index.d.ts 20 KB

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