@ray-js/lock-sdk 1.1.1-beta.3 → 1.1.1-beta.5
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 +2 -2
- package/lib/config/dp-map/common.js +1 -1
- package/lib/interface.d.ts +3 -1
- package/lib/sync/temp.js +1 -1
- package/lib/temporary.js +1 -1
- package/lib/unlock-method.d.ts +1 -0
- package/lib/unlock-method.js +11 -6
- package/lib/user.js +29 -31
- package/lib/utils/errors.js +1 -0
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +2 -1
- package/package.json +1 -1
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:
|
|
44
|
-
version: "
|
|
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}`;
|
package/lib/interface.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export interface CurrentUser {
|
|
|
82
82
|
permanent: boolean;
|
|
83
83
|
}
|
|
84
84
|
export interface UnlockMethodBaseInfo {
|
|
85
|
-
unlockId:
|
|
85
|
+
unlockId: number;
|
|
86
86
|
unlockName: string;
|
|
87
87
|
isBound: boolean;
|
|
88
88
|
id: number;
|
|
@@ -144,11 +144,13 @@ export type DpMapDataType<T extends DpMapType> = {
|
|
|
144
144
|
};
|
|
145
145
|
export interface NotifyInfo {
|
|
146
146
|
appSend?: boolean;
|
|
147
|
+
msgSend?: boolean;
|
|
147
148
|
msgPhone?: string;
|
|
148
149
|
countryCode?: string;
|
|
149
150
|
}
|
|
150
151
|
export interface UnlockMethodDetail {
|
|
151
152
|
isBound: boolean;
|
|
153
|
+
type: UnlockMethodType;
|
|
152
154
|
phase: number;
|
|
153
155
|
dpId: number;
|
|
154
156
|
isSpecial: boolean;
|
package/lib/sync/temp.js
CHANGED
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
|
|
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,
|
package/lib/unlock-method.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ErrorData, UnBindUnlockMethodGroup, UnlockGuide, UnlockMethodDetail, UnlockMethodType } from "./interface";
|
|
2
2
|
export interface SpecialUnlockMethodInfo {
|
|
3
3
|
appSend?: boolean;
|
|
4
|
+
msgSend?: boolean;
|
|
4
5
|
msgPhone?: string;
|
|
5
6
|
verifyCode?: string;
|
|
6
7
|
countryCode?: string;
|
package/lib/unlock-method.js
CHANGED
|
@@ -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,
|
|
@@ -42,6 +43,7 @@ export const getUnlockMethodDetail = async (id) => {
|
|
|
42
43
|
userType: cloudData.userType,
|
|
43
44
|
notifyInfo: {
|
|
44
45
|
appSend: !!cloudData.notifyInfo?.appSend,
|
|
46
|
+
msgSend: !!cloudData.notifyInfo?.msgPhone,
|
|
45
47
|
msgPhone: cloudData.notifyInfo?.msgPhone,
|
|
46
48
|
countryCode: cloudData.notifyInfo?.countryCode,
|
|
47
49
|
},
|
|
@@ -49,7 +51,7 @@ export const getUnlockMethodDetail = async (id) => {
|
|
|
49
51
|
return detail;
|
|
50
52
|
};
|
|
51
53
|
const getUnlockMethodBase = async (type, userId) => {
|
|
52
|
-
const { idsByCode, devInfo: { devId }, supportBigData,
|
|
54
|
+
const { idsByCode, devInfo: { devId }, supportBigData, } = config;
|
|
53
55
|
const unlockMethodConfig = getUnlockMethodTypeByType(type);
|
|
54
56
|
const addDpCode = supportBigData
|
|
55
57
|
? dpCodes.unlockMethodCreateW
|
|
@@ -105,11 +107,14 @@ const checkSpecial = (isSpecial, params, oldSetting) => {
|
|
|
105
107
|
if (!supportedPhone) {
|
|
106
108
|
throw getError(1057);
|
|
107
109
|
}
|
|
108
|
-
else if (!params?.
|
|
110
|
+
else if (!params?.msgSend) {
|
|
109
111
|
throw getError(1058);
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
|
-
if (supportedPhone && params?.
|
|
114
|
+
if (supportedPhone && params?.msgSend) {
|
|
115
|
+
if (!params.msgPhone) {
|
|
116
|
+
throw getError(1066);
|
|
117
|
+
}
|
|
113
118
|
if (!params.countryCode) {
|
|
114
119
|
throw getError(1056);
|
|
115
120
|
}
|
|
@@ -122,9 +127,9 @@ const checkSpecial = (isSpecial, params, oldSetting) => {
|
|
|
122
127
|
unlockAttr: isSpecial ? 1 : 0,
|
|
123
128
|
notifyInfo: {
|
|
124
129
|
appSend: !!params?.appSend,
|
|
125
|
-
msgPhone: supportedPhone ? params?.msgPhone : undefined,
|
|
126
|
-
countryCode: supportedPhone ? params?.countryCode : undefined,
|
|
127
|
-
msgPhoneVerifyCode: supportedPhone ? params?.verifyCode : undefined,
|
|
130
|
+
msgPhone: supportedPhone && params?.msgSend ? params?.msgPhone : undefined,
|
|
131
|
+
countryCode: supportedPhone && params?.msgSend ? params?.countryCode : undefined,
|
|
132
|
+
msgPhoneVerifyCode: supportedPhone && params?.msgSend ? params?.verifyCode : undefined,
|
|
128
133
|
},
|
|
129
134
|
};
|
|
130
135
|
};
|
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(
|
|
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: {
|
|
@@ -38,7 +39,7 @@ const concactUserList = (list, result) => {
|
|
|
38
39
|
let unlockDetails = unlockDetail.map((detail) => {
|
|
39
40
|
const unlockList = detail.unlockList.map((unlockItem) => {
|
|
40
41
|
return {
|
|
41
|
-
unlockId: unlockItem.unlockId.split("-")[1],
|
|
42
|
+
unlockId: +unlockItem.unlockId.split("-")[1],
|
|
42
43
|
unlockName: unlockItem.unlockName,
|
|
43
44
|
id: unlockItem.opModeId,
|
|
44
45
|
isBound: unlockItem.allocateFlag === 1,
|
|
@@ -153,33 +154,33 @@ export const updateUserLimitTime = async (params) => {
|
|
|
153
154
|
endMinute: expiredTime % 60,
|
|
154
155
|
},
|
|
155
156
|
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (result.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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,
|
|
@@ -241,11 +242,8 @@ export const openFamilyUserDetail = async (userId) => {
|
|
|
241
242
|
const url = `tuyaSmart://member_info?homeId=${homeId}&memberId=${userId}&role=${role}`;
|
|
242
243
|
ty.router({
|
|
243
244
|
url: url,
|
|
244
|
-
success: (d) => {
|
|
245
|
-
console.log("openFamilyUserDetail success");
|
|
246
|
-
},
|
|
247
245
|
fail: (e) => {
|
|
248
|
-
console.
|
|
246
|
+
console.error("openFamilyUserDetail fail", e);
|
|
249
247
|
},
|
|
250
248
|
});
|
|
251
249
|
return;
|
package/lib/utils/errors.js
CHANGED
|
@@ -64,6 +64,7 @@ const errors = {
|
|
|
64
64
|
1063: "Password length only supports 4-6 digits",
|
|
65
65
|
1064: "Non-thread device, not supported in LAN connection to open and close locks",
|
|
66
66
|
1065: "Cloud side has been deleted, but device side synchronization deletion failed",
|
|
67
|
+
1066: "Phone number cannot be empty",
|
|
67
68
|
};
|
|
68
69
|
export const getError = (code, ...places) => {
|
|
69
70
|
if (errors[code]) {
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -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>;
|
package/lib/utils/index.js
CHANGED
|
@@ -49,7 +49,8 @@ export function getCapabilities(capability) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
export const formatWeek = (value) => {
|
|
52
|
-
|
|
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)
|