@lindle/sharepoint_requests 0.1.11 → 0.1.13
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 +4 -2
- package/dist/root/index.d.ts +17 -217
- package/dist/root/instance.d.ts +2 -2
- package/dist/root/internal/context.d.ts +9 -0
- package/dist/root/internal/digest.d.ts +2 -0
- package/dist/root/internal/emailRequests.d.ts +10 -0
- package/dist/root/internal/listRequests/createAttachment.d.ts +3 -0
- package/dist/root/internal/listRequests/createListItem.d.ts +3 -0
- package/dist/root/internal/listRequests/deleteItem.d.ts +3 -0
- package/dist/root/internal/listRequests/getFiles.d.ts +8 -0
- package/dist/root/internal/listRequests/getListItems.d.ts +8 -0
- package/dist/root/internal/listRequests/getOnly.d.ts +3 -0
- package/dist/root/internal/listRequests/index.d.ts +7 -0
- package/dist/root/internal/listRequests/updateListItem.d.ts +3 -0
- package/dist/root/internal/odata.d.ts +5 -0
- package/dist/root/internal/userRequests.d.ts +15 -0
- package/dist/sharepoint_requests.cjs.development.js +621 -775
- package/dist/sharepoint_requests.cjs.development.js.map +1 -1
- package/dist/sharepoint_requests.cjs.production.min.js +1 -1
- package/dist/sharepoint_requests.cjs.production.min.js.map +1 -1
- package/dist/sharepoint_requests.esm.js +620 -775
- package/dist/sharepoint_requests.esm.js.map +1 -1
- package/dist/types.d.ts +38 -7
- package/package.json +1 -1
- package/src/index.ts +37 -28
- package/src/root/index.ts +201 -600
- package/src/root/instance.ts +22 -13
- package/src/root/internal/context.ts +10 -0
- package/src/root/internal/digest.ts +22 -0
- package/src/root/internal/emailRequests.ts +45 -0
- package/src/root/internal/listRequests/createAttachment.ts +18 -0
- package/src/root/internal/listRequests/createListItem.ts +36 -0
- package/src/root/internal/listRequests/deleteItem.ts +10 -0
- package/src/root/internal/listRequests/getFiles.ts +31 -0
- package/src/root/internal/listRequests/getListItems.ts +50 -0
- package/src/root/internal/listRequests/getOnly.ts +18 -0
- package/src/root/internal/listRequests/index.ts +7 -0
- package/src/root/internal/listRequests/updateListItem.ts +32 -0
- package/src/root/internal/odata.ts +36 -0
- package/src/root/internal/userRequests.ts +109 -0
- package/src/types.ts +76 -36
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
|
-
var axios =
|
|
7
|
+
var axios = require('axios');
|
|
8
|
+
var axios__default = _interopDefault(axios);
|
|
8
9
|
|
|
9
10
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
10
11
|
try {
|
|
@@ -149,135 +150,625 @@ function _regeneratorDefine(e, r, n, t) {
|
|
|
149
150
|
}, _regeneratorDefine(e, r, n, t);
|
|
150
151
|
}
|
|
151
152
|
|
|
153
|
+
var defaultConfig = {
|
|
154
|
+
headers: {
|
|
155
|
+
Accept: 'application/json; odata=verbose',
|
|
156
|
+
'Content-Type': 'application/json; odata=verbose'
|
|
157
|
+
},
|
|
158
|
+
timeout: 15000,
|
|
159
|
+
withCredentials: true
|
|
160
|
+
};
|
|
152
161
|
var instance = function instance(baseURL, config) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
timeout: 15000,
|
|
160
|
-
withCredentials: true
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
return axios.create(_extends({
|
|
164
|
-
baseURL: baseURL
|
|
165
|
-
}, config));
|
|
162
|
+
var _config$headers;
|
|
163
|
+
var userHeaders = (config == null ? void 0 : config.headers) instanceof axios.AxiosHeaders ? config.headers.toJSON() : (_config$headers = config == null ? void 0 : config.headers) != null ? _config$headers : {};
|
|
164
|
+
return axios__default.create(_extends({}, defaultConfig, config, {
|
|
165
|
+
baseURL: baseURL,
|
|
166
|
+
headers: _extends({}, defaultConfig.headers, userHeaders)
|
|
167
|
+
}));
|
|
166
168
|
};
|
|
167
169
|
|
|
170
|
+
function fetchDigest(_x, _x2) {
|
|
171
|
+
return _fetchDigest.apply(this, arguments);
|
|
172
|
+
}
|
|
173
|
+
function _fetchDigest() {
|
|
174
|
+
_fetchDigest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(instance, baseURL) {
|
|
175
|
+
var _response$data, response, formDigestValue, _t;
|
|
176
|
+
return _regenerator().w(function (_context) {
|
|
177
|
+
while (1) switch (_context.p = _context.n) {
|
|
178
|
+
case 0:
|
|
179
|
+
_context.p = 0;
|
|
180
|
+
_context.n = 1;
|
|
181
|
+
return instance.post(baseURL + "_api/contextinfo");
|
|
182
|
+
case 1:
|
|
183
|
+
response = _context.v;
|
|
184
|
+
formDigestValue = (_response$data = response.data) == null || (_response$data = _response$data.d) == null || (_response$data = _response$data.GetContextWebInformation) == null ? void 0 : _response$data.FormDigestValue;
|
|
185
|
+
if (formDigestValue) {
|
|
186
|
+
_context.n = 2;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
throw new Error('Invalid response structure: Missing FormDigestValue');
|
|
190
|
+
case 2:
|
|
191
|
+
return _context.a(2, formDigestValue);
|
|
192
|
+
case 3:
|
|
193
|
+
_context.p = 3;
|
|
194
|
+
_t = _context.v;
|
|
195
|
+
console.error('Failed to retrieve the Form Digest Value:', _t);
|
|
196
|
+
throw new Error("Error retrieving Form Digest Value");
|
|
197
|
+
case 4:
|
|
198
|
+
return _context.a(2);
|
|
199
|
+
}
|
|
200
|
+
}, _callee, null, [[0, 3]]);
|
|
201
|
+
}));
|
|
202
|
+
return _fetchDigest.apply(this, arguments);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function transformArraysToEdmStrings(data) {
|
|
206
|
+
for (var key in data) {
|
|
207
|
+
if (Array.isArray(data[key])) {
|
|
208
|
+
data[key] = {
|
|
209
|
+
__metadata: {
|
|
210
|
+
type: 'Collection(Edm.String)'
|
|
211
|
+
},
|
|
212
|
+
results: data[key]
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function createListItem(_x, _x2) {
|
|
218
|
+
return _createListItem.apply(this, arguments);
|
|
219
|
+
}
|
|
220
|
+
function _createListItem() {
|
|
221
|
+
_createListItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, listData) {
|
|
222
|
+
var response, _t, _t2, _t3, _t4, _t5;
|
|
223
|
+
return _regenerator().w(function (_context) {
|
|
224
|
+
while (1) switch (_context.n) {
|
|
225
|
+
case 0:
|
|
226
|
+
transformArraysToEdmStrings(listData);
|
|
227
|
+
listData.__metadata = {
|
|
228
|
+
type: "SP.Data." + context.listName + "ListItem"
|
|
229
|
+
};
|
|
230
|
+
_t = context;
|
|
231
|
+
_t2 = context.endpoint;
|
|
232
|
+
_t3 = JSON.stringify(listData);
|
|
233
|
+
_context.n = 1;
|
|
234
|
+
return fetchDigest(context.instance, context.baseURL);
|
|
235
|
+
case 1:
|
|
236
|
+
_t4 = _context.v;
|
|
237
|
+
_t5 = {
|
|
238
|
+
'X-RequestDigest': _t4,
|
|
239
|
+
'IF-MATCH': '*'
|
|
240
|
+
};
|
|
241
|
+
_context.n = 2;
|
|
242
|
+
return _t.instance.call(_t, {
|
|
243
|
+
url: _t2,
|
|
244
|
+
method: 'POST',
|
|
245
|
+
data: _t3,
|
|
246
|
+
headers: _t5
|
|
247
|
+
});
|
|
248
|
+
case 2:
|
|
249
|
+
response = _context.v;
|
|
250
|
+
return _context.a(2, response);
|
|
251
|
+
}
|
|
252
|
+
}, _callee);
|
|
253
|
+
}));
|
|
254
|
+
return _createListItem.apply(this, arguments);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function createAttachment(_x, _x2) {
|
|
258
|
+
return _createAttachment.apply(this, arguments);
|
|
259
|
+
}
|
|
260
|
+
function _createAttachment() {
|
|
261
|
+
_createAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, _ref) {
|
|
262
|
+
var file, itemId, requestUrl, response, _t, _t2, _t3, _t4, _t5;
|
|
263
|
+
return _regenerator().w(function (_context) {
|
|
264
|
+
while (1) switch (_context.n) {
|
|
265
|
+
case 0:
|
|
266
|
+
file = _ref.file, itemId = _ref.itemId;
|
|
267
|
+
requestUrl = "_api/lists/getbytitle('" + context.listName + "')/items(" + itemId + ")/AttachmentFiles/add(FileName='" + file.name + "')";
|
|
268
|
+
_t = context.instance;
|
|
269
|
+
_t2 = requestUrl;
|
|
270
|
+
_t3 = file;
|
|
271
|
+
_context.n = 1;
|
|
272
|
+
return fetchDigest(context.instance, context.baseURL);
|
|
273
|
+
case 1:
|
|
274
|
+
_t4 = _context.v;
|
|
275
|
+
_t5 = {
|
|
276
|
+
'X-RequestDigest': _t4
|
|
277
|
+
};
|
|
278
|
+
_context.n = 2;
|
|
279
|
+
return _t.post.call(_t, _t2, _t3, {
|
|
280
|
+
headers: _t5,
|
|
281
|
+
withCredentials: true
|
|
282
|
+
});
|
|
283
|
+
case 2:
|
|
284
|
+
response = _context.v;
|
|
285
|
+
return _context.a(2, response);
|
|
286
|
+
}
|
|
287
|
+
}, _callee);
|
|
288
|
+
}));
|
|
289
|
+
return _createAttachment.apply(this, arguments);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function deleteItem(_x, _x2) {
|
|
293
|
+
return _deleteItem.apply(this, arguments);
|
|
294
|
+
}
|
|
295
|
+
function _deleteItem() {
|
|
296
|
+
_deleteItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, id) {
|
|
297
|
+
var response;
|
|
298
|
+
return _regenerator().w(function (_context) {
|
|
299
|
+
while (1) switch (_context.n) {
|
|
300
|
+
case 0:
|
|
301
|
+
_context.n = 1;
|
|
302
|
+
return context.instance["delete"](context.endpoint + "(" + id + ")");
|
|
303
|
+
case 1:
|
|
304
|
+
response = _context.v;
|
|
305
|
+
return _context.a(2, response);
|
|
306
|
+
}
|
|
307
|
+
}, _callee);
|
|
308
|
+
}));
|
|
309
|
+
return _deleteItem.apply(this, arguments);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function buildODataParams(options, orderBySeparator) {
|
|
313
|
+
if (orderBySeparator === void 0) {
|
|
314
|
+
orderBySeparator = ',';
|
|
315
|
+
}
|
|
316
|
+
var _ref = options || {},
|
|
317
|
+
expand = _ref.expand,
|
|
318
|
+
orderBy = _ref.orderBy,
|
|
319
|
+
limit = _ref.limit,
|
|
320
|
+
filter = _ref.filter,
|
|
321
|
+
cols = _ref.cols,
|
|
322
|
+
skip = _ref.skip;
|
|
323
|
+
var params = {
|
|
324
|
+
$expand: Array.isArray(expand) ? expand.join(',') : expand,
|
|
325
|
+
$top: limit,
|
|
326
|
+
$skip: skip,
|
|
327
|
+
$select: Array.isArray(cols) ? cols.join(',') : cols,
|
|
328
|
+
$filter: filter,
|
|
329
|
+
$orderby: Array.isArray(orderBy) ? orderBy.join(orderBySeparator) : orderBy
|
|
330
|
+
};
|
|
331
|
+
return params;
|
|
332
|
+
}
|
|
333
|
+
function appendParamsToUrl(baseUrl, params) {
|
|
334
|
+
Object.entries(params).forEach(function (_ref2) {
|
|
335
|
+
var key = _ref2[0],
|
|
336
|
+
value = _ref2[1];
|
|
337
|
+
if (value !== undefined && value !== null) {
|
|
338
|
+
baseUrl.searchParams.append(key, String(value));
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function getFiles(_x, _x2) {
|
|
344
|
+
return _getFiles.apply(this, arguments);
|
|
345
|
+
}
|
|
346
|
+
function _getFiles() {
|
|
347
|
+
_getFiles = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, options) {
|
|
348
|
+
var params, url, response, data, meta;
|
|
349
|
+
return _regenerator().w(function (_context) {
|
|
350
|
+
while (1) switch (_context.n) {
|
|
351
|
+
case 0:
|
|
352
|
+
params = buildODataParams(options, ',');
|
|
353
|
+
url = new URL(context.endpoint, context.instance.defaults.baseURL);
|
|
354
|
+
appendParamsToUrl(url, params);
|
|
355
|
+
_context.n = 1;
|
|
356
|
+
return context.instance.request({
|
|
357
|
+
url: context.endpoint,
|
|
358
|
+
method: 'GET',
|
|
359
|
+
params: params
|
|
360
|
+
});
|
|
361
|
+
case 1:
|
|
362
|
+
response = _context.v;
|
|
363
|
+
data = options != null && options.limit || !response.data.d.results ? response.data.d : response.data.d.results;
|
|
364
|
+
meta = {
|
|
365
|
+
url: url
|
|
366
|
+
};
|
|
367
|
+
return _context.a(2, {
|
|
368
|
+
data: data,
|
|
369
|
+
meta: meta
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}, _callee);
|
|
373
|
+
}));
|
|
374
|
+
return _getFiles.apply(this, arguments);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function getListItems(_x, _x2) {
|
|
378
|
+
return _getListItems.apply(this, arguments);
|
|
379
|
+
}
|
|
380
|
+
function _getListItems() {
|
|
381
|
+
_getListItems = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, options) {
|
|
382
|
+
var _ref, _response$data$d$resu, _response$data, _response$data2;
|
|
383
|
+
var params, url, response, rawData, cols, keys, filterItem, data, meta;
|
|
384
|
+
return _regenerator().w(function (_context) {
|
|
385
|
+
while (1) switch (_context.n) {
|
|
386
|
+
case 0:
|
|
387
|
+
params = buildODataParams(options, ' ');
|
|
388
|
+
url = new URL(context.endpoint, context.instance.defaults.baseURL);
|
|
389
|
+
appendParamsToUrl(url, params);
|
|
390
|
+
_context.n = 1;
|
|
391
|
+
return context.instance.request({
|
|
392
|
+
url: context.endpoint,
|
|
393
|
+
method: 'GET',
|
|
394
|
+
params: params
|
|
395
|
+
});
|
|
396
|
+
case 1:
|
|
397
|
+
response = _context.v;
|
|
398
|
+
rawData = (_ref = (_response$data$d$resu = (_response$data = response.data) == null || (_response$data = _response$data.d) == null ? void 0 : _response$data.results) != null ? _response$data$d$resu : (_response$data2 = response.data) == null ? void 0 : _response$data2.d) != null ? _ref : response.data;
|
|
399
|
+
cols = options == null ? void 0 : options.cols;
|
|
400
|
+
keys = cols ? (Array.isArray(cols) ? cols : [cols]).filter(Boolean) : undefined;
|
|
401
|
+
filterItem = function filterItem(item) {
|
|
402
|
+
if (!keys || !item || typeof item !== 'object') {
|
|
403
|
+
return item;
|
|
404
|
+
}
|
|
405
|
+
return keys.reduce(function (acc, key) {
|
|
406
|
+
if (key in item) {
|
|
407
|
+
acc[key] = item[key];
|
|
408
|
+
}
|
|
409
|
+
return acc;
|
|
410
|
+
}, {});
|
|
411
|
+
};
|
|
412
|
+
data = Array.isArray(rawData) ? rawData.map(filterItem) : filterItem(rawData);
|
|
413
|
+
meta = {
|
|
414
|
+
url: url
|
|
415
|
+
};
|
|
416
|
+
return _context.a(2, {
|
|
417
|
+
data: data,
|
|
418
|
+
meta: meta
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}, _callee);
|
|
422
|
+
}));
|
|
423
|
+
return _getListItems.apply(this, arguments);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function getOnly(_x, _x2, _x3) {
|
|
427
|
+
return _getOnly.apply(this, arguments);
|
|
428
|
+
}
|
|
429
|
+
function _getOnly() {
|
|
430
|
+
_getOnly = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(instance, endpoint, options) {
|
|
431
|
+
var params, _yield$instance$get, data;
|
|
432
|
+
return _regenerator().w(function (_context) {
|
|
433
|
+
while (1) switch (_context.n) {
|
|
434
|
+
case 0:
|
|
435
|
+
params = buildODataParams(options, ',');
|
|
436
|
+
_context.n = 1;
|
|
437
|
+
return instance.get(endpoint, {
|
|
438
|
+
params: params
|
|
439
|
+
});
|
|
440
|
+
case 1:
|
|
441
|
+
_yield$instance$get = _context.v;
|
|
442
|
+
data = _yield$instance$get.data;
|
|
443
|
+
if (!data) {
|
|
444
|
+
_context.n = 2;
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
return _context.a(2, data.d.results ? data.d.results : data.d);
|
|
448
|
+
case 2:
|
|
449
|
+
return _context.a(2);
|
|
450
|
+
}
|
|
451
|
+
}, _callee);
|
|
452
|
+
}));
|
|
453
|
+
return _getOnly.apply(this, arguments);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function updateListItem(_x, _x2, _x3, _x4) {
|
|
457
|
+
return _updateListItem.apply(this, arguments);
|
|
458
|
+
}
|
|
459
|
+
function _updateListItem() {
|
|
460
|
+
_updateListItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, id, data, digest) {
|
|
461
|
+
var formDigestValue, url, response, _t;
|
|
462
|
+
return _regenerator().w(function (_context) {
|
|
463
|
+
while (1) switch (_context.n) {
|
|
464
|
+
case 0:
|
|
465
|
+
_t = digest;
|
|
466
|
+
if (_t) {
|
|
467
|
+
_context.n = 2;
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
_context.n = 1;
|
|
471
|
+
return fetchDigest(context.instance, context.baseURL);
|
|
472
|
+
case 1:
|
|
473
|
+
_t = _context.v;
|
|
474
|
+
case 2:
|
|
475
|
+
formDigestValue = _t;
|
|
476
|
+
data.__metadata = {
|
|
477
|
+
type: "SP.Data." + context.listName + "ListItem"
|
|
478
|
+
};
|
|
479
|
+
url = "_api/lists/getbytitle('" + context.listName + "')/getItemById('" + id + "')";
|
|
480
|
+
_context.n = 3;
|
|
481
|
+
return context.instance({
|
|
482
|
+
url: url,
|
|
483
|
+
method: 'POST',
|
|
484
|
+
data: JSON.stringify(data),
|
|
485
|
+
headers: {
|
|
486
|
+
'X-RequestDigest': formDigestValue,
|
|
487
|
+
'IF-MATCH': '*',
|
|
488
|
+
'X-Http-Method': 'PATCH'
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
case 3:
|
|
492
|
+
response = _context.v;
|
|
493
|
+
return _context.a(2, response);
|
|
494
|
+
}
|
|
495
|
+
}, _callee);
|
|
496
|
+
}));
|
|
497
|
+
return _updateListItem.apply(this, arguments);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function sendEmail(_x, _x2) {
|
|
501
|
+
return _sendEmail.apply(this, arguments);
|
|
502
|
+
}
|
|
503
|
+
function _sendEmail() {
|
|
504
|
+
_sendEmail = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, _ref) {
|
|
505
|
+
var From, To, Subject, Body, httpRequest, response, _t, _t2, _t3, _t4, _t5;
|
|
506
|
+
return _regenerator().w(function (_context) {
|
|
507
|
+
while (1) switch (_context.n) {
|
|
508
|
+
case 0:
|
|
509
|
+
From = _ref.From, To = _ref.To, Subject = _ref.Subject, Body = _ref.Body;
|
|
510
|
+
httpRequest = '_api/SP.Utilities.Utility.SendEmail';
|
|
511
|
+
_t = context;
|
|
512
|
+
_t2 = httpRequest;
|
|
513
|
+
_context.n = 1;
|
|
514
|
+
return fetchDigest(context.instance, context.baseURL);
|
|
515
|
+
case 1:
|
|
516
|
+
_t3 = _context.v;
|
|
517
|
+
_t4 = {
|
|
518
|
+
'X-RequestDigest': _t3,
|
|
519
|
+
'X-Http-Method': 'POST',
|
|
520
|
+
'Content-Type': 'application/json;odata=verbose'
|
|
521
|
+
};
|
|
522
|
+
_t5 = JSON.stringify({
|
|
523
|
+
properties: {
|
|
524
|
+
__metadata: {
|
|
525
|
+
type: 'SP.Utilities.EmailProperties'
|
|
526
|
+
},
|
|
527
|
+
From: From,
|
|
528
|
+
To: {
|
|
529
|
+
results: Array.isArray(To) ? To : [To]
|
|
530
|
+
},
|
|
531
|
+
Body: Body,
|
|
532
|
+
Subject: Subject
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
_context.n = 2;
|
|
536
|
+
return _t.instance.call(_t, {
|
|
537
|
+
url: _t2,
|
|
538
|
+
method: 'POST',
|
|
539
|
+
headers: _t4,
|
|
540
|
+
data: _t5
|
|
541
|
+
});
|
|
542
|
+
case 2:
|
|
543
|
+
response = _context.v;
|
|
544
|
+
return _context.a(2, response);
|
|
545
|
+
}
|
|
546
|
+
}, _callee);
|
|
547
|
+
}));
|
|
548
|
+
return _sendEmail.apply(this, arguments);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function typeAhead(_x, _x2, _x3) {
|
|
552
|
+
return _typeAhead.apply(this, arguments);
|
|
553
|
+
}
|
|
554
|
+
function _typeAhead() {
|
|
555
|
+
_typeAhead = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(instance, input, filter) {
|
|
556
|
+
var requestUrl, data, response;
|
|
557
|
+
return _regenerator().w(function (_context) {
|
|
558
|
+
while (1) switch (_context.n) {
|
|
559
|
+
case 0:
|
|
560
|
+
requestUrl = "_api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUser";
|
|
561
|
+
data = {
|
|
562
|
+
queryParams: {
|
|
563
|
+
__metadata: {
|
|
564
|
+
type: 'SP.UI.ApplicationPages.ClientPeoplePickerQueryParameters'
|
|
565
|
+
},
|
|
566
|
+
AllowEmailAddresses: true,
|
|
567
|
+
AllowMultipleEntities: false,
|
|
568
|
+
AllUrlZones: false,
|
|
569
|
+
MaximumEntitySuggestions: 10,
|
|
570
|
+
PrincipalSource: 15,
|
|
571
|
+
PrincipalType: 1,
|
|
572
|
+
QueryString: input
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
if (filter) {
|
|
576
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
577
|
+
data.queryParams.RequiredProperties = [filter];
|
|
578
|
+
}
|
|
579
|
+
_context.n = 1;
|
|
580
|
+
return instance.post(requestUrl, JSON.stringify(data), {
|
|
581
|
+
headers: {
|
|
582
|
+
Accept: 'application/json; odata=verbose',
|
|
583
|
+
'Content-Type': 'application/json;odata=verbose'
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
case 1:
|
|
587
|
+
response = _context.v;
|
|
588
|
+
return _context.a(2, response.data.d.ClientPeoplePickerSearchUser);
|
|
589
|
+
}
|
|
590
|
+
}, _callee);
|
|
591
|
+
}));
|
|
592
|
+
return _typeAhead.apply(this, arguments);
|
|
593
|
+
}
|
|
594
|
+
function currentUserProperties(_x4) {
|
|
595
|
+
return _currentUserProperties.apply(this, arguments);
|
|
596
|
+
}
|
|
597
|
+
function _currentUserProperties() {
|
|
598
|
+
_currentUserProperties = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(instance) {
|
|
599
|
+
var requestUrl, profile;
|
|
600
|
+
return _regenerator().w(function (_context2) {
|
|
601
|
+
while (1) switch (_context2.n) {
|
|
602
|
+
case 0:
|
|
603
|
+
requestUrl = '_api/sp.userprofiles.peoplemanager/getmyproperties';
|
|
604
|
+
_context2.n = 1;
|
|
605
|
+
return instance.get(requestUrl);
|
|
606
|
+
case 1:
|
|
607
|
+
profile = _context2.v;
|
|
608
|
+
profile = profile.data.d;
|
|
609
|
+
profile.UserProfileProperties.results.forEach(function (prop) {
|
|
610
|
+
if (prop.Key === 'FirstName') {
|
|
611
|
+
profile.FirstName = prop.Value;
|
|
612
|
+
}
|
|
613
|
+
if (prop.Key === 'LastName') {
|
|
614
|
+
profile.LastName = prop.Value;
|
|
615
|
+
}
|
|
616
|
+
if (prop.Key === 'Country') {
|
|
617
|
+
profile.Country = prop.Value;
|
|
618
|
+
}
|
|
619
|
+
if (prop.Key === 'UserName') {
|
|
620
|
+
profile.UserName = prop.Value;
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
return _context2.a(2, profile);
|
|
624
|
+
}
|
|
625
|
+
}, _callee2);
|
|
626
|
+
}));
|
|
627
|
+
return _currentUserProperties.apply(this, arguments);
|
|
628
|
+
}
|
|
629
|
+
function getSiteUser(_x5, _x6) {
|
|
630
|
+
return _getSiteUser.apply(this, arguments);
|
|
631
|
+
}
|
|
632
|
+
function _getSiteUser() {
|
|
633
|
+
_getSiteUser = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(instance, searchValue) {
|
|
634
|
+
var requestUrl, response;
|
|
635
|
+
return _regenerator().w(function (_context3) {
|
|
636
|
+
while (1) switch (_context3.n) {
|
|
637
|
+
case 0:
|
|
638
|
+
requestUrl = "_api/web/siteusers?&$filter=substringof('" + searchValue + "', Title) or substringof('" + searchValue + "', LoginName) or substringof('" + searchValue + "', Email)&$top=50&$expand=Groups";
|
|
639
|
+
_context3.n = 1;
|
|
640
|
+
return instance.get(requestUrl);
|
|
641
|
+
case 1:
|
|
642
|
+
response = _context3.v;
|
|
643
|
+
return _context3.a(2, response.data.d);
|
|
644
|
+
}
|
|
645
|
+
}, _callee3);
|
|
646
|
+
}));
|
|
647
|
+
return _getSiteUser.apply(this, arguments);
|
|
648
|
+
}
|
|
649
|
+
function roleDefinitions(_x7) {
|
|
650
|
+
return _roleDefinitions.apply(this, arguments);
|
|
651
|
+
}
|
|
652
|
+
function _roleDefinitions() {
|
|
653
|
+
_roleDefinitions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(instance) {
|
|
654
|
+
var requestUrl, response;
|
|
655
|
+
return _regenerator().w(function (_context4) {
|
|
656
|
+
while (1) switch (_context4.n) {
|
|
657
|
+
case 0:
|
|
658
|
+
requestUrl = "_api/Web/RoleDefinitions";
|
|
659
|
+
_context4.n = 1;
|
|
660
|
+
return instance.get(requestUrl);
|
|
661
|
+
case 1:
|
|
662
|
+
response = _context4.v;
|
|
663
|
+
return _context4.a(2, response.data.d.results);
|
|
664
|
+
}
|
|
665
|
+
}, _callee4);
|
|
666
|
+
}));
|
|
667
|
+
return _roleDefinitions.apply(this, arguments);
|
|
668
|
+
}
|
|
669
|
+
function getEffectiveBasePermissions(_x8) {
|
|
670
|
+
return _getEffectiveBasePermissions.apply(this, arguments);
|
|
671
|
+
}
|
|
672
|
+
function _getEffectiveBasePermissions() {
|
|
673
|
+
_getEffectiveBasePermissions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(instance) {
|
|
674
|
+
var requestUrl, response;
|
|
675
|
+
return _regenerator().w(function (_context5) {
|
|
676
|
+
while (1) switch (_context5.n) {
|
|
677
|
+
case 0:
|
|
678
|
+
requestUrl = "_api/Web/effectiveBasePermissions";
|
|
679
|
+
_context5.n = 1;
|
|
680
|
+
return instance.get(requestUrl);
|
|
681
|
+
case 1:
|
|
682
|
+
response = _context5.v;
|
|
683
|
+
return _context5.a(2, response.data.d.EffectiveBasePermissions);
|
|
684
|
+
}
|
|
685
|
+
}, _callee5);
|
|
686
|
+
}));
|
|
687
|
+
return _getEffectiveBasePermissions.apply(this, arguments);
|
|
688
|
+
}
|
|
689
|
+
function currentUserPermissions(_x9) {
|
|
690
|
+
return _currentUserPermissions.apply(this, arguments);
|
|
691
|
+
}
|
|
692
|
+
function _currentUserPermissions() {
|
|
693
|
+
_currentUserPermissions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(context) {
|
|
694
|
+
var _yield$getEffectiveBa, High, definitions, result;
|
|
695
|
+
return _regenerator().w(function (_context6) {
|
|
696
|
+
while (1) switch (_context6.n) {
|
|
697
|
+
case 0:
|
|
698
|
+
_context6.n = 1;
|
|
699
|
+
return getEffectiveBasePermissions(context.instance);
|
|
700
|
+
case 1:
|
|
701
|
+
_yield$getEffectiveBa = _context6.v;
|
|
702
|
+
High = _yield$getEffectiveBa.High;
|
|
703
|
+
_context6.n = 2;
|
|
704
|
+
return roleDefinitions(context.instance);
|
|
705
|
+
case 2:
|
|
706
|
+
definitions = _context6.v;
|
|
707
|
+
result = definitions.find(function (_ref) {
|
|
708
|
+
var BasePermissions = _ref.BasePermissions;
|
|
709
|
+
return BasePermissions.High === High;
|
|
710
|
+
});
|
|
711
|
+
return _context6.a(2, result);
|
|
712
|
+
}
|
|
713
|
+
}, _callee6);
|
|
714
|
+
}));
|
|
715
|
+
return _currentUserPermissions.apply(this, arguments);
|
|
716
|
+
}
|
|
717
|
+
|
|
168
718
|
var HTTPSharePointRequests = /*#__PURE__*/function () {
|
|
169
|
-
|
|
170
|
-
* Creates an HTTP SharePoint requester bound to the provided base URL.
|
|
171
|
-
*
|
|
172
|
-
* @param baseURL The root SharePoint site URL (with or without trailing slash).
|
|
173
|
-
*/
|
|
174
|
-
function HTTPSharePointRequests(baseURL) {
|
|
719
|
+
function HTTPSharePointRequests(baseURL, config) {
|
|
175
720
|
var _this = this;
|
|
176
721
|
this.lists = {
|
|
177
|
-
/**
|
|
178
|
-
* Fetches all SharePoint lists available to the current site.
|
|
179
|
-
*
|
|
180
|
-
* @returns Promise resolving to the list collection response payload.
|
|
181
|
-
*/
|
|
182
722
|
get: function get() {
|
|
183
723
|
_this.endpoint = '_api/web/lists';
|
|
184
|
-
|
|
724
|
+
_this.sharepointVersion = '2013';
|
|
725
|
+
return getListItems(_this.getContext());
|
|
185
726
|
}
|
|
186
727
|
};
|
|
187
728
|
this.folders = {
|
|
188
|
-
/**
|
|
189
|
-
* Retrieves SharePoint folders from the default folders endpoint.
|
|
190
|
-
*
|
|
191
|
-
* @returns A promise resolving with folder metadata.
|
|
192
|
-
*/
|
|
193
729
|
get: function get() {
|
|
194
730
|
_this.endpoint = '_api/web/folders';
|
|
195
|
-
_this.
|
|
731
|
+
_this.sharepointVersion = '2013';
|
|
732
|
+
getListItems(_this.getContext());
|
|
196
733
|
}
|
|
197
734
|
};
|
|
198
735
|
this.email = {
|
|
199
|
-
/**
|
|
200
|
-
* Sends an email using SharePoint's Utility.SendEmail API.
|
|
201
|
-
*
|
|
202
|
-
* @param {EmailProps} param0 - The email properties.
|
|
203
|
-
* @param {string} param0.From - The sender's email address.
|
|
204
|
-
* @example
|
|
205
|
-
* Example of a sender's email address
|
|
206
|
-
* "sender@example.com"
|
|
207
|
-
* @param {string | string[]} param0.To - The recipient's email address or an array of email addresses.
|
|
208
|
-
* @example
|
|
209
|
-
* Example of a single recipient's email address
|
|
210
|
-
* "recipient@example.com"
|
|
211
|
-
* Example of multiple recipients' email addresses
|
|
212
|
-
* ["recipient1@example.com", "recipient2@example.com"]
|
|
213
|
-
* @param {string} param0.Subject - The subject of the email.
|
|
214
|
-
* @example
|
|
215
|
-
* Example of an email subject
|
|
216
|
-
* "Meeting Reminder"
|
|
217
|
-
* @param {string} param0.Body - The body content of the email.
|
|
218
|
-
* @example
|
|
219
|
-
* Example of an email body
|
|
220
|
-
* "Dear team, please be reminded of the meeting scheduled for tomorrow at 10 AM."
|
|
221
|
-
* @returns {Promise<any>} - A promise that resolves to the response of the email send request.
|
|
222
|
-
*/
|
|
223
736
|
send: function send(props) {
|
|
224
|
-
|
|
737
|
+
_this.sharepointVersion = '2013';
|
|
738
|
+
return sendEmail(_this.getContext(), props);
|
|
225
739
|
}
|
|
226
740
|
};
|
|
227
741
|
this.user = {
|
|
228
|
-
/**
|
|
229
|
-
* Provides accessors for the current user's profile information.
|
|
230
|
-
*
|
|
231
|
-
* @returns Helper exposing a `get` function to retrieve profile details.
|
|
232
|
-
*/
|
|
233
742
|
properties: function properties() {
|
|
234
743
|
return {
|
|
235
744
|
get: function get() {
|
|
236
|
-
|
|
745
|
+
_this.sharepointVersion = '2013';
|
|
746
|
+
return currentUserProperties(_this.instance);
|
|
237
747
|
}
|
|
238
748
|
};
|
|
239
749
|
},
|
|
240
|
-
/**
|
|
241
|
-
* Searches across site users and their groups.
|
|
242
|
-
*
|
|
243
|
-
* @param searchValue Query string to match site users.
|
|
244
|
-
* @returns Promise resolving to matching site users.
|
|
245
|
-
*/
|
|
246
750
|
searchSiteUser: function searchSiteUser(searchValue) {
|
|
247
|
-
|
|
751
|
+
_this.sharepointVersion = '2013';
|
|
752
|
+
return getSiteUser(_this.instance, searchValue);
|
|
248
753
|
},
|
|
249
|
-
/**
|
|
250
|
-
* Performs a people-picker search scoped to the current site collection.
|
|
251
|
-
*
|
|
252
|
-
* @param input Search prefix.
|
|
253
|
-
* @param filter Optional additional filter condition.
|
|
254
|
-
* @returns Promise with type-ahead person results.
|
|
255
|
-
*/
|
|
256
754
|
searchUser: function searchUser(input, filter) {
|
|
257
|
-
|
|
755
|
+
_this.sharepointVersion = '2013';
|
|
756
|
+
return typeAhead(_this.instance, input, filter);
|
|
258
757
|
},
|
|
259
|
-
/**
|
|
260
|
-
* Fetches the currently authenticated SharePoint user.
|
|
261
|
-
*
|
|
262
|
-
* @returns Helper exposing `get` that resolves to the current user payload.
|
|
263
|
-
*/
|
|
264
758
|
current: function current() {
|
|
265
759
|
_this.endpoint = '_api/web/currentUser';
|
|
760
|
+
_this.sharepointVersion = '2013';
|
|
266
761
|
return {
|
|
267
762
|
get: function get() {
|
|
268
|
-
return _this.
|
|
763
|
+
return getOnly(_this.instance, _this.endpoint);
|
|
269
764
|
}
|
|
270
765
|
};
|
|
271
766
|
},
|
|
272
|
-
/**
|
|
273
|
-
* Retrieves calculated permission level for the current user.
|
|
274
|
-
*
|
|
275
|
-
* @returns Helper exposing `get` resolving to the user's permission definition.
|
|
276
|
-
*/
|
|
277
767
|
currentPermission: function currentPermission() {
|
|
278
768
|
return {
|
|
279
769
|
get: function get() {
|
|
280
|
-
|
|
770
|
+
_this.sharepointVersion = '2013';
|
|
771
|
+
return currentUserPermissions(_this.getContext());
|
|
281
772
|
}
|
|
282
773
|
};
|
|
283
774
|
}
|
|
@@ -285,26 +776,18 @@ var HTTPSharePointRequests = /*#__PURE__*/function () {
|
|
|
285
776
|
this.baseURL = baseURL.endsWith('/') ? baseURL : baseURL + "/";
|
|
286
777
|
this.endpoint = '/api';
|
|
287
778
|
this.listName = '';
|
|
288
|
-
this.instance = instance(this.baseURL);
|
|
779
|
+
this.instance = instance(this.baseURL, config);
|
|
780
|
+
this.sharepointVersion = '2013';
|
|
289
781
|
}
|
|
290
|
-
/**
|
|
291
|
-
* Converts array values in a payload to the `Collection(Edm.String)` structure
|
|
292
|
-
* expected by SharePoint REST endpoints.
|
|
293
|
-
*
|
|
294
|
-
* @param data The list item payload to harmonise in-place.
|
|
295
|
-
*/
|
|
296
782
|
var _proto = HTTPSharePointRequests.prototype;
|
|
297
|
-
_proto.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
}
|
|
783
|
+
_proto.getContext = function getContext() {
|
|
784
|
+
return {
|
|
785
|
+
instance: this.instance,
|
|
786
|
+
baseURL: this.baseURL,
|
|
787
|
+
endpoint: this.endpoint,
|
|
788
|
+
listName: this.listName,
|
|
789
|
+
sharepointVersion: this.sharepointVersion
|
|
790
|
+
};
|
|
308
791
|
}
|
|
309
792
|
/**
|
|
310
793
|
* @deprecated Use `from` instead.
|
|
@@ -312,55 +795,44 @@ var HTTPSharePointRequests = /*#__PURE__*/function () {
|
|
|
312
795
|
_proto.list = function list(listName) {
|
|
313
796
|
this.listName = listName;
|
|
314
797
|
this.endpoint = "_vti_bin/ListData.svc/" + listName;
|
|
798
|
+
this.sharepointVersion = '2010';
|
|
315
799
|
return this;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Selects a SharePoint list and exposes list-scoped CRUD helpers.
|
|
319
|
-
*
|
|
320
|
-
* @param listName Logical list key configured in the generic type map.
|
|
321
|
-
* @param sharepoint_ver SharePoint version used to choose the correct REST endpoint.
|
|
322
|
-
* @returns Chainable helpers bound to the selected list.
|
|
323
|
-
*/;
|
|
800
|
+
};
|
|
324
801
|
_proto.from = function from(listName, sharepoint_ver) {
|
|
325
802
|
var _this2 = this;
|
|
326
|
-
|
|
327
|
-
sharepoint_ver = '2013';
|
|
328
|
-
}
|
|
803
|
+
var version = sharepoint_ver != null ? sharepoint_ver : '2013';
|
|
329
804
|
this.listName = listName;
|
|
330
|
-
this.
|
|
805
|
+
this.sharepointVersion = version;
|
|
806
|
+
this.endpoint = version === '2013' ? "_api/web/lists/GetByTitle('" + this.listName + "')/items" : "_vti_bin/ListData.svc/" + listName;
|
|
807
|
+
var getContext = function getContext() {
|
|
808
|
+
return _this2.getContext();
|
|
809
|
+
};
|
|
331
810
|
return {
|
|
332
811
|
create: function create(data) {
|
|
333
|
-
return
|
|
812
|
+
return createListItem(getContext(), data);
|
|
334
813
|
},
|
|
335
814
|
get: function get(options) {
|
|
336
|
-
return
|
|
815
|
+
return getListItems(getContext(), options);
|
|
337
816
|
},
|
|
338
817
|
update: function update(id, data, digest) {
|
|
339
|
-
return
|
|
818
|
+
return updateListItem(getContext(), id, data, digest);
|
|
340
819
|
},
|
|
341
820
|
"delete": function _delete(id) {
|
|
342
|
-
return
|
|
821
|
+
return deleteItem(getContext(), id);
|
|
343
822
|
},
|
|
344
823
|
createFile: function createFile(props) {
|
|
345
|
-
return
|
|
824
|
+
return createAttachment(getContext(), props);
|
|
346
825
|
},
|
|
347
826
|
fields: function fields(options) {
|
|
348
|
-
// return this.field_v2(options)
|
|
349
827
|
_this2.endpoint = !(options != null && options.fieldName) ? "_api/web/lists/GetByTitle('" + _this2.listName + "')/fields" : "_api/web/lists/GetByTitle('" + _this2.listName + "')/fields/getbytitle('" + options.fieldName + "')";
|
|
350
828
|
return {
|
|
351
829
|
get: function get() {
|
|
352
|
-
return _this2.
|
|
830
|
+
return getOnly(_this2.instance, _this2.endpoint, options);
|
|
353
831
|
}
|
|
354
832
|
};
|
|
355
833
|
}
|
|
356
834
|
};
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Targets a SharePoint folder path and exposes file retrieval helpers.
|
|
360
|
-
*
|
|
361
|
-
* @param folderName Optional folder path relative to `Shared Documents`.
|
|
362
|
-
* @returns Helper exposing `get` to fetch files or sub-folders.
|
|
363
|
-
*/;
|
|
835
|
+
};
|
|
364
836
|
_proto.folder = function folder(folderName) {
|
|
365
837
|
var _this3 = this;
|
|
366
838
|
var filePath = ['Shared Documents'];
|
|
@@ -368,678 +840,52 @@ var HTTPSharePointRequests = /*#__PURE__*/function () {
|
|
|
368
840
|
filePath = Array.isArray(folderName) ? [].concat(filePath, folderName) : [].concat(filePath, [folderName]);
|
|
369
841
|
}
|
|
370
842
|
this.endpoint = "_api/web/GetFolderByServerRelativeUrl('" + filePath.join('/') + "')";
|
|
843
|
+
this.sharepointVersion = '2013';
|
|
844
|
+
var getContext = function getContext() {
|
|
845
|
+
return _this3.getContext();
|
|
846
|
+
};
|
|
371
847
|
return {
|
|
372
|
-
/**
|
|
373
|
-
* Fetches files or folders from the targeted path.
|
|
374
|
-
*
|
|
375
|
-
* @param options Optional REST query options to refine the result set.
|
|
376
|
-
* @returns Promise resolving to folder contents and metadata.
|
|
377
|
-
*/
|
|
378
848
|
get: function get(options) {
|
|
379
849
|
if (!(options != null && options.type)) {
|
|
380
850
|
_this3.endpoint += '/Files';
|
|
381
851
|
} else {
|
|
382
852
|
_this3.endpoint += "/" + options.type;
|
|
383
853
|
}
|
|
384
|
-
return
|
|
854
|
+
return getFiles(getContext(), options);
|
|
385
855
|
}
|
|
386
856
|
};
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Retrieves user list items and exposes a get helper with optional query parameters.
|
|
390
|
-
*
|
|
391
|
-
* @param options Optional REST query options.
|
|
392
|
-
* @returns Helper exposing `get` returning SharePoint user rows.
|
|
393
|
-
*/;
|
|
857
|
+
};
|
|
394
858
|
_proto.users = function users(options) {
|
|
395
859
|
var _this4 = this;
|
|
396
860
|
this.endpoint = '_api/web/SiteUserInfoList/items';
|
|
861
|
+
this.sharepointVersion = '2013';
|
|
397
862
|
return {
|
|
398
|
-
/**
|
|
399
|
-
* Executes the user list request using the specified options.
|
|
400
|
-
*
|
|
401
|
-
* @returns Promise resolving to the SharePoint user list response.
|
|
402
|
-
*/
|
|
403
863
|
get: function get() {
|
|
404
|
-
return _this4.
|
|
864
|
+
return getListItems(_this4.getContext(), options);
|
|
405
865
|
}
|
|
406
866
|
};
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* Asynchronously retrieves the Form Digest Value from the context information API.
|
|
410
|
-
*
|
|
411
|
-
* @returns {Promise<string>} A promise that resolves to the Form Digest Value.
|
|
412
|
-
* @throws {Error} If the HTTP request fails or the response does not contain the expected data.
|
|
413
|
-
*/;
|
|
414
|
-
_proto.getDigest =
|
|
415
|
-
/*#__PURE__*/
|
|
416
|
-
function () {
|
|
417
|
-
var _getDigest = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
418
|
-
var _response$data, response, _t;
|
|
419
|
-
return _regenerator().w(function (_context) {
|
|
420
|
-
while (1) switch (_context.p = _context.n) {
|
|
421
|
-
case 0:
|
|
422
|
-
_context.p = 0;
|
|
423
|
-
_context.n = 1;
|
|
424
|
-
return this.instance.post(this.baseURL + "_api/contextinfo");
|
|
425
|
-
case 1:
|
|
426
|
-
response = _context.v;
|
|
427
|
-
if ((_response$data = response.data) != null && (_response$data = _response$data.d) != null && (_response$data = _response$data.GetContextWebInformation) != null && _response$data.FormDigestValue) {
|
|
428
|
-
_context.n = 2;
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
throw new Error('Invalid response structure: Missing FormDigestValue');
|
|
432
|
-
case 2:
|
|
433
|
-
return _context.a(2, response.data.d.GetContextWebInformation.FormDigestValue);
|
|
434
|
-
case 3:
|
|
435
|
-
_context.p = 3;
|
|
436
|
-
_t = _context.v;
|
|
437
|
-
console.error('Failed to retrieve the Form Digest Value:', _t);
|
|
438
|
-
throw new Error("Error retrieving Form Digest Value");
|
|
439
|
-
case 4:
|
|
440
|
-
return _context.a(2);
|
|
441
|
-
}
|
|
442
|
-
}, _callee, this, [[0, 3]]);
|
|
443
|
-
}));
|
|
444
|
-
function getDigest() {
|
|
445
|
-
return _getDigest.apply(this, arguments);
|
|
446
|
-
}
|
|
447
|
-
return getDigest;
|
|
448
|
-
}()
|
|
449
|
-
/**
|
|
450
|
-
* Executes a GET request without additional metadata wrapping.
|
|
451
|
-
*
|
|
452
|
-
* @param options Optional REST query options.
|
|
453
|
-
* @returns SharePoint response payload or undefined when empty.
|
|
454
|
-
*/
|
|
455
|
-
;
|
|
456
|
-
_proto.get_only =
|
|
457
|
-
/*#__PURE__*/
|
|
458
|
-
function () {
|
|
459
|
-
var _get_only = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
460
|
-
var _ref, expand, orderBy, limit, filter, cols, skip, params, _yield$this$instance$, data;
|
|
461
|
-
return _regenerator().w(function (_context2) {
|
|
462
|
-
while (1) switch (_context2.n) {
|
|
463
|
-
case 0:
|
|
464
|
-
_ref = options || {}, expand = _ref.expand, orderBy = _ref.orderBy, limit = _ref.limit, filter = _ref.filter, cols = _ref.cols, skip = _ref.skip;
|
|
465
|
-
params = {
|
|
466
|
-
$expand: Array.isArray(expand) ? expand.join(',') : expand,
|
|
467
|
-
$top: limit,
|
|
468
|
-
$skip: skip,
|
|
469
|
-
$select: Array.isArray(cols) ? cols.join(',') : cols,
|
|
470
|
-
$filter: filter,
|
|
471
|
-
$orderby: Array.isArray(orderBy) ? orderBy.join(',') : orderBy
|
|
472
|
-
};
|
|
473
|
-
_context2.n = 1;
|
|
474
|
-
return this.instance.get(this.endpoint, {
|
|
475
|
-
params: params
|
|
476
|
-
});
|
|
477
|
-
case 1:
|
|
478
|
-
_yield$this$instance$ = _context2.v;
|
|
479
|
-
data = _yield$this$instance$.data;
|
|
480
|
-
if (!data) {
|
|
481
|
-
_context2.n = 2;
|
|
482
|
-
break;
|
|
483
|
-
}
|
|
484
|
-
return _context2.a(2, data.d.results ? data.d.results : data.d);
|
|
485
|
-
case 2:
|
|
486
|
-
return _context2.a(2);
|
|
487
|
-
}
|
|
488
|
-
}, _callee2, this);
|
|
489
|
-
}));
|
|
490
|
-
function get_only(_x) {
|
|
491
|
-
return _get_only.apply(this, arguments);
|
|
492
|
-
}
|
|
493
|
-
return get_only;
|
|
494
|
-
}()
|
|
495
|
-
/**
|
|
496
|
-
* Retrieves folder contents with optional filtering and returns the payload with metadata.
|
|
497
|
-
*
|
|
498
|
-
* @param options REST options describing expand/filter/order conditions.
|
|
499
|
-
* @returns Folder data and the fully resolved request URL.
|
|
500
|
-
*/
|
|
501
|
-
;
|
|
502
|
-
_proto.get_files =
|
|
503
|
-
/*#__PURE__*/
|
|
504
|
-
function () {
|
|
505
|
-
var _get_files = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
506
|
-
var _ref2, expand, orderBy, limit, filter, cols, skip, params, url, response, data, meta;
|
|
507
|
-
return _regenerator().w(function (_context3) {
|
|
508
|
-
while (1) switch (_context3.n) {
|
|
509
|
-
case 0:
|
|
510
|
-
_ref2 = options || {}, expand = _ref2.expand, orderBy = _ref2.orderBy, limit = _ref2.limit, filter = _ref2.filter, cols = _ref2.cols, skip = _ref2.skip;
|
|
511
|
-
params = {
|
|
512
|
-
$expand: Array.isArray(expand) ? expand.join(',') : expand,
|
|
513
|
-
$top: limit,
|
|
514
|
-
$skip: skip,
|
|
515
|
-
$select: Array.isArray(cols) ? cols.join(',') : cols,
|
|
516
|
-
$filter: filter,
|
|
517
|
-
$orderby: Array.isArray(orderBy) ? orderBy.join(',') : orderBy
|
|
518
|
-
};
|
|
519
|
-
url = new URL(this.endpoint, this.instance.defaults.baseURL);
|
|
520
|
-
Object.entries(params).forEach(function (_ref3) {
|
|
521
|
-
var key = _ref3[0],
|
|
522
|
-
value = _ref3[1];
|
|
523
|
-
if (value !== undefined && value !== null) {
|
|
524
|
-
url.searchParams.append(key, String(value));
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
_context3.n = 1;
|
|
528
|
-
return this.instance.request({
|
|
529
|
-
url: this.endpoint,
|
|
530
|
-
method: 'GET',
|
|
531
|
-
params: params
|
|
532
|
-
});
|
|
533
|
-
case 1:
|
|
534
|
-
response = _context3.v;
|
|
535
|
-
data = limit || !response.data.d.results ? response.data.d : response.data.d.results;
|
|
536
|
-
meta = {
|
|
537
|
-
url: url
|
|
538
|
-
};
|
|
539
|
-
return _context3.a(2, {
|
|
540
|
-
data: data,
|
|
541
|
-
meta: meta
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
}, _callee3, this);
|
|
545
|
-
}));
|
|
546
|
-
function get_files(_x2) {
|
|
547
|
-
return _get_files.apply(this, arguments);
|
|
548
|
-
}
|
|
549
|
-
return get_files;
|
|
550
|
-
}()
|
|
551
|
-
/**
|
|
552
|
-
* Performs a typed list read against the current endpoint.
|
|
553
|
-
*
|
|
554
|
-
* @param options Optional REST query options governing expand, filter, ordering and pagination.
|
|
555
|
-
* @returns SharePoint list items alongside the fully-resolved request URL.
|
|
556
|
-
*/
|
|
557
|
-
;
|
|
558
|
-
_proto.get_v2 =
|
|
559
|
-
/*#__PURE__*/
|
|
560
|
-
function () {
|
|
561
|
-
var _get_v = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options) {
|
|
562
|
-
var _ref4, expand, orderBy, limit, filter, cols, skip, params, url, response, data, meta;
|
|
563
|
-
return _regenerator().w(function (_context4) {
|
|
564
|
-
while (1) switch (_context4.n) {
|
|
565
|
-
case 0:
|
|
566
|
-
_ref4 = options || {}, expand = _ref4.expand, orderBy = _ref4.orderBy, limit = _ref4.limit, filter = _ref4.filter, cols = _ref4.cols, skip = _ref4.skip;
|
|
567
|
-
params = {
|
|
568
|
-
$expand: Array.isArray(expand) ? expand.join(',') : expand,
|
|
569
|
-
$top: limit,
|
|
570
|
-
$skip: skip,
|
|
571
|
-
$select: Array.isArray(cols) ? cols.join(',') : cols,
|
|
572
|
-
$filter: filter,
|
|
573
|
-
$orderby: Array.isArray(orderBy) ? orderBy.join(' ') : orderBy
|
|
574
|
-
};
|
|
575
|
-
url = new URL(this.endpoint, this.instance.defaults.baseURL);
|
|
576
|
-
Object.entries(params).forEach(function (_ref5) {
|
|
577
|
-
var key = _ref5[0],
|
|
578
|
-
value = _ref5[1];
|
|
579
|
-
if (value !== undefined && value !== null) {
|
|
580
|
-
url.searchParams.append(key, String(value));
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
_context4.n = 1;
|
|
584
|
-
return this.instance.request({
|
|
585
|
-
url: this.endpoint,
|
|
586
|
-
method: 'GET',
|
|
587
|
-
params: params
|
|
588
|
-
});
|
|
589
|
-
case 1:
|
|
590
|
-
response = _context4.v;
|
|
591
|
-
data = limit || !response.data.d.results ? response.data.d : response.data.d.results;
|
|
592
|
-
meta = {
|
|
593
|
-
url: url
|
|
594
|
-
};
|
|
595
|
-
return _context4.a(2, {
|
|
596
|
-
data: data,
|
|
597
|
-
meta: meta
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
}, _callee4, this);
|
|
601
|
-
}));
|
|
602
|
-
function get_v2(_x3) {
|
|
603
|
-
return _get_v.apply(this, arguments);
|
|
604
|
-
}
|
|
605
|
-
return get_v2;
|
|
606
|
-
}()
|
|
607
|
-
/**
|
|
608
|
-
* Updates an item in the currently selected list.
|
|
609
|
-
*
|
|
610
|
-
* @param id Target list item identifier.
|
|
611
|
-
* @param data Payload with fields to update.
|
|
612
|
-
* @param digest Optional pre-fetched form digest to reuse.
|
|
613
|
-
* @returns Axios response of the update request.
|
|
614
|
-
*/
|
|
615
|
-
;
|
|
616
|
-
_proto.update_2 =
|
|
617
|
-
/*#__PURE__*/
|
|
618
|
-
function () {
|
|
619
|
-
var _update_ = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(id, data, digest) {
|
|
620
|
-
var formDigestValue, url, response, _t2;
|
|
621
|
-
return _regenerator().w(function (_context5) {
|
|
622
|
-
while (1) switch (_context5.n) {
|
|
623
|
-
case 0:
|
|
624
|
-
_t2 = digest;
|
|
625
|
-
if (_t2) {
|
|
626
|
-
_context5.n = 2;
|
|
627
|
-
break;
|
|
628
|
-
}
|
|
629
|
-
_context5.n = 1;
|
|
630
|
-
return this.getDigest();
|
|
631
|
-
case 1:
|
|
632
|
-
_t2 = _context5.v;
|
|
633
|
-
case 2:
|
|
634
|
-
formDigestValue = _t2;
|
|
635
|
-
data.__metadata = {
|
|
636
|
-
type: "SP.Data." + this.listName + "ListItem"
|
|
637
|
-
};
|
|
638
|
-
url = "_api/lists/getbytitle('" + this.listName + "')/getItemById('" + id + "')";
|
|
639
|
-
_context5.n = 3;
|
|
640
|
-
return this.instance({
|
|
641
|
-
url: url,
|
|
642
|
-
method: 'POST',
|
|
643
|
-
data: JSON.stringify(data),
|
|
644
|
-
headers: {
|
|
645
|
-
'X-RequestDigest': formDigestValue,
|
|
646
|
-
'IF-MATCH': '*',
|
|
647
|
-
'X-Http-Method': 'PATCH'
|
|
648
|
-
}
|
|
649
|
-
});
|
|
650
|
-
case 3:
|
|
651
|
-
response = _context5.v;
|
|
652
|
-
return _context5.a(2, response);
|
|
653
|
-
}
|
|
654
|
-
}, _callee5, this);
|
|
655
|
-
}));
|
|
656
|
-
function update_2(_x4, _x5, _x6) {
|
|
657
|
-
return _update_.apply(this, arguments);
|
|
658
|
-
}
|
|
659
|
-
return update_2;
|
|
660
|
-
}()
|
|
661
|
-
/**
|
|
662
|
-
* Creates a new item within the active list.
|
|
663
|
-
*
|
|
664
|
-
* @param listData SharePoint list item payload.
|
|
665
|
-
* @returns Axios response resolved from the create request.
|
|
666
|
-
*/
|
|
667
|
-
;
|
|
668
|
-
_proto.create_v2 =
|
|
669
|
-
/*#__PURE__*/
|
|
670
|
-
function () {
|
|
671
|
-
var _create_v = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(listData) {
|
|
672
|
-
var response, _t3, _t4, _t5, _t6, _t7;
|
|
673
|
-
return _regenerator().w(function (_context6) {
|
|
674
|
-
while (1) switch (_context6.n) {
|
|
675
|
-
case 0:
|
|
676
|
-
this.transformArraysToEdmStrings(listData);
|
|
677
|
-
listData.__metadata = {
|
|
678
|
-
type: "SP.Data." + this.listName + "ListItem"
|
|
679
|
-
};
|
|
680
|
-
_t3 = this;
|
|
681
|
-
_t4 = this.endpoint;
|
|
682
|
-
_t5 = JSON.stringify(listData);
|
|
683
|
-
_context6.n = 1;
|
|
684
|
-
return this.getDigest();
|
|
685
|
-
case 1:
|
|
686
|
-
_t6 = _context6.v;
|
|
687
|
-
_t7 = {
|
|
688
|
-
'X-RequestDigest': _t6,
|
|
689
|
-
'IF-MATCH': '*'
|
|
690
|
-
};
|
|
691
|
-
_context6.n = 2;
|
|
692
|
-
return _t3.instance.call(_t3, {
|
|
693
|
-
url: _t4,
|
|
694
|
-
method: 'POST',
|
|
695
|
-
data: _t5,
|
|
696
|
-
headers: _t7
|
|
697
|
-
});
|
|
698
|
-
case 2:
|
|
699
|
-
response = _context6.v;
|
|
700
|
-
return _context6.a(2, response);
|
|
701
|
-
}
|
|
702
|
-
}, _callee6, this);
|
|
703
|
-
}));
|
|
704
|
-
function create_v2(_x7) {
|
|
705
|
-
return _create_v.apply(this, arguments);
|
|
706
|
-
}
|
|
707
|
-
return create_v2;
|
|
708
|
-
}()
|
|
709
|
-
/**
|
|
710
|
-
* Uploads an attachment file to an existing list item.
|
|
711
|
-
*
|
|
712
|
-
* @param props File payload and target item identifier.
|
|
713
|
-
* @returns Axios response describing the upload result.
|
|
714
|
-
*/
|
|
715
|
-
;
|
|
716
|
-
_proto.createFile =
|
|
717
|
-
/*#__PURE__*/
|
|
718
|
-
function () {
|
|
719
|
-
var _createFile = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(_ref6) {
|
|
720
|
-
var file, itemId, requestUrl, res, _t8, _t9, _t0, _t1, _t10;
|
|
721
|
-
return _regenerator().w(function (_context7) {
|
|
722
|
-
while (1) switch (_context7.n) {
|
|
723
|
-
case 0:
|
|
724
|
-
file = _ref6.file, itemId = _ref6.itemId;
|
|
725
|
-
requestUrl = "_api/lists/getbytitle('" + this.listName + "')/items(" + itemId + ")/AttachmentFiles/add(FileName='" + file.name + "')";
|
|
726
|
-
_t8 = this.instance;
|
|
727
|
-
_t9 = requestUrl;
|
|
728
|
-
_t0 = file;
|
|
729
|
-
_context7.n = 1;
|
|
730
|
-
return this.getDigest();
|
|
731
|
-
case 1:
|
|
732
|
-
_t1 = _context7.v;
|
|
733
|
-
_t10 = {
|
|
734
|
-
'X-RequestDigest': _t1
|
|
735
|
-
};
|
|
736
|
-
_context7.n = 2;
|
|
737
|
-
return _t8.post.call(_t8, _t9, _t0, {
|
|
738
|
-
headers: _t10,
|
|
739
|
-
withCredentials: true
|
|
740
|
-
});
|
|
741
|
-
case 2:
|
|
742
|
-
res = _context7.v;
|
|
743
|
-
return _context7.a(2, res);
|
|
744
|
-
}
|
|
745
|
-
}, _callee7, this);
|
|
746
|
-
}));
|
|
747
|
-
function createFile(_x8) {
|
|
748
|
-
return _createFile.apply(this, arguments);
|
|
749
|
-
}
|
|
750
|
-
return createFile;
|
|
751
|
-
}()
|
|
752
|
-
/**
|
|
753
|
-
* Deletes an item using the current endpoint.
|
|
754
|
-
*
|
|
755
|
-
* @param ID Identifier of the entity to remove.
|
|
756
|
-
* @returns Axios response from the delete call.
|
|
757
|
-
*/
|
|
758
|
-
;
|
|
759
|
-
_proto["delete"] =
|
|
760
|
-
/*#__PURE__*/
|
|
761
|
-
function () {
|
|
762
|
-
var _delete2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(ID) {
|
|
763
|
-
var response;
|
|
764
|
-
return _regenerator().w(function (_context8) {
|
|
765
|
-
while (1) switch (_context8.n) {
|
|
766
|
-
case 0:
|
|
767
|
-
_context8.n = 1;
|
|
768
|
-
return this.instance["delete"](this.endpoint + "(" + ID + ")");
|
|
769
|
-
case 1:
|
|
770
|
-
response = _context8.v;
|
|
771
|
-
return _context8.a(2, response);
|
|
772
|
-
}
|
|
773
|
-
}, _callee8, this);
|
|
774
|
-
}));
|
|
775
|
-
function _delete(_x9) {
|
|
776
|
-
return _delete2.apply(this, arguments);
|
|
777
|
-
}
|
|
778
|
-
return _delete;
|
|
779
|
-
}();
|
|
780
|
-
_proto.sendEmail = /*#__PURE__*/function () {
|
|
781
|
-
var _sendEmail = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref7) {
|
|
782
|
-
var From, To, Subject, Body, httpRequest, response, _t11, _t12, _t13, _t14, _t15;
|
|
783
|
-
return _regenerator().w(function (_context9) {
|
|
784
|
-
while (1) switch (_context9.n) {
|
|
785
|
-
case 0:
|
|
786
|
-
From = _ref7.From, To = _ref7.To, Subject = _ref7.Subject, Body = _ref7.Body;
|
|
787
|
-
httpRequest = '_api/SP.Utilities.Utility.SendEmail';
|
|
788
|
-
_t11 = this;
|
|
789
|
-
_t12 = httpRequest;
|
|
790
|
-
_context9.n = 1;
|
|
791
|
-
return this.getDigest();
|
|
792
|
-
case 1:
|
|
793
|
-
_t13 = _context9.v;
|
|
794
|
-
_t14 = {
|
|
795
|
-
'X-RequestDigest': _t13,
|
|
796
|
-
'X-Http-Method': 'POST',
|
|
797
|
-
'Content-Type': 'application/json;odata=verbose'
|
|
798
|
-
};
|
|
799
|
-
_t15 = JSON.stringify({
|
|
800
|
-
properties: {
|
|
801
|
-
__metadata: {
|
|
802
|
-
type: 'SP.Utilities.EmailProperties'
|
|
803
|
-
},
|
|
804
|
-
From: From,
|
|
805
|
-
To: {
|
|
806
|
-
results: Array.isArray(To) ? To : [To]
|
|
807
|
-
},
|
|
808
|
-
Body: Body,
|
|
809
|
-
Subject: Subject
|
|
810
|
-
}
|
|
811
|
-
});
|
|
812
|
-
_context9.n = 2;
|
|
813
|
-
return _t11.instance.call(_t11, {
|
|
814
|
-
url: _t12,
|
|
815
|
-
method: 'POST',
|
|
816
|
-
headers: _t14,
|
|
817
|
-
data: _t15
|
|
818
|
-
});
|
|
819
|
-
case 2:
|
|
820
|
-
response = _context9.v;
|
|
821
|
-
return _context9.a(2, response);
|
|
822
|
-
}
|
|
823
|
-
}, _callee9, this);
|
|
824
|
-
}));
|
|
825
|
-
function sendEmail(_x0) {
|
|
826
|
-
return _sendEmail.apply(this, arguments);
|
|
827
|
-
}
|
|
828
|
-
return sendEmail;
|
|
829
|
-
}()
|
|
830
|
-
/**
|
|
831
|
-
* Queries SharePoint's people picker endpoint for matching users.
|
|
832
|
-
*
|
|
833
|
-
* @param input Free-text search term.
|
|
834
|
-
* @param filter Optional additional filter condition.
|
|
835
|
-
* @returns Promise with type-ahead results payload.
|
|
836
|
-
*/
|
|
837
|
-
;
|
|
838
|
-
_proto.typeAhead =
|
|
839
|
-
/*#__PURE__*/
|
|
840
|
-
function () {
|
|
841
|
-
var _typeAhead = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(input, filter) {
|
|
842
|
-
var filterValue, response;
|
|
843
|
-
return _regenerator().w(function (_context0) {
|
|
844
|
-
while (1) switch (_context0.n) {
|
|
845
|
-
case 0:
|
|
846
|
-
filterValue = filter ? " and " + filter : '';
|
|
847
|
-
_context0.n = 1;
|
|
848
|
-
return this.instance.get("_vti_bin/listdata.svc/UserInformationList?$top=10&$filter=substringof('" + input + "',Name) or substringof('" + input + "',WorkEmail)" + filterValue);
|
|
849
|
-
case 1:
|
|
850
|
-
response = _context0.v;
|
|
851
|
-
return _context0.a(2, response.data.d);
|
|
852
|
-
}
|
|
853
|
-
}, _callee0, this);
|
|
854
|
-
}));
|
|
855
|
-
function typeAhead(_x1, _x10) {
|
|
856
|
-
return _typeAhead.apply(this, arguments);
|
|
857
|
-
}
|
|
858
|
-
return typeAhead;
|
|
859
|
-
}()
|
|
860
|
-
/**
|
|
861
|
-
* Retrieves the current user profile and flattens selected properties.
|
|
862
|
-
*
|
|
863
|
-
* @returns Promise containing the current user's profile information.
|
|
864
|
-
*/
|
|
865
|
-
;
|
|
866
|
-
_proto.currentUserProperties =
|
|
867
|
-
/*#__PURE__*/
|
|
868
|
-
function () {
|
|
869
|
-
var _currentUserProperties = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
870
|
-
var requestUrl, profile;
|
|
871
|
-
return _regenerator().w(function (_context1) {
|
|
872
|
-
while (1) switch (_context1.n) {
|
|
873
|
-
case 0:
|
|
874
|
-
requestUrl = '_api/sp.userprofiles.peoplemanager/getmyproperties';
|
|
875
|
-
_context1.n = 1;
|
|
876
|
-
return this.instance.get(requestUrl);
|
|
877
|
-
case 1:
|
|
878
|
-
profile = _context1.v;
|
|
879
|
-
profile = profile.data.d;
|
|
880
|
-
profile.UserProfileProperties.results.forEach(function (prop) {
|
|
881
|
-
if (prop.Key === 'FirstName') {
|
|
882
|
-
profile.FirstName = prop.Value;
|
|
883
|
-
}
|
|
884
|
-
if (prop.Key === 'LastName') {
|
|
885
|
-
profile.LastName = prop.Value;
|
|
886
|
-
}
|
|
887
|
-
if (prop.Key === 'Country') {
|
|
888
|
-
profile.Country = prop.Value;
|
|
889
|
-
}
|
|
890
|
-
if (prop.Key === 'UserName') {
|
|
891
|
-
profile.UserName = prop.Value;
|
|
892
|
-
}
|
|
893
|
-
});
|
|
894
|
-
return _context1.a(2, profile);
|
|
895
|
-
}
|
|
896
|
-
}, _callee1, this);
|
|
897
|
-
}));
|
|
898
|
-
function currentUserProperties() {
|
|
899
|
-
return _currentUserProperties.apply(this, arguments);
|
|
900
|
-
}
|
|
901
|
-
return currentUserProperties;
|
|
902
|
-
}()
|
|
903
|
-
/**
|
|
904
|
-
* Searches site users based on a substring match across common fields.
|
|
905
|
-
*
|
|
906
|
-
* @param searchValue Term to match against the SharePoint user directory.
|
|
907
|
-
* @returns Promise with matching site users and their groups.
|
|
908
|
-
*/
|
|
909
|
-
;
|
|
910
|
-
_proto.getSiteUser =
|
|
911
|
-
/*#__PURE__*/
|
|
912
|
-
function () {
|
|
913
|
-
var _getSiteUser = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(searchValue) {
|
|
914
|
-
var requestUrl, response;
|
|
915
|
-
return _regenerator().w(function (_context10) {
|
|
916
|
-
while (1) switch (_context10.n) {
|
|
917
|
-
case 0:
|
|
918
|
-
requestUrl = "_api/web/siteusers?&$filter=substringof('" + searchValue + "', Title) or substringof('" + searchValue + "', LoginName) or substringof('" + searchValue + "', Email)&$top=50&$expand=Groups";
|
|
919
|
-
_context10.n = 1;
|
|
920
|
-
return this.instance.get(requestUrl);
|
|
921
|
-
case 1:
|
|
922
|
-
response = _context10.v;
|
|
923
|
-
return _context10.a(2, response.data.d);
|
|
924
|
-
}
|
|
925
|
-
}, _callee10, this);
|
|
926
|
-
}));
|
|
927
|
-
function getSiteUser(_x11) {
|
|
928
|
-
return _getSiteUser.apply(this, arguments);
|
|
929
|
-
}
|
|
930
|
-
return getSiteUser;
|
|
931
|
-
}()
|
|
932
|
-
/**
|
|
933
|
-
* Retrieves all available role definitions for the current site.
|
|
934
|
-
*
|
|
935
|
-
* @returns Promise resolving to an array of role definitions.
|
|
936
|
-
*/
|
|
937
|
-
;
|
|
938
|
-
_proto.roleDefinitions =
|
|
939
|
-
/*#__PURE__*/
|
|
940
|
-
function () {
|
|
941
|
-
var _roleDefinitions = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
942
|
-
var requestUrl, response;
|
|
943
|
-
return _regenerator().w(function (_context11) {
|
|
944
|
-
while (1) switch (_context11.n) {
|
|
945
|
-
case 0:
|
|
946
|
-
requestUrl = "_api/Web/RoleDefinitions";
|
|
947
|
-
_context11.n = 1;
|
|
948
|
-
return this.instance.get(requestUrl);
|
|
949
|
-
case 1:
|
|
950
|
-
response = _context11.v;
|
|
951
|
-
return _context11.a(2, response.data.d.results);
|
|
952
|
-
}
|
|
953
|
-
}, _callee11, this);
|
|
954
|
-
}));
|
|
955
|
-
function roleDefinitions() {
|
|
956
|
-
return _roleDefinitions.apply(this, arguments);
|
|
957
|
-
}
|
|
958
|
-
return roleDefinitions;
|
|
959
|
-
}()
|
|
960
|
-
/**
|
|
961
|
-
* Fetches the bit-encoded permissions of the current user.
|
|
962
|
-
*
|
|
963
|
-
* @returns Promise resolving to the `EffectiveBasePermissions` object.
|
|
964
|
-
*/
|
|
965
|
-
;
|
|
966
|
-
_proto.getEffectiveBasePermissions =
|
|
967
|
-
/*#__PURE__*/
|
|
968
|
-
function () {
|
|
969
|
-
var _getEffectiveBasePermissions = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
970
|
-
var requestUrl, response;
|
|
971
|
-
return _regenerator().w(function (_context12) {
|
|
972
|
-
while (1) switch (_context12.n) {
|
|
973
|
-
case 0:
|
|
974
|
-
requestUrl = "_api/Web/effectiveBasePermissions";
|
|
975
|
-
_context12.n = 1;
|
|
976
|
-
return this.instance.get(requestUrl);
|
|
977
|
-
case 1:
|
|
978
|
-
response = _context12.v;
|
|
979
|
-
return _context12.a(2, response.data.d.EffectiveBasePermissions);
|
|
980
|
-
}
|
|
981
|
-
}, _callee12, this);
|
|
982
|
-
}));
|
|
983
|
-
function getEffectiveBasePermissions() {
|
|
984
|
-
return _getEffectiveBasePermissions.apply(this, arguments);
|
|
985
|
-
}
|
|
986
|
-
return getEffectiveBasePermissions;
|
|
987
|
-
}()
|
|
988
|
-
/**
|
|
989
|
-
* Matches the current user's effective permissions against known role definitions.
|
|
990
|
-
*
|
|
991
|
-
* @returns The matching SharePoint role definition as a structured permission object.
|
|
992
|
-
*/
|
|
993
|
-
;
|
|
994
|
-
_proto.currentUserPermissions =
|
|
995
|
-
/*#__PURE__*/
|
|
996
|
-
function () {
|
|
997
|
-
var _currentUserPermissions = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
998
|
-
var _yield$this$getEffect, High, roleDefinitions, result;
|
|
999
|
-
return _regenerator().w(function (_context13) {
|
|
1000
|
-
while (1) switch (_context13.n) {
|
|
1001
|
-
case 0:
|
|
1002
|
-
_context13.n = 1;
|
|
1003
|
-
return this.getEffectiveBasePermissions();
|
|
1004
|
-
case 1:
|
|
1005
|
-
_yield$this$getEffect = _context13.v;
|
|
1006
|
-
High = _yield$this$getEffect.High;
|
|
1007
|
-
_context13.n = 2;
|
|
1008
|
-
return this.roleDefinitions();
|
|
1009
|
-
case 2:
|
|
1010
|
-
roleDefinitions = _context13.v;
|
|
1011
|
-
result = roleDefinitions.find(function (_ref8) {
|
|
1012
|
-
var BasePermissions = _ref8.BasePermissions;
|
|
1013
|
-
return BasePermissions.High === High;
|
|
1014
|
-
});
|
|
1015
|
-
return _context13.a(2, result);
|
|
1016
|
-
}
|
|
1017
|
-
}, _callee13, this);
|
|
1018
|
-
}));
|
|
1019
|
-
function currentUserPermissions() {
|
|
1020
|
-
return _currentUserPermissions.apply(this, arguments);
|
|
1021
|
-
}
|
|
1022
|
-
return currentUserPermissions;
|
|
1023
|
-
}();
|
|
867
|
+
};
|
|
1024
868
|
return HTTPSharePointRequests;
|
|
1025
869
|
}();
|
|
1026
870
|
|
|
1027
871
|
// Load environment variables from .env file
|
|
1028
872
|
function createBase() {
|
|
1029
873
|
function create(_ref) {
|
|
1030
|
-
var baseURL = _ref.baseURL
|
|
874
|
+
var baseURL = _ref.baseURL,
|
|
875
|
+
config = _ref.config;
|
|
1031
876
|
if (!baseURL) {
|
|
1032
877
|
throw new Error('A valid SharePoint URL must be provided.');
|
|
1033
878
|
}
|
|
1034
|
-
return new HTTPSharePointRequests(baseURL);
|
|
879
|
+
return new HTTPSharePointRequests(baseURL, config);
|
|
1035
880
|
}
|
|
1036
881
|
return {
|
|
1037
882
|
/**
|
|
1038
883
|
* @deprecated Use `create` instead.
|
|
1039
884
|
*/
|
|
1040
|
-
baseURL: function baseURL(url) {
|
|
885
|
+
baseURL: function baseURL(url, config) {
|
|
1041
886
|
return create({
|
|
1042
|
-
baseURL: url
|
|
887
|
+
baseURL: url,
|
|
888
|
+
config: config
|
|
1043
889
|
});
|
|
1044
890
|
},
|
|
1045
891
|
create: create
|