@stalfh233/omc-cli 0.6.99 → 0.6.100

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/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
@@ -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
- ...(mergedOptions !== undefined ? { options: mergedOptions } : {}),
1797
+ ...(finalOptions !== undefined ? { options: finalOptions } : {}),
1741
1798
  schemaCode: args.schemaCode,
1742
1799
  code: args.sheetCode,
1743
1800
  name: pre.name,
@@ -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",
@@ -49,6 +49,24 @@ function normalizeOptions(dataRuleType, options, propertyCode) {
49
49
  }
50
50
  return normalized;
51
51
  }
52
+ /**
53
+ * T24(2.1.5):`validateHiddenProperties` 的「未声明 = 保留」比较语义。
54
+ *
55
+ * lane 的 `datarule.update` 会把当前行里、调用方没显式给的
56
+ * `validateHiddenProperties` 自动捎带(`withPreservedHiddenValidation`)。因此
57
+ * intent 没声明该键时,读回里多出来的值属于**保留**,不是漂移——严格比较会让
58
+ * 每次 plan 都发 update、apply 后又永远 mismatch。声明了该键才参与比较。
59
+ */
60
+ function optionsForComparison(declared, live) {
61
+ if (declared === null || typeof declared !== "object" || Array.isArray(declared))
62
+ return live;
63
+ if (Object.prototype.hasOwnProperty.call(declared, "validateHiddenProperties"))
64
+ return live;
65
+ if (live === null || typeof live !== "object" || Array.isArray(live))
66
+ return live;
67
+ const { validateHiddenProperties: _preserved, ...rest } = live;
68
+ return rest;
69
+ }
52
70
  /** Stored target field codes (propertyCodes array preferred, legacy singular fallback). */
53
71
  function rowCodes(row) {
54
72
  if (Array.isArray(row.propertyCodes) && row.propertyCodes.length > 0)
@@ -156,7 +174,7 @@ export const dataruleCapability = {
156
174
  }
157
175
  if (!current)
158
176
  emit.change("datarule.create", { schemaCode: intent.code, ...rule }, resource, "datarule-absent");
159
- else if (!sameValue(current.options, rule.options) || !optionalSame(current.checkType, rule.checkType) || !optionalSame(current.childRule, rule.childRule) || !optionalSame(current.name, rule.name) || !optionalSame(current.sortKey, rule.sortKey))
177
+ else if (!sameValue(optionsForComparison(rule.options, current.options), rule.options) || !optionalSame(current.checkType, rule.checkType) || !optionalSame(current.childRule, rule.childRule) || !optionalSame(current.name, rule.name) || !optionalSame(current.sortKey, rule.sortKey))
160
178
  emit.change("datarule.update", { id: current.id, schemaCode: intent.code, ...rule }, resource, "datarule-drift");
161
179
  else
162
180
  emit.skip(resource, "datarule-present");
@@ -179,7 +197,7 @@ export const dataruleCapability = {
179
197
  }
180
198
  if (!row)
181
199
  emit.difference("datarule-missing", resource, `字段 ${intent.code}.${rule.propertyCode} 的数据规则不存在`);
182
- else if (!sameValue(row.options, rule.options) || !optionalSame(row.checkType, rule.checkType) || !optionalSame(row.childRule, rule.childRule) || !optionalSame(row.name, rule.name) || !optionalSame(row.sortKey, rule.sortKey))
200
+ else if (!sameValue(optionsForComparison(rule.options, row.options), rule.options) || !optionalSame(row.checkType, rule.checkType) || !optionalSame(row.childRule, rule.childRule) || !optionalSame(row.name, rule.name) || !optionalSame(row.sortKey, rule.sortKey))
183
201
  emit.difference("datarule-mismatch", resource, `字段 ${intent.code}.${rule.propertyCode} 的数据规则不等价`);
184
202
  }
185
203
  },
@@ -39,7 +39,7 @@ const dataRuleOptionsArg = z
39
39
  * a distinct options key. `checkType` is ONLY meaningful with dataRuleType 1.
40
40
  *
41
41
  * - 1 REGEX_CHECK 正则校验 options {regexp:"/…/", regexpText:{zh,en}} (regexp is slash-wrapped; RegexCheckValidator strips the outer chars)
42
- * - 2 SUBMIT_CHECK 提交校验 options {conditions:"<cond>[ &&| || <cond>]", verifyType:"submitDenied"? , prompt:"<plain text — the portal shows options.prompt verbatim, so do NOT URL-encode it>"} ← cross-field rules use a currentModel value object on the right (e.g. {end} 小于 {"valueType":"currentModel","value":"start"})
42
+ * - 2 SUBMIT_CHECK 提交校验 options {conditions:"<cond>[ &&| || <cond>]", verifyType:"submitDenied"? , prompt:"<plain text — the portal shows options.prompt verbatim, so do NOT URL-encode it>", validateHiddenProperties?:[<fieldCodes>]} ← cross-field rules use a currentModel value object on the right (e.g. {end} 小于 {"valueType":"currentModel","value":"start"})
43
43
  * - 3 EMPTY_ROW_CHECK 空行校验 options {isEmptyRow:true, isEmptyRowTips?}
44
44
  * - 4 MAX_LENGTH_CHECK 最大长度 options {maxLength:<int>}
45
45
  * - 5 REPEAT_CHECK 重复校验 options {properties:[<fieldCodes>], isSubTableValidationAllData?, prompt:[{code,isDataItem}]}
@@ -54,7 +54,11 @@ export const DATARULE_CHECK_TYPES = Object.freeze({
54
54
  /** Options the 8.6.26 engine actually reads for each data-rule discriminator. */
55
55
  export const DATARULE_CHECK_OPTION_KEYS = Object.freeze({
56
56
  1: Object.freeze(["regexp", "regexpText"]),
57
- 2: Object.freeze(["conditions", "verifyType", "prompt"]),
57
+ // 2.1.5 `DataRuleOptions.validateHiddenProperties`(`launcher-2.1.5/cloudpivot-contracts-AI-Platform-v2.1.5/.../
58
+ // bizmodel/DataRuleOptions.java:18`)由服务端 `ConditionFilterUtil`(同批 :29)按它过滤隐藏字段;
59
+ // 条件是条件串,所以只有 checkType 2(唯一读 conditions 的类别)接受它。8.6.26 无此键——白名单是并集,
60
+ // 8.6 环境带着它写入无害(服务端忽略),但读取面会把它算作 effective 而非 ignored。
61
+ 2: Object.freeze(["conditions", "verifyType", "prompt", "validateHiddenProperties"]),
58
62
  3: Object.freeze(["isEmptyRow", "isEmptyRowTips"]),
59
63
  4: Object.freeze(["maxLength"]),
60
64
  5: Object.freeze(["noRepeat", "properties", "isSubTableValidationAllData", "prompt"]),
@@ -573,6 +577,31 @@ async function assertChildFormulaRefs(session, args, knownChildFields) {
573
577
  `(裸 {字段}=主记录字段,带点 {子表code.字段}=子表字段)。`,
574
578
  });
575
579
  }
580
+ /**
581
+ * T24(2.1.5):`validateHiddenProperties` 的自动保留。
582
+ *
583
+ * `datarule.update` 把 options **整份重发**(平台 update 是全行覆盖,见
584
+ * `fullDataRuleBody`),所以调用方只改 `prompt` 时,没带 `validateHiddenProperties`
585
+ * 就会把设计器配好的隐藏字段校验名单**静默清空**(服务端 `ConditionFilterUtil`
586
+ * 正是按这份名单过滤隐藏字段的必填/唯一校验:`launcher-2.1.5/.../ConditionFilterUtil.java:29`)。
587
+ * 规则:调用方显式给了该键(含 `null`/`[]`)就尊重;没给则从当前行 options 原样捎带。
588
+ *
589
+ * 只在目标类型/checkType 的白名单接受该键时合并(checkType 2),否则改 checkType
590
+ * 的更新会因残留键撞 `datarule-unknown-option-keys`。合并必须发生在
591
+ * `withStitchEditorText`/`withOptionsPropertyCodes` 之前,避免被后两者重建的 options 覆盖。
592
+ */
593
+ export function withPreservedHiddenValidation(options, currentOptions, dataRuleType, checkType) {
594
+ if (options.validateHiddenProperties !== undefined)
595
+ return options;
596
+ if (!effectiveOptionKeys(dataRuleType, checkType).includes("validateHiddenProperties"))
597
+ return options;
598
+ if (currentOptions === null || typeof currentOptions !== "object" || Array.isArray(currentOptions))
599
+ return options;
600
+ const stored = currentOptions.validateHiddenProperties;
601
+ if (stored === undefined)
602
+ return options;
603
+ return { ...options, validateHiddenProperties: stored };
604
+ }
576
605
  /** Ensure the wire `options` carries `propertyCodes` (comma-joined), as the designer writes it. */
577
606
  function withOptionsPropertyCodes(options, codes) {
578
607
  if (codes.length === 0)
@@ -1022,10 +1051,12 @@ export function registerDataRuleLane(tools) {
1022
1051
  if (duplicate)
1023
1052
  throw new ToolRefusalError({ status: "refused", blocker: "datarule-duplicate-property-type", nextCommand: `omc call datarule.update --args '${JSON.stringify({ id: String(duplicate.id ?? "<existingId>"), schemaCode: args.schemaCode, propertyCode: codes.length === 1 ? codes[0] : undefined, propertyCodes: codes.length > 1 ? codes : undefined, dataRuleType: args.dataRuleType, checkType: args.checkType, options: args.options })}'`, message: `字段 ${args.schemaCode}.${codes.join(",")} 已存在同类型数据规则${args.dataRuleType === 1 ? `(checkType ${args.checkType})` : ""};拒绝 update POST;如需修改请使用该规则 id 更新` });
1024
1053
  const beforeDecoded = decodeDataRule(current);
1054
+ // T24:先合并再走 withStitchEditorText/withOptionsPropertyCodes(两者会重建 options 对象)。
1055
+ const outgoingOptions = withPreservedHiddenValidation(args.options, parseOptions(current.options), args.dataRuleType, args.checkType);
1025
1056
  const performed = await wireCall(session, {
1026
1057
  path: ENDPOINTS.dataRuleUpdate,
1027
1058
  method: "POST",
1028
- body: fullDataRuleBody(current, boundArgs, JSON.stringify(withOptionsPropertyCodes(withStitchEditorText(args.options), codes))),
1059
+ body: fullDataRuleBody(current, boundArgs, JSON.stringify(withOptionsPropertyCodes(withStitchEditorText(outgoingOptions), codes))),
1029
1060
  });
1030
1061
  const record = (await listDataRules(session, args.schemaCode, args.dataRuleType)).find((row) => row.id === id);
1031
1062
  if (!record)
@@ -9,7 +9,8 @@ import { decodeJsonColumn, decodeJsonObjectColumn, JSON_COLUMN_NULL_COALESCE, JS
9
9
  import { syncFormConditionDataRules } from "./datarule.js";
10
10
  import { FORM_CONDITION_OPTION_KEYS } from "./datarule-protocol.js";
11
11
  import { defineTool, ToolRefusalError } from "../tool-types.js";
12
- import { wireCall, wireRows, WireError } from "../wire.js";
12
+ import { wireCall, wireRows, WireError, optionPublishMessages } from "../wire.js";
13
+ import { assertTreeSelectionOptions } from "../field-tree-options.js";
13
14
  import { executeFormDraftWrite, executeFormPublishWrite, readFormOrNull } from "../form-support.js";
14
15
  import { FIELD_LANE_CONTRACT } from "./field-contract.js";
15
16
  import { flattenTreeRows, mapBounded } from "../support.js";
@@ -1691,8 +1692,12 @@ export async function executeFieldPublish(session, args) {
1691
1692
  // pre-publish DRAFT shape (name + type). The draft face must be
1692
1693
  // snapshotted BEFORE the publish because a model-scoped publish can leave
1693
1694
  // it empty; the draft row is the caller-visible expectation.
1694
- const draftSnapshot = new Map(wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: "false" } })).data)
1695
- .map((row) => [codeOf(row), { name: String(row.name ?? ""), propertyType: Number(row.type ?? row.propertyType) }]));
1695
+ // T19:发布门预检与已发布短路比对复用同一草稿读。快照本身只放 name/type
1696
+ //(detail 校验的 expected 会原样回给调用方);原始 options 单独一张表,
1697
+ // 避免把整列 options 带进 mismatches.expected。
1698
+ const draftRows = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: "false" } })).data);
1699
+ const draftSnapshot = new Map(draftRows.map((row) => [codeOf(row), { name: String(row.name ?? ""), propertyType: Number(row.type ?? row.propertyType) }]));
1700
+ const draftOptionsRawByCode = new Map(draftRows.map((row) => [codeOf(row), row.options]));
1696
1701
  const verifyFieldDetails = async (targets) => {
1697
1702
  const bounded = targets.slice(0, 25);
1698
1703
  const checked = await mapBounded(bounded, 5, async (code) => {
@@ -1731,9 +1736,9 @@ export async function executeFieldPublish(session, args) {
1731
1736
  // r29e F10/F11:旧短路只看「code 在发布面存在」,改了 options 仍报
1732
1737
  // already-published + verification.ok(假绿)。再比草稿/发布 options 指纹;
1733
1738
  // 不一致就真发布。name/type 仍由 verifyFieldDetails 核对。
1734
- const draftOptionsByCode = new Map(wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: "false" } })).data)
1735
- .map((row) => [codeOf(row), optionsFingerprint(row.options)])
1736
- .filter(([code]) => code.length > 0));
1739
+ const draftOptionsByCode = new Map([...draftOptionsRawByCode]
1740
+ .filter(([code]) => code.length > 0)
1741
+ .map(([code, options]) => [code, optionsFingerprint(options)]));
1737
1742
  const publishedOptionsByCode = new Map(prePublishedRows
1738
1743
  .map((row) => [codeOf(row), optionsFingerprint(row.options)])
1739
1744
  .filter(([code]) => code.length > 0));
@@ -1762,6 +1767,12 @@ export async function executeFieldPublish(session, args) {
1762
1767
  },
1763
1768
  };
1764
1769
  }
1770
+ // T19(2026-11-24):2.1.5+ 的树形自定义下拉发布门。平台在模型级发布时
1771
+ // 递归校验 custom 树的 code/value 非空 + code 全树唯一,非法即整单失败
1772
+ // (外层 300004「数据模型不存在!」+ 逐项 301013,真正原因在 data 里)。
1773
+ // 这个预检必须在 POST 之前:already-published 短路只在 options 指纹一致时
1774
+ // 成立;改了 options 会走到这里真发布,正好被门拦。
1775
+ await assertTreeSelectionOptions(session, args.schemaCode, draftRows);
1765
1776
  // Ticket 79 live-fidelity (docker log evidence, 2026-09-13 21:43-21:45,
1766
1777
  // cloud8_launcher log_error.log + nginx access timings): under DB
1767
1778
  // connection-pool contention a model publish can fail with a transient
@@ -1788,6 +1799,29 @@ export async function executeFieldPublish(session, args) {
1788
1799
  // 「数据模型不存在!」。子表不是顶层 biz schema,发布是父模型级。旧回执只
1789
1800
  // 把裸 wire 错误冒泡 + 指向 omc help omc-refusals,用户只能自己猜父模型。
1790
1801
  if (error instanceof WireError && error.kind === "business" && error.errcode === 300004) {
1802
+ // T20(2026-11-24):2.1.5 把「树形自定义选项非法」的整单发布失败包成
1803
+ // 外层 300004 + 609016,真正原因在 data 的逐项 301013「…数据项的选项
1804
+ // 设置有误」(BizSchemaCheckServiceImpl :60-66 抛
1805
+ // BIZ_SCHEMA_MODEL_NOT_EXIST,明细在 data)。先认 payload,别让用户去
1806
+ // 查「模型不存在/子表」。
1807
+ const platformMessages = optionPublishMessages(error.payload);
1808
+ if (platformMessages.length > 0) {
1809
+ throw new ToolRefusalError({
1810
+ status: "refused",
1811
+ blocker: "field-options-publish-invalid",
1812
+ errcode: 300004,
1813
+ schemaCode: args.schemaCode,
1814
+ platformMessages,
1815
+ nextCommand: `omc call field.list --args '${JSON.stringify({ schemaCode: args.schemaCode, published: false })}'`,
1816
+ message: `平台在发布时拒绝了本模型的字段选项(外层 300004「数据模型不存在!」只是外壳,明细是 301013):${platformMessages.join(";")}。` +
1817
+ "这不是模型不存在、也不是子表 schemaCode 问题。2.1.5+ 在**模型级发布**时递归校验树形自定义下拉(optionsSet.optionsType=\"custom\" + " +
1818
+ "optionStructure=\"tree\"):每个节点的 code(平台内部叫**选项编码**,口语叫 key)与 value(显示值)必须非空,且 code 全树唯一" +
1819
+ "(RadioOptionsModel.validateCustomTreeOptions,launcher-2.1.5 .../bizmodel/RadioOptionsModel.java:130-142)。" +
1820
+ "8.6/8.7 不查;平铺自定义/字典/业务模型下拉也不查。修法:用 field.update 给报错字段的节点补非空 code/value。" +
1821
+ "若不需要层级,把 optionsSet.optionStructure 改成 \"flat\" 再发布。",
1822
+ nextAction: "先 omc call field.list --args '{\"schemaCode\":\"<model>\",\"published\":false}' 核对草稿字段的 optionsSet.custom 树;修好后重跑 field.publish",
1823
+ });
1824
+ }
1791
1825
  const parent = await findChildTableParent(session, args.schemaCode).catch(() => undefined);
1792
1826
  throw new ToolRefusalError({
1793
1827
  status: "refused",
@@ -19,7 +19,7 @@ const FORM_TOOLS = FORM_LANE_CONTRACT.tools;
19
19
  * `src/endpoints.ts` 由 discovery 片持有,本轮不新增 ENDPOINTS 键(w2 设计 §3.5
20
20
  * 的所有权划分)——单一真相仍是 contract 的 wire 事实。
21
21
  */
22
- const FORM_SHEET_LIST_PATH = "/api/api/app/bizsheet/list";
22
+ const FORM_SHEET_LIST_PATH = ENDPOINTS.sheetList;
23
23
  /** BizFormType.getIndex()(BizFormType.java:13-15,45-48);未知索引原样透传、不猜。 */
24
24
  const FORM_TYPE_NAMES = Object.freeze({ 0: "DEFAULT_SHEET", 1: "CUSTOMIZE_SHEET", 2: "PRINT_TEMPLATE" });
25
25
  const FORM_LIST_MAX_SHEETS = 12;
@@ -410,6 +410,22 @@ export function buttonsRenderCompat(buttons) {
410
410
  }
411
411
  return violations.length ? { ok: false, violations } : { ok: true };
412
412
  }
413
+ /**
414
+ * T22:2.1.5 树视图(`displayType="INLINE_LIST"`)条件行的三个树过滤组键
415
+ * (`BizQueryConditionModel.java:90,92,94`)。8.6 的条件行没有它们;读面只在
416
+ * 有值时才投影、写面只在基线含它们时设防,8.6 因此零影响。
417
+ */
418
+ export const LISTVIEW_TREE_CONDITION_KEYS = ["treeLimitScopeType", "treeLimitConditionGroup", "treeDefaultConditionGroup"];
419
+ /**
420
+ * 一行条件上「有值」的树过滤组键(undefined/null/空串视为没配)。读面投影与
421
+ * 写前保护共用这一个判定,避免「读得见但判成没值」的双面不一致。
422
+ */
423
+ export function treeConditionKeysPresent(row) {
424
+ return LISTVIEW_TREE_CONDITION_KEYS.filter((key) => {
425
+ const value = row[key];
426
+ return value !== undefined && value !== null && !(typeof value === "string" && value.trim() === "");
427
+ });
428
+ }
413
429
  /**
414
430
  * The keys a list-view condition (a filter CONTROL definition) accepts. Mirrors
415
431
  * `com.authine.cloudpivot.metadata.bizquery.BizQueryConditionModel` (8.6.26) at
@@ -437,6 +453,11 @@ const LISTVIEW_CONDITION_KEYS = new Set([
437
453
  "buildTreeBy",
438
454
  "visible",
439
455
  "filterType",
456
+ // T22:2.1.5 `BizQueryConditionModel.java:90,92,94` 的树视图过滤组三键
457
+ // (treeLimitScopeType / treeLimitConditionGroup / treeDefaultConditionGroup)。
458
+ // 8.6 的条件行没有它们;调用方显式传入时必须放行(否则
459
+ // listview-condition-unknown-key 会把「原样带回」的路堵死),值原样透传。
460
+ ...LISTVIEW_TREE_CONDITION_KEYS,
440
461
  ]);
441
462
  /**
442
463
  * Out-the-door dry lint for `sorts`/`conditions`/`actions`/`presentation`/
@@ -732,6 +753,30 @@ export function assertListViewConfigureShape(args) {
732
753
  if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
733
754
  throw new ToolRefusalError({ status: "refused", blocker: "listview-query-layer-invalid", message: "queryLayer entries must be objects" });
734
755
  }
756
+ // T21 零副作用拒收(写前、无 wire):2.1.5 的「内联树」
757
+ // (`BizQueryLayer.displayType="INLINE_LIST"`)不是纯配置——平台只在
758
+ // `/query/publish` 里初始化层级:`BizQueryController.java:979-986` 调
759
+ // `initializeHierarchyPath`,由 `HierarchyPathInitializationServiceImpl.java:59-140`
760
+ // 建 `_hierarchy_path_<hash>` LONG_TEXT 列 + 停写锁 + 全表回填 + 状态。OMC 走的是
761
+ // `/query/update`(`endpoints.ts` listQueryUpdate),写完视图立即 publish=TRUE 但
762
+ // 层级从未初始化 → 树加载抛 `HIERARCHY_PATH_MAINTENANCE_PENDING`
763
+ // (`QueryRuntimeController.java:457-470`),数据写入还可能撞未建列。8.6/8.7 的
764
+ // `BizQueryLayer` 没有 displayType/treeLoadMode,因此这条路径只能拒收、指路设计器。
765
+ // 只检查**本次显式传入**的 args.queryLayer:基线里已有的 INLINE_LIST 由
766
+ // `{...model}` echo 回写,其层级早已由当初的设计器发布初始化过,不在此列。
767
+ if (entry.displayType === "INLINE_LIST") {
768
+ throw new ToolRefusalError({
769
+ status: "refused",
770
+ blocker: "listview-inline-tree-needs-publish",
771
+ nextAction: "用平台设计器发布该视图(双端 PC/APP)让平台建层级路径列并回填,或先把该层改回普通层级(displayType 不用 INLINE_LIST)再配置",
772
+ message: "内联树(displayType=INLINE_LIST)不能经 OMC 的 /query/update 配置:" +
773
+ "平台只在 /query/publish 里初始化层级(BizQueryController.java:979-986 → " +
774
+ "HierarchyPathInitializationServiceImpl.java:59-140:建 _hierarchy_path_* LONG_TEXT 列 + 停写锁 + 全表回填 + 状态)," +
775
+ "而 /query/update 只落配置、随即 publish=TRUE;层级没初始化时树加载会抛 " +
776
+ "HIERARCHY_PATH_MAINTENANCE_PENDING(QueryRuntimeController.java:457-470),数据写入也可能撞未建列。" +
777
+ "8.6/8.7 的 BizQueryLayer 也没有 displayType/treeLoadMode。本次零写入拒绝;请改用平台设计器发布该视图,或先配置普通层级。",
778
+ });
779
+ }
735
780
  }
736
781
  }
737
782
  const multiTableHeaderConfig = args.multiTableHeaderConfig;
@@ -864,6 +909,12 @@ export function normalizeConditions(conditions, fieldRows, schemaCode) {
864
909
  row.includeSubData = condition.includeSubData;
865
910
  if (condition.buildTreeBy !== undefined)
866
911
  row.buildTreeBy = condition.buildTreeBy;
912
+ // T22:树过滤组三键(BizQueryConditionModel.java:90,92,94)。读面原样带出、
913
+ // 调用方显式带回时必须原样落到写报文,否则「允许带齐」只是放行却仍静默丢。
914
+ for (const key of LISTVIEW_TREE_CONDITION_KEYS) {
915
+ if (condition[key] !== undefined)
916
+ row[key] = condition[key];
917
+ }
867
918
  // A query condition IS a filter the list shows; the platform defaults an
868
919
  // omitted `visible` to false, which hides every filter the caller asked
869
920
  // for. Offer it shown unless the caller explicitly opts out.
@@ -1099,7 +1150,7 @@ export function decodeSortRow(row) {
1099
1150
  };
1100
1151
  }
1101
1152
  export function decodeConditionRow(row) {
1102
- return {
1153
+ const out = {
1103
1154
  propertyCode: row.propertyCode ?? null,
1104
1155
  propertyType: row.propertyType ?? null,
1105
1156
  displayType: decodeWireEnum(DISPLAY_TYPE, row.displayType),
@@ -1119,11 +1170,37 @@ export function decodeConditionRow(row) {
1119
1170
  buildTreeBy: row.buildTreeBy ?? null,
1120
1171
  visible: row.visible ?? null,
1121
1172
  };
1173
+ // T22:2.1.5 树视图过滤组三键(BizQueryConditionModel.java:90,92,94)。8.6 的
1174
+ // 条件行没有它们 → 一个字节都不新增;有值才带,避免给普通条件加三个 null 噪声。
1175
+ const presentTreeKeys = treeConditionKeysPresent(row);
1176
+ for (const key of LISTVIEW_TREE_CONDITION_KEYS) {
1177
+ if (presentTreeKeys.includes(key))
1178
+ out[key] = row[key];
1179
+ }
1180
+ return out;
1122
1181
  }
1123
1182
  export function readArray(model, key) {
1124
1183
  const value = model[key];
1125
1184
  return Array.isArray(value) ? value : [];
1126
1185
  }
1186
+ /**
1187
+ * T22:`listview.get` 精简面的 queryLayer 摘要。2.1.5 的 `BizQueryLayer` 新增
1188
+ * `displayType`/`treeLoadMode`(`docs/platform-contracts/2.1-delta.md:62`,8.6
1189
+ * 的 `apps.d.ts:145-205` 没有),但完整对象是设计器面的大载荷,精简面只回
1190
+ * 「这层是什么」:code/layerType/displayType/treeLoadMode,缺失键省略——8.6 的
1191
+ * 层对象不会凭空多出 displayType/treeLoadMode。
1192
+ */
1193
+ export function queryLayerSummary(queryLayer) {
1194
+ return queryLayer.map((layer) => {
1195
+ const summary = {};
1196
+ for (const key of ["code", "layerType", "displayType", "treeLoadMode"]) {
1197
+ const value = layer[key];
1198
+ if (value !== undefined && value !== null)
1199
+ summary[key] = value;
1200
+ }
1201
+ return summary;
1202
+ });
1203
+ }
1127
1204
  export function decodeActionRow(row) {
1128
1205
  const type = row.queryActionType;
1129
1206
  const association = row.associationType ?? row.queryActionRelativeType;
@@ -11,7 +11,7 @@ import { QUERY_ACTION_TYPE } from "omc-core/list-view-wire";
11
11
  import { resolveModelTreeNode } from "./model.js";
12
12
  import { NUMERICAL_FORMAT_DECIMALS, SYSTEM_FIELD_CODES, canonicalNumericalFormat } from "../field-families.js";
13
13
  import { LIST_VIEW_LANE_CONTRACT } from "./list-view-contract.js";
14
- import { assertListViewConfigureShape, decodeActionRow, decodeButtonRow, decodeConditionRow, decodeGantt, decodePresentation, decodeSortRow, listViewActionArg, listViewButtonArg, listViewConditionArg, listViewGanttArg, listViewMultiTableHeaderArg, listViewOptionsArg, listViewPresentationArg, listViewQueryLayerArg, listViewSortArg, mergeActions, PLATFORM_DEFAULT_LIST_ACTIONS, normalizeActions, normalizeButtons, normalizeConditions, normalizeGantt, normalizePresentation, normalizeSorts, parseConditionOptions, presentationTypeArg, readArray, resolveFieldRef, buttonsRenderCompat, columnsRenderCompat, } from "./list-view-shapes.js";
14
+ import { assertListViewConfigureShape, decodeActionRow, decodeButtonRow, decodeConditionRow, decodeGantt, decodePresentation, decodeSortRow, listViewActionArg, listViewButtonArg, listViewConditionArg, listViewGanttArg, listViewMultiTableHeaderArg, listViewOptionsArg, listViewPresentationArg, listViewQueryLayerArg, listViewSortArg, mergeActions, PLATFORM_DEFAULT_LIST_ACTIONS, normalizeActions, normalizeButtons, normalizeConditions, normalizeGantt, normalizePresentation, normalizeSorts, parseConditionOptions, presentationTypeArg, queryLayerSummary, readArray, resolveFieldRef, treeConditionKeysPresent, buttonsRenderCompat, columnsRenderCompat, } from "./list-view-shapes.js";
15
15
  // Ticket 53: every shape (enum/zod/encode/decode/lint) lives once in
16
16
  // ./list-view-shapes.ts and is re-exported for existing import paths.
17
17
  export { assertListViewConfigureShape } from "./list-view-shapes.js";
@@ -37,6 +37,59 @@ function sumTypeByCodeFromPresentation(model) {
37
37
  }
38
38
  return out;
39
39
  }
40
+ /**
41
+ * T14 最小安全网:CloudPivot 2.1.5 的 BizQueryModel 新增顶层
42
+ * `queryDataRangeRestriction`(`{clientType:"PC"|…, conditionGroup:[[{propertyCode,…}]]}`,
43
+ * 即「数据范围限制」)。平台 `saveBizQueryDetail` 是 **delete-on-omit**:
44
+ * 先按 clientType 删掉旧条、再加 incoming(launcher-2.1.5 ModelManagementFacadeImpl.java:2159-2161,242-243)
45
+ * ——请求里没带这个键 = 静默删除,且照样回 200。
46
+ *
47
+ * 因此读面/写后校验都需要一个**只含计数与客户端**的摘要(不回传全量条件:
48
+ * 体积大且条件里可能有业务敏感值)。raw 既可能是对象,也可能是 JSON 字符串
49
+ * (PowerShell ConvertFrom-Json 等中转会把对象摊平/还原成字符串,同
50
+ * flowWorkflowCodeFromActionConfig 的处理惯例)。
51
+ */
52
+ export function dataRangeRestrictionSummary(raw) {
53
+ let value = null;
54
+ if (typeof raw === "string") {
55
+ const text = raw.trim();
56
+ // 空串 = 平台侧没配(String 列的空值),等同缺席。
57
+ if (text === "")
58
+ return { present: false };
59
+ try {
60
+ const parsed = JSON.parse(text);
61
+ if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed))
62
+ value = parsed;
63
+ }
64
+ catch {
65
+ return { present: false };
66
+ }
67
+ }
68
+ else if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
69
+ value = raw;
70
+ }
71
+ if (value === null)
72
+ return { present: false };
73
+ // conditionGroup 是 List<List<…>>:外层是「条件组」,每组是一个条件数组。
74
+ // 单元素数组被中转摊平成对象的情形按 1 条计(只影响计数,不影响判定)。
75
+ let groupCount = 0;
76
+ let conditionCount = 0;
77
+ if (Array.isArray(value.conditionGroup)) {
78
+ groupCount = value.conditionGroup.length;
79
+ for (const group of value.conditionGroup) {
80
+ if (Array.isArray(group))
81
+ conditionCount += group.length;
82
+ else if (group !== null && typeof group === "object")
83
+ conditionCount += 1;
84
+ }
85
+ }
86
+ return {
87
+ present: true,
88
+ ...(typeof value.clientType === "string" && value.clientType.length > 0 ? { clientType: value.clientType } : {}),
89
+ groupCount,
90
+ conditionCount,
91
+ };
92
+ }
40
93
  function fieldOptions(options) {
41
94
  if (typeof options === "string") {
42
95
  try {
@@ -402,6 +455,20 @@ export function registerListViewLane(tools) {
402
455
  const conditions = readArray(model, "queryConditions")
403
456
  .map(decodeConditionRow)
404
457
  .sort((a, b) => String(a.propertyCode ?? "").localeCompare(String(b.propertyCode ?? "")));
458
+ // T14:2.1.5 的 queryDataRangeRestriction 不在精简面的任何既有投影里,
459
+ // 调用方无法验收它「还在」。键存在(非 undefined/null)才回摘要;8.6 没有
460
+ // 这个键 → 一个字节都不新增(键缺席 = 该版本族无此配置面)。full:true
461
+ // 已在上面原样回报文,保持不动。
462
+ const dataRangeRestriction = model.queryDataRangeRestriction !== undefined && model.queryDataRangeRestriction !== null
463
+ ? dataRangeRestrictionSummary(model.queryDataRangeRestriction)
464
+ : undefined;
465
+ // T22:2.1.5 的 queryLayer(含 displayType/treeLoadMode)不在这条精简面的任何
466
+ // 既有投影里,调用方无法验收「层级/树加载方式还是我配的那样」。只回摘要
467
+ // (code/layerType/displayType/treeLoadMode),不回全量层对象;空数组或 8.6
468
+ // 无该键时不新增任何字节。full:true 已原样回报文,保持不动。
469
+ const queryLayer = Array.isArray(model.queryLayer) && model.queryLayer.length > 0
470
+ ? queryLayerSummary(model.queryLayer)
471
+ : undefined;
405
472
  return {
406
473
  schemaCode: args.schemaCode,
407
474
  code,
@@ -468,6 +535,8 @@ export function registerListViewLane(tools) {
468
535
  return { buttons: decoded };
469
536
  })(),
470
537
  options: model.options !== undefined && model.options !== null ? parseConditionOptions(model.options) : null,
538
+ ...(dataRangeRestriction !== undefined ? { dataRangeRestriction } : {}),
539
+ ...(queryLayer !== undefined ? { queryLayer } : {}),
471
540
  // Round 16 (bench65 feedback): the query row's `published=false` is NOT
472
541
  // an "inactive view" signal — a list view has no draft/publish
473
542
  // lifecycle; this column is a design-time placeholder. The view is
@@ -688,8 +757,48 @@ export function registerListViewLane(tools) {
688
757
  const model = (got.data ?? {});
689
758
  if (!model.id)
690
759
  throw new WireError("business", `list view ${code} not found on ${args.schemaCode}`, 302025);
760
+ // T14:写前基线(2.1.5 才有的键;8.6 读到 undefined → present:false,后续
761
+ // 守卫与写后校验全部不触发,回执不多一个字节)。
762
+ const dataRangeBefore = dataRangeRestrictionSummary(model.queryDataRangeRestriction);
691
763
  const columns = Array.isArray(model.queryColumns) ? ([...model.queryColumns]) : [];
692
764
  const fieldRows = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: "true" } })).data);
765
+ // T22 写前保护(零副作用):conditions 是**整体替换**(下面的
766
+ // `body.queryConditions = normalizedConditions`),而 normalizeConditions 只投影
767
+ // 8.6 的固定键面。2.1.5 的树视图条件组三键(`BizQueryConditionModel.java:90,92,94`:
768
+ // treeLimitScopeType / treeLimitConditionGroup / treeDefaultConditionGroup)在基线里
769
+ // 存在、提交行却没带 → 平台照常 200 保存,但树过滤组被静默清掉。基线有、提交缺就拒;
770
+ // 调用方显式带齐则放行。没有任何 tree 键时(8.6 同样没有)零影响。
771
+ if (args.conditions !== undefined) {
772
+ const submittedByCode = new Map();
773
+ for (const row of args.conditions) {
774
+ const ref = String(row.propertyCode ?? "");
775
+ const resolved = (ref.length > 0 ? resolveFieldRef(fieldRows, ref)?.code : undefined) ?? ref;
776
+ if (!submittedByCode.has(resolved))
777
+ submittedByCode.set(resolved, row);
778
+ }
779
+ const lost = readArray(model, "queryConditions").flatMap((row) => {
780
+ const required = treeConditionKeysPresent(row);
781
+ if (required.length === 0)
782
+ return [];
783
+ const propertyCode = String(row.propertyCode ?? "");
784
+ const supplied = treeConditionKeysPresent(submittedByCode.get(propertyCode) ?? {});
785
+ const missing = required.filter((key) => !supplied.includes(key));
786
+ return missing.length > 0 ? [{ propertyCode, keys: missing }] : [];
787
+ });
788
+ if (lost.length > 0)
789
+ throw new ToolRefusalError({
790
+ status: "refused",
791
+ blocker: "listview-tree-conditions-would-be-lost",
792
+ schemaCode: args.schemaCode,
793
+ code,
794
+ lost,
795
+ nextAction: "把 treeLimitScopeType/treeLimitConditionGroup/treeDefaultConditionGroup 原样带进对应 propertyCode 的条件行(值照抄基线)后重试;本次不想改 conditions 就省略该参数;或用 omc call 的逃生口自行承担替换语义",
796
+ message: "conditions 是整体替换:本视图基线条件里的树过滤组会被静默清掉。" +
797
+ `受影响条件:${lost.map((entry) => `${entry.propertyCode}(${entry.keys.join("/")})`).join("、")}。` +
798
+ "2.1.5 的 BizQueryConditionModel.java:90,92,94 有 treeLimitScopeType/treeLimitConditionGroup/treeDefaultConditionGroup 三键," +
799
+ "提交行未原样带回即随整表替换丢失(平台仍回 200,树过滤组消失)。把这三键原样带进对应条件行,或本次不要改 conditions。",
800
+ });
801
+ }
693
802
  let sortKey = columns.reduce((max, c) => Math.max(max, Number(c.sortKey) || 0), 0);
694
803
  const added = [];
695
804
  const updated = [];
@@ -901,6 +1010,25 @@ export function registerListViewLane(tools) {
901
1010
  if (args.multiTableHeaderConfig !== undefined) {
902
1011
  body.multiTableHeaderConfig = encodeJsonColumn(args.multiTableHeaderConfig);
903
1012
  }
1013
+ // T14 写前守卫(零副作用):body 现在是 `{...model, queryColumns}`,正常路径
1014
+ // 天然带回该键。但平台是 delete-on-omit(launcher-2.1.5
1015
+ // ModelManagementFacadeImpl.java:2159-2161,242-243:先按 clientType 删旧条再
1016
+ // 加 incoming),任何将来「从 spec 构造 body / 用 header 起稿」的重构都会
1017
+ // 静默清空既有数据范围限制并回 200。基线有值而 body 缺键时直接拒。
1018
+ // 只对**非空**基线设防:平台对未配置/空组返回 {} 或空 conditionGroup 时,
1019
+ // 「丢了」本来也没有内容可丢,不应误报。
1020
+ if (dataRangeBefore.present && (dataRangeBefore.conditionCount ?? 0) > 0 && !Object.prototype.hasOwnProperty.call(body, "queryDataRangeRestriction"))
1021
+ throw new ToolRefusalError({
1022
+ status: "refused",
1023
+ blocker: "listview-datarange-echo-missing",
1024
+ schemaCode: args.schemaCode,
1025
+ code,
1026
+ dataRangeRestriction: dataRangeBefore,
1027
+ nextCommand: `omc call listview.get --args '${JSON.stringify({ schemaCode: args.schemaCode, code, full: true })}'`,
1028
+ message: "平台 saveBizQueryDetail 是 delete-on-omit(ModelManagementFacadeImpl.java:2159-2161,242-243):按 clientType 先删旧条再加 incoming," +
1029
+ "请求未带 queryDataRangeRestriction 会把既有数据范围限制静默删除且返回成功。" +
1030
+ "本视图当前已配置数据范围限制,写入 body 必须原样回传该键;先 listview.get --full 取证,再重试。",
1031
+ });
904
1032
  const performed = await wireCall(session, { path: ENDPOINTS.listQueryUpdate, method: "POST", body });
905
1033
  // BUG-11 (live, docker+source verified): the controller's /query/update
906
1034
  // forces publish=TRUE and the engine's updateBizQuery SKIPS the entity
@@ -1034,6 +1162,24 @@ export function registerListViewLane(tools) {
1034
1162
  if (afterModel.multiTableHeaderConfig !== undefined && afterModel.multiTableHeaderConfig !== null && afterModel.multiTableHeaderConfig !== "") {
1035
1163
  readback.multiTableHeaderConfig = parseConditionOptions(afterModel.multiTableHeaderConfig);
1036
1164
  }
1165
+ // T14 写后校验:写已发生,所以不用 ok/失败表达丢失,而是回一个状态字段。
1166
+ // 仅当基线本来就有数据范围限制时才校验(8.6 无此面 → 不加任何键)。
1167
+ if (dataRangeBefore.present && (dataRangeBefore.conditionCount ?? 0) > 0) {
1168
+ const dataRangeAfter = dataRangeRestrictionSummary(afterModel.queryDataRangeRestriction);
1169
+ const preserved = dataRangeAfter.present &&
1170
+ dataRangeAfter.clientType === dataRangeBefore.clientType &&
1171
+ dataRangeAfter.groupCount === dataRangeBefore.groupCount &&
1172
+ dataRangeAfter.conditionCount === dataRangeBefore.conditionCount;
1173
+ readback.dataRangeRestriction = preserved
1174
+ ? { status: "preserved", ...dataRangeAfter }
1175
+ : {
1176
+ // present 但计数/客户端变了 = 平台改写(coerced);整键不见了 = lost。
1177
+ status: dataRangeAfter.present ? "coerced" : "lost",
1178
+ before: dataRangeBefore,
1179
+ after: dataRangeAfter,
1180
+ message: "平台 delete-on-omit:请求未带 queryDataRangeRestriction(或平台改写)会把既有数据范围限制删掉/改形且返回成功(ModelManagementFacadeImpl.java:2159-2161,242-243)。写已发生,本字段是状态而非失败;用 listview.get --full 复核并到设计器重建数据范围限制。",
1181
+ };
1182
+ }
1037
1183
  return { performed: { errcode: performed.errcode }, readback };
1038
1184
  },
1039
1185
  preflight: assertListViewConfigureShape,
@@ -16,6 +16,7 @@ import { writeTool } from "../write.js";
16
16
  import { registerPackageTool } from "../package-tool.js";
17
17
  import { defineTool, ToolInputError, ToolRefusalError } from "../tool-types.js";
18
18
  import { wireCall, wireRows, WireError } from "../wire.js";
19
+ import { assertTreeSelectionOptions } from "../field-tree-options.js";
19
20
  import { readModelRecord } from "../model-record.js";
20
21
  import { MODEL_CREATE_BODY_DEFAULTS, MODEL_LANE_CONTRACT } from "./model-contract.js";
21
22
  import { flattenFolders } from "./folder.js";
@@ -1574,10 +1575,21 @@ export function registerModelLane(tools) {
1574
1575
  return failed;
1575
1576
  }
1576
1577
  const existingFields = new Map();
1578
+ // T19:发布门校验的是**草稿面** options。existingFields 会被 isPublish=true
1579
+ // 的行覆盖(后写胜),不能拿它做预检——否则「草稿树非法、已发布面仍是旧合法值」
1580
+ // 会漏检,直到平台整单 300004。草稿面单独留一份。
1581
+ const draftFields = new Map();
1577
1582
  const mergedFieldCodes = [];
1583
+ // T19:本次新建字段的线上 options(create 后已落库,发布门预检也需要
1584
+ // 覆盖它们——existingFields 只含调用开始时读到的行)。
1585
+ const createdOptions = new Map();
1578
1586
  for (const isPublish of ["false", "true"]) {
1579
- for (const row of wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.code, isPublish } })).data))
1580
- existingFields.set(String(row.code ?? row.propertyCode ?? ""), row);
1587
+ for (const row of wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.code, isPublish } })).data)) {
1588
+ const code = String(row.code ?? row.propertyCode ?? "");
1589
+ existingFields.set(code, row);
1590
+ if (isPublish === "false")
1591
+ draftFields.set(code, row);
1592
+ }
1581
1593
  }
1582
1594
  const configureTargetVersion = session.detectedVersion();
1583
1595
  for (const entry of entries) {
@@ -1599,6 +1611,7 @@ export function registerModelLane(tools) {
1599
1611
  }
1600
1612
  const prepared = prepareFieldChange(input);
1601
1613
  const performed = await wireCall(session, { path: ENDPOINTS.fieldCreate, method: "POST", body: fieldChangeWireBody(input, prepared) });
1614
+ createdOptions.set(entry.code, prepared.options);
1602
1615
  const after = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.code, isPublish: "false" } })).data);
1603
1616
  if (!after.some((row) => String(row.code ?? row.propertyCode) === entry.code))
1604
1617
  throw new ToolRefusalError({ status: "refused", blocker: "field-create-readback-failed", message: `field.create 后权威草稿字段未读到 ${entry.code}` });
@@ -1609,6 +1622,14 @@ export function registerModelLane(tools) {
1609
1622
  return failed;
1610
1623
  }
1611
1624
  failed = await run(results.length, "field.publish", async () => {
1625
+ // T19(2026-11-24):2.1.5+ 树形自定义下拉发布门(custom + tree 节点的
1626
+ // code/value 非空、code 全树唯一)。平台在模型级发布时整单拒(外层
1627
+ // 300004 + 逐项 301013),所以在 POST 前先用草稿行做同样预检。复用启动
1628
+ // 时读到的 existingFields,并补上本次新建字段的 options。
1629
+ await assertTreeSelectionOptions(session, args.code, [
1630
+ ...draftFields.values(),
1631
+ ...[...createdOptions].map(([code, options]) => ({ code, options })),
1632
+ ]);
1612
1633
  const performed = await wireCall(session, { path: ENDPOINTS.fieldPublish, method: "POST", body: { bizSchemaCode: args.code, sendMessage: false } });
1613
1634
  const after = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.code, isPublish: "true" } })).data);
1614
1635
  const publishedCodes = new Set(after.map((row) => String(row.code ?? row.propertyCode)));
@@ -123,13 +123,29 @@ export function registerOnlineJsLane(tools) {
123
123
  return { schemaCode: args.schemaCode, sheetCode, present: false, hint: "表单不存在——先 form.draft/表单创建" };
124
124
  const draft = readCustomScriptSource(typeof sheet.draftHtmlJson === "string" ? sheet.draftHtmlJson : null);
125
125
  const published = readCustomScriptSource(typeof sheet.publishedHtmlJson === "string" ? sheet.publishedHtmlJson : null);
126
+ // 平台设计器保存时会把 IIFE 之外的代码拆到 beforeCustomScript/afterCustomScript
127
+ // (8.6 的 javaScriptSplit 就有,2.1.5 只是抽成 helper)。只回 customScript 会让
128
+ // 调用方以为 helper 代码丢了。这里如实列出非空的两段(空段不占字节)。
129
+ const segmentsOf = (raw) => {
130
+ const elements = parseLayoutElements(raw);
131
+ const pick = (id) => {
132
+ const element = elements.find((candidate) => candidate.id === id);
133
+ const text = typeof element?.innerHTML === "string" ? element.innerHTML : "";
134
+ return text.trim() === "" ? undefined : { bytes: Buffer.byteLength(text, "utf8"), sha256: createHash("sha256").update(text, "utf8").digest("hex"), script: text };
135
+ };
136
+ const before = pick("beforeCustomScript");
137
+ const after = pick("afterCustomScript");
138
+ return before === undefined && after === undefined ? undefined : { ...(before !== undefined ? { before } : {}), ...(after !== undefined ? { after } : {}) };
139
+ };
140
+ const draftSegments = segmentsOf(typeof sheet.draftHtmlJson === "string" ? sheet.draftHtmlJson : null);
141
+ const publishedSegments = segmentsOf(typeof sheet.publishedHtmlJson === "string" ? sheet.publishedHtmlJson : null);
126
142
  return {
127
143
  schemaCode: args.schemaCode,
128
144
  sheetCode,
129
145
  present: draft.present || published.present,
130
146
  sheetPublished: sheet.published === true,
131
- draft: { ...draft, scriptSha256: draft.sha256 || undefined, ...(draft.script === null ? { note: "草稿无 customScript 脚本(尚未 compose 或被清空)" } : {}) },
132
- published: { ...published, scriptSha256: published.sha256 || undefined, ...(published.script === null ? { note: "发布面无 customScript 脚本" } : {}) },
147
+ draft: { ...draft, scriptSha256: draft.sha256 || undefined, ...(draft.script === null ? { note: "草稿无 customScript 脚本(尚未 compose 或被清空)" } : {}), ...(draftSegments !== undefined ? { segments: draftSegments } : {}) },
148
+ published: { ...published, scriptSha256: published.sha256 || undefined, ...(published.script === null ? { note: "发布面无 customScript 脚本" } : {}), ...(publishedSegments !== undefined ? { segments: publishedSegments } : {}) },
133
149
  ...(draft.sha256 !== "" && published.sha256 !== ""
134
150
  ? { draftPublishedInSync: draft.sha256 === published.sha256 }
135
151
  : {}),
@@ -47,7 +47,7 @@ function permissionGroupRows(data) {
47
47
  // 8.7(AI-Platform v1.1.23-dsj.8)的 DataPermissionType 新增 MY_BRANCH_OFFICE=7「同机构」;
48
48
  // 未知值原样回传(不降级成 1/6),否则读回后回写会把新权限改坏。
49
49
  const permissionType = (v) => ({ 1: "全部可见", 2: "本部门", 3: "仅自己", 4: "自定义", 5: "角色管理范围", 6: "均不可见", 7: "同机构" }[String(v)] ?? (v == null ? null : v));
50
- const PERMISSION_UPDATE_FUNCTION = "/api/api/system/permission/update_function";
50
+ const PERMISSION_UPDATE_FUNCTION = ENDPOINTS.permissionUpdateFunction;
51
51
  /**
52
52
  * r96(2026-11-24,真机会话 40 次 `perm.auth` 摩擦):动作码此前只活在源码里,
53
53
  * `describe perm.auth` 只显示 `grants: array<object>`,非法码只回「未知视图动作码:xxx」
@@ -54,6 +54,13 @@ export const ONLINE_JS_EVENTS = new Set([
54
54
  "onActionDone",
55
55
  "onPrintFormDataHandle",
56
56
  "onPrintWorkflowLogDataHandle",
57
+ // 平台 `LifecycleHookNames`(cloudpivot-form runtime/lifecycle.ts,8.6 与 2.1.5 一致)
58
+ // 还有这 4 个:新建 / 编辑 / 模型级校验 / 保存。此前白名单只有 8 个,写这些事件
59
+ // 会被本工具判「未知事件」——用户侧表现就是「在线 JS 语法变了、写不进去」。
60
+ "onAdd",
61
+ "onEdit",
62
+ "onModelValidate",
63
+ "onSubmit",
57
64
  ]);
58
65
  const WRAPPER_OPEN = /\(\s*function\s*\(\s*form\s*\)/;
59
66
  const WRAPPER_CLOSE = "})";
@@ -24,6 +24,7 @@ const submitCrossFieldCheck = Object.freeze({
24
24
  `**右值必须用结构值** {"valueType":"currentModel","value":"<字段code>"}——裸 {字段code} 右值平台存储成功但**永不解析、规则静默不生效**(2026-09-24 真机;工具 fail-closed 拦截 + 读回 shapeWarning 标记存量雷)。`,
25
25
  "**prompt 存纯文本**:门户对顶层 options.prompt 原样显示,URL 编码会弹 %E5.. 乱码(真机 equipmaint_workorder 案)。",
26
26
  "单字段正则/长度类校验用 checkType:1/4/5(REGEX/MAX_LENGTH/EMPTY_ROW)+ 对应 options 键。",
27
+ "**`options.validateHiddenProperties`(2.1.5 隐藏字段也参与校验)**:可选数组;update 未显式给时自动保留当前行值,显式 `[]` 才清空。",
27
28
  ],
28
29
  priorToolReferences: [{ tool: "field.list", args: { environment, schemaCode: "<模型>" }, purpose: "确认两个比较字段已发布" }],
29
30
  dryRun: { supported: true, command: `omc call datarule.create --env ${environment} --dry-run --args '<recipe.args>'`, notes: "dry-run 过协议校验(裸右值/prompt 编码当场拒),零 wire" },
@@ -62,7 +63,7 @@ const dataruleCalcRule = Object.freeze({
62
63
  "`options.shortTextStitch` 的值必须是 JSON 对象字符串,**三个键都要给全**:`{\"formula\":\"{a}+{b}\",\"editorText\":\"<field-omc0001>a</field-omc0001>+<field-omc0001>b</field-omc0001>\",\"editorMark\":\"field-omc0001\"}`。",
63
64
  "**`editorText`/`editorMark` 不是可选**(真机 2026-10-08):设计器「计算规则」弹窗按 `editorText` 里的 `<field-{editorMark}>…</field-{editorMark}>` 标记解析;`editorMark:\"\"` 或 `editorText` 不带标记 → 弹窗**标红/判非法**。约定:`editorMark` = `field-<任意一致 id>`(如 `field-omc0001`),`editorText` 里**每个字段引用**都包成 `<field-omc0001>ref</field-omc0001>`——**标签内只放裸 token,不要带花括号**(前端 `parseFormulaFromEditorText` 会自己给标签内容套上 `{}`:写 `<field-omc0001>{a}</field-omc0001>` 会被反解成 `{{a}}` ≠ `formula`,该规则显示「已失效」;真机 2026-10-08 SCM 沙盒已复现,OMC 现已 fail closed `datarule-stitch-editor-mismatch`)。",
64
65
  "**`formula` 引用语法**(真机 production + 设计器核验):同类字段裸 `{字段code}`(`{a}+{b}`);**子表列用 `{子表字段code.子列code}` 点号全限定**(`{prop_repair_detail.qty}*{prop_repair_detail.unit_price}`);子表聚合 `SUM({子表.子列})`;支持 `IF/CASE/VALUE/AND/=、字符串字面量、运算符空格`。",
65
- "**公式函数面 64 个(2026-11-12 运行版反编译 `BizDataRuleFacadeImpl`,别再靠猜)**:日期族 `NOW()`(当前时刻 DATE)/`TODAY()`(当天 TEXT,**不能当 DATE 参数**)/`DATE()/ADDDAY/ADDHOUR/ADDMINUTE/ADDMONTH/ADDYEAR/DATEDIF/DAY/MONTH/YEAR/HOUR/MINUTE/SECOND/QUARTER/WEEKDAY/WEEKNUM`;数学族 `SUM/SUMIF/AVG/COUNT/COUNTIF/MAX/MIN/LARGE/SMALL/ROUND/VALUE/ABS/CEILING/FLOOR/INTDOWN/INTUP/FIXED/LOG/MOD/PI/POWER/RAND/SIN/COS/SQRT`;文本族 `CONTAINS/STARTSWITH/SEARCH/LEFT/RIGHT/LEN/LOWER/UPPER/TRIM/SUBSTITUTE/REPLACE/SUBSTRING/STRING/TEXT/UNION/GETADDRESS/GETUNITNAME/UPPERMONEY`;逻辑 `ISNULL/IF/CASE`。",
66
+ "**公式函数面 65 个(2026-11-12 反编译 `BizDataRuleFacadeImpl`;2.1.5 新增 `PRODUCT` 累乘,8.6 无)**:日期族 `NOW()`(当前时刻 DATE)/`TODAY()`(当天 TEXT,**不能当 DATE 参数**)/`DATE()/ADDDAY/ADDHOUR/ADDMINUTE/ADDMONTH/ADDYEAR/DATEDIF/DAY/MONTH/YEAR/HOUR/MINUTE/SECOND/QUARTER/WEEKDAY/WEEKNUM`;数学族 `SUM/SUMIF/AVG/COUNT/COUNTIF/MAX/MIN/LARGE/SMALL/ROUND/VALUE/ABS/CEILING/FLOOR/INTDOWN/INTUP/FIXED/LOG/MOD/PI/POWER/RAND/SIN/COS/SQRT/PRODUCT`;文本族 `CONTAINS/STARTSWITH/SEARCH/LEFT/RIGHT/LEN/LOWER/UPPER/TRIM/SUBSTITUTE/REPLACE/SUBSTRING/STRING/TEXT/UNION/GETADDRESS/GETUNITNAME/UPPERMONEY`;逻辑 `ISNULL/IF/CASE`。",
66
67
  "**日期运算写法**:加法**日期在前、增量在后、负数为减**——`ADDHOUR(NOW(), 4)`(当前 +4 小时)、`ADDDAY(某日期, -3)`(前 3 天)、`ADDMONTH(开始, 6)`;`DATEDIF(结束时间, 开始时间, 单位)` 回数值,单位区分大小写 `y/M/d/h/m/s`(**`M`=月、`m`=分钟**,易错)。例:时限「重大 4 小时」= `ADDHOUR(NOW(), 4)`;「还剩几小时」= `DATEDIF(承诺截止, NOW(), \"h\")`。",
67
68
  "**计算由门户前端执行、API 不回填**:写测试数据带预算值;正确性由门户表单填表确认。设计器「计算规则」弹窗读取 `bizdatarule/list`(本规则即写入该表)。",
68
69
  ],
@@ -308,7 +308,7 @@ const formulaAggregationCrossModel = Object.freeze({
308
308
  conditionalRequirements: [
309
309
  "**DYNAMIC 条件的两个 code 分属两侧,写反了就静默 0**:`propertyCode` = **来源模型**的字段(这里是 r17_c.nm),`currentPropertyCode` = **目标模型**的字段(这里是 r17_d.srcNo)。语义 = 「来源行的 nm 等于本目标行的 srcNo」。",
310
310
  "`propertyType`/`currentPropertyType` 是 BizPropertyType 的**整数码**(0=SHORT_TEXT 2=NUMERICAL 9=WORK_SHEET…),`operatorType` 是 OperatorType 的**整数码**(1=EQ 6=ITEQ 9=IS_NULL 10=IS_NOT_NULL…)。写名字会被 ObjectMapperUtils 抛 json processing exception 并掩码成 305003;工具会自动转码。",
311
- "`calculateType` 是**字符串**(SUM/COUNT/COUNTIF/SUMIF/AVG/MAX/MIN/**LARGE/SMALL/UNION**),不是枚举 code。r18b 真机三种特殊算法:LARGE/SMALL **必须带位置参数** `LARGE({<来源>.<列>},2)`(缺 k → 平台 NumberFormatException → 目标写入 50000);**UNION 是文本拼接**,顶层 `resultType` 必须是 0/LONG_TEXT=1(写 2 会 50000,读回是去重串,如单号本身);SUM/AVG/MAX/MIN/COUNT 用 resultType:2。",
311
+ "`calculateType` 是**字符串**(SUM/COUNT/COUNTIF/SUMIF/AVG/MAX/MIN/**LARGE/SMALL/UNION/PRODUCT**),不是枚举 code。2.1.5 新增 `PRODUCT`(累乘;8.6 无)。r18b 真机三种特殊算法:LARGE/SMALL **必须带位置参数** `LARGE({<来源>.<列>},2)`(缺 k → 平台 NumberFormatException → 目标写入 50000);**UNION 是文本拼接**,顶层 `resultType` 必须是 0/LONG_TEXT=1(写 2 会 50000,读回是去重串,如单号本身);SUM/AVG/MAX/MIN/COUNT 用 resultType:2。",
312
312
  "发布后平台会**自动生成一条 t100 CALCULATE_RULE 镜像行**(h_biz_data_rule,propertyCode=字段 code),它是回算触发的前置条件,别手动删。",
313
313
  "**回算时机(r17b 2026-10-26 真机完整行为图谱)**:① 目标行**自己 submit** 时镜像规则一定算(最可靠,不依赖事件);② 来源行 submit/update/delete 触发 `RollUpEventListener`→`FormulaPropertySupport` 事件回算——FIXED+DYNAMIC 混用、多组 OR、COUNTIF/MAX、子表行级条件(propertyCode 带 `.`)都验证过,DELETE 也会回算;③ ⚠️ 事件回算**只在目标模型发布后的几分钟内可靠**,之后静默停止(源端数据变了目标字段不更新、无报错)——重新 `field.publish --force` 目标模型即可恢复。定时巡检/对账场景务必重发或依赖目标行写入路径。",
314
314
  ],
@@ -11,7 +11,7 @@ const SHAPE_GATES = Object.freeze({
11
11
  },
12
12
  "submit-date-shape": {
13
13
  whatWentWrong: "日期字段的值形状不对(毫秒时间戳会落库 NULL)",
14
- correctShape: "字符串且匹配字段 format:日期字段 \"YYYY-MM-DD\";日期时间字段 ISO8601 带时区 \"2026-01-01T10:00:00+08:00\"",
14
+ correctShape: "字符串且逐位匹配字段 format:日期 \"YYYY-MM-DD\";日期时间 \"YYYY-MM-DD HH:mm:ss\"(DATE 支持到秒,不支持毫秒/ISO8601 带时区)",
15
15
  recipeCommand: { tool: "data.submit", recipe: "plain-data-submit" },
16
16
  doNot: "不要传毫秒数(如 1790000000000)——不报错但落库 NULL,读回才发现",
17
17
  },
package/dist/wire.js CHANGED
@@ -11,6 +11,7 @@ export class WireError extends Error {
11
11
  errcode;
12
12
  diagnostic;
13
13
  hint;
14
+ payload;
14
15
  constructor(kind, message, errcode,
15
16
  /** Round-2 T-06: diagnosable context for malformed/http-status envelopes. */
16
17
  diagnostic,
@@ -19,13 +20,56 @@ export class WireError extends Error {
19
20
  * (例如「同一 schemaCode 去掉 filter 能读 → 是过滤形状问题」)。信封照实
20
21
  * 保留 wire-business/errcode,只多一行可执行线索。
21
22
  */
22
- hint) {
23
+ hint,
24
+ /**
25
+ * T20(2.1.5 发布门,2026-11-24):业务错误信封的 `data` 原样保留。平台把
26
+ * 「树形自定义选项非法」整个模型发布失败包成外层 300004「数据模型不存在!」
27
+ * + data 里的逐项 301013「…数据项的选项设置有误」;只留 errmsg 会把真正
28
+ * 原因丢掉,调用方永远查不到「模型不存在」(BizSchemaCheckServiceImpl
29
+ * :60-66 抛 BIZ_SCHEMA_MODEL_NOT_EXIST,明细在 data)。
30
+ */
31
+ payload) {
23
32
  super(message);
24
33
  this.kind = kind;
25
34
  this.errcode = errcode;
26
35
  this.diagnostic = diagnostic;
27
36
  this.hint = hint;
37
+ this.payload = payload;
38
+ }
39
+ }
40
+ /**
41
+ * 从 300004 业务错误的 `data` 里提取「选项设置有误」明细(T20 兜底)。
42
+ *
43
+ * 兼容两种载荷:裸数组 `[{statusCode:"301013",errMsg:"…"}]` 或
44
+ * `{data:[...]}`。命中条件与平台一致:`statusCode === 301013`(数字/字符串)
45
+ * 或 `errMsg`/`errContent` 含「选项设置有误」。返回去重后的消息;没有明细时
46
+ * 返回 `[]`,调用方据此保持原有 300004 解释(不要把无关 300004 抢成选项问题)。
47
+ */
48
+ export function optionPublishMessages(payload) {
49
+ const items = Array.isArray(payload)
50
+ ? payload
51
+ : payload !== null && typeof payload === "object" && Array.isArray(payload.data)
52
+ ? (payload.data)
53
+ : undefined;
54
+ if (!items)
55
+ return [];
56
+ const messages = [];
57
+ for (const item of items) {
58
+ if (item === null || typeof item !== "object" || Array.isArray(item))
59
+ continue;
60
+ const row = item;
61
+ const status = row.statusCode;
62
+ const statusHit = status !== undefined && status !== null && String(status).trim() === "301013";
63
+ const message = typeof row.errMsg === "string" ? row.errMsg : typeof row.errContent === "string" ? row.errContent : undefined;
64
+ const textHit = message !== undefined && message.includes("选项设置有误");
65
+ if (!statusHit && !textHit)
66
+ continue;
67
+ if (message === undefined || !message.trim())
68
+ continue;
69
+ if (!messages.includes(message))
70
+ messages.push(message);
28
71
  }
72
+ return messages;
29
73
  }
30
74
  /** Redact common secret keys and truncate — the malformed-envelope preview must be safe to log. */
31
75
  function redactedBodyPreview(body, limit = 200) {
@@ -232,7 +276,7 @@ export async function wireCall(session, call) {
232
276
  throw new WireError("malformed-envelope", `envelope for ${call.path} (${call.method ?? "GET"}) has no numeric errcode; body: ${redactedBodyPreview(body)}`, undefined, { httpStatus: response.status, bodyPreview: redactedBodyPreview(body) });
233
277
  if (envelope.errcode !== 0) {
234
278
  const message = typeof envelope.errmsg === "string" ? envelope.errmsg : "CloudPivot rejected the request";
235
- throw new WireError("business", `errcode ${envelope.errcode} for ${call.path}: ${message}`, envelope.errcode);
279
+ throw new WireError("business", `errcode ${envelope.errcode} for ${call.path}: ${message}`, envelope.errcode, undefined, undefined, envelope.data);
236
280
  }
237
281
  const result = {
238
282
  path: call.path,
package/dist/write.js CHANGED
@@ -26,7 +26,7 @@ import { validateBusinessCode } from "./code-rules.js";
26
26
  import { hardLayoutViolations, validateFormLayout } from "./form-layout.js";
27
27
  import { prepareRuleGraph, validateRuleNodeGraph } from "./lanes/rule-graph.js";
28
28
  import { assertRuleNamePlatformAcceptable } from "./rule-support.js";
29
- import { WireError } from "./wire.js";
29
+ import { WireError, optionPublishMessages } from "./wire.js";
30
30
  /**
31
31
  * The shared governed write pipeline and the low-level write registration
32
32
  * factory every lane adapter uses.
@@ -141,6 +141,25 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
141
141
  if (error instanceof WireError) {
142
142
  // F3: rule-node runtime failures are masked by the platform as 300004.
143
143
  if (error.errcode === 300004) {
144
+ // T20(2026-11-24):2.1.5 的树形自定义下拉发布门把「选项非法」包成
145
+ // 外层 300004「数据模型不存在!」+ data 里的逐项 301013「…数据项的
146
+ // 选项设置有误」(BizSchemaCheckServiceImpl :60-66)。payload 命中时
147
+ // 必须比业务规则运行时异常的解释更优先,否则用户会去查 rulelog。
148
+ const platformMessages = optionPublishMessages(error.payload);
149
+ if (platformMessages.length > 0) {
150
+ return {
151
+ status: "refused",
152
+ blocker: "field-options-publish-invalid",
153
+ errcode: 300004,
154
+ platformMessages,
155
+ message: `平台在发布时拒绝了字段选项(外层 300004「数据模型不存在!」只是外壳,明细 301013):${platformMessages.join(";")}。` +
156
+ "这是 2.1.5+ 的树形自定义下拉发布门,不是模型缺失或业务规则运行时异常:optionsSet.optionsType=\"custom\" + optionStructure=\"tree\" 时," +
157
+ "每个节点的 code(平台内部叫选项编码,口语叫 key)与 value(显示值)必须非空,且 code 全树唯一(RadioOptionsModel.validateCustomTreeOptions,launcher-2.1.5 .../bizmodel/RadioOptionsModel.java:130-142)。" +
158
+ "8.6/8.7 不查;平铺自定义/字典/业务模型下拉也不查。",
159
+ nextCommand: "omc call field.list --args '{\"schemaCode\":\"<model>\",\"published\":false}'",
160
+ nextAction: "核对报错字段的 optionsSet.custom 树,用 field.update 补非空 code/value;不需要层级就把 optionStructure 改成 \"flat\" 后重发",
161
+ };
162
+ }
144
163
  return {
145
164
  status: "refused",
146
165
  blocker: `wire-${error.kind}`,
@@ -194,6 +213,64 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
194
213
  nextAction: "先 data.load/form.get 读回该记录(隐藏字段有真值),把缺失字段补进 payload 再提交;不要靠删字段绕过——规则仍会命中",
195
214
  nextCommand: "omc call data.load --args '{\"schemaCode\":\"<model>\",\"bizObjectId\":\"<id>\"}'",
196
215
  };
216
+ // 2.1.5 起新增的「格式/长度/维护锁」错误码(8.6 这些场景回 10005/40000/50000,
217
+ // 没有可读码)。不改变判定,只把码翻成人话 + 下一步。
218
+ if (error.errcode === 309056 || error.errcode === 309057) {
219
+ const kind = error.errcode === 309056 ? "名称" : "code";
220
+ return {
221
+ status: "refused",
222
+ blocker: `wire-${error.kind}`,
223
+ errcode: error.errcode,
224
+ "platform-version": "2.1.5+",
225
+ message: `${error.message}——2.1.5 起平台统一用 309056/309057 校验${kind}格式(8.6 是零散的 10005):名称 1–60 字符且不能以空格开头;code 必须字母开头、≤60、只含 A-Za-z0-9_。`,
226
+ nextAction: `按上述规则改 ${kind}后重试;不要靠换中文/特殊字符绕过`,
227
+ };
228
+ }
229
+ if (error.errcode === 601016 || error.errcode === 601019)
230
+ return {
231
+ status: "refused",
232
+ blocker: "schema-maintenance-locked",
233
+ errcode: error.errcode,
234
+ "platform-version": "2.1.5+",
235
+ message: `${error.message}——模型正在做表结构变更/层级路径维护(2.1.5 新增 601016/601019),期间不接收写入;这是**暂时锁**,不是参数错。`,
236
+ nextAction: "等维护结束(或联系平台管理员确认迁移任务)后重试同一请求;不要改参数硬重试",
237
+ };
238
+ if (error.errcode === 700000)
239
+ return {
240
+ status: "refused",
241
+ blocker: "value-length-out-of-bounds",
242
+ errcode: 700000,
243
+ "platform-version": "2.1.5+",
244
+ message: `${error.message}——列长度溢出首次被翻译成 700000(8.6 只会回 40000/50000);先核对该字段的库列长度或 options 限制。`,
245
+ nextAction: "缩短该字段值,或改字段长度(field.update → field.publish)后重试",
246
+ };
247
+ if (error.errcode === 550038)
248
+ return {
249
+ status: "refused",
250
+ blocker: "inherited-rule-readonly",
251
+ errcode: 550038,
252
+ "platform-version": "2.1.5+",
253
+ message: `${error.message}——该业务规则继承自父级(2.1.5 新增继承机制),不能直接改/删/发布/启停。`,
254
+ nextAction: "到父级模型改规则,或用 rule.references 确认继承来源后再决定",
255
+ };
256
+ if (error.errcode === 401085)
257
+ return {
258
+ status: "refused",
259
+ blocker: "workflow-activity-name-invalid",
260
+ errcode: 401085,
261
+ "platform-version": "2.1.5+",
262
+ message: `${error.message}——2.1.5 的流程发布新增节点名校验:非空且 ≤80 字符单位(中文按 2 计),ERROR 级会让 publish 整体不发布。`,
263
+ nextAction: "workflow.get_draft 读回 activities[].name,缩短超长/补齐空名后重新 publish",
264
+ };
265
+ if (error.errcode === 480000)
266
+ return {
267
+ status: "refused",
268
+ blocker: "current-task-suspended",
269
+ errcode: 480000,
270
+ "platform-version": "2.1.5+",
271
+ message: `${error.message}——当前任务被挂起(2.1.5 新增:前置/串行任务未完成),不是提交参数错。`,
272
+ nextAction: "workitem.list 看同一实例的前置任务状态;前置完成后重试提交",
273
+ };
197
274
  // 子表超限:8.6 = 36102,8.7/2.1.5 = 36104(同义)。
198
275
  if (error.errcode === 36102 || error.errcode === 36104)
199
276
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.99",
3
+ "version": "0.6.100",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "commander": "14.0.3",
59
- "omc-core": "0.6.99",
59
+ "omc-core": "0.6.100",
60
60
  "proper-lockfile": "4.1.2",
61
61
  "write-file-atomic": "6.0.0",
62
62
  "zod": "^3.23.8",
@@ -74,6 +74,6 @@
74
74
  "directory": "packages/omc-cli"
75
75
  },
76
76
  "optionalDependencies": {
77
- "@stalfh233/omc-fake-platform": "0.6.99"
77
+ "@stalfh233/omc-fake-platform": "0.6.100"
78
78
  }
79
79
  }