dt-common-device 1.0.0 → 1.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 (36) hide show
  1. package/README.md +94 -29
  2. package/dist/config/config.d.ts +3 -0
  3. package/dist/config/config.js +24 -0
  4. package/dist/device/cloud/interfaces/IDevicesService.d.ts +3 -3
  5. package/dist/device/cloud/services/Connection.service.d.ts +5 -5
  6. package/dist/device/cloud/services/Connection.service.js +1 -1
  7. package/dist/device/cloud/services/Device.service.d.ts +3 -3
  8. package/dist/device/cloud/services/index.d.ts +3 -2
  9. package/dist/device/cloud/services/index.js +7 -16
  10. package/dist/device/cloud/types.d.ts +29 -4
  11. package/dist/device/cloud/types.js +8 -0
  12. package/dist/device/local/services/Device.service.d.ts +7 -15
  13. package/dist/device/local/services/Device.service.js +23 -14
  14. package/dist/device/local/services/DeviceHub.service.d.ts +8 -18
  15. package/dist/device/local/services/DeviceHub.service.js +24 -12
  16. package/dist/device/local/services/index.d.ts +2 -2
  17. package/dist/device/local/services/index.js +5 -16
  18. package/dist/index.d.ts +3 -2
  19. package/dist/index.js +12 -3
  20. package/dist/types/config.types.d.ts +7 -0
  21. package/dist/types/config.types.js +2 -0
  22. package/dist/types/index.d.ts +1 -0
  23. package/dist/types/index.js +17 -0
  24. package/package.json +1 -1
  25. package/src/config/config.ts +27 -0
  26. package/src/device/cloud/interfaces/IDevicesService.ts +6 -3
  27. package/src/device/cloud/services/Connection.service.ts +5 -13
  28. package/src/device/cloud/services/Device.service.ts +3 -3
  29. package/src/device/cloud/services/index.ts +3 -2
  30. package/src/device/cloud/types.ts +109 -83
  31. package/src/device/local/services/Device.service.ts +25 -30
  32. package/src/device/local/services/DeviceHub.service.ts +26 -31
  33. package/src/device/local/services/index.ts +2 -2
  34. package/src/index.ts +13 -2
  35. package/src/types/config.types.ts +7 -0
  36. package/src/types/index.ts +1 -0
package/README.md CHANGED
@@ -1,73 +1,138 @@
1
+ # dt-common-device
2
+
3
+ A TypeScript library for device management, supporting both cloud and local device operations.
4
+
5
+ ## Installation
6
+
7
+ ```sh
1
8
  npm install dt-common-device
9
+ ```
2
10
 
3
- ## Import
11
+ ## Initialization (Required)
4
12
 
5
- import { cloud, local, cloudInterfaces, localInterfaces } from "dt-common-device";
13
+ Before using any service, you **must** call `initialize()` in your main entry file:
6
14
 
7
- ## Cloud Functions
15
+ ```ts
16
+ import { initialize } from "dt-common-device";
17
+
18
+ initialize({
19
+ DEVICE_SERVICE: "https://api.example.com/device",
20
+ ADMIN_SERVICE: "https://api.example.com/admin",
21
+ OPERATIONAL_SERVICE: "https://api.example.com/ops",
22
+ MONITORING_SERVICE: "https://api.example.com/monitor",
23
+ // ...other config as needed
24
+ });
25
+ ```
8
26
 
9
- These are stubs and must be implemented by the consuming project.
27
+ At least one service URL must be provided.
28
+
29
+ ---
30
+
31
+ ## Importing Services
32
+
33
+ ### Cloud Device Service
10
34
 
11
35
  ```ts
12
- const connectionService = new cloud.ConnectionService();
36
+ import { CloudDeviceService } from "dt-common-device";
13
37
 
14
- // Example: create a connection (must implement this in your project)
15
- await connectionService.createConnection(connectionData, userId);
38
+ const cloudService = new CloudDeviceService();
16
39
 
17
- // Example: get device account (must implement this in your project)
18
- await connectionService.getDeviceAccount(connection);
40
+ // Example: get devices (must implement in your project)
41
+ // await cloudService.getDevices(connection);
19
42
  ```
20
43
 
21
- ## Local Functions
22
-
23
- ### DeviceService
44
+ ### Local Device Service
24
45
 
25
46
  ```ts
26
- const deviceService = new local.DeviceService();
47
+ import { LocalDeviceService } from "dt-common-device";
48
+
49
+ const localService = new LocalDeviceService();
27
50
 
28
51
  // Create a device
29
- await deviceService.createDevice(deviceBody, httpClient);
52
+ await localService.createDevice(deviceBody);
30
53
 
31
54
  // Get a device
32
- const device = await deviceService.getDevice(deviceId, httpClient);
55
+ const device = await localService.getDevice(deviceId);
33
56
 
34
57
  // Update a device
35
- await deviceService.updateDevice(deviceId, updateBody, httpClient);
58
+ await localService.updateDevice(deviceId, updateBody);
36
59
 
37
60
  // Delete a device
38
- await deviceService.deleteDevice(deviceId, httpClient);
61
+ await localService.deleteDevice(deviceId);
39
62
  ```
40
63
 
41
- ## Local Functions
42
-
43
- ### DeviceHubService
64
+ ### Local Device Hub Service
44
65
 
45
66
  ```ts
46
- const deviceHubService = new local.DeviceHubService();
67
+ import { LocalDeviceHubService } from "dt-common-device";
68
+
69
+ const deviceHubService = new LocalDeviceHubService();
47
70
 
48
71
  // Add a hub
49
- await deviceHubService.addHub(hubBody, httpClient);
72
+ await deviceHubService.addHub(hubBody);
50
73
 
51
74
  // Get hubs
52
- const hubs = await deviceHubService.getHubs(hubIds, httpClient);
75
+ const hubs = await deviceHubService.getHubs(hubIds);
53
76
 
54
77
  // Get a single hub
55
- const hub = await deviceHubService.getHub(hubId, httpClient);
78
+ const hub = await deviceHubService.getHub(hubId);
56
79
 
57
80
  // Update a hub
58
- await deviceHubService.updateHub(hubId, updateBody, httpClient);
81
+ await deviceHubService.updateHub(hubId, updateBody);
59
82
 
60
83
  // Delete a hub
61
- await deviceHubService.deleteHub(hubId, httpClient);
84
+ await deviceHubService.deleteHub(hubId);
62
85
 
63
86
  // Delete multiple hubs
64
- await deviceHubService.deleteAllHubs(hubIds, httpClient);
87
+ await deviceHubService.deleteAllHubs(hubIds);
65
88
  ```
66
89
 
67
- ### Types
90
+ ---
91
+
92
+ ## Importing Types and Interfaces
68
93
 
69
94
  All types and interfaces are available as named exports:
70
95
 
71
96
  ```ts
72
- import { IDevice, IHubCreateParams } from "dt-common-device";
97
+ import { IDevice, IHubCreateParams, IConnection } from "dt-common-device";
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Notes
103
+
104
+ - You **must** call `initialize()` before using any service. If not, you will get a runtime error.
105
+ - Cloud service methods are stubs and must be implemented by the consuming project.
106
+ - All types are strongly typed for TypeScript support.
107
+
108
+ ---
109
+
110
+ ## Example Usage
111
+
112
+ ```ts
113
+ import {
114
+ initialize,
115
+ CloudDeviceService,
116
+ LocalDeviceService,
117
+ IDevice,
118
+ } from "dt-common-device";
119
+
120
+ initialize({
121
+ DEVICE_SERVICE: "https://api.example.com/device",
122
+ });
123
+
124
+ const cloudService = new CloudDeviceService();
125
+ const localService = new LocalDeviceService();
126
+
127
+ async function main() {
128
+ // Example: get devices from cloud (must implement in your project)
129
+ // const devices: IDevice[] = await cloudService.getDevices(connection);
130
+
131
+ // Example: create a device locally
132
+ await localService.createDevice({
133
+ /* device params */
134
+ });
135
+ }
136
+
137
+ main();
73
138
  ```
@@ -0,0 +1,3 @@
1
+ import { DeviceConfig } from "../types";
2
+ export declare function initialize(cfg: DeviceConfig): void;
3
+ export declare function getConfig(): DeviceConfig;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initialize = initialize;
4
+ exports.getConfig = getConfig;
5
+ let config = null;
6
+ function initialize(cfg) {
7
+ // Check if at least one service is provided
8
+ const hasAtLeastOneService = [
9
+ "ADMIN_SERVICE",
10
+ "OPERATIONAL_SERVICE",
11
+ "DEVICE_SERVICE",
12
+ "MONITORING_SERVICE",
13
+ ].some((key) => Boolean(cfg[key]));
14
+ if (!hasAtLeastOneService) {
15
+ throw new Error("At least one http service must be initialized");
16
+ }
17
+ config = { ...cfg };
18
+ }
19
+ function getConfig() {
20
+ if (!config) {
21
+ throw new Error("dt-common-device: Library not initialized. Call initialize() first.");
22
+ }
23
+ return config;
24
+ }
@@ -1,9 +1,9 @@
1
1
  import { IConnection } from "../types";
2
2
  export interface IDeviceService {
3
- getDevices(connection: IConnection): Promise<any[]>;
4
- getDevice(connectionId: string, deviceId: string): Promise<any>;
3
+ getDevices(connection: IConnection): Promise<Record<string, any>[]>;
4
+ getDevice(connectionId: string, deviceId: string): Promise<Record<string, any>>;
5
5
  getStatus(connectionId: string, deviceId: string): Promise<string | null>;
6
- getState(deviceId: string): Promise<any>;
6
+ getState(deviceId: string): Promise<Record<string, any>>;
7
7
  getGateways(connectionId: string): Promise<any[] | null>;
8
8
  getGatewayDetails(connectionId: string, gatewayId: string): Promise<any>;
9
9
  }
@@ -1,5 +1,5 @@
1
1
  import { IDeviceConnectionService } from "../interfaces";
2
- import { IConnection, IConnectionConnectParams, IDevice, IDeviceAccountResponse } from "../types";
2
+ import { IConnection, IDevice, IDeviceAccountResponse } from "../types";
3
3
  /**
4
4
  * Device Cloud Service Class
5
5
  * Implements IDeviceCloudService interface with empty implementations
@@ -12,7 +12,7 @@ export declare class ConnectionService implements IDeviceConnectionService {
12
12
  * @param userId - User identifier
13
13
  * @returns Promise with connection result
14
14
  */
15
- createConnection(data: IConnection, userId: string): Promise<any>;
15
+ createConnection(data: IConnection, userId: string): Promise<void>;
16
16
  /**
17
17
  * Gets device account information for a connection
18
18
  * @param connection - Connection object
@@ -24,19 +24,19 @@ export declare class ConnectionService implements IDeviceConnectionService {
24
24
  * @param connection - Connection object
25
25
  * @returns Promise with array of devices
26
26
  */
27
- getDevices(connection: IConnection): Promise<any>;
27
+ getDevices(connection: IConnection): Promise<Record<string, any>[]>;
28
28
  /**
29
29
  * Filters devices based on connection and device list
30
30
  * @param connection - Connection object
31
31
  * @param devices - Array of devices to filter
32
32
  * @returns Promise with filtered devices
33
33
  */
34
- filterDevices(connection: IConnection, devices: any[]): Promise<IDevice[]>;
34
+ filterDevices(connection: IConnection, devices: Record<string, any>[]): Promise<IDevice[]>;
35
35
  /**
36
36
  * Connects to a device service
37
37
  * @param connection - Connection object
38
38
  * @param connectionConnect - Connection parameters
39
39
  * @returns Promise with connection result
40
40
  */
41
- connect(connection: IConnection, connectionConnect: IConnectionConnectParams): Promise<any>;
41
+ connect(connection: IConnection): Promise<void>;
42
42
  }
@@ -51,7 +51,7 @@ class ConnectionService {
51
51
  * @param connectionConnect - Connection parameters
52
52
  * @returns Promise with connection result
53
53
  */
54
- async connect(connection, connectionConnect) {
54
+ async connect(connection) {
55
55
  // Implementation will be provided by the consuming project
56
56
  throw new Error("connect method not implemented");
57
57
  }
@@ -1,10 +1,10 @@
1
1
  import { IDeviceService } from "../interfaces";
2
2
  import { IConnection } from "../types";
3
3
  export declare class DeviceService implements IDeviceService {
4
- getDevices(connection: IConnection): Promise<any[]>;
4
+ getDevices(connection: IConnection): Promise<Record<string, any>[]>;
5
5
  getDevice(connectionId: string, deviceId: string): Promise<any>;
6
6
  getStatus(connectionId: string, deviceId: string): Promise<string | null>;
7
- getState(deviceId: string): Promise<any>;
7
+ getState(deviceId: string): Promise<Record<string, any>>;
8
8
  getGateways(connectionId: string): Promise<any[] | null>;
9
- getGatewayDetails(connectionId: string, gatewayId: string): Promise<any>;
9
+ getGatewayDetails(connectionId: string, gatewayId: string): Promise<Record<string, any>>;
10
10
  }
@@ -1,2 +1,3 @@
1
- export * from "./Connection.service";
2
- export * from "./Device.service";
1
+ export { DeviceService as CloudDeviceService } from "./Device.service";
2
+ export { ConnectionService as CloudConnectionService } from "./Connection.service";
3
+ export { DeviceHubService as CloudDeviceHubService } from "./DeviceHub.service";
@@ -1,19 +1,10 @@
1
1
  "use strict";
2
2
  // Device Cloud Services - Export all service classes
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
3
  Object.defineProperty(exports, "__esModule", { value: true });
18
- __exportStar(require("./Connection.service"), exports);
19
- __exportStar(require("./Device.service"), exports);
4
+ exports.CloudDeviceHubService = exports.CloudConnectionService = exports.CloudDeviceService = void 0;
5
+ var Device_service_1 = require("./Device.service");
6
+ Object.defineProperty(exports, "CloudDeviceService", { enumerable: true, get: function () { return Device_service_1.DeviceService; } });
7
+ var Connection_service_1 = require("./Connection.service");
8
+ Object.defineProperty(exports, "CloudConnectionService", { enumerable: true, get: function () { return Connection_service_1.ConnectionService; } });
9
+ var DeviceHub_service_1 = require("./DeviceHub.service");
10
+ Object.defineProperty(exports, "CloudDeviceHubService", { enumerable: true, get: function () { return DeviceHub_service_1.DeviceHubService; } });
@@ -1,12 +1,32 @@
1
- export interface IConnection {
1
+ /**
2
+ * Base entity for all models.
3
+ * All date fields must be ISO 8601 strings.
4
+ */
5
+ export declare class BaseEntity {
6
+ id?: string;
7
+ createdAt?: string;
8
+ updatedAt?: string;
9
+ }
10
+ /**
11
+ * Represents a connection to a device provider.
12
+ * WARNING: Do not log or expose sensitive fields (accessToken, clientSecret).
13
+ */
14
+ export interface IConnection extends BaseEntity {
2
15
  connectionName: string;
3
16
  connectionRefId: string;
4
17
  propertyId: string;
5
18
  connectionProvider: ConnectionProvider;
19
+ /** Sensitive. */
6
20
  accessToken?: string;
21
+ /** Sensitive. */
7
22
  clientId?: string;
23
+ /** Sensitive. */
8
24
  clientSecret?: string;
9
25
  }
26
+ /**
27
+ * Represents a device in the system.
28
+ * All date fields must be ISO 8601 strings.
29
+ */
10
30
  export interface IDevice {
11
31
  deviceId: string;
12
32
  propertyId: string;
@@ -47,13 +67,18 @@ export interface IDevice {
47
67
  };
48
68
  lastUpdated?: string;
49
69
  };
50
- state?: Record<string, any>;
51
- metaData?: Record<string, any>;
70
+ state?: Record<string, unknown>;
71
+ metaData?: Record<string, unknown>;
52
72
  hubDeviceDetails?: IDevice[];
53
73
  }
74
+ /**
75
+ * Device account response from provider.
76
+ * WARNING: Do not log or expose connection_access_token.
77
+ */
54
78
  export interface IDeviceAccountResponse {
55
79
  id: string;
56
80
  connection_name: string;
81
+ /** Sensitive. */
57
82
  connection_access_token: string;
58
83
  connection_provider: string;
59
84
  totalDevices: number;
@@ -63,7 +88,7 @@ export interface IDeviceAccountResponse {
63
88
  export interface IConnectionConnectParams {
64
89
  code?: string;
65
90
  propertyId?: string;
66
- [key: string]: any;
91
+ [key: string]: unknown;
67
92
  }
68
93
  export interface ConnectionProvider {
69
94
  Smartthings: "Smartthings";
@@ -1,3 +1,11 @@
1
1
  "use strict";
2
2
  // Device Cloud Type Interfaces for DeviceThread Common Library
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.BaseEntity = void 0;
5
+ /**
6
+ * Base entity for all models.
7
+ * All date fields must be ISO 8601 strings.
8
+ */
9
+ class BaseEntity {
10
+ }
11
+ exports.BaseEntity = BaseEntity;
@@ -1,18 +1,10 @@
1
1
  import { IDeviceCreateParams } from "../interfaces";
2
2
  export declare class DeviceService {
3
- createDevice(body: IDeviceCreateParams, httpClient: {
4
- post: (url: string, options: any) => Promise<any>;
5
- }): Promise<void>;
6
- getDevice(deviceId: string, httpClient: {
7
- get: (url: string) => Promise<any>;
8
- }): Promise<any>;
9
- getPropertyDevices(propertyId: string, httpClient: {
10
- get: (url: string, options: any) => Promise<any>;
11
- }): Promise<any>;
12
- updateDevice(deviceId: string, body: any, httpClient: {
13
- put: (url: string, options: any) => Promise<any>;
14
- }): Promise<any>;
15
- deleteDevice(deviceId: string, httpClient: {
16
- delete: (url: string) => Promise<any>;
17
- }): Promise<any>;
3
+ private readonly baseUrl;
4
+ constructor();
5
+ createDevice(body: IDeviceCreateParams): Promise<void>;
6
+ getDevice(deviceId: string): Promise<any>;
7
+ getPropertyDevices(propertyId: string): Promise<any>;
8
+ updateDevice(deviceId: string, body: any): Promise<any>;
9
+ deleteDevice(deviceId: string): Promise<any>;
18
10
  }
@@ -1,27 +1,36 @@
1
1
  "use strict";
2
2
  // src/device/local/services/Device.service.ts
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
4
7
  exports.DeviceService = void 0;
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const config_1 = require("../../../config/config");
5
10
  class DeviceService {
6
- async createDevice(body, httpClient) {
7
- // Create main device
8
- await httpClient.post("/devices", { body });
11
+ constructor() {
12
+ const { DEVICE_SERVICE } = (0, config_1.getConfig)();
13
+ if (!DEVICE_SERVICE) {
14
+ throw new Error("DEVICE_SERVICE is not configured. Call initialize() first with DEVICE_SERVICE.");
15
+ }
16
+ this.baseUrl = DEVICE_SERVICE;
9
17
  }
10
- async getDevice(deviceId, httpClient) {
11
- return await httpClient.get(`/devices/${deviceId}`);
18
+ async createDevice(body) {
19
+ await axios_1.default.post(`${this.baseUrl}/devices`, body);
12
20
  }
13
- async getPropertyDevices(propertyId, httpClient) {
14
- return await httpClient.get(`/devices`, {
15
- params: {
16
- propertyId,
17
- },
21
+ async getDevice(deviceId) {
22
+ return await axios_1.default.get(`${this.baseUrl}/devices/${deviceId}`);
23
+ }
24
+ async getPropertyDevices(propertyId) {
25
+ return await axios_1.default.get(`${this.baseUrl}/devices`, {
26
+ params: { propertyId },
18
27
  });
19
28
  }
20
- async updateDevice(deviceId, body, httpClient) {
21
- return await httpClient.put(`/devices/${deviceId}`, { body });
29
+ async updateDevice(deviceId, body) {
30
+ return await axios_1.default.put(`${this.baseUrl}/devices/${deviceId}`, body);
22
31
  }
23
- async deleteDevice(deviceId, httpClient) {
24
- return await httpClient.delete(`/devices/${deviceId}`);
32
+ async deleteDevice(deviceId) {
33
+ return await axios_1.default.delete(`${this.baseUrl}/devices/${deviceId}`);
25
34
  }
26
35
  }
27
36
  exports.DeviceService = DeviceService;
@@ -1,21 +1,11 @@
1
1
  import { IHubCreateParams } from "../interfaces";
2
2
  export declare class DeviceHubService {
3
- addHub(body: IHubCreateParams, httpClient: {
4
- post: (url: string, options: any) => Promise<any>;
5
- }): Promise<any>;
6
- getHubs(hubIds: string[], httpClient: {
7
- get: (url: string, options?: any) => Promise<any>;
8
- }): Promise<any>;
9
- getHub(hubId: string, httpClient: {
10
- get: (url: string) => Promise<any>;
11
- }): Promise<any>;
12
- updateHub(hubId: string, body: any, httpClient: {
13
- put: (url: string, options: any) => Promise<any>;
14
- }): Promise<any>;
15
- deleteHub(hubId: string, httpClient: {
16
- delete: (url: string) => Promise<any>;
17
- }): Promise<any>;
18
- deleteAllHubs(hubIds: string[], httpClient: {
19
- delete: (url: string) => Promise<any>;
20
- }): Promise<any>;
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>;
21
11
  }
@@ -1,28 +1,40 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.DeviceHubService = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const config_1 = require("../../../config/config");
4
9
  class DeviceHubService {
5
- async addHub(body, httpClient) {
6
- return await httpClient.post(`/devices/hubs`, { body });
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);
7
19
  }
8
20
  //get hubs takes an array of hub ids as query params
9
- async getHubs(hubIds, httpClient) {
21
+ async getHubs(hubIds) {
10
22
  const query = hubIds && hubIds.length ? `?ids=${hubIds.join(",")}` : "";
11
- return await httpClient.get(`/devices/hubs${query}`);
23
+ return await axios_1.default.get(`${this.baseUrl}/devices/hubs${query}`);
12
24
  }
13
25
  //get hub takes a hub id in params
14
- async getHub(hubId, httpClient) {
15
- return await httpClient.get(`/devices/hubs/${hubId}`);
26
+ async getHub(hubId) {
27
+ return await axios_1.default.get(`${this.baseUrl}/devices/hubs/${hubId}`);
16
28
  }
17
- async updateHub(hubId, body, httpClient) {
18
- return await httpClient.put(`/devices/hubs/${hubId}`, { body });
29
+ async updateHub(hubId, body) {
30
+ return await axios_1.default.put(`${this.baseUrl}/devices/hubs/${hubId}`, body);
19
31
  }
20
- async deleteHub(hubId, httpClient) {
21
- return await httpClient.delete(`/devices/hubs/${hubId}`);
32
+ async deleteHub(hubId) {
33
+ return await axios_1.default.delete(`${this.baseUrl}/devices/hubs/${hubId}`);
22
34
  }
23
- async deleteAllHubs(hubIds, httpClient) {
35
+ async deleteAllHubs(hubIds) {
24
36
  const query = hubIds.length ? `?ids=${hubIds.join(",")}` : "";
25
- return await httpClient.delete(`/devices/hubs${query}`);
37
+ return await axios_1.default.delete(`${this.baseUrl}/devices/hubs${query}`);
26
38
  }
27
39
  }
28
40
  exports.DeviceHubService = DeviceHubService;
@@ -1,2 +1,2 @@
1
- export * from "./Device.service";
2
- export * from "./DeviceHub.service";
1
+ export { DeviceService as LocalDeviceService } from "./Device.service";
2
+ export { DeviceHubService as LocalDeviceHubService } from "./DeviceHub.service";
@@ -1,18 +1,7 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Device.service"), exports);
18
- __exportStar(require("./DeviceHub.service"), exports);
3
+ exports.LocalDeviceHubService = exports.LocalDeviceService = void 0;
4
+ var Device_service_1 = require("./Device.service");
5
+ Object.defineProperty(exports, "LocalDeviceService", { enumerable: true, get: function () { return Device_service_1.DeviceService; } });
6
+ var DeviceHub_service_1 = require("./DeviceHub.service");
7
+ Object.defineProperty(exports, "LocalDeviceHubService", { enumerable: true, get: function () { return DeviceHub_service_1.DeviceHubService; } });
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export * as cloud from "./device/cloud/services";
1
+ export { CloudDeviceService, CloudDeviceHubService, CloudConnectionService, } from "./device/cloud/services";
2
+ export { LocalDeviceService, LocalDeviceHubService, } from "./device/local/services";
2
3
  export * as cloudInterfaces from "./device/cloud/interfaces";
3
4
  export * from "./device/cloud/types";
4
- export * as local from "./device/local/services";
5
5
  export * as localInterfaces from "./device/local/interfaces";
6
+ export { initialize, getConfig } from "./config/config";
package/dist/index.js CHANGED
@@ -37,11 +37,20 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
37
37
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.localInterfaces = exports.local = exports.cloudInterfaces = exports.cloud = void 0;
40
+ exports.getConfig = exports.initialize = exports.localInterfaces = exports.cloudInterfaces = exports.LocalDeviceHubService = exports.LocalDeviceService = exports.CloudConnectionService = exports.CloudDeviceHubService = exports.CloudDeviceService = void 0;
41
41
  // Cloud exports
42
- exports.cloud = __importStar(require("./device/cloud/services"));
42
+ var services_1 = require("./device/cloud/services");
43
+ Object.defineProperty(exports, "CloudDeviceService", { enumerable: true, get: function () { return services_1.CloudDeviceService; } });
44
+ Object.defineProperty(exports, "CloudDeviceHubService", { enumerable: true, get: function () { return services_1.CloudDeviceHubService; } });
45
+ Object.defineProperty(exports, "CloudConnectionService", { enumerable: true, get: function () { return services_1.CloudConnectionService; } });
46
+ var services_2 = require("./device/local/services");
47
+ Object.defineProperty(exports, "LocalDeviceService", { enumerable: true, get: function () { return services_2.LocalDeviceService; } });
48
+ Object.defineProperty(exports, "LocalDeviceHubService", { enumerable: true, get: function () { return services_2.LocalDeviceHubService; } });
43
49
  exports.cloudInterfaces = __importStar(require("./device/cloud/interfaces"));
44
50
  __exportStar(require("./device/cloud/types"), exports);
45
51
  // Local exports
46
- exports.local = __importStar(require("./device/local/services"));
47
52
  exports.localInterfaces = __importStar(require("./device/local/interfaces"));
53
+ //initialize export
54
+ var config_1 = require("./config/config");
55
+ Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return config_1.initialize; } });
56
+ Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return config_1.getConfig; } });
@@ -0,0 +1,7 @@
1
+ export type DeviceConfig = {
2
+ ADMIN_SERVICE: string;
3
+ OPERATIONAL_SERVICE: string;
4
+ DEVICE_SERVICE: string;
5
+ MONITORING_SERVICE: string;
6
+ [key: string]: string;
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./config.types";
@@ -0,0 +1,17 @@
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -0,0 +1,27 @@
1
+ import { DeviceConfig } from "../types";
2
+
3
+ let config: DeviceConfig | null = null;
4
+
5
+ export function initialize(cfg: DeviceConfig) {
6
+ // Check if at least one service is provided
7
+ const hasAtLeastOneService = [
8
+ "ADMIN_SERVICE",
9
+ "OPERATIONAL_SERVICE",
10
+ "DEVICE_SERVICE",
11
+ "MONITORING_SERVICE",
12
+ ].some((key) => Boolean(cfg[key]));
13
+
14
+ if (!hasAtLeastOneService) {
15
+ throw new Error("At least one http service must be initialized");
16
+ }
17
+ config = { ...cfg };
18
+ }
19
+
20
+ export function getConfig(): DeviceConfig {
21
+ if (!config) {
22
+ throw new Error(
23
+ "dt-common-device: Library not initialized. Call initialize() first."
24
+ );
25
+ }
26
+ return config;
27
+ }
@@ -1,10 +1,13 @@
1
1
  import { IConnection } from "../types";
2
2
 
3
3
  export interface IDeviceService {
4
- getDevices(connection: IConnection): Promise<any[]>;
5
- getDevice(connectionId: string, deviceId: string): Promise<any>;
4
+ getDevices(connection: IConnection): Promise<Record<string, any>[]>;
5
+ getDevice(
6
+ connectionId: string,
7
+ deviceId: string
8
+ ): Promise<Record<string, any>>;
6
9
  getStatus(connectionId: string, deviceId: string): Promise<string | null>;
7
- getState(deviceId: string): Promise<any>;
10
+ getState(deviceId: string): Promise<Record<string, any>>;
8
11
  getGateways(connectionId: string): Promise<any[] | null>;
9
12
  getGatewayDetails(connectionId: string, gatewayId: string): Promise<any>;
10
13
  }
@@ -1,11 +1,6 @@
1
1
  // Device Cloud Service - Class Implementation
2
2
  import { IDeviceConnectionService } from "../interfaces";
3
- import {
4
- IConnection,
5
- IConnectionConnectParams,
6
- IDevice,
7
- IDeviceAccountResponse,
8
- } from "../types";
3
+ import { IConnection, IDevice, IDeviceAccountResponse } from "../types";
9
4
 
10
5
  /**
11
6
  * Device Cloud Service Class
@@ -19,7 +14,7 @@ export class ConnectionService implements IDeviceConnectionService {
19
14
  * @param userId - User identifier
20
15
  * @returns Promise with connection result
21
16
  */
22
- async createConnection(data: IConnection, userId: string): Promise<any> {
17
+ async createConnection(data: IConnection, userId: string) {
23
18
  // Implementation will be provided by the consuming project
24
19
  throw new Error("createConnection method not implemented");
25
20
  }
@@ -41,7 +36,7 @@ export class ConnectionService implements IDeviceConnectionService {
41
36
  * @param connection - Connection object
42
37
  * @returns Promise with array of devices
43
38
  */
44
- async getDevices(connection: IConnection): Promise<any> {
39
+ async getDevices(connection: IConnection): Promise<Record<string, any>[]> {
45
40
  // Implementation will be provided by the consuming project
46
41
  throw new Error("getDevices method not implemented");
47
42
  }
@@ -54,7 +49,7 @@ export class ConnectionService implements IDeviceConnectionService {
54
49
  */
55
50
  async filterDevices(
56
51
  connection: IConnection,
57
- devices: any[]
52
+ devices: Record<string, any>[]
58
53
  ): Promise<IDevice[]> {
59
54
  // Implementation will be provided by the consuming project
60
55
  throw new Error("filterDevices method not implemented");
@@ -66,10 +61,7 @@ export class ConnectionService implements IDeviceConnectionService {
66
61
  * @param connectionConnect - Connection parameters
67
62
  * @returns Promise with connection result
68
63
  */
69
- async connect(
70
- connection: IConnection,
71
- connectionConnect: IConnectionConnectParams
72
- ): Promise<any> {
64
+ async connect(connection: IConnection) {
73
65
  // Implementation will be provided by the consuming project
74
66
  throw new Error("connect method not implemented");
75
67
  }
@@ -2,7 +2,7 @@ import { IDeviceService } from "../interfaces";
2
2
  import { IConnection } from "../types";
3
3
 
4
4
  export class DeviceService implements IDeviceService {
5
- async getDevices(connection: IConnection): Promise<any[]> {
5
+ async getDevices(connection: IConnection): Promise<Record<string, any>[]> {
6
6
  // Implementation will be provided by the consuming project
7
7
  throw new Error("getDevices method not implemented");
8
8
  }
@@ -20,7 +20,7 @@ export class DeviceService implements IDeviceService {
20
20
  throw new Error("getDeviceStatus method not implemented");
21
21
  }
22
22
 
23
- async getState(deviceId: string): Promise<any> {
23
+ async getState(deviceId: string): Promise<Record<string, any>> {
24
24
  // Implementation will be provided by the consuming project
25
25
  throw new Error("getState method not implemented");
26
26
  }
@@ -33,7 +33,7 @@ export class DeviceService implements IDeviceService {
33
33
  async getGatewayDetails(
34
34
  connectionId: string,
35
35
  gatewayId: string
36
- ): Promise<any> {
36
+ ): Promise<Record<string, any>> {
37
37
  // Implementation will be provided by the consuming project
38
38
  throw new Error("getGatewayDetails method not implemented");
39
39
  }
@@ -1,4 +1,5 @@
1
1
  // Device Cloud Services - Export all service classes
2
2
 
3
- export * from "./Connection.service";
4
- export * from "./Device.service";
3
+ export { DeviceService as CloudDeviceService } from "./Device.service";
4
+ export { ConnectionService as CloudConnectionService } from "./Connection.service";
5
+ export { DeviceHubService as CloudDeviceHubService } from "./DeviceHub.service";
@@ -1,83 +1,109 @@
1
- // Device Cloud Type Interfaces for DeviceThread Common Library
2
-
3
- export interface IConnection {
4
- connectionName: string;
5
- connectionRefId: string;
6
- propertyId: string;
7
- connectionProvider: ConnectionProvider;
8
- accessToken?: string;
9
- clientId?: string;
10
- clientSecret?: string;
11
- }
12
-
13
- export interface IDevice {
14
- deviceId: string;
15
- propertyId: string;
16
- name: string;
17
- hubId: string[];
18
- specifications?: {
19
- manufacturer?: string;
20
- model?: string;
21
- firmware?: {
22
- version?: string;
23
- newVersionAvailable?: boolean;
24
- newVersion?: string;
25
- mandatoryUpdate?: boolean;
26
- };
27
- };
28
- protocol?: {
29
- location?: {
30
- id?: string;
31
- name?: string;
32
- city?: string;
33
- };
34
- name?: string;
35
- room?: {
36
- id?: string;
37
- name?: string;
38
- };
39
- accountId?: string;
40
- };
41
- deviceType: {
42
- id: string;
43
- type: string;
44
- };
45
- status: {
46
- online: boolean;
47
- error?: {
48
- type?: string;
49
- message?: string;
50
- };
51
- lastUpdated?: string;
52
- };
53
- state?: Record<string, any>;
54
- metaData?: Record<string, any>;
55
- hubDeviceDetails?: IDevice[];
56
- }
57
-
58
- export interface IDeviceAccountResponse {
59
- id: string;
60
- connection_name: string;
61
- connection_access_token: string;
62
- connection_provider: string;
63
- totalDevices: number;
64
- connection_ref_id: string;
65
- isActive: boolean;
66
- }
67
-
68
- export interface IConnectionConnectParams {
69
- code?: string;
70
- propertyId?: string;
71
- [key: string]: any;
72
- }
73
-
74
- export interface ConnectionProvider {
75
- Smartthings: "Smartthings";
76
- SaltoKS: "SaltoKS";
77
- Tuya: "Tuya";
78
- TTLock: "TTLock";
79
- Schlage: "Schlage";
80
- YaleWifi: "YaleWifi";
81
- Devicethread: "Devicethread";
82
- Sensibo: "Sensibo";
83
- }
1
+ // Device Cloud Type Interfaces for DeviceThread Common Library
2
+
3
+ /**
4
+ * Base entity for all models.
5
+ * All date fields must be ISO 8601 strings.
6
+ */
7
+ export class BaseEntity {
8
+ id?: string;
9
+ createdAt?: string; // ISO 8601
10
+ updatedAt?: string; // ISO 8601
11
+ }
12
+
13
+ /**
14
+ * Represents a connection to a device provider.
15
+ * WARNING: Do not log or expose sensitive fields (accessToken, clientSecret).
16
+ */
17
+ export interface IConnection extends BaseEntity {
18
+ connectionName: string;
19
+ connectionRefId: string;
20
+ propertyId: string;
21
+ connectionProvider: ConnectionProvider;
22
+ /** Sensitive. */
23
+ accessToken?: string;
24
+ /** Sensitive. */
25
+ clientId?: string;
26
+ /** Sensitive. */
27
+ clientSecret?: string;
28
+ }
29
+
30
+ /**
31
+ * Represents a device in the system.
32
+ * All date fields must be ISO 8601 strings.
33
+ */
34
+ export interface IDevice {
35
+ deviceId: string;
36
+ propertyId: string;
37
+ name: string;
38
+ hubId: string[];
39
+ specifications?: {
40
+ manufacturer?: string;
41
+ model?: string;
42
+ firmware?: {
43
+ version?: string;
44
+ newVersionAvailable?: boolean;
45
+ newVersion?: string;
46
+ mandatoryUpdate?: boolean;
47
+ };
48
+ };
49
+ protocol?: {
50
+ location?: {
51
+ id?: string;
52
+ name?: string;
53
+ city?: string;
54
+ };
55
+ name?: string;
56
+ room?: {
57
+ id?: string;
58
+ name?: string;
59
+ };
60
+ accountId?: string;
61
+ };
62
+ deviceType: {
63
+ id: string;
64
+ type: string;
65
+ };
66
+ status: {
67
+ online: boolean;
68
+ error?: {
69
+ type?: string;
70
+ message?: string;
71
+ };
72
+ lastUpdated?: string; // ISO 8601
73
+ };
74
+ state?: Record<string, unknown>;
75
+ metaData?: Record<string, unknown>;
76
+ hubDeviceDetails?: IDevice[];
77
+ }
78
+
79
+ /**
80
+ * Device account response from provider.
81
+ * WARNING: Do not log or expose connection_access_token.
82
+ */
83
+ export interface IDeviceAccountResponse {
84
+ id: string;
85
+ connection_name: string;
86
+ /** Sensitive. */
87
+ connection_access_token: string;
88
+ connection_provider: string;
89
+ totalDevices: number;
90
+ connection_ref_id: string;
91
+ isActive: boolean;
92
+ }
93
+
94
+ export interface IConnectionConnectParams {
95
+ code?: string;
96
+ propertyId?: string;
97
+ [key: string]: unknown;
98
+ }
99
+
100
+ export interface ConnectionProvider {
101
+ Smartthings: "Smartthings";
102
+ SaltoKS: "SaltoKS";
103
+ Tuya: "Tuya";
104
+ TTLock: "TTLock";
105
+ Schlage: "Schlage";
106
+ YaleWifi: "YaleWifi";
107
+ Devicethread: "Devicethread";
108
+ Sensibo: "Sensibo";
109
+ }
@@ -1,46 +1,41 @@
1
1
  // src/device/local/services/Device.service.ts
2
2
 
3
+ import axios from "axios";
4
+ import { getConfig } from "../../../config/config";
3
5
  import { IDeviceCreateParams } from "../interfaces";
4
6
 
5
7
  export class DeviceService {
6
- async createDevice(
7
- body: IDeviceCreateParams,
8
- httpClient: { post: (url: string, options: any) => Promise<any> }
9
- ): Promise<void> {
10
- // Create main device
11
- await httpClient.post("/devices", { body });
8
+ private readonly baseUrl: string;
9
+
10
+ constructor() {
11
+ const { DEVICE_SERVICE } = getConfig();
12
+ if (!DEVICE_SERVICE) {
13
+ throw new Error(
14
+ "DEVICE_SERVICE is not configured. Call initialize() first with DEVICE_SERVICE."
15
+ );
16
+ }
17
+ this.baseUrl = DEVICE_SERVICE;
18
+ }
19
+
20
+ async createDevice(body: IDeviceCreateParams): Promise<void> {
21
+ await axios.post(`${this.baseUrl}/devices`, body);
12
22
  }
13
23
 
14
- async getDevice(
15
- deviceId: string,
16
- httpClient: { get: (url: string) => Promise<any> }
17
- ): Promise<any> {
18
- return await httpClient.get(`/devices/${deviceId}`);
24
+ async getDevice(deviceId: string): Promise<any> {
25
+ return await axios.get(`${this.baseUrl}/devices/${deviceId}`);
19
26
  }
20
27
 
21
- async getPropertyDevices(
22
- propertyId: string,
23
- httpClient: { get: (url: string, options: any) => Promise<any> }
24
- ): Promise<any> {
25
- return await httpClient.get(`/devices`, {
26
- params: {
27
- propertyId,
28
- },
28
+ async getPropertyDevices(propertyId: string): Promise<any> {
29
+ return await axios.get(`${this.baseUrl}/devices`, {
30
+ params: { propertyId },
29
31
  });
30
32
  }
31
33
 
32
- async updateDevice(
33
- deviceId: string,
34
- body: any,
35
- httpClient: { put: (url: string, options: any) => Promise<any> }
36
- ): Promise<any> {
37
- return await httpClient.put(`/devices/${deviceId}`, { body });
34
+ async updateDevice(deviceId: string, body: any): Promise<any> {
35
+ return await axios.put(`${this.baseUrl}/devices/${deviceId}`, body);
38
36
  }
39
37
 
40
- async deleteDevice(
41
- deviceId: string,
42
- httpClient: { delete: (url: string) => Promise<any> }
43
- ): Promise<any> {
44
- return await httpClient.delete(`/devices/${deviceId}`);
38
+ async deleteDevice(deviceId: string): Promise<any> {
39
+ return await axios.delete(`${this.baseUrl}/devices/${deviceId}`);
45
40
  }
46
41
  }
@@ -1,50 +1,45 @@
1
+ import axios from "axios";
2
+ import { getConfig } from "../../../config/config";
1
3
  import { IHubCreateParams } from "../interfaces";
2
4
 
3
5
  export class DeviceHubService {
4
- async addHub(
5
- body: IHubCreateParams,
6
- httpClient: { post: (url: string, options: any) => Promise<any> }
7
- ): Promise<any> {
8
- return await httpClient.post(`/devices/hubs`, { body });
6
+ private readonly baseUrl: string;
7
+
8
+ constructor() {
9
+ const { DEVICE_SERVICE } = getConfig();
10
+ if (!DEVICE_SERVICE) {
11
+ throw new Error(
12
+ "DEVICE_SERVICE is not configured. Call initialize() first with DEVICE_SERVICE."
13
+ );
14
+ }
15
+ this.baseUrl = DEVICE_SERVICE;
16
+ }
17
+
18
+ async addHub(body: IHubCreateParams): Promise<any> {
19
+ return await axios.post(`${this.baseUrl}/devices/hubs`, body);
9
20
  }
10
21
 
11
22
  //get hubs takes an array of hub ids as query params
12
- async getHubs(
13
- hubIds: string[],
14
- httpClient: { get: (url: string, options?: any) => Promise<any> }
15
- ): Promise<any> {
23
+ async getHubs(hubIds: string[]): Promise<any> {
16
24
  const query = hubIds && hubIds.length ? `?ids=${hubIds.join(",")}` : "";
17
- return await httpClient.get(`/devices/hubs${query}`);
25
+ return await axios.get(`${this.baseUrl}/devices/hubs${query}`);
18
26
  }
19
27
 
20
28
  //get hub takes a hub id in params
21
- async getHub(
22
- hubId: string,
23
- httpClient: { get: (url: string) => Promise<any> }
24
- ): Promise<any> {
25
- return await httpClient.get(`/devices/hubs/${hubId}`);
29
+ async getHub(hubId: string): Promise<any> {
30
+ return await axios.get(`${this.baseUrl}/devices/hubs/${hubId}`);
26
31
  }
27
32
 
28
- async updateHub(
29
- hubId: string,
30
- body: any,
31
- httpClient: { put: (url: string, options: any) => Promise<any> }
32
- ): Promise<any> {
33
- return await httpClient.put(`/devices/hubs/${hubId}`, { body });
33
+ async updateHub(hubId: string, body: any): Promise<any> {
34
+ return await axios.put(`${this.baseUrl}/devices/hubs/${hubId}`, body);
34
35
  }
35
36
 
36
- async deleteHub(
37
- hubId: string,
38
- httpClient: { delete: (url: string) => Promise<any> }
39
- ): Promise<any> {
40
- return await httpClient.delete(`/devices/hubs/${hubId}`);
37
+ async deleteHub(hubId: string): Promise<any> {
38
+ return await axios.delete(`${this.baseUrl}/devices/hubs/${hubId}`);
41
39
  }
42
40
 
43
- async deleteAllHubs(
44
- hubIds: string[],
45
- httpClient: { delete: (url: string) => Promise<any> }
46
- ): Promise<any> {
41
+ async deleteAllHubs(hubIds: string[]): Promise<any> {
47
42
  const query = hubIds.length ? `?ids=${hubIds.join(",")}` : "";
48
- return await httpClient.delete(`/devices/hubs${query}`);
43
+ return await axios.delete(`${this.baseUrl}/devices/hubs${query}`);
49
44
  }
50
45
  }
@@ -1,2 +1,2 @@
1
- export * from "./Device.service";
2
- export * from "./DeviceHub.service";
1
+ export { DeviceService as LocalDeviceService } from "./Device.service";
2
+ export { DeviceHubService as LocalDeviceHubService } from "./DeviceHub.service";
package/src/index.ts CHANGED
@@ -1,10 +1,21 @@
1
1
  // Main entry point for dt-common-device
2
2
 
3
3
  // Cloud exports
4
- export * as cloud from "./device/cloud/services";
4
+ export {
5
+ CloudDeviceService,
6
+ CloudDeviceHubService,
7
+ CloudConnectionService,
8
+ } from "./device/cloud/services";
9
+ export {
10
+ LocalDeviceService,
11
+ LocalDeviceHubService,
12
+ } from "./device/local/services";
13
+
5
14
  export * as cloudInterfaces from "./device/cloud/interfaces";
6
15
  export * from "./device/cloud/types";
7
16
 
8
17
  // Local exports
9
- export * as local from "./device/local/services";
10
18
  export * as localInterfaces from "./device/local/interfaces";
19
+
20
+ //initialize export
21
+ export { initialize, getConfig } from "./config/config";
@@ -0,0 +1,7 @@
1
+ export type DeviceConfig = {
2
+ ADMIN_SERVICE: string;
3
+ OPERATIONAL_SERVICE: string;
4
+ DEVICE_SERVICE: string;
5
+ MONITORING_SERVICE: string;
6
+ [key: string]: string;
7
+ };
@@ -0,0 +1 @@
1
+ export * from "./config.types";