gd-sprest 8.7.9 → 8.8.1
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/batch.d.ts +11 -0
- package/build/rest.js +1 -1
- package/build/utils/batch.js +41 -8
- package/build/utils/request.js +1 -1
- package/build/v2/sites.js +1 -1
- package/dist/gd-sprest.d.ts +17 -6
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +1 -1
package/@types/utils/batch.d.ts
CHANGED
|
@@ -9,4 +9,15 @@ export interface IBatchRequest {
|
|
|
9
9
|
changesetId?: string;
|
|
10
10
|
response?: IBase;
|
|
11
11
|
targetInfo: ITargetInfo;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* V2 Batch Request
|
|
16
|
+
*/
|
|
17
|
+
export interface IBatchRequestV2 {
|
|
18
|
+
body?: object | string;
|
|
19
|
+
headers?: { [key: string]: string };
|
|
20
|
+
id: string;
|
|
21
|
+
method: string;
|
|
22
|
+
url: string;
|
|
12
23
|
}
|
package/build/rest.js
CHANGED
package/build/utils/batch.js
CHANGED
|
@@ -64,22 +64,30 @@ 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) {
|
|
67
|
+
Batch.getTargetInfo = function (url, requests, requestDigest, isV2) {
|
|
68
|
+
if (isV2 === void 0) { isV2 = false; }
|
|
68
69
|
var batchId = "batch_" + lib_1.ContextInfo.generateGUID();
|
|
69
70
|
var batchRequests = [];
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
// See if this is v2
|
|
72
|
+
if (isV2) {
|
|
73
|
+
// Create the batch requests
|
|
74
|
+
batchRequests = Batch.createBatchV2(requests);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// Create the batch requests
|
|
78
|
+
batchRequests.push(Batch.createBatch(batchId, requests));
|
|
79
|
+
// End the batch request
|
|
80
|
+
batchRequests.push("--" + batchId + "--");
|
|
81
|
+
}
|
|
74
82
|
// Return the target information
|
|
75
83
|
return new _1.TargetInfo({
|
|
76
84
|
url: url,
|
|
77
|
-
endpoint: "$batch",
|
|
85
|
+
endpoint: (isV2 ? "_api/v2.0/" : "") + "$batch",
|
|
78
86
|
method: "POST",
|
|
79
|
-
data: batchRequests.join("\r\n"),
|
|
87
|
+
data: isV2 ? { requests: batchRequests } : batchRequests.join("\r\n"),
|
|
80
88
|
requestDigest: requestDigest,
|
|
81
89
|
requestHeader: {
|
|
82
|
-
"Content-Type": 'multipart/mixed; boundary="' + batchId + '"'
|
|
90
|
+
"Content-Type": isV2 ? "application/json" : 'multipart/mixed; boundary="' + batchId + '"'
|
|
83
91
|
}
|
|
84
92
|
});
|
|
85
93
|
};
|
|
@@ -136,6 +144,31 @@ var Batch = /** @class */ (function () {
|
|
|
136
144
|
// Return the batch request
|
|
137
145
|
return request.join("\r\n");
|
|
138
146
|
};
|
|
147
|
+
// Method to generate a batch request
|
|
148
|
+
Batch.createBatchV2 = function (requests) {
|
|
149
|
+
var batch = [];
|
|
150
|
+
// Parse the requests
|
|
151
|
+
for (var i = 0; i < requests.length; i++) {
|
|
152
|
+
var request = requests[i];
|
|
153
|
+
// Create the batch request
|
|
154
|
+
var batchRequest = {
|
|
155
|
+
id: (i + 1).toString(),
|
|
156
|
+
method: request.targetInfo.requestMethod,
|
|
157
|
+
url: request.targetInfo.requestUrl
|
|
158
|
+
};
|
|
159
|
+
// See if a body is set
|
|
160
|
+
if (request.targetInfo.requestData) {
|
|
161
|
+
batchRequest.body = request.targetInfo.requestData;
|
|
162
|
+
batchRequest.headers = {
|
|
163
|
+
"Content-Type": "application/json"
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
// Add the batch request
|
|
167
|
+
batch.push(batchRequest);
|
|
168
|
+
}
|
|
169
|
+
// Return the batch requests
|
|
170
|
+
return batch;
|
|
171
|
+
};
|
|
139
172
|
// Process the batch request callbacks
|
|
140
173
|
Batch.processCallbacks = function (batchRequests) {
|
|
141
174
|
if (batchRequests === void 0) { batchRequests = []; }
|
package/build/utils/request.js
CHANGED
|
@@ -429,7 +429,7 @@ exports.Request = {
|
|
|
429
429
|
// Return a promise
|
|
430
430
|
return new Promise(function (resolve) {
|
|
431
431
|
// Execute the request
|
|
432
|
-
execute(batch_1.Batch.getTargetInfo(base.targetInfo.url, batchRequest, base.targetInfo.requestDigest), batchIdx_1++, function () {
|
|
432
|
+
execute(batch_1.Batch.getTargetInfo(base.targetInfo.url, batchRequest, base.targetInfo.requestDigest, base.targetInfo.endpoint.indexOf("_api/v2") >= 0), batchIdx_1++, function () {
|
|
433
433
|
// Resolve the request
|
|
434
434
|
resolve(null);
|
|
435
435
|
});
|
package/build/v2/sites.js
CHANGED
|
@@ -186,7 +186,7 @@ exports.sites.getList = function (props) {
|
|
|
186
186
|
// Find the list
|
|
187
187
|
findList(info.siteId, info.webId, props.listName).then(function (listId) {
|
|
188
188
|
// Resolve the request
|
|
189
|
-
resolve((0, exports.sites)({ siteId: info.siteId }).lists(listId));
|
|
189
|
+
resolve((0, exports.sites)({ siteId: info.siteId, webId: info.webId }).lists(listId));
|
|
190
190
|
}, reject);
|
|
191
191
|
}
|
|
192
192
|
}, reject);
|
package/dist/gd-sprest.d.ts
CHANGED
|
@@ -7174,13 +7174,24 @@ declare module 'gd-sprest/utils/batch' {
|
|
|
7174
7174
|
import { ITargetInfo } from "gd-sprest/utils/targetInfo";
|
|
7175
7175
|
|
|
7176
7176
|
/**
|
|
7177
|
-
|
|
7178
|
-
|
|
7177
|
+
* Batch Request
|
|
7178
|
+
*/
|
|
7179
7179
|
export interface IBatchRequest {
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7180
|
+
callback?: any;
|
|
7181
|
+
changesetId?: string;
|
|
7182
|
+
response?: IBase;
|
|
7183
|
+
targetInfo: ITargetInfo;
|
|
7184
|
+
}
|
|
7185
|
+
|
|
7186
|
+
/**
|
|
7187
|
+
* V2 Batch Request
|
|
7188
|
+
*/
|
|
7189
|
+
export interface IBatchRequestV2 {
|
|
7190
|
+
body?: object | string;
|
|
7191
|
+
headers?: { [key: string]: string };
|
|
7192
|
+
id: string;
|
|
7193
|
+
method: string;
|
|
7194
|
+
url: string;
|
|
7184
7195
|
}
|
|
7185
7196
|
}
|
|
7186
7197
|
|