index.d.ts 20 KB

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