@lindle/sharepoint_requests 0.1.10 → 0.1.12

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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import SHAREPOINT_REQUESTS from './root';
2
+ import type { CreateAxiosDefaults as AxiosConfig } from 'axios';
2
3
  import type { LookupField, ChoiceField, PersonField } from './types';
3
4
  export default function createBase<T extends {
4
5
  LISTS: Record<string, any>;
@@ -7,9 +8,10 @@ export default function createBase<T extends {
7
8
  /**
8
9
  * @deprecated Use `create` instead.
9
10
  */
10
- baseURL(url: string): SHAREPOINT_REQUESTS<T>;
11
- create: ({ baseURL }: {
11
+ baseURL(url: string, config?: AxiosConfig): SHAREPOINT_REQUESTS<T>;
12
+ create: ({ baseURL, config, }: {
12
13
  baseURL: string;
14
+ config?: AxiosConfig;
13
15
  }) => SHAREPOINT_REQUESTS<T>;
14
16
  };
15
17
  export { LookupField, ChoiceField, PersonField };
@@ -1,4 +1,4 @@
1
- import { AxiosResponse } from 'axios';
1
+ import { AxiosResponse, CreateAxiosDefaults as AxiosConfig } from 'axios';
2
2
  import { CreateFileProps, CurrentUser, EmailProps, Field_Options, Folder_Options, IListName, ItemID, ListData, Options, PersonField, SHAREPOINT_VER, SPItem, UserPermision, UserProfile } from '../types';
3
3
  declare class HTTPSharePointRequests<T extends {
4
4
  LISTS: Record<string, any>;
@@ -8,13 +8,30 @@ declare class HTTPSharePointRequests<T extends {
8
8
  private endpoint;
9
9
  private listName;
10
10
  private instance;
11
- constructor(baseURL: string);
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
+ */
17
+ 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
+ */
12
24
  private transformArraysToEdmStrings;
13
25
  /**
14
26
  * @deprecated Use `from` instead.
15
27
  */
16
28
  list(listName: IListName<T>): this;
17
29
  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
+ */
18
35
  get: () => Promise<{
19
36
  data: any[];
20
37
  meta: {
@@ -22,6 +39,13 @@ declare class HTTPSharePointRequests<T extends {
22
39
  };
23
40
  }>;
24
41
  };
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
+ */
25
49
  from<K extends Extract<keyof T['LISTS'], string>>(listName: K, sharepoint_ver?: SHAREPOINT_VER): {
26
50
  create: (data: ListData) => Promise<AxiosResponse<any, any, {}>>;
27
51
  get: (options?: Options<T['LISTS'][K]>) => Promise<{
@@ -38,9 +62,26 @@ declare class HTTPSharePointRequests<T extends {
38
62
  };
39
63
  };
40
64
  folders: {
65
+ /**
66
+ * Retrieves SharePoint folders from the default folders endpoint.
67
+ *
68
+ * @returns A promise resolving with folder metadata.
69
+ */
41
70
  get: () => void;
42
71
  };
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
+ */
43
78
  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
+ */
44
85
  get: (options?: Folder_Options<any>) => Promise<{
45
86
  data: any;
46
87
  meta: {
@@ -48,7 +89,18 @@ declare class HTTPSharePointRequests<T extends {
48
89
  };
49
90
  }>;
50
91
  };
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
+ */
51
98
  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
+ */
52
104
  get: () => Promise<{
53
105
  data: any[];
54
106
  meta: {
@@ -63,12 +115,56 @@ declare class HTTPSharePointRequests<T extends {
63
115
  * @throws {Error} If the HTTP request fails or the response does not contain the expected data.
64
116
  */
65
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
+ */
66
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
+ */
67
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
+ */
68
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
+ */
69
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
+ */
70
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
+ */
71
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
+ */
72
168
  private delete;
73
169
  email: {
74
170
  /**
@@ -102,24 +198,85 @@ declare class HTTPSharePointRequests<T extends {
102
198
  }, any, {}>>;
103
199
  };
104
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
+ */
105
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
+ */
106
214
  private currentUserProperties;
107
215
  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
+ */
108
221
  properties: () => {
109
222
  get: () => Promise<UserProfile>;
110
223
  };
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
+ */
111
230
  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
+ */
112
238
  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
+ */
113
244
  current: () => {
114
245
  get: () => Promise<CurrentUser>;
115
246
  };
247
+ /**
248
+ * Retrieves calculated permission level for the current user.
249
+ *
250
+ * @returns Helper exposing `get` resolving to the user's permission definition.
251
+ */
116
252
  currentPermission: () => {
117
253
  get: () => Promise<UserPermision>;
118
254
  };
119
255
  };
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
+ */
120
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
+ */
121
268
  private roleDefinitions;
269
+ /**
270
+ * Fetches the bit-encoded permissions of the current user.
271
+ *
272
+ * @returns Promise resolving to the `EffectiveBasePermissions` object.
273
+ */
122
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
+ */
123
280
  private currentUserPermissions;
124
281
  }
125
282
  export default HTTPSharePointRequests;
@@ -1,3 +1,3 @@
1
- import { CreateAxiosDefaults } from 'axios';
2
- export declare const instance: (baseURL: string, config?: CreateAxiosDefaults) => import("axios").AxiosInstance;
1
+ import { CreateAxiosDefaults as AxiosConfig } from 'axios';
2
+ export declare const instance: (baseURL: string, config?: AxiosConfig) => import("axios").AxiosInstance;
3
3
  export default instance;