From 87b646b3a0af9ee30cd58b017ae51136de67d361 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 30 Sep 2026 14:31:00 +0000 Subject: [PATCH 1/2] refactor(frontend): type alert capability endpoints and drop AlertsView casts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The five alert-capability endpoints returned untyped data, and the rule editor worked around it with local interfaces — one of them wrong: the modal declared Proxmox scope options as {id, name} while the server and AlertRuleStepSource use {id, label}. AlertsView then bound fifteen props and handlers through `as any`, which vue-tsc does not check and the no-explicit-any lint rule cannot see in templates. - api/alerts.ts types the capability GETs with the generated models (AlertSplitCapabilities, AlertDockerCapabilities, AlertHostCapabilities) plus AlertMetricCatalog for the {metrics} envelope; types/alert.ts adds AlertRuleCapabilities, the merged shape useAlertsPage builds. - AlertRuleModal, AlertRuleStepSource and AlertRuleList drop their local copies for the generated types (AlertRule, AlertMetricCapability, AlertScopeOption, AlertDockerHostScope, ...). - The modal emits the API AlertRulePayload; the form→API conversion (the form keeps explicit nulls for cleared values) happens in one helper instead of three casts. - AlertsView has no `as any` left. Root CLAUDE.md no longer claims every API response is typed and says which modules still return untyped data. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 2 +- frontend/src/api/alerts.ts | 12 +-- .../src/components/alerts/AlertRuleList.vue | 48 +----------- .../components/alerts/AlertRuleModal.spec.ts | 22 ++++-- .../src/components/alerts/AlertRuleModal.vue | 77 ++++++------------- .../components/alerts/AlertRuleStepSource.vue | 29 +++---- frontend/src/composables/useAlertsPage.ts | 23 +----- frontend/src/types/alert.ts | 27 ++++++- frontend/src/views/AlertsView.vue | 30 ++++---- 9 files changed, 101 insertions(+), 169 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index c8d95513..2b04899d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -80,7 +80,7 @@ Three independent Go/Vue modules: **server** (Go API), **agent** (Go collector), - [composables/](frontend/src/composables/) — `useWebSocket`, `useCommandStream`, `useDashboard`, `useHostDetail`, `useFormValidator`, `useToast`, `useConfirmDialog`, `usePagination`, … - [utils/](frontend/src/utils/) — formatters, chart theme, dockerPorts, cron, dayjs, httpErrorBus, statusClasses, … -**TypeScript adoption**: all `.vue` files use `