@zdavison/matador 2.0.7 → 2.0.9

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.
Files changed (200) hide show
  1. package/package.json +3 -2
  2. package/src/hooks/safe-hooks.ts +0 -16
  3. package/src/hooks/types.ts +0 -7
  4. package/src/index.ts +1 -0
  5. package/src/types/event.ts +8 -14
  6. package/src/types/index.ts +3 -2
  7. package/dist/checkpoint/context.d.ts +0 -59
  8. package/dist/checkpoint/context.d.ts.map +0 -1
  9. package/dist/checkpoint/context.js +0 -140
  10. package/dist/checkpoint/context.test.d.ts +0 -2
  11. package/dist/checkpoint/context.test.d.ts.map +0 -1
  12. package/dist/checkpoint/context.test.js +0 -424
  13. package/dist/checkpoint/index.d.ts +0 -7
  14. package/dist/checkpoint/index.d.ts.map +0 -1
  15. package/dist/checkpoint/index.js +0 -6
  16. package/dist/checkpoint/stores/memory.d.ts +0 -29
  17. package/dist/checkpoint/stores/memory.d.ts.map +0 -1
  18. package/dist/checkpoint/stores/memory.js +0 -39
  19. package/dist/checkpoint/stores/noop.d.ts +0 -14
  20. package/dist/checkpoint/stores/noop.d.ts.map +0 -1
  21. package/dist/checkpoint/stores/noop.js +0 -18
  22. package/dist/checkpoint/stores/stores.test.d.ts +0 -2
  23. package/dist/checkpoint/stores/stores.test.d.ts.map +0 -1
  24. package/dist/checkpoint/stores/stores.test.js +0 -146
  25. package/dist/checkpoint/types.d.ts +0 -119
  26. package/dist/checkpoint/types.d.ts.map +0 -1
  27. package/dist/checkpoint/types.js +0 -1
  28. package/dist/codec/codec.d.ts +0 -29
  29. package/dist/codec/codec.d.ts.map +0 -1
  30. package/dist/codec/codec.js +0 -15
  31. package/dist/codec/header-aware-codec.d.ts +0 -36
  32. package/dist/codec/header-aware-codec.d.ts.map +0 -1
  33. package/dist/codec/header-aware-codec.js +0 -1
  34. package/dist/codec/index.d.ts +0 -6
  35. package/dist/codec/index.d.ts.map +0 -1
  36. package/dist/codec/index.js +0 -3
  37. package/dist/codec/json-codec.d.ts +0 -13
  38. package/dist/codec/json-codec.d.ts.map +0 -1
  39. package/dist/codec/json-codec.js +0 -64
  40. package/dist/codec/rabbitmq-codec.d.ts +0 -28
  41. package/dist/codec/rabbitmq-codec.d.ts.map +0 -1
  42. package/dist/codec/rabbitmq-codec.js +0 -242
  43. package/dist/codec/rabbitmq-codec.test.d.ts +0 -2
  44. package/dist/codec/rabbitmq-codec.test.d.ts.map +0 -1
  45. package/dist/codec/rabbitmq-codec.test.js +0 -433
  46. package/dist/core/fanout.d.ts +0 -59
  47. package/dist/core/fanout.d.ts.map +0 -1
  48. package/dist/core/fanout.js +0 -121
  49. package/dist/core/fanout.test.d.ts +0 -2
  50. package/dist/core/fanout.test.d.ts.map +0 -1
  51. package/dist/core/fanout.test.js +0 -1054
  52. package/dist/core/index.d.ts +0 -7
  53. package/dist/core/index.d.ts.map +0 -1
  54. package/dist/core/index.js +0 -3
  55. package/dist/core/matador.d.ts +0 -133
  56. package/dist/core/matador.d.ts.map +0 -1
  57. package/dist/core/matador.js +0 -228
  58. package/dist/core/matador.test.d.ts +0 -2
  59. package/dist/core/matador.test.d.ts.map +0 -1
  60. package/dist/core/matador.test.js +0 -446
  61. package/dist/core/shutdown.d.ts +0 -78
  62. package/dist/core/shutdown.d.ts.map +0 -1
  63. package/dist/core/shutdown.js +0 -111
  64. package/dist/core/shutdown.test.d.ts +0 -2
  65. package/dist/core/shutdown.test.d.ts.map +0 -1
  66. package/dist/core/shutdown.test.js +0 -524
  67. package/dist/errors/checkpoint-errors.d.ts +0 -30
  68. package/dist/errors/checkpoint-errors.d.ts.map +0 -1
  69. package/dist/errors/checkpoint-errors.js +0 -49
  70. package/dist/errors/has-description.d.ts +0 -18
  71. package/dist/errors/has-description.d.ts.map +0 -1
  72. package/dist/errors/has-description.js +0 -9
  73. package/dist/errors/index.d.ts +0 -6
  74. package/dist/errors/index.d.ts.map +0 -1
  75. package/dist/errors/index.js +0 -22
  76. package/dist/errors/matador-errors.d.ts +0 -183
  77. package/dist/errors/matador-errors.d.ts.map +0 -1
  78. package/dist/errors/matador-errors.js +0 -376
  79. package/dist/errors/retry-errors.d.ts +0 -102
  80. package/dist/errors/retry-errors.d.ts.map +0 -1
  81. package/dist/errors/retry-errors.js +0 -155
  82. package/dist/errors/retry-errors.test.d.ts +0 -2
  83. package/dist/errors/retry-errors.test.d.ts.map +0 -1
  84. package/dist/errors/retry-errors.test.js +0 -136
  85. package/dist/hooks/index.d.ts +0 -4
  86. package/dist/hooks/index.d.ts.map +0 -1
  87. package/dist/hooks/index.js +0 -2
  88. package/dist/hooks/safe-hooks.d.ts +0 -33
  89. package/dist/hooks/safe-hooks.d.ts.map +0 -1
  90. package/dist/hooks/safe-hooks.js +0 -132
  91. package/dist/hooks/types.d.ts +0 -176
  92. package/dist/hooks/types.d.ts.map +0 -1
  93. package/dist/hooks/types.js +0 -9
  94. package/dist/index.cjs +0 -3242
  95. package/dist/index.cjs.map +0 -1
  96. package/dist/index.d.cts +0 -23
  97. package/dist/index.d.ts +0 -23
  98. package/dist/index.d.ts.map +0 -1
  99. package/dist/index.js +0 -31
  100. package/dist/index.js.map +0 -1
  101. package/dist/pipeline/index.d.ts +0 -3
  102. package/dist/pipeline/index.d.ts.map +0 -1
  103. package/dist/pipeline/index.js +0 -1
  104. package/dist/pipeline/pipeline.d.ts +0 -63
  105. package/dist/pipeline/pipeline.d.ts.map +0 -1
  106. package/dist/pipeline/pipeline.js +0 -273
  107. package/dist/pipeline/pipeline.test.d.ts +0 -2
  108. package/dist/pipeline/pipeline.test.d.ts.map +0 -1
  109. package/dist/pipeline/pipeline.test.js +0 -1112
  110. package/dist/retry/index.d.ts +0 -4
  111. package/dist/retry/index.d.ts.map +0 -1
  112. package/dist/retry/index.js +0 -1
  113. package/dist/retry/policy.d.ts +0 -43
  114. package/dist/retry/policy.d.ts.map +0 -1
  115. package/dist/retry/policy.js +0 -1
  116. package/dist/retry/standard-policy.d.ts +0 -44
  117. package/dist/retry/standard-policy.d.ts.map +0 -1
  118. package/dist/retry/standard-policy.js +0 -102
  119. package/dist/retry/standard-policy.test.d.ts +0 -2
  120. package/dist/retry/standard-policy.test.d.ts.map +0 -1
  121. package/dist/retry/standard-policy.test.js +0 -196
  122. package/dist/schema/index.d.ts +0 -4
  123. package/dist/schema/index.d.ts.map +0 -1
  124. package/dist/schema/index.js +0 -2
  125. package/dist/schema/registry.d.ts +0 -63
  126. package/dist/schema/registry.d.ts.map +0 -1
  127. package/dist/schema/registry.js +0 -174
  128. package/dist/schema/registry.test.d.ts +0 -2
  129. package/dist/schema/registry.test.d.ts.map +0 -1
  130. package/dist/schema/registry.test.js +0 -278
  131. package/dist/schema/types.d.ts +0 -158
  132. package/dist/schema/types.d.ts.map +0 -1
  133. package/dist/schema/types.js +0 -74
  134. package/dist/schema/types.test.d.ts +0 -2
  135. package/dist/schema/types.test.d.ts.map +0 -1
  136. package/dist/schema/types.test.js +0 -242
  137. package/dist/topology/builder.d.ts +0 -80
  138. package/dist/topology/builder.d.ts.map +0 -1
  139. package/dist/topology/builder.js +0 -165
  140. package/dist/topology/builder.test.d.ts +0 -2
  141. package/dist/topology/builder.test.d.ts.map +0 -1
  142. package/dist/topology/builder.test.js +0 -360
  143. package/dist/topology/index.d.ts +0 -5
  144. package/dist/topology/index.d.ts.map +0 -1
  145. package/dist/topology/index.js +0 -2
  146. package/dist/topology/types.d.ts +0 -128
  147. package/dist/topology/types.d.ts.map +0 -1
  148. package/dist/topology/types.js +0 -28
  149. package/dist/transport/capabilities.d.ts +0 -66
  150. package/dist/transport/capabilities.d.ts.map +0 -1
  151. package/dist/transport/capabilities.js +0 -18
  152. package/dist/transport/connection-manager.d.ts +0 -95
  153. package/dist/transport/connection-manager.d.ts.map +0 -1
  154. package/dist/transport/connection-manager.js +0 -144
  155. package/dist/transport/index.d.ts +0 -11
  156. package/dist/transport/index.d.ts.map +0 -1
  157. package/dist/transport/index.js +0 -5
  158. package/dist/transport/local/local-transport.d.ts +0 -62
  159. package/dist/transport/local/local-transport.d.ts.map +0 -1
  160. package/dist/transport/local/local-transport.js +0 -241
  161. package/dist/transport/local/local-transport.test.d.ts +0 -2
  162. package/dist/transport/local/local-transport.test.d.ts.map +0 -1
  163. package/dist/transport/local/local-transport.test.js +0 -192
  164. package/dist/transport/multi/multi-transport.d.ts +0 -94
  165. package/dist/transport/multi/multi-transport.d.ts.map +0 -1
  166. package/dist/transport/multi/multi-transport.js +0 -184
  167. package/dist/transport/multi/multi-transport.test.d.ts +0 -2
  168. package/dist/transport/multi/multi-transport.test.d.ts.map +0 -1
  169. package/dist/transport/multi/multi-transport.test.js +0 -236
  170. package/dist/transport/rabbitmq/rabbitmq-transport.d.ts +0 -83
  171. package/dist/transport/rabbitmq/rabbitmq-transport.d.ts.map +0 -1
  172. package/dist/transport/rabbitmq/rabbitmq-transport.js +0 -541
  173. package/dist/transport/rabbitmq/rabbitmq-transport.test.d.ts +0 -2
  174. package/dist/transport/rabbitmq/rabbitmq-transport.test.d.ts.map +0 -1
  175. package/dist/transport/rabbitmq/rabbitmq-transport.test.js +0 -100
  176. package/dist/transport/transport.d.ts +0 -152
  177. package/dist/transport/transport.d.ts.map +0 -1
  178. package/dist/transport/transport.js +0 -1
  179. package/dist/types/common.d.ts +0 -41
  180. package/dist/types/common.d.ts.map +0 -1
  181. package/dist/types/common.js +0 -12
  182. package/dist/types/dispatcher.d.ts +0 -14
  183. package/dist/types/dispatcher.d.ts.map +0 -1
  184. package/dist/types/dispatcher.js +0 -1
  185. package/dist/types/envelope.d.ts +0 -131
  186. package/dist/types/envelope.d.ts.map +0 -1
  187. package/dist/types/envelope.js +0 -99
  188. package/dist/types/event.d.ts +0 -96
  189. package/dist/types/event.d.ts.map +0 -1
  190. package/dist/types/event.js +0 -26
  191. package/dist/types/event.test.d.ts +0 -2
  192. package/dist/types/event.test.d.ts.map +0 -1
  193. package/dist/types/event.test.js +0 -130
  194. package/dist/types/index.d.ts +0 -10
  195. package/dist/types/index.d.ts.map +0 -1
  196. package/dist/types/index.js +0 -4
  197. package/dist/types/subscriber.d.ts +0 -227
  198. package/dist/types/subscriber.d.ts.map +0 -1
  199. package/dist/types/subscriber.js +0 -97
  200. package/tsconfig.tsbuildinfo +0 -1
@@ -1,242 +0,0 @@
1
- import { describe, expect, it } from 'bun:test';
2
- import { MatadorEvent, createSubscriber, createSubscriberStub, } from '../types/index.js';
3
- import { bind, installPlugins, isSchemaEntryTuple } from './types.js';
4
- class UserCreatedEvent extends MatadorEvent {
5
- data;
6
- static key = 'user.created';
7
- static description = 'User created event';
8
- constructor(data) {
9
- super();
10
- this.data = data;
11
- }
12
- }
13
- class OrderPlacedEvent extends MatadorEvent {
14
- data;
15
- static key = 'order.placed';
16
- static description = 'Order placed event';
17
- constructor(data) {
18
- super();
19
- this.data = data;
20
- }
21
- }
22
- class ChatMessageSentEvent extends MatadorEvent {
23
- data;
24
- static key = 'chat.message.sent';
25
- static description = 'Chat message sent event';
26
- constructor(data) {
27
- super();
28
- this.data = data;
29
- }
30
- }
31
- describe('bind', () => {
32
- it('should create a schema entry tuple', () => {
33
- const subscriber = createSubscriber({
34
- name: 'test-sub',
35
- description: 'Test subscriber',
36
- callback: async () => { },
37
- });
38
- const entry = bind(UserCreatedEvent, [subscriber]);
39
- expect(isSchemaEntryTuple(entry)).toBe(true);
40
- expect(entry[0]).toBe(UserCreatedEvent);
41
- expect(entry[1]).toHaveLength(1);
42
- expect(entry[1][0]).toBe(subscriber);
43
- });
44
- });
45
- describe('isSchemaEntryTuple', () => {
46
- it('should return true for tuple format', () => {
47
- const entry = [UserCreatedEvent, []];
48
- expect(isSchemaEntryTuple(entry)).toBe(true);
49
- });
50
- it('should return false for object format', () => {
51
- const entry = { eventClass: UserCreatedEvent, subscribers: [] };
52
- expect(isSchemaEntryTuple(entry)).toBe(false);
53
- });
54
- });
55
- describe('installPlugins', () => {
56
- it('should add plugin subscriber to all events', () => {
57
- const sub1 = createSubscriber({
58
- name: 'user-handler',
59
- description: 'Handles user events',
60
- callback: async () => { },
61
- });
62
- const sub2 = createSubscriber({
63
- name: 'order-handler',
64
- description: 'Handles order events',
65
- callback: async () => { },
66
- });
67
- const globalSub = createSubscriber({
68
- name: 'analytics',
69
- description: 'Analytics subscriber',
70
- callback: async () => { },
71
- });
72
- const baseSchema = {
73
- [UserCreatedEvent.key]: [UserCreatedEvent, [sub1]],
74
- [OrderPlacedEvent.key]: [OrderPlacedEvent, [sub2]],
75
- };
76
- const schema = installPlugins(baseSchema, [{ subscriber: globalSub }]);
77
- // Check user.created has both subscribers
78
- const userEntry = schema[UserCreatedEvent.key];
79
- expect(isSchemaEntryTuple(userEntry)).toBe(true);
80
- const [, userSubs] = userEntry;
81
- expect(userSubs).toHaveLength(2);
82
- expect(userSubs[0]).toBe(sub1);
83
- expect(userSubs[1]).toBe(globalSub);
84
- // Check order.placed has both subscribers
85
- const orderEntry = schema[OrderPlacedEvent.key];
86
- const [, orderSubs] = orderEntry;
87
- expect(orderSubs).toHaveLength(2);
88
- expect(orderSubs[0]).toBe(sub2);
89
- expect(orderSubs[1]).toBe(globalSub);
90
- });
91
- it('should respect exclusions', () => {
92
- const sub1 = createSubscriber({
93
- name: 'user-handler',
94
- description: 'Handles user events',
95
- callback: async () => { },
96
- });
97
- const sub2 = createSubscriber({
98
- name: 'order-handler',
99
- description: 'Handles order events',
100
- callback: async () => { },
101
- });
102
- const sub3 = createSubscriber({
103
- name: 'chat-handler',
104
- description: 'Handles chat events',
105
- callback: async () => { },
106
- });
107
- const globalSub = createSubscriber({
108
- name: 'analytics',
109
- description: 'Analytics subscriber',
110
- callback: async () => { },
111
- });
112
- const baseSchema = {
113
- [UserCreatedEvent.key]: [UserCreatedEvent, [sub1]],
114
- [OrderPlacedEvent.key]: [OrderPlacedEvent, [sub2]],
115
- [ChatMessageSentEvent.key]: [ChatMessageSentEvent, [sub3]],
116
- };
117
- const schema = installPlugins(baseSchema, [
118
- {
119
- subscriber: globalSub,
120
- exclusions: [ChatMessageSentEvent.key],
121
- },
122
- ]);
123
- // user.created should have analytics
124
- const userEntry = schema[UserCreatedEvent.key];
125
- const [, userSubs] = userEntry;
126
- expect(userSubs).toHaveLength(2);
127
- // order.placed should have analytics
128
- const orderEntry = schema[OrderPlacedEvent.key];
129
- const [, orderSubs] = orderEntry;
130
- expect(orderSubs).toHaveLength(2);
131
- // chat.message.sent should NOT have analytics (excluded)
132
- const chatEntry = schema[ChatMessageSentEvent.key];
133
- const [, chatSubs] = chatEntry;
134
- expect(chatSubs).toHaveLength(1);
135
- expect(chatSubs[0]).toBe(sub3);
136
- });
137
- it('should handle multiple plugins', () => {
138
- const sub1 = createSubscriber({
139
- name: 'user-handler',
140
- description: 'Handles user events',
141
- callback: async () => { },
142
- });
143
- const analyticsSub = createSubscriber({
144
- name: 'analytics',
145
- description: 'Analytics subscriber',
146
- callback: async () => { },
147
- });
148
- const loggingSub = createSubscriber({
149
- name: 'logging',
150
- description: 'Logging subscriber',
151
- callback: async () => { },
152
- });
153
- const baseSchema = {
154
- [UserCreatedEvent.key]: [UserCreatedEvent, [sub1]],
155
- };
156
- const schema = installPlugins(baseSchema, [
157
- { subscriber: analyticsSub },
158
- { subscriber: loggingSub },
159
- ]);
160
- const entry = schema[UserCreatedEvent.key];
161
- const [, subs] = entry;
162
- expect(subs).toHaveLength(3);
163
- expect(subs[0]).toBe(sub1);
164
- expect(subs[1]).toBe(analyticsSub);
165
- expect(subs[2]).toBe(loggingSub);
166
- });
167
- it('should handle object format schema entries', () => {
168
- const sub1 = createSubscriber({
169
- name: 'user-handler',
170
- description: 'Handles user events',
171
- callback: async () => { },
172
- });
173
- const globalSub = createSubscriber({
174
- name: 'analytics',
175
- description: 'Analytics subscriber',
176
- callback: async () => { },
177
- });
178
- const baseSchema = {
179
- [UserCreatedEvent.key]: {
180
- eventClass: UserCreatedEvent,
181
- subscribers: [sub1],
182
- },
183
- };
184
- const schema = installPlugins(baseSchema, [{ subscriber: globalSub }]);
185
- const entry = schema[UserCreatedEvent.key];
186
- expect(isSchemaEntryTuple(entry)).toBe(true);
187
- const [eventClass, subs] = entry;
188
- expect(eventClass).toBe(UserCreatedEvent);
189
- expect(subs).toHaveLength(2);
190
- });
191
- it('should work with subscriber stubs', () => {
192
- const sub1 = createSubscriber({
193
- name: 'user-handler',
194
- description: 'Handles user events',
195
- callback: async () => { },
196
- });
197
- const stubSub = createSubscriberStub({
198
- name: 'remote-analytics',
199
- targetQueue: 'analytics-worker',
200
- });
201
- const baseSchema = {
202
- [UserCreatedEvent.key]: [UserCreatedEvent, [sub1]],
203
- };
204
- const schema = installPlugins(baseSchema, [{ subscriber: stubSub }]);
205
- const entry = schema[UserCreatedEvent.key];
206
- const [, subs] = entry;
207
- expect(subs).toHaveLength(2);
208
- expect(subs[1]).toBe(stubSub);
209
- });
210
- it('should return empty schema for empty input', () => {
211
- const schema = installPlugins({}, [
212
- {
213
- subscriber: createSubscriber({
214
- name: 'analytics',
215
- description: 'Analytics subscriber',
216
- callback: async () => { },
217
- }),
218
- },
219
- ]);
220
- expect(Object.keys(schema)).toHaveLength(0);
221
- });
222
- it('should not modify original schema', () => {
223
- const sub1 = createSubscriber({
224
- name: 'user-handler',
225
- description: 'Handles user events',
226
- callback: async () => { },
227
- });
228
- const globalSub = createSubscriber({
229
- name: 'analytics',
230
- description: 'Analytics subscriber',
231
- callback: async () => { },
232
- });
233
- const baseSchema = {
234
- [UserCreatedEvent.key]: [UserCreatedEvent, [sub1]],
235
- };
236
- installPlugins(baseSchema, [{ subscriber: globalSub }]);
237
- // Original schema should be unchanged
238
- const entry = baseSchema[UserCreatedEvent.key];
239
- const [, subs] = entry;
240
- expect(subs).toHaveLength(1);
241
- });
242
- });
@@ -1,80 +0,0 @@
1
- import type { HasDescription } from '../errors/index.js';
2
- import type { DeadLetterConfig, QueueDefinition, RetryConfig, Topology } from './types.js';
3
- /**
4
- * Options for adding a queue.
5
- * Excludes 'name' as that is provided as the first argument to addQueue.
6
- */
7
- export type QueueOptions = Omit<QueueDefinition, 'name'>;
8
- /**
9
- * Error thrown when topology validation fails.
10
- */
11
- export declare class TopologyValidationError extends Error implements HasDescription {
12
- readonly issues: readonly string[];
13
- readonly description: string;
14
- constructor(message: string, issues: readonly string[]);
15
- }
16
- /**
17
- * Fluent builder for creating Topology configurations.
18
- */
19
- export declare class TopologyBuilder {
20
- /**
21
- * Creates a new TopologyBuilder instance.
22
- */
23
- static create(): TopologyBuilder;
24
- private namespace;
25
- private queues;
26
- private deadLetter;
27
- private retry;
28
- /**
29
- * Sets the namespace prefix for all queues.
30
- */
31
- withNamespace(namespace: string): this;
32
- /**
33
- * Adds a queue to the topology.
34
- * @param definition - A complete QueueDefinition object
35
- */
36
- addQueue(definition: QueueDefinition): this;
37
- /**
38
- * Adds a queue to the topology.
39
- * @param name - Queue name
40
- * @param options - Queue options
41
- */
42
- addQueue(name: string, options?: QueueOptions): this;
43
- /**
44
- * Alias for addQueue().
45
- * @param definition - A complete QueueDefinition object
46
- */
47
- queue(definition: QueueDefinition): this;
48
- /**
49
- * Alias for addQueue().
50
- * @param name - Queue name
51
- * @param options - Queue options
52
- */
53
- queue(name: string, options?: QueueOptions): this;
54
- /**
55
- * Configures dead-letter queue settings.
56
- */
57
- withDeadLetter(config: Partial<DeadLetterConfig>): this;
58
- /**
59
- * Configures retry settings.
60
- */
61
- withRetry(config: Partial<RetryConfig>): this;
62
- /**
63
- * Disables retry functionality.
64
- */
65
- withoutRetry(): this;
66
- /**
67
- * Disables dead-letter queues.
68
- */
69
- withoutDeadLetter(): this;
70
- /**
71
- * Validates the topology configuration.
72
- */
73
- validate(): readonly string[];
74
- /**
75
- * Builds the topology configuration.
76
- * @throws TopologyValidationError if validation fails
77
- */
78
- build(): Topology;
79
- }
80
- //# sourceMappingURL=builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/topology/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,QAAQ,EACT,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAWzD;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAM,YAAW,cAAc;aASxD,MAAM,EAAE,SAAS,MAAM,EAAE;IAR3C,QAAQ,CAAC,WAAW,SAIuC;gBAGzD,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,SAAS,MAAM,EAAE;CAK5C;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,MAAM,IAAI,eAAe;IAIhC,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,UAAU,CAGhB;IACF,OAAO,CAAC,KAAK,CAIX;IAEF;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKtC;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI;IAapD;;;OAGG;IACH,KAAK,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI;IACxC;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI;IAWjD;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI;IAQvD;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAS7C;;OAEG;IACH,YAAY,IAAI,IAAI;IAKpB;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAQzB;;OAEG;IACH,QAAQ,IAAI,SAAS,MAAM,EAAE;IAuD7B;;;OAGG;IACH,KAAK,IAAI,QAAQ;CAgBlB"}
@@ -1,165 +0,0 @@
1
- /**
2
- * Type guard to check if the argument is a QueueDefinition object.
3
- */
4
- function isQueueDefinition(arg) {
5
- return typeof arg === 'object' && arg !== null && 'name' in arg;
6
- }
7
- /**
8
- * Error thrown when topology validation fails.
9
- */
10
- export class TopologyValidationError extends Error {
11
- issues;
12
- description = 'The topology configuration is invalid. Check the issues array for ' +
13
- 'specific validation failures such as missing namespace, invalid queue ' +
14
- 'names, or conflicting settings. This error occurs during Matador ' +
15
- 'initialization and must be fixed in the configuration.';
16
- constructor(message, issues) {
17
- super(message);
18
- this.issues = issues;
19
- this.name = 'TopologyValidationError';
20
- }
21
- }
22
- /**
23
- * Fluent builder for creating Topology configurations.
24
- */
25
- export class TopologyBuilder {
26
- /**
27
- * Creates a new TopologyBuilder instance.
28
- */
29
- static create() {
30
- return new TopologyBuilder();
31
- }
32
- namespace = '';
33
- queues = [];
34
- deadLetter = {
35
- unhandled: { enabled: true },
36
- undeliverable: { enabled: true },
37
- };
38
- retry = {
39
- enabled: true,
40
- defaultDelayMs: 1000,
41
- maxDelayMs: 300000, // 5 minutes
42
- };
43
- /**
44
- * Sets the namespace prefix for all queues.
45
- */
46
- withNamespace(namespace) {
47
- this.namespace = namespace;
48
- return this;
49
- }
50
- addQueue(nameOrDefinition, options = {}) {
51
- if (isQueueDefinition(nameOrDefinition)) {
52
- this.queues.push(nameOrDefinition);
53
- }
54
- else {
55
- this.queues.push({ name: nameOrDefinition, ...options });
56
- }
57
- return this;
58
- }
59
- queue(nameOrDefinition, options = {}) {
60
- if (isQueueDefinition(nameOrDefinition)) {
61
- return this.addQueue(nameOrDefinition);
62
- }
63
- return this.addQueue(nameOrDefinition, options);
64
- }
65
- /**
66
- * Configures dead-letter queue settings.
67
- */
68
- withDeadLetter(config) {
69
- this.deadLetter = {
70
- unhandled: config.unhandled ?? this.deadLetter.unhandled,
71
- undeliverable: config.undeliverable ?? this.deadLetter.undeliverable,
72
- };
73
- return this;
74
- }
75
- /**
76
- * Configures retry settings.
77
- */
78
- withRetry(config) {
79
- this.retry = {
80
- enabled: config.enabled ?? this.retry.enabled,
81
- defaultDelayMs: config.defaultDelayMs ?? this.retry.defaultDelayMs,
82
- maxDelayMs: config.maxDelayMs ?? this.retry.maxDelayMs,
83
- };
84
- return this;
85
- }
86
- /**
87
- * Disables retry functionality.
88
- */
89
- withoutRetry() {
90
- this.retry = { ...this.retry, enabled: false };
91
- return this;
92
- }
93
- /**
94
- * Disables dead-letter queues.
95
- */
96
- withoutDeadLetter() {
97
- this.deadLetter = {
98
- unhandled: { enabled: false },
99
- undeliverable: { enabled: false },
100
- };
101
- return this;
102
- }
103
- /**
104
- * Validates the topology configuration.
105
- */
106
- validate() {
107
- const issues = [];
108
- if (!this.namespace || this.namespace.trim() === '') {
109
- issues.push('Namespace is required');
110
- }
111
- else if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(this.namespace)) {
112
- issues.push('Namespace must start with a letter and contain only alphanumeric characters, underscores, and hyphens');
113
- }
114
- if (this.queues.length === 0) {
115
- issues.push('At least one queue is required');
116
- }
117
- const queueNames = new Set();
118
- for (const queue of this.queues) {
119
- if (!queue.name || queue.name.trim() === '') {
120
- issues.push('Queue name cannot be empty');
121
- }
122
- else if (!queue.exact && !/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(queue.name)) {
123
- // Skip pattern validation for exact queues (allows names like 'matador.shared.id-platform')
124
- issues.push(`Queue name "${queue.name}" must start with a letter and contain only alphanumeric characters, underscores, and hyphens`);
125
- }
126
- else if (queueNames.has(queue.name)) {
127
- issues.push(`Duplicate queue name: "${queue.name}"`);
128
- }
129
- else {
130
- queueNames.add(queue.name);
131
- }
132
- if (queue.concurrency !== undefined && queue.concurrency < 1) {
133
- issues.push(`Queue "${queue.name}" concurrency must be at least 1`);
134
- }
135
- if (queue.consumerTimeout !== undefined && queue.consumerTimeout < 0) {
136
- issues.push(`Queue "${queue.name}" consumer timeout must be non-negative`);
137
- }
138
- }
139
- if (this.retry.enabled) {
140
- if (this.retry.defaultDelayMs < 0) {
141
- issues.push('Default retry delay must be non-negative');
142
- }
143
- if (this.retry.maxDelayMs < this.retry.defaultDelayMs) {
144
- issues.push('Max retry delay must be greater than or equal to default delay');
145
- }
146
- }
147
- return issues;
148
- }
149
- /**
150
- * Builds the topology configuration.
151
- * @throws TopologyValidationError if validation fails
152
- */
153
- build() {
154
- const issues = this.validate();
155
- if (issues.length > 0) {
156
- throw new TopologyValidationError(`Invalid topology: ${issues.join('; ')}`, issues);
157
- }
158
- return {
159
- namespace: this.namespace,
160
- queues: [...this.queues],
161
- deadLetter: this.deadLetter,
162
- retry: this.retry,
163
- };
164
- }
165
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=builder.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"builder.test.d.ts","sourceRoot":"","sources":["../../src/topology/builder.test.ts"],"names":[],"mappings":""}