@stalfh233/omc-cli 0.6.98 → 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;