@amqp-contract/contract 0.3.1 → 0.3.3
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 +1 -68
- package/docs/index.md +51 -51
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,74 +80,7 @@ const contract = defineContract({
|
|
|
80
80
|
|
|
81
81
|
## API
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Define an AMQP exchange. Returns an exchange definition object that can be referenced by bindings and publishers.
|
|
86
|
-
|
|
87
|
-
**Types:** `'fanout'`, `'direct'`, or `'topic'`
|
|
88
|
-
|
|
89
|
-
### `defineQueue(name, options?)`
|
|
90
|
-
|
|
91
|
-
Define an AMQP queue. Returns a queue definition object that can be referenced by bindings and consumers.
|
|
92
|
-
|
|
93
|
-
### `defineMessage(payloadSchema, options?)`
|
|
94
|
-
|
|
95
|
-
Define a message definition with a payload schema and optional metadata (headers, summary, description).
|
|
96
|
-
This is useful for documentation generation and type inference.
|
|
97
|
-
|
|
98
|
-
### `defineQueueBinding(queue, exchange, options?)`
|
|
99
|
-
|
|
100
|
-
Define a binding between a queue and an exchange. Pass the queue and exchange objects (not strings).
|
|
101
|
-
|
|
102
|
-
**For fanout exchanges:** Routing key is optional (fanout ignores routing keys).
|
|
103
|
-
**For direct/topic exchanges:** Routing key is required in options.
|
|
104
|
-
|
|
105
|
-
### `defineExchangeBinding(destination, source, options?)`
|
|
106
|
-
|
|
107
|
-
Define a binding between two exchanges (source → destination). Messages published to the source exchange will be routed to the destination exchange based on the routing key pattern.
|
|
108
|
-
|
|
109
|
-
Pass the exchange objects (not strings).
|
|
110
|
-
|
|
111
|
-
### `definePublisher(exchange, message, options?)`
|
|
112
|
-
|
|
113
|
-
Define a message publisher with validation schema. Pass the exchange object (not a string).
|
|
114
|
-
|
|
115
|
-
**For fanout exchanges:** Routing key is optional (fanout ignores routing keys).
|
|
116
|
-
**For direct/topic exchanges:** Routing key is required in options.
|
|
117
|
-
|
|
118
|
-
### `defineConsumer(queue, message, options?)`
|
|
119
|
-
|
|
120
|
-
Define a message consumer with validation schema. Pass the queue object (not a string).
|
|
121
|
-
|
|
122
|
-
### `defineContract(definition)`
|
|
123
|
-
|
|
124
|
-
Create a complete AMQP contract with exchanges, queues, bindings, publishers, and consumers.
|
|
125
|
-
|
|
126
|
-
## Key Concepts
|
|
127
|
-
|
|
128
|
-
### Composition Pattern
|
|
129
|
-
|
|
130
|
-
The contract API uses a composition pattern where you:
|
|
131
|
-
|
|
132
|
-
1. Define exchanges and queues first as variables
|
|
133
|
-
2. Reference these objects in bindings, publishers, and consumers
|
|
134
|
-
3. Compose everything together in `defineContract`
|
|
135
|
-
|
|
136
|
-
This provides:
|
|
137
|
-
|
|
138
|
-
- **Better type safety**: TypeScript can validate exchange/queue types
|
|
139
|
-
- **Better refactoring**: Rename an exchange in one place
|
|
140
|
-
- **DRY principle**: Define once, reference many times
|
|
141
|
-
|
|
142
|
-
### Exchange Types & Routing Keys
|
|
143
|
-
|
|
144
|
-
The API enforces routing key requirements based on exchange type:
|
|
145
|
-
|
|
146
|
-
- **Fanout exchanges**: Don't use routing keys (all messages go to all bound queues)
|
|
147
|
-
- **Direct exchanges**: Require explicit routing keys for exact matching
|
|
148
|
-
- **Topic exchanges**: Require routing key patterns (e.g., `order.*`, `order.#`)
|
|
149
|
-
|
|
150
|
-
TypeScript enforces these rules at compile time through discriminated unions.
|
|
83
|
+
For complete API documentation, see the [Contract API Reference](https://btravers.github.io/amqp-contract/api/contract).
|
|
151
84
|
|
|
152
85
|
## Documentation
|
|
153
86
|
|
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/fb7fe976925e332da34b847357ebcbeefd37355d/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/
|
|
35
|
+
Defined in: [types.ts:20](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L20)
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/fb7fe976925e332da34b847357ebcbeefd37355d/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/fb7fe976925e332da34b847357ebcbeefd37355d/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/fb7fe976925e332da34b847357ebcbeefd37355d/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/fb7fe976925e332da34b847357ebcbeefd37355d/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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L24) |
|
|
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/
|
|
62
|
+
Defined in: [types.ts:298](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L298)
|
|
63
63
|
|
|
64
64
|
Union type of all binding definitions.
|
|
65
65
|
|
|
@@ -75,7 +75,7 @@ A binding can be either:
|
|
|
75
75
|
type ConsumerDefinition<TMessage> = object;
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Defined in: [types.ts:354](https://github.com/btravers/amqp-contract/blob/
|
|
78
|
+
Defined in: [types.ts:354](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L354)
|
|
79
79
|
|
|
80
80
|
Definition of a message consumer.
|
|
81
81
|
|
|
@@ -101,8 +101,8 @@ const consumer: ConsumerDefinition = {
|
|
|
101
101
|
|
|
102
102
|
| Property | Type | Description | Defined in |
|
|
103
103
|
| ------ | ------ | ------ | ------ |
|
|
104
|
-
| <a id="message"></a> `message` | `TMessage` | The message definition including the payload schema | [types.ts:359](https://github.com/btravers/amqp-contract/blob/
|
|
105
|
-
| <a id="queue"></a> `queue` | [`QueueDefinition`](#queuedefinition) | The queue to consume messages from | [types.ts:356](https://github.com/btravers/amqp-contract/blob/
|
|
104
|
+
| <a id="message"></a> `message` | `TMessage` | The message definition including the payload schema | [types.ts:359](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L359) |
|
|
105
|
+
| <a id="queue"></a> `queue` | [`QueueDefinition`](#queuedefinition) | The queue to consume messages from | [types.ts:356](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L356) |
|
|
106
106
|
|
|
107
107
|
***
|
|
108
108
|
|
|
@@ -112,7 +112,7 @@ const consumer: ConsumerDefinition = {
|
|
|
112
112
|
type ContractDefinition = object;
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
Defined in: [types.ts:395](https://github.com/btravers/amqp-contract/blob/
|
|
115
|
+
Defined in: [types.ts:395](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L395)
|
|
116
116
|
|
|
117
117
|
Complete AMQP contract definition.
|
|
118
118
|
|
|
@@ -151,11 +151,11 @@ const contract: ContractDefinition = {
|
|
|
151
151
|
|
|
152
152
|
| Property | Type | Description | Defined in |
|
|
153
153
|
| ------ | ------ | ------ | ------ |
|
|
154
|
-
| <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/
|
|
155
|
-
| <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/
|
|
156
|
-
| <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/
|
|
157
|
-
| <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/
|
|
158
|
-
| <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/
|
|
154
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L412) |
|
|
155
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L426) |
|
|
156
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L400) |
|
|
157
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L419) |
|
|
158
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L406) |
|
|
159
159
|
|
|
160
160
|
***
|
|
161
161
|
|
|
@@ -165,7 +165,7 @@ const contract: ContractDefinition = {
|
|
|
165
165
|
type DirectExchangeDefinition = BaseExchangeDefinition & object;
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
Defined in: [types.ts:82](https://github.com/btravers/amqp-contract/blob/
|
|
168
|
+
Defined in: [types.ts:82](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L82)
|
|
169
169
|
|
|
170
170
|
A direct exchange definition.
|
|
171
171
|
|
|
@@ -176,7 +176,7 @@ This is ideal for point-to-point messaging where each message should go to speci
|
|
|
176
176
|
|
|
177
177
|
| Name | Type | Defined in |
|
|
178
178
|
| ------ | ------ | ------ |
|
|
179
|
-
| `type` | `"direct"` | [types.ts:83](https://github.com/btravers/amqp-contract/blob/
|
|
179
|
+
| `type` | `"direct"` | [types.ts:83](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L83) |
|
|
180
180
|
|
|
181
181
|
#### Example
|
|
182
182
|
|
|
@@ -203,7 +203,7 @@ type ExchangeBindingDefinition = object &
|
|
|
203
203
|
};
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
Defined in: [types.ts:262](https://github.com/btravers/amqp-contract/blob/
|
|
206
|
+
Defined in: [types.ts:262](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L262)
|
|
207
207
|
|
|
208
208
|
Binding between two exchanges (exchange-to-exchange routing).
|
|
209
209
|
|
|
@@ -214,9 +214,9 @@ This allows for more complex routing topologies.
|
|
|
214
214
|
|
|
215
215
|
| Name | Type | Description | Defined in |
|
|
216
216
|
| ------ | ------ | ------ | ------ |
|
|
217
|
-
| `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. | [types.ts:272](https://github.com/btravers/amqp-contract/blob/
|
|
218
|
-
| `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:267](https://github.com/btravers/amqp-contract/blob/
|
|
219
|
-
| `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:264](https://github.com/btravers/amqp-contract/blob/
|
|
217
|
+
| `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. | [types.ts:272](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L272) |
|
|
218
|
+
| `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:267](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L267) |
|
|
219
|
+
| `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:264](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L264) |
|
|
220
220
|
|
|
221
221
|
#### Example
|
|
222
222
|
|
|
@@ -241,7 +241,7 @@ type ExchangeDefinition =
|
|
|
241
241
|
| TopicExchangeDefinition;
|
|
242
242
|
```
|
|
243
243
|
|
|
244
|
-
Defined in: [types.ts:112](https://github.com/btravers/amqp-contract/blob/
|
|
244
|
+
Defined in: [types.ts:112](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L112)
|
|
245
245
|
|
|
246
246
|
Union type of all exchange definitions.
|
|
247
247
|
|
|
@@ -255,7 +255,7 @@ Represents any type of AMQP exchange: fanout, direct, or topic.
|
|
|
255
255
|
type FanoutExchangeDefinition = BaseExchangeDefinition & object;
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
-
Defined in: [types.ts:65](https://github.com/btravers/amqp-contract/blob/
|
|
258
|
+
Defined in: [types.ts:65](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L65)
|
|
259
259
|
|
|
260
260
|
A fanout exchange definition.
|
|
261
261
|
|
|
@@ -266,7 +266,7 @@ This is the simplest exchange type for pub/sub messaging patterns.
|
|
|
266
266
|
|
|
267
267
|
| Name | Type | Defined in |
|
|
268
268
|
| ------ | ------ | ------ |
|
|
269
|
-
| `type` | `"fanout"` | [types.ts:66](https://github.com/btravers/amqp-contract/blob/
|
|
269
|
+
| `type` | `"fanout"` | [types.ts:66](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L66) |
|
|
270
270
|
|
|
271
271
|
#### Example
|
|
272
272
|
|
|
@@ -284,7 +284,7 @@ const logsExchange: FanoutExchangeDefinition = defineExchange('logs', 'fanout',
|
|
|
284
284
|
type InferConsumerNames<TContract> = TContract["consumers"] extends Record<string, unknown> ? keyof TContract["consumers"] : never;
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
-
Defined in: [types.ts:462](https://github.com/btravers/amqp-contract/blob/
|
|
287
|
+
Defined in: [types.ts:462](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L462)
|
|
288
288
|
|
|
289
289
|
Extract consumer names from a contract.
|
|
290
290
|
|
|
@@ -316,7 +316,7 @@ type ConsumerNames = InferConsumerNames<typeof myContract>;
|
|
|
316
316
|
type InferPublisherNames<TContract> = TContract["publishers"] extends Record<string, unknown> ? keyof TContract["publishers"] : never;
|
|
317
317
|
```
|
|
318
318
|
|
|
319
|
-
Defined in: [types.ts:444](https://github.com/btravers/amqp-contract/blob/
|
|
319
|
+
Defined in: [types.ts:444](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L444)
|
|
320
320
|
|
|
321
321
|
Extract publisher names from a contract.
|
|
322
322
|
|
|
@@ -348,7 +348,7 @@ type PublisherNames = InferPublisherNames<typeof myContract>;
|
|
|
348
348
|
type MessageDefinition<TPayload, THeaders> = object;
|
|
349
349
|
```
|
|
350
350
|
|
|
351
|
-
Defined in: [types.ts:178](https://github.com/btravers/amqp-contract/blob/
|
|
351
|
+
Defined in: [types.ts:178](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L178)
|
|
352
352
|
|
|
353
353
|
Definition of a message with typed payload and optional headers.
|
|
354
354
|
|
|
@@ -363,10 +363,10 @@ Definition of a message with typed payload and optional headers.
|
|
|
363
363
|
|
|
364
364
|
| Property | Type | Description | Defined in |
|
|
365
365
|
| ------ | ------ | ------ | ------ |
|
|
366
|
-
| <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/
|
|
367
|
-
| <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/
|
|
368
|
-
| <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/
|
|
369
|
-
| <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/
|
|
366
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L204) |
|
|
367
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L192) |
|
|
368
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L186) |
|
|
369
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L198) |
|
|
370
370
|
|
|
371
371
|
***
|
|
372
372
|
|
|
@@ -385,7 +385,7 @@ type PublisherDefinition<TMessage> = object &
|
|
|
385
385
|
};
|
|
386
386
|
```
|
|
387
387
|
|
|
388
|
-
Defined in: [types.ts:317](https://github.com/btravers/amqp-contract/blob/
|
|
388
|
+
Defined in: [types.ts:317](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L317)
|
|
389
389
|
|
|
390
390
|
Definition of a message publisher.
|
|
391
391
|
|
|
@@ -396,7 +396,7 @@ The message payload is validated against the schema before being sent to RabbitM
|
|
|
396
396
|
|
|
397
397
|
| Name | Type | Description | Defined in |
|
|
398
398
|
| ------ | ------ | ------ | ------ |
|
|
399
|
-
| `message` | `TMessage` | The message definition including the payload schema | [types.ts:319](https://github.com/btravers/amqp-contract/blob/
|
|
399
|
+
| `message` | `TMessage` | The message definition including the payload schema | [types.ts:319](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L319) |
|
|
400
400
|
|
|
401
401
|
#### Type Parameters
|
|
402
402
|
|
|
@@ -431,7 +431,7 @@ type QueueBindingDefinition = object &
|
|
|
431
431
|
};
|
|
432
432
|
```
|
|
433
433
|
|
|
434
|
-
Defined in: [types.ts:214](https://github.com/btravers/amqp-contract/blob/
|
|
434
|
+
Defined in: [types.ts:214](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L214)
|
|
435
435
|
|
|
436
436
|
Binding between a queue and an exchange.
|
|
437
437
|
|
|
@@ -443,9 +443,9 @@ For fanout exchanges, no routing key is needed as all messages are broadcast.
|
|
|
443
443
|
|
|
444
444
|
| Name | Type | Description | Defined in |
|
|
445
445
|
| ------ | ------ | ------ | ------ |
|
|
446
|
-
| `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/
|
|
447
|
-
| `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:219](https://github.com/btravers/amqp-contract/blob/
|
|
448
|
-
| `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:216](https://github.com/btravers/amqp-contract/blob/
|
|
446
|
+
| `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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L225) |
|
|
447
|
+
| `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:219](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L219) |
|
|
448
|
+
| `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:216](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L216) |
|
|
449
449
|
|
|
450
450
|
***
|
|
451
451
|
|
|
@@ -455,7 +455,7 @@ For fanout exchanges, no routing key is needed as all messages are broadcast.
|
|
|
455
455
|
type QueueDefinition = object;
|
|
456
456
|
```
|
|
457
457
|
|
|
458
|
-
Defined in: [types.ts:123](https://github.com/btravers/amqp-contract/blob/
|
|
458
|
+
Defined in: [types.ts:123](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L123)
|
|
459
459
|
|
|
460
460
|
Definition of an AMQP queue.
|
|
461
461
|
|
|
@@ -466,11 +466,11 @@ to receive messages based on routing rules.
|
|
|
466
466
|
|
|
467
467
|
| Property | Type | Description | Defined in |
|
|
468
468
|
| ------ | ------ | ------ | ------ |
|
|
469
|
-
| <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/
|
|
470
|
-
| <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/
|
|
471
|
-
| <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/
|
|
472
|
-
| <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/
|
|
473
|
-
| <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/
|
|
469
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L169) |
|
|
470
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L146) |
|
|
471
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L133) |
|
|
472
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L140) |
|
|
473
|
+
| <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/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L127) |
|
|
474
474
|
|
|
475
475
|
***
|
|
476
476
|
|
|
@@ -480,7 +480,7 @@ to receive messages based on routing rules.
|
|
|
480
480
|
type TopicExchangeDefinition = BaseExchangeDefinition & object;
|
|
481
481
|
```
|
|
482
482
|
|
|
483
|
-
Defined in: [types.ts:103](https://github.com/btravers/amqp-contract/blob/
|
|
483
|
+
Defined in: [types.ts:103](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L103)
|
|
484
484
|
|
|
485
485
|
A topic exchange definition.
|
|
486
486
|
|
|
@@ -494,7 +494,7 @@ Words are separated by dots (e.g., `order.created.high-value`).
|
|
|
494
494
|
|
|
495
495
|
| Name | Type | Defined in |
|
|
496
496
|
| ------ | ------ | ------ |
|
|
497
|
-
| `type` | `"topic"` | [types.ts:104](https://github.com/btravers/amqp-contract/blob/
|
|
497
|
+
| `type` | `"topic"` | [types.ts:104](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/types.ts#L104) |
|
|
498
498
|
|
|
499
499
|
#### Example
|
|
500
500
|
|
|
@@ -516,7 +516,7 @@ function defineConsumer<TMessage>(
|
|
|
516
516
|
options?): ConsumerDefinition<TMessage>;
|
|
517
517
|
```
|
|
518
518
|
|
|
519
|
-
Defined in: [builder.ts:595](https://github.com/btravers/amqp-contract/blob/
|
|
519
|
+
Defined in: [builder.ts:595](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/builder.ts#L595)
|
|
520
520
|
|
|
521
521
|
Define a message consumer.
|
|
522
522
|
|
|
@@ -583,7 +583,7 @@ const processOrderConsumer = defineConsumer(orderQueue, orderMessage);
|
|
|
583
583
|
function defineContract<TContract>(definition): TContract;
|
|
584
584
|
```
|
|
585
585
|
|
|
586
|
-
Defined in: [builder.ts:676](https://github.com/btravers/amqp-contract/blob/
|
|
586
|
+
Defined in: [builder.ts:676](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/builder.ts#L676)
|
|
587
587
|
|
|
588
588
|
Define an AMQP contract.
|
|
589
589
|
|
|
@@ -672,7 +672,7 @@ export const contract = defineContract({
|
|
|
672
672
|
function defineMessage<TPayload, THeaders>(payload, options?): MessageDefinition<TPayload, THeaders>;
|
|
673
673
|
```
|
|
674
674
|
|
|
675
|
-
Defined in: [builder.ts:197](https://github.com/btravers/amqp-contract/blob/
|
|
675
|
+
Defined in: [builder.ts:197](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/builder.ts#L197)
|
|
676
676
|
|
|
677
677
|
Define a message definition with payload and optional headers/metadata.
|
|
678
678
|
|
|
@@ -733,7 +733,7 @@ const orderMessage = defineMessage(
|
|
|
733
733
|
function defineQueue(name, options?): QueueDefinition;
|
|
734
734
|
```
|
|
735
735
|
|
|
736
|
-
Defined in: [builder.ts:152](https://github.com/btravers/amqp-contract/blob/
|
|
736
|
+
Defined in: [builder.ts:152](https://github.com/btravers/amqp-contract/blob/fb7fe976925e332da34b847357ebcbeefd37355d/packages/contract/src/builder.ts#L152)
|
|
737
737
|
|
|
738
738
|
Define an AMQP queue.
|
|
739
739
|
|