axios 1.7.8 → 1.8.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.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +61 -0
- package/README.md +30 -14
- package/dist/axios.js +25 -11
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +2 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +23 -7
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +19 -7
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +2 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +19 -7
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +28 -33
- package/index.d.ts +568 -75
- package/lib/core/Axios.js +10 -1
- package/lib/core/buildFullPath.js +3 -2
- package/lib/env/data.js +1 -1
- package/lib/utils.js +5 -2
- package/package.json +3 -3
- package/SECURITY.md +0 -6
package/index.d.ts
CHANGED
@@ -1,76 +1,569 @@
|
|
1
1
|
// TypeScript Version: 4.7
|
2
|
-
export
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
2
|
+
export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
|
3
|
+
|
4
|
+
interface RawAxiosHeaders {
|
5
|
+
[key: string]: AxiosHeaderValue;
|
6
|
+
}
|
7
|
+
|
8
|
+
type MethodsHeaders = Partial<{
|
9
|
+
[Key in Method as Lowercase<Key>]: AxiosHeaders;
|
10
|
+
} & {common: AxiosHeaders}>;
|
11
|
+
|
12
|
+
type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean);
|
13
|
+
|
14
|
+
type AxiosHeaderParser = (this: AxiosHeaders, value: AxiosHeaderValue, header: string) => any;
|
15
|
+
|
16
|
+
export class AxiosHeaders {
|
17
|
+
constructor(
|
18
|
+
headers?: RawAxiosHeaders | AxiosHeaders | string
|
19
|
+
);
|
20
|
+
|
21
|
+
[key: string]: any;
|
22
|
+
|
23
|
+
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
24
|
+
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders;
|
25
|
+
|
26
|
+
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
27
|
+
get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue;
|
28
|
+
|
29
|
+
has(header: string, matcher?: AxiosHeaderMatcher): boolean;
|
30
|
+
|
31
|
+
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
|
32
|
+
|
33
|
+
clear(matcher?: AxiosHeaderMatcher): boolean;
|
34
|
+
|
35
|
+
normalize(format: boolean): AxiosHeaders;
|
36
|
+
|
37
|
+
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
38
|
+
|
39
|
+
toJSON(asStrings?: boolean): RawAxiosHeaders;
|
40
|
+
|
41
|
+
static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
|
42
|
+
|
43
|
+
static accessor(header: string | string[]): AxiosHeaders;
|
44
|
+
|
45
|
+
static concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
46
|
+
|
47
|
+
setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
48
|
+
getContentType(parser?: RegExp): RegExpExecArray | null;
|
49
|
+
getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
50
|
+
hasContentType(matcher?: AxiosHeaderMatcher): boolean;
|
51
|
+
|
52
|
+
setContentLength(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
53
|
+
getContentLength(parser?: RegExp): RegExpExecArray | null;
|
54
|
+
getContentLength(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
55
|
+
hasContentLength(matcher?: AxiosHeaderMatcher): boolean;
|
56
|
+
|
57
|
+
setAccept(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
58
|
+
getAccept(parser?: RegExp): RegExpExecArray | null;
|
59
|
+
getAccept(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
60
|
+
hasAccept(matcher?: AxiosHeaderMatcher): boolean;
|
61
|
+
|
62
|
+
setUserAgent(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
63
|
+
getUserAgent(parser?: RegExp): RegExpExecArray | null;
|
64
|
+
getUserAgent(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
65
|
+
hasUserAgent(matcher?: AxiosHeaderMatcher): boolean;
|
66
|
+
|
67
|
+
setContentEncoding(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
68
|
+
getContentEncoding(parser?: RegExp): RegExpExecArray | null;
|
69
|
+
getContentEncoding(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
70
|
+
hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean;
|
71
|
+
|
72
|
+
setAuthorization(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
73
|
+
getAuthorization(parser?: RegExp): RegExpExecArray | null;
|
74
|
+
getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
75
|
+
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
|
76
|
+
|
77
|
+
[Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>;
|
78
|
+
}
|
79
|
+
|
80
|
+
type CommonRequestHeadersList = 'Accept' | 'Content-Length' | 'User-Agent' | 'Content-Encoding' | 'Authorization';
|
81
|
+
|
82
|
+
type ContentType = AxiosHeaderValue | 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream';
|
83
|
+
|
84
|
+
export type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & {
|
85
|
+
[Key in CommonRequestHeadersList]: AxiosHeaderValue;
|
86
|
+
} & {
|
87
|
+
'Content-Type': ContentType
|
88
|
+
}>;
|
89
|
+
|
90
|
+
export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
|
91
|
+
|
92
|
+
type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' | 'Cache-Control'| 'Content-Encoding';
|
93
|
+
|
94
|
+
type RawCommonResponseHeaders = {
|
95
|
+
[Key in CommonResponseHeadersList]: AxiosHeaderValue;
|
96
|
+
} & {
|
97
|
+
"set-cookie": string[];
|
98
|
+
};
|
99
|
+
|
100
|
+
export type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>;
|
101
|
+
|
102
|
+
export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
|
103
|
+
|
104
|
+
export interface AxiosRequestTransformer {
|
105
|
+
(this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
|
106
|
+
}
|
107
|
+
|
108
|
+
export interface AxiosResponseTransformer {
|
109
|
+
(this: InternalAxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any;
|
110
|
+
}
|
111
|
+
|
112
|
+
export interface AxiosAdapter {
|
113
|
+
(config: InternalAxiosRequestConfig): AxiosPromise;
|
114
|
+
}
|
115
|
+
|
116
|
+
export interface AxiosBasicCredentials {
|
117
|
+
username: string;
|
118
|
+
password: string;
|
119
|
+
}
|
120
|
+
|
121
|
+
export interface AxiosProxyConfig {
|
122
|
+
host: string;
|
123
|
+
port: number;
|
124
|
+
auth?: AxiosBasicCredentials;
|
125
|
+
protocol?: string;
|
126
|
+
}
|
127
|
+
|
128
|
+
export enum HttpStatusCode {
|
129
|
+
Continue = 100,
|
130
|
+
SwitchingProtocols = 101,
|
131
|
+
Processing = 102,
|
132
|
+
EarlyHints = 103,
|
133
|
+
Ok = 200,
|
134
|
+
Created = 201,
|
135
|
+
Accepted = 202,
|
136
|
+
NonAuthoritativeInformation = 203,
|
137
|
+
NoContent = 204,
|
138
|
+
ResetContent = 205,
|
139
|
+
PartialContent = 206,
|
140
|
+
MultiStatus = 207,
|
141
|
+
AlreadyReported = 208,
|
142
|
+
ImUsed = 226,
|
143
|
+
MultipleChoices = 300,
|
144
|
+
MovedPermanently = 301,
|
145
|
+
Found = 302,
|
146
|
+
SeeOther = 303,
|
147
|
+
NotModified = 304,
|
148
|
+
UseProxy = 305,
|
149
|
+
Unused = 306,
|
150
|
+
TemporaryRedirect = 307,
|
151
|
+
PermanentRedirect = 308,
|
152
|
+
BadRequest = 400,
|
153
|
+
Unauthorized = 401,
|
154
|
+
PaymentRequired = 402,
|
155
|
+
Forbidden = 403,
|
156
|
+
NotFound = 404,
|
157
|
+
MethodNotAllowed = 405,
|
158
|
+
NotAcceptable = 406,
|
159
|
+
ProxyAuthenticationRequired = 407,
|
160
|
+
RequestTimeout = 408,
|
161
|
+
Conflict = 409,
|
162
|
+
Gone = 410,
|
163
|
+
LengthRequired = 411,
|
164
|
+
PreconditionFailed = 412,
|
165
|
+
PayloadTooLarge = 413,
|
166
|
+
UriTooLong = 414,
|
167
|
+
UnsupportedMediaType = 415,
|
168
|
+
RangeNotSatisfiable = 416,
|
169
|
+
ExpectationFailed = 417,
|
170
|
+
ImATeapot = 418,
|
171
|
+
MisdirectedRequest = 421,
|
172
|
+
UnprocessableEntity = 422,
|
173
|
+
Locked = 423,
|
174
|
+
FailedDependency = 424,
|
175
|
+
TooEarly = 425,
|
176
|
+
UpgradeRequired = 426,
|
177
|
+
PreconditionRequired = 428,
|
178
|
+
TooManyRequests = 429,
|
179
|
+
RequestHeaderFieldsTooLarge = 431,
|
180
|
+
UnavailableForLegalReasons = 451,
|
181
|
+
InternalServerError = 500,
|
182
|
+
NotImplemented = 501,
|
183
|
+
BadGateway = 502,
|
184
|
+
ServiceUnavailable = 503,
|
185
|
+
GatewayTimeout = 504,
|
186
|
+
HttpVersionNotSupported = 505,
|
187
|
+
VariantAlsoNegotiates = 506,
|
188
|
+
InsufficientStorage = 507,
|
189
|
+
LoopDetected = 508,
|
190
|
+
NotExtended = 510,
|
191
|
+
NetworkAuthenticationRequired = 511,
|
192
|
+
}
|
193
|
+
|
194
|
+
export type Method =
|
195
|
+
| 'get' | 'GET'
|
196
|
+
| 'delete' | 'DELETE'
|
197
|
+
| 'head' | 'HEAD'
|
198
|
+
| 'options' | 'OPTIONS'
|
199
|
+
| 'post' | 'POST'
|
200
|
+
| 'put' | 'PUT'
|
201
|
+
| 'patch' | 'PATCH'
|
202
|
+
| 'purge' | 'PURGE'
|
203
|
+
| 'link' | 'LINK'
|
204
|
+
| 'unlink' | 'UNLINK';
|
205
|
+
|
206
|
+
export type ResponseType =
|
207
|
+
| 'arraybuffer'
|
208
|
+
| 'blob'
|
209
|
+
| 'document'
|
210
|
+
| 'json'
|
211
|
+
| 'text'
|
212
|
+
| 'stream'
|
213
|
+
| 'formdata';
|
214
|
+
|
215
|
+
export type responseEncoding =
|
216
|
+
| 'ascii' | 'ASCII'
|
217
|
+
| 'ansi' | 'ANSI'
|
218
|
+
| 'binary' | 'BINARY'
|
219
|
+
| 'base64' | 'BASE64'
|
220
|
+
| 'base64url' | 'BASE64URL'
|
221
|
+
| 'hex' | 'HEX'
|
222
|
+
| 'latin1' | 'LATIN1'
|
223
|
+
| 'ucs-2' | 'UCS-2'
|
224
|
+
| 'ucs2' | 'UCS2'
|
225
|
+
| 'utf-8' | 'UTF-8'
|
226
|
+
| 'utf8' | 'UTF8'
|
227
|
+
| 'utf16le' | 'UTF16LE';
|
228
|
+
|
229
|
+
export interface TransitionalOptions {
|
230
|
+
silentJSONParsing?: boolean;
|
231
|
+
forcedJSONParsing?: boolean;
|
232
|
+
clarifyTimeoutError?: boolean;
|
233
|
+
}
|
234
|
+
|
235
|
+
export interface GenericAbortSignal {
|
236
|
+
readonly aborted: boolean;
|
237
|
+
onabort?: ((...args: any) => any) | null;
|
238
|
+
addEventListener?: (...args: any) => any;
|
239
|
+
removeEventListener?: (...args: any) => any;
|
240
|
+
}
|
241
|
+
|
242
|
+
export interface FormDataVisitorHelpers {
|
243
|
+
defaultVisitor: SerializerVisitor;
|
244
|
+
convertValue: (value: any) => any;
|
245
|
+
isVisitable: (value: any) => boolean;
|
246
|
+
}
|
247
|
+
|
248
|
+
export interface SerializerVisitor {
|
249
|
+
(
|
250
|
+
this: GenericFormData,
|
251
|
+
value: any,
|
252
|
+
key: string | number,
|
253
|
+
path: null | Array<string | number>,
|
254
|
+
helpers: FormDataVisitorHelpers
|
255
|
+
): boolean;
|
256
|
+
}
|
257
|
+
|
258
|
+
export interface SerializerOptions {
|
259
|
+
visitor?: SerializerVisitor;
|
260
|
+
dots?: boolean;
|
261
|
+
metaTokens?: boolean;
|
262
|
+
indexes?: boolean | null;
|
263
|
+
}
|
264
|
+
|
265
|
+
// tslint:disable-next-line
|
266
|
+
export interface FormSerializerOptions extends SerializerOptions {
|
267
|
+
}
|
268
|
+
|
269
|
+
export interface ParamEncoder {
|
270
|
+
(value: any, defaultEncoder: (value: any) => any): any;
|
271
|
+
}
|
272
|
+
|
273
|
+
export interface CustomParamsSerializer {
|
274
|
+
(params: Record<string, any>, options?: ParamsSerializerOptions): string;
|
275
|
+
}
|
276
|
+
|
277
|
+
export interface ParamsSerializerOptions extends SerializerOptions {
|
278
|
+
encode?: ParamEncoder;
|
279
|
+
serialize?: CustomParamsSerializer;
|
280
|
+
}
|
281
|
+
|
282
|
+
type MaxUploadRate = number;
|
283
|
+
|
284
|
+
type MaxDownloadRate = number;
|
285
|
+
|
286
|
+
type BrowserProgressEvent = any;
|
287
|
+
|
288
|
+
export interface AxiosProgressEvent {
|
289
|
+
loaded: number;
|
290
|
+
total?: number;
|
291
|
+
progress?: number;
|
292
|
+
bytes: number;
|
293
|
+
rate?: number;
|
294
|
+
estimated?: number;
|
295
|
+
upload?: boolean;
|
296
|
+
download?: boolean;
|
297
|
+
event?: BrowserProgressEvent;
|
298
|
+
lengthComputable: boolean;
|
299
|
+
}
|
300
|
+
|
301
|
+
type Milliseconds = number;
|
302
|
+
|
303
|
+
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | string;
|
304
|
+
|
305
|
+
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
306
|
+
|
307
|
+
export type AddressFamily = 4 | 6 | undefined;
|
308
|
+
|
309
|
+
export interface LookupAddressEntry {
|
310
|
+
address: string;
|
311
|
+
family?: AddressFamily;
|
312
|
+
}
|
313
|
+
|
314
|
+
export type LookupAddress = string | LookupAddressEntry;
|
315
|
+
|
316
|
+
export interface AxiosRequestConfig<D = any> {
|
317
|
+
url?: string;
|
318
|
+
method?: Method | string;
|
319
|
+
baseURL?: string;
|
320
|
+
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
321
|
+
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
322
|
+
headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
|
323
|
+
params?: any;
|
324
|
+
paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer;
|
325
|
+
data?: D;
|
326
|
+
timeout?: Milliseconds;
|
327
|
+
timeoutErrorMessage?: string;
|
328
|
+
withCredentials?: boolean;
|
329
|
+
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
|
330
|
+
auth?: AxiosBasicCredentials;
|
331
|
+
responseType?: ResponseType;
|
332
|
+
responseEncoding?: responseEncoding | string;
|
333
|
+
xsrfCookieName?: string;
|
334
|
+
xsrfHeaderName?: string;
|
335
|
+
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
336
|
+
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
337
|
+
maxContentLength?: number;
|
338
|
+
validateStatus?: ((status: number) => boolean) | null;
|
339
|
+
maxBodyLength?: number;
|
340
|
+
maxRedirects?: number;
|
341
|
+
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
|
342
|
+
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>, statusCode: HttpStatusCode}) => void;
|
343
|
+
socketPath?: string | null;
|
344
|
+
transport?: any;
|
345
|
+
httpAgent?: any;
|
346
|
+
httpsAgent?: any;
|
347
|
+
proxy?: AxiosProxyConfig | false;
|
348
|
+
cancelToken?: CancelToken;
|
349
|
+
decompress?: boolean;
|
350
|
+
transitional?: TransitionalOptions;
|
351
|
+
signal?: GenericAbortSignal;
|
352
|
+
insecureHTTPParser?: boolean;
|
353
|
+
env?: {
|
354
|
+
FormData?: new (...args: any[]) => object;
|
355
|
+
};
|
356
|
+
formSerializer?: FormSerializerOptions;
|
357
|
+
family?: AddressFamily;
|
358
|
+
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |
|
359
|
+
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);
|
360
|
+
withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
|
361
|
+
fetchOptions?: Record<string, any>;
|
362
|
+
}
|
363
|
+
|
364
|
+
// Alias
|
365
|
+
export type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
|
366
|
+
|
367
|
+
export interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
|
368
|
+
headers: AxiosRequestHeaders;
|
369
|
+
}
|
370
|
+
|
371
|
+
export interface HeadersDefaults {
|
372
|
+
common: RawAxiosRequestHeaders;
|
373
|
+
delete: RawAxiosRequestHeaders;
|
374
|
+
get: RawAxiosRequestHeaders;
|
375
|
+
head: RawAxiosRequestHeaders;
|
376
|
+
post: RawAxiosRequestHeaders;
|
377
|
+
put: RawAxiosRequestHeaders;
|
378
|
+
patch: RawAxiosRequestHeaders;
|
379
|
+
options?: RawAxiosRequestHeaders;
|
380
|
+
purge?: RawAxiosRequestHeaders;
|
381
|
+
link?: RawAxiosRequestHeaders;
|
382
|
+
unlink?: RawAxiosRequestHeaders;
|
383
|
+
}
|
384
|
+
|
385
|
+
export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
386
|
+
headers: HeadersDefaults;
|
387
|
+
}
|
388
|
+
|
389
|
+
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
390
|
+
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
|
391
|
+
}
|
392
|
+
|
393
|
+
export interface AxiosResponse<T = any, D = any> {
|
394
|
+
data: T;
|
395
|
+
status: number;
|
396
|
+
statusText: string;
|
397
|
+
headers: RawAxiosResponseHeaders | AxiosResponseHeaders;
|
398
|
+
config: InternalAxiosRequestConfig<D>;
|
399
|
+
request?: any;
|
400
|
+
}
|
401
|
+
|
402
|
+
export class AxiosError<T = unknown, D = any> extends Error {
|
403
|
+
constructor(
|
404
|
+
message?: string,
|
405
|
+
code?: string,
|
406
|
+
config?: InternalAxiosRequestConfig<D>,
|
407
|
+
request?: any,
|
408
|
+
response?: AxiosResponse<T, D>
|
409
|
+
);
|
410
|
+
|
411
|
+
config?: InternalAxiosRequestConfig<D>;
|
412
|
+
code?: string;
|
413
|
+
request?: any;
|
414
|
+
response?: AxiosResponse<T, D>;
|
415
|
+
isAxiosError: boolean;
|
416
|
+
status?: number;
|
417
|
+
toJSON: () => object;
|
418
|
+
cause?: Error;
|
419
|
+
static from<T = unknown, D = any>(
|
420
|
+
error: Error | unknown,
|
421
|
+
code?: string,
|
422
|
+
config?: InternalAxiosRequestConfig<D>,
|
423
|
+
request?: any,
|
424
|
+
response?: AxiosResponse<T, D>,
|
425
|
+
customProps?: object,
|
426
|
+
): AxiosError<T, D>;
|
427
|
+
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
428
|
+
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
429
|
+
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
430
|
+
static readonly ERR_NETWORK = "ERR_NETWORK";
|
431
|
+
static readonly ERR_DEPRECATED = "ERR_DEPRECATED";
|
432
|
+
static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE";
|
433
|
+
static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST";
|
434
|
+
static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
|
435
|
+
static readonly ERR_INVALID_URL = "ERR_INVALID_URL";
|
436
|
+
static readonly ERR_CANCELED = "ERR_CANCELED";
|
437
|
+
static readonly ECONNABORTED = "ECONNABORTED";
|
438
|
+
static readonly ETIMEDOUT = "ETIMEDOUT";
|
439
|
+
}
|
440
|
+
|
441
|
+
export class CanceledError<T> extends AxiosError<T> {
|
442
|
+
}
|
443
|
+
|
444
|
+
export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
|
445
|
+
|
446
|
+
export interface CancelStatic {
|
447
|
+
new (message?: string): Cancel;
|
448
|
+
}
|
449
|
+
|
450
|
+
export interface Cancel {
|
451
|
+
message: string | undefined;
|
452
|
+
}
|
453
|
+
|
454
|
+
export interface Canceler {
|
455
|
+
(message?: string, config?: AxiosRequestConfig, request?: any): void;
|
456
|
+
}
|
457
|
+
|
458
|
+
export interface CancelTokenStatic {
|
459
|
+
new (executor: (cancel: Canceler) => void): CancelToken;
|
460
|
+
source(): CancelTokenSource;
|
461
|
+
}
|
462
|
+
|
463
|
+
export interface CancelToken {
|
464
|
+
promise: Promise<Cancel>;
|
465
|
+
reason?: Cancel;
|
466
|
+
throwIfRequested(): void;
|
467
|
+
}
|
468
|
+
|
469
|
+
export interface CancelTokenSource {
|
470
|
+
token: CancelToken;
|
471
|
+
cancel: Canceler;
|
472
|
+
}
|
473
|
+
|
474
|
+
export interface AxiosInterceptorOptions {
|
475
|
+
synchronous?: boolean;
|
476
|
+
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
477
|
+
}
|
478
|
+
|
479
|
+
type AxiosRequestInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions) => number;
|
480
|
+
|
481
|
+
type AxiosResponseInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null) => number;
|
482
|
+
|
483
|
+
export interface AxiosInterceptorManager<V> {
|
484
|
+
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
485
|
+
eject(id: number): void;
|
486
|
+
clear(): void;
|
487
|
+
}
|
488
|
+
|
489
|
+
export class Axios {
|
490
|
+
constructor(config?: AxiosRequestConfig);
|
491
|
+
defaults: AxiosDefaults;
|
492
|
+
interceptors: {
|
493
|
+
request: AxiosInterceptorManager<InternalAxiosRequestConfig>;
|
494
|
+
response: AxiosInterceptorManager<AxiosResponse>;
|
495
|
+
};
|
496
|
+
getUri(config?: AxiosRequestConfig): string;
|
497
|
+
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
498
|
+
get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
499
|
+
delete<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
500
|
+
head<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
501
|
+
options<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
502
|
+
post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
503
|
+
put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
504
|
+
patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
505
|
+
postForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
506
|
+
putForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
507
|
+
patchForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
508
|
+
}
|
509
|
+
|
510
|
+
export interface AxiosInstance extends Axios {
|
511
|
+
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
512
|
+
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
513
|
+
|
514
|
+
defaults: Omit<AxiosDefaults, 'headers'> & {
|
515
|
+
headers: HeadersDefaults & {
|
516
|
+
[key: string]: AxiosHeaderValue
|
517
|
+
}
|
518
|
+
};
|
519
|
+
}
|
520
|
+
|
521
|
+
export interface GenericFormData {
|
522
|
+
append(name: string, value: any, options?: any): any;
|
523
|
+
}
|
524
|
+
|
525
|
+
export interface GenericHTMLFormElement {
|
526
|
+
name: string;
|
527
|
+
method: string;
|
528
|
+
submit(): void;
|
529
|
+
}
|
530
|
+
|
531
|
+
export function getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;
|
532
|
+
|
533
|
+
export function toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;
|
534
|
+
|
535
|
+
export function formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
|
536
|
+
|
537
|
+
export function isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
|
538
|
+
|
539
|
+
export function spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
540
|
+
|
541
|
+
export function isCancel(value: any): value is Cancel;
|
542
|
+
|
543
|
+
export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
544
|
+
|
545
|
+
export function mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
|
546
|
+
|
547
|
+
export interface AxiosStatic extends AxiosInstance {
|
548
|
+
create(config?: CreateAxiosDefaults): AxiosInstance;
|
549
|
+
Cancel: CancelStatic;
|
550
|
+
CancelToken: CancelTokenStatic;
|
551
|
+
Axios: typeof Axios;
|
552
|
+
AxiosError: typeof AxiosError;
|
553
|
+
HttpStatusCode: typeof HttpStatusCode;
|
554
|
+
readonly VERSION: string;
|
555
|
+
isCancel: typeof isCancel;
|
556
|
+
all: typeof all;
|
557
|
+
spread: typeof spread;
|
558
|
+
isAxiosError: typeof isAxiosError;
|
559
|
+
toFormData: typeof toFormData;
|
560
|
+
formToJSON: typeof formToJSON;
|
561
|
+
getAdapter: typeof getAdapter;
|
562
|
+
CanceledError: typeof CanceledError;
|
563
|
+
AxiosHeaders: typeof AxiosHeaders;
|
564
|
+
mergeConfig: typeof mergeConfig;
|
565
|
+
}
|
566
|
+
|
567
|
+
declare const axios: AxiosStatic;
|
568
|
+
|
569
|
+
export default axios;
|
package/lib/core/Axios.js
CHANGED
@@ -97,6 +97,15 @@ class Axios {
|
|
97
97
|
}
|
98
98
|
}
|
99
99
|
|
100
|
+
// Set config.allowAbsoluteUrls
|
101
|
+
if (config.allowAbsoluteUrls !== undefined) {
|
102
|
+
// do nothing
|
103
|
+
} else if (this.defaults.allowAbsoluteUrls !== undefined) {
|
104
|
+
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
105
|
+
} else {
|
106
|
+
config.allowAbsoluteUrls = true;
|
107
|
+
}
|
108
|
+
|
100
109
|
validator.assertOptions(config, {
|
101
110
|
baseUrl: validators.spelling('baseURL'),
|
102
111
|
withXsrfToken: validators.spelling('withXSRFToken')
|
@@ -192,7 +201,7 @@ class Axios {
|
|
192
201
|
|
193
202
|
getUri(config) {
|
194
203
|
config = mergeConfig(this.defaults, config);
|
195
|
-
const fullPath = buildFullPath(config.baseURL, config.url);
|
204
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
196
205
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
197
206
|
}
|
198
207
|
}
|
@@ -13,8 +13,9 @@ import combineURLs from '../helpers/combineURLs.js';
|
|
13
13
|
*
|
14
14
|
* @returns {string} The combined full path
|
15
15
|
*/
|
16
|
-
export default function buildFullPath(baseURL, requestedURL) {
|
17
|
-
|
16
|
+
export default function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
17
|
+
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
18
|
+
if (baseURL && isRelativeUrl || allowAbsoluteUrls == false) {
|
18
19
|
return combineURLs(baseURL, requestedURL);
|
19
20
|
}
|
20
21
|
return requestedURL;
|
package/lib/env/data.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "1.
|
1
|
+
export const VERSION = "1.8.0";
|