dt-common-device 1.3.0 → 2.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 (156) hide show
  1. package/TROUBLESHOOTING.md +184 -0
  2. package/dist/config/config.d.ts +9 -2
  3. package/dist/config/config.js +97 -14
  4. package/dist/constants/Event.d.ts +75 -0
  5. package/dist/constants/Event.js +78 -0
  6. package/dist/db/db.d.ts +1 -0
  7. package/dist/db/db.js +18 -2
  8. package/dist/device/cloud/entities/CloudDevice.d.ts +1 -0
  9. package/dist/device/cloud/entities/CloudDevice.js +3 -0
  10. package/dist/device/local/entities/AlertBuilder.d.ts +87 -0
  11. package/dist/device/local/entities/AlertBuilder.example.d.ts +11 -0
  12. package/dist/device/local/entities/AlertBuilder.example.js +117 -0
  13. package/dist/device/local/entities/AlertBuilder.js +179 -0
  14. package/dist/device/local/entities/IssueBuilder.d.ts +109 -0
  15. package/dist/device/local/entities/IssueBuilder.example.d.ts +16 -0
  16. package/dist/device/local/entities/IssueBuilder.example.js +196 -0
  17. package/dist/device/local/entities/IssueBuilder.js +237 -0
  18. package/dist/device/local/entities/index.d.ts +2 -0
  19. package/dist/device/local/entities/index.js +7 -0
  20. package/dist/device/local/events/EventHandler.js +6 -6
  21. package/dist/device/local/events/Events.d.ts +33 -12
  22. package/dist/device/local/events/Events.js +33 -12
  23. package/dist/device/local/interfaces/IDevice.d.ts +10 -9
  24. package/dist/device/local/interfaces/IDevice.js +7 -0
  25. package/dist/device/local/models/Alert.model.d.ts +28 -0
  26. package/dist/device/local/models/Alert.model.js +222 -0
  27. package/dist/device/local/models/Issue.model.d.ts +28 -0
  28. package/dist/device/local/models/Issue.model.js +260 -0
  29. package/dist/device/local/repository/Alert.repository.d.ts +106 -0
  30. package/dist/device/local/repository/Alert.repository.js +374 -0
  31. package/dist/device/local/repository/Device.repository.d.ts +11 -2
  32. package/dist/device/local/repository/Device.repository.js +163 -30
  33. package/dist/device/local/repository/Hub.repository.d.ts +1 -1
  34. package/dist/device/local/repository/Hub.repository.js +60 -18
  35. package/dist/device/local/repository/Issue.repository.d.ts +113 -0
  36. package/dist/device/local/repository/Issue.repository.js +401 -0
  37. package/dist/device/local/repository/Schedule.repository.d.ts +1 -1
  38. package/dist/device/local/repository/Schedule.repository.js +14 -18
  39. package/dist/device/local/services/Alert.service.d.ts +135 -5
  40. package/dist/device/local/services/Alert.service.js +471 -7
  41. package/dist/device/local/services/AlertService.example.d.ts +55 -0
  42. package/dist/device/local/services/AlertService.example.js +148 -0
  43. package/dist/device/local/services/Device.service.d.ts +9 -6
  44. package/dist/device/local/services/Device.service.js +61 -41
  45. package/dist/device/local/services/Issue.service.d.ts +168 -0
  46. package/dist/device/local/services/Issue.service.js +642 -0
  47. package/dist/device/local/services/IssueService.example.d.ts +68 -0
  48. package/dist/device/local/services/IssueService.example.js +177 -0
  49. package/dist/device/local/services/index.d.ts +7 -5
  50. package/dist/device/local/services/index.js +21 -11
  51. package/dist/events/BaseEventHandler.d.ts +43 -0
  52. package/dist/events/BaseEventHandler.js +111 -0
  53. package/dist/events/BaseEventTransformer.d.ts +26 -0
  54. package/dist/events/BaseEventTransformer.js +72 -0
  55. package/dist/events/DeviceEventHandler.d.ts +15 -0
  56. package/dist/events/DeviceEventHandler.js +152 -0
  57. package/dist/events/DeviceEventTransformerFactory.d.ts +27 -0
  58. package/dist/events/DeviceEventTransformerFactory.js +116 -0
  59. package/dist/events/EventHandler.d.ts +11 -0
  60. package/dist/events/EventHandler.js +111 -0
  61. package/dist/events/EventHandlerOrchestrator.d.ts +35 -0
  62. package/dist/events/EventHandlerOrchestrator.js +141 -0
  63. package/dist/events/EventProcessingService.d.ts +43 -0
  64. package/dist/events/EventProcessingService.js +243 -0
  65. package/dist/events/InternalEventSubscription.d.ts +44 -0
  66. package/dist/events/InternalEventSubscription.js +152 -0
  67. package/dist/events/index.d.ts +9 -0
  68. package/dist/events/index.js +21 -0
  69. package/dist/events/interfaces/DeviceEvent.d.ts +48 -0
  70. package/dist/events/interfaces/IEventHandler.d.ts +23 -0
  71. package/dist/{device/cloud/interface.js → events/interfaces/IEventHandler.js} +0 -1
  72. package/dist/events/interfaces/IEventTransformer.d.ts +7 -0
  73. package/dist/{device/cloud/interfaces/IDeviceConnectionService.js → events/interfaces/IEventTransformer.js} +0 -1
  74. package/dist/events/interfaces/IInternalEvent.d.ts +42 -0
  75. package/dist/events/interfaces/IInternalEvent.js +2 -0
  76. package/dist/events/interfaces/index.d.ts +4 -0
  77. package/dist/{device → events/interfaces}/index.js +4 -4
  78. package/dist/index.d.ts +6 -2
  79. package/dist/index.js +9 -2
  80. package/dist/types/alert.types.d.ts +57 -0
  81. package/dist/types/alert.types.js +22 -0
  82. package/dist/types/config.types.d.ts +15 -4
  83. package/dist/types/index.d.ts +2 -0
  84. package/dist/types/index.js +2 -0
  85. package/dist/types/issue.types.d.ts +90 -0
  86. package/dist/types/issue.types.js +40 -0
  87. package/dist/utils/http-utils.d.ts +13 -0
  88. package/dist/utils/http-utils.js +117 -0
  89. package/package.json +2 -1
  90. package/src/config/config.ts +117 -14
  91. package/src/{device/local/events/Events.ts → constants/Event.ts} +34 -13
  92. package/src/db/db.ts +14 -5
  93. package/src/device/cloud/entities/CloudDevice.ts +4 -0
  94. package/src/device/local/entities/AlertBuilder.example.ts +126 -0
  95. package/src/device/local/entities/AlertBuilder.ts +202 -0
  96. package/src/device/local/entities/IssueBuilder.example.ts +210 -0
  97. package/src/device/local/entities/IssueBuilder.ts +263 -0
  98. package/src/device/local/entities/README.md +173 -0
  99. package/src/device/local/entities/index.ts +2 -0
  100. package/src/device/local/interfaces/IDevice.ts +11 -9
  101. package/src/device/local/models/Alert.model.md +319 -0
  102. package/src/device/local/models/Alert.model.ts +283 -0
  103. package/src/device/local/models/Issue.model.md +386 -0
  104. package/src/device/local/models/Issue.model.ts +350 -0
  105. package/src/device/local/models/README.md +312 -0
  106. package/src/device/local/repository/Alert.repository.ts +465 -0
  107. package/src/device/local/repository/Device.repository.ts +251 -30
  108. package/src/device/local/repository/Hub.repository.ts +74 -18
  109. package/src/device/local/repository/Issue.repository.ts +517 -0
  110. package/src/device/local/repository/Schedule.repository.ts +28 -22
  111. package/src/device/local/services/Alert.service.ts +617 -5
  112. package/src/device/local/services/AlertService.example.ts +229 -0
  113. package/src/device/local/services/Device.service.ts +74 -52
  114. package/src/device/local/services/Issue.service.ts +872 -0
  115. package/src/device/local/services/IssueService.example.ts +307 -0
  116. package/src/device/local/services/index.ts +7 -5
  117. package/src/events/BaseEventHandler.ts +145 -0
  118. package/src/events/BaseEventTransformer.ts +97 -0
  119. package/src/events/DeviceEventHandler.ts +211 -0
  120. package/src/events/DeviceEventTransformerFactory.ts +77 -0
  121. package/src/{device/local/events → events}/EventHandler.ts +24 -19
  122. package/src/events/EventHandlerOrchestrator.ts +119 -0
  123. package/src/events/EventProcessingService.ts +248 -0
  124. package/src/events/InternalEventSubscription.ts +219 -0
  125. package/src/events/index.ts +9 -0
  126. package/src/events/interfaces/DeviceEvent.ts +56 -0
  127. package/src/events/interfaces/IEventHandler.ts +28 -0
  128. package/src/events/interfaces/IEventTransformer.ts +8 -0
  129. package/src/events/interfaces/IInternalEvent.ts +47 -0
  130. package/src/events/interfaces/index.ts +4 -0
  131. package/src/index.ts +9 -2
  132. package/src/types/alert.types.ts +64 -0
  133. package/src/types/config.types.ts +17 -4
  134. package/src/types/index.ts +2 -0
  135. package/src/types/issue.types.ts +98 -0
  136. package/src/utils/http-utils.ts +143 -0
  137. package/dist/device/cloud/interface.d.ts +0 -101
  138. package/dist/device/cloud/interfaces/IDeviceConnectionService.d.ts +0 -7
  139. package/dist/device/cloud/interfaces/IDevicesService.d.ts +0 -9
  140. package/dist/device/cloud/services/Device.service.d.ts +0 -39
  141. package/dist/device/cloud/services/Device.service.js +0 -9
  142. package/dist/device/cloud/services/DeviceCloudService.d.ts +0 -42
  143. package/dist/device/cloud/services/DeviceCloudService.js +0 -59
  144. package/dist/device/cloud/services/DeviceHub.service.d.ts +0 -3
  145. package/dist/device/cloud/services/DeviceHub.service.js +0 -6
  146. package/dist/device/cloud/services/Hub.service.d.ts +0 -25
  147. package/dist/device/cloud/services/Hub.service.js +0 -9
  148. package/dist/device/cloud/services/SmartThingsDeviceService.d.ts +0 -38
  149. package/dist/device/cloud/services/SmartThingsDeviceService.js +0 -52
  150. package/dist/device/index.d.ts +0 -4
  151. package/dist/device/local/interface.d.ts +0 -0
  152. package/dist/device/local/interface.js +0 -1
  153. package/dist/device/local/services/DeviceHub.service.d.ts +0 -11
  154. package/dist/device/local/services/DeviceHub.service.js +0 -40
  155. package/src/device/local/events/index.ts +0 -2
  156. /package/dist/{device/cloud/interfaces/IDevicesService.js → events/interfaces/DeviceEvent.js} +0 -0
@@ -0,0 +1,64 @@
1
+ import { EntityType } from "./issue.types";
2
+
3
+ export enum AlertCategory {
4
+ READINESS = "READINESS",
5
+ OPERATIONS = "OPERATIONS",
6
+ SECURITY = "SECURITY",
7
+ ENERGY = "ENERGY",
8
+ OTHER = "OTHER",
9
+ }
10
+
11
+ export enum AlertSeverity {
12
+ INFO = "INFO",
13
+ LOW = "LOW",
14
+ MEDIUM = "MEDIUM",
15
+ HIGH = "HIGH",
16
+ CRITICAL = "CRITICAL",
17
+ }
18
+
19
+ export interface AlertDocument {
20
+ _id: string;
21
+ category: AlertCategory;
22
+ propertyId: string;
23
+ title: string;
24
+ description: string;
25
+ entityId?: string;
26
+ entityType: EntityType;
27
+ severity: AlertSeverity;
28
+ isRead: boolean;
29
+ isActive: boolean;
30
+ isDeleted: boolean;
31
+ snoozeUntil?: Date;
32
+ createdBy?: string;
33
+ updatedBy?: string;
34
+ createdAt: Date;
35
+ updatedAt: Date;
36
+ }
37
+
38
+ export interface CreateAlertData {
39
+ category: AlertCategory;
40
+ propertyId: string;
41
+ title: string;
42
+ description: string;
43
+ entityId?: string;
44
+ entityType: EntityType;
45
+ severity?: AlertSeverity;
46
+ createdBy?: string;
47
+ snoozeUntil?: Date;
48
+ }
49
+
50
+ export interface UpdateAlertData {
51
+ category?: AlertCategory;
52
+ title?: string;
53
+ description?: string;
54
+ entityId?: string;
55
+ entityType?: EntityType;
56
+ severity?: AlertSeverity;
57
+ isRead?: boolean;
58
+ isActive?: boolean;
59
+ snoozeUntil?: Date;
60
+ updatedBy?: string;
61
+ }
62
+
63
+ // Re-export EntityType from issue.types.ts to avoid duplication
64
+ export { EntityType } from "./issue.types";
@@ -1,8 +1,21 @@
1
+ import { IInternalEvent } from "../events/interfaces/IInternalEvent";
2
+
3
+ export interface ILogger {
4
+ info(message: string, ...args: any[]): void;
5
+ warn(message: string, ...args: any[]): void;
6
+ error(message: string, ...args: any[]): void;
7
+ }
8
+
9
+ type AllowedSource = "ACCESS_SERVICE" | "ADMIN_SERVICE" | "ENERGY_SERVICE";
10
+
1
11
  export type DeviceConfig = {
2
- ADMIN_SERVICE?: string;
3
- OPERATIONAL_SERVICE?: string;
12
+ SOURCE: AllowedSource;
13
+ SQS_QUEUE_URL: string;
4
14
  DEVICE_SERVICE?: string;
5
- MONITORING_SERVICE?: string;
15
+ ADMIN_SERVICE?: string;
16
+ ACCESS_SERVICE?: string;
6
17
  ENERGY_SERVICE?: string;
7
- [key: string]: string | undefined;
18
+ INTERNAL_EVENT_HANDLER: IInternalEvent;
19
+ LOGGER: ILogger;
20
+ [key: string]: any;
8
21
  };
@@ -1 +1,3 @@
1
1
  export * from "./config.types";
2
+ export * from "./issue.types";
3
+ export * from "./alert.types";
@@ -0,0 +1,98 @@
1
+ export enum IssuesCategory {
2
+ READINESS = "READINESS",
3
+ OPERATIONS = "OPERATIONS",
4
+ SECURITY = "SECURITY",
5
+ ENERGY = "ENERGY",
6
+ OTHER = "OTHER",
7
+ }
8
+
9
+ export enum EntityType {
10
+ DEVICE = "DEVICE",
11
+ COLLECTION = "COLLECTION",
12
+ USER = "USER",
13
+ INTEGRATION = "INTEGRATION",
14
+ PROPERTY = "PROPERTY",
15
+ HUB = "HUB",
16
+ SCHEDULE = "SCHEDULE",
17
+ ALERT = "ALERT",
18
+ OTHER = "OTHER",
19
+ }
20
+
21
+ export enum IssueStatus {
22
+ PENDING = "PENDING",
23
+ IN_PROGRESS = "IN_PROGRESS",
24
+ RESOLVED = "RESOLVED",
25
+ CLOSED = "CLOSED",
26
+ CANCELLED = "CANCELLED",
27
+ ON_HOLD = "ON_HOLD",
28
+ }
29
+
30
+ export enum IssuePriority {
31
+ LOW = "LOW",
32
+ MEDIUM = "MEDIUM",
33
+ HIGH = "HIGH",
34
+ CRITICAL = "CRITICAL",
35
+ URGENT = "URGENT",
36
+ }
37
+
38
+ export interface IssueComment {
39
+ id: string;
40
+ userId: string;
41
+ content: string;
42
+ createdAt: Date;
43
+ updatedAt?: Date;
44
+ }
45
+
46
+ export interface IssueDocument {
47
+ _id: string;
48
+ category: IssuesCategory;
49
+ propertyId: string;
50
+ title: string;
51
+ description: string;
52
+ entityId?: string;
53
+ entityType: EntityType;
54
+ status: IssueStatus;
55
+ priority: IssuePriority;
56
+ assignedTo?: string;
57
+ createdBy: string;
58
+ updatedBy?: string;
59
+ isDeleted: boolean;
60
+ createdAt: Date;
61
+ updatedAt: Date;
62
+ resolvedAt?: Date;
63
+ dueDate?: Date;
64
+ comments?: IssueComment[];
65
+ }
66
+
67
+ export interface CreateIssueData {
68
+ category: IssuesCategory;
69
+ propertyId: string;
70
+ title: string;
71
+ description: string;
72
+ entityId?: string;
73
+ entityType: EntityType;
74
+ priority?: IssuePriority;
75
+ assignedTo?: string;
76
+ createdBy: string;
77
+ dueDate?: Date;
78
+ }
79
+
80
+ export interface UpdateIssueData {
81
+ category?: IssuesCategory;
82
+ title?: string;
83
+ description?: string;
84
+ entityId?: string;
85
+ entityType?: EntityType;
86
+ status?: IssueStatus;
87
+ priority?: IssuePriority;
88
+ assignedTo?: string;
89
+ updatedBy: string;
90
+ resolvedAt?: Date;
91
+ dueDate?: Date;
92
+ isDeleted?: boolean;
93
+ }
94
+
95
+ export interface AddCommentData {
96
+ userId: string;
97
+ content: string;
98
+ }
@@ -0,0 +1,143 @@
1
+ import { getConfig } from "../config/config";
2
+ import axios from "axios";
3
+
4
+ /**
5
+ * Validates if a URL is properly formatted and accessible
6
+ */
7
+ export function validateServiceUrl(url: string): boolean {
8
+ try {
9
+ const parsedUrl = new URL(url);
10
+ return parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:";
11
+ } catch (error) {
12
+ getConfig().LOGGER.error(`Invalid service URL: ${url}`, error);
13
+ return false;
14
+ }
15
+ }
16
+
17
+ /**
18
+ * Creates a properly configured axios instance with error handling
19
+ */
20
+ export function createAxiosInstance(baseURL?: string) {
21
+ const instance = axios.create({
22
+ baseURL,
23
+ timeout: 30000, // 30 seconds timeout
24
+ maxRedirects: 5,
25
+ validateStatus: (status: number) => status < 500, // Don't throw on 4xx errors
26
+ headers: {
27
+ "Content-Type": "application/json",
28
+ "User-Agent": "dt-common-device/1.3.0",
29
+ },
30
+ });
31
+
32
+ // Add request interceptor for logging
33
+ instance.interceptors.request.use(
34
+ (config: any) => {
35
+ const logger = getConfig().LOGGER;
36
+ logger.info(
37
+ `Making request to: ${config.method?.toUpperCase()} ${config.url}`,
38
+ {
39
+ baseURL: config.baseURL,
40
+ timeout: config.timeout,
41
+ }
42
+ );
43
+ return config;
44
+ },
45
+ (error: any) => {
46
+ getConfig().LOGGER.error("Request interceptor error:", error);
47
+ return Promise.reject(error);
48
+ }
49
+ );
50
+
51
+ // Add response interceptor for error handling
52
+ instance.interceptors.response.use(
53
+ (response: any) => {
54
+ return response;
55
+ },
56
+ (error: any) => {
57
+ const logger = getConfig().LOGGER;
58
+ const errorInfo = {
59
+ url: error.config?.url,
60
+ method: error.config?.method,
61
+ status: error.response?.status,
62
+ statusText: error.response?.statusText,
63
+ message: error.message,
64
+ code: error.code,
65
+ baseURL: error.config?.baseURL,
66
+ };
67
+
68
+ logger.error("HTTP request failed:", errorInfo);
69
+
70
+ // Log additional details for network errors
71
+ if (error.code === "ECONNREFUSED" || error.code === "ENOTFOUND") {
72
+ logger.error("Network connectivity issue detected. Please check:", {
73
+ serviceUrl: error.config?.baseURL,
74
+ errorCode: error.code,
75
+ errorMessage: error.message,
76
+ });
77
+ }
78
+
79
+ return Promise.reject(error);
80
+ }
81
+ );
82
+
83
+ return instance;
84
+ }
85
+
86
+ /**
87
+ * Centralized axios instance for device service
88
+ */
89
+ let deviceServiceAxiosInstance: any = null;
90
+
91
+ export function getDeviceServiceAxiosInstance(): any {
92
+ if (!deviceServiceAxiosInstance) {
93
+ const { DEVICE_SERVICE } = getConfig();
94
+ if (!DEVICE_SERVICE) {
95
+ throw new Error(
96
+ "DEVICE_SERVICE is not configured. Call initialize() first with DEVICE_SERVICE."
97
+ );
98
+ }
99
+ deviceServiceAxiosInstance = createAxiosInstance(DEVICE_SERVICE);
100
+ }
101
+ return deviceServiceAxiosInstance;
102
+ }
103
+
104
+ /**
105
+ * Retry function for failed HTTP requests
106
+ */
107
+ export async function retryRequest<T>(
108
+ requestFn: () => Promise<T>,
109
+ maxRetries: number = 3,
110
+ delay: number = 1000
111
+ ): Promise<T> {
112
+ let lastError: any;
113
+
114
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
115
+ try {
116
+ return await requestFn();
117
+ } catch (error: any) {
118
+ lastError = error;
119
+
120
+ if (attempt === maxRetries) {
121
+ getConfig().LOGGER.error(
122
+ `Request failed after ${maxRetries} attempts:`,
123
+ error
124
+ );
125
+ throw error;
126
+ }
127
+
128
+ getConfig().LOGGER.warn(
129
+ `Request attempt ${attempt} failed, retrying in ${delay}ms:`,
130
+ {
131
+ error: error.message,
132
+ attempt,
133
+ maxRetries,
134
+ }
135
+ );
136
+
137
+ await new Promise((resolve) => setTimeout(resolve, delay));
138
+ delay *= 2; // Exponential backoff
139
+ }
140
+ }
141
+
142
+ throw lastError;
143
+ }
@@ -1,101 +0,0 @@
1
- import { IConnection, IConnectionConnectParams, IDevice, IDeviceAccountResponse, IDeviceCommand, ISmartthingsDeviceCommand, ICommandResponse } from "./types";
2
- /**
3
- * Class interface for device cloud operations and connection management
4
- */
5
- export interface IDeviceCloudService {
6
- /**
7
- * Creates a new connection for device management
8
- * @param data - Connection data
9
- * @param userId - User identifier
10
- * @returns Promise with connection result
11
- */
12
- createConnection(data: IConnection, userId: string): Promise<any>;
13
- /**
14
- * Gets device account information for a connection
15
- * @param connection - Connection object
16
- * @returns Promise with device account response
17
- */
18
- getDeviceAccount(connection: IConnection): Promise<IDeviceAccountResponse>;
19
- /**
20
- * Gets all devices for a connection
21
- * @param connection - Connection object
22
- * @returns Promise with array of devices
23
- */
24
- getDevices(connection: IConnection): Promise<IDevice[]>;
25
- /**
26
- * Filters devices based on connection and device list
27
- * @param connection - Connection object
28
- * @param devices - Array of devices to filter
29
- * @returns Promise with filtered devices
30
- */
31
- filterDevices(connection: IConnection, devices: any[]): Promise<IDevice[]>;
32
- /**
33
- * Connects to a device service
34
- * @param connection - Connection object
35
- * @param connectionConnect - Connection parameters
36
- * @returns Promise with connection result
37
- */
38
- connect(connection: IConnection, connectionConnect: IConnectionConnectParams): Promise<any>;
39
- }
40
- /**
41
- * Interface for device command operations
42
- */
43
- export interface IDeviceCommandManager {
44
- /**
45
- * Invokes a command on a device
46
- * @param command - Device command to execute
47
- * @param deviceId - Device identifier
48
- * @returns Promise with command response
49
- */
50
- invokeCommand(command: IDeviceCommand, deviceId: string): Promise<ICommandResponse>;
51
- }
52
- /**
53
- * Interface for SmartThings specific device command operations
54
- */
55
- export interface ISmartthingsDeviceCommandManager extends IDeviceCommandManager {
56
- /**
57
- * Performs device action for SmartThings
58
- * @param commands - Array of SmartThings device commands
59
- * @param deviceId - Device identifier
60
- * @param accessToken - Access token for authentication
61
- * @returns Promise with action result
62
- */
63
- performDeviceAction(commands: ISmartthingsDeviceCommand[], deviceId: string, accessToken: string): Promise<any>;
64
- /**
65
- * Gets device status for SmartThings
66
- * @param deviceId - Device identifier
67
- * @param accessToken - Access token for authentication
68
- * @returns Promise with device status
69
- */
70
- getDeviceStatus(deviceId: string, accessToken: string): Promise<any>;
71
- /**
72
- * Gets device lock status for SmartThings
73
- * @param deviceId - Device identifier
74
- * @param accessToken - Access token for authentication
75
- * @returns Promise with lock status
76
- */
77
- getDeviceLockStatus(deviceId: string, accessToken: string): Promise<any>;
78
- }
79
- /**
80
- * Interface for device command factory
81
- */
82
- export interface IDeviceCommandManagerFactory {
83
- /**
84
- * Creates a device command manager for a specific connection provider
85
- * @param connectionProvider - Connection provider type
86
- * @param connection - Connection object
87
- * @returns Device command manager instance
88
- */
89
- createDeviceCommandManager(connectionProvider: string, connection: IConnection): IDeviceCommandManager;
90
- }
91
- /**
92
- * Interface for device command classes
93
- */
94
- export interface IDeviceCommandClass {
95
- /**
96
- * Creates a SmartThings device command from a generic device command
97
- * @param deviceCommand - Generic device command
98
- * @returns SmartThings device command
99
- */
100
- fromDeviceCommand(deviceCommand: IDeviceCommand): ISmartthingsDeviceCommand;
101
- }
@@ -1,7 +0,0 @@
1
- import { IConnection, IConnectionConnectParams, IDeviceAccountResponse } from "../types";
2
- export interface IDeviceConnectionService {
3
- createConnection(data: IConnection, userId: string): Promise<any>;
4
- getDeviceAccount(connection: IConnection): Promise<IDeviceAccountResponse>;
5
- getDevices(connection: IConnection): Promise<any>;
6
- connect(connection: IConnection, connectionConnect: IConnectionConnectParams): Promise<any>;
7
- }
@@ -1,9 +0,0 @@
1
- import { IConnection } from "../types";
2
- export interface IDeviceService {
3
- getDevices(connection: IConnection): Promise<Record<string, any>[]>;
4
- getDevice(connectionId: string, deviceId: string): Promise<Record<string, any>>;
5
- getStatus(connectionId: string, deviceId: string): Promise<string | null>;
6
- getState(deviceId: string): Promise<Record<string, any>>;
7
- getGateways(connectionId: string): Promise<any[] | null>;
8
- getGatewayDetails(connectionId: string, gatewayId: string): Promise<any>;
9
- }
@@ -1,39 +0,0 @@
1
- import { IDeviceService } from "../interfaces";
2
- import { IConnection, IDevice } from "../types";
3
- export declare abstract class DeviceService implements IDeviceService {
4
- deviceId: string;
5
- propertyId: string;
6
- name: string;
7
- hubId: string[];
8
- deviceType: {
9
- id: string;
10
- type: string;
11
- };
12
- status: {
13
- online: boolean;
14
- error?: {
15
- type?: string;
16
- message?: string;
17
- };
18
- lastUpdated?: string;
19
- };
20
- state?: Record<string, any>;
21
- metaData?: Record<string, any>;
22
- zone?: {
23
- id: string;
24
- name: string;
25
- zoneType: string;
26
- parentZone?: {
27
- id: string;
28
- name: string;
29
- zoneType: string;
30
- };
31
- };
32
- connection: IConnection;
33
- constructor(device: IDevice);
34
- abstract getDevices(connection: IConnection): Promise<Record<string, any>[]>;
35
- abstract getDevice(connectionId: string, deviceId: string): Promise<any>;
36
- abstract getBattery(deviceId: string): Promise<number | string>;
37
- abstract getStatus(connectionId: string, deviceId: string): Promise<string>;
38
- abstract getState(deviceId: string): Promise<string>;
39
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DeviceService = void 0;
4
- class DeviceService {
5
- constructor(device) {
6
- Object.assign(this, device);
7
- }
8
- }
9
- exports.DeviceService = DeviceService;
@@ -1,42 +0,0 @@
1
- import { IDeviceCloudService } from "../interface";
2
- import { IConnection, IDevice, IDeviceAccountResponse, IConnectionConnectParams } from "../types";
3
- /**
4
- * Device Cloud Service Class
5
- * Implements IDeviceCloudService interface with empty implementations
6
- * Implementation will be provided by the consuming project
7
- */
8
- export declare class DeviceCloudService implements IDeviceCloudService {
9
- /**
10
- * Creates a new connection for device management
11
- * @param data - Connection data
12
- * @param userId - User identifier
13
- * @returns Promise with connection result
14
- */
15
- createConnection(data: IConnection, userId: string): Promise<any>;
16
- /**
17
- * Gets device account information for a connection
18
- * @param connection - Connection object
19
- * @returns Promise with device account response
20
- */
21
- getDeviceAccount(connection: IConnection): Promise<IDeviceAccountResponse>;
22
- /**
23
- * Gets all devices for a connection
24
- * @param connection - Connection object
25
- * @returns Promise with array of devices
26
- */
27
- getDevices(connection: IConnection): Promise<IDevice[]>;
28
- /**
29
- * Filters devices based on connection and device list
30
- * @param connection - Connection object
31
- * @param devices - Array of devices to filter
32
- * @returns Promise with filtered devices
33
- */
34
- filterDevices(connection: IConnection, devices: any[]): Promise<IDevice[]>;
35
- /**
36
- * Connects to a device service
37
- * @param connection - Connection object
38
- * @param connectionConnect - Connection parameters
39
- * @returns Promise with connection result
40
- */
41
- connect(connection: IConnection, connectionConnect: IConnectionConnectParams): Promise<any>;
42
- }
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DeviceCloudService = void 0;
4
- /**
5
- * Device Cloud Service Class
6
- * Implements IDeviceCloudService interface with empty implementations
7
- * Implementation will be provided by the consuming project
8
- */
9
- class DeviceCloudService {
10
- /**
11
- * Creates a new connection for device management
12
- * @param data - Connection data
13
- * @param userId - User identifier
14
- * @returns Promise with connection result
15
- */
16
- async createConnection(data, userId) {
17
- // Implementation will be provided by the consuming project
18
- throw new Error("createConnection method not implemented");
19
- }
20
- /**
21
- * Gets device account information for a connection
22
- * @param connection - Connection object
23
- * @returns Promise with device account response
24
- */
25
- async getDeviceAccount(connection) {
26
- // Implementation will be provided by the consuming project
27
- throw new Error("getDeviceAccount method not implemented");
28
- }
29
- /**
30
- * Gets all devices for a connection
31
- * @param connection - Connection object
32
- * @returns Promise with array of devices
33
- */
34
- async getDevices(connection) {
35
- // Implementation will be provided by the consuming project
36
- throw new Error("getDevices method not implemented");
37
- }
38
- /**
39
- * Filters devices based on connection and device list
40
- * @param connection - Connection object
41
- * @param devices - Array of devices to filter
42
- * @returns Promise with filtered devices
43
- */
44
- async filterDevices(connection, devices) {
45
- // Implementation will be provided by the consuming project
46
- throw new Error("filterDevices method not implemented");
47
- }
48
- /**
49
- * Connects to a device service
50
- * @param connection - Connection object
51
- * @param connectionConnect - Connection parameters
52
- * @returns Promise with connection result
53
- */
54
- async connect(connection, connectionConnect) {
55
- // Implementation will be provided by the consuming project
56
- throw new Error("connect method not implemented");
57
- }
58
- }
59
- exports.DeviceCloudService = DeviceCloudService;
@@ -1,3 +0,0 @@
1
- export declare abstract class DeviceHubService {
2
- abstract getHubs(): Promise<any>;
3
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DeviceHubService = void 0;
4
- class DeviceHubService {
5
- }
6
- exports.DeviceHubService = DeviceHubService;
@@ -1,25 +0,0 @@
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
- }
@@ -1,9 +0,0 @@
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;