gd-sprest 9.6.2 → 9.6.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/build/rest.js +1 -1
- package/build/utils/batch.js +5 -4
- package/build/utils/request.js +6 -5
- 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
|
@@ -64,7 +64,8 @@ var Batch = /** @class */ (function () {
|
|
|
64
64
|
return base;
|
|
65
65
|
};
|
|
66
66
|
// Method to generate a batch request
|
|
67
|
-
Batch.getTargetInfo = function (url, requests, requestDigest, isV2) {
|
|
67
|
+
Batch.getTargetInfo = function (url, requests, requestDigest, requestHeader, isV2) {
|
|
68
|
+
if (requestHeader === void 0) { requestHeader = {}; }
|
|
68
69
|
if (isV2 === void 0) { isV2 = false; }
|
|
69
70
|
var batchId = "batch_" + lib_1.ContextInfo.generateGUID();
|
|
70
71
|
var batchRequests = [];
|
|
@@ -79,6 +80,8 @@ var Batch = /** @class */ (function () {
|
|
|
79
80
|
}
|
|
80
81
|
// End the batch request
|
|
81
82
|
batchRequests.push("--" + batchId + "--");
|
|
83
|
+
// Update the request header
|
|
84
|
+
requestHeader["Content-Type"] = 'multipart/mixed; boundary="' + batchId + '"';
|
|
82
85
|
// Return the target information
|
|
83
86
|
return new _1.TargetInfo({
|
|
84
87
|
url: url,
|
|
@@ -86,9 +89,7 @@ var Batch = /** @class */ (function () {
|
|
|
86
89
|
method: "POST",
|
|
87
90
|
data: batchRequests.join("\r\n"),
|
|
88
91
|
requestDigest: requestDigest,
|
|
89
|
-
requestHeader:
|
|
90
|
-
"Content-Type": 'multipart/mixed; boundary="' + batchId + '"'
|
|
91
|
-
}
|
|
92
|
+
requestHeader: requestHeader
|
|
92
93
|
});
|
|
93
94
|
};
|
|
94
95
|
// Method to generate a batch request
|
package/build/utils/request.js
CHANGED
|
@@ -428,7 +428,7 @@ exports.Request = {
|
|
|
428
428
|
// Return a promise
|
|
429
429
|
return new Promise(function (resolve) {
|
|
430
430
|
// Execute the request
|
|
431
|
-
execute(batch_1.Batch.getTargetInfo(base.targetInfo.url, batchRequest, base.targetInfo.requestDigest, base.targetInfo.endpoint.indexOf("_api/v2") >= 0), batchIdx_1++, function () {
|
|
431
|
+
execute(batch_1.Batch.getTargetInfo(base.targetInfo.url, batchRequest, base.targetInfo.requestDigest, base.targetInfo.requestHeader, base.targetInfo.endpoint.indexOf("_api/v2") >= 0), batchIdx_1++, function () {
|
|
432
432
|
// Resolve the request
|
|
433
433
|
resolve(null);
|
|
434
434
|
});
|
|
@@ -666,6 +666,7 @@ exports.Request = {
|
|
|
666
666
|
return new Promise(function (resolve, reject) {
|
|
667
667
|
// Method to validate the request
|
|
668
668
|
var request = function (xhr, resolve) {
|
|
669
|
+
var _a;
|
|
669
670
|
// Validate the response
|
|
670
671
|
if (xhr && xhr.status < 400 && typeof (xhr.response) === "string" && xhr.response.length > 0) {
|
|
671
672
|
// Try to convert the response and ensure the data property exists
|
|
@@ -674,7 +675,7 @@ exports.Request = {
|
|
|
674
675
|
data = JSON.parse(xhr.response);
|
|
675
676
|
}
|
|
676
677
|
// Reject the request
|
|
677
|
-
catch (
|
|
678
|
+
catch (_b) {
|
|
678
679
|
reject();
|
|
679
680
|
return;
|
|
680
681
|
}
|
|
@@ -683,7 +684,7 @@ exports.Request = {
|
|
|
683
684
|
// See if the callback for odata query exists
|
|
684
685
|
if (base.targetInfo.callbackQuery) {
|
|
685
686
|
// Call the method
|
|
686
|
-
base.targetInfo.callbackQuery(data.d.results);
|
|
687
|
+
base.targetInfo.callbackQuery(((_a = data.d) === null || _a === void 0 ? void 0 : _a.results) || data.value);
|
|
687
688
|
}
|
|
688
689
|
// See if there are more items to get
|
|
689
690
|
if (base.nextFl) {
|
|
@@ -696,7 +697,7 @@ exports.Request = {
|
|
|
696
697
|
targetInfo.url = data["@odata.nextLink"] || data.d.__next;
|
|
697
698
|
// Create a new object
|
|
698
699
|
new xhrRequest_1.XHRRequest(true, new targetInfo_1.TargetInfo(targetInfo), function (xhr) {
|
|
699
|
-
var _a, _b
|
|
700
|
+
var _a, _b;
|
|
700
701
|
// Convert the response and see if values were returned
|
|
701
702
|
var data = JSON.parse(xhr.response);
|
|
702
703
|
if (data.d || data.value) {
|
|
@@ -709,7 +710,7 @@ exports.Request = {
|
|
|
709
710
|
}
|
|
710
711
|
// Append the raw data results
|
|
711
712
|
if ((_b = base["d"]) === null || _b === void 0 ? void 0 : _b.results) {
|
|
712
|
-
base["d"].results = base["d"].results.concat(
|
|
713
|
+
base["d"].results = base["d"].results.concat(data.d.results);
|
|
713
714
|
}
|
|
714
715
|
else {
|
|
715
716
|
base["value"] = base["value"].concat(data.value);
|