feat: schedule methods on the web api client

This commit is contained in:
2026-08-04 14:10:04 +01:00
parent a1e6986a64
commit 439bc2ed7d
+25 -5
View File
@@ -251,6 +251,10 @@ export interface Workflow {
target_server_ids: string[];
target_tags?: Record<string, string>;
steps: WorkflowStepRef[];
schedule?: Schedule;
next_run_at?: string;
last_run_at?: string;
last_skipped?: Skip;
}
export interface StepRun {
@@ -656,11 +660,7 @@ export const api = {
return request<Settings>("/settings");
},
saveSettings(settings: {
alerts: AlertSettings;
workflow_log_retention_days?: number | null;
local_login_enabled?: boolean;
}): Promise<{ saved: boolean }> {
saveSettings(settings: { alerts: AlertSettings; workflow_log_retention_days?: number | null; local_login_enabled?: boolean }): Promise<{ saved: boolean }> {
return request<{ saved: boolean }>("/settings", {
method: "PUT",
body: JSON.stringify(settings),
@@ -863,6 +863,14 @@ export const api = {
serverRunLogStreamUrl(runId: string, serverId: string): string {
return `/api/runs/${runId}/servers/${serverId}/logs/stream`;
},
setWorkflowSchedule(workflowId: string, schedule: Schedule): Promise<{ schedule: Schedule; next_run_at: string | null }> {
return request(`/workflows/${workflowId}/schedule`, { method: "PUT", body: JSON.stringify(schedule) });
},
previewSchedule(workflowId: string, cron: string, tz: string): Promise<{ occurrences: string[] }> {
return request(`/workflows/${workflowId}/schedule/preview?cron=${encodeURIComponent(cron)}&tz=${encodeURIComponent(tz)}`);
},
};
export type LicenseState = "valid" | "expired" | "invalid";
@@ -903,3 +911,15 @@ export const licence = {
return request("/license", { method: "POST", body: JSON.stringify({ blob }) });
},
};
export interface Schedule {
enabled: boolean;
cron: string;
tz: string;
}
export interface Skip {
reason: string;
due: string;
at: string;
}