@amqp-contract/worker-nestjs 0.12.0 → 0.13.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 +36 -35
- 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/69a6467d137997be809af2ea5c4332c378579b49/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/69a6467d137997be809af2ea5c4332c378579b49/packages/worker-nestjs/src/worker.module.ts#L95)
|
|
83
83
|
|
|
84
84
|
Register the AMQP worker module with synchronous configuration
|
|
85
85
|
|
|
@@ -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/69a6467d137997be809af2ea5c4332c378579b49/packages/worker-nestjs/src/worker.module.ts#L117)
|
|
111
111
|
|
|
112
112
|
Register the AMQP worker module with asynchronous configuration
|
|
113
113
|
|
|
@@ -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/69a6467d137997be809af2ea5c4332c378579b49/packages/worker-nestjs/src/worker.service.ts#L75)
|
|
137
137
|
|
|
138
138
|
Type-safe AMQP worker service for NestJS applications.
|
|
139
139
|
|
|
@@ -186,7 +186,7 @@ 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/69a6467d137997be809af2ea5c4332c378579b49/packages/worker-nestjs/src/worker.service.ts#L80)
|
|
190
190
|
|
|
191
191
|
###### Parameters
|
|
192
192
|
|
|
@@ -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/69a6467d137997be809af2ea5c4332c378579b49/packages/worker-nestjs/src/worker.service.ts#L106)
|
|
210
210
|
|
|
211
211
|
Close the AMQP worker when the NestJS module is destroyed.
|
|
212
212
|
|
|
@@ -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/69a6467d137997be809af2ea5c4332c378579b49/packages/worker-nestjs/src/worker.service.ts#L95)
|
|
234
234
|
|
|
235
235
|
Initialize the AMQP worker when the NestJS module starts.
|
|
236
236
|
|
|
@@ -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/69a6467d137997be809af2ea5c4332c378579b49/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`<`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/
|
|
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/
|
|
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/69a6467d137997be809af2ea5c4332c378579b49/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/69a6467d137997be809af2ea5c4332c378579b49/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/69a6467d137997be809af2ea5c4332c378579b49/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/69a6467d137997be809af2ea5c4332c378579b49/packages/worker-nestjs/src/worker.service.ts#L29)
|
|
291
291
|
|
|
292
292
|
Configuration options for the AMQP worker NestJS module.
|
|
293
293
|
|
|
@@ -319,23 +319,20 @@ 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)<`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/
|
|
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/69a6467d137997be809af2ea5c4332c378579b49/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/69a6467d137997be809af2ea5c4332c378579b49/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/69a6467d137997be809af2ea5c4332c378579b49/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/69a6467d137997be809af2ea5c4332c378579b49/packages/worker-nestjs/src/worker.service.ts#L35) |
|
|
326
326
|
|
|
327
327
|
***
|
|
328
328
|
|
|
329
|
-
### WorkerInferSafeConsumerHandlers
|
|
329
|
+
### ~~WorkerInferSafeConsumerHandlers~~
|
|
330
330
|
|
|
331
331
|
```ts
|
|
332
|
-
type WorkerInferSafeConsumerHandlers<TContract> =
|
|
332
|
+
type WorkerInferSafeConsumerHandlers<TContract> = WorkerInferConsumerHandlers<TContract>;
|
|
333
333
|
```
|
|
334
334
|
|
|
335
|
-
Defined in: worker/dist/index.d.mts:
|
|
336
|
-
|
|
337
|
-
Safe consumer handlers for a contract.
|
|
338
|
-
All handlers return `Future<Result<void, HandlerError>>` for explicit error control.
|
|
335
|
+
Defined in: worker/dist/index.d.mts:288
|
|
339
336
|
|
|
340
337
|
#### Type Parameters
|
|
341
338
|
|
|
@@ -343,6 +340,10 @@ All handlers return `Future<Result<void, HandlerError>>` for explicit error cont
|
|
|
343
340
|
| ------ |
|
|
344
341
|
| `TContract` *extends* `ContractDefinition` |
|
|
345
342
|
|
|
343
|
+
#### Deprecated
|
|
344
|
+
|
|
345
|
+
Use `WorkerInferConsumerHandlers` instead. Will be removed in next major version.
|
|
346
|
+
|
|
346
347
|
## Variables
|
|
347
348
|
|
|
348
349
|
### MODULE\_OPTIONS\_TOKEN
|
|
@@ -351,7 +352,7 @@ All handlers return `Future<Result<void, HandlerError>>` for explicit error cont
|
|
|
351
352
|
const MODULE_OPTIONS_TOKEN: typeof MODULE_OPTIONS_TOKEN;
|
|
352
353
|
```
|
|
353
354
|
|
|
354
|
-
Defined in: [worker-nestjs/src/worker.module-definition.ts:5](https://github.com/btravers/amqp-contract/blob/
|
|
355
|
+
Defined in: [worker-nestjs/src/worker.module-definition.ts:5](https://github.com/btravers/amqp-contract/blob/69a6467d137997be809af2ea5c4332c378579b49/packages/worker-nestjs/src/worker.module-definition.ts#L5)
|
|
355
356
|
|
|
356
357
|
Injection token for AMQP worker module options
|
|
357
358
|
Used by NestJS DI system to inject configuration into AmqpWorkerService
|
|
@@ -366,10 +367,10 @@ Used by NestJS DI system to inject configuration into AmqpWorkerService
|
|
|
366
367
|
function defineHandler<TContract, TName>(
|
|
367
368
|
contract,
|
|
368
369
|
consumerName,
|
|
369
|
-
handler):
|
|
370
|
+
handler): WorkerInferConsumerHandlerEntry<TContract, TName>;
|
|
370
371
|
```
|
|
371
372
|
|
|
372
|
-
Defined in: worker/dist/index.d.mts:
|
|
373
|
+
Defined in: worker/dist/index.d.mts:602
|
|
373
374
|
|
|
374
375
|
Define a type-safe handler for a specific consumer in a contract.
|
|
375
376
|
|
|
@@ -393,11 +394,11 @@ Supports two patterns:
|
|
|
393
394
|
| ------ | ------ | ------ |
|
|
394
395
|
| `contract` | `TContract` | The contract definition containing the consumer |
|
|
395
396
|
| `consumerName` | `TName` | The name of the consumer from the contract |
|
|
396
|
-
| `handler` | `
|
|
397
|
+
| `handler` | `WorkerInferConsumerHandler`<`TContract`, `TName`> | The handler function that returns `Future<Result<void, HandlerError>>` |
|
|
397
398
|
|
|
398
399
|
##### Returns
|
|
399
400
|
|
|
400
|
-
`
|
|
401
|
+
`WorkerInferConsumerHandlerEntry`<`TContract`, `TName`>
|
|
401
402
|
|
|
402
403
|
A type-safe handler that can be used with TypedAmqpWorker
|
|
403
404
|
|
|
@@ -439,10 +440,10 @@ function defineHandler<TContract, TName>(
|
|
|
439
440
|
contract,
|
|
440
441
|
consumerName,
|
|
441
442
|
handler,
|
|
442
|
-
options):
|
|
443
|
+
options): WorkerInferConsumerHandlerEntry<TContract, TName>;
|
|
443
444
|
```
|
|
444
445
|
|
|
445
|
-
Defined in: worker/dist/index.d.mts:
|
|
446
|
+
Defined in: worker/dist/index.d.mts:603
|
|
446
447
|
|
|
447
448
|
Define a type-safe handler for a specific consumer in a contract.
|
|
448
449
|
|
|
@@ -466,13 +467,13 @@ Supports two patterns:
|
|
|
466
467
|
| ------ | ------ | ------ |
|
|
467
468
|
| `contract` | `TContract` | The contract definition containing the consumer |
|
|
468
469
|
| `consumerName` | `TName` | The name of the consumer from the contract |
|
|
469
|
-
| `handler` | `
|
|
470
|
+
| `handler` | `WorkerInferConsumerHandler`<`TContract`, `TName`> | The handler function that returns `Future<Result<void, HandlerError>>` |
|
|
470
471
|
| `options` | \{ `prefetch?`: `number`; \} | Optional consumer options (prefetch) |
|
|
471
472
|
| `options.prefetch?` | `number` | - |
|
|
472
473
|
|
|
473
474
|
##### Returns
|
|
474
475
|
|
|
475
|
-
`
|
|
476
|
+
`WorkerInferConsumerHandlerEntry`<`TContract`, `TName`>
|
|
476
477
|
|
|
477
478
|
A type-safe handler that can be used with TypedAmqpWorker
|
|
478
479
|
|
|
@@ -512,10 +513,10 @@ const validateOrderHandler = defineHandler(
|
|
|
512
513
|
### defineHandlers()
|
|
513
514
|
|
|
514
515
|
```ts
|
|
515
|
-
function defineHandlers<TContract>(contract, handlers):
|
|
516
|
+
function defineHandlers<TContract>(contract, handlers): WorkerInferConsumerHandlers<TContract>;
|
|
516
517
|
```
|
|
517
518
|
|
|
518
|
-
Defined in: worker/dist/index.d.mts:
|
|
519
|
+
Defined in: worker/dist/index.d.mts:635
|
|
519
520
|
|
|
520
521
|
Define multiple type-safe handlers for consumers in a contract.
|
|
521
522
|
|
|
@@ -533,11 +534,11 @@ providing explicit error handling and better control over retry behavior.
|
|
|
533
534
|
| Parameter | Type | Description |
|
|
534
535
|
| ------ | ------ | ------ |
|
|
535
536
|
| `contract` | `TContract` | The contract definition containing the consumers |
|
|
536
|
-
| `handlers` |
|
|
537
|
+
| `handlers` | `WorkerInferConsumerHandlers`<`TContract`> | An object with handler functions for each consumer |
|
|
537
538
|
|
|
538
539
|
#### Returns
|
|
539
540
|
|
|
540
|
-
|
|
541
|
+
`WorkerInferConsumerHandlers`<`TContract`>
|
|
541
542
|
|
|
542
543
|
A type-safe handlers object that can be used with TypedAmqpWorker
|
|
543
544
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amqp-contract/worker-nestjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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.13.0",
|
|
56
|
+
"@amqp-contract/worker": "0.13.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.13.0",
|
|
76
76
|
"@amqp-contract/tsconfig": "0.1.0",
|
|
77
77
|
"@amqp-contract/typedoc": "0.1.0"
|
|
78
78
|
},
|