index.d.cts 21 KB

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