@lindle/sharepoint_requests 0.1.9 → 0.1.11

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