dt-common-device 7.2.7 → 7.4.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/alerts/Alert.model.js +0 -1
- package/dist/alerts/Alert.repository.d.ts +1 -0
- package/dist/alerts/Alert.repository.js +25 -19
- package/dist/alerts/alert.types.d.ts +3 -3
- package/dist/config/config.d.ts +1 -0
- package/dist/config/config.js +12 -0
- package/dist/config/constants.js +7 -1
- package/dist/constants/Event.d.ts +1 -0
- package/dist/constants/Event.js +1 -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/device/local/services/Device.service.d.ts +1 -0
- package/dist/entities/device/local/services/Device.service.js +12 -5
- 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/events/EventHandler.d.ts +1 -0
- package/dist/events/EventHandler.js +10 -0
- package/dist/events/InternalEventSubscription.d.ts +1 -0
- package/dist/events/InternalEventSubscription.js +4 -0
- package/dist/issues/Issue.model.d.ts +1 -1
- package/dist/issues/Issue.model.js +0 -1
- package/dist/issues/Issue.repository.d.ts +1 -0
- package/dist/issues/Issue.repository.js +23 -23
- package/dist/issues/issue.types.d.ts +3 -3
- 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;
|
|
@@ -2,6 +2,7 @@ import { IAlertDocument } from "./Alert.model";
|
|
|
2
2
|
import { CreateAlertData, UpdateAlertData, AlertCategory, AlertSeverity, IAlertQuery } from "./alert.types";
|
|
3
3
|
export declare class AlertRepository {
|
|
4
4
|
private buildQuery;
|
|
5
|
+
private buildOptions;
|
|
5
6
|
/**
|
|
6
7
|
* Create a new alert
|
|
7
8
|
*/
|
|
@@ -48,7 +48,7 @@ let AlertRepository = (() => {
|
|
|
48
48
|
let _classExtraInitializers = [];
|
|
49
49
|
let _classThis;
|
|
50
50
|
var AlertRepository = _classThis = class {
|
|
51
|
-
|
|
51
|
+
buildQuery(filters = {}) {
|
|
52
52
|
const query = {};
|
|
53
53
|
if (filters.propertyId)
|
|
54
54
|
query.propertyId = filters.propertyId;
|
|
@@ -68,18 +68,34 @@ let AlertRepository = (() => {
|
|
|
68
68
|
query.isRead = filters.isRead;
|
|
69
69
|
if (!filters.includeDeleted)
|
|
70
70
|
query.isDeleted = false;
|
|
71
|
-
if (filters.type)
|
|
72
|
-
|
|
71
|
+
if (filters.type) {
|
|
72
|
+
if (Array.isArray(filters.type)) {
|
|
73
|
+
query.type = { $in: filters.type };
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
query.type = filters.type;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
73
79
|
// Date filtering
|
|
74
80
|
if (filters.startDate || filters.endDate) {
|
|
75
81
|
query.createdAt = {};
|
|
76
82
|
if (filters.startDate)
|
|
77
|
-
query.createdAt.$gte = filters.startDate;
|
|
83
|
+
query.createdAt.$gte = new Date(filters.startDate);
|
|
78
84
|
if (filters.endDate)
|
|
79
|
-
query.createdAt.$lte = filters.endDate;
|
|
85
|
+
query.createdAt.$lte = new Date(filters.endDate);
|
|
80
86
|
}
|
|
81
87
|
return query;
|
|
82
88
|
}
|
|
89
|
+
buildOptions(filters = {}) {
|
|
90
|
+
const options = {};
|
|
91
|
+
if (filters.sort)
|
|
92
|
+
options.sort = filters.sort;
|
|
93
|
+
if (filters.skip)
|
|
94
|
+
options.skip = filters.skip;
|
|
95
|
+
if (filters.limit)
|
|
96
|
+
options.limit = filters.limit;
|
|
97
|
+
return options;
|
|
98
|
+
}
|
|
83
99
|
/**
|
|
84
100
|
* Create a new alert
|
|
85
101
|
*/
|
|
@@ -120,19 +136,9 @@ let AlertRepository = (() => {
|
|
|
120
136
|
*/
|
|
121
137
|
async query(filters = {}) {
|
|
122
138
|
try {
|
|
123
|
-
const query =
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
queryBuilder.sort(filters.sort);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
queryBuilder.sort({ severity: -1, createdAt: -1 });
|
|
130
|
-
}
|
|
131
|
-
if (filters.skip)
|
|
132
|
-
queryBuilder.skip(filters.skip);
|
|
133
|
-
if (filters.limit)
|
|
134
|
-
queryBuilder.limit(filters.limit);
|
|
135
|
-
const results = await queryBuilder.exec();
|
|
139
|
+
const query = this.buildQuery(filters);
|
|
140
|
+
const options = this.buildOptions(filters);
|
|
141
|
+
const results = await Alert_model_1.AlertModel.find(query, null, options);
|
|
136
142
|
return results.map((result) => result.toObject());
|
|
137
143
|
}
|
|
138
144
|
catch (error) {
|
|
@@ -184,7 +190,7 @@ let AlertRepository = (() => {
|
|
|
184
190
|
*/
|
|
185
191
|
async count(filters = {}) {
|
|
186
192
|
try {
|
|
187
|
-
const query =
|
|
193
|
+
const query = this.buildQuery(filters);
|
|
188
194
|
return await Alert_model_1.AlertModel.countDocuments(query);
|
|
189
195
|
}
|
|
190
196
|
catch (error) {
|
|
@@ -75,12 +75,12 @@ export interface IAlertQuery {
|
|
|
75
75
|
severity?: AlertSeverity;
|
|
76
76
|
entityType?: EntityType;
|
|
77
77
|
entityId?: string;
|
|
78
|
-
type?: AlertType;
|
|
78
|
+
type?: AlertType | AlertType[];
|
|
79
79
|
isActive?: boolean;
|
|
80
80
|
isRead?: boolean;
|
|
81
81
|
includeDeleted?: boolean;
|
|
82
|
-
startDate?:
|
|
83
|
-
endDate?:
|
|
82
|
+
startDate?: string;
|
|
83
|
+
endDate?: string;
|
|
84
84
|
sort?: {
|
|
85
85
|
[key: string]: 1 | -1;
|
|
86
86
|
};
|
package/dist/config/config.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare function getConfig(): IConfig;
|
|
|
5
5
|
export declare function getDeviceServiceUrl(): string;
|
|
6
6
|
export declare function getAdminServiceUrl(): string;
|
|
7
7
|
export declare function getSqsQueueUrl(): string;
|
|
8
|
+
export declare function getReservationSqsQueueUrl(): string;
|
|
8
9
|
export declare function getEventSubscription(): InternalEventSubscription | null;
|
|
9
10
|
export declare function checkRequiredEnv(requiredEnvs: string[]): void;
|
|
10
11
|
export declare function ensureAuditInitialized(): void;
|
package/dist/config/config.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.getConfig = getConfig;
|
|
|
8
8
|
exports.getDeviceServiceUrl = getDeviceServiceUrl;
|
|
9
9
|
exports.getAdminServiceUrl = getAdminServiceUrl;
|
|
10
10
|
exports.getSqsQueueUrl = getSqsQueueUrl;
|
|
11
|
+
exports.getReservationSqsQueueUrl = getReservationSqsQueueUrl;
|
|
11
12
|
exports.getEventSubscription = getEventSubscription;
|
|
12
13
|
exports.checkRequiredEnv = checkRequiredEnv;
|
|
13
14
|
exports.ensureAuditInitialized = ensureAuditInitialized;
|
|
@@ -149,6 +150,17 @@ function getSqsQueueUrl() {
|
|
|
149
150
|
}
|
|
150
151
|
throw new Error("dt-common-device: AWS_SQS_URL is not configured for this service");
|
|
151
152
|
}
|
|
153
|
+
function getReservationSqsQueueUrl() {
|
|
154
|
+
if (constants_1.CONFIG_KEYS[sourceKey].env.includes("RESERVATION_SQS_URL")) {
|
|
155
|
+
const reservationSqsQueueUrl = process.env.RESERVATION_SQS_URL;
|
|
156
|
+
if (!reservationSqsQueueUrl) {
|
|
157
|
+
getConfig().LOGGER.error("RESERVATION_SQS_URL must be set in environment variables");
|
|
158
|
+
throw new Error("dt-common-device: RESERVATION_SQS_URL must be set in environment variables");
|
|
159
|
+
}
|
|
160
|
+
return reservationSqsQueueUrl;
|
|
161
|
+
}
|
|
162
|
+
return "";
|
|
163
|
+
}
|
|
152
164
|
function getEventSubscription() {
|
|
153
165
|
return eventSubscription;
|
|
154
166
|
}
|
package/dist/config/constants.js
CHANGED
|
@@ -17,7 +17,13 @@ exports.REQUIRED = {
|
|
|
17
17
|
};
|
|
18
18
|
exports.CONFIG_KEYS = {
|
|
19
19
|
ACCESS: {
|
|
20
|
-
env: [
|
|
20
|
+
env: [
|
|
21
|
+
"ADMIN_DB_URI",
|
|
22
|
+
"PMS_DB_URI",
|
|
23
|
+
"AWS_SQS_URL",
|
|
24
|
+
"RESERVATION_SQS_URL",
|
|
25
|
+
"ADMIN_SERVICE",
|
|
26
|
+
],
|
|
21
27
|
INTERNAL_EVENT_HANDLER: true,
|
|
22
28
|
db_keys: {
|
|
23
29
|
access: "DATABASE_URL",
|
package/dist/constants/Event.js
CHANGED
|
@@ -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()
|
|
@@ -6,6 +6,7 @@ export declare class LocalDeviceService {
|
|
|
6
6
|
private readonly deviceRepository;
|
|
7
7
|
private readonly alertService;
|
|
8
8
|
private readonly issueService;
|
|
9
|
+
private readonly localPropertyService;
|
|
9
10
|
constructor();
|
|
10
11
|
createDevice(body: IDevice): Promise<IDevice>;
|
|
11
12
|
getDevice(deviceId: string, withHubDetails?: boolean): Promise<IDevice>;
|
|
@@ -83,6 +83,7 @@ const IAuditProperties_1 = require("../../../../audit/IAuditProperties");
|
|
|
83
83
|
const constants_1 = require("../../../../constants");
|
|
84
84
|
const audit_1 = require("../../../../audit");
|
|
85
85
|
const issue_types_1 = require("../../../../issues/issue.types");
|
|
86
|
+
const property_1 = require("../../../property");
|
|
86
87
|
let LocalDeviceService = (() => {
|
|
87
88
|
let _classDecorators = [(0, typedi_1.Service)()];
|
|
88
89
|
let _classDescriptor;
|
|
@@ -95,6 +96,7 @@ let LocalDeviceService = (() => {
|
|
|
95
96
|
this.deviceRepository = typedi_1.default.get(Device_repository_1.DeviceRepository);
|
|
96
97
|
this.alertService = typedi_1.default.get(Alert_service_1.AlertService);
|
|
97
98
|
this.issueService = typedi_1.default.get(Issue_service_1.IssueService);
|
|
99
|
+
this.localPropertyService = typedi_1.default.get(property_1.LocalPropertyService);
|
|
98
100
|
}
|
|
99
101
|
async createDevice(body) {
|
|
100
102
|
const device = await this.deviceRepository.createDevice(body);
|
|
@@ -355,6 +357,11 @@ let LocalDeviceService = (() => {
|
|
|
355
357
|
// Save the battery level in the device
|
|
356
358
|
await this.deviceRepository.setBatteryLevel(deviceId, batteryLevel);
|
|
357
359
|
await this.eventHandler.onBatteryLevelChange(deviceId, batteryLevel, auditBody);
|
|
360
|
+
if (oldBatteryLevel?.value < batteryLevel &&
|
|
361
|
+
batteryLevel - oldBatteryLevel?.value > 10) {
|
|
362
|
+
// Battery level has increased (considering as battery has been replaced)
|
|
363
|
+
await this.eventHandler.onBatteryReplaced(deviceId, batteryLevel, auditBody);
|
|
364
|
+
}
|
|
358
365
|
// Additional condition: if battery level is less than 50, update battery state to "replace"
|
|
359
366
|
if (batteryLevel < 50) {
|
|
360
367
|
const batteryState = {
|
|
@@ -402,11 +409,11 @@ let LocalDeviceService = (() => {
|
|
|
402
409
|
}
|
|
403
410
|
}
|
|
404
411
|
async getPropertyBatteryThreshold(propertyId) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
return
|
|
412
|
+
const preferences = await this.localPropertyService.getPropertyPreferences(propertyId, ["batteryPreference"]);
|
|
413
|
+
if (!preferences) {
|
|
414
|
+
return 20; // 20% default threshold
|
|
415
|
+
}
|
|
416
|
+
return preferences?.settings?.batteryPreference?.value ?? 20;
|
|
410
417
|
}
|
|
411
418
|
async checkForDeviceMalfunctions(device, source, reason) {
|
|
412
419
|
// TODO: Implement device malfunction detection logic
|
|
@@ -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");
|
|
@@ -10,5 +10,6 @@ export declare class EventHandler {
|
|
|
10
10
|
onStatusChangeMany(query: IStatusQuery, status: IStatus, auditProperties: IAuditProperties, eventType: any): Promise<void>;
|
|
11
11
|
onBatteryLevelChange(deviceId: string, batteryLevel: number, auditProperties: IAuditProperties): Promise<void>;
|
|
12
12
|
onBatteryStateChange(deviceId: string, batteryState: any, auditProperties: IAuditProperties): Promise<void>;
|
|
13
|
+
onBatteryReplaced(deviceId: string, batteryLevel: number, auditProperties: IAuditProperties): Promise<void>;
|
|
13
14
|
onDeviceMetaChange(deviceId: string, metaData: Record<string, any>, auditProperties: IAuditProperties): Promise<void>;
|
|
14
15
|
}
|
|
@@ -135,6 +135,16 @@ let EventHandler = (() => {
|
|
|
135
135
|
},
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
+
async onBatteryReplaced(deviceId, batteryLevel, auditProperties) {
|
|
139
|
+
await (0, audit_1.pushAudit)({
|
|
140
|
+
auditType: Event_1.DT_EVENT_TYPES.DEVICE.BATTERY.REPLACED,
|
|
141
|
+
auditData: {
|
|
142
|
+
deviceId,
|
|
143
|
+
batteryLevel,
|
|
144
|
+
...auditProperties,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
}
|
|
138
148
|
async onDeviceMetaChange(deviceId, metaData, auditProperties) {
|
|
139
149
|
await (0, audit_1.pushAudit)({
|
|
140
150
|
auditType: Event_1.DT_EVENT_TYPES.DEVICE.METADATA.UPDATED,
|
|
@@ -9,6 +9,7 @@ export declare enum InternalEventType {
|
|
|
9
9
|
export declare class InternalEventSubscription {
|
|
10
10
|
private readonly internalEventHandler;
|
|
11
11
|
private readonly sqsQueueUrl;
|
|
12
|
+
private readonly reservationSqsQueueUrl;
|
|
12
13
|
private readonly logger;
|
|
13
14
|
private readonly isInitialized;
|
|
14
15
|
private isSubscribed;
|
|
@@ -18,6 +18,7 @@ class InternalEventSubscription {
|
|
|
18
18
|
this.isInitialized = false;
|
|
19
19
|
this.isSubscribed = false;
|
|
20
20
|
this.sqsQueueUrl = (0, config_1.getSqsQueueUrl)() || "";
|
|
21
|
+
this.reservationSqsQueueUrl = (0, config_1.getReservationSqsQueueUrl)() || "";
|
|
21
22
|
this.logger = (0, config_1.getConfig)().LOGGER;
|
|
22
23
|
this.isInitialized = true;
|
|
23
24
|
}
|
|
@@ -85,6 +86,9 @@ class InternalEventSubscription {
|
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
88
|
try {
|
|
89
|
+
if (this.reservationSqsQueueUrl) {
|
|
90
|
+
await dt_pub_sub_1.eventDispatcher.subscribeToQueue(this.reservationSqsQueueUrl, this.handleMessage.bind(this));
|
|
91
|
+
}
|
|
88
92
|
await dt_pub_sub_1.eventDispatcher.subscribeToQueue(this.sqsQueueUrl, this.handleMessage.bind(this));
|
|
89
93
|
this.isSubscribed = true;
|
|
90
94
|
this.logger.info("Successfully subscribed to internal events", {
|
|
@@ -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;
|
|
@@ -2,6 +2,7 @@ import { IIssueDocument } from "./Issue.model";
|
|
|
2
2
|
import { CreateIssueData, UpdateIssueData, IssuePriority, IssuesCategory, IIssueQuery } from "./issue.types";
|
|
3
3
|
export declare class IssueRepository {
|
|
4
4
|
private buildQuery;
|
|
5
|
+
private buildOptions;
|
|
5
6
|
/**
|
|
6
7
|
* Create a new issue
|
|
7
8
|
*/
|
|
@@ -48,7 +48,7 @@ let IssueRepository = (() => {
|
|
|
48
48
|
let _classExtraInitializers = [];
|
|
49
49
|
let _classThis;
|
|
50
50
|
var IssueRepository = _classThis = class {
|
|
51
|
-
|
|
51
|
+
buildQuery(filters) {
|
|
52
52
|
const query = {};
|
|
53
53
|
if (filters.propertyId)
|
|
54
54
|
query.propertyId = filters.propertyId;
|
|
@@ -68,25 +68,35 @@ let IssueRepository = (() => {
|
|
|
68
68
|
query.entitySubType = filters.entitySubType;
|
|
69
69
|
if (filters.entityId)
|
|
70
70
|
query.entityId = filters.entityId;
|
|
71
|
-
if (filters.type)
|
|
72
|
-
|
|
71
|
+
if (filters.type) {
|
|
72
|
+
if (Array.isArray(filters.type)) {
|
|
73
|
+
query.type = { $in: filters.type };
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
query.type = filters.type;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
73
79
|
if (!filters.includeDeleted)
|
|
74
80
|
query.isDeleted = false;
|
|
75
81
|
// Date filtering
|
|
76
82
|
if (filters.startDate || filters.endDate) {
|
|
77
83
|
query.createdAt = {};
|
|
78
84
|
if (filters.startDate)
|
|
79
|
-
query.createdAt.$gte = filters.startDate;
|
|
85
|
+
query.createdAt.$gte = new Date(filters.startDate);
|
|
80
86
|
if (filters.endDate)
|
|
81
|
-
query.createdAt.$lte = filters.endDate;
|
|
87
|
+
query.createdAt.$lte = new Date(filters.endDate);
|
|
82
88
|
}
|
|
89
|
+
return query;
|
|
90
|
+
}
|
|
91
|
+
buildOptions(filters) {
|
|
92
|
+
const options = {};
|
|
83
93
|
if (filters.sort)
|
|
84
|
-
|
|
94
|
+
options.sort = filters.sort;
|
|
85
95
|
if (filters.limit)
|
|
86
|
-
|
|
96
|
+
options.limit = filters.limit;
|
|
87
97
|
if (filters.skip)
|
|
88
|
-
|
|
89
|
-
return
|
|
98
|
+
options.skip = filters.skip;
|
|
99
|
+
return options;
|
|
90
100
|
}
|
|
91
101
|
/**
|
|
92
102
|
* Create a new issue
|
|
@@ -126,19 +136,9 @@ let IssueRepository = (() => {
|
|
|
126
136
|
*/
|
|
127
137
|
async query(filters = {}) {
|
|
128
138
|
try {
|
|
129
|
-
const query =
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
queryBuilder.sort(filters.sort);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
queryBuilder.sort({ createdAt: -1 });
|
|
136
|
-
}
|
|
137
|
-
if (filters.skip)
|
|
138
|
-
queryBuilder.skip(filters.skip);
|
|
139
|
-
if (filters.limit)
|
|
140
|
-
queryBuilder.limit(filters.limit);
|
|
141
|
-
const results = await queryBuilder.exec();
|
|
139
|
+
const query = this.buildQuery(filters);
|
|
140
|
+
const options = this.buildOptions(filters);
|
|
141
|
+
const results = await Issue_model_1.IssueModel.find(query, null, options);
|
|
142
142
|
return results.map((result) => result.toObject());
|
|
143
143
|
}
|
|
144
144
|
catch (error) {
|
|
@@ -190,7 +190,7 @@ let IssueRepository = (() => {
|
|
|
190
190
|
*/
|
|
191
191
|
async count(filters = {}) {
|
|
192
192
|
try {
|
|
193
|
-
const query =
|
|
193
|
+
const query = this.buildQuery(filters);
|
|
194
194
|
return await Issue_model_1.IssueModel.countDocuments(query);
|
|
195
195
|
}
|
|
196
196
|
catch (error) {
|
|
@@ -124,14 +124,14 @@ export interface IIssueQuery {
|
|
|
124
124
|
assignedTo?: string;
|
|
125
125
|
status?: IssueStatus;
|
|
126
126
|
priority?: IssuePriority;
|
|
127
|
-
type?: IssueType;
|
|
127
|
+
type?: IssueType | IssueType[];
|
|
128
128
|
category?: IssuesCategory;
|
|
129
129
|
entityType?: EntityType;
|
|
130
130
|
entitySubType?: EntitySubType;
|
|
131
131
|
entityId?: string;
|
|
132
132
|
includeDeleted?: boolean;
|
|
133
|
-
startDate?:
|
|
134
|
-
endDate?:
|
|
133
|
+
startDate?: string;
|
|
134
|
+
endDate?: string;
|
|
135
135
|
limit?: number;
|
|
136
136
|
skip?: number;
|
|
137
137
|
sort?: {
|
package/package.json
CHANGED