dt-common-device 9.2.2 → 9.2.4

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 (230) hide show
  1. package/dist/admin/Admin.repository.d.ts +7 -0
  2. package/dist/admin/Admin.repository.js +182 -0
  3. package/dist/admin/Admin.service.d.ts +5 -0
  4. package/dist/admin/Admin.service.js +17 -0
  5. package/dist/admin/index.d.ts +1 -0
  6. package/dist/admin/index.js +17 -0
  7. package/dist/audit/AuditProperties.d.ts +16 -0
  8. package/dist/audit/AuditProperties.js +2 -0
  9. package/dist/chronicle/Cronicle.service.d.ts +2 -6
  10. package/dist/chronicle/Cronicle.service.js +2 -19
  11. package/dist/chronicle/IChronicle.interface.d.ts +14 -0
  12. package/dist/chronicle/IChronicle.interface.js +2 -0
  13. package/dist/chronicle/ICronicle.interface.d.ts +0 -1
  14. package/dist/chronicle/chronicle.service.d.ts +4 -0
  15. package/dist/chronicle/chronicle.service.js +44 -0
  16. package/dist/connection/Connection.repository.d.ts +8 -0
  17. package/dist/connection/Connection.repository.js +92 -0
  18. package/dist/connection/Connection.service.d.ts +8 -0
  19. package/dist/connection/Connection.service.js +32 -0
  20. package/dist/connection/IConnection.d.ts +28 -0
  21. package/dist/connection/IConnection.js +16 -0
  22. package/dist/connection/index.d.ts +2 -0
  23. package/dist/connection/index.js +18 -0
  24. package/dist/copilotQueue/examples/CopilotQueue.example.d.ts +37 -0
  25. package/dist/copilotQueue/examples/CopilotQueue.example.js +140 -0
  26. package/dist/copilotQueue/examples/index.d.ts +1 -0
  27. package/dist/copilotQueue/examples/index.js +17 -0
  28. package/dist/device/cloud/entities/CloudConnection.d.ts +6 -0
  29. package/dist/device/cloud/entities/CloudConnection.js +6 -0
  30. package/dist/device/cloud/entities/CloudDevice.d.ts +16 -0
  31. package/dist/device/cloud/entities/CloudDevice.js +26 -0
  32. package/dist/device/cloud/entities/CloudDeviceService.d.ts +5 -0
  33. package/dist/device/cloud/entities/CloudDeviceService.js +9 -0
  34. package/dist/device/cloud/entities/DeviceFactory.d.ts +7 -0
  35. package/dist/device/cloud/entities/DeviceFactory.js +80 -0
  36. package/dist/device/cloud/entities/index.d.ts +3 -0
  37. package/dist/device/cloud/entities/index.js +19 -0
  38. package/dist/device/cloud/interface.d.ts +101 -0
  39. package/dist/device/cloud/interface.js +3 -0
  40. package/dist/device/cloud/interfaces/ICloudConnection.d.ts +5 -0
  41. package/dist/device/cloud/interfaces/ICloudConnection.js +2 -0
  42. package/dist/device/cloud/interfaces/ICloudDevice.d.ts +9 -0
  43. package/dist/device/cloud/interfaces/ICloudDevice.js +2 -0
  44. package/dist/device/cloud/interfaces/ICloudDeviceService.d.ts +4 -0
  45. package/dist/device/cloud/interfaces/ICloudDeviceService.js +2 -0
  46. package/dist/device/cloud/interfaces/IConnectionService.d.ts +7 -0
  47. package/dist/device/cloud/interfaces/IConnectionService.js +2 -0
  48. package/dist/device/cloud/interfaces/IDeviceConnectionService.d.ts +7 -0
  49. package/dist/device/cloud/interfaces/IDeviceConnectionService.js +3 -0
  50. package/dist/device/cloud/interfaces/IDeviceFactory.d.ts +4 -0
  51. package/dist/device/cloud/interfaces/IDeviceFactory.js +2 -0
  52. package/dist/device/cloud/interfaces/IDeviceService.d.ts +8 -0
  53. package/dist/device/cloud/interfaces/IDeviceService.js +2 -0
  54. package/dist/device/cloud/interfaces/IDevicesService.d.ts +9 -0
  55. package/dist/device/cloud/interfaces/IDevicesService.js +2 -0
  56. package/dist/device/cloud/interfaces/IHubService.d.ts +5 -0
  57. package/dist/device/cloud/interfaces/IHubService.js +2 -0
  58. package/dist/device/cloud/interfaces/IRawDataTransformer.d.ts +4 -0
  59. package/dist/device/cloud/interfaces/IRawDataTransformer.js +2 -0
  60. package/dist/device/cloud/interfaces/IRawDevice.d.ts +17 -0
  61. package/dist/device/cloud/interfaces/IRawDevice.js +11 -0
  62. package/dist/device/cloud/interfaces/index.d.ts +5 -0
  63. package/dist/device/cloud/interfaces/index.js +21 -0
  64. package/dist/device/cloud/services/CloudDevice.service.d.ts +5 -0
  65. package/dist/device/cloud/services/CloudDevice.service.js +9 -0
  66. package/dist/device/cloud/services/Connection.service.d.ts +8 -0
  67. package/dist/device/cloud/services/Connection.service.js +6 -0
  68. package/dist/device/cloud/services/Device.service.d.ts +39 -0
  69. package/dist/device/cloud/services/Device.service.js +9 -0
  70. package/dist/device/cloud/services/DeviceCloudService.d.ts +42 -0
  71. package/dist/device/cloud/services/DeviceCloudService.js +59 -0
  72. package/dist/device/cloud/services/DeviceHub.service.d.ts +3 -0
  73. package/dist/device/cloud/services/DeviceHub.service.js +6 -0
  74. package/dist/device/cloud/services/Hub.service.d.ts +25 -0
  75. package/dist/device/cloud/services/Hub.service.js +9 -0
  76. package/dist/device/cloud/services/SmartThingsDeviceService.d.ts +38 -0
  77. package/dist/device/cloud/services/SmartThingsDeviceService.js +52 -0
  78. package/dist/device/cloud/services/index.d.ts +2 -0
  79. package/dist/device/cloud/services/index.js +18 -0
  80. package/dist/device/cloud/types.d.ts +52 -0
  81. package/dist/device/cloud/types.js +15 -0
  82. package/dist/device/index.d.ts +4 -0
  83. package/dist/device/index.js +20 -0
  84. package/dist/device/local/entities/AlertBuilder.d.ts +87 -0
  85. package/dist/device/local/entities/AlertBuilder.example.d.ts +11 -0
  86. package/dist/device/local/entities/AlertBuilder.example.js +117 -0
  87. package/dist/device/local/entities/AlertBuilder.js +179 -0
  88. package/dist/device/local/entities/IssueBuilder.d.ts +109 -0
  89. package/dist/device/local/entities/IssueBuilder.example.d.ts +16 -0
  90. package/dist/device/local/entities/IssueBuilder.example.js +196 -0
  91. package/dist/device/local/entities/IssueBuilder.js +237 -0
  92. package/dist/device/local/entities/index.d.ts +2 -0
  93. package/dist/device/local/entities/index.js +7 -0
  94. package/dist/device/local/events/EventHandler.d.ts +11 -0
  95. package/dist/device/local/events/EventHandler.js +86 -0
  96. package/dist/device/local/events/Events.d.ts +54 -0
  97. package/dist/device/local/events/Events.js +57 -0
  98. package/dist/device/local/events/index.d.ts +2 -0
  99. package/dist/device/local/events/index.js +7 -0
  100. package/dist/device/local/handler/EventHandler.d.ts +7 -0
  101. package/dist/device/local/handler/EventHandler.js +44 -0
  102. package/dist/device/local/interface.d.ts +0 -0
  103. package/dist/device/local/interface.js +1 -0
  104. package/dist/device/local/interfaces/IConnection.d.ts +26 -0
  105. package/dist/device/local/interfaces/IConnection.js +14 -0
  106. package/dist/device/local/interfaces/IDevice.d.ts +68 -0
  107. package/dist/device/local/interfaces/IDevice.js +10 -0
  108. package/dist/device/local/interfaces/IDtDevice.d.ts +16 -0
  109. package/dist/device/local/interfaces/IDtDevice.js +2 -0
  110. package/dist/device/local/interfaces/IHub.d.ts +46 -0
  111. package/dist/device/local/interfaces/IHub.js +2 -0
  112. package/dist/device/local/interfaces/IProperty.d.ts +29 -0
  113. package/dist/device/local/interfaces/IProperty.js +2 -0
  114. package/dist/device/local/interfaces/ISchedule.d.ts +25 -0
  115. package/dist/device/local/interfaces/ISchedule.js +2 -0
  116. package/dist/device/local/interfaces/index.d.ts +3 -0
  117. package/dist/device/local/interfaces/index.js +19 -0
  118. package/dist/device/local/models/Alert.model.d.ts +28 -0
  119. package/dist/device/local/models/Alert.model.js +222 -0
  120. package/dist/device/local/models/Issue.model.d.ts +28 -0
  121. package/dist/device/local/models/Issue.model.js +260 -0
  122. package/dist/device/local/repository/Alert.repository.d.ts +106 -0
  123. package/dist/device/local/repository/Alert.repository.js +374 -0
  124. package/dist/device/local/repository/Connection.repository.d.ts +8 -0
  125. package/dist/device/local/repository/Connection.repository.js +92 -0
  126. package/dist/device/local/repository/Device.repository.d.ts +30 -0
  127. package/dist/device/local/repository/Device.repository.js +325 -0
  128. package/dist/device/local/repository/Hub.repository.d.ts +13 -0
  129. package/dist/device/local/repository/Hub.repository.js +139 -0
  130. package/dist/device/local/repository/Issue.repository.d.ts +113 -0
  131. package/dist/device/local/repository/Issue.repository.js +401 -0
  132. package/dist/device/local/repository/Property.repository.d.ts +8 -0
  133. package/dist/device/local/repository/Property.repository.js +95 -0
  134. package/dist/device/local/repository/Schedule.repository.d.ts +9 -0
  135. package/dist/device/local/repository/Schedule.repository.js +109 -0
  136. package/dist/device/local/services/Alert.service.d.ts +137 -0
  137. package/dist/device/local/services/Alert.service.js +475 -0
  138. package/dist/device/local/services/AlertService.example.d.ts +55 -0
  139. package/dist/device/local/services/AlertService.example.js +148 -0
  140. package/dist/device/local/services/Connection.service.d.ts +8 -0
  141. package/dist/device/local/services/Connection.service.js +32 -0
  142. package/dist/device/local/services/Device.service.d.ts +40 -0
  143. package/dist/device/local/services/Device.service.js +391 -0
  144. package/dist/device/local/services/DeviceHub.service.d.ts +11 -0
  145. package/dist/device/local/services/DeviceHub.service.js +40 -0
  146. package/dist/device/local/services/Hub.service.d.ts +12 -0
  147. package/dist/device/local/services/Hub.service.js +107 -0
  148. package/dist/device/local/services/Issue.service.d.ts +168 -0
  149. package/dist/device/local/services/Issue.service.js +642 -0
  150. package/dist/device/local/services/IssueService.example.d.ts +68 -0
  151. package/dist/device/local/services/IssueService.example.js +177 -0
  152. package/dist/device/local/services/Property.service.d.ts +8 -0
  153. package/dist/device/local/services/Property.service.js +36 -0
  154. package/dist/device/local/services/Schedule.service.d.ts +9 -0
  155. package/dist/device/local/services/Schedule.service.js +26 -0
  156. package/dist/device/local/services/index.d.ts +3 -0
  157. package/dist/device/local/services/index.js +19 -0
  158. package/dist/entities/accessGroup/AccessGroup.repository.d.ts +1 -2
  159. package/dist/entities/accessGroup/AccessGroup.repository.js +1 -4
  160. package/dist/entities/accessGroup/AccessGroup.service.d.ts +1 -2
  161. package/dist/entities/accessGroup/AccessGroup.service.js +3 -4
  162. package/dist/entities/guest/Guest.repository.d.ts +1 -1
  163. package/dist/entities/guest/Guest.repository.js +2 -5
  164. package/dist/entities/guest/Guest.service.d.ts +1 -1
  165. package/dist/entities/guest/Guest.service.js +1 -4
  166. package/dist/entities/schedules/Schedule.repository.d.ts +1 -1
  167. package/dist/entities/schedules/Schedule.repository.js +2 -5
  168. package/dist/entities/schedules/Schedule.service.d.ts +1 -1
  169. package/dist/entities/schedules/Schedule.service.js +1 -4
  170. package/dist/entities/user/User.repository.js +1 -4
  171. package/dist/entities/user/User.service.d.ts +1 -1
  172. package/dist/entities/user/User.service.js +1 -4
  173. package/dist/entities/zone/Zone.service.js +1 -4
  174. package/dist/pms/IPms.d.ts +6 -0
  175. package/dist/pms/IPms.js +10 -0
  176. package/dist/pms/index.d.ts +1 -0
  177. package/dist/pms/index.js +18 -0
  178. package/dist/pms/webhookQueue/examples/index.d.ts +2 -0
  179. package/dist/pms/webhookQueue/examples/index.js +18 -0
  180. package/dist/pms/webhookQueue/examples/pms-integration.d.ts +65 -0
  181. package/dist/pms/webhookQueue/examples/pms-integration.js +254 -0
  182. package/dist/pms/webhookQueue/examples/usage.d.ts +7 -0
  183. package/dist/pms/webhookQueue/examples/usage.js +175 -0
  184. package/dist/pms/webhookQueue/index.d.ts +3 -0
  185. package/dist/pms/webhookQueue/index.js +20 -0
  186. package/dist/pms/webhookQueue/interfaces/IWebhookQueue.d.ts +33 -0
  187. package/dist/pms/webhookQueue/interfaces/IWebhookQueue.js +2 -0
  188. package/dist/pms/webhookQueue/interfaces/IWebhookWorker.d.ts +38 -0
  189. package/dist/pms/webhookQueue/interfaces/IWebhookWorker.js +2 -0
  190. package/dist/pms/webhookQueue/interfaces/index.d.ts +1 -0
  191. package/dist/pms/webhookQueue/interfaces/index.js +17 -0
  192. package/dist/pms/webhookQueue/services/WebhookQueueFactory.d.ts +38 -0
  193. package/dist/pms/webhookQueue/services/WebhookQueueFactory.js +131 -0
  194. package/dist/pms/webhookQueue/services/WebhookQueueIntegration.d.ts +70 -0
  195. package/dist/pms/webhookQueue/services/WebhookQueueIntegration.js +207 -0
  196. package/dist/pms/webhookQueue/services/WebhookQueueService.d.ts +45 -0
  197. package/dist/pms/webhookQueue/services/WebhookQueueService.js +270 -0
  198. package/dist/pms/webhookQueue/services/WebhookWorker.d.ts +37 -0
  199. package/dist/pms/webhookQueue/services/WebhookWorker.js +201 -0
  200. package/dist/pms/webhookQueue/services/index.d.ts +1 -0
  201. package/dist/pms/webhookQueue/services/index.js +17 -0
  202. package/dist/pms/webhookQueue/types/index.d.ts +1 -0
  203. package/dist/pms/webhookQueue/types/index.js +17 -0
  204. package/dist/pms/webhookQueue/types/webhook.types.d.ts +39 -0
  205. package/dist/pms/webhookQueue/types/webhook.types.js +2 -0
  206. package/dist/property/IProperty.d.ts +29 -0
  207. package/dist/property/IProperty.js +2 -0
  208. package/dist/property/Property.repository.d.ts +8 -0
  209. package/dist/property/Property.repository.js +109 -0
  210. package/dist/property/Property.service.d.ts +8 -0
  211. package/dist/property/Property.service.js +124 -0
  212. package/dist/property/index.d.ts +2 -0
  213. package/dist/property/index.js +18 -0
  214. package/dist/queue/entities/HybridHttpQueue.js +2 -1
  215. package/dist/queue/interfaces/IHttpRequestJob.d.ts +9 -0
  216. package/dist/queue/interfaces/IHttpRequestJob.js +2 -0
  217. package/dist/queue/utils/queueUtils.d.ts +1 -1
  218. package/dist/queue/utils/queueUtils.js +24 -8
  219. package/dist/queue/utils/rateLimit.utils.js +1 -1
  220. package/dist/types/alert.types.d.ts +57 -0
  221. package/dist/types/alert.types.js +22 -0
  222. package/dist/types/config.types.d.ts +19 -0
  223. package/dist/types/config.types.js +2 -0
  224. package/dist/types/index.d.ts +3 -0
  225. package/dist/types/index.js +19 -0
  226. package/dist/types/issue.types.d.ts +90 -0
  227. package/dist/types/issue.types.js +40 -0
  228. package/dist/utils/http-utils.d.ts +13 -0
  229. package/dist/utils/http-utils.js +117 -0
  230. package/package.json +1 -1
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.PropertyRepository = void 0;
42
+ const db_1 = require("../db");
43
+ const typedi_1 = require("typedi");
44
+ let PropertyRepository = (() => {
45
+ let _classDecorators = [(0, typedi_1.Service)()];
46
+ let _classDescriptor;
47
+ let _classExtraInitializers = [];
48
+ let _classThis;
49
+ var PropertyRepository = _classThis = class {
50
+ constructor() {
51
+ this.postgres = (0, db_1.getPostgresClient)();
52
+ }
53
+ async getPropertyPreferences(propertyId, keys) {
54
+ try {
55
+ const propertyPreferences = await this.postgres.query(`SELECT * FROM dt_property_settings WHERE "propertyId" = $1`, [propertyId]);
56
+ if (propertyPreferences.rows.length > 0) {
57
+ if (keys && keys.length > 0) {
58
+ const settings = propertyPreferences.rows[0].settings;
59
+ const filteredSettings = {};
60
+ // Only include the requested keys from settings
61
+ keys.forEach((key) => {
62
+ if (settings && settings[key] !== undefined) {
63
+ filteredSettings[key] = settings[key];
64
+ }
65
+ });
66
+ return {
67
+ ...propertyPreferences.rows[0],
68
+ settings: filteredSettings,
69
+ };
70
+ }
71
+ return propertyPreferences.rows[0];
72
+ }
73
+ return null;
74
+ }
75
+ catch (error) {
76
+ console.error("Error in getPropertyPreferences:", error);
77
+ throw new Error("Failed to get property preferences");
78
+ }
79
+ }
80
+ async getProperty(propertyId) {
81
+ const property = await this.postgres.query("SELECT * FROM dt_properties WHERE id = $1", [propertyId]);
82
+ if (property.rows.length > 0) {
83
+ return property.rows[0];
84
+ }
85
+ return null;
86
+ }
87
+ async getAllProperties() {
88
+ try {
89
+ //Retrieve all the properties ids from the database
90
+ const properties = await this.postgres.query("SELECT id FROM dt_properties");
91
+ return properties.rows.map((property) => property.id);
92
+ }
93
+ catch (error) {
94
+ console.log(error);
95
+ throw new Error("Failed to get all properties");
96
+ }
97
+ }
98
+ };
99
+ __setFunctionName(_classThis, "PropertyRepository");
100
+ (() => {
101
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
102
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
103
+ PropertyRepository = _classThis = _classDescriptor.value;
104
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
105
+ __runInitializers(_classThis, _classExtraInitializers);
106
+ })();
107
+ return PropertyRepository = _classThis;
108
+ })();
109
+ exports.PropertyRepository = PropertyRepository;
@@ -0,0 +1,8 @@
1
+ export declare class LocalPropertyService {
2
+ private readonly propertyRepository;
3
+ constructor();
4
+ getPropertyPreferences(propertyId: string, keys?: string[]): Promise<import("./IProperty").IPropertySettings | null>;
5
+ getProperty(propertyId: string): Promise<import("./IProperty").IProperty | null>;
6
+ getPropertyTimeZone(propertyId: string): Promise<string>;
7
+ getAllProperties(): Promise<any[]>;
8
+ }
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
19
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
20
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
21
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
22
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
23
+ var _, done = false;
24
+ for (var i = decorators.length - 1; i >= 0; i--) {
25
+ var context = {};
26
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
27
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
28
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
29
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
30
+ if (kind === "accessor") {
31
+ if (result === void 0) continue;
32
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
33
+ if (_ = accept(result.get)) descriptor.get = _;
34
+ if (_ = accept(result.set)) descriptor.set = _;
35
+ if (_ = accept(result.init)) initializers.unshift(_);
36
+ }
37
+ else if (_ = accept(result)) {
38
+ if (kind === "field") initializers.unshift(_);
39
+ else descriptor[key] = _;
40
+ }
41
+ }
42
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
43
+ done = true;
44
+ };
45
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
46
+ var useValue = arguments.length > 2;
47
+ for (var i = 0; i < initializers.length; i++) {
48
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
49
+ }
50
+ return useValue ? value : void 0;
51
+ };
52
+ var __importStar = (this && this.__importStar) || (function () {
53
+ var ownKeys = function(o) {
54
+ ownKeys = Object.getOwnPropertyNames || function (o) {
55
+ var ar = [];
56
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
57
+ return ar;
58
+ };
59
+ return ownKeys(o);
60
+ };
61
+ return function (mod) {
62
+ if (mod && mod.__esModule) return mod;
63
+ var result = {};
64
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
65
+ __setModuleDefault(result, mod);
66
+ return result;
67
+ };
68
+ })();
69
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
70
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
71
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
72
+ };
73
+ Object.defineProperty(exports, "__esModule", { value: true });
74
+ exports.LocalPropertyService = void 0;
75
+ const Property_repository_1 = require("./Property.repository");
76
+ const typedi_1 = __importStar(require("typedi"));
77
+ let LocalPropertyService = (() => {
78
+ let _classDecorators = [(0, typedi_1.Service)()];
79
+ let _classDescriptor;
80
+ let _classExtraInitializers = [];
81
+ let _classThis;
82
+ var LocalPropertyService = _classThis = class {
83
+ constructor() {
84
+ // Use dependency injection instead of creating new instance
85
+ this.propertyRepository = typedi_1.default.get(Property_repository_1.PropertyRepository);
86
+ }
87
+ async getPropertyPreferences(propertyId, keys) {
88
+ if (!propertyId) {
89
+ throw new Error("Property ID is required");
90
+ }
91
+ return await this.propertyRepository.getPropertyPreferences(propertyId, keys);
92
+ }
93
+ async getProperty(propertyId) {
94
+ if (!propertyId) {
95
+ throw new Error("Property ID is required");
96
+ }
97
+ return await this.propertyRepository.getProperty(propertyId);
98
+ }
99
+ async getPropertyTimeZone(propertyId) {
100
+ if (!propertyId) {
101
+ throw new Error("Property ID is required");
102
+ }
103
+ const property = await this.propertyRepository.getProperty(propertyId);
104
+ if (!property) {
105
+ throw new Error("Property not found");
106
+ }
107
+ return property.timezone;
108
+ }
109
+ async getAllProperties() {
110
+ const properties = await this.propertyRepository.getAllProperties();
111
+ return properties;
112
+ }
113
+ };
114
+ __setFunctionName(_classThis, "LocalPropertyService");
115
+ (() => {
116
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
117
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
118
+ LocalPropertyService = _classThis = _classDescriptor.value;
119
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
120
+ __runInitializers(_classThis, _classExtraInitializers);
121
+ })();
122
+ return LocalPropertyService = _classThis;
123
+ })();
124
+ exports.LocalPropertyService = LocalPropertyService;
@@ -0,0 +1,2 @@
1
+ export * from "./IProperty";
2
+ export * from "./Property.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("./IProperty"), exports);
18
+ __exportStar(require("./Property.service"), exports);
@@ -88,7 +88,8 @@ let HybridHttpQueue = (() => {
88
88
  queueUtils_1.QueueUtils.getOrCreateWorker(queueKey, this.workers, this.processHttpRequest.bind(this), this.jobResults);
89
89
  (0, config_1.getConfig)().LOGGER.info(`Request queued: ${method} ${url} -> ${provider} [${connectionId}]. Job ID: ${jobId}, Delay: ${delay}ms`);
90
90
  // Wait for job completion and return result
91
- return queueUtils_1.QueueUtils.waitForJobCompletion(jobId, queueKey, this.jobResults);
91
+ // Pass the delay so timeout calculation accounts for it
92
+ return queueUtils_1.QueueUtils.waitForJobCompletion(jobId, queueKey, this.jobResults, delay);
92
93
  }
93
94
  async processHttpRequest(job) {
94
95
  const { connectionId, provider, url, method, options } = job.data;
@@ -0,0 +1,9 @@
1
+ import { HttpCallOption } from "../types/http.types";
2
+ export interface IHttpRequestJob {
3
+ connectionId: string;
4
+ provider: string;
5
+ url: string;
6
+ method: string;
7
+ options: HttpCallOption;
8
+ timestamp: number;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -8,5 +8,5 @@ export declare class QueueUtils {
8
8
  static waitForRateLimitExpiry(connectionId: string, provider: string, rateLimitConfigs: Map<string, IRateLimitConfig>): Promise<void>;
9
9
  static executeHttpRequest(url: string, method: string, options: HttpCallOption, connectionId: string, provider: string): Promise<any>;
10
10
  static addJobToQueue(queueKey: string, jobData: any, delay: number, queues: Map<string, any>): Promise<string>;
11
- static waitForJobCompletion(jobId: string, queueKey: string, jobResults: Map<string, any>): Promise<any>;
11
+ static waitForJobCompletion(jobId: string, queueKey: string, jobResults: Map<string, any>, jobDelay?: number): Promise<any>;
12
12
  }
@@ -128,20 +128,33 @@ class QueueUtils {
128
128
  });
129
129
  return job.id;
130
130
  }
131
- static async waitForJobCompletion(jobId, queueKey, jobResults) {
131
+ static async waitForJobCompletion(jobId, queueKey, jobResults, jobDelay = 0) {
132
132
  return new Promise((resolve, reject) => {
133
133
  let timeoutId;
134
+ let backupTimeoutId;
134
135
  let checkCount = 0;
135
- const maxChecks = 600;
136
+ // Calculate timeout: delay + execution buffer
137
+ // Buffer includes: HTTP request timeout (60s) + rate limit wait + processing overhead
138
+ const baseBuffer = queueKey.toLowerCase().includes("cloudbeds")
139
+ ? 180000
140
+ : 90000;
141
+ const totalTimeout = jobDelay + baseBuffer;
142
+ // Calculate max checks based on total timeout
143
+ // Use 50ms for first 10 checks, then 100ms for remaining
144
+ // Max checks should cover the total timeout
145
+ const maxChecks = Math.ceil((totalTimeout - 500) / 100 + 10);
146
+ (0, config_1.getConfig)().LOGGER.info(`Waiting for job ${jobId}: delay=${jobDelay}ms, totalTimeout=${totalTimeout}ms, maxChecks=${maxChecks}`);
136
147
  const checkJob = async () => {
137
148
  if (++checkCount >= maxChecks) {
138
149
  clearTimeout(timeoutId);
139
- return reject(new Error("Job timeout: Request took too long"));
150
+ clearTimeout(backupTimeoutId);
151
+ return reject(new Error(`Job timeout: Request took too long (waited ${totalTimeout}ms, delay was ${jobDelay}ms)`));
140
152
  }
141
153
  try {
142
154
  const memoryResult = jobResults.get(jobId);
143
155
  if (memoryResult?.resolved) {
144
156
  clearTimeout(timeoutId);
157
+ clearTimeout(backupTimeoutId);
145
158
  return memoryResult.result !== undefined
146
159
  ? resolve(memoryResult.result)
147
160
  : reject(new Error(memoryResult.error || "Unknown error"));
@@ -151,16 +164,19 @@ class QueueUtils {
151
164
  }
152
165
  catch (error) {
153
166
  clearTimeout(timeoutId);
167
+ clearTimeout(backupTimeoutId);
154
168
  reject(new Error(`Error checking job: ${error.message}`));
155
169
  }
156
170
  };
157
171
  checkJob();
158
- const waitTime = queueKey.toLowerCase().includes("cloudbeds") ? 180000 : 60000;
159
- // Backup timeout
160
- setTimeout(() => {
172
+ // const waitTime = queueKey.toLowerCase().includes("cloudbeds")
173
+ // ? 180000
174
+ // : 60000;
175
+ // Backup timeout with the calculated total timeout
176
+ backupTimeoutId = setTimeout(() => {
161
177
  clearTimeout(timeoutId);
162
- reject(new Error("Request timeout: Maximum wait time exceeded"));
163
- }, waitTime);
178
+ reject(new Error(`Request timeout: Maximum wait time exceeded (${totalTimeout}ms). Job delay was ${jobDelay}ms.`));
179
+ }, totalTimeout);
164
180
  });
165
181
  }
166
182
  }
@@ -76,7 +76,7 @@ class RateLimitUtils {
76
76
  maxTimeoutWindowMs: 120000,
77
77
  });
78
78
  configs.set(constants_1.CONNECTION_PROVIDERS.SMARTTHINGS, {
79
- maxRequests: 12,
79
+ maxRequests: 30,
80
80
  windowMs: 60000, // 1 minute
81
81
  provider: constants_1.CONNECTION_PROVIDERS.SMARTTHINGS,
82
82
  maxTimeoutWindowMs: 120000,
@@ -0,0 +1,57 @@
1
+ import { EntityType } from "./issue.types";
2
+ export declare enum AlertCategory {
3
+ READINESS = "READINESS",
4
+ OPERATIONS = "OPERATIONS",
5
+ SECURITY = "SECURITY",
6
+ ENERGY = "ENERGY",
7
+ OTHER = "OTHER"
8
+ }
9
+ export declare enum AlertSeverity {
10
+ INFO = "INFO",
11
+ LOW = "LOW",
12
+ MEDIUM = "MEDIUM",
13
+ HIGH = "HIGH",
14
+ CRITICAL = "CRITICAL"
15
+ }
16
+ export interface AlertDocument {
17
+ _id: string;
18
+ category: AlertCategory;
19
+ propertyId: string;
20
+ title: string;
21
+ description: string;
22
+ entityId?: string;
23
+ entityType: EntityType;
24
+ severity: AlertSeverity;
25
+ isRead: boolean;
26
+ isActive: boolean;
27
+ isDeleted: boolean;
28
+ snoozeUntil?: Date;
29
+ createdBy?: string;
30
+ updatedBy?: string;
31
+ createdAt: Date;
32
+ updatedAt: Date;
33
+ }
34
+ export interface CreateAlertData {
35
+ category: AlertCategory;
36
+ propertyId: string;
37
+ title: string;
38
+ description: string;
39
+ entityId?: string;
40
+ entityType: EntityType;
41
+ severity?: AlertSeverity;
42
+ createdBy?: string;
43
+ snoozeUntil?: Date;
44
+ }
45
+ export interface UpdateAlertData {
46
+ category?: AlertCategory;
47
+ title?: string;
48
+ description?: string;
49
+ entityId?: string;
50
+ entityType?: EntityType;
51
+ severity?: AlertSeverity;
52
+ isRead?: boolean;
53
+ isActive?: boolean;
54
+ snoozeUntil?: Date;
55
+ updatedBy?: string;
56
+ }
57
+ export { EntityType } from "./issue.types";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityType = exports.AlertSeverity = exports.AlertCategory = void 0;
4
+ var AlertCategory;
5
+ (function (AlertCategory) {
6
+ AlertCategory["READINESS"] = "READINESS";
7
+ AlertCategory["OPERATIONS"] = "OPERATIONS";
8
+ AlertCategory["SECURITY"] = "SECURITY";
9
+ AlertCategory["ENERGY"] = "ENERGY";
10
+ AlertCategory["OTHER"] = "OTHER";
11
+ })(AlertCategory || (exports.AlertCategory = AlertCategory = {}));
12
+ var AlertSeverity;
13
+ (function (AlertSeverity) {
14
+ AlertSeverity["INFO"] = "INFO";
15
+ AlertSeverity["LOW"] = "LOW";
16
+ AlertSeverity["MEDIUM"] = "MEDIUM";
17
+ AlertSeverity["HIGH"] = "HIGH";
18
+ AlertSeverity["CRITICAL"] = "CRITICAL";
19
+ })(AlertSeverity || (exports.AlertSeverity = AlertSeverity = {}));
20
+ // Re-export EntityType from issue.types.ts to avoid duplication
21
+ var issue_types_1 = require("./issue.types");
22
+ Object.defineProperty(exports, "EntityType", { enumerable: true, get: function () { return issue_types_1.EntityType; } });
@@ -0,0 +1,19 @@
1
+ import { IInternalEvent } from "../events/interfaces/IInternalEvent";
2
+ export interface ILogger {
3
+ info(message: string, ...args: any[]): void;
4
+ warn(message: string, ...args: any[]): void;
5
+ error(message: string, ...args: any[]): void;
6
+ }
7
+ type AllowedSource = "ACCESS_SERVICE" | "ADMIN_SERVICE" | "ENERGY_SERVICE";
8
+ export type DeviceConfig = {
9
+ SOURCE: AllowedSource;
10
+ SQS_QUEUE_URL: string;
11
+ DEVICE_SERVICE?: string;
12
+ ADMIN_SERVICE?: string;
13
+ ACCESS_SERVICE?: string;
14
+ ENERGY_SERVICE?: string;
15
+ INTERNAL_EVENT_HANDLER: IInternalEvent;
16
+ LOGGER: ILogger;
17
+ [key: string]: any;
18
+ };
19
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from "./config.types";
2
+ export * from "./issue.types";
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("./config.types"), exports);
18
+ __exportStar(require("./issue.types"), exports);
19
+ __exportStar(require("./alert.types"), exports);
@@ -0,0 +1,90 @@
1
+ export declare enum IssuesCategory {
2
+ READINESS = "READINESS",
3
+ OPERATIONS = "OPERATIONS",
4
+ SECURITY = "SECURITY",
5
+ ENERGY = "ENERGY",
6
+ OTHER = "OTHER"
7
+ }
8
+ export declare enum EntityType {
9
+ DEVICE = "DEVICE",
10
+ COLLECTION = "COLLECTION",
11
+ USER = "USER",
12
+ INTEGRATION = "INTEGRATION",
13
+ PROPERTY = "PROPERTY",
14
+ HUB = "HUB",
15
+ SCHEDULE = "SCHEDULE",
16
+ ALERT = "ALERT",
17
+ OTHER = "OTHER"
18
+ }
19
+ export declare enum IssueStatus {
20
+ PENDING = "PENDING",
21
+ IN_PROGRESS = "IN_PROGRESS",
22
+ RESOLVED = "RESOLVED",
23
+ CLOSED = "CLOSED",
24
+ CANCELLED = "CANCELLED",
25
+ ON_HOLD = "ON_HOLD"
26
+ }
27
+ export declare enum IssuePriority {
28
+ LOW = "LOW",
29
+ MEDIUM = "MEDIUM",
30
+ HIGH = "HIGH",
31
+ CRITICAL = "CRITICAL",
32
+ URGENT = "URGENT"
33
+ }
34
+ export interface IssueComment {
35
+ id: string;
36
+ userId: string;
37
+ content: string;
38
+ createdAt: Date;
39
+ updatedAt?: Date;
40
+ }
41
+ export interface IssueDocument {
42
+ _id: string;
43
+ category: IssuesCategory;
44
+ propertyId: string;
45
+ title: string;
46
+ description: string;
47
+ entityId?: string;
48
+ entityType: EntityType;
49
+ status: IssueStatus;
50
+ priority: IssuePriority;
51
+ assignedTo?: string;
52
+ createdBy: string;
53
+ updatedBy?: string;
54
+ isDeleted: boolean;
55
+ createdAt: Date;
56
+ updatedAt: Date;
57
+ resolvedAt?: Date;
58
+ dueDate?: Date;
59
+ comments?: IssueComment[];
60
+ }
61
+ export interface CreateIssueData {
62
+ category: IssuesCategory;
63
+ propertyId: string;
64
+ title: string;
65
+ description: string;
66
+ entityId?: string;
67
+ entityType: EntityType;
68
+ priority?: IssuePriority;
69
+ assignedTo?: string;
70
+ createdBy: string;
71
+ dueDate?: Date;
72
+ }
73
+ export interface UpdateIssueData {
74
+ category?: IssuesCategory;
75
+ title?: string;
76
+ description?: string;
77
+ entityId?: string;
78
+ entityType?: EntityType;
79
+ status?: IssueStatus;
80
+ priority?: IssuePriority;
81
+ assignedTo?: string;
82
+ updatedBy: string;
83
+ resolvedAt?: Date;
84
+ dueDate?: Date;
85
+ isDeleted?: boolean;
86
+ }
87
+ export interface AddCommentData {
88
+ userId: string;
89
+ content: string;
90
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IssuePriority = exports.IssueStatus = exports.EntityType = exports.IssuesCategory = void 0;
4
+ var IssuesCategory;
5
+ (function (IssuesCategory) {
6
+ IssuesCategory["READINESS"] = "READINESS";
7
+ IssuesCategory["OPERATIONS"] = "OPERATIONS";
8
+ IssuesCategory["SECURITY"] = "SECURITY";
9
+ IssuesCategory["ENERGY"] = "ENERGY";
10
+ IssuesCategory["OTHER"] = "OTHER";
11
+ })(IssuesCategory || (exports.IssuesCategory = IssuesCategory = {}));
12
+ var EntityType;
13
+ (function (EntityType) {
14
+ EntityType["DEVICE"] = "DEVICE";
15
+ EntityType["COLLECTION"] = "COLLECTION";
16
+ EntityType["USER"] = "USER";
17
+ EntityType["INTEGRATION"] = "INTEGRATION";
18
+ EntityType["PROPERTY"] = "PROPERTY";
19
+ EntityType["HUB"] = "HUB";
20
+ EntityType["SCHEDULE"] = "SCHEDULE";
21
+ EntityType["ALERT"] = "ALERT";
22
+ EntityType["OTHER"] = "OTHER";
23
+ })(EntityType || (exports.EntityType = EntityType = {}));
24
+ var IssueStatus;
25
+ (function (IssueStatus) {
26
+ IssueStatus["PENDING"] = "PENDING";
27
+ IssueStatus["IN_PROGRESS"] = "IN_PROGRESS";
28
+ IssueStatus["RESOLVED"] = "RESOLVED";
29
+ IssueStatus["CLOSED"] = "CLOSED";
30
+ IssueStatus["CANCELLED"] = "CANCELLED";
31
+ IssueStatus["ON_HOLD"] = "ON_HOLD";
32
+ })(IssueStatus || (exports.IssueStatus = IssueStatus = {}));
33
+ var IssuePriority;
34
+ (function (IssuePriority) {
35
+ IssuePriority["LOW"] = "LOW";
36
+ IssuePriority["MEDIUM"] = "MEDIUM";
37
+ IssuePriority["HIGH"] = "HIGH";
38
+ IssuePriority["CRITICAL"] = "CRITICAL";
39
+ IssuePriority["URGENT"] = "URGENT";
40
+ })(IssuePriority || (exports.IssuePriority = IssuePriority = {}));
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Validates if a URL is properly formatted and accessible
3
+ */
4
+ export declare function validateServiceUrl(url: string): boolean;
5
+ /**
6
+ * Creates a properly configured axios instance with error handling
7
+ */
8
+ export declare function createAxiosInstance(baseURL?: string): import("axios").AxiosInstance;
9
+ export declare function getDeviceServiceAxiosInstance(): any;
10
+ /**
11
+ * Retry function for failed HTTP requests
12
+ */
13
+ export declare function retryRequest<T>(requestFn: () => Promise<T>, maxRetries?: number, delay?: number): Promise<T>;