e10-data 0.1.28 → 0.1.29

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,17 @@
1
1
  # 变更记录
2
2
 
3
+ ## 0.1.29(2026-10-19)—— `module call` 支持 `--conf-file`(配置只取一次)
4
+
5
+ ### 1. `module call` 新增 `--conf-file <文件|@文件>`
6
+
7
+ - 背景:`module call` 每次执行都会先 `conf get` 一次;而组参阶段(如技能侧 `build_query.py`)已经把同一条 `confAttrs` 取回并落盘。同一 `confKey` 一次问数会被取两遍配置。
8
+ - 新增 `--conf-file`:直接从本地文件读 `confAttrs`,**跳过 `conf get`**(不发配置中心请求)。
9
+ - 兼容两种输入:① 模板缓存(扁平对象,含 `apiPath` / `http_method` / `request_example` 等);② `conf get --json` 的原样输出(外层含 `confValue` / `confAttrs`)。
10
+ - 带该参数时 `--group`(及 `--conf-key`)可省略,缺省值从文件内的 `module` / `confKey` 回填。
11
+ - stderr 输出一行 `# confAttrs 来自本地缓存(…)|未请求配置中心`,便于核对是否真的没取配置。
12
+ - 缓存缺失 / 过期 / 配置变更时去掉该参数即可回退原 `conf get` 路径。
13
+ - 实测:`--dry-run` 固定开销 1.18 s → 0.59 s;单次问数配置读取请求数 2 → 1。
14
+
3
15
  ## 0.1.28(2026-10-17)—— `module call` 支持自定义 `confType` 与 `--show-params` 精简
4
16
 
5
17
  ### 1. `module call` 新增 `--type <confType>`
package/bin/e10-data.mjs CHANGED
@@ -2186,14 +2186,19 @@ async function moduleInvoiceToken(json, timeoutMs) {
2186
2186
 
2187
2187
  async function cmdModuleCall(args, json) {
2188
2188
  // ---- 必填与选项(缺参一律退出码 8,对齐 call_module.py)----
2189
- if (!args["conf-key"] || args["conf-key"] === true) {
2190
- moduleDie(json, MODULE_EXIT.USAGE, "缺必填参数 --conf-key(用法: module call --conf-key <confKey> --group <模块> [--type <confType>])");
2191
- }
2192
- if (!args.group || args.group === true) {
2193
- moduleDie(json, MODULE_EXIT.USAGE, "缺必填参数 --group(模块唯一标识,如 WORKFLOW / EHR / DOCUMENT)");
2194
- }
2195
- const confKey = String(args["conf-key"]);
2196
- const group = String(args.group);
2189
+ // 2026-10-19 本地增强:--conf-file <file|@file> 直接读本地 confAttrs,跳过 conf get
2190
+ // (组参阶段已把该条配置落盘时用;可省掉同一 confKey 的第二次配置读取)
2191
+ const confFile = (typeof args["conf-file"] === "string" && args["conf-file"])
2192
+ ? String(args["conf-file"]).replace(/^@/, "")
2193
+ : ((typeof args.attrs === "string" && args.attrs) ? String(args.attrs).replace(/^@/, "") : "");
2194
+ if ((!args["conf-key"] || args["conf-key"] === true) && !confFile) {
2195
+ moduleDie(json, MODULE_EXIT.USAGE, "缺必填参数 --conf-key(用法: module call --conf-key <confKey> --group <模块> [--type <confType>] [--conf-file <本地confAttrs>])");
2196
+ }
2197
+ if ((!args.group || args.group === true) && !confFile) {
2198
+ moduleDie(json, MODULE_EXIT.USAGE, "缺必填参数 --group(模块唯一标识,如 WORKFLOW / EHR / DOCUMENT;带 --conf-file 时可省)");
2199
+ }
2200
+ let confKey = (args["conf-key"] && args["conf-key"] !== true) ? String(args["conf-key"]) : "";
2201
+ let group = (args.group && args.group !== true) ? String(args.group) : "";
2197
2202
  // 2026-10-16:支持自定义 confType(域级配置分组,如 ebu / pmo / contract / partner)。
2198
2203
  // 不传 --type 时行为与旧版完全一致(confType 固定 api)。
2199
2204
  const confType = (typeof args.type === "string" && args.type) ? args.type : "api";
@@ -2201,18 +2206,46 @@ async function cmdModuleCall(args, json) {
2201
2206
  const limit = (args.limit === undefined || args.limit === true) ? 50 : (parseInt(String(args.limit), 10) || 0);
2202
2207
  const fields = (typeof args.fields === "string" && args.fields) ? readListArg(args.fields).split(",").map((s) => s.trim()).filter(Boolean) : null;
2203
2208
 
2204
- // ---- ① 精取该条接口配置(confType 默认 api,可用 --type 指定;confGroup 二级定位必带)----
2205
- let rec;
2206
- try { rec = await confGetData(confType, confKey, false, group); }
2207
- catch (e) {
2208
- const m = String((e && e.message) || e);
2209
- moduleDie(json, /登录态失效|未取得登录凭据/.test(m) ? MODULE_EXIT.AUTH : MODULE_EXIT.JSON,
2210
- "conf get 失败:" + m + "(先核对 confType / confGroup / confKey;自定义 confType 须显式 --type;登录态问题请重新登录)");
2211
- }
2212
- let attrs = rec.confAttrs;
2213
- if (typeof attrs === "string") {
2214
- try { attrs = parseJsonSafe(attrs, "confAttrs"); }
2215
- catch { moduleDie(json, MODULE_EXIT.JSON, "confAttrs 二次解析失败(非 JSON 字符串): " + confKey); }
2209
+ // ---- ① 取该条接口配置:--conf-file 读本地(0 请求) / 否则精取 confAttrs ----
2210
+ let rec, attrs;
2211
+ if (confFile) {
2212
+ let raw;
2213
+ try { raw = fs.readFileSync(confFile, "utf-8"); }
2214
+ catch (e) {
2215
+ moduleDie(json, MODULE_EXIT.JSON, "读 --conf-file 失败:" + String((e && e.message) || e) + "(" + confFile + ")");
2216
+ }
2217
+ let d;
2218
+ try { d = JSON.parse(String(raw).replace(/^\uFEFF/, "").trim()); }
2219
+ catch { moduleDie(json, MODULE_EXIT.JSON, "--conf-file 不是合法 JSON:" + confFile); }
2220
+ if (Array.isArray(d)) d = d[0] || {};
2221
+ if (!d || typeof d !== "object") moduleDie(json, MODULE_EXIT.JSON, "--conf-file 形态异常(期望对象):" + confFile);
2222
+ if (d.confAttrs !== undefined || (d.confValue !== undefined && d.api_path === undefined)) {
2223
+ // 形态②:`conf get --json` 原样输出
2224
+ rec = d;
2225
+ attrs = d.confAttrs;
2226
+ if (typeof attrs === "string") {
2227
+ try { attrs = parseJsonSafe(attrs, "confAttrs"); }
2228
+ catch { moduleDie(json, MODULE_EXIT.JSON, "confAttrs 二次解析失败(非 JSON 字符串): " + confFile); }
2229
+ }
2230
+ } else {
2231
+ // 形态①:模板缓存(`--show-params --full` 的输出,本身即 attrs 视图)
2232
+ rec = d; attrs = d;
2233
+ }
2234
+ confKey = confKey || String(d.confKey || (attrs && attrs.confKey) || "");
2235
+ group = group || String((attrs && attrs.module) || d.module || "");
2236
+ process.stderr.write("# confAttrs 来自本地缓存(" + confFile + ")|未请求配置中心\n");
2237
+ } else {
2238
+ try { rec = await confGetData(confType, confKey, false, group); }
2239
+ catch (e) {
2240
+ const m = String((e && e.message) || e);
2241
+ moduleDie(json, /登录态失效|未取得登录凭据/.test(m) ? MODULE_EXIT.AUTH : MODULE_EXIT.JSON,
2242
+ "conf get 失败:" + m + "(先核对 confType / confGroup / confKey;自定义 confType 须显式 --type;登录态问题请重新登录)");
2243
+ }
2244
+ attrs = rec.confAttrs;
2245
+ if (typeof attrs === "string") {
2246
+ try { attrs = parseJsonSafe(attrs, "confAttrs"); }
2247
+ catch { moduleDie(json, MODULE_EXIT.JSON, "confAttrs 二次解析失败(非 JSON 字符串): " + confKey); }
2248
+ }
2216
2249
  }
2217
2250
  if (!attrs || typeof attrs !== "object" || Array.isArray(attrs)) {
2218
2251
  moduleDie(json, MODULE_EXIT.JSON, "confAttrs 缺失或形态异常: " + confKey + "(--group " + group + ")");
@@ -3106,9 +3139,12 @@ attend 考勤 REST 接口(2026-09-07 新增,hr-attendance 病假/事假等
3106
3139
  attend statis [--user <人员ID>] [--begin 2026-09-01] [--end 2026-09-30] # getAttendInfoStatis 假期余额统计;--user 默认当前登录用户,--begin/--end 默认当月
3107
3140
  module 模块配置接口调用(配置中心驱动;**已确定「哪个模块的哪条具体接口」之后**用它取数,2026-09-28 新增)
3108
3141
  module call --conf-key <confKey> --group <模块> [--type <confType>] [--args '<JSON>'|--args @params.json]
3142
+ [--conf-file <本地confAttrs文件>]
3109
3143
  [--query "k=v&k2=v2"] [--method GET|POST|FORM] [--header 'K: V'|--headers '<JSON>'|@file]
3110
3144
  [--limit 50] [--fields a,b|@f] [--raw] [--show-params [--full]] [--dry-run] [--timeout 60] [--json]
3111
3145
  # --type:confType,默认 api(模块通道);域级自定义分组传该域名(如 ebu / pmo / contract / partner)
3146
+ # --conf-file:直接读本地 confAttrs(跳过 conf get,配置只取一次)。喂 build_query.py 生成的
3147
+ # .e10_cache/<group>__<confKey>.json,或 conf get --type api --json 的原样输出;给了它可省 --group。
3112
3148
  # 一条命令完成:精取该条 confAttrs → 按 http_method/input_params 组参 → 发请求
3113
3149
  # (自动禁代理 + Cookie/eteamsid/UA 三件套)→ 按外层结构(datajson/data/records/裸数组)提取精简结果
3114
3150
  # 与技能自带 python 调用器 call_module.py 等价(参数名/退出码/提取口径全对齐),但复用本 CLI 凭据缓存与
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "e10-data",
3
- "version": "0.1.28",
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)行为**完全不变**。 v0.1.28(2026-10-17):`module call` 支持 `--type <confType>`(自定义 confType / 域级配置分组,默认 `api`,不传时行为与旧版一致)与 `--show-params` 精简模式(默认省略 `request_example`,`--full` / `--with-example` 回显,`--no-example` 显式精简),`--show-params` 输出新增 `conf_type` 字段。",
3
+ "version": "0.1.29",
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)行为**完全不变**。 v0.1.28(2026-10-17):`module call` 支持 `--type <confType>`(自定义 confType / 域级配置分组,默认 `api`,不传时行为与旧版一致)与 `--show-params` 精简模式(默认省略 `request_example`,`--full` / `--with-example` 回显,`--no-example` 显式精简),`--show-params` 输出新增 `conf_type` 字段。v0.1.29(2026-10-19)本地增强:`module call` 新增 `--conf-file <文件|@文件>`——直接读本地 confAttrs 跳过 `conf get`(同一 confKey 一次问数只取一次配置),兼容模板缓存与 `conf get --json` 原样输出,带该参数时 `--group`/`--conf-key` 可从文件回填,stderr 提示「未请求配置中心」;缓存缺失/过期时去掉该参数即回退原路径。",
5
5
  "author": "e10-dw",
6
6
  "license": "MIT",
7
7
  "type": "module",