Server: - Add endpointUri to PositionedNode (from RouteNode) - Add fromEndpointUri to RouteSummary (catalog API) - Catalog controller resolves endpoint URI from diagram store UI: - Build endpointRouteMap from catalog's fromEndpointUri field - Drill-down uses exact match on node.endpointUri against the map - Remove label parsing heuristics (extractTargetEndpoint, camelToKebab) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { api } from '../client';
|
|
|
|
export interface DiagramNode {
|
|
id?: string;
|
|
label?: string;
|
|
type?: string;
|
|
x?: number;
|
|
y?: number;
|
|
width?: number;
|
|
height?: number;
|
|
children?: DiagramNode[];
|
|
endpointUri?: string;
|
|
}
|
|
|
|
export interface DiagramEdge {
|
|
sourceId: string;
|
|
targetId: string;
|
|
label?: string;
|
|
points: number[][];
|
|
}
|
|
|
|
export interface DiagramLayout {
|
|
width?: number;
|
|
height?: number;
|
|
nodes?: DiagramNode[];
|
|
edges?: DiagramEdge[];
|
|
}
|
|
|
|
export function useDiagramLayout(
|
|
contentHash: string | null,
|
|
direction: 'LR' | 'TB' = 'LR',
|
|
) {
|
|
return useQuery({
|
|
queryKey: ['diagrams', 'layout', contentHash, direction],
|
|
queryFn: async () => {
|
|
const { data, error } = await api.GET('/diagrams/{contentHash}/render', {
|
|
params: {
|
|
path: { contentHash: contentHash! },
|
|
query: { direction },
|
|
},
|
|
headers: { Accept: 'application/json' },
|
|
});
|
|
if (error) throw new Error('Failed to load diagram layout');
|
|
return data as DiagramLayout;
|
|
},
|
|
enabled: !!contentHash,
|
|
});
|
|
}
|
|
|
|
export function useDiagramByRoute(
|
|
application: string | undefined,
|
|
routeId: string | undefined,
|
|
direction: 'LR' | 'TB' = 'LR',
|
|
) {
|
|
return useQuery({
|
|
queryKey: ['diagrams', 'byRoute', application, routeId, direction],
|
|
queryFn: async () => {
|
|
const { data, error } = await api.GET('/diagrams', {
|
|
params: { query: { application: application!, routeId: routeId!, direction } },
|
|
});
|
|
if (error) throw new Error('Failed to load diagram for route');
|
|
return data as DiagramLayout;
|
|
},
|
|
enabled: !!application && !!routeId,
|
|
});
|
|
}
|