dt-common-device 13.7.1 → 14.0.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.
- package/dist/Integrations/twilio/twilio.service.d.ts +2 -1
- package/dist/Integrations/twilio/twilio.service.js +20 -16
- package/dist/alerts/alert.types.d.ts +1 -5
- package/dist/alerts/alert.types.js +0 -4
- package/dist/audit/AuditUtils.js +0 -11
- package/dist/audit/PushAudit.d.ts +0 -5
- package/dist/audit/PushAudit.js +9 -24
- package/dist/config/config.d.ts +0 -1
- package/dist/config/config.js +0 -9
- package/dist/config/constants.js +0 -1
- package/dist/constants/ConnectionProviders.d.ts +0 -1
- package/dist/constants/ConnectionProviders.js +0 -1
- package/dist/emails/emailService.js +41 -23
- package/dist/entities/connection/Connection.repository.js +1 -9
- package/dist/entities/connection/IConnection.d.ts +1 -2
- package/dist/entities/connection/IConnection.js +0 -1
- package/dist/entities/pms/pms.service.js +11 -22
- package/dist/entities/property/Property.repository.d.ts +0 -1
- package/dist/entities/property/Property.repository.js +0 -5
- package/dist/entities/property/Property.service.d.ts +0 -1
- package/dist/entities/property/Property.service.js +0 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/dist/issues/issue.types.d.ts +2 -5
- package/dist/issues/issue.types.js +0 -4
- package/dist/queue/utils/rateLimit.utils.js +2 -2
- package/dist/utils/http.utils.d.ts +0 -1
- package/dist/utils/http.utils.js +0 -8
- 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
|
|
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
|
|
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.
|
|
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
|
-
|
|
101
|
+
//find fromNumber from the dt_connections table based on the propertyId
|
|
102
|
+
const response = await this.connectionRepository.queryConnections({
|
|
102
103
|
propertyId,
|
|
103
|
-
connectionProvider:
|
|
104
|
-
isEnable: true,
|
|
104
|
+
connectionProvider: IConnection_1.ConnectionProvider.Twilio,
|
|
105
105
|
});
|
|
106
|
-
|
|
107
|
-
|
|
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
|
|
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");
|
package/dist/audit/AuditUtils.js
CHANGED
|
@@ -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;
|
package/dist/audit/PushAudit.js
CHANGED
|
@@ -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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
}
|
package/dist/config/config.d.ts
CHANGED
|
@@ -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;
|
package/dist/config/config.js
CHANGED
|
@@ -41,7 +41,6 @@ exports.getConfig = getConfig;
|
|
|
41
41
|
exports.getDeviceServiceUrl = getDeviceServiceUrl;
|
|
42
42
|
exports.getAdminServiceUrl = getAdminServiceUrl;
|
|
43
43
|
exports.getMonitoringServiceUrl = getMonitoringServiceUrl;
|
|
44
|
-
exports.getNotificationServiceUrl = getNotificationServiceUrl;
|
|
45
44
|
exports.getSqsQueueUrl = getSqsQueueUrl;
|
|
46
45
|
exports.getReservationSqsQueueUrl = getReservationSqsQueueUrl;
|
|
47
46
|
exports.getHeartbeatSqsQueueUrl = getHeartbeatSqsQueueUrl;
|
|
@@ -195,14 +194,6 @@ function getMonitoringServiceUrl() {
|
|
|
195
194
|
}
|
|
196
195
|
return monitoringServiceUrl;
|
|
197
196
|
}
|
|
198
|
-
function getNotificationServiceUrl() {
|
|
199
|
-
const notificationServiceUrl = process.env.NOTIFICATION_SERVICE;
|
|
200
|
-
if (!notificationServiceUrl) {
|
|
201
|
-
getConfig().LOGGER.error("NOTIFICATION_SERVICE must be set in environment variables");
|
|
202
|
-
throw new Error("dt-common-device: NOTIFICATION_SERVICE must be set in environment variables");
|
|
203
|
-
}
|
|
204
|
-
return notificationServiceUrl;
|
|
205
|
-
}
|
|
206
197
|
function getSqsQueueUrl() {
|
|
207
198
|
if (constants_1.CONFIG_KEYS[sourceKey].env.includes("AWS_SQS_URL")) {
|
|
208
199
|
const sqsQueueUrl = process.env.AWS_SQS_URL;
|
package/dist/config/constants.js
CHANGED
|
@@ -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
|
|
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
|
|
247
|
+
// const logo: any = await GetLogo(ctx);
|
|
248
|
+
let finalMessage = message
|
|
242
249
|
.replaceAll("{{year}}", currentYear)
|
|
243
|
-
.replaceAll("{{
|
|
250
|
+
.replaceAll("{{contactUsPhone}}", `${CONTACT_US_DETAILS?.PHONE}`)
|
|
251
|
+
.replaceAll("{{contactUsEmail}}", `${CONTACT_US_DETAILS?.TO_EMAIL_ADDRESS}`)
|
|
244
252
|
.replaceAll("{{logo}}", `${imageURL}`);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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: {
|
|
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
|
-
|
|
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",
|
|
293
|
+
(0, config_1.getLogger)().error("sendMail: Error", error);
|
|
276
294
|
}
|
|
277
295
|
}
|
|
278
296
|
};
|
|
@@ -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
|
|
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++;
|
|
@@ -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 = {}));
|
|
@@ -148,30 +148,19 @@ let PmsService = (() => {
|
|
|
148
148
|
if (!scheduleAccessGroups || scheduleAccessGroups.length === 0) {
|
|
149
149
|
return false;
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
//
|
|
153
|
-
|
|
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
|
|
162
|
-
const
|
|
163
|
-
if
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
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
|
};
|
|
@@ -82,8 +82,8 @@ class RateLimitUtils {
|
|
|
82
82
|
maxTimeoutWindowMs: 120000,
|
|
83
83
|
});
|
|
84
84
|
configs.set(constants_1.CONNECTION_PROVIDERS.YALEWIFI, {
|
|
85
|
-
maxRequests:
|
|
86
|
-
windowMs:
|
|
85
|
+
maxRequests: 38,
|
|
86
|
+
windowMs: 10000,
|
|
87
87
|
provider: constants_1.CONNECTION_PROVIDERS.YALEWIFI,
|
|
88
88
|
maxTimeoutWindowMs: 120000,
|
|
89
89
|
});
|
|
@@ -9,7 +9,6 @@ export declare function createAxiosInstance(baseURL?: string): import("axios").A
|
|
|
9
9
|
export declare function getDeviceServiceAxiosInstance(): any;
|
|
10
10
|
export declare function getAdminServiceAxiosInstance(): any;
|
|
11
11
|
export declare function getMonitoringServiceAxiosInstance(): any;
|
|
12
|
-
export declare function getNotificationServiceAxiosInstance(): any;
|
|
13
12
|
/**
|
|
14
13
|
* Retry function for failed HTTP requests
|
|
15
14
|
*/
|
package/dist/utils/http.utils.js
CHANGED
|
@@ -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
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dt-common-device",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
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.
|
|
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",
|