@amqp-contract/contract 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -4
- package/dist/index.cjs +29 -0
- package/dist/index.d.cts +274 -25
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +274 -25
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +29 -0
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +222 -60
- package/package.json +2 -2
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/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/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/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/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/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) |
|
|
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/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L298)
|
|
63
63
|
|
|
64
64
|
Union type of all binding definitions.
|
|
65
65
|
|
|
@@ -69,13 +69,48 @@ A binding can be either:
|
|
|
69
69
|
|
|
70
70
|
***
|
|
71
71
|
|
|
72
|
+
### BindingPattern
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
type BindingPattern<S> = S extends "" ? never : S;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Defined in: [builder.ts:805](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L805)
|
|
79
|
+
|
|
80
|
+
Type-safe binding pattern that validates basic format and wildcards.
|
|
81
|
+
|
|
82
|
+
Validates that a binding pattern follows basic AMQP binding pattern rules:
|
|
83
|
+
- Can contain wildcards (* for one word, # for zero or more words)
|
|
84
|
+
- Must not be empty
|
|
85
|
+
- Should contain alphanumeric characters, dots, hyphens, underscores, and wildcards
|
|
86
|
+
|
|
87
|
+
Note: Full character-by-character validation is not performed to avoid TypeScript
|
|
88
|
+
recursion depth limits. Runtime validation is still recommended.
|
|
89
|
+
|
|
90
|
+
#### Type Parameters
|
|
91
|
+
|
|
92
|
+
| Type Parameter | Description |
|
|
93
|
+
| ------ | ------ |
|
|
94
|
+
| `S` *extends* `string` | The binding pattern string to validate |
|
|
95
|
+
|
|
96
|
+
#### Example
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
type ValidPattern = BindingPattern<"order.*">; // "order.*"
|
|
100
|
+
type ValidHash = BindingPattern<"order.#">; // "order.#"
|
|
101
|
+
type ValidConcrete = BindingPattern<"order.created">; // "order.created"
|
|
102
|
+
type Invalid = BindingPattern<"">; // never (empty string)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
***
|
|
106
|
+
|
|
72
107
|
### ConsumerDefinition
|
|
73
108
|
|
|
74
109
|
```ts
|
|
75
110
|
type ConsumerDefinition<TMessage> = object;
|
|
76
111
|
```
|
|
77
112
|
|
|
78
|
-
Defined in: [types.ts:354](https://github.com/btravers/amqp-contract/blob/
|
|
113
|
+
Defined in: [types.ts:354](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L354)
|
|
79
114
|
|
|
80
115
|
Definition of a message consumer.
|
|
81
116
|
|
|
@@ -101,8 +136,8 @@ const consumer: ConsumerDefinition = {
|
|
|
101
136
|
|
|
102
137
|
| Property | Type | Description | Defined in |
|
|
103
138
|
| ------ | ------ | ------ | ------ |
|
|
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/
|
|
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) |
|
|
106
141
|
|
|
107
142
|
***
|
|
108
143
|
|
|
@@ -112,9 +147,9 @@ const consumer: ConsumerDefinition = {
|
|
|
112
147
|
type ConsumerFirstResult<TMessage, TConsumer, TBinding> = object;
|
|
113
148
|
```
|
|
114
149
|
|
|
115
|
-
Defined in: [builder.ts:
|
|
150
|
+
Defined in: [builder.ts:1182](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L1182)
|
|
116
151
|
|
|
117
|
-
Consumer-first builder result.
|
|
152
|
+
Consumer-first builder result for fanout and direct exchanges.
|
|
118
153
|
|
|
119
154
|
This type represents a consumer with its binding and provides a method to create
|
|
120
155
|
a publisher that uses the same message schema and routing key.
|
|
@@ -131,9 +166,40 @@ a publisher that uses the same message schema and routing key.
|
|
|
131
166
|
|
|
132
167
|
| Property | Type | Description | Defined in |
|
|
133
168
|
| ------ | ------ | ------ | ------ |
|
|
134
|
-
| <a id="binding"></a> `binding` | `TBinding` | The binding definition connecting the exchange to the queue | [builder.ts:
|
|
135
|
-
| <a id="consumer"></a> `consumer` | `TConsumer` | The consumer definition | [builder.ts:
|
|
136
|
-
| <a id="createpublisher"></a> `createPublisher` | () => [`PublisherDefinition`](#publisherdefinition)\<`TMessage
|
|
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) |
|
|
172
|
+
|
|
173
|
+
***
|
|
174
|
+
|
|
175
|
+
### ConsumerFirstResultWithRoutingKey
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
type ConsumerFirstResultWithRoutingKey<TMessage, TConsumer, TBinding> = object;
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Defined in: [builder.ts:1215](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L1215)
|
|
182
|
+
|
|
183
|
+
Consumer-first builder result for topic exchanges.
|
|
184
|
+
|
|
185
|
+
This type represents a consumer with its binding (which may use a pattern) and provides
|
|
186
|
+
a method to create a publisher with a concrete routing key that matches the pattern.
|
|
187
|
+
|
|
188
|
+
#### Type Parameters
|
|
189
|
+
|
|
190
|
+
| Type Parameter | Description |
|
|
191
|
+
| ------ | ------ |
|
|
192
|
+
| `TMessage` *extends* [`MessageDefinition`](#messagedefinition) | The message definition |
|
|
193
|
+
| `TConsumer` *extends* [`ConsumerDefinition`](#consumerdefinition)\<`TMessage`\> | The consumer definition |
|
|
194
|
+
| `TBinding` *extends* [`QueueBindingDefinition`](#queuebindingdefinition) | The queue binding definition |
|
|
195
|
+
|
|
196
|
+
#### Properties
|
|
197
|
+
|
|
198
|
+
| Property | Type | Description | Defined in |
|
|
199
|
+
| ------ | ------ | ------ | ------ |
|
|
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) |
|
|
137
203
|
|
|
138
204
|
***
|
|
139
205
|
|
|
@@ -143,7 +209,7 @@ a publisher that uses the same message schema and routing key.
|
|
|
143
209
|
type ContractDefinition = object;
|
|
144
210
|
```
|
|
145
211
|
|
|
146
|
-
Defined in: [types.ts:395](https://github.com/btravers/amqp-contract/blob/
|
|
212
|
+
Defined in: [types.ts:395](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L395)
|
|
147
213
|
|
|
148
214
|
Complete AMQP contract definition.
|
|
149
215
|
|
|
@@ -182,11 +248,11 @@ const contract: ContractDefinition = {
|
|
|
182
248
|
|
|
183
249
|
| Property | Type | Description | Defined in |
|
|
184
250
|
| ------ | ------ | ------ | ------ |
|
|
185
|
-
| <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/
|
|
186
|
-
| <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/
|
|
187
|
-
| <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/
|
|
188
|
-
| <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/
|
|
189
|
-
| <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/
|
|
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) |
|
|
190
256
|
|
|
191
257
|
***
|
|
192
258
|
|
|
@@ -196,7 +262,7 @@ const contract: ContractDefinition = {
|
|
|
196
262
|
type DirectExchangeDefinition = BaseExchangeDefinition & object;
|
|
197
263
|
```
|
|
198
264
|
|
|
199
|
-
Defined in: [types.ts:82](https://github.com/btravers/amqp-contract/blob/
|
|
265
|
+
Defined in: [types.ts:82](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L82)
|
|
200
266
|
|
|
201
267
|
A direct exchange definition.
|
|
202
268
|
|
|
@@ -207,7 +273,7 @@ This is ideal for point-to-point messaging where each message should go to speci
|
|
|
207
273
|
|
|
208
274
|
| Name | Type | Defined in |
|
|
209
275
|
| ------ | ------ | ------ |
|
|
210
|
-
| `type` | `"direct"` | [types.ts:83](https://github.com/btravers/amqp-contract/blob/
|
|
276
|
+
| `type` | `"direct"` | [types.ts:83](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L83) |
|
|
211
277
|
|
|
212
278
|
#### Example
|
|
213
279
|
|
|
@@ -234,7 +300,7 @@ type ExchangeBindingDefinition = object &
|
|
|
234
300
|
};
|
|
235
301
|
```
|
|
236
302
|
|
|
237
|
-
Defined in: [types.ts:262](https://github.com/btravers/amqp-contract/blob/
|
|
303
|
+
Defined in: [types.ts:262](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L262)
|
|
238
304
|
|
|
239
305
|
Binding between two exchanges (exchange-to-exchange routing).
|
|
240
306
|
|
|
@@ -245,9 +311,9 @@ This allows for more complex routing topologies.
|
|
|
245
311
|
|
|
246
312
|
| Name | Type | Description | Defined in |
|
|
247
313
|
| ------ | ------ | ------ | ------ |
|
|
248
|
-
| `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. | [types.ts:272](https://github.com/btravers/amqp-contract/blob/
|
|
249
|
-
| `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:267](https://github.com/btravers/amqp-contract/blob/
|
|
250
|
-
| `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:264](https://github.com/btravers/amqp-contract/blob/
|
|
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) |
|
|
251
317
|
|
|
252
318
|
#### Example
|
|
253
319
|
|
|
@@ -272,7 +338,7 @@ type ExchangeDefinition =
|
|
|
272
338
|
| TopicExchangeDefinition;
|
|
273
339
|
```
|
|
274
340
|
|
|
275
|
-
Defined in: [types.ts:112](https://github.com/btravers/amqp-contract/blob/
|
|
341
|
+
Defined in: [types.ts:112](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L112)
|
|
276
342
|
|
|
277
343
|
Union type of all exchange definitions.
|
|
278
344
|
|
|
@@ -286,7 +352,7 @@ Represents any type of AMQP exchange: fanout, direct, or topic.
|
|
|
286
352
|
type FanoutExchangeDefinition = BaseExchangeDefinition & object;
|
|
287
353
|
```
|
|
288
354
|
|
|
289
|
-
Defined in: [types.ts:65](https://github.com/btravers/amqp-contract/blob/
|
|
355
|
+
Defined in: [types.ts:65](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L65)
|
|
290
356
|
|
|
291
357
|
A fanout exchange definition.
|
|
292
358
|
|
|
@@ -297,7 +363,7 @@ This is the simplest exchange type for pub/sub messaging patterns.
|
|
|
297
363
|
|
|
298
364
|
| Name | Type | Defined in |
|
|
299
365
|
| ------ | ------ | ------ |
|
|
300
|
-
| `type` | `"fanout"` | [types.ts:66](https://github.com/btravers/amqp-contract/blob/
|
|
366
|
+
| `type` | `"fanout"` | [types.ts:66](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L66) |
|
|
301
367
|
|
|
302
368
|
#### Example
|
|
303
369
|
|
|
@@ -315,7 +381,7 @@ const logsExchange: FanoutExchangeDefinition = defineExchange('logs', 'fanout',
|
|
|
315
381
|
type InferConsumerNames<TContract> = TContract["consumers"] extends Record<string, unknown> ? keyof TContract["consumers"] : never;
|
|
316
382
|
```
|
|
317
383
|
|
|
318
|
-
Defined in: [types.ts:462](https://github.com/btravers/amqp-contract/blob/
|
|
384
|
+
Defined in: [types.ts:462](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L462)
|
|
319
385
|
|
|
320
386
|
Extract consumer names from a contract.
|
|
321
387
|
|
|
@@ -347,7 +413,7 @@ type ConsumerNames = InferConsumerNames<typeof myContract>;
|
|
|
347
413
|
type InferPublisherNames<TContract> = TContract["publishers"] extends Record<string, unknown> ? keyof TContract["publishers"] : never;
|
|
348
414
|
```
|
|
349
415
|
|
|
350
|
-
Defined in: [types.ts:444](https://github.com/btravers/amqp-contract/blob/
|
|
416
|
+
Defined in: [types.ts:444](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L444)
|
|
351
417
|
|
|
352
418
|
Extract publisher names from a contract.
|
|
353
419
|
|
|
@@ -373,13 +439,45 @@ type PublisherNames = InferPublisherNames<typeof myContract>;
|
|
|
373
439
|
|
|
374
440
|
***
|
|
375
441
|
|
|
442
|
+
### MatchingRoutingKey
|
|
443
|
+
|
|
444
|
+
```ts
|
|
445
|
+
type MatchingRoutingKey<Pattern, Key> = RoutingKey<Key> extends never ? never : BindingPattern<Pattern> extends never ? never : MatchesPattern<Key, Pattern> extends true ? Key : never;
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
Defined in: [builder.ts:867](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L867)
|
|
449
|
+
|
|
450
|
+
Validate that a routing key matches a binding pattern.
|
|
451
|
+
|
|
452
|
+
This is a utility type provided for users who want compile-time validation
|
|
453
|
+
that a routing key matches a specific pattern. It's not enforced internally
|
|
454
|
+
in the API to avoid TypeScript recursion depth issues with complex routing keys.
|
|
455
|
+
|
|
456
|
+
Returns the routing key if it's valid and matches the pattern, `never` otherwise.
|
|
457
|
+
|
|
458
|
+
#### Type Parameters
|
|
459
|
+
|
|
460
|
+
| Type Parameter | Description |
|
|
461
|
+
| ------ | ------ |
|
|
462
|
+
| `Pattern` *extends* `string` | The binding pattern (can contain * and # wildcards) |
|
|
463
|
+
| `Key` *extends* `string` | The routing key to validate |
|
|
464
|
+
|
|
465
|
+
#### Example
|
|
466
|
+
|
|
467
|
+
```typescript
|
|
468
|
+
type ValidKey = MatchingRoutingKey<"order.*", "order.created">; // "order.created"
|
|
469
|
+
type InvalidKey = MatchingRoutingKey<"order.*", "user.created">; // never
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
***
|
|
473
|
+
|
|
376
474
|
### MessageDefinition
|
|
377
475
|
|
|
378
476
|
```ts
|
|
379
477
|
type MessageDefinition<TPayload, THeaders> = object;
|
|
380
478
|
```
|
|
381
479
|
|
|
382
|
-
Defined in: [types.ts:178](https://github.com/btravers/amqp-contract/blob/
|
|
480
|
+
Defined in: [types.ts:178](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L178)
|
|
383
481
|
|
|
384
482
|
Definition of a message with typed payload and optional headers.
|
|
385
483
|
|
|
@@ -394,10 +492,10 @@ Definition of a message with typed payload and optional headers.
|
|
|
394
492
|
|
|
395
493
|
| Property | Type | Description | Defined in |
|
|
396
494
|
| ------ | ------ | ------ | ------ |
|
|
397
|
-
| <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/
|
|
398
|
-
| <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/
|
|
399
|
-
| <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/
|
|
400
|
-
| <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/
|
|
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) |
|
|
401
499
|
|
|
402
500
|
***
|
|
403
501
|
|
|
@@ -416,7 +514,7 @@ type PublisherDefinition<TMessage> = object &
|
|
|
416
514
|
};
|
|
417
515
|
```
|
|
418
516
|
|
|
419
|
-
Defined in: [types.ts:317](https://github.com/btravers/amqp-contract/blob/
|
|
517
|
+
Defined in: [types.ts:317](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L317)
|
|
420
518
|
|
|
421
519
|
Definition of a message publisher.
|
|
422
520
|
|
|
@@ -427,7 +525,7 @@ The message payload is validated against the schema before being sent to RabbitM
|
|
|
427
525
|
|
|
428
526
|
| Name | Type | Description | Defined in |
|
|
429
527
|
| ------ | ------ | ------ | ------ |
|
|
430
|
-
| `message` | `TMessage` | The message definition including the payload schema | [types.ts:319](https://github.com/btravers/amqp-contract/blob/
|
|
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) |
|
|
431
529
|
|
|
432
530
|
#### Type Parameters
|
|
433
531
|
|
|
@@ -453,9 +551,9 @@ const publisher: PublisherDefinition = {
|
|
|
453
551
|
type PublisherFirstResult<TMessage, TPublisher> = object;
|
|
454
552
|
```
|
|
455
553
|
|
|
456
|
-
Defined in: [builder.ts:734](https://github.com/btravers/amqp-contract/blob/
|
|
554
|
+
Defined in: [builder.ts:734](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L734)
|
|
457
555
|
|
|
458
|
-
Publisher-first builder result.
|
|
556
|
+
Publisher-first builder result for fanout and direct exchanges.
|
|
459
557
|
|
|
460
558
|
This type represents a publisher and provides a method to create
|
|
461
559
|
a consumer that uses the same message schema with a binding to the exchange.
|
|
@@ -474,8 +572,38 @@ emit events without knowing which queues will consume them.
|
|
|
474
572
|
|
|
475
573
|
| Property | Type | Description | Defined in |
|
|
476
574
|
| ------ | ------ | ------ | ------ |
|
|
477
|
-
| <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/
|
|
478
|
-
| <a id="publisher"></a> `publisher` | `TPublisher` | The publisher definition | [builder.ts:739](https://github.com/btravers/amqp-contract/blob/
|
|
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) |
|
|
577
|
+
|
|
578
|
+
***
|
|
579
|
+
|
|
580
|
+
### PublisherFirstResultWithRoutingKey
|
|
581
|
+
|
|
582
|
+
```ts
|
|
583
|
+
type PublisherFirstResultWithRoutingKey<TMessage, TPublisher, TRoutingKey> = object;
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
Defined in: [builder.ts:886](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L886)
|
|
587
|
+
|
|
588
|
+
Publisher-first builder result for topic exchanges.
|
|
589
|
+
|
|
590
|
+
This type represents a publisher with a concrete routing key and provides a method
|
|
591
|
+
to create consumers that can use routing key patterns matching the publisher's key.
|
|
592
|
+
|
|
593
|
+
#### Type Parameters
|
|
594
|
+
|
|
595
|
+
| Type Parameter | Description |
|
|
596
|
+
| ------ | ------ |
|
|
597
|
+
| `TMessage` *extends* [`MessageDefinition`](#messagedefinition) | The message definition |
|
|
598
|
+
| `TPublisher` *extends* [`PublisherDefinition`](#publisherdefinition)\<`TMessage`\> | The publisher definition |
|
|
599
|
+
| `TRoutingKey` *extends* `string` | The literal routing key type from the publisher (for documentation purposes) |
|
|
600
|
+
|
|
601
|
+
#### Properties
|
|
602
|
+
|
|
603
|
+
| Property | Type | Description | Defined in |
|
|
604
|
+
| ------ | ------ | ------ | ------ |
|
|
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) |
|
|
479
607
|
|
|
480
608
|
***
|
|
481
609
|
|
|
@@ -494,7 +622,7 @@ type QueueBindingDefinition = object &
|
|
|
494
622
|
};
|
|
495
623
|
```
|
|
496
624
|
|
|
497
|
-
Defined in: [types.ts:214](https://github.com/btravers/amqp-contract/blob/
|
|
625
|
+
Defined in: [types.ts:214](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L214)
|
|
498
626
|
|
|
499
627
|
Binding between a queue and an exchange.
|
|
500
628
|
|
|
@@ -506,9 +634,9 @@ For fanout exchanges, no routing key is needed as all messages are broadcast.
|
|
|
506
634
|
|
|
507
635
|
| Name | Type | Description | Defined in |
|
|
508
636
|
| ------ | ------ | ------ | ------ |
|
|
509
|
-
| `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/
|
|
510
|
-
| `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:219](https://github.com/btravers/amqp-contract/blob/
|
|
511
|
-
| `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:216](https://github.com/btravers/amqp-contract/blob/
|
|
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) |
|
|
512
640
|
|
|
513
641
|
***
|
|
514
642
|
|
|
@@ -518,7 +646,7 @@ For fanout exchanges, no routing key is needed as all messages are broadcast.
|
|
|
518
646
|
type QueueDefinition = object;
|
|
519
647
|
```
|
|
520
648
|
|
|
521
|
-
Defined in: [types.ts:123](https://github.com/btravers/amqp-contract/blob/
|
|
649
|
+
Defined in: [types.ts:123](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L123)
|
|
522
650
|
|
|
523
651
|
Definition of an AMQP queue.
|
|
524
652
|
|
|
@@ -529,11 +657,45 @@ to receive messages based on routing rules.
|
|
|
529
657
|
|
|
530
658
|
| Property | Type | Description | Defined in |
|
|
531
659
|
| ------ | ------ | ------ | ------ |
|
|
532
|
-
| <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/
|
|
533
|
-
| <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/
|
|
534
|
-
| <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/
|
|
535
|
-
| <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/
|
|
536
|
-
| <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/
|
|
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) |
|
|
665
|
+
|
|
666
|
+
***
|
|
667
|
+
|
|
668
|
+
### RoutingKey
|
|
669
|
+
|
|
670
|
+
```ts
|
|
671
|
+
type RoutingKey<S> = S extends "" ? never : S extends `${string}*${string}` | `${string}#${string}` ? never : S;
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
Defined in: [builder.ts:778](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L778)
|
|
675
|
+
|
|
676
|
+
Type-safe routing key that validates basic format.
|
|
677
|
+
|
|
678
|
+
Validates that a routing key follows basic AMQP routing key rules:
|
|
679
|
+
- Must not contain wildcards (* or #)
|
|
680
|
+
- Must not be empty
|
|
681
|
+
- Should contain alphanumeric characters, dots, hyphens, and underscores
|
|
682
|
+
|
|
683
|
+
Note: Full character-by-character validation is not performed to avoid TypeScript
|
|
684
|
+
recursion depth limits. Runtime validation is still recommended.
|
|
685
|
+
|
|
686
|
+
#### Type Parameters
|
|
687
|
+
|
|
688
|
+
| Type Parameter | Description |
|
|
689
|
+
| ------ | ------ |
|
|
690
|
+
| `S` *extends* `string` | The routing key string to validate |
|
|
691
|
+
|
|
692
|
+
#### Example
|
|
693
|
+
|
|
694
|
+
```typescript
|
|
695
|
+
type Valid = RoutingKey<"order.created">; // "order.created"
|
|
696
|
+
type Invalid = RoutingKey<"order.*">; // never (contains wildcard)
|
|
697
|
+
type Invalid2 = RoutingKey<"">; // never (empty string)
|
|
698
|
+
```
|
|
537
699
|
|
|
538
700
|
***
|
|
539
701
|
|
|
@@ -543,7 +705,7 @@ to receive messages based on routing rules.
|
|
|
543
705
|
type TopicExchangeDefinition = BaseExchangeDefinition & object;
|
|
544
706
|
```
|
|
545
707
|
|
|
546
|
-
Defined in: [types.ts:103](https://github.com/btravers/amqp-contract/blob/
|
|
708
|
+
Defined in: [types.ts:103](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L103)
|
|
547
709
|
|
|
548
710
|
A topic exchange definition.
|
|
549
711
|
|
|
@@ -557,7 +719,7 @@ Words are separated by dots (e.g., `order.created.high-value`).
|
|
|
557
719
|
|
|
558
720
|
| Name | Type | Defined in |
|
|
559
721
|
| ------ | ------ | ------ |
|
|
560
|
-
| `type` | `"topic"` | [types.ts:104](https://github.com/btravers/amqp-contract/blob/
|
|
722
|
+
| `type` | `"topic"` | [types.ts:104](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/types.ts#L104) |
|
|
561
723
|
|
|
562
724
|
#### Example
|
|
563
725
|
|
|
@@ -579,7 +741,7 @@ function defineConsumer<TMessage>(
|
|
|
579
741
|
options?): ConsumerDefinition<TMessage>;
|
|
580
742
|
```
|
|
581
743
|
|
|
582
|
-
Defined in: [builder.ts:595](https://github.com/btravers/amqp-contract/blob/
|
|
744
|
+
Defined in: [builder.ts:595](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L595)
|
|
583
745
|
|
|
584
746
|
Define a message consumer.
|
|
585
747
|
|
|
@@ -646,7 +808,7 @@ const processOrderConsumer = defineConsumer(orderQueue, orderMessage);
|
|
|
646
808
|
function defineContract<TContract>(definition): TContract;
|
|
647
809
|
```
|
|
648
810
|
|
|
649
|
-
Defined in: [builder.ts:676](https://github.com/btravers/amqp-contract/blob/
|
|
811
|
+
Defined in: [builder.ts:676](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L676)
|
|
650
812
|
|
|
651
813
|
Define an AMQP contract.
|
|
652
814
|
|
|
@@ -735,7 +897,7 @@ export const contract = defineContract({
|
|
|
735
897
|
function defineMessage<TPayload, THeaders>(payload, options?): MessageDefinition<TPayload, THeaders>;
|
|
736
898
|
```
|
|
737
899
|
|
|
738
|
-
Defined in: [builder.ts:197](https://github.com/btravers/amqp-contract/blob/
|
|
900
|
+
Defined in: [builder.ts:197](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L197)
|
|
739
901
|
|
|
740
902
|
Define a message definition with payload and optional headers/metadata.
|
|
741
903
|
|
|
@@ -796,7 +958,7 @@ const orderMessage = defineMessage(
|
|
|
796
958
|
function defineQueue(name, options?): QueueDefinition;
|
|
797
959
|
```
|
|
798
960
|
|
|
799
|
-
Defined in: [builder.ts:152](https://github.com/btravers/amqp-contract/blob/
|
|
961
|
+
Defined in: [builder.ts:152](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L152)
|
|
800
962
|
|
|
801
963
|
Define an AMQP queue.
|
|
802
964
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amqp-contract/contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Contract builder for amqp-contract",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"amqp",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@vitest/coverage-v8": "4.0.16",
|
|
48
|
-
"tsdown": "0.18.
|
|
48
|
+
"tsdown": "0.18.3",
|
|
49
49
|
"typedoc": "0.28.15",
|
|
50
50
|
"typedoc-plugin-markdown": "4.9.0",
|
|
51
51
|
"typescript": "5.9.3",
|