@diia-inhouse/diia-queue 14.0.31 → 14.1.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.
@@ -8,7 +8,7 @@ import { AmqpAsserter } from "./amqpAsserter.js";
8
8
  import { AmqpConnection } from "./amqpConnection.js";
9
9
  import { AmqpListener } from "./amqpListener.js";
10
10
  import { AmqpPublisher } from "./amqpPublisher.js";
11
- import _ from "lodash";
11
+ import lodash from "lodash";
12
12
  import { randomUUID } from "node:crypto";
13
13
  import { EventEmitter } from "node:events";
14
14
  //#region src/providers/rabbitmq/index.ts
@@ -112,7 +112,7 @@ var RabbitMQProvider = class extends EventEmitter {
112
112
  };
113
113
  }
114
114
  async makeAMQPConnection(client) {
115
- return new AmqpConnection(this.rabbitmqConfig.connection, this.logger, this.rabbitmqConfig.reconnectOptions, _.merge({ clientProperties: { connectionClientType: client } }, this.rabbitmqConfig.socketOptions));
115
+ return new AmqpConnection(this.rabbitmqConfig.connection, this.logger, this.rabbitmqConfig.reconnectOptions, lodash.merge({ clientProperties: { connectionClientType: client } }, this.rabbitmqConfig.socketOptions));
116
116
  }
117
117
  async makeAMQPListener(queuesOptions) {
118
118
  return new AmqpListener(await this.getConnection("listener"), this.logger, this.rabbitMQMetricsService, queuesOptions, this.systemServiceName);
@@ -25,14 +25,15 @@ var EventBus = class extends Communicator {
25
25
  getProducerExchangesOptions() {
26
26
  if (!this.queueName) return [];
27
27
  const { rabbit: { declareOptions: { assertExchanges } = {} } } = this.queueProvider.getConfig();
28
- const exchangeNames = this.optionsBuilder.getExchangeNamesByQueueName(this.queueName);
29
- const exchangesOptions = [];
30
- for (const exchangeName of exchangeNames) exchangesOptions.push({
31
- name: exchangeName,
28
+ const globalExchangeNames = this.optionsBuilder.getExchangeNamesByQueueName(this.queueName);
29
+ const globalExchangesOptions = [];
30
+ for (const globalExchangeName of globalExchangeNames) globalExchangesOptions.push({
31
+ name: globalExchangeName,
32
32
  declare: assertExchanges,
33
33
  type: "topic"
34
34
  });
35
- return exchangesOptions;
35
+ const { exchangesOptions: messageBrokerServiceConfigExchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
36
+ return [...globalExchangesOptions, ...messageBrokerServiceConfigExchangesOptions];
36
37
  }
37
38
  getMulticastListeners() {
38
39
  if (!this.queueName || this.eventListenerList.length === 0) return [];
@@ -1,5 +1,5 @@
1
1
  import { collectEventBusListeners } from "../utils.js";
2
- import _ from "lodash";
2
+ import lodash from "lodash";
3
3
  //#region src/services/eventCommunicator.ts
4
4
  var EventCommunicator = class {
5
5
  logger;
@@ -18,8 +18,10 @@ var EventCommunicator = class {
18
18
  const listeners = [];
19
19
  for (const queueOptions of queuesOptions) {
20
20
  const { name: queueName } = queueOptions;
21
+ const eventNames = this.defineEventNamesByQueueName(queueName, eventQueueMap);
22
+ if (!this.listenerList.some(({ queueNames = [], event }) => queueNames.includes(queueName) || eventNames.includes(event))) continue;
21
23
  const listener = {
22
- eventNames: this.defineEventNamesByQueueName(queueName, eventQueueMap),
24
+ eventNames,
23
25
  queueOptions,
24
26
  exchangesOptions,
25
27
  handler: eventsHandler
@@ -31,8 +33,8 @@ var EventCommunicator = class {
31
33
  getUnicastListeners() {
32
34
  const listeners = [];
33
35
  const { queuesOptions, exchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
34
- const queuesOptionsMap = _.keyBy(queuesOptions, "name");
35
- const exchangesOptionsMap = _.keyBy(exchangesOptions, "name");
36
+ const queuesOptionsMap = lodash.keyBy(queuesOptions, "name");
37
+ const exchangesOptionsMap = lodash.keyBy(exchangesOptions, "name");
36
38
  for (const eventListener of this.listenerList) {
37
39
  const { queueNames = [] } = eventListener;
38
40
  for (const queueName of queueNames) {
@@ -64,8 +64,9 @@ var ExternalEventBus = class ExternalEventBus extends Communicator {
64
64
  return `${this.exchangePrefixName}${topic}`;
65
65
  }
66
66
  getProducerExchangesOptions() {
67
- const [exchangesOptions] = this.defineQueuesAndExchangesOptionsBasedOnGlobalConfig();
68
- return exchangesOptions;
67
+ const [globalExchangesOptions] = this.defineQueuesAndExchangesOptionsBasedOnGlobalConfig();
68
+ const { exchangesOptions: messageBrokerServiceConfigExchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
69
+ return [...globalExchangesOptions, ...messageBrokerServiceConfigExchangesOptions];
69
70
  }
70
71
  getMulticastListeners() {
71
72
  const [exchangesOptions, queuesOptions] = this.defineQueuesAndExchangesOptionsBasedOnGlobalConfig();
@@ -38,20 +38,21 @@ var ScheduledTask = class extends Communicator {
38
38
  return this.eventCommunicator.getMulticastListeners([queueOptions], exchangesOptions);
39
39
  }
40
40
  getProducerExchangesOptions() {
41
- const exchangesOptions = [];
41
+ const globalExchangesOptions = [];
42
42
  const { topics = {}, rabbit: { declareOptions: { assertExchanges } = {} } } = this.queueProvider.getConfig();
43
43
  const createExchangeOptions = (exchangeName) => ({
44
44
  name: exchangeName,
45
45
  type: "topic",
46
46
  declare: assertExchanges
47
47
  });
48
- const exchangeNamesByQueueName = this.optionsBuilder.getExchangeNamesByQueueName(this.queueName);
49
- const exchangeNamesSet = new Set([...Object.keys(topics), ...exchangeNamesByQueueName]);
50
- for (const exchangeName of exchangeNamesSet) {
51
- const exchangeOptions = createExchangeOptions(exchangeName);
52
- exchangesOptions.push(exchangeOptions);
48
+ const globalExchangeNamesByQueueName = this.optionsBuilder.getExchangeNamesByQueueName(this.queueName);
49
+ const globalExchangeNamesSet = new Set([...Object.keys(topics), ...globalExchangeNamesByQueueName]);
50
+ for (const globalExchangeName of globalExchangeNamesSet) {
51
+ const exchangeOptions = createExchangeOptions(globalExchangeName);
52
+ globalExchangesOptions.push(exchangeOptions);
53
53
  }
54
- return exchangesOptions;
54
+ const { exchangesOptions: messageBrokerServiceConfigExchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
55
+ return [...globalExchangesOptions, ...messageBrokerServiceConfigExchangesOptions];
55
56
  }
56
57
  getRoutingKey(serviceName) {
57
58
  return `${serviceName}.${this.eventRoutingPart}`;
@@ -2,7 +2,7 @@ import { QueueTypes } from "../interfaces/messageBrokerServiceConfig.js";
2
2
  import "../interfaces/index.js";
3
3
  import constants_default from "../constants.js";
4
4
  import Communicator from "./communicator.js";
5
- import _ from "lodash";
5
+ import lodash from "lodash";
6
6
  //#region src/services/task.ts
7
7
  var Task = class extends Communicator {
8
8
  serviceName;
@@ -18,8 +18,8 @@ var Task = class extends Communicator {
18
18
  }
19
19
  async onInit() {
20
20
  const { queuesOptions, exchangesOptions } = await this.init();
21
- const queuesOptionsMap = _.keyBy(queuesOptions, "name");
22
- const exchangesOptionsMap = _.keyBy(exchangesOptions, "name");
21
+ const queuesOptionsMap = lodash.keyBy(queuesOptions, "name");
22
+ const exchangesOptionsMap = lodash.keyBy(exchangesOptions, "name");
23
23
  for (const task of this.taskList) {
24
24
  const { name: taskName, isDelayed = false, queueNames = [] } = task;
25
25
  if (queueNames.length === 0) {
@@ -69,8 +69,8 @@ var Task = class extends Communicator {
69
69
  getUnicastListeners() {
70
70
  const listeners = [];
71
71
  const { queuesOptions, exchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
72
- const queuesOptionsMap = _.keyBy(queuesOptions, "name");
73
- const exchangesOptionsMap = _.keyBy(exchangesOptions, "name");
72
+ const queuesOptionsMap = lodash.keyBy(queuesOptions, "name");
73
+ const exchangesOptionsMap = lodash.keyBy(exchangesOptions, "name");
74
74
  for (const task of this.taskList) {
75
75
  const { queueNames = [], name: taskName, isDelayed = false } = task;
76
76
  if (queueNames.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diia-inhouse/diia-queue",
3
- "version": "14.0.31",
3
+ "version": "14.1.0",
4
4
  "type": "module",
5
5
  "description": "Package provide queue functionality",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "scripts": {
25
25
  "build": "rimraf dist/ && tsdown",
26
- "build-watch": "tsdown --watch",
26
+ "build:watch": "tsdown --watch",
27
27
  "lint": "oxlint && oxfmt --check .",
28
28
  "lint-fix": "oxlint --fix && oxfmt .",
29
29
  "lint:lockfile": "lockfile-lint --path package-lock.json --allowed-hosts registry.npmjs.org --validate-https",