fix(m4): typed MitreSyncResult interface — drop the as cast
Mirrors the backend Pydantic `SyncResultOut` in TS so the mutation result is
properly typed end-to-end. `(res as { duration_ms: number })` cast removed
from MitrePage.tsx; `apiPost<MitreSyncResult>` carries the contract.
Also annotated the unused query-key factories in mitre.ts so the next reader
knows they're parked for M5 template-form consumption (not dead).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,7 +9,12 @@ import { SectionHeader } from '@/components/ui/SectionHeader';
|
||||
import { Tag } from '@/components/ui/Tag';
|
||||
import { ApiError, apiGet, apiPost } from '@/lib/api';
|
||||
import { useAuth } from '@/lib/auth';
|
||||
import { mitreKeys, type MitreStatus, type MitreTag } from '@/lib/mitre';
|
||||
import {
|
||||
mitreKeys,
|
||||
type MitreStatus,
|
||||
type MitreSyncResult,
|
||||
type MitreTag,
|
||||
} from '@/lib/mitre';
|
||||
|
||||
export function MitrePage() {
|
||||
const { state } = useAuth();
|
||||
@@ -24,14 +29,14 @@ export function MitrePage() {
|
||||
});
|
||||
|
||||
const sync = useMutation({
|
||||
mutationFn: () => apiPost<Record<string, unknown>>('/mitre/sync'),
|
||||
mutationFn: () => apiPost<MitreSyncResult>('/mitre/sync'),
|
||||
onMutate: () => {
|
||||
setSyncResult(null);
|
||||
setSyncError(null);
|
||||
},
|
||||
onSuccess: async (res) => {
|
||||
const counts = `${res.tactics_upserted} tactics, ${res.techniques_upserted} techniques, ${res.subtechniques_upserted} subtechniques`;
|
||||
setSyncResult(`Sync completed in ${(res as { duration_ms: number }).duration_ms / 1000}s — ${counts}.`);
|
||||
setSyncResult(`Sync completed in ${(res.duration_ms / 1000).toFixed(1)}s — ${counts}.`);
|
||||
await qc.invalidateQueries({ queryKey: ['mitre'] });
|
||||
},
|
||||
onError: (e) => {
|
||||
|
||||
Reference in New Issue
Block a user