From df2aae024649ae130f6e2706f4e5b9209310099f Mon Sep 17 00:00:00 2001 From: rcourtman Date: Fri, 10 Oct 2025 15:45:12 +0000 Subject: [PATCH] feat: add UpdatePlan and history types to frontend API Add TypeScript interfaces and API methods for new update system: **New Types:** - UpdatePlan: Deployment-specific update plan with canAutoUpdate flag - UpdateHistoryEntry: Complete audit log entry with all metadata **New API Methods:** - getUpdatePlan(version, channel?) - Get deployment-specific update plan - getUpdateHistory(limit?, status?) - List update history with filters - getUpdateHistoryEntry(eventId) - Get specific history entry details These types match the backend Go structs and enable frontend integration with the adapter-based update system. Next: Implement UI components (confirmation modal, progress modal, update banner enhancements, settings history panel). --- frontend-modern/src/api/updates.ts | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/frontend-modern/src/api/updates.ts b/frontend-modern/src/api/updates.ts index 4f9915a65..a7eb2092e 100644 --- a/frontend-modern/src/api/updates.ts +++ b/frontend-modern/src/api/updates.ts @@ -29,6 +29,40 @@ export interface VersionInfo { deploymentType?: string; } +export interface UpdatePlan { + canAutoUpdate: boolean; + instructions?: string[]; + prerequisites?: string[]; + estimatedTime?: string; + requiresRoot: boolean; + rollbackSupport: boolean; + downloadUrl?: string; +} + +export interface UpdateHistoryEntry { + event_id: string; + timestamp: string; + action: 'update' | 'rollback'; + channel: string; + version_from: string; + version_to: string; + deployment_type: string; + initiated_by: 'user' | 'auto' | 'api'; + initiated_via: 'ui' | 'cli' | 'script' | 'webhook'; + status: 'in_progress' | 'success' | 'failed' | 'rolled_back' | 'cancelled'; + duration_ms: number; + backup_path?: string; + log_path?: string; + error?: { + message: string; + code?: string; + details?: string; + }; + download_bytes?: number; + related_event_id?: string; + notes?: string; +} + export class UpdatesAPI { static async checkForUpdates(channel?: string): Promise { const url = channel ? `/api/updates/check?channel=${channel}` : '/api/updates/check'; @@ -49,4 +83,26 @@ export class UpdatesAPI { static async getVersion(): Promise { return apiFetchJSON('/api/version'); } + + static async getUpdatePlan(version: string, channel?: string): Promise { + const url = channel + ? `/api/updates/plan?version=${version}&channel=${channel}` + : `/api/updates/plan?version=${version}`; + return apiFetchJSON(url); + } + + static async getUpdateHistory( + limit?: number, + status?: string + ): Promise { + const params = new URLSearchParams(); + if (limit) params.append('limit', limit.toString()); + if (status) params.append('status', status); + const url = `/api/updates/history${params.toString() ? `?${params.toString()}` : ''}`; + return apiFetchJSON(url); + } + + static async getUpdateHistoryEntry(eventId: string): Promise { + return apiFetchJSON(`/api/updates/history/entry?id=${eventId}`); + } }