/**
 * @module Resilience
 */
import { type IReadableContext } from "../../../execution-context/contracts/_module.js";
import { type MiddlewareFn } from "../../../middleware/contracts/_module.js";
import { type ITimeSpan } from "../../../time-span/contracts/_module.js";
import { TimeSpan } from "../../../time-span/implementations/_module.js";
import { type Invokable } from "../../../utilities/_module.js";
/**
 * IMPORT_PATH: `"@daiso-tech/core/resilience"`
 * @group Middlewares
 */
export type OnTimeoutData<TParameters extends Array<unknown> = Array<unknown>> = {
    waitTime: TimeSpan;
    args: TParameters;
    context: IReadableContext;
};
/**
 * IMPORT_PATH: `"@daiso-tech/core/resilience"`
 * @group Middlewares
 */
export type OnTimeout<TParameters extends Array<unknown> = Array<unknown>> = Invokable<[data: OnTimeoutData<TParameters>]>;
/**
 * IMPORT_PATH: `"@daiso-tech/core/resilience"`
 * @group Middlewares
 */
export type TimeoutCallbacks<TParameters extends Array<unknown> = Array<unknown>> = {
    /**
     * Callback {@link Invokable | `Invokable`} that will be called before the timeout occurs.
     */
    onTimeout?: OnTimeout<TParameters>;
};
/**
 * Configuration for the `timeout` resilience middleware.
 * Rejects if the middleware result does not complete within the specified time; it does not cancel or abort next().
 *
 * IMPORT_PATH: `"@daiso-tech/core/resilience"`
 * @group Middlewares
 */
export type TimeoutSettings<TParameters extends Array<unknown> = Array<unknown>> = TimeoutCallbacks<TParameters> & {
    /**
     * The maximum time to wait before automatically aborting the executing function.
     *
     * @default
     * ```ts
     * import { TimeSpan } from "@daiso-tech/core/time-span";
     *
     * TimeSpan.fromSeconds(2)
     * ```
     */
    waitTime?: ITimeSpan;
};
/**
 * The `timeout` middleware automatically cancels functions after a specified time period, throwing an error when aborted.
 *
 * IMPORT_PATH: `"@daiso-tech/core/resilience"`
 * @group Middlewares
 * @throws {TimeoutResilienceError}
 */
export declare function timeout<TParameters extends Array<unknown>, TReturn>(settings?: NoInfer<TimeoutSettings<TParameters>>): MiddlewareFn<TParameters, Promise<TReturn>>;
