import type { AnyAsyncMiddleware, ErrorMiddleware, ErrorMiddlewareAsync, MiddlewareAsync, MiddlewarePromise, OptionsResponse } from './shared.js'; export interface ExtendableIndexedMiddleware { } /** * MiddlewareIndexedAsync class that implements MiddlewareAsync and ExtendableIndexedMiddleware. * @template T - The type of the arguments. * @template TMiddleware - The type of the middleware. */ export declare class MiddlewareIndexedAsync> implements MiddlewareAsync, ExtendableIndexedMiddleware { private getIndexKey; readonly name?: string; protected _delegate: MiddlewareAsync; /** * Constructor for MiddlewareIndexedAsync. * @param {function} getIndexKey - Function to get the index key. * @param {string} [name] - Optional name for the middleware. */ constructor(getIndexKey: (...args: T) => string, name?: string); /** * Get the keys of the index. * @returns {string[]} The keys of the index. */ protected getKeys(): string[]; protected readonly index: Record & { ''?: ErrorMiddleware; }; /** * Use middleware for a specific key. * @param {null|string} key - The key for the middleware. * @param {AnyAsyncMiddleware} middleware - The middleware to use. * @returns {this} The instance of MiddlewareIndexedAsync. */ useMiddleware(key: null, middleware: MiddlewareAsync): this; useMiddleware(key: '', middleware: ErrorMiddlewareAsync): this; useMiddleware(key: string, middleware: TMiddleware): this; /** * Use an error handler. * @param {function} handler - The error handler function. * @returns {this} The instance of MiddlewareIndexedAsync. */ useError(handler: ((error: Error | OptionsResponse, ...args: T) => Promise)): this; /** * Process the request. * @template X - The type of the return value. * @param {...T} req - The request arguments. * @returns {Promise} The result of the processing. */ process(...req: T): Promise; /** * Handle an error. * @param {Error|OptionsResponse} error - The error to handle. * @param {...T} req - The request arguments. * @returns {MiddlewarePromise} The result of the error handling. */ handleError(error: Error | OptionsResponse, ...req: T): MiddlewarePromise; /** * Handle the request. * @param {...T} req - The request arguments. * @returns {MiddlewarePromise} The result of the handling. */ handle(...req: T): MiddlewarePromise; }