@lindle/sharepoint_requests 0.1.12 → 0.1.14

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 (37) hide show
  1. package/dist/root/index.d.ts +16 -217
  2. package/dist/root/internal/context.d.ts +9 -0
  3. package/dist/root/internal/digest.d.ts +2 -0
  4. package/dist/root/internal/emailRequests.d.ts +10 -0
  5. package/dist/root/internal/listRequests/createAttachment.d.ts +3 -0
  6. package/dist/root/internal/listRequests/createListItem.d.ts +3 -0
  7. package/dist/root/internal/listRequests/deleteItem.d.ts +3 -0
  8. package/dist/root/internal/listRequests/getFiles.d.ts +8 -0
  9. package/dist/root/internal/listRequests/getListItems.d.ts +8 -0
  10. package/dist/root/internal/listRequests/getOnly.d.ts +3 -0
  11. package/dist/root/internal/listRequests/index.d.ts +7 -0
  12. package/dist/root/internal/listRequests/updateListItem.d.ts +3 -0
  13. package/dist/root/internal/odata.d.ts +5 -0
  14. package/dist/root/internal/userRequests.d.ts +15 -0
  15. package/dist/sharepoint_requests.cjs.development.js +596 -756
  16. package/dist/sharepoint_requests.cjs.development.js.map +1 -1
  17. package/dist/sharepoint_requests.cjs.production.min.js +1 -1
  18. package/dist/sharepoint_requests.cjs.production.min.js.map +1 -1
  19. package/dist/sharepoint_requests.esm.js +596 -756
  20. package/dist/sharepoint_requests.esm.js.map +1 -1
  21. package/dist/types.d.ts +38 -7
  22. package/package.json +1 -1
  23. package/src/root/index.ts +194 -598
  24. package/src/root/internal/context.ts +10 -0
  25. package/src/root/internal/digest.ts +22 -0
  26. package/src/root/internal/emailRequests.ts +45 -0
  27. package/src/root/internal/listRequests/createAttachment.ts +18 -0
  28. package/src/root/internal/listRequests/createListItem.ts +35 -0
  29. package/src/root/internal/listRequests/deleteItem.ts +10 -0
  30. package/src/root/internal/listRequests/getFiles.ts +31 -0
  31. package/src/root/internal/listRequests/getListItems.ts +50 -0
  32. package/src/root/internal/listRequests/getOnly.ts +18 -0
  33. package/src/root/internal/listRequests/index.ts +7 -0
  34. package/src/root/internal/listRequests/updateListItem.ts +32 -0
  35. package/src/root/internal/odata.ts +36 -0
  36. package/src/root/internal/userRequests.ts +109 -0
  37. package/src/types.ts +76 -36
@@ -1,87 +1,47 @@
1
- import { AxiosResponse, CreateAxiosDefaults as AxiosConfig } from 'axios';
2
- import { CreateFileProps, CurrentUser, EmailProps, Field_Options, Folder_Options, IListName, ItemID, ListData, Options, PersonField, SHAREPOINT_VER, SPItem, UserPermision, UserProfile } from '../types';
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
3
  declare class HTTPSharePointRequests<T extends {
4
- LISTS: Record<string, any>;
5
- FOLDERS?: Record<string, any>;
4
+ LISTS: Record<string, unknown>;
5
+ FOLDERS?: Record<string, unknown>;
6
6
  }> {
7
7
  private baseURL;
8
8
  private endpoint;
9
9
  private listName;
10
10
  private instance;
11
- /**
12
- * Creates an HTTP SharePoint requester bound to the provided base URL.
13
- *
14
- * @param baseURL The root SharePoint site URL (with or without trailing slash).
15
- * @param config Optional axios configuration overrides.
16
- */
11
+ private sharepointVersion;
17
12
  constructor(baseURL: string, config?: AxiosConfig);
18
- /**
19
- * Converts array values in a payload to the `Collection(Edm.String)` structure
20
- * expected by SharePoint REST endpoints.
21
- *
22
- * @param data The list item payload to harmonise in-place.
23
- */
24
- private transformArraysToEdmStrings;
13
+ private getContext;
25
14
  /**
26
15
  * @deprecated Use `from` instead.
27
16
  */
28
17
  list(listName: IListName<T>): this;
29
18
  readonly lists: {
30
- /**
31
- * Fetches all SharePoint lists available to the current site.
32
- *
33
- * @returns Promise resolving to the list collection response payload.
34
- */
35
19
  get: () => Promise<{
36
- data: any[];
20
+ data: Partial<import("../types").SPItem2013>[];
37
21
  meta: {
38
22
  url: URL;
39
23
  };
40
24
  }>;
41
25
  };
42
- /**
43
- * Selects a SharePoint list and exposes list-scoped CRUD helpers.
44
- *
45
- * @param listName Logical list key configured in the generic type map.
46
- * @param sharepoint_ver SharePoint version used to choose the correct REST endpoint.
47
- * @returns Chainable helpers bound to the selected list.
48
- */
49
- from<K extends Extract<keyof T['LISTS'], string>>(listName: K, sharepoint_ver?: SHAREPOINT_VER): {
50
- create: (data: ListData) => Promise<AxiosResponse<any, any, {}>>;
51
- get: (options?: Options<T['LISTS'][K]>) => Promise<{
52
- data: (T["LISTS"][K] & Partial<SPItem>)[];
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>>)[];
53
30
  meta: {
54
31
  url: URL;
55
32
  };
56
33
  }>;
57
- update: (id: ItemID, data: ListData, digest?: string) => Promise<AxiosResponse<any, any, {}>>;
58
- delete: (id: ItemID) => Promise<AxiosResponse<any, any, {}>>;
59
- createFile: (props: CreateFileProps) => Promise<AxiosResponse<any, any, {}>>;
60
- fields: (options?: Field_Options<T['LISTS'][K]>) => {
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>) => {
61
38
  get: () => Promise<any>;
62
39
  };
63
40
  };
64
41
  folders: {
65
- /**
66
- * Retrieves SharePoint folders from the default folders endpoint.
67
- *
68
- * @returns A promise resolving with folder metadata.
69
- */
70
42
  get: () => void;
71
43
  };
72
- /**
73
- * Targets a SharePoint folder path and exposes file retrieval helpers.
74
- *
75
- * @param folderName Optional folder path relative to `Shared Documents`.
76
- * @returns Helper exposing `get` to fetch files or sub-folders.
77
- */
78
44
  folder(folderName?: string | string[]): {
79
- /**
80
- * Fetches files or folders from the targeted path.
81
- *
82
- * @param options Optional REST query options to refine the result set.
83
- * @returns Promise resolving to folder contents and metadata.
84
- */
85
45
  get: (options?: Folder_Options<any>) => Promise<{
86
46
  data: any;
87
47
  meta: {
@@ -89,18 +49,7 @@ declare class HTTPSharePointRequests<T extends {
89
49
  };
90
50
  }>;
91
51
  };
92
- /**
93
- * Retrieves user list items and exposes a get helper with optional query parameters.
94
- *
95
- * @param options Optional REST query options.
96
- * @returns Helper exposing `get` returning SharePoint user rows.
97
- */
98
52
  users(options?: Options<any>): {
99
- /**
100
- * Executes the user list request using the specified options.
101
- *
102
- * @returns Promise resolving to the SharePoint user list response.
103
- */
104
53
  get: () => Promise<{
105
54
  data: any[];
106
55
  meta: {
@@ -108,175 +57,25 @@ declare class HTTPSharePointRequests<T extends {
108
57
  };
109
58
  }>;
110
59
  };
111
- /**
112
- * Asynchronously retrieves the Form Digest Value from the context information API.
113
- *
114
- * @returns {Promise<string>} A promise that resolves to the Form Digest Value.
115
- * @throws {Error} If the HTTP request fails or the response does not contain the expected data.
116
- */
117
- private getDigest;
118
- /**
119
- * Executes a GET request without additional metadata wrapping.
120
- *
121
- * @param options Optional REST query options.
122
- * @returns SharePoint response payload or undefined when empty.
123
- */
124
- private get_only;
125
- /**
126
- * Retrieves folder contents with optional filtering and returns the payload with metadata.
127
- *
128
- * @param options REST options describing expand/filter/order conditions.
129
- * @returns Folder data and the fully resolved request URL.
130
- */
131
- private get_files;
132
- /**
133
- * Performs a typed list read against the current endpoint.
134
- *
135
- * @param options Optional REST query options governing expand, filter, ordering and pagination.
136
- * @returns SharePoint list items alongside the fully-resolved request URL.
137
- */
138
- private get_v2;
139
- /**
140
- * Updates an item in the currently selected list.
141
- *
142
- * @param id Target list item identifier.
143
- * @param data Payload with fields to update.
144
- * @param digest Optional pre-fetched form digest to reuse.
145
- * @returns Axios response of the update request.
146
- */
147
- private update_2;
148
- /**
149
- * Creates a new item within the active list.
150
- *
151
- * @param listData SharePoint list item payload.
152
- * @returns Axios response resolved from the create request.
153
- */
154
- private create_v2;
155
- /**
156
- * Uploads an attachment file to an existing list item.
157
- *
158
- * @param props File payload and target item identifier.
159
- * @returns Axios response describing the upload result.
160
- */
161
- private createFile;
162
- /**
163
- * Deletes an item using the current endpoint.
164
- *
165
- * @param ID Identifier of the entity to remove.
166
- * @returns Axios response from the delete call.
167
- */
168
- private delete;
169
60
  email: {
170
- /**
171
- * Sends an email using SharePoint's Utility.SendEmail API.
172
- *
173
- * @param {EmailProps} param0 - The email properties.
174
- * @param {string} param0.From - The sender's email address.
175
- * @example
176
- * Example of a sender's email address
177
- * "sender@example.com"
178
- * @param {string | string[]} param0.To - The recipient's email address or an array of email addresses.
179
- * @example
180
- * Example of a single recipient's email address
181
- * "recipient@example.com"
182
- * Example of multiple recipients' email addresses
183
- * ["recipient1@example.com", "recipient2@example.com"]
184
- * @param {string} param0.Subject - The subject of the email.
185
- * @example
186
- * Example of an email subject
187
- * "Meeting Reminder"
188
- * @param {string} param0.Body - The body content of the email.
189
- * @example
190
- * Example of an email body
191
- * "Dear team, please be reminded of the meeting scheduled for tomorrow at 10 AM."
192
- * @returns {Promise<any>} - A promise that resolves to the response of the email send request.
193
- */
194
- send: (props: EmailProps) => Promise<AxiosResponse<{
61
+ send: (props: EmailProps) => Promise<import("axios").AxiosResponse<{
195
62
  d: {
196
63
  SendEmail: null;
197
64
  };
198
65
  }, any, {}>>;
199
66
  };
200
- private sendEmail;
201
- /**
202
- * Queries SharePoint's people picker endpoint for matching users.
203
- *
204
- * @param input Free-text search term.
205
- * @param filter Optional additional filter condition.
206
- * @returns Promise with type-ahead results payload.
207
- */
208
- private typeAhead;
209
- /**
210
- * Retrieves the current user profile and flattens selected properties.
211
- *
212
- * @returns Promise containing the current user's profile information.
213
- */
214
- private currentUserProperties;
215
67
  user: {
216
- /**
217
- * Provides accessors for the current user's profile information.
218
- *
219
- * @returns Helper exposing a `get` function to retrieve profile details.
220
- */
221
68
  properties: () => {
222
69
  get: () => Promise<UserProfile>;
223
70
  };
224
- /**
225
- * Searches across site users and their groups.
226
- *
227
- * @param searchValue Query string to match site users.
228
- * @returns Promise resolving to matching site users.
229
- */
230
71
  searchSiteUser: (searchValue: string) => Promise<any>;
231
- /**
232
- * Performs a people-picker search scoped to the current site collection.
233
- *
234
- * @param input Search prefix.
235
- * @param filter Optional additional filter condition.
236
- * @returns Promise with type-ahead person results.
237
- */
238
72
  searchUser: (input: string, filter?: string) => Promise<PersonField>;
239
- /**
240
- * Fetches the currently authenticated SharePoint user.
241
- *
242
- * @returns Helper exposing `get` that resolves to the current user payload.
243
- */
244
73
  current: () => {
245
74
  get: () => Promise<CurrentUser>;
246
75
  };
247
- /**
248
- * Retrieves calculated permission level for the current user.
249
- *
250
- * @returns Helper exposing `get` resolving to the user's permission definition.
251
- */
252
76
  currentPermission: () => {
253
77
  get: () => Promise<UserPermision>;
254
78
  };
255
79
  };
256
- /**
257
- * Searches site users based on a substring match across common fields.
258
- *
259
- * @param searchValue Term to match against the SharePoint user directory.
260
- * @returns Promise with matching site users and their groups.
261
- */
262
- private getSiteUser;
263
- /**
264
- * Retrieves all available role definitions for the current site.
265
- *
266
- * @returns Promise resolving to an array of role definitions.
267
- */
268
- private roleDefinitions;
269
- /**
270
- * Fetches the bit-encoded permissions of the current user.
271
- *
272
- * @returns Promise resolving to the `EffectiveBasePermissions` object.
273
- */
274
- private getEffectiveBasePermissions;
275
- /**
276
- * Matches the current user's effective permissions against known role definitions.
277
- *
278
- * @returns The matching SharePoint role definition as a structured permission object.
279
- */
280
- private currentUserPermissions;
281
80
  }
282
81
  export default HTTPSharePointRequests;
@@ -0,0 +1,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
+ }
@@ -0,0 +1,2 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ export declare function fetchDigest(instance: AxiosInstance, baseURL: string): Promise<string>;
@@ -0,0 +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 {};
@@ -0,0 +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, {}>>;
@@ -0,0 +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, {}>>;
@@ -0,0 +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, {}>>;
@@ -0,0 +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
+ }>;
@@ -0,0 +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
+ }>;
@@ -0,0 +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>;
@@ -0,0 +1,7 @@
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';
@@ -0,0 +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, {}>>;
@@ -0,0 +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 {};
@@ -0,0 +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 {};