dt-common-device 1.2.2 → 1.2.4
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/CloudDevice.d.ts +1 -1
- package/dist/device/cloud/entities/CloudDeviceService.d.ts +1 -1
- package/dist/device/cloud/entities/index.d.ts +0 -1
- package/dist/device/cloud/entities/index.js +0 -1
- package/dist/device/cloud/interfaces/ICloudDeviceService.d.ts +1 -1
- package/dist/device/cloud/interfaces/index.d.ts +1 -1
- package/dist/device/cloud/interfaces/index.js +1 -1
- package/dist/device/cloud/types.d.ts +1 -0
- package/dist/device/local/events/EventHandler.d.ts +1 -0
- package/dist/device/local/events/EventHandler.js +11 -0
- package/dist/device/local/interfaces/IConnection.d.ts +12 -2
- package/dist/device/local/interfaces/IConnection.js +12 -0
- package/dist/device/local/interfaces/IProperty.d.ts +5 -0
- package/dist/device/local/interfaces/ISchedule.d.ts +25 -0
- package/dist/device/local/interfaces/ISchedule.js +2 -0
- package/dist/device/local/repository/Connection.repository.d.ts +2 -1
- package/dist/device/local/repository/Connection.repository.js +15 -0
- package/dist/device/local/repository/Hub.repository.d.ts +1 -1
- package/dist/device/local/repository/Property.repository.d.ts +2 -6
- package/dist/device/local/repository/Property.repository.js +1 -5
- package/dist/device/local/repository/Schedule.repository.d.ts +8 -0
- package/dist/device/local/repository/Schedule.repository.js +102 -0
- package/dist/device/local/services/Connection.service.d.ts +3 -2
- package/dist/device/local/services/Connection.service.js +15 -0
- package/dist/device/local/services/Device.service.d.ts +0 -1
- package/dist/device/local/services/Device.service.js +46 -13
- package/dist/device/local/services/Hub.service.d.ts +1 -1
- package/dist/device/local/services/Hub.service.js +18 -0
- package/dist/device/local/services/Property.service.d.ts +1 -5
- package/dist/device/local/services/Property.service.js +9 -0
- package/dist/device/local/services/Schedule.service.d.ts +8 -0
- package/dist/device/local/services/Schedule.service.js +23 -0
- package/dist/device/local/services/index.d.ts +1 -0
- package/dist/device/local/services/index.js +3 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -4
- package/package.json +4 -4
- package/src/device/cloud/entities/CloudDevice.ts +1 -1
- package/src/device/cloud/entities/CloudDeviceService.ts +1 -1
- package/src/device/cloud/entities/index.ts +0 -1
- package/src/device/cloud/interfaces/ICloudDeviceService.ts +1 -1
- package/src/device/cloud/interfaces/index.ts +1 -1
- package/src/device/local/events/EventHandler.ts +16 -0
- package/src/device/local/interfaces/IConnection.ts +27 -0
- package/src/device/local/interfaces/IProperty.ts +6 -0
- package/src/device/local/interfaces/ISchedule.ts +40 -0
- package/src/device/local/repository/Connection.repository.ts +21 -1
- package/src/device/local/repository/Hub.repository.ts +1 -1
- package/src/device/local/repository/Property.repository.ts +3 -7
- package/src/device/local/repository/Schedule.repository.ts +56 -0
- package/src/device/local/services/Connection.service.ts +23 -2
- package/src/device/local/services/Device.service.ts +47 -25
- package/src/device/local/services/Hub.service.ts +20 -1
- package/src/device/local/services/Property.service.ts +9 -0
- package/src/device/local/services/Schedule.service.ts +22 -0
- package/src/device/local/services/index.ts +1 -0
- package/src/index.ts +2 -3
- package/src/device/cloud/entities/CloudConnection.ts +0 -13
- package/src/device/cloud/interfaces/ICloudConnection.ts +0 -6
- package/src/device/cloud/types.ts +0 -57
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Container from "typedi";
|
|
2
|
+
import { ScheduleRepository } from "../repository/Schedule.repository";
|
|
3
|
+
import { ISchedule } from "../interfaces/ISchedule";
|
|
4
|
+
|
|
5
|
+
export class LocalScheduleService {
|
|
6
|
+
private readonly scheduleRepository: ScheduleRepository;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.scheduleRepository = Container.get(ScheduleRepository);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async getSchedule(scheduleId: string) {
|
|
12
|
+
return await this.scheduleRepository.getSchedule(scheduleId);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async setSchedule(scheduleId: string, schedule: ISchedule) {
|
|
16
|
+
return await this.scheduleRepository.setSchedule(scheduleId, schedule);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async getScheduleByZone(zoneId: string) {
|
|
20
|
+
return await this.scheduleRepository.getScheduleByZone(zoneId);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -2,3 +2,4 @@ export { LocalDeviceService } from "./Device.service";
|
|
|
2
2
|
export { LocalHubService } from "./Hub.service";
|
|
3
3
|
export { LocalConnectionService } from "./Connection.service";
|
|
4
4
|
export { LocalPropertyService } from "./Property.service";
|
|
5
|
+
export { LocalScheduleService } from "./Schedule.service";
|
package/src/index.ts
CHANGED
|
@@ -3,19 +3,18 @@
|
|
|
3
3
|
// Cloud exports
|
|
4
4
|
export {
|
|
5
5
|
CloudDevice,
|
|
6
|
-
DeviceFactory,
|
|
7
|
-
CloudConnection,
|
|
8
6
|
CloudDeviceService,
|
|
7
|
+
DeviceFactory,
|
|
9
8
|
} from "./device/cloud/entities";
|
|
10
9
|
export {
|
|
11
10
|
LocalDeviceService,
|
|
12
11
|
LocalHubService,
|
|
13
12
|
LocalConnectionService,
|
|
14
13
|
LocalPropertyService,
|
|
14
|
+
LocalScheduleService,
|
|
15
15
|
} from "./device/local/services";
|
|
16
16
|
|
|
17
17
|
export * from "./device/cloud/interfaces";
|
|
18
|
-
export * from "./device/cloud/types";
|
|
19
18
|
|
|
20
19
|
// Local exports
|
|
21
20
|
export * from "./device/local/interfaces";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Device Cloud Service - Class Implementation
|
|
2
|
-
import { ICloudConnection } from "../interfaces";
|
|
3
|
-
import { IDeviceAccountResponse, IConnection } from "../types";
|
|
4
|
-
|
|
5
|
-
export abstract class CloudConnection implements ICloudConnection {
|
|
6
|
-
abstract createConnection(
|
|
7
|
-
data: IConnection,
|
|
8
|
-
userId: string
|
|
9
|
-
): Promise<IConnection>;
|
|
10
|
-
abstract getDeviceAccount(
|
|
11
|
-
connection: IConnection
|
|
12
|
-
): Promise<IDeviceAccountResponse>;
|
|
13
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// Device Cloud Type Interfaces for DeviceThread Common Library
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a connection to a device provider.
|
|
5
|
-
* WARNING: Do not log or expose sensitive fields (accessToken, clientSecret).
|
|
6
|
-
*/
|
|
7
|
-
export interface IConnection {
|
|
8
|
-
id?: string;
|
|
9
|
-
createdAt?: Date;
|
|
10
|
-
updatedAt?: Date;
|
|
11
|
-
isDeleted?: boolean;
|
|
12
|
-
connectionName: string;
|
|
13
|
-
connectionRefId: string;
|
|
14
|
-
propertyId: string;
|
|
15
|
-
connectionProvider: ConnectionProvider;
|
|
16
|
-
accessToken?: string;
|
|
17
|
-
clientId?: string;
|
|
18
|
-
clientSecret: string;
|
|
19
|
-
isActive?: boolean;
|
|
20
|
-
metaData?: any;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface IConnectionPagination {
|
|
24
|
-
page: number;
|
|
25
|
-
limit: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Device account response from provider.
|
|
30
|
-
* WARNING: Do not log or expose connection_access_token.
|
|
31
|
-
*/
|
|
32
|
-
export interface IDeviceAccountResponse {
|
|
33
|
-
id: string;
|
|
34
|
-
connection_name: string;
|
|
35
|
-
connection_access_token: string;
|
|
36
|
-
connection_provider: string;
|
|
37
|
-
totalDevices: number;
|
|
38
|
-
connection_ref_id: string;
|
|
39
|
-
isActive: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface IConnectionConnectParams {
|
|
43
|
-
code?: string;
|
|
44
|
-
propertyId?: string;
|
|
45
|
-
[key: string]: unknown;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export enum ConnectionProvider {
|
|
49
|
-
Smartthings = "Smartthings",
|
|
50
|
-
SaltoKS = "SaltoKS",
|
|
51
|
-
TTLock = "TTLock",
|
|
52
|
-
Tuya = "Tuya",
|
|
53
|
-
Schlage = "Schlage",
|
|
54
|
-
YaleWifi = "YaleWifi",
|
|
55
|
-
Sensibo = "Sensibo",
|
|
56
|
-
Devicethread = "Devicethread",
|
|
57
|
-
}
|