47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { api } from './api';
|
|
|
|
export type ConsistencySeverity = 'ok' | 'warn' | 'error';
|
|
export type ConsistencyStatus = 'pass' | 'fail';
|
|
|
|
export interface ConsistencyCheckResult {
|
|
id: string;
|
|
label: string;
|
|
severity: ConsistencySeverity;
|
|
count: number;
|
|
message: string;
|
|
}
|
|
|
|
export interface ConsistencyResult {
|
|
generatedAt: string;
|
|
status: ConsistencyStatus;
|
|
counts: Record<string, number>;
|
|
checks: {
|
|
partitionKeys: ConsistencyCheckResult[];
|
|
orphanReferences: ConsistencyCheckResult[];
|
|
auditCoverage: ConsistencyCheckResult[];
|
|
};
|
|
summary: {
|
|
errors: number;
|
|
warnings: number;
|
|
human: string;
|
|
};
|
|
}
|
|
|
|
export function getConsistencyReport() {
|
|
return api.get<ConsistencyResult>('/consistency');
|
|
}
|
|
|
|
export function summarizeConsistencyResult(result: ConsistencyResult) {
|
|
const checks = [
|
|
...result.checks.partitionKeys,
|
|
...result.checks.orphanReferences,
|
|
...result.checks.auditCoverage,
|
|
];
|
|
return {
|
|
ok: checks.filter((item) => item.severity === 'ok').length,
|
|
warn: checks.filter((item) => item.severity === 'warn').length,
|
|
error: checks.filter((item) => item.severity === 'error').length,
|
|
total: checks.length,
|
|
};
|
|
}
|