@indra211/exios 1.0.0 → 2.0.1
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/README.md +58 -14
- package/dist/index.cjs +939 -395
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +74 -8
- package/dist/index.js +940 -395
- package/dist/index.node.cjs +2545 -0
- package/dist/index.node.js +2515 -0
- package/package.json +62 -4
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,12 @@ import type * as Pkg from './index.js' with { 'resolution-mode': 'import' };
|
|
|
2
2
|
|
|
3
3
|
declare const exios: Pkg.ExiosDefault & { default: Pkg.ExiosDefault };
|
|
4
4
|
declare namespace exios {
|
|
5
|
+
type AdapterConfig = Pkg.AdapterConfig;
|
|
6
|
+
type AdapterFn = Pkg.AdapterFn;
|
|
7
|
+
type AdapterName = Pkg.AdapterName;
|
|
8
|
+
type CancelToken = Pkg.CancelToken;
|
|
9
|
+
type CancelTokenSource = Pkg.CancelTokenSource;
|
|
10
|
+
type Canceler = Pkg.Canceler;
|
|
5
11
|
type BreakerConfig = Pkg.BreakerConfig;
|
|
6
12
|
type BreakerState = Pkg.BreakerState;
|
|
7
13
|
type CanceledError<T = any, D = any> = Pkg.CanceledError<T, D>;
|
|
@@ -22,6 +28,7 @@ declare namespace exios {
|
|
|
22
28
|
type Method = Pkg.Method;
|
|
23
29
|
type Outcome = Pkg.Outcome;
|
|
24
30
|
type ProgressEvent = Pkg.ProgressEvent;
|
|
31
|
+
type ProxyConfig = Pkg.ProxyConfig;
|
|
25
32
|
type RawHeaders = Pkg.RawHeaders;
|
|
26
33
|
type RequestBreakerOverride = Pkg.RequestBreakerOverride;
|
|
27
34
|
type ResponseType = Pkg.ResponseType;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,21 +7,23 @@ declare class ExiosError<T = any, D = any> extends Error {
|
|
|
7
7
|
static readonly ERR_CANCELED = "ERR_CANCELED";
|
|
8
8
|
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
|
9
9
|
static readonly ERR_CIRCUIT_OPEN = "ERR_CIRCUIT_OPEN";
|
|
10
|
+
static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
|
|
11
|
+
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
|
10
12
|
code?: string;
|
|
11
13
|
config?: InternalConfig<D>;
|
|
12
|
-
request?:
|
|
14
|
+
request?: any;
|
|
13
15
|
response?: ExiosResponse<T, D>;
|
|
14
16
|
status?: number;
|
|
15
17
|
readonly isExiosError: true;
|
|
16
18
|
meta: {
|
|
17
19
|
attempts: number;
|
|
18
20
|
};
|
|
19
|
-
constructor(message: string, code?: string, config?: InternalConfig<D>, request?:
|
|
21
|
+
constructor(message: string, code?: string, config?: InternalConfig<D>, request?: any, response?: ExiosResponse<T, D>);
|
|
20
22
|
toJSON(): Record<string, unknown>;
|
|
21
|
-
static from<T = any, D = any>(err: unknown, code: string | undefined, config?: InternalConfig<D>, request?:
|
|
23
|
+
static from<T = any, D = any>(err: unknown, code: string | undefined, config?: InternalConfig<D>, request?: any, response?: ExiosResponse<T, D>): ExiosError<T, D>;
|
|
22
24
|
}
|
|
23
25
|
declare class CanceledError<T = any, D = any> extends ExiosError<T, D> {
|
|
24
|
-
constructor(message?: string, config?: InternalConfig<D>, request?:
|
|
26
|
+
constructor(message?: string, config?: InternalConfig<D>, request?: any);
|
|
25
27
|
}
|
|
26
28
|
declare class CircuitOpenError extends ExiosError {
|
|
27
29
|
origin: string;
|
|
@@ -32,6 +34,31 @@ declare function isExiosError(v: unknown): v is ExiosError;
|
|
|
32
34
|
/** Also true for a canceled error from another copy of the package (dual-package hazard). */
|
|
33
35
|
declare function isCancel(v: unknown): v is CanceledError;
|
|
34
36
|
|
|
37
|
+
type Canceler = (message?: string, config?: InternalConfig, request?: any) => void;
|
|
38
|
+
interface CancelTokenSource {
|
|
39
|
+
token: CancelToken;
|
|
40
|
+
cancel: Canceler;
|
|
41
|
+
}
|
|
42
|
+
type Listener = (reason: CanceledError) => void;
|
|
43
|
+
/**
|
|
44
|
+
* axios-compatible cancel token, built on AbortSignal.
|
|
45
|
+
* @deprecated Use `signal` with an AbortController (same as axios).
|
|
46
|
+
*/
|
|
47
|
+
declare class CancelToken {
|
|
48
|
+
reason?: CanceledError;
|
|
49
|
+
readonly promise: Promise<CanceledError>;
|
|
50
|
+
private listeners;
|
|
51
|
+
constructor(executor: (cancel: Canceler) => void);
|
|
52
|
+
throwIfRequested(): void;
|
|
53
|
+
subscribe(listener: Listener): void;
|
|
54
|
+
unsubscribe(listener: Listener): void;
|
|
55
|
+
/** An AbortSignal that aborts with the reason; call `signal.unsubscribe()` when done with it. */
|
|
56
|
+
toAbortSignal(): AbortSignal & {
|
|
57
|
+
unsubscribe(): void;
|
|
58
|
+
};
|
|
59
|
+
static source(): CancelTokenSource;
|
|
60
|
+
}
|
|
61
|
+
|
|
35
62
|
type Method = "get" | "post" | "put" | "patch" | "delete" | "head" | "options" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
36
63
|
type ResponseType = "json" | "text" | "blob" | "arraybuffer" | "formData" | "stream";
|
|
37
64
|
type HeaderValue = string | number | boolean | null | undefined;
|
|
@@ -40,6 +67,18 @@ type RawHeaders = Record<string, HeaderValue> | Headers;
|
|
|
40
67
|
type HeadersDefaults = {
|
|
41
68
|
common: Record<string, HeaderValue>;
|
|
42
69
|
} & Record<Lowercase<Method>, Record<string, HeaderValue>>;
|
|
70
|
+
type AdapterName = "xhr" | "http" | "fetch";
|
|
71
|
+
type AdapterFn = (config: InternalConfig) => Promise<ExiosResponse>;
|
|
72
|
+
type AdapterConfig = AdapterName | AdapterFn | Array<AdapterName | AdapterFn>;
|
|
73
|
+
interface ProxyConfig {
|
|
74
|
+
protocol?: string;
|
|
75
|
+
host: string;
|
|
76
|
+
port: number;
|
|
77
|
+
auth?: {
|
|
78
|
+
username: string;
|
|
79
|
+
password: string;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
43
82
|
interface Outcome {
|
|
44
83
|
error?: ExiosError;
|
|
45
84
|
response?: ExiosResponse;
|
|
@@ -85,7 +124,8 @@ interface ProgressEvent {
|
|
|
85
124
|
bytes: number;
|
|
86
125
|
rate?: number;
|
|
87
126
|
estimated?: number;
|
|
88
|
-
|
|
127
|
+
upload?: true;
|
|
128
|
+
download?: true;
|
|
89
129
|
event?: undefined;
|
|
90
130
|
}
|
|
91
131
|
type Transformer = (this: InternalConfig, data: any, headers: Record<string, string>, status?: number) => any;
|
|
@@ -122,6 +162,30 @@ interface ExiosRequestConfig<D = any> {
|
|
|
122
162
|
silentJSONParsing?: boolean;
|
|
123
163
|
clarifyTimeoutError?: boolean;
|
|
124
164
|
};
|
|
165
|
+
adapter?: AdapterConfig;
|
|
166
|
+
onUploadProgress?: (e: ProgressEvent) => void;
|
|
167
|
+
xsrfCookieName?: string;
|
|
168
|
+
xsrfHeaderName?: string;
|
|
169
|
+
withXSRFToken?: boolean | ((config: InternalConfig) => boolean | undefined);
|
|
170
|
+
/** @deprecated Use `signal` (AbortController), as in axios. */
|
|
171
|
+
cancelToken?: CancelToken;
|
|
172
|
+
/** Node http adapter: proxy server, or `false` to ignore HTTP(S)_PROXY env vars. */
|
|
173
|
+
proxy?: ProxyConfig | false;
|
|
174
|
+
/** Node http adapter: `http.Agent` used for http: URLs. */
|
|
175
|
+
httpAgent?: unknown;
|
|
176
|
+
/** Node http adapter: `https.Agent` used for https: URLs. */
|
|
177
|
+
httpsAgent?: unknown;
|
|
178
|
+
/** Node http adapter: redirects to follow (default 21; 0 = return the 3xx). */
|
|
179
|
+
maxRedirects?: number;
|
|
180
|
+
beforeRedirect?: (options: Record<string, any>, responseDetails: {
|
|
181
|
+
headers: Record<string, string | string[]>;
|
|
182
|
+
statusCode: number;
|
|
183
|
+
}) => void;
|
|
184
|
+
/** Node http adapter: unix socket path. */
|
|
185
|
+
socketPath?: string | null;
|
|
186
|
+
/** Node http adapter: decode gzip/deflate/br responses (default true). */
|
|
187
|
+
decompress?: boolean;
|
|
188
|
+
insecureHTTPParser?: boolean;
|
|
125
189
|
fetch?: typeof fetch;
|
|
126
190
|
fetchOptions?: Omit<RequestInit, "body" | "headers" | "method" | "signal">;
|
|
127
191
|
redirect?: RequestRedirect;
|
|
@@ -149,7 +213,8 @@ interface ExiosResponse<T = any, D = any> {
|
|
|
149
213
|
statusText: string;
|
|
150
214
|
headers: Record<string, string | string[]>;
|
|
151
215
|
config: InternalConfig<D>;
|
|
152
|
-
|
|
216
|
+
/** XMLHttpRequest (xhr), ClientRequest (http) or Request (fetch). */
|
|
217
|
+
request: any;
|
|
153
218
|
meta: {
|
|
154
219
|
attempts: number;
|
|
155
220
|
};
|
|
@@ -217,6 +282,7 @@ declare function mergeConfig(a: ExiosRequestConfig, b?: ExiosRequestConfig): Exi
|
|
|
217
282
|
declare function toFormData(obj: object, fd?: FormData): FormData;
|
|
218
283
|
|
|
219
284
|
declare const statics: {
|
|
285
|
+
CancelToken: typeof CancelToken;
|
|
220
286
|
ExiosError: typeof ExiosError;
|
|
221
287
|
CanceledError: typeof CanceledError;
|
|
222
288
|
CircuitOpenError: typeof CircuitOpenError;
|
|
@@ -229,5 +295,5 @@ type ExiosDefault = ExiosStatic & typeof statics;
|
|
|
229
295
|
declare const exios: ExiosDefault;
|
|
230
296
|
declare const create: (config?: ExiosRequestConfig) => ExiosStatic;
|
|
231
297
|
|
|
232
|
-
export { CanceledError, CircuitOpenError, ExiosError, InterceptorManager, create, exios as default, isCancel, isExiosError, mergeConfig, toFormData };
|
|
233
|
-
export type { BreakerConfig, BreakerState, ExiosDefault, ExiosDefaults, ExiosInstance, ExiosRequestConfig, ExiosResponse, ExiosStatic, HeaderValue, HeadersDefaults, InterceptorHandler, InterceptorOptions, InternalConfig, Method, Outcome, ProgressEvent, RawHeaders, RequestBreakerOverride, ResponseType, RetryConfig, Transformer };
|
|
298
|
+
export { CancelToken, CanceledError, CircuitOpenError, ExiosError, InterceptorManager, create, exios as default, isCancel, isExiosError, mergeConfig, toFormData };
|
|
299
|
+
export type { AdapterConfig, AdapterFn, AdapterName, BreakerConfig, BreakerState, CancelTokenSource, Canceler, ExiosDefault, ExiosDefaults, ExiosInstance, ExiosRequestConfig, ExiosResponse, ExiosStatic, HeaderValue, HeadersDefaults, InterceptorHandler, InterceptorOptions, InternalConfig, Method, Outcome, ProgressEvent, ProxyConfig, RawHeaders, RequestBreakerOverride, ResponseType, RetryConfig, Transformer };
|