dt-common-device 7.3.0 → 7.4.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.
@@ -5,6 +5,7 @@ export declare function getConfig(): IConfig;
5
5
  export declare function getDeviceServiceUrl(): string;
6
6
  export declare function getAdminServiceUrl(): string;
7
7
  export declare function getSqsQueueUrl(): string;
8
+ export declare function getReservationSqsQueueUrl(): string;
8
9
  export declare function getEventSubscription(): InternalEventSubscription | null;
9
10
  export declare function checkRequiredEnv(requiredEnvs: string[]): void;
10
11
  export declare function ensureAuditInitialized(): void;
@@ -8,6 +8,7 @@ exports.getConfig = getConfig;
8
8
  exports.getDeviceServiceUrl = getDeviceServiceUrl;
9
9
  exports.getAdminServiceUrl = getAdminServiceUrl;
10
10
  exports.getSqsQueueUrl = getSqsQueueUrl;
11
+ exports.getReservationSqsQueueUrl = getReservationSqsQueueUrl;
11
12
  exports.getEventSubscription = getEventSubscription;
12
13
  exports.checkRequiredEnv = checkRequiredEnv;
13
14
  exports.ensureAuditInitialized = ensureAuditInitialized;
@@ -149,6 +150,17 @@ function getSqsQueueUrl() {
149
150
  }
150
151
  throw new Error("dt-common-device: AWS_SQS_URL is not configured for this service");
151
152
  }
153
+ function getReservationSqsQueueUrl() {
154
+ if (constants_1.CONFIG_KEYS[sourceKey].env.includes("RESERVATION_SQS_URL")) {
155
+ const reservationSqsQueueUrl = process.env.RESERVATION_SQS_URL;
156
+ if (!reservationSqsQueueUrl) {
157
+ getConfig().LOGGER.error("RESERVATION_SQS_URL must be set in environment variables");
158
+ throw new Error("dt-common-device: RESERVATION_SQS_URL must be set in environment variables");
159
+ }
160
+ return reservationSqsQueueUrl;
161
+ }
162
+ return "";
163
+ }
152
164
  function getEventSubscription() {
153
165
  return eventSubscription;
154
166
  }
@@ -17,7 +17,13 @@ exports.REQUIRED = {
17
17
  };
18
18
  exports.CONFIG_KEYS = {
19
19
  ACCESS: {
20
- env: ["ADMIN_DB_URI", "PMS_DB_URI", "AWS_SQS_URL", "ADMIN_SERVICE"],
20
+ env: [
21
+ "ADMIN_DB_URI",
22
+ "PMS_DB_URI",
23
+ "AWS_SQS_URL",
24
+ "RESERVATION_SQS_URL",
25
+ "ADMIN_SERVICE",
26
+ ],
21
27
  INTERNAL_EVENT_HANDLER: true,
22
28
  db_keys: {
23
29
  access: "DATABASE_URL",
@@ -9,6 +9,7 @@ export declare enum InternalEventType {
9
9
  export declare class InternalEventSubscription {
10
10
  private readonly internalEventHandler;
11
11
  private readonly sqsQueueUrl;
12
+ private readonly reservationSqsQueueUrl;
12
13
  private readonly logger;
13
14
  private readonly isInitialized;
14
15
  private isSubscribed;
@@ -18,6 +18,7 @@ class InternalEventSubscription {
18
18
  this.isInitialized = false;
19
19
  this.isSubscribed = false;
20
20
  this.sqsQueueUrl = (0, config_1.getSqsQueueUrl)() || "";
21
+ this.reservationSqsQueueUrl = (0, config_1.getReservationSqsQueueUrl)() || "";
21
22
  this.logger = (0, config_1.getConfig)().LOGGER;
22
23
  this.isInitialized = true;
23
24
  }
@@ -85,6 +86,9 @@ class InternalEventSubscription {
85
86
  return;
86
87
  }
87
88
  try {
89
+ if (this.reservationSqsQueueUrl) {
90
+ await dt_pub_sub_1.eventDispatcher.subscribeToQueue(this.reservationSqsQueueUrl, this.handleMessage.bind(this));
91
+ }
88
92
  await dt_pub_sub_1.eventDispatcher.subscribeToQueue(this.sqsQueueUrl, this.handleMessage.bind(this));
89
93
  this.isSubscribed = true;
90
94
  this.logger.info("Successfully subscribed to internal events", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "7.3.0",
3
+ "version": "7.4.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [