dt-common-device 2.0.7 → 3.0.1

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 (211) hide show
  1. package/README.md +352 -98
  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/interface.d.ts +101 -0
  35. package/dist/device/cloud/interface.js +3 -0
  36. package/dist/device/cloud/interfaces/ICloudDeviceService.d.ts +1 -1
  37. package/dist/device/cloud/interfaces/IDeviceConnectionService.d.ts +7 -0
  38. package/dist/device/cloud/interfaces/IDeviceConnectionService.js +3 -0
  39. package/dist/device/cloud/interfaces/IDevicesService.d.ts +9 -0
  40. package/dist/device/cloud/interfaces/IDevicesService.js +2 -0
  41. package/dist/device/cloud/interfaces/IRawDevice.d.ts +1 -1
  42. package/dist/device/cloud/services/Device.service.d.ts +39 -0
  43. package/dist/device/cloud/services/Device.service.js +9 -0
  44. package/dist/device/cloud/services/DeviceCloudService.d.ts +42 -0
  45. package/dist/device/cloud/services/DeviceCloudService.js +59 -0
  46. package/dist/device/cloud/services/DeviceHub.service.d.ts +3 -0
  47. package/dist/device/cloud/services/DeviceHub.service.js +6 -0
  48. package/dist/device/cloud/services/Hub.service.d.ts +25 -0
  49. package/dist/device/cloud/services/Hub.service.js +9 -0
  50. package/dist/device/cloud/services/SmartThingsDeviceService.d.ts +38 -0
  51. package/dist/device/cloud/services/SmartThingsDeviceService.js +52 -0
  52. package/dist/device/index.d.ts +4 -0
  53. package/dist/device/index.js +20 -0
  54. package/dist/device/local/events/EventHandler.js +6 -6
  55. package/dist/device/local/events/Events.d.ts +12 -33
  56. package/dist/device/local/events/Events.js +12 -33
  57. package/dist/device/local/interface.d.ts +0 -0
  58. package/dist/device/local/interface.js +1 -0
  59. package/dist/device/local/interfaces/index.d.ts +2 -3
  60. package/dist/device/local/interfaces/index.js +2 -3
  61. package/dist/device/local/repository/Device.repository.js +3 -3
  62. package/dist/device/local/repository/Hub.repository.js +4 -4
  63. package/dist/device/local/repository/Schedule.repository.js +2 -2
  64. package/dist/device/local/services/Device.service.d.ts +2 -2
  65. package/dist/device/local/services/Device.service.js +1 -1
  66. package/dist/device/local/services/DeviceHub.service.d.ts +11 -0
  67. package/dist/device/local/services/DeviceHub.service.js +40 -0
  68. package/dist/device/local/services/index.d.ts +0 -4
  69. package/dist/device/local/services/index.js +0 -4
  70. package/dist/events/BaseEventHandler.d.ts +2 -2
  71. package/dist/events/BaseEventHandler.js +2 -2
  72. package/dist/events/BaseEventTransformer.d.ts +1 -1
  73. package/dist/events/BaseEventTransformer.js +1 -1
  74. package/dist/events/DeviceEventHandler.d.ts +1 -1
  75. package/dist/events/DeviceEventHandler.js +2 -2
  76. package/dist/events/EventHandler.js +1 -1
  77. package/dist/events/EventHandlerOrchestrator.js +1 -1
  78. package/dist/events/EventProcessingService.js +1 -1
  79. package/dist/events/InternalEventSubscription.js +1 -1
  80. package/dist/index.d.ts +7 -5
  81. package/dist/index.js +16 -13
  82. package/dist/issues/Issue.model.d.ts +28 -0
  83. package/dist/issues/Issue.model.js +260 -0
  84. package/dist/issues/Issue.repository.d.ts +113 -0
  85. package/dist/issues/Issue.repository.js +401 -0
  86. package/dist/issues/Issue.service.d.ts +168 -0
  87. package/dist/issues/Issue.service.js +642 -0
  88. package/dist/issues/IssueBuilder.d.ts +109 -0
  89. package/dist/issues/IssueBuilder.example.d.ts +16 -0
  90. package/dist/issues/IssueBuilder.example.js +196 -0
  91. package/dist/issues/IssueBuilder.js +237 -0
  92. package/dist/issues/IssueService.example.d.ts +68 -0
  93. package/dist/issues/IssueService.example.js +177 -0
  94. package/dist/issues/index.d.ts +2 -0
  95. package/dist/issues/index.js +18 -0
  96. package/dist/issues/issue.types.d.ts +90 -0
  97. package/dist/issues/issue.types.js +40 -0
  98. package/dist/property/IProperty.d.ts +29 -0
  99. package/dist/property/IProperty.js +2 -0
  100. package/dist/property/Property.repository.d.ts +8 -0
  101. package/dist/property/Property.repository.js +95 -0
  102. package/dist/property/Property.service.d.ts +8 -0
  103. package/dist/property/Property.service.js +36 -0
  104. package/dist/property/index.d.ts +2 -0
  105. package/dist/property/index.js +18 -0
  106. package/dist/queue/entities/HybridHttpQueue.d.ts +24 -0
  107. package/dist/queue/entities/HybridHttpQueue.js +241 -0
  108. package/dist/queue/entities/index.d.ts +1 -0
  109. package/dist/queue/entities/index.js +17 -0
  110. package/dist/queue/index.d.ts +5 -0
  111. package/dist/queue/index.js +22 -0
  112. package/dist/queue/interfaces/IHttpRequestJob.d.ts +9 -0
  113. package/dist/queue/interfaces/IHttpRequestJob.js +2 -0
  114. package/dist/queue/interfaces/IHybridHttpQueue.d.ts +17 -0
  115. package/dist/queue/interfaces/IHybridHttpQueue.js +2 -0
  116. package/dist/queue/interfaces/IJobResult.d.ts +14 -0
  117. package/dist/queue/interfaces/IJobResult.js +2 -0
  118. package/dist/queue/interfaces/IRateLimitConfig.d.ts +5 -0
  119. package/dist/queue/interfaces/IRateLimitConfig.js +2 -0
  120. package/dist/queue/interfaces/index.d.ts +4 -0
  121. package/dist/queue/interfaces/index.js +20 -0
  122. package/dist/queue/services/QueueService.d.ts +19 -0
  123. package/dist/queue/services/QueueService.js +73 -0
  124. package/dist/queue/services/index.d.ts +1 -0
  125. package/dist/queue/services/index.js +17 -0
  126. package/dist/queue/types/http.types.d.ts +21 -0
  127. package/dist/queue/types/http.types.js +2 -0
  128. package/dist/queue/types/index.d.ts +2 -0
  129. package/dist/queue/types/index.js +18 -0
  130. package/dist/queue/types/queue.types.d.ts +31 -0
  131. package/dist/queue/types/queue.types.js +2 -0
  132. package/dist/queue/utils/index.d.ts +3 -0
  133. package/dist/queue/utils/index.js +19 -0
  134. package/dist/queue/utils/jobUtils.d.ts +10 -0
  135. package/dist/queue/utils/jobUtils.js +64 -0
  136. package/dist/queue/utils/queueUtils.d.ts +5 -0
  137. package/dist/queue/utils/queueUtils.js +60 -0
  138. package/dist/queue/utils/rateLimit.utils.d.ts +10 -0
  139. package/dist/queue/utils/rateLimit.utils.js +97 -0
  140. package/package.json +2 -1
  141. package/src/{device/local/models → alerts}/Alert.model.ts +1 -1
  142. package/src/{device/local/repository → alerts}/Alert.repository.ts +2 -2
  143. package/src/{device/local/services → alerts}/Alert.service.ts +14 -7
  144. package/src/{device/local/entities → alerts}/AlertBuilder.example.ts +2 -2
  145. package/src/{device/local/entities → alerts}/AlertBuilder.ts +14 -8
  146. package/src/{device/local/services → alerts}/AlertService.example.ts +6 -5
  147. package/src/{types → alerts}/alert.types.ts +2 -2
  148. package/src/alerts/index.ts +3 -0
  149. package/src/config/config.ts +7 -7
  150. package/src/{types → config}/config.types.ts +1 -1
  151. package/src/{device/local/repository → connection}/Connection.repository.ts +2 -2
  152. package/src/{device/local/services → connection}/Connection.service.ts +2 -2
  153. package/src/connection/index.ts +3 -0
  154. package/src/device/cloud/entities/CloudDevice.ts +2 -2
  155. package/src/device/cloud/entities/CloudDeviceService.ts +1 -1
  156. package/src/device/cloud/entities/DeviceFactory.ts +2 -2
  157. package/src/device/cloud/interfaces/ICloudDeviceService.ts +1 -1
  158. package/src/device/cloud/interfaces/IRawDevice.ts +1 -1
  159. package/src/device/local/interfaces/index.ts +2 -3
  160. package/src/device/local/repository/Device.repository.ts +3 -3
  161. package/src/device/local/repository/Hub.repository.ts +4 -4
  162. package/src/device/local/repository/Schedule.repository.ts +2 -2
  163. package/src/device/local/services/Device.service.ts +1 -1
  164. package/src/device/local/services/index.ts +0 -4
  165. package/{TROUBLESHOOTING.md → src/docs/TROUBLESHOOTING.md} +2 -2
  166. package/src/events/BaseEventHandler.ts +3 -3
  167. package/src/events/BaseEventTransformer.ts +2 -2
  168. package/src/events/DeviceEventHandler.ts +3 -3
  169. package/src/events/EventHandler.ts +1 -1
  170. package/src/events/EventHandlerOrchestrator.ts +2 -2
  171. package/src/events/EventProcessingService.ts +2 -2
  172. package/src/events/InternalEventSubscription.ts +2 -2
  173. package/src/index.ts +19 -13
  174. package/src/{device/local/models → issues}/Issue.model.ts +1 -1
  175. package/src/{device/local/repository → issues}/Issue.repository.ts +2 -2
  176. package/src/{device/local/services → issues}/Issue.service.ts +4 -4
  177. package/src/{device/local/entities → issues}/IssueBuilder.example.ts +1 -1
  178. package/src/{device/local/entities → issues}/IssueBuilder.ts +1 -1
  179. package/src/{device/local/services → issues}/IssueService.example.ts +6 -5
  180. package/src/issues/index.ts +2 -0
  181. package/src/{device/local/repository → property}/Property.repository.ts +2 -2
  182. package/src/{device/local/services → property}/Property.service.ts +1 -1
  183. package/src/property/index.ts +2 -0
  184. package/src/queue/entities/HybridHttpQueue.ts +272 -0
  185. package/src/queue/entities/index.ts +1 -0
  186. package/src/queue/index.ts +6 -0
  187. package/src/queue/interfaces/IHttpRequestJob.ts +10 -0
  188. package/src/queue/interfaces/IHybridHttpQueue.ts +24 -0
  189. package/src/queue/interfaces/IJobResult.ts +15 -0
  190. package/src/queue/interfaces/IRateLimitConfig.ts +5 -0
  191. package/src/queue/interfaces/index.ts +4 -0
  192. package/src/queue/services/QueueService.ts +39 -0
  193. package/src/queue/services/index.ts +1 -0
  194. package/src/queue/types/http.types.ts +22 -0
  195. package/src/queue/types/index.ts +2 -0
  196. package/src/queue/types/queue.types.ts +21 -0
  197. package/src/queue/utils/index.ts +3 -0
  198. package/src/queue/utils/jobUtils.ts +80 -0
  199. package/src/queue/utils/queueUtils.ts +91 -0
  200. package/src/queue/utils/rateLimit.utils.ts +131 -0
  201. package/tsconfig.json +4 -0
  202. package/src/device/local/entities/README.md +0 -173
  203. package/src/device/local/entities/index.ts +0 -2
  204. package/src/types/index.ts +0 -3
  205. /package/src/{device/local/interfaces → connection}/IConnection.ts +0 -0
  206. /package/src/{device/local/models → docs}/Alert.model.md +0 -0
  207. /package/src/{device/local/models/README.md → docs/Alerts&IssuesModel.md} +0 -0
  208. /package/src/{device/local/models → docs}/Issue.model.md +0 -0
  209. /package/{SECURITY.md → src/docs/SECURITY.md} +0 -0
  210. /package/src/{types → issues}/issue.types.ts +0 -0
  211. /package/src/{device/local/interfaces → property}/IProperty.ts +0 -0
@@ -0,0 +1,25 @@
1
+ import { IHubService } from "../interfaces";
2
+ import { IConnection, IDevice } from "../types";
3
+ export declare abstract class HubService implements IHubService {
4
+ deviceId: string;
5
+ propertyId: string;
6
+ name: string;
7
+ deviceType: {
8
+ id: string;
9
+ type: string;
10
+ };
11
+ status: {
12
+ online: boolean;
13
+ error?: {
14
+ type?: string;
15
+ message?: string;
16
+ };
17
+ lastUpdated?: string;
18
+ };
19
+ metaData?: Record<string, any>;
20
+ connection: IConnection;
21
+ constructor(hub: IDevice);
22
+ abstract getHubs(connectionId: string): Promise<any[] | null>;
23
+ abstract getHub(connectionId: string, hubId: string): Promise<Record<string, any>>;
24
+ abstract getStatus(connectionId: string, hubId: string): Promise<string>;
25
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HubService = void 0;
4
+ class HubService {
5
+ constructor(hub) {
6
+ Object.assign(this, hub);
7
+ }
8
+ }
9
+ exports.HubService = HubService;
@@ -0,0 +1,38 @@
1
+ import { ISmartthingsDeviceCommandManager } from "../interface";
2
+ import { IDeviceCommand, ISmartthingsDeviceCommand, ICommandResponse } from "../types";
3
+ /**
4
+ * SmartThings Device Service Class
5
+ * Implements ISmartthingsDeviceCommandManager interface with empty implementations
6
+ * Implementation will be provided by the consuming project
7
+ */
8
+ export declare class SmartThingsDeviceService implements ISmartthingsDeviceCommandManager {
9
+ /**
10
+ * Invokes a command on a device
11
+ * @param command - Device command to execute
12
+ * @param deviceId - Device identifier
13
+ * @returns Promise with command response
14
+ */
15
+ invokeCommand(command: IDeviceCommand, deviceId: string): Promise<ICommandResponse>;
16
+ /**
17
+ * Performs device action for SmartThings
18
+ * @param commands - Array of SmartThings device commands
19
+ * @param deviceId - Device identifier
20
+ * @param accessToken - Access token for authentication
21
+ * @returns Promise with action result
22
+ */
23
+ performDeviceAction(commands: ISmartthingsDeviceCommand[], deviceId: string, accessToken: string): Promise<any>;
24
+ /**
25
+ * Gets device status for SmartThings
26
+ * @param deviceId - Device identifier
27
+ * @param accessToken - Access token for authentication
28
+ * @returns Promise with device status
29
+ */
30
+ getDeviceStatus(deviceId: string, accessToken: string): Promise<any>;
31
+ /**
32
+ * Gets device lock status for SmartThings
33
+ * @param deviceId - Device identifier
34
+ * @param accessToken - Access token for authentication
35
+ * @returns Promise with lock status
36
+ */
37
+ getDeviceLockStatus(deviceId: string, accessToken: string): Promise<any>;
38
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartThingsDeviceService = void 0;
4
+ /**
5
+ * SmartThings Device Service Class
6
+ * Implements ISmartthingsDeviceCommandManager interface with empty implementations
7
+ * Implementation will be provided by the consuming project
8
+ */
9
+ class SmartThingsDeviceService {
10
+ /**
11
+ * Invokes a command on a device
12
+ * @param command - Device command to execute
13
+ * @param deviceId - Device identifier
14
+ * @returns Promise with command response
15
+ */
16
+ async invokeCommand(command, deviceId) {
17
+ // Implementation will be provided by the consuming project
18
+ throw new Error("invokeCommand method not implemented");
19
+ }
20
+ /**
21
+ * Performs device action for SmartThings
22
+ * @param commands - Array of SmartThings device commands
23
+ * @param deviceId - Device identifier
24
+ * @param accessToken - Access token for authentication
25
+ * @returns Promise with action result
26
+ */
27
+ async performDeviceAction(commands, deviceId, accessToken) {
28
+ // Implementation will be provided by the consuming project
29
+ throw new Error("performDeviceAction method not implemented");
30
+ }
31
+ /**
32
+ * Gets device status for SmartThings
33
+ * @param deviceId - Device identifier
34
+ * @param accessToken - Access token for authentication
35
+ * @returns Promise with device status
36
+ */
37
+ async getDeviceStatus(deviceId, accessToken) {
38
+ // Implementation will be provided by the consuming project
39
+ throw new Error("getDeviceStatus method not implemented");
40
+ }
41
+ /**
42
+ * Gets device lock status for SmartThings
43
+ * @param deviceId - Device identifier
44
+ * @param accessToken - Access token for authentication
45
+ * @returns Promise with lock status
46
+ */
47
+ async getDeviceLockStatus(deviceId, accessToken) {
48
+ // Implementation will be provided by the consuming project
49
+ throw new Error("getDeviceLockStatus method not implemented");
50
+ }
51
+ }
52
+ exports.SmartThingsDeviceService = SmartThingsDeviceService;
@@ -0,0 +1,4 @@
1
+ export * from "./cloud/interface";
2
+ export * from "./cloud/types";
3
+ export type { IConnection, IConnectionConnectParams, IDevice, IDeviceAccountResponse, } from "./cloud/types";
4
+ export type { IDeviceCloudService } from "./cloud/interface";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // DeviceThread Common Library - Device Module
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ // Export cloud device interfaces
19
+ __exportStar(require("./cloud/interface"), exports);
20
+ __exportStar(require("./cloud/types"), exports);
@@ -9,9 +9,9 @@ class EventHandler {
9
9
  this.source = "dt-common-device";
10
10
  }
11
11
  async onDeviceCreate(body) {
12
- await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.CREATE.SUCCESS, body, this.source);
12
+ await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.CREATED, body, this.source);
13
13
  const payload = {
14
- eventType: Events_1.DT_EVENT_TYPES.DEVICE.CREATE.SUCCESS,
14
+ eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.CREATED,
15
15
  properties: {
16
16
  ...body,
17
17
  },
@@ -19,9 +19,9 @@ class EventHandler {
19
19
  await (0, dt_audit_library_1.publishAudit)(payload);
20
20
  }
21
21
  async onDeviceUpdate(deviceId, body) {
22
- await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.UPDATE.SUCCESS, { deviceId, body }, this.source);
22
+ await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.UPDATED, { deviceId, body }, this.source);
23
23
  const payload = {
24
- eventType: Events_1.DT_EVENT_TYPES.DEVICE.UPDATE.SUCCESS,
24
+ eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.UPDATED,
25
25
  properties: {
26
26
  ...body,
27
27
  },
@@ -29,9 +29,9 @@ class EventHandler {
29
29
  await (0, dt_audit_library_1.publishAudit)(payload);
30
30
  }
31
31
  async onDeviceDelete(deviceId) {
32
- await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DELETE.SUCCESS, { deviceId }, this.source);
32
+ await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.DELETED, { deviceId }, this.source);
33
33
  const payload = {
34
- eventType: Events_1.DT_EVENT_TYPES.DEVICE.DELETE.SUCCESS,
34
+ eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.DELETED,
35
35
  properties: {
36
36
  deviceId,
37
37
  },
@@ -1,16 +1,9 @@
1
1
  export declare const DT_EVENT_TYPES: {
2
2
  DEVICE: {
3
- CREATE: {
4
- SUCCESS: string;
5
- FAILED: string;
6
- };
7
- UPDATE: {
8
- SUCCESS: string;
9
- FAILED: string;
10
- };
11
- DELETE: {
12
- SUCCESS: string;
13
- FAILED: string;
3
+ DEVICE: {
4
+ CREATED: string;
5
+ UPDATED: string;
6
+ DELETED: string;
14
7
  };
15
8
  STATE: {
16
9
  SET: string;
@@ -41,31 +34,17 @@ export declare const DT_EVENT_TYPES: {
41
34
  };
42
35
  };
43
36
  CONNECTION: {
44
- CREATE: {
45
- SUCCESS: string;
46
- FAILED: string;
47
- };
48
- UPDATE: {
49
- SUCCESS: string;
50
- FAILED: string;
51
- };
52
- DELETE: {
53
- SUCCESS: string;
54
- FAILED: string;
37
+ CONNECTION: {
38
+ CREATED: string;
39
+ UPDATED: string;
40
+ DELETED: string;
55
41
  };
56
42
  };
57
43
  PROPERTY: {
58
- CREATE: {
59
- SUCCESS: string;
60
- FAILED: string;
61
- };
62
- UPDATE: {
63
- SUCCESS: string;
64
- FAILED: string;
65
- };
66
- DELETE: {
67
- SUCCESS: string;
68
- FAILED: string;
44
+ PROPERTY: {
45
+ CREATED: string;
46
+ UPDATED: string;
47
+ DELETED: string;
69
48
  };
70
49
  PREFERENCES: {
71
50
  UPDATED: string;
@@ -3,17 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DT_EVENT_TYPES = void 0;
4
4
  exports.DT_EVENT_TYPES = {
5
5
  DEVICE: {
6
- CREATE: {
7
- SUCCESS: "device.create.success",
8
- FAILED: "device.create.failed",
9
- },
10
- UPDATE: {
11
- SUCCESS: "device.update.success",
12
- FAILED: "device.update.failed",
13
- },
14
- DELETE: {
15
- SUCCESS: "device.delete.success",
16
- FAILED: "device.delete.failed",
6
+ DEVICE: {
7
+ CREATED: "device.device.created",
8
+ UPDATED: "device.device.updated",
9
+ DELETED: "device.device.deleted",
17
10
  },
18
11
  STATE: {
19
12
  SET: "device.state.set",
@@ -44,31 +37,17 @@ exports.DT_EVENT_TYPES = {
44
37
  },
45
38
  },
46
39
  CONNECTION: {
47
- CREATE: {
48
- SUCCESS: "connection.create.success",
49
- FAILED: "connection.create.failed",
50
- },
51
- UPDATE: {
52
- SUCCESS: "connection.update.success",
53
- FAILED: "connection.update.failed",
54
- },
55
- DELETE: {
56
- SUCCESS: "connection.delete.success",
57
- FAILED: "connection.delete.failed",
40
+ CONNECTION: {
41
+ CREATED: "connection.connection.created",
42
+ UPDATED: "connection.connection.updated",
43
+ DELETED: "connection.connection.deleted",
58
44
  },
59
45
  },
60
46
  PROPERTY: {
61
- CREATE: {
62
- SUCCESS: "property.create.success",
63
- FAILED: "property.create.failed",
64
- },
65
- UPDATE: {
66
- SUCCESS: "property.update.success",
67
- FAILED: "property.update.failed",
68
- },
69
- DELETE: {
70
- SUCCESS: "property.delete.success",
71
- FAILED: "property.delete.failed",
47
+ PROPERTY: {
48
+ CREATED: "property.property.created",
49
+ UPDATED: "property.property.updated",
50
+ DELETED: "property.property.deleted",
72
51
  },
73
52
  PREFERENCES: {
74
53
  UPDATED: "property.preferences.updated",
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -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);
@@ -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;
@@ -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"));
@@ -0,0 +1,11 @@
1
+ import { IHubCreateParams } from "../interfaces";
2
+ export declare class DeviceHubService {
3
+ private readonly baseUrl;
4
+ constructor();
5
+ addHub(body: IHubCreateParams): Promise<any>;
6
+ getHubs(hubIds: string[]): Promise<any>;
7
+ getHub(hubId: string): Promise<any>;
8
+ updateHub(hubId: string, body: any): Promise<any>;
9
+ deleteHub(hubId: string): Promise<any>;
10
+ deleteAllHubs(hubIds: string[]): Promise<any>;
11
+ }
@@ -0,0 +1,40 @@
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.DeviceHubService = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const config_1 = require("../../../config/config");
9
+ class DeviceHubService {
10
+ constructor() {
11
+ const { DEVICE_SERVICE } = (0, config_1.getConfig)();
12
+ if (!DEVICE_SERVICE) {
13
+ throw new Error("DEVICE_SERVICE is not configured. Call initialize() first with DEVICE_SERVICE.");
14
+ }
15
+ this.baseUrl = DEVICE_SERVICE;
16
+ }
17
+ async addHub(body) {
18
+ return await axios_1.default.post(`${this.baseUrl}/devices/hubs`, body);
19
+ }
20
+ //get hubs takes an array of hub ids as query params
21
+ async getHubs(hubIds) {
22
+ const query = hubIds && hubIds.length ? `?ids=${hubIds.join(",")}` : "";
23
+ return await axios_1.default.get(`${this.baseUrl}/devices/hubs${query}`);
24
+ }
25
+ //get hub takes a hub id in params
26
+ async getHub(hubId) {
27
+ return await axios_1.default.get(`${this.baseUrl}/devices/hubs/${hubId}`);
28
+ }
29
+ async updateHub(hubId, body) {
30
+ return await axios_1.default.put(`${this.baseUrl}/devices/hubs/${hubId}`, body);
31
+ }
32
+ async deleteHub(hubId) {
33
+ return await axios_1.default.delete(`${this.baseUrl}/devices/hubs/${hubId}`);
34
+ }
35
+ async deleteAllHubs(hubIds) {
36
+ const query = hubIds.length ? `?ids=${hubIds.join(",")}` : "";
37
+ return await axios_1.default.delete(`${this.baseUrl}/devices/hubs${query}`);
38
+ }
39
+ }
40
+ exports.DeviceHubService = DeviceHubService;
@@ -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";