UNPKG

@dbs-portal/core-api

Version:

HTTP client and API utilities for DBS Portal

107 lines 3.2 kB
/** * Advanced API client with interceptors, caching, retry logic, and more * Now powered by Axios for robust HTTP handling */ import { HttpClient } from './http-client'; import type { ApiClientConfig, RequestConfig, ApiResponse } from '../types'; /** * Advanced API client with comprehensive features using Axios */ export declare class ApiClient { private httpClient; private cacheManager?; private retryManager?; private rateLimiter?; private config; private interceptorIds; constructor(config?: ApiClientConfig); /** * Set up Axios interceptors for caching, rate limiting, and event handling */ private setupAxiosInterceptors; /** * Makes an HTTP request with all features applied */ request<T = any>(config: RequestConfig): Promise<ApiResponse<T>>; /** * GET request */ get<T = any>(url: string, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * POST request */ post<T = any>(url: string, data?: any, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * PUT request */ put<T = any>(url: string, data?: any, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * PATCH request */ patch<T = any>(url: string, data?: any, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * DELETE request */ delete<T = any>(url: string, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * HEAD request */ head(url: string, config?: Partial<RequestConfig>): Promise<ApiResponse<void>>; /** * OPTIONS request */ options<T = any>(url: string, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * Adds a request interceptor using Axios */ addRequestInterceptor(onFulfilled?: (config: any) => any | Promise<any>, onRejected?: (error: any) => any): number; /** * Adds a response interceptor using Axios */ addResponseInterceptor(onFulfilled?: (response: any) => any | Promise<any>, onRejected?: (error: any) => any): number; /** * Removes a request interceptor */ removeRequestInterceptor(id: number): void; /** * Removes a response interceptor */ removeResponseInterceptor(id: number): void; /** * Clears all custom interceptors (keeps built-in ones) */ clearInterceptors(): void; /** * Clears cache */ clearCache(): void; /** * Gets cache statistics */ getCacheStats(): any; /** * Updates client configuration */ updateConfig(config: Partial<ApiClientConfig>): void; /** * Gets current configuration */ getConfig(): ApiClientConfig; /** * Gets the underlying Axios instance for advanced usage */ getAxiosInstance(): import("axios").AxiosInstance; /** * Gets the underlying HTTP client */ getHttpClient(): HttpClient; /** * Determines if cache should be used for request */ private shouldUseCache; /** * Determines if response should be cached */ private shouldCacheResponse; } //# sourceMappingURL=api-client.d.ts.map