diff --git a/web/lib/api.ts b/web/lib/api.ts index 6432647..defbec9 100644 --- a/web/lib/api.ts +++ b/web/lib/api.ts @@ -251,6 +251,10 @@ export interface Workflow { target_server_ids: string[]; target_tags?: Record; 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"); }, - 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; +}