e10-data 0.1.10 → 0.1.12

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/README.md CHANGED
@@ -112,6 +112,37 @@ e10-data conf delete GET_WORKFLOW_LIST --type api --group workflow
112
112
  - 同一 `confKey` 可存在于多个 `confGroup`;`conf batch` / `batch-file` 的返回映射在带分组时以 `组|键` 为键,不会互相覆盖。
113
113
  - `--json` 输出:`conf group` 返回配置数组(带 `--key` 时返回单条),`conf batch` 返回映射对象。
114
114
 
115
+ ## ds appId 自动解析(v0.1.11 新增)
116
+
117
+ ChatBI 数据源取数接口(`getListDatas` / `getChartDatas` / `getStatDatas` / `getCountData`)对**部分 EB 应用(独立部署)**的数据集,必须在 `queryDto` 中携带 `appId`,否则后端一律返回 `code=500 请求失败`(实测:小餐厅应用 `840360791696547845` 名下 4 张表不传全 500、传即 200;低代码大赛等应用不传也正常)。
118
+
119
+ `e10-data ds list|chart|stat|count` 现**默认自动解析并带上 appId**,解析顺序:
120
+
121
+ 1. `--app-id <id>` 显式指定(最高优先,0 额外请求);
122
+ 2. 本地缓存 `~/.e10-cli/.e10-data-ds-appid.json`(key = `sourceType|groupId|tableId`,TTL 7 天);
123
+ 3. `ebdf_obj`(DSL 查 `ec_edcapp.ebdf_obj`,`id = tableId` → `app_id`)—— EB 表单权威来源,请求最小;
124
+ 4. `ds tables`(`listByPage`)按 id 匹配,命中后把**整组** `id→appId` 映射一次性写入缓存;
125
+ 5. `ds fields` 扫字段 `config.appId`(Ebuilder 类字段携带);
126
+ 6. 均无 → 不带 appId 发送(兼容旧行为)。
127
+
128
+ ```bash
129
+ # 默认:自动解析(推荐)
130
+ e10-data ds count --group weaver-ebuilder-form-service --table 840360795890851856
131
+
132
+ # 显式指定(跳过所有解析,最快)
133
+ e10-data ds count --group weaver-ebuilder-form-service --table 840360795890851856 --app-id 840360791696547845
134
+
135
+ # 完全跳过自动解析(明确不需要 appId 的数据集,省一次解析往返)
136
+ e10-data ds count --group weaver-ebuilder-form-service --table 1081139888007225347 --no-app-id
137
+
138
+ # 查看某张表的 appId:ds tables 输出新增 appId 列;ds fields 命中时在表头打印 appId=…
139
+ e10-data ds tables --group weaver-ebuilder-form-service --name 低代码大赛
140
+ e10-data ds fields --group weaver-ebuilder-form-service --table 840360795890851856
141
+ ```
142
+
143
+ > ⚠️ `ds tables`(`listByPage`)**不覆盖全部数据集**:实测「小餐厅」应用的 4 张表在该清单(共 997 条)里查不到,其 appId 由第 3 步 `ebdf_obj` 兜底拿到——故解析顺序把 `ebdf_obj` 置于 `ds tables` 之前。
144
+ > 实测对照(带 appId 与 DSL 口径一致):`ds count` + `ydlc isNotNull` = **6470**,与 DSL 同口径结果一致;`ds chart` 按区域分组 = 上海 5123 / 北京 165 / 区域空 1182。
145
+
115
146
  ## ds --where 过滤条件(v0.1.8 起支持树形 OR)
116
147
 
117
148
  `e10-data ds list|chart|stat|count --where` 接收**条件数组**或**完整条件树**,均可递归嵌套表达 AND/OR:
package/bin/e10-data.mjs CHANGED
@@ -6,6 +6,9 @@
6
6
  * 覆盖(数据查询链路全部家族;登录/HRM 复用 e10-login / hrm-cli,checkEbModulePermission 已废弃不提供):
7
7
  * e10-data query DSL 查询 executeQueryDsl(conn/model/schema/tableId/dslQuery/debug)
8
8
  * e10-data ds tables|fields|list|chart|stat|count 数据源(业务模块)取数与元数据
9
+ * 取数(list/chart/stat/count)自动解析并携带 queryDto.appId(v0.1.12):
10
+ * 顺序 chat_bi_eb_config_map(dw,按 obj_id) → ebdf_obj(ec_edcapp,按 id),实时查、不缓存;
11
+ * --app-id <id> 显式指定 / --app-id auto 强制自动 / --no-app-id 跳过(最快)
9
12
  * e10-data doc count|list 文档查询 documentListCount / documentList
10
13
  * e10-data noun list 词库 getChatDocsBySkillKey
11
14
  * e10-data field id2name|name2id 关联字段翻译 testRemoteBrowser / complete
@@ -493,17 +496,66 @@ function parseOrder(val) {
493
496
  return { fieldId: f, fieldName: f, objId: "", isAsc: (dir || "asc").toLowerCase() !== "desc", mainField: true };
494
497
  });
495
498
  }
499
+ // ---------------- ds appId 自动解析(v0.1.12)----------------
500
+ // 背景:ChatBI 数据源取数接口(getListDatas / getChartDatas / getStatDatas / getCountData)
501
+ // 对部分 EB 应用(独立部署)的数据集必须携带 queryDto.appId,否则后端一律返回 code=500。
502
+ // 解析顺序(无缓存,每次实时查):--app-id <id> 显式 > chat_bi_eb_config_map(dw 权限配置表,按 obj_id,主来源)
503
+ // > ebdf_obj(ec_edcapp,按 id,兜底) > 不带 appId 发送(兼容旧行为)。
504
+ // 关闭自动解析:--no-app-id。
505
+ const APPID_SOURCES = [
506
+ { confKey: "CONN_DW", model: "dw", schema: "dw", table: "chat_bi_eb_config_map", idField: "obj_id" },
507
+ { confKey: "CONN_EC_EDCAPP", model: "ebuilder", schema: "ec_edcapp", table: "ebdf_obj", idField: "id" },
508
+ ];
509
+ function dsFieldsForm(gid, tid, st) {
510
+ return { groupId: gid, sourceId: tid, sourceType: st, detailFieldsGroup: "true", enableMerge: "true", needTableName: "true", params: "[]" };
511
+ }
512
+ async function appIdByDsl(src, tid) {
513
+ const conn = await confGetData("conn", src.confKey, true);
514
+ const connId = (conn && conn.confValue) ? String(conn.confValue) : "";
515
+ if (!connId) return "";
516
+ const dslQuery = {
517
+ select: { columns: [{ field: "t1.app_id", alias: "app_id" }] },
518
+ from: { table: src.table, alias: "t1" },
519
+ where: { logic: "AND", conditions: [{ field: "t1." + src.idField, op: "=", value: String(tid) }, { field: "t1.delete_type", op: "=", value: 0 }] },
520
+ limit: { size: 1, offset: 0 },
521
+ };
522
+ const r = await postJson("/api/dw/dsl/executeQueryDsl", { connId, model: src.model, schema: src.schema, tableId: "", dslQuery });
523
+ const rows = Array.isArray(r && r.data) ? r.data : [];
524
+ return (rows[0] && rows[0].app_id) ? String(rows[0].app_id) : "";
525
+ }
526
+ async function resolveDsAppId(tid) {
527
+ for (const src of APPID_SOURCES) {
528
+ let appId = "";
529
+ try { appId = await appIdByDsl(src, tid); } catch { appId = ""; }
530
+ if (appId) return appId;
531
+ }
532
+ return "";
533
+ }
534
+ // ds 取数统一入口:--app-id <id> 显式 / --app-id auto 或省略=自动解析 / --no-app-id 跳过
535
+ async function dsDto(args, tid, gid, pageNo, pageSize, queryType) {
536
+ const dto = baseDto(tid, gid, pageNo, pageSize, queryType);
537
+ const explicit = args["app-id"];
538
+ if (typeof explicit === "string" && explicit !== "" && explicit !== "auto") {
539
+ dto.appId = explicit;
540
+ } else if (!args["no-app-id"]) {
541
+ const appId = await resolveDsAppId(tid);
542
+ if (appId) dto.appId = String(appId);
543
+ }
544
+ return dto;
545
+ }
496
546
  async function cmdTables(args, json) {
497
547
  const gid = need("group", args);
498
548
  const form = { name: args.name || "", pageNo: args.page || "1", pageSize: args.size || "100", groupId: gid, sourceType: args["source-type"] || "LOGIC", dataUsage: "" };
549
+ if (typeof args["app-id"] === "string" && args["app-id"] !== "" && args["app-id"] !== "auto") form.appId = args["app-id"];
499
550
  const r = await postMultipart("/api/ebuilder/common/ds/listByPage", form);
500
551
  if (json) return r;
501
552
  const recs = ((r.data || {}).records) || [];
502
- printHuman("分组表清单 (total=" + ((r.data || {}).total) + ")", recs, ["id", "name", "tableText", "detailTable", "usage"]);
553
+ printHuman("分组表清单 (total=" + ((r.data || {}).total) + ")", recs, ["id", "name", "appId", "tableText", "detailTable", "usage"]);
503
554
  }
504
555
  async function cmdFields(args, json) {
505
556
  const gid = need("group", args), tid = need("table", args);
506
- const form = { groupId: gid, sourceId: tid, sourceType: args["source-type"] || "LOGIC", detailFieldsGroup: "true", enableMerge: "true", needTableName: "true", params: "[]" };
557
+ const form = dsFieldsForm(gid, tid, args["source-type"] || "LOGIC");
558
+ if (typeof args["app-id"] === "string" && args["app-id"] !== "" && args["app-id"] !== "auto") form.appId = args["app-id"];
507
559
  const r = await postMultipart("/api/ebuilder/common/ds/fields", form);
508
560
  if (json) return r;
509
561
  for (const d of (r.data || [])) {
@@ -514,7 +566,7 @@ async function cmdFields(args, json) {
514
566
  async function cmdList(args, json) {
515
567
  const gid = need("group", args), tid = need("table", args), fld = need("fields", args);
516
568
  const fields = fld.split(",").map((f) => ({ fieldId: f, fieldName: f, objId: String(tid), mainField: true }));
517
- const dto = baseDto(tid, gid, parseInt(args.page || "1", 10), parseInt(args.size || "20", 10), "getListData");
569
+ const dto = await dsDto(args, tid, gid, parseInt(args.page || "1", 10), parseInt(args.size || "20", 10), "getListData");
518
570
  dto.queryFields = fields;
519
571
  dto.orderFields = parseOrder(args.order);
520
572
  const ct = parseWhere(args.where); if (ct) dto.conditionTrees = ct;
@@ -527,7 +579,7 @@ async function cmdList(args, json) {
527
579
  }
528
580
  async function cmdChart(args, json) {
529
581
  const gid = need("group", args), tid = need("table", args), gb = need("group-by", args);
530
- const dto = baseDto(tid, gid, parseInt(args.page || "1", 10), parseInt(args.size || "100", 10), "getChartData");
582
+ const dto = await dsDto(args, tid, gid, parseInt(args.page || "1", 10), parseInt(args.size || "100", 10), "getChartData");
531
583
  dto.groupFields = gb.split(",").map((f) => ({ fieldId: f, fieldName: f, objId: String(tid), mainField: true }));
532
584
  dto.groupStatFields = parseStat(need("stat", args)).map((s) => ({ ...s, objId: String(tid) }));
533
585
  const ct = parseWhere(args.where); if (ct) dto.conditionTrees = ct;
@@ -537,7 +589,7 @@ async function cmdChart(args, json) {
537
589
  }
538
590
  async function cmdStat(args, json) {
539
591
  const gid = need("group", args), tid = need("table", args);
540
- const dto = baseDto(tid, gid, 1, 10, "getStatData");
592
+ const dto = await dsDto(args, tid, gid, 1, 10, "getStatData");
541
593
  dto.statFields = parseStat(need("stat", args)).map((s) => ({ ...s, objId: String(tid) }));
542
594
  const ct = parseWhere(args.where); if (ct) dto.conditionTrees = ct;
543
595
  const r = await postMultipart("/api/dw/newetl/chatBi/ds/getStatDatas", { sourceType: args["source-type"] || "LOGIC", queryDto: dto });
@@ -548,7 +600,7 @@ async function cmdStat(args, json) {
548
600
  }
549
601
  async function cmdCount(args, json) {
550
602
  const gid = need("group", args), tid = need("table", args);
551
- const dto = baseDto(tid, gid, 1, 10, "getCountData");
603
+ const dto = await dsDto(args, tid, gid, 1, 10, "getCountData");
552
604
  const ct = parseWhere(args.where); if (ct) dto.conditionTrees = ct;
553
605
  const r = await postMultipart("/api/dw/newetl/chatBi/ds/getCountData", { sourceType: args["source-type"] || "LOGIC", queryDto: dto });
554
606
  if (json) return r;
@@ -1358,6 +1410,9 @@ ds 数据源(业务模块)取数与元数据
1358
1410
  ds stat --group <gid> --table <tid> --stat '[...]' [--where ...]
1359
1411
  ds count --group <gid> --table <tid> [--where ...]
1360
1412
  (ds 通用 --source-type LOGIC|ETEAMS,默认 LOGIC)
1413
+ (ds 取数 list|chart|stat|count 的 appId:默认自动解析并带上——顺序 chat_bi_eb_config_map(dw 权限配置表,按 obj_id)
1414
+ → ebdf_obj(ec_edcapp,按 id),每次实时查、不缓存;也可 --app-id <id> 显式指定、--app-id auto 强制自动、
1415
+ --no-app-id 完全跳过自动解析(最快,适用于无需 appId 的数据集);ds tables/fields 也接受 --app-id)
1361
1416
  --where 过滤条件(v0.1.8 起支持树形 OR,递归):
1362
1417
  数组 = AND 根: [{"fieldId":"f1","conditionType":"Date","compareType":"range","conditionValue":"2026-09~2026-10"},{"fieldId":"f2",...}]
1363
1418
  对象 = 完整树: {"relationship":"0","conditionList":[{"fieldId":"f1",...},{"fieldId":"f2",...}]} # "0"=OR、"1"=AND,缺省 AND
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "e10-data",
3
- "version": "0.1.10",
4
- "description": "泛微 E10 数据接口统一 CLI(data-assistant 专家配套):DSL 查询/数据源/文档/词库/关联字段翻译/环境参数配置中心(conf,支持 confGroup 分组)/专家包版本管理;认证加解密全部交由 weaver-e10-login(本 CLI 不再自行解密,通过 e10-login 命令出口获取凭据)",
3
+ "version": "0.1.12",
4
+ "description": "泛微 E10 数据接口统一 CLI(data-assistant 专家配套):DSL 查询/数据源/文档/词库/关联字段翻译/环境参数配置中心(conf,支持 confGroup 分组)/专家包版本管理;ds 取数(list/chart/stat/count)自动解析并携带 queryDto.appId(v0.1.12,chat_bi_eb_config_map → ebdf_obj;--app-id 显式/--no-app-id 跳过);认证加解密全部交由 weaver-e10-login(本 CLI 不再自行解密,通过 e10-login 命令出口获取凭据)",
5
5
  "author": "e10-dw",
6
6
  "license": "MIT",
7
7
  "type": "module",