@stalfh233/omc-cli 0.6.81 → 0.6.82
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 +5 -2
- package/dist/artifacts.js +28 -5
- package/dist/capability-overview.js +4 -4
- package/dist/cli.js +72 -36
- package/dist/endpoints.js +12 -0
- package/dist/env-export.js +4 -0
- package/dist/human-summary.js +8 -0
- package/dist/lanes/b2-registration-contract.js +11 -0
- package/dist/lanes/b2-registration-coverage.js +1 -0
- package/dist/lanes/businessrule-contract.js +5 -3
- package/dist/lanes/businessrule.js +82 -0
- package/dist/lanes/rule-graph.js +21 -5
- package/dist/lanes/servicelog.js +376 -0
- package/dist/lanes/workflow-contract.js +12 -2
- package/dist/lanes/workflow-coverage.js +1 -0
- package/dist/lanes/workflow.js +357 -27
- package/dist/model-purge.js +12 -3
- package/dist/read-shapes.js +12 -8
- package/dist/recipes/businessrule.js +1 -1
- package/dist/refusal-guidance.js +4 -3
- package/dist/rule-support.js +309 -28
- package/dist/session-account.js +66 -0
- package/dist/tool-search.js +5 -1
- package/dist/tools.js +2 -0
- package/package.json +3 -3
- package/skills/omc-capabilities.md +5 -5
|
@@ -195,6 +195,76 @@ function ruleSummaryRoundTrip(roundTrip) {
|
|
|
195
195
|
gapsHint: "gap 的 message/fix 用 rule.get(不带 summary)取 roundTrip.gaps",
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* r85(retro 2026-11-19 issue 09/11):codeType:7 映射的公式口径注记。
|
|
200
|
+
*
|
|
201
|
+
* - `eqEqParams`:formula 含 `==` —— 服务端(Aviator)规范比较符就是 `==`,
|
|
202
|
+
* `=` 在 IF() 条件内被服务端归一为 `==`(CalculateRuleExecutor.java:704-706),
|
|
203
|
+
* 两种都可在服务端求值;设计器可能对 `==` 标红(已知口径不一致,平台侧)。
|
|
204
|
+
* 工具不改写用户公式,本注记非侵入。
|
|
205
|
+
* - `designerTextParams`:editorText/editorMark 有设计器痕迹(`<field-xxx>` 富
|
|
206
|
+
* 文本,xxx 是设计器随机 nonce)——运行时只读 formula;rule.save 默认保留
|
|
207
|
+
* 这些映射的设计器文本(preservedDesignerText)。
|
|
208
|
+
* - `bareFormulaParams`:只有 formula、无 editorText——设计器以纯文本呈现(可能
|
|
209
|
+
* 标红),运行不受影响。
|
|
210
|
+
*/
|
|
211
|
+
const RULE_FORMULA_NOTES_TEXT = "公式口径:服务端(Aviator)规范比较符是 ==;= 在 IF() 条件内被服务端归一后同样可求值(CalculateRuleExecutor.java:704-706),设计器可能对 == 标红(已知不一致,平台侧,工具不改写公式)。editorText 是设计器富文本(<field-xxx>code</field-xxx>;xxx 为设计器随机 nonce,不是字段 id),运行时只读 formula;bareFormulaParams 的映射在设计器以纯文本/标红呈现但运行不受影响,改动它们时 rule.save 默认保留现存设计器文本(preservedDesignerText)";
|
|
212
|
+
function ruleFormulaNotes(nodes) {
|
|
213
|
+
if (!Array.isArray(nodes))
|
|
214
|
+
return undefined;
|
|
215
|
+
const eqEqParams = [];
|
|
216
|
+
const designerTextParams = [];
|
|
217
|
+
const bareFormulaParams = [];
|
|
218
|
+
for (const entry of nodes) {
|
|
219
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
220
|
+
continue;
|
|
221
|
+
const node = entry;
|
|
222
|
+
const mapping = node.methodMapping;
|
|
223
|
+
if (!mapping || typeof mapping !== "object" || Array.isArray(mapping))
|
|
224
|
+
continue;
|
|
225
|
+
const m = mapping;
|
|
226
|
+
for (const listKey of ["inputMappings", "outputMappings"]) {
|
|
227
|
+
if (!Array.isArray(m[listKey]))
|
|
228
|
+
continue;
|
|
229
|
+
for (const element of m[listKey]) {
|
|
230
|
+
if (!element || typeof element !== "object" || Array.isArray(element))
|
|
231
|
+
continue;
|
|
232
|
+
const row = element;
|
|
233
|
+
if (Number(row.codeType) !== 7 || typeof row.bizCode !== "string")
|
|
234
|
+
continue;
|
|
235
|
+
let expression = null;
|
|
236
|
+
try {
|
|
237
|
+
const parsed = JSON.parse(row.bizCode);
|
|
238
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
|
|
239
|
+
expression = parsed;
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
expression = null;
|
|
243
|
+
}
|
|
244
|
+
const formula = expression !== null && typeof expression.formula === "string" ? expression.formula : "";
|
|
245
|
+
if (!formula)
|
|
246
|
+
continue;
|
|
247
|
+
const where = `${String(node.nodeCode ?? "")}/${String(row.serviceMethodParameterCode ?? "")}`;
|
|
248
|
+
if (formula.includes("=="))
|
|
249
|
+
eqEqParams.push(where);
|
|
250
|
+
const editorText = expression !== null && typeof expression.editorText === "string" ? expression.editorText : "";
|
|
251
|
+
const editorMark = expression !== null && typeof expression.editorMark === "string" ? expression.editorMark : "";
|
|
252
|
+
if (editorText.includes("<field-") || editorMark !== "")
|
|
253
|
+
designerTextParams.push(where);
|
|
254
|
+
else
|
|
255
|
+
bareFormulaParams.push(where);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (eqEqParams.length === 0 && designerTextParams.length === 0 && bareFormulaParams.length === 0)
|
|
260
|
+
return undefined;
|
|
261
|
+
return {
|
|
262
|
+
eqEqParams,
|
|
263
|
+
designerTextParams,
|
|
264
|
+
bareFormulaParams,
|
|
265
|
+
note: RULE_FORMULA_NOTES_TEXT,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
198
268
|
/** 摘要面公共体:身份 + 体量 + 节点摘要。正文仍在默认面(nodes/routes)。 */
|
|
199
269
|
function ruleSummaryBody(record, graph, roundTrip) {
|
|
200
270
|
const nodes = Array.isArray(graph.nodes) ? graph.nodes : [];
|
|
@@ -1201,6 +1271,9 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1201
1271
|
routes: projected.routes,
|
|
1202
1272
|
schedulerSetting: parse(record.schedulerSetting),
|
|
1203
1273
|
renderCompat,
|
|
1274
|
+
// r85(retro 2026-11-19 issue 09/11):codeType:7 公式口径注记(非侵入,
|
|
1275
|
+
// 不改写公式)。无表达式映射时不出现该键。
|
|
1276
|
+
...((() => { const notes = ruleFormulaNotes(projected.nodes); return notes ? { formulaNotes: notes } : {}; })()),
|
|
1204
1277
|
...(semanticFindings ? { semanticFindings } : {}),
|
|
1205
1278
|
// r73 #2:roundTrip 是显式判定键(safe:true 也在),不是缺键
|
|
1206
1279
|
...(roundTrip ? { roundTrip } : {}),
|
|
@@ -1277,6 +1350,8 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1277
1350
|
nodeGraph: ruleNodeGraphArg,
|
|
1278
1351
|
publish: z.boolean().optional().describe("also publish the new version in this call (businessrule/publish) so the designer sees it; enabling stays with rule.enable — default false keeps the legacy draft-only save"),
|
|
1279
1352
|
allowAdvisory: z.boolean().optional().describe("调查逃生口;默认 false"),
|
|
1353
|
+
allowAbsentMappingFields: z.boolean().optional().describe("逃生阀:codeType:1 映射 bizCode 不在来源模型已发布字段时仍保存(回执 absentMappingFieldsAllowed 点名);默认拒 rule-mapping-field-absent(平台侧不保证拦,运行时静默 null→10005)"),
|
|
1354
|
+
allowDesignerTextOverwrite: z.boolean().optional().describe("逃生阀:覆盖映射现存的设计器公式文本(editorText/editorMark);默认保留现存设计器文本只更新 formula(回执 preservedDesignerText 点名)"),
|
|
1280
1355
|
customTrigger: z.boolean().optional().describe("默认开:自定义 ruleCode + bizRuleType 0(非平台触发码 Create/Update/Delete/GetList/Load/Available/Cancel)即按钮/流程规则,工具在 START 后合成平台标准 CUSTOM_NODE「自定义按钮/流程触发」系统触发节点(nodeCode=ruleCode,live 布局 x558/y233);调用方已写 CUSTOM_NODE 则原样保留;显式 false 退回"),
|
|
1281
1356
|
},
|
|
1282
1357
|
execute: async (session, args) => executeRuleSaveWrite(session, args),
|
|
@@ -1291,6 +1366,13 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1291
1366
|
mode: linted.existing?.id ? "update" : "create",
|
|
1292
1367
|
nodeCount: linted.nodes.length,
|
|
1293
1368
|
routeCount: linted.routes.length,
|
|
1369
|
+
// r85(retro 2026-11-19):dry-run 与真写同源注记。
|
|
1370
|
+
...(linted.routesSource !== undefined ? { routesSource: linted.routesSource, routesNote: "本次未传 routes:将读现行连线沿用(businessrule/get +1 wire)" } : {}),
|
|
1371
|
+
...(linted.emptyMappings.length > 0 ? { emptyMappings: linted.emptyMappings } : {}),
|
|
1372
|
+
...(linted.preservedDesignerText.length > 0 ? { preservedDesignerText: linted.preservedDesignerText } : {}),
|
|
1373
|
+
...(linted.designerTextOverwritten.length > 0 ? { designerTextOverwritten: linted.designerTextOverwritten } : {}),
|
|
1374
|
+
...(linted.mappingFieldChecks > 0 ? { mappingFieldChecks: linted.mappingFieldChecks } : {}),
|
|
1375
|
+
...(linted.absentMappingFields !== undefined ? { absentMappingFieldsAllowed: linted.absentMappingFields } : {}),
|
|
1294
1376
|
publish: args.publish === true,
|
|
1295
1377
|
customTrigger: linted.customTriggerApplied,
|
|
1296
1378
|
...(linted.bizMethodChecks > 0 ? { bizMethodChecks: linted.bizMethodChecks } : {}),
|
package/dist/lanes/rule-graph.js
CHANGED
|
@@ -743,8 +743,16 @@ export function prepareRuleGraph(ruleCode, graph, customTrigger, schemaCode) {
|
|
|
743
743
|
const literal = row.value !== undefined ? row.value : row.expressionValue;
|
|
744
744
|
if (literal === undefined)
|
|
745
745
|
return row;
|
|
746
|
+
const literalText = typeof literal === "string" ? literal : String(literal);
|
|
747
|
+
// r85(issue 04):显式空常量(value:"")归一为 bizCode:""——这是合法的
|
|
748
|
+
// "空映射"形状,不是"值搬移"事件,不告警。
|
|
749
|
+
if (literalText === "") {
|
|
750
|
+
const emptyNext = { ...row, bizCode: "" };
|
|
751
|
+
delete emptyNext.value;
|
|
752
|
+
return emptyNext;
|
|
753
|
+
}
|
|
746
754
|
changed = true;
|
|
747
|
-
const next = { ...row, bizCode:
|
|
755
|
+
const next = { ...row, bizCode: literalText };
|
|
748
756
|
delete next.value;
|
|
749
757
|
return next;
|
|
750
758
|
});
|
|
@@ -1392,16 +1400,24 @@ export function validateMethodMapping(mapping, nodeCode) {
|
|
|
1392
1400
|
blockers.push({ code: "rule-graph-bizaction-mapping-codetype", nodeCode, key: `methodMapping.${listKey}[${index}].codeType`, message: `${listKey}[${index}].codeType 必须是 0-${RULE_CODE_TYPES.length - 1} 的整数(CodeType int 序列化:${RULE_CODE_TYPES.map((t, i) => `${i}=${t}`).join("/")})` });
|
|
1393
1401
|
if (typeof row.serviceMethodParameterCode !== "string" || !row.serviceMethodParameterCode.trim())
|
|
1394
1402
|
blockers.push({ code: "rule-graph-bizaction-mapping-param", nodeCode, key: `methodMapping.${listKey}[${index}].serviceMethodParameterCode`, message: `${listKey}[${index}] 缺 serviceMethodParameterCode(集成方法参数 code;quote 以它对账方法参数表)` });
|
|
1395
|
-
|
|
1396
|
-
|
|
1403
|
+
// r85(retro 2026-11-19 issue 04):显式留空是合法形状——`bizCode:""`(恰好
|
|
1404
|
+
// 空串)在平台侧是"空映射":保存/发布不校验(RuleQuoteImpl.java:193 跳过
|
|
1405
|
+
// 空白),运行时 MapOps 跳过该映射=参数不传(MapOps.java:490-496)。仍拒:
|
|
1406
|
+
// 键缺席(与显式空串语义可区分)、纯空白串(MapOps isEmpty 不跳过、会按
|
|
1407
|
+
// 字段码 " " 求值成 null)、非字符串。
|
|
1408
|
+
if (row.codeType === 1 && row.bizCode !== "" && (typeof row.bizCode !== "string" || !row.bizCode.trim()))
|
|
1409
|
+
blockers.push({ code: "rule-graph-bizaction-mapping-bizcode", nodeCode, key: `methodMapping.${listKey}[${index}].bizCode`, message: `${listKey}[${index}].codeType=1(PROPERTY) 必须带 bizCode(RuleBizActionQuoteImpl 只消费 PROPERTY 映射的 bizCode+propertyName);可选参数显式留空传 bizCode:""(空映射:运行时参数不传,回执 emptyMappings 点名)` });
|
|
1397
1410
|
// CONST(0): the literal value must live in `bizCode` by the time it is
|
|
1398
1411
|
// written (MapOps reads getBizCode for CONST; the designer writes
|
|
1399
1412
|
// componentValue=bizCode). prepareRuleGraph moves a value found under
|
|
1400
1413
|
// `value`/`expressionValue` into bizCode, so accept any of the three here
|
|
1401
1414
|
// and only refuse when the element carries no value at all (which would
|
|
1402
1415
|
// arrive as literal "null" at runtime).
|
|
1403
|
-
|
|
1404
|
-
|
|
1416
|
+
// r85(issue 04):显式空常量合法——bizCode:"" / value:"" 是"空映射"(运行时
|
|
1417
|
+
// MapOps 跳过、参数不传),与"忘了给值"区分开:后者仍拒。
|
|
1418
|
+
const explicitEmptyConst = row.bizCode === "" || row.value === "" || row.expressionValue === "";
|
|
1419
|
+
if (row.codeType === 0 && !explicitEmptyConst && !(typeof row.bizCode === "string" && row.bizCode.trim()) && row.value === undefined && row.expressionValue === undefined)
|
|
1420
|
+
blockers.push({ code: "rule-graph-bizaction-mapping-const-value", nodeCode, key: `methodMapping.${listKey}[${index}].bizCode`, message: `${listKey}[${index}].codeType=0(CONST) 缺常量值——放 bizCode(或 value,工具会移入 bizCode);平台 CONST 只读 bizCode,缺值运行时会取到字面 null。可选参数显式留空传 bizCode:""(空映射:运行时参数不传)` });
|
|
1405
1421
|
// EXPRESSION(7) — 入参「计算规则」:MapOps INPUT 方向对 CodeType.CONST /
|
|
1406
1422
|
// CodeType.EXPRESSION 都取 `getBizMethodValue`/`getExpressionValue`
|
|
1407
1423
|
// (MapOps.java:510-541),Mapping.expressionValue 是 Object、平台原样透传。
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ENDPOINTS } from "../endpoints.js";
|
|
4
|
+
import { capabilityArg, environmentArg } from "../args.js";
|
|
5
|
+
import { governedRead } from "../read.js";
|
|
6
|
+
import { writeArtifact } from "../support.js";
|
|
7
|
+
import { defineTool, ToolRefusalError } from "../tool-types.js";
|
|
8
|
+
import { wireCallWith404Fallback } from "../wire.js";
|
|
9
|
+
import { B2_LANE_CONTRACT } from "./b2-registration-contract.js";
|
|
10
|
+
/**
|
|
11
|
+
* Business-service invocation logs (`h_log_biz_service`) — the only place that
|
|
12
|
+
* records what a rule actually sent to an integration endpoint (params), what
|
|
13
|
+
* came back (result) and whether it failed (bizServiceStatus). Wire facts live
|
|
14
|
+
* in B2_LANE_CONTRACT.wire.logFace; the short version:
|
|
15
|
+
*
|
|
16
|
+
* GET /api/log/list_bizservicelog?code&methodName&dataTitle&startTime&endTime&page&size&status
|
|
17
|
+
*
|
|
18
|
+
* `page` is REQUIRED and 0-based (LogManagerController.java:239). The server
|
|
19
|
+
* filters code/methodName as LIKE-contains (comma → IN), dataTitle likewise,
|
|
20
|
+
* `startTime >= startTime` AND `endTime <= endTime`, and always orders
|
|
21
|
+
* startTime DESC. schemaCode/bizObjectId are NOT query parameters on this face
|
|
22
|
+
* (BizServiceLogModel carries them on the row; the controller ignores them), so
|
|
23
|
+
* those two selectors are matched client-side over a bounded number of wire
|
|
24
|
+
* pages and the scan accounting is reported instead of pretending a full scan.
|
|
25
|
+
*
|
|
26
|
+
* A log table grows without bound; an unfiltered query is exactly the 60s
|
|
27
|
+
* socket-timeout trap the manual JDBC route hit. So the tool is fail-closed:
|
|
28
|
+
* no selector → refusal, and the time window defaults to the last 60 minutes.
|
|
29
|
+
*/
|
|
30
|
+
const DEFAULT_WINDOW_MINUTES = 60;
|
|
31
|
+
const DEFAULT_LIMIT = 20;
|
|
32
|
+
const MAX_LIMIT = 100;
|
|
33
|
+
/** Client-side matching (schemaCode/bizObjectId) reads at most this many wire pages. */
|
|
34
|
+
const CLIENT_FILTER_SCAN_PAGES = 5;
|
|
35
|
+
/** One-line params/result summary length. */
|
|
36
|
+
const SUMMARY_CHARS = 240;
|
|
37
|
+
/** Full params/result payloads above this size go to an artifact file. */
|
|
38
|
+
const FULL_PAYLOAD_ARTIFACT_BYTES = 4096;
|
|
39
|
+
const TIME_PATTERN = /^\d{4}-\d{2}-\d{2}(?:[ T]\d{2}:\d{2}(?::\d{2})?)?$/;
|
|
40
|
+
const B2_LANE = B2_LANE_CONTRACT.lane;
|
|
41
|
+
const B2_TOOLS = B2_LANE_CONTRACT.tools;
|
|
42
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
43
|
+
/** Platform-local wall clock (the log columns are wall-clock strings, no TZ). */
|
|
44
|
+
function formatLocal(date) {
|
|
45
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
46
|
+
}
|
|
47
|
+
/** Best-effort parse of the same shapes the wire accepts (date or 19-char datetime). */
|
|
48
|
+
function parseLocal(value) {
|
|
49
|
+
const match = value.match(/^(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/);
|
|
50
|
+
if (!match)
|
|
51
|
+
return undefined;
|
|
52
|
+
const [, year, month, day, hour, minute, second] = match;
|
|
53
|
+
return new Date(Number(year), Number(month) - 1, Number(day), Number(hour ?? 0), Number(minute ?? 0), Number(second ?? 0));
|
|
54
|
+
}
|
|
55
|
+
/** `T` is accepted on input; the platform's DateUtility expects a space. */
|
|
56
|
+
const wireTime = (value) => value.replace("T", " ");
|
|
57
|
+
/** Single-line summary of a free-form log column, with the original byte size. */
|
|
58
|
+
function summarize(value) {
|
|
59
|
+
if (value === null || value === undefined)
|
|
60
|
+
return { text: null, bytes: 0, truncated: false };
|
|
61
|
+
const full = typeof value === "string" ? value : JSON.stringify(value);
|
|
62
|
+
const bytes = Buffer.byteLength(full, "utf8");
|
|
63
|
+
const oneLine = full.replace(/\s+/g, " ").trim();
|
|
64
|
+
if (oneLine.length <= SUMMARY_CHARS)
|
|
65
|
+
return { text: oneLine, bytes, truncated: false };
|
|
66
|
+
return { text: `${oneLine.slice(0, SUMMARY_CHARS)}…`, bytes, truncated: true };
|
|
67
|
+
}
|
|
68
|
+
const RULE_KEYS = ["ruleCode", "ruleName", "nodeCode", "nodeName"];
|
|
69
|
+
/** extensionLog is the caller-supplied trace context (rule/node) in the usual case. */
|
|
70
|
+
function ruleOf(raw) {
|
|
71
|
+
if (raw === null || raw === undefined)
|
|
72
|
+
return undefined;
|
|
73
|
+
const text = typeof raw === "string" ? raw : JSON.stringify(raw);
|
|
74
|
+
if (!text)
|
|
75
|
+
return undefined;
|
|
76
|
+
try {
|
|
77
|
+
const parsed = JSON.parse(text);
|
|
78
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
79
|
+
const picked = {};
|
|
80
|
+
for (const key of RULE_KEYS) {
|
|
81
|
+
const value = parsed[key];
|
|
82
|
+
if (typeof value === "string" && value.length > 0)
|
|
83
|
+
picked[key] = value;
|
|
84
|
+
}
|
|
85
|
+
if (Object.keys(picked).length > 0)
|
|
86
|
+
return picked;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Fall through: an unparseable extensionLog is still evidence — surface it
|
|
91
|
+
// as a truncated raw string rather than dropping it.
|
|
92
|
+
}
|
|
93
|
+
return { raw: summarize(text).text ?? text };
|
|
94
|
+
}
|
|
95
|
+
const statusOf = (value) => {
|
|
96
|
+
if (value === 1 || value === "1" || value === "FAILURE")
|
|
97
|
+
return { status: "failure", statusName: "失败" };
|
|
98
|
+
if (value === 2 || value === "2" || value === "SUCCESS")
|
|
99
|
+
return { status: "success", statusName: "成功" };
|
|
100
|
+
return { status: null };
|
|
101
|
+
};
|
|
102
|
+
export function registerServiceLogLane(tools) {
|
|
103
|
+
tools.push(defineTool({
|
|
104
|
+
name: "servicelog.search",
|
|
105
|
+
layer: "low",
|
|
106
|
+
kind: "read",
|
|
107
|
+
lane: B2_LANE,
|
|
108
|
+
search: {
|
|
109
|
+
intents: [
|
|
110
|
+
"业务服务日志", "业务服务调用日志", "服务调用日志", "接口调用日志", "调用记录",
|
|
111
|
+
"接口调用记录", "调接口记录", "业务集成日志", "规则传了什么参数", "规则到底传了什么参数",
|
|
112
|
+
"接口传了什么参数", "接口返回了什么",
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
scope: B2_TOOLS["servicelog.search"].scope,
|
|
116
|
+
description: B2_TOOLS["servicelog.search"].description,
|
|
117
|
+
inputSchema: {
|
|
118
|
+
environment: environmentArg,
|
|
119
|
+
code: z.string().min(1).optional().describe("业务服务编码(服务侧叫 serviceCode);平台按 LIKE 包含匹配,逗号分隔=精确 IN"),
|
|
120
|
+
methodName: z.string().min(1).optional().describe("业务方法名(LIKE 包含;逗号分隔=精确 IN)"),
|
|
121
|
+
dataTitle: z.string().min(1).optional().describe("数据标题(LIKE 包含)"),
|
|
122
|
+
schemaCode: z.string().min(1).optional().describe("模型编码:平台列表端点没有这个过滤参数,本工具在扫描页内客户端精确匹配"),
|
|
123
|
+
bizObjectId: z.string().min(1).optional().describe("业务对象 id:同上,客户端精确匹配(规则排查最常用)"),
|
|
124
|
+
status: z.union([z.literal(0), z.literal(1), z.literal(2)]).optional().describe("1=失败 2=成功 0=全部(平台只有成功/失败两态)"),
|
|
125
|
+
startTime: z.string().regex(TIME_PATTERN).optional().describe("开始时间:yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss(平台按 startTime>= 过滤)"),
|
|
126
|
+
endTime: z.string().regex(TIME_PATTERN).optional().describe("结束时间:同上(平台按 endTime<= 过滤)"),
|
|
127
|
+
minutes: z.number().int().min(1).max(1440).optional().describe(`未给时间时向前取多少分钟(默认 ${DEFAULT_WINDOW_MINUTES})`),
|
|
128
|
+
limit: z.number().int().min(1).max(MAX_LIMIT).optional().describe(`每页条数(默认 ${DEFAULT_LIMIT},上限 ${MAX_LIMIT})`),
|
|
129
|
+
page: z.number().int().min(0).optional().describe("wire 页码,从 0 开始(时间倒序的第几页)"),
|
|
130
|
+
capability: capabilityArg,
|
|
131
|
+
},
|
|
132
|
+
handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
|
133
|
+
const hasSelector = args.code !== undefined || args.methodName !== undefined || args.dataTitle !== undefined
|
|
134
|
+
|| args.schemaCode !== undefined || args.bizObjectId !== undefined;
|
|
135
|
+
if (!hasSelector) {
|
|
136
|
+
throw new ToolRefusalError({
|
|
137
|
+
status: "refused",
|
|
138
|
+
blocker: "servicelog-filter-required",
|
|
139
|
+
message: "没有任何过滤条件——业务服务日志表会无限增长,无过滤查询正是全表扫描超时的来源;本工具 fail-closed,不提供「查全部」。至少给 code / methodName / dataTitle / schemaCode / bizObjectId 之一(时间窗默认最近 60 分钟,也可传 startTime/endTime 或 minutes)。",
|
|
140
|
+
nextCommand: `omc call servicelog.search --args '{"bizObjectId":"<单据id>","minutes":60}'`,
|
|
141
|
+
examples: [
|
|
142
|
+
{ why: "规则给这个单据调过哪些接口、传了什么参数", args: { bizObjectId: "<bizObjectId>" } },
|
|
143
|
+
{ why: "某个集成服务最近一小时的失败调用", args: { code: "<服务编码>", status: 1, minutes: 60 } },
|
|
144
|
+
{ why: "按模型 + 方法名缩小", args: { schemaCode: "<模型code>", methodName: "<方法名>", startTime: "2026-01-01 00:00:00", endTime: "2026-01-01 23:59:59" } },
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const limit = args.limit ?? DEFAULT_LIMIT;
|
|
149
|
+
const startPage = args.page ?? 0;
|
|
150
|
+
const minutes = args.minutes ?? DEFAULT_WINDOW_MINUTES;
|
|
151
|
+
const now = new Date();
|
|
152
|
+
let startTime = args.startTime;
|
|
153
|
+
let endTime = args.endTime;
|
|
154
|
+
let windowSource;
|
|
155
|
+
if (startTime === undefined && endTime === undefined) {
|
|
156
|
+
startTime = formatLocal(new Date(now.getTime() - minutes * 60_000));
|
|
157
|
+
endTime = formatLocal(now);
|
|
158
|
+
windowSource = "default";
|
|
159
|
+
}
|
|
160
|
+
else if (startTime !== undefined && endTime === undefined) {
|
|
161
|
+
endTime = formatLocal(now);
|
|
162
|
+
windowSource = "explicit-start";
|
|
163
|
+
}
|
|
164
|
+
else if (startTime === undefined && endTime !== undefined) {
|
|
165
|
+
const end = parseLocal(endTime);
|
|
166
|
+
startTime = formatLocal(new Date((end ?? now).getTime() - minutes * 60_000));
|
|
167
|
+
windowSource = "explicit-end";
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
windowSource = "explicit";
|
|
171
|
+
}
|
|
172
|
+
const clientFilter = args.schemaCode !== undefined || args.bizObjectId !== undefined;
|
|
173
|
+
const fetchPage = async (page) => {
|
|
174
|
+
const query = {
|
|
175
|
+
page: String(page),
|
|
176
|
+
size: String(limit),
|
|
177
|
+
startTime: wireTime(startTime),
|
|
178
|
+
endTime: wireTime(endTime),
|
|
179
|
+
};
|
|
180
|
+
if (args.code !== undefined)
|
|
181
|
+
query.code = args.code;
|
|
182
|
+
if (args.methodName !== undefined)
|
|
183
|
+
query.methodName = args.methodName;
|
|
184
|
+
if (args.dataTitle !== undefined)
|
|
185
|
+
query.dataTitle = args.dataTitle;
|
|
186
|
+
// status=0 is the平台「全部」值; omitting it keeps the query identical.
|
|
187
|
+
if (args.status !== undefined && args.status !== 0)
|
|
188
|
+
query.status = String(args.status);
|
|
189
|
+
let endpointFamily;
|
|
190
|
+
const result = await wireCallWith404Fallback(session, [
|
|
191
|
+
{ path: ENDPOINTS.bizServiceLogList, query },
|
|
192
|
+
{ path: ENDPOINTS.bizServiceLogListSinglePrefix, query },
|
|
193
|
+
], (failed, next) => { endpointFamily = { used: next.path, reason: `${failed.path} HTTP 404(该部署只在单前缀挂载日志控制器,已下探)` }; });
|
|
194
|
+
const envelope = result.data;
|
|
195
|
+
const content = envelope && Array.isArray(envelope.content)
|
|
196
|
+
? envelope.content.filter((row) => Boolean(row) && typeof row === "object")
|
|
197
|
+
: [];
|
|
198
|
+
return {
|
|
199
|
+
content,
|
|
200
|
+
totalElements: typeof envelope?.totalElements === "number" ? envelope.totalElements : null,
|
|
201
|
+
totalPages: typeof envelope?.totalPages === "number" ? envelope.totalPages : null,
|
|
202
|
+
endpointFamily,
|
|
203
|
+
path: result.path,
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
const matches = (row) => (args.schemaCode === undefined || row.schemaCode === args.schemaCode)
|
|
207
|
+
&& (args.bizObjectId === undefined || row.bizObjectId === args.bizObjectId);
|
|
208
|
+
let rows = [];
|
|
209
|
+
let totalElements = null;
|
|
210
|
+
let totalPages = null;
|
|
211
|
+
let wireCalls = 0;
|
|
212
|
+
let rowsFetched = 0;
|
|
213
|
+
let endpointFamily;
|
|
214
|
+
let usedPath = ENDPOINTS.bizServiceLogList;
|
|
215
|
+
let rowFilter;
|
|
216
|
+
if (!clientFilter) {
|
|
217
|
+
const page = await fetchPage(startPage);
|
|
218
|
+
wireCalls = 1;
|
|
219
|
+
rowsFetched = page.content.length;
|
|
220
|
+
rows = page.content;
|
|
221
|
+
totalElements = page.totalElements;
|
|
222
|
+
totalPages = page.totalPages;
|
|
223
|
+
endpointFamily = page.endpointFamily;
|
|
224
|
+
usedPath = page.path;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
// Wire paging is startTime DESC; scan a bounded page window from `page`
|
|
228
|
+
// and match the two row-only selectors locally. `exhausted:false` says
|
|
229
|
+
// the scan stopped before the end — never read it as "no such call".
|
|
230
|
+
const matched = [];
|
|
231
|
+
let scannedPages = 0;
|
|
232
|
+
let scannedElements = 0;
|
|
233
|
+
let exhausted = false;
|
|
234
|
+
let moreLikely = false;
|
|
235
|
+
for (let offset = 0; offset < CLIENT_FILTER_SCAN_PAGES; offset += 1) {
|
|
236
|
+
const page = await fetchPage(startPage + offset);
|
|
237
|
+
wireCalls += 1;
|
|
238
|
+
scannedPages += 1;
|
|
239
|
+
totalElements = page.totalElements;
|
|
240
|
+
totalPages = page.totalPages;
|
|
241
|
+
endpointFamily = page.endpointFamily ?? endpointFamily;
|
|
242
|
+
usedPath = page.path;
|
|
243
|
+
scannedElements += page.content.length;
|
|
244
|
+
rowsFetched += page.content.length;
|
|
245
|
+
for (const row of page.content)
|
|
246
|
+
if (matches(row))
|
|
247
|
+
matched.push(row);
|
|
248
|
+
if (matched.length >= limit) {
|
|
249
|
+
moreLikely = true;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
const noNextPage = page.totalPages !== null && startPage + offset + 1 >= page.totalPages;
|
|
253
|
+
if (page.content.length < limit || noNextPage) {
|
|
254
|
+
exhausted = true;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
rows = matched.slice(0, limit);
|
|
259
|
+
rowFilter = {
|
|
260
|
+
...(args.schemaCode !== undefined ? { schemaCode: args.schemaCode } : {}),
|
|
261
|
+
...(args.bizObjectId !== undefined ? { bizObjectId: args.bizObjectId } : {}),
|
|
262
|
+
matched: matched.length,
|
|
263
|
+
returned: rows.length,
|
|
264
|
+
scannedPages,
|
|
265
|
+
scannedElements,
|
|
266
|
+
exhausted,
|
|
267
|
+
...(moreLikely ? { moreLikely: true } : {}),
|
|
268
|
+
...(matched.length > rows.length ? { truncatedMatches: matched.length - rows.length } : {}),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const full = [];
|
|
272
|
+
let fullPayloadBytes = 0;
|
|
273
|
+
const logs = rows.map((row) => {
|
|
274
|
+
const params = summarize(row.params);
|
|
275
|
+
const result = summarize(row.result);
|
|
276
|
+
const detail = typeof row.detail === "string" && row.detail.length > 0 ? summarize(row.detail) : undefined;
|
|
277
|
+
fullPayloadBytes += params.bytes + result.bytes;
|
|
278
|
+
full.push({ id: row.id ?? null, startTime: row.startTime ?? null, code: row.code ?? null, methodName: row.methodName ?? null, params: row.params ?? null, result: row.result ?? null });
|
|
279
|
+
const status = statusOf(row.bizServiceStatus);
|
|
280
|
+
const rule = ruleOf(row.extensionLog);
|
|
281
|
+
return {
|
|
282
|
+
startTime: row.startTime ?? null,
|
|
283
|
+
...(typeof row.endTime === "string" && row.endTime !== row.startTime ? { endTime: row.endTime } : {}),
|
|
284
|
+
usedTime: row.usedTime ?? null,
|
|
285
|
+
code: row.code ?? null,
|
|
286
|
+
methodName: row.methodName ?? null,
|
|
287
|
+
status: status.status,
|
|
288
|
+
...(typeof row.bizServiceStatusName === "string" ? { statusName: row.bizServiceStatusName } : {}),
|
|
289
|
+
dataTitle: row.dataTitle ?? null,
|
|
290
|
+
schemaCode: row.schemaCode ?? null,
|
|
291
|
+
bizObjectId: row.bizObjectId ?? null,
|
|
292
|
+
...(rule ? { rule } : {}),
|
|
293
|
+
params: params.text,
|
|
294
|
+
paramsBytes: params.bytes,
|
|
295
|
+
...(params.truncated ? { paramsTruncated: true } : {}),
|
|
296
|
+
result: result.text,
|
|
297
|
+
resultBytes: result.bytes,
|
|
298
|
+
...(result.truncated ? { resultTruncated: true } : {}),
|
|
299
|
+
...(detail ? { detail: detail.text, ...(detail.truncated ? { detailTruncated: true } : {}) } : {}),
|
|
300
|
+
};
|
|
301
|
+
});
|
|
302
|
+
// Full params/result over the threshold leave the envelope; the summary
|
|
303
|
+
// above already answers "what did the rule send" for normal payloads.
|
|
304
|
+
let payload;
|
|
305
|
+
if (fullPayloadBytes > FULL_PAYLOAD_ARTIFACT_BYTES) {
|
|
306
|
+
const artifact = writeArtifact(ctx, `servicelog-${randomUUID().slice(0, 8)}.json`, {
|
|
307
|
+
window: { startTime, endTime },
|
|
308
|
+
rows: full,
|
|
309
|
+
});
|
|
310
|
+
payload = {
|
|
311
|
+
payloadFile: artifact.detailFile,
|
|
312
|
+
payloadSha256: artifact.detailSha256,
|
|
313
|
+
payloadBytes: fullPayloadBytes,
|
|
314
|
+
payloadHint: `完整 params/result 共 ${fullPayloadBytes}B 已外置(单行摘要见 logs);用 jq 定向取回(例如 jq '.rows[0].params' <payloadFile>),勿整份读入。params 侧平台入库上限 2000 字符。`,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
const returned = logs.length;
|
|
318
|
+
const hasMore = clientFilter
|
|
319
|
+
? (rowFilter?.exhausted === false || rowFilter?.moreLikely === true)
|
|
320
|
+
: (totalPages !== null ? startPage + wireCalls < totalPages : null);
|
|
321
|
+
const nextPage = clientFilter
|
|
322
|
+
? (rowFilter?.exhausted === false && rowFilter.moreLikely !== true ? startPage + wireCalls : undefined)
|
|
323
|
+
: (hasMore === true ? startPage + 1 : undefined);
|
|
324
|
+
const notes = [
|
|
325
|
+
"服务端过滤 code/methodName(LIKE 包含,逗号=精确 IN)、dataTitle、时间(startTime>= 且 endTime<= 两列)、status;schemaCode/bizObjectId 不在平台列表参数里,本工具在扫描页内客户端匹配。",
|
|
326
|
+
"日志异步落库(刚触发的调用可能晚数秒才可见);历史按平台保留天数清理。params 入库上限 2000 字符(更长的部分平台已截断),result 无此上限但可能很大。",
|
|
327
|
+
windowSource === "default"
|
|
328
|
+
? `未给时间,默认窗口最近 ${minutes} 分钟(本机时钟,与平台同时区才可直接用;跨时区请显式 startTime/endTime)。`
|
|
329
|
+
: "时间窗为显式传入(按字符串原样上送;平台按 startTime>=、endTime<= 两列过滤)。",
|
|
330
|
+
...(clientFilter ? [`schemaCode/bizObjectId 是客户端匹配:最多扫 ${CLIENT_FILTER_SCAN_PAGES} 个 wire 页(约 ${limit * CLIENT_FILTER_SCAN_PAGES} 行),exhausted:false 表示扫描被上限截断——未命中不代表没有更早的调用。`] : []),
|
|
331
|
+
...(typeof rowFilter?.truncatedMatches === "number" ? [`扫描到的命中数(${String(rowFilter.matched)})超过 limit,只回前 ${returned} 条——提高 limit 重查;page 是 wire 页码(时间倒序),不是命中偏移。`] : []),
|
|
332
|
+
...(endpointFamily ? [`端点下探:${endpointFamily.reason}`] : []),
|
|
333
|
+
...(payload ? [payload.payloadHint] : []),
|
|
334
|
+
];
|
|
335
|
+
const emptyHint = returned === 0
|
|
336
|
+
? "0 条先核对:① code 是 LIKE 包含匹配(crm_expiry 能命中 crm_expiry_service);② 日志异步落库,稍后重试;③ 时间窗/时区是否覆盖到;④ schemaCode/bizObjectId 是客户端匹配、且扫描有页数上限。"
|
|
337
|
+
: undefined;
|
|
338
|
+
return {
|
|
339
|
+
window: { startTime, endTime, minutes, source: windowSource },
|
|
340
|
+
filters: {
|
|
341
|
+
...(args.code !== undefined ? { code: args.code } : {}),
|
|
342
|
+
...(args.methodName !== undefined ? { methodName: args.methodName } : {}),
|
|
343
|
+
...(args.dataTitle !== undefined ? { dataTitle: args.dataTitle } : {}),
|
|
344
|
+
...(args.status !== undefined ? { status: args.status } : {}),
|
|
345
|
+
...(args.schemaCode !== undefined ? { schemaCode: args.schemaCode } : {}),
|
|
346
|
+
...(args.bizObjectId !== undefined ? { bizObjectId: args.bizObjectId } : {}),
|
|
347
|
+
},
|
|
348
|
+
paging: {
|
|
349
|
+
page: startPage,
|
|
350
|
+
size: limit,
|
|
351
|
+
totalElements,
|
|
352
|
+
totalPages,
|
|
353
|
+
returned,
|
|
354
|
+
hasMore,
|
|
355
|
+
...(nextPage !== undefined ? { nextPage } : {}),
|
|
356
|
+
...(nextPage !== undefined ? { nextCommand: `omc call servicelog.search --args '${JSON.stringify({ ...plannableFilters(args), page: nextPage })}'` } : {}),
|
|
357
|
+
},
|
|
358
|
+
...(rowFilter ? { rowFilter } : {}),
|
|
359
|
+
logs,
|
|
360
|
+
...(emptyHint ? { emptyHint } : {}),
|
|
361
|
+
notes,
|
|
362
|
+
wire: { path: usedPath, calls: wireCalls, rowsFetched },
|
|
363
|
+
...(payload ?? {}),
|
|
364
|
+
};
|
|
365
|
+
}, { target: `servicelog.search:${JSON.stringify(args)}` }),
|
|
366
|
+
}));
|
|
367
|
+
}
|
|
368
|
+
/** Echo the human filters into the copyable next command (never the paging/window defaults). */
|
|
369
|
+
function plannableFilters(args) {
|
|
370
|
+
const picked = {};
|
|
371
|
+
for (const key of ["code", "methodName", "dataTitle", "status", "schemaCode", "bizObjectId", "startTime", "endTime", "limit"])
|
|
372
|
+
if (args[key] !== undefined)
|
|
373
|
+
picked[key] = args[key];
|
|
374
|
+
return picked;
|
|
375
|
+
}
|
|
376
|
+
//# sourceMappingURL=servicelog.js.map
|
|
@@ -69,6 +69,7 @@ export const WORKFLOW_WIRE = Object.freeze({
|
|
|
69
69
|
authoringChain: "workflow.create (header) → workflow.update (write draft template) → workflow.publish",
|
|
70
70
|
bindPoint: "startEventHandler|cancelEventHandler|activateEventHandler|endEventHandler{bizActions:[<ruleCode>], bizActionType:\"BIZ_RULE\"} (flow level; NODE level = activities[<activityCode>].{beforeActivate|afterActivate|endActivity|cancelActivity|activityApproved|activityRejected|jobSubmitted|jobRejected} with the same ActivityEventHandler shape)",
|
|
71
71
|
bindRuleChain: "workflow.bindRule reads the draft, merges the handler selected by `handler` (start|cancel|activate|end, default end — flow level) or by `activityCode` + `nodeEvent` (node level), workflow/update, then workflow/publish + published-face readback",
|
|
72
|
+
unbindRuleChain: "workflow.unbindRule mirrors workflow.bindRule's two target forms and REMOVES the listed ruleCodes from the handler's bizActions (others preserved); an emptied handler is written back as the platform's canonical unbound shape — handler object kept, bizActions/bizActionType null (WorkflowTemplateController's own template JSON; CollectionUtils.isEmpty treats null and [] alike). Absent codes are refused with the handler's existing codes (workflow-unbind-rule-absent). It NEVER disables the rule (it may be bound elsewhere — check rule.references kind=rule first).",
|
|
72
73
|
renderCompat: "workflow.update/publish/bindRule fail closed on 8.6.26 ActivityType values, unique non-empty activityCode values, rules references, and non-empty `x, y` points; missing points are derived from activity geometry and every write readback carries workflowRenderCompat with activities, rules, START/END, points, and danglingViolations",
|
|
73
74
|
bindRuleScope: "flow level: all four WorkflowTemplateModel event handlers (startEventHandler/cancelEventHandler/activateEventHandler/endEventHandler), each an ActivityEventHandler carrying bizActions + bizActionType=BIZ_RULE; `handler` defaults to end. node level: the eight ActivityEventHandler fields on each activity row (beforeActivate/afterActivate/endActivity/cancelActivity/activityApproved/activityRejected/jobSubmitted/jobRejected), selected by `activityCode` + `nodeEvent`",
|
|
74
75
|
boundRuleMustBeEnabled: "流程事件绑定的规则**必须启用**:禁用/未发布的规则(rule.save 落 DRAFT/DISABLED 态)绑到事件处理器后设计器显示「失效·未启用」且事件不会执行它(真机 2026-10-08 SCM 沙盒)。workflow.bindRule 会先把绑定的自定义规则 publish+enable(rule.enable 链,回读 enabledRuleCodes/alreadyEnabledRuleCodes),并对不存在的 code 报 workflow-bind-rule-absent",
|
|
@@ -108,6 +109,7 @@ export const WORKFLOW_LANE_CONTRACT = Object.freeze({
|
|
|
108
109
|
authoringChain: WORKFLOW_WIRE.authoringChain,
|
|
109
110
|
bindPoint: WORKFLOW_WIRE.bindPoint,
|
|
110
111
|
bindRuleChain: WORKFLOW_WIRE.bindRuleChain,
|
|
112
|
+
unbindRuleChain: WORKFLOW_WIRE.unbindRuleChain,
|
|
111
113
|
renderCompat: WORKFLOW_WIRE.renderCompat,
|
|
112
114
|
bindRuleScope: WORKFLOW_WIRE.bindRuleScope,
|
|
113
115
|
boundRuleMustBeEnabled: WORKFLOW_WIRE.boundRuleMustBeEnabled,
|
|
@@ -128,6 +130,7 @@ export const WORKFLOW_LANE_CONTRACT = Object.freeze({
|
|
|
128
130
|
authoringChain: Object.freeze([behaviorBinding("test/ticket-112-workflow-template-merge.test.ts#workflow.publish also merges onto the draft", assertWorkflowContract)]),
|
|
129
131
|
bindPoint: Object.freeze([emitterBinding("lanes/workflow-contract.WORKFLOW_EVENT_HANDLER_FIELDS", assertWorkflowContract)]),
|
|
130
132
|
bindRuleChain: Object.freeze([behaviorBinding("test/issue-14-workflow-bind-rule.test.ts#workflow.bindRule merges endEventHandler", assertWorkflowContract)]),
|
|
133
|
+
unbindRuleChain: Object.freeze([behaviorBinding("test/r85-workflow-unbind.test.ts#r85 unbind:flow 级解绑——命中/保留他绑/移空 canonical 态/absent 拒(issue 01)", assertWorkflowContract)]),
|
|
131
134
|
renderCompat: Object.freeze([behaviorBinding("test/ticket-112-workflow-template-merge.test.ts#workflow shorthand maps legal activities and derives points into workflowRenderCompat", assertWorkflowContract)]),
|
|
132
135
|
bindRuleScope: Object.freeze([behaviorBinding("test/issue-14-workflow-bind-rule.test.ts#workflow.bindRule binds start/cancel/end handlers independently", assertWorkflowContract)]),
|
|
133
136
|
boundRuleMustBeEnabled: Object.freeze([behaviorBinding("test/issue-14-workflow-bind-rule.test.ts#workflow.bindRule ENABLES a bound custom rule", assertWorkflowContract)]),
|
|
@@ -154,7 +157,7 @@ export const WORKFLOW_LANE_CONTRACT = Object.freeze({
|
|
|
154
157
|
}),
|
|
155
158
|
"workflow.get_published": Object.freeze({
|
|
156
159
|
scope: WORKFLOW_SCOPE,
|
|
157
|
-
description: "Read the current PUBLISHED workflow template (`/api/api/workflow/get_published`). **默认返回 workflowSummary(activities + ruleBindings),不是整份正文**;节点级规则绑定按活动投影在 `workflowSummary.activities[].bizActions`({节点事件:[规则码]};流程级看 ruleBindings
|
|
160
|
+
description: "Read the current PUBLISHED workflow template (`/api/api/workflow/get_published`). **默认返回 workflowSummary(activities + ruleBindings),不是整份正文**;节点级规则绑定按活动投影在 `workflowSummary.activities[].bizActions`({节点事件:[规则码]};流程级看 ruleBindings),SYSTEM_ACTIVITY 顶层绑定(规则绑在系统活动节点本身、激活时执行)看 `activities[].systemBizActions`——三个面看完再下「没绑」结论。完整正文加 --full,或 `--jq 'data.activities[code=<活动>].<节点事件>.bizActions'` 这类**叶子**路径——对父节点 data.activities 取值会再次被折叠。在 workflow.publish / workflow.bindRule 之后用它确认发布后的绑定点。",
|
|
158
161
|
}),
|
|
159
162
|
// R79 三期 T-A:应用内流程清单(注意:不能放在 tools 的首位——
|
|
160
163
|
// lane-contracts 的 assertDescriptionsDerive 用首个 tool 的 scope 匹配契约
|
|
@@ -181,7 +184,11 @@ export const WORKFLOW_LANE_CONTRACT = Object.freeze({
|
|
|
181
184
|
}),
|
|
182
185
|
"workflow.bindRule": Object.freeze({
|
|
183
186
|
scope: WORKFLOW_SCOPE,
|
|
184
|
-
description: "Bind a business rule to one of a workflow's event handlers (BIZ_RULE). **Flow level**: `handler` = `start`→startEventHandler, `cancel`→cancelEventHandler, `activate`→activateEventHandler, `end`→endEventHandler (default `end`). **Node level**(节点级事件): pass `activityCode` + `nodeEvent` instead of `handler`, one of `beforeActivate|afterActivate|endActivity|cancelActivity|activityApproved|activityRejected|jobSubmitted|jobRejected` (e.g. `{activityCode:\"Activity2\",nodeEvent:\"endActivity\"}` = 申请人提交离开该节点时). The two forms are mutually exclusive; `nodeEvent` without `activityCode`, or a code absent from the draft, is refused with the available codes. Reads the draft, merges `{ bizActions:[<ruleCode>], bizActionType:\"BIZ_RULE\" }` into the selected handler(节点级写到 `activities[i][nodeEvent]`,其余字段原样保留), writes via `/api/api/workflow/update`, publishes, and reads back the published face. **A workflow-bound rule MUST be enabled**(rule.save 落 DRAFT/DISABLED 的规则绑上后设计器显示「失效·未启用」且事件不执行它):本工具先把自定义规则 publish+enable,回读 `enabledRuleCodes`/`alreadyEnabledRuleCodes`;不存在的 code 报 `workflow-bind-rule-absent`。四个 flow handler 是 WorkflowTemplateModel 上同构的 ActivityEventHandler 字段。Pass `publish:false` to leave the template draft-only.",
|
|
187
|
+
description: "Bind a business rule to one of a workflow's event handlers (BIZ_RULE). **Flow level**: `handler` = `start`→startEventHandler, `cancel`→cancelEventHandler, `activate`→activateEventHandler, `end`→endEventHandler (default `end`). **Node level**(节点级事件): pass `activityCode` + `nodeEvent` instead of `handler`, one of `beforeActivate|afterActivate|endActivity|cancelActivity|activityApproved|activityRejected|jobSubmitted|jobRejected` (e.g. `{activityCode:\"Activity2\",nodeEvent:\"endActivity\"}` = 申请人提交离开该节点时). The two forms are mutually exclusive; `nodeEvent` without `activityCode`, or a code absent from the draft, is refused with the available codes. Reads the draft, merges `{ bizActions:[<ruleCode>], bizActionType:\"BIZ_RULE\" }` into the selected handler(节点级写到 `activities[i][nodeEvent]`,其余字段原样保留), writes via `/api/api/workflow/update`, publishes, and reads back the published face. **A workflow-bound rule MUST be enabled**(rule.save 落 DRAFT/DISABLED 的规则绑上后设计器显示「失效·未启用」且事件不执行它):本工具先把自定义规则 publish+enable,回读 `enabledRuleCodes`/`alreadyEnabledRuleCodes`;不存在的 code 报 `workflow-bind-rule-absent`。四个 flow handler 是 WorkflowTemplateModel 上同构的 ActivityEventHandler 字段。Pass `publish:false` to leave the template draft-only. 误绑撤销用 `workflow.unbindRule`(镜像本工具的两种目标形态做减法)。",
|
|
188
|
+
}),
|
|
189
|
+
"workflow.unbindRule": Object.freeze({
|
|
190
|
+
scope: WORKFLOW_SCOPE,
|
|
191
|
+
description: "Unbind business rules from a workflow event handler — the inverse of `workflow.bindRule`(bindRule 是 merge 语义,误绑此前只能导出整模板手改回写). Same two target forms: `handler`(flow 级 start|cancel|activate|end,缺省 end)或 `activityCode` + `nodeEvent`(八节点事件,与 bindRule 同枚举),二选一。从目标 handler 的 bizActions 里**只移除列出的 ruleCode(s)**,其余绑定原样保留;移空后按平台 canonical 未绑态写回(handler 对象保留、bizActions/bizActionType 置 null——平台判空 null 与 [] 等价)。ruleCode 不在该 handler 时报 `workflow-unbind-rule-absent`(带现有 codes)。**不自动 disable 规则**——规则可能还被其它流程/事件绑定着;确认无引用先 `rule.references kind=rule`,要停用再单独 `rule.disable`。写路径与 bindRule 同构:get_draft → workflow/update → publish → get_published 读回。Pass `publish:false` to leave the template draft-only.",
|
|
185
192
|
}),
|
|
186
193
|
"workflow.delete": Object.freeze({
|
|
187
194
|
scope: WORKFLOW_SCOPE,
|
|
@@ -262,6 +269,7 @@ export function assertWorkflowContract() {
|
|
|
262
269
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.publish", ["workflow/publish", "template"]);
|
|
263
270
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.setButtons", ["buttonPermission", "customBtns", "childTableBtns", "formButtonCodes", "form-button-absent", "publish:false"]);
|
|
264
271
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.bindRule", ["startEventHandler", "cancelEventHandler", "activateEventHandler", "endEventHandler", "bizActions", "bizActionType", "BIZ_RULE", "publish:false", "enabledRuleCodes", "workflow-bind-rule-absent", "activityCode", "nodeEvent", "endActivity", "activityApproved"]);
|
|
272
|
+
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.unbindRule", ["bizActions", "workflow-unbind-rule-absent", "publish:false", "activityCode", "nodeEvent", "rule.disable", "rule.references"]);
|
|
265
273
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.permissions", ["list_permission", "40009", "PART_VISIABLE"]);
|
|
266
274
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.addPermission", ["create_permission", "unitType", "unitId"]);
|
|
267
275
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.removePermission", ["delete_permission", "permissionId"]);
|
|
@@ -300,6 +308,8 @@ export function assertWorkflowContract() {
|
|
|
300
308
|
throw new Error("workflow contract must pin the authoring chain ending in publish");
|
|
301
309
|
if (!WORKFLOW_WIRE.bindRuleChain.includes("workflow/update"))
|
|
302
310
|
throw new Error("workflow contract must pin the bind-rule write step");
|
|
311
|
+
if (!WORKFLOW_WIRE.unbindRuleChain.includes("workflow-unbind-rule-absent") || !WORKFLOW_WIRE.unbindRuleChain.includes("NEVER disables"))
|
|
312
|
+
throw new Error("workflow contract must pin the unbind-rule absent refusal and the no-auto-disable rule");
|
|
303
313
|
if (!WORKFLOW_WIRE.bindRuleScope.includes("startEventHandler") || !WORKFLOW_WIRE.bindRuleScope.includes("endEventHandler"))
|
|
304
314
|
throw new Error("workflow contract must pin the full event-handler scope");
|
|
305
315
|
if (!WORKFLOW_WIRE.boundRuleMustBeEnabled.includes("必须启用") || !WORKFLOW_WIRE.boundRuleMustBeEnabled.includes("rule.enable"))
|
|
@@ -17,6 +17,7 @@ export const WORKFLOW_COVERAGE = declareLaneCoverage(WORKFLOW_LANE_CONTRACT.lane
|
|
|
17
17
|
claim("workflow.update", T["workflow.update"].scope),
|
|
18
18
|
claim("workflow.publish", T["workflow.publish"].scope),
|
|
19
19
|
claim("workflow.bindRule", T["workflow.bindRule"].scope),
|
|
20
|
+
claim("workflow.unbindRule", T["workflow.unbindRule"].scope),
|
|
20
21
|
claim("workflow.setButtons", T["workflow.setButtons"].scope),
|
|
21
22
|
claim("workflow.delete", T["workflow.delete"].scope),
|
|
22
23
|
claim("workflow.permissions", T["workflow.permissions"].scope),
|