dt-common-device 4.0.7 → 5.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/alerts/Alert.service.d.ts +1 -1
- package/dist/audit/AuditUtils.d.ts +26 -2
- package/dist/audit/AuditUtils.js +255 -32
- package/dist/audit/IAuditProperties.d.ts +32 -0
- package/dist/audit/IAuditProperties.js +13 -0
- package/dist/audit/PushAudit.d.ts +5 -0
- package/dist/audit/PushAudit.js +16 -0
- package/dist/audit/index.d.ts +2 -0
- package/dist/audit/index.js +18 -0
- package/dist/config/config.d.ts +10 -3
- package/dist/config/config.js +120 -47
- package/dist/config/config.types.d.ts +1 -8
- package/dist/config/constants.d.ts +49 -0
- package/dist/config/constants.js +64 -0
- package/dist/db/db.d.ts +2 -0
- package/dist/db/db.js +23 -1
- package/dist/entities/accessGroup/AccessGroup.repository.d.ts +5 -0
- package/dist/entities/accessGroup/AccessGroup.repository.js +72 -0
- package/dist/entities/accessGroup/AccessGroup.service.d.ts +5 -0
- package/dist/{device/local/repository/Connection.repository.js → entities/accessGroup/AccessGroup.service.js} +50 -37
- package/dist/entities/accessGroup/IAccessGroup.d.ts +14 -0
- package/dist/entities/accessGroup/index.d.ts +2 -0
- package/dist/entities/accessGroup/index.js +18 -0
- package/dist/{admin → entities/admin}/Admin.repository.js +4 -4
- package/dist/{connection → entities/connection}/Connection.repository.js +1 -1
- package/dist/{device → entities/device}/local/repository/Device.repository.d.ts +1 -0
- package/dist/{device → entities/device}/local/repository/Device.repository.js +20 -3
- package/dist/{device → entities/device}/local/repository/Hub.repository.js +3 -3
- package/dist/{device → entities/device}/local/repository/Schedule.repository.js +2 -2
- package/dist/{device → entities/device}/local/services/Device.service.d.ts +10 -9
- package/dist/{device → entities/device}/local/services/Device.service.js +10 -4
- package/dist/entities/guest/Guest.repository.d.ts +6 -0
- package/dist/entities/guest/Guest.repository.js +74 -0
- package/dist/entities/guest/Guest.service.d.ts +6 -0
- package/dist/entities/guest/Guest.service.js +104 -0
- package/dist/entities/guest/IGuest.d.ts +12 -0
- package/dist/entities/guest/index.d.ts +2 -0
- package/dist/entities/guest/index.js +18 -0
- package/dist/{property → entities/property}/Property.repository.js +1 -1
- package/dist/entities/schedules/ISchedule.d.ts +14 -0
- package/dist/entities/schedules/Schedule.repository.d.ts +6 -0
- package/dist/entities/schedules/Schedule.repository.js +74 -0
- package/dist/entities/schedules/Schedule.service.d.ts +6 -0
- package/dist/entities/schedules/Schedule.service.js +104 -0
- package/dist/entities/schedules/index.d.ts +2 -0
- package/dist/entities/schedules/index.js +18 -0
- package/dist/{user → entities/user}/User.repository.js +2 -2
- package/dist/{user → entities/user}/User.service.js +3 -0
- package/dist/entities/zone/IZone.d.ts +10 -0
- package/dist/entities/zone/Zone.repository.d.ts +6 -0
- package/dist/{device/local/repository/Property.repository.js → entities/zone/Zone.repository.js} +14 -32
- package/dist/entities/zone/Zone.service.d.ts +6 -0
- package/dist/entities/zone/Zone.service.js +104 -0
- package/dist/entities/zone/index.d.ts +2 -0
- package/dist/entities/zone/index.js +18 -0
- package/dist/events/BaseEventHandler.d.ts +3 -3
- package/dist/events/BaseEventHandler.js +1 -1
- package/dist/events/DeviceEventHandler.d.ts +1 -1
- package/dist/events/DeviceEventHandler.js +4 -3
- package/dist/events/EventHandler.d.ts +10 -9
- package/dist/events/EventHandler.js +50 -9
- package/dist/events/InternalEventSubscription.js +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +10 -8
- package/dist/issues/Issue.service.d.ts +1 -1
- package/dist/microservice/MicroServiceFactory.d.ts +1 -1
- package/dist/microservice/MicroServiceFactory.js +1 -1
- package/dist/utils/http.utils.d.ts +1 -2
- package/dist/utils/http.utils.js +5 -27
- package/package.json +1 -1
- package/dist/audit/AuditProperties.d.ts +0 -16
- package/dist/device/cloud/entities/CloudConnection.d.ts +0 -6
- package/dist/device/cloud/entities/CloudConnection.js +0 -6
- package/dist/device/cloud/interfaces/ICloudConnection.d.ts +0 -5
- package/dist/device/cloud/interfaces/IConnectionService.d.ts +0 -7
- package/dist/device/cloud/interfaces/IDeviceService.d.ts +0 -8
- package/dist/device/cloud/interfaces/IHubService.d.ts +0 -5
- package/dist/device/cloud/interfaces/IHubService.js +0 -2
- package/dist/device/cloud/services/CloudDevice.service.d.ts +0 -5
- package/dist/device/cloud/services/CloudDevice.service.js +0 -9
- package/dist/device/cloud/services/Connection.service.d.ts +0 -8
- package/dist/device/cloud/services/Connection.service.js +0 -6
- package/dist/device/cloud/services/index.d.ts +0 -2
- package/dist/device/cloud/services/index.js +0 -18
- package/dist/device/cloud/types.d.ts +0 -52
- package/dist/device/cloud/types.js +0 -15
- package/dist/device/local/entities/AlertBuilder.d.ts +0 -87
- package/dist/device/local/entities/AlertBuilder.example.d.ts +0 -11
- package/dist/device/local/entities/AlertBuilder.example.js +0 -117
- package/dist/device/local/entities/AlertBuilder.js +0 -179
- package/dist/device/local/entities/IssueBuilder.d.ts +0 -109
- package/dist/device/local/entities/IssueBuilder.example.d.ts +0 -16
- package/dist/device/local/entities/IssueBuilder.example.js +0 -196
- package/dist/device/local/entities/IssueBuilder.js +0 -237
- package/dist/device/local/entities/index.d.ts +0 -2
- package/dist/device/local/entities/index.js +0 -7
- package/dist/device/local/events/EventHandler.d.ts +0 -11
- package/dist/device/local/events/EventHandler.js +0 -86
- package/dist/device/local/events/Events.d.ts +0 -75
- package/dist/device/local/events/Events.js +0 -78
- package/dist/device/local/events/index.d.ts +0 -2
- package/dist/device/local/events/index.js +0 -7
- package/dist/device/local/handler/EventHandler.d.ts +0 -7
- package/dist/device/local/handler/EventHandler.js +0 -44
- package/dist/device/local/interfaces/IConnection.d.ts +0 -26
- package/dist/device/local/interfaces/IConnection.js +0 -14
- package/dist/device/local/interfaces/IHub.d.ts +0 -46
- package/dist/device/local/interfaces/IHub.js +0 -2
- package/dist/device/local/models/Alert.model.d.ts +0 -28
- package/dist/device/local/models/Alert.model.js +0 -222
- package/dist/device/local/models/Issue.model.d.ts +0 -28
- package/dist/device/local/models/Issue.model.js +0 -260
- package/dist/device/local/repository/Alert.repository.d.ts +0 -106
- package/dist/device/local/repository/Alert.repository.js +0 -374
- package/dist/device/local/repository/Connection.repository.d.ts +0 -8
- package/dist/device/local/repository/Issue.repository.d.ts +0 -113
- package/dist/device/local/repository/Issue.repository.js +0 -401
- package/dist/device/local/repository/Property.repository.d.ts +0 -8
- package/dist/device/local/services/Alert.service.d.ts +0 -137
- package/dist/device/local/services/Alert.service.js +0 -475
- package/dist/device/local/services/AlertService.example.d.ts +0 -55
- package/dist/device/local/services/AlertService.example.js +0 -148
- package/dist/device/local/services/Connection.service.d.ts +0 -8
- package/dist/device/local/services/Connection.service.js +0 -32
- package/dist/device/local/services/Issue.service.d.ts +0 -168
- package/dist/device/local/services/Issue.service.js +0 -642
- package/dist/device/local/services/IssueService.example.d.ts +0 -68
- package/dist/device/local/services/IssueService.example.js +0 -177
- package/dist/device/local/services/Property.service.d.ts +0 -8
- package/dist/device/local/services/Property.service.js +0 -36
- package/dist/property/IProperty.d.ts +0 -29
- package/dist/property/IProperty.js +0 -2
- package/dist/queue/interfaces/IHttpRequestJob.d.ts +0 -9
- package/dist/queue/interfaces/IHttpRequestJob.js +0 -2
- package/dist/types/alert.types.d.ts +0 -57
- package/dist/types/alert.types.js +0 -22
- package/dist/types/config.types.d.ts +0 -19
- package/dist/types/config.types.js +0 -2
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.js +0 -19
- package/dist/types/issue.types.d.ts +0 -90
- package/dist/types/issue.types.js +0 -40
- package/dist/utils/http-utils.d.ts +0 -13
- package/dist/utils/http-utils.js +0 -117
- /package/dist/{audit/AuditProperties.js → entities/accessGroup/IAccessGroup.js} +0 -0
- /package/dist/{admin → entities/admin}/Admin.repository.d.ts +0 -0
- /package/dist/{admin → entities/admin}/Admin.service.d.ts +0 -0
- /package/dist/{admin → entities/admin}/Admin.service.js +0 -0
- /package/dist/{admin → entities/admin}/index.d.ts +0 -0
- /package/dist/{admin → entities/admin}/index.js +0 -0
- /package/dist/{connection → entities/connection}/Connection.repository.d.ts +0 -0
- /package/dist/{connection → entities/connection}/Connection.service.d.ts +0 -0
- /package/dist/{connection → entities/connection}/Connection.service.js +0 -0
- /package/dist/{connection → entities/connection}/IConnection.d.ts +0 -0
- /package/dist/{connection → entities/connection}/IConnection.js +0 -0
- /package/dist/{connection → entities/connection}/index.d.ts +0 -0
- /package/dist/{connection → entities/connection}/index.js +0 -0
- /package/dist/{device → entities/device}/cloud/entities/CloudDevice.d.ts +0 -0
- /package/dist/{device → entities/device}/cloud/entities/CloudDevice.js +0 -0
- /package/dist/{device → entities/device}/cloud/entities/CloudDeviceService.d.ts +0 -0
- /package/dist/{device → entities/device}/cloud/entities/CloudDeviceService.js +0 -0
- /package/dist/{device → entities/device}/cloud/entities/DeviceFactory.d.ts +0 -0
- /package/dist/{device → entities/device}/cloud/entities/DeviceFactory.js +0 -0
- /package/dist/{device → entities/device}/cloud/entities/index.d.ts +0 -0
- /package/dist/{device → entities/device}/cloud/entities/index.js +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/ICloudDevice.d.ts +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/ICloudDevice.js +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/ICloudDeviceService.d.ts +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/ICloudDeviceService.js +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/IDeviceFactory.d.ts +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/IDeviceFactory.js +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/IRawDataTransformer.d.ts +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/IRawDataTransformer.js +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/IRawDevice.d.ts +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/IRawDevice.js +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/index.d.ts +0 -0
- /package/dist/{device → entities/device}/cloud/interfaces/index.js +0 -0
- /package/dist/{device → entities/device}/local/interfaces/IDevice.d.ts +0 -0
- /package/dist/{device → entities/device}/local/interfaces/IDevice.js +0 -0
- /package/dist/{device → entities/device}/local/interfaces/IDtDevice.d.ts +0 -0
- /package/dist/{device → entities/device}/local/interfaces/IDtDevice.js +0 -0
- /package/dist/{device → entities/device}/local/interfaces/ISchedule.d.ts +0 -0
- /package/dist/{device → entities/device}/local/interfaces/ISchedule.js +0 -0
- /package/dist/{device → entities/device}/local/interfaces/index.d.ts +0 -0
- /package/dist/{device → entities/device}/local/interfaces/index.js +0 -0
- /package/dist/{device → entities/device}/local/repository/Hub.repository.d.ts +0 -0
- /package/dist/{device → entities/device}/local/repository/Schedule.repository.d.ts +0 -0
- /package/dist/{device → entities/device}/local/services/Hub.service.d.ts +0 -0
- /package/dist/{device → entities/device}/local/services/Hub.service.js +0 -0
- /package/dist/{device → entities/device}/local/services/Schedule.service.d.ts +0 -0
- /package/dist/{device → entities/device}/local/services/Schedule.service.js +0 -0
- /package/dist/{device → entities/device}/local/services/index.d.ts +0 -0
- /package/dist/{device → entities/device}/local/services/index.js +0 -0
- /package/dist/{device/cloud/interfaces/ICloudConnection.js → entities/guest/IGuest.js} +0 -0
- /package/dist/{pms → entities/pms}/IPms.d.ts +0 -0
- /package/dist/{pms → entities/pms}/IPms.js +0 -0
- /package/dist/{pms → entities/pms}/index.d.ts +0 -0
- /package/dist/{pms → entities/pms}/index.js +0 -0
- /package/dist/{device/local/interfaces → entities/property}/IProperty.d.ts +0 -0
- /package/dist/{device/local/interfaces → entities/property}/IProperty.js +0 -0
- /package/dist/{property → entities/property}/Property.repository.d.ts +0 -0
- /package/dist/{property → entities/property}/Property.service.d.ts +0 -0
- /package/dist/{property → entities/property}/Property.service.js +0 -0
- /package/dist/{property → entities/property}/index.d.ts +0 -0
- /package/dist/{property → entities/property}/index.js +0 -0
- /package/dist/{device/cloud/interfaces/IConnectionService.js → entities/schedules/ISchedule.js} +0 -0
- /package/dist/{user → entities/user}/IUser.d.ts +0 -0
- /package/dist/{user → entities/user}/IUser.js +0 -0
- /package/dist/{user → entities/user}/User.repository.d.ts +0 -0
- /package/dist/{user → entities/user}/User.service.d.ts +0 -0
- /package/dist/{device/cloud/interfaces/IDeviceService.js → entities/zone/IZone.js} +0 -0
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IssueBuilder = void 0;
|
|
4
|
-
const issue_types_1 = require("../../../types/issue.types");
|
|
5
|
-
/**
|
|
6
|
-
* IssueBuilder - A builder pattern implementation for constructing CreateIssueData objects
|
|
7
|
-
*
|
|
8
|
-
* This builder provides a fluent interface for creating issue 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 issueData = new IssueBuilder()
|
|
14
|
-
* .setCategory(IssuesCategory.OPERATIONS)
|
|
15
|
-
* .setPropertyId("prop123")
|
|
16
|
-
* .setTitle("Device Maintenance Required")
|
|
17
|
-
* .setDescription("Device requires scheduled maintenance")
|
|
18
|
-
* .setEntityId("device456")
|
|
19
|
-
* .setEntityType(EntityType.DEVICE)
|
|
20
|
-
* .setPriority(IssuePriority.HIGH)
|
|
21
|
-
* .setAssignedTo("tech789")
|
|
22
|
-
* .setCreatedBy("user123")
|
|
23
|
-
* .setDueDate(new Date("2024-01-15"))
|
|
24
|
-
* .build();
|
|
25
|
-
*/
|
|
26
|
-
class IssueBuilder {
|
|
27
|
-
constructor() {
|
|
28
|
-
this.data = {};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Sets the issue category
|
|
32
|
-
*/
|
|
33
|
-
setCategory(category) {
|
|
34
|
-
this.data.category = category;
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Sets the property ID
|
|
39
|
-
*/
|
|
40
|
-
setPropertyId(propertyId) {
|
|
41
|
-
if (!propertyId || propertyId.trim() === "") {
|
|
42
|
-
throw new Error("Property ID is required and cannot be empty");
|
|
43
|
-
}
|
|
44
|
-
this.data.propertyId = propertyId;
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Sets the issue title
|
|
49
|
-
*/
|
|
50
|
-
setTitle(title) {
|
|
51
|
-
if (!title || title.trim() === "") {
|
|
52
|
-
throw new Error("Title is required and cannot be empty");
|
|
53
|
-
}
|
|
54
|
-
this.data.title = title.trim();
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Sets the issue description
|
|
59
|
-
*/
|
|
60
|
-
setDescription(description) {
|
|
61
|
-
if (!description || description.trim() === "") {
|
|
62
|
-
throw new Error("Description is required and cannot be empty");
|
|
63
|
-
}
|
|
64
|
-
this.data.description = description.trim();
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Sets the entity ID (optional)
|
|
69
|
-
*/
|
|
70
|
-
setEntityId(entityId) {
|
|
71
|
-
if (entityId !== undefined) {
|
|
72
|
-
this.data.entityId = entityId.trim() || undefined;
|
|
73
|
-
}
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Sets the entity type
|
|
78
|
-
*/
|
|
79
|
-
setEntityType(entityType) {
|
|
80
|
-
this.data.entityType = entityType;
|
|
81
|
-
return this;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Sets the issue priority (optional, defaults to MEDIUM)
|
|
85
|
-
*/
|
|
86
|
-
setPriority(priority) {
|
|
87
|
-
if (priority !== undefined) {
|
|
88
|
-
this.data.priority = priority;
|
|
89
|
-
}
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Sets the user assigned to the issue (optional)
|
|
94
|
-
*/
|
|
95
|
-
setAssignedTo(assignedTo) {
|
|
96
|
-
if (assignedTo !== undefined) {
|
|
97
|
-
this.data.assignedTo = assignedTo.trim() || undefined;
|
|
98
|
-
}
|
|
99
|
-
return this;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Sets the user who created the issue (required)
|
|
103
|
-
*/
|
|
104
|
-
setCreatedBy(createdBy) {
|
|
105
|
-
if (!createdBy || createdBy.trim() === "") {
|
|
106
|
-
throw new Error("Created by user is required and cannot be empty");
|
|
107
|
-
}
|
|
108
|
-
this.data.createdBy = createdBy.trim();
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Sets the due date (optional)
|
|
113
|
-
*/
|
|
114
|
-
setDueDate(dueDate) {
|
|
115
|
-
if (dueDate !== undefined) {
|
|
116
|
-
this.data.dueDate = dueDate;
|
|
117
|
-
}
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Validates that all required fields are present
|
|
122
|
-
*/
|
|
123
|
-
validate() {
|
|
124
|
-
const requiredFields = ["category", "propertyId", "title", "description", "entityType", "createdBy"];
|
|
125
|
-
const missingFields = requiredFields.filter(field => !this.data[field]);
|
|
126
|
-
if (missingFields.length > 0) {
|
|
127
|
-
throw new Error(`Missing required fields: ${missingFields.join(", ")}`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Builds and returns the CreateIssueData object
|
|
132
|
-
* @throws Error if required fields are missing
|
|
133
|
-
*/
|
|
134
|
-
build() {
|
|
135
|
-
this.validate();
|
|
136
|
-
// Set default priority if not provided
|
|
137
|
-
if (!this.data.priority) {
|
|
138
|
-
this.data.priority = issue_types_1.IssuePriority.MEDIUM;
|
|
139
|
-
}
|
|
140
|
-
return this.data;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Resets the builder to its initial state
|
|
144
|
-
*/
|
|
145
|
-
reset() {
|
|
146
|
-
this.data = {};
|
|
147
|
-
return this;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Creates a new builder instance with predefined values for common issue types
|
|
151
|
-
*/
|
|
152
|
-
static createReadinessIssue() {
|
|
153
|
-
return new IssueBuilder()
|
|
154
|
-
.setCategory(issue_types_1.IssuesCategory.READINESS)
|
|
155
|
-
.setPriority(issue_types_1.IssuePriority.MEDIUM);
|
|
156
|
-
}
|
|
157
|
-
static createOperationsIssue() {
|
|
158
|
-
return new IssueBuilder()
|
|
159
|
-
.setCategory(issue_types_1.IssuesCategory.OPERATIONS)
|
|
160
|
-
.setPriority(issue_types_1.IssuePriority.HIGH);
|
|
161
|
-
}
|
|
162
|
-
static createSecurityIssue() {
|
|
163
|
-
return new IssueBuilder()
|
|
164
|
-
.setCategory(issue_types_1.IssuesCategory.SECURITY)
|
|
165
|
-
.setPriority(issue_types_1.IssuePriority.CRITICAL);
|
|
166
|
-
}
|
|
167
|
-
static createEnergyIssue() {
|
|
168
|
-
return new IssueBuilder()
|
|
169
|
-
.setCategory(issue_types_1.IssuesCategory.ENERGY)
|
|
170
|
-
.setPriority(issue_types_1.IssuePriority.LOW);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Creates a device-specific issue builder
|
|
174
|
-
*/
|
|
175
|
-
static createDeviceIssue(deviceId, propertyId) {
|
|
176
|
-
return new IssueBuilder()
|
|
177
|
-
.setEntityType(issue_types_1.EntityType.DEVICE)
|
|
178
|
-
.setEntityId(deviceId)
|
|
179
|
-
.setPropertyId(propertyId);
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Creates a hub-specific issue builder
|
|
183
|
-
*/
|
|
184
|
-
static createHubIssue(hubId, propertyId) {
|
|
185
|
-
return new IssueBuilder()
|
|
186
|
-
.setEntityType(issue_types_1.EntityType.HUB)
|
|
187
|
-
.setEntityId(hubId)
|
|
188
|
-
.setPropertyId(propertyId);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Creates a user-specific issue builder
|
|
192
|
-
*/
|
|
193
|
-
static createUserIssue(userId, propertyId) {
|
|
194
|
-
return new IssueBuilder()
|
|
195
|
-
.setEntityType(issue_types_1.EntityType.USER)
|
|
196
|
-
.setEntityId(userId)
|
|
197
|
-
.setPropertyId(propertyId);
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Creates a property-specific issue builder
|
|
201
|
-
*/
|
|
202
|
-
static createPropertyIssue(propertyId) {
|
|
203
|
-
return new IssueBuilder()
|
|
204
|
-
.setEntityType(issue_types_1.EntityType.PROPERTY)
|
|
205
|
-
.setEntityId(propertyId)
|
|
206
|
-
.setPropertyId(propertyId);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Creates a maintenance issue builder
|
|
210
|
-
*/
|
|
211
|
-
static createMaintenanceIssue(propertyId, entityId, entityType) {
|
|
212
|
-
const builder = new IssueBuilder()
|
|
213
|
-
.setCategory(issue_types_1.IssuesCategory.READINESS)
|
|
214
|
-
.setPropertyId(propertyId)
|
|
215
|
-
.setPriority(issue_types_1.IssuePriority.MEDIUM);
|
|
216
|
-
if (entityId)
|
|
217
|
-
builder.setEntityId(entityId);
|
|
218
|
-
if (entityType)
|
|
219
|
-
builder.setEntityType(entityType);
|
|
220
|
-
return builder;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Creates an urgent issue builder
|
|
224
|
-
*/
|
|
225
|
-
static createUrgentIssue(propertyId, entityId, entityType) {
|
|
226
|
-
const builder = new IssueBuilder()
|
|
227
|
-
.setCategory(issue_types_1.IssuesCategory.OPERATIONS)
|
|
228
|
-
.setPropertyId(propertyId)
|
|
229
|
-
.setPriority(issue_types_1.IssuePriority.URGENT);
|
|
230
|
-
if (entityId)
|
|
231
|
-
builder.setEntityId(entityId);
|
|
232
|
-
if (entityType)
|
|
233
|
-
builder.setEntityType(entityType);
|
|
234
|
-
return builder;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
exports.IssueBuilder = IssueBuilder;
|
|
@@ -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,11 +0,0 @@
|
|
|
1
|
-
export declare class EventHandler {
|
|
2
|
-
private readonly source;
|
|
3
|
-
constructor();
|
|
4
|
-
onDeviceCreate(body: any): Promise<void>;
|
|
5
|
-
onDeviceUpdate(deviceId: string, body: any): Promise<void>;
|
|
6
|
-
onDeviceDelete(deviceId: string): Promise<void>;
|
|
7
|
-
onStateChange(deviceId: string, state: any): Promise<void>;
|
|
8
|
-
onStatusChange(deviceId: string, status: any): Promise<void>;
|
|
9
|
-
onBatteryLevelChange(deviceId: string, batteryLevel: number): Promise<void>;
|
|
10
|
-
onDeviceMetaChange(deviceId: string, metaData: Record<string, any>): Promise<void>;
|
|
11
|
-
}
|
|
@@ -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.CREATE.SUCCESS, body, this.source);
|
|
13
|
-
const payload = {
|
|
14
|
-
eventType: Events_1.DT_EVENT_TYPES.DEVICE.CREATE.SUCCESS,
|
|
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.UPDATE.SUCCESS, { deviceId, body }, this.source);
|
|
23
|
-
const payload = {
|
|
24
|
-
eventType: Events_1.DT_EVENT_TYPES.DEVICE.UPDATE.SUCCESS,
|
|
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.DELETE.SUCCESS, { deviceId }, this.source);
|
|
33
|
-
const payload = {
|
|
34
|
-
eventType: Events_1.DT_EVENT_TYPES.DEVICE.DELETE.SUCCESS,
|
|
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,75 +0,0 @@
|
|
|
1
|
-
export declare const DT_EVENT_TYPES: {
|
|
2
|
-
DEVICE: {
|
|
3
|
-
CREATE: {
|
|
4
|
-
SUCCESS: string;
|
|
5
|
-
FAILED: string;
|
|
6
|
-
};
|
|
7
|
-
UPDATE: {
|
|
8
|
-
SUCCESS: string;
|
|
9
|
-
FAILED: string;
|
|
10
|
-
};
|
|
11
|
-
DELETE: {
|
|
12
|
-
SUCCESS: string;
|
|
13
|
-
FAILED: string;
|
|
14
|
-
};
|
|
15
|
-
STATE: {
|
|
16
|
-
SET: string;
|
|
17
|
-
UNKNOWN: string;
|
|
18
|
-
UPDATED: string;
|
|
19
|
-
CHANGED: string;
|
|
20
|
-
};
|
|
21
|
-
STATUS: {
|
|
22
|
-
SET: string;
|
|
23
|
-
ONLINE: string;
|
|
24
|
-
OFFLINE: string;
|
|
25
|
-
UNKNOWN: string;
|
|
26
|
-
UPDATED: string;
|
|
27
|
-
CHANGED: string;
|
|
28
|
-
};
|
|
29
|
-
BATTERY: {
|
|
30
|
-
SET: string;
|
|
31
|
-
UNKNOWN: string;
|
|
32
|
-
LOW: string;
|
|
33
|
-
CRITICAL: string;
|
|
34
|
-
UPDATED: string;
|
|
35
|
-
CHANGED: string;
|
|
36
|
-
};
|
|
37
|
-
META_DATA: {
|
|
38
|
-
SET: string;
|
|
39
|
-
UPDATED: string;
|
|
40
|
-
CHANGED: string;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
CONNECTION: {
|
|
44
|
-
CREATE: {
|
|
45
|
-
SUCCESS: string;
|
|
46
|
-
FAILED: string;
|
|
47
|
-
};
|
|
48
|
-
UPDATE: {
|
|
49
|
-
SUCCESS: string;
|
|
50
|
-
FAILED: string;
|
|
51
|
-
};
|
|
52
|
-
DELETE: {
|
|
53
|
-
SUCCESS: string;
|
|
54
|
-
FAILED: string;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
PROPERTY: {
|
|
58
|
-
CREATE: {
|
|
59
|
-
SUCCESS: string;
|
|
60
|
-
FAILED: string;
|
|
61
|
-
};
|
|
62
|
-
UPDATE: {
|
|
63
|
-
SUCCESS: string;
|
|
64
|
-
FAILED: string;
|
|
65
|
-
};
|
|
66
|
-
DELETE: {
|
|
67
|
-
SUCCESS: string;
|
|
68
|
-
FAILED: string;
|
|
69
|
-
};
|
|
70
|
-
PREFERENCES: {
|
|
71
|
-
UPDATED: string;
|
|
72
|
-
CREATED: string;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
};
|
|
@@ -1,78 +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
|
-
CREATE: {
|
|
7
|
-
SUCCESS: "device.create.success",
|
|
8
|
-
FAILED: "device.create.failed",
|
|
9
|
-
},
|
|
10
|
-
UPDATE: {
|
|
11
|
-
SUCCESS: "device.update.success",
|
|
12
|
-
FAILED: "device.update.failed",
|
|
13
|
-
},
|
|
14
|
-
DELETE: {
|
|
15
|
-
SUCCESS: "device.delete.success",
|
|
16
|
-
FAILED: "device.delete.failed",
|
|
17
|
-
},
|
|
18
|
-
STATE: {
|
|
19
|
-
SET: "device.state.set",
|
|
20
|
-
UNKNOWN: "device.state.unknown",
|
|
21
|
-
UPDATED: "device.state.updated",
|
|
22
|
-
CHANGED: "device.state.changed",
|
|
23
|
-
},
|
|
24
|
-
STATUS: {
|
|
25
|
-
SET: "device.status.set",
|
|
26
|
-
ONLINE: "device.status.online",
|
|
27
|
-
OFFLINE: "device.status.offline",
|
|
28
|
-
UNKNOWN: "device.status.unknown",
|
|
29
|
-
UPDATED: "device.status.updated",
|
|
30
|
-
CHANGED: "device.status.changed",
|
|
31
|
-
},
|
|
32
|
-
BATTERY: {
|
|
33
|
-
SET: "device.battery.set",
|
|
34
|
-
UNKNOWN: "device.battery.unknown",
|
|
35
|
-
LOW: "device.battery.low",
|
|
36
|
-
CRITICAL: "device.battery.critical",
|
|
37
|
-
UPDATED: "device.battery.updated",
|
|
38
|
-
CHANGED: "device.battery.changed",
|
|
39
|
-
},
|
|
40
|
-
META_DATA: {
|
|
41
|
-
SET: "device.metaData.set",
|
|
42
|
-
UPDATED: "device.metaData.updated",
|
|
43
|
-
CHANGED: "device.metaData.changed",
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
CONNECTION: {
|
|
47
|
-
CREATE: {
|
|
48
|
-
SUCCESS: "connection.create.success",
|
|
49
|
-
FAILED: "connection.create.failed",
|
|
50
|
-
},
|
|
51
|
-
UPDATE: {
|
|
52
|
-
SUCCESS: "connection.update.success",
|
|
53
|
-
FAILED: "connection.update.failed",
|
|
54
|
-
},
|
|
55
|
-
DELETE: {
|
|
56
|
-
SUCCESS: "connection.delete.success",
|
|
57
|
-
FAILED: "connection.delete.failed",
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
PROPERTY: {
|
|
61
|
-
CREATE: {
|
|
62
|
-
SUCCESS: "property.create.success",
|
|
63
|
-
FAILED: "property.create.failed",
|
|
64
|
-
},
|
|
65
|
-
UPDATE: {
|
|
66
|
-
SUCCESS: "property.update.success",
|
|
67
|
-
FAILED: "property.update.failed",
|
|
68
|
-
},
|
|
69
|
-
DELETE: {
|
|
70
|
-
SUCCESS: "property.delete.success",
|
|
71
|
-
FAILED: "property.delete.failed",
|
|
72
|
-
},
|
|
73
|
-
PREFERENCES: {
|
|
74
|
-
UPDATED: "property.preferences.updated",
|
|
75
|
-
CREATED: "property.preferences.created",
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
};
|
|
@@ -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,7 +0,0 @@
|
|
|
1
|
-
export declare class EventHandler {
|
|
2
|
-
private readonly source;
|
|
3
|
-
constructor();
|
|
4
|
-
onStateChange(deviceId: string, state: any): Promise<void>;
|
|
5
|
-
onStatusChange(deviceId: string, status: any): Promise<void>;
|
|
6
|
-
onBatteryLevelChange(deviceId: string, batteryLevel: number): Promise<void>;
|
|
7
|
-
}
|
|
@@ -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,26 +0,0 @@
|
|
|
1
|
-
export interface IConnection {
|
|
2
|
-
id?: string;
|
|
3
|
-
createdAt?: Date;
|
|
4
|
-
updatedAt?: Date;
|
|
5
|
-
isDeleted?: boolean;
|
|
6
|
-
connectionName: string;
|
|
7
|
-
connectionRefId: string;
|
|
8
|
-
propertyId: string;
|
|
9
|
-
connectionProvider: ConnectionProvider;
|
|
10
|
-
accessToken?: string;
|
|
11
|
-
refreshToken?: string;
|
|
12
|
-
clientId?: string;
|
|
13
|
-
clientSecret: string;
|
|
14
|
-
isActive?: boolean;
|
|
15
|
-
metaData?: any;
|
|
16
|
-
}
|
|
17
|
-
export declare enum ConnectionProvider {
|
|
18
|
-
Smartthings = "Smartthings",
|
|
19
|
-
SaltoKS = "SaltoKS",
|
|
20
|
-
TTLock = "TTLock",
|
|
21
|
-
Tuya = "Tuya",
|
|
22
|
-
Schlage = "Schlage",
|
|
23
|
-
YaleWifi = "YaleWifi",
|
|
24
|
-
Sensibo = "Sensibo",
|
|
25
|
-
Devicethread = "Devicethread"
|
|
26
|
-
}
|
|
@@ -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 = {}));
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export interface IHub {
|
|
2
|
-
deviceId: string;
|
|
3
|
-
propertyId: string;
|
|
4
|
-
name: string;
|
|
5
|
-
hubId?: string[];
|
|
6
|
-
specifications: {
|
|
7
|
-
manufacturer?: string;
|
|
8
|
-
model?: string;
|
|
9
|
-
firmware?: {
|
|
10
|
-
version?: string;
|
|
11
|
-
newVersionAvailable?: boolean;
|
|
12
|
-
newVersion?: string;
|
|
13
|
-
mandatoryUpdate?: boolean;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
protocol: {
|
|
17
|
-
location?: {
|
|
18
|
-
id?: string;
|
|
19
|
-
name?: string;
|
|
20
|
-
city?: string;
|
|
21
|
-
};
|
|
22
|
-
name?: string;
|
|
23
|
-
room?: {
|
|
24
|
-
id?: string;
|
|
25
|
-
name?: string;
|
|
26
|
-
};
|
|
27
|
-
accountId?: string;
|
|
28
|
-
};
|
|
29
|
-
deviceType: {
|
|
30
|
-
id: string;
|
|
31
|
-
type: string;
|
|
32
|
-
};
|
|
33
|
-
status: {
|
|
34
|
-
online: boolean;
|
|
35
|
-
error?: {
|
|
36
|
-
type?: string;
|
|
37
|
-
message?: string;
|
|
38
|
-
default?: object;
|
|
39
|
-
};
|
|
40
|
-
lastUpdated?: Date;
|
|
41
|
-
};
|
|
42
|
-
state?: object;
|
|
43
|
-
metaData?: object;
|
|
44
|
-
createdAt?: Date;
|
|
45
|
-
updatedAt?: Date;
|
|
46
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import mongoose, { Model } from "mongoose";
|
|
2
|
-
import { AlertCategory, AlertSeverity, EntityType, AlertDocument as IAlertDocument, CreateAlertData, UpdateAlertData } from "../../../types/alert.types";
|
|
3
|
-
interface IAlertMethods {
|
|
4
|
-
markAsRead(updatedBy: string): void;
|
|
5
|
-
markAsUnread(updatedBy: string): void;
|
|
6
|
-
activate(updatedBy: string): void;
|
|
7
|
-
deactivate(updatedBy: string): void;
|
|
8
|
-
snooze(until: Date, updatedBy: string): void;
|
|
9
|
-
unsnooze(updatedBy: string): void;
|
|
10
|
-
}
|
|
11
|
-
interface IAlertModel extends Model<IAlertDocument, {}, IAlertMethods> {
|
|
12
|
-
findByProperty(propertyId: string, includeDeleted?: boolean): Promise<IAlertDocument[]>;
|
|
13
|
-
findByEntity(entityId: string, entityType: EntityType, includeDeleted?: boolean): Promise<IAlertDocument[]>;
|
|
14
|
-
findByCategory(category: AlertCategory, includeDeleted?: boolean): Promise<IAlertDocument[]>;
|
|
15
|
-
findBySeverity(severity: AlertSeverity, includeDeleted?: boolean): Promise<IAlertDocument[]>;
|
|
16
|
-
findActive(includeDeleted?: boolean): Promise<IAlertDocument[]>;
|
|
17
|
-
findUnread(includeDeleted?: boolean): Promise<IAlertDocument[]>;
|
|
18
|
-
findSnoozed(includeDeleted?: boolean): Promise<IAlertDocument[]>;
|
|
19
|
-
findExpiredSnooze(includeDeleted?: boolean): Promise<IAlertDocument[]>;
|
|
20
|
-
}
|
|
21
|
-
declare const AlertSchema: mongoose.Schema<IAlertDocument, IAlertModel, IAlertMethods, {}, {}, {}, mongoose.DefaultSchemaOptions, IAlertDocument, mongoose.Document<unknown, {}, mongoose.FlatRecord<IAlertDocument>, {}> & Omit<mongoose.FlatRecord<IAlertDocument> & Required<{
|
|
22
|
-
_id: string;
|
|
23
|
-
}> & {
|
|
24
|
-
__v: number;
|
|
25
|
-
}, keyof IAlertMethods> & IAlertMethods>;
|
|
26
|
-
export declare const AlertModel: IAlertModel;
|
|
27
|
-
export { AlertSchema };
|
|
28
|
-
export type { IAlertDocument, CreateAlertData, UpdateAlertData, IAlertMethods, IAlertModel, };
|