Save and display execution records

This commit is contained in:
yoan
2024-11-20 15:47:51 +08:00
parent 03b2a9da66
commit 2d10fa0218
18 changed files with 405 additions and 54 deletions

View File

@@ -1,4 +1,4 @@
import { Workflow, WorkflowNode } from "@/domain/workflow";
import { Workflow, WorkflowNode, WorkflowRunLog } from "@/domain/workflow";
import { getPb } from "./api";
export const get = async (id: string) => {
@@ -39,3 +39,30 @@ export const list = async (req: WorkflowListReq) => {
export const remove = async (id: string) => {
return await getPb().collection("workflow").delete(id);
};
type WorkflowLogsReq = {
id: string;
page: number;
perPage?: number;
};
export const logs = async (req: WorkflowLogsReq) => {
let page = 1;
if (req.page) {
page = req.page;
}
let perPage = 10;
if (req.perPage) {
perPage = req.perPage;
}
const response = await getPb()
.collection("workflow_run_log")
.getList<WorkflowRunLog>(page, perPage, {
sort: "-created",
filter: getPb().filter("workflow={:workflowId}", { workflowId: req.id }),
});
return response;
};