/** * Copyright 2018 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 * * This file has been modified by kouhin (https://github.com/kouhin/redaxios). * Modifications: * - Rewritten from JavaScript to TypeScript with full type definitions. * - Added axios-compatible error handling (RedaxiosError, createError, isAxiosError). */ type LC = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'head'; export type Method = LC | Uppercase; export type ResponseType = 'text' | 'json' | 'stream' | 'blob' | 'arrayBuffer' | 'formData'; export type RequestHeaders = Record | Headers; export interface Options { url?: string; method?: Method; headers?: RequestHeaders; body?: FormData | string | object; responseType?: ResponseType; params?: Record | URLSearchParams; paramsSerializer?: (params: Options['params']) => string; withCredentials?: boolean; auth?: string; validateStatus?: (status: number) => boolean; transformRequest?: Array<(body: any, headers?: RequestHeaders) => any>; baseURL?: string; fetch?: typeof globalThis.fetch; data?: any; signal?: AbortSignal; timeout?: number; } export interface Response { status: number; statusText: string; config: Options; data: T; headers: Headers; redirect: boolean; url: string; type: globalThis.ResponseType; body: ReadableStream | null; bodyUsed: boolean; } export interface RedaxiosError extends Error { config: Options; response: Response; status: number; code: 'ERR_BAD_REQUEST' | 'ERR_BAD_RESPONSE' | 'ERR_NETWORK' | 'ERR_CANCELED' | 'ECONNABORTED'; isAxiosError: true; } export type BodylessMethod = (url: string, config?: Options) => Promise>; export type BodyMethod = (url: string, body?: any, config?: Options) => Promise>; export interface RedaxiosInstance { (config: Options): Promise>; (url: string, config?: Options): Promise>; request: RedaxiosInstance; get: BodylessMethod; delete: BodylessMethod; head: BodylessMethod; options: BodylessMethod; post: BodyMethod; put: BodyMethod; patch: BodyMethod; defaults: Options; create: (defaults?: Options) => RedaxiosInstance; isAxiosError: (value: any) => value is RedaxiosError; isCancel: (value: any) => boolean; } declare const _default: RedaxiosInstance; export default _default; //# sourceMappingURL=index.d.ts.map