import { P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.cjs'; import { Redis } from 'ioredis'; import { QueueOptions, Queue, JobsOptions, Job, QueueEventsOptions, QueueEvents, QueueBaseOptions, FlowProducer, RepeatOptions, WorkerOptions, Worker } from 'bullmq'; import { Service } from 'moleculer'; import 'bson'; import 'zod/v4'; import 'ajv/dist/2019.js'; import 'pino'; import 'pino-pretty'; type QueueMixinOptions = { brokerURL: string | ((svc: TService) => Promise); }; /** * connection is mandatory for BullMQ but is managed by each mixins. */ type WithoutConnection = Omit; /** * This Mixin add the capability to launch a job. */ declare function QueueClient(queueName: N, opts: WithoutConnection & QueueMixinOptions): PartialCustomServiceSchema; /** * Add a job to a specific queue. The queue name needs to be passed as parameters * to enable multiple queue clients in the same service. */ addJob(qName: N, name: string, data: D, jOpts?: JobsOptions): Promise; /** * Add jobs to a specific queue. The queue name needs to be passed as parameters * to enable multiple queue clients in the same service. */ addBulkJob(qName: N, name: string, data: D[], jOpts?: JobsOptions): Promise; /** * Get a queue bundle if you need specific features */ getQueue(qName: N): Queue; }, PartialCustomServiceSchema; client: Redis; onClose: () => Promise | void; }>; getFromStore(storeName: string, key: string): Redis | null; removeServiceFromStore(storeName: string, key: string): Promise; setClientToStore(storeName: string, key: string, client: Redis, onClose: () => Promise | void): void; }, unknown>[]>; /** * This Mixin add the capability to wait on a job. * WARNING: Needs to be used with QueueClient mixin. */ declare function QueueEventsClient(queueName: N, opts: WithoutConnection & QueueMixinOptions): PartialCustomServiceSchema; /** * Return the QueueEvents instance for the given queue name. * Will run the QueueEvents if it's not already running (lazy connect). * Will throw an error if the QueueEvents is not found. */ getQueueEvents(qName: N): QueueEvents; /** * Same as addJob but will also wait for the job to finish before returning. */ addAndWait(qName: N, name: string, data: D, jOpts?: JobsOptions, ttl?: number): Promise; /** * Same as addBulkJob but will also wait for the jobs to finish before returning. */ addBulkAndWait(qName: N, name: string, data: D[], jOpts?: JobsOptions, ttl?: number): Promise; }, PartialCustomServiceSchema; client: Redis; onClose: () => Promise | void; }>; getFromStore(storeName: string, key: string): Redis | null; removeServiceFromStore(storeName: string, key: string): Promise; setClientToStore(storeName: string, key: string, client: Redis, onClose: () => Promise | void): void; }, unknown>[]>; /** * This Mixin add the capability to launch a BullMQ flows. */ declare function QueueFlowProducerMixin(opts: WithoutConnection & QueueMixinOptions): PartialCustomServiceSchema; type RepeatableJob = { name: string; data?: unknown; } & RepeatOptions; type QueueStaticRepeatableJobsOptions = { /** * Set to `false` to prevent deleting repeatable jobs not registered. */ autoRemove?: boolean; }; /** * This Mixin allow to register repeatable jobs and remove other ones. * It should mainly be setup on the same service as the related QueueWorker. */ declare function QueueStaticRepeatableJobs(queueName: string, jobs: RepeatableJob[], opts: QueueStaticRepeatableJobsOptions & QueueMixinOptions): PartialCustomServiceSchema; }, PartialCustomServiceSchema; client: Redis; onClose: () => Promise | void; }>; getFromStore(storeName: string, key: string): Redis | null; removeServiceFromStore(storeName: string, key: string): Promise; setClientToStore(storeName: string, key: string, client: Redis, onClose: () => Promise | void): void; }, unknown>[]>; type JobMeta = { job?: Job; jobWorkerToken?: string; }; type JobProcessorOptions = { /** * Use the job name as the action name. * When false (default), the action name is 'processor'. */ useNamedFunctions?: boolean; /** * Skip normal info logs at the start and end of the job. * Will never disable logs on errors. */ skipNormalLogs?: boolean; /** * Allow to log additional fields from the job data. * Currently, doesn't support nested fields. */ logDataFields?: string[]; /** * Optional wrapper that MUST call the passed function. */ wrapper?: (job: Job, token: string | undefined, fn: (job: Job, token?: string) => Promise) => Promise; }; /** * This Mixin create the worker system. */ declare function QueueWorker(queueName: string, opts: WithoutConnection & QueueMixinOptions, processorOptions?: JobProcessorOptions): PartialCustomServiceSchema; _processJob(job: Job, token?: string): Promise; }, unknown>; export { QueueClient, QueueEventsClient, QueueFlowProducerMixin, QueueStaticRepeatableJobs, QueueWorker }; export type { JobMeta, JobProcessorOptions, QueueMixinOptions, QueueStaticRepeatableJobsOptions, RepeatableJob };