index.d.cts 24 KB

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