index.d.cts 23 KB

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