feat(platform,datalink,bill): add workflow job drilldown, safe record batch-edit, audit, and spec linkage diagnostics (v0.8.11)

This commit is contained in:
gitea committed 2026-09-29 20:00:55 +08:00
1 parent 2ec08033e0
commit a0ec7f95a7
37 files changed
+3958 -674

No files matched your search

+153 -1
View File
@@ -10,7 +10,19 @@ import {
} from "./workflow-state.js";
import { WorkflowDetailSchema } from "./types.js";
import type { WorkflowDetail } from "./types.js";
import { listWorkflowSnapshots, listWorkflowLogs, toggleWorkflow, updateWorkflow } from "./api.js";
import {
getExecutionLogs,
getJob,
getJobExecutionLevel,
getJobExecutionTree,
getJobFailedExecutions,
getWorkflowDetail,
listWorkflowSnapshots,
listWorkflowLogs,
toggleWorkflow,
updateWorkflow,
} from "./api.js";
import { AuthenticationError, EkbApiError } from "../../core/errors.js";
import { WorkflowAlertStore } from "./workflow-alert-store.js";
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
import { join } from "node:path";
@@ -150,4 +162,144 @@ describe("workflow draft state machine", () => {
expect(failed.status).toBe("failed");
expect(failed.error).toBe("网络错误");
});
it("throws structured AuthenticationError or EkbApiError when Piper unwrap receives null data or non-200 code", async () => {
const unauthorizedClient = {
get: async () =>
new Response(JSON.stringify({ code: 401, message: "登录已过期", data: null }), {
status: 200,
}),
} as any;
await expect(getWorkflowDetail(unauthorizedClient, "wf-1")).rejects.toBeInstanceOf(AuthenticationError);
const nullDataClient = {
get: async () =>
new Response(JSON.stringify({ code: 200, msg: "pipeline not found", data: null }), {
status: 200,
}),
} as any;
await expect(getWorkflowDetail(nullDataClient, "wf-1")).rejects.toBeInstanceOf(EkbApiError);
});
it("calls the 5 Piper Job diagnostic endpoints and parses execution trees, failed nodes, child levels, and logs", async () => {
const client = {
get: async (url: string, options?: any) => {
if (url === "api/easo/jobs/892809886382563347") {
return new Response(
JSON.stringify({
code: 200,
data: {
id: "892809886382563347",
pipelineId: "886351399301758976",
label: "每30分钟创建采购申请单",
state: "COMPLETED",
successTaskCount: 5,
errorTaskCount: 1,
hasError: true,
},
})
);
}
if (url === "api/easo/jobs/892809886382563347/execution") {
return new Response(
JSON.stringify({
code: 200,
data: [
{
id: "892809893789696012",
jobId: "892809886382563347",
name: "every_0",
label: "循环",
type: "every",
state: "COMPLETED",
levelIndex: [0],
},
],
})
);
}
if (url === "api/easo/jobs/892809886382563347/execution/level/failed") {
return new Response(
JSON.stringify({
code: 200,
data: [
{
id: "892809900000000001",
jobId: "892809886382563347",
parentId: "892809893789696012",
name: "ekuaibao_flow_create_task_0",
label: "创建预付申请单",
type: "flow-create-task",
state: "FAILED",
inputs: { form: { u_关联合同流程: "ID01VSau4VJWSH" } },
outputs: { error: "我方签约主体未填写" },
},
],
})
);
}
if (url === "api/easo/jobs/892809886382563347/execution/level") {
expect(options?.searchParams).toEqual({
parentId: "892809893789696012",
number: "1",
pageSize: "20",
});
return new Response(
JSON.stringify({
code: 200,
data: {
number: 1,
size: 20,
totalPages: 1,
totalItems: 1,
items: [
[
{
id: "892809900000000001",
name: "ekuaibao_flow_create_task_0",
state: "FAILED",
inputs: { form: { u_关联合同流程: "ID01VSau4VJWSH" } },
outputs: { error: "我方签约主体未填写" },
},
],
],
},
})
);
}
if (url === "api/easo/executions/892809893789696012/logs") {
return new Response(
JSON.stringify({
code: 200,
data: {
total: 1,
items: [{ id: "log-1", message: "MVEL script executed", level: "INFO" }],
},
})
);
}
throw new Error(`Unexpected URL: ${url}`);
},
} as any;
const job = await getJob(client, "892809886382563347");
expect(job.hasError).toBe(true);
expect(job.errorTaskCount).toBe(1);
const tree = await getJobExecutionTree(client, "892809886382563347");
expect(tree).toHaveLength(1);
expect(tree[0]?.name).toBe("every_0");
const failed = await getJobFailedExecutions(client, "892809886382563347");
expect(failed.items).toHaveLength(1);
expect((failed.items[0]?.outputs as any)?.error).toBe("我方签约主体未填写");
const level = await getJobExecutionLevel(client, "892809886382563347", {
parentId: "892809893789696012",
});
expect(level.items).toHaveLength(1);
const logs = await getExecutionLogs(client, "892809893789696012");
expect(logs[0]?.message).toBe("MVEL script executed");
});
});