@amqp-contract/contract 0.3.5 → 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 +42 -51
- package/dist/index.cjs +83 -0
- package/dist/index.d.cts +528 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +528 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +82 -1
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +276 -51
- 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,70 @@ 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) |
|
|
141
|
+
|
|
142
|
+
***
|
|
143
|
+
|
|
144
|
+
### ConsumerFirstResult
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
type ConsumerFirstResult<TMessage, TConsumer, TBinding> = object;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Defined in: [builder.ts:1182](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L1182)
|
|
151
|
+
|
|
152
|
+
Consumer-first builder result for fanout and direct exchanges.
|
|
153
|
+
|
|
154
|
+
This type represents a consumer with its binding and provides a method to create
|
|
155
|
+
a publisher that uses the same message schema and routing key.
|
|
156
|
+
|
|
157
|
+
#### Type Parameters
|
|
158
|
+
|
|
159
|
+
| Type Parameter | Description |
|
|
160
|
+
| ------ | ------ |
|
|
161
|
+
| `TMessage` *extends* [`MessageDefinition`](#messagedefinition) | The message definition |
|
|
162
|
+
| `TConsumer` *extends* [`ConsumerDefinition`](#consumerdefinition)\<`TMessage`\> | The consumer definition |
|
|
163
|
+
| `TBinding` *extends* [`QueueBindingDefinition`](#queuebindingdefinition) | The queue binding definition |
|
|
164
|
+
|
|
165
|
+
#### Properties
|
|
166
|
+
|
|
167
|
+
| Property | Type | Description | Defined in |
|
|
168
|
+
| ------ | ------ | ------ | ------ |
|
|
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) |
|
|
106
203
|
|
|
107
204
|
***
|
|
108
205
|
|
|
@@ -112,7 +209,7 @@ const consumer: ConsumerDefinition = {
|
|
|
112
209
|
type ContractDefinition = object;
|
|
113
210
|
```
|
|
114
211
|
|
|
115
|
-
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)
|
|
116
213
|
|
|
117
214
|
Complete AMQP contract definition.
|
|
118
215
|
|
|
@@ -151,11 +248,11 @@ const contract: ContractDefinition = {
|
|
|
151
248
|
|
|
152
249
|
| Property | Type | Description | Defined in |
|
|
153
250
|
| ------ | ------ | ------ | ------ |
|
|
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/
|
|
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) |
|
|
159
256
|
|
|
160
257
|
***
|
|
161
258
|
|
|
@@ -165,7 +262,7 @@ const contract: ContractDefinition = {
|
|
|
165
262
|
type DirectExchangeDefinition = BaseExchangeDefinition & object;
|
|
166
263
|
```
|
|
167
264
|
|
|
168
|
-
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)
|
|
169
266
|
|
|
170
267
|
A direct exchange definition.
|
|
171
268
|
|
|
@@ -176,7 +273,7 @@ This is ideal for point-to-point messaging where each message should go to speci
|
|
|
176
273
|
|
|
177
274
|
| Name | Type | Defined in |
|
|
178
275
|
| ------ | ------ | ------ |
|
|
179
|
-
| `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) |
|
|
180
277
|
|
|
181
278
|
#### Example
|
|
182
279
|
|
|
@@ -203,7 +300,7 @@ type ExchangeBindingDefinition = object &
|
|
|
203
300
|
};
|
|
204
301
|
```
|
|
205
302
|
|
|
206
|
-
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)
|
|
207
304
|
|
|
208
305
|
Binding between two exchanges (exchange-to-exchange routing).
|
|
209
306
|
|
|
@@ -214,9 +311,9 @@ This allows for more complex routing topologies.
|
|
|
214
311
|
|
|
215
312
|
| Name | Type | Description | Defined in |
|
|
216
313
|
| ------ | ------ | ------ | ------ |
|
|
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/
|
|
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) |
|
|
220
317
|
|
|
221
318
|
#### Example
|
|
222
319
|
|
|
@@ -241,7 +338,7 @@ type ExchangeDefinition =
|
|
|
241
338
|
| TopicExchangeDefinition;
|
|
242
339
|
```
|
|
243
340
|
|
|
244
|
-
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)
|
|
245
342
|
|
|
246
343
|
Union type of all exchange definitions.
|
|
247
344
|
|
|
@@ -255,7 +352,7 @@ Represents any type of AMQP exchange: fanout, direct, or topic.
|
|
|
255
352
|
type FanoutExchangeDefinition = BaseExchangeDefinition & object;
|
|
256
353
|
```
|
|
257
354
|
|
|
258
|
-
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)
|
|
259
356
|
|
|
260
357
|
A fanout exchange definition.
|
|
261
358
|
|
|
@@ -266,7 +363,7 @@ This is the simplest exchange type for pub/sub messaging patterns.
|
|
|
266
363
|
|
|
267
364
|
| Name | Type | Defined in |
|
|
268
365
|
| ------ | ------ | ------ |
|
|
269
|
-
| `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) |
|
|
270
367
|
|
|
271
368
|
#### Example
|
|
272
369
|
|
|
@@ -284,7 +381,7 @@ const logsExchange: FanoutExchangeDefinition = defineExchange('logs', 'fanout',
|
|
|
284
381
|
type InferConsumerNames<TContract> = TContract["consumers"] extends Record<string, unknown> ? keyof TContract["consumers"] : never;
|
|
285
382
|
```
|
|
286
383
|
|
|
287
|
-
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)
|
|
288
385
|
|
|
289
386
|
Extract consumer names from a contract.
|
|
290
387
|
|
|
@@ -316,7 +413,7 @@ type ConsumerNames = InferConsumerNames<typeof myContract>;
|
|
|
316
413
|
type InferPublisherNames<TContract> = TContract["publishers"] extends Record<string, unknown> ? keyof TContract["publishers"] : never;
|
|
317
414
|
```
|
|
318
415
|
|
|
319
|
-
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)
|
|
320
417
|
|
|
321
418
|
Extract publisher names from a contract.
|
|
322
419
|
|
|
@@ -342,13 +439,45 @@ type PublisherNames = InferPublisherNames<typeof myContract>;
|
|
|
342
439
|
|
|
343
440
|
***
|
|
344
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
|
+
|
|
345
474
|
### MessageDefinition
|
|
346
475
|
|
|
347
476
|
```ts
|
|
348
477
|
type MessageDefinition<TPayload, THeaders> = object;
|
|
349
478
|
```
|
|
350
479
|
|
|
351
|
-
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)
|
|
352
481
|
|
|
353
482
|
Definition of a message with typed payload and optional headers.
|
|
354
483
|
|
|
@@ -363,10 +492,10 @@ Definition of a message with typed payload and optional headers.
|
|
|
363
492
|
|
|
364
493
|
| Property | Type | Description | Defined in |
|
|
365
494
|
| ------ | ------ | ------ | ------ |
|
|
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/
|
|
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) |
|
|
370
499
|
|
|
371
500
|
***
|
|
372
501
|
|
|
@@ -385,7 +514,7 @@ type PublisherDefinition<TMessage> = object &
|
|
|
385
514
|
};
|
|
386
515
|
```
|
|
387
516
|
|
|
388
|
-
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)
|
|
389
518
|
|
|
390
519
|
Definition of a message publisher.
|
|
391
520
|
|
|
@@ -396,7 +525,7 @@ The message payload is validated against the schema before being sent to RabbitM
|
|
|
396
525
|
|
|
397
526
|
| Name | Type | Description | Defined in |
|
|
398
527
|
| ------ | ------ | ------ | ------ |
|
|
399
|
-
| `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) |
|
|
400
529
|
|
|
401
530
|
#### Type Parameters
|
|
402
531
|
|
|
@@ -416,6 +545,68 @@ const publisher: PublisherDefinition = {
|
|
|
416
545
|
|
|
417
546
|
***
|
|
418
547
|
|
|
548
|
+
### PublisherFirstResult
|
|
549
|
+
|
|
550
|
+
```ts
|
|
551
|
+
type PublisherFirstResult<TMessage, TPublisher> = object;
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
Defined in: [builder.ts:734](https://github.com/btravers/amqp-contract/blob/2337be9d96ffc5b2bb77c6d63ca6e010efd8c2bc/packages/contract/src/builder.ts#L734)
|
|
555
|
+
|
|
556
|
+
Publisher-first builder result for fanout and direct exchanges.
|
|
557
|
+
|
|
558
|
+
This type represents a publisher and provides a method to create
|
|
559
|
+
a consumer that uses the same message schema with a binding to the exchange.
|
|
560
|
+
|
|
561
|
+
This pattern is suitable for event-oriented messaging where publishers
|
|
562
|
+
emit events without knowing which queues will consume them.
|
|
563
|
+
|
|
564
|
+
#### Type Parameters
|
|
565
|
+
|
|
566
|
+
| Type Parameter | Description |
|
|
567
|
+
| ------ | ------ |
|
|
568
|
+
| `TMessage` *extends* [`MessageDefinition`](#messagedefinition) | The message definition |
|
|
569
|
+
| `TPublisher` *extends* [`PublisherDefinition`](#publisherdefinition)\<`TMessage`\> | The publisher definition |
|
|
570
|
+
|
|
571
|
+
#### Properties
|
|
572
|
+
|
|
573
|
+
| Property | Type | Description | Defined in |
|
|
574
|
+
| ------ | ------ | ------ | ------ |
|
|
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) |
|
|
607
|
+
|
|
608
|
+
***
|
|
609
|
+
|
|
419
610
|
### QueueBindingDefinition
|
|
420
611
|
|
|
421
612
|
```ts
|
|
@@ -431,7 +622,7 @@ type QueueBindingDefinition = object &
|
|
|
431
622
|
};
|
|
432
623
|
```
|
|
433
624
|
|
|
434
|
-
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)
|
|
435
626
|
|
|
436
627
|
Binding between a queue and an exchange.
|
|
437
628
|
|
|
@@ -443,9 +634,9 @@ For fanout exchanges, no routing key is needed as all messages are broadcast.
|
|
|
443
634
|
|
|
444
635
|
| Name | Type | Description | Defined in |
|
|
445
636
|
| ------ | ------ | ------ | ------ |
|
|
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/
|
|
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) |
|
|
449
640
|
|
|
450
641
|
***
|
|
451
642
|
|
|
@@ -455,7 +646,7 @@ For fanout exchanges, no routing key is needed as all messages are broadcast.
|
|
|
455
646
|
type QueueDefinition = object;
|
|
456
647
|
```
|
|
457
648
|
|
|
458
|
-
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)
|
|
459
650
|
|
|
460
651
|
Definition of an AMQP queue.
|
|
461
652
|
|
|
@@ -466,11 +657,45 @@ to receive messages based on routing rules.
|
|
|
466
657
|
|
|
467
658
|
| Property | Type | Description | Defined in |
|
|
468
659
|
| ------ | ------ | ------ | ------ |
|
|
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/
|
|
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
|
+
```
|
|
474
699
|
|
|
475
700
|
***
|
|
476
701
|
|
|
@@ -480,7 +705,7 @@ to receive messages based on routing rules.
|
|
|
480
705
|
type TopicExchangeDefinition = BaseExchangeDefinition & object;
|
|
481
706
|
```
|
|
482
707
|
|
|
483
|
-
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)
|
|
484
709
|
|
|
485
710
|
A topic exchange definition.
|
|
486
711
|
|
|
@@ -494,7 +719,7 @@ Words are separated by dots (e.g., `order.created.high-value`).
|
|
|
494
719
|
|
|
495
720
|
| Name | Type | Defined in |
|
|
496
721
|
| ------ | ------ | ------ |
|
|
497
|
-
| `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) |
|
|
498
723
|
|
|
499
724
|
#### Example
|
|
500
725
|
|
|
@@ -516,7 +741,7 @@ function defineConsumer<TMessage>(
|
|
|
516
741
|
options?): ConsumerDefinition<TMessage>;
|
|
517
742
|
```
|
|
518
743
|
|
|
519
|
-
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)
|
|
520
745
|
|
|
521
746
|
Define a message consumer.
|
|
522
747
|
|
|
@@ -583,7 +808,7 @@ const processOrderConsumer = defineConsumer(orderQueue, orderMessage);
|
|
|
583
808
|
function defineContract<TContract>(definition): TContract;
|
|
584
809
|
```
|
|
585
810
|
|
|
586
|
-
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)
|
|
587
812
|
|
|
588
813
|
Define an AMQP contract.
|
|
589
814
|
|
|
@@ -672,7 +897,7 @@ export const contract = defineContract({
|
|
|
672
897
|
function defineMessage<TPayload, THeaders>(payload, options?): MessageDefinition<TPayload, THeaders>;
|
|
673
898
|
```
|
|
674
899
|
|
|
675
|
-
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)
|
|
676
901
|
|
|
677
902
|
Define a message definition with payload and optional headers/metadata.
|
|
678
903
|
|
|
@@ -733,7 +958,7 @@ const orderMessage = defineMessage(
|
|
|
733
958
|
function defineQueue(name, options?): QueueDefinition;
|
|
734
959
|
```
|
|
735
960
|
|
|
736
|
-
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)
|
|
737
962
|
|
|
738
963
|
Define an AMQP queue.
|
|
739
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",
|