@stalfh233/omc-cli 0.8.6 → 0.8.8
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/coverage/m1-coverage-manifest-v1.json +1 -0
- package/dist/approval-flow.js +49 -4
- package/dist/batch-call.js +21 -4
- package/dist/cli-stdout.js +1 -0
- package/dist/cli.js +84 -3
- package/dist/code-rules.js +35 -11
- package/dist/config-store.js +15 -1
- package/dist/endpoints.js +10 -0
- package/dist/form-layout.js +79 -0
- package/dist/form-support.js +111 -7
- package/dist/graph.js +38 -3
- package/dist/human-summary.js +19 -1
- package/dist/lanes/field-contract.js +5 -1
- package/dist/lanes/field-coverage.js +1 -0
- package/dist/lanes/field.js +20 -2
- package/dist/lanes/form-contract.js +1 -1
- package/dist/lanes/form.js +24 -2
- package/dist/lanes/list-view.js +104 -2
- package/dist/lanes/model-references.js +172 -0
- package/dist/lanes/model.js +206 -123
- package/dist/lanes/runtime-data-contract.js +4 -4
- package/dist/lanes/runtime-data.js +170 -7
- package/dist/lanes/workflow.js +213 -45
- package/dist/model-purge.js +106 -21
- package/dist/model-scaffold.js +52 -10
- package/dist/recipes/field.js +44 -1
- package/dist/recipes/form.js +33 -6
- package/dist/recipes/list-view.js +1 -1
- package/dist/reserved.js +28 -0
- package/dist/search-index.js +2 -0
- package/dist/tool-types.js +1 -0
- package/dist/write.js +12 -0
- package/package.json +3 -3
- package/skills/omc-business-configuration.md +6 -0
- package/skills/omc-capabilities.md +1 -1
- package/skills/omc-playbook.md +5 -0
- package/skills/omc-requirement-vocabulary.md +13 -0
- package/skills/omc-start-here.md +1 -1
- package/skills/omc-tool-selection.md +2 -0
- package/skills/omc-write-hazards.md +3 -0
package/dist/approval-flow.js
CHANGED
|
@@ -20,6 +20,8 @@ import { runToolCall } from "./call.js";
|
|
|
20
20
|
import { envelope, requestId, classifyResult, CLI_EXIT_CODES } from "./cli-contract.js";
|
|
21
21
|
import { writeEnvelope } from "./cli-output.js";
|
|
22
22
|
import { argvValue } from "./args.js";
|
|
23
|
+
import { ConfigStore, defaultPaths } from "./config-store.js";
|
|
24
|
+
import { sessionAccountForEnvironment } from "./session-account.js";
|
|
23
25
|
/**
|
|
24
26
|
* r31c F20: participant object arrays only accept `{code,corpId,id,name,type}`.
|
|
25
27
|
* Intuitive keys (`participantType`/`roleId`/`participantName`) are silently
|
|
@@ -65,8 +67,8 @@ export function assertParticipantShape(participant, at) {
|
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
|
-
/** 解析步骤 DSL 为 {name,
|
|
69
|
-
export function
|
|
70
|
+
/** 解析步骤 DSL 为 {name,participant,kind,code}(导出供测试)。 */
|
|
71
|
+
export function parseStepDetail(raw) {
|
|
70
72
|
const match = /^(.+?)@(role|user):([A-Za-z0-9_.:-]+)$/.exec(raw.trim());
|
|
71
73
|
if (!match)
|
|
72
74
|
throw new Error(`--steps "${raw}" 解析失败:形如 名称@role:<角色code> 或 名称@user:<用户id>(自由文本角色名能发布但解析不到人、不生成待办)`);
|
|
@@ -74,10 +76,50 @@ export function parseStep(raw) {
|
|
|
74
76
|
// Role steps stay on FindUserByRole (department-scoped). User steps emit the
|
|
75
77
|
// canonical object array — never participantType/roleId.
|
|
76
78
|
if (kind === "role")
|
|
77
|
-
return { name: name.trim(), participant: `FindUserByRole({Originator.OU},"${code}","random")` };
|
|
79
|
+
return { name: name.trim(), kind: "role", code: code, participant: `FindUserByRole({Originator.OU},"${code}","random")` };
|
|
78
80
|
const participant = JSON.stringify([{ code, corpId: "other", id: code, name: name.trim(), type: 3 }]);
|
|
79
81
|
assertParticipantShape(participant, `--steps ${name}`);
|
|
80
|
-
return { name: name.trim(), participant };
|
|
82
|
+
return { name: name.trim(), kind: "user", code: code, participant };
|
|
83
|
+
}
|
|
84
|
+
/** 解析步骤 DSL 为 {name, participant}(导出供测试)。 */
|
|
85
|
+
export function parseStep(raw) {
|
|
86
|
+
const detail = parseStepDetail(raw);
|
|
87
|
+
return { name: detail.name, participant: detail.participant };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* F11(0.8.7 探针 B):dry-run 回执里 user 参与者的 `corpId:"other"` 是 **CLI
|
|
91
|
+
* 自己**为 `--steps 名称@user:<id>` 生成的占位(见 parseStepDetail),不是平台
|
|
92
|
+
* 要求,也不是「查不到组织」。平台解析用户时先按 `id` 找人,id 命中则 corpId
|
|
93
|
+
* 不参与(8.6.26 `ParticipleServiceImplCompanion.java:171-174`、
|
|
94
|
+
* `WorkflowTemplateValidateUtility.java:549-552`;type 3=用户见 `UnitType.java`)。
|
|
95
|
+
* 这行说明进 dry-run,避免调用方把占位当坏数据去「修」。
|
|
96
|
+
*
|
|
97
|
+
* 显示名只在**零额外 wire**可得时给:本地 token 缓存的会话账号 id 与该 user
|
|
98
|
+
* 步骤的 id 相同,才把它标成 resolvedName;否则只解释语义,不猜。
|
|
99
|
+
*/
|
|
100
|
+
function participantNotes(steps, environment) {
|
|
101
|
+
const account = sessionAccountForEnvironment(new ConfigStore(defaultPaths()), environment);
|
|
102
|
+
const notes = [];
|
|
103
|
+
for (const raw of steps) {
|
|
104
|
+
const detail = parseStepDetail(raw);
|
|
105
|
+
if (detail.kind !== "user")
|
|
106
|
+
continue;
|
|
107
|
+
const resolvedName = "id" in account && account.id === detail.code && typeof account.name === "string" && account.name.length > 0 ? account.name : undefined;
|
|
108
|
+
notes.push({
|
|
109
|
+
activity: detail.name,
|
|
110
|
+
type: 3,
|
|
111
|
+
typeName: "用户",
|
|
112
|
+
code: detail.code,
|
|
113
|
+
corpId: "other",
|
|
114
|
+
note: "corpId:\"other\" 是 CLI 为 user 参与者生成的本地占位(src/approval-flow.ts parseStepDetail),不是平台要求、也不是组织查询结果;平台先按 id 解析用户,id 命中时 corpId 不参与(8.6.26 ParticipleServiceImplCompanion.java:171-174 / WorkflowTemplateValidateUtility.java:549-552,type 3=用户)。审批人按 id 找人,apply 后接待办解析为本人。",
|
|
115
|
+
...(resolvedName !== undefined
|
|
116
|
+
? { resolvedName, resolvedNameSource: "sessionAccount(本地 token 缓存,零 wire)" }
|
|
117
|
+
: {
|
|
118
|
+
resolvedNameNote: "当前会话账号与该步骤 id 不同或本地无缓存 token,dry-run 不访问环境,无法零 wire 解析显示名(不猜);apply 后工作流读面会按 id 解析。",
|
|
119
|
+
}),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return notes;
|
|
81
123
|
}
|
|
82
124
|
/** 编译完整模板(recipe 验证形状)。 */
|
|
83
125
|
export function composeApprovalTemplate(options) {
|
|
@@ -129,6 +171,7 @@ export async function cmdApprovalFlow(args) {
|
|
|
129
171
|
const usage = [
|
|
130
172
|
'用法:omc approval-flow --schema <模型> --steps "节点名@role:<角色code>" [--steps ...多级] [--no-originator-node] [--no-reject-to-start] [--apply]',
|
|
131
173
|
"步骤也可用 名称@user:<用户id> 绑定具体审批人。默认 dry-run(编译模板预览);--apply 建/改流程+字段权限+发布。",
|
|
174
|
+
"user 参与者的 corpId 是 CLI 生成的本地占位(平台按 id 解析用户,id 命中时 corpId 不参与);dry-run 的 participantNotes 会逐条说明,无需手改 corpId。",
|
|
132
175
|
"⚠️ 本工具只做线性流程(START→填写→N 级审批→END),没有 --condition。",
|
|
133
176
|
"条件分支请用:omc describe workflow.update --example workflow-conditional-branch",
|
|
134
177
|
'最小条件流示例:routes 上加 ruleConditionGroup:[[{currentDataItem:"amount",bizPropertyType:2,conditionType:"GT",value:"50000"}]],兜底线加 utilizeElse:true。',
|
|
@@ -156,11 +199,13 @@ export async function cmdApprovalFlow(args) {
|
|
|
156
199
|
const linearOnlyNote = "本工具只做线性审批;条件分支用 omc describe workflow.update --example workflow-conditional-branch。" +
|
|
157
200
|
"workflow.permissions 只设谁能发起,不是行级可见范围(行级数据权限当前工具面不支持)。";
|
|
158
201
|
if (!apply) {
|
|
202
|
+
const compiledParticipantNotes = participantNotes(steps, environment);
|
|
159
203
|
writeEnvelope(envelope("ok", {
|
|
160
204
|
schemaCode: schema,
|
|
161
205
|
...compiled,
|
|
162
206
|
dryRun: true,
|
|
163
207
|
crossAccountApproval,
|
|
208
|
+
...(compiledParticipantNotes.length > 0 ? { participantNotes: compiledParticipantNotes } : {}),
|
|
164
209
|
linearOnly: true,
|
|
165
210
|
rowLevelDataPermission: "unsupported",
|
|
166
211
|
note: `dry-run 仅编译预览;--apply 执行 workflow.create(无流程时)→update(模板+字段权限)→publish。边界:非发起人身份的审批无法在单会话 CLI 内推进(单 token);若要验跨账号审批,用第二账号另建环境,或把参与人设为 {Originator}。${linearOnlyNote}`,
|
package/dist/batch-call.js
CHANGED
|
@@ -46,17 +46,34 @@ function failureDetails(entry, args) {
|
|
|
46
46
|
}
|
|
47
47
|
return { hint: "平台回了无明细 50000,常见成因见 help omc-refusals;请用该行输入与已发布字段逐项核对" };
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Tools whose input schema carries a business-object payload (`formData`).
|
|
51
|
+
* Verified against the registry: `runtimeFormDataArg` is declared only on
|
|
52
|
+
* data.save / data.update / data.submit. `configure_model.fields[]` is a
|
|
53
|
+
* field-definition list, not a data row, and the `code` on config tools is a
|
|
54
|
+
* business code — neither may borrow this row-shape heuristic. Anything else
|
|
55
|
+
* (reads, model/field/config writes, …) gets no guessed warnings at all.
|
|
56
|
+
*/
|
|
57
|
+
const FORM_DATA_TOOLS = new Set(["data.save", "data.update", "data.submit"]);
|
|
49
58
|
export function batchWarnings(argsList, tool) {
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
|
|
59
|
+
// Without a tool name there is no schema to justify a row shape: return
|
|
60
|
+
// nothing rather than treating arbitrary args as formData.
|
|
61
|
+
if (tool === undefined || !FORM_DATA_TOOLS.has(tool))
|
|
62
|
+
return [];
|
|
63
|
+
// data.save's warnings are produced by the runtime-data lane from published
|
|
64
|
+
// field metadata + readback, which is authoritative. Re-running the generic
|
|
65
|
+
// heuristics here would re-add the ghost `code` requirement that lane removed.
|
|
53
66
|
if (tool === "data.save")
|
|
54
67
|
return [];
|
|
55
68
|
const warnings = [];
|
|
56
69
|
const seenCodes = new Map();
|
|
57
70
|
argsList.forEach((args, index) => {
|
|
58
71
|
const row = index + 1;
|
|
59
|
-
|
|
72
|
+
// Only rows that actually carry the formData payload are data rows. A
|
|
73
|
+
// data.submit approval row has no formData and must not be checked as one.
|
|
74
|
+
if (args.formData === null || typeof args.formData !== "object" || Array.isArray(args.formData))
|
|
75
|
+
return;
|
|
76
|
+
const data = args.formData;
|
|
60
77
|
if (data.code === undefined || data.code === null || data.code === "")
|
|
61
78
|
warnings.push({ row, fieldCode: "code", code: "required", message: "必填字段 code 缺失" });
|
|
62
79
|
else if (typeof data.code === "string") {
|
package/dist/cli-stdout.js
CHANGED
package/dist/cli.js
CHANGED
|
@@ -73,6 +73,7 @@ import { WireError, wireCall } from "./wire.js";
|
|
|
73
73
|
import { describeWireFailure } from "./wire-failure.js";
|
|
74
74
|
import { DEFAULT_PULL_CONCURRENCY, GraphIndexAmbiguousError, GraphIndexError, GraphIndexUnreadableError, GraphPullLockHeldError, GraphPullTimeoutError, DEFAULT_GRAPH_PULL_TIMEOUT_MS, MAX_GRAPH_PULL_TIMEOUT_MS, MAX_PULL_CONCURRENCY, graphDbPath, graphRoot, impactGraph, listGraphIndexes, publishGraphPull, queryGraphReferences, queryGraphReferencesBatch, queryGraphEdges, readGraphStatus, searchGraphRules, } from "./graph.js";
|
|
75
75
|
import { cmdResidue } from "./residue.js";
|
|
76
|
+
import { reservedCodeReport } from "./reserved.js";
|
|
76
77
|
import { cmdTrack } from "./track.js";
|
|
77
78
|
import { ENDPOINTS } from "./endpoints.js";
|
|
78
79
|
import { makeToolContext } from "./context.js";
|
|
@@ -853,6 +854,24 @@ async function cmdCall(store, args) {
|
|
|
853
854
|
return emit("error", result, CLI_EXIT_CODES.invalidInput);
|
|
854
855
|
}
|
|
855
856
|
}
|
|
857
|
+
// GitLab #47:显式 --env 指向未配置环境时,恢复动作是「去掉 --env 重跑本次
|
|
858
|
+
// 调用」。在进入执行面(会话/写锁/wire)之前给出,stderr 与 stdout 同一份
|
|
859
|
+
// 文案,不必让 agent 再撞一次。只处理 unknown environment;跨环境拒绝/凭据
|
|
860
|
+
// 缺失的恢复动作不同,继续走原有分类。
|
|
861
|
+
if (environment !== undefined && tool !== undefined) {
|
|
862
|
+
try {
|
|
863
|
+
if (!store.readConfig().environments[environment])
|
|
864
|
+
store.resolveEnvironment(environment);
|
|
865
|
+
}
|
|
866
|
+
catch (error) {
|
|
867
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
868
|
+
if (/^unknown environment "/u.test(message)) {
|
|
869
|
+
const result = withUnknownEnvironmentRecovery({ status: "error", message }, { tool: toolName, ...(rawArgs !== undefined ? { rawArgs } : {}), ...(argsFile !== undefined ? { argsFile } : {}), parsedArgs });
|
|
870
|
+
humanSummary(JSON.stringify(result));
|
|
871
|
+
return emit("error", result, CLI_EXIT_CODES.authConfig);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
856
875
|
const toolKind = tool?.kind;
|
|
857
876
|
// F2':只对写面(含 dry-run 预览)标记;读面人话不追加 2>&1 提示。
|
|
858
877
|
if (toolKind === "write")
|
|
@@ -912,6 +931,9 @@ async function cmdCall(store, args) {
|
|
|
912
931
|
await lock.release();
|
|
913
932
|
}
|
|
914
933
|
}
|
|
934
|
+
// GitLab #47:unknown --env 的恢复动作 = 去掉 --env 重跑同一调用。文案由
|
|
935
|
+
// config-store 给出绑定事实,这里补上只有 call 层才知道的 tool + 本次参数。
|
|
936
|
+
result = withUnknownEnvironmentRecovery(result, { tool: toolName, ...(rawArgs !== undefined ? { rawArgs } : {}), ...(argsFile !== undefined ? { argsFile } : {}), parsedArgs });
|
|
915
937
|
let unwrappedBody;
|
|
916
938
|
let resultMeta;
|
|
917
939
|
// C7(0.8.4):结果容器键自描述——`items`/`models`/`rules`/`logs`/`fields` 各面
|
|
@@ -1174,6 +1196,59 @@ function resolvedDefaultEnvironment(store) {
|
|
|
1174
1196
|
return "default";
|
|
1175
1197
|
}
|
|
1176
1198
|
}
|
|
1199
|
+
/**
|
|
1200
|
+
* GitLab #47:`unknown environment "test"` 的恢复动作在 99% 情况下是「去掉
|
|
1201
|
+
* --env 重跑同一条调用」(项目 .omc-env 已是正确绑定)。config-store 的文案
|
|
1202
|
+
* 说明了这条规则,但只有 call 这一层知道 tool 与本次参数,所以在这里补一条
|
|
1203
|
+
* **真正可复制**的 nextCommand。
|
|
1204
|
+
*
|
|
1205
|
+
* 只对 `unknown environment "…"` 这一类生效:跨环境访问被拒、凭据缺失、平台
|
|
1206
|
+
* 错误的恢复动作各不相同,不能套用「去掉 --env」。参数过大/来自 stdin/文件时
|
|
1207
|
+
* 退回不内联参数的命令,绝不截断或编造载荷。
|
|
1208
|
+
*/
|
|
1209
|
+
function withoutEnvironmentCommand(input) {
|
|
1210
|
+
const inlineRaw = input.rawArgs !== undefined && input.rawArgs.trim().startsWith("{") ? input.rawArgs : undefined;
|
|
1211
|
+
// `parseToolInput` folds `--env` into args.environment; keeping it in the retry
|
|
1212
|
+
// would reproduce the very failure it is meant to recover from. Strip it from
|
|
1213
|
+
// the caller's JSON too (a tool-arg `environment` fails the same way).
|
|
1214
|
+
let inline = inlineRaw;
|
|
1215
|
+
if (inlineRaw !== undefined) {
|
|
1216
|
+
try {
|
|
1217
|
+
const parsed = JSON.parse(inlineRaw);
|
|
1218
|
+
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) && "environment" in parsed) {
|
|
1219
|
+
delete parsed.environment;
|
|
1220
|
+
inline = Object.keys(parsed).length > 0 ? JSON.stringify(parsed) : undefined;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
catch {
|
|
1224
|
+
// Not valid JSON: the call already failed input validation before this path.
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
const remaining = { ...input.parsedArgs };
|
|
1228
|
+
delete remaining.environment;
|
|
1229
|
+
const serialized = inline ?? (Object.keys(remaining).length > 0 ? JSON.stringify(remaining) : undefined);
|
|
1230
|
+
if (serialized === undefined || serialized === "{}")
|
|
1231
|
+
return `omc call ${input.tool}`;
|
|
1232
|
+
if (serialized.length <= 500)
|
|
1233
|
+
return `omc call ${input.tool} --args '${serialized.replace(/'/g, "'\\''")}'`;
|
|
1234
|
+
if (input.argsFile !== undefined)
|
|
1235
|
+
return `omc call ${input.tool} --args-file ${input.argsFile}`;
|
|
1236
|
+
if (input.rawArgs === "-")
|
|
1237
|
+
return `omc call ${input.tool} --args -`;
|
|
1238
|
+
return `omc call ${input.tool}`;
|
|
1239
|
+
}
|
|
1240
|
+
function withUnknownEnvironmentRecovery(result, input) {
|
|
1241
|
+
if (result.status !== "error" || typeof result.message !== "string")
|
|
1242
|
+
return result;
|
|
1243
|
+
if (!/^unknown environment "/u.test(result.message))
|
|
1244
|
+
return result;
|
|
1245
|
+
const nextCommand = withoutEnvironmentCommand(input);
|
|
1246
|
+
return {
|
|
1247
|
+
...result,
|
|
1248
|
+
nextCommand,
|
|
1249
|
+
message: result.message.includes("直接重试:") ? result.message : `${result.message};直接重试:${nextCommand}`,
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1177
1252
|
/**
|
|
1178
1253
|
* Above this size `omc artifact get` returns the outline, not the body. The
|
|
1179
1254
|
* transport cap (64 KB) is far too generous for a working context: one 27 KB
|
|
@@ -2575,7 +2650,7 @@ function cmdGraphReferences(kind, code, transport, selector = {}) {
|
|
|
2575
2650
|
const results = kinds.map((one) => queryGraphReferences(one, code, selector));
|
|
2576
2651
|
const result = results[0];
|
|
2577
2652
|
if (kind === undefined)
|
|
2578
|
-
return emitResult({ status: "ok", code, index: result.index, references: Object.fromEntries(results.map((item) => [item.kind, { matches: item.matches, ...(item.coverage !== undefined ? { coverage: item.coverage } : {}), ...(item.note !== undefined ? { note: item.note } : {}) }])) }, transport);
|
|
2653
|
+
return emitResult({ status: "ok", code, index: result.index, references: Object.fromEntries(results.map((item) => [item.kind, { matches: item.matches, ...(item.coverage !== undefined ? { coverage: item.coverage } : {}), ...(item.note !== undefined ? { note: item.note } : {}), ...(item.granularityUnsupported !== undefined ? { granularityUnsupported: item.granularityUnsupported } : {}) }])) }, transport);
|
|
2579
2654
|
return emitResult({
|
|
2580
2655
|
status: "ok",
|
|
2581
2656
|
kind: result.kind,
|
|
@@ -2590,6 +2665,8 @@ function cmdGraphReferences(kind, code, transport, selector = {}) {
|
|
|
2590
2665
|
...(result.scopeNote !== undefined ? { scopeNote: result.scopeNote } : {}),
|
|
2591
2666
|
...(result.coverage !== undefined ? { coverage: result.coverage } : {}),
|
|
2592
2667
|
...(result.note !== undefined ? { note: result.note } : {}),
|
|
2668
|
+
// issue 07(CLI 面):粒度边界与 MCP 同源——白名单重建漏带就等于没修。
|
|
2669
|
+
...(result.granularityUnsupported !== undefined ? { granularityUnsupported: result.granularityUnsupported } : {}),
|
|
2593
2670
|
...(result.gapWarning !== undefined ? { gapWarning: result.gapWarning } : {}),
|
|
2594
2671
|
}, transport);
|
|
2595
2672
|
}
|
|
@@ -3488,7 +3565,7 @@ async function main() {
|
|
|
3488
3565
|
commandExitCode = CLI_EXIT_CODES.ok;
|
|
3489
3566
|
});
|
|
3490
3567
|
command.command("doctor").option("--environment <environment>").option("--env <environment>").option("--service <serviceCode>", "可选:体检单个业务集成服务的鉴权参数形状(掩码/占位/全 0 检出,WARN 非致命)").option("--fresh-login", "忽略 token 缓存,做一次完整登录握手(默认复用缓存,登录请求 0 次;回执 loginSource 标明来源)").addOption(new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键),相对回执 result(checks/anchor/unsupportedCapabilities)").argParser((value, previous = []) => [...previous, value]).default([])).option("--explain", "--jq 未命中时给出完整排查载荷(available/correctPath/成因 hint);默认 miss 只回 missedAt/didYouMean/helpRef").action(async (options) => { commandExitCode = await cmdDoctor(new ConfigStore(defaultPaths()), options.environment ?? options.env, options.service, options.freshLogin === true, Array.isArray(options.jq) ? options.jq : [], options.explain === true); });
|
|
3491
|
-
command.command("call <tool>").option("--env <environment>", "环境名;项目白名单按当前 cwd 解析,须在含 .omc-env 的目录内运行").option("--environment <environment>").option("--args <json>").option("--args-file <path>", "从文件读参数 JSON。**必须位于配置根内**(数组批量请改用 --args-list;跨目录/系统临时文件会被拒);免落盘用 `--args -`(stdin)").option("--args-list <json-array>", '同一工具跑 N 次(JSON 数组,每条一个 args 对象,最多 200 条);超过上限请分批,或用 omc script 读文件。逐条执行、默认不中断,最后回 succeeded/failed
|
|
3568
|
+
command.command("call <tool>").option("--env <environment>", "环境名;项目白名单按当前 cwd 解析,须在含 .omc-env 的目录内运行").option("--environment <environment>").option("--args <json>").option("--args-file <path>", "从文件读参数 JSON。**必须位于配置根内**(数组批量请改用 --args-list;跨目录/系统临时文件会被拒);免落盘用 `--args -`(stdin)").option("--args-list <json-array>", '同一工具跑 N 次(JSON 数组,每条一个 args 对象,最多 200 条);超过上限请分批,或用 omc script 读文件。逐条执行、默认不中断,最后回 succeeded/failed 汇总。**只回汇总(succeeded/failed + 每行 ok),不内联各条 result**;读批量请用 `omc script -`(逐行带 result)或工具的 schemaCodes/ruleCodes 批参数。适合批量建字段等').option("--preflight", "与 --args-list 一起用:只跑参数校验 + 写前语义闸(零 wire、零写入),一次报全所有形状问题").option("--keys", "与 artifact get 的 --keys 同义(= --extract-keys):列出本次结果 artifact 的顶层键与体积").addOption(new Option("--extract <path>", "在本次结果的 artifact 内取一个路径的值(可重复;省掉一次 artifact get)").argParser((value, previous = []) => [...previous, value]).default([])).addOption(new Option("--jq [path]", "路径选择器(非 jq)——不是 jq 表达式,不支持管道;[] 映射如 items[].fields.planNo;裸 --jq 列顶层键。单路径命中时 result 直接是节点本体。示例:omc call model.list --env e --jq models · omc call rule.list --env e --args '{\"schemaCode\":\"m\"}' --jq rules[].code · omc call workflow.get_published --env e --args '{\"code\":\"f\"}' --jq activities[].bizActions").argParser((value, previous = []) => [...previous, value]).default([])).option("--extract-keys", "列出本次结果 artifact 的顶层键与体积(省掉一次 artifact get --keys)").option("--max-output-bytes <bytes>", "最终 stdout 信封预算;默认 65536(投影/--jq 之后再判);读面 diet(~2048) 独立外置 detailArtifactId,抬高本参数不会把已 diet 的大表重新内联;artifact get 内联上限 8192").option("--request-id <requestId>").option("--reason <text>", "写入原因(审计面,仅写操作):记入本次写 journal 行的 reason;不是工具参数(写 schema 拒未知键),也不参与任何门禁").option("--timeout-ms <milliseconds>").option("--wait <milliseconds>", "仅 `omc call` / `omc intent apply` 支持;写锁冲突时有界排队(0=立刻拒绝)").option("--dry-run").option("--explain", "--jq 未命中时给出完整排查载荷(available 该层全部键、correctPath、nextCommand、成因 hint);默认 miss 只回 missedAt/didYouMean/helpRef(≤300B)").addHelpText("after", `\n${onboardingHelp()}\n`).action(async (tool, options) => {
|
|
3492
3569
|
const rest = [tool, ...(options.env ? ["--env", options.env] : []), ...(options.environment ? ["--environment", options.environment] : []), ...(options.args !== undefined ? ["--args", options.args] : []), ...(options.argsFile !== undefined ? ["--args-file", options.argsFile] : []), ...(options.argsList !== undefined ? ["--args-list", options.argsList] : []), ...(options.preflight ? ["--preflight"] : []), ...(Array.isArray(options.extract) ? options.extract.flatMap((path) => ["--extract", path]) : []), ...(options.jq === true ? ["--jq"] : Array.isArray(options.jq) ? options.jq.flatMap((path) => path === true ? ["--jq"] : ["--jq", path]) : []), ...(options.extractKeys ? ["--extract-keys"] : []),
|
|
3493
3570
|
...(options.keys ? ["--keys"] : []), ...(options.maxOutputBytes !== undefined ? ["--max-output-bytes", options.maxOutputBytes] : []), ...(options.requestId ? ["--request-id", options.requestId] : []), ...(options.reason !== undefined ? ["--reason", options.reason] : []), ...(options.timeoutMs !== undefined ? ["--timeout-ms", options.timeoutMs] : []), ...(options.wait !== undefined ? ["--wait", options.wait] : []), ...(options.dryRun ? ["--dry-run"] : []), ...(options.explain ? ["--explain"] : [])];
|
|
3494
3571
|
commandExitCode = await cmdCall(new ConfigStore(defaultPaths()), rest);
|
|
@@ -3529,7 +3606,7 @@ async function main() {
|
|
|
3529
3606
|
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"] : [])];
|
|
3530
3607
|
commandExitCode = await cmdRuleWhen(rest);
|
|
3531
3608
|
});
|
|
3532
|
-
command.command("approval-flow").option("--schema <schemaCode>").option("--schema-code <schemaCode>").addOption(new Option("--steps <step>", "审批步骤,可重复;`节点名@role:<角色code>` 或 `节点名@user:<userId
|
|
3609
|
+
command.command("approval-flow").option("--schema <schemaCode>").option("--schema-code <schemaCode>").addOption(new Option("--steps <step>", "审批步骤,可重复;`节点名@role:<角色code>` 或 `节点名@user:<userId>`(user 参与者的 corpId 是 CLI 本地占位,平台按 id 解析用户,无需手改)").argParser(collectValues).default([])).option("--env <environment>").option("--environment <environment>").option("--apply").option("--no-originator-node").option("--no-reject-to-start").addHelpText("after", "\n审批流拼装器:--steps 名称@role:<角色code> 或 节点名@user:<userId>(多级给多个)。编译为验证模板(START→填写→审批链→END,审批节点字段只读),--apply 建流+权限+发布。\n`@user:` 适合单账号/角色无成员环境;参与者对象的 corpId 由 CLI 写成本地占位 \"other\",平台先按 id 解析用户、id 命中时 corpId 不参与(8.6.26 ParticipleServiceImplCompanion.java:171-174),dry-run 的 participantNotes 会逐条说明,无需替换。role 参与者按 OU 解析,先 `org.role.users` 复核。\n边界:非发起人身份的审批无法在单会话 CLI 内推进(单 token);若要验跨账号审批,用第二账号另建环境,或把参与人设为 {Originator}。\n").action(async (options) => {
|
|
3533
3610
|
const rest = ["approval-flow", ...(options.schema ? ["--schema", options.schema] : []), ...(options.schemaCode ? ["--schema-code", options.schemaCode] : []), ...(Array.isArray(options.steps) ? options.steps.flatMap((s) => ["--steps", s]) : []), ...(options.env ? ["--env", options.env] : []), ...(options.environment ? ["--environment", options.environment] : []), ...(options.apply ? ["--apply"] : []), ...(options.originatorNode === false ? ["--no-originator-node"] : []), ...(options.rejectToStart === false ? ["--no-reject-to-start"] : [])];
|
|
3534
3611
|
commandExitCode = await cmdApprovalFlow(rest);
|
|
3535
3612
|
});
|
|
@@ -3851,6 +3928,10 @@ async function main() {
|
|
|
3851
3928
|
// 2026-11-05 用户实测:`commands --json` 存在,于是大家自然写 `capabilities --json`
|
|
3852
3929
|
// ——旧实现报 `unknown option`(退出码 10)。输出本来就是 JSON 信封,接受它做兼容别名。
|
|
3853
3930
|
command.command("capabilities").option("--compact").option("--full", "完整投影(id/标题/别名/工具/依赖)——默认只是能力索引").option("--json", "兼容别名:输出本就是 JSON 信封(与 commands --json 对齐)").option("--max-output-bytes <bytes>").addOption(jqOption()).addOption(explainOption()).action(async (options) => { commandExitCode = await withTransport(options, request, (transport) => cmdCapabilities(transport, { compact: options.compact === true, full: options.full === true }, options.jq, options.explain === true)); });
|
|
3931
|
+
// F1(0.8.7 探针 B):保留字清单不可发现——报错只给 code_reserved 分类,help 只有
|
|
3932
|
+
// SQL 关键字。本命令是 src/code-rules.ts 同一张表的只读投影(零环境接触),
|
|
3933
|
+
// 不新增第二套校验逻辑,也不声称是平台全量清单。
|
|
3934
|
+
command.command("reserved").description("本地 code 保留字清单(系统默认属性/扩展默认属性/平台内部/子表专用 + SQL 关键字);建模型或字段前查,平台 301014/10033 仍是最终门").option("--json", "兼容别名:输出本就是 JSON 信封").option("--max-output-bytes <bytes>").addHelpText("after", "\n清单来自本地 dry-lint 同一张表(src/code-rules.ts),与 field.create / model.create / configure_model 的 code_reserved 判定同源;不是平台全量保留字清单——平台最终门仍是属性冲突 301014、SQL 关键字 10033。\n").action(async (options) => { commandExitCode = await withTransport(options, request, (transport) => emitTransportResult(reservedCodeReport(), transport)); });
|
|
3854
3935
|
// `--env` is accepted but ignored: `next` is a zero-environment-contact route
|
|
3855
3936
|
// solver, and a caller who reflexively passes `--env` should not be refused
|
|
3856
3937
|
// (round 15 dogfood: `next "<goal>" --env local` → unknown option, one round).
|
package/dist/code-rules.js
CHANGED
|
@@ -26,7 +26,12 @@ const CODE_PATTERNS = {
|
|
|
26
26
|
* (8.6.26 :1017-1020; 2.1.5 :1048-1051), i.e. on every property created or
|
|
27
27
|
* renamed through the property manager (child columns included).
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Display-order copy of the same table. The Set below is derived from it, so
|
|
31
|
+
* `omc reserved` and the write gate cannot drift: every listed code is rejected
|
|
32
|
+
* by `validateBusinessCode` and every Set member appears in the listing.
|
|
33
|
+
*/
|
|
34
|
+
export const SYSTEM_RESERVED_CODES = Object.freeze([
|
|
30
35
|
"id",
|
|
31
36
|
"name",
|
|
32
37
|
"creater",
|
|
@@ -41,7 +46,8 @@ export const RESERVED_CODES = new Set([
|
|
|
41
46
|
"sequenceStatus",
|
|
42
47
|
"ownerDeptQueryCode",
|
|
43
48
|
"version",
|
|
44
|
-
]
|
|
49
|
+
]);
|
|
50
|
+
export const RESERVED_CODES = new Set(SYSTEM_RESERVED_CODES.map((code) => code.toLowerCase()));
|
|
45
51
|
/**
|
|
46
52
|
* Group 2a — platform EXTENDED property codes (`DefaultPropertyExtendType`).
|
|
47
53
|
* Not plain audit columns: they are the display-name companions the engine
|
|
@@ -54,13 +60,14 @@ export const RESERVED_CODES = new Set([
|
|
|
54
60
|
* Checked (equalsIgnoreCase) by validateNotEqualDefaultPropertyCode
|
|
55
61
|
* (8.6.26 :1021-1024; 2.1.5 :1052-1055) — 301014 on the platform.
|
|
56
62
|
*/
|
|
57
|
-
export const
|
|
63
|
+
export const EXTENDED_RESERVED_CODES = Object.freeze([
|
|
58
64
|
"createdName",
|
|
59
65
|
"createdDeptName",
|
|
60
66
|
"ownerName",
|
|
61
67
|
"ownerDeptName",
|
|
62
68
|
"modifiedName",
|
|
63
|
-
]
|
|
69
|
+
]);
|
|
70
|
+
export const RESERVED_EXTEND_CODES = new Set(EXTENDED_RESERVED_CODES.map((code) => code.toLowerCase()));
|
|
64
71
|
/**
|
|
65
72
|
* Group 2b — engine-internal reserved words (`INTERNAL_RESERVED_WORDS_LOWERCASE`).
|
|
66
73
|
* Not enum members: a literal lowercase set hit with `code.toLowerCase()`.
|
|
@@ -71,10 +78,11 @@ export const RESERVED_EXTEND_CODES = new Set([
|
|
|
71
78
|
* com/authine/cloudpivot/metadata/BizPropertyManagerImpl.java:109 (set),
|
|
72
79
|
* checked at :1056-1058
|
|
73
80
|
*/
|
|
74
|
-
export const
|
|
81
|
+
export const INTERNAL_RESERVED_CODES = Object.freeze([
|
|
75
82
|
"parentworkflowinstanceid",
|
|
76
83
|
"sheetbizobjectid",
|
|
77
84
|
]);
|
|
85
|
+
export const RESERVED_INTERNAL_CODES = new Set(INTERNAL_RESERVED_CODES);
|
|
78
86
|
/**
|
|
79
87
|
* Group 3 — SUB-TABLE-only reserved columns (`DefaultSubPropertyType`). The
|
|
80
88
|
* platform checks this enum ONLY when `getBizSchema().isSubSchema()` is true
|
|
@@ -89,25 +97,41 @@ export const RESERVED_INTERNAL_CODES = new Set([
|
|
|
89
97
|
* Enum: 8.6.26 .../cloudpivot-shared-8.6.26/.../DefaultSubPropertyType.java:12-17;
|
|
90
98
|
* 2.1.5 .../cloudpivot-contracts-AI-Platform-v2.1.5/.../DefaultSubPropertyType.java:12-17.
|
|
91
99
|
*/
|
|
92
|
-
export const
|
|
100
|
+
export const SUBTABLE_RESERVED_CODES = Object.freeze([
|
|
93
101
|
"id",
|
|
94
102
|
"parentId",
|
|
95
103
|
"sortKey",
|
|
96
104
|
"modifier",
|
|
97
105
|
"modifiedTime",
|
|
98
106
|
"version",
|
|
99
|
-
]
|
|
107
|
+
]);
|
|
108
|
+
export const RESERVED_SUBTABLE_CODES = new Set(SUBTABLE_RESERVED_CODES.map((code) => code.toLowerCase()));
|
|
100
109
|
/**
|
|
101
110
|
* SQL 关键字(MySQL 未加引号时的保留字)。平台在 wire 才拒绝(10033
|
|
102
111
|
* 编码[order]为SQL关键字),这里前置到与 code 格式同层,省一轮建了再改。
|
|
103
112
|
*/
|
|
104
|
-
export const
|
|
113
|
+
export const SQL_KEYWORDS = Object.freeze([
|
|
105
114
|
"order", "group", "key", "index", "desc", "asc", "select", "from", "where", "join",
|
|
106
115
|
"union", "all", "and", "or", "not", "null", "true", "false", "case", "when", "then",
|
|
107
116
|
"else", "end", "default", "primary", "foreign", "references", "constraint", "create",
|
|
108
117
|
"drop", "alter", "insert", "delete", "update", "into", "values", "table", "column",
|
|
109
118
|
"check", "distinct", "having", "limit", "offset", "by", "left", "right", "inner", "outer",
|
|
110
119
|
]);
|
|
120
|
+
export const SQL_KEYWORD_CODES = new Set(SQL_KEYWORDS);
|
|
121
|
+
/**
|
|
122
|
+
* The single projection of the table above for the read-only `omc reserved`
|
|
123
|
+
* face. Derived (not copied) so it cannot drift from the gate. This is a LOCAL
|
|
124
|
+
* dry-lint list, not a claim about the platform's complete reserved set: the
|
|
125
|
+
* platform remains the final gate (301014 for property codes, 10033 for SQL
|
|
126
|
+
* keywords).
|
|
127
|
+
*/
|
|
128
|
+
export const RESERVED_CODE_GROUPS = Object.freeze([
|
|
129
|
+
Object.freeze({ id: "system", title: "系统默认属性", appliesTo: "模型 code 与字段 code", codes: SYSTEM_RESERVED_CODES, note: "DefaultPropertyType;平台自建且业务不得占用" }),
|
|
130
|
+
Object.freeze({ id: "extended", title: "扩展默认属性", appliesTo: "字段 code", codes: EXTENDED_RESERVED_CODES, note: "DefaultPropertyExtendType;引擎维护的显示名伴生列" }),
|
|
131
|
+
Object.freeze({ id: "internal", title: "平台内部保留", appliesTo: "字段 code", codes: INTERNAL_RESERVED_CODES, note: "INTERNAL_RESERVED_WORDS_LOWERCASE" }),
|
|
132
|
+
Object.freeze({ id: "subtable", title: "子表专用", appliesTo: "子表列 code(主表字段不受此组限制)", codes: SUBTABLE_RESERVED_CODES, note: "DefaultSubPropertyType;仅 isSubSchema() 时校验" }),
|
|
133
|
+
Object.freeze({ id: "sql", title: "SQL 关键字", appliesTo: "模型 code 与字段 code", codes: SQL_KEYWORDS, note: "落库时回 10033;不是平台属性保留字,但同样不可用" }),
|
|
134
|
+
]);
|
|
111
135
|
/** Infer the style a code is written in (underscores → snake, else camel). */
|
|
112
136
|
export function inferCodeStyle(code) {
|
|
113
137
|
if (code.includes("_"))
|
|
@@ -148,18 +172,18 @@ export function validateBusinessCode(rawCode, options) {
|
|
|
148
172
|
}
|
|
149
173
|
const reserved = reservedClassification(code.toLowerCase(), options);
|
|
150
174
|
if (reserved === "main")
|
|
151
|
-
violations.push({ code, classification: "code_reserved", message: `code "${code}"
|
|
175
|
+
violations.push({ code, classification: "code_reserved", message: `code "${code}" 是平台系统/保留字段编码,业务模型与字段不得使用(会与平台自身列冲突);完整清单见 omc reserved` });
|
|
152
176
|
else if (reserved === "extended")
|
|
153
177
|
violations.push({
|
|
154
178
|
code,
|
|
155
179
|
classification: "code_reserved",
|
|
156
|
-
message: `code "${code}" 是平台扩展/内部保留字段编码(DefaultPropertyExtendType / INTERNAL_RESERVED_WORDS_LOWERCASE,如 ownerName、createdName、parentworkflowinstanceid、sheetbizobjectid),平台会报 301014
|
|
180
|
+
message: `code "${code}" 是平台扩展/内部保留字段编码(DefaultPropertyExtendType / INTERNAL_RESERVED_WORDS_LOWERCASE,如 ownerName、createdName、parentworkflowinstanceid、sheetbizobjectid),平台会报 301014;平台自动维护该列,业务字段不得占用;完整清单见 omc reserved`,
|
|
157
181
|
});
|
|
158
182
|
else if (reserved === "subtable")
|
|
159
183
|
violations.push({
|
|
160
184
|
code,
|
|
161
185
|
classification: "code_reserved",
|
|
162
|
-
message: `code "${code}" 是子表(CHILD_TABLE)平台保留列(DefaultSubPropertyType,如 parentId、sortKey),子表列不得使用(平台报 301014
|
|
186
|
+
message: `code "${code}" 是子表(CHILD_TABLE)平台保留列(DefaultSubPropertyType,如 parentId、sortKey),子表列不得使用(平台报 301014);主表字段不受此组限制;完整清单见 omc reserved`,
|
|
163
187
|
});
|
|
164
188
|
if (SQL_KEYWORD_CODES.has(code.toLowerCase()))
|
|
165
189
|
violations.push({
|
package/dist/config-store.js
CHANGED
|
@@ -327,11 +327,25 @@ export class ConfigStore {
|
|
|
327
327
|
this.assertProjectScope(resolved.name, resolved.source);
|
|
328
328
|
return resolved;
|
|
329
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* GitLab #47:agent 把自然语言标签(「测试环境」)拼成 `--env test`,失败后
|
|
332
|
+
* 只能靠撞一次才知道「省略 --env = 项目绑定环境」。文案里必须直接给出这件事,
|
|
333
|
+
* 且只陈述事实(绑定名可读就读、读不到就说未绑定)——**不做名字猜测**:猜错
|
|
334
|
+
* 比一次失败更危险(会写到别的环境)。
|
|
335
|
+
*/
|
|
336
|
+
unknownEnvironmentAdvice() {
|
|
337
|
+
const bound = this.readProjectEnvBinding();
|
|
338
|
+
if (bound === undefined)
|
|
339
|
+
return "本项目未绑定 .omc-env(省略 --env 不会选中特定环境);先 omc env list 查看可用环境,再显式传 --env <name> 或运行 omc setup 绑定";
|
|
340
|
+
if (!this.readConfig().environments[bound])
|
|
341
|
+
return `本项目 .omc-env 绑定的 "${bound}" 未在 omc.config.json 配置(省略 --env 同样不可用);先运行 omc setup 或改 .omc-env`;
|
|
342
|
+
return `本项目绑定环境:${bound}(.omc-env);省略 --env 即用它`;
|
|
343
|
+
}
|
|
330
344
|
resolveCandidate(explicit) {
|
|
331
345
|
if (explicit && explicit.trim()) {
|
|
332
346
|
const profile = this.readConfig().environments[explicit];
|
|
333
347
|
if (!profile)
|
|
334
|
-
throw new ConfigurationError(`unknown environment "${explicit}"; available: ${this.availableEnvironmentNames()}(仅本项目;doctor prints the bound 环境=; do not guess or read ~/.config/omc manually)`);
|
|
348
|
+
throw new ConfigurationError(`unknown environment "${explicit}"; available: ${this.availableEnvironmentNames()}(仅本项目;doctor prints the bound 环境=; do not guess or read ~/.config/omc manually);${this.unknownEnvironmentAdvice()}`);
|
|
335
349
|
return { name: explicit, profile, source: "explicit" };
|
|
336
350
|
}
|
|
337
351
|
if (process.env.OMC_ENV) {
|
package/dist/endpoints.js
CHANGED
|
@@ -94,6 +94,16 @@ export const ENDPOINTS = {
|
|
|
94
94
|
customPageContentUpdate: "/api/api/custom/page/content/update",
|
|
95
95
|
customPageContentPublish: "/api/api/custom/page/content/publish",
|
|
96
96
|
appPackagePhysicallyDelete: "/api/api/app/apppackage/physically_delete",
|
|
97
|
+
/**
|
|
98
|
+
* Platform async-delete task result (2.1.5 and 8.6.26 both:
|
|
99
|
+
* AppPackageController `/delete/history?taskId=` → 8.6.26 :1460-1476,
|
|
100
|
+
* 2.1.5 :1369-1378; `getAppDeletHistoryByTaskId`, unknown id → 309027
|
|
101
|
+
* 任务不存在). physically_delete returns the AppDeleteHistoryModel it saved
|
|
102
|
+
* with TaskStatus.RUN (:1333-1358); the real failure reason is only written
|
|
103
|
+
* to this row (message + FAIL in the catch). The CLI polls this endpoint
|
|
104
|
+
* inline from model.delete — there is deliberately no `deleteHistory` tool.
|
|
105
|
+
*/
|
|
106
|
+
appPackageDeleteHistory: "/api/api/app/apppackage/delete/history",
|
|
97
107
|
fieldList: "/api/api/app/bizproperty/list",
|
|
98
108
|
fieldGet: "/api/api/app/bizproperty/get",
|
|
99
109
|
fieldCreate: "/api/api/app/bizproperty/create",
|
package/dist/form-layout.js
CHANGED
|
@@ -11,7 +11,15 @@
|
|
|
11
11
|
* 3. a full-width control (span 24) occupies its row alone;
|
|
12
12
|
* 4. every attribute control appears in `rows` exactly once — nothing extra,
|
|
13
13
|
* nothing missing, no duplicates.
|
|
14
|
+
*
|
|
15
|
+
* ALSO: the control `type` inside attributes JSON is the FORM-CONTROL enum, NOT
|
|
16
|
+
* the field `propertyType`. See `controlTypeMismatches` below — the two are
|
|
17
|
+
* different numeric enums (2.1.5 probe B: published `customer` is 80 while the
|
|
18
|
+
* field is WORK_SHEET=9; writing 9 stores fine and reads back silently wrong).
|
|
14
19
|
*/
|
|
20
|
+
import { CAPABILITY_CONTROL_TYPES } from "./capability-shape.js";
|
|
21
|
+
import { FIELD_CONTROL_CODES } from "./lanes/field-contract.js";
|
|
22
|
+
import { SYSTEM_FIELD_CODES, familyName } from "./field-families.js";
|
|
15
23
|
export const ALLOWED_SPANS = new Set([6, 8, 12, 16, 18, 24]);
|
|
16
24
|
export const FULL_SPAN = 24;
|
|
17
25
|
/**
|
|
@@ -146,4 +154,75 @@ export function validateFormLayout(rows, attributes) {
|
|
|
146
154
|
});
|
|
147
155
|
return violations;
|
|
148
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* The one-line enum reminder attached to every `form-control-type-mismatch`
|
|
159
|
+
* refusal. Names come from `BizFormPropertyType` (backend, 2.1.5/8.6.26) and the
|
|
160
|
+
* designer's BPM type table (frontend `admin/src/template/template.ts:22-200`).
|
|
161
|
+
*/
|
|
162
|
+
export const FORM_CONTROL_TYPE_HINT = "表单控件 type 与字段 propertyType 是**两套枚举**:控件 1=单行文本 2=多行文本 3=日期 4=数值 5=单选 6=复选 7=下拉 8=逻辑 80=关联单选 81=关联多选 201=子表 …(对应 propertyType 0/1/3/2/12/13/14/4/9/11/8)。";
|
|
163
|
+
/**
|
|
164
|
+
* Cross-check `attributes[code].type` (form-control enum) against the published
|
|
165
|
+
* field's `propertyType` (BizPropertyType enum). Both sides are required before
|
|
166
|
+
* anything is refused:
|
|
167
|
+
* - only codes resolvable on the published `field.list` face are checked;
|
|
168
|
+
* - system fields / layout widgets are skipped (`skipCodes`, plus Title/Group
|
|
169
|
+
* never resolve on field.list);
|
|
170
|
+
* - a missing/unknown control `type` is never guessed (custom designer codes
|
|
171
|
+
* such as 1001/1201 stay untouched);
|
|
172
|
+
* - a propertyType with no evidenced control mapping is skipped (COMMENT=7…).
|
|
173
|
+
*
|
|
174
|
+
* Evidence — backend: BizFormPropertyType.java:13-51 (1/2/3/4/5/6/7/8/9/19/80/
|
|
175
|
+
* 81/82/89/90/100-106/201…), BizPropertyType.java:27-54 (0/1/2/3/4/…/9/11/14).
|
|
176
|
+
* Frontend: admin/src/template/template.ts:22-200 (a-text=1, a-textarea=2,
|
|
177
|
+
* a-date=3, a-number=4, a-dropdown=7, a-logic=8, a-association-form=80,
|
|
178
|
+
* a-sheet=201). The mapping itself is the shared CAPABILITY_CONTROL_TYPES table
|
|
179
|
+
* (`field-families.ts` FIELD_CONTROL_TYPES is its public alias).
|
|
180
|
+
*/
|
|
181
|
+
export function controlTypeMismatches(attributes, fields, skipCodes = SYSTEM_FIELD_CODES) {
|
|
182
|
+
const attrs = attributes && typeof attributes === "object" && !Array.isArray(attributes) ? attributes : undefined;
|
|
183
|
+
if (attrs === undefined)
|
|
184
|
+
return [];
|
|
185
|
+
const skipped = new Set(skipCodes);
|
|
186
|
+
const propertyTypes = new Map();
|
|
187
|
+
for (const field of fields) {
|
|
188
|
+
if (typeof field.code !== "string" || field.code === "")
|
|
189
|
+
continue;
|
|
190
|
+
// Serial-number fields are SHORT_TEXT(0) on the field face but carry the
|
|
191
|
+
// SequenceNo control (100) — the mapping table would read 0 → 1. Their
|
|
192
|
+
// control face is field-options-owned (`formPropertyType:100` /
|
|
193
|
+
// `seqNoSetting`, field-families.ts:193), so skip instead of guessing.
|
|
194
|
+
if (typeof field.options === "string" && /"(formPropertyType|seqNoSetting)"\s*:/.test(field.options))
|
|
195
|
+
skipped.add(field.code);
|
|
196
|
+
const propertyType = Number(field.propertyType ?? field.type);
|
|
197
|
+
if (Number.isInteger(propertyType))
|
|
198
|
+
propertyTypes.set(field.code, propertyType);
|
|
199
|
+
}
|
|
200
|
+
const mismatches = [];
|
|
201
|
+
for (const [code, control] of Object.entries(attrs)) {
|
|
202
|
+
if (skipped.has(code))
|
|
203
|
+
continue;
|
|
204
|
+
if (!control || typeof control !== "object")
|
|
205
|
+
continue;
|
|
206
|
+
const rawType = control.type;
|
|
207
|
+
if (rawType === undefined || rawType === null || rawType === "")
|
|
208
|
+
continue;
|
|
209
|
+
const givenType = Number(rawType);
|
|
210
|
+
if (!Number.isInteger(givenType))
|
|
211
|
+
continue;
|
|
212
|
+
// Unknown/custom control codes are NOT guessed.
|
|
213
|
+
const known = FIELD_CONTROL_CODES[givenType];
|
|
214
|
+
if (known === undefined || (known.status !== "known" && known.status !== "designer"))
|
|
215
|
+
continue;
|
|
216
|
+
const propertyType = propertyTypes.get(code);
|
|
217
|
+
if (propertyType === undefined)
|
|
218
|
+
continue;
|
|
219
|
+
const expectedType = CAPABILITY_CONTROL_TYPES[propertyType];
|
|
220
|
+
if (expectedType === undefined)
|
|
221
|
+
continue;
|
|
222
|
+
if (givenType === expectedType)
|
|
223
|
+
continue;
|
|
224
|
+
mismatches.push({ code, givenType, expectedType, propertyType, fieldTypeName: familyName(propertyType) });
|
|
225
|
+
}
|
|
226
|
+
return mismatches;
|
|
227
|
+
}
|
|
149
228
|
//# sourceMappingURL=form-layout.js.map
|