@monque/tsed 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -18
- package/dist/CHANGELOG.md +19 -0
- package/dist/README.md +18 -18
- package/dist/index.cjs +101 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -63
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +78 -64
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +98 -85
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- package/src/config/config.ts +4 -2
- package/src/config/types.ts +35 -2
- package/src/constants/constants.ts +1 -1
- package/src/constants/types.ts +3 -3
- package/src/decorators/cron.ts +5 -5
- package/src/decorators/index.ts +5 -5
- package/src/decorators/{worker-controller.ts → job-controller.ts} +14 -14
- package/src/decorators/{worker.ts → job.ts} +14 -14
- package/src/decorators/types.ts +18 -18
- package/src/index.ts +7 -7
- package/src/monque-module.ts +23 -18
- package/src/utils/build-job-name.ts +2 -2
- package/src/utils/collect-job-metadata.ts +95 -0
- package/src/utils/get-job-token.ts +29 -0
- package/src/utils/index.ts +4 -4
- package/src/utils/resolve-database.ts +6 -5
- package/src/utils/collect-worker-metadata.ts +0 -95
- package/src/utils/get-worker-token.ts +0 -27
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["Store","Store","Store","MonqueError","ObjectId","Store","Monque","ProviderScope","DIContext","InjectorService","LOGGER","Configuration"],"sources":["../src/config/config.ts","../src/constants/constants.ts","../src/constants/types.ts","../src/decorators/cron.ts","../src/decorators/worker.ts","../src/decorators/worker-controller.ts","../src/services/monque-service.ts","../src/utils/build-job-name.ts","../src/utils/collect-worker-metadata.ts","../src/utils/get-worker-token.ts","../src/utils/guards.ts","../src/utils/resolve-database.ts","../src/monque-module.ts"],"sourcesContent":["/**\n * @monque/tsed - Configuration\n *\n * Defines the configuration interface and TsED module augmentation.\n */\n\nimport type { MonqueTsedConfig } from './types.js';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// TsED Module Augmentation\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Augment TsED's Configuration interface to include monque settings.\n *\n * This allows type-safe configuration via @Configuration decorator.\n */\ndeclare global {\n\tnamespace TsED {\n\t\tinterface Configuration {\n\t\t\t/**\n\t\t\t * Monque job queue configuration.\n\t\t\t */\n\t\t\tmonque?: MonqueTsedConfig;\n\t\t}\n\t}\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Validation\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Validate that exactly one database resolution strategy is provided.\n *\n * @param config - The configuration to validate.\n * @throws Error if zero or multiple strategies are provided.\n *\n * @example\n * ```typescript\n * validateDatabaseConfig({ db: mongoDb }); // OK\n * validateDatabaseConfig({}); // throws\n * validateDatabaseConfig({ db: mongoDb, dbFactory: fn }); // throws\n * ```\n */\nexport function validateDatabaseConfig(config: MonqueTsedConfig): void {\n\tconst strategies = [config.db, config.dbFactory, config.dbToken].filter(Boolean);\n\n\tif (strategies.length === 0) {\n\t\tthrow new Error(\n\t\t\t\"MonqueTsedConfig requires exactly one of 'db', 'dbFactory', or 'dbToken' to be set\",\n\t\t);\n\t}\n\n\tif (strategies.length > 1) {\n\t\tthrow new Error(\n\t\t\t\"MonqueTsedConfig accepts only one of 'db', 'dbFactory', or 'dbToken' - multiple were provided\",\n\t\t);\n\t}\n}\n","/**\n * Symbol used to store decorator metadata on class constructors.\n *\n * Used by @WorkerController, @Worker, and @Cron decorators to attach\n * metadata that is later collected by MonqueModule during initialization.\n *\n * @example\n * ```typescript\n * Store.from(Class).set(MONQUE, metadata);\n * ```\n */\nexport const MONQUE = Symbol.for('monque');\n","/**\n * Provider type constants for DI scanning.\n *\n * These constants are used to categorize providers registered with Ts.ED's\n * dependency injection container, enabling MonqueModule to discover and\n * register workers automatically.\n *\n * Note: Using string constants with `as const` instead of enums per\n * Constitution guidelines.\n */\nexport const ProviderTypes = {\n\t/** Provider type for @WorkerController decorated classes */\n\tWORKER_CONTROLLER: 'monque:worker-controller',\n\t/** Provider type for cron job handlers */\n\tCRON: 'monque:cron',\n} as const;\n\n/**\n * Union type of all provider type values.\n */\nexport type ProviderType = (typeof ProviderTypes)[keyof typeof ProviderTypes];\n","import { Store } from '@tsed/core';\n\nimport { MONQUE } from '@/constants';\nimport type { CronDecoratorOptions, CronMetadata, WorkerStore } from '@/decorators/types.js';\n\n/**\n * Method decorator that registers a method as a scheduled cron job.\n *\n * @param pattern - Cron expression (e.g., \"* * * * *\", \"@daily\")\n * @param options - Optional cron configuration (name, timezone, etc.)\n *\n * @example\n * ```typescript\n * @WorkerController()\n * class ReportWorkers {\n * @Cron(\"@daily\", { timezone: \"UTC\" })\n * async generateDailyReport() {\n * // ...\n * }\n * }\n * ```\n */\nexport function Cron(pattern: string, options?: CronDecoratorOptions): MethodDecorator {\n\treturn <T>(\n\t\ttarget: object,\n\t\tpropertyKey: string | symbol,\n\t\t_descriptor: TypedPropertyDescriptor<T>,\n\t): void => {\n\t\tconst methodName = String(propertyKey);\n\n\t\tconst cronMetadata: CronMetadata = {\n\t\t\tpattern,\n\t\t\t// Default name to method name if not provided\n\t\t\tname: options?.name || methodName,\n\t\t\tmethod: methodName,\n\t\t\topts: options || {},\n\t\t};\n\n\t\t// Get the class constructor (target is the prototype for instance methods)\n\t\tconst targetConstructor = target.constructor;\n\t\tconst store = Store.from(targetConstructor);\n\n\t\t// Get or initialize the MONQUE store\n\t\tconst existing = store.get<Partial<WorkerStore>>(MONQUE) || {\n\t\t\ttype: 'controller',\n\t\t\tworkers: [],\n\t\t\tcronJobs: [],\n\t\t};\n\n\t\t// Add this cron job to the list\n\t\tconst cronJobs = [...(existing.cronJobs || []), cronMetadata];\n\n\t\tstore.set(MONQUE, {\n\t\t\t...existing,\n\t\t\tcronJobs,\n\t\t});\n\t};\n}\n","/**\n * @Worker method decorator\n *\n * Registers a method as a job handler. The method will be called when a job\n * with the matching name is picked up for processing.\n *\n * @param name - Job name (combined with controller namespace if present).\n * @param options - Worker configuration options.\n *\n * @example\n * ```typescript\n * @WorkerController(\"notifications\")\n * export class NotificationWorkers {\n * @Worker(\"push\", { concurrency: 10 })\n * async sendPush(job: Job<PushPayload>) {\n * await pushService.send(job.data);\n * }\n * }\n * ```\n */\nimport { Store } from '@tsed/core';\n\nimport { MONQUE } from '@/constants';\n\nimport type { WorkerDecoratorOptions, WorkerMetadata, WorkerStore } from './types.js';\n\n/**\n * Method decorator that registers a method as a job handler.\n *\n * @param name - The job name (will be prefixed with controller namespace if present)\n * @param options - Optional worker configuration (concurrency, replace, etc.)\n */\nexport function Worker(name: string, options?: WorkerDecoratorOptions): MethodDecorator {\n\treturn <T>(\n\t\ttarget: object,\n\t\tpropertyKey: string | symbol,\n\t\t_descriptor: TypedPropertyDescriptor<T>,\n\t): void => {\n\t\tconst methodName = String(propertyKey);\n\n\t\tconst workerMetadata: WorkerMetadata = {\n\t\t\tname,\n\t\t\tmethod: methodName,\n\t\t\topts: options || {},\n\t\t};\n\n\t\t// Get the class constructor (target is the prototype for instance methods)\n\t\tconst targetConstructor = target.constructor;\n\t\tconst store = Store.from(targetConstructor);\n\n\t\t// Get or initialize the MONQUE store\n\t\tconst existing = store.get<Partial<WorkerStore>>(MONQUE) || {\n\t\t\ttype: 'controller',\n\t\t\tworkers: [],\n\t\t\tcronJobs: [],\n\t\t};\n\n\t\t// Add this worker to the list\n\t\tconst workers = [...(existing.workers || []), workerMetadata];\n\n\t\tstore.set(MONQUE, {\n\t\t\t...existing,\n\t\t\tworkers,\n\t\t});\n\t};\n}\n","/**\n * @WorkerController class decorator\n *\n * Marks a class as containing worker methods and registers it with the Ts.ED DI container.\n * Workers in the class will have their job names prefixed with the namespace.\n *\n * @param namespace - Optional prefix for all job names in this controller.\n * When set, job names become \"{namespace}.{name}\".\n *\n * @example\n * ```typescript\n * @WorkerController(\"email\")\n * export class EmailWorkers {\n * @Worker(\"send\") // Registered as \"email.send\"\n * async send(job: Job<EmailPayload>) { }\n * }\n * ```\n */\nimport { Store, useDecorators } from '@tsed/core';\nimport { Injectable } from '@tsed/di';\n\nimport { MONQUE, ProviderTypes } from '@/constants';\n\nimport type { WorkerStore } from './types.js';\n\n/**\n * Class decorator that registers a class as a worker controller.\n *\n * @param namespace - Optional namespace prefix for job names\n */\nexport function WorkerController(namespace?: string): ClassDecorator {\n\treturn useDecorators(\n\t\t// Register as injectable with custom provider type\n\t\tInjectable({\n\t\t\ttype: ProviderTypes.WORKER_CONTROLLER,\n\t\t}),\n\t\t// Apply custom decorator to store metadata\n\t\t(target: object) => {\n\t\t\tconst store = Store.from(target);\n\n\t\t\t// Get existing store or create new one\n\t\t\tconst existing = store.get<Partial<WorkerStore>>(MONQUE) || {};\n\n\t\t\t// Merge with new metadata, only include namespace if defined\n\t\t\tconst workerStore: WorkerStore = {\n\t\t\t\ttype: 'controller',\n\t\t\t\t...(namespace !== undefined && { namespace }),\n\t\t\t\tworkers: existing.workers || [],\n\t\t\t\tcronJobs: existing.cronJobs || [],\n\t\t\t};\n\n\t\t\tstore.set(MONQUE, workerStore);\n\t\t},\n\t);\n}\n","/**\n * MonqueService - Injectable wrapper for Monque\n *\n * Provides a DI-friendly interface to the Monque job queue.\n * All methods delegate to the underlying Monque instance.\n *\n * @example\n * ```typescript\n * @Service()\n * export class OrderService {\n * @Inject()\n * private monque: MonqueService;\n *\n * async createOrder(data: CreateOrderDto) {\n * const order = await this.save(data);\n * await this.monque.enqueue(\"order.process\", { orderId: order.id });\n * return order;\n * }\n * }\n * ```\n */\n\nimport type {\n\tBulkOperationResult,\n\tCursorOptions,\n\tCursorPage,\n\tEnqueueOptions,\n\tGetJobsFilter,\n\tJobSelector,\n\tMonque,\n\tPersistedJob,\n\tQueueStats,\n\tScheduleOptions,\n} from '@monque/core';\nimport { MonqueError } from '@monque/core';\nimport { Injectable } from '@tsed/di';\nimport { ObjectId } from 'mongodb';\n\n/**\n * Injectable service that wraps the Monque instance.\n *\n * Exposes the full Monque public API through dependency injection.\n */\n@Injectable()\nexport class MonqueService {\n\t/**\n\t * Internal Monque instance (set by MonqueModule)\n\t * @internal\n\t */\n\tprivate _monque: Monque | null = null;\n\n\t/**\n\t * Set the internal Monque instance.\n\t * Called by MonqueModule during initialization.\n\t * @internal\n\t */\n\t_setMonque(monque: Monque): void {\n\t\tthis._monque = monque;\n\t}\n\n\t/**\n\t * Access the underlying Monque instance.\n\t * @throws Error if MonqueModule is not initialized\n\t */\n\tget monque(): Monque {\n\t\tif (!this._monque) {\n\t\t\tthrow new MonqueError(\n\t\t\t\t'MonqueService is not initialized. Ensure MonqueModule is imported and enabled.',\n\t\t\t);\n\t\t}\n\n\t\treturn this._monque;\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Job Scheduling\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\t/**\n\t * Enqueue a job for processing.\n\t *\n\t * @param name - Job type identifier (use full namespaced name, e.g., \"email.send\")\n\t * @param data - Job payload\n\t * @param options - Scheduling and deduplication options\n\t * @returns The created or existing job document\n\t */\n\tasync enqueue<T>(name: string, data: T, options?: EnqueueOptions): Promise<PersistedJob<T>> {\n\t\treturn this.monque.enqueue(name, data, options);\n\t}\n\n\t/**\n\t * Enqueue a job for immediate processing.\n\t *\n\t * @param name - Job type identifier\n\t * @param data - Job payload\n\t * @returns The created job document\n\t */\n\tasync now<T>(name: string, data: T): Promise<PersistedJob<T>> {\n\t\treturn this.monque.now(name, data);\n\t}\n\n\t/**\n\t * Schedule a recurring job with a cron expression.\n\t *\n\t * @param cron - Cron expression (5-field standard or predefined like @daily)\n\t * @param name - Job type identifier\n\t * @param data - Job payload\n\t * @param options - Scheduling options\n\t * @returns The created job document\n\t */\n\tasync schedule<T>(\n\t\tcron: string,\n\t\tname: string,\n\t\tdata: T,\n\t\toptions?: ScheduleOptions,\n\t): Promise<PersistedJob<T>> {\n\t\treturn this.monque.schedule(cron, name, data, options);\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Job Management (Single Job Operations)\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\t/**\n\t * Cancel a pending or scheduled job.\n\t *\n\t * @param jobId - The ID of the job to cancel\n\t * @returns The cancelled job, or null if not found\n\t */\n\tasync cancelJob(jobId: string): Promise<PersistedJob<unknown> | null> {\n\t\treturn this.monque.cancelJob(jobId);\n\t}\n\n\t/**\n\t * Retry a failed or cancelled job.\n\t *\n\t * @param jobId - The ID of the job to retry\n\t * @returns The updated job, or null if not found\n\t */\n\tasync retryJob(jobId: string): Promise<PersistedJob<unknown> | null> {\n\t\treturn this.monque.retryJob(jobId);\n\t}\n\n\t/**\n\t * Reschedule a pending job to run at a different time.\n\t *\n\t * @param jobId - The ID of the job to reschedule\n\t * @param runAt - The new Date when the job should run\n\t * @returns The updated job, or null if not found\n\t */\n\tasync rescheduleJob(jobId: string, runAt: Date): Promise<PersistedJob<unknown> | null> {\n\t\treturn this.monque.rescheduleJob(jobId, runAt);\n\t}\n\n\t/**\n\t * Permanently delete a job.\n\t *\n\t * @param jobId - The ID of the job to delete\n\t * @returns true if deleted, false if job not found\n\t */\n\tasync deleteJob(jobId: string): Promise<boolean> {\n\t\treturn this.monque.deleteJob(jobId);\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Job Management (Bulk Operations)\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\t/**\n\t * Cancel multiple jobs matching the given filter.\n\t *\n\t * @param filter - Selector for which jobs to cancel\n\t * @returns Result with count of cancelled jobs\n\t */\n\tasync cancelJobs(filter: JobSelector): Promise<BulkOperationResult> {\n\t\treturn this.monque.cancelJobs(filter);\n\t}\n\n\t/**\n\t * Retry multiple jobs matching the given filter.\n\t *\n\t * @param filter - Selector for which jobs to retry\n\t * @returns Result with count of retried jobs\n\t */\n\tasync retryJobs(filter: JobSelector): Promise<BulkOperationResult> {\n\t\treturn this.monque.retryJobs(filter);\n\t}\n\n\t/**\n\t * Delete multiple jobs matching the given filter.\n\t *\n\t * @param filter - Selector for which jobs to delete\n\t * @returns Result with count of deleted jobs\n\t */\n\tasync deleteJobs(filter: JobSelector): Promise<BulkOperationResult> {\n\t\treturn this.monque.deleteJobs(filter);\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Job Queries\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\t/**\n\t * Get a job by its ID.\n\t *\n\t * @param jobId - The job's ObjectId (as string or ObjectId)\n\t * @returns The job document, or null if not found\n\t * @throws MonqueError if jobId is an invalid hex string\n\t */\n\tasync getJob<T>(jobId: string | ObjectId): Promise<PersistedJob<T> | null> {\n\t\tlet id: ObjectId;\n\n\t\tif (typeof jobId === 'string') {\n\t\t\tif (!ObjectId.isValid(jobId)) {\n\t\t\t\tthrow new MonqueError(`Invalid job ID format: ${jobId}`);\n\t\t\t}\n\t\t\tid = ObjectId.createFromHexString(jobId);\n\t\t} else {\n\t\t\tid = jobId;\n\t\t}\n\n\t\treturn this.monque.getJob(id);\n\t}\n\n\t/**\n\t * Query jobs from the queue with optional filters.\n\t *\n\t * @param filter - Optional filter criteria (name, status, limit, skip)\n\t * @returns Array of matching jobs\n\t */\n\tasync getJobs<T>(filter?: GetJobsFilter): Promise<PersistedJob<T>[]> {\n\t\treturn this.monque.getJobs(filter);\n\t}\n\n\t/**\n\t * Get a paginated list of jobs using opaque cursors.\n\t *\n\t * @param options - Pagination options (cursor, limit, direction, filter)\n\t * @returns Page of jobs with next/prev cursors\n\t */\n\tasync getJobsWithCursor<T>(options?: CursorOptions): Promise<CursorPage<T>> {\n\t\treturn this.monque.getJobsWithCursor(options);\n\t}\n\n\t/**\n\t * Get aggregate statistics for the job queue.\n\t *\n\t * @param filter - Optional filter to scope statistics by job name\n\t * @returns Queue statistics\n\t */\n\tasync getQueueStats(filter?: Pick<JobSelector, 'name'>): Promise<QueueStats> {\n\t\treturn this.monque.getQueueStats(filter);\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Health Check\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\t/**\n\t * Check if the scheduler is healthy and running.\n\t *\n\t * @returns true if running and connected\n\t */\n\tisHealthy(): boolean {\n\t\treturn this.monque.isHealthy();\n\t}\n}\n","/**\n * Build the full job name by combining namespace and name.\n *\n * @param namespace - Optional namespace from @WorkerController\n * @param name - Job name from @Worker or @Cron\n * @returns Full job name (e.g., \"email.send\" or just \"send\")\n *\n * @example\n * ```typescript\n * buildJobName(\"email\", \"send\"); // \"email.send\"\n * buildJobName(undefined, \"send\"); // \"send\"\n * buildJobName(\"\", \"send\"); // \"send\"\n * ```\n */\nexport function buildJobName(namespace: string | undefined, name: string): string {\n\treturn namespace ? `${namespace}.${name}` : name;\n}\n","/**\n * Collect worker metadata utility\n *\n * Collects all worker metadata from a class decorated with @WorkerController.\n * Used by MonqueModule to discover and register all workers.\n */\nimport { Store } from '@tsed/core';\n\nimport { MONQUE } from '@/constants';\nimport type { CronDecoratorOptions, WorkerDecoratorOptions, WorkerStore } from '@/decorators';\n\nimport { buildJobName } from './build-job-name.js';\n\n/**\n * Collected worker registration info ready for Monque.register()\n */\nexport interface CollectedWorkerMetadata {\n\t/**\n\t * Full job name (with namespace prefix if applicable)\n\t */\n\tfullName: string;\n\n\t/**\n\t * Method name on the controller class\n\t */\n\tmethod: string;\n\n\t/**\n\t * Worker options to pass to Monque.register()\n\t */\n\topts: WorkerDecoratorOptions | CronDecoratorOptions;\n\n\t/**\n\t * Whether this is a cron job\n\t */\n\tisCron: boolean;\n\n\t/**\n\t * Cron pattern (only for cron jobs)\n\t */\n\tcronPattern?: string;\n}\n\n/**\n * Collect all worker metadata from a class.\n *\n * @param target - The class constructor (decorated with @WorkerController)\n * @returns Array of collected worker metadata ready for registration\n *\n * @example\n * ```typescript\n * const metadata = collectWorkerMetadata(EmailWorkers);\n * // Returns:\n * // [\n * // { fullName: \"email.send\", method: \"sendEmail\", opts: {}, isCron: false },\n * // { fullName: \"email.daily-digest\", method: \"sendDailyDigest\", opts: {}, isCron: true, cronPattern: \"0 9 * * *\" }\n * // ]\n * ```\n */\nexport function collectWorkerMetadata(\n\ttarget: new (...args: unknown[]) => unknown,\n): CollectedWorkerMetadata[] {\n\tconst store = Store.from(target);\n\tconst workerStore = store.get<WorkerStore>(MONQUE);\n\n\tif (!workerStore) {\n\t\treturn [];\n\t}\n\n\tconst results: CollectedWorkerMetadata[] = [];\n\tconst namespace = workerStore.namespace;\n\n\t// Collect regular workers\n\tfor (const worker of workerStore.workers) {\n\t\tresults.push({\n\t\t\tfullName: buildJobName(namespace, worker.name),\n\t\t\tmethod: worker.method,\n\t\t\topts: worker.opts,\n\t\t\tisCron: false,\n\t\t});\n\t}\n\n\t// Collect cron jobs\n\tfor (const cron of workerStore.cronJobs) {\n\t\tresults.push({\n\t\t\tfullName: buildJobName(namespace, cron.name),\n\t\t\tmethod: cron.method,\n\t\t\topts: cron.opts,\n\t\t\tisCron: true,\n\t\t\tcronPattern: cron.pattern,\n\t\t});\n\t}\n\n\treturn results;\n}\n","/**\n * Generate a unique token for a worker controller.\n *\n * Used internally by Ts.ED DI to identify worker controller providers.\n * The token is based on the class name for debugging purposes.\n *\n * @param target - The class constructor\n * @returns A Symbol token unique to this worker controller\n *\n * @example\n * ```typescript\n * @WorkerController(\"email\")\n * class EmailWorkers {}\n *\n * const token = getWorkerToken(EmailWorkers);\n * // Symbol(\"monque:worker:EmailWorkers\")\n * ```\n */\nexport function getWorkerToken(target: new (...args: unknown[]) => unknown): symbol {\n\tconst name = target.name?.trim();\n\n\tif (!name) {\n\t\tthrow new Error('Worker class must have a non-empty name');\n\t}\n\n\treturn Symbol.for(`monque:worker:${name}`);\n}\n","/**\n * @monque/tsed - Type Guards\n *\n * Utilities for duck-typing Mongoose and MongoDB related objects\n * to avoid hard dependencies on @tsed/mongoose.\n */\n\nimport type { Db } from 'mongodb';\n\n/**\n * Interface representing a Mongoose Connection object.\n * We only care that it has a `db` property which is a MongoDB Db instance.\n */\nexport interface MongooseConnection {\n\tdb: Db;\n}\n\n/**\n * Interface representing the @tsed/mongoose MongooseService.\n * It acts as a registry/factory for connections.\n */\nexport interface MongooseService {\n\t/**\n\t * Get a connection by its ID (configuration key).\n\t * @param id The connection ID (default: \"default\")\n\t */\n\tget(id?: string): MongooseConnection | undefined;\n}\n\n/**\n * Type guard to check if an object acts like a Mongoose Service.\n *\n * Checks if the object has a `get` method.\n *\n * @param value The value to check\n */\nexport function isMongooseService(value: unknown): value is MongooseService {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t'get' in value &&\n\t\ttypeof (value as MongooseService).get === 'function'\n\t);\n}\n\n/**\n * Type guard to check if an object acts like a Mongoose Connection.\n *\n * Checks if the object has a `db` property.\n *\n * @param value The value to check\n */\nexport function isMongooseConnection(value: unknown): value is MongooseConnection {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t'db' in value &&\n\t\ttypeof (value as MongooseConnection).db === 'object' &&\n\t\t(value as MongooseConnection).db !== null &&\n\t\ttypeof (value as MongooseConnection).db.collection === 'function'\n\t);\n}\n","/**\n * @monque/tsed - Database Resolution Utility\n *\n * Multi-strategy database resolution for flexible MongoDB connection handling.\n */\n\nimport type { TokenProvider } from '@tsed/di';\nimport type { Db } from 'mongodb';\n\nimport type { MonqueTsedConfig } from '@/config';\n\nimport { isMongooseConnection, isMongooseService } from './guards.js';\n\n/**\n * Type for the injector function used to resolve DI tokens.\n */\nexport type InjectorFn = <T>(token: TokenProvider<T>) => T | undefined;\n\n/**\n * Resolve the MongoDB database instance from the configuration.\n *\n * Supports three resolution strategies:\n * 1. **Direct `db`**: Returns the provided Db instance directly\n * 2. **Factory `dbFactory`**: Calls the factory function (supports async)\n * 3. **DI Token `dbToken`**: Resolves the Db from the DI container\n *\n * @param config - The Monque configuration containing database settings\n * @param injectorFn - Optional function to resolve DI tokens (required for dbToken strategy)\n * @returns The resolved MongoDB Db instance\n * @throws Error if no database strategy is provided or if DI resolution fails\n *\n * @example\n * ```typescript\n * // Direct Db instance\n * const db = await resolveDatabase({ db: mongoDb });\n *\n * // Factory function\n * const db = await resolveDatabase({\n * dbFactory: async () => {\n * const client = await MongoClient.connect(uri);\n * return client.db(\"myapp\");\n * }\n * });\n *\n * // DI token\n * const db = await resolveDatabase(\n * { dbToken: \"MONGODB_DATABASE\" },\n * (token) => injector.get(token)\n * );\n * ```\n */\nexport async function resolveDatabase(\n\tconfig: MonqueTsedConfig,\n\tinjectorFn?: InjectorFn,\n): Promise<Db> {\n\t// Strategy 1: Direct Db instance\n\tif (config.db) {\n\t\treturn config.db;\n\t}\n\n\t// Strategy 2: Factory function (sync or async)\n\tif (config.dbFactory) {\n\t\treturn config.dbFactory();\n\t}\n\n\t// Strategy 3: DI token resolution\n\tif (config.dbToken) {\n\t\tif (!injectorFn) {\n\t\t\tthrow new Error(\n\t\t\t\t'MonqueTsedConfig.dbToken requires an injector function to resolve the database',\n\t\t\t);\n\t\t}\n\n\t\tconst resolved = injectorFn(config.dbToken);\n\n\t\tif (!resolved) {\n\t\t\tthrow new Error(\n\t\t\t\t`Could not resolve database from token: ${String(config.dbToken)}. ` +\n\t\t\t\t\t'Make sure the provider is registered in the DI container.',\n\t\t\t);\n\t\t}\n\n\t\tif (isMongooseService(resolved)) {\n\t\t\t// Check for Mongoose Service (duck typing)\n\t\t\t// It has a get() method that returns a connection\n\t\t\tconst connectionId = config.mongooseConnectionId || 'default';\n\t\t\tconst connection = resolved.get(connectionId);\n\n\t\t\tif (!connection) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`MongooseService resolved from token \"${String(config.dbToken)}\" returned no connection for ID \"${connectionId}\". ` +\n\t\t\t\t\t\t'Ensure the connection ID is correct and the connection is established.',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ('db' in connection && connection.db) {\n\t\t\t\treturn connection.db as Db;\n\t\t\t}\n\t\t}\n\n\t\tif (isMongooseConnection(resolved)) {\n\t\t\t// Check for Mongoose Connection (duck typing)\n\t\t\t// It has a db property that is the native Db instance\n\t\t\treturn resolved.db as Db;\n\t\t}\n\n\t\t// Default: Assume it is a native Db instance\n\t\tif (typeof resolved !== 'object' || resolved === null || !('collection' in resolved)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Resolved value from token \"${String(config.dbToken)}\" does not appear to be a valid MongoDB Db instance.`,\n\t\t\t);\n\t\t}\n\n\t\treturn resolved as Db;\n\t}\n\n\t// No strategy provided\n\tthrow new Error(\"MonqueTsedConfig requires 'db', 'dbFactory', or 'dbToken' to be set\");\n}\n","/**\n * MonqueModule - Main Integration Module\n *\n * Orchestrates the integration between Monque and Ts.ED.\n * Handles lifecycle hooks, configuration resolution, and worker registration.\n */\n\nimport {\n\ttype Job,\n\tMonque,\n\ttype MonqueOptions,\n\ttype ScheduleOptions,\n\ttype WorkerOptions,\n} from '@monque/core';\nimport {\n\tConfiguration,\n\tDIContext,\n\tInject,\n\tInjectorService,\n\tLOGGER,\n\tModule,\n\ttype OnDestroy,\n\ttype OnInit,\n\tProviderScope,\n\trunInContext,\n\ttype TokenProvider,\n} from '@tsed/di';\n\nimport { type MonqueTsedConfig, validateDatabaseConfig } from '@/config';\nimport { ProviderTypes } from '@/constants';\nimport { MonqueService } from '@/services';\nimport { collectWorkerMetadata, resolveDatabase } from '@/utils';\n\n@Module({\n\timports: [MonqueService],\n})\nexport class MonqueModule implements OnInit, OnDestroy {\n\tprotected injector: InjectorService;\n\tprotected monqueService: MonqueService;\n\tprotected logger: LOGGER;\n\tprotected monqueConfig: MonqueTsedConfig;\n\n\tprotected monque: Monque | null = null;\n\n\tconstructor(\n\t\t@Inject(InjectorService) injector: InjectorService,\n\t\t@Inject(MonqueService) monqueService: MonqueService,\n\t\t@Inject(LOGGER) logger: LOGGER,\n\t\t@Inject(Configuration) configuration: Configuration,\n\t) {\n\t\tthis.injector = injector;\n\t\tthis.monqueService = monqueService;\n\t\tthis.logger = logger;\n\t\tthis.monqueConfig = configuration.get<MonqueTsedConfig>('monque') || {};\n\t}\n\n\tasync $onInit(): Promise<void> {\n\t\tconst config = this.monqueConfig;\n\n\t\tif (config?.enabled === false) {\n\t\t\tthis.logger.info('Monque integration is disabled');\n\n\t\t\treturn;\n\t\t}\n\n\t\tvalidateDatabaseConfig(config);\n\n\t\ttry {\n\t\t\tconst db = await resolveDatabase(config, (token) =>\n\t\t\t\tthis.injector.get(token as TokenProvider),\n\t\t\t);\n\n\t\t\t// We construct the options object carefully to match MonqueOptions\n\t\t\tconst { db: _db, ...restConfig } = config;\n\t\t\tconst options: MonqueOptions = restConfig;\n\n\t\t\tthis.monque = new Monque(db, options);\n\t\t\tthis.monqueService._setMonque(this.monque);\n\n\t\t\tthis.logger.info('Monque: Connecting to MongoDB...');\n\t\t\tawait this.monque.initialize();\n\n\t\t\tawait this.registerWorkers();\n\n\t\t\tawait this.monque.start();\n\n\t\t\tthis.logger.info('Monque: Started successfully');\n\t\t} catch (error) {\n\t\t\tthis.logger.error({\n\t\t\t\tevent: 'MONQUE_INIT_ERROR',\n\t\t\t\tmessage: 'Failed to initialize Monque',\n\t\t\t\terror,\n\t\t\t});\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync $onDestroy(): Promise<void> {\n\t\tif (this.monque) {\n\t\t\tthis.logger.info('Monque: Stopping...');\n\n\t\t\tawait this.monque.stop();\n\n\t\t\tthis.logger.info('Monque: Stopped');\n\t\t}\n\t}\n\n\t/**\n\t * Discover and register all workers from @WorkerController providers\n\t */\n\tprotected async registerWorkers(): Promise<void> {\n\t\tif (!this.monque) {\n\t\t\tthrow new Error('Monque instance not initialized');\n\t\t}\n\n\t\tconst monque = this.monque;\n\t\tconst workerControllers = this.injector.getProviders(ProviderTypes.WORKER_CONTROLLER);\n\t\tconst registeredJobs = new Set<string>();\n\n\t\tthis.logger.info(`Monque: Found ${workerControllers.length} worker controllers`);\n\n\t\tfor (const provider of workerControllers) {\n\t\t\tconst useClass = provider.useClass;\n\t\t\tconst workers = collectWorkerMetadata(useClass);\n\t\t\t// Try to resolve singleton instance immediately\n\t\t\tconst instance = this.injector.get(provider.token);\n\n\t\t\tif (!instance && provider.scope !== ProviderScope.REQUEST) {\n\t\t\t\tthis.logger.warn(\n\t\t\t\t\t`Monque: Could not resolve instance for controller ${provider.name}. Skipping.`,\n\t\t\t\t);\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const worker of workers) {\n\t\t\t\tconst { fullName, method, opts, isCron, cronPattern } = worker;\n\n\t\t\t\tif (registeredJobs.has(fullName)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Monque: Duplicate job registration detected. Job \"${fullName}\" is already registered.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tregisteredJobs.add(fullName);\n\n\t\t\t\tconst handler = async (job: Job) => {\n\t\t\t\t\tconst $ctx = new DIContext({\n\t\t\t\t\t\tinjector: this.injector,\n\t\t\t\t\t\tid: job._id?.toString() || 'unknown',\n\t\t\t\t\t});\n\t\t\t\t\t$ctx.set('MONQUE_JOB', job);\n\t\t\t\t\t$ctx.container.set(DIContext, $ctx);\n\n\t\t\t\t\tawait runInContext($ctx, async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tlet targetInstance = instance;\n\t\t\t\t\t\t\tif (provider.scope === ProviderScope.REQUEST || !targetInstance) {\n\t\t\t\t\t\t\t\ttargetInstance = await this.injector.invoke(provider.token, {\n\t\t\t\t\t\t\t\t\tlocals: $ctx.container,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst typedInstance = targetInstance as Record<string, (job: Job) => unknown>;\n\n\t\t\t\t\t\t\tif (typedInstance && typeof typedInstance[method] === 'function') {\n\t\t\t\t\t\t\t\tawait typedInstance[method](job);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tthis.logger.error({\n\t\t\t\t\t\t\t\tevent: 'MONQUE_JOB_ERROR',\n\t\t\t\t\t\t\t\tjobName: fullName,\n\t\t\t\t\t\t\t\tjobId: job._id,\n\t\t\t\t\t\t\t\tmessage: `Error processing job ${fullName}`,\n\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\tawait $ctx.destroy();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tif (isCron && cronPattern) {\n\t\t\t\t\tthis.logger.debug(`Monque: Registering cron job \"${fullName}\" (${cronPattern})`);\n\n\t\t\t\t\tmonque.register(fullName, handler, opts as WorkerOptions);\n\t\t\t\t\tawait monque.schedule(cronPattern, fullName, {}, opts as ScheduleOptions);\n\t\t\t\t} else {\n\t\t\t\t\tthis.logger.debug(`Monque: Registering worker \"${fullName}\"`);\n\t\t\t\t\tmonque.register(fullName, handler, opts as WorkerOptions);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.logger.info(`Monque: Registered ${registeredJobs.size} jobs`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,uBAAuB,QAAgC;CACtE,MAAM,aAAa;EAAC,OAAO;EAAI,OAAO;EAAW,OAAO;EAAQ,CAAC,OAAO,QAAQ;AAEhF,KAAI,WAAW,WAAW,EACzB,OAAM,IAAI,MACT,qFACA;AAGF,KAAI,WAAW,SAAS,EACvB,OAAM,IAAI,MACT,gGACA;;;;;;;;;;;;;;;;AC9CH,MAAa,SAAS,OAAO,IAAI,SAAS;;;;;;;;;;;;;;ACD1C,MAAa,gBAAgB;CAE5B,mBAAmB;CAEnB,MAAM;CACN;;;;;;;;;;;;;;;;;;;;;ACOD,SAAgB,KAAK,SAAiB,SAAiD;AACtF,SACC,QACA,aACA,gBACU;EACV,MAAM,aAAa,OAAO,YAAY;EAEtC,MAAM,eAA6B;GAClC;GAEA,MAAM,SAAS,QAAQ;GACvB,QAAQ;GACR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ueError","Store","Store","Store","MonqueError","ObjectId","Store","MonqueError","ConnectionError","Monque","MonqueError","ProviderScope","WorkerRegistrationError","DIContext","InjectorService","LOGGER","Configuration"],"sources":["../src/config/config.ts","../src/constants/constants.ts","../src/constants/types.ts","../src/decorators/cron.ts","../src/decorators/job.ts","../src/decorators/job-controller.ts","../src/services/monque-service.ts","../src/utils/build-job-name.ts","../src/utils/collect-job-metadata.ts","../src/utils/get-job-token.ts","../src/utils/guards.ts","../src/utils/resolve-database.ts","../src/monque-module.ts"],"sourcesContent":["/**\n * @monque/tsed - Configuration\n *\n * Defines the configuration interface and TsED module augmentation.\n */\n\nimport { MonqueError } from '@monque/core';\n\nimport type { MonqueTsedConfig } from './types.js';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// TsED Module Augmentation\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Augment TsED's Configuration interface to include monque settings.\n *\n * This allows type-safe configuration via @Configuration decorator.\n */\ndeclare global {\n\tnamespace TsED {\n\t\tinterface Configuration {\n\t\t\t/**\n\t\t\t * Monque job queue configuration.\n\t\t\t */\n\t\t\tmonque?: MonqueTsedConfig;\n\t\t}\n\t}\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Validation\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Validate that exactly one database resolution strategy is provided.\n *\n * @param config - The configuration to validate.\n * @throws Error if zero or multiple strategies are provided.\n *\n * @example\n * ```typescript\n * validateDatabaseConfig({ db: mongoDb }); // OK\n * validateDatabaseConfig({}); // throws\n * validateDatabaseConfig({ db: mongoDb, dbFactory: fn }); // throws\n * ```\n */\nexport function validateDatabaseConfig(config: MonqueTsedConfig): void {\n\tconst strategies = [config.db, config.dbFactory, config.dbToken].filter(Boolean);\n\n\tif (strategies.length === 0) {\n\t\tthrow new MonqueError(\n\t\t\t\"MonqueTsedConfig requires exactly one of 'db', 'dbFactory', or 'dbToken' to be set\",\n\t\t);\n\t}\n\n\tif (strategies.length > 1) {\n\t\tthrow new MonqueError(\n\t\t\t\"MonqueTsedConfig accepts only one of 'db', 'dbFactory', or 'dbToken' - multiple were provided\",\n\t\t);\n\t}\n}\n","/**\n * Symbol used to store decorator metadata on class constructors.\n *\n * Used by @JobController, @Job, and @Cron decorators to attach\n * metadata that is later collected by MonqueModule during initialization.\n *\n * @example\n * ```typescript\n * Store.from(Class).set(MONQUE, metadata);\n * ```\n */\nexport const MONQUE = Symbol.for('monque');\n","/**\n * Provider type constants for DI scanning.\n *\n * These constants are used to categorize providers registered with Ts.ED's\n * dependency injection container, enabling MonqueModule to discover and\n * register jobs automatically.\n *\n * Note: Using string constants with `as const` instead of enums per\n * Constitution guidelines.\n */\nexport const ProviderTypes = {\n\t/** Provider type for @JobController decorated classes */\n\tJOB_CONTROLLER: 'monque:job-controller',\n\t/** Provider type for cron job handlers */\n\tCRON: 'monque:cron',\n} as const;\n\n/**\n * Union type of all provider type values.\n */\nexport type ProviderType = (typeof ProviderTypes)[keyof typeof ProviderTypes];\n","import { Store } from '@tsed/core';\n\nimport { MONQUE } from '@/constants';\nimport type { CronDecoratorOptions, CronMetadata, JobStore } from '@/decorators/types.js';\n\n/**\n * Method decorator that registers a method as a scheduled cron job.\n *\n * @param pattern - Cron expression (e.g., \"* * * * *\", \"@daily\")\n * @param options - Optional cron configuration (name, timezone, etc.)\n *\n * @example\n * ```typescript\n * @JobController()\n * class ReportJobs {\n * @Cron(\"@daily\", { timezone: \"UTC\" })\n * async generateDailyReport() {\n * // ...\n * }\n * }\n * ```\n */\nexport function Cron(pattern: string, options?: CronDecoratorOptions): MethodDecorator {\n\treturn <T>(\n\t\ttarget: object,\n\t\tpropertyKey: string | symbol,\n\t\t_descriptor: TypedPropertyDescriptor<T>,\n\t): void => {\n\t\tconst methodName = String(propertyKey);\n\n\t\tconst cronMetadata: CronMetadata = {\n\t\t\tpattern,\n\t\t\t// Default name to method name if not provided\n\t\t\tname: options?.name || methodName,\n\t\t\tmethod: methodName,\n\t\t\topts: options || {},\n\t\t};\n\n\t\t// Get the class constructor (target is the prototype for instance methods)\n\t\tconst targetConstructor = target.constructor;\n\t\tconst store = Store.from(targetConstructor);\n\n\t\t// Get or initialize the MONQUE store\n\t\tconst existing = store.get<Partial<JobStore>>(MONQUE) || {\n\t\t\ttype: 'controller',\n\t\t\tjobs: [],\n\t\t\tcronJobs: [],\n\t\t};\n\n\t\t// Add this cron job to the list\n\t\tconst cronJobs = [...(existing.cronJobs || []), cronMetadata];\n\n\t\tstore.set(MONQUE, {\n\t\t\t...existing,\n\t\t\tcronJobs,\n\t\t});\n\t};\n}\n","/**\n * @Job method decorator\n *\n * Registers a method as a job handler. The method will be called when a job\n * with the matching name is picked up for processing.\n *\n * @param name - Job name (combined with controller namespace if present).\n * @param options - Job configuration options.\n *\n * @example\n * ```typescript\n * @JobController(\"notifications\")\n * export class NotificationJobs {\n * @Job(\"push\", { concurrency: 10 })\n * async sendPush(job: Job<PushPayload>) {\n * await pushService.send(job.data);\n * }\n * }\n * ```\n */\nimport { Store } from '@tsed/core';\n\nimport { MONQUE } from '@/constants';\n\nimport type { JobDecoratorOptions, JobMetadata, JobStore } from './types.js';\n\n/**\n * Method decorator that registers a method as a job handler.\n *\n * @param name - The job name (will be prefixed with controller namespace if present)\n * @param options - Optional job configuration (concurrency, replace, etc.)\n */\nexport function Job(name: string, options?: JobDecoratorOptions): MethodDecorator {\n\treturn <T>(\n\t\ttarget: object,\n\t\tpropertyKey: string | symbol,\n\t\t_descriptor: TypedPropertyDescriptor<T>,\n\t): void => {\n\t\tconst methodName = String(propertyKey);\n\n\t\tconst jobMetadata: JobMetadata = {\n\t\t\tname,\n\t\t\tmethod: methodName,\n\t\t\topts: options || {},\n\t\t};\n\n\t\t// Get the class constructor (target is the prototype for instance methods)\n\t\tconst targetConstructor = target.constructor;\n\t\tconst store = Store.from(targetConstructor);\n\n\t\t// Get or initialize the MONQUE store\n\t\tconst existing = store.get<Partial<JobStore>>(MONQUE) || {\n\t\t\ttype: 'controller',\n\t\t\tjobs: [],\n\t\t\tcronJobs: [],\n\t\t};\n\n\t\t// Add this job to the list\n\t\tconst jobs = [...(existing.jobs || []), jobMetadata];\n\n\t\tstore.set(MONQUE, {\n\t\t\t...existing,\n\t\t\tjobs,\n\t\t});\n\t};\n}\n","/**\n * @JobController class decorator\n *\n * Marks a class as containing job methods and registers it with the Ts.ED DI container.\n * Jobs in the class will have their job names prefixed with the namespace.\n *\n * @param namespace - Optional prefix for all job names in this controller.\n * When set, job names become \"{namespace}.{name}\".\n *\n * @example\n * ```typescript\n * @JobController(\"email\")\n * export class EmailJobs {\n * @Job(\"send\") // Registered as \"email.send\"\n * async send(job: Job<EmailPayload>) { }\n * }\n * ```\n */\nimport { Store, useDecorators } from '@tsed/core';\nimport { Injectable } from '@tsed/di';\n\nimport { MONQUE, ProviderTypes } from '@/constants';\n\nimport type { JobStore } from './types.js';\n\n/**\n * Class decorator that registers a class as a job controller.\n *\n * @param namespace - Optional namespace prefix for job names\n */\nexport function JobController(namespace?: string): ClassDecorator {\n\treturn useDecorators(\n\t\t// Register as injectable with custom provider type\n\t\tInjectable({\n\t\t\ttype: ProviderTypes.JOB_CONTROLLER,\n\t\t}),\n\t\t// Apply custom decorator to store metadata\n\t\t(target: object) => {\n\t\t\tconst store = Store.from(target);\n\n\t\t\t// Get existing store or create new one\n\t\t\tconst existing = store.get<Partial<JobStore>>(MONQUE) || {};\n\n\t\t\t// Merge with new metadata, only include namespace if defined\n\t\t\tconst jobStore: JobStore = {\n\t\t\t\ttype: 'controller',\n\t\t\t\t...(namespace !== undefined && { namespace }),\n\t\t\t\tjobs: existing.jobs || [],\n\t\t\t\tcronJobs: existing.cronJobs || [],\n\t\t\t};\n\n\t\t\tstore.set(MONQUE, jobStore);\n\t\t},\n\t);\n}\n","/**\n * MonqueService - Injectable wrapper for Monque\n *\n * Provides a DI-friendly interface to the Monque job queue.\n * All methods delegate to the underlying Monque instance.\n *\n * @example\n * ```typescript\n * @Service()\n * export class OrderService {\n * @Inject()\n * private monque: MonqueService;\n *\n * async createOrder(data: CreateOrderDto) {\n * const order = await this.save(data);\n * await this.monque.enqueue(\"order.process\", { orderId: order.id });\n * return order;\n * }\n * }\n * ```\n */\n\nimport type {\n\tBulkOperationResult,\n\tCursorOptions,\n\tCursorPage,\n\tEnqueueOptions,\n\tGetJobsFilter,\n\tJobSelector,\n\tMonque,\n\tPersistedJob,\n\tQueueStats,\n\tScheduleOptions,\n} from '@monque/core';\nimport { MonqueError } from '@monque/core';\nimport { Injectable } from '@tsed/di';\nimport { ObjectId } from 'mongodb';\n\n/**\n * Injectable service that wraps the Monque instance.\n *\n * Exposes the full Monque public API through dependency injection.\n */\n@Injectable()\nexport class MonqueService {\n\t/**\n\t * Internal Monque instance (set by MonqueModule)\n\t * @internal\n\t */\n\tprivate _monque: Monque | null = null;\n\n\t/**\n\t * Set the internal Monque instance.\n\t * Called by MonqueModule during initialization.\n\t * @internal\n\t */\n\t_setMonque(monque: Monque): void {\n\t\tthis._monque = monque;\n\t}\n\n\t/**\n\t * Access the underlying Monque instance.\n\t * @throws Error if MonqueModule is not initialized\n\t */\n\tget monque(): Monque {\n\t\tif (!this._monque) {\n\t\t\tthrow new MonqueError(\n\t\t\t\t'MonqueService is not initialized. Ensure MonqueModule is imported and enabled.',\n\t\t\t);\n\t\t}\n\n\t\treturn this._monque;\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Job Scheduling\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\t/**\n\t * Enqueue a job for processing.\n\t *\n\t * @param name - Job type identifier (use full namespaced name, e.g., \"email.send\")\n\t * @param data - Job payload\n\t * @param options - Scheduling and deduplication options\n\t * @returns The created or existing job document\n\t */\n\tasync enqueue<T>(name: string, data: T, options?: EnqueueOptions): Promise<PersistedJob<T>> {\n\t\treturn this.monque.enqueue(name, data, options);\n\t}\n\n\t/**\n\t * Enqueue a job for immediate processing.\n\t *\n\t * @param name - Job type identifier\n\t * @param data - Job payload\n\t * @returns The created job document\n\t */\n\tasync now<T>(name: string, data: T): Promise<PersistedJob<T>> {\n\t\treturn this.monque.now(name, data);\n\t}\n\n\t/**\n\t * Schedule a recurring job with a cron expression.\n\t *\n\t * @param cron - Cron expression (5-field standard or predefined like @daily)\n\t * @param name - Job type identifier\n\t * @param data - Job payload\n\t * @param options - Scheduling options\n\t * @returns The created job document\n\t */\n\tasync schedule<T>(\n\t\tcron: string,\n\t\tname: string,\n\t\tdata: T,\n\t\toptions?: ScheduleOptions,\n\t): Promise<PersistedJob<T>> {\n\t\treturn this.monque.schedule(cron, name, data, options);\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Job Management (Single Job Operations)\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\t/**\n\t * Cancel a pending or scheduled job.\n\t *\n\t * @param jobId - The ID of the job to cancel\n\t * @returns The cancelled job, or null if not found\n\t */\n\tasync cancelJob(jobId: string): Promise<PersistedJob<unknown> | null> {\n\t\treturn this.monque.cancelJob(jobId);\n\t}\n\n\t/**\n\t * Retry a failed or cancelled job.\n\t *\n\t * @param jobId - The ID of the job to retry\n\t * @returns The updated job, or null if not found\n\t */\n\tasync retryJob(jobId: string): Promise<PersistedJob<unknown> | null> {\n\t\treturn this.monque.retryJob(jobId);\n\t}\n\n\t/**\n\t * Reschedule a pending job to run at a different time.\n\t *\n\t * @param jobId - The ID of the job to reschedule\n\t * @param runAt - The new Date when the job should run\n\t * @returns The updated job, or null if not found\n\t */\n\tasync rescheduleJob(jobId: string, runAt: Date): Promise<PersistedJob<unknown> | null> {\n\t\treturn this.monque.rescheduleJob(jobId, runAt);\n\t}\n\n\t/**\n\t * Permanently delete a job.\n\t *\n\t * @param jobId - The ID of the job to delete\n\t * @returns true if deleted, false if job not found\n\t */\n\tasync deleteJob(jobId: string): Promise<boolean> {\n\t\treturn this.monque.deleteJob(jobId);\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Job Management (Bulk Operations)\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\t/**\n\t * Cancel multiple jobs matching the given filter.\n\t *\n\t * @param filter - Selector for which jobs to cancel\n\t * @returns Result with count of cancelled jobs\n\t */\n\tasync cancelJobs(filter: JobSelector): Promise<BulkOperationResult> {\n\t\treturn this.monque.cancelJobs(filter);\n\t}\n\n\t/**\n\t * Retry multiple jobs matching the given filter.\n\t *\n\t * @param filter - Selector for which jobs to retry\n\t * @returns Result with count of retried jobs\n\t */\n\tasync retryJobs(filter: JobSelector): Promise<BulkOperationResult> {\n\t\treturn this.monque.retryJobs(filter);\n\t}\n\n\t/**\n\t * Delete multiple jobs matching the given filter.\n\t *\n\t * @param filter - Selector for which jobs to delete\n\t * @returns Result with count of deleted jobs\n\t */\n\tasync deleteJobs(filter: JobSelector): Promise<BulkOperationResult> {\n\t\treturn this.monque.deleteJobs(filter);\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Job Queries\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\t/**\n\t * Get a job by its ID.\n\t *\n\t * @param jobId - The job's ObjectId (as string or ObjectId)\n\t * @returns The job document, or null if not found\n\t * @throws MonqueError if jobId is an invalid hex string\n\t */\n\tasync getJob<T>(jobId: string | ObjectId): Promise<PersistedJob<T> | null> {\n\t\tlet id: ObjectId;\n\n\t\tif (typeof jobId === 'string') {\n\t\t\tif (!ObjectId.isValid(jobId)) {\n\t\t\t\tthrow new MonqueError(`Invalid job ID format: ${jobId}`);\n\t\t\t}\n\t\t\tid = ObjectId.createFromHexString(jobId);\n\t\t} else {\n\t\t\tid = jobId;\n\t\t}\n\n\t\treturn this.monque.getJob(id);\n\t}\n\n\t/**\n\t * Query jobs from the queue with optional filters.\n\t *\n\t * @param filter - Optional filter criteria (name, status, limit, skip)\n\t * @returns Array of matching jobs\n\t */\n\tasync getJobs<T>(filter?: GetJobsFilter): Promise<PersistedJob<T>[]> {\n\t\treturn this.monque.getJobs(filter);\n\t}\n\n\t/**\n\t * Get a paginated list of jobs using opaque cursors.\n\t *\n\t * @param options - Pagination options (cursor, limit, direction, filter)\n\t * @returns Page of jobs with next/prev cursors\n\t */\n\tasync getJobsWithCursor<T>(options?: CursorOptions): Promise<CursorPage<T>> {\n\t\treturn this.monque.getJobsWithCursor(options);\n\t}\n\n\t/**\n\t * Get aggregate statistics for the job queue.\n\t *\n\t * @param filter - Optional filter to scope statistics by job name\n\t * @returns Queue statistics\n\t */\n\tasync getQueueStats(filter?: Pick<JobSelector, 'name'>): Promise<QueueStats> {\n\t\treturn this.monque.getQueueStats(filter);\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Health Check\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\t/**\n\t * Check if the scheduler is healthy and running.\n\t *\n\t * @returns true if running and connected\n\t */\n\tisHealthy(): boolean {\n\t\treturn this.monque.isHealthy();\n\t}\n}\n","/**\n * Build the full job name by combining namespace and name.\n *\n * @param namespace - Optional namespace from @JobController\n * @param name - Job name from @Job or @Cron\n * @returns Full job name (e.g., \"email.send\" or just \"send\")\n *\n * @example\n * ```typescript\n * buildJobName(\"email\", \"send\"); // \"email.send\"\n * buildJobName(undefined, \"send\"); // \"send\"\n * buildJobName(\"\", \"send\"); // \"send\"\n * ```\n */\nexport function buildJobName(namespace: string | undefined, name: string): string {\n\treturn namespace ? `${namespace}.${name}` : name;\n}\n","/**\n * Collect job metadata utility\n *\n * Collects all job metadata from a class decorated with @JobController.\n * Used by MonqueModule to discover and register all jobs.\n */\nimport { Store } from '@tsed/core';\n\nimport { MONQUE } from '@/constants';\nimport type { CronDecoratorOptions, JobDecoratorOptions, JobStore } from '@/decorators';\n\nimport { buildJobName } from './build-job-name.js';\n\n/**\n * Collected job registration info ready for Monque.register()\n */\nexport interface CollectedJobMetadata {\n\t/**\n\t * Full job name (with namespace prefix if applicable)\n\t */\n\tfullName: string;\n\n\t/**\n\t * Method name on the controller class\n\t */\n\tmethod: string;\n\n\t/**\n\t * Job options to pass to Monque.register()\n\t */\n\topts: JobDecoratorOptions | CronDecoratorOptions;\n\n\t/**\n\t * Whether this is a cron job\n\t */\n\tisCron: boolean;\n\n\t/**\n\t * Cron pattern (only for cron jobs)\n\t */\n\tcronPattern?: string;\n}\n\n/**\n * Collect all job metadata from a class.\n *\n * @param target - The class constructor (decorated with @JobController)\n * @returns Array of collected job metadata ready for registration\n *\n * @example\n * ```typescript\n * const metadata = collectJobMetadata(EmailJobs);\n * // Returns:\n * // [\n * // { fullName: \"email.send\", method: \"sendEmail\", opts: {}, isCron: false },\n * // { fullName: \"email.daily-digest\", method: \"sendDailyDigest\", opts: {}, isCron: true, cronPattern: \"0 9 * * *\" }\n * // ]\n * ```\n */\nexport function collectJobMetadata(\n\ttarget: new (...args: unknown[]) => unknown,\n): CollectedJobMetadata[] {\n\tconst store = Store.from(target);\n\tconst jobStore = store.get<JobStore>(MONQUE);\n\n\tif (!jobStore) {\n\t\treturn [];\n\t}\n\n\tconst results: CollectedJobMetadata[] = [];\n\tconst namespace = jobStore.namespace;\n\n\t// Collect regular jobs\n\tfor (const job of jobStore.jobs) {\n\t\tresults.push({\n\t\t\tfullName: buildJobName(namespace, job.name),\n\t\t\tmethod: job.method,\n\t\t\topts: job.opts,\n\t\t\tisCron: false,\n\t\t});\n\t}\n\n\t// Collect cron jobs\n\tfor (const cron of jobStore.cronJobs) {\n\t\tresults.push({\n\t\t\tfullName: buildJobName(namespace, cron.name),\n\t\t\tmethod: cron.method,\n\t\t\topts: cron.opts,\n\t\t\tisCron: true,\n\t\t\tcronPattern: cron.pattern,\n\t\t});\n\t}\n\n\treturn results;\n}\n","/**\n * Generate a unique token for a job controller.\n *\n * Used internally by Ts.ED DI to identify job controller providers.\n * The token is based on the class name for debugging purposes.\n *\n * @param target - The class constructor\n * @returns A Symbol token unique to this job controller\n *\n * @example\n * ```typescript\n * @JobController(\"email\")\n * class EmailJobs {}\n *\n * const token = getJobToken(EmailJobs);\n * // Symbol(\"monque:job:EmailJobs\")\n * ```\n */\nimport { MonqueError } from '@monque/core';\n\nexport function getJobToken(target: new (...args: unknown[]) => unknown): symbol {\n\tconst name = target.name?.trim();\n\n\tif (!name) {\n\t\tthrow new MonqueError('Job class must have a non-empty name');\n\t}\n\n\treturn Symbol.for(`monque:job:${name}`);\n}\n","/**\n * @monque/tsed - Type Guards\n *\n * Utilities for duck-typing Mongoose and MongoDB related objects\n * to avoid hard dependencies on @tsed/mongoose.\n */\n\nimport type { Db } from 'mongodb';\n\n/**\n * Interface representing a Mongoose Connection object.\n * We only care that it has a `db` property which is a MongoDB Db instance.\n */\nexport interface MongooseConnection {\n\tdb: Db;\n}\n\n/**\n * Interface representing the @tsed/mongoose MongooseService.\n * It acts as a registry/factory for connections.\n */\nexport interface MongooseService {\n\t/**\n\t * Get a connection by its ID (configuration key).\n\t * @param id The connection ID (default: \"default\")\n\t */\n\tget(id?: string): MongooseConnection | undefined;\n}\n\n/**\n * Type guard to check if an object acts like a Mongoose Service.\n *\n * Checks if the object has a `get` method.\n *\n * @param value The value to check\n */\nexport function isMongooseService(value: unknown): value is MongooseService {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t'get' in value &&\n\t\ttypeof (value as MongooseService).get === 'function'\n\t);\n}\n\n/**\n * Type guard to check if an object acts like a Mongoose Connection.\n *\n * Checks if the object has a `db` property.\n *\n * @param value The value to check\n */\nexport function isMongooseConnection(value: unknown): value is MongooseConnection {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t'db' in value &&\n\t\ttypeof (value as MongooseConnection).db === 'object' &&\n\t\t(value as MongooseConnection).db !== null &&\n\t\ttypeof (value as MongooseConnection).db.collection === 'function'\n\t);\n}\n","/**\n * @monque/tsed - Database Resolution Utility\n *\n * Multi-strategy database resolution for flexible MongoDB connection handling.\n */\n\nimport { ConnectionError } from '@monque/core';\nimport type { TokenProvider } from '@tsed/di';\nimport type { Db } from 'mongodb';\n\nimport type { MonqueTsedConfig } from '@/config';\n\nimport { isMongooseConnection, isMongooseService } from './guards.js';\n\n/**\n * Type for the injector function used to resolve DI tokens.\n */\nexport type InjectorFn = <T>(token: TokenProvider<T>) => T | undefined;\n\n/**\n * Resolve the MongoDB database instance from the configuration.\n *\n * Supports three resolution strategies:\n * 1. **Direct `db`**: Returns the provided Db instance directly\n * 2. **Factory `dbFactory`**: Calls the factory function (supports async)\n * 3. **DI Token `dbToken`**: Resolves the Db from the DI container\n *\n * @param config - The Monque configuration containing database settings\n * @param injectorFn - Optional function to resolve DI tokens (required for dbToken strategy)\n * @returns The resolved MongoDB Db instance\n * @throws Error if no database strategy is provided or if DI resolution fails\n *\n * @example\n * ```typescript\n * // Direct Db instance\n * const db = await resolveDatabase({ db: mongoDb });\n *\n * // Factory function\n * const db = await resolveDatabase({\n * dbFactory: async () => {\n * const client = await MongoClient.connect(uri);\n * return client.db(\"myapp\");\n * }\n * });\n *\n * // DI token\n * const db = await resolveDatabase(\n * { dbToken: \"MONGODB_DATABASE\" },\n * (token) => injector.get(token)\n * );\n * ```\n */\nexport async function resolveDatabase(\n\tconfig: MonqueTsedConfig,\n\tinjectorFn?: InjectorFn,\n): Promise<Db> {\n\t// Strategy 1: Direct Db instance\n\tif (config.db) {\n\t\treturn config.db;\n\t}\n\n\t// Strategy 2: Factory function (sync or async)\n\tif (config.dbFactory) {\n\t\treturn config.dbFactory();\n\t}\n\n\t// Strategy 3: DI token resolution\n\tif (config.dbToken) {\n\t\tif (!injectorFn) {\n\t\t\tthrow new ConnectionError(\n\t\t\t\t'MonqueTsedConfig.dbToken requires an injector function to resolve the database',\n\t\t\t);\n\t\t}\n\n\t\tconst resolved = injectorFn(config.dbToken);\n\n\t\tif (!resolved) {\n\t\t\tthrow new ConnectionError(\n\t\t\t\t`Could not resolve database from token: ${String(config.dbToken)}. ` +\n\t\t\t\t\t'Make sure the provider is registered in the DI container.',\n\t\t\t);\n\t\t}\n\n\t\tif (isMongooseService(resolved)) {\n\t\t\t// Check for Mongoose Service (duck typing)\n\t\t\t// It has a get() method that returns a connection\n\t\t\tconst connectionId = config.mongooseConnectionId || 'default';\n\t\t\tconst connection = resolved.get(connectionId);\n\n\t\t\tif (!connection) {\n\t\t\t\tthrow new ConnectionError(\n\t\t\t\t\t`MongooseService resolved from token \"${String(config.dbToken)}\" returned no connection for ID \"${connectionId}\". ` +\n\t\t\t\t\t\t'Ensure the connection ID is correct and the connection is established.',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ('db' in connection && connection.db) {\n\t\t\t\treturn connection.db as Db;\n\t\t\t}\n\t\t}\n\n\t\tif (isMongooseConnection(resolved)) {\n\t\t\t// Check for Mongoose Connection (duck typing)\n\t\t\t// It has a db property that is the native Db instance\n\t\t\treturn resolved.db as Db;\n\t\t}\n\n\t\t// Default: Assume it is a native Db instance\n\t\tif (typeof resolved !== 'object' || resolved === null || !('collection' in resolved)) {\n\t\t\tthrow new ConnectionError(\n\t\t\t\t`Resolved value from token \"${String(config.dbToken)}\" does not appear to be a valid MongoDB Db instance.`,\n\t\t\t);\n\t\t}\n\n\t\treturn resolved as Db;\n\t}\n\n\t// No strategy provided\n\tthrow new ConnectionError(\"MonqueTsedConfig requires 'db', 'dbFactory', or 'dbToken' to be set\");\n}\n","/**\n * MonqueModule - Main Integration Module\n *\n * Orchestrates the integration between Monque and Ts.ED.\n * Handles lifecycle hooks, configuration resolution, and job registration.\n */\n\nimport {\n\ttype Job,\n\tMonque,\n\tMonqueError,\n\ttype MonqueOptions,\n\ttype ScheduleOptions,\n\ttype WorkerOptions,\n\tWorkerRegistrationError,\n} from '@monque/core';\nimport {\n\tConfiguration,\n\tDIContext,\n\tInject,\n\tInjectorService,\n\tLOGGER,\n\tModule,\n\ttype OnDestroy,\n\ttype OnInit,\n\tProviderScope,\n\trunInContext,\n\ttype TokenProvider,\n} from '@tsed/di';\n\nimport { type MonqueTsedConfig, validateDatabaseConfig } from '@/config';\nimport { ProviderTypes } from '@/constants';\nimport { MonqueService } from '@/services';\nimport { collectJobMetadata, resolveDatabase } from '@/utils';\n\n@Module({\n\timports: [MonqueService],\n})\nexport class MonqueModule implements OnInit, OnDestroy {\n\tprotected injector: InjectorService;\n\tprotected monqueService: MonqueService;\n\tprotected logger: LOGGER;\n\tprotected monqueConfig: MonqueTsedConfig;\n\n\tprotected monque: Monque | null = null;\n\n\tconstructor(\n\t\t@Inject(InjectorService) injector: InjectorService,\n\t\t@Inject(MonqueService) monqueService: MonqueService,\n\t\t@Inject(LOGGER) logger: LOGGER,\n\t\t@Inject(Configuration) configuration: Configuration,\n\t) {\n\t\tthis.injector = injector;\n\t\tthis.monqueService = monqueService;\n\t\tthis.logger = logger;\n\t\tthis.monqueConfig = configuration.get<MonqueTsedConfig>('monque') || {};\n\t}\n\n\tasync $onInit(): Promise<void> {\n\t\tconst config = this.monqueConfig;\n\n\t\tif (config?.enabled === false) {\n\t\t\tthis.logger.info('Monque integration is disabled');\n\n\t\t\treturn;\n\t\t}\n\n\t\tvalidateDatabaseConfig(config);\n\n\t\ttry {\n\t\t\tconst db = await resolveDatabase(config, (token) =>\n\t\t\t\tthis.injector.get(token as TokenProvider),\n\t\t\t);\n\n\t\t\t// We construct the options object carefully to match MonqueOptions\n\t\t\tconst { db: _db, ...restConfig } = config;\n\t\t\tconst options: MonqueOptions = restConfig;\n\n\t\t\tthis.monque = new Monque(db, options);\n\t\t\tthis.monqueService._setMonque(this.monque);\n\n\t\t\tthis.logger.info('Monque: Connecting to MongoDB...');\n\t\t\tawait this.monque.initialize();\n\n\t\t\tif (config.disableJobProcessing) {\n\t\t\t\tthis.logger.info('Monque: Job processing is disabled for this instance');\n\t\t\t} else {\n\t\t\t\tawait this.registerJobs();\n\t\t\t\tawait this.monque.start();\n\t\t\t\tthis.logger.info('Monque: Started successfully');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.logger.error({\n\t\t\t\tevent: 'MONQUE_INIT_ERROR',\n\t\t\t\tmessage: 'Failed to initialize Monque',\n\t\t\t\terror,\n\t\t\t});\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync $onDestroy(): Promise<void> {\n\t\tif (this.monque) {\n\t\t\tthis.logger.info('Monque: Stopping...');\n\n\t\t\tawait this.monque.stop();\n\n\t\t\tthis.logger.info('Monque: Stopped');\n\t\t}\n\t}\n\n\t/**\n\t * Discover and register all jobs from @JobController providers\n\t */\n\tprotected async registerJobs(): Promise<void> {\n\t\tif (!this.monque) {\n\t\t\tthrow new MonqueError('Monque instance not initialized');\n\t\t}\n\n\t\tconst monque = this.monque;\n\t\tconst jobControllers = this.injector.getProviders(ProviderTypes.JOB_CONTROLLER);\n\t\tconst registeredJobs = new Set<string>();\n\n\t\tthis.logger.info(`Monque: Found ${jobControllers.length} job controllers`);\n\n\t\tfor (const provider of jobControllers) {\n\t\t\tconst useClass = provider.useClass;\n\t\t\tconst jobs = collectJobMetadata(useClass);\n\t\t\t// Try to resolve singleton instance immediately\n\t\t\tconst instance = this.injector.get(provider.token);\n\n\t\t\tif (!instance && provider.scope !== ProviderScope.REQUEST) {\n\t\t\t\tthis.logger.warn(\n\t\t\t\t\t`Monque: Could not resolve instance for controller ${provider.name}. Skipping.`,\n\t\t\t\t);\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const job of jobs) {\n\t\t\t\tconst { fullName, method, opts, isCron, cronPattern } = job;\n\n\t\t\t\tif (registeredJobs.has(fullName)) {\n\t\t\t\t\tthrow new WorkerRegistrationError(\n\t\t\t\t\t\t`Monque: Duplicate job registration detected. Job \"${fullName}\" is already registered.`,\n\t\t\t\t\t\tfullName,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tregisteredJobs.add(fullName);\n\n\t\t\t\tconst handler = async (job: Job) => {\n\t\t\t\t\tconst $ctx = new DIContext({\n\t\t\t\t\t\tinjector: this.injector,\n\t\t\t\t\t\tid: job._id?.toString() || 'unknown',\n\t\t\t\t\t});\n\t\t\t\t\t$ctx.set('MONQUE_JOB', job);\n\t\t\t\t\t$ctx.container.set(DIContext, $ctx);\n\n\t\t\t\t\tawait runInContext($ctx, async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tlet targetInstance = instance;\n\t\t\t\t\t\t\tif (provider.scope === ProviderScope.REQUEST || !targetInstance) {\n\t\t\t\t\t\t\t\ttargetInstance = await this.injector.invoke(provider.token, {\n\t\t\t\t\t\t\t\t\tlocals: $ctx.container,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst typedInstance = targetInstance as Record<string, (job: Job) => unknown>;\n\n\t\t\t\t\t\t\tif (typedInstance && typeof typedInstance[method] === 'function') {\n\t\t\t\t\t\t\t\tawait typedInstance[method](job);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tthis.logger.error({\n\t\t\t\t\t\t\t\tevent: 'MONQUE_JOB_ERROR',\n\t\t\t\t\t\t\t\tjobName: fullName,\n\t\t\t\t\t\t\t\tjobId: job._id,\n\t\t\t\t\t\t\t\tmessage: `Error processing job ${fullName}`,\n\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\tawait $ctx.destroy();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tif (isCron && cronPattern) {\n\t\t\t\t\tthis.logger.debug(`Monque: Registering cron job \"${fullName}\" (${cronPattern})`);\n\n\t\t\t\t\tmonque.register(fullName, handler, opts as WorkerOptions);\n\t\t\t\t\tawait monque.schedule(cronPattern, fullName, {}, opts as ScheduleOptions);\n\t\t\t\t} else {\n\t\t\t\t\tthis.logger.debug(`Monque: Registering job \"${fullName}\"`);\n\t\t\t\t\tmonque.register(fullName, handler, opts as WorkerOptions);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.logger.info(`Monque: Registered ${registeredJobs.size} jobs`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+C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AAM;QACjB,OAAO;QACP,SAAS;QACT,OAAO,IAAI;QACX,SAAS,wBAAwB;QACjC;QACA,CAAC;AACF,aAAM;gBACG;AACT,aAAM,KAAK,SAAS;;OAEpB;;AAGH,QAAI,UAAU,aAAa;AAC1B,UAAK,OAAO,MAAM,iCAAiC,SAAS,KAAK,YAAY,GAAG;AAEhF,YAAO,SAAS,UAAU,SAAS,KAAsB;AACzD,WAAM,OAAO,SAAS,aAAa,UAAU,EAAE,EAAE,KAAwB;WACnE;AACN,UAAK,OAAO,MAAM,4BAA4B,SAAS,GAAG;AAC1D,YAAO,SAAS,UAAU,SAAS,KAAsB;;;;AAK5D,OAAK,OAAO,KAAK,sBAAsB,eAAe,KAAK,OAAO;;;;sBAtK5D,EACP,SAAS,CAAC,cAAc,EACxB,CAAC;yCAUQG,yBAAgB;yCAChB,cAAc;yCACdC,gBAAO;yCACPC,uBAAc"}
|
package/dist/index.d.cts
CHANGED
|
@@ -21,12 +21,12 @@ import { Db, ObjectId } from "mongodb";
|
|
|
21
21
|
* export class Server {}
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
interface MonqueTsedConfig extends
|
|
24
|
+
interface MonqueTsedConfig extends MonqueOptions {
|
|
25
25
|
/**
|
|
26
26
|
* Enable or disable the Monque module.
|
|
27
27
|
*
|
|
28
28
|
* When disabled:
|
|
29
|
-
* -
|
|
29
|
+
* - Jobs are not registered
|
|
30
30
|
* - Lifecycle hooks are no-ops
|
|
31
31
|
* - MonqueService throws on access
|
|
32
32
|
*
|
|
@@ -104,6 +104,38 @@ interface MonqueTsedConfig extends Omit<MonqueOptions, 'db'> {
|
|
|
104
104
|
* @default "default"
|
|
105
105
|
*/
|
|
106
106
|
mongooseConnectionId?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Disable job processing on this instance.
|
|
109
|
+
*
|
|
110
|
+
* When true, the module will initialize the database connection (allowing you to
|
|
111
|
+
* enqueue jobs via MonqueService) but will NOT register jobs or start the
|
|
112
|
+
* polling loop. Useful for "Producer-only" nodes like API servers that only
|
|
113
|
+
* enqueue jobs but don't process them.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* // API Server (Producer-only)
|
|
118
|
+
* @Configuration({
|
|
119
|
+
* monque: {
|
|
120
|
+
* dbFactory: async () => client.db('myapp'),
|
|
121
|
+
* disableJobProcessing: true, // Only enqueue, don't process
|
|
122
|
+
* }
|
|
123
|
+
* })
|
|
124
|
+
* export class ApiServer {}
|
|
125
|
+
*
|
|
126
|
+
* // Job Server (Consumer)
|
|
127
|
+
* @Configuration({
|
|
128
|
+
* monque: {
|
|
129
|
+
* dbFactory: async () => client.db('myapp'),
|
|
130
|
+
* // disableJobProcessing defaults to false - processes jobs
|
|
131
|
+
* }
|
|
132
|
+
* })
|
|
133
|
+
* export class JobServer {}
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @default false
|
|
137
|
+
*/
|
|
138
|
+
disableJobProcessing?: boolean;
|
|
107
139
|
}
|
|
108
140
|
//#endregion
|
|
109
141
|
//#region src/config/config.d.ts
|
|
@@ -141,7 +173,7 @@ declare function validateDatabaseConfig(config: MonqueTsedConfig): void;
|
|
|
141
173
|
/**
|
|
142
174
|
* Symbol used to store decorator metadata on class constructors.
|
|
143
175
|
*
|
|
144
|
-
* Used by @
|
|
176
|
+
* Used by @JobController, @Job, and @Cron decorators to attach
|
|
145
177
|
* metadata that is later collected by MonqueModule during initialization.
|
|
146
178
|
*
|
|
147
179
|
* @example
|
|
@@ -157,13 +189,13 @@ declare const MONQUE: unique symbol;
|
|
|
157
189
|
*
|
|
158
190
|
* These constants are used to categorize providers registered with Ts.ED's
|
|
159
191
|
* dependency injection container, enabling MonqueModule to discover and
|
|
160
|
-
* register
|
|
192
|
+
* register jobs automatically.
|
|
161
193
|
*
|
|
162
194
|
* Note: Using string constants with `as const` instead of enums per
|
|
163
195
|
* Constitution guidelines.
|
|
164
196
|
*/
|
|
165
197
|
declare const ProviderTypes: {
|
|
166
|
-
/** Provider type for @
|
|
198
|
+
/** Provider type for @JobController decorated classes */readonly JOB_CONTROLLER: "monque:job-controller"; /** Provider type for cron job handlers */
|
|
167
199
|
readonly CRON: "monque:cron";
|
|
168
200
|
};
|
|
169
201
|
/**
|
|
@@ -173,18 +205,18 @@ type ProviderType = (typeof ProviderTypes)[keyof typeof ProviderTypes];
|
|
|
173
205
|
//#endregion
|
|
174
206
|
//#region src/decorators/types.d.ts
|
|
175
207
|
/**
|
|
176
|
-
* Options for the @
|
|
208
|
+
* Options for the @Job method decorator.
|
|
177
209
|
*
|
|
178
210
|
* Maps to @monque/core WorkerOptions. All standard Monque worker options
|
|
179
211
|
* are exposed here for decorator-based configuration.
|
|
180
212
|
*/
|
|
181
|
-
interface
|
|
213
|
+
interface JobDecoratorOptions extends WorkerOptions {}
|
|
182
214
|
/**
|
|
183
|
-
* Metadata for a single @
|
|
215
|
+
* Metadata for a single @Job decorated method.
|
|
184
216
|
*
|
|
185
|
-
* Stored in the
|
|
217
|
+
* Stored in the JobStore and used by MonqueModule to register workers.
|
|
186
218
|
*/
|
|
187
|
-
interface
|
|
219
|
+
interface JobMetadata {
|
|
188
220
|
/**
|
|
189
221
|
* Job name (without namespace prefix).
|
|
190
222
|
* Combined with controller namespace to form full job name.
|
|
@@ -195,9 +227,9 @@ interface WorkerMetadata {
|
|
|
195
227
|
*/
|
|
196
228
|
method: string;
|
|
197
229
|
/**
|
|
198
|
-
*
|
|
230
|
+
* Job options forwarded to Monque.register().
|
|
199
231
|
*/
|
|
200
|
-
opts:
|
|
232
|
+
opts: JobDecoratorOptions;
|
|
201
233
|
}
|
|
202
234
|
/**
|
|
203
235
|
* Options for the @Cron method decorator.
|
|
@@ -213,7 +245,7 @@ interface CronDecoratorOptions extends ScheduleOptions {
|
|
|
213
245
|
/**
|
|
214
246
|
* Metadata for a single @Cron decorated method.
|
|
215
247
|
*
|
|
216
|
-
* Stored in the
|
|
248
|
+
* Stored in the JobStore and used by MonqueModule to schedule cron jobs.
|
|
217
249
|
*/
|
|
218
250
|
interface CronMetadata {
|
|
219
251
|
/**
|
|
@@ -234,21 +266,21 @@ interface CronMetadata {
|
|
|
234
266
|
opts: CronDecoratorOptions;
|
|
235
267
|
}
|
|
236
268
|
/**
|
|
237
|
-
* Complete metadata structure stored on @
|
|
269
|
+
* Complete metadata structure stored on @JobController classes.
|
|
238
270
|
*
|
|
239
271
|
* Accessed via `Store.from(Class).get(MONQUE)`.
|
|
240
272
|
*
|
|
241
273
|
* @example
|
|
242
274
|
* ```typescript
|
|
243
|
-
* const store = Store.from(
|
|
275
|
+
* const store = Store.from(EmailJobs).get<JobStore>(MONQUE);
|
|
244
276
|
* console.log(store.namespace); // "email"
|
|
245
|
-
* console.log(store.
|
|
277
|
+
* console.log(store.jobs); // [{ name: "send", method: "sendEmail", opts: {} }]
|
|
246
278
|
* ```
|
|
247
279
|
*/
|
|
248
|
-
interface
|
|
280
|
+
interface JobStore {
|
|
249
281
|
/**
|
|
250
282
|
* Type identifier for the store.
|
|
251
|
-
* Always "controller" for
|
|
283
|
+
* Always "controller" for JobController.
|
|
252
284
|
*/
|
|
253
285
|
type: 'controller';
|
|
254
286
|
/**
|
|
@@ -257,9 +289,9 @@ interface WorkerStore {
|
|
|
257
289
|
*/
|
|
258
290
|
namespace?: string;
|
|
259
291
|
/**
|
|
260
|
-
*
|
|
292
|
+
* Job method registrations from @Job decorators.
|
|
261
293
|
*/
|
|
262
|
-
|
|
294
|
+
jobs: JobMetadata[];
|
|
263
295
|
/**
|
|
264
296
|
* Cron job registrations from @Cron decorators.
|
|
265
297
|
*/
|
|
@@ -275,8 +307,8 @@ interface WorkerStore {
|
|
|
275
307
|
*
|
|
276
308
|
* @example
|
|
277
309
|
* ```typescript
|
|
278
|
-
* @
|
|
279
|
-
* class
|
|
310
|
+
* @JobController()
|
|
311
|
+
* class ReportJobs {
|
|
280
312
|
* @Cron("@daily", { timezone: "UTC" })
|
|
281
313
|
* async generateDailyReport() {
|
|
282
314
|
* // ...
|
|
@@ -286,22 +318,22 @@ interface WorkerStore {
|
|
|
286
318
|
*/
|
|
287
319
|
declare function Cron(pattern: string, options?: CronDecoratorOptions): MethodDecorator;
|
|
288
320
|
//#endregion
|
|
289
|
-
//#region src/decorators/
|
|
321
|
+
//#region src/decorators/job.d.ts
|
|
290
322
|
/**
|
|
291
323
|
* Method decorator that registers a method as a job handler.
|
|
292
324
|
*
|
|
293
325
|
* @param name - The job name (will be prefixed with controller namespace if present)
|
|
294
|
-
* @param options - Optional
|
|
326
|
+
* @param options - Optional job configuration (concurrency, replace, etc.)
|
|
295
327
|
*/
|
|
296
|
-
declare function
|
|
328
|
+
declare function Job(name: string, options?: JobDecoratorOptions): MethodDecorator;
|
|
297
329
|
//#endregion
|
|
298
|
-
//#region src/decorators/
|
|
330
|
+
//#region src/decorators/job-controller.d.ts
|
|
299
331
|
/**
|
|
300
|
-
* Class decorator that registers a class as a
|
|
332
|
+
* Class decorator that registers a class as a job controller.
|
|
301
333
|
*
|
|
302
334
|
* @param namespace - Optional namespace prefix for job names
|
|
303
335
|
*/
|
|
304
|
-
declare function
|
|
336
|
+
declare function JobController(namespace?: string): ClassDecorator;
|
|
305
337
|
//#endregion
|
|
306
338
|
//#region src/services/monque-service.d.ts
|
|
307
339
|
/**
|
|
@@ -451,17 +483,17 @@ declare class MonqueModule implements OnInit, OnDestroy {
|
|
|
451
483
|
$onInit(): Promise<void>;
|
|
452
484
|
$onDestroy(): Promise<void>;
|
|
453
485
|
/**
|
|
454
|
-
* Discover and register all
|
|
486
|
+
* Discover and register all jobs from @JobController providers
|
|
455
487
|
*/
|
|
456
|
-
protected
|
|
488
|
+
protected registerJobs(): Promise<void>;
|
|
457
489
|
}
|
|
458
490
|
//#endregion
|
|
459
491
|
//#region src/utils/build-job-name.d.ts
|
|
460
492
|
/**
|
|
461
493
|
* Build the full job name by combining namespace and name.
|
|
462
494
|
*
|
|
463
|
-
* @param namespace - Optional namespace from @
|
|
464
|
-
* @param name - Job name from @
|
|
495
|
+
* @param namespace - Optional namespace from @JobController
|
|
496
|
+
* @param name - Job name from @Job or @Cron
|
|
465
497
|
* @returns Full job name (e.g., "email.send" or just "send")
|
|
466
498
|
*
|
|
467
499
|
* @example
|
|
@@ -473,11 +505,11 @@ declare class MonqueModule implements OnInit, OnDestroy {
|
|
|
473
505
|
*/
|
|
474
506
|
declare function buildJobName(namespace: string | undefined, name: string): string;
|
|
475
507
|
//#endregion
|
|
476
|
-
//#region src/utils/collect-
|
|
508
|
+
//#region src/utils/collect-job-metadata.d.ts
|
|
477
509
|
/**
|
|
478
|
-
* Collected
|
|
510
|
+
* Collected job registration info ready for Monque.register()
|
|
479
511
|
*/
|
|
480
|
-
interface
|
|
512
|
+
interface CollectedJobMetadata {
|
|
481
513
|
/**
|
|
482
514
|
* Full job name (with namespace prefix if applicable)
|
|
483
515
|
*/
|
|
@@ -487,9 +519,9 @@ interface CollectedWorkerMetadata {
|
|
|
487
519
|
*/
|
|
488
520
|
method: string;
|
|
489
521
|
/**
|
|
490
|
-
*
|
|
522
|
+
* Job options to pass to Monque.register()
|
|
491
523
|
*/
|
|
492
|
-
opts:
|
|
524
|
+
opts: JobDecoratorOptions | CronDecoratorOptions;
|
|
493
525
|
/**
|
|
494
526
|
* Whether this is a cron job
|
|
495
527
|
*/
|
|
@@ -500,14 +532,14 @@ interface CollectedWorkerMetadata {
|
|
|
500
532
|
cronPattern?: string;
|
|
501
533
|
}
|
|
502
534
|
/**
|
|
503
|
-
* Collect all
|
|
535
|
+
* Collect all job metadata from a class.
|
|
504
536
|
*
|
|
505
|
-
* @param target - The class constructor (decorated with @
|
|
506
|
-
* @returns Array of collected
|
|
537
|
+
* @param target - The class constructor (decorated with @JobController)
|
|
538
|
+
* @returns Array of collected job metadata ready for registration
|
|
507
539
|
*
|
|
508
540
|
* @example
|
|
509
541
|
* ```typescript
|
|
510
|
-
* const metadata =
|
|
542
|
+
* const metadata = collectJobMetadata(EmailJobs);
|
|
511
543
|
* // Returns:
|
|
512
544
|
* // [
|
|
513
545
|
* // { fullName: "email.send", method: "sendEmail", opts: {}, isCron: false },
|
|
@@ -515,28 +547,10 @@ interface CollectedWorkerMetadata {
|
|
|
515
547
|
* // ]
|
|
516
548
|
* ```
|
|
517
549
|
*/
|
|
518
|
-
declare function
|
|
550
|
+
declare function collectJobMetadata(target: new (...args: unknown[]) => unknown): CollectedJobMetadata[];
|
|
519
551
|
//#endregion
|
|
520
|
-
//#region src/utils/get-
|
|
521
|
-
|
|
522
|
-
* Generate a unique token for a worker controller.
|
|
523
|
-
*
|
|
524
|
-
* Used internally by Ts.ED DI to identify worker controller providers.
|
|
525
|
-
* The token is based on the class name for debugging purposes.
|
|
526
|
-
*
|
|
527
|
-
* @param target - The class constructor
|
|
528
|
-
* @returns A Symbol token unique to this worker controller
|
|
529
|
-
*
|
|
530
|
-
* @example
|
|
531
|
-
* ```typescript
|
|
532
|
-
* @WorkerController("email")
|
|
533
|
-
* class EmailWorkers {}
|
|
534
|
-
*
|
|
535
|
-
* const token = getWorkerToken(EmailWorkers);
|
|
536
|
-
* // Symbol("monque:worker:EmailWorkers")
|
|
537
|
-
* ```
|
|
538
|
-
*/
|
|
539
|
-
declare function getWorkerToken(target: new (...args: unknown[]) => unknown): symbol;
|
|
552
|
+
//#region src/utils/get-job-token.d.ts
|
|
553
|
+
declare function getJobToken(target: new (...args: unknown[]) => unknown): symbol;
|
|
540
554
|
//#endregion
|
|
541
555
|
//#region src/utils/resolve-database.d.ts
|
|
542
556
|
/**
|
|
@@ -578,5 +592,5 @@ type InjectorFn = <T>(token: TokenProvider<T>) => T | undefined;
|
|
|
578
592
|
*/
|
|
579
593
|
declare function resolveDatabase(config: MonqueTsedConfig, injectorFn?: InjectorFn): Promise<Db>;
|
|
580
594
|
//#endregion
|
|
581
|
-
export { type
|
|
595
|
+
export { type CollectedJobMetadata, Cron, type CronDecoratorOptions, type CronMetadata, type InjectorFn, Job, JobController, type JobDecoratorOptions, type JobMetadata, type JobStore, MONQUE, MonqueModule, MonqueService, type MonqueTsedConfig, type ProviderType, ProviderTypes, buildJobName, collectJobMetadata, getJobToken, resolveDatabase, validateDatabaseConfig };
|
|
582
596
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/config/types.ts","../src/config/config.ts","../src/constants/constants.ts","../src/constants/types.ts","../src/decorators/types.ts","../src/decorators/cron.ts","../src/decorators/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/config/types.ts","../src/config/config.ts","../src/constants/constants.ts","../src/constants/types.ts","../src/decorators/types.ts","../src/decorators/cron.ts","../src/decorators/job.ts","../src/decorators/job-controller.ts","../src/services/monque-service.ts","../src/monque-module.ts","../src/utils/build-job-name.ts","../src/utils/collect-job-metadata.ts","../src/utils/get-job-token.ts","../src/utils/resolve-database.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UA0BiB,gBAAA,SAAyB,aAAA;EA6EzC;;;;;;;;;;EAlEA,OAAA;EC7BkD;;;;;;;;;;;AAuCnD;;;;EDOC,EAAA,GAAK,EAAA;;;;AE3CN;;;;;;;;ACDA;;;;;AAUA;;EHsDC,SAAA,SAAkB,OAAA,CAAQ,EAAA,IAAM,EAAA;EGtDE;;;;;ACJnC;;;;;AAWA;;;;;;;;;;AA2BA;;;;;AAgBA;;EJiCC,OAAA,GAAU,aAAA,CAAc,EAAA;EIdE;;;;;;;EJuB1B,oBAAA;EIJgB;;;;;;;;;;;;;;;ACtFjB;;;;;;;;;;;;;ACUA;;;ENiHC,oBAAA;AAAA;;;;;;;;QC9HO,MAAA;EAAA,UACG,IAAA;IAAA,UACC,aAAA;MDK8B;;;MCDvC,MAAA,GAAS,gBAAA;IAAA;EAAA;AAAA;;;;;;;;;;;;;;iBAsBI,sBAAA,CAAuB,MAAA,EAAQ,gBAAA;;;;;;;;ADrB/C;;;;;;cEfa,M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