import { QueueDataType, DispatcherOptionsType, DispatcherStorageType, ResolvedQueueDataType, ResolvedQueueItemType, RunningRequestValueType } from '.';
import { ClientInstance } from '../client';
import { EventEmitter } from '../utils';
import { RequestInstance } from '../request';
import { AdapterInstance } from '../adapter';
/**
 * Dispatcher controls and manages the requests that are going to be executed with adapter. It manages them based on the options provided with request.
 * This class can also run them with different modes like deduplication, cancelation, queueing or run-all-at-once mode. With it's help we can pause,
 * stop, start and cancel requests.
 */
export declare class Dispatcher<Adapter extends AdapterInstance> {
    options?: DispatcherOptionsType | undefined;
    emitter: EventEmitter;
    events: {
        emitDrained: <Request extends RequestInstance>(values: QueueDataType<Request>, isTriggeredExternally?: boolean) => void;
        emitQueueStatusChanged: <Request extends RequestInstance>(values: QueueDataType<Request>, isTriggeredExternally?: boolean) => void;
        emitQueueChanged: <Request extends RequestInstance>(values: QueueDataType<Request>, isTriggeredExternally?: boolean) => void;
        onDrained: <Request extends RequestInstance>(callback: (values: QueueDataType<Request>) => void) => VoidFunction;
        onDrainedByKey: <Request extends RequestInstance>(queryKey: string, callback: (values: QueueDataType<Request>) => void) => VoidFunction;
        onQueueStatusChange: <Request extends RequestInstance>(callback: (values: QueueDataType<Request>) => void) => VoidFunction;
        onQueueStatusChangeByKey: <Request extends RequestInstance>(queryKey: string, callback: (values: QueueDataType<Request>) => void) => VoidFunction;
        onQueueChange: <Request extends RequestInstance>(callback: (values: QueueDataType<Request>) => void) => VoidFunction;
        onQueueChangeByKey: <Request extends RequestInstance>(queryKey: string, callback: (values: QueueDataType<Request>) => void) => VoidFunction;
    };
    storage: DispatcherStorageType;
    private requestCount;
    private runningRequests;
    private logger;
    private client;
    constructor(options?: DispatcherOptionsType | undefined);
    private isRequestJSON;
    initialize: (client: ClientInstance<{
        adapter: Adapter;
    }>) => this;
    /**
     * Start request handling by queryKey
     */
    start: (queryKey: string) => void;
    /**
     * Pause request queue, but do not cancel already started requests
     */
    pause: (queryKey: string) => void;
    /**
     * Stop request queue and cancel all started requests - those will be treated like not started
     */
    stop: (queryKey: string) => void;
    /**
     * Return all queue keys currently tracked by the dispatcher storage
     */
    getQueuesKeys: () => string[];
    /**
     * Return queue state object.
     * Automatically reconstructs any serialized (JSON) requests back into
     * proper Request class instances so the rest of the pipeline can rely on
     * having a real `RequestInstance`.
     */
    getQueue: <R extends RequestInstance = RequestInstance>(queryKey: string) => ResolvedQueueDataType<R>;
    /**
     * Return request from queue state
     */
    getRequest: <Request extends RequestInstance = RequestInstance>(queryKey: string, requestId: string) => import('.').QueueItemType<Request> | undefined;
    /**
     * Get value of the active queue status based on the stopped status
     */
    getIsActiveQueue: (queryKey: string) => boolean;
    /**
     * Add new element to storage
     */
    addQueueItem: <Request extends RequestInstance = RequestInstance>(queryKey: string, element: ResolvedQueueItemType<Request>) => void;
    /**
     * Set new queue storage value
     */
    setQueue: <Request extends RequestInstance = RequestInstance>(queryKey: string, queue: ResolvedQueueDataType<Request>) => ResolvedQueueDataType<Request>;
    /**
     * Clear requests from queue cache
     */
    clearQueue: (queryKey: string) => {
        queryKey: string;
        requests: never[];
        stopped: boolean;
    };
    /**
     * Method used to flush the queue requests
     */
    flushQueue: (queryKey: string) => Promise<void>;
    /**
     * Flush all available requests from all queues
     */
    flush: () => Promise<void>;
    /**
     * Clear all running requests and storage
     */
    clear: () => void;
    /**
     * Start particular request
     */
    startRequest: (queryKey: string, requestId: string) => void;
    /**
     * Stop particular request
     */
    stopRequest: (queryKey: string, requestId: string) => void;
    /**
     * Get currently running requests from all queryKeys
     */
    getAllRunningRequests: () => RunningRequestValueType[];
    /**
     * Get currently running requests
     */
    getRunningRequests: (queryKey: string) => RunningRequestValueType[];
    /**
     * Get running request by id
     */
    getRunningRequest: (queryKey: string, requestId: string) => RunningRequestValueType | undefined;
    /**
     * Add request to the running requests list
     */
    addRunningRequest: (queryKey: string, requestId: string, request: RequestInstance) => RunningRequestValueType;
    /**
     * Get the value based on the currently running requests
     */
    hasRunningRequests: (queryKey: string) => boolean;
    /**
     * Check if request is currently processing
     */
    hasRunningRequest: (queryKey: string, requestId: string) => boolean;
    /**
     * Cancel all started requests, but do NOT remove it from main storage
     */
    cancelRunningRequests: (queryKey: string) => void;
    /**
     * Cancel started request, but do NOT remove it from main storage
     */
    cancelRunningRequest: (queryKey: string, requestId: string) => void;
    /**
     * Delete all started requests, but do NOT clear it from queue and do NOT cancel them
     */
    deleteRunningRequests: (queryKey: string) => void;
    /**
     * Delete request by id, but do NOT clear it from queue and do NOT cancel them
     */
    deleteRunningRequest: (queryKey: string, requestId: string) => void;
    /**
     * Get count of requests from the same queryKey
     */
    getQueueRequestCount: (queryKey: string) => number;
    /**
     * Add request count to the queryKey
     */
    incrementQueueRequestCount: (queryKey: string) => void;
    /**
     * Create storage element from request
     */
    createStorageItem: <R extends RequestInstance>(request: R) => ResolvedQueueItemType<R>;
    /**
     * Add request to the dispatcher handler
     */
    add: (request: RequestInstance) => string;
    /**
     * Delete from the storage and cancel request
     */
    delete: (queryKey: string, requestId: string, abortKey: string) => ResolvedQueueDataType<RequestInstance> | undefined;
    /**
     * Request can run for some time, once it's done, we have to check if it's successful or if it was aborted
     * It can be different once the previous call was set as cancelled and removed from queue before this request got resolved
     */
    performRequest: (storageItem: ResolvedQueueItemType) => Promise<void | ResolvedQueueDataType<RequestInstance>>;
}
//# sourceMappingURL=dispatcher.d.ts.map