gd-sprest 9.7.2 → 9.7.4
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/@types/utils/base.d.ts +0 -3
- package/build/helper/executor.js +10 -20
- package/build/helper/fieldSchemaXML.js +85 -89
- package/build/helper/index.js +12 -28
- package/build/helper/jslink.js +124 -128
- package/build/helper/listForm.js +109 -118
- package/build/helper/listFormField.js +62 -65
- package/build/helper/methods/addContentEditorWebPart.js +9 -17
- package/build/helper/methods/addPermissionLevel.js +12 -16
- package/build/helper/methods/addScriptEditorWebPart.js +9 -17
- package/build/helper/methods/copyPermissionLevel.js +22 -26
- package/build/helper/methods/createContentType.js +96 -19
- package/build/helper/methods/createDocSet.js +10 -14
- package/build/helper/methods/getCurrentTheme.js +26 -31
- package/build/helper/methods/hasPermissions.js +8 -13
- package/build/helper/methods/index.js +16 -32
- package/build/helper/methods/loadSPCore.js +13 -17
- package/build/helper/methods/parse.js +5 -9
- package/build/helper/methods/request.js +4 -8
- package/build/helper/methods/setContentTypeFields.js +71 -79
- package/build/helper/methods/setGroupOwner.js +6 -10
- package/build/helper/methods/setWebProperty.js +26 -30
- package/build/helper/methods/stringify.js +3 -7
- package/build/helper/methods/webWorker.js +40 -20
- package/build/helper/ribbonLink.js +10 -14
- package/build/helper/sbLink.js +11 -15
- package/build/helper/sp/calloutManager.js +22 -25
- package/build/helper/sp/index.js +13 -16
- package/build/helper/sp/modalDialog.js +32 -35
- package/build/helper/sp/notify.js +9 -12
- package/build/helper/sp/ribbon.js +1 -4
- package/build/helper/sp/sod.js +9 -18
- package/build/helper/sp/status.js +18 -21
- package/build/helper/spCfg.js +232 -259
- package/build/helper/spCfgTypes.js +2 -5
- package/build/helper/taxonomy.js +144 -182
- package/build/helper/webpart.js +110 -94
- package/build/index.js +6 -23
- package/build/lib/apps.js +4 -7
- package/build/lib/contextInfo.js +217 -781
- package/build/lib/directorySession.js +4 -7
- package/build/lib/graph.js +16 -19
- package/build/lib/groupService.js +4 -7
- package/build/lib/groupSiteManager.js +4 -7
- package/build/lib/hubSites.js +11 -25
- package/build/lib/hubSitesUtility.js +4 -7
- package/build/lib/index.js +27 -43
- package/build/lib/list.js +49 -53
- package/build/lib/navigation.js +4 -7
- package/build/lib/peopleManager.js +4 -7
- package/build/lib/peoplePicker.js +4 -7
- package/build/lib/profileLoader.js +4 -7
- package/build/lib/search.js +30 -33
- package/build/lib/sensitivityLabels.js +6 -9
- package/build/lib/site.js +20 -35
- package/build/lib/siteIconManager.js +4 -7
- package/build/lib/siteManager.js +4 -7
- package/build/lib/sitePages.js +37 -51
- package/build/lib/socialFeed.js +13 -16
- package/build/lib/themeManager.js +4 -7
- package/build/lib/userProfile.js +4 -7
- package/build/lib/utility.js +12 -17
- package/build/lib/web.js +34 -49
- package/build/lib/webTemplateExtensions.js +4 -7
- package/build/lib/wfInstanceService.js +4 -7
- package/build/lib/wfSubscriptionService.js +4 -7
- package/build/mapper/custom/audit.js +3 -6
- package/build/mapper/custom/graph.js +13 -16
- package/build/mapper/custom/index.js +8 -24
- package/build/mapper/custom/odata.js +3 -6
- package/build/mapper/custom/old.js +42 -45
- package/build/mapper/custom/peoplePicker.js +4 -7
- package/build/mapper/custom/propertyValues.js +3 -6
- package/build/mapper/custom/utility.js +17 -20
- package/build/mapper/custom/webTemplateExtensions.js +19 -22
- package/build/mapper/def.js +1032 -989
- package/build/mapper/index.js +4 -9
- package/build/mapper/v2.js +2629 -2632
- package/build/rest.js +16 -19
- package/build/sptypes/graphtypes.js +694 -710
- package/build/sptypes/index.js +3 -7
- package/build/sptypes/sptypes.js +49 -52
- package/build/utils/base.js +20 -37
- package/build/utils/batch.js +53 -63
- package/build/utils/helper.js +79 -83
- package/build/utils/index.js +9 -25
- package/build/utils/methodInfo.js +88 -141
- package/build/utils/oData.js +62 -112
- package/build/utils/request.js +137 -155
- package/build/utils/requestType.js +1 -4
- package/build/utils/targetInfo.js +39 -52
- package/build/utils/xhrRequest.js +59 -107
- package/build/v2/drive.js +9 -13
- package/build/v2/drives.js +8 -12
- package/build/v2/index.js +3 -19
- package/build/v2/sites.js +61 -65
- package/dist/gd-sprest.d.ts +0 -3
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +2 -2
package/build/utils/request.js
CHANGED
|
@@ -1,41 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.Request = void 0;
|
|
15
|
-
var base_1 = require("./base");
|
|
16
|
-
var batch_1 = require("./batch");
|
|
17
|
-
var lib_1 = require("../lib");
|
|
18
|
-
var executor_1 = require("../helper/executor");
|
|
19
|
-
var helper_1 = require("./helper");
|
|
20
|
-
var mapper_1 = require("../mapper");
|
|
21
|
-
var requestType_1 = require("./requestType");
|
|
22
|
-
var targetInfo_1 = require("./targetInfo");
|
|
23
|
-
var xhrRequest_1 = require("./xhrRequest");
|
|
1
|
+
import { Base } from "./base";
|
|
2
|
+
import { Batch } from "./batch";
|
|
3
|
+
import { ContextInfo, Graph } from "../lib";
|
|
4
|
+
import { Executor } from "../helper/executor";
|
|
5
|
+
import { Helper } from "./helper";
|
|
6
|
+
import { Mapper, MapperV2, Mapper_Custom } from "../mapper";
|
|
7
|
+
import { RequestType } from "./requestType";
|
|
8
|
+
import { TargetInfo } from "./targetInfo";
|
|
9
|
+
import { XHRRequest } from "./xhrRequest";
|
|
24
10
|
/**
|
|
25
11
|
* Request
|
|
26
12
|
*/
|
|
27
|
-
|
|
13
|
+
export const Request = {
|
|
28
14
|
// Method to add the methods to base object
|
|
29
|
-
addMethods:
|
|
15
|
+
addMethods: (base, data, resultsObjType) => {
|
|
30
16
|
var _a, _b;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
let obj = base;
|
|
18
|
+
let isCollection = data.results && data.results.length > 0;
|
|
19
|
+
let methods = null;
|
|
34
20
|
// Determine the metadata
|
|
35
|
-
|
|
21
|
+
let metadata = isCollection ? data.results[0].__metadata : data.__metadata;
|
|
36
22
|
// Get the object type
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
let objType = metadata && metadata.type ? metadata.type : obj.targetInfo.endpoint;
|
|
24
|
+
let isV2 = ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.parent) === null || _a === void 0 ? void 0 : _a.targetInfo) === null || _b === void 0 ? void 0 : _b.endpoint.startsWith("_api/v2.0/")) ||
|
|
39
25
|
obj["@odata.context"] || objType.startsWith("@odata.context") ? true : false;
|
|
40
26
|
if (isV2) {
|
|
41
27
|
// See if we are overriding the object type
|
|
@@ -45,8 +31,8 @@ exports.Request = {
|
|
|
45
31
|
}
|
|
46
32
|
else {
|
|
47
33
|
// Get the object type from the context
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
let metadataType = (obj["@odata.context"] || objType);
|
|
35
|
+
let values = metadataType.split("_api/v2.0/$metadata#");
|
|
50
36
|
if (values.length > 1) {
|
|
51
37
|
objType = values[1];
|
|
52
38
|
}
|
|
@@ -58,12 +44,12 @@ exports.Request = {
|
|
|
58
44
|
objType = objType.replace("s/$entity", "");
|
|
59
45
|
}
|
|
60
46
|
// Get the methods for this object type
|
|
61
|
-
methods =
|
|
47
|
+
methods = MapperV2[objType];
|
|
62
48
|
}
|
|
63
49
|
// Else, get the methods from the default mapper, otherwise get it from the custom mapper
|
|
64
|
-
else if ((methods =
|
|
50
|
+
else if ((methods = Mapper[objType + (isCollection ? ".Collection" : "")]) == null) {
|
|
65
51
|
// Determine the object type
|
|
66
|
-
|
|
52
|
+
let values = objType.split('/');
|
|
67
53
|
objType = values[values.length - 1];
|
|
68
54
|
values = objType.split('.');
|
|
69
55
|
objType = (values[values.length - 1]).toLowerCase();
|
|
@@ -98,25 +84,24 @@ exports.Request = {
|
|
|
98
84
|
objType = "tenantapps";
|
|
99
85
|
}
|
|
100
86
|
// Get the methods for the base object
|
|
101
|
-
methods =
|
|
87
|
+
methods = Mapper_Custom[objType];
|
|
102
88
|
}
|
|
103
89
|
// Ensure methods exist
|
|
104
90
|
if (methods) {
|
|
105
91
|
// Parse the methods
|
|
106
|
-
for (
|
|
92
|
+
for (let methodName in methods) {
|
|
107
93
|
// Get the method information
|
|
108
|
-
|
|
94
|
+
let methodInfo = methods[methodName] ? methods[methodName] : {};
|
|
109
95
|
// See if the base is the "Properties" definition for the object
|
|
110
96
|
if (methodName == "properties") {
|
|
111
97
|
// Parse the properties
|
|
112
|
-
for (
|
|
113
|
-
|
|
114
|
-
var propInfo = property.split("|");
|
|
98
|
+
for (let property of methodInfo) {
|
|
99
|
+
let propInfo = property.split("|");
|
|
115
100
|
// Get the metadata type
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
101
|
+
let propName = propInfo[0];
|
|
102
|
+
let propType = propInfo.length > 1 ? propInfo[1] : null;
|
|
103
|
+
let subPropName = propInfo.length > 2 ? propInfo[2] : null;
|
|
104
|
+
let subPropType = propInfo.length > 3 ? propInfo[3] : null;
|
|
120
105
|
// See if the property is null or is a collection
|
|
121
106
|
if (obj[propName] == null || (obj[propName].__deferred && obj[propName].__deferred.uri)) {
|
|
122
107
|
// See if the base property has a sub-property defined for it
|
|
@@ -149,10 +134,10 @@ exports.Request = {
|
|
|
149
134
|
}
|
|
150
135
|
},
|
|
151
136
|
// Method to add properties to the base object
|
|
152
|
-
addProperties:
|
|
137
|
+
addProperties: (base, data) => {
|
|
153
138
|
// Parse the data properties
|
|
154
139
|
for (var key in data) {
|
|
155
|
-
|
|
140
|
+
let value = data[key];
|
|
156
141
|
// Skip the results
|
|
157
142
|
if (key == "results") {
|
|
158
143
|
continue;
|
|
@@ -196,7 +181,7 @@ exports.Request = {
|
|
|
196
181
|
// Ensure the collection is an object
|
|
197
182
|
if (base[key].results.length == 0 || typeof (base[key].results[0]) === "object") {
|
|
198
183
|
// Create the base property as a new request
|
|
199
|
-
|
|
184
|
+
let objCollection = new Base(base.targetInfo);
|
|
200
185
|
objCollection["results"] = base[key].results;
|
|
201
186
|
// See no results exist
|
|
202
187
|
if (objCollection["results"].length == 0) {
|
|
@@ -206,11 +191,11 @@ exports.Request = {
|
|
|
206
191
|
// Update the endpoint for the base request to point to the base property
|
|
207
192
|
objCollection.targetInfo.endpoint = (objCollection.targetInfo.endpoint.split("?")[0] + "/" + key).replace(/\//g, "/");
|
|
208
193
|
// Add the methods
|
|
209
|
-
|
|
194
|
+
Request.addMethods(objCollection, objCollection);
|
|
210
195
|
// Update the data collection
|
|
211
|
-
|
|
196
|
+
Helper.updateDataCollection(base, objCollection["results"]);
|
|
212
197
|
// Update the expanded properties
|
|
213
|
-
|
|
198
|
+
Helper.updateExpandedProperties(base);
|
|
214
199
|
// Update the property
|
|
215
200
|
base[key] = objCollection;
|
|
216
201
|
}
|
|
@@ -226,13 +211,13 @@ exports.Request = {
|
|
|
226
211
|
}
|
|
227
212
|
},
|
|
228
213
|
// Method to execute the request
|
|
229
|
-
execute:
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
214
|
+
execute: (base, args) => {
|
|
215
|
+
let reject = null;
|
|
216
|
+
let resolve = null;
|
|
217
|
+
let waitFl = false;
|
|
233
218
|
// Parse the arguments
|
|
234
|
-
for (
|
|
235
|
-
|
|
219
|
+
for (let i = 0; i < args.length; i++) {
|
|
220
|
+
let arg = args[i];
|
|
236
221
|
// Check the type
|
|
237
222
|
switch (typeof (arg)) {
|
|
238
223
|
case "boolean":
|
|
@@ -265,9 +250,9 @@ exports.Request = {
|
|
|
265
250
|
// See if we are waiting for the responses to complete
|
|
266
251
|
if (waitFl) {
|
|
267
252
|
// Wait for the responses to execute
|
|
268
|
-
|
|
253
|
+
Request.waitForRequestsToComplete(base, () => {
|
|
269
254
|
// Execute this request
|
|
270
|
-
|
|
255
|
+
Request.executeRequest(base, true, (response, errorFl) => {
|
|
271
256
|
// See if there was an error
|
|
272
257
|
if (errorFl) {
|
|
273
258
|
// Set the wait flag
|
|
@@ -278,11 +263,11 @@ exports.Request = {
|
|
|
278
263
|
// Else, see if there is a resolve method
|
|
279
264
|
else if (resolve) {
|
|
280
265
|
// Execute the callback and see if it returns a promise
|
|
281
|
-
|
|
282
|
-
|
|
266
|
+
let returnVal = resolve(response);
|
|
267
|
+
let waitFunc = returnVal ? returnVal.done || returnVal.then : null;
|
|
283
268
|
if (waitFunc && typeof (waitFunc) === "function") {
|
|
284
269
|
// Wait for the promise to complete
|
|
285
|
-
waitFunc(
|
|
270
|
+
waitFunc(() => {
|
|
286
271
|
// Set the wait flag
|
|
287
272
|
base.base.waitFlags[base.responseIndex] = true;
|
|
288
273
|
// Set the base to this object, and clear requests
|
|
@@ -315,7 +300,7 @@ exports.Request = {
|
|
|
315
300
|
}
|
|
316
301
|
else {
|
|
317
302
|
// Execute this request
|
|
318
|
-
|
|
303
|
+
Request.executeRequest(base, true, (response, errorFl) => {
|
|
319
304
|
// See if there was an error
|
|
320
305
|
if (errorFl) {
|
|
321
306
|
// Set the wait flag
|
|
@@ -325,10 +310,10 @@ exports.Request = {
|
|
|
325
310
|
}
|
|
326
311
|
else {
|
|
327
312
|
// Execute the resolve and see if it returns a promise
|
|
328
|
-
|
|
313
|
+
let returnVal = resolve ? resolve(response) : null;
|
|
329
314
|
if (returnVal && typeof (returnVal.done) === "function") {
|
|
330
315
|
// Wait for the promise to complete
|
|
331
|
-
returnVal.done(
|
|
316
|
+
returnVal.done(() => {
|
|
332
317
|
// Set the wait flag
|
|
333
318
|
base.base.waitFlags[base.responseIndex] = true;
|
|
334
319
|
});
|
|
@@ -341,7 +326,7 @@ exports.Request = {
|
|
|
341
326
|
});
|
|
342
327
|
}
|
|
343
328
|
// See if this is a query request
|
|
344
|
-
if (base.targetInfo.requestType ==
|
|
329
|
+
if (base.targetInfo.requestType == RequestType.OData) {
|
|
345
330
|
// Return the parent for chaining purposes
|
|
346
331
|
return base.parent;
|
|
347
332
|
}
|
|
@@ -349,9 +334,9 @@ exports.Request = {
|
|
|
349
334
|
return base;
|
|
350
335
|
},
|
|
351
336
|
// Method to execute the request
|
|
352
|
-
executeRequest:
|
|
337
|
+
executeRequest: (base, asyncFl, callback) => {
|
|
353
338
|
// Execution method
|
|
354
|
-
|
|
339
|
+
let execute = (targetInfo, batchIdx, onComplete) => {
|
|
355
340
|
// See if this is an asynchronous request
|
|
356
341
|
if (asyncFl) {
|
|
357
342
|
// See if this is not a batch request, and it already exists
|
|
@@ -361,19 +346,19 @@ exports.Request = {
|
|
|
361
346
|
}
|
|
362
347
|
else {
|
|
363
348
|
// Create the request
|
|
364
|
-
base.xhr = new
|
|
349
|
+
base.xhr = new XHRRequest(asyncFl, targetInfo, () => {
|
|
365
350
|
// Update the response and status
|
|
366
351
|
base.response = base.xhr.response;
|
|
367
352
|
base.status = base.xhr.status;
|
|
368
|
-
|
|
353
|
+
let errorFl = !(base.status >= 200 && base.status < 300);
|
|
369
354
|
// See if we are returning a file buffer
|
|
370
|
-
if (base.requestType ==
|
|
355
|
+
if (base.requestType == RequestType.GetBuffer) {
|
|
371
356
|
// Execute the callback
|
|
372
357
|
callback ? callback(base.response, errorFl) : null;
|
|
373
358
|
}
|
|
374
359
|
else {
|
|
375
360
|
// Update the data object
|
|
376
|
-
|
|
361
|
+
Request.updateDataObject(base, isBatchRequest, batchIdx);
|
|
377
362
|
// Ensure this isn't a batch request
|
|
378
363
|
if (!isBatchRequest) {
|
|
379
364
|
// See if this is an xml response
|
|
@@ -383,14 +368,14 @@ exports.Request = {
|
|
|
383
368
|
}
|
|
384
369
|
else {
|
|
385
370
|
// Validate the data collection
|
|
386
|
-
|
|
371
|
+
Request.validateDataCollectionResults(base).then(
|
|
387
372
|
// Success
|
|
388
|
-
|
|
373
|
+
() => {
|
|
389
374
|
// Execute the callback
|
|
390
375
|
callback ? callback(base, errorFl) : null;
|
|
391
376
|
},
|
|
392
377
|
// Error
|
|
393
|
-
|
|
378
|
+
() => {
|
|
394
379
|
// Execute the callback and set the error flag
|
|
395
380
|
callback ? callback(base, true) : null;
|
|
396
381
|
});
|
|
@@ -409,17 +394,17 @@ exports.Request = {
|
|
|
409
394
|
// Else, we haven't executed this request
|
|
410
395
|
else {
|
|
411
396
|
// Create the request
|
|
412
|
-
base.xhr = new
|
|
397
|
+
base.xhr = new XHRRequest(asyncFl, targetInfo);
|
|
413
398
|
// Update the response and status
|
|
414
399
|
base.response = base.xhr.response;
|
|
415
400
|
base.status = base.xhr.status;
|
|
416
401
|
// See if we are returning a file buffer
|
|
417
|
-
if (base.requestType ==
|
|
402
|
+
if (base.requestType == RequestType.GetBuffer) {
|
|
418
403
|
// Return the response
|
|
419
404
|
return base.response;
|
|
420
405
|
}
|
|
421
406
|
// Update the base object
|
|
422
|
-
|
|
407
|
+
Request.updateDataObject(base, isBatchRequest, batchIdx);
|
|
423
408
|
// See if the base is a collection and has more results
|
|
424
409
|
if (base["@odata.nextLink"] || (base["d"] && base["d"].__next)) {
|
|
425
410
|
// Add the "next" method to get the next set of results
|
|
@@ -432,25 +417,25 @@ exports.Request = {
|
|
|
432
417
|
}
|
|
433
418
|
};
|
|
434
419
|
// See if this is a batch request
|
|
435
|
-
|
|
420
|
+
let isBatchRequest = base.base && base.base.batchRequests && base.base.batchRequests.length > 0;
|
|
436
421
|
if (isBatchRequest) {
|
|
437
|
-
|
|
438
|
-
|
|
422
|
+
let batchIdx = 0;
|
|
423
|
+
let root = Helper.getRootParent(base);
|
|
439
424
|
// Parse the requests
|
|
440
|
-
|
|
425
|
+
Executor(base.base.batchRequests, batchRequest => {
|
|
441
426
|
// Do nothing if the stop flag is set
|
|
442
|
-
if (
|
|
427
|
+
if (root.stopFl) {
|
|
443
428
|
return;
|
|
444
429
|
}
|
|
445
430
|
// Return a promise
|
|
446
|
-
return new Promise(
|
|
431
|
+
return new Promise(resolve => {
|
|
447
432
|
// Execute the request
|
|
448
|
-
execute(
|
|
433
|
+
execute(Batch.getTargetInfo(base.targetInfo.url, batchRequest, base.targetInfo.requestDigest, base.targetInfo.requestHeader, base.targetInfo.endpoint.indexOf("_api/v2") >= 0), batchIdx++, () => {
|
|
449
434
|
// Resolve the request
|
|
450
435
|
resolve(null);
|
|
451
436
|
});
|
|
452
437
|
});
|
|
453
|
-
}).then(
|
|
438
|
+
}).then(() => {
|
|
454
439
|
// Execute the callback if it exists
|
|
455
440
|
callback ? callback(base.base.batchRequests, false) : null;
|
|
456
441
|
// Clear the batch requests
|
|
@@ -459,19 +444,18 @@ exports.Request = {
|
|
|
459
444
|
}
|
|
460
445
|
else {
|
|
461
446
|
// Execute the request
|
|
462
|
-
return execute(new
|
|
447
|
+
return execute(new TargetInfo(base.targetInfo));
|
|
463
448
|
}
|
|
464
449
|
},
|
|
465
450
|
// Method to parse the xml
|
|
466
|
-
parseXML:
|
|
467
|
-
|
|
468
|
-
var results = null;
|
|
451
|
+
parseXML: (xml, objData = {}) => {
|
|
452
|
+
let results = null;
|
|
469
453
|
// See if the element has children
|
|
470
454
|
if (xml.hasChildNodes()) {
|
|
471
455
|
// Parse the child nodes
|
|
472
|
-
for (
|
|
473
|
-
|
|
474
|
-
|
|
456
|
+
for (let i = 0; i < xml.childNodes.length; i++) {
|
|
457
|
+
let childNode = xml.childNodes[i];
|
|
458
|
+
let childPropName = childNode.nodeName.replace("d:", "");
|
|
475
459
|
// See if this is a text element
|
|
476
460
|
if (childPropName == "#text") {
|
|
477
461
|
// Return the value
|
|
@@ -482,13 +466,13 @@ exports.Request = {
|
|
|
482
466
|
// Ensure the results exist
|
|
483
467
|
results = results || [];
|
|
484
468
|
// Append the object
|
|
485
|
-
results.push(
|
|
469
|
+
results.push(Request.parseXML(childNode));
|
|
486
470
|
}
|
|
487
471
|
else {
|
|
488
472
|
// Read the value properties
|
|
489
|
-
|
|
473
|
+
let childType = childNode.getAttribute("m:type");
|
|
490
474
|
// Get the value
|
|
491
|
-
|
|
475
|
+
let value = Request.parseXML(childNode);
|
|
492
476
|
if (value) {
|
|
493
477
|
// Update the value based on the type
|
|
494
478
|
switch (childType) {
|
|
@@ -519,29 +503,27 @@ exports.Request = {
|
|
|
519
503
|
return xml.nodeValue;
|
|
520
504
|
}
|
|
521
505
|
// Return the collection if it exists, otherwise the object
|
|
522
|
-
return results ? { results
|
|
506
|
+
return results ? { results } : objData;
|
|
523
507
|
},
|
|
524
508
|
// Method to convert the input arguments into an object
|
|
525
|
-
updateDataObject:
|
|
509
|
+
updateDataObject: (base, isBatchRequest = false, batchIdx = 0) => {
|
|
526
510
|
var _a;
|
|
527
|
-
if (isBatchRequest === void 0) { isBatchRequest = false; }
|
|
528
|
-
if (batchIdx === void 0) { batchIdx = 0; }
|
|
529
511
|
// Ensure the request was successful
|
|
530
512
|
if ((base.status >= 200 && base.status < 300) || (isBatchRequest && base.status == 422)) {
|
|
531
513
|
// Return if we are expecting a buffer
|
|
532
|
-
if (base.requestType ==
|
|
514
|
+
if (base.requestType == RequestType.GetBuffer) {
|
|
533
515
|
return;
|
|
534
516
|
}
|
|
535
517
|
// Parse the responses
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
for (
|
|
539
|
-
|
|
518
|
+
let batchRequestIdx = 0;
|
|
519
|
+
let responses = isBatchRequest ? base.response.split("\n") : [base.response];
|
|
520
|
+
for (let i = 0; i < responses.length; i++) {
|
|
521
|
+
let data = null;
|
|
540
522
|
// Set the response
|
|
541
|
-
|
|
523
|
+
let response = responses[i];
|
|
542
524
|
response = response === "" && !isBatchRequest ? "{}" : response;
|
|
543
525
|
// Set the xml flag
|
|
544
|
-
|
|
526
|
+
let isXML = response.indexOf("<?xml") == 0;
|
|
545
527
|
if (isXML) {
|
|
546
528
|
// Append the response while data exists
|
|
547
529
|
while (responses[i + 1] && responses[i + 1].indexOf("--batchresponse") != 0) {
|
|
@@ -557,48 +539,48 @@ exports.Request = {
|
|
|
557
539
|
continue;
|
|
558
540
|
}
|
|
559
541
|
// Set the object based on the request type
|
|
560
|
-
|
|
542
|
+
let obj = isBatchRequest ? Object.create(base) : base;
|
|
561
543
|
// Set the exists flag
|
|
562
544
|
obj["existsFl"] = typeof (obj["Exists"]) === "boolean" ? obj["Exists"] : data.error == null;
|
|
563
545
|
// See if this is xml
|
|
564
546
|
if (isXML) {
|
|
565
|
-
|
|
547
|
+
let objData = {};
|
|
566
548
|
// Convert the xml to an object
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
objData[xmlDoc.nodeName.replace("d:", "")] =
|
|
549
|
+
let parser = new DOMParser();
|
|
550
|
+
let xmlDoc = parser.parseFromString(data, "application/xml").firstChild;
|
|
551
|
+
objData[xmlDoc.nodeName.replace("d:", "")] = Request.parseXML(xmlDoc);
|
|
570
552
|
// See if this is a REST request
|
|
571
553
|
if (objData.entry && objData.entry.content && objData.entry.content["m:properties"]) {
|
|
572
554
|
// Set the object to the properties
|
|
573
555
|
objData = objData.entry.content["m:properties"];
|
|
574
556
|
// Update the metadata
|
|
575
|
-
|
|
557
|
+
Helper.updateMetadata(obj, objData);
|
|
576
558
|
// Update the base object's properties
|
|
577
|
-
|
|
559
|
+
Request.addProperties(obj, objData);
|
|
578
560
|
// Add the methods
|
|
579
|
-
|
|
561
|
+
Request.addMethods(obj, objData, objData["@odata.context"]);
|
|
580
562
|
// See if we are not bypassing the processing of the response
|
|
581
563
|
if (base.targetInfo.disableProcessing != true) {
|
|
582
564
|
// Update the data collection
|
|
583
|
-
|
|
565
|
+
Helper.updateDataCollection(obj, objData["results"]);
|
|
584
566
|
// Update the expanded properties
|
|
585
|
-
|
|
567
|
+
Helper.updateExpandedProperties(obj);
|
|
586
568
|
}
|
|
587
569
|
// Update the search results
|
|
588
|
-
|
|
570
|
+
Helper.updateSearchResults(obj);
|
|
589
571
|
}
|
|
590
572
|
else {
|
|
591
573
|
// Update the object
|
|
592
|
-
obj =
|
|
574
|
+
obj = Object.assign(Object.assign({}, obj), objData);
|
|
593
575
|
// Update the search results
|
|
594
|
-
|
|
576
|
+
Helper.updateSearchResults(obj);
|
|
595
577
|
}
|
|
596
578
|
}
|
|
597
579
|
// Else, see if the data properties exists
|
|
598
580
|
else if (data.d) {
|
|
599
581
|
// Get the endpoint method to see if it's part of the response
|
|
600
|
-
|
|
601
|
-
|
|
582
|
+
let endpointInfo = ((_a = base.targetInfo.endpoint) === null || _a === void 0 ? void 0 : _a.split('/')) || "";
|
|
583
|
+
let endpointMethod = endpointInfo ? endpointInfo[endpointInfo.length - 1] || "" : "";
|
|
602
584
|
endpointMethod = endpointMethod ? endpointMethod[0].toUpperCase() + endpointMethod.substring(1) : "";
|
|
603
585
|
if (endpointMethod && data.d[endpointMethod]) {
|
|
604
586
|
// Update the response to be that object
|
|
@@ -607,50 +589,50 @@ exports.Request = {
|
|
|
607
589
|
// Save a reference to it
|
|
608
590
|
obj["d"] = data.d;
|
|
609
591
|
// Update the metadata
|
|
610
|
-
|
|
592
|
+
Helper.updateMetadata(obj, data.d);
|
|
611
593
|
// Update the base object's properties
|
|
612
|
-
|
|
594
|
+
Request.addProperties(obj, data.d);
|
|
613
595
|
// Add the methods
|
|
614
|
-
|
|
596
|
+
Request.addMethods(obj, data.d, data["@odata.context"]);
|
|
615
597
|
// See if we are not bypassing the processing of the response
|
|
616
598
|
if (base.targetInfo.disableProcessing != true) {
|
|
617
599
|
// Update the data collection
|
|
618
|
-
|
|
600
|
+
Helper.updateDataCollection(obj, data.d.results);
|
|
619
601
|
// Update the expanded properties
|
|
620
|
-
|
|
602
|
+
Helper.updateExpandedProperties(obj);
|
|
621
603
|
}
|
|
622
604
|
// Update the search results
|
|
623
|
-
|
|
605
|
+
Helper.updateSearchResults(obj);
|
|
624
606
|
}
|
|
625
607
|
// Else, see if this is a graph request
|
|
626
608
|
else if (data["@odata.context"] || data["odata.type"] || data["odata.metadata"]) {
|
|
627
609
|
// Save a reference to it
|
|
628
610
|
obj["d"] = data;
|
|
629
611
|
// Update the base object's properties
|
|
630
|
-
|
|
612
|
+
Request.addProperties(obj, data);
|
|
631
613
|
// Add the methods
|
|
632
|
-
|
|
614
|
+
Request.addMethods(obj, data, data["@odata.context"] || data["odata.type"] || data["odata.metadata"]);
|
|
633
615
|
// See if we are not bypassing the processing of the response
|
|
634
616
|
if (base.targetInfo.disableProcessing != true) {
|
|
635
617
|
// Update the data collection
|
|
636
|
-
|
|
618
|
+
Helper.updateDataCollection(obj, data.value);
|
|
637
619
|
// Update the expanded properties
|
|
638
|
-
|
|
620
|
+
Helper.updateExpandedProperties(obj);
|
|
639
621
|
}
|
|
640
622
|
}
|
|
641
623
|
else {
|
|
642
624
|
// Update the base object's properties
|
|
643
|
-
|
|
625
|
+
Request.addProperties(obj, data);
|
|
644
626
|
// See if the response is an array
|
|
645
627
|
if (typeof (data) === "object" && typeof (data.length) === "number" && typeof (data.push) === "function") {
|
|
646
628
|
// Update the data collection
|
|
647
|
-
|
|
629
|
+
Helper.updateDataCollection(obj, data);
|
|
648
630
|
}
|
|
649
631
|
}
|
|
650
632
|
// See if the batch request exists
|
|
651
633
|
if (isBatchRequest) {
|
|
652
634
|
// Get the batch request
|
|
653
|
-
|
|
635
|
+
let batchRequest = base.base.batchRequests[batchIdx][batchRequestIdx++];
|
|
654
636
|
if (batchRequest == null) {
|
|
655
637
|
// Update the batch indexes
|
|
656
638
|
batchIdx++;
|
|
@@ -658,7 +640,7 @@ exports.Request = {
|
|
|
658
640
|
// Ensure the requests exist
|
|
659
641
|
if (base.base.batchRequests[batchIdx]) {
|
|
660
642
|
// Update the batch request
|
|
661
|
-
|
|
643
|
+
let batch = base.base.batchRequests[batchIdx];
|
|
662
644
|
batchRequest = batch ? batch[batchRequestIdx++] : null;
|
|
663
645
|
}
|
|
664
646
|
else {
|
|
@@ -675,21 +657,21 @@ exports.Request = {
|
|
|
675
657
|
// See if this was a batch request
|
|
676
658
|
if (isBatchRequest) {
|
|
677
659
|
// Process the callbacks
|
|
678
|
-
|
|
660
|
+
Batch.processCallbacks(base.base.batchRequests[batchIdx]);
|
|
679
661
|
}
|
|
680
662
|
}
|
|
681
663
|
},
|
|
682
664
|
// Method to validate the data collection results
|
|
683
|
-
validateDataCollectionResults:
|
|
665
|
+
validateDataCollectionResults: (base) => {
|
|
684
666
|
// Return a promise
|
|
685
|
-
return new Promise(
|
|
667
|
+
return new Promise((resolve, reject) => {
|
|
686
668
|
// Method to validate the request
|
|
687
|
-
|
|
669
|
+
let request = (xhr, resolve) => {
|
|
688
670
|
var _a;
|
|
689
671
|
// Validate the response
|
|
690
672
|
if (xhr && xhr.status < 400 && typeof (xhr.response) === "string" && xhr.response.length > 0) {
|
|
691
673
|
// Try to convert the response and ensure the data property exists
|
|
692
|
-
|
|
674
|
+
let data = null;
|
|
693
675
|
try {
|
|
694
676
|
data = JSON.parse(xhr.response);
|
|
695
677
|
}
|
|
@@ -708,26 +690,26 @@ exports.Request = {
|
|
|
708
690
|
// See if there are more items to get
|
|
709
691
|
if (base.nextFl) {
|
|
710
692
|
// Get the root base object
|
|
711
|
-
|
|
693
|
+
let root = Helper.getRootParent(base);
|
|
712
694
|
// See if we are getting all items in the base request
|
|
713
695
|
if (base.getAllItemsFl && root.stopFl != true) {
|
|
714
696
|
// Create the target information to query the next set of results
|
|
715
|
-
|
|
716
|
-
targetInfo.accessToken = base.targetInfo.accessToken || (base.xhr.isGraph ?
|
|
697
|
+
let targetInfo = Object.create(base.targetInfo);
|
|
698
|
+
targetInfo.accessToken = base.targetInfo.accessToken || (base.xhr.isGraph ? Graph.Token : null);
|
|
717
699
|
targetInfo.endpoint = "";
|
|
718
700
|
targetInfo.url = data["@odata.nextLink"] || data.d.__next;
|
|
719
701
|
// Create a new object
|
|
720
|
-
new
|
|
702
|
+
new XHRRequest(true, new TargetInfo(targetInfo), (xhr) => {
|
|
721
703
|
var _a, _b;
|
|
722
704
|
// Convert the response and see if values were returned
|
|
723
|
-
|
|
705
|
+
let data = JSON.parse(xhr.response);
|
|
724
706
|
if (data.d || data.value) {
|
|
725
707
|
// See if we are not bypassing the processing of the response
|
|
726
708
|
if (base.targetInfo.disableProcessing != true) {
|
|
727
709
|
// Update the data collection
|
|
728
|
-
|
|
710
|
+
Helper.updateDataCollection(base, ((_a = data.d) === null || _a === void 0 ? void 0 : _a.results) || data.value);
|
|
729
711
|
// Update the expanded properties
|
|
730
|
-
|
|
712
|
+
Helper.updateExpandedProperties(base);
|
|
731
713
|
}
|
|
732
714
|
// Append the raw data results
|
|
733
715
|
if ((_b = base["d"]) === null || _b === void 0 ? void 0 : _b.results) {
|
|
@@ -767,15 +749,15 @@ exports.Request = {
|
|
|
767
749
|
});
|
|
768
750
|
},
|
|
769
751
|
// Method to wait for the parent requests to complete
|
|
770
|
-
waitForRequestsToComplete:
|
|
752
|
+
waitForRequestsToComplete: (base, callback, requestIdx) => {
|
|
771
753
|
// Ensure a callback exists and is a function
|
|
772
754
|
if (typeof (callback) === "function") {
|
|
773
755
|
// Loop until the requests have completed
|
|
774
|
-
|
|
775
|
-
|
|
756
|
+
let intervalId = ContextInfo.window.setInterval(() => {
|
|
757
|
+
let counter = 0;
|
|
776
758
|
// Parse the responses to the requests
|
|
777
|
-
for (
|
|
778
|
-
|
|
759
|
+
for (let i = 0; i < base.base.responses.length; i++) {
|
|
760
|
+
let response = base.base.responses[i];
|
|
779
761
|
// See if we are waiting until a specified index
|
|
780
762
|
if (requestIdx == counter++) {
|
|
781
763
|
break;
|
|
@@ -790,7 +772,7 @@ exports.Request = {
|
|
|
790
772
|
}
|
|
791
773
|
}
|
|
792
774
|
// Clear the interval
|
|
793
|
-
|
|
775
|
+
ContextInfo.window.clearInterval(intervalId);
|
|
794
776
|
// Execute the callback
|
|
795
777
|
callback();
|
|
796
778
|
}, 10);
|