d9414e4cba
Full DAG engine app with CLI subcommands (run, list, status, validate, server) and React/Mantine web frontend. Uses net/http + embedded Vite build. SQLite store for run history. Scheduler with cron_ticker for automated execution. Compatible with existing dagu YAML format. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import type {
|
|
DagSummary,
|
|
DagDetail,
|
|
DagRun,
|
|
RunDetail,
|
|
SchedulerStatus,
|
|
} from "./types";
|
|
|
|
const BASE = "/api";
|
|
|
|
async function fetchJSON<T>(path: string, init?: RequestInit): Promise<T> {
|
|
const res = await fetch(`${BASE}${path}`, init);
|
|
if (!res.ok) {
|
|
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
throw new Error(err.error || res.statusText);
|
|
}
|
|
return res.json();
|
|
}
|
|
|
|
export function listDags(): Promise<DagSummary[]> {
|
|
return fetchJSON("/dags");
|
|
}
|
|
|
|
export function getDag(name: string): Promise<DagDetail> {
|
|
return fetchJSON(`/dags/${encodeURIComponent(name)}`);
|
|
}
|
|
|
|
export function triggerDag(
|
|
name: string
|
|
): Promise<{ status: string; dag: string; message: string }> {
|
|
return fetchJSON(`/dags/${encodeURIComponent(name)}/run`, {
|
|
method: "POST",
|
|
});
|
|
}
|
|
|
|
export function listRuns(params?: {
|
|
dag?: string;
|
|
limit?: number;
|
|
offset?: number;
|
|
}): Promise<{ runs: DagRun[]; total: number }> {
|
|
const search = new URLSearchParams();
|
|
if (params?.dag) search.set("dag", params.dag);
|
|
if (params?.limit) search.set("limit", String(params.limit));
|
|
if (params?.offset) search.set("offset", String(params.offset));
|
|
const qs = search.toString();
|
|
return fetchJSON(`/runs${qs ? "?" + qs : ""}`);
|
|
}
|
|
|
|
export function getRun(id: string): Promise<RunDetail> {
|
|
return fetchJSON(`/runs/${encodeURIComponent(id)}`);
|
|
}
|
|
|
|
export function startScheduler(): Promise<void> {
|
|
return fetchJSON("/scheduler/start", { method: "POST" });
|
|
}
|
|
|
|
export function stopScheduler(): Promise<void> {
|
|
return fetchJSON("/scheduler/stop", { method: "POST" });
|
|
}
|
|
|
|
export function getSchedulerStatus(): Promise<SchedulerStatus> {
|
|
return fetchJSON("/scheduler/status");
|
|
}
|