dt-common-device 7.1.1 → 7.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.
Files changed (196) hide show
  1. package/dist/alerts/Alert.model.d.ts +1 -1
  2. package/dist/entities/accessGroup/AccessGroup.repository.d.ts +2 -1
  3. package/dist/entities/accessGroup/AccessGroup.repository.js +4 -1
  4. package/dist/entities/accessGroup/AccessGroup.service.d.ts +2 -1
  5. package/dist/entities/accessGroup/AccessGroup.service.js +4 -3
  6. package/dist/entities/guest/Guest.repository.d.ts +1 -1
  7. package/dist/entities/guest/Guest.repository.js +5 -2
  8. package/dist/entities/guest/Guest.service.d.ts +1 -1
  9. package/dist/entities/guest/Guest.service.js +4 -1
  10. package/dist/entities/schedules/Schedule.repository.d.ts +1 -1
  11. package/dist/entities/schedules/Schedule.repository.js +5 -2
  12. package/dist/entities/schedules/Schedule.service.d.ts +1 -1
  13. package/dist/entities/schedules/Schedule.service.js +4 -1
  14. package/dist/entities/user/User.repository.js +4 -1
  15. package/dist/entities/user/User.service.d.ts +1 -1
  16. package/dist/entities/user/User.service.js +4 -1
  17. package/dist/entities/zone/Zone.service.js +4 -1
  18. package/dist/issues/Issue.model.d.ts +1 -1
  19. package/dist/issues/Issue.model.js +6 -1
  20. package/dist/issues/Issue.service.d.ts +9 -1
  21. package/dist/issues/Issue.service.js +15 -3
  22. package/dist/issues/IssueBuilder.d.ts +9 -8
  23. package/dist/issues/IssueBuilder.js +38 -21
  24. package/dist/issues/issue.types.d.ts +29 -4
  25. package/dist/issues/issue.types.js +23 -1
  26. package/package.json +1 -1
  27. package/dist/admin/Admin.repository.d.ts +0 -7
  28. package/dist/admin/Admin.repository.js +0 -182
  29. package/dist/admin/Admin.service.d.ts +0 -5
  30. package/dist/admin/Admin.service.js +0 -17
  31. package/dist/admin/index.d.ts +0 -1
  32. package/dist/admin/index.js +0 -17
  33. package/dist/audit/AuditProperties.d.ts +0 -16
  34. package/dist/audit/AuditProperties.js +0 -2
  35. package/dist/connection/Connection.repository.d.ts +0 -8
  36. package/dist/connection/Connection.repository.js +0 -92
  37. package/dist/connection/Connection.service.d.ts +0 -8
  38. package/dist/connection/Connection.service.js +0 -32
  39. package/dist/connection/IConnection.d.ts +0 -28
  40. package/dist/connection/IConnection.js +0 -16
  41. package/dist/connection/index.d.ts +0 -2
  42. package/dist/connection/index.js +0 -18
  43. package/dist/device/cloud/entities/CloudConnection.d.ts +0 -6
  44. package/dist/device/cloud/entities/CloudConnection.js +0 -6
  45. package/dist/device/cloud/entities/CloudDevice.d.ts +0 -16
  46. package/dist/device/cloud/entities/CloudDevice.js +0 -26
  47. package/dist/device/cloud/entities/CloudDeviceService.d.ts +0 -5
  48. package/dist/device/cloud/entities/CloudDeviceService.js +0 -9
  49. package/dist/device/cloud/entities/DeviceFactory.d.ts +0 -7
  50. package/dist/device/cloud/entities/DeviceFactory.js +0 -80
  51. package/dist/device/cloud/entities/index.d.ts +0 -3
  52. package/dist/device/cloud/entities/index.js +0 -19
  53. package/dist/device/cloud/interface.d.ts +0 -101
  54. package/dist/device/cloud/interface.js +0 -3
  55. package/dist/device/cloud/interfaces/ICloudConnection.d.ts +0 -5
  56. package/dist/device/cloud/interfaces/ICloudConnection.js +0 -2
  57. package/dist/device/cloud/interfaces/ICloudDevice.d.ts +0 -9
  58. package/dist/device/cloud/interfaces/ICloudDevice.js +0 -2
  59. package/dist/device/cloud/interfaces/ICloudDeviceService.d.ts +0 -4
  60. package/dist/device/cloud/interfaces/ICloudDeviceService.js +0 -2
  61. package/dist/device/cloud/interfaces/IConnectionService.d.ts +0 -7
  62. package/dist/device/cloud/interfaces/IConnectionService.js +0 -2
  63. package/dist/device/cloud/interfaces/IDeviceConnectionService.d.ts +0 -7
  64. package/dist/device/cloud/interfaces/IDeviceConnectionService.js +0 -3
  65. package/dist/device/cloud/interfaces/IDeviceFactory.d.ts +0 -4
  66. package/dist/device/cloud/interfaces/IDeviceFactory.js +0 -2
  67. package/dist/device/cloud/interfaces/IDeviceService.d.ts +0 -8
  68. package/dist/device/cloud/interfaces/IDeviceService.js +0 -2
  69. package/dist/device/cloud/interfaces/IDevicesService.d.ts +0 -9
  70. package/dist/device/cloud/interfaces/IDevicesService.js +0 -2
  71. package/dist/device/cloud/interfaces/IHubService.d.ts +0 -5
  72. package/dist/device/cloud/interfaces/IHubService.js +0 -2
  73. package/dist/device/cloud/interfaces/IRawDataTransformer.d.ts +0 -4
  74. package/dist/device/cloud/interfaces/IRawDataTransformer.js +0 -2
  75. package/dist/device/cloud/interfaces/IRawDevice.d.ts +0 -17
  76. package/dist/device/cloud/interfaces/IRawDevice.js +0 -11
  77. package/dist/device/cloud/interfaces/index.d.ts +0 -5
  78. package/dist/device/cloud/interfaces/index.js +0 -21
  79. package/dist/device/cloud/services/CloudDevice.service.d.ts +0 -5
  80. package/dist/device/cloud/services/CloudDevice.service.js +0 -9
  81. package/dist/device/cloud/services/Connection.service.d.ts +0 -8
  82. package/dist/device/cloud/services/Connection.service.js +0 -6
  83. package/dist/device/cloud/services/Device.service.d.ts +0 -39
  84. package/dist/device/cloud/services/Device.service.js +0 -9
  85. package/dist/device/cloud/services/DeviceCloudService.d.ts +0 -42
  86. package/dist/device/cloud/services/DeviceCloudService.js +0 -59
  87. package/dist/device/cloud/services/DeviceHub.service.d.ts +0 -3
  88. package/dist/device/cloud/services/DeviceHub.service.js +0 -6
  89. package/dist/device/cloud/services/Hub.service.d.ts +0 -25
  90. package/dist/device/cloud/services/Hub.service.js +0 -9
  91. package/dist/device/cloud/services/SmartThingsDeviceService.d.ts +0 -38
  92. package/dist/device/cloud/services/SmartThingsDeviceService.js +0 -52
  93. package/dist/device/cloud/services/index.d.ts +0 -2
  94. package/dist/device/cloud/services/index.js +0 -18
  95. package/dist/device/cloud/types.d.ts +0 -52
  96. package/dist/device/cloud/types.js +0 -15
  97. package/dist/device/index.d.ts +0 -4
  98. package/dist/device/index.js +0 -20
  99. package/dist/device/local/entities/AlertBuilder.d.ts +0 -87
  100. package/dist/device/local/entities/AlertBuilder.example.d.ts +0 -11
  101. package/dist/device/local/entities/AlertBuilder.example.js +0 -117
  102. package/dist/device/local/entities/AlertBuilder.js +0 -179
  103. package/dist/device/local/entities/IssueBuilder.d.ts +0 -109
  104. package/dist/device/local/entities/IssueBuilder.example.d.ts +0 -16
  105. package/dist/device/local/entities/IssueBuilder.example.js +0 -196
  106. package/dist/device/local/entities/IssueBuilder.js +0 -237
  107. package/dist/device/local/entities/index.d.ts +0 -2
  108. package/dist/device/local/entities/index.js +0 -7
  109. package/dist/device/local/events/EventHandler.d.ts +0 -11
  110. package/dist/device/local/events/EventHandler.js +0 -86
  111. package/dist/device/local/events/Events.d.ts +0 -54
  112. package/dist/device/local/events/Events.js +0 -57
  113. package/dist/device/local/events/index.d.ts +0 -2
  114. package/dist/device/local/events/index.js +0 -7
  115. package/dist/device/local/handler/EventHandler.d.ts +0 -7
  116. package/dist/device/local/handler/EventHandler.js +0 -44
  117. package/dist/device/local/interface.d.ts +0 -0
  118. package/dist/device/local/interface.js +0 -1
  119. package/dist/device/local/interfaces/IConnection.d.ts +0 -26
  120. package/dist/device/local/interfaces/IConnection.js +0 -14
  121. package/dist/device/local/interfaces/IDevice.d.ts +0 -68
  122. package/dist/device/local/interfaces/IDevice.js +0 -10
  123. package/dist/device/local/interfaces/IDtDevice.d.ts +0 -16
  124. package/dist/device/local/interfaces/IDtDevice.js +0 -2
  125. package/dist/device/local/interfaces/IHub.d.ts +0 -46
  126. package/dist/device/local/interfaces/IHub.js +0 -2
  127. package/dist/device/local/interfaces/IProperty.d.ts +0 -29
  128. package/dist/device/local/interfaces/IProperty.js +0 -2
  129. package/dist/device/local/interfaces/ISchedule.d.ts +0 -25
  130. package/dist/device/local/interfaces/ISchedule.js +0 -2
  131. package/dist/device/local/interfaces/index.d.ts +0 -3
  132. package/dist/device/local/interfaces/index.js +0 -19
  133. package/dist/device/local/models/Alert.model.d.ts +0 -28
  134. package/dist/device/local/models/Alert.model.js +0 -222
  135. package/dist/device/local/models/Issue.model.d.ts +0 -28
  136. package/dist/device/local/models/Issue.model.js +0 -260
  137. package/dist/device/local/repository/Alert.repository.d.ts +0 -106
  138. package/dist/device/local/repository/Alert.repository.js +0 -374
  139. package/dist/device/local/repository/Connection.repository.d.ts +0 -8
  140. package/dist/device/local/repository/Connection.repository.js +0 -92
  141. package/dist/device/local/repository/Device.repository.d.ts +0 -30
  142. package/dist/device/local/repository/Device.repository.js +0 -325
  143. package/dist/device/local/repository/Hub.repository.d.ts +0 -13
  144. package/dist/device/local/repository/Hub.repository.js +0 -139
  145. package/dist/device/local/repository/Issue.repository.d.ts +0 -113
  146. package/dist/device/local/repository/Issue.repository.js +0 -401
  147. package/dist/device/local/repository/Property.repository.d.ts +0 -8
  148. package/dist/device/local/repository/Property.repository.js +0 -95
  149. package/dist/device/local/repository/Schedule.repository.d.ts +0 -9
  150. package/dist/device/local/repository/Schedule.repository.js +0 -109
  151. package/dist/device/local/services/Alert.service.d.ts +0 -137
  152. package/dist/device/local/services/Alert.service.js +0 -475
  153. package/dist/device/local/services/AlertService.example.d.ts +0 -55
  154. package/dist/device/local/services/AlertService.example.js +0 -148
  155. package/dist/device/local/services/Connection.service.d.ts +0 -8
  156. package/dist/device/local/services/Connection.service.js +0 -32
  157. package/dist/device/local/services/Device.service.d.ts +0 -40
  158. package/dist/device/local/services/Device.service.js +0 -391
  159. package/dist/device/local/services/DeviceHub.service.d.ts +0 -11
  160. package/dist/device/local/services/DeviceHub.service.js +0 -40
  161. package/dist/device/local/services/Hub.service.d.ts +0 -12
  162. package/dist/device/local/services/Hub.service.js +0 -107
  163. package/dist/device/local/services/Issue.service.d.ts +0 -168
  164. package/dist/device/local/services/Issue.service.js +0 -642
  165. package/dist/device/local/services/IssueService.example.d.ts +0 -68
  166. package/dist/device/local/services/IssueService.example.js +0 -177
  167. package/dist/device/local/services/Property.service.d.ts +0 -8
  168. package/dist/device/local/services/Property.service.js +0 -36
  169. package/dist/device/local/services/Schedule.service.d.ts +0 -9
  170. package/dist/device/local/services/Schedule.service.js +0 -26
  171. package/dist/device/local/services/index.d.ts +0 -3
  172. package/dist/device/local/services/index.js +0 -19
  173. package/dist/pms/IPms.d.ts +0 -6
  174. package/dist/pms/IPms.js +0 -10
  175. package/dist/pms/index.d.ts +0 -1
  176. package/dist/pms/index.js +0 -17
  177. package/dist/property/IProperty.d.ts +0 -29
  178. package/dist/property/IProperty.js +0 -2
  179. package/dist/property/Property.repository.d.ts +0 -8
  180. package/dist/property/Property.repository.js +0 -109
  181. package/dist/property/Property.service.d.ts +0 -8
  182. package/dist/property/Property.service.js +0 -124
  183. package/dist/property/index.d.ts +0 -2
  184. package/dist/property/index.js +0 -18
  185. package/dist/queue/interfaces/IHttpRequestJob.d.ts +0 -9
  186. package/dist/queue/interfaces/IHttpRequestJob.js +0 -2
  187. package/dist/types/alert.types.d.ts +0 -57
  188. package/dist/types/alert.types.js +0 -22
  189. package/dist/types/config.types.d.ts +0 -19
  190. package/dist/types/config.types.js +0 -2
  191. package/dist/types/index.d.ts +0 -3
  192. package/dist/types/index.js +0 -19
  193. package/dist/types/issue.types.d.ts +0 -90
  194. package/dist/types/issue.types.js +0 -40
  195. package/dist/utils/http-utils.d.ts +0 -13
  196. package/dist/utils/http-utils.js +0 -117
@@ -13,7 +13,7 @@ interface IAlertModel extends Model<IAlertDocument, {}, IAlertMethods> {
13
13
  findSnoozed(includeDeleted?: boolean): Promise<IAlertDocument[]>;
14
14
  findExpiredSnooze(includeDeleted?: boolean): Promise<IAlertDocument[]>;
15
15
  }
16
- declare const AlertSchema: mongoose.Schema<IAlertDocument, IAlertModel, IAlertMethods, {}, {}, {}, mongoose.DefaultSchemaOptions, IAlertDocument, mongoose.Document<unknown, {}, mongoose.FlatRecord<IAlertDocument>, {}> & Omit<mongoose.FlatRecord<IAlertDocument> & Required<{
16
+ declare const AlertSchema: mongoose.Schema<IAlertDocument, IAlertModel, IAlertMethods, {}, {}, {}, mongoose.DefaultSchemaOptions, IAlertDocument, mongoose.Document<unknown, {}, mongoose.FlatRecord<IAlertDocument>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & Omit<mongoose.FlatRecord<IAlertDocument> & Required<{
17
17
  _id: string;
18
18
  }> & {
19
19
  __v: number;
@@ -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
  }
@@ -52,8 +52,11 @@ let GuestRepository = (() => {
52
52
  }
53
53
  async getGuest(guestId) {
54
54
  try {
55
- const guest = await this.pmsPostgres.query(`SELECT * FROM dt_guests WHERE "id" = $1`, [guestId]);
56
- return guest.rows[0];
55
+ const guest = await this.pmsPostgres.query(`SELECT * FROM dt_guest WHERE "id" = $1`, [guestId]);
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
  }
@@ -52,8 +52,11 @@ let ScheduleRepository = (() => {
52
52
  }
53
53
  async getSchedule(scheduleId) {
54
54
  try {
55
- const schedule = await this.pmsPostgres.query(`SELECT * FROM dt_schedules WHERE "id" = $1`, [scheduleId]);
56
- return schedule.rows[0];
55
+ const schedule = await this.pmsPostgres.query(`SELECT * FROM dt_schedule WHERE "id" = $1`, [scheduleId]);
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");
@@ -14,7 +14,7 @@ interface IIssueModel extends Model<IIssueDocument, {}, IIssueMethods> {
14
14
  findOverdue(includeDeleted?: boolean): Promise<IIssueDocument[]>;
15
15
  findUpcoming(days?: number, includeDeleted?: boolean): Promise<IIssueDocument[]>;
16
16
  }
17
- declare const IssueSchema: mongoose.Schema<IIssueDocument, IIssueModel, IIssueMethods, {}, {}, {}, mongoose.DefaultSchemaOptions, IIssueDocument, mongoose.Document<unknown, {}, mongoose.FlatRecord<IIssueDocument>, {}> & Omit<mongoose.FlatRecord<IIssueDocument> & Required<{
17
+ declare const IssueSchema: mongoose.Schema<IIssueDocument, IIssueModel, IIssueMethods, {}, {}, {}, mongoose.DefaultSchemaOptions, IIssueDocument, mongoose.Document<unknown, {}, mongoose.FlatRecord<IIssueDocument>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & Omit<mongoose.FlatRecord<IIssueDocument> & Required<{
18
18
  _id: string;
19
19
  }> & {
20
20
  __v: number;
@@ -58,7 +58,7 @@ const IssueSchema = new mongoose_1.Schema({
58
58
  },
59
59
  zoneId: {
60
60
  type: String,
61
- required: true,
61
+ required: false,
62
62
  index: true,
63
63
  },
64
64
  title: {
@@ -87,6 +87,11 @@ const IssueSchema = new mongoose_1.Schema({
87
87
  default: issue_types_1.IssueStatus.PENDING,
88
88
  index: true,
89
89
  },
90
+ type: {
91
+ type: String,
92
+ enum: Object.values(issue_types_1.IssueType),
93
+ required: true,
94
+ },
90
95
  priority: {
91
96
  type: String,
92
97
  enum: Object.values(issue_types_1.IssuePriority),
@@ -1,5 +1,5 @@
1
1
  import { IIssueDocument } from "./Issue.model";
2
- import { CreateIssueData, UpdateIssueData, AddCommentData, IssuePriority, IssuesCategory, IIssueQuery } from "./issue.types";
2
+ import { CreateIssueData, UpdateIssueData, AddCommentData, IssuePriority, IssuesCategory, EntityType, IIssueQuery } from "./issue.types";
3
3
  import { IssueBuilder } from "./IssueBuilder";
4
4
  import { Source } from "../constants/Service";
5
5
  import { IDevice } from "../entities/device/local/interfaces";
@@ -34,6 +34,14 @@ export declare class IssueService {
34
34
  * Create a user-specific issue using IssueBuilder
35
35
  */
36
36
  createUserIssue(data: CreateIssueData): Promise<IIssueDocument>;
37
+ createCloudAccountAuthorizationIssue(data: {
38
+ propertyId: string;
39
+ entityId: string;
40
+ entityType: EntityType;
41
+ title: string;
42
+ description: string;
43
+ createdBy: string;
44
+ }): Promise<IIssueDocument>;
37
45
  /**
38
46
  * Create issue for device going offline longer than baseline
39
47
  */
@@ -221,6 +221,13 @@ let IssueService = (() => {
221
221
  issueBuilder.setDueDate(data.dueDate);
222
222
  return await this.createIssue(issueBuilder);
223
223
  }
224
+ async createCloudAccountAuthorizationIssue(data) {
225
+ const issueBuilder = IssueBuilder_1.IssueBuilder.createCloudAccountAuthorizationIssue(data.propertyId, data.entityId, data.entityType)
226
+ .setTitle(data.title)
227
+ .setDescription(data.description)
228
+ .setCreatedBy(data.createdBy);
229
+ return await this.createIssue(issueBuilder);
230
+ }
224
231
  /**
225
232
  * Create issue for device going offline longer than baseline
226
233
  */
@@ -235,6 +242,7 @@ let IssueService = (() => {
235
242
  createdBy: source,
236
243
  category: issue_types_1.IssuesCategory.OPERATIONS,
237
244
  priority: issue_types_1.IssuePriority.HIGH,
245
+ type: issue_types_1.IssueType.DEVICE_OFFLINE,
238
246
  });
239
247
  }
240
248
  async createDoorLeftOpenIssue(device, source, reason) {
@@ -249,6 +257,7 @@ let IssueService = (() => {
249
257
  createdBy: source,
250
258
  category: issue_types_1.IssuesCategory.SECURITY,
251
259
  priority: issue_types_1.IssuePriority.HIGH,
260
+ type: issue_types_1.IssueType.DOOR_LEFT_OPEN,
252
261
  });
253
262
  }
254
263
  /**
@@ -265,6 +274,7 @@ let IssueService = (() => {
265
274
  createdBy: source,
266
275
  category: issue_types_1.IssuesCategory.ENERGY,
267
276
  priority: issue_types_1.IssuePriority.MEDIUM,
277
+ type: issue_types_1.IssueType.BATTERY_LOW,
268
278
  });
269
279
  }
270
280
  /**
@@ -281,6 +291,7 @@ let IssueService = (() => {
281
291
  createdBy: source,
282
292
  category: issue_types_1.IssuesCategory.OPERATIONS,
283
293
  priority: issue_types_1.IssuePriority.HIGH,
294
+ type: issue_types_1.IssueType.DEVICE_MALFUNCTION,
284
295
  });
285
296
  }
286
297
  /**
@@ -644,9 +655,7 @@ let IssueService = (() => {
644
655
  if (!data.propertyId) {
645
656
  throw new Error("Property ID is required");
646
657
  }
647
- if (!data.zoneId) {
648
- throw new Error("Zone ID is required");
649
- }
658
+ // Zone ID is now optional, so no validation needed
650
659
  if (!data.createdBy) {
651
660
  throw new Error("Created by user ID is required");
652
661
  }
@@ -673,16 +682,19 @@ let IssueService = (() => {
673
682
  issue_types_1.IssueStatus.IN_PROGRESS,
674
683
  issue_types_1.IssueStatus.CANCELLED,
675
684
  issue_types_1.IssueStatus.ON_HOLD,
685
+ issue_types_1.IssueStatus.IGNORED,
676
686
  ],
677
687
  [issue_types_1.IssueStatus.IN_PROGRESS]: [
678
688
  issue_types_1.IssueStatus.RESOLVED,
679
689
  issue_types_1.IssueStatus.CANCELLED,
680
690
  issue_types_1.IssueStatus.ON_HOLD,
691
+ issue_types_1.IssueStatus.IGNORED,
681
692
  ],
682
693
  [issue_types_1.IssueStatus.RESOLVED]: [issue_types_1.IssueStatus.CLOSED, issue_types_1.IssueStatus.PENDING], // Reopen
683
694
  [issue_types_1.IssueStatus.CLOSED]: [issue_types_1.IssueStatus.PENDING], // Reopen
684
695
  [issue_types_1.IssueStatus.CANCELLED]: [issue_types_1.IssueStatus.PENDING], // Reopen
685
696
  [issue_types_1.IssueStatus.ON_HOLD]: [issue_types_1.IssueStatus.PENDING, issue_types_1.IssueStatus.IN_PROGRESS],
697
+ [issue_types_1.IssueStatus.IGNORED]: [issue_types_1.IssueStatus.PENDING, issue_types_1.IssueStatus.IN_PROGRESS], // Reopen from ignored
686
698
  };
687
699
  if (!validTransitions[currentStatus]?.includes(newStatus)) {
688
700
  throw new Error(`Invalid status transition from ${currentStatus} to ${newStatus}`);
@@ -31,9 +31,9 @@ export declare class IssueBuilder {
31
31
  */
32
32
  setPropertyId(propertyId: string): this;
33
33
  /**
34
- * Sets the zone ID
34
+ * Sets the zone ID (optional)
35
35
  */
36
- setZoneId(zoneId: string): this;
36
+ setZoneId(zoneId?: string): this;
37
37
  /**
38
38
  * Sets the issue title
39
39
  */
@@ -89,25 +89,26 @@ export declare class IssueBuilder {
89
89
  /**
90
90
  * Creates a device-specific issue builder
91
91
  */
92
- static createDeviceIssue(deviceId: string, propertyId: string, zoneId: string): IssueBuilder;
92
+ static createDeviceIssue(deviceId: string, propertyId: string, zoneId?: string): IssueBuilder;
93
93
  /**
94
94
  * Creates a hub-specific issue builder
95
95
  */
96
- static createHubIssue(hubId: string, propertyId: string, zoneId: string): IssueBuilder;
96
+ static createHubIssue(hubId: string, propertyId: string, zoneId?: string): IssueBuilder;
97
97
  /**
98
98
  * Creates a user-specific issue builder
99
99
  */
100
- static createUserIssue(userId: string, propertyId: string, zoneId: string): IssueBuilder;
100
+ static createUserIssue(userId: string, propertyId: string, zoneId?: string): IssueBuilder;
101
101
  /**
102
102
  * Creates a property-specific issue builder
103
103
  */
104
- static createPropertyIssue(propertyId: string, zoneId: string): IssueBuilder;
104
+ static createPropertyIssue(propertyId: string, zoneId?: string): IssueBuilder;
105
105
  /**
106
106
  * Creates a maintenance issue builder
107
107
  */
108
- static createMaintenanceIssue(propertyId: string, zoneId: string, entityId?: string, entityType?: EntityType): IssueBuilder;
108
+ static createMaintenanceIssue(propertyId: string, zoneId?: string, entityId?: string, entityType?: EntityType): IssueBuilder;
109
109
  /**
110
110
  * Creates an urgent issue builder
111
111
  */
112
- static createUrgentIssue(propertyId: string, zoneId: string, entityId?: string, entityType?: EntityType): IssueBuilder;
112
+ static createUrgentIssue(propertyId: string, zoneId?: string, entityId?: string, entityType?: EntityType): IssueBuilder;
113
+ static createCloudAccountAuthorizationIssue(propertyId: string, entityId: string, entityType: EntityType): IssueBuilder;
113
114
  }
@@ -45,13 +45,15 @@ class IssueBuilder {
45
45
  return this;
46
46
  }
47
47
  /**
48
- * Sets the zone ID
48
+ * Sets the zone ID (optional)
49
49
  */
50
50
  setZoneId(zoneId) {
51
- if (!zoneId || zoneId.trim() === "") {
52
- throw new Error("Zone ID is required and cannot be empty");
51
+ if (zoneId !== undefined) {
52
+ if (zoneId.trim() === "") {
53
+ throw new Error("Zone ID cannot be empty if provided");
54
+ }
55
+ this.data.zoneId = zoneId.trim();
53
56
  }
54
- this.data.zoneId = zoneId;
55
57
  return this;
56
58
  }
57
59
  /**
@@ -134,7 +136,6 @@ class IssueBuilder {
134
136
  const requiredFields = [
135
137
  "category",
136
138
  "propertyId",
137
- "zoneId",
138
139
  "title",
139
140
  "description",
140
141
  "entityId",
@@ -192,41 +193,49 @@ class IssueBuilder {
192
193
  * Creates a device-specific issue builder
193
194
  */
194
195
  static createDeviceIssue(deviceId, propertyId, zoneId) {
195
- return new IssueBuilder()
196
+ const builder = new IssueBuilder()
196
197
  .setEntityType(issue_types_1.EntityType.DEVICE)
197
198
  .setEntityId(deviceId)
198
- .setPropertyId(propertyId)
199
- .setZoneId(zoneId);
199
+ .setPropertyId(propertyId);
200
+ if (zoneId)
201
+ builder.setZoneId(zoneId);
202
+ return builder;
200
203
  }
201
204
  /**
202
205
  * Creates a hub-specific issue builder
203
206
  */
204
207
  static createHubIssue(hubId, propertyId, zoneId) {
205
- return new IssueBuilder()
208
+ const builder = new IssueBuilder()
206
209
  .setEntityType(issue_types_1.EntityType.HUB)
207
210
  .setEntityId(hubId)
208
- .setPropertyId(propertyId)
209
- .setZoneId(zoneId);
211
+ .setPropertyId(propertyId);
212
+ if (zoneId)
213
+ builder.setZoneId(zoneId);
214
+ return builder;
210
215
  }
211
216
  /**
212
217
  * Creates a user-specific issue builder
213
218
  */
214
219
  static createUserIssue(userId, propertyId, zoneId) {
215
- return new IssueBuilder()
220
+ const builder = new IssueBuilder()
216
221
  .setEntityType(issue_types_1.EntityType.USER)
217
222
  .setEntityId(userId)
218
- .setPropertyId(propertyId)
219
- .setZoneId(zoneId);
223
+ .setPropertyId(propertyId);
224
+ if (zoneId)
225
+ builder.setZoneId(zoneId);
226
+ return builder;
220
227
  }
221
228
  /**
222
229
  * Creates a property-specific issue builder
223
230
  */
224
231
  static createPropertyIssue(propertyId, zoneId) {
225
- return new IssueBuilder()
232
+ const builder = new IssueBuilder()
226
233
  .setEntityType(issue_types_1.EntityType.PROPERTY)
227
234
  .setEntityId(propertyId)
228
- .setPropertyId(propertyId)
229
- .setZoneId(zoneId);
235
+ .setPropertyId(propertyId);
236
+ if (zoneId)
237
+ builder.setZoneId(zoneId);
238
+ return builder;
230
239
  }
231
240
  /**
232
241
  * Creates a maintenance issue builder
@@ -234,13 +243,13 @@ class IssueBuilder {
234
243
  static createMaintenanceIssue(propertyId, zoneId, entityId, entityType) {
235
244
  const builder = new IssueBuilder()
236
245
  .setCategory(issue_types_1.IssuesCategory.READINESS)
237
- .setPropertyId(propertyId)
238
- .setZoneId(zoneId)
239
- .setPriority(issue_types_1.IssuePriority.MEDIUM);
246
+ .setPropertyId(propertyId);
240
247
  if (entityId)
241
248
  builder.setEntityId(entityId);
242
249
  if (entityType)
243
250
  builder.setEntityType(entityType);
251
+ if (zoneId)
252
+ builder.setZoneId(zoneId);
244
253
  return builder;
245
254
  }
246
255
  /**
@@ -250,12 +259,20 @@ class IssueBuilder {
250
259
  const builder = new IssueBuilder()
251
260
  .setCategory(issue_types_1.IssuesCategory.OPERATIONS)
252
261
  .setPropertyId(propertyId)
253
- .setZoneId(zoneId)
254
262
  .setPriority(issue_types_1.IssuePriority.URGENT);
255
263
  if (entityId)
256
264
  builder.setEntityId(entityId);
257
265
  if (entityType)
258
266
  builder.setEntityType(entityType);
267
+ if (zoneId)
268
+ builder.setZoneId(zoneId);
269
+ return builder;
270
+ }
271
+ static createCloudAccountAuthorizationIssue(propertyId, entityId, entityType) {
272
+ const builder = new IssueBuilder()
273
+ .setEntityType(entityType)
274
+ .setEntityId(entityId)
275
+ .setPropertyId(propertyId);
259
276
  return builder;
260
277
  }
261
278
  }
@@ -14,7 +14,9 @@ export declare enum EntityType {
14
14
  HUB = "HUB",
15
15
  SCHEDULE = "SCHEDULE",
16
16
  ALERT = "ALERT",
17
- OTHER = "OTHER"
17
+ OTHER = "OTHER",
18
+ CLOUD_DEVICE_ACCOUNT = "CLOUD_DEVICE_ACCOUNT",
19
+ CLOUD_PMS_ACCOUNT = "CLOUD_PMS_ACCOUNT"
18
20
  }
19
21
  export declare enum IssueStatus {
20
22
  PENDING = "PENDING",
@@ -22,7 +24,8 @@ export declare enum IssueStatus {
22
24
  RESOLVED = "RESOLVED",
23
25
  CLOSED = "CLOSED",
24
26
  CANCELLED = "CANCELLED",
25
- ON_HOLD = "ON_HOLD"
27
+ ON_HOLD = "ON_HOLD",
28
+ IGNORED = "IGNORED"
26
29
  }
27
30
  export declare enum IssuePriority {
28
31
  LOW = "LOW",
@@ -38,17 +41,36 @@ export interface IssueComment {
38
41
  createdAt: Date;
39
42
  updatedAt?: Date;
40
43
  }
44
+ export declare enum IssueType {
45
+ BATTERY_LOW = "BATTERY_LOW",
46
+ DEVICE_OFFLINE = "DEVICE_OFFLINE",
47
+ HUB_OFFLINE = "HUB_OFFLINE",
48
+ ACCOUNT_UNAUTHORIZED = "ACCOUNT_UNAUTHORIZED",
49
+ ACCOUNT_NEW_DEVICE = "ACCOUNT_NEW_DEVICE",
50
+ ACCOUNT_MISSING_DEVICE = "ACCOUNT_MISSING_DEVICE",
51
+ DEVICE_TAMPER_ATTEMPT = "DEVICE_TAMPER_ATTEMPT",
52
+ LOCK_JAMMED = "LOCK_JAMMED",
53
+ DEVICE_MALFUNCTION = "DEVICE_MALFUNCTION",
54
+ DOOR_LEFT_OPEN = "DOOR_LEFT_OPEN",
55
+ DOOR_OPEN_FREQUENT = "DOOR_OPEN_FREQUENT",
56
+ DOOR_OPEN_OUTSIDE_BIZ_HOURS = "DOOR_OPEN_OUTSIDE_BIZ_HOURS",
57
+ LOCK_ACCESS_EMERGENCY_CODE = "LOCK_ACCESS_EMERGENCY_CODE",
58
+ LOCK_ACCESS_MASTER_CODE = "LOCK_ACCESS_MASTER_CODE",
59
+ SPECIFIC_DOOR_ACCESS = "SPECIFIC_DOOR_ACCESS",
60
+ GUEST_LOCK_FIRST_ACCESS = "GUEST_LOCK_FIRST_ACCESS"
61
+ }
41
62
  export interface IssueDocument {
42
63
  _id: string;
43
64
  category: IssuesCategory;
44
65
  propertyId: string;
45
- zoneId: string;
66
+ zoneId?: string;
46
67
  title: string;
47
68
  description: string;
48
69
  entityId?: string;
49
70
  entityType: EntityType;
50
71
  status: IssueStatus;
51
72
  priority: IssuePriority;
73
+ type: IssueType;
52
74
  assignedTo?: string;
53
75
  createdBy: string;
54
76
  updatedBy?: string;
@@ -62,11 +84,12 @@ export interface IssueDocument {
62
84
  export interface CreateIssueData {
63
85
  category: IssuesCategory;
64
86
  propertyId: string;
65
- zoneId: string;
87
+ zoneId?: string;
66
88
  title: string;
67
89
  description: string;
68
90
  entityId: string;
69
91
  entityType: EntityType;
92
+ type: IssueType;
70
93
  priority?: IssuePriority;
71
94
  assignedTo?: string;
72
95
  createdBy: string;
@@ -79,6 +102,7 @@ export interface UpdateIssueData {
79
102
  entityId?: string;
80
103
  entityType?: EntityType;
81
104
  status?: IssueStatus;
105
+ type?: IssueType;
82
106
  priority?: IssuePriority;
83
107
  assignedTo?: string;
84
108
  updatedBy?: string;
@@ -96,6 +120,7 @@ export interface IIssueQuery {
96
120
  assignedTo?: string;
97
121
  status?: IssueStatus;
98
122
  priority?: IssuePriority;
123
+ type?: IssueType;
99
124
  category?: IssuesCategory;
100
125
  entityType?: EntityType;
101
126
  entityId?: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IssuePriority = exports.IssueStatus = exports.EntityType = exports.IssuesCategory = void 0;
3
+ exports.IssueType = exports.IssuePriority = exports.IssueStatus = exports.EntityType = exports.IssuesCategory = void 0;
4
4
  var IssuesCategory;
5
5
  (function (IssuesCategory) {
6
6
  IssuesCategory["READINESS"] = "READINESS";
@@ -20,6 +20,8 @@ var EntityType;
20
20
  EntityType["SCHEDULE"] = "SCHEDULE";
21
21
  EntityType["ALERT"] = "ALERT";
22
22
  EntityType["OTHER"] = "OTHER";
23
+ EntityType["CLOUD_DEVICE_ACCOUNT"] = "CLOUD_DEVICE_ACCOUNT";
24
+ EntityType["CLOUD_PMS_ACCOUNT"] = "CLOUD_PMS_ACCOUNT";
23
25
  })(EntityType || (exports.EntityType = EntityType = {}));
24
26
  var IssueStatus;
25
27
  (function (IssueStatus) {
@@ -29,6 +31,7 @@ var IssueStatus;
29
31
  IssueStatus["CLOSED"] = "CLOSED";
30
32
  IssueStatus["CANCELLED"] = "CANCELLED";
31
33
  IssueStatus["ON_HOLD"] = "ON_HOLD";
34
+ IssueStatus["IGNORED"] = "IGNORED";
32
35
  })(IssueStatus || (exports.IssueStatus = IssueStatus = {}));
33
36
  var IssuePriority;
34
37
  (function (IssuePriority) {
@@ -38,3 +41,22 @@ var IssuePriority;
38
41
  IssuePriority["CRITICAL"] = "CRITICAL";
39
42
  IssuePriority["URGENT"] = "URGENT";
40
43
  })(IssuePriority || (exports.IssuePriority = IssuePriority = {}));
44
+ var IssueType;
45
+ (function (IssueType) {
46
+ IssueType["BATTERY_LOW"] = "BATTERY_LOW";
47
+ IssueType["DEVICE_OFFLINE"] = "DEVICE_OFFLINE";
48
+ IssueType["HUB_OFFLINE"] = "HUB_OFFLINE";
49
+ IssueType["ACCOUNT_UNAUTHORIZED"] = "ACCOUNT_UNAUTHORIZED";
50
+ IssueType["ACCOUNT_NEW_DEVICE"] = "ACCOUNT_NEW_DEVICE";
51
+ IssueType["ACCOUNT_MISSING_DEVICE"] = "ACCOUNT_MISSING_DEVICE";
52
+ IssueType["DEVICE_TAMPER_ATTEMPT"] = "DEVICE_TAMPER_ATTEMPT";
53
+ IssueType["LOCK_JAMMED"] = "LOCK_JAMMED";
54
+ IssueType["DEVICE_MALFUNCTION"] = "DEVICE_MALFUNCTION";
55
+ IssueType["DOOR_LEFT_OPEN"] = "DOOR_LEFT_OPEN";
56
+ IssueType["DOOR_OPEN_FREQUENT"] = "DOOR_OPEN_FREQUENT";
57
+ IssueType["DOOR_OPEN_OUTSIDE_BIZ_HOURS"] = "DOOR_OPEN_OUTSIDE_BIZ_HOURS";
58
+ IssueType["LOCK_ACCESS_EMERGENCY_CODE"] = "LOCK_ACCESS_EMERGENCY_CODE";
59
+ IssueType["LOCK_ACCESS_MASTER_CODE"] = "LOCK_ACCESS_MASTER_CODE";
60
+ IssueType["SPECIFIC_DOOR_ACCESS"] = "SPECIFIC_DOOR_ACCESS";
61
+ IssueType["GUEST_LOCK_FIRST_ACCESS"] = "GUEST_LOCK_FIRST_ACCESS";
62
+ })(IssueType || (exports.IssueType = IssueType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "7.1.1",
3
+ "version": "7.1.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,7 +0,0 @@
1
- export declare class AdminRepository {
2
- private readonly axiosInstance;
3
- private readonly deviceRepository;
4
- private readonly postgres;
5
- constructor();
6
- getZonesByAccessGroupIds(accessGroupIds: string[]): Promise<any[]>;
7
- }