/** * Input parameter of a middleware. */ export interface MiddlewareOptions> { /** * Initial function enriched by the middleware e.g. axios request getting a timeout. */ readonly fn: MiddlewareFunction; /** * Context of the execution e.g. the request context or URL. */ context: ContextT; } /** * Minimal Context of the middleware. */ export interface MiddlewareContext { /** * URI of the function passed to the middleware. */ readonly uri: string; /** * Tenant identifier. */ readonly tenantId: string | undefined; } /** * Function around which the middlewares are added. */ export type MiddlewareFunction = (arg: ArgumentT) => Promise; /** * Middleware type - This function takes some initial function and returns a function. * The input containing the initial function and some context information e.g. axios request and the request context. * It returns a new functions with some additional feature e.g. timeout. */ export type Middleware> = (options: MiddlewareOptions) => MiddlewareFunction; /** * Helper function to join a list of middlewares given an initial input. * @param middlewares - Middlewares to be layered around the function. * @param context - Context for the middleware execution. * @param fn - Function around which the middlewares are added. * @returns Function with middlewares layered around it. * @internal */ export declare function executeWithMiddleware>(middlewares: Middleware[] | undefined, { fn, context, fnArgument }: MiddlewareOptions & { fnArgument: ArgumentT; }): Promise;