@amqp-contract/worker-nestjs 0.3.3 → 0.3.5

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/dist/index.cjs CHANGED
@@ -3,10 +3,10 @@ let _amqp_contract_worker = require("@amqp-contract/worker");
3
3
 
4
4
  //#region src/worker.module-definition.ts
5
5
  /**
6
- * ConfigurableModuleBuilder for AMQP worker module
7
- * This creates forRoot and forRootAsync methods automatically
6
+ * Injection token for AMQP worker module options
7
+ * Used by NestJS DI system to inject configuration into AmqpWorkerService
8
8
  */
9
- const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } = new _nestjs_common.ConfigurableModuleBuilder().setClassMethodName("forRoot").build();
9
+ const MODULE_OPTIONS_TOKEN = Symbol("AMQP_WORKER_MODULE_OPTIONS");
10
10
 
11
11
  //#endregion
12
12
  //#region \0@oxc-project+runtime@0.103.0/helpers/decorateMetadata.js
@@ -73,11 +73,45 @@ AmqpWorkerService = __decorate([
73
73
 
74
74
  //#endregion
75
75
  //#region src/worker.module.ts
76
- let AmqpWorkerModule = class AmqpWorkerModule$1 extends ConfigurableModuleClass {};
77
- AmqpWorkerModule = __decorate([(0, _nestjs_common.Module)({
78
- providers: [AmqpWorkerService],
79
- exports: [AmqpWorkerService]
80
- })], AmqpWorkerModule);
76
+ var _AmqpWorkerModule;
77
+ let AmqpWorkerModule = _AmqpWorkerModule = class AmqpWorkerModule$1 {
78
+ /**
79
+ * Register the AMQP worker module with synchronous configuration
80
+ *
81
+ * @param options - The worker configuration options with contract and handlers
82
+ * @returns A dynamic module for NestJS
83
+ */
84
+ static forRoot(options) {
85
+ return {
86
+ module: _AmqpWorkerModule,
87
+ providers: [{
88
+ provide: MODULE_OPTIONS_TOKEN,
89
+ useValue: options
90
+ }, AmqpWorkerService],
91
+ exports: [AmqpWorkerService]
92
+ };
93
+ }
94
+ /**
95
+ * Register the AMQP worker module with asynchronous configuration
96
+ *
97
+ * @param options - Async configuration options with factory function
98
+ * @returns A dynamic module for NestJS
99
+ */
100
+ static forRootAsync(options) {
101
+ const providers = [{
102
+ provide: MODULE_OPTIONS_TOKEN,
103
+ useFactory: options.useFactory,
104
+ inject: options.inject || []
105
+ }, AmqpWorkerService];
106
+ return {
107
+ module: _AmqpWorkerModule,
108
+ imports: options.imports || [],
109
+ providers,
110
+ exports: [AmqpWorkerService]
111
+ };
112
+ }
113
+ };
114
+ AmqpWorkerModule = _AmqpWorkerModule = __decorate([(0, _nestjs_common.Module)({})], AmqpWorkerModule);
81
115
 
82
116
  //#endregion
83
117
  Object.defineProperty(exports, 'AmqpWorkerModule', {
package/dist/index.d.cts CHANGED
@@ -1,5 +1,4 @@
1
- import * as _nestjs_common0 from "@nestjs/common";
2
- import { OnModuleDestroy, OnModuleInit } from "@nestjs/common";
1
+ import { DynamicModule, ModuleMetadata, OnModuleDestroy, OnModuleInit, Type } from "@nestjs/common";
3
2
  import { ContractDefinition } from "@amqp-contract/contract";
4
3
  import { AmqpConnectionManagerOptions, ConnectionUrl } from "amqp-connection-manager";
5
4
  import { WorkerInferConsumerHandler, WorkerInferConsumerHandlers, WorkerInferConsumerHandlers as WorkerInferConsumerHandlers$1, WorkerInferConsumerInput, defineHandler, defineHandlers } from "@amqp-contract/worker";
@@ -96,20 +95,100 @@ declare class AmqpWorkerService<TContract extends ContractDefinition> implements
96
95
  onModuleDestroy(): Promise<void>;
97
96
  }
98
97
  //#endregion
99
- //#region src/worker.module-definition.d.ts
98
+ //#region src/worker.module.d.ts
100
99
  /**
101
- * ConfigurableModuleBuilder for AMQP worker module
102
- * This creates forRoot and forRootAsync methods automatically
100
+ * Factory function return type for async module configuration
103
101
  */
104
- declare const ConfigurableModuleClass: _nestjs_common0.ConfigurableModuleCls<AmqpWorkerModuleOptions<ContractDefinition>, "forRoot", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
105
- //#endregion
106
- //#region src/worker.module.d.ts
102
+ type AmqpWorkerModuleOptionsFactory<TContract extends ContractDefinition> = AmqpWorkerModuleOptions<TContract> | Promise<AmqpWorkerModuleOptions<TContract>>;
103
+ /**
104
+ * Options for async module configuration using factory pattern
105
+ */
106
+ interface AmqpWorkerModuleAsyncOptions<TContract extends ContractDefinition> {
107
+ /**
108
+ * Factory function that returns the module options.
109
+ * Can use injected dependencies to create configuration.
110
+ */
111
+ useFactory: (...args: any[]) => AmqpWorkerModuleOptionsFactory<TContract>;
112
+ /**
113
+ * Optional dependencies to inject into the factory function.
114
+ * Can be a token (string/symbol) a class or a reference to a provider.
115
+ */
116
+ inject?: (string | symbol | Type<unknown>)[];
117
+ /**
118
+ * Optional list of imported modules that export providers needed by the factory
119
+ */
120
+ imports?: ModuleMetadata["imports"];
121
+ }
107
122
  /**
108
123
  * NestJS module for AMQP worker integration
109
124
  * This module provides type-safe AMQP worker functionality using @amqp-contract/worker
110
125
  * without relying on NestJS decorators (except for dependency injection)
126
+ *
127
+ * @typeParam TContract - The contract definition type for type-safe handlers
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * // Synchronous configuration
132
+ * @Module({
133
+ * imports: [
134
+ * AmqpWorkerModule.forRoot({
135
+ * contract: myContract,
136
+ * handlers: {
137
+ * processOrder: async (message) => {
138
+ * // message is fully typed based on the contract
139
+ * console.log('Order:', message.orderId);
140
+ * }
141
+ * },
142
+ * urls: ['amqp://localhost']
143
+ * })
144
+ * ]
145
+ * })
146
+ * export class AppModule {}
147
+ *
148
+ * // Asynchronous configuration
149
+ * @Module({
150
+ * imports: [
151
+ * AmqpWorkerModule.forRootAsync({
152
+ * imports: [ConfigModule],
153
+ * useFactory: (configService: ConfigService) => ({
154
+ * contract: myContract,
155
+ * handlers: {
156
+ * processOrder: async (message) => {
157
+ * console.log('Order:', message.orderId);
158
+ * }
159
+ * },
160
+ * urls: configService.get('AMQP_URLS')
161
+ * }),
162
+ * inject: [ConfigService]
163
+ * })
164
+ * ]
165
+ * })
166
+ * export class AppModule {}
167
+ * ```
168
+ */
169
+ declare class AmqpWorkerModule {
170
+ /**
171
+ * Register the AMQP worker module with synchronous configuration
172
+ *
173
+ * @param options - The worker configuration options with contract and handlers
174
+ * @returns A dynamic module for NestJS
175
+ */
176
+ static forRoot<TContract extends ContractDefinition>(options: AmqpWorkerModuleOptions<TContract>): DynamicModule;
177
+ /**
178
+ * Register the AMQP worker module with asynchronous configuration
179
+ *
180
+ * @param options - Async configuration options with factory function
181
+ * @returns A dynamic module for NestJS
182
+ */
183
+ static forRootAsync<TContract extends ContractDefinition>(options: AmqpWorkerModuleAsyncOptions<TContract>): DynamicModule;
184
+ }
185
+ //#endregion
186
+ //#region src/worker.module-definition.d.ts
187
+ /**
188
+ * Injection token for AMQP worker module options
189
+ * Used by NestJS DI system to inject configuration into AmqpWorkerService
111
190
  */
112
- declare class AmqpWorkerModule extends ConfigurableModuleClass {}
191
+ declare const MODULE_OPTIONS_TOKEN: unique symbol;
113
192
  //#endregion
114
- export { AmqpWorkerModule, type AmqpWorkerModuleOptions, AmqpWorkerService, MODULE_OPTIONS_TOKEN, type WorkerInferConsumerHandler, type WorkerInferConsumerHandlers, type WorkerInferConsumerInput, defineHandler, defineHandlers };
193
+ export { AmqpWorkerModule, type AmqpWorkerModuleAsyncOptions, type AmqpWorkerModuleOptions, AmqpWorkerService, MODULE_OPTIONS_TOKEN, type WorkerInferConsumerHandler, type WorkerInferConsumerHandlers, type WorkerInferConsumerInput, defineHandler, defineHandlers };
115
194
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/worker.service.ts","../src/worker.module-definition.ts","../src/worker.module.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AA2BA;;;;;;;;AA6CA;;;;;;;;;;UA7CiB,0CAA0C;;ECnB5C,QAAA,EDqBH,SCrBG;EAAuB;EAAA,QAAA,EDuB1B,6BCvB0B,CDuBE,SCvBF,CAAA;EAAA;EAAA,IAAA,EDyB9B,aCzB8B,EAAA;EAAE;sBD2BlB;;;AE1BtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cFgEa,oCAAoC,+BACpC,cAAc;;;uBAMG,wBAAwB;;;;;;;;;;;kBAa9B;;;;;;;;qBAWG;;;;;;;;cChGZ,yBAAuB,eAAA,CAAA,sBAAA,wBAAA;;;;;;;;cCKzB,gBAAA,SAAyB,uBAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/worker.service.ts","../src/worker.module.ts","../src/worker.module-definition.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AA2BA;;;;;;;;AA6CA;;;;;;;;;;;UA7CiB,0CAA0C;ECbtD;EAAiD,QAAA,EDe1C,SCf0C;EAC1B;EAAxB,QAAA,EDgBQ,6BChBR,CDgBoC,SChBpC,CAAA;EACgC;EAAxB,IAAA,EDiBJ,aCjBI,EAAA;EAAR;EAAO,iBAAA,CAAA,EDmBW,4BCnBX,GAAA,SAAA;AAKX;;;;;;;AAiEA;;;;;;;;;;;;;AClFA;;;;;;;;;;;;;;;cFqEa,oCAAoC,+BACpC,cAAc;;;uBAMG,wBAAwB;;;;;;;;;;;kBAa9B;;;;;;;;qBAWG;;;;;;;AA7E3B,KCbK,8BDamC,CAAA,kBCbc,kBDad,CAAA,GCZpC,uBDYoC,CCZZ,SDYY,CAAA,GCXpC,ODWoC,CCX5B,uBDW4B,CCXJ,SDWI,CAAA,CAAA;;;;AAI5B,UCVK,4BDUL,CAAA,kBCVoD,kBDUpD,CAAA,CAAA;EAEJ;;;AAuCR;EACiD,UAAA,EAAA,CAAA,GAAA,IAAA,EAAA,GAAA,EAAA,EAAA,GC9Cf,8BD8Ce,CC9CgB,SD8ChB,CAAA;EAOK;;;;EANzC,MAAA,CAAA,EAAA,CAAA,MAAA,GAAA,MAAA,GC1CiB,ID0CjB,CAAA,OAAA,CAAA,CAAA,EAAA;EAAc;;;YCtCf;;AA3B0E;;;;;;;;AAYtF;;;;;;;AAiEA;;;;;;;;;;;;;AClFA;;;;;;;;;;;;;;;;;;;cDmFa,gBAAA;;;;;;;mCAOsB,6BACtB,wBAAwB,aAChC;;;;;;;wCAoBmC,6BAC3B,6BAA6B,aACrC;;;;;;;;cClHQ"}
package/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- import * as _nestjs_common0 from "@nestjs/common";
2
- import { OnModuleDestroy, OnModuleInit } from "@nestjs/common";
1
+ import { DynamicModule, ModuleMetadata, OnModuleDestroy, OnModuleInit, Type } from "@nestjs/common";
3
2
  import { WorkerInferConsumerHandler, WorkerInferConsumerHandlers, WorkerInferConsumerHandlers as WorkerInferConsumerHandlers$1, WorkerInferConsumerInput, defineHandler, defineHandlers } from "@amqp-contract/worker";
4
3
  import { ContractDefinition } from "@amqp-contract/contract";
5
4
  import { AmqpConnectionManagerOptions, ConnectionUrl } from "amqp-connection-manager";
@@ -96,20 +95,100 @@ declare class AmqpWorkerService<TContract extends ContractDefinition> implements
96
95
  onModuleDestroy(): Promise<void>;
97
96
  }
98
97
  //#endregion
99
- //#region src/worker.module-definition.d.ts
98
+ //#region src/worker.module.d.ts
100
99
  /**
101
- * ConfigurableModuleBuilder for AMQP worker module
102
- * This creates forRoot and forRootAsync methods automatically
100
+ * Factory function return type for async module configuration
103
101
  */
104
- declare const ConfigurableModuleClass: _nestjs_common0.ConfigurableModuleCls<AmqpWorkerModuleOptions<ContractDefinition>, "forRoot", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
105
- //#endregion
106
- //#region src/worker.module.d.ts
102
+ type AmqpWorkerModuleOptionsFactory<TContract extends ContractDefinition> = AmqpWorkerModuleOptions<TContract> | Promise<AmqpWorkerModuleOptions<TContract>>;
103
+ /**
104
+ * Options for async module configuration using factory pattern
105
+ */
106
+ interface AmqpWorkerModuleAsyncOptions<TContract extends ContractDefinition> {
107
+ /**
108
+ * Factory function that returns the module options.
109
+ * Can use injected dependencies to create configuration.
110
+ */
111
+ useFactory: (...args: any[]) => AmqpWorkerModuleOptionsFactory<TContract>;
112
+ /**
113
+ * Optional dependencies to inject into the factory function.
114
+ * Can be a token (string/symbol) a class or a reference to a provider.
115
+ */
116
+ inject?: (string | symbol | Type<unknown>)[];
117
+ /**
118
+ * Optional list of imported modules that export providers needed by the factory
119
+ */
120
+ imports?: ModuleMetadata["imports"];
121
+ }
107
122
  /**
108
123
  * NestJS module for AMQP worker integration
109
124
  * This module provides type-safe AMQP worker functionality using @amqp-contract/worker
110
125
  * without relying on NestJS decorators (except for dependency injection)
126
+ *
127
+ * @typeParam TContract - The contract definition type for type-safe handlers
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * // Synchronous configuration
132
+ * @Module({
133
+ * imports: [
134
+ * AmqpWorkerModule.forRoot({
135
+ * contract: myContract,
136
+ * handlers: {
137
+ * processOrder: async (message) => {
138
+ * // message is fully typed based on the contract
139
+ * console.log('Order:', message.orderId);
140
+ * }
141
+ * },
142
+ * urls: ['amqp://localhost']
143
+ * })
144
+ * ]
145
+ * })
146
+ * export class AppModule {}
147
+ *
148
+ * // Asynchronous configuration
149
+ * @Module({
150
+ * imports: [
151
+ * AmqpWorkerModule.forRootAsync({
152
+ * imports: [ConfigModule],
153
+ * useFactory: (configService: ConfigService) => ({
154
+ * contract: myContract,
155
+ * handlers: {
156
+ * processOrder: async (message) => {
157
+ * console.log('Order:', message.orderId);
158
+ * }
159
+ * },
160
+ * urls: configService.get('AMQP_URLS')
161
+ * }),
162
+ * inject: [ConfigService]
163
+ * })
164
+ * ]
165
+ * })
166
+ * export class AppModule {}
167
+ * ```
168
+ */
169
+ declare class AmqpWorkerModule {
170
+ /**
171
+ * Register the AMQP worker module with synchronous configuration
172
+ *
173
+ * @param options - The worker configuration options with contract and handlers
174
+ * @returns A dynamic module for NestJS
175
+ */
176
+ static forRoot<TContract extends ContractDefinition>(options: AmqpWorkerModuleOptions<TContract>): DynamicModule;
177
+ /**
178
+ * Register the AMQP worker module with asynchronous configuration
179
+ *
180
+ * @param options - Async configuration options with factory function
181
+ * @returns A dynamic module for NestJS
182
+ */
183
+ static forRootAsync<TContract extends ContractDefinition>(options: AmqpWorkerModuleAsyncOptions<TContract>): DynamicModule;
184
+ }
185
+ //#endregion
186
+ //#region src/worker.module-definition.d.ts
187
+ /**
188
+ * Injection token for AMQP worker module options
189
+ * Used by NestJS DI system to inject configuration into AmqpWorkerService
111
190
  */
112
- declare class AmqpWorkerModule extends ConfigurableModuleClass {}
191
+ declare const MODULE_OPTIONS_TOKEN: unique symbol;
113
192
  //#endregion
114
- export { AmqpWorkerModule, type AmqpWorkerModuleOptions, AmqpWorkerService, MODULE_OPTIONS_TOKEN, type WorkerInferConsumerHandler, type WorkerInferConsumerHandlers, type WorkerInferConsumerInput, defineHandler, defineHandlers };
193
+ export { AmqpWorkerModule, type AmqpWorkerModuleAsyncOptions, type AmqpWorkerModuleOptions, AmqpWorkerService, MODULE_OPTIONS_TOKEN, type WorkerInferConsumerHandler, type WorkerInferConsumerHandlers, type WorkerInferConsumerInput, defineHandler, defineHandlers };
115
194
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/worker.service.ts","../src/worker.module-definition.ts","../src/worker.module.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AA2BA;;;;;;;;AA6CA;;;;;;;;;;UA7CiB,0CAA0C;;ECnB5C,QAAA,EDqBH,SCrBG;EAAuB;EAAA,QAAA,EDuB1B,6BCvB0B,CDuBE,SCvBF,CAAA;EAAA;EAAA,IAAA,EDyB9B,aCzB8B,EAAA;EAAE;sBD2BlB;;;AE1BtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cFgEa,oCAAoC,+BACpC,cAAc;;;uBAMG,wBAAwB;;;;;;;;;;;kBAa9B;;;;;;;;qBAWG;;;;;;;;cChGZ,yBAAuB,eAAA,CAAA,sBAAA,wBAAA;;;;;;;;cCKzB,gBAAA,SAAyB,uBAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/worker.service.ts","../src/worker.module.ts","../src/worker.module-definition.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AA2BA;;;;;;;;AA6CA;;;;;;;;;;;UA7CiB,0CAA0C;ECbtD;EAAiD,QAAA,EDe1C,SCf0C;EAC1B;EAAxB,QAAA,EDgBQ,6BChBR,CDgBoC,SChBpC,CAAA;EACgC;EAAxB,IAAA,EDiBJ,aCjBI,EAAA;EAAR;EAAO,iBAAA,CAAA,EDmBW,4BCnBX,GAAA,SAAA;AAKX;;;;;;;AAiEA;;;;;;;;;;;;;AClFA;;;;;;;;;;;;;;;cFqEa,oCAAoC,+BACpC,cAAc;;;uBAMG,wBAAwB;;;;;;;;;;;kBAa9B;;;;;;;;qBAWG;;;;;;;AA7E3B,KCbK,8BDamC,CAAA,kBCbc,kBDad,CAAA,GCZpC,uBDYoC,CCZZ,SDYY,CAAA,GCXpC,ODWoC,CCX5B,uBDW4B,CCXJ,SDWI,CAAA,CAAA;;;;AAI5B,UCVK,4BDUL,CAAA,kBCVoD,kBDUpD,CAAA,CAAA;EAEJ;;;AAuCR;EACiD,UAAA,EAAA,CAAA,GAAA,IAAA,EAAA,GAAA,EAAA,EAAA,GC9Cf,8BD8Ce,CC9CgB,SD8ChB,CAAA;EAOK;;;;EANzC,MAAA,CAAA,EAAA,CAAA,MAAA,GAAA,MAAA,GC1CiB,ID0CjB,CAAA,OAAA,CAAA,CAAA,EAAA;EAAc;;;YCtCf;;AA3B0E;;;;;;;;AAYtF;;;;;;;AAiEA;;;;;;;;;;;;;AClFA;;;;;;;;;;;;;;;;;;;cDmFa,gBAAA;;;;;;;mCAOsB,6BACtB,wBAAwB,aAChC;;;;;;;wCAoBmC,6BAC3B,6BAA6B,aACrC;;;;;;;;cClHQ"}
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { ConfigurableModuleBuilder, Inject, Injectable, Module } from "@nestjs/common";
1
+ import { Inject, Injectable, Module } from "@nestjs/common";
2
2
  import { TypedAmqpWorker, defineHandler, defineHandlers } from "@amqp-contract/worker";
3
3
 
4
4
  //#region src/worker.module-definition.ts
5
5
  /**
6
- * ConfigurableModuleBuilder for AMQP worker module
7
- * This creates forRoot and forRootAsync methods automatically
6
+ * Injection token for AMQP worker module options
7
+ * Used by NestJS DI system to inject configuration into AmqpWorkerService
8
8
  */
9
- const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } = new ConfigurableModuleBuilder().setClassMethodName("forRoot").build();
9
+ const MODULE_OPTIONS_TOKEN = Symbol("AMQP_WORKER_MODULE_OPTIONS");
10
10
 
11
11
  //#endregion
12
12
  //#region \0@oxc-project+runtime@0.103.0/helpers/decorateMetadata.js
@@ -73,11 +73,45 @@ AmqpWorkerService = __decorate([
73
73
 
74
74
  //#endregion
75
75
  //#region src/worker.module.ts
76
- let AmqpWorkerModule = class AmqpWorkerModule$1 extends ConfigurableModuleClass {};
77
- AmqpWorkerModule = __decorate([Module({
78
- providers: [AmqpWorkerService],
79
- exports: [AmqpWorkerService]
80
- })], AmqpWorkerModule);
76
+ var _AmqpWorkerModule;
77
+ let AmqpWorkerModule = _AmqpWorkerModule = class AmqpWorkerModule$1 {
78
+ /**
79
+ * Register the AMQP worker module with synchronous configuration
80
+ *
81
+ * @param options - The worker configuration options with contract and handlers
82
+ * @returns A dynamic module for NestJS
83
+ */
84
+ static forRoot(options) {
85
+ return {
86
+ module: _AmqpWorkerModule,
87
+ providers: [{
88
+ provide: MODULE_OPTIONS_TOKEN,
89
+ useValue: options
90
+ }, AmqpWorkerService],
91
+ exports: [AmqpWorkerService]
92
+ };
93
+ }
94
+ /**
95
+ * Register the AMQP worker module with asynchronous configuration
96
+ *
97
+ * @param options - Async configuration options with factory function
98
+ * @returns A dynamic module for NestJS
99
+ */
100
+ static forRootAsync(options) {
101
+ const providers = [{
102
+ provide: MODULE_OPTIONS_TOKEN,
103
+ useFactory: options.useFactory,
104
+ inject: options.inject || []
105
+ }, AmqpWorkerService];
106
+ return {
107
+ module: _AmqpWorkerModule,
108
+ imports: options.imports || [],
109
+ providers,
110
+ exports: [AmqpWorkerService]
111
+ };
112
+ }
113
+ };
114
+ AmqpWorkerModule = _AmqpWorkerModule = __decorate([Module({})], AmqpWorkerModule);
81
115
 
82
116
  //#endregion
83
117
  export { AmqpWorkerModule, AmqpWorkerService, MODULE_OPTIONS_TOKEN, defineHandler, defineHandlers };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["AmqpWorkerService","options: AmqpWorkerModuleOptions<TContract>","AmqpWorkerModule"],"sources":["../src/worker.module-definition.ts","../src/worker.service.ts","../src/worker.module.ts"],"sourcesContent":["import { ConfigurableModuleBuilder } from \"@nestjs/common\";\nimport type { ContractDefinition } from \"@amqp-contract/contract\";\nimport type { AmqpWorkerModuleOptions } from \"./worker.service.js\";\n\n/**\n * ConfigurableModuleBuilder for AMQP worker module\n * This creates forRoot and forRootAsync methods automatically\n */\nexport const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } = new ConfigurableModuleBuilder<\n AmqpWorkerModuleOptions<ContractDefinition>\n>()\n .setClassMethodName(\"forRoot\")\n .build();\n","import { Inject, Injectable, type OnModuleDestroy, type OnModuleInit } from \"@nestjs/common\";\nimport type { ContractDefinition } from \"@amqp-contract/contract\";\nimport type { AmqpConnectionManagerOptions, ConnectionUrl } from \"amqp-connection-manager\";\nimport { TypedAmqpWorker, type WorkerInferConsumerHandlers } from \"@amqp-contract/worker\";\nimport { MODULE_OPTIONS_TOKEN } from \"./worker.module-definition.js\";\n\n/**\n * Configuration options for the AMQP worker NestJS module.\n *\n * @typeParam TContract - The contract definition type\n *\n * @example\n * ```typescript\n * const options: AmqpWorkerModuleOptions<typeof contract> = {\n * contract: myContract,\n * handlers: {\n * processOrder: async (message) => {\n * console.log('Processing order:', message.orderId);\n * }\n * },\n * urls: ['amqp://localhost'],\n * connectionOptions: {\n * heartbeatIntervalInSeconds: 30\n * }\n * };\n * ```\n */\nexport interface AmqpWorkerModuleOptions<TContract extends ContractDefinition> {\n /** The AMQP contract definition specifying consumers and their message schemas */\n contract: TContract;\n /** Message handlers for each consumer defined in the contract */\n handlers: WorkerInferConsumerHandlers<TContract>;\n /** AMQP broker URL(s). Multiple URLs provide failover support */\n urls: ConnectionUrl[];\n /** Optional connection configuration (heartbeat, reconnect settings, etc.) */\n connectionOptions?: AmqpConnectionManagerOptions | undefined;\n}\n\n/**\n * Type-safe AMQP worker service for NestJS applications.\n *\n * This service wraps {@link TypedAmqpWorker} and integrates it with the NestJS\n * lifecycle, automatically starting message consumption on module init and\n * cleaning up resources on module destroy.\n *\n * @typeParam TContract - The contract definition type\n *\n * @example\n * ```typescript\n * // In your module\n * import { AmqpWorkerModule } from '@amqp-contract/worker-nestjs';\n *\n * @Module({\n * imports: [\n * AmqpWorkerModule.forRoot({\n * contract: myContract,\n * handlers: {\n * processOrder: async (message) => {\n * console.log('Received order:', message.orderId);\n * // Process the order...\n * }\n * },\n * urls: ['amqp://localhost']\n * })\n * ]\n * })\n * export class AppModule {}\n *\n * // The worker automatically starts consuming messages when the module initializes\n * // and stops gracefully when the application shuts down\n * ```\n */\n@Injectable()\nexport class AmqpWorkerService<TContract extends ContractDefinition>\n implements OnModuleInit, OnModuleDestroy\n{\n private worker: TypedAmqpWorker<TContract> | null = null;\n\n constructor(\n @Inject(MODULE_OPTIONS_TOKEN)\n private readonly options: AmqpWorkerModuleOptions<TContract>,\n ) {}\n\n /**\n * Initialize the AMQP worker when the NestJS module starts.\n *\n * This lifecycle hook automatically creates and starts the worker,\n * beginning message consumption from all configured consumers.\n * The connection will be established in the background with\n * automatic reconnection handling.\n *\n * @throws Error if the worker fails to start\n */\n async onModuleInit(): Promise<void> {\n this.worker = await TypedAmqpWorker.create(this.options).resultToPromise();\n }\n\n /**\n * Close the AMQP worker when the NestJS module is destroyed.\n *\n * This lifecycle hook ensures proper cleanup of resources when the\n * NestJS application shuts down, gracefully stopping message consumption\n * and closing the connection.\n */\n async onModuleDestroy(): Promise<void> {\n if (this.worker) {\n await this.worker.close().resultToPromise();\n this.worker = null;\n }\n }\n}\n","import { Module } from \"@nestjs/common\";\nimport { ConfigurableModuleClass } from \"./worker.module-definition.js\";\nimport { AmqpWorkerService } from \"./worker.service.js\";\n\n/**\n * NestJS module for AMQP worker integration\n * This module provides type-safe AMQP worker functionality using @amqp-contract/worker\n * without relying on NestJS decorators (except for dependency injection)\n */\n@Module({\n providers: [AmqpWorkerService],\n exports: [AmqpWorkerService],\n})\nexport class AmqpWorkerModule extends ConfigurableModuleClass {}\n"],"mappings":";;;;;;;;AAQA,MAAa,EAAE,yBAAyB,yBAAyB,IAAI,2BAElE,CACA,mBAAmB,UAAU,CAC7B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6DH,8BAAMA,oBAEb;CACE,AAAQ,SAA4C;CAEpD,YACE,AACiBC,SACjB;EADiB;;;;;;;;;;;;CAanB,MAAM,eAA8B;AAClC,OAAK,SAAS,MAAM,gBAAgB,OAAO,KAAK,QAAQ,CAAC,iBAAiB;;;;;;;;;CAU5E,MAAM,kBAAiC;AACrC,MAAI,KAAK,QAAQ;AACf,SAAM,KAAK,OAAO,OAAO,CAAC,iBAAiB;AAC3C,QAAK,SAAS;;;;;CAnCnB,YAAY;oBAOR,OAAO,qBAAqB;;;;;;AClE1B,6BAAMC,2BAAyB,wBAAwB;+BAJ7D,OAAO;CACN,WAAW,CAAC,kBAAkB;CAC9B,SAAS,CAAC,kBAAkB;CAC7B,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":["AmqpWorkerService","options: AmqpWorkerModuleOptions<TContract>","AmqpWorkerModule","providers: Provider[]"],"sources":["../src/worker.module-definition.ts","../src/worker.service.ts","../src/worker.module.ts"],"sourcesContent":["/**\n * Injection token for AMQP worker module options\n * Used by NestJS DI system to inject configuration into AmqpWorkerService\n */\nexport const MODULE_OPTIONS_TOKEN = Symbol(\"AMQP_WORKER_MODULE_OPTIONS\");\n","import { Inject, Injectable, type OnModuleDestroy, type OnModuleInit } from \"@nestjs/common\";\nimport type { ContractDefinition } from \"@amqp-contract/contract\";\nimport type { AmqpConnectionManagerOptions, ConnectionUrl } from \"amqp-connection-manager\";\nimport { TypedAmqpWorker, type WorkerInferConsumerHandlers } from \"@amqp-contract/worker\";\nimport { MODULE_OPTIONS_TOKEN } from \"./worker.module-definition.js\";\n\n/**\n * Configuration options for the AMQP worker NestJS module.\n *\n * @typeParam TContract - The contract definition type\n *\n * @example\n * ```typescript\n * const options: AmqpWorkerModuleOptions<typeof contract> = {\n * contract: myContract,\n * handlers: {\n * processOrder: async (message) => {\n * console.log('Processing order:', message.orderId);\n * }\n * },\n * urls: ['amqp://localhost'],\n * connectionOptions: {\n * heartbeatIntervalInSeconds: 30\n * }\n * };\n * ```\n */\nexport interface AmqpWorkerModuleOptions<TContract extends ContractDefinition> {\n /** The AMQP contract definition specifying consumers and their message schemas */\n contract: TContract;\n /** Message handlers for each consumer defined in the contract */\n handlers: WorkerInferConsumerHandlers<TContract>;\n /** AMQP broker URL(s). Multiple URLs provide failover support */\n urls: ConnectionUrl[];\n /** Optional connection configuration (heartbeat, reconnect settings, etc.) */\n connectionOptions?: AmqpConnectionManagerOptions | undefined;\n}\n\n/**\n * Type-safe AMQP worker service for NestJS applications.\n *\n * This service wraps {@link TypedAmqpWorker} and integrates it with the NestJS\n * lifecycle, automatically starting message consumption on module init and\n * cleaning up resources on module destroy.\n *\n * @typeParam TContract - The contract definition type\n *\n * @example\n * ```typescript\n * // In your module\n * import { AmqpWorkerModule } from '@amqp-contract/worker-nestjs';\n *\n * @Module({\n * imports: [\n * AmqpWorkerModule.forRoot({\n * contract: myContract,\n * handlers: {\n * processOrder: async (message) => {\n * console.log('Received order:', message.orderId);\n * // Process the order...\n * }\n * },\n * urls: ['amqp://localhost']\n * })\n * ]\n * })\n * export class AppModule {}\n *\n * // The worker automatically starts consuming messages when the module initializes\n * // and stops gracefully when the application shuts down\n * ```\n */\n@Injectable()\nexport class AmqpWorkerService<TContract extends ContractDefinition>\n implements OnModuleInit, OnModuleDestroy\n{\n private worker: TypedAmqpWorker<TContract> | null = null;\n\n constructor(\n @Inject(MODULE_OPTIONS_TOKEN)\n private readonly options: AmqpWorkerModuleOptions<TContract>,\n ) {}\n\n /**\n * Initialize the AMQP worker when the NestJS module starts.\n *\n * This lifecycle hook automatically creates and starts the worker,\n * beginning message consumption from all configured consumers.\n * The connection will be established in the background with\n * automatic reconnection handling.\n *\n * @throws Error if the worker fails to start\n */\n async onModuleInit(): Promise<void> {\n this.worker = await TypedAmqpWorker.create(this.options).resultToPromise();\n }\n\n /**\n * Close the AMQP worker when the NestJS module is destroyed.\n *\n * This lifecycle hook ensures proper cleanup of resources when the\n * NestJS application shuts down, gracefully stopping message consumption\n * and closing the connection.\n */\n async onModuleDestroy(): Promise<void> {\n if (this.worker) {\n await this.worker.close().resultToPromise();\n this.worker = null;\n }\n }\n}\n","import {\n Module,\n type DynamicModule,\n type Provider,\n type Type,\n type ModuleMetadata,\n} from \"@nestjs/common\";\nimport type { ContractDefinition } from \"@amqp-contract/contract\";\nimport { MODULE_OPTIONS_TOKEN } from \"./worker.module-definition.js\";\nimport { AmqpWorkerService, type AmqpWorkerModuleOptions } from \"./worker.service.js\";\n\n/**\n * Factory function return type for async module configuration\n */\ntype AmqpWorkerModuleOptionsFactory<TContract extends ContractDefinition> =\n | AmqpWorkerModuleOptions<TContract>\n | Promise<AmqpWorkerModuleOptions<TContract>>;\n\n/**\n * Options for async module configuration using factory pattern\n */\nexport interface AmqpWorkerModuleAsyncOptions<TContract extends ContractDefinition> {\n /**\n * Factory function that returns the module options.\n * Can use injected dependencies to create configuration.\n */\n // oxlint-disable-next-line no-explicit-any\n useFactory: (...args: any[]) => AmqpWorkerModuleOptionsFactory<TContract>;\n /**\n * Optional dependencies to inject into the factory function.\n * Can be a token (string/symbol) a class or a reference to a provider.\n */\n inject?: (string | symbol | Type<unknown>)[];\n /**\n * Optional list of imported modules that export providers needed by the factory\n */\n imports?: ModuleMetadata[\"imports\"];\n}\n\n/**\n * NestJS module for AMQP worker integration\n * This module provides type-safe AMQP worker functionality using @amqp-contract/worker\n * without relying on NestJS decorators (except for dependency injection)\n *\n * @typeParam TContract - The contract definition type for type-safe handlers\n *\n * @example\n * ```typescript\n * // Synchronous configuration\n * @Module({\n * imports: [\n * AmqpWorkerModule.forRoot({\n * contract: myContract,\n * handlers: {\n * processOrder: async (message) => {\n * // message is fully typed based on the contract\n * console.log('Order:', message.orderId);\n * }\n * },\n * urls: ['amqp://localhost']\n * })\n * ]\n * })\n * export class AppModule {}\n *\n * // Asynchronous configuration\n * @Module({\n * imports: [\n * AmqpWorkerModule.forRootAsync({\n * imports: [ConfigModule],\n * useFactory: (configService: ConfigService) => ({\n * contract: myContract,\n * handlers: {\n * processOrder: async (message) => {\n * console.log('Order:', message.orderId);\n * }\n * },\n * urls: configService.get('AMQP_URLS')\n * }),\n * inject: [ConfigService]\n * })\n * ]\n * })\n * export class AppModule {}\n * ```\n */\n@Module({})\nexport class AmqpWorkerModule {\n /**\n * Register the AMQP worker module with synchronous configuration\n *\n * @param options - The worker configuration options with contract and handlers\n * @returns A dynamic module for NestJS\n */\n static forRoot<TContract extends ContractDefinition>(\n options: AmqpWorkerModuleOptions<TContract>,\n ): DynamicModule {\n return {\n module: AmqpWorkerModule,\n providers: [\n {\n provide: MODULE_OPTIONS_TOKEN,\n useValue: options,\n },\n AmqpWorkerService,\n ],\n exports: [AmqpWorkerService],\n };\n }\n\n /**\n * Register the AMQP worker module with asynchronous configuration\n *\n * @param options - Async configuration options with factory function\n * @returns A dynamic module for NestJS\n */\n static forRootAsync<TContract extends ContractDefinition>(\n options: AmqpWorkerModuleAsyncOptions<TContract>,\n ): DynamicModule {\n const providers: Provider[] = [\n {\n provide: MODULE_OPTIONS_TOKEN,\n useFactory: options.useFactory,\n inject: options.inject || [],\n },\n AmqpWorkerService,\n ];\n\n return {\n module: AmqpWorkerModule,\n imports: options.imports || [],\n providers,\n exports: [AmqpWorkerService],\n };\n }\n}\n"],"mappings":";;;;;;;;AAIA,MAAa,uBAAuB,OAAO,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;ACqEjE,8BAAMA,oBAEb;CACE,AAAQ,SAA4C;CAEpD,YACE,AACiBC,SACjB;EADiB;;;;;;;;;;;;CAanB,MAAM,eAA8B;AAClC,OAAK,SAAS,MAAM,gBAAgB,OAAO,KAAK,QAAQ,CAAC,iBAAiB;;;;;;;;;CAU5E,MAAM,kBAAiC;AACrC,MAAI,KAAK,QAAQ;AACf,SAAM,KAAK,OAAO,OAAO,CAAC,iBAAiB;AAC3C,QAAK,SAAS;;;;;CAnCnB,YAAY;oBAOR,OAAO,qBAAqB;;;;;;;ACQ1B,iDAAMC,mBAAiB;;;;;;;CAO5B,OAAO,QACL,SACe;AACf,SAAO;GACL;GACA,WAAW,CACT;IACE,SAAS;IACT,UAAU;IACX,EACD,kBACD;GACD,SAAS,CAAC,kBAAkB;GAC7B;;;;;;;;CASH,OAAO,aACL,SACe;EACf,MAAMC,YAAwB,CAC5B;GACE,SAAS;GACT,YAAY,QAAQ;GACpB,QAAQ,QAAQ,UAAU,EAAE;GAC7B,EACD,kBACD;AAED,SAAO;GACL;GACA,SAAS,QAAQ,WAAW,EAAE;GAC9B;GACA,SAAS,CAAC,kBAAkB;GAC7B;;;mDA/CJ,OAAO,EAAE,CAAC"}
package/docs/index.md CHANGED
@@ -8,20 +8,55 @@
8
8
 
9
9
  ### AmqpWorkerModule
10
10
 
11
- Defined in: [packages/worker-nestjs/src/worker.module.ts:14](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/worker-nestjs/src/worker.module.ts#L14)
11
+ Defined in: [worker-nestjs/src/worker.module.ts:88](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.module.ts#L88)
12
12
 
13
13
  NestJS module for AMQP worker integration
14
14
  This module provides type-safe AMQP worker functionality using @amqp-contract/worker
15
15
  without relying on NestJS decorators (except for dependency injection)
16
16
 
17
- #### Extends
17
+ #### Type Param
18
18
 
19
- - `ConfigurableModuleClass`
19
+ The contract definition type for type-safe handlers
20
20
 
21
- #### Indexable
21
+ #### Example
22
22
 
23
- ```ts
24
- [key: string]: any
23
+ ```typescript
24
+ // Synchronous configuration
25
+ @Module({
26
+ imports: [
27
+ AmqpWorkerModule.forRoot({
28
+ contract: myContract,
29
+ handlers: {
30
+ processOrder: async (message) => {
31
+ // message is fully typed based on the contract
32
+ console.log('Order:', message.orderId);
33
+ }
34
+ },
35
+ urls: ['amqp://localhost']
36
+ })
37
+ ]
38
+ })
39
+ export class AppModule {}
40
+
41
+ // Asynchronous configuration
42
+ @Module({
43
+ imports: [
44
+ AmqpWorkerModule.forRootAsync({
45
+ imports: [ConfigModule],
46
+ useFactory: (configService: ConfigService) => ({
47
+ contract: myContract,
48
+ handlers: {
49
+ processOrder: async (message) => {
50
+ console.log('Order:', message.orderId);
51
+ }
52
+ },
53
+ urls: configService.get('AMQP_URLS')
54
+ }),
55
+ inject: [ConfigService]
56
+ })
57
+ ]
58
+ })
59
+ export class AppModule {}
25
60
  ```
26
61
 
27
62
  #### Constructors
@@ -32,30 +67,73 @@ without relying on NestJS decorators (except for dependency injection)
32
67
  new AmqpWorkerModule(): AmqpWorkerModule;
33
68
  ```
34
69
 
35
- Defined in: node\_modules/.pnpm/@nestjs+common@11.1.10\_reflect-metadata@0.2.2\_rxjs@7.8.2/node\_modules/@nestjs/common/module-utils/interfaces/configurable-module-cls.interface.d.ts:12
36
-
37
70
  ###### Returns
38
71
 
39
72
  [`AmqpWorkerModule`](#amqpworkermodule)
40
73
 
41
- ###### Inherited from
74
+ #### Methods
75
+
76
+ ##### forRoot()
42
77
 
43
78
  ```ts
44
- ConfigurableModuleClass.constructor
79
+ static forRoot<TContract>(options): DynamicModule;
45
80
  ```
46
81
 
47
- #### Properties
82
+ Defined in: [worker-nestjs/src/worker.module.ts:95](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.module.ts#L95)
83
+
84
+ Register the AMQP worker module with synchronous configuration
85
+
86
+ ###### Type Parameters
87
+
88
+ | Type Parameter |
89
+ | ------ |
90
+ | `TContract` *extends* `ContractDefinition` |
91
+
92
+ ###### Parameters
93
+
94
+ | Parameter | Type | Description |
95
+ | ------ | ------ | ------ |
96
+ | `options` | [`AmqpWorkerModuleOptions`](#amqpworkermoduleoptions)\<`TContract`\> | The worker configuration options with contract and handlers |
97
+
98
+ ###### Returns
99
+
100
+ `DynamicModule`
101
+
102
+ A dynamic module for NestJS
103
+
104
+ ##### forRootAsync()
105
+
106
+ ```ts
107
+ static forRootAsync<TContract>(options): DynamicModule;
108
+ ```
109
+
110
+ Defined in: [worker-nestjs/src/worker.module.ts:117](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.module.ts#L117)
111
+
112
+ Register the AMQP worker module with asynchronous configuration
113
+
114
+ ###### Type Parameters
48
115
 
49
- | Property | Modifier | Type | Inherited from | Defined in |
50
- | ------ | ------ | ------ | ------ | ------ |
51
- | <a id="forroot"></a> `forRoot` | `static` | (`options`) => `DynamicModule` | `ConfigurableModuleClass.forRoot` | |
52
- | <a id="forrootasync"></a> `forRootAsync` | `static` | (`options`) => `DynamicModule` | `ConfigurableModuleClass.forRootAsync` | |
116
+ | Type Parameter |
117
+ | ------ |
118
+ | `TContract` *extends* `ContractDefinition` |
119
+
120
+ ###### Parameters
121
+
122
+ | Parameter | Type | Description |
123
+ | ------ | ------ | ------ |
124
+ | `options` | [`AmqpWorkerModuleAsyncOptions`](#amqpworkermoduleasyncoptions)\<`TContract`\> | Async configuration options with factory function |
125
+
126
+ ###### Returns
127
+
128
+ `DynamicModule`
129
+
130
+ A dynamic module for NestJS
53
131
 
54
132
  ***
55
133
 
56
134
  ### AmqpWorkerService
57
135
 
58
- Defined in: [packages/worker-nestjs/src/worker.service.ts:74](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/worker-nestjs/src/worker.service.ts#L74)
136
+ Defined in: [worker-nestjs/src/worker.service.ts:74](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.service.ts#L74)
59
137
 
60
138
  Type-safe AMQP worker service for NestJS applications.
61
139
 
@@ -108,7 +186,7 @@ export class AppModule {}
108
186
  new AmqpWorkerService<TContract>(options): AmqpWorkerService<TContract>;
109
187
  ```
110
188
 
111
- Defined in: [packages/worker-nestjs/src/worker.service.ts:79](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/worker-nestjs/src/worker.service.ts#L79)
189
+ Defined in: [worker-nestjs/src/worker.service.ts:79](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.service.ts#L79)
112
190
 
113
191
  ###### Parameters
114
192
 
@@ -128,7 +206,7 @@ Defined in: [packages/worker-nestjs/src/worker.service.ts:79](https://github.com
128
206
  onModuleDestroy(): Promise<void>;
129
207
  ```
130
208
 
131
- Defined in: [packages/worker-nestjs/src/worker.service.ts:105](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/worker-nestjs/src/worker.service.ts#L105)
209
+ Defined in: [worker-nestjs/src/worker.service.ts:105](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.service.ts#L105)
132
210
 
133
211
  Close the AMQP worker when the NestJS module is destroyed.
134
212
 
@@ -152,7 +230,7 @@ OnModuleDestroy.onModuleDestroy
152
230
  onModuleInit(): Promise<void>;
153
231
  ```
154
232
 
155
- Defined in: [packages/worker-nestjs/src/worker.service.ts:94](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/worker-nestjs/src/worker.service.ts#L94)
233
+ Defined in: [worker-nestjs/src/worker.service.ts:94](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.service.ts#L94)
156
234
 
157
235
  Initialize the AMQP worker when the NestJS module starts.
158
236
 
@@ -177,9 +255,31 @@ OnModuleInit.onModuleInit
177
255
 
178
256
  ## Interfaces
179
257
 
258
+ ### AmqpWorkerModuleAsyncOptions
259
+
260
+ Defined in: [worker-nestjs/src/worker.module.ts:22](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.module.ts#L22)
261
+
262
+ Options for async module configuration using factory pattern
263
+
264
+ #### Type Parameters
265
+
266
+ | Type Parameter |
267
+ | ------ |
268
+ | `TContract` *extends* `ContractDefinition` |
269
+
270
+ #### Properties
271
+
272
+ | Property | Type | Description | Defined in |
273
+ | ------ | ------ | ------ | ------ |
274
+ | <a id="imports"></a> `imports?` | ( \| `DynamicModule` \| `Type`\<`any`\> \| `Promise`\<`DynamicModule`\> \| `ForwardReference`\<`any`\>)[] | Optional list of imported modules that export providers needed by the factory | [worker-nestjs/src/worker.module.ts:37](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.module.ts#L37) |
275
+ | <a id="inject"></a> `inject?` | (`string` \| `symbol` \| `Type`\<`unknown`\>)[] | Optional dependencies to inject into the factory function. Can be a token (string/symbol) a class or a reference to a provider. | [worker-nestjs/src/worker.module.ts:33](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.module.ts#L33) |
276
+ | <a id="usefactory"></a> `useFactory` | (...`args`) => `AmqpWorkerModuleOptionsFactory`\<`TContract`\> | Factory function that returns the module options. Can use injected dependencies to create configuration. | [worker-nestjs/src/worker.module.ts:28](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.module.ts#L28) |
277
+
278
+ ***
279
+
180
280
  ### AmqpWorkerModuleOptions
181
281
 
182
- Defined in: [packages/worker-nestjs/src/worker.service.ts:28](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/worker-nestjs/src/worker.service.ts#L28)
282
+ Defined in: [worker-nestjs/src/worker.service.ts:28](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.service.ts#L28)
183
283
 
184
284
  Configuration options for the AMQP worker NestJS module.
185
285
 
@@ -210,10 +310,10 @@ const options: AmqpWorkerModuleOptions<typeof contract> = {
210
310
 
211
311
  | Property | Type | Description | Defined in |
212
312
  | ------ | ------ | ------ | ------ |
213
- | <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.) | [packages/worker-nestjs/src/worker.service.ts:36](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/worker-nestjs/src/worker.service.ts#L36) |
214
- | <a id="contract"></a> `contract` | `TContract` | The AMQP contract definition specifying consumers and their message schemas | [packages/worker-nestjs/src/worker.service.ts:30](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/worker-nestjs/src/worker.service.ts#L30) |
215
- | <a id="handlers"></a> `handlers` | [`WorkerInferConsumerHandlers`](#workerinferconsumerhandlers)\<`TContract`\> | Message handlers for each consumer defined in the contract | [packages/worker-nestjs/src/worker.service.ts:32](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/worker-nestjs/src/worker.service.ts#L32) |
216
- | <a id="urls"></a> `urls` | `ConnectionUrl`[] | AMQP broker URL(s). Multiple URLs provide failover support | [packages/worker-nestjs/src/worker.service.ts:34](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/worker-nestjs/src/worker.service.ts#L34) |
313
+ | <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.) | [worker-nestjs/src/worker.service.ts:36](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.service.ts#L36) |
314
+ | <a id="contract"></a> `contract` | `TContract` | The AMQP contract definition specifying consumers and their message schemas | [worker-nestjs/src/worker.service.ts:30](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.service.ts#L30) |
315
+ | <a id="handlers"></a> `handlers` | [`WorkerInferConsumerHandlers`](#workerinferconsumerhandlers)\<`TContract`\> | Message handlers for each consumer defined in the contract | [worker-nestjs/src/worker.service.ts:32](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.service.ts#L32) |
316
+ | <a id="urls"></a> `urls` | `ConnectionUrl`[] | AMQP broker URL(s). Multiple URLs provide failover support | [worker-nestjs/src/worker.service.ts:34](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.service.ts#L34) |
217
317
 
218
318
  ## Type Aliases
219
319
 
@@ -223,7 +323,7 @@ const options: AmqpWorkerModuleOptions<typeof contract> = {
223
323
  type WorkerInferConsumerHandler<TContract, TName> = (message) => Promise<void>;
224
324
  ```
225
325
 
226
- Defined in: packages/worker/dist/index.d.mts:55
326
+ Defined in: worker/dist/index.d.mts:55
227
327
 
228
328
  Infer consumer handler type for a specific consumer
229
329
 
@@ -252,7 +352,7 @@ Infer consumer handler type for a specific consumer
252
352
  type WorkerInferConsumerHandlers<TContract> = { [K in InferConsumerNames<TContract>]: WorkerInferConsumerHandler<TContract, K> };
253
353
  ```
254
354
 
255
- Defined in: packages/worker/dist/index.d.mts:59
355
+ Defined in: worker/dist/index.d.mts:59
256
356
 
257
357
  Infer all consumer handlers for a contract
258
358
 
@@ -270,7 +370,7 @@ Infer all consumer handlers for a contract
270
370
  type WorkerInferConsumerInput<TContract, TName> = ConsumerInferInput<InferConsumer<TContract, TName>>;
271
371
  ```
272
372
 
273
- Defined in: packages/worker/dist/index.d.mts:51
373
+ Defined in: worker/dist/index.d.mts:51
274
374
 
275
375
  Worker perspective types - for consuming messages
276
376
 
@@ -286,10 +386,13 @@ Worker perspective types - for consuming messages
286
386
  ### MODULE\_OPTIONS\_TOKEN
287
387
 
288
388
  ```ts
289
- MODULE_OPTIONS_TOKEN: string | symbol;
389
+ const MODULE_OPTIONS_TOKEN: typeof MODULE_OPTIONS_TOKEN;
290
390
  ```
291
391
 
292
- Defined in: [packages/worker-nestjs/src/worker.module-definition.ts:9](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/worker-nestjs/src/worker.module-definition.ts#L9)
392
+ Defined in: [worker-nestjs/src/worker.module-definition.ts:5](https://github.com/btravers/amqp-contract/blob/d4ba5adf1e580179e8e0a4a6505d50b03f1a9b29/packages/worker-nestjs/src/worker.module-definition.ts#L5)
393
+
394
+ Injection token for AMQP worker module options
395
+ Used by NestJS DI system to inject configuration into AmqpWorkerService
293
396
 
294
397
  ## Functions
295
398
 
@@ -302,7 +405,7 @@ function defineHandler<TContract, TName>(
302
405
  handler): WorkerInferConsumerHandler<TContract, TName>;
303
406
  ```
304
407
 
305
- Defined in: packages/worker/dist/index.d.mts:273
408
+ Defined in: worker/dist/index.d.mts:273
306
409
 
307
410
  Define a type-safe handler for a specific consumer in a contract.
308
411
 
@@ -394,7 +497,7 @@ const worker = await TypedAmqpWorker.create({
394
497
  function defineHandlers<TContract>(contract, handlers): WorkerInferConsumerHandlers<TContract>;
395
498
  ```
396
499
 
397
- Defined in: packages/worker/dist/index.d.mts:330
500
+ Defined in: worker/dist/index.d.mts:330
398
501
 
399
502
  Define multiple type-safe handlers for consumers in a contract.
400
503
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amqp-contract/worker-nestjs",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "NestJS integration for @amqp-contract/worker",
5
5
  "keywords": [
6
6
  "amqp",
@@ -43,8 +43,8 @@
43
43
  "docs"
44
44
  ],
45
45
  "dependencies": {
46
- "@amqp-contract/contract": "0.3.3",
47
- "@amqp-contract/worker": "0.3.3"
46
+ "@amqp-contract/contract": "0.3.5",
47
+ "@amqp-contract/worker": "0.3.5"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@nestjs/common": "11.1.10",