dt-common-device 7.10.11 → 8.0.1
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/admin/Admin.repository.d.ts +7 -0
- package/dist/admin/Admin.repository.js +182 -0
- package/dist/admin/Admin.service.d.ts +5 -0
- package/dist/admin/Admin.service.js +17 -0
- package/dist/admin/index.d.ts +1 -0
- package/dist/admin/index.js +17 -0
- package/dist/audit/AuditProperties.d.ts +16 -0
- package/dist/audit/AuditProperties.js +2 -0
- package/dist/chronicle/Cronicle.service.d.ts +2 -6
- package/dist/chronicle/Cronicle.service.js +2 -19
- package/dist/chronicle/IChronicle.interface.d.ts +14 -0
- package/dist/chronicle/IChronicle.interface.js +2 -0
- package/dist/chronicle/ICronicle.interface.d.ts +0 -1
- package/dist/chronicle/chronicle.service.d.ts +4 -0
- package/dist/chronicle/chronicle.service.js +44 -0
- package/dist/config/config.d.ts +3 -0
- package/dist/config/config.js +36 -0
- package/dist/config/constants.js +11 -1
- package/dist/connection/Connection.repository.d.ts +8 -0
- package/dist/connection/Connection.repository.js +92 -0
- package/dist/connection/Connection.service.d.ts +8 -0
- package/dist/connection/Connection.service.js +32 -0
- package/dist/connection/IConnection.d.ts +28 -0
- package/dist/connection/IConnection.js +16 -0
- package/dist/connection/index.d.ts +2 -0
- package/dist/connection/index.js +18 -0
- package/dist/device/cloud/entities/CloudConnection.d.ts +6 -0
- package/dist/device/cloud/entities/CloudConnection.js +6 -0
- package/dist/device/cloud/entities/CloudDevice.d.ts +16 -0
- package/dist/device/cloud/entities/CloudDevice.js +26 -0
- package/dist/device/cloud/entities/CloudDeviceService.d.ts +5 -0
- package/dist/device/cloud/entities/CloudDeviceService.js +9 -0
- package/dist/device/cloud/entities/DeviceFactory.d.ts +7 -0
- package/dist/device/cloud/entities/DeviceFactory.js +80 -0
- package/dist/device/cloud/entities/index.d.ts +3 -0
- package/dist/device/cloud/entities/index.js +19 -0
- package/dist/device/cloud/interface.d.ts +101 -0
- package/dist/device/cloud/interface.js +3 -0
- package/dist/device/cloud/interfaces/ICloudConnection.d.ts +5 -0
- package/dist/device/cloud/interfaces/ICloudConnection.js +2 -0
- package/dist/device/cloud/interfaces/ICloudDevice.d.ts +9 -0
- package/dist/device/cloud/interfaces/ICloudDevice.js +2 -0
- package/dist/device/cloud/interfaces/ICloudDeviceService.d.ts +4 -0
- package/dist/device/cloud/interfaces/ICloudDeviceService.js +2 -0
- package/dist/device/cloud/interfaces/IConnectionService.d.ts +7 -0
- package/dist/device/cloud/interfaces/IConnectionService.js +2 -0
- package/dist/device/cloud/interfaces/IDeviceConnectionService.d.ts +7 -0
- package/dist/device/cloud/interfaces/IDeviceConnectionService.js +3 -0
- package/dist/device/cloud/interfaces/IDeviceFactory.d.ts +4 -0
- package/dist/device/cloud/interfaces/IDeviceFactory.js +2 -0
- package/dist/device/cloud/interfaces/IDeviceService.d.ts +8 -0
- package/dist/device/cloud/interfaces/IDeviceService.js +2 -0
- package/dist/device/cloud/interfaces/IDevicesService.d.ts +9 -0
- package/dist/device/cloud/interfaces/IDevicesService.js +2 -0
- package/dist/device/cloud/interfaces/IHubService.d.ts +5 -0
- package/dist/device/cloud/interfaces/IHubService.js +2 -0
- package/dist/device/cloud/interfaces/IRawDataTransformer.d.ts +4 -0
- package/dist/device/cloud/interfaces/IRawDataTransformer.js +2 -0
- package/dist/device/cloud/interfaces/IRawDevice.d.ts +17 -0
- package/dist/device/cloud/interfaces/IRawDevice.js +11 -0
- package/dist/device/cloud/interfaces/index.d.ts +5 -0
- package/dist/device/cloud/interfaces/index.js +21 -0
- package/dist/device/cloud/services/CloudDevice.service.d.ts +5 -0
- package/dist/device/cloud/services/CloudDevice.service.js +9 -0
- package/dist/device/cloud/services/Connection.service.d.ts +8 -0
- package/dist/device/cloud/services/Connection.service.js +6 -0
- package/dist/device/cloud/services/Device.service.d.ts +39 -0
- package/dist/device/cloud/services/Device.service.js +9 -0
- package/dist/device/cloud/services/DeviceCloudService.d.ts +42 -0
- package/dist/device/cloud/services/DeviceCloudService.js +59 -0
- package/dist/device/cloud/services/DeviceHub.service.d.ts +3 -0
- package/dist/device/cloud/services/DeviceHub.service.js +6 -0
- package/dist/device/cloud/services/Hub.service.d.ts +25 -0
- package/dist/device/cloud/services/Hub.service.js +9 -0
- package/dist/device/cloud/services/SmartThingsDeviceService.d.ts +38 -0
- package/dist/device/cloud/services/SmartThingsDeviceService.js +52 -0
- package/dist/device/cloud/services/index.d.ts +2 -0
- package/dist/device/cloud/services/index.js +18 -0
- package/dist/device/cloud/types.d.ts +52 -0
- package/dist/device/cloud/types.js +15 -0
- package/dist/device/index.d.ts +4 -0
- package/dist/device/index.js +20 -0
- package/dist/device/local/entities/AlertBuilder.d.ts +87 -0
- package/dist/device/local/entities/AlertBuilder.example.d.ts +11 -0
- package/dist/device/local/entities/AlertBuilder.example.js +117 -0
- package/dist/device/local/entities/AlertBuilder.js +179 -0
- package/dist/device/local/entities/IssueBuilder.d.ts +109 -0
- package/dist/device/local/entities/IssueBuilder.example.d.ts +16 -0
- package/dist/device/local/entities/IssueBuilder.example.js +196 -0
- package/dist/device/local/entities/IssueBuilder.js +237 -0
- package/dist/device/local/entities/index.d.ts +2 -0
- package/dist/device/local/entities/index.js +7 -0
- package/dist/device/local/events/EventHandler.d.ts +11 -0
- package/dist/device/local/events/EventHandler.js +86 -0
- package/dist/device/local/events/Events.d.ts +54 -0
- package/dist/device/local/events/Events.js +57 -0
- package/dist/device/local/events/index.d.ts +2 -0
- package/dist/device/local/events/index.js +7 -0
- package/dist/device/local/handler/EventHandler.d.ts +7 -0
- package/dist/device/local/handler/EventHandler.js +44 -0
- package/dist/device/local/interface.d.ts +0 -0
- package/dist/device/local/interface.js +1 -0
- package/dist/device/local/interfaces/IConnection.d.ts +26 -0
- package/dist/device/local/interfaces/IConnection.js +14 -0
- package/dist/device/local/interfaces/IDevice.d.ts +68 -0
- package/dist/device/local/interfaces/IDevice.js +10 -0
- package/dist/device/local/interfaces/IDtDevice.d.ts +16 -0
- package/dist/device/local/interfaces/IDtDevice.js +2 -0
- package/dist/device/local/interfaces/IHub.d.ts +46 -0
- package/dist/device/local/interfaces/IHub.js +2 -0
- package/dist/device/local/interfaces/IProperty.d.ts +29 -0
- package/dist/device/local/interfaces/IProperty.js +2 -0
- package/dist/device/local/interfaces/ISchedule.d.ts +25 -0
- package/dist/device/local/interfaces/ISchedule.js +2 -0
- package/dist/device/local/interfaces/index.d.ts +3 -0
- package/dist/device/local/interfaces/index.js +19 -0
- package/dist/device/local/models/Alert.model.d.ts +28 -0
- package/dist/device/local/models/Alert.model.js +222 -0
- package/dist/device/local/models/Issue.model.d.ts +28 -0
- package/dist/device/local/models/Issue.model.js +260 -0
- package/dist/device/local/repository/Alert.repository.d.ts +106 -0
- package/dist/device/local/repository/Alert.repository.js +374 -0
- package/dist/device/local/repository/Connection.repository.d.ts +8 -0
- package/dist/device/local/repository/Connection.repository.js +92 -0
- package/dist/device/local/repository/Device.repository.d.ts +30 -0
- package/dist/device/local/repository/Device.repository.js +325 -0
- package/dist/device/local/repository/Hub.repository.d.ts +13 -0
- package/dist/device/local/repository/Hub.repository.js +139 -0
- package/dist/device/local/repository/Issue.repository.d.ts +113 -0
- package/dist/device/local/repository/Issue.repository.js +401 -0
- package/dist/device/local/repository/Property.repository.d.ts +8 -0
- package/dist/device/local/repository/Property.repository.js +95 -0
- package/dist/device/local/repository/Schedule.repository.d.ts +9 -0
- package/dist/device/local/repository/Schedule.repository.js +109 -0
- package/dist/device/local/services/Alert.service.d.ts +137 -0
- package/dist/device/local/services/Alert.service.js +475 -0
- package/dist/device/local/services/AlertService.example.d.ts +55 -0
- package/dist/device/local/services/AlertService.example.js +148 -0
- package/dist/device/local/services/Connection.service.d.ts +8 -0
- package/dist/device/local/services/Connection.service.js +32 -0
- package/dist/device/local/services/Device.service.d.ts +40 -0
- package/dist/device/local/services/Device.service.js +391 -0
- package/dist/device/local/services/DeviceHub.service.d.ts +11 -0
- package/dist/device/local/services/DeviceHub.service.js +40 -0
- package/dist/device/local/services/Hub.service.d.ts +12 -0
- package/dist/device/local/services/Hub.service.js +107 -0
- package/dist/device/local/services/Issue.service.d.ts +168 -0
- package/dist/device/local/services/Issue.service.js +642 -0
- package/dist/device/local/services/IssueService.example.d.ts +68 -0
- package/dist/device/local/services/IssueService.example.js +177 -0
- package/dist/device/local/services/Property.service.d.ts +8 -0
- package/dist/device/local/services/Property.service.js +36 -0
- package/dist/device/local/services/Schedule.service.d.ts +9 -0
- package/dist/device/local/services/Schedule.service.js +26 -0
- package/dist/device/local/services/index.d.ts +3 -0
- package/dist/device/local/services/index.js +19 -0
- package/dist/entities/accessGroup/AccessGroup.repository.d.ts +1 -2
- package/dist/entities/accessGroup/AccessGroup.repository.js +1 -4
- package/dist/entities/accessGroup/AccessGroup.service.d.ts +1 -2
- package/dist/entities/accessGroup/AccessGroup.service.js +3 -4
- package/dist/entities/device/local/repository/Device.repository.js +1 -1
- package/dist/entities/device/local/repository/DeviceProfile.repository.js +1 -1
- package/dist/entities/device/local/services/Device.service.d.ts +1 -1
- package/dist/entities/device/local/services/Device.service.js +19 -11
- package/dist/entities/guest/Guest.repository.d.ts +1 -1
- package/dist/entities/guest/Guest.repository.js +2 -5
- package/dist/entities/guest/Guest.service.d.ts +1 -1
- package/dist/entities/guest/Guest.service.js +1 -4
- package/dist/entities/schedules/Schedule.repository.d.ts +1 -1
- package/dist/entities/schedules/Schedule.repository.js +2 -5
- package/dist/entities/schedules/Schedule.service.d.ts +1 -1
- package/dist/entities/schedules/Schedule.service.js +1 -4
- package/dist/entities/user/User.repository.js +1 -4
- package/dist/entities/user/User.service.d.ts +1 -1
- package/dist/entities/user/User.service.js +1 -4
- package/dist/entities/zone/Zone.service.js +1 -4
- package/dist/events/InternalEventSubscription.d.ts +2 -0
- package/dist/events/InternalEventSubscription.js +8 -2
- package/dist/pms/IPms.d.ts +6 -0
- package/dist/pms/IPms.js +10 -0
- package/dist/pms/index.d.ts +1 -0
- package/dist/pms/index.js +18 -0
- package/dist/pms/webhookQueue/examples/index.d.ts +2 -0
- package/dist/pms/webhookQueue/examples/index.js +18 -0
- package/dist/pms/webhookQueue/examples/pms-integration.d.ts +65 -0
- package/dist/pms/webhookQueue/examples/pms-integration.js +254 -0
- package/dist/pms/webhookQueue/examples/usage.d.ts +7 -0
- package/dist/pms/webhookQueue/examples/usage.js +175 -0
- package/dist/pms/webhookQueue/index.d.ts +3 -0
- package/dist/pms/webhookQueue/index.js +20 -0
- package/dist/pms/webhookQueue/interfaces/IWebhookQueue.d.ts +33 -0
- package/dist/pms/webhookQueue/interfaces/IWebhookQueue.js +2 -0
- package/dist/pms/webhookQueue/interfaces/IWebhookWorker.d.ts +38 -0
- package/dist/pms/webhookQueue/interfaces/IWebhookWorker.js +2 -0
- package/dist/pms/webhookQueue/interfaces/index.d.ts +1 -0
- package/dist/pms/webhookQueue/interfaces/index.js +17 -0
- package/dist/pms/webhookQueue/services/WebhookQueueFactory.d.ts +38 -0
- package/dist/pms/webhookQueue/services/WebhookQueueFactory.js +131 -0
- package/dist/pms/webhookQueue/services/WebhookQueueIntegration.d.ts +70 -0
- package/dist/pms/webhookQueue/services/WebhookQueueIntegration.js +207 -0
- package/dist/pms/webhookQueue/services/WebhookQueueService.d.ts +45 -0
- package/dist/pms/webhookQueue/services/WebhookQueueService.js +270 -0
- package/dist/pms/webhookQueue/services/WebhookWorker.d.ts +37 -0
- package/dist/pms/webhookQueue/services/WebhookWorker.js +201 -0
- package/dist/pms/webhookQueue/services/index.d.ts +1 -0
- package/dist/pms/webhookQueue/services/index.js +17 -0
- package/dist/pms/webhookQueue/types/index.d.ts +1 -0
- package/dist/pms/webhookQueue/types/index.js +17 -0
- package/dist/pms/webhookQueue/types/webhook.types.d.ts +39 -0
- package/dist/pms/webhookQueue/types/webhook.types.js +2 -0
- package/dist/property/IProperty.d.ts +29 -0
- package/dist/property/IProperty.js +2 -0
- package/dist/property/Property.repository.d.ts +8 -0
- package/dist/property/Property.repository.js +109 -0
- package/dist/property/Property.service.d.ts +8 -0
- package/dist/property/Property.service.js +124 -0
- package/dist/property/index.d.ts +2 -0
- package/dist/property/index.js +18 -0
- package/dist/queue/interfaces/IHttpRequestJob.d.ts +9 -0
- package/dist/queue/interfaces/IHttpRequestJob.js +2 -0
- package/dist/types/alert.types.d.ts +57 -0
- package/dist/types/alert.types.js +22 -0
- package/dist/types/config.types.d.ts +19 -0
- package/dist/types/config.types.js +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/issue.types.d.ts +90 -0
- package/dist/types/issue.types.js +40 -0
- package/dist/utils/http-utils.d.ts +13 -0
- package/dist/utils/http-utils.js +117 -0
- package/dist/utils/http.utils.d.ts +1 -0
- package/dist/utils/http.utils.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { IssueService } from "./Issue.service";
|
|
2
|
+
/**
|
|
3
|
+
* Example usage of the updated IssueService with IssueBuilder integration
|
|
4
|
+
* This file demonstrates various ways to use the IssueService with the new IssueBuilder
|
|
5
|
+
*/
|
|
6
|
+
export declare class IssueServiceExample {
|
|
7
|
+
private readonly issueService;
|
|
8
|
+
constructor(issueService: IssueService);
|
|
9
|
+
/**
|
|
10
|
+
* Example 1: Using the updated createIssue method with IssueBuilder
|
|
11
|
+
*/
|
|
12
|
+
createIssueWithBuilder(): Promise<import("../../../types/issue.types").IssueDocument>;
|
|
13
|
+
/**
|
|
14
|
+
* Example 2: Using convenience methods for specific issue types
|
|
15
|
+
*/
|
|
16
|
+
createSpecificIssues(): Promise<{
|
|
17
|
+
readinessIssue: import("../../../types/issue.types").IssueDocument;
|
|
18
|
+
operationsIssue: import("../../../types/issue.types").IssueDocument;
|
|
19
|
+
securityIssue: import("../../../types/issue.types").IssueDocument;
|
|
20
|
+
energyIssue: import("../../../types/issue.types").IssueDocument;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Example 3: Using device-specific issue methods
|
|
24
|
+
*/
|
|
25
|
+
createDeviceIssues(): Promise<{
|
|
26
|
+
deviceIssue1: import("../../../types/issue.types").IssueDocument;
|
|
27
|
+
deviceIssue2: import("../../../types/issue.types").IssueDocument;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Example 4: Using hub-specific issue methods
|
|
31
|
+
*/
|
|
32
|
+
createHubIssues(): Promise<{
|
|
33
|
+
hubIssue1: import("../../../types/issue.types").IssueDocument;
|
|
34
|
+
hubIssue2: import("../../../types/issue.types").IssueDocument;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Example 5: Using user-specific issue methods
|
|
38
|
+
*/
|
|
39
|
+
createUserIssues(): Promise<{
|
|
40
|
+
userIssue: import("../../../types/issue.types").IssueDocument;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Example 6: Using maintenance and urgent issue methods
|
|
44
|
+
*/
|
|
45
|
+
createMaintenanceAndUrgentIssues(): Promise<{
|
|
46
|
+
maintenanceIssue: import("../../../types/issue.types").IssueDocument;
|
|
47
|
+
urgentIssue: import("../../../types/issue.types").IssueDocument;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Example 7: Using static factory methods with IssueBuilder
|
|
51
|
+
*/
|
|
52
|
+
createIssuesWithStaticMethods(): Promise<{
|
|
53
|
+
issue1: import("../../../types/issue.types").IssueDocument;
|
|
54
|
+
issue2: import("../../../types/issue.types").IssueDocument;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Example 8: Creating multiple issues efficiently
|
|
58
|
+
*/
|
|
59
|
+
createMultipleIssues(): Promise<import("../../../types/issue.types").IssueDocument[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Example 9: Creating issue with due date calculation
|
|
62
|
+
*/
|
|
63
|
+
createIssueWithDueDate(): Promise<import("../../../types/issue.types").IssueDocument>;
|
|
64
|
+
/**
|
|
65
|
+
* Example 10: Backward compatibility - still works with CreateIssueData
|
|
66
|
+
*/
|
|
67
|
+
createIssueWithLegacyData(): Promise<import("../../../types/issue.types").IssueDocument>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IssueServiceExample = void 0;
|
|
4
|
+
const IssueBuilder_1 = require("../entities/IssueBuilder");
|
|
5
|
+
const issue_types_1 = require("../../../types/issue.types");
|
|
6
|
+
/**
|
|
7
|
+
* Example usage of the updated IssueService with IssueBuilder integration
|
|
8
|
+
* This file demonstrates various ways to use the IssueService with the new IssueBuilder
|
|
9
|
+
*/
|
|
10
|
+
class IssueServiceExample {
|
|
11
|
+
constructor(issueService) {
|
|
12
|
+
this.issueService = issueService;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Example 1: Using the updated createIssue method with IssueBuilder
|
|
16
|
+
*/
|
|
17
|
+
async createIssueWithBuilder() {
|
|
18
|
+
const issueBuilder = new IssueBuilder_1.IssueBuilder()
|
|
19
|
+
.setCategory(issue_types_1.IssuesCategory.OPERATIONS)
|
|
20
|
+
.setPropertyId("prop123")
|
|
21
|
+
.setTitle("Device Maintenance Required")
|
|
22
|
+
.setDescription("Device requires scheduled maintenance")
|
|
23
|
+
.setEntityId("device456")
|
|
24
|
+
.setEntityType(issue_types_1.EntityType.DEVICE)
|
|
25
|
+
.setPriority(issue_types_1.IssuePriority.HIGH)
|
|
26
|
+
.setAssignedTo("tech789")
|
|
27
|
+
.setCreatedBy("user123")
|
|
28
|
+
.setDueDate(new Date("2024-01-15"));
|
|
29
|
+
// Pass the IssueBuilder directly to createIssue
|
|
30
|
+
const issue = await this.issueService.createIssue(issueBuilder);
|
|
31
|
+
return issue;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Example 2: Using convenience methods for specific issue types
|
|
35
|
+
*/
|
|
36
|
+
async createSpecificIssues() {
|
|
37
|
+
// Create a readiness issue
|
|
38
|
+
const readinessIssue = await this.issueService.createReadinessIssue("prop123", "System Maintenance Required", "System maintenance is scheduled for tonight", "admin", "system456", issue_types_1.EntityType.PROPERTY, "maintenance-team", new Date("2024-01-20"));
|
|
39
|
+
// Create an operations issue
|
|
40
|
+
const operationsIssue = await this.issueService.createOperationsIssue("prop123", "Device Temperature High", "Device temperature exceeds normal operating range", "monitor", "device789", issue_types_1.EntityType.DEVICE, "tech-support", new Date("2024-01-10"));
|
|
41
|
+
// Create a security issue
|
|
42
|
+
const securityIssue = await this.issueService.createSecurityIssue("prop123", "Unauthorized Access Attempt", "Multiple failed login attempts detected", "security-system", "user123", issue_types_1.EntityType.USER, "security-team", new Date("2024-01-05"));
|
|
43
|
+
// Create an energy issue
|
|
44
|
+
const energyIssue = await this.issueService.createEnergyIssue("prop123", "High Energy Consumption", "Energy usage is 20% above normal levels", "energy-monitor", "zone456", issue_types_1.EntityType.COLLECTION, "energy-manager", new Date("2024-01-25"));
|
|
45
|
+
return { readinessIssue, operationsIssue, securityIssue, energyIssue };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Example 3: Using device-specific issue methods
|
|
49
|
+
*/
|
|
50
|
+
async createDeviceIssues() {
|
|
51
|
+
// Create a device issue with default category and priority
|
|
52
|
+
const deviceIssue1 = await this.issueService.createDeviceIssue("device123", "prop456", "Device Battery Low", "Device battery level is below 20%", "system", undefined, // Use default category
|
|
53
|
+
undefined, // Use default priority
|
|
54
|
+
"maintenance-team", new Date("2024-01-12"));
|
|
55
|
+
// Create a device issue with custom category and priority
|
|
56
|
+
const deviceIssue2 = await this.issueService.createDeviceIssue("device789", "prop456", "Device Firmware Update Available", "New firmware version is available for installation", "firmware-manager", issue_types_1.IssuesCategory.READINESS, issue_types_1.IssuePriority.MEDIUM, "admin", new Date("2024-01-20"));
|
|
57
|
+
return { deviceIssue1, deviceIssue2 };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Example 4: Using hub-specific issue methods
|
|
61
|
+
*/
|
|
62
|
+
async createHubIssues() {
|
|
63
|
+
// Create a hub issue with default settings
|
|
64
|
+
const hubIssue1 = await this.issueService.createHubIssue("hub123", "prop456", "Hub Connection Lost", "Hub has lost connection to the network", "network-monitor", undefined, // Use default category
|
|
65
|
+
undefined, // Use default priority
|
|
66
|
+
"network-admin", new Date("2024-01-05"));
|
|
67
|
+
// Create a hub issue with custom settings
|
|
68
|
+
const hubIssue2 = await this.issueService.createHubIssue("hub789", "prop456", "Hub Maintenance Required", "Hub requires scheduled maintenance", "maintenance-system", issue_types_1.IssuesCategory.READINESS, issue_types_1.IssuePriority.LOW, "technician", new Date("2024-01-15"));
|
|
69
|
+
return { hubIssue1, hubIssue2 };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Example 5: Using user-specific issue methods
|
|
73
|
+
*/
|
|
74
|
+
async createUserIssues() {
|
|
75
|
+
// Create a user issue
|
|
76
|
+
const userIssue = await this.issueService.createUserIssue("user456", "prop303", "User Access Review Required", "User access permissions need review", "access-control", issue_types_1.IssuesCategory.SECURITY, issue_types_1.IssuePriority.MEDIUM, "hr-admin", new Date("2024-01-30"));
|
|
77
|
+
return { userIssue };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Example 6: Using maintenance and urgent issue methods
|
|
81
|
+
*/
|
|
82
|
+
async createMaintenanceAndUrgentIssues() {
|
|
83
|
+
// Create a maintenance issue
|
|
84
|
+
const maintenanceIssue = await this.issueService.createMaintenanceIssue("prop505", "Scheduled Device Maintenance", "Regular maintenance is scheduled for this device", "maintenance-scheduler", "device789", issue_types_1.EntityType.DEVICE, "technician", new Date("2024-01-12"));
|
|
85
|
+
// Create an urgent issue
|
|
86
|
+
const urgentIssue = await this.issueService.createUrgentIssue("prop606", "Critical Hub Failure", "Hub is experiencing critical failures", "monitoring-system", "hub123", issue_types_1.EntityType.HUB, "emergency-tech", new Date("2024-01-03"));
|
|
87
|
+
return { maintenanceIssue, urgentIssue };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Example 7: Using static factory methods with IssueBuilder
|
|
91
|
+
*/
|
|
92
|
+
async createIssuesWithStaticMethods() {
|
|
93
|
+
// Create a device issue using static factory method
|
|
94
|
+
const deviceIssue = IssueBuilder_1.IssueBuilder.createDeviceIssue("device123", "prop456")
|
|
95
|
+
.setCategory(issue_types_1.IssuesCategory.OPERATIONS)
|
|
96
|
+
.setTitle("Device Offline")
|
|
97
|
+
.setDescription("Device has been offline for more than 5 minutes")
|
|
98
|
+
.setPriority(issue_types_1.IssuePriority.HIGH)
|
|
99
|
+
.setAssignedTo("tech-support")
|
|
100
|
+
.setCreatedBy("monitor")
|
|
101
|
+
.setDueDate(new Date("2024-01-10"));
|
|
102
|
+
const issue1 = await this.issueService.createIssue(deviceIssue);
|
|
103
|
+
// Create a hub issue using static factory method
|
|
104
|
+
const hubIssue = IssueBuilder_1.IssueBuilder.createHubIssue("hub789", "prop202")
|
|
105
|
+
.setCategory(issue_types_1.IssuesCategory.SECURITY)
|
|
106
|
+
.setTitle("Hub Security Breach")
|
|
107
|
+
.setDescription("Unauthorized access attempt detected on hub")
|
|
108
|
+
.setPriority(issue_types_1.IssuePriority.CRITICAL)
|
|
109
|
+
.setAssignedTo("security-team")
|
|
110
|
+
.setCreatedBy("security-system")
|
|
111
|
+
.setDueDate(new Date("2024-01-05"));
|
|
112
|
+
const issue2 = await this.issueService.createIssue(hubIssue);
|
|
113
|
+
return { issue1, issue2 };
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Example 8: Creating multiple issues efficiently
|
|
117
|
+
*/
|
|
118
|
+
async createMultipleIssues() {
|
|
119
|
+
const issues = [];
|
|
120
|
+
// Create multiple device issues efficiently
|
|
121
|
+
const deviceIds = ["device1", "device2", "device3"];
|
|
122
|
+
const propertyId = "prop123";
|
|
123
|
+
for (const deviceId of deviceIds) {
|
|
124
|
+
const issueBuilder = IssueBuilder_1.IssueBuilder.createDeviceIssue(deviceId, propertyId)
|
|
125
|
+
.setCategory(issue_types_1.IssuesCategory.OPERATIONS)
|
|
126
|
+
.setTitle(`Device ${deviceId} Status`)
|
|
127
|
+
.setDescription(`Status check for device ${deviceId}`)
|
|
128
|
+
.setPriority(issue_types_1.IssuePriority.MEDIUM)
|
|
129
|
+
.setAssignedTo("batch-processor")
|
|
130
|
+
.setCreatedBy("batch-processor")
|
|
131
|
+
.setDueDate(new Date("2024-01-15"));
|
|
132
|
+
const issue = await this.issueService.createIssue(issueBuilder);
|
|
133
|
+
issues.push(issue);
|
|
134
|
+
}
|
|
135
|
+
return issues;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Example 9: Creating issue with due date calculation
|
|
139
|
+
*/
|
|
140
|
+
async createIssueWithDueDate() {
|
|
141
|
+
const dueDate = new Date();
|
|
142
|
+
dueDate.setDate(dueDate.getDate() + 7); // Due in 7 days
|
|
143
|
+
const issueBuilder = new IssueBuilder_1.IssueBuilder()
|
|
144
|
+
.setCategory(issue_types_1.IssuesCategory.READINESS)
|
|
145
|
+
.setPropertyId("prop808")
|
|
146
|
+
.setTitle("System Update Required")
|
|
147
|
+
.setDescription("System requires critical security update")
|
|
148
|
+
.setEntityType(issue_types_1.EntityType.PROPERTY)
|
|
149
|
+
.setPriority(issue_types_1.IssuePriority.HIGH)
|
|
150
|
+
.setAssignedTo("system-admin")
|
|
151
|
+
.setCreatedBy("update-manager")
|
|
152
|
+
.setDueDate(dueDate);
|
|
153
|
+
const issue = await this.issueService.createIssue(issueBuilder);
|
|
154
|
+
return issue;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Example 10: Backward compatibility - still works with CreateIssueData
|
|
158
|
+
*/
|
|
159
|
+
async createIssueWithLegacyData() {
|
|
160
|
+
const issueData = {
|
|
161
|
+
category: issue_types_1.IssuesCategory.OPERATIONS,
|
|
162
|
+
propertyId: "prop123",
|
|
163
|
+
title: "Legacy Issue",
|
|
164
|
+
description: "This issue was created using the old CreateIssueData format",
|
|
165
|
+
entityId: "device456",
|
|
166
|
+
entityType: issue_types_1.EntityType.DEVICE,
|
|
167
|
+
priority: issue_types_1.IssuePriority.MEDIUM,
|
|
168
|
+
assignedTo: "tech-support",
|
|
169
|
+
createdBy: "legacy-system",
|
|
170
|
+
dueDate: new Date("2024-01-20")
|
|
171
|
+
};
|
|
172
|
+
// This still works with the updated createIssue method
|
|
173
|
+
const issue = await this.issueService.createIssue(issueData);
|
|
174
|
+
return issue;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.IssueServiceExample = IssueServiceExample;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class LocalPropertyService {
|
|
2
|
+
private readonly propertyRepository;
|
|
3
|
+
constructor();
|
|
4
|
+
getPropertyPreferences(propertyId: string): Promise<import("../interfaces").IPropertySettings | null>;
|
|
5
|
+
getProperty(propertyId: string): Promise<import("../interfaces").IProperty | null>;
|
|
6
|
+
getPropertyTimeZone(propertyId: string): Promise<string>;
|
|
7
|
+
getAllProperties(): Promise<any[]>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalPropertyService = void 0;
|
|
4
|
+
const Property_repository_1 = require("../repository/Property.repository");
|
|
5
|
+
class LocalPropertyService {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.propertyRepository = new Property_repository_1.PropertyRepository();
|
|
8
|
+
}
|
|
9
|
+
async getPropertyPreferences(propertyId) {
|
|
10
|
+
if (!propertyId) {
|
|
11
|
+
throw new Error("Property ID is required");
|
|
12
|
+
}
|
|
13
|
+
return await this.propertyRepository.getPropertyPreferences(propertyId);
|
|
14
|
+
}
|
|
15
|
+
async getProperty(propertyId) {
|
|
16
|
+
if (!propertyId) {
|
|
17
|
+
throw new Error("Property ID is required");
|
|
18
|
+
}
|
|
19
|
+
return await this.propertyRepository.getProperty(propertyId);
|
|
20
|
+
}
|
|
21
|
+
async getPropertyTimeZone(propertyId) {
|
|
22
|
+
if (!propertyId) {
|
|
23
|
+
throw new Error("Property ID is required");
|
|
24
|
+
}
|
|
25
|
+
const property = await this.propertyRepository.getProperty(propertyId);
|
|
26
|
+
if (!property) {
|
|
27
|
+
throw new Error("Property not found");
|
|
28
|
+
}
|
|
29
|
+
return property.timezone;
|
|
30
|
+
}
|
|
31
|
+
async getAllProperties() {
|
|
32
|
+
const properties = await this.propertyRepository.getAllProperties();
|
|
33
|
+
return properties;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.LocalPropertyService = LocalPropertyService;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ISchedule } from "../interfaces/ISchedule";
|
|
2
|
+
export declare class LocalScheduleService {
|
|
3
|
+
private readonly scheduleRepository;
|
|
4
|
+
constructor();
|
|
5
|
+
getSchedule(scheduleId: string): Promise<any>;
|
|
6
|
+
setSchedule(scheduleId: string, schedule: ISchedule): Promise<any>;
|
|
7
|
+
getScheduleByZone(zoneId: string): Promise<any>;
|
|
8
|
+
deleteSchedule(scheduleId: string): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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.LocalScheduleService = void 0;
|
|
7
|
+
const typedi_1 = __importDefault(require("typedi"));
|
|
8
|
+
const Schedule_repository_1 = require("../repository/Schedule.repository");
|
|
9
|
+
class LocalScheduleService {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.scheduleRepository = typedi_1.default.get(Schedule_repository_1.ScheduleRepository);
|
|
12
|
+
}
|
|
13
|
+
async getSchedule(scheduleId) {
|
|
14
|
+
return await this.scheduleRepository.getSchedule(scheduleId);
|
|
15
|
+
}
|
|
16
|
+
async setSchedule(scheduleId, schedule) {
|
|
17
|
+
return await this.scheduleRepository.setSchedule(scheduleId, schedule);
|
|
18
|
+
}
|
|
19
|
+
async getScheduleByZone(zoneId) {
|
|
20
|
+
return await this.scheduleRepository.getScheduleByZone(zoneId);
|
|
21
|
+
}
|
|
22
|
+
async deleteSchedule(scheduleId) {
|
|
23
|
+
return await this.scheduleRepository.deleteSchedule(scheduleId);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.LocalScheduleService = LocalScheduleService;
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./Device.service"), exports);
|
|
18
|
+
__exportStar(require("./Hub.service"), exports);
|
|
19
|
+
__exportStar(require("./Schedule.service"), exports);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IAccessGroup } from "./IAccessGroup";
|
|
2
1
|
export declare class AccessGroupRepository {
|
|
3
2
|
private readonly postgres;
|
|
4
3
|
constructor();
|
|
5
|
-
getAccessGroup(accessGroupId: string): Promise<
|
|
4
|
+
getAccessGroup(accessGroupId: string): Promise<any>;
|
|
6
5
|
}
|
|
@@ -56,10 +56,7 @@ let AccessGroupRepository = (() => {
|
|
|
56
56
|
WHERE "id" = $1
|
|
57
57
|
`;
|
|
58
58
|
const result = await this.postgres.query(query, [accessGroupId]);
|
|
59
|
-
|
|
60
|
-
return result.rows[0];
|
|
61
|
-
}
|
|
62
|
-
return null;
|
|
59
|
+
return result.rows[0];
|
|
63
60
|
}
|
|
64
61
|
};
|
|
65
62
|
__setFunctionName(_classThis, "AccessGroupRepository");
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IAccessGroup } from "./IAccessGroup";
|
|
2
1
|
export declare class AccessGroupService {
|
|
3
2
|
private readonly accessGroupRepository;
|
|
4
3
|
constructor();
|
|
5
|
-
getAccessGroup(accessGroupId: string): Promise<
|
|
4
|
+
getAccessGroup(accessGroupId: string): Promise<any>;
|
|
6
5
|
}
|
|
@@ -87,10 +87,7 @@ let AccessGroupService = (() => {
|
|
|
87
87
|
if (!accessGroupId) {
|
|
88
88
|
throw new Error("Access Group ID is required");
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
if (!accessGroup)
|
|
92
|
-
return null;
|
|
93
|
-
return accessGroup;
|
|
90
|
+
return await this.accessGroupRepository.getAccessGroup(accessGroupId);
|
|
94
91
|
}
|
|
95
92
|
};
|
|
96
93
|
__setFunctionName(_classThis, "AccessGroupService");
|
|
@@ -104,3 +101,5 @@ let AccessGroupService = (() => {
|
|
|
104
101
|
return AccessGroupService = _classThis;
|
|
105
102
|
})();
|
|
106
103
|
exports.AccessGroupService = AccessGroupService;
|
|
104
|
+
// Accessgroup.getAccessGroup(accessGroupId)
|
|
105
|
+
// GetAccessGroup()
|
|
@@ -194,7 +194,7 @@ let DeviceRepository = (() => {
|
|
|
194
194
|
}
|
|
195
195
|
async setBatteryLevel(deviceId, newBatteryLevel) {
|
|
196
196
|
try {
|
|
197
|
-
const response = await this.axiosInstance.put(`/devices/${deviceId}/battery-level`, { newBatteryLevel });
|
|
197
|
+
const response = await this.axiosInstance.put(`/devices/${deviceId}/battery-level`, { batteryLevel: newBatteryLevel });
|
|
198
198
|
return response.data;
|
|
199
199
|
}
|
|
200
200
|
catch (error) {
|
|
@@ -49,7 +49,7 @@ let DeviceProfileRepository = (() => {
|
|
|
49
49
|
let _classThis;
|
|
50
50
|
var DeviceProfileRepository = _classThis = class {
|
|
51
51
|
constructor() {
|
|
52
|
-
this.axiosInstance = (0, utils_1.
|
|
52
|
+
this.axiosInstance = (0, utils_1.getDeviceProfileServiceAxiosInstance)();
|
|
53
53
|
}
|
|
54
54
|
async getDeviceBaseLine(deviceId) {
|
|
55
55
|
try {
|
|
@@ -4,9 +4,9 @@ import { IAuditProperties } from "../../../../audit/IAuditProperties";
|
|
|
4
4
|
export declare class LocalDeviceService {
|
|
5
5
|
private readonly eventHandler;
|
|
6
6
|
private readonly deviceRepository;
|
|
7
|
-
private readonly alertService;
|
|
8
7
|
private readonly issueService;
|
|
9
8
|
private readonly localPropertyService;
|
|
9
|
+
private readonly deviceProfileRepository;
|
|
10
10
|
constructor();
|
|
11
11
|
createDevice(body: IDevice): Promise<IDevice>;
|
|
12
12
|
getDevice(deviceId: string, withHubDetails?: boolean): Promise<IDevice>;
|
|
@@ -75,7 +75,6 @@ exports.LocalDeviceService = void 0;
|
|
|
75
75
|
const EventHandler_1 = require("../../../../events/EventHandler");
|
|
76
76
|
const lodash_1 = require("lodash");
|
|
77
77
|
const Device_repository_1 = require("../repository/Device.repository");
|
|
78
|
-
const Alert_service_1 = require("../../../../alerts/Alert.service");
|
|
79
78
|
const Issue_service_1 = require("../../../../issues/Issue.service");
|
|
80
79
|
const Service_1 = require("../../../../constants/Service");
|
|
81
80
|
const typedi_1 = __importStar(require("typedi"));
|
|
@@ -84,6 +83,7 @@ const constants_1 = require("../../../../constants");
|
|
|
84
83
|
const audit_1 = require("../../../../audit");
|
|
85
84
|
const issue_types_1 = require("../../../../issues/issue.types");
|
|
86
85
|
const property_1 = require("../../../property");
|
|
86
|
+
const DeviceProfile_repository_1 = require("../repository/DeviceProfile.repository");
|
|
87
87
|
let LocalDeviceService = (() => {
|
|
88
88
|
let _classDecorators = [(0, typedi_1.Service)()];
|
|
89
89
|
let _classDescriptor;
|
|
@@ -94,9 +94,9 @@ let LocalDeviceService = (() => {
|
|
|
94
94
|
// Use dependency injection instead of creating new instances
|
|
95
95
|
this.eventHandler = typedi_1.default.get(EventHandler_1.EventHandler);
|
|
96
96
|
this.deviceRepository = typedi_1.default.get(Device_repository_1.DeviceRepository);
|
|
97
|
-
this.alertService = typedi_1.default.get(Alert_service_1.AlertService);
|
|
98
97
|
this.issueService = typedi_1.default.get(Issue_service_1.IssueService);
|
|
99
98
|
this.localPropertyService = typedi_1.default.get(property_1.LocalPropertyService);
|
|
99
|
+
this.deviceProfileRepository = typedi_1.default.get(DeviceProfile_repository_1.DeviceProfileRepository);
|
|
100
100
|
}
|
|
101
101
|
async createDevice(body) {
|
|
102
102
|
const device = await this.deviceRepository.createDevice(body);
|
|
@@ -136,11 +136,20 @@ let LocalDeviceService = (() => {
|
|
|
136
136
|
else {
|
|
137
137
|
await this.handleOfflineStatus(device, device.status, body.status, auditBody?.source || Service_1.Source.SYSTEM, auditBody, body.status.error?.message);
|
|
138
138
|
}
|
|
139
|
-
// delete body
|
|
139
|
+
// delete the status from the body, so it doesn't get updated in the database again!
|
|
140
|
+
delete body.status;
|
|
140
141
|
}
|
|
141
|
-
if (body.state?.batteryPercentage?.value
|
|
142
|
+
if (body.state?.batteryPercentage?.value ||
|
|
143
|
+
body.state?.batteryPercentage?.value === 0) {
|
|
142
144
|
await this.setBatteryLevel(deviceId, body.state?.batteryPercentage?.value, auditBody?.source || Service_1.Source.SYSTEM, auditBody);
|
|
143
|
-
// delete body
|
|
145
|
+
// delete the battery percentage and battery state from the body, so it doesn't get updated in the database again!
|
|
146
|
+
delete body.state?.batteryPercentage;
|
|
147
|
+
delete body.state?.batteryState;
|
|
148
|
+
}
|
|
149
|
+
if (body.state?.lockState?.value) {
|
|
150
|
+
await this.setState(deviceId, { lockState: body.state.lockState }, auditBody);
|
|
151
|
+
// delete the lock state from the body, so it doesn't get updated in the database again!
|
|
152
|
+
delete body.state?.lockState;
|
|
144
153
|
}
|
|
145
154
|
await this.deviceRepository.updateDevice(deviceId, body);
|
|
146
155
|
return await this.eventHandler.onDeviceUpdate(deviceId, body, auditBody);
|
|
@@ -206,7 +215,7 @@ let LocalDeviceService = (() => {
|
|
|
206
215
|
}
|
|
207
216
|
// If old state and new state are different
|
|
208
217
|
const oldState = (await this.getState(deviceId))?.state ?? {};
|
|
209
|
-
const changedKeys = Object.keys(newState).filter((key) => !(0, lodash_1.isEqual)(oldState[key], newState[key]));
|
|
218
|
+
const changedKeys = Object.keys(newState).filter((key) => !(0, lodash_1.isEqual)(oldState[key].value.toLowerCase(), newState[key].value.toLowerCase()));
|
|
210
219
|
if (changedKeys.length > 0) {
|
|
211
220
|
await this.deviceRepository.setState(deviceId, newState);
|
|
212
221
|
return await this.eventHandler.onStateChange(deviceId, newState, auditProperties, eventType);
|
|
@@ -342,10 +351,9 @@ let LocalDeviceService = (() => {
|
|
|
342
351
|
}
|
|
343
352
|
}
|
|
344
353
|
async getDeviceBaseline(deviceId) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
return 3600000; // 1 hour in milliseconds
|
|
354
|
+
const response = await this.deviceProfileRepository.getDeviceBaseLine(deviceId);
|
|
355
|
+
const baselineInMilliseconds = response?.baseline && response?.baseline * 60 * 1000;
|
|
356
|
+
return baselineInMilliseconds ?? 3600000; // 1 hour in milliseconds
|
|
349
357
|
}
|
|
350
358
|
async getBatteryLevel(deviceId) {
|
|
351
359
|
if (!deviceId) {
|
|
@@ -379,7 +387,7 @@ let LocalDeviceService = (() => {
|
|
|
379
387
|
lastUpdated: new Date().toISOString(),
|
|
380
388
|
},
|
|
381
389
|
};
|
|
382
|
-
await this.
|
|
390
|
+
await this.setState(deviceId, batteryState, auditBody);
|
|
383
391
|
await this.eventHandler.onBatteryReplaced(deviceId, batteryLevel, auditBody);
|
|
384
392
|
// Cancel any existing battery issue
|
|
385
393
|
await this.issueService.performIssueAction({
|
|
@@ -52,11 +52,8 @@ let GuestRepository = (() => {
|
|
|
52
52
|
}
|
|
53
53
|
async getGuest(guestId) {
|
|
54
54
|
try {
|
|
55
|
-
const guest = await this.pmsPostgres.query(`SELECT * FROM
|
|
56
|
-
|
|
57
|
-
return guest.rows[0];
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
55
|
+
const guest = await this.pmsPostgres.query(`SELECT * FROM dt_guests WHERE "id" = $1`, [guestId]);
|
|
56
|
+
return guest.rows[0];
|
|
60
57
|
}
|
|
61
58
|
catch (error) {
|
|
62
59
|
console.error("Error in getGuest:", error);
|
|
@@ -88,10 +88,7 @@ let GuestService = (() => {
|
|
|
88
88
|
if (!guestId) {
|
|
89
89
|
throw new Error("Guest ID is required");
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
if (!guest)
|
|
93
|
-
return null;
|
|
94
|
-
return guest;
|
|
91
|
+
return await this.guestRepository.getGuest(guestId);
|
|
95
92
|
}
|
|
96
93
|
};
|
|
97
94
|
__setFunctionName(_classThis, "GuestService");
|
|
@@ -52,11 +52,8 @@ let ScheduleRepository = (() => {
|
|
|
52
52
|
}
|
|
53
53
|
async getSchedule(scheduleId) {
|
|
54
54
|
try {
|
|
55
|
-
const schedule = await this.pmsPostgres.query(`SELECT * FROM
|
|
56
|
-
|
|
57
|
-
return schedule.rows[0];
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
55
|
+
const schedule = await this.pmsPostgres.query(`SELECT * FROM dt_schedules WHERE "id" = $1`, [scheduleId]);
|
|
56
|
+
return schedule.rows[0];
|
|
60
57
|
}
|
|
61
58
|
catch (error) {
|
|
62
59
|
console.error("Error in getSchedule:", error);
|
|
@@ -88,10 +88,7 @@ let ScheduleService = (() => {
|
|
|
88
88
|
if (!scheduleId) {
|
|
89
89
|
throw new Error("Schedule ID is required");
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
if (!schedule)
|
|
93
|
-
return null;
|
|
94
|
-
return schedule;
|
|
91
|
+
return await this.scheduleRepository.getSchedule(scheduleId);
|
|
95
92
|
}
|
|
96
93
|
};
|
|
97
94
|
__setFunctionName(_classThis, "ScheduleService");
|
|
@@ -52,10 +52,7 @@ let UserRepository = (() => {
|
|
|
52
52
|
}
|
|
53
53
|
async getUser(userId) {
|
|
54
54
|
const user = await this.postgres.query(`SELECT * FROM dt_users WHERE "id" = $1`, [userId]);
|
|
55
|
-
|
|
56
|
-
return user.rows[0];
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
55
|
+
return user.rows[0];
|
|
59
56
|
}
|
|
60
57
|
};
|
|
61
58
|
__setFunctionName(_classThis, "UserRepository");
|
|
@@ -87,10 +87,7 @@ let UserService = (() => {
|
|
|
87
87
|
if (!userId) {
|
|
88
88
|
throw new Error("User ID is required");
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
if (!user)
|
|
92
|
-
return null;
|
|
93
|
-
return user;
|
|
90
|
+
return await this.userRepository.getUser(userId);
|
|
94
91
|
}
|
|
95
92
|
};
|
|
96
93
|
__setFunctionName(_classThis, "UserService");
|