import type { Nullable } from '../types/misc.js'; import type { CallerResponse, IRequestConfig } from './call.types.js'; import type { IEndpointInfo } from './endpoint.types.js'; export type CallerHooks = { /** * Called before config is created, to validate result input data. * May throw to abort request. Use for input validation if needed. * Objects are cloned to avoid mutation. */ beforeConfig?: (api: T, body: IEndpointInfo.ExtractIn, pathParams: IEndpointInfo.ExtractPath, queryParams: IEndpointInfo.ExtractQuery) => CallerHooks.HookReturnType; /** * Called before request is sent. * The config can be mutated or returned as updated object – in the latter case it will be merged into original config via `Object.assign`. * This is useful for adding headers or modifying request data. */ beforeRequest?: >(config: IRequestConfig) => CallerHooks.HookReturnType>; /** * Called after response is receieved. * The config can be mutated or returned as updated object – in the latter case it will be merged into original config via `Object.assign`. * This is useful for adding headers or modifying request data. */ afterResponse?: , TOut = IEndpointInfo.ExtractOut, TResponse extends CallerResponse = CallerResponse>(config: IRequestConfig, response: TResponse) => CallerHooks.HookReturnType; }; export declare namespace CallerHooks { type HookReturnType = T | Promise; function merge(items: Nullable | CallerHooks[]>): CallerHooks; }