dt-common-device 11.0.5 → 11.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit/AuditUtils.d.ts +3 -0
- package/dist/audit/AuditUtils.js +67 -12
- 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
|
@@ -18,8 +18,11 @@ export declare class AuditUtils {
|
|
|
18
18
|
private getPropertyName;
|
|
19
19
|
private getFieldFromDevice;
|
|
20
20
|
private getUserName;
|
|
21
|
+
private getGuestName;
|
|
21
22
|
private getDeviceName;
|
|
22
23
|
private getZoneName;
|
|
23
24
|
private getAccessGroupName;
|
|
25
|
+
private getScheduleId;
|
|
26
|
+
private getReferenceId;
|
|
24
27
|
private getScheduleDetails;
|
|
25
28
|
}
|
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") {
|
|
@@ -162,22 +162,32 @@ let AuditUtils = (() => {
|
|
|
162
162
|
if (userId && !userName)
|
|
163
163
|
audit.userName = await this.getUserName(userId);
|
|
164
164
|
if (guestId && !guestName)
|
|
165
|
-
audit.guestName =
|
|
166
|
-
if (guestName)
|
|
167
|
-
audit.guestName = "Guest";
|
|
165
|
+
audit.guestName = await this.getGuestName(guestId);
|
|
168
166
|
if (deviceId && !deviceName) {
|
|
169
167
|
audit.deviceName = await this.getDeviceName(deviceId);
|
|
170
168
|
}
|
|
171
169
|
if (accessGroupId && !accessGroupName)
|
|
172
170
|
audit.accessGroupName = await this.getAccessGroupName(accessGroupId);
|
|
173
|
-
if (scheduleId)
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
audit.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
+
// }
|
|
181
191
|
}
|
|
182
192
|
catch (error) {
|
|
183
193
|
(0, config_1.getLogger)().error(`Error in populateAuditFields: ${error instanceof Error ? error.message : error}`);
|
|
@@ -256,6 +266,20 @@ let AuditUtils = (() => {
|
|
|
256
266
|
return "";
|
|
257
267
|
}
|
|
258
268
|
}
|
|
269
|
+
async getGuestName(guestId) {
|
|
270
|
+
try {
|
|
271
|
+
return await this.getCachedEntityData("guest", guestId, async () => {
|
|
272
|
+
const guest = await typedi_1.default.get(pms_1.PmsService).getGuest(guestId);
|
|
273
|
+
if (!guest)
|
|
274
|
+
return "";
|
|
275
|
+
return `${guest?.firstName || ""} ${guest?.lastName || ""}`.trim();
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
(0, config_1.getLogger)().error(`Error in getGuestName: ${error instanceof Error ? error.message : error}`);
|
|
280
|
+
return "";
|
|
281
|
+
}
|
|
282
|
+
}
|
|
259
283
|
async getDeviceName(deviceId) {
|
|
260
284
|
try {
|
|
261
285
|
return await this.getCachedEntityData("device", deviceId, async () => {
|
|
@@ -298,6 +322,34 @@ let AuditUtils = (() => {
|
|
|
298
322
|
return "";
|
|
299
323
|
}
|
|
300
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
|
+
}
|
|
301
353
|
async getScheduleDetails(scheduleId) {
|
|
302
354
|
try {
|
|
303
355
|
return await this.getCachedEntityData("schedule", scheduleId, async () => {
|
|
@@ -309,6 +361,7 @@ let AuditUtils = (() => {
|
|
|
309
361
|
scheduleDuration: 0,
|
|
310
362
|
scheduleSource: "",
|
|
311
363
|
scheduleStatus: "",
|
|
364
|
+
referenceId: "",
|
|
312
365
|
};
|
|
313
366
|
}
|
|
314
367
|
const scheduleDuration = this.calculateScheduleDuration(schedule.startTime, schedule.endTime);
|
|
@@ -318,6 +371,7 @@ let AuditUtils = (() => {
|
|
|
318
371
|
scheduleDuration,
|
|
319
372
|
scheduleSource: schedule.source,
|
|
320
373
|
scheduleStatus: schedule.status,
|
|
374
|
+
referenceId: schedule.referenceId,
|
|
321
375
|
};
|
|
322
376
|
});
|
|
323
377
|
}
|
|
@@ -329,6 +383,7 @@ let AuditUtils = (() => {
|
|
|
329
383
|
scheduleDuration: 0,
|
|
330
384
|
scheduleSource: "",
|
|
331
385
|
scheduleStatus: "",
|
|
386
|
+
referenceId: "",
|
|
332
387
|
};
|
|
333
388
|
}
|
|
334
389
|
}
|
|
@@ -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");
|