feat: unified catalog endpoint and slug-based app navigation
All checks were successful
All checks were successful
Consolidate route catalog (agent-driven) and apps table (deployment-
driven) into a single GET /api/v1/catalog?environment={slug} endpoint.
Apps table is authoritative; agent data enriches with live health,
routes, and metrics. Unmanaged apps (agents without App record) appear
with managed=false.
- Add CatalogController merging App records + agent registry + ClickHouse
- Add CatalogApp DTO with deployment summary, managed flag, health
- Change AppController and DeploymentController to accept slugs (not UUIDs)
- Add AppRepository.findBySlug() and AppService.getBySlug()
- Replace useRouteCatalog() with useCatalog() across all UI components
- Navigate to /apps/{slug} instead of /apps/{UUID}
- Update sidebar, search, and all catalog lookups to use slug
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -92,9 +92,12 @@ export function useCreateApp() {
|
||||
export function useDeleteApp() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (id: string) =>
|
||||
appFetch<void>(`/${id}`, { method: 'DELETE' }),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['apps'] }),
|
||||
mutationFn: (slug: string) =>
|
||||
appFetch<void>(`/${slug}`, { method: 'DELETE' }),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: ['apps'] });
|
||||
qc.invalidateQueries({ queryKey: ['catalog'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,25 +3,57 @@ import { config } from '../../config';
|
||||
import { useAuthStore } from '../../auth/auth-store';
|
||||
import { useRefreshInterval } from './use-refresh-interval';
|
||||
|
||||
export function useRouteCatalog(from?: string, to?: string, environment?: string) {
|
||||
export interface CatalogRoute {
|
||||
routeId: string;
|
||||
exchangeCount: number;
|
||||
lastSeen: string | null;
|
||||
fromEndpointUri: string | null;
|
||||
routeState: string | null;
|
||||
}
|
||||
|
||||
export interface CatalogAgent {
|
||||
instanceId: string;
|
||||
displayName: string;
|
||||
state: string;
|
||||
tps: number;
|
||||
}
|
||||
|
||||
export interface DeploymentSummary {
|
||||
status: string;
|
||||
replicas: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface CatalogApp {
|
||||
slug: string;
|
||||
displayName: string;
|
||||
managed: boolean;
|
||||
environmentSlug: string;
|
||||
health: 'live' | 'stale' | 'dead' | 'offline';
|
||||
agentCount: number;
|
||||
routes: CatalogRoute[];
|
||||
agents: CatalogAgent[];
|
||||
exchangeCount: number;
|
||||
deployment: DeploymentSummary | null;
|
||||
}
|
||||
|
||||
export function useCatalog(environment?: string) {
|
||||
const refetchInterval = useRefreshInterval(15_000);
|
||||
return useQuery({
|
||||
queryKey: ['routes', 'catalog', from, to, environment],
|
||||
queryKey: ['catalog', environment],
|
||||
queryFn: async () => {
|
||||
const token = useAuthStore.getState().accessToken;
|
||||
const params = new URLSearchParams();
|
||||
if (from) params.set('from', from);
|
||||
if (to) params.set('to', to);
|
||||
if (environment) params.set('environment', environment);
|
||||
const qs = params.toString();
|
||||
const res = await fetch(`${config.apiBaseUrl}/routes/catalog${qs ? `?${qs}` : ''}`, {
|
||||
const res = await fetch(`${config.apiBaseUrl}/catalog${qs ? `?${qs}` : ''}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
'X-Cameleer-Protocol-Version': '1',
|
||||
},
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to load route catalog');
|
||||
return res.json();
|
||||
if (!res.ok) throw new Error('Failed to load catalog');
|
||||
return res.json() as Promise<CatalogApp[]>;
|
||||
},
|
||||
placeholderData: (prev) => prev,
|
||||
refetchInterval,
|
||||
|
||||
Reference in New Issue
Block a user