-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcoverage.ts
More file actions
46 lines (41 loc) · 1.08 KB
/
coverage.ts
File metadata and controls
46 lines (41 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { useQuery } from '@tanstack/react-query';
import { apiClient } from './client.js';
export interface CoverageReport {
schemaUrl: string;
schemaTitle: string;
totalShapes: number;
mappedShapes: number;
coveragePercent: number;
computedAt: string;
}
export interface CoverageOverview {
totalSchemas: number;
totalShexMaps: number;
totalShapes: number;
totalMappedShapes: number;
overallCoveragePercent: number;
bySchema: CoverageReport[];
computedAt: string;
}
export interface ShapeGap {
schemaUrl: string;
shapeUrl: string;
shapeLabel: string;
hasMappings: boolean;
mappingCount: number;
}
export function useCoverageOverview() {
return useQuery<CoverageOverview>({
queryKey: ['coverage'],
queryFn: () => apiClient.get('/coverage').then((r) => r.data),
});
}
export function useGapAnalysis(schemaUrl?: string) {
return useQuery<ShapeGap[]>({
queryKey: ['coverage', 'gaps', schemaUrl],
queryFn: () =>
apiClient
.get('/coverage/gaps', { params: schemaUrl ? { schema: schemaUrl } : {} })
.then((r) => r.data),
});
}