@varlet/axle 0.9.3 → 0.9.5
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/lib/index.cjs +12 -7
- package/lib/index.d.cts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +7 -4
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -47,11 +47,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
47
47
|
// src/index.ts
|
|
48
48
|
var src_exports = {};
|
|
49
49
|
__export(src_exports, {
|
|
50
|
+
AxiosError: () => import_axios2.AxiosError,
|
|
50
51
|
createAxle: () => createAxle,
|
|
51
52
|
createFetchRunner: () => createFetchRunner,
|
|
52
53
|
createMatcher: () => createMatcher,
|
|
53
54
|
createModifyRunner: () => createModifyRunner,
|
|
54
55
|
download: () => download,
|
|
56
|
+
isAxiosError: () => import_axios2.isAxiosError,
|
|
55
57
|
matchPattern: () => matchPattern,
|
|
56
58
|
requestHeadersInterceptor: () => requestHeadersInterceptor,
|
|
57
59
|
requestMd5Interceptor: () => requestMd5Interceptor,
|
|
@@ -86,6 +88,7 @@ function objectToFormData(object) {
|
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
// src/instance.ts
|
|
91
|
+
var import_axios2 = require("axios");
|
|
89
92
|
function createFetchRunner(service, method, responseType) {
|
|
90
93
|
return function(url, params, config) {
|
|
91
94
|
return service[method](url, __spreadValues({
|
|
@@ -207,7 +210,7 @@ function createMatcher(include, exclude) {
|
|
|
207
210
|
|
|
208
211
|
// src/helper.ts
|
|
209
212
|
var import_rattail = require("rattail");
|
|
210
|
-
var
|
|
213
|
+
var import_axios3 = require("axios");
|
|
211
214
|
function withResponse(promise) {
|
|
212
215
|
return new Promise((resolve, reject) => {
|
|
213
216
|
promise.then((response) => {
|
|
@@ -216,7 +219,7 @@ function withResponse(promise) {
|
|
|
216
219
|
errorResponse: void 0
|
|
217
220
|
});
|
|
218
221
|
}).catch((error) => {
|
|
219
|
-
if ((0,
|
|
222
|
+
if ((0, import_axios3.isAxiosError)(error)) {
|
|
220
223
|
resolve({
|
|
221
224
|
response: void 0,
|
|
222
225
|
errorResponse: error.response
|
|
@@ -264,7 +267,7 @@ function requestHeadersInterceptor(options = {}) {
|
|
|
264
267
|
}
|
|
265
268
|
|
|
266
269
|
// src/interceptors/requestMockInterceptor.ts
|
|
267
|
-
var
|
|
270
|
+
var import_axios4 = require("axios");
|
|
268
271
|
var import_minimatch2 = require("minimatch");
|
|
269
272
|
function settle(response, resolve, reject, delay = 0) {
|
|
270
273
|
if (delay > 0) {
|
|
@@ -276,7 +279,7 @@ function settle(response, resolve, reject, delay = 0) {
|
|
|
276
279
|
if (!response.config.validateStatus || response.config.validateStatus(response.status)) {
|
|
277
280
|
resolve(response);
|
|
278
281
|
} else {
|
|
279
|
-
reject(new
|
|
282
|
+
reject(new import_axios4.AxiosError(`Request failed with status code ${response.status}`, void 0, response.config, response));
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
285
|
function requestMockInterceptor(options = {}) {
|
|
@@ -361,14 +364,14 @@ function responseTimeoutInterceptor(options = {}) {
|
|
|
361
364
|
}
|
|
362
365
|
|
|
363
366
|
// src/interceptors/responseRetryInterceptor.ts
|
|
364
|
-
var
|
|
367
|
+
var import_axios5 = __toESM(require("axios"), 1);
|
|
365
368
|
function responseRetryInterceptor(options) {
|
|
366
369
|
return {
|
|
367
370
|
onFulfilled: (response) => response,
|
|
368
371
|
async onRejected(error) {
|
|
369
372
|
var _a, _b, _c;
|
|
370
373
|
const matcher = createMatcher(options.include, options.exclude);
|
|
371
|
-
if (!matcher((_a = error.config.method) != null ? _a : "", (_b = error.config.url) != null ? _b : "", (_c = error == null ? void 0 : error.response) == null ? void 0 : _c.status) || (0,
|
|
374
|
+
if (!matcher((_a = error.config.method) != null ? _a : "", (_b = error.config.url) != null ? _b : "", (_c = error == null ? void 0 : error.response) == null ? void 0 : _c.status) || (0, import_axios5.isCancel)(error)) {
|
|
372
375
|
return Promise.reject(error);
|
|
373
376
|
}
|
|
374
377
|
const { count = 1 } = options;
|
|
@@ -376,7 +379,7 @@ function responseRetryInterceptor(options) {
|
|
|
376
379
|
async function retry() {
|
|
377
380
|
try {
|
|
378
381
|
retryCount++;
|
|
379
|
-
return await
|
|
382
|
+
return await import_axios5.default.create()(error.config);
|
|
380
383
|
} catch (error2) {
|
|
381
384
|
if (retryCount === count) {
|
|
382
385
|
return Promise.reject(error2);
|
|
@@ -487,11 +490,13 @@ function requestMd5Interceptor(options = {}) {
|
|
|
487
490
|
}
|
|
488
491
|
// Annotate the CommonJS export names for ESM import in node:
|
|
489
492
|
0 && (module.exports = {
|
|
493
|
+
AxiosError,
|
|
490
494
|
createAxle,
|
|
491
495
|
createFetchRunner,
|
|
492
496
|
createMatcher,
|
|
493
497
|
createModifyRunner,
|
|
494
498
|
download,
|
|
499
|
+
isAxiosError,
|
|
495
500
|
matchPattern,
|
|
496
501
|
requestHeadersInterceptor,
|
|
497
502
|
requestMd5Interceptor,
|
package/lib/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as RequestInterceptor, a as ResponseInterceptor } from './instance-6ab5bfe4.js';
|
|
2
2
|
export { e as AxleInstance, A as AxleRequestConfig, b as FetchMethod, F as FetchRunner, I as Interceptor, c as ModifyMethod, M as ModifyRunner, d as RunnerMethod, h as createAxle, f as createFetchRunner, g as createModifyRunner } from './instance-6ab5bfe4.js';
|
|
3
3
|
import { AxiosResponse, AxiosInterceptorOptions, AxiosRequestConfig } from 'axios';
|
|
4
|
-
export { AxiosError, AxiosInstance, AxiosInterceptorOptions, AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse, HeadersDefaults, InternalAxiosRequestConfig, ResponseType } from 'axios';
|
|
4
|
+
export { AxiosError, AxiosInstance, AxiosInterceptorOptions, AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse, HeadersDefaults, InternalAxiosRequestConfig, ResponseType, isAxiosError } from 'axios';
|
|
5
5
|
|
|
6
6
|
declare function matchPattern(pattern: string, method: string, url: string, status?: number | null | undefined): boolean;
|
|
7
7
|
declare function createMatcher(include?: string[], exclude?: string[]): (method: string, url: string, status?: number | null | undefined) => boolean;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as RequestInterceptor, a as ResponseInterceptor } from './instance-6ab5bfe4.js';
|
|
2
2
|
export { e as AxleInstance, A as AxleRequestConfig, b as FetchMethod, F as FetchRunner, I as Interceptor, c as ModifyMethod, M as ModifyRunner, d as RunnerMethod, h as createAxle, f as createFetchRunner, g as createModifyRunner } from './instance-6ab5bfe4.js';
|
|
3
3
|
import { AxiosResponse, AxiosInterceptorOptions, AxiosRequestConfig } from 'axios';
|
|
4
|
-
export { AxiosError, AxiosInstance, AxiosInterceptorOptions, AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse, HeadersDefaults, InternalAxiosRequestConfig, ResponseType } from 'axios';
|
|
4
|
+
export { AxiosError, AxiosInstance, AxiosInterceptorOptions, AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse, HeadersDefaults, InternalAxiosRequestConfig, ResponseType, isAxiosError } from 'axios';
|
|
5
5
|
|
|
6
6
|
declare function matchPattern(pattern: string, method: string, url: string, status?: number | null | undefined): boolean;
|
|
7
7
|
declare function createMatcher(include?: string[], exclude?: string[]): (method: string, url: string, status?: number | null | undefined) => boolean;
|
package/lib/index.js
CHANGED
|
@@ -25,6 +25,7 @@ function objectToFormData(object) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// src/instance.ts
|
|
28
|
+
import { AxiosError, isAxiosError } from "axios";
|
|
28
29
|
function createFetchRunner(service, method, responseType) {
|
|
29
30
|
return function(url, params, config) {
|
|
30
31
|
return service[method](url, __spreadValues({
|
|
@@ -146,7 +147,7 @@ function createMatcher(include, exclude) {
|
|
|
146
147
|
|
|
147
148
|
// src/helper.ts
|
|
148
149
|
import { inBrowser } from "rattail";
|
|
149
|
-
import { isAxiosError } from "axios";
|
|
150
|
+
import { isAxiosError as isAxiosError2 } from "axios";
|
|
150
151
|
function withResponse(promise) {
|
|
151
152
|
return new Promise((resolve, reject) => {
|
|
152
153
|
promise.then((response) => {
|
|
@@ -155,7 +156,7 @@ function withResponse(promise) {
|
|
|
155
156
|
errorResponse: void 0
|
|
156
157
|
});
|
|
157
158
|
}).catch((error) => {
|
|
158
|
-
if (
|
|
159
|
+
if (isAxiosError2(error)) {
|
|
159
160
|
resolve({
|
|
160
161
|
response: void 0,
|
|
161
162
|
errorResponse: error.response
|
|
@@ -203,7 +204,7 @@ function requestHeadersInterceptor(options = {}) {
|
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
// src/interceptors/requestMockInterceptor.ts
|
|
206
|
-
import { AxiosError } from "axios";
|
|
207
|
+
import { AxiosError as AxiosError2 } from "axios";
|
|
207
208
|
import { minimatch as minimatch2 } from "minimatch";
|
|
208
209
|
function settle(response, resolve, reject, delay = 0) {
|
|
209
210
|
if (delay > 0) {
|
|
@@ -215,7 +216,7 @@ function settle(response, resolve, reject, delay = 0) {
|
|
|
215
216
|
if (!response.config.validateStatus || response.config.validateStatus(response.status)) {
|
|
216
217
|
resolve(response);
|
|
217
218
|
} else {
|
|
218
|
-
reject(new
|
|
219
|
+
reject(new AxiosError2(`Request failed with status code ${response.status}`, void 0, response.config, response));
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
function requestMockInterceptor(options = {}) {
|
|
@@ -425,11 +426,13 @@ function requestMd5Interceptor(options = {}) {
|
|
|
425
426
|
};
|
|
426
427
|
}
|
|
427
428
|
export {
|
|
429
|
+
AxiosError,
|
|
428
430
|
createAxle,
|
|
429
431
|
createFetchRunner,
|
|
430
432
|
createMatcher,
|
|
431
433
|
createModifyRunner,
|
|
432
434
|
download,
|
|
435
|
+
isAxiosError,
|
|
433
436
|
matchPattern,
|
|
434
437
|
requestHeadersInterceptor,
|
|
435
438
|
requestMd5Interceptor,
|