dt-common-device 7.1.3 → 7.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/alerts/Alert.model.js +1 -1
- package/dist/alerts/Alert.repository.js +1 -1
- package/dist/alerts/Alert.service.js +4 -4
- package/dist/alerts/AlertBuilder.d.ts +1 -1
- package/dist/alerts/AlertBuilder.js +3 -3
- package/dist/alerts/alert.types.d.ts +0 -1
- package/dist/alerts/alert.types.js +0 -1
- package/dist/issues/Issue.model.js +1 -1
- package/dist/issues/Issue.repository.js +1 -1
- package/dist/issues/Issue.service.d.ts +2 -2
- package/dist/issues/Issue.service.js +8 -8
- package/dist/issues/IssueBuilder.d.ts +3 -3
- package/dist/issues/IssueBuilder.js +8 -7
- package/dist/issues/issue.types.d.ts +1 -3
- package/dist/issues/issue.types.js +0 -2
- package/package.json +1 -1
|
@@ -77,7 +77,7 @@ let AlertRepository = (() => {
|
|
|
77
77
|
try {
|
|
78
78
|
const alert = new Alert_model_1.AlertModel({
|
|
79
79
|
...alertData,
|
|
80
|
-
severity: alertData.severity || alert_types_1.AlertSeverity.
|
|
80
|
+
severity: alertData.severity || alert_types_1.AlertSeverity.LOW,
|
|
81
81
|
isRead: false,
|
|
82
82
|
isActive: true,
|
|
83
83
|
isDeleted: false,
|
|
@@ -200,7 +200,7 @@ let AlertService = (() => {
|
|
|
200
200
|
* Raise alert for device battery level below threshold (READINESS + OPERATIONAL + ENERGY)
|
|
201
201
|
*/
|
|
202
202
|
async raiseDeviceBatteryAlert(device, batteryLevel, threshold, source) {
|
|
203
|
-
return await this.raiseDeviceAlert(device.deviceId, device.propertyId, device.zoneId, "Device Battery Low", `Device ${device.name} (${device.deviceId}) battery level is ${batteryLevel}%, which is below the property threshold of ${threshold}%.`, alert_types_1.AlertCategory.ENERGY, alert_types_1.AlertSeverity.
|
|
203
|
+
return await this.raiseDeviceAlert(device.deviceId, device.propertyId, device.zoneId, "Device Battery Low", `Device ${device.name} (${device.deviceId}) battery level is ${batteryLevel}%, which is below the property threshold of ${threshold}%.`, alert_types_1.AlertCategory.ENERGY, alert_types_1.AlertSeverity.HIGH, source);
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
206
206
|
* Raise alert for device issue (jammed or malfunctioned) (READINESS + OPERATIONAL)
|
|
@@ -538,13 +538,13 @@ let AlertService = (() => {
|
|
|
538
538
|
determineDefaultSeverity(category) {
|
|
539
539
|
// Business logic: Determine default severity based on category
|
|
540
540
|
const categorySeverities = {
|
|
541
|
-
[alert_types_1.AlertCategory.READINESS]: alert_types_1.AlertSeverity.
|
|
541
|
+
[alert_types_1.AlertCategory.READINESS]: alert_types_1.AlertSeverity.LOW,
|
|
542
542
|
[alert_types_1.AlertCategory.OPERATIONS]: alert_types_1.AlertSeverity.HIGH,
|
|
543
543
|
[alert_types_1.AlertCategory.SECURITY]: alert_types_1.AlertSeverity.CRITICAL,
|
|
544
544
|
[alert_types_1.AlertCategory.ENERGY]: alert_types_1.AlertSeverity.LOW,
|
|
545
|
-
[alert_types_1.AlertCategory.OTHER]: alert_types_1.AlertSeverity.
|
|
545
|
+
[alert_types_1.AlertCategory.OTHER]: alert_types_1.AlertSeverity.LOW,
|
|
546
546
|
};
|
|
547
|
-
return categorySeverities[category] || alert_types_1.AlertSeverity.
|
|
547
|
+
return categorySeverities[category] || alert_types_1.AlertSeverity.LOW;
|
|
548
548
|
}
|
|
549
549
|
applyBusinessRules(filters) {
|
|
550
550
|
// Business logic: Apply additional filters based on business rules
|
|
@@ -49,7 +49,7 @@ export declare class AlertBuilder {
|
|
|
49
49
|
*/
|
|
50
50
|
setEntityType(entityType: EntityType): this;
|
|
51
51
|
/**
|
|
52
|
-
* Sets the alert severity (optional, defaults to
|
|
52
|
+
* Sets the alert severity (optional, defaults to LOW)
|
|
53
53
|
*/
|
|
54
54
|
setSeverity(severity?: AlertSeverity): this;
|
|
55
55
|
/**
|
|
@@ -89,7 +89,7 @@ class AlertBuilder {
|
|
|
89
89
|
return this;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
* Sets the alert severity (optional, defaults to
|
|
92
|
+
* Sets the alert severity (optional, defaults to LOW)
|
|
93
93
|
*/
|
|
94
94
|
setSeverity(severity) {
|
|
95
95
|
if (severity !== undefined) {
|
|
@@ -141,7 +141,7 @@ class AlertBuilder {
|
|
|
141
141
|
this.validate();
|
|
142
142
|
// Set default severity if not provided
|
|
143
143
|
if (!this.data.severity) {
|
|
144
|
-
this.data.severity = alert_types_1.AlertSeverity.
|
|
144
|
+
this.data.severity = alert_types_1.AlertSeverity.LOW;
|
|
145
145
|
}
|
|
146
146
|
return this.data;
|
|
147
147
|
}
|
|
@@ -158,7 +158,7 @@ class AlertBuilder {
|
|
|
158
158
|
static createReadinessAlert() {
|
|
159
159
|
return new AlertBuilder()
|
|
160
160
|
.setCategory(alert_types_1.AlertCategory.READINESS)
|
|
161
|
-
.setSeverity(alert_types_1.AlertSeverity.
|
|
161
|
+
.setSeverity(alert_types_1.AlertSeverity.LOW);
|
|
162
162
|
}
|
|
163
163
|
static createOperationsAlert() {
|
|
164
164
|
return new AlertBuilder()
|
|
@@ -13,7 +13,6 @@ var AlertSeverity;
|
|
|
13
13
|
(function (AlertSeverity) {
|
|
14
14
|
AlertSeverity["INFO"] = "INFO";
|
|
15
15
|
AlertSeverity["LOW"] = "LOW";
|
|
16
|
-
AlertSeverity["MEDIUM"] = "MEDIUM";
|
|
17
16
|
AlertSeverity["HIGH"] = "HIGH";
|
|
18
17
|
AlertSeverity["CRITICAL"] = "CRITICAL";
|
|
19
18
|
})(AlertSeverity || (exports.AlertSeverity = AlertSeverity = {}));
|
|
@@ -95,7 +95,7 @@ const IssueSchema = new mongoose_1.Schema({
|
|
|
95
95
|
priority: {
|
|
96
96
|
type: String,
|
|
97
97
|
enum: Object.values(issue_types_1.IssuePriority),
|
|
98
|
-
default: issue_types_1.IssuePriority.
|
|
98
|
+
default: issue_types_1.IssuePriority.LOW,
|
|
99
99
|
},
|
|
100
100
|
assignedTo: {
|
|
101
101
|
type: String,
|
|
@@ -84,7 +84,7 @@ let IssueRepository = (() => {
|
|
|
84
84
|
const issue = new Issue_model_1.IssueModel({
|
|
85
85
|
...issueData,
|
|
86
86
|
status: issue_types_1.IssueStatus.PENDING,
|
|
87
|
-
priority: issueData.priority || issue_types_1.IssuePriority.
|
|
87
|
+
priority: issueData.priority || issue_types_1.IssuePriority.LOW,
|
|
88
88
|
isDeleted: false,
|
|
89
89
|
});
|
|
90
90
|
return await issue.save();
|
|
@@ -61,9 +61,9 @@ export declare class IssueService {
|
|
|
61
61
|
*/
|
|
62
62
|
createMaintenanceIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
63
63
|
/**
|
|
64
|
-
* Create
|
|
64
|
+
* Create a high priority issue using IssueBuilder
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
createHighPriorityIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
67
67
|
/**
|
|
68
68
|
* Create a new issue with business logic validation
|
|
69
69
|
* Accepts either a CreateIssueData object or an IssueBuilder instance
|
|
@@ -291,7 +291,7 @@ let IssueService = (() => {
|
|
|
291
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.`,
|
|
292
292
|
createdBy: source,
|
|
293
293
|
category: issue_types_1.IssuesCategory.ENERGY,
|
|
294
|
-
priority: issue_types_1.IssuePriority.
|
|
294
|
+
priority: issue_types_1.IssuePriority.CRITICAL,
|
|
295
295
|
type: issue_types_1.IssueType.BATTERY_LOW,
|
|
296
296
|
});
|
|
297
297
|
}
|
|
@@ -329,10 +329,10 @@ let IssueService = (() => {
|
|
|
329
329
|
return await this.createIssue(issueBuilder);
|
|
330
330
|
}
|
|
331
331
|
/**
|
|
332
|
-
* Create
|
|
332
|
+
* Create a high priority issue using IssueBuilder
|
|
333
333
|
*/
|
|
334
|
-
async
|
|
335
|
-
const issueBuilder = IssueBuilder_1.IssueBuilder.
|
|
334
|
+
async createHighPriorityIssue(data) {
|
|
335
|
+
const issueBuilder = IssueBuilder_1.IssueBuilder.createHighPriorityIssue(data.propertyId, data.type, data.entityId, data.entityType)
|
|
336
336
|
.setTitle(data.title)
|
|
337
337
|
.setDescription(data.description)
|
|
338
338
|
.setCreatedBy(data.createdBy);
|
|
@@ -732,13 +732,13 @@ let IssueService = (() => {
|
|
|
732
732
|
determineDefaultPriority(category) {
|
|
733
733
|
// Business logic: Determine default priority based on category
|
|
734
734
|
const categoryPriorities = {
|
|
735
|
-
[issue_types_1.IssuesCategory.READINESS]: issue_types_1.IssuePriority.
|
|
735
|
+
[issue_types_1.IssuesCategory.READINESS]: issue_types_1.IssuePriority.LOW,
|
|
736
736
|
[issue_types_1.IssuesCategory.OPERATIONS]: issue_types_1.IssuePriority.HIGH,
|
|
737
737
|
[issue_types_1.IssuesCategory.SECURITY]: issue_types_1.IssuePriority.CRITICAL,
|
|
738
|
-
[issue_types_1.IssuesCategory.ENERGY]: issue_types_1.IssuePriority.
|
|
739
|
-
[issue_types_1.IssuesCategory.OTHER]: issue_types_1.IssuePriority.
|
|
738
|
+
[issue_types_1.IssuesCategory.ENERGY]: issue_types_1.IssuePriority.HIGH,
|
|
739
|
+
[issue_types_1.IssuesCategory.OTHER]: issue_types_1.IssuePriority.LOW,
|
|
740
740
|
};
|
|
741
|
-
return categoryPriorities[category] || issue_types_1.IssuePriority.
|
|
741
|
+
return categoryPriorities[category] || issue_types_1.IssuePriority.LOW;
|
|
742
742
|
}
|
|
743
743
|
applyBusinessRules(filters) {
|
|
744
744
|
// Business logic: Apply additional filters based on business rules
|
|
@@ -55,7 +55,7 @@ export declare class IssueBuilder {
|
|
|
55
55
|
*/
|
|
56
56
|
setEntityType(entityType: EntityType): this;
|
|
57
57
|
/**
|
|
58
|
-
* Sets the issue priority (optional, defaults to
|
|
58
|
+
* Sets the issue priority (optional, defaults to LOW)
|
|
59
59
|
*/
|
|
60
60
|
setPriority(priority?: IssuePriority): this;
|
|
61
61
|
/**
|
|
@@ -111,8 +111,8 @@ export declare class IssueBuilder {
|
|
|
111
111
|
*/
|
|
112
112
|
static createMaintenanceIssue(propertyId: string, type: IssueType, entityId?: string, entityType?: EntityType): IssueBuilder;
|
|
113
113
|
/**
|
|
114
|
-
* Creates
|
|
114
|
+
* Creates a high priority issue builder
|
|
115
115
|
*/
|
|
116
|
-
static
|
|
116
|
+
static createHighPriorityIssue(propertyId: string, type: IssueType, entityId?: string, entityType?: EntityType): IssueBuilder;
|
|
117
117
|
static createCloudAccountAuthorizationIssue(propertyId: string, entityId: string, entityType: EntityType, type: IssueType): IssueBuilder;
|
|
118
118
|
}
|
|
@@ -100,7 +100,7 @@ class IssueBuilder {
|
|
|
100
100
|
return this;
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
|
-
* Sets the issue priority (optional, defaults to
|
|
103
|
+
* Sets the issue priority (optional, defaults to LOW)
|
|
104
104
|
*/
|
|
105
105
|
setPriority(priority) {
|
|
106
106
|
if (priority !== undefined) {
|
|
@@ -163,7 +163,7 @@ class IssueBuilder {
|
|
|
163
163
|
this.validate();
|
|
164
164
|
// Set default priority if not provided
|
|
165
165
|
if (!this.data.priority) {
|
|
166
|
-
this.data.priority = issue_types_1.IssuePriority.
|
|
166
|
+
this.data.priority = issue_types_1.IssuePriority.LOW;
|
|
167
167
|
}
|
|
168
168
|
return this.data;
|
|
169
169
|
}
|
|
@@ -180,7 +180,7 @@ class IssueBuilder {
|
|
|
180
180
|
static createReadinessIssue() {
|
|
181
181
|
return new IssueBuilder()
|
|
182
182
|
.setCategory(issue_types_1.IssuesCategory.READINESS)
|
|
183
|
-
.setPriority(issue_types_1.IssuePriority.
|
|
183
|
+
.setPriority(issue_types_1.IssuePriority.LOW);
|
|
184
184
|
}
|
|
185
185
|
static createOperationsIssue() {
|
|
186
186
|
return new IssueBuilder()
|
|
@@ -248,7 +248,8 @@ class IssueBuilder {
|
|
|
248
248
|
const builder = new IssueBuilder()
|
|
249
249
|
.setCategory(issue_types_1.IssuesCategory.READINESS)
|
|
250
250
|
.setPropertyId(propertyId)
|
|
251
|
-
.setType(type)
|
|
251
|
+
.setType(type)
|
|
252
|
+
.setPriority(issue_types_1.IssuePriority.LOW);
|
|
252
253
|
if (entityId)
|
|
253
254
|
builder.setEntityId(entityId);
|
|
254
255
|
if (entityType)
|
|
@@ -256,14 +257,14 @@ class IssueBuilder {
|
|
|
256
257
|
return builder;
|
|
257
258
|
}
|
|
258
259
|
/**
|
|
259
|
-
* Creates
|
|
260
|
+
* Creates a high priority issue builder
|
|
260
261
|
*/
|
|
261
|
-
static
|
|
262
|
+
static createHighPriorityIssue(propertyId, type, entityId, entityType) {
|
|
262
263
|
const builder = new IssueBuilder()
|
|
263
264
|
.setCategory(issue_types_1.IssuesCategory.OPERATIONS)
|
|
264
265
|
.setPropertyId(propertyId)
|
|
265
266
|
.setType(type)
|
|
266
|
-
.setPriority(issue_types_1.IssuePriority.
|
|
267
|
+
.setPriority(issue_types_1.IssuePriority.HIGH);
|
|
267
268
|
if (entityId)
|
|
268
269
|
builder.setEntityId(entityId);
|
|
269
270
|
if (entityType)
|
|
@@ -29,10 +29,8 @@ export declare enum IssueStatus {
|
|
|
29
29
|
}
|
|
30
30
|
export declare enum IssuePriority {
|
|
31
31
|
LOW = "LOW",
|
|
32
|
-
MEDIUM = "MEDIUM",
|
|
33
32
|
HIGH = "HIGH",
|
|
34
|
-
CRITICAL = "CRITICAL"
|
|
35
|
-
URGENT = "URGENT"
|
|
33
|
+
CRITICAL = "CRITICAL"
|
|
36
34
|
}
|
|
37
35
|
export interface IssueComment {
|
|
38
36
|
id: string;
|
|
@@ -36,10 +36,8 @@ var IssueStatus;
|
|
|
36
36
|
var IssuePriority;
|
|
37
37
|
(function (IssuePriority) {
|
|
38
38
|
IssuePriority["LOW"] = "LOW";
|
|
39
|
-
IssuePriority["MEDIUM"] = "MEDIUM";
|
|
40
39
|
IssuePriority["HIGH"] = "HIGH";
|
|
41
40
|
IssuePriority["CRITICAL"] = "CRITICAL";
|
|
42
|
-
IssuePriority["URGENT"] = "URGENT";
|
|
43
41
|
})(IssuePriority || (exports.IssuePriority = IssuePriority = {}));
|
|
44
42
|
var IssueType;
|
|
45
43
|
(function (IssueType) {
|