@zdavison/matador 2.0.2 → 2.0.4

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 (55) hide show
  1. package/dist/core/matador.d.ts +2 -2
  2. package/dist/core/matador.d.ts.map +1 -1
  3. package/dist/core/matador.js +6 -0
  4. package/dist/index.cjs +80 -32
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +3 -3
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/pipeline/pipeline.d.ts +4 -1
  12. package/dist/pipeline/pipeline.d.ts.map +1 -1
  13. package/dist/pipeline/pipeline.js +16 -4
  14. package/dist/pipeline/pipeline.test.js +15 -1
  15. package/dist/topology/builder.d.ts +14 -0
  16. package/dist/topology/builder.d.ts.map +1 -1
  17. package/dist/topology/builder.js +20 -11
  18. package/dist/topology/builder.test.js +138 -0
  19. package/dist/topology/index.d.ts +2 -2
  20. package/dist/topology/index.d.ts.map +1 -1
  21. package/dist/topology/index.js +1 -1
  22. package/dist/topology/types.d.ts +53 -1
  23. package/dist/topology/types.d.ts.map +1 -1
  24. package/dist/topology/types.js +10 -0
  25. package/dist/transport/local/local-transport.d.ts.map +1 -1
  26. package/dist/transport/rabbitmq/rabbitmq-transport.d.ts +8 -0
  27. package/dist/transport/rabbitmq/rabbitmq-transport.d.ts.map +1 -1
  28. package/dist/transport/rabbitmq/rabbitmq-transport.js +42 -22
  29. package/dist/transport/rabbitmq/rabbitmq-transport.test.d.ts +2 -0
  30. package/dist/transport/rabbitmq/rabbitmq-transport.test.d.ts.map +1 -0
  31. package/dist/transport/rabbitmq/rabbitmq-transport.test.js +98 -0
  32. package/dist/types/dispatcher.d.ts +14 -0
  33. package/dist/types/dispatcher.d.ts.map +1 -0
  34. package/dist/types/dispatcher.js +1 -0
  35. package/dist/types/index.d.ts +2 -1
  36. package/dist/types/index.d.ts.map +1 -1
  37. package/dist/types/subscriber.d.ts +20 -4
  38. package/dist/types/subscriber.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/src/core/matador.ts +14 -1
  41. package/src/index.ts +9 -0
  42. package/src/pipeline/pipeline.test.ts +24 -2
  43. package/src/pipeline/pipeline.ts +28 -6
  44. package/src/topology/builder.test.ts +176 -0
  45. package/src/topology/builder.ts +44 -5
  46. package/src/topology/index.ts +4 -0
  47. package/src/topology/types.ts +75 -1
  48. package/src/transport/local/local-transport.ts +4 -1
  49. package/src/transport/rabbitmq/rabbitmq-transport.test.ts +118 -0
  50. package/src/transport/rabbitmq/rabbitmq-transport.ts +48 -25
  51. package/src/types/dispatcher.ts +18 -0
  52. package/src/types/index.ts +4 -0
  53. package/src/types/subscriber.ts +22 -3
  54. package/test/e2e/rabbitmq-transport.e2e.test.ts +287 -0
  55. package/tsconfig.tsbuildinfo +1 -1
@@ -5,7 +5,7 @@ import type { RetryPolicy } from '../retry/index.js';
5
5
  import type { MatadorSchema } from '../schema/index.js';
6
6
  import type { Topology } from '../topology/index.js';
7
7
  import type { Transport } from '../transport/index.js';
8
- import type { AnySubscriber, Event, EventClass, EventOptions } from '../types/index.js';
8
+ import type { AnySubscriber, Dispatcher, Event, EventClass, EventOptions } from '../types/index.js';
9
9
  import type { SendResult } from './fanout.js';
10
10
  import type { HandlersState, ShutdownConfig } from './shutdown.js';
11
11
  /**
@@ -44,7 +44,7 @@ export interface MatadorConfig {
44
44
  * - Fanout: Event sending
45
45
  * - Shutdown: Graceful termination
46
46
  */
47
- export declare class Matador {
47
+ export declare class Matador implements Dispatcher {
48
48
  private readonly transport;
49
49
  private readonly topology;
50
50
  private readonly schema;
@@ -1 +1 @@
1
- {"version":3,"file":"matador.d.ts","sourceRoot":"","sources":["../../src/core/matador.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM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,CAAC,CAAC,EACzB,IAAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,UAAU,CAAC;IAChB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;IAkC3E;;OAEG;IACH,gBAAgB,IAAI,aAAa;IAIjC;;OAEG;IACH,MAAM,IAAI,OAAO;IAIjB;;OAEG;IACG,WAAW,CAAC,SAAS,SAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAatD;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B;;OAEG;IACH,WAAW,IAAI,OAAO;YAIR,aAAa;CAM5B"}
@@ -56,6 +56,7 @@ export class Matador {
56
56
  retryPolicy: this.retryPolicy,
57
57
  hooks: this.hooks,
58
58
  checkpointStore: config.checkpointStore,
59
+ dispatcher: this,
59
60
  });
60
61
  // Create fanout engine
61
62
  const defaultQueue = this.topology.queues[0]?.name ?? 'default';
@@ -124,10 +125,15 @@ export class Matador {
124
125
  throw new InvalidSchemaError('Schema validation failed', errors.map((e) => e.message).join(', '));
125
126
  }
126
127
  // Connect transport
128
+ this.hooks.logger.info(`[Matador] ⏳ Starting backend '${this.transport.name}'...`);
127
129
  await this.transport.connect();
130
+ this.hooks.logger.info(`[Matador] 🟢 Backend '${this.transport.name}' started.`);
128
131
  // Apply topology
129
132
  await this.transport.applyTopology(this.topology);
130
133
  // Subscribe to queues
134
+ if (this.consumeFrom.length > 0) {
135
+ this.hooks.logger.info(`[Matador] 🟢 Worker subscribing to '${this.consumeFrom.join(',')}'.`);
136
+ }
131
137
  for (const queueName of this.consumeFrom) {
132
138
  const qualifiedName = getQualifiedQueueName(this.topology.namespace, queueName);
133
139
  const queueDef = this.topology.queues.find((q) => q.name === queueName);
package/dist/index.cjs CHANGED
@@ -330,8 +330,17 @@ function getDeadLetterQueueName(namespace, queueName, dlqType) {
330
330
  function getRetryQueueName(namespace, queueName) {
331
331
  return `${namespace}.${queueName}.retry`;
332
332
  }
333
+ function resolveQueueName(namespace, queueDef) {
334
+ if (queueDef.exact) {
335
+ return queueDef.name;
336
+ }
337
+ return `${namespace}.${queueDef.name}`;
338
+ }
333
339
 
334
340
  // src/topology/builder.ts
341
+ function isQueueDefinition(arg) {
342
+ return typeof arg === "object" && arg !== null && "name" in arg;
343
+ }
335
344
  var TopologyValidationError = class extends Error {
336
345
  constructor(message, issues) {
337
346
  super(message);
@@ -366,18 +375,19 @@ var TopologyBuilder = class _TopologyBuilder {
366
375
  this.namespace = namespace;
367
376
  return this;
368
377
  }
369
- /**
370
- * Adds a queue to the topology.
371
- */
372
- addQueue(name, options = {}) {
373
- this.queues.push({ name, ...options });
378
+ addQueue(nameOrDefinition, options = {}) {
379
+ if (isQueueDefinition(nameOrDefinition)) {
380
+ this.queues.push(nameOrDefinition);
381
+ } else {
382
+ this.queues.push({ name: nameOrDefinition, ...options });
383
+ }
374
384
  return this;
375
385
  }
376
- /**
377
- * Alias for addQueue().
378
- */
379
- queue(name, options = {}) {
380
- return this.addQueue(name, options);
386
+ queue(nameOrDefinition, options = {}) {
387
+ if (isQueueDefinition(nameOrDefinition)) {
388
+ return this.addQueue(nameOrDefinition);
389
+ }
390
+ return this.addQueue(nameOrDefinition, options);
381
391
  }
382
392
  /**
383
393
  * Configures dead-letter queue settings.
@@ -436,7 +446,7 @@ var TopologyBuilder = class _TopologyBuilder {
436
446
  for (const queue of this.queues) {
437
447
  if (!queue.name || queue.name.trim() === "") {
438
448
  issues.push("Queue name cannot be empty");
439
- } else if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(queue.name)) {
449
+ } else if (!queue.exact && !/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(queue.name)) {
440
450
  issues.push(
441
451
  `Queue name "${queue.name}" must start with a letter and contain only alphanumeric characters, underscores, and hyphens`
442
452
  );
@@ -1402,6 +1412,7 @@ var ProcessingPipeline = class {
1402
1412
  retryPolicy;
1403
1413
  hooks;
1404
1414
  checkpointStore;
1415
+ dispatcher;
1405
1416
  constructor(config) {
1406
1417
  this.transport = config.transport;
1407
1418
  this.schema = config.schema;
@@ -1409,6 +1420,7 @@ var ProcessingPipeline = class {
1409
1420
  this.retryPolicy = config.retryPolicy;
1410
1421
  this.hooks = config.hooks;
1411
1422
  this.checkpointStore = config.checkpointStore ?? new NoOpCheckpointStore();
1423
+ this.dispatcher = config.dispatcher;
1412
1424
  }
1413
1425
  /**
1414
1426
  * Processes a raw message from the transport.
@@ -1495,15 +1507,23 @@ var ProcessingPipeline = class {
1495
1507
  }
1496
1508
  });
1497
1509
  }
1510
+ const callbackContext = { matador: this.dispatcher };
1498
1511
  await this.hooks.onWorkerWrap(envelope, subscriberDef, async () => {
1499
1512
  await this.hooks.onWorkerBeforeProcess(envelope, subscriberDef);
1500
1513
  try {
1501
1514
  if (isResumable && context) {
1502
1515
  const resumableCallback = subscriber.callback;
1503
- result = await resumableCallback(envelope, context);
1516
+ const fullContext = {
1517
+ io: context.io.bind(context),
1518
+ all: context.all.bind(context),
1519
+ attempt: context.attempt,
1520
+ isRetry: context.isRetry,
1521
+ matador: this.dispatcher
1522
+ };
1523
+ result = await resumableCallback(envelope, fullContext);
1504
1524
  } else {
1505
1525
  const standardCallback = subscriber.callback;
1506
- result = await standardCallback(envelope);
1526
+ result = await standardCallback(envelope, callbackContext);
1507
1527
  }
1508
1528
  } catch (e) {
1509
1529
  error = e instanceof Error ? e : new Error(String(e));
@@ -1936,7 +1956,8 @@ var Matador = class {
1936
1956
  codec: this.codec,
1937
1957
  retryPolicy: this.retryPolicy,
1938
1958
  hooks: this.hooks,
1939
- checkpointStore: config.checkpointStore
1959
+ checkpointStore: config.checkpointStore,
1960
+ dispatcher: this
1940
1961
  });
1941
1962
  const defaultQueue = this.topology.queues[0]?.name ?? "default";
1942
1963
  this.fanout = new FanoutEngine({
@@ -2005,8 +2026,19 @@ var Matador = class {
2005
2026
  errors.map((e) => e.message).join(", ")
2006
2027
  );
2007
2028
  }
2029
+ this.hooks.logger.info(
2030
+ `[Matador] \u23F3 Starting backend '${this.transport.name}'...`
2031
+ );
2008
2032
  await this.transport.connect();
2033
+ this.hooks.logger.info(
2034
+ `[Matador] \u{1F7E2} Backend '${this.transport.name}' started.`
2035
+ );
2009
2036
  await this.transport.applyTopology(this.topology);
2037
+ if (this.consumeFrom.length > 0) {
2038
+ this.hooks.logger.info(
2039
+ `[Matador] \u{1F7E2} Worker subscribing to '${this.consumeFrom.join(",")}'.`
2040
+ );
2041
+ }
2010
2042
  for (const queueName of this.consumeFrom) {
2011
2043
  const qualifiedName = getQualifiedQueueName(
2012
2044
  this.topology.namespace,
@@ -2350,7 +2382,10 @@ var LocalTransport = class {
2350
2382
  try {
2351
2383
  await sub.handler(message.envelope, receipt);
2352
2384
  } catch (error) {
2353
- this.logger.error("[Matador] \u{1F534} Handler error in message processing", error);
2385
+ this.logger.error(
2386
+ "[Matador] \u{1F534} Handler error in message processing",
2387
+ error
2388
+ );
2354
2389
  }
2355
2390
  }
2356
2391
  }
@@ -2600,6 +2635,10 @@ var MultiTransport = class {
2600
2635
  throw new Error("Transport does not support dead letter routing");
2601
2636
  }
2602
2637
  };
2638
+ function redactAmqpUrl(url) {
2639
+ const regex = /^(amqps?:\/\/)[^:]+:[^@]+@/;
2640
+ return url.replace(regex, "$1****:****@");
2641
+ }
2603
2642
  var RabbitMQTransport = class {
2604
2643
  name = "rabbitmq";
2605
2644
  _capabilities = {
@@ -2856,6 +2895,9 @@ var RabbitMQTransport = class {
2856
2895
  return queueChannel;
2857
2896
  }
2858
2897
  async doConnect() {
2898
+ this.logger.info(
2899
+ `[Matador] \u23F3 Connecting to RabbitMQ at '${redactAmqpUrl(this.config.url)}'.`
2900
+ );
2859
2901
  const connection = await amqplib__default.default.connect(this.config.url);
2860
2902
  this.connection = connection;
2861
2903
  connection.on("error", (err) => {
@@ -2961,24 +3003,29 @@ var RabbitMQTransport = class {
2961
3003
  }
2962
3004
  async assertWorkQueue(channel, topology, queueDef) {
2963
3005
  const queueName = queueDef.exact ? queueDef.name : `${topology.namespace}.${queueDef.name}`;
2964
- const queueOptions = {
2965
- durable: true,
2966
- arguments: {}
2967
- };
2968
- if (this.config.quorumQueues && !queueDef.exact) {
2969
- queueOptions.arguments["x-queue-type"] = "quorum";
2970
- }
2971
- const dlxExchange = this.getDLXExchangeName(topology.namespace);
2972
- if (topology.deadLetter.unhandled.enabled || topology.deadLetter.undeliverable.enabled) {
2973
- queueOptions.arguments["x-dead-letter-exchange"] = dlxExchange;
2974
- }
2975
- if (queueDef.priorities) {
2976
- queueOptions.arguments["x-max-priority"] = 10;
2977
- }
2978
- if (queueDef.consumerTimeout) {
2979
- queueOptions.arguments["x-consumer-timeout"] = queueDef.consumerTimeout;
3006
+ const rabbitmqOptions = queueDef.transport?.rabbitmq?.options;
3007
+ if (rabbitmqOptions) {
3008
+ await channel.assertQueue(queueName, rabbitmqOptions);
3009
+ } else {
3010
+ const queueOptions = {
3011
+ durable: true,
3012
+ arguments: {}
3013
+ };
3014
+ if (this.config.quorumQueues && !queueDef.exact) {
3015
+ queueOptions.arguments["x-queue-type"] = "quorum";
3016
+ }
3017
+ const dlxExchange = this.getDLXExchangeName(topology.namespace);
3018
+ if (topology.deadLetter.unhandled.enabled || topology.deadLetter.undeliverable.enabled) {
3019
+ queueOptions.arguments["x-dead-letter-exchange"] = dlxExchange;
3020
+ }
3021
+ if (queueDef.priorities) {
3022
+ queueOptions.arguments["x-max-priority"] = 10;
3023
+ }
3024
+ if (queueDef.consumerTimeout) {
3025
+ queueOptions.arguments["x-consumer-timeout"] = queueDef.consumerTimeout;
3026
+ }
3027
+ await channel.assertQueue(queueName, queueOptions);
2980
3028
  }
2981
- await channel.assertQueue(queueName, queueOptions);
2982
3029
  const mainExchange = this.getMainExchangeName(topology.namespace);
2983
3030
  await channel.bindQueue(queueName, mainExchange, queueName);
2984
3031
  if (this.delayedExchangeAvailable) {
@@ -3149,6 +3196,7 @@ exports.isSubscriber = isSubscriber;
3149
3196
  exports.isSubscriberNotRegisteredError = isSubscriberNotRegisteredError;
3150
3197
  exports.isSubscriberStub = isSubscriberStub;
3151
3198
  exports.isTransportNotConnectedError = isTransportNotConnectedError;
3199
+ exports.resolveQueueName = resolveQueueName;
3152
3200
  exports.supportsDelayedMessages = supportsDelayedMessages;
3153
3201
  exports.supportsDeliveryMode = supportsDeliveryMode;
3154
3202
  exports.validResult = validResult;