dt-common-device 7.0.0 → 7.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/Admin.repository.d.ts +7 -0
- package/dist/admin/Admin.repository.js +182 -0
- package/dist/admin/Admin.service.d.ts +5 -0
- package/dist/admin/Admin.service.js +17 -0
- package/dist/admin/index.d.ts +1 -0
- package/dist/admin/index.js +17 -0
- package/dist/alerts/Alert.model.d.ts +1 -1
- package/dist/audit/AuditProperties.d.ts +16 -0
- package/dist/audit/AuditProperties.js +2 -0
- package/dist/config/constants.js +1 -1
- package/dist/connection/Connection.repository.d.ts +8 -0
- package/dist/connection/Connection.repository.js +92 -0
- package/dist/connection/Connection.service.d.ts +8 -0
- package/dist/connection/Connection.service.js +32 -0
- package/dist/connection/IConnection.d.ts +28 -0
- package/dist/connection/IConnection.js +16 -0
- package/dist/connection/index.d.ts +2 -0
- package/dist/connection/index.js +18 -0
- package/dist/device/cloud/entities/CloudConnection.d.ts +6 -0
- package/dist/device/cloud/entities/CloudConnection.js +6 -0
- package/dist/device/cloud/entities/CloudDevice.d.ts +16 -0
- package/dist/device/cloud/entities/CloudDevice.js +26 -0
- package/dist/device/cloud/entities/CloudDeviceService.d.ts +5 -0
- package/dist/device/cloud/entities/CloudDeviceService.js +9 -0
- package/dist/device/cloud/entities/DeviceFactory.d.ts +7 -0
- package/dist/device/cloud/entities/DeviceFactory.js +80 -0
- package/dist/device/cloud/entities/index.d.ts +3 -0
- package/dist/device/cloud/entities/index.js +19 -0
- package/dist/device/cloud/interface.d.ts +101 -0
- package/dist/device/cloud/interface.js +3 -0
- package/dist/device/cloud/interfaces/ICloudConnection.d.ts +5 -0
- package/dist/device/cloud/interfaces/ICloudConnection.js +2 -0
- package/dist/device/cloud/interfaces/ICloudDevice.d.ts +9 -0
- package/dist/device/cloud/interfaces/ICloudDevice.js +2 -0
- package/dist/device/cloud/interfaces/ICloudDeviceService.d.ts +4 -0
- package/dist/device/cloud/interfaces/ICloudDeviceService.js +2 -0
- package/dist/device/cloud/interfaces/IConnectionService.d.ts +7 -0
- package/dist/device/cloud/interfaces/IConnectionService.js +2 -0
- package/dist/device/cloud/interfaces/IDeviceConnectionService.d.ts +7 -0
- package/dist/device/cloud/interfaces/IDeviceConnectionService.js +3 -0
- package/dist/device/cloud/interfaces/IDeviceFactory.d.ts +4 -0
- package/dist/device/cloud/interfaces/IDeviceFactory.js +2 -0
- package/dist/device/cloud/interfaces/IDeviceService.d.ts +8 -0
- package/dist/device/cloud/interfaces/IDeviceService.js +2 -0
- package/dist/device/cloud/interfaces/IDevicesService.d.ts +9 -0
- package/dist/device/cloud/interfaces/IDevicesService.js +2 -0
- package/dist/device/cloud/interfaces/IHubService.d.ts +5 -0
- package/dist/device/cloud/interfaces/IHubService.js +2 -0
- package/dist/device/cloud/interfaces/IRawDataTransformer.d.ts +4 -0
- package/dist/device/cloud/interfaces/IRawDataTransformer.js +2 -0
- package/dist/device/cloud/interfaces/IRawDevice.d.ts +17 -0
- package/dist/device/cloud/interfaces/IRawDevice.js +11 -0
- package/dist/device/cloud/interfaces/index.d.ts +5 -0
- package/dist/device/cloud/interfaces/index.js +21 -0
- package/dist/device/cloud/services/CloudDevice.service.d.ts +5 -0
- package/dist/device/cloud/services/CloudDevice.service.js +9 -0
- package/dist/device/cloud/services/Connection.service.d.ts +8 -0
- package/dist/device/cloud/services/Connection.service.js +6 -0
- package/dist/device/cloud/services/Device.service.d.ts +39 -0
- package/dist/device/cloud/services/Device.service.js +9 -0
- package/dist/device/cloud/services/DeviceCloudService.d.ts +42 -0
- package/dist/device/cloud/services/DeviceCloudService.js +59 -0
- package/dist/device/cloud/services/DeviceHub.service.d.ts +3 -0
- package/dist/device/cloud/services/DeviceHub.service.js +6 -0
- package/dist/device/cloud/services/Hub.service.d.ts +25 -0
- package/dist/device/cloud/services/Hub.service.js +9 -0
- package/dist/device/cloud/services/SmartThingsDeviceService.d.ts +38 -0
- package/dist/device/cloud/services/SmartThingsDeviceService.js +52 -0
- package/dist/device/cloud/services/index.d.ts +2 -0
- package/dist/device/cloud/services/index.js +18 -0
- package/dist/device/cloud/types.d.ts +52 -0
- package/dist/device/cloud/types.js +15 -0
- package/dist/device/index.d.ts +4 -0
- package/dist/device/index.js +20 -0
- package/dist/device/local/entities/AlertBuilder.d.ts +87 -0
- package/dist/device/local/entities/AlertBuilder.example.d.ts +11 -0
- package/dist/device/local/entities/AlertBuilder.example.js +117 -0
- package/dist/device/local/entities/AlertBuilder.js +179 -0
- package/dist/device/local/entities/IssueBuilder.d.ts +109 -0
- package/dist/device/local/entities/IssueBuilder.example.d.ts +16 -0
- package/dist/device/local/entities/IssueBuilder.example.js +196 -0
- package/dist/device/local/entities/IssueBuilder.js +237 -0
- package/dist/device/local/entities/index.d.ts +2 -0
- package/dist/device/local/entities/index.js +7 -0
- package/dist/device/local/events/EventHandler.d.ts +11 -0
- package/dist/device/local/events/EventHandler.js +86 -0
- package/dist/device/local/events/Events.d.ts +54 -0
- package/dist/device/local/events/Events.js +57 -0
- package/dist/device/local/events/index.d.ts +2 -0
- package/dist/device/local/events/index.js +7 -0
- package/dist/device/local/handler/EventHandler.d.ts +7 -0
- package/dist/device/local/handler/EventHandler.js +44 -0
- package/dist/device/local/interface.d.ts +0 -0
- package/dist/device/local/interface.js +1 -0
- package/dist/device/local/interfaces/IConnection.d.ts +26 -0
- package/dist/device/local/interfaces/IConnection.js +14 -0
- package/dist/device/local/interfaces/IDevice.d.ts +68 -0
- package/dist/device/local/interfaces/IDevice.js +10 -0
- package/dist/device/local/interfaces/IDtDevice.d.ts +16 -0
- package/dist/device/local/interfaces/IDtDevice.js +2 -0
- package/dist/device/local/interfaces/IHub.d.ts +46 -0
- package/dist/device/local/interfaces/IHub.js +2 -0
- package/dist/device/local/interfaces/IProperty.d.ts +29 -0
- package/dist/device/local/interfaces/IProperty.js +2 -0
- package/dist/device/local/interfaces/ISchedule.d.ts +25 -0
- package/dist/device/local/interfaces/ISchedule.js +2 -0
- package/dist/device/local/interfaces/index.d.ts +3 -0
- package/dist/device/local/interfaces/index.js +19 -0
- package/dist/device/local/models/Alert.model.d.ts +28 -0
- package/dist/device/local/models/Alert.model.js +222 -0
- package/dist/device/local/models/Issue.model.d.ts +28 -0
- package/dist/device/local/models/Issue.model.js +260 -0
- package/dist/device/local/repository/Alert.repository.d.ts +106 -0
- package/dist/device/local/repository/Alert.repository.js +374 -0
- package/dist/device/local/repository/Connection.repository.d.ts +8 -0
- package/dist/device/local/repository/Connection.repository.js +92 -0
- package/dist/device/local/repository/Device.repository.d.ts +30 -0
- package/dist/device/local/repository/Device.repository.js +325 -0
- package/dist/device/local/repository/Hub.repository.d.ts +13 -0
- package/dist/device/local/repository/Hub.repository.js +139 -0
- package/dist/device/local/repository/Issue.repository.d.ts +113 -0
- package/dist/device/local/repository/Issue.repository.js +401 -0
- package/dist/device/local/repository/Property.repository.d.ts +8 -0
- package/dist/device/local/repository/Property.repository.js +95 -0
- package/dist/device/local/repository/Schedule.repository.d.ts +9 -0
- package/dist/device/local/repository/Schedule.repository.js +109 -0
- package/dist/device/local/services/Alert.service.d.ts +137 -0
- package/dist/device/local/services/Alert.service.js +475 -0
- package/dist/device/local/services/AlertService.example.d.ts +55 -0
- package/dist/device/local/services/AlertService.example.js +148 -0
- package/dist/device/local/services/Connection.service.d.ts +8 -0
- package/dist/device/local/services/Connection.service.js +32 -0
- package/dist/device/local/services/Device.service.d.ts +40 -0
- package/dist/device/local/services/Device.service.js +391 -0
- package/dist/device/local/services/DeviceHub.service.d.ts +11 -0
- package/dist/device/local/services/DeviceHub.service.js +40 -0
- package/dist/device/local/services/Hub.service.d.ts +12 -0
- package/dist/device/local/services/Hub.service.js +107 -0
- package/dist/device/local/services/Issue.service.d.ts +168 -0
- package/dist/device/local/services/Issue.service.js +642 -0
- package/dist/device/local/services/IssueService.example.d.ts +68 -0
- package/dist/device/local/services/IssueService.example.js +177 -0
- package/dist/device/local/services/Property.service.d.ts +8 -0
- package/dist/device/local/services/Property.service.js +36 -0
- package/dist/device/local/services/Schedule.service.d.ts +9 -0
- package/dist/device/local/services/Schedule.service.js +26 -0
- package/dist/device/local/services/index.d.ts +3 -0
- package/dist/device/local/services/index.js +19 -0
- package/dist/entities/accessGroup/AccessGroup.repository.d.ts +1 -2
- package/dist/entities/accessGroup/AccessGroup.repository.js +1 -4
- package/dist/entities/accessGroup/AccessGroup.service.d.ts +1 -2
- package/dist/entities/accessGroup/AccessGroup.service.js +3 -4
- package/dist/entities/admin/Admin.repository.d.ts +2 -1
- package/dist/entities/admin/Admin.repository.js +11 -0
- package/dist/entities/admin/Admin.service.d.ts +1 -0
- package/dist/entities/admin/Admin.service.js +12 -0
- package/dist/entities/admin/IAdmin.d.ts +5 -0
- package/dist/entities/device/local/interfaces/ISchedule.d.ts +6 -5
- package/dist/entities/device/local/repository/Schedule.repository.d.ts +1 -0
- package/dist/entities/device/local/repository/Schedule.repository.js +12 -0
- package/dist/entities/device/local/services/Schedule.service.d.ts +1 -0
- package/dist/entities/device/local/services/Schedule.service.js +3 -0
- package/dist/entities/guest/Guest.repository.d.ts +1 -1
- package/dist/entities/guest/Guest.repository.js +2 -5
- package/dist/entities/guest/Guest.service.d.ts +1 -1
- package/dist/entities/guest/Guest.service.js +1 -4
- package/dist/entities/pms/pms.repository.d.ts +1 -0
- package/dist/entities/pms/pms.repository.js +8 -0
- package/dist/entities/pms/pms.service.d.ts +1 -0
- package/dist/entities/pms/pms.service.js +9 -0
- package/dist/entities/schedules/Schedule.repository.d.ts +1 -1
- package/dist/entities/schedules/Schedule.repository.js +2 -5
- package/dist/entities/schedules/Schedule.service.d.ts +1 -1
- package/dist/entities/schedules/Schedule.service.js +1 -4
- package/dist/entities/user/User.repository.js +1 -4
- package/dist/entities/user/User.service.d.ts +1 -1
- package/dist/entities/user/User.service.js +1 -4
- package/dist/entities/zone/Zone.service.js +1 -4
- package/dist/issues/Issue.model.d.ts +1 -1
- package/dist/pms/IPms.d.ts +6 -0
- package/dist/pms/IPms.js +10 -0
- package/dist/pms/index.d.ts +1 -0
- package/dist/pms/index.js +17 -0
- package/dist/property/IProperty.d.ts +29 -0
- package/dist/property/IProperty.js +2 -0
- package/dist/property/Property.repository.d.ts +8 -0
- package/dist/property/Property.repository.js +109 -0
- package/dist/property/Property.service.d.ts +8 -0
- package/dist/property/Property.service.js +124 -0
- package/dist/property/index.d.ts +2 -0
- package/dist/property/index.js +18 -0
- package/dist/queue/interfaces/IHttpRequestJob.d.ts +9 -0
- package/dist/queue/interfaces/IHttpRequestJob.js +2 -0
- package/dist/types/alert.types.d.ts +57 -0
- package/dist/types/alert.types.js +22 -0
- package/dist/types/config.types.d.ts +19 -0
- package/dist/types/config.types.js +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/issue.types.d.ts +90 -0
- package/dist/types/issue.types.js +40 -0
- package/dist/utils/http-utils.d.ts +13 -0
- package/dist/utils/http-utils.js +117 -0
- package/package.json +1 -1
|
@@ -92,6 +92,15 @@ let PmsService = (() => {
|
|
|
92
92
|
return null;
|
|
93
93
|
return schedule;
|
|
94
94
|
}
|
|
95
|
+
async getScheduleIdByAccessGroupId(accessGroupId, status) {
|
|
96
|
+
if (!accessGroupId) {
|
|
97
|
+
throw new Error("Access Group ID is required");
|
|
98
|
+
}
|
|
99
|
+
const scheduleId = await this.pmsRepository.getScheduleIdByAccessGroupId(accessGroupId, status);
|
|
100
|
+
if (!scheduleId)
|
|
101
|
+
return null;
|
|
102
|
+
return scheduleId;
|
|
103
|
+
}
|
|
95
104
|
async getGuest(guestId) {
|
|
96
105
|
if (!guestId) {
|
|
97
106
|
throw new Error("Guest ID is required");
|
|
@@ -52,11 +52,8 @@ let ScheduleRepository = (() => {
|
|
|
52
52
|
}
|
|
53
53
|
async getSchedule(scheduleId) {
|
|
54
54
|
try {
|
|
55
|
-
const schedule = await this.pmsPostgres.query(`SELECT * FROM
|
|
56
|
-
|
|
57
|
-
return schedule.rows[0];
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
55
|
+
const schedule = await this.pmsPostgres.query(`SELECT * FROM dt_schedules WHERE "id" = $1`, [scheduleId]);
|
|
56
|
+
return schedule.rows[0];
|
|
60
57
|
}
|
|
61
58
|
catch (error) {
|
|
62
59
|
console.error("Error in getSchedule:", error);
|
|
@@ -88,10 +88,7 @@ let ScheduleService = (() => {
|
|
|
88
88
|
if (!scheduleId) {
|
|
89
89
|
throw new Error("Schedule ID is required");
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
if (!schedule)
|
|
93
|
-
return null;
|
|
94
|
-
return schedule;
|
|
91
|
+
return await this.scheduleRepository.getSchedule(scheduleId);
|
|
95
92
|
}
|
|
96
93
|
};
|
|
97
94
|
__setFunctionName(_classThis, "ScheduleService");
|
|
@@ -52,10 +52,7 @@ let UserRepository = (() => {
|
|
|
52
52
|
}
|
|
53
53
|
async getUser(userId) {
|
|
54
54
|
const user = await this.postgres.query(`SELECT * FROM dt_users WHERE "id" = $1`, [userId]);
|
|
55
|
-
|
|
56
|
-
return user.rows[0];
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
55
|
+
return user.rows[0];
|
|
59
56
|
}
|
|
60
57
|
};
|
|
61
58
|
__setFunctionName(_classThis, "UserRepository");
|
|
@@ -87,10 +87,7 @@ let UserService = (() => {
|
|
|
87
87
|
if (!userId) {
|
|
88
88
|
throw new Error("User ID is required");
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
if (!user)
|
|
92
|
-
return null;
|
|
93
|
-
return user;
|
|
90
|
+
return await this.userRepository.getUser(userId);
|
|
94
91
|
}
|
|
95
92
|
};
|
|
96
93
|
__setFunctionName(_classThis, "UserService");
|
|
@@ -88,10 +88,7 @@ let ZoneService = (() => {
|
|
|
88
88
|
if (!zoneId) {
|
|
89
89
|
throw new Error("Zone ID is required");
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
if (!zone)
|
|
93
|
-
return null;
|
|
94
|
-
return zone;
|
|
91
|
+
return await this.zoneRepository.getZone(zoneId);
|
|
95
92
|
}
|
|
96
93
|
};
|
|
97
94
|
__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>, {}> & Omit<mongoose.FlatRecord<IIssueDocument> & Required<{
|
|
18
18
|
_id: string;
|
|
19
19
|
}> & {
|
|
20
20
|
__v: number;
|
package/dist/pms/IPms.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PmsProvider = void 0;
|
|
4
|
+
var PmsProvider;
|
|
5
|
+
(function (PmsProvider) {
|
|
6
|
+
PmsProvider["Cloudbeds"] = "Cloudbeds";
|
|
7
|
+
PmsProvider["StayNTouch"] = "StayNTouch";
|
|
8
|
+
PmsProvider["HotelKey"] = "HotelKey";
|
|
9
|
+
PmsProvider["Yanolja"] = "Yanolja";
|
|
10
|
+
})(PmsProvider || (exports.PmsProvider = PmsProvider = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./IPms";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./IPms"), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface IProperty {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
apartment: string;
|
|
5
|
+
city: string;
|
|
6
|
+
country: string;
|
|
7
|
+
state: string;
|
|
8
|
+
street: string;
|
|
9
|
+
zipCode: string;
|
|
10
|
+
createdBy?: string;
|
|
11
|
+
isDeleted: boolean;
|
|
12
|
+
imageURL: string;
|
|
13
|
+
timezone: string;
|
|
14
|
+
officialName?: string;
|
|
15
|
+
sameAsOfficialName?: boolean;
|
|
16
|
+
phoneNumber?: string;
|
|
17
|
+
phoneNumberCountryCode?: string;
|
|
18
|
+
propertyKey?: string;
|
|
19
|
+
hubNetworkId?: string;
|
|
20
|
+
isTimeZoneOverridden: boolean;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
propertyBillingId?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface IPropertySettings {
|
|
26
|
+
id: string;
|
|
27
|
+
propertyId: string;
|
|
28
|
+
settings: Record<string, any>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IProperty, IPropertySettings } from "./IProperty";
|
|
2
|
+
export declare class PropertyRepository {
|
|
3
|
+
private readonly postgres;
|
|
4
|
+
constructor();
|
|
5
|
+
getPropertyPreferences(propertyId: string, keys?: string[]): Promise<IPropertySettings | null>;
|
|
6
|
+
getProperty(propertyId: string): Promise<IProperty | null>;
|
|
7
|
+
getAllProperties(): Promise<any[]>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.PropertyRepository = void 0;
|
|
42
|
+
const db_1 = require("../db");
|
|
43
|
+
const typedi_1 = require("typedi");
|
|
44
|
+
let PropertyRepository = (() => {
|
|
45
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
46
|
+
let _classDescriptor;
|
|
47
|
+
let _classExtraInitializers = [];
|
|
48
|
+
let _classThis;
|
|
49
|
+
var PropertyRepository = _classThis = class {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.postgres = (0, db_1.getPostgresClient)();
|
|
52
|
+
}
|
|
53
|
+
async getPropertyPreferences(propertyId, keys) {
|
|
54
|
+
try {
|
|
55
|
+
const propertyPreferences = await this.postgres.query(`SELECT * FROM dt_property_settings WHERE "propertyId" = $1`, [propertyId]);
|
|
56
|
+
if (propertyPreferences.rows.length > 0) {
|
|
57
|
+
if (keys && keys.length > 0) {
|
|
58
|
+
const settings = propertyPreferences.rows[0].settings;
|
|
59
|
+
const filteredSettings = {};
|
|
60
|
+
// Only include the requested keys from settings
|
|
61
|
+
keys.forEach((key) => {
|
|
62
|
+
if (settings && settings[key] !== undefined) {
|
|
63
|
+
filteredSettings[key] = settings[key];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
...propertyPreferences.rows[0],
|
|
68
|
+
settings: filteredSettings,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return propertyPreferences.rows[0];
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error("Error in getPropertyPreferences:", error);
|
|
77
|
+
throw new Error("Failed to get property preferences");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async getProperty(propertyId) {
|
|
81
|
+
const property = await this.postgres.query("SELECT * FROM dt_properties WHERE id = $1", [propertyId]);
|
|
82
|
+
if (property.rows.length > 0) {
|
|
83
|
+
return property.rows[0];
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
async getAllProperties() {
|
|
88
|
+
try {
|
|
89
|
+
//Retrieve all the properties ids from the database
|
|
90
|
+
const properties = await this.postgres.query("SELECT id FROM dt_properties");
|
|
91
|
+
return properties.rows.map((property) => property.id);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
console.log(error);
|
|
95
|
+
throw new Error("Failed to get all properties");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
__setFunctionName(_classThis, "PropertyRepository");
|
|
100
|
+
(() => {
|
|
101
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
102
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
103
|
+
PropertyRepository = _classThis = _classDescriptor.value;
|
|
104
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
105
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
106
|
+
})();
|
|
107
|
+
return PropertyRepository = _classThis;
|
|
108
|
+
})();
|
|
109
|
+
exports.PropertyRepository = PropertyRepository;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class LocalPropertyService {
|
|
2
|
+
private readonly propertyRepository;
|
|
3
|
+
constructor();
|
|
4
|
+
getPropertyPreferences(propertyId: string, keys?: string[]): Promise<import("./IProperty").IPropertySettings | null>;
|
|
5
|
+
getProperty(propertyId: string): Promise<import("./IProperty").IProperty | null>;
|
|
6
|
+
getPropertyTimeZone(propertyId: string): Promise<string>;
|
|
7
|
+
getAllProperties(): Promise<any[]>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
19
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
20
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
21
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
22
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
23
|
+
var _, done = false;
|
|
24
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
25
|
+
var context = {};
|
|
26
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
27
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
28
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
29
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
30
|
+
if (kind === "accessor") {
|
|
31
|
+
if (result === void 0) continue;
|
|
32
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
33
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
34
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
35
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
36
|
+
}
|
|
37
|
+
else if (_ = accept(result)) {
|
|
38
|
+
if (kind === "field") initializers.unshift(_);
|
|
39
|
+
else descriptor[key] = _;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
43
|
+
done = true;
|
|
44
|
+
};
|
|
45
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
46
|
+
var useValue = arguments.length > 2;
|
|
47
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
48
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
49
|
+
}
|
|
50
|
+
return useValue ? value : void 0;
|
|
51
|
+
};
|
|
52
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
53
|
+
var ownKeys = function(o) {
|
|
54
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
55
|
+
var ar = [];
|
|
56
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
57
|
+
return ar;
|
|
58
|
+
};
|
|
59
|
+
return ownKeys(o);
|
|
60
|
+
};
|
|
61
|
+
return function (mod) {
|
|
62
|
+
if (mod && mod.__esModule) return mod;
|
|
63
|
+
var result = {};
|
|
64
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
65
|
+
__setModuleDefault(result, mod);
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
})();
|
|
69
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
70
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
71
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
72
|
+
};
|
|
73
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
+
exports.LocalPropertyService = void 0;
|
|
75
|
+
const Property_repository_1 = require("./Property.repository");
|
|
76
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
77
|
+
let LocalPropertyService = (() => {
|
|
78
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
79
|
+
let _classDescriptor;
|
|
80
|
+
let _classExtraInitializers = [];
|
|
81
|
+
let _classThis;
|
|
82
|
+
var LocalPropertyService = _classThis = class {
|
|
83
|
+
constructor() {
|
|
84
|
+
// Use dependency injection instead of creating new instance
|
|
85
|
+
this.propertyRepository = typedi_1.default.get(Property_repository_1.PropertyRepository);
|
|
86
|
+
}
|
|
87
|
+
async getPropertyPreferences(propertyId, keys) {
|
|
88
|
+
if (!propertyId) {
|
|
89
|
+
throw new Error("Property ID is required");
|
|
90
|
+
}
|
|
91
|
+
return await this.propertyRepository.getPropertyPreferences(propertyId, keys);
|
|
92
|
+
}
|
|
93
|
+
async getProperty(propertyId) {
|
|
94
|
+
if (!propertyId) {
|
|
95
|
+
throw new Error("Property ID is required");
|
|
96
|
+
}
|
|
97
|
+
return await this.propertyRepository.getProperty(propertyId);
|
|
98
|
+
}
|
|
99
|
+
async getPropertyTimeZone(propertyId) {
|
|
100
|
+
if (!propertyId) {
|
|
101
|
+
throw new Error("Property ID is required");
|
|
102
|
+
}
|
|
103
|
+
const property = await this.propertyRepository.getProperty(propertyId);
|
|
104
|
+
if (!property) {
|
|
105
|
+
throw new Error("Property not found");
|
|
106
|
+
}
|
|
107
|
+
return property.timezone;
|
|
108
|
+
}
|
|
109
|
+
async getAllProperties() {
|
|
110
|
+
const properties = await this.propertyRepository.getAllProperties();
|
|
111
|
+
return properties;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
__setFunctionName(_classThis, "LocalPropertyService");
|
|
115
|
+
(() => {
|
|
116
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
117
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
118
|
+
LocalPropertyService = _classThis = _classDescriptor.value;
|
|
119
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
120
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
121
|
+
})();
|
|
122
|
+
return LocalPropertyService = _classThis;
|
|
123
|
+
})();
|
|
124
|
+
exports.LocalPropertyService = LocalPropertyService;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./IProperty"), exports);
|
|
18
|
+
__exportStar(require("./Property.service"), exports);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { EntityType } from "./issue.types";
|
|
2
|
+
export declare enum AlertCategory {
|
|
3
|
+
READINESS = "READINESS",
|
|
4
|
+
OPERATIONS = "OPERATIONS",
|
|
5
|
+
SECURITY = "SECURITY",
|
|
6
|
+
ENERGY = "ENERGY",
|
|
7
|
+
OTHER = "OTHER"
|
|
8
|
+
}
|
|
9
|
+
export declare enum AlertSeverity {
|
|
10
|
+
INFO = "INFO",
|
|
11
|
+
LOW = "LOW",
|
|
12
|
+
MEDIUM = "MEDIUM",
|
|
13
|
+
HIGH = "HIGH",
|
|
14
|
+
CRITICAL = "CRITICAL"
|
|
15
|
+
}
|
|
16
|
+
export interface AlertDocument {
|
|
17
|
+
_id: string;
|
|
18
|
+
category: AlertCategory;
|
|
19
|
+
propertyId: string;
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
entityId?: string;
|
|
23
|
+
entityType: EntityType;
|
|
24
|
+
severity: AlertSeverity;
|
|
25
|
+
isRead: boolean;
|
|
26
|
+
isActive: boolean;
|
|
27
|
+
isDeleted: boolean;
|
|
28
|
+
snoozeUntil?: Date;
|
|
29
|
+
createdBy?: string;
|
|
30
|
+
updatedBy?: string;
|
|
31
|
+
createdAt: Date;
|
|
32
|
+
updatedAt: Date;
|
|
33
|
+
}
|
|
34
|
+
export interface CreateAlertData {
|
|
35
|
+
category: AlertCategory;
|
|
36
|
+
propertyId: string;
|
|
37
|
+
title: string;
|
|
38
|
+
description: string;
|
|
39
|
+
entityId?: string;
|
|
40
|
+
entityType: EntityType;
|
|
41
|
+
severity?: AlertSeverity;
|
|
42
|
+
createdBy?: string;
|
|
43
|
+
snoozeUntil?: Date;
|
|
44
|
+
}
|
|
45
|
+
export interface UpdateAlertData {
|
|
46
|
+
category?: AlertCategory;
|
|
47
|
+
title?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
entityId?: string;
|
|
50
|
+
entityType?: EntityType;
|
|
51
|
+
severity?: AlertSeverity;
|
|
52
|
+
isRead?: boolean;
|
|
53
|
+
isActive?: boolean;
|
|
54
|
+
snoozeUntil?: Date;
|
|
55
|
+
updatedBy?: string;
|
|
56
|
+
}
|
|
57
|
+
export { EntityType } from "./issue.types";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EntityType = exports.AlertSeverity = exports.AlertCategory = void 0;
|
|
4
|
+
var AlertCategory;
|
|
5
|
+
(function (AlertCategory) {
|
|
6
|
+
AlertCategory["READINESS"] = "READINESS";
|
|
7
|
+
AlertCategory["OPERATIONS"] = "OPERATIONS";
|
|
8
|
+
AlertCategory["SECURITY"] = "SECURITY";
|
|
9
|
+
AlertCategory["ENERGY"] = "ENERGY";
|
|
10
|
+
AlertCategory["OTHER"] = "OTHER";
|
|
11
|
+
})(AlertCategory || (exports.AlertCategory = AlertCategory = {}));
|
|
12
|
+
var AlertSeverity;
|
|
13
|
+
(function (AlertSeverity) {
|
|
14
|
+
AlertSeverity["INFO"] = "INFO";
|
|
15
|
+
AlertSeverity["LOW"] = "LOW";
|
|
16
|
+
AlertSeverity["MEDIUM"] = "MEDIUM";
|
|
17
|
+
AlertSeverity["HIGH"] = "HIGH";
|
|
18
|
+
AlertSeverity["CRITICAL"] = "CRITICAL";
|
|
19
|
+
})(AlertSeverity || (exports.AlertSeverity = AlertSeverity = {}));
|
|
20
|
+
// Re-export EntityType from issue.types.ts to avoid duplication
|
|
21
|
+
var issue_types_1 = require("./issue.types");
|
|
22
|
+
Object.defineProperty(exports, "EntityType", { enumerable: true, get: function () { return issue_types_1.EntityType; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IInternalEvent } from "../events/interfaces/IInternalEvent";
|
|
2
|
+
export interface ILogger {
|
|
3
|
+
info(message: string, ...args: any[]): void;
|
|
4
|
+
warn(message: string, ...args: any[]): void;
|
|
5
|
+
error(message: string, ...args: any[]): void;
|
|
6
|
+
}
|
|
7
|
+
type AllowedSource = "ACCESS_SERVICE" | "ADMIN_SERVICE" | "ENERGY_SERVICE";
|
|
8
|
+
export type DeviceConfig = {
|
|
9
|
+
SOURCE: AllowedSource;
|
|
10
|
+
SQS_QUEUE_URL: string;
|
|
11
|
+
DEVICE_SERVICE?: string;
|
|
12
|
+
ADMIN_SERVICE?: string;
|
|
13
|
+
ACCESS_SERVICE?: string;
|
|
14
|
+
ENERGY_SERVICE?: string;
|
|
15
|
+
INTERNAL_EVENT_HANDLER: IInternalEvent;
|
|
16
|
+
LOGGER: ILogger;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./config.types"), exports);
|
|
18
|
+
__exportStar(require("./issue.types"), exports);
|
|
19
|
+
__exportStar(require("./alert.types"), exports);
|