@amqp-contract/contract 0.6.0 → 0.7.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 +23 -19
- package/dist/index.cjs +21 -2
- package/dist/index.d.cts +46 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +46 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +21 -2
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +122 -73
- package/package.json +12 -5
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/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/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 = object;
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
Defined in: [types.ts:
|
|
35
|
+
Defined in: [types.ts:50](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L50)
|
|
36
36
|
|
|
37
37
|
Base definition of an AMQP exchange.
|
|
38
38
|
|
|
@@ -43,11 +43,11 @@ type and routing rules. This type contains properties common to all exchange typ
|
|
|
43
43
|
|
|
44
44
|
| Property | Type | Description | Defined in |
|
|
45
45
|
| ------ | ------ | ------ | ------ |
|
|
46
|
-
| <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:
|
|
47
|
-
| <a id="autodelete"></a> `autoDelete?` | `boolean` | If true, the exchange is deleted when all queues have finished using it. **Default** `false` | [types.ts:
|
|
48
|
-
| <a id="durable"></a> `durable?` | `boolean` | If true, the exchange survives broker restarts. Durable exchanges are persisted to disk. **Default** `false` | [types.ts:
|
|
49
|
-
| <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. **Default** `false` | [types.ts:
|
|
50
|
-
| <a id="name"></a> `name` | `string` | The name of the exchange. Must be unique within the RabbitMQ virtual host. | [types.ts:
|
|
46
|
+
| <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:79](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L79) |
|
|
47
|
+
| <a id="autodelete"></a> `autoDelete?` | `boolean` | If true, the exchange is deleted when all queues have finished using it. **Default** `false` | [types.ts:66](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L66) |
|
|
48
|
+
| <a id="durable"></a> `durable?` | `boolean` | If true, the exchange survives broker restarts. Durable exchanges are persisted to disk. **Default** `false` | [types.ts:60](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L60) |
|
|
49
|
+
| <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. **Default** `false` | [types.ts:73](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L73) |
|
|
50
|
+
| <a id="name"></a> `name` | `string` | The name of the exchange. Must be unique within the RabbitMQ virtual host. | [types.ts:54](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L54) |
|
|
51
51
|
|
|
52
52
|
***
|
|
53
53
|
|
|
@@ -59,7 +59,7 @@ type BindingDefinition =
|
|
|
59
59
|
| ExchangeBindingDefinition;
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
Defined in: [types.ts:
|
|
62
|
+
Defined in: [types.ts:370](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L370)
|
|
63
63
|
|
|
64
64
|
Union type of all binding definitions.
|
|
65
65
|
|
|
@@ -75,7 +75,7 @@ A binding can be either:
|
|
|
75
75
|
type BindingPattern<S> = S extends "" ? never : S;
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Defined in: [builder.ts:
|
|
78
|
+
Defined in: [builder.ts:844](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L844)
|
|
79
79
|
|
|
80
80
|
Type-safe binding pattern that validates basic format and wildcards.
|
|
81
81
|
|
|
@@ -104,18 +104,58 @@ type Invalid = BindingPattern<"">; // never (empty string)
|
|
|
104
104
|
|
|
105
105
|
***
|
|
106
106
|
|
|
107
|
+
### CompressionAlgorithm
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
type CompressionAlgorithm = "gzip" | "deflate";
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Defined in: [types.ts:42](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L42)
|
|
114
|
+
|
|
115
|
+
Supported compression algorithms for message payloads.
|
|
116
|
+
|
|
117
|
+
- `gzip`: GZIP compression (standard, widely supported, good compression ratio)
|
|
118
|
+
- `deflate`: DEFLATE compression (faster than gzip, slightly less compression)
|
|
119
|
+
|
|
120
|
+
Compression is configured at runtime via PublishOptions when calling
|
|
121
|
+
AmqpClient.publish, not at publisher definition time.
|
|
122
|
+
|
|
123
|
+
When compression is enabled, the message payload is compressed before publishing
|
|
124
|
+
and automatically decompressed when consuming. The `content-encoding` AMQP
|
|
125
|
+
message property is set to indicate the compression algorithm used.
|
|
126
|
+
|
|
127
|
+
To disable compression, simply omit the `compression` option (it's optional).
|
|
128
|
+
|
|
129
|
+
#### Example
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// Define a publisher without compression configuration
|
|
133
|
+
const orderCreatedPublisher = definePublisher(exchange, message, {
|
|
134
|
+
routingKey: "order.created",
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Later, choose whether to compress at publish time
|
|
138
|
+
await client.publish("orderCreated", payload, {
|
|
139
|
+
compression: "gzip",
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
***
|
|
144
|
+
|
|
107
145
|
### ConsumerDefinition
|
|
108
146
|
|
|
109
147
|
```ts
|
|
110
148
|
type ConsumerDefinition<TMessage> = object;
|
|
111
149
|
```
|
|
112
150
|
|
|
113
|
-
Defined in: [types.ts:
|
|
151
|
+
Defined in: [types.ts:431](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L431)
|
|
114
152
|
|
|
115
153
|
Definition of a message consumer.
|
|
116
154
|
|
|
117
155
|
A consumer receives and processes messages from a queue with automatic schema validation.
|
|
118
156
|
The message payload is validated against the schema before being passed to your handler.
|
|
157
|
+
If the message is compressed (indicated by the content-encoding header), it will be
|
|
158
|
+
automatically decompressed before validation.
|
|
119
159
|
|
|
120
160
|
#### Example
|
|
121
161
|
|
|
@@ -136,8 +176,8 @@ const consumer: ConsumerDefinition = {
|
|
|
136
176
|
|
|
137
177
|
| Property | Type | Description | Defined in |
|
|
138
178
|
| ------ | ------ | ------ | ------ |
|
|
139
|
-
| <a id="message"></a> `message` | `TMessage` | The message definition including the payload schema | [types.ts:
|
|
140
|
-
| <a id="queue"></a> `queue` | [`QueueDefinition`](#queuedefinition) | The queue to consume messages from | [types.ts:
|
|
179
|
+
| <a id="message"></a> `message` | `TMessage` | The message definition including the payload schema | [types.ts:436](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L436) |
|
|
180
|
+
| <a id="queue"></a> `queue` | [`QueueDefinition`](#queuedefinition) | The queue to consume messages from | [types.ts:433](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L433) |
|
|
141
181
|
|
|
142
182
|
***
|
|
143
183
|
|
|
@@ -147,7 +187,7 @@ const consumer: ConsumerDefinition = {
|
|
|
147
187
|
type ConsumerFirstResult<TMessage, TConsumer, TBinding> = object;
|
|
148
188
|
```
|
|
149
189
|
|
|
150
|
-
Defined in: [builder.ts:
|
|
190
|
+
Defined in: [builder.ts:1221](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L1221)
|
|
151
191
|
|
|
152
192
|
Consumer-first builder result for fanout and direct exchanges.
|
|
153
193
|
|
|
@@ -166,9 +206,9 @@ a publisher that uses the same message schema and routing key.
|
|
|
166
206
|
|
|
167
207
|
| Property | Type | Description | Defined in |
|
|
168
208
|
| ------ | ------ | ------ | ------ |
|
|
169
|
-
| <a id="binding"></a> `binding` | `TBinding` | The binding definition connecting the exchange to the queue | [builder.ts:
|
|
170
|
-
| <a id="consumer"></a> `consumer` | `TConsumer` | The consumer definition | [builder.ts:
|
|
171
|
-
| <a id="createpublisher"></a> `createPublisher` | () => `TBinding`\[`"exchange"`\] *extends* [`FanoutExchangeDefinition`](#fanoutexchangedefinition) ? `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: [`FanoutExchangeDefinition`](#fanoutexchangedefinition); \}\> : `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: \| [`DirectExchangeDefinition`](#directexchangedefinition) \| [`TopicExchangeDefinition`](#topicexchangedefinition); \}\> | Create a publisher that sends messages to this consumer. The publisher will automatically use the same message schema and routing key. | [builder.ts:
|
|
209
|
+
| <a id="binding"></a> `binding` | `TBinding` | The binding definition connecting the exchange to the queue | [builder.ts:1229](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L1229) |
|
|
210
|
+
| <a id="consumer"></a> `consumer` | `TConsumer` | The consumer definition | [builder.ts:1227](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L1227) |
|
|
211
|
+
| <a id="createpublisher"></a> `createPublisher` | () => `TBinding`\[`"exchange"`\] *extends* [`FanoutExchangeDefinition`](#fanoutexchangedefinition) ? `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: [`FanoutExchangeDefinition`](#fanoutexchangedefinition); \}\> : `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: \| [`DirectExchangeDefinition`](#directexchangedefinition) \| [`TopicExchangeDefinition`](#topicexchangedefinition); \}\> | Create a publisher that sends messages to this consumer. The publisher will automatically use the same message schema and routing key. | [builder.ts:1236](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L1236) |
|
|
172
212
|
|
|
173
213
|
***
|
|
174
214
|
|
|
@@ -178,7 +218,7 @@ a publisher that uses the same message schema and routing key.
|
|
|
178
218
|
type ConsumerFirstResultWithRoutingKey<TMessage, TConsumer, TBinding> = object;
|
|
179
219
|
```
|
|
180
220
|
|
|
181
|
-
Defined in: [builder.ts:
|
|
221
|
+
Defined in: [builder.ts:1254](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L1254)
|
|
182
222
|
|
|
183
223
|
Consumer-first builder result for topic exchanges.
|
|
184
224
|
|
|
@@ -197,9 +237,9 @@ a method to create a publisher with a concrete routing key that matches the patt
|
|
|
197
237
|
|
|
198
238
|
| Property | Type | Description | Defined in |
|
|
199
239
|
| ------ | ------ | ------ | ------ |
|
|
200
|
-
| <a id="binding-1"></a> `binding` | `TBinding` | The binding definition connecting the exchange to the queue | [builder.ts:
|
|
201
|
-
| <a id="consumer-1"></a> `consumer` | `TConsumer` | The consumer definition | [builder.ts:
|
|
202
|
-
| <a id="createpublisher-1"></a> `createPublisher` | \<`TPublisherRoutingKey`\>(`routingKey`) => `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: \| [`DirectExchangeDefinition`](#directexchangedefinition) \| [`TopicExchangeDefinition`](#topicexchangedefinition); \}\> | Create a publisher that sends messages to this consumer. For topic exchanges, the routing key can be specified to match the binding pattern. | [builder.ts:
|
|
240
|
+
| <a id="binding-1"></a> `binding` | `TBinding` | The binding definition connecting the exchange to the queue | [builder.ts:1262](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L1262) |
|
|
241
|
+
| <a id="consumer-1"></a> `consumer` | `TConsumer` | The consumer definition | [builder.ts:1260](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L1260) |
|
|
242
|
+
| <a id="createpublisher-1"></a> `createPublisher` | \<`TPublisherRoutingKey`\>(`routingKey`) => `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: \| [`DirectExchangeDefinition`](#directexchangedefinition) \| [`TopicExchangeDefinition`](#topicexchangedefinition); \}\> | Create a publisher that sends messages to this consumer. For topic exchanges, the routing key can be specified to match the binding pattern. | [builder.ts:1270](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L1270) |
|
|
203
243
|
|
|
204
244
|
***
|
|
205
245
|
|
|
@@ -209,7 +249,7 @@ a method to create a publisher with a concrete routing key that matches the patt
|
|
|
209
249
|
type ContractDefinition = object;
|
|
210
250
|
```
|
|
211
251
|
|
|
212
|
-
Defined in: [types.ts:
|
|
252
|
+
Defined in: [types.ts:472](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L472)
|
|
213
253
|
|
|
214
254
|
Complete AMQP contract definition.
|
|
215
255
|
|
|
@@ -248,11 +288,11 @@ const contract: ContractDefinition = {
|
|
|
248
288
|
|
|
249
289
|
| Property | Type | Description | Defined in |
|
|
250
290
|
| ------ | ------ | ------ | ------ |
|
|
251
|
-
| <a id="bindings"></a> `bindings?` | `Record`\<`string`, [`BindingDefinition`](#bindingdefinition)\> | Named binding definitions. Bindings can be queue-to-exchange or exchange-to-exchange. | [types.ts:
|
|
252
|
-
| <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:
|
|
253
|
-
| <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:
|
|
254
|
-
| <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:
|
|
255
|
-
| <a id="queues"></a> `queues?` | `Record`\<`string`, [`QueueDefinition`](#queuedefinition)\> | Named queue definitions. Each key becomes available as a named resource in the contract. | [types.ts:
|
|
291
|
+
| <a id="bindings"></a> `bindings?` | `Record`\<`string`, [`BindingDefinition`](#bindingdefinition)\> | Named binding definitions. Bindings can be queue-to-exchange or exchange-to-exchange. | [types.ts:489](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L489) |
|
|
292
|
+
| <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:503](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L503) |
|
|
293
|
+
| <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:477](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L477) |
|
|
294
|
+
| <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:496](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L496) |
|
|
295
|
+
| <a id="queues"></a> `queues?` | `Record`\<`string`, [`QueueDefinition`](#queuedefinition)\> | Named queue definitions. Each key becomes available as a named resource in the contract. | [types.ts:483](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L483) |
|
|
256
296
|
|
|
257
297
|
***
|
|
258
298
|
|
|
@@ -262,7 +302,7 @@ const contract: ContractDefinition = {
|
|
|
262
302
|
type DeadLetterConfig = object;
|
|
263
303
|
```
|
|
264
304
|
|
|
265
|
-
Defined in: [types.ts:
|
|
305
|
+
Defined in: [types.ts:154](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L154)
|
|
266
306
|
|
|
267
307
|
Configuration for dead letter exchange (DLX) on a queue.
|
|
268
308
|
|
|
@@ -274,8 +314,8 @@ or storage.
|
|
|
274
314
|
|
|
275
315
|
| Property | Type | Description | Defined in |
|
|
276
316
|
| ------ | ------ | ------ | ------ |
|
|
277
|
-
| <a id="exchange"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | The exchange to send dead-lettered messages to. This exchange must be declared in the contract. | [types.ts:
|
|
278
|
-
| <a id="routingkey"></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:
|
|
317
|
+
| <a id="exchange"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | The exchange to send dead-lettered messages to. This exchange must be declared in the contract. | [types.ts:159](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L159) |
|
|
318
|
+
| <a id="routingkey"></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:165](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L165) |
|
|
279
319
|
|
|
280
320
|
***
|
|
281
321
|
|
|
@@ -285,7 +325,7 @@ or storage.
|
|
|
285
325
|
type DirectExchangeDefinition = BaseExchangeDefinition & object;
|
|
286
326
|
```
|
|
287
327
|
|
|
288
|
-
Defined in: [types.ts:
|
|
328
|
+
Defined in: [types.ts:112](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L112)
|
|
289
329
|
|
|
290
330
|
A direct exchange definition.
|
|
291
331
|
|
|
@@ -296,7 +336,7 @@ This is ideal for point-to-point messaging where each message should go to speci
|
|
|
296
336
|
|
|
297
337
|
| Name | Type | Defined in |
|
|
298
338
|
| ------ | ------ | ------ |
|
|
299
|
-
| `type` | `"direct"` | [types.ts:
|
|
339
|
+
| `type` | `"direct"` | [types.ts:113](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L113) |
|
|
300
340
|
|
|
301
341
|
#### Example
|
|
302
342
|
|
|
@@ -323,7 +363,7 @@ type ExchangeBindingDefinition = object &
|
|
|
323
363
|
};
|
|
324
364
|
```
|
|
325
365
|
|
|
326
|
-
Defined in: [types.ts:
|
|
366
|
+
Defined in: [types.ts:334](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L334)
|
|
327
367
|
|
|
328
368
|
Binding between two exchanges (exchange-to-exchange routing).
|
|
329
369
|
|
|
@@ -334,9 +374,9 @@ This allows for more complex routing topologies.
|
|
|
334
374
|
|
|
335
375
|
| Name | Type | Description | Defined in |
|
|
336
376
|
| ------ | ------ | ------ | ------ |
|
|
337
|
-
| `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. | [types.ts:
|
|
338
|
-
| `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:
|
|
339
|
-
| `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:
|
|
377
|
+
| `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. | [types.ts:344](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L344) |
|
|
378
|
+
| `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:339](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L339) |
|
|
379
|
+
| `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:336](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L336) |
|
|
340
380
|
|
|
341
381
|
#### Example
|
|
342
382
|
|
|
@@ -361,7 +401,7 @@ type ExchangeDefinition =
|
|
|
361
401
|
| TopicExchangeDefinition;
|
|
362
402
|
```
|
|
363
403
|
|
|
364
|
-
Defined in: [types.ts:
|
|
404
|
+
Defined in: [types.ts:142](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L142)
|
|
365
405
|
|
|
366
406
|
Union type of all exchange definitions.
|
|
367
407
|
|
|
@@ -375,7 +415,7 @@ Represents any type of AMQP exchange: fanout, direct, or topic.
|
|
|
375
415
|
type FanoutExchangeDefinition = BaseExchangeDefinition & object;
|
|
376
416
|
```
|
|
377
417
|
|
|
378
|
-
Defined in: [types.ts:
|
|
418
|
+
Defined in: [types.ts:95](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L95)
|
|
379
419
|
|
|
380
420
|
A fanout exchange definition.
|
|
381
421
|
|
|
@@ -386,7 +426,7 @@ This is the simplest exchange type for pub/sub messaging patterns.
|
|
|
386
426
|
|
|
387
427
|
| Name | Type | Defined in |
|
|
388
428
|
| ------ | ------ | ------ |
|
|
389
|
-
| `type` | `"fanout"` | [types.ts:
|
|
429
|
+
| `type` | `"fanout"` | [types.ts:96](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L96) |
|
|
390
430
|
|
|
391
431
|
#### Example
|
|
392
432
|
|
|
@@ -404,7 +444,7 @@ const logsExchange: FanoutExchangeDefinition = defineExchange('logs', 'fanout',
|
|
|
404
444
|
type InferConsumerNames<TContract> = TContract["consumers"] extends Record<string, unknown> ? keyof TContract["consumers"] : never;
|
|
405
445
|
```
|
|
406
446
|
|
|
407
|
-
Defined in: [types.ts:
|
|
447
|
+
Defined in: [types.ts:539](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L539)
|
|
408
448
|
|
|
409
449
|
Extract consumer names from a contract.
|
|
410
450
|
|
|
@@ -436,7 +476,7 @@ type ConsumerNames = InferConsumerNames<typeof myContract>;
|
|
|
436
476
|
type InferPublisherNames<TContract> = TContract["publishers"] extends Record<string, unknown> ? keyof TContract["publishers"] : never;
|
|
437
477
|
```
|
|
438
478
|
|
|
439
|
-
Defined in: [types.ts:
|
|
479
|
+
Defined in: [types.ts:521](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L521)
|
|
440
480
|
|
|
441
481
|
Extract publisher names from a contract.
|
|
442
482
|
|
|
@@ -468,7 +508,7 @@ type PublisherNames = InferPublisherNames<typeof myContract>;
|
|
|
468
508
|
type MatchingRoutingKey<Pattern, Key> = RoutingKey<Key> extends never ? never : BindingPattern<Pattern> extends never ? never : MatchesPattern<Key, Pattern> extends true ? Key : never;
|
|
469
509
|
```
|
|
470
510
|
|
|
471
|
-
Defined in: [builder.ts:
|
|
511
|
+
Defined in: [builder.ts:906](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L906)
|
|
472
512
|
|
|
473
513
|
Validate that a routing key matches a binding pattern.
|
|
474
514
|
|
|
@@ -500,7 +540,7 @@ type InvalidKey = MatchingRoutingKey<"order.*", "user.created">; // never
|
|
|
500
540
|
type MessageDefinition<TPayload, THeaders> = object;
|
|
501
541
|
```
|
|
502
542
|
|
|
503
|
-
Defined in: [types.ts:
|
|
543
|
+
Defined in: [types.ts:250](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L250)
|
|
504
544
|
|
|
505
545
|
Definition of a message with typed payload and optional headers.
|
|
506
546
|
|
|
@@ -515,10 +555,10 @@ Definition of a message with typed payload and optional headers.
|
|
|
515
555
|
|
|
516
556
|
| Property | Type | Description | Defined in |
|
|
517
557
|
| ------ | ------ | ------ | ------ |
|
|
518
|
-
| <a id="description"></a> `description?` | `string` | Detailed description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:
|
|
519
|
-
| <a id="headers"></a> `headers?` | `THeaders` | Optional headers schema for validating message metadata. Must be a Standard Schema v1 compatible schema. | [types.ts:
|
|
520
|
-
| <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:
|
|
521
|
-
| <a id="summary"></a> `summary?` | `string` | Brief description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:
|
|
558
|
+
| <a id="description"></a> `description?` | `string` | Detailed description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:276](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L276) |
|
|
559
|
+
| <a id="headers"></a> `headers?` | `THeaders` | Optional headers schema for validating message metadata. Must be a Standard Schema v1 compatible schema. | [types.ts:264](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L264) |
|
|
560
|
+
| <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:258](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L258) |
|
|
561
|
+
| <a id="summary"></a> `summary?` | `string` | Brief description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:270](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L270) |
|
|
522
562
|
|
|
523
563
|
***
|
|
524
564
|
|
|
@@ -537,18 +577,21 @@ type PublisherDefinition<TMessage> = object &
|
|
|
537
577
|
};
|
|
538
578
|
```
|
|
539
579
|
|
|
540
|
-
Defined in: [types.ts:
|
|
580
|
+
Defined in: [types.ts:392](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L392)
|
|
541
581
|
|
|
542
582
|
Definition of a message publisher.
|
|
543
583
|
|
|
544
584
|
A publisher sends messages to an exchange with automatic schema validation.
|
|
545
585
|
The message payload is validated against the schema before being sent to RabbitMQ.
|
|
546
586
|
|
|
587
|
+
Compression can be optionally applied at publish time by specifying a compression
|
|
588
|
+
algorithm when calling the publish method.
|
|
589
|
+
|
|
547
590
|
#### Type Declaration
|
|
548
591
|
|
|
549
592
|
| Name | Type | Description | Defined in |
|
|
550
593
|
| ------ | ------ | ------ | ------ |
|
|
551
|
-
| `message` | `TMessage` | The message definition including the payload schema | [types.ts:
|
|
594
|
+
| `message` | `TMessage` | The message definition including the payload schema | [types.ts:394](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L394) |
|
|
552
595
|
|
|
553
596
|
#### Type Parameters
|
|
554
597
|
|
|
@@ -574,7 +617,7 @@ const publisher: PublisherDefinition = {
|
|
|
574
617
|
type PublisherFirstResult<TMessage, TPublisher> = object;
|
|
575
618
|
```
|
|
576
619
|
|
|
577
|
-
Defined in: [builder.ts:
|
|
620
|
+
Defined in: [builder.ts:773](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L773)
|
|
578
621
|
|
|
579
622
|
Publisher-first builder result for fanout and direct exchanges.
|
|
580
623
|
|
|
@@ -595,8 +638,8 @@ emit events without knowing which queues will consume them.
|
|
|
595
638
|
|
|
596
639
|
| Property | Type | Description | Defined in |
|
|
597
640
|
| ------ | ------ | ------ | ------ |
|
|
598
|
-
| <a id="createconsumer"></a> `createConsumer` | (`queue`) => `object` | Create a consumer that receives messages from this publisher. The consumer will automatically use the same message schema and a binding will be created with the same routing key. | [builder.ts:
|
|
599
|
-
| <a id="publisher"></a> `publisher` | `TPublisher` | The publisher definition | [builder.ts:
|
|
641
|
+
| <a id="createconsumer"></a> `createConsumer` | (`queue`) => `object` | Create a consumer that receives messages from this publisher. The consumer will automatically use the same message schema and a binding will be created with the same routing key. | [builder.ts:787](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L787) |
|
|
642
|
+
| <a id="publisher"></a> `publisher` | `TPublisher` | The publisher definition | [builder.ts:778](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L778) |
|
|
600
643
|
|
|
601
644
|
***
|
|
602
645
|
|
|
@@ -606,7 +649,7 @@ emit events without knowing which queues will consume them.
|
|
|
606
649
|
type PublisherFirstResultWithRoutingKey<TMessage, TPublisher, TRoutingKey> = object;
|
|
607
650
|
```
|
|
608
651
|
|
|
609
|
-
Defined in: [builder.ts:
|
|
652
|
+
Defined in: [builder.ts:925](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L925)
|
|
610
653
|
|
|
611
654
|
Publisher-first builder result for topic exchanges.
|
|
612
655
|
|
|
@@ -625,8 +668,8 @@ to create consumers that can use routing key patterns matching the publisher's k
|
|
|
625
668
|
|
|
626
669
|
| Property | Type | Description | Defined in |
|
|
627
670
|
| ------ | ------ | ------ | ------ |
|
|
628
|
-
| <a id="createconsumer-1"></a> `createConsumer` | \<`TConsumerRoutingKey`\>(`queue`, `routingKey?`) => `object` | Create a consumer that receives messages from this publisher. For topic exchanges, the routing key pattern can be specified for the binding. | [builder.ts:
|
|
629
|
-
| <a id="publisher-1"></a> `publisher` | `TPublisher` | The publisher definition | [builder.ts:
|
|
671
|
+
| <a id="createconsumer-1"></a> `createConsumer` | \<`TConsumerRoutingKey`\>(`queue`, `routingKey?`) => `object` | Create a consumer that receives messages from this publisher. For topic exchanges, the routing key pattern can be specified for the binding. | [builder.ts:940](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L940) |
|
|
672
|
+
| <a id="publisher-1"></a> `publisher` | `TPublisher` | The publisher definition | [builder.ts:931](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L931) |
|
|
630
673
|
|
|
631
674
|
***
|
|
632
675
|
|
|
@@ -645,7 +688,7 @@ type QueueBindingDefinition = object &
|
|
|
645
688
|
};
|
|
646
689
|
```
|
|
647
690
|
|
|
648
|
-
Defined in: [types.ts:
|
|
691
|
+
Defined in: [types.ts:286](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L286)
|
|
649
692
|
|
|
650
693
|
Binding between a queue and an exchange.
|
|
651
694
|
|
|
@@ -657,9 +700,9 @@ For fanout exchanges, no routing key is needed as all messages are broadcast.
|
|
|
657
700
|
|
|
658
701
|
| Name | Type | Description | Defined in |
|
|
659
702
|
| ------ | ------ | ------ | ------ |
|
|
660
|
-
| `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. Can be used for advanced routing scenarios with the headers exchange type. | [types.ts:
|
|
661
|
-
| `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:
|
|
662
|
-
| `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:
|
|
703
|
+
| `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. Can be used for advanced routing scenarios with the headers exchange type. | [types.ts:297](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L297) |
|
|
704
|
+
| `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:291](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L291) |
|
|
705
|
+
| `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:288](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L288) |
|
|
663
706
|
|
|
664
707
|
***
|
|
665
708
|
|
|
@@ -669,7 +712,7 @@ For fanout exchanges, no routing key is needed as all messages are broadcast.
|
|
|
669
712
|
type QueueDefinition = object;
|
|
670
713
|
```
|
|
671
714
|
|
|
672
|
-
Defined in: [types.ts:
|
|
715
|
+
Defined in: [types.ts:174](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L174)
|
|
673
716
|
|
|
674
717
|
Definition of an AMQP queue.
|
|
675
718
|
|
|
@@ -680,12 +723,12 @@ to receive messages based on routing rules.
|
|
|
680
723
|
|
|
681
724
|
| Property | Type | Description | Defined in |
|
|
682
725
|
| ------ | ------ | ------ | ------ |
|
|
683
|
-
| <a id="arguments-1"></a> `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for advanced configuration. Common arguments include: - `x-message-ttl`: Message time-to-live in milliseconds - `x-expires`: Queue expiration time in milliseconds - `x-max-length`: Maximum number of messages in the queue - `x-max-length-bytes`: Maximum size of the queue in bytes - `x-max-priority`: Maximum priority level for priority queues Note: When using the `deadLetter` property, the `x-dead-letter-exchange` and `x-dead-letter-routing-key` arguments are automatically set and should not be specified in this arguments object. **Example** `{ 'x-message-ttl': 86400000, // 24 hours 'x-max-priority': 10 }` | [types.ts:
|
|
684
|
-
| <a id="autodelete-1"></a> `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. **Default** `false` | [types.ts:
|
|
685
|
-
| <a id="deadletter"></a> `deadLetter?` | [`DeadLetterConfig`](#deadletterconfig) | Dead letter configuration for handling failed or rejected messages. When configured, messages that are rejected, expire, or exceed queue limits will be automatically forwarded to the specified dead letter exchange. **Example** `const dlx = defineExchange('orders-dlx', 'topic', { durable: true }); const queue = defineQueue('order-processing', { durable: true, deadLetter: { exchange: dlx, routingKey: 'order.failed' } });` | [types.ts:
|
|
686
|
-
| <a id="durable-1"></a> `durable?` | `boolean` | If true, the queue survives broker restarts. Durable queues are persisted to disk. **Default** `false` | [types.ts:
|
|
687
|
-
| <a id="exclusive"></a> `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. **Default** `false` | [types.ts:
|
|
688
|
-
| <a id="name-1"></a> `name` | `string` | The name of the queue. Must be unique within the RabbitMQ virtual host. | [types.ts:
|
|
726
|
+
| <a id="arguments-1"></a> `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for advanced configuration. Common arguments include: - `x-message-ttl`: Message time-to-live in milliseconds - `x-expires`: Queue expiration time in milliseconds - `x-max-length`: Maximum number of messages in the queue - `x-max-length-bytes`: Maximum size of the queue in bytes - `x-max-priority`: Maximum priority level for priority queues Note: When using the `deadLetter` property, the `x-dead-letter-exchange` and `x-dead-letter-routing-key` arguments are automatically set and should not be specified in this arguments object. **Example** `{ 'x-message-ttl': 86400000, // 24 hours 'x-max-priority': 10 }` | [types.ts:241](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L241) |
|
|
727
|
+
| <a id="autodelete-1"></a> `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. **Default** `false` | [types.ts:197](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L197) |
|
|
728
|
+
| <a id="deadletter"></a> `deadLetter?` | [`DeadLetterConfig`](#deadletterconfig) | Dead letter configuration for handling failed or rejected messages. When configured, messages that are rejected, expire, or exceed queue limits will be automatically forwarded to the specified dead letter exchange. **Example** `const dlx = defineExchange('orders-dlx', 'topic', { durable: true }); const queue = defineQueue('order-processing', { durable: true, deadLetter: { exchange: dlx, routingKey: 'order.failed' } });` | [types.ts:217](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L217) |
|
|
729
|
+
| <a id="durable-1"></a> `durable?` | `boolean` | If true, the queue survives broker restarts. Durable queues are persisted to disk. **Default** `false` | [types.ts:184](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L184) |
|
|
730
|
+
| <a id="exclusive"></a> `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. **Default** `false` | [types.ts:191](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L191) |
|
|
731
|
+
| <a id="name-1"></a> `name` | `string` | The name of the queue. Must be unique within the RabbitMQ virtual host. | [types.ts:178](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L178) |
|
|
689
732
|
|
|
690
733
|
***
|
|
691
734
|
|
|
@@ -695,7 +738,7 @@ to receive messages based on routing rules.
|
|
|
695
738
|
type RoutingKey<S> = S extends "" ? never : S extends `${string}*${string}` | `${string}#${string}` ? never : S;
|
|
696
739
|
```
|
|
697
740
|
|
|
698
|
-
Defined in: [builder.ts:
|
|
741
|
+
Defined in: [builder.ts:817](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L817)
|
|
699
742
|
|
|
700
743
|
Type-safe routing key that validates basic format.
|
|
701
744
|
|
|
@@ -729,7 +772,7 @@ type Invalid2 = RoutingKey<"">; // never (empty string)
|
|
|
729
772
|
type TopicExchangeDefinition = BaseExchangeDefinition & object;
|
|
730
773
|
```
|
|
731
774
|
|
|
732
|
-
Defined in: [types.ts:
|
|
775
|
+
Defined in: [types.ts:133](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L133)
|
|
733
776
|
|
|
734
777
|
A topic exchange definition.
|
|
735
778
|
|
|
@@ -743,7 +786,7 @@ Words are separated by dots (e.g., `order.created.high-value`).
|
|
|
743
786
|
|
|
744
787
|
| Name | Type | Defined in |
|
|
745
788
|
| ------ | ------ | ------ |
|
|
746
|
-
| `type` | `"topic"` | [types.ts:
|
|
789
|
+
| `type` | `"topic"` | [types.ts:134](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L134) |
|
|
747
790
|
|
|
748
791
|
#### Example
|
|
749
792
|
|
|
@@ -765,7 +808,7 @@ function defineConsumer<TMessage>(
|
|
|
765
808
|
options?): ConsumerDefinition<TMessage>;
|
|
766
809
|
```
|
|
767
810
|
|
|
768
|
-
Defined in: [builder.ts:
|
|
811
|
+
Defined in: [builder.ts:634](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L634)
|
|
769
812
|
|
|
770
813
|
Define a message consumer.
|
|
771
814
|
|
|
@@ -832,7 +875,7 @@ const processOrderConsumer = defineConsumer(orderQueue, orderMessage);
|
|
|
832
875
|
function defineContract<TContract>(definition): TContract;
|
|
833
876
|
```
|
|
834
877
|
|
|
835
|
-
Defined in: [builder.ts:
|
|
878
|
+
Defined in: [builder.ts:715](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L715)
|
|
836
879
|
|
|
837
880
|
Define an AMQP contract.
|
|
838
881
|
|
|
@@ -921,7 +964,7 @@ export const contract = defineContract({
|
|
|
921
964
|
function defineMessage<TPayload, THeaders>(payload, options?): MessageDefinition<TPayload, THeaders>;
|
|
922
965
|
```
|
|
923
966
|
|
|
924
|
-
Defined in: [builder.ts:
|
|
967
|
+
Defined in: [builder.ts:236](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L236)
|
|
925
968
|
|
|
926
969
|
Define a message definition with payload and optional headers/metadata.
|
|
927
970
|
|
|
@@ -982,7 +1025,7 @@ const orderMessage = defineMessage(
|
|
|
982
1025
|
function defineQueue(name, options?): QueueDefinition;
|
|
983
1026
|
```
|
|
984
1027
|
|
|
985
|
-
Defined in: [builder.ts:
|
|
1028
|
+
Defined in: [builder.ts:170](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L170)
|
|
986
1029
|
|
|
987
1030
|
Define an AMQP queue.
|
|
988
1031
|
|
|
@@ -994,7 +1037,7 @@ to receive messages based on routing rules.
|
|
|
994
1037
|
| Parameter | Type | Description |
|
|
995
1038
|
| ------ | ------ | ------ |
|
|
996
1039
|
| `name` | `string` | The name of the queue |
|
|
997
|
-
| `options?` | `Omit`\<[`QueueDefinition`](#queuedefinition), `"name"`\> | Optional queue configuration |
|
|
1040
|
+
| `options?` | `Omit`\<[`QueueDefinition`](#queuedefinition), `"name"`\> & `object` | Optional queue configuration |
|
|
998
1041
|
|
|
999
1042
|
#### Returns
|
|
1000
1043
|
|
|
@@ -1010,6 +1053,12 @@ const orderQueue = defineQueue('order-processing', {
|
|
|
1010
1053
|
durable: true,
|
|
1011
1054
|
});
|
|
1012
1055
|
|
|
1056
|
+
// Priority queue with max priority of 10
|
|
1057
|
+
const taskQueue = defineQueue('urgent-tasks', {
|
|
1058
|
+
durable: true,
|
|
1059
|
+
maxPriority: 10,
|
|
1060
|
+
});
|
|
1061
|
+
|
|
1013
1062
|
// Queue with dead letter exchange
|
|
1014
1063
|
const dlx = defineExchange('orders-dlx', 'topic', { durable: true });
|
|
1015
1064
|
const orderQueueWithDLX = defineQueue('order-processing', {
|
package/package.json
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amqp-contract/contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Contract builder for amqp-contract",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"amqp",
|
|
7
7
|
"contract",
|
|
8
8
|
"rabbitmq",
|
|
9
|
-
"typescript"
|
|
9
|
+
"typescript",
|
|
10
|
+
"nodejs",
|
|
11
|
+
"messaging",
|
|
12
|
+
"type-safe",
|
|
13
|
+
"schema",
|
|
14
|
+
"validation",
|
|
15
|
+
"message-broker",
|
|
16
|
+
"message-queue",
|
|
17
|
+
"schema-validation"
|
|
10
18
|
],
|
|
11
19
|
"homepage": "https://github.com/btravers/amqp-contract#readme",
|
|
12
20
|
"bugs": {
|
|
@@ -45,12 +53,12 @@
|
|
|
45
53
|
},
|
|
46
54
|
"devDependencies": {
|
|
47
55
|
"@vitest/coverage-v8": "4.0.16",
|
|
48
|
-
"tsdown": "0.18.
|
|
56
|
+
"tsdown": "0.18.4",
|
|
49
57
|
"typedoc": "0.28.15",
|
|
50
58
|
"typedoc-plugin-markdown": "4.9.0",
|
|
51
59
|
"typescript": "5.9.3",
|
|
52
60
|
"vitest": "4.0.16",
|
|
53
|
-
"zod": "4.
|
|
61
|
+
"zod": "4.3.5",
|
|
54
62
|
"@amqp-contract/tsconfig": "0.0.0",
|
|
55
63
|
"@amqp-contract/typedoc": "0.0.1"
|
|
56
64
|
},
|
|
@@ -59,7 +67,6 @@
|
|
|
59
67
|
"build:docs": "typedoc",
|
|
60
68
|
"dev": "tsdown src/index.ts --format cjs,esm --dts --watch",
|
|
61
69
|
"test": "vitest run",
|
|
62
|
-
"test:watch": "vitest",
|
|
63
70
|
"typecheck": "tsc --noEmit"
|
|
64
71
|
}
|
|
65
72
|
}
|