dt-common-device 4.0.8 → 4.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit/IAuditProperties.d.ts +32 -0
- package/dist/audit/IAuditProperties.js +13 -0
- package/dist/audit/PushAudit.d.ts +5 -0
- package/dist/audit/PushAudit.js +16 -0
- package/dist/audit/index.d.ts +2 -0
- package/dist/audit/index.js +18 -0
- package/dist/config/constants.d.ts +49 -0
- package/dist/config/constants.js +64 -0
- package/dist/entities/accessGroup/AccessGroup.repository.d.ts +5 -0
- package/dist/entities/accessGroup/AccessGroup.repository.js +72 -0
- package/dist/entities/accessGroup/AccessGroup.service.d.ts +5 -0
- package/dist/entities/accessGroup/AccessGroup.service.js +105 -0
- package/dist/entities/accessGroup/IAccessGroup.d.ts +14 -0
- package/dist/entities/accessGroup/IAccessGroup.js +2 -0
- package/dist/entities/accessGroup/index.d.ts +2 -0
- package/dist/entities/accessGroup/index.js +18 -0
- package/dist/entities/admin/Admin.repository.d.ts +7 -0
- package/dist/entities/admin/Admin.repository.js +182 -0
- package/dist/entities/admin/Admin.service.d.ts +5 -0
- package/dist/entities/admin/Admin.service.js +17 -0
- package/dist/entities/admin/index.d.ts +1 -0
- package/dist/entities/admin/index.js +17 -0
- package/dist/entities/connection/Connection.repository.d.ts +8 -0
- package/dist/entities/connection/Connection.repository.js +92 -0
- package/dist/entities/connection/Connection.service.d.ts +8 -0
- package/dist/entities/connection/Connection.service.js +32 -0
- package/dist/entities/connection/IConnection.d.ts +28 -0
- package/dist/entities/connection/IConnection.js +16 -0
- package/dist/entities/connection/index.d.ts +2 -0
- package/dist/entities/connection/index.js +18 -0
- package/dist/entities/device/cloud/entities/CloudDevice.d.ts +16 -0
- package/dist/entities/device/cloud/entities/CloudDevice.js +26 -0
- package/dist/entities/device/cloud/entities/CloudDeviceService.d.ts +5 -0
- package/dist/entities/device/cloud/entities/CloudDeviceService.js +9 -0
- package/dist/entities/device/cloud/entities/DeviceFactory.d.ts +7 -0
- package/dist/entities/device/cloud/entities/DeviceFactory.js +80 -0
- package/dist/entities/device/cloud/entities/index.d.ts +3 -0
- package/dist/entities/device/cloud/entities/index.js +19 -0
- package/dist/entities/device/cloud/interfaces/ICloudDevice.d.ts +9 -0
- package/dist/entities/device/cloud/interfaces/ICloudDevice.js +2 -0
- package/dist/entities/device/cloud/interfaces/ICloudDeviceService.d.ts +4 -0
- package/dist/entities/device/cloud/interfaces/ICloudDeviceService.js +2 -0
- package/dist/entities/device/cloud/interfaces/IDeviceFactory.d.ts +4 -0
- package/dist/entities/device/cloud/interfaces/IDeviceFactory.js +2 -0
- package/dist/entities/device/cloud/interfaces/IRawDataTransformer.d.ts +4 -0
- package/dist/entities/device/cloud/interfaces/IRawDataTransformer.js +2 -0
- package/dist/entities/device/cloud/interfaces/IRawDevice.d.ts +17 -0
- package/dist/entities/device/cloud/interfaces/IRawDevice.js +11 -0
- package/dist/entities/device/cloud/interfaces/index.d.ts +5 -0
- package/dist/entities/device/cloud/interfaces/index.js +21 -0
- package/dist/entities/device/local/interfaces/IDevice.d.ts +68 -0
- package/dist/entities/device/local/interfaces/IDevice.js +10 -0
- package/dist/entities/device/local/interfaces/IDtDevice.d.ts +16 -0
- package/dist/entities/device/local/interfaces/IDtDevice.js +2 -0
- package/dist/entities/device/local/interfaces/ISchedule.d.ts +25 -0
- package/dist/entities/device/local/interfaces/ISchedule.js +2 -0
- package/dist/entities/device/local/interfaces/index.d.ts +3 -0
- package/dist/entities/device/local/interfaces/index.js +19 -0
- package/dist/entities/device/local/repository/Device.repository.d.ts +30 -0
- package/dist/entities/device/local/repository/Device.repository.js +325 -0
- package/dist/entities/device/local/repository/Hub.repository.d.ts +13 -0
- package/dist/entities/device/local/repository/Hub.repository.js +139 -0
- package/dist/entities/device/local/repository/Schedule.repository.d.ts +9 -0
- package/dist/entities/device/local/repository/Schedule.repository.js +109 -0
- package/dist/entities/device/local/services/Device.service.d.ts +40 -0
- package/dist/entities/device/local/services/Device.service.js +391 -0
- package/dist/entities/device/local/services/Hub.service.d.ts +12 -0
- package/dist/entities/device/local/services/Hub.service.js +107 -0
- package/dist/entities/device/local/services/Schedule.service.d.ts +9 -0
- package/dist/entities/device/local/services/Schedule.service.js +26 -0
- package/dist/entities/device/local/services/index.d.ts +3 -0
- package/dist/entities/device/local/services/index.js +19 -0
- package/dist/entities/guest/Guest.repository.d.ts +6 -0
- package/dist/entities/guest/Guest.repository.js +74 -0
- package/dist/entities/guest/Guest.service.d.ts +6 -0
- package/dist/entities/guest/Guest.service.js +104 -0
- package/dist/entities/guest/IGuest.d.ts +12 -0
- package/dist/entities/guest/IGuest.js +2 -0
- package/dist/entities/guest/index.d.ts +2 -0
- package/dist/entities/guest/index.js +18 -0
- package/dist/entities/pms/IPms.d.ts +6 -0
- package/dist/entities/pms/IPms.js +10 -0
- package/dist/entities/pms/index.d.ts +1 -0
- package/dist/entities/pms/index.js +17 -0
- package/dist/entities/property/IProperty.d.ts +29 -0
- package/dist/entities/property/IProperty.js +2 -0
- package/dist/entities/property/Property.repository.d.ts +8 -0
- package/dist/entities/property/Property.repository.js +109 -0
- package/dist/entities/property/Property.service.d.ts +8 -0
- package/dist/entities/property/Property.service.js +124 -0
- package/dist/entities/property/index.d.ts +2 -0
- package/dist/entities/property/index.js +18 -0
- package/dist/entities/schedules/ISchedule.d.ts +14 -0
- package/dist/entities/schedules/ISchedule.js +2 -0
- package/dist/entities/schedules/Schedule.repository.d.ts +6 -0
- package/dist/entities/schedules/Schedule.repository.js +74 -0
- package/dist/entities/schedules/Schedule.service.d.ts +6 -0
- package/dist/entities/schedules/Schedule.service.js +104 -0
- package/dist/entities/schedules/index.d.ts +2 -0
- package/dist/entities/schedules/index.js +18 -0
- package/dist/entities/user/IUser.d.ts +15 -0
- package/dist/entities/user/IUser.js +2 -0
- package/dist/entities/user/User.repository.d.ts +5 -0
- package/dist/entities/user/User.repository.js +68 -0
- package/dist/entities/user/User.service.d.ts +6 -0
- package/dist/entities/user/User.service.js +103 -0
- package/dist/entities/zone/IZone.d.ts +10 -0
- package/dist/entities/zone/IZone.js +2 -0
- package/dist/entities/zone/Zone.repository.d.ts +6 -0
- package/dist/entities/zone/Zone.repository.js +77 -0
- package/dist/entities/zone/Zone.service.d.ts +6 -0
- package/dist/entities/zone/Zone.service.js +104 -0
- package/dist/entities/zone/index.d.ts +2 -0
- package/dist/entities/zone/index.js +18 -0
- package/dist/queue/utils/rateLimit.utils.js +1 -1
- package/package.json +1 -1
|
@@ -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("./Admin.service"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IConnection } from "./IConnection";
|
|
2
|
+
export declare class ConnectionRepository {
|
|
3
|
+
private readonly pool;
|
|
4
|
+
constructor();
|
|
5
|
+
createConnection(data: Partial<IConnection>): Promise<IConnection>;
|
|
6
|
+
getConnectionById(connectionId: string): Promise<IConnection>;
|
|
7
|
+
updateConnection(connectionId: string, data: Partial<IConnection>): Promise<any>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
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.ConnectionRepository = void 0;
|
|
42
|
+
const db_1 = require("../../db");
|
|
43
|
+
const typedi_1 = require("typedi");
|
|
44
|
+
let ConnectionRepository = (() => {
|
|
45
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
46
|
+
let _classDescriptor;
|
|
47
|
+
let _classExtraInitializers = [];
|
|
48
|
+
let _classThis;
|
|
49
|
+
var ConnectionRepository = _classThis = class {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.pool = (0, db_1.getPostgresClient)();
|
|
52
|
+
}
|
|
53
|
+
async createConnection(data) {
|
|
54
|
+
const result = await this.pool.query('INSERT INTO dt_connections ("connectionName", "connectionRefId", "propertyId", "connectionProvider", "accessToken", "refreshToken", "clientId", "clientSecret", "isActive", "metaData") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *', [
|
|
55
|
+
data.connectionName,
|
|
56
|
+
data.connectionRefId,
|
|
57
|
+
data.propertyId,
|
|
58
|
+
data.connectionProvider,
|
|
59
|
+
data.accessToken,
|
|
60
|
+
data.refreshToken,
|
|
61
|
+
data.clientId,
|
|
62
|
+
data.clientSecret,
|
|
63
|
+
data.isActive,
|
|
64
|
+
data.metaData,
|
|
65
|
+
]);
|
|
66
|
+
return result.rows[0];
|
|
67
|
+
}
|
|
68
|
+
async getConnectionById(connectionId) {
|
|
69
|
+
const result = await this.pool.query("SELECT * FROM dt_connections WHERE id = $1", [connectionId]);
|
|
70
|
+
return result.rows[0];
|
|
71
|
+
}
|
|
72
|
+
async updateConnection(connectionId, data) {
|
|
73
|
+
// Build dynamic SET clause with quoted column names
|
|
74
|
+
const setClause = Object.keys(data)
|
|
75
|
+
.map((key, index) => `"${key}" = $${index + 2}`)
|
|
76
|
+
.join(", ");
|
|
77
|
+
const values = Object.values(data);
|
|
78
|
+
const result = await this.pool.query(`UPDATE dt_connections SET ${setClause}, "updatedAt" = NOW() WHERE id = $1 RETURNING *`, [connectionId, ...values]);
|
|
79
|
+
return result.rows[0];
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
__setFunctionName(_classThis, "ConnectionRepository");
|
|
83
|
+
(() => {
|
|
84
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
85
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
86
|
+
ConnectionRepository = _classThis = _classDescriptor.value;
|
|
87
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
88
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
89
|
+
})();
|
|
90
|
+
return ConnectionRepository = _classThis;
|
|
91
|
+
})();
|
|
92
|
+
exports.ConnectionRepository = ConnectionRepository;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IConnection } from "./IConnection";
|
|
2
|
+
export declare class LocalConnectionService {
|
|
3
|
+
private readonly connectionRepository;
|
|
4
|
+
constructor();
|
|
5
|
+
createConnection(data: Partial<IConnection>): Promise<IConnection>;
|
|
6
|
+
getConnection(connectionId: string): Promise<IConnection>;
|
|
7
|
+
updateConnection(connectionId: string, data: Partial<IConnection>): Promise<IConnection>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalConnectionService = void 0;
|
|
4
|
+
const typedi_1 = require("typedi");
|
|
5
|
+
const Connection_repository_1 = require("./Connection.repository");
|
|
6
|
+
class LocalConnectionService {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.connectionRepository = typedi_1.Container.get(Connection_repository_1.ConnectionRepository);
|
|
9
|
+
}
|
|
10
|
+
async createConnection(data) {
|
|
11
|
+
if (!data.connectionName ||
|
|
12
|
+
!data.connectionRefId ||
|
|
13
|
+
!data.propertyId ||
|
|
14
|
+
!data.connectionProvider) {
|
|
15
|
+
throw new Error("Missing required fields");
|
|
16
|
+
}
|
|
17
|
+
return await this.connectionRepository.createConnection(data);
|
|
18
|
+
}
|
|
19
|
+
async getConnection(connectionId) {
|
|
20
|
+
if (!connectionId) {
|
|
21
|
+
throw new Error("Connection ID is required");
|
|
22
|
+
}
|
|
23
|
+
return await this.connectionRepository.getConnectionById(connectionId);
|
|
24
|
+
}
|
|
25
|
+
async updateConnection(connectionId, data) {
|
|
26
|
+
if (!connectionId) {
|
|
27
|
+
throw new Error("Connection ID is required");
|
|
28
|
+
}
|
|
29
|
+
return await this.connectionRepository.updateConnection(connectionId, data);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.LocalConnectionService = LocalConnectionService;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface IConnection {
|
|
2
|
+
id?: string;
|
|
3
|
+
createdAt?: Date;
|
|
4
|
+
updatedAt?: Date;
|
|
5
|
+
isDeleted?: boolean;
|
|
6
|
+
connectionName: string;
|
|
7
|
+
connectionRefId: string;
|
|
8
|
+
propertyId: string;
|
|
9
|
+
connectionProvider: ConnectionProvider;
|
|
10
|
+
accessToken?: string;
|
|
11
|
+
refreshToken?: string;
|
|
12
|
+
clientId?: string;
|
|
13
|
+
clientSecret: string;
|
|
14
|
+
isActive?: boolean;
|
|
15
|
+
metaData?: any;
|
|
16
|
+
}
|
|
17
|
+
export declare enum ConnectionProvider {
|
|
18
|
+
Smartthings = "Smartthings",
|
|
19
|
+
SaltoKS = "SaltoKS",
|
|
20
|
+
TTLock = "TTLock",
|
|
21
|
+
Tuya = "Tuya",
|
|
22
|
+
Schlage = "Schlage",
|
|
23
|
+
YaleWifi = "YaleWifi",
|
|
24
|
+
Sensibo = "Sensibo",
|
|
25
|
+
Devicethread = "Devicethread",
|
|
26
|
+
Dormakaba = "Dormakaba",
|
|
27
|
+
Dusaw = "Dusaw"
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectionProvider = void 0;
|
|
4
|
+
var ConnectionProvider;
|
|
5
|
+
(function (ConnectionProvider) {
|
|
6
|
+
ConnectionProvider["Smartthings"] = "Smartthings";
|
|
7
|
+
ConnectionProvider["SaltoKS"] = "SaltoKS";
|
|
8
|
+
ConnectionProvider["TTLock"] = "TTLock";
|
|
9
|
+
ConnectionProvider["Tuya"] = "Tuya";
|
|
10
|
+
ConnectionProvider["Schlage"] = "Schlage";
|
|
11
|
+
ConnectionProvider["YaleWifi"] = "YaleWifi";
|
|
12
|
+
ConnectionProvider["Sensibo"] = "Sensibo";
|
|
13
|
+
ConnectionProvider["Devicethread"] = "Devicethread";
|
|
14
|
+
ConnectionProvider["Dormakaba"] = "Dormakaba";
|
|
15
|
+
ConnectionProvider["Dusaw"] = "Dusaw";
|
|
16
|
+
})(ConnectionProvider || (exports.ConnectionProvider = ConnectionProvider = {}));
|
|
@@ -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("./IConnection"), exports);
|
|
18
|
+
__exportStar(require("./Connection.service"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IDevice } from "../../local/interfaces";
|
|
2
|
+
import { ICloudDevice } from "../interfaces/ICloudDevice";
|
|
3
|
+
import { ICloudDeviceService } from "../interfaces/ICloudDeviceService";
|
|
4
|
+
import { IConnection } from "../../../connection";
|
|
5
|
+
export declare abstract class CloudDevice implements ICloudDevice {
|
|
6
|
+
deviceId: string;
|
|
7
|
+
localDevice?: IDevice;
|
|
8
|
+
connection?: IConnection;
|
|
9
|
+
cloudDeviceService: ICloudDeviceService;
|
|
10
|
+
constructor(device: IDevice, cloudDeviceService: ICloudDeviceService);
|
|
11
|
+
getDevice(connectionId: string, deviceId: string): Promise<Record<string, any>>;
|
|
12
|
+
getBattery(deviceId: string): Promise<number | string>;
|
|
13
|
+
getState(deviceId: string): Promise<string>;
|
|
14
|
+
getStatus(connectionId: string, deviceId: string): Promise<string>;
|
|
15
|
+
toLocalDevice(): Promise<IDevice>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudDevice = void 0;
|
|
4
|
+
class CloudDevice {
|
|
5
|
+
constructor(device, cloudDeviceService) {
|
|
6
|
+
this.deviceId = device.deviceId;
|
|
7
|
+
this.localDevice = device;
|
|
8
|
+
this.cloudDeviceService = cloudDeviceService;
|
|
9
|
+
}
|
|
10
|
+
async getDevice(connectionId, deviceId) {
|
|
11
|
+
throw new Error("Method not implemented in Super Class.");
|
|
12
|
+
}
|
|
13
|
+
async getBattery(deviceId) {
|
|
14
|
+
throw new Error("Method not implemented in Super Class.");
|
|
15
|
+
}
|
|
16
|
+
async getState(deviceId) {
|
|
17
|
+
throw new Error("Method not implemented in Super Class.");
|
|
18
|
+
}
|
|
19
|
+
async getStatus(connectionId, deviceId) {
|
|
20
|
+
throw new Error("Method not implemented in Super Class.");
|
|
21
|
+
}
|
|
22
|
+
async toLocalDevice() {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.CloudDevice = CloudDevice;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudDeviceService = void 0;
|
|
4
|
+
class CloudDeviceService {
|
|
5
|
+
async getConnection(deviceId) {
|
|
6
|
+
throw new Error("Method not implemented.");
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.CloudDeviceService = CloudDeviceService;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IDevice } from "../../local/interfaces";
|
|
2
|
+
import { IDeviceFactory } from "../interfaces/IDeviceFactory";
|
|
3
|
+
export declare class DeviceFactory implements IDeviceFactory {
|
|
4
|
+
private readonly localDeviceService;
|
|
5
|
+
constructor();
|
|
6
|
+
getDevice(deviceId: string): Promise<IDevice>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.DeviceFactory = void 0;
|
|
45
|
+
const Device_service_1 = require("../../local/services/Device.service");
|
|
46
|
+
const typedi_1 = __importDefault(require("typedi"));
|
|
47
|
+
const typedi_2 = require("typedi");
|
|
48
|
+
let DeviceFactory = (() => {
|
|
49
|
+
let _classDecorators = [(0, typedi_2.Service)()];
|
|
50
|
+
let _classDescriptor;
|
|
51
|
+
let _classExtraInitializers = [];
|
|
52
|
+
let _classThis;
|
|
53
|
+
var DeviceFactory = _classThis = class {
|
|
54
|
+
constructor() {
|
|
55
|
+
// Use dependency injection instead of creating new instance
|
|
56
|
+
this.localDeviceService = typedi_1.default.get(Device_service_1.LocalDeviceService);
|
|
57
|
+
}
|
|
58
|
+
async getDevice(deviceId) {
|
|
59
|
+
try {
|
|
60
|
+
return await this.localDeviceService.getDevice(deviceId);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
// Log the error for debugging purposes
|
|
64
|
+
console.error(`DeviceFactory: Failed to get device ${deviceId}:`, error);
|
|
65
|
+
// Re-throw the error with additional context
|
|
66
|
+
throw new Error(`DeviceFactory: Unable to retrieve device ${deviceId}. ${error instanceof Error ? error.message : "Unknown error occurred"}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
__setFunctionName(_classThis, "DeviceFactory");
|
|
71
|
+
(() => {
|
|
72
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
73
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
74
|
+
DeviceFactory = _classThis = _classDescriptor.value;
|
|
75
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
76
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
77
|
+
})();
|
|
78
|
+
return DeviceFactory = _classThis;
|
|
79
|
+
})();
|
|
80
|
+
exports.DeviceFactory = DeviceFactory;
|
|
@@ -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("./CloudDevice"), exports);
|
|
18
|
+
__exportStar(require("./DeviceFactory"), exports);
|
|
19
|
+
__exportStar(require("./CloudDeviceService"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICloudDeviceService } from "./ICloudDeviceService";
|
|
2
|
+
export interface ICloudDevice {
|
|
3
|
+
deviceId: string;
|
|
4
|
+
cloudDeviceService: ICloudDeviceService;
|
|
5
|
+
getDevice(connectionId: string, deviceId: string): Promise<Record<string, any>>;
|
|
6
|
+
getBattery(deviceId: string): Promise<number | string>;
|
|
7
|
+
getState(deviceId: string): Promise<string>;
|
|
8
|
+
getStatus(connectionId: string, deviceId: string): Promise<string>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IConnection } from "../../../connection";
|
|
2
|
+
export declare enum DeviceType {
|
|
3
|
+
HUB = "HUB",
|
|
4
|
+
LOCK = "LOCK",
|
|
5
|
+
ELEVATOR_LOCK = "ELEVATOR LOCK",
|
|
6
|
+
THERMOSTAT = "THERMOSTAT",
|
|
7
|
+
TV = "TV"
|
|
8
|
+
}
|
|
9
|
+
export interface IRawDevice {
|
|
10
|
+
deviceId?: string;
|
|
11
|
+
deviceType: DeviceType;
|
|
12
|
+
name?: string;
|
|
13
|
+
connection: IConnection;
|
|
14
|
+
propertyId: string;
|
|
15
|
+
zoneId: string;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeviceType = void 0;
|
|
4
|
+
var DeviceType;
|
|
5
|
+
(function (DeviceType) {
|
|
6
|
+
DeviceType["HUB"] = "HUB";
|
|
7
|
+
DeviceType["LOCK"] = "LOCK";
|
|
8
|
+
DeviceType["ELEVATOR_LOCK"] = "ELEVATOR LOCK";
|
|
9
|
+
DeviceType["THERMOSTAT"] = "THERMOSTAT";
|
|
10
|
+
DeviceType["TV"] = "TV";
|
|
11
|
+
})(DeviceType || (exports.DeviceType = DeviceType = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
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("./ICloudDevice"), exports);
|
|
18
|
+
__exportStar(require("./ICloudDeviceService"), exports);
|
|
19
|
+
__exportStar(require("./IDeviceFactory"), exports);
|
|
20
|
+
__exportStar(require("./IRawDataTransformer"), exports);
|
|
21
|
+
__exportStar(require("./IRawDevice"), exports);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export interface IDevice {
|
|
2
|
+
deviceId: string;
|
|
3
|
+
propertyId: string;
|
|
4
|
+
zoneId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
hubId: string[];
|
|
7
|
+
specifications: {
|
|
8
|
+
manufacturer?: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
firmware?: {
|
|
11
|
+
version?: string;
|
|
12
|
+
newVersionAvailable?: boolean;
|
|
13
|
+
newVersion?: string;
|
|
14
|
+
mandatoryUpdate?: boolean;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
protocol: {
|
|
18
|
+
location?: {
|
|
19
|
+
id?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
city?: string;
|
|
22
|
+
};
|
|
23
|
+
name?: string;
|
|
24
|
+
room?: {
|
|
25
|
+
id?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
};
|
|
28
|
+
accountId?: string;
|
|
29
|
+
};
|
|
30
|
+
connection: {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
};
|
|
34
|
+
deviceType: {
|
|
35
|
+
id: string;
|
|
36
|
+
type: string;
|
|
37
|
+
};
|
|
38
|
+
status: IStatus;
|
|
39
|
+
isActive: {
|
|
40
|
+
value: boolean;
|
|
41
|
+
lastUpdated: string;
|
|
42
|
+
};
|
|
43
|
+
state?: Record<string, any>;
|
|
44
|
+
metaData?: Record<string, any>;
|
|
45
|
+
createdAt?: Date;
|
|
46
|
+
updatedAt?: Date;
|
|
47
|
+
hubDeviceDetails?: IDevice[];
|
|
48
|
+
capabilities?: Record<string, any>;
|
|
49
|
+
}
|
|
50
|
+
export declare class IStatus {
|
|
51
|
+
online: boolean;
|
|
52
|
+
liveStatus?: "ONLINE" | "OFFLINE";
|
|
53
|
+
error?: {
|
|
54
|
+
type?: string;
|
|
55
|
+
message?: string;
|
|
56
|
+
default?: object;
|
|
57
|
+
};
|
|
58
|
+
lastUpdated?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface IStatusQuery {
|
|
61
|
+
deviceIds?: string[];
|
|
62
|
+
zoneId?: string;
|
|
63
|
+
propertyId?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface IStatusUpdateRequest {
|
|
66
|
+
query: IStatusQuery;
|
|
67
|
+
status: IStatus;
|
|
68
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface IDtDevice {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
zoneId: string;
|
|
6
|
+
deviceType: string;
|
|
7
|
+
deviceId: string;
|
|
8
|
+
deviceNetworkId: string;
|
|
9
|
+
propertyId: string;
|
|
10
|
+
connectionId: string;
|
|
11
|
+
hubId: string;
|
|
12
|
+
isBatteryLowAlertSent: boolean;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
isActive: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ISchedule {
|
|
2
|
+
id?: string;
|
|
3
|
+
name: string;
|
|
4
|
+
deviceId: string;
|
|
5
|
+
scheduleId: string | null;
|
|
6
|
+
state: {
|
|
7
|
+
targetTemperature?: number;
|
|
8
|
+
temperatureUnit?: "C" | "F";
|
|
9
|
+
mode?: "cool" | "heat" | "fan" | "dry" | "auto";
|
|
10
|
+
swing?: "stopped" | "rangeFull" | "fixedTop" | "fixedMiddleTop" | "fixedMiddle" | "fixedMiddleBottom" | "fixedBottom";
|
|
11
|
+
fanLevel?: "auto" | "low" | "medium" | "high";
|
|
12
|
+
};
|
|
13
|
+
startTime: string;
|
|
14
|
+
endTime: string;
|
|
15
|
+
recurringDays: ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")[];
|
|
16
|
+
createTime?: string;
|
|
17
|
+
nextTime?: string;
|
|
18
|
+
nextTimeSecondsFromNow?: number;
|
|
19
|
+
targetTimeLocal: string;
|
|
20
|
+
timezone: string;
|
|
21
|
+
scheduleInheritedFrom: "zone" | "device";
|
|
22
|
+
zoneId: string;
|
|
23
|
+
userId: string;
|
|
24
|
+
status?: "SET" | "UNSET";
|
|
25
|
+
}
|