@amqp-contract/contract 0.5.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/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/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L12)
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:20](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L20)
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:49](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L49) |
47
- | <a id="autodelete"></a> `autoDelete?` | `boolean` | If true, the exchange is deleted when all queues have finished using it. **Default** `false` | [types.ts:36](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L36) |
48
- | <a id="durable"></a> `durable?` | `boolean` | If true, the exchange survives broker restarts. Durable exchanges are persisted to disk. **Default** `false` | [types.ts:30](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L30) |
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:43](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L43) |
50
- | <a id="name"></a> `name` | `string` | The name of the exchange. Must be unique within the RabbitMQ virtual host. | [types.ts:24](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L24) |
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:298](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L298)
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:805](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L805)
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:354](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L354)
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:359](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L359) |
140
- | <a id="queue"></a> `queue` | [`QueueDefinition`](#queuedefinition) | The queue to consume messages from | [types.ts:356](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L356) |
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:1182](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L1182)
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:1190](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L1190) |
170
- | <a id="consumer"></a> `consumer` | `TConsumer` | The consumer definition | [builder.ts:1188](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L1188) |
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:1197](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L1197) |
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:1215](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L1215)
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:1223](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L1223) |
201
- | <a id="consumer-1"></a> `consumer` | `TConsumer` | The consumer definition | [builder.ts:1221](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L1221) |
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:1231](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L1231) |
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:395](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L395)
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,34 @@ 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:412](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L412) |
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:426](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L426) |
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:400](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L400) |
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:419](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L419) |
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:406](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L406) |
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) |
296
+
297
+ ***
298
+
299
+ ### DeadLetterConfig
300
+
301
+ ```ts
302
+ type DeadLetterConfig = object;
303
+ ```
304
+
305
+ Defined in: [types.ts:154](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L154)
306
+
307
+ Configuration for dead letter exchange (DLX) on a queue.
308
+
309
+ When a message in a queue is rejected, expires, or exceeds the queue length limit,
310
+ it can be automatically forwarded to a dead letter exchange for further processing
311
+ or storage.
312
+
313
+ #### Properties
314
+
315
+ | Property | Type | Description | Defined in |
316
+ | ------ | ------ | ------ | ------ |
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) |
256
319
 
257
320
  ***
258
321
 
@@ -262,7 +325,7 @@ const contract: ContractDefinition = {
262
325
  type DirectExchangeDefinition = BaseExchangeDefinition & object;
263
326
  ```
264
327
 
265
- Defined in: [types.ts:82](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L82)
328
+ Defined in: [types.ts:112](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L112)
266
329
 
267
330
  A direct exchange definition.
268
331
 
@@ -273,7 +336,7 @@ This is ideal for point-to-point messaging where each message should go to speci
273
336
 
274
337
  | Name | Type | Defined in |
275
338
  | ------ | ------ | ------ |
276
- | `type` | `"direct"` | [types.ts:83](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L83) |
339
+ | `type` | `"direct"` | [types.ts:113](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L113) |
277
340
 
278
341
  #### Example
279
342
 
@@ -300,7 +363,7 @@ type ExchangeBindingDefinition = object &
300
363
  };
301
364
  ```
302
365
 
303
- Defined in: [types.ts:262](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L262)
366
+ Defined in: [types.ts:334](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L334)
304
367
 
305
368
  Binding between two exchanges (exchange-to-exchange routing).
306
369
 
@@ -311,9 +374,9 @@ This allows for more complex routing topologies.
311
374
 
312
375
  | Name | Type | Description | Defined in |
313
376
  | ------ | ------ | ------ | ------ |
314
- | `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. | [types.ts:272](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L272) |
315
- | `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:267](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L267) |
316
- | `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:264](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L264) |
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) |
317
380
 
318
381
  #### Example
319
382
 
@@ -338,7 +401,7 @@ type ExchangeDefinition =
338
401
  | TopicExchangeDefinition;
339
402
  ```
340
403
 
341
- Defined in: [types.ts:112](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L112)
404
+ Defined in: [types.ts:142](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L142)
342
405
 
343
406
  Union type of all exchange definitions.
344
407
 
@@ -352,7 +415,7 @@ Represents any type of AMQP exchange: fanout, direct, or topic.
352
415
  type FanoutExchangeDefinition = BaseExchangeDefinition & object;
353
416
  ```
354
417
 
355
- Defined in: [types.ts:65](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L65)
418
+ Defined in: [types.ts:95](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L95)
356
419
 
357
420
  A fanout exchange definition.
358
421
 
@@ -363,7 +426,7 @@ This is the simplest exchange type for pub/sub messaging patterns.
363
426
 
364
427
  | Name | Type | Defined in |
365
428
  | ------ | ------ | ------ |
366
- | `type` | `"fanout"` | [types.ts:66](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L66) |
429
+ | `type` | `"fanout"` | [types.ts:96](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L96) |
367
430
 
368
431
  #### Example
369
432
 
@@ -381,7 +444,7 @@ const logsExchange: FanoutExchangeDefinition = defineExchange('logs', 'fanout',
381
444
  type InferConsumerNames<TContract> = TContract["consumers"] extends Record<string, unknown> ? keyof TContract["consumers"] : never;
382
445
  ```
383
446
 
384
- Defined in: [types.ts:462](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L462)
447
+ Defined in: [types.ts:539](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L539)
385
448
 
386
449
  Extract consumer names from a contract.
387
450
 
@@ -413,7 +476,7 @@ type ConsumerNames = InferConsumerNames<typeof myContract>;
413
476
  type InferPublisherNames<TContract> = TContract["publishers"] extends Record<string, unknown> ? keyof TContract["publishers"] : never;
414
477
  ```
415
478
 
416
- Defined in: [types.ts:444](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L444)
479
+ Defined in: [types.ts:521](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L521)
417
480
 
418
481
  Extract publisher names from a contract.
419
482
 
@@ -445,7 +508,7 @@ type PublisherNames = InferPublisherNames<typeof myContract>;
445
508
  type MatchingRoutingKey<Pattern, Key> = RoutingKey<Key> extends never ? never : BindingPattern<Pattern> extends never ? never : MatchesPattern<Key, Pattern> extends true ? Key : never;
446
509
  ```
447
510
 
448
- Defined in: [builder.ts:867](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L867)
511
+ Defined in: [builder.ts:906](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L906)
449
512
 
450
513
  Validate that a routing key matches a binding pattern.
451
514
 
@@ -477,7 +540,7 @@ type InvalidKey = MatchingRoutingKey<"order.*", "user.created">; // never
477
540
  type MessageDefinition<TPayload, THeaders> = object;
478
541
  ```
479
542
 
480
- Defined in: [types.ts:178](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L178)
543
+ Defined in: [types.ts:250](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L250)
481
544
 
482
545
  Definition of a message with typed payload and optional headers.
483
546
 
@@ -492,10 +555,10 @@ Definition of a message with typed payload and optional headers.
492
555
 
493
556
  | Property | Type | Description | Defined in |
494
557
  | ------ | ------ | ------ | ------ |
495
- | <a id="description"></a> `description?` | `string` | Detailed description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:204](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L204) |
496
- | <a id="headers"></a> `headers?` | `THeaders` | Optional headers schema for validating message metadata. Must be a Standard Schema v1 compatible schema. | [types.ts:192](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L192) |
497
- | <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:186](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L186) |
498
- | <a id="summary"></a> `summary?` | `string` | Brief description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:198](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L198) |
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) |
499
562
 
500
563
  ***
501
564
 
@@ -514,18 +577,21 @@ type PublisherDefinition<TMessage> = object &
514
577
  };
515
578
  ```
516
579
 
517
- Defined in: [types.ts:317](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L317)
580
+ Defined in: [types.ts:392](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L392)
518
581
 
519
582
  Definition of a message publisher.
520
583
 
521
584
  A publisher sends messages to an exchange with automatic schema validation.
522
585
  The message payload is validated against the schema before being sent to RabbitMQ.
523
586
 
587
+ Compression can be optionally applied at publish time by specifying a compression
588
+ algorithm when calling the publish method.
589
+
524
590
  #### Type Declaration
525
591
 
526
592
  | Name | Type | Description | Defined in |
527
593
  | ------ | ------ | ------ | ------ |
528
- | `message` | `TMessage` | The message definition including the payload schema | [types.ts:319](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L319) |
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) |
529
595
 
530
596
  #### Type Parameters
531
597
 
@@ -551,7 +617,7 @@ const publisher: PublisherDefinition = {
551
617
  type PublisherFirstResult<TMessage, TPublisher> = object;
552
618
  ```
553
619
 
554
- Defined in: [builder.ts:734](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L734)
620
+ Defined in: [builder.ts:773](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L773)
555
621
 
556
622
  Publisher-first builder result for fanout and direct exchanges.
557
623
 
@@ -572,8 +638,8 @@ emit events without knowing which queues will consume them.
572
638
 
573
639
  | Property | Type | Description | Defined in |
574
640
  | ------ | ------ | ------ | ------ |
575
- | <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:748](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L748) |
576
- | <a id="publisher"></a> `publisher` | `TPublisher` | The publisher definition | [builder.ts:739](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L739) |
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) |
577
643
 
578
644
  ***
579
645
 
@@ -583,7 +649,7 @@ emit events without knowing which queues will consume them.
583
649
  type PublisherFirstResultWithRoutingKey<TMessage, TPublisher, TRoutingKey> = object;
584
650
  ```
585
651
 
586
- Defined in: [builder.ts:886](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L886)
652
+ Defined in: [builder.ts:925](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L925)
587
653
 
588
654
  Publisher-first builder result for topic exchanges.
589
655
 
@@ -602,8 +668,8 @@ to create consumers that can use routing key patterns matching the publisher's k
602
668
 
603
669
  | Property | Type | Description | Defined in |
604
670
  | ------ | ------ | ------ | ------ |
605
- | <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:901](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L901) |
606
- | <a id="publisher-1"></a> `publisher` | `TPublisher` | The publisher definition | [builder.ts:892](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L892) |
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) |
607
673
 
608
674
  ***
609
675
 
@@ -622,7 +688,7 @@ type QueueBindingDefinition = object &
622
688
  };
623
689
  ```
624
690
 
625
- Defined in: [types.ts:214](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L214)
691
+ Defined in: [types.ts:286](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L286)
626
692
 
627
693
  Binding between a queue and an exchange.
628
694
 
@@ -634,9 +700,9 @@ For fanout exchanges, no routing key is needed as all messages are broadcast.
634
700
 
635
701
  | Name | Type | Description | Defined in |
636
702
  | ------ | ------ | ------ | ------ |
637
- | `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. Can be used for advanced routing scenarios with the headers exchange type. | [types.ts:225](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L225) |
638
- | `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:219](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L219) |
639
- | `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:216](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L216) |
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) |
640
706
 
641
707
  ***
642
708
 
@@ -646,7 +712,7 @@ For fanout exchanges, no routing key is needed as all messages are broadcast.
646
712
  type QueueDefinition = object;
647
713
  ```
648
714
 
649
- Defined in: [types.ts:123](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L123)
715
+ Defined in: [types.ts:174](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L174)
650
716
 
651
717
  Definition of an AMQP queue.
652
718
 
@@ -657,11 +723,12 @@ to receive messages based on routing rules.
657
723
 
658
724
  | Property | Type | Description | Defined in |
659
725
  | ------ | ------ | ------ | ------ |
660
- | <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-dead-letter-exchange`: Exchange for dead-lettered messages - `x-dead-letter-routing-key`: Routing key for dead-lettered messages - `x-max-priority`: Maximum priority level for priority queues **Example** `{ 'x-message-ttl': 86400000, // 24 hours 'x-dead-letter-exchange': 'dlx', 'x-max-priority': 10 }` | [types.ts:169](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L169) |
661
- | <a id="autodelete-1"></a> `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. **Default** `false` | [types.ts:146](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L146) |
662
- | <a id="durable-1"></a> `durable?` | `boolean` | If true, the queue survives broker restarts. Durable queues are persisted to disk. **Default** `false` | [types.ts:133](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L133) |
663
- | <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:140](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L140) |
664
- | <a id="name-1"></a> `name` | `string` | The name of the queue. Must be unique within the RabbitMQ virtual host. | [types.ts:127](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L127) |
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) |
665
732
 
666
733
  ***
667
734
 
@@ -671,7 +738,7 @@ to receive messages based on routing rules.
671
738
  type RoutingKey<S> = S extends "" ? never : S extends `${string}*${string}` | `${string}#${string}` ? never : S;
672
739
  ```
673
740
 
674
- Defined in: [builder.ts:778](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L778)
741
+ Defined in: [builder.ts:817](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L817)
675
742
 
676
743
  Type-safe routing key that validates basic format.
677
744
 
@@ -705,7 +772,7 @@ type Invalid2 = RoutingKey<"">; // never (empty string)
705
772
  type TopicExchangeDefinition = BaseExchangeDefinition & object;
706
773
  ```
707
774
 
708
- Defined in: [types.ts:103](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L103)
775
+ Defined in: [types.ts:133](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L133)
709
776
 
710
777
  A topic exchange definition.
711
778
 
@@ -719,7 +786,7 @@ Words are separated by dots (e.g., `order.created.high-value`).
719
786
 
720
787
  | Name | Type | Defined in |
721
788
  | ------ | ------ | ------ |
722
- | `type` | `"topic"` | [types.ts:104](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L104) |
789
+ | `type` | `"topic"` | [types.ts:134](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/types.ts#L134) |
723
790
 
724
791
  #### Example
725
792
 
@@ -741,7 +808,7 @@ function defineConsumer<TMessage>(
741
808
  options?): ConsumerDefinition<TMessage>;
742
809
  ```
743
810
 
744
- Defined in: [builder.ts:595](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L595)
811
+ Defined in: [builder.ts:634](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L634)
745
812
 
746
813
  Define a message consumer.
747
814
 
@@ -808,7 +875,7 @@ const processOrderConsumer = defineConsumer(orderQueue, orderMessage);
808
875
  function defineContract<TContract>(definition): TContract;
809
876
  ```
810
877
 
811
- Defined in: [builder.ts:676](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L676)
878
+ Defined in: [builder.ts:715](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L715)
812
879
 
813
880
  Define an AMQP contract.
814
881
 
@@ -897,7 +964,7 @@ export const contract = defineContract({
897
964
  function defineMessage<TPayload, THeaders>(payload, options?): MessageDefinition<TPayload, THeaders>;
898
965
  ```
899
966
 
900
- Defined in: [builder.ts:197](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L197)
967
+ Defined in: [builder.ts:236](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L236)
901
968
 
902
969
  Define a message definition with payload and optional headers/metadata.
903
970
 
@@ -958,7 +1025,7 @@ const orderMessage = defineMessage(
958
1025
  function defineQueue(name, options?): QueueDefinition;
959
1026
  ```
960
1027
 
961
- Defined in: [builder.ts:152](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L152)
1028
+ Defined in: [builder.ts:170](https://github.com/btravers/amqp-contract/blob/382c6d2fbfc563c9f6f16cb71cb33fd4a3d41d77/packages/contract/src/builder.ts#L170)
962
1029
 
963
1030
  Define an AMQP queue.
964
1031
 
@@ -970,7 +1037,7 @@ to receive messages based on routing rules.
970
1037
  | Parameter | Type | Description |
971
1038
  | ------ | ------ | ------ |
972
1039
  | `name` | `string` | The name of the queue |
973
- | `options?` | `Omit`\<[`QueueDefinition`](#queuedefinition), `"name"`\> | Optional queue configuration |
1040
+ | `options?` | `Omit`\<[`QueueDefinition`](#queuedefinition), `"name"`\> & `object` | Optional queue configuration |
974
1041
 
975
1042
  #### Returns
976
1043
 
@@ -981,11 +1048,27 @@ A queue definition
981
1048
  #### Example
982
1049
 
983
1050
  ```typescript
984
- const orderProcessingQueue = defineQueue('order-processing', {
1051
+ // Basic queue
1052
+ const orderQueue = defineQueue('order-processing', {
1053
+ durable: true,
1054
+ });
1055
+
1056
+ // Priority queue with max priority of 10
1057
+ const taskQueue = defineQueue('urgent-tasks', {
985
1058
  durable: true,
1059
+ maxPriority: 10,
1060
+ });
1061
+
1062
+ // Queue with dead letter exchange
1063
+ const dlx = defineExchange('orders-dlx', 'topic', { durable: true });
1064
+ const orderQueueWithDLX = defineQueue('order-processing', {
1065
+ durable: true,
1066
+ deadLetter: {
1067
+ exchange: dlx,
1068
+ routingKey: 'order.failed'
1069
+ },
986
1070
  arguments: {
987
1071
  'x-message-ttl': 86400000, // 24 hours
988
- 'x-dead-letter-exchange': 'orders-dlx'
989
1072
  }
990
1073
  });
991
1074
  ```
package/package.json CHANGED
@@ -1,12 +1,20 @@
1
1
  {
2
2
  "name": "@amqp-contract/contract",
3
- "version": "0.5.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.3",
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.2.1",
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
  }