import { AfterResponseHook, BeforeRequestHook } from "ky"; /** * A request interceptor. Use this to change request parameters * before sending doing the service call or to prevent the request from * being sent by returning a Response. * Be careful when returning inside an interceptor because this might prevent * other hooks from firing. You can use the priority property to influence * hook order. * * See: https://github.com/sindresorhus/ky#hooksbeforerequest * * @export * @interface IRequestInterceptor */ export interface IRequestInterceptor { hook: BeforeRequestHook; } /** * A response interceptor. Use this to change the Response before sending it to * the client. Changing the status can be used to change a success response to * an error or visa versa * * @export * @interface IResponseInterceptor */ export interface IResponseInterceptor { hook: AfterResponseHook; } /** * The basic interceptor implementation * * @export * @class Interceptor */ export declare class Interceptor { protected name: string; /** * Creates an instance of an Interceptor * Extending classes will need to set their name and interceptor type * and implement their interceptor handler * * @param {string} name * @param {('request'|'response')} type */ constructor(name: string); /** * Retrieves the name of the interceptor * * @return {string} */ getName(): string; /** * The interceptor token as registered with the registry; * * @private * @type {string} */ private registryToken; /** * Used to influence the order interceptors are processed in * Higher priority hooks are processed first. * */ priority: number; /** * Stores an activation token as provided by the service registry * */ set token(newToken: string | undefined); /** * Retrieves the current token * * @returns */ get token(): string | undefined; /** * Check if the token provided is the activation token for this interceptor * * @param {string} token * @returns */ hasToken(token: string): boolean; /** * Used to disable an interceptor * */ disabled: boolean; /** * Indicates the interceptor is active * * @readonly */ get isActive(): boolean; /** * The request interceptor implementation * * @type {IRequestInterceptor} */ requestInterceptor?: IRequestInterceptor; /** * The response interceptor implementation * * @type {IResponseInterceptor} */ responseInterceptor?: IResponseInterceptor; /** * Registers and enables the interceptor * */ activate(): void; /** * Disables the interceptor and stops warning logging * */ deactivate(): void; } /** * This class manages the interceptors that need to be added to the EVA Service calls * * @export * @class InterceptorRepository */ export declare class InterceptorRepository { /** * The collection of request interceptors * * @private * @type {Interceptor[]} */ private interceptors; /** * Returns the currently active interceptors * Ordered by priority * * @returns */ getActiveInterceptors(): Interceptor[]; /** * Return the list of active request interceptors ordered by priority * * @returns */ getRequestInterceptors(): BeforeRequestHook[]; /** * Return the list of active request interceptors ordered by priority * * @returns */ getResponseInterceptors(): AfterResponseHook[]; /** * Register and activate a new interceptor * * @param {Interceptor} interceptor * @returns {string} */ addInterceptor(interceptor: Interceptor): string; /** * Remove an interceptor from the registry * * @param {string} token */ removeInterceptor(token: string): void; } export declare const evaServiceInterceptors: InterceptorRepository; //# sourceMappingURL=interceptors.d.ts.map