dt-common-device 1.0.20 → 1.2.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.
- package/dist/device/cloud/entities/CloudConnection.d.ts +6 -0
- package/dist/device/cloud/entities/CloudConnection.js +6 -0
- package/dist/device/cloud/entities/CloudDevice.js +0 -19
- package/dist/device/cloud/entities/CloudDeviceService.d.ts +5 -0
- package/dist/device/cloud/entities/CloudDeviceService.js +9 -0
- package/dist/device/cloud/entities/DeviceFactory.d.ts +2 -1
- package/dist/device/cloud/entities/index.d.ts +2 -0
- package/dist/device/cloud/entities/index.js +2 -0
- package/dist/device/cloud/interfaces/ICloudConnection.d.ts +5 -0
- package/dist/device/cloud/interfaces/ICloudConnection.js +2 -0
- package/dist/device/cloud/interfaces/IDeviceFactory.d.ts +4 -0
- package/dist/device/cloud/interfaces/IDeviceFactory.js +2 -0
- package/dist/device/cloud/interfaces/index.d.ts +1 -3
- package/dist/device/cloud/interfaces/index.js +1 -3
- package/dist/device/cloud/types.d.ts +1 -1
- package/dist/device/local/events/EventHandler.d.ts +10 -0
- package/dist/device/local/events/EventHandler.js +75 -0
- package/dist/device/local/events/Events.d.ts +21 -0
- package/dist/device/local/events/Events.js +24 -0
- package/dist/device/local/interfaces/IDtDevice.d.ts +16 -0
- package/dist/device/local/interfaces/IDtDevice.js +2 -0
- package/dist/device/local/interfaces/index.d.ts +0 -1
- package/dist/device/local/interfaces/index.js +0 -1
- package/dist/device/local/repository/Connection.repository.d.ts +7 -0
- package/dist/device/local/repository/Connection.repository.js +77 -0
- package/dist/device/local/repository/Device.repository.d.ts +16 -0
- package/dist/device/local/repository/Device.repository.js +134 -0
- package/dist/device/local/repository/Hub.repository.d.ts +13 -0
- package/dist/device/local/repository/Hub.repository.js +97 -0
- package/dist/device/local/repository/Property.repository.d.ts +9 -0
- package/dist/device/local/repository/Property.repository.js +81 -0
- package/dist/device/local/services/Connection.service.d.ts +3 -2
- package/dist/device/local/services/Connection.service.js +7 -4
- package/dist/device/local/services/Device.service.d.ts +7 -9
- package/dist/device/local/services/Device.service.js +17 -91
- package/dist/device/local/services/Hub.service.d.ts +7 -7
- package/dist/device/local/services/Hub.service.js +13 -21
- package/dist/device/local/services/Property.service.d.ts +9 -0
- package/dist/device/local/services/Property.service.js +13 -0
- package/dist/device/local/services/index.d.ts +2 -1
- package/dist/device/local/services/index.js +4 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.js +8 -8
- package/package.json +4 -3
- package/src/device/cloud/entities/CloudConnection.ts +13 -0
- package/src/device/cloud/entities/CloudDevice.ts +1 -21
- package/src/device/cloud/entities/DeviceFactory.ts +2 -1
- package/src/device/cloud/entities/index.ts +2 -0
- package/src/device/cloud/interfaces/ICloudConnection.ts +6 -0
- package/src/device/cloud/interfaces/ICloudDevice.ts +0 -1
- package/src/device/cloud/interfaces/IDeviceFactory.ts +5 -0
- package/src/device/cloud/interfaces/index.ts +1 -3
- package/src/device/cloud/types.ts +1 -1
- package/src/device/local/events/EventHandler.ts +101 -0
- package/src/device/local/events/Events.ts +23 -0
- package/src/device/local/interfaces/IDtDevice.ts +16 -0
- package/src/device/local/interfaces/index.ts +0 -1
- package/src/device/local/repository/Connection.repository.ts +32 -0
- package/src/device/local/repository/Device.repository.ts +106 -0
- package/src/device/local/repository/Hub.repository.ts +51 -0
- package/src/device/local/repository/Property.repository.ts +32 -0
- package/src/device/local/services/Connection.service.ts +11 -9
- package/src/device/local/services/Device.service.ts +21 -109
- package/src/device/local/services/Hub.service.ts +17 -28
- package/src/device/local/services/Property.service.ts +12 -0
- package/src/device/local/services/index.ts +2 -1
- package/src/index.ts +5 -3
- package/src/device/cloud/interfaces/IConnectionService.ts +0 -15
- package/src/device/cloud/interfaces/IDeviceService.ts +0 -12
- package/src/device/cloud/interfaces/IHubService.ts +0 -5
- package/src/device/cloud/services/Connection.service.ts +0 -19
- package/src/device/cloud/services/index.ts +0 -2
- package/src/device/local/handler/EventHandler.ts +0 -52
- package/src/device/local/interfaces/IConnection.ts +0 -17
- package/src/device/local/interfaces/IHub.ts +0 -46
- /package/src/device/cloud/{services/CloudDevice.service.ts → entities/CloudDeviceService.ts} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PropertyRepository } from "../repository/Property.repository";
|
|
2
|
+
|
|
3
|
+
export class LocalPropertyService {
|
|
4
|
+
private readonly propertyRepository: PropertyRepository;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.propertyRepository = new PropertyRepository();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async getPropertyPreferences(propertyId: string) {
|
|
10
|
+
return await this.propertyRepository.getPropertyPreferences(propertyId);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { LocalDeviceService } from "./Device.service";
|
|
2
|
-
export {
|
|
2
|
+
export { LocalHubService } from "./Hub.service";
|
|
3
3
|
export { LocalConnectionService } from "./Connection.service";
|
|
4
|
+
export { LocalPropertyService } from "./Property.service";
|
package/src/index.ts
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
// Cloud exports
|
|
4
4
|
export {
|
|
5
|
+
CloudDevice,
|
|
6
|
+
DeviceFactory,
|
|
7
|
+
CloudConnection,
|
|
5
8
|
CloudDeviceService,
|
|
6
|
-
|
|
7
|
-
} from "./device/cloud/services";
|
|
8
|
-
export { CloudDevice, DeviceFactory } from "./device/cloud/entities";
|
|
9
|
+
} from "./device/cloud/entities";
|
|
9
10
|
export {
|
|
10
11
|
LocalDeviceService,
|
|
11
12
|
LocalHubService,
|
|
12
13
|
LocalConnectionService,
|
|
14
|
+
LocalPropertyService,
|
|
13
15
|
} from "./device/local/services";
|
|
14
16
|
|
|
15
17
|
export * from "./device/cloud/interfaces";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IConnection,
|
|
3
|
-
IConnectionConnectParams,
|
|
4
|
-
IDeviceAccountResponse,
|
|
5
|
-
} from "../types";
|
|
6
|
-
|
|
7
|
-
export interface IConnectionService {
|
|
8
|
-
createConnection(data: IConnection, userId: string): Promise<any>;
|
|
9
|
-
getDeviceAccount(connection: IConnection): Promise<IDeviceAccountResponse>;
|
|
10
|
-
getDevices(connection: IConnection): Promise<any>;
|
|
11
|
-
connect(
|
|
12
|
-
connection: IConnection,
|
|
13
|
-
connectionConnect: IConnectionConnectParams
|
|
14
|
-
): Promise<any>;
|
|
15
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IConnection } from "../types";
|
|
2
|
-
|
|
3
|
-
export interface IDeviceService {
|
|
4
|
-
getDevices(connection: IConnection): Promise<Record<string, any>[]>;
|
|
5
|
-
getDevice(
|
|
6
|
-
connectionId: string,
|
|
7
|
-
deviceId: string
|
|
8
|
-
): Promise<Record<string, any>>;
|
|
9
|
-
getBattery(deviceId: string): Promise<number | string>;
|
|
10
|
-
getState(deviceId: string): Promise<string>;
|
|
11
|
-
getStatus(connectionId: string, deviceId: string): Promise<string>;
|
|
12
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Device Cloud Service - Class Implementation
|
|
2
|
-
import { IConnectionService } from "../interfaces";
|
|
3
|
-
import {
|
|
4
|
-
IDeviceAccountResponse,
|
|
5
|
-
IConnectionConnectParams,
|
|
6
|
-
IConnection,
|
|
7
|
-
} from "../types";
|
|
8
|
-
|
|
9
|
-
export abstract class ConnectionService implements IConnectionService {
|
|
10
|
-
abstract createConnection(data: IConnection, userId: string): Promise<any>;
|
|
11
|
-
abstract getDeviceAccount(
|
|
12
|
-
connection: IConnection
|
|
13
|
-
): Promise<IDeviceAccountResponse>;
|
|
14
|
-
abstract getDevices(connection: IConnection): Promise<any>;
|
|
15
|
-
abstract connect(
|
|
16
|
-
connection: IConnection,
|
|
17
|
-
connectionConnect: IConnectionConnectParams
|
|
18
|
-
): Promise<any>;
|
|
19
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { eventDispatcher } from "dt-pub-sub";
|
|
2
|
-
import { publishAudit } from "dt-audit-library";
|
|
3
|
-
|
|
4
|
-
export class EventHandler {
|
|
5
|
-
private readonly source = "dt-common-device";
|
|
6
|
-
constructor() {}
|
|
7
|
-
async onStateChange(deviceId: string, state: any) {
|
|
8
|
-
await eventDispatcher.publishEvent(
|
|
9
|
-
"device.state.set",
|
|
10
|
-
{ deviceId, state },
|
|
11
|
-
this.source
|
|
12
|
-
);
|
|
13
|
-
const payload = {
|
|
14
|
-
eventType: "device.state.set",
|
|
15
|
-
properties: {
|
|
16
|
-
deviceId,
|
|
17
|
-
state,
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
await publishAudit(payload);
|
|
21
|
-
}
|
|
22
|
-
async onStatusChange(deviceId: string, status: any) {
|
|
23
|
-
await eventDispatcher.publishEvent(
|
|
24
|
-
"device.status.set",
|
|
25
|
-
{ deviceId, status },
|
|
26
|
-
this.source
|
|
27
|
-
);
|
|
28
|
-
const payload = {
|
|
29
|
-
eventType: "device.status.set",
|
|
30
|
-
properties: {
|
|
31
|
-
deviceId,
|
|
32
|
-
status,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
await publishAudit(payload);
|
|
36
|
-
}
|
|
37
|
-
async onBatteryLevelChange(deviceId: string, batteryLevel: number) {
|
|
38
|
-
await eventDispatcher.publishEvent(
|
|
39
|
-
"device.battery.set",
|
|
40
|
-
{ deviceId, batteryLevel },
|
|
41
|
-
this.source
|
|
42
|
-
);
|
|
43
|
-
const payload = {
|
|
44
|
-
eventType: "device.battery.set",
|
|
45
|
-
properties: {
|
|
46
|
-
deviceId,
|
|
47
|
-
batteryLevel,
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
await publishAudit(payload);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ConnectionProvider } from "../../cloud/types";
|
|
2
|
-
|
|
3
|
-
export interface IConnection {
|
|
4
|
-
id?: string;
|
|
5
|
-
createdAt?: Date;
|
|
6
|
-
updatedAt?: Date;
|
|
7
|
-
isDeleted?: boolean;
|
|
8
|
-
connectionName: string;
|
|
9
|
-
connectionRefId: string;
|
|
10
|
-
propertyId: string;
|
|
11
|
-
connectionProvider: ConnectionProvider;
|
|
12
|
-
accessToken?: string;
|
|
13
|
-
clientId?: string;
|
|
14
|
-
clientSecret: string;
|
|
15
|
-
isActive?: boolean;
|
|
16
|
-
metaData?: any;
|
|
17
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export interface IHub {
|
|
2
|
-
deviceId: string;
|
|
3
|
-
propertyId: string;
|
|
4
|
-
name: string;
|
|
5
|
-
hubId?: string[];
|
|
6
|
-
specifications: {
|
|
7
|
-
manufacturer?: string;
|
|
8
|
-
model?: string;
|
|
9
|
-
firmware?: {
|
|
10
|
-
version?: string;
|
|
11
|
-
newVersionAvailable?: boolean;
|
|
12
|
-
newVersion?: string;
|
|
13
|
-
mandatoryUpdate?: boolean;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
protocol: {
|
|
17
|
-
location?: {
|
|
18
|
-
id?: string;
|
|
19
|
-
name?: string;
|
|
20
|
-
city?: string;
|
|
21
|
-
};
|
|
22
|
-
name?: string;
|
|
23
|
-
room?: {
|
|
24
|
-
id?: string;
|
|
25
|
-
name?: string;
|
|
26
|
-
};
|
|
27
|
-
accountId?: string;
|
|
28
|
-
};
|
|
29
|
-
deviceType: {
|
|
30
|
-
id: string;
|
|
31
|
-
type: string;
|
|
32
|
-
};
|
|
33
|
-
status: {
|
|
34
|
-
online: boolean;
|
|
35
|
-
error?: {
|
|
36
|
-
type?: string;
|
|
37
|
-
message?: string;
|
|
38
|
-
default?: object;
|
|
39
|
-
};
|
|
40
|
-
lastUpdated?: Date;
|
|
41
|
-
};
|
|
42
|
-
state?: object;
|
|
43
|
-
metaData?: object;
|
|
44
|
-
createdAt?: Date;
|
|
45
|
-
updatedAt?: Date;
|
|
46
|
-
}
|
/package/src/device/cloud/{services/CloudDevice.service.ts → entities/CloudDeviceService.ts}
RENAMED
|
File without changes
|