Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/axios/index.d.ts
1126 views
1
// TypeScript Version: 3.0
2
3
export type AxiosRequestHeaders = Record<string, string>;
4
5
export type AxiosResponseHeaders = Record<string, string> & {
6
"set-cookie"?: string[]
7
};
8
9
export interface AxiosRequestTransformer {
10
(data: any, headers?: AxiosRequestHeaders): any;
11
}
12
13
export interface AxiosResponseTransformer {
14
(data: any, headers?: AxiosResponseHeaders): any;
15
}
16
17
export interface AxiosAdapter {
18
(config: AxiosRequestConfig): AxiosPromise;
19
}
20
21
export interface AxiosBasicCredentials {
22
username: string;
23
password: string;
24
}
25
26
export interface AxiosProxyConfig {
27
host: string;
28
port: number;
29
auth?: {
30
username: string;
31
password: string;
32
};
33
protocol?: string;
34
}
35
36
export type Method =
37
| 'get' | 'GET'
38
| 'delete' | 'DELETE'
39
| 'head' | 'HEAD'
40
| 'options' | 'OPTIONS'
41
| 'post' | 'POST'
42
| 'put' | 'PUT'
43
| 'patch' | 'PATCH'
44
| 'purge' | 'PURGE'
45
| 'link' | 'LINK'
46
| 'unlink' | 'UNLINK';
47
48
export type ResponseType =
49
| 'arraybuffer'
50
| 'blob'
51
| 'document'
52
| 'json'
53
| 'text'
54
| 'stream';
55
56
export interface TransitionalOptions {
57
silentJSONParsing?: boolean;
58
forcedJSONParsing?: boolean;
59
clarifyTimeoutError?: boolean;
60
}
61
62
export interface AxiosRequestConfig<D = any> {
63
url?: string;
64
method?: Method;
65
baseURL?: string;
66
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
67
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
68
headers?: AxiosRequestHeaders;
69
params?: any;
70
paramsSerializer?: (params: any) => string;
71
data?: D;
72
timeout?: number;
73
timeoutErrorMessage?: string;
74
withCredentials?: boolean;
75
adapter?: AxiosAdapter;
76
auth?: AxiosBasicCredentials;
77
responseType?: ResponseType;
78
xsrfCookieName?: string;
79
xsrfHeaderName?: string;
80
onUploadProgress?: (progressEvent: any) => void;
81
onDownloadProgress?: (progressEvent: any) => void;
82
maxContentLength?: number;
83
validateStatus?: ((status: number) => boolean) | null;
84
maxBodyLength?: number;
85
maxRedirects?: number;
86
socketPath?: string | null;
87
httpAgent?: any;
88
httpsAgent?: any;
89
proxy?: AxiosProxyConfig | false;
90
cancelToken?: CancelToken;
91
decompress?: boolean;
92
transitional?: TransitionalOptions;
93
signal?: AbortSignal;
94
insecureHTTPParser?: boolean;
95
}
96
97
export interface HeadersDefaults {
98
common: AxiosRequestHeaders;
99
delete: AxiosRequestHeaders;
100
get: AxiosRequestHeaders;
101
head: AxiosRequestHeaders;
102
post: AxiosRequestHeaders;
103
put: AxiosRequestHeaders;
104
patch: AxiosRequestHeaders;
105
options?: AxiosRequestHeaders;
106
purge?: AxiosRequestHeaders;
107
link?: AxiosRequestHeaders;
108
unlink?: AxiosRequestHeaders;
109
}
110
111
export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
112
headers: HeadersDefaults;
113
}
114
115
export interface AxiosResponse<T = any, D = any> {
116
data: T;
117
status: number;
118
statusText: string;
119
headers: AxiosResponseHeaders;
120
config: AxiosRequestConfig<D>;
121
request?: any;
122
}
123
124
export interface AxiosError<T = any, D = any> extends Error {
125
config: AxiosRequestConfig<D>;
126
code?: string;
127
request?: any;
128
response?: AxiosResponse<T, D>;
129
isAxiosError: boolean;
130
toJSON: () => object;
131
}
132
133
export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
134
}
135
136
export interface CancelStatic {
137
new (message?: string): Cancel;
138
}
139
140
export interface Cancel {
141
message: string;
142
}
143
144
export interface Canceler {
145
(message?: string): void;
146
}
147
148
export interface CancelTokenStatic {
149
new (executor: (cancel: Canceler) => void): CancelToken;
150
source(): CancelTokenSource;
151
}
152
153
export interface CancelToken {
154
promise: Promise<Cancel>;
155
reason?: Cancel;
156
throwIfRequested(): void;
157
}
158
159
export interface CancelTokenSource {
160
token: CancelToken;
161
cancel: Canceler;
162
}
163
164
export interface AxiosInterceptorManager<V> {
165
use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any): number;
166
eject(id: number): void;
167
}
168
169
export class Axios {
170
constructor(config?: AxiosRequestConfig);
171
defaults: AxiosDefaults;
172
interceptors: {
173
request: AxiosInterceptorManager<AxiosRequestConfig>;
174
response: AxiosInterceptorManager<AxiosResponse>;
175
};
176
getUri(config?: AxiosRequestConfig): string;
177
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
178
get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
179
delete<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
180
head<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
181
options<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
182
post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
183
put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
184
patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
185
}
186
187
export interface AxiosInstance extends Axios {
188
(config: AxiosRequestConfig): AxiosPromise;
189
(url: string, config?: AxiosRequestConfig): AxiosPromise;
190
}
191
192
export interface AxiosStatic extends AxiosInstance {
193
create(config?: AxiosRequestConfig): AxiosInstance;
194
Cancel: CancelStatic;
195
CancelToken: CancelTokenStatic;
196
Axios: typeof Axios;
197
readonly VERSION: string;
198
isCancel(value: any): boolean;
199
all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
200
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
201
isAxiosError(payload: any): payload is AxiosError;
202
}
203
204
declare const axios: AxiosStatic;
205
206
export default axios;
207
208