@monque/tsed 1.0.0 → 1.2.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 CHANGED
@@ -26,12 +26,12 @@ A **Ts.ED** integration for **Monque**, a robust, type-safe MongoDB job queue fo
26
26
 
27
27
  ## Features
28
28
 
29
- - 🎯 **Decorator-based API**: `@JobController`, `@Job`, and `@Cron` for declarative job handling.
30
- - 💉 **Dependency Injection**: Full support for Ts.ED DI (inject Services/Providers into your jobs).
31
- - 🔒 **Job Isolation**: Each job execution runs in a dedicated `DIContext` with Request Scope support.
32
- - 🔍 **Type Safety**: Leverage TypeScript generics for fully typed job payloads.
33
- - **Full Monque Power**: Complete access to all `@monque/core` features (backoff, heartbeats, atomic locking).
34
- - 🛠️ **Seamless Integration**: Native lifecycle hooks support (`$onInit`, `$onDestroy`) for graceful scheduler management.
29
+ - **Decorator-based API**: `@JobController`, `@Job`, and `@Cron` for declarative job handling.
30
+ - **Dependency Injection**: Full support for Ts.ED DI (inject Services/Providers into your jobs).
31
+ - **Job Isolation**: Each job execution runs in a dedicated `DIContext` with Request Scope support.
32
+ - **Type Safety**: Leverage TypeScript generics for fully typed job payloads.
33
+ - **Full Monque Power**: Complete access to all `@monque/core` features (backoff, heartbeats, atomic locking).
34
+ - **Seamless Integration**: Native lifecycle hooks support (`$onInit`, `$onDestroy`) for graceful scheduler management.
35
35
 
36
36
  ## Installation
37
37
 
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @monque/tsed
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#171](https://github.com/ueberBrot/monque/pull/171) [`3ddc358`](https://github.com/ueberBrot/monque/commit/3ddc3588fe89b73f4fe01cbfff5acd2051153a7a) Thanks [@renovate](https://github.com/apps/renovate)! - chore(deps): update dependencies
8
+
9
+ - @monque/tsed: @monque/core (^1.2.0 → ^1.3.0)
10
+
11
+ ## 1.1.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#163](https://github.com/ueberBrot/monque/pull/163) [`2d542f6`](https://github.com/ueberBrot/monque/commit/2d542f6b78a8ff9b39ec06a7a5217a3bf05f3e02) Thanks [@ueberBrot](https://github.com/ueberBrot)! - mongodb (^7.0.0 → ^7.1.0)
16
+
17
+ - [#165](https://github.com/ueberBrot/monque/pull/165) [`a9b258e`](https://github.com/ueberBrot/monque/commit/a9b258e3191d96b6e1b5f75a8d99e014fb8d0853) Thanks [@renovate](https://github.com/apps/renovate)! - chore(deps): update dependencies
18
+
19
+ - @monque/tsed: @tsed/core (^8.24.1 → ^8.25.1)
20
+ - @monque/tsed: @tsed/di (^8.24.1 → ^8.25.1)
21
+ - @monque/tsed: @tsed/mongoose (^8.24.1 → ^8.25.1)
22
+
3
23
  ## 1.0.0
4
24
 
5
25
  ### Major Changes
package/dist/README.md CHANGED
@@ -26,12 +26,12 @@ A **Ts.ED** integration for **Monque**, a robust, type-safe MongoDB job queue fo
26
26
 
27
27
  ## Features
28
28
 
29
- - 🎯 **Decorator-based API**: `@JobController`, `@Job`, and `@Cron` for declarative job handling.
30
- - 💉 **Dependency Injection**: Full support for Ts.ED DI (inject Services/Providers into your jobs).
31
- - 🔒 **Job Isolation**: Each job execution runs in a dedicated `DIContext` with Request Scope support.
32
- - 🔍 **Type Safety**: Leverage TypeScript generics for fully typed job payloads.
33
- - **Full Monque Power**: Complete access to all `@monque/core` features (backoff, heartbeats, atomic locking).
34
- - 🛠️ **Seamless Integration**: Native lifecycle hooks support (`$onInit`, `$onDestroy`) for graceful scheduler management.
29
+ - **Decorator-based API**: `@JobController`, `@Job`, and `@Cron` for declarative job handling.
30
+ - **Dependency Injection**: Full support for Ts.ED DI (inject Services/Providers into your jobs).
31
+ - **Job Isolation**: Each job execution runs in a dedicated `DIContext` with Request Scope support.
32
+ - **Type Safety**: Leverage TypeScript generics for fully typed job payloads.
33
+ - **Full Monque Power**: Complete access to all `@monque/core` features (backoff, heartbeats, atomic locking).
34
+ - **Seamless Integration**: Native lifecycle hooks support (`$onInit`, `$onDestroy`) for graceful scheduler management.
35
35
 
36
36
  ## Installation
37
37
 
package/dist/index.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  let _monque_core = require("@monque/core");
2
3
  let _tsed_core = require("@tsed/core");
3
4
  let _tsed_di = require("@tsed/di");
@@ -197,7 +198,7 @@ function JobController(namespace) {
197
198
  }
198
199
 
199
200
  //#endregion
200
- //#region \0@oxc-project+runtime@0.110.0/helpers/decorate.js
201
+ //#region \0@oxc-project+runtime@0.112.0/helpers/decorate.js
201
202
  function __decorate(decorators, target, key, desc) {
202
203
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
203
204
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -554,13 +555,13 @@ async function resolveDatabase(config, injectorFn) {
554
555
  }
555
556
 
556
557
  //#endregion
557
- //#region \0@oxc-project+runtime@0.110.0/helpers/decorateMetadata.js
558
+ //#region \0@oxc-project+runtime@0.112.0/helpers/decorateMetadata.js
558
559
  function __decorateMetadata(k, v) {
559
560
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
560
561
  }
561
562
 
562
563
  //#endregion
563
- //#region \0@oxc-project+runtime@0.110.0/helpers/decorateParam.js
564
+ //#region \0@oxc-project+runtime@0.112.0/helpers/decorateParam.js
564
565
  function __decorateParam(paramIndex, decorator) {
565
566
  return function(target, key) {
566
567
  decorator(target, key, paramIndex);
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["MonqueError","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+CA,SAAgB,uBAAuB,QAAgC;CACtE,MAAM,aAAa;EAAC,OAAO;EAAI,OAAO;EAAW,OAAO;EAAQ,CAAC,OAAO,QAAQ;AAEhF,KAAI,WAAW,WAAW,EACzB,OAAM,IAAIA,yBACT,qFACA;AAGF,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AAO,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"}
1
+ {"version":3,"file":"index.cjs","names":["MonqueError","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+CA,SAAgB,uBAAuB,QAAgC;CACtE,MAAM,aAAa;EAAC,OAAO;EAAI,OAAO;EAAW,OAAO;EAAQ,CAAC,OAAO,QAAQ;AAEhF,KAAI,WAAW,WAAW,EACzB,OAAM,IAAIA,yBACT,qFACA;AAGF,KAAI,WAAW,SAAS,EACvB,OAAM,IAAIA,yBACT,gGACA;;;;;;;;;;;;;;;;AChDH,MAAa,SAAS,OAAO,IAAI,SAAS;;;;;;;;;;;;;;ACD1C,MAAa,gBAAgB;CAE5B,gBAAgB;CAEhB,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,MAAM,WAAW,EAAE;GACnB;EAGD,MAAM,oBAAoB,OAAO;EACjC,MAAM,QAAQC,iBAAM,KAAK,kBAAkB;EAG3C,MAAM,WAAW,MAAM,IAAuB,OAAO,IAAI;GACxD,MAAM;GACN,MAAM,EAAE;GACR,UAAU,EAAE;GACZ;EAGD,MAAM,WAAW,CAAC,GAAI,SAAS,YAAY,EAAE,EAAG,aAAa;AAE7D,QAAM,IAAI,QAAQ;GACjB,GAA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f,IAAI,IAAI,KAAK,UAAU,IAAI;MAC3B,CAAC;AACF,UAAK,IAAI,cAAc,IAAI;AAC3B,UAAK,UAAU,IAAIA,oBAAW,KAAK;AAEnC,sCAAmB,MAAM,YAAY;AACpC,UAAI;OACH,IAAI,iBAAiB;AACrB,WAAI,SAAS,UAAUF,uBAAc,WAAW,CAAC,eAChD,kBAAiB,MAAM,KAAK,SAAS,OAAO,SAAS,OAAO,EAC3D,QAAQ,KAAK,WACb,CAAC;OAGH,MAAM,gBAAgB;AAEtB,WAAI,iBAAiB,OAAO,cAAc,YAAY,WACrD,OAAM,cAAc,QAAQ,IAAI;eAEzB,OAAO;AACf,YAAK,OAAO,MAAM;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.mjs CHANGED
@@ -197,7 +197,7 @@ function JobController(namespace) {
197
197
  }
198
198
 
199
199
  //#endregion
200
- //#region \0@oxc-project+runtime@0.110.0/helpers/decorate.js
200
+ //#region \0@oxc-project+runtime@0.112.0/helpers/decorate.js
201
201
  function __decorate(decorators, target, key, desc) {
202
202
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
203
203
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -554,13 +554,13 @@ async function resolveDatabase(config, injectorFn) {
554
554
  }
555
555
 
556
556
  //#endregion
557
- //#region \0@oxc-project+runtime@0.110.0/helpers/decorateMetadata.js
557
+ //#region \0@oxc-project+runtime@0.112.0/helpers/decorateMetadata.js
558
558
  function __decorateMetadata(k, v) {
559
559
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
560
560
  }
561
561
 
562
562
  //#endregion
563
- //#region \0@oxc-project+runtime@0.110.0/helpers/decorateParam.js
563
+ //#region \0@oxc-project+runtime@0.112.0/helpers/decorateParam.js
564
564
  function __decorateParam(paramIndex, decorator) {
565
565
  return function(target, key) {
566
566
  decorator(target, key, paramIndex);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monque/tsed",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Ts.ED integration for Monque - A robust, type-safe MongoDB job queue for TypeScript",
5
5
  "author": "Maurice de Bruyn <debruyn.maurice@gmail.com>",
6
6
  "repository": {
@@ -68,11 +68,11 @@
68
68
  "lint": "biome check ."
69
69
  },
70
70
  "peerDependencies": {
71
- "@monque/core": "^1.2.0",
72
- "@tsed/core": "^8.24.1",
73
- "@tsed/di": "^8.24.1",
74
- "@tsed/mongoose": "^8.24.1",
75
- "mongodb": "catalog:"
71
+ "@monque/core": "^1.3.0",
72
+ "@tsed/core": "^8.25.1",
73
+ "@tsed/di": "^8.25.1",
74
+ "@tsed/mongoose": "^8.25.1",
75
+ "mongodb": "^7.1.0"
76
76
  },
77
77
  "peerDependenciesMeta": {
78
78
  "@tsed/mongoose": {
@@ -81,18 +81,18 @@
81
81
  },
82
82
  "devDependencies": {
83
83
  "@monque/core": "workspace:*",
84
- "@testcontainers/mongodb": "catalog:",
85
- "@total-typescript/ts-reset": "catalog:",
86
- "@tsed/core": "^8.24.1",
87
- "@tsed/di": "^8.24.1",
88
- "@tsed/mongoose": "^8.24.1",
89
- "@tsed/platform-http": "^8.24.1",
90
- "@tsed/testcontainers-mongo": "^8.24.1",
91
- "@types/node": "catalog:",
92
- "@vitest/coverage-v8": "catalog:",
93
- "mongodb": "catalog:",
94
- "testcontainers": "^11.11.0",
95
- "tsdown": "catalog:",
96
- "vitest": "catalog:"
84
+ "@testcontainers/mongodb": "^11.12.0",
85
+ "@total-typescript/ts-reset": "^0.6.1",
86
+ "@tsed/core": "^8.25.1",
87
+ "@tsed/di": "^8.25.1",
88
+ "@tsed/mongoose": "^8.25.1",
89
+ "@tsed/platform-http": "^8.25.1",
90
+ "@tsed/testcontainers-mongo": "^8.25.1",
91
+ "@types/node": "^22.19.11",
92
+ "@vitest/coverage-v8": "^4.0.18",
93
+ "mongodb": "^7.1.0",
94
+ "testcontainers": "^11.12.0",
95
+ "tsdown": "^0.20.3",
96
+ "vitest": "^4.0.18"
97
97
  }
98
98
  }