dt-common-device 5.1.7 → 6.1.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 -6
- package/dist/alerts/Alert.model.js +1 -35
- package/dist/alerts/Alert.repository.d.ts +4 -46
- package/dist/alerts/Alert.repository.js +29 -102
- package/dist/alerts/Alert.service.d.ts +3 -35
- package/dist/alerts/Alert.service.js +39 -54
- package/dist/alerts/AlertBuilder.d.ts +10 -10
- package/dist/alerts/AlertBuilder.js +1 -0
- package/dist/alerts/alert.types.d.ts +15 -0
- package/dist/audit/AuditUtils.js +7 -10
- package/dist/config/config.js +5 -0
- package/dist/config/config.types.d.ts +1 -1
- package/dist/config/constants.d.ts +9 -0
- package/dist/config/constants.js +9 -0
- package/dist/constants/Event.d.ts +12 -0
- package/dist/constants/Event.js +12 -0
- package/dist/entities/admin/Admin.repository.d.ts +4 -0
- package/dist/entities/admin/Admin.repository.js +31 -0
- package/dist/entities/admin/Admin.service.d.ts +4 -0
- package/dist/entities/admin/Admin.service.js +124 -14
- package/dist/entities/admin/IAdmin.d.ts +39 -0
- package/dist/entities/admin/IAdmin.js +2 -0
- package/dist/entities/admin/index.d.ts +1 -0
- package/dist/entities/admin/index.js +1 -0
- package/dist/entities/device/local/interfaces/IDevice.d.ts +12 -0
- package/dist/entities/device/local/services/Device.service.d.ts +3 -4
- package/dist/entities/device/local/services/Device.service.js +59 -9
- package/dist/entities/pms/IPms.d.ts +26 -0
- package/dist/entities/pms/index.d.ts +1 -0
- package/dist/entities/pms/index.js +1 -0
- package/dist/entities/pms/pms.repository.d.ts +8 -0
- package/dist/entities/pms/pms.repository.js +98 -0
- package/dist/entities/pms/pms.service.d.ts +8 -0
- package/dist/entities/pms/pms.service.js +124 -0
- package/dist/events/BaseEventHandler.d.ts +2 -2
- package/dist/events/BaseEventHandler.js +21 -10
- package/dist/issues/Issue.model.d.ts +1 -5
- package/dist/issues/Issue.model.js +0 -28
- package/dist/issues/Issue.repository.d.ts +4 -42
- package/dist/issues/Issue.repository.js +29 -79
- package/dist/issues/Issue.service.d.ts +12 -40
- package/dist/issues/Issue.service.js +179 -145
- package/dist/issues/IssueBuilder.d.ts +11 -11
- package/dist/issues/IssueBuilder.js +10 -2
- package/dist/issues/IssueService.example.js +128 -15
- package/dist/issues/index.d.ts +1 -0
- package/dist/issues/index.js +1 -0
- package/dist/issues/issue.types.d.ts +17 -2
- package/package.json +1 -1
package/dist/config/config.js
CHANGED
|
@@ -60,6 +60,11 @@ async function initialize(cfg) {
|
|
|
60
60
|
db_keys = constants_1.CONFIG_KEYS.REMOTE.db_keys;
|
|
61
61
|
await validateServiceConfig(cfg);
|
|
62
62
|
}
|
|
63
|
+
if (cfg.SOURCE === "MIGRATION") {
|
|
64
|
+
sourceKey = "MIGRATION";
|
|
65
|
+
db_keys = constants_1.CONFIG_KEYS.MIGRATION.db_keys;
|
|
66
|
+
await validateServiceConfig(cfg);
|
|
67
|
+
}
|
|
63
68
|
// Connect to databases
|
|
64
69
|
try {
|
|
65
70
|
await (0, db_1.connectDatabase)();
|
|
@@ -4,7 +4,7 @@ export interface ILogger {
|
|
|
4
4
|
warn(message: string, ...args: any[]): void;
|
|
5
5
|
error(message: string, ...args: any[]): void;
|
|
6
6
|
}
|
|
7
|
-
type AllowedSource = "ACCESS_SERVICE" | "ADMIN_SERVICE" | "ENERGY_SERVICE" | "REMOTE_SERVICE" | "SCHEDULE_SERVICE";
|
|
7
|
+
type AllowedSource = "ACCESS_SERVICE" | "ADMIN_SERVICE" | "ENERGY_SERVICE" | "REMOTE_SERVICE" | "SCHEDULE_SERVICE" | "MIGRATION";
|
|
8
8
|
export type IConfig = {
|
|
9
9
|
SOURCE: AllowedSource;
|
|
10
10
|
INTERNAL_EVENT_HANDLER?: IInternalEvent;
|
package/dist/config/constants.js
CHANGED
|
@@ -61,4 +61,13 @@ exports.CONFIG_KEYS = {
|
|
|
61
61
|
access: "ACCESS_DB_URI",
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
|
+
MIGRATION: {
|
|
65
|
+
env: ["ADMIN_DB_URI", "ACCESS_DB_URI", "PMS_DB_URI"],
|
|
66
|
+
INTERNAL_EVENT_HANDLER: false,
|
|
67
|
+
db_keys: {
|
|
68
|
+
admin: "ADMIN_DB_URI",
|
|
69
|
+
access: "ACCESS_DB_URI",
|
|
70
|
+
pms: "PMS_DB_URI",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
64
73
|
};
|
|
@@ -15,6 +15,11 @@ export declare const DT_EVENT_TYPES: {
|
|
|
15
15
|
SUCCESS: string;
|
|
16
16
|
FAILED: string;
|
|
17
17
|
};
|
|
18
|
+
RESET: {
|
|
19
|
+
ATTEMPT: string;
|
|
20
|
+
SUCCESS: string;
|
|
21
|
+
FAILED: string;
|
|
22
|
+
};
|
|
18
23
|
ZONE: {
|
|
19
24
|
UPDATE: {
|
|
20
25
|
ATTEMPT: string;
|
|
@@ -67,6 +72,13 @@ export declare const DT_EVENT_TYPES: {
|
|
|
67
72
|
UNPROCESSED: string;
|
|
68
73
|
UNHANDLED: string;
|
|
69
74
|
};
|
|
75
|
+
ISSUE: {
|
|
76
|
+
CREATED: string;
|
|
77
|
+
CANCELLED: string;
|
|
78
|
+
RESOLVED: string;
|
|
79
|
+
UPDATED: string;
|
|
80
|
+
DELETED: string;
|
|
81
|
+
};
|
|
70
82
|
};
|
|
71
83
|
CONNECTION: {
|
|
72
84
|
CREATE: {
|
package/dist/constants/Event.js
CHANGED
|
@@ -18,6 +18,11 @@ exports.DT_EVENT_TYPES = {
|
|
|
18
18
|
SUCCESS: "device.delete.success",
|
|
19
19
|
FAILED: "device.delete.failed",
|
|
20
20
|
},
|
|
21
|
+
RESET: {
|
|
22
|
+
ATTEMPT: "device.reset.attempt",
|
|
23
|
+
SUCCESS: "device.reset.success",
|
|
24
|
+
FAILED: "device.reset.failed",
|
|
25
|
+
},
|
|
21
26
|
ZONE: {
|
|
22
27
|
UPDATE: {
|
|
23
28
|
ATTEMPT: "device.zone.update.attempt",
|
|
@@ -70,6 +75,13 @@ exports.DT_EVENT_TYPES = {
|
|
|
70
75
|
UNPROCESSED: "device.webhook.unprocessed",
|
|
71
76
|
UNHANDLED: "device.webhook.unhandled",
|
|
72
77
|
},
|
|
78
|
+
ISSUE: {
|
|
79
|
+
CREATED: "device.issue.created",
|
|
80
|
+
CANCELLED: "device.issue.cancelled",
|
|
81
|
+
RESOLVED: "device.issue.resolved",
|
|
82
|
+
UPDATED: "device.issue.updated",
|
|
83
|
+
DELETED: "device.issue.deleted",
|
|
84
|
+
},
|
|
73
85
|
},
|
|
74
86
|
CONNECTION: {
|
|
75
87
|
CREATE: {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { IAccessGroup, IUser, IZone } from "./IAdmin";
|
|
1
2
|
export declare class AdminRepository {
|
|
2
3
|
private readonly axiosInstance;
|
|
3
4
|
private readonly deviceRepository;
|
|
4
5
|
private readonly postgres;
|
|
5
6
|
constructor();
|
|
6
7
|
getZonesByAccessGroupIds(accessGroupIds: string[]): Promise<any[]>;
|
|
8
|
+
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
9
|
+
getZone(zoneId: string): Promise<IZone | null>;
|
|
10
|
+
getUser(userId: string): Promise<IUser | null>;
|
|
7
11
|
}
|
|
@@ -166,6 +166,37 @@ let AdminRepository = (() => {
|
|
|
166
166
|
const collectionZoneDevices = Array.from(new Set(_collectionZone));
|
|
167
167
|
return collectionZoneDevices;
|
|
168
168
|
}
|
|
169
|
+
async getAccessGroup(accessGroupId) {
|
|
170
|
+
const query = `
|
|
171
|
+
SELECT * FROM dt_collections
|
|
172
|
+
WHERE "id" = $1
|
|
173
|
+
`;
|
|
174
|
+
const result = await this.postgres.query(query, [accessGroupId]);
|
|
175
|
+
if (result.rows.length > 0) {
|
|
176
|
+
return result.rows[0];
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
async getZone(zoneId) {
|
|
181
|
+
try {
|
|
182
|
+
const zone = await this.postgres.query(`SELECT * FROM dt_zones WHERE "id" = $1`, [zoneId]);
|
|
183
|
+
if (zone.rows.length > 0) {
|
|
184
|
+
return zone.rows[0];
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
console.error("Error in getZone:", error);
|
|
190
|
+
throw new Error("Failed to get zone");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async getUser(userId) {
|
|
194
|
+
const user = await this.postgres.query(`SELECT * FROM dt_users WHERE "id" = $1`, [userId]);
|
|
195
|
+
if (user.rows.length > 0) {
|
|
196
|
+
return user.rows[0];
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
169
200
|
};
|
|
170
201
|
__setFunctionName(_classThis, "AdminRepository");
|
|
171
202
|
(() => {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { IAccessGroup, IUser, IZone } from "./IAdmin";
|
|
1
2
|
export declare class AdminService {
|
|
2
3
|
private readonly adminRepository;
|
|
3
4
|
constructor();
|
|
4
5
|
getZonesByAccessGroupIds(accessGroupIds: string[]): Promise<any[] | undefined>;
|
|
6
|
+
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
7
|
+
getZone(zoneId: string): Promise<IZone | null>;
|
|
8
|
+
getUser(userId: string): Promise<IUser | null>;
|
|
5
9
|
}
|
|
@@ -1,22 +1,132 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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 });
|
|
4
72
|
};
|
|
5
73
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
74
|
exports.AdminService = void 0;
|
|
7
|
-
const typedi_1 =
|
|
75
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
8
76
|
const Admin_repository_1 = require("./Admin.repository");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
77
|
+
let AdminService = (() => {
|
|
78
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
79
|
+
let _classDescriptor;
|
|
80
|
+
let _classExtraInitializers = [];
|
|
81
|
+
let _classThis;
|
|
82
|
+
var AdminService = _classThis = class {
|
|
83
|
+
constructor() {
|
|
84
|
+
this.adminRepository = typedi_1.default.get(Admin_repository_1.AdminRepository);
|
|
16
85
|
}
|
|
17
|
-
|
|
18
|
-
|
|
86
|
+
async getZonesByAccessGroupIds(accessGroupIds) {
|
|
87
|
+
try {
|
|
88
|
+
return await this.adminRepository.getZonesByAccessGroupIds(accessGroupIds);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.log(error);
|
|
92
|
+
}
|
|
19
93
|
}
|
|
20
|
-
|
|
21
|
-
|
|
94
|
+
async getAccessGroup(accessGroupId) {
|
|
95
|
+
if (!accessGroupId) {
|
|
96
|
+
throw new Error("Access Group ID is required");
|
|
97
|
+
}
|
|
98
|
+
const accessGroup = await this.adminRepository.getAccessGroup(accessGroupId);
|
|
99
|
+
if (!accessGroup)
|
|
100
|
+
return null;
|
|
101
|
+
return accessGroup;
|
|
102
|
+
}
|
|
103
|
+
async getZone(zoneId) {
|
|
104
|
+
if (!zoneId) {
|
|
105
|
+
throw new Error("Zone ID is required");
|
|
106
|
+
}
|
|
107
|
+
const zone = await this.adminRepository.getZone(zoneId);
|
|
108
|
+
if (!zone)
|
|
109
|
+
return null;
|
|
110
|
+
return zone;
|
|
111
|
+
}
|
|
112
|
+
async getUser(userId) {
|
|
113
|
+
if (!userId) {
|
|
114
|
+
throw new Error("User ID is required");
|
|
115
|
+
}
|
|
116
|
+
const user = await this.adminRepository.getUser(userId);
|
|
117
|
+
if (!user)
|
|
118
|
+
return null;
|
|
119
|
+
return user;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
__setFunctionName(_classThis, "AdminService");
|
|
123
|
+
(() => {
|
|
124
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
125
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
126
|
+
AdminService = _classThis = _classDescriptor.value;
|
|
127
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
128
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
129
|
+
})();
|
|
130
|
+
return AdminService = _classThis;
|
|
131
|
+
})();
|
|
22
132
|
exports.AdminService = AdminService;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface IAccessGroup {
|
|
2
|
+
id: string;
|
|
3
|
+
propertyId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
displayName: string;
|
|
6
|
+
type: string;
|
|
7
|
+
externalId?: string;
|
|
8
|
+
refId?: string;
|
|
9
|
+
isDeleted: boolean;
|
|
10
|
+
createdBy: string;
|
|
11
|
+
createdAt: Date;
|
|
12
|
+
updatedAt: Date;
|
|
13
|
+
accessibleBy: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface IZone {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
propertyId: string;
|
|
19
|
+
parentId?: string;
|
|
20
|
+
zoneTypeId: string;
|
|
21
|
+
deviceHiveNetworkId?: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
}
|
|
25
|
+
export interface IUser {
|
|
26
|
+
id: string;
|
|
27
|
+
emailId: string;
|
|
28
|
+
firstName: string;
|
|
29
|
+
lastName: string;
|
|
30
|
+
phoneNumber: string;
|
|
31
|
+
phoneNumberCountryCode: string;
|
|
32
|
+
password: string;
|
|
33
|
+
createdAt: Date;
|
|
34
|
+
updatedAt: Date;
|
|
35
|
+
isDeleted: boolean;
|
|
36
|
+
deletedBy?: string | null;
|
|
37
|
+
deletedAt?: Date | null;
|
|
38
|
+
imageURL?: string | null;
|
|
39
|
+
}
|
|
@@ -66,3 +66,15 @@ export interface IStatusUpdateRequest {
|
|
|
66
66
|
query: IStatusQuery;
|
|
67
67
|
status: IStatus;
|
|
68
68
|
}
|
|
69
|
+
export interface IQueryDevice {
|
|
70
|
+
isDeleted?: boolean;
|
|
71
|
+
zoneId?: string;
|
|
72
|
+
zoneIds?: string[];
|
|
73
|
+
deviceId?: string;
|
|
74
|
+
deviceIds?: string[];
|
|
75
|
+
propertyId?: string;
|
|
76
|
+
hubId?: string;
|
|
77
|
+
deviceType?: string;
|
|
78
|
+
excludeDeviceType?: string | string[];
|
|
79
|
+
connectionId?: string;
|
|
80
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDevice, IStatus, IStatusQuery } from "../interfaces";
|
|
1
|
+
import { IDevice, IQueryDevice, IStatus, IStatusQuery } from "../interfaces";
|
|
2
2
|
import { Source } from "../../../../constants/Service";
|
|
3
3
|
import { IAuditProperties } from "../../../../audit/IAuditProperties";
|
|
4
4
|
export declare class LocalDeviceService {
|
|
@@ -6,14 +6,13 @@ export declare class LocalDeviceService {
|
|
|
6
6
|
private readonly deviceRepository;
|
|
7
7
|
private readonly alertService;
|
|
8
8
|
private readonly issueService;
|
|
9
|
-
private readonly logger;
|
|
10
9
|
constructor();
|
|
11
10
|
createDevice(body: IDevice): Promise<IDevice>;
|
|
12
11
|
getDevice(deviceId: string, withHubDetails?: boolean): Promise<IDevice>;
|
|
13
12
|
getDevices(deviceIds: string[], withHubDetails?: boolean): Promise<IDevice[]>;
|
|
14
13
|
getPropertyDevices(propertyId: string, selectDeviceId?: boolean, type?: string, withHubDetails?: boolean): Promise<IDevice[]>;
|
|
15
14
|
getPropertyDeviceIds(propertyId: string, selectDeviceId: boolean | undefined, type: string): Promise<any>;
|
|
16
|
-
updateDevice(deviceId: string, body:
|
|
15
|
+
updateDevice(deviceId: string, body: Partial<IDevice>, auditBody: IAuditProperties): Promise<any>;
|
|
17
16
|
updateDevices(query: any, updateData: any): Promise<any>;
|
|
18
17
|
deleteDevice(deviceId: string, auditBody: IAuditProperties): Promise<any>;
|
|
19
18
|
getState(deviceId: string): Promise<any>;
|
|
@@ -36,5 +35,5 @@ export declare class LocalDeviceService {
|
|
|
36
35
|
querySelect(query: any, fields: string[]): Promise<any>;
|
|
37
36
|
queryCount(query: any): Promise<number>;
|
|
38
37
|
deleteDevices(query: any): Promise<any>;
|
|
39
|
-
queryDevices(query:
|
|
38
|
+
queryDevices(query: IQueryDevice): Promise<any>;
|
|
40
39
|
}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
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
|
+
});
|
|
2
18
|
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
19
|
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
20
|
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
@@ -33,26 +49,39 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
33
49
|
}
|
|
34
50
|
return useValue ? value : void 0;
|
|
35
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
|
+
})();
|
|
36
69
|
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
70
|
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
71
|
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
72
|
};
|
|
40
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
-
};
|
|
43
73
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
74
|
exports.LocalDeviceService = void 0;
|
|
45
75
|
const EventHandler_1 = require("../../../../events/EventHandler");
|
|
46
76
|
const lodash_1 = require("lodash");
|
|
47
77
|
const Device_repository_1 = require("../repository/Device.repository");
|
|
48
|
-
const typedi_1 = __importDefault(require("typedi"));
|
|
49
78
|
const Alert_service_1 = require("../../../../alerts/Alert.service");
|
|
50
79
|
const Issue_service_1 = require("../../../../issues/Issue.service");
|
|
51
|
-
const
|
|
52
|
-
const typedi_2 = require("typedi");
|
|
80
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
53
81
|
const constants_1 = require("../../../../constants");
|
|
82
|
+
const audit_1 = require("../../../../audit");
|
|
54
83
|
let LocalDeviceService = (() => {
|
|
55
|
-
let _classDecorators = [(0,
|
|
84
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
56
85
|
let _classDescriptor;
|
|
57
86
|
let _classExtraInitializers = [];
|
|
58
87
|
let _classThis;
|
|
@@ -63,7 +92,6 @@ let LocalDeviceService = (() => {
|
|
|
63
92
|
this.deviceRepository = typedi_1.default.get(Device_repository_1.DeviceRepository);
|
|
64
93
|
this.alertService = typedi_1.default.get(Alert_service_1.AlertService);
|
|
65
94
|
this.issueService = typedi_1.default.get(Issue_service_1.IssueService);
|
|
66
|
-
this.logger = (0, config_1.getConfig)().LOGGER;
|
|
67
95
|
}
|
|
68
96
|
async createDevice(body) {
|
|
69
97
|
const device = await this.deviceRepository.createDevice(body);
|
|
@@ -98,6 +126,29 @@ let LocalDeviceService = (() => {
|
|
|
98
126
|
if (!deviceId) {
|
|
99
127
|
throw new Error("Device ID is required");
|
|
100
128
|
}
|
|
129
|
+
const device = await this.getDevice(deviceId);
|
|
130
|
+
if (!device) {
|
|
131
|
+
throw new Error("Device not found");
|
|
132
|
+
}
|
|
133
|
+
if (body?.status) {
|
|
134
|
+
const auditType = body?.status?.online
|
|
135
|
+
? constants_1.DT_EVENT_TYPES.DEVICE.STATUS.ONLINE
|
|
136
|
+
: constants_1.DT_EVENT_TYPES.DEVICE.STATUS.OFFLINE;
|
|
137
|
+
(0, audit_1.pushAudit)({
|
|
138
|
+
auditType,
|
|
139
|
+
auditData: {
|
|
140
|
+
deviceId,
|
|
141
|
+
zoneId: device.zoneId,
|
|
142
|
+
deviceType: device.deviceType,
|
|
143
|
+
deviceName: device.name,
|
|
144
|
+
deviceStatus: device.status,
|
|
145
|
+
...auditBody,
|
|
146
|
+
oldStatus: device.status,
|
|
147
|
+
newStatus: body.status,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
//TODO: Also check if state is coming in the body and publish audit based on which state is changing to get the audit type
|
|
101
152
|
await this.deviceRepository.updateDevice(deviceId, body);
|
|
102
153
|
return await this.eventHandler.onDeviceUpdate(deviceId, body, auditBody);
|
|
103
154
|
}
|
|
@@ -253,7 +304,6 @@ let LocalDeviceService = (() => {
|
|
|
253
304
|
async getDeviceBaseline(deviceId) {
|
|
254
305
|
// TODO: Implement device baseline retrieval
|
|
255
306
|
// This should return the baseline time in milliseconds for the specific device
|
|
256
|
-
// For now, returning a default value of 5 minutes (300000ms)
|
|
257
307
|
// In a real implementation, this would fetch from device configuration or settings
|
|
258
308
|
return 3600000; // 1 hour in milliseconds
|
|
259
309
|
}
|
|
@@ -4,3 +4,29 @@ export declare enum PmsProvider {
|
|
|
4
4
|
HotelKey = "HotelKey",
|
|
5
5
|
Yanolja = "Yanolja"
|
|
6
6
|
}
|
|
7
|
+
export interface IPmsSchedule {
|
|
8
|
+
id: string;
|
|
9
|
+
propertyId: string;
|
|
10
|
+
referenceId: string;
|
|
11
|
+
startTime: string;
|
|
12
|
+
endTime: string;
|
|
13
|
+
source: string;
|
|
14
|
+
status: string;
|
|
15
|
+
isExpired: boolean;
|
|
16
|
+
isDeleted: boolean;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
createdBy: string;
|
|
20
|
+
}
|
|
21
|
+
export interface IGuest {
|
|
22
|
+
id: string;
|
|
23
|
+
firstName: string;
|
|
24
|
+
lastName: string;
|
|
25
|
+
email: string;
|
|
26
|
+
phoneNumber: string;
|
|
27
|
+
phoneNumberCountryCode: string;
|
|
28
|
+
guestRefId?: string;
|
|
29
|
+
countryCode: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IGuest, IPmsSchedule } from "./IPms";
|
|
2
|
+
export declare class PmsRepository {
|
|
3
|
+
private readonly pmsPostgres;
|
|
4
|
+
constructor();
|
|
5
|
+
getSchedule(scheduleId: string): Promise<IPmsSchedule | null>;
|
|
6
|
+
getGuest(guestId: string): Promise<IGuest | null>;
|
|
7
|
+
getGuestId(scheduleId: string): Promise<string | null>;
|
|
8
|
+
}
|