dt-common-device 7.10.0 → 7.10.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.
@@ -19,11 +19,16 @@ export declare class AlertService {
19
19
  * Create a hub-specific alert using AlertBuilder
20
20
  */
21
21
  raiseHubAlert(data: CreateAlertData): Promise<IAlertDocument | null>;
22
+ raiseDeviceTamperAttemptAlert(device: IDevice, zone: any, source: Source): Promise<IAlertDocument | null>;
22
23
  raiseDoorLeftOpenAlert(device: IDevice, zone: any, openThreshold: number, source: Source): Promise<IAlertDocument | null>;
23
24
  raiseNewDeviceAlert(device: {
24
25
  deviceId: string;
25
26
  deviceType: string;
26
27
  name: string;
28
+ }, connection: {
29
+ id: string;
30
+ provider: string;
31
+ type?: string;
27
32
  }, propertyId: string, source: Source): Promise<IAlertDocument | null>;
28
33
  raiseDoorOpenFrequentAlert(device: IDevice, zone: any, accessTimes: number, openThreshold: number, source: Source): Promise<IAlertDocument | null>;
29
34
  raiseDoorOpenOutsideBusinessHoursAlert(device: IDevice, zone: any, source: Source): Promise<IAlertDocument | null>;
@@ -162,6 +162,21 @@ let AlertService = (() => {
162
162
  alertBuilder.setEntitySubType(data.entitySubType);
163
163
  return await this.createAlert(alertBuilder);
164
164
  }
165
+ async raiseDeviceTamperAttemptAlert(device, zone, source) {
166
+ return await this.createAlert({
167
+ entityId: device.deviceId,
168
+ entityType: alert_types_1.EntityType.DEVICE,
169
+ entitySubType: device.deviceType.type,
170
+ propertyId: device.propertyId,
171
+ zoneId: device.zoneId,
172
+ title: "Device Tamper Attempt",
173
+ description: `System detected a tamper attempt on ${device.name}.`,
174
+ createdBy: source,
175
+ category: alert_types_1.AlertCategory.SECURITY,
176
+ severity: alert_types_1.AlertSeverity.CRITICAL,
177
+ type: alert_types_1.AlertType.DEVICE_TAMPER_ATTEMPT,
178
+ });
179
+ }
165
180
  async raiseDoorLeftOpenAlert(device, zone, openThreshold, source) {
166
181
  return await this.createAlert({
167
182
  entityId: device.deviceId,
@@ -177,14 +192,14 @@ let AlertService = (() => {
177
192
  type: alert_types_1.AlertType.DOOR_LEFT_OPEN,
178
193
  });
179
194
  }
180
- async raiseNewDeviceAlert(device, propertyId, source) {
195
+ async raiseNewDeviceAlert(device, connection, propertyId, source) {
181
196
  return await this.createAlert({
182
- entityId: device.deviceId,
183
- entityType: alert_types_1.EntityType.DEVICE,
184
- entitySubType: device?.deviceType,
197
+ entityId: connection.id,
198
+ entityType: alert_types_1.EntityType.CLOUD_DEVICE_ACCOUNT,
199
+ entitySubType: connection.provider,
185
200
  propertyId: propertyId,
186
201
  title: "New Device Detected",
187
- description: `New device ${device.name} has been detected.`,
202
+ description: `New device ${device.name} has been detected on the ${connection.provider} account.`,
188
203
  createdBy: source,
189
204
  category: alert_types_1.AlertCategory.OPERATIONS,
190
205
  severity: alert_types_1.AlertSeverity.INFO,
@@ -333,10 +348,11 @@ let AlertService = (() => {
333
348
  return await this.createAlert({
334
349
  zoneId: zone.zoneId,
335
350
  propertyId: zone.propertyId,
351
+ entityId: zone.zoneId,
336
352
  entityType: alert_types_1.EntityType.ZONE,
337
353
  entitySubType: issues_1.EntitySubType.ZONE,
338
354
  title: `Zone Not Mapped to Access Group`,
339
- description: `${zone?.name} is not mapped to any access group. Only Emergency Codes Generated. Add to an Access group to generate Guest and Staff Modes`,
355
+ description: `${zone?.name} is not mapped to any access group. Only Emergency Access Modes Generated. Add to an Access group to generate Guest and Staff Access Modes!`,
340
356
  createdBy: source,
341
357
  category: alert_types_1.AlertCategory.OPERATIONS,
342
358
  severity: alert_types_1.AlertSeverity.INFO,
@@ -7,4 +7,5 @@ export declare class ScheduleRepository {
7
7
  getScheduleByZone(zoneId: string): Promise<any>;
8
8
  setSchedule(scheduleId: string, schedule: ISchedule): Promise<any>;
9
9
  deleteSchedule(scheduleId: string): Promise<any>;
10
+ querySchedules(query: any): Promise<any>;
10
11
  }
@@ -107,6 +107,16 @@ let ScheduleRepository = (() => {
107
107
  throw new Error(`Failed to delete schedule from DB: ${error.message}`);
108
108
  }
109
109
  }
110
+ async querySchedules(query) {
111
+ try {
112
+ const response = await this.axiosInstance.post(`/devices/schedules/query`, query);
113
+ return response.data;
114
+ }
115
+ catch (error) {
116
+ (0, config_1.getConfig)().LOGGER.error("Failed to query schedules:", error);
117
+ throw new Error(`Failed to query schedules: ${error.message || "Unknown error"}`);
118
+ }
119
+ }
110
120
  };
111
121
  __setFunctionName(_classThis, "ScheduleRepository");
112
122
  (() => {
@@ -7,4 +7,5 @@ export declare class LocalScheduleService {
7
7
  setSchedule(scheduleId: string, schedule: ISchedule): Promise<any>;
8
8
  getScheduleByZone(zoneId: string): Promise<any>;
9
9
  deleteSchedule(scheduleId: string): Promise<any>;
10
+ querySchedules(query: any): Promise<any>;
10
11
  }
@@ -25,5 +25,8 @@ class LocalScheduleService {
25
25
  async deleteSchedule(scheduleId) {
26
26
  return await this.scheduleRepository.deleteSchedule(scheduleId);
27
27
  }
28
+ async querySchedules(query) {
29
+ return await this.scheduleRepository.querySchedules(query);
30
+ }
28
31
  }
29
32
  exports.LocalScheduleService = LocalScheduleService;
@@ -42,6 +42,10 @@ export declare class IssueService {
42
42
  deviceId: string;
43
43
  deviceType: string;
44
44
  name: string;
45
+ }, connection: {
46
+ id: string;
47
+ provider: string;
48
+ type?: string;
45
49
  }, propertyId: string, source: Source): Promise<IIssueDocument | null>;
46
50
  createAccountUnauthorizedIssue(account: {
47
51
  accountId: string;
@@ -266,14 +266,14 @@ let IssueService = (() => {
266
266
  type: issue_types_1.IssueType.BATTERY_LOW,
267
267
  });
268
268
  }
269
- async createAccountMissingDeviceIssue(device, propertyId, source) {
269
+ async createAccountMissingDeviceIssue(device, connection, propertyId, source) {
270
270
  return await this.createIssue({
271
- entityId: device.deviceId,
272
- entityType: issue_types_1.EntityType.DEVICE,
273
- entitySubType: device.deviceType,
271
+ entityId: connection.id,
272
+ entityType: issue_types_1.EntityType.CLOUD_DEVICE_ACCOUNT,
273
+ entitySubType: connection.provider,
274
274
  propertyId: propertyId,
275
275
  title: "Device Missing",
276
- description: `${device.name} is missing from the account. Requires Attention.`,
276
+ description: `${device.name} is missing from the ${connection.provider} account.`,
277
277
  createdBy: source,
278
278
  category: issue_types_1.IssuesCategory.OPERATIONS,
279
279
  priority: issue_types_1.IssuePriority.CRITICAL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "7.10.0",
3
+ "version": "7.10.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [