/**
 * Includes all the scripts needed by the queue and jobs.
 */
/// <reference types="node" />
import { JobJson, JobJsonRaw, JobsOptions, RedisClient, KeepJobs } from '../interfaces';
import { JobState, FinishedStatus, FinishedPropValAttribute } from '../types';
import { QueueBase } from './queue-base';
import { Job, MoveToWaitingChildrenOpts } from './job';
export declare type MinimalQueue = Pick<QueueBase, 'name' | 'client' | 'toKey' | 'keys' | 'opts' | 'closing' | 'waitUntilReady' | 'removeListener' | 'emit' | 'on' | 'redisVersion'>;
export declare type ParentOpts = {
    waitChildrenKey?: string;
    parentDependenciesKey?: string;
    parentKey?: string;
};
export declare type JobData = [JobJsonRaw | number, string?];
export declare class Scripts {
    protected queue: MinimalQueue;
    constructor(queue: MinimalQueue);
    isJobInList(listKey: string, jobId: string): Promise<boolean>;
    addJob(client: RedisClient, job: JobJson, opts: JobsOptions, jobId: string, parentOpts?: ParentOpts): Promise<string>;
    pause(pause: boolean): Promise<void>;
    private removeRepeatableArgs;
    removeRepeatable(repeatJobId: string, repeatJobKey: string): Promise<number>;
    remove(jobId: string): Promise<number>;
    extendLock(jobId: string, token: string, duration: number): Promise<number>;
    updateData<T = any, R = any, N extends string = string>(job: Job<T, R, N>, data: T): Promise<void>;
    updateProgress<T = any, R = any, N extends string = string>(job: Job<T, R, N>, progress: number | object): Promise<void>;
    protected moveToFinishedArgs<T = any, R = any, N extends string = string>(job: Job<T, R, N>, val: any, propVal: FinishedPropValAttribute, shouldRemove: boolean | number | KeepJobs, target: FinishedStatus, token: string, timestamp: number, fetchNext?: boolean): (string | number | boolean | Buffer)[];
    protected moveToFinished<DataType = any, ReturnType = any, NameType extends string = string>(job: Job<DataType, ReturnType, NameType>, val: any, propVal: FinishedPropValAttribute, shouldRemove: boolean | number | KeepJobs, target: FinishedStatus, token: string, fetchNext: boolean): Promise<JobData | []>;
    finishedErrors(code: number, jobId: string, command: string, state?: string): Error;
    private drainArgs;
    drain(delayed: boolean): Promise<void>;
    moveToCompleted<T = any, R = any, N extends string = string>(job: Job<T, R, N>, returnvalue: R, removeOnComplete: boolean | number | KeepJobs, token: string, fetchNext: boolean): Promise<JobData | []>;
    moveToFailedArgs<T = any, R = any, N extends string = string>(job: Job<T, R, N>, failedReason: string, removeOnFailed: boolean | number | KeepJobs, token: string, fetchNext?: boolean): (string | number | boolean | Buffer)[];
    isFinished(jobId: string, returnValue?: boolean): Promise<number | [number, string]>;
    getState(jobId: string): Promise<JobState | 'unknown'>;
    changeDelay(jobId: string, delay: number): Promise<void>;
    private changeDelayArgs;
    moveToDelayedArgs(jobId: string, timestamp: number, token: string): string[];
    moveToWaitingChildrenArgs(jobId: string, token: string, opts?: MoveToWaitingChildrenOpts): string[];
    moveToDelayed(jobId: string, timestamp: number, token?: string): Promise<void>;
    /**
     * Move parent job to waiting-children state.
     *
     * @returns true if job is successfully moved, false if there are pending dependencies.
     * @throws JobNotExist
     * This exception is thrown if jobId is missing.
     * @throws JobLockNotExist
     * This exception is thrown if job lock is missing.
     * @throws JobNotInState
     * This exception is thrown if job is not in active state.
     */
    moveToWaitingChildren(jobId: string, token: string, opts?: MoveToWaitingChildrenOpts): Promise<boolean>;
    /**
     * Remove jobs in a specific state.
     *
     * @returns Id jobs from the deleted records.
     */
    cleanJobsInSet(set: string, timestamp: number, limit?: number): Promise<string[]>;
    retryJobArgs(jobId: string, lifo: boolean, token: string): string[];
    protected retryJobsArgs(state: FinishedStatus, count: number, timestamp: number): (string | number)[];
    retryJobs(state?: FinishedStatus, count?: number, timestamp?: number): Promise<number>;
    /**
     * Attempts to reprocess a job
     *
     * @param job -
     * @param state - The expected job state. If the job is not found
     * on the provided state, then it's not reprocessed. Supported states: 'failed', 'completed'
     *
     * @returns Returns a promise that evaluates to a return code:
     * 1 means the operation was a success
     * 0 means the job does not exist
     * -1 means the job is currently locked and can't be retried.
     * -2 means the job was not found in the expected set
     */
    reprocessJob<T = any, R = any, N extends string = string>(job: Job<T, R, N>, state: 'failed' | 'completed'): Promise<void>;
    moveToActive(token: string, jobId?: string): Promise<[] | [number | JobJsonRaw, string?]>;
    /**
     * It checks if the job in the top of the delay set should be moved back to the
     * top of the  wait queue (so that it will be processed as soon as possible)
     */
    updateDelaySet(delayedTimestamp: number): Promise<[number, string]>;
    promote(jobId: string): Promise<number>;
    /**
     * Looks for unlocked jobs in the active queue.
     *
     * The job was being worked on, but the worker process died and it failed to renew the lock.
     * We call these jobs 'stalled'. This is the most common case. We resolve these by moving them
     * back to wait to be re-processed. To prevent jobs from cycling endlessly between active and wait,
     * (e.g. if the job handler keeps crashing),
     * we limit the number stalled job recoveries to settings.maxStalledCount.
     */
    moveStalledJobsToWait(): Promise<[string[], string[]]>;
    obliterate(opts: {
        force: boolean;
        count: number;
    }): Promise<number>;
}
export declare function raw2jobData(raw: any[]): [JobJsonRaw | number, string?] | [];
