dt-common-device 5.1.2 → 5.1.3

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.
@@ -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<any>;
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
- return result.rows[0];
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<any>;
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
- return await this.accessGroupRepository.getAccessGroup(accessGroupId);
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()
@@ -2,5 +2,5 @@ import { IGuest } from "./IGuest";
2
2
  export declare class GuestRepository {
3
3
  private readonly pmsPostgres;
4
4
  constructor();
5
- getGuest(guestId: string): Promise<IGuest>;
5
+ getGuest(guestId: string): Promise<IGuest | null>;
6
6
  }
@@ -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
- return guest.rows[0];
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);
@@ -2,5 +2,5 @@ import { IGuest } from "./IGuest";
2
2
  export declare class GuestService {
3
3
  private readonly guestRepository;
4
4
  constructor();
5
- getGuest(guestId: string): Promise<IGuest>;
5
+ getGuest(guestId: string): Promise<IGuest | null>;
6
6
  }
@@ -88,7 +88,10 @@ let GuestService = (() => {
88
88
  if (!guestId) {
89
89
  throw new Error("Guest ID is required");
90
90
  }
91
- return await this.guestRepository.getGuest(guestId);
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");
@@ -2,5 +2,5 @@ import { ISchedule } from "./ISchedule";
2
2
  export declare class ScheduleRepository {
3
3
  private readonly pmsPostgres;
4
4
  constructor();
5
- getSchedule(scheduleId: string): Promise<ISchedule>;
5
+ getSchedule(scheduleId: string): Promise<ISchedule | null>;
6
6
  }
@@ -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
- return schedule.rows[0];
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);
@@ -2,5 +2,5 @@ import { ISchedule } from "./ISchedule";
2
2
  export declare class ScheduleService {
3
3
  private readonly scheduleRepository;
4
4
  constructor();
5
- getSchedule(scheduleId: string): Promise<ISchedule>;
5
+ getSchedule(scheduleId: string): Promise<ISchedule | null>;
6
6
  }
@@ -88,7 +88,10 @@ let ScheduleService = (() => {
88
88
  if (!scheduleId) {
89
89
  throw new Error("Schedule ID is required");
90
90
  }
91
- return await this.scheduleRepository.getSchedule(scheduleId);
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
- return user.rows[0];
55
+ if (user.rows.length > 0) {
56
+ return user.rows[0];
57
+ }
58
+ return null;
56
59
  }
57
60
  };
58
61
  __setFunctionName(_classThis, "UserRepository");
@@ -2,5 +2,5 @@ import { IUser } from "./IUser";
2
2
  export declare class UserService {
3
3
  private readonly userRepository;
4
4
  constructor();
5
- getUser(userId: string): Promise<IUser>;
5
+ getUser(userId: string): Promise<IUser | null>;
6
6
  }
@@ -87,7 +87,10 @@ let UserService = (() => {
87
87
  if (!userId) {
88
88
  throw new Error("User ID is required");
89
89
  }
90
- return await this.userRepository.getUser(userId);
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
- return await this.zoneRepository.getZone(zoneId);
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");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "5.1.2",
3
+ "version": "5.1.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [