@stalfh233/omc-cli 0.8.5 → 0.8.7
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/coverage/m1-coverage-manifest-v1.json +1 -0
- package/dist/approval-flow.js +49 -4
- package/dist/batch-call.js +21 -4
- package/dist/bench/scenario.js +1 -1
- package/dist/cli-stdout.js +1 -0
- package/dist/cli.js +84 -3
- package/dist/code-rules.js +144 -8
- package/dist/config-store.js +15 -1
- package/dist/coverage.js +2 -1
- package/dist/discovery.js +8 -2
- package/dist/endpoints.js +10 -0
- package/dist/form-layout.js +79 -0
- package/dist/form-support.js +65 -1
- package/dist/goal-routes.js +35 -5
- package/dist/graph.js +38 -3
- package/dist/human-summary.js +38 -2
- package/dist/intent/capabilities/field.js +1 -1
- package/dist/lanes/field-contract.js +4 -0
- package/dist/lanes/field-coverage.js +1 -0
- package/dist/lanes/field.js +20 -2
- package/dist/lanes/form-contract.js +1 -1
- package/dist/lanes/form.js +25 -3
- package/dist/lanes/list-view.js +21 -11
- package/dist/lanes/model-contract.js +2 -2
- package/dist/lanes/model-references.js +172 -0
- package/dist/lanes/model.js +226 -129
- package/dist/lanes/runtime-data-contract.js +3 -3
- package/dist/lanes/runtime-data.js +64 -8
- package/dist/lanes/workflow.js +91 -1
- package/dist/model-purge.js +1 -1
- package/dist/model-scaffold.js +6 -3
- package/dist/recipes/form.js +33 -6
- package/dist/recipes/runtime-data.js +1 -1
- package/dist/reserved.js +28 -0
- package/dist/residue.js +1 -1
- package/dist/tool-types.js +1 -0
- package/dist/version-family-gaps.js +33 -6
- package/dist/write.js +46 -8
- package/package.json +3 -3
- package/skills/omc-business-configuration.md +7 -0
- package/skills/omc-capabilities.md +1 -1
- package/skills/omc-playbook.md +5 -0
- package/skills/omc-refusals.md +4 -2
- package/skills/omc-start-here.md +1 -1
- package/skills/omc-tool-selection.md +2 -0
- package/skills/omc-write-hazards.md +3 -0
package/dist/lanes/list-view.js
CHANGED
|
@@ -405,6 +405,25 @@ export function decodeButtonScript(input) {
|
|
|
405
405
|
...(parsed !== undefined ? { actionConfig: parsed } : {}),
|
|
406
406
|
};
|
|
407
407
|
}
|
|
408
|
+
/**
|
|
409
|
+
* 306103(删除后将无可用视图)。平台要求**每个模型至少保留一个 PC 可见视图和
|
|
410
|
+
* 一个 MOBILE 可见视图**;该码只在 2.1.5 出现(`ErrorCode.java:383`),8.6.26
|
|
411
|
+
* 无 306103。导出以便回执文案被测试钉住(PC/MOBILE 各一条 + 正确出路)。
|
|
412
|
+
*/
|
|
413
|
+
export function listviewLastVisibleRefusal(schemaCode, code) {
|
|
414
|
+
return new ToolRefusalError({
|
|
415
|
+
status: "refused",
|
|
416
|
+
blocker: "listview-last-visible",
|
|
417
|
+
schemaCode,
|
|
418
|
+
code,
|
|
419
|
+
nextCommand: `omc model-purge --code ${schemaCode}`,
|
|
420
|
+
cleanupGuidance: `删视图在平台上不是独立清理步骤:要清视图就删模型(model-purge / model.delete 级联删除它的全部视图,含这条);` +
|
|
421
|
+
`listview.delete 只用于替换视图(先建/配好替代视图再删旧的),最后一条可见视图不可单删。`,
|
|
422
|
+
message: `不能删除视图 ${code}:平台要求**至少保留一个 PC 可见视图和一个 MOBILE 可见视图**(PC + MOBILE 各一条,306103)。` +
|
|
423
|
+
`单独删最后一条视图没有意义——删模型会级联删除它的所有视图。要继续用这个模型就**就地改**(listview.configure 省略 code 即改默认视图),` +
|
|
424
|
+
`要整体清理就用 model-purge(默认 dry-run,先看计划)。`,
|
|
425
|
+
});
|
|
426
|
+
}
|
|
408
427
|
export function registerListViewLane(tools) {
|
|
409
428
|
tools.push(defineTool({
|
|
410
429
|
name: "listview.get",
|
|
@@ -731,7 +750,7 @@ export function registerListViewLane(tools) {
|
|
|
731
750
|
fieldCodes: z.array(z.string()).min(1).describe("要展示的字段:可给 propertyCode 或字段显示名(唯一匹配时自动解析,歧义或不存在则拒绝,不静默跳过)"),
|
|
732
751
|
hideDefaultSystemFields: z.boolean().optional().describe("是否隐藏平台默认系统列(createdTime/creater/name/sequenceNo 等);平台 update 按提交列集合决定,不能靠 visible:false"),
|
|
733
752
|
replaceColumns: z.boolean().optional().describe("把 fieldCodes 当作列集合的权威全集:未列出的已有列(含系统列)全部移除,最终列 = fieldCodes(按给定顺序)。默认 false 为增量(保留已有列)。系统列与业务列一视同仁——想要 createdTime/sequenceNo 就把它写进 fieldCodes"),
|
|
734
|
-
sorts: z.array(listViewSortArg).optional().describe("querySorts; omitted leaves the existing sorts untouched, provided replaces them"),
|
|
753
|
+
sorts: z.array(listViewSortArg).optional().describe("querySorts; omitted leaves the existing sorts untouched, provided replaces them。成员键:propertyCode + direction(ASC/DESC),其余可省"),
|
|
735
754
|
conditions: z.array(listViewConditionArg).optional().describe("queryConditions; omitted leaves the existing conditions untouched, provided replaces them(2.1.5 树视图三键原样带回;值变化默认拒 listview-tree-conditions-changed)"),
|
|
736
755
|
allowTreeConditionChange: z.boolean().optional().describe("仅当确认要改写树过滤组时传 true:允许提交值与基线的 treeLimitScopeType/treeLimitConditionGroup/treeDefaultConditionGroup 不同(新值原样写入);默认 false 时值不同即拒 listview-tree-conditions-changed。本参数只放行值差异,不放行缺键——基线有值而提交行没带仍拒 listview-tree-conditions-would-be-lost。"),
|
|
737
756
|
actions: z.array(listViewActionArg).optional().describe("queryActions; omitted leaves the existing actions untouched, provided MERGES into the effective set by actionCode (existing platform defaults like 新增/删除/导入/导出 are preserved, a matching actionCode is updated). Use replaceActions:true for the authoritative full set"),
|
|
@@ -1293,16 +1312,7 @@ export function registerListViewLane(tools) {
|
|
|
1293
1312
|
// list view per model. r15's `nextCommand` fell back to the generic
|
|
1294
1313
|
// refusal router; name the constraint and the only real deletion path.
|
|
1295
1314
|
if (error instanceof WireError && error.kind === "business" && (error.errcode === 306103 || /无可用视图/.test(error.message)))
|
|
1296
|
-
throw
|
|
1297
|
-
status: "refused",
|
|
1298
|
-
blocker: "listview-last-visible",
|
|
1299
|
-
schemaCode: args.schemaCode,
|
|
1300
|
-
code: args.code,
|
|
1301
|
-
nextCommand: `omc model-purge --code ${args.schemaCode}`,
|
|
1302
|
-
message: `不能删除视图 ${args.code}:平台要求每个模型至少保留一条可见列表视图(306103)。` +
|
|
1303
|
-
`单独删最后一条视图没有意义——视图会随模型一起级联删除。要继续用这个模型就**就地改**(listview.configure 省略 code 即改默认视图),` +
|
|
1304
|
-
`要整体清理就用 model-purge(默认 dry-run,先看计划)。`,
|
|
1305
|
-
});
|
|
1315
|
+
throw listviewLastVisibleRefusal(args.schemaCode, args.code);
|
|
1306
1316
|
throw error;
|
|
1307
1317
|
}
|
|
1308
1318
|
const readback = await wireCall(session, { path: ENDPOINTS.listQueryGetHeader, query: { schemaCode: args.schemaCode, code: args.code } });
|
|
@@ -13,7 +13,7 @@ export const MODEL_WIRE = Object.freeze({
|
|
|
13
13
|
deleteIdNamespace: "physically_delete resolves each row id as an AppFunction id (removeBizModel → getAppFunction(id), AppIntegrationFacadeImpl) and answers 601003 业务模型不存在 for a biz-model record id; the two id spaces are NOT interchangeable. model.delete/deleteMany resolve the node across applications (default app first, then applicationList per-app trees) and refuse fail-closed with model-application-unresolved when the record exists but no tree node does — never guessing a record id",
|
|
14
14
|
deleteTolerance: "already-absent short-circuits; the authoritative record face polls to verified absence; the tree node is eventually consistent and reported as treeNodePending",
|
|
15
15
|
referencePrecheck: "before physically_delete, every same-app sibling model's bizproperty faces (draft + published) are scanned for relation fields targeting the model (relativeCode or options.schemaCode of WORK_SHEET/MULT_WORK_SHEET/RELEVANCE_DATA); any hit refuses with blocker model-referenced-by + referencingModels — the server-side async 'xxx被模型 yyy 引用,不能删除' (AppIntegrationFacadeImpl.deleteFunctions:2201, live TID xydiq8enji3ziq4bl2diurx9c) surfaced at call time instead of errcode 0 followed by a silent async failure",
|
|
16
|
-
dependencyInvertedDelete: "referenced cleanup is dependency-inverted: delete referencing models first, then the referenced model; the physical delete
|
|
16
|
+
dependencyInvertedDelete: "referenced cleanup is dependency-inverted: delete referencing models first, then the referenced model; the physical delete is a platform async task whose duration is UNBOUNDED (a live probe exceeded 4 minutes), so absent:false + treeNodePending:true means wait-and-recheck (the poll runs ~60s and returns nextAction guidance), never an immediate failure verdict and never a completed deletion — especially right after deleting a referencing model, whose cascade may still be dropping the relation columns",
|
|
17
17
|
usableLadder: "model.create → field.create → model-scoped field.publish (rung-1..3); configure_model performs an authoritative readback immediately after every model.create, field.create, field.publish, form.draft, and form.publish step and stops with completed/failed step evidence on failure; form draft/publish is the separate configure_form capability",
|
|
18
18
|
summaryWire: "bizmodels/get_summary (GET ?schemaCode) returns the data-title string; bizmodels/update_summary (POST {schemaCode, summary}) requires a non-empty summary (validateNotEmpty) and answers 300014 BIZ_SCHEMA_NOT_PUBLISHED (ErrorCode.java:194) for a missing schema — 8.6.26 BizSchemaController.java:668-736",
|
|
19
19
|
});
|
|
@@ -112,7 +112,7 @@ export const MODEL_LANE_CONTRACT = Object.freeze({
|
|
|
112
112
|
}),
|
|
113
113
|
"model.delete": Object.freeze({
|
|
114
114
|
scope: MODEL_SCOPE,
|
|
115
|
-
description: "物理删除模型(apppackage/physically_delete [{id,code,type:BizModel}]);exact-absence 读回在 `readback.absent`/`readback.treeNodePending`(顶层无这两键——用 `--jq readback.absent`)。id 必须是应用树 AppFunction id(业务模型记录 id → 601003)。无 `applicationCode` 时跨应用解析节点,记录在但树节点缺 → `model-application-unresolved`。同应用入站引用预检 → `model-referenced-by`(dependency-inverted
|
|
115
|
+
description: "物理删除模型(apppackage/physically_delete [{id,code,type:BizModel}]);exact-absence 读回在 `readback.absent`/`readback.treeNodePending`(顶层无这两键——用 `--jq readback.absent`)。id 必须是应用树 AppFunction id(业务模型记录 id → 601003)。无 `applicationCode` 时跨应用解析节点,记录在但树节点缺 → `model-application-unresolved`。同应用入站引用预检 → `model-referenced-by`(dependency-inverted:先删引用方再删被引用方)。平台为异步任务、时长不定:`absent:false` 不当成功(deliveryState=WRITE_UNVERIFIED),以记录面与应用树为准,稍后重跑(幂等)。`performed.taskId` 为平台删除历史任务号(无查询端点)。可显式传 `applicationCode`。",
|
|
116
116
|
}),
|
|
117
117
|
configure_model: Object.freeze({
|
|
118
118
|
scope: MODEL_SCOPE,
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../endpoints.js";
|
|
2
|
+
import { relationTargetOf } from "../field-families.js";
|
|
3
|
+
import { wireCall, wireRows } from "../wire.js";
|
|
4
|
+
const WORK_SHEET = 9;
|
|
5
|
+
const CHILD_TABLE = 8;
|
|
6
|
+
function propertyTypeOf(row) {
|
|
7
|
+
return Number(row.type ?? row.propertyType);
|
|
8
|
+
}
|
|
9
|
+
function fieldCodeOf(row) {
|
|
10
|
+
const code = row.code ?? row.propertyCode;
|
|
11
|
+
return typeof code === "string" && code.length > 0 ? code : undefined;
|
|
12
|
+
}
|
|
13
|
+
function fieldNameOf(row) {
|
|
14
|
+
return typeof row.name === "string" && row.name.length > 0 ? row.name : String(fieldCodeOf(row) ?? "");
|
|
15
|
+
}
|
|
16
|
+
export async function inboundModelReferences(session, targets, treeRows, options = {}) {
|
|
17
|
+
const targetSet = new Set(targets);
|
|
18
|
+
if (targetSet.size === 0)
|
|
19
|
+
return [];
|
|
20
|
+
const models = new Map();
|
|
21
|
+
for (const row of treeRows) {
|
|
22
|
+
if (row.type !== "BizModel" || typeof row.code !== "string" || row.code.length === 0)
|
|
23
|
+
continue;
|
|
24
|
+
models.set(row.code, { code: row.code, name: typeof row.name === "string" && row.name.length > 0 ? row.name : row.code });
|
|
25
|
+
}
|
|
26
|
+
const skip = options.skipReading ?? new Set();
|
|
27
|
+
const scannable = [...models.values()].filter((model) => !skip.has(model.code));
|
|
28
|
+
const fieldCache = new Map();
|
|
29
|
+
const fieldsOf = async (schemaCode) => {
|
|
30
|
+
const cached = fieldCache.get(schemaCode);
|
|
31
|
+
if (cached !== undefined)
|
|
32
|
+
return cached;
|
|
33
|
+
const rows = [];
|
|
34
|
+
for (const isPublish of ["false", "true"]) {
|
|
35
|
+
const listed = await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode, isPublish } });
|
|
36
|
+
rows.push(...wireRows(listed.data));
|
|
37
|
+
}
|
|
38
|
+
fieldCache.set(schemaCode, rows);
|
|
39
|
+
return rows;
|
|
40
|
+
};
|
|
41
|
+
// one read pass: every tree model's fields, plus the CHILD_TABLE fields that
|
|
42
|
+
// give us child schema → parent model (isSubSchema()->parentCode on the wire).
|
|
43
|
+
const modelFields = new Map();
|
|
44
|
+
const childOwners = new Map();
|
|
45
|
+
for (const model of scannable) {
|
|
46
|
+
const rows = await fieldsOf(model.code);
|
|
47
|
+
modelFields.set(model.code, rows);
|
|
48
|
+
for (const row of rows) {
|
|
49
|
+
if (propertyTypeOf(row) !== CHILD_TABLE)
|
|
50
|
+
continue;
|
|
51
|
+
const code = fieldCodeOf(row);
|
|
52
|
+
if (code === undefined || childOwners.has(code))
|
|
53
|
+
continue;
|
|
54
|
+
childOwners.set(code, { model, childField: { code, name: fieldNameOf(row) } });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const ignore = options.ignoreReferencing ?? new Set();
|
|
58
|
+
const found = new Map();
|
|
59
|
+
const add = (referenced, owner, via, field, childTable) => {
|
|
60
|
+
const selfReference = owner.code === referenced;
|
|
61
|
+
// Intra-batch references are allowed by the platform; self references are not.
|
|
62
|
+
if (!selfReference && ignore.has(owner.code))
|
|
63
|
+
return;
|
|
64
|
+
const key = `${referenced}::${owner.code}::${via}::${childTable?.code ?? ""}`;
|
|
65
|
+
const entry = found.get(key) ?? {
|
|
66
|
+
referenced,
|
|
67
|
+
schemaCode: owner.code,
|
|
68
|
+
name: owner.name,
|
|
69
|
+
via,
|
|
70
|
+
fields: [],
|
|
71
|
+
...(childTable !== undefined ? { childTable } : {}),
|
|
72
|
+
selfReference,
|
|
73
|
+
};
|
|
74
|
+
if (!entry.fields.some((existing) => existing.code === field.code))
|
|
75
|
+
entry.fields.push(field);
|
|
76
|
+
found.set(key, entry);
|
|
77
|
+
};
|
|
78
|
+
for (const model of scannable) {
|
|
79
|
+
for (const row of modelFields.get(model.code)) {
|
|
80
|
+
if (propertyTypeOf(row) !== WORK_SHEET)
|
|
81
|
+
continue;
|
|
82
|
+
const target = relationTargetOf(row);
|
|
83
|
+
if (target === undefined || !targetSet.has(target))
|
|
84
|
+
continue;
|
|
85
|
+
// platform filter step 2: the property is defined ON the target itself.
|
|
86
|
+
if (model.code === target)
|
|
87
|
+
continue;
|
|
88
|
+
const code = fieldCodeOf(row);
|
|
89
|
+
if (code === undefined)
|
|
90
|
+
continue;
|
|
91
|
+
add(target, model, "model-field", { code, name: fieldNameOf(row), type: row.type ?? row.propertyType });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (const [childCode, owner] of childOwners) {
|
|
95
|
+
const rows = await fieldsOf(childCode);
|
|
96
|
+
for (const row of rows) {
|
|
97
|
+
if (propertyTypeOf(row) !== WORK_SHEET)
|
|
98
|
+
continue;
|
|
99
|
+
const target = relationTargetOf(row);
|
|
100
|
+
if (target === undefined || !targetSet.has(target))
|
|
101
|
+
continue;
|
|
102
|
+
// platform filter step 2 uses the PROPERTY's schemaCode (the child schema).
|
|
103
|
+
if (childCode === target)
|
|
104
|
+
continue;
|
|
105
|
+
const code = fieldCodeOf(row);
|
|
106
|
+
if (code === undefined)
|
|
107
|
+
continue;
|
|
108
|
+
add(target, owner.model, "child-table", { code, name: fieldNameOf(row), type: row.type ?? row.propertyType }, owner.childField);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return [...found.values()].sort((left, right) => left.referenced.localeCompare(right.referenced) ||
|
|
112
|
+
left.schemaCode.localeCompare(right.schemaCode) ||
|
|
113
|
+
left.via.localeCompare(right.via) ||
|
|
114
|
+
(left.childTable?.code ?? "").localeCompare(right.childTable?.code ?? ""));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Build the refusal payload shared by the three delete entry points
|
|
118
|
+
* (model.delete dry-run, model.delete, model.deleteMany). The message names the
|
|
119
|
+
* real platform cause and the exact commands that remove the reference.
|
|
120
|
+
*/
|
|
121
|
+
export function inboundReferenceRefusal(target, references) {
|
|
122
|
+
const referencingModels = [];
|
|
123
|
+
for (const reference of references) {
|
|
124
|
+
const existing = referencingModels.find((model) => model.schemaCode === reference.schemaCode);
|
|
125
|
+
const fields = reference.fields.map((field) => ({ code: field.code, type: field.type }));
|
|
126
|
+
if (existing)
|
|
127
|
+
existing.fields.push(...fields.filter((field) => !existing.fields.some((known) => known.code === field.code)));
|
|
128
|
+
else
|
|
129
|
+
referencingModels.push({ schemaCode: reference.schemaCode, name: reference.name, fields });
|
|
130
|
+
}
|
|
131
|
+
const steps = [];
|
|
132
|
+
const publishOwners = new Set();
|
|
133
|
+
const step = (tool, args) => {
|
|
134
|
+
steps.push({ tool, args, command: `omc call ${tool} --args '${JSON.stringify(args)}'` });
|
|
135
|
+
};
|
|
136
|
+
for (const reference of references) {
|
|
137
|
+
for (const field of reference.fields) {
|
|
138
|
+
const schemaCode = reference.via === "child-table" ? reference.childTable.code : reference.schemaCode;
|
|
139
|
+
step("field.delete", { schemaCode, code: field.code });
|
|
140
|
+
}
|
|
141
|
+
publishOwners.add(reference.schemaCode);
|
|
142
|
+
}
|
|
143
|
+
for (const owner of publishOwners)
|
|
144
|
+
step("field.publish", { schemaCode: owner });
|
|
145
|
+
step("model.delete", { schemaCode: target });
|
|
146
|
+
const selfReferences = references.filter((reference) => reference.selfReference);
|
|
147
|
+
const externalReferences = references.filter((reference) => !reference.selfReference);
|
|
148
|
+
const selfText = selfReferences.map((reference) => `${reference.childTable.code}.${reference.fields.map((field) => field.code).join("/")}`);
|
|
149
|
+
const externalText = [...new Set(externalReferences.map((reference) => reference.schemaCode))];
|
|
150
|
+
const parts = [];
|
|
151
|
+
if (selfText.length > 0) {
|
|
152
|
+
parts.push(`本模型的子表关联列 ${selfText.join("、")} 指向自身:子表属性的 schemaCode 经 isSubSchema()->parentCode 解析回 ${target},平台删除线程(appendRelatedFunction)会对自身无限递归,physically_delete 先回 taskId 后任务永远停在 RUN——删除**永不完成**,真因只写在平台日志,CLI 只会看到「级联中」。`);
|
|
153
|
+
}
|
|
154
|
+
if (externalText.length > 0) {
|
|
155
|
+
parts.push(`${target} 被模型 ${externalText.join("、")} 的关联字段引用:平台异步任务会以 BIZ_SCHEMA_RELEATIVE_SCHEMA_NOT_EMPTY 失败("${target}被模型 ${externalText[0]} 引用,不能删除")。`);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
blocker: "model-referenced-by",
|
|
159
|
+
referencingModels,
|
|
160
|
+
inboundReferences: [...references],
|
|
161
|
+
deletionOrder: [...new Set([...references.map((reference) => reference.schemaCode), target])],
|
|
162
|
+
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 依赖倒序执行:先删引用方模型的关联字段(或整体删掉引用方模型),再删本模型",
|
|
167
|
+
message: `${target} 不能删除(零写入拒绝,未调用 physically_delete)。${parts.join(" ")}` +
|
|
168
|
+
`依赖倒序(逐条可执行命令见 deletionSteps / nextCommand):先删关联列 → 发布所属模型 → 再删本模型。` +
|
|
169
|
+
`不要在未拆引用时重试 model.delete——平台只会再次回 taskId 并把真因留在删除历史里(模型引用失败时 taskStatus=FAIL,子表自引用时任务永远 RUN)。`,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=model-references.js.map
|