index.d.cts 20 KB

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