dt-common-device 7.1.4 → 7.1.6

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.
@@ -402,7 +402,7 @@ let LocalDeviceService = (() => {
402
402
  // Raise alert for device malfunction (READINESS + OPERATIONAL)
403
403
  await this.alertService.raiseDeviceIssueAlert(device, "Device Malfunction Detected", source, reason);
404
404
  // Raise issue for device malfunction (READINESS + OPERATIONAL)
405
- await this.issueService.createDeviceMalfunctionIssue(device, "Device Malfunction", source, reason);
405
+ await this.issueService.createDeviceMalfunctionIssue(device, source, reason);
406
406
  }
407
407
  }
408
408
  async getMetaData(deviceId) {
@@ -81,6 +81,12 @@ const IssueSchema = new mongoose_1.Schema({
81
81
  required: true,
82
82
  index: true,
83
83
  },
84
+ entitySubType: {
85
+ type: String,
86
+ enum: Object.values(issue_types_1.EntitySubType),
87
+ required: true,
88
+ index: true,
89
+ },
84
90
  status: {
85
91
  type: String,
86
92
  enum: Object.values(issue_types_1.IssueStatus),
@@ -55,7 +55,7 @@ export declare class IssueService {
55
55
  /**
56
56
  * Create issue for device malfunction (jammed or not accepting codes) (READINESS + OPERATIONAL)
57
57
  */
58
- createDeviceMalfunctionIssue(device: IDevice, issueType: string, source: Source, reason?: string): Promise<IIssueDocument>;
58
+ createDeviceMalfunctionIssue(device: IDevice, source: Source, reason?: string): Promise<IIssueDocument>;
59
59
  /**
60
60
  * Create a maintenance issue using IssueBuilder
61
61
  */
@@ -183,7 +183,7 @@ let IssueService = (() => {
183
183
  * Create a device-specific issue using IssueBuilder
184
184
  */
185
185
  async createDeviceIssue(data) {
186
- const issueBuilder = IssueBuilder_1.IssueBuilder.createDeviceIssue(data.entityId, data.propertyId, data.type)
186
+ const issueBuilder = IssueBuilder_1.IssueBuilder.createDeviceIssue(data.entityId, data.propertyId, data.type, data.entitySubType)
187
187
  .setTitle(data.title)
188
188
  .setDescription(data.description)
189
189
  .setCreatedBy(data.createdBy);
@@ -253,13 +253,14 @@ let IssueService = (() => {
253
253
  return await this.createDeviceIssue({
254
254
  entityId: device.deviceId,
255
255
  entityType: issue_types_1.EntityType.DEVICE,
256
+ entitySubType: device.deviceType.type,
256
257
  propertyId: device.propertyId,
257
258
  zoneId: device.zoneId,
258
259
  title: "Device Offline - Requires Attention",
259
- description: `Device ${device.name} (${device.deviceId}) has been offline for longer than the baseline time. ${reason ? `Reason: ${reason}` : ""} This requires immediate attention to restore device functionality.`,
260
+ description: `${device.name} has been offline for longer than the threshold time. ${reason ? `Reason: ${reason}` : ""} This requires immediate attention to restore device functionality.`,
260
261
  createdBy: source,
261
262
  category: issue_types_1.IssuesCategory.OPERATIONS,
262
- priority: issue_types_1.IssuePriority.HIGH,
263
+ priority: issue_types_1.IssuePriority.CRITICAL,
263
264
  type: issue_types_1.IssueType.DEVICE_OFFLINE,
264
265
  });
265
266
  }
@@ -268,10 +269,11 @@ let IssueService = (() => {
268
269
  return await this.createDeviceIssue({
269
270
  entityId: device.deviceId,
270
271
  entityType: issue_types_1.EntityType.DEVICE,
272
+ entitySubType: device.deviceType.type,
271
273
  propertyId: device.propertyId,
272
274
  zoneId: device.zoneId,
273
275
  title: "Door Left Open - Requires Attention",
274
- description: `Zone ${zone?.name} has a door left open, for more than 10 minutes. ${reason ? `Reason: ${reason}` : ""}. Please check the zone and close the door.`,
276
+ description: `${zone?.name} has a door left open, for more than 10 minutes. ${reason ? `Reason: ${reason}` : ""}. Please check the zone and close the door.`,
275
277
  createdBy: source,
276
278
  category: issue_types_1.IssuesCategory.SECURITY,
277
279
  priority: issue_types_1.IssuePriority.HIGH,
@@ -285,10 +287,11 @@ let IssueService = (() => {
285
287
  return await this.createDeviceIssue({
286
288
  entityId: device.deviceId,
287
289
  entityType: issue_types_1.EntityType.DEVICE,
290
+ entitySubType: device.deviceType.type,
288
291
  propertyId: device.propertyId,
289
292
  zoneId: device.zoneId,
290
293
  title: "Device Battery Low - Requires Attention",
291
- description: `Device ${device.name} (${device.deviceId}) battery level is ${batteryLevel}%, which is below the property threshold of ${threshold}%. Please replace or charge the device battery.`,
294
+ description: `${device.name} battery level is ${batteryLevel}%, which is below the property threshold of ${threshold}%. Please replace or charge the device battery.`,
292
295
  createdBy: source,
293
296
  category: issue_types_1.IssuesCategory.ENERGY,
294
297
  priority: issue_types_1.IssuePriority.CRITICAL,
@@ -298,14 +301,15 @@ let IssueService = (() => {
298
301
  /**
299
302
  * Create issue for device malfunction (jammed or not accepting codes) (READINESS + OPERATIONAL)
300
303
  */
301
- async createDeviceMalfunctionIssue(device, issueType, source, reason) {
304
+ async createDeviceMalfunctionIssue(device, source, reason) {
302
305
  return await this.createDeviceIssue({
303
306
  entityId: device.deviceId,
304
307
  entityType: issue_types_1.EntityType.DEVICE,
308
+ entitySubType: device.deviceType.type,
305
309
  propertyId: device.propertyId,
306
310
  zoneId: device.zoneId,
307
- title: `Device Malfunction - ${issueType} - Requires Attention`,
308
- description: `Device ${device.name} (${device.deviceId}) has a malfunction: ${issueType}. ${reason ? `Reason: ${reason}` : ""} This requires immediate attention to resolve the device malfunction.`,
311
+ title: `Device Malfunction - Requires Attention`,
312
+ description: `${device.name} has a malfunction. ${reason ? `Reason: ${reason}` : ""} This requires immediate attention to resolve the device malfunction.`,
309
313
  createdBy: source,
310
314
  category: issue_types_1.IssuesCategory.OPERATIONS,
311
315
  priority: issue_types_1.IssuePriority.HIGH,
@@ -1,4 +1,4 @@
1
- import { CreateIssueData, IssuesCategory, IssuePriority, EntityType, IssueType } from "./issue.types";
1
+ import { CreateIssueData, IssuesCategory, IssuePriority, EntityType, IssueType, EntitySubType } from "./issue.types";
2
2
  /**
3
3
  * IssueBuilder - A builder pattern implementation for constructing CreateIssueData objects
4
4
  *
@@ -54,6 +54,10 @@ export declare class IssueBuilder {
54
54
  * Sets the entity type
55
55
  */
56
56
  setEntityType(entityType: EntityType): this;
57
+ /**
58
+ * Sets the entity sub type
59
+ */
60
+ setEntitySubType(entitySubType: EntitySubType): this;
57
61
  /**
58
62
  * Sets the issue priority (optional, defaults to LOW)
59
63
  */
@@ -93,7 +97,7 @@ export declare class IssueBuilder {
93
97
  /**
94
98
  * Creates a device-specific issue builder
95
99
  */
96
- static createDeviceIssue(deviceId: string, propertyId: string, type: IssueType): IssueBuilder;
100
+ static createDeviceIssue(deviceId: string, propertyId: string, type: IssueType, entitySubType: EntitySubType): IssueBuilder;
97
101
  /**
98
102
  * Creates a hub-specific issue builder
99
103
  */
@@ -99,6 +99,13 @@ class IssueBuilder {
99
99
  this.data.entityType = entityType;
100
100
  return this;
101
101
  }
102
+ /**
103
+ * Sets the entity sub type
104
+ */
105
+ setEntitySubType(entitySubType) {
106
+ this.data.entitySubType = entitySubType;
107
+ return this;
108
+ }
102
109
  /**
103
110
  * Sets the issue priority (optional, defaults to LOW)
104
111
  */
@@ -148,6 +155,7 @@ class IssueBuilder {
148
155
  "description",
149
156
  "entityId",
150
157
  "entityType",
158
+ "entitySubType",
151
159
  "createdBy",
152
160
  ];
153
161
  const missingFields = requiredFields.filter((field) => !this.data[field]);
@@ -200,12 +208,13 @@ class IssueBuilder {
200
208
  /**
201
209
  * Creates a device-specific issue builder
202
210
  */
203
- static createDeviceIssue(deviceId, propertyId, type) {
211
+ static createDeviceIssue(deviceId, propertyId, type, entitySubType) {
204
212
  const builder = new IssueBuilder()
205
213
  .setEntityType(issue_types_1.EntityType.DEVICE)
206
214
  .setEntityId(deviceId)
207
215
  .setPropertyId(propertyId)
208
- .setType(type);
216
+ .setType(type)
217
+ .setEntitySubType(entitySubType);
209
218
  return builder;
210
219
  }
211
220
  /**
@@ -18,6 +18,15 @@ export declare enum EntityType {
18
18
  CLOUD_DEVICE_ACCOUNT = "CLOUD_DEVICE_ACCOUNT",
19
19
  CLOUD_PMS_ACCOUNT = "CLOUD_PMS_ACCOUNT"
20
20
  }
21
+ export declare enum EntitySubType {
22
+ LOCK = "LOCK",
23
+ HUB = "HUB",
24
+ TV = "TV",
25
+ THERMOSTAT = "THERMOSTAT",
26
+ ON_PREM_SERVER = "ON_PREM_SERVER",
27
+ PMS_ACCOUNT = "PMS_ACCOUNT",
28
+ DEVICE_ACCOUNT = "DEVICE_ACCOUNT"
29
+ }
21
30
  export declare enum IssueStatus {
22
31
  PENDING = "PENDING",
23
32
  IN_PROGRESS = "IN_PROGRESS",
@@ -66,6 +75,7 @@ export interface IssueDocument {
66
75
  description: string;
67
76
  entityId?: string;
68
77
  entityType: EntityType;
78
+ entitySubType: EntitySubType;
69
79
  status: IssueStatus;
70
80
  priority: IssuePriority;
71
81
  type: IssueType;
@@ -87,6 +97,7 @@ export interface CreateIssueData {
87
97
  description: string;
88
98
  entityId: string;
89
99
  entityType: EntityType;
100
+ entitySubType: EntitySubType;
90
101
  type: IssueType;
91
102
  priority?: IssuePriority;
92
103
  assignedTo?: string;
@@ -99,6 +110,7 @@ export interface UpdateIssueData {
99
110
  description?: string;
100
111
  entityId?: string;
101
112
  entityType?: EntityType;
113
+ entitySubType?: EntitySubType;
102
114
  status?: IssueStatus;
103
115
  type?: IssueType;
104
116
  priority?: IssuePriority;
@@ -121,6 +133,7 @@ export interface IIssueQuery {
121
133
  type?: IssueType;
122
134
  category?: IssuesCategory;
123
135
  entityType?: EntityType;
136
+ entitySubType?: EntitySubType;
124
137
  entityId?: string;
125
138
  includeDeleted?: boolean;
126
139
  limit?: number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IssueType = exports.IssuePriority = exports.IssueStatus = exports.EntityType = exports.IssuesCategory = void 0;
3
+ exports.IssueType = exports.IssuePriority = exports.IssueStatus = exports.EntitySubType = exports.EntityType = exports.IssuesCategory = void 0;
4
4
  var IssuesCategory;
5
5
  (function (IssuesCategory) {
6
6
  IssuesCategory["READINESS"] = "READINESS";
@@ -23,6 +23,16 @@ var EntityType;
23
23
  EntityType["CLOUD_DEVICE_ACCOUNT"] = "CLOUD_DEVICE_ACCOUNT";
24
24
  EntityType["CLOUD_PMS_ACCOUNT"] = "CLOUD_PMS_ACCOUNT";
25
25
  })(EntityType || (exports.EntityType = EntityType = {}));
26
+ var EntitySubType;
27
+ (function (EntitySubType) {
28
+ EntitySubType["LOCK"] = "LOCK";
29
+ EntitySubType["HUB"] = "HUB";
30
+ EntitySubType["TV"] = "TV";
31
+ EntitySubType["THERMOSTAT"] = "THERMOSTAT";
32
+ EntitySubType["ON_PREM_SERVER"] = "ON_PREM_SERVER";
33
+ EntitySubType["PMS_ACCOUNT"] = "PMS_ACCOUNT";
34
+ EntitySubType["DEVICE_ACCOUNT"] = "DEVICE_ACCOUNT";
35
+ })(EntitySubType || (exports.EntitySubType = EntitySubType = {}));
26
36
  var IssueStatus;
27
37
  (function (IssueStatus) {
28
38
  IssueStatus["PENDING"] = "PENDING";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "7.1.4",
3
+ "version": "7.1.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [