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/batch.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Batch = void 0;
|
|
4
|
-
var lib_1 = require("../lib");
|
|
5
|
-
var _1 = require(".");
|
|
1
|
+
import { ContextInfo } from "../lib";
|
|
2
|
+
import { TargetInfo } from ".";
|
|
6
3
|
/**
|
|
7
4
|
* Batch Requests
|
|
8
5
|
*/
|
|
9
|
-
|
|
10
|
-
function Batch() {
|
|
11
|
-
}
|
|
6
|
+
export class Batch {
|
|
12
7
|
// Method to execute a batch request
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
static execute(base, args) {
|
|
9
|
+
let createFl = false;
|
|
10
|
+
let callback = null;
|
|
16
11
|
// Parse the arguments
|
|
17
|
-
for (
|
|
18
|
-
|
|
12
|
+
for (let i = 0; i < args.length; i++) {
|
|
13
|
+
let arg = args[i];
|
|
19
14
|
// Check the type
|
|
20
15
|
switch (typeof (arg)) {
|
|
21
16
|
case "boolean":
|
|
@@ -36,9 +31,9 @@ var Batch = /** @class */ (function () {
|
|
|
36
31
|
base.base.batchRequests = base.base.batchRequests || [];
|
|
37
32
|
// Create the request
|
|
38
33
|
base.base.batchRequests.push([{
|
|
39
|
-
callback
|
|
40
|
-
changesetId:
|
|
41
|
-
targetInfo: new
|
|
34
|
+
callback,
|
|
35
|
+
changesetId: ContextInfo.generateGUID(),
|
|
36
|
+
targetInfo: new TargetInfo(base.targetInfo)
|
|
42
37
|
}]);
|
|
43
38
|
}
|
|
44
39
|
else {
|
|
@@ -46,29 +41,27 @@ var Batch = /** @class */ (function () {
|
|
|
46
41
|
if (base.base.batchRequests[base.base.batchRequests.length - 1].length == 100) {
|
|
47
42
|
// Create a new request
|
|
48
43
|
base.base.batchRequests.push([{
|
|
49
|
-
callback
|
|
50
|
-
changesetId:
|
|
51
|
-
targetInfo: new
|
|
44
|
+
callback,
|
|
45
|
+
changesetId: ContextInfo.generateGUID(),
|
|
46
|
+
targetInfo: new TargetInfo(base.targetInfo)
|
|
52
47
|
}]);
|
|
53
48
|
}
|
|
54
49
|
else {
|
|
55
50
|
// Append the request
|
|
56
51
|
base.base.batchRequests[base.base.batchRequests.length - 1].push({
|
|
57
|
-
callback
|
|
58
|
-
changesetId:
|
|
59
|
-
targetInfo: new
|
|
52
|
+
callback,
|
|
53
|
+
changesetId: ContextInfo.generateGUID(),
|
|
54
|
+
targetInfo: new TargetInfo(base.targetInfo)
|
|
60
55
|
});
|
|
61
56
|
}
|
|
62
57
|
}
|
|
63
58
|
// Return this object
|
|
64
59
|
return base;
|
|
65
|
-
}
|
|
60
|
+
}
|
|
66
61
|
// Method to generate a batch request
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var batchId = "batch_" + lib_1.ContextInfo.generateGUID();
|
|
71
|
-
var batchRequests = [];
|
|
62
|
+
static getTargetInfo(url, requests, requestDigest, requestHeader = {}, isV2 = false) {
|
|
63
|
+
let batchId = "batch_" + ContextInfo.generateGUID();
|
|
64
|
+
let batchRequests = [];
|
|
72
65
|
// See if this is v2
|
|
73
66
|
if (isV2) {
|
|
74
67
|
// Create the batch requests
|
|
@@ -83,60 +76,60 @@ var Batch = /** @class */ (function () {
|
|
|
83
76
|
// Update the request header
|
|
84
77
|
requestHeader["Content-Type"] = 'multipart/mixed; boundary="' + batchId + '"';
|
|
85
78
|
// Return the target information
|
|
86
|
-
return new
|
|
87
|
-
url
|
|
79
|
+
return new TargetInfo({
|
|
80
|
+
url,
|
|
88
81
|
endpoint: (isV2 ? "_api/v2.0/" : "") + "$batch",
|
|
89
82
|
method: "POST",
|
|
90
83
|
data: batchRequests.join("\r\n"),
|
|
91
|
-
requestDigest
|
|
92
|
-
requestHeader
|
|
84
|
+
requestDigest,
|
|
85
|
+
requestHeader
|
|
93
86
|
});
|
|
94
|
-
}
|
|
87
|
+
}
|
|
95
88
|
// Method to generate a batch request
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
static createBatch(batchId, requests) {
|
|
90
|
+
let batch = [];
|
|
98
91
|
// Parse the requests
|
|
99
|
-
for (
|
|
100
|
-
|
|
92
|
+
for (let i = 0; i < requests.length; i++) {
|
|
93
|
+
let request = requests[i];
|
|
101
94
|
// Create the batch request
|
|
102
95
|
batch.push("--" + batchId);
|
|
103
96
|
// Determine if the batch requires a change set
|
|
104
|
-
|
|
97
|
+
let requiresChangeset = request && request.targetInfo.requestMethod != "GET";
|
|
105
98
|
if (requiresChangeset) {
|
|
106
99
|
// Create a change set
|
|
107
|
-
batch.push("Content-Type: multipart/mixed; boundary=" +
|
|
100
|
+
batch.push("Content-Type: multipart/mixed; boundary=" + request.changesetId);
|
|
108
101
|
batch.push("");
|
|
109
|
-
batch.push("--" +
|
|
102
|
+
batch.push("--" + request.changesetId);
|
|
110
103
|
batch.push("Content-Type: application/http");
|
|
111
104
|
batch.push("Content-Transfer-Encoding: binary");
|
|
112
105
|
batch.push("");
|
|
113
|
-
batch.push(
|
|
106
|
+
batch.push(request.targetInfo.requestMethod + " " + request.targetInfo.requestUrl + " HTTP/1.1");
|
|
114
107
|
batch.push("Content-Type: application/json;odata=verbose");
|
|
115
108
|
// See if we are making a delete/update
|
|
116
|
-
if (
|
|
109
|
+
if (request.targetInfo.requestMethod == "DELETE" || request.targetInfo.requestMethod == "MERGE") {
|
|
117
110
|
// Append the header for deleting/updating
|
|
118
111
|
batch.push("IF-MATCH: *");
|
|
119
112
|
}
|
|
120
113
|
batch.push("");
|
|
121
|
-
|
|
114
|
+
request.targetInfo.requestData ? batch.push(request.targetInfo.requestData) : null;
|
|
122
115
|
batch.push("");
|
|
123
|
-
batch.push("--" +
|
|
116
|
+
batch.push("--" + request.changesetId + "--");
|
|
124
117
|
}
|
|
125
118
|
else {
|
|
126
119
|
// Create a change set
|
|
127
120
|
batch.push("Content-Type: application/http");
|
|
128
121
|
batch.push("Content-Transfer-Encoding: binary");
|
|
129
122
|
batch.push("");
|
|
130
|
-
batch.push("GET " +
|
|
123
|
+
batch.push("GET " + request.targetInfo.requestUrl + " HTTP/1.1");
|
|
131
124
|
batch.push("Accept: application/json;odata=verbose");
|
|
132
125
|
batch.push("");
|
|
133
|
-
|
|
126
|
+
request.targetInfo.requestData ? batch.push(request.targetInfo.requestData) : null;
|
|
134
127
|
batch.push("");
|
|
135
128
|
}
|
|
136
129
|
}
|
|
137
130
|
// Add the change set information to the batch
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
let batchRequest = batch.join("\r\n");
|
|
132
|
+
let request = [];
|
|
140
133
|
request.push("Content-Type: multipart/mixed; boundary=" + batchId);
|
|
141
134
|
request.push("Content-Length: " + batchRequest.length);
|
|
142
135
|
request.push("");
|
|
@@ -144,17 +137,17 @@ var Batch = /** @class */ (function () {
|
|
|
144
137
|
request.push("");
|
|
145
138
|
// Return the batch request
|
|
146
139
|
return request.join("\r\n");
|
|
147
|
-
}
|
|
140
|
+
}
|
|
148
141
|
// Method to generate a batch request
|
|
149
|
-
|
|
150
|
-
|
|
142
|
+
static createBatchV2(batchId, requests) {
|
|
143
|
+
let batch = [];
|
|
151
144
|
// Parse the requests
|
|
152
|
-
for (
|
|
153
|
-
|
|
145
|
+
for (let i = 0; i < requests.length; i++) {
|
|
146
|
+
let request = requests[i];
|
|
154
147
|
// Create the batch request
|
|
155
148
|
batch.push("--" + batchId);
|
|
156
149
|
// Determine if the batch requires a change set
|
|
157
|
-
|
|
150
|
+
let requiresChangeset = request && request.targetInfo.requestMethod != "GET";
|
|
158
151
|
if (requiresChangeset) {
|
|
159
152
|
// Create a change set
|
|
160
153
|
batch.push("Content-Type: application/http");
|
|
@@ -187,20 +180,17 @@ var Batch = /** @class */ (function () {
|
|
|
187
180
|
}
|
|
188
181
|
// Return the batch request
|
|
189
182
|
return batch.join("\r\n");
|
|
190
|
-
}
|
|
183
|
+
}
|
|
191
184
|
// Process the batch request callbacks
|
|
192
|
-
|
|
193
|
-
if (batchRequests === void 0) { batchRequests = []; }
|
|
185
|
+
static processCallbacks(batchRequests = []) {
|
|
194
186
|
// Parse the requests
|
|
195
|
-
for (
|
|
196
|
-
|
|
187
|
+
for (let i = 0; i < batchRequests.length; i++) {
|
|
188
|
+
let batchRequest = batchRequests[i];
|
|
197
189
|
// See if a callback exists
|
|
198
190
|
if (batchRequest.callback) {
|
|
199
191
|
// Execute the callback
|
|
200
192
|
batchRequest.callback(batchRequest.response, batchRequest.targetInfo);
|
|
201
193
|
}
|
|
202
194
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
}());
|
|
206
|
-
exports.Batch = Batch;
|
|
195
|
+
}
|
|
196
|
+
}
|
package/build/utils/helper.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var lib_1 = require("../lib");
|
|
5
|
-
var _1 = require(".");
|
|
6
|
-
var xhrRequest_1 = require("./xhrRequest");
|
|
1
|
+
import { ContextInfo, Graph } from "../lib";
|
|
2
|
+
import { Base, MethodInfo, Request, RequestType, TargetInfo } from ".";
|
|
3
|
+
import { XHRRequest } from "./xhrRequest";
|
|
7
4
|
/**
|
|
8
5
|
* Request Helper
|
|
9
6
|
*/
|
|
10
|
-
|
|
7
|
+
export const Helper = {
|
|
11
8
|
// Method to add the base references
|
|
12
|
-
addBaseMethods:
|
|
9
|
+
addBaseMethods: (base, obj) => {
|
|
13
10
|
// Add the base references
|
|
14
11
|
obj["addMethods"] = base.addMethods;
|
|
15
12
|
obj["base"] = base.base;
|
|
@@ -27,14 +24,14 @@ exports.Helper = {
|
|
|
27
24
|
obj["waitForRequestsToComplete"] = base.waitForRequestsToComplete;
|
|
28
25
|
},
|
|
29
26
|
// Method to wait for all requests to complete, before resolving the request
|
|
30
|
-
done:
|
|
27
|
+
done: (base, resolve) => {
|
|
31
28
|
// Ensure the base is set
|
|
32
29
|
base.base = base.base ? base.base : base;
|
|
33
30
|
// Ensure the response index is set
|
|
34
31
|
base.responseIndex = base.responseIndex >= 0 ? base.responseIndex : 0;
|
|
35
32
|
// Wait for the responses to execute
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
Request.waitForRequestsToComplete(base, () => {
|
|
34
|
+
let responses = base.base.responses;
|
|
38
35
|
// Clear the responses
|
|
39
36
|
base.base.responses = [];
|
|
40
37
|
// Clear the wait flags
|
|
@@ -44,11 +41,11 @@ exports.Helper = {
|
|
|
44
41
|
});
|
|
45
42
|
},
|
|
46
43
|
// Method to execute a method
|
|
47
|
-
executeMethod:
|
|
44
|
+
executeMethod: (base, methodName, methodConfig, args) => {
|
|
48
45
|
var _a, _b;
|
|
49
|
-
|
|
46
|
+
let targetInfo = null;
|
|
50
47
|
// See if the metadata is defined for the base object
|
|
51
|
-
|
|
48
|
+
let metadata = base["d"] ? base["d"].__metadata : base["__metadata"];
|
|
52
49
|
if (metadata && metadata.uri) {
|
|
53
50
|
// Create the target information and use the url defined for the base object
|
|
54
51
|
targetInfo = {
|
|
@@ -61,7 +58,7 @@ exports.Helper = {
|
|
|
61
58
|
methodConfig.metadataType = metadata.type;
|
|
62
59
|
}
|
|
63
60
|
// Update the metadata uri
|
|
64
|
-
|
|
61
|
+
Helper.updateMetadataUri(base, metadata, targetInfo);
|
|
65
62
|
}
|
|
66
63
|
else {
|
|
67
64
|
// Copy the target information
|
|
@@ -73,20 +70,20 @@ exports.Helper = {
|
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
72
|
// See if the method config name has a base reference
|
|
76
|
-
|
|
73
|
+
let startIdx = (_b = methodConfig === null || methodConfig === void 0 ? void 0 : methodConfig.name) === null || _b === void 0 ? void 0 : _b.indexOf("[base.");
|
|
77
74
|
if (startIdx >= 0) {
|
|
78
75
|
// Get the property name
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
let endIdx = methodConfig.name.indexOf("]", startIdx);
|
|
77
|
+
let propName = methodConfig.name.substring(startIdx, endIdx).split(".")[1];
|
|
81
78
|
// Get the property value
|
|
82
|
-
|
|
79
|
+
let propValue = (base[propName] || "").replace(/"/g, '').split(',')[0];
|
|
83
80
|
// Update the method name
|
|
84
81
|
methodConfig.name = methodConfig.name.replace("[base." + propName + "]", propValue);
|
|
85
82
|
}
|
|
86
83
|
// Get the method information
|
|
87
|
-
var methodInfo = new
|
|
84
|
+
var methodInfo = new MethodInfo(methodName, methodConfig, args);
|
|
88
85
|
// Update the target information
|
|
89
|
-
targetInfo.bufferFl = methodConfig.requestType ==
|
|
86
|
+
targetInfo.bufferFl = methodConfig.requestType == RequestType.GetBuffer;
|
|
90
87
|
targetInfo.data = methodInfo.body;
|
|
91
88
|
targetInfo.defaultToWebFl = typeof (targetInfo.defaultToWebFl) === "undefined" && base.base ? base.base.targetInfo.defaultToWebFl : targetInfo.defaultToWebFl;
|
|
92
89
|
targetInfo.method = methodInfo.requestMethod;
|
|
@@ -123,7 +120,7 @@ exports.Helper = {
|
|
|
123
120
|
}
|
|
124
121
|
}
|
|
125
122
|
// Create a new object
|
|
126
|
-
|
|
123
|
+
let obj = new Base(targetInfo);
|
|
127
124
|
// Set the properties
|
|
128
125
|
obj.base = base.base ? base.base : base;
|
|
129
126
|
obj.getAllItemsFl = methodInfo.getAllItemsFl;
|
|
@@ -132,25 +129,25 @@ exports.Helper = {
|
|
|
132
129
|
// Ensure the return type exists
|
|
133
130
|
if (methodConfig.returnType) {
|
|
134
131
|
// Add the methods
|
|
135
|
-
|
|
132
|
+
Request.addMethods(obj, { __metadata: { type: methodConfig.returnType } });
|
|
136
133
|
}
|
|
137
134
|
// Return the object
|
|
138
135
|
return obj;
|
|
139
136
|
},
|
|
140
137
|
// Method to return a collection
|
|
141
|
-
getCollection:
|
|
138
|
+
getCollection: (base, method, args) => {
|
|
142
139
|
// Copy the target information
|
|
143
|
-
|
|
140
|
+
let targetInfo = Object.create(base.targetInfo);
|
|
144
141
|
// Clear the target information properties from any previous requests
|
|
145
142
|
targetInfo.data = null;
|
|
146
143
|
targetInfo.method = null;
|
|
147
144
|
// See if the metadata is defined for the base object
|
|
148
|
-
|
|
145
|
+
let metadata = base["d"] ? base["d"].__metadata : base["__metadata"];
|
|
149
146
|
if (metadata && metadata.uri) {
|
|
150
147
|
// Update the url of the target information
|
|
151
148
|
targetInfo.url = metadata.uri;
|
|
152
149
|
// Update the metadata uri
|
|
153
|
-
|
|
150
|
+
Helper.updateMetadataUri(base, metadata, targetInfo);
|
|
154
151
|
// Set the endpoint
|
|
155
152
|
targetInfo.endpoint = method;
|
|
156
153
|
}
|
|
@@ -161,7 +158,7 @@ exports.Helper = {
|
|
|
161
158
|
// Update the callback
|
|
162
159
|
targetInfo.callback = args && typeof (args[0]) === "function" ? args[0] : null;
|
|
163
160
|
// Create a new object
|
|
164
|
-
|
|
161
|
+
let obj = new Base(targetInfo);
|
|
165
162
|
// Set the properties
|
|
166
163
|
obj.base = base.base ? base.base : base;
|
|
167
164
|
obj.parent = base;
|
|
@@ -169,14 +166,14 @@ exports.Helper = {
|
|
|
169
166
|
return obj;
|
|
170
167
|
},
|
|
171
168
|
// Method to get the next set of results
|
|
172
|
-
getNextSetOfResults:
|
|
169
|
+
getNextSetOfResults: (base) => {
|
|
173
170
|
// Create the target information to query the next set of results
|
|
174
|
-
|
|
175
|
-
targetInfo.accessToken = base.targetInfo.accessToken || (base.xhr.isGraph ?
|
|
171
|
+
let targetInfo = Object.create(base.targetInfo);
|
|
172
|
+
targetInfo.accessToken = base.targetInfo.accessToken || (base.xhr.isGraph ? Graph.Token : null);
|
|
176
173
|
targetInfo.endpoint = "";
|
|
177
174
|
targetInfo.url = base["@odata.nextLink"] || base["d"].__next;
|
|
178
175
|
// Create a new object
|
|
179
|
-
|
|
176
|
+
let obj = new Base(targetInfo);
|
|
180
177
|
// Set the properties
|
|
181
178
|
obj.base = base.base ? base.base : base;
|
|
182
179
|
obj.parent = base;
|
|
@@ -184,24 +181,24 @@ exports.Helper = {
|
|
|
184
181
|
return obj;
|
|
185
182
|
},
|
|
186
183
|
// Method to return a property of the base object
|
|
187
|
-
getProperty:
|
|
184
|
+
getProperty: (base, propertyName, requestType) => {
|
|
188
185
|
// Copy the target information
|
|
189
|
-
|
|
186
|
+
let targetInfo = Object.create(base.targetInfo);
|
|
190
187
|
// See if this is a graph request
|
|
191
188
|
if (requestType.indexOf("graph") == 0) {
|
|
192
189
|
// Default the request type
|
|
193
|
-
targetInfo.requestType =
|
|
190
|
+
targetInfo.requestType = RequestType.GraphGet;
|
|
194
191
|
}
|
|
195
192
|
// Clear the target information properties from any previous requests
|
|
196
193
|
targetInfo.data = null;
|
|
197
194
|
targetInfo.method = null;
|
|
198
195
|
// See if the metadata is defined for the base object
|
|
199
|
-
|
|
196
|
+
let metadata = base["d"] ? base["d"].__metadata : base["__metadata"];
|
|
200
197
|
if (metadata && metadata.uri) {
|
|
201
198
|
// Update the url of the target information
|
|
202
199
|
targetInfo.url = metadata.uri;
|
|
203
200
|
// Update the metadata uri
|
|
204
|
-
|
|
201
|
+
Helper.updateMetadataUri(base, metadata, targetInfo);
|
|
205
202
|
// Set the endpoint
|
|
206
203
|
targetInfo.endpoint = propertyName;
|
|
207
204
|
}
|
|
@@ -210,32 +207,32 @@ exports.Helper = {
|
|
|
210
207
|
targetInfo.endpoint += "/" + propertyName;
|
|
211
208
|
}
|
|
212
209
|
// Create a new object
|
|
213
|
-
|
|
210
|
+
let obj = new Base(targetInfo);
|
|
214
211
|
// Set the properties
|
|
215
212
|
obj.base = base.base ? base.base : base;
|
|
216
213
|
obj.parent = base;
|
|
217
214
|
// Add the methods
|
|
218
|
-
requestType ?
|
|
215
|
+
requestType ? Request.addMethods(obj, { __metadata: { type: requestType } }) : null;
|
|
219
216
|
// Return the object
|
|
220
217
|
return obj;
|
|
221
218
|
},
|
|
222
219
|
// Method to get the request information
|
|
223
|
-
getRequestInfo:
|
|
220
|
+
getRequestInfo: (base) => {
|
|
224
221
|
// Create the request, but don't execute it
|
|
225
|
-
|
|
222
|
+
let xhr = new XHRRequest(true, new TargetInfo(base.targetInfo), null, false);
|
|
226
223
|
// Return the request information
|
|
227
224
|
return xhr.requestInfo;
|
|
228
225
|
},
|
|
229
|
-
getRootParent:
|
|
226
|
+
getRootParent: (base) => {
|
|
230
227
|
// Find the root base object and return it
|
|
231
|
-
|
|
228
|
+
let root = base;
|
|
232
229
|
while (root.parent) {
|
|
233
230
|
root = root.parent;
|
|
234
231
|
}
|
|
235
232
|
return root;
|
|
236
233
|
},
|
|
237
234
|
// Method to stringify the object
|
|
238
|
-
stringify:
|
|
235
|
+
stringify: (base) => {
|
|
239
236
|
// Stringify the object
|
|
240
237
|
return JSON.stringify({
|
|
241
238
|
response: base.response,
|
|
@@ -256,20 +253,20 @@ exports.Helper = {
|
|
|
256
253
|
});
|
|
257
254
|
},
|
|
258
255
|
// Method to update a collection object
|
|
259
|
-
updateDataCollection:
|
|
256
|
+
updateDataCollection: (obj, results) => {
|
|
260
257
|
// Ensure the base is a collection
|
|
261
258
|
if (results) {
|
|
262
259
|
// Save the results
|
|
263
260
|
obj["results"] = obj["results"] ? obj["results"].concat(results) : results;
|
|
264
261
|
// See if only one object exists
|
|
265
262
|
if (obj["results"].length > 0) {
|
|
266
|
-
|
|
263
|
+
let results = obj["results"];
|
|
267
264
|
// See if this is a v2 request, and set the default object type
|
|
268
|
-
|
|
265
|
+
let objType = null;
|
|
269
266
|
if (obj["@odata.context"] || obj["odata.type"] || obj["odata.metadata"]) {
|
|
270
267
|
// Get the object type
|
|
271
|
-
|
|
272
|
-
|
|
268
|
+
let metadataType = (obj["@odata.context"] || obj["odata.type"] || obj["odata.metadata"] || objType);
|
|
269
|
+
let values = metadataType.split("_api/v2.0/$metadata#");
|
|
273
270
|
if (values.length > 1) {
|
|
274
271
|
objType = values[1];
|
|
275
272
|
}
|
|
@@ -281,51 +278,50 @@ exports.Helper = {
|
|
|
281
278
|
objType = objType.replace(/s$/, '');
|
|
282
279
|
}
|
|
283
280
|
// Parse the results
|
|
284
|
-
for (
|
|
285
|
-
var result = results_1[_i];
|
|
281
|
+
for (let result of results) {
|
|
286
282
|
// Add the base methods
|
|
287
|
-
|
|
283
|
+
Helper.addBaseMethods(obj, result);
|
|
288
284
|
// Update the metadata
|
|
289
|
-
|
|
285
|
+
Helper.updateMetadata(obj, result);
|
|
290
286
|
// Add the methods
|
|
291
|
-
|
|
287
|
+
Request.addMethods(result, result, objType);
|
|
292
288
|
}
|
|
293
289
|
}
|
|
294
290
|
}
|
|
295
291
|
},
|
|
296
292
|
// Method to update the expanded collection property
|
|
297
|
-
updateExpandedCollection:
|
|
293
|
+
updateExpandedCollection: (base, results) => {
|
|
298
294
|
// Parse the results
|
|
299
|
-
for (
|
|
300
|
-
|
|
295
|
+
for (let i = 0; i < results.length; i++) {
|
|
296
|
+
let result = results[i];
|
|
301
297
|
// See if this property was expanded
|
|
302
298
|
if (result["__metadata"] || result["@odata.context"] || result["odata.type"] || result["odata.metadata"]) {
|
|
303
299
|
// Add the base methods
|
|
304
|
-
|
|
300
|
+
Helper.addBaseMethods(base, result);
|
|
305
301
|
// Update the metadata
|
|
306
|
-
|
|
302
|
+
Helper.updateMetadata(result, result);
|
|
307
303
|
// Add the methods
|
|
308
|
-
|
|
304
|
+
Request.addMethods(result, result);
|
|
309
305
|
}
|
|
310
306
|
}
|
|
311
307
|
},
|
|
312
308
|
// Method to update the expanded properties
|
|
313
|
-
updateExpandedProperties:
|
|
309
|
+
updateExpandedProperties: (base) => {
|
|
314
310
|
// Ensure this is an OData request
|
|
315
|
-
if (base["results"] == null || base.requestType !=
|
|
311
|
+
if (base["results"] == null || base.requestType != RequestType.OData) {
|
|
316
312
|
return;
|
|
317
313
|
}
|
|
318
314
|
// Parse the results
|
|
319
|
-
for (
|
|
320
|
-
|
|
315
|
+
for (let i = 0; i < base["results"].length; i++) {
|
|
316
|
+
let result = base["results"][i];
|
|
321
317
|
// Parse the properties
|
|
322
|
-
for (
|
|
318
|
+
for (let key in result) {
|
|
323
319
|
// Skip the parent property
|
|
324
320
|
if (key == "parent") {
|
|
325
321
|
continue;
|
|
326
322
|
}
|
|
327
323
|
// Ensure the property exists
|
|
328
|
-
|
|
324
|
+
let prop = result[key];
|
|
329
325
|
if (prop) {
|
|
330
326
|
// See if this is a graph collection
|
|
331
327
|
if (typeof (prop === null || prop === void 0 ? void 0 : prop.length) === "number" && typeof (result[key + "@odata.navigationLinkUrl"]) === "string") {
|
|
@@ -335,29 +331,29 @@ exports.Helper = {
|
|
|
335
331
|
// See if this is a collection
|
|
336
332
|
if (prop["results"] && prop["results"].length > 0) {
|
|
337
333
|
// Update the expanded collection
|
|
338
|
-
|
|
334
|
+
Helper.updateExpandedCollection(base, prop.results);
|
|
339
335
|
}
|
|
340
336
|
// Else, see if this property was expanded
|
|
341
337
|
else if (prop["__metadata"]) {
|
|
342
338
|
// Add the base methods
|
|
343
|
-
|
|
339
|
+
Helper.addBaseMethods(result, prop);
|
|
344
340
|
// Update the metadata
|
|
345
|
-
|
|
341
|
+
Helper.updateMetadata(result, prop);
|
|
346
342
|
// Add the methods
|
|
347
|
-
|
|
343
|
+
Request.addMethods(prop, prop);
|
|
348
344
|
}
|
|
349
345
|
}
|
|
350
346
|
}
|
|
351
347
|
}
|
|
352
348
|
},
|
|
353
349
|
// Method to update the metadata
|
|
354
|
-
updateMetadata:
|
|
350
|
+
updateMetadata: (base, data) => {
|
|
355
351
|
// See if this is the app web
|
|
356
|
-
if (
|
|
352
|
+
if (ContextInfo.isAppWeb) {
|
|
357
353
|
// Get the url information
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
354
|
+
let hostUrl = ContextInfo.webAbsoluteUrl.toLowerCase();
|
|
355
|
+
let requestUrl = data && data.__metadata && data.__metadata.uri ? data.__metadata.uri.toLowerCase() : null;
|
|
356
|
+
let targetUrl = base.targetInfo && base.targetInfo.url ? base.targetInfo.url.toLowerCase() : null;
|
|
361
357
|
// Ensure the urls exist
|
|
362
358
|
if (hostUrl == null || requestUrl == null || targetUrl == null) {
|
|
363
359
|
return;
|
|
@@ -376,7 +372,7 @@ exports.Helper = {
|
|
|
376
372
|
}
|
|
377
373
|
},
|
|
378
374
|
// Method to update the metadata uri
|
|
379
|
-
updateMetadataUri:
|
|
375
|
+
updateMetadataUri: (base, metadata, targetInfo) => {
|
|
380
376
|
// See if this is a field
|
|
381
377
|
if (/^SP.Field/.test(metadata.type) || /^SP\..*Field$/.test(metadata.type)) {
|
|
382
378
|
// Fix the url reference
|
|
@@ -394,21 +390,21 @@ exports.Helper = {
|
|
|
394
390
|
}
|
|
395
391
|
},
|
|
396
392
|
// Method to update the search results
|
|
397
|
-
updateSearchResults:
|
|
393
|
+
updateSearchResults: (base) => {
|
|
398
394
|
// See if this contains search results
|
|
399
|
-
|
|
395
|
+
let results = base["postquery"];
|
|
400
396
|
if (results == null || results.PrimaryQueryResult == null) {
|
|
401
397
|
return;
|
|
402
398
|
}
|
|
403
399
|
// Clear the results
|
|
404
400
|
base["postquery"].results = base["postquery"].results || [];
|
|
405
401
|
// Parse the results
|
|
406
|
-
for (
|
|
407
|
-
|
|
408
|
-
|
|
402
|
+
for (let i = 0; i < results.PrimaryQueryResult.RelevantResults.RowCount; i++) {
|
|
403
|
+
let data = {};
|
|
404
|
+
let result = results.PrimaryQueryResult.RelevantResults.Table.Rows.results[i];
|
|
409
405
|
// Parse the cells
|
|
410
|
-
for (
|
|
411
|
-
|
|
406
|
+
for (let j = 0; j < result.Cells.results.length; j++) {
|
|
407
|
+
let cell = result.Cells.results[j];
|
|
412
408
|
// Add the key/value
|
|
413
409
|
data[cell.Key] = cell.Value;
|
|
414
410
|
}
|
package/build/utils/index.js
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./requestType"), exports);
|
|
18
|
-
__exportStar(require("./helper"), exports);
|
|
19
|
-
__exportStar(require("./base"), exports);
|
|
20
|
-
__exportStar(require("./batch"), exports);
|
|
21
|
-
__exportStar(require("./methodInfo"), exports);
|
|
22
|
-
__exportStar(require("./oData"), exports);
|
|
23
|
-
__exportStar(require("./request"), exports);
|
|
24
|
-
__exportStar(require("./targetInfo"), exports);
|
|
25
|
-
__exportStar(require("./xhrRequest"), exports);
|
|
1
|
+
export * from "./requestType";
|
|
2
|
+
export * from "./helper";
|
|
3
|
+
export * from "./base";
|
|
4
|
+
export * from "./batch";
|
|
5
|
+
export * from "./methodInfo";
|
|
6
|
+
export * from "./oData";
|
|
7
|
+
export * from "./request";
|
|
8
|
+
export * from "./targetInfo";
|
|
9
|
+
export * from "./xhrRequest";
|