import { Options } from 'camel-case'; import { AxiosInstance, AxiosRequestTransformer, AxiosResponseTransformer, AxiosInterceptorManager, AxiosRequestConfig, AxiosRequestHeaders } from 'axios'; /** string transformers (change-case functions) */ interface CaseFunction { (input: string, options?: Options): string; } type CaseFunctionTypes = 'snake' | 'camel' | 'header'; type CaseFunctions = { [K in CaseFunctionTypes]: CaseFunction; }; /** decorators for string transformers */ interface ApplyCaseOptions { (fn: CaseFunction, options?: Options): CaseFunction; } interface PreserveSpecificKeys { (fn: CaseFunction, keys: string[] | PreservedKeysCondition): CaseFunction; } /** objects which can be handled in object transformers */ interface TransformableObject { [key: string]: unknown; } type Transformable = (unknown[] | Record | FormData | URLSearchParams) & TransformableObject; /** object transformers and their factories */ interface PreservedKeysCondition { (input: string, options?: Options): boolean; } type ObjectTransformerOptions = { overwrite?: boolean; preservedKeys?: string[] | PreservedKeysCondition; caseOptions?: Options; }; interface ObjectTransformer { (data: unknown, options?: ObjectTransformerOptions): unknown; } type ObjectTransformers = { [K in CaseFunctionTypes]: ObjectTransformer; }; interface CreateObjectTransformer { (fn: CaseFunction): ObjectTransformer; } interface CreateObjectTransformerOf { (type: CaseFunctionTypes, options?: Partial): ObjectTransformer; } interface CreateObjectTransformers { (options?: Partial): ObjectTransformers; } /** converters for axios and their factories */ type AxiosCaseMiddlewareOptions = Omit & { caseFunctions?: Partial; ignoreHeaders?: boolean; ignoreParams?: boolean; }; type AxiosInterceptor = NonNullable['use']>[0]>; type AxiosRequestInterceptor = AxiosInterceptor; interface CreateAxiosInterceptor { (options?: AxiosCaseMiddlewareOptions): AxiosInterceptor; } interface CreateAxiosRequestInterceptor { (options?: AxiosCaseMiddlewareOptions): AxiosRequestInterceptor; } interface CreateAxiosRequestTransformer { (options?: AxiosCaseMiddlewareOptions): AxiosRequestTransformer; } interface CreateAxiosResponseTransformer { (options?: AxiosCaseMiddlewareOptions): AxiosResponseTransformer; } /** converter applier */ type ApplyCaseMiddlewareOptions = AxiosCaseMiddlewareOptions & { caseMiddleware?: { requestTransformer?: AxiosRequestTransformer; responseTransformer?: AxiosResponseTransformer; requestInterceptor?: AxiosRequestInterceptor; }; }; interface ApplyCaseMiddleware { (axios: AxiosInstance, options?: ApplyCaseMiddlewareOptions): AxiosInstance; } declare const applyCaseMiddleware: ApplyCaseMiddleware; export { type ApplyCaseMiddleware, type ApplyCaseMiddlewareOptions, type ApplyCaseOptions, type AxiosCaseMiddlewareOptions, type AxiosInterceptor, type AxiosRequestInterceptor, type CaseFunction, type CaseFunctionTypes, type CaseFunctions, type CreateAxiosInterceptor, type CreateAxiosRequestInterceptor, type CreateAxiosRequestTransformer, type CreateAxiosResponseTransformer, type CreateObjectTransformer, type CreateObjectTransformerOf, type CreateObjectTransformers, type ObjectTransformer, type ObjectTransformerOptions, type ObjectTransformers, type PreserveSpecificKeys, type PreservedKeysCondition, type Transformable, type TransformableObject, applyCaseMiddleware as default };