gd-sprest 9.3.8 → 9.3.9
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/build/rest.js +1 -1
- package/build/utils/batch.js +41 -21
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +1 -1
package/build/rest.js
CHANGED
package/build/utils/batch.js
CHANGED
|
@@ -71,23 +71,23 @@ var Batch = /** @class */ (function () {
|
|
|
71
71
|
// See if this is v2
|
|
72
72
|
if (isV2) {
|
|
73
73
|
// Create the batch requests
|
|
74
|
-
batchRequests
|
|
74
|
+
batchRequests.push(Batch.createBatchV2(batchId, requests));
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
77
|
// Create the batch requests
|
|
78
78
|
batchRequests.push(Batch.createBatch(batchId, requests));
|
|
79
|
-
// End the batch request
|
|
80
|
-
batchRequests.push("--" + batchId + "--");
|
|
81
79
|
}
|
|
80
|
+
// End the batch request
|
|
81
|
+
batchRequests.push("--" + batchId + "--");
|
|
82
82
|
// Return the target information
|
|
83
83
|
return new _1.TargetInfo({
|
|
84
84
|
url: url,
|
|
85
85
|
endpoint: (isV2 ? "_api/v2.0/" : "") + "$batch",
|
|
86
86
|
method: "POST",
|
|
87
|
-
data:
|
|
87
|
+
data: batchRequests.join("\r\n"),
|
|
88
88
|
requestDigest: requestDigest,
|
|
89
89
|
requestHeader: {
|
|
90
|
-
"Content-Type":
|
|
90
|
+
"Content-Type": 'multipart/mixed; boundary="' + batchId + '"'
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
};
|
|
@@ -145,29 +145,49 @@ var Batch = /** @class */ (function () {
|
|
|
145
145
|
return request.join("\r\n");
|
|
146
146
|
};
|
|
147
147
|
// Method to generate a batch request
|
|
148
|
-
Batch.createBatchV2 = function (requests) {
|
|
148
|
+
Batch.createBatchV2 = function (batchId, requests) {
|
|
149
149
|
var batch = [];
|
|
150
150
|
// Parse the requests
|
|
151
151
|
for (var i = 0; i < requests.length; i++) {
|
|
152
152
|
var request = requests[i];
|
|
153
153
|
// Create the batch request
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
154
|
+
batch.push("--" + batchId);
|
|
155
|
+
// Determine if the batch requires a change set
|
|
156
|
+
var requiresChangeset = request && request.targetInfo.requestMethod != "GET";
|
|
157
|
+
if (requiresChangeset) {
|
|
158
|
+
// Create a change set
|
|
159
|
+
batch.push("Content-Type: multipart/mixed; boundary=" + request.changesetId);
|
|
160
|
+
batch.push("");
|
|
161
|
+
batch.push("--" + request.changesetId);
|
|
162
|
+
batch.push("Content-Type: application/http");
|
|
163
|
+
batch.push("Content-Transfer-Encoding: binary");
|
|
164
|
+
batch.push("");
|
|
165
|
+
batch.push(request.targetInfo.requestMethod + " " + request.targetInfo.requestUrl + " HTTP/1.1");
|
|
166
|
+
batch.push("Content-Type: application/json;odata=verbose");
|
|
167
|
+
// See if we are making a delete/update
|
|
168
|
+
if (request.targetInfo.requestMethod == "DELETE" || request.targetInfo.requestMethod == "MERGE") {
|
|
169
|
+
// Append the header for deleting/updating
|
|
170
|
+
batch.push("IF-MATCH: *");
|
|
171
|
+
}
|
|
172
|
+
batch.push("");
|
|
173
|
+
request.targetInfo.requestData ? batch.push(request.targetInfo.requestData) : null;
|
|
174
|
+
batch.push("");
|
|
175
|
+
batch.push("--" + request.changesetId + "--");
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
// Create a change set
|
|
179
|
+
batch.push("Content-Type: application/http");
|
|
180
|
+
batch.push("Content-Transfer-Encoding: binary");
|
|
181
|
+
batch.push("");
|
|
182
|
+
batch.push("GET " + request.targetInfo.requestUrl + " HTTP/1.1");
|
|
183
|
+
batch.push("Accept: application/json");
|
|
184
|
+
batch.push("");
|
|
185
|
+
request.targetInfo.requestData ? batch.push(request.targetInfo.requestData) : null;
|
|
186
|
+
batch.push("");
|
|
165
187
|
}
|
|
166
|
-
// Add the batch request
|
|
167
|
-
batch.push(batchRequest);
|
|
168
188
|
}
|
|
169
|
-
// Return the batch
|
|
170
|
-
return batch;
|
|
189
|
+
// Return the batch request
|
|
190
|
+
return batch.join("\r\n");
|
|
171
191
|
};
|
|
172
192
|
// Process the batch request callbacks
|
|
173
193
|
Batch.processCallbacks = function (batchRequests) {
|