"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.__tsfTypeAliases = exports.BaseJob = exports.OutputDataSymbol = exports.InputDataSymbol = exports.JobSymbol = void 0;
exports.WorkerJob = WorkerJob;
exports.getRegisteredWorkerJobs = getRegisteredWorkerJobs;
const tslib_1 = require("tslib");
const _a = tslib_1.__importStar(require("@zyno-io/ts-reflection/type-metadata-runtime"));
const __tsf_metadata_type = _a.createCompactMetadataRegistryV1("[1,[{\"kind\":2,\"typeName\":\"I\"},{\"kind\":12,\"types\":[{\"kind\":22,\"type\":{\"kind\":2,\"typeName\":\"O\"}},{\"kind\":2,\"typeName\":\"O\"}]}]]", []);
exports.JobSymbol = Symbol('Job');
exports.InputDataSymbol = Symbol('InputData');
exports.OutputDataSymbol = Symbol('OutputData');
let _BaseJobMetadata_1;
class BaseJob {
    [exports.JobSymbol] = exports.JobSymbol;
    [exports.InputDataSymbol];
    [exports.OutputDataSymbol];
    static QUEUE_NAME = 'default';
    static CRON_SCHEDULE = null;
    static __tsfType = _BaseJobMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"BaseJob\",\"typeName\":\"BaseJob\",\"classType\":{\"$tsf\":0},\"properties\":[],\"methods\":[{\"name\":\"handle\",\"parameters\":[{\"name\":\"data\",\"type\":{\"$tsfType\":0},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":1}}],\"hasConstructor\":false,\"constructorParameters\":[]}]", [() => BaseJob], __tsf_metadata_type);
}
exports.BaseJob = BaseJob;
_BaseJobMetadata_1.classType = BaseJob;
BaseJob.__tsfType = _BaseJobMetadata_1;
const workerJobs = new Set();
function WorkerJob(options = {}) {
    return target => {
        const jobClass = target;
        const queueName = options.queueName ?? options.queue;
        const cronSchedule = options.cronSchedule ?? options.cron;
        if (queueName !== undefined)
            jobClass.QUEUE_NAME = queueName;
        if (cronSchedule !== undefined)
            jobClass.CRON_SCHEDULE = cronSchedule;
        workerJobs.add(jobClass);
    };
}
function getRegisteredWorkerJobs() {
    return [...workerJobs];
}
exports.__tsfTypeAliases = _a.decodeCompactMetadataV1("[1,{\"BaseJobClass\":{\"kind\":18,\"typeName\":\"BaseJobClass\",\"types\":[{\"kind\":20,\"name\":\"QUEUE_NAME\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"CRON_SCHEDULE\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":5}]},\"optional\":false}]},\"IJobOptions\":{\"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}]},\"QueuedWorkerJob\":{\"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\":0}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"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\"]},\"WorkerJobOptions\":{\"kind\":18,\"typeName\":\"WorkerJobOptions\",\"types\":[{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"cronSchedule\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":5}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"cron\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":5}]},{\"kind\":4}]},\"optional\":true}]},\"WorkerJobRecord\":{\"kind\":18,\"typeName\":\"WorkerJobRecord\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queueId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"attempt\",\"type\":{\"kind\":7},\"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\":\"traceId\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":5}]},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"}]},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":2,\"typeName\":\"O\"},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false},{\"kind\":20,\"name\":\"executedAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false},{\"kind\":20,\"name\":\"completedAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false}],\"typeParameters\":[\"I\",\"O\"]},\"WorkerJobStatus\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"queued\"},{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"},{\"kind\":10,\"literal\":\"skipped\"}],\"typeName\":\"WorkerJobStatus\"}}]", [() => (typeof Date !== "undefined" ? Date : (typeof exports !== "undefined" ? exports.Date : undefined))], __tsf_metadata_type);
//# sourceMappingURL=types.js.map