@amqp-contract/worker 0.25.0 → 2.0.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 CHANGED
@@ -6,184 +6,36 @@
6
6
 
7
7
  ## Classes
8
8
 
9
- ### `abstract` HandlerError
10
-
11
- Defined in: [packages/worker/src/errors.ts:10](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L10)
12
-
13
- Abstract base class for all handler-signalled errors.
14
-
15
- Concrete subclasses (`RetryableError`, `NonRetryableError`) discriminate on
16
- the `name` property so exhaustive narrowing in user code keeps working.
17
- `error instanceof HandlerError` is true for any handler error.
18
-
19
- #### Extends
20
-
21
- - `Error`
22
-
23
- #### Extended by
24
-
25
- - [`NonRetryableError`](#nonretryableerror)
26
- - [`RetryableError`](#retryableerror)
27
-
28
- #### Constructors
29
-
30
- ##### Constructor
31
-
32
- ```ts
33
- new HandlerError(message, cause?): HandlerError;
34
- ```
35
-
36
- Defined in: [packages/worker/src/errors.ts:13](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L13)
37
-
38
- ###### Parameters
39
-
40
- | Parameter | Type |
41
- | ------ | ------ |
42
- | `message` | `string` |
43
- | `cause?` | `unknown` |
44
-
45
- ###### Returns
46
-
47
- [`HandlerError`](#abstract-handlererror)
48
-
49
- ###### Overrides
50
-
51
- ```ts
52
- Error.constructor
53
- ```
54
-
55
- #### Properties
56
-
57
- | Property | Modifier | Type | Description | Overrides | Inherited from | Defined in |
58
- | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
59
- | <a id="cause"></a> `cause?` | `readonly` | `unknown` | - | - | `Error.cause` | [packages/worker/src/errors.ts:15](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L15) |
60
- | <a id="message"></a> `message` | `public` | `string` | - | - | `Error.message` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
61
- | <a id="name"></a> `name` | `abstract` | `"RetryableError"` \| `"NonRetryableError"` | - | `Error.name` | - | [packages/worker/src/errors.ts:11](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L11) |
62
- | <a id="stack"></a> `stack?` | `public` | `string` | - | - | `Error.stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
63
- | <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@24.12.2/node\_modules/@types/node/globals.d.ts:68 |
64
-
65
- #### Methods
66
-
67
- ##### captureStackTrace()
68
-
69
- ```ts
70
- static captureStackTrace(targetObject, constructorOpt?): void;
71
- ```
72
-
73
- Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:52
74
-
75
- Creates a `.stack` property on `targetObject`, which when accessed returns
76
- a string representing the location in the code at which
77
- `Error.captureStackTrace()` was called.
78
-
79
- ```js
80
- const myObject = {};
81
- Error.captureStackTrace(myObject);
82
- myObject.stack; // Similar to `new Error().stack`
83
- ```
84
-
85
- The first line of the trace will be prefixed with
86
- `${myObject.name}: ${myObject.message}`.
87
-
88
- The optional `constructorOpt` argument accepts a function. If given, all frames
89
- above `constructorOpt`, including `constructorOpt`, will be omitted from the
90
- generated stack trace.
91
-
92
- The `constructorOpt` argument is useful for hiding implementation
93
- details of error generation from the user. For instance:
94
-
95
- ```js
96
- function a() {
97
- b();
98
- }
99
-
100
- function b() {
101
- c();
102
- }
103
-
104
- function c() {
105
- // Create an error without stack trace to avoid calculating the stack trace twice.
106
- const { stackTraceLimit } = Error;
107
- Error.stackTraceLimit = 0;
108
- const error = new Error();
109
- Error.stackTraceLimit = stackTraceLimit;
110
-
111
- // Capture the stack trace above function b
112
- Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
113
- throw error;
114
- }
115
-
116
- a();
117
- ```
118
-
119
- ###### Parameters
120
-
121
- | Parameter | Type |
122
- | ------ | ------ |
123
- | `targetObject` | `object` |
124
- | `constructorOpt?` | `Function` |
125
-
126
- ###### Returns
127
-
128
- `void`
129
-
130
- ###### Inherited from
131
-
132
- ```ts
133
- Error.captureStackTrace
134
- ```
135
-
136
- ##### prepareStackTrace()
137
-
138
- ```ts
139
- static prepareStackTrace(err, stackTraces): any;
140
- ```
141
-
142
- Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:56
143
-
144
- ###### Parameters
145
-
146
- | Parameter | Type |
147
- | ------ | ------ |
148
- | `err` | `Error` |
149
- | `stackTraces` | `CallSite`[] |
150
-
151
- ###### Returns
152
-
153
- `any`
154
-
155
- ###### See
156
-
157
- https://v8.dev/docs/stack-trace-api#customizing-stack-traces
158
-
159
- ###### Inherited from
160
-
161
- ```ts
162
- Error.prepareStackTrace
163
- ```
164
-
165
- ***
166
-
167
9
  ### MessageValidationError
168
10
 
169
- Defined in: packages/core/dist/index.d.mts:27
11
+ Defined in: packages/core/dist/index.d.mts:40
170
12
 
171
13
  Error thrown when message validation fails (payload or headers).
172
14
 
173
15
  Used by both the client (publish-time payload validation) and the worker
174
- (consume-time payload and headers validation).
16
+ (consume-time payload and headers validation). Carries a `_tag` of
17
+ `"@amqp-contract/MessageValidationError"` (namespaced to avoid collisions);
18
+ the `Error.name` is kept bare (`"MessageValidationError"`).
175
19
 
176
20
  #### Param
177
21
 
22
+ **source**
23
+
178
24
  The name of the publisher or consumer that triggered the validation
179
25
 
180
26
  #### Param
181
27
 
28
+ **issues**
29
+
182
30
  The validation issues from the Standard Schema validation
183
31
 
184
32
  #### Extends
185
33
 
186
- - `Error`
34
+ - `MessageValidationError_base`&lt;\{
35
+ `issues`: `unknown`;
36
+ `message`: `string`;
37
+ `source`: `string`;
38
+ \}&gt;
187
39
 
188
40
  #### Constructors
189
41
 
@@ -193,7 +45,7 @@ The validation issues from the Standard Schema validation
193
45
  new MessageValidationError(source, issues): MessageValidationError;
194
46
  ```
195
47
 
196
- Defined in: packages/core/dist/index.d.mts:30
48
+ Defined in: packages/core/dist/index.d.mts:45
197
49
 
198
50
  ###### Parameters
199
51
 
@@ -209,136 +61,45 @@ Defined in: packages/core/dist/index.d.mts:30
209
61
  ###### Overrides
210
62
 
211
63
  ```ts
212
- Error.constructor
64
+ MessageValidationError_base<{
65
+ message: string;
66
+ source: string;
67
+ issues: unknown;
68
+ }>.constructor
213
69
  ```
214
70
 
215
71
  #### Properties
216
72
 
217
- | Property | Modifier | Type | Description | Inherited from | Defined in |
218
- | ------ | ------ | ------ | ------ | ------ | ------ |
219
- | <a id="cause-1"></a> `cause?` | `public` | `unknown` | - | `Error.cause` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
220
- | <a id="issues"></a> `issues` | `readonly` | `unknown` | - | - | packages/core/dist/index.d.mts:29 |
221
- | <a id="message-1"></a> `message` | `public` | `string` | - | `Error.message` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
222
- | <a id="name-1"></a> `name` | `public` | `string` | - | `Error.name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
223
- | <a id="source"></a> `source` | `readonly` | `string` | - | - | packages/core/dist/index.d.mts:28 |
224
- | <a id="stack-1"></a> `stack?` | `public` | `string` | - | `Error.stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
225
- | <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@24.12.2/node\_modules/@types/node/globals.d.ts:68 |
226
-
227
- #### Methods
228
-
229
- ##### captureStackTrace()
230
-
231
- ```ts
232
- static captureStackTrace(targetObject, constructorOpt?): void;
233
- ```
234
-
235
- Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:52
236
-
237
- Creates a `.stack` property on `targetObject`, which when accessed returns
238
- a string representing the location in the code at which
239
- `Error.captureStackTrace()` was called.
240
-
241
- ```js
242
- const myObject = {};
243
- Error.captureStackTrace(myObject);
244
- myObject.stack; // Similar to `new Error().stack`
245
- ```
246
-
247
- The first line of the trace will be prefixed with
248
- `${myObject.name}: ${myObject.message}`.
249
-
250
- The optional `constructorOpt` argument accepts a function. If given, all frames
251
- above `constructorOpt`, including `constructorOpt`, will be omitted from the
252
- generated stack trace.
253
-
254
- The `constructorOpt` argument is useful for hiding implementation
255
- details of error generation from the user. For instance:
256
-
257
- ```js
258
- function a() {
259
- b();
260
- }
261
-
262
- function b() {
263
- c();
264
- }
265
-
266
- function c() {
267
- // Create an error without stack trace to avoid calculating the stack trace twice.
268
- const { stackTraceLimit } = Error;
269
- Error.stackTraceLimit = 0;
270
- const error = new Error();
271
- Error.stackTraceLimit = stackTraceLimit;
272
-
273
- // Capture the stack trace above function b
274
- Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
275
- throw error;
276
- }
277
-
278
- a();
279
- ```
280
-
281
- ###### Parameters
282
-
283
- | Parameter | Type |
284
- | ------ | ------ |
285
- | `targetObject` | `object` |
286
- | `constructorOpt?` | `Function` |
287
-
288
- ###### Returns
289
-
290
- `void`
291
-
292
- ###### Inherited from
293
-
294
- ```ts
295
- Error.captureStackTrace
296
- ```
297
-
298
- ##### prepareStackTrace()
299
-
300
- ```ts
301
- static prepareStackTrace(err, stackTraces): any;
302
- ```
303
-
304
- Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:56
305
-
306
- ###### Parameters
307
-
308
- | Parameter | Type |
309
- | ------ | ------ |
310
- | `err` | `Error` |
311
- | `stackTraces` | `CallSite`[] |
312
-
313
- ###### Returns
314
-
315
- `any`
316
-
317
- ###### See
318
-
319
- https://v8.dev/docs/stack-trace-api#customizing-stack-traces
320
-
321
- ###### Inherited from
322
-
323
- ```ts
324
- Error.prepareStackTrace
325
- ```
73
+ | Property | Modifier | Type | Inherited from | Defined in |
74
+ | ------ | ------ | ------ | ------ | ------ |
75
+ | <a id="_tag"></a> `_tag` | `readonly` | `"@amqp-contract/MessageValidationError"` | `MessageValidationError_base._tag` | node\_modules/.pnpm/unthrown@1.0.0/node\_modules/unthrown/dist/index.d.mts:778 |
76
+ | <a id="cause"></a> `cause?` | `public` | `unknown` | `MessageValidationError_base.cause` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
77
+ | <a id="issues"></a> `issues` | `readonly` | `unknown` | `MessageValidationError_base.issues` | packages/core/dist/index.d.mts:43 |
78
+ | <a id="message"></a> `message` | `public` | `string` | `MessageValidationError_base.message` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
79
+ | <a id="name"></a> `name` | `public` | `string` | `MessageValidationError_base.name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
80
+ | <a id="source"></a> `source` | `readonly` | `string` | `MessageValidationError_base.source` | packages/core/dist/index.d.mts:42 |
81
+ | <a id="stack"></a> `stack?` | `public` | `string` | `MessageValidationError_base.stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
326
82
 
327
83
  ***
328
84
 
329
85
  ### NonRetryableError
330
86
 
331
- Defined in: [packages/worker/src/errors.ts:46](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L46)
87
+ Defined in: [packages/worker/src/errors.ts:37](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/errors.ts#L37)
332
88
 
333
89
  Non-retryable errors - permanent failures that should not be retried
334
90
  Examples: invalid data, business rule violations, permanent external failures
335
91
 
336
92
  Use this error type when retrying would not help - the message will be
337
- immediately sent to the dead letter queue (DLQ) if configured.
93
+ immediately sent to the dead letter queue (DLQ) if configured. Carries a
94
+ namespaced `_tag` of `"@amqp-contract/NonRetryableError"`; the `Error.name` is
95
+ kept bare (`"NonRetryableError"`).
338
96
 
339
97
  #### Extends
340
98
 
341
- - [`HandlerError`](#abstract-handlererror)
99
+ - `TaggedErrorInstance`&lt;`"@amqp-contract/NonRetryableError"`, \{
100
+ `cause?`: `unknown`;
101
+ `message`: `string`;
102
+ \}&gt;
342
103
 
343
104
  #### Constructors
344
105
 
@@ -348,7 +109,7 @@ immediately sent to the dead letter queue (DLQ) if configured.
348
109
  new NonRetryableError(message, cause?): NonRetryableError;
349
110
  ```
350
111
 
351
- Defined in: [packages/worker/src/errors.ts:13](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L13)
112
+ Defined in: [packages/worker/src/errors.ts:43](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/errors.ts#L43)
352
113
 
353
114
  ###### Parameters
354
115
 
@@ -361,121 +122,32 @@ Defined in: [packages/worker/src/errors.ts:13](https://github.com/btravers/amqp-
361
122
 
362
123
  [`NonRetryableError`](#nonretryableerror)
363
124
 
364
- ###### Inherited from
365
-
366
- [`HandlerError`](#abstract-handlererror).[`constructor`](#constructor)
367
-
368
- #### Properties
369
-
370
- | Property | Modifier | Type | Description | Overrides | Inherited from | Defined in |
371
- | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
372
- | <a id="cause-2"></a> `cause?` | `readonly` | `unknown` | - | - | [`HandlerError`](#abstract-handlererror).[`cause`](#cause) | [packages/worker/src/errors.ts:15](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L15) |
373
- | <a id="message-2"></a> `message` | `public` | `string` | - | - | [`HandlerError`](#abstract-handlererror).[`message`](#message) | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
374
- | <a id="name-2"></a> `name` | `readonly` | `"NonRetryableError"` | - | [`HandlerError`](#abstract-handlererror).[`name`](#name) | - | [packages/worker/src/errors.ts:47](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L47) |
375
- | <a id="stack-2"></a> `stack?` | `public` | `string` | - | - | [`HandlerError`](#abstract-handlererror).[`stack`](#stack) | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
376
- | <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. | - | [`HandlerError`](#abstract-handlererror).[`stackTraceLimit`](#stacktracelimit) | node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:68 |
377
-
378
- #### Methods
379
-
380
- ##### captureStackTrace()
381
-
382
- ```ts
383
- static captureStackTrace(targetObject, constructorOpt?): void;
384
- ```
385
-
386
- Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:52
387
-
388
- Creates a `.stack` property on `targetObject`, which when accessed returns
389
- a string representing the location in the code at which
390
- `Error.captureStackTrace()` was called.
391
-
392
- ```js
393
- const myObject = {};
394
- Error.captureStackTrace(myObject);
395
- myObject.stack; // Similar to `new Error().stack`
396
- ```
397
-
398
- The first line of the trace will be prefixed with
399
- `${myObject.name}: ${myObject.message}`.
400
-
401
- The optional `constructorOpt` argument accepts a function. If given, all frames
402
- above `constructorOpt`, including `constructorOpt`, will be omitted from the
403
- generated stack trace.
404
-
405
- The `constructorOpt` argument is useful for hiding implementation
406
- details of error generation from the user. For instance:
407
-
408
- ```js
409
- function a() {
410
- b();
411
- }
412
-
413
- function b() {
414
- c();
415
- }
416
-
417
- function c() {
418
- // Create an error without stack trace to avoid calculating the stack trace twice.
419
- const { stackTraceLimit } = Error;
420
- Error.stackTraceLimit = 0;
421
- const error = new Error();
422
- Error.stackTraceLimit = stackTraceLimit;
423
-
424
- // Capture the stack trace above function b
425
- Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
426
- throw error;
427
- }
428
-
429
- a();
430
- ```
431
-
432
- ###### Parameters
433
-
434
- | Parameter | Type |
435
- | ------ | ------ |
436
- | `targetObject` | `object` |
437
- | `constructorOpt?` | `Function` |
438
-
439
- ###### Returns
440
-
441
- `void`
442
-
443
- ###### Inherited from
444
-
445
- [`HandlerError`](#abstract-handlererror).[`captureStackTrace`](#capturestacktrace)
446
-
447
- ##### prepareStackTrace()
125
+ ###### Overrides
448
126
 
449
127
  ```ts
450
- static prepareStackTrace(err, stackTraces): any;
128
+ TaggedError("@amqp-contract/NonRetryableError", {
129
+ name: "NonRetryableError",
130
+ })<{
131
+ message: string;
132
+ cause?: unknown;
133
+ }>.constructor
451
134
  ```
452
135
 
453
- Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:56
454
-
455
- ###### Parameters
456
-
457
- | Parameter | Type |
458
- | ------ | ------ |
459
- | `err` | `Error` |
460
- | `stackTraces` | `CallSite`[] |
461
-
462
- ###### Returns
463
-
464
- `any`
465
-
466
- ###### See
467
-
468
- https://v8.dev/docs/stack-trace-api#customizing-stack-traces
469
-
470
- ###### Inherited from
136
+ #### Properties
471
137
 
472
- [`HandlerError`](#abstract-handlererror).[`prepareStackTrace`](#preparestacktrace)
138
+ | Property | Modifier | Type | Inherited from | Defined in |
139
+ | ------ | ------ | ------ | ------ | ------ |
140
+ | <a id="_tag-1"></a> `_tag` | `readonly` | `"@amqp-contract/NonRetryableError"` | `TaggedError("@amqp-contract/NonRetryableError", { name: "NonRetryableError", })._tag` | node\_modules/.pnpm/unthrown@1.0.0/node\_modules/unthrown/dist/index.d.mts:778 |
141
+ | <a id="cause-1"></a> `cause?` | `public` | `unknown` | [`MessageValidationError`](#messagevalidationerror).[`cause`](#cause) | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
142
+ | <a id="message-1"></a> `message` | `public` | `string` | `TaggedError("@amqp-contract/NonRetryableError", { name: "NonRetryableError", }).message` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
143
+ | <a id="name-1"></a> `name` | `public` | `string` | `TaggedError("@amqp-contract/NonRetryableError", { name: "NonRetryableError", }).name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
144
+ | <a id="stack-1"></a> `stack?` | `public` | `string` | `TaggedError("@amqp-contract/NonRetryableError", { name: "NonRetryableError", }).stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
473
145
 
474
146
  ***
475
147
 
476
148
  ### RetryableError
477
149
 
478
- Defined in: [packages/worker/src/errors.ts:35](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L35)
150
+ Defined in: [packages/worker/src/errors.ts:17](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/errors.ts#L17)
479
151
 
480
152
  Retryable errors - transient failures that may succeed on retry
481
153
  Examples: network timeouts, rate limiting, temporary service unavailability
@@ -483,9 +155,17 @@ Examples: network timeouts, rate limiting, temporary service unavailability
483
155
  Use this error type when the operation might succeed if retried.
484
156
  The worker will apply exponential backoff and retry the message.
485
157
 
158
+ Built on unthrown's [TaggedError](https://github.com/btravstack/unthrown), so it carries a namespaced `_tag` of
159
+ `"@amqp-contract/RetryableError"` (to avoid colliding with other libraries'
160
+ tags in a shared `matchTags`) for exhaustive dispatch; the `Error.name` is
161
+ kept bare (`"RetryableError"`).
162
+
486
163
  #### Extends
487
164
 
488
- - [`HandlerError`](#abstract-handlererror)
165
+ - `TaggedErrorInstance`&lt;`"@amqp-contract/RetryableError"`, \{
166
+ `cause?`: `unknown`;
167
+ `message`: `string`;
168
+ \}&gt;
489
169
 
490
170
  #### Constructors
491
171
 
@@ -495,7 +175,7 @@ The worker will apply exponential backoff and retry the message.
495
175
  new RetryableError(message, cause?): RetryableError;
496
176
  ```
497
177
 
498
- Defined in: [packages/worker/src/errors.ts:13](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L13)
178
+ Defined in: [packages/worker/src/errors.ts:23](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/errors.ts#L23)
499
179
 
500
180
  ###### Parameters
501
181
 
@@ -508,121 +188,32 @@ Defined in: [packages/worker/src/errors.ts:13](https://github.com/btravers/amqp-
508
188
 
509
189
  [`RetryableError`](#retryableerror)
510
190
 
511
- ###### Inherited from
512
-
513
- [`HandlerError`](#abstract-handlererror).[`constructor`](#constructor)
514
-
515
- #### Properties
516
-
517
- | Property | Modifier | Type | Description | Overrides | Inherited from | Defined in |
518
- | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
519
- | <a id="cause-3"></a> `cause?` | `readonly` | `unknown` | - | - | [`HandlerError`](#abstract-handlererror).[`cause`](#cause) | [packages/worker/src/errors.ts:15](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L15) |
520
- | <a id="message-3"></a> `message` | `public` | `string` | - | - | [`HandlerError`](#abstract-handlererror).[`message`](#message) | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
521
- | <a id="name-3"></a> `name` | `readonly` | `"RetryableError"` | - | [`HandlerError`](#abstract-handlererror).[`name`](#name) | - | [packages/worker/src/errors.ts:36](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L36) |
522
- | <a id="stack-3"></a> `stack?` | `public` | `string` | - | - | [`HandlerError`](#abstract-handlererror).[`stack`](#stack) | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
523
- | <a id="stacktracelimit-3"></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. | - | [`HandlerError`](#abstract-handlererror).[`stackTraceLimit`](#stacktracelimit) | node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:68 |
524
-
525
- #### Methods
526
-
527
- ##### captureStackTrace()
528
-
529
- ```ts
530
- static captureStackTrace(targetObject, constructorOpt?): void;
531
- ```
532
-
533
- Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:52
534
-
535
- Creates a `.stack` property on `targetObject`, which when accessed returns
536
- a string representing the location in the code at which
537
- `Error.captureStackTrace()` was called.
538
-
539
- ```js
540
- const myObject = {};
541
- Error.captureStackTrace(myObject);
542
- myObject.stack; // Similar to `new Error().stack`
543
- ```
544
-
545
- The first line of the trace will be prefixed with
546
- `${myObject.name}: ${myObject.message}`.
547
-
548
- The optional `constructorOpt` argument accepts a function. If given, all frames
549
- above `constructorOpt`, including `constructorOpt`, will be omitted from the
550
- generated stack trace.
551
-
552
- The `constructorOpt` argument is useful for hiding implementation
553
- details of error generation from the user. For instance:
554
-
555
- ```js
556
- function a() {
557
- b();
558
- }
559
-
560
- function b() {
561
- c();
562
- }
563
-
564
- function c() {
565
- // Create an error without stack trace to avoid calculating the stack trace twice.
566
- const { stackTraceLimit } = Error;
567
- Error.stackTraceLimit = 0;
568
- const error = new Error();
569
- Error.stackTraceLimit = stackTraceLimit;
570
-
571
- // Capture the stack trace above function b
572
- Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
573
- throw error;
574
- }
575
-
576
- a();
577
- ```
578
-
579
- ###### Parameters
580
-
581
- | Parameter | Type |
582
- | ------ | ------ |
583
- | `targetObject` | `object` |
584
- | `constructorOpt?` | `Function` |
585
-
586
- ###### Returns
587
-
588
- `void`
589
-
590
- ###### Inherited from
591
-
592
- [`HandlerError`](#abstract-handlererror).[`captureStackTrace`](#capturestacktrace)
593
-
594
- ##### prepareStackTrace()
191
+ ###### Overrides
595
192
 
596
193
  ```ts
597
- static prepareStackTrace(err, stackTraces): any;
194
+ TaggedError("@amqp-contract/RetryableError", {
195
+ name: "RetryableError",
196
+ })<{
197
+ message: string;
198
+ cause?: unknown;
199
+ }>.constructor
598
200
  ```
599
201
 
600
- Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:56
601
-
602
- ###### Parameters
603
-
604
- | Parameter | Type |
605
- | ------ | ------ |
606
- | `err` | `Error` |
607
- | `stackTraces` | `CallSite`[] |
608
-
609
- ###### Returns
610
-
611
- `any`
612
-
613
- ###### See
614
-
615
- https://v8.dev/docs/stack-trace-api#customizing-stack-traces
616
-
617
- ###### Inherited from
202
+ #### Properties
618
203
 
619
- [`HandlerError`](#abstract-handlererror).[`prepareStackTrace`](#preparestacktrace)
204
+ | Property | Modifier | Type | Inherited from | Defined in |
205
+ | ------ | ------ | ------ | ------ | ------ |
206
+ | <a id="_tag-2"></a> `_tag` | `readonly` | `"@amqp-contract/RetryableError"` | `TaggedError("@amqp-contract/RetryableError", { name: "RetryableError", })._tag` | node\_modules/.pnpm/unthrown@1.0.0/node\_modules/unthrown/dist/index.d.mts:778 |
207
+ | <a id="cause-2"></a> `cause?` | `public` | `unknown` | [`MessageValidationError`](#messagevalidationerror).[`cause`](#cause) | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
208
+ | <a id="message-2"></a> `message` | `public` | `string` | `TaggedError("@amqp-contract/RetryableError", { name: "RetryableError", }).message` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
209
+ | <a id="name-2"></a> `name` | `public` | `string` | `TaggedError("@amqp-contract/RetryableError", { name: "RetryableError", }).name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
210
+ | <a id="stack-2"></a> `stack?` | `public` | `string` | `TaggedError("@amqp-contract/RetryableError", { name: "RetryableError", }).stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
620
211
 
621
212
  ***
622
213
 
623
214
  ### TypedAmqpWorker
624
215
 
625
- Defined in: [packages/worker/src/worker.ts:182](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L182)
216
+ Defined in: [packages/worker/src/worker.ts:189](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L189)
626
217
 
627
218
  Type-safe AMQP worker for consuming messages from RabbitMQ.
628
219
 
@@ -634,7 +225,7 @@ and error handling for consuming messages based on a contract definition.
634
225
  ```typescript
635
226
  import { TypedAmqpWorker } from '@amqp-contract/worker';
636
227
  import { defineQueue, defineMessage, defineContract, defineConsumer } from '@amqp-contract/contract';
637
- import { okAsync } from 'neverthrow';
228
+ import { Ok } from 'unthrown';
638
229
  import { z } from 'zod';
639
230
 
640
231
  const orderQueue = defineQueue('order-processing');
@@ -654,14 +245,13 @@ const result = await TypedAmqpWorker.create({
654
245
  handlers: {
655
246
  processOrder: ({ payload }) => {
656
247
  console.log('Processing order', payload.orderId);
657
- return okAsync(undefined);
248
+ return Ok(undefined).toAsync();
658
249
  },
659
250
  },
660
251
  urls: ['amqp://localhost'],
661
252
  });
662
253
 
663
- if (result.isErr()) throw result.error;
664
- const worker = result.value;
254
+ const worker = result.unwrap();
665
255
 
666
256
  // Close when done
667
257
  await worker.close();
@@ -678,10 +268,10 @@ await worker.close();
678
268
  ##### close()
679
269
 
680
270
  ```ts
681
- close(): ResultAsync<void, TechnicalError>;
271
+ close(): AsyncResult<void, TechnicalError>;
682
272
  ```
683
273
 
684
- Defined in: [packages/worker/src/worker.ts:342](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L342)
274
+ Defined in: [packages/worker/src/worker.ts:350](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L350)
685
275
 
686
276
  Close the AMQP channel and connection.
687
277
 
@@ -690,7 +280,7 @@ stopping all message consumption and cleaning up resources.
690
280
 
691
281
  ###### Returns
692
282
 
693
- `ResultAsync`&lt;`void`, `TechnicalError`&gt;
283
+ `AsyncResult`&lt;`void`, `TechnicalError`&gt;
694
284
 
695
285
  ###### Example
696
286
 
@@ -704,15 +294,15 @@ if (closeResult.isOk()) {
704
294
  ##### create()
705
295
 
706
296
  ```ts
707
- static create<TContract>(__namedParameters): ResultAsync<TypedAmqpWorker<TContract>, TechnicalError>;
297
+ static create<TContract>(__namedParameters): AsyncResult<TypedAmqpWorker<TContract>, TechnicalError>;
708
298
  ```
709
299
 
710
- Defined in: [packages/worker/src/worker.ts:281](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L281)
300
+ Defined in: [packages/worker/src/worker.ts:288](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L288)
711
301
 
712
302
  Create a type-safe AMQP worker from a contract.
713
303
 
714
304
  Connection management (including automatic reconnection) is handled internally
715
- by amqp-connection-manager via the [AmqpClient](https://btravers.github.io/amqp-contract/api/core#amqpclient). The worker will set up
305
+ by amqp-connection-manager via the [AmqpClient](https://btravstack.github.io/amqp-contract/api/core#amqpclient). The worker will set up
716
306
  consumers for all contract-defined handlers asynchronously in the background
717
307
  once the underlying connection and channels are ready.
718
308
 
@@ -733,9 +323,9 @@ URLs and connection options, following RabbitMQ best practices.
733
323
 
734
324
  ###### Returns
735
325
 
736
- `ResultAsync`&lt;[`TypedAmqpWorker`](#typedamqpworker)&lt;`TContract`&gt;, `TechnicalError`&gt;
326
+ `AsyncResult`&lt;[`TypedAmqpWorker`](#typedamqpworker)&lt;`TContract`&gt;, `TechnicalError`&gt;
737
327
 
738
- A ResultAsync that resolves to the worker or a TechnicalError.
328
+ A AsyncResult that resolves to the worker or a TechnicalError.
739
329
 
740
330
  ###### Example
741
331
 
@@ -743,7 +333,7 @@ A ResultAsync that resolves to the worker or a TechnicalError.
743
333
  const result = await TypedAmqpWorker.create({
744
334
  contract: myContract,
745
335
  handlers: {
746
- processOrder: ({ payload }) => okAsync(undefined),
336
+ processOrder: ({ payload }) => Ok(undefined).toAsync(),
747
337
  },
748
338
  urls: ['amqp://localhost'],
749
339
  });
@@ -757,7 +347,7 @@ const result = await TypedAmqpWorker.create({
757
347
  type ConsumerOptions = AmqpClientConsumerOptions;
758
348
  ```
759
349
 
760
- Defined in: [packages/worker/src/worker.ts:50](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L50)
350
+ Defined in: [packages/worker/src/worker.ts:58](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L58)
761
351
 
762
352
  ***
763
353
 
@@ -767,7 +357,7 @@ Defined in: [packages/worker/src/worker.ts:50](https://github.com/btravers/amqp-
767
357
  type CreateWorkerOptions<TContract> = object;
768
358
  ```
769
359
 
770
- Defined in: [packages/worker/src/worker.ts:97](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L97)
360
+ Defined in: [packages/worker/src/worker.ts:105](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L105)
771
361
 
772
362
  Options for creating a type-safe AMQP worker.
773
363
 
@@ -780,13 +370,13 @@ const options: CreateWorkerOptions<typeof contract> = {
780
370
  // Simple handler
781
371
  processOrder: ({ payload }) => {
782
372
  console.log('Processing order:', payload.orderId);
783
- return okAsync(undefined);
373
+ return Ok(undefined).toAsync();
784
374
  },
785
375
  // Handler with prefetch configuration
786
376
  processPayment: [
787
377
  ({ payload }) => {
788
378
  console.log('Processing payment:', payload.paymentId);
789
- return okAsync(undefined);
379
+ return Ok(undefined).toAsync();
790
380
  },
791
381
  { prefetch: 10 }
792
382
  ]
@@ -815,14 +405,35 @@ not at the handler level. See `QueueDefinition.retry` for configuration options.
815
405
 
816
406
  | Property | Type | Description | Defined in |
817
407
  | ------ | ------ | ------ | ------ |
818
- | <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.) | [packages/worker/src/worker.ts:114](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L114) |
819
- | <a id="connecttimeoutms"></a> `connectTimeoutMs?` | `number` \| `null` | Maximum time in ms to wait for the AMQP connection to become ready before `create()` resolves to an `err(TechnicalError)`. Defaults to 30s (the [AmqpClient](https://btravers.github.io/amqp-contract/api/core#amqpclient)'s `DEFAULT_CONNECT_TIMEOUT_MS`). Pass `null` to disable the timeout and let amqp-connection-manager retry indefinitely. | [packages/worker/src/worker.ts:134](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L134) |
820
- | <a id="contract"></a> `contract` | `TContract` | The AMQP contract definition specifying consumers and their message schemas | [packages/worker/src/worker.ts:99](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L99) |
821
- | <a id="defaultconsumeroptions"></a> `defaultConsumerOptions?` | [`ConsumerOptions`](#consumeroptions) | Optional default consumer options applied to all consumer handlers. Handler-specific options provided in tuple form override these defaults. | [packages/worker/src/worker.ts:127](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L127) |
822
- | <a id="handlers"></a> `handlers` | [`WorkerInferHandlers`](#workerinferhandlers)&lt;`TContract`&gt; | Handlers for each `consumers` and `rpcs` entry in the contract. - Regular consumers return `ResultAsync<void, HandlerError>`. - RPC handlers return `ResultAsync<TResponse, HandlerError>` where `TResponse` is inferred from the RPC's response message schema. Use `defineHandler` / `defineHandlers` to create handlers with full type inference. | [packages/worker/src/worker.ts:110](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L110) |
823
- | <a id="logger"></a> `logger?` | `Logger` | Optional logger for logging message consumption and errors | [packages/worker/src/worker.ts:116](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L116) |
824
- | <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:122](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L122) |
825
- | <a id="urls"></a> `urls` | `ConnectionUrl`[] | AMQP broker URL(s). Multiple URLs provide failover support | [packages/worker/src/worker.ts:112](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/worker.ts#L112) |
408
+ | <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | Optional connection configuration (heartbeat, reconnect settings, etc.) | [packages/worker/src/worker.ts:122](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L122) |
409
+ | <a id="connecttimeoutms"></a> `connectTimeoutMs?` | `number` \| `null` | Maximum time in ms to wait for the AMQP connection to become ready before `create()` resolves to an `Err(TechnicalError)`. Defaults to 30s (the [AmqpClient](https://btravstack.github.io/amqp-contract/api/core#amqpclient)'s `DEFAULT_CONNECT_TIMEOUT_MS`). Pass `null` to disable the timeout and let amqp-connection-manager retry indefinitely. | [packages/worker/src/worker.ts:142](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L142) |
410
+ | <a id="contract"></a> `contract` | `TContract` | The AMQP contract definition specifying consumers and their message schemas | [packages/worker/src/worker.ts:107](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L107) |
411
+ | <a id="defaultconsumeroptions"></a> `defaultConsumerOptions?` | [`ConsumerOptions`](#consumeroptions) | Optional default consumer options applied to all consumer handlers. Handler-specific options provided in tuple form override these defaults. | [packages/worker/src/worker.ts:135](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L135) |
412
+ | <a id="handlers"></a> `handlers` | [`WorkerInferHandlers`](#workerinferhandlers)&lt;`TContract`&gt; | Handlers for each `consumers` and `rpcs` entry in the contract. - Regular consumers return `AsyncResult<void, HandlerError>`. - RPC handlers return `AsyncResult<TResponse, HandlerError>` where `TResponse` is inferred from the RPC's response message schema. Use `defineHandler` / `defineHandlers` to create handlers with full type inference. | [packages/worker/src/worker.ts:118](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L118) |
413
+ | <a id="logger"></a> `logger?` | `Logger` | Optional logger for logging message consumption and errors | [packages/worker/src/worker.ts:124](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L124) |
414
+ | <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:130](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L130) |
415
+ | <a id="urls"></a> `urls` | `ConnectionUrl`[] | AMQP broker URL(s). Multiple URLs provide failover support | [packages/worker/src/worker.ts:120](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/worker.ts#L120) |
416
+
417
+ ***
418
+
419
+ ### HandlerError
420
+
421
+ ```ts
422
+ type HandlerError =
423
+ | RetryableError
424
+ | NonRetryableError;
425
+ ```
426
+
427
+ Defined in: [packages/worker/src/errors.ts:58](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/errors.ts#L58)
428
+
429
+ Any handler-signalled error — the union a handler may put in the `Err`
430
+ channel of its `AsyncResult`. Discriminate on `_tag`
431
+ (`"@amqp-contract/RetryableError"` / `"@amqp-contract/NonRetryableError"`),
432
+ e.g. with `matchTags`.
433
+
434
+ Previously an abstract base class; now a tagged union, because unthrown's
435
+ `TaggedError` mints a distinct base class per tag. Use [isHandlerError](#ishandlererror)
436
+ for runtime narrowing instead of `instanceof HandlerError`.
826
437
 
827
438
  ***
828
439
 
@@ -832,7 +443,7 @@ not at the handler level. See `QueueDefinition.retry` for configuration options.
832
443
  type WorkerConsumedMessage<TPayload, THeaders> = object;
833
444
  ```
834
445
 
835
- Defined in: [packages/worker/src/types.ts:156](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L156)
446
+ Defined in: [packages/worker/src/types.ts:156](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L156)
836
447
 
837
448
  A consumed message containing parsed payload and headers.
838
449
 
@@ -846,7 +457,7 @@ const handler = defineHandler(contract, 'processOrder', (message, rawMessage) =>
846
457
  console.log(message.payload.orderId); // Typed payload
847
458
  console.log(message.headers?.priority); // Typed headers (if defined)
848
459
  console.log(rawMessage.fields.deliveryTag); // Raw AMQP message
849
- return okAsync(undefined);
460
+ return Ok(undefined).toAsync();
850
461
  });
851
462
  ```
852
463
 
@@ -861,8 +472,8 @@ const handler = defineHandler(contract, 'processOrder', (message, rawMessage) =>
861
472
 
862
473
  | Property | Type | Description | Defined in |
863
474
  | ------ | ------ | ------ | ------ |
864
- | <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:160](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L160) |
865
- | <a id="payload"></a> `payload` | `TPayload` | The validated message payload | [packages/worker/src/types.ts:158](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L158) |
475
+ | <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:160](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L160) |
476
+ | <a id="payload"></a> `payload` | `TPayload` | The validated message payload | [packages/worker/src/types.ts:158](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L158) |
866
477
 
867
478
  ***
868
479
 
@@ -872,7 +483,7 @@ const handler = defineHandler(contract, 'processOrder', (message, rawMessage) =>
872
483
  type WorkerInferConsumedMessage<TContract, TName> = WorkerConsumedMessage<WorkerInferConsumerPayload<TContract, TName>, WorkerInferConsumerHeaders<TContract, TName>>;
873
484
  ```
874
485
 
875
- Defined in: [packages/worker/src/types.ts:166](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L166)
486
+ Defined in: [packages/worker/src/types.ts:166](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L166)
876
487
 
877
488
  Infer the full consumed message type for a regular consumer.
878
489
 
@@ -888,13 +499,13 @@ Infer the full consumed message type for a regular consumer.
888
499
  ### WorkerInferConsumerHandler
889
500
 
890
501
  ```ts
891
- type WorkerInferConsumerHandler<TContract, TName> = (message, rawMessage) => ResultAsync<void, HandlerError>;
502
+ type WorkerInferConsumerHandler<TContract, TName> = (message, rawMessage) => AsyncResult<void, HandlerError>;
892
503
  ```
893
504
 
894
- Defined in: [packages/worker/src/types.ts:197](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L197)
505
+ Defined in: [packages/worker/src/types.ts:197](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L197)
895
506
 
896
507
  Handler signature for a regular consumer (event/command). Returns
897
- `ResultAsync<void, HandlerError>` — there is no response message.
508
+ `AsyncResult<void, HandlerError>` — there is no response message.
898
509
 
899
510
  #### Type Parameters
900
511
 
@@ -912,7 +523,7 @@ Handler signature for a regular consumer (event/command). Returns
912
523
 
913
524
  #### Returns
914
525
 
915
- `ResultAsync`&lt;`void`, [`HandlerError`](#abstract-handlererror)&gt;
526
+ `AsyncResult`&lt;`void`, [`HandlerError`](#handlererror)&gt;
916
527
 
917
528
  ***
918
529
 
@@ -924,7 +535,7 @@ type WorkerInferConsumerHandlerEntry<TContract, TName> =
924
535
  | readonly [WorkerInferConsumerHandler<TContract, TName>, ConsumerOptions];
925
536
  ```
926
537
 
927
- Defined in: [packages/worker/src/types.ts:223](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L223)
538
+ Defined in: [packages/worker/src/types.ts:223](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L223)
928
539
 
929
540
  Handler entry for a regular consumer — function or `[handler, options]`.
930
541
 
@@ -943,7 +554,7 @@ Handler entry for a regular consumer — function or `[handler, options]`.
943
554
  type WorkerInferConsumerHeaders<TContract, TName> = ConsumerInferHeadersOutput<InferConsumer<TContract, TName>>;
944
555
  ```
945
556
 
946
- Defined in: [packages/worker/src/types.ts:85](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L85)
557
+ Defined in: [packages/worker/src/types.ts:85](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L85)
947
558
 
948
559
  Infer the headers type for a regular consumer.
949
560
  Returns undefined if no headers schema is defined.
@@ -963,7 +574,7 @@ Returns undefined if no headers schema is defined.
963
574
  type WorkerInferHandlers<TContract> = [InferConsumerNames<TContract>] extends [never] ? object : { [K in InferConsumerNames<TContract>]: WorkerInferConsumerHandlerEntry<TContract, K> } & [InferRpcNames<TContract>] extends [never] ? object : { [K in InferRpcNames<TContract>]: WorkerInferRpcHandlerEntry<TContract, K> };
964
575
  ```
965
576
 
966
- Defined in: [packages/worker/src/types.ts:257](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L257)
577
+ Defined in: [packages/worker/src/types.ts:257](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L257)
967
578
 
968
579
  All handlers for a contract: one entry per `consumers` key plus one entry
969
580
  per `rpcs` key. The two name spaces are disjoint so the resulting object
@@ -980,11 +591,11 @@ type is unambiguous.
980
591
  ```typescript
981
592
  const handlers: WorkerInferHandlers<typeof contract> = {
982
593
  processOrder: ({ payload }) =>
983
- ResultAsync.fromPromise(
594
+ fromPromise(
984
595
  processPayment(payload),
985
596
  (error) => new RetryableError('Payment failed', error),
986
597
  ).map(() => undefined),
987
- calculate: ({ payload }) => okAsync({ sum: payload.a + payload.b }),
598
+ calculate: ({ payload }) => Ok({ sum: payload.a + payload.b }).toAsync(),
988
599
  };
989
600
  ```
990
601
 
@@ -996,7 +607,7 @@ const handlers: WorkerInferHandlers<typeof contract> = {
996
607
  type WorkerInferRpcConsumedMessage<TContract, TName> = WorkerConsumedMessage<WorkerInferRpcRequest<TContract, TName>, WorkerInferRpcHeaders<TContract, TName>>;
997
608
  ```
998
609
 
999
- Defined in: [packages/worker/src/types.ts:178](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L178)
610
+ Defined in: [packages/worker/src/types.ts:178](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L178)
1000
611
 
1001
612
  Infer the consumed message type for an RPC handler — payload + headers from
1002
613
  the request side of the RPC.
@@ -1013,13 +624,13 @@ the request side of the RPC.
1013
624
  ### WorkerInferRpcHandler
1014
625
 
1015
626
  ```ts
1016
- type WorkerInferRpcHandler<TContract, TName> = (message, rawMessage) => ResultAsync<WorkerInferRpcResponse<TContract, TName>, HandlerError>;
627
+ type WorkerInferRpcHandler<TContract, TName> = (message, rawMessage) => AsyncResult<WorkerInferRpcResponse<TContract, TName>, HandlerError>;
1017
628
  ```
1018
629
 
1019
- Defined in: [packages/worker/src/types.ts:212](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L212)
630
+ Defined in: [packages/worker/src/types.ts:212](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L212)
1020
631
 
1021
632
  Handler signature for an RPC. Returns
1022
- `ResultAsync<TResponse, HandlerError>` where `TResponse` is the inferred
633
+ `AsyncResult<TResponse, HandlerError>` where `TResponse` is the inferred
1023
634
  response payload. The worker validates the response against the RPC's
1024
635
  response schema and publishes it back to `msg.properties.replyTo` with the
1025
636
  same `correlationId`.
@@ -1040,7 +651,7 @@ same `correlationId`.
1040
651
 
1041
652
  #### Returns
1042
653
 
1043
- `ResultAsync`&lt;[`WorkerInferRpcResponse`](#workerinferrpcresponse)&lt;`TContract`, `TName`&gt;, [`HandlerError`](#abstract-handlererror)&gt;
654
+ `AsyncResult`&lt;[`WorkerInferRpcResponse`](#workerinferrpcresponse)&lt;`TContract`, `TName`&gt;, [`HandlerError`](#handlererror)&gt;
1044
655
 
1045
656
  ***
1046
657
 
@@ -1052,7 +663,7 @@ type WorkerInferRpcHandlerEntry<TContract, TName> =
1052
663
  | readonly [WorkerInferRpcHandler<TContract, TName>, ConsumerOptions];
1053
664
  ```
1054
665
 
1055
- Defined in: [packages/worker/src/types.ts:233](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L233)
666
+ Defined in: [packages/worker/src/types.ts:233](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L233)
1056
667
 
1057
668
  Handler entry for an RPC — function or `[handler, options]`.
1058
669
 
@@ -1071,7 +682,7 @@ Handler entry for an RPC — function or `[handler, options]`.
1071
682
  type WorkerInferRpcHeaders<TContract, TName> = InferRpc<TContract, TName> extends RpcDefinition<infer TRequest, MessageDefinition> ? TRequest extends MessageDefinition<infer _TPayload, infer THeaders> ? THeaders extends StandardSchemaV1<Record<string, unknown>> ? InferSchemaOutput<THeaders> : undefined : undefined : undefined;
1072
683
  ```
1073
684
 
1074
- Defined in: [packages/worker/src/types.ts:107](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L107)
685
+ Defined in: [packages/worker/src/types.ts:107](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L107)
1075
686
 
1076
687
  Infer the request headers type for an RPC. Returns undefined unless the RPC's
1077
688
  request `MessageDefinition` declares a headers schema.
@@ -1091,7 +702,7 @@ request `MessageDefinition` declares a headers schema.
1091
702
  type WorkerInferRpcRequest<TContract, TName> = InferRpc<TContract, TName> extends RpcDefinition<infer TRequest, MessageDefinition> ? TRequest extends MessageDefinition ? InferSchemaOutput<TRequest["payload"]> : never : never;
1092
703
  ```
1093
704
 
1094
- Defined in: [packages/worker/src/types.ts:93](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L93)
705
+ Defined in: [packages/worker/src/types.ts:93](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L93)
1095
706
 
1096
707
  Infer the request payload type for an RPC.
1097
708
 
@@ -1110,10 +721,10 @@ Infer the request payload type for an RPC.
1110
721
  type WorkerInferRpcResponse<TContract, TName> = InferRpc<TContract, TName> extends RpcDefinition<MessageDefinition, infer TResponse> ? TResponse extends MessageDefinition ? InferSchemaOutput<TResponse["payload"]> : never : never;
1111
722
  ```
1112
723
 
1113
- Defined in: [packages/worker/src/types.ts:123](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/types.ts#L123)
724
+ Defined in: [packages/worker/src/types.ts:123](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/types.ts#L123)
1114
725
 
1115
726
  Infer the response payload type for an RPC. The handler must return a
1116
- `ResultAsync<TResponse, HandlerError>` matching this shape.
727
+ `AsyncResult<TResponse, HandlerError>` matching this shape.
1117
728
 
1118
729
  #### Type Parameters
1119
730
 
@@ -1135,13 +746,13 @@ function defineHandler<TContract, TName>(
1135
746
  handler): WorkerInferConsumerHandlerEntry<TContract, TName>;
1136
747
  ```
1137
748
 
1138
- Defined in: [packages/worker/src/handlers.ts:121](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/handlers.ts#L121)
749
+ Defined in: [packages/worker/src/handlers.ts:121](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/handlers.ts#L121)
1139
750
 
1140
751
  Define a type-safe handler for a specific consumer or RPC in a contract.
1141
752
 
1142
753
  **Recommended:** This function creates handlers that return
1143
- `ResultAsync<void, HandlerError>` (consumers) or
1144
- `ResultAsync<TResponse, HandlerError>` (RPCs), providing explicit error
754
+ `AsyncResult<void, HandlerError>` (consumers) or
755
+ `AsyncResult<TResponse, HandlerError>` (RPCs), providing explicit error
1145
756
  handling and better control over retry behavior.
1146
757
 
1147
758
  Supports two patterns:
@@ -1161,7 +772,7 @@ Supports two patterns:
1161
772
  | ------ | ------ | ------ |
1162
773
  | `contract` | `TContract` | The contract definition containing the consumer or RPC |
1163
774
  | `name` | `TName` | The name of the consumer or RPC from the contract |
1164
- | `handler` | [`WorkerInferConsumerHandler`](#workerinferconsumerhandler)&lt;`TContract`, `TName`&gt; | The handler function — for consumers, returns `ResultAsync<void, HandlerError>`; for RPCs, returns `ResultAsync<TResponse, HandlerError>`. |
775
+ | `handler` | [`WorkerInferConsumerHandler`](#workerinferconsumerhandler)&lt;`TContract`, `TName`&gt; | The handler function — for consumers, returns `AsyncResult<void, HandlerError>`; for RPCs, returns `AsyncResult<TResponse, HandlerError>`. |
1165
776
 
1166
777
  ##### Returns
1167
778
 
@@ -1171,26 +782,30 @@ A type-safe handler that can be used with TypedAmqpWorker
1171
782
 
1172
783
  ##### Examples
1173
784
 
785
+ **Consumer handler**
786
+
1174
787
  ```typescript
1175
788
  import { defineHandler, RetryableError, NonRetryableError } from '@amqp-contract/worker';
1176
- import { errAsync, okAsync, ResultAsync } from 'neverthrow';
789
+ import { fromPromise, Ok } from 'unthrown';
1177
790
 
1178
791
  const processOrderHandler = defineHandler(
1179
792
  orderContract,
1180
793
  'processOrder',
1181
794
  ({ payload }) =>
1182
- ResultAsync.fromPromise(
795
+ fromPromise(
1183
796
  processPayment(payload),
1184
797
  (error) => new RetryableError('Payment failed', error),
1185
798
  ).map(() => undefined),
1186
799
  );
1187
800
  ```
1188
801
 
802
+ **RPC handler**
803
+
1189
804
  ```typescript
1190
805
  const calculateHandler = defineHandler(
1191
806
  rpcContract,
1192
807
  'calculate',
1193
- ({ payload }) => okAsync({ sum: payload.a + payload.b }),
808
+ ({ payload }) => Ok({ sum: payload.a + payload.b }).toAsync(),
1194
809
  );
1195
810
  ```
1196
811
 
@@ -1204,13 +819,13 @@ function defineHandler<TContract, TName>(
1204
819
  options): WorkerInferConsumerHandlerEntry<TContract, TName>;
1205
820
  ```
1206
821
 
1207
- Defined in: [packages/worker/src/handlers.ts:129](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/handlers.ts#L129)
822
+ Defined in: [packages/worker/src/handlers.ts:129](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/handlers.ts#L129)
1208
823
 
1209
824
  Define a type-safe handler for a specific consumer or RPC in a contract.
1210
825
 
1211
826
  **Recommended:** This function creates handlers that return
1212
- `ResultAsync<void, HandlerError>` (consumers) or
1213
- `ResultAsync<TResponse, HandlerError>` (RPCs), providing explicit error
827
+ `AsyncResult<void, HandlerError>` (consumers) or
828
+ `AsyncResult<TResponse, HandlerError>` (RPCs), providing explicit error
1214
829
  handling and better control over retry behavior.
1215
830
 
1216
831
  Supports two patterns:
@@ -1230,7 +845,7 @@ Supports two patterns:
1230
845
  | ------ | ------ | ------ |
1231
846
  | `contract` | `TContract` | The contract definition containing the consumer or RPC |
1232
847
  | `name` | `TName` | The name of the consumer or RPC from the contract |
1233
- | `handler` | [`WorkerInferConsumerHandler`](#workerinferconsumerhandler)&lt;`TContract`, `TName`&gt; | The handler function — for consumers, returns `ResultAsync<void, HandlerError>`; for RPCs, returns `ResultAsync<TResponse, HandlerError>`. |
848
+ | `handler` | [`WorkerInferConsumerHandler`](#workerinferconsumerhandler)&lt;`TContract`, `TName`&gt; | The handler function — for consumers, returns `AsyncResult<void, HandlerError>`; for RPCs, returns `AsyncResult<TResponse, HandlerError>`. |
1234
849
  | `options` | `ConsumerOptions` | Optional consumer options (prefetch) |
1235
850
 
1236
851
  ##### Returns
@@ -1241,26 +856,30 @@ A type-safe handler that can be used with TypedAmqpWorker
1241
856
 
1242
857
  ##### Examples
1243
858
 
859
+ **Consumer handler**
860
+
1244
861
  ```typescript
1245
862
  import { defineHandler, RetryableError, NonRetryableError } from '@amqp-contract/worker';
1246
- import { errAsync, okAsync, ResultAsync } from 'neverthrow';
863
+ import { fromPromise, Ok } from 'unthrown';
1247
864
 
1248
865
  const processOrderHandler = defineHandler(
1249
866
  orderContract,
1250
867
  'processOrder',
1251
868
  ({ payload }) =>
1252
- ResultAsync.fromPromise(
869
+ fromPromise(
1253
870
  processPayment(payload),
1254
871
  (error) => new RetryableError('Payment failed', error),
1255
872
  ).map(() => undefined),
1256
873
  );
1257
874
  ```
1258
875
 
876
+ **RPC handler**
877
+
1259
878
  ```typescript
1260
879
  const calculateHandler = defineHandler(
1261
880
  rpcContract,
1262
881
  'calculate',
1263
- ({ payload }) => okAsync({ sum: payload.a + payload.b }),
882
+ ({ payload }) => Ok({ sum: payload.a + payload.b }).toAsync(),
1264
883
  );
1265
884
  ```
1266
885
 
@@ -1273,13 +892,13 @@ function defineHandler<TContract, TName>(
1273
892
  handler): WorkerInferRpcHandlerEntry<TContract, TName>;
1274
893
  ```
1275
894
 
1276
- Defined in: [packages/worker/src/handlers.ts:138](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/handlers.ts#L138)
895
+ Defined in: [packages/worker/src/handlers.ts:138](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/handlers.ts#L138)
1277
896
 
1278
897
  Define a type-safe handler for a specific consumer or RPC in a contract.
1279
898
 
1280
899
  **Recommended:** This function creates handlers that return
1281
- `ResultAsync<void, HandlerError>` (consumers) or
1282
- `ResultAsync<TResponse, HandlerError>` (RPCs), providing explicit error
900
+ `AsyncResult<void, HandlerError>` (consumers) or
901
+ `AsyncResult<TResponse, HandlerError>` (RPCs), providing explicit error
1283
902
  handling and better control over retry behavior.
1284
903
 
1285
904
  Supports two patterns:
@@ -1299,7 +918,7 @@ Supports two patterns:
1299
918
  | ------ | ------ | ------ |
1300
919
  | `contract` | `TContract` | The contract definition containing the consumer or RPC |
1301
920
  | `name` | `TName` | The name of the consumer or RPC from the contract |
1302
- | `handler` | [`WorkerInferRpcHandler`](#workerinferrpchandler)&lt;`TContract`, `TName`&gt; | The handler function — for consumers, returns `ResultAsync<void, HandlerError>`; for RPCs, returns `ResultAsync<TResponse, HandlerError>`. |
921
+ | `handler` | [`WorkerInferRpcHandler`](#workerinferrpchandler)&lt;`TContract`, `TName`&gt; | The handler function — for consumers, returns `AsyncResult<void, HandlerError>`; for RPCs, returns `AsyncResult<TResponse, HandlerError>`. |
1303
922
 
1304
923
  ##### Returns
1305
924
 
@@ -1309,26 +928,30 @@ A type-safe handler that can be used with TypedAmqpWorker
1309
928
 
1310
929
  ##### Examples
1311
930
 
931
+ **Consumer handler**
932
+
1312
933
  ```typescript
1313
934
  import { defineHandler, RetryableError, NonRetryableError } from '@amqp-contract/worker';
1314
- import { errAsync, okAsync, ResultAsync } from 'neverthrow';
935
+ import { fromPromise, Ok } from 'unthrown';
1315
936
 
1316
937
  const processOrderHandler = defineHandler(
1317
938
  orderContract,
1318
939
  'processOrder',
1319
940
  ({ payload }) =>
1320
- ResultAsync.fromPromise(
941
+ fromPromise(
1321
942
  processPayment(payload),
1322
943
  (error) => new RetryableError('Payment failed', error),
1323
944
  ).map(() => undefined),
1324
945
  );
1325
946
  ```
1326
947
 
948
+ **RPC handler**
949
+
1327
950
  ```typescript
1328
951
  const calculateHandler = defineHandler(
1329
952
  rpcContract,
1330
953
  'calculate',
1331
- ({ payload }) => okAsync({ sum: payload.a + payload.b }),
954
+ ({ payload }) => Ok({ sum: payload.a + payload.b }).toAsync(),
1332
955
  );
1333
956
  ```
1334
957
 
@@ -1342,13 +965,13 @@ function defineHandler<TContract, TName>(
1342
965
  options): WorkerInferRpcHandlerEntry<TContract, TName>;
1343
966
  ```
1344
967
 
1345
- Defined in: [packages/worker/src/handlers.ts:146](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/handlers.ts#L146)
968
+ Defined in: [packages/worker/src/handlers.ts:146](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/handlers.ts#L146)
1346
969
 
1347
970
  Define a type-safe handler for a specific consumer or RPC in a contract.
1348
971
 
1349
972
  **Recommended:** This function creates handlers that return
1350
- `ResultAsync<void, HandlerError>` (consumers) or
1351
- `ResultAsync<TResponse, HandlerError>` (RPCs), providing explicit error
973
+ `AsyncResult<void, HandlerError>` (consumers) or
974
+ `AsyncResult<TResponse, HandlerError>` (RPCs), providing explicit error
1352
975
  handling and better control over retry behavior.
1353
976
 
1354
977
  Supports two patterns:
@@ -1368,7 +991,7 @@ Supports two patterns:
1368
991
  | ------ | ------ | ------ |
1369
992
  | `contract` | `TContract` | The contract definition containing the consumer or RPC |
1370
993
  | `name` | `TName` | The name of the consumer or RPC from the contract |
1371
- | `handler` | [`WorkerInferRpcHandler`](#workerinferrpchandler)&lt;`TContract`, `TName`&gt; | The handler function — for consumers, returns `ResultAsync<void, HandlerError>`; for RPCs, returns `ResultAsync<TResponse, HandlerError>`. |
994
+ | `handler` | [`WorkerInferRpcHandler`](#workerinferrpchandler)&lt;`TContract`, `TName`&gt; | The handler function — for consumers, returns `AsyncResult<void, HandlerError>`; for RPCs, returns `AsyncResult<TResponse, HandlerError>`. |
1372
995
  | `options` | `ConsumerOptions` | Optional consumer options (prefetch) |
1373
996
 
1374
997
  ##### Returns
@@ -1379,26 +1002,30 @@ A type-safe handler that can be used with TypedAmqpWorker
1379
1002
 
1380
1003
  ##### Examples
1381
1004
 
1005
+ **Consumer handler**
1006
+
1382
1007
  ```typescript
1383
1008
  import { defineHandler, RetryableError, NonRetryableError } from '@amqp-contract/worker';
1384
- import { errAsync, okAsync, ResultAsync } from 'neverthrow';
1009
+ import { fromPromise, Ok } from 'unthrown';
1385
1010
 
1386
1011
  const processOrderHandler = defineHandler(
1387
1012
  orderContract,
1388
1013
  'processOrder',
1389
1014
  ({ payload }) =>
1390
- ResultAsync.fromPromise(
1015
+ fromPromise(
1391
1016
  processPayment(payload),
1392
1017
  (error) => new RetryableError('Payment failed', error),
1393
1018
  ).map(() => undefined),
1394
1019
  );
1395
1020
  ```
1396
1021
 
1022
+ **RPC handler**
1023
+
1397
1024
  ```typescript
1398
1025
  const calculateHandler = defineHandler(
1399
1026
  rpcContract,
1400
1027
  'calculate',
1401
- ({ payload }) => okAsync({ sum: payload.a + payload.b }),
1028
+ ({ payload }) => Ok({ sum: payload.a + payload.b }).toAsync(),
1402
1029
  );
1403
1030
  ```
1404
1031
 
@@ -1410,13 +1037,13 @@ const calculateHandler = defineHandler(
1410
1037
  function defineHandlers<TContract>(contract, handlers): WorkerInferHandlers<TContract>;
1411
1038
  ```
1412
1039
 
1413
- Defined in: [packages/worker/src/handlers.ts:198](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/handlers.ts#L198)
1040
+ Defined in: [packages/worker/src/handlers.ts:198](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/handlers.ts#L198)
1414
1041
 
1415
1042
  Define multiple type-safe handlers for consumers and RPCs in a contract.
1416
1043
 
1417
1044
  **Recommended:** This function creates handlers that return
1418
- `ResultAsync<void, HandlerError>` (consumers) or
1419
- `ResultAsync<TResponse, HandlerError>` (RPCs), providing explicit error
1045
+ `AsyncResult<void, HandlerError>` (consumers) or
1046
+ `AsyncResult<TResponse, HandlerError>` (RPCs), providing explicit error
1420
1047
  handling and better control over retry behavior.
1421
1048
 
1422
1049
  The handlers object must contain exactly one entry per `consumers` and
@@ -1445,15 +1072,15 @@ A type-safe handlers object that can be used with TypedAmqpWorker
1445
1072
 
1446
1073
  ```typescript
1447
1074
  import { defineHandlers, RetryableError } from '@amqp-contract/worker';
1448
- import { okAsync, ResultAsync } from 'neverthrow';
1075
+ import { fromPromise, Ok } from 'unthrown';
1449
1076
 
1450
1077
  const handlers = defineHandlers(orderContract, {
1451
1078
  processOrder: ({ payload }) =>
1452
- ResultAsync.fromPromise(
1079
+ fromPromise(
1453
1080
  processPayment(payload),
1454
1081
  (error) => new RetryableError('Payment failed', error),
1455
1082
  ).map(() => undefined),
1456
- calculate: ({ payload }) => okAsync({ sum: payload.a + payload.b }),
1083
+ calculate: ({ payload }) => Ok({ sum: payload.a + payload.b }).toAsync(),
1457
1084
  });
1458
1085
  ```
1459
1086
 
@@ -1465,7 +1092,7 @@ const handlers = defineHandlers(orderContract, {
1465
1092
  function isHandlerError(error): error is HandlerError;
1466
1093
  ```
1467
1094
 
1468
- Defined in: [packages/worker/src/errors.ts:124](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L124)
1095
+ Defined in: [packages/worker/src/errors.ts:134](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/errors.ts#L134)
1469
1096
 
1470
1097
  Type guard to check if an error is any HandlerError (RetryableError or NonRetryableError).
1471
1098
 
@@ -1502,7 +1129,7 @@ function handleError(error: unknown) {
1502
1129
  function isNonRetryableError(error): error is NonRetryableError;
1503
1130
  ```
1504
1131
 
1505
- Defined in: [packages/worker/src/errors.ts:102](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L102)
1132
+ Defined in: [packages/worker/src/errors.ts:112](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/errors.ts#L112)
1506
1133
 
1507
1134
  Type guard to check if an error is a NonRetryableError.
1508
1135
 
@@ -1542,7 +1169,7 @@ try {
1542
1169
  function isRetryableError(error): error is RetryableError;
1543
1170
  ```
1544
1171
 
1545
- Defined in: [packages/worker/src/errors.ts:77](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L77)
1172
+ Defined in: [packages/worker/src/errors.ts:87](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/errors.ts#L87)
1546
1173
 
1547
1174
  Type guard to check if an error is a RetryableError.
1548
1175
 
@@ -1584,7 +1211,7 @@ try {
1584
1211
  function nonRetryable(message, cause?): NonRetryableError;
1585
1212
  ```
1586
1213
 
1587
- Defined in: [packages/worker/src/errors.ts:187](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L187)
1214
+ Defined in: [packages/worker/src/errors.ts:197](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/errors.ts#L197)
1588
1215
 
1589
1216
  Create a NonRetryableError with less verbosity.
1590
1217
 
@@ -1608,17 +1235,17 @@ A new NonRetryableError instance
1608
1235
 
1609
1236
  ```typescript
1610
1237
  import { nonRetryable } from '@amqp-contract/worker';
1611
- import { errAsync, okAsync } from 'neverthrow';
1238
+ import { Err, Ok } from 'unthrown';
1612
1239
 
1613
1240
  const handler = ({ payload }) => {
1614
1241
  if (!isValidPayload(payload)) {
1615
- return errAsync(nonRetryable('Invalid payload format'));
1242
+ return Err(nonRetryable('Invalid payload format')).toAsync();
1616
1243
  }
1617
- return okAsync(undefined);
1244
+ return Ok(undefined).toAsync();
1618
1245
  };
1619
1246
 
1620
1247
  // Equivalent to:
1621
- // return errAsync(new NonRetryableError('Invalid payload format'));
1248
+ // return Err(new NonRetryableError('Invalid payload format')).toAsync();
1622
1249
  ```
1623
1250
 
1624
1251
  ***
@@ -1629,7 +1256,7 @@ const handler = ({ payload }) => {
1629
1256
  function retryable(message, cause?): RetryableError;
1630
1257
  ```
1631
1258
 
1632
- Defined in: [packages/worker/src/errors.ts:157](https://github.com/btravers/amqp-contract/blob/a478140dbe88d884a96d8fcfb20743271fd43c3f/packages/worker/src/errors.ts#L157)
1259
+ Defined in: [packages/worker/src/errors.ts:167](https://github.com/btravstack/amqp-contract/blob/cbafe3c4c44a5efd57ab3b8ebb53564b509d9d31/packages/worker/src/errors.ts#L167)
1633
1260
 
1634
1261
  Create a RetryableError with less verbosity.
1635
1262
 
@@ -1653,14 +1280,14 @@ A new RetryableError instance
1653
1280
 
1654
1281
  ```typescript
1655
1282
  import { retryable } from '@amqp-contract/worker';
1656
- import { ResultAsync } from 'neverthrow';
1283
+ import { fromPromise } from 'unthrown';
1657
1284
 
1658
1285
  const handler = ({ payload }) =>
1659
- ResultAsync.fromPromise(
1286
+ fromPromise(
1660
1287
  processPayment(payload),
1661
1288
  (e) => retryable('Payment service unavailable', e),
1662
1289
  ).map(() => undefined);
1663
1290
 
1664
1291
  // Equivalent to:
1665
- // ResultAsync.fromPromise(processPayment(payload), (e) => new RetryableError('...', e))
1292
+ // fromPromise(processPayment(payload), (e) => new RetryableError('...', e))
1666
1293
  ```