@ray-js/lock-sdk 1.2.1-beta.9 → 1.2.2-beta.0

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/log.d.ts CHANGED
@@ -120,6 +120,7 @@ export interface LockLogListItem {
120
120
  unionUnlockInfo?: UnionUnlockInfo[];
121
121
  mediaInfoList?: MediaInfoRecord[];
122
122
  localOperateRecordInfo?: LocalOperateRecordInfo;
123
+ localOperateRecord?: LocalOperateRecordInfo;
123
124
  data?: boolean | number | string;
124
125
  dpId: number;
125
126
  matterRecordInfo?: {
package/lib/constant.d.ts CHANGED
@@ -61,7 +61,8 @@ export declare enum LocalOperateUserType {
61
61
  SUPER_ADMIN = 0,
62
62
  ADMIN = 1,
63
63
  SPECIAL_USER = 2,
64
- NORMAL_USER = 3
64
+ NORMAL_USER = 3,
65
+ UNKNOW = 255
65
66
  }
66
67
  export declare enum LocalOperateCategory {
67
68
  ADD_UNLOCK_METHOD = 0,
package/lib/constant.js CHANGED
@@ -71,6 +71,7 @@ export var LocalOperateUserType;
71
71
  LocalOperateUserType[LocalOperateUserType["ADMIN"] = 1] = "ADMIN";
72
72
  LocalOperateUserType[LocalOperateUserType["SPECIAL_USER"] = 2] = "SPECIAL_USER";
73
73
  LocalOperateUserType[LocalOperateUserType["NORMAL_USER"] = 3] = "NORMAL_USER";
74
+ LocalOperateUserType[LocalOperateUserType["UNKNOW"] = 255] = "UNKNOW";
74
75
  })(LocalOperateUserType || (LocalOperateUserType = {}));
75
76
  export var LocalOperateCategory;
76
77
  (function (LocalOperateCategory) {
@@ -20,3 +20,7 @@ export interface AwakeDeviceOptions {
20
20
  timeout?: number;
21
21
  }
22
22
  export declare function awakeDevice(options?: AwakeDeviceOptions): Promise<true>;
23
+ interface DisconnectDeviceOptions {
24
+ disconnetBle?: boolean;
25
+ }
26
+ export declare function disconnectDevice(options?: DisconnectDeviceOptions): Promise<void>;
@@ -2,7 +2,7 @@ import { resolveRuntimeFromExportThis } from "../bootstrap/resolve-runtime-from-
2
2
  import { openSceneForRuntime } from "../../../feature/misc/open-scene";
3
3
  import { isSupportBleControlForRuntime } from "../../../feature/misc/ble-control";
4
4
  import { getDpPeriodTimeForRuntime, updateDpPeriodTimeForRuntime, } from "../../../feature/misc/dp-period";
5
- import { awakeDeviceForRuntime, connectDeviceForRuntime, } from "../../../feature/misc/connect-device";
5
+ import { awakeDeviceForRuntime, connectDeviceForRuntime, disconnectDeviceForRuntime, } from "../../../feature/misc/connect-device";
6
6
  import { validatePwdComplexityForRuntime } from "../../../feature/misc/validate-pwd";
7
7
  import { gotoServiceForRuntime, } from "../../../feature/service/goto-service";
8
8
  export { parseDpPeriodTime } from "../../../feature/misc/dp-period";
@@ -31,3 +31,6 @@ export async function validatePwdComplexity(password) {
31
31
  export async function awakeDevice(options) {
32
32
  return awakeDeviceForRuntime(resolveRuntimeFromExportThis(this), options);
33
33
  }
34
+ export async function disconnectDevice(options) {
35
+ return disconnectDeviceForRuntime(resolveRuntimeFromExportThis(this), options);
36
+ }
@@ -36,6 +36,9 @@ function handleLockLogs(list, cfg) {
36
36
  catch {
37
37
  }
38
38
  }
39
+ if (type === "setting" && item.logType === "lock_local_record") {
40
+ type = "local_operation";
41
+ }
39
42
  let userName = item.userName;
40
43
  let unlockName = item.unlockName;
41
44
  let tempPwdInfo = undefined;
@@ -167,7 +170,7 @@ function handleLockLogs(list, cfg) {
167
170
  position: item.position,
168
171
  };
169
172
  }),
170
- localRecord: handleLocalOperation(item.localOperateRecordInfo, itemData),
173
+ localRecord: handleLocalOperation(item.localOperateRecordInfo || item.localOperateRecord, itemData),
171
174
  unionUnlockInfo: item.unionUnlockInfo?.map((item1) => {
172
175
  return {
173
176
  userId: item1.userId,
@@ -299,7 +302,7 @@ export async function getLogsForRuntime(rt, params) {
299
302
  dpCode,
300
303
  userName,
301
304
  unlockName,
302
- mediaInfo: record.mediaInfoList?.map?.(item => {
305
+ mediaInfo: record.mediaInfoList?.map?.((item) => {
303
306
  return {
304
307
  mediaPath: item.mediaPath,
305
308
  fileKey: item.fileKey,
@@ -391,7 +394,7 @@ export async function getAlarmsForRuntime(rt, params) {
391
394
  dpCode,
392
395
  userName: record.userName,
393
396
  unlockName: record.unlockName,
394
- mediaInfo: record.mediaInfoList?.map?.(item => {
397
+ mediaInfo: record.mediaInfoList?.map?.((item) => {
395
398
  return {
396
399
  mediaPath: item.mediaPath,
397
400
  fileKey: item.fileKey,
@@ -6,6 +6,7 @@ import { getWithLocalCache } from "../storage/swr-cache";
6
6
  import { getVideoResolutionMark } from "../../api/video";
7
7
  import dpCodes from "../../config/dp-code";
8
8
  import { hasDpForRuntime } from "../dp/has-dp";
9
+ import { sdkLog } from "../../utils/sdk-log";
9
10
  export const hasCapabilityForRuntime = (runtime, capability) => runtime.config.communication.includes(capability);
10
11
  export const isBlePureDeviceForRuntime = (rt) => hasCapabilityForRuntime(rt, ProductCommunicationType.BLUETOOTH) &&
11
12
  rt.config.communication.length === 1;
@@ -91,6 +92,10 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
91
92
  ]);
92
93
  const productAbilities = productAbilitiesRes.status === "fulfilled" ? productAbilitiesRes.value : [];
93
94
  const tttAbList = tttList.status === "fulfilled" ? tttList.value.abilityList : [];
95
+ sdkLog("info", "advancedAbilities", "supportVR", {
96
+ devId,
97
+ data: { tttAbList },
98
+ });
94
99
  const videoMark = videoMarkRes.status === "fulfilled"
95
100
  ? videoMarkRes.value
96
101
  : { capability: [], cloudCapability: [] };
@@ -221,7 +226,11 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
221
226
  }
222
227
  }
223
228
  catch (error) {
224
- console.warn(`setting [${item.abilityCode}] config error`, error);
229
+ sdkLog("error", "advancedAbilities", "parseCode Error", {
230
+ devId,
231
+ data: { code: item.abilityCode },
232
+ error,
233
+ });
225
234
  }
226
235
  });
227
236
  if (deviceAdvancedAbilityRes.status === "fulfilled") {
@@ -3,3 +3,6 @@ export declare function connectDeviceForRuntime(rt: LockDeviceRuntime, timeout?:
3
3
  export declare const awakeDeviceForRuntime: (runtime: LockDeviceRuntime, options?: {
4
4
  timeout?: number;
5
5
  }) => Promise<true>;
6
+ export declare const disconnectDeviceForRuntime: (rt: LockDeviceRuntime, options?: {
7
+ disconnetBle?: boolean;
8
+ }) => Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import dpCodes from "../../config/dp-code";
2
- import { connectBLEDevice, getBLEOnlineState, onBleChange, onOnlineChange, offBleChange, offOnlineChange, yuChannelSyncSingleSync, } from "../../platform/device";
2
+ import { connectBLEDevice, getBLEOnlineState, onBleChange, onOnlineChange, offBleChange, offOnlineChange, yuChannelSyncSingleSync, disconnectBLEDevice, } from "../../platform/device";
3
3
  import { DPCHANGE } from "../../utils/constant";
4
4
  import emitter from "../../utils/event";
5
5
  import { getError } from "../../utils/errors";
@@ -85,7 +85,7 @@ export async function connectDeviceForRuntime(rt, timeout) {
85
85
  const cfg = rt.config;
86
86
  const devId = cfg.devInfo.devId;
87
87
  const deviceStatus = getDeviceStatusForRuntime(rt);
88
- const hasWirelessAwakeDp = !!cfg.dpSchema[wirelessAwake];
88
+ const hasWirelessAwakeDp = hasDpForRuntime(rt, wirelessAwake) && !cfg.notSupportWake;
89
89
  const startedAt = Date.now();
90
90
  sdkLog("info", "connectDevice", "start", {
91
91
  devId,
@@ -148,7 +148,7 @@ export const awakeDeviceForRuntime = (runtime, options) => {
148
148
  const devId = cfg.devInfo.devId;
149
149
  const timeout = options?.timeout || 15000;
150
150
  const startedAt = Date.now();
151
- const hasWirelessAwake = hasDpForRuntime(runtime, wirelessAwake);
151
+ const hasWirelessAwake = hasDpForRuntime(runtime, wirelessAwake) && !cfg.notSupportWake;
152
152
  sdkLog("info", "connectDevice", "awakeStart", {
153
153
  devId,
154
154
  data: { timeout, hasWirelessAwake },
@@ -187,6 +187,7 @@ export const awakeDeviceForRuntime = (runtime, options) => {
187
187
  devId,
188
188
  duration: Date.now() - startedAt,
189
189
  });
190
+ clearTimeout(timer);
190
191
  return resolve(true);
191
192
  }
192
193
  const connecting = await ipc.isConnecting(devId);
@@ -214,3 +215,30 @@ export const awakeDeviceForRuntime = (runtime, options) => {
214
215
  run();
215
216
  });
216
217
  };
218
+ export const disconnectDeviceForRuntime = async (rt, options) => {
219
+ const cfg = rt.config;
220
+ const devId = cfg.devInfo.devId;
221
+ const startedAt = Date.now();
222
+ sdkLog("info", "disconnectDevice", "start", {
223
+ devId,
224
+ });
225
+ try {
226
+ const deviceStatus = getDeviceStatusForRuntime(rt);
227
+ await ipc.disConnect(devId);
228
+ if (deviceStatus.onlineTypes.includes("ble") && !!options?.disconnetBle) {
229
+ await disconnectBLEDevice(devId);
230
+ }
231
+ sdkLog("info", "disconnectDevice", "success", {
232
+ devId,
233
+ duration: Date.now() - startedAt,
234
+ });
235
+ }
236
+ catch (e) {
237
+ sdkLog("error", "disconnectDevice", "Fail", {
238
+ devId,
239
+ duration: Date.now() - startedAt,
240
+ error: e,
241
+ });
242
+ throw e;
243
+ }
244
+ };
@@ -17,7 +17,7 @@ import { fetchDeviceProperties } from "./remote-permissions";
17
17
  import { ipc, yuChannelSyncSingleSync } from "../../platform";
18
18
  import { sdkLog } from "../../utils/sdk-log";
19
19
  import { ProductCommunicationType, RotateType } from "../../constant";
20
- import { isHarmony } from "../../utils";
20
+ import { isHarmony, isVirtualDevice } from "../../utils";
21
21
  import { getError } from "../../utils/errors";
22
22
  export const initState = async (runtime) => {
23
23
  const { devInfo: { dps, devId, yuNetState }, dpSchema, } = runtime.config;
@@ -85,6 +85,7 @@ export const initState = async (runtime) => {
85
85
  },
86
86
  });
87
87
  if (isSupportVideo &&
88
+ !isVirtualDevice(devId) &&
88
89
  !abilities.videoConfig.isHighResolution &&
89
90
  !abilities.videoConfig.isLowResolution) {
90
91
  throw getError(1107);
@@ -173,6 +173,7 @@ export declare const navigateTo: (params: ParamType<typeof ty.navigateTo>) => vo
173
173
  export declare const checkShowMatterMutilpleShare: (deviceId: string) => Promise<unknown>;
174
174
  export declare const getBLEOnlineState: (deviceId: string) => Promise<boolean>;
175
175
  export declare const connectBLEDevice: (deviceId: string) => Promise<void>;
176
+ export declare const disconnectBLEDevice: (deviceId: string) => Promise<void>;
176
177
  export interface BLEFileTransferParams {
177
178
  deviceId: string;
178
179
  fileId: number;
@@ -365,6 +365,15 @@ export const connectBLEDevice = (deviceId) => {
365
365
  });
366
366
  });
367
367
  };
368
+ export const disconnectBLEDevice = (deviceId) => {
369
+ return new Promise((resolve, reject) => {
370
+ ty.device.disconnectBLEDevice({
371
+ deviceId,
372
+ success: () => resolve(),
373
+ fail: reject,
374
+ });
375
+ });
376
+ };
368
377
  export const postBLEFileTransfer = (params) => {
369
378
  return new Promise((resolve, reject) => {
370
379
  const device = ty.device;
@@ -450,10 +459,10 @@ export const offAppShow = (cb) => {
450
459
  ty.offAppShow(cb);
451
460
  };
452
461
  export const onAppHide = (cb) => {
453
- ty.onAppShow(cb);
462
+ ty.onAppHide(cb);
454
463
  };
455
464
  export const offAppHide = (cb) => {
456
- ty.offAppShow(cb);
465
+ ty.offAppHide(cb);
457
466
  };
458
467
  export const trackEvent = (event, data) => {
459
468
  ty.event({
@@ -6,6 +6,7 @@ declare const _default: {
6
6
  isConnecting: (deviceId: string) => Promise<{
7
7
  isConnecting: boolean;
8
8
  }>;
9
+ disConnect: (deviceId: string) => Promise<unknown>;
9
10
  connect: (deviceId: string) => Promise<unknown>;
10
11
  getCurrentSupportedTalkMode: (deviceId: string) => Promise<{
11
12
  talkbackMode: number;
@@ -18,6 +18,11 @@ const connect = (deviceId) => {
18
18
  ty.ipc.connect({ deviceId, success: resolve, fail: reject });
19
19
  });
20
20
  };
21
+ const disConnect = (deviceId) => {
22
+ return new Promise((resolve, reject) => {
23
+ ty.ipc.disConnect({ deviceId, success: resolve, fail: reject });
24
+ });
25
+ };
21
26
  const getCurrentSupportedTalkMode = (deviceId) => {
22
27
  if (ty.ipc.getCurrentSupportedTalkMode) {
23
28
  return new Promise((resolve, reject) => {
@@ -47,6 +52,7 @@ export default {
47
52
  wakeUpDoorBell,
48
53
  isConnected,
49
54
  isConnecting,
55
+ disConnect,
50
56
  connect,
51
57
  getCurrentSupportedTalkMode,
52
58
  getTTTAbilityKeyList,
@@ -158,3 +158,4 @@ export declare const getAppUser: () => {
158
158
  isTemporaryUser: boolean;
159
159
  } | null;
160
160
  export declare const isHarmony: () => boolean;
161
+ export declare const isVirtualDevice: (devId: string) => boolean;
@@ -207,3 +207,4 @@ getAppUserAsync().catch(() => {
207
207
  export const isHarmony = () => {
208
208
  return getSystemInfo().platform === "harmony";
209
209
  };
210
+ export const isVirtualDevice = (devId) => /^vdevo\d+$/.test(devId);
@@ -7,7 +7,7 @@ const levelWeights = {
7
7
  trace: 5,
8
8
  };
9
9
  let config = {
10
- level: "warn",
10
+ level: "info",
11
11
  console: false,
12
12
  };
13
13
  const sensitiveKeyPattern = /password|pwd|token|key|secret|ins|devUnlockId|raw|dpValue/i;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.2.1-beta.9",
3
+ "version": "1.2.2-beta.0",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"