dt-common-device 13.4.0 → 13.4.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.
- package/dist/emails/emailService.d.ts +0 -2
- package/dist/emails/emailService.js +0 -36
- package/package.json +4 -1
- package/dist/admin/Admin.repository.js +0 -182
- package/dist/admin/Admin.service.js +0 -17
- package/dist/admin/index.js +0 -17
- package/dist/alerts/AlertBuilder.example.js +0 -117
- package/dist/alerts/AlertService.example.js +0 -150
- package/dist/audit/AuditProperties.js +0 -2
- package/dist/chronicle/Cronicle.service.js +0 -76
- package/dist/chronicle/IChronicle.interface.js +0 -2
- package/dist/chronicle/ICronicle.interface.js +0 -2
- package/dist/chronicle/chronicle.service.js +0 -44
- package/dist/chronicle/index.js +0 -5
- package/dist/connection/Connection.repository.js +0 -92
- package/dist/connection/Connection.service.js +0 -32
- package/dist/connection/IConnection.js +0 -16
- package/dist/connection/index.js +0 -18
- package/dist/copilotQueue/examples/CopilotQueue.example.js +0 -140
- package/dist/copilotQueue/examples/index.js +0 -17
- package/dist/device/cloud/entities/CloudConnection.js +0 -6
- package/dist/device/cloud/entities/CloudDevice.js +0 -26
- package/dist/device/cloud/entities/CloudDeviceService.js +0 -9
- package/dist/device/cloud/entities/DeviceFactory.js +0 -80
- package/dist/device/cloud/entities/index.js +0 -19
- package/dist/device/cloud/interface.js +0 -3
- package/dist/device/cloud/interfaces/ICloudConnection.js +0 -2
- package/dist/device/cloud/interfaces/ICloudDevice.js +0 -2
- package/dist/device/cloud/interfaces/ICloudDeviceService.js +0 -2
- package/dist/device/cloud/interfaces/IConnectionService.js +0 -2
- package/dist/device/cloud/interfaces/IDeviceConnectionService.js +0 -3
- package/dist/device/cloud/interfaces/IDeviceFactory.js +0 -2
- package/dist/device/cloud/interfaces/IDeviceService.js +0 -2
- package/dist/device/cloud/interfaces/IDevicesService.js +0 -2
- package/dist/device/cloud/interfaces/IHubService.js +0 -2
- package/dist/device/cloud/interfaces/IRawDataTransformer.js +0 -2
- package/dist/device/cloud/interfaces/IRawDevice.js +0 -11
- package/dist/device/cloud/interfaces/index.js +0 -21
- package/dist/device/cloud/services/CloudDevice.service.js +0 -9
- package/dist/device/cloud/services/Connection.service.js +0 -6
- package/dist/device/cloud/services/Device.service.js +0 -9
- package/dist/device/cloud/services/DeviceCloudService.js +0 -59
- package/dist/device/cloud/services/DeviceHub.service.js +0 -6
- package/dist/device/cloud/services/Hub.service.js +0 -9
- package/dist/device/cloud/services/index.js +0 -18
- package/dist/device/index.js +0 -20
- package/dist/device/local/entities/AlertBuilder.example.js +0 -117
- package/dist/device/local/entities/AlertBuilder.js +0 -179
- package/dist/device/local/entities/index.js +0 -7
- package/dist/device/local/events/EventHandler.js +0 -86
- package/dist/device/local/events/Events.js +0 -57
- package/dist/device/local/events/index.js +0 -7
- package/dist/device/local/handler/EventHandler.js +0 -44
- package/dist/device/local/interface.js +0 -1
- package/dist/device/local/interfaces/IConnection.js +0 -14
- package/dist/device/local/interfaces/IDevice.js +0 -10
- package/dist/device/local/interfaces/IDtDevice.js +0 -2
- package/dist/device/local/interfaces/IHub.js +0 -2
- package/dist/device/local/interfaces/IProperty.js +0 -2
- package/dist/device/local/interfaces/ISchedule.js +0 -2
- package/dist/device/local/interfaces/index.js +0 -19
- package/dist/device/local/models/Alert.model.js +0 -222
- package/dist/device/local/models/Issue.model.js +0 -260
- package/dist/device/local/repository/Alert.repository.js +0 -374
- package/dist/device/local/repository/Connection.repository.js +0 -92
- package/dist/device/local/repository/Device.repository.js +0 -325
- package/dist/device/local/repository/Hub.repository.js +0 -139
- package/dist/device/local/repository/Issue.repository.js +0 -401
- package/dist/device/local/services/Alert.service.js +0 -475
- package/dist/device/local/services/AlertService.example.js +0 -148
- package/dist/device/local/services/Connection.service.js +0 -32
- package/dist/device/local/services/Device.service.js +0 -391
- package/dist/device/local/services/DeviceHub.service.js +0 -40
- package/dist/device/local/services/Hub.service.js +0 -107
- package/dist/device/local/services/index.js +0 -19
- package/dist/entities/accessGroup/AccessGroup.repository.js +0 -72
- package/dist/entities/accessGroup/AccessGroup.service.js +0 -105
- package/dist/entities/accessGroup/IAccessGroup.js +0 -2
- package/dist/entities/accessGroup/index.js +0 -18
- package/dist/entities/device/local/repository/DeviceProfile.repository.js +0 -75
- package/dist/entities/guest/Guest.repository.js +0 -74
- package/dist/entities/guest/Guest.service.js +0 -104
- package/dist/entities/guest/IGuest.js +0 -2
- package/dist/entities/guest/index.js +0 -18
- package/dist/entities/schedules/ISchedule.js +0 -2
- package/dist/entities/schedules/index.js +0 -18
- package/dist/entities/zone/index.js +0 -18
- package/dist/pms/IPms.js +0 -10
- package/dist/pms/index.js +0 -18
- package/dist/pms/webhookQueue/examples/index.js +0 -18
- package/dist/pms/webhookQueue/index.js +0 -20
- package/dist/pms/webhookQueue/interfaces/index.js +0 -17
- package/dist/pms/webhookQueue/services/index.js +0 -17
- package/dist/pms/webhookQueue/types/index.js +0 -17
- package/dist/property/IProperty.js +0 -2
- package/dist/property/index.js +0 -18
- package/dist/queue/interfaces/IHttpRequestJob.js +0 -2
- package/dist/types/alert.types.js +0 -22
- package/dist/types/config.types.js +0 -2
- package/dist/types/index.js +0 -19
- package/dist/utils/http-utils.js +0 -117
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DeviceCloudService = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Device Cloud Service Class
|
|
6
|
-
* Implements IDeviceCloudService interface with empty implementations
|
|
7
|
-
* Implementation will be provided by the consuming project
|
|
8
|
-
*/
|
|
9
|
-
class DeviceCloudService {
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new connection for device management
|
|
12
|
-
* @param data - Connection data
|
|
13
|
-
* @param userId - User identifier
|
|
14
|
-
* @returns Promise with connection result
|
|
15
|
-
*/
|
|
16
|
-
async createConnection(data, userId) {
|
|
17
|
-
// Implementation will be provided by the consuming project
|
|
18
|
-
throw new Error("createConnection method not implemented");
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Gets device account information for a connection
|
|
22
|
-
* @param connection - Connection object
|
|
23
|
-
* @returns Promise with device account response
|
|
24
|
-
*/
|
|
25
|
-
async getDeviceAccount(connection) {
|
|
26
|
-
// Implementation will be provided by the consuming project
|
|
27
|
-
throw new Error("getDeviceAccount method not implemented");
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Gets all devices for a connection
|
|
31
|
-
* @param connection - Connection object
|
|
32
|
-
* @returns Promise with array of devices
|
|
33
|
-
*/
|
|
34
|
-
async getDevices(connection) {
|
|
35
|
-
// Implementation will be provided by the consuming project
|
|
36
|
-
throw new Error("getDevices method not implemented");
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Filters devices based on connection and device list
|
|
40
|
-
* @param connection - Connection object
|
|
41
|
-
* @param devices - Array of devices to filter
|
|
42
|
-
* @returns Promise with filtered devices
|
|
43
|
-
*/
|
|
44
|
-
async filterDevices(connection, devices) {
|
|
45
|
-
// Implementation will be provided by the consuming project
|
|
46
|
-
throw new Error("filterDevices method not implemented");
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Connects to a device service
|
|
50
|
-
* @param connection - Connection object
|
|
51
|
-
* @param connectionConnect - Connection parameters
|
|
52
|
-
* @returns Promise with connection result
|
|
53
|
-
*/
|
|
54
|
-
async connect(connection, connectionConnect) {
|
|
55
|
-
// Implementation will be provided by the consuming project
|
|
56
|
-
throw new Error("connect method not implemented");
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.DeviceCloudService = DeviceCloudService;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./CloudDevice.service"), exports);
|
|
18
|
-
__exportStar(require("./Connection.service"), exports);
|
package/dist/device/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// DeviceThread Common Library - Device Module
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
// Export cloud device interfaces
|
|
19
|
-
__exportStar(require("./cloud/interface"), exports);
|
|
20
|
-
__exportStar(require("./cloud/types"), exports);
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBasicAlert = createBasicAlert;
|
|
4
|
-
exports.createDeviceAlert = createDeviceAlert;
|
|
5
|
-
exports.createSecurityAlert = createSecurityAlert;
|
|
6
|
-
exports.createEnergyAlert = createEnergyAlert;
|
|
7
|
-
exports.createHubAlert = createHubAlert;
|
|
8
|
-
exports.createSnoozedAlert = createSnoozedAlert;
|
|
9
|
-
exports.createMultipleAlerts = createMultipleAlerts;
|
|
10
|
-
const AlertBuilder_1 = require("./AlertBuilder");
|
|
11
|
-
const alert_types_1 = require("../../../types/alert.types");
|
|
12
|
-
/**
|
|
13
|
-
* Example usage of AlertBuilder
|
|
14
|
-
* This file demonstrates various ways to use the AlertBuilder pattern
|
|
15
|
-
*/
|
|
16
|
-
// Example 1: Basic alert creation
|
|
17
|
-
function createBasicAlert() {
|
|
18
|
-
const alertData = new AlertBuilder_1.AlertBuilder()
|
|
19
|
-
.setCategory(alert_types_1.AlertCategory.OPERATIONS)
|
|
20
|
-
.setPropertyId("prop123")
|
|
21
|
-
.setTitle("Device Offline")
|
|
22
|
-
.setDescription("Device has been offline for more than 5 minutes")
|
|
23
|
-
.setEntityId("device456")
|
|
24
|
-
.setEntityType(alert_types_1.EntityType.DEVICE)
|
|
25
|
-
.setSeverity(alert_types_1.AlertSeverity.HIGH)
|
|
26
|
-
.setCreatedBy("user789")
|
|
27
|
-
.build();
|
|
28
|
-
return alertData;
|
|
29
|
-
}
|
|
30
|
-
// Example 2: Using static factory methods
|
|
31
|
-
function createDeviceAlert() {
|
|
32
|
-
const alertData = AlertBuilder_1.AlertBuilder.createDeviceAlert("device123", "prop456")
|
|
33
|
-
.setCategory(alert_types_1.AlertCategory.READINESS)
|
|
34
|
-
.setTitle("Device Maintenance Required")
|
|
35
|
-
.setDescription("Device firmware update is available")
|
|
36
|
-
.setSeverity(alert_types_1.AlertSeverity.MEDIUM)
|
|
37
|
-
.setCreatedBy("system")
|
|
38
|
-
.build();
|
|
39
|
-
return alertData;
|
|
40
|
-
}
|
|
41
|
-
// Example 3: Using predefined alert types
|
|
42
|
-
function createSecurityAlert() {
|
|
43
|
-
const alertData = AlertBuilder_1.AlertBuilder.createSecurityAlert()
|
|
44
|
-
.setPropertyId("prop789")
|
|
45
|
-
.setTitle("Unauthorized Access Attempt")
|
|
46
|
-
.setDescription("Multiple failed login attempts detected")
|
|
47
|
-
.setEntityId("user123")
|
|
48
|
-
.setEntityType(alert_types_1.EntityType.USER)
|
|
49
|
-
.setCreatedBy("security-system")
|
|
50
|
-
.build();
|
|
51
|
-
return alertData;
|
|
52
|
-
}
|
|
53
|
-
// Example 4: Creating energy alert
|
|
54
|
-
function createEnergyAlert() {
|
|
55
|
-
const alertData = AlertBuilder_1.AlertBuilder.createEnergyAlert()
|
|
56
|
-
.setPropertyId("prop101")
|
|
57
|
-
.setTitle("High Energy Consumption")
|
|
58
|
-
.setDescription("Energy usage is 20% above normal levels")
|
|
59
|
-
.setEntityId("zone456")
|
|
60
|
-
.setEntityType(alert_types_1.EntityType.COLLECTION)
|
|
61
|
-
.setCreatedBy("energy-monitor")
|
|
62
|
-
.build();
|
|
63
|
-
return alertData;
|
|
64
|
-
}
|
|
65
|
-
// Example 5: Creating hub alert
|
|
66
|
-
function createHubAlert() {
|
|
67
|
-
const alertData = AlertBuilder_1.AlertBuilder.createHubAlert("hub789", "prop202")
|
|
68
|
-
.setCategory(alert_types_1.AlertCategory.OPERATIONS)
|
|
69
|
-
.setTitle("Hub Connection Lost")
|
|
70
|
-
.setDescription("Hub has lost connection to the network")
|
|
71
|
-
.setSeverity(alert_types_1.AlertSeverity.CRITICAL)
|
|
72
|
-
.setCreatedBy("network-monitor")
|
|
73
|
-
.build();
|
|
74
|
-
return alertData;
|
|
75
|
-
}
|
|
76
|
-
// Example 6: Alert with snooze
|
|
77
|
-
function createSnoozedAlert() {
|
|
78
|
-
const snoozeUntil = new Date();
|
|
79
|
-
snoozeUntil.setHours(snoozeUntil.getHours() + 2); // Snooze for 2 hours
|
|
80
|
-
const alertData = new AlertBuilder_1.AlertBuilder()
|
|
81
|
-
.setCategory(alert_types_1.AlertCategory.OTHER)
|
|
82
|
-
.setPropertyId("prop303")
|
|
83
|
-
.setTitle("Scheduled Maintenance")
|
|
84
|
-
.setDescription("System maintenance scheduled for tonight")
|
|
85
|
-
.setEntityType(alert_types_1.EntityType.PROPERTY)
|
|
86
|
-
.setSeverity(alert_types_1.AlertSeverity.INFO)
|
|
87
|
-
.setCreatedBy("admin")
|
|
88
|
-
.setSnoozeUntil(snoozeUntil)
|
|
89
|
-
.build();
|
|
90
|
-
return alertData;
|
|
91
|
-
}
|
|
92
|
-
// Example 7: Reusing builder instance
|
|
93
|
-
function createMultipleAlerts() {
|
|
94
|
-
const builder = new AlertBuilder_1.AlertBuilder()
|
|
95
|
-
.setPropertyId("prop404")
|
|
96
|
-
.setCreatedBy("system");
|
|
97
|
-
const alert1 = builder
|
|
98
|
-
.setCategory(alert_types_1.AlertCategory.OPERATIONS)
|
|
99
|
-
.setTitle("Device Temperature High")
|
|
100
|
-
.setDescription("Device temperature exceeds normal operating range")
|
|
101
|
-
.setEntityId("device789")
|
|
102
|
-
.setEntityType(alert_types_1.EntityType.DEVICE)
|
|
103
|
-
.setSeverity(alert_types_1.AlertSeverity.HIGH)
|
|
104
|
-
.build();
|
|
105
|
-
const alert2 = builder
|
|
106
|
-
.reset()
|
|
107
|
-
.setPropertyId("prop404")
|
|
108
|
-
.setCategory(alert_types_1.AlertCategory.ENERGY)
|
|
109
|
-
.setTitle("Low Battery Warning")
|
|
110
|
-
.setDescription("Device battery level is below 20%")
|
|
111
|
-
.setEntityId("device789")
|
|
112
|
-
.setEntityType(alert_types_1.EntityType.DEVICE)
|
|
113
|
-
.setSeverity(alert_types_1.AlertSeverity.MEDIUM)
|
|
114
|
-
.setCreatedBy("system")
|
|
115
|
-
.build();
|
|
116
|
-
return [alert1, alert2];
|
|
117
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AlertBuilder = void 0;
|
|
4
|
-
const alert_types_1 = require("../../../types/alert.types");
|
|
5
|
-
/**
|
|
6
|
-
* AlertBuilder - A builder pattern implementation for constructing CreateAlertData objects
|
|
7
|
-
*
|
|
8
|
-
* This builder provides a fluent interface for creating alert data with proper validation
|
|
9
|
-
* and default values. It follows the Builder pattern which is a standard design pattern
|
|
10
|
-
* in TypeScript for constructing complex objects.
|
|
11
|
-
*
|
|
12
|
-
* Usage example:
|
|
13
|
-
* const alertData = new AlertBuilder()
|
|
14
|
-
* .setCategory(AlertCategory.OPERATIONS)
|
|
15
|
-
* .setPropertyId("prop123")
|
|
16
|
-
* .setTitle("Device Offline")
|
|
17
|
-
* .setDescription("Device has been offline for more than 5 minutes")
|
|
18
|
-
* .setEntityId("device456")
|
|
19
|
-
* .setEntityType(EntityType.DEVICE)
|
|
20
|
-
* .setSeverity(AlertSeverity.HIGH)
|
|
21
|
-
* .setCreatedBy("user789")
|
|
22
|
-
* .build();
|
|
23
|
-
*/
|
|
24
|
-
class AlertBuilder {
|
|
25
|
-
constructor() {
|
|
26
|
-
this.data = {};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Sets the alert category
|
|
30
|
-
*/
|
|
31
|
-
setCategory(category) {
|
|
32
|
-
this.data.category = category;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Sets the property ID
|
|
37
|
-
*/
|
|
38
|
-
setPropertyId(propertyId) {
|
|
39
|
-
if (!propertyId || propertyId.trim() === "") {
|
|
40
|
-
throw new Error("Property ID is required and cannot be empty");
|
|
41
|
-
}
|
|
42
|
-
this.data.propertyId = propertyId;
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Sets the alert title
|
|
47
|
-
*/
|
|
48
|
-
setTitle(title) {
|
|
49
|
-
if (!title || title.trim() === "") {
|
|
50
|
-
throw new Error("Title is required and cannot be empty");
|
|
51
|
-
}
|
|
52
|
-
this.data.title = title.trim();
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Sets the alert description
|
|
57
|
-
*/
|
|
58
|
-
setDescription(description) {
|
|
59
|
-
if (!description || description.trim() === "") {
|
|
60
|
-
throw new Error("Description is required and cannot be empty");
|
|
61
|
-
}
|
|
62
|
-
this.data.description = description.trim();
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Sets the entity ID (optional)
|
|
67
|
-
*/
|
|
68
|
-
setEntityId(entityId) {
|
|
69
|
-
if (entityId !== undefined) {
|
|
70
|
-
this.data.entityId = entityId.trim() || undefined;
|
|
71
|
-
}
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Sets the entity type
|
|
76
|
-
*/
|
|
77
|
-
setEntityType(entityType) {
|
|
78
|
-
this.data.entityType = entityType;
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Sets the alert severity (optional, defaults to MEDIUM)
|
|
83
|
-
*/
|
|
84
|
-
setSeverity(severity) {
|
|
85
|
-
if (severity !== undefined) {
|
|
86
|
-
this.data.severity = severity;
|
|
87
|
-
}
|
|
88
|
-
return this;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Sets the user who created the alert (optional)
|
|
92
|
-
*/
|
|
93
|
-
setCreatedBy(createdBy) {
|
|
94
|
-
if (createdBy !== undefined) {
|
|
95
|
-
this.data.createdBy = createdBy.trim() || undefined;
|
|
96
|
-
}
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Sets the snooze until date (optional)
|
|
101
|
-
*/
|
|
102
|
-
setSnoozeUntil(snoozeUntil) {
|
|
103
|
-
if (snoozeUntil !== undefined) {
|
|
104
|
-
this.data.snoozeUntil = snoozeUntil;
|
|
105
|
-
}
|
|
106
|
-
return this;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Validates that all required fields are present
|
|
110
|
-
*/
|
|
111
|
-
validate() {
|
|
112
|
-
const requiredFields = ["category", "propertyId", "title", "description", "entityType"];
|
|
113
|
-
const missingFields = requiredFields.filter(field => !this.data[field]);
|
|
114
|
-
if (missingFields.length > 0) {
|
|
115
|
-
throw new Error(`Missing required fields: ${missingFields.join(", ")}`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Builds and returns the CreateAlertData object
|
|
120
|
-
* @throws Error if required fields are missing
|
|
121
|
-
*/
|
|
122
|
-
build() {
|
|
123
|
-
this.validate();
|
|
124
|
-
// Set default severity if not provided
|
|
125
|
-
if (!this.data.severity) {
|
|
126
|
-
this.data.severity = alert_types_1.AlertSeverity.MEDIUM;
|
|
127
|
-
}
|
|
128
|
-
return this.data;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Resets the builder to its initial state
|
|
132
|
-
*/
|
|
133
|
-
reset() {
|
|
134
|
-
this.data = {};
|
|
135
|
-
return this;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Creates a new builder instance with predefined values for common alert types
|
|
139
|
-
*/
|
|
140
|
-
static createReadinessAlert() {
|
|
141
|
-
return new AlertBuilder()
|
|
142
|
-
.setCategory(alert_types_1.AlertCategory.READINESS)
|
|
143
|
-
.setSeverity(alert_types_1.AlertSeverity.MEDIUM);
|
|
144
|
-
}
|
|
145
|
-
static createOperationsAlert() {
|
|
146
|
-
return new AlertBuilder()
|
|
147
|
-
.setCategory(alert_types_1.AlertCategory.OPERATIONS)
|
|
148
|
-
.setSeverity(alert_types_1.AlertSeverity.HIGH);
|
|
149
|
-
}
|
|
150
|
-
static createSecurityAlert() {
|
|
151
|
-
return new AlertBuilder()
|
|
152
|
-
.setCategory(alert_types_1.AlertCategory.SECURITY)
|
|
153
|
-
.setSeverity(alert_types_1.AlertSeverity.CRITICAL);
|
|
154
|
-
}
|
|
155
|
-
static createEnergyAlert() {
|
|
156
|
-
return new AlertBuilder()
|
|
157
|
-
.setCategory(alert_types_1.AlertCategory.ENERGY)
|
|
158
|
-
.setSeverity(alert_types_1.AlertSeverity.LOW);
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Creates a device-specific alert builder
|
|
162
|
-
*/
|
|
163
|
-
static createDeviceAlert(deviceId, propertyId) {
|
|
164
|
-
return new AlertBuilder()
|
|
165
|
-
.setEntityType(alert_types_1.EntityType.DEVICE)
|
|
166
|
-
.setEntityId(deviceId)
|
|
167
|
-
.setPropertyId(propertyId);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Creates a hub-specific alert builder
|
|
171
|
-
*/
|
|
172
|
-
static createHubAlert(hubId, propertyId) {
|
|
173
|
-
return new AlertBuilder()
|
|
174
|
-
.setEntityType(alert_types_1.EntityType.HUB)
|
|
175
|
-
.setEntityId(hubId)
|
|
176
|
-
.setPropertyId(propertyId);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
exports.AlertBuilder = AlertBuilder;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IssueBuilder = exports.AlertBuilder = void 0;
|
|
4
|
-
var AlertBuilder_1 = require("./AlertBuilder");
|
|
5
|
-
Object.defineProperty(exports, "AlertBuilder", { enumerable: true, get: function () { return AlertBuilder_1.AlertBuilder; } });
|
|
6
|
-
var IssueBuilder_1 = require("./IssueBuilder");
|
|
7
|
-
Object.defineProperty(exports, "IssueBuilder", { enumerable: true, get: function () { return IssueBuilder_1.IssueBuilder; } });
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventHandler = void 0;
|
|
4
|
-
const dt_pub_sub_1 = require("dt-pub-sub");
|
|
5
|
-
const dt_audit_library_1 = require("dt-audit-library");
|
|
6
|
-
const Events_1 = require("./Events");
|
|
7
|
-
class EventHandler {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.source = "dt-common-device";
|
|
10
|
-
}
|
|
11
|
-
async onDeviceCreate(body) {
|
|
12
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.CREATED, body, this.source);
|
|
13
|
-
const payload = {
|
|
14
|
-
eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.CREATED,
|
|
15
|
-
properties: {
|
|
16
|
-
...body,
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
20
|
-
}
|
|
21
|
-
async onDeviceUpdate(deviceId, body) {
|
|
22
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.UPDATED, { deviceId, body }, this.source);
|
|
23
|
-
const payload = {
|
|
24
|
-
eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.UPDATED,
|
|
25
|
-
properties: {
|
|
26
|
-
...body,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
30
|
-
}
|
|
31
|
-
async onDeviceDelete(deviceId) {
|
|
32
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.DELETED, { deviceId }, this.source);
|
|
33
|
-
const payload = {
|
|
34
|
-
eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.DELETED,
|
|
35
|
-
properties: {
|
|
36
|
-
deviceId,
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
40
|
-
}
|
|
41
|
-
async onStateChange(deviceId, state) {
|
|
42
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.STATE.SET, { deviceId, state }, this.source);
|
|
43
|
-
const payload = {
|
|
44
|
-
eventType: Events_1.DT_EVENT_TYPES.DEVICE.STATE.SET,
|
|
45
|
-
properties: {
|
|
46
|
-
deviceId,
|
|
47
|
-
state,
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
51
|
-
}
|
|
52
|
-
async onStatusChange(deviceId, status) {
|
|
53
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.STATUS.SET, { deviceId, status }, this.source);
|
|
54
|
-
const payload = {
|
|
55
|
-
eventType: Events_1.DT_EVENT_TYPES.DEVICE.STATUS.SET,
|
|
56
|
-
properties: {
|
|
57
|
-
deviceId,
|
|
58
|
-
status,
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
62
|
-
}
|
|
63
|
-
async onBatteryLevelChange(deviceId, batteryLevel) {
|
|
64
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.BATTERY.SET, { deviceId, batteryLevel }, this.source);
|
|
65
|
-
const payload = {
|
|
66
|
-
eventType: Events_1.DT_EVENT_TYPES.DEVICE.BATTERY.SET,
|
|
67
|
-
properties: {
|
|
68
|
-
deviceId,
|
|
69
|
-
batteryLevel,
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
73
|
-
}
|
|
74
|
-
async onDeviceMetaChange(deviceId, metaData) {
|
|
75
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.META_DATA.SET, { deviceId, metaData }, this.source);
|
|
76
|
-
const payload = {
|
|
77
|
-
eventType: Events_1.DT_EVENT_TYPES.DEVICE.META_DATA.SET,
|
|
78
|
-
properties: {
|
|
79
|
-
deviceId,
|
|
80
|
-
metaData,
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.EventHandler = EventHandler;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DT_EVENT_TYPES = void 0;
|
|
4
|
-
exports.DT_EVENT_TYPES = {
|
|
5
|
-
DEVICE: {
|
|
6
|
-
DEVICE: {
|
|
7
|
-
CREATED: "device.device.created",
|
|
8
|
-
UPDATED: "device.device.updated",
|
|
9
|
-
DELETED: "device.device.deleted",
|
|
10
|
-
},
|
|
11
|
-
STATE: {
|
|
12
|
-
SET: "device.state.set",
|
|
13
|
-
UNKNOWN: "device.state.unknown",
|
|
14
|
-
UPDATED: "device.state.updated",
|
|
15
|
-
CHANGED: "device.state.changed",
|
|
16
|
-
},
|
|
17
|
-
STATUS: {
|
|
18
|
-
SET: "device.status.set",
|
|
19
|
-
ONLINE: "device.status.online",
|
|
20
|
-
OFFLINE: "device.status.offline",
|
|
21
|
-
UNKNOWN: "device.status.unknown",
|
|
22
|
-
UPDATED: "device.status.updated",
|
|
23
|
-
CHANGED: "device.status.changed",
|
|
24
|
-
},
|
|
25
|
-
BATTERY: {
|
|
26
|
-
SET: "device.battery.set",
|
|
27
|
-
UNKNOWN: "device.battery.unknown",
|
|
28
|
-
LOW: "device.battery.low",
|
|
29
|
-
CRITICAL: "device.battery.critical",
|
|
30
|
-
UPDATED: "device.battery.updated",
|
|
31
|
-
CHANGED: "device.battery.changed",
|
|
32
|
-
},
|
|
33
|
-
META_DATA: {
|
|
34
|
-
SET: "device.metaData.set",
|
|
35
|
-
UPDATED: "device.metaData.updated",
|
|
36
|
-
CHANGED: "device.metaData.changed",
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
CONNECTION: {
|
|
40
|
-
CONNECTION: {
|
|
41
|
-
CREATED: "connection.connection.created",
|
|
42
|
-
UPDATED: "connection.connection.updated",
|
|
43
|
-
DELETED: "connection.connection.deleted",
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
PROPERTY: {
|
|
47
|
-
PROPERTY: {
|
|
48
|
-
CREATED: "property.property.created",
|
|
49
|
-
UPDATED: "property.property.updated",
|
|
50
|
-
DELETED: "property.property.deleted",
|
|
51
|
-
},
|
|
52
|
-
PREFERENCES: {
|
|
53
|
-
UPDATED: "property.preferences.updated",
|
|
54
|
-
CREATED: "property.preferences.created",
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventHandler = exports.DT_EVENT_TYPES = void 0;
|
|
4
|
-
var Events_1 = require("./Events");
|
|
5
|
-
Object.defineProperty(exports, "DT_EVENT_TYPES", { enumerable: true, get: function () { return Events_1.DT_EVENT_TYPES; } });
|
|
6
|
-
var EventHandler_1 = require("./EventHandler");
|
|
7
|
-
Object.defineProperty(exports, "EventHandler", { enumerable: true, get: function () { return EventHandler_1.EventHandler; } });
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventHandler = void 0;
|
|
4
|
-
const dt_pub_sub_1 = require("dt-pub-sub");
|
|
5
|
-
const dt_audit_library_1 = require("dt-audit-library");
|
|
6
|
-
class EventHandler {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.source = "dt-common-device";
|
|
9
|
-
}
|
|
10
|
-
async onStateChange(deviceId, state) {
|
|
11
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent("device.state.set", { deviceId, state }, this.source);
|
|
12
|
-
const payload = {
|
|
13
|
-
eventType: "device.state.set",
|
|
14
|
-
properties: {
|
|
15
|
-
deviceId,
|
|
16
|
-
state,
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
20
|
-
}
|
|
21
|
-
async onStatusChange(deviceId, status) {
|
|
22
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent("device.status.set", { deviceId, status }, this.source);
|
|
23
|
-
const payload = {
|
|
24
|
-
eventType: "device.status.set",
|
|
25
|
-
properties: {
|
|
26
|
-
deviceId,
|
|
27
|
-
status,
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
31
|
-
}
|
|
32
|
-
async onBatteryLevelChange(deviceId, batteryLevel) {
|
|
33
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent("device.battery.set", { deviceId, batteryLevel }, this.source);
|
|
34
|
-
const payload = {
|
|
35
|
-
eventType: "device.battery.set",
|
|
36
|
-
properties: {
|
|
37
|
-
deviceId,
|
|
38
|
-
batteryLevel,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.EventHandler = EventHandler;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConnectionProvider = void 0;
|
|
4
|
-
var ConnectionProvider;
|
|
5
|
-
(function (ConnectionProvider) {
|
|
6
|
-
ConnectionProvider["Smartthings"] = "Smartthings";
|
|
7
|
-
ConnectionProvider["SaltoKS"] = "SaltoKS";
|
|
8
|
-
ConnectionProvider["TTLock"] = "TTLock";
|
|
9
|
-
ConnectionProvider["Tuya"] = "Tuya";
|
|
10
|
-
ConnectionProvider["Schlage"] = "Schlage";
|
|
11
|
-
ConnectionProvider["YaleWifi"] = "YaleWifi";
|
|
12
|
-
ConnectionProvider["Sensibo"] = "Sensibo";
|
|
13
|
-
ConnectionProvider["Devicethread"] = "Devicethread";
|
|
14
|
-
})(ConnectionProvider || (exports.ConnectionProvider = ConnectionProvider = {}));
|