@ray-js/lock-sdk 1.0.0 → 1.0.1-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.
@@ -98,7 +98,7 @@ export interface LinkageRule {
98
98
  * @param deviceId
99
99
  * @returns {Promise<LinkageList>}
100
100
  */
101
- export declare const getLinkageList: (deviceId: string) => Promise<LinkageRule[]>;
101
+ export declare const getLinkageList: (deviceId: string, homeId: string) => Promise<LinkageRule[]>;
102
102
  interface LinkageCondition {
103
103
  entityType: number;
104
104
  entityId: string;
@@ -145,17 +145,17 @@ interface SaveLinkageParams {
145
145
  * @param data
146
146
  * @returns
147
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>;
148
+ export declare const saveLinkage: (data: SaveLinkageParams, homeId: string) => Promise<unknown>;
149
+ export declare const enableLinkage: (ruleId: string, homeId: string) => Promise<unknown>;
150
+ export declare const disableLinkage: (ruleId: string, homeId: string) => Promise<unknown>;
151
151
  /**
152
152
  * 获取剩余短信通知次数
153
153
  * @returns
154
154
  */
155
- export declare const getRemainingMessage: () => Promise<number>;
155
+ export declare const getRemainingMessage: (homeId: string) => Promise<number>;
156
156
  /**
157
157
  * 获取剩余语音通知次数
158
158
  * @returns
159
159
  */
160
- export declare const getRemainingPhone: () => Promise<number>;
160
+ export declare const getRemainingPhone: (homeId: string) => Promise<number>;
161
161
  export {};
@@ -5,12 +5,15 @@ import { requestCloud } from "../utils/device";
5
5
  * @param deviceId
6
6
  * @returns {Promise<LinkageList>}
7
7
  */
8
- export const getLinkageList = deviceId => {
8
+ export const getLinkageList = (deviceId, homeId) => {
9
9
  return requestCloud({
10
10
  api: `${THING}.m.linkage.doorlock.rule.query`,
11
11
  version: "2.0",
12
12
  data: {
13
13
  devId: deviceId
14
+ },
15
+ extData: {
16
+ gid: homeId
14
17
  }
15
18
  });
16
19
  };
@@ -19,30 +22,39 @@ export const getLinkageList = deviceId => {
19
22
  * @param data
20
23
  * @returns
21
24
  */
22
- export const saveLinkage = data => {
25
+ export const saveLinkage = (data, homeId) => {
23
26
  return requestCloud({
24
27
  api: `${THING}.m.linkage.device.shell.save`,
25
28
  version: "2.0",
26
29
  data: {
27
30
  shellExpr: data
31
+ },
32
+ extData: {
33
+ gid: homeId
28
34
  }
29
35
  });
30
36
  };
31
- export const enableLinkage = ruleId => {
37
+ export const enableLinkage = (ruleId, homeId) => {
32
38
  return requestCloud({
33
39
  api: `${THING}.m.linkage.rule.enable`,
34
40
  version: "1.0",
35
41
  data: {
36
42
  ruleId
43
+ },
44
+ extData: {
45
+ gid: homeId
37
46
  }
38
47
  });
39
48
  };
40
- export const disableLinkage = ruleId => {
49
+ export const disableLinkage = (ruleId, homeId) => {
41
50
  return requestCloud({
42
51
  api: `${THING}.m.linkage.rule.disable`,
43
52
  version: "1.0",
44
53
  data: {
45
54
  ruleId
55
+ },
56
+ extData: {
57
+ gid: homeId
46
58
  }
47
59
  });
48
60
  };
@@ -51,12 +63,15 @@ export const disableLinkage = ruleId => {
51
63
  * 获取剩余短信通知次数
52
64
  * @returns
53
65
  */
54
- export const getRemainingMessage = () => {
66
+ export const getRemainingMessage = homeId => {
55
67
  return requestCloud({
56
68
  api: `${THING}.m.notification.subscribe.info`,
57
69
  version: "1.0",
58
70
  data: {
59
71
  notificationType: "sms_notification"
72
+ },
73
+ extData: {
74
+ gid: homeId
60
75
  }
61
76
  });
62
77
  };
@@ -65,10 +80,13 @@ export const getRemainingMessage = () => {
65
80
  * 获取剩余语音通知次数
66
81
  * @returns
67
82
  */
68
- export const getRemainingPhone = () => {
83
+ export const getRemainingPhone = homeId => {
69
84
  return requestCloud({
70
85
  api: `${THING}.m.mobile.voice.times.count`,
71
86
  version: "1.0",
72
- data: {}
87
+ data: {},
88
+ extData: {
89
+ gid: homeId
90
+ }
73
91
  });
74
92
  };
package/lib/linkage.d.ts CHANGED
@@ -19,7 +19,7 @@ export declare const enableDoorbellService: () => Promise<void>;
19
19
  /**
20
20
  * 禁用门铃通知服务
21
21
  */
22
- export declare const disableDoorbellService: () => Promise<never>;
22
+ export declare const disableDoorbellService: () => Promise<void>;
23
23
  /**
24
24
  * 去配置门铃通知服务
25
25
  */
package/lib/linkage.js CHANGED
@@ -17,7 +17,8 @@ const MESSAGE_TYPE = "smsSend"; // actions对象的actionExecutor属性的类型
17
17
  * @returns {Promise<{message: number, phone: number}>}
18
18
  */
19
19
  export const getRemainingInfo = async () => {
20
- const [message, phone] = await Promise.all([getRemainingMessage(), getRemainingPhone()]);
20
+ const homeInfo = await getHomeInfo();
21
+ const [message, phone] = await Promise.all([getRemainingMessage(homeInfo.homeId), getRemainingPhone(homeInfo.homeId)]);
21
22
  return {
22
23
  message,
23
24
  phone
@@ -29,15 +30,15 @@ export const getRemainingInfo = async () => {
29
30
  * @returns {Promise<boolean>}
30
31
  */
31
32
  export const getDoorbellService = async () => {
32
- const list = await getLinkageList(config.devInfo.devId);
33
+ const homeInfo = await getHomeInfo();
34
+ const list = await getLinkageList(config.devInfo.devId, homeInfo.homeId);
33
35
  return list.find(item => item.code === DOORBELL_RING_TYPE && item.ruleId);
34
36
  };
35
37
  const createDoorbellService = async () => {
36
38
  const actions = await createAction({
37
- createType: "auto",
38
- smartType: "remind"
39
+ createType: "remind",
40
+ smartType: "auto"
39
41
  });
40
- console.log("actions", actions);
41
42
  await saveDoorbellService(actions);
42
43
  };
43
44
  const saveDoorbellService = async actions => {
@@ -46,12 +47,14 @@ const saveDoorbellService = async actions => {
46
47
  saveLinkage({
47
48
  devId: config.devInfo.devId,
48
49
  ownerId: homeInfo.homeId,
49
- name: "",
50
+ name: "doorbell",
50
51
  enabled: true,
51
- extraInfo: {},
52
- bizType: DOORBELL_RING_TYPE,
52
+ extraInfo: {
53
+ code: DOORBELL_RING_TYPE
54
+ },
55
+ bizType: "3",
53
56
  logicRuleList: [{
54
- name: "",
57
+ name: "doorbell",
55
58
  // 规则名称
56
59
  matchType: 2,
57
60
  // MatchType枚举,1:任意条件触发,2:全部条件满足触发,3:通过expr来判断整个条件的匹配情况
@@ -61,7 +64,7 @@ const saveDoorbellService = async actions => {
61
64
  // 是否在场景列表中展示
62
65
  preConditions: [],
63
66
  coverIcon: "",
64
- displayColor: "",
67
+ displayColor: "0084FF",
65
68
  background: "",
66
69
  conditions: [{
67
70
  entityType: 23,
@@ -114,7 +117,7 @@ const saveDoorbellService = async actions => {
114
117
  return item;
115
118
  })
116
119
  }]
117
- });
120
+ }, homeInfo.homeId);
118
121
  };
119
122
 
120
123
  /**
@@ -122,9 +125,10 @@ const saveDoorbellService = async actions => {
122
125
  * 注意: 首次开通时,会先进入创建动作的页面,创建完成后,会自动启用门铃通知服务
123
126
  */
124
127
  export const enableDoorbellService = async () => {
128
+ const homeInfo = await getHomeInfo();
125
129
  const service = await getDoorbellService();
126
130
  if (service && service.ruleId) {
127
- await enableLinkage(service.ruleId);
131
+ await enableLinkage(service.ruleId, homeInfo.homeId);
128
132
  } else {
129
133
  await createDoorbellService();
130
134
  }
@@ -134,9 +138,11 @@ export const enableDoorbellService = async () => {
134
138
  * 禁用门铃通知服务
135
139
  */
136
140
  export const disableDoorbellService = async () => {
141
+ const homeInfo = await getHomeInfo();
137
142
  const service = await getDoorbellService();
138
143
  if (service && service.ruleId) {
139
- await disableLinkage(service.ruleId);
144
+ await disableLinkage(service.ruleId, homeInfo.homeId);
145
+ return;
140
146
  }
141
147
  throw getError(1059);
142
148
  };
@@ -166,7 +172,6 @@ export const toSetDoorbellService = async () => {
166
172
  return item;
167
173
  })
168
174
  });
169
- console.log("actions", actions);
170
175
  await saveDoorbellService(actions);
171
176
  } else {
172
177
  // 去创建
package/lib/sleep.js CHANGED
@@ -30,7 +30,6 @@ export const hasSleepAbility = () => {
30
30
  const {
31
31
  dpSchema
32
32
  } = config;
33
- console.log('dpSchema', dpSchema[dpCodes.dormantSwitch], dpSchema[dpCodes.dormantTimeSet]);
34
33
  return (typeof dpSchema[dpCodes.dormantSwitch] !== "undefined" || typeof dpSchema[dpCodes.onlineSwitch] !== "undefined") && typeof dpSchema[dpCodes.dormantTimeSet] !== "undefined";
35
34
  };
36
35
  const setSleepStatus = async status => {
@@ -182,7 +182,6 @@ export const addPassword = async params => {
182
182
  checkReport: dpData => {
183
183
  if (typeof dpData[addDpCode] !== "undefined") {
184
184
  const result = dpUtils.parse(dpData[addDpCode], addDpReportMap);
185
- console.log("AddPassword checkReport", result);
186
185
  let hasReport = result.type === unlockMethodConfig.id && [0xff, 0xfd].includes(result.stage);
187
186
  // 是否严格模式
188
187
  if (config.strictMode) {
@@ -359,7 +358,6 @@ const handleAddReport = async dps => {
359
358
  }
360
359
  };
361
360
  const clearMonitoringAddReport = () => {
362
- console.log("clearMonitoringAddReport");
363
361
  clearTimeout(addUnlockMethodData.timeoutId);
364
362
  // 清除监听器
365
363
  emitter.off(DPCHANGE, handleAddReport);
package/lib/user.d.ts CHANGED
@@ -84,7 +84,7 @@ export declare const openAddFamilyUser: () => Promise<unknown>;
84
84
  * 支持编辑
85
85
  * @param {string} userId 成员id
86
86
  */
87
- export declare const openFamilyUserDetail: (userId: string) => Promise<never>;
87
+ export declare const openFamilyUserDetail: (userId: string) => Promise<undefined>;
88
88
  interface AddUserParams {
89
89
  /**
90
90
  * 用户名称
package/lib/user.js CHANGED
@@ -213,7 +213,6 @@ export const updateUserLimitTime = async params => {
213
213
  checkReport: dps => {
214
214
  if (typeof dps[dpCode] !== "undefined") {
215
215
  const result = DpUtils.parse(dps[dpCode], config.supportBigData ? reportUpdateMapBig : reportUpdateMap);
216
- console.log("reportUpdate result", result);
217
216
  if (result.type === 0) {
218
217
  if (result.memberId === lockUserId) {
219
218
  return result;
@@ -231,7 +230,6 @@ export const updateUserLimitTime = async params => {
231
230
  }
232
231
  // 更新云端数据
233
232
  try {
234
- console.log("dpValue.validConfig", dpValue.validConfig);
235
233
  await updateUserTimeSchedule({
236
234
  devId: config.devInfo.devId,
237
235
  userId: userId,
@@ -298,32 +296,25 @@ const userTypeMap = {
298
296
  * @param {string} userId 成员id
299
297
  */
300
298
  export const openFamilyUserDetail = async userId => {
301
- const homeId = await getCurrentHomeInfo();
299
+ const {
300
+ homeId
301
+ } = await getCurrentHomeInfo();
302
302
  const {
303
303
  userType: currentUserType
304
304
  } = await getCurrentUser();
305
305
  const role = userTypeMap[currentUserType];
306
306
  let link = await isSupportShortLink("member_info");
307
307
  if (link) {
308
- ty.canIUseRouter({
309
- url: "member_info",
310
- success: res => {
311
- if (res !== null && res !== void 0 && res.result) {
312
- ty.router({
313
- url: `tuyaSmart://member_info?homeId=${homeId}&memberId=${userId}&role=${role}`,
314
- success: () => {
315
- console.log("跳转成员详情页成功");
316
- },
317
- fail: e => {
318
- console.log("跳转成员详情页失败", e);
319
- }
320
- });
321
- }
308
+ ty.router({
309
+ url: `tuyaSmart://member_info?homeId=${homeId}&memberId=${userId}&role=${role}`,
310
+ success: () => {
311
+ console.log("openFamilyUserDetail success");
322
312
  },
323
- fail: err => {
324
- console.log(err);
313
+ fail: e => {
314
+ console.log("openFamilyUserDetail fail", e);
325
315
  }
326
316
  });
317
+ return;
327
318
  }
328
319
 
329
320
  // 不支持跳转
@@ -39,6 +39,7 @@ export declare const requestCloud: <T>(options: {
39
39
  api: string;
40
40
  version: string;
41
41
  data: Record<string, any>;
42
+ extData?: Record<string, any>;
42
43
  }) => Promise<T>;
43
44
  export declare const getLaunchOptionsSync: () => any;
44
45
  export declare function encrypt(deviceId: string, plaintext: string): Promise<string>;
@@ -146,6 +146,7 @@ export const requestCloud = options => {
146
146
  api: options.api,
147
147
  version: options.version,
148
148
  data: options.data,
149
+ extData: options.extData,
149
150
  success: d => {
150
151
  resolve(d);
151
152
  },
@@ -210,7 +211,8 @@ export const isSupportShortLink = async link => {
210
211
  resolve("");
211
212
  }
212
213
  },
213
- fail: () => {
214
+ fail: err => {
215
+ console.warn("isSupportShortLink fail", err);
214
216
  resolve("");
215
217
  }
216
218
  });
@@ -15,7 +15,6 @@ import { getError } from "./errors";
15
15
  * @returns
16
16
  */
17
17
  export const publishDpsOnly = async dpData => {
18
- console.log("_publishDps", dpData);
19
18
  const {
20
19
  devInfo,
21
20
  idsByCode
@@ -47,7 +46,6 @@ export const publishDpsOnly = async dpData => {
47
46
  // 发送 dp 并等待上报
48
47
  export const publishDps = async (dpData, option) => {
49
48
  await publishDpsOnly(dpData);
50
- console.log("publishDps success");
51
49
  // 默认 15s 超时
52
50
  const {
53
51
  timeout = 15000,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1-beta-1",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"