dt-common-device 7.1.13 → 7.2.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.model.d.ts +1 -1
- package/dist/audit/IAuditProperties.d.ts +3 -1
- package/dist/audit/IAuditProperties.js +2 -0
- package/dist/config/config.js +3 -0
- package/dist/config/constants.js +2 -1
- package/dist/constants/Event.d.ts +31 -0
- package/dist/constants/Event.js +31 -0
- 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/admin/Admin.repository.d.ts +1 -0
- package/dist/entities/admin/Admin.repository.js +32 -0
- package/dist/entities/admin/Admin.service.d.ts +1 -0
- package/dist/entities/admin/Admin.service.js +8 -0
- package/dist/entities/device/local/services/Device.service.js +2 -1
- 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/dist/issues/Issue.model.d.ts +1 -1
- package/dist/issues/Issue.service.d.ts +15 -15
- package/dist/issues/Issue.service.js +34 -6
- 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/DeviceFactory.js +0 -80
- 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 -17
- 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
|
@@ -13,7 +13,7 @@ interface IAlertModel extends Model<IAlertDocument, {}, IAlertMethods> {
|
|
|
13
13
|
findSnoozed(includeDeleted?: boolean): Promise<IAlertDocument[]>;
|
|
14
14
|
findExpiredSnooze(includeDeleted?: boolean): Promise<IAlertDocument[]>;
|
|
15
15
|
}
|
|
16
|
-
declare const AlertSchema: mongoose.Schema<IAlertDocument, IAlertModel, IAlertMethods, {}, {}, {}, mongoose.DefaultSchemaOptions, IAlertDocument, mongoose.Document<unknown, {}, mongoose.FlatRecord<IAlertDocument>, {}
|
|
16
|
+
declare const AlertSchema: mongoose.Schema<IAlertDocument, IAlertModel, IAlertMethods, {}, {}, {}, mongoose.DefaultSchemaOptions, IAlertDocument, mongoose.Document<unknown, {}, mongoose.FlatRecord<IAlertDocument>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & Omit<mongoose.FlatRecord<IAlertDocument> & Required<{
|
|
17
17
|
_id: string;
|
|
18
18
|
}> & {
|
|
19
19
|
__v: number;
|
package/dist/config/config.js
CHANGED
|
@@ -103,6 +103,9 @@ async function validateInternalEventHandler(cfg) {
|
|
|
103
103
|
throw error;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
+
else {
|
|
107
|
+
throw new Error("dt-common-device: No internal event handler provided. Please provide an internal event handler in the config.");
|
|
108
|
+
}
|
|
106
109
|
}
|
|
107
110
|
async function validateServiceConfig(cfg) {
|
|
108
111
|
checkRequiredEnv(constants_1.CONFIG_KEYS[sourceKey].env);
|
package/dist/config/constants.js
CHANGED
|
@@ -164,4 +164,35 @@ export declare const DT_EVENT_TYPES: {
|
|
|
164
164
|
FAILED: string;
|
|
165
165
|
};
|
|
166
166
|
};
|
|
167
|
+
ISSUE: {
|
|
168
|
+
CREATE: {
|
|
169
|
+
SUCCESS: string;
|
|
170
|
+
FAILED: string;
|
|
171
|
+
SKIPPED: string;
|
|
172
|
+
};
|
|
173
|
+
UPDATE: {
|
|
174
|
+
SUCCESS: string;
|
|
175
|
+
};
|
|
176
|
+
DELETE: {
|
|
177
|
+
SUCCESS: string;
|
|
178
|
+
};
|
|
179
|
+
CANCEL: {
|
|
180
|
+
SUCCESS: string;
|
|
181
|
+
};
|
|
182
|
+
RESOLVE: {
|
|
183
|
+
SUCCESS: string;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
ALERT: {
|
|
187
|
+
CREATE: {
|
|
188
|
+
SUCCESS: string;
|
|
189
|
+
SKIPPED: string;
|
|
190
|
+
};
|
|
191
|
+
UPDATE: {
|
|
192
|
+
SUCCESS: string;
|
|
193
|
+
};
|
|
194
|
+
DELETE: {
|
|
195
|
+
SUCCESS: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
167
198
|
};
|
package/dist/constants/Event.js
CHANGED
|
@@ -167,4 +167,35 @@ exports.DT_EVENT_TYPES = {
|
|
|
167
167
|
FAILED: "zone.delete.failed",
|
|
168
168
|
},
|
|
169
169
|
},
|
|
170
|
+
ISSUE: {
|
|
171
|
+
CREATE: {
|
|
172
|
+
SUCCESS: "issue.create.success",
|
|
173
|
+
FAILED: "issue.create.failed",
|
|
174
|
+
SKIPPED: "issue.create.skipped",
|
|
175
|
+
},
|
|
176
|
+
UPDATE: {
|
|
177
|
+
SUCCESS: "issue.update.success",
|
|
178
|
+
},
|
|
179
|
+
DELETE: {
|
|
180
|
+
SUCCESS: "issue.delete.success",
|
|
181
|
+
},
|
|
182
|
+
CANCEL: {
|
|
183
|
+
SUCCESS: "issue.cancel.success",
|
|
184
|
+
},
|
|
185
|
+
RESOLVE: {
|
|
186
|
+
SUCCESS: "issue.resolve.success",
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
ALERT: {
|
|
190
|
+
CREATE: {
|
|
191
|
+
SUCCESS: "alert.create.success",
|
|
192
|
+
SKIPPED: "alert.create.skipped",
|
|
193
|
+
},
|
|
194
|
+
UPDATE: {
|
|
195
|
+
SUCCESS: "alert.update.success",
|
|
196
|
+
},
|
|
197
|
+
DELETE: {
|
|
198
|
+
SUCCESS: "alert.delete.success",
|
|
199
|
+
},
|
|
200
|
+
},
|
|
170
201
|
};
|
|
@@ -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()
|
|
@@ -4,6 +4,7 @@ export declare class AdminRepository {
|
|
|
4
4
|
private readonly postgres;
|
|
5
5
|
constructor();
|
|
6
6
|
getZonesByAccessGroupIds(accessGroupIds: string[]): Promise<any[]>;
|
|
7
|
+
getZonesByAccessGroups(accessGroupIds: string[]): Promise<any[]>;
|
|
7
8
|
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
8
9
|
getZoneAccessGroupByZoneId(zoneId: string): Promise<IZoneAccessGroup | null>;
|
|
9
10
|
getZone(zoneId: string): Promise<IZone | null>;
|
|
@@ -165,6 +165,38 @@ let AdminRepository = (() => {
|
|
|
165
165
|
const collectionZoneDevices = Array.from(new Set(_collectionZone));
|
|
166
166
|
return collectionZoneDevices;
|
|
167
167
|
}
|
|
168
|
+
async getZonesByAccessGroups(accessGroupIds) {
|
|
169
|
+
// Fetch zones associated with these access groups
|
|
170
|
+
const zonesIdsQuery = `
|
|
171
|
+
SELECT DISTINCT z."zoneId"
|
|
172
|
+
FROM dt_zones_collection_map z
|
|
173
|
+
WHERE z."collectionId" = ANY($1)
|
|
174
|
+
`;
|
|
175
|
+
const zonesIdsResult = await this.postgres.query(zonesIdsQuery, [
|
|
176
|
+
accessGroupIds,
|
|
177
|
+
]);
|
|
178
|
+
const zoneTypesQuery = `
|
|
179
|
+
SELECT id
|
|
180
|
+
FROM "dt_zoneTypes"
|
|
181
|
+
WHERE name = 'Guest Room'
|
|
182
|
+
`;
|
|
183
|
+
const zoneTypes = await this.postgres.query(zoneTypesQuery);
|
|
184
|
+
const guestRoomZoneTypeId = zoneTypes.rows[0].id;
|
|
185
|
+
const zonesIds = zonesIdsResult.rows.map((row) => row.zoneId);
|
|
186
|
+
const zonesQuery = `
|
|
187
|
+
SELECT id
|
|
188
|
+
FROM dt_zones
|
|
189
|
+
WHERE id = ANY($1) AND "zoneTypeId" = $2
|
|
190
|
+
`;
|
|
191
|
+
const zonesResult = await this.postgres.query(zonesQuery, [
|
|
192
|
+
zonesIds,
|
|
193
|
+
guestRoomZoneTypeId,
|
|
194
|
+
]);
|
|
195
|
+
if (zonesResult?.rows?.length > 0) {
|
|
196
|
+
return zonesResult?.rows?.map((e) => e.id);
|
|
197
|
+
}
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
168
200
|
async getAccessGroup(accessGroupId) {
|
|
169
201
|
const query = `
|
|
170
202
|
SELECT * FROM dt_collections
|
|
@@ -3,6 +3,7 @@ export declare class AdminService {
|
|
|
3
3
|
private readonly adminRepository;
|
|
4
4
|
constructor();
|
|
5
5
|
getZonesByAccessGroupIds(accessGroupIds: string[]): Promise<any[] | undefined>;
|
|
6
|
+
getZonesByAccessGroups(accessGroupIds: string[]): Promise<any[] | undefined>;
|
|
6
7
|
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
7
8
|
getAccessGroupByZoneId(zoneId: string): Promise<IAccessGroup | null>;
|
|
8
9
|
getZone(zoneId: string): Promise<IZone | null>;
|
|
@@ -91,6 +91,14 @@ let AdminService = (() => {
|
|
|
91
91
|
console.log(error);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
+
async getZonesByAccessGroups(accessGroupIds) {
|
|
95
|
+
try {
|
|
96
|
+
return await this.adminRepository.getZonesByAccessGroups(accessGroupIds);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.log(error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
94
102
|
async getAccessGroup(accessGroupId) {
|
|
95
103
|
if (!accessGroupId) {
|
|
96
104
|
throw new Error("Access Group ID is required");
|
|
@@ -82,6 +82,7 @@ const typedi_1 = __importStar(require("typedi"));
|
|
|
82
82
|
const IAuditProperties_1 = require("../../../../audit/IAuditProperties");
|
|
83
83
|
const constants_1 = require("../../../../constants");
|
|
84
84
|
const audit_1 = require("../../../../audit");
|
|
85
|
+
const issue_types_1 = require("../../../../issues/issue.types");
|
|
85
86
|
let LocalDeviceService = (() => {
|
|
86
87
|
let _classDecorators = [(0, typedi_1.Service)()];
|
|
87
88
|
let _classDescriptor;
|
|
@@ -361,7 +362,7 @@ let LocalDeviceService = (() => {
|
|
|
361
362
|
// Raise alert
|
|
362
363
|
await this.alertService.raiseDeviceBatteryAlert(device, batteryLevel, propertyThreshold, source);
|
|
363
364
|
// Raise issue when the level is below threshold
|
|
364
|
-
await this.issueService.createDeviceBatteryIssue(device, batteryLevel, propertyThreshold, source);
|
|
365
|
+
await this.issueService.createDeviceBatteryIssue(device, batteryLevel, propertyThreshold, issue_types_1.IssuePriority.CRITICAL, source);
|
|
365
366
|
}
|
|
366
367
|
}
|
|
367
368
|
}
|
|
@@ -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");
|
|
@@ -14,7 +14,7 @@ interface IIssueModel extends Model<IIssueDocument, {}, IIssueMethods> {
|
|
|
14
14
|
findOverdue(includeDeleted?: boolean): Promise<IIssueDocument[]>;
|
|
15
15
|
findUpcoming(days?: number, includeDeleted?: boolean): Promise<IIssueDocument[]>;
|
|
16
16
|
}
|
|
17
|
-
declare const IssueSchema: mongoose.Schema<IIssueDocument, IIssueModel, IIssueMethods, {}, {}, {}, mongoose.DefaultSchemaOptions, IIssueDocument, mongoose.Document<unknown, {}, mongoose.FlatRecord<IIssueDocument>, {}
|
|
17
|
+
declare const IssueSchema: mongoose.Schema<IIssueDocument, IIssueModel, IIssueMethods, {}, {}, {}, mongoose.DefaultSchemaOptions, IIssueDocument, mongoose.Document<unknown, {}, mongoose.FlatRecord<IIssueDocument>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & Omit<mongoose.FlatRecord<IIssueDocument> & Required<{
|
|
18
18
|
_id: string;
|
|
19
19
|
}> & {
|
|
20
20
|
__v: number;
|
|
@@ -9,31 +9,31 @@ export declare class IssueService {
|
|
|
9
9
|
/**
|
|
10
10
|
* Create a readiness issue using IssueBuilder
|
|
11
11
|
*/
|
|
12
|
-
createReadinessIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
12
|
+
createReadinessIssue(data: CreateIssueData): Promise<IIssueDocument | null>;
|
|
13
13
|
/**
|
|
14
14
|
* Create an operations issue using IssueBuilder
|
|
15
15
|
*/
|
|
16
|
-
createOperationsIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
16
|
+
createOperationsIssue(data: CreateIssueData): Promise<IIssueDocument | null>;
|
|
17
17
|
/**
|
|
18
18
|
* Create a security issue using IssueBuilder
|
|
19
19
|
*/
|
|
20
|
-
createSecurityIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
20
|
+
createSecurityIssue(data: CreateIssueData): Promise<IIssueDocument | null>;
|
|
21
21
|
/**
|
|
22
22
|
* Create an energy issue using IssueBuilder
|
|
23
23
|
*/
|
|
24
|
-
createEnergyIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
24
|
+
createEnergyIssue(data: CreateIssueData): Promise<IIssueDocument | null>;
|
|
25
25
|
/**
|
|
26
26
|
* Create a device-specific issue using IssueBuilder
|
|
27
27
|
*/
|
|
28
|
-
createDeviceIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
28
|
+
createDeviceIssue(data: CreateIssueData): Promise<IIssueDocument | null>;
|
|
29
29
|
/**
|
|
30
30
|
* Create a hub-specific issue using IssueBuilder
|
|
31
31
|
*/
|
|
32
|
-
createHubIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
32
|
+
createHubIssue(data: CreateIssueData): Promise<IIssueDocument | null>;
|
|
33
33
|
/**
|
|
34
34
|
* Create a user-specific issue using IssueBuilder
|
|
35
35
|
*/
|
|
36
|
-
createUserIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
36
|
+
createUserIssue(data: CreateIssueData): Promise<IIssueDocument | null>;
|
|
37
37
|
createCloudAccountAuthorizationIssue(data: {
|
|
38
38
|
propertyId: string;
|
|
39
39
|
entityId: string;
|
|
@@ -42,33 +42,33 @@ export declare class IssueService {
|
|
|
42
42
|
description: string;
|
|
43
43
|
createdBy: string;
|
|
44
44
|
type: IssueType;
|
|
45
|
-
}): Promise<IIssueDocument>;
|
|
45
|
+
}): Promise<IIssueDocument | null>;
|
|
46
46
|
/**
|
|
47
47
|
* Create issue for device going offline longer than baseline
|
|
48
48
|
*/
|
|
49
|
-
createDeviceOfflineIssue(device: IDevice, source: Source, reason?: string): Promise<IIssueDocument>;
|
|
50
|
-
createDoorLeftOpenIssue(device: IDevice, source: Source, reason?: string): Promise<IIssueDocument>;
|
|
49
|
+
createDeviceOfflineIssue(device: IDevice, source: Source, reason?: string): Promise<IIssueDocument | null>;
|
|
50
|
+
createDoorLeftOpenIssue(device: IDevice, source: Source, reason?: string): Promise<IIssueDocument | null>;
|
|
51
51
|
/**
|
|
52
52
|
* Create issue for device battery level below threshold (READINESS + OPERATIONAL + ENERGY)
|
|
53
53
|
*/
|
|
54
|
-
createDeviceBatteryIssue(device: IDevice, batteryLevel: number, threshold: number, source: Source): Promise<IIssueDocument>;
|
|
54
|
+
createDeviceBatteryIssue(device: IDevice, batteryLevel: number, threshold: number, priority: IssuePriority, source: Source): Promise<IIssueDocument | null>;
|
|
55
55
|
/**
|
|
56
56
|
* Create issue for device malfunction (jammed or not accepting codes) (READINESS + OPERATIONAL)
|
|
57
57
|
*/
|
|
58
|
-
createDeviceMalfunctionIssue(device: IDevice, source: Source, reason?: string): Promise<IIssueDocument>;
|
|
58
|
+
createDeviceMalfunctionIssue(device: IDevice, source: Source, reason?: string): Promise<IIssueDocument | null>;
|
|
59
59
|
/**
|
|
60
60
|
* Create a maintenance issue using IssueBuilder
|
|
61
61
|
*/
|
|
62
|
-
createMaintenanceIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
62
|
+
createMaintenanceIssue(data: CreateIssueData): Promise<IIssueDocument | null>;
|
|
63
63
|
/**
|
|
64
64
|
* Create a high priority issue using IssueBuilder
|
|
65
65
|
*/
|
|
66
|
-
createHighPriorityIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
66
|
+
createHighPriorityIssue(data: CreateIssueData): Promise<IIssueDocument | null>;
|
|
67
67
|
/**
|
|
68
68
|
* Create a new issue with business logic validation
|
|
69
69
|
* Accepts either a CreateIssueData object or an IssueBuilder instance
|
|
70
70
|
*/
|
|
71
|
-
createIssue(issueData: CreateIssueData | IssueBuilder): Promise<IIssueDocument>;
|
|
71
|
+
createIssue(issueData: CreateIssueData | IssueBuilder): Promise<IIssueDocument | null>;
|
|
72
72
|
/**
|
|
73
73
|
* Get issue by ID with business logic
|
|
74
74
|
*/
|
|
@@ -78,6 +78,9 @@ const Issue_model_1 = require("./Issue.model");
|
|
|
78
78
|
const issue_types_1 = require("./issue.types");
|
|
79
79
|
const IssueBuilder_1 = require("./IssueBuilder");
|
|
80
80
|
const Admin_service_1 = require("../entities/admin/Admin.service");
|
|
81
|
+
const audit_1 = require("../audit");
|
|
82
|
+
const constants_1 = require("../constants");
|
|
83
|
+
const dt_pub_sub_1 = require("dt-pub-sub");
|
|
81
84
|
let IssueService = (() => {
|
|
82
85
|
let _classDecorators = [(0, typedi_1.Service)()];
|
|
83
86
|
let _classDescriptor;
|
|
@@ -257,7 +260,7 @@ let IssueService = (() => {
|
|
|
257
260
|
propertyId: device.propertyId,
|
|
258
261
|
zoneId: device.zoneId,
|
|
259
262
|
title: "Device Offline - Requires Attention",
|
|
260
|
-
description: `${device.name} has been offline for longer than the threshold time. ${reason ? `Reason: ${reason}
|
|
263
|
+
description: `${device.name} has been offline for longer than the threshold time. ${reason ? `Reason: ${reason}.` : ""}`,
|
|
261
264
|
createdBy: source,
|
|
262
265
|
category: issue_types_1.IssuesCategory.OPERATIONS,
|
|
263
266
|
priority: issue_types_1.IssuePriority.CRITICAL,
|
|
@@ -273,7 +276,7 @@ let IssueService = (() => {
|
|
|
273
276
|
propertyId: device.propertyId,
|
|
274
277
|
zoneId: device.zoneId,
|
|
275
278
|
title: "Door Left Open - Requires Attention",
|
|
276
|
-
description: `${zone?.name} has a door left open, for more than 10 minutes. ${reason ? `Reason: ${reason}
|
|
279
|
+
description: `${zone?.name} has a door left open, for more than 10 minutes. ${reason ? `Reason: ${reason}.` : ""}`,
|
|
277
280
|
createdBy: source,
|
|
278
281
|
category: issue_types_1.IssuesCategory.SECURITY,
|
|
279
282
|
priority: issue_types_1.IssuePriority.HIGH,
|
|
@@ -283,7 +286,7 @@ let IssueService = (() => {
|
|
|
283
286
|
/**
|
|
284
287
|
* Create issue for device battery level below threshold (READINESS + OPERATIONAL + ENERGY)
|
|
285
288
|
*/
|
|
286
|
-
async createDeviceBatteryIssue(device, batteryLevel, threshold, source) {
|
|
289
|
+
async createDeviceBatteryIssue(device, batteryLevel, threshold, priority, source) {
|
|
287
290
|
return await this.createDeviceIssue({
|
|
288
291
|
entityId: device.deviceId,
|
|
289
292
|
entityType: issue_types_1.EntityType.DEVICE,
|
|
@@ -294,7 +297,7 @@ let IssueService = (() => {
|
|
|
294
297
|
description: `${device.name} battery level is ${batteryLevel}%, which is below the property threshold of ${threshold}%.`,
|
|
295
298
|
createdBy: source,
|
|
296
299
|
category: issue_types_1.IssuesCategory.ENERGY,
|
|
297
|
-
priority:
|
|
300
|
+
priority: priority,
|
|
298
301
|
type: issue_types_1.IssueType.BATTERY_LOW,
|
|
299
302
|
});
|
|
300
303
|
}
|
|
@@ -309,7 +312,7 @@ let IssueService = (() => {
|
|
|
309
312
|
propertyId: device.propertyId,
|
|
310
313
|
zoneId: device.zoneId,
|
|
311
314
|
title: `Device Malfunction - Requires Attention`,
|
|
312
|
-
description: `${device.name} is malfunctioning. ${reason ? `Reason: ${reason}
|
|
315
|
+
description: `${device.name} is malfunctioning. ${reason ? `Reason: ${reason}.` : ""}`,
|
|
313
316
|
createdBy: source,
|
|
314
317
|
category: issue_types_1.IssuesCategory.OPERATIONS,
|
|
315
318
|
priority: issue_types_1.IssuePriority.HIGH,
|
|
@@ -372,7 +375,32 @@ let IssueService = (() => {
|
|
|
372
375
|
processedIssueData.dueDate <= new Date()) {
|
|
373
376
|
throw new Error("Due date must be in the future");
|
|
374
377
|
}
|
|
375
|
-
|
|
378
|
+
const existingIssue = await this.issueRepository.query({
|
|
379
|
+
propertyId: processedIssueData.propertyId,
|
|
380
|
+
entityId: processedIssueData.entityId,
|
|
381
|
+
entityType: processedIssueData.entityType,
|
|
382
|
+
entitySubType: processedIssueData.entitySubType,
|
|
383
|
+
type: processedIssueData.type,
|
|
384
|
+
});
|
|
385
|
+
if (existingIssue.length > 0) {
|
|
386
|
+
await (0, audit_1.pushAudit)({
|
|
387
|
+
auditType: constants_1.DT_EVENT_TYPES.ISSUE.CREATE.SKIPPED,
|
|
388
|
+
auditData: {
|
|
389
|
+
reason: "Issue already exists",
|
|
390
|
+
propertyId: processedIssueData.propertyId,
|
|
391
|
+
entityId: processedIssueData.entityId,
|
|
392
|
+
entityType: processedIssueData.entityType,
|
|
393
|
+
entitySubType: processedIssueData.entitySubType,
|
|
394
|
+
type: processedIssueData.type,
|
|
395
|
+
resource: audit_1.Resource.ISSUE,
|
|
396
|
+
source: processedIssueData.createdBy,
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
const issue = await this.issueRepository.create(processedIssueData);
|
|
402
|
+
await dt_pub_sub_1.eventDispatcher.publishEvent(constants_1.DT_EVENT_TYPES.ISSUE.CREATE.SUCCESS, issue, "dt-common-device");
|
|
403
|
+
return issue;
|
|
376
404
|
}
|
|
377
405
|
/**
|
|
378
406
|
* Get issue by ID with business logic
|
package/package.json
CHANGED