import type { AsyncHandlerInput, AsyncHandlerOutput } from './AsyncHandler'; import { AsyncHandler } from './AsyncHandler'; /** * Utility handler that allows combining the results of multiple handlers into one. * Will run the handlers and then call the abstract `combine` function with the results, * which then generates the handler's output. */ export declare abstract class UnionHandler> extends AsyncHandler, AsyncHandlerOutput> { protected readonly handlers: T[]; protected readonly requireAll: boolean; protected readonly ignoreErrors: boolean; /** * Creates a new `UnionHandler`. * * When `requireAll` is false or `ignoreErrors` is true, * the length of the input to `combine` can vary; * otherwise, it is exactly the number of handlers. * * @param handlers - The handlers whose output is to be combined. * @param requireAll - If true, will fail if any of the handlers do not support the input. If false, only the handlers that support the input will be called; * will fail only if none of the handlers can handle the input. * @param ignoreErrors - If true, ignores handlers that fail by omitting their output; * if false, fails when any handlers fail. */ constructor(handlers: T[], requireAll?: boolean, ignoreErrors?: boolean); canHandle(input: AsyncHandlerInput): Promise; handle(input: AsyncHandlerInput): Promise>; /** * Checks if all handlers can handle the input. * If not, throw an error based on the errors of the failed handlers. */ protected allCanHandle(input: AsyncHandlerInput): Promise; /** * Combines the results of the handlers into a single output. */ protected abstract combine(results: AsyncHandlerOutput[]): Promise>; } /** * Obtains the values of all fulfilled promises. * If there are rejections, and `ignoreErrors` is false, a combined error of all rejected promises is thrown. */ export declare function allFulfilled(promises: Promise[], ignoreErrors?: boolean): Promise;