@ray-js/lock-sdk 1.1.0 → 1.1.1-beta.10
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.d.ts +8 -0
- package/lib/api/index.js +10 -0
- package/lib/api/lock.d.ts +5 -0
- package/lib/api/lock.js +7 -0
- package/lib/api/temp.js +1 -1
- package/lib/api/user.d.ts +6 -0
- package/lib/api/user.js +9 -2
- package/lib/capability.js +44 -18
- package/lib/config/dp-code/index.d.ts +1 -0
- package/lib/config/dp-code/index.js +1 -0
- package/lib/config/dp-map/common.js +1 -1
- package/lib/config/dp-map/unlock-method-big.d.ts +10 -11
- package/lib/config/index.d.ts +2 -1
- package/lib/config/index.js +1 -0
- package/lib/index.js +2 -1
- package/lib/interface.d.ts +14 -1
- package/lib/log.js +16 -4
- package/lib/open.js +22 -12
- package/lib/other.d.ts +1 -0
- package/lib/other.js +18 -10
- package/lib/state.js +65 -73
- package/lib/sync/temp.js +1 -1
- package/lib/sync/user.js +2 -38
- package/lib/temporary.d.ts +2 -1
- package/lib/temporary.js +60 -16
- package/lib/unlock-method.d.ts +3 -1
- package/lib/unlock-method.js +59 -7
- package/lib/user.d.ts +22 -2
- package/lib/user.js +115 -104
- package/lib/utils/device.d.ts +1 -0
- package/lib/utils/device.js +1 -1
- package/lib/utils/errors.js +3 -0
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +16 -13
- package/lib/utils/publishDps.js +1 -1
- package/lib/utils/user.d.ts +2 -0
- package/lib/utils/user.js +39 -0
- package/package.json +1 -1
- package/lib/dp-interface.d.ts +0 -7
- package/lib/dp-interface.js +0 -1
- package/lib/sync/unlock-mothod.d.ts +0 -2
- package/lib/sync/unlock-mothod.js +0 -42
package/lib/user.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserDetail, getUserList } from "./api/user";
|
|
1
|
+
import { getUserDetail, getUserDetailQuery, getUserList, } from "./api/user";
|
|
2
2
|
import config from "./config";
|
|
3
3
|
import { update as updateMap, reportUpdate as reportUpdateMap, } from "./config/dp-map/unlock-method";
|
|
4
4
|
import { update as updateMapBig, reportUpdate as reportUpdateMapBig, } from "./config/dp-map/unlock-method-big";
|
|
@@ -8,62 +8,67 @@ import DpUtils from "@ray-js/tuya-dp-transform";
|
|
|
8
8
|
import { getError } from "./utils/errors";
|
|
9
9
|
import { updateUserTimeSchedule, addNormalUser, removeNormalUser, } from "./api/user";
|
|
10
10
|
import { validConfigDpMap } from "./config/dp-map/common";
|
|
11
|
-
import { formatTimestampToMilliseconds, formatWeek, isAdmin, parseWeek, unlockMethodConfigs, validateEffectiveConfig, } from "./utils";
|
|
11
|
+
import { formatTimestampToMilliseconds, formatWeek, getPermanentSetting, isAdmin, isUseNearChannel, parseWeek, unlockMethodConfigs, validateEffectiveConfig, } from "./utils";
|
|
12
12
|
import { getCurrentHomeInfo, isSupportShortLink } from "./utils/device";
|
|
13
13
|
import { LoopTypes } from "./utils/constant";
|
|
14
14
|
import { getCurrentUser } from "./state";
|
|
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
|
-
unlockName: unlockItem.unlockName,
|
|
41
|
-
id: unlockItem.opModeId,
|
|
42
|
-
isBound: unlockItem.allocateFlag === 1,
|
|
43
|
-
photoUnlock: unlockItem.photoUnlock,
|
|
44
|
-
isSpecial: unlockItem.unlockAttr === 1,
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
const unlockMethodConfig = unlockMethodConfigs.find((item) => item.code === detail.dpCode);
|
|
15
|
+
import { deleteUser } from "./utils/user";
|
|
16
|
+
import { UserType } from "./constant";
|
|
17
|
+
const handleUserDetail = (user) => {
|
|
18
|
+
const { timeScheduleInfo, unlockDetail, ...rest } = user;
|
|
19
|
+
let scheduleInfo = {
|
|
20
|
+
permanent: true,
|
|
21
|
+
};
|
|
22
|
+
if (!timeScheduleInfo.permanent &&
|
|
23
|
+
timeScheduleInfo.scheduleDetails &&
|
|
24
|
+
timeScheduleInfo.scheduleDetails.length > 0) {
|
|
25
|
+
Object.assign(scheduleInfo, {
|
|
26
|
+
permanent: false,
|
|
27
|
+
effectiveTime: formatTimestampToMilliseconds(timeScheduleInfo.effectiveTime || 0),
|
|
28
|
+
expiredTime: formatTimestampToMilliseconds(timeScheduleInfo.expiredTime || 0),
|
|
29
|
+
scheduleDetails: {
|
|
30
|
+
repeat: !timeScheduleInfo.scheduleDetails[0].allDay,
|
|
31
|
+
effectiveTime: timeScheduleInfo.scheduleDetails[0].effectiveTime,
|
|
32
|
+
invalidTime: timeScheduleInfo.scheduleDetails[0].invalidTime,
|
|
33
|
+
timeZoneId: timeScheduleInfo.scheduleDetails[0].timeZoneId,
|
|
34
|
+
weeks: parseWeek(timeScheduleInfo.scheduleDetails[0].workingDay),
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
let unlockDetails = unlockDetail.map((detail) => {
|
|
39
|
+
const unlockList = detail.unlockList.map((unlockItem) => {
|
|
48
40
|
return {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
unlockId: +unlockItem.unlockId.split("-")[1],
|
|
42
|
+
unlockName: unlockItem.unlockName,
|
|
43
|
+
id: unlockItem.opModeId,
|
|
44
|
+
isBound: unlockItem.allocateFlag === 1,
|
|
45
|
+
photoUnlock: unlockItem.photoUnlock,
|
|
46
|
+
isSpecial: unlockItem.unlockAttr === 1,
|
|
54
47
|
};
|
|
55
48
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
const unlockMethodConfig = unlockMethodConfigs.find((item) => item.code === detail.dpCode);
|
|
50
|
+
return {
|
|
51
|
+
count: unlockList.length,
|
|
52
|
+
dpCode: detail.dpCode,
|
|
53
|
+
dpId: detail.dpId,
|
|
54
|
+
type: unlockMethodConfig.type,
|
|
55
|
+
unlockList,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
...rest,
|
|
60
|
+
timeScheduleInfo: scheduleInfo,
|
|
61
|
+
unlockDetails,
|
|
62
|
+
isAccountUser: user.userListType === "group_user",
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const concactUserList = (list, result) => {
|
|
66
|
+
return list.reduce((acc, item) => {
|
|
67
|
+
acc.push(handleUserDetail(item));
|
|
62
68
|
return acc;
|
|
63
69
|
}, result);
|
|
64
70
|
};
|
|
65
|
-
|
|
66
|
-
const { page = 1, pageSize = 10, keyword = "" } = params || {};
|
|
71
|
+
const getUserDpCodes = async () => {
|
|
67
72
|
const currentUser = await getCurrentUser();
|
|
68
73
|
const dps = [];
|
|
69
74
|
if (currentUser.allOpenDps) {
|
|
@@ -75,6 +80,11 @@ export const getUsers = async (params) => {
|
|
|
75
80
|
return acc;
|
|
76
81
|
}, dps);
|
|
77
82
|
}
|
|
83
|
+
return dps;
|
|
84
|
+
};
|
|
85
|
+
export const getUsers = async (params) => {
|
|
86
|
+
const { page = 1, pageSize = 10, keyword = "" } = params || {};
|
|
87
|
+
const dps = await getUserDpCodes();
|
|
78
88
|
const res = await getUserList({
|
|
79
89
|
dpCodes: dps.join(","),
|
|
80
90
|
devId: config.devInfo.devId,
|
|
@@ -95,18 +105,13 @@ export const getUsers = async (params) => {
|
|
|
95
105
|
};
|
|
96
106
|
};
|
|
97
107
|
export const getUserInfo = async (params) => {
|
|
98
|
-
const
|
|
108
|
+
const currentUser = await getCurrentUser();
|
|
109
|
+
const res = await getUserDetailQuery({
|
|
99
110
|
devId: config.devInfo.devId,
|
|
100
111
|
userId: params.userId,
|
|
112
|
+
dpIds: currentUser.allOpenDps,
|
|
101
113
|
});
|
|
102
|
-
|
|
103
|
-
keyword: user.nickName,
|
|
104
|
-
});
|
|
105
|
-
const res = data.list.find((item) => item.userId === params.userId);
|
|
106
|
-
if (res) {
|
|
107
|
-
return res;
|
|
108
|
-
}
|
|
109
|
-
throw getError(1048);
|
|
114
|
+
return handleUserDetail(res);
|
|
110
115
|
};
|
|
111
116
|
export const updateUserLimitTime = async (params) => {
|
|
112
117
|
const { userId, lockUserId, permanent, effective } = params;
|
|
@@ -134,52 +139,50 @@ export const updateUserLimitTime = async (params) => {
|
|
|
134
139
|
validNum: 0,
|
|
135
140
|
pwdLength: 0,
|
|
136
141
|
pwd: [],
|
|
137
|
-
validConfig:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
: effective.expiredDate
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
endMinute: permanent ? 0 : expiredTime % 60,
|
|
154
|
-
},
|
|
142
|
+
validConfig: permanent
|
|
143
|
+
? getPermanentSetting()
|
|
144
|
+
: {
|
|
145
|
+
startTime: effective.effectiveDate,
|
|
146
|
+
endTime: effective.expiredDate,
|
|
147
|
+
loop: loopType,
|
|
148
|
+
loopConfig: 0,
|
|
149
|
+
weeks: effective?.repeat !== "week" || effective?.weeks === undefined
|
|
150
|
+
? [0, 0, 0, 0, 0, 0, 0]
|
|
151
|
+
: effective.weeks,
|
|
152
|
+
days: [],
|
|
153
|
+
startHour: Math.floor(effectiveTime / 60),
|
|
154
|
+
startMinute: effectiveTime % 60,
|
|
155
|
+
endHour: Math.floor(expiredTime / 60),
|
|
156
|
+
endMinute: expiredTime % 60,
|
|
157
|
+
},
|
|
155
158
|
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (result.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
159
|
+
try {
|
|
160
|
+
const dpCode = config.supportBigData
|
|
161
|
+
? dpCodes.unlockMethodEditW
|
|
162
|
+
: dpCodes.unlockMethodEdit;
|
|
163
|
+
const res = (await publishDps({
|
|
164
|
+
[dpCode]: DpUtils.format(dpValue, (config.supportBigData ? updateMapBig : updateMap)),
|
|
165
|
+
}, {
|
|
166
|
+
checkReport: (dps) => {
|
|
167
|
+
if (typeof dps[dpCode] !== "undefined") {
|
|
168
|
+
const result = DpUtils.parse(dps[dpCode], (config.supportBigData
|
|
169
|
+
? reportUpdateMapBig
|
|
170
|
+
: reportUpdateMap));
|
|
171
|
+
if (result.type === 0) {
|
|
172
|
+
if (result.memberId === lockUserId) {
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
console.warn("An incorrect member id was returned");
|
|
177
|
+
}
|
|
173
178
|
}
|
|
174
179
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
try {
|
|
180
|
+
return false;
|
|
181
|
+
},
|
|
182
|
+
}));
|
|
183
|
+
if (res.status !== 255) {
|
|
184
|
+
throw getError(1011);
|
|
185
|
+
}
|
|
183
186
|
await updateUserTimeSchedule({
|
|
184
187
|
devId: config.devInfo.devId,
|
|
185
188
|
userId: userId,
|
|
@@ -241,11 +244,8 @@ export const openFamilyUserDetail = async (userId) => {
|
|
|
241
244
|
const url = `tuyaSmart://member_info?homeId=${homeId}&memberId=${userId}&role=${role}`;
|
|
242
245
|
ty.router({
|
|
243
246
|
url: url,
|
|
244
|
-
success: (d) => {
|
|
245
|
-
console.log("openFamilyUserDetail success");
|
|
246
|
-
},
|
|
247
247
|
fail: (e) => {
|
|
248
|
-
console.
|
|
248
|
+
console.error("openFamilyUserDetail fail", e);
|
|
249
249
|
},
|
|
250
250
|
});
|
|
251
251
|
return;
|
|
@@ -268,6 +268,17 @@ export const removeUser = async (userId) => {
|
|
|
268
268
|
if (!config.supportBigData) {
|
|
269
269
|
throw getError(1060);
|
|
270
270
|
}
|
|
271
|
+
const res = await getUserDetail({
|
|
272
|
+
devId: config.devInfo.devId,
|
|
273
|
+
userId,
|
|
274
|
+
});
|
|
275
|
+
if (isUseNearChannel()) {
|
|
276
|
+
return deleteUser({
|
|
277
|
+
userId,
|
|
278
|
+
lockUserId: res.lockUserId,
|
|
279
|
+
admin: res.userType === UserType.ADMIN || res.userType === UserType.OWNER,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
271
282
|
return removeNormalUser({
|
|
272
283
|
devId: config.devInfo.devId,
|
|
273
284
|
userId,
|
package/lib/utils/device.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const setDeviceProperty: (devId: string, code: string, value: str
|
|
|
5
5
|
export declare const publishDeviceDps: (params: {
|
|
6
6
|
deviceId: string;
|
|
7
7
|
dps: Record<string, boolean | number | string>;
|
|
8
|
+
pipelines?: number[];
|
|
8
9
|
}) => Promise<unknown>;
|
|
9
10
|
export declare const registerDevice: (devIds: string[]) => void;
|
|
10
11
|
export declare const registerBleStatus: (devId: string) => void;
|
package/lib/utils/device.js
CHANGED
package/lib/utils/errors.js
CHANGED
|
@@ -63,6 +63,9 @@ const errors = {
|
|
|
63
63
|
1062: "Device does not support active connection",
|
|
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
|
+
1065: "Cloud side has been deleted, but device side synchronization deletion failed",
|
|
67
|
+
1066: "Phone number cannot be empty",
|
|
68
|
+
1067: "Password limit reached within this period",
|
|
66
69
|
};
|
|
67
70
|
export const getError = (code, ...places) => {
|
|
68
71
|
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)
|
|
@@ -64,7 +65,7 @@ export const getPermanentSetting = () => {
|
|
|
64
65
|
const now = Math.floor(+new Date() / 1000);
|
|
65
66
|
return {
|
|
66
67
|
startTime: now,
|
|
67
|
-
endTime:
|
|
68
|
+
endTime: 0x72bc9b7f,
|
|
68
69
|
loop: LoopTypes.NONE,
|
|
69
70
|
loopConfig: 0,
|
|
70
71
|
weeks: [0, 0, 0, 0, 0, 0, 0],
|
|
@@ -258,18 +259,20 @@ onBackgroundFetchData(preFetchKeys, (res) => {
|
|
|
258
259
|
});
|
|
259
260
|
});
|
|
260
261
|
export const getDataWithPreFetch = async (key, apiCb) => {
|
|
261
|
-
if (
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
result
|
|
268
|
-
|
|
269
|
-
|
|
262
|
+
if (config.preFetch) {
|
|
263
|
+
if (preFetchData[key]) {
|
|
264
|
+
return preFetchData[key];
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
const result = await getBackgroundFetchData([key]);
|
|
268
|
+
if (result &&
|
|
269
|
+
result.fetchedData[key] &&
|
|
270
|
+
result.fetchedData[key].fetchedData) {
|
|
271
|
+
return result.fetchedData[key].fetchedData;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
270
275
|
}
|
|
271
|
-
}
|
|
272
|
-
catch {
|
|
273
276
|
}
|
|
274
277
|
return apiCb();
|
|
275
278
|
};
|
package/lib/utils/publishDps.js
CHANGED
|
@@ -7,7 +7,7 @@ import { getError } from "./errors";
|
|
|
7
7
|
export const publishDpsOnly = async (dpData) => {
|
|
8
8
|
const { devInfo, idsByCode } = config;
|
|
9
9
|
const option = {};
|
|
10
|
-
if (config.
|
|
10
|
+
if (config.deviceStatus.type === "offline") {
|
|
11
11
|
throw getError(1001);
|
|
12
12
|
}
|
|
13
13
|
if (isOnlineByType(config.onlineType, 2)) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { removeUser } from "../api/user";
|
|
2
|
+
import dpCodes from "../config/dp-code";
|
|
3
|
+
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
4
|
+
import { remove as removeBigMap, reportRemove as reportRemoveBigMap, } from "../config/dp-map/unlock-method-big";
|
|
5
|
+
import { remove as removeMap, reportRemove as reportRemoveMap, } from "../config/dp-map/unlock-method";
|
|
6
|
+
import { publishDps } from "../utils/publishDps";
|
|
7
|
+
import config from "../config";
|
|
8
|
+
export const deleteUser = async (data) => {
|
|
9
|
+
const { admin, lockUserId, userId } = data;
|
|
10
|
+
const dpCode = config.supportBigData
|
|
11
|
+
? dpCodes.unlockMethodDelW
|
|
12
|
+
: dpCodes.unlockMethodDel;
|
|
13
|
+
const dpData = {
|
|
14
|
+
type: 0,
|
|
15
|
+
stage: 0,
|
|
16
|
+
admin: !!admin,
|
|
17
|
+
memberId: lockUserId,
|
|
18
|
+
unlockId: config.supportBigData ? 0xffff : 0xff,
|
|
19
|
+
category: 0,
|
|
20
|
+
};
|
|
21
|
+
await publishDps({
|
|
22
|
+
[dpCode]: dpUtils.format(dpData, (config.supportBigData ? removeBigMap : removeMap)),
|
|
23
|
+
}, {
|
|
24
|
+
checkReport: (dps) => {
|
|
25
|
+
if (dps[dpCode]) {
|
|
26
|
+
const dpValue = dpUtils.parse(dps[dpCode], (config.supportBigData
|
|
27
|
+
? reportRemoveBigMap
|
|
28
|
+
: reportRemoveMap));
|
|
29
|
+
if (dpValue.type === 0 &&
|
|
30
|
+
dpValue.status == 255 &&
|
|
31
|
+
dpValue.memberId === lockUserId) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
await removeUser(config.devInfo.devId, userId);
|
|
39
|
+
};
|
package/package.json
CHANGED
package/lib/dp-interface.d.ts
DELETED
package/lib/dp-interface.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { fetchSyncUnlockMethodInfo } from "../api/lock";
|
|
2
|
-
import config from "../config";
|
|
3
|
-
import dpCodes from "../config/dp-code";
|
|
4
|
-
import { getCurrentUser } from "../state";
|
|
5
|
-
import { publishDps } from "../utils/publishDps";
|
|
6
|
-
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
7
|
-
import { reportSync as reportSyncMap } from "../config/dp-map/unlock-method";
|
|
8
|
-
import { reportSync as reportSyncBigMap } from "../config/dp-map/unlock-method-big";
|
|
9
|
-
let syncUnlockMethodFirst = true;
|
|
10
|
-
export const syncUnlockMethod = async () => {
|
|
11
|
-
syncUnlockMethodFirst = false;
|
|
12
|
-
const { allOpenDps = "" } = await getCurrentUser();
|
|
13
|
-
const { ins = "", distributed = false } = await fetchSyncUnlockMethodInfo({
|
|
14
|
-
devId: config.devInfo.devId,
|
|
15
|
-
dpIds: allOpenDps.split(","),
|
|
16
|
-
});
|
|
17
|
-
if (ins && distributed) {
|
|
18
|
-
const dpCode = config.supportBigData
|
|
19
|
-
? dpCodes.synchMethodW
|
|
20
|
-
: dpCodes.synchMethod;
|
|
21
|
-
await publishDps({ [dpCode]: ins }, {
|
|
22
|
-
checkReport: (dpData) => {
|
|
23
|
-
if (typeof dpData[dpCode] !== "undefined") {
|
|
24
|
-
const result = dpUtils.parse(dpData[dpCode], config.supportBigData ? reportSyncBigMap : reportSyncMap);
|
|
25
|
-
if (result.stage === 1) {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
export const autoSyncUnlockMethod = async () => {
|
|
35
|
-
try {
|
|
36
|
-
if (syncUnlockMethodFirst) {
|
|
37
|
-
await syncUnlockMethod();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
}
|
|
42
|
-
};
|