@diia-inhouse/diia-queue 14.0.31 → 14.1.1

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);
@@ -135,14 +135,14 @@ var Communicator = class {
135
135
  unifyServiceConfig(listeners, implicitExchangesOptions = []) {
136
136
  const queuesMap = /* @__PURE__ */ new Map();
137
137
  const exchangesMap = /* @__PURE__ */ new Map();
138
+ const { queuesOptions, exchangesOptions: explicitExchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
139
+ for (const exchangeOpts of [...explicitExchangesOptions, ...implicitExchangesOptions]) if (!exchangesMap.has(exchangeOpts.name)) exchangesMap.set(exchangeOpts.name, exchangeOpts);
138
140
  for (const listener of listeners) {
139
141
  const { queueOptions, exchangesOptions } = listener;
140
142
  queuesMap.set(queueOptions.name, queueOptions);
141
- for (const exchangeOptions of exchangesOptions) exchangesMap.set(exchangeOptions.name, exchangeOptions);
143
+ for (const exchangeOptions of exchangesOptions) if (!exchangesMap.has(exchangeOptions.name)) exchangesMap.set(exchangeOptions.name, exchangeOptions);
142
144
  }
143
- const { queuesOptions, exchangesOptions: explicitExchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
144
145
  for (const queueOpts of queuesOptions) if (!queuesMap.has(queueOpts.name)) queuesMap.set(queueOpts.name, queueOpts);
145
- for (const exchangeOpts of [...explicitExchangesOptions, ...implicitExchangesOptions]) if (!exchangesMap.has(exchangeOpts.name)) exchangesMap.set(exchangeOpts.name, exchangeOpts);
146
146
  return {
147
147
  queuesOptions: [...queuesMap.values()],
148
148
  exchangesOptions: [...exchangesMap.values()]
@@ -30,7 +30,8 @@ var EventBus = class extends Communicator {
30
30
  for (const exchangeName of exchangeNames) exchangesOptions.push({
31
31
  name: exchangeName,
32
32
  declare: assertExchanges,
33
- type: "topic"
33
+ type: "topic",
34
+ bindTo: []
34
35
  });
35
36
  return exchangesOptions;
36
37
  }
@@ -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) {
@@ -122,7 +122,8 @@ var ExternalEventBus = class ExternalEventBus extends Communicator {
122
122
  const exchangeOptions = {
123
123
  name: exchangeName,
124
124
  type: "topic",
125
- declare: assertExchanges
125
+ declare: assertExchanges,
126
+ bindTo: []
126
127
  };
127
128
  exchangesMap.set(exchangeName, exchangeOptions);
128
129
  }
@@ -43,7 +43,8 @@ var ScheduledTask = class extends Communicator {
43
43
  const createExchangeOptions = (exchangeName) => ({
44
44
  name: exchangeName,
45
45
  type: "topic",
46
- declare: assertExchanges
46
+ declare: assertExchanges,
47
+ bindTo: []
47
48
  });
48
49
  const exchangeNamesByQueueName = this.optionsBuilder.getExchangeNamesByQueueName(this.queueName);
49
50
  const exchangeNamesSet = new Set([...Object.keys(topics), ...exchangeNamesByQueueName]);
@@ -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.1",
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",