fix: stabilize auth identity, record operations, and workflow diagnostics
This commit is contained in:
1 parent
c74fdda7da
commit
7ec369f77e
36 files changed
+1021
-337
No files matched your search
@@ -149,7 +149,7 @@ export async function handleWorkflowDiffJob(
|
||||
} else {
|
||||
const divergedNodes = diff.nodes.filter((n) => n.diverged);
|
||||
const nodeRows = divergedNodes.map((n) => [
|
||||
n.taskName,
|
||||
n.currentLoopPath ? `${n.taskName} [loop ${n.currentLoopPath}]` : n.taskName,
|
||||
n.displayName || "-",
|
||||
n.type || "-",
|
||||
n.statusA || "(未执行)",
|
||||
|
||||
@@ -487,7 +487,7 @@ export async function handleJob(parsed: CliParsedArgs, runtime: CliRuntime): Pro
|
||||
if (diag.rules.length > 0) {
|
||||
outLines.push(" • 规则比对明细:");
|
||||
for (const r of diag.rules) {
|
||||
const statusIcon = r.matched ? "✅" : "❌";
|
||||
const statusIcon = r.matched === null ? "?" : r.matched ? "✅" : "❌";
|
||||
const missTag = r.isMissing ? " [⚠️ 属性缺失]" : "";
|
||||
outLines.push(` ${statusIcon} ${r.leftLabel} ${r.operatorLabel} ${JSON.stringify(r.expectedValue)}${missTag}`);
|
||||
outLines.push(` ↳ ${r.detail}`);
|
||||
|
||||
@@ -7,6 +7,7 @@ import { stringOption, booleanOption, numberOption } from "../../parser.js";
|
||||
import { printJson, printTable, printKeyValue } from "../../printer.js";
|
||||
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
|
||||
import { createWorkflowDetailClient } from "./shared.js";
|
||||
import { isDryRun, mutationPreview, requireMutationConfirmation } from "../../mutation.js";
|
||||
|
||||
export async function handleWorkflowTest(
|
||||
parsed: CliParsedArgs,
|
||||
@@ -16,19 +17,28 @@ export async function handleWorkflowTest(
|
||||
if (!pipelineId) {
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: "用法: hose-use workflow test <pipelineId> --flow=<单号|单据ID> [--auto-publish] [--timeout=<ms>] [--force]\n别名: hose-use workflow debug <pipelineId> --flow=<单号>\n",
|
||||
stderr: "用法: hose-use workflow test <pipelineId> --flow=<单号|单据ID> [--auto-publish] [--timeout=<ms>] [--dry-run | --yes]\n别名: hose-use workflow debug <pipelineId> --flow=<单号>\n",
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const { client } = await createWorkflowDetailClient(parsed, runtime, pipelineId);
|
||||
const flowCodeOrId = stringOption(parsed.options, ["flow", "code", "flow-code", "flowCode", "bill", "entity", "id"]);
|
||||
const autoPublish = booleanOption(parsed.options, ["auto-publish", "autoPublish", "publish"]);
|
||||
const timeoutMs = numberOption(parsed.options, ["timeout", "timeout-ms", "timeoutMs"]) || 15000;
|
||||
const force = booleanOption(parsed.options, ["force", "confirm", "yes", "i-know-it-is-prod"]);
|
||||
const timeoutMs = numberOption(parsed.options, ["timeout", "timeout-ms", "timeoutMs"]) ?? 15000;
|
||||
const warnings = ["调试会在真实环境执行工作流节点,可能改变业务数据、发送通知并生成快照;auto-publish 还可能发布流程。"];
|
||||
if (flowCodeOrId) {
|
||||
requireMutationConfirmation(parsed, runtime, "执行工作流调试", `hose-use workflow test ${pipelineId} --flow=${flowCodeOrId} --yes`);
|
||||
if (isDryRun(parsed, runtime)) {
|
||||
return mutationPreview(parsed, runtime, "执行工作流调试", pipelineId, { flowCodeOrId, autoPublish, timeoutMs, warnings });
|
||||
}
|
||||
}
|
||||
const { client } = await createWorkflowDetailClient(parsed, runtime, pipelineId);
|
||||
|
||||
// 获取工作流状态,检测是否处于生产启用中
|
||||
const detail = await getWorkflowDetail(client, pipelineId).catch(() => null);
|
||||
const detail = await getWorkflowDetail(client, pipelineId).catch(() => {
|
||||
warnings.push("未能读取工作流状态,启用状态未知。");
|
||||
return null;
|
||||
});
|
||||
const isEnabled = detail?.state === 1 || (detail as any)?.active === true;
|
||||
|
||||
// 如果没有传入 --flow,先列出当前可用的调试数据源供用户参考
|
||||
@@ -37,7 +47,7 @@ export async function handleWorkflowTest(
|
||||
const source = await getWorkflowDebugSource(client, pipelineId, { page: 1, pageSize: 5 });
|
||||
if (runtime.jsonMode) {
|
||||
return {
|
||||
stdout: printJson(source, runtime.outputOptions),
|
||||
stdout: printJson({ ...source, productionEnabled: detail ? isEnabled : null, warnings }, runtime.outputOptions),
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
@@ -73,17 +83,19 @@ export async function handleWorkflowTest(
|
||||
}
|
||||
|
||||
// 执行端到端调试测试
|
||||
const report = await runWorkflowDebugTest(client, pipelineId, {
|
||||
const execution = await runWorkflowDebugTest(client, pipelineId, {
|
||||
flowCodeOrId,
|
||||
autoPublish,
|
||||
timeoutMs,
|
||||
});
|
||||
const report = { ...execution, productionEnabled: detail ? isEnabled : null, warnings };
|
||||
const exitCode = report.outcome === "completed" ? 0 : 1;
|
||||
|
||||
if (runtime.jsonMode) {
|
||||
return {
|
||||
stdout: printJson(report, runtime.outputOptions),
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
exitCode,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -114,6 +126,9 @@ export async function handleWorkflowTest(
|
||||
"生成 Job ID": report.jobId,
|
||||
"测试目标单据": report.targetEntityId,
|
||||
"执行结果状态": report.status,
|
||||
"测试结果": report.outcome,
|
||||
"是否超时": String(report.timedOut),
|
||||
"诊断完整": String(report.diagnosticsComplete),
|
||||
"运行模式": report.runType,
|
||||
"总耗时(ms)": String(report.durationTime ?? "-"),
|
||||
"节点执行总数": report.executionTree.length,
|
||||
@@ -128,6 +143,8 @@ export async function handleWorkflowTest(
|
||||
)
|
||||
: "暂无顶层节点执行记录",
|
||||
];
|
||||
outLines.push(...warnings.map(warning => `⚠️ ${warning}`));
|
||||
outLines.push(...report.diagnosticsErrors.map(error => `诊断读取失败 [${error.source}]: ${error.message}`));
|
||||
|
||||
if (report.conditionDiagnoses.length > 0) {
|
||||
outLines.push("");
|
||||
@@ -139,7 +156,7 @@ export async function handleWorkflowTest(
|
||||
if (diag.rules.length > 0) {
|
||||
outLines.push(" • 规则比对明细:");
|
||||
for (const r of diag.rules) {
|
||||
const statusIcon = r.matched ? "✅" : "❌";
|
||||
const statusIcon = r.matched === null ? "?" : r.matched ? "✅" : "❌";
|
||||
const missTag = r.isMissing ? " [⚠️ 属性缺失]" : "";
|
||||
outLines.push(` ${statusIcon} ${r.leftLabel} ${r.operatorLabel} ${JSON.stringify(r.expectedValue)}${missTag}`);
|
||||
outLines.push(` ↳ ${r.detail}`);
|
||||
@@ -151,6 +168,6 @@ export async function handleWorkflowTest(
|
||||
return {
|
||||
stdout: `${outLines.join("\n")}\n`,
|
||||
stderr: "",
|
||||
exitCode: report.status === "FAILED" ? 1 : 0,
|
||||
exitCode,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user