mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-12 19:55:14 +02:00
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { apiPost, apiDelete } from '../client';
|
|
import type { ScanView } from '../types';
|
|
|
|
export type ScanMode = 'full' | 'ast' | 'cfg' | 'taint';
|
|
export type EngineProfile = 'fast' | 'balanced' | 'deep';
|
|
|
|
export interface StartScanBody {
|
|
scan_root?: string;
|
|
mode?: ScanMode;
|
|
engine_profile?: EngineProfile;
|
|
/**
|
|
* Override dynamic verification for this scan.
|
|
* true — force on.
|
|
* false — force off (skip verification; M7 default is on).
|
|
* absent — use server config default (true since M7).
|
|
*/
|
|
verify?: boolean;
|
|
/** Also verify Confidence < Medium findings. Default false. */
|
|
verify_all_confidence?: boolean;
|
|
}
|
|
|
|
export function useStartScan() {
|
|
const qc = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (body?: StartScanBody) => apiPost<ScanView>('/scans', body),
|
|
onSuccess: () => {
|
|
qc.invalidateQueries({ queryKey: ['scans'] });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useDeleteScan() {
|
|
const qc = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (id: string) =>
|
|
apiDelete<void>(`/scans/${encodeURIComponent(id)}`),
|
|
onSuccess: () => {
|
|
qc.invalidateQueries({ queryKey: ['scans'] });
|
|
qc.invalidateQueries({ queryKey: ['overview'] });
|
|
},
|
|
});
|
|
}
|