e10-data 0.1.26 → 0.1.27

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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # 变更记录
2
2
 
3
+ ## 0.1.27(2026-10-15)—— 新增 `noun scope`:词库按生效范围批量检索
4
+
5
+ ### 1. `noun` 族新增子命令 `scope`
6
+
7
+ - 端点:`POST /api/dw/newetl/chatBi/doc/getChatBiDocByScopeId`,**请求体 = 数据集 id 的 JSON 数组**(`List<Long>`,必填非空)。
8
+ - 入参(`--ids <id1,id2|@ids.json>`)= **数据集 id 列表**,即 `e10-data scene items --group <分组id>` 输出里每个条目的 `id`
9
+ (`ChatBiDataset.id`;接口条目与数据源条目同等适用)。支持逗号分隔或 `@文件`(JSON 数组或逗号串,沿用 `readListArg`)。
10
+ - **id 一律按字符串下发**:19 位雪花号超出 JS 安全整数(2^53),`Number()` 会丢精度
11
+ (实测 `Number("1060565684758507544")` 末位归零)→ 下发即检不到、且**不报错**,故 JSON 数组元素用字符串形态。
12
+ - 命中范围(服务端):`deleteType=0` 且同租户 且(`allScope=1` 全局词库 **或** `scopeEffectId LIKE '%<任一传入 id>%'`)
13
+ ⇒ **全局词库恒返回**,与传入哪些 id 无关。
14
+ - 输出:`--json` = `{ scopeIds, count, globalCount, scopedCount, docs[] }`(`docs` 只留 `keyword` / `synonyms` / `wordExplain` / `allScope` / `scopeEffectId` / `docType`);
15
+ 人读 = 逐条打印名词并标注生效范围(全局 / 数据集),「只命中全局词库」时额外给提示。
16
+ - 边界(实测):GET 不可用(业务失败);空数组 → `{"code":500,"msg":"getChatBiDocByScopeId.arg0: can not be empty"}`;
17
+ 超出 `Long` 上限的位数 → 500;合法但未命中的 id **不报错**,只返回全局词库。
18
+ - ⚠️ **本命令为新增通道,不影响原有 `noun list`**(`getChatDocsBySkillKey`,仍按 skillKey + 数据源三参数检索,行为与输出完全不变);两条通道并存,`noun list` 的既有调用方无需改动。
19
+
20
+ ```bash
21
+ e10-data noun scope --ids 1060565684758507544,1060565684758507545 # 人读:批量取回该数据集的词库
22
+ e10-data noun scope --ids @ids.json --json # ids.json = ["1060565684758507544","1060565684758507545"]
23
+ ```
24
+
25
+ ### 2. 同步改动
26
+
27
+ - `CMD_SUBS` 白名单 `noun: ["list"]` → `noun: ["list", "scope"]`;`main()` 的 `noun` 分支新增 `scope`;
28
+ `usage()` 的 `noun` 帮助段新增 `noun scope` 条目;头部注释 `noun` 一行改为 `list|scope`;
29
+ `README.md` / `CHANGELOG.md` / `package.json`(版本 + description)同步。
30
+
3
31
  ## 0.1.26(2026-10-15)—— 新增 `refusal rules`:拒答话术规则
4
32
 
5
33
  ### 1. `refusal` 族新增子命令 `rules`
package/README.md CHANGED
@@ -20,7 +20,7 @@ e10-data login xiaoe-env [--domain <url>] 登录:环境变量 Xi
20
20
  e10-data query <--conn <connId> --model <ebuilder|flow|eteams|attend|hr|document|dw|blog> --schema <数据库> [--table-id <流程ID>] [--debug true|false] --dsl @file.json>
21
21
  e10-data ds tables|fields|list|chart|stat|count 数据源(业务模块)取数与元数据
22
22
  e10-data doc count|list 文档查询(documentListCount + documentList)
23
- e10-data noun list --skill <skillKey> 词库查询(可带 --source-type/--source-group/--source-table 三参数)
23
+ e10-data noun list|scope 词库查询(list = 按 skill/数据源;scope = 按生效范围批量,2026-10-15 新增)
24
24
  e10-data field id2name|name2id 关联字段翻译(testRemoteBrowser / complete)
25
25
  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 分组,见下)
26
26
  e10-data exp status|manifest|commits|file|pull|init|commit|lock|release|rollback 专家包版本管理
@@ -76,6 +76,7 @@ e10-data ds count --group weaver-project-servicetask --table 715738355537494016
76
76
  e10-data ds fields --group weaver-formreport-service --table 1307487628041044060
77
77
  e10-data doc count --name 智能问数
78
78
  e10-data noun list --skill rd-department
79
+ e10-data noun scope --ids 1060565684758507544,1060565684758507545 # 词库:按生效范围(数据集 id)批量取回
79
80
  e10-data field id2name --module ebuilder/form --type ebuilder --ids 3194494277170470571 \
80
81
  --form-param '{"fieldId":"966849910772850766","module":"ebuilderform"}'
81
82
  e10-data conf get CONN_EC_EDCAPP # 读配置中心单条
package/bin/e10-data.mjs CHANGED
@@ -17,7 +17,7 @@
17
17
  * 该值取自 ebdf_obj.app_id(2026-10-09 起不再做 EB 权限前置校验);
18
18
  * 不带 appId 时按原样发送,由后端报错(CLI 不做拦截)
19
19
  * e10-data doc count|list 文档查询 documentListCount / documentList
20
- * e10-data noun list 词库 getChatDocsBySkillKey
20
+ * e10-data noun list|scope 词库:list = getChatDocsBySkillKey(按 skill/数据源);scope = getChatBiDocByScopeId(按生效范围批量)
21
21
  * e10-data field id2name|name2id 关联字段翻译 testRemoteBrowser / complete
22
22
  * e10-data conf get|batch|batch-file|group|group-file|resolve|resolve-file|add|add-file|update|delete
23
23
  * 环境参数配置中心(chatBi config map,替代 config-resolve 脚本 URL 直连;
@@ -49,6 +49,7 @@
49
49
  * node e10-data.mjs ds count --group weaver-project-servicetask --table 715738355537494016
50
50
  * node e10-data.mjs doc count --name 测试
51
51
  * node e10-data.mjs noun list --skill rd-department
52
+ * node e10-data.mjs noun scope --ids 1060565684758507544,1060565684758507545
52
53
  * node e10-data.mjs field id2name --module ebuilder/form --type ebuilder \
53
54
  * --ids 3194494277170470571 --form-param '{"fieldId":"966849910772850766","module":"ebuilderform"}'
54
55
  */
@@ -710,7 +711,7 @@ async function cmdLoginXiaoeEnv(args, json) {
710
711
  const CMD_SUBS = {
711
712
  ds: ["groups", "find", "describe", "tables", "fields", "fields-dsl", "list", "chart", "stat", "count"],
712
713
  doc: ["count", "list"],
713
- noun: ["list"],
714
+ noun: ["list", "scope"],
714
715
  field: ["id2name", "name2id"],
715
716
  conf: ["get", "batch", "batch-file", "group", "group-file", "resolve", "resolve-file", "add", "add-file", "update", "delete"],
716
717
  exp: ["status", "manifest", "commits", "file", "pull", "init", "commit", "lock", "release", "rollback"],
@@ -1640,6 +1641,74 @@ async function cmdNoun(args, json) {
1640
1641
  }
1641
1642
  }
1642
1643
 
1644
+ // noun scope(2026-10-15 新增)—— 按生效范围批量检索词库 getChatBiDocByScopeId
1645
+ // 入参 = 数据集 id 列表(Long 数组)= 场景定位(scene items --group <gid>)里每个条目的 id
1646
+ // ⚠️ id 一律按**字符串**下发:19 位雪花号超出 JS 安全整数(2^53),Number() 会丢精度
1647
+ // (实测 Number("1060565684758507544") 末位归零)→ 下发即检不到,且不报错。
1648
+ const DOC_SCOPE_PATH = "/api/dw/newetl/chatBi/doc/getChatBiDocByScopeId";
1649
+
1650
+ /** 词库条目 → 模型真正要用的精简字段(+ 生效范围标识,便于判「有无专属词库」) */
1651
+ function normalizeDoc(d) {
1652
+ return {
1653
+ keyword: d.keyword ?? null,
1654
+ synonyms: d.synonyms ?? null,
1655
+ wordExplain: d.wordExplain ?? null,
1656
+ allScope: d.allScope ?? null, // 0=表级别 1=所有数据集 2=WorkBuddy Skill
1657
+ scopeEffectId: d.scopeEffectId ?? null,
1658
+ docType: d.docType ?? null,
1659
+ };
1660
+ }
1661
+
1662
+ /** --ids:逗号/空白分隔的 id 串,或 @文件(JSON 数组或逗号串)→ 字符串 id 数组(去重保序) */
1663
+ function parseScopeIds(val) {
1664
+ const raw = String(readListArg(val) ?? "").trim();
1665
+ const ids = raw.split(/[,\s]+/).map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
1666
+ if (!ids.length) throw new Error("--ids 为空:请传数据集 id 列表(如 --ids 1060565684758507544,1060565684758507545 或 --ids @ids.json)");
1667
+ for (const id of ids) {
1668
+ if (!/^\d+$/.test(id)) throw new Error("--ids 含非法项「" + id + "」(须为数字型数据集 id,取自 scene items 的条目 id)");
1669
+ if (BigInt(id) > 9223372036854775807n) throw new Error("--ids 含超出 Long 上限的 id:" + id);
1670
+ }
1671
+ return [...new Set(ids)];
1672
+ }
1673
+
1674
+ /** 按生效范围批量取词库 → { scopeIds, count, globalCount, scopedCount, docs } */
1675
+ async function fetchDocsByScope(ids) {
1676
+ const r = await postJson(DOC_SCOPE_PATH, ids.map(String));
1677
+ const bad = r && typeof r === "object" && !Array.isArray(r)
1678
+ && ((r.code !== undefined && Number(r.code) !== 0) || r.fail === true);
1679
+ if (bad) throw new Error("getChatBiDocByScopeId 业务失败:code=" + r.code + " msg=" + (r.msg || "(无 msg)"));
1680
+ const docs = ((r && r.data) || []).map(normalizeDoc);
1681
+ return {
1682
+ scopeIds: ids,
1683
+ count: docs.length,
1684
+ globalCount: docs.filter((d) => d.allScope === 1).length,
1685
+ scopedCount: docs.filter((d) => d.allScope !== 1).length,
1686
+ docs,
1687
+ };
1688
+ }
1689
+
1690
+ async function cmdNounScope(args, json) {
1691
+ const ids = parseScopeIds(need("ids", args));
1692
+ const out = await fetchDocsByScope(ids);
1693
+ if (json) return out;
1694
+ console.log("== 词库 " + out.count + " 条(生效范围 id " + ids.length + " 个;全局 " + out.globalCount
1695
+ + " + 数据集级 " + out.scopedCount + ")==");
1696
+ if (!out.count) {
1697
+ console.log("(空词库:该环境未返回任何词库条目)");
1698
+ return;
1699
+ }
1700
+ for (const d of out.docs) {
1701
+ const tag = d.allScope === 1 ? "全局" : (d.allScope === 2 ? "Skill" : "数据集");
1702
+ const scope = d.allScope === 1 ? "全部数据" : (d.scopeEffectId || "");
1703
+ console.log("【" + (d.keyword || "") + "】" + (d.synonyms ? " 同义:" + d.synonyms : "")
1704
+ + " [" + tag + " " + scope + "]");
1705
+ if (d.wordExplain) console.log(" " + String(d.wordExplain).replace(/\n/g, " "));
1706
+ }
1707
+ if (out.scopedCount === 0) {
1708
+ console.log("(提示:本次只命中全局词库,所选数据集均无专属词库 —— 为确定结论)");
1709
+ }
1710
+ }
1711
+
1643
1712
  // ---------------- field:关联字段翻译 ----------------
1644
1713
  function customParamFromArgs(args) {
1645
1714
  if (args["form-param"]) return { formParam: args["form-param"] };
@@ -2989,6 +3058,11 @@ doc 文档查询
2989
3058
  doc list [同上条件] [--all 翻页到底] [--page N] [--size 100]
2990
3059
  noun 词库查询
2991
3060
  noun list --skill <skillKey> [--source-type LOGIC] [--source-group gid] [--source-table tid](数据源场景带三参数)
3061
+ noun scope --ids <id1,id2|@ids.json> [--json] # 2026-10-15 新增:按生效范围批量检索
3062
+ # 端点 /api/dw/newetl/chatBi/doc/getChatBiDocByScopeId(POST,body = 数据集 id 的 JSON 数组)
3063
+ # 入参 = **数据集 id 列表** = scene items --group <分组id> 里每个条目的 id 字段(接口/数据源条目同等适用)
3064
+ # 命中范围:allScope=1(所有数据集,恒返回)∪ scopeEffectId 含任一传入 id(数据集级)
3065
+ # ⚠️ id 按字符串下发(19 位雪花号超 2^53);空列表会被后端拒绝(arg0: can not be empty)
2992
3066
  field 关联字段翻译
2993
3067
  field id2name --module <m> --type <t> --ids id1,id2 [--form-param '{"fieldId":"..","module":"ebuilderform"}'|--eb-browser-param '{..}'|--property-type x]
2994
3068
  field name2id --module <m> --type <t> --name 名称 [同上附加参数]
@@ -3095,6 +3169,7 @@ async function main() {
3095
3169
  else { usage(); process.exit(1); }
3096
3170
  } else if (family === "noun") {
3097
3171
  if (sub === "list") result = await cmdNoun(args, json);
3172
+ else if (sub === "scope") result = await cmdNounScope(args, json);
3098
3173
  else { usage(); process.exit(1); }
3099
3174
  } else if (family === "field") {
3100
3175
  if (sub === "id2name") result = await cmdFieldId2name(args, json);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "e10-data",
3
- "version": "0.1.26",
4
- "description": "泛微 E10 数据接口统一 CLI(data-assistant 专家配套):登录(login xiaoe-env,环境变量 XiaoE 全局 token 换 ETEAMSID,免浏览器/免 python)/DSL 查询/数据源/文档/词库/关联字段翻译/环境参数配置中心(conf,支持 confGroup 分组)/专家包版本管理;ds 取数(list/chart/stat/count)的 appId 由调用方显式传入 --app-id(v0.1.14 起 CLI 不再自动反查;EB 建模表单 weaver-ebuilder-form-service 必须带,appId 取自 ebdf_obj.app_id;2026-10-09 起不再做 EB 权限前置校验);认证凭据**唯一来源 = weaver-work-cli**(通过 `auth export-weaver-env` 命令出口取明文凭据,**不设 e10-login 回退**;加解密由该 CLI 自行负责,本 CLI 不实现任何加解密;仅 login xiaoe-env 在无凭据时自行换 token,写 profile 仍交 e10-login set)。v0.1.17 性能改造:免凭据命令(--version/--help/未知命令)提前返回、直连 e10-login JS 入口(去掉 shell:true 的 cmd.exe 开销)、新增凭据进程间 TTL 缓存(不落明文);v0.1.19(2026-09-24)新增 ds 发现层聚合 groups/find/describe(进程内并发,全 58 分组扫表实测 ~5.5s),并修复 ds tables --name 因 listByPage 端点切换导致的关键词过滤静默失效;v0.1.18(2026-09-24)新增 ds fields-dsl(接口 /api/dw/newetl/chatBi/ds/fieldsForDSL),并移除凭据明文镜像同步(不再写 ~/.workbuddy/e10-login-cache.md);v0.1.20(2026-09-24)凭据来源切换为 weaver-work-cli 唯一来源、移除 e10-login 回退,并补齐 userId/tenantKey 传递(修复 attend statis 等命令报「缺少查询人员」的问题)。v0.1.21(2026-09-28)新增 module call —— 模块配置接口调用(配置中心驱动):已确定「哪个模块的哪条具体接口」之后的一条命令取数入口(精取该条 confAttrs → 按 http_method/input_params 组参 → 发请求(自动禁代理 + Cookie/eteamsid/UA 三件套)→ 提取精简结果),与技能自带 script/call_module.py 等价(参数名/退出码/提取口径全对齐),复用本 CLI 凭据缓存与 conf 通道、零临时文件;同时 auth 归一化与凭据缓存补齐 userAgent(供 AgentType UA 使用,缺失时从 cookie 的 agentType= 推导)。v0.1.22(2026-10-10):移除 `eb perm-page` 命令(EB 建模表单取数不再做权限前置校验,appId 直接取 ebdf_obj.app_id);`--fields`/`--group-by`/`--order` 等逗号列表支持 `@文件`(逗号字符串或 JSON 数组,与 --where/--stat/--dsl 一致,规避 shell 拆分导致的静默丢列/0 行)。v0.1.23(2026-10-13)新增 `refusal get` —— 拒答话术 getRefusalSpeechTechnique(入参仅 type,返回对象的 data = 话术字符串;默认 auto 通道 = POST multipart 表单优先、返回不含 data 时自动回退 GET ?type=,可用 --http post|get 锁定单通道)。v0.1.25(2026-10-14)新增 `scene groups|items` —— 场景定位元数据 getSceneGroups(① groups 分组骨架 / ② items --group <groupId> 组内条目),由技能 references/scene-locate/scripts/locate.mjs 整体迁入(属元数据定位接口、不取业务数据):默认输出精简 JSON(groups: groupId/groupName/itemCount/groupDesc;items: id/datasetName/datasetType/sourceId[/moduleName/sourceType/sourceGroupId/appId]/datasetDesc),--json 原样输出接口返回,计数走 stderr;--client agent|all|connector 默认 agent。v0.1.26(2026-10-15)新增 `refusal rules` —— 拒答话术规则 getRefusalSpeechRules(**无入参**,返回对象的 data = 对象数组;调用方式与 refusal get 同口径:默认 auto 通道 = POST 空 multipart 表单优先、返回不含 data 时回退 GET,可用 --http post|get 锁定单通道;人读直接打印 data 数组,--json 原样输出整个响应对象)。",
3
+ "version": "0.1.27",
4
+ "description": "泛微 E10 数据接口统一 CLI(data-assistant 专家配套):登录(login xiaoe-env,环境变量 XiaoE 全局 token 换 ETEAMSID,免浏览器/免 python)/DSL 查询/数据源/文档/词库/关联字段翻译/环境参数配置中心(conf,支持 confGroup 分组)/专家包版本管理;ds 取数(list/chart/stat/count)的 appId 由调用方显式传入 --app-id(v0.1.14 起 CLI 不再自动反查;EB 建模表单 weaver-ebuilder-form-service 必须带,appId 取自 ebdf_obj.app_id;2026-10-09 起不再做 EB 权限前置校验);认证凭据**唯一来源 = weaver-work-cli**(通过 `auth export-weaver-env` 命令出口取明文凭据,**不设 e10-login 回退**;加解密由该 CLI 自行负责,本 CLI 不实现任何加解密;仅 login xiaoe-env 在无凭据时自行换 token,写 profile 仍交 e10-login set)。v0.1.17 性能改造:免凭据命令(--version/--help/未知命令)提前返回、直连 e10-login JS 入口(去掉 shell:true 的 cmd.exe 开销)、新增凭据进程间 TTL 缓存(不落明文);v0.1.19(2026-09-24)新增 ds 发现层聚合 groups/find/describe(进程内并发,全 58 分组扫表实测 ~5.5s),并修复 ds tables --name 因 listByPage 端点切换导致的关键词过滤静默失效;v0.1.18(2026-09-24)新增 ds fields-dsl(接口 /api/dw/newetl/chatBi/ds/fieldsForDSL),并移除凭据明文镜像同步(不再写 ~/.workbuddy/e10-login-cache.md);v0.1.20(2026-09-24)凭据来源切换为 weaver-work-cli 唯一来源、移除 e10-login 回退,并补齐 userId/tenantKey 传递(修复 attend statis 等命令报「缺少查询人员」的问题)。v0.1.21(2026-09-28)新增 module call —— 模块配置接口调用(配置中心驱动):已确定「哪个模块的哪条具体接口」之后的一条命令取数入口(精取该条 confAttrs → 按 http_method/input_params 组参 → 发请求(自动禁代理 + Cookie/eteamsid/UA 三件套)→ 提取精简结果),与技能自带 script/call_module.py 等价(参数名/退出码/提取口径全对齐),复用本 CLI 凭据缓存与 conf 通道、零临时文件;同时 auth 归一化与凭据缓存补齐 userAgent(供 AgentType UA 使用,缺失时从 cookie 的 agentType= 推导)。v0.1.22(2026-10-10):移除 `eb perm-page` 命令(EB 建模表单取数不再做权限前置校验,appId 直接取 ebdf_obj.app_id);`--fields`/`--group-by`/`--order` 等逗号列表支持 `@文件`(逗号字符串或 JSON 数组,与 --where/--stat/--dsl 一致,规避 shell 拆分导致的静默丢列/0 行)。v0.1.23(2026-10-13)新增 `refusal get` —— 拒答话术 getRefusalSpeechTechnique(入参仅 type,返回对象的 data = 话术字符串;默认 auto 通道 = POST multipart 表单优先、返回不含 data 时自动回退 GET ?type=,可用 --http post|get 锁定单通道)。v0.1.25(2026-10-14)新增 `scene groups|items` —— 场景定位元数据 getSceneGroups(① groups 分组骨架 / ② items --group <groupId> 组内条目),由技能 references/scene-locate/scripts/locate.mjs 整体迁入(属元数据定位接口、不取业务数据):默认输出精简 JSON(groups: groupId/groupName/itemCount/groupDesc;items: id/datasetName/datasetType/sourceId[/moduleName/sourceType/sourceGroupId/appId]/datasetDesc),--json 原样输出接口返回,计数走 stderr;--client agent|all|connector 默认 agent。v0.1.26(2026-10-15)新增 `refusal rules` —— 拒答话术规则 getRefusalSpeechRules(**无入参**,返回对象的 data = 对象数组;调用方式与 refusal get 同口径:默认 auto 通道 = POST 空 multipart 表单优先、返回不含 data 时回退 GET,可用 --http post|get 锁定单通道;人读直接打印 data 数组,--json 原样输出整个响应对象)。v0.1.27(2026-10-15)新增 `noun scope --ids <id1,id2|@ids.json>` —— 词库**按生效范围批量检索**(端点 /api/dw/newetl/chatBi/doc/getChatBiDocByScopeId,POST body = 数据集 id 的 JSON 数组;入参 = 数据集 id 列表 = `scene items --group <分组id>` 里每个条目的 `id`;命中 = allScope=1 全局词库 ∪ scopeEffectId 含任一传入 id;id 按字符串下发,避免 19 位雪花号超 2^53 丢精度)。属**新增通道**,原 `noun list --skill <skillKey>`(getChatDocsBySkillKey)行为**完全不变**。",
5
5
  "author": "e10-dw",
6
6
  "license": "MIT",
7
7
  "type": "module",