@amqp-contract/worker 0.17.0 → 0.18.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 +49 -49
- package/package.json +6 -6
package/docs/index.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
### MessageValidationError
|
|
10
10
|
|
|
11
|
-
Defined in: [packages/worker/src/errors.ts:4](https://github.com/btravers/amqp-contract/blob/
|
|
11
|
+
Defined in: [packages/worker/src/errors.ts:4](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L4)
|
|
12
12
|
|
|
13
13
|
Error thrown when message validation fails
|
|
14
14
|
|
|
@@ -24,7 +24,7 @@ Error thrown when message validation fails
|
|
|
24
24
|
new MessageValidationError(consumerName, issues): MessageValidationError;
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
Defined in: [packages/worker/src/errors.ts:5](https://github.com/btravers/amqp-contract/blob/
|
|
27
|
+
Defined in: [packages/worker/src/errors.ts:5](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L5)
|
|
28
28
|
|
|
29
29
|
###### Parameters
|
|
30
30
|
|
|
@@ -48,12 +48,12 @@ Error.constructor
|
|
|
48
48
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
49
49
|
| ------ | ------ | ------ | ------ | ------ | ------ |
|
|
50
50
|
| <a id="cause"></a> `cause?` | `public` | `unknown` | - | `Error.cause` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26 |
|
|
51
|
-
| <a id="consumername"></a> `consumerName` | `readonly` | `string` | - | - | [packages/worker/src/errors.ts:6](https://github.com/btravers/amqp-contract/blob/
|
|
52
|
-
| <a id="issues"></a> `issues` | `readonly` | `unknown` | - | - | [packages/worker/src/errors.ts:7](https://github.com/btravers/amqp-contract/blob/
|
|
51
|
+
| <a id="consumername"></a> `consumerName` | `readonly` | `string` | - | - | [packages/worker/src/errors.ts:6](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L6) |
|
|
52
|
+
| <a id="issues"></a> `issues` | `readonly` | `unknown` | - | - | [packages/worker/src/errors.ts:7](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L7) |
|
|
53
53
|
| <a id="message"></a> `message` | `public` | `string` | - | `Error.message` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 |
|
|
54
54
|
| <a id="name"></a> `name` | `public` | `string` | - | `Error.name` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
|
|
55
55
|
| <a id="stack"></a> `stack?` | `public` | `string` | - | `Error.stack` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 |
|
|
56
|
-
| <a id="stacktracelimit"></a> `stackTraceLimit` | `static` | `number` | The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | `Error.stackTraceLimit` | node\_modules/.pnpm/@types+node@25.2.
|
|
56
|
+
| <a id="stacktracelimit"></a> `stackTraceLimit` | `static` | `number` | The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | `Error.stackTraceLimit` | node\_modules/.pnpm/@types+node@25.2.3/node\_modules/@types/node/globals.d.ts:67 |
|
|
57
57
|
|
|
58
58
|
#### Methods
|
|
59
59
|
|
|
@@ -63,7 +63,7 @@ Error.constructor
|
|
|
63
63
|
static captureStackTrace(targetObject, constructorOpt?): void;
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
Defined in: node\_modules/.pnpm/@types+node@25.2.
|
|
66
|
+
Defined in: node\_modules/.pnpm/@types+node@25.2.3/node\_modules/@types/node/globals.d.ts:51
|
|
67
67
|
|
|
68
68
|
Creates a `.stack` property on `targetObject`, which when accessed returns
|
|
69
69
|
a string representing the location in the code at which
|
|
@@ -132,7 +132,7 @@ Error.captureStackTrace
|
|
|
132
132
|
static prepareStackTrace(err, stackTraces): any;
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
Defined in: node\_modules/.pnpm/@types+node@25.2.
|
|
135
|
+
Defined in: node\_modules/.pnpm/@types+node@25.2.3/node\_modules/@types/node/globals.d.ts:55
|
|
136
136
|
|
|
137
137
|
###### Parameters
|
|
138
138
|
|
|
@@ -159,7 +159,7 @@ Error.prepareStackTrace
|
|
|
159
159
|
|
|
160
160
|
### NonRetryableError
|
|
161
161
|
|
|
162
|
-
Defined in: [packages/worker/src/errors.ts:52](https://github.com/btravers/amqp-contract/blob/
|
|
162
|
+
Defined in: [packages/worker/src/errors.ts:52](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L52)
|
|
163
163
|
|
|
164
164
|
Non-retryable errors - permanent failures that should not be retried
|
|
165
165
|
Examples: invalid data, business rule violations, permanent external failures
|
|
@@ -179,7 +179,7 @@ immediately sent to the dead letter queue (DLQ) if configured.
|
|
|
179
179
|
new NonRetryableError(message, cause?): NonRetryableError;
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
-
Defined in: [packages/worker/src/errors.ts:53](https://github.com/btravers/amqp-contract/blob/
|
|
182
|
+
Defined in: [packages/worker/src/errors.ts:53](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L53)
|
|
183
183
|
|
|
184
184
|
###### Parameters
|
|
185
185
|
|
|
@@ -202,11 +202,11 @@ Error.constructor
|
|
|
202
202
|
|
|
203
203
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
204
204
|
| ------ | ------ | ------ | ------ | ------ | ------ |
|
|
205
|
-
| <a id="cause-1"></a> `cause?` | `readonly` | `unknown` | - | `Error.cause` | [packages/worker/src/errors.ts:55](https://github.com/btravers/amqp-contract/blob/
|
|
205
|
+
| <a id="cause-1"></a> `cause?` | `readonly` | `unknown` | - | `Error.cause` | [packages/worker/src/errors.ts:55](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L55) |
|
|
206
206
|
| <a id="message-1"></a> `message` | `public` | `string` | - | `Error.message` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 |
|
|
207
207
|
| <a id="name-1"></a> `name` | `public` | `string` | - | `Error.name` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
|
|
208
208
|
| <a id="stack-1"></a> `stack?` | `public` | `string` | - | `Error.stack` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 |
|
|
209
|
-
| <a id="stacktracelimit-1"></a> `stackTraceLimit` | `static` | `number` | The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | `Error.stackTraceLimit` | node\_modules/.pnpm/@types+node@25.2.
|
|
209
|
+
| <a id="stacktracelimit-1"></a> `stackTraceLimit` | `static` | `number` | The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | `Error.stackTraceLimit` | node\_modules/.pnpm/@types+node@25.2.3/node\_modules/@types/node/globals.d.ts:67 |
|
|
210
210
|
|
|
211
211
|
#### Methods
|
|
212
212
|
|
|
@@ -216,7 +216,7 @@ Error.constructor
|
|
|
216
216
|
static captureStackTrace(targetObject, constructorOpt?): void;
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
-
Defined in: node\_modules/.pnpm/@types+node@25.2.
|
|
219
|
+
Defined in: node\_modules/.pnpm/@types+node@25.2.3/node\_modules/@types/node/globals.d.ts:51
|
|
220
220
|
|
|
221
221
|
Creates a `.stack` property on `targetObject`, which when accessed returns
|
|
222
222
|
a string representing the location in the code at which
|
|
@@ -285,7 +285,7 @@ Error.captureStackTrace
|
|
|
285
285
|
static prepareStackTrace(err, stackTraces): any;
|
|
286
286
|
```
|
|
287
287
|
|
|
288
|
-
Defined in: node\_modules/.pnpm/@types+node@25.2.
|
|
288
|
+
Defined in: node\_modules/.pnpm/@types+node@25.2.3/node\_modules/@types/node/globals.d.ts:55
|
|
289
289
|
|
|
290
290
|
###### Parameters
|
|
291
291
|
|
|
@@ -312,7 +312,7 @@ Error.prepareStackTrace
|
|
|
312
312
|
|
|
313
313
|
### RetryableError
|
|
314
314
|
|
|
315
|
-
Defined in: [packages/worker/src/errors.ts:28](https://github.com/btravers/amqp-contract/blob/
|
|
315
|
+
Defined in: [packages/worker/src/errors.ts:28](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L28)
|
|
316
316
|
|
|
317
317
|
Retryable errors - transient failures that may succeed on retry
|
|
318
318
|
Examples: network timeouts, rate limiting, temporary service unavailability
|
|
@@ -332,7 +332,7 @@ The worker will apply exponential backoff and retry the message.
|
|
|
332
332
|
new RetryableError(message, cause?): RetryableError;
|
|
333
333
|
```
|
|
334
334
|
|
|
335
|
-
Defined in: [packages/worker/src/errors.ts:29](https://github.com/btravers/amqp-contract/blob/
|
|
335
|
+
Defined in: [packages/worker/src/errors.ts:29](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L29)
|
|
336
336
|
|
|
337
337
|
###### Parameters
|
|
338
338
|
|
|
@@ -355,11 +355,11 @@ Error.constructor
|
|
|
355
355
|
|
|
356
356
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
357
357
|
| ------ | ------ | ------ | ------ | ------ | ------ |
|
|
358
|
-
| <a id="cause-2"></a> `cause?` | `readonly` | `unknown` | - | `Error.cause` | [packages/worker/src/errors.ts:31](https://github.com/btravers/amqp-contract/blob/
|
|
358
|
+
| <a id="cause-2"></a> `cause?` | `readonly` | `unknown` | - | `Error.cause` | [packages/worker/src/errors.ts:31](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L31) |
|
|
359
359
|
| <a id="message-2"></a> `message` | `public` | `string` | - | `Error.message` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 |
|
|
360
360
|
| <a id="name-2"></a> `name` | `public` | `string` | - | `Error.name` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
|
|
361
361
|
| <a id="stack-2"></a> `stack?` | `public` | `string` | - | `Error.stack` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 |
|
|
362
|
-
| <a id="stacktracelimit-2"></a> `stackTraceLimit` | `static` | `number` | The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | `Error.stackTraceLimit` | node\_modules/.pnpm/@types+node@25.2.
|
|
362
|
+
| <a id="stacktracelimit-2"></a> `stackTraceLimit` | `static` | `number` | The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | `Error.stackTraceLimit` | node\_modules/.pnpm/@types+node@25.2.3/node\_modules/@types/node/globals.d.ts:67 |
|
|
363
363
|
|
|
364
364
|
#### Methods
|
|
365
365
|
|
|
@@ -369,7 +369,7 @@ Error.constructor
|
|
|
369
369
|
static captureStackTrace(targetObject, constructorOpt?): void;
|
|
370
370
|
```
|
|
371
371
|
|
|
372
|
-
Defined in: node\_modules/.pnpm/@types+node@25.2.
|
|
372
|
+
Defined in: node\_modules/.pnpm/@types+node@25.2.3/node\_modules/@types/node/globals.d.ts:51
|
|
373
373
|
|
|
374
374
|
Creates a `.stack` property on `targetObject`, which when accessed returns
|
|
375
375
|
a string representing the location in the code at which
|
|
@@ -438,7 +438,7 @@ Error.captureStackTrace
|
|
|
438
438
|
static prepareStackTrace(err, stackTraces): any;
|
|
439
439
|
```
|
|
440
440
|
|
|
441
|
-
Defined in: node\_modules/.pnpm/@types+node@25.2.
|
|
441
|
+
Defined in: node\_modules/.pnpm/@types+node@25.2.3/node\_modules/@types/node/globals.d.ts:55
|
|
442
442
|
|
|
443
443
|
###### Parameters
|
|
444
444
|
|
|
@@ -465,7 +465,7 @@ Error.prepareStackTrace
|
|
|
465
465
|
|
|
466
466
|
### TypedAmqpWorker
|
|
467
467
|
|
|
468
|
-
Defined in: [packages/worker/src/worker.ts:158](https://github.com/btravers/amqp-contract/blob/
|
|
468
|
+
Defined in: [packages/worker/src/worker.ts:158](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/worker.ts#L158)
|
|
469
469
|
|
|
470
470
|
Type-safe AMQP worker for consuming messages from RabbitMQ.
|
|
471
471
|
|
|
@@ -520,7 +520,7 @@ await worker.close().resultToPromise();
|
|
|
520
520
|
close(): Future<Result<void, TechnicalError>>;
|
|
521
521
|
```
|
|
522
522
|
|
|
523
|
-
Defined in: [packages/worker/src/worker.ts:278](https://github.com/btravers/amqp-contract/blob/
|
|
523
|
+
Defined in: [packages/worker/src/worker.ts:278](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/worker.ts#L278)
|
|
524
524
|
|
|
525
525
|
Close the AMQP channel and connection.
|
|
526
526
|
|
|
@@ -548,7 +548,7 @@ if (closeResult.isOk()) {
|
|
|
548
548
|
static create<TContract>(options): Future<Result<TypedAmqpWorker<TContract>, TechnicalError>>;
|
|
549
549
|
```
|
|
550
550
|
|
|
551
|
-
Defined in: [packages/worker/src/worker.ts:235](https://github.com/btravers/amqp-contract/blob/
|
|
551
|
+
Defined in: [packages/worker/src/worker.ts:235](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/worker.ts#L235)
|
|
552
552
|
|
|
553
553
|
Create a type-safe AMQP worker from a contract.
|
|
554
554
|
|
|
@@ -598,7 +598,7 @@ const worker = await TypedAmqpWorker.create({
|
|
|
598
598
|
type CreateWorkerOptions<TContract> = object;
|
|
599
599
|
```
|
|
600
600
|
|
|
601
|
-
Defined in: [packages/worker/src/worker.ts:94](https://github.com/btravers/amqp-contract/blob/
|
|
601
|
+
Defined in: [packages/worker/src/worker.ts:94](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/worker.ts#L94)
|
|
602
602
|
|
|
603
603
|
Options for creating a type-safe AMQP worker.
|
|
604
604
|
|
|
@@ -643,12 +643,12 @@ not at the handler level. See `QueueDefinition.retry` for configuration options.
|
|
|
643
643
|
|
|
644
644
|
| Property | Type | Description | Defined in |
|
|
645
645
|
| ------ | ------ | ------ | ------ |
|
|
646
|
-
| <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.) | [packages/worker/src/worker.ts:106](https://github.com/btravers/amqp-contract/blob/
|
|
647
|
-
| <a id="contract"></a> `contract` | `TContract` | The AMQP contract definition specifying consumers and their message schemas | [packages/worker/src/worker.ts:96](https://github.com/btravers/amqp-contract/blob/
|
|
648
|
-
| <a id="handlers"></a> `handlers` | [`WorkerInferConsumerHandlers`](#workerinferconsumerhandlers)<`TContract`> | Handlers for each consumer defined in the contract. Handlers must return `Future<Result<void, HandlerError>>` for explicit error handling. Use defineHandler() to create handlers. | [packages/worker/src/worker.ts:102](https://github.com/btravers/amqp-contract/blob/
|
|
649
|
-
| <a id="logger"></a> `logger?` | `Logger` | Optional logger for logging message consumption and errors | [packages/worker/src/worker.ts:108](https://github.com/btravers/amqp-contract/blob/
|
|
650
|
-
| <a id="telemetry"></a> `telemetry?` | `TelemetryProvider` | Optional telemetry provider for tracing and metrics. If not provided, uses the default provider which attempts to load OpenTelemetry. OpenTelemetry instrumentation is automatically enabled if @opentelemetry/api is installed. | [packages/worker/src/worker.ts:114](https://github.com/btravers/amqp-contract/blob/
|
|
651
|
-
| <a id="urls"></a> `urls` | `ConnectionUrl`[] | AMQP broker URL(s). Multiple URLs provide failover support | [packages/worker/src/worker.ts:104](https://github.com/btravers/amqp-contract/blob/
|
|
646
|
+
| <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.) | [packages/worker/src/worker.ts:106](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/worker.ts#L106) |
|
|
647
|
+
| <a id="contract"></a> `contract` | `TContract` | The AMQP contract definition specifying consumers and their message schemas | [packages/worker/src/worker.ts:96](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/worker.ts#L96) |
|
|
648
|
+
| <a id="handlers"></a> `handlers` | [`WorkerInferConsumerHandlers`](#workerinferconsumerhandlers)<`TContract`> | Handlers for each consumer defined in the contract. Handlers must return `Future<Result<void, HandlerError>>` for explicit error handling. Use defineHandler() to create handlers. | [packages/worker/src/worker.ts:102](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/worker.ts#L102) |
|
|
649
|
+
| <a id="logger"></a> `logger?` | `Logger` | Optional logger for logging message consumption and errors | [packages/worker/src/worker.ts:108](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/worker.ts#L108) |
|
|
650
|
+
| <a id="telemetry"></a> `telemetry?` | `TelemetryProvider` | Optional telemetry provider for tracing and metrics. If not provided, uses the default provider which attempts to load OpenTelemetry. OpenTelemetry instrumentation is automatically enabled if @opentelemetry/api is installed. | [packages/worker/src/worker.ts:114](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/worker.ts#L114) |
|
|
651
|
+
| <a id="urls"></a> `urls` | `ConnectionUrl`[] | AMQP broker URL(s). Multiple URLs provide failover support | [packages/worker/src/worker.ts:104](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/worker.ts#L104) |
|
|
652
652
|
|
|
653
653
|
***
|
|
654
654
|
|
|
@@ -660,7 +660,7 @@ type HandlerError =
|
|
|
660
660
|
| NonRetryableError;
|
|
661
661
|
```
|
|
662
662
|
|
|
663
|
-
Defined in: [packages/worker/src/errors.ts:73](https://github.com/btravers/amqp-contract/blob/
|
|
663
|
+
Defined in: [packages/worker/src/errors.ts:73](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L73)
|
|
664
664
|
|
|
665
665
|
Union type representing all handler errors.
|
|
666
666
|
Use this type when defining handlers that explicitly signal error outcomes.
|
|
@@ -673,7 +673,7 @@ Use this type when defining handlers that explicitly signal error outcomes.
|
|
|
673
673
|
type WorkerConsumedMessage<TPayload, THeaders> = object;
|
|
674
674
|
```
|
|
675
675
|
|
|
676
|
-
Defined in: [packages/worker/src/types.ts:104](https://github.com/btravers/amqp-contract/blob/
|
|
676
|
+
Defined in: [packages/worker/src/types.ts:104](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/types.ts#L104)
|
|
677
677
|
|
|
678
678
|
A consumed message containing parsed payload and headers.
|
|
679
679
|
|
|
@@ -703,8 +703,8 @@ const handler = defineHandler(contract, 'processOrder', (message, rawMessage) =>
|
|
|
703
703
|
|
|
704
704
|
| Property | Type | Description | Defined in |
|
|
705
705
|
| ------ | ------ | ------ | ------ |
|
|
706
|
-
| <a id="headers"></a> `headers` | `THeaders` *extends* `undefined` ? `undefined` : `THeaders` | The validated message headers (present only when headers schema is defined) | [packages/worker/src/types.ts:108](https://github.com/btravers/amqp-contract/blob/
|
|
707
|
-
| <a id="payload"></a> `payload` | `TPayload` | The validated message payload | [packages/worker/src/types.ts:106](https://github.com/btravers/amqp-contract/blob/
|
|
706
|
+
| <a id="headers"></a> `headers` | `THeaders` *extends* `undefined` ? `undefined` : `THeaders` | The validated message headers (present only when headers schema is defined) | [packages/worker/src/types.ts:108](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/types.ts#L108) |
|
|
707
|
+
| <a id="payload"></a> `payload` | `TPayload` | The validated message payload | [packages/worker/src/types.ts:106](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/types.ts#L106) |
|
|
708
708
|
|
|
709
709
|
***
|
|
710
710
|
|
|
@@ -714,7 +714,7 @@ const handler = defineHandler(contract, 'processOrder', (message, rawMessage) =>
|
|
|
714
714
|
type WorkerInferConsumedMessage<TContract, TName> = WorkerConsumedMessage<WorkerInferConsumerPayload<TContract, TName>, WorkerInferConsumerHeaders<TContract, TName>>;
|
|
715
715
|
```
|
|
716
716
|
|
|
717
|
-
Defined in: [packages/worker/src/types.ts:115](https://github.com/btravers/amqp-contract/blob/
|
|
717
|
+
Defined in: [packages/worker/src/types.ts:115](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/types.ts#L115)
|
|
718
718
|
|
|
719
719
|
Infer the full consumed message type for a specific consumer.
|
|
720
720
|
Includes both payload and headers (if defined).
|
|
@@ -734,7 +734,7 @@ Includes both payload and headers (if defined).
|
|
|
734
734
|
type WorkerInferConsumerHandler<TContract, TName> = (message, rawMessage) => Future<Result<void, HandlerError>>;
|
|
735
735
|
```
|
|
736
736
|
|
|
737
|
-
Defined in: [packages/worker/src/types.ts:154](https://github.com/btravers/amqp-contract/blob/
|
|
737
|
+
Defined in: [packages/worker/src/types.ts:154](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/types.ts#L154)
|
|
738
738
|
|
|
739
739
|
Consumer handler type for a specific consumer.
|
|
740
740
|
Returns a `Future<Result<void, HandlerError>>` for explicit error handling.
|
|
@@ -787,7 +787,7 @@ type WorkerInferConsumerHandlerEntry<TContract, TName> =
|
|
|
787
787
|
}];
|
|
788
788
|
```
|
|
789
789
|
|
|
790
|
-
Defined in: [packages/worker/src/types.ts:172](https://github.com/btravers/amqp-contract/blob/
|
|
790
|
+
Defined in: [packages/worker/src/types.ts:172](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/types.ts#L172)
|
|
791
791
|
|
|
792
792
|
Handler entry for a consumer - either a function or a tuple of [handler, options].
|
|
793
793
|
|
|
@@ -813,7 +813,7 @@ not at the handler level. See `QueueDefinition.retry` for configuration options.
|
|
|
813
813
|
type WorkerInferConsumerHandlers<TContract> = { [K in InferConsumerNames<TContract>]: WorkerInferConsumerHandlerEntry<TContract, K> };
|
|
814
814
|
```
|
|
815
815
|
|
|
816
|
-
Defined in: [packages/worker/src/types.ts:193](https://github.com/btravers/amqp-contract/blob/
|
|
816
|
+
Defined in: [packages/worker/src/types.ts:193](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/types.ts#L193)
|
|
817
817
|
|
|
818
818
|
Consumer handlers for a contract.
|
|
819
819
|
All handlers return `Future<Result<void, HandlerError>>` for explicit error control.
|
|
@@ -843,7 +843,7 @@ const handlers: WorkerInferConsumerHandlers<typeof contract> = {
|
|
|
843
843
|
type WorkerInferConsumerHeaders<TContract, TName> = ConsumerInferHeadersInput<InferConsumer<TContract, TName>>;
|
|
844
844
|
```
|
|
845
845
|
|
|
846
|
-
Defined in: [packages/worker/src/types.ts:79](https://github.com/btravers/amqp-contract/blob/
|
|
846
|
+
Defined in: [packages/worker/src/types.ts:79](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/types.ts#L79)
|
|
847
847
|
|
|
848
848
|
Infer the headers type for a specific consumer
|
|
849
849
|
Returns undefined if no headers schema is defined
|
|
@@ -863,7 +863,7 @@ Returns undefined if no headers schema is defined
|
|
|
863
863
|
type WorkerInferSafeConsumerHandler<TContract, TName> = WorkerInferConsumerHandler<TContract, TName>;
|
|
864
864
|
```
|
|
865
865
|
|
|
866
|
-
Defined in: [packages/worker/src/types.ts:205](https://github.com/btravers/amqp-contract/blob/
|
|
866
|
+
Defined in: [packages/worker/src/types.ts:205](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/types.ts#L205)
|
|
867
867
|
|
|
868
868
|
#### Type Parameters
|
|
869
869
|
|
|
@@ -884,7 +884,7 @@ Use `WorkerInferConsumerHandler` instead. Will be removed in next major version.
|
|
|
884
884
|
type WorkerInferSafeConsumerHandlerEntry<TContract, TName> = WorkerInferConsumerHandlerEntry<TContract, TName>;
|
|
885
885
|
```
|
|
886
886
|
|
|
887
|
-
Defined in: [packages/worker/src/types.ts:213](https://github.com/btravers/amqp-contract/blob/
|
|
887
|
+
Defined in: [packages/worker/src/types.ts:213](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/types.ts#L213)
|
|
888
888
|
|
|
889
889
|
#### Type Parameters
|
|
890
890
|
|
|
@@ -905,7 +905,7 @@ Use `WorkerInferConsumerHandlerEntry` instead. Will be removed in next major ver
|
|
|
905
905
|
type WorkerInferSafeConsumerHandlers<TContract> = WorkerInferConsumerHandlers<TContract>;
|
|
906
906
|
```
|
|
907
907
|
|
|
908
|
-
Defined in: [packages/worker/src/types.ts:221](https://github.com/btravers/amqp-contract/blob/
|
|
908
|
+
Defined in: [packages/worker/src/types.ts:221](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/types.ts#L221)
|
|
909
909
|
|
|
910
910
|
#### Type Parameters
|
|
911
911
|
|
|
@@ -930,7 +930,7 @@ function defineHandler<TContract, TName>(
|
|
|
930
930
|
handler): WorkerInferConsumerHandlerEntry<TContract, TName>;
|
|
931
931
|
```
|
|
932
932
|
|
|
933
|
-
Defined in: [packages/worker/src/handlers.ts:103](https://github.com/btravers/amqp-contract/blob/
|
|
933
|
+
Defined in: [packages/worker/src/handlers.ts:103](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/handlers.ts#L103)
|
|
934
934
|
|
|
935
935
|
Define a type-safe handler for a specific consumer in a contract.
|
|
936
936
|
|
|
@@ -1003,7 +1003,7 @@ function defineHandler<TContract, TName>(
|
|
|
1003
1003
|
options): WorkerInferConsumerHandlerEntry<TContract, TName>;
|
|
1004
1004
|
```
|
|
1005
1005
|
|
|
1006
|
-
Defined in: [packages/worker/src/handlers.ts:111](https://github.com/btravers/amqp-contract/blob/
|
|
1006
|
+
Defined in: [packages/worker/src/handlers.ts:111](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/handlers.ts#L111)
|
|
1007
1007
|
|
|
1008
1008
|
Define a type-safe handler for a specific consumer in a contract.
|
|
1009
1009
|
|
|
@@ -1076,7 +1076,7 @@ const validateOrderHandler = defineHandler(
|
|
|
1076
1076
|
function defineHandlers<TContract>(contract, handlers): WorkerInferConsumerHandlers<TContract>;
|
|
1077
1077
|
```
|
|
1078
1078
|
|
|
1079
|
-
Defined in: [packages/worker/src/handlers.ts:166](https://github.com/btravers/amqp-contract/blob/
|
|
1079
|
+
Defined in: [packages/worker/src/handlers.ts:166](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/handlers.ts#L166)
|
|
1080
1080
|
|
|
1081
1081
|
Define multiple type-safe handlers for consumers in a contract.
|
|
1082
1082
|
|
|
@@ -1129,7 +1129,7 @@ const handlers = defineHandlers(orderContract, {
|
|
|
1129
1129
|
function isHandlerError(error): error is HandlerError;
|
|
1130
1130
|
```
|
|
1131
1131
|
|
|
1132
|
-
Defined in: [packages/worker/src/errors.ts:149](https://github.com/btravers/amqp-contract/blob/
|
|
1132
|
+
Defined in: [packages/worker/src/errors.ts:149](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L149)
|
|
1133
1133
|
|
|
1134
1134
|
Type guard to check if an error is any HandlerError (RetryableError or NonRetryableError).
|
|
1135
1135
|
|
|
@@ -1166,7 +1166,7 @@ function handleError(error: unknown) {
|
|
|
1166
1166
|
function isNonRetryableError(error): error is NonRetryableError;
|
|
1167
1167
|
```
|
|
1168
1168
|
|
|
1169
|
-
Defined in: [packages/worker/src/errors.ts:127](https://github.com/btravers/amqp-contract/blob/
|
|
1169
|
+
Defined in: [packages/worker/src/errors.ts:127](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L127)
|
|
1170
1170
|
|
|
1171
1171
|
Type guard to check if an error is a NonRetryableError.
|
|
1172
1172
|
|
|
@@ -1206,7 +1206,7 @@ try {
|
|
|
1206
1206
|
function isRetryableError(error): error is RetryableError;
|
|
1207
1207
|
```
|
|
1208
1208
|
|
|
1209
|
-
Defined in: [packages/worker/src/errors.ts:102](https://github.com/btravers/amqp-contract/blob/
|
|
1209
|
+
Defined in: [packages/worker/src/errors.ts:102](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L102)
|
|
1210
1210
|
|
|
1211
1211
|
Type guard to check if an error is a RetryableError.
|
|
1212
1212
|
|
|
@@ -1248,7 +1248,7 @@ try {
|
|
|
1248
1248
|
function nonRetryable(message, cause?): NonRetryableError;
|
|
1249
1249
|
```
|
|
1250
1250
|
|
|
1251
|
-
Defined in: [packages/worker/src/errors.ts:211](https://github.com/btravers/amqp-contract/blob/
|
|
1251
|
+
Defined in: [packages/worker/src/errors.ts:211](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L211)
|
|
1252
1252
|
|
|
1253
1253
|
Create a NonRetryableError with less verbosity.
|
|
1254
1254
|
|
|
@@ -1293,7 +1293,7 @@ const handler = ({ payload }) => {
|
|
|
1293
1293
|
function retryable(message, cause?): RetryableError;
|
|
1294
1294
|
```
|
|
1295
1295
|
|
|
1296
|
-
Defined in: [packages/worker/src/errors.ts:181](https://github.com/btravers/amqp-contract/blob/
|
|
1296
|
+
Defined in: [packages/worker/src/errors.ts:181](https://github.com/btravers/amqp-contract/blob/fc480811955c7c63b50aea18b1676c065870bfae/packages/worker/src/errors.ts#L181)
|
|
1297
1297
|
|
|
1298
1298
|
Create a RetryableError with less verbosity.
|
|
1299
1299
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amqp-contract/worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Worker utilities for consuming messages using amqp-contract",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"amqp",
|
|
@@ -52,22 +52,22 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@standard-schema/spec": "1.1.0",
|
|
54
54
|
"@swan-io/boxed": "3.2.1",
|
|
55
|
-
"@amqp-contract/contract": "0.
|
|
56
|
-
"@amqp-contract/core": "0.
|
|
55
|
+
"@amqp-contract/contract": "0.18.0",
|
|
56
|
+
"@amqp-contract/core": "0.18.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/amqplib": "0.10.8",
|
|
60
|
-
"@types/node": "25.2.
|
|
60
|
+
"@types/node": "25.2.3",
|
|
61
61
|
"@vitest/coverage-v8": "4.0.18",
|
|
62
62
|
"amqp-connection-manager": "5.0.0",
|
|
63
63
|
"amqplib": "0.10.9",
|
|
64
64
|
"tsdown": "0.20.3",
|
|
65
65
|
"typedoc": "0.28.16",
|
|
66
|
-
"typedoc-plugin-markdown": "4.
|
|
66
|
+
"typedoc-plugin-markdown": "4.10.0",
|
|
67
67
|
"typescript": "5.9.3",
|
|
68
68
|
"vitest": "4.0.18",
|
|
69
69
|
"zod": "4.3.6",
|
|
70
|
-
"@amqp-contract/testing": "0.
|
|
70
|
+
"@amqp-contract/testing": "0.18.0",
|
|
71
71
|
"@amqp-contract/tsconfig": "0.1.0",
|
|
72
72
|
"@amqp-contract/typedoc": "0.1.0"
|
|
73
73
|
},
|