Files
helm-dashboard/frontend/src/API/scanners.ts
yuri-sakharov c9b8fb7809 Introduced tsconfig.app.json and tsconfig.base.json + Refactored eslint.config.js to the latest structure (#652)
* Introduced tsconfig.app.json and tsconfig.base.json

* yarn.lock

* Introduced tsconfig.app.json, tsconfig.base.jsonfig.

* Refactored eslint.config.js to latest structure

* Returned previous recommended rules.

* More rules

* Force import rules

* Check

* Check

* Cleanup ESLint configuration and plugins

* Cleanup heap: "writable",DD_RUM: "writable" from ESLint configuration

* "scripts" moved to the top of package.json
2026-02-15 17:41:04 +00:00

72 lines
1.8 KiB
TypeScript

/** DO NOT DELETE THESE FUNCTIONS - we left this until we support scan ops again */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
type UseMutationOptions,
type UseQueryOptions,
useMutation,
useQuery,
} from "@tanstack/react-query";
import apiService from "./apiService";
import {
type ScanResult,
type ScanResults,
type ScannersList,
} from "./interfaces";
// Get list of discovered scanners
// @ts-expect-error unused
function useGetDiscoveredScanners(options?: UseQueryOptions<ScannersList>) {
return useQuery<ScannersList>({
queryKey: ["scanners"],
queryFn: () =>
apiService.fetchWithSafeDefaults<ScannersList>({
url: "/api/scanners",
fallback: { scanners: [] },
}),
...(options ?? {}),
});
}
// Scan manifests using all applicable scanners
// @ts-expect-error unused
function useScanManifests(
manifest: string,
options?: UseMutationOptions<ScanResults, Error, string>
) {
const formData = new FormData();
formData.append("manifest", manifest);
return useMutation<ScanResults, Error, string>({
mutationFn: () =>
apiService.fetchWithSafeDefaults<ScanResults>({
url: "/api/scanners/manifests",
options: {
method: "POST",
body: formData,
},
fallback: {},
}),
...(options ?? {}),
});
}
// Scan specified k8s resource in cluster
// @ts-expect-error unused
function useScanK8sResource(
kind: string,
namespace: string,
name: string,
options?: UseQueryOptions<ScanResults>
) {
return useQuery<ScanResults>({
queryKey: ["scanners", "resource", kind, namespace, name],
queryFn: () =>
apiService.fetchWithSafeDefaults<ScanResults>({
url: `/api/scanners/resource/${kind}?namespace=${namespace}&name=${name}`,
fallback: {},
}),
...(options ?? {}),
});
}