@stalfh233/omc-cli 0.8.7 → 0.8.9

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.
@@ -233,30 +233,47 @@ export async function cmdModelScaffold(args) {
233
233
  steps.push({ step: "model.create", status: created.ok ? "ok" : "skipped", ...(modelExists ? { detail: { reason: "already-present" } } : {}) });
234
234
  // 2) 字段:逐条,duplicate 记 skipped,其余失败继续跑完(一次看全)。
235
235
  const failedFields = [];
236
+ // F3(0.8.8,探针 C):回执计数必须解释得通。字段写入分两条路:
237
+ // - 顶层字段:一次 field.create 写一个字段;
238
+ // - CHILD_TABLE:平台在同一次 save 里把子表字段 **和声明的子列** 一起写进去
239
+ // (BizPropertyFacadeImpl.save:87-89:isSubTable() → ensureBizObjectSchema
240
+ // (property.getCode()).addProperty(subProperties)),因此 attach 成功之后
241
+ // 逐条 child:field.create 回 already-present 的子列,是「本次刚建出来」,
242
+ // 不是「本次开始前就在」。旧回执把两者都算 skipped(真机 13/6/6)。
243
+ let createdFieldCount = 0;
244
+ let alreadyPresentFieldCount = 0;
245
+ let childColumnsCreated = 0;
236
246
  // Only the PARENT publishes. A CHILD_TABLE's columns live under the parent's
237
247
  // schema (the platform answers 300004 数据模型不存在 for
238
248
  // bizproperty/publish on a child schema), and the parent's publish already
239
249
  // verifies them — r12's "checked 21/20/21" counts include child columns.
240
250
  const publishTargets = new Set([code]);
241
251
  const createFields = async (schemaCode, list, label) => {
252
+ const counts = { created: 0, alreadyPresent: 0, failed: 0 };
242
253
  for (const field of list) {
243
254
  const outcome = await call("field.create", scaffoldFieldArgs(schemaCode, field));
244
255
  const message = String(outcome.result.message ?? "");
245
256
  if (outcome.ok) {
257
+ counts.created += 1;
246
258
  steps.push({ step: `${label}:field.create`, status: "ok", detail: { schemaCode, code: field.code } });
247
259
  }
248
260
  else if (/已存在|duplicate/i.test(message)) {
261
+ counts.alreadyPresent += 1;
249
262
  steps.push({ step: `${label}:field.create`, status: "skipped", detail: { schemaCode, code: field.code, reason: "already-present" } });
250
263
  }
251
264
  else {
265
+ counts.failed += 1;
252
266
  const reason = refusalText(outcome.result);
253
267
  failedFields.push({ code: field.code, message: reason });
254
268
  steps.push({ step: `${label}:field.create`, status: "failed", detail: { schemaCode, code: field.code, message: reason } });
255
269
  }
256
270
  }
271
+ return counts;
257
272
  };
258
273
  const topLevel = fields.filter((field) => scaffoldChildrenOf(field).length === 0);
259
- await createFields(code, topLevel, "model");
274
+ const topCounts = await createFields(code, topLevel, "model");
275
+ createdFieldCount += topCounts.created;
276
+ alreadyPresentFieldCount += topCounts.alreadyPresent;
260
277
  // 3) 子表:先挂子表字段(CHILD_TABLE 建在父模型上),再往子表 schema 建子列。
261
278
  for (const child of fields.filter((field) => scaffoldChildrenOf(field).length > 0)) {
262
279
  const parentOutcome = await call("field.create", scaffoldFieldArgs(code, { ...child }));
@@ -267,6 +284,7 @@ export async function cmdModelScaffold(args) {
267
284
  steps.push({ step: "child:attach", status: "failed", detail: { parent: code, child: child.code, message: reason } });
268
285
  continue;
269
286
  }
287
+ const children = scaffoldChildrenOf(child);
270
288
  steps.push({
271
289
  step: "child:attach",
272
290
  status: parentOutcome.ok ? "ok" : "skipped",
@@ -276,10 +294,26 @@ export async function cmdModelScaffold(args) {
276
294
  detail: {
277
295
  parent: code,
278
296
  child: child.code,
279
- note: parentOutcome.ok ? "子表字段与子列在这一次 attach 中一起建立;随后的 child:field.create 返回 already-present 是正常的" : "子表已存在(含子列),跳过",
297
+ note: parentOutcome.ok
298
+ ? "子表字段与子列在这一次 attach 中一起建立(BizPropertyFacadeImpl.save 的 isSubTable 分支);随后的 child:field.create 返回 already-present 是正常的"
299
+ : "子表已存在(含子列),跳过",
280
300
  },
281
301
  });
282
- await createFields(child.code, scaffoldChildrenOf(child), "child");
302
+ const childCounts = await createFields(child.code, children, "child");
303
+ if (parentOutcome.ok) {
304
+ // The attach created the CHILD_TABLE field AND every declared column in one
305
+ // platform save; a follow-up already-present is THIS RUN's write, so it
306
+ // belongs to created (never to skipped). A column whose follow-up create
307
+ // really failed is counted as failed, not created.
308
+ const built = Math.max(0, children.length - childCounts.failed);
309
+ createdFieldCount += 1 + built;
310
+ childColumnsCreated += built;
311
+ }
312
+ else {
313
+ createdFieldCount += childCounts.created;
314
+ alreadyPresentFieldCount += 1 + childCounts.alreadyPresent;
315
+ childColumnsCreated += childCounts.created;
316
+ }
283
317
  }
284
318
  // 4) 发布字段:半成品不发布(比不发布更难查)。
285
319
  const publishFieldSteps = [];
@@ -327,21 +361,29 @@ export async function cmdModelScaffold(args) {
327
361
  }
328
362
  const failedSteps = steps.filter((step) => step.status === "failed");
329
363
  const status = failedSteps.length > 0 ? "partial" : "ok";
330
- const fieldCount = fields.reduce((sum, field) => sum + 1 + scaffoldChildrenOf(field).length, 0);
331
- // NOTE: renamed locally to unblock tsx (parallel agent redeclared `created`
332
- // in this same scope). Keep semantics identical.
333
- const fieldsCreated = steps.filter((step) => step.step.endsWith("field.create") && step.status === "ok").length;
364
+ const childColumnCount = fields.reduce((sum, field) => sum + scaffoldChildrenOf(field).length, 0);
365
+ // `fieldCount` 是历史键,语义是「最终业务字段总数」(顶层声明 + 子列);
366
+ // 落库计数改用显式键名(F3,0.8.8):created/skipped 旧键保留为别名,但取值
367
+ // 以「本次真的写入」为准,不再把 attach 一起建出的子列记成 skipped。
368
+ const fieldCount = fields.length + childColumnCount;
334
369
  const publishActions = publishFieldSteps.filter((step) => step.status === "ok").length;
335
370
  // r28g F5:旧键 publishedFields 实际是「发布动作次数/目标 schema 数」(常=1),
336
371
  // 与 fieldCount 量级不符。保留旧键作兼容别名,同时给 publishActions + 字段计数。
337
- const fieldsPublishedEstimate = publishingBlocked || fieldPublishFailed ? 0 : fieldsCreated;
372
+ const fieldsPublishedEstimate = publishingBlocked || fieldPublishFailed ? 0 : createdFieldCount;
338
373
  const result = {
339
374
  status,
340
375
  model: code,
341
376
  name,
342
377
  fieldCount,
343
- created: fieldsCreated,
344
- skipped: steps.filter((step) => step.step.endsWith("field.create") && step.status === "skipped").length,
378
+ declaredFieldCount: fields.length,
379
+ createdFieldCount,
380
+ alreadyPresentFieldCount,
381
+ childColumnCount,
382
+ childColumnsCreated,
383
+ failedFieldCount: failedFields.length,
384
+ countsNote: "declaredFieldCount = 本次 --fields 声明的顶层字段数;createdFieldCount = 本次真正新写入的业务字段数(子表 attach 一并建出的子列计入 created,不记 skipped);alreadyPresentFieldCount = 本次开始前就已存在的字段数;fieldCount = 最终业务字段总数(declaredFieldCount + childColumnCount)。旧键 created/skipped 分别是 createdFieldCount/alreadyPresentFieldCount 的别名。",
385
+ created: createdFieldCount,
386
+ skipped: alreadyPresentFieldCount,
345
387
  failed: failedFields.length,
346
388
  publishActions,
347
389
  publishedFields: publishActions,
@@ -132,7 +132,7 @@ const numericPercent = Object.freeze({
132
132
  conditionalRequirements: [
133
133
  "`options.format` 必须是平台常量:百分比 `ratio`(20%)/`ratio.tenths`(20.0%)/`ratio.percentile`(20.00%),普通数字 `integer/tenths/percentile…`,货币 `RMB./dollar./euro./HK.` 前缀,`none`=裸值;`percentile` 是两位小数**不是**百分比。全表见 `omc contract field-families` 的 numericalFormat。",
134
134
  "`scale` 与小数据对齐(两位百分比 = `scale:2`+`ratio.percentile`);只写 scale 门户显示 `2,000.00` 普通数字。别名 percent/currency/¥ 由 CLI 归一为常量再落库;**别绕过 CLI 把 `percent` 写进字段行**——平台字面读不懂,门户跌回裸值(真机 r64b:format:\"percent\" → `0.5`)。",
135
- "生效:字段行 format 优先于表单控件 format,`field.publish` 后即生效(无需重建表单);列表是另一套列枚举,配完看一眼列表列。",
135
+ "生效:字段行 format 优先于表单控件,`field.publish` 即生效(无需重建表单);列表另是一套列枚举。",
136
136
  ],
137
137
  priorToolReferences: [
138
138
  { tool: "field.list", args: { environment, schemaCode: model, code: "completionRate", full: true }, purpose: "确认 code 未占用(默认清单面不回 options)" },
@@ -228,6 +228,55 @@ const childTable = Object.freeze({
228
228
  ],
229
229
  requiresEnvironmentDerivedIds: false,
230
230
  });
231
+ /**
232
+ * 探针 C F1(0.8.8):子表列取主表字段的快照填充。
233
+ *
234
+ * 平台执行面(file:line 见交付报告):mappings 的 `{source,target}` 就是
235
+ * `WorkSheetPropertyMapping.linkageCode/assignmentCode`(2.1.5 :45-54)——
236
+ * source=关联目标(本例=父模型)字段,target=本模型(子表)字段;
237
+ * `WorkSheetMappingServiceImpl` 只在表单映射链里 `assignChildData`,CLI
238
+ * `data.save` 走的 `/api/runtime/form/save` 不调用 mappingList(探针 C F4)。
239
+ *
240
+ * 探针 D(0.8.9):F2 发布必须发**父模型** code(子表 schema 发布 → 300004,
241
+ * `BizPropertyController.java:1138-1146` 用 `getAppFunctionByCodeIgnoreDelete`
242
+ * 取顶层 app function,子表没有该行);F9 映射正确性读面在 `field.get` 的
243
+ * `options.mappings` 与 `mappingRuntimeNote`,不必等到 `data.save`。
244
+ */
245
+ const childTableParentFieldFill = Object.freeze({
246
+ id: "child-map-fill",
247
+ title: "子表取主表",
248
+ aliases: ["取主表", "关联填充"],
249
+ status: "requires-prior-readback",
250
+ tool: "field.create",
251
+ args: {
252
+ environment,
253
+ schemaCode: "<model>_items",
254
+ code: "refParent",
255
+ name: "关联",
256
+ propertyType: "WORK_SHEET",
257
+ relativeCode: "<model>",
258
+ options: {
259
+ schemaCode: "<model>",
260
+ queryCode: "<model>",
261
+ displayField: "<父字段>",
262
+ mappings: [{ source: "<父字段>", target: "<快照列>" }],
263
+ },
264
+ },
265
+ preconditions: [
266
+ "子表 code 全局唯一;先建并发布快照标量列,再建关联列。",
267
+ "**发布用父模型 code**:`field.publish {\"schemaCode\":\"<父模型>\"}`——子表 code 会被拒(300004 → `field-publish-child-schema`);模型级一次发全部草稿字段,子表列随父模型发。",
268
+ ],
269
+ conditionalRequirements: [
270
+ "映射只在门户选值时回填:CLI data.save(/api/runtime/form/save)不跑 options.mappings,快照列需调用方自填;配置正确性以字段行 options.mappings 为准。",
271
+ "关联列必须带 relativeCode(=options.schemaCode=主模型);source=主模型字段、target=本子表列,均裸 code。",
272
+ "关联列不能是 CHILD_TABLE/OCR/ELECTRONIC_SIGN/MULT_WORK_SHEET/RELEVANCE_DATA/FORMULA。",
273
+ ],
274
+ priorToolReferences: [],
275
+ dryRun: { supported: true, command: `omc call field.create --env ${environment} --dry-run --args '<args>'`, notes: "" },
276
+ expectedReadback: { readback: { fieldPresent: true }, next: ["field.publish {schemaCode:<父模型>}", "field.get 读回 options.mappings"] },
277
+ refusalRecovery: [{ code: "relation-mapping-field-not-found", action: "source 用主模型字段、target 用本子表列,均裸 code" }],
278
+ requiresEnvironmentDerivedIds: true,
279
+ });
231
280
  const businessModelDropdown = Object.freeze({
232
281
  id: "business-model-dropdown",
233
282
  title: "用另一个模型的数据作下拉来源(businessModel)",
@@ -274,7 +323,7 @@ const businessModelDropdown = Object.freeze({
274
323
  });
275
324
  const formulaAggregationCrossModel = Object.freeze({
276
325
  id: "formula-aggregation-cross-model",
277
- title: "跨模型汇总:FORMULA 字段 + AGGREGATION + DYNAMIC 条件(API 可回算,r17 真机 100→105 实测)",
326
+ title: "跨模型汇总:FORMULA + AGGREGATION + DYNAMIC 条件(API 可回算,r17 真机)",
278
327
  aliases: ["跨模型汇总", "跨模型聚合", "另一个模型", "其它模型", "其他模型", "另一张表", "统计合计写入", "汇总到本模型", "API 回填聚合"],
279
328
  status: "offline-valid",
280
329
  tool: "field.create",
@@ -300,7 +349,7 @@ const formulaAggregationCrossModel = Object.freeze({
300
349
  },
301
350
  },
302
351
  preconditions: [
303
- "**只能汇总「别的模型」**:同模型(含自己的子表)聚合在 field.publish 必抛 305003(平台 publishFormula 把相对码改写成子表父模型 = 本模型,checkCycleOfAggregation:1032 判成环)。工具已写前拒绝 `aggregation-self-schema-cycle`。",
352
+ "**只能汇总「别的模型」**:同模型(含自己的子表)聚合在 field.publish 必抛 305003(平台 publishFormula 把相对码改写成子表父模型 = 本模型,checkCycleOfAggregation:1032 判成环);工具拒 `aggregation-self-schema-cycle`。",
304
353
  "目标字段用 FORMULA(100)(不是普通字段 + 计算规则——type2 计算规则在 REST 路径永不执行)。",
305
354
  "`schemaCode` 是被汇总的**来源模型**;`dataItemCode` 是来源模型的**主表标量列**(不带 schema 前缀);`queryConditions` **不能为空**,否则反向过滤器为空、找不到要回算的目标行(真机:空条件时 recalc 日志照常打印但目标字段恒为 0)。",
306
355
  "**不要指向子表 schema**(r18 2026-10-26 真机):`schemaCode:\"<子表>\"` 能发布,但目标模型从此**整个不可写** —— `data.submit`/`data.update` 一律回 40000「调用数据库发生异常」且无明细;而且子表 schema 没有父单单号列,按父单匹配恒为 0。`dataItemCode` 写成 `<子表>.<子列>` 则在 publish 直接 309004「使用的聚合数据项不存在」。要汇总子表:先在来源**主模型**上物化一个数值字段(门户计算规则或写入方维护),再聚合该标量。OMC 已写前拒绝 `aggregation-target-is-child-schema` / `aggregation-data-item-not-scalar`。",
@@ -350,7 +399,7 @@ const formulaExpressionSameModel = Object.freeze({
350
399
  preconditions: ["目标模型已存在;amount 是同一模型上已存在并已发布的数值字段;total 尚不存在"],
351
400
  conditionalRequirements: [
352
401
  "formulaConfig 是 JSON 字符串,内层 expression 仍是 JSON 字符串:CLI recipe 已代做两层序列化,直接把 args 传给 field.create,不要再手工转义。",
353
- "这是同模型的基础 EXPRESSION;跨模型汇总请改用 formula-aggregation-cross-model。",
402
+ "跨模型汇总改用 formula-aggregation-cross-model。",
354
403
  ],
355
404
  priorToolReferences: [
356
405
  { tool: "field.list", args: { environment, schemaCode: model, published: true }, purpose: "确认 amount 已发布并确认目标 code 未占用" },
@@ -400,10 +449,10 @@ const externalLookupModel = Object.freeze({
400
449
  "数据段已通:接口数据已能落进映射模型表(见 conditionalRequirements 第 1 条的三个已验证组合)",
401
450
  ],
402
451
  conditionalRequirements: [
403
- "**数据段首选(平台标准模式,2026-10-29 playwright 门户实证定案)**:映射模型的 GetList/Load 规则挂 BIZ_ACTION 实时调接口(接口方法配 frontEndExtensionEnable:true)——门户关联控件**打开即触发**前端查询链→GetList 规则→BIZ_ACTION 实时调外部接口(引擎日志 bizBusService.invoke + 外部网关日志双侧铁证)。**验证必须走门户填表;data.list 后端查询不反映此链,别用它判死**(r29 曾据此误判不成立)。配置侧三个收尾点:① WORK_SHEET 字段必须带 relativeCode(仅 options.schemaCode 发布表单会 301015 关联业务模型为空);② GetList 规则的 BIZ_ACTION 入参映射要接前端搜索词(实测未配词时 invoke 参数为空 {});③ 出参→列表行的映射配完候选才回显(未配时弹窗 Total 0 但接口已调)。「下拉框形态(输关键字回车查询)」是表单 attributes 层的控件形态设置,默认弹窗形态。备选(不需要实时时):预置 Create/Update 规则落映射表 / TIMING 定时同步。图内「BIZ_ACTION→CREATE 落表→再查」回环在 1.1.25 不可表达,不要走这条岔路。",
452
+ "**数据段首选(平台标准模式)**:映射模型的 GetList/Load 规则挂 BIZ_ACTION 实时调接口(接口方法配 frontEndExtensionEnable:true)——门户关联控件**打开即触发**前端查询链→GetList 规则→BIZ_ACTION 实时调外部接口(引擎日志 bizBusService.invoke + 外部网关日志双侧铁证)。**验证必须走门户填表;data.list 不反映此链**(r29 曾误判)。配置侧三个收尾点:① WORK_SHEET 字段必须带 relativeCode(仅 options.schemaCode 发布表单会 301015 关联业务模型为空);② GetList 规则的 BIZ_ACTION 入参映射要接前端搜索词(实测未配词时 invoke 参数为空 {});③ 出参→列表行的映射配完候选才回显(未配时弹窗 Total 0 但接口已调)。「下拉框形态(输关键字回车查询)」是表单 attributes 层的控件形态设置,默认弹窗形态。备选(不需要实时时):预置 Create/Update 规则落映射表 / TIMING 定时同步。图内「BIZ_ACTION→CREATE 落表→再查」回环在 1.1.25 不可表达,不要走这条岔路。",
404
453
  "**表单段是平台原生能力**:关联单选指向映射模型后,门户上输入关键字回车即查映射表、选中即 mappings 带出——前台填表时映射自然出现,无需按钮/脚本。",
405
454
  "下拉框形态在 form.draft 控件层配置;映射表要有数据下拉才有选项。",
406
- "**关联填充映射的事实源是字段行 `options.mappings`**:改表单控件属性里的 mappings 会被平台按字段重算覆盖、回读不生效(真机 2026-10-14 中冶实证)。改映射走 `field.update` 按完整 options 提交(只改 mappings,其余键 queryCode/displayField/schemaCode/conditions… 原值保留)→ `field.publish` → `form.draft`(**rebuild:false**,保留现有布局与已挂在线JS)重存 → `form.publish` → 回读核对。**不要用 field.update 的 cascadeRepublish 刷已带自定义布局/在线JS 的表单**——它会 rebuild 脚手架(rebuild:false 手动链才安全)。",
455
+ "**关联填充映射的事实源是字段行 `options.mappings`**:改表单控件属性里的 mappings 会被平台按字段重算覆盖、回读不生效(真机 2026-10-14 中冶实证)。改映射走 `field.update` 按完整 options 提交(只改 mappings,其余键 queryCode/displayField/schemaCode/conditions… 原值保留)→ `field.publish` → `form.draft`(**rebuild:false**,保留现有布局与已挂在线JS)重存 → `form.publish` → 回读核对。**别用 cascadeRepublish 刷已带布局/在线JS 的表单**(会 rebuild 脚手架)。",
407
456
  ],
408
457
  priorToolReferences: [
409
458
  { tool: "model.create", args: { environment }, purpose: "建映射模型(字段与接口返回一一对应;mappings 的 source/target 只填裸字段 code,不带模型前缀)" },
@@ -420,6 +469,6 @@ const externalLookupModel = Object.freeze({
420
469
  });
421
470
  export const FIELD_METADATA = Object.freeze({
422
471
  "field.update": Object.freeze({ recipes: [formConditionalRequired, formAlwaysReadonly, formConditionalReadonly], relatedTools: ["field.list", "field.publish", "form.draft", "form.publish"] }),
423
- "field.create": Object.freeze({ recipes: [fieldSerialNumber, numericTwoDecimals, numericPercent, dictionarySelection, dictionaryMultiSelection, childTable, businessModelDropdown, formulaAggregationCrossModel, formulaExpressionSameModel, externalLookupModel], relatedTools: ["dictionary.names", "dictionary.records", "discover_environment", "field.list", "field.publish", "form.draft", "configure_form", "form.publish"] }),
472
+ "field.create": Object.freeze({ recipes: [fieldSerialNumber, numericTwoDecimals, numericPercent, dictionarySelection, dictionaryMultiSelection, childTable, childTableParentFieldFill, businessModelDropdown, formulaAggregationCrossModel, formulaExpressionSameModel, externalLookupModel], relatedTools: ["dictionary.names", "dictionary.records", "discover_environment", "field.list", "field.publish", "form.draft", "configure_form", "form.publish"] }),
424
473
  });
425
474
  //# sourceMappingURL=field.js.map
@@ -9,7 +9,7 @@ const listViewConfigure = Object.freeze({
9
9
  conditionalRequirements: [
10
10
  "**省略 `code` 即配置默认视图(code = schemaCode);不要先 listview.create——那会多出一个自定义视图。** 只有确实需要第二个视图时才 listview.create。案卷:r60a-F13 真机对齐 2026-11-13;r73 #6 真机对齐 2026-11-17;8.6.41 实测默认视图同样可 configure(改默认视图影响所有用户)。",
11
11
  "`fieldCodes` 只列业务字段,可给 propertyCode 或字段显示名;系统列由平台决定。未知引用被拒(listview-columns-unknown-field)。",
12
- "数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位…;真机:scale 2 → displayFormat 3 = 两位小数);本工具会原地修正既有列的 displayFormat。",
12
+ "**`displayFormat` 是平台数值格式枚举,不是字段 `scale`**(scale 只决定小数位,currency/percent 会覆盖位数)。平台 `QueryRuntimeController.parseNumber`(8.6.26 :1830,case 1/2/3/11/12/23..26 小数、case 4/5/6/13/14/27..30 百分比、case 7/15/16/31..34 货币¥、case 8/17/18/35..38 美元、case 9/19/20/39..42 欧元;前端枚举同值:`RMB.percentile=7`、`ratio.percentile=6`,admin bundle 19497.069256cf.js)。枚举表:**1=0 位小数、2=1 位、3=2 位、11=3 位、12=4 位、23..26=5..8 位**(`1..n=小数位` 这一族;真机 scale 2 → displayFormat 3);**6=百分比(2 位)**、4/5/13/14/27..30 为百分比其它位数;**7=货币 ¥(2 位)**、15/16/31..34 为货币其它位数。金额列(NUMERICAL scale=2 + format=RMB.percentile)回读 7,不是 3。本工具会原地修正既有列的 displayFormat。",
13
13
  "**列汇总**:数值列 `sumType` wire 为整数——0=不统计/1=求和/2=平均/3=最小/4=最大/5=计数,写进 `presentation.columnsJson` 的列对象(8.6.26 反编译 SumType 实证)。",
14
14
  "`query/update` 自动 publish=TRUE——视图无草稿/发布两态,无需独立发布步骤。",
15
15
  ],
package/dist/reserved.js CHANGED
@@ -25,4 +25,52 @@ export function reservedCodeReport() {
25
25
  nextCommand: "omc help omc-write-hazards",
26
26
  };
27
27
  }
28
+ /**
29
+ * F13(0.8.9 探针 D):`omc reserved <code...>` 按候选 code 只回命中项。查的是
30
+ * **同一张表**(`RESERVED_CODE_GROUPS`,与写门同源),大小写不敏感——本地判据
31
+ * 就是 `code.toLowerCase()` 比对,所以这里也只做 lower-case 比对,不另造规则。
32
+ * 一个 code 可能落在多组(`id` 同时在 system 与 subtable),逐条 `group` 给首个,
33
+ * 顶层 `groups` 列全命中组,避免静默丢掉第二个归属。
34
+ */
35
+ const RESERVED_CODE_LOOKUP = (() => {
36
+ const map = new Map();
37
+ for (const group of RESERVED_CODE_GROUPS) {
38
+ for (const entry of group.codes) {
39
+ const key = entry.toLowerCase();
40
+ const list = map.get(key) ?? [];
41
+ list.push({ group, entry });
42
+ map.set(key, list);
43
+ }
44
+ }
45
+ return map;
46
+ })();
47
+ /** Per-candidate verdict for `omc reserved <code...>`; never touches an environment. */
48
+ export function reservedCodeLookup(rawCodes) {
49
+ const checked = rawCodes.map((raw) => {
50
+ const code = String(raw).trim();
51
+ const matches = RESERVED_CODE_LOOKUP.get(code.toLowerCase()) ?? [];
52
+ const first = matches[0];
53
+ return {
54
+ code,
55
+ reserved: matches.length > 0,
56
+ ...(first === undefined ? {} : { group: first.group.id, matched: first.entry }),
57
+ };
58
+ });
59
+ const hits = checked.filter((entry) => entry.reserved);
60
+ const groups = RESERVED_CODE_GROUPS.map((group) => ({
61
+ id: group.id,
62
+ title: group.title,
63
+ codes: hits.filter((hit) => (RESERVED_CODE_LOOKUP.get(hit.code.toLowerCase()) ?? []).some((match) => match.group.id === group.id)).map((hit) => hit.code),
64
+ })).filter((group) => group.codes.length > 0);
65
+ return {
66
+ status: "ok",
67
+ scope: "本地 code dry-lint(model.create / field.create / configure_model 使用同一张表);不是平台全量保留字清单",
68
+ rule: "reserved:true 的 code 不要用于业务模型 / 字段;平台最终门:属性冲突 301014、SQL 关键字 10033。命中不是错误(退出码 0)",
69
+ checked,
70
+ hits,
71
+ total: hits.length,
72
+ ...(groups.length > 0 ? { groups } : {}),
73
+ ...(hits.length > 0 ? { nextCommand: "omc reserved" } : {}),
74
+ };
75
+ }
28
76
  //# sourceMappingURL=reserved.js.map
@@ -28,6 +28,8 @@ const KEY_RULES = Object.freeze({
28
28
  workflowCode: { cls: "registry", source: "workflow.get_published → code" },
29
29
  sheetCode: { cls: "registry", source: "form.get / model.inspect → 默认表单槽位" },
30
30
  propertyCode: { cls: "registry", source: "field.list → fields[].code(名称匹配,可能歧义)" },
31
+ // 0.8.8(探针 C F1):子表关联列的 relativeCode = 关联目标模型 code(model.list 可查)。
32
+ relativeCode: { cls: "registry", source: "model.list → models[].schemaCode(关联目标模型)" },
31
33
  serviceCode: { cls: "registry", source: "service.list → serviceCode" },
32
34
  methodCode: { cls: "registry", source: "method.get / service.get → methodCode" },
33
35
  serviceCategoryId: { cls: "registry", source: "service.category.list → id(「全部」空 id 不可用)" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.8.7",
3
+ "version": "0.8.9",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "commander": "14.0.3",
61
- "omc-core": "0.8.7",
61
+ "omc-core": "0.8.9",
62
62
  "proper-lockfile": "4.1.2",
63
63
  "write-file-atomic": "6.0.0",
64
64
  "zod": "^3.23.8",
@@ -76,6 +76,6 @@
76
76
  "directory": "packages/omc-cli"
77
77
  },
78
78
  "optionalDependencies": {
79
- "@stalfh233/omc-fake-platform": "0.8.7"
79
+ "@stalfh233/omc-fake-platform": "0.8.9"
80
80
  }
81
81
  }
@@ -13,7 +13,7 @@ description: 一页纸业务场景步骤清单(采购申请 / 请假审批 /
13
13
 
14
14
  1. `omc next "从零做采购申请:主子表、合计、条件审批、列表、按钮"` → `omc intent schema`
15
15
  2. `omc model-scaffold --app <app> --code <code> --name 采购申请 --fields '<JSON数组>' --apply`(字段含 `amount` NUMERICAL scale=2、`<主表code>_details` CHILD_TABLE 及 item/qty/price/lineAmount 子列;子表 code 必须全局唯一)
16
- 3. (`model-scaffold` 已在第 2 步完成字段发布与表单发布;无需另起命令)
16
+ 3. (第 2 步已含字段/表单发布,无需另起命令)
17
17
  4. `omc compute --schema <code> --target amount --formula 'SUM({<主表code>_details.lineAmount})' --apply`(⚠️ 只在门户算,REST 不回填)
18
18
  5. 条件审批(金额>50000 两级):**不要** `approval-flow --condition`(无此参数)。线性先:`omc approval-flow --schema <code> --steps '经理@role:<mgr>' --steps '总监@role:<dir>' --apply`;条件分流改 `omc describe workflow.update --example workflow-conditional-branch` 后 `workflow.update`。
19
19
  6. 发起权限:`omc call workflow.addPermission --args '{"workflowCode":"<code>_wf","unitId":"<deptOrRoleId>","unitType":1}'`(这是**谁能发起**,不是行级可见范围)
@@ -48,7 +48,7 @@ description: 一页纸业务场景步骤清单(采购申请 / 请假审批 /
48
48
  ## 清理顺序(cleanup)
49
49
 
50
50
  - 数据 → 流程 → 模型:先 `data.delete`;删流程前清列表 `add` 绑定(首次 publish 自动绑;303024 用 `listviewBinding.unbindCommand`)。
51
- - 视图随模型级联(末条不可删);删模型看 `deleteTask.taskStatus`。
51
+ - 视图随模型级联,最后一条不可单删;不单列清理步骤,删模型看 `deleteTask.taskStatus`。
52
52
 
53
53
  ## 读法
54
54
 
@@ -39,6 +39,19 @@ capability's coverage/tools/boundaries from `omc-capabilities`.
39
39
  | 集成、接口、服务、回调、对接外部系统 | B2 业务集成服务 (`service.register`);二开接口 = 扩展模块写 REST 接口 + RESTFUL 服务指向它;自定义协议适配器 SPI 非常规、不在支持面 |
40
40
  | 数据、提交、保存、删除、查记录 | M2 runtime data |
41
41
 
42
+ ## 子表关联列取主表字段(options.mappings 字段映射)
43
+
44
+ 需求原话常是「子表列指向主模型,把 `pb_repair.repairNo` 映射到 `pb_repair_items.repairNoSnapshot`」——这是**子表 schema 上的 WORK_SHEET 关联列 + `options.mappings`**,不是业务规则 `dataActions`。
45
+
46
+ 1. 先在子表 schema 建快照标量列(如 `repairNoSnapshot` SHORT_TEXT)并发布。
47
+ 2. 再建关联列,形状照抄配方 `omc describe field.create --example child-map-fill`:
48
+ `field.create {schemaCode:"<model>_items", code:"refParent", propertyType:"WORK_SHEET", relativeCode:"<model>", options:{schemaCode:"<model>", queryCode:"<model>", displayField:"<父字段>", mappings:[{source:"<父字段>",target:"<快照列>"}]}}`。
49
+ 3. `field.publish`(整模型一次)→ `field.get` 读回核对 `options.mappings`。
50
+
51
+ - **字段映射**的事实源是字段行 `options.mappings`(`source`=关联目标/父模型字段,`target`=本子表列,都是裸 code);改表单控件属性里的映射会被平台按字段重算覆盖。
52
+ - **关联填充只在门户选值时由表单运行时回填**:CLI `data.save`(`/api/runtime/form/save`)**不跑映射**,API 写入必须自己带快照列值,否则读回为空——这不是映射配置失败。
53
+ - 子表 code 是全局唯一子 schema;关联列必须带 `relativeCode`,且不能是 CHILD_TABLE / OCR / ELECTRONIC_SIGN / MULT_WORK_SHEET / RELEVANCE_DATA / FORMULA。
54
+
42
55
  ## 横切面 — landscape and boundaries
43
56
 
44
57
  Coverage status and boundaries for every capability (including 权限/子表/聚合/