@ray-js/lock-sdk 1.1.1-beta.4 → 1.1.1-beta.6

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/user.js CHANGED
@@ -40,8 +40,8 @@ export const getUserList = (params) => {
40
40
  };
41
41
  export const getUserDetail = (params) => {
42
42
  return requestApi({
43
- api: `${THING}.m.device.member.detail`,
44
- version: "4.0",
43
+ api: 'm.lock.device.member.detail',
44
+ version: "1.0",
45
45
  data: params,
46
46
  });
47
47
  };
@@ -52,7 +52,7 @@ export const validConfigDpMap = {
52
52
  .slice(0, 7);
53
53
  },
54
54
  format: (value) => {
55
- const weekHex = parseInt(value.reverse().join(""), 2)
55
+ const weekHex = parseInt([...value].reverse().join(""), 2)
56
56
  .toString(16)
57
57
  .padStart(2, "0");
58
58
  return `000000${weekHex}`;
@@ -150,6 +150,7 @@ export interface NotifyInfo {
150
150
  }
151
151
  export interface UnlockMethodDetail {
152
152
  isBound: boolean;
153
+ type: UnlockMethodType;
153
154
  phase: number;
154
155
  dpId: number;
155
156
  isSpecial: boolean;
package/lib/open.js CHANGED
@@ -94,7 +94,7 @@ const _doAction = async (isOpen, timeout) => {
94
94
  }
95
95
  return false;
96
96
  };
97
- if (hasThread && deviceStatus.onlineType === "local") {
97
+ if (hasThread && deviceStatus.onlineTypes.includes("local") && deviceStatus.onlineTypes.length === 1) {
98
98
  await publishDps({ [dpCodes.matterLanUnlock]: isOpen }, {
99
99
  checkReport: (dps) => {
100
100
  return typeof dps[dpCodes.matterLanUnlock] !== "undefined";
package/lib/sync/temp.js CHANGED
@@ -69,7 +69,7 @@ export const syncTemp = async () => {
69
69
  });
70
70
  }
71
71
  catch (e) {
72
- console.log(e, "sync temp password error");
72
+ console.warn(e, "sync temp password error");
73
73
  }
74
74
  };
75
75
  export const autoSyncTemp = () => {
package/lib/temporary.js CHANGED
@@ -83,7 +83,7 @@ export const createTempCustom = parallelOnly(async (params) => {
83
83
  endTime: effective.expiredDate,
84
84
  loop: loopType,
85
85
  loopConfig: 0,
86
- weeks: effective.weeks ? [...effective.weeks] : [0, 0, 0, 0, 0, 0, 0],
86
+ weeks: effective.weeks ? effective.weeks : [0, 0, 0, 0, 0, 0, 0],
87
87
  days: [],
88
88
  startHour: Math.floor(effectiveTime / 60),
89
89
  startMinute: effectiveTime % 60,
@@ -31,6 +31,7 @@ export const getUnlockMethodDetail = async (id) => {
31
31
  });
32
32
  const detail = {
33
33
  isBound: cloudData.allocateFlag === 1,
34
+ type: getUnlockMethodTypeByDpCode(config.codesById[Number(cloudData.opmode)])?.type,
34
35
  phase: cloudData.phase,
35
36
  dpId: Number(cloudData.opmode),
36
37
  isSpecial: cloudData.unlockAttr === 1,
@@ -50,7 +51,7 @@ export const getUnlockMethodDetail = async (id) => {
50
51
  return detail;
51
52
  };
52
53
  const getUnlockMethodBase = async (type, userId) => {
53
- const { idsByCode, devInfo: { devId }, supportBigData, dpSchema, } = config;
54
+ const { idsByCode, devInfo: { devId }, supportBigData, } = config;
54
55
  const unlockMethodConfig = getUnlockMethodTypeByType(type);
55
56
  const addDpCode = supportBigData
56
57
  ? dpCodes.unlockMethodCreateW
package/lib/user.js CHANGED
@@ -23,7 +23,8 @@ const concactUserList = (list, result) => {
23
23
  if (!item.timeScheduleInfo.permanent &&
24
24
  item.timeScheduleInfo.scheduleDetails &&
25
25
  item.timeScheduleInfo.scheduleDetails.length > 0) {
26
- Object.assign(timeScheduleInfo, {
26
+ Object.assign(scheduleInfo, {
27
+ permanent: false,
27
28
  effectiveTime: formatTimestampToMilliseconds(item.timeScheduleInfo.effectiveTime || 0),
28
29
  expiredTime: formatTimestampToMilliseconds(item.timeScheduleInfo.expiredTime || 0),
29
30
  scheduleDetails: {
@@ -145,7 +146,7 @@ export const updateUserLimitTime = async (params) => {
145
146
  loopConfig: 0,
146
147
  weeks: effective?.repeat !== "week" || effective?.weeks === undefined
147
148
  ? [0, 0, 0, 0, 0, 0, 0]
148
- : [...effective.weeks],
149
+ : effective.weeks,
149
150
  days: [],
150
151
  startHour: Math.floor(effectiveTime / 60),
151
152
  startMinute: effectiveTime % 60,
@@ -153,33 +154,33 @@ export const updateUserLimitTime = async (params) => {
153
154
  endMinute: expiredTime % 60,
154
155
  },
155
156
  };
156
- const dpCode = config.supportBigData
157
- ? dpCodes.unlockMethodEditW
158
- : dpCodes.unlockMethodEdit;
159
- const res = (await publishDps({
160
- [dpCode]: DpUtils.format(dpValue, (config.supportBigData ? updateMapBig : updateMap)),
161
- }, {
162
- checkReport: (dps) => {
163
- if (typeof dps[dpCode] !== "undefined") {
164
- const result = DpUtils.parse(dps[dpCode], (config.supportBigData
165
- ? reportUpdateMapBig
166
- : reportUpdateMap));
167
- if (result.type === 0) {
168
- if (result.memberId === lockUserId) {
169
- return result;
170
- }
171
- else {
172
- console.warn("An incorrect member id was returned");
157
+ try {
158
+ const dpCode = config.supportBigData
159
+ ? dpCodes.unlockMethodEditW
160
+ : dpCodes.unlockMethodEdit;
161
+ const res = (await publishDps({
162
+ [dpCode]: DpUtils.format(dpValue, (config.supportBigData ? updateMapBig : updateMap)),
163
+ }, {
164
+ checkReport: (dps) => {
165
+ if (typeof dps[dpCode] !== "undefined") {
166
+ const result = DpUtils.parse(dps[dpCode], (config.supportBigData
167
+ ? reportUpdateMapBig
168
+ : reportUpdateMap));
169
+ if (result.type === 0) {
170
+ if (result.memberId === lockUserId) {
171
+ return result;
172
+ }
173
+ else {
174
+ console.warn("An incorrect member id was returned");
175
+ }
173
176
  }
174
177
  }
175
- }
176
- return false;
177
- },
178
- }));
179
- if (res.status !== 255) {
180
- throw getError(1011);
181
- }
182
- try {
178
+ return false;
179
+ },
180
+ }));
181
+ if (res.status !== 255) {
182
+ throw getError(1011);
183
+ }
183
184
  await updateUserTimeSchedule({
184
185
  devId: config.devInfo.devId,
185
186
  userId: userId,
@@ -107,7 +107,7 @@ export declare const parseOfflinePassword: (value: string) => string;
107
107
  export declare const formatTimestampToMilliseconds: (timestamp: number) => number;
108
108
  export declare const unlockMethodConfigs: UnlockMethodConfig[];
109
109
  export declare const getUnlockMethodTypeByDpCode: (dpCode: string) => UnlockMethodConfig;
110
- export declare const getUnlockMethodTypeById: (id: number) => UnlockMethodConfig;
110
+ export declare const getUnlockMethodTypeById: (id: number | string) => UnlockMethodConfig;
111
111
  export declare const getUnlockMethodTypeByType: (type: string) => UnlockMethodConfig;
112
112
  export declare const parallelMerge: <T extends (...args: any[]) => Promise<any>>(cb: T) => (...args: Parameters<T>) => ReturnType<T>;
113
113
  export declare const parallelOnly: <T extends (...args: any[]) => Promise<any>>(cb: T) => (...args: Parameters<T>) => ReturnType<T>;
@@ -49,7 +49,8 @@ export function getCapabilities(capability) {
49
49
  });
50
50
  }
51
51
  export const formatWeek = (value) => {
52
- return parseInt([...value].reverse().join(""), 2);
52
+ const temp = value.slice(0, 7);
53
+ return parseInt(temp.reverse().join(""), 2);
53
54
  };
54
55
  export const parseWeek = (value) => {
55
56
  return Number(value)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.1.1-beta.4",
3
+ "version": "1.1.1-beta.6",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"