source: imaps-frontend/node_modules/axios/index.d.cts@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

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