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