import { AxiosInstance, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
import { Document } from 'openapi-client-axios';

type TokenArg = string | (() => string | Promise<string>);
declare const authorize: <T extends AxiosInstance>(client: T, token: TokenArg) => T;

type RequestInterceptor = {
    type: 'request';
    fulfilled: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;
    rejected?: (error: unknown) => unknown;
};
type ResponseInterceptor = {
    type: 'response';
    fulfilled: (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>;
    rejected?: (error: unknown) => unknown;
};
type Interceptor = RequestInterceptor | ResponseInterceptor;
type HeadersConfig = Record<string, string>;
type OverridesConfig = Record<string, string>;
/**
 * An API handle that provides:
 * - `getClient()` — cached singleton
 * - `createClient()` — fresh instance
 * - Any operation method (e.g. `.getEntity(...)`) — auto-resolved via lazy singleton
 */
type ApiHandle<T extends AxiosInstance = AxiosInstance> = {
    /** Get the cached singleton client instance (lazy-initialized on first call) */
    getClient: () => T;
    /** Create a fresh client instance (not cached) */
    createClient: () => T;
    /** Get the full OpenAPI specification document (lazy-loaded) */
    openapi: () => Promise<Document>;
} & {
    [K in keyof T]: T[K];
};

export { type ApiHandle as A, type HeadersConfig as H, type Interceptor as I, type OverridesConfig as O, type TokenArg as T, authorize as a };
