@amqp-contract/worker 0.8.0 → 0.10.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/dist/index.cjs +42 -16
- package/dist/index.d.cts +10 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +10 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +43 -17
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +52 -51
- package/package.json +4 -4
package/docs/index.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
### MessageValidationError
|
|
10
10
|
|
|
11
|
-
Defined in: [packages/worker/src/errors.ts:35](https://github.com/btravers/amqp-contract/blob/
|
|
11
|
+
Defined in: [packages/worker/src/errors.ts:35](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L35)
|
|
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:36](https://github.com/btravers/amqp-contract/blob/
|
|
27
|
+
Defined in: [packages/worker/src/errors.ts:36](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L36)
|
|
28
28
|
|
|
29
29
|
###### Parameters
|
|
30
30
|
|
|
@@ -48,8 +48,8 @@ WorkerError.constructor
|
|
|
48
48
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
49
49
|
| ------ | ------ | ------ | ------ | ------ | ------ |
|
|
50
50
|
| <a id="cause"></a> `cause?` | `public` | `unknown` | - | `WorkerError.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:37](https://github.com/btravers/amqp-contract/blob/
|
|
52
|
-
| <a id="issues"></a> `issues` | `readonly` | `unknown` | - | - | [packages/worker/src/errors.ts:38](https://github.com/btravers/amqp-contract/blob/
|
|
51
|
+
| <a id="consumername"></a> `consumerName` | `readonly` | `string` | - | - | [packages/worker/src/errors.ts:37](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L37) |
|
|
52
|
+
| <a id="issues"></a> `issues` | `readonly` | `unknown` | - | - | [packages/worker/src/errors.ts:38](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L38) |
|
|
53
53
|
| <a id="message"></a> `message` | `public` | `string` | - | `WorkerError.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` | - | `WorkerError.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` | - | `WorkerError.stack` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 |
|
|
@@ -159,7 +159,7 @@ WorkerError.prepareStackTrace
|
|
|
159
159
|
|
|
160
160
|
### NonRetryableError
|
|
161
161
|
|
|
162
|
-
Defined in: [packages/worker/src/errors.ts:69](https://github.com/btravers/amqp-contract/blob/
|
|
162
|
+
Defined in: [packages/worker/src/errors.ts:69](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L69)
|
|
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:70](https://github.com/btravers/amqp-contract/blob/
|
|
182
|
+
Defined in: [packages/worker/src/errors.ts:70](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L70)
|
|
183
183
|
|
|
184
184
|
###### Parameters
|
|
185
185
|
|
|
@@ -202,7 +202,7 @@ WorkerError.constructor
|
|
|
202
202
|
|
|
203
203
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
204
204
|
| ------ | ------ | ------ | ------ | ------ | ------ |
|
|
205
|
-
| <a id="cause-1"></a> `cause?` | `readonly` | `unknown` | - | `WorkerError.cause` | [packages/worker/src/errors.ts:72](https://github.com/btravers/amqp-contract/blob/
|
|
205
|
+
| <a id="cause-1"></a> `cause?` | `readonly` | `unknown` | - | `WorkerError.cause` | [packages/worker/src/errors.ts:72](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L72) |
|
|
206
206
|
| <a id="message-1"></a> `message` | `public` | `string` | - | `WorkerError.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` | - | `WorkerError.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` | - | `WorkerError.stack` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 |
|
|
@@ -312,7 +312,7 @@ WorkerError.prepareStackTrace
|
|
|
312
312
|
|
|
313
313
|
### RetryableError
|
|
314
314
|
|
|
315
|
-
Defined in: [packages/worker/src/errors.ts:52](https://github.com/btravers/amqp-contract/blob/
|
|
315
|
+
Defined in: [packages/worker/src/errors.ts:52](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L52)
|
|
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:53](https://github.com/btravers/amqp-contract/blob/
|
|
335
|
+
Defined in: [packages/worker/src/errors.ts:53](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L53)
|
|
336
336
|
|
|
337
337
|
###### Parameters
|
|
338
338
|
|
|
@@ -355,7 +355,7 @@ WorkerError.constructor
|
|
|
355
355
|
|
|
356
356
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
357
357
|
| ------ | ------ | ------ | ------ | ------ | ------ |
|
|
358
|
-
| <a id="cause-2"></a> `cause?` | `readonly` | `unknown` | - | `WorkerError.cause` | [packages/worker/src/errors.ts:55](https://github.com/btravers/amqp-contract/blob/
|
|
358
|
+
| <a id="cause-2"></a> `cause?` | `readonly` | `unknown` | - | `WorkerError.cause` | [packages/worker/src/errors.ts:55](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L55) |
|
|
359
359
|
| <a id="message-2"></a> `message` | `public` | `string` | - | `WorkerError.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` | - | `WorkerError.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` | - | `WorkerError.stack` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 |
|
|
@@ -465,7 +465,7 @@ WorkerError.prepareStackTrace
|
|
|
465
465
|
|
|
466
466
|
### TechnicalError
|
|
467
467
|
|
|
468
|
-
Defined in: [packages/worker/src/errors.ts:22](https://github.com/btravers/amqp-contract/blob/
|
|
468
|
+
Defined in: [packages/worker/src/errors.ts:22](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L22)
|
|
469
469
|
|
|
470
470
|
Error for technical/runtime failures in worker operations
|
|
471
471
|
This includes validation failures, parsing failures, and processing failures
|
|
@@ -482,7 +482,7 @@ This includes validation failures, parsing failures, and processing failures
|
|
|
482
482
|
new TechnicalError(message, cause?): TechnicalError;
|
|
483
483
|
```
|
|
484
484
|
|
|
485
|
-
Defined in: [packages/worker/src/errors.ts:23](https://github.com/btravers/amqp-contract/blob/
|
|
485
|
+
Defined in: [packages/worker/src/errors.ts:23](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L23)
|
|
486
486
|
|
|
487
487
|
###### Parameters
|
|
488
488
|
|
|
@@ -505,7 +505,7 @@ WorkerError.constructor
|
|
|
505
505
|
|
|
506
506
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
507
507
|
| ------ | ------ | ------ | ------ | ------ | ------ |
|
|
508
|
-
| <a id="cause-3"></a> `cause?` | `readonly` | `unknown` | - | `WorkerError.cause` | [packages/worker/src/errors.ts:25](https://github.com/btravers/amqp-contract/blob/
|
|
508
|
+
| <a id="cause-3"></a> `cause?` | `readonly` | `unknown` | - | `WorkerError.cause` | [packages/worker/src/errors.ts:25](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L25) |
|
|
509
509
|
| <a id="message-3"></a> `message` | `public` | `string` | - | `WorkerError.message` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 |
|
|
510
510
|
| <a id="name-3"></a> `name` | `public` | `string` | - | `WorkerError.name` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
|
|
511
511
|
| <a id="stack-3"></a> `stack?` | `public` | `string` | - | `WorkerError.stack` | node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 |
|
|
@@ -615,7 +615,7 @@ WorkerError.prepareStackTrace
|
|
|
615
615
|
|
|
616
616
|
### TypedAmqpWorker
|
|
617
617
|
|
|
618
|
-
Defined in: [packages/worker/src/worker.ts:
|
|
618
|
+
Defined in: [packages/worker/src/worker.ts:190](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L190)
|
|
619
619
|
|
|
620
620
|
Type-safe AMQP worker for consuming messages from RabbitMQ.
|
|
621
621
|
|
|
@@ -669,7 +669,7 @@ await worker.close().resultToPromise();
|
|
|
669
669
|
close(): Future<Result<void, TechnicalError>>;
|
|
670
670
|
```
|
|
671
671
|
|
|
672
|
-
Defined in: [packages/worker/src/worker.ts:
|
|
672
|
+
Defined in: [packages/worker/src/worker.ts:327](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L327)
|
|
673
673
|
|
|
674
674
|
Close the AMQP channel and connection.
|
|
675
675
|
|
|
@@ -697,7 +697,7 @@ if (closeResult.isOk()) {
|
|
|
697
697
|
static create<TContract>(options): Future<Result<TypedAmqpWorker<TContract>, TechnicalError>>;
|
|
698
698
|
```
|
|
699
699
|
|
|
700
|
-
Defined in: [packages/worker/src/worker.ts:
|
|
700
|
+
Defined in: [packages/worker/src/worker.ts:283](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L283)
|
|
701
701
|
|
|
702
702
|
Create a type-safe AMQP worker from a contract.
|
|
703
703
|
|
|
@@ -747,7 +747,7 @@ const worker = await TypedAmqpWorker.create({
|
|
|
747
747
|
type CreateWorkerOptions<TContract> = object;
|
|
748
748
|
```
|
|
749
749
|
|
|
750
|
-
Defined in: [packages/worker/src/worker.ts:
|
|
750
|
+
Defined in: [packages/worker/src/worker.ts:124](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L124)
|
|
751
751
|
|
|
752
752
|
Options for creating a type-safe AMQP worker.
|
|
753
753
|
|
|
@@ -801,12 +801,13 @@ const options: CreateWorkerOptions<typeof contract> = {
|
|
|
801
801
|
|
|
802
802
|
| Property | Type | Description | Defined in |
|
|
803
803
|
| ------ | ------ | ------ | ------ |
|
|
804
|
-
| <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.) | [packages/worker/src/worker.ts:
|
|
805
|
-
| <a id="contract"></a> `contract` | `TContract` | The AMQP contract definition specifying consumers and their message schemas | [packages/worker/src/worker.ts:
|
|
806
|
-
| <a id="handlers"></a> `handlers` | [`WorkerInferSafeConsumerHandlers`](#workerinfersafeconsumerhandlers)\<`TContract`\> | Handlers for each consumer defined in the contract. Handlers must return `Future<Result<void, HandlerError>>` for explicit error handling. Use defineHandler() to create safe handlers, or defineUnsafeHandler() which wraps Promise-based handlers into safe handlers internally. | [packages/worker/src/worker.ts:
|
|
807
|
-
| <a id="logger"></a> `logger?` | `Logger` | Optional logger for logging message consumption and errors | [packages/worker/src/worker.ts:
|
|
808
|
-
| <a id="retry"></a> `retry?` | [`RetryOptions`](#retryoptions) | Retry configuration - when undefined, uses legacy behavior (immediate requeue) | [packages/worker/src/worker.ts:
|
|
809
|
-
| <a id="
|
|
804
|
+
| <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.) | [packages/worker/src/worker.ts:137](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L137) |
|
|
805
|
+
| <a id="contract"></a> `contract` | `TContract` | The AMQP contract definition specifying consumers and their message schemas | [packages/worker/src/worker.ts:126](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L126) |
|
|
806
|
+
| <a id="handlers"></a> `handlers` | [`WorkerInferSafeConsumerHandlers`](#workerinfersafeconsumerhandlers)\<`TContract`\> | Handlers for each consumer defined in the contract. Handlers must return `Future<Result<void, HandlerError>>` for explicit error handling. Use defineHandler() to create safe handlers, or defineUnsafeHandler() which wraps Promise-based handlers into safe handlers internally. | [packages/worker/src/worker.ts:133](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L133) |
|
|
807
|
+
| <a id="logger"></a> `logger?` | `Logger` | Optional logger for logging message consumption and errors | [packages/worker/src/worker.ts:139](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L139) |
|
|
808
|
+
| <a id="retry"></a> `retry?` | [`RetryOptions`](#retryoptions) | Retry configuration - when undefined, uses legacy behavior (immediate requeue) | [packages/worker/src/worker.ts:141](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L141) |
|
|
809
|
+
| <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:147](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L147) |
|
|
810
|
+
| <a id="urls"></a> `urls` | `ConnectionUrl`[] | AMQP broker URL(s). Multiple URLs provide failover support | [packages/worker/src/worker.ts:135](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L135) |
|
|
810
811
|
|
|
811
812
|
***
|
|
812
813
|
|
|
@@ -818,7 +819,7 @@ type HandlerError =
|
|
|
818
819
|
| NonRetryableError;
|
|
819
820
|
```
|
|
820
821
|
|
|
821
|
-
Defined in: [packages/worker/src/errors.ts:83](https://github.com/btravers/amqp-contract/blob/
|
|
822
|
+
Defined in: [packages/worker/src/errors.ts:83](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/errors.ts#L83)
|
|
822
823
|
|
|
823
824
|
Union type representing all handler errors.
|
|
824
825
|
Use this type when defining handlers that explicitly signal error outcomes.
|
|
@@ -831,7 +832,7 @@ Use this type when defining handlers that explicitly signal error outcomes.
|
|
|
831
832
|
type RetryOptions = object;
|
|
832
833
|
```
|
|
833
834
|
|
|
834
|
-
Defined in: [packages/worker/src/worker.ts:
|
|
835
|
+
Defined in: [packages/worker/src/worker.ts:56](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L56)
|
|
835
836
|
|
|
836
837
|
Retry configuration options for handling failed message processing.
|
|
837
838
|
|
|
@@ -842,11 +843,11 @@ RabbitMQ's native TTL + Dead Letter Exchange (DLX) pattern.
|
|
|
842
843
|
|
|
843
844
|
| Property | Type | Description | Defined in |
|
|
844
845
|
| ------ | ------ | ------ | ------ |
|
|
845
|
-
| <a id="backoffmultiplier"></a> `backoffMultiplier?` | `number` | Exponential backoff multiplier (default: 2) | [packages/worker/src/worker.ts:
|
|
846
|
-
| <a id="initialdelayms"></a> `initialDelayMs?` | `number` | Initial delay in ms before first retry (default: 1000) | [packages/worker/src/worker.ts:
|
|
847
|
-
| <a id="jitter"></a> `jitter?` | `boolean` | Add jitter to prevent thundering herd (default: true) | [packages/worker/src/worker.ts:
|
|
848
|
-
| <a id="maxdelayms"></a> `maxDelayMs?` | `number` | Maximum delay in ms between retries (default: 30000) | [packages/worker/src/worker.ts:
|
|
849
|
-
| <a id="maxretries"></a> `maxRetries?` | `number` | Maximum retry attempts before sending to DLQ (default: 3) | [packages/worker/src/worker.ts:
|
|
846
|
+
| <a id="backoffmultiplier"></a> `backoffMultiplier?` | `number` | Exponential backoff multiplier (default: 2) | [packages/worker/src/worker.ts:64](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L64) |
|
|
847
|
+
| <a id="initialdelayms"></a> `initialDelayMs?` | `number` | Initial delay in ms before first retry (default: 1000) | [packages/worker/src/worker.ts:60](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L60) |
|
|
848
|
+
| <a id="jitter"></a> `jitter?` | `boolean` | Add jitter to prevent thundering herd (default: true) | [packages/worker/src/worker.ts:66](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L66) |
|
|
849
|
+
| <a id="maxdelayms"></a> `maxDelayMs?` | `number` | Maximum delay in ms between retries (default: 30000) | [packages/worker/src/worker.ts:62](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L62) |
|
|
850
|
+
| <a id="maxretries"></a> `maxRetries?` | `number` | Maximum retry attempts before sending to DLQ (default: 3) | [packages/worker/src/worker.ts:58](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/worker.ts#L58) |
|
|
850
851
|
|
|
851
852
|
***
|
|
852
853
|
|
|
@@ -856,7 +857,7 @@ RabbitMQ's native TTL + Dead Letter Exchange (DLX) pattern.
|
|
|
856
857
|
type WorkerInferConsumerBatchHandler<TContract, TName> = WorkerInferUnsafeConsumerBatchHandler<TContract, TName>;
|
|
857
858
|
```
|
|
858
859
|
|
|
859
|
-
Defined in: [packages/worker/src/types.ts:195](https://github.com/btravers/amqp-contract/blob/
|
|
860
|
+
Defined in: [packages/worker/src/types.ts:195](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L195)
|
|
860
861
|
|
|
861
862
|
#### Type Parameters
|
|
862
863
|
|
|
@@ -877,7 +878,7 @@ Use WorkerInferUnsafeConsumerBatchHandler instead
|
|
|
877
878
|
type WorkerInferConsumerHandler<TContract, TName> = WorkerInferUnsafeConsumerHandler<TContract, TName>;
|
|
878
879
|
```
|
|
879
880
|
|
|
880
|
-
Defined in: [packages/worker/src/types.ts:187](https://github.com/btravers/amqp-contract/blob/
|
|
881
|
+
Defined in: [packages/worker/src/types.ts:187](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L187)
|
|
881
882
|
|
|
882
883
|
#### Type Parameters
|
|
883
884
|
|
|
@@ -898,7 +899,7 @@ Use WorkerInferUnsafeConsumerHandler instead
|
|
|
898
899
|
type WorkerInferConsumerHandlerEntry<TContract, TName> = WorkerInferUnsafeConsumerHandlerEntry<TContract, TName>;
|
|
899
900
|
```
|
|
900
901
|
|
|
901
|
-
Defined in: [packages/worker/src/types.ts:203](https://github.com/btravers/amqp-contract/blob/
|
|
902
|
+
Defined in: [packages/worker/src/types.ts:203](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L203)
|
|
902
903
|
|
|
903
904
|
#### Type Parameters
|
|
904
905
|
|
|
@@ -919,7 +920,7 @@ Use WorkerInferUnsafeConsumerHandlerEntry instead
|
|
|
919
920
|
type WorkerInferConsumerHandlers<TContract> = WorkerInferUnsafeConsumerHandlers<TContract>;
|
|
920
921
|
```
|
|
921
922
|
|
|
922
|
-
Defined in: [packages/worker/src/types.ts:211](https://github.com/btravers/amqp-contract/blob/
|
|
923
|
+
Defined in: [packages/worker/src/types.ts:211](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L211)
|
|
923
924
|
|
|
924
925
|
#### Type Parameters
|
|
925
926
|
|
|
@@ -939,7 +940,7 @@ Use WorkerInferUnsafeConsumerHandlers instead
|
|
|
939
940
|
type WorkerInferConsumerInput<TContract, TName> = ConsumerInferInput<InferConsumer<TContract, TName>>;
|
|
940
941
|
```
|
|
941
942
|
|
|
942
|
-
Defined in: [packages/worker/src/types.ts:39](https://github.com/btravers/amqp-contract/blob/
|
|
943
|
+
Defined in: [packages/worker/src/types.ts:39](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L39)
|
|
943
944
|
|
|
944
945
|
Worker perspective types - for consuming messages
|
|
945
946
|
|
|
@@ -958,7 +959,7 @@ Worker perspective types - for consuming messages
|
|
|
958
959
|
type WorkerInferSafeConsumerBatchHandler<TContract, TName> = (messages) => Future<Result<void, HandlerError>>;
|
|
959
960
|
```
|
|
960
961
|
|
|
961
|
-
Defined in: [packages/worker/src/types.ts:80](https://github.com/btravers/amqp-contract/blob/
|
|
962
|
+
Defined in: [packages/worker/src/types.ts:80](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L80)
|
|
962
963
|
|
|
963
964
|
Safe consumer handler type for batch processing.
|
|
964
965
|
Returns a `Future<Result<void, HandlerError>>` for explicit error handling.
|
|
@@ -995,7 +996,7 @@ const handler: WorkerInferSafeConsumerBatchHandler<typeof contract, 'processOrde
|
|
|
995
996
|
type WorkerInferSafeConsumerHandler<TContract, TName> = (message) => Future<Result<void, HandlerError>>;
|
|
996
997
|
```
|
|
997
998
|
|
|
998
|
-
Defined in: [packages/worker/src/types.ts:65](https://github.com/btravers/amqp-contract/blob/
|
|
999
|
+
Defined in: [packages/worker/src/types.ts:65](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L65)
|
|
999
1000
|
|
|
1000
1001
|
Safe consumer handler type for a specific consumer.
|
|
1001
1002
|
Returns a `Future<Result<void, HandlerError>>` for explicit error handling.
|
|
@@ -1047,7 +1048,7 @@ type WorkerInferSafeConsumerHandlerEntry<TContract, TName> =
|
|
|
1047
1048
|
}];
|
|
1048
1049
|
```
|
|
1049
1050
|
|
|
1050
|
-
Defined in: [packages/worker/src/types.ts:95](https://github.com/btravers/amqp-contract/blob/
|
|
1051
|
+
Defined in: [packages/worker/src/types.ts:95](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L95)
|
|
1051
1052
|
|
|
1052
1053
|
Safe handler entry for a consumer - either a function or a tuple of [handler, options].
|
|
1053
1054
|
|
|
@@ -1071,7 +1072,7 @@ Three patterns are supported:
|
|
|
1071
1072
|
type WorkerInferSafeConsumerHandlers<TContract> = { [K in InferConsumerNames<TContract>]: WorkerInferSafeConsumerHandlerEntry<TContract, K> };
|
|
1072
1073
|
```
|
|
1073
1074
|
|
|
1074
|
-
Defined in: [packages/worker/src/types.ts:113](https://github.com/btravers/amqp-contract/blob/
|
|
1075
|
+
Defined in: [packages/worker/src/types.ts:113](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L113)
|
|
1075
1076
|
|
|
1076
1077
|
Safe consumer handlers for a contract.
|
|
1077
1078
|
All handlers return `Future<Result<void, HandlerError>>` for explicit error control.
|
|
@@ -1090,7 +1091,7 @@ All handlers return `Future<Result<void, HandlerError>>` for explicit error cont
|
|
|
1090
1091
|
type WorkerInferUnsafeConsumerBatchHandler<TContract, TName> = (messages) => Promise<void>;
|
|
1091
1092
|
```
|
|
1092
1093
|
|
|
1093
|
-
Defined in: [packages/worker/src/types.ts:147](https://github.com/btravers/amqp-contract/blob/
|
|
1094
|
+
Defined in: [packages/worker/src/types.ts:147](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L147)
|
|
1094
1095
|
|
|
1095
1096
|
Unsafe consumer handler type for batch processing.
|
|
1096
1097
|
Returns a `Promise<void>` - throws exceptions on error.
|
|
@@ -1125,7 +1126,7 @@ Prefer using safe handlers (WorkerInferSafeConsumerBatchHandler) that return
|
|
|
1125
1126
|
type WorkerInferUnsafeConsumerHandler<TContract, TName> = (message) => Promise<void>;
|
|
1126
1127
|
```
|
|
1127
1128
|
|
|
1128
|
-
Defined in: [packages/worker/src/types.ts:135](https://github.com/btravers/amqp-contract/blob/
|
|
1129
|
+
Defined in: [packages/worker/src/types.ts:135](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L135)
|
|
1129
1130
|
|
|
1130
1131
|
Unsafe consumer handler type for a specific consumer.
|
|
1131
1132
|
Returns a `Promise<void>` - throws exceptions on error.
|
|
@@ -1175,7 +1176,7 @@ type WorkerInferUnsafeConsumerHandlerEntry<TContract, TName> =
|
|
|
1175
1176
|
}];
|
|
1176
1177
|
```
|
|
1177
1178
|
|
|
1178
|
-
Defined in: [packages/worker/src/types.ts:157](https://github.com/btravers/amqp-contract/blob/
|
|
1179
|
+
Defined in: [packages/worker/src/types.ts:157](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L157)
|
|
1179
1180
|
|
|
1180
1181
|
Unsafe handler entry for a consumer - either a function or a tuple of [handler, options].
|
|
1181
1182
|
|
|
@@ -1198,7 +1199,7 @@ Prefer using safe handler entries (WorkerInferSafeConsumerHandlerEntry).
|
|
|
1198
1199
|
type WorkerInferUnsafeConsumerHandlers<TContract> = { [K in InferConsumerNames<TContract>]: WorkerInferUnsafeConsumerHandlerEntry<TContract, K> };
|
|
1199
1200
|
```
|
|
1200
1201
|
|
|
1201
|
-
Defined in: [packages/worker/src/types.ts:176](https://github.com/btravers/amqp-contract/blob/
|
|
1202
|
+
Defined in: [packages/worker/src/types.ts:176](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/types.ts#L176)
|
|
1202
1203
|
|
|
1203
1204
|
Unsafe consumer handlers for a contract.
|
|
1204
1205
|
|
|
@@ -1225,7 +1226,7 @@ function defineHandler<TContract, TName>(
|
|
|
1225
1226
|
handler): WorkerInferSafeConsumerHandlerEntry<TContract, TName>;
|
|
1226
1227
|
```
|
|
1227
1228
|
|
|
1228
|
-
Defined in: [packages/worker/src/handlers.ts:134](https://github.com/btravers/amqp-contract/blob/
|
|
1229
|
+
Defined in: [packages/worker/src/handlers.ts:134](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/handlers.ts#L134)
|
|
1229
1230
|
|
|
1230
1231
|
Define a type-safe handler for a specific consumer in a contract.
|
|
1231
1232
|
|
|
@@ -1299,7 +1300,7 @@ function defineHandler<TContract, TName>(
|
|
|
1299
1300
|
options): WorkerInferSafeConsumerHandlerEntry<TContract, TName>;
|
|
1300
1301
|
```
|
|
1301
1302
|
|
|
1302
|
-
Defined in: [packages/worker/src/handlers.ts:142](https://github.com/btravers/amqp-contract/blob/
|
|
1303
|
+
Defined in: [packages/worker/src/handlers.ts:142](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/handlers.ts#L142)
|
|
1303
1304
|
|
|
1304
1305
|
Define a type-safe handler for a specific consumer in a contract.
|
|
1305
1306
|
|
|
@@ -1377,7 +1378,7 @@ function defineHandler<TContract, TName>(
|
|
|
1377
1378
|
options): WorkerInferSafeConsumerHandlerEntry<TContract, TName>;
|
|
1378
1379
|
```
|
|
1379
1380
|
|
|
1380
|
-
Defined in: [packages/worker/src/handlers.ts:151](https://github.com/btravers/amqp-contract/blob/
|
|
1381
|
+
Defined in: [packages/worker/src/handlers.ts:151](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/handlers.ts#L151)
|
|
1381
1382
|
|
|
1382
1383
|
Define a type-safe handler for a specific consumer in a contract.
|
|
1383
1384
|
|
|
@@ -1453,7 +1454,7 @@ const validateOrderHandler = defineHandler(
|
|
|
1453
1454
|
function defineHandlers<TContract>(contract, handlers): WorkerInferSafeConsumerHandlers<TContract>;
|
|
1454
1455
|
```
|
|
1455
1456
|
|
|
1456
|
-
Defined in: [packages/worker/src/handlers.ts:208](https://github.com/btravers/amqp-contract/blob/
|
|
1457
|
+
Defined in: [packages/worker/src/handlers.ts:208](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/handlers.ts#L208)
|
|
1457
1458
|
|
|
1458
1459
|
Define multiple type-safe handlers for consumers in a contract.
|
|
1459
1460
|
|
|
@@ -1511,7 +1512,7 @@ function defineUnsafeHandler<TContract, TName>(
|
|
|
1511
1512
|
handler): WorkerInferSafeConsumerHandlerEntry<TContract, TName>;
|
|
1512
1513
|
```
|
|
1513
1514
|
|
|
1514
|
-
Defined in: [packages/worker/src/handlers.ts:272](https://github.com/btravers/amqp-contract/blob/
|
|
1515
|
+
Defined in: [packages/worker/src/handlers.ts:272](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/handlers.ts#L272)
|
|
1515
1516
|
|
|
1516
1517
|
Define an unsafe handler for a specific consumer in a contract.
|
|
1517
1518
|
|
|
@@ -1574,7 +1575,7 @@ function defineUnsafeHandler<TContract, TName>(
|
|
|
1574
1575
|
options): WorkerInferSafeConsumerHandlerEntry<TContract, TName>;
|
|
1575
1576
|
```
|
|
1576
1577
|
|
|
1577
|
-
Defined in: [packages/worker/src/handlers.ts:280](https://github.com/btravers/amqp-contract/blob/
|
|
1578
|
+
Defined in: [packages/worker/src/handlers.ts:280](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/handlers.ts#L280)
|
|
1578
1579
|
|
|
1579
1580
|
Define an unsafe handler for a specific consumer in a contract.
|
|
1580
1581
|
|
|
@@ -1641,7 +1642,7 @@ function defineUnsafeHandler<TContract, TName>(
|
|
|
1641
1642
|
options): WorkerInferSafeConsumerHandlerEntry<TContract, TName>;
|
|
1642
1643
|
```
|
|
1643
1644
|
|
|
1644
|
-
Defined in: [packages/worker/src/handlers.ts:289](https://github.com/btravers/amqp-contract/blob/
|
|
1645
|
+
Defined in: [packages/worker/src/handlers.ts:289](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/handlers.ts#L289)
|
|
1645
1646
|
|
|
1646
1647
|
Define an unsafe handler for a specific consumer in a contract.
|
|
1647
1648
|
|
|
@@ -1706,7 +1707,7 @@ const processOrderHandler = defineUnsafeHandler(
|
|
|
1706
1707
|
function defineUnsafeHandlers<TContract>(contract, handlers): WorkerInferSafeConsumerHandlers<TContract>;
|
|
1707
1708
|
```
|
|
1708
1709
|
|
|
1709
|
-
Defined in: [packages/worker/src/handlers.ts:373](https://github.com/btravers/amqp-contract/blob/
|
|
1710
|
+
Defined in: [packages/worker/src/handlers.ts:373](https://github.com/btravers/amqp-contract/blob/00468eb63a019d6161c43f07dab8b68232bbb383/packages/worker/src/handlers.ts#L373)
|
|
1710
1711
|
|
|
1711
1712
|
Define multiple unsafe handlers for consumers in a contract.
|
|
1712
1713
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amqp-contract/worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Worker utilities for consuming messages using amqp-contract",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"amqp",
|
|
@@ -52,8 +52,8 @@
|
|
|
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.10.0",
|
|
56
|
+
"@amqp-contract/core": "0.10.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/amqplib": "0.10.8",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"typescript": "5.9.3",
|
|
68
68
|
"vitest": "4.0.16",
|
|
69
69
|
"zod": "4.3.5",
|
|
70
|
-
"@amqp-contract/testing": "0.
|
|
70
|
+
"@amqp-contract/testing": "0.10.0",
|
|
71
71
|
"@amqp-contract/tsconfig": "0.1.0",
|
|
72
72
|
"@amqp-contract/typedoc": "0.1.0"
|
|
73
73
|
},
|