@stalfh233/omc-cli 0.8.8 → 0.8.10

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.
@@ -349,6 +349,37 @@ function fieldRollbackSpec(toolName) {
349
349
  function parseFieldOptionsForReadback(options) {
350
350
  return decodeJsonColumn(options, JSON_COLUMN_PASSTHROUGH);
351
351
  }
352
+ /**
353
+ * 探针 D F9(0.8.9):字段行 `options.mappings` 存在 = 关联填充配置。
354
+ * 平台存储形态是 options.mappings 的 **JSON 字符串**(`WorkSheetPropertyMapping[]`,
355
+ * 见 test/field-relation-mapping-sources.test.ts 的证据表),但 API 写面也可能
356
+ * 直接回数组——两种都认。
357
+ */
358
+ function hasRelationMappings(options) {
359
+ if (options === null || typeof options !== "object")
360
+ return false;
361
+ const raw = options.mappings;
362
+ if (Array.isArray(raw))
363
+ return raw.length > 0;
364
+ if (typeof raw !== "string")
365
+ return false;
366
+ try {
367
+ const parsed = JSON.parse(raw);
368
+ return Array.isArray(parsed) && parsed.length > 0;
369
+ }
370
+ catch {
371
+ return false;
372
+ }
373
+ }
374
+ /**
375
+ * 字段配置面的映射运行期说明(探针 D F9):映射配置正确 ≠ REST 写会回填。
376
+ * 后端证据:CLI `data.save` 打 `/api/runtime/form/save`
377
+ * (FormRuntimeController.java:806-832 → saveBizSheet:932-977 → saveBizObject),
378
+ * 该控制器全文没有 mappingList;`BizFormMappingFacadeImpl.mappingList`
379
+ * 只挂在 OpenAPI v2/v3 写面(BaseController.java:985-1001)与门户表单链。
380
+ * 因此「配置对不对」看 options.mappings,「值会不会回填」看写入面走哪条路。
381
+ */
382
+ const FIELD_MAPPING_RUNTIME_NOTE = "映射只在门户选值时回填:CLI data.save(/api/runtime/form/save)不跑 options.mappings,快照列需调用方自填;配置正确性以字段行 options.mappings 为准。";
352
383
  /**
353
384
  * `name_i18n` is a JSON locale map. When every locale value equals the display
354
385
  * `name` there is no translation to convey, so echoing the map on every field of
@@ -571,7 +602,7 @@ export function registerFieldLane(tools) {
571
602
  lane: FIELD_LANE,
572
603
  scope: FIELD_TOOLS["field.list"].scope,
573
604
  description: FIELD_TOOLS["field.list"].description,
574
- inputSchema: { environment: environmentArg, schemaCode: z.string(), published: z.boolean().default(false), code: z.string().optional(), fields: z.array(z.string()).optional(), full: z.boolean().optional().describe("行内联完整 options/subSchema;默认清单面只有 code/name/type/typeName(+conditions 信号/shapeWarning),验证 options 用 code/fields 选择器或 full:true;平台读面带回 propertyEmpty 时一并输出(不回则省略,不塞 false)"), all: z.boolean().optional().describe("默认只返业务字段(过滤 SYSTEM_FIELD_CODES 的 13 个平台字段:id/name/sequenceNo/createdTime/creater/sequenceStatus/…);true 连系统字段一起返"), capability: capabilityArg },
605
+ inputSchema: { environment: environmentArg, schemaCode: z.string(), published: z.boolean().default(false), code: z.string().optional(), fields: z.array(z.string()).optional(), full: z.boolean().optional().describe("行内联完整 options/subSchema(含子表原始 subSchema);默认面只有 code/name/type(+conditions/shapeWarning),验证 options 用 code/fields 或 full:true;propertyEmpty 平台带回才输出(不回省略,不塞 false)"), all: z.boolean().optional().describe("默认只返业务字段(滤掉 13 个系统字段:id/name/sequenceNo/createdTime/…);true 连系统字段一起返"), capability: capabilityArg },
575
606
  handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
576
607
  const rows = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: args.published ? "true" : "false" } })).data);
577
608
  // r61 a-F9(r60a-F9):draft 面此前不报字段的发布态,行级缺 published 键
@@ -649,6 +680,11 @@ export function registerFieldLane(tools) {
649
680
  // restores the previous full list (uses the SAME SYSTEM_FIELD_CODES set the
650
681
  // list-view/form scaffolds already filter with).
651
682
  const visible = args.all === true ? selected : selected.filter((field) => !isSystemFieldCode(field.code));
683
+ // 探针 D F9:只有真的把 options 送到调用方时(code/fields 选择器或 full)才附带
684
+ // 映射运行期说明——默认清单面不内联 options,在那里提映射是噪音。
685
+ const mappingRuntimeNote = detailed && visible.some((field) => hasRelationMappings(field.options))
686
+ ? FIELD_MAPPING_RUNTIME_NOTE
687
+ : undefined;
652
688
  const projected = detailed
653
689
  ? visible
654
690
  : visible.map((field) => {
@@ -707,6 +743,7 @@ export function registerFieldLane(tools) {
707
743
  }),
708
744
  ...(selector.length > 0 ? { selected: selector } : {}),
709
745
  ...(args.all !== true ? { businessOnly: true } : {}),
746
+ ...(mappingRuntimeNote !== undefined ? { mappingRuntimeNote } : {}),
710
747
  fields: projected,
711
748
  // 券商 issue 1.4(2026-10-27):默认面空清单曾被误读成「模型没有字段」。
712
749
  // 空清单要自己解释三种可能,别让 agent 二次试错;发布面(published:true)
@@ -796,12 +833,13 @@ export function registerFieldLane(tools) {
796
833
  ...fieldListTool,
797
834
  name: "field.get",
798
835
  search: { intents: ["读一个字段", "单个字段", "字段详情", "这个字段配置", "字段 options", "查字段详情"] },
799
- description: "单字段读(field.list 的 code 选择器)。返回该字段 options/subSchema 等详情。",
836
+ description: "单字段读(= field.list + code)。options/subSchema 传 full:true。",
800
837
  inputSchema: {
801
838
  environment: environmentArg,
802
839
  schemaCode: z.string(),
803
840
  code: z.string(),
804
841
  published: z.boolean().default(false),
842
+ full: z.boolean().optional().describe("同 field.list.full:完整 options/subSchema(含子表原始 subSchema)"),
805
843
  capability: capabilityArg,
806
844
  },
807
845
  });
@@ -1875,6 +1913,13 @@ function relationMappingsEmptyWarnings(publishedRows) {
1875
1913
  if (type !== FIELD_PROPERTY_TYPES.WORK_SHEET)
1876
1914
  return false;
1877
1915
  const options = optionsObjectOf(row.options);
1916
+ // 普通关联本来就不需要副本列:`mappings` 键缺席是**合法常态**,不是空配置。
1917
+ // 平台证据:BizFormJsonResolveServiceImpl.getRelationMappingByCode 对空/缺
1918
+ // mappings 直接回 null(无映射即合法,无报错),DataModelInitUtils.disposeOptions
1919
+ // 也只在键存在时搬运 mappings。只有调用方**显式声明了 mappings 键却留空**
1920
+ // ("" / "[]" / [] / null)才是配置错误——那会在设计器里显示「已设置」但无映射行。
1921
+ if (!Object.prototype.hasOwnProperty.call(options, "mappings"))
1922
+ return false;
1878
1923
  const mappings = options.mappings;
1879
1924
  if (mappings === undefined || mappings === null)
1880
1925
  return true;
@@ -1024,6 +1024,28 @@ export const PLATFORM_DEFAULT_LIST_ACTIONS = Object.freeze([
1024
1024
  { actionCode: "import_attachment", queryActionType: "IMPORT_ATTACHMENT" },
1025
1025
  { actionCode: "export_attachment", queryActionType: "EXPORT_ATTACHMENT" },
1026
1026
  ]);
1027
+ /**
1028
+ * Actions the platform INJECTS on the query/get READ face (not stored). Evidence:
1029
+ * 8.6.26 `BizQueryController.dealHistoryDataOfButton` — called from the
1030
+ * query/get path at :385; qr_code :488, batch_print :500, batch_update :514,
1031
+ * import_attachment :547, export_attachment :555, batch_submit :567
1032
+ * (`decompiled-engine/.../web/api/controller/app/BizQueryController.java`; the
1033
+ * launcher-8.6.26 copy is :452/:543/:555/:568/:601/:609/:621).
1034
+ *
1035
+ * Consequence (F14, 0.8.9 probe D): `listview.configure {actions:[],replaceActions:true}`
1036
+ * removes the STORED/flow/custom actions (add/delete/import/…) but the read face
1037
+ * still lists these six, so a receipt that only echoes `actions` looks like the
1038
+ * replace did nothing. Readback therefore reports them separately as
1039
+ * `platformDefaultActions`, never as proof that the caller's list survived.
1040
+ */
1041
+ export const PLATFORM_INJECTED_READ_ACTIONS = Object.freeze([
1042
+ "qr_code",
1043
+ "batch_print",
1044
+ "batch_update",
1045
+ "import_attachment",
1046
+ "export_attachment",
1047
+ "batch_submit",
1048
+ ]);
1027
1049
  /**
1028
1050
  * Merge caller actions into a base set by actionCode (existing rows keep their
1029
1051
  * platform fields, caller fields win) and append the rest. Live 2026-09-17:
@@ -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, diffTreeConditionKeys, LISTVIEW_TREE_CONDITION_KEYS, 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, treeConditionValueEqual, buttonsRenderCompat, columnsRenderCompat, } from "./list-view-shapes.js";
14
+ import { assertListViewConfigureShape, decodeActionRow, decodeButtonRow, decodeConditionRow, decodeGantt, decodePresentation, decodeSortRow, diffTreeConditionKeys, LISTVIEW_TREE_CONDITION_KEYS, listViewActionArg, listViewButtonArg, listViewConditionArg, listViewGanttArg, listViewMultiTableHeaderArg, listViewOptionsArg, listViewPresentationArg, listViewQueryLayerArg, listViewSortArg, mergeActions, PLATFORM_DEFAULT_LIST_ACTIONS, PLATFORM_INJECTED_READ_ACTIONS, normalizeActions, normalizeButtons, normalizeConditions, normalizeGantt, normalizePresentation, normalizeSorts, parseConditionOptions, presentationTypeArg, queryLayerSummary, readArray, resolveFieldRef, treeConditionKeysPresent, treeConditionValueEqual, 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";
@@ -692,7 +692,14 @@ export function registerListViewLane(tools) {
692
692
  // byte-compare. Columns project to the authorable identity (sortKey/id
693
693
  // are re-minted by every configure). Actions are therefore OUT of the
694
694
  // rollback snapshot (and out of the restore) by design.
695
- const columns = (Array.isArray(model.queryColumns) ? model.queryColumns : []).map((column) => ({ propertyCode: column.propertyCode, name: column.name, visible: column.visible }));
695
+ // 0.8.10(探针 E / round17):系统列(name/creater/createdTime/sequenceNo…)
696
+ // 与动作同属平台托管面:默认视图由平台种下、每次 configure 重铸 sortKey/id,
697
+ // 且回滚恢复它们需要把它们当 fieldCodes 提交(会与业务字段混淆)。回滚快照
698
+ // 因此只保留**业务列**;恢复时 replaceColumns 只重建业务列,系统列由平台
699
+ // 按缺省行为处理。口径与 queryActions 出快照一致。
700
+ const columns = (Array.isArray(model.queryColumns) ? model.queryColumns : [])
701
+ .filter((column) => !SYSTEM_FIELD_CODES.has(String(column.propertyCode ?? "")))
702
+ .map((column) => ({ propertyCode: column.propertyCode, name: column.name, visible: column.visible }));
696
703
  return { ...model, queryColumns: columns, queryActions: undefined };
697
704
  },
698
705
  inverse: ({ before, args }) => {
@@ -1177,6 +1184,23 @@ export function registerListViewLane(tools) {
1177
1184
  .map(decodeConditionRow)
1178
1185
  .sort((a, b) => String(a.propertyCode ?? "").localeCompare(String(b.propertyCode ?? "")));
1179
1186
  const readback = { code, added, updated, columns: afterCols, sorts, conditions };
1187
+ // F2(0.8.10 探针 E):平台在建视图时就给默认视图种了 4 个系统列
1188
+ // name/creater/createdTime/sequenceNo(BizQueryServiceImpl.createDefaultBizQuery
1189
+ // :209-226),增量 configure(未传 replaceColumns/hideDefaultSystemFields)会
1190
+ // 把它们原样保留——真机 4 列请求回读 8 列,调用方会以为 fieldCodes 写错了。
1191
+ // 只报告不改变写入语义;权威列集合 = 调用方 fieldCodes + 平台既有列。
1192
+ if (args.replaceColumns !== true && args.hideDefaultSystemFields !== true) {
1193
+ const requestedCodes = new Set(args.fieldCodes.map((ref) => resolveFieldRef(fieldRows, ref)?.code ?? ref));
1194
+ const systemColumnsAdded = [
1195
+ ...new Set(afterCols
1196
+ .map((column) => String(column.propertyCode ?? ""))
1197
+ .filter((columnCode) => columnCode.length > 0 && SYSTEM_FIELD_CODES.has(columnCode) && !requestedCodes.has(columnCode))),
1198
+ ];
1199
+ if (systemColumnsAdded.length > 0) {
1200
+ readback.systemColumnsAdded = systemColumnsAdded;
1201
+ readback.systemColumnsNote = `平台额外保留系统列 ${systemColumnsAdded.join("、")};要精确 ${requestedCodes.size} 列请同时传 replaceColumns:true + hideDefaultSystemFields:true(系统列与业务列一视同仁,想保留哪个就写进 fieldCodes)`;
1202
+ }
1203
+ }
1180
1204
  // r35(2026-10-31 真机):视图固定条件读回正确,但 `data.list --queryCode <视图>`
1181
1205
  // 不应用该过滤(4 条未过滤返回)——视图条件的运行时过滤语义未取证(门户 vs
1182
1206
  // REST queryCode),coverage 已声明 "filtering … not probed"。前置声明省 3 轮排查。
@@ -1242,9 +1266,44 @@ export function registerListViewLane(tools) {
1242
1266
  }
1243
1267
  readback.columnsRenderCompat = columnsRenderCompat(readArray(afterModel, "queryColumns"));
1244
1268
  if (args.actions !== undefined) {
1245
- readback.actions = readArray(afterModel, "queryActions")
1269
+ const afterActions = readArray(afterModel, "queryActions")
1246
1270
  .map(decodeActionRow)
1247
1271
  .sort((a, b) => Number(a.sortKey ?? 0) - Number(b.sortKey ?? 0));
1272
+ readback.actions = afterActions;
1273
+ // F14(0.8.9 探针 D)/ F8(0.8.10 探针 E):actions:[] + replaceActions:true
1274
+ // 之后 `actions` 仍列 6 条平台注入动作(BizQueryController.dealHistoryDataOfButton
1275
+ // :482-575 在 query/get 读面强制补齐 qr_code/batch_print/batch_update/
1276
+ // import_attachment/export_attachment/batch_submit),使用者会怀疑 replace
1277
+ // 没生效。区分三层:平台真值 actions 原样保留;本次被清掉的(写入前权威
1278
+ // 读回集减去回读集)进 removedActionCodes;回读里由平台注入且不是调用方
1279
+ // 显式提交的 code 进 platformDefaultActions。**只要按权威全集替换且传了
1280
+ // actions(含空数组)就必给 platformDefaultActions + actionsNote**——0.8.9
1281
+ // 只在两个差集非空时写 note,差集同时为空就静默,探针把它读成「replace
1282
+ // 没生效」。差集为空时 note 明说「本次没有移除非默认动作」,不伪装。
1283
+ if (args.replaceActions === true) {
1284
+ const afterCodes = new Set(afterActions.map((action) => String(action.actionCode ?? "")).filter(Boolean));
1285
+ const submittedCodes = new Set(args.actions.map((action) => String(action.actionCode ?? "")).filter(Boolean));
1286
+ const platformDefaultActions = [
1287
+ ...new Set(afterActions
1288
+ .map((action) => String(action.actionCode ?? ""))
1289
+ .filter((code) => PLATFORM_INJECTED_READ_ACTIONS.includes(code) && !submittedCodes.has(code))),
1290
+ ];
1291
+ const removedActionCodes = [
1292
+ ...new Set(readArray(model, "queryActions")
1293
+ .map((action) => String(action.actionCode ?? ""))
1294
+ .filter((code) => code.length > 0 && !afterCodes.has(code) && !submittedCodes.has(code))),
1295
+ ];
1296
+ if (removedActionCodes.length > 0)
1297
+ readback.removedActionCodes = removedActionCodes;
1298
+ readback.platformDefaultActions = platformDefaultActions;
1299
+ readback.actionsNote =
1300
+ (removedActionCodes.length > 0
1301
+ ? `本次移除 ${removedActionCodes.join("、")}(权威读回差集);`
1302
+ : "本次没有移除非默认动作(权威读回差集为空);") +
1303
+ (platformDefaultActions.length > 0
1304
+ ? `流程/自定义动作已清空;剩余为平台默认动作(${platformDefaultActions.join("、")},query/get 注入,不是 replaceActions 未生效)。`
1305
+ : "流程/自定义动作已清空;回读里没有平台注入的默认动作(剩余动作均来自本次提交或平台保留),不是 replaceActions 未生效。");
1306
+ }
1248
1307
  }
1249
1308
  if (afterModel.queryPresentation && typeof afterModel.queryPresentation === "object") {
1250
1309
  readback.presentation = decodePresentation(afterModel.queryPresentation);
@@ -113,12 +113,21 @@ export async function inboundModelReferences(session, targets, treeRows, options
113
113
  left.via.localeCompare(right.via) ||
114
114
  (left.childTable?.code ?? "").localeCompare(right.childTable?.code ?? ""));
115
115
  }
116
+ /**
117
+ * `omc model-purge --unbind-references --apply` — the ONE command that executes
118
+ * the same `field.delete → field.publish` unlink steps and then lets
119
+ * model.delete cascade (0.8.9 F7; `UNBIND_STEP_TOOLS` in model-purge.ts is the
120
+ * allow-list). Shared here so the refusal and the purge receipt cannot drift.
121
+ */
122
+ export function modelPurgeUnbindCommand(schemaCode, options = {}) {
123
+ return `omc model-purge --code ${schemaCode} --unbind-references${options.purgeInstances === true ? " --purge-instances" : ""} --apply`;
124
+ }
116
125
  /**
117
126
  * Build the refusal payload shared by the three delete entry points
118
127
  * (model.delete dry-run, model.delete, model.deleteMany). The message names the
119
128
  * real platform cause and the exact commands that remove the reference.
120
129
  */
121
- export function inboundReferenceRefusal(target, references) {
130
+ export function inboundReferenceRefusal(target, references, options = {}) {
122
131
  const referencingModels = [];
123
132
  for (const reference of references) {
124
133
  const existing = referencingModels.find((model) => model.schemaCode === reference.schemaCode);
@@ -145,6 +154,9 @@ export function inboundReferenceRefusal(target, references) {
145
154
  step("model.delete", { schemaCode: target });
146
155
  const selfReferences = references.filter((reference) => reference.selfReference);
147
156
  const externalReferences = references.filter((reference) => !reference.selfReference);
157
+ // F6(0.8.10):自引用才走「一条命令删净」;普通兄弟模型引用的 nextCommand
158
+ // 仍是 deletionSteps[0](既有路径不变)。
159
+ const selfPurgeCommand = selfReferences.length > 0 ? options.selfReferencePurgeCommand : undefined;
148
160
  const selfText = selfReferences.map((reference) => `${reference.childTable.code}.${reference.fields.map((field) => field.code).join("/")}`);
149
161
  const externalText = [...new Set(externalReferences.map((reference) => reference.schemaCode))];
150
162
  const parts = [];
@@ -160,12 +172,16 @@ export function inboundReferenceRefusal(target, references) {
160
172
  inboundReferences: [...references],
161
173
  deletionOrder: [...new Set([...references.map((reference) => reference.schemaCode), target])],
162
174
  deletionSteps: steps,
163
- nextCommand: steps[0]?.command ?? `omc call model.delete --args '${JSON.stringify({ schemaCode: target })}'`,
164
- nextAction: selfText.length > 0
165
- ? "按 deletionSteps 依赖倒序逐条执行:先 field.delete 删掉指向自身的子表关联列(及其它引用列),再 field.publish 发布所属模型,最后 model.delete(本工具已零写入拒绝,不会启动平台删除任务)"
166
- : "按 deletionSteps 依赖倒序执行:先删引用方模型的关联字段(或整体删掉引用方模型),再删本模型",
175
+ nextCommand: selfPurgeCommand ?? steps[0]?.command ?? `omc call model.delete --args '${JSON.stringify({ schemaCode: target })}'`,
176
+ nextAction: selfPurgeCommand !== undefined
177
+ ? "一条命令删净(破坏性):nextCommand 会先按 deletionSteps 删除指向自身的子表关联列(及其它引用列),再让 model.delete 级联删本模型;被删列数据不可恢复。逐条手工审计命令仍见 deletionSteps"
178
+ : selfText.length > 0
179
+ ? "按 deletionSteps 依赖倒序逐条执行:先 field.delete 删掉指向自身的子表关联列(及其它引用列),再 field.publish 发布所属模型,最后 model.delete(本工具已零写入拒绝,不会启动平台删除任务)"
180
+ : "按 deletionSteps 依赖倒序执行:先删引用方模型的关联字段(或整体删掉引用方模型),再删本模型",
167
181
  message: `${target} 不能删除(零写入拒绝,未调用 physically_delete)。${parts.join(" ")}` +
168
- `依赖倒序(逐条可执行命令见 deletionSteps / nextCommand):先删关联列 → 发布所属模型 → 再删本模型。` +
182
+ (selfPurgeCommand !== undefined
183
+ ? `一条命令删净:nextCommand = \`${selfPurgeCommand}\` —— 破坏性:它先删除上述引用列(子表关联列/兄弟模型关联列),再删除 ${target} 模型;被删列的数据不可恢复。逐条可审计的依赖倒序命令仍见 deletionSteps:先删关联列 → 发布所属模型 → 再删本模型。`
184
+ : `依赖倒序(逐条可执行命令见 deletionSteps / nextCommand):先删关联列 → 发布所属模型 → 再删本模型。`) +
169
185
  `不要在未拆引用时重试 model.delete——平台只会再次回 taskId 并把真因留在删除历史里(模型引用失败时 taskStatus=FAIL,子表自引用时任务永远 RUN)。`,
170
186
  };
171
187
  }
@@ -18,7 +18,7 @@ import { defineTool, ToolInputError, ToolRefusalError } from "../tool-types.js";
18
18
  import { wireCall, wireRows, WireError } from "../wire.js";
19
19
  import { assertTreeSelectionOptions } from "../field-tree-options.js";
20
20
  import { readModelRecord } from "../model-record.js";
21
- import { inboundModelReferences, inboundReferenceRefusal } from "./model-references.js";
21
+ import { inboundModelReferences, inboundReferenceRefusal, modelPurgeUnbindCommand } from "./model-references.js";
22
22
  import { MODEL_CREATE_BODY_DEFAULTS, MODEL_LANE_CONTRACT } from "./model-contract.js";
23
23
  import { flattenFolders } from "./folder.js";
24
24
  const MODEL_LANE = MODEL_LANE_CONTRACT.lane;
@@ -911,7 +911,7 @@ export function registerModelLane(tools) {
911
911
  // (dogfood R3). `mayBeReferenced` is the honest preview.
912
912
  wouldChange: !nodeResolved || references.length === 0,
913
913
  mayBeReferenced: references.length > 0,
914
- ...(references.length > 0 ? inboundReferenceRefusal(args.schemaCode, references) : {}),
914
+ ...(references.length > 0 ? inboundReferenceRefusal(args.schemaCode, references, { selfReferencePurgeCommand: modelPurgeUnbindCommand(args.schemaCode) }) : {}),
915
915
  referencingModels: referencing,
916
916
  inboundReferences: references,
917
917
  treeNodeResolved: nodeResolved,
@@ -1015,7 +1015,10 @@ export function registerModelLane(tools) {
1015
1015
  throw new ToolRefusalError({
1016
1016
  status: "refused",
1017
1017
  schemaCode: args.schemaCode,
1018
- ...inboundReferenceRefusal(args.schemaCode, inboundReferences),
1018
+ // F6(0.8.10):自引用子表列的三步手工链(0.8.7 起)仍保留在
1019
+ // deletionSteps,但 nextCommand 改为 0.8.9 就有的
1020
+ // `model-purge --unbind-references`——一条命令拆引用再删模型。
1021
+ ...inboundReferenceRefusal(args.schemaCode, inboundReferences, { selfReferencePurgeCommand: modelPurgeUnbindCommand(args.schemaCode) }),
1019
1022
  });
1020
1023
  }
1021
1024
  // Model deletion CASCADES the workflow template away but leaves
@@ -5,7 +5,7 @@ export { RUNTIME_DATA_WIRE, RUNTIME_QUERY_OPERATORS, ENGINE_OWNED_KEYS, SUBMIT_S
5
5
  import { RUNTIME_DATA_WIRE } from "omc-core/wire-facts";
6
6
  export function dataListDescription() {
7
7
  const wire = RUNTIME_DATA_WIRE;
8
- return `按简化过滤 DSL 查询业务对象(runtime/query/list);DSL 在 CLI 内翻译为平台 queryCondition(${wire.dslShape}),并按发布字段元数据为每个条件注入 propertyType(未知过滤字段将被拒绝,可用 rawCondition 逃生);响应行在 items[],业务字段在 items[].fields.<code>(不是 rows[],也不是 item 顶层——--jq 常用 items[].fields.sku);空模型返回空列表;列表只投影视图列:**已判定未投影的列会从 items[].fields 省略键**(items[].unprojected 点名;不是数据丢失——data.load 有值;显式选列在结果中全为 null 而发布字段元数据显示其存在时,readback 追加 projectionHint,先用 listview.configure 配置该模型的默认视图列或用 data.load 读单条权威值)。键缺席=字段不存在或该行已判定未投影(见 items[].unprojected);键在且值 null=真空值(未投影或真空值不再同形;nullSemantics 说明口径)。`;
8
+ return `按简化过滤 DSL 查询业务对象(runtime/query/list);DSL 在 CLI 内翻译为平台 queryCondition(${wire.dslShape}),并按发布字段元数据为每个条件注入 propertyType(未知过滤字段将被拒绝,可用 rawCondition 逃生;op 大小写不敏感);响应行在 items[],业务字段在 items[].fields.<code>(不是 rows[],也不是 item 顶层——--jq 常用 items[].fields.sku);空模型返回空列表;列表只投影视图列:**显式选列只能收窄、不能扩列**(视图外 code 进 columnsOutsideView,扩列用 data.load);**已判定未投影的列会从 items[].fields 省略键**(items[].unprojected 点名;不是数据丢失——data.load 有值;全 null 时 readback 追加 projectionHint,先 listview.configure 配置视图列或用 data.load 读单条)。键缺席=字段不存在或该行已判定未投影(见 items[].unprojected);键在且值 null=真空值(未投影或真空值不再同形;nullSemantics 说明口径)。`;
9
9
  }
10
10
  export function dataAggregateDescription() {
11
11
  return `临时计数与数值聚合(纯读)。count:runtime/query/list size:1 读 totalElements(服务端精确、不受 cap 影响;带 filter +1 field.list)。sum/avg/min/max:field 必填且已发布 propertyType=2(NUMERICAL);无 GET_LIST 改源时优先 /sum ALL_DATA(coverage.mode=server-aggregate,全量精确),否则/失败/键不符回退本地折叠(strategyFallback;size:200 翻页至 cap 1000,null 不进聚合、avg=sum/非 null 行数,nonNullCount=0→value:null)。complete 看 rowsScanned>=total,否则 missingCount+capNotice,绝不外推。groupBy 单列:count 值域可枚举(options/字典)→值域×count(V+3 wire),分桶并发窗口 4(限流退化 2,见 wire.concurrency),桶序稳定;按 count 降序取 topN(默认 10/上限 20),截断给 truncatedBuckets/bucketsTruncatedCount,null 单列 nullBucket;不可枚举或数值指标→本地扫描(coverage.mode=paged-local-scan/local-scan),数值桶 {key,count,nonNullCount,value} 按 value 降序、并列按 key,null 行进 nullBucket。filter.draftPolicy:count+groupBy 默认 includeDrafts:false 注入 sequenceStatus≠DRAFT;数值指标不默认排除;count 省略=平台默认(无条件含草稿、带条件排草稿);显式 false 强制排除。边界:临时问句用本工具;持久图表/看板用 report.chartdata,视图汇总列用 sumType,写时计算用 datarule type2。子表计数/求和用 child(主表 schemaCode + childSchemaCode/bizObjectId)。`;