@amqp-contract/contract 0.5.0 → 0.6.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 +7 -4
- package/dist/index.cjs +14 -3
- package/dist/index.d.cts +81 -31
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +81 -31
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +14 -3
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +104 -70
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,10 @@ const orderMessage = defineMessage(z.object({
|
|
|
33
33
|
amount: z.number(),
|
|
34
34
|
}));
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const {
|
|
37
|
+
publisher: orderCreatedPublisher,
|
|
38
|
+
createConsumer: createOrderCreatedConsumer,
|
|
39
|
+
} = definePublisherFirst(
|
|
37
40
|
ordersExchange,
|
|
38
41
|
orderMessage,
|
|
39
42
|
{ routingKey: 'order.created' }
|
|
@@ -41,18 +44,18 @@ const orderCreatedEvent = definePublisherFirst(
|
|
|
41
44
|
|
|
42
45
|
// Multiple queues can consume the same event
|
|
43
46
|
const orderQueue = defineQueue('order-processing', { durable: true });
|
|
44
|
-
const { consumer, binding } =
|
|
47
|
+
const { consumer, binding } = createOrderCreatedConsumer(orderQueue);
|
|
45
48
|
|
|
46
49
|
// For topic exchanges, consumers can override with their own pattern
|
|
47
50
|
const analyticsQueue = defineQueue('analytics', { durable: true });
|
|
48
51
|
const { consumer: analyticsConsumer, binding: analyticsBinding } =
|
|
49
|
-
|
|
52
|
+
createOrderCreatedConsumer(analyticsQueue, 'order.*'); // Subscribe to all order events
|
|
50
53
|
|
|
51
54
|
const contract = defineContract({
|
|
52
55
|
exchanges: { orders: ordersExchange },
|
|
53
56
|
queues: { orderQueue, analyticsQueue },
|
|
54
57
|
bindings: { orderBinding: binding, analyticsBinding },
|
|
55
|
-
publishers: { orderCreated:
|
|
58
|
+
publishers: { orderCreated: orderCreatedPublisher },
|
|
56
59
|
consumers: {
|
|
57
60
|
processOrder: consumer,
|
|
58
61
|
trackOrders: analyticsConsumer,
|
package/dist/index.cjs
CHANGED
|
@@ -31,16 +31,27 @@ function defineExchange(name, type, options) {
|
|
|
31
31
|
* @param options.durable - If true, the queue survives broker restarts (default: false)
|
|
32
32
|
* @param options.exclusive - If true, the queue can only be used by the declaring connection (default: false)
|
|
33
33
|
* @param options.autoDelete - If true, the queue is deleted when the last consumer unsubscribes (default: false)
|
|
34
|
-
* @param options.
|
|
34
|
+
* @param options.deadLetter - Dead letter configuration for handling failed messages
|
|
35
|
+
* @param options.arguments - Additional AMQP arguments (e.g., x-message-ttl, x-max-priority)
|
|
35
36
|
* @returns A queue definition
|
|
36
37
|
*
|
|
37
38
|
* @example
|
|
38
39
|
* ```typescript
|
|
39
|
-
*
|
|
40
|
+
* // Basic queue
|
|
41
|
+
* const orderQueue = defineQueue('order-processing', {
|
|
40
42
|
* durable: true,
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* // Queue with dead letter exchange
|
|
46
|
+
* const dlx = defineExchange('orders-dlx', 'topic', { durable: true });
|
|
47
|
+
* const orderQueueWithDLX = defineQueue('order-processing', {
|
|
48
|
+
* durable: true,
|
|
49
|
+
* deadLetter: {
|
|
50
|
+
* exchange: dlx,
|
|
51
|
+
* routingKey: 'order.failed'
|
|
52
|
+
* },
|
|
41
53
|
* arguments: {
|
|
42
54
|
* 'x-message-ttl': 86400000, // 24 hours
|
|
43
|
-
* 'x-dead-letter-exchange': 'orders-dlx'
|
|
44
55
|
* }
|
|
45
56
|
* });
|
|
46
57
|
* ```
|
package/dist/index.d.cts
CHANGED
|
@@ -103,6 +103,25 @@ type TopicExchangeDefinition = BaseExchangeDefinition & {
|
|
|
103
103
|
* Represents any type of AMQP exchange: fanout, direct, or topic.
|
|
104
104
|
*/
|
|
105
105
|
type ExchangeDefinition = FanoutExchangeDefinition | DirectExchangeDefinition | TopicExchangeDefinition;
|
|
106
|
+
/**
|
|
107
|
+
* Configuration for dead letter exchange (DLX) on a queue.
|
|
108
|
+
*
|
|
109
|
+
* When a message in a queue is rejected, expires, or exceeds the queue length limit,
|
|
110
|
+
* it can be automatically forwarded to a dead letter exchange for further processing
|
|
111
|
+
* or storage.
|
|
112
|
+
*/
|
|
113
|
+
type DeadLetterConfig = {
|
|
114
|
+
/**
|
|
115
|
+
* The exchange to send dead-lettered messages to.
|
|
116
|
+
* This exchange must be declared in the contract.
|
|
117
|
+
*/
|
|
118
|
+
exchange: ExchangeDefinition;
|
|
119
|
+
/**
|
|
120
|
+
* Optional routing key to use when forwarding messages to the dead letter exchange.
|
|
121
|
+
* If not specified, the original message routing key is used.
|
|
122
|
+
*/
|
|
123
|
+
routingKey?: string;
|
|
124
|
+
};
|
|
106
125
|
/**
|
|
107
126
|
* Definition of an AMQP queue.
|
|
108
127
|
*
|
|
@@ -130,6 +149,25 @@ type QueueDefinition = {
|
|
|
130
149
|
* @default false
|
|
131
150
|
*/
|
|
132
151
|
autoDelete?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Dead letter configuration for handling failed or rejected messages.
|
|
154
|
+
*
|
|
155
|
+
* When configured, messages that are rejected, expire, or exceed queue limits
|
|
156
|
+
* will be automatically forwarded to the specified dead letter exchange.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const dlx = defineExchange('orders-dlx', 'topic', { durable: true });
|
|
161
|
+
* const queue = defineQueue('order-processing', {
|
|
162
|
+
* durable: true,
|
|
163
|
+
* deadLetter: {
|
|
164
|
+
* exchange: dlx,
|
|
165
|
+
* routingKey: 'order.failed'
|
|
166
|
+
* }
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
deadLetter?: DeadLetterConfig;
|
|
133
171
|
/**
|
|
134
172
|
* Additional AMQP arguments for advanced configuration.
|
|
135
173
|
*
|
|
@@ -138,15 +176,16 @@ type QueueDefinition = {
|
|
|
138
176
|
* - `x-expires`: Queue expiration time in milliseconds
|
|
139
177
|
* - `x-max-length`: Maximum number of messages in the queue
|
|
140
178
|
* - `x-max-length-bytes`: Maximum size of the queue in bytes
|
|
141
|
-
* - `x-dead-letter-exchange`: Exchange for dead-lettered messages
|
|
142
|
-
* - `x-dead-letter-routing-key`: Routing key for dead-lettered messages
|
|
143
179
|
* - `x-max-priority`: Maximum priority level for priority queues
|
|
144
180
|
*
|
|
181
|
+
* Note: When using the `deadLetter` property, the `x-dead-letter-exchange` and
|
|
182
|
+
* `x-dead-letter-routing-key` arguments are automatically set and should not be
|
|
183
|
+
* specified in this arguments object.
|
|
184
|
+
*
|
|
145
185
|
* @example
|
|
146
186
|
* ```typescript
|
|
147
187
|
* {
|
|
148
188
|
* 'x-message-ttl': 86400000, // 24 hours
|
|
149
|
-
* 'x-dead-letter-exchange': 'dlx',
|
|
150
189
|
* 'x-max-priority': 10
|
|
151
190
|
* }
|
|
152
191
|
* ```
|
|
@@ -494,16 +533,27 @@ declare function defineExchange(name: string, type: "topic", options?: Omit<Base
|
|
|
494
533
|
* @param options.durable - If true, the queue survives broker restarts (default: false)
|
|
495
534
|
* @param options.exclusive - If true, the queue can only be used by the declaring connection (default: false)
|
|
496
535
|
* @param options.autoDelete - If true, the queue is deleted when the last consumer unsubscribes (default: false)
|
|
497
|
-
* @param options.
|
|
536
|
+
* @param options.deadLetter - Dead letter configuration for handling failed messages
|
|
537
|
+
* @param options.arguments - Additional AMQP arguments (e.g., x-message-ttl, x-max-priority)
|
|
498
538
|
* @returns A queue definition
|
|
499
539
|
*
|
|
500
540
|
* @example
|
|
501
541
|
* ```typescript
|
|
502
|
-
*
|
|
542
|
+
* // Basic queue
|
|
543
|
+
* const orderQueue = defineQueue('order-processing', {
|
|
503
544
|
* durable: true,
|
|
545
|
+
* });
|
|
546
|
+
*
|
|
547
|
+
* // Queue with dead letter exchange
|
|
548
|
+
* const dlx = defineExchange('orders-dlx', 'topic', { durable: true });
|
|
549
|
+
* const orderQueueWithDLX = defineQueue('order-processing', {
|
|
550
|
+
* durable: true,
|
|
551
|
+
* deadLetter: {
|
|
552
|
+
* exchange: dlx,
|
|
553
|
+
* routingKey: 'order.failed'
|
|
554
|
+
* },
|
|
504
555
|
* arguments: {
|
|
505
556
|
* 'x-message-ttl': 86400000, // 24 hours
|
|
506
|
-
* 'x-dead-letter-exchange': 'orders-dlx'
|
|
507
557
|
* }
|
|
508
558
|
* });
|
|
509
559
|
* ```
|
|
@@ -1013,15 +1063,15 @@ type PublisherFirstResultWithRoutingKey<TMessage extends MessageDefinition, TPub
|
|
|
1013
1063
|
* );
|
|
1014
1064
|
*
|
|
1015
1065
|
* // Create publisher-first relationship (event pattern)
|
|
1016
|
-
* const
|
|
1066
|
+
* const { publisher: publishLog, createConsumer: createLogConsumer } = definePublisherFirst(logsExchange, logMessage);
|
|
1017
1067
|
*
|
|
1018
1068
|
* // Multiple queues can consume the same event
|
|
1019
1069
|
* const logsQueue1 = defineQueue('logs-queue-1', { durable: true });
|
|
1020
1070
|
* const logsQueue2 = defineQueue('logs-queue-2', { durable: true });
|
|
1021
1071
|
*
|
|
1022
1072
|
* // Use in contract
|
|
1023
|
-
* const { consumer: consumer1, binding: binding1 } =
|
|
1024
|
-
* const { consumer: consumer2, binding: binding2 } =
|
|
1073
|
+
* const { consumer: consumer1, binding: binding1 } = createLogConsumer(logsQueue1);
|
|
1074
|
+
* const { consumer: consumer2, binding: binding2 } = createLogConsumer(logsQueue2);
|
|
1025
1075
|
*
|
|
1026
1076
|
* const contract = defineContract({
|
|
1027
1077
|
* exchanges: { logs: logsExchange },
|
|
@@ -1030,7 +1080,7 @@ type PublisherFirstResultWithRoutingKey<TMessage extends MessageDefinition, TPub
|
|
|
1030
1080
|
* logBinding1: binding1,
|
|
1031
1081
|
* logBinding2: binding2,
|
|
1032
1082
|
* },
|
|
1033
|
-
* publishers: { publishLog
|
|
1083
|
+
* publishers: { publishLog },
|
|
1034
1084
|
* consumers: {
|
|
1035
1085
|
* consumeLog1: consumer1,
|
|
1036
1086
|
* consumeLog2: consumer2,
|
|
@@ -1072,7 +1122,7 @@ declare function definePublisherFirst<TMessage extends MessageDefinition>(exchan
|
|
|
1072
1122
|
* );
|
|
1073
1123
|
*
|
|
1074
1124
|
* // Create publisher-first relationship with routing key
|
|
1075
|
-
* const
|
|
1125
|
+
* const { publisher: executeTaskPublisher, createConsumer: createTaskConsumer } = definePublisherFirst(
|
|
1076
1126
|
* tasksExchange,
|
|
1077
1127
|
* taskMessage,
|
|
1078
1128
|
* { routingKey: 'task.execute' }
|
|
@@ -1080,13 +1130,13 @@ declare function definePublisherFirst<TMessage extends MessageDefinition>(exchan
|
|
|
1080
1130
|
*
|
|
1081
1131
|
* // Use in contract - routing key is consistent across publisher and bindings
|
|
1082
1132
|
* const taskQueue = defineQueue('task-queue', { durable: true });
|
|
1083
|
-
* const { consumer, binding } =
|
|
1133
|
+
* const { consumer, binding } = createTaskConsumer(taskQueue);
|
|
1084
1134
|
*
|
|
1085
1135
|
* const contract = defineContract({
|
|
1086
1136
|
* exchanges: { tasks: tasksExchange },
|
|
1087
1137
|
* queues: { taskQueue },
|
|
1088
1138
|
* bindings: { taskBinding: binding },
|
|
1089
|
-
* publishers: { executeTask:
|
|
1139
|
+
* publishers: { executeTask: executeTaskPublisher },
|
|
1090
1140
|
* consumers: { processTask: consumer },
|
|
1091
1141
|
* });
|
|
1092
1142
|
* ```
|
|
@@ -1127,7 +1177,7 @@ declare function definePublisherFirst<TMessage extends MessageDefinition, TRouti
|
|
|
1127
1177
|
* );
|
|
1128
1178
|
*
|
|
1129
1179
|
* // Create publisher-first relationship with concrete routing key
|
|
1130
|
-
* const
|
|
1180
|
+
* const { publisher: orderCreatedPublisher, createConsumer: createOrderCreatedConsumer } = definePublisherFirst(
|
|
1131
1181
|
* ordersExchange,
|
|
1132
1182
|
* orderMessage,
|
|
1133
1183
|
* { routingKey: 'order.created' } // Concrete key
|
|
@@ -1139,9 +1189,9 @@ declare function definePublisherFirst<TMessage extends MessageDefinition, TRouti
|
|
|
1139
1189
|
*
|
|
1140
1190
|
* // Use in contract
|
|
1141
1191
|
* const { consumer: processConsumer, binding: processBinding } =
|
|
1142
|
-
*
|
|
1192
|
+
* createOrderCreatedConsumer(orderQueue); // Uses 'order.created'
|
|
1143
1193
|
* const { consumer: allOrdersConsumer, binding: allOrdersBinding } =
|
|
1144
|
-
*
|
|
1194
|
+
* createOrderCreatedConsumer(allOrdersQueue, 'order.*'); // Uses pattern
|
|
1145
1195
|
*
|
|
1146
1196
|
* const contract = defineContract({
|
|
1147
1197
|
* exchanges: { orders: ordersExchange },
|
|
@@ -1150,7 +1200,7 @@ declare function definePublisherFirst<TMessage extends MessageDefinition, TRouti
|
|
|
1150
1200
|
* orderBinding: processBinding,
|
|
1151
1201
|
* allOrdersBinding,
|
|
1152
1202
|
* },
|
|
1153
|
-
* publishers: { orderCreated:
|
|
1203
|
+
* publishers: { orderCreated: orderCreatedPublisher },
|
|
1154
1204
|
* consumers: {
|
|
1155
1205
|
* processOrder: processConsumer,
|
|
1156
1206
|
* trackAllOrders: allOrdersConsumer,
|
|
@@ -1248,7 +1298,7 @@ type ConsumerFirstResultWithRoutingKey<TMessage extends MessageDefinition, TCons
|
|
|
1248
1298
|
* );
|
|
1249
1299
|
*
|
|
1250
1300
|
* // Create consumer-first relationship
|
|
1251
|
-
* const
|
|
1301
|
+
* const { consumer: processNotificationConsumer, binding: notificationBinding, createPublisher: createNotificationPublisher } = defineConsumerFirst(
|
|
1252
1302
|
* notificationsQueue,
|
|
1253
1303
|
* notificationsExchange,
|
|
1254
1304
|
* notificationMessage
|
|
@@ -1258,9 +1308,9 @@ type ConsumerFirstResultWithRoutingKey<TMessage extends MessageDefinition, TCons
|
|
|
1258
1308
|
* const contract = defineContract({
|
|
1259
1309
|
* exchanges: { notifications: notificationsExchange },
|
|
1260
1310
|
* queues: { notificationsQueue },
|
|
1261
|
-
* bindings: { notificationBinding
|
|
1262
|
-
* publishers: { sendNotification:
|
|
1263
|
-
* consumers: { processNotification:
|
|
1311
|
+
* bindings: { notificationBinding },
|
|
1312
|
+
* publishers: { sendNotification: createNotificationPublisher() },
|
|
1313
|
+
* consumers: { processNotification: processNotificationConsumer },
|
|
1264
1314
|
* });
|
|
1265
1315
|
* ```
|
|
1266
1316
|
*/
|
|
@@ -1301,7 +1351,7 @@ declare function defineConsumerFirst<TMessage extends MessageDefinition>(queue:
|
|
|
1301
1351
|
* );
|
|
1302
1352
|
*
|
|
1303
1353
|
* // Create consumer-first relationship with routing key
|
|
1304
|
-
* const
|
|
1354
|
+
* const { consumer: processTaskConsumer, binding: taskBinding, createPublisher: createTaskPublisher } = defineConsumerFirst(
|
|
1305
1355
|
* taskQueue,
|
|
1306
1356
|
* tasksExchange,
|
|
1307
1357
|
* taskMessage,
|
|
@@ -1312,9 +1362,9 @@ declare function defineConsumerFirst<TMessage extends MessageDefinition>(queue:
|
|
|
1312
1362
|
* const contract = defineContract({
|
|
1313
1363
|
* exchanges: { tasks: tasksExchange },
|
|
1314
1364
|
* queues: { taskQueue },
|
|
1315
|
-
* bindings: { taskBinding
|
|
1316
|
-
* publishers: { executeTask:
|
|
1317
|
-
* consumers: { processTask:
|
|
1365
|
+
* bindings: { taskBinding },
|
|
1366
|
+
* publishers: { executeTask: createTaskPublisher() },
|
|
1367
|
+
* consumers: { processTask: processTaskConsumer },
|
|
1318
1368
|
* });
|
|
1319
1369
|
* ```
|
|
1320
1370
|
*/
|
|
@@ -1356,7 +1406,7 @@ declare function defineConsumerFirst<TMessage extends MessageDefinition, TRoutin
|
|
|
1356
1406
|
* );
|
|
1357
1407
|
*
|
|
1358
1408
|
* // Create consumer-first relationship with pattern
|
|
1359
|
-
* const
|
|
1409
|
+
* const { consumer: processOrderConsumer, binding: orderBinding, createPublisher: createOrderPublisher } = defineConsumerFirst(
|
|
1360
1410
|
* orderQueue,
|
|
1361
1411
|
* ordersExchange,
|
|
1362
1412
|
* orderMessage,
|
|
@@ -1367,12 +1417,12 @@ declare function defineConsumerFirst<TMessage extends MessageDefinition, TRoutin
|
|
|
1367
1417
|
* const contract = defineContract({
|
|
1368
1418
|
* exchanges: { orders: ordersExchange },
|
|
1369
1419
|
* queues: { orderQueue },
|
|
1370
|
-
* bindings: { orderBinding
|
|
1420
|
+
* bindings: { orderBinding },
|
|
1371
1421
|
* publishers: {
|
|
1372
|
-
* orderCreated:
|
|
1373
|
-
* orderUpdated:
|
|
1422
|
+
* orderCreated: createOrderPublisher('order.created'), // Concrete key
|
|
1423
|
+
* orderUpdated: createOrderPublisher('order.updated'), // Concrete key
|
|
1374
1424
|
* },
|
|
1375
|
-
* consumers: { processOrder:
|
|
1425
|
+
* consumers: { processOrder: processOrderConsumer },
|
|
1376
1426
|
* });
|
|
1377
1427
|
* ```
|
|
1378
1428
|
*/
|
|
@@ -1383,5 +1433,5 @@ declare function defineConsumerFirst<TMessage extends MessageDefinition, TRoutin
|
|
|
1383
1433
|
exchange: TopicExchangeDefinition;
|
|
1384
1434
|
}>>;
|
|
1385
1435
|
//#endregion
|
|
1386
|
-
export { type AnySchema, type BaseExchangeDefinition, type BindingDefinition, type BindingPattern, type ConsumerDefinition, type ConsumerFirstResult, type ConsumerFirstResultWithRoutingKey, type ContractDefinition, type DirectExchangeDefinition, type ExchangeBindingDefinition, type ExchangeDefinition, type FanoutExchangeDefinition, type InferConsumerNames, type InferPublisherNames, type MatchingRoutingKey, type MessageDefinition, type PublisherDefinition, type PublisherFirstResult, type PublisherFirstResultWithRoutingKey, type QueueBindingDefinition, type QueueDefinition, type RoutingKey, type TopicExchangeDefinition, defineConsumer, defineConsumerFirst, defineContract, defineExchange, defineExchangeBinding, defineMessage, definePublisher, definePublisherFirst, defineQueue, defineQueueBinding };
|
|
1436
|
+
export { type AnySchema, type BaseExchangeDefinition, type BindingDefinition, type BindingPattern, type ConsumerDefinition, type ConsumerFirstResult, type ConsumerFirstResultWithRoutingKey, type ContractDefinition, type DeadLetterConfig, type DirectExchangeDefinition, type ExchangeBindingDefinition, type ExchangeDefinition, type FanoutExchangeDefinition, type InferConsumerNames, type InferPublisherNames, type MatchingRoutingKey, type MessageDefinition, type PublisherDefinition, type PublisherFirstResult, type PublisherFirstResultWithRoutingKey, type QueueBindingDefinition, type QueueDefinition, type RoutingKey, type TopicExchangeDefinition, defineConsumer, defineConsumerFirst, defineContract, defineExchange, defineExchangeBinding, defineMessage, definePublisher, definePublisherFirst, defineQueue, defineQueueBinding };
|
|
1387
1437
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/builder.ts"],"sourcesContent":[],"mappings":";;;;;;AAWA;AAQA;AA6CA;AAiBA;AAqBA;AASA;;AAEI,KAtGQ,SAAA,GAAY,gBAsGpB;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/builder.ts"],"sourcesContent":[],"mappings":";;;;;;AAWA;AAQA;AA6CA;AAiBA;AAqBA;AASA;;AAEI,KAtGQ,SAAA,GAAY,gBAsGpB;;;AAUJ;AAoBA;AA4EA;;AAC+B,KAzMnB,sBAAA,GAyMmB;EACK;;;EAYxB,IAAA,EAAA,MAAA;EAAQ;AAsBpB;;;EAegB,OAAA,CAAA,EAAA,OAAA;EAA2B;;;AAiC3C;EAKe,UAAA,CAAA,EAAA,OAAA;EAKD;;;;;EA0BF,QAAA,CAAA,EAAA,OAAA;EAmBA;;;;EAMI,SAAA,CAAA,EA5TF,MA4TE,CAAA,MAAA,EAAA,OAAA,CAAA;CAA2B;;;AA+B3C;;;;;;AAyCA;;;;;AAiB4B,KArYhB,wBAAA,GAA2B,sBAqYX,GAAA;EAAf,IAAA,EAAA,QAAA;CAOiB;;;;;AAyB9B;;;;;;AAkBA;;;AACiC,KAvarB,wBAAA,GAA2B,sBAuaN,GAAA;EAAgC,IAAA,EAAA,QAAA;CAAS;;;;ACld1E;;;;;AA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,QACH,oBAAoB;cACR,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmD3B,qCAAqC,0BAC5C,2BACG,mCACD,oBACC,KACR,QAAQ;YAAoC;oDAG7C,oBACD,UACA,mBAAmB,WACnB,QAAQ;YAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoD9B,qCAAqC,sDAC5C,2BACG,mCACD;cAEK,WAAW;cACX;IAEb,oBACD,UACA,mBAAmB,WACnB,QAAQ;YAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuD9B,qCAAqC,sDAC5C,2BACG,kCACD;cAEK,eAAe;cACf;IAEb,kCACD,UACA,mBAAmB,WACnB,QAAQ;YAAoC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -103,6 +103,25 @@ type TopicExchangeDefinition = BaseExchangeDefinition & {
|
|
|
103
103
|
* Represents any type of AMQP exchange: fanout, direct, or topic.
|
|
104
104
|
*/
|
|
105
105
|
type ExchangeDefinition = FanoutExchangeDefinition | DirectExchangeDefinition | TopicExchangeDefinition;
|
|
106
|
+
/**
|
|
107
|
+
* Configuration for dead letter exchange (DLX) on a queue.
|
|
108
|
+
*
|
|
109
|
+
* When a message in a queue is rejected, expires, or exceeds the queue length limit,
|
|
110
|
+
* it can be automatically forwarded to a dead letter exchange for further processing
|
|
111
|
+
* or storage.
|
|
112
|
+
*/
|
|
113
|
+
type DeadLetterConfig = {
|
|
114
|
+
/**
|
|
115
|
+
* The exchange to send dead-lettered messages to.
|
|
116
|
+
* This exchange must be declared in the contract.
|
|
117
|
+
*/
|
|
118
|
+
exchange: ExchangeDefinition;
|
|
119
|
+
/**
|
|
120
|
+
* Optional routing key to use when forwarding messages to the dead letter exchange.
|
|
121
|
+
* If not specified, the original message routing key is used.
|
|
122
|
+
*/
|
|
123
|
+
routingKey?: string;
|
|
124
|
+
};
|
|
106
125
|
/**
|
|
107
126
|
* Definition of an AMQP queue.
|
|
108
127
|
*
|
|
@@ -130,6 +149,25 @@ type QueueDefinition = {
|
|
|
130
149
|
* @default false
|
|
131
150
|
*/
|
|
132
151
|
autoDelete?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Dead letter configuration for handling failed or rejected messages.
|
|
154
|
+
*
|
|
155
|
+
* When configured, messages that are rejected, expire, or exceed queue limits
|
|
156
|
+
* will be automatically forwarded to the specified dead letter exchange.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const dlx = defineExchange('orders-dlx', 'topic', { durable: true });
|
|
161
|
+
* const queue = defineQueue('order-processing', {
|
|
162
|
+
* durable: true,
|
|
163
|
+
* deadLetter: {
|
|
164
|
+
* exchange: dlx,
|
|
165
|
+
* routingKey: 'order.failed'
|
|
166
|
+
* }
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
deadLetter?: DeadLetterConfig;
|
|
133
171
|
/**
|
|
134
172
|
* Additional AMQP arguments for advanced configuration.
|
|
135
173
|
*
|
|
@@ -138,15 +176,16 @@ type QueueDefinition = {
|
|
|
138
176
|
* - `x-expires`: Queue expiration time in milliseconds
|
|
139
177
|
* - `x-max-length`: Maximum number of messages in the queue
|
|
140
178
|
* - `x-max-length-bytes`: Maximum size of the queue in bytes
|
|
141
|
-
* - `x-dead-letter-exchange`: Exchange for dead-lettered messages
|
|
142
|
-
* - `x-dead-letter-routing-key`: Routing key for dead-lettered messages
|
|
143
179
|
* - `x-max-priority`: Maximum priority level for priority queues
|
|
144
180
|
*
|
|
181
|
+
* Note: When using the `deadLetter` property, the `x-dead-letter-exchange` and
|
|
182
|
+
* `x-dead-letter-routing-key` arguments are automatically set and should not be
|
|
183
|
+
* specified in this arguments object.
|
|
184
|
+
*
|
|
145
185
|
* @example
|
|
146
186
|
* ```typescript
|
|
147
187
|
* {
|
|
148
188
|
* 'x-message-ttl': 86400000, // 24 hours
|
|
149
|
-
* 'x-dead-letter-exchange': 'dlx',
|
|
150
189
|
* 'x-max-priority': 10
|
|
151
190
|
* }
|
|
152
191
|
* ```
|
|
@@ -494,16 +533,27 @@ declare function defineExchange(name: string, type: "topic", options?: Omit<Base
|
|
|
494
533
|
* @param options.durable - If true, the queue survives broker restarts (default: false)
|
|
495
534
|
* @param options.exclusive - If true, the queue can only be used by the declaring connection (default: false)
|
|
496
535
|
* @param options.autoDelete - If true, the queue is deleted when the last consumer unsubscribes (default: false)
|
|
497
|
-
* @param options.
|
|
536
|
+
* @param options.deadLetter - Dead letter configuration for handling failed messages
|
|
537
|
+
* @param options.arguments - Additional AMQP arguments (e.g., x-message-ttl, x-max-priority)
|
|
498
538
|
* @returns A queue definition
|
|
499
539
|
*
|
|
500
540
|
* @example
|
|
501
541
|
* ```typescript
|
|
502
|
-
*
|
|
542
|
+
* // Basic queue
|
|
543
|
+
* const orderQueue = defineQueue('order-processing', {
|
|
503
544
|
* durable: true,
|
|
545
|
+
* });
|
|
546
|
+
*
|
|
547
|
+
* // Queue with dead letter exchange
|
|
548
|
+
* const dlx = defineExchange('orders-dlx', 'topic', { durable: true });
|
|
549
|
+
* const orderQueueWithDLX = defineQueue('order-processing', {
|
|
550
|
+
* durable: true,
|
|
551
|
+
* deadLetter: {
|
|
552
|
+
* exchange: dlx,
|
|
553
|
+
* routingKey: 'order.failed'
|
|
554
|
+
* },
|
|
504
555
|
* arguments: {
|
|
505
556
|
* 'x-message-ttl': 86400000, // 24 hours
|
|
506
|
-
* 'x-dead-letter-exchange': 'orders-dlx'
|
|
507
557
|
* }
|
|
508
558
|
* });
|
|
509
559
|
* ```
|
|
@@ -1013,15 +1063,15 @@ type PublisherFirstResultWithRoutingKey<TMessage extends MessageDefinition, TPub
|
|
|
1013
1063
|
* );
|
|
1014
1064
|
*
|
|
1015
1065
|
* // Create publisher-first relationship (event pattern)
|
|
1016
|
-
* const
|
|
1066
|
+
* const { publisher: publishLog, createConsumer: createLogConsumer } = definePublisherFirst(logsExchange, logMessage);
|
|
1017
1067
|
*
|
|
1018
1068
|
* // Multiple queues can consume the same event
|
|
1019
1069
|
* const logsQueue1 = defineQueue('logs-queue-1', { durable: true });
|
|
1020
1070
|
* const logsQueue2 = defineQueue('logs-queue-2', { durable: true });
|
|
1021
1071
|
*
|
|
1022
1072
|
* // Use in contract
|
|
1023
|
-
* const { consumer: consumer1, binding: binding1 } =
|
|
1024
|
-
* const { consumer: consumer2, binding: binding2 } =
|
|
1073
|
+
* const { consumer: consumer1, binding: binding1 } = createLogConsumer(logsQueue1);
|
|
1074
|
+
* const { consumer: consumer2, binding: binding2 } = createLogConsumer(logsQueue2);
|
|
1025
1075
|
*
|
|
1026
1076
|
* const contract = defineContract({
|
|
1027
1077
|
* exchanges: { logs: logsExchange },
|
|
@@ -1030,7 +1080,7 @@ type PublisherFirstResultWithRoutingKey<TMessage extends MessageDefinition, TPub
|
|
|
1030
1080
|
* logBinding1: binding1,
|
|
1031
1081
|
* logBinding2: binding2,
|
|
1032
1082
|
* },
|
|
1033
|
-
* publishers: { publishLog
|
|
1083
|
+
* publishers: { publishLog },
|
|
1034
1084
|
* consumers: {
|
|
1035
1085
|
* consumeLog1: consumer1,
|
|
1036
1086
|
* consumeLog2: consumer2,
|
|
@@ -1072,7 +1122,7 @@ declare function definePublisherFirst<TMessage extends MessageDefinition>(exchan
|
|
|
1072
1122
|
* );
|
|
1073
1123
|
*
|
|
1074
1124
|
* // Create publisher-first relationship with routing key
|
|
1075
|
-
* const
|
|
1125
|
+
* const { publisher: executeTaskPublisher, createConsumer: createTaskConsumer } = definePublisherFirst(
|
|
1076
1126
|
* tasksExchange,
|
|
1077
1127
|
* taskMessage,
|
|
1078
1128
|
* { routingKey: 'task.execute' }
|
|
@@ -1080,13 +1130,13 @@ declare function definePublisherFirst<TMessage extends MessageDefinition>(exchan
|
|
|
1080
1130
|
*
|
|
1081
1131
|
* // Use in contract - routing key is consistent across publisher and bindings
|
|
1082
1132
|
* const taskQueue = defineQueue('task-queue', { durable: true });
|
|
1083
|
-
* const { consumer, binding } =
|
|
1133
|
+
* const { consumer, binding } = createTaskConsumer(taskQueue);
|
|
1084
1134
|
*
|
|
1085
1135
|
* const contract = defineContract({
|
|
1086
1136
|
* exchanges: { tasks: tasksExchange },
|
|
1087
1137
|
* queues: { taskQueue },
|
|
1088
1138
|
* bindings: { taskBinding: binding },
|
|
1089
|
-
* publishers: { executeTask:
|
|
1139
|
+
* publishers: { executeTask: executeTaskPublisher },
|
|
1090
1140
|
* consumers: { processTask: consumer },
|
|
1091
1141
|
* });
|
|
1092
1142
|
* ```
|
|
@@ -1127,7 +1177,7 @@ declare function definePublisherFirst<TMessage extends MessageDefinition, TRouti
|
|
|
1127
1177
|
* );
|
|
1128
1178
|
*
|
|
1129
1179
|
* // Create publisher-first relationship with concrete routing key
|
|
1130
|
-
* const
|
|
1180
|
+
* const { publisher: orderCreatedPublisher, createConsumer: createOrderCreatedConsumer } = definePublisherFirst(
|
|
1131
1181
|
* ordersExchange,
|
|
1132
1182
|
* orderMessage,
|
|
1133
1183
|
* { routingKey: 'order.created' } // Concrete key
|
|
@@ -1139,9 +1189,9 @@ declare function definePublisherFirst<TMessage extends MessageDefinition, TRouti
|
|
|
1139
1189
|
*
|
|
1140
1190
|
* // Use in contract
|
|
1141
1191
|
* const { consumer: processConsumer, binding: processBinding } =
|
|
1142
|
-
*
|
|
1192
|
+
* createOrderCreatedConsumer(orderQueue); // Uses 'order.created'
|
|
1143
1193
|
* const { consumer: allOrdersConsumer, binding: allOrdersBinding } =
|
|
1144
|
-
*
|
|
1194
|
+
* createOrderCreatedConsumer(allOrdersQueue, 'order.*'); // Uses pattern
|
|
1145
1195
|
*
|
|
1146
1196
|
* const contract = defineContract({
|
|
1147
1197
|
* exchanges: { orders: ordersExchange },
|
|
@@ -1150,7 +1200,7 @@ declare function definePublisherFirst<TMessage extends MessageDefinition, TRouti
|
|
|
1150
1200
|
* orderBinding: processBinding,
|
|
1151
1201
|
* allOrdersBinding,
|
|
1152
1202
|
* },
|
|
1153
|
-
* publishers: { orderCreated:
|
|
1203
|
+
* publishers: { orderCreated: orderCreatedPublisher },
|
|
1154
1204
|
* consumers: {
|
|
1155
1205
|
* processOrder: processConsumer,
|
|
1156
1206
|
* trackAllOrders: allOrdersConsumer,
|
|
@@ -1248,7 +1298,7 @@ type ConsumerFirstResultWithRoutingKey<TMessage extends MessageDefinition, TCons
|
|
|
1248
1298
|
* );
|
|
1249
1299
|
*
|
|
1250
1300
|
* // Create consumer-first relationship
|
|
1251
|
-
* const
|
|
1301
|
+
* const { consumer: processNotificationConsumer, binding: notificationBinding, createPublisher: createNotificationPublisher } = defineConsumerFirst(
|
|
1252
1302
|
* notificationsQueue,
|
|
1253
1303
|
* notificationsExchange,
|
|
1254
1304
|
* notificationMessage
|
|
@@ -1258,9 +1308,9 @@ type ConsumerFirstResultWithRoutingKey<TMessage extends MessageDefinition, TCons
|
|
|
1258
1308
|
* const contract = defineContract({
|
|
1259
1309
|
* exchanges: { notifications: notificationsExchange },
|
|
1260
1310
|
* queues: { notificationsQueue },
|
|
1261
|
-
* bindings: { notificationBinding
|
|
1262
|
-
* publishers: { sendNotification:
|
|
1263
|
-
* consumers: { processNotification:
|
|
1311
|
+
* bindings: { notificationBinding },
|
|
1312
|
+
* publishers: { sendNotification: createNotificationPublisher() },
|
|
1313
|
+
* consumers: { processNotification: processNotificationConsumer },
|
|
1264
1314
|
* });
|
|
1265
1315
|
* ```
|
|
1266
1316
|
*/
|
|
@@ -1301,7 +1351,7 @@ declare function defineConsumerFirst<TMessage extends MessageDefinition>(queue:
|
|
|
1301
1351
|
* );
|
|
1302
1352
|
*
|
|
1303
1353
|
* // Create consumer-first relationship with routing key
|
|
1304
|
-
* const
|
|
1354
|
+
* const { consumer: processTaskConsumer, binding: taskBinding, createPublisher: createTaskPublisher } = defineConsumerFirst(
|
|
1305
1355
|
* taskQueue,
|
|
1306
1356
|
* tasksExchange,
|
|
1307
1357
|
* taskMessage,
|
|
@@ -1312,9 +1362,9 @@ declare function defineConsumerFirst<TMessage extends MessageDefinition>(queue:
|
|
|
1312
1362
|
* const contract = defineContract({
|
|
1313
1363
|
* exchanges: { tasks: tasksExchange },
|
|
1314
1364
|
* queues: { taskQueue },
|
|
1315
|
-
* bindings: { taskBinding
|
|
1316
|
-
* publishers: { executeTask:
|
|
1317
|
-
* consumers: { processTask:
|
|
1365
|
+
* bindings: { taskBinding },
|
|
1366
|
+
* publishers: { executeTask: createTaskPublisher() },
|
|
1367
|
+
* consumers: { processTask: processTaskConsumer },
|
|
1318
1368
|
* });
|
|
1319
1369
|
* ```
|
|
1320
1370
|
*/
|
|
@@ -1356,7 +1406,7 @@ declare function defineConsumerFirst<TMessage extends MessageDefinition, TRoutin
|
|
|
1356
1406
|
* );
|
|
1357
1407
|
*
|
|
1358
1408
|
* // Create consumer-first relationship with pattern
|
|
1359
|
-
* const
|
|
1409
|
+
* const { consumer: processOrderConsumer, binding: orderBinding, createPublisher: createOrderPublisher } = defineConsumerFirst(
|
|
1360
1410
|
* orderQueue,
|
|
1361
1411
|
* ordersExchange,
|
|
1362
1412
|
* orderMessage,
|
|
@@ -1367,12 +1417,12 @@ declare function defineConsumerFirst<TMessage extends MessageDefinition, TRoutin
|
|
|
1367
1417
|
* const contract = defineContract({
|
|
1368
1418
|
* exchanges: { orders: ordersExchange },
|
|
1369
1419
|
* queues: { orderQueue },
|
|
1370
|
-
* bindings: { orderBinding
|
|
1420
|
+
* bindings: { orderBinding },
|
|
1371
1421
|
* publishers: {
|
|
1372
|
-
* orderCreated:
|
|
1373
|
-
* orderUpdated:
|
|
1422
|
+
* orderCreated: createOrderPublisher('order.created'), // Concrete key
|
|
1423
|
+
* orderUpdated: createOrderPublisher('order.updated'), // Concrete key
|
|
1374
1424
|
* },
|
|
1375
|
-
* consumers: { processOrder:
|
|
1425
|
+
* consumers: { processOrder: processOrderConsumer },
|
|
1376
1426
|
* });
|
|
1377
1427
|
* ```
|
|
1378
1428
|
*/
|
|
@@ -1383,5 +1433,5 @@ declare function defineConsumerFirst<TMessage extends MessageDefinition, TRoutin
|
|
|
1383
1433
|
exchange: TopicExchangeDefinition;
|
|
1384
1434
|
}>>;
|
|
1385
1435
|
//#endregion
|
|
1386
|
-
export { type AnySchema, type BaseExchangeDefinition, type BindingDefinition, type BindingPattern, type ConsumerDefinition, type ConsumerFirstResult, type ConsumerFirstResultWithRoutingKey, type ContractDefinition, type DirectExchangeDefinition, type ExchangeBindingDefinition, type ExchangeDefinition, type FanoutExchangeDefinition, type InferConsumerNames, type InferPublisherNames, type MatchingRoutingKey, type MessageDefinition, type PublisherDefinition, type PublisherFirstResult, type PublisherFirstResultWithRoutingKey, type QueueBindingDefinition, type QueueDefinition, type RoutingKey, type TopicExchangeDefinition, defineConsumer, defineConsumerFirst, defineContract, defineExchange, defineExchangeBinding, defineMessage, definePublisher, definePublisherFirst, defineQueue, defineQueueBinding };
|
|
1436
|
+
export { type AnySchema, type BaseExchangeDefinition, type BindingDefinition, type BindingPattern, type ConsumerDefinition, type ConsumerFirstResult, type ConsumerFirstResultWithRoutingKey, type ContractDefinition, type DeadLetterConfig, type DirectExchangeDefinition, type ExchangeBindingDefinition, type ExchangeDefinition, type FanoutExchangeDefinition, type InferConsumerNames, type InferPublisherNames, type MatchingRoutingKey, type MessageDefinition, type PublisherDefinition, type PublisherFirstResult, type PublisherFirstResultWithRoutingKey, type QueueBindingDefinition, type QueueDefinition, type RoutingKey, type TopicExchangeDefinition, defineConsumer, defineConsumerFirst, defineContract, defineExchange, defineExchangeBinding, defineMessage, definePublisher, definePublisherFirst, defineQueue, defineQueueBinding };
|
|
1387
1437
|
//# sourceMappingURL=index.d.mts.map
|