@contentstack/marketplace-sdk 1.3.0 → 1.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.4.0](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.3.0) (2024-08-25)
4
+ - Enhancement: Retry logic to make use of x-ratelimit-remaining header
5
+
3
6
  ## [v1.3.0](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.3.0) (2024-08-11)
4
7
  - Enh: Add search function to query apps by names
5
8
 
@@ -9,6 +12,7 @@
9
12
  - Added Pre-commit hook to run the snyk and talismand scans
10
13
 
11
14
  ## [v1.2.8](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.2.8) (2024-05-26)
15
+
12
16
  - Fix: Added params support to getInstalledApps method for enhanced flexibility
13
17
 
14
18
  ## [v1.2.7](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.2.7) (2024-05-15)
@@ -213,18 +213,31 @@ export function ConcurrencyQueue(_ref) {
213
213
  } else {
214
214
  return Promise.reject(responseHandler(error));
215
215
  }
216
- } else if (response.status === 429 || response.status === 401 && _this.config.refreshToken) {
217
- retryErrorType = "Error with status: ".concat(response.status);
218
- networkError++;
219
- if (networkError > _this.config.retryLimit) {
220
- return Promise.reject(responseHandler(error));
216
+ } else {
217
+ var rateLimitRemaining = response.headers['x-ratelimit-remaining'];
218
+ if (rateLimitRemaining !== undefined && parseInt(rateLimitRemaining) <= 0) {
219
+ // return Promise.reject(responseHandler(error))
220
+
221
+ _this.running.shift();
222
+ return _delay(wait).then(function () {
223
+ error.config.retryCount = networkError++;
224
+ // deepcode ignore Ssrf: URL is dynamic
225
+ return axios(updateRequestConfig(error, 'Rate Limit Hit', wait));
226
+ });
227
+ }
228
+ if (response.status === 429 || response.status === 401 && _this.config.refreshToken) {
229
+ retryErrorType = "Error with status: ".concat(response.status);
230
+ networkError++;
231
+ if (networkError > _this.config.retryLimit) {
232
+ return Promise.reject(responseHandler(error));
233
+ }
234
+ _this.running.shift();
235
+ // Cool down the running requests
236
+ _delay(wait, response.status === 401);
237
+ error.config.retryCount = networkError;
238
+ // deepcode ignore Ssrf: URL is dynamic
239
+ return axios(updateRequestConfig(error, retryErrorType, wait));
221
240
  }
222
- _this.running.shift();
223
- // Cool down the running requests
224
- _delay(wait, response.status === 401);
225
- error.config.retryCount = networkError;
226
- // deepcode ignore Ssrf: URL is dynamic
227
- return axios(updateRequestConfig(error, retryErrorType, wait));
228
241
  }
229
242
  if (_this.config.retryCondition && _this.config.retryCondition(error)) {
230
243
  retryErrorType = error.response ? "Error with status: ".concat(response.status) : "Error Code:".concat(error.code);
@@ -223,18 +223,31 @@ function ConcurrencyQueue(_ref) {
223
223
  } else {
224
224
  return Promise.reject(responseHandler(error));
225
225
  }
226
- } else if (response.status === 429 || response.status === 401 && _this.config.refreshToken) {
227
- retryErrorType = "Error with status: ".concat(response.status);
228
- networkError++;
229
- if (networkError > _this.config.retryLimit) {
230
- return Promise.reject(responseHandler(error));
226
+ } else {
227
+ var rateLimitRemaining = response.headers['x-ratelimit-remaining'];
228
+ if (rateLimitRemaining !== undefined && parseInt(rateLimitRemaining) <= 0) {
229
+ // return Promise.reject(responseHandler(error))
230
+
231
+ _this.running.shift();
232
+ return _delay(wait).then(function () {
233
+ error.config.retryCount = networkError++;
234
+ // deepcode ignore Ssrf: URL is dynamic
235
+ return axios(updateRequestConfig(error, 'Rate Limit Hit', wait));
236
+ });
237
+ }
238
+ if (response.status === 429 || response.status === 401 && _this.config.refreshToken) {
239
+ retryErrorType = "Error with status: ".concat(response.status);
240
+ networkError++;
241
+ if (networkError > _this.config.retryLimit) {
242
+ return Promise.reject(responseHandler(error));
243
+ }
244
+ _this.running.shift();
245
+ // Cool down the running requests
246
+ _delay(wait, response.status === 401);
247
+ error.config.retryCount = networkError;
248
+ // deepcode ignore Ssrf: URL is dynamic
249
+ return axios(updateRequestConfig(error, retryErrorType, wait));
231
250
  }
232
- _this.running.shift();
233
- // Cool down the running requests
234
- _delay(wait, response.status === 401);
235
- error.config.retryCount = networkError;
236
- // deepcode ignore Ssrf: URL is dynamic
237
- return axios(updateRequestConfig(error, retryErrorType, wait));
238
251
  }
239
252
  if (_this.config.retryCondition && _this.config.retryCondition(error)) {
240
253
  retryErrorType = error.response ? "Error with status: ".concat(response.status) : "Error Code:".concat(error.code);