import { ReactElement, ReactNode } from 'react'; import { ApiClient } from '../api-client'; import { ApiClientConfig, ApiError, ApiResponse, ErrorInterceptor, RequestConfig, RequestInterceptor, ResponseInterceptor } from '../types'; /** * API client context value */ export interface ApiClientContextValue { /** API client instance */ client: ApiClient; /** Whether client is configured */ isConfigured: boolean; /** Current configuration */ config: ApiClientConfig | null; /** Make a GET request */ get: (url: string, options?: Partial) => Promise>; /** Make a POST request */ post: (url: string, body?: B, options?: Partial) => Promise>; /** Make a PUT request */ put: (url: string, body?: B, options?: Partial) => Promise>; /** Make a PATCH request */ patch: (url: string, body?: B, options?: Partial) => Promise>; /** Make a DELETE request */ del: (url: string, options?: Partial) => Promise>; /** Make a generic request */ request: (config: RequestConfig) => Promise>; /** Add request interceptor */ addRequestInterceptor: (interceptor: RequestInterceptor) => () => void; /** Add response interceptor */ addResponseInterceptor: (interceptor: ResponseInterceptor) => () => void; /** Add error interceptor */ addErrorInterceptor: (interceptor: ErrorInterceptor) => () => void; /** Set token refresh function */ setTokenRefresh: (fn: () => Promise) => void; /** Cancel a specific request */ cancelRequest: (requestId: string) => void; /** Cancel all pending requests */ cancelAllRequests: () => void; /** Reconfigure the client */ configure: (config: Partial) => void; } /** * API client provider props */ export interface ApiClientProviderProps { /** Child components */ children: ReactNode; /** Initial client configuration */ config?: ApiClientConfig; /** Custom client instance */ client?: ApiClient; /** Token refresh function */ onTokenRefresh?: () => Promise; /** Global error handler */ onError?: (error: ApiError) => void; } /** * API client provider component * * @example * ```typescript * function App() { * return ( * toast.error(error.message)} * > * * * ); * } * ``` */ export declare function ApiClientProvider({ children, config, client: customClient, onTokenRefresh, onError, }: ApiClientProviderProps): ReactElement; /** * Hook to access the API client and utilities * * @returns API client context with request methods and configuration * @throws Error if used outside ApiClientProvider * * @example * ```typescript * function UserList() { * const { get, isConfigured } = useApiClient(); * const [users, setUsers] = useState([]); * * useEffect(() => { * if (isConfigured) { * get('/users').then((res) => setUsers(res.data)); * } * }, [get, isConfigured]); * * return
    {users.map(user =>
  • {user.name}
  • )}
; * } * ``` */ export declare function useApiClient(): ApiClientContextValue; /** * Hook to get only the API client instance * * @returns API client instance */ export declare function useApiClientInstance(): ApiClient; /** * Hook to check if API client is configured * * @returns Whether the client is configured */ export declare function useApiClientStatus(): { isConfigured: boolean; config: ApiClientConfig | null; }; /** * Hook to add interceptors with automatic cleanup * * @example * ```typescript * useApiInterceptors({ * request: (config) => { * config.headers['X-Custom-Header'] = 'value'; * return config; * }, * response: (response) => { * console.log('Response received:', response.status); * return response; * }, * }); * ``` */ export declare function useApiInterceptors(interceptors: { request?: RequestInterceptor; response?: ResponseInterceptor; error?: ErrorInterceptor; }): void;