@varlet/axle 0.9.2 → 0.9.4
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.d.cts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -4
- package/lib/use.d.cts +1 -1
- package/lib/use.d.ts +1 -1
- package/package.json +1 -1
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
|
@@ -146,7 +146,7 @@ function createMatcher(include, exclude) {
|
|
|
146
146
|
|
|
147
147
|
// src/helper.ts
|
|
148
148
|
import { inBrowser } from "rattail";
|
|
149
|
-
import { isAxiosError } from "axios";
|
|
149
|
+
import { isAxiosError as isAxiosError2 } from "axios";
|
|
150
150
|
function withResponse(promise) {
|
|
151
151
|
return new Promise((resolve, reject) => {
|
|
152
152
|
promise.then((response) => {
|
|
@@ -155,7 +155,7 @@ function withResponse(promise) {
|
|
|
155
155
|
errorResponse: void 0
|
|
156
156
|
});
|
|
157
157
|
}).catch((error) => {
|
|
158
|
-
if (
|
|
158
|
+
if (isAxiosError2(error)) {
|
|
159
159
|
resolve({
|
|
160
160
|
response: void 0,
|
|
161
161
|
errorResponse: error.response
|
|
@@ -203,7 +203,7 @@ function requestHeadersInterceptor(options = {}) {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
// src/interceptors/requestMockInterceptor.ts
|
|
206
|
-
import { AxiosError } from "axios";
|
|
206
|
+
import { AxiosError as AxiosError2 } from "axios";
|
|
207
207
|
import { minimatch as minimatch2 } from "minimatch";
|
|
208
208
|
function settle(response, resolve, reject, delay = 0) {
|
|
209
209
|
if (delay > 0) {
|
|
@@ -215,7 +215,7 @@ function settle(response, resolve, reject, delay = 0) {
|
|
|
215
215
|
if (!response.config.validateStatus || response.config.validateStatus(response.status)) {
|
|
216
216
|
resolve(response);
|
|
217
217
|
} else {
|
|
218
|
-
reject(new
|
|
218
|
+
reject(new AxiosError2(`Request failed with status code ${response.status}`, void 0, response.config, response));
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
function requestMockInterceptor(options = {}) {
|
package/lib/use.d.cts
CHANGED
|
@@ -34,7 +34,7 @@ interface UseAxleOptions<V = any, R = any, P = Record<string, any>> {
|
|
|
34
34
|
config?: AxleRequestConfig | (() => AxleRequestConfig);
|
|
35
35
|
onBefore?(refs: UseAxleRefs<V>): void;
|
|
36
36
|
onAfter?(refs: UseAxleRefs<V>): void;
|
|
37
|
-
onTransform?(response: R, refs: UseAxleRefs<V>): V
|
|
37
|
+
onTransform?(response: R, refs: UseAxleRefs<V>): V | Promise<V>;
|
|
38
38
|
onSuccess?(response: R, refs: UseAxleRefs<V>): void;
|
|
39
39
|
onError?(error: Error, refs: UseAxleRefs<V>): void;
|
|
40
40
|
}
|
package/lib/use.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ interface UseAxleOptions<V = any, R = any, P = Record<string, any>> {
|
|
|
34
34
|
config?: AxleRequestConfig | (() => AxleRequestConfig);
|
|
35
35
|
onBefore?(refs: UseAxleRefs<V>): void;
|
|
36
36
|
onAfter?(refs: UseAxleRefs<V>): void;
|
|
37
|
-
onTransform?(response: R, refs: UseAxleRefs<V>): V
|
|
37
|
+
onTransform?(response: R, refs: UseAxleRefs<V>): V | Promise<V>;
|
|
38
38
|
onSuccess?(response: R, refs: UseAxleRefs<V>): void;
|
|
39
39
|
onError?(error: Error, refs: UseAxleRefs<V>): void;
|
|
40
40
|
}
|