@devrev/ts-adaas 1.10.1-beta.7 → 1.11.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.
@@ -1 +1 @@
1
- {"version":3,"file":"axios-client-internal.d.ts","sourceRoot":"","sources":["../../src/http/axios-client-internal.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,WAAW,+BAEf,CAAC;AAsEH,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"axios-client-internal.d.ts","sourceRoot":"","sources":["../../src/http/axios-client-internal.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,WAAW,+BAEf,CAAC;AAmFH,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -28,11 +28,15 @@ exports.axiosClient = axiosClient;
28
28
  // This will retry requests after 2, 4, 8, 16 and 32 seconds
29
29
  const delay = axios_retry_1.default.exponentialDelay(retryCount, error, 1000);
30
30
  const delayInSeconds = Math.round(delay / 1000);
31
- console.warn(`Retrying ${(_h = error.config) === null || _h === void 0 ? void 0 : _h.method} request to ${(_j = error.config) === null || _j === void 0 ? void 0 : _j.url} in ${delayInSeconds}s due to ${(_k = error.response) === null || _k === void 0 ? void 0 : _k.status} error.`);
31
+ // Handle network errors (no response) vs HTTP errors
32
+ const errorDescription = ((_h = error.response) === null || _h === void 0 ? void 0 : _h.status)
33
+ ? `${error.response.status} error`
34
+ : 'network (no response) error';
35
+ console.warn(`Retrying ${(_j = error.config) === null || _j === void 0 ? void 0 : _j.method} request to ${(_k = error.config) === null || _k === void 0 ? void 0 : _k.url} in ${delayInSeconds}s due to ${errorDescription}.`);
32
36
  return delay;
33
37
  },
34
38
  retryCondition: (error) => {
35
- var _a, _b, _c, _d, _e, _f;
39
+ var _a, _b, _c, _d, _e, _f, _g;
36
40
  const retryAfter = ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b['retry-after']) ||
37
41
  ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.headers) === null || _d === void 0 ? void 0 : _d['Retry-After']);
38
42
  // 5xx errors
@@ -47,6 +51,11 @@ exports.axiosClient = axiosClient;
47
51
  Number(retryAfter) >= 0) {
48
52
  return true;
49
53
  }
54
+ // Network errors for idempotent requests if not 429, because 429 is handled above
55
+ else if (axios_retry_1.default.isNetworkOrIdempotentRequestError(error) &&
56
+ ((_g = error.response) === null || _g === void 0 ? void 0 : _g.status) !== 429) {
57
+ return true;
58
+ }
50
59
  // all other errors
51
60
  else {
52
61
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrev/ts-adaas",
3
- "version": "1.10.1-beta.7",
3
+ "version": "1.11.0",
4
4
  "description": "Typescript library containing the ADaaS(AirDrop as a Service) control protocol.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",