dt-common-device 13.8.2 → 14.0.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.
Files changed (42) hide show
  1. package/dist/Integrations/twilio/twilio.service.d.ts +2 -1
  2. package/dist/Integrations/twilio/twilio.service.js +20 -16
  3. package/dist/alerts/alert.types.d.ts +1 -5
  4. package/dist/alerts/alert.types.js +0 -4
  5. package/dist/audit/AuditUtils.js +0 -11
  6. package/dist/audit/PushAudit.d.ts +0 -5
  7. package/dist/audit/PushAudit.js +9 -24
  8. package/dist/config/config.d.ts +0 -1
  9. package/dist/config/config.js +35 -11
  10. package/dist/config/constants.js +0 -1
  11. package/dist/constants/ConnectionProviders.d.ts +0 -1
  12. package/dist/constants/ConnectionProviders.js +0 -1
  13. package/dist/constants/Event.d.ts +0 -12
  14. package/dist/constants/Event.js +0 -12
  15. package/dist/copilotQueue/utils/queueManager.js +35 -2
  16. package/dist/emails/emailService.js +41 -23
  17. package/dist/entities/admin/Admin.repository.d.ts +2 -11
  18. package/dist/entities/admin/Admin.repository.js +2 -73
  19. package/dist/entities/admin/Admin.service.d.ts +1 -2
  20. package/dist/entities/admin/Admin.service.js +0 -9
  21. package/dist/entities/admin/IAdmin.d.ts +0 -40
  22. package/dist/entities/connection/Connection.repository.js +4 -12
  23. package/dist/entities/connection/IConnection.d.ts +1 -2
  24. package/dist/entities/connection/IConnection.js +0 -1
  25. package/dist/entities/device/local/interfaces/IDevice.d.ts +0 -6
  26. package/dist/entities/device/local/repository/Device.repository.d.ts +0 -7
  27. package/dist/entities/device/local/repository/Device.repository.js +0 -11
  28. package/dist/entities/device/local/services/Device.service.d.ts +0 -8
  29. package/dist/entities/device/local/services/Device.service.js +0 -21
  30. package/dist/entities/pms/pms.service.js +11 -22
  31. package/dist/entities/property/Property.repository.d.ts +0 -1
  32. package/dist/entities/property/Property.repository.js +0 -5
  33. package/dist/entities/property/Property.service.d.ts +0 -1
  34. package/dist/entities/property/Property.service.js +0 -6
  35. package/dist/index.d.ts +0 -1
  36. package/dist/index.js +0 -2
  37. package/dist/issues/issue.types.d.ts +2 -5
  38. package/dist/issues/issue.types.js +0 -4
  39. package/dist/utils/http.utils.d.ts +1 -3
  40. package/dist/utils/http.utils.js +0 -8
  41. package/dist/webhookQueue/services/WebhookQueueService.js +36 -3
  42. package/package.json +2 -3
@@ -1,6 +1,7 @@
1
1
  import { ISendSMSRequest } from "./interface/twilioInterface";
2
2
  export declare class TwilioService {
3
- private readonly notificationService;
3
+ private readonly connectionRepository;
4
+ private readonly propertyRepository;
4
5
  constructor();
5
6
  sendSMS(data: ISendSMSRequest): Promise<any>;
6
7
  }
@@ -76,8 +76,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
76
76
  Object.defineProperty(exports, "__esModule", { value: true });
77
77
  exports.TwilioService = void 0;
78
78
  const typedi_1 = __importStar(require("typedi"));
79
- const Notification_service_1 = require("../../entities/notification/Notification.service");
79
+ const Connection_repository_1 = require("../../entities/connection/Connection.repository");
80
+ const IConnection_1 = require("../../entities/connection/IConnection");
80
81
  const twilio_1 = __importDefault(require("twilio"));
82
+ const Property_repository_1 = require("../../entities/property/Property.repository");
81
83
  let TwilioService = (() => {
82
84
  let _classDecorators = [(0, typedi_1.Service)()];
83
85
  let _classDescriptor;
@@ -85,35 +87,37 @@ let TwilioService = (() => {
85
87
  let _classThis;
86
88
  var TwilioService = _classThis = class {
87
89
  constructor() {
88
- this.notificationService = typedi_1.default.get(Notification_service_1.NotificationService);
90
+ this.connectionRepository = typedi_1.default.get(Connection_repository_1.ConnectionRepository);
91
+ this.propertyRepository = typedi_1.default.get(Property_repository_1.PropertyRepository);
89
92
  }
90
93
  // -----------------------------
91
94
  // Send SMS
92
95
  // -----------------------------
93
96
  async sendSMS(data) {
94
97
  const { propertyId, message, toNumber } = data;
95
- if (!propertyId) {
96
- throw new Error("Property ID is required for sending SMS");
97
- }
98
98
  if (!toNumber) {
99
99
  throw new Error("To number is required for sending SMS");
100
100
  }
101
- const connection = await this.notificationService.queryConnections({
101
+ //find fromNumber from the dt_connections table based on the propertyId
102
+ const response = await this.connectionRepository.queryConnections({
102
103
  propertyId,
103
- connectionProvider: "twilio",
104
- isEnable: true,
104
+ connectionProvider: IConnection_1.ConnectionProvider.Twilio,
105
105
  });
106
- if (!connection) {
107
- throw new Error("Twilio connection not found for this property");
108
- }
109
- const { clientId, clientSecret, metaData } = connection;
110
- if (!clientId || !clientSecret) {
111
- throw new Error("Twilio credentials (clientId, clientSecret) not found");
112
- }
106
+ //need connectionId, clientSecret, metaData
107
+ const { clientId, clientSecret, metaData } = response[0];
113
108
  const fromNumber = metaData?.fromNumber;
114
- if (!fromNumber || typeof fromNumber !== "string") {
109
+ if (!fromNumber) {
115
110
  throw new Error("From number not found");
116
111
  }
112
+ //find toNumber and sms_enabled from the property settings table based on the propertyId
113
+ const _settingsRes = await this.propertyRepository.getPropertyPreferences(propertyId);
114
+ if (!_settingsRes) {
115
+ throw new Error("Property settings not found");
116
+ }
117
+ const smsEnabled = _settingsRes?.settings?.notificationPreferences?.smsNotification?.enabled;
118
+ if (!smsEnabled) {
119
+ throw new Error("SMS notifications are not enabled for this property");
120
+ }
117
121
  //TODO: Need to do single tone pattern for the client
118
122
  const client = (0, twilio_1.default)(clientId, clientSecret);
119
123
  try {
@@ -26,9 +26,7 @@ export declare enum AlertType {
26
26
  DEVICE_ONLINE = "DEVICE_ONLINE",
27
27
  ZONE_NOT_MAPPED_TO_ACCESS_GROUP = "ZONE_NOT_MAPPED_TO_ACCESS_GROUP",
28
28
  INCORRECT_CODE_USED = "INCORRECT_CODE_USED",
29
- RESERVATION_INACTIVE_ACCESSGROUP = "RESERVATION_INACTIVE_ACCESSGROUP",
30
- ACCESS_GROUP_CREATED = "ACCESS_GROUP_CREATED",
31
- ACCESS_GROUP_UPDATED = "ACCESS_GROUP_UPDATED"
29
+ RESERVATION_INACTIVE_ACCESSGROUP = "RESERVATION_INACTIVE_ACCESSGROUP"
32
30
  }
33
31
  export declare const AlertDescriptions: {
34
32
  ACCOUNT_NEW_DEVICE: string;
@@ -46,8 +44,6 @@ export declare const AlertDescriptions: {
46
44
  ZONE_NOT_MAPPED_TO_ACCESS_GROUP: string;
47
45
  INCORRECT_CODE_USED: string;
48
46
  RESERVATION_INACTIVE_ACCESSGROUP: string;
49
- ACCESS_GROUP_CREATED: string;
50
- ACCESS_GROUP_UPDATED: string;
51
47
  };
52
48
  export interface AlertDocument {
53
49
  _id: string;
@@ -32,8 +32,6 @@ var AlertType;
32
32
  AlertType["ZONE_NOT_MAPPED_TO_ACCESS_GROUP"] = "ZONE_NOT_MAPPED_TO_ACCESS_GROUP";
33
33
  AlertType["INCORRECT_CODE_USED"] = "INCORRECT_CODE_USED";
34
34
  AlertType["RESERVATION_INACTIVE_ACCESSGROUP"] = "RESERVATION_INACTIVE_ACCESSGROUP";
35
- AlertType["ACCESS_GROUP_CREATED"] = "ACCESS_GROUP_CREATED";
36
- AlertType["ACCESS_GROUP_UPDATED"] = "ACCESS_GROUP_UPDATED";
37
35
  })(AlertType || (exports.AlertType = AlertType = {}));
38
36
  exports.AlertDescriptions = {
39
37
  [AlertType.ACCOUNT_NEW_DEVICE]: "The alert is raised when system detects a new device in the device cloud account.",
@@ -51,8 +49,6 @@ exports.AlertDescriptions = {
51
49
  [AlertType.ZONE_NOT_MAPPED_TO_ACCESS_GROUP]: "The alert is raised when a zone is not mapped to an access group.",
52
50
  [AlertType.INCORRECT_CODE_USED]: "The alert is raised when user uses the incorrect code on the device.",
53
51
  [AlertType.RESERVATION_INACTIVE_ACCESSGROUP]: "The alert is raised when a reservation is received for an inactive access group.",
54
- [AlertType.ACCESS_GROUP_CREATED]: "The alert is raised when an access group is created for the pms system.",
55
- [AlertType.ACCESS_GROUP_UPDATED]: "The alert is raised when an access group is updated for the pms system."
56
52
  };
57
53
  // Re-export EntityType from issue.types.ts to avoid duplication
58
54
  var issue_types_1 = require("../issues/issue.types");
@@ -79,7 +79,6 @@ const typedi_1 = __importStar(require("typedi"));
79
79
  const pms_1 = require("../entities/pms");
80
80
  const admin_1 = require("../entities/admin");
81
81
  const config_1 = require("../config/config");
82
- const class_validator_1 = require("class-validator");
83
82
  let AuditUtils = (() => {
84
83
  let _classDecorators = [(0, typedi_1.Service)()];
85
84
  let _classDescriptor;
@@ -224,8 +223,6 @@ let AuditUtils = (() => {
224
223
  }
225
224
  async getPropertyName(propertyId) {
226
225
  try {
227
- if (!(0, class_validator_1.isUUID)(propertyId))
228
- return "property_not_found";
229
226
  return await this.getCachedEntityData("property", propertyId, async () => {
230
227
  const property = await typedi_1.default.get(property_1.LocalPropertyService).getProperty(propertyId);
231
228
  return property?.name || "property_not_found";
@@ -257,8 +254,6 @@ let AuditUtils = (() => {
257
254
  }
258
255
  async getUserName(userId) {
259
256
  try {
260
- if (!(0, class_validator_1.isUUID)(userId))
261
- return "user_not_found";
262
257
  return await this.getCachedEntityData("user", userId, async () => {
263
258
  const user = await typedi_1.default.get(admin_1.AdminService).getUser(userId);
264
259
  if (!user)
@@ -273,8 +268,6 @@ let AuditUtils = (() => {
273
268
  }
274
269
  async getGuestName(guestId) {
275
270
  try {
276
- if (!(0, class_validator_1.isUUID)(guestId))
277
- return "Guest User";
278
271
  return await this.getCachedEntityData("guest", guestId, async () => {
279
272
  const guest = await typedi_1.default.get(pms_1.PmsService).getGuest(guestId);
280
273
  if (!guest)
@@ -303,8 +296,6 @@ let AuditUtils = (() => {
303
296
  }
304
297
  async getZoneName(zoneId) {
305
298
  try {
306
- if (!(0, class_validator_1.isUUID)(zoneId))
307
- return "zone_not_found";
308
299
  return await this.getCachedEntityData("zone", zoneId, async () => {
309
300
  const zone = await typedi_1.default.get(admin_1.AdminService).getZone(zoneId);
310
301
  if (!zone)
@@ -319,8 +310,6 @@ let AuditUtils = (() => {
319
310
  }
320
311
  async getAccessGroupName(accessGroupId) {
321
312
  try {
322
- if (!(0, class_validator_1.isUUID)(accessGroupId))
323
- return "access_group_not_found";
324
313
  return await this.getCachedEntityData("accessGroup", accessGroupId, async () => {
325
314
  const accessGroup = await typedi_1.default.get(admin_1.AdminService).getAccessGroup(accessGroupId);
326
315
  if (!accessGroup)
@@ -1,9 +1,4 @@
1
1
  import { IAuditProperties } from "./IAuditProperties";
2
- /**
3
- * Publishes an audit event. Failures are logged and swallowed so callers can
4
- * fire-and-forget without causing unhandled promise rejections when the audit
5
- * pipeline returns 5xx or times out (see e.g. Sentry DT-PMS-C).
6
- */
7
2
  export declare function pushAudit(data: {
8
3
  auditType: string;
9
4
  auditData: IAuditProperties;
@@ -5,31 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.pushAudit = pushAudit;
7
7
  const dt_audit_library_1 = require("dt-audit-library");
8
- const config_1 = require("../config/config");
9
8
  const AuditUtils_1 = require("./AuditUtils");
10
9
  const typedi_1 = __importDefault(require("typedi"));
11
- /**
12
- * Publishes an audit event. Failures are logged and swallowed so callers can
13
- * fire-and-forget without causing unhandled promise rejections when the audit
14
- * pipeline returns 5xx or times out (see e.g. Sentry DT-PMS-C).
15
- */
16
10
  async function pushAudit(data) {
17
- try {
18
- const audit = await typedi_1.default.get(AuditUtils_1.AuditUtils).buildAuditProperties(data.auditData);
19
- await (0, dt_audit_library_1.publishAudit)({
20
- eventType: data.auditType,
21
- properties: {
22
- ...audit,
23
- timestamp: new Date().toISOString(),
24
- env_type: process.env.NODE_ENV,
25
- },
26
- });
27
- }
28
- catch (err) {
29
- const status = err?.response?.status;
30
- const code = err?.code;
31
- (0, config_1.getLogger)().error(`pushAudit failed for ${data.auditType}: ${err?.message ?? err}`, status != null || code != null
32
- ? { auditType: data.auditType, status, code }
33
- : { auditType: data.auditType });
34
- }
11
+ const audit = await typedi_1.default.get(AuditUtils_1.AuditUtils).buildAuditProperties(data.auditData);
12
+ await (0, dt_audit_library_1.publishAudit)({
13
+ eventType: data.auditType,
14
+ properties: {
15
+ ...audit,
16
+ timestamp: new Date().toISOString(),
17
+ env_type: process.env.NODE_ENV,
18
+ },
19
+ });
35
20
  }
@@ -5,7 +5,6 @@ export declare function getConfig(): IConfig;
5
5
  export declare function getDeviceServiceUrl(): string;
6
6
  export declare function getAdminServiceUrl(): string;
7
7
  export declare function getMonitoringServiceUrl(): string;
8
- export declare function getNotificationServiceUrl(): string;
9
8
  export declare function getSqsQueueUrl(): string;
10
9
  export declare function getReservationSqsQueueUrl(): string;
11
10
  export declare function getHeartbeatSqsQueueUrl(): string;
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -8,7 +41,6 @@ exports.getConfig = getConfig;
8
41
  exports.getDeviceServiceUrl = getDeviceServiceUrl;
9
42
  exports.getAdminServiceUrl = getAdminServiceUrl;
10
43
  exports.getMonitoringServiceUrl = getMonitoringServiceUrl;
11
- exports.getNotificationServiceUrl = getNotificationServiceUrl;
12
44
  exports.getSqsQueueUrl = getSqsQueueUrl;
13
45
  exports.getReservationSqsQueueUrl = getReservationSqsQueueUrl;
14
46
  exports.getHeartbeatSqsQueueUrl = getHeartbeatSqsQueueUrl;
@@ -30,7 +62,6 @@ const db_1 = require("../db/db");
30
62
  const dotenv_1 = __importDefault(require("dotenv"));
31
63
  const events_1 = require("../events");
32
64
  const constants_1 = require("./constants");
33
- const notificationQueue_1 = require("../notificationQueue");
34
65
  dotenv_1.default.config();
35
66
  let config = null;
36
67
  let auditInitialized = false;
@@ -163,14 +194,6 @@ function getMonitoringServiceUrl() {
163
194
  }
164
195
  return monitoringServiceUrl;
165
196
  }
166
- function getNotificationServiceUrl() {
167
- const notificationServiceUrl = process.env.NOTIFICATION_SERVICE;
168
- if (!notificationServiceUrl) {
169
- getConfig().LOGGER.error("NOTIFICATION_SERVICE must be set in environment variables");
170
- throw new Error("dt-common-device: NOTIFICATION_SERVICE must be set in environment variables");
171
- }
172
- return notificationServiceUrl;
173
- }
174
197
  function getSqsQueueUrl() {
175
198
  if (constants_1.CONFIG_KEYS[sourceKey].env.includes("AWS_SQS_URL")) {
176
199
  const sqsQueueUrl = process.env.AWS_SQS_URL;
@@ -329,7 +352,8 @@ async function shutdown() {
329
352
  }
330
353
  // Close notification queue connections
331
354
  try {
332
- await (0, notificationQueue_1.closeNotificationQueue)();
355
+ const { closeNotificationQueue } = await Promise.resolve().then(() => __importStar(require("../notificationQueue/queue.service")));
356
+ await closeNotificationQueue();
333
357
  }
334
358
  catch (error) {
335
359
  getConfig().LOGGER.error("Failed to close notification queue", { error });
@@ -85,7 +85,6 @@ exports.CONFIG_KEYS = {
85
85
  "ADMIN_DB_URI",
86
86
  "ACCESS_DB_URI",
87
87
  "AWS_SQS_URL",
88
- "ADMIN_SERVICE",
89
88
  "HEARTBEAT_SQS_URL",
90
89
  "CRONICLE_ENDPOINT",
91
90
  "CRONICLE_API_KEY",
@@ -22,5 +22,4 @@ export declare const CONNECTION_PROVIDERS: {
22
22
  readonly SIFELY: "Sifely";
23
23
  readonly CHECKFRONT: "Checkfront";
24
24
  readonly TWILIO: "Twilio";
25
- readonly DAIKIN: "Daikin";
26
25
  };
@@ -28,5 +28,4 @@ exports.CONNECTION_PROVIDERS = {
28
28
  SIFELY: "Sifely",
29
29
  CHECKFRONT: "Checkfront",
30
30
  TWILIO: "Twilio",
31
- DAIKIN: "Daikin",
32
31
  };
@@ -73,10 +73,6 @@ export declare const DT_EVENT_TYPES: {
73
73
  UNPROCESSED: string;
74
74
  UNHANDLED: string;
75
75
  };
76
- MAINTENANCE_MODE: {
77
- ENABLED: string;
78
- DISABLED: string;
79
- };
80
76
  };
81
77
  CONNECTION: {
82
78
  CREATE: {
@@ -144,10 +140,6 @@ export declare const DT_EVENT_TYPES: {
144
140
  SUCCESS: string;
145
141
  FAILED: string;
146
142
  };
147
- MAINTENANCE_MODE: {
148
- ENABLED: string;
149
- DISABLED: string;
150
- };
151
143
  };
152
144
  ZONE: {
153
145
  CREATE: {
@@ -165,10 +157,6 @@ export declare const DT_EVENT_TYPES: {
165
157
  SUCCESS: string;
166
158
  FAILED: string;
167
159
  };
168
- MAINTENANCE_MODE: {
169
- ENABLED: string;
170
- DISABLED: string;
171
- };
172
160
  };
173
161
  ISSUE: {
174
162
  CREATE: {
@@ -76,10 +76,6 @@ exports.DT_EVENT_TYPES = {
76
76
  UNPROCESSED: "device.webhook.unprocessed",
77
77
  UNHANDLED: "device.webhook.unhandled",
78
78
  },
79
- MAINTENANCE_MODE: {
80
- ENABLED: "device.maintenance_mode.enabled",
81
- DISABLED: "device.maintenance_mode.disabled",
82
- },
83
79
  },
84
80
  CONNECTION: {
85
81
  CREATE: {
@@ -147,10 +143,6 @@ exports.DT_EVENT_TYPES = {
147
143
  SUCCESS: "accessgroup.delete.success",
148
144
  FAILED: "accessgroup.delete.failed",
149
145
  },
150
- MAINTENANCE_MODE: {
151
- ENABLED: "access_group.maintenance_mode.enabled",
152
- DISABLED: "access_group.maintenance_mode.disabled",
153
- },
154
146
  },
155
147
  ZONE: {
156
148
  CREATE: {
@@ -168,10 +160,6 @@ exports.DT_EVENT_TYPES = {
168
160
  SUCCESS: "zone.delete.success",
169
161
  FAILED: "zone.delete.failed",
170
162
  },
171
- MAINTENANCE_MODE: {
172
- ENABLED: "zone.maintenance_mode.enabled",
173
- DISABLED: "zone.maintenance_mode.disabled",
174
- },
175
163
  },
176
164
  ISSUE: {
177
165
  CREATE: {
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.QueueManager = void 0;
4
37
  const redis_1 = require("../../db/redis");
@@ -11,7 +44,7 @@ class QueueManager {
11
44
  if (queues.has(queueKey)) {
12
45
  return queues.get(queueKey);
13
46
  }
14
- const { Queue } = await import("bullmq");
47
+ const { Queue } = await Promise.resolve().then(() => __importStar(require("bullmq")));
15
48
  const queue = new Queue(queueKey, {
16
49
  connection: (0, redis_1.getRedisClient)(),
17
50
  });
@@ -25,7 +58,7 @@ class QueueManager {
25
58
  if (workers.has(queueKey)) {
26
59
  return workers.get(queueKey);
27
60
  }
28
- const { Worker } = await import("bullmq");
61
+ const { Worker } = await Promise.resolve().then(() => __importStar(require("bullmq")));
29
62
  const worker = new Worker(queueKey, processor, {
30
63
  connection: (0, redis_1.getRedisClient)(),
31
64
  concurrency: 1, // Process one job at a time for FIFO ordering
@@ -236,43 +236,61 @@ let EmailService = (() => {
236
236
  else {
237
237
  imageURL = `https://api-sandbox-new.devicethread.com/dt-logo.png`;
238
238
  }
239
- const fromEmail = typeof mailData.fromEmail === "string" ? mailData.fromEmail.trim() : "";
239
+ const CONTACT_US_DETAILS = (0, Email_1.getContactUsDetails)();
240
+ const from = CONTACT_US_DETAILS?.FROM_EMAIL_ADDRESS;
241
+ if (!process.env.AWS_ACCESS_KEY_ID ||
242
+ !process.env.AWS_SECRET_ACCESS_KEY) {
243
+ throw new Error("AWS credentials are not set");
244
+ }
245
+ // Section below is replacing the global variables from template like contact us email, phone and current year.
240
246
  const currentYear = new Date().getFullYear().toString();
241
- const finalMessage = message
247
+ // const logo: any = await GetLogo(ctx);
248
+ let finalMessage = message
242
249
  .replaceAll("{{year}}", currentYear)
243
- .replaceAll("{{contactUsEmail}}", fromEmail)
250
+ .replaceAll("{{contactUsPhone}}", `${CONTACT_US_DETAILS?.PHONE}`)
251
+ .replaceAll("{{contactUsEmail}}", `${CONTACT_US_DETAILS?.TO_EMAIL_ADDRESS}`)
244
252
  .replaceAll("{{logo}}", `${imageURL}`);
245
- (0, config_1.getLogger)().info(`sending email (SES) with params: ${JSON.stringify(toAddr)}`);
246
- if (ccAddr && Array.isArray(ccAddr) && ccAddr.length > 0) {
247
- (0, config_1.getLogger)().info(`CC addresses: ${JSON.stringify(ccAddr)}`);
248
- }
249
- mailData.from = fromEmail;
250
- if (pdfBuffer) {
251
- return;
252
- }
253
- await this.sesClient.send(new client_ses_1.SendEmailCommand({
254
- Source: fromEmail,
253
+ // .replaceAll('{{logo}}', `${logo}`);
254
+ //
255
+ const params = {
255
256
  Destination: {
256
257
  ToAddresses: toAddr,
257
- ...(ccAddr && Array.isArray(ccAddr) && ccAddr.length > 0
258
- ? {
259
- CcAddresses: ccAddr.filter((e) => typeof e === "string" && e.trim()),
260
- }
261
- : {}),
262
258
  },
263
259
  Message: {
264
- Subject: { Data: subject, Charset: "UTF-8" },
265
260
  Body: {
266
- Html: { Data: finalMessage, Charset: "UTF-8" },
261
+ Html: {
262
+ Charset: "UTF-8",
263
+ Data: finalMessage,
264
+ },
265
+ },
266
+ Subject: {
267
+ Charset: "UTF-8",
268
+ Data: subject,
267
269
  },
268
270
  },
269
- ...(fromEmail ? { ReplyToAddresses: [fromEmail] } : {}),
270
- }));
271
+ Source: from, // SENDER_ADDRESS
272
+ ReplyToAddresses: [CONTACT_US_DETAILS?.TO_EMAIL_ADDRESS],
273
+ };
274
+ // Add CC addresses if present
275
+ if (ccAddr && Array.isArray(ccAddr) && ccAddr.length > 0) {
276
+ params.Destination.CcAddresses = ccAddr;
277
+ }
278
+ (0, config_1.getLogger)().info(`sending email with params: ${JSON.stringify(toAddr)}`);
279
+ if (ccAddr && ccAddr.length > 0) {
280
+ (0, config_1.getLogger)().info(`CC addresses: ${JSON.stringify(ccAddr)}`);
281
+ }
282
+ mailData.from = CONTACT_US_DETAILS?.FROM_EMAIL_ADDRESS;
283
+ if (pdfBuffer) {
284
+ // this.sendEmailWithAttachments(this.sesClient, mailData, finalMessage, pdfBuffer)
285
+ }
286
+ else {
287
+ await this.sesClient.send(new client_ses_1.SendEmailCommand(params));
288
+ }
271
289
  const maskedEmailsList = toAddr.map((email) => (0, Email_1.GetMaskedEmail)(email));
272
290
  (0, config_1.getLogger)().info(`Sending email to: ${maskedEmailsList.join(", ")}`);
273
291
  }
274
292
  catch (error) {
275
- (0, config_1.getLogger)().error("sendMail: Error", JSON.stringify(error));
293
+ (0, config_1.getLogger)().error("sendMail: Error", error);
276
294
  }
277
295
  }
278
296
  };
@@ -1,20 +1,11 @@
1
- import { IAccessGroup, IDeliverableLocksByAccessGroupResult, IUser, IZone, IZoneAccessGroup, ILocksAndZonesByAccessGroup } from "./IAdmin";
1
+ import { IAccessGroup, IUser, IZone, IZoneAccessGroup } from "./IAdmin";
2
2
  export declare class AdminRepository {
3
3
  private readonly deviceRepository;
4
4
  private readonly postgres;
5
5
  private readonly localDeviceService;
6
6
  private readonly redisUtils;
7
7
  constructor();
8
- /**
9
- * Raw zones + devices for access groups (all non-HUB devices). Used when callers need the full list (e.g. UI).
10
- */
11
- private loadCollectionZonesDevicesByAccessGroupIds;
12
- getZonesByAccessGroupIds(accessGroupIds: string[], propertyId: string): Promise<ILocksAndZonesByAccessGroup[]>;
13
- /**
14
- * ZN-2: same data as {@link getZonesByAccessGroupIds}, but `devices` are only LOCKs that are not
15
- * under maintenance (zone or device). `maintenanceSkips` is structured data for audit emission.
16
- */
17
- getDeliverableLockDevicesByAccessGroupIds(accessGroupIds: string[], propertyId: string): Promise<IDeliverableLocksByAccessGroupResult>;
8
+ getZonesByAccessGroupIds(accessGroupIds: string[], propertyId: string): Promise<any[]>;
18
9
  getZonesByAccessGroups(accessGroupIds: string[], type?: string[]): Promise<any[]>;
19
10
  getAccessGroup(accessGroupId: string, propertyId?: string): Promise<IAccessGroup | null>;
20
11
  getZoneAccessGroupByZoneId(zoneId: string): Promise<IZoneAccessGroup[] | null>;
@@ -91,13 +91,7 @@ let AdminRepository = (() => {
91
91
  this.localDeviceService = typedi_1.default.get(services_1.LocalDeviceService);
92
92
  this.redisUtils = typedi_1.default.get(utils_1.RedisUtils);
93
93
  }
94
- /**
95
- * Raw zones + devices for access groups (all non-HUB devices). Used when callers need the full list (e.g. UI).
96
- */
97
- async loadCollectionZonesDevicesByAccessGroupIds(accessGroupIds, propertyId) {
98
- if (!accessGroupIds?.length) {
99
- return [];
100
- }
94
+ async getZonesByAccessGroupIds(accessGroupIds, propertyId) {
101
95
  // If not cached, get the result from the database
102
96
  const result = await this.postgres.query(`SELECT
103
97
  "zc"."id" AS "zoneCollectionMapId",
@@ -106,8 +100,7 @@ let AdminRepository = (() => {
106
100
  "z"."id" AS "zoneId",
107
101
  "z"."name" AS "zoneName",
108
102
  "z"."zoneTypeId",
109
- "zt"."name" AS "zoneTypeName",
110
- "z"."isUnderMaintenance"
103
+ "zt"."name" AS "zoneTypeName"
111
104
  FROM "dt_zones_collection_map" AS "zc"
112
105
  INNER JOIN "dt_zones" AS "z" ON "zc"."zoneId" = "z"."id"
113
106
  LEFT JOIN "dt_zoneTypes" AS "zt" ON "z"."zoneTypeId" = "zt"."id"
@@ -178,14 +171,6 @@ let AdminRepository = (() => {
178
171
  zoneIds: _zoneIds,
179
172
  excludeDeviceType: interfaces_1.DeviceType.HUB,
180
173
  });
181
- // Fetch isUnderMaintenance for ALL zone IDs (including child zones not in the collection map)
182
- const allCollectionIds = collectionZone.map((e) => e.collectionId);
183
- const [allZoneMaintenanceResult, collectionMaintenanceResult] = await Promise.all([
184
- this.postgres.query(`SELECT "id", "isUnderMaintenance" FROM "dt_zones" WHERE "id" = ANY($1)`, [_zoneIds]),
185
- this.postgres.query(`SELECT "id", "isUnderMaintenance" FROM "dt_collections" WHERE "id" = ANY($1)`, [allCollectionIds]),
186
- ]);
187
- const zoneMaintenanceMap = new Map(allZoneMaintenanceResult.rows.map((r) => [r.id, r.isUnderMaintenance ?? false]));
188
- const collectionMaintenanceMap = new Map(collectionMaintenanceResult.rows.map((r) => [r.id, r.isUnderMaintenance ?? false]));
189
174
  const _collectionZone = collectionZone.map((e) => {
190
175
  const zones = e.zoneIds;
191
176
  let devices = [];
@@ -199,21 +184,18 @@ let AdminRepository = (() => {
199
184
  const _devices = devices.concat(device);
200
185
  devices = _devices;
201
186
  // Create zone data for each zone
202
- // Use zoneMaintenanceMap for isUnderMaintenance so child zones are also covered
203
187
  const zoneInfo = response.find((r) => r.zoneId === element);
204
188
  const zoneData = {
205
189
  zoneId: element,
206
190
  deviceIds: device?.map((d) => d.deviceId), // Get first device ID if available
207
191
  zoneName: zoneInfo?.zoneName || "",
208
192
  zoneType: zoneInfo?.zoneTypeName || null,
209
- isUnderMaintenance: zoneMaintenanceMap.get(element) ?? false,
210
193
  };
211
194
  zonesData.push(zoneData);
212
195
  });
213
196
  e.devices = devices;
214
197
  e.zones = zonesData;
215
198
  e.parentZone = response;
216
- e.isUnderMaintenance = collectionMaintenanceMap.get(e.collectionId) ?? false;
217
199
  return e;
218
200
  });
219
201
  const collectionZoneDevices = Array.from(new Set(_collectionZone));
@@ -225,59 +207,6 @@ let AdminRepository = (() => {
225
207
  // );
226
208
  return collectionZoneDevices;
227
209
  }
228
- async getZonesByAccessGroupIds(accessGroupIds, propertyId) {
229
- return await this.loadCollectionZonesDevicesByAccessGroupIds(accessGroupIds, propertyId);
230
- }
231
- /**
232
- * ZN-2: same data as {@link getZonesByAccessGroupIds}, but `devices` are only LOCKs that are not
233
- * under maintenance (zone or device). `maintenanceSkips` is structured data for audit emission.
234
- */
235
- async getDeliverableLockDevicesByAccessGroupIds(accessGroupIds, propertyId) {
236
- if (!accessGroupIds?.length) {
237
- return { collections: [], maintenanceSkips: [] };
238
- }
239
- const raw = await this.loadCollectionZonesDevicesByAccessGroupIds(accessGroupIds, propertyId);
240
- const maintenanceSkips = [];
241
- const collections = raw.map((cz) => {
242
- const inactiveIds = new Set();
243
- for (const zone of cz.zones || []) {
244
- if (zone.isUnderMaintenance) {
245
- (zone.deviceIds || []).forEach((id) => {
246
- if (id != null && id !== "")
247
- inactiveIds.add(String(id));
248
- });
249
- maintenanceSkips.push({
250
- accessGroupId: cz.collectionId,
251
- zoneId: zone.zoneId,
252
- deviceIds: (zone.deviceIds || [])
253
- .map((x) => String(x))
254
- .filter((x) => x !== ""),
255
- reason: "zone inactive",
256
- });
257
- }
258
- }
259
- for (const dev of cz.devices || []) {
260
- if (dev.deviceType?.type !== "LOCK" || !dev.isUnderMaintenance) {
261
- continue;
262
- }
263
- const did = String(dev.deviceId);
264
- if (inactiveIds.has(did)) {
265
- continue;
266
- }
267
- inactiveIds.add(did);
268
- maintenanceSkips.push({
269
- accessGroupId: cz.collectionId,
270
- zoneId: dev.zoneId,
271
- deviceIds: [did],
272
- reason: "device under maintenance",
273
- });
274
- }
275
- const deliverableDevices = (cz.devices || []).filter((d) => d.deviceType?.type === "LOCK" &&
276
- !inactiveIds.has(String(d.deviceId)));
277
- return { ...cz, devices: deliverableDevices, skippedDevices: cz.devices.filter((device) => device.deviceType?.type === "LOCK" && inactiveIds.has(String(device.deviceId))) };
278
- });
279
- return { collections, maintenanceSkips };
280
- }
281
210
  async getZonesByAccessGroups(accessGroupIds, type) {
282
211
  // Fetch zone IDs associated with these access groups
283
212
  const zonesIdsQuery = `
@@ -3,8 +3,7 @@ export declare class AdminService {
3
3
  private readonly adminRepository;
4
4
  private readonly redisUtils;
5
5
  constructor();
6
- getZonesByAccessGroupIds(accessGroupIds: string[], propertyId: string): Promise<import("./IAdmin").ILocksAndZonesByAccessGroup[]>;
7
- getDeliverableLockDevicesByAccessGroupIds(accessGroupIds: string[], propertyId: string): Promise<import("./IAdmin").IDeliverableLocksByAccessGroupResult>;
6
+ getZonesByAccessGroupIds(accessGroupIds: string[], propertyId: string): Promise<any[]>;
8
7
  getZonesByAccessGroups(accessGroupIds: string[], type?: string[]): Promise<any[]>;
9
8
  getAccessGroup(accessGroupId: string, propertyId?: string): Promise<IAccessGroup | null>;
10
9
  getAccessGroupByZoneId(zoneId: string): Promise<IAccessGroup[] | []>;
@@ -95,15 +95,6 @@ let AdminService = (() => {
95
95
  return [];
96
96
  }
97
97
  }
98
- async getDeliverableLockDevicesByAccessGroupIds(accessGroupIds, propertyId) {
99
- try {
100
- return await this.adminRepository.getDeliverableLockDevicesByAccessGroupIds(accessGroupIds, propertyId);
101
- }
102
- catch (error) {
103
- console.log(error);
104
- return { collections: [], maintenanceSkips: [] };
105
- }
106
- }
107
98
  async getZonesByAccessGroups(accessGroupIds, type) {
108
99
  try {
109
100
  return await this.adminRepository.getZonesByAccessGroups(accessGroupIds, type);
@@ -1,4 +1,3 @@
1
- import { IDevice } from "../device/local/interfaces";
2
1
  export interface IAccessGroup {
3
2
  id: string;
4
3
  propertyId: string;
@@ -49,42 +48,3 @@ export interface IUser {
49
48
  deletedAt?: Date | null;
50
49
  imageURL?: string | null;
51
50
  }
52
- /** ZN-2 skip metadata for callers that emit maintenance audits (e.g. smart-access-node). */
53
- export type IZn2MaintenanceSkipReason = "zone inactive" | "device under maintenance";
54
- export interface IZn2MaintenanceSkip {
55
- accessGroupId: string;
56
- zoneId: string;
57
- deviceIds: string[];
58
- reason: IZn2MaintenanceSkipReason;
59
- }
60
- /** LOCK devices eligible for guest programming after zone + device maintenance rules. */
61
- export interface IDeliverableLocksByAccessGroupResult {
62
- collections: {
63
- collectionId: string;
64
- devices: IDevice[];
65
- skippedDevices: IDevice[];
66
- zones: {
67
- zoneId: string;
68
- deviceIds: string[];
69
- zoneName: string;
70
- zoneTypeName: string;
71
- isUnderMaintenance: boolean;
72
- }[];
73
- parentZone: any;
74
- isUnderMaintenance: boolean;
75
- }[];
76
- maintenanceSkips: IZn2MaintenanceSkip[];
77
- }
78
- export interface ILocksAndZonesByAccessGroup {
79
- collectionId: string;
80
- devices: IDevice[];
81
- zones: {
82
- zoneId: string;
83
- deviceIds: string[];
84
- zoneName: string;
85
- zoneTypeName: string;
86
- isUnderMaintenance: boolean;
87
- }[];
88
- parentZone: any;
89
- isUnderMaintenance: boolean;
90
- }
@@ -83,15 +83,7 @@ let ConnectionRepository = (() => {
83
83
  // Build conditions dynamically based on provided query parameters
84
84
  Object.keys(query).forEach((key) => {
85
85
  const value = query[key];
86
- if (value === undefined || value === null)
87
- return;
88
- // ✅ Special handling for metaData (JSON)
89
- if (key === "metaData" && typeof value === "object") {
90
- conditions.push(`"metaData" @> $${paramIndex}`);
91
- values.push(JSON.stringify(value));
92
- paramIndex++;
93
- }
94
- else {
86
+ if (value !== undefined && value !== null) {
95
87
  conditions.push(`"${key}" = $${paramIndex}`);
96
88
  values.push(value);
97
89
  paramIndex++;
@@ -125,9 +117,9 @@ let ConnectionRepository = (() => {
125
117
  .join(", ");
126
118
  const values = Object.values(data);
127
119
  const result = await this.pool.query(`UPDATE dt_connections
128
- SET ${setClause}, "updatedAt" = NOW()
129
- WHERE id = $1 AND "propertyId" = $2
130
- RETURNING *`, [connectionId, propertyId, ...values]);
120
+ SET ${setClause}, "updatedAt" = NOW()
121
+ WHERE id = $1 AND "propertyId" = $2
122
+ RETURNING *`, [connectionId, propertyId, ...values]);
131
123
  if (result.rowCount === 0) {
132
124
  return null;
133
125
  }
@@ -29,6 +29,5 @@ export declare enum ConnectionProvider {
29
29
  Dusaw = "Dusaw",
30
30
  Lockly = "Lockly",
31
31
  Sifely = "Sifely",
32
- Twilio = "Twilio",
33
- Daikin = "Daikin"
32
+ Twilio = "Twilio"
34
33
  }
@@ -20,5 +20,4 @@ var ConnectionProvider;
20
20
  ConnectionProvider["Lockly"] = "Lockly";
21
21
  ConnectionProvider["Sifely"] = "Sifely";
22
22
  ConnectionProvider["Twilio"] = "Twilio";
23
- ConnectionProvider["Daikin"] = "Daikin";
24
23
  })(ConnectionProvider || (exports.ConnectionProvider = ConnectionProvider = {}));
@@ -1,7 +1,6 @@
1
1
  export interface IDevice {
2
2
  deviceId: string;
3
3
  propertyId: string;
4
- collectionId?: string;
5
4
  zoneId: string;
6
5
  name: string;
7
6
  hubId: string[];
@@ -49,11 +48,6 @@ export interface IDevice {
49
48
  capabilities?: Record<string, any>;
50
49
  isDeleted?: boolean;
51
50
  deletedAt?: Date;
52
- /** Persisted maintenance; ZONE-sourced rows mirror parent zone toggles (smart-cloud). */
53
- isUnderMaintenance?: boolean;
54
- underMaintenanceSince?: string | Date | null;
55
- maintenanceReason?: string | null;
56
- maintenanceSource?: "ZONE" | "DEVICE" | null;
57
51
  }
58
52
  export declare class IStatus {
59
53
  online: boolean;
@@ -8,13 +8,6 @@ export declare class DeviceRepository {
8
8
  getDevice(deviceId: string, withHubDetails?: boolean): Promise<IDevice>;
9
9
  updateDevice(deviceId: string, body: any): Promise<IDevice>;
10
10
  updateDevices(query: any, updateData: any): Promise<any>;
11
- /** Sync Mongo `devices_v2` when smart-cloud toggles zone maintenance (operational device-service). */
12
- syncDevicesZoneMaintenance(body: {
13
- zoneId: string;
14
- enabled: boolean;
15
- maintenanceReason?: string | null;
16
- underMaintenanceSince?: string | null;
17
- }): Promise<any>;
18
11
  deleteDevice(deviceId: string): Promise<void>;
19
12
  getDevices(deviceIds: string[], withHubDetails?: boolean): Promise<IDevice[]>;
20
13
  getPropertyDevices(propertyId: string, selectDeviceId?: boolean, type?: string, withHubDetails?: boolean): Promise<IDevice[]>;
@@ -96,17 +96,6 @@ let DeviceRepository = (() => {
96
96
  throw new Error(`Failed to update devices: ${error.message}`);
97
97
  }
98
98
  }
99
- /** Sync Mongo `devices_v2` when smart-cloud toggles zone maintenance (operational device-service). */
100
- async syncDevicesZoneMaintenance(body) {
101
- try {
102
- const response = await this.axiosInstance.put(`/devices/maintenance/zone`, body);
103
- return response.data;
104
- }
105
- catch (error) {
106
- (0, config_1.getConfig)().LOGGER.error("Failed to sync zone maintenance to devices:", error);
107
- throw new Error(`Failed to sync zone maintenance: ${error.message || "Unknown error"}`);
108
- }
109
- }
110
99
  async deleteDevice(deviceId) {
111
100
  try {
112
101
  await this.axiosInstance.delete(`/devices/${deviceId}`);
@@ -13,14 +13,6 @@ export declare class LocalDeviceService {
13
13
  getDevices(deviceIds: string[], withHubDetails?: boolean): Promise<IDevice[]>;
14
14
  getPropertyDevices(propertyId: string, selectDeviceId?: boolean, type?: string, withHubDetails?: boolean): Promise<IDevice[]>;
15
15
  updateDevice(deviceId: string, body: Partial<IDevice>, auditBody: IAuditProperties): Promise<any>;
16
- /**
17
- * When a zone’s maintenance flag changes in smart-cloud, mirror the same rules as `dt_devices`
18
- * onto operational Mongo (`devices_v2`) via device-service.
19
- */
20
- syncDevicesZoneMaintenance(zoneId: string, enabled: boolean, options?: {
21
- maintenanceReason?: string | null;
22
- underMaintenanceSince?: string | Date | null;
23
- }): Promise<any>;
24
16
  updateDevices(query: any, updateData: any): Promise<any>;
25
17
  deleteDevice(deviceId: string, auditBody: IAuditProperties): Promise<any>;
26
18
  getState(deviceId: string): Promise<any>;
@@ -154,27 +154,6 @@ let LocalDeviceService = (() => {
154
154
  await this.deviceRepository.updateDevice(deviceId, body);
155
155
  return await this.eventHandler.onDeviceUpdate(deviceId, body, auditBody);
156
156
  }
157
- /**
158
- * When a zone’s maintenance flag changes in smart-cloud, mirror the same rules as `dt_devices`
159
- * onto operational Mongo (`devices_v2`) via device-service.
160
- */
161
- async syncDevicesZoneMaintenance(zoneId, enabled, options) {
162
- if (!zoneId) {
163
- throw new Error("Zone ID is required");
164
- }
165
- const body = { zoneId, enabled };
166
- if (enabled && options) {
167
- if (options.maintenanceReason !== undefined) {
168
- body.maintenanceReason = options.maintenanceReason;
169
- }
170
- const since = options.underMaintenanceSince;
171
- if (since !== undefined && since !== null) {
172
- body.underMaintenanceSince =
173
- since instanceof Date ? since.toISOString() : since;
174
- }
175
- }
176
- return await this.deviceRepository.syncDevicesZoneMaintenance(body);
177
- }
178
157
  async updateDevices(query, updateData) {
179
158
  if (!query || !updateData) {
180
159
  throw new Error("Query and update data are required");
@@ -148,30 +148,19 @@ let PmsService = (() => {
148
148
  if (!scheduleAccessGroups || scheduleAccessGroups.length === 0) {
149
149
  return false;
150
150
  }
151
- // Split reservations often have multiple rows per schedule with the *same* startTime
152
- // across different access groups. Sorting *all* rows globally made the last two entries
153
- // always different access groups. Here we only consider rows for this accessGroupId,
154
- // ordered by startTime, and require the latest segment to follow the previous one in time.
155
- const rowsForThisAccessGroup = scheduleAccessGroups
156
- .filter((row) => row.accessGroupId === accessGroupId)
157
- .sort((a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime());
158
- if (rowsForThisAccessGroup.length < 2) {
151
+ const orderedAccessGroups = [...scheduleAccessGroups].sort((a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime());
152
+ // First entry new code should be assigned
153
+ if (orderedAccessGroups.length < 2) {
159
154
  return false;
160
155
  }
161
- const previousSegment = rowsForThisAccessGroup.at(-2);
162
- const currentSegment = rowsForThisAccessGroup.at(-1);
163
- if (!previousSegment.endTime || !currentSegment.startTime) {
164
- return false;
165
- }
166
- const previousStart = new Date(previousSegment.startTime).getTime();
167
- const previousEnd = new Date(previousSegment.endTime).getTime();
168
- const currentStart = new Date(currentSegment.startTime).getTime();
169
- // Same startTime as previous row (duplicate import, extra map row, etc.) — still reuse one code.
170
- if (currentStart === previousStart) {
171
- return true;
172
- }
173
- // Consecutive nights: current segment starts at or after previous segment ends.
174
- return currentStart >= previousEnd;
156
+ const last = orderedAccessGroups?.at(-1);
157
+ const secondLast = orderedAccessGroups?.at(-2);
158
+ // True only if last and second last entries are same and equal to accessGroupId
159
+ return (
160
+ // This 1st condition doesnt seems to be required so verify with use case
161
+ last.accessGroupId === accessGroupId &&
162
+ secondLast.accessGroupId === accessGroupId //A(secondLast) A(last)
163
+ );
175
164
  }
176
165
  };
177
166
  __setFunctionName(_classThis, "PmsService");
@@ -4,6 +4,5 @@ export declare class PropertyRepository {
4
4
  constructor();
5
5
  getPropertyPreferences(propertyId: string, keys?: string[]): Promise<IPropertySettings | null>;
6
6
  getProperty(propertyId: string): Promise<IProperty | null>;
7
- getOrganizationByPropertyId(propertyId: string): Promise<any | null>;
8
7
  getAllProperties(): Promise<any[]>;
9
8
  }
@@ -41,7 +41,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.PropertyRepository = void 0;
42
42
  const db_1 = require("../../db");
43
43
  const typedi_1 = require("typedi");
44
- const utils_1 = require("../../utils");
45
44
  let PropertyRepository = (() => {
46
45
  let _classDecorators = [(0, typedi_1.Service)()];
47
46
  let _classDescriptor;
@@ -85,10 +84,6 @@ let PropertyRepository = (() => {
85
84
  }
86
85
  return null;
87
86
  }
88
- async getOrganizationByPropertyId(propertyId) {
89
- const organization = await (0, utils_1.getAdminServiceAxiosInstance)().get(`/properties/${propertyId}/organizations`);
90
- return organization.data.data;
91
- }
92
87
  async getAllProperties() {
93
88
  try {
94
89
  //Retrieve all the properties ids from the database where isDeleted is false
@@ -5,5 +5,4 @@ export declare class LocalPropertyService {
5
5
  getProperty(propertyId: string): Promise<import("./IProperty").IProperty | null>;
6
6
  getPropertyTimeZone(propertyId: string): Promise<string>;
7
7
  getAllProperties(): Promise<any[]>;
8
- getOrganizationByPropertyId(propertyId: string): Promise<any>;
9
8
  }
@@ -110,12 +110,6 @@ let LocalPropertyService = (() => {
110
110
  const properties = await this.propertyRepository.getAllProperties();
111
111
  return properties;
112
112
  }
113
- async getOrganizationByPropertyId(propertyId) {
114
- if (!propertyId) {
115
- throw new Error("Property ID is required");
116
- }
117
- return await this.propertyRepository.getOrganizationByPropertyId(propertyId);
118
- }
119
113
  };
120
114
  __setFunctionName(_classThis, "LocalPropertyService");
121
115
  (() => {
package/dist/index.d.ts CHANGED
@@ -25,4 +25,3 @@ export * from "./webhooks";
25
25
  export * from "./Integrations";
26
26
  export * from "./Integrations/twilio";
27
27
  export * from "./emails/emailService";
28
- export * from "./entities/notification";
package/dist/index.js CHANGED
@@ -75,5 +75,3 @@ __exportStar(require("./Integrations"), exports);
75
75
  __exportStar(require("./Integrations/twilio"), exports);
76
76
  // Export Email Service
77
77
  __exportStar(require("./emails/emailService"), exports);
78
- // Export Notification Service
79
- __exportStar(require("./entities/notification"), exports);
@@ -49,8 +49,7 @@ export declare enum EntitySubType {
49
49
  SALTOSPACE = "SALTOSPACE",
50
50
  SCHLAGE = "SCHLAGE",
51
51
  LOCKLY = "LOCKLY",
52
- SIFELY = "SIFELY",
53
- GEOCODING = "GEOCODING"
52
+ SIFELY = "SIFELY"
54
53
  }
55
54
  export declare enum IssueStatus {
56
55
  PENDING = "PENDING",
@@ -86,8 +85,7 @@ export declare enum IssueType {
86
85
  LOW_GUEST_CODES = "LOW_GUEST_CODES",
87
86
  PMS_CODE_NOT_DELIVERED = "PMS_CODE_NOT_DELIVERED",
88
87
  SCHEDULE_CODE_NOT_ASSIGNED = "SCHEDULE_CODE_NOT_ASSIGNED",
89
- MISSING_ACCESS_GROUP = "MISSING_ACCESS_GROUP",
90
- GEOCODING_FAILED = "GEOCODING_FAILED"
88
+ MISSING_ACCESS_GROUP = "MISSING_ACCESS_GROUP"
91
89
  }
92
90
  export declare const IssueDescriptions: {
93
91
  BATTERY_LOW: string;
@@ -103,7 +101,6 @@ export declare const IssueDescriptions: {
103
101
  PMS_CODE_NOT_DELIVERED: string;
104
102
  SCHEDULE_CODE_NOT_ASSIGNED: string;
105
103
  MISSING_ACCESS_GROUP: string;
106
- GEOCODING_FAILED: string;
107
104
  };
108
105
  export interface IssueDocument {
109
106
  id: string;
@@ -60,8 +60,6 @@ var EntitySubType;
60
60
  EntitySubType["SCHLAGE"] = "SCHLAGE";
61
61
  EntitySubType["LOCKLY"] = "LOCKLY";
62
62
  EntitySubType["SIFELY"] = "SIFELY";
63
- // OTHER
64
- EntitySubType["GEOCODING"] = "GEOCODING";
65
63
  })(EntitySubType || (exports.EntitySubType = EntitySubType = {}));
66
64
  var IssueStatus;
67
65
  (function (IssueStatus) {
@@ -94,7 +92,6 @@ var IssueType;
94
92
  IssueType["PMS_CODE_NOT_DELIVERED"] = "PMS_CODE_NOT_DELIVERED";
95
93
  IssueType["SCHEDULE_CODE_NOT_ASSIGNED"] = "SCHEDULE_CODE_NOT_ASSIGNED";
96
94
  IssueType["MISSING_ACCESS_GROUP"] = "MISSING_ACCESS_GROUP";
97
- IssueType["GEOCODING_FAILED"] = "GEOCODING_FAILED";
98
95
  })(IssueType || (exports.IssueType = IssueType = {}));
99
96
  exports.IssueDescriptions = {
100
97
  [IssueType.BATTERY_LOW]: "The issue is raised when the battery level is lower than the threshold.",
@@ -110,5 +107,4 @@ exports.IssueDescriptions = {
110
107
  [IssueType.PMS_CODE_NOT_DELIVERED]: "The issue is raised when the code is not delivered to the PMS system.",
111
108
  [IssueType.SCHEDULE_CODE_NOT_ASSIGNED]: "The issue is raised when the code is not assigned to a schedule.",
112
109
  [IssueType.MISSING_ACCESS_GROUP]: "The issue is raised when the access group is missing from devicethread but present in PMS system.",
113
- [IssueType.GEOCODING_FAILED]: "The issue is raised when the system fails to retrieve latitude and longitude from the provided property address.",
114
110
  };
@@ -1,4 +1,3 @@
1
- import axios from "axios";
2
1
  /**
3
2
  * Validates if a URL is properly formatted and accessible
4
3
  */
@@ -6,11 +5,10 @@ export declare function validateServiceUrl(url: string): boolean;
6
5
  /**
7
6
  * Creates a properly configured axios instance with error handling
8
7
  */
9
- export declare function createAxiosInstance(baseURL?: string): axios.AxiosInstance;
8
+ export declare function createAxiosInstance(baseURL?: string): import("axios").AxiosInstance;
10
9
  export declare function getDeviceServiceAxiosInstance(): any;
11
10
  export declare function getAdminServiceAxiosInstance(): any;
12
11
  export declare function getMonitoringServiceAxiosInstance(): any;
13
- export declare function getNotificationServiceAxiosInstance(): any;
14
12
  /**
15
13
  * Retry function for failed HTTP requests
16
14
  */
@@ -8,7 +8,6 @@ exports.createAxiosInstance = createAxiosInstance;
8
8
  exports.getDeviceServiceAxiosInstance = getDeviceServiceAxiosInstance;
9
9
  exports.getAdminServiceAxiosInstance = getAdminServiceAxiosInstance;
10
10
  exports.getMonitoringServiceAxiosInstance = getMonitoringServiceAxiosInstance;
11
- exports.getNotificationServiceAxiosInstance = getNotificationServiceAxiosInstance;
12
11
  exports.retryRequest = retryRequest;
13
12
  const config_1 = require("../config/config");
14
13
  const axios_1 = __importDefault(require("axios"));
@@ -106,13 +105,6 @@ function getMonitoringServiceAxiosInstance() {
106
105
  }
107
106
  return deviceMonitoringServiceAxiosInstance;
108
107
  }
109
- let notificationServiceAxiosInstance = null;
110
- function getNotificationServiceAxiosInstance() {
111
- if (!notificationServiceAxiosInstance) {
112
- notificationServiceAxiosInstance = createAxiosInstance((0, config_1.getNotificationServiceUrl)());
113
- }
114
- return notificationServiceAxiosInstance;
115
- }
116
108
  /**
117
109
  * Retry function for failed HTTP requests
118
110
  */
@@ -1,4 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
19
  function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
20
  var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
@@ -33,6 +49,23 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
33
49
  }
34
50
  return useValue ? value : void 0;
35
51
  };
52
+ var __importStar = (this && this.__importStar) || (function () {
53
+ var ownKeys = function(o) {
54
+ ownKeys = Object.getOwnPropertyNames || function (o) {
55
+ var ar = [];
56
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
57
+ return ar;
58
+ };
59
+ return ownKeys(o);
60
+ };
61
+ return function (mod) {
62
+ if (mod && mod.__esModule) return mod;
63
+ var result = {};
64
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
65
+ __setModuleDefault(result, mod);
66
+ return result;
67
+ };
68
+ })();
36
69
  var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
70
  if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
71
  return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
@@ -111,7 +144,7 @@ let WebhookQueueService = (() => {
111
144
  try {
112
145
  // Create queue instance if not exists locally
113
146
  if (!this.webhookQueues.has(queueName)) {
114
- const { Queue } = await import("bullmq");
147
+ const { Queue } = await Promise.resolve().then(() => __importStar(require("bullmq")));
115
148
  const queue = new Queue(queueName, {
116
149
  connection: (0, redis_1.getRedisClient)(),
117
150
  });
@@ -186,7 +219,7 @@ let WebhookQueueService = (() => {
186
219
  try {
187
220
  // Create queue instance if not exists locally
188
221
  if (!this.webhookQueues.has(queueName)) {
189
- const { Queue } = await import("bullmq");
222
+ const { Queue } = await Promise.resolve().then(() => __importStar(require("bullmq")));
190
223
  const queue = new Queue(queueName, {
191
224
  connection: (0, redis_1.getRedisClient)(),
192
225
  });
@@ -212,7 +245,7 @@ let WebhookQueueService = (() => {
212
245
  if (queues.has(queueKey)) {
213
246
  return queues.get(queueKey);
214
247
  }
215
- const { Queue } = await import("bullmq");
248
+ const { Queue } = await Promise.resolve().then(() => __importStar(require("bullmq")));
216
249
  const queue = new Queue(queueKey, {
217
250
  connection: (0, redis_1.getRedisClient)(),
218
251
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "13.8.2",
3
+ "version": "14.0.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -43,11 +43,10 @@
43
43
  "typescript": "^5.8.3"
44
44
  },
45
45
  "dependencies": {
46
- "@aws-sdk/client-s3": "3.1015.0",
46
+ "@aws-sdk/client-s3": "^3.835.0",
47
47
  "@aws-sdk/client-ses": "3.1003.0",
48
48
  "axios": "1.10.0",
49
49
  "bullmq": "5.56.4",
50
- "class-validator": "0.15.1",
51
50
  "dt-audit-library": "1.7.1",
52
51
  "dt-pub-sub": "^1.0.0",
53
52
  "ioredis": "5.6.1",