UNPKG

@metis-w/api-client

Version:

Modern TypeScript HTTP API client with dynamic routes, parameterized endpoints, interceptors, and advanced features

72 lines 2.83 kB
import { APIResponse, RequestConfig } from "../../types"; interface InterceptorConfig { id: string; interceptor: (config: RequestConfig) => RequestConfig | Promise<RequestConfig>; } interface ResponseInterceptorConfig { id: string; interceptor: (response: APIResponse) => APIResponse | Promise<APIResponse>; } export declare class InterceptorManager { private requestInterceptors; private responseInterceptors; /** * Adds a request interceptor to the client. * @param interceptor Adds a request interceptor to the client. */ addRequestInterceptor(interceptor: (config: RequestConfig) => RequestConfig | Promise<RequestConfig>): void; /** * Adds a response interceptor to the client. * Interceptors can modify the response before it is returned. * @param interceptor Adds a response interceptor to the client. */ addResponseInterceptor(interceptor: (response: APIResponse) => APIResponse | Promise<APIResponse>): void; /** * Adds a request interceptor with a specific ID. * @param id - Unique identifier for the interceptor * @param interceptor - The interceptor function to be added */ addRequestInterceptorWithId(id: string, interceptor: (config: RequestConfig) => RequestConfig | Promise<RequestConfig>): void; /** * Adds a response interceptor with a specific ID. * @param id - Unique identifier for the interceptor * @param interceptor - The interceptor function to be added */ addResponseInterceptorWithId(id: string, interceptor: (response: APIResponse) => APIResponse | Promise<APIResponse>): void; /** * Removes a request interceptor by its unique ID. * @param id - Unique identifier for the interceptor * @return True if the interceptor was removed, false if not found */ removeRequestInterceptor(id: string): boolean; /** * Removes a response interceptor by its unique ID. * @param id - Unique identifier for the interceptor * @return True if the interceptor was removed, false if not found */ removeResponseInterceptor(id: string): boolean; /** * Clears all request interceptors. */ clearRequestInterceptors(): void; /** * Clears all response interceptors. */ clearResponseInterceptors(): void; /** * Clears all request and response interceptors. */ clearAllInterceptors(): void; /** * Gets all request interceptors for execution * @return Set of request interceptors */ getRequestInterceptors(): Set<InterceptorConfig>; /** * Gets all response interceptors for execution * @return Set of response interceptors */ getResponseInterceptors(): Set<ResponseInterceptorConfig>; } export {}; //# sourceMappingURL=interceptor-manager.d.ts.map