@amqp-contract/contract 0.21.0 → 0.23.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 +31 -1
- package/dist/index.cjs +132 -51
- package/dist/index.d.cts +104 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +104 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +132 -52
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +306 -178
- package/package.json +4 -4
package/docs/index.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
type AnySchema = StandardSchemaV1;
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Defined in: [types.ts:12](https://github.com/btravers/amqp-contract/blob/
|
|
15
|
+
Defined in: [types.ts:12](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L12)
|
|
16
16
|
|
|
17
17
|
Any schema that conforms to Standard Schema v1.
|
|
18
18
|
|
|
@@ -32,7 +32,7 @@ https://github.com/standard-schema/standard-schema
|
|
|
32
32
|
type BaseExchangeDefinition<TName> = object;
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
Defined in: [types.ts:394](https://github.com/btravers/amqp-contract/blob/
|
|
35
|
+
Defined in: [types.ts:394](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L394)
|
|
36
36
|
|
|
37
37
|
Base definition of an AMQP exchange.
|
|
38
38
|
|
|
@@ -49,11 +49,11 @@ type and routing rules. This type contains properties common to all exchange typ
|
|
|
49
49
|
|
|
50
50
|
| Property | Type | Description | Defined in |
|
|
51
51
|
| ------ | ------ | ------ | ------ |
|
|
52
|
-
| <a id="arguments"></a> `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for advanced configuration. Common arguments include alternate-exchange for handling unroutable messages. | [types.ts:421](https://github.com/btravers/amqp-contract/blob/
|
|
53
|
-
| <a id="autodelete"></a> `autoDelete?` | `boolean` | If true, the exchange is deleted when all queues have finished using it. | [types.ts:409](https://github.com/btravers/amqp-contract/blob/
|
|
54
|
-
| <a id="durable"></a> `durable?` | `boolean` | If true, the exchange survives broker restarts. Durable exchanges are persisted to disk. **Default** `true` | [types.ts:404](https://github.com/btravers/amqp-contract/blob/
|
|
55
|
-
| <a id="internal"></a> `internal?` | `boolean` | If true, the exchange cannot be directly published to by clients. It can only receive messages from other exchanges via exchange-to-exchange bindings. | [types.ts:415](https://github.com/btravers/amqp-contract/blob/
|
|
56
|
-
| <a id="name"></a> `name` | `TName` | The name of the exchange. Must be unique within the RabbitMQ virtual host. | [types.ts:398](https://github.com/btravers/amqp-contract/blob/
|
|
52
|
+
| <a id="arguments"></a> `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for advanced configuration. Common arguments include alternate-exchange for handling unroutable messages. | [types.ts:421](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L421) |
|
|
53
|
+
| <a id="autodelete"></a> `autoDelete?` | `boolean` | If true, the exchange is deleted when all queues have finished using it. | [types.ts:409](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L409) |
|
|
54
|
+
| <a id="durable"></a> `durable?` | `boolean` | If true, the exchange survives broker restarts. Durable exchanges are persisted to disk. **Default** `true` | [types.ts:404](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L404) |
|
|
55
|
+
| <a id="internal"></a> `internal?` | `boolean` | If true, the exchange cannot be directly published to by clients. It can only receive messages from other exchanges via exchange-to-exchange bindings. | [types.ts:415](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L415) |
|
|
56
|
+
| <a id="name"></a> `name` | `TName` | The name of the exchange. Must be unique within the RabbitMQ virtual host. | [types.ts:398](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L398) |
|
|
57
57
|
|
|
58
58
|
***
|
|
59
59
|
|
|
@@ -65,7 +65,7 @@ type BindingDefinition =
|
|
|
65
65
|
| ExchangeBindingDefinition;
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
Defined in: [types.ts:891](https://github.com/btravers/amqp-contract/blob/
|
|
68
|
+
Defined in: [types.ts:891](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L891)
|
|
69
69
|
|
|
70
70
|
Union type of all binding definitions.
|
|
71
71
|
|
|
@@ -81,7 +81,7 @@ A binding can be either:
|
|
|
81
81
|
type BindingPattern<S> = S extends "" ? never : S;
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
Defined in: [builder/routing-types.ts:52](https://github.com/btravers/amqp-contract/blob/
|
|
84
|
+
Defined in: [builder/routing-types.ts:52](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/routing-types.ts#L52)
|
|
85
85
|
|
|
86
86
|
Type-safe binding pattern that validates basic format and wildcards.
|
|
87
87
|
|
|
@@ -116,7 +116,7 @@ type Invalid = BindingPattern<"">; // never (empty string)
|
|
|
116
116
|
type BridgedPublisherConfig<TMessage, TBridgeExchange, TTargetExchange> = object;
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
Defined in: [builder/command.ts:61](https://github.com/btravers/amqp-contract/blob/
|
|
119
|
+
Defined in: [builder/command.ts:61](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L61)
|
|
120
120
|
|
|
121
121
|
Configuration for a bridged command publisher.
|
|
122
122
|
|
|
@@ -135,11 +135,11 @@ messages to the target exchange (remote domain) via an exchange-to-exchange bind
|
|
|
135
135
|
|
|
136
136
|
| Property | Type | Description | Defined in |
|
|
137
137
|
| ------ | ------ | ------ | ------ |
|
|
138
|
-
| <a id="__brand"></a> `__brand` | `"BridgedPublisherConfig"` | Discriminator to identify this as a bridged publisher config | [builder/command.ts:67](https://github.com/btravers/amqp-contract/blob/
|
|
139
|
-
| <a id="bridgeexchange"></a> `bridgeExchange` | `TBridgeExchange` | The bridge (local domain) exchange | [builder/command.ts:73](https://github.com/btravers/amqp-contract/blob/
|
|
140
|
-
| <a id="exchangebinding"></a> `exchangeBinding` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) | The exchange-to-exchange binding (bridge → target) | [builder/command.ts:71](https://github.com/btravers/amqp-contract/blob/
|
|
141
|
-
| <a id="publisher"></a> `publisher` | [`PublisherDefinition`](#publisherdefinition)<`TMessage`> | The publisher definition (publishes to bridge exchange) | [builder/command.ts:69](https://github.com/btravers/amqp-contract/blob/
|
|
142
|
-
| <a id="targetexchange"></a> `targetExchange` | `TTargetExchange` | The target (remote domain) exchange | [builder/command.ts:75](https://github.com/btravers/amqp-contract/blob/
|
|
138
|
+
| <a id="__brand"></a> `__brand` | `"BridgedPublisherConfig"` | Discriminator to identify this as a bridged publisher config | [builder/command.ts:67](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L67) |
|
|
139
|
+
| <a id="bridgeexchange"></a> `bridgeExchange` | `TBridgeExchange` | The bridge (local domain) exchange | [builder/command.ts:73](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L73) |
|
|
140
|
+
| <a id="exchangebinding"></a> `exchangeBinding` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) | The exchange-to-exchange binding (bridge → target) | [builder/command.ts:71](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L71) |
|
|
141
|
+
| <a id="publisher"></a> `publisher` | [`PublisherDefinition`](#publisherdefinition)<`TMessage`> | The publisher definition (publishes to bridge exchange) | [builder/command.ts:69](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L69) |
|
|
142
|
+
| <a id="targetexchange"></a> `targetExchange` | `TTargetExchange` | The target (remote domain) exchange | [builder/command.ts:75](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L75) |
|
|
143
143
|
|
|
144
144
|
***
|
|
145
145
|
|
|
@@ -149,7 +149,7 @@ messages to the target exchange (remote domain) via an exchange-to-exchange bind
|
|
|
149
149
|
type BridgedPublisherConfigBase = object;
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
Defined in: [types.ts:1024](https://github.com/btravers/amqp-contract/blob/
|
|
152
|
+
Defined in: [types.ts:1024](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1024)
|
|
153
153
|
|
|
154
154
|
Base type for bridged publisher configuration.
|
|
155
155
|
|
|
@@ -164,11 +164,11 @@ defineCommandPublisher with bridgeExchange option
|
|
|
164
164
|
|
|
165
165
|
| Property | Type | Defined in |
|
|
166
166
|
| ------ | ------ | ------ |
|
|
167
|
-
| <a id="__brand-1"></a> `__brand` | `"BridgedPublisherConfig"` | [types.ts:1025](https://github.com/btravers/amqp-contract/blob/
|
|
168
|
-
| <a id="bridgeexchange-1"></a> `bridgeExchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:1028](https://github.com/btravers/amqp-contract/blob/
|
|
169
|
-
| <a id="exchangebinding-1"></a> `exchangeBinding` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) | [types.ts:1027](https://github.com/btravers/amqp-contract/blob/
|
|
170
|
-
| <a id="publisher-1"></a> `publisher` | [`PublisherDefinition`](#publisherdefinition) | [types.ts:1026](https://github.com/btravers/amqp-contract/blob/
|
|
171
|
-
| <a id="targetexchange-1"></a> `targetExchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:1029](https://github.com/btravers/amqp-contract/blob/
|
|
167
|
+
| <a id="__brand-1"></a> `__brand` | `"BridgedPublisherConfig"` | [types.ts:1025](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1025) |
|
|
168
|
+
| <a id="bridgeexchange-1"></a> `bridgeExchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:1028](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1028) |
|
|
169
|
+
| <a id="exchangebinding-1"></a> `exchangeBinding` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) | [types.ts:1027](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1027) |
|
|
170
|
+
| <a id="publisher-1"></a> `publisher` | [`PublisherDefinition`](#publisherdefinition) | [types.ts:1026](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1026) |
|
|
171
|
+
| <a id="targetexchange-1"></a> `targetExchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:1029](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1029) |
|
|
172
172
|
|
|
173
173
|
***
|
|
174
174
|
|
|
@@ -178,7 +178,7 @@ defineCommandPublisher with bridgeExchange option
|
|
|
178
178
|
type ClassicQueueDefinition<TName> = BaseQueueDefinition<TName> & object;
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
Defined in: [types.ts:608](https://github.com/btravers/amqp-contract/blob/
|
|
181
|
+
Defined in: [types.ts:608](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L608)
|
|
182
182
|
|
|
183
183
|
Definition of a classic queue.
|
|
184
184
|
|
|
@@ -189,11 +189,11 @@ specific features not supported by quorum queues (e.g., exclusive queues, auto-d
|
|
|
189
189
|
|
|
190
190
|
| Name | Type | Description | Defined in |
|
|
191
191
|
| ------ | ------ | ------ | ------ |
|
|
192
|
-
| `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. | [types.ts:628](https://github.com/btravers/amqp-contract/blob/
|
|
193
|
-
| `durable` | `boolean` | If true, the queue survives broker restarts. Durable queues are persisted to disk. | [types.ts:617](https://github.com/btravers/amqp-contract/blob/
|
|
194
|
-
| `exclusive?` | `boolean` | If true, the queue can only be used by the declaring connection and is deleted when that connection closes. Exclusive queues are private to the connection. | [types.ts:623](https://github.com/btravers/amqp-contract/blob/
|
|
195
|
-
| `maxPriority?` | `number` | Maximum priority level for priority queue (1-255, recommended: 1-10). Sets x-max-priority argument. | [types.ts:634](https://github.com/btravers/amqp-contract/blob/
|
|
196
|
-
| `type` | `"classic"` | Queue type discriminator: classic queue. | [types.ts:612](https://github.com/btravers/amqp-contract/blob/
|
|
192
|
+
| `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. | [types.ts:628](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L628) |
|
|
193
|
+
| `durable` | `boolean` | If true, the queue survives broker restarts. Durable queues are persisted to disk. | [types.ts:617](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L617) |
|
|
194
|
+
| `exclusive?` | `boolean` | If true, the queue can only be used by the declaring connection and is deleted when that connection closes. Exclusive queues are private to the connection. | [types.ts:623](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L623) |
|
|
195
|
+
| `maxPriority?` | `number` | Maximum priority level for priority queue (1-255, recommended: 1-10). Sets x-max-priority argument. | [types.ts:634](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L634) |
|
|
196
|
+
| `type` | `"classic"` | Queue type discriminator: classic queue. | [types.ts:612](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L612) |
|
|
197
197
|
|
|
198
198
|
#### Type Parameters
|
|
199
199
|
|
|
@@ -209,7 +209,7 @@ specific features not supported by quorum queues (e.g., exclusive queues, auto-d
|
|
|
209
209
|
type ClassicQueueOptions = BaseQueueOptions & object;
|
|
210
210
|
```
|
|
211
211
|
|
|
212
|
-
Defined in: [types.ts:342](https://github.com/btravers/amqp-contract/blob/
|
|
212
|
+
Defined in: [types.ts:342](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L342)
|
|
213
213
|
|
|
214
214
|
Options for creating a classic queue.
|
|
215
215
|
|
|
@@ -223,11 +223,11 @@ Classic queues support all traditional RabbitMQ features including:
|
|
|
223
223
|
|
|
224
224
|
| Name | Type | Description | Defined in |
|
|
225
225
|
| ------ | ------ | ------ | ------ |
|
|
226
|
-
| `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. | [types.ts:363](https://github.com/btravers/amqp-contract/blob/
|
|
227
|
-
| `durable?` | `boolean` | If true, the queue survives broker restarts. Durable queues are persisted to disk. **Default** `true` | [types.ts:352](https://github.com/btravers/amqp-contract/blob/
|
|
228
|
-
| `exclusive?` | `boolean` | If true, the queue can only be used by the declaring connection and is deleted when that connection closes. Exclusive queues are private to the connection. | [types.ts:358](https://github.com/btravers/amqp-contract/blob/
|
|
229
|
-
| `maxPriority?` | `number` | Maximum priority level for priority queue (1-255, recommended: 1-10). Sets x-max-priority argument. | [types.ts:369](https://github.com/btravers/amqp-contract/blob/
|
|
230
|
-
| `type` | `"classic"` | Queue type: classic (for special cases) | [types.ts:346](https://github.com/btravers/amqp-contract/blob/
|
|
226
|
+
| `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. | [types.ts:363](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L363) |
|
|
227
|
+
| `durable?` | `boolean` | If true, the queue survives broker restarts. Durable queues are persisted to disk. **Default** `true` | [types.ts:352](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L352) |
|
|
228
|
+
| `exclusive?` | `boolean` | If true, the queue can only be used by the declaring connection and is deleted when that connection closes. Exclusive queues are private to the connection. | [types.ts:358](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L358) |
|
|
229
|
+
| `maxPriority?` | `number` | Maximum priority level for priority queue (1-255, recommended: 1-10). Sets x-max-priority argument. | [types.ts:369](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L369) |
|
|
230
|
+
| `type` | `"classic"` | Queue type: classic (for special cases) | [types.ts:346](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L346) |
|
|
231
231
|
|
|
232
232
|
#### Example
|
|
233
233
|
|
|
@@ -246,7 +246,7 @@ const priorityQueue = defineQueue('tasks', {
|
|
|
246
246
|
type CommandConsumerConfig<TMessage, TExchange, TRoutingKey, TQueue> = object;
|
|
247
247
|
```
|
|
248
248
|
|
|
249
|
-
Defined in: [builder/command.ts:29](https://github.com/btravers/amqp-contract/blob/
|
|
249
|
+
Defined in: [builder/command.ts:29](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L29)
|
|
250
250
|
|
|
251
251
|
Configuration for a command consumer.
|
|
252
252
|
|
|
@@ -266,13 +266,13 @@ The consumer "owns" the queue, and publishers send commands to it.
|
|
|
266
266
|
|
|
267
267
|
| Property | Type | Description | Defined in |
|
|
268
268
|
| ------ | ------ | ------ | ------ |
|
|
269
|
-
| <a id="__brand-2"></a> `__brand` | `"CommandConsumerConfig"` | Discriminator to identify this as a command consumer config | [builder/command.ts:36](https://github.com/btravers/amqp-contract/blob/
|
|
270
|
-
| <a id="binding"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | The binding connecting the queue to the exchange | [builder/command.ts:40](https://github.com/btravers/amqp-contract/blob/
|
|
271
|
-
| <a id="consumer"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition)<`TMessage`> | The consumer definition for processing commands | [builder/command.ts:38](https://github.com/btravers/amqp-contract/blob/
|
|
272
|
-
| <a id="exchange"></a> `exchange` | `TExchange` | The exchange that receives commands | [builder/command.ts:42](https://github.com/btravers/amqp-contract/blob/
|
|
273
|
-
| <a id="message"></a> `message` | `TMessage` | The message definition | [builder/command.ts:46](https://github.com/btravers/amqp-contract/blob/
|
|
274
|
-
| <a id="queue"></a> `queue` | `TQueue` | The queue this consumer reads from | [builder/command.ts:44](https://github.com/btravers/amqp-contract/blob/
|
|
275
|
-
| <a id="routingkey"></a> `routingKey` | `TRoutingKey` | The routing key pattern for the binding | [builder/command.ts:48](https://github.com/btravers/amqp-contract/blob/
|
|
269
|
+
| <a id="__brand-2"></a> `__brand` | `"CommandConsumerConfig"` | Discriminator to identify this as a command consumer config | [builder/command.ts:36](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L36) |
|
|
270
|
+
| <a id="binding"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | The binding connecting the queue to the exchange | [builder/command.ts:40](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L40) |
|
|
271
|
+
| <a id="consumer"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition)<`TMessage`> | The consumer definition for processing commands | [builder/command.ts:38](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L38) |
|
|
272
|
+
| <a id="exchange"></a> `exchange` | `TExchange` | The exchange that receives commands | [builder/command.ts:42](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L42) |
|
|
273
|
+
| <a id="message"></a> `message` | `TMessage` | The message definition | [builder/command.ts:46](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L46) |
|
|
274
|
+
| <a id="queue"></a> `queue` | `TQueue` | The queue this consumer reads from | [builder/command.ts:44](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L44) |
|
|
275
|
+
| <a id="routingkey"></a> `routingKey` | `TRoutingKey` | The routing key pattern for the binding | [builder/command.ts:48](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L48) |
|
|
276
276
|
|
|
277
277
|
***
|
|
278
278
|
|
|
@@ -282,7 +282,7 @@ The consumer "owns" the queue, and publishers send commands to it.
|
|
|
282
282
|
type CommandConsumerConfigBase = object;
|
|
283
283
|
```
|
|
284
284
|
|
|
285
|
-
Defined in: [types.ts:988](https://github.com/btravers/amqp-contract/blob/
|
|
285
|
+
Defined in: [types.ts:988](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L988)
|
|
286
286
|
|
|
287
287
|
Base type for command consumer configuration.
|
|
288
288
|
|
|
@@ -297,13 +297,13 @@ defineCommandConsumer for creating command consumers
|
|
|
297
297
|
|
|
298
298
|
| Property | Type | Defined in |
|
|
299
299
|
| ------ | ------ | ------ |
|
|
300
|
-
| <a id="__brand-3"></a> `__brand` | `"CommandConsumerConfig"` | [types.ts:989](https://github.com/btravers/amqp-contract/blob/
|
|
301
|
-
| <a id="binding-1"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | [types.ts:991](https://github.com/btravers/amqp-contract/blob/
|
|
302
|
-
| <a id="consumer-1"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition) | [types.ts:990](https://github.com/btravers/amqp-contract/blob/
|
|
303
|
-
| <a id="exchange-1"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:992](https://github.com/btravers/amqp-contract/blob/
|
|
304
|
-
| <a id="message-1"></a> `message` | [`MessageDefinition`](#messagedefinition) | [types.ts:994](https://github.com/btravers/amqp-contract/blob/
|
|
305
|
-
| <a id="queue-1"></a> `queue` | [`QueueEntry`](#queueentry) | [types.ts:993](https://github.com/btravers/amqp-contract/blob/
|
|
306
|
-
| <a id="routingkey-1"></a> `routingKey` | `string` \| `undefined` | [types.ts:995](https://github.com/btravers/amqp-contract/blob/
|
|
300
|
+
| <a id="__brand-3"></a> `__brand` | `"CommandConsumerConfig"` | [types.ts:989](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L989) |
|
|
301
|
+
| <a id="binding-1"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | [types.ts:991](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L991) |
|
|
302
|
+
| <a id="consumer-1"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition) | [types.ts:990](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L990) |
|
|
303
|
+
| <a id="exchange-1"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:992](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L992) |
|
|
304
|
+
| <a id="message-1"></a> `message` | [`MessageDefinition`](#messagedefinition) | [types.ts:994](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L994) |
|
|
305
|
+
| <a id="queue-1"></a> `queue` | [`QueueEntry`](#queueentry) | [types.ts:993](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L993) |
|
|
306
|
+
| <a id="routingkey-1"></a> `routingKey` | `string` \| `undefined` | [types.ts:995](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L995) |
|
|
307
307
|
|
|
308
308
|
***
|
|
309
309
|
|
|
@@ -313,7 +313,7 @@ defineCommandConsumer for creating command consumers
|
|
|
313
313
|
type CompressionAlgorithm = "gzip" | "deflate";
|
|
314
314
|
```
|
|
315
315
|
|
|
316
|
-
Defined in: [types.ts:199](https://github.com/btravers/amqp-contract/blob/
|
|
316
|
+
Defined in: [types.ts:199](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L199)
|
|
317
317
|
|
|
318
318
|
Supported compression algorithms for message payloads.
|
|
319
319
|
|
|
@@ -351,7 +351,7 @@ await client.publish("orderCreated", payload, {
|
|
|
351
351
|
type ConsumerDefinition<TMessage> = object;
|
|
352
352
|
```
|
|
353
353
|
|
|
354
|
-
Defined in: [types.ts:952](https://github.com/btravers/amqp-contract/blob/
|
|
354
|
+
Defined in: [types.ts:952](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L952)
|
|
355
355
|
|
|
356
356
|
Definition of a message consumer.
|
|
357
357
|
|
|
@@ -379,8 +379,8 @@ const consumer: ConsumerDefinition = {
|
|
|
379
379
|
|
|
380
380
|
| Property | Type | Description | Defined in |
|
|
381
381
|
| ------ | ------ | ------ | ------ |
|
|
382
|
-
| <a id="message-2"></a> `message` | `TMessage` | The message definition including the payload schema | [types.ts:957](https://github.com/btravers/amqp-contract/blob/
|
|
383
|
-
| <a id="queue-2"></a> `queue` | [`QueueEntry`](#queueentry) | The queue to consume messages from | [types.ts:954](https://github.com/btravers/amqp-contract/blob/
|
|
382
|
+
| <a id="message-2"></a> `message` | `TMessage` | The message definition including the payload schema | [types.ts:957](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L957) |
|
|
383
|
+
| <a id="queue-2"></a> `queue` | [`QueueEntry`](#queueentry) | The queue to consume messages from | [types.ts:954](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L954) |
|
|
384
384
|
|
|
385
385
|
***
|
|
386
386
|
|
|
@@ -393,7 +393,7 @@ type ConsumerEntry =
|
|
|
393
393
|
| CommandConsumerConfigBase;
|
|
394
394
|
```
|
|
395
395
|
|
|
396
|
-
Defined in: [types.ts:
|
|
396
|
+
Defined in: [types.ts:1162](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1162)
|
|
397
397
|
|
|
398
398
|
Consumer entry that can be passed to defineContract's consumers section.
|
|
399
399
|
|
|
@@ -410,7 +410,7 @@ Can be either:
|
|
|
410
410
|
type ContractDefinition = object;
|
|
411
411
|
```
|
|
412
412
|
|
|
413
|
-
Defined in: [types.ts:
|
|
413
|
+
Defined in: [types.ts:1093](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1093)
|
|
414
414
|
|
|
415
415
|
Complete AMQP contract definition (output type).
|
|
416
416
|
|
|
@@ -449,11 +449,12 @@ const contract: ContractDefinition = {
|
|
|
449
449
|
|
|
450
450
|
| Property | Type | Description | Defined in |
|
|
451
451
|
| ------ | ------ | ------ | ------ |
|
|
452
|
-
| <a id="bindings"></a> `bindings?` | `Record`<`string`, [`BindingDefinition`](#bindingdefinition)> | Named binding definitions. Bindings can be queue-to-exchange or exchange-to-exchange. | [types.ts:
|
|
453
|
-
| <a id="consumers"></a> `consumers?` | `Record`<`string`, [`ConsumerDefinition`](#consumerdefinition)> | Named consumer definitions. Each key requires a corresponding handler in the TypedAmqpWorker. The handler will be fully typed based on the message schema. | [types.ts:
|
|
454
|
-
| <a id="exchanges"></a> `exchanges?` | `Record`<`string`, [`ExchangeDefinition`](#exchangedefinition)> | Named exchange definitions. Each key becomes available as a named resource in the contract. | [types.ts:
|
|
455
|
-
| <a id="publishers"></a> `publishers?` | `Record`<`string`, [`PublisherDefinition`](#publisherdefinition)> | Named publisher definitions. Each key becomes a method on the TypedAmqpClient for publishing messages. The method will be fully typed based on the message schema. | [types.ts:
|
|
456
|
-
| <a id="queues"></a> `queues?` | `Record`<`string`, [`QueueEntry`](#queueentry)> | Named queue definitions. Each key becomes available as a named resource in the contract. When a queue has TTL-backoff retry configured, pass the `QueueWithTtlBackoffInfrastructure` object returned by `defineQueue`. The wait queue, exchanges, and bindings will be automatically added. | [types.ts:
|
|
452
|
+
| <a id="bindings"></a> `bindings?` | `Record`<`string`, [`BindingDefinition`](#bindingdefinition)> | Named binding definitions. Bindings can be queue-to-exchange or exchange-to-exchange. | [types.ts:1113](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1113) |
|
|
453
|
+
| <a id="consumers"></a> `consumers?` | `Record`<`string`, [`ConsumerDefinition`](#consumerdefinition)> | Named consumer definitions. Each key requires a corresponding handler in the TypedAmqpWorker. The handler will be fully typed based on the message schema. | [types.ts:1127](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1127) |
|
|
454
|
+
| <a id="exchanges"></a> `exchanges?` | `Record`<`string`, [`ExchangeDefinition`](#exchangedefinition)> | Named exchange definitions. Each key becomes available as a named resource in the contract. | [types.ts:1098](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1098) |
|
|
455
|
+
| <a id="publishers"></a> `publishers?` | `Record`<`string`, [`PublisherDefinition`](#publisherdefinition)> | Named publisher definitions. Each key becomes a method on the TypedAmqpClient for publishing messages. The method will be fully typed based on the message schema. | [types.ts:1120](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1120) |
|
|
456
|
+
| <a id="queues"></a> `queues?` | `Record`<`string`, [`QueueEntry`](#queueentry)> | Named queue definitions. Each key becomes available as a named resource in the contract. When a queue has TTL-backoff retry configured, pass the `QueueWithTtlBackoffInfrastructure` object returned by `defineQueue`. The wait queue, exchanges, and bindings will be automatically added. | [types.ts:1107](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1107) |
|
|
457
|
+
| <a id="rpcs"></a> `rpcs?` | `Record`<`string`, [`RpcDefinition`](#rpcdefinition)> | Named RPC definitions. Each key gets: - A handler in the TypedAmqpWorker that returns the typed response. - A `client.call(name, request, options)` method on the TypedAmqpClient. RPC entries do not appear in `publishers` or `consumers` because each end of an RPC plays both roles (publisher of one direction, consumer of the other). | [types.ts:1138](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1138) |
|
|
457
458
|
|
|
458
459
|
***
|
|
459
460
|
|
|
@@ -463,7 +464,7 @@ const contract: ContractDefinition = {
|
|
|
463
464
|
type ContractDefinitionInput = object;
|
|
464
465
|
```
|
|
465
466
|
|
|
466
|
-
Defined in: [types.ts:
|
|
467
|
+
Defined in: [types.ts:1191](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1191)
|
|
467
468
|
|
|
468
469
|
Contract definition input type with automatic extraction of event/command patterns.
|
|
469
470
|
|
|
@@ -495,8 +496,9 @@ defineContract - Processes this input and returns a ContractDefinition
|
|
|
495
496
|
|
|
496
497
|
| Property | Type | Description | Defined in |
|
|
497
498
|
| ------ | ------ | ------ | ------ |
|
|
498
|
-
| <a id="consumers-1"></a> `consumers?` | `Record`<`string`, [`ConsumerEntry`](#consumerentry)> | Named consumer definitions. Can accept: - ConsumerDefinition from defineConsumer - EventConsumerResult from defineEventConsumer (binding auto-extracted) - CommandConsumerConfig from defineCommandConsumer (binding auto-extracted) | [types.ts:
|
|
499
|
-
| <a id="publishers-1"></a> `publishers?` | `Record`<`string`, [`PublisherEntry`](#publisherentry)> | Named publisher definitions. Can accept: - PublisherDefinition from definePublisher - EventPublisherConfig from defineEventPublisher (auto-extracted to publisher) | [types.ts:
|
|
499
|
+
| <a id="consumers-1"></a> `consumers?` | `Record`<`string`, [`ConsumerEntry`](#consumerentry)> | Named consumer definitions. Can accept: - ConsumerDefinition from defineConsumer - EventConsumerResult from defineEventConsumer (binding auto-extracted) - CommandConsumerConfig from defineCommandConsumer (binding auto-extracted) | [types.ts:1209](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1209) |
|
|
500
|
+
| <a id="publishers-1"></a> `publishers?` | `Record`<`string`, [`PublisherEntry`](#publisherentry)> | Named publisher definitions. Can accept: - PublisherDefinition from definePublisher - EventPublisherConfig from defineEventPublisher (auto-extracted to publisher) | [types.ts:1199](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1199) |
|
|
501
|
+
| <a id="rpcs-1"></a> `rpcs?` | `Record`<`string`, [`RpcDefinition`](#rpcdefinition)> | Named RPC definitions from `defineRpc`. Each entry contributes its queue (and DLX if any) to the contract topology and exposes a typed `client.call(name, ...)` / worker handler pair. | [types.ts:1216](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1216) |
|
|
500
502
|
|
|
501
503
|
***
|
|
502
504
|
|
|
@@ -506,7 +508,7 @@ defineContract - Processes this input and returns a ContractDefinition
|
|
|
506
508
|
type ContractOutput<TContract> = object;
|
|
507
509
|
```
|
|
508
510
|
|
|
509
|
-
Defined in: [types.ts:
|
|
511
|
+
Defined in: [types.ts:1533](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1533)
|
|
510
512
|
|
|
511
513
|
Contract output type with all resources extracted and properly typed.
|
|
512
514
|
|
|
@@ -527,11 +529,12 @@ This type represents the fully expanded contract with:
|
|
|
527
529
|
|
|
528
530
|
| Property | Type | Defined in |
|
|
529
531
|
| ------ | ------ | ------ |
|
|
530
|
-
| <a id="bindings-1"></a> `bindings` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractBindingsFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractExchangeBindingsFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractExchangeBindingsFromPublishers`<`TContract`\[`"publishers"`\]> : `object` | [types.ts:
|
|
531
|
-
| <a id="consumers-2"></a> `consumers` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractConsumerDefinitions`<`TContract`\[`"consumers"`\]> : `object` | [types.ts:
|
|
532
|
-
| <a id="exchanges-1"></a> `exchanges` | `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractExchangesFromPublishers`<`TContract`\[`"publishers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractDeadLetterExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractBridgeExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractTargetExchangesFromPublishers`<`TContract`\[`"publishers"`\]> : `object` | [types.ts:
|
|
533
|
-
| <a id="publishers-2"></a> `publishers` | `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractPublisherDefinitions`<`TContract`\[`"publishers"`\]> : `object` | [types.ts:
|
|
534
|
-
| <a id="queues-1"></a> `queues` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractQueuesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` | [types.ts:
|
|
532
|
+
| <a id="bindings-1"></a> `bindings` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractBindingsFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractExchangeBindingsFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractExchangeBindingsFromPublishers`<`TContract`\[`"publishers"`\]> : `object` | [types.ts:1558](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1558) |
|
|
533
|
+
| <a id="consumers-2"></a> `consumers` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractConsumerDefinitions`<`TContract`\[`"consumers"`\]> : `object` | [types.ts:1570](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1570) |
|
|
534
|
+
| <a id="exchanges-1"></a> `exchanges` | `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractExchangesFromPublishers`<`TContract`\[`"publishers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractDeadLetterExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractBridgeExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractTargetExchangesFromPublishers`<`TContract`\[`"publishers"`\]> : `object` & `TContract`\[`"rpcs"`\] *extends* `Record`<`string`, [`RpcDefinition`](#rpcdefinition)> ? `ExtractDeadLetterExchangesFromRpcs`<`TContract`\[`"rpcs"`\]> : `object` | [types.ts:1534](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1534) |
|
|
535
|
+
| <a id="publishers-2"></a> `publishers` | `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractPublisherDefinitions`<`TContract`\[`"publishers"`\]> : `object` | [types.ts:1567](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1567) |
|
|
536
|
+
| <a id="queues-1"></a> `queues` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractQueuesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"rpcs"`\] *extends* `Record`<`string`, [`RpcDefinition`](#rpcdefinition)> ? `ExtractQueuesFromRpcs`<`TContract`\[`"rpcs"`\]> : `object` | [types.ts:1552](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1552) |
|
|
537
|
+
| <a id="rpcs-2"></a> `rpcs` | `TContract`\[`"rpcs"`\] *extends* `Record`<`string`, [`RpcDefinition`](#rpcdefinition)> ? `TContract`\[`"rpcs"`\] : `object` | [types.ts:1573](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1573) |
|
|
535
538
|
|
|
536
539
|
***
|
|
537
540
|
|
|
@@ -541,7 +544,7 @@ This type represents the fully expanded contract with:
|
|
|
541
544
|
type DeadLetterConfig = object;
|
|
542
545
|
```
|
|
543
546
|
|
|
544
|
-
Defined in: [types.ts:518](https://github.com/btravers/amqp-contract/blob/
|
|
547
|
+
Defined in: [types.ts:518](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L518)
|
|
545
548
|
|
|
546
549
|
Configuration for dead letter exchange (DLX) on a queue.
|
|
547
550
|
|
|
@@ -553,8 +556,8 @@ or storage.
|
|
|
553
556
|
|
|
554
557
|
| Property | Type | Description | Defined in |
|
|
555
558
|
| ------ | ------ | ------ | ------ |
|
|
556
|
-
| <a id="exchange-2"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | The exchange to send dead-lettered messages to. This exchange must be declared in the contract. | [types.ts:523](https://github.com/btravers/amqp-contract/blob/
|
|
557
|
-
| <a id="routingkey-2"></a> `routingKey?` | `string` | Optional routing key to use when forwarding messages to the dead letter exchange. If not specified, the original message routing key is used. | [types.ts:529](https://github.com/btravers/amqp-contract/blob/
|
|
559
|
+
| <a id="exchange-2"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | The exchange to send dead-lettered messages to. This exchange must be declared in the contract. | [types.ts:523](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L523) |
|
|
560
|
+
| <a id="routingkey-2"></a> `routingKey?` | `string` | Optional routing key to use when forwarding messages to the dead letter exchange. If not specified, the original message routing key is used. | [types.ts:529](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L529) |
|
|
558
561
|
|
|
559
562
|
***
|
|
560
563
|
|
|
@@ -566,7 +569,7 @@ type DefineQueueOptions =
|
|
|
566
569
|
| ClassicQueueOptions;
|
|
567
570
|
```
|
|
568
571
|
|
|
569
|
-
Defined in: [types.ts:379](https://github.com/btravers/amqp-contract/blob/
|
|
572
|
+
Defined in: [types.ts:379](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L379)
|
|
570
573
|
|
|
571
574
|
Options for defining a queue. Uses a discriminated union based on the `type` property
|
|
572
575
|
to enforce quorum queue constraints at compile time.
|
|
@@ -582,7 +585,7 @@ to enforce quorum queue constraints at compile time.
|
|
|
582
585
|
type DirectExchangeDefinition<TName> = BaseExchangeDefinition<TName> & object;
|
|
583
586
|
```
|
|
584
587
|
|
|
585
|
-
Defined in: [types.ts:459](https://github.com/btravers/amqp-contract/blob/
|
|
588
|
+
Defined in: [types.ts:459](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L459)
|
|
586
589
|
|
|
587
590
|
A direct exchange definition.
|
|
588
591
|
|
|
@@ -593,7 +596,7 @@ This is ideal for point-to-point messaging where each message should go to speci
|
|
|
593
596
|
|
|
594
597
|
| Name | Type | Defined in |
|
|
595
598
|
| ------ | ------ | ------ |
|
|
596
|
-
| `type` | `"direct"` | [types.ts:461](https://github.com/btravers/amqp-contract/blob/
|
|
599
|
+
| `type` | `"direct"` | [types.ts:461](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L461) |
|
|
597
600
|
|
|
598
601
|
#### Type Parameters
|
|
599
602
|
|
|
@@ -617,7 +620,7 @@ const tasksExchange: DirectExchangeDefinition = defineExchange('tasks', {
|
|
|
617
620
|
type EventConsumerResult<TMessage, TExchange, TQueue, TExchangeBinding, TBridgeExchange> = object;
|
|
618
621
|
```
|
|
619
622
|
|
|
620
|
-
Defined in: [builder/event.ts:54](https://github.com/btravers/amqp-contract/blob/
|
|
623
|
+
Defined in: [builder/event.ts:54](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L54)
|
|
621
624
|
|
|
622
625
|
Result from defineEventConsumer.
|
|
623
626
|
|
|
@@ -639,13 +642,13 @@ will be automatically extracted.
|
|
|
639
642
|
|
|
640
643
|
| Property | Type | Description | Defined in |
|
|
641
644
|
| ------ | ------ | ------ | ------ |
|
|
642
|
-
| <a id="__brand-4"></a> `__brand` | `"EventConsumerResult"` | Discriminator to identify this as an event consumer result | [builder/event.ts:64](https://github.com/btravers/amqp-contract/blob/
|
|
643
|
-
| <a id="binding-2"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | The binding connecting the queue to the exchange | [builder/event.ts:68](https://github.com/btravers/amqp-contract/blob/
|
|
644
|
-
| <a id="bridgeexchange-2"></a> `bridgeExchange` | `TBridgeExchange` | The bridge (local domain) exchange when bridging, if configured | [builder/event.ts:76](https://github.com/btravers/amqp-contract/blob/
|
|
645
|
-
| <a id="consumer-2"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition)<`TMessage`> | The consumer definition for processing messages | [builder/event.ts:66](https://github.com/btravers/amqp-contract/blob/
|
|
646
|
-
| <a id="exchange-3"></a> `exchange` | `TExchange` | The source exchange this consumer subscribes to | [builder/event.ts:70](https://github.com/btravers/amqp-contract/blob/
|
|
647
|
-
| <a id="exchangebinding-2"></a> `exchangeBinding` | `TExchangeBinding` | The exchange-to-exchange binding when bridging, if configured | [builder/event.ts:74](https://github.com/btravers/amqp-contract/blob/
|
|
648
|
-
| <a id="queue-3"></a> `queue` | `TQueue` | The queue this consumer reads from | [builder/event.ts:72](https://github.com/btravers/amqp-contract/blob/
|
|
645
|
+
| <a id="__brand-4"></a> `__brand` | `"EventConsumerResult"` | Discriminator to identify this as an event consumer result | [builder/event.ts:64](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L64) |
|
|
646
|
+
| <a id="binding-2"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | The binding connecting the queue to the exchange | [builder/event.ts:68](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L68) |
|
|
647
|
+
| <a id="bridgeexchange-2"></a> `bridgeExchange` | `TBridgeExchange` | The bridge (local domain) exchange when bridging, if configured | [builder/event.ts:76](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L76) |
|
|
648
|
+
| <a id="consumer-2"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition)<`TMessage`> | The consumer definition for processing messages | [builder/event.ts:66](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L66) |
|
|
649
|
+
| <a id="exchange-3"></a> `exchange` | `TExchange` | The source exchange this consumer subscribes to | [builder/event.ts:70](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L70) |
|
|
650
|
+
| <a id="exchangebinding-2"></a> `exchangeBinding` | `TExchangeBinding` | The exchange-to-exchange binding when bridging, if configured | [builder/event.ts:74](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L74) |
|
|
651
|
+
| <a id="queue-3"></a> `queue` | `TQueue` | The queue this consumer reads from | [builder/event.ts:72](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L72) |
|
|
649
652
|
|
|
650
653
|
***
|
|
651
654
|
|
|
@@ -655,7 +658,7 @@ will be automatically extracted.
|
|
|
655
658
|
type EventConsumerResultBase = object;
|
|
656
659
|
```
|
|
657
660
|
|
|
658
|
-
Defined in: [types.ts:1006](https://github.com/btravers/amqp-contract/blob/
|
|
661
|
+
Defined in: [types.ts:1006](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1006)
|
|
659
662
|
|
|
660
663
|
Base type for event consumer result.
|
|
661
664
|
|
|
@@ -670,13 +673,13 @@ defineEventConsumer for creating event consumers
|
|
|
670
673
|
|
|
671
674
|
| Property | Type | Defined in |
|
|
672
675
|
| ------ | ------ | ------ |
|
|
673
|
-
| <a id="__brand-5"></a> `__brand` | `"EventConsumerResult"` | [types.ts:1007](https://github.com/btravers/amqp-contract/blob/
|
|
674
|
-
| <a id="binding-3"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | [types.ts:1009](https://github.com/btravers/amqp-contract/blob/
|
|
675
|
-
| <a id="bridgeexchange-3"></a> `bridgeExchange` | [`ExchangeDefinition`](#exchangedefinition) \| `undefined` | [types.ts:1013](https://github.com/btravers/amqp-contract/blob/
|
|
676
|
-
| <a id="consumer-3"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition) | [types.ts:1008](https://github.com/btravers/amqp-contract/blob/
|
|
677
|
-
| <a id="exchange-4"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:1010](https://github.com/btravers/amqp-contract/blob/
|
|
678
|
-
| <a id="exchangebinding-3"></a> `exchangeBinding` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) \| `undefined` | [types.ts:1012](https://github.com/btravers/amqp-contract/blob/
|
|
679
|
-
| <a id="queue-4"></a> `queue` | [`QueueEntry`](#queueentry) | [types.ts:1011](https://github.com/btravers/amqp-contract/blob/
|
|
676
|
+
| <a id="__brand-5"></a> `__brand` | `"EventConsumerResult"` | [types.ts:1007](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1007) |
|
|
677
|
+
| <a id="binding-3"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | [types.ts:1009](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1009) |
|
|
678
|
+
| <a id="bridgeexchange-3"></a> `bridgeExchange` | [`ExchangeDefinition`](#exchangedefinition) \| `undefined` | [types.ts:1013](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1013) |
|
|
679
|
+
| <a id="consumer-3"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition) | [types.ts:1008](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1008) |
|
|
680
|
+
| <a id="exchange-4"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:1010](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1010) |
|
|
681
|
+
| <a id="exchangebinding-3"></a> `exchangeBinding` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) \| `undefined` | [types.ts:1012](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1012) |
|
|
682
|
+
| <a id="queue-4"></a> `queue` | [`QueueEntry`](#queueentry) | [types.ts:1011](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1011) |
|
|
680
683
|
|
|
681
684
|
***
|
|
682
685
|
|
|
@@ -686,7 +689,7 @@ defineEventConsumer for creating event consumers
|
|
|
686
689
|
type EventPublisherConfig<TMessage, TExchange, TRoutingKey> = object;
|
|
687
690
|
```
|
|
688
691
|
|
|
689
|
-
Defined in: [builder/event.ts:28](https://github.com/btravers/amqp-contract/blob/
|
|
692
|
+
Defined in: [builder/event.ts:28](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L28)
|
|
690
693
|
|
|
691
694
|
Configuration for an event publisher.
|
|
692
695
|
|
|
@@ -706,11 +709,11 @@ publishers broadcast events and consumers subscribe to receive them.
|
|
|
706
709
|
|
|
707
710
|
| Property | Type | Description | Defined in |
|
|
708
711
|
| ------ | ------ | ------ | ------ |
|
|
709
|
-
| <a id="__brand-6"></a> `__brand` | `"EventPublisherConfig"` | Discriminator to identify this as an event publisher config | [builder/event.ts:34](https://github.com/btravers/amqp-contract/blob/
|
|
710
|
-
| <a id="arguments-1"></a> `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments | [builder/event.ts:42](https://github.com/btravers/amqp-contract/blob/
|
|
711
|
-
| <a id="exchange-5"></a> `exchange` | `TExchange` | The exchange to publish to | [builder/event.ts:36](https://github.com/btravers/amqp-contract/blob/
|
|
712
|
-
| <a id="message-3"></a> `message` | `TMessage` | The message definition | [builder/event.ts:38](https://github.com/btravers/amqp-contract/blob/
|
|
713
|
-
| <a id="routingkey-3"></a> `routingKey` | `TRoutingKey` | The routing key for direct/topic exchanges | [builder/event.ts:40](https://github.com/btravers/amqp-contract/blob/
|
|
712
|
+
| <a id="__brand-6"></a> `__brand` | `"EventPublisherConfig"` | Discriminator to identify this as an event publisher config | [builder/event.ts:34](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L34) |
|
|
713
|
+
| <a id="arguments-1"></a> `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments | [builder/event.ts:42](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L42) |
|
|
714
|
+
| <a id="exchange-5"></a> `exchange` | `TExchange` | The exchange to publish to | [builder/event.ts:36](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L36) |
|
|
715
|
+
| <a id="message-3"></a> `message` | `TMessage` | The message definition | [builder/event.ts:38](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L38) |
|
|
716
|
+
| <a id="routingkey-3"></a> `routingKey` | `TRoutingKey` | The routing key for direct/topic exchanges | [builder/event.ts:40](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L40) |
|
|
714
717
|
|
|
715
718
|
***
|
|
716
719
|
|
|
@@ -720,7 +723,7 @@ publishers broadcast events and consumers subscribe to receive them.
|
|
|
720
723
|
type EventPublisherConfigBase = object;
|
|
721
724
|
```
|
|
722
725
|
|
|
723
|
-
Defined in: [types.ts:972](https://github.com/btravers/amqp-contract/blob/
|
|
726
|
+
Defined in: [types.ts:972](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L972)
|
|
724
727
|
|
|
725
728
|
Base type for event publisher configuration.
|
|
726
729
|
|
|
@@ -735,11 +738,11 @@ defineEventPublisher for creating event publishers
|
|
|
735
738
|
|
|
736
739
|
| Property | Type | Defined in |
|
|
737
740
|
| ------ | ------ | ------ |
|
|
738
|
-
| <a id="__brand-7"></a> `__brand` | `"EventPublisherConfig"` | [types.ts:973](https://github.com/btravers/amqp-contract/blob/
|
|
739
|
-
| <a id="arguments-2"></a> `arguments?` | `Record`<`string`, `unknown`> | [types.ts:977](https://github.com/btravers/amqp-contract/blob/
|
|
740
|
-
| <a id="exchange-6"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:974](https://github.com/btravers/amqp-contract/blob/
|
|
741
|
-
| <a id="message-4"></a> `message` | [`MessageDefinition`](#messagedefinition) | [types.ts:975](https://github.com/btravers/amqp-contract/blob/
|
|
742
|
-
| <a id="routingkey-4"></a> `routingKey` | `string` \| `undefined` | [types.ts:976](https://github.com/btravers/amqp-contract/blob/
|
|
741
|
+
| <a id="__brand-7"></a> `__brand` | `"EventPublisherConfig"` | [types.ts:973](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L973) |
|
|
742
|
+
| <a id="arguments-2"></a> `arguments?` | `Record`<`string`, `unknown`> | [types.ts:977](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L977) |
|
|
743
|
+
| <a id="exchange-6"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:974](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L974) |
|
|
744
|
+
| <a id="message-4"></a> `message` | [`MessageDefinition`](#messagedefinition) | [types.ts:975](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L975) |
|
|
745
|
+
| <a id="routingkey-4"></a> `routingKey` | `string` \| `undefined` | [types.ts:976](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L976) |
|
|
743
746
|
|
|
744
747
|
***
|
|
745
748
|
|
|
@@ -759,7 +762,7 @@ type ExchangeBindingDefinition = object &
|
|
|
759
762
|
};
|
|
760
763
|
```
|
|
761
764
|
|
|
762
|
-
Defined in: [types.ts:855](https://github.com/btravers/amqp-contract/blob/
|
|
765
|
+
Defined in: [types.ts:855](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L855)
|
|
763
766
|
|
|
764
767
|
Binding between two exchanges (exchange-to-exchange routing).
|
|
765
768
|
|
|
@@ -770,9 +773,9 @@ This allows for more complex routing topologies.
|
|
|
770
773
|
|
|
771
774
|
| Name | Type | Description | Defined in |
|
|
772
775
|
| ------ | ------ | ------ | ------ |
|
|
773
|
-
| `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for the binding. | [types.ts:865](https://github.com/btravers/amqp-contract/blob/
|
|
774
|
-
| `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:860](https://github.com/btravers/amqp-contract/blob/
|
|
775
|
-
| `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:857](https://github.com/btravers/amqp-contract/blob/
|
|
776
|
+
| `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for the binding. | [types.ts:865](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L865) |
|
|
777
|
+
| `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:860](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L860) |
|
|
778
|
+
| `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:857](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L857) |
|
|
776
779
|
|
|
777
780
|
#### Example
|
|
778
781
|
|
|
@@ -798,7 +801,7 @@ type ExchangeDefinition<TName> =
|
|
|
798
801
|
| HeadersExchangeDefinition<TName>;
|
|
799
802
|
```
|
|
800
803
|
|
|
801
|
-
Defined in: [types.ts:505](https://github.com/btravers/amqp-contract/blob/
|
|
804
|
+
Defined in: [types.ts:505](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L505)
|
|
802
805
|
|
|
803
806
|
Union type of all exchange definitions.
|
|
804
807
|
|
|
@@ -818,7 +821,7 @@ Represents any type of AMQP exchange: topic, direct, fanout, headers.
|
|
|
818
821
|
type FanoutExchangeDefinition<TName> = BaseExchangeDefinition<TName> & object;
|
|
819
822
|
```
|
|
820
823
|
|
|
821
|
-
Defined in: [types.ts:477](https://github.com/btravers/amqp-contract/blob/
|
|
824
|
+
Defined in: [types.ts:477](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L477)
|
|
822
825
|
|
|
823
826
|
A fanout exchange definition.
|
|
824
827
|
|
|
@@ -829,7 +832,7 @@ This is the simplest exchange type for pub/sub messaging patterns.
|
|
|
829
832
|
|
|
830
833
|
| Name | Type | Defined in |
|
|
831
834
|
| ------ | ------ | ------ |
|
|
832
|
-
| `type` | `"fanout"` | [types.ts:479](https://github.com/btravers/amqp-contract/blob/
|
|
835
|
+
| `type` | `"fanout"` | [types.ts:479](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L479) |
|
|
833
836
|
|
|
834
837
|
#### Type Parameters
|
|
835
838
|
|
|
@@ -853,7 +856,7 @@ const logsExchange: FanoutExchangeDefinition = defineExchange('logs', {
|
|
|
853
856
|
type HeadersExchangeDefinition<TName> = BaseExchangeDefinition<TName> & object;
|
|
854
857
|
```
|
|
855
858
|
|
|
856
|
-
Defined in: [types.ts:495](https://github.com/btravers/amqp-contract/blob/
|
|
859
|
+
Defined in: [types.ts:495](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L495)
|
|
857
860
|
|
|
858
861
|
A headers exchange definition.
|
|
859
862
|
|
|
@@ -864,7 +867,7 @@ This is useful for more complex routing scenarios where metadata is important.
|
|
|
864
867
|
|
|
865
868
|
| Name | Type | Defined in |
|
|
866
869
|
| ------ | ------ | ------ |
|
|
867
|
-
| `type` | `"headers"` | [types.ts:497](https://github.com/btravers/amqp-contract/blob/
|
|
870
|
+
| `type` | `"headers"` | [types.ts:497](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L497) |
|
|
868
871
|
|
|
869
872
|
#### Type Parameters
|
|
870
873
|
|
|
@@ -888,7 +891,7 @@ const routesExchange: HeadersExchangeDefinition = defineExchange('routes', {
|
|
|
888
891
|
type ImmediateRequeueRetryOptions = object;
|
|
889
892
|
```
|
|
890
893
|
|
|
891
|
-
Defined in: [types.ts:88](https://github.com/btravers/amqp-contract/blob/
|
|
894
|
+
Defined in: [types.ts:88](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L88)
|
|
892
895
|
|
|
893
896
|
Immediate-Requeue retry options.
|
|
894
897
|
|
|
@@ -908,8 +911,8 @@ https://www.rabbitmq.com/docs/quorum-queues#poison-message-handling
|
|
|
908
911
|
|
|
909
912
|
| Property | Type | Description | Defined in |
|
|
910
913
|
| ------ | ------ | ------ | ------ |
|
|
911
|
-
| <a id="maxretries"></a> `maxRetries?` | `number` | Maximum retry attempts before sending to DLQ. **Minimum** 1 - Must be a positive integer (1 or greater) **Default** `3` | [types.ts:98](https://github.com/btravers/amqp-contract/blob/
|
|
912
|
-
| <a id="mode"></a> `mode` | `"immediate-requeue"` | Immediate-Requeue mode. | [types.ts:92](https://github.com/btravers/amqp-contract/blob/
|
|
914
|
+
| <a id="maxretries"></a> `maxRetries?` | `number` | Maximum retry attempts before sending to DLQ. **Minimum** 1 - Must be a positive integer (1 or greater) **Default** `3` | [types.ts:98](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L98) |
|
|
915
|
+
| <a id="mode"></a> `mode` | `"immediate-requeue"` | Immediate-Requeue mode. | [types.ts:92](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L92) |
|
|
913
916
|
|
|
914
917
|
***
|
|
915
918
|
|
|
@@ -919,7 +922,7 @@ https://www.rabbitmq.com/docs/quorum-queues#poison-message-handling
|
|
|
919
922
|
type InferConsumerNames<TContract> = TContract["consumers"] extends Record<string, unknown> ? keyof TContract["consumers"] : never;
|
|
920
923
|
```
|
|
921
924
|
|
|
922
|
-
Defined in: [types.ts:
|
|
925
|
+
Defined in: [types.ts:1609](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1609)
|
|
923
926
|
|
|
924
927
|
Extract consumer names from a contract.
|
|
925
928
|
|
|
@@ -951,7 +954,7 @@ type ConsumerNames = InferConsumerNames<typeof myContract>;
|
|
|
951
954
|
type InferPublisherNames<TContract> = TContract["publishers"] extends Record<string, unknown> ? keyof TContract["publishers"] : never;
|
|
952
955
|
```
|
|
953
956
|
|
|
954
|
-
Defined in: [types.ts:
|
|
957
|
+
Defined in: [types.ts:1591](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1591)
|
|
955
958
|
|
|
956
959
|
Extract publisher names from a contract.
|
|
957
960
|
|
|
@@ -977,13 +980,38 @@ type PublisherNames = InferPublisherNames<typeof myContract>;
|
|
|
977
980
|
|
|
978
981
|
***
|
|
979
982
|
|
|
983
|
+
### InferRpcNames
|
|
984
|
+
|
|
985
|
+
```ts
|
|
986
|
+
type InferRpcNames<TContract> = TContract["rpcs"] extends Record<string, RpcDefinition> ? keyof TContract["rpcs"] : never;
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
Defined in: [types.ts:1621](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1621)
|
|
990
|
+
|
|
991
|
+
Extract RPC names from a contract.
|
|
992
|
+
|
|
993
|
+
Each name in this union has a typed worker handler and a `client.call(name, ...)`
|
|
994
|
+
method. RPC names are disjoint from `InferConsumerNames` and `InferPublisherNames`.
|
|
995
|
+
|
|
996
|
+
#### Type Parameters
|
|
997
|
+
|
|
998
|
+
| Type Parameter | Description |
|
|
999
|
+
| ------ | ------ |
|
|
1000
|
+
| `TContract` *extends* [`ContractDefinition`](#contractdefinition) | The contract definition |
|
|
1001
|
+
|
|
1002
|
+
#### Returns
|
|
1003
|
+
|
|
1004
|
+
Union of RPC names, or never if no RPCs defined
|
|
1005
|
+
|
|
1006
|
+
***
|
|
1007
|
+
|
|
980
1008
|
### MatchingRoutingKey
|
|
981
1009
|
|
|
982
1010
|
```ts
|
|
983
1011
|
type MatchingRoutingKey<Pattern, Key> = RoutingKey<Key> extends never ? never : BindingPattern<Pattern> extends never ? never : MatchesPattern<Key, Pattern> extends true ? Key : never;
|
|
984
1012
|
```
|
|
985
1013
|
|
|
986
|
-
Defined in: [builder/routing-types.ts:114](https://github.com/btravers/amqp-contract/blob/
|
|
1014
|
+
Defined in: [builder/routing-types.ts:114](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/routing-types.ts#L114)
|
|
987
1015
|
|
|
988
1016
|
Validate that a routing key matches a binding pattern.
|
|
989
1017
|
|
|
@@ -1015,7 +1043,7 @@ type InvalidKey = MatchingRoutingKey<"order.*", "user.created">; // never
|
|
|
1015
1043
|
type MessageDefinition<TPayload, THeaders> = object;
|
|
1016
1044
|
```
|
|
1017
1045
|
|
|
1018
|
-
Defined in: [types.ts:769](https://github.com/btravers/amqp-contract/blob/
|
|
1046
|
+
Defined in: [types.ts:769](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L769)
|
|
1019
1047
|
|
|
1020
1048
|
Definition of a message with typed payload and optional headers.
|
|
1021
1049
|
|
|
@@ -1030,10 +1058,10 @@ Definition of a message with typed payload and optional headers.
|
|
|
1030
1058
|
|
|
1031
1059
|
| Property | Type | Description | Defined in |
|
|
1032
1060
|
| ------ | ------ | ------ | ------ |
|
|
1033
|
-
| <a id="description"></a> `description?` | `string` | Detailed description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:797](https://github.com/btravers/amqp-contract/blob/
|
|
1034
|
-
| <a id="headers"></a> `headers?` | `THeaders` | Optional headers schema for validating message metadata. Must be a Standard Schema v1 compatible schema. | [types.ts:785](https://github.com/btravers/amqp-contract/blob/
|
|
1035
|
-
| <a id="payload"></a> `payload` | `TPayload` | The payload schema for validating message content. Must be a Standard Schema v1 compatible schema (Zod, Valibot, ArkType, etc.). | [types.ts:779](https://github.com/btravers/amqp-contract/blob/
|
|
1036
|
-
| <a id="summary"></a> `summary?` | `string` | Brief description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:791](https://github.com/btravers/amqp-contract/blob/
|
|
1061
|
+
| <a id="description"></a> `description?` | `string` | Detailed description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:797](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L797) |
|
|
1062
|
+
| <a id="headers"></a> `headers?` | `THeaders` | Optional headers schema for validating message metadata. Must be a Standard Schema v1 compatible schema. | [types.ts:785](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L785) |
|
|
1063
|
+
| <a id="payload"></a> `payload` | `TPayload` | The payload schema for validating message content. Must be a Standard Schema v1 compatible schema (Zod, Valibot, ArkType, etc.). | [types.ts:779](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L779) |
|
|
1064
|
+
| <a id="summary"></a> `summary?` | `string` | Brief description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:791](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L791) |
|
|
1037
1065
|
|
|
1038
1066
|
***
|
|
1039
1067
|
|
|
@@ -1053,7 +1081,7 @@ type PublisherDefinition<TMessage> = object &
|
|
|
1053
1081
|
};
|
|
1054
1082
|
```
|
|
1055
1083
|
|
|
1056
|
-
Defined in: [types.ts:913](https://github.com/btravers/amqp-contract/blob/
|
|
1084
|
+
Defined in: [types.ts:913](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L913)
|
|
1057
1085
|
|
|
1058
1086
|
Definition of a message publisher.
|
|
1059
1087
|
|
|
@@ -1067,7 +1095,7 @@ algorithm when calling the publish method.
|
|
|
1067
1095
|
|
|
1068
1096
|
| Name | Type | Description | Defined in |
|
|
1069
1097
|
| ------ | ------ | ------ | ------ |
|
|
1070
|
-
| `message` | `TMessage` | The message definition including the payload schema | [types.ts:915](https://github.com/btravers/amqp-contract/blob/
|
|
1098
|
+
| `message` | `TMessage` | The message definition including the payload schema | [types.ts:915](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L915) |
|
|
1071
1099
|
|
|
1072
1100
|
#### Type Parameters
|
|
1073
1101
|
|
|
@@ -1096,7 +1124,7 @@ type PublisherEntry =
|
|
|
1096
1124
|
| BridgedPublisherConfigBase;
|
|
1097
1125
|
```
|
|
1098
1126
|
|
|
1099
|
-
Defined in: [types.ts:
|
|
1127
|
+
Defined in: [types.ts:1149](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1149)
|
|
1100
1128
|
|
|
1101
1129
|
Publisher entry that can be passed to defineContract's publishers section.
|
|
1102
1130
|
|
|
@@ -1123,7 +1151,7 @@ type QueueBindingDefinition = object &
|
|
|
1123
1151
|
};
|
|
1124
1152
|
```
|
|
1125
1153
|
|
|
1126
|
-
Defined in: [types.ts:807](https://github.com/btravers/amqp-contract/blob/
|
|
1154
|
+
Defined in: [types.ts:807](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L807)
|
|
1127
1155
|
|
|
1128
1156
|
Binding between a queue and an exchange.
|
|
1129
1157
|
|
|
@@ -1135,9 +1163,9 @@ For fanout and headers exchanges, no routing key is needed.
|
|
|
1135
1163
|
|
|
1136
1164
|
| Name | Type | Description | Defined in |
|
|
1137
1165
|
| ------ | ------ | ------ | ------ |
|
|
1138
|
-
| `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for the binding. Can be used for advanced routing scenarios with the headers exchange type. | [types.ts:818](https://github.com/btravers/amqp-contract/blob/
|
|
1139
|
-
| `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:812](https://github.com/btravers/amqp-contract/blob/
|
|
1140
|
-
| `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:809](https://github.com/btravers/amqp-contract/blob/
|
|
1166
|
+
| `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for the binding. Can be used for advanced routing scenarios with the headers exchange type. | [types.ts:818](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L818) |
|
|
1167
|
+
| `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:812](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L812) |
|
|
1168
|
+
| `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:809](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L809) |
|
|
1141
1169
|
|
|
1142
1170
|
***
|
|
1143
1171
|
|
|
@@ -1149,7 +1177,7 @@ type QueueDefinition<TName> =
|
|
|
1149
1177
|
| ClassicQueueDefinition<TName>;
|
|
1150
1178
|
```
|
|
1151
1179
|
|
|
1152
|
-
Defined in: [types.ts:646](https://github.com/btravers/amqp-contract/blob/
|
|
1180
|
+
Defined in: [types.ts:646](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L646)
|
|
1153
1181
|
|
|
1154
1182
|
Definition of an AMQP queue.
|
|
1155
1183
|
|
|
@@ -1175,7 +1203,7 @@ type QueueEntry<TName> =
|
|
|
1175
1203
|
| QueueWithTtlBackoffInfrastructure<TName>;
|
|
1176
1204
|
```
|
|
1177
1205
|
|
|
1178
|
-
Defined in: [types.ts:749](https://github.com/btravers/amqp-contract/blob/
|
|
1206
|
+
Defined in: [types.ts:749](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L749)
|
|
1179
1207
|
|
|
1180
1208
|
A queue entry that can be passed to `defineContract`.
|
|
1181
1209
|
|
|
@@ -1195,7 +1223,7 @@ Can be either a plain queue definition or a queue with TTL-backoff infrastructur
|
|
|
1195
1223
|
type QueueType = "quorum" | "classic";
|
|
1196
1224
|
```
|
|
1197
1225
|
|
|
1198
|
-
Defined in: [types.ts:227](https://github.com/btravers/amqp-contract/blob/
|
|
1226
|
+
Defined in: [types.ts:227](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L227)
|
|
1199
1227
|
|
|
1200
1228
|
Supported queue types in RabbitMQ.
|
|
1201
1229
|
|
|
@@ -1233,7 +1261,7 @@ const tempQueue = defineQueue('temp-queue', {
|
|
|
1233
1261
|
type QueueWithTtlBackoffInfrastructure<TName> = object;
|
|
1234
1262
|
```
|
|
1235
1263
|
|
|
1236
|
-
Defined in: [types.ts:706](https://github.com/btravers/amqp-contract/blob/
|
|
1264
|
+
Defined in: [types.ts:706](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L706)
|
|
1237
1265
|
|
|
1238
1266
|
A queue with automatically generated TTL-backoff retry infrastructure.
|
|
1239
1267
|
|
|
@@ -1269,12 +1297,12 @@ const contract = defineContract({
|
|
|
1269
1297
|
|
|
1270
1298
|
| Property | Type | Description | Defined in |
|
|
1271
1299
|
| ------ | ------ | ------ | ------ |
|
|
1272
|
-
| <a id="queue-5"></a> `queue` | [`QueueDefinition`](#queuedefinition)<`TName`> | The main queue definition. | [types.ts:716](https://github.com/btravers/amqp-contract/blob/
|
|
1273
|
-
| <a id="retryexchange"></a> `retryExchange` | [`HeadersExchangeDefinition`](#headersexchangedefinition) | Retry exchange used to route messages to retry back to the main queue. | [types.ts:731](https://github.com/btravers/amqp-contract/blob/
|
|
1274
|
-
| <a id="retryqueuebinding"></a> `retryQueueBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes messages to retry back to the main queue. | [types.ts:741](https://github.com/btravers/amqp-contract/blob/
|
|
1275
|
-
| <a id="waitexchange"></a> `waitExchange` | [`HeadersExchangeDefinition`](#headersexchangedefinition) | Wait exchange used to route failed messages to the wait queue. | [types.ts:726](https://github.com/btravers/amqp-contract/blob/
|
|
1276
|
-
| <a id="waitqueue"></a> `waitQueue` | [`QueueDefinition`](#queuedefinition) | The wait queue for holding messages during backoff delay. | [types.ts:721](https://github.com/btravers/amqp-contract/blob/
|
|
1277
|
-
| <a id="waitqueuebinding"></a> `waitQueueBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes failed messages to the wait queue. | [types.ts:736](https://github.com/btravers/amqp-contract/blob/
|
|
1300
|
+
| <a id="queue-5"></a> `queue` | [`QueueDefinition`](#queuedefinition)<`TName`> | The main queue definition. | [types.ts:716](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L716) |
|
|
1301
|
+
| <a id="retryexchange"></a> `retryExchange` | [`HeadersExchangeDefinition`](#headersexchangedefinition) | Retry exchange used to route messages to retry back to the main queue. | [types.ts:731](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L731) |
|
|
1302
|
+
| <a id="retryqueuebinding"></a> `retryQueueBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes messages to retry back to the main queue. | [types.ts:741](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L741) |
|
|
1303
|
+
| <a id="waitexchange"></a> `waitExchange` | [`HeadersExchangeDefinition`](#headersexchangedefinition) | Wait exchange used to route failed messages to the wait queue. | [types.ts:726](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L726) |
|
|
1304
|
+
| <a id="waitqueue"></a> `waitQueue` | [`QueueDefinition`](#queuedefinition) | The wait queue for holding messages during backoff delay. | [types.ts:721](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L721) |
|
|
1305
|
+
| <a id="waitqueuebinding"></a> `waitQueueBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes failed messages to the wait queue. | [types.ts:736](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L736) |
|
|
1278
1306
|
|
|
1279
1307
|
***
|
|
1280
1308
|
|
|
@@ -1284,7 +1312,7 @@ const contract = defineContract({
|
|
|
1284
1312
|
type QuorumQueueDefinition<TName> = BaseQueueDefinition<TName> & object;
|
|
1285
1313
|
```
|
|
1286
1314
|
|
|
1287
|
-
Defined in: [types.ts:572](https://github.com/btravers/amqp-contract/blob/
|
|
1315
|
+
Defined in: [types.ts:572](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L572)
|
|
1288
1316
|
|
|
1289
1317
|
Definition of a quorum queue.
|
|
1290
1318
|
|
|
@@ -1294,11 +1322,11 @@ Quorum queues provide better durability and high-availability using the Raft con
|
|
|
1294
1322
|
|
|
1295
1323
|
| Name | Type | Description | Defined in |
|
|
1296
1324
|
| ------ | ------ | ------ | ------ |
|
|
1297
|
-
| `autoDelete?` | `never` | Quorum queues do not support auto-delete mode. Use type: 'classic' if you need auto-deleting queues. | [types.ts:593](https://github.com/btravers/amqp-contract/blob/
|
|
1298
|
-
| `durable` | `true` | Quorum queues only support durable queues. | [types.ts:581](https://github.com/btravers/amqp-contract/blob/
|
|
1299
|
-
| `exclusive?` | `never` | Quorum queues do not support exclusive mode. Use type: 'classic' if you need exclusive queues. | [types.ts:587](https://github.com/btravers/amqp-contract/blob/
|
|
1300
|
-
| `maxPriority?` | `never` | Quorum queues do not support priority queues. Use type: 'classic' if you need priority queues. | [types.ts:599](https://github.com/btravers/amqp-contract/blob/
|
|
1301
|
-
| `type` | `"quorum"` | Queue type discriminator: quorum queue. | [types.ts:576](https://github.com/btravers/amqp-contract/blob/
|
|
1325
|
+
| `autoDelete?` | `never` | Quorum queues do not support auto-delete mode. Use type: 'classic' if you need auto-deleting queues. | [types.ts:593](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L593) |
|
|
1326
|
+
| `durable` | `true` | Quorum queues only support durable queues. | [types.ts:581](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L581) |
|
|
1327
|
+
| `exclusive?` | `never` | Quorum queues do not support exclusive mode. Use type: 'classic' if you need exclusive queues. | [types.ts:587](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L587) |
|
|
1328
|
+
| `maxPriority?` | `never` | Quorum queues do not support priority queues. Use type: 'classic' if you need priority queues. | [types.ts:599](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L599) |
|
|
1329
|
+
| `type` | `"quorum"` | Queue type discriminator: quorum queue. | [types.ts:576](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L576) |
|
|
1302
1330
|
|
|
1303
1331
|
#### Type Parameters
|
|
1304
1332
|
|
|
@@ -1314,7 +1342,7 @@ Quorum queues provide better durability and high-availability using the Raft con
|
|
|
1314
1342
|
type QuorumQueueOptions = BaseQueueOptions & object;
|
|
1315
1343
|
```
|
|
1316
1344
|
|
|
1317
|
-
Defined in: [types.ts:295](https://github.com/btravers/amqp-contract/blob/
|
|
1345
|
+
Defined in: [types.ts:295](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L295)
|
|
1318
1346
|
|
|
1319
1347
|
Options for creating a quorum queue.
|
|
1320
1348
|
|
|
@@ -1333,11 +1361,11 @@ Quorum queues provide native retry support for immediate-requeue retry mode:
|
|
|
1333
1361
|
|
|
1334
1362
|
| Name | Type | Description | Defined in |
|
|
1335
1363
|
| ------ | ------ | ------ | ------ |
|
|
1336
|
-
| `autoDelete?` | `never` | Quorum queues do not support auto-delete mode. Use type: 'classic' if you need auto-deleting queues. | [types.ts:316](https://github.com/btravers/amqp-contract/blob/
|
|
1337
|
-
| `durable?` | `true` | Quorum queues only support durable queues. | [types.ts:304](https://github.com/btravers/amqp-contract/blob/
|
|
1338
|
-
| `exclusive?` | `never` | Quorum queues do not support exclusive mode. Use type: 'classic' if you need exclusive queues. | [types.ts:310](https://github.com/btravers/amqp-contract/blob/
|
|
1339
|
-
| `maxPriority?` | `never` | Quorum queues do not support priority queues. Use type: 'classic' if you need priority queues. | [types.ts:322](https://github.com/btravers/amqp-contract/blob/
|
|
1340
|
-
| `type?` | `"quorum"` | Queue type: quorum (default, recommended) | [types.ts:299](https://github.com/btravers/amqp-contract/blob/
|
|
1364
|
+
| `autoDelete?` | `never` | Quorum queues do not support auto-delete mode. Use type: 'classic' if you need auto-deleting queues. | [types.ts:316](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L316) |
|
|
1365
|
+
| `durable?` | `true` | Quorum queues only support durable queues. | [types.ts:304](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L304) |
|
|
1366
|
+
| `exclusive?` | `never` | Quorum queues do not support exclusive mode. Use type: 'classic' if you need exclusive queues. | [types.ts:310](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L310) |
|
|
1367
|
+
| `maxPriority?` | `never` | Quorum queues do not support priority queues. Use type: 'classic' if you need priority queues. | [types.ts:322](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L322) |
|
|
1368
|
+
| `type?` | `"quorum"` | Queue type: quorum (default, recommended) | [types.ts:299](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L299) |
|
|
1341
1369
|
|
|
1342
1370
|
#### Example
|
|
1343
1371
|
|
|
@@ -1360,7 +1388,7 @@ type ResolvedRetryOptions =
|
|
|
1360
1388
|
| ResolvedTtlBackoffRetryOptions;
|
|
1361
1389
|
```
|
|
1362
1390
|
|
|
1363
|
-
Defined in: [types.ts:166](https://github.com/btravers/amqp-contract/blob/
|
|
1391
|
+
Defined in: [types.ts:166](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L166)
|
|
1364
1392
|
|
|
1365
1393
|
Resolved retry configuration stored in queue definitions.
|
|
1366
1394
|
|
|
@@ -1380,7 +1408,7 @@ a wait queue and the necessary exchanges and bindings.
|
|
|
1380
1408
|
type RoutingKey<S> = S extends "" ? never : S extends `${string}*${string}` | `${string}#${string}` ? never : S;
|
|
1381
1409
|
```
|
|
1382
1410
|
|
|
1383
|
-
Defined in: [builder/routing-types.ts:25](https://github.com/btravers/amqp-contract/blob/
|
|
1411
|
+
Defined in: [builder/routing-types.ts:25](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/routing-types.ts#L25)
|
|
1384
1412
|
|
|
1385
1413
|
Type-safe routing key that validates basic format.
|
|
1386
1414
|
|
|
@@ -1408,13 +1436,51 @@ type Invalid2 = RoutingKey<"">; // never (empty string)
|
|
|
1408
1436
|
|
|
1409
1437
|
***
|
|
1410
1438
|
|
|
1439
|
+
### RpcDefinition
|
|
1440
|
+
|
|
1441
|
+
```ts
|
|
1442
|
+
type RpcDefinition<TRequestMessage, TResponseMessage, TQueue> = object;
|
|
1443
|
+
```
|
|
1444
|
+
|
|
1445
|
+
Defined in: [types.ts:1047](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1047)
|
|
1446
|
+
|
|
1447
|
+
Definition of an RPC operation: a request/response pair flowing over a
|
|
1448
|
+
request queue with replies routed back via direct reply-to.
|
|
1449
|
+
|
|
1450
|
+
An RPC is bidirectional on both ends — the server consumes requests and
|
|
1451
|
+
publishes responses; the client publishes requests and consumes responses —
|
|
1452
|
+
so it has its own slot in the contract (`rpcs`) rather than being shoehorned
|
|
1453
|
+
into `consumers` or `publishers`.
|
|
1454
|
+
|
|
1455
|
+
#### See
|
|
1456
|
+
|
|
1457
|
+
defineRpc for creating RPC definitions
|
|
1458
|
+
|
|
1459
|
+
#### Type Parameters
|
|
1460
|
+
|
|
1461
|
+
| Type Parameter | Default type | Description |
|
|
1462
|
+
| ------ | ------ | ------ |
|
|
1463
|
+
| `TRequestMessage` *extends* [`MessageDefinition`](#messagedefinition) | [`MessageDefinition`](#messagedefinition) | The request message definition |
|
|
1464
|
+
| `TResponseMessage` *extends* [`MessageDefinition`](#messagedefinition) | [`MessageDefinition`](#messagedefinition) | The response message definition |
|
|
1465
|
+
| `TQueue` *extends* [`QueueEntry`](#queueentry) | [`QueueEntry`](#queueentry) | The request queue entry |
|
|
1466
|
+
|
|
1467
|
+
#### Properties
|
|
1468
|
+
|
|
1469
|
+
| Property | Type | Description | Defined in |
|
|
1470
|
+
| ------ | ------ | ------ | ------ |
|
|
1471
|
+
| <a id="queue-6"></a> `queue` | `TQueue` | The queue that receives RPC requests. Replies are routed back via direct reply-to. | [types.ts:1053](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1053) |
|
|
1472
|
+
| <a id="request"></a> `request` | `TRequestMessage` | Schema for the request payload (validated on both publish and consume). | [types.ts:1055](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1055) |
|
|
1473
|
+
| <a id="response"></a> `response` | `TResponseMessage` | Schema for the response payload (validated on both worker reply and client receive). | [types.ts:1057](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L1057) |
|
|
1474
|
+
|
|
1475
|
+
***
|
|
1476
|
+
|
|
1411
1477
|
### TopicExchangeDefinition
|
|
1412
1478
|
|
|
1413
1479
|
```ts
|
|
1414
1480
|
type TopicExchangeDefinition<TName> = BaseExchangeDefinition<TName> & object;
|
|
1415
1481
|
```
|
|
1416
1482
|
|
|
1417
|
-
Defined in: [types.ts:441](https://github.com/btravers/amqp-contract/blob/
|
|
1483
|
+
Defined in: [types.ts:441](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L441)
|
|
1418
1484
|
|
|
1419
1485
|
A topic exchange definition.
|
|
1420
1486
|
|
|
@@ -1428,7 +1494,7 @@ Words are separated by dots (e.g., `order.created.high-value`).
|
|
|
1428
1494
|
|
|
1429
1495
|
| Name | Type | Defined in |
|
|
1430
1496
|
| ------ | ------ | ------ |
|
|
1431
|
-
| `type` | `"topic"` | [types.ts:443](https://github.com/btravers/amqp-contract/blob/
|
|
1497
|
+
| `type` | `"topic"` | [types.ts:443](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L443) |
|
|
1432
1498
|
|
|
1433
1499
|
#### Type Parameters
|
|
1434
1500
|
|
|
@@ -1453,7 +1519,7 @@ const ordersExchange: TopicExchangeDefinition = defineExchange('orders', {
|
|
|
1453
1519
|
type TtlBackoffRetryOptions = object;
|
|
1454
1520
|
```
|
|
1455
1521
|
|
|
1456
|
-
Defined in: [types.ts:27](https://github.com/btravers/amqp-contract/blob/
|
|
1522
|
+
Defined in: [types.ts:27](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L27)
|
|
1457
1523
|
|
|
1458
1524
|
TTL-Backoff retry options for exponential backoff with configurable delays.
|
|
1459
1525
|
|
|
@@ -1467,15 +1533,15 @@ per-message TTL, then dead-lettered back to the main queue after the TTL expires
|
|
|
1467
1533
|
|
|
1468
1534
|
| Property | Type | Description | Defined in |
|
|
1469
1535
|
| ------ | ------ | ------ | ------ |
|
|
1470
|
-
| <a id="backoffmultiplier"></a> `backoffMultiplier?` | `number` | Exponential backoff multiplier. **Default** `2` | [types.ts:52](https://github.com/btravers/amqp-contract/blob/
|
|
1471
|
-
| <a id="initialdelayms"></a> `initialDelayMs?` | `number` | Initial delay in ms before first retry. **Default** `1000` | [types.ts:42](https://github.com/btravers/amqp-contract/blob/
|
|
1472
|
-
| <a id="jitter"></a> `jitter?` | `boolean` | Add jitter to prevent thundering herd. **Default** `true` | [types.ts:57](https://github.com/btravers/amqp-contract/blob/
|
|
1473
|
-
| <a id="maxdelayms"></a> `maxDelayMs?` | `number` | Maximum delay in ms between retries. **Default** `30000` | [types.ts:47](https://github.com/btravers/amqp-contract/blob/
|
|
1474
|
-
| <a id="maxretries-1"></a> `maxRetries?` | `number` | Maximum retry attempts before sending to DLQ. **Minimum** 1 - Must be a positive integer (1 or greater) **Default** `3` | [types.ts:37](https://github.com/btravers/amqp-contract/blob/
|
|
1475
|
-
| <a id="mode-1"></a> `mode` | `"ttl-backoff"` | TTL-Backoff mode uses wait queues with per-message TTL for exponential backoff. | [types.ts:31](https://github.com/btravers/amqp-contract/blob/
|
|
1476
|
-
| <a id="retryexchangename"></a> `retryExchangeName?` | `string` | Name of the retry exchange. **Default** `'retry-exchange'` | [types.ts:72](https://github.com/btravers/amqp-contract/blob/
|
|
1477
|
-
| <a id="waitexchangename"></a> `waitExchangeName?` | `string` | Name of the wait exchange. **Default** `'wait-exchange'` | [types.ts:67](https://github.com/btravers/amqp-contract/blob/
|
|
1478
|
-
| <a id="waitqueuename"></a> `waitQueueName?` | `string` | Name of the wait queue. **Default** `'{queueName}-wait'` | [types.ts:62](https://github.com/btravers/amqp-contract/blob/
|
|
1536
|
+
| <a id="backoffmultiplier"></a> `backoffMultiplier?` | `number` | Exponential backoff multiplier. **Default** `2` | [types.ts:52](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L52) |
|
|
1537
|
+
| <a id="initialdelayms"></a> `initialDelayMs?` | `number` | Initial delay in ms before first retry. **Default** `1000` | [types.ts:42](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L42) |
|
|
1538
|
+
| <a id="jitter"></a> `jitter?` | `boolean` | Add jitter to prevent thundering herd. **Default** `true` | [types.ts:57](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L57) |
|
|
1539
|
+
| <a id="maxdelayms"></a> `maxDelayMs?` | `number` | Maximum delay in ms between retries. **Default** `30000` | [types.ts:47](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L47) |
|
|
1540
|
+
| <a id="maxretries-1"></a> `maxRetries?` | `number` | Maximum retry attempts before sending to DLQ. **Minimum** 1 - Must be a positive integer (1 or greater) **Default** `3` | [types.ts:37](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L37) |
|
|
1541
|
+
| <a id="mode-1"></a> `mode` | `"ttl-backoff"` | TTL-Backoff mode uses wait queues with per-message TTL for exponential backoff. | [types.ts:31](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L31) |
|
|
1542
|
+
| <a id="retryexchangename"></a> `retryExchangeName?` | `string` | Name of the retry exchange. **Default** `'retry-exchange'` | [types.ts:72](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L72) |
|
|
1543
|
+
| <a id="waitexchangename"></a> `waitExchangeName?` | `string` | Name of the wait exchange. **Default** `'wait-exchange'` | [types.ts:67](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L67) |
|
|
1544
|
+
| <a id="waitqueuename"></a> `waitQueueName?` | `string` | Name of the wait queue. **Default** `'{queueName}-wait'` | [types.ts:62](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/types.ts#L62) |
|
|
1479
1545
|
|
|
1480
1546
|
## Functions
|
|
1481
1547
|
|
|
@@ -1488,7 +1554,7 @@ function defineConsumer<TMessage>(
|
|
|
1488
1554
|
options?): ConsumerDefinition<TMessage>;
|
|
1489
1555
|
```
|
|
1490
1556
|
|
|
1491
|
-
Defined in: [builder/consumer.ts:120](https://github.com/btravers/amqp-contract/blob/
|
|
1557
|
+
Defined in: [builder/consumer.ts:120](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/consumer.ts#L120)
|
|
1492
1558
|
|
|
1493
1559
|
Define a message consumer.
|
|
1494
1560
|
|
|
@@ -1573,7 +1639,7 @@ const processOrderConsumer = defineConsumer(orderQueue, orderMessage);
|
|
|
1573
1639
|
function defineContract<TContract>(definition): ContractOutput<TContract>;
|
|
1574
1640
|
```
|
|
1575
1641
|
|
|
1576
|
-
Defined in: [builder/contract.ts:
|
|
1642
|
+
Defined in: [builder/contract.ts:136](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/contract.ts#L136)
|
|
1577
1643
|
|
|
1578
1644
|
Define an AMQP contract.
|
|
1579
1645
|
|
|
@@ -1661,7 +1727,7 @@ export const contract = defineContract({
|
|
|
1661
1727
|
function defineMessage<TPayload, THeaders>(payload, options?): MessageDefinition<TPayload, THeaders>;
|
|
1662
1728
|
```
|
|
1663
1729
|
|
|
1664
|
-
Defined in: [builder/message.ts:39](https://github.com/btravers/amqp-contract/blob/
|
|
1730
|
+
Defined in: [builder/message.ts:39](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/message.ts#L39)
|
|
1665
1731
|
|
|
1666
1732
|
Define a message definition with payload and optional headers/metadata.
|
|
1667
1733
|
|
|
@@ -1724,7 +1790,7 @@ const orderMessage = defineMessage(
|
|
|
1724
1790
|
function defineQueue<TName, TDlx>(name, options): QueueEntryWithDeadLetterExchange<TName, TDlx>;
|
|
1725
1791
|
```
|
|
1726
1792
|
|
|
1727
|
-
Defined in: [builder/queue.ts:113](https://github.com/btravers/amqp-contract/blob/
|
|
1793
|
+
Defined in: [builder/queue.ts:113](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/queue.ts#L113)
|
|
1728
1794
|
|
|
1729
1795
|
Define an AMQP queue.
|
|
1730
1796
|
|
|
@@ -1802,7 +1868,7 @@ const orderQueue = defineQueue('order-processing', {
|
|
|
1802
1868
|
function defineQueue<TName>(name, options?): QueueEntry<TName>;
|
|
1803
1869
|
```
|
|
1804
1870
|
|
|
1805
|
-
Defined in: [builder/queue.ts:118](https://github.com/btravers/amqp-contract/blob/
|
|
1871
|
+
Defined in: [builder/queue.ts:118](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/queue.ts#L118)
|
|
1806
1872
|
|
|
1807
1873
|
Define an AMQP queue.
|
|
1808
1874
|
|
|
@@ -1875,13 +1941,75 @@ const orderQueue = defineQueue('order-processing', {
|
|
|
1875
1941
|
|
|
1876
1942
|
***
|
|
1877
1943
|
|
|
1944
|
+
### defineRpc()
|
|
1945
|
+
|
|
1946
|
+
```ts
|
|
1947
|
+
function defineRpc<TRequestMessage, TResponseMessage, TQueue>(queue, messages): RpcDefinition<TRequestMessage, TResponseMessage, TQueue>;
|
|
1948
|
+
```
|
|
1949
|
+
|
|
1950
|
+
Defined in: [builder/rpc.ts:41](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/rpc.ts#L41)
|
|
1951
|
+
|
|
1952
|
+
Define an RPC operation: a request/response pair flowing over a request
|
|
1953
|
+
queue with replies routed back via RabbitMQ direct reply-to.
|
|
1954
|
+
|
|
1955
|
+
RPC is bidirectional on both ends — the worker handler consumes the request
|
|
1956
|
+
and produces the response; `client.call(name, request, options)` publishes
|
|
1957
|
+
the request and awaits the typed response. Both sides share the same
|
|
1958
|
+
definition, so request and response schemas cannot drift between them.
|
|
1959
|
+
|
|
1960
|
+
Plug the result into `defineContract({ rpcs: { name: ... } })`. RPCs do not
|
|
1961
|
+
appear in `publishers` or `consumers`.
|
|
1962
|
+
|
|
1963
|
+
#### Type Parameters
|
|
1964
|
+
|
|
1965
|
+
| Type Parameter |
|
|
1966
|
+
| ------ |
|
|
1967
|
+
| `TRequestMessage` *extends* [`MessageDefinition`](#messagedefinition) |
|
|
1968
|
+
| `TResponseMessage` *extends* [`MessageDefinition`](#messagedefinition) |
|
|
1969
|
+
| `TQueue` *extends* [`QueueEntry`](#queueentry) |
|
|
1970
|
+
|
|
1971
|
+
#### Parameters
|
|
1972
|
+
|
|
1973
|
+
| Parameter | Type | Description |
|
|
1974
|
+
| ------ | ------ | ------ |
|
|
1975
|
+
| `queue` | `TQueue` | The queue that receives RPC requests. The queue name is used as the routing key on the AMQP default direct exchange. |
|
|
1976
|
+
| `messages` | \{ `request`: `TRequestMessage`; `response`: `TResponseMessage`; \} | - |
|
|
1977
|
+
| `messages.request` | `TRequestMessage` | Schema validated against incoming request payloads (server side) and outgoing requests (client side). |
|
|
1978
|
+
| `messages.response` | `TResponseMessage` | Schema validated against handler return values (server side) and incoming replies (client side). |
|
|
1979
|
+
|
|
1980
|
+
#### Returns
|
|
1981
|
+
|
|
1982
|
+
[`RpcDefinition`](#rpcdefinition)<`TRequestMessage`, `TResponseMessage`, `TQueue`>
|
|
1983
|
+
|
|
1984
|
+
#### Example
|
|
1985
|
+
|
|
1986
|
+
```typescript
|
|
1987
|
+
import { defineQueue, defineMessage, defineRpc, defineContract } from '@amqp-contract/contract';
|
|
1988
|
+
import { z } from 'zod';
|
|
1989
|
+
|
|
1990
|
+
const calculate = defineRpc(defineQueue('rpc.calculate'), {
|
|
1991
|
+
request: defineMessage(z.object({ a: z.number(), b: z.number() })),
|
|
1992
|
+
response: defineMessage(z.object({ sum: z.number() })),
|
|
1993
|
+
});
|
|
1994
|
+
|
|
1995
|
+
const contract = defineContract({ rpcs: { calculate } });
|
|
1996
|
+
|
|
1997
|
+
// Server (worker): handler returns the typed response
|
|
1998
|
+
// handlers: { calculate: ({ payload }) => Future.value(Result.Ok({ sum: payload.a + payload.b })) }
|
|
1999
|
+
|
|
2000
|
+
// Client: typed call with required timeout
|
|
2001
|
+
// const result = await client.call('calculate', { a: 1, b: 2 }, { timeoutMs: 5_000 }).toPromise();
|
|
2002
|
+
```
|
|
2003
|
+
|
|
2004
|
+
***
|
|
2005
|
+
|
|
1878
2006
|
### extractConsumer()
|
|
1879
2007
|
|
|
1880
2008
|
```ts
|
|
1881
2009
|
function extractConsumer(entry): ConsumerDefinition;
|
|
1882
2010
|
```
|
|
1883
2011
|
|
|
1884
|
-
Defined in: [builder/consumer.ts:54](https://github.com/btravers/amqp-contract/blob/
|
|
2012
|
+
Defined in: [builder/consumer.ts:54](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/consumer.ts#L54)
|
|
1885
2013
|
|
|
1886
2014
|
Extract the ConsumerDefinition from any ConsumerEntry type.
|
|
1887
2015
|
|
|
@@ -1930,7 +2058,7 @@ extractConsumer(consumer3).queue.name; // "my-queue"
|
|
|
1930
2058
|
function extractQueue<T>(entry): ExtractQueueFromEntry<T>;
|
|
1931
2059
|
```
|
|
1932
2060
|
|
|
1933
|
-
Defined in: [builder/queue-utils.ts:60](https://github.com/btravers/amqp-contract/blob/
|
|
2061
|
+
Defined in: [builder/queue-utils.ts:60](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/queue-utils.ts#L60)
|
|
1934
2062
|
|
|
1935
2063
|
Extract the plain QueueDefinition from a QueueEntry.
|
|
1936
2064
|
|
|
@@ -2002,7 +2130,7 @@ isQueueWithTtlBackoffInfrastructure - Type guard to check if extraction is neede
|
|
|
2002
2130
|
function isBridgedPublisherConfig(value): value is BridgedPublisherConfig<MessageDefinition, ExchangeDefinition, ExchangeDefinition>;
|
|
2003
2131
|
```
|
|
2004
2132
|
|
|
2005
|
-
Defined in: [builder/command.ts:514](https://github.com/btravers/amqp-contract/blob/
|
|
2133
|
+
Defined in: [builder/command.ts:514](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L514)
|
|
2006
2134
|
|
|
2007
2135
|
Type guard to check if a value is a BridgedPublisherConfig.
|
|
2008
2136
|
|
|
@@ -2026,7 +2154,7 @@ True if the value is a BridgedPublisherConfig
|
|
|
2026
2154
|
function isCommandConsumerConfig(value): value is CommandConsumerConfig<MessageDefinition, ExchangeDefinition, string | undefined, QueueEntry>;
|
|
2027
2155
|
```
|
|
2028
2156
|
|
|
2029
|
-
Defined in: [builder/command.ts:497](https://github.com/btravers/amqp-contract/blob/
|
|
2157
|
+
Defined in: [builder/command.ts:497](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/command.ts#L497)
|
|
2030
2158
|
|
|
2031
2159
|
Type guard to check if a value is a CommandConsumerConfig.
|
|
2032
2160
|
|
|
@@ -2050,7 +2178,7 @@ True if the value is a CommandConsumerConfig
|
|
|
2050
2178
|
function isEventConsumerResult(value): value is EventConsumerResult<MessageDefinition, ExchangeDefinition, QueueEntry, ExchangeBindingDefinition | undefined, ExchangeDefinition | undefined>;
|
|
2051
2179
|
```
|
|
2052
2180
|
|
|
2053
|
-
Defined in: [builder/event.ts:616](https://github.com/btravers/amqp-contract/blob/
|
|
2181
|
+
Defined in: [builder/event.ts:616](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L616)
|
|
2054
2182
|
|
|
2055
2183
|
Type guard to check if a value is an EventConsumerResult.
|
|
2056
2184
|
|
|
@@ -2074,7 +2202,7 @@ True if the value is an EventConsumerResult
|
|
|
2074
2202
|
function isEventPublisherConfig(value): value is EventPublisherConfig<MessageDefinition, ExchangeDefinition, string | undefined>;
|
|
2075
2203
|
```
|
|
2076
2204
|
|
|
2077
|
-
Defined in: [builder/event.ts:599](https://github.com/btravers/amqp-contract/blob/
|
|
2205
|
+
Defined in: [builder/event.ts:599](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/event.ts#L599)
|
|
2078
2206
|
|
|
2079
2207
|
Type guard to check if a value is an EventPublisherConfig.
|
|
2080
2208
|
|
|
@@ -2098,7 +2226,7 @@ True if the value is an EventPublisherConfig
|
|
|
2098
2226
|
function isQueueWithTtlBackoffInfrastructure(entry): entry is QueueWithTtlBackoffInfrastructure;
|
|
2099
2227
|
```
|
|
2100
2228
|
|
|
2101
|
-
Defined in: [builder/ttl-backoff.ts:43](https://github.com/btravers/amqp-contract/blob/
|
|
2229
|
+
Defined in: [builder/ttl-backoff.ts:43](https://github.com/btravers/amqp-contract/blob/cb947e699b512bf57d7ddfcc5ae6e2531e8dfa43/packages/contract/src/builder/ttl-backoff.ts#L43)
|
|
2102
2230
|
|
|
2103
2231
|
Type guard to check if a queue entry is a QueueWithTtlBackoffInfrastructure.
|
|
2104
2232
|
|