dt-common-device 11.1.0 → 11.1.2
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/audit/AuditUtils.d.ts +2 -0
- package/dist/audit/AuditUtils.js +49 -10
- package/dist/constants/Event.d.ts +4 -0
- package/dist/constants/Event.js +4 -0
- package/dist/cronicle/Cronicle.service.js +4 -3
- package/dist/entities/pms/pms.repository.d.ts +1 -0
- package/dist/entities/pms/pms.repository.js +13 -0
- package/dist/entities/pms/pms.service.d.ts +1 -0
- package/dist/entities/pms/pms.service.js +9 -0
- package/package.json +1 -1
package/dist/audit/AuditUtils.js
CHANGED
|
@@ -134,7 +134,7 @@ let AuditUtils = (() => {
|
|
|
134
134
|
}
|
|
135
135
|
async populateAuditFields(audit) {
|
|
136
136
|
try {
|
|
137
|
-
const { propertyId, propertyName, userId, userName, guestId, guestName, deviceId, deviceName, zoneId, zoneName, accessGroupId, accessGroupName, scheduleId, } = audit;
|
|
137
|
+
const { propertyId, propertyName, userId, userName, guestId, guestName, deviceId, deviceName, zoneId, zoneName, accessGroupId, accessGroupName, scheduleId, referenceId, } = audit;
|
|
138
138
|
if (propertyId && !propertyName) {
|
|
139
139
|
(0, config_1.getLogger)().info(`Property ID: ${propertyId}`);
|
|
140
140
|
if (propertyId === "triggered_externally") {
|
|
@@ -168,15 +168,26 @@ let AuditUtils = (() => {
|
|
|
168
168
|
}
|
|
169
169
|
if (accessGroupId && !accessGroupName)
|
|
170
170
|
audit.accessGroupName = await this.getAccessGroupName(accessGroupId);
|
|
171
|
-
if (scheduleId)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
audit.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
171
|
+
if (referenceId && !scheduleId)
|
|
172
|
+
audit.scheduleId = await this.getScheduleId(referenceId);
|
|
173
|
+
if (scheduleId && !referenceId)
|
|
174
|
+
audit.referenceId = await this.getReferenceId(scheduleId);
|
|
175
|
+
// if (scheduleId) {
|
|
176
|
+
// const {
|
|
177
|
+
// scheduleStartDate,
|
|
178
|
+
// scheduleEndDate,
|
|
179
|
+
// scheduleDuration,
|
|
180
|
+
// scheduleSource,
|
|
181
|
+
// scheduleStatus,
|
|
182
|
+
// referenceId,
|
|
183
|
+
// } = await this.getScheduleDetails(scheduleId);
|
|
184
|
+
// audit.scheduleStartDate = scheduleStartDate;
|
|
185
|
+
// audit.scheduleEndDate = scheduleEndDate;
|
|
186
|
+
// audit.scheduleDuration = scheduleDuration;
|
|
187
|
+
// audit.scheduleSource = scheduleSource;
|
|
188
|
+
// audit.scheduleStatus = scheduleStatus;
|
|
189
|
+
// audit.referenceId = referenceId;
|
|
190
|
+
// }
|
|
180
191
|
}
|
|
181
192
|
catch (error) {
|
|
182
193
|
(0, config_1.getLogger)().error(`Error in populateAuditFields: ${error instanceof Error ? error.message : error}`);
|
|
@@ -311,6 +322,34 @@ let AuditUtils = (() => {
|
|
|
311
322
|
return "";
|
|
312
323
|
}
|
|
313
324
|
}
|
|
325
|
+
async getScheduleId(referenceId) {
|
|
326
|
+
try {
|
|
327
|
+
return await this.getCachedEntityData("scheduleId", referenceId, async () => {
|
|
328
|
+
const schedule = await typedi_1.default.get(pms_1.PmsService).getScheduleByReferenceId(referenceId);
|
|
329
|
+
if (!schedule)
|
|
330
|
+
return "";
|
|
331
|
+
return schedule?.id || "";
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
(0, config_1.getLogger)().error(`Error in getScheduleId: ${error instanceof Error ? error.message : error}`);
|
|
336
|
+
return "";
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
async getReferenceId(scheduleId) {
|
|
340
|
+
try {
|
|
341
|
+
return await this.getCachedEntityData("referenceId", scheduleId, async () => {
|
|
342
|
+
const schedule = await typedi_1.default.get(pms_1.PmsService).getSchedule(scheduleId);
|
|
343
|
+
if (!schedule)
|
|
344
|
+
return "";
|
|
345
|
+
return schedule?.referenceId || "";
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
(0, config_1.getLogger)().error(`Error in getReferenceId: ${error instanceof Error ? error.message : error}`);
|
|
350
|
+
return "";
|
|
351
|
+
}
|
|
352
|
+
}
|
|
314
353
|
async getScheduleDetails(scheduleId) {
|
|
315
354
|
try {
|
|
316
355
|
return await this.getCachedEntityData("schedule", scheduleId, async () => {
|
package/dist/constants/Event.js
CHANGED
|
@@ -242,6 +242,10 @@ exports.DT_EVENT_TYPES = {
|
|
|
242
242
|
HEARTBEAT: {
|
|
243
243
|
DISABLED: "heartbeat.disabled",
|
|
244
244
|
STARTED: "heartbeat.started",
|
|
245
|
+
DEVICE_CHECK: {
|
|
246
|
+
PROGRESS: "heartbeat.device_check.progress",
|
|
247
|
+
COMPLETED: "heartbeat.device_check.completed",
|
|
248
|
+
},
|
|
245
249
|
DEVICE: {
|
|
246
250
|
IN_ACTIVE: "heartbeat.device.in_active",
|
|
247
251
|
OFFLINE: "heartbeat.device.offline",
|
|
@@ -26,10 +26,11 @@ class CronicleService {
|
|
|
26
26
|
params: {
|
|
27
27
|
url: apiUrl,
|
|
28
28
|
method,
|
|
29
|
-
headers: {
|
|
29
|
+
headers: JSON.stringify({
|
|
30
30
|
"Content-Type": "application/json",
|
|
31
31
|
"x-api-key": this.cronicleApiKey,
|
|
32
|
-
},
|
|
32
|
+
}),
|
|
33
|
+
timeout: 120,
|
|
33
34
|
},
|
|
34
35
|
data: payload,
|
|
35
36
|
timing: {
|
|
@@ -40,7 +41,7 @@ class CronicleService {
|
|
|
40
41
|
hours: schedule.hours,
|
|
41
42
|
minutes: schedule.minutes,
|
|
42
43
|
},
|
|
43
|
-
timeout:
|
|
44
|
+
timeout: 0,
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
47
|
catch (error) {
|
|
@@ -3,6 +3,7 @@ export declare class PmsRepository {
|
|
|
3
3
|
private readonly pmsPostgres;
|
|
4
4
|
constructor();
|
|
5
5
|
getSchedule(scheduleId: string): Promise<IPmsSchedule | null>;
|
|
6
|
+
getScheduleByReferenceId(referenceId: string): Promise<IPmsSchedule | null>;
|
|
6
7
|
getScheduleIdByAccessGroupId(accessGroupId: string, status: string): Promise<string | null>;
|
|
7
8
|
getGuest(guestId: string): Promise<IGuest | null>;
|
|
8
9
|
getGuestId(scheduleId: string): Promise<string | null>;
|
|
@@ -63,6 +63,19 @@ let PmsRepository = (() => {
|
|
|
63
63
|
throw new Error("Failed to get schedule");
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
async getScheduleByReferenceId(referenceId) {
|
|
67
|
+
try {
|
|
68
|
+
const schedule = await this.pmsPostgres.query(`SELECT * FROM dt_schedule WHERE "referenceId" = $1`, [referenceId]);
|
|
69
|
+
if (schedule.rows.length > 0) {
|
|
70
|
+
return schedule.rows[0];
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
console.error("Error in getScheduleByReferenceId:", error);
|
|
76
|
+
throw new Error("Failed to get schedule by reference ID");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
66
79
|
async getScheduleIdByAccessGroupId(accessGroupId, status) {
|
|
67
80
|
const scheduleId = await this.pmsPostgres.query(`SELECT "scheduleId" FROM dt_schedule_accessgroup_map WHERE "accessGroupId" = $1 AND "status" = $2`, [accessGroupId, status]);
|
|
68
81
|
//TODO: Need to Check if only one Schedule is there for the given Access Group in checked-in state!
|
|
@@ -3,6 +3,7 @@ export declare class PmsService {
|
|
|
3
3
|
private readonly pmsRepository;
|
|
4
4
|
constructor();
|
|
5
5
|
getSchedule(scheduleId: string): Promise<IPmsSchedule | null>;
|
|
6
|
+
getScheduleByReferenceId(referenceId: string): Promise<IPmsSchedule | null>;
|
|
6
7
|
getScheduleIdByAccessGroupId(accessGroupId: string, status: string): Promise<string | null>;
|
|
7
8
|
getGuest(guestId: string): Promise<IGuest | null>;
|
|
8
9
|
getGuestId(scheduleId: string): Promise<string | null>;
|
|
@@ -92,6 +92,15 @@ let PmsService = (() => {
|
|
|
92
92
|
return null;
|
|
93
93
|
return schedule;
|
|
94
94
|
}
|
|
95
|
+
async getScheduleByReferenceId(referenceId) {
|
|
96
|
+
if (!referenceId) {
|
|
97
|
+
throw new Error("Reference ID is required");
|
|
98
|
+
}
|
|
99
|
+
const schedule = await this.pmsRepository.getScheduleByReferenceId(referenceId);
|
|
100
|
+
if (!schedule)
|
|
101
|
+
return null;
|
|
102
|
+
return schedule;
|
|
103
|
+
}
|
|
95
104
|
async getScheduleIdByAccessGroupId(accessGroupId, status) {
|
|
96
105
|
if (!accessGroupId) {
|
|
97
106
|
throw new Error("Access Group ID is required");
|