gd-sprest 9.7.7 → 9.7.8
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/request.js +8 -11
- package/build/utils/xhrRequest.js +13 -0
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +2 -2
package/build/rest.js
CHANGED
package/build/utils/request.js
CHANGED
|
@@ -698,18 +698,13 @@ export const Request = {
|
|
|
698
698
|
targetInfo.accessToken = base.targetInfo.accessToken || (base.xhr.isGraph ? Graph.Token : null);
|
|
699
699
|
targetInfo.endpoint = "";
|
|
700
700
|
targetInfo.url = data["@odata.nextLink"] || data.d.__next;
|
|
701
|
-
//
|
|
702
|
-
let rateLimitRemaining = parseInt(xhr.getResponseHeader("RateLimit-Remaining"));
|
|
703
|
-
let rateLimitReset = parseInt(xhr.getResponseHeader("RateLimit-Reset"));
|
|
701
|
+
// Set the sleep value to prevent throttling
|
|
704
702
|
let sleepInMS = 0;
|
|
705
|
-
if (
|
|
706
|
-
//
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
// Log
|
|
711
|
-
console.info("[gd-sprest] Throttle approaching from response. Waiting " + sleepInMS + "ms before sending the next request.");
|
|
712
|
-
}
|
|
703
|
+
if (xhr.rateLimit && xhr.rateLimit.remaining < 50) {
|
|
704
|
+
// Set the rate
|
|
705
|
+
sleepInMS = xhr.rateLimit.reset * 1000;
|
|
706
|
+
// Log
|
|
707
|
+
console.info("[gd-sprest] Throttle approaching... Waiting " + sleepInMS + "ms before sending the next request.", xhr.rateLimit);
|
|
713
708
|
}
|
|
714
709
|
// Wait before we execute the call
|
|
715
710
|
setTimeout(() => {
|
|
@@ -726,6 +721,8 @@ export const Request = {
|
|
|
726
721
|
// Update the expanded properties
|
|
727
722
|
Helper.updateExpandedProperties(base);
|
|
728
723
|
}
|
|
724
|
+
// Set the rate limit information
|
|
725
|
+
base.rateLimit = xhr.rateLimit;
|
|
729
726
|
// Append the raw data results
|
|
730
727
|
if ((_b = base["d"]) === null || _b === void 0 ? void 0 : _b.results) {
|
|
731
728
|
base["d"].results = base["d"].results.concat(data.d.results);
|
|
@@ -41,6 +41,19 @@ export class XHRRequest {
|
|
|
41
41
|
get request() { return this.xhr ? this.xhr : null; }
|
|
42
42
|
// The data send in the body of the request
|
|
43
43
|
get requestData() { return this.targetInfo.requestData; }
|
|
44
|
+
// Return the rate limit information
|
|
45
|
+
get rateLimit() {
|
|
46
|
+
// Ensure the rate limit information exists
|
|
47
|
+
if (this.xhr == null || this.getResponseHeader("RateLimit-Limit") == null) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
// Return the rate limit information
|
|
51
|
+
return {
|
|
52
|
+
limit: this.getResponseHeader("RateLimit-Limit"),
|
|
53
|
+
remaining: parseInt(this.getResponseHeader("RateLimit-Remaining")),
|
|
54
|
+
reset: parseInt(this.getResponseHeader("RateLimit-Reset"))
|
|
55
|
+
};
|
|
56
|
+
}
|
|
44
57
|
// The request headers
|
|
45
58
|
get requestHeaders() { return this.headers; }
|
|
46
59
|
// The request information
|