@stalfh233/omc-cli 0.6.99 → 0.7.0
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/conformance/README.md +267 -0
- package/conformance/frontend-behavior-probe.mjs +1986 -0
- package/conformance/frontend-scenarios/calc-visibility.json +22 -0
- package/conformance/frontend-scenarios/form-buttons.json +19 -0
- package/conformance/frontend-scenarios/list-buttons.json +28 -0
- package/conformance/frontend-scenarios/onlinejs.json +19 -0
- package/dist/cli-stdout.js +4 -0
- package/dist/cli.js +178 -2
- package/dist/endpoints.js +2 -0
- package/dist/field-tree-options.js +165 -0
- package/dist/form-support.js +59 -2
- package/dist/formula-lint.js +5 -1
- package/dist/intent/capabilities/datarule.js +20 -2
- package/dist/lanes/datarule.js +34 -3
- package/dist/lanes/field.js +40 -6
- package/dist/lanes/form.js +1 -1
- package/dist/lanes/list-view-shapes.js +78 -1
- package/dist/lanes/list-view.js +147 -1
- package/dist/lanes/model.js +23 -2
- package/dist/lanes/online-js.js +18 -2
- package/dist/lanes/perm.js +1 -1
- package/dist/lanes/workflow.js +16 -2
- package/dist/online-js-source.js +7 -0
- package/dist/recipes/datarule.js +2 -1
- package/dist/recipes/field.js +1 -1
- package/dist/refusal-guidance.js +1 -1
- package/dist/wire.js +46 -2
- package/dist/write.js +78 -1
- package/package.json +6 -4
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "calc-visibility",
|
|
3
|
+
"description": "计算规则 + 字段显隐前台验证:填「数量」「单价」后「金额」应被计算规则算出 15;勾选「显示明细」后明细块显示、「隐藏字段」仍隐藏;「编码」只读、「名称」必填。\n\n占位符:所有 label 的文本都要换成你模型里的**字段显示名**(不是 code);显隐切换用的复选框字段也要用显示名。若计算结果是小数,把 step#4 的 valueEquals 换成 valueMatches(step#5 就是示例)。\n\n说明:valueEquals 会先等最多 withinMs,等计算规则生效再比;千分位逗号和首尾空白会被忽略,纯数字还会做数值比较(15 与 15.00 视为相等)。",
|
|
4
|
+
"login": true,
|
|
5
|
+
"steps": [
|
|
6
|
+
{ "action": "goto", "path": "/portal-page/<替换为你的表单URL>" },
|
|
7
|
+
{ "action": "waitForText", "text": "<替换为表单标题>", "timeoutMs": 30000 },
|
|
8
|
+
{ "action": "fill", "label": "<替换为数量字段显示名>", "value": "3" },
|
|
9
|
+
{ "action": "fill", "label": "<替换为单价字段显示名>", "value": "5" },
|
|
10
|
+
{ "action": "assert", "kind": "valueEquals", "label": "<替换为金额字段显示名>", "expected": "15", "withinMs": 8000 },
|
|
11
|
+
{ "action": "assert", "kind": "valueMatches", "label": "<替换为金额字段显示名>", "expected": "^1[0-9](\\.[0-9]+)?$", "optional": true },
|
|
12
|
+
|
|
13
|
+
{ "action": "check", "label": "<替换为显隐开关字段显示名>" },
|
|
14
|
+
{ "action": "assert", "kind": "visible", "label": "<替换为条件显示的字段显示名>" },
|
|
15
|
+
{ "action": "uncheck", "label": "<替换为显隐开关字段显示名>" },
|
|
16
|
+
{ "action": "assert", "kind": "hidden", "label": "<替换为条件显示的字段显示名>" },
|
|
17
|
+
|
|
18
|
+
{ "action": "assert", "kind": "readonly", "label": "<替换为只读字段显示名>" },
|
|
19
|
+
{ "action": "assert", "kind": "required", "label": "<替换为必填字段显示名>" },
|
|
20
|
+
{ "action": "assert", "kind": "noConsoleErrors" }
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "form-buttons",
|
|
3
|
+
"description": "表单按钮前台验证:流程表单(带 workItemId)底部工具栏渲染自定义表单按钮,点击发出 runtime/form/executeCustomButton 且 errcode=0,SCRIPT 按钮的脚本在浏览器里执行(console.log 可被探针捕获),页面无新的 console error。\n\n为什么必须走 workItem URL:普通表单页(/form/detail?...&isWorkFlow=false)只渲染平台内置按钮,FORM 位置的按钮可见性由「当前流程节点」的 buttonPermission.customBtns[].enabled 控制(设计器「表单操作」勾选),所以必须①表单按钮已随 form.publish 生成 h_biz_button(triggerType=FORM),②workflow.setButtons 在该节点勾选,③用带 workItemId 的表单 URL 打开。已发布节点配置是运行时读取的(把节点按钮关掉再发布,已打开过的实例刷新后按钮也消失),因此顺序应是 setButtons 先、起实例后。\n\n怎么拿 workItemId(二选一,推荐第一种):\nA) 草稿留在发起节点:omc call data.save --args '{\"schemaCode\":\"<模型code>\",\"workflowCode\":\"<流程code>\",\"formData\":{...}}' → 读 performed.workItemId / performed.workflowInstanceId / performed.bizObjectId,行是 DRAFT、当前节点就是第一个 {Originator} 填写节点,按钮勾在这个节点最直观。\nB) 已提交单的下一节点:omc call data.submit --args '{\"schemaCode\":\"<模型code>\",\"formData\":{...}}' → readback.workItemId 是**下一个**待办节点(发起节点的待办在提交时已自动过掉);此时按钮要勾在 readback.nextWorkItems[0].activityCode 那个节点上。\nURL 形状(已真机验证,直接开,不必经门户):/form/detail?schemaCode=<模型code>&objectId=<bizObjectId>&workItemId=<workItemId>&workflowInstanceId=<workflowInstanceId>&perms=edit&isMobile=false\n\n占位符:\n- <模型code> / <流程code> / <按钮显示名>;URL 里的 <bizObjectId>/<workItemId>/<workflowInstanceId> 来自上面的回执。\n- 本场景按「两个按钮」验证:一个 bindAction=SCRIPT(断言脚本日志),一个 bindAction=BUSINESS_RULE(断言服务端请求)。只建了服务端动作按钮时,删掉第 4/5 步;只建 SCRIPT 按钮时,SCRIPT 是纯前端执行、**不发** executeCustomButton,第 7 步会失败(这不是缺陷)。\n- 按钮 script 里写 console.log('omc-probe-button'),与第 5 步的 text 对齐。\n\n已知坑:\n- 提交型 data.submit 会把发起节点一次过掉;想停在发起节点用 data.save(DRAFT)。\n- 在按钮启用前就已创建/走到位的旧待办可能仍不显示按钮(节点定义按实例创建时的版本绑定);不要排查页面缓存,直接按上面的顺序新建一条实例。\n- 平台 1.1.25/1.1.30 的表单页是英文 UI(Submit/Save/Print…),自定义按钮按 name 原文渲染,click/text 用按钮显示名即可。",
|
|
4
|
+
"login": true,
|
|
5
|
+
"steps": [
|
|
6
|
+
{
|
|
7
|
+
"action": "goto",
|
|
8
|
+
"path": "/form/detail?schemaCode=<模型code>&objectId=<bizObjectId>&workItemId=<workItemId>&workflowInstanceId=<workflowInstanceId>&perms=edit&isMobile=false",
|
|
9
|
+
"waitMs": 3000
|
|
10
|
+
},
|
|
11
|
+
{ "action": "wait", "ms": 1000 },
|
|
12
|
+
{ "action": "waitForText", "text": "<SCRIPT按钮显示名>", "timeoutMs": 30000 },
|
|
13
|
+
{ "action": "click", "text": "<SCRIPT按钮显示名>" },
|
|
14
|
+
{ "action": "assert", "kind": "probeLogContains", "text": "omc-probe-button" },
|
|
15
|
+
{ "action": "click", "text": "<BUSINESS_RULE按钮显示名>" },
|
|
16
|
+
{ "action": "assert", "kind": "request", "path": "runtime/form/executeCustomButton", "errcode": 0, "withinMs": 20000 },
|
|
17
|
+
{ "action": "assert", "kind": "noConsoleErrors" }
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "list-buttons",
|
|
3
|
+
"description": "列表视图自定义按钮(BizButtonModel)前台验证:点「视图 SCRIPT 按钮」后,脚本到底在哪执行、有没有 HTTP 请求。\n\n按钮配置形状(listview.configure 的 buttons[],t248 真机验证通过):\n{ code:\"probeListBtn\", name:\"列表探针\", useLocation:\"LIST\", bindAction:\"SCRIPT\", operateType:\"WITH_OUT_VIEW\", script:\"console.log('omc-probe-list-button')\" }\n等价 wire:actionConfig = {\"scriptData\":\"console.log('omc-probe-list-button')\"}(JSON 字符串)。平台运行期只读 actionConfig.scriptData,不需要 buttonType/params/scriptType/showInNewForm。\n\n两种 operateType 的语义完全不同(都验证过):\n- WITH_OUT_VIEW:点按钮 → 浏览器内 new Function(\"scriptData\",\"rowIndex\", scriptData) 在**列表页**立即执行,随后 goForm 提前 return(不取表单 URL、不跳转、**不发任何请求**)。本场景第一段就是它:断言 console 日志,且不会出现 runtime/form/get_form_url。不要求选行。\n- WITH_VIEW:脚本不在列表页执行,而是把 scriptData 塞进 sessionStorage.scriptData 并给表单 URL 加 scriptOpen=true,打开该行表单后由表单页 eval。**必须恰好选中 1 行**,0 行只弹「请选择数据」提示(无请求、无日志),多行弹「只能选择一条数据」。本场景第二段:选行 → 点击 → 断言请求 scriptOpen=true(命中 GET /runtime/form/load?...&scriptOpen=true)。\n\n前置(踩过的坑,缺一个就会「点了没反应」):\n1) 按钮必须真的渲染在工具栏 #list-actions 里。工具栏按宽度切分:放不下时自定义按钮被挪进右侧「…」浮层(.list-actions-more),此时 #list-actions 里找不到它;选中行后工具栏会追加删除/批量按钮,可能把它挤进「…」——这正是「选中行后按钮被工具栏替换/消失」的原因。最省事的做法是 listview.configure 传 replaceActions:true + actions:[] 把内置按钮清掉,再放 1 个自定义按钮。\n2) 首次进应用右上角有「Click here to enter the admin backend…」引导浮层,会盖住工具栏右端;被盖住时 Playwright/人手点击都点不到按钮(无日志无请求无报错)。本场景点的是左侧靠前的位置,若按钮落在右端被盖住,先关掉该浮层。\n3) SCRIPT 按钮跑完后平台会调 onCustomActionDone → this.eventHooksHandler.exec(...),而模型没有「视图级在线 JS」时 eventHooksHandler 为 null,必抛 pageerror(平台 bug,与其他调用点的 null 判断不一致)。已在 ignoreConsole 里忽略。\n4) about:srcdoc 沙箱 iframe 的 console error 是平台自身的,也已忽略。\n\n占位符:\n- 列表页 path:登录后打开目标视图,把地址栏 /application/ 之后的路径填进来(形如 /application/<appCode>/application-list/<schemaCode>?code=<schemaCode>)。\n- 视图标题:视图名(本场景用 waitForText 等它出现)。\n- 不选行按钮的 code / 显示名:WITH_OUT_VIEW 那个 SCRIPT 按钮。\n- 选行按钮的 code / 显示名:WITH_VIEW 那个 SCRIPT 按钮。\n- 脚本里的 console 片段:要和按钮 script 里的 console.log 文本一致(示例 omc-probe-list-button)。\n\nt248 实测(AI-Platform 1.1.30,模型 lbtnProbe,1 条已提交数据):14 步全 PASS;点 WITH_OUT_VIEW 按钮只出 console 日志、零请求;选行后点 WITH_VIEW 按钮出 GET /api/api/runtime/form/get_form_url 与 GET /api/api/runtime/form/load?...&scriptOpen=true&_viewCode=<viewCode>,errcode 0。",
|
|
4
|
+
"login": true,
|
|
5
|
+
"ignoreConsole": [
|
|
6
|
+
"Cannot read properties of null (reading 'exec')",
|
|
7
|
+
"Blocked script execution in 'about:srcdoc'",
|
|
8
|
+
"allow-scripts' permission is not set"
|
|
9
|
+
],
|
|
10
|
+
"steps": [
|
|
11
|
+
{ "action": "goto", "path": "/application/<替换为appCode>/application-list/<替换为schemaCode>?code=<替换为schemaCode>" },
|
|
12
|
+
{ "action": "assert", "kind": "request", "path": "runtime/query/list", "errcode": 0, "withinMs": 20000 },
|
|
13
|
+
{ "action": "waitForText", "text": "<替换为列表视图标题>", "timeoutMs": 30000 },
|
|
14
|
+
|
|
15
|
+
{ "action": "assert", "kind": "visible", "selector": "#list-actions button.list-action-<替换为列表按钮code>" },
|
|
16
|
+
{ "action": "click", "selector": "#list-actions button.list-action-<替换为列表按钮code>" },
|
|
17
|
+
{ "action": "assert", "kind": "probeLogContains", "text": "omc-probe-list-button" },
|
|
18
|
+
{ "action": "assert", "kind": "noConsoleErrors" },
|
|
19
|
+
|
|
20
|
+
{ "action": "goto", "path": "/application/<替换为appCode>/application-list/<替换为schemaCode>?code=<替换为schemaCode>" },
|
|
21
|
+
{ "action": "waitForText", "text": "<替换为列表视图标题>", "timeoutMs": 30000 },
|
|
22
|
+
{ "action": "wait", "ms": 2500 },
|
|
23
|
+
{ "action": "eval", "script": "(function(){var all=[].slice.call(document.querySelectorAll('.ant-checkbox-input')).filter(function(el){return !el.closest('.table-head-row');});if(!all.length){return 'no-row-checkbox';}all[0].click();return 'row-selected';})()" },
|
|
24
|
+
{ "action": "click", "selector": "#list-actions button.list-action-<替换为选行按钮code>" },
|
|
25
|
+
{ "action": "assert", "kind": "request", "path": "scriptOpen=true", "withinMs": 20000 },
|
|
26
|
+
{ "action": "assert", "kind": "noConsoleErrors" }
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "onlinejs",
|
|
3
|
+
"description": "在线 JS 前台验证:确认表单页真的注册并触发了生命周期事件(onLoad/onAdd/onSubmit),保存按钮真的发出 runtime/form/save 请求且 errcode=0,页面没有新的 console error。\n\n路径怎么取:登录后从门户打开目标表单的新增页,把浏览器地址栏里 `.../portal-page/` 之后到 `#` 之前的完整路径复制到下面的 path(例如 /portal-page/defaultPortal/form/xxxx)。如果打开的是列表页再点「新建」,就把列表页地址写进 step#0,再保留 step#2 的点击「新建」。\n\n标签文本(label)要换成你模型里的显示名;按钮文本(text)要换成你表单上实际的按钮名(保存/提交/确定)。\n\n注意:1.1.25 的在线 JS 里 `form` 是闭包参数,页面不暴露 `window.form`,所以 `eventFired/eventRegistered` 只能作为 optional;主断言请用脚本里的 console.log + `probeLogContains`(示例:form.on('onLoad', function(){ console.log('omc-probe-onLoad'); }))。",
|
|
4
|
+
"login": true,
|
|
5
|
+
"steps": [
|
|
6
|
+
{ "action": "goto", "path": "/portal-page/<替换为你的表单URL>", "waitMs": 1000 },
|
|
7
|
+
{ "action": "waitForText", "text": "<替换为页面标题或“新建”>", "timeoutMs": 30000 },
|
|
8
|
+
{ "action": "click", "text": "新建" },
|
|
9
|
+
{ "action": "assert", "kind": "probeLogContains", "text": "omc-probe-onLoad" },
|
|
10
|
+
{ "action": "assert", "kind": "eventFired", "event": "onLoad", "optional": true },
|
|
11
|
+
{ "action": "fill", "label": "<替换为必填字段显示名>", "value": "<占位值>" },
|
|
12
|
+
{ "action": "click", "text": "保存" },
|
|
13
|
+
{ "action": "assert", "kind": "request", "path": "runtime/form/save", "errcode": 0, "withinMs": 20000 },
|
|
14
|
+
{ "action": "assert", "kind": "probeLogContains", "text": "omc-probe-onSubmit" },
|
|
15
|
+
{ "action": "assert", "kind": "eventFired", "event": "onSubmit", "optional": true },
|
|
16
|
+
{ "action": "assert", "kind": "probeLogContains", "text": "<你脚本里 console.log 的片段>", "optional": true },
|
|
17
|
+
{ "action": "assert", "kind": "noConsoleErrors" }
|
|
18
|
+
]
|
|
19
|
+
}
|
package/dist/cli-stdout.js
CHANGED
|
@@ -56,6 +56,10 @@ export const CLI_STDOUT_OWNERS = {
|
|
|
56
56
|
"workflow-update-publish": "envelope",
|
|
57
57
|
// 原始输出
|
|
58
58
|
env: "raw",
|
|
59
|
+
// `frontend probe` 把仓库内探针作为子进程继承 stdio:stdout 是探针自己的
|
|
60
|
+
// 报告/日志,不是信封。主流程再补一个信封会变成「第二个答案」,失败时还会
|
|
61
|
+
// 谎报「以退出码 N 结束但没有写出结果信封」。退出码由子进程透传。
|
|
62
|
+
frontend: "raw",
|
|
59
63
|
// MCP stdio 服务器:stdout 是 JSON-RPC 帧流,补一个信封会直接污染协议。
|
|
60
64
|
"mcp-graph": "raw",
|
|
61
65
|
"--version": "raw",
|
package/dist/cli.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// T04:SQLite 警告过滤器必须保持第一个 import(先于任何拉起 omc-core/node:sqlite 的模块)。
|
|
3
3
|
import "./sqlite-warning-filter.js";
|
|
4
4
|
import { argvValue } from "./args.js";
|
|
5
|
-
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
6
6
|
import { createInterface } from "node:readline/promises";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { homedir } from "node:os";
|
|
7
9
|
import { stdin, argv } from "node:process";
|
|
8
10
|
import { createRequire } from "node:module";
|
|
9
11
|
import { Command, CommanderError, Option } from "commander";
|
|
@@ -28,7 +30,7 @@ import { sessionAccountForEnvironment } from "./session-account.js";
|
|
|
28
30
|
import { closeWritableWindow, openWritableWindow, parseWritableTtl, sweepWritableWindowsAtStartup, validateWritableReason, writableWindowStatus, WRITABLE_WINDOW_DEFAULT_TTL_MINUTES, WRITABLE_WINDOW_LOG, WRITABLE_WINDOW_MAX_TTL_MINUTES, WritableWindowInputError } from "./writable-window.js";
|
|
29
31
|
import { artifactPathMissHint, nullProjectionHint, PATH_MISS_HELP_REF, partialPathMissHint, pathMissCopyableHint, pathMissCopyablePaths, pathMissCrossFaceCorrection, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH, unwrapSinglePathProjection } from "./path-projection.js";
|
|
30
32
|
import { basename, dirname, join, resolve } from "node:path";
|
|
31
|
-
import { existsSync, readFileSync, writeFileSync, chmodSync } from "node:fs";
|
|
33
|
+
import { existsSync, readFileSync, writeFileSync, chmodSync, mkdirSync } from "node:fs";
|
|
32
34
|
import { buildToolRegistry } from "./tools.js";
|
|
33
35
|
import { parseDurationMs } from "./duration.js";
|
|
34
36
|
import { acquireWriteLock, writeLockHeldFace } from "./write-lock.js";
|
|
@@ -2763,6 +2765,156 @@ function joinSplitFlagValues(raw, flags) {
|
|
|
2763
2765
|
}
|
|
2764
2766
|
/** r60b-F7:最近一次 commander 帮助输出(configureOutput 的写通道暂存)。 */
|
|
2765
2767
|
let lastHelpChunk = "";
|
|
2768
|
+
const FRONTEND_CACHE_DIR = join(homedir(), ".omc", "frontend-probe");
|
|
2769
|
+
/** 与探针共用:`omc frontend setup` 把 playwright-core 装到 <cache>/node_modules。 */
|
|
2770
|
+
function resolveFrontendPlaywrightRoot() {
|
|
2771
|
+
const root = join(FRONTEND_CACHE_DIR, "node_modules");
|
|
2772
|
+
return existsSync(join(root, "playwright")) || existsSync(join(root, "playwright-core")) ? root : undefined;
|
|
2773
|
+
}
|
|
2774
|
+
function detectFrontendChromium() {
|
|
2775
|
+
const explicit = process.env.PW_EXECUTABLE_PATH ?? process.env.CHROME_PATH ?? process.env.PUPPETEER_EXECUTABLE_PATH;
|
|
2776
|
+
if (explicit)
|
|
2777
|
+
return existsSync(explicit) ? explicit : null;
|
|
2778
|
+
const candidates = [
|
|
2779
|
+
"/usr/bin/chromium", "/usr/bin/chromium-browser", "/usr/bin/google-chrome",
|
|
2780
|
+
"/usr/bin/google-chrome-stable", "/opt/google/chrome/chrome", "/snap/bin/chromium",
|
|
2781
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
2782
|
+
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
|
|
2783
|
+
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
|
|
2784
|
+
];
|
|
2785
|
+
return candidates.find((candidate) => existsSync(candidate)) ?? null;
|
|
2786
|
+
}
|
|
2787
|
+
function spawnCapture(command, args, env = process.env) {
|
|
2788
|
+
return new Promise((done) => {
|
|
2789
|
+
const child = spawn(command, args, { stdio: ["ignore", "pipe", "pipe"], env });
|
|
2790
|
+
let stdout = "";
|
|
2791
|
+
let stderr = "";
|
|
2792
|
+
child.stdout?.on("data", (chunk) => { stdout += chunk.toString("utf8"); });
|
|
2793
|
+
child.stderr?.on("data", (chunk) => { stderr += chunk.toString("utf8"); });
|
|
2794
|
+
child.on("error", (error) => done({ code: CLI_EXIT_CODES.internal, stdout, stderr: `${stderr}${error.message}` }));
|
|
2795
|
+
child.on("close", (code) => done({ code: code ?? CLI_EXIT_CODES.internal, stdout, stderr }));
|
|
2796
|
+
});
|
|
2797
|
+
}
|
|
2798
|
+
/**
|
|
2799
|
+
* `omc frontend setup`:方案 A —— 只装 `playwright-core`(几 MB,不下载浏览器),
|
|
2800
|
+
* 用系统 Chromium/Chrome;装到 OMC 自己的缓存目录,不污染全局 node_modules。
|
|
2801
|
+
* `--check` 只诊断,不联网。
|
|
2802
|
+
*/
|
|
2803
|
+
async function runFrontendSetup(options) {
|
|
2804
|
+
const chromium = detectFrontendChromium();
|
|
2805
|
+
const playwrightRoot = resolveFrontendPlaywrightRoot();
|
|
2806
|
+
if (options.check === true) {
|
|
2807
|
+
console.log(JSON.stringify({
|
|
2808
|
+
ok: playwrightRoot !== undefined && chromium !== null,
|
|
2809
|
+
cacheDir: FRONTEND_CACHE_DIR,
|
|
2810
|
+
playwrightRoot: playwrightRoot ?? null,
|
|
2811
|
+
chromium,
|
|
2812
|
+
installCommand: playwrightRoot === undefined ? `npm install --prefix ${FRONTEND_CACHE_DIR} playwright-core` : null,
|
|
2813
|
+
envHint: chromium === null ? "设置 PW_EXECUTABLE_PATH 指向 Chromium/Chrome,或安装系统浏览器" : null,
|
|
2814
|
+
}, null, 2));
|
|
2815
|
+
return CLI_EXIT_CODES.ok;
|
|
2816
|
+
}
|
|
2817
|
+
mkdirSync(FRONTEND_CACHE_DIR, { recursive: true });
|
|
2818
|
+
console.error(`[omc frontend] 安装 playwright-core → ${FRONTEND_CACHE_DIR}(不下载浏览器,使用系统 Chromium)`);
|
|
2819
|
+
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
2820
|
+
const installed = await spawnCapture(npm, [
|
|
2821
|
+
"install", "--prefix", FRONTEND_CACHE_DIR, "playwright-core",
|
|
2822
|
+
"--no-audit", "--no-fund", "--loglevel=error",
|
|
2823
|
+
...(options.force === true ? ["--force"] : []),
|
|
2824
|
+
]);
|
|
2825
|
+
if (installed.code !== 0) {
|
|
2826
|
+
console.error(`[omc frontend] playwright-core 安装失败(exit ${installed.code}):${installed.stderr.trim().slice(-800)}`);
|
|
2827
|
+
return installed.code;
|
|
2828
|
+
}
|
|
2829
|
+
const root = resolveFrontendPlaywrightRoot();
|
|
2830
|
+
if (root === undefined) {
|
|
2831
|
+
console.error(`[omc frontend] 安装命令成功但 ${join(FRONTEND_CACHE_DIR, "node_modules")} 下仍找不到 playwright-core`);
|
|
2832
|
+
return CLI_EXIT_CODES.internal;
|
|
2833
|
+
}
|
|
2834
|
+
if (chromium === null) {
|
|
2835
|
+
console.error("[omc frontend] playwright-core 已装好,但未找到 Chromium/Chrome;请安装系统浏览器或设置 PW_EXECUTABLE_PATH。");
|
|
2836
|
+
return CLI_EXIT_CODES.authConfig;
|
|
2837
|
+
}
|
|
2838
|
+
console.log(JSON.stringify({ ok: true, cacheDir: FRONTEND_CACHE_DIR, playwrightRoot: root, chromium }, null, 2));
|
|
2839
|
+
return CLI_EXIT_CODES.ok;
|
|
2840
|
+
}
|
|
2841
|
+
/**
|
|
2842
|
+
* `omc frontend probe`:把仓库内的 Playwright 前台探针(conformance/
|
|
2843
|
+
* frontend-behavior-probe.mjs)作为 CLI 子命令跑起来。它不是 `call` 工具,
|
|
2844
|
+
* 不进 tools/list;只负责解析环境/凭据并以子进程继承 stdio,退出码透传。
|
|
2845
|
+
*
|
|
2846
|
+
* 凭据从配置根读取后经环境变量注入子进程(不落盘);手跑场景仍可用 CREDS。
|
|
2847
|
+
* Playwright/Chromium 不是硬依赖:缺了由探针给出 PW_ROOT/PW_EXECUTABLE_PATH 指引。
|
|
2848
|
+
*/
|
|
2849
|
+
async function runFrontendProbe(options) {
|
|
2850
|
+
const probePath = fileURLToPath(new URL("../conformance/frontend-behavior-probe.mjs", import.meta.url));
|
|
2851
|
+
if (!existsSync(probePath)) {
|
|
2852
|
+
console.error(`[omc frontend] 探针脚本不存在:${probePath}(当前安装包未包含 conformance/;请从源码仓库运行,或升级到含该文件的版本)`);
|
|
2853
|
+
return CLI_EXIT_CODES.internal;
|
|
2854
|
+
}
|
|
2855
|
+
const args = [probePath];
|
|
2856
|
+
if (options.selfTest === true)
|
|
2857
|
+
args.push("--self-test");
|
|
2858
|
+
else if (options.validate !== undefined)
|
|
2859
|
+
args.push("--validate", options.validate);
|
|
2860
|
+
else if (options.scenario !== undefined)
|
|
2861
|
+
args.push("--scenario", options.scenario);
|
|
2862
|
+
else {
|
|
2863
|
+
console.error("用法:omc frontend probe --scenario <file> [--env <name>] [--report-dir <dir>] [--headed] [--fail-fast] [--trace]\n omc frontend probe --validate <file>\n omc frontend probe --self-test");
|
|
2864
|
+
return CLI_EXIT_CODES.invalidInput;
|
|
2865
|
+
}
|
|
2866
|
+
if (options.reportDir !== undefined)
|
|
2867
|
+
args.push("--out", options.reportDir);
|
|
2868
|
+
if (options.headed === true)
|
|
2869
|
+
args.push("--headed");
|
|
2870
|
+
if (options.failFast === true)
|
|
2871
|
+
args.push("--fail-fast");
|
|
2872
|
+
if (options.trace === true)
|
|
2873
|
+
args.push("--trace");
|
|
2874
|
+
if (options.screenshots === true)
|
|
2875
|
+
args.push("--screenshots");
|
|
2876
|
+
if (options.timeout !== undefined)
|
|
2877
|
+
args.push("--timeout", options.timeout);
|
|
2878
|
+
const env = { ...process.env };
|
|
2879
|
+
if (env.PW_ROOT === undefined) {
|
|
2880
|
+
const cached = resolveFrontendPlaywrightRoot();
|
|
2881
|
+
if (cached !== undefined)
|
|
2882
|
+
env.PW_ROOT = cached;
|
|
2883
|
+
}
|
|
2884
|
+
if (options.selfTest !== true && options.validate === undefined) {
|
|
2885
|
+
try {
|
|
2886
|
+
const store = new ConfigStore(defaultPaths());
|
|
2887
|
+
const resolved = store.resolveEnvironment(options.env);
|
|
2888
|
+
const baseUrl = (options.baseUrl ?? resolved.profile.baseUrl).replace(/\/+$/, "");
|
|
2889
|
+
args.push("--base-url", baseUrl);
|
|
2890
|
+
env.OMC_ENV = resolved.name;
|
|
2891
|
+
env.BASE_URL = baseUrl;
|
|
2892
|
+
try {
|
|
2893
|
+
const credential = store.readCredential(resolved.name);
|
|
2894
|
+
env.OMC_PROBE_USERNAME = credential.username;
|
|
2895
|
+
env.OMC_PROBE_PASSWORD = credential.password;
|
|
2896
|
+
}
|
|
2897
|
+
catch {
|
|
2898
|
+
// 凭据不在配置根时,退回探针的 CREDS 文件路径(手跑场景)。
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
catch (error) {
|
|
2902
|
+
if (options.baseUrl === undefined) {
|
|
2903
|
+
console.error(`[omc frontend] 无法解析环境:${error instanceof Error ? error.message : String(error)}`);
|
|
2904
|
+
return CLI_EXIT_CODES.invalidInput;
|
|
2905
|
+
}
|
|
2906
|
+
args.push("--base-url", options.baseUrl);
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
return await new Promise((resolve) => {
|
|
2910
|
+
const child = spawn(process.execPath, args, { stdio: "inherit", env });
|
|
2911
|
+
child.on("error", (error) => {
|
|
2912
|
+
console.error(`[omc frontend] 探针启动失败:${error.message}`);
|
|
2913
|
+
resolve(CLI_EXIT_CODES.internal);
|
|
2914
|
+
});
|
|
2915
|
+
child.on("close", (code) => resolve(code ?? CLI_EXIT_CODES.internal));
|
|
2916
|
+
});
|
|
2917
|
+
}
|
|
2766
2918
|
async function main() {
|
|
2767
2919
|
let commandExitCode = 0;
|
|
2768
2920
|
// r73 #7:artifact get 的 --out 值(在 configureOutput 之前截获,见下)。全局
|
|
@@ -3058,6 +3210,30 @@ async function main() {
|
|
|
3058
3210
|
// landed in the argParser slot and silently dropped every --steps value
|
|
3059
3211
|
// (live 2026-10-18: `--steps "审批@role:x"` answered "至少一个 --steps").
|
|
3060
3212
|
const collectValues = (value, previous = []) => [...previous, value];
|
|
3213
|
+
const frontendCommand = command.command("frontend").description("前台运行时验证(Playwright):omc frontend probe --scenario <file> --env <name>(在线 JS / 表单按钮 / 列表按钮 / 计算规则 / 字段显隐)");
|
|
3214
|
+
frontendCommand
|
|
3215
|
+
.command("setup")
|
|
3216
|
+
.description("一次性安装 playwright-core 到 OMC 缓存(不下载浏览器,使用系统 Chromium/Chrome)")
|
|
3217
|
+
.option("--check", "只诊断(输出 JSON,不联网安装)")
|
|
3218
|
+
.option("--force", "强制重装 playwright-core")
|
|
3219
|
+
.addHelpText("after", "\n等价手工命令:npm install --prefix " + FRONTEND_CACHE_DIR + " playwright-core\n探针会自动优先从该缓存加载;也可设 PW_ROOT 指向已有 playwright 的 node_modules、PW_EXECUTABLE_PATH 指向浏览器。\n")
|
|
3220
|
+
.action(async (options) => { commandExitCode = await runFrontendSetup(options); });
|
|
3221
|
+
frontendCommand
|
|
3222
|
+
.command("probe")
|
|
3223
|
+
.description("跑前台行为探针;产出 probe-report.json(默认不截图)")
|
|
3224
|
+
.option("--scenario <file>", "场景 JSON(模板见 conformance/frontend-scenarios/)")
|
|
3225
|
+
.option("--env <environment>", "环境名(决定 baseUrl 与登录凭据;--base-url 可覆盖地址)")
|
|
3226
|
+
.option("--base-url <url>", "覆盖环境 baseUrl")
|
|
3227
|
+
.option("--report-dir <dir>", "探针输出目录(报告 + 截图;默认 ./frontend-probe-out)。注意:全局 `--out <file>` 是 stdout 信封落盘,与此无关")
|
|
3228
|
+
.option("--headed", "显示浏览器")
|
|
3229
|
+
.option("--fail-fast", "首个失败即停")
|
|
3230
|
+
.option("--timeout <ms>", "单步/等待超时")
|
|
3231
|
+
.option("--screenshots", "逐步骤截图(默认不截图;失败也不自动截图)")
|
|
3232
|
+
.option("--trace", "写 Playwright trace.zip")
|
|
3233
|
+
.option("--self-test", "用内联 HTML 验证探针自身(不连环境)")
|
|
3234
|
+
.option("--validate <file>", "离线校验场景 JSON")
|
|
3235
|
+
.addHelpText("after", "\n需要 Playwright + Chromium:默认从 PW_ROOT 的 node_modules 取 playwright、PW_EXECUTABLE_PATH 或 /usr/bin/chromium 启浏览器;缺失时探针会给出安装指引。凭据从 OMC 配置根读取,也可用 CREDS 文件。\n默认**不写截图**(--screenshots 开启)。stdout 只有探针自己的输出(无 CLI 信封),退出码透传:0 全通过 · 1 断言/步骤失败 · 2 场景非法 · 3 harness/登录/浏览器错误。\n场景提交/保存数据成功后会打印 `DATA-LINK <url>`,可直接点开该单据。\n示例:omc frontend probe --scenario calc-visibility.json --env t248 --report-dir /tmp/probe-out --headed\n")
|
|
3236
|
+
.action(async (options) => { commandExitCode = await runFrontendProbe(options); });
|
|
3061
3237
|
command.command("rule-when").option("--schema <schemaCode>").option("--schema-code <schemaCode>").option("--on <trigger>", "触发时机:create | update(**没有 submit**——提交后执行请用 create 或 update,按平台触发面语义选)").addOption(new Option("--when <condition>", "条件,可重复").argParser(collectValues).default([])).addOption(new Option("--then <action>", "动作,可重复").argParser(collectValues).default([])).option("--name <name>").option("--env <environment>").option("--environment <environment>").option("--apply").addHelpText("after", "\n条件-动作规则拼装器:--when 条件(可多个 AND)→ --then set:字段=值/引用/公式。编译为设计器验证形状(预置触发+UPDATE filter/赋值)。默认 dry-run,--apply 保存并发布;前台生效按输出清单人工验证。\n触发时机只有 create / update 两个(无 submit):\"提交后/审批前\"这类需求在平台侧没有独立触发点,用 create(新建即触发)或 update(更新即触发)表达;要按状态过滤,把条件写进 --when。\n").action(async (options) => {
|
|
3062
3238
|
const rest = ["rule-when", ...(options.schema ? ["--schema", options.schema] : []), ...(options.schemaCode ? ["--schema-code", options.schemaCode] : []), ...(options.on ? ["--on", options.on] : []), ...(Array.isArray(options.when) ? options.when.flatMap((w) => ["--when", w]) : []), ...(Array.isArray(options.then) ? options.then.flatMap((a) => ["--then", a]) : []), ...(options.name ? ["--name", options.name] : []), ...(options.env ? ["--env", options.env] : []), ...(options.environment ? ["--environment", options.environment] : []), ...(options.apply ? ["--apply"] : [])];
|
|
3063
3239
|
commandExitCode = await cmdRuleWhen(rest);
|
package/dist/endpoints.js
CHANGED
|
@@ -124,6 +124,7 @@ export const ENDPOINTS = {
|
|
|
124
124
|
sheetCreate: "/api/api/app/bizsheet/create",
|
|
125
125
|
sheetUpdate: "/api/api/app/bizsheet/update",
|
|
126
126
|
sheetPublish: "/api/api/app/bizsheet/publish",
|
|
127
|
+
sheetList: "/api/api/app/bizsheet/list",
|
|
127
128
|
sheetHistoryList: "/api/api/app/bizsheet/history/list",
|
|
128
129
|
businessRuleListBySchemaCode: "/api/api/app/businessrule/list_by_schemacode",
|
|
129
130
|
runtimeBusinessRuleListBySchemaCode: "/api/api/runtime/business_rule/list_by_schemacode",
|
|
@@ -349,6 +350,7 @@ export const ENDPOINTS = {
|
|
|
349
350
|
permissionGroup: "/api/api/system/permission/get_group",
|
|
350
351
|
permissionGroupBySchema: "/api/api/system/permission/getGroupBySchemaCode",
|
|
351
352
|
permissionGroupUpdate: "/api/api/system/permission/update_group",
|
|
353
|
+
permissionUpdateFunction: "/api/api/system/permission/update_function",
|
|
352
354
|
permissionGroupAndFunctionUpdate: "/api/api/system/permission/updatePermissionGroupAndFunction",
|
|
353
355
|
permissionGroupStatus: "/api/api/system/permission/updatePermissionGroupStatus",
|
|
354
356
|
permissionGroupDelete: "/api/api/system/permission/delete_group",
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { ENDPOINTS } from "./endpoints.js";
|
|
2
|
+
import { ToolRefusalError } from "./tool-types.js";
|
|
3
|
+
import { wireCall, wireRows } from "./wire.js";
|
|
4
|
+
/** 把 options 列(对象或 JSON 字符串)归一成对象;解析失败按空对象处理。 */
|
|
5
|
+
function optionsObjectOf(raw) {
|
|
6
|
+
if (raw === null || raw === undefined)
|
|
7
|
+
return {};
|
|
8
|
+
if (typeof raw === "string") {
|
|
9
|
+
const trimmed = raw.trim();
|
|
10
|
+
if (!trimmed)
|
|
11
|
+
return {};
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(trimmed);
|
|
14
|
+
return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (typeof raw === "object" && !Array.isArray(raw))
|
|
21
|
+
return raw;
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
/** options.optionsSet 可能是对象,也可能是未解码的 JSON 字符串。 */
|
|
25
|
+
function optionsSetObjectOf(raw) {
|
|
26
|
+
if (typeof raw === "string") {
|
|
27
|
+
const trimmed = raw.trim();
|
|
28
|
+
if (!trimmed)
|
|
29
|
+
return undefined;
|
|
30
|
+
try {
|
|
31
|
+
const parsed = JSON.parse(trimmed);
|
|
32
|
+
return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (raw !== null && typeof raw === "object" && !Array.isArray(raw))
|
|
39
|
+
return raw;
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
function childPath(parent, index) {
|
|
43
|
+
return `${parent}[${index}]`;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 纯函数:返回树形自定义选项的发布门问题清单。只处理
|
|
47
|
+
* `optionsType:"custom"` + `optionStructure:"tree"`;其余(平铺/字典/业务
|
|
48
|
+
* 模型/缺省)一律 `[]`。`code` 先 trim 再判空与去重,与平台
|
|
49
|
+
* `StringUtils.isBlank` + `codes.add(code)` 的语义一致(平台对原始 code
|
|
50
|
+
* 去重,因此 `"a"` 与 `" a "` 在这里也视为重复,宁可先拦)。
|
|
51
|
+
*/
|
|
52
|
+
export function treeSelectionOptionProblems(fieldCode, options) {
|
|
53
|
+
const optionsSet = optionsSetObjectOf(options.optionsSet);
|
|
54
|
+
if (!optionsSet)
|
|
55
|
+
return [];
|
|
56
|
+
if (optionsSet.optionsType !== "custom" || optionsSet.optionStructure !== "tree")
|
|
57
|
+
return [];
|
|
58
|
+
const custom = optionsSet.custom;
|
|
59
|
+
if (custom === undefined || custom === null)
|
|
60
|
+
return [];
|
|
61
|
+
if (!Array.isArray(custom))
|
|
62
|
+
return [];
|
|
63
|
+
const problems = [];
|
|
64
|
+
const seenCodes = new Map();
|
|
65
|
+
const walk = (nodes, at) => {
|
|
66
|
+
nodes.forEach((node, index) => {
|
|
67
|
+
const path = childPath(at, index);
|
|
68
|
+
if (node === null || typeof node !== "object" || Array.isArray(node)) {
|
|
69
|
+
problems.push({ field: fieldCode, path, index, reason: "node-not-object", message: "节点必须是对象({code, value, children?})" });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const record = node;
|
|
73
|
+
const rawCode = record.code;
|
|
74
|
+
let code;
|
|
75
|
+
if (rawCode === undefined || rawCode === null) {
|
|
76
|
+
problems.push({ field: fieldCode, path, index, reason: "code-missing", message: "缺少选项编码 code(平台内部叫选项编码,口语叫 key)" });
|
|
77
|
+
}
|
|
78
|
+
else if (typeof rawCode !== "string") {
|
|
79
|
+
problems.push({ field: fieldCode, path, index, reason: "code-invalid", message: `选项编码 code 必须是字符串(收到 ${typeof rawCode})` });
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const trimmed = rawCode.trim();
|
|
83
|
+
if (!trimmed) {
|
|
84
|
+
problems.push({ field: fieldCode, path, index, reason: "code-missing", message: "选项编码 code 不能为空白" });
|
|
85
|
+
}
|
|
86
|
+
else if (seenCodes.has(trimmed)) {
|
|
87
|
+
problems.push({
|
|
88
|
+
field: fieldCode,
|
|
89
|
+
path,
|
|
90
|
+
index,
|
|
91
|
+
reason: "code-duplicate",
|
|
92
|
+
code: trimmed,
|
|
93
|
+
message: `选项编码 code「${trimmed}」与 ${seenCodes.get(trimmed)} 重复(必须全树唯一)`,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
seenCodes.set(trimmed, path);
|
|
98
|
+
code = trimmed;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const rawValue = record.value;
|
|
102
|
+
if (rawValue === undefined || rawValue === null) {
|
|
103
|
+
problems.push({ field: fieldCode, path, index, reason: "value-missing", message: "缺少显示值 value(平台回执里叫数据项/显示值)", ...(code !== undefined ? { code } : {}) });
|
|
104
|
+
}
|
|
105
|
+
else if (typeof rawValue !== "string") {
|
|
106
|
+
problems.push({ field: fieldCode, path, index, reason: "value-invalid", message: `显示值 value 必须是字符串(收到 ${typeof rawValue})`, ...(code !== undefined ? { code } : {}) });
|
|
107
|
+
}
|
|
108
|
+
else if (!rawValue.trim()) {
|
|
109
|
+
problems.push({ field: fieldCode, path, index, reason: "value-missing", message: "显示值 value 不能为空白", ...(code !== undefined ? { code } : {}) });
|
|
110
|
+
}
|
|
111
|
+
if (Array.isArray(record.children))
|
|
112
|
+
walk(record.children, `${path}.children`);
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
walk(custom, "custom");
|
|
116
|
+
return problems;
|
|
117
|
+
}
|
|
118
|
+
function problemLines(problems) {
|
|
119
|
+
return problems.map((problem) => `- ${problem.field} ${problem.path}(${problem.reason}):${problem.message}`).join("\n");
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 读草稿面字段(或复用调用方已读到的 rows),逐字段跑发布门预检;有问题
|
|
123
|
+
* 抛 `ToolRefusalError`,在真正 POST `bizproperty/publish` 之前短路。
|
|
124
|
+
*
|
|
125
|
+
* `fieldCount` = 命中问题的字段数;`checkedFieldCount` = 本次实际检查的字段数。
|
|
126
|
+
*/
|
|
127
|
+
export async function assertTreeSelectionOptions(session, schemaCode, rows) {
|
|
128
|
+
const draftRows = rows ?? wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode, isPublish: "false" } })).data);
|
|
129
|
+
const problems = [];
|
|
130
|
+
const affected = new Set();
|
|
131
|
+
let checked = 0;
|
|
132
|
+
for (const row of draftRows) {
|
|
133
|
+
const fieldCode = String(row.code ?? row.propertyCode ?? "");
|
|
134
|
+
if (!fieldCode)
|
|
135
|
+
continue;
|
|
136
|
+
checked += 1;
|
|
137
|
+
const found = treeSelectionOptionProblems(fieldCode, optionsObjectOf(row.options));
|
|
138
|
+
if (found.length === 0)
|
|
139
|
+
continue;
|
|
140
|
+
affected.add(fieldCode);
|
|
141
|
+
problems.push(...found);
|
|
142
|
+
}
|
|
143
|
+
if (problems.length === 0)
|
|
144
|
+
return;
|
|
145
|
+
throw new ToolRefusalError({
|
|
146
|
+
status: "refused",
|
|
147
|
+
blocker: "field-tree-options-invalid",
|
|
148
|
+
schemaCode,
|
|
149
|
+
fieldCount: affected.size,
|
|
150
|
+
checkedFieldCount: checked,
|
|
151
|
+
problems,
|
|
152
|
+
nextCommand: `omc call field.list --args '${JSON.stringify({ schemaCode, published: false })}'`,
|
|
153
|
+
message: `发布前预检拒绝:${affected.size} 个字段的树形自定义选项不合法(共 ${problems.length} 处)。` +
|
|
154
|
+
"这是 CloudPivot 2.1.5+(客户口径 8.8)新增的**发布门**:optionsSet.optionsType=\"custom\" 且 optionStructure=\"tree\" 时,服务端递归要求每个节点的 " +
|
|
155
|
+
"code(平台内部叫**选项编码**,口语叫 key)与 value(显示值)都非空,且 code 全树唯一——" +
|
|
156
|
+
"否则整个模型发布失败(RadioOptionsModel.validateCustomTreeOptions,launcher-2.1.5 .../bizmodel/RadioOptionsModel.java:130-142;门条件同文件 :124-126;" +
|
|
157
|
+
"入口 BizSchemaCheckServiceImpl.publishBizSchemaBefore :60-66 / checkOptions :134-160)。" +
|
|
158
|
+
"8.6/8.7 没有这道门;平铺自定义(optionStructure 缺省或 \"flat\")、字典、业务模型下拉都不校验;field.create/field.update 阶段也不校验," +
|
|
159
|
+
"所以非法树能存进草稿,直到模型级发布才整单失败(外层 300004「数据模型不存在!」+ 载荷 609016,逐项 301013「…数据项的选项设置有误,请重新设置」)。\n" +
|
|
160
|
+
`问题:\n${problemLines(problems)}\n` +
|
|
161
|
+
"修法二选一:① 用 field.update 给这些节点补非空 code/value(code 就是平台回执里的「选项编码」,不是另有一个 key 字段);" +
|
|
162
|
+
"② 不需要层级时把 optionsSet.optionStructure 改成 \"flat\"(会丢掉树结构)。",
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=field-tree-options.js.map
|
package/dist/form-support.js
CHANGED
|
@@ -601,6 +601,17 @@ export function assertFormulasSurvivedRebuild(next, baseline, where) {
|
|
|
601
601
|
`只改字段时不要用 cascadeRepublish。`,
|
|
602
602
|
});
|
|
603
603
|
}
|
|
604
|
+
/**
|
|
605
|
+
* 2.1.5 设计器把「已发布字段原地改控件类型」做成 pending 状态:控件 options 上打
|
|
606
|
+
* `typeChanged:true` + `fromType`(另有 `controlTypeChanged`),见
|
|
607
|
+
* cloudpivot-designer-2.1.5 package/src/form-design/scripts/edit-property.ts:80-102
|
|
608
|
+
* (isPendingTypeChanged:`control.type !== fromType` 即「仍在转换中」);同文件
|
|
609
|
+
* :199-203 在发布分支把表单级 options.dataItemTypeChangeList 清空为 []。
|
|
610
|
+
* 8.6 全包没有这些键,但旧草稿可能来自 2.1.5 设计器:rebuild 按字段元数据重造控件,
|
|
611
|
+
* 若把旧标记原样盖回,设计器会永远显示未完成的类型转换。这里只丢 pending 标记,
|
|
612
|
+
* 其余 options(formula/visible/mappings…)照旧保留。
|
|
613
|
+
*/
|
|
614
|
+
const PENDING_TYPE_CHANGE_KEYS = new Set(["typeChanged", "fromType", "controlTypeChanged"]);
|
|
604
615
|
export function preserveDesignerControlOptions(next, previous) {
|
|
605
616
|
const STRUCTURAL = new Set(["name", "name_i18n", "schemaCode", "displayField", "queryCode", "relativePropertyMatchCode"]);
|
|
606
617
|
const preserved = [];
|
|
@@ -617,7 +628,7 @@ export function preserveDesignerControlOptions(next, previous) {
|
|
|
617
628
|
continue;
|
|
618
629
|
const merged = { ...fresh.options };
|
|
619
630
|
for (const [optionKey, value] of Object.entries(prior.options)) {
|
|
620
|
-
if (STRUCTURAL.has(optionKey) || value === undefined)
|
|
631
|
+
if (STRUCTURAL.has(optionKey) || PENDING_TYPE_CHANGE_KEYS.has(optionKey) || value === undefined)
|
|
621
632
|
continue;
|
|
622
633
|
merged[optionKey] = value;
|
|
623
634
|
}
|
|
@@ -1008,6 +1019,42 @@ function decodeOptionsColumn(value) {
|
|
|
1008
1019
|
}
|
|
1009
1020
|
return {};
|
|
1010
1021
|
}
|
|
1022
|
+
/**
|
|
1023
|
+
* 2.1.5 设计器的发布语义:把表单级 pending 类型转换列表
|
|
1024
|
+
* `options.dataItemTypeChangeList` 清空为 `[]`——cloudpivot-designer-2.1.5
|
|
1025
|
+
* package/src/form-design/scripts/edit-property.ts:199-203 的 isPublish 分支恒写
|
|
1026
|
+
* `[]`(对应控件上的 typeChanged/fromType,同文件 :80-102)。OMC 的 form.publish
|
|
1027
|
+
* 是整包读回再写:原样回写会让已发布表单仍带 pending 列表,下一次设计器保存会
|
|
1028
|
+
* merge 回陈旧条目。键不存在时**不新增**:8.6 表单没有这个键(全包 0 命中),
|
|
1029
|
+
* 凭空添加会污染 options 回读/等价校验。输入可能是 options 列字符串或已解码对象,
|
|
1030
|
+
* 返回保持原形态(string→string);无需改写时返回 undefined。
|
|
1031
|
+
*/
|
|
1032
|
+
function clearPendingTypeChangeList(options) {
|
|
1033
|
+
const serialized = typeof options === "string";
|
|
1034
|
+
let parsed;
|
|
1035
|
+
if (serialized) {
|
|
1036
|
+
try {
|
|
1037
|
+
const value = JSON.parse(options);
|
|
1038
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
1039
|
+
return undefined;
|
|
1040
|
+
parsed = { ...value };
|
|
1041
|
+
}
|
|
1042
|
+
catch {
|
|
1043
|
+
return undefined;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
else if (options !== null && typeof options === "object" && !Array.isArray(options)) {
|
|
1047
|
+
parsed = { ...options };
|
|
1048
|
+
}
|
|
1049
|
+
else {
|
|
1050
|
+
return undefined;
|
|
1051
|
+
}
|
|
1052
|
+
const pending = parsed.dataItemTypeChangeList;
|
|
1053
|
+
if (!Array.isArray(pending) || pending.length === 0)
|
|
1054
|
+
return undefined;
|
|
1055
|
+
parsed.dataItemTypeChangeList = [];
|
|
1056
|
+
return serialized ? JSON.stringify(parsed) : parsed;
|
|
1057
|
+
}
|
|
1011
1058
|
/**
|
|
1012
1059
|
* Merge the caller's form buttons into the sheet `options` column. Returns the
|
|
1013
1060
|
* options JSON string to POST (undefined = leave the column untouched).
|
|
@@ -1037,6 +1084,11 @@ export function mergeFormOptionsWithButtons(existingOptions, input, tool) {
|
|
|
1037
1084
|
incoming = validateFormButtons(parsed, tool);
|
|
1038
1085
|
}
|
|
1039
1086
|
const options = decodeOptionsColumn(existingOptions);
|
|
1087
|
+
// 2.1.5 把表单 AI 助理配置从 sheet payload 拆到 POST /api/ai/form_assistant/config/update
|
|
1088
|
+
// (设计器保存时会 `delete options.formAssistantConfig`)。OMC 是按读回整包合并 options 的:
|
|
1089
|
+
// 若把旧值原样回写,会和 AI 侧新配置打架。这里在合并前剔除该键(8.6 无此键,删除无害)。
|
|
1090
|
+
if (options !== undefined && typeof options === "object" && "formAssistantConfig" in options)
|
|
1091
|
+
delete options.formAssistantConfig;
|
|
1040
1092
|
// Default MERGE: an upsert by `code` so a caller can add or edit ONE button
|
|
1041
1093
|
// without re-sending the whole list (and without a read-modify-write race).
|
|
1042
1094
|
// `replace` restores the whole-list semantics.
|
|
@@ -1735,9 +1787,14 @@ export async function executeFormPublishWrite(session, args) {
|
|
|
1735
1787
|
// (ModelManagementFacadeImpl.publishBizForm:1022). Passing them here is the
|
|
1736
1788
|
// only way to create form buttons without the designer.
|
|
1737
1789
|
const mergedOptions = mergeFormOptionsWithButtons(pre.options, { buttons: args.buttons, customButtonJson: args.customButtonJson, buttonsMode: args.buttonsMode, removeButtonCodes: args.removeButtonCodes, buttonScripts: args.buttonScripts }, "form.publish");
|
|
1790
|
+
// 2.1.5 设计器发布时恒清空 options.dataItemTypeChangeList(edit-property.ts:199-203)。
|
|
1791
|
+
// 清空必须作用在**最终** options 上:按钮合并优先(mergedOptions 是字符串),
|
|
1792
|
+
// 没有按钮增量时才回落到 pre.options;键不存在则原样透传,不新增。
|
|
1793
|
+
const pendingCleared = clearPendingTypeChangeList(mergedOptions ?? pre.options);
|
|
1794
|
+
const finalOptions = mergedOptions !== undefined ? pendingCleared ?? mergedOptions : pendingCleared;
|
|
1738
1795
|
const payload = {
|
|
1739
1796
|
...pre,
|
|
1740
|
-
...(
|
|
1797
|
+
...(finalOptions !== undefined ? { options: finalOptions } : {}),
|
|
1741
1798
|
schemaCode: args.schemaCode,
|
|
1742
1799
|
code: args.sheetCode,
|
|
1743
1800
|
name: pre.name,
|
package/dist/formula-lint.js
CHANGED
|
@@ -19,10 +19,14 @@ export const FORMULA_FUNCTIONS = new Set([
|
|
|
19
19
|
"LOWER", "UPPER", "SEARCH", "STARTSWITH", "SUBSTITUTE", "TRIM", "GETUNITNAME", "LEFT",
|
|
20
20
|
"RIGHT", "TEXT", "UNION", "DATE", "COUNTIF", "SUM", "AVG", "MAX", "MIN", "COUNT", "ROUND",
|
|
21
21
|
"INTUP", "INTDOWN", "VALUE", "FIXED", "ABS", "CEILING", "FLOOR", "COS", "SIN", "LARGE",
|
|
22
|
-
"SMALL", "LOG", "MOD", "PI", "POWER", "RAND", "SQRT", "SUMIF", "DATEDIF", "YEAR", "MONTH",
|
|
22
|
+
"SMALL", "LOG", "MOD", "PI", "POWER", "RAND", "SQRT", "SUMIF", "PRODUCT", "DATEDIF", "YEAR", "MONTH",
|
|
23
23
|
"DAY", "WEEKNUM", "WEEKDAY", "QUARTER", "HOUR", "MINUTE", "SECOND", "ADDDAY", "ADDMONTH",
|
|
24
24
|
"ADDYEAR", "TODAY", "BETWEEN", "NOTBETWEEN", "ADDHOUR", "ADDMINUTE", "NOW", "CASE", "ISNULL",
|
|
25
25
|
]);
|
|
26
|
+
// 2.1.5 新增 `PRODUCT`(累乘):`launcher-2.1.5/cloudpivot-contracts-AI-Platform-v2.1.5/.../
|
|
27
|
+
// bizmodel/CalculateMethodType.java:57`,并进 `aggregateTypes`(同文件 :107)。8.6.26 未注册
|
|
28
|
+
// (该版枚举到 SUMIF 直接接 DATEDIF)——lint 是 advisory、不按版本分支,所以并集放行;
|
|
29
|
+
// 8.6 环境真用 PRODUCT() 会在提交期报 101005,由服务端兜底。
|
|
26
30
|
/** Names agents reach for that the engine does NOT register, with the real one. */
|
|
27
31
|
export const FORMULA_FUNCTION_ALIASES = Object.freeze({
|
|
28
32
|
CONCAT: "STRING",
|