@sebspark/retry 0.1.1 → 0.1.2
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/dist/index.js +5 -6
- package/dist/index.mjs +2 -3
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -18,13 +18,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
interval: () => interval,
|
|
24
24
|
retry: () => retry,
|
|
25
25
|
retryCondition: () => retryCondition
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
29
|
// src/retry.ts
|
|
30
30
|
var defaultSettings = {
|
|
@@ -106,14 +106,13 @@ var serverErrorCodes = [
|
|
|
106
106
|
var retryCondition = {
|
|
107
107
|
always: (_error) => true,
|
|
108
108
|
httpErrors: (...codes) => (error) => {
|
|
109
|
-
var _a, _b;
|
|
110
109
|
const captureCodes = codes.flatMap((code) => {
|
|
111
110
|
if (typeof code === "number") return code;
|
|
112
111
|
if (code === "client") return clientErrorCodes;
|
|
113
112
|
if (code === "server") return serverErrorCodes;
|
|
114
|
-
return;
|
|
113
|
+
return 500;
|
|
115
114
|
}).filter((code) => !!code);
|
|
116
|
-
const status = error.status || error.statusCode ||
|
|
115
|
+
const status = error.status || error.statusCode || error.response?.status || error.response?.statusCode || 0;
|
|
117
116
|
return captureCodes.includes(status);
|
|
118
117
|
},
|
|
119
118
|
serverErrors: (error) => retryCondition.httpErrors("server")(error),
|
package/dist/index.mjs
CHANGED
|
@@ -78,14 +78,13 @@ var serverErrorCodes = [
|
|
|
78
78
|
var retryCondition = {
|
|
79
79
|
always: (_error) => true,
|
|
80
80
|
httpErrors: (...codes) => (error) => {
|
|
81
|
-
var _a, _b;
|
|
82
81
|
const captureCodes = codes.flatMap((code) => {
|
|
83
82
|
if (typeof code === "number") return code;
|
|
84
83
|
if (code === "client") return clientErrorCodes;
|
|
85
84
|
if (code === "server") return serverErrorCodes;
|
|
86
|
-
return;
|
|
85
|
+
return 500;
|
|
87
86
|
}).filter((code) => !!code);
|
|
88
|
-
const status = error.status || error.statusCode ||
|
|
87
|
+
const status = error.status || error.statusCode || error.response?.status || error.response?.statusCode || 0;
|
|
89
88
|
return captureCodes.includes(status);
|
|
90
89
|
},
|
|
91
90
|
serverErrors: (error) => retryCondition.httpErrors("server")(error),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebspark/retry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"typecheck": "vitest --typecheck.only --passWithNoTests"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"tsconfig": "*"
|
|
19
|
+
"@sebspark/tsconfig": "*",
|
|
20
|
+
"axios": "1.12.2"
|
|
20
21
|
}
|
|
21
22
|
}
|