@lindle/sharepoint_requests 0.1.13 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +5 -0
  2. package/dist/index.d.ts +17 -17
  3. package/dist/root/index.d.ts +85 -81
  4. package/dist/root/instance.d.ts +3 -3
  5. package/dist/root/internal/context.d.ts +11 -9
  6. package/dist/root/internal/digest.d.ts +2 -2
  7. package/dist/root/internal/emailRequests.d.ts +10 -10
  8. package/dist/root/internal/listRequests/createAttachment.d.ts +3 -3
  9. package/dist/root/internal/listRequests/createListItem.d.ts +3 -3
  10. package/dist/root/internal/listRequests/deleteItem.d.ts +3 -3
  11. package/dist/root/internal/listRequests/getFiles.d.ts +8 -8
  12. package/dist/root/internal/listRequests/getListItems.d.ts +8 -8
  13. package/dist/root/internal/listRequests/getOnly.d.ts +3 -3
  14. package/dist/root/internal/listRequests/index.d.ts +8 -7
  15. package/dist/root/internal/listRequests/updateListItem.d.ts +3 -3
  16. package/dist/root/internal/listRequests/uploadFile.d.ts +3 -0
  17. package/dist/root/internal/odata.d.ts +5 -5
  18. package/dist/root/internal/userRequests.d.ts +15 -15
  19. package/dist/sharepoint_requests.cjs.development.js +232 -52
  20. package/dist/sharepoint_requests.cjs.development.js.map +1 -1
  21. package/dist/sharepoint_requests.cjs.production.min.js +1 -1
  22. package/dist/sharepoint_requests.cjs.production.min.js.map +1 -1
  23. package/dist/sharepoint_requests.esm.js +232 -52
  24. package/dist/sharepoint_requests.esm.js.map +1 -1
  25. package/dist/types.d.ts +237 -232
  26. package/package.json +6 -3
  27. package/src/root/index.ts +51 -2
  28. package/src/root/internal/context.ts +2 -0
  29. package/src/root/internal/listRequests/createListItem.ts +18 -13
  30. package/src/root/internal/listRequests/index.ts +1 -0
  31. package/src/root/internal/listRequests/updateListItem.ts +21 -3
  32. package/src/root/internal/listRequests/uploadFile.ts +66 -0
  33. package/src/types.ts +10 -5
package/README.md CHANGED
@@ -79,6 +79,10 @@ console.log('Item deleted successfully');
79
79
  const file = new File(['content'], 'example.txt');
80
80
  await sharepoint.from('ListName').createFile({ file, itemId: 1 });
81
81
  console.log('File uploaded successfully');
82
+
83
+ const doc = new File(['doc content'], 'document.pdf');
84
+ await sharepoint.from('Documents', '2013').uploadFile({ file: doc, folderPath: 'Shared/SubFolder' });
85
+ console.log('Library file uploaded successfully');
82
86
  ```
83
87
 
84
88
  #### Send Emails
@@ -160,6 +164,7 @@ The package is fully typed, enabling autocompletion and type safety for all meth
160
164
  #### Files
161
165
 
162
166
  - `createFile({ file, itemId })` - Upload a file to a list item.
167
+ - `uploadFile({ file, folderPath, overwrite })` - Upload a file to a document library (SharePoint 2013).
163
168
 
164
169
  ## Development
165
170
 
package/dist/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- import SHAREPOINT_REQUESTS from './root';
2
- import type { CreateAxiosDefaults as AxiosConfig } from 'axios';
3
- import type { LookupField, ChoiceField, PersonField } from './types';
4
- export default function createBase<T extends {
5
- LISTS: Record<string, any>;
6
- FOLDERS?: Record<string, any>;
7
- } = any>(): {
8
- /**
9
- * @deprecated Use `create` instead.
10
- */
11
- baseURL(url: string, config?: AxiosConfig): SHAREPOINT_REQUESTS<T>;
12
- create: ({ baseURL, config, }: {
13
- baseURL: string;
14
- config?: AxiosConfig;
15
- }) => SHAREPOINT_REQUESTS<T>;
16
- };
17
- export { LookupField, ChoiceField, PersonField };
1
+ import SHAREPOINT_REQUESTS from './root';
2
+ import type { CreateAxiosDefaults as AxiosConfig } from 'axios';
3
+ import type { LookupField, ChoiceField, PersonField } from './types';
4
+ export default function createBase<T extends {
5
+ LISTS: Record<string, any>;
6
+ FOLDERS?: Record<string, any>;
7
+ } = any>(): {
8
+ /**
9
+ * @deprecated Use `create` instead.
10
+ */
11
+ baseURL(url: string, config?: AxiosConfig): SHAREPOINT_REQUESTS<T>;
12
+ create: ({ baseURL, config, }: {
13
+ baseURL: string;
14
+ config?: AxiosConfig;
15
+ }) => SHAREPOINT_REQUESTS<T>;
16
+ };
17
+ export { LookupField, ChoiceField, PersonField };
@@ -1,81 +1,85 @@
1
- import { CreateAxiosDefaults as AxiosConfig } from 'axios';
2
- import { CreateFileProps, CurrentUser, EmailProps, Field_Options, Folder_Options, IListName, ItemID, ListData, Options, PersonField, SHAREPOINT_VER, UserPermision, UserProfile } from '../types';
3
- declare class HTTPSharePointRequests<T extends {
4
- LISTS: Record<string, unknown>;
5
- FOLDERS?: Record<string, unknown>;
6
- }> {
7
- private baseURL;
8
- private endpoint;
9
- private listName;
10
- private instance;
11
- private sharepointVersion;
12
- constructor(baseURL: string, config?: AxiosConfig);
13
- private getContext;
14
- /**
15
- * @deprecated Use `from` instead.
16
- */
17
- list(listName: IListName<T>): this;
18
- readonly lists: {
19
- get: () => Promise<{
20
- data: Partial<import("../types").SPItem2013>[];
21
- meta: {
22
- url: URL;
23
- };
24
- }>;
25
- };
26
- from<K extends Extract<keyof T['LISTS'], string>, V extends SHAREPOINT_VER = '2013'>(listName: K, sharepoint_ver?: V): {
27
- create: (data: ListData) => Promise<import("axios").AxiosResponse<any, any, {}>>;
28
- get: (options?: Options<T['LISTS'][K], V>) => Promise<{
29
- data: (T["LISTS"][K] & Partial<import("../types").SPItem<V>>)[];
30
- meta: {
31
- url: URL;
32
- };
33
- }>;
34
- update: (id: ItemID, data: ListData, digest?: string) => Promise<import("axios").AxiosResponse<any, any, {}>>;
35
- delete: (id: ItemID) => Promise<import("axios").AxiosResponse<any, any, {}>>;
36
- createFile: (props: CreateFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
37
- fields: (options?: Field_Options<T['LISTS'][K], V>) => {
38
- get: () => Promise<any>;
39
- };
40
- };
41
- folders: {
42
- get: () => void;
43
- };
44
- folder(folderName?: string | string[]): {
45
- get: (options?: Folder_Options<any>) => Promise<{
46
- data: any;
47
- meta: {
48
- url: URL;
49
- };
50
- }>;
51
- };
52
- users(options?: Options<any>): {
53
- get: () => Promise<{
54
- data: any[];
55
- meta: {
56
- url: URL;
57
- };
58
- }>;
59
- };
60
- email: {
61
- send: (props: EmailProps) => Promise<import("axios").AxiosResponse<{
62
- d: {
63
- SendEmail: null;
64
- };
65
- }, any, {}>>;
66
- };
67
- user: {
68
- properties: () => {
69
- get: () => Promise<UserProfile>;
70
- };
71
- searchSiteUser: (searchValue: string) => Promise<any>;
72
- searchUser: (input: string, filter?: string) => Promise<PersonField>;
73
- current: () => {
74
- get: () => Promise<CurrentUser>;
75
- };
76
- currentPermission: () => {
77
- get: () => Promise<UserPermision>;
78
- };
79
- };
80
- }
81
- export default HTTPSharePointRequests;
1
+ import { CreateAxiosDefaults as AxiosConfig } from 'axios';
2
+ import { CreateFileProps, CurrentUser, EmailProps, Field_Options, Folder_Options, UploadFileProps, IListName, ItemID, ListData, Options, PersonField, SHAREPOINT_VER, UserPermision, UserProfile } from '../types';
3
+ declare class HTTPSharePointRequests<T extends {
4
+ LISTS: Record<string, unknown>;
5
+ FOLDERS?: Record<string, unknown>;
6
+ }> {
7
+ private baseURL;
8
+ private endpoint;
9
+ private listName;
10
+ private instance;
11
+ private sharepointVersion;
12
+ private listItemEntityTypeFullName?;
13
+ constructor(baseURL: string, config?: AxiosConfig);
14
+ private getContext;
15
+ private resolveListItemEntityTypeFullName;
16
+ /**
17
+ * @deprecated Use `from` instead.
18
+ */
19
+ list(listName: IListName<T>): this;
20
+ readonly lists: {
21
+ get: () => Promise<{
22
+ data: Partial<import("../types").SPItem2013>[];
23
+ meta: {
24
+ url: URL;
25
+ };
26
+ }>;
27
+ };
28
+ getDigest(): Promise<string>;
29
+ from<K extends Extract<keyof T['LISTS'], string>, V extends SHAREPOINT_VER = '2013'>(listName: K, sharepoint_ver?: V): {
30
+ create: (data: ListData) => Promise<import("axios").AxiosResponse<any, any, {}>>;
31
+ get: (options?: Options<T["LISTS"][K], V>) => Promise<{
32
+ data: (T["LISTS"][K] & Partial<import("../types").SPItem<V>>)[];
33
+ meta: {
34
+ url: URL;
35
+ };
36
+ }>;
37
+ update: (id: ItemID, data: ListData, digest?: string) => Promise<import("axios").AxiosResponse<any, any, {}>>;
38
+ delete: (id: ItemID) => Promise<import("axios").AxiosResponse<any, any, {}>>;
39
+ createFile: (props: CreateFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
40
+ uploadFile: (props: UploadFileProps) => Promise<import("axios").AxiosResponse<any, any, {}>>;
41
+ fields: (options?: Field_Options<T["LISTS"][K], V>) => {
42
+ get: () => Promise<any>;
43
+ };
44
+ };
45
+ folders: {
46
+ get: () => void;
47
+ };
48
+ folder(folderName?: string | string[]): {
49
+ get: (options?: Folder_Options<any>) => Promise<{
50
+ data: any;
51
+ meta: {
52
+ url: URL;
53
+ };
54
+ }>;
55
+ };
56
+ users(options?: Options<any>): {
57
+ get: () => Promise<{
58
+ data: any[];
59
+ meta: {
60
+ url: URL;
61
+ };
62
+ }>;
63
+ };
64
+ email: {
65
+ send: (props: EmailProps) => Promise<import("axios").AxiosResponse<{
66
+ d: {
67
+ SendEmail: null;
68
+ };
69
+ }, any, {}>>;
70
+ };
71
+ user: {
72
+ properties: () => {
73
+ get: () => Promise<UserProfile>;
74
+ };
75
+ searchSiteUser: (searchValue: string) => Promise<any>;
76
+ searchUser: (input: string, filter?: string) => Promise<PersonField>;
77
+ current: () => {
78
+ get: () => Promise<CurrentUser>;
79
+ };
80
+ currentPermission: () => {
81
+ get: () => Promise<UserPermision>;
82
+ };
83
+ };
84
+ }
85
+ export default HTTPSharePointRequests;
@@ -1,3 +1,3 @@
1
- import { CreateAxiosDefaults as AxiosConfig } from 'axios';
2
- export declare const instance: (baseURL: string, config?: AxiosConfig) => import("axios").AxiosInstance;
3
- export default instance;
1
+ import { CreateAxiosDefaults as AxiosConfig } from 'axios';
2
+ export declare const instance: (baseURL: string, config?: AxiosConfig) => import("axios").AxiosInstance;
3
+ export default instance;
@@ -1,9 +1,11 @@
1
- import type { AxiosInstance } from 'axios';
2
- import type { SHAREPOINT_VER } from '../../types';
3
- export interface RequestContext<V extends SHAREPOINT_VER = '2013'> {
4
- instance: AxiosInstance;
5
- baseURL: string;
6
- endpoint: string;
7
- listName: string;
8
- sharepointVersion: V;
9
- }
1
+ import type { AxiosInstance } from 'axios';
2
+ import type { SHAREPOINT_VER } from '../../types';
3
+ export interface RequestContext<V extends SHAREPOINT_VER = '2013'> {
4
+ instance: AxiosInstance;
5
+ baseURL: string;
6
+ endpoint: string;
7
+ listName: string;
8
+ sharepointVersion: V;
9
+ listItemEntityTypeFullName?: string;
10
+ resolveListItemEntityType?: () => Promise<string>;
11
+ }
@@ -1,2 +1,2 @@
1
- import type { AxiosInstance } from 'axios';
2
- export declare function fetchDigest(instance: AxiosInstance, baseURL: string): Promise<string>;
1
+ import type { AxiosInstance } from 'axios';
2
+ export declare function fetchDigest(instance: AxiosInstance, baseURL: string): Promise<string>;
@@ -1,10 +1,10 @@
1
- import type { AxiosResponse } from 'axios';
2
- import type { EmailProps } from '../../types';
3
- import type { RequestContext } from './context';
4
- declare type SendEmailResponse = AxiosResponse<{
5
- d: {
6
- SendEmail: null;
7
- };
8
- }>;
9
- export declare function sendEmail(context: RequestContext, { From, To, Subject, Body }: EmailProps): Promise<SendEmailResponse>;
10
- export {};
1
+ import type { AxiosResponse } from 'axios';
2
+ import type { EmailProps } from '../../types';
3
+ import type { RequestContext } from './context';
4
+ type SendEmailResponse = AxiosResponse<{
5
+ d: {
6
+ SendEmail: null;
7
+ };
8
+ }>;
9
+ export declare function sendEmail(context: RequestContext, { From, To, Subject, Body }: EmailProps): Promise<SendEmailResponse>;
10
+ export {};
@@ -1,3 +1,3 @@
1
- import type { CreateFileProps, SHAREPOINT_VER } from '../../../types';
2
- import type { RequestContext } from '../context';
3
- export declare function createAttachment<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, { file, itemId }: CreateFileProps): Promise<import("axios").AxiosResponse<any, any, {}>>;
1
+ import type { CreateFileProps, SHAREPOINT_VER } from '../../../types';
2
+ import type { RequestContext } from '../context';
3
+ export declare function createAttachment<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, { file, itemId }: CreateFileProps): Promise<import("axios").AxiosResponse<any, any, {}>>;
@@ -1,3 +1,3 @@
1
- import type { ListData, SHAREPOINT_VER } from '../../../types';
2
- import type { RequestContext } from '../context';
3
- export declare function createListItem<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, listData: ListData): Promise<import("axios").AxiosResponse<any, any, {}>>;
1
+ import type { ListData, SHAREPOINT_VER } from '../../../types';
2
+ import type { RequestContext } from '../context';
3
+ export declare function createListItem<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, listData: ListData): Promise<import("axios").AxiosResponse<any, any, {}>>;
@@ -1,3 +1,3 @@
1
- import type { SHAREPOINT_VER } from '../../../types';
2
- import type { RequestContext } from '../context';
3
- export declare function deleteItem<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, id: number | string): Promise<import("axios").AxiosResponse<any, any, {}>>;
1
+ import type { SHAREPOINT_VER } from '../../../types';
2
+ import type { RequestContext } from '../context';
3
+ export declare function deleteItem<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, id: number | string): Promise<import("axios").AxiosResponse<any, any, {}>>;
@@ -1,8 +1,8 @@
1
- import type { Folder_Options, SHAREPOINT_VER } from '../../../types';
2
- import type { RequestContext } from '../context';
3
- export declare function getFiles<T, V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, options?: Folder_Options<T>): Promise<{
4
- data: any;
5
- meta: {
6
- url: URL;
7
- };
8
- }>;
1
+ import type { Folder_Options, SHAREPOINT_VER } from '../../../types';
2
+ import type { RequestContext } from '../context';
3
+ export declare function getFiles<T, V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, options?: Folder_Options<T>): Promise<{
4
+ data: any;
5
+ meta: {
6
+ url: URL;
7
+ };
8
+ }>;
@@ -1,8 +1,8 @@
1
- import type { Options, SPItem, SHAREPOINT_VER } from '../../../types';
2
- import type { RequestContext } from '../context';
3
- export declare function getListItems<K, V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, options?: Options<K, V>): Promise<{
4
- data: (K & Partial<SPItem<V>>)[];
5
- meta: {
6
- url: URL;
7
- };
8
- }>;
1
+ import type { Options, SPItem, SHAREPOINT_VER } from '../../../types';
2
+ import type { RequestContext } from '../context';
3
+ export declare function getListItems<K, V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, options?: Options<K, V>): Promise<{
4
+ data: (K & Partial<SPItem<V>>)[];
5
+ meta: {
6
+ url: URL;
7
+ };
8
+ }>;
@@ -1,3 +1,3 @@
1
- import type { AxiosInstance } from 'axios';
2
- import type { Options, SHAREPOINT_VER } from '../../../types';
3
- export declare function getOnly<T, V extends SHAREPOINT_VER = '2013'>(instance: AxiosInstance, endpoint: string, options?: Options<T, V>): Promise<any>;
1
+ import type { AxiosInstance } from 'axios';
2
+ import type { Options, SHAREPOINT_VER } from '../../../types';
3
+ export declare function getOnly<T, V extends SHAREPOINT_VER = '2013'>(instance: AxiosInstance, endpoint: string, options?: Options<T, V>): Promise<any>;
@@ -1,7 +1,8 @@
1
- export { createListItem } from './createListItem';
2
- export { createAttachment } from './createAttachment';
3
- export { deleteItem } from './deleteItem';
4
- export { getFiles } from './getFiles';
5
- export { getListItems } from './getListItems';
6
- export { getOnly } from './getOnly';
7
- export { updateListItem } from './updateListItem';
1
+ export { createListItem } from './createListItem';
2
+ export { createAttachment } from './createAttachment';
3
+ export { deleteItem } from './deleteItem';
4
+ export { getFiles } from './getFiles';
5
+ export { getListItems } from './getListItems';
6
+ export { getOnly } from './getOnly';
7
+ export { updateListItem } from './updateListItem';
8
+ export { uploadFile } from './uploadFile';
@@ -1,3 +1,3 @@
1
- import type { ListData, SHAREPOINT_VER } from '../../../types';
2
- import type { RequestContext } from '../context';
3
- export declare function updateListItem<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, id: number | string, data: ListData, digest?: string): Promise<import("axios").AxiosResponse<any, any, {}>>;
1
+ import type { ListData, SHAREPOINT_VER } from '../../../types';
2
+ import type { RequestContext } from '../context';
3
+ export declare function updateListItem<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, id: number | string, data: ListData, digest?: string): Promise<import("axios").AxiosResponse<any, any, {}>>;
@@ -0,0 +1,3 @@
1
+ import type { SHAREPOINT_VER, UploadFileProps } from '../../../types';
2
+ import type { RequestContext } from '../context';
3
+ export declare function uploadFile<V extends SHAREPOINT_VER = '2013'>(context: RequestContext<V>, { file, folderPath, overwrite }: UploadFileProps): Promise<import("axios").AxiosResponse<any, any, {}>>;
@@ -1,5 +1,5 @@
1
- import type { Folder_Options, Options, SHAREPOINT_VER } from '../../types';
2
- declare type QueryableOptions<T, V extends SHAREPOINT_VER = '2013'> = Options<T, V> | Folder_Options<T>;
3
- export declare function buildODataParams<T, V extends SHAREPOINT_VER = '2013'>(options: QueryableOptions<T, V> | undefined, orderBySeparator?: ',' | ' '): Record<string, string | number>;
4
- export declare function appendParamsToUrl(baseUrl: URL, params: Record<string, string | number | undefined | null>): void;
5
- export {};
1
+ import type { Folder_Options, Options, SHAREPOINT_VER } from '../../types';
2
+ type QueryableOptions<T, V extends SHAREPOINT_VER = '2013'> = Options<T, V> | Folder_Options<T>;
3
+ export declare function buildODataParams<T, V extends SHAREPOINT_VER = '2013'>(options: QueryableOptions<T, V> | undefined, orderBySeparator?: ',' | ' '): Record<string, string | number>;
4
+ export declare function appendParamsToUrl(baseUrl: URL, params: Record<string, string | number | undefined | null>): void;
5
+ export {};
@@ -1,15 +1,15 @@
1
- import type { AxiosInstance } from 'axios';
2
- import type { PersonField, UserPermision, UserProfile } from '../../types';
3
- import type { RequestContext } from './context';
4
- declare type RoleDefinition = {
5
- BasePermissions: {
6
- High: string;
7
- };
8
- };
9
- export declare function typeAhead(instance: AxiosInstance, input: string, filter?: string): Promise<PersonField>;
10
- export declare function currentUserProperties(instance: AxiosInstance): Promise<UserProfile>;
11
- export declare function getSiteUser(instance: AxiosInstance, searchValue: string): Promise<any>;
12
- export declare function roleDefinitions(instance: AxiosInstance): Promise<RoleDefinition[]>;
13
- export declare function getEffectiveBasePermissions(instance: AxiosInstance): Promise<any>;
14
- export declare function currentUserPermissions(context: RequestContext): Promise<UserPermision>;
15
- export {};
1
+ import type { AxiosInstance } from 'axios';
2
+ import type { PersonField, UserPermision, UserProfile } from '../../types';
3
+ import type { RequestContext } from './context';
4
+ type RoleDefinition = {
5
+ BasePermissions: {
6
+ High: string;
7
+ };
8
+ };
9
+ export declare function typeAhead(instance: AxiosInstance, input: string, filter?: string): Promise<PersonField>;
10
+ export declare function currentUserProperties(instance: AxiosInstance): Promise<UserProfile>;
11
+ export declare function getSiteUser(instance: AxiosInstance, searchValue: string): Promise<any>;
12
+ export declare function roleDefinitions(instance: AxiosInstance): Promise<RoleDefinition[]>;
13
+ export declare function getEffectiveBasePermissions(instance: AxiosInstance): Promise<any>;
14
+ export declare function currentUserPermissions(context: RequestContext): Promise<UserPermision>;
15
+ export {};