@ray-js/lock-sdk 1.0.0-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.
Files changed (95) hide show
  1. package/lib/api/index.d.ts +5 -0
  2. package/lib/api/index.js +18 -0
  3. package/lib/api/linkage.d.ts +161 -0
  4. package/lib/api/linkage.js +74 -0
  5. package/lib/api/lock.d.ts +195 -0
  6. package/lib/api/lock.js +129 -0
  7. package/lib/api/log.d.ts +166 -0
  8. package/lib/api/log.js +44 -0
  9. package/lib/api/setting.d.ts +14 -0
  10. package/lib/api/setting.js +36 -0
  11. package/lib/api/temp.d.ts +211 -0
  12. package/lib/api/temp.js +130 -0
  13. package/lib/api/user.d.ts +154 -0
  14. package/lib/api/user.js +59 -0
  15. package/lib/api/video.d.ts +9 -0
  16. package/lib/api/video.js +17 -0
  17. package/lib/config/dp-code/index.d.ts +175 -0
  18. package/lib/config/dp-code/index.js +224 -0
  19. package/lib/config/dp-map/common.d.ts +102 -0
  20. package/lib/config/dp-map/common.js +120 -0
  21. package/lib/config/dp-map/normal.d.ts +6 -0
  22. package/lib/config/dp-map/normal.js +51 -0
  23. package/lib/config/dp-map/open.d.ts +21 -0
  24. package/lib/config/dp-map/open.js +62 -0
  25. package/lib/config/dp-map/unlock-method-big.d.ts +559 -0
  26. package/lib/config/dp-map/unlock-method-big.js +237 -0
  27. package/lib/config/dp-map/unlock-method.d.ts +551 -0
  28. package/lib/config/dp-map/unlock-method.js +231 -0
  29. package/lib/config/index.d.ts +46 -0
  30. package/lib/config/index.js +56 -0
  31. package/lib/constant.d.ts +101 -0
  32. package/lib/constant.js +136 -0
  33. package/lib/dp-interface.d.ts +7 -0
  34. package/lib/dp-interface.js +1 -0
  35. package/lib/event.d.ts +8 -0
  36. package/lib/event.js +9 -0
  37. package/lib/index.d.ts +25 -0
  38. package/lib/index.js +92 -0
  39. package/lib/interface.d.ts +807 -0
  40. package/lib/interface.js +1 -0
  41. package/lib/linkage.d.ts +26 -0
  42. package/lib/linkage.js +175 -0
  43. package/lib/log.d.ts +91 -0
  44. package/lib/log.js +314 -0
  45. package/lib/media.d.ts +43 -0
  46. package/lib/media.js +80 -0
  47. package/lib/open.d.ts +48 -0
  48. package/lib/open.js +247 -0
  49. package/lib/other.d.ts +36 -0
  50. package/lib/other.js +178 -0
  51. package/lib/parse/index.d.ts +6 -0
  52. package/lib/parse/index.js +22 -0
  53. package/lib/signal.d.ts +26 -0
  54. package/lib/signal.js +38 -0
  55. package/lib/sleep.d.ts +61 -0
  56. package/lib/sleep.js +121 -0
  57. package/lib/state.d.ts +54 -0
  58. package/lib/state.js +429 -0
  59. package/lib/sync/remote-serect-key.d.ts +5 -0
  60. package/lib/sync/remote-serect-key.js +60 -0
  61. package/lib/sync/t0.d.ts +5 -0
  62. package/lib/sync/t0.js +33 -0
  63. package/lib/sync/temp.d.ts +7 -0
  64. package/lib/sync/temp.js +88 -0
  65. package/lib/sync/unlock-mothod.d.ts +5 -0
  66. package/lib/sync/unlock-mothod.js +54 -0
  67. package/lib/temporary.d.ts +226 -0
  68. package/lib/temporary.js +637 -0
  69. package/lib/unlock-method.d.ts +269 -0
  70. package/lib/unlock-method.js +723 -0
  71. package/lib/user.d.ts +108 -0
  72. package/lib/user.js +361 -0
  73. package/lib/utils/base64-to-hex.d.ts +1 -0
  74. package/lib/utils/base64-to-hex.js +12 -0
  75. package/lib/utils/byte.d.ts +19 -0
  76. package/lib/utils/byte.js +74 -0
  77. package/lib/utils/constant.d.ts +11 -0
  78. package/lib/utils/constant.js +17 -0
  79. package/lib/utils/device.d.ts +207 -0
  80. package/lib/utils/device.js +353 -0
  81. package/lib/utils/errors.d.ts +2 -0
  82. package/lib/utils/errors.js +125 -0
  83. package/lib/utils/event.d.ts +23 -0
  84. package/lib/utils/event.js +144 -0
  85. package/lib/utils/hex-to-base64.d.ts +1 -0
  86. package/lib/utils/hex-to-base64.js +8 -0
  87. package/lib/utils/hex-to-bytes.d.ts +6 -0
  88. package/lib/utils/hex-to-bytes.js +16 -0
  89. package/lib/utils/index.d.ts +169 -0
  90. package/lib/utils/index.js +419 -0
  91. package/lib/utils/log.d.ts +5 -0
  92. package/lib/utils/log.js +78 -0
  93. package/lib/utils/publishDps.d.ts +11 -0
  94. package/lib/utils/publishDps.js +91 -0
  95. package/package.json +37 -0
@@ -0,0 +1,5 @@
1
+ export declare const sendPhoneVerifyCode: (params: {
2
+ account: string;
3
+ devId: string;
4
+ }) => Promise<unknown>;
5
+ export declare const getActiveTime: (devId: string) => Promise<string>;
@@ -0,0 +1,18 @@
1
+ import { THING } from "../utils/constant";
2
+ import { requestCloud } from "../utils/device";
3
+ export const sendPhoneVerifyCode = params => {
4
+ return requestCloud({
5
+ api: `${THING}.m.device.user.verifycode.send`,
6
+ version: "1.0",
7
+ data: params
8
+ });
9
+ };
10
+ export const getActiveTime = devId => {
11
+ return requestCloud({
12
+ api: `${THING}.m.device.active.date`,
13
+ version: "1.0",
14
+ data: {
15
+ devId
16
+ }
17
+ });
18
+ };
@@ -0,0 +1,161 @@
1
+ export interface LinkageRule {
2
+ background: string;
3
+ code: string;
4
+ description: string;
5
+ displayColor: string;
6
+ icon: string;
7
+ order: number;
8
+ title: string;
9
+ ruleId?: string;
10
+ ruleVO?: {
11
+ actions: {
12
+ actionExecutor: string;
13
+ actionStrategy: string;
14
+ attribute: number;
15
+ devDelMark: boolean;
16
+ enabled: boolean;
17
+ entityId: string;
18
+ executorProperty: {
19
+ topic: string;
20
+ customParameters: Record<string, any>;
21
+ };
22
+ extraProperty: {
23
+ entityName: string;
24
+ iconUrl: string;
25
+ statusDescript: string;
26
+ type: string;
27
+ };
28
+ gmtModified: number;
29
+ id: string;
30
+ offGwSync: boolean;
31
+ orderNum: number;
32
+ ruleId: string;
33
+ status: boolean;
34
+ }[];
35
+ auditStatus: number;
36
+ boundForPanel: boolean;
37
+ boundForWiFiPanel: boolean;
38
+ code: string;
39
+ commonField: string;
40
+ conditions: {
41
+ attribute: number;
42
+ condType: number;
43
+ devDelMark: boolean;
44
+ enabled: boolean;
45
+ entityId: string;
46
+ entityName: string;
47
+ entitySubIds: string;
48
+ entityType: number;
49
+ expr: any[];
50
+ exprDisplay: "远程开锁 : Unlock";
51
+ extraInfo: Record<string, any>;
52
+ handleStrategy: string;
53
+ iconUrl: string;
54
+ id: string;
55
+ orderNum: number;
56
+ ruleId: string;
57
+ serviceProvider: string;
58
+ support: number;
59
+ }[];
60
+ containDeviceDelete: boolean;
61
+ coverIcon: string;
62
+ description: string;
63
+ disableTime: number;
64
+ displayColor: string;
65
+ enabled: boolean;
66
+ forceCloudTrigger: boolean;
67
+ gmtCreate: number;
68
+ gmtModified: number;
69
+ id: string;
70
+ iotAutoAlarm: boolean;
71
+ isAlarmIssue: boolean;
72
+ isLogicRule: boolean;
73
+ linkageType: number;
74
+ localLinkage: boolean;
75
+ matchType: number;
76
+ name: string;
77
+ needCleanGidSid: boolean;
78
+ needValidOutOfWork: boolean;
79
+ newLocalScene: false;
80
+ offGwSync: boolean;
81
+ offGwSyncSuccess: boolean;
82
+ orderWeight: number;
83
+ outOfWork: number;
84
+ ownerId: string;
85
+ panelType: number;
86
+ permissionCode: string;
87
+ ruleGenre: number;
88
+ ruleSource: number;
89
+ ruleType: number;
90
+ scenarioRule: boolean;
91
+ status: true;
92
+ stickyOnTop: false;
93
+ subMatchType: number;
94
+ };
95
+ }
96
+ /**
97
+ * 获取所有的联动规则
98
+ * @param deviceId
99
+ * @returns {Promise<LinkageList>}
100
+ */
101
+ export declare const getLinkageList: (deviceId: string) => Promise<LinkageRule[]>;
102
+ interface LinkageCondition {
103
+ entityType: number;
104
+ entityId: string;
105
+ entitySubIds: "";
106
+ iconUrl?: string;
107
+ expr: [];
108
+ extraInfo: Record<string, any>;
109
+ }
110
+ interface LinkageAction {
111
+ actionExecutor: string;
112
+ entityName: string;
113
+ extraProperty: {
114
+ topic: string;
115
+ customParameters: Record<string, any>;
116
+ };
117
+ executorProperty: {
118
+ topic: string;
119
+ customParameters: Record<string, any>;
120
+ };
121
+ }
122
+ interface SaveLinkageParams {
123
+ devId: string;
124
+ ownerId: string;
125
+ name: string;
126
+ enabled: boolean;
127
+ extraInfo: Record<string, any>;
128
+ bizType: string;
129
+ logicRuleList: {
130
+ id?: string;
131
+ name: string;
132
+ matchType: number;
133
+ enabled: boolean;
134
+ scenarioRule: boolean;
135
+ preConditions: LinkageCondition[];
136
+ coverIcon: string;
137
+ displayColor: string;
138
+ background: string;
139
+ conditions: LinkageCondition[];
140
+ actions: LinkageAction[];
141
+ }[];
142
+ }
143
+ /**
144
+ * 保存联动规则
145
+ * @param data
146
+ * @returns
147
+ */
148
+ export declare const saveLinkage: (data: SaveLinkageParams) => Promise<unknown>;
149
+ export declare const enableLinkage: (ruleId: string) => Promise<unknown>;
150
+ export declare const disableLinkage: (ruleId: string) => Promise<unknown>;
151
+ /**
152
+ * 获取剩余短信通知次数
153
+ * @returns
154
+ */
155
+ export declare const getRemainingMessage: () => Promise<number>;
156
+ /**
157
+ * 获取剩余语音通知次数
158
+ * @returns
159
+ */
160
+ export declare const getRemainingPhone: () => Promise<number>;
161
+ export {};
@@ -0,0 +1,74 @@
1
+ import { THING } from "../utils/constant";
2
+ import { requestCloud } from "../utils/device";
3
+ /**
4
+ * 获取所有的联动规则
5
+ * @param deviceId
6
+ * @returns {Promise<LinkageList>}
7
+ */
8
+ export const getLinkageList = deviceId => {
9
+ return requestCloud({
10
+ api: `${THING}.m.linkage.doorlock.rule.query`,
11
+ version: "2.0",
12
+ data: {
13
+ devId: deviceId
14
+ }
15
+ });
16
+ };
17
+ /**
18
+ * 保存联动规则
19
+ * @param data
20
+ * @returns
21
+ */
22
+ export const saveLinkage = data => {
23
+ return requestCloud({
24
+ api: `${THING}.m.linkage.device.shell.save`,
25
+ version: "2.0",
26
+ data: {
27
+ shellExpr: data
28
+ }
29
+ });
30
+ };
31
+ export const enableLinkage = ruleId => {
32
+ return requestCloud({
33
+ api: `${THING}.m.linkage.rule.enable`,
34
+ version: "1.0",
35
+ data: {
36
+ ruleId
37
+ }
38
+ });
39
+ };
40
+ export const disableLinkage = ruleId => {
41
+ return requestCloud({
42
+ api: `${THING}.m.linkage.rule.disable`,
43
+ version: "1.0",
44
+ data: {
45
+ ruleId
46
+ }
47
+ });
48
+ };
49
+
50
+ /**
51
+ * 获取剩余短信通知次数
52
+ * @returns
53
+ */
54
+ export const getRemainingMessage = () => {
55
+ return requestCloud({
56
+ api: `${THING}.m.notification.subscribe.info`,
57
+ version: "1.0",
58
+ data: {
59
+ notificationType: "sms_notification"
60
+ }
61
+ });
62
+ };
63
+
64
+ /**
65
+ * 获取剩余语音通知次数
66
+ * @returns
67
+ */
68
+ export const getRemainingPhone = () => {
69
+ return requestCloud({
70
+ api: `${THING}.m.mobile.voice.times.count`,
71
+ version: "1.0",
72
+ data: {}
73
+ });
74
+ };
@@ -0,0 +1,195 @@
1
+ /**
2
+ * 直接通过云端开关锁
3
+ * @param params
4
+ * @returns
5
+ */
6
+ export declare const openDoorByCloud: (deviceId: string, isOpen: boolean) => Promise<unknown>;
7
+ export declare const checkRemoteKey: (deviceId: string) => Promise<{
8
+ effectiveTime: number;
9
+ invalidTime: number;
10
+ password: string;
11
+ }>;
12
+ /**
13
+ * 获取开锁密钥
14
+ * @param deviceId
15
+ * @returns
16
+ */
17
+ export declare const getDoorKey: (deviceId: string) => Promise<{
18
+ effectiveTime: number;
19
+ invalidTime: number;
20
+ password: string;
21
+ }>;
22
+ interface UnlockMethodDetailParams {
23
+ devId: string;
24
+ opModeId: number;
25
+ }
26
+ interface NotifyInfo {
27
+ /**
28
+ * 是否开启 App 消息通知
29
+ */
30
+ appSend?: boolean;
31
+ /**
32
+ * 短信通知手机号,有手机号时,表示开启短信通知
33
+ */
34
+ msgPhone?: string;
35
+ /**
36
+ * 短信通知国家码
37
+ */
38
+ countryCode?: string;
39
+ /**
40
+ * 目标用户 id
41
+ */
42
+ targetUserId?: number;
43
+ }
44
+ /**
45
+ * 开锁方式详细信息
46
+ */
47
+ interface UnlockMethodDetail {
48
+ /**
49
+ * 是否为云端绑定的开锁方式
50
+ */
51
+ allocateFlag: number;
52
+ /**
53
+ * 开锁方式状态
54
+ */
55
+ phase: number;
56
+ /**
57
+ * 开锁方式对应的 dp id
58
+ */
59
+ opmode: string;
60
+ /**
61
+ * 是否为特殊开锁方式
62
+ */
63
+ unlockAttr: number;
64
+ /**
65
+ * 开锁方式名称
66
+ */
67
+ unlockName: string;
68
+ /**
69
+ * 所属用户 id
70
+ */
71
+ userId: string;
72
+ /**
73
+ * 开锁方式硬件id
74
+ */
75
+ opmodeValue: string;
76
+ /**
77
+ * 开锁方式 id
78
+ */
79
+ unlockId: string;
80
+ /**
81
+ * 锁端用户 id
82
+ */
83
+ lockUserId: number;
84
+ /**
85
+ * 开锁方式硬件 id
86
+ */
87
+ opmodeId: string;
88
+ voiceAttr: number;
89
+ /**
90
+ * 时效配置
91
+ */
92
+ userTimeSet: string;
93
+ /**
94
+ * 用户类型
95
+ */
96
+ userType: number;
97
+ sourceAttribute: number;
98
+ /**
99
+ * 开锁消息通知配置
100
+ */
101
+ notifyInfo?: NotifyInfo;
102
+ }
103
+ export declare const getUnlockMethodInfo: (params: UnlockMethodDetailParams) => Promise<UnlockMethodDetail>;
104
+ export declare const fetchCreatePasswordSN: (params: {
105
+ dpId: number;
106
+ devId: string;
107
+ }) => Promise<number>;
108
+ interface CreateUnlockMethodParams {
109
+ devId: string;
110
+ userId: string;
111
+ unlockId: string;
112
+ unlockName?: string;
113
+ unlockAttr: number;
114
+ unlockDetail?: string;
115
+ notifyInfo?: {
116
+ appSend?: boolean;
117
+ msgPhone?: string;
118
+ countryCode?: string;
119
+ msgPhoneVerifyCode?: string;
120
+ };
121
+ }
122
+ export declare const createUnlockMethod: (params: CreateUnlockMethodParams) => Promise<{
123
+ opModeId: number;
124
+ unlockName: string;
125
+ }>;
126
+ interface EditUnlockMethodParams {
127
+ devId: string;
128
+ opModeId: number;
129
+ unlockName?: string;
130
+ unlockAttr: number;
131
+ unlockDetail?: string;
132
+ notifyInfo?: {
133
+ appSend?: boolean;
134
+ msgPhone?: string;
135
+ countryCode?: string;
136
+ msgPhoneVerifyCode?: string;
137
+ };
138
+ }
139
+ export declare const editUnlockMethod: (params: EditUnlockMethodParams) => Promise<unknown>;
140
+ interface RemoveUnlockMethodParams {
141
+ devId: string;
142
+ opmodeId: number;
143
+ }
144
+ /**
145
+ * 删除解锁方式
146
+ * @param {RemoveUnlockMethodParams} params
147
+ * @returns
148
+ */
149
+ export declare const removeUnlockMethod: (params: RemoveUnlockMethodParams) => Promise<unknown>;
150
+ interface FetchSyncUnlockMethodInfoParams {
151
+ devId: string;
152
+ dpIds: string[];
153
+ }
154
+ interface FetchSyncUnlockMethodInfo {
155
+ ins: string;
156
+ distributed: boolean;
157
+ }
158
+ export declare const fetchSyncUnlockMethodInfo: (params: FetchSyncUnlockMethodInfoParams) => Promise<FetchSyncUnlockMethodInfo>;
159
+ interface CheckUnbindUnlockMethodParams {
160
+ devId: string;
161
+ }
162
+ export declare const checkFreeUnlockMethods: (params: CheckUnbindUnlockMethodParams) => Promise<number | boolean>;
163
+ interface FetchFreeUnlockMethodsParams {
164
+ devId: string;
165
+ }
166
+ export interface UnbindUnlockMethods {
167
+ opmode: number;
168
+ standardDp: string;
169
+ unlockInfo: {
170
+ opmodeId: number;
171
+ unlockId: string;
172
+ unlockName: string;
173
+ unlockSn: number;
174
+ }[];
175
+ }
176
+ export declare const fetchFreeUnlockMethods: (params: FetchFreeUnlockMethodsParams) => Promise<UnbindUnlockMethods[]>;
177
+ interface BindUnlockMethodToUserParams {
178
+ devId: string;
179
+ userId: string;
180
+ unlockIds: string[];
181
+ }
182
+ export declare const bindUnlockMethodToUser: (params: BindUnlockMethodToUserParams) => Promise<boolean>;
183
+ interface UnbindMemberUnlockMethodParams {
184
+ devId: string;
185
+ userId: string;
186
+ unlockIds: string[];
187
+ }
188
+ export declare const unbindMemberUnlockMethod: (params: UnbindMemberUnlockMethodParams) => Promise<boolean>;
189
+ interface BindUnlockMethodToUserByRecordParams {
190
+ devId: string;
191
+ userId: string;
192
+ unlockIds: string[];
193
+ }
194
+ export declare const bindUnlockMethodToUserByRecord: (params: BindUnlockMethodToUserByRecordParams) => Promise<boolean>;
195
+ export {};
@@ -0,0 +1,129 @@
1
+ import { THING } from "../utils/constant";
2
+ import { requestCloud } from "../utils/device";
3
+
4
+ /**
5
+ * 直接通过云端开关锁
6
+ * @param params
7
+ * @returns
8
+ */
9
+ export const openDoorByCloud = (deviceId, isOpen) => {
10
+ return requestCloud({
11
+ api: `${THING}.m.zigbee.lock.remotepwd.execute`,
12
+ version: "1.0",
13
+ data: {
14
+ devId: deviceId,
15
+ open: isOpen
16
+ }
17
+ });
18
+ };
19
+ export const checkRemoteKey = async deviceId => {
20
+ return requestCloud({
21
+ api: "m.lock.ble.remote.unlock.check",
22
+ version: "1.0",
23
+ data: {
24
+ devId: deviceId
25
+ }
26
+ });
27
+ };
28
+
29
+ /**
30
+ * 获取开锁密钥
31
+ * @param deviceId
32
+ * @returns
33
+ */
34
+ export const getDoorKey = deviceId => {
35
+ return requestCloud({
36
+ api: "m.lock.ble.remote.unlock.get",
37
+ version: "1.0",
38
+ data: {
39
+ devId: deviceId
40
+ }
41
+ });
42
+ };
43
+
44
+ /**
45
+ * 开锁方式详细信息
46
+ */
47
+
48
+ export const getUnlockMethodInfo = params => {
49
+ return requestCloud({
50
+ api: `${THING}.m.device.member.opmode.detail`,
51
+ version: "1.0",
52
+ data: params
53
+ });
54
+ };
55
+ export const fetchCreatePasswordSN = params => {
56
+ return requestCloud({
57
+ api: `${THING}.m.device.dp.sn.get`,
58
+ version: "1.0",
59
+ data: params
60
+ });
61
+ };
62
+ export const createUnlockMethod = params => {
63
+ return requestCloud({
64
+ api: `${THING}.m.device.member.opmode.add`,
65
+ version: "5.0",
66
+ data: params
67
+ });
68
+ };
69
+ export const editUnlockMethod = params => {
70
+ return requestCloud({
71
+ api: `${THING}.m.device.member.opmode.update`,
72
+ version: "5.0",
73
+ data: params
74
+ });
75
+ };
76
+ /**
77
+ * 删除解锁方式
78
+ * @param {RemoveUnlockMethodParams} params
79
+ * @returns
80
+ */
81
+ export const removeUnlockMethod = params => {
82
+ return requestCloud({
83
+ api: `${THING}.m.device.member.opmode.remove`,
84
+ version: "2.0",
85
+ data: params
86
+ });
87
+ };
88
+ export const fetchSyncUnlockMethodInfo = params => {
89
+ return requestCloud({
90
+ api: `${THING}.m.device.opmode.sync.rise`,
91
+ version: "2.0",
92
+ data: params
93
+ });
94
+ };
95
+ export const checkFreeUnlockMethods = params => {
96
+ return requestCloud({
97
+ api: `${THING}.m.device.unlock.waitassign`,
98
+ version: "1.0",
99
+ data: params
100
+ });
101
+ };
102
+ export const fetchFreeUnlockMethods = params => {
103
+ return requestCloud({
104
+ api: `${THING}.m.device.unlock.assignlist`,
105
+ version: "1.0",
106
+ data: params
107
+ });
108
+ };
109
+ export const bindUnlockMethodToUser = params => {
110
+ return requestCloud({
111
+ api: `${THING}.m.device.user.unlock.allocate`,
112
+ version: "1.0",
113
+ data: params
114
+ });
115
+ };
116
+ export const unbindMemberUnlockMethod = params => {
117
+ return requestCloud({
118
+ api: `${THING}.m.device.user.unlock.unbind`,
119
+ version: "1.0",
120
+ data: params
121
+ });
122
+ };
123
+ export const bindUnlockMethodToUserByRecord = params => {
124
+ return requestCloud({
125
+ api: `${THING}.m.device.user.unlock.bind`,
126
+ version: "1.0",
127
+ data: params
128
+ });
129
+ };