@stalfh233/omc-cli 0.8.31 → 0.8.33
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/arg-vocabulary.js +223 -0
- package/dist/artifact-cmd.js +443 -0
- package/dist/batch-call.js +56 -3
- package/dist/call-command.js +70 -0
- package/dist/call-execute.js +228 -0
- package/dist/call-input.js +557 -0
- package/dist/call-output.js +240 -0
- package/dist/cli.js +23 -1360
- package/dist/command-transport.js +4 -1
- package/dist/field-add.js +2 -1
- package/dist/form-support.js +17 -4
- package/dist/intent/plan-apply.js +14 -24
- package/dist/lanes/datarule.js +21 -0
- package/dist/lanes/field.js +31 -0
- package/dist/lanes/list-view-shapes.js +8 -1
- package/dist/lanes/list-view.js +64 -2
- package/dist/lanes/runtime-data/aggregate-support.js +209 -0
- package/dist/lanes/runtime-data/aggregate.js +679 -0
- package/dist/lanes/runtime-data/field-options.js +52 -0
- package/dist/lanes/runtime-data/lane.js +4 -0
- package/dist/lanes/runtime-data/record-delete.js +419 -0
- package/dist/lanes/runtime-data/record-read.js +984 -0
- package/dist/lanes/runtime-data/record-write.js +562 -0
- package/dist/lanes/runtime-data/registration.js +22 -0
- package/dist/lanes/runtime-data/shapes.js +594 -0
- package/dist/lanes/runtime-data/submission.js +1293 -0
- package/dist/lanes/runtime-data/write-support.js +875 -0
- package/dist/lanes/runtime-data-contract.js +1 -1
- package/dist/lanes/runtime-data.js +10 -5556
- package/dist/lanes/workflow/approval-ops.js +983 -0
- package/dist/lanes/workflow/instance-read.js +284 -0
- package/dist/lanes/workflow/lifecycle-write.js +1499 -0
- package/dist/lanes/workflow/permissions.js +571 -0
- package/dist/lanes/workflow/recovery.js +361 -0
- package/dist/lanes/workflow/registration.js +14 -0
- package/dist/lanes/workflow/shapes.js +811 -0
- package/dist/lanes/workflow/template-fetch.js +197 -0
- package/dist/lanes/workflow/template-merge.js +1351 -0
- package/dist/lanes/workflow/template-read.js +327 -0
- package/dist/lanes/workflow.js +11 -6312
- package/dist/model-scaffold.js +3 -1
- package/dist/path-projection.js +27 -6
- package/dist/read-projection.js +442 -0
- package/dist/read.js +40 -335
- package/dist/rollback.js +17 -23
- package/dist/runtime-support.js +1 -1
- package/dist/verification.js +39 -0
- package/dist/write-coordinator.js +152 -0
- package/dist/write-outcome.js +295 -0
- package/dist/write.js +34 -115
- package/package.json +3 -3
- package/skills/omc-refusals.md +1 -1
- package/skills/omc-start-here.md +3 -3
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../../endpoints.js";
|
|
2
|
+
import { ToolRefusalError, ToolInputError } from "../../tool-types.js";
|
|
3
|
+
import { wireCall, wireRows, WireError } from "../../wire.js";
|
|
4
|
+
import { sanitizeWorkflowSnapshotForReplay, workflowCompactProjection } from "./shapes.js";
|
|
5
|
+
/**
|
|
6
|
+
* 2026-10-27 用户需求:创建流程时流程名默认与表单名一致。
|
|
7
|
+
*
|
|
8
|
+
* 解析链(全部真实读回,不捏造):
|
|
9
|
+
* ① 显式 name → "args"
|
|
10
|
+
* ② 该模型默认表单的名字(bizsheet/get 的 name 字段)→ "form-name"
|
|
11
|
+
* ③ 模型名(bizmodels/list_schema 行的 name)→ "model-name"
|
|
12
|
+
* ④ 都读不到(模型不存在/无名字段)→ 拒绝:让调用方显式给 name,
|
|
13
|
+
* 绝不拿 schemaCode 冒充流程名(占位符冒充合法值是形状红线)。
|
|
14
|
+
*/
|
|
15
|
+
export async function resolveWorkflowName(session, explicitName, schemaCode) {
|
|
16
|
+
if (typeof explicitName === "string" && explicitName.trim().length > 0)
|
|
17
|
+
return { name: explicitName, resolvedFrom: "args" };
|
|
18
|
+
const sheet = await wireCall(session, { path: ENDPOINTS.sheetGet, query: { schemaCode, sheetCode: schemaCode } }).catch(() => null);
|
|
19
|
+
const sheetName = sheet?.data?.name;
|
|
20
|
+
if (typeof sheetName === "string" && sheetName.trim().length > 0)
|
|
21
|
+
return { name: sheetName, resolvedFrom: "form-name" };
|
|
22
|
+
const listed = await wireCall(session, { path: ENDPOINTS.modelList, method: "POST", body: { schemaCodes: [schemaCode] } }).catch(() => null);
|
|
23
|
+
const rows = wireRows(listed?.data);
|
|
24
|
+
const modelName = rows.find((row) => String(row.schemaCode ?? "") === schemaCode)?.name;
|
|
25
|
+
if (typeof modelName === "string" && modelName.trim().length > 0)
|
|
26
|
+
return { name: modelName, resolvedFrom: "model-name" };
|
|
27
|
+
throw new ToolRefusalError({
|
|
28
|
+
status: "refused",
|
|
29
|
+
blocker: "invalid-input",
|
|
30
|
+
message: `流程 name 缺省解析失败:模型 ${schemaCode} 读不到表单名或模型名(模型不存在?)。显式传 name,或先确认模型存在(omc call model.list --args '{"filter":"<名或码>"}')`,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function workflowRollbackSpec(toolName) {
|
|
34
|
+
return {
|
|
35
|
+
target: (args) => `workflow:${String(args.schemaCode ?? "")}/${String(args.code ?? args.workflowCode ?? "")}`,
|
|
36
|
+
read: async (session, args) => {
|
|
37
|
+
const code = String(args.code ?? args.workflowCode ?? "") || (await resolveWorkflowArg(session, { workflowCode: undefined, schemaCode: args.schemaCode }) ?? undefined);
|
|
38
|
+
if (!code)
|
|
39
|
+
return null;
|
|
40
|
+
return getWorkflowDraftOrNull(session, code);
|
|
41
|
+
},
|
|
42
|
+
inverse: ({ before, args, readback }) => {
|
|
43
|
+
const schemaCode = String(args.schemaCode ?? "");
|
|
44
|
+
const code = String(args.code ?? args.workflowCode ?? "");
|
|
45
|
+
if (toolName === "workflow.create") {
|
|
46
|
+
if (readback.alreadyPresent === true)
|
|
47
|
+
return { kind: "calls", calls: [], notes: ["create 时已存在(幂等跳过),未写入,无需回滚"] };
|
|
48
|
+
return { kind: "calls", calls: [{ tool: "workflow.delete", args: { schemaCode, code } }] };
|
|
49
|
+
}
|
|
50
|
+
if (toolName === "workflow.delete") {
|
|
51
|
+
if (before == null)
|
|
52
|
+
return { kind: "calls", calls: [], notes: ["delete 前目标已缺席(幂等),无需回滚"] };
|
|
53
|
+
const row = before;
|
|
54
|
+
return {
|
|
55
|
+
kind: "calls",
|
|
56
|
+
calls: [
|
|
57
|
+
{ tool: "workflow.create", args: { schemaCode, code, name: String(row.workflowName ?? row.name ?? code) } },
|
|
58
|
+
{ tool: "workflow.update", args: { schemaCode, code, template: sanitizeWorkflowSnapshotForReplay(row), merge: false } },
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (toolName === "workflow.publish")
|
|
63
|
+
return {
|
|
64
|
+
kind: "irreversible",
|
|
65
|
+
reason: "平台无 unpublish:发布是生命周期推进(workflowVersion 递增),不可参数重放撤销。内容回退路径:对该流程前一 workflow.update/bindRule 的 before 执行 rollback plan/apply 恢复草稿内容后,重新 workflow.publish",
|
|
66
|
+
};
|
|
67
|
+
// update / bindRule / unbindRule:整模板替换回 before 草稿
|
|
68
|
+
if (before == null)
|
|
69
|
+
return { kind: "irreversible", reason: "before 快照为空(流程不存在),无内容可恢复" };
|
|
70
|
+
return { kind: "calls", calls: [{ tool: "workflow.update", args: { schemaCode, code, template: sanitizeWorkflowSnapshotForReplay(before), merge: false } }] };
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* How many workflow instances for this model are still unfinished.
|
|
76
|
+
*
|
|
77
|
+
* Best-effort (0 on any failure): it exists to WARN before a delete that would
|
|
78
|
+
* orphan todos, never to block one.
|
|
79
|
+
*/
|
|
80
|
+
export async function countPendingWorkItems(session, workflowCode) {
|
|
81
|
+
try {
|
|
82
|
+
const data = (await wireCall(session, {
|
|
83
|
+
path: ENDPOINTS.workflowListWorkItems,
|
|
84
|
+
query: { workflowCode, status: "PENDING", page: "0", size: "1" },
|
|
85
|
+
})).data;
|
|
86
|
+
const total = Number(data?.totalElements ?? 0);
|
|
87
|
+
return Number.isFinite(total) && total > 0 ? total : 0;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Round-2 BUG-05 — live `workflow/get_header` and `workflow/get_draft` answer
|
|
95
|
+
* `401001 流程不存在!` for an ABSENT workflow rather than a null payload. Both
|
|
96
|
+
* are ABSENCE signals, not failures: the pre-create probe and the post-create
|
|
97
|
+
* readback must treat them as "no workflow" so workflow.create can proceed
|
|
98
|
+
* instead of stopping at the probe's 401001.
|
|
99
|
+
*/
|
|
100
|
+
export function isWorkflowAbsent(error) {
|
|
101
|
+
return error instanceof WireError && error.kind === "business" && error.errcode === 401001;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Identity seam: a caller may hold only the model's `schemaCode`. Resolve the
|
|
105
|
+
* workflow it backs via the platform link (workflow/isworkflow →
|
|
106
|
+
* workflow/getWorkflow); return null when the model has no workflow.
|
|
107
|
+
*/
|
|
108
|
+
export async function resolveWorkflowArg(session, args) {
|
|
109
|
+
if (args.workflowCode)
|
|
110
|
+
return args.workflowCode;
|
|
111
|
+
if (!args.schemaCode)
|
|
112
|
+
throw new ToolInputError({ status: "error", blocker: "tool-input-invalid", tool: "workflow.*", message: "需要 workflowCode,或 schemaCode(工具内部解析该模型的流程)" });
|
|
113
|
+
const code = (await wireCall(session, { path: ENDPOINTS.workflowIsWorkflow, query: { schemaCode: args.schemaCode } })).data === true
|
|
114
|
+
? (await wireCall(session, { path: ENDPOINTS.workflowGetBySchema, query: { schemaCode: args.schemaCode } })).data
|
|
115
|
+
: null;
|
|
116
|
+
const workflowCode = code && typeof code.workflowCode === "string" && code.workflowCode ? code.workflowCode : null;
|
|
117
|
+
return workflowCode;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* BUG-05-F8: `isworkflow` can lag behind the real workflow binding. Keep the
|
|
121
|
+
* ordinary probe hot path unchanged, and only use the bounded model index when
|
|
122
|
+
* that probe says nothing. The index is intentionally not the high-level
|
|
123
|
+
* workflow.list tool (which would add summaries/details to this point lookup).
|
|
124
|
+
*/
|
|
125
|
+
export async function resolveWorkflowArgWithFallback(session, args) {
|
|
126
|
+
if (args.workflowCode)
|
|
127
|
+
return { workflowCode: args.workflowCode };
|
|
128
|
+
if (!args.schemaCode)
|
|
129
|
+
throw new ToolInputError({ status: "error", blocker: "tool-input-invalid", tool: "workflow.*", message: "需要 workflowCode,或 schemaCode(工具内部解析该模型的流程)" });
|
|
130
|
+
const direct = await resolveWorkflowArg(session, args);
|
|
131
|
+
if (direct)
|
|
132
|
+
return { workflowCode: direct, resolution: "schemaCode-bind" };
|
|
133
|
+
// 直接探针的唯一门槛是 `workflow/isworkflow`——真机里它会滞后于真实绑定。
|
|
134
|
+
// 因此缺席时**绕过该门**直接问 getWorkflow(不问应用树:单点解析不需要
|
|
135
|
+
// 模型清单,省一次 wire),拿到平台真实 workflowCode 才继续。
|
|
136
|
+
const base = {
|
|
137
|
+
workflowCode: null,
|
|
138
|
+
resolution: "schemaCode-probe-plus-fallback",
|
|
139
|
+
scannedModels: 1,
|
|
140
|
+
nextCommand: `omc call workflow.list --args '{"applicationCode":"<应用code>"}'(按模型索引复核;不要据此断言流程不存在)`,
|
|
141
|
+
};
|
|
142
|
+
try {
|
|
143
|
+
const linked = (await wireCall(session, { path: ENDPOINTS.workflowGetBySchema, query: { schemaCode: args.schemaCode } })).data;
|
|
144
|
+
const workflowCode = linked && typeof linked.workflowCode === "string" && linked.workflowCode ? linked.workflowCode : null;
|
|
145
|
+
if (workflowCode)
|
|
146
|
+
return { ...base, workflowCode, resolution: "workflow-list-fallback" };
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return { ...base, readFailed: true, nextCommand: `omc call workflow.list --args '{"applicationCode":"<应用code>"}'(getWorkflow 读取失败;不要断言流程不存在)` };
|
|
150
|
+
}
|
|
151
|
+
return base;
|
|
152
|
+
}
|
|
153
|
+
export async function scanModelWorkflowBindings(session, schemaCode) {
|
|
154
|
+
const workflowCode = await resolveWorkflowArg(session, { schemaCode });
|
|
155
|
+
if (!workflowCode)
|
|
156
|
+
return null;
|
|
157
|
+
let pub;
|
|
158
|
+
try {
|
|
159
|
+
pub = await wireCall(session, { path: ENDPOINTS.workflowGetPublished, query: { workflowCode } });
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
if (isWorkflowAbsent(error))
|
|
163
|
+
return null;
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
const data = (pub.data ?? null);
|
|
167
|
+
const published = data !== null && (data.templateType === "PUBLISH" || data.published === true);
|
|
168
|
+
const summary = workflowCompactProjection({ data: pub.data }).workflowSummary;
|
|
169
|
+
const ruleBindings = summary?.ruleBindings ?? [];
|
|
170
|
+
const nodeRuleBindings = summary?.nodeRuleBindings ?? [];
|
|
171
|
+
const systemRuleBindings = summary?.systemRuleBindings ?? [];
|
|
172
|
+
const ruleBindingCount = ruleBindings.reduce((sum, binding) => sum + binding.ruleCodes.length, 0) +
|
|
173
|
+
nodeRuleBindings.reduce((sum, binding) => sum + binding.ruleCodes.length, 0) +
|
|
174
|
+
systemRuleBindings.reduce((sum, binding) => sum + binding.ruleCodes.length, 0);
|
|
175
|
+
return { workflowCode, published, ruleBindings, nodeRuleBindings, systemRuleBindings, ruleBindingCount };
|
|
176
|
+
}
|
|
177
|
+
export async function getWorkflowHeaderOrNull(session, workflowCode) {
|
|
178
|
+
try {
|
|
179
|
+
return ((await wireCall(session, { path: ENDPOINTS.workflowGetHeader, query: { workflowCode } })).data ?? null);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (isWorkflowAbsent(error))
|
|
183
|
+
return null;
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
export async function getWorkflowDraftOrNull(session, workflowCode) {
|
|
188
|
+
try {
|
|
189
|
+
return ((await wireCall(session, { path: ENDPOINTS.workflowGetDraft, query: { workflowCode } })).data ?? null);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
if (isWorkflowAbsent(error))
|
|
193
|
+
return null;
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=template-fetch.js.map
|