@ray-js/lock-sdk 1.2.1-beta.2 → 1.2.1-beta.4

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.
@@ -37,4 +37,15 @@ export interface getAlbumDateListResult {
37
37
  dateList: string[];
38
38
  }
39
39
  export declare const getAlbumDateList: (devId: string) => Promise<getAlbumDateListResult>;
40
+ interface GetDeviceCurrentMeidaConfigResult {
41
+ audioAttributes: {
42
+ callMode: Array<1 | 2>;
43
+ hardwareCapability: Array<1 | 2>;
44
+ };
45
+ maxZoomInTimes: number;
46
+ skill: string;
47
+ vedioClarity: number;
48
+ vedioClaritys: number[];
49
+ }
50
+ export declare const getDeviceCurrentMeidaConfig: (devId: string) => Promise<GetDeviceCurrentMeidaConfigResult>;
40
51
  export {};
package/lib/api/video.js CHANGED
@@ -60,3 +60,13 @@ export const getAlbumDateList = (devId) => {
60
60
  },
61
61
  });
62
62
  };
63
+ export const getDeviceCurrentMeidaConfig = (devId) => {
64
+ return requestApi({
65
+ logName: "getDeviceCurrentMeidaConfig",
66
+ api: "m.ipc.device.ability.get",
67
+ version: "1.0",
68
+ data: {
69
+ devId,
70
+ },
71
+ });
72
+ };
@@ -4,5 +4,4 @@ export declare function offOfflineDpsUpdate(callback: (dps: OfflineDps) => void)
4
4
  export declare function publishOfflineDps(dps: Record<string, DpValue>): Promise<void>;
5
5
  export declare function getOfflineDps(isForce?: boolean): Promise<OfflineDps>;
6
6
  export declare function getOfflineDpCache(code: string): import("../../../interface").OfflineDpInfo | undefined;
7
- export declare function checkOfflineDpUpdate(dps: Record<string, DpValue>, isForce?: boolean): Promise<void>;
8
7
  export declare function isOfflineDpSyncing(code: string): boolean;
@@ -1,5 +1,5 @@
1
1
  import { resolveRuntimeFromExportThis } from "../bootstrap/resolve-runtime-from-export-this";
2
- import { checkOfflineDpUpdateForRuntime, publishOfflineDpsForRuntime, getOfflineDpsForRuntime, getOfflineDpCacheForRuntime, onOfflineDpsUpdateForRuntime, offOfflineDpsUpdateForRuntime, } from "../../../feature/offline-dps";
2
+ import { publishOfflineDpsForRuntime, getOfflineDpsForRuntime, getOfflineDpCacheForRuntime, onOfflineDpsUpdateForRuntime, offOfflineDpsUpdateForRuntime, } from "../../../feature/offline-dps";
3
3
  export function onOfflineDpsUpdate(callback) {
4
4
  onOfflineDpsUpdateForRuntime(resolveRuntimeFromExportThis(this), callback);
5
5
  }
@@ -15,9 +15,6 @@ export async function getOfflineDps(isForce) {
15
15
  export function getOfflineDpCache(code) {
16
16
  return getOfflineDpCacheForRuntime(resolveRuntimeFromExportThis(this), code);
17
17
  }
18
- export async function checkOfflineDpUpdate(dps, isForce) {
19
- return checkOfflineDpUpdateForRuntime(resolveRuntimeFromExportThis(this), dps, isForce);
20
- }
21
18
  export function isOfflineDpSyncing(code) {
22
19
  const rt = resolveRuntimeFromExportThis(this);
23
20
  if (!rt.config.supportOfflineDps) {
@@ -76,6 +76,8 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
76
76
  "tyabipd4hh",
77
77
  "tyabin4u5v",
78
78
  "visual_door_lock_cloud_store",
79
+ "tyabixkep7",
80
+ "tyabig3wt9",
79
81
  ])),
80
82
  getWithLocalCache(rt, "deviceAdvancedAbility", () => getDeviceAdvancedAbility(devId)),
81
83
  ipc.getTTTAbilityKeyList("isSupportedVRMode"),
@@ -83,6 +85,10 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
83
85
  const productAbilities = productAbilitiesRes.status === "fulfilled" ? productAbilitiesRes.value : [];
84
86
  const tttAbList = tttList.status === "fulfilled" ? tttList.value.abilityList : [];
85
87
  const deviceAdvanceAbilityCache = {
88
+ videoConfig: {
89
+ isLowResolution: false,
90
+ isHighResolution: false,
91
+ },
86
92
  cloudStorage: {
87
93
  support: false,
88
94
  },
@@ -122,6 +128,14 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
122
128
  if (item.isOpen) {
123
129
  const data = item.extConfig ? JSON.parse(item.extConfig) : {};
124
130
  switch (item.abilityCode) {
131
+ case "tyabixkep7": {
132
+ deviceAdvanceAbilityCache.videoConfig.isHighResolution = true;
133
+ break;
134
+ }
135
+ case "tyabig3wt9": {
136
+ deviceAdvanceAbilityCache.videoConfig.isLowResolution = true;
137
+ break;
138
+ }
125
139
  case "visual_door_lock_cloud_store":
126
140
  deviceAdvanceAbilityCache.cloudStorage.support = true;
127
141
  break;
@@ -18,6 +18,7 @@ import { ipc, yuChannelSyncSingleSync } from "../../platform";
18
18
  import { sdkLog } from "../../utils/sdk-log";
19
19
  import { ProductCommunicationType, RotateType } from "../../constant";
20
20
  import { isHarmony } from "../../utils";
21
+ import { getError } from "src/utils/errors";
21
22
  export const initState = async (runtime) => {
22
23
  const { devInfo: { dps, devId, yuNetState }, dpSchema, } = runtime.config;
23
24
  const startedAt = Date.now();
@@ -74,6 +75,40 @@ export const initState = async (runtime) => {
74
75
  if (userInfoResult.status === "rejected") {
75
76
  throw userInfoResult.reason;
76
77
  }
78
+ if (advanceAbilities.status === "fulfilled") {
79
+ const abilities = advanceAbilities.value;
80
+ sdkLog("debug", "initState", "advancedAbilitiesFetched", {
81
+ devId,
82
+ data: {
83
+ yuChannelSupport: abilities.yuChannel.support,
84
+ yuChannelValue: abilities.yuChannel.value,
85
+ },
86
+ });
87
+ if (isSupportVideo &&
88
+ !abilities.videoConfig.isHighResolution &&
89
+ !abilities.videoConfig.isLowResolution) {
90
+ throw getError(1107);
91
+ }
92
+ if (abilities.yuChannel.support) {
93
+ if (abilities.yuChannel.value === 1) {
94
+ sdkLog("debug", "initState", "yuChannelSync", {
95
+ devId,
96
+ data: { reason: "abilityEnabled" },
97
+ });
98
+ yuChannelSyncSingleSync(devId);
99
+ }
100
+ else if (yuNetState === 1) {
101
+ sdkLog("debug", "initState", "yuChannelSync", {
102
+ devId,
103
+ data: { reason: "yuNetState" },
104
+ });
105
+ yuChannelSyncSingleSync(devId);
106
+ }
107
+ }
108
+ }
109
+ else {
110
+ throw getError(1108);
111
+ }
77
112
  if (isSupportVideo) {
78
113
  const isSEI = runtime.config.capabilities?.rotateType === RotateType.SEI;
79
114
  if (rotateInfo.status === "fulfilled") {
@@ -128,32 +163,6 @@ export const initState = async (runtime) => {
128
163
  videoAngle: runtime.config.videoAngle,
129
164
  },
130
165
  });
131
- if (advanceAbilities.status === "fulfilled") {
132
- const abilities = advanceAbilities.value;
133
- sdkLog("debug", "initState", "advancedAbilitiesFetched", {
134
- devId,
135
- data: {
136
- yuChannelSupport: abilities.yuChannel.support,
137
- yuChannelValue: abilities.yuChannel.value,
138
- },
139
- });
140
- if (abilities.yuChannel.support) {
141
- if (abilities.yuChannel.value === 1) {
142
- sdkLog("debug", "initState", "yuChannelSync", {
143
- devId,
144
- data: { reason: "abilityEnabled" },
145
- });
146
- yuChannelSyncSingleSync(devId);
147
- }
148
- else if (yuNetState === 1) {
149
- sdkLog("debug", "initState", "yuChannelSync", {
150
- devId,
151
- data: { reason: "yuNetState" },
152
- });
153
- yuChannelSyncSingleSync(devId);
154
- }
155
- }
156
- }
157
166
  syncRemoteSerectKey(runtime);
158
167
  checkOfflineDpUpdateForRuntime(runtime, {}, true).then(() => {
159
168
  sdkLog("debug", "initState", "offlineDpCheckDone", { devId });
@@ -1,7 +1,7 @@
1
1
  import dpUtils from "@ray-js/tuya-dp-transform";
2
2
  import { createUnlockMethod } from "../../../api/lock";
3
3
  import { parallelOnlyForRuntime } from "../../utils";
4
- import { formatCloudUnlockId, sleep } from "../../../utils";
4
+ import { sleep } from "../../../utils";
5
5
  import { getError } from "../../../utils/errors";
6
6
  import { publishDpsForRuntime } from "../../dp/publish-dps";
7
7
  import emitter from "../../../utils/event";
@@ -207,7 +207,7 @@ const handleAddReport = async (dps) => {
207
207
  const res = await createUnlockMethod({
208
208
  devId: cfg.devInfo.devId,
209
209
  userId: addUnlockMethodData.userId,
210
- unlockId: formatCloudUnlockId(addUnlockMethodData.unlockDpId, result.unlockId),
210
+ unlockId: `${addUnlockMethodData.unlockDpId}-${result.unlockId}`,
211
211
  unlockName: "",
212
212
  unlockAttr: 0,
213
213
  });
@@ -1,7 +1,7 @@
1
1
  import dpUtils from "@ray-js/tuya-dp-transform";
2
2
  import { createUnlockMethod } from "../../../api/lock";
3
3
  import { encrypt } from "../../../platform/device";
4
- import { formatCloudUnlockId, sleep } from "../../../utils";
4
+ import { sleep } from "../../../utils";
5
5
  import { getError, handleCloudError } from "../../../utils/errors";
6
6
  import { publishDpsForRuntime } from "../../dp/publish-dps";
7
7
  import { getUnlockMethodBase } from "./internal/base";
@@ -76,7 +76,7 @@ export async function addPasswordForRuntime(rt, params) {
76
76
  const result = await createUnlockMethod({
77
77
  devId: devId,
78
78
  userId: params.userId,
79
- unlockId: formatCloudUnlockId(dpId, res.unlockId),
79
+ unlockId: `${dpId}-${res.unlockId}`,
80
80
  unlockName: params.name,
81
81
  unlockDetail: aesPwd,
82
82
  ...specialInfo,
@@ -26,7 +26,7 @@ export async function updateUnlockMethodForRuntime(rt, params) {
26
26
  await editUnlockMethod({
27
27
  devId: cfg.devInfo.devId,
28
28
  opModeId: params.id,
29
- unlockName: params.name,
29
+ unlockName: params.name || detail.unlockName,
30
30
  ...specialInfo,
31
31
  });
32
32
  sdkLog("info", "unlockMethod", "updateSuccess", {
@@ -359,6 +359,10 @@ export interface AlbumMessage extends MediaInfo {
359
359
  }
360
360
  export type VRModeType = "original" | "VR" | "horizontal" | "vertical";
361
361
  export interface DeviceAdvancedAbility {
362
+ videoConfig: {
363
+ isLowResolution: boolean;
364
+ isHighResolution: boolean;
365
+ };
362
366
  cloudStorage: {
363
367
  support: boolean;
364
368
  };
@@ -106,6 +106,8 @@ const errors = {
106
106
  1104: "Failed to switch cameras",
107
107
  1105: "Camera switching is not supported",
108
108
  1106: "No validity configuration data",
109
+ 1107: "Invalid device, please re-authorize",
110
+ 1108: "Failed to get configuration",
109
111
  };
110
112
  export const getError = (code, ...places) => {
111
113
  if (errors[code]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.2.1-beta.2",
3
+ "version": "1.2.1-beta.4",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"