diff --git a/axios/axios-tests.ts b/axios/axios-tests.ts deleted file mode 100644 index 2587222b36..0000000000 --- a/axios/axios-tests.ts +++ /dev/null @@ -1,125 +0,0 @@ - - -enum HttpMethod { GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH } -enum ResponseType { arraybuffer, blob, document, json, text } - -interface Repository { - id: number; - name: string; -} - -interface Issue { - id: number; - title: string; -} - -function makePromise(val: any) { - return >{ - then: () => val, - catch: () => val - }; -} - -axios.interceptors.request.use(config => { - console.log("Method:" + config.method + " Url:" +config.url); - return config; -}); - - -const requestId: number = axios.interceptors.request.use( - (config) => { - console.log("Method:" + config.method + " Url:" +config.url); - return config; - }, - (error: any) => error); - - -axios.interceptors.request.eject(requestId); -axios.interceptors.request.eject(7); - -const requestId2: number = axios.interceptors.request.use( - (config) => { - console.log("Method:" + config.method + " Url:" +config.url); - return makePromise(config); - }, - (error: any) => error); - -axios.interceptors.response.use(config => { - console.log("Status:" + config.status); - return config; -}); - -axios.interceptors.response.use(config => { - console.log("Status:" + config.status); - return makePromise(config); -}); - -const responseId: number = axios.interceptors.response.use( - config => { - console.log("Status:" + config.status); - return config; - }, - (error: any) => error); - -axios.interceptors.response.eject(responseId); - -axios.get("https://api.github.com/repos/mzabriskie/axios") - .then(r => console.log(r.config.method)); - -var getRepoDetails = axios({ - url: "https://api.github.com/repos/mzabriskie/axios", - method: HttpMethod[HttpMethod.GET], - headers: {}, -}).then(r => { - console.log("ID:" + r.data.id + " Name: " + r.data.name); - return r; -}); - -axios.post("http://example.com/", {}, { - transformRequest: (data: any) => data -}); - -axios.post("http://example.com/", { - headers: {'X-Custom-Header': 'foobar'} -}, { - transformRequest: [ - (data: any) => data - ] -}); - -var config: Axios.AxiosXHRConfigBase = {headers: {}}; -config.headers['X-Custom-Header'] = 'baz'; -axios.post("http://example.com/", config); - -var getRepoIssue = axios.get("https://api.github.com/repos/mzabriskie/axios/issues/1"); - -var axiosInstance = axios.create({ - baseURL: "https://api.github.com/repos/mzabriskie/axios/", - timeout: 1000 -}); - -axiosInstance.request({url: "issues/1"}).then(res => { - if (res.headers['content-type'].startsWith('application/json')) { - throw new Error('Unexpected content-type'); - } -}); - -axios.all([getRepoDetails, getRepoDetails]).then(([repo1, repo2]) => { - var sumIds = repo1.data.id + repo2.data.id; - console.log("Sum ID:" + sumIds); - return sumIds; -}); - -var repoSum = (repo1: Axios.AxiosXHR, repo2: Axios.AxiosXHR) => { - var sumIds = repo1.data.id + repo2.data.id; - console.log("Sum ID:" + sumIds); - return sumIds; -}; - -axios.all([getRepoDetails, getRepoDetails]).then(axios.spread(repoSum)); - -axios.defaults.baseURL = 'https://api.example.com'; -axios.defaults.headers.common['Authorization'] = "AUTH_TOKEN"; -axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; - -axiosInstance.defaults.headers.common['Authorization'] = "AUTH_TOKEN"; diff --git a/axios/index.d.ts b/axios/index.d.ts deleted file mode 100644 index b32a78ebe0..0000000000 --- a/axios/index.d.ts +++ /dev/null @@ -1,328 +0,0 @@ -// Type definitions for axios 0.9.1 -// Project: https://github.com/mzabriskie/axios -// Definitions by: Marcel Buesing -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace Axios { - - interface IThenable { - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IThenable; - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IThenable; - } - - interface IPromise extends IThenable { - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IPromise; - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IPromise; - catch(onRejected?: (error: any) => U | IThenable): IPromise; - } - - /** - * HTTP Basic auth details - */ - interface AxiosHttpBasicAuth { - username: string; - password: string; - } - - /** - * Common axios XHR config interface - * - request body data type - */ - interface AxiosXHRConfigBase { - /** - * will be prepended to `url` unless `url` is absolute. - * It can be convenient to set `baseURL` for an instance - * of axios to pass relative URLs to methods of that instance. - */ - baseURL?: string; - - /** - * custom headers to be sent - */ - headers?: {[key: string]: any}; - - /** - * URL parameters to be sent with the request - */ - params?: Object; - - /** - * optional function in charge of serializing `params` - * (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/) - */ - paramsSerializer?: (params: Object) => string; - - /** - * specifies the number of milliseconds before the request times out. - * If the request takes longer than `timeout`, the request will be aborted. - */ - timeout?: number; - - /** - * indicates whether or not cross-site Access-Control requests - * should be made using credentials - */ - withCredentials?: boolean; - - /** - * indicates that HTTP Basic auth should be used, and supplies - * credentials. This will set an `Authorization` header, - * overwriting any existing `Authorization` custom headers you have - * set using `headers`. - */ - auth?: AxiosHttpBasicAuth; - - /** - * indicates the type of data that the server will respond with - * options are 'arraybuffer', 'blob', 'document', 'json', 'text' - */ - responseType?: string; - - /** - * name of the cookie to use as a value for xsrf token - */ - xsrfCookieName?: string; - - /** - * name of the http header that carries the xsrf token value - */ - xsrfHeaderName?: string; - - /** - * Change the request data before it is sent to the server. - * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' - * The last function in the array must return a string or an ArrayBuffer - */ - transformRequest?: ((data: T) => U) | [(data: T) => U]; - - /** - * change the response data to be made before it is passed to then/catch - */ - transformResponse?: (data: T) => U; - - /** - * defines whether to resolve or reject the promise for a given HTTP response status code. - * If returns `true` (or is set to `null` or `undefined`), the promise will be resolved; - * otherwise, the promise will be rejected - */ - validateStatus?: (status: number) => boolean | undefined; - } - - /** - * - request body data type - */ - interface AxiosXHRConfig extends AxiosXHRConfigBase { - /** - * server URL that will be used for the request, options are: - * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH - */ - url: string; - - /** - * request method to be used when making the request - */ - method?: string; - - /** - * data to be sent as the request body - * Only applicable for request methods 'PUT', 'POST', and 'PATCH' - * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash - */ - data?: T; - } - - interface AxiosXHRConfigDefaults extends AxiosXHRConfigBase { - /** - * custom headers to be sent - */ - headers: { - common: {[index: string]: string}; - patch: {[index: string]: string}; - post: {[index: string]: string}; - put: {[index: string]: string}; - }; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosXHR { - /** - * Response that was provided by the server - */ - data: T; - - /** - * HTTP status code from the server response - */ - status: number; - - /** - * HTTP status message from the server response - */ - statusText: string; - - /** - * headers that the server responded with - */ - headers: {[index: string]: any}; - - /** - * config that was provided to `axios` for the request - */ - config: AxiosXHRConfig; - } - - interface Interceptor { - /** - * intercept request before it is sent - */ - request: RequestInterceptor; - - /** - * intercept response of request when it is received. - */ - response: ResponseInterceptor - } - - type InterceptorId = number; - - interface RequestInterceptor { - /** - * - request body data type - */ - - use(fulfilledFn: (config: AxiosXHRConfig) => AxiosXHRConfig): InterceptorId; - - use(fulfilledFn: (config: AxiosXHRConfig) => AxiosXHRConfig, - rejectedFn: (error: any) => any) - : InterceptorId; - - use(fulfilledFn: (config: AxiosXHRConfig) => IPromise>): InterceptorId; - - use(fulfilledFn: (config: AxiosXHRConfig) => IPromise>, - rejectedFn: (error: any) => any) - : InterceptorId; - - eject(interceptorId: InterceptorId): void; - } - - interface ResponseInterceptor { - /** - * - expected response type - */ - - use(fulfilledFn: (config: Axios.AxiosXHR) => Axios.AxiosXHR): InterceptorId; - - use(fulfilledFn: (config: Axios.AxiosXHR) => IPromise>): InterceptorId; - - use(fulfilledFn: (config: Axios.AxiosXHR) => Axios.AxiosXHR, - rejectedFn: (error: any) => any) - : InterceptorId; - - use(fulfilledFn: (config: Axios.AxiosXHR) => IPromise>, - rejectedFn: (error: any) => any) - : InterceptorId; - - eject(interceptorId: InterceptorId): void; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosInstance { - - /** - * Send request as configured - */ - (config: AxiosXHRConfig): IPromise>; - - /** - * Send request as configured - */ - new (config: AxiosXHRConfig): IPromise>; - - /** - * Send request as configured - */ - request(config: AxiosXHRConfig): IPromise>; - - /** - * intercept requests or responses before they are handled by then or catch - */ - interceptors: Interceptor; - - /** - * Config defaults - */ - defaults: AxiosXHRConfigDefaults; - - /** - * equivalent to `Promise.all` - */ - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>, T8 | IPromise>, T9 | IPromise>, T10 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>, T8 | IPromise>, T9 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>, T8 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR]>; - - /** - * spread array parameter to `fn`. - * note: alternative to `spread`, destructuring assignment. - */ - spread(fn: (t1: T1, t2: T2) => U): (arr: ([T1, T2])) => U; - - /** - * convenience alias, method = GET - */ - get(url: string, config?: AxiosXHRConfigBase): IPromise>; - - - /** - * convenience alias, method = DELETE - */ - delete(url: string, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = HEAD - */ - head(url: string, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = POST - */ - post(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = PUT - */ - put(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = PATCH - */ - patch(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; - } - - /** - * - expected response type, - */ - interface AxiosStatic extends AxiosInstance { - /** - * create a new instance of axios with a custom config - */ - create(config: AxiosXHRConfigBase): AxiosInstance; - } -} - -declare var axios: Axios.AxiosStatic; - -declare module "axios" { - export = axios; -} diff --git a/axios/tsconfig.json b/axios/tsconfig.json deleted file mode 100644 index 4300cfb925..0000000000 --- a/axios/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "axios-tests.ts" - ] -} \ No newline at end of file diff --git a/notNeededPackages.json b/notNeededPackages.json index e671ef4523..46509a1642 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -293,6 +293,12 @@ "typingsPackageName": "redux-saga", "sourceRepoURL": "https://github.com/redux-saga/redux-saga", "asOfVersion": "0.10.5" + }, + { + "libraryName": "axios", + "typingsPackageName": "axios", + "sourceRepoURL": "https://github.com/mzabriskie/axios", + "asOfVersion": "0.14.0" } ] }