dt-common-device 2.0.6 → 3.0.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.
Files changed (187) hide show
  1. package/README.md +321 -99
  2. package/dist/alerts/Alert.model.d.ts +28 -0
  3. package/dist/alerts/Alert.model.js +222 -0
  4. package/dist/alerts/Alert.repository.d.ts +106 -0
  5. package/dist/alerts/Alert.repository.js +374 -0
  6. package/dist/alerts/Alert.service.d.ts +137 -0
  7. package/dist/alerts/Alert.service.js +476 -0
  8. package/dist/alerts/AlertBuilder.d.ts +87 -0
  9. package/dist/alerts/AlertBuilder.example.d.ts +11 -0
  10. package/dist/alerts/AlertBuilder.example.js +117 -0
  11. package/dist/alerts/AlertBuilder.js +185 -0
  12. package/dist/alerts/AlertService.example.d.ts +55 -0
  13. package/dist/alerts/AlertService.example.js +148 -0
  14. package/dist/alerts/alert.types.d.ts +57 -0
  15. package/dist/alerts/alert.types.js +22 -0
  16. package/dist/alerts/index.d.ts +3 -0
  17. package/dist/alerts/index.js +19 -0
  18. package/dist/config/config.d.ts +4 -4
  19. package/dist/config/config.js +3 -3
  20. package/dist/config/config.types.d.ts +19 -0
  21. package/dist/config/config.types.js +2 -0
  22. package/dist/connection/Connection.repository.d.ts +8 -0
  23. package/dist/connection/Connection.repository.js +92 -0
  24. package/dist/connection/Connection.service.d.ts +8 -0
  25. package/dist/connection/Connection.service.js +32 -0
  26. package/dist/connection/IConnection.d.ts +26 -0
  27. package/dist/connection/IConnection.js +14 -0
  28. package/dist/connection/index.d.ts +2 -0
  29. package/dist/connection/index.js +18 -0
  30. package/dist/device/cloud/entities/CloudDevice.d.ts +2 -2
  31. package/dist/device/cloud/entities/CloudDeviceService.d.ts +1 -1
  32. package/dist/device/cloud/entities/DeviceFactory.d.ts +1 -1
  33. package/dist/device/cloud/entities/DeviceFactory.js +1 -1
  34. package/dist/device/cloud/interfaces/ICloudDeviceService.d.ts +1 -1
  35. package/dist/device/cloud/interfaces/IRawDevice.d.ts +1 -1
  36. package/dist/device/local/interfaces/index.d.ts +2 -3
  37. package/dist/device/local/interfaces/index.js +2 -3
  38. package/dist/device/local/repository/Device.repository.d.ts +2 -0
  39. package/dist/device/local/repository/Device.repository.js +22 -3
  40. package/dist/device/local/repository/Hub.repository.js +4 -4
  41. package/dist/device/local/repository/Schedule.repository.js +2 -2
  42. package/dist/device/local/services/Device.service.d.ts +2 -2
  43. package/dist/device/local/services/Device.service.js +3 -1
  44. package/dist/device/local/services/index.d.ts +0 -4
  45. package/dist/device/local/services/index.js +0 -4
  46. package/dist/events/BaseEventHandler.d.ts +2 -2
  47. package/dist/events/BaseEventHandler.js +2 -2
  48. package/dist/events/BaseEventTransformer.d.ts +1 -1
  49. package/dist/events/BaseEventTransformer.js +1 -1
  50. package/dist/events/DeviceEventHandler.d.ts +1 -1
  51. package/dist/events/DeviceEventHandler.js +2 -2
  52. package/dist/events/EventHandler.js +1 -1
  53. package/dist/events/EventHandlerOrchestrator.js +1 -1
  54. package/dist/events/EventProcessingService.js +1 -1
  55. package/dist/events/InternalEventSubscription.js +1 -1
  56. package/dist/index.d.ts +7 -5
  57. package/dist/index.js +16 -13
  58. package/dist/issues/Issue.model.d.ts +28 -0
  59. package/dist/issues/Issue.model.js +260 -0
  60. package/dist/issues/Issue.repository.d.ts +113 -0
  61. package/dist/issues/Issue.repository.js +401 -0
  62. package/dist/issues/Issue.service.d.ts +168 -0
  63. package/dist/issues/Issue.service.js +642 -0
  64. package/dist/issues/IssueBuilder.d.ts +109 -0
  65. package/dist/issues/IssueBuilder.example.d.ts +16 -0
  66. package/dist/issues/IssueBuilder.example.js +196 -0
  67. package/dist/issues/IssueBuilder.js +237 -0
  68. package/dist/issues/IssueService.example.d.ts +68 -0
  69. package/dist/issues/IssueService.example.js +177 -0
  70. package/dist/issues/index.d.ts +2 -0
  71. package/dist/issues/index.js +18 -0
  72. package/dist/issues/issue.types.d.ts +90 -0
  73. package/dist/issues/issue.types.js +40 -0
  74. package/dist/property/IProperty.d.ts +29 -0
  75. package/dist/property/IProperty.js +2 -0
  76. package/dist/property/Property.repository.d.ts +8 -0
  77. package/dist/property/Property.repository.js +95 -0
  78. package/dist/property/Property.service.d.ts +8 -0
  79. package/dist/property/Property.service.js +36 -0
  80. package/dist/property/index.d.ts +2 -0
  81. package/dist/property/index.js +18 -0
  82. package/dist/queue/entities/HybridHttpQueue.d.ts +23 -0
  83. package/dist/queue/entities/HybridHttpQueue.js +189 -0
  84. package/dist/queue/entities/index.d.ts +1 -0
  85. package/dist/queue/entities/index.js +17 -0
  86. package/dist/queue/index.d.ts +5 -0
  87. package/dist/queue/index.js +22 -0
  88. package/dist/queue/interfaces/IHttpRequestJob.d.ts +9 -0
  89. package/dist/queue/interfaces/IHttpRequestJob.js +2 -0
  90. package/dist/queue/interfaces/IHybridHttpQueue.d.ts +16 -0
  91. package/dist/queue/interfaces/IHybridHttpQueue.js +2 -0
  92. package/dist/queue/interfaces/IJobResult.d.ts +6 -0
  93. package/dist/queue/interfaces/IJobResult.js +2 -0
  94. package/dist/queue/interfaces/IRateLimitConfig.d.ts +5 -0
  95. package/dist/queue/interfaces/IRateLimitConfig.js +2 -0
  96. package/dist/queue/interfaces/index.d.ts +4 -0
  97. package/dist/queue/interfaces/index.js +20 -0
  98. package/dist/queue/services/QueueService.d.ts +19 -0
  99. package/dist/queue/services/QueueService.js +73 -0
  100. package/dist/queue/services/index.d.ts +1 -0
  101. package/dist/queue/services/index.js +17 -0
  102. package/dist/queue/types/http.types.d.ts +21 -0
  103. package/dist/queue/types/http.types.js +2 -0
  104. package/dist/queue/types/index.d.ts +2 -0
  105. package/dist/queue/types/index.js +18 -0
  106. package/dist/queue/types/queue.types.d.ts +35 -0
  107. package/dist/queue/types/queue.types.js +2 -0
  108. package/dist/queue/utils/index.d.ts +3 -0
  109. package/dist/queue/utils/index.js +19 -0
  110. package/dist/queue/utils/jobUtils.d.ts +10 -0
  111. package/dist/queue/utils/jobUtils.js +64 -0
  112. package/dist/queue/utils/queueUtils.d.ts +5 -0
  113. package/dist/queue/utils/queueUtils.js +59 -0
  114. package/dist/queue/utils/rateLimit.utils.d.ts +6 -0
  115. package/dist/queue/utils/rateLimit.utils.js +44 -0
  116. package/package.json +2 -1
  117. package/src/{device/local/models → alerts}/Alert.model.ts +1 -1
  118. package/src/{device/local/repository → alerts}/Alert.repository.ts +2 -2
  119. package/src/{device/local/services → alerts}/Alert.service.ts +14 -7
  120. package/src/{device/local/entities → alerts}/AlertBuilder.example.ts +2 -2
  121. package/src/{device/local/entities → alerts}/AlertBuilder.ts +14 -8
  122. package/src/{device/local/services → alerts}/AlertService.example.ts +6 -5
  123. package/src/{types → alerts}/alert.types.ts +2 -2
  124. package/src/alerts/index.ts +3 -0
  125. package/src/config/config.ts +7 -7
  126. package/src/{types → config}/config.types.ts +1 -1
  127. package/src/{device/local/repository → connection}/Connection.repository.ts +2 -2
  128. package/src/{device/local/services → connection}/Connection.service.ts +2 -2
  129. package/src/connection/index.ts +3 -0
  130. package/src/device/cloud/entities/CloudDevice.ts +2 -2
  131. package/src/device/cloud/entities/CloudDeviceService.ts +1 -1
  132. package/src/device/cloud/entities/DeviceFactory.ts +2 -2
  133. package/src/device/cloud/interfaces/ICloudDeviceService.ts +1 -1
  134. package/src/device/cloud/interfaces/IRawDevice.ts +1 -1
  135. package/src/device/local/interfaces/index.ts +2 -3
  136. package/src/device/local/repository/Device.repository.ts +29 -3
  137. package/src/device/local/repository/Hub.repository.ts +4 -4
  138. package/src/device/local/repository/Schedule.repository.ts +2 -2
  139. package/src/device/local/services/Device.service.ts +5 -1
  140. package/src/device/local/services/index.ts +0 -4
  141. package/{TROUBLESHOOTING.md → src/docs/TROUBLESHOOTING.md} +2 -2
  142. package/src/events/BaseEventHandler.ts +3 -3
  143. package/src/events/BaseEventTransformer.ts +2 -2
  144. package/src/events/DeviceEventHandler.ts +3 -3
  145. package/src/events/EventHandler.ts +1 -1
  146. package/src/events/EventHandlerOrchestrator.ts +2 -2
  147. package/src/events/EventProcessingService.ts +2 -2
  148. package/src/events/InternalEventSubscription.ts +2 -2
  149. package/src/index.ts +19 -13
  150. package/src/{device/local/models → issues}/Issue.model.ts +1 -1
  151. package/src/{device/local/repository → issues}/Issue.repository.ts +2 -2
  152. package/src/{device/local/services → issues}/Issue.service.ts +4 -4
  153. package/src/{device/local/entities → issues}/IssueBuilder.example.ts +1 -1
  154. package/src/{device/local/entities → issues}/IssueBuilder.ts +1 -1
  155. package/src/{device/local/services → issues}/IssueService.example.ts +6 -5
  156. package/src/issues/index.ts +2 -0
  157. package/src/{device/local/repository → property}/Property.repository.ts +2 -2
  158. package/src/{device/local/services → property}/Property.service.ts +1 -1
  159. package/src/property/index.ts +2 -0
  160. package/src/queue/entities/HybridHttpQueue.ts +196 -0
  161. package/src/queue/entities/index.ts +1 -0
  162. package/src/queue/index.ts +6 -0
  163. package/src/queue/interfaces/IHttpRequestJob.ts +10 -0
  164. package/src/queue/interfaces/IHybridHttpQueue.ts +23 -0
  165. package/src/queue/interfaces/IJobResult.ts +6 -0
  166. package/src/queue/interfaces/IRateLimitConfig.ts +5 -0
  167. package/src/queue/interfaces/index.ts +4 -0
  168. package/src/queue/services/QueueService.ts +39 -0
  169. package/src/queue/services/index.ts +1 -0
  170. package/src/queue/types/http.types.ts +22 -0
  171. package/src/queue/types/index.ts +2 -0
  172. package/src/queue/types/queue.types.ts +22 -0
  173. package/src/queue/utils/index.ts +3 -0
  174. package/src/queue/utils/jobUtils.ts +80 -0
  175. package/src/queue/utils/queueUtils.ts +90 -0
  176. package/src/queue/utils/rateLimit.utils.ts +58 -0
  177. package/tsconfig.json +4 -0
  178. package/src/device/local/entities/README.md +0 -173
  179. package/src/device/local/entities/index.ts +0 -2
  180. package/src/types/index.ts +0 -3
  181. /package/src/{device/local/interfaces → connection}/IConnection.ts +0 -0
  182. /package/src/{device/local/models → docs}/Alert.model.md +0 -0
  183. /package/src/{device/local/models/README.md → docs/Alerts&IssuesModel.md} +0 -0
  184. /package/src/{device/local/models → docs}/Issue.model.md +0 -0
  185. /package/{SECURITY.md → src/docs/SECURITY.md} +0 -0
  186. /package/src/{types → issues}/issue.types.ts +0 -0
  187. /package/src/{device/local/interfaces → property}/IProperty.ts +0 -0
@@ -0,0 +1,3 @@
1
+ export * from "./Alert.service";
2
+ export * from "./AlertBuilder";
3
+ export * from "./alert.types";
@@ -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("./Alert.service"), exports);
18
+ __exportStar(require("./AlertBuilder"), exports);
19
+ __exportStar(require("./alert.types"), exports);
@@ -1,7 +1,7 @@
1
- import { DeviceConfig } from "../types";
2
- import { InternalEventSubscription } from "../events";
3
- export declare function initialize(cfg: DeviceConfig): Promise<void>;
4
- export declare function getConfig(): DeviceConfig;
1
+ import { InternalEventSubscription } from "src/events";
2
+ import { IConfig } from "./config.types";
3
+ export declare function initialize(cfg: IConfig): Promise<void>;
4
+ export declare function getConfig(): IConfig;
5
5
  export declare function getEventSubscription(): InternalEventSubscription | null;
6
6
  export declare function checkRequiredEnv(): void;
7
7
  export declare function ensureAuditInitialized(): void;
@@ -13,10 +13,10 @@ exports.getMongoUri = getMongoUri;
13
13
  exports.getRedisDbHostAndPort = getRedisDbHostAndPort;
14
14
  exports.shutdown = shutdown;
15
15
  const dt_audit_library_1 = require("dt-audit-library");
16
- const db_1 = require("../db/db");
16
+ const db_1 = require("src/db/db");
17
17
  const dotenv_1 = __importDefault(require("dotenv"));
18
- const events_1 = require("../events");
19
- const http_utils_1 = require("../utils/http.utils");
18
+ const events_1 = require("src/events");
19
+ const http_utils_1 = require("src/utils/http.utils");
20
20
  dotenv_1.default.config();
21
21
  let config = null;
22
22
  let auditInitialized = false;
@@ -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 IConfig = {
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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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("src/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,26 @@
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
+ }
@@ -0,0 +1,14 @@
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 || (exports.ConnectionProvider = ConnectionProvider = {}));
@@ -0,0 +1,2 @@
1
+ export * from "./IConnection";
2
+ export * from "./Connection.service";
@@ -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);
@@ -1,7 +1,7 @@
1
- import { IDevice } from "../../local/interfaces";
1
+ import { IDevice } from "src/device/local/interfaces";
2
2
  import { ICloudDevice } from "../interfaces/ICloudDevice";
3
3
  import { ICloudDeviceService } from "../interfaces/ICloudDeviceService";
4
- import { IConnection } from "../../local/interfaces/IConnection";
4
+ import { IConnection } from "src/connection";
5
5
  export declare abstract class CloudDevice implements ICloudDevice {
6
6
  deviceId: string;
7
7
  localDevice?: IDevice;
@@ -1,5 +1,5 @@
1
1
  import { ICloudDeviceService } from "../interfaces/ICloudDeviceService";
2
- import { IConnection } from "../../local/interfaces/IConnection";
2
+ import { IConnection } from "src/connection";
3
3
  export declare class CloudDeviceService implements ICloudDeviceService {
4
4
  getConnection(deviceId: string): Promise<IConnection>;
5
5
  }
@@ -1,4 +1,4 @@
1
- import { IDevice } from "../../local/interfaces";
1
+ import { IDevice } from "src/device/local/interfaces";
2
2
  import { IDeviceFactory } from "../interfaces/IDeviceFactory";
3
3
  export declare class DeviceFactory implements IDeviceFactory {
4
4
  private readonly localDeviceService;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceFactory = void 0;
4
- const Device_service_1 = require("../../local/services/Device.service");
4
+ const Device_service_1 = require("src/device/local/services/Device.service");
5
5
  class DeviceFactory {
6
6
  constructor() {
7
7
  this.localDeviceService = new Device_service_1.LocalDeviceService();
@@ -1,4 +1,4 @@
1
- import { IConnection } from "../../local/interfaces/IConnection";
1
+ import { IConnection } from "../../../connection";
2
2
  export interface ICloudDeviceService {
3
3
  getConnection(deviceId: string): Promise<IConnection>;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { IConnection } from "../../local/interfaces";
1
+ import { IConnection } from "../../../connection";
2
2
  export declare enum DeviceType {
3
3
  HUB = "HUB",
4
4
  LOCK = "LOCK",
@@ -1,4 +1,3 @@
1
1
  export * from "./IDevice";
2
- export * from "./IProperty";
3
- export * from "./IConnection";
4
- export * from "./IProperty";
2
+ export * from "./IDtDevice";
3
+ export * from "./ISchedule";
@@ -15,6 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./IDevice"), exports);
18
- __exportStar(require("./IProperty"), exports);
19
- __exportStar(require("./IConnection"), exports);
20
- __exportStar(require("./IProperty"), exports);
18
+ __exportStar(require("./IDtDevice"), exports);
19
+ __exportStar(require("./ISchedule"), exports);
@@ -6,6 +6,8 @@ export declare class DeviceRepository {
6
6
  constructor();
7
7
  createDevice(body: IDevice): Promise<IDevice>;
8
8
  getDevice(deviceId: string, withHubDetails?: boolean): Promise<IDevice>;
9
+ updateDevice(deviceId: string, body: any): Promise<IDevice>;
10
+ deleteDevice(deviceId: string): Promise<void>;
9
11
  getDevices(deviceIds: string[], withHubDetails?: boolean): Promise<IDevice[]>;
10
12
  getPropertyDevices(propertyId: string, selectDeviceId?: boolean, type?: string, withHubDetails?: boolean): Promise<IDevice[]>;
11
13
  getPropertyDeviceIds(propertyId: string, selectDeviceId: boolean | undefined, manufacturer: string): Promise<any>;
@@ -39,10 +39,10 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
39
39
  };
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.DeviceRepository = void 0;
42
- const config_1 = require("../../../config/config");
43
- const db_1 = require("../../../db");
42
+ const config_1 = require("src/config/config");
43
+ const db_1 = require("src/db");
44
44
  const typedi_1 = require("typedi");
45
- const http_utils_1 = require("../../../utils/http.utils");
45
+ const http_utils_1 = require("src/utils/http.utils");
46
46
  let DeviceRepository = (() => {
47
47
  let _classDecorators = [(0, typedi_1.Service)()];
48
48
  let _classDescriptor;
@@ -73,6 +73,25 @@ let DeviceRepository = (() => {
73
73
  throw new Error(`Failed to get device: ${error.message || "Unknown error"}`);
74
74
  }
75
75
  }
76
+ async updateDevice(deviceId, body) {
77
+ try {
78
+ const response = await this.axiosInstance.put(`/devices/${deviceId}`, body);
79
+ return response.data;
80
+ }
81
+ catch (error) {
82
+ (0, config_1.getConfig)().LOGGER.error(`Failed to update device ${deviceId}:`, error);
83
+ throw new Error(`Failed to update device: ${error.message || "Unknown error"}`);
84
+ }
85
+ }
86
+ async deleteDevice(deviceId) {
87
+ try {
88
+ await this.axiosInstance.delete(`/devices/${deviceId}`);
89
+ }
90
+ catch (error) {
91
+ (0, config_1.getConfig)().LOGGER.error(`Failed to delete device ${deviceId}:`, error);
92
+ throw new Error(`Failed to delete device: ${error.message || "Unknown error"}`);
93
+ }
94
+ }
76
95
  async getDevices(deviceIds, withHubDetails = false) {
77
96
  try {
78
97
  const response = await this.axiosInstance.get(`/devices`, {
@@ -39,10 +39,10 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
39
39
  };
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.HubRepository = void 0;
42
- const config_1 = require("../../../config/config");
43
- const db_1 = require("../../../db");
42
+ const config_1 = require("src/config/config");
43
+ const db_1 = require("src/db");
44
44
  const typedi_1 = require("typedi");
45
- const http_utils_1 = require("../../../utils/http.utils");
45
+ const http_utils_1 = require("src/utils/http.utils");
46
46
  let HubRepository = (() => {
47
47
  let _classDecorators = [(0, typedi_1.Service)()];
48
48
  let _classDescriptor;
@@ -65,7 +65,7 @@ let HubRepository = (() => {
65
65
  }
66
66
  async getHubs(hubIds) {
67
67
  try {
68
- const query = hubIds && hubIds.length ? `?ids=${hubIds.join(",")}` : "";
68
+ const query = hubIds?.length ? `?ids=${hubIds.join(",")}` : "";
69
69
  const response = await this.axiosInstance.get(`/devices/hubs${query}`);
70
70
  return response.data;
71
71
  }
@@ -40,8 +40,8 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.ScheduleRepository = void 0;
42
42
  const typedi_1 = require("typedi");
43
- const config_1 = require("../../../config/config");
44
- const http_utils_1 = require("../../../utils/http.utils");
43
+ const config_1 = require("src/config/config");
44
+ const http_utils_1 = require("src/utils/http.utils");
45
45
  let ScheduleRepository = (() => {
46
46
  let _classDecorators = [(0, typedi_1.Service)()];
47
47
  let _classDescriptor;
@@ -18,8 +18,8 @@ export declare class LocalDeviceService {
18
18
  setBatteryLevel(deviceId: string, batteryLevel: number): Promise<void>;
19
19
  getMetaData(deviceId: string): Promise<any>;
20
20
  setMetaData(deviceId: string, metaData: Record<string, any>): Promise<any>;
21
- getDevicesByZone(zoneId: string): Promise<import("../interfaces/IDtDevice").IDtDevice[]>;
22
- getDevicesByAccessGroup(accessGroupId: string): Promise<import("../interfaces/IDtDevice").IDtDevice[]>;
21
+ getDevicesByZone(zoneId: string): Promise<import("../interfaces").IDtDevice[]>;
22
+ getDevicesByAccessGroup(accessGroupId: string): Promise<import("../interfaces").IDtDevice[]>;
23
23
  querySelect(query: any, fields: string[]): Promise<any>;
24
24
  queryCount(query: any): Promise<number>;
25
25
  deleteDevices(query: any): Promise<any>;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LocalDeviceService = void 0;
7
- const EventHandler_1 = require("../../../events/EventHandler");
7
+ const EventHandler_1 = require("src/events/EventHandler");
8
8
  const lodash_1 = require("lodash");
9
9
  const Device_repository_1 = require("../repository/Device.repository");
10
10
  const typedi_1 = __importDefault(require("typedi"));
@@ -46,12 +46,14 @@ class LocalDeviceService {
46
46
  if (!deviceId) {
47
47
  throw new Error("Device ID is required");
48
48
  }
49
+ await this.deviceRepository.updateDevice(deviceId, body);
49
50
  return await this.eventHandler.onDeviceUpdate(deviceId, body);
50
51
  }
51
52
  async deleteDevice(deviceId) {
52
53
  if (!deviceId) {
53
54
  throw new Error("Device ID is required");
54
55
  }
56
+ await this.deviceRepository.deleteDevice(deviceId);
55
57
  return await this.eventHandler.onDeviceDelete(deviceId);
56
58
  }
57
59
  async getState(deviceId) {
@@ -1,7 +1,3 @@
1
- export * from "./Alert.service";
2
- export * from "./Connection.service";
3
1
  export * from "./Device.service";
4
2
  export * from "./Hub.service";
5
- export * from "./Issue.service";
6
- export * from "./Property.service";
7
3
  export * from "./Schedule.service";
@@ -14,10 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Alert.service"), exports);
18
- __exportStar(require("./Connection.service"), exports);
19
17
  __exportStar(require("./Device.service"), exports);
20
18
  __exportStar(require("./Hub.service"), exports);
21
- __exportStar(require("./Issue.service"), exports);
22
- __exportStar(require("./Property.service"), exports);
23
19
  __exportStar(require("./Schedule.service"), exports);
@@ -1,7 +1,7 @@
1
1
  import { DeviceEvent } from "./interfaces/DeviceEvent";
2
2
  import { IEventHandler } from "./interfaces/IEventHandler";
3
- import { ILogger } from "../types/config.types";
4
- import { LocalDeviceService } from "../device/local/services/Device.service";
3
+ import { ILogger } from "src/config/config.types";
4
+ import { LocalDeviceService } from "src/device/local/services/Device.service";
5
5
  export declare abstract class BaseEventHandler implements IEventHandler {
6
6
  protected readonly supportedEventTypes: string[];
7
7
  protected readonly priority: number;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseEventHandler = void 0;
4
- const config_1 = require("../config/config");
5
- const Device_service_1 = require("../device/local/services/Device.service");
4
+ const config_1 = require("src/config/config");
5
+ const Device_service_1 = require("src/device/local/services/Device.service");
6
6
  class BaseEventHandler {
7
7
  constructor(supportedEventTypes, priority = 100) {
8
8
  this.supportedEventTypes = supportedEventTypes;
@@ -1,4 +1,4 @@
1
- import { ILogger } from "../types/config.types";
1
+ import { ILogger } from "src/config/config.types";
2
2
  import { DeviceEvent } from "./interfaces/DeviceEvent";
3
3
  import { IEventTransformer } from "./interfaces/IEventTransformer";
4
4
  export declare abstract class BaseEventTransformer implements IEventTransformer {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseEventTransformer = void 0;
4
- const config_1 = require("../config/config");
4
+ const config_1 = require("src/config/config");
5
5
  class BaseEventTransformer {
6
6
  constructor(deviceType, rawData) {
7
7
  this.deviceType = deviceType;
@@ -1,4 +1,4 @@
1
- import { IDevice } from "../device/local/interfaces";
1
+ import { IDevice } from "src/device/local/interfaces";
2
2
  import { BaseEventHandler } from "./BaseEventHandler";
3
3
  import { DeviceEvent, DeviceEventEntity, EventConstructionOptions } from "./interfaces/DeviceEvent";
4
4
  export declare class DeviceEventHandler extends BaseEventHandler {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceEventHandler = void 0;
4
- const Event_1 = require("../constants/Event");
5
- const services_1 = require("../device/local/services");
4
+ const Event_1 = require("src/constants/Event");
5
+ const services_1 = require("src/device/local/services");
6
6
  const BaseEventHandler_1 = require("./BaseEventHandler");
7
7
  class DeviceEventHandler extends BaseEventHandler_1.BaseEventHandler {
8
8
  constructor() {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EventHandler = void 0;
4
4
  const dt_pub_sub_1 = require("dt-pub-sub");
5
5
  const dt_audit_library_1 = require("dt-audit-library");
6
- const Event_1 = require("../constants/Event");
6
+ const Event_1 = require("src/constants/Event");
7
7
  class EventHandler {
8
8
  constructor() {
9
9
  this.source = "dt-common-device";
@@ -40,7 +40,7 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.EventHandlerOrchestrator = void 0;
42
42
  const typedi_1 = require("typedi");
43
- const config_1 = require("../config/config");
43
+ const config_1 = require("src/config/config");
44
44
  let EventHandlerOrchestrator = (() => {
45
45
  let _classDecorators = [(0, typedi_1.Service)()];
46
46
  let _classDescriptor;
@@ -41,7 +41,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.EventProcessingService = void 0;
42
42
  const typedi_1 = require("typedi");
43
43
  const DeviceEventHandler_1 = require("./DeviceEventHandler");
44
- const config_1 = require("../config/config");
44
+ const config_1 = require("src/config/config");
45
45
  const EventHandlerOrchestrator_1 = require("./EventHandlerOrchestrator");
46
46
  let EventProcessingService = (() => {
47
47
  let _classDecorators = [(0, typedi_1.Service)()];
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InternalEventSubscription = exports.InternalEventType = void 0;
4
4
  const dt_pub_sub_1 = require("dt-pub-sub");
5
- const config_1 = require("../config/config");
5
+ const config_1 = require("src/config/config");
6
6
  // Event types enum for better type safety
7
7
  var InternalEventType;
8
8
  (function (InternalEventType) {
package/dist/index.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  export { CloudDevice, CloudDeviceService, DeviceFactory, } from "./device/cloud/entities";
2
- export { LocalDeviceService, LocalHubService, LocalConnectionService, LocalPropertyService, LocalScheduleService, } from "./device/local/services";
3
- export * from "./events";
4
- export * from "./events/interfaces";
5
- export * from "./device/cloud/interfaces";
2
+ export { LocalDeviceService, LocalHubService, LocalScheduleService, } from "./device/local/services";
6
3
  export * from "./device/local/interfaces";
4
+ export * from "./device/cloud/interfaces";
5
+ export * from "./connection";
6
+ export * from "./property";
7
7
  export * from "./events";
8
8
  export * from "./events/interfaces";
9
- export * from "./types";
9
+ export * from "./alerts";
10
+ export * from "./issues";
10
11
  export * from "./utils";
12
+ export * from "./queue";
11
13
  export { initialize, getConfig, shutdown } from "./config/config";