/** * @rajeev02/app-shell — API Client * Offline-first API layer with interceptors, token refresh, retry, cache-first strategy */ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; export type CacheStrategy = "network_first" | "cache_first" | "network_only" | "cache_only" | "stale_while_revalidate"; export interface ApiConfig { baseUrl: string; timeout?: number; defaultHeaders?: Record; /** Get current access token */ getToken?: () => Promise; /** Refresh token when 401 received */ onRefreshToken?: () => Promise; /** Called on network error (for queueing) */ onNetworkError?: (request: ApiRequest) => void; /** Default cache strategy */ defaultCacheStrategy?: CacheStrategy; /** Default cache TTL in seconds */ defaultCacheTtl?: number; } export interface ApiRequest { method: HttpMethod; path: string; body?: unknown; headers?: Record; query?: Record; cacheStrategy?: CacheStrategy; cacheTtl?: number; retryCount?: number; maxRetries?: number; tag?: string; } export interface ApiResponse { data: T; status: number; headers: Record; fromCache: boolean; duration: number; } export interface RequestInterceptor { name: string; onRequest: (request: ApiRequest) => ApiRequest | Promise; } export interface ResponseInterceptor { name: string; onResponse: (response: ApiResponse) => ApiResponse | Promise; onError?: (error: unknown, request: ApiRequest) => unknown; } /** * Offline-First API Client */ export declare class ApiClient { private config; private requestInterceptors; private responseInterceptors; private pendingRequests; private cache; private isRefreshing; private refreshQueue; constructor(config: ApiConfig); /** Add request interceptor */ addRequestInterceptor(interceptor: RequestInterceptor): void; /** Add response interceptor */ addResponseInterceptor(interceptor: ResponseInterceptor): void; /** Main request method */ request(req: ApiRequest): Promise>; get(path: string, query?: Record, options?: Partial): Promise>; post(path: string, body?: unknown, options?: Partial): Promise>; put(path: string, body?: unknown, options?: Partial): Promise>; patch(path: string, body?: unknown, options?: Partial): Promise>; delete(path: string, options?: Partial): Promise>; /** Clear API cache */ clearCache(): void; /** Get pending (queued) requests count */ getPendingCount(): number; private fetchFromNetwork; private processResponse; private handleTokenRefresh; private getFromCache; private getCacheKey; private buildUrl; } //# sourceMappingURL=index.d.ts.map