@dbs-portal/core-api
Version:
HTTP client and API utilities for DBS Portal
88 lines • 2.56 kB
TypeScript
/**
* Interceptor manager for handling request and response interceptors
*/
import type { IInterceptorManager } from '../types';
/**
* Manages interceptors for requests and responses
*/
export declare class InterceptorManager<T> implements IInterceptorManager {
private interceptors;
private nextId;
/**
* Adds an interceptor
*/
use(onFulfilled?: any, onRejected?: any): number;
/**
* Removes an interceptor by ID
*/
eject(id: number): void;
/**
* Clears all interceptors
*/
clear(): void;
/**
* Gets all active interceptors
*/
getInterceptors(): T[];
/**
* Gets the number of active interceptors
*/
size(): number;
/**
* Checks if there are any interceptors
*/
isEmpty(): boolean;
/**
* Executes all interceptors in sequence
*/
executeAll<TInput, TOutput = TInput>(input: TInput, executor: (interceptor: T, input: TInput) => Promise<TOutput> | TOutput): Promise<TOutput>;
/**
* Executes interceptors with error handling
*/
executeWithErrorHandling<TInput, TOutput = TInput>(input: TInput, onFulfilledExecutor: (interceptor: T, input: TInput) => Promise<TOutput> | TOutput, onRejectedExecutor?: (interceptor: T, error: any) => Promise<any> | any): Promise<TOutput>;
/**
* Creates a new interceptor manager with copied interceptors
*/
clone(): InterceptorManager<T>;
/**
* Merges interceptors from another manager
*/
merge(other: InterceptorManager<T>): void;
/**
* Filters interceptors based on a predicate
*/
filter(predicate: (interceptor: T) => boolean): InterceptorManager<T>;
/**
* Maps interceptors to a new type
*/
map<U>(mapper: (interceptor: T) => U): U[];
/**
* Finds an interceptor by predicate
*/
find(predicate: (interceptor: T) => boolean): T | undefined;
/**
* Checks if any interceptor matches the predicate
*/
some(predicate: (interceptor: T) => boolean): boolean;
/**
* Checks if all interceptors match the predicate
*/
every(predicate: (interceptor: T) => boolean): boolean;
/**
* Iterates over all interceptors
*/
forEach(callback: (interceptor: T, index: number) => void): void;
/**
* Converts to array
*/
toArray(): T[];
/**
* Gets interceptor statistics
*/
getStats(): {
total: number;
active: number;
removed: number;
};
}
//# sourceMappingURL=interceptor-manager.d.ts.map