dt-common-device 11.2.2 → 11.3.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 (233) hide show
  1. package/dist/chronicle/Cronicle.service.d.ts +6 -2
  2. package/dist/chronicle/Cronicle.service.js +19 -2
  3. package/dist/chronicle/ICronicle.interface.d.ts +1 -0
  4. package/dist/constants/ConnectionProviders.d.ts +1 -0
  5. package/dist/constants/ConnectionProviders.js +1 -0
  6. package/dist/entities/accessGroup/AccessGroup.repository.d.ts +2 -1
  7. package/dist/entities/accessGroup/AccessGroup.repository.js +4 -1
  8. package/dist/entities/accessGroup/AccessGroup.service.d.ts +2 -1
  9. package/dist/entities/accessGroup/AccessGroup.service.js +4 -3
  10. package/dist/entities/guest/Guest.repository.d.ts +1 -1
  11. package/dist/entities/guest/Guest.repository.js +5 -2
  12. package/dist/entities/guest/Guest.service.d.ts +1 -1
  13. package/dist/entities/guest/Guest.service.js +4 -1
  14. package/dist/entities/pms/IPms.d.ts +2 -1
  15. package/dist/entities/pms/IPms.js +1 -0
  16. package/dist/entities/schedules/Schedule.repository.d.ts +1 -1
  17. package/dist/entities/schedules/Schedule.repository.js +5 -2
  18. package/dist/entities/schedules/Schedule.service.d.ts +1 -1
  19. package/dist/entities/schedules/Schedule.service.js +4 -1
  20. package/dist/entities/user/User.repository.js +4 -1
  21. package/dist/entities/user/User.service.d.ts +1 -1
  22. package/dist/entities/user/User.service.js +4 -1
  23. package/dist/entities/zone/Zone.service.js +4 -1
  24. package/dist/issues/issue.types.d.ts +1 -0
  25. package/dist/issues/issue.types.js +1 -0
  26. package/dist/queue/utils/rateLimit.utils.js +6 -0
  27. package/package.json +1 -1
  28. package/dist/admin/Admin.repository.d.ts +0 -7
  29. package/dist/admin/Admin.repository.js +0 -182
  30. package/dist/admin/Admin.service.d.ts +0 -5
  31. package/dist/admin/Admin.service.js +0 -17
  32. package/dist/admin/index.d.ts +0 -1
  33. package/dist/admin/index.js +0 -17
  34. package/dist/audit/AuditProperties.d.ts +0 -16
  35. package/dist/audit/AuditProperties.js +0 -2
  36. package/dist/chronicle/IChronicle.interface.d.ts +0 -14
  37. package/dist/chronicle/IChronicle.interface.js +0 -2
  38. package/dist/chronicle/chronicle.service.d.ts +0 -4
  39. package/dist/chronicle/chronicle.service.js +0 -44
  40. package/dist/connection/Connection.repository.d.ts +0 -8
  41. package/dist/connection/Connection.repository.js +0 -92
  42. package/dist/connection/Connection.service.d.ts +0 -8
  43. package/dist/connection/Connection.service.js +0 -32
  44. package/dist/connection/IConnection.d.ts +0 -28
  45. package/dist/connection/IConnection.js +0 -16
  46. package/dist/connection/index.d.ts +0 -2
  47. package/dist/connection/index.js +0 -18
  48. package/dist/copilotQueue/examples/CopilotQueue.example.d.ts +0 -37
  49. package/dist/copilotQueue/examples/CopilotQueue.example.js +0 -140
  50. package/dist/copilotQueue/examples/index.d.ts +0 -1
  51. package/dist/copilotQueue/examples/index.js +0 -17
  52. package/dist/device/cloud/entities/CloudConnection.d.ts +0 -6
  53. package/dist/device/cloud/entities/CloudConnection.js +0 -6
  54. package/dist/device/cloud/entities/CloudDevice.d.ts +0 -16
  55. package/dist/device/cloud/entities/CloudDevice.js +0 -26
  56. package/dist/device/cloud/entities/CloudDeviceService.d.ts +0 -5
  57. package/dist/device/cloud/entities/CloudDeviceService.js +0 -9
  58. package/dist/device/cloud/entities/DeviceFactory.d.ts +0 -7
  59. package/dist/device/cloud/entities/DeviceFactory.js +0 -80
  60. package/dist/device/cloud/entities/index.d.ts +0 -3
  61. package/dist/device/cloud/entities/index.js +0 -19
  62. package/dist/device/cloud/interface.d.ts +0 -101
  63. package/dist/device/cloud/interface.js +0 -3
  64. package/dist/device/cloud/interfaces/ICloudConnection.d.ts +0 -5
  65. package/dist/device/cloud/interfaces/ICloudConnection.js +0 -2
  66. package/dist/device/cloud/interfaces/ICloudDevice.d.ts +0 -9
  67. package/dist/device/cloud/interfaces/ICloudDevice.js +0 -2
  68. package/dist/device/cloud/interfaces/ICloudDeviceService.d.ts +0 -4
  69. package/dist/device/cloud/interfaces/ICloudDeviceService.js +0 -2
  70. package/dist/device/cloud/interfaces/IConnectionService.d.ts +0 -7
  71. package/dist/device/cloud/interfaces/IConnectionService.js +0 -2
  72. package/dist/device/cloud/interfaces/IDeviceConnectionService.d.ts +0 -7
  73. package/dist/device/cloud/interfaces/IDeviceConnectionService.js +0 -3
  74. package/dist/device/cloud/interfaces/IDeviceFactory.d.ts +0 -4
  75. package/dist/device/cloud/interfaces/IDeviceFactory.js +0 -2
  76. package/dist/device/cloud/interfaces/IDeviceService.d.ts +0 -8
  77. package/dist/device/cloud/interfaces/IDeviceService.js +0 -2
  78. package/dist/device/cloud/interfaces/IDevicesService.d.ts +0 -9
  79. package/dist/device/cloud/interfaces/IDevicesService.js +0 -2
  80. package/dist/device/cloud/interfaces/IHubService.d.ts +0 -5
  81. package/dist/device/cloud/interfaces/IHubService.js +0 -2
  82. package/dist/device/cloud/interfaces/IRawDataTransformer.d.ts +0 -4
  83. package/dist/device/cloud/interfaces/IRawDataTransformer.js +0 -2
  84. package/dist/device/cloud/interfaces/IRawDevice.d.ts +0 -17
  85. package/dist/device/cloud/interfaces/IRawDevice.js +0 -11
  86. package/dist/device/cloud/interfaces/index.d.ts +0 -5
  87. package/dist/device/cloud/interfaces/index.js +0 -21
  88. package/dist/device/cloud/services/CloudDevice.service.d.ts +0 -5
  89. package/dist/device/cloud/services/CloudDevice.service.js +0 -9
  90. package/dist/device/cloud/services/Connection.service.d.ts +0 -8
  91. package/dist/device/cloud/services/Connection.service.js +0 -6
  92. package/dist/device/cloud/services/Device.service.d.ts +0 -39
  93. package/dist/device/cloud/services/Device.service.js +0 -9
  94. package/dist/device/cloud/services/DeviceCloudService.d.ts +0 -42
  95. package/dist/device/cloud/services/DeviceCloudService.js +0 -59
  96. package/dist/device/cloud/services/DeviceHub.service.d.ts +0 -3
  97. package/dist/device/cloud/services/DeviceHub.service.js +0 -6
  98. package/dist/device/cloud/services/Hub.service.d.ts +0 -25
  99. package/dist/device/cloud/services/Hub.service.js +0 -9
  100. package/dist/device/cloud/services/SmartThingsDeviceService.d.ts +0 -38
  101. package/dist/device/cloud/services/SmartThingsDeviceService.js +0 -52
  102. package/dist/device/cloud/services/index.d.ts +0 -2
  103. package/dist/device/cloud/services/index.js +0 -18
  104. package/dist/device/cloud/types.d.ts +0 -52
  105. package/dist/device/cloud/types.js +0 -15
  106. package/dist/device/index.d.ts +0 -4
  107. package/dist/device/index.js +0 -20
  108. package/dist/device/local/entities/AlertBuilder.d.ts +0 -87
  109. package/dist/device/local/entities/AlertBuilder.example.d.ts +0 -11
  110. package/dist/device/local/entities/AlertBuilder.example.js +0 -117
  111. package/dist/device/local/entities/AlertBuilder.js +0 -179
  112. package/dist/device/local/entities/IssueBuilder.d.ts +0 -109
  113. package/dist/device/local/entities/IssueBuilder.example.d.ts +0 -16
  114. package/dist/device/local/entities/IssueBuilder.example.js +0 -196
  115. package/dist/device/local/entities/IssueBuilder.js +0 -237
  116. package/dist/device/local/entities/index.d.ts +0 -2
  117. package/dist/device/local/entities/index.js +0 -7
  118. package/dist/device/local/events/EventHandler.d.ts +0 -11
  119. package/dist/device/local/events/EventHandler.js +0 -86
  120. package/dist/device/local/events/Events.d.ts +0 -54
  121. package/dist/device/local/events/Events.js +0 -57
  122. package/dist/device/local/events/index.d.ts +0 -2
  123. package/dist/device/local/events/index.js +0 -7
  124. package/dist/device/local/handler/EventHandler.d.ts +0 -7
  125. package/dist/device/local/handler/EventHandler.js +0 -44
  126. package/dist/device/local/interface.d.ts +0 -0
  127. package/dist/device/local/interface.js +0 -1
  128. package/dist/device/local/interfaces/IConnection.d.ts +0 -26
  129. package/dist/device/local/interfaces/IConnection.js +0 -14
  130. package/dist/device/local/interfaces/IDevice.d.ts +0 -68
  131. package/dist/device/local/interfaces/IDevice.js +0 -10
  132. package/dist/device/local/interfaces/IDtDevice.d.ts +0 -16
  133. package/dist/device/local/interfaces/IDtDevice.js +0 -2
  134. package/dist/device/local/interfaces/IHub.d.ts +0 -46
  135. package/dist/device/local/interfaces/IHub.js +0 -2
  136. package/dist/device/local/interfaces/IProperty.d.ts +0 -29
  137. package/dist/device/local/interfaces/IProperty.js +0 -2
  138. package/dist/device/local/interfaces/ISchedule.d.ts +0 -25
  139. package/dist/device/local/interfaces/ISchedule.js +0 -2
  140. package/dist/device/local/interfaces/index.d.ts +0 -3
  141. package/dist/device/local/interfaces/index.js +0 -19
  142. package/dist/device/local/models/Alert.model.d.ts +0 -28
  143. package/dist/device/local/models/Alert.model.js +0 -222
  144. package/dist/device/local/models/Issue.model.d.ts +0 -28
  145. package/dist/device/local/models/Issue.model.js +0 -260
  146. package/dist/device/local/repository/Alert.repository.d.ts +0 -106
  147. package/dist/device/local/repository/Alert.repository.js +0 -374
  148. package/dist/device/local/repository/Connection.repository.d.ts +0 -8
  149. package/dist/device/local/repository/Connection.repository.js +0 -92
  150. package/dist/device/local/repository/Device.repository.d.ts +0 -30
  151. package/dist/device/local/repository/Device.repository.js +0 -325
  152. package/dist/device/local/repository/Hub.repository.d.ts +0 -13
  153. package/dist/device/local/repository/Hub.repository.js +0 -139
  154. package/dist/device/local/repository/Issue.repository.d.ts +0 -113
  155. package/dist/device/local/repository/Issue.repository.js +0 -401
  156. package/dist/device/local/repository/Property.repository.d.ts +0 -8
  157. package/dist/device/local/repository/Property.repository.js +0 -95
  158. package/dist/device/local/repository/Schedule.repository.d.ts +0 -9
  159. package/dist/device/local/repository/Schedule.repository.js +0 -109
  160. package/dist/device/local/services/Alert.service.d.ts +0 -137
  161. package/dist/device/local/services/Alert.service.js +0 -475
  162. package/dist/device/local/services/AlertService.example.d.ts +0 -55
  163. package/dist/device/local/services/AlertService.example.js +0 -148
  164. package/dist/device/local/services/Connection.service.d.ts +0 -8
  165. package/dist/device/local/services/Connection.service.js +0 -32
  166. package/dist/device/local/services/Device.service.d.ts +0 -40
  167. package/dist/device/local/services/Device.service.js +0 -391
  168. package/dist/device/local/services/DeviceHub.service.d.ts +0 -11
  169. package/dist/device/local/services/DeviceHub.service.js +0 -40
  170. package/dist/device/local/services/Hub.service.d.ts +0 -12
  171. package/dist/device/local/services/Hub.service.js +0 -107
  172. package/dist/device/local/services/Issue.service.d.ts +0 -168
  173. package/dist/device/local/services/Issue.service.js +0 -642
  174. package/dist/device/local/services/IssueService.example.d.ts +0 -68
  175. package/dist/device/local/services/IssueService.example.js +0 -177
  176. package/dist/device/local/services/Property.service.d.ts +0 -8
  177. package/dist/device/local/services/Property.service.js +0 -36
  178. package/dist/device/local/services/Schedule.service.d.ts +0 -9
  179. package/dist/device/local/services/Schedule.service.js +0 -26
  180. package/dist/device/local/services/index.d.ts +0 -3
  181. package/dist/device/local/services/index.js +0 -19
  182. package/dist/pms/IPms.d.ts +0 -6
  183. package/dist/pms/IPms.js +0 -10
  184. package/dist/pms/index.d.ts +0 -1
  185. package/dist/pms/index.js +0 -18
  186. package/dist/pms/webhookQueue/examples/index.d.ts +0 -2
  187. package/dist/pms/webhookQueue/examples/index.js +0 -18
  188. package/dist/pms/webhookQueue/examples/pms-integration.d.ts +0 -65
  189. package/dist/pms/webhookQueue/examples/pms-integration.js +0 -254
  190. package/dist/pms/webhookQueue/examples/usage.d.ts +0 -7
  191. package/dist/pms/webhookQueue/examples/usage.js +0 -175
  192. package/dist/pms/webhookQueue/index.d.ts +0 -3
  193. package/dist/pms/webhookQueue/index.js +0 -20
  194. package/dist/pms/webhookQueue/interfaces/IWebhookQueue.d.ts +0 -33
  195. package/dist/pms/webhookQueue/interfaces/IWebhookQueue.js +0 -2
  196. package/dist/pms/webhookQueue/interfaces/IWebhookWorker.d.ts +0 -38
  197. package/dist/pms/webhookQueue/interfaces/IWebhookWorker.js +0 -2
  198. package/dist/pms/webhookQueue/interfaces/index.d.ts +0 -1
  199. package/dist/pms/webhookQueue/interfaces/index.js +0 -17
  200. package/dist/pms/webhookQueue/services/WebhookQueueFactory.d.ts +0 -38
  201. package/dist/pms/webhookQueue/services/WebhookQueueFactory.js +0 -131
  202. package/dist/pms/webhookQueue/services/WebhookQueueIntegration.d.ts +0 -70
  203. package/dist/pms/webhookQueue/services/WebhookQueueIntegration.js +0 -207
  204. package/dist/pms/webhookQueue/services/WebhookQueueService.d.ts +0 -45
  205. package/dist/pms/webhookQueue/services/WebhookQueueService.js +0 -270
  206. package/dist/pms/webhookQueue/services/WebhookWorker.d.ts +0 -37
  207. package/dist/pms/webhookQueue/services/WebhookWorker.js +0 -201
  208. package/dist/pms/webhookQueue/services/index.d.ts +0 -1
  209. package/dist/pms/webhookQueue/services/index.js +0 -17
  210. package/dist/pms/webhookQueue/types/index.d.ts +0 -1
  211. package/dist/pms/webhookQueue/types/index.js +0 -17
  212. package/dist/pms/webhookQueue/types/webhook.types.d.ts +0 -39
  213. package/dist/pms/webhookQueue/types/webhook.types.js +0 -2
  214. package/dist/property/IProperty.d.ts +0 -29
  215. package/dist/property/IProperty.js +0 -2
  216. package/dist/property/Property.repository.d.ts +0 -8
  217. package/dist/property/Property.repository.js +0 -109
  218. package/dist/property/Property.service.d.ts +0 -8
  219. package/dist/property/Property.service.js +0 -124
  220. package/dist/property/index.d.ts +0 -2
  221. package/dist/property/index.js +0 -18
  222. package/dist/queue/interfaces/IHttpRequestJob.d.ts +0 -9
  223. package/dist/queue/interfaces/IHttpRequestJob.js +0 -2
  224. package/dist/types/alert.types.d.ts +0 -57
  225. package/dist/types/alert.types.js +0 -22
  226. package/dist/types/config.types.d.ts +0 -19
  227. package/dist/types/config.types.js +0 -2
  228. package/dist/types/index.d.ts +0 -3
  229. package/dist/types/index.js +0 -19
  230. package/dist/types/issue.types.d.ts +0 -90
  231. package/dist/types/issue.types.js +0 -40
  232. package/dist/utils/http-utils.d.ts +0 -13
  233. package/dist/utils/http-utils.js +0 -117
@@ -1,109 +0,0 @@
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;
@@ -1,8 +0,0 @@
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
- }
@@ -1,124 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- export * from "./IProperty";
2
- export * from "./Property.service";
@@ -1,18 +0,0 @@
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);
@@ -1,9 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,57 +0,0 @@
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";
@@ -1,22 +0,0 @@
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; } });
@@ -1,19 +0,0 @@
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 {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- export * from "./config.types";
2
- export * from "./issue.types";
3
- export * from "./alert.types";
@@ -1,19 +0,0 @@
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);
@@ -1,90 +0,0 @@
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
- }
@@ -1,40 +0,0 @@
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 = {}));
@@ -1,13 +0,0 @@
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>;
@@ -1,117 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateServiceUrl = validateServiceUrl;
7
- exports.createAxiosInstance = createAxiosInstance;
8
- exports.getDeviceServiceAxiosInstance = getDeviceServiceAxiosInstance;
9
- exports.retryRequest = retryRequest;
10
- const config_1 = require("../config/config");
11
- const axios_1 = __importDefault(require("axios"));
12
- /**
13
- * Validates if a URL is properly formatted and accessible
14
- */
15
- function validateServiceUrl(url) {
16
- try {
17
- const parsedUrl = new URL(url);
18
- return parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:";
19
- }
20
- catch (error) {
21
- (0, config_1.getConfig)().LOGGER.error(`Invalid service URL: ${url}`, error);
22
- return false;
23
- }
24
- }
25
- /**
26
- * Creates a properly configured axios instance with error handling
27
- */
28
- function createAxiosInstance(baseURL) {
29
- const instance = axios_1.default.create({
30
- baseURL,
31
- timeout: 30000, // 30 seconds timeout
32
- maxRedirects: 5,
33
- validateStatus: (status) => status < 500, // Don't throw on 4xx errors
34
- headers: {
35
- "Content-Type": "application/json",
36
- "User-Agent": "dt-common-device/1.3.0",
37
- },
38
- });
39
- // Add request interceptor for logging
40
- instance.interceptors.request.use((config) => {
41
- const logger = (0, config_1.getConfig)().LOGGER;
42
- logger.info(`Making request to: ${config.method?.toUpperCase()} ${config.url}`, {
43
- baseURL: config.baseURL,
44
- timeout: config.timeout,
45
- });
46
- return config;
47
- }, (error) => {
48
- (0, config_1.getConfig)().LOGGER.error("Request interceptor error:", error);
49
- return Promise.reject(error);
50
- });
51
- // Add response interceptor for error handling
52
- instance.interceptors.response.use((response) => {
53
- return response;
54
- }, (error) => {
55
- const logger = (0, config_1.getConfig)().LOGGER;
56
- const errorInfo = {
57
- url: error.config?.url,
58
- method: error.config?.method,
59
- status: error.response?.status,
60
- statusText: error.response?.statusText,
61
- message: error.message,
62
- code: error.code,
63
- baseURL: error.config?.baseURL,
64
- };
65
- logger.error("HTTP request failed:", errorInfo);
66
- // Log additional details for network errors
67
- if (error.code === "ECONNREFUSED" || error.code === "ENOTFOUND") {
68
- logger.error("Network connectivity issue detected. Please check:", {
69
- serviceUrl: error.config?.baseURL,
70
- errorCode: error.code,
71
- errorMessage: error.message,
72
- });
73
- }
74
- return Promise.reject(error);
75
- });
76
- return instance;
77
- }
78
- /**
79
- * Centralized axios instance for device service
80
- */
81
- let deviceServiceAxiosInstance = null;
82
- function getDeviceServiceAxiosInstance() {
83
- if (!deviceServiceAxiosInstance) {
84
- const { DEVICE_SERVICE } = (0, config_1.getConfig)();
85
- if (!DEVICE_SERVICE) {
86
- throw new Error("DEVICE_SERVICE is not configured. Call initialize() first with DEVICE_SERVICE.");
87
- }
88
- deviceServiceAxiosInstance = createAxiosInstance(DEVICE_SERVICE);
89
- }
90
- return deviceServiceAxiosInstance;
91
- }
92
- /**
93
- * Retry function for failed HTTP requests
94
- */
95
- async function retryRequest(requestFn, maxRetries = 3, delay = 1000) {
96
- let lastError;
97
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
98
- try {
99
- return await requestFn();
100
- }
101
- catch (error) {
102
- lastError = error;
103
- if (attempt === maxRetries) {
104
- (0, config_1.getConfig)().LOGGER.error(`Request failed after ${maxRetries} attempts:`, error);
105
- throw error;
106
- }
107
- (0, config_1.getConfig)().LOGGER.warn(`Request attempt ${attempt} failed, retrying in ${delay}ms:`, {
108
- error: error.message,
109
- attempt,
110
- maxRetries,
111
- });
112
- await new Promise((resolve) => setTimeout(resolve, delay));
113
- delay *= 2; // Exponential backoff
114
- }
115
- }
116
- throw lastError;
117
- }