@stalfh233/omc-cli 0.6.26 → 0.6.27
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/cli-stdout.js +1 -0
- package/dist/cli.js +2 -0
- package/dist/endpoints.js +1 -0
- package/dist/lanes/rulelog.js +9 -2
- package/dist/lanes/runtime-data.js +20 -66
- package/dist/rule-support.js +110 -0
- package/dist/track.js +70 -0
- package/package.json +3 -3
package/dist/cli-stdout.js
CHANGED
package/dist/cli.js
CHANGED
|
@@ -58,6 +58,7 @@ import { parseToolInput, ToolInputError } from "./tool-types.js";
|
|
|
58
58
|
import { WireError, wireCall } from "./wire.js";
|
|
59
59
|
import { DEFAULT_PULL_CONCURRENCY, GraphIndexAbsentError, GraphPullLockHeldError, MAX_PULL_CONCURRENCY, impactGraph, publishGraphPull, queryGraphReferences, queryGraphReferencesBatch, queryGraphEdges, readGraphStatus, searchGraphRules, } from "./graph.js";
|
|
60
60
|
import { cmdResidue } from "./residue.js";
|
|
61
|
+
import { cmdTrack } from "./track.js";
|
|
61
62
|
import { ENDPOINTS } from "./endpoints.js";
|
|
62
63
|
import { makeToolContext } from "./context.js";
|
|
63
64
|
import { cmdRollbackList, cmdRollbackPlan, cmdRollbackApply } from "./rollback.js";
|
|
@@ -2535,6 +2536,7 @@ async function main() {
|
|
|
2535
2536
|
});
|
|
2536
2537
|
command.command("bench").option("--live-sample").option("--env <environment>").action(async (options) => { commandExitCode = await cmdBench([...(options.liveSample ? ["--live-sample"] : []), ...(options.env ? ["--env", options.env] : [])]); });
|
|
2537
2538
|
command.command("residue <prefix>").description("跨面前缀残留扫描(model 全租户/folder/custompage;默认 deep 再查命中模型的 rule/datarule/onlinejs)——收尾「删净」一次证明,clean:true 即零残留。清理入口:omc model-purge --code <schemaCode>(按依赖倒序,默认 dry-run)。只读零写入;report 面暂停维护未扫描").option("--env <environment>", "环境名(默认按 cwd 的 .omc-env 解析)").option("--apps <codes>", "all(默认,全租户)或逗号分隔应用码").option("--no-deep", "只扫 model/folder/custompage,不深查命中模型").option("--all-faces", "列出全部应用×面(含 count:0;默认只回非零面+byFace/userResidues 紧凑形)").option("--max-output-bytes <bytes>").action(async (prefix, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdResidue(prefix, { env: options.env, apps: options.apps, ...(options.deep === false ? { noDeep: true } : {}), ...(options.allFaces ? { allFaces: true } : {}) }, transport)); });
|
|
2539
|
+
command.command("track <schemaCode> <bizObjectId>").description("读取单条业务数据的行级变更留痕(只读;平台来源枚举含 BUSINESS_RULE 时原样回传)").option("--env <environment>").option("--property-code <code>").option("--max-output-bytes <bytes>").action(async (schemaCode, bizObjectId, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdTrack(schemaCode, bizObjectId, { env: options.env, propertyCode: options.propertyCode }, transport)); });
|
|
2538
2540
|
const jqOption = () => new Option("--jq [path]", "路径投影(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([]);
|
|
2539
2541
|
command.command("commands").option("--json").option("--compact").option("--filter <keyword>").option("--lane <id>").option("--max-output-bytes <bytes>").addOption(jqOption()).action(async (options) => { commandExitCode = await withTransport(options, request, (transport) => cmdDiscovery("commands", transport, undefined, { json: options.json === true, compact: options.compact === true, ...(options.filter ? { filter: options.filter } : {}), ...(options.lane ? { lane: options.lane } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) })); });
|
|
2540
2542
|
command.command("describe <tool>").option("--full").option("--cache-ok", "允许 --full 在同会话重复读时短路为 artifact 指针(默认每次回全文)").option("--schema-only").option("--param <name>").option("--example [id]").option("--max-output-bytes <bytes>").addOption(jqOption()).action(async (tool, options) => {
|
package/dist/endpoints.js
CHANGED
|
@@ -110,6 +110,7 @@ export const ENDPOINTS = {
|
|
|
110
110
|
ruleRuntimeExecuteBase: "/api/api/launcher/domain_service_runtime",
|
|
111
111
|
ruleLogSearch: "/api/api/launcher/domain_service_runtime/{schemaCode}/search_rule_log",
|
|
112
112
|
ruleActivityLog: "/api/api/launcher/domain_service_runtime/{schemaCode}/query_rule_activity_log",
|
|
113
|
+
dataTrackSearch: "/api/api/launcher/domain_service_runtime/{schemaCode}/search_data_track",
|
|
113
114
|
/**
|
|
114
115
|
* Form-toolbar button execution — a DIFFERENT face from the list-button one.
|
|
115
116
|
* Live 2026-10-23 (1.1.25, Playwright capture of a `triggerType=FORM` button
|
package/dist/lanes/rulelog.js
CHANGED
|
@@ -57,11 +57,18 @@ export function registerRuleLogLane(tools) {
|
|
|
57
57
|
const log = { ruleCode: row.code, name: row.name, triggerType: row.triggerType, status: row.status, triggerTime: row.triggerTime, finishTime: row.finishTime, ...(row.errMsg ? { errMsg: row.errMsg } : {}), ruleVersion: row.ruleVersion, traceId: row.traceId, triggerRows: Array.isArray(row.inputSummaries) ? row.inputSummaries.map((v) => ({ id: v.id, name: v.name })) : [] };
|
|
58
58
|
if (args.includeNodes === true && index < 3) {
|
|
59
59
|
const nodeData = (await wireCall(session, { path: path(ENDPOINTS.ruleActivityLog, args.schemaCode), method: "POST", body: { ruleLogId: row.id } })).data;
|
|
60
|
-
log.nodes = Array.isArray(nodeData) ? nodeData.map((node) => ({
|
|
60
|
+
log.nodes = Array.isArray(nodeData) ? nodeData.map((node) => ({
|
|
61
|
+
type: node.type,
|
|
62
|
+
name: node.name,
|
|
63
|
+
status: node.status,
|
|
64
|
+
...(String(node.type ?? "").toUpperCase() === "QUERY" ? { matchedUnknown: true } : {}),
|
|
65
|
+
...(node.targetSchemaCode ? { targetSchemaCode: node.targetSchemaCode } : {}),
|
|
66
|
+
...(node.errMsg ? { errMsg: node.errMsg } : {}),
|
|
67
|
+
})) : [];
|
|
61
68
|
}
|
|
62
69
|
return log;
|
|
63
70
|
}));
|
|
64
|
-
return { index: { schemaCode: args.schemaCode, page: requestedPage, size: requestedSize, totalElements: data.totalElements ?? logs.length, totalPages: data.totalPages ?? 0, ...(rowFilter ? { rowFilter } : {}) }, logs, notes: ["status=true 表示成功,status=false 表示失败", ...notes, ...(args.includeNodes === true ? ["节点 VO 不提供 targetBizObjectId,节点行级 id 不可得;仅前 3 条命中日志拉取节点链"] : [])] };
|
|
71
|
+
return { index: { schemaCode: args.schemaCode, page: requestedPage, size: requestedSize, totalElements: data.totalElements ?? logs.length, totalPages: data.totalPages ?? 0, ...(rowFilter ? { rowFilter } : {}) }, logs, notes: ["status=true 表示成功,status=false 表示失败", ...notes, ...(args.includeNodes === true ? ["节点 VO 不提供 targetBizObjectId,节点行级 id 不可得;仅前 3 条命中日志拉取节点链", "QUERY 节点日志不记录命中数:matchedUnknown=true;0 行与成功同形,请用 data.load 比对目标行"] : [])] };
|
|
65
72
|
}, { target: `rulelog.search:${args.schemaCode}:${JSON.stringify(args)}` }),
|
|
66
73
|
}));
|
|
67
74
|
}
|
|
@@ -13,7 +13,6 @@ import { closestMatch } from "../closest-match.js";
|
|
|
13
13
|
import { getReplayToken, listInstanceActivities, searchWorkItems, wireString } from "../workflow-support.js";
|
|
14
14
|
import { PLATFORM_ADMIN_START_BYPASS, resolvePermissionActor } from "../identity.js";
|
|
15
15
|
import { ENGINE_OWNED_KEYS, RUNTIME_DATA_LANE_CONTRACT, RUNTIME_DATA_WIRE, runtimeFormDataArg, } from "./runtime-data-contract.js";
|
|
16
|
-
import { SYSTEM_FIELD_CODES } from "../field-families.js";
|
|
17
16
|
import { applicationResolutionOf, resolveApplicationScope } from "../support.js";
|
|
18
17
|
/** r29b F8: keep ids/itemsPreview through governedRead's compact diet. */
|
|
19
18
|
const DATA_LIST_PREVIEW_LIMIT = 20;
|
|
@@ -1240,22 +1239,18 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1240
1239
|
const selected = fields ?? Object.keys(data).filter((field) => !["id", "bizObjectId", "schemaCode", "sequenceStatus", "createdTime", "updatedTime", "creator", "updater"].includes(field));
|
|
1241
1240
|
return { id: row.bizObjectId ?? row.id ?? data.id, fields: Object.fromEntries(selected.map((field) => [field, data[field] ?? null])) };
|
|
1242
1241
|
});
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
let
|
|
1246
|
-
if (
|
|
1242
|
+
const preview = dataListItemPreview(items);
|
|
1243
|
+
const nullProjection = items.some((item) => Object.values(item.fields).some((value) => value === null));
|
|
1244
|
+
let viewColumnsCount;
|
|
1245
|
+
if (nullProjection) {
|
|
1247
1246
|
try {
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1250
|
-
const hintColumns = [...typeByCode.keys()].filter((field) => !SYSTEM_FIELD_CODES.has(field) && (!returnedKeys.has(field) || items.every((item) => item.fields[field] === null)));
|
|
1251
|
-
if (hintColumns.length > 0)
|
|
1252
|
-
allHint = `这些列在默认视图未配置(值可能存在但列表投影为 null 或整列省略):${hintColumns.join("、")};先用 listview.configure 配置列,或用 data.load 读单条权威值`;
|
|
1247
|
+
const view = (await wireCall(session, { path: ENDPOINTS.listQueryGet, query: { schemaCode: args.schemaCode, code: args.queryCode ?? args.schemaCode, clientType: "PC" } })).data;
|
|
1248
|
+
viewColumnsCount = Array.isArray(view?.queryColumns) ? view.queryColumns.length : 0;
|
|
1253
1249
|
}
|
|
1254
1250
|
catch {
|
|
1255
|
-
//
|
|
1251
|
+
// Projection diagnostics must never make data.list fail.
|
|
1256
1252
|
}
|
|
1257
1253
|
}
|
|
1258
|
-
const preview = dataListItemPreview(items);
|
|
1259
1254
|
return {
|
|
1260
1255
|
schemaCode: args.schemaCode,
|
|
1261
1256
|
...application,
|
|
@@ -1292,7 +1287,7 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1292
1287
|
capNotice: `已取前 ${collected.length} 条 / 共 ${total} 条(安全上限 ${CAP})——还差 ${total - collected.length} 条没返回。不要把它当全集:加 filters 分片(如按日期/业务键)分别拉取,或去掉 all 用 page/size 手动翻页。`,
|
|
1293
1288
|
}
|
|
1294
1289
|
: {}),
|
|
1295
|
-
...(
|
|
1290
|
+
...(nullProjection ? { projectionHint: { hint: "null 可能=未投影进视图列,判真值用 data.load --args {schemaCode,bizObjectId}", ...(viewColumnsCount !== undefined ? { viewColumnsCount } : {}) } } : {}),
|
|
1296
1291
|
items,
|
|
1297
1292
|
};
|
|
1298
1293
|
}
|
|
@@ -1404,6 +1399,17 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1404
1399
|
const data = row.data && typeof row.data === "object" ? row.data : row;
|
|
1405
1400
|
return String(data.sequenceStatus ?? row.sequenceStatus ?? "") === "DRAFT";
|
|
1406
1401
|
}).length;
|
|
1402
|
+
let viewColumnsCount;
|
|
1403
|
+
const hasNullValue = items.some((item) => Object.values(item.fields).some((value) => value === null));
|
|
1404
|
+
if (hasNullValue) {
|
|
1405
|
+
try {
|
|
1406
|
+
const view = (await wireCall(session, { path: ENDPOINTS.listQueryGet, query: { schemaCode: args.schemaCode, code: args.queryCode ?? args.schemaCode, clientType: "PC" } })).data;
|
|
1407
|
+
viewColumnsCount = Array.isArray(view?.queryColumns) ? view.queryColumns.length : 0;
|
|
1408
|
+
}
|
|
1409
|
+
catch {
|
|
1410
|
+
// Keep the data read authoritative if the optional diagnostic read fails.
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1407
1413
|
const readback = {
|
|
1408
1414
|
schemaCode: args.schemaCode,
|
|
1409
1415
|
...application,
|
|
@@ -1433,6 +1439,7 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1433
1439
|
return { filter: policy };
|
|
1434
1440
|
})(),
|
|
1435
1441
|
...(choiceFilterFields.length > 0 && Number(total ?? 0) === 0 ? { filterValueHint: choiceFilterValueHint(choiceFilterFields) } : {}),
|
|
1442
|
+
...(hasNullValue ? { projectionHint: { hint: "null 可能=未投影进视图列,判真值用 data.load --args {schemaCode,bizObjectId}", ...(viewColumnsCount !== undefined ? { viewColumnsCount } : {}) } } : {}),
|
|
1436
1443
|
totalPages,
|
|
1437
1444
|
itemsCount: items.length,
|
|
1438
1445
|
itemsReturned: items.length,
|
|
@@ -1444,59 +1451,6 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1444
1451
|
// r29b F8 的 ids/itemsPreview 由 compact(外置时)现算,见 dataListCompactProjection。
|
|
1445
1452
|
items,
|
|
1446
1453
|
};
|
|
1447
|
-
// A model's unconfigured default list view projects business columns as
|
|
1448
|
-
// null even though the stored values exist (ticket 07). Only when the
|
|
1449
|
-
// caller explicitly projected columns, EVERY returned row yielded null
|
|
1450
|
-
// for EVERY selected column, and the published metadata confirms those
|
|
1451
|
-
// are real model fields, surface the recovery hint. `items` is never
|
|
1452
|
-
// reshaped — the hint is a sibling readback field.
|
|
1453
|
-
// Candidate keys first (pure — zero wires); metadata only when there is
|
|
1454
|
-
// at least one all-null column to classify (preserves the rawCondition
|
|
1455
|
-
// path's zero-extra-wire contract when there is nothing to hint).
|
|
1456
|
-
const businessNullColumns = async () => {
|
|
1457
|
-
const candidates = Object.keys(items[0]?.fields ?? {}).filter((field) => !SYSTEM_FIELD_CODES.has(field) && items.every((item) => item.fields[field] === null));
|
|
1458
|
-
if (candidates.length === 0)
|
|
1459
|
-
return [];
|
|
1460
|
-
const typeByCode = await publishedTypeByCode();
|
|
1461
|
-
return candidates.filter((field) => typeByCode.has(field));
|
|
1462
|
-
};
|
|
1463
|
-
// A6(GitLab #15,2026-11-04):未配置列有两种投影形态——值为 null,或
|
|
1464
|
-
// **整键省略**(orderChange 实测:sequenceNo 在 data.list 里根本不出现,
|
|
1465
|
-
// data.load 却有值,被误读成「单号为空」)。省略检测需要发布元数据
|
|
1466
|
-
// (fieldList 有 60s wire 缓存,DSL 过滤路径本就已取);两种形态合并进 hint。
|
|
1467
|
-
const projectionHintFor = async () => {
|
|
1468
|
-
if (items.length === 0)
|
|
1469
|
-
return undefined;
|
|
1470
|
-
const typeByCode = await publishedTypeByCode();
|
|
1471
|
-
const returnedKeys = new Set(Object.keys(items[0]?.fields ?? {}));
|
|
1472
|
-
const nullColumns = fields && fields.length > 0
|
|
1473
|
-
? fields.filter((field) => typeByCode.has(field) && items.every((item) => item.fields[field] === null))
|
|
1474
|
-
: [...returnedKeys].filter((field) => !SYSTEM_FIELD_CODES.has(field) && typeByCode.has(field) && items.every((item) => item.fields[field] === null));
|
|
1475
|
-
const omittedColumns = !fields
|
|
1476
|
-
? [...typeByCode.keys()].filter((field) => !SYSTEM_FIELD_CODES.has(field) && !returnedKeys.has(field))
|
|
1477
|
-
: [];
|
|
1478
|
-
const hintColumns = [...new Set([...nullColumns, ...omittedColumns])];
|
|
1479
|
-
if (hintColumns.length === 0)
|
|
1480
|
-
return undefined;
|
|
1481
|
-
return `这些列在默认视图未配置(值可能存在但列表投影为 null 或整列省略):${hintColumns.join("、")};先用 listview.configure 配置列,或用 data.load 读单条权威值`;
|
|
1482
|
-
};
|
|
1483
|
-
if (fields &&
|
|
1484
|
-
fields.length > 0 &&
|
|
1485
|
-
items.length > 0 &&
|
|
1486
|
-
items.every((item) => fields.every((field) => item.fields[field] === null))) {
|
|
1487
|
-
const typeByCode = await publishedTypeByCode();
|
|
1488
|
-
if (fields.every((field) => typeByCode.has(field)))
|
|
1489
|
-
readback.projectionHint = RUNTIME_DATA_WIRE.projectionHint;
|
|
1490
|
-
}
|
|
1491
|
-
else if (!fields && items.length > 0) {
|
|
1492
|
-
// r17 finding: BOTH delegated agents tripped on implicit projection —
|
|
1493
|
-
// business fields absent from the list view render as null in every
|
|
1494
|
-
// row with no explanation. Name the null'd business columns so the
|
|
1495
|
-
// agent reads data.load instead of misdiagnosing "data lost".
|
|
1496
|
-
const hint = await projectionHintFor();
|
|
1497
|
-
if (hint)
|
|
1498
|
-
readback.projectionHint = hint;
|
|
1499
|
-
}
|
|
1500
1454
|
// r29b F8: ids/itemsPreview 已在同信封;artifact 提示由 compact 外置后的
|
|
1501
1455
|
// fetch/detailArtifactId 承担。这里不改既有 projectionHint 主句(契约测试
|
|
1502
1456
|
// 钉死 RUNTIME_DATA_WIRE.projectionHint 原文)。
|
package/dist/rule-support.js
CHANGED
|
@@ -9,6 +9,7 @@ import { validateRuleNodeGraph, prepareRuleGraph, PLATFORM_TRIGGER_RULE_CODES, D
|
|
|
9
9
|
import { FORMULA_LINT_CODES } from "./formula-lint.js";
|
|
10
10
|
import { compileMethodConfigPlain } from "./bizservice-config.js";
|
|
11
11
|
import { RESERVED_CODES } from "./code-rules.js";
|
|
12
|
+
import { SYSTEM_FIELD_CODES } from "./field-families.js";
|
|
12
13
|
import { FIELD_PROPERTY_TYPES } from "./field-families.js";
|
|
13
14
|
/** Business-rule node graph. Platform trigger rules are addressed by ruleCode: Create / Update / Delete / Available / Cancel / GetList / Load. */
|
|
14
15
|
export const ruleNodeGraphArg = z
|
|
@@ -342,6 +343,111 @@ function collectBizMethodRefs(nodes) {
|
|
|
342
343
|
* error (the platform requires the field to be PUBLISHED, not merely drafted).
|
|
343
344
|
*/
|
|
344
345
|
const RULE_RESERVED_MAPPING_CODES = RESERVED_CODES;
|
|
346
|
+
const RULE_GRAPH_FIELD_OWNERSHIP_EXEMPT = (code) => code === "_input" || /^_QN_.*_output$/u.test(code) || SYSTEM_FIELD_CODES.has(code) || RESERVED_CODES.has(code.toLowerCase());
|
|
347
|
+
function fieldCodeParts(raw) {
|
|
348
|
+
const parts = raw.split(".").map((part) => part.trim()).filter(Boolean);
|
|
349
|
+
return parts.length > 1 ? { child: parts[0], field: parts[1] } : { field: parts[0] ?? "" };
|
|
350
|
+
}
|
|
351
|
+
function collectRuleGraphFieldRefs(schemaCode, nodes) {
|
|
352
|
+
const refs = [];
|
|
353
|
+
const queryModels = new Map();
|
|
354
|
+
for (const entry of nodes) {
|
|
355
|
+
if (!entry || typeof entry !== "object")
|
|
356
|
+
continue;
|
|
357
|
+
const node = entry;
|
|
358
|
+
if (String(node.nodeType ?? "") === "QUERY" && typeof node.nodeCode === "string" && typeof node.targetSchemaCode === "string")
|
|
359
|
+
queryModels.set(node.nodeCode, node.targetSchemaCode.trim());
|
|
360
|
+
}
|
|
361
|
+
const sourceModel = (node) => {
|
|
362
|
+
const input = typeof node.inputParam === "string" ? /^_(.+)_output$/u.exec(node.inputParam) : undefined;
|
|
363
|
+
return input?.[1] && queryModels.get(input[1]) ? queryModels.get(input[1]) : schemaCode;
|
|
364
|
+
};
|
|
365
|
+
const add = (node, side, raw, model, where) => {
|
|
366
|
+
if (typeof raw !== "string")
|
|
367
|
+
return;
|
|
368
|
+
const value = raw.trim();
|
|
369
|
+
if (!value || RULE_GRAPH_FIELD_OWNERSHIP_EXEMPT(value))
|
|
370
|
+
return;
|
|
371
|
+
const { field, child } = fieldCodeParts(value);
|
|
372
|
+
if (!field || RULE_GRAPH_FIELD_OWNERSHIP_EXEMPT(field))
|
|
373
|
+
return;
|
|
374
|
+
// A dotted child path is addressed by the child schema itself. The gate
|
|
375
|
+
// intentionally checks the child code/field set only; parent fan-out and
|
|
376
|
+
// child-row execution remain the separate rule-graph semantics gate.
|
|
377
|
+
refs.push({ nodeCode: String(node.nodeCode ?? ""), side, code: value, model: child ?? model, where });
|
|
378
|
+
};
|
|
379
|
+
const walkFormula = (node, formula, model, where) => {
|
|
380
|
+
if (typeof formula !== "string")
|
|
381
|
+
return;
|
|
382
|
+
for (const match of formula.matchAll(/\{([^{}]+)\}/gu))
|
|
383
|
+
add(node, "input", match[1], model, `${where}.formula`);
|
|
384
|
+
};
|
|
385
|
+
const walkConditions = (node, value, targetModel, inputModel, where) => {
|
|
386
|
+
if (Array.isArray(value))
|
|
387
|
+
return value.forEach((item, index) => walkConditions(node, item, targetModel, inputModel, `${where}[${index}]`));
|
|
388
|
+
if (!value || typeof value !== "object")
|
|
389
|
+
return;
|
|
390
|
+
const record = value;
|
|
391
|
+
if (record.targetSchemaDataItem !== undefined)
|
|
392
|
+
add(node, "target", record.targetSchemaDataItem, targetModel, `${where}.targetSchemaDataItem`);
|
|
393
|
+
if (record.currentSchemaDataItem !== undefined)
|
|
394
|
+
add(node, "input", record.currentSchemaDataItem, inputModel, `${where}.currentSchemaDataItem`);
|
|
395
|
+
if (String(record.ruleValueType ?? "").toUpperCase() === "EXPRESSION")
|
|
396
|
+
walkFormula(node, record.value, inputModel, `${where}.value`);
|
|
397
|
+
for (const [key, item] of Object.entries(record))
|
|
398
|
+
if (["mainConditions", "sheetConditions", "conditionGroup", "targetConditionGroups", "exitConditionGroups", "dataCondition", "execConditionGroups", "sourceConditionGroups"].includes(key))
|
|
399
|
+
walkConditions(node, item, targetModel, inputModel, `${where}.${key}`);
|
|
400
|
+
};
|
|
401
|
+
for (const entry of nodes) {
|
|
402
|
+
if (!entry || typeof entry !== "object")
|
|
403
|
+
continue;
|
|
404
|
+
const node = entry;
|
|
405
|
+
const type = String(node.nodeType ?? "");
|
|
406
|
+
const targetModel = type === "QUERY" ? String(node.targetSchemaCode ?? "") : String(node.targetObjectCode ?? schemaCode);
|
|
407
|
+
const inputModel = sourceModel(node);
|
|
408
|
+
walkConditions(node, node.filterCondition, targetModel, inputModel, "filterCondition");
|
|
409
|
+
walkConditions(node, node.targetConditionGroups, targetModel, inputModel, "targetConditionGroups");
|
|
410
|
+
walkConditions(node, node.exitConditionGroups, targetModel, inputModel, "exitConditionGroups");
|
|
411
|
+
if (Array.isArray(node.dataActions))
|
|
412
|
+
for (const [index, action] of node.dataActions.entries()) {
|
|
413
|
+
if (!action || typeof action !== "object")
|
|
414
|
+
continue;
|
|
415
|
+
const record = action;
|
|
416
|
+
add(node, "target", record.targetDataItem, targetModel, `dataActions[${index}].targetDataItem`);
|
|
417
|
+
add(node, "input", record.currentDataItemValue ?? record.currentSchemaDataItem, inputModel, `dataActions[${index}].currentDataItemValue`);
|
|
418
|
+
const formula = record.value && typeof record.value === "object" ? record.value.formula : undefined;
|
|
419
|
+
walkFormula(node, formula, inputModel, `dataActions[${index}].value`);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return refs;
|
|
423
|
+
}
|
|
424
|
+
async function assertRuleGraphFieldOwnership(session, schemaCode, nodes, allowAdvisory = false) {
|
|
425
|
+
const refs = collectRuleGraphFieldRefs(schemaCode, nodes);
|
|
426
|
+
if (refs.length === 0)
|
|
427
|
+
return [];
|
|
428
|
+
const models = [...new Set(refs.map((ref) => ref.model))].filter(Boolean).slice(0, 3);
|
|
429
|
+
const fieldSets = new Map();
|
|
430
|
+
await Promise.all(models.map(async (model) => {
|
|
431
|
+
const fields = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: model, isPublish: "true" } })).data);
|
|
432
|
+
fieldSets.set(model, new Set(fields.map((field) => String(field.code ?? field.propertyCode ?? "").trim()).filter(Boolean)));
|
|
433
|
+
}));
|
|
434
|
+
// An unseeded model has no published-field evidence on the fake platform;
|
|
435
|
+
// retain legacy round-trip behavior there. Once a field set is observable,
|
|
436
|
+
// every referenced code is checked fail-closed (real environments always
|
|
437
|
+
// expose the published field list, including an empty list for a model).
|
|
438
|
+
const missing = refs.filter((ref) => {
|
|
439
|
+
const fields = fieldSets.get(ref.model);
|
|
440
|
+
return fields !== undefined && fields.size > 0 && !fields.has(fieldCodeParts(ref.code).field);
|
|
441
|
+
});
|
|
442
|
+
if (missing.length === 0)
|
|
443
|
+
return [];
|
|
444
|
+
const first = missing[0];
|
|
445
|
+
const candidates = [...(fieldSets.get(first.model) ?? [])].sort().slice(0, 50);
|
|
446
|
+
const message = `规则节点 ${first.nodeCode} 的${first.side === "target" ? "目标" : "输入源"}字段 ${first.model}.${first.code} 不存在或未发布;请从该模型已发布字段中选择。候选:${candidates.join("、") || "(无)"}`;
|
|
447
|
+
if (allowAdvisory)
|
|
448
|
+
return [{ code: "rule-graph-field-not-in-model", nodeCode: first.nodeCode, key: first.where, severity: "warning", message: `${message}(allowAdvisory:true,仅调查放行)` }];
|
|
449
|
+
throw new ToolRefusalError({ status: "refused", blocker: "rule-graph-field-not-in-model", nodeCode: first.nodeCode, side: first.side, model: first.model, field: first.code, where: first.where, missing, candidates, message });
|
|
450
|
+
}
|
|
345
451
|
async function assertBizActionMappingFieldsExist(session, schemaCode, nodes) {
|
|
346
452
|
const rows = [];
|
|
347
453
|
for (const entry of nodes) {
|
|
@@ -791,6 +897,10 @@ export async function executeRuleSaveWrite(session, args) {
|
|
|
791
897
|
});
|
|
792
898
|
await assertCreateSelectionCompatibility(session, args.schemaCode, Array.isArray(nodes) ? nodes : []);
|
|
793
899
|
await assertBizActionMappingFieldsExist(session, args.schemaCode, Array.isArray(nodes) ? nodes : []);
|
|
900
|
+
// r47a: ordinary UPDATE/CREATE/EXPRESSION references use two distinct
|
|
901
|
+
// ownership sides. Read each involved published field set once (at most the
|
|
902
|
+
// rule model plus two target/query models) and refuse before rule.save.
|
|
903
|
+
blockers.push(...(await assertRuleGraphFieldOwnership(session, args.schemaCode, Array.isArray(nodes) ? nodes : [], args.allowAdvisory === true)));
|
|
794
904
|
// Ticket 96: phantom-schema gate — BEFORE the first businessrule wire call
|
|
795
905
|
// (the rule list itself auto-creates preset rows for unknown schemas).
|
|
796
906
|
await assertRuleSchemaExists(session, args.schemaCode);
|
package/dist/track.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ConfigStore, defaultPaths } from "./config-store.js";
|
|
2
|
+
import { SessionManager } from "./session-manager.js";
|
|
3
|
+
import { makeToolContext } from "./context.js";
|
|
4
|
+
import { ENDPOINTS } from "./endpoints.js";
|
|
5
|
+
import { wireCall } from "./wire.js";
|
|
6
|
+
import { emitInvalid, emitResult } from "./command-transport.js";
|
|
7
|
+
const trackPath = (schemaCode) => ENDPOINTS.dataTrackSearch.replace("{schemaCode}", encodeURIComponent(schemaCode));
|
|
8
|
+
function asRows(data) {
|
|
9
|
+
if (!data || typeof data !== "object")
|
|
10
|
+
return [];
|
|
11
|
+
const record = data;
|
|
12
|
+
return Array.isArray(record.content) ? record.content.filter((row) => Boolean(row && typeof row === "object")) : [];
|
|
13
|
+
}
|
|
14
|
+
function project(row) {
|
|
15
|
+
const source = row.sourceOperateType ?? row.operateType ?? row.sourceUserType;
|
|
16
|
+
return {
|
|
17
|
+
id: row.id ?? null,
|
|
18
|
+
time: row.createdTime ?? row.operateTime ?? row.updateTime ?? null,
|
|
19
|
+
operateType: row.operateType ?? null,
|
|
20
|
+
sourceOperateType: row.sourceOperateType ?? null,
|
|
21
|
+
sourceUserType: row.sourceUserType ?? null,
|
|
22
|
+
source: source ?? null,
|
|
23
|
+
operator: row.userName ?? row.operatorName ?? row.userId ?? row.creator ?? null,
|
|
24
|
+
propertyCodes: Array.isArray(row.propertyCodes)
|
|
25
|
+
? row.propertyCodes
|
|
26
|
+
: Array.isArray(row.propertyCodeList)
|
|
27
|
+
? row.propertyCodeList
|
|
28
|
+
: Object.keys((row.beforeRowData ?? row.afterRowData ?? {})),
|
|
29
|
+
...(row.beforeRowData !== undefined ? { beforeRowData: row.beforeRowData } : {}),
|
|
30
|
+
...(row.afterRowData !== undefined ? { afterRowData: row.afterRowData } : {}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export async function searchTrack(session, schemaCode, bizObjectId, propertyCode) {
|
|
34
|
+
const body = {
|
|
35
|
+
// DataTrackSearchAssembler uses PageRequest.of(page - 1, size).
|
|
36
|
+
page: 1,
|
|
37
|
+
size: 100,
|
|
38
|
+
bizObjectIds: [bizObjectId],
|
|
39
|
+
...(propertyCode ? { propertyCodes: [propertyCode] } : {}),
|
|
40
|
+
};
|
|
41
|
+
const data = (await wireCall(session, { path: trackPath(schemaCode), method: "POST", body })).data;
|
|
42
|
+
const rows = asRows(data);
|
|
43
|
+
const raw = data && typeof data === "object" ? data : {};
|
|
44
|
+
return {
|
|
45
|
+
schemaCode,
|
|
46
|
+
bizObjectId,
|
|
47
|
+
page: 1,
|
|
48
|
+
size: 100,
|
|
49
|
+
total: raw.totalElements ?? rows.length,
|
|
50
|
+
entries: rows.map(project),
|
|
51
|
+
notes: [
|
|
52
|
+
"sourceOperateType/source 为平台留痕来源;BUSINESS_RULE 表示业务规则来源(若平台返回该枚举)",
|
|
53
|
+
"平台回执未提供 before/after 时不补造旧值;本命令只报告平台实际返回的字段",
|
|
54
|
+
...(rows.length === 100 ? ["本次最多取 100 条;需要更早历史时当前命令尚未提供分页参数"] : []),
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export async function cmdTrack(schemaCode, bizObjectId, options, transport) {
|
|
59
|
+
if (!schemaCode || !bizObjectId)
|
|
60
|
+
return emitInvalid(transport, { message: "track 需要 schemaCode 和 bizObjectId" });
|
|
61
|
+
try {
|
|
62
|
+
const context = makeToolContext({ sessions: new SessionManager(new ConfigStore(defaultPaths())) });
|
|
63
|
+
const session = await context.sessions.session(options.env);
|
|
64
|
+
return emitResult(await searchTrack(session, schemaCode, bizObjectId, options.propertyCode), transport);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
return emitResult({ status: "error", blocker: "track-search-failed", message: error instanceof Error ? error.message : String(error) }, transport);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=track.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.27",
|
|
4
4
|
"description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"commander": "14.0.3",
|
|
58
|
-
"omc-core": "0.6.
|
|
58
|
+
"omc-core": "0.6.27",
|
|
59
59
|
"proper-lockfile": "4.1.2",
|
|
60
60
|
"write-file-atomic": "6.0.0",
|
|
61
61
|
"zod": "^3.23.8",
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"directory": "packages/omc-cli"
|
|
74
74
|
},
|
|
75
75
|
"optionalDependencies": {
|
|
76
|
-
"@stalfh233/omc-fake-platform": "0.6.
|
|
76
|
+
"@stalfh233/omc-fake-platform": "0.6.27"
|
|
77
77
|
}
|
|
78
78
|
}
|