Skip to content

refactor(frontend): type alert capability endpoints and drop AlertsView casts - #434

Open
Rem7474 wants to merge 2 commits into
refactor/dedupe-css-and-template-blocksfrom
refactor/type-alert-capabilities
Open

Rem7474 wants to merge 2 commits into
refactor/dedupe-css-and-template-blocksfrom
refactor/type-alert-capabilities

Conversation

@Rem7474

@Rem7474 Rem7474 commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • The 5 alert-capability endpoints are typed with the generated models (AlertSplitCapabilities, AlertDockerCapabilities, AlertHostCapabilities) + AlertMetricCatalog for the {metrics} envelope. types/alert.ts adds AlertRuleCapabilities (the merged shape useAlertsPage builds).
  • AlertRuleModal, AlertRuleStepSource, AlertRuleList drop their local interfaces for the generated ones. One local type was wrong: the modal described Proxmox scope options as {id, name} while the server and the step component use {id, label}.
  • The modal emits the API AlertRulePayload; the form→API conversion (form keeps explicit null for cleared hysteresis/scopes) happens in one helper instead of three casts.
  • AlertsView.vue: 15 as any template casts → 0. They hid nothing serious once the types lined up — the remaining mismatches were formatDate not accepting undefined and the handler/payload types above.
  • Root CLAUDE.md: no longer claims every API response is typed; points at the modules that still return untyped data (51 api.get( calls remain, mostly proxmox/hosts/auth).

Other views with template casts (DockerView, HostDetailView, GitWebhooksView, DashboardView) are left for follow-ups, one per view.

Stacked on #433.

Test plan

  • typecheck, lint, full npm run test (alerts specs updated to typed fixtures)
  • Manual: create / edit a rule for each source (agent, Proxmox with scope, Docker, synthetic), test it, download test logs

🤖 Generated with Claude Code

@github-actions github-actions Bot added documentation Improvements or additions to documentation frontend labels Sep 30, 2026
…ew casts

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 <noreply@anthropic.com>
@Rem7474
Rem7474 force-pushed the refactor/dedupe-css-and-template-blocks branch from ba9e1d4 to 4e028c5 Compare September 30, 2026 19:31
@Rem7474
Rem7474 force-pushed the refactor/type-alert-capabilities branch from 60b7275 to 720529a Compare September 30, 2026 19:31
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rem7474
Rem7474 force-pushed the refactor/type-alert-capabilities branch from 720529a to 3af0beb Compare September 30, 2026 19:37
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
54.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@Rem7474

Rem7474 commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

SonarCloud new-code coverage: 54.5 % (gate 80 %), left as is on purpose.

The remaining uncovered new lines have no runtime behaviour to test:

  • api/alerts.ts (5 lines): only the api.get<T>() type argument changes on the five capability endpoints. The api/* wrappers are mocked in every spec, so no unit test runs them.
  • views/AlertsView.vue (1 line, 2 conditions): (x as any) casts removed from template bindings. The view is covered by its page composable's specs, not mounted as a whole.
  • AlertRuleModal.vue:
    • the docker-capabilities fallback literal gains metrics: [];
    • downloadTestLogs now passes apiPayload() instead of an inline cast.

A spec for the "Tester" action (payload plus API error display) was added, since that path had no test. A test for each typed line would only re-assert the TypeScript types. vue-tsc covers those at build time.

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant