import { DefaultJobOptions, Job, Queue, Worker } from "bullmq";
import { Consumers, JobExecuter, WorkerOptions } from "../types";
/**
 * This is the common queue management class for the Lexamica Message Queue package. This class provides a protected API for using the Lexamica message queues that provents the erroneous mutiliating, processing, or deleting of message queues and their jobs. Create an instance of this class, and then call the .init() function to start.
 */
export declare class CommonQueueManagement {
    private queues;
    private workers;
    private jobs;
    private delayed_jobs;
    private listeners;
    private init_names;
    private context;
    private access_control;
    private initialized;
    private QUEUES;
    private WORKERS;
    private JOBS;
    /**
     * The constructor that accepts the config props necessary to create a class instance
     * @param {string[]} initQueues the list of queue names to initialize. This will likely be managed by the specific instance sub-class you should be using.
     * @param {Consumers} context one of the available instances defined. Your instance sub-class will automatically provide this.
     * @param {string} connection_url the connection url to a Redis DB. If no connection url is given, a local Redis instance will be used.
     */
    constructor(initQueues: string[], context: Consumers, connection_url?: string);
    /**
     * Create the default queues and start tracking them in this class instance. Each queue will also either be created in Redis, or hooked into an existing instance of that queue set up previously.
     * @param {{ [name: string]: JobExecuter }} executors A object with the keys set to queue names, and the values set to the default worker execution functions that will be assigned to the workers in this queue. Additional workers with different execution functions can be added later.
     * @param {number} workers How many workers to create by default for this queue. If you are unsure, pick 1.
     */
    init: (executors: {
        [name: string]: JobExecuter;
    }, workers: number) => Promise<void>;
    /**
     * Utility function that throws an error if queues have not been initialized before trying to call class functions
     * @throws {Error} Queues have not been initialized. Call the .init() method.
     */
    private _checkInit;
    /**
     * Utility function that throws an error if the queue specified has not been created in this instance
     * @param {string} queue_name the name of the queue
     * @throws {Error} Queue has likely not been created in this class instance.
     */
    private _verifyQueue;
    /**
     * Utility function that verifies that the current instance sub-class of this class is allowed to perform the queue action desired. This protects instances from process, deleting, etc. jobs not intended for them.
     * @param {string} queue_name The name of the queue being checked
     * @param {QueuePermissions} access one of the queue permissions like READ, WRITE, etc.
     * @throws {Error} queue access is denied for the given access type
     * @returns {boolean} returns true if access is allowed. Throws an error otherwise
     */
    private _verifyAccess;
    /**
     * Accepts a job ID in an object and removes it from the applicable tracked jobs list.
     * @param {{ jobId: string }} param0
     */
    private _removeJob;
    /**
     * Gets the list of queues being tracked in this class instance
     * @returns {Record<string, Queue>}
     */
    getQueues: () => Record<string, Queue>;
    /**
     * Gets the list of workers currently being tracked against the queue given in this class instance
     * @param {string} queue_name the name of the queue
     * @returns {Worker[]}
     */
    getWorkers(queue_name: string): Worker[];
    /**
     * Gets the non-delayed jobs currently being tracked in this class instance. NOTE: this does not represent all jobs in the Redis queue, and may not even be completely consistent for this class instance. This is mainly to aid in finding a Job instance or ID if possible.
     * @param {string} queue_name the name of the queue the job is in
     * @param {boolean} withData set to true to get the job data payload as well
     * @returns An object with the keys set to the job IDs and the values set to a job payload.
     */
    getJobs(queue_name: string, withData?: boolean): Record<string, {
        queue: string;
        attempts: number;
        status: string;
        data: Record<string, unknown>;
    }>;
    /**
     * Gets the delayed jobs currently being tracked in this class instance. NOTE: this does not represent all jobs in the Redis queue, and may not even be completely consistent for this class instance. This is mainly to aid in finding a Job instance or ID if possible.
     * @param {string} queue_name the name of the queue the job is in
     * @param {boolean} withData set to true to get the job data payload as well
     * @returns An object with the keys set to the job IDs and the values set to a job payload.
     */
    getDelayedJobs(queue_name: string, withData?: boolean): Record<string, {
        queue: string;
        attempts: number;
        status: string;
        data: Record<string, unknown>;
    }>;
    /**
     * Add a new queue instance to this class instance. This will create the queue in Redis if it does not exist, or will link to an existing queue in Redis with the same name.
     * @param {string} queue_name the name of the queue
     * @param {number} workers the number of workers to initialize with this queue
     * @param {JobExecuter} executer the execution function to assign to this queue's workers
     * @returns {Promise<{ queue: Queue | null; workers: Worker[] }>}
     */
    addQueue: (queue_name: string, workers: number, executer: JobExecuter) => Promise<{
        queue: Queue | null;
        workers: Worker[];
    }>;
    /**
     * Removes all jobs associated with this queue
     * @param {string} queue_name the name of the queue
     * @returns {Promise<boolean>}
     */
    clearQueue: (queue_name: string) => Promise<boolean>;
    /**
     * Remove the queue from this class instance and from the Redis DB
     * @param {string} queue_name the name of the queue
     * @returns {Promise<boolean>}
     */
    deleteQueue: (queue_name: string) => Promise<boolean>;
    /**
     * Create a new worker in this instance
     * @param {string} queue_name the queue to assign this worker to
     * @param {JobExecuter} executer the function to execute for this worker's jobs
     * @param {WorkerOptions} options the config options to configure the worker
     * @returns {Worker | void}
     */
    addWorker: (queue_name: string, executer: JobExecuter, options: WorkerOptions) => Worker | void;
    /**
     * Finished current jobs and close the worker from accepting any more jobs
     * @param {Worker} worker the worker instance to close
     * @returns {Promise<void>}
     */
    closeWorker: (queue_name: string, worker: Worker) => Promise<void>;
    /**
     * Finished all jobs in a queue and close all of its workers from accepting new jobs
     * @param {string} queue_name the name of the queue to close all workers in
     * @returns {Promise<void>}
     */
    closeAllWorkersInQueue: (queue_name: string) => Promise<void>;
    /**
     * Add a new job to a queue
     * @param {string} queue_name name of the queue
     * @param {string} job_name the name to assign this job
     * @param {Record<string, unknown>} job_data data payload to attach to this job
     * @param {DefaultJobOptions} job_options job options to config this job
     * @param {number} delay add an optional processing delay to this job in milliseconds
     * @returns {Promise<Job | void>}
     */
    addJob: (queue_name: string, job_name: string, job_data: Record<string, unknown>, job_options: DefaultJobOptions, delay?: number) => Promise<Job | void>;
    /**
     * Cancel a job and pervent it from processing.
     * @param {Job} job instance of the job to cancel
     * @returns {Promise<boolean>}
     */
    cancelJob: (job: Job) => Promise<boolean>;
    /**
     * Cancel all jobs being tracked in this instance in a given queue from executing
     * @param {string} queue_name name of the queue
     * @returns {Promise<number>}
     */
    cancelAllJobsInQueue: (queue_name: string) => Promise<number>;
}
