dt-common-device 7.8.14 → 7.9.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/audit/AuditUtils.js +172 -100
- package/dist/entities/accessGroup/AccessGroup.repository.d.ts +2 -1
- package/dist/entities/accessGroup/AccessGroup.repository.js +4 -1
- package/dist/entities/accessGroup/AccessGroup.service.d.ts +2 -1
- package/dist/entities/accessGroup/AccessGroup.service.js +4 -3
- package/dist/entities/device/local/repository/DeviceProfile.repository.d.ts +5 -0
- package/dist/{device/cloud/entities/DeviceFactory.js → entities/device/local/repository/DeviceProfile.repository.js} +12 -27
- package/dist/entities/device/local/services/Device.service.js +3 -3
- package/dist/entities/guest/Guest.repository.d.ts +1 -1
- package/dist/entities/guest/Guest.repository.js +5 -2
- package/dist/entities/guest/Guest.service.d.ts +1 -1
- package/dist/entities/guest/Guest.service.js +4 -1
- package/dist/entities/schedules/Schedule.repository.d.ts +1 -1
- package/dist/entities/schedules/Schedule.repository.js +5 -2
- package/dist/entities/schedules/Schedule.service.d.ts +1 -1
- package/dist/entities/schedules/Schedule.service.js +4 -1
- package/dist/entities/user/User.repository.js +4 -1
- package/dist/entities/user/User.service.d.ts +1 -1
- package/dist/entities/user/User.service.js +4 -1
- package/dist/entities/zone/Zone.service.js +4 -1
- package/package.json +1 -1
- package/dist/admin/Admin.repository.d.ts +0 -7
- package/dist/admin/Admin.repository.js +0 -182
- package/dist/admin/Admin.service.d.ts +0 -5
- package/dist/admin/Admin.service.js +0 -17
- package/dist/admin/index.d.ts +0 -1
- package/dist/admin/index.js +0 -17
- package/dist/audit/AuditProperties.d.ts +0 -16
- package/dist/audit/AuditProperties.js +0 -2
- package/dist/chronicle/IChronicle.interface.d.ts +0 -14
- package/dist/chronicle/IChronicle.interface.js +0 -2
- package/dist/chronicle/chronicle.service.d.ts +0 -4
- package/dist/chronicle/chronicle.service.js +0 -44
- package/dist/connection/Connection.repository.d.ts +0 -8
- package/dist/connection/Connection.repository.js +0 -92
- package/dist/connection/Connection.service.d.ts +0 -8
- package/dist/connection/Connection.service.js +0 -32
- package/dist/connection/IConnection.d.ts +0 -28
- package/dist/connection/IConnection.js +0 -16
- package/dist/connection/index.d.ts +0 -2
- package/dist/connection/index.js +0 -18
- package/dist/device/cloud/entities/CloudConnection.d.ts +0 -6
- package/dist/device/cloud/entities/CloudConnection.js +0 -6
- package/dist/device/cloud/entities/CloudDevice.d.ts +0 -16
- package/dist/device/cloud/entities/CloudDevice.js +0 -26
- package/dist/device/cloud/entities/CloudDeviceService.d.ts +0 -5
- package/dist/device/cloud/entities/CloudDeviceService.js +0 -9
- package/dist/device/cloud/entities/DeviceFactory.d.ts +0 -7
- package/dist/device/cloud/entities/index.d.ts +0 -3
- package/dist/device/cloud/entities/index.js +0 -19
- package/dist/device/cloud/interface.d.ts +0 -101
- package/dist/device/cloud/interface.js +0 -3
- package/dist/device/cloud/interfaces/ICloudConnection.d.ts +0 -5
- package/dist/device/cloud/interfaces/ICloudConnection.js +0 -2
- package/dist/device/cloud/interfaces/ICloudDevice.d.ts +0 -9
- package/dist/device/cloud/interfaces/ICloudDevice.js +0 -2
- package/dist/device/cloud/interfaces/ICloudDeviceService.d.ts +0 -4
- package/dist/device/cloud/interfaces/ICloudDeviceService.js +0 -2
- package/dist/device/cloud/interfaces/IConnectionService.d.ts +0 -7
- package/dist/device/cloud/interfaces/IConnectionService.js +0 -2
- package/dist/device/cloud/interfaces/IDeviceConnectionService.d.ts +0 -7
- package/dist/device/cloud/interfaces/IDeviceConnectionService.js +0 -3
- package/dist/device/cloud/interfaces/IDeviceFactory.d.ts +0 -4
- package/dist/device/cloud/interfaces/IDeviceFactory.js +0 -2
- package/dist/device/cloud/interfaces/IDeviceService.d.ts +0 -8
- package/dist/device/cloud/interfaces/IDeviceService.js +0 -2
- package/dist/device/cloud/interfaces/IDevicesService.d.ts +0 -9
- package/dist/device/cloud/interfaces/IDevicesService.js +0 -2
- package/dist/device/cloud/interfaces/IHubService.d.ts +0 -5
- package/dist/device/cloud/interfaces/IHubService.js +0 -2
- package/dist/device/cloud/interfaces/IRawDataTransformer.d.ts +0 -4
- package/dist/device/cloud/interfaces/IRawDataTransformer.js +0 -2
- package/dist/device/cloud/interfaces/IRawDevice.d.ts +0 -17
- package/dist/device/cloud/interfaces/IRawDevice.js +0 -11
- package/dist/device/cloud/interfaces/index.d.ts +0 -5
- package/dist/device/cloud/interfaces/index.js +0 -21
- 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/Device.service.d.ts +0 -39
- package/dist/device/cloud/services/Device.service.js +0 -9
- package/dist/device/cloud/services/DeviceCloudService.d.ts +0 -42
- package/dist/device/cloud/services/DeviceCloudService.js +0 -59
- package/dist/device/cloud/services/DeviceHub.service.d.ts +0 -3
- package/dist/device/cloud/services/DeviceHub.service.js +0 -6
- package/dist/device/cloud/services/Hub.service.d.ts +0 -25
- package/dist/device/cloud/services/Hub.service.js +0 -9
- package/dist/device/cloud/services/SmartThingsDeviceService.d.ts +0 -38
- package/dist/device/cloud/services/SmartThingsDeviceService.js +0 -52
- 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/index.d.ts +0 -4
- package/dist/device/index.js +0 -20
- 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 -54
- package/dist/device/local/events/Events.js +0 -57
- 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/interface.d.ts +0 -0
- package/dist/device/local/interface.js +0 -1
- package/dist/device/local/interfaces/IConnection.d.ts +0 -26
- package/dist/device/local/interfaces/IConnection.js +0 -14
- package/dist/device/local/interfaces/IDevice.d.ts +0 -68
- package/dist/device/local/interfaces/IDevice.js +0 -10
- package/dist/device/local/interfaces/IDtDevice.d.ts +0 -16
- package/dist/device/local/interfaces/IDtDevice.js +0 -2
- package/dist/device/local/interfaces/IHub.d.ts +0 -46
- package/dist/device/local/interfaces/IHub.js +0 -2
- package/dist/device/local/interfaces/IProperty.d.ts +0 -29
- package/dist/device/local/interfaces/IProperty.js +0 -2
- package/dist/device/local/interfaces/ISchedule.d.ts +0 -25
- package/dist/device/local/interfaces/ISchedule.js +0 -2
- package/dist/device/local/interfaces/index.d.ts +0 -3
- package/dist/device/local/interfaces/index.js +0 -19
- 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/Connection.repository.js +0 -92
- package/dist/device/local/repository/Device.repository.d.ts +0 -30
- package/dist/device/local/repository/Device.repository.js +0 -325
- package/dist/device/local/repository/Hub.repository.d.ts +0 -13
- package/dist/device/local/repository/Hub.repository.js +0 -139
- 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/repository/Property.repository.js +0 -95
- package/dist/device/local/repository/Schedule.repository.d.ts +0 -9
- package/dist/device/local/repository/Schedule.repository.js +0 -109
- 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/Device.service.d.ts +0 -40
- package/dist/device/local/services/Device.service.js +0 -391
- package/dist/device/local/services/DeviceHub.service.d.ts +0 -11
- package/dist/device/local/services/DeviceHub.service.js +0 -40
- package/dist/device/local/services/Hub.service.d.ts +0 -12
- package/dist/device/local/services/Hub.service.js +0 -107
- 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/device/local/services/Schedule.service.d.ts +0 -9
- package/dist/device/local/services/Schedule.service.js +0 -26
- package/dist/device/local/services/index.d.ts +0 -3
- package/dist/device/local/services/index.js +0 -19
- package/dist/pms/IPms.d.ts +0 -6
- package/dist/pms/IPms.js +0 -10
- package/dist/pms/index.d.ts +0 -1
- package/dist/pms/index.js +0 -18
- package/dist/pms/webhookQueue/examples/index.d.ts +0 -2
- package/dist/pms/webhookQueue/examples/index.js +0 -18
- package/dist/pms/webhookQueue/examples/pms-integration.d.ts +0 -65
- package/dist/pms/webhookQueue/examples/pms-integration.js +0 -254
- package/dist/pms/webhookQueue/examples/usage.d.ts +0 -7
- package/dist/pms/webhookQueue/examples/usage.js +0 -175
- package/dist/pms/webhookQueue/index.d.ts +0 -3
- package/dist/pms/webhookQueue/index.js +0 -20
- package/dist/pms/webhookQueue/interfaces/IWebhookQueue.d.ts +0 -33
- package/dist/pms/webhookQueue/interfaces/IWebhookQueue.js +0 -2
- package/dist/pms/webhookQueue/interfaces/IWebhookWorker.d.ts +0 -38
- package/dist/pms/webhookQueue/interfaces/IWebhookWorker.js +0 -2
- package/dist/pms/webhookQueue/interfaces/index.d.ts +0 -1
- package/dist/pms/webhookQueue/interfaces/index.js +0 -17
- package/dist/pms/webhookQueue/services/WebhookQueueFactory.d.ts +0 -38
- package/dist/pms/webhookQueue/services/WebhookQueueFactory.js +0 -131
- package/dist/pms/webhookQueue/services/WebhookQueueIntegration.d.ts +0 -70
- package/dist/pms/webhookQueue/services/WebhookQueueIntegration.js +0 -207
- package/dist/pms/webhookQueue/services/WebhookQueueService.d.ts +0 -45
- package/dist/pms/webhookQueue/services/WebhookQueueService.js +0 -270
- package/dist/pms/webhookQueue/services/WebhookWorker.d.ts +0 -37
- package/dist/pms/webhookQueue/services/WebhookWorker.js +0 -201
- package/dist/pms/webhookQueue/services/index.d.ts +0 -1
- package/dist/pms/webhookQueue/services/index.js +0 -17
- package/dist/pms/webhookQueue/types/index.d.ts +0 -1
- package/dist/pms/webhookQueue/types/index.js +0 -17
- package/dist/pms/webhookQueue/types/webhook.types.d.ts +0 -39
- package/dist/pms/webhookQueue/types/webhook.types.js +0 -2
- package/dist/property/IProperty.d.ts +0 -29
- package/dist/property/IProperty.js +0 -2
- package/dist/property/Property.repository.d.ts +0 -8
- package/dist/property/Property.repository.js +0 -109
- package/dist/property/Property.service.d.ts +0 -8
- package/dist/property/Property.service.js +0 -124
- package/dist/property/index.d.ts +0 -2
- package/dist/property/index.js +0 -18
- 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/AuditUtils.js
CHANGED
|
@@ -78,6 +78,7 @@ const services_1 = require("../entities/device/local/services");
|
|
|
78
78
|
const typedi_1 = __importStar(require("typedi"));
|
|
79
79
|
const pms_1 = require("../entities/pms");
|
|
80
80
|
const admin_1 = require("../entities/admin");
|
|
81
|
+
const config_1 = require("../config/config");
|
|
81
82
|
let AuditUtils = (() => {
|
|
82
83
|
let _classDecorators = [(0, typedi_1.Service)()];
|
|
83
84
|
let _classDescriptor;
|
|
@@ -132,57 +133,74 @@ let AuditUtils = (() => {
|
|
|
132
133
|
return audit;
|
|
133
134
|
}
|
|
134
135
|
async populateAuditFields(audit) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (propertyId
|
|
138
|
-
|
|
136
|
+
try {
|
|
137
|
+
const { propertyId, propertyName, userId, userName, guestId, guestName, deviceId, deviceName, zoneId, zoneName, accessGroupId, accessGroupName, scheduleId, } = audit;
|
|
138
|
+
if (propertyId && !propertyName) {
|
|
139
|
+
(0, config_1.getLogger)().info(`Property ID: ${propertyId}`);
|
|
140
|
+
if (propertyId === "triggered_externally") {
|
|
141
|
+
audit.propertyName = "Triggered Externally";
|
|
142
|
+
}
|
|
143
|
+
else if (propertyId === "property_not_found") {
|
|
144
|
+
(0, config_1.getLogger)().info(`Property ID: ${propertyId}`);
|
|
145
|
+
audit.propertyName = "Property Not Found";
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
(0, config_1.getLogger)().info(`Property ID: ${propertyId}`);
|
|
149
|
+
audit.propertyName = await this.getPropertyName(propertyId);
|
|
150
|
+
}
|
|
139
151
|
}
|
|
140
|
-
|
|
141
|
-
audit.
|
|
152
|
+
if (!propertyId && deviceId) {
|
|
153
|
+
audit.propertyId = await this.getFieldFromDevice(deviceId, "propertyId");
|
|
154
|
+
audit.propertyName = await this.getPropertyName(audit.propertyId);
|
|
155
|
+
}
|
|
156
|
+
if (zoneId && !zoneName)
|
|
157
|
+
audit.zoneName = await this.getZoneName(zoneId);
|
|
158
|
+
if (!zoneId && deviceId) {
|
|
159
|
+
audit.zoneId = await this.getFieldFromDevice(deviceId, "zoneId");
|
|
160
|
+
audit.zoneName = await this.getZoneName(audit.zoneId);
|
|
161
|
+
}
|
|
162
|
+
if (userId && !userName)
|
|
163
|
+
audit.userName = await this.getUserName(userId);
|
|
164
|
+
if (guestId && !guestName)
|
|
165
|
+
audit.guestName = await this.getGuestName(guestId);
|
|
166
|
+
if (deviceId && !deviceName) {
|
|
167
|
+
audit.deviceName = await this.getDeviceName(deviceId);
|
|
168
|
+
}
|
|
169
|
+
if (accessGroupId && !accessGroupName)
|
|
170
|
+
audit.accessGroupName = await this.getAccessGroupName(accessGroupId);
|
|
171
|
+
if (scheduleId) {
|
|
172
|
+
const { scheduleStartDate, scheduleEndDate, scheduleDuration, scheduleSource, scheduleStatus, } = await this.getScheduleDetails(scheduleId);
|
|
173
|
+
audit.scheduleStartDate = scheduleStartDate;
|
|
174
|
+
audit.scheduleEndDate = scheduleEndDate;
|
|
175
|
+
audit.scheduleDuration = scheduleDuration;
|
|
176
|
+
audit.scheduleSource = scheduleSource;
|
|
177
|
+
audit.scheduleStatus = scheduleStatus;
|
|
142
178
|
}
|
|
143
179
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
audit.propertyName = await this.getPropertyName(audit.propertyId);
|
|
147
|
-
}
|
|
148
|
-
if (zoneId && !zoneName)
|
|
149
|
-
audit.zoneName = await this.getZoneName(zoneId);
|
|
150
|
-
if (!zoneId && deviceId) {
|
|
151
|
-
audit.zoneId = await this.getFieldFromDevice(deviceId, "zoneId");
|
|
152
|
-
audit.zoneName = await this.getZoneName(audit.zoneId);
|
|
153
|
-
}
|
|
154
|
-
if (userId && !userName)
|
|
155
|
-
audit.userName = await this.getUserName(userId);
|
|
156
|
-
if (guestId && !guestName)
|
|
157
|
-
audit.guestName = await this.getGuestName(guestId);
|
|
158
|
-
if (deviceId && !deviceName) {
|
|
159
|
-
audit.deviceName = await this.getDeviceName(deviceId);
|
|
160
|
-
}
|
|
161
|
-
if (accessGroupId && !accessGroupName)
|
|
162
|
-
audit.accessGroupName = await this.getAccessGroupName(accessGroupId);
|
|
163
|
-
if (scheduleId) {
|
|
164
|
-
const { scheduleStartDate, scheduleEndDate, scheduleDuration, scheduleSource, scheduleStatus, } = await this.getScheduleDetails(scheduleId);
|
|
165
|
-
audit.scheduleStartDate = scheduleStartDate;
|
|
166
|
-
audit.scheduleEndDate = scheduleEndDate;
|
|
167
|
-
audit.scheduleDuration = scheduleDuration;
|
|
168
|
-
audit.scheduleSource = scheduleSource;
|
|
169
|
-
audit.scheduleStatus = scheduleStatus;
|
|
180
|
+
catch (error) {
|
|
181
|
+
(0, config_1.getLogger)().error("Error in populateAuditFields:", error);
|
|
170
182
|
}
|
|
171
183
|
}
|
|
172
184
|
/**
|
|
173
185
|
* Generic utility to get cached entity data from Redis using individual keys
|
|
174
186
|
*/
|
|
175
187
|
async getCachedEntityData(entityType, entityId, fetchFunction) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
188
|
+
try {
|
|
189
|
+
const cacheKey = `${this.CACHE_PREFIX}:${entityType}:${entityId}`;
|
|
190
|
+
// Try to get from cache first
|
|
191
|
+
const cachedData = await this.redisUtils.get(cacheKey);
|
|
192
|
+
if (cachedData) {
|
|
193
|
+
return JSON.parse(cachedData);
|
|
194
|
+
}
|
|
195
|
+
// If not in cache, fetch from database and cache it
|
|
196
|
+
const entityData = await fetchFunction();
|
|
197
|
+
await this.redisUtils.set(cacheKey, JSON.stringify(entityData), this.CACHE_TTL);
|
|
198
|
+
return entityData;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
(0, config_1.getLogger)().error("Error in getCachedEntityData:", error);
|
|
202
|
+
throw error;
|
|
181
203
|
}
|
|
182
|
-
// If not in cache, fetch from database and cache it
|
|
183
|
-
const entityData = await fetchFunction();
|
|
184
|
-
await this.redisUtils.set(cacheKey, JSON.stringify(entityData), this.CACHE_TTL);
|
|
185
|
-
return entityData;
|
|
186
204
|
}
|
|
187
205
|
/**
|
|
188
206
|
* Utility to calculate schedule duration in days
|
|
@@ -192,85 +210,139 @@ let AuditUtils = (() => {
|
|
|
192
210
|
return Math.ceil(duration / (1000 * 60 * 60 * 24));
|
|
193
211
|
}
|
|
194
212
|
async getPropertyName(propertyId) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
213
|
+
try {
|
|
214
|
+
return await this.getCachedEntityData("property", propertyId, async () => {
|
|
215
|
+
const property = await typedi_1.default.get(property_1.LocalPropertyService).getProperty(propertyId);
|
|
216
|
+
return property?.name || "property_not_found";
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
(0, config_1.getLogger)().error("Error in getPropertyName:", error);
|
|
221
|
+
return "";
|
|
222
|
+
}
|
|
199
223
|
}
|
|
200
224
|
async getFieldFromDevice(deviceId, field) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
225
|
+
try {
|
|
226
|
+
const redisKey = `device:${deviceId}`;
|
|
227
|
+
const redisDevice = await this.redisUtils.hget(redisKey, "device");
|
|
228
|
+
if (redisDevice) {
|
|
229
|
+
return redisDevice[field];
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
const device = await typedi_1.default.get(services_1.LocalDeviceService).getDevice(deviceId);
|
|
233
|
+
await this.redisUtils.hset(redisKey, "device", JSON.stringify(device));
|
|
234
|
+
await this.redisUtils.expire(redisKey, this.CACHE_TTL);
|
|
235
|
+
return device[field];
|
|
236
|
+
}
|
|
205
237
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
await this.redisUtils.expire(redisKey, this.CACHE_TTL);
|
|
210
|
-
return device[field];
|
|
238
|
+
catch (error) {
|
|
239
|
+
(0, config_1.getLogger)().error("Error in getFieldFromDevice:", error);
|
|
240
|
+
return "";
|
|
211
241
|
}
|
|
212
242
|
}
|
|
213
243
|
async getUserName(userId) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
244
|
+
try {
|
|
245
|
+
return await this.getCachedEntityData("user", userId, async () => {
|
|
246
|
+
const user = await typedi_1.default.get(admin_1.AdminService).getUser(userId);
|
|
247
|
+
if (!user)
|
|
248
|
+
return "user_not_found";
|
|
249
|
+
return `${user?.firstName || ""} ${user?.lastName || ""}`.trim();
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
(0, config_1.getLogger)().error("Error in getUserName:", error);
|
|
254
|
+
return "";
|
|
255
|
+
}
|
|
220
256
|
}
|
|
221
257
|
async getGuestName(guestId) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
258
|
+
try {
|
|
259
|
+
return await this.getCachedEntityData("guest", guestId, async () => {
|
|
260
|
+
const guest = await typedi_1.default.get(pms_1.PmsService).getGuest(guestId);
|
|
261
|
+
if (!guest)
|
|
262
|
+
return "";
|
|
263
|
+
return `${guest?.firstName || ""} ${guest?.lastName || ""}`.trim();
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
(0, config_1.getLogger)().error("Error in getGuestName:", error);
|
|
268
|
+
return "";
|
|
269
|
+
}
|
|
228
270
|
}
|
|
229
271
|
async getDeviceName(deviceId) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
272
|
+
try {
|
|
273
|
+
return await this.getCachedEntityData("device", deviceId, async () => {
|
|
274
|
+
const device = await typedi_1.default.get(services_1.LocalDeviceService).querySelect({ deviceId }, ["name"]);
|
|
275
|
+
if (!device)
|
|
276
|
+
return "";
|
|
277
|
+
return device[0]?.name || "";
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
(0, config_1.getLogger)().error("Error in getDeviceName:", error);
|
|
282
|
+
return "";
|
|
283
|
+
}
|
|
236
284
|
}
|
|
237
285
|
async getZoneName(zoneId) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
286
|
+
try {
|
|
287
|
+
return await this.getCachedEntityData("zone", zoneId, async () => {
|
|
288
|
+
const zone = await typedi_1.default.get(admin_1.AdminService).getZone(zoneId);
|
|
289
|
+
if (!zone)
|
|
290
|
+
return "";
|
|
291
|
+
return zone?.name || "";
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
(0, config_1.getLogger)().error("Error in getZoneName:", error);
|
|
296
|
+
return "";
|
|
297
|
+
}
|
|
244
298
|
}
|
|
245
299
|
async getAccessGroupName(accessGroupId) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
300
|
+
try {
|
|
301
|
+
return await this.getCachedEntityData("accessGroup", accessGroupId, async () => {
|
|
302
|
+
const accessGroup = await typedi_1.default.get(admin_1.AdminService).getAccessGroup(accessGroupId);
|
|
303
|
+
if (!accessGroup)
|
|
304
|
+
return "";
|
|
305
|
+
return accessGroup?.name || "";
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
(0, config_1.getLogger)().error("Error in getAccessGroupName:", error);
|
|
310
|
+
return "";
|
|
311
|
+
}
|
|
252
312
|
}
|
|
253
313
|
async getScheduleDetails(scheduleId) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
314
|
+
try {
|
|
315
|
+
return await this.getCachedEntityData("schedule", scheduleId, async () => {
|
|
316
|
+
const schedule = await typedi_1.default.get(pms_1.PmsService).getSchedule(scheduleId);
|
|
317
|
+
if (!schedule) {
|
|
318
|
+
return {
|
|
319
|
+
scheduleStartDate: "",
|
|
320
|
+
scheduleEndDate: "",
|
|
321
|
+
scheduleDuration: 0,
|
|
322
|
+
scheduleSource: "",
|
|
323
|
+
scheduleStatus: "",
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
const scheduleDuration = this.calculateScheduleDuration(schedule.startTime, schedule.endTime);
|
|
257
327
|
return {
|
|
258
|
-
scheduleStartDate:
|
|
259
|
-
scheduleEndDate:
|
|
260
|
-
scheduleDuration
|
|
261
|
-
scheduleSource:
|
|
262
|
-
scheduleStatus:
|
|
328
|
+
scheduleStartDate: schedule.startTime,
|
|
329
|
+
scheduleEndDate: schedule.endTime,
|
|
330
|
+
scheduleDuration,
|
|
331
|
+
scheduleSource: schedule.source,
|
|
332
|
+
scheduleStatus: schedule.status,
|
|
263
333
|
};
|
|
264
|
-
}
|
|
265
|
-
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
(0, config_1.getLogger)().error("Error in getScheduleDetails:", error);
|
|
266
338
|
return {
|
|
267
|
-
scheduleStartDate:
|
|
268
|
-
scheduleEndDate:
|
|
269
|
-
scheduleDuration,
|
|
270
|
-
scheduleSource:
|
|
271
|
-
scheduleStatus:
|
|
339
|
+
scheduleStartDate: "",
|
|
340
|
+
scheduleEndDate: "",
|
|
341
|
+
scheduleDuration: 0,
|
|
342
|
+
scheduleSource: "",
|
|
343
|
+
scheduleStatus: "",
|
|
272
344
|
};
|
|
273
|
-
}
|
|
345
|
+
}
|
|
274
346
|
}
|
|
275
347
|
};
|
|
276
348
|
__setFunctionName(_classThis, "AuditUtils");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { IAccessGroup } from "./IAccessGroup";
|
|
1
2
|
export declare class AccessGroupRepository {
|
|
2
3
|
private readonly postgres;
|
|
3
4
|
constructor();
|
|
4
|
-
getAccessGroup(accessGroupId: string): Promise<
|
|
5
|
+
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
5
6
|
}
|
|
@@ -56,7 +56,10 @@ let AccessGroupRepository = (() => {
|
|
|
56
56
|
WHERE "id" = $1
|
|
57
57
|
`;
|
|
58
58
|
const result = await this.postgres.query(query, [accessGroupId]);
|
|
59
|
-
|
|
59
|
+
if (result.rows.length > 0) {
|
|
60
|
+
return result.rows[0];
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
60
63
|
}
|
|
61
64
|
};
|
|
62
65
|
__setFunctionName(_classThis, "AccessGroupRepository");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { IAccessGroup } from "./IAccessGroup";
|
|
1
2
|
export declare class AccessGroupService {
|
|
2
3
|
private readonly accessGroupRepository;
|
|
3
4
|
constructor();
|
|
4
|
-
getAccessGroup(accessGroupId: string): Promise<
|
|
5
|
+
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
5
6
|
}
|
|
@@ -87,7 +87,10 @@ let AccessGroupService = (() => {
|
|
|
87
87
|
if (!accessGroupId) {
|
|
88
88
|
throw new Error("Access Group ID is required");
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
const accessGroup = await this.accessGroupRepository.getAccessGroup(accessGroupId);
|
|
91
|
+
if (!accessGroup)
|
|
92
|
+
return null;
|
|
93
|
+
return accessGroup;
|
|
91
94
|
}
|
|
92
95
|
};
|
|
93
96
|
__setFunctionName(_classThis, "AccessGroupService");
|
|
@@ -101,5 +104,3 @@ let AccessGroupService = (() => {
|
|
|
101
104
|
return AccessGroupService = _classThis;
|
|
102
105
|
})();
|
|
103
106
|
exports.AccessGroupService = AccessGroupService;
|
|
104
|
-
// Accessgroup.getAccessGroup(accessGroupId)
|
|
105
|
-
// GetAccessGroup()
|
|
@@ -37,44 +37,29 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
|
|
|
37
37
|
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
38
|
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
39
|
};
|
|
40
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
-
};
|
|
43
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
let
|
|
49
|
-
let _classDecorators = [(0, typedi_2.Service)()];
|
|
41
|
+
exports.DeviceProfileRepository = void 0;
|
|
42
|
+
const typedi_1 = require("typedi");
|
|
43
|
+
const utils_1 = require("../../../../utils");
|
|
44
|
+
let DeviceProfileRepository = (() => {
|
|
45
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
50
46
|
let _classDescriptor;
|
|
51
47
|
let _classExtraInitializers = [];
|
|
52
48
|
let _classThis;
|
|
53
|
-
var
|
|
49
|
+
var DeviceProfileRepository = _classThis = class {
|
|
54
50
|
constructor() {
|
|
55
|
-
|
|
56
|
-
this.localDeviceService = typedi_1.default.get(Device_service_1.LocalDeviceService);
|
|
57
|
-
}
|
|
58
|
-
async getDevice(deviceId) {
|
|
59
|
-
try {
|
|
60
|
-
return await this.localDeviceService.getDevice(deviceId);
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
// Log the error for debugging purposes
|
|
64
|
-
console.error(`DeviceFactory: Failed to get device ${deviceId}:`, error);
|
|
65
|
-
// Re-throw the error with additional context
|
|
66
|
-
throw new Error(`DeviceFactory: Unable to retrieve device ${deviceId}. ${error instanceof Error ? error.message : "Unknown error occurred"}`);
|
|
67
|
-
}
|
|
51
|
+
this.axiosInstance = (0, utils_1.getDeviceServiceAxiosInstance)();
|
|
68
52
|
}
|
|
53
|
+
async getDeviceBaseLine(deviceId) { }
|
|
69
54
|
};
|
|
70
|
-
__setFunctionName(_classThis, "
|
|
55
|
+
__setFunctionName(_classThis, "DeviceProfileRepository");
|
|
71
56
|
(() => {
|
|
72
57
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
73
58
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
74
|
-
|
|
59
|
+
DeviceProfileRepository = _classThis = _classDescriptor.value;
|
|
75
60
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
76
61
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
77
62
|
})();
|
|
78
|
-
return
|
|
63
|
+
return DeviceProfileRepository = _classThis;
|
|
79
64
|
})();
|
|
80
|
-
exports.
|
|
65
|
+
exports.DeviceProfileRepository = DeviceProfileRepository;
|
|
@@ -137,7 +137,7 @@ let LocalDeviceService = (() => {
|
|
|
137
137
|
await this.handleOnlineStatus(device, device.status, body.status, auditBody?.source || Service_1.Source.SYSTEM, auditBody);
|
|
138
138
|
}
|
|
139
139
|
else {
|
|
140
|
-
await this.handleOfflineStatus(device, device.status, body.status, auditBody?.source || Service_1.Source.SYSTEM, auditBody);
|
|
140
|
+
await this.handleOfflineStatus(device, device.status, body.status, auditBody?.source || Service_1.Source.SYSTEM, auditBody, body.status.error?.message);
|
|
141
141
|
}
|
|
142
142
|
if (body.state?.batteryPercentage?.value) {
|
|
143
143
|
await this.setBatteryLevel(deviceId, body.state?.batteryPercentage?.value, auditBody?.source || Service_1.Source.SYSTEM, auditBody);
|
|
@@ -278,8 +278,8 @@ let LocalDeviceService = (() => {
|
|
|
278
278
|
await this.eventHandler.onStatusChangeMany(query, newStatus, auditBody, eventType);
|
|
279
279
|
}
|
|
280
280
|
async handleOfflineStatus(device, oldStatus, newStatus, source, auditBody, reason, currentTime) {
|
|
281
|
-
const isExistingStatusOnline = oldStatus?.
|
|
282
|
-
const isExistingStatusOffline = oldStatus?.
|
|
281
|
+
const isExistingStatusOnline = oldStatus?.liveStatus === "ONLINE";
|
|
282
|
+
const isExistingStatusOffline = oldStatus?.liveStatus === "OFFLINE";
|
|
283
283
|
if (isExistingStatusOnline) {
|
|
284
284
|
// Existing status is Online
|
|
285
285
|
newStatus.online = true;
|
|
@@ -52,8 +52,11 @@ let GuestRepository = (() => {
|
|
|
52
52
|
}
|
|
53
53
|
async getGuest(guestId) {
|
|
54
54
|
try {
|
|
55
|
-
const guest = await this.pmsPostgres.query(`SELECT * FROM
|
|
56
|
-
|
|
55
|
+
const guest = await this.pmsPostgres.query(`SELECT * FROM dt_guest WHERE "id" = $1`, [guestId]);
|
|
56
|
+
if (guest.rows.length > 0) {
|
|
57
|
+
return guest.rows[0];
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
57
60
|
}
|
|
58
61
|
catch (error) {
|
|
59
62
|
console.error("Error in getGuest:", error);
|
|
@@ -88,7 +88,10 @@ let GuestService = (() => {
|
|
|
88
88
|
if (!guestId) {
|
|
89
89
|
throw new Error("Guest ID is required");
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
const guest = await this.guestRepository.getGuest(guestId);
|
|
92
|
+
if (!guest)
|
|
93
|
+
return null;
|
|
94
|
+
return guest;
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
__setFunctionName(_classThis, "GuestService");
|
|
@@ -52,8 +52,11 @@ let ScheduleRepository = (() => {
|
|
|
52
52
|
}
|
|
53
53
|
async getSchedule(scheduleId) {
|
|
54
54
|
try {
|
|
55
|
-
const schedule = await this.pmsPostgres.query(`SELECT * FROM
|
|
56
|
-
|
|
55
|
+
const schedule = await this.pmsPostgres.query(`SELECT * FROM dt_schedule WHERE "id" = $1`, [scheduleId]);
|
|
56
|
+
if (schedule.rows.length > 0) {
|
|
57
|
+
return schedule.rows[0];
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
57
60
|
}
|
|
58
61
|
catch (error) {
|
|
59
62
|
console.error("Error in getSchedule:", error);
|
|
@@ -88,7 +88,10 @@ let ScheduleService = (() => {
|
|
|
88
88
|
if (!scheduleId) {
|
|
89
89
|
throw new Error("Schedule ID is required");
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
const schedule = await this.scheduleRepository.getSchedule(scheduleId);
|
|
92
|
+
if (!schedule)
|
|
93
|
+
return null;
|
|
94
|
+
return schedule;
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
__setFunctionName(_classThis, "ScheduleService");
|
|
@@ -52,7 +52,10 @@ 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
|
-
|
|
55
|
+
if (user.rows.length > 0) {
|
|
56
|
+
return user.rows[0];
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
56
59
|
}
|
|
57
60
|
};
|
|
58
61
|
__setFunctionName(_classThis, "UserRepository");
|
|
@@ -87,7 +87,10 @@ let UserService = (() => {
|
|
|
87
87
|
if (!userId) {
|
|
88
88
|
throw new Error("User ID is required");
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
const user = await this.userRepository.getUser(userId);
|
|
91
|
+
if (!user)
|
|
92
|
+
return null;
|
|
93
|
+
return user;
|
|
91
94
|
}
|
|
92
95
|
};
|
|
93
96
|
__setFunctionName(_classThis, "UserService");
|
|
@@ -88,7 +88,10 @@ let ZoneService = (() => {
|
|
|
88
88
|
if (!zoneId) {
|
|
89
89
|
throw new Error("Zone ID is required");
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
const zone = await this.zoneRepository.getZone(zoneId);
|
|
92
|
+
if (!zone)
|
|
93
|
+
return null;
|
|
94
|
+
return zone;
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
__setFunctionName(_classThis, "ZoneService");
|
package/package.json
CHANGED