@stalfh233/omc-cli 0.6.36 → 0.6.37

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.
@@ -168,7 +168,7 @@ export const FIELD_LANE_CONTRACT = Object.freeze({
168
168
  description: describeTool("Create a draft field on a model (bizproperty/create).", [
169
169
  "Field type must be one of the live-accepted families; nested child tables and OCR/ELECTRONIC_SIGN are out of coverage.",
170
170
  `Reserved/system codes are refused (code_reserved): ${[...RESERVED_CODES].join(", ")} — pick a business code (e.g. owner → taskOwner).`,
171
- "The relation field family name is `WORK_SHEET` (there is no RELATED_SINGLE/RELATION): pass `propertyType:\"WORK_SHEET\"` + `relativeCode:<schemaCode>` + `options:{schemaCode,queryCode,displayField,displayFieldType,mappings}`; `mappings` is a JSON *string* (empty string when there is no mapping).",
171
+ "**mapping 类型兼容**(三层口径 r52):①拦截依据=设计器 `filterCondition`:长文本←长文本/短文本(单向);短文本/下拉/单选←同族;复选框/下拉多选←同族;**其余必须同型**。违反→`mapping-type-incompatible`。②设计器只过滤下拉:保存不复核、平台 `checkOptions` 缺 WORK_SHEET、运行期直接 put——绕过设计器可写违规组合。③后果:50000 或**静默损坏**(`→LOGICAL` 恒 false、`NUMERICAL→DATE` 丢 null、文本→人员/关联=悬空 id、多值→单选串进单值列、`→COMMENT/OCR/SIGN/RELEVANCE_DATA` 不落库)。④映射只在关联单选建记录时生效;`data.save/submit` 不跑映射。",
172
172
  "For single/multi-select pass `choices` (e.g. [\"A\",\"B\",\"C\"]) or `options.optionsSet` with optionsType custom/dictionary/businessModel; dictionary uses checkedDictionary/checkedDictionaryCode, businessModel uses schemaCode/sheetDataItem.",
173
173
  "For a relation pass `relativeCode` and `options` (schemaCode/displayField/...). `searchFormula` and `conditions` are JSON strings for the relation data restriction/query conditions.",
174
174
  "For a relation display field the tool writes the field-row top-level `relativePropertyCode` = options.displayField (the runtime reads THAT key, not options.displayField — QueryRuntimeController.java:1214-1226) and defaults options.displayFieldType:0 + displayFieldFormat:\"\".",
@@ -179,7 +179,7 @@ export const FIELD_LANE_CONTRACT = Object.freeze({
179
179
  "field.update": Object.freeze({
180
180
  scope: "create publish readback",
181
181
  description: describeTool("Update an existing field (bizproperty/update) — merges `options` (and optional `choices`/`relativeCode`) onto the current draft/published record.", [
182
- "**不切换 propertyType**:field.update 传 propertyType 会被静默忽略(errcode 0 但类型不变,r6 实证 2026-10-10)——已发布字段改类型只能 field.delete + field.create 重建(含关联 mappings 的同类型对齐场景:人员单选只能映射给人员单选)。choices 只对文本单选族(RADIO/DROPDOWN_BOX 等)合法,传给其它类型会被出门校验拒。",
182
+ "**不切换 propertyType**:field.update 传 propertyType 会被静默忽略(errcode 0 但类型不变,r6 实证 2026-10-10)——已发布字段改类型只能 field.delete + field.create 重建(mapping 类型兼容见 field.create 的 mappings 说明)。choices 只对文本单选族(RADIO/DROPDOWN_BOX 等)合法,传给其它类型会被出门校验拒。",
183
183
  "字典-backed 可用 `syncDictionary:true` 重填 useDictionariesData;readback 带 face:\"draft\"。",
184
184
  "Use it to add relation `mappings` (source/target carry-through) or change field options. **关联填充映射的事实源是字段行 `options.mappings`**(真机 2026-10-14 中冶实证:改表单控件属性里的 mappings 会被平台按字段重算覆盖、回读不生效)。改映射的正确链:`field.update` 按完整 options 提交(只改 mappings,其余键 queryCode/displayField/schemaCode/conditions… 原值保留)→ `field.publish` → 已发布表单重派生一次:`form.draft`(**rebuild:false**,保留现有布局与已挂在线JS)重存 → `form.publish` → 回读核对。**不要用 field.update 的 cascadeRepublish 刷已带自定义布局/在线JS 的表单**——它会 rebuild 脚手架,可能动到现有自定义布局(rebuild:false 手动链才安全)。",
185
185
  "A relation's display field is the field-row top-level `relativePropertyCode` (options.displayField is mirrored but not what the runtime reads); the tool rewrites it when you pass a new displayField.",
@@ -45,6 +45,45 @@ function relationTypeOf(row) {
45
45
  const value = Number(row.type ?? row.propertyType);
46
46
  return Number.isInteger(value) ? value : undefined;
47
47
  }
48
+ /**
49
+ * 设计器的可映射类型表(r52 前端逆向,admin/js/17170.93392489.js `filterCondition`):
50
+ *
51
+ * LongText ← LongText | ShortText (单向:长文本可收短文本,反之不行)
52
+ * ShortText/Dropdown/Radio ← 同族三选一
53
+ * Checkbox/DropdownMulti ← 同族二选一
54
+ * 其它(数值/日期/时间/逻辑/人员/部门/关联/地址/附件/子表…)← 必须完全相同
55
+ *
56
+ * 这是「用户手点得出来」的口径。平台后端零校验,所以绕过设计器(API/导入/复制)
57
+ * 能写出设计器不允许的组合——那些组合要么运行期 50000,要么静默丢值。
58
+ */
59
+ const MAPPING_TEXT_FAMILY = new Set([
60
+ FIELD_PROPERTY_TYPES.SHORT_TEXT,
61
+ FIELD_PROPERTY_TYPES.DROPDOWN_BOX,
62
+ FIELD_PROPERTY_TYPES.RADIO,
63
+ ]);
64
+ const MAPPING_MULTI_FAMILY = new Set([
65
+ FIELD_PROPERTY_TYPES.CHECKBOX,
66
+ FIELD_PROPERTY_TYPES.DROPDOWN_MULTI_BOX,
67
+ ]);
68
+ function mappingCompatibleSourceTypes(targetType) {
69
+ if (targetType === FIELD_PROPERTY_TYPES.LONG_TEXT)
70
+ return [FIELD_PROPERTY_TYPES.LONG_TEXT, FIELD_PROPERTY_TYPES.SHORT_TEXT];
71
+ if (MAPPING_TEXT_FAMILY.has(targetType))
72
+ return [...MAPPING_TEXT_FAMILY];
73
+ if (MAPPING_MULTI_FAMILY.has(targetType))
74
+ return [...MAPPING_MULTI_FAMILY];
75
+ return [targetType];
76
+ }
77
+ function mappingTypesCompatible(targetType, sourceType) {
78
+ return mappingCompatibleSourceTypes(targetType).includes(sourceType);
79
+ }
80
+ /** propertyType 数字 → 枚举名(拒绝信息用;未知返回数字串)。 */
81
+ function propertyTypeName(type) {
82
+ for (const [name, value] of Object.entries(FIELD_PROPERTY_TYPES))
83
+ if (value === type)
84
+ return name;
85
+ return String(type);
86
+ }
48
87
  /** Semantic relation gate: the designer only offers published business fields. */
49
88
  async function assertRelationOptionsFields(session, schemaCode, propertyType, relativeCode, options) {
50
89
  const type = typeof propertyType === "number" ? propertyType : FIELD_PROPERTY_TYPES[String(propertyType ?? "")];
@@ -94,6 +133,15 @@ async function assertRelationOptionsFields(session, schemaCode, propertyType, re
94
133
  if (!sourceCandidates.includes(source) || !targetCandidates.includes(mappedTarget)) {
95
134
  throw new ToolRefusalError({ status: "refused", blocker: "relation-mapping-field-not-found", schemaCode, relationTarget: target, mappingIndex: index, source, targetField: mappedTarget, sourceCandidates, targetCandidates, message: `关联映射第 ${index + 1} 行字段不存在:source=${source || "(空)"}(目标模型候选:${sourceCandidates.join("、") || "(无)"}),target=${mappedTarget || "(空)"}(本模型候选:${targetCandidates.join("、") || "(无)"})。请使用发布面业务字段 code。` });
96
135
  }
136
+ // r52:类型兼容门。设计器 filterCondition(admin/js/17170.93392489.js)是产品承认的
137
+ // 可映射不变量,但它只活在下拉框里——保存、导入、field.create 全都绕过;平台后端
138
+ // checkOptions 的 if 链缺 WORK_SHEET 分支,运行期 assignChildData 直接 put 零转换。
139
+ // 所以错配要么运行期 50000,要么静默变 null/false/悬空 id。这里按设计器口径拦。
140
+ const sourceType = targetFields.find((row) => row.code === source)?.type;
141
+ const targetType = ownFields.find((row) => row.code === mappedTarget)?.type;
142
+ if (sourceType !== undefined && targetType !== undefined && !mappingTypesCompatible(targetType, sourceType)) {
143
+ throw new ToolRefusalError({ status: "refused", blocker: "mapping-type-incompatible", schemaCode, relationTarget: target, mappingIndex: index, source, sourceType: propertyTypeName(sourceType), targetField: mappedTarget, targetType: propertyTypeName(targetType), allowedSourceTypes: mappingCompatibleSourceTypes(targetType).map(propertyTypeName), message: `关联映射第 ${index + 1} 行类型不兼容:${propertyTypeName(sourceType)} → ${propertyTypeName(targetType)}。设计器只允许 ${propertyTypeName(targetType)} 接收 ${mappingCompatibleSourceTypes(targetType).map(propertyTypeName).join("/")}。平台后端不校验这条,硬写会在运行期 50000 或静默丢值(真机 r52 2026-11-10)。` });
144
+ }
97
145
  }
98
146
  }
99
147
  async function readFieldRollback(session, args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.36",
3
+ "version": "0.6.37",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "commander": "14.0.3",
58
- "omc-core": "0.6.36",
58
+ "omc-core": "0.6.37",
59
59
  "proper-lockfile": "4.1.2",
60
60
  "write-file-atomic": "6.0.0",
61
61
  "zod": "^3.23.8",
@@ -73,6 +73,6 @@
73
73
  "directory": "packages/omc-cli"
74
74
  },
75
75
  "optionalDependencies": {
76
- "@stalfh233/omc-fake-platform": "0.6.36"
76
+ "@stalfh233/omc-fake-platform": "0.6.37"
77
77
  }
78
78
  }