import { Logger } from "../index.js";
/**
 * Function that define the amount of time between calls
 */
export type WaitDelayer = (retries: number) => number;
/**
 * Return a delayer that always wait for the same amount of time
 * @param pause amount of time to wait
 * @returns
 */
export declare function WaitLinearDelay(pause: number): WaitDelayer;
/**
 * Return a delayer that always wait for the same amount of time
 * @param pause amount of time to wait
 * @returns
 */
export declare function WaitExponentialDelay(pause: number): WaitDelayer;
/**
 * Delayer factory definition
 */
export type WaitDelayerFactory = (interval: number) => WaitDelayer;
/**
 * WaitDelayer definition
 */
export interface WaitDelayerDefinition {
    /**
     * Interval
     */
    interval: number;
    /**
     * Type of delayer registered in WaitDelayerFactoryRegistry
     */
    type: string;
}
/**
 * Registry for DelayerFactory
 */
export declare class WaitDelayerFactories {
    static registry: {
        [key: string]: WaitDelayerFactory;
    };
    /**
     * Add a delayer
     * @param type
     * @param delayer
     */
    static registerFactory(type: string, delayer: WaitDelayerFactory): void;
    /**
     * Return a registered delayer
     * @param type
     * @returns
     */
    static getFactory(type: string): WaitDelayerFactory;
    /**
     *
     * @param definition to get delayer from
     * @returns
     */
    static get(definition?: WaitDelayerDefinition): WaitDelayer;
}
/**
 * Wait for an operation to end
 *
 * Some AWS Api require minutes and polling
 * This method will call the callback function until it returns
 * `true`, or the max `retries` has been reached.
 * Between each call, it will wait the `delay`
 *
 * If it reaches the max retries without a good answer from
 * callback, the Promise will be rejected
 *
 * @param callback to call between each call
 * @param retries max number of retries
 * @param title to display
 * @param logger logger to use to report
 * @param delayer function that return pause between each call default to WaitExponential(1000)
 */
export declare function WaitFor<T = any>(callback: (resolve: (value?: T) => void, reject?: (reason?: any) => void) => Promise<boolean>, retries: number, title?: string, logger?: Logger, delayer?: WaitDelayer): Promise<T>;
/**
 * Return a promise that can be cancelled
 */
export declare class CancelablePromise<T = void> extends Promise<T> {
    cancel: () => Promise<void>;
    constructor(callback?: (resolve: (res: T) => void, reject: (err: any) => void) => void, onCancel?: () => Promise<void>);
}
/**
 * Create a promise that will loop on the same callback until cancelled
 */
export declare class CancelableLoopPromise extends Promise<void> {
    cancel: () => Promise<void>;
    constructor(callback: (canceller: () => Promise<void>) => Promise<void>, onCancel?: () => Promise<void>);
    static get [Symbol.species](): PromiseConstructor;
}
