@lindle/sharepoint_requests 0.1.18 → 0.1.19
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/README.md +121 -116
- package/dist/index.d.ts +2 -2
- package/dist/root/index.d.ts +104 -29
- package/dist/root/internal/context.d.ts +2 -2
- package/dist/root/internal/digest.d.ts +1 -1
- package/dist/root/internal/emailRequests.d.ts +3 -3
- package/dist/root/internal/listRequests/createAttachment.d.ts +2 -2
- package/dist/root/internal/listRequests/createListItem.d.ts +2 -2
- package/dist/root/internal/listRequests/deleteFile.d.ts +2 -2
- package/dist/root/internal/listRequests/deleteItem.d.ts +2 -2
- package/dist/root/internal/listRequests/getFiles.d.ts +2 -2
- package/dist/root/internal/listRequests/getListItems.d.ts +3 -3
- package/dist/root/internal/listRequests/getOnly.d.ts +2 -2
- package/dist/root/internal/listRequests/normalizePayload.d.ts +1 -1
- package/dist/root/internal/listRequests/updateListItem.d.ts +2 -2
- package/dist/root/internal/listRequests/uploadFile.d.ts +3 -3
- package/dist/root/internal/odata.d.ts +1 -1
- package/dist/root/internal/sharepointUrl.d.ts +2 -0
- package/dist/root/internal/userRequests.d.ts +3 -3
- package/dist/sharepoint_requests.cjs.development.js +397 -225
- 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 +397 -225
- package/dist/sharepoint_requests.esm.js.map +1 -1
- package/dist/types.d.ts +10 -6
- package/package.json +1 -1
- package/src/index.ts +3 -5
- package/src/root/index.ts +260 -145
- package/src/root/internal/context.ts +2 -2
- package/src/root/internal/digest.ts +4 -3
- package/src/root/internal/emailRequests.ts +4 -7
- package/src/root/internal/listRequests/createAttachment.ts +14 -3
- package/src/root/internal/listRequests/createListItem.ts +18 -12
- package/src/root/internal/listRequests/deleteFile.ts +4 -3
- package/src/root/internal/listRequests/deleteItem.ts +17 -3
- package/src/root/internal/listRequests/getFiles.ts +4 -10
- package/src/root/internal/listRequests/getListItems.ts +16 -9
- package/src/root/internal/listRequests/getOnly.ts +10 -7
- package/src/root/internal/listRequests/normalizePayload.ts +1 -1
- package/src/root/internal/listRequests/updateListItem.ts +24 -14
- package/src/root/internal/listRequests/uploadFile.ts +5 -8
- package/src/root/internal/listRequests/utils.ts +1 -1
- package/src/root/internal/odata.ts +2 -4
- package/src/root/internal/sharepointUrl.ts +7 -0
- package/src/root/internal/userRequests.ts +43 -11
- package/src/types.ts +152 -148
|
@@ -194,7 +194,7 @@ function fetchDigest(_x, _x2) {
|
|
|
194
194
|
}
|
|
195
195
|
function _fetchDigest() {
|
|
196
196
|
_fetchDigest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(instance, baseURL) {
|
|
197
|
-
var _response$data, response, formDigestValue, _t;
|
|
197
|
+
var _response$data, response, formDigestValue, cause, _t;
|
|
198
198
|
return _regenerator().w(function (_context) {
|
|
199
199
|
while (1) switch (_context.p = _context.n) {
|
|
200
200
|
case 0:
|
|
@@ -214,8 +214,8 @@ function _fetchDigest() {
|
|
|
214
214
|
case 3:
|
|
215
215
|
_context.p = 3;
|
|
216
216
|
_t = _context.v;
|
|
217
|
-
|
|
218
|
-
throw new Error("Error retrieving Form Digest Value");
|
|
217
|
+
cause = _t instanceof Error ? _t.message : 'Unknown contextinfo error';
|
|
218
|
+
throw new Error("Error retrieving Form Digest Value: " + cause);
|
|
219
219
|
case 4:
|
|
220
220
|
return _context.a(2);
|
|
221
221
|
}
|
|
@@ -224,6 +224,57 @@ function _fetchDigest() {
|
|
|
224
224
|
return _fetchDigest.apply(this, arguments);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
function sendEmail(_x, _x2) {
|
|
228
|
+
return _sendEmail.apply(this, arguments);
|
|
229
|
+
}
|
|
230
|
+
function _sendEmail() {
|
|
231
|
+
_sendEmail = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, _ref) {
|
|
232
|
+
var From, To, Subject, Body, httpRequest, response, _t, _t2, _t3, _t4, _t5;
|
|
233
|
+
return _regenerator().w(function (_context) {
|
|
234
|
+
while (1) switch (_context.n) {
|
|
235
|
+
case 0:
|
|
236
|
+
From = _ref.From, To = _ref.To, Subject = _ref.Subject, Body = _ref.Body;
|
|
237
|
+
httpRequest = '_api/SP.Utilities.Utility.SendEmail';
|
|
238
|
+
_t = context;
|
|
239
|
+
_t2 = httpRequest;
|
|
240
|
+
_context.n = 1;
|
|
241
|
+
return fetchDigest(context.instance, context.baseURL);
|
|
242
|
+
case 1:
|
|
243
|
+
_t3 = _context.v;
|
|
244
|
+
_t4 = {
|
|
245
|
+
'X-RequestDigest': _t3,
|
|
246
|
+
'X-Http-Method': 'POST',
|
|
247
|
+
'Content-Type': 'application/json;odata=verbose'
|
|
248
|
+
};
|
|
249
|
+
_t5 = JSON.stringify({
|
|
250
|
+
properties: {
|
|
251
|
+
__metadata: {
|
|
252
|
+
type: 'SP.Utilities.EmailProperties'
|
|
253
|
+
},
|
|
254
|
+
From: From,
|
|
255
|
+
To: {
|
|
256
|
+
results: Array.isArray(To) ? To : [To]
|
|
257
|
+
},
|
|
258
|
+
Body: Body,
|
|
259
|
+
Subject: Subject
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
_context.n = 2;
|
|
263
|
+
return _t.instance.call(_t, {
|
|
264
|
+
url: _t2,
|
|
265
|
+
method: 'POST',
|
|
266
|
+
headers: _t4,
|
|
267
|
+
data: _t5
|
|
268
|
+
});
|
|
269
|
+
case 2:
|
|
270
|
+
response = _context.v;
|
|
271
|
+
return _context.a(2, response);
|
|
272
|
+
}
|
|
273
|
+
}, _callee);
|
|
274
|
+
}));
|
|
275
|
+
return _sendEmail.apply(this, arguments);
|
|
276
|
+
}
|
|
277
|
+
|
|
227
278
|
var LOOKUP_ID_KEYS = ['lookupId', 'LookupId', 'lookupID', 'LookupID', 'Id', 'ID'];
|
|
228
279
|
function isPlainObject(value) {
|
|
229
280
|
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
@@ -393,39 +444,45 @@ function createListItem(_x2, _x3) {
|
|
|
393
444
|
}
|
|
394
445
|
function _createListItem() {
|
|
395
446
|
_createListItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(context, listData) {
|
|
396
|
-
var
|
|
447
|
+
var normalizedData, payload, metadataType, userMetadata, response, _t, _t2, _t3, _t4, _t5;
|
|
397
448
|
return _regenerator().w(function (_context2) {
|
|
398
449
|
while (1) switch (_context2.n) {
|
|
399
450
|
case 0:
|
|
451
|
+
normalizedData = normalizeListPayload(listData);
|
|
452
|
+
payload = normalizedData;
|
|
453
|
+
if (!(context.sharepointVersion === '2013')) {
|
|
454
|
+
_context2.n = 2;
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
400
457
|
_context2.n = 1;
|
|
401
458
|
return resolveMetadataType(context);
|
|
402
459
|
case 1:
|
|
403
460
|
metadataType = _context2.v;
|
|
404
|
-
normalizedData = normalizeListPayload(listData);
|
|
405
461
|
userMetadata = listData.__metadata;
|
|
406
462
|
payload = _extends({}, normalizedData, {
|
|
407
463
|
__metadata: _extends({}, userMetadata && typeof userMetadata === 'object' ? userMetadata : {}, {
|
|
408
464
|
type: metadataType
|
|
409
465
|
})
|
|
410
466
|
});
|
|
467
|
+
case 2:
|
|
411
468
|
_t = context;
|
|
412
469
|
_t2 = context.endpoint;
|
|
413
470
|
_t3 = JSON.stringify(payload);
|
|
414
|
-
_context2.n =
|
|
471
|
+
_context2.n = 3;
|
|
415
472
|
return fetchDigest(context.instance, context.baseURL);
|
|
416
|
-
case
|
|
473
|
+
case 3:
|
|
417
474
|
_t4 = _context2.v;
|
|
418
475
|
_t5 = {
|
|
419
476
|
'X-RequestDigest': _t4
|
|
420
477
|
};
|
|
421
|
-
_context2.n =
|
|
478
|
+
_context2.n = 4;
|
|
422
479
|
return _t.instance.call(_t, {
|
|
423
480
|
url: _t2,
|
|
424
481
|
method: 'POST',
|
|
425
482
|
data: _t3,
|
|
426
483
|
headers: _t5
|
|
427
484
|
});
|
|
428
|
-
case
|
|
485
|
+
case 4:
|
|
429
486
|
response = _context2.v;
|
|
430
487
|
return _context2.a(2, response);
|
|
431
488
|
}
|
|
@@ -434,33 +491,71 @@ function _createListItem() {
|
|
|
434
491
|
return _createListItem.apply(this, arguments);
|
|
435
492
|
}
|
|
436
493
|
|
|
494
|
+
function escapeODataStringLiteral(value) {
|
|
495
|
+
return value.replace(/'/g, "''");
|
|
496
|
+
}
|
|
497
|
+
function buildListByTitleEndpoint(listName) {
|
|
498
|
+
return "_api/web/lists/GetByTitle('" + escapeODataStringLiteral(listName) + "')";
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function buildLibraryPath(folderPath) {
|
|
502
|
+
if (!folderPath) {
|
|
503
|
+
return '';
|
|
504
|
+
}
|
|
505
|
+
var segments = Array.isArray(folderPath) ? folderPath : folderPath.split('/').filter(Boolean);
|
|
506
|
+
if (!segments.length) {
|
|
507
|
+
return '';
|
|
508
|
+
}
|
|
509
|
+
var escapedSegments = segments.map(function (segment) {
|
|
510
|
+
if (!segment.trim()) {
|
|
511
|
+
throw new Error('Folder path segments cannot be empty.');
|
|
512
|
+
}
|
|
513
|
+
var sanitized = segment.replace(/'/g, "''");
|
|
514
|
+
return "/Folders('" + encodeURIComponent(sanitized) + "')";
|
|
515
|
+
});
|
|
516
|
+
return escapedSegments.join('');
|
|
517
|
+
}
|
|
518
|
+
function encodeFileName(fileName) {
|
|
519
|
+
if (!fileName.trim()) {
|
|
520
|
+
throw new Error('File name cannot be empty.');
|
|
521
|
+
}
|
|
522
|
+
return encodeURIComponent(fileName.replace(/'/g, "''"));
|
|
523
|
+
}
|
|
524
|
+
|
|
437
525
|
function createAttachment(_x, _x2) {
|
|
438
526
|
return _createAttachment.apply(this, arguments);
|
|
439
527
|
}
|
|
440
528
|
function _createAttachment() {
|
|
441
529
|
_createAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, _ref) {
|
|
442
|
-
var file, itemId, requestUrl, response, _t, _t2, _t3, _t4, _t5;
|
|
530
|
+
var file, itemId, encodedFileName, requestUrl, response, _t, _t2, _t3, _t4, _t5;
|
|
443
531
|
return _regenerator().w(function (_context) {
|
|
444
532
|
while (1) switch (_context.n) {
|
|
445
533
|
case 0:
|
|
446
534
|
file = _ref.file, itemId = _ref.itemId;
|
|
447
|
-
|
|
535
|
+
if (!(context.sharepointVersion !== '2013')) {
|
|
536
|
+
_context.n = 1;
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
throw new Error('createAttachment is only supported for SharePoint 2013 REST endpoints.');
|
|
540
|
+
case 1:
|
|
541
|
+
encodedFileName = encodeFileName(file.name);
|
|
542
|
+
requestUrl = buildListByTitleEndpoint(context.listName) + "/items(" + itemId + ")/AttachmentFiles/add(FileName='" + encodedFileName + "')";
|
|
448
543
|
_t = context.instance;
|
|
449
544
|
_t2 = requestUrl;
|
|
450
545
|
_t3 = file;
|
|
451
|
-
_context.n =
|
|
546
|
+
_context.n = 2;
|
|
452
547
|
return fetchDigest(context.instance, context.baseURL);
|
|
453
|
-
case
|
|
548
|
+
case 2:
|
|
454
549
|
_t4 = _context.v;
|
|
455
550
|
_t5 = {
|
|
456
551
|
'X-RequestDigest': _t4
|
|
457
552
|
};
|
|
458
|
-
_context.n =
|
|
553
|
+
_context.n = 3;
|
|
459
554
|
return _t.post.call(_t, _t2, _t3, {
|
|
460
555
|
headers: _t5,
|
|
461
556
|
withCredentials: true
|
|
462
557
|
});
|
|
463
|
-
case
|
|
558
|
+
case 3:
|
|
464
559
|
response = _context.v;
|
|
465
560
|
return _context.a(2, response);
|
|
466
561
|
}
|
|
@@ -474,13 +569,24 @@ function deleteItem(_x, _x2) {
|
|
|
474
569
|
}
|
|
475
570
|
function _deleteItem() {
|
|
476
571
|
_deleteItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, id) {
|
|
477
|
-
var response;
|
|
572
|
+
var requestDigest, url, response;
|
|
478
573
|
return _regenerator().w(function (_context) {
|
|
479
574
|
while (1) switch (_context.n) {
|
|
480
575
|
case 0:
|
|
481
576
|
_context.n = 1;
|
|
482
|
-
return context.instance
|
|
577
|
+
return fetchDigest(context.instance, context.baseURL);
|
|
483
578
|
case 1:
|
|
579
|
+
requestDigest = _context.v;
|
|
580
|
+
url = context.sharepointVersion === '2013' ? buildListByTitleEndpoint(context.listName) + "/items(" + id + ")" : context.endpoint + "(" + id + ")";
|
|
581
|
+
_context.n = 2;
|
|
582
|
+
return context.instance.post(url, undefined, {
|
|
583
|
+
headers: {
|
|
584
|
+
'X-RequestDigest': requestDigest,
|
|
585
|
+
'IF-MATCH': '*',
|
|
586
|
+
'X-HTTP-Method': 'DELETE'
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
case 2:
|
|
484
590
|
response = _context.v;
|
|
485
591
|
return _context.a(2, response);
|
|
486
592
|
}
|
|
@@ -489,30 +595,6 @@ function _deleteItem() {
|
|
|
489
595
|
return _deleteItem.apply(this, arguments);
|
|
490
596
|
}
|
|
491
597
|
|
|
492
|
-
function buildLibraryPath(folderPath) {
|
|
493
|
-
if (!folderPath) {
|
|
494
|
-
return '';
|
|
495
|
-
}
|
|
496
|
-
var segments = Array.isArray(folderPath) ? folderPath : folderPath.split('/').filter(Boolean);
|
|
497
|
-
if (!segments.length) {
|
|
498
|
-
return '';
|
|
499
|
-
}
|
|
500
|
-
var escapedSegments = segments.map(function (segment) {
|
|
501
|
-
if (!segment.trim()) {
|
|
502
|
-
throw new Error('Folder path segments cannot be empty.');
|
|
503
|
-
}
|
|
504
|
-
var sanitized = segment.replace(/'/g, "''");
|
|
505
|
-
return "/Folders('" + encodeURIComponent(sanitized) + "')";
|
|
506
|
-
});
|
|
507
|
-
return escapedSegments.join('');
|
|
508
|
-
}
|
|
509
|
-
function encodeFileName(fileName) {
|
|
510
|
-
if (!fileName.trim()) {
|
|
511
|
-
throw new Error('File name cannot be empty.');
|
|
512
|
-
}
|
|
513
|
-
return encodeURIComponent(fileName.replace(/'/g, "''"));
|
|
514
|
-
}
|
|
515
|
-
|
|
516
598
|
var SUPPORTED_VERSION = '2013';
|
|
517
599
|
function deleteFile(_x, _x2) {
|
|
518
600
|
return _deleteFile.apply(this, arguments);
|
|
@@ -531,7 +613,7 @@ function _deleteFile() {
|
|
|
531
613
|
throw new Error('deleteFile is only supported for SharePoint 2013 REST endpoints.');
|
|
532
614
|
case 1:
|
|
533
615
|
encodedFileName = encodeFileName(fileName);
|
|
534
|
-
requestUrl =
|
|
616
|
+
requestUrl = buildListByTitleEndpoint(context.listName) + "/RootFolder";
|
|
535
617
|
requestUrl += buildLibraryPath(folderPath);
|
|
536
618
|
requestUrl += "/Files('" + encodedFileName + "')";
|
|
537
619
|
_context.n = 2;
|
|
@@ -592,6 +674,7 @@ function getFiles(_x, _x2) {
|
|
|
592
674
|
}
|
|
593
675
|
function _getFiles() {
|
|
594
676
|
_getFiles = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, options) {
|
|
677
|
+
var _ref, _response$data$d$resu, _response$data, _response$data2;
|
|
595
678
|
var params, url, response, data, meta;
|
|
596
679
|
return _regenerator().w(function (_context) {
|
|
597
680
|
while (1) switch (_context.n) {
|
|
@@ -607,7 +690,7 @@ function _getFiles() {
|
|
|
607
690
|
});
|
|
608
691
|
case 1:
|
|
609
692
|
response = _context.v;
|
|
610
|
-
data =
|
|
693
|
+
data = (_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;
|
|
611
694
|
meta = {
|
|
612
695
|
url: url
|
|
613
696
|
};
|
|
@@ -687,13 +770,19 @@ function _getOnly() {
|
|
|
687
770
|
case 1:
|
|
688
771
|
_yield$instance$get = _context.v;
|
|
689
772
|
data = _yield$instance$get.data;
|
|
690
|
-
if (
|
|
773
|
+
if (data) {
|
|
691
774
|
_context.n = 2;
|
|
692
775
|
break;
|
|
693
776
|
}
|
|
694
|
-
return _context.a(2,
|
|
777
|
+
return _context.a(2, undefined);
|
|
695
778
|
case 2:
|
|
696
|
-
|
|
779
|
+
if (!data.d) {
|
|
780
|
+
_context.n = 3;
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
return _context.a(2, data.d.results ? data.d.results : data.d);
|
|
784
|
+
case 3:
|
|
785
|
+
return _context.a(2, data);
|
|
697
786
|
}
|
|
698
787
|
}, _callee);
|
|
699
788
|
}));
|
|
@@ -731,7 +820,7 @@ function updateListItem(_x2, _x3, _x4, _x5) {
|
|
|
731
820
|
}
|
|
732
821
|
function _updateListItem() {
|
|
733
822
|
_updateListItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(context, id, data, digest) {
|
|
734
|
-
var formDigestValue,
|
|
823
|
+
var formDigestValue, normalizedData, payload, metadataType, userMetadata, url, response, _t;
|
|
735
824
|
return _regenerator().w(function (_context2) {
|
|
736
825
|
while (1) switch (_context2.n) {
|
|
737
826
|
case 0:
|
|
@@ -746,19 +835,25 @@ function _updateListItem() {
|
|
|
746
835
|
_t = _context2.v;
|
|
747
836
|
case 2:
|
|
748
837
|
formDigestValue = _t;
|
|
838
|
+
normalizedData = normalizeListPayload(data);
|
|
839
|
+
payload = normalizedData;
|
|
840
|
+
if (!(context.sharepointVersion === '2013')) {
|
|
841
|
+
_context2.n = 4;
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
749
844
|
_context2.n = 3;
|
|
750
845
|
return resolveMetadataType$1(context);
|
|
751
846
|
case 3:
|
|
752
847
|
metadataType = _context2.v;
|
|
753
|
-
normalizedData = normalizeListPayload(data);
|
|
754
848
|
userMetadata = data.__metadata;
|
|
755
849
|
payload = _extends({}, normalizedData, {
|
|
756
850
|
__metadata: _extends({}, userMetadata && typeof userMetadata === 'object' ? userMetadata : {}, {
|
|
757
851
|
type: metadataType
|
|
758
852
|
})
|
|
759
853
|
});
|
|
760
|
-
|
|
761
|
-
|
|
854
|
+
case 4:
|
|
855
|
+
url = context.sharepointVersion === '2013' ? buildListByTitleEndpoint(context.listName) + "/items(" + id + ")" : context.endpoint + "(" + id + ")";
|
|
856
|
+
_context2.n = 5;
|
|
762
857
|
return context.instance({
|
|
763
858
|
url: url,
|
|
764
859
|
method: 'POST',
|
|
@@ -766,10 +861,10 @@ function _updateListItem() {
|
|
|
766
861
|
headers: {
|
|
767
862
|
'X-RequestDigest': formDigestValue,
|
|
768
863
|
'IF-MATCH': '*',
|
|
769
|
-
'X-
|
|
864
|
+
'X-HTTP-Method': 'MERGE'
|
|
770
865
|
}
|
|
771
866
|
});
|
|
772
|
-
case
|
|
867
|
+
case 5:
|
|
773
868
|
response = _context2.v;
|
|
774
869
|
return _context2.a(2, response);
|
|
775
870
|
}
|
|
@@ -802,7 +897,7 @@ function _uploadFile() {
|
|
|
802
897
|
}
|
|
803
898
|
throw new Error('A file with a valid name must be provided.');
|
|
804
899
|
case 2:
|
|
805
|
-
requestUrl =
|
|
900
|
+
requestUrl = buildListByTitleEndpoint(context.listName) + "/RootFolder";
|
|
806
901
|
requestUrl += buildLibraryPath(folderPath);
|
|
807
902
|
encodedFileName = encodeFileName(file.name);
|
|
808
903
|
requestUrl += "/Files/add(url='" + encodedFileName + "',overwrite=" + (overwrite ? 'true' : 'false') + ")?$expand=ListItemAllFields&$select=ListItemAllFields/Id";
|
|
@@ -851,63 +946,13 @@ function _uploadFile() {
|
|
|
851
946
|
return _uploadFile.apply(this, arguments);
|
|
852
947
|
}
|
|
853
948
|
|
|
854
|
-
function sendEmail(_x, _x2) {
|
|
855
|
-
return _sendEmail.apply(this, arguments);
|
|
856
|
-
}
|
|
857
|
-
function _sendEmail() {
|
|
858
|
-
_sendEmail = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, _ref) {
|
|
859
|
-
var From, To, Subject, Body, httpRequest, response, _t, _t2, _t3, _t4, _t5;
|
|
860
|
-
return _regenerator().w(function (_context) {
|
|
861
|
-
while (1) switch (_context.n) {
|
|
862
|
-
case 0:
|
|
863
|
-
From = _ref.From, To = _ref.To, Subject = _ref.Subject, Body = _ref.Body;
|
|
864
|
-
httpRequest = '_api/SP.Utilities.Utility.SendEmail';
|
|
865
|
-
_t = context;
|
|
866
|
-
_t2 = httpRequest;
|
|
867
|
-
_context.n = 1;
|
|
868
|
-
return fetchDigest(context.instance, context.baseURL);
|
|
869
|
-
case 1:
|
|
870
|
-
_t3 = _context.v;
|
|
871
|
-
_t4 = {
|
|
872
|
-
'X-RequestDigest': _t3,
|
|
873
|
-
'X-Http-Method': 'POST',
|
|
874
|
-
'Content-Type': 'application/json;odata=verbose'
|
|
875
|
-
};
|
|
876
|
-
_t5 = JSON.stringify({
|
|
877
|
-
properties: {
|
|
878
|
-
__metadata: {
|
|
879
|
-
type: 'SP.Utilities.EmailProperties'
|
|
880
|
-
},
|
|
881
|
-
From: From,
|
|
882
|
-
To: {
|
|
883
|
-
results: Array.isArray(To) ? To : [To]
|
|
884
|
-
},
|
|
885
|
-
Body: Body,
|
|
886
|
-
Subject: Subject
|
|
887
|
-
}
|
|
888
|
-
});
|
|
889
|
-
_context.n = 2;
|
|
890
|
-
return _t.instance.call(_t, {
|
|
891
|
-
url: _t2,
|
|
892
|
-
method: 'POST',
|
|
893
|
-
headers: _t4,
|
|
894
|
-
data: _t5
|
|
895
|
-
});
|
|
896
|
-
case 2:
|
|
897
|
-
response = _context.v;
|
|
898
|
-
return _context.a(2, response);
|
|
899
|
-
}
|
|
900
|
-
}, _callee);
|
|
901
|
-
}));
|
|
902
|
-
return _sendEmail.apply(this, arguments);
|
|
903
|
-
}
|
|
904
|
-
|
|
905
949
|
function typeAhead(_x, _x2, _x3) {
|
|
906
950
|
return _typeAhead.apply(this, arguments);
|
|
907
951
|
}
|
|
908
952
|
function _typeAhead() {
|
|
909
953
|
_typeAhead = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(instance, input, filter) {
|
|
910
|
-
var
|
|
954
|
+
var _response$data$d$Clie, _response$data, _response$data2;
|
|
955
|
+
var requestUrl, data, response, searchResults, parsed;
|
|
911
956
|
return _regenerator().w(function (_context) {
|
|
912
957
|
while (1) switch (_context.n) {
|
|
913
958
|
case 0:
|
|
@@ -939,7 +984,35 @@ function _typeAhead() {
|
|
|
939
984
|
});
|
|
940
985
|
case 1:
|
|
941
986
|
response = _context.v;
|
|
942
|
-
|
|
987
|
+
searchResults = (_response$data$d$Clie = (_response$data = response.data) == null || (_response$data = _response$data.d) == null ? void 0 : _response$data.ClientPeoplePickerSearchUser) != null ? _response$data$d$Clie : (_response$data2 = response.data) == null ? void 0 : _response$data2.ClientPeoplePickerSearchUser;
|
|
988
|
+
if (!(typeof searchResults === 'string')) {
|
|
989
|
+
_context.n = 3;
|
|
990
|
+
break;
|
|
991
|
+
}
|
|
992
|
+
parsed = JSON.parse(searchResults);
|
|
993
|
+
if (!(Array.isArray(parsed) && parsed.length > 0)) {
|
|
994
|
+
_context.n = 2;
|
|
995
|
+
break;
|
|
996
|
+
}
|
|
997
|
+
return _context.a(2, parsed[0]);
|
|
998
|
+
case 2:
|
|
999
|
+
throw new Error('People picker returned no results.');
|
|
1000
|
+
case 3:
|
|
1001
|
+
if (!(Array.isArray(searchResults) && searchResults.length > 0)) {
|
|
1002
|
+
_context.n = 4;
|
|
1003
|
+
break;
|
|
1004
|
+
}
|
|
1005
|
+
return _context.a(2, searchResults[0]);
|
|
1006
|
+
case 4:
|
|
1007
|
+
if (!(searchResults && typeof searchResults === 'object')) {
|
|
1008
|
+
_context.n = 5;
|
|
1009
|
+
break;
|
|
1010
|
+
}
|
|
1011
|
+
return _context.a(2, searchResults);
|
|
1012
|
+
case 5:
|
|
1013
|
+
throw new Error('Invalid people picker response.');
|
|
1014
|
+
case 6:
|
|
1015
|
+
return _context.a(2);
|
|
943
1016
|
}
|
|
944
1017
|
}, _callee);
|
|
945
1018
|
}));
|
|
@@ -985,13 +1058,19 @@ function getSiteUser(_x5, _x6) {
|
|
|
985
1058
|
}
|
|
986
1059
|
function _getSiteUser() {
|
|
987
1060
|
_getSiteUser = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(instance, searchValue) {
|
|
988
|
-
var
|
|
1061
|
+
var safeSearchValue, response;
|
|
989
1062
|
return _regenerator().w(function (_context3) {
|
|
990
1063
|
while (1) switch (_context3.n) {
|
|
991
1064
|
case 0:
|
|
992
|
-
|
|
1065
|
+
safeSearchValue = escapeODataStringLiteral(searchValue);
|
|
993
1066
|
_context3.n = 1;
|
|
994
|
-
return instance.get(
|
|
1067
|
+
return instance.get('_api/web/siteusers', {
|
|
1068
|
+
params: {
|
|
1069
|
+
$filter: "substringof('" + safeSearchValue + "', Title) or substringof('" + safeSearchValue + "', LoginName) or substringof('" + safeSearchValue + "', Email)",
|
|
1070
|
+
$top: 50,
|
|
1071
|
+
$expand: 'Groups'
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
995
1074
|
case 1:
|
|
996
1075
|
response = _context3.v;
|
|
997
1076
|
return _context3.a(2, response.data.d);
|
|
@@ -1062,6 +1141,12 @@ function _currentUserPermissions() {
|
|
|
1062
1141
|
var BasePermissions = _ref.BasePermissions;
|
|
1063
1142
|
return BasePermissions.High === High;
|
|
1064
1143
|
});
|
|
1144
|
+
if (result) {
|
|
1145
|
+
_context6.n = 3;
|
|
1146
|
+
break;
|
|
1147
|
+
}
|
|
1148
|
+
throw new Error("Unable to resolve current user permission for BasePermissions.High=\"" + High + "\".");
|
|
1149
|
+
case 3:
|
|
1065
1150
|
return _context6.a(2, result);
|
|
1066
1151
|
}
|
|
1067
1152
|
}, _callee6);
|
|
@@ -1073,155 +1158,160 @@ var HTTPSharePointRequests = /*#__PURE__*/function () {
|
|
|
1073
1158
|
function HTTPSharePointRequests(baseURL, config) {
|
|
1074
1159
|
var _this = this;
|
|
1075
1160
|
this.baseURL = void 0;
|
|
1076
|
-
this.endpoint = void 0;
|
|
1077
|
-
this.listName = void 0;
|
|
1078
1161
|
this.instance = void 0;
|
|
1079
|
-
this.
|
|
1080
|
-
this.
|
|
1081
|
-
this.lists = {
|
|
1082
|
-
get: function get() {
|
|
1083
|
-
_this.endpoint = '_api/web/lists';
|
|
1084
|
-
_this.sharepointVersion = '2013';
|
|
1085
|
-
return getListItems(_this.getContext());
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1088
|
-
this.folders = {
|
|
1089
|
-
get: function get() {
|
|
1090
|
-
_this.endpoint = '_api/web/folders';
|
|
1091
|
-
_this.sharepointVersion = '2013';
|
|
1092
|
-
getListItems(_this.getContext());
|
|
1093
|
-
}
|
|
1094
|
-
};
|
|
1095
|
-
this.email = {
|
|
1096
|
-
send: function send(props) {
|
|
1097
|
-
_this.sharepointVersion = '2013';
|
|
1098
|
-
return sendEmail(_this.getContext(), props);
|
|
1099
|
-
}
|
|
1100
|
-
};
|
|
1162
|
+
this.listItemEntityTypeCache = void 0;
|
|
1163
|
+
this.email = void 0;
|
|
1101
1164
|
this.user = {
|
|
1102
1165
|
properties: function properties() {
|
|
1103
1166
|
return {
|
|
1104
1167
|
get: function get() {
|
|
1105
|
-
_this.sharepointVersion = '2013';
|
|
1106
1168
|
return currentUserProperties(_this.instance);
|
|
1107
1169
|
}
|
|
1108
1170
|
};
|
|
1109
1171
|
},
|
|
1110
1172
|
searchSiteUser: function searchSiteUser(searchValue) {
|
|
1111
|
-
_this.sharepointVersion = '2013';
|
|
1112
1173
|
return getSiteUser(_this.instance, searchValue);
|
|
1113
1174
|
},
|
|
1114
1175
|
searchUser: function searchUser(input, filter) {
|
|
1115
|
-
_this.sharepointVersion = '2013';
|
|
1116
1176
|
return typeAhead(_this.instance, input, filter);
|
|
1117
1177
|
},
|
|
1118
1178
|
current: function current() {
|
|
1119
|
-
_this.endpoint = '_api/web/currentUser';
|
|
1120
|
-
_this.sharepointVersion = '2013';
|
|
1121
1179
|
return {
|
|
1122
1180
|
get: function get() {
|
|
1123
|
-
return getOnly(_this.instance,
|
|
1181
|
+
return getOnly(_this.instance, '_api/web/currentUser');
|
|
1124
1182
|
}
|
|
1125
1183
|
};
|
|
1126
1184
|
},
|
|
1127
1185
|
currentPermission: function currentPermission() {
|
|
1128
1186
|
return {
|
|
1129
1187
|
get: function get() {
|
|
1130
|
-
_this.
|
|
1131
|
-
|
|
1188
|
+
return currentUserPermissions(_this.createContext({
|
|
1189
|
+
endpoint: '_api/web/effectiveBasePermissions',
|
|
1190
|
+
listName: '',
|
|
1191
|
+
sharepointVersion: '2013'
|
|
1192
|
+
}));
|
|
1132
1193
|
}
|
|
1133
1194
|
};
|
|
1134
1195
|
}
|
|
1135
1196
|
};
|
|
1136
1197
|
this.baseURL = baseURL.endsWith('/') ? baseURL : baseURL + "/";
|
|
1137
|
-
this.endpoint = '/api';
|
|
1138
|
-
this.listName = '';
|
|
1139
1198
|
this.instance = instance(this.baseURL, config);
|
|
1140
|
-
this.
|
|
1141
|
-
this.
|
|
1199
|
+
this.listItemEntityTypeCache = new Map();
|
|
1200
|
+
this.email = Object.assign(function (from, to, subject, body) {
|
|
1201
|
+
return _this.sendEmail({
|
|
1202
|
+
From: from,
|
|
1203
|
+
To: to,
|
|
1204
|
+
Subject: subject,
|
|
1205
|
+
Body: body
|
|
1206
|
+
});
|
|
1207
|
+
}, {
|
|
1208
|
+
send: function send(props) {
|
|
1209
|
+
return _this.sendEmail(props);
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1142
1212
|
}
|
|
1143
1213
|
var _proto = HTTPSharePointRequests.prototype;
|
|
1144
|
-
_proto.
|
|
1214
|
+
_proto.createContext = function createContext(_ref) {
|
|
1215
|
+
var endpoint = _ref.endpoint,
|
|
1216
|
+
listName = _ref.listName,
|
|
1217
|
+
sharepointVersion = _ref.sharepointVersion,
|
|
1218
|
+
listItemEntityTypeFullName = _ref.listItemEntityTypeFullName,
|
|
1219
|
+
resolveListItemEntityType = _ref.resolveListItemEntityType;
|
|
1145
1220
|
return {
|
|
1146
1221
|
instance: this.instance,
|
|
1147
1222
|
baseURL: this.baseURL,
|
|
1148
|
-
endpoint:
|
|
1149
|
-
listName:
|
|
1150
|
-
sharepointVersion:
|
|
1151
|
-
listItemEntityTypeFullName:
|
|
1152
|
-
resolveListItemEntityType:
|
|
1223
|
+
endpoint: endpoint,
|
|
1224
|
+
listName: listName,
|
|
1225
|
+
sharepointVersion: sharepointVersion,
|
|
1226
|
+
listItemEntityTypeFullName: listItemEntityTypeFullName,
|
|
1227
|
+
resolveListItemEntityType: resolveListItemEntityType
|
|
1153
1228
|
};
|
|
1154
1229
|
};
|
|
1155
1230
|
_proto.resolveListItemEntityTypeFullName = /*#__PURE__*/function () {
|
|
1156
|
-
var _resolveListItemEntityTypeFullName = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
1231
|
+
var _resolveListItemEntityTypeFullName = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(listName) {
|
|
1157
1232
|
var _response$data$d$List, _response$data, _response$data2;
|
|
1158
|
-
var response, entityType;
|
|
1233
|
+
var cacheKey, cachedType, response, entityType;
|
|
1159
1234
|
return _regenerator().w(function (_context) {
|
|
1160
1235
|
while (1) switch (_context.n) {
|
|
1161
1236
|
case 0:
|
|
1162
|
-
|
|
1237
|
+
cacheKey = listName;
|
|
1238
|
+
cachedType = this.listItemEntityTypeCache.get(cacheKey);
|
|
1239
|
+
if (!cachedType) {
|
|
1163
1240
|
_context.n = 1;
|
|
1164
1241
|
break;
|
|
1165
1242
|
}
|
|
1166
|
-
return _context.a(2,
|
|
1243
|
+
return _context.a(2, cachedType);
|
|
1167
1244
|
case 1:
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
break;
|
|
1171
|
-
}
|
|
1172
|
-
throw new Error('List name is not set.');
|
|
1245
|
+
_context.n = 2;
|
|
1246
|
+
return this.instance.get(buildListByTitleEndpoint(listName) + "?$select=ListItemEntityTypeFullName");
|
|
1173
1247
|
case 2:
|
|
1174
|
-
if (!(this.sharepointVersion !== '2013')) {
|
|
1175
|
-
_context.n = 3;
|
|
1176
|
-
break;
|
|
1177
|
-
}
|
|
1178
|
-
this.listItemEntityTypeFullName = "SP.Data." + this.listName + "ListItem";
|
|
1179
|
-
return _context.a(2, this.listItemEntityTypeFullName);
|
|
1180
|
-
case 3:
|
|
1181
|
-
_context.n = 4;
|
|
1182
|
-
return this.instance.get("_api/web/lists/GetByTitle('" + this.listName + "')?$select=ListItemEntityTypeFullName");
|
|
1183
|
-
case 4:
|
|
1184
1248
|
response = _context.v;
|
|
1185
1249
|
entityType = (_response$data$d$List = (_response$data = response.data) == null || (_response$data = _response$data.d) == null ? void 0 : _response$data.ListItemEntityTypeFullName) != null ? _response$data$d$List : (_response$data2 = response.data) == null ? void 0 : _response$data2.ListItemEntityTypeFullName;
|
|
1186
1250
|
if (!(!entityType || typeof entityType !== 'string')) {
|
|
1187
|
-
_context.n =
|
|
1251
|
+
_context.n = 3;
|
|
1188
1252
|
break;
|
|
1189
1253
|
}
|
|
1190
|
-
throw new Error("Unable to resolve ListItemEntityTypeFullName for list \"" +
|
|
1191
|
-
case
|
|
1192
|
-
this.
|
|
1193
|
-
return _context.a(2,
|
|
1254
|
+
throw new Error("Unable to resolve ListItemEntityTypeFullName for list \"" + listName + "\".");
|
|
1255
|
+
case 3:
|
|
1256
|
+
this.listItemEntityTypeCache.set(cacheKey, entityType);
|
|
1257
|
+
return _context.a(2, entityType);
|
|
1194
1258
|
}
|
|
1195
1259
|
}, _callee, this);
|
|
1196
1260
|
}));
|
|
1197
|
-
function resolveListItemEntityTypeFullName() {
|
|
1261
|
+
function resolveListItemEntityTypeFullName(_x) {
|
|
1198
1262
|
return _resolveListItemEntityTypeFullName.apply(this, arguments);
|
|
1199
1263
|
}
|
|
1200
1264
|
return resolveListItemEntityTypeFullName;
|
|
1201
|
-
}()
|
|
1202
|
-
|
|
1203
|
-
* @deprecated Use `from` instead.
|
|
1204
|
-
*/
|
|
1205
|
-
;
|
|
1206
|
-
_proto.list = function list(listName) {
|
|
1207
|
-
this.listName = listName;
|
|
1208
|
-
this.endpoint = "_vti_bin/ListData.svc/" + listName;
|
|
1209
|
-
this.sharepointVersion = '2010';
|
|
1210
|
-
this.listItemEntityTypeFullName = undefined;
|
|
1211
|
-
return this;
|
|
1212
|
-
};
|
|
1213
|
-
_proto.getDigest = function getDigest() {
|
|
1214
|
-
return fetchDigest(this.instance, this.baseURL);
|
|
1215
|
-
};
|
|
1216
|
-
_proto.from = function from(listName, sharepoint_ver) {
|
|
1265
|
+
}();
|
|
1266
|
+
_proto.buildListScope = function buildListScope(listName, version) {
|
|
1217
1267
|
var _this2 = this;
|
|
1218
|
-
var
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1268
|
+
var listNameValue = String(listName);
|
|
1269
|
+
var endpoint = version === '2013' ? buildListByTitleEndpoint(listNameValue) + "/items" : "_vti_bin/ListData.svc/" + encodeURIComponent(listNameValue);
|
|
1270
|
+
var scopedEntityType;
|
|
1271
|
+
var resolveListItemEntityType = /*#__PURE__*/function () {
|
|
1272
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
1273
|
+
return _regenerator().w(function (_context2) {
|
|
1274
|
+
while (1) switch (_context2.n) {
|
|
1275
|
+
case 0:
|
|
1276
|
+
if (!scopedEntityType) {
|
|
1277
|
+
_context2.n = 1;
|
|
1278
|
+
break;
|
|
1279
|
+
}
|
|
1280
|
+
return _context2.a(2, scopedEntityType);
|
|
1281
|
+
case 1:
|
|
1282
|
+
if (!(version !== '2013')) {
|
|
1283
|
+
_context2.n = 2;
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
scopedEntityType = "SP.Data." + listNameValue + "ListItem";
|
|
1287
|
+
return _context2.a(2, scopedEntityType);
|
|
1288
|
+
case 2:
|
|
1289
|
+
_context2.n = 3;
|
|
1290
|
+
return _this2.resolveListItemEntityTypeFullName(listNameValue);
|
|
1291
|
+
case 3:
|
|
1292
|
+
scopedEntityType = _context2.v;
|
|
1293
|
+
return _context2.a(2, scopedEntityType);
|
|
1294
|
+
}
|
|
1295
|
+
}, _callee2);
|
|
1296
|
+
}));
|
|
1297
|
+
return function resolveListItemEntityType() {
|
|
1298
|
+
return _ref2.apply(this, arguments);
|
|
1299
|
+
};
|
|
1300
|
+
}();
|
|
1223
1301
|
var getContext = function getContext() {
|
|
1224
|
-
return _this2.
|
|
1302
|
+
return _this2.createContext({
|
|
1303
|
+
endpoint: endpoint,
|
|
1304
|
+
listName: listNameValue,
|
|
1305
|
+
sharepointVersion: version,
|
|
1306
|
+
listItemEntityTypeFullName: scopedEntityType,
|
|
1307
|
+
resolveListItemEntityType: resolveListItemEntityType
|
|
1308
|
+
});
|
|
1309
|
+
};
|
|
1310
|
+
var removeItem = function removeItem(id) {
|
|
1311
|
+
return deleteItem(getContext(), id);
|
|
1312
|
+
};
|
|
1313
|
+
var removeFile = function removeFile(props) {
|
|
1314
|
+
return deleteFile(getContext(), props);
|
|
1225
1315
|
};
|
|
1226
1316
|
return {
|
|
1227
1317
|
create: function create(data) {
|
|
@@ -1233,60 +1323,142 @@ var HTTPSharePointRequests = /*#__PURE__*/function () {
|
|
|
1233
1323
|
update: function update(id, data, digest) {
|
|
1234
1324
|
return updateListItem(getContext(), id, data, digest);
|
|
1235
1325
|
},
|
|
1236
|
-
"delete":
|
|
1237
|
-
|
|
1238
|
-
},
|
|
1326
|
+
"delete": removeItem,
|
|
1327
|
+
remove: removeItem,
|
|
1239
1328
|
createFile: function createFile(props) {
|
|
1240
1329
|
return createAttachment(getContext(), props);
|
|
1241
1330
|
},
|
|
1242
1331
|
uploadFile: function uploadFile$1(props) {
|
|
1243
1332
|
return uploadFile(getContext(), props);
|
|
1244
1333
|
},
|
|
1245
|
-
deleteFile:
|
|
1246
|
-
|
|
1247
|
-
},
|
|
1334
|
+
deleteFile: removeFile,
|
|
1335
|
+
removeFile: removeFile,
|
|
1248
1336
|
fields: function fields(options) {
|
|
1249
|
-
|
|
1337
|
+
var fieldsEndpoint = !(options != null && options.fieldName) ? buildListByTitleEndpoint(listNameValue) + "/fields" : buildListByTitleEndpoint(listNameValue) + "/fields/getbytitle('" + escapeODataStringLiteral(String(options.fieldName)) + "')";
|
|
1250
1338
|
return {
|
|
1251
1339
|
get: function get() {
|
|
1252
|
-
return getOnly(_this2.instance,
|
|
1340
|
+
return getOnly(_this2.instance, fieldsEndpoint, options);
|
|
1253
1341
|
}
|
|
1254
1342
|
};
|
|
1343
|
+
},
|
|
1344
|
+
items: {
|
|
1345
|
+
create: function create(data) {
|
|
1346
|
+
return createListItem(getContext(), data);
|
|
1347
|
+
},
|
|
1348
|
+
get: function get(options) {
|
|
1349
|
+
return getListItems(getContext(), options);
|
|
1350
|
+
},
|
|
1351
|
+
update: function update(id, data, digest) {
|
|
1352
|
+
return updateListItem(getContext(), id, data, digest);
|
|
1353
|
+
},
|
|
1354
|
+
"delete": removeItem,
|
|
1355
|
+
remove: removeItem
|
|
1356
|
+
},
|
|
1357
|
+
files: {
|
|
1358
|
+
attach: function attach(props) {
|
|
1359
|
+
return createAttachment(getContext(), props);
|
|
1360
|
+
},
|
|
1361
|
+
upload: function upload(props) {
|
|
1362
|
+
return uploadFile(getContext(), props);
|
|
1363
|
+
},
|
|
1364
|
+
"delete": removeFile,
|
|
1365
|
+
remove: removeFile
|
|
1366
|
+
}
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* @deprecated Use `from(listName, '2010')` instead.
|
|
1371
|
+
*/;
|
|
1372
|
+
_proto.list = function list(listName) {
|
|
1373
|
+
return this.from(listName, '2010');
|
|
1374
|
+
};
|
|
1375
|
+
_proto.from = function from(listName, sharepointVersion) {
|
|
1376
|
+
var version = sharepointVersion != null ? sharepointVersion : '2013';
|
|
1377
|
+
return this.buildListScope(listName, version);
|
|
1378
|
+
};
|
|
1379
|
+
_proto.field = function field(listName, fieldName, sharepointVersion) {
|
|
1380
|
+
return this.from(listName, sharepointVersion).fields({
|
|
1381
|
+
fieldName: fieldName
|
|
1382
|
+
}).get();
|
|
1383
|
+
};
|
|
1384
|
+
_proto.lists = function lists(options) {
|
|
1385
|
+
var context = this.createContext({
|
|
1386
|
+
endpoint: '_api/web/lists',
|
|
1387
|
+
listName: '',
|
|
1388
|
+
sharepointVersion: '2013'
|
|
1389
|
+
});
|
|
1390
|
+
return {
|
|
1391
|
+
get: function get() {
|
|
1392
|
+
return getListItems(context, options);
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
};
|
|
1396
|
+
_proto.getDigest = function getDigest() {
|
|
1397
|
+
return fetchDigest(this.instance, this.baseURL);
|
|
1398
|
+
};
|
|
1399
|
+
_proto.folders = function folders(options) {
|
|
1400
|
+
var context = this.createContext({
|
|
1401
|
+
endpoint: '_api/web/folders',
|
|
1402
|
+
listName: '',
|
|
1403
|
+
sharepointVersion: '2013'
|
|
1404
|
+
});
|
|
1405
|
+
return {
|
|
1406
|
+
get: function get() {
|
|
1407
|
+
return getFiles(context, options);
|
|
1255
1408
|
}
|
|
1256
1409
|
};
|
|
1257
1410
|
};
|
|
1258
1411
|
_proto.folder = function folder(folderName) {
|
|
1259
1412
|
var _this3 = this;
|
|
1260
|
-
var
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
this.endpoint = "_api/web/GetFolderByServerRelativeUrl('" + filePath.join('/') + "')";
|
|
1265
|
-
this.sharepointVersion = '2013';
|
|
1266
|
-
var getContext = function getContext() {
|
|
1267
|
-
return _this3.getContext();
|
|
1268
|
-
};
|
|
1413
|
+
var defaultPath = ['Shared Documents'];
|
|
1414
|
+
var segments = folderName ? Array.isArray(folderName) ? [].concat(defaultPath, folderName) : [].concat(defaultPath, folderName.split('/').filter(Boolean)) : defaultPath;
|
|
1415
|
+
var serverRelativePath = escapeODataStringLiteral(segments.join('/'));
|
|
1416
|
+
var baseEndpoint = "_api/web/GetFolderByServerRelativeUrl('" + serverRelativePath + "')";
|
|
1269
1417
|
return {
|
|
1270
1418
|
get: function get(options) {
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1419
|
+
var _options$type;
|
|
1420
|
+
var folderType = (_options$type = options == null ? void 0 : options.type) != null ? _options$type : 'Files';
|
|
1421
|
+
var endpoint = baseEndpoint + "/" + folderType;
|
|
1422
|
+
var context = _this3.createContext({
|
|
1423
|
+
endpoint: endpoint,
|
|
1424
|
+
listName: '',
|
|
1425
|
+
sharepointVersion: '2013'
|
|
1426
|
+
});
|
|
1427
|
+
return getFiles(context, _extends({}, options, {
|
|
1428
|
+
type: folderType
|
|
1429
|
+
}));
|
|
1277
1430
|
}
|
|
1278
1431
|
};
|
|
1279
1432
|
};
|
|
1280
1433
|
_proto.users = function users(options) {
|
|
1281
|
-
var
|
|
1282
|
-
|
|
1283
|
-
|
|
1434
|
+
var context = this.createContext({
|
|
1435
|
+
endpoint: '_api/web/SiteUserInfoList/items',
|
|
1436
|
+
listName: '',
|
|
1437
|
+
sharepointVersion: '2013'
|
|
1438
|
+
});
|
|
1284
1439
|
return {
|
|
1285
1440
|
get: function get() {
|
|
1286
|
-
return getListItems(
|
|
1441
|
+
return getListItems(context, options);
|
|
1287
1442
|
}
|
|
1288
1443
|
};
|
|
1289
1444
|
};
|
|
1445
|
+
_proto.sendEmail = function sendEmail$1(props) {
|
|
1446
|
+
var context = this.createContext({
|
|
1447
|
+
endpoint: '_api/SP.Utilities.Utility.SendEmail',
|
|
1448
|
+
listName: '',
|
|
1449
|
+
sharepointVersion: '2013'
|
|
1450
|
+
});
|
|
1451
|
+
return sendEmail(context, props);
|
|
1452
|
+
};
|
|
1453
|
+
_proto.getCurrentUser = function getCurrentUser() {
|
|
1454
|
+
return this.user.current().get();
|
|
1455
|
+
};
|
|
1456
|
+
_proto.currentUserProperties = function currentUserProperties() {
|
|
1457
|
+
return this.user.properties().get();
|
|
1458
|
+
};
|
|
1459
|
+
_proto.currentUserPermission = function currentUserPermission() {
|
|
1460
|
+
return this.user.currentPermission().get();
|
|
1461
|
+
};
|
|
1290
1462
|
return HTTPSharePointRequests;
|
|
1291
1463
|
}();
|
|
1292
1464
|
|