dt-common-device 12.0.4 → 13.0.0
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/issues/Issue.service.js +1 -1
- package/package.json +1 -1
- package/dist/alerts/AlertBuilder.example.d.ts +0 -11
- package/dist/alerts/AlertBuilder.example.js +0 -117
- package/dist/alerts/AlertService.example.d.ts +0 -55
- package/dist/alerts/AlertService.example.js +0 -150
- package/dist/chronicle/Cronicle.service.d.ts +0 -13
- package/dist/chronicle/Cronicle.service.js +0 -93
- package/dist/chronicle/ICronicle.interface.d.ts +0 -16
- package/dist/chronicle/ICronicle.interface.js +0 -2
- package/dist/chronicle/index.d.ts +0 -2
- package/dist/chronicle/index.js +0 -5
- package/dist/entities/accessGroup/AccessGroup.repository.d.ts +0 -6
- package/dist/entities/accessGroup/AccessGroup.repository.js +0 -75
- package/dist/entities/accessGroup/AccessGroup.service.d.ts +0 -6
- package/dist/entities/accessGroup/AccessGroup.service.js +0 -106
- package/dist/entities/accessGroup/IAccessGroup.d.ts +0 -14
- package/dist/entities/accessGroup/IAccessGroup.js +0 -2
- package/dist/entities/accessGroup/index.d.ts +0 -2
- package/dist/entities/accessGroup/index.js +0 -18
- package/dist/entities/device/local/repository/DeviceProfile.repository.d.ts +0 -5
- package/dist/entities/device/local/repository/DeviceProfile.repository.js +0 -75
- package/dist/entities/guest/Guest.repository.d.ts +0 -6
- package/dist/entities/guest/Guest.repository.js +0 -77
- package/dist/entities/guest/Guest.service.d.ts +0 -6
- package/dist/entities/guest/Guest.service.js +0 -107
- package/dist/entities/guest/IGuest.d.ts +0 -12
- package/dist/entities/guest/IGuest.js +0 -2
- package/dist/entities/guest/index.d.ts +0 -2
- package/dist/entities/guest/index.js +0 -18
- package/dist/entities/schedules/ISchedule.d.ts +0 -14
- package/dist/entities/schedules/ISchedule.js +0 -2
- package/dist/entities/schedules/Schedule.repository.d.ts +0 -6
- package/dist/entities/schedules/Schedule.repository.js +0 -77
- package/dist/entities/schedules/Schedule.service.d.ts +0 -6
- package/dist/entities/schedules/Schedule.service.js +0 -107
- package/dist/entities/schedules/index.d.ts +0 -2
- package/dist/entities/schedules/index.js +0 -18
- package/dist/entities/user/IUser.d.ts +0 -15
- package/dist/entities/user/IUser.js +0 -2
- package/dist/entities/user/User.repository.d.ts +0 -5
- package/dist/entities/user/User.repository.js +0 -71
- package/dist/entities/user/User.service.d.ts +0 -6
- package/dist/entities/user/User.service.js +0 -106
- package/dist/entities/zone/IZone.d.ts +0 -10
- package/dist/entities/zone/IZone.js +0 -2
- package/dist/entities/zone/Zone.repository.d.ts +0 -6
- package/dist/entities/zone/Zone.repository.js +0 -77
- package/dist/entities/zone/Zone.service.d.ts +0 -6
- package/dist/entities/zone/Zone.service.js +0 -107
- package/dist/entities/zone/index.d.ts +0 -2
- package/dist/entities/zone/index.js +0 -18
- package/dist/issues/IssueBuilder.example.d.ts +0 -16
- package/dist/issues/IssueBuilder.example.js +0 -196
- package/dist/issues/IssueService.example.d.ts +0 -68
- package/dist/issues/IssueService.example.js +0 -292
|
@@ -239,7 +239,7 @@ let IssueService = (() => {
|
|
|
239
239
|
title: device.deviceType.type.toLowerCase() === "hub"
|
|
240
240
|
? "Hub Offline"
|
|
241
241
|
: "Device Offline",
|
|
242
|
-
description: `${device.name} has gone offline ${reason ? `Reason: ${reason}
|
|
242
|
+
description: `${device.name} has gone offline. ${reason ? `Reason: ${reason}.` : ""}`,
|
|
243
243
|
createdBy: source,
|
|
244
244
|
category: issue_types_1.IssuesCategory.OPERATIONS,
|
|
245
245
|
priority: issue_types_1.IssuePriority.CRITICAL,
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example usage of AlertBuilder
|
|
3
|
-
* This file demonstrates various ways to use the AlertBuilder pattern
|
|
4
|
-
*/
|
|
5
|
-
export declare function createBasicAlert(): import("./alert.types").CreateAlertData;
|
|
6
|
-
export declare function createDeviceAlert(): import("./alert.types").CreateAlertData;
|
|
7
|
-
export declare function createSecurityAlert(): import("./alert.types").CreateAlertData;
|
|
8
|
-
export declare function createEnergyAlert(): import("./alert.types").CreateAlertData;
|
|
9
|
-
export declare function createHubAlert(): import("./alert.types").CreateAlertData;
|
|
10
|
-
export declare function createSnoozedAlert(): import("./alert.types").CreateAlertData;
|
|
11
|
-
export declare function createMultipleAlerts(): import("./alert.types").CreateAlertData[];
|
|
@@ -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("./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,55 +0,0 @@
|
|
|
1
|
-
import { AlertService } from "./Alert.service";
|
|
2
|
-
/**
|
|
3
|
-
* Example usage of the updated AlertService with AlertBuilder integration
|
|
4
|
-
* This file demonstrates various ways to use the AlertService with the new AlertBuilder
|
|
5
|
-
*/
|
|
6
|
-
export declare class AlertServiceExample {
|
|
7
|
-
private readonly alertService;
|
|
8
|
-
constructor(alertService: AlertService);
|
|
9
|
-
/**
|
|
10
|
-
* Example 1: Using the updated createAlert method with AlertBuilder
|
|
11
|
-
*/
|
|
12
|
-
createAlertWithBuilder(): Promise<import("./alert.types").AlertDocument>;
|
|
13
|
-
/**
|
|
14
|
-
* Example 2: Using convenience methods for specific alert types
|
|
15
|
-
*/
|
|
16
|
-
createSpecificAlerts(): Promise<{
|
|
17
|
-
readinessAlert: import("./alert.types").AlertDocument;
|
|
18
|
-
operationsAlert: import("./alert.types").AlertDocument;
|
|
19
|
-
securityAlert: import("./alert.types").AlertDocument;
|
|
20
|
-
energyAlert: import("./alert.types").AlertDocument;
|
|
21
|
-
}>;
|
|
22
|
-
/**
|
|
23
|
-
* Example 3: Using device-specific alert methods
|
|
24
|
-
*/
|
|
25
|
-
createDeviceAlerts(): Promise<{
|
|
26
|
-
deviceAlert1: import("./alert.types").AlertDocument;
|
|
27
|
-
deviceAlert2: import("./alert.types").AlertDocument;
|
|
28
|
-
}>;
|
|
29
|
-
/**
|
|
30
|
-
* Example 4: Using hub-specific alert methods
|
|
31
|
-
*/
|
|
32
|
-
createHubAlerts(): Promise<{
|
|
33
|
-
hubAlert1: import("./alert.types").AlertDocument;
|
|
34
|
-
hubAlert2: import("./alert.types").AlertDocument;
|
|
35
|
-
}>;
|
|
36
|
-
/**
|
|
37
|
-
* Example 5: Using static factory methods with AlertBuilder
|
|
38
|
-
*/
|
|
39
|
-
createAlertsWithStaticMethods(): Promise<{
|
|
40
|
-
alert1: import("./alert.types").AlertDocument;
|
|
41
|
-
alert2: import("./alert.types").AlertDocument;
|
|
42
|
-
}>;
|
|
43
|
-
/**
|
|
44
|
-
* Example 6: Creating multiple alerts efficiently
|
|
45
|
-
*/
|
|
46
|
-
createMultipleAlerts(): Promise<import("./alert.types").AlertDocument[]>;
|
|
47
|
-
/**
|
|
48
|
-
* Example 7: Creating alerts with snooze functionality
|
|
49
|
-
*/
|
|
50
|
-
createSnoozedAlert(): Promise<import("./alert.types").AlertDocument>;
|
|
51
|
-
/**
|
|
52
|
-
* Example 8: Backward compatibility - still works with CreateAlertData
|
|
53
|
-
*/
|
|
54
|
-
createAlertWithLegacyData(): Promise<import("./alert.types").AlertDocument>;
|
|
55
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AlertServiceExample = void 0;
|
|
4
|
-
const Service_1 = require("../constants/Service");
|
|
5
|
-
const AlertBuilder_1 = require("./AlertBuilder");
|
|
6
|
-
const alert_types_1 = require("./alert.types");
|
|
7
|
-
/**
|
|
8
|
-
* Example usage of the updated AlertService with AlertBuilder integration
|
|
9
|
-
* This file demonstrates various ways to use the AlertService with the new AlertBuilder
|
|
10
|
-
*/
|
|
11
|
-
class AlertServiceExample {
|
|
12
|
-
constructor(alertService) {
|
|
13
|
-
this.alertService = alertService;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Example 1: Using the updated createAlert method with AlertBuilder
|
|
17
|
-
*/
|
|
18
|
-
async createAlertWithBuilder() {
|
|
19
|
-
const alertBuilder = new AlertBuilder_1.AlertBuilder()
|
|
20
|
-
.setCategory(alert_types_1.AlertCategory.OPERATIONS)
|
|
21
|
-
.setPropertyId("prop123")
|
|
22
|
-
.setTitle("Device Offline")
|
|
23
|
-
.setDescription("Device has been offline for more than 5 minutes")
|
|
24
|
-
.setEntityId("device456")
|
|
25
|
-
.setEntityType(alert_types_1.EntityType.DEVICE)
|
|
26
|
-
.setSeverity(alert_types_1.AlertSeverity.HIGH)
|
|
27
|
-
.setCreatedBy("user789");
|
|
28
|
-
// Pass the AlertBuilder directly to createAlert
|
|
29
|
-
const alert = await this.alertService.createAlert(alertBuilder);
|
|
30
|
-
return alert;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Example 2: Using convenience methods for specific alert types
|
|
34
|
-
*/
|
|
35
|
-
async createSpecificAlerts() {
|
|
36
|
-
// Create a readiness alert
|
|
37
|
-
const readinessAlert = await this.alertService.raiseReadinessAlert("prop123", "System Maintenance Required", "System maintenance is scheduled for tonight", "system456", alert_types_1.EntityType.PROPERTY, "admin");
|
|
38
|
-
// Create an operations alert
|
|
39
|
-
const operationsAlert = await this.alertService.raiseOperationsAlert("prop123", "Device Temperature High", "Device temperature exceeds normal operating range", "device789", alert_types_1.EntityType.DEVICE, "monitor");
|
|
40
|
-
// Create a security alert
|
|
41
|
-
const securityAlert = await this.alertService.raiseSecurityAlert("prop123", "Unauthorized Access Attempt", "Multiple failed login attempts detected", "user123", alert_types_1.EntityType.USER, "security-system");
|
|
42
|
-
// Create an energy alert
|
|
43
|
-
const energyAlert = await this.alertService.raiseEnergyAlert("prop123", "High Energy Consumption", "Energy usage is 20% above normal levels", "zone456", alert_types_1.EntityType.COLLECTION, "energy-monitor");
|
|
44
|
-
return { readinessAlert, operationsAlert, securityAlert, energyAlert };
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Example 3: Using device-specific alert methods
|
|
48
|
-
*/
|
|
49
|
-
async createDeviceAlerts() {
|
|
50
|
-
// Create a device alert with default category and severity
|
|
51
|
-
const deviceAlert1 = await this.alertService.raiseDeviceAlert("device123", "prop456", "Device Battery Low", "Device battery level is below 20%", undefined, // Use default category
|
|
52
|
-
undefined, // Use default severity
|
|
53
|
-
Service_1.Source.CLOUD_EVENT);
|
|
54
|
-
// Create a device alert with custom category and severity
|
|
55
|
-
const deviceAlert2 = await this.alertService.raiseDeviceAlert("device789", "prop456", "Device Firmware Update Available", "New firmware version is available for installation", alert_types_1.AlertCategory.READINESS, alert_types_1.AlertSeverity.MEDIUM, Service_1.Source.CLOUD_EVENT);
|
|
56
|
-
return { deviceAlert1, deviceAlert2 };
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Example 4: Using hub-specific alert methods
|
|
60
|
-
*/
|
|
61
|
-
async createHubAlerts() {
|
|
62
|
-
// Create a hub alert with default settings
|
|
63
|
-
const hubAlert1 = await this.alertService.raiseHubAlert("hub123", "prop456", "Hub Connection Lost", "Hub has lost connection to the network", undefined, // Use default category
|
|
64
|
-
undefined, // Use default severity
|
|
65
|
-
"network-monitor");
|
|
66
|
-
// Create a hub alert with custom settings
|
|
67
|
-
const hubAlert2 = await this.alertService.raiseHubAlert("hub789", "prop456", "Hub Maintenance Required", "Hub requires scheduled maintenance", alert_types_1.AlertCategory.READINESS, alert_types_1.AlertSeverity.LOW, "maintenance-system");
|
|
68
|
-
return { hubAlert1, hubAlert2 };
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Example 5: Using static factory methods with AlertBuilder
|
|
72
|
-
*/
|
|
73
|
-
async createAlertsWithStaticMethods() {
|
|
74
|
-
// Create a device alert using static factory method
|
|
75
|
-
const deviceAlert = AlertBuilder_1.AlertBuilder.createDeviceAlert("device123", "prop456")
|
|
76
|
-
.setCategory(alert_types_1.AlertCategory.OPERATIONS)
|
|
77
|
-
.setTitle("Device Offline")
|
|
78
|
-
.setDescription("Device has been offline for more than 5 minutes")
|
|
79
|
-
.setSeverity(alert_types_1.AlertSeverity.HIGH)
|
|
80
|
-
.setCreatedBy("monitor");
|
|
81
|
-
const alert1 = await this.alertService.createAlert(deviceAlert);
|
|
82
|
-
// Create a hub alert using static factory method
|
|
83
|
-
const hubAlert = AlertBuilder_1.AlertBuilder.createHubAlert("hub789", "prop202")
|
|
84
|
-
.setCategory(alert_types_1.AlertCategory.SECURITY)
|
|
85
|
-
.setTitle("Hub Security Breach")
|
|
86
|
-
.setDescription("Unauthorized access attempt detected on hub")
|
|
87
|
-
.setSeverity(alert_types_1.AlertSeverity.CRITICAL)
|
|
88
|
-
.setCreatedBy("security-system");
|
|
89
|
-
const alert2 = await this.alertService.createAlert(hubAlert);
|
|
90
|
-
return { alert1, alert2 };
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Example 6: Creating multiple alerts efficiently
|
|
94
|
-
*/
|
|
95
|
-
async createMultipleAlerts() {
|
|
96
|
-
const alerts = [];
|
|
97
|
-
// Create multiple device alerts efficiently
|
|
98
|
-
const deviceIds = ["device1", "device2", "device3"];
|
|
99
|
-
const propertyId = "prop123";
|
|
100
|
-
for (const deviceId of deviceIds) {
|
|
101
|
-
const alertBuilder = AlertBuilder_1.AlertBuilder.createDeviceAlert(deviceId, propertyId)
|
|
102
|
-
.setCategory(alert_types_1.AlertCategory.OPERATIONS)
|
|
103
|
-
.setTitle(`Device ${deviceId} Status`)
|
|
104
|
-
.setDescription(`Status check for device ${deviceId}`)
|
|
105
|
-
.setSeverity(alert_types_1.AlertSeverity.MEDIUM)
|
|
106
|
-
.setCreatedBy("batch-processor");
|
|
107
|
-
const alert = await this.alertService.createAlert(alertBuilder);
|
|
108
|
-
alerts.push(alert);
|
|
109
|
-
}
|
|
110
|
-
return alerts;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Example 7: Creating alerts with snooze functionality
|
|
114
|
-
*/
|
|
115
|
-
async createSnoozedAlert() {
|
|
116
|
-
const snoozeUntil = new Date();
|
|
117
|
-
snoozeUntil.setHours(snoozeUntil.getHours() + 2); // Snooze for 2 hours
|
|
118
|
-
const alertBuilder = new AlertBuilder_1.AlertBuilder()
|
|
119
|
-
.setCategory(alert_types_1.AlertCategory.OTHER)
|
|
120
|
-
.setPropertyId("prop303")
|
|
121
|
-
.setTitle("Scheduled Maintenance")
|
|
122
|
-
.setDescription("System maintenance scheduled for tonight")
|
|
123
|
-
.setEntityType(alert_types_1.EntityType.PROPERTY)
|
|
124
|
-
.setSeverity(alert_types_1.AlertSeverity.INFO)
|
|
125
|
-
.setCreatedBy("admin")
|
|
126
|
-
.setSnoozeUntil(snoozeUntil);
|
|
127
|
-
const alert = await this.alertService.createAlert(alertBuilder);
|
|
128
|
-
return alert;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Example 8: Backward compatibility - still works with CreateAlertData
|
|
132
|
-
*/
|
|
133
|
-
async createAlertWithLegacyData() {
|
|
134
|
-
const alertData = {
|
|
135
|
-
category: alert_types_1.AlertCategory.OPERATIONS,
|
|
136
|
-
propertyId: "prop123",
|
|
137
|
-
title: "Legacy Alert",
|
|
138
|
-
description: "This alert was created using the old CreateAlertData format",
|
|
139
|
-
entityId: "device456",
|
|
140
|
-
entityType: alert_types_1.EntityType.DEVICE,
|
|
141
|
-
severity: alert_types_1.AlertSeverity.MEDIUM,
|
|
142
|
-
createdBy: "legacy-system",
|
|
143
|
-
source: Service_1.Source.CLOUD_EVENT,
|
|
144
|
-
};
|
|
145
|
-
// This still works with the updated createAlert method
|
|
146
|
-
const alert = await this.alertService.createAlert(alertData);
|
|
147
|
-
return alert;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
exports.AlertServiceExample = AlertServiceExample;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ICronicle } from "./ICronicle.interface";
|
|
2
|
-
export declare class CronicleService {
|
|
3
|
-
private readonly cronicleEndpoint;
|
|
4
|
-
private readonly cronicleApiKey;
|
|
5
|
-
constructor();
|
|
6
|
-
registerJob(payload: ICronicle): Promise<void>;
|
|
7
|
-
getJob(jobId: string): Promise<any>;
|
|
8
|
-
getSchedules(filter: {
|
|
9
|
-
offset: number;
|
|
10
|
-
limit: number;
|
|
11
|
-
}): Promise<any>;
|
|
12
|
-
deleteJob(jobId: string): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CronicleService = void 0;
|
|
7
|
-
const config_1 = require("../config/config");
|
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
class CronicleService {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.cronicleEndpoint = process.env.CRONICLE_ENDPOINT || "";
|
|
12
|
-
this.cronicleApiKey = process.env.CRONICLE_API_KEY || "";
|
|
13
|
-
}
|
|
14
|
-
async registerJob(payload) {
|
|
15
|
-
const { name, apiUrl, method, schedule, cronJobId, target, category } = payload;
|
|
16
|
-
try {
|
|
17
|
-
await axios_1.default.post(`${this.cronicleEndpoint}/create_event/v1`, {
|
|
18
|
-
id: cronJobId,
|
|
19
|
-
title: name,
|
|
20
|
-
category: category ?? "general",
|
|
21
|
-
plugin: "urlplug",
|
|
22
|
-
timeZone: "UTC",
|
|
23
|
-
enabled: 1,
|
|
24
|
-
target: target,
|
|
25
|
-
api_key: this.cronicleApiKey,
|
|
26
|
-
params: {
|
|
27
|
-
url: apiUrl,
|
|
28
|
-
method,
|
|
29
|
-
headers: {
|
|
30
|
-
"Content-Type": "application/json",
|
|
31
|
-
"x-api-key": this.cronicleApiKey,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
data: payload,
|
|
35
|
-
timing: {
|
|
36
|
-
years: schedule.years,
|
|
37
|
-
months: schedule.months,
|
|
38
|
-
days: schedule.days,
|
|
39
|
-
weekdays: schedule.weekdays,
|
|
40
|
-
hours: schedule.hours,
|
|
41
|
-
minutes: schedule.minutes,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
(0, config_1.getConfig)().LOGGER.error(`Failed to create device: ${error.message}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async getJob(jobId) {
|
|
50
|
-
try {
|
|
51
|
-
(0, config_1.getConfig)().LOGGER.info(`Getting job: ${jobId}`);
|
|
52
|
-
(0, config_1.getConfig)().LOGGER.info(`Cronicle endpoint: ${this.cronicleEndpoint}/get_event/v1`);
|
|
53
|
-
const res = await axios_1.default.post(`${this.cronicleEndpoint}/get_event/v1`, {
|
|
54
|
-
id: jobId,
|
|
55
|
-
api_key: this.cronicleApiKey,
|
|
56
|
-
});
|
|
57
|
-
return res.data;
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
(0, config_1.getConfig)().LOGGER.error(`Failed to get job: ${error.message}`);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async getSchedules(filter) {
|
|
65
|
-
try {
|
|
66
|
-
const res = await axios_1.default.post(`${this.cronicleEndpoint}/get_schedule/v1`, {
|
|
67
|
-
api_key: this.cronicleApiKey,
|
|
68
|
-
offset: filter.offset ?? 0,
|
|
69
|
-
limit: filter.limit ?? 100,
|
|
70
|
-
});
|
|
71
|
-
return res.data;
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
(0, config_1.getConfig)().LOGGER.error(`Failed to get schedules: ${error.message}`);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async deleteJob(jobId) {
|
|
79
|
-
try {
|
|
80
|
-
(0, config_1.getConfig)().LOGGER.info(`Deleting job: ${jobId}`);
|
|
81
|
-
await axios_1.default.post(`${this.cronicleEndpoint}/delete_event/v1`, {
|
|
82
|
-
id: jobId,
|
|
83
|
-
api_key: this.cronicleApiKey,
|
|
84
|
-
});
|
|
85
|
-
(0, config_1.getConfig)().LOGGER.info(`Deleted job: ${jobId}`);
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
(0, config_1.getConfig)().LOGGER.error(`Failed to delete job: ${error.message}`);
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.CronicleService = CronicleService;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface ICronicle {
|
|
2
|
-
name: string;
|
|
3
|
-
cronJobId: string;
|
|
4
|
-
category?: "heartbeat" | "replenish_codes" | "sync_reservations" | "delete_reservations" | "deliver_codes" | "daily_summary" | "battery_report";
|
|
5
|
-
apiUrl: string;
|
|
6
|
-
method: "POST";
|
|
7
|
-
target: string;
|
|
8
|
-
schedule: {
|
|
9
|
-
years?: number[];
|
|
10
|
-
months?: number[];
|
|
11
|
-
days?: number[];
|
|
12
|
-
weekdays?: number[];
|
|
13
|
-
hours?: number[];
|
|
14
|
-
minutes?: number[];
|
|
15
|
-
};
|
|
16
|
-
}
|
package/dist/chronicle/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CronicleService = void 0;
|
|
4
|
-
var Cronicle_service_1 = require("./Cronicle.service");
|
|
5
|
-
Object.defineProperty(exports, "CronicleService", { enumerable: true, get: function () { return Cronicle_service_1.CronicleService; } });
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.AccessGroupRepository = void 0;
|
|
42
|
-
const typedi_1 = require("typedi");
|
|
43
|
-
const db_1 = require("../../db");
|
|
44
|
-
let AccessGroupRepository = (() => {
|
|
45
|
-
let _classDecorators = [(0, typedi_1.Service)()];
|
|
46
|
-
let _classDescriptor;
|
|
47
|
-
let _classExtraInitializers = [];
|
|
48
|
-
let _classThis;
|
|
49
|
-
var AccessGroupRepository = _classThis = class {
|
|
50
|
-
constructor() {
|
|
51
|
-
this.postgres = (0, db_1.getPostgresClient)();
|
|
52
|
-
}
|
|
53
|
-
async getAccessGroup(accessGroupId) {
|
|
54
|
-
const query = `
|
|
55
|
-
SELECT * FROM dt_collections
|
|
56
|
-
WHERE "id" = $1
|
|
57
|
-
`;
|
|
58
|
-
const result = await this.postgres.query(query, [accessGroupId]);
|
|
59
|
-
if (result.rows.length > 0) {
|
|
60
|
-
return result.rows[0];
|
|
61
|
-
}
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
__setFunctionName(_classThis, "AccessGroupRepository");
|
|
66
|
-
(() => {
|
|
67
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
68
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
69
|
-
AccessGroupRepository = _classThis = _classDescriptor.value;
|
|
70
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
71
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
72
|
-
})();
|
|
73
|
-
return AccessGroupRepository = _classThis;
|
|
74
|
-
})();
|
|
75
|
-
exports.AccessGroupRepository = AccessGroupRepository;
|