-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[axios_v0.19.x] Split Flow version to align with recent changes. (#3689…
…) (#3691)
- Loading branch information
1 parent
b09080b
commit a4cc3d5
Showing
4 changed files
with
617 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
216 changes: 216 additions & 0 deletions
216
definitions/npm/axios_v0.19.x/flow_v0.80.x-v0.103.x/axios_v0.19.x.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
declare module 'axios' { | ||
import type { Agent as HttpAgent } from 'http'; | ||
import type { Agent as HttpsAgent } from 'https'; | ||
|
||
declare type AxiosTransformer<T> = ( | ||
data: T, | ||
headers?: { [key: string]: any } | ||
) => any; | ||
|
||
declare type ProxyConfig = {| | ||
host: string, | ||
port: number, | ||
auth?: { | ||
username: string, | ||
password: string, | ||
}, | ||
protocol?: string, | ||
|}; | ||
|
||
declare class Cancel { | ||
constructor(message?: string): Cancel; | ||
message: string; | ||
} | ||
|
||
declare type Canceler = (message?: string) => void; | ||
|
||
declare type CancelTokenSource = {| | ||
token: CancelToken, | ||
cancel: Canceler, | ||
|}; | ||
|
||
declare class CancelToken { | ||
constructor(executor: (cancel: Canceler) => void): void; | ||
static source(): CancelTokenSource; | ||
promise: Promise<Cancel>; | ||
reason?: Cancel; | ||
throwIfRequested(): void; | ||
} | ||
|
||
declare type Method = | ||
| 'get' | ||
| 'GET' | ||
| 'delete' | ||
| 'DELETE' | ||
| 'head' | ||
| 'HEAD' | ||
| 'options' | ||
| 'OPTIONS' | ||
| 'post' | ||
| 'POST' | ||
| 'put' | ||
| 'PUT' | ||
| 'patch' | ||
| 'PATCH'; | ||
|
||
declare type ResponseType = | ||
| 'arraybuffer' | ||
| 'blob' | ||
| 'document' | ||
| 'json' | ||
| 'text' | ||
| 'stream'; | ||
|
||
declare type AxiosAdapter = ( | ||
config: AxiosXHRConfig<any> | ||
) => Promise<AxiosXHR<any>>; | ||
|
||
declare type AxiosXHRConfigBase<T, R = T> = { | ||
adapter?: AxiosAdapter, | ||
auth?: { | ||
username: string, | ||
password: string, | ||
}, | ||
baseURL?: string, | ||
cancelToken?: CancelToken, | ||
headers?: { [key: string]: any }, | ||
httpAgent?: HttpAgent, | ||
httpsAgent?: HttpsAgent, | ||
maxContentLength?: number, | ||
maxRedirects?: number, | ||
socketPath?: string | null, | ||
params?: { [key: string]: any }, | ||
paramsSerializer?: (params: { [key: string]: any }) => string, | ||
onUploadProgress?: (progressEvent: ProgressEvent) => void, | ||
onDownloadProgress?: (progressEvent: ProgressEvent) => void, | ||
proxy?: ProxyConfig | false, | ||
responseType?: ResponseType, | ||
timeout?: number, | ||
transformRequest?: AxiosTransformer<T> | Array<AxiosTransformer<T>>, | ||
transformResponse?: AxiosTransformer<R> | Array<AxiosTransformer<R>>, | ||
validateStatus?: (status: number) => boolean, | ||
withCredentials?: boolean, | ||
xsrfCookieName?: string, | ||
xsrfHeaderName?: string, | ||
}; | ||
|
||
declare type AxiosXHRConfig<T, R = T> = {| | ||
...$Exact<AxiosXHRConfigBase<T, R>>, | ||
data?: T, | ||
method?: Method, | ||
url: string, | ||
|}; | ||
|
||
declare type AxiosXHRConfigShape<T, R = T> = $Shape<AxiosXHRConfig<T, R>>; | ||
|
||
declare type AxiosXHR<T, R = T> = { | ||
config: AxiosXHRConfig<T, R>, | ||
data: R, | ||
headers: ?{ [key: string]: any }, | ||
status: number, | ||
statusText: string, | ||
request: http$ClientRequest<> | XMLHttpRequest | mixed, | ||
}; | ||
|
||
declare type AxiosInterceptorIdent = number; | ||
|
||
declare type AxiosRequestInterceptor<T, R = T> = {| | ||
use( | ||
onFulfilled: ?( | ||
response: AxiosXHRConfig<T, R> | ||
) => Promise<AxiosXHRConfig<mixed>> | AxiosXHRConfig<mixed>, | ||
onRejected: ?(error: mixed) => mixed | ||
): AxiosInterceptorIdent, | ||
eject(ident: AxiosInterceptorIdent): void, | ||
|}; | ||
|
||
declare type AxiosResponseInterceptor<T, R = T> = {| | ||
use( | ||
onFulfilled: ?(response: AxiosXHR<T, R>) => mixed, | ||
onRejected: ?(error: mixed) => mixed | ||
): AxiosInterceptorIdent, | ||
eject(ident: AxiosInterceptorIdent): void, | ||
|}; | ||
|
||
declare type AxiosPromise<T, R = T> = Promise<AxiosXHR<T, R>>; | ||
|
||
declare class Axios { | ||
<T, R>( | ||
config: AxiosXHRConfig<T, R> | string, | ||
config?: AxiosXHRConfigShape<T, R> | ||
): AxiosPromise<T, R>; | ||
constructor<T, R>(config?: AxiosXHRConfigBase<T, R>): void; | ||
request<T, R>( | ||
config: AxiosXHRConfig<T, R> | string, | ||
config?: AxiosXHRConfigShape<T, R> | ||
): AxiosPromise<T, R>; | ||
delete<R>( | ||
url: string, | ||
config?: AxiosXHRConfigBase<mixed, R> | ||
): AxiosPromise<mixed, R>; | ||
get<R>( | ||
url: string, | ||
config?: AxiosXHRConfigBase<mixed, R> | ||
): AxiosPromise<mixed, R>; | ||
head<R>( | ||
url: string, | ||
config?: AxiosXHRConfigBase<mixed, R> | ||
): AxiosPromise<mixed, R>; | ||
post<T, R>( | ||
url: string, | ||
data?: T, | ||
config?: AxiosXHRConfigBase<T, R> | ||
): AxiosPromise<T, R>; | ||
put<T, R>( | ||
url: string, | ||
data?: T, | ||
config?: AxiosXHRConfigBase<T, R> | ||
): AxiosPromise<T, R>; | ||
patch<T, R>( | ||
url: string, | ||
data?: T, | ||
config?: AxiosXHRConfigBase<T, R> | ||
): AxiosPromise<T, R>; | ||
interceptors: { | ||
request: AxiosRequestInterceptor<mixed>, | ||
response: AxiosResponseInterceptor<mixed>, | ||
}; | ||
defaults: {| | ||
...$Exact<AxiosXHRConfigBase<mixed>>, | ||
headers: { [key: string]: any }, | ||
|}; | ||
getUri<T, R>(config?: AxiosXHRConfig<T, R>): string; | ||
} | ||
|
||
declare class AxiosError<T, R = T> extends Error { | ||
config: AxiosXHRConfig<T, R>; | ||
request?: http$ClientRequest<> | XMLHttpRequest; | ||
response?: AxiosXHR<T, R>; | ||
code?: string; | ||
isAxiosError: boolean; | ||
} | ||
|
||
declare interface AxiosExport extends Axios { | ||
<T, R>( | ||
config: AxiosXHRConfig<T, R> | string, | ||
config?: AxiosXHRConfigShape<T, R> | ||
): AxiosPromise<T, R>; | ||
Axios: typeof Axios; | ||
Cancel: typeof Cancel; | ||
CancelToken: typeof CancelToken; | ||
isCancel(value: any): boolean; | ||
create(config?: AxiosXHRConfigBase<any>): Axios; | ||
all: typeof Promise.all; | ||
spread<T, R>(callback: (...args: T) => R): (array: T) => R; | ||
} | ||
|
||
declare type $AxiosXHRConfigBase<T, R = T> = AxiosXHRConfigBase<T, R>; | ||
|
||
declare type $AxiosXHRConfig<T, R = T> = AxiosXHRConfig<T, R>; | ||
|
||
declare type $AxiosXHR<T, R = T> = AxiosXHR<T, R>; | ||
|
||
declare type $AxiosError<T, R = T> = AxiosError<T, R>; | ||
|
||
declare module.exports: AxiosExport; | ||
} |
Oops, something went wrong.