From 826466aa55aace0b3471c959bb577dd4a6e88b28 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Mon, 23 Mar 2026 21:25:36 +0100 Subject: [PATCH] fix: cast diagram layout response type to fix TS build error The render endpoint returns a union type (SVG string | JSON object). Cast to DiagramLayout interface so .nodes is accessible. Also rename useDiagramByRoute parameter from group to application. Co-Authored-By: Claude Opus 4.6 (1M context) --- ui/src/api/queries/diagrams.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ui/src/api/queries/diagrams.ts b/ui/src/api/queries/diagrams.ts index 1d276557..c9a35163 100644 --- a/ui/src/api/queries/diagrams.ts +++ b/ui/src/api/queries/diagrams.ts @@ -1,6 +1,13 @@ import { useQuery } from '@tanstack/react-query'; import { api } from '../client'; +interface DiagramLayout { + width?: number; + height?: number; + nodes?: Array<{ id?: string; label?: string; type?: string; x?: number; y?: number; width?: number; height?: number }>; + edges?: Array<{ from?: string; to?: string }>; +} + export function useDiagramLayout(contentHash: string | null) { return useQuery({ queryKey: ['diagrams', 'layout', contentHash], @@ -10,22 +17,22 @@ export function useDiagramLayout(contentHash: string | null) { headers: { Accept: 'application/json' }, }); if (error) throw new Error('Failed to load diagram layout'); - return data!; + return data as DiagramLayout; }, enabled: !!contentHash, }); } -export function useDiagramByRoute(group: string | undefined, routeId: string | undefined) { +export function useDiagramByRoute(application: string | undefined, routeId: string | undefined) { return useQuery({ - queryKey: ['diagrams', 'byRoute', group, routeId], + queryKey: ['diagrams', 'byRoute', application, routeId], queryFn: async () => { const { data, error } = await api.GET('/diagrams', { - params: { query: { group: group!, routeId: routeId! } }, + params: { query: { group: application!, routeId: routeId! } }, }); if (error) throw new Error('Failed to load diagram for route'); return data!; }, - enabled: !!group && !!routeId, + enabled: !!application && !!routeId, }); }