dt-common-device 5.1.2 → 5.1.4
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.js +19 -0
- package/dist/entities/accessGroup/AccessGroup.repository.d.ts +2 -1
- package/dist/entities/accessGroup/AccessGroup.repository.js +4 -1
- package/dist/entities/accessGroup/AccessGroup.service.d.ts +2 -1
- package/dist/entities/accessGroup/AccessGroup.service.js +4 -3
- package/dist/entities/admin/Admin.repository.js +1 -1
- package/dist/entities/guest/Guest.repository.d.ts +1 -1
- package/dist/entities/guest/Guest.repository.js +4 -1
- package/dist/entities/guest/Guest.service.d.ts +1 -1
- package/dist/entities/guest/Guest.service.js +4 -1
- package/dist/entities/schedules/Schedule.repository.d.ts +1 -1
- package/dist/entities/schedules/Schedule.repository.js +4 -1
- package/dist/entities/schedules/Schedule.service.d.ts +1 -1
- package/dist/entities/schedules/Schedule.service.js +4 -1
- package/dist/entities/user/User.repository.js +4 -1
- package/dist/entities/user/User.service.d.ts +1 -1
- package/dist/entities/user/User.service.js +4 -1
- package/dist/entities/zone/Zone.service.js +4 -1
- package/package.json +1 -1
package/dist/audit/AuditUtils.js
CHANGED
|
@@ -210,36 +210,55 @@ let AuditUtils = (() => {
|
|
|
210
210
|
async getUserName(userId) {
|
|
211
211
|
return this.getCachedEntityData("user", userId, async () => {
|
|
212
212
|
const user = await typedi_1.default.get(User_service_1.UserService).getUser(userId);
|
|
213
|
+
if (!user)
|
|
214
|
+
return "";
|
|
213
215
|
return `${user?.firstName || ""} ${user?.lastName || ""}`.trim();
|
|
214
216
|
});
|
|
215
217
|
}
|
|
216
218
|
async getGuestName(guestId) {
|
|
217
219
|
return this.getCachedEntityData("guest", guestId, async () => {
|
|
218
220
|
const guest = await typedi_1.default.get(guest_1.GuestService).getGuest(guestId);
|
|
221
|
+
if (!guest)
|
|
222
|
+
return "";
|
|
219
223
|
return `${guest?.firstName || ""} ${guest?.lastName || ""}`.trim();
|
|
220
224
|
});
|
|
221
225
|
}
|
|
222
226
|
async getDeviceName(deviceId) {
|
|
223
227
|
return this.getCachedEntityData("device", deviceId, async () => {
|
|
224
228
|
const device = await typedi_1.default.get(services_1.LocalDeviceService).querySelect({ deviceId }, ["name"]);
|
|
229
|
+
if (!device)
|
|
230
|
+
return "";
|
|
225
231
|
return device[0]?.name || "";
|
|
226
232
|
});
|
|
227
233
|
}
|
|
228
234
|
async getZoneName(zoneId) {
|
|
229
235
|
return this.getCachedEntityData("zone", zoneId, async () => {
|
|
230
236
|
const zone = await typedi_1.default.get(zone_1.ZoneService).getZone(zoneId);
|
|
237
|
+
if (!zone)
|
|
238
|
+
return "";
|
|
231
239
|
return zone?.name || "";
|
|
232
240
|
});
|
|
233
241
|
}
|
|
234
242
|
async getAccessGroupName(accessGroupId) {
|
|
235
243
|
return this.getCachedEntityData("accessGroup", accessGroupId, async () => {
|
|
236
244
|
const accessGroup = await typedi_1.default.get(accessGroup_1.AccessGroupService).getAccessGroup(accessGroupId);
|
|
245
|
+
if (!accessGroup)
|
|
246
|
+
return "";
|
|
237
247
|
return accessGroup?.name || "";
|
|
238
248
|
});
|
|
239
249
|
}
|
|
240
250
|
async getScheduleDetails(scheduleId) {
|
|
241
251
|
return this.getCachedEntityData("schedule", scheduleId, async () => {
|
|
242
252
|
const schedule = await typedi_1.default.get(schedules_1.ScheduleService).getSchedule(scheduleId);
|
|
253
|
+
if (!schedule) {
|
|
254
|
+
return {
|
|
255
|
+
scheduleStartDate: "",
|
|
256
|
+
scheduleEndDate: "",
|
|
257
|
+
scheduleDuration: 0,
|
|
258
|
+
scheduleSource: "",
|
|
259
|
+
scheduleStatus: "",
|
|
260
|
+
};
|
|
261
|
+
}
|
|
243
262
|
const scheduleDuration = this.calculateScheduleDuration(schedule.startTime, schedule.endTime);
|
|
244
263
|
return {
|
|
245
264
|
scheduleStartDate: schedule.startTime,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { IAccessGroup } from "./IAccessGroup";
|
|
1
2
|
export declare class AccessGroupRepository {
|
|
2
3
|
private readonly postgres;
|
|
3
4
|
constructor();
|
|
4
|
-
getAccessGroup(accessGroupId: string): Promise<
|
|
5
|
+
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
5
6
|
}
|
|
@@ -56,7 +56,10 @@ let AccessGroupRepository = (() => {
|
|
|
56
56
|
WHERE "id" = $1
|
|
57
57
|
`;
|
|
58
58
|
const result = await this.postgres.query(query, [accessGroupId]);
|
|
59
|
-
|
|
59
|
+
if (result.rows.length > 0) {
|
|
60
|
+
return result.rows[0];
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
60
63
|
}
|
|
61
64
|
};
|
|
62
65
|
__setFunctionName(_classThis, "AccessGroupRepository");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { IAccessGroup } from "./IAccessGroup";
|
|
1
2
|
export declare class AccessGroupService {
|
|
2
3
|
private readonly accessGroupRepository;
|
|
3
4
|
constructor();
|
|
4
|
-
getAccessGroup(accessGroupId: string): Promise<
|
|
5
|
+
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
5
6
|
}
|
|
@@ -87,7 +87,10 @@ let AccessGroupService = (() => {
|
|
|
87
87
|
if (!accessGroupId) {
|
|
88
88
|
throw new Error("Access Group ID is required");
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
const accessGroup = await this.accessGroupRepository.getAccessGroup(accessGroupId);
|
|
91
|
+
if (!accessGroup)
|
|
92
|
+
return null;
|
|
93
|
+
return accessGroup;
|
|
91
94
|
}
|
|
92
95
|
};
|
|
93
96
|
__setFunctionName(_classThis, "AccessGroupService");
|
|
@@ -101,5 +104,3 @@ let AccessGroupService = (() => {
|
|
|
101
104
|
return AccessGroupService = _classThis;
|
|
102
105
|
})();
|
|
103
106
|
exports.AccessGroupService = AccessGroupService;
|
|
104
|
-
// Accessgroup.getAccessGroup(accessGroupId)
|
|
105
|
-
// GetAccessGroup()
|
|
@@ -114,7 +114,7 @@ let AdminRepository = (() => {
|
|
|
114
114
|
const collectionZone = [];
|
|
115
115
|
for (let i = 0; i < response.length; i++) {
|
|
116
116
|
let zoneIds = [];
|
|
117
|
-
const zones = await this.axiosInstance.get(`/zones/child?zoneId=${response[i].zoneId}`);
|
|
117
|
+
const zones = await this.axiosInstance.get(`/zones/child?zoneId=${response[i].zoneId}`).data.data;
|
|
118
118
|
zoneIds.push(response[i].zoneId);
|
|
119
119
|
if (zones.childZones?.length > 0) {
|
|
120
120
|
const nestedZoneIds = new Set(_zones(zones.childZones));
|
|
@@ -53,7 +53,10 @@ let GuestRepository = (() => {
|
|
|
53
53
|
async getGuest(guestId) {
|
|
54
54
|
try {
|
|
55
55
|
const guest = await this.pmsPostgres.query(`SELECT * FROM dt_guest WHERE "id" = $1`, [guestId]);
|
|
56
|
-
|
|
56
|
+
if (guest.rows.length > 0) {
|
|
57
|
+
return guest.rows[0];
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
57
60
|
}
|
|
58
61
|
catch (error) {
|
|
59
62
|
console.error("Error in getGuest:", error);
|
|
@@ -88,7 +88,10 @@ let GuestService = (() => {
|
|
|
88
88
|
if (!guestId) {
|
|
89
89
|
throw new Error("Guest ID is required");
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
const guest = await this.guestRepository.getGuest(guestId);
|
|
92
|
+
if (!guest)
|
|
93
|
+
return null;
|
|
94
|
+
return guest;
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
__setFunctionName(_classThis, "GuestService");
|
|
@@ -53,7 +53,10 @@ let ScheduleRepository = (() => {
|
|
|
53
53
|
async getSchedule(scheduleId) {
|
|
54
54
|
try {
|
|
55
55
|
const schedule = await this.pmsPostgres.query(`SELECT * FROM dt_schedule WHERE "id" = $1`, [scheduleId]);
|
|
56
|
-
|
|
56
|
+
if (schedule.rows.length > 0) {
|
|
57
|
+
return schedule.rows[0];
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
57
60
|
}
|
|
58
61
|
catch (error) {
|
|
59
62
|
console.error("Error in getSchedule:", error);
|
|
@@ -88,7 +88,10 @@ let ScheduleService = (() => {
|
|
|
88
88
|
if (!scheduleId) {
|
|
89
89
|
throw new Error("Schedule ID is required");
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
const schedule = await this.scheduleRepository.getSchedule(scheduleId);
|
|
92
|
+
if (!schedule)
|
|
93
|
+
return null;
|
|
94
|
+
return schedule;
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
__setFunctionName(_classThis, "ScheduleService");
|
|
@@ -52,7 +52,10 @@ let UserRepository = (() => {
|
|
|
52
52
|
}
|
|
53
53
|
async getUser(userId) {
|
|
54
54
|
const user = await this.postgres.query(`SELECT * FROM dt_users WHERE "id" = $1`, [userId]);
|
|
55
|
-
|
|
55
|
+
if (user.rows.length > 0) {
|
|
56
|
+
return user.rows[0];
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
56
59
|
}
|
|
57
60
|
};
|
|
58
61
|
__setFunctionName(_classThis, "UserRepository");
|
|
@@ -87,7 +87,10 @@ let UserService = (() => {
|
|
|
87
87
|
if (!userId) {
|
|
88
88
|
throw new Error("User ID is required");
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
const user = await this.userRepository.getUser(userId);
|
|
91
|
+
if (!user)
|
|
92
|
+
return null;
|
|
93
|
+
return user;
|
|
91
94
|
}
|
|
92
95
|
};
|
|
93
96
|
__setFunctionName(_classThis, "UserService");
|
|
@@ -88,7 +88,10 @@ let ZoneService = (() => {
|
|
|
88
88
|
if (!zoneId) {
|
|
89
89
|
throw new Error("Zone ID is required");
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
const zone = await this.zoneRepository.getZone(zoneId);
|
|
92
|
+
if (!zone)
|
|
93
|
+
return null;
|
|
94
|
+
return zone;
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
__setFunctionName(_classThis, "ZoneService");
|