"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.__tsfTypeAliases = exports.WorkerQueueRegistry = void 0;
const tslib_1 = require("tslib");
const _a = tslib_1.__importStar(require("@zyno-io/ts-reflection/type-metadata-runtime"));
const redis_1 = require("../../helpers/redis/redis");
const observer_1 = require("./observer");
const bullmq_1 = require("bullmq");
const __tsf_metadata_type = _a.createCompactMetadataRegistryV1("[1,[{\"kind\":8},{\"kind\":6},{\"kind\":2,\"typeName\":\"JobClass\"},{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},{\"kind\":2,\"typeName\":\"JobClass\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"I\"}]},{\"kind\":2,\"typeName\":\"I\"},{\"kind\":2},{\"kind\":3},{\"kind\":14,\"type\":{\"kind\":18,\"typeName\":\"BullMqCronJobSchedule\",\"types\":[{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"pattern\",\"type\":{\"kind\":6},\"optional\":false}]}},{\"kind\":22,\"type\":{\"kind\":14,\"type\":{\"kind\":18,\"typeName\":\"RemovedBullMqJobScheduler\",\"types\":[{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"pattern\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"key\",\"type\":{\"kind\":6},\"optional\":false}]}}},{\"kind\":22,\"type\":{\"kind\":3}},{\"kind\":12,\"types\":[{\"kind\":2,\"typeName\":\"I\"},{\"kind\":5},{\"kind\":4}]}]]", []);
let _WorkerQueueRegistryMetadata_1;
class WorkerQueueRegistry {
    config;
    static queues = new Map();
    static bullQueues = new Set();
    static nextId = 1;
    bullQueues = new Map();
    constructor(config) {
        this.config = config;
    }
    usesBullMq() {
        if (this.config?.APP_ENV === 'test')
            return false;
        return true;
    }
    getDefaultQueueName() {
        return this.config?.BULL_QUEUE ?? 'default';
    }
    getQueueName(jobClass, options = {}) {
        return options.queueName ?? getOwnQueueName(jobClass) ?? this.getDefaultQueueName();
    }
    async enqueue(jobClass, data, options = {}) {
        if (!this.usesBullMq())
            return this.add(jobClass, data, options);
        const queueName = this.getQueueName(jobClass, options);
        const bullJob = await this.getBullQueue(queueName).add(jobClass.name, {
            data,
            options: { ...options }
        }, {
            delay: options.delay,
            removeOnComplete: 1000,
            removeOnFail: 1000
        });
        const job = this.fromBullJob(bullJob, jobClass);
        (0, observer_1.notifyWorkerObservers)({
            type: job.shouldExecuteAt.getTime() > Date.now() ? 'delayed' : 'added',
            job
        });
        return job;
    }
    add(jobClass, data, options = {}) {
        const queue = this.getQueueName(jobClass, options);
        const createdAt = new Date();
        const job = {
            id: String(WorkerQueueRegistry.nextId++),
            queue,
            name: jobClass.name,
            data,
            jobClass,
            options: { ...options },
            createdAt,
            shouldExecuteAt: new Date(createdAt.getTime() + (options.delay ?? 0)),
            attemptsMade: 0,
            status: 'queued'
        };
        const jobs = WorkerQueueRegistry.queues.get(queue) ?? [];
        jobs.push(job);
        WorkerQueueRegistry.queues.set(queue, jobs);
        (0, observer_1.notifyWorkerObservers)({
            type: job.shouldExecuteAt.getTime() > Date.now() ? 'delayed' : 'added',
            job
        });
        return job;
    }
    getQueuedJobs(queue = this.getDefaultQueueName()) {
        return [...(WorkerQueueRegistry.queues.get(queue) ?? [])];
    }
    getAllQueuedJobs() {
        return [...WorkerQueueRegistry.queues.values()].flat();
    }
    markCompleted(job, result) {
        job.status = 'completed';
        job.result = result;
    }
    markFailed(job, result) {
        job.status = 'failed';
        job.result = result;
    }
    remove(job) {
        const jobs = WorkerQueueRegistry.queues.get(job.queue);
        if (!jobs)
            return;
        const remaining = jobs.filter(item => item !== job);
        if (remaining.length)
            WorkerQueueRegistry.queues.set(job.queue, remaining);
        else
            WorkerQueueRegistry.queues.delete(job.queue);
    }
    clear(queue) {
        if (queue)
            WorkerQueueRegistry.queues.delete(queue);
        else
            WorkerQueueRegistry.queues.clear();
    }
    getBullQueue(queueName) {
        const existing = this.bullQueues.get(queueName);
        if (existing)
            return existing;
        const queue = new bullmq_1.Queue(queueName, this.getBullMqOptions());
        this.bullQueues.set(queueName, queue);
        WorkerQueueRegistry.bullQueues.add(queue);
        return queue;
    }
    getBullQueues() {
        return [...this.bullQueues.entries()].map(([name, queue]) => ({ name, queue }));
    }
    async removeStaleBullMqJobSchedulers(desiredSchedules) {
        if (!this.usesBullMq())
            return [];
        const desiredByQueue = new Map();
        for (const schedule of desiredSchedules) {
            const queueSchedules = desiredByQueue.get(schedule.queue) ?? new Map();
            queueSchedules.set(schedule.name, schedule);
            desiredByQueue.set(schedule.queue, queueSchedules);
        }
        const removed = [];
        for (const queueName of await this.discoverBullMqJobSchedulerQueueNames()) {
            const queue = this.getBullQueue(queueName);
            const desiredQueueSchedules = desiredByQueue.get(queueName);
            const staleRepeatKeys = new Set();
            for (const scheduler of await queue.getJobSchedulers()) {
                const isTsfScheduler = isTsfBullMqJobScheduler(scheduler);
                if (!isTsfScheduler)
                    continue;
                const desired = desiredQueueSchedules?.get(scheduler.name);
                const matchesDesiredSchedule = desired !== undefined && desired.pattern === scheduler.pattern && scheduler.key === `${desired.name}:${desired.pattern}`;
                if (matchesDesiredSchedule)
                    continue;
                staleRepeatKeys.add(scheduler.key);
                const wasRemoved = await queue.removeJobScheduler(scheduler.key);
                if (wasRemoved) {
                    removed.push({
                        queue: queueName,
                        name: scheduler.name,
                        pattern: scheduler.pattern,
                        key: scheduler.key
                    });
                }
            }
            // BullMQ materializes the next occurrence before it invokes the worker handler. Removing
            // only a scheduler therefore leaves an already-created occurrence able to keep an
            // orphaned chain alive. Reconcile pending occurrences after definitions are gone as well.
            await this.removePendingBullMqRepeatJobs(queue, desiredQueueSchedules, staleRepeatKeys);
        }
        return removed;
    }
    /**
     * Stops a repeat chain after a worker has received an unregistered repeat job. This is a
     * defensive backstop for a job that was materialized while a stale scheduler was being removed.
     */
    async removeBullMqRepeatChain(queueName, repeatKey) {
        if (!this.usesBullMq())
            return;
        const queue = this.getBullQueue(queueName);
        await queue.removeJobScheduler(repeatKey);
        await this.removePendingBullMqRepeatJobs(queue, undefined, new Set([repeatKey]));
    }
    normalizeJobData(data) {
        return (data === undefined ? {} : data);
    }
    fromBullJob(job, jobClass) {
        const createdAt = new Date(job.timestamp);
        const delay = typeof job.delay === 'number' ? job.delay : Number(job.opts.delay ?? 0);
        const payload = this.unwrapBullMqJobData(job.data);
        return {
            id: String(job.id ?? ''),
            queue: job.queueName,
            name: job.name,
            data: this.normalizeJobData(payload.data),
            jobClass,
            options: { ...payload.options },
            createdAt,
            shouldExecuteAt: new Date(createdAt.getTime() + delay),
            attemptsMade: job.attemptsMade,
            status: 'queued'
        };
    }
    async shutdown() {
        await Promise.all([...this.bullQueues.values()].map(closeBullQueue));
        for (const queue of this.bullQueues.values())
            WorkerQueueRegistry.bullQueues.delete(queue);
        this.bullQueues.clear();
    }
    static async closeQueues() {
        WorkerQueueRegistry.queues.clear();
        const queues = [...WorkerQueueRegistry.bullQueues];
        WorkerQueueRegistry.bullQueues.clear();
        await Promise.all(queues.map(closeBullQueue));
    }
    getBullMqOptions() {
        const config = this.config;
        if (!config) {
            throw new Error('BullMQ workers require app config');
        }
        let options;
        let prefix;
        try {
            ({ options, prefix } = (0, redis_1.createRedisOptions)('BULL'));
        }
        catch (error) {
            throw new Error('BullMQ workers require REDIS_HOST or REDIS_SENTINEL_HOST (or BULL_REDIS_HOST/BULL_REDIS_SENTINEL_HOST) to be configured', { cause: error });
        }
        const { retryStrategy, ...redisOptions } = options;
        const connection = {
            ...redisOptions,
            ...(retryStrategy ? { retryStrategy } : {}),
            maxRetriesPerRequest: null
        };
        return {
            connection,
            prefix: `${prefix}:bmq`
        };
    }
    unwrapBullMqJobData(raw) {
        if (isRecord(raw) && isWorkerPayloadWrapper(raw)) {
            const wrapped = raw;
            return {
                data: wrapped.data,
                options: isRecord(wrapped.options) ? { ...wrapped.options } : {}
            };
        }
        return { data: raw, options: {} };
    }
    async discoverBullMqJobSchedulerQueueNames() {
        const prefix = this.getBullMqOptions().prefix ?? 'bull';
        const discoveryQueue = this.getBullQueue(this.getDefaultQueueName());
        const client = await discoveryQueue.getBackend().client;
        const queueNames = new Set(this.bullQueues.keys());
        const keyPrefix = `${prefix}:`;
        const keySuffix = ':repeat';
        let cursor = '0';
        do {
            const result = await client.scan(cursor, { MATCH: `${escapeRedisGlob(prefix)}:*${keySuffix}`, COUNT: 100 });
            cursor = result[0];
            for (const key of result[1]) {
                if (!key.startsWith(keyPrefix) || !key.endsWith(keySuffix))
                    continue;
                const queueName = key.slice(keyPrefix.length, -keySuffix.length);
                if (queueName && !queueName.includes(':'))
                    queueNames.add(queueName);
            }
        } while (cursor !== '0');
        return [...queueNames].sort();
    }
    async removePendingBullMqRepeatJobs(queue, desiredSchedules, staleRepeatKeys) {
        const jobs = await queue.getJobs(['wait', 'delayed', 'prioritized', 'waiting-children']);
        for (const job of jobs) {
            const repeatKey = job.repeatJobKey;
            if (!repeatKey)
                continue;
            const desired = desiredSchedules?.get(job.name);
            const matchesDesiredSchedule = desired !== undefined && repeatKey === `${desired.name}:${desired.pattern}`;
            const isTsfRepeatJob = isTsfBullMqRepeatJob(job);
            if (!staleRepeatKeys.has(repeatKey) && (!isTsfRepeatJob || matchesDesiredSchedule))
                continue;
            await job.remove();
        }
    }
    static __tsfType = _WorkerQueueRegistryMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"WorkerQueueRegistry\",\"typeName\":\"WorkerQueueRegistry\",\"classType\":{\"$tsf\":0},\"properties\":[],\"methods\":[{\"name\":\"usesBullMq\",\"parameters\":[],\"returnType\":{\"$tsfType\":0}},{\"name\":\"getDefaultQueueName\",\"parameters\":[],\"returnType\":{\"$tsfType\":1}},{\"name\":\"getQueueName\",\"parameters\":[{\"name\":\"jobClass\",\"type\":{\"$tsfType\":2},\"optional\":false,\"default\":false},{\"name\":\"options\",\"type\":{\"$tsfType\":3},\"optional\":true,\"default\":true}],\"returnType\":{\"$tsfType\":1}},{\"name\":\"enqueue\",\"parameters\":[{\"name\":\"jobClass\",\"type\":{\"$tsfType\":4},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":5},\"optional\":false,\"default\":false},{\"name\":\"options\",\"type\":{\"$tsfType\":3},\"optional\":true,\"default\":true}],\"returnType\":{\"kind\":22,\"type\":{\"kind\":18,\"typeName\":\"QueuedWorkerJob\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"jobClass\",\"type\":{\"kind\":2,\"typeName\":\"JobClass\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"I\"}]},\"optional\":false},{\"kind\":20,\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"attemptsMade\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"queued\"},{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"},{\"kind\":10,\"literal\":\"skipped\"}],\"typeName\":\"WorkerJobStatus\"},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2},{\"kind\":4}]},\"optional\":true}]}}},{\"name\":\"add\",\"parameters\":[{\"name\":\"jobClass\",\"type\":{\"$tsfType\":4},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":5},\"optional\":false,\"default\":false},{\"name\":\"options\",\"type\":{\"$tsfType\":3},\"optional\":true,\"default\":true}],\"returnType\":{\"kind\":18,\"typeName\":\"QueuedWorkerJob\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"jobClass\",\"type\":{\"kind\":2,\"typeName\":\"JobClass\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"I\"}]},\"optional\":false},{\"kind\":20,\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"attemptsMade\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"queued\"},{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"},{\"kind\":10,\"literal\":\"skipped\"}],\"typeName\":\"WorkerJobStatus\"},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2},{\"kind\":4}]},\"optional\":true}]}},{\"name\":\"getQueuedJobs\",\"parameters\":[{\"name\":\"queue\",\"type\":{\"$tsfType\":6},\"optional\":true,\"default\":true}],\"returnType\":{\"kind\":14,\"type\":{\"kind\":18,\"typeName\":\"QueuedWorkerJob\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"jobClass\",\"type\":{\"kind\":2,\"typeName\":\"JobClass\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"I\"}]},\"optional\":false},{\"kind\":20,\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"attemptsMade\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"queued\"},{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"},{\"kind\":10,\"literal\":\"skipped\"}],\"typeName\":\"WorkerJobStatus\"},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2},{\"kind\":4}]},\"optional\":true}],\"typeParameters\":[\"I\"]}}},{\"name\":\"getAllQueuedJobs\",\"parameters\":[],\"returnType\":{\"kind\":14,\"type\":{\"kind\":18,\"typeName\":\"QueuedWorkerJob\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"jobClass\",\"type\":{\"kind\":2,\"typeName\":\"JobClass\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"I\"}]},\"optional\":false},{\"kind\":20,\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"attemptsMade\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"queued\"},{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"},{\"kind\":10,\"literal\":\"skipped\"}],\"typeName\":\"WorkerJobStatus\"},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2},{\"kind\":4}]},\"optional\":true}],\"typeParameters\":[\"I\"]}}},{\"name\":\"markCompleted\",\"parameters\":[{\"name\":\"job\",\"type\":{\"kind\":18,\"typeName\":\"QueuedWorkerJob\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"jobClass\",\"type\":{\"kind\":2,\"typeName\":\"JobClass\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"I\"}]},\"optional\":false},{\"kind\":20,\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"attemptsMade\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"queued\"},{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"},{\"kind\":10,\"literal\":\"skipped\"}],\"typeName\":\"WorkerJobStatus\"},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2},{\"kind\":4}]},\"optional\":true}],\"typeParameters\":[\"I\"]},\"optional\":false,\"default\":false},{\"name\":\"result\",\"type\":{\"$tsfType\":6},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"markFailed\",\"parameters\":[{\"name\":\"job\",\"type\":{\"kind\":18,\"typeName\":\"QueuedWorkerJob\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"jobClass\",\"type\":{\"kind\":2,\"typeName\":\"JobClass\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"I\"}]},\"optional\":false},{\"kind\":20,\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"attemptsMade\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"queued\"},{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"},{\"kind\":10,\"literal\":\"skipped\"}],\"typeName\":\"WorkerJobStatus\"},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2},{\"kind\":4}]},\"optional\":true}],\"typeParameters\":[\"I\"]},\"optional\":false,\"default\":false},{\"name\":\"result\",\"type\":{\"$tsfType\":6},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"remove\",\"parameters\":[{\"name\":\"job\",\"type\":{\"kind\":18,\"typeName\":\"QueuedWorkerJob\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"jobClass\",\"type\":{\"kind\":2,\"typeName\":\"JobClass\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"I\"}]},\"optional\":false},{\"kind\":20,\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"attemptsMade\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"queued\"},{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"},{\"kind\":10,\"literal\":\"skipped\"}],\"typeName\":\"WorkerJobStatus\"},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2},{\"kind\":4}]},\"optional\":true}],\"typeParameters\":[\"I\"]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"clear\",\"parameters\":[{\"name\":\"queue\",\"type\":{\"$tsfType\":1},\"optional\":true,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"getBullQueue\",\"parameters\":[{\"name\":\"queueName\",\"type\":{\"$tsfType\":1},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsf\":2}},{\"name\":\"getBullQueues\",\"parameters\":[],\"returnType\":{\"kind\":14,\"type\":{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"$tsf\":3},\"optional\":false}]}}},{\"name\":\"removeStaleBullMqJobSchedulers\",\"parameters\":[{\"name\":\"desiredSchedules\",\"type\":{\"$tsfType\":8},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":9}},{\"name\":\"removeBullMqRepeatChain\",\"parameters\":[{\"name\":\"queueName\",\"type\":{\"$tsfType\":1},\"optional\":false,\"default\":false},{\"name\":\"repeatKey\",\"type\":{\"$tsfType\":1},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":10},\"description\":\"Stops a repeat chain after a worker has received an unregistered repeat job. This is a defensive backstop for a job that was materialized while a stale scheduler was being removed.\"},{\"name\":\"normalizeJobData\",\"parameters\":[{\"name\":\"data\",\"type\":{\"$tsfType\":11},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":5}},{\"name\":\"fromBullJob\",\"parameters\":[{\"name\":\"job\",\"type\":{\"$tsf\":4},\"optional\":false,\"default\":false},{\"name\":\"jobClass\",\"type\":{\"$tsfType\":4},\"optional\":false,\"default\":false}],\"returnType\":{\"kind\":18,\"typeName\":\"QueuedWorkerJob\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"jobClass\",\"type\":{\"kind\":2,\"typeName\":\"JobClass\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"I\"}]},\"optional\":false},{\"kind\":20,\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"attemptsMade\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"queued\"},{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"},{\"kind\":10,\"literal\":\"skipped\"}],\"typeName\":\"WorkerJobStatus\"},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2},{\"kind\":4}]},\"optional\":true}]}},{\"name\":\"shutdown\",\"parameters\":[],\"returnType\":{\"$tsfType\":10}},{\"name\":\"getBullMqOptions\",\"parameters\":[],\"returnType\":{\"kind\":13,\"types\":[{\"$tsfAlias\":[5,\"bullmq\",\"QueueOptions\",\"QueueOptions\"]},{\"kind\":18,\"typeName\":\"Pick\",\"utilityType\":\"Pick\",\"typeArguments\":[{\"$tsfAlias\":[5,\"bullmq\",\"WorkerOptions\",\"WorkerOptions\"]}],\"utilityKeys\":[\"connection\",\"prefix\"],\"types\":[]}]}}],\"hasConstructor\":true,\"constructorParameters\":[{\"name\":\"config\",\"type\":{\"kind\":16,\"typeName\":\"BaseAppConfig\",\"classType\":{\"$tsfImport\":[5,\"../../app/index\",\"BaseAppConfig\"]}},\"optional\":true,\"default\":false}]}]", [() => WorkerQueueRegistry, () => (typeof Date !== "undefined" ? Date : (typeof exports !== "undefined" ? exports.Date : undefined)), Object.assign(_a.resolveCompactMetadataAliasV1(require, "bullmq", "Queue", "Queue"), { typeArguments: [{ kind: 18, typeName: "BullMqWorkerJobData", types: [{ kind: 20, name: "data", type: { kind: 2, typeName: "I" }, optional: false }, { kind: 20, name: "options", type: { kind: 18, typeName: "IJobOptions", types: [{ kind: 20, name: "delay", type: { kind: 12, types: [{ kind: 7 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "queueName", type: { kind: 12, types: [{ kind: 6 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "runInTest", type: { kind: 12, types: [{ kind: 8 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "runImmediately", type: { kind: 12, types: [{ kind: 8 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "recordToDatabase", type: { kind: 12, types: [{ kind: 8 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "repeatKey", type: { kind: 12, types: [{ kind: 6 }, { kind: 4 }] }, optional: true }] }, optional: false }], typeParameters: ["I"] }] }), Object.assign(_a.resolveCompactMetadataAliasV1(require, "bullmq", "Queue", "Queue"), { typeArguments: [{ kind: 18, typeName: "BullMqWorkerJobData", types: [{ kind: 20, name: "data", type: { kind: 2, typeName: "I" }, optional: false }, { kind: 20, name: "options", type: { kind: 18, typeName: "IJobOptions", types: [{ kind: 20, name: "delay", type: { kind: 12, types: [{ kind: 7 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "queueName", type: { kind: 12, types: [{ kind: 6 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "runInTest", type: { kind: 12, types: [{ kind: 8 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "runImmediately", type: { kind: 12, types: [{ kind: 8 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "recordToDatabase", type: { kind: 12, types: [{ kind: 8 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "repeatKey", type: { kind: 12, types: [{ kind: 6 }, { kind: 4 }] }, optional: true }] }, optional: false }], typeParameters: ["I"] }] }), Object.assign(_a.resolveCompactMetadataAliasV1(require, "bullmq", "Job", "BullJob"), { typeArguments: [{ kind: 18, typeName: "BullMqWorkerJobData", types: [{ kind: 20, name: "data", type: { kind: 2, typeName: "I" }, optional: false }, { kind: 20, name: "options", type: { kind: 18, typeName: "IJobOptions", types: [{ kind: 20, name: "delay", type: { kind: 12, types: [{ kind: 7 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "queueName", type: { kind: 12, types: [{ kind: 6 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "runInTest", type: { kind: 12, types: [{ kind: 8 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "runImmediately", type: { kind: 12, types: [{ kind: 8 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "recordToDatabase", type: { kind: 12, types: [{ kind: 8 }, { kind: 4 }] }, optional: true }, { kind: 20, name: "repeatKey", type: { kind: 12, types: [{ kind: 6 }, { kind: 4 }] }, optional: true }] }, optional: false }] }] }), require], __tsf_metadata_type);
}
exports.WorkerQueueRegistry = WorkerQueueRegistry;
_WorkerQueueRegistryMetadata_1.classType = WorkerQueueRegistry;
WorkerQueueRegistry.__tsfType = _WorkerQueueRegistryMetadata_1;
async function closeBullQueue(queue) {
    const clientPromise = queue.getBackend().client.catch(() => undefined);
    try {
        await queue.close();
    }
    catch {
        // Queue cleanup is best-effort during application shutdown.
    }
    // BullMQ closes its ioredis client with QUIT, which leaves Sentinel failover detector
    // subscriptions connected. Disconnect the underlying client to tear those sockets down.
    try {
        (await clientPromise)?.disconnect();
    }
    catch {
        // Force cleanup is also best-effort when graceful cleanup fails.
    }
}
function getOwnQueueName(jobClass) {
    return Object.prototype.hasOwnProperty.call(jobClass, 'QUEUE_NAME') ? jobClass.QUEUE_NAME : undefined;
}
function isRecord(value) {
    return typeof value === 'object' && value !== null;
}
function isWorkerPayloadWrapper(value) {
    if (!Object.prototype.hasOwnProperty.call(value, 'options'))
        return false;
    if (Object.prototype.hasOwnProperty.call(value, 'data'))
        return true;
    return isRecord(value.options) && Object.prototype.hasOwnProperty.call(value.options, 'repeatKey');
}
function isTsfBullMqJobScheduler(scheduler) {
    if (!isRecord(scheduler) || typeof scheduler.key !== 'string' || typeof scheduler.name !== 'string')
        return false;
    if (!isRecord(scheduler.template))
        return false;
    const templateData = scheduler.template.data;
    if (!isRecord(templateData) || !isRecord(templateData.options))
        return false;
    return templateData.options.repeatKey === scheduler.key && scheduler.key.startsWith(`${scheduler.name}:`);
}
function isTsfBullMqRepeatJob(job) {
    const data = job.data;
    return isRecord(data) && isWorkerPayloadWrapper(data) && data.options.repeatKey === job.repeatJobKey;
}
function escapeRedisGlob(value) {
    return value.replace(/[\\*?[\]]/g, '\\$&');
}
exports.__tsfTypeAliases = JSON.parse("[1,{\"BullMqCronJobSchedule\":{\"kind\":18,\"typeName\":\"BullMqCronJobSchedule\",\"types\":[{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"pattern\",\"type\":{\"kind\":6},\"optional\":false}]},\"BullMqWorkerJobData\":{\"kind\":18,\"typeName\":\"BullMqWorkerJobData\",\"types\":[{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false}],\"typeParameters\":[\"I\"]},\"RemovedBullMqJobScheduler\":{\"kind\":18,\"typeName\":\"RemovedBullMqJobScheduler\",\"types\":[{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"pattern\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"key\",\"type\":{\"kind\":6},\"optional\":false}]}}]")[1];
//# sourceMappingURL=queue.js.map