@stalfh233/omc-cli 0.8.2 → 0.8.4
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/dist/bench/call-face-eval.js +1 -1
- package/dist/bench/scenario.js +3 -3
- package/dist/cli-contract.js +55 -2
- package/dist/cli-output.js +59 -8
- package/dist/cli.js +338 -59
- package/dist/field-families.js +19 -9
- package/dist/form-layout.js +19 -4
- package/dist/form-support.js +181 -9
- package/dist/graph.js +151 -29
- package/dist/intent/capabilities/field.js +98 -0
- package/dist/intent/plan-apply.js +9 -0
- package/dist/lanes/app.js +34 -6
- package/dist/lanes/field.js +360 -94
- package/dist/lanes/form.js +27 -5
- package/dist/lanes/model.js +42 -11
- package/dist/lanes/runtime-data.js +93 -4
- package/dist/lanes/workflow-contract.js +1 -1
- package/dist/lanes/workflow.js +30 -14
- package/dist/path-projection.js +25 -14
- package/dist/read.js +132 -3
- package/dist/refusal-guidance.js +14 -0
- package/dist/session.js +30 -2
- package/dist/support.js +3 -1
- package/dist/wire-failure.js +120 -0
- package/dist/wire.js +109 -5
- package/dist/workflow-support.js +41 -0
- package/package.json +3 -3
package/dist/field-families.js
CHANGED
|
@@ -139,7 +139,7 @@ export const subFieldArg = z
|
|
|
139
139
|
* Field options. The shape depends on `propertyType`:
|
|
140
140
|
* - relation families WORK_SHEET(9) / MULT_WORK_SHEET(11):
|
|
141
141
|
* { schemaCode:<target model>, queryCode:<target model>, displayField:"name",
|
|
142
|
-
* mappings:'[{"source"
|
|
142
|
+
* mappings:'[{"source":<关联侧字段/父模型字段/子表code.字段code>,"target":<本模型字段 code>}]' }
|
|
143
143
|
* - RELEVANCE_DATA(16) — a *reference to another field*, NOT a model relation
|
|
144
144
|
* (8.6.26 `RelevanceDataOptions`, admin field serializer):
|
|
145
145
|
* { relevanceField:<local WORK_SHEET field code>,
|
|
@@ -173,7 +173,8 @@ export const fieldOptionsArg = z
|
|
|
173
173
|
mappings: z
|
|
174
174
|
.union([z.string(), z.array(z.object({ source: z.string(), target: z.string() }))])
|
|
175
175
|
.optional()
|
|
176
|
-
.describe('relation mappings:[{"source":"
|
|
176
|
+
.describe('relation mappings:[{"source":"<关联侧字段>","target":"<本模型字段>"}] 或 JSON 串([]/""=无映射)。source=关联侧字段/父模型字段/子表code.字段code;target 只用本模型裸 code。仅门户选取回填;data.save/update 不跑;data.load 不跟随上游改名'),
|
|
177
|
+
mainTableCode: z.string().optional().describe("关联目标为子表时的主表模型 code(设计器键;运行期认 parentCode;拒绝回执看 relationParentCode)"),
|
|
177
178
|
searchFormula: jsonString().optional().describe("WORK_SHEET / MULT_WORK_SHEET data restriction range JSON"),
|
|
178
179
|
conditions: jsonString().optional().describe("WORK_SHEET / MULT_WORK_SHEET query conditions JSON"),
|
|
179
180
|
optionsSet: optionsSetArg.optional().describe("selection source: custom, dictionary, or businessModel"),
|
|
@@ -190,8 +191,8 @@ export const fieldOptionsArg = z
|
|
|
190
191
|
// surface the constraint before preflight. Bounds stay in
|
|
191
192
|
// assertNumericalScale (not zod min/max) so scale:9 still returns the
|
|
192
193
|
// teaching refusal, not a generic tool-input-invalid.
|
|
193
|
-
scale: z.number().optional().describe("NUMERICAL 必填:小数位数(0
|
|
194
|
-
format: z.unknown().optional().describe("NUMERICAL
|
|
194
|
+
scale: z.number().optional().describe("NUMERICAL 必填:小数位数(0=整数 … 8=8位)。金额用 2;不是 listview displayFormat 枚举"),
|
|
195
|
+
format: z.unknown().optional().describe("NUMERICAL 显示格式族(平台常量,全表见 contract 的 numericalFormat):**百分比存比值** 0.5→50.00%(存 50 显示 5000.00%),`scale` 与小数位对齐;别名 percent/currency/¥ 由 CLI 归一;字段行 format 优先于表单控件"),
|
|
195
196
|
nested: z.boolean().optional().describe("nested child-table metadata — refused (coverage boundary)"),
|
|
196
197
|
relationLinkage: z.boolean().optional().describe("advanced relation linkage — refused (coverage boundary)"),
|
|
197
198
|
})
|
|
@@ -784,7 +785,12 @@ export function normalizeMappingsOption(options) {
|
|
|
784
785
|
if (!("mappings" in options) || options.mappings === undefined)
|
|
785
786
|
return { options };
|
|
786
787
|
const mappings = options.mappings;
|
|
787
|
-
const mappingsError = (detail) => refuseFieldOptions(`relation mappings fail the reproduced protocol`, `rejected: options.mappings ${detail};合法形状:JSON 字符串 [{"source":"<来源字段>","target":"<目标字段>"}]
|
|
788
|
+
const mappingsError = (detail) => refuseFieldOptions(`relation mappings fail the reproduced protocol`, `rejected: options.mappings ${detail};合法形状:JSON 字符串 [{"source":"<来源字段>","target":"<目标字段>"}] 或等价数组。source 用裸字段 code,关联目标是子表时也可用 子表code.字段code(平台存储形态,如 contract_payment_items.collectionItemName);target 只用本模型字段 code,不带前缀。无映射用 ""(不是 "[]"——"[]" 会让设计器显示"已设置"但弹窗无映射行)`);
|
|
789
|
+
/** `子表code.字段code`(单点号、两段非空);`模型.字段` 仍按原协议拒绝。 */
|
|
790
|
+
const sheetColumnSource = (source) => {
|
|
791
|
+
const dot = source.indexOf(".");
|
|
792
|
+
return dot > 0 && dot < source.length - 1 && !source.slice(dot + 1).includes(".");
|
|
793
|
+
};
|
|
788
794
|
let normalized;
|
|
789
795
|
if (Array.isArray(mappings)) {
|
|
790
796
|
if (mappings.length === 0)
|
|
@@ -798,8 +804,10 @@ export function normalizeMappingsOption(options) {
|
|
|
798
804
|
const target = record.target;
|
|
799
805
|
if (typeof source !== "string" || source.trim() === "" || typeof target !== "string" || target.trim() === "")
|
|
800
806
|
mappingsError("每项的 source/target 必须是非空字符串");
|
|
801
|
-
if (
|
|
802
|
-
mappingsError("
|
|
807
|
+
if (target.includes("."))
|
|
808
|
+
mappingsError("target 只用本模型字段 code,不带前缀");
|
|
809
|
+
if (source.includes(".") && !sheetColumnSource(source))
|
|
810
|
+
mappingsError("source 的点号形态只允许 子表code.字段code(关联目标是子表时);其它情况用裸字段 code");
|
|
803
811
|
return { source: source.trim(), target: target.trim() };
|
|
804
812
|
});
|
|
805
813
|
normalized = JSON.stringify(rows);
|
|
@@ -819,8 +827,10 @@ export function normalizeMappingsOption(options) {
|
|
|
819
827
|
}
|
|
820
828
|
if (!Array.isArray(parsed) || parsed.some((row) => row === null || typeof row !== "object" || Array.isArray(row) || typeof row.source !== "string" || typeof row.target !== "string" || row.source === "" || row.target === ""))
|
|
821
829
|
mappingsError("解析结果必须是 [{source,target}] 形状(source/target 非空字符串)");
|
|
822
|
-
if (parsed.some((row) => String(row.
|
|
823
|
-
mappingsError("
|
|
830
|
+
if (parsed.some((row) => String(row.target).includes(".")))
|
|
831
|
+
mappingsError("target 只用本模型字段 code,不带前缀");
|
|
832
|
+
if (parsed.some((row) => String(row.source).includes(".") && !sheetColumnSource(String(row.source))))
|
|
833
|
+
mappingsError("source 的点号形态只允许 子表code.字段code(关联目标是子表时);其它情况用裸字段 code");
|
|
824
834
|
normalized = JSON.stringify(parsed.map(({ source, target }) => ({ source: source.trim(), target: target.trim() })));
|
|
825
835
|
}
|
|
826
836
|
}
|
package/dist/form-layout.js
CHANGED
|
@@ -31,7 +31,13 @@ export const SOFT_LAYOUT_CLASSIFICATIONS = new Set();
|
|
|
31
31
|
export function hardLayoutViolations(violations) {
|
|
32
32
|
return violations.filter((violation) => !SOFT_LAYOUT_CLASSIFICATIONS.has(violation.classification));
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Child-table (Sheet 201) column keys. These normally live on the 201 control's
|
|
36
|
+
* `columns`; a key here is NOT by itself proof of a leak, because the same code
|
|
37
|
+
* can legitimately be a TOP-LEVEL control of this form (a main-table field that
|
|
38
|
+
* shares a child column's code — issue 2026-11-25 A2). The control map's own
|
|
39
|
+
* keys are the ledger that disambiguates; see `validateFormLayoutShape`.
|
|
40
|
+
*/
|
|
35
41
|
function childColumnKeys(attrs) {
|
|
36
42
|
const keys = new Set();
|
|
37
43
|
for (const control of Object.values(attrs)) {
|
|
@@ -51,7 +57,8 @@ function childColumnKeys(attrs) {
|
|
|
51
57
|
* on string". Healthy platform forms carry object options only (0/43 sampled).
|
|
52
58
|
* - a non-string viewJson cell.
|
|
53
59
|
* - a child-table column key used as a layout row (child keys stay on the 201
|
|
54
|
-
* control's `columns`)
|
|
60
|
+
* control's `columns`) — but only when that code is NOT also a top-level
|
|
61
|
+
* control of this form (see below).
|
|
55
62
|
* Tolerant of a one-sided layout (only rows or only attributes supplied).
|
|
56
63
|
*/
|
|
57
64
|
export function validateFormLayoutShape(rows, attributes) {
|
|
@@ -78,9 +85,17 @@ export function validateFormLayoutShape(rows, attributes) {
|
|
|
78
85
|
});
|
|
79
86
|
const childKeys = childColumnKeys(attrs);
|
|
80
87
|
if (childKeys.size > 0) {
|
|
81
|
-
|
|
88
|
+
// A layout row is rendered ONLY when its cell is a key of the top-level
|
|
89
|
+
// control map: the renderer resolves each cell via `controls[k]` and
|
|
90
|
+
// drops unknown keys (`cloudpivot-form/renderer/components/
|
|
91
|
+
// form-renderer-helper.ts:503-515` mapAndFilter; group detection uses the
|
|
92
|
+
// same lookup at :1383-1391). So a code registered as a control here is a
|
|
93
|
+
// legal row even when the same code is also listed as a 201 column — the
|
|
94
|
+
// main-table-field/child-column name collision from issue 2026-11-25 A2.
|
|
95
|
+
// Only "not a top-level control AND a 201 column" is a child-column leak.
|
|
96
|
+
const leaked = [...new Set(rows.flat().filter((cell) => typeof cell === "string" && childKeys.has(cell) && !Object.prototype.hasOwnProperty.call(attrs, cell)))];
|
|
82
97
|
if (leaked.length > 0)
|
|
83
|
-
violations.push({ classification: "child_column_in_rows", field: leaked.join("、"), message: `子表列 key 不能进 viewJson
|
|
98
|
+
violations.push({ classification: "child_column_in_rows", field: leaked.join("、"), message: `子表列 key 不能进 viewJson(控件表里没有同名顶层控件,应只挂在 201 控件的 columns 上):${leaked.join("、")}` });
|
|
84
99
|
}
|
|
85
100
|
}
|
|
86
101
|
return violations;
|
package/dist/form-support.js
CHANGED
|
@@ -876,13 +876,36 @@ export async function lintFormPublishReadOnly(session, args) {
|
|
|
876
876
|
note: "降级门与真写同一函数;alreadyPublished:true 时真写会短路(不改发布面)",
|
|
877
877
|
};
|
|
878
878
|
}
|
|
879
|
+
/** A3 (issue 2026-11-25): the non-layout args that make a no-layout write an explicit, bounded intent. */
|
|
880
|
+
function hasExplicitDraftIntent(args) {
|
|
881
|
+
const nonEmpty = (value) => Array.isArray(value) && value.length > 0;
|
|
882
|
+
if (args.rebuild === true || args.refreshFromFields === true)
|
|
883
|
+
return true;
|
|
884
|
+
if (nonEmpty(args.fieldCodes) || nonEmpty(args.childColumns))
|
|
885
|
+
return true;
|
|
886
|
+
if (typeof args.draftHtmlJson === "string" && args.draftHtmlJson.trim() !== "")
|
|
887
|
+
return true;
|
|
888
|
+
if (nonEmpty(args.buttons) || nonEmpty(args.buttonScripts) || nonEmpty(args.removeButtonCodes))
|
|
889
|
+
return true;
|
|
890
|
+
return typeof args.customButtonJson === "string" && args.customButtonJson.trim() !== "";
|
|
891
|
+
}
|
|
879
892
|
/**
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
*
|
|
883
|
-
*
|
|
893
|
+
* Ticket 74 + A3 (issue 2026-11-25) pure gate (no session, zero wire):
|
|
894
|
+
* 1. caller-provided "[]"/"{}" face → `form-empty-layout`;
|
|
895
|
+
* 2. BOTH layout faces absent and no other explicit draft intent →
|
|
896
|
+
* `form-draft-empty-layout`.
|
|
897
|
+
*
|
|
898
|
+
* (2) is the A3 incident: `form.draft --args '{"schemaCode":"m"}'` carries no
|
|
899
|
+
* layout intent at all, so the executor falls back to the stored draft — and
|
|
900
|
+
* when that draft is empty (the platform designer's Save is not lossless, and
|
|
901
|
+
* `draftViewJson` may even be "") it re-scaffolds from fields, silently
|
|
902
|
+
* dropping every non-field control (approval-info widgets, HTML, buttons'
|
|
903
|
+
* layout). dry-run reads no environment, so it cannot tell whether the stored
|
|
904
|
+
* draft is empty; it must refuse before any wire call instead of promising
|
|
905
|
+
* `wouldChange:true`. One layout face alone IS a legitimate partial update, and
|
|
906
|
+
* explicit intents (rebuild / refreshFromFields / fieldCodes / childColumns /
|
|
907
|
+
* draftHtmlJson / button edits) stay allowed.
|
|
884
908
|
*/
|
|
885
|
-
/** Ticket 74 pure gate (no session): caller-provided "[]"/"{}" layouts refuse. */
|
|
886
909
|
export function refuseEmptyCallerLayout(args) {
|
|
887
910
|
if (args.allowEmptyLayout === true)
|
|
888
911
|
return;
|
|
@@ -891,15 +914,30 @@ export function refuseEmptyCallerLayout(args) {
|
|
|
891
914
|
emptyFaces.push("draftViewJson");
|
|
892
915
|
if (typeof args.draftAttributesJson === "string" && isEmptyLayoutJson(args.draftAttributesJson))
|
|
893
916
|
emptyFaces.push("draftAttributesJson");
|
|
894
|
-
if (emptyFaces.length
|
|
917
|
+
if (emptyFaces.length > 0) {
|
|
918
|
+
throw new ToolRefusalError({
|
|
919
|
+
status: "refused",
|
|
920
|
+
blocker: "form-empty-layout",
|
|
921
|
+
schemaCode: args.schemaCode,
|
|
922
|
+
sheetCode: args.sheetCode,
|
|
923
|
+
faces: emptyFaces,
|
|
924
|
+
message: `显式提供的 ${emptyFaces.join("、")} 是空布局("[]"/"{}")——平台设计器 Save 会把草稿清成该形态(非无损),照写会丢控件。若确要清空布局请显式传 allowEmptyLayout:true;若是设计器 Save 后的修复,先用表单版本历史(/api/api/app/bizsheet/history/list)取回完好版本原文再写回`,
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
if (args.draftViewJson !== undefined || args.draftAttributesJson !== undefined)
|
|
928
|
+
return;
|
|
929
|
+
if (hasExplicitDraftIntent(args))
|
|
895
930
|
return;
|
|
896
931
|
throw new ToolRefusalError({
|
|
897
932
|
status: "refused",
|
|
898
|
-
blocker: "form-empty-layout",
|
|
933
|
+
blocker: "form-draft-empty-layout",
|
|
899
934
|
schemaCode: args.schemaCode,
|
|
900
935
|
sheetCode: args.sheetCode,
|
|
901
|
-
|
|
902
|
-
message:
|
|
936
|
+
missingFaces: ["draftViewJson", "draftAttributesJson"],
|
|
937
|
+
message: "没有 draftViewJson / draftAttributesJson:这次调用没有任何布局意图。写入以环境里现存的草稿为准——草稿面为空(缺失、\"[]\"/\"{}\"、空串)时会按已发布字段重搭或落一份空/残布局,审批信息/HTML/按钮区等非字段控件全部消失,等于清空表单布局。平台不会替你把关:bizsheet/update 不校验空布局,publish 只校验数据项存在就把草稿原样提拔成发布面;dry-run 又不读环境,因此在任何 wire 之前拒绝。"
|
|
938
|
+
+ "部分更新只传其中一个布局键即可(只传 draftAttributesJson 或只传 draftViewJson 都合法);确认按已发布字段整表重搭请显式传 rebuild:true;只刷新字段派生配置传 refreshFromFields:true。"
|
|
939
|
+
+ `最小可用示例见 nextCommand(rebuild 重搭);带布局的写法:--args '{"schemaCode":"${args.schemaCode}","draftViewJson":"[[\\"name\\"]]","draftAttributesJson":"{\\"name\\":{\\"key\\":\\"name\\",\\"type\\":1,\\"options\\":{\\"name\\":\\"名称\\"}}}"}'`,
|
|
940
|
+
nextCommand: `omc call form.draft --args '{"schemaCode":"${args.schemaCode}","rebuild":true}'`,
|
|
903
941
|
});
|
|
904
942
|
}
|
|
905
943
|
/**
|
|
@@ -1189,6 +1227,134 @@ export function customButtonJsonStoredShape(options) {
|
|
|
1189
1227
|
return "absent";
|
|
1190
1228
|
}
|
|
1191
1229
|
export const CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING = "customButtonJson 被存为字符串(双重编码)——前端按钮不渲染,设计器形状=数组+actionConfig 对象(线上 #38);用 form.draft/form.publish 重写 buttons 即自愈";
|
|
1230
|
+
/**
|
|
1231
|
+
* B5-2(issue 2026-11-25 真机 2.1.5):`faces.inSync` 原先只比
|
|
1232
|
+
* `draftViewJson === publishedViewJson`,于是「草稿改了字段标签
|
|
1233
|
+
* (attributesJson.options.name)」仍旧回 `inSync:true / effectiveFace:"published"`,
|
|
1234
|
+
* 结论句还写「与发布面一致」。
|
|
1235
|
+
*
|
|
1236
|
+
* 平台自己的「有没有未发布草稿」判定比的是**四对**面(对:
|
|
1237
|
+
* attributes/view/actions/html,任一不同即 existDraft):
|
|
1238
|
+
* - 8.6.26:`AppIntegrationFacadeImpl.java:2670`(decompiled-full/launcher-8.6.26/
|
|
1239
|
+
* cloudpivot-engine)同式在 `decompiled-engine/.../AppIntegrationFacadeImpl.java:2725`;
|
|
1240
|
+
* 随后的提拔分支把 draft 四份逐份拷进 published(:2681-2684 / :2726-2730)。
|
|
1241
|
+
* - 设计器发布把四面写成同一份内存值:`publishedAttributesJson`/`publishedViewJson`
|
|
1242
|
+
* 由布局生成后回填 draft,`draftActionsJson=publishedActionsJson`、
|
|
1243
|
+
* `draftHtmlJson=publishedHtmlJson`(frontend-dist/admin/js/4280.cfa75764.js
|
|
1244
|
+
* `initLayout` 后的发布分支;同文件保存分支只写 draft)。
|
|
1245
|
+
* - 运行时面只认 published 四份:`getPublishBizForm` 把 draft 四份置 null 后交付
|
|
1246
|
+
* (ModelManagementFacadeImpl.java:626-640 / 2.1.5 :624-639,B5 已引)。
|
|
1247
|
+
*
|
|
1248
|
+
* 比较用**规范化后的语义等值**,不是字符串:平台两种写法(null vs "[]" vs "{}"、
|
|
1249
|
+
* 顶层 JSON 串、嵌套 stringified JSON、对象键序)表示同一个面时不应制造差异
|
|
1250
|
+
* (同一口径见 lanes/config-diff.ts 的 FORM_FACE_PAIRS / normalizeEmptyPair)。
|
|
1251
|
+
*/
|
|
1252
|
+
export const FORM_FACE_PAIRS = [
|
|
1253
|
+
{ key: "view", draftKey: "draftViewJson", publishedKey: "publishedViewJson" },
|
|
1254
|
+
{ key: "attributes", draftKey: "draftAttributesJson", publishedKey: "publishedAttributesJson" },
|
|
1255
|
+
{ key: "html", draftKey: "draftHtmlJson", publishedKey: "publishedHtmlJson" },
|
|
1256
|
+
{ key: "actions", draftKey: "draftActionsJson", publishedKey: "publishedActionsJson" },
|
|
1257
|
+
];
|
|
1258
|
+
const EMPTY_FORM_FACE = { __emptyFormFace: true };
|
|
1259
|
+
/**
|
|
1260
|
+
* Canonical value for one face: object keys sorted (order-insensitive), arrays
|
|
1261
|
+
* kept in order (row/button order is meaningful), and stringified JSON parsed
|
|
1262
|
+
* so `{options:"{\"name\":\"A\"}"}` and `{options:{name:"A"}}` compare equal.
|
|
1263
|
+
* null / "" / "[]" / "{}" all canonicalise to the same empty sentinel: the
|
|
1264
|
+
* platform stores "no face" in any of those spellings (config-diff
|
|
1265
|
+
* normalizeEmptyPair has the same rule for the diff face).
|
|
1266
|
+
*/
|
|
1267
|
+
function canonicalFormFaceValue(value) {
|
|
1268
|
+
if (Array.isArray(value)) {
|
|
1269
|
+
if (value.length === 0)
|
|
1270
|
+
return EMPTY_FORM_FACE;
|
|
1271
|
+
return value.map((item) => canonicalFormFaceValue(item));
|
|
1272
|
+
}
|
|
1273
|
+
if (value !== null && typeof value === "object") {
|
|
1274
|
+
const entries = Object.entries(value)
|
|
1275
|
+
.filter(([, item]) => item !== undefined)
|
|
1276
|
+
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));
|
|
1277
|
+
if (entries.length === 0)
|
|
1278
|
+
return EMPTY_FORM_FACE;
|
|
1279
|
+
return Object.fromEntries(entries.map(([key, item]) => [key, canonicalFormFaceValue(item)]));
|
|
1280
|
+
}
|
|
1281
|
+
if (typeof value === "string") {
|
|
1282
|
+
const trimmed = value.trim();
|
|
1283
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
1284
|
+
try {
|
|
1285
|
+
return canonicalFormFaceValue(JSON.parse(trimmed));
|
|
1286
|
+
}
|
|
1287
|
+
catch {
|
|
1288
|
+
return value;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
return value;
|
|
1292
|
+
}
|
|
1293
|
+
return value;
|
|
1294
|
+
}
|
|
1295
|
+
/** Canonical signature of a stored face column (dirty/unparsable columns stay opaque text). */
|
|
1296
|
+
function formFaceSignature(value) {
|
|
1297
|
+
if (value === undefined || value === null)
|
|
1298
|
+
return JSON.stringify(EMPTY_FORM_FACE);
|
|
1299
|
+
if (typeof value !== "string")
|
|
1300
|
+
return JSON.stringify(canonicalFormFaceValue(value));
|
|
1301
|
+
const trimmed = value.trim();
|
|
1302
|
+
if (trimmed === "")
|
|
1303
|
+
return JSON.stringify(EMPTY_FORM_FACE);
|
|
1304
|
+
if (!trimmed.startsWith("{") && !trimmed.startsWith("["))
|
|
1305
|
+
return JSON.stringify(trimmed);
|
|
1306
|
+
try {
|
|
1307
|
+
return JSON.stringify(canonicalFormFaceValue(JSON.parse(trimmed)));
|
|
1308
|
+
}
|
|
1309
|
+
catch {
|
|
1310
|
+
return JSON.stringify(trimmed);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Compare the draft face against the published face ACROSS all four published
|
|
1315
|
+
* columns. `draftPresent`/`publishedPresent` are the caller's content-derived
|
|
1316
|
+
* presence booleans (same rule as `faces.*.present`); when either side is
|
|
1317
|
+
* absent the faces are not comparable and `inSync` stays null.
|
|
1318
|
+
*/
|
|
1319
|
+
export function compareFormFaces(sheet, presence) {
|
|
1320
|
+
if (!presence.draftPresent || !presence.publishedPresent)
|
|
1321
|
+
return { inSync: null, differingFaces: [] };
|
|
1322
|
+
const differingFaces = [];
|
|
1323
|
+
for (const pair of FORM_FACE_PAIRS) {
|
|
1324
|
+
if (formFaceSignature(sheet[pair.draftKey]) !== formFaceSignature(sheet[pair.publishedKey]))
|
|
1325
|
+
differingFaces.push(pair.key);
|
|
1326
|
+
}
|
|
1327
|
+
return { inSync: differingFaces.length === 0, differingFaces };
|
|
1328
|
+
}
|
|
1329
|
+
export function resolveEffectiveFormFace(input) {
|
|
1330
|
+
const { draftPresent, publishedPresent, inSync } = input;
|
|
1331
|
+
if (publishedPresent) {
|
|
1332
|
+
if (draftPresent && inSync === false) {
|
|
1333
|
+
const where = input.differingFaces && input.differingFaces.length > 0 ? `(${input.differingFaces.join("/")} 面不同)` : "";
|
|
1334
|
+
return {
|
|
1335
|
+
effectiveFace: "both",
|
|
1336
|
+
effectiveFaceNote: `线上=published 面;draft 是另一份未发布草稿,有未发布改动${where},form.publish 后才生效`,
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
return {
|
|
1340
|
+
effectiveFace: "published",
|
|
1341
|
+
effectiveFaceNote: draftPresent
|
|
1342
|
+
? "线上=published 面(draft 内容与发布面语义一致,没有未发布改动)"
|
|
1343
|
+
: "线上=published 面(没有草稿面)",
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
if (draftPresent)
|
|
1347
|
+
return {
|
|
1348
|
+
effectiveFace: "draft",
|
|
1349
|
+
effectiveFaceNote: "只有 draft 面,线上读不到(published*Json 为空),需 form.publish",
|
|
1350
|
+
};
|
|
1351
|
+
return {
|
|
1352
|
+
effectiveFace: "none",
|
|
1353
|
+
effectiveFaceNote: "两面皆空,线上不可读",
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
/** 旗标与内容矛盾时的「以谁为准」一句话(B5;拼进 flagNote,不另开长键)。 */
|
|
1357
|
+
export const FORM_FLAG_AUTHORITY_NOTE = "以 faces/effectiveFace 为准:published*Json 内容才是运行时面,published/existDraft 旗标会滞后";
|
|
1192
1358
|
/** The caller's buttons from a READ face (parsed array, or null when absent).
|
|
1193
1359
|
* #39/#38: decodes BOTH stored forms — the designer's ARRAY (authoritative;
|
|
1194
1360
|
* the read face used to be blind to it and answered null while the store
|
|
@@ -1210,6 +1376,12 @@ export function readFormButtons(options) {
|
|
|
1210
1376
|
}
|
|
1211
1377
|
return Array.isArray(parsed) ? parsed : null;
|
|
1212
1378
|
}
|
|
1379
|
+
/**
|
|
1380
|
+
* Shared form.draft write body — read the current sheet, compose a scaffold
|
|
1381
|
+
* from published fields when the form is empty, and POST the proven payload
|
|
1382
|
+
* to bizsheet/update. Used by the form.draft write tool AND by configure_form,
|
|
1383
|
+
* so the high-level orchestrator never bypasses the scaffold.
|
|
1384
|
+
*/
|
|
1213
1385
|
export async function executeFormDraftWrite(session, args) {
|
|
1214
1386
|
// 兼容别名:`fieldCodes:["items.category"]` 等价于
|
|
1215
1387
|
// `childColumns:[{parent:"items",fieldCodes:["category"]}]`(issue #24)。
|