@amqp-contract/client 0.24.0 → 1.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/README.md +13 -10
- package/dist/index.cjs +72 -68
- package/dist/index.d.cts +111 -18
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +111 -18
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +62 -58
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +113 -373
- package/package.json +20 -17
package/docs/index.md
CHANGED
|
@@ -8,24 +8,34 @@
|
|
|
8
8
|
|
|
9
9
|
### MessageValidationError
|
|
10
10
|
|
|
11
|
-
Defined in: packages/core/dist/index.d.mts:
|
|
11
|
+
Defined in: packages/core/dist/index.d.mts:40
|
|
12
12
|
|
|
13
13
|
Error thrown when message validation fails (payload or headers).
|
|
14
14
|
|
|
15
15
|
Used by both the client (publish-time payload validation) and the worker
|
|
16
|
-
(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"`).
|
|
17
19
|
|
|
18
20
|
#### Param
|
|
19
21
|
|
|
22
|
+
**source**
|
|
23
|
+
|
|
20
24
|
The name of the publisher or consumer that triggered the validation
|
|
21
25
|
|
|
22
26
|
#### Param
|
|
23
27
|
|
|
28
|
+
**issues**
|
|
29
|
+
|
|
24
30
|
The validation issues from the Standard Schema validation
|
|
25
31
|
|
|
26
32
|
#### Extends
|
|
27
33
|
|
|
28
|
-
- `
|
|
34
|
+
- `MessageValidationError_base`<\{
|
|
35
|
+
`issues`: `unknown`;
|
|
36
|
+
`message`: `string`;
|
|
37
|
+
`source`: `string`;
|
|
38
|
+
\}>
|
|
29
39
|
|
|
30
40
|
#### Constructors
|
|
31
41
|
|
|
@@ -35,7 +45,7 @@ The validation issues from the Standard Schema validation
|
|
|
35
45
|
new MessageValidationError(source, issues): MessageValidationError;
|
|
36
46
|
```
|
|
37
47
|
|
|
38
|
-
Defined in: packages/core/dist/index.d.mts:
|
|
48
|
+
Defined in: packages/core/dist/index.d.mts:45
|
|
39
49
|
|
|
40
50
|
###### Parameters
|
|
41
51
|
|
|
@@ -51,134 +61,43 @@ Defined in: packages/core/dist/index.d.mts:30
|
|
|
51
61
|
###### Overrides
|
|
52
62
|
|
|
53
63
|
```ts
|
|
54
|
-
|
|
64
|
+
MessageValidationError_base<{
|
|
65
|
+
message: string;
|
|
66
|
+
source: string;
|
|
67
|
+
issues: unknown;
|
|
68
|
+
}>.constructor
|
|
55
69
|
```
|
|
56
70
|
|
|
57
71
|
#### Properties
|
|
58
72
|
|
|
59
|
-
| Property | Modifier | Type |
|
|
60
|
-
| ------ | ------ | ------ | ------ | ------ |
|
|
61
|
-
| <a id="
|
|
62
|
-
| <a id="
|
|
63
|
-
| <a id="
|
|
64
|
-
| <a id="
|
|
65
|
-
| <a id="
|
|
66
|
-
| <a id="
|
|
67
|
-
| <a id="
|
|
68
|
-
|
|
69
|
-
#### Methods
|
|
70
|
-
|
|
71
|
-
##### captureStackTrace()
|
|
72
|
-
|
|
73
|
-
```ts
|
|
74
|
-
static captureStackTrace(targetObject, constructorOpt?): void;
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:52
|
|
78
|
-
|
|
79
|
-
Creates a `.stack` property on `targetObject`, which when accessed returns
|
|
80
|
-
a string representing the location in the code at which
|
|
81
|
-
`Error.captureStackTrace()` was called.
|
|
82
|
-
|
|
83
|
-
```js
|
|
84
|
-
const myObject = {};
|
|
85
|
-
Error.captureStackTrace(myObject);
|
|
86
|
-
myObject.stack; // Similar to `new Error().stack`
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
The first line of the trace will be prefixed with
|
|
90
|
-
`${myObject.name}: ${myObject.message}`.
|
|
91
|
-
|
|
92
|
-
The optional `constructorOpt` argument accepts a function. If given, all frames
|
|
93
|
-
above `constructorOpt`, including `constructorOpt`, will be omitted from the
|
|
94
|
-
generated stack trace.
|
|
95
|
-
|
|
96
|
-
The `constructorOpt` argument is useful for hiding implementation
|
|
97
|
-
details of error generation from the user. For instance:
|
|
98
|
-
|
|
99
|
-
```js
|
|
100
|
-
function a() {
|
|
101
|
-
b();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function b() {
|
|
105
|
-
c();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function c() {
|
|
109
|
-
// Create an error without stack trace to avoid calculating the stack trace twice.
|
|
110
|
-
const { stackTraceLimit } = Error;
|
|
111
|
-
Error.stackTraceLimit = 0;
|
|
112
|
-
const error = new Error();
|
|
113
|
-
Error.stackTraceLimit = stackTraceLimit;
|
|
114
|
-
|
|
115
|
-
// Capture the stack trace above function b
|
|
116
|
-
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
|
|
117
|
-
throw error;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
a();
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
###### Parameters
|
|
124
|
-
|
|
125
|
-
| Parameter | Type |
|
|
126
|
-
| ------ | ------ |
|
|
127
|
-
| `targetObject` | `object` |
|
|
128
|
-
| `constructorOpt?` | `Function` |
|
|
129
|
-
|
|
130
|
-
###### Returns
|
|
131
|
-
|
|
132
|
-
`void`
|
|
133
|
-
|
|
134
|
-
###### Inherited from
|
|
135
|
-
|
|
136
|
-
```ts
|
|
137
|
-
Error.captureStackTrace
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
##### prepareStackTrace()
|
|
141
|
-
|
|
142
|
-
```ts
|
|
143
|
-
static prepareStackTrace(err, stackTraces): any;
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:56
|
|
147
|
-
|
|
148
|
-
###### Parameters
|
|
149
|
-
|
|
150
|
-
| Parameter | Type |
|
|
151
|
-
| ------ | ------ |
|
|
152
|
-
| `err` | `Error` |
|
|
153
|
-
| `stackTraces` | `CallSite`[] |
|
|
154
|
-
|
|
155
|
-
###### Returns
|
|
156
|
-
|
|
157
|
-
`any`
|
|
158
|
-
|
|
159
|
-
###### See
|
|
160
|
-
|
|
161
|
-
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
162
|
-
|
|
163
|
-
###### Inherited from
|
|
164
|
-
|
|
165
|
-
```ts
|
|
166
|
-
Error.prepareStackTrace
|
|
167
|
-
```
|
|
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@0.2.0/node\_modules/unthrown/dist/index.d.mts:638 |
|
|
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 |
|
|
168
82
|
|
|
169
83
|
***
|
|
170
84
|
|
|
171
85
|
### RpcCancelledError
|
|
172
86
|
|
|
173
|
-
Defined in: [packages/client/src/errors.ts:
|
|
87
|
+
Defined in: [packages/client/src/errors.ts:38](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/errors.ts#L38)
|
|
174
88
|
|
|
175
89
|
Returned from any in-flight RPC call when the client is closed before the
|
|
176
90
|
reply is received. The correlation map is cleared on close and every pending
|
|
177
|
-
caller's promise resolves with `err(RpcCancelledError)`.
|
|
91
|
+
caller's promise resolves with `err(RpcCancelledError)`. Carries a namespaced
|
|
92
|
+
`_tag` of `"@amqp-contract/RpcCancelledError"`; the `Error.name` is kept bare
|
|
93
|
+
(`"RpcCancelledError"`).
|
|
178
94
|
|
|
179
95
|
#### Extends
|
|
180
96
|
|
|
181
|
-
- `
|
|
97
|
+
- `TaggedErrorInstance`<`"@amqp-contract/RpcCancelledError"`, \{
|
|
98
|
+
`message`: `string`;
|
|
99
|
+
`rpcName`: `string`;
|
|
100
|
+
\}>
|
|
182
101
|
|
|
183
102
|
#### Constructors
|
|
184
103
|
|
|
@@ -188,7 +107,7 @@ caller's promise resolves with `err(RpcCancelledError)`.
|
|
|
188
107
|
new RpcCancelledError(rpcName): RpcCancelledError;
|
|
189
108
|
```
|
|
190
109
|
|
|
191
|
-
Defined in: [packages/client/src/errors.ts:
|
|
110
|
+
Defined in: [packages/client/src/errors.ts:44](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/errors.ts#L44)
|
|
192
111
|
|
|
193
112
|
###### Parameters
|
|
194
113
|
|
|
@@ -203,136 +122,47 @@ Defined in: [packages/client/src/errors.ts:40](https://github.com/btravers/amqp-
|
|
|
203
122
|
###### Overrides
|
|
204
123
|
|
|
205
124
|
```ts
|
|
206
|
-
|
|
125
|
+
TaggedError("@amqp-contract/RpcCancelledError", {
|
|
126
|
+
name: "RpcCancelledError",
|
|
127
|
+
})<{
|
|
128
|
+
message: string;
|
|
129
|
+
rpcName: string;
|
|
130
|
+
}>.constructor
|
|
207
131
|
```
|
|
208
132
|
|
|
209
133
|
#### Properties
|
|
210
134
|
|
|
211
|
-
| Property | Modifier | Type |
|
|
212
|
-
| ------ | ------ | ------ | ------ | ------ |
|
|
213
|
-
| <a id="
|
|
214
|
-
| <a id="
|
|
215
|
-
| <a id="
|
|
216
|
-
| <a id="
|
|
217
|
-
| <a id="
|
|
218
|
-
| <a id="
|
|
219
|
-
|
|
220
|
-
#### Methods
|
|
221
|
-
|
|
222
|
-
##### captureStackTrace()
|
|
223
|
-
|
|
224
|
-
```ts
|
|
225
|
-
static captureStackTrace(targetObject, constructorOpt?): void;
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:52
|
|
229
|
-
|
|
230
|
-
Creates a `.stack` property on `targetObject`, which when accessed returns
|
|
231
|
-
a string representing the location in the code at which
|
|
232
|
-
`Error.captureStackTrace()` was called.
|
|
233
|
-
|
|
234
|
-
```js
|
|
235
|
-
const myObject = {};
|
|
236
|
-
Error.captureStackTrace(myObject);
|
|
237
|
-
myObject.stack; // Similar to `new Error().stack`
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
The first line of the trace will be prefixed with
|
|
241
|
-
`${myObject.name}: ${myObject.message}`.
|
|
242
|
-
|
|
243
|
-
The optional `constructorOpt` argument accepts a function. If given, all frames
|
|
244
|
-
above `constructorOpt`, including `constructorOpt`, will be omitted from the
|
|
245
|
-
generated stack trace.
|
|
246
|
-
|
|
247
|
-
The `constructorOpt` argument is useful for hiding implementation
|
|
248
|
-
details of error generation from the user. For instance:
|
|
249
|
-
|
|
250
|
-
```js
|
|
251
|
-
function a() {
|
|
252
|
-
b();
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function b() {
|
|
256
|
-
c();
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function c() {
|
|
260
|
-
// Create an error without stack trace to avoid calculating the stack trace twice.
|
|
261
|
-
const { stackTraceLimit } = Error;
|
|
262
|
-
Error.stackTraceLimit = 0;
|
|
263
|
-
const error = new Error();
|
|
264
|
-
Error.stackTraceLimit = stackTraceLimit;
|
|
265
|
-
|
|
266
|
-
// Capture the stack trace above function b
|
|
267
|
-
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
|
|
268
|
-
throw error;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
a();
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
###### Parameters
|
|
275
|
-
|
|
276
|
-
| Parameter | Type |
|
|
277
|
-
| ------ | ------ |
|
|
278
|
-
| `targetObject` | `object` |
|
|
279
|
-
| `constructorOpt?` | `Function` |
|
|
280
|
-
|
|
281
|
-
###### Returns
|
|
282
|
-
|
|
283
|
-
`void`
|
|
284
|
-
|
|
285
|
-
###### Inherited from
|
|
286
|
-
|
|
287
|
-
```ts
|
|
288
|
-
Error.captureStackTrace
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
##### prepareStackTrace()
|
|
292
|
-
|
|
293
|
-
```ts
|
|
294
|
-
static prepareStackTrace(err, stackTraces): any;
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:56
|
|
298
|
-
|
|
299
|
-
###### Parameters
|
|
300
|
-
|
|
301
|
-
| Parameter | Type |
|
|
302
|
-
| ------ | ------ |
|
|
303
|
-
| `err` | `Error` |
|
|
304
|
-
| `stackTraces` | `CallSite`[] |
|
|
305
|
-
|
|
306
|
-
###### Returns
|
|
307
|
-
|
|
308
|
-
`any`
|
|
309
|
-
|
|
310
|
-
###### See
|
|
311
|
-
|
|
312
|
-
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
313
|
-
|
|
314
|
-
###### Inherited from
|
|
315
|
-
|
|
316
|
-
```ts
|
|
317
|
-
Error.prepareStackTrace
|
|
318
|
-
```
|
|
135
|
+
| Property | Modifier | Type | Inherited from | Defined in |
|
|
136
|
+
| ------ | ------ | ------ | ------ | ------ |
|
|
137
|
+
| <a id="_tag-1"></a> `_tag` | `readonly` | `"@amqp-contract/RpcCancelledError"` | `TaggedError("@amqp-contract/RpcCancelledError", { name: "RpcCancelledError", })._tag` | node\_modules/.pnpm/unthrown@0.2.0/node\_modules/unthrown/dist/index.d.mts:638 |
|
|
138
|
+
| <a id="cause-1"></a> `cause?` | `public` | `unknown` | `TaggedError("@amqp-contract/RpcCancelledError", { name: "RpcCancelledError", }).cause` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
|
|
139
|
+
| <a id="message-1"></a> `message` | `public` | `string` | `TaggedError("@amqp-contract/RpcCancelledError", { name: "RpcCancelledError", }).message` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
|
|
140
|
+
| <a id="name-1"></a> `name` | `public` | `string` | `TaggedError("@amqp-contract/RpcCancelledError", { name: "RpcCancelledError", }).name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
|
|
141
|
+
| <a id="rpcname"></a> `rpcName` | `readonly` | `string` | `TaggedError("@amqp-contract/RpcCancelledError", { name: "RpcCancelledError", }).rpcName` | [packages/client/src/errors.ts:42](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/errors.ts#L42) |
|
|
142
|
+
| <a id="stack-1"></a> `stack?` | `public` | `string` | `TaggedError("@amqp-contract/RpcCancelledError", { name: "RpcCancelledError", }).stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
|
|
319
143
|
|
|
320
144
|
***
|
|
321
145
|
|
|
322
146
|
### RpcTimeoutError
|
|
323
147
|
|
|
324
|
-
Defined in: [packages/client/src/errors.ts:
|
|
148
|
+
Defined in: [packages/client/src/errors.ts:15](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/errors.ts#L15)
|
|
325
149
|
|
|
326
150
|
Returned from `TypedAmqpClient.call()` when the configured `timeoutMs` elapses
|
|
327
151
|
before the RPC server publishes a reply with the matching `correlationId`.
|
|
328
152
|
|
|
329
153
|
The pending call is removed from the in-memory correlation map; if a reply
|
|
330
154
|
arrives after the timeout it is dropped (and a debug log is emitted by the
|
|
331
|
-
client if a logger is configured).
|
|
155
|
+
client if a logger is configured). Carries a namespaced `_tag` of
|
|
156
|
+
`"@amqp-contract/RpcTimeoutError"`; the `Error.name` is kept bare
|
|
157
|
+
(`"RpcTimeoutError"`).
|
|
332
158
|
|
|
333
159
|
#### Extends
|
|
334
160
|
|
|
335
|
-
- `
|
|
161
|
+
- `TaggedErrorInstance`<`"@amqp-contract/RpcTimeoutError"`, \{
|
|
162
|
+
`message`: `string`;
|
|
163
|
+
`rpcName`: `string`;
|
|
164
|
+
`timeoutMs`: `number`;
|
|
165
|
+
\}>
|
|
336
166
|
|
|
337
167
|
#### Constructors
|
|
338
168
|
|
|
@@ -342,7 +172,7 @@ client if a logger is configured).
|
|
|
342
172
|
new RpcTimeoutError(rpcName, timeoutMs): RpcTimeoutError;
|
|
343
173
|
```
|
|
344
174
|
|
|
345
|
-
Defined in: [packages/client/src/errors.ts:
|
|
175
|
+
Defined in: [packages/client/src/errors.ts:22](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/errors.ts#L22)
|
|
346
176
|
|
|
347
177
|
###### Parameters
|
|
348
178
|
|
|
@@ -358,126 +188,32 @@ Defined in: [packages/client/src/errors.ts:24](https://github.com/btravers/amqp-
|
|
|
358
188
|
###### Overrides
|
|
359
189
|
|
|
360
190
|
```ts
|
|
361
|
-
|
|
191
|
+
TaggedError("@amqp-contract/RpcTimeoutError", {
|
|
192
|
+
name: "RpcTimeoutError",
|
|
193
|
+
})<{
|
|
194
|
+
message: string;
|
|
195
|
+
rpcName: string;
|
|
196
|
+
timeoutMs: number;
|
|
197
|
+
}>.constructor
|
|
362
198
|
```
|
|
363
199
|
|
|
364
200
|
#### Properties
|
|
365
201
|
|
|
366
|
-
| Property | Modifier | Type |
|
|
367
|
-
| ------ | ------ | ------ | ------ | ------ |
|
|
368
|
-
| <a id="
|
|
369
|
-
| <a id="
|
|
370
|
-
| <a id="
|
|
371
|
-
| <a id="
|
|
372
|
-
| <a id="
|
|
373
|
-
| <a id="
|
|
374
|
-
| <a id="
|
|
375
|
-
|
|
376
|
-
#### Methods
|
|
377
|
-
|
|
378
|
-
##### captureStackTrace()
|
|
379
|
-
|
|
380
|
-
```ts
|
|
381
|
-
static captureStackTrace(targetObject, constructorOpt?): void;
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
Defined in: node\_modules/.pnpm/@types+node@24.12.2/node\_modules/@types/node/globals.d.ts:52
|
|
385
|
-
|
|
386
|
-
Creates a `.stack` property on `targetObject`, which when accessed returns
|
|
387
|
-
a string representing the location in the code at which
|
|
388
|
-
`Error.captureStackTrace()` was called.
|
|
389
|
-
|
|
390
|
-
```js
|
|
391
|
-
const myObject = {};
|
|
392
|
-
Error.captureStackTrace(myObject);
|
|
393
|
-
myObject.stack; // Similar to `new Error().stack`
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
The first line of the trace will be prefixed with
|
|
397
|
-
`${myObject.name}: ${myObject.message}`.
|
|
398
|
-
|
|
399
|
-
The optional `constructorOpt` argument accepts a function. If given, all frames
|
|
400
|
-
above `constructorOpt`, including `constructorOpt`, will be omitted from the
|
|
401
|
-
generated stack trace.
|
|
402
|
-
|
|
403
|
-
The `constructorOpt` argument is useful for hiding implementation
|
|
404
|
-
details of error generation from the user. For instance:
|
|
405
|
-
|
|
406
|
-
```js
|
|
407
|
-
function a() {
|
|
408
|
-
b();
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
function b() {
|
|
412
|
-
c();
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
function c() {
|
|
416
|
-
// Create an error without stack trace to avoid calculating the stack trace twice.
|
|
417
|
-
const { stackTraceLimit } = Error;
|
|
418
|
-
Error.stackTraceLimit = 0;
|
|
419
|
-
const error = new Error();
|
|
420
|
-
Error.stackTraceLimit = stackTraceLimit;
|
|
421
|
-
|
|
422
|
-
// Capture the stack trace above function b
|
|
423
|
-
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
|
|
424
|
-
throw error;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
a();
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
###### Parameters
|
|
431
|
-
|
|
432
|
-
| Parameter | Type |
|
|
433
|
-
| ------ | ------ |
|
|
434
|
-
| `targetObject` | `object` |
|
|
435
|
-
| `constructorOpt?` | `Function` |
|
|
436
|
-
|
|
437
|
-
###### Returns
|
|
438
|
-
|
|
439
|
-
`void`
|
|
440
|
-
|
|
441
|
-
###### Inherited from
|
|
442
|
-
|
|
443
|
-
```ts
|
|
444
|
-
Error.captureStackTrace
|
|
445
|
-
```
|
|
446
|
-
|
|
447
|
-
##### prepareStackTrace()
|
|
448
|
-
|
|
449
|
-
```ts
|
|
450
|
-
static prepareStackTrace(err, stackTraces): any;
|
|
451
|
-
```
|
|
452
|
-
|
|
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
|
|
471
|
-
|
|
472
|
-
```ts
|
|
473
|
-
Error.prepareStackTrace
|
|
474
|
-
```
|
|
202
|
+
| Property | Modifier | Type | Inherited from | Defined in |
|
|
203
|
+
| ------ | ------ | ------ | ------ | ------ |
|
|
204
|
+
| <a id="_tag-2"></a> `_tag` | `readonly` | `"@amqp-contract/RpcTimeoutError"` | `TaggedError("@amqp-contract/RpcTimeoutError", { name: "RpcTimeoutError", })._tag` | node\_modules/.pnpm/unthrown@0.2.0/node\_modules/unthrown/dist/index.d.mts:638 |
|
|
205
|
+
| <a id="cause-2"></a> `cause?` | `public` | `unknown` | `TaggedError("@amqp-contract/RpcTimeoutError", { name: "RpcTimeoutError", }).cause` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
|
|
206
|
+
| <a id="message-2"></a> `message` | `public` | `string` | `TaggedError("@amqp-contract/RpcTimeoutError", { name: "RpcTimeoutError", }).message` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
|
|
207
|
+
| <a id="name-2"></a> `name` | `public` | `string` | `TaggedError("@amqp-contract/RpcTimeoutError", { name: "RpcTimeoutError", }).name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
|
|
208
|
+
| <a id="rpcname-1"></a> `rpcName` | `readonly` | `string` | `TaggedError("@amqp-contract/RpcTimeoutError", { name: "RpcTimeoutError", }).rpcName` | [packages/client/src/errors.ts:19](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/errors.ts#L19) |
|
|
209
|
+
| <a id="stack-2"></a> `stack?` | `public` | `string` | `TaggedError("@amqp-contract/RpcTimeoutError", { name: "RpcTimeoutError", }).stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
|
|
210
|
+
| <a id="timeoutms"></a> `timeoutMs` | `readonly` | `number` | `TaggedError("@amqp-contract/RpcTimeoutError", { name: "RpcTimeoutError", }).timeoutMs` | [packages/client/src/errors.ts:20](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/errors.ts#L20) |
|
|
475
211
|
|
|
476
212
|
***
|
|
477
213
|
|
|
478
214
|
### TypedAmqpClient
|
|
479
215
|
|
|
480
|
-
Defined in: [packages/client/src/client.ts:
|
|
216
|
+
Defined in: [packages/client/src/client.ts:125](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L125)
|
|
481
217
|
|
|
482
218
|
Type-safe AMQP client for publishing messages
|
|
483
219
|
|
|
@@ -495,21 +231,21 @@ Type-safe AMQP client for publishing messages
|
|
|
495
231
|
call<TName>(
|
|
496
232
|
rpcName,
|
|
497
233
|
request,
|
|
498
|
-
options):
|
|
234
|
+
options): AsyncResult<ClientInferRpcResponseOutput<TContract, TName>,
|
|
499
235
|
| TechnicalError
|
|
500
236
|
| MessageValidationError
|
|
501
237
|
| RpcTimeoutError
|
|
502
238
|
| RpcCancelledError>;
|
|
503
239
|
```
|
|
504
240
|
|
|
505
|
-
Defined in: [packages/client/src/client.ts:
|
|
241
|
+
Defined in: [packages/client/src/client.ts:420](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L420)
|
|
506
242
|
|
|
507
243
|
Invoke an RPC defined via `defineRpc` and await the typed response.
|
|
508
244
|
|
|
509
245
|
The request payload is validated against the RPC's request schema, then
|
|
510
246
|
published to the AMQP default exchange with the server's queue name as
|
|
511
247
|
routing key, `replyTo` set to `amq.rabbitmq.reply-to`, and a fresh UUID
|
|
512
|
-
`correlationId`. The returned
|
|
248
|
+
`correlationId`. The returned AsyncResult resolves once a matching reply
|
|
513
249
|
arrives and validates against the response schema, or once `timeoutMs`
|
|
514
250
|
elapses (whichever comes first).
|
|
515
251
|
|
|
@@ -529,7 +265,7 @@ elapses (whichever comes first).
|
|
|
529
265
|
|
|
530
266
|
###### Returns
|
|
531
267
|
|
|
532
|
-
`
|
|
268
|
+
`AsyncResult`<[`ClientInferRpcResponseOutput`](#clientinferrpcresponseoutput)<`TContract`, `TName`>,
|
|
533
269
|
\| `TechnicalError`
|
|
534
270
|
\| [`MessageValidationError`](#messagevalidationerror)
|
|
535
271
|
\| [`RpcTimeoutError`](#rpctimeouterror)
|
|
@@ -539,23 +275,27 @@ elapses (whichever comes first).
|
|
|
539
275
|
|
|
540
276
|
```typescript
|
|
541
277
|
const result = await client.call('calculate', { a: 1, b: 2 }, { timeoutMs: 5_000 });
|
|
542
|
-
|
|
278
|
+
result.match({
|
|
279
|
+
ok: (value) => console.log(value.sum), // 3
|
|
280
|
+
err: (error) => console.error(error),
|
|
281
|
+
defect: (cause) => console.error(cause),
|
|
282
|
+
});
|
|
543
283
|
```
|
|
544
284
|
|
|
545
285
|
##### close()
|
|
546
286
|
|
|
547
287
|
```ts
|
|
548
|
-
close():
|
|
288
|
+
close(): AsyncResult<void, TechnicalError>;
|
|
549
289
|
```
|
|
550
290
|
|
|
551
|
-
Defined in: [packages/client/src/client.ts:
|
|
291
|
+
Defined in: [packages/client/src/client.ts:574](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L574)
|
|
552
292
|
|
|
553
293
|
Close the channel and connection. Cancels the reply consumer (if any) and
|
|
554
294
|
rejects every in-flight RPC call with `RpcCancelledError`.
|
|
555
295
|
|
|
556
296
|
###### Returns
|
|
557
297
|
|
|
558
|
-
`
|
|
298
|
+
`AsyncResult`<`void`, `TechnicalError`>
|
|
559
299
|
|
|
560
300
|
##### publish()
|
|
561
301
|
|
|
@@ -563,10 +303,10 @@ rejects every in-flight RPC call with `RpcCancelledError`.
|
|
|
563
303
|
publish<TName>(
|
|
564
304
|
publisherName,
|
|
565
305
|
message,
|
|
566
|
-
options?):
|
|
306
|
+
options?): AsyncResult<void, TechnicalError | MessageValidationError>;
|
|
567
307
|
```
|
|
568
308
|
|
|
569
|
-
Defined in: [packages/client/src/client.ts:
|
|
309
|
+
Defined in: [packages/client/src/client.ts:308](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L308)
|
|
570
310
|
|
|
571
311
|
Publish a message using a defined publisher.
|
|
572
312
|
|
|
@@ -586,7 +326,7 @@ Publish a message using a defined publisher.
|
|
|
586
326
|
|
|
587
327
|
###### Returns
|
|
588
328
|
|
|
589
|
-
`
|
|
329
|
+
`AsyncResult`<`void`, `TechnicalError` \| [`MessageValidationError`](#messagevalidationerror)>
|
|
590
330
|
|
|
591
331
|
###### Remarks
|
|
592
332
|
|
|
@@ -597,15 +337,15 @@ value already in options will be overwritten by the compression algorithm.
|
|
|
597
337
|
##### create()
|
|
598
338
|
|
|
599
339
|
```ts
|
|
600
|
-
static create<TContract>(__namedParameters):
|
|
340
|
+
static create<TContract>(__namedParameters): AsyncResult<TypedAmqpClient<TContract>, TechnicalError>;
|
|
601
341
|
```
|
|
602
342
|
|
|
603
|
-
Defined in: [packages/client/src/client.ts:
|
|
343
|
+
Defined in: [packages/client/src/client.ts:156](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L156)
|
|
604
344
|
|
|
605
345
|
Create a type-safe AMQP client from a contract.
|
|
606
346
|
|
|
607
347
|
Connection management (including automatic reconnection) is handled internally
|
|
608
|
-
by amqp-connection-manager via the [AmqpClient](https://
|
|
348
|
+
by amqp-connection-manager via the [AmqpClient](https://btravstack.github.io/amqp-contract/api/core#amqpclient). The client establishes
|
|
609
349
|
infrastructure asynchronously in the background once the connection is ready.
|
|
610
350
|
|
|
611
351
|
Connections are automatically shared across clients with the same URLs and
|
|
@@ -625,7 +365,7 @@ connection options, following RabbitMQ best practices.
|
|
|
625
365
|
|
|
626
366
|
###### Returns
|
|
627
367
|
|
|
628
|
-
`
|
|
368
|
+
`AsyncResult`<[`TypedAmqpClient`](#typedamqpclient)<`TContract`>, `TechnicalError`>
|
|
629
369
|
|
|
630
370
|
## Type Aliases
|
|
631
371
|
|
|
@@ -635,7 +375,7 @@ connection options, following RabbitMQ best practices.
|
|
|
635
375
|
type CallOptions = object;
|
|
636
376
|
```
|
|
637
377
|
|
|
638
|
-
Defined in: [packages/client/src/client.ts:
|
|
378
|
+
Defined in: [packages/client/src/client.ts:105](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L105)
|
|
639
379
|
|
|
640
380
|
Per-call options for `client.call()`.
|
|
641
381
|
|
|
@@ -643,8 +383,8 @@ Per-call options for `client.call()`.
|
|
|
643
383
|
|
|
644
384
|
| Property | Type | Description | Defined in |
|
|
645
385
|
| ------ | ------ | ------ | ------ |
|
|
646
|
-
| <a id="publishoptions"></a> `publishOptions?` | `Omit`<`AmqpClientPublishOptions`, `"replyTo"` \| `"correlationId"`> | Optional AMQP message properties to merge into the request. `replyTo` and `correlationId` are managed by the client and cannot be overridden. | [packages/client/src/client.ts:
|
|
647
|
-
| <a id="timeoutms-1"></a> `timeoutMs` | `number` | Maximum time in ms to wait for an RPC reply. If exceeded, the call resolves to `err(RpcTimeoutError)` and the in-memory correlation entry is cleared. A late reply arriving after the timeout is silently dropped. Required: RPC without a timeout is a footgun. | [packages/client/src/client.ts:
|
|
386
|
+
| <a id="publishoptions"></a> `publishOptions?` | `Omit`<`AmqpClientPublishOptions`, `"replyTo"` \| `"correlationId"`> | Optional AMQP message properties to merge into the request. `replyTo` and `correlationId` are managed by the client and cannot be overridden. | [packages/client/src/client.ts:119](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L119) |
|
|
387
|
+
| <a id="timeoutms-1"></a> `timeoutMs` | `number` | Maximum time in ms to wait for an RPC reply. If exceeded, the call resolves to `err(RpcTimeoutError)` and the in-memory correlation entry is cleared. A late reply arriving after the timeout is silently dropped. Required: RPC without a timeout is a footgun. | [packages/client/src/client.ts:113](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L113) |
|
|
648
388
|
|
|
649
389
|
***
|
|
650
390
|
|
|
@@ -654,7 +394,7 @@ Per-call options for `client.call()`.
|
|
|
654
394
|
type ClientInferPublisherInput<TContract, TName> = PublisherInferInput<InferPublisher<TContract, TName>>;
|
|
655
395
|
```
|
|
656
396
|
|
|
657
|
-
Defined in: [packages/client/src/types.ts:43](https://github.com/
|
|
397
|
+
Defined in: [packages/client/src/types.ts:43](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/types.ts#L43)
|
|
658
398
|
|
|
659
399
|
Input type accepted by `client.publish(name, ...)` for a specific publisher.
|
|
660
400
|
|
|
@@ -673,7 +413,7 @@ Input type accepted by `client.publish(name, ...)` for a specific publisher.
|
|
|
673
413
|
type ClientInferRpcRequestInput<TContract, TName> = InferRpc<TContract, TName> extends RpcDefinition<infer TRequest, MessageDefinition> ? TRequest extends MessageDefinition ? InferSchemaInput<TRequest["payload"]> : never : never;
|
|
674
414
|
```
|
|
675
415
|
|
|
676
|
-
Defined in: [packages/client/src/types.ts:61](https://github.com/
|
|
416
|
+
Defined in: [packages/client/src/types.ts:61](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/types.ts#L61)
|
|
677
417
|
|
|
678
418
|
Input type accepted by `client.call(name, request, ...)`.
|
|
679
419
|
|
|
@@ -692,7 +432,7 @@ Input type accepted by `client.call(name, request, ...)`.
|
|
|
692
432
|
type ClientInferRpcResponseOutput<TContract, TName> = InferRpc<TContract, TName> extends RpcDefinition<MessageDefinition, infer TResponse> ? TResponse extends MessageDefinition ? InferSchemaOutput<TResponse["payload"]> : never : never;
|
|
693
433
|
```
|
|
694
434
|
|
|
695
|
-
Defined in: [packages/client/src/types.ts:74](https://github.com/
|
|
435
|
+
Defined in: [packages/client/src/types.ts:74](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/types.ts#L74)
|
|
696
436
|
|
|
697
437
|
Output (validated) response type returned by `client.call(name, ...)`.
|
|
698
438
|
|
|
@@ -711,7 +451,7 @@ Output (validated) response type returned by `client.call(name, ...)`.
|
|
|
711
451
|
type CreateClientOptions<TContract> = object;
|
|
712
452
|
```
|
|
713
453
|
|
|
714
|
-
Defined in: [packages/client/src/client.ts:
|
|
454
|
+
Defined in: [packages/client/src/client.ts:76](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L76)
|
|
715
455
|
|
|
716
456
|
Options for creating a client
|
|
717
457
|
|
|
@@ -725,13 +465,13 @@ Options for creating a client
|
|
|
725
465
|
|
|
726
466
|
| Property | Type | Description | Defined in |
|
|
727
467
|
| ------ | ------ | ------ | ------ |
|
|
728
|
-
| <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | - | [packages/client/src/client.ts:
|
|
729
|
-
| <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://
|
|
730
|
-
| <a id="contract"></a> `contract` | `TContract` | - | [packages/client/src/client.ts:
|
|
731
|
-
| <a id="defaultpublishoptions"></a> `defaultPublishOptions?` | [`PublishOptions`](#publishoptions-1) | Default publish options that will be applied to all publish operations. These can be overridden by options passed to the publish method. By default, persistent is set to true for message durability. | [packages/client/src/client.ts:
|
|
732
|
-
| <a id="logger"></a> `logger?` | `Logger` | - | [packages/client/src/client.ts:
|
|
733
|
-
| <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/client/src/client.ts:
|
|
734
|
-
| <a id="urls"></a> `urls` | `ConnectionUrl`[] | - | [packages/client/src/client.ts:
|
|
468
|
+
| <a id="connectionoptions"></a> `connectionOptions?` | `AmqpConnectionManagerOptions` | - | [packages/client/src/client.ts:79](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L79) |
|
|
469
|
+
| <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/client/src/client.ts:99](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L99) |
|
|
470
|
+
| <a id="contract"></a> `contract` | `TContract` | - | [packages/client/src/client.ts:77](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L77) |
|
|
471
|
+
| <a id="defaultpublishoptions"></a> `defaultPublishOptions?` | [`PublishOptions`](#publishoptions-1) | Default publish options that will be applied to all publish operations. These can be overridden by options passed to the publish method. By default, persistent is set to true for message durability. | [packages/client/src/client.ts:92](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L92) |
|
|
472
|
+
| <a id="logger"></a> `logger?` | `Logger` | - | [packages/client/src/client.ts:80](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L80) |
|
|
473
|
+
| <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/client/src/client.ts:86](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L86) |
|
|
474
|
+
| <a id="urls"></a> `urls` | `ConnectionUrl`[] | - | [packages/client/src/client.ts:78](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L78) |
|
|
735
475
|
|
|
736
476
|
***
|
|
737
477
|
|
|
@@ -741,7 +481,7 @@ Options for creating a client
|
|
|
741
481
|
type PublishOptions = AmqpClientPublishOptions & object;
|
|
742
482
|
```
|
|
743
483
|
|
|
744
|
-
Defined in: [packages/client/src/client.ts:
|
|
484
|
+
Defined in: [packages/client/src/client.ts:64](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L64)
|
|
745
485
|
|
|
746
486
|
Publish options that extend amqp-client's PublishOptions with optional compression support.
|
|
747
487
|
|
|
@@ -749,4 +489,4 @@ Publish options that extend amqp-client's PublishOptions with optional compressi
|
|
|
749
489
|
|
|
750
490
|
| Name | Type | Description | Defined in |
|
|
751
491
|
| ------ | ------ | ------ | ------ |
|
|
752
|
-
| `compression?` | `CompressionAlgorithm` | Optional compression algorithm to use for the message payload. When specified, the message will be compressed using the chosen algorithm and the contentEncoding header will be set automatically. | [packages/client/src/client.ts:
|
|
492
|
+
| `compression?` | `CompressionAlgorithm` | Optional compression algorithm to use for the message payload. When specified, the message will be compressed using the chosen algorithm and the contentEncoding header will be set automatically. | [packages/client/src/client.ts:70](https://github.com/btravstack/amqp-contract/blob/5bdec81d9ab13131c5b7f699c426616cfbed2b5f/packages/client/src/client.ts#L70) |
|