e10-data 0.1.7 → 0.1.9

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.
Files changed (3) hide show
  1. package/README.md +98 -1
  2. package/bin/e10-data.mjs +205 -86
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -19,7 +19,7 @@ e10-data ds tables|fields|list|chart|stat|count 数据源(业务模块
19
19
  e10-data doc count|list 文档查询(documentListCount + documentList)
20
20
  e10-data noun list --skill <skillKey> 词库查询(可带 --source-type/--source-group/--source-table 三参数)
21
21
  e10-data field id2name|name2id 关联字段翻译(testRemoteBrowser / complete)
22
- e10-data conf get|batch|batch-file|resolve|resolve-file|add|add-file|update|delete 环境参数配置中心(chatBi config map,替代 config-resolve 脚本 URL 直连;confType 默认按 CONN_/DS_/WF_ 前缀推导,可 --type 显式)
22
+ e10-data conf get|batch|batch-file|group|group-file|resolve|resolve-file|add|add-file|update|delete 环境参数配置中心(chatBi config map,替代 config-resolve 脚本 URL 直连;confType 默认按 CONN_/DS_/WF_/API_ 前缀推导,可 --type 显式;confType=api 时支持 confGroup 分组,见下)
23
23
  e10-data exp status|manifest|commits|file|pull|init|commit|lock|release|rollback 专家包版本管理
24
24
  e10-data attend statis 考勤假期余额统计 getAttendInfoStatis(hr-attendance 病假/事假等,v0.1.5 新增)
25
25
  ```
@@ -47,12 +47,109 @@ e10-data conf get CONN_EC_EDCAPP # 读配置
47
47
  e10-data conf resolve '{"connId":"#{CONN_EC_EDCAPP}"}' # 占位符替换为真实值
48
48
  e10-data conf add CONN_EC_EDCAPP --value 10 --name "说明" --attrs '{"schema":"ec_edcapp"}'
49
49
  e10-data conf delete CONN_EC_EDCAPP
50
+ # confType=api + confGroup 分组(v0.1.9 新增)
51
+ e10-data conf group api workflow # 按 类型+分组 批量查全部配置
52
+ e10-data conf get GET_WORKFLOW_LIST --type api --group workflow # 单查(组内定位)
53
+ e10-data conf add GET_WORKFLOW_LIST --type api --group workflow --value /api/workflow/getList --name 查询流程列表 --attrs '{"request":{"pageNo":"页码"},"response":{"list":"流程列表"}}'
54
+ e10-data conf add-file @api-items.json # 批量新增(元素含 confGroup,见下)
55
+ e10-data conf update GET_WORKFLOW_LIST --type api --group workflow --value /api/workflow/queryList
56
+ e10-data conf delete GET_WORKFLOW_LIST --type api --group workflow
50
57
  e10-data exp status --expert data-assistant
51
58
  e10-data exp pull --expert data-assistant --dir <本地专家包目录> [--dry-run] [--force]
52
59
  e10-data attend statis # 查当前登录用户当月假期余额(病假/事假/年假)
53
60
  e10-data attend statis --user 6264843388578732287 --begin 2026-09-01 --end 2026-09-30
54
61
  ```
55
62
 
63
+ ## conf 配置中心与 confGroup 分组(v0.1.9 新增)
64
+
65
+ `conf` 系列对接 chatBi config map 接口,`confGroup` 是**可选**的二级分组维度:后端在 `confType=api` 时按 `confType + confGroup + confKey` 定位配置(如 `api/workflow/GET_WORKFLOW_LIST`),用于把同类 API 定义归档到同一分组。
66
+
67
+ **下发规则(重要)**:只有 `confType` 为 `api`(或显式传了 `--group`)时,CLI 才会在请求体/查询串里带上 `confGroup`;其他 confType 一律不带该字段,避免污染既有配置类型。
68
+
69
+ | 操作 | 命令 | 对应接口 |
70
+ |---|---|---|
71
+ | 新增(批量,可含分组) | `conf add <key> --value v [--type api] [--group g]` / `conf add-file @items.json` | `POST /api/dw/newetl/chatBi/batchAddChatBiConfigMap` |
72
+ | 单查 | `conf get <key> [--type api] [--group g]` | `GET /api/dw/newetl/chatBi/getChatBiConfigMap?confType=&confGroup=&confKey=` |
73
+ | 批量查(按 key) | `conf batch <k1> <k2> ...` / `conf batch-file @items.json` | `POST /api/dw/newetl/chatBi/batchGetChatBiConfigMap` |
74
+ | 批量查(按类型+分组) | `conf group <confType> <confGroup> [--key k]` / `conf group-file @items.json` | `POST /api/dw/newetl/chatBi/batchGetChatBiConfigMapByTypeAndGroup` |
75
+ | 更新 | `conf update <key> [--value v] [--name n] [--attrs a] [--group g]` | `POST /api/dw/newetl/chatBi/updateChatBiConfigMap` |
76
+ | 删除 | `conf delete <key> [--type api] [--group g]` | `DELETE /api/dw/newetl/chatBi/deleteChatBiConfigMap?confType=&confGroup=&confKey=` |
77
+
78
+ 批量新增文件 `api-items.json`(`confType=api` 时元素带 `confGroup`):
79
+
80
+ ```json
81
+ [
82
+ {
83
+ "confType": "api",
84
+ "confGroup": "workflow",
85
+ "confKey": "GET_WORKFLOW_LIST",
86
+ "confValue": "/api/workflow/getList",
87
+ "confName": "查询流程列表",
88
+ "confAttrs": "{\"request\":{\"pageNo\":\"页码\",\"pageSize\":\"每页数量\"},\"response\":{\"list\":\"流程列表\"}}"
89
+ },
90
+ {
91
+ "confType": "api",
92
+ "confGroup": "workflow",
93
+ "confKey": "GET_WORKFLOW_DETAIL",
94
+ "confValue": "/api/workflow/getDetail",
95
+ "confName": "查询流程详情",
96
+ "confAttrs": "{\"request\":{\"id\":\"流程ID\"},\"response\":{\"id\":\"流程ID\",\"name\":\"流程名称\"}}"
97
+ }
98
+ ]
99
+ ```
100
+
101
+ ```bash
102
+ e10-data conf add-file @api-items.json # 批量新增(逐条判重:同 组+键 已存在则跳过)
103
+ e10-data conf group api workflow # 取回 workflow 分组下全部 API 配置
104
+ e10-data conf group-file @groups.json # 多分组一次取回,@groups.json = [{"confType":"api","confGroup":"workflow"}]
105
+ e10-data conf update GET_WORKFLOW_LIST --type api --group workflow --value /api/workflow/queryList
106
+ e10-data conf delete GET_WORKFLOW_LIST --type api --group workflow
107
+ ```
108
+
109
+ 补充说明:
110
+
111
+ - `confKey` 前缀推导 confType:`CONN_→conn`、`DS_→ds`、`WF_→wf`、`API_→api`;其余类型用 `--type` 显式指定(`--type` 与 `--group` 可同时使用)。
112
+ - 同一 `confKey` 可存在于多个 `confGroup`;`conf batch` / `batch-file` 的返回映射在带分组时以 `组|键` 为键,不会互相覆盖。
113
+ - `--json` 输出:`conf group` 返回配置数组(带 `--key` 时返回单条),`conf batch` 返回映射对象。
114
+
115
+ ## ds --where 过滤条件(v0.1.8 起支持树形 OR)
116
+
117
+ `e10-data ds list|chart|stat|count --where` 接收**条件数组**或**完整条件树**,均可递归嵌套表达 AND/OR:
118
+
119
+ ```bash
120
+ # ① 数组 = AND 根(旧写法,行为不变):满足全部条件的记录
121
+ e10-data ds count --group <gid> --table <tid> \
122
+ --where '[{"fieldId":"fieldA","compareType":"range","conditionValue":"2026-09~2026-10"},{"fieldId":"fieldB","compareType":"eq","conditionValue":"1"}]'
123
+
124
+ # ② 对象 = 完整条件树:relationship "0"=OR、"1"=AND(缺省 AND),conditionList 内可再嵌套条件组
125
+ e10-data ds count --group <gid> --table <tid> \
126
+ --where '{"relationship":"0","conditionList":[{"fieldId":"fieldA","compareType":"range","conditionValue":"2026-09~2026-10"},{"fieldId":"fieldB","compareType":"range","conditionValue":"2026-09~2026-10"}]}'
127
+
128
+ # ③ 数组元素内嵌条件组 → 复杂组合,如 (A AND B) OR (C AND D)
129
+ e10-data ds list --group <gid> --table <tid> --fields a,b \
130
+ --where @cond.json # 内容见下
131
+ ```
132
+
133
+ ```json
134
+ // cond.json —— 组合条件示例
135
+ [
136
+ { "relationship": "1", "conditionList": [
137
+ { "fieldId": "A", "compareType": "eq", "conditionValue": "x" },
138
+ { "fieldId": "B", "compareType": "eq", "conditionValue": "y" } ] },
139
+ { "relationship": "0", "conditionList": [
140
+ { "fieldId": "C", "compareType": "eq", "conditionValue": "m" },
141
+ { "fieldId": "D", "compareType": "eq", "conditionValue": "n" } ] }
142
+ ]
143
+ ```
144
+
145
+ 要点:
146
+
147
+ - **叶子字段键**:`fieldId` 与 `conditionId` 均可(fieldId 优先),旧树形 `conditionId` 写法兼容;
148
+ - **relationship**:`"0"`/`0`/`false` = OR,其余 = AND;子节点关系作用于其自身 `conditionList`;
149
+ - 数组顶层恒为 AND 根,需要整体 OR 请用对象形态 `{"relationship":"0","conditionList":[...]}`;
150
+ - 叶子缺少字段会**直接报错**(v0.1.8 起,不再静默产生空条件导致误返回全表);
151
+ - 其余条件属性(conditionType/compareType/conditionValue/objId/mainField/ignoreCaseMark 等)照旧透传。
152
+
56
153
  ## exp pull 智能拉取(v0.1.4 新增,防本地修改被覆盖)`exp pull` 不再盲目覆盖。CLI 在专家包本地目录维护基线文件 `.sync-state.json`(记录上次同步的 commitId/headRevision 与每文件 sha256),拉取时逐文件三方对比:
57
154
 
58
155
  | 场景 | 判定 | 处理 |
package/bin/e10-data.mjs CHANGED
@@ -9,8 +9,9 @@
9
9
  * e10-data doc count|list 文档查询 documentListCount / documentList
10
10
  * e10-data noun list 词库 getChatDocsBySkillKey
11
11
  * e10-data field id2name|name2id 关联字段翻译 testRemoteBrowser / complete
12
- * e10-data conf get|batch|batch-file|resolve|resolve-file|add|add-file|update|delete
13
- * 环境参数配置中心(chatBi config map,替代 config-resolve 脚本 URL 直连)
12
+ * e10-data conf get|batch|batch-file|group|group-file|resolve|resolve-file|add|add-file|update|delete
13
+ * 环境参数配置中心(chatBi config map,替代 config-resolve 脚本 URL 直连;
14
+ * confType=api 时支持 confGroup 分组二级定位,见 --group)
14
15
  * e10-data attend statis 考勤假期余额统计 getAttendInfoStatis(hr-attendance 病假/事假,2026-09-07)
15
16
  *
16
17
  * 通用:--json 原样输出;复杂 JSON 参数支持 @文件 或 内联(中文走 @文件 更稳)
@@ -265,6 +266,11 @@ function readJsonArg(val, label) {
265
266
  return parseJsonSafe(raw, label);
266
267
  }
267
268
  function need(arg, args) { if (!args[arg]) throw new Error("缺少必填参数 --" + arg); return args[arg]; }
269
+ // 文件/JSON 参数取值:兼容 --flag <v> 与位置参数 <v>(如 conf add-file @items.json / --add-file @items.json)
270
+ function flagOrPos(args, flag, keys) {
271
+ if (args[flag] !== undefined) return args[flag];
272
+ return keys && keys.length ? keys[0] : undefined;
273
+ }
268
274
 
269
275
  // ---------------- 展示 ----------------
270
276
  function fmt(v) {
@@ -321,21 +327,43 @@ function dyn() {
321
327
  function baseDto(tableId, groupId, pageNo, pageSize, queryType) {
322
328
  return { tableId: String(tableId), groupId, pageNo, pageSize, queryType, containDetailTable: false, needFormat: true, dynamicParams: dyn() };
323
329
  }
330
+ // 条件树(conditionTrees)协议:根/组节点 { key, relationship("1"=AND|"0"=OR), isParent:true, parentNode, conditionList:[...] }
331
+ // 叶子节点 { key, relationship:"1", isParent:false, parentNode, conditionId, conditionType, compareType, conditionValue, ... }
332
+ // v0.1.8 起 parseWhere 支持递归树(OR);向后兼容:数组=AND 根、叶子键 fieldId 优先(conditionId 兼容兜底)
333
+ function normRel(r) { return (r === "0" || r === 0 || r === false) ? "0" : "1"; }
334
+ function isCondGroup(c) { return !!c && Array.isArray(c.conditionList) && c.conditionList.length > 0; }
335
+ function buildCondNode(c, key, parentKey) {
336
+ if (isCondGroup(c)) {
337
+ return {
338
+ key, relationship: normRel(c.relationship), isParent: true, parentNode: parentKey,
339
+ mainField: c.mainField !== false,
340
+ conditionList: c.conditionList.map((k, i) => buildCondNode(k, key + "_" + i, key)),
341
+ };
342
+ }
343
+ const fid = (c && (c.fieldId || c.conditionId)) || "";
344
+ if (!fid) throw new Error("--where 条件缺少字段:叶子须提供 fieldId(或 conditionId),条件组须提供非空 conditionList");
345
+ return {
346
+ key, relationship: "1", isParent: false, parentNode: parentKey,
347
+ objId: c.objId || "", conditionId: fid, fieldName: c.fieldName || fid,
348
+ conditionType: c.conditionType || "", compareType: c.compareType, conditionValue: c.conditionValue ?? "",
349
+ fieldValue: c.fieldValue || "", mainField: c.mainField !== false, ignoreCaseMark: c.ignoreCaseMark || false,
350
+ };
351
+ }
324
352
  function parseWhere(val) {
325
353
  if (!val) return null;
326
- const arr = readJsonArg(val, "--where");
327
- const list = Array.isArray(arr) ? arr : (arr.conditionList || []);
328
- if (!list.length) return null;
354
+ const raw = readJsonArg(val, "--where");
355
+ if (!raw) return null;
329
356
  const ts = Date.now(), rootKey = "root_" + ts;
330
- return {
331
- key: rootKey, relationship: "1", isParent: true, parentNode: "", mainField: true,
332
- conditionList: list.map((c, i) => ({
333
- key: rootKey + "_" + i, relationship: "1", isParent: false, parentNode: rootKey,
334
- objId: c.objId || "", conditionId: c.fieldId, fieldName: c.fieldName || c.fieldId,
335
- conditionType: c.conditionType || "", compareType: c.compareType, conditionValue: c.conditionValue ?? "",
336
- fieldValue: c.fieldValue || "", mainField: c.mainField !== false, ignoreCaseMark: c.ignoreCaseMark || false,
337
- })),
338
- };
357
+ if (Array.isArray(raw)) { // 数组 → AND 根(元素可为叶子或内嵌条件组,组自带 relationship)
358
+ const kids = [];
359
+ raw.forEach((c, i) => { if (c && typeof c === "object") kids.push(buildCondNode(c, rootKey + "_" + i, rootKey)); });
360
+ if (!kids.length) return null;
361
+ return { key: rootKey, relationship: "1", isParent: true, parentNode: "", mainField: true, conditionList: kids };
362
+ }
363
+ if (typeof raw !== "object") throw new Error("--where 须为条件数组或条件树对象");
364
+ // 对象形态 = 完整条件树({relationship, conditionList:[...]},缺省 AND);无 conditionList 视为无条件
365
+ if (!Array.isArray(raw.conditionList) || !raw.conditionList.length) return null;
366
+ return buildCondNode(raw, rootKey, "");
339
367
  }
340
368
  function parseStat(val) {
341
369
  const arr = readJsonArg(val, "--stat");
@@ -531,13 +559,21 @@ async function cmdFieldName2id(args, json) {
531
559
  }
532
560
 
533
561
  // ---------------- conf:环境参数配置中心(chatBi config map) ----------------
534
- // 覆盖 config-resolve 原 resolve_config.py 的 URL 直连调用:get/batch/batch-file/resolve/resolve-file
562
+ // 覆盖 config-resolve 原 resolve_config.py 的 URL 直连调用:get/batch/batch-file/group/group-file/resolve/resolve-file
535
563
  // 与管理 add/add-file/update/delete。认证复用进程内登录缓存(完整 Cookie + eteamsid,同 query/ds/doc),
536
564
  // 无内置令牌;baseUrl 取登录缓存(与 executeQueryDsl 同域)。confType 默认由 key 前缀推导
537
- // (CONN_→conn / DS_→ds / WF_→wf),可用 --type 显式指定任意大类(如 data-source-query / system-config)。
538
- const CONF_PREFIX_TYPE = [["CONN_", "conn"], ["DS_", "ds"], ["WF_", "wf"]];
565
+ // (CONN_→conn / DS_→ds / WF_→wf / API_→api),可用 --type 显式指定任意大类(如 data-source-query / system-config)。
566
+ //
567
+ // v0.1.9 confGroup(配置分组,可选):
568
+ // 后端在 confType=api 时支持按分组二次分层(如 api/workflow、api/hr),定位维度变为
569
+ // 「confType + confGroup + confKey」。本 CLI 统一用 --group 传分组:
570
+ // · confType 为 api(或显式传了 --group)时,新增/更新/删除/单查 才下发 confGroup 字段,
571
+ // 其他 confType 一律不带该字段,避免污染既有(无分组列)的配置类型。
572
+ // · conf group <confType> <confGroup> 走 batchGetChatBiConfigMapByTypeAndGroup 按类型+分组批量取回。
573
+ const CONF_PREFIX_TYPE = [["CONN_", "conn"], ["DS_", "ds"], ["WF_", "wf"], ["API_", "api"]];
539
574
  const CONF_GET_PATH = "/api/dw/newetl/chatBi/getChatBiConfigMap";
540
575
  const CONF_BATCH_PATH = "/api/dw/newetl/chatBi/batchGetChatBiConfigMap";
576
+ const CONF_BATCH_GROUP_PATH = "/api/dw/newetl/chatBi/batchGetChatBiConfigMapByTypeAndGroup";
541
577
  const CONF_ADD_PATH = "/api/dw/newetl/chatBi/batchAddChatBiConfigMap";
542
578
  const CONF_UPDATE_PATH = "/api/dw/newetl/chatBi/updateChatBiConfigMap";
543
579
  const CONF_DELETE_PATH = "/api/dw/newetl/chatBi/deleteChatBiConfigMap";
@@ -545,7 +581,25 @@ const CONF_TOKEN_RE = /#\{([A-Z][A-Z0-9_]{2,})\}/g;
545
581
  function confKeyType(key, explicitType) {
546
582
  if (explicitType) return explicitType;
547
583
  for (const [p, t] of CONF_PREFIX_TYPE) if (key.startsWith(p)) return t;
548
- throw new Error("无法由 confKey 推导 confType(需 CONN_/DS_/WF_ 前缀或显式 --type): " + key);
584
+ throw new Error("无法由 confKey 推导 confType(需 CONN_/DS_/WF_/API_ 前缀或显式 --type): " + key);
585
+ }
586
+ // confGroup 仅在 confType=api 或调用方显式指定时下发(见上方说明)
587
+ function confUseGroup(ctype, group) {
588
+ return ctype === "api" || (group !== undefined && group !== null && group !== "");
589
+ }
590
+ function confPutGroup(body, ctype, group) {
591
+ if (confUseGroup(ctype, group)) body.confGroup = group === undefined || group === null ? "" : String(group);
592
+ return body;
593
+ }
594
+ function confGroupSuffix(ctype, group) { // GET/DELETE 用的 query 后缀
595
+ return confUseGroup(ctype, group) ? "&confGroup=" + encodeURIComponent(group === undefined || group === null ? "" : String(group)) : "";
596
+ }
597
+ function confItemId(it) { // 同 confKey 可分布在多个 confGroup,带分组时用「组|键」做映射键,避免互相覆盖
598
+ const g = it && it.confGroup;
599
+ return g ? g + "|" + (it.confKey || "") : ((it && it.confKey) || "");
600
+ }
601
+ function confLookup(map, it) { // 兼容后端回包是否带 confGroup:先按「组|键」取,再退化到 confKey
602
+ return map[confItemId(it)] || map[it.confKey];
549
603
  }
550
604
  function confFail(j, url) {
551
605
  const m = (j && (j.msg || (j.actionMsg && j.actionMsg.message))) || "";
@@ -570,51 +624,62 @@ async function confRequest(method, url, bodyObj) {
570
624
  checkAuthFail(resp, text, j);
571
625
  return j;
572
626
  }
573
- async function confGetData(ctype, key, silent) {
574
- const url = CONF_GET_PATH + "?confType=" + encodeURIComponent(ctype) + "&confKey=" + encodeURIComponent(key);
627
+ async function confGetData(ctype, key, silent, group) {
628
+ const url = CONF_GET_PATH + "?confType=" + encodeURIComponent(ctype) + "&confKey=" + encodeURIComponent(key) + confGroupSuffix(ctype, group);
575
629
  let r;
576
630
  try { r = await confRequest("GET", url); }
577
631
  catch (e) { if (silent) return null; throw e; }
578
632
  const data = (r && r.data) || null;
579
633
  if (!silent && (!data || data.confValue === undefined || data.confValue === null || data.confValue === "")) {
580
- throw new Error("配置不存在或为空: confType=" + ctype + " confKey=" + key);
634
+ throw new Error("配置不存在或为空: confType=" + ctype + (group ? " confGroup=" + group : "") + " confKey=" + key);
581
635
  }
582
636
  return data;
583
637
  }
584
638
  function confNormalizeBatch(payload) {
585
639
  const data = (payload && payload.data) || null;
586
640
  const out = {};
587
- if (Array.isArray(data)) {
588
- for (const row of data) {
589
- if (!row || typeof row !== "object") continue;
590
- const k = row.confKey || row.conf_key;
591
- if (k) out[k] = row;
592
- }
593
- } else if (data && typeof data === "object") {
594
- for (const [k, v] of Object.entries(data)) {
595
- if (v && typeof v === "object" && !v.confKey) v.confKey = k;
596
- out[k] = v;
597
- }
598
- }
641
+ const put = (row, fallbackKey) => {
642
+ if (!row || typeof row !== "object") return;
643
+ const k = row.confKey || row.conf_key || fallbackKey;
644
+ if (!k) return;
645
+ if (row.confGroup === undefined) { const g = row.conf_group; if (g !== undefined && g !== null && g !== "") row.confGroup = g; }
646
+ out[confItemId({ confGroup: row.confGroup, confKey: k })] = row;
647
+ };
648
+ if (Array.isArray(data)) for (const row of data) put(row);
649
+ else if (data && typeof data === "object") for (const [k, v] of Object.entries(data)) put(v, k);
599
650
  return out;
600
651
  }
652
+ // 按类型+分组批量取回(batchGetChatBiConfigMapByTypeAndGroup),payload = [{confType, confGroup}...]
653
+ async function confBatchByTypeAndGroup(pairs) {
654
+ const payload = pairs.map((p) => ({ confType: p.confType, confGroup: p.confGroup === undefined || p.confGroup === null ? "" : String(p.confGroup) }));
655
+ const r = await confRequest("POST", CONF_BATCH_GROUP_PATH, payload);
656
+ return confNormalizeBatch(r);
657
+ }
601
658
  async function cmdConfGet(args, json, keys) {
602
659
  const key = keys[0];
603
- if (!key) throw new Error("conf get 缺少 confKey(用法: conf get <key> [--type t])");
660
+ if (!key) throw new Error("conf get 缺少 confKey(用法: conf get <key> [--type t] [--group g])");
604
661
  const ctype = confKeyType(key, args.type);
605
- const data = await confGetData(ctype, key);
662
+ let data;
663
+ try {
664
+ data = await confGetData(ctype, key, false, args.group);
665
+ } catch (e) {
666
+ if (ctype === "api" && !args.group) {
667
+ throw new Error(e.message + "(confType=api 建议用 --group 指定分组,如 --group workflow;或用 conf group api <分组> 查看该分组下全部配置)");
668
+ }
669
+ throw e;
670
+ }
606
671
  if (json) return data;
607
672
  console.log(JSON.stringify(data, null, 1));
608
673
  }
609
674
  async function cmdConfBatch(args, json, keys) {
610
- if (!keys.length) throw new Error("conf batch 缺少 confKey 列表(用法: conf batch <key1> [key2 ...])");
611
- const items = keys.map((k) => ({ confType: confKeyType(k, args.type), confKey: k }));
675
+ if (!keys.length) throw new Error("conf batch 缺少 confKey 列表(用法: conf batch <key1> [key2 ...] [--type t] [--group g])");
676
+ const items = keys.map((k) => { const t = confKeyType(k, args.type); return confPutGroup({ confType: t, confKey: k }, t, args.group); });
612
677
  let map = {};
613
678
  try {
614
679
  const r = await confRequest("POST", CONF_BATCH_PATH, items);
615
680
  map = confNormalizeBatch(r);
616
681
  for (const it of items) {
617
- const c = map[it.confKey];
682
+ const c = confLookup(map, it);
618
683
  if (!c || c.confValue === undefined || c.confValue === null || c.confValue === "") {
619
684
  throw new Error("批量响应缺失 confKey=" + it.confKey);
620
685
  }
@@ -623,43 +688,82 @@ async function cmdConfBatch(args, json, keys) {
623
688
  if (String(e.message).indexOf("批量响应缺失") === 0) throw e;
624
689
  console.error("[config-resolve] 批量接口不可用,降级逐条单查: " + e.message);
625
690
  map = {};
626
- for (const it of items) map[it.confKey] = await confGetData(it.confType, it.confKey);
691
+ for (const it of items) map[confItemId(it)] = await confGetData(it.confType, it.confKey, false, it.confGroup);
627
692
  }
628
693
  if (json) return map;
629
- printHuman("配置 " + items.length + " 条", keys.map((k) => ({ key: k, confType: items.find((x) => x.confKey === k).confType, confValue: (map[k] || {}).confValue ?? "", confName: (map[k] || {}).confName ?? "" })), ["key", "confType", "confValue", "confName"]);
630
- }
631
- async function cmdConfBatchFile(args, json) {
632
- if (!args["batch-file"]) throw new Error("conf batch-file 缺少参数(用法: conf batch-file @items.json)");
633
- const items = readJsonArg(args["batch-file"], "--batch-file");
694
+ printHuman("配置 " + items.length + " 条", keys.map((k) => {
695
+ const it = items.find((x) => x.confKey === k);
696
+ const c = confLookup(map, it) || {};
697
+ return { key: k, confType: it.confType, confGroup: it.confGroup ?? "", confValue: c.confValue ?? "", confName: c.confName ?? "" };
698
+ }), ["key", "confType", "confGroup", "confValue", "confName"]);
699
+ }
700
+ async function cmdConfBatchFile(args, json, keys) {
701
+ const val = flagOrPos(args, "batch-file", keys);
702
+ if (val === undefined) throw new Error("conf batch-file 缺少参数(用法: conf batch-file @items.json)");
703
+ const items = readJsonArg(String(val), "--batch-file");
634
704
  const list = Array.isArray(items) ? items : [items];
635
705
  const map = {};
706
+ const meta = {};
636
707
  for (const it of list) {
637
708
  if (!it.confKey || !it.confType) continue;
638
- map[it.confKey] = await confGetData(it.confType, it.confKey);
709
+ const id = confItemId(it);
710
+ map[id] = await confGetData(it.confType, it.confKey, false, it.confGroup);
711
+ meta[id] = it;
639
712
  }
640
713
  if (json) return map;
641
- printHuman("配置 " + Object.keys(map).length + " 条", Object.keys(map).map((k) => ({ key: k, confValue: (map[k] || {}).confValue ?? "", confName: (map[k] || {}).confName ?? "" })), ["key", "confValue", "confName"]);
714
+ printHuman("配置 " + Object.keys(map).length + " 条", Object.keys(map).map((id) => ({ key: meta[id].confKey, confGroup: meta[id].confGroup ?? "", confValue: (map[id] || {}).confValue ?? "", confName: (map[id] || {}).confName ?? "" })), ["key", "confGroup", "confValue", "confName"]);
715
+ }
716
+ // 按类型+分组批量查(batchGetChatBiConfigMapByTypeAndGroup):pairs = [{confType, confGroup}...]
717
+ async function cmdConfGroup(args, json, keys) {
718
+ const ctype = keys[0] || args.type;
719
+ const group = keys[1] !== undefined ? keys[1] : args.group;
720
+ if (!ctype) throw new Error("conf group 缺少 confType(用法: conf group <confType> <confGroup> | --type api --group workflow)");
721
+ if (group === undefined) throw new Error("conf group 缺少 confGroup(用法: conf group <confType> <confGroup>)");
722
+ const map = await confBatchByTypeAndGroup([{ confType: ctype, confGroup: group }]);
723
+ const rows = Object.values(map);
724
+ const onlyKey = args.key;
725
+ const filtered = onlyKey ? rows.filter((r) => (r.confKey || r.conf_key) === onlyKey) : rows;
726
+ if (json) return onlyKey ? (filtered[0] ?? null) : filtered;
727
+ if (onlyKey && !filtered.length) throw new Error("配置不存在: confType=" + ctype + " confGroup=" + group + " confKey=" + onlyKey);
728
+ printHuman("confType=" + ctype + " confGroup=" + group + " 配置 " + filtered.length + " 条",
729
+ filtered.map((r) => ({ confKey: r.confKey || r.conf_key || "", confValue: r.confValue ?? "", confName: r.confName ?? "", confAttrs: r.confAttrs ?? "" })),
730
+ ["confKey", "confValue", "confName", "confAttrs"]);
731
+ return filtered;
732
+ }
733
+ async function cmdConfGroupFile(args, json, keys) {
734
+ const val = flagOrPos(args, "group-file", keys);
735
+ if (val === undefined) throw new Error("conf group-file 缺少参数(用法: conf group-file @items.json,形如 [{\"confType\":\"api\",\"confGroup\":\"workflow\"}])");
736
+ const pairs = readJsonArg(String(val), "--group-file");
737
+ const list = (Array.isArray(pairs) ? pairs : [pairs]).filter((p) => p && p.confType);
738
+ if (!list.length) throw new Error("conf group-file 内容为空或缺少 confType");
739
+ const map = await confBatchByTypeAndGroup(list);
740
+ const rows = Object.values(map);
741
+ if (json) return map;
742
+ printHuman("批量分组配置 " + rows.length + " 条",
743
+ rows.map((r) => ({ confType: r.confType ?? "", confGroup: r.confGroup ?? "", confKey: r.confKey || r.conf_key || "", confValue: r.confValue ?? "", confName: r.confName ?? "" })),
744
+ ["confType", "confGroup", "confKey", "confValue", "confName"]);
745
+ return map;
642
746
  }
643
- async function confResolveAll(keys) {
747
+ async function confResolveAll(keys, group) {
644
748
  // 多占位符:先批量预取一轮(失败降级逐条单查),返回 {key: data}
645
- const items = keys.map((k) => ({ confType: confKeyType(k, ""), confKey: k }));
749
+ const items = keys.map((k) => confPutGroup({ confType: confKeyType(k, ""), confKey: k }, confKeyType(k, ""), group));
646
750
  const map = {};
647
751
  try {
648
752
  const r = await confRequest("POST", CONF_BATCH_PATH, items);
649
753
  const got = confNormalizeBatch(r);
650
754
  for (const it of items) {
651
- const c = got[it.confKey];
755
+ const c = confLookup(got, it);
652
756
  if (!c || c.confValue === undefined || c.confValue === null || c.confValue === "") throw new Error("缺失 " + it.confKey);
653
757
  map[it.confKey] = c;
654
758
  }
655
759
  } catch {
656
- for (const it of items) map[it.confKey] = await confGetData(it.confType, it.confKey);
760
+ for (const it of items) map[it.confKey] = await confGetData(it.confType, it.confKey, false, it.confGroup);
657
761
  }
658
762
  return map;
659
763
  }
660
- async function confResolveText(text, json) {
764
+ async function confResolveText(text, json, group) {
661
765
  const found = [...new Set([...text.matchAll(CONF_TOKEN_RE)].map((m) => m[1]))];
662
- const map = found.length ? await confResolveAll(found) : {};
766
+ const map = found.length ? await confResolveAll(found, group) : {};
663
767
  const out = text.replace(CONF_TOKEN_RE, (m0, k) => {
664
768
  const cfg = map[k];
665
769
  if (!cfg) throw new Error("配置不存在或为空: " + k);
@@ -670,45 +774,47 @@ async function confResolveText(text, json) {
670
774
  }
671
775
  async function cmdConfResolve(args, json, keys) {
672
776
  let text = keys[0];
673
- if (!text) throw new Error("conf resolve 缺少文本(用法: conf resolve '<含#{KEY}文本>' | @file.txt)");
777
+ if (!text) throw new Error("conf resolve 缺少文本(用法: conf resolve '<含#{KEY}文本>' | @file.txt [--group g])");
674
778
  if (text.startsWith("@")) text = fs.readFileSync(text.slice(1), "utf-8");
675
- const out = await confResolveText(text, json);
779
+ const out = await confResolveText(text, json, args.group);
676
780
  if (json) { console.log(JSON.stringify(out, null, 1)); return out; }
677
781
  process.stdout.write(out + "\n");
678
782
  }
679
- async function cmdConfResolveFile(args, json) {
680
- const p = args["resolve-file"];
681
- if (!p) throw new Error("conf resolve-file 缺少文件路径(用法: conf resolve-file <文件路径>)");
783
+ async function cmdConfResolveFile(args, json, keys) {
784
+ const p = flagOrPos(args, "resolve-file", keys);
785
+ if (!p) throw new Error("conf resolve-file 缺少文件路径(用法: conf resolve-file <文件路径> [--group g])");
682
786
  if (!fs.existsSync(p)) throw new Error("文件不存在: " + p);
683
787
  const text = fs.readFileSync(p, "utf-8");
684
- const out = await confResolveText(text, json);
788
+ const out = await confResolveText(text, json, args.group);
685
789
  if (json) { console.log(JSON.stringify(out, null, 1)); return out; }
686
790
  process.stdout.write(out + "\n");
687
791
  }
688
792
  async function cmdConfAdd(args, json, keys) {
689
793
  const key = keys[0];
690
- if (!key || args.value === undefined) throw new Error("conf add 缺少 confKey/confValue(用法: conf add <key> --value <真实值> [--name] [--attrs] [--type] [--force])");
794
+ if (!key || args.value === undefined) throw new Error("conf add 缺少 confKey/confValue(用法: conf add <key> --value <真实值> [--name] [--attrs] [--type] [--group] [--force])");
691
795
  const ctype = confKeyType(key, args.type);
692
- if (!args.force && await confGetData(ctype, key, true)) {
796
+ if (!args.force && await confGetData(ctype, key, true, args.group)) {
693
797
  console.error("[config-resolve] 配置已存在,跳过新增(如需修改请用 conf update;确需重建可先 conf delete): " + key);
694
798
  return null;
695
799
  }
696
- const item = { confType: ctype, confKey: key, confValue: String(args.value), confAttrs: args.attrs || "", confName: args.name || "" };
800
+ const item = confPutGroup({ confType: ctype, confKey: key, confValue: String(args.value), confAttrs: args.attrs || "", confName: args.name || "" }, ctype, args.group);
697
801
  const r = await confRequest("POST", CONF_ADD_PATH, [item]);
698
802
  if (json) return r;
699
- console.log("新增成功: " + key + " = " + item.confValue);
803
+ console.log("新增成功: " + (item.confGroup ? item.confGroup + "/" : "") + key + " = " + item.confValue);
700
804
  }
701
- async function cmdConfAddFile(args, json) {
702
- if (args["add-file"] === undefined) throw new Error("conf add-file 缺少参数(用法: conf add-file @items.json)");
703
- const items = readJsonArg(args["add-file"], "--add-file");
805
+ async function cmdConfAddFile(args, json, keys) {
806
+ const val = flagOrPos(args, "add-file", keys);
807
+ if (val === undefined) throw new Error("conf add-file 缺少参数(用法: conf add-file @items.json,元素形如 {confType,confGroup,confKey,confValue,confName,confAttrs})");
808
+ const items = readJsonArg(String(val), "--add-file");
704
809
  const list = Array.isArray(items) ? items : [items];
705
810
  const toAdd = [];
706
811
  for (const it of list) {
707
812
  if (!it.confKey || it.confValue === undefined) continue;
708
813
  const ctype = it.confType || confKeyType(it.confKey, args.type);
709
- const dup = await confGetData(ctype, it.confKey, true);
814
+ const group = it.confGroup !== undefined ? it.confGroup : args.group;
815
+ const dup = await confGetData(ctype, it.confKey, true, group);
710
816
  if (dup) { console.error("[config-resolve] 已存在跳过: " + it.confKey); continue; }
711
- toAdd.push({ confType: ctype, confKey: it.confKey, confValue: String(it.confValue), confAttrs: it.confAttrs || "", confName: it.confName || "" });
817
+ toAdd.push(confPutGroup({ confType: ctype, confKey: it.confKey, confValue: String(it.confValue), confAttrs: it.confAttrs || "", confName: it.confName || "" }, ctype, group));
712
818
  }
713
819
  if (!toAdd.length) { console.log("全部已存在,无新增"); return null; }
714
820
  const r = await confRequest("POST", CONF_ADD_PATH, toAdd);
@@ -717,37 +823,40 @@ async function cmdConfAddFile(args, json) {
717
823
  }
718
824
  async function cmdConfUpdate(args, json, keys) {
719
825
  const key = keys[0];
720
- if (!key) throw new Error("conf update 缺少 confKey(用法: conf update <key> [--value v] [--name n] [--attrs a] [--type t])");
826
+ if (!key) throw new Error("conf update 缺少 confKey(用法: conf update <key> [--value v] [--name n] [--attrs a] [--type t] [--group g])");
721
827
  if (args.value === undefined && args.name === undefined && args.attrs === undefined) {
722
828
  throw new Error("conf update 至少需提供 --value / --name / --attrs 之一");
723
829
  }
724
- const body = { confType: confKeyType(key, args.type), confKey: key };
830
+ const ctype = confKeyType(key, args.type);
831
+ const body = confPutGroup({ confType: ctype, confKey: key }, ctype, args.group);
725
832
  if (args.value !== undefined) body.confValue = String(args.value);
726
833
  if (args.name !== undefined) body.confName = args.name;
727
834
  if (args.attrs !== undefined) body.confAttrs = args.attrs;
728
835
  const r = await confRequest("POST", CONF_UPDATE_PATH, body);
729
836
  if (json) return r;
730
- console.log("更新成功: " + key);
837
+ console.log("更新成功: " + (body.confGroup ? body.confGroup + "/" : "") + key);
731
838
  }
732
839
  async function cmdConfDelete(args, json, keys) {
733
840
  const key = keys[0];
734
- if (!key) throw new Error("conf delete 缺少 confKey(用法: conf delete <key> [--type t])");
841
+ if (!key) throw new Error("conf delete 缺少 confKey(用法: conf delete <key> [--type t] [--group g])");
735
842
  const ctype = confKeyType(key, args.type);
736
- const url = CONF_DELETE_PATH + "?confType=" + encodeURIComponent(ctype) + "&confKey=" + encodeURIComponent(key);
843
+ const url = CONF_DELETE_PATH + "?confType=" + encodeURIComponent(ctype) + "&confKey=" + encodeURIComponent(key) + confGroupSuffix(ctype, args.group);
737
844
  const r = await confRequest("DELETE", url);
738
845
  if (json) return r;
739
- console.log("删除成功: " + key);
846
+ console.log("删除成功: " + (confUseGroup(ctype, args.group) && args.group ? args.group + "/" : "") + key);
740
847
  }
741
848
  async function cmdConf(sub, args, json, pos) {
742
849
  const keys = pos.slice(2);
743
850
  switch (sub) {
744
851
  case "get": return cmdConfGet(args, json, keys);
745
852
  case "batch": return cmdConfBatch(args, json, keys);
746
- case "batch-file": return cmdConfBatchFile(args, json);
853
+ case "batch-file": return cmdConfBatchFile(args, json, keys);
854
+ case "group": return cmdConfGroup(args, json, keys);
855
+ case "group-file": return cmdConfGroupFile(args, json, keys);
747
856
  case "resolve": return cmdConfResolve(args, json, keys);
748
- case "resolve-file": return cmdConfResolveFile(args, json);
857
+ case "resolve-file": return cmdConfResolveFile(args, json, keys);
749
858
  case "add": return cmdConfAdd(args, json, keys);
750
- case "add-file": return cmdConfAddFile(args, json);
859
+ case "add-file": return cmdConfAddFile(args, json, keys);
751
860
  case "update": return cmdConfUpdate(args, json, keys);
752
861
  case "delete": return cmdConfDelete(args, json, keys);
753
862
  default: usage(); process.exit(1);
@@ -1133,6 +1242,11 @@ ds 数据源(业务模块)取数与元数据
1133
1242
  ds stat --group <gid> --table <tid> --stat '[...]' [--where ...]
1134
1243
  ds count --group <gid> --table <tid> [--where ...]
1135
1244
  (ds 通用 --source-type LOGIC|ETEAMS,默认 LOGIC)
1245
+ --where 过滤条件(v0.1.8 起支持树形 OR,递归):
1246
+ 数组 = AND 根: [{"fieldId":"f1","conditionType":"Date","compareType":"range","conditionValue":"2026-09~2026-10"},{"fieldId":"f2",...}]
1247
+ 对象 = 完整树: {"relationship":"0","conditionList":[{"fieldId":"f1",...},{"fieldId":"f2",...}]} # "0"=OR、"1"=AND,缺省 AND
1248
+ 数组元素可内嵌条件组 {"relationship":"0","conditionList":[...]} 实现 (A AND B) OR (C AND D)
1249
+ 叶子键 fieldId/conditionId 均可(fieldId 优先);缺少字段的叶子会直接报错(不再静默当全表)
1136
1250
  doc 文档查询
1137
1251
  doc count [--name 关键词] [--creator id1,id2] [--author id1,id2] [--content-type office] [--time "起~止"] [--last-time "起~止"] [--folder id,id|--folder-neq id,id]
1138
1252
  doc list [同上条件] [--all 翻页到底] [--page N] [--size 100]
@@ -1141,16 +1255,21 @@ noun 词库查询
1141
1255
  field 关联字段翻译
1142
1256
  field id2name --module <m> --type <t> --ids id1,id2 [--form-param '{"fieldId":"..","module":"ebuilderform"}'|--eb-browser-param '{..}'|--property-type x]
1143
1257
  field name2id --module <m> --type <t> --name 名称 [同上附加参数]
1144
- conf 环境参数配置中心(chatBi config map,替代 config-resolve 脚本 URL 直连;confType 默认由 CONN_/DS_/WF_ 前缀推导,可 --type 显式)
1145
- conf get <key> [--type t] # 单查(confValue/confAttrs/confName 全量 JSON)
1146
- conf batch <key1> [key2 ...] # 批量查(批量接口异常自动降级逐条单查)
1147
- conf batch-file @items.json # 按 [{confType,confKey}..] 显式批量查(支持任意 confType)
1148
- conf resolve '<含#{KEY}文本>'|@file.txt # 文本占位符替换为真实值(含中文建议 @file)
1149
- conf resolve-file <文件路径> # 读文件替换全部占位符并打印(不改写原文件)
1150
- conf add <key> --value <真实值> [--name 说明] [--attrs '{"schema":..}'] [--type t] [--force] # 新增(默认判重,已存在跳过)
1151
- conf add-file @items.json # JSON 数组批量新增(逐条判重)
1152
- conf update <key> [--value v] [--name n] [--attrs a] [--type t] # 更新(confType+confKey 定位,传哪个字段更哪个)
1153
- conf delete <key> [--type t] # 删除
1258
+ conf 环境参数配置中心(chatBi config map,替代 config-resolve 脚本 URL 直连;confType 默认由 CONN_/DS_/WF_/API_ 前缀推导,可 --type 显式)
1259
+ confGroup(配置分组,v0.1.9 新增,可选):confType=api 时后端支持二级分层(如 api/workflow),
1260
+ 定位维度 = confType+confGroup+confKey;仅 confType=api(或显式传 --group)时才下发 confGroup,其他类型不带该字段
1261
+ conf get <key> [--type t] [--group g] # 单查(confValue/confAttrs/confName 全量 JSON)
1262
+ conf batch <key1> [key2 ...] [--type t] [--group g] # 批量查(批量接口异常自动降级逐条单查)
1263
+ conf batch-file @items.json # 按 [{confType,confGroup,confKey}..] 显式批量查(支持任意 confType)
1264
+ conf group <confType> <confGroup> [--key k] # 按类型+分组批量查(batchGetChatBiConfigMapByTypeAndGroup)
1265
+ conf group-file @items.json # 按 [{"confType":"api","confGroup":"workflow"}..] 多分组批量查
1266
+ conf resolve '<含#{KEY}文本>'|@file.txt [--group g] # 文本占位符替换为真实值(含中文建议 @file)
1267
+ conf resolve-file <文件路径> [--group g] # 读文件替换全部占位符并打印(不改写原文件)
1268
+ conf add <key> --value <真实值> [--name 说明] [--attrs '{"request":..,"response":..}'] [--type t] [--group g] [--force] # 新增(默认判重,已存在跳过)
1269
+ conf add-file @items.json # JSON 数组批量新增(逐条判重,元素可带 confGroup)
1270
+ conf update <key> [--value v] [--name n] [--attrs a] [--type t] [--group g] # 更新(confType+confGroup+confKey 定位,传哪个字段更哪个)
1271
+ conf delete <key> [--type t] [--group g] # 删除
1272
+ 示例: conf group api workflow | conf add GET_WORKFLOW_LIST --type api --group workflow --value /api/workflow/getList --name 查询流程列表
1154
1273
  exp 专家包版本管理(expert-repository/v1,响应以 data.actionMsg.code=0 判成功)
1155
1274
  exp status --expert <code> [--branch main] # 仓库状态(headCommitId/headRevision=提交基线)
1156
1275
  exp manifest --expert <code> [--commit <id>] # 文件清单(sha256)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "e10-data",
3
- "version": "0.1.7",
4
- "description": "泛微 E10 数据接口统一 CLI(data-assistant 专家配套):DSL 查询/数据源/文档/词库/关联字段翻译/环境参数配置中心(conf)/专家包版本管理,认证复用 weaver-e10-login 登录态",
3
+ "version": "0.1.9",
4
+ "description": "泛微 E10 数据接口统一 CLI(data-assistant 专家配套):DSL 查询/数据源/文档/词库/关联字段翻译/环境参数配置中心(conf,支持 confGroup 分组)/专家包版本管理,认证复用 weaver-e10-login 登录态",
5
5
  "author": "e10-dw",
6
6
  "license": "MIT",
7
7
  "type": "module",