@ray-js/api 1.6.0-beta.6 → 1.6.0-beta.8

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.
@@ -84,4 +84,24 @@ export interface GetRemoteLocalRelationResponse {
84
84
  * @returns
85
85
  */
86
86
  declare const getRemoteLocalRelation: (params: GetRemoteLocalRelationParams) => Promise<GetRemoteLocalRelationResponse>;
87
- export { getDpsInfos, updateDpName, getGroupDpsInfos, updateGroupDpName, getWeatherQuality, getWeathers, saveCustomizePosition, getCustomizePosition, getDevProperty, saveDevProperty, getRemoteLocalRelation, };
87
+ declare enum BizType {
88
+ Device = 0,
89
+ Group = 1
90
+ }
91
+ type GetLightHighPowerParams = {
92
+ bizId: string;
93
+ bizType: BizType;
94
+ abilityCodes: string;
95
+ };
96
+ type GetLightHighPowerResponse = {
97
+ abilityCode: string;
98
+ buyableForCustomer?: boolean;
99
+ vasEnabled: boolean;
100
+ }[] | [];
101
+ /**
102
+ * 判断当前设备是否支持高级能力 @ray-js/ray^1.5.7 新增
103
+ * @param params { devId: string, type: number }
104
+ * @returns
105
+ */
106
+ declare const getLightHighPower: (params: GetLightHighPowerParams) => Promise<GetLightHighPowerResponse>;
107
+ export { getDpsInfos, updateDpName, getGroupDpsInfos, updateGroupDpName, getWeatherQuality, getWeathers, saveCustomizePosition, getCustomizePosition, getDevProperty, saveDevProperty, getRemoteLocalRelation, getLightHighPower, };
@@ -148,4 +148,21 @@ const getRemoteLocalRelation = params => {
148
148
  version: '1.0'
149
149
  });
150
150
  };
151
- export { getDpsInfos, updateDpName, getGroupDpsInfos, updateGroupDpName, getWeatherQuality, getWeathers, saveCustomizePosition, getCustomizePosition, getDevProperty, saveDevProperty, getRemoteLocalRelation };
151
+ var BizType = /*#__PURE__*/function (BizType) {
152
+ BizType[BizType["Device"] = 0] = "Device";
153
+ BizType[BizType["Group"] = 1] = "Group";
154
+ return BizType;
155
+ }(BizType || {});
156
+ /**
157
+ * 判断当前设备是否支持高级能力 @ray-js/ray^1.5.7 新增
158
+ * @param params { devId: string, type: number }
159
+ * @returns
160
+ */
161
+ const getLightHighPower = params => {
162
+ return requestCloud({
163
+ api: "".concat(THING, ".m.light.high.power.get"),
164
+ data: params,
165
+ version: '1.2'
166
+ });
167
+ };
168
+ export { getDpsInfos, updateDpName, getGroupDpsInfos, updateGroupDpName, getWeatherQuality, getWeathers, saveCustomizePosition, getCustomizePosition, getDevProperty, saveDevProperty, getRemoteLocalRelation, getLightHighPower };
@@ -1,3 +1,11 @@
1
+ /**
2
+ * 与面板/设备建立绑定关系,通常为设备ID、DP点、群组、规则,dpId#value等
3
+ */
4
+ type AssociativeEntityId = string;
5
+ /**
6
+ * 当associativeEntityId不足以区分情况下使用,通常可关联设备、DP值、群组、规则等
7
+ */
8
+ type AssociativeEntityValue = string;
1
9
  export interface Scene {
2
10
  dpId: number;
3
11
  bindType: number;
@@ -322,36 +330,117 @@ export interface IGetAstronomicalList {
322
330
  bizId: string;
323
331
  }
324
332
  export interface IGetAstronomicalListResponse {
325
- categoryStatus: number;
326
- id: string;
327
- category: string;
328
- timers: Array<{
329
- status: number;
330
- loops: string;
331
- time: string;
332
- id: number;
333
- isAppPush: boolean;
334
- dps: string;
335
- groupOrder: number;
336
- groupId: string;
337
- aliasName: string;
338
- }>;
333
+ /**
334
+ * 日出日落类型
335
+ */
336
+ astronomicalType: number;
337
+ /**
338
+ * 设备或群组 ID
339
+ */
340
+ bizId: string;
341
+ /**
342
+ * 资源类型。0:单设备。1:群组设备。
343
+ */
344
+ bizType: number;
345
+ /**
346
+ * DP 值
347
+ */
348
+ dps: string;
349
+ /**
350
+ * 定时任务 ID
351
+ */
352
+ id: number;
353
+ /**
354
+ * 经度
355
+ */
356
+ lat: number;
357
+ /**
358
+ * 纬度
359
+ */
360
+ lon: number;
361
+ /**
362
+ * 周循环
363
+ */
364
+ loops: string;
365
+ /**
366
+ * 下一个日出时间
367
+ */
368
+ nextSunSet: string;
369
+ /**
370
+ * 定时偏移执行类型
371
+ */
372
+ offsetType: number;
373
+ /**
374
+ * 定时任务状态,0 关闭,1 开启,2 无效/已删除
375
+ */
376
+ status: number;
377
+ /**
378
+ * 定时时间
379
+ */
380
+ time: string;
381
+ /**
382
+ * 时区
383
+ */
384
+ timezone: string;
339
385
  }
340
386
  export interface IAstronomical {
387
+ /**
388
+ * 定时任务 ID
389
+ */
390
+ id: number;
391
+ /**
392
+ * 设备或群组 ID
393
+ */
341
394
  bizId: string;
395
+ /**
396
+ * 资源类型。0:单设备。1:群组设备。
397
+ */
342
398
  bizType: number;
399
+ /**
400
+ * 周循环
401
+ */
343
402
  loops: string;
344
- dps: any;
403
+ /**
404
+ * DP 值
405
+ */
406
+ dps: string;
407
+ /**
408
+ * 日出日落类型
409
+ */
345
410
  astronomicalType: number;
411
+ /**
412
+ * 时区
413
+ */
346
414
  timezone: string;
415
+ /**
416
+ * 定时日期 yyyyMMdd
417
+ */
347
418
  date: string;
419
+ /**
420
+ * 定时时间
421
+ */
348
422
  time: string;
423
+ /**
424
+ * 定时偏移执行类型
425
+ */
349
426
  offsetType: number;
427
+ /**
428
+ * 经度
429
+ */
350
430
  lat: number;
431
+ /**
432
+ * 纬度
433
+ */
351
434
  lon: number;
352
435
  }
353
436
  export interface IUpdateAstronomicalStatus {
437
+ /**
438
+ * 定时任务 ID
439
+ */
354
440
  id: string;
441
+ /**
442
+ * 0:关闭。1:开启
443
+ */
355
444
  status: number;
356
445
  }
357
446
  export interface IUpdateBillConfigure {
@@ -867,23 +956,215 @@ export type IGetSceneListResponse = Array<{
867
956
  name: string;
868
957
  id: string;
869
958
  }>;
959
+ export interface ISceneAction {
960
+ /**
961
+ * 执行动作的显示名称
962
+ */
963
+ actionDisplay: string;
964
+ /**
965
+ * 执行动作的执行者
966
+ */
967
+ actionExecutor: string;
968
+ /**
969
+ * 执行动作的策略
970
+ */
971
+ actionStrategy: string;
972
+ /**
973
+ * 属性值
974
+ */
975
+ attribute: number;
976
+ /**
977
+ * 设备删除标记,表示设备是否被删除
978
+ */
979
+ devDelMark: boolean;
980
+ /**
981
+ * 动作是否启用
982
+ */
983
+ enabled: boolean;
984
+ /**
985
+ * 实体ID,表示动作所属的实体的ID
986
+ */
987
+ entityId: string;
988
+ /**
989
+ * 修改时间戳
990
+ */
991
+ gmtModified: number;
992
+ /**
993
+ * 动作的唯一ID
994
+ */
995
+ id: string;
996
+ /**
997
+ * 网关同步标记,表示是否网关同步
998
+ */
999
+ offGwSync: boolean;
1000
+ /**
1001
+ * 动作的顺序号
1002
+ */
1003
+ orderNum: number;
1004
+ /**
1005
+ * 规则ID,表示动作所属的规则的ID
1006
+ */
1007
+ ruleId: string;
1008
+ /**
1009
+ * 动作状态
1010
+ */
1011
+ status: boolean;
1012
+ /**
1013
+ * 用户ID,表示动作所属的用户的ID
1014
+ */
1015
+ uid: string;
1016
+ }
1017
+ /**
1018
+ * 一键执行类型的联动规则数据
1019
+ */
1020
+ export type IGetSceneListResponseV2 = Array<{
1021
+ /**
1022
+ * 执行动作
1023
+ */
1024
+ actions: ISceneAction[];
1025
+ alarmIssue: boolean;
1026
+ /**
1027
+ * 属性
1028
+ * 根据枚举值的2次幂进行位运算
1029
+ */
1030
+ attribute: number;
1031
+ /**
1032
+ * 审核状态
1033
+ * 0. 未审核
1034
+ * 1. 审核通过
1035
+ * 2. 审核不通过
1036
+ */
1037
+ auditStatus: number;
1038
+ /**
1039
+ * 背景图地址
1040
+ */
1041
+ background?: string;
1042
+ /**
1043
+ * 面板绑定
1044
+ */
1045
+ boundForPanel: boolean;
1046
+ boundForWiFiPanel: boolean;
1047
+ /**
1048
+ * 规则 code
1049
+ */
1050
+ code: string;
1051
+ /**
1052
+ * 通用json字段,比如本地联动会存网关id,gwId
1053
+ */
1054
+ commonField: string;
1055
+ containDeviceDelete: boolean;
1056
+ /**
1057
+ * 图标
1058
+ */
1059
+ coverIcon: string;
1060
+ description?: string;
1061
+ disableTime?: number;
1062
+ /**
1063
+ * 背景颜色
1064
+ */
1065
+ displayColor: string;
1066
+ /**
1067
+ * 规则是否启用
1068
+ */
1069
+ enabled: boolean;
1070
+ forceCloudTrigger: boolean;
1071
+ /**
1072
+ * 执行规则 id
1073
+ */
1074
+ id: string;
1075
+ iotAutoAlarm: boolean;
1076
+ isAlarmIssue: boolean;
1077
+ isLogicRule: boolean;
1078
+ /**
1079
+ * 联动类型
1080
+ */
1081
+ linkageType: number;
1082
+ /**
1083
+ * 是否本地联动
1084
+ */
1085
+ localLinkage: boolean;
1086
+ logicRule: boolean;
1087
+ /**
1088
+ * 匹配类型
1089
+ * 1. 任意条件,多个条件里只要有一个即触发(即 或关系)。
1090
+ * 2. 全部满足,多个条件全部满足才触发。
1091
+ * 3. 表态式匹配, 根据 rule 字段的 expr 确定是否满足,条件满足时触发。
1092
+ */
1093
+ matchType: number;
1094
+ /**
1095
+ * 联动名称或备注
1096
+ */
1097
+ name: string;
1098
+ needCleanGidSid: boolean;
1099
+ needValidOutOfWork: boolean;
1100
+ newLocalScene: boolean;
1101
+ offGwSync: boolean;
1102
+ offGwSyncSuccess: boolean;
1103
+ orderWeight: number;
1104
+ outOfWork: number;
1105
+ /**
1106
+ * 家庭id
1107
+ */
1108
+ ownerId: string;
1109
+ panelType: number;
1110
+ permissionCode: string;
1111
+ ruleGenre: number;
1112
+ ruleSource: number;
1113
+ /**
1114
+ * 规则类型
1115
+ * 1. 系统定义
1116
+ * 2. 商家定义
1117
+ * 3. 用户定义
1118
+ * 4. 安防规则
1119
+ * 5. 服务定义(如 dp 点转发)
1120
+ */
1121
+ ruleType: number;
1122
+ /**
1123
+ * 运行环境
1124
+ */
1125
+ runtimeEnv: string;
1126
+ scenarioRule: boolean;
1127
+ status: boolean;
1128
+ statusConditions: any[];
1129
+ /**
1130
+ * 是否显示在首页顶部
1131
+ */
1132
+ stickyOnTop: boolean;
1133
+ subMatchType: number;
1134
+ /**
1135
+ * 用户 id
1136
+ */
1137
+ uid: string;
1138
+ }>;
870
1139
  export interface IBindRule {
871
1140
  devId: string;
872
- associativeEntityId: string;
1141
+ /**
1142
+ * 与面板/设备建立绑定关系,通常为设备ID、DP点、群组、规则,dpId#value等
1143
+ */
1144
+ sourceEntityId?: string;
1145
+ /**
1146
+ * 当associativeEntityId不足以区分情况下使用,通常可关联设备、DP值、群组、规则等
1147
+ */
1148
+ associativeEntityId: AssociativeEntityId;
873
1149
  ruleId: string;
874
1150
  entitySubIds: string;
875
1151
  expr: [string[]];
876
1152
  bizDomain: string;
1153
+ gid: string;
1154
+ /**
1155
+ * 拓展字段,非必传
1156
+ */
1157
+ property?: Record<string, any>;
877
1158
  }
878
1159
  export interface IBindRuleResponse {
879
1160
  /**
880
- * 关联 DP 点和 DP 点值的组合
1161
+ * 与面板/设备建立绑定关系,通常为设备ID、DP点、群组、规则,dpId#value等
881
1162
  */
882
- associativeEntityId: string;
1163
+ associativeEntityId: AssociativeEntityId;
883
1164
  /**
884
- * 动作 ID
1165
+ * 当associativeEntityId不足以区分情况下使用,通常可关联设备、DP值、群组、规则等
885
1166
  */
886
- associativeEntityValue: string;
1167
+ associativeEntityValue: AssociativeEntityValue;
887
1168
  /**
888
1169
  * 业务域
889
1170
  */
@@ -909,25 +1190,69 @@ export interface IBindRuleResponse {
909
1190
  */
910
1191
  triggerRuleVO: any;
911
1192
  }
1193
+ declare enum EntityType {
1194
+ DEVICE = 1,// 关联实体为设备
1195
+ RULE = 2
1196
+ }
912
1197
  export interface IGetBindRuleList {
913
1198
  bizDomain: string;
914
1199
  devId: string;
915
1200
  sourceEntityId?: string;
916
- entityType: number;
1201
+ entityType: EntityType;
917
1202
  gid: string;
918
1203
  }
919
1204
  export type IGetBindRuleListResponse = Array<{
920
- associativeEntityId: string;
921
- associativeEntityValueList: any[];
1205
+ /**
1206
+ * 与面板/设备建立绑定关系,通常为设备ID、DP点、群组、规则,dpId#value等
1207
+ */
1208
+ associativeEntityId: AssociativeEntityId;
1209
+ /**
1210
+ * 关联实体的值列表
1211
+ */
1212
+ associativeEntityValueList: Array<IGetSceneListResponseV2[number] & {
1213
+ /**
1214
+ * 无线开关规则是否启用
1215
+ */
1216
+ triggerRuleEnable: boolean;
1217
+ /**
1218
+ * 无线开关执行规则 id
1219
+ */
1220
+ triggerRuleId: string;
1221
+ }>;
1222
+ /**
1223
+ * 绑定 id,一般用来解绑
1224
+ */
1225
+ bindId: number;
1226
+ /**
1227
+ * 业务域
1228
+ */
922
1229
  bizDomain: string;
1230
+ /**
1231
+ * 是否启用
1232
+ */
1233
+ enable: boolean;
1234
+ /**
1235
+ * 设备 ID
1236
+ */
923
1237
  sourceEntityId: string;
924
1238
  }>;
1239
+ export interface IUnbindRule {
1240
+ /**
1241
+ * 解绑 id
1242
+ */
1243
+ bindId: string;
1244
+ /**
1245
+ * 家庭 id
1246
+ */
1247
+ gid: string;
1248
+ }
925
1249
  export interface IRemoveRule {
926
1250
  bizDomain: string;
927
1251
  sourceEntityId?: string;
928
1252
  devId: string;
929
- associativeEntityId: string;
930
- associativeEntityValue: string;
1253
+ associativeEntityId: AssociativeEntityId;
1254
+ associativeEntityValue: AssociativeEntityValue;
1255
+ gid: string;
931
1256
  }
932
1257
  export interface IGetDevProperty {
933
1258
  /**
@@ -1057,3 +1382,4 @@ export type IGetZigbeeLocalGroupDeviceListResponse = Array<{
1057
1382
  */
1058
1383
  gwOnline: boolean;
1059
1384
  }>;
1385
+ export {};
@@ -1 +1,22 @@
1
+ // 场景相关接口
2
+ /**
3
+ * 与面板/设备建立绑定关系,通常为设备ID、DP点、群组、规则,dpId#value等
4
+ */
5
+ /**
6
+ * 当associativeEntityId不足以区分情况下使用,通常可关联设备、DP值、群组、规则等
7
+ */
8
+ // 云端定时接口
9
+ // 电费统计接口
10
+ // 设备接口
11
+ // 数据统计接口
12
+ // 告警相关接口
13
+ // 联动相关
14
+ /**
15
+ * 一键执行类型的联动规则数据
16
+ */
17
+ var EntityType = /*#__PURE__*/function (EntityType) {
18
+ EntityType[EntityType["DEVICE"] = 1] = "DEVICE";
19
+ EntityType[EntityType["RULE"] = 2] = "RULE";
20
+ return EntityType;
21
+ }(EntityType || {}); // 关联实体为联动规则
1
22
  export {};
@@ -1,4 +1,4 @@
1
- import { IGetLinkageDeviceList, IBindRule, IGetBindRuleList, IRemoveRule, IGetLinkageDeviceListResponse, IGetSceneListResponse, IGetBindRuleListResponse, IBindRuleResponse } from './interface';
1
+ import { IGetLinkageDeviceList, IBindRule, IGetBindRuleList, IRemoveRule, IGetLinkageDeviceListResponse, IGetSceneListResponse, IGetBindRuleListResponse, IBindRuleResponse, IUnbindRule, IGetSceneListResponseV2 } from './interface';
2
2
  /**
3
3
  * 获取家庭下支持联动的设备列表
4
4
  * @param {number} gid 家庭id
@@ -6,20 +6,30 @@ import { IGetLinkageDeviceList, IBindRule, IGetBindRuleList, IRemoveRule, IGetLi
6
6
  */
7
7
  declare const getLinkageDeviceList: (params: IGetLinkageDeviceList) => Promise<IGetLinkageDeviceListResponse>;
8
8
  /**
9
- * 查询家庭下一键执行场景列表
9
+ * 查询家庭下联动规则列表,包含失效及自动化规则
10
10
  * @param {number} devId 设备id
11
11
  * @param {number} gid 家庭Id
12
12
  */
13
- declare const getSceneList: ({ devId, gid }: {
13
+ declare const getSceneList: ({ devId, gid, }: {
14
14
  devId: string;
15
15
  gid: string;
16
16
  }) => Promise<IGetSceneListResponse>;
17
+ /**
18
+ * 查询家庭下一键执行列表,会去掉失效或自动化规则
19
+ * @param {number} devId 设备id
20
+ * @param {boolean} containStandardZigBee 是否包含标准场景,默认不包含
21
+ * @param {number} gid 家庭Id
22
+ */
23
+ declare const getSceneListV2: ({ devId, gid, containStandardZigBee, }: {
24
+ devId: string;
25
+ gid: string;
26
+ containStandardZigBee?: boolean;
27
+ }) => Promise<IGetSceneListResponseV2>;
17
28
  /**
18
29
  * 查询家庭下已绑定的列表
19
30
  * @param {string} bizDomain 业务范围
20
31
  * @param {string} devId 设备id
21
32
  * @param {number} entityType 实体类型
22
- * @param {string} gid 家庭Id
23
33
  */
24
34
  declare const getBindRuleList: (params: IGetBindRuleList) => Promise<IGetBindRuleListResponse>;
25
35
  /**
@@ -30,14 +40,22 @@ declare const getBindRuleList: (params: IGetBindRuleList) => Promise<IGetBindRul
30
40
  * @param {string} entitySubIds 关联 DP 点
31
41
  * @param {Array} expr 关联DP点、动作组合
32
42
  * @param {string} bizDomain 业务域
43
+ * @param {string} bizDomain 业务域
44
+ */
45
+ declare const bindRule: (params: IBindRule) => Promise<IBindRuleResponse>;
46
+ /**
47
+ * 解绑联动
48
+ * @param {string} bindId 绑定 id
49
+ * @param {string} gid 家庭id
33
50
  */
34
- declare const bindRule: ({ devId, associativeEntityId, ruleId, entitySubIds, expr, bizDomain, }: IBindRule) => Promise<IBindRuleResponse>;
51
+ declare const unbindRule: (params: IUnbindRule) => Promise<boolean>;
35
52
  /**
36
53
  * 解除联动
37
54
  * @param {string} bizDomain 业务范围
38
55
  * @param {string} devId 设备id
39
56
  * @param {string} associativeEntityId 关联dp组合
40
57
  * @param {string} associativeEntityValue 规则id
58
+ * @param {string} gid 家庭id
41
59
  */
42
60
  declare const removeRule: (params: IRemoveRule) => Promise<boolean>;
43
61
  /**
@@ -61,4 +79,4 @@ declare const enableRule: ({ ruleId }: {
61
79
  declare const disableRule: ({ ruleId }: {
62
80
  ruleId: string;
63
81
  }) => Promise<boolean>;
64
- export { getLinkageDeviceList, getSceneList, getBindRuleList, bindRule, removeRule, triggerRule, enableRule, disableRule, };
82
+ export { getLinkageDeviceList, getSceneList, getSceneListV2, getBindRuleList, bindRule, unbindRule, removeRule, triggerRule, enableRule, disableRule, };
@@ -1,6 +1,7 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- const _excluded = ["gid", "devId", "sourceEntityId"];
3
+ const _excluded = ["gid", "devId", "sourceEntityId"],
4
+ _excluded2 = ["sourceEntityId", "devId", "gid"];
4
5
  import { requestCloud } from '../';
5
6
  import { THING } from '../constants';
6
7
  /**
@@ -14,13 +15,13 @@ const getLinkageDeviceList = params => {
14
15
  version: '3.0',
15
16
  data: _objectSpread({}, params),
16
17
  extData: {
17
- gid: params.gid
18
+ gid: "".concat(params.gid)
18
19
  }
19
20
  });
20
21
  };
21
22
 
22
23
  /**
23
- * 查询家庭下一键执行场景列表
24
+ * 查询家庭下联动规则列表,包含失效及自动化规则
24
25
  * @param {number} devId 设备id
25
26
  * @param {number} gid 家庭Id
26
27
  */
@@ -36,7 +37,32 @@ const getSceneList = _ref => {
36
37
  devId
37
38
  },
38
39
  extData: {
39
- gid
40
+ gid: "".concat(gid)
41
+ }
42
+ });
43
+ };
44
+
45
+ /**
46
+ * 查询家庭下一键执行列表,会去掉失效或自动化规则
47
+ * @param {number} devId 设备id
48
+ * @param {boolean} containStandardZigBee 是否包含标准场景,默认不包含
49
+ * @param {number} gid 家庭Id
50
+ */
51
+ const getSceneListV2 = _ref2 => {
52
+ let {
53
+ devId,
54
+ gid,
55
+ containStandardZigBee = false
56
+ } = _ref2;
57
+ return requestCloud({
58
+ api: "".concat(THING, ".m.linkage.rule.brief.query"),
59
+ version: '2.0',
60
+ data: {
61
+ devId,
62
+ containStandardZigBee
63
+ },
64
+ extData: {
65
+ gid: "".concat(gid)
40
66
  }
41
67
  });
42
68
  };
@@ -46,7 +72,6 @@ const getSceneList = _ref => {
46
72
  * @param {string} bizDomain 业务范围
47
73
  * @param {string} devId 设备id
48
74
  * @param {number} entityType 实体类型
49
- * @param {string} gid 家庭Id
50
75
  */
51
76
  const getBindRuleList = async params => {
52
77
  const {
@@ -62,7 +87,7 @@ const getBindRuleList = async params => {
62
87
  sourceEntityId: sourceEntityId || devId
63
88
  }),
64
89
  extData: {
65
- gid
90
+ gid: "".concat(gid)
66
91
  }
67
92
  });
68
93
  };
@@ -75,22 +100,26 @@ const getBindRuleList = async params => {
75
100
  * @param {string} entitySubIds 关联 DP 点
76
101
  * @param {Array} expr 关联DP点、动作组合
77
102
  * @param {string} bizDomain 业务域
103
+ * @param {string} bizDomain 业务域
78
104
  */
79
- const bindRule = _ref2 => {
80
- let {
105
+ const bindRule = params => {
106
+ const {
81
107
  devId,
108
+ sourceEntityId,
82
109
  associativeEntityId,
83
110
  ruleId,
84
111
  entitySubIds,
85
112
  expr,
86
- bizDomain
87
- } = _ref2;
113
+ bizDomain,
114
+ gid,
115
+ property
116
+ } = params;
88
117
  return requestCloud({
89
118
  api: "".concat(THING, ".m.linkage.associative.entity.bind"),
90
119
  version: '1.0',
91
120
  data: {
92
121
  relationExpr: {
93
- sourceEntityId: devId,
122
+ sourceEntityId: sourceEntityId || devId,
94
123
  associativeEntityId,
95
124
  associativeEntityValue: ruleId,
96
125
  triggerRuleVO: {
@@ -107,9 +136,32 @@ const bindRule = _ref2 => {
107
136
  actionExecutor: 'ruleTrigger'
108
137
  }]
109
138
  },
139
+ ruleIds: [ruleId],
140
+ property,
110
141
  bizDomain,
111
142
  uniqueType: 3
112
143
  }
144
+ },
145
+ extData: {
146
+ gid: "".concat(gid)
147
+ }
148
+ });
149
+ };
150
+
151
+ /**
152
+ * 解绑联动
153
+ * @param {string} bindId 绑定 id
154
+ * @param {string} gid 家庭id
155
+ */
156
+ const unbindRule = params => {
157
+ return requestCloud({
158
+ api: "".concat(THING, ".m.linkage.bind.delete"),
159
+ version: '1.0',
160
+ data: {
161
+ bindId: params.bindId
162
+ },
163
+ extData: {
164
+ gid: "".concat(params.gid)
113
165
  }
114
166
  });
115
167
  };
@@ -120,12 +172,24 @@ const bindRule = _ref2 => {
120
172
  * @param {string} devId 设备id
121
173
  * @param {string} associativeEntityId 关联dp组合
122
174
  * @param {string} associativeEntityValue 规则id
175
+ * @param {string} gid 家庭id
123
176
  */
124
177
  const removeRule = params => {
178
+ const {
179
+ sourceEntityId,
180
+ devId,
181
+ gid
182
+ } = params,
183
+ rest = _objectWithoutProperties(params, _excluded2);
125
184
  return requestCloud({
126
185
  api: "".concat(THING, ".m.linkage.associative.entity.remove"),
127
186
  version: '1.0',
128
- data: _objectSpread({}, params)
187
+ data: _objectSpread({
188
+ sourceEntityId: sourceEntityId || devId
189
+ }, rest),
190
+ extData: {
191
+ gid: "".concat(gid)
192
+ }
129
193
  });
130
194
  };
131
195
 
@@ -179,4 +243,4 @@ const disableRule = _ref5 => {
179
243
  }
180
244
  });
181
245
  };
182
- export { getLinkageDeviceList, getSceneList, getBindRuleList, bindRule, removeRule, triggerRule, enableRule, disableRule };
246
+ export { getLinkageDeviceList, getSceneList, getSceneListV2, getBindRuleList, bindRule, unbindRule, removeRule, triggerRule, enableRule, disableRule };
@@ -1,15 +1,17 @@
1
+ export type ErrorMsg = {
2
+ errorMsg: string;
3
+ errorCode: string | number;
4
+ innerError: {
5
+ errorCode: string | number;
6
+ errorMsg: string;
7
+ };
8
+ };
1
9
  export type ICommon = {
2
10
  success?: () => void;
3
- fail?: (err?: {
4
- errorMsg: string;
5
- errorCode: string | number;
6
- innerError: {
7
- errorCode: string | number;
8
- errorMsg: string;
9
- };
10
- }) => void;
11
+ fail?: (err?: ErrorMsg) => void;
11
12
  complete?: () => void;
12
- } & {
13
+ };
14
+ export type RecordRest = {
13
15
  [key: string]: string | boolean | number;
14
16
  };
15
17
  export declare function nativeRouter<T extends ICommon>(uri: string, params?: T): Promise<void>;
@@ -4,6 +4,7 @@ type OpenSceneCreateParams = {
4
4
  } & ICommon;
5
5
  export declare function openSceneCreate(params?: OpenSceneCreateParams): Promise<void>;
6
6
  export declare const openCreateScene: typeof openSceneCreate;
7
+ export declare function openCreateTapToRunScene(params?: ICommon): Promise<void>;
7
8
  export declare function openUniversalCreateScene(params?: OpenSceneCreateParams): Promise<void>;
8
9
  type OpenSceneEdit = {
9
10
  devId?: string;
@@ -1,9 +1,18 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  import { nativeRouter } from './common';
2
3
  export function openSceneCreate(params) {
3
4
  return nativeRouter('createScene', params);
4
5
  }
5
6
  export const openCreateScene = openSceneCreate;
6
7
 
8
+ // App 基线 5.13.0 以上开始支持
9
+ export function openCreateTapToRunScene(params) {
10
+ const p = _objectSpread({
11
+ biz_type: 'click_execution'
12
+ }, params);
13
+ return nativeRouter('addScene', p);
14
+ }
15
+
7
16
  // 兼容Android 端仅支持 Zigbee 本地场景, Android使用createSmartScene
8
17
  export function openUniversalCreateScene(params) {
9
18
  const url = ty.getSystemInfoSync().platform === 'android' ? 'createSmartScene' : 'createScene';
@@ -21,7 +21,10 @@ type OpenMoreService = {} & ICommon;
21
21
  * 跳转到更多服务
22
22
  */
23
23
  export declare function openMoreService(params?: OpenMoreService): Promise<void>;
24
- type OpenAppHelpCenter = {} & ICommon;
24
+ type OpenAppHelpCenter = {
25
+ bizCode?: string;
26
+ key?: string;
27
+ } & ICommon;
25
28
  /**
26
29
  * 跳转到App帮助与反馈页
27
30
  */
@@ -1,3 +1,6 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ const _excluded = ["bizCode", "key"];
1
4
  import { nativeRouter } from './common';
2
5
  /**
3
6
  * 打开APP扫码
@@ -31,7 +34,17 @@ export function openMoreService(params) {
31
34
  * 跳转到App帮助与反馈页
32
35
  */
33
36
  export function openAppHelpCenter(params) {
34
- return nativeRouter('helpCenter', params);
37
+ const _ref = params || {},
38
+ {
39
+ bizCode = 'help_center',
40
+ key = 'main_page'
41
+ } = _ref,
42
+ rest = _objectWithoutProperties(_ref, _excluded);
43
+ const p = _objectSpread({
44
+ bizCode,
45
+ key
46
+ }, rest);
47
+ return nativeRouter('helpCenter', p);
35
48
  }
36
49
 
37
50
  // messageCenter
@@ -0,0 +1,64 @@
1
+ ```
2
+ createScene
3
+ tysh_family_add_member_rn
4
+ presentGatewayCategroy
5
+ device_detail
6
+ helpAndFeedBack
7
+ sceneUiUpdate
8
+ createAuto
9
+ member_info
10
+ more_service
11
+ createScene_allDevices
12
+ editScene
13
+ ty_home_security_page
14
+ createAutoWithCondition
15
+ config_device
16
+ device_only_search_config_gw_sub
17
+ grid_update_firmware
18
+ dev_network_check
19
+ helpCenter
20
+ camera_base_setting
21
+ device_gw_sub_device_help_list
22
+ zigbee_pair
23
+ devManualAndSmart
24
+ device_offline_reconnect
25
+ ihcImportDevice
26
+ complete_user_information
27
+ ty_user_setting
28
+ addRelationDeviceWithoutMesh
29
+ editLocalSceneWithoutMesh
30
+ philipsImportDevice
31
+ msg_media_play
32
+ gotoGeekLock
33
+ devMultiLink
34
+ scene/createScene
35
+ camera_video_view
36
+ config_device_home
37
+ messageCenter
38
+ smartScene
39
+ jumpHome
40
+ tysh_family_setting
41
+ camera_motion_monitor
42
+ tutorial_tips
43
+ sleep_stages_guide
44
+ editZigbeeGroupScene
45
+ ty_scene_device_related_scenes
46
+ range-finder-canvas
47
+ settingVoiceServiceConfigListRouter
48
+ createAutoWithCondition
49
+ scan
50
+ upgrade_detail
51
+ tsod_cycling_navigation
52
+ tsod_additional_unlock_methods
53
+ tsod_ambient_lighting
54
+ tsod_shortcut_siri
55
+ config_device_home
56
+ thing_add_scene
57
+ // 6.13新增
58
+ createSmartScene
59
+ addScene
60
+ camera_playback_panel
61
+ ipc_album_panel
62
+ camera_cloud_panel
63
+ modeSetting
64
+ ```
@@ -1,4 +1,4 @@
1
- import { DevInfo } from '../types/devInfo';
1
+ import { DevInfo, GroupInfo } from '../types/devInfo';
2
2
  export interface InitPanelEnvironmentOptions {
3
3
  /**
4
4
  * @description 是否需要使用默认离线弹窗
@@ -40,10 +40,21 @@ export interface InitPanelEnvironmentOptions {
40
40
  * @default undefined
41
41
  */
42
42
  groupId?: string;
43
+ /**
44
+ * 微信详细页面路由
45
+ * @default undefined
46
+ */
47
+ deviceDetailPage?: string;
48
+ /**
49
+ *是否显示故障提示
50
+ * @default false
51
+ */
52
+ showFault?: boolean;
43
53
  }
44
54
  export declare function parseDevice(dev: ty.device.DeviceInfo | DevInfo): DevInfo;
55
+ export declare function parseGroup(group: ty.device.GroupInfo): GroupInfo;
45
56
  /**
46
- * 初始化面板环境下使用到的设备信息
57
+ * 初始化面板环境下使用到的设备或群组信息
47
58
  * @returns Promise<DevInfo>
48
59
  */
49
60
  export declare const initDevInfo: (option?: {
@@ -57,3 +68,10 @@ export declare const updateDevInfo: (devInfo: DevInfo) => void;
57
68
  * @param config: InitPanelEnvironmentOptions 配置项
58
69
  */
59
70
  export declare function initPanelEnvironment(options?: InitPanelEnvironmentOptions): Promise<void>;
71
+ /**
72
+ * 初始化面板环境
73
+ * @param options 一些配置
74
+ * @param initCallback 初始化回调整
75
+ * @param destroyCallback 销毁环境回调整
76
+ */
77
+ export declare const useInitPanelEnv: (options?: InitPanelEnvironmentOptions, initCallback?: (devId: string) => any, destroyCallback?: (devId: string) => any) => void;
@@ -1,6 +1,8 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import { getDeviceInfo, getLaunchOptionsSync, getGroupInfo, registerDeviceListListener, registerGroupChange, exitMiniProgram, subscribeDeviceRemoved, onDeviceRemoved } from '../../all-kits';
3
+ import { useEffect } from 'react';
3
4
  import getApp from '../../getApp';
5
+
4
6
  // 本地化缓存 deviceInfo 方便随时调用
5
7
  let __deviceInfo = null;
6
8
  const defaultPanelEnvironmentOptions = {
@@ -8,14 +10,15 @@ const defaultPanelEnvironmentOptions = {
8
10
  bleCover: false,
9
11
  customTop: null,
10
12
  bleConnectType: 0,
11
- showBLEToast: true
13
+ showBLEToast: true,
14
+ showFault: false
12
15
  };
13
16
  export function parseDevice(dev) {
14
17
  if (!dev) return null;
15
- // @ts-ignore
16
18
  const deviceInfo = _objectSpread({}, dev);
19
+ // tuyalink 协议设备没有 schema 字段。避免崩溃加设置为空数组
17
20
  const {
18
- schema
21
+ schema = []
19
22
  } = dev;
20
23
  const idCodes = {};
21
24
  const codeIds = {};
@@ -32,26 +35,50 @@ export function parseDevice(dev) {
32
35
  deviceInfo.codeIds = codeIds;
33
36
  return deviceInfo;
34
37
  }
38
+ export function parseGroup(group) {
39
+ if (!group) return null;
40
+ const groupInfo = _objectSpread({}, group);
41
+ const {
42
+ schema
43
+ } = group;
44
+ const idCodes = {};
45
+ const codeIds = {};
46
+ schema.forEach(item => {
47
+ // @ts-ignore
48
+ const {
49
+ id,
50
+ code
51
+ } = item;
52
+ idCodes[id] = code;
53
+ codeIds[code] = id;
54
+ });
55
+ groupInfo.idCodes = idCodes;
56
+ groupInfo.codeIds = codeIds;
57
+ return groupInfo;
58
+ }
35
59
 
36
60
  /**
37
- * 初始化面板环境下使用到的设备信息
61
+ * 初始化面板环境下使用到的设备或群组信息
38
62
  * @returns Promise<DevInfo>
39
63
  */
40
64
  export const initDevInfo = option => {
41
65
  return new Promise((resolve, reject) => {
66
+ var _data$query, _data$query2;
42
67
  if (__deviceInfo) {
43
68
  resolve(__deviceInfo);
44
69
  }
45
70
  const data = getLaunchOptionsSync();
46
- const {
71
+ let {
47
72
  deviceId,
48
73
  groupId
49
- } = option || data.query;
74
+ } = option || {};
75
+ deviceId = deviceId || ((_data$query = data.query) === null || _data$query === void 0 ? void 0 : _data$query.deviceId);
76
+ groupId = groupId || ((_data$query2 = data.query) === null || _data$query2 === void 0 ? void 0 : _data$query2.groupId);
50
77
  if (groupId) {
51
78
  getGroupInfo({
52
79
  groupId,
53
80
  success: groupInfo => {
54
- __deviceInfo = groupInfo;
81
+ __deviceInfo = parseDevice(groupInfo);
55
82
  resolve(__deviceInfo);
56
83
  }
57
84
  });
@@ -95,19 +122,14 @@ export async function initPanelEnvironment() {
95
122
  });
96
123
  return;
97
124
  }
125
+ let init = false;
98
126
  const App = getApp();
99
-
100
- // 基础库版本需要大于 2.6.0
101
- // @ts-ignore
102
- App.onReady = event => {
127
+ const initPanel = event => {
103
128
  var _options$deviceId, _options$groupId;
104
129
  const deviceId = (_options$deviceId = options.deviceId) !== null && _options$deviceId !== void 0 ? _options$deviceId : event.query.deviceId;
105
130
  const groupId = (_options$groupId = options.groupId) !== null && _options$groupId !== void 0 ? _options$groupId : event.query.groupId;
106
- const {
107
- useDefaultOffline
108
- } = options;
109
131
  // @ts-ignore
110
- if (ty.panel && ty.panel.initPanelKit && useDefaultOffline) {
132
+ if (ty.panel && ty.panel.initPanelKit) {
111
133
  // @ts-ignore
112
134
  ty.panel.initPanelKit(_objectSpread({
113
135
  deviceId,
@@ -136,6 +158,48 @@ export async function initPanelEnvironment() {
136
158
  });
137
159
  }
138
160
  };
161
+ // 由于手机性能、初始化方法调用时机、框架初始化及界面加载逻辑的差异,
162
+ // 有时注册 App.onReady 时可能当前界面已经执行完了该事件,导致逻辑无法正常执行。因此增加延时逻辑,保证逻辑正常执行
163
+ // 若 3s 后仍未执行,则认为当前界面已经执行完了 App.onReady,直接执行逻辑
164
+ const timeout = setTimeout(() => {
165
+ if (init) return;
166
+ initPanel(getLaunchOptionsSync());
167
+ }, 3000);
168
+ // 基础库版本需要大于 2.6.0
169
+ // @ts-ignore
170
+ App.onReady = event => {
171
+ init = true;
172
+ clearTimeout(timeout);
173
+ initPanel(event);
174
+ };
175
+
139
176
  // 使用 Promise 确保业务可以通过 initPanelEnvironment 的正常调用明确设备信息初始化完成
140
177
  await initDevInfo(options.deviceId || options.groupId ? options : undefined);
141
- }
178
+ }
179
+
180
+ /**
181
+ * 初始化面板环境
182
+ * @param options 一些配置
183
+ * @param initCallback 初始化回调整
184
+ * @param destroyCallback 销毁环境回调整
185
+ */
186
+ export const useInitPanelEnv = function () {
187
+ var _data$query3, _data$query4;
188
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultPanelEnvironmentOptions;
189
+ let initCallback = arguments.length > 1 ? arguments[1] : undefined;
190
+ let destroyCallback = arguments.length > 2 ? arguments[2] : undefined;
191
+ const data = getLaunchOptionsSync();
192
+ let {
193
+ deviceId,
194
+ groupId
195
+ } = options || {};
196
+ deviceId = deviceId || ((_data$query3 = data.query) === null || _data$query3 === void 0 ? void 0 : _data$query3.deviceId);
197
+ groupId = groupId || ((_data$query4 = data.query) === null || _data$query4 === void 0 ? void 0 : _data$query4.groupId);
198
+ initPanelEnvironment(options);
199
+ useEffect(() => {
200
+ initCallback && initCallback(deviceId || groupId);
201
+ return () => {
202
+ destroyCallback && destroyCallback(deviceId || groupId);
203
+ };
204
+ }, []);
205
+ };
@@ -1,21 +1,21 @@
1
1
  export type DpValue = boolean | number | string;
2
2
  export type DpState = Record<string, DpValue>;
3
3
  export interface DpSchema {
4
- attr: number;
5
- canTrigger: boolean;
4
+ attr?: number;
5
+ canTrigger?: boolean;
6
6
  /**
7
7
  * 功能点标识码,如 switch
8
8
  */
9
9
  code: string;
10
- defaultRecommend: boolean;
11
- editPermission: boolean;
12
- executable: boolean;
13
- extContent: string;
14
- iconname: string;
10
+ defaultRecommend?: boolean;
11
+ editPermission?: boolean;
12
+ executable?: boolean;
13
+ extContent?: string;
14
+ iconname?: string;
15
15
  /**
16
16
  * 功能点 ID
17
17
  */
18
- id: number;
18
+ id: number | string;
19
19
  /**
20
20
  * 功能点模式类型
21
21
  * rw: 可下发可上报(可读可写)
@@ -34,7 +34,7 @@ export interface DpSchema {
34
34
  /**
35
35
  * 功能点类型
36
36
  */
37
- type: 'bool' | 'value' | 'enum' | 'bitmap' | 'string';
37
+ type: 'bool' | 'value' | 'enum' | 'bitmap' | 'string' | 'raw';
38
38
  /**
39
39
  * 枚举值范围,type = enum 时才存在
40
40
  */
@@ -103,4 +103,17 @@ export type DevInfo = Omit<ty.device.DeviceInfo, 'schema' | 'panelConfig'> & {
103
103
  */
104
104
  panelConfig: PanelConfig;
105
105
  };
106
+ /**
107
+ * 群组信息
108
+ */
109
+ export type GroupInfo = ty.device.GroupInfo & {
110
+ /**
111
+ * dp id 与 dp code 的映射
112
+ */
113
+ idCodes: Record<string, string>;
114
+ /**
115
+ * dp code 与 dp id 的映射
116
+ */
117
+ codeIds: Record<string, string>;
118
+ };
106
119
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/api",
3
- "version": "1.6.0-beta.6",
3
+ "version": "1.6.0-beta.8",
4
4
  "description": "Ray universal api",
5
5
  "keywords": [
6
6
  "ray"
@@ -29,14 +29,14 @@
29
29
  "watch": "ray start --type=component"
30
30
  },
31
31
  "dependencies": {
32
- "@ray-js/framework": "^1.6.0-beta.6",
33
- "@ray-js/router": "^1.6.0-beta.6",
32
+ "@ray-js/framework": "^1.6.0-beta.8",
33
+ "@ray-js/router": "^1.6.0-beta.8",
34
34
  "@ray-js/wechat": "^0.2.9",
35
35
  "base64-browser": "^1.0.1",
36
36
  "query-string": "^7.1.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@ray-js/cli": "^1.6.0-beta.6",
39
+ "@ray-js/cli": "^1.6.0-beta.8",
40
40
  "art-template": "^4.13.2",
41
41
  "fs-extra": "^10.1.0",
42
42
  "miniprogram-api-typings": "^3.12.2",
@@ -46,5 +46,5 @@
46
46
  "access": "public",
47
47
  "registry": "https://registry.npmjs.org"
48
48
  },
49
- "gitHead": "d7f01ca1b85707f2e7696e820b45aa271a39126d"
49
+ "gitHead": "b1d4118961bba4f3f2a889ec5bb9444d165df0dc"
50
50
  }