@ray-js/lock-sdk 1.0.1 → 1.0.3-beta-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/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 +8 -26
- package/lib/other.js +107 -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/utils/errors.js
CHANGED
|
@@ -1,127 +1,80 @@
|
|
|
1
1
|
const errors = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
1037: "Password already exists",
|
|
63
|
-
// 密码名称重复
|
|
64
|
-
1038: "Password name is duplicated",
|
|
65
|
-
// 密码生效时间与结束时间不正确
|
|
66
|
-
1039: "Password effective time and end time are incorrect",
|
|
67
|
-
// 临时密码 id 不存在
|
|
68
|
-
1040: "Temporary password ID does not exist",
|
|
69
|
-
// 设备无硬件 ID 可用
|
|
70
|
-
1041: "Device has no hardware ID available",
|
|
71
|
-
// 添加临时密码失败
|
|
72
|
-
1042: "Failed to add temporary password",
|
|
73
|
-
// 临时密码添加失败,未获取到云端预分配的编号
|
|
74
|
-
1043: "Temporary password addition failed, pre-allocated number not obtained from cloud",
|
|
75
|
-
// 清空单个密码时,缺少传入 unlockBindingId
|
|
76
|
-
1044: "When clearing a single password, missing unlockBindingId",
|
|
77
|
-
// 功能不支持
|
|
78
|
-
1045: "Function not supported",
|
|
79
|
-
// 远程开关门未开启
|
|
80
|
-
1046: "Remote door opening and closing function is not enabled",
|
|
81
|
-
// 无权限远程开关门
|
|
82
|
-
1047: "Remote door opening and closing without permission",
|
|
83
|
-
// 无此用户
|
|
84
|
-
1048: "No such user",
|
|
85
|
-
// 不支持修改管理员时效
|
|
86
|
-
1049: "Does not support modifying administrator validity period",
|
|
87
|
-
// 开锁方式未存在绑定关系
|
|
88
|
-
1050: "Unlock method does not have a binding relationship",
|
|
89
|
-
// 无效数据
|
|
90
|
-
1051: "Invalid data",
|
|
91
|
-
// 操作正式执行,请稍后
|
|
92
|
-
1052: "Operation is being executed, please wait",
|
|
93
|
-
// 同步添加云端开锁方式失败
|
|
94
|
-
1053: "Failed to synchronize and add cloud unlocking method",
|
|
95
|
-
// 密码不能为空
|
|
96
|
-
1054: "Password cannot be empty",
|
|
97
|
-
// 特殊开锁方式使用短信通知时,验证码不能为空
|
|
98
|
-
1055: "Verification code cannot be empty",
|
|
99
|
-
// 特殊开锁方式使用短信通知时,国家码不能为空
|
|
100
|
-
1056: "Country code cannot be empty",
|
|
101
|
-
// 特殊开锁方式 app 消息通知必须开启
|
|
102
|
-
1057: "Special unlock method app message notification must be enabled",
|
|
103
|
-
// 特殊开锁方式 app 消息或手机短信必须开启一个
|
|
104
|
-
1058: "Special unlock method app message notification or phone SMS must be enabled",
|
|
105
|
-
// 门铃通知服务未开通
|
|
106
|
-
1059: "Doorbell notification service not enabled",
|
|
107
|
-
// 不支持添加普通成员
|
|
108
|
-
1060: "Does not support adding normal members"
|
|
2
|
+
1001: "Device offline",
|
|
3
|
+
1002: "Operation timeout",
|
|
4
|
+
1003: "Remote unlocking failure",
|
|
5
|
+
1004: "Device reports that remote unlocking failed",
|
|
6
|
+
1005: "Remote unlocking failure",
|
|
7
|
+
1006: "Secret key times has been used up",
|
|
8
|
+
1007: "Secret key is not valid",
|
|
9
|
+
1008: "Secret key is wrong",
|
|
10
|
+
1009: "Missing required attribute: {0}",
|
|
11
|
+
1010: "The effective time cannot be greater than the valid time",
|
|
12
|
+
1011: "Failed to update device side member validity",
|
|
13
|
+
1012: "Failed to update member validity",
|
|
14
|
+
1013: "App not support the function",
|
|
15
|
+
1014: "Device does not support the function",
|
|
16
|
+
1015: "Timeout when entering unlocking method",
|
|
17
|
+
1016: "Failed to enter unlocking method",
|
|
18
|
+
1017: "Repeated entry when entering unlocking method",
|
|
19
|
+
1018: "Hardware ID allocation completed when entering unlocking method",
|
|
20
|
+
1019: "Error in adding password, field is non-numeric (backup)",
|
|
21
|
+
1020: "Error in adding password, password length",
|
|
22
|
+
1021: "Unsupported unlocking method type",
|
|
23
|
+
1022: "Currently entering fingerprint",
|
|
24
|
+
1023: "Currently binding door card",
|
|
25
|
+
1024: "Currently binding face",
|
|
26
|
+
1025: "Password is too simple",
|
|
27
|
+
1026: "Parameter error, such as repeated message sequence number",
|
|
28
|
+
1027: "Start add Unlock method failure",
|
|
29
|
+
1028: "Delete failed",
|
|
30
|
+
1029: "Hardware ID cannot be deleted",
|
|
31
|
+
1030: "Only numeric passwords are supported",
|
|
32
|
+
1031: "Password name length cannot exceed 20 characters",
|
|
33
|
+
1032: "Validity not configured",
|
|
34
|
+
1033: "Validity start date not configured",
|
|
35
|
+
1034: "Validity end date not configured",
|
|
36
|
+
1035: "Weekly repeat validity configuration not set",
|
|
37
|
+
1036: "Monthly repeat validity configuration not set",
|
|
38
|
+
1037: "Password already exists",
|
|
39
|
+
1038: "Password name is duplicated",
|
|
40
|
+
1039: "Password effective time and end time are incorrect",
|
|
41
|
+
1040: "Temporary password ID does not exist",
|
|
42
|
+
1041: "Device has no hardware ID available",
|
|
43
|
+
1042: "Failed to add temporary password",
|
|
44
|
+
1043: "Temporary password addition failed, pre-allocated number not obtained from cloud",
|
|
45
|
+
1044: "When clearing a single password, missing unlockBindingId",
|
|
46
|
+
1045: "Function not supported",
|
|
47
|
+
1046: "Remote door opening and closing function is not enabled",
|
|
48
|
+
1047: "Remote door opening and closing without permission",
|
|
49
|
+
1048: "No such user",
|
|
50
|
+
1049: "Does not support modifying administrator validity period",
|
|
51
|
+
1050: "Unlock method does not have a binding relationship",
|
|
52
|
+
1051: "Invalid data",
|
|
53
|
+
1052: "Operation is being executed, please wait",
|
|
54
|
+
1053: "Failed to synchronize and add cloud unlocking method",
|
|
55
|
+
1054: "Password cannot be empty",
|
|
56
|
+
1055: "Verification code cannot be empty",
|
|
57
|
+
1056: "Country code cannot be empty",
|
|
58
|
+
1057: "Special unlock method app message notification must be enabled",
|
|
59
|
+
1058: "Special unlock method app message notification or phone SMS must be enabled",
|
|
60
|
+
1059: "Doorbell notification service not enabled",
|
|
61
|
+
1060: "Does not support adding normal members",
|
|
109
62
|
};
|
|
110
|
-
export const getError =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
63
|
+
export const getError = (code, ...places) => {
|
|
64
|
+
if (errors[code]) {
|
|
65
|
+
let desc = errors[code];
|
|
66
|
+
if (places.length > 0) {
|
|
67
|
+
for (let i = 0; i < places.length; i++) {
|
|
68
|
+
desc = desc.replace(`{${i}}`, places[i]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
errorCode: code,
|
|
73
|
+
errorMsg: desc,
|
|
74
|
+
};
|
|
117
75
|
}
|
|
118
76
|
return {
|
|
119
|
-
|
|
120
|
-
|
|
77
|
+
errorCode: code,
|
|
78
|
+
errorMsg: "unknow error",
|
|
121
79
|
};
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
errorCode: code,
|
|
125
|
-
errorMsg: "unknow error"
|
|
126
|
-
};
|
|
127
|
-
};
|
|
80
|
+
};
|
package/lib/utils/event.js
CHANGED
|
@@ -1,144 +1,88 @@
|
|
|
1
|
-
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
-
import "core-js/modules/esnext.iterator.for-each.js";
|
|
3
|
-
import "core-js/modules/esnext.iterator.some.js";
|
|
4
1
|
function createEmitter() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
let listeners = {};
|
|
3
|
+
let cachedEvents = {};
|
|
4
|
+
function addEvent(type, cb, emitType) {
|
|
5
|
+
if (!listeners[type]) {
|
|
6
|
+
listeners[type] = [];
|
|
7
|
+
}
|
|
8
|
+
const index = listeners[type].findIndex((item) => item.cb === cb);
|
|
9
|
+
if (index === -1) {
|
|
10
|
+
listeners[type].push({
|
|
11
|
+
type: emitType,
|
|
12
|
+
cb,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
if (listeners[type][index].type !== emitType) {
|
|
17
|
+
listeners[type][index].type = emitType;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function on(type, cb) {
|
|
22
|
+
addEvent(type, cb, "on");
|
|
23
|
+
if (cachedEvents[type] && cachedEvents[type].length > 0) {
|
|
24
|
+
cachedEvents[type].forEach((data) => {
|
|
25
|
+
emit(type, data);
|
|
26
|
+
});
|
|
27
|
+
clearCache(type);
|
|
28
|
+
}
|
|
10
29
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (index === -1) {
|
|
14
|
-
listeners[type].push({
|
|
15
|
-
type: emitType,
|
|
16
|
-
cb
|
|
17
|
-
});
|
|
18
|
-
} else {
|
|
19
|
-
// 执行类型是否变更
|
|
20
|
-
if (listeners[type][index].type !== emitType) {
|
|
21
|
-
listeners[type][index].type = emitType;
|
|
22
|
-
}
|
|
30
|
+
function once(type, cb) {
|
|
31
|
+
addEvent(type, cb, "once");
|
|
23
32
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 注册事件监听
|
|
28
|
-
* @param type
|
|
29
|
-
* @param cb
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 注册事件监听
|
|
34
|
-
* 事件只会执行一次
|
|
35
|
-
* @param type
|
|
36
|
-
* @param cb
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 是否有事件监听
|
|
41
|
-
* @param type
|
|
42
|
-
* @returns
|
|
43
|
-
*/
|
|
44
|
-
function hasListener(type) {
|
|
45
|
-
return !!listeners[type] && listeners[type].length > 0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 缓存事件,当有监听器时直接执行
|
|
50
|
-
* 事件会被缓存,直到有监听器时才会执行
|
|
51
|
-
* @param type
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* 清除缓存事件
|
|
56
|
-
* @param type
|
|
57
|
-
*/
|
|
58
|
-
function clearCache(type) {
|
|
59
|
-
cachedEvents[type] = [];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* 移除事件监听
|
|
64
|
-
* @param type
|
|
65
|
-
* @param cb
|
|
66
|
-
* @returns
|
|
67
|
-
*/
|
|
68
|
-
function off(type, cb) {
|
|
69
|
-
if (!listeners[type]) {
|
|
70
|
-
return;
|
|
33
|
+
function hasListener(type) {
|
|
34
|
+
return !!listeners[type] && listeners[type].length > 0;
|
|
71
35
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
* 执行事件
|
|
83
|
-
* @param type
|
|
84
|
-
* @param data
|
|
85
|
-
*/
|
|
86
|
-
function emit(type, data) {
|
|
87
|
-
if (listeners[type]) {
|
|
88
|
-
// 取得事件列表的副本进行操作,以保证所有事件被执行
|
|
89
|
-
const list = [...listeners[type]];
|
|
90
|
-
const count = list.length;
|
|
91
|
-
for (let i = 0; i < count; i++) {
|
|
92
|
-
const {
|
|
93
|
-
cb,
|
|
94
|
-
type: cbType
|
|
95
|
-
} = list[i];
|
|
96
|
-
if (cbType === "once") {
|
|
97
|
-
listeners[type].splice(i, 1);
|
|
36
|
+
function cache(type, data) {
|
|
37
|
+
cachedEvents[type] = cachedEvents[type] || [];
|
|
38
|
+
cachedEvents[type].push(data);
|
|
39
|
+
}
|
|
40
|
+
function clearCache(type) {
|
|
41
|
+
cachedEvents[type] = [];
|
|
42
|
+
}
|
|
43
|
+
function off(type, cb) {
|
|
44
|
+
if (!listeners[type]) {
|
|
45
|
+
return;
|
|
98
46
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
47
|
+
listeners[type].some((item, i) => {
|
|
48
|
+
if (item.cb === cb) {
|
|
49
|
+
listeners[type].splice(i, 1);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function emit(type, data) {
|
|
56
|
+
if (listeners[type]) {
|
|
57
|
+
const list = [...listeners[type]];
|
|
58
|
+
const count = list.length;
|
|
59
|
+
for (let i = 0; i < count; i++) {
|
|
60
|
+
const { cb, type: cbType } = list[i];
|
|
61
|
+
if (cbType === "once") {
|
|
62
|
+
listeners[type].splice(i, 1);
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
cb(data);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
console.warn(e);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
104
71
|
}
|
|
105
|
-
}
|
|
106
72
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
cachedEvents[type].forEach(data => {
|
|
121
|
-
emit(type, data);
|
|
122
|
-
});
|
|
123
|
-
// 清除缓存事件
|
|
124
|
-
clearCache(type);
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
off,
|
|
128
|
-
once: function once(type, cb) {
|
|
129
|
-
addEvent(type, cb, "once");
|
|
130
|
-
},
|
|
131
|
-
emit,
|
|
132
|
-
clear: () => {
|
|
133
|
-
listeners = {};
|
|
134
|
-
},
|
|
135
|
-
hasListener,
|
|
136
|
-
cache: function cache(type, data) {
|
|
137
|
-
cachedEvents[type] = cachedEvents[type] || [];
|
|
138
|
-
cachedEvents[type].push(data);
|
|
139
|
-
},
|
|
140
|
-
clearCache
|
|
141
|
-
};
|
|
73
|
+
const clear = () => {
|
|
74
|
+
listeners = {};
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
on,
|
|
78
|
+
off,
|
|
79
|
+
once,
|
|
80
|
+
emit,
|
|
81
|
+
clear,
|
|
82
|
+
hasListener,
|
|
83
|
+
cache,
|
|
84
|
+
clearCache,
|
|
85
|
+
};
|
|
142
86
|
}
|
|
143
87
|
export { createEmitter };
|
|
144
|
-
export default createEmitter();
|
|
88
|
+
export default createEmitter();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Base64 } from 'js-base64';
|
|
2
2
|
import hexToBytes from './hex-to-bytes';
|
|
3
3
|
export default function hexToBase64(value) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
4
|
+
if (!value) {
|
|
5
|
+
return '';
|
|
6
|
+
}
|
|
7
|
+
return Base64.fromUint8Array(hexToBytes(value));
|
|
8
|
+
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 将 hex 字符串转为字节数据
|
|
3
|
-
* @param value
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
1
|
export default function hexToBytes(value) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
2
|
+
if (value.length % 2 !== 0) {
|
|
3
|
+
throw new Error('hex length error');
|
|
4
|
+
}
|
|
5
|
+
const len = value.length / 2;
|
|
6
|
+
const data = new Uint8Array(len);
|
|
7
|
+
for (let i = 0; i < len; i++) {
|
|
8
|
+
data[i] = parseInt(value.slice(i * 2, i * 2 + 2), 16);
|
|
9
|
+
}
|
|
10
|
+
return data;
|
|
11
|
+
}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,26 +1,10 @@
|
|
|
1
1
|
import { UserType } from "../constant";
|
|
2
2
|
import { EffectiveConfig, UnlockMethodConfig, Week } from "../interface";
|
|
3
3
|
import { LoopTypes } from "./constant";
|
|
4
|
-
/**
|
|
5
|
-
* 格式化为24时间格式
|
|
6
|
-
* @param time
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
4
|
export declare const get24Time: (time: number) => number[];
|
|
10
5
|
export declare const getNowTime: () => number;
|
|
11
|
-
/**
|
|
12
|
-
* 判断设备在线类型
|
|
13
|
-
* @param onlineType 设备的通道在线数据
|
|
14
|
-
* @param type 待检测的通道类型,0为wifi,1为局域网,2为蓝牙,3为Mesh, 4为 beacon
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
6
|
export declare const isOnlineByType: (onlineType: number, type: number) => boolean;
|
|
18
7
|
export declare function isCapability(capability: number, id: number): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* 获取产品支持的通讯能力
|
|
21
|
-
* @param capability 产品能力值
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
8
|
export declare function getCapabilities(capability: number): ({
|
|
25
9
|
readonly id: 0;
|
|
26
10
|
readonly name: "wifi";
|
|
@@ -104,10 +88,6 @@ export declare function getCapabilities(capability: number): ({
|
|
|
104
88
|
})[];
|
|
105
89
|
export declare const formatWeek: (value: number[]) => number;
|
|
106
90
|
export declare const parseWeek: (value: number) => Week;
|
|
107
|
-
/**
|
|
108
|
-
* 获取一个永久生效的设置
|
|
109
|
-
* @returns
|
|
110
|
-
*/
|
|
111
91
|
export declare const getPermanentSetting: () => {
|
|
112
92
|
startTime: number;
|
|
113
93
|
endTime: number;
|
|
@@ -122,36 +102,14 @@ export declare const getPermanentSetting: () => {
|
|
|
122
102
|
};
|
|
123
103
|
export declare const isAdmin: (userType: UserType) => boolean;
|
|
124
104
|
export declare const validateEffectiveConfig: (effective?: EffectiveConfig) => void;
|
|
125
|
-
/**
|
|
126
|
-
* 是否使用近场通道,一般为蓝牙
|
|
127
|
-
* @returns
|
|
128
|
-
*/
|
|
129
105
|
export declare const isUseNearChannel: () => boolean;
|
|
130
106
|
export declare const parseOfflinePassword: (value: string) => string;
|
|
131
|
-
/**
|
|
132
|
-
* 格式化时间戳为毫秒
|
|
133
|
-
* 注意此方法只支持 2010 年之后的时间戳
|
|
134
|
-
* @param timestamp 时间戳
|
|
135
|
-
*/
|
|
136
107
|
export declare const formatTimestampToMilliseconds: (timestamp: number) => number;
|
|
137
|
-
/**
|
|
138
|
-
* 开锁方式配置数据
|
|
139
|
-
*/
|
|
140
108
|
export declare const unlockMethodConfigs: UnlockMethodConfig[];
|
|
141
109
|
export declare const getUnlockMethodTypeByDpCode: (dpCode: string) => UnlockMethodConfig;
|
|
142
110
|
export declare const getUnlockMethodTypeById: (id: number) => UnlockMethodConfig;
|
|
143
111
|
export declare const getUnlockMethodTypeByType: (type: string) => UnlockMethodConfig;
|
|
144
|
-
/**
|
|
145
|
-
* 针对异常函数,当函数在短时间内被多次调用时,只保留最先一次调用,并统一返回结果
|
|
146
|
-
* @param cb 回调函数
|
|
147
|
-
* @returns
|
|
148
|
-
*/
|
|
149
112
|
export declare const parallelMerge: <T extends (...args: any[]) => Promise<any>>(cb: T) => (...args: Parameters<T>) => ReturnType<T>;
|
|
150
|
-
/**
|
|
151
|
-
* 针对异常函数,当函数在短时间内被多次调用时,只允许函数在短时间内执行一次
|
|
152
|
-
* @param cb 回调函数
|
|
153
|
-
* @returns
|
|
154
|
-
*/
|
|
155
113
|
export declare const parallelOnly: <T extends (...args: any[]) => Promise<any>>(cb: T) => (...args: Parameters<T>) => ReturnType<T>;
|
|
156
114
|
declare const preFetchKeys: readonly ["getRotate", "getCurrentUser", "getDeviceProperties"];
|
|
157
115
|
type PreFetchKey = (typeof preFetchKeys)[number];
|