@ray-js/lock-sdk 1.0.1 → 1.0.2
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/lib/api/index.js +13 -15
- package/lib/api/linkage.d.ts +0 -18
- package/lib/api/linkage.js +61 -81
- package/lib/api/lock.d.ts +0 -69
- package/lib/api/lock.js +91 -113
- package/lib/api/log.d.ts +0 -33
- package/lib/api/log.js +33 -38
- package/lib/api/setting.d.ts +0 -11
- package/lib/api/setting.js +17 -30
- package/lib/api/temp.d.ts +0 -48
- package/lib/api/temp.js +85 -115
- package/lib/api/user.d.ts +5 -54
- package/lib/api/user.js +40 -52
- package/lib/api/video.d.ts +0 -5
- package/lib/api/video.js +9 -15
- package/lib/config/dp-code/index.d.ts +0 -117
- package/lib/config/dp-code/index.js +79 -221
- package/lib/config/dp-map/common.d.ts +0 -3
- package/lib/config/dp-map/common.js +101 -116
- package/lib/config/dp-map/normal.js +29 -50
- package/lib/config/dp-map/open.d.ts +0 -16
- package/lib/config/dp-map/open.js +62 -63
- package/lib/config/dp-map/unlock-method-big.d.ts +0 -60
- package/lib/config/dp-map/unlock-method-big.js +196 -233
- package/lib/config/dp-map/unlock-method.d.ts +0 -63
- package/lib/config/dp-map/unlock-method.js +189 -227
- package/lib/config/index.d.ts +0 -25
- package/lib/config/index.js +21 -54
- package/lib/constant.d.ts +12 -40
- package/lib/constant.js +83 -136
- package/lib/event.d.ts +0 -6
- package/lib/event.js +1 -8
- package/lib/index.d.ts +0 -7
- package/lib/index.js +45 -71
- package/lib/interface.d.ts +0 -523
- package/lib/interface.js +1 -1
- package/lib/linkage.d.ts +0 -18
- package/lib/linkage.js +125 -162
- package/lib/log.d.ts +0 -50
- package/lib/log.js +255 -290
- package/lib/media.d.ts +0 -34
- package/lib/media.js +6 -77
- package/lib/open.d.ts +0 -35
- package/lib/open.js +129 -224
- package/lib/other.d.ts +0 -24
- package/lib/other.js +98 -159
- package/lib/parse/index.d.ts +0 -4
- package/lib/parse/index.js +13 -19
- package/lib/signal.d.ts +0 -13
- package/lib/signal.js +17 -31
- package/lib/sleep.d.ts +0 -42
- package/lib/sleep.js +41 -98
- package/lib/state.d.ts +0 -38
- package/lib/state.js +223 -369
- package/lib/sync/remote-serect-key.d.ts +0 -4
- package/lib/sync/remote-serect-key.js +33 -49
- package/lib/sync/t0.d.ts +0 -3
- package/lib/sync/t0.js +14 -21
- package/lib/sync/temp.d.ts +0 -5
- package/lib/sync/temp.js +68 -77
- package/lib/sync/unlock-mothod.d.ts +0 -3
- package/lib/sync/unlock-mothod.js +28 -40
- package/lib/temporary.d.ts +0 -149
- package/lib/temporary.js +469 -593
- package/lib/unlock-method.d.ts +0 -185
- package/lib/unlock-method.js +479 -650
- package/lib/user.d.ts +2 -81
- package/lib/user.js +202 -336
- package/lib/utils/base64-to-hex.js +10 -10
- package/lib/utils/byte.d.ts +0 -16
- package/lib/utils/byte.js +57 -68
- package/lib/utils/constant.js +7 -11
- package/lib/utils/device.d.ts +46 -83
- package/lib/utils/device.js +294 -322
- package/lib/utils/errors.js +75 -122
- package/lib/utils/event.js +79 -135
- package/lib/utils/hex-to-base64.js +5 -5
- package/lib/utils/hex-to-bytes.d.ts +0 -5
- package/lib/utils/hex-to-bytes.js +10 -15
- package/lib/utils/index.d.ts +0 -42
- package/lib/utils/index.js +247 -377
- package/lib/utils/log.d.ts +1 -4
- package/lib/utils/log.js +71 -74
- package/lib/utils/publishDps.d.ts +0 -5
- package/lib/utils/publishDps.js +58 -80
- package/package.json +3 -4
package/lib/interface.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/lib/linkage.d.ts
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 获取剩余通知次数
|
|
3
|
-
* @returns {Promise<{message: number, phone: number}>}
|
|
4
|
-
*/
|
|
5
1
|
export declare const getRemainingInfo: () => Promise<{
|
|
6
2
|
message: number;
|
|
7
3
|
phone: number;
|
|
8
4
|
}>;
|
|
9
|
-
/**
|
|
10
|
-
* 获取门铃通知服务信息
|
|
11
|
-
* @returns {Promise<boolean>}
|
|
12
|
-
*/
|
|
13
5
|
export declare const getDoorbellService: () => Promise<import("./api/linkage").LinkageRule | undefined>;
|
|
14
|
-
/**
|
|
15
|
-
* 启用门铃通知服务
|
|
16
|
-
* 注意: 首次开通时,会先进入创建动作的页面,创建完成后,会自动启用门铃通知服务
|
|
17
|
-
*/
|
|
18
6
|
export declare const enableDoorbellService: () => Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* 禁用门铃通知服务
|
|
21
|
-
*/
|
|
22
7
|
export declare const disableDoorbellService: () => Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* 去配置门铃通知服务
|
|
25
|
-
*/
|
|
26
8
|
export declare const toSetDoorbellService: () => Promise<void>;
|
package/lib/linkage.js
CHANGED
|
@@ -1,180 +1,143 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "core-js/modules/esnext.iterator.find.js";
|
|
3
|
-
import "core-js/modules/esnext.iterator.map.js";
|
|
4
|
-
import { disableLinkage, enableLinkage, getLinkageList, getRemainingMessage, getRemainingPhone, saveLinkage } from "./api/linkage";
|
|
1
|
+
import { disableLinkage, enableLinkage, getLinkageList, getRemainingMessage, getRemainingPhone, saveLinkage, } from "./api/linkage";
|
|
5
2
|
import config from "./config";
|
|
6
3
|
import { getHomeInfo } from "./utils";
|
|
7
4
|
import { createAction, editAction } from "./utils/device";
|
|
8
5
|
import { getError } from "./utils/errors";
|
|
9
6
|
const DOORBELL_RING_TYPE = "doorbell_ring";
|
|
10
|
-
const TARGET_KEY = "appPushTrigger";
|
|
11
|
-
const ACTION_TYPE = "kafkaSend";
|
|
12
|
-
const MOBILE_TYPE = "mobileVoiceSend";
|
|
13
|
-
const MESSAGE_TYPE = "smsSend";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 获取剩余通知次数
|
|
17
|
-
* @returns {Promise<{message: number, phone: number}>}
|
|
18
|
-
*/
|
|
7
|
+
const TARGET_KEY = "appPushTrigger";
|
|
8
|
+
const ACTION_TYPE = "kafkaSend";
|
|
9
|
+
const MOBILE_TYPE = "mobileVoiceSend";
|
|
10
|
+
const MESSAGE_TYPE = "smsSend";
|
|
19
11
|
export const getRemainingInfo = async () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
const homeInfo = await getHomeInfo();
|
|
13
|
+
const [message, phone] = await Promise.all([
|
|
14
|
+
getRemainingMessage(homeInfo.homeId),
|
|
15
|
+
getRemainingPhone(homeInfo.homeId),
|
|
16
|
+
]);
|
|
17
|
+
return {
|
|
18
|
+
message,
|
|
19
|
+
phone,
|
|
20
|
+
};
|
|
26
21
|
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 获取门铃通知服务信息
|
|
30
|
-
* @returns {Promise<boolean>}
|
|
31
|
-
*/
|
|
32
22
|
export const getDoorbellService = async () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
const homeInfo = await getHomeInfo();
|
|
24
|
+
const list = await getLinkageList(config.devInfo.devId, homeInfo.homeId);
|
|
25
|
+
return list.find((item) => item.code === DOORBELL_RING_TYPE && item.ruleId);
|
|
36
26
|
};
|
|
37
27
|
const createDoorbellService = async () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
const actions = await createAction({
|
|
29
|
+
createType: "remind",
|
|
30
|
+
smartType: "auto",
|
|
31
|
+
});
|
|
32
|
+
await saveDoorbellService(actions);
|
|
43
33
|
};
|
|
44
|
-
const saveDoorbellService = async actions => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
enabled: true,
|
|
52
|
-
extraInfo: {
|
|
53
|
-
code: DOORBELL_RING_TYPE
|
|
54
|
-
},
|
|
55
|
-
bizType: "3",
|
|
56
|
-
logicRuleList: [{
|
|
57
|
-
name: "doorbell",
|
|
58
|
-
// 规则名称
|
|
59
|
-
matchType: 2,
|
|
60
|
-
// MatchType枚举,1:任意条件触发,2:全部条件满足触发,3:通过expr来判断整个条件的匹配情况
|
|
61
|
-
enabled: true,
|
|
62
|
-
// 规则启用/禁用
|
|
63
|
-
scenarioRule: false,
|
|
64
|
-
// 是否在场景列表中展示
|
|
65
|
-
preConditions: [],
|
|
66
|
-
coverIcon: "",
|
|
67
|
-
displayColor: "0084FF",
|
|
68
|
-
background: "",
|
|
69
|
-
conditions: [{
|
|
70
|
-
entityType: 23,
|
|
71
|
-
// entityType=23,表示kafka 消息触发类型
|
|
72
|
-
entityId: config.devInfo.devId,
|
|
73
|
-
// 可以是设备ID,或者产品id等,根据实际的业务需求来
|
|
74
|
-
entitySubIds: "",
|
|
75
|
-
// 无 根据实际的需求来 可以是dpIds
|
|
76
|
-
iconUrl: "",
|
|
77
|
-
// 图片
|
|
78
|
-
expr: [],
|
|
79
|
-
// 为空 传递JSONArray
|
|
34
|
+
const saveDoorbellService = async (actions) => {
|
|
35
|
+
const homeInfo = await getHomeInfo();
|
|
36
|
+
saveLinkage({
|
|
37
|
+
devId: config.devInfo.devId,
|
|
38
|
+
ownerId: homeInfo.homeId,
|
|
39
|
+
name: "doorbell",
|
|
40
|
+
enabled: true,
|
|
80
41
|
extraInfo: {
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
42
|
+
code: DOORBELL_RING_TYPE,
|
|
43
|
+
},
|
|
44
|
+
bizType: "3",
|
|
45
|
+
logicRuleList: [
|
|
46
|
+
{
|
|
47
|
+
name: "doorbell",
|
|
48
|
+
matchType: 2,
|
|
49
|
+
enabled: true,
|
|
50
|
+
scenarioRule: false,
|
|
51
|
+
preConditions: [],
|
|
52
|
+
coverIcon: "",
|
|
53
|
+
displayColor: "0084FF",
|
|
54
|
+
background: "",
|
|
55
|
+
conditions: [
|
|
56
|
+
{
|
|
57
|
+
entityType: 23,
|
|
58
|
+
entityId: config.devInfo.devId,
|
|
59
|
+
entitySubIds: "",
|
|
60
|
+
iconUrl: "",
|
|
61
|
+
expr: [],
|
|
62
|
+
extraInfo: {
|
|
63
|
+
businessType: DOORBELL_RING_TYPE,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
actions: actions.map((item) => {
|
|
68
|
+
if (item?.actionExecutor === MOBILE_TYPE) {
|
|
69
|
+
const executorProperty = {
|
|
70
|
+
topic: 1,
|
|
71
|
+
customParameters: {
|
|
72
|
+
type: 1,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
actionExecutor: ACTION_TYPE,
|
|
77
|
+
entityName: "notify_phone",
|
|
78
|
+
extraProperty: executorProperty,
|
|
79
|
+
executorProperty,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (item?.actionExecutor === MESSAGE_TYPE) {
|
|
83
|
+
const executorProperty = {
|
|
84
|
+
topic: 2,
|
|
85
|
+
customParameters: {
|
|
86
|
+
type: 2,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
actionExecutor: ACTION_TYPE,
|
|
91
|
+
entityName: "notify_message",
|
|
92
|
+
extraProperty: executorProperty,
|
|
93
|
+
executorProperty,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return item;
|
|
97
|
+
}),
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
}, homeInfo.homeId);
|
|
121
101
|
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* 启用门铃通知服务
|
|
125
|
-
* 注意: 首次开通时,会先进入创建动作的页面,创建完成后,会自动启用门铃通知服务
|
|
126
|
-
*/
|
|
127
102
|
export const enableDoorbellService = async () => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
103
|
+
const homeInfo = await getHomeInfo();
|
|
104
|
+
const service = await getDoorbellService();
|
|
105
|
+
if (service && service.ruleId) {
|
|
106
|
+
await enableLinkage(service.ruleId, homeInfo.homeId);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
await createDoorbellService();
|
|
110
|
+
}
|
|
135
111
|
};
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 禁用门铃通知服务
|
|
139
|
-
*/
|
|
140
112
|
export const disableDoorbellService = async () => {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
113
|
+
const homeInfo = await getHomeInfo();
|
|
114
|
+
const service = await getDoorbellService();
|
|
115
|
+
if (service && service.ruleId) {
|
|
116
|
+
await disableLinkage(service.ruleId, homeInfo.homeId);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
throw getError(1059);
|
|
148
120
|
};
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* 去配置门铃通知服务
|
|
152
|
-
*/
|
|
153
121
|
export const toSetDoorbellService = async () => {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
} else {
|
|
177
|
-
// 去创建
|
|
178
|
-
await createDoorbellService();
|
|
179
|
-
}
|
|
180
|
-
};
|
|
122
|
+
const service = await getDoorbellService();
|
|
123
|
+
if (service && service.ruleId && service.ruleVO) {
|
|
124
|
+
const findIndex = service.ruleVO.actions.findIndex((item) => item.actionExecutor === TARGET_KEY ||
|
|
125
|
+
item.actionExecutor === ACTION_TYPE);
|
|
126
|
+
const actions = await editAction({
|
|
127
|
+
editIndex: findIndex > -1 ? findIndex : 0,
|
|
128
|
+
smartType: "auto",
|
|
129
|
+
actionArray: service.ruleVO.actions.map((item) => {
|
|
130
|
+
if (item.actionExecutor === ACTION_TYPE) {
|
|
131
|
+
const { customParameters: { type }, } = item.executorProperty;
|
|
132
|
+
const actionType = type === 1 ? MOBILE_TYPE : MESSAGE_TYPE;
|
|
133
|
+
item.actionExecutor = actionType;
|
|
134
|
+
}
|
|
135
|
+
return item;
|
|
136
|
+
}),
|
|
137
|
+
});
|
|
138
|
+
await saveDoorbellService(actions);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
await createDoorbellService();
|
|
142
|
+
}
|
|
143
|
+
};
|
package/lib/log.d.ts
CHANGED
|
@@ -1,86 +1,36 @@
|
|
|
1
1
|
import { AlbumMessage, LogData, UnlockMethodType } from "./interface";
|
|
2
|
-
/**
|
|
3
|
-
* 开锁 DP 映射开锁类型
|
|
4
|
-
*/
|
|
5
2
|
export declare const unlockDp2Type: Record<string, UnlockMethodType>;
|
|
6
|
-
/**
|
|
7
|
-
* 获取最近2条记录
|
|
8
|
-
*/
|
|
9
3
|
export declare const getLatestLogs: () => Promise<{
|
|
10
4
|
data: LogData[];
|
|
11
5
|
unreadCount: number;
|
|
12
6
|
}>;
|
|
13
|
-
/**
|
|
14
|
-
* 注册通知可刷新日志事件
|
|
15
|
-
* @param cb
|
|
16
|
-
*/
|
|
17
7
|
export declare const onLogsRefresh: (cb: () => void) => void;
|
|
18
|
-
/**
|
|
19
|
-
* 注销通知可刷新日志事件
|
|
20
|
-
* @param cb
|
|
21
|
-
*/
|
|
22
8
|
export declare const offLogsRefresh: (cb: () => void) => void;
|
|
23
9
|
interface GetLogsParams {
|
|
24
|
-
/**
|
|
25
|
-
* 页码,默认 1
|
|
26
|
-
*/
|
|
27
10
|
page?: number;
|
|
28
|
-
/**
|
|
29
|
-
* 每页数量,默认为 50
|
|
30
|
-
*/
|
|
31
11
|
pageSize?: number;
|
|
32
12
|
}
|
|
33
13
|
export declare const openDps: string[];
|
|
34
|
-
/**
|
|
35
|
-
* 获取日志记录列表
|
|
36
|
-
* @param {GetLogsParams} params
|
|
37
|
-
*/
|
|
38
14
|
export declare const getLogs: (params?: GetLogsParams) => Promise<{
|
|
39
15
|
list: LogData[];
|
|
40
16
|
hasMore: boolean;
|
|
41
17
|
total: number;
|
|
42
18
|
}>;
|
|
43
19
|
interface GetAlarmsParams {
|
|
44
|
-
/**
|
|
45
|
-
* 页码,默认 1
|
|
46
|
-
*/
|
|
47
20
|
page?: number;
|
|
48
|
-
/**
|
|
49
|
-
* 页码,默认 50
|
|
50
|
-
*/
|
|
51
21
|
pageSize?: number;
|
|
52
22
|
}
|
|
53
|
-
/**
|
|
54
|
-
* 获取告警列表
|
|
55
|
-
* @param {GetAlarmsParams} params
|
|
56
|
-
*/
|
|
57
23
|
export declare const getAlarms: (params?: GetAlarmsParams) => Promise<{
|
|
58
24
|
list: LogData[];
|
|
59
25
|
hasMore: boolean;
|
|
60
26
|
total: number;
|
|
61
27
|
}>;
|
|
62
28
|
interface GetAlbumsParams {
|
|
63
|
-
/**
|
|
64
|
-
* 页码,默认 1
|
|
65
|
-
*/
|
|
66
29
|
page?: number;
|
|
67
|
-
/**
|
|
68
|
-
* 每页数量,默认为 20
|
|
69
|
-
*/
|
|
70
30
|
pageSize?: number;
|
|
71
|
-
/**
|
|
72
|
-
* 开始时间,单位为毫秒
|
|
73
|
-
*/
|
|
74
31
|
startTime?: number;
|
|
75
|
-
/**
|
|
76
|
-
* 结束时间,单位为毫秒
|
|
77
|
-
*/
|
|
78
32
|
endTime?: number;
|
|
79
33
|
}
|
|
80
|
-
/**
|
|
81
|
-
* 获取相册日志
|
|
82
|
-
* 仅支持视对讲设备
|
|
83
|
-
*/
|
|
84
34
|
export declare const getAlbums: (params?: GetAlbumsParams) => Promise<{
|
|
85
35
|
hasMore: boolean;
|
|
86
36
|
list: AlbumMessage[];
|