@amqp-contract/worker-nestjs 0.11.0 → 0.12.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/docs/index.md +37 -37
- package/package.json +4 -4
package/docs/index.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
### AmqpWorkerModule
|
|
10
10
|
|
|
11
|
-
Defined in: [worker-nestjs/src/worker.module.ts:88](https://github.com/btravers/amqp-contract/blob/
|
|
11
|
+
Defined in: [worker-nestjs/src/worker.module.ts:88](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/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
|
|
@@ -79,7 +79,7 @@ new AmqpWorkerModule(): AmqpWorkerModule;
|
|
|
79
79
|
static forRoot<TContract>(options): DynamicModule;
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
Defined in: [worker-nestjs/src/worker.module.ts:95](https://github.com/btravers/amqp-contract/blob/
|
|
82
|
+
Defined in: [worker-nestjs/src/worker.module.ts:95](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.module.ts#L95)
|
|
83
83
|
|
|
84
84
|
Register the AMQP worker module with synchronous configuration
|
|
85
85
|
|
|
@@ -93,7 +93,7 @@ Register the AMQP worker module with synchronous configuration
|
|
|
93
93
|
|
|
94
94
|
| Parameter | Type | Description |
|
|
95
95
|
| ------ | ------ | ------ |
|
|
96
|
-
| `options` | [`AmqpWorkerModuleOptions`](#amqpworkermoduleoptions)
|
|
96
|
+
| `options` | [`AmqpWorkerModuleOptions`](#amqpworkermoduleoptions)<`TContract`> | The worker configuration options with contract and handlers |
|
|
97
97
|
|
|
98
98
|
###### Returns
|
|
99
99
|
|
|
@@ -107,7 +107,7 @@ A dynamic module for NestJS
|
|
|
107
107
|
static forRootAsync<TContract>(options): DynamicModule;
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
Defined in: [worker-nestjs/src/worker.module.ts:117](https://github.com/btravers/amqp-contract/blob/
|
|
110
|
+
Defined in: [worker-nestjs/src/worker.module.ts:117](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.module.ts#L117)
|
|
111
111
|
|
|
112
112
|
Register the AMQP worker module with asynchronous configuration
|
|
113
113
|
|
|
@@ -121,7 +121,7 @@ Register the AMQP worker module with asynchronous configuration
|
|
|
121
121
|
|
|
122
122
|
| Parameter | Type | Description |
|
|
123
123
|
| ------ | ------ | ------ |
|
|
124
|
-
| `options` | [`AmqpWorkerModuleAsyncOptions`](#amqpworkermoduleasyncoptions)
|
|
124
|
+
| `options` | [`AmqpWorkerModuleAsyncOptions`](#amqpworkermoduleasyncoptions)<`TContract`> | Async configuration options with factory function |
|
|
125
125
|
|
|
126
126
|
###### Returns
|
|
127
127
|
|
|
@@ -133,7 +133,7 @@ A dynamic module for NestJS
|
|
|
133
133
|
|
|
134
134
|
### AmqpWorkerService
|
|
135
135
|
|
|
136
|
-
Defined in: [worker-nestjs/src/worker.service.ts:75](https://github.com/btravers/amqp-contract/blob/
|
|
136
|
+
Defined in: [worker-nestjs/src/worker.service.ts:75](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.service.ts#L75)
|
|
137
137
|
|
|
138
138
|
Type-safe AMQP worker service for NestJS applications.
|
|
139
139
|
|
|
@@ -186,17 +186,17 @@ export class AppModule {}
|
|
|
186
186
|
new AmqpWorkerService<TContract>(options): AmqpWorkerService<TContract>;
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
-
Defined in: [worker-nestjs/src/worker.service.ts:80](https://github.com/btravers/amqp-contract/blob/
|
|
189
|
+
Defined in: [worker-nestjs/src/worker.service.ts:80](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.service.ts#L80)
|
|
190
190
|
|
|
191
191
|
###### Parameters
|
|
192
192
|
|
|
193
193
|
| Parameter | Type |
|
|
194
194
|
| ------ | ------ |
|
|
195
|
-
| `options` | [`AmqpWorkerModuleOptions`](#amqpworkermoduleoptions)
|
|
195
|
+
| `options` | [`AmqpWorkerModuleOptions`](#amqpworkermoduleoptions)<`TContract`> |
|
|
196
196
|
|
|
197
197
|
###### Returns
|
|
198
198
|
|
|
199
|
-
[`AmqpWorkerService`](#amqpworkerservice)
|
|
199
|
+
[`AmqpWorkerService`](#amqpworkerservice)<`TContract`>
|
|
200
200
|
|
|
201
201
|
#### Methods
|
|
202
202
|
|
|
@@ -206,7 +206,7 @@ Defined in: [worker-nestjs/src/worker.service.ts:80](https://github.com/btravers
|
|
|
206
206
|
onModuleDestroy(): Promise<void>;
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
Defined in: [worker-nestjs/src/worker.service.ts:106](https://github.com/btravers/amqp-contract/blob/
|
|
209
|
+
Defined in: [worker-nestjs/src/worker.service.ts:106](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.service.ts#L106)
|
|
210
210
|
|
|
211
211
|
Close the AMQP worker when the NestJS module is destroyed.
|
|
212
212
|
|
|
@@ -216,7 +216,7 @@ and closing the connection.
|
|
|
216
216
|
|
|
217
217
|
###### Returns
|
|
218
218
|
|
|
219
|
-
`Promise
|
|
219
|
+
`Promise`<`void`>
|
|
220
220
|
|
|
221
221
|
###### Implementation of
|
|
222
222
|
|
|
@@ -230,7 +230,7 @@ OnModuleDestroy.onModuleDestroy
|
|
|
230
230
|
onModuleInit(): Promise<void>;
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
Defined in: [worker-nestjs/src/worker.service.ts:95](https://github.com/btravers/amqp-contract/blob/
|
|
233
|
+
Defined in: [worker-nestjs/src/worker.service.ts:95](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.service.ts#L95)
|
|
234
234
|
|
|
235
235
|
Initialize the AMQP worker when the NestJS module starts.
|
|
236
236
|
|
|
@@ -241,7 +241,7 @@ automatic reconnection handling.
|
|
|
241
241
|
|
|
242
242
|
###### Returns
|
|
243
243
|
|
|
244
|
-
`Promise
|
|
244
|
+
`Promise`<`void`>
|
|
245
245
|
|
|
246
246
|
###### Throws
|
|
247
247
|
|
|
@@ -261,7 +261,7 @@ OnModuleInit.onModuleInit
|
|
|
261
261
|
type AmqpWorkerModuleAsyncOptions<TContract> = object;
|
|
262
262
|
```
|
|
263
263
|
|
|
264
|
-
Defined in: [worker-nestjs/src/worker.module.ts:22](https://github.com/btravers/amqp-contract/blob/
|
|
264
|
+
Defined in: [worker-nestjs/src/worker.module.ts:22](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.module.ts#L22)
|
|
265
265
|
|
|
266
266
|
Options for async module configuration using factory pattern
|
|
267
267
|
|
|
@@ -275,9 +275,9 @@ Options for async module configuration using factory pattern
|
|
|
275
275
|
|
|
276
276
|
| Property | Type | Description | Defined in |
|
|
277
277
|
| ------ | ------ | ------ | ------ |
|
|
278
|
-
| <a id="imports"></a> `imports?` | `ModuleMetadata`\[`"imports"`\] | 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/
|
|
279
|
-
| <a id="inject"></a> `inject?` | (`string` \| `symbol` \| `Type
|
|
280
|
-
| <a id="usefactory"></a> `useFactory` | (...`args`) => `AmqpWorkerModuleOptionsFactory
|
|
278
|
+
| <a id="imports"></a> `imports?` | `ModuleMetadata`\[`"imports"`\] | 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/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.module.ts#L37) |
|
|
279
|
+
| <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/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.module.ts#L33) |
|
|
280
|
+
| <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/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.module.ts#L28) |
|
|
281
281
|
|
|
282
282
|
***
|
|
283
283
|
|
|
@@ -287,7 +287,7 @@ Options for async module configuration using factory pattern
|
|
|
287
287
|
type AmqpWorkerModuleOptions<TContract> = object;
|
|
288
288
|
```
|
|
289
289
|
|
|
290
|
-
Defined in: [worker-nestjs/src/worker.service.ts:29](https://github.com/btravers/amqp-contract/blob/
|
|
290
|
+
Defined in: [worker-nestjs/src/worker.service.ts:29](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.service.ts#L29)
|
|
291
291
|
|
|
292
292
|
Configuration options for the AMQP worker NestJS module.
|
|
293
293
|
|
|
@@ -319,10 +319,10 @@ const options: AmqpWorkerModuleOptions<typeof contract> = {
|
|
|
319
319
|
|
|
320
320
|
| Property | Type | Description | Defined in |
|
|
321
321
|
| ------ | ------ | ------ | ------ |
|
|
322
|
-
| <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.) | [worker-nestjs/src/worker.service.ts:37](https://github.com/btravers/amqp-contract/blob/
|
|
323
|
-
| <a id="contract"></a> `contract` | `TContract` | The AMQP contract definition specifying consumers and their message schemas | [worker-nestjs/src/worker.service.ts:31](https://github.com/btravers/amqp-contract/blob/
|
|
324
|
-
| <a id="handlers"></a> `handlers` | [`WorkerInferSafeConsumerHandlers`](#workerinfersafeconsumerhandlers)
|
|
325
|
-
| <a id="urls"></a> `urls` | `ConnectionUrl`[] | AMQP broker URL(s). Multiple URLs provide failover support | [worker-nestjs/src/worker.service.ts:35](https://github.com/btravers/amqp-contract/blob/
|
|
322
|
+
| <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.) | [worker-nestjs/src/worker.service.ts:37](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.service.ts#L37) |
|
|
323
|
+
| <a id="contract"></a> `contract` | `TContract` | The AMQP contract definition specifying consumers and their message schemas | [worker-nestjs/src/worker.service.ts:31](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.service.ts#L31) |
|
|
324
|
+
| <a id="handlers"></a> `handlers` | [`WorkerInferSafeConsumerHandlers`](#workerinfersafeconsumerhandlers)<`TContract`> | Message handlers for each consumer defined in the contract. Use defineHandlers to create type-safe handlers. | [worker-nestjs/src/worker.service.ts:33](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.service.ts#L33) |
|
|
325
|
+
| <a id="urls"></a> `urls` | `ConnectionUrl`[] | AMQP broker URL(s). Multiple URLs provide failover support | [worker-nestjs/src/worker.service.ts:35](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.service.ts#L35) |
|
|
326
326
|
|
|
327
327
|
***
|
|
328
328
|
|
|
@@ -332,7 +332,7 @@ const options: AmqpWorkerModuleOptions<typeof contract> = {
|
|
|
332
332
|
type WorkerInferSafeConsumerHandlers<TContract> = { [K in InferConsumerNames<TContract>]: WorkerInferSafeConsumerHandlerEntry<TContract, K> };
|
|
333
333
|
```
|
|
334
334
|
|
|
335
|
-
Defined in: worker/dist/index.d.mts:
|
|
335
|
+
Defined in: worker/dist/index.d.mts:146
|
|
336
336
|
|
|
337
337
|
Safe consumer handlers for a contract.
|
|
338
338
|
All handlers return `Future<Result<void, HandlerError>>` for explicit error control.
|
|
@@ -351,7 +351,7 @@ All handlers return `Future<Result<void, HandlerError>>` for explicit error cont
|
|
|
351
351
|
const MODULE_OPTIONS_TOKEN: typeof MODULE_OPTIONS_TOKEN;
|
|
352
352
|
```
|
|
353
353
|
|
|
354
|
-
Defined in: [worker-nestjs/src/worker.module-definition.ts:5](https://github.com/btravers/amqp-contract/blob/
|
|
354
|
+
Defined in: [worker-nestjs/src/worker.module-definition.ts:5](https://github.com/btravers/amqp-contract/blob/c50b9d5f661ce899d34d7eebcfafa47844bd1087/packages/worker-nestjs/src/worker.module-definition.ts#L5)
|
|
355
355
|
|
|
356
356
|
Injection token for AMQP worker module options
|
|
357
357
|
Used by NestJS DI system to inject configuration into AmqpWorkerService
|
|
@@ -366,10 +366,10 @@ Used by NestJS DI system to inject configuration into AmqpWorkerService
|
|
|
366
366
|
function defineHandler<TContract, TName>(
|
|
367
367
|
contract,
|
|
368
368
|
consumerName,
|
|
369
|
-
handler): WorkerInferSafeConsumerHandlerEntry<TContract, TName>;
|
|
369
|
+
handler): WorkerInferSafeConsumerHandlerEntry<TContract, TName>;
|
|
370
370
|
```
|
|
371
371
|
|
|
372
|
-
Defined in: worker/dist/index.d.mts:
|
|
372
|
+
Defined in: worker/dist/index.d.mts:460
|
|
373
373
|
|
|
374
374
|
Define a type-safe handler for a specific consumer in a contract.
|
|
375
375
|
|
|
@@ -378,7 +378,7 @@ providing explicit error handling and better control over retry behavior.
|
|
|
378
378
|
|
|
379
379
|
Supports two patterns:
|
|
380
380
|
1. Simple handler: just the function
|
|
381
|
-
2. Handler with options: [handler, { prefetch: 10 }]
|
|
381
|
+
2. Handler with options: [handler, \{ prefetch: 10 \}]
|
|
382
382
|
|
|
383
383
|
##### Type Parameters
|
|
384
384
|
|
|
@@ -393,11 +393,11 @@ Supports two patterns:
|
|
|
393
393
|
| ------ | ------ | ------ |
|
|
394
394
|
| `contract` | `TContract` | The contract definition containing the consumer |
|
|
395
395
|
| `consumerName` | `TName` | The name of the consumer from the contract |
|
|
396
|
-
| `handler` | `WorkerInferSafeConsumerHandler
|
|
396
|
+
| `handler` | `WorkerInferSafeConsumerHandler`<`TContract`, `TName`> | The handler function that returns `Future<Result<void, HandlerError>>` |
|
|
397
397
|
|
|
398
398
|
##### Returns
|
|
399
399
|
|
|
400
|
-
`WorkerInferSafeConsumerHandlerEntry
|
|
400
|
+
`WorkerInferSafeConsumerHandlerEntry`<`TContract`, `TName`>
|
|
401
401
|
|
|
402
402
|
A type-safe handler that can be used with TypedAmqpWorker
|
|
403
403
|
|
|
@@ -439,10 +439,10 @@ function defineHandler<TContract, TName>(
|
|
|
439
439
|
contract,
|
|
440
440
|
consumerName,
|
|
441
441
|
handler,
|
|
442
|
-
options): WorkerInferSafeConsumerHandlerEntry<TContract, TName>;
|
|
442
|
+
options): WorkerInferSafeConsumerHandlerEntry<TContract, TName>;
|
|
443
443
|
```
|
|
444
444
|
|
|
445
|
-
Defined in: worker/dist/index.d.mts:
|
|
445
|
+
Defined in: worker/dist/index.d.mts:461
|
|
446
446
|
|
|
447
447
|
Define a type-safe handler for a specific consumer in a contract.
|
|
448
448
|
|
|
@@ -451,7 +451,7 @@ providing explicit error handling and better control over retry behavior.
|
|
|
451
451
|
|
|
452
452
|
Supports two patterns:
|
|
453
453
|
1. Simple handler: just the function
|
|
454
|
-
2. Handler with options: [handler, { prefetch: 10 }]
|
|
454
|
+
2. Handler with options: [handler, \{ prefetch: 10 \}]
|
|
455
455
|
|
|
456
456
|
##### Type Parameters
|
|
457
457
|
|
|
@@ -466,13 +466,13 @@ Supports two patterns:
|
|
|
466
466
|
| ------ | ------ | ------ |
|
|
467
467
|
| `contract` | `TContract` | The contract definition containing the consumer |
|
|
468
468
|
| `consumerName` | `TName` | The name of the consumer from the contract |
|
|
469
|
-
| `handler` | `WorkerInferSafeConsumerHandler
|
|
469
|
+
| `handler` | `WorkerInferSafeConsumerHandler`<`TContract`, `TName`> | The handler function that returns `Future<Result<void, HandlerError>>` |
|
|
470
470
|
| `options` | \{ `prefetch?`: `number`; \} | Optional consumer options (prefetch) |
|
|
471
471
|
| `options.prefetch?` | `number` | - |
|
|
472
472
|
|
|
473
473
|
##### Returns
|
|
474
474
|
|
|
475
|
-
`WorkerInferSafeConsumerHandlerEntry
|
|
475
|
+
`WorkerInferSafeConsumerHandlerEntry`<`TContract`, `TName`>
|
|
476
476
|
|
|
477
477
|
A type-safe handler that can be used with TypedAmqpWorker
|
|
478
478
|
|
|
@@ -515,7 +515,7 @@ const validateOrderHandler = defineHandler(
|
|
|
515
515
|
function defineHandlers<TContract>(contract, handlers): WorkerInferSafeConsumerHandlers<TContract>;
|
|
516
516
|
```
|
|
517
517
|
|
|
518
|
-
Defined in: worker/dist/index.d.mts:
|
|
518
|
+
Defined in: worker/dist/index.d.mts:493
|
|
519
519
|
|
|
520
520
|
Define multiple type-safe handlers for consumers in a contract.
|
|
521
521
|
|
|
@@ -533,11 +533,11 @@ providing explicit error handling and better control over retry behavior.
|
|
|
533
533
|
| Parameter | Type | Description |
|
|
534
534
|
| ------ | ------ | ------ |
|
|
535
535
|
| `contract` | `TContract` | The contract definition containing the consumers |
|
|
536
|
-
| `handlers` | [`WorkerInferSafeConsumerHandlers`](#workerinfersafeconsumerhandlers)
|
|
536
|
+
| `handlers` | [`WorkerInferSafeConsumerHandlers`](#workerinfersafeconsumerhandlers)<`TContract`> | An object with handler functions for each consumer |
|
|
537
537
|
|
|
538
538
|
#### Returns
|
|
539
539
|
|
|
540
|
-
[`WorkerInferSafeConsumerHandlers`](#workerinfersafeconsumerhandlers)
|
|
540
|
+
[`WorkerInferSafeConsumerHandlers`](#workerinfersafeconsumerhandlers)<`TContract`>
|
|
541
541
|
|
|
542
542
|
A type-safe handlers object that can be used with TypedAmqpWorker
|
|
543
543
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amqp-contract/worker-nestjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "NestJS integration for @amqp-contract/worker",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"amqp",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"docs"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@amqp-contract/contract": "0.
|
|
56
|
-
"@amqp-contract/worker": "0.
|
|
55
|
+
"@amqp-contract/contract": "0.12.0",
|
|
56
|
+
"@amqp-contract/worker": "0.12.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@nestjs/common": "11.1.12",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"typescript": "5.9.3",
|
|
73
73
|
"vitest": "4.0.17",
|
|
74
74
|
"zod": "4.3.5",
|
|
75
|
-
"@amqp-contract/testing": "0.
|
|
75
|
+
"@amqp-contract/testing": "0.12.0",
|
|
76
76
|
"@amqp-contract/tsconfig": "0.1.0",
|
|
77
77
|
"@amqp-contract/typedoc": "0.1.0"
|
|
78
78
|
},
|