71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import { queryKeys } from "../../../shared/api/queryKeys";
|
|
import {
|
|
getDeployApiDiscover,
|
|
getDeployApiInventory,
|
|
getDeployApiPlan,
|
|
getDeployApiTestboxConfigs,
|
|
getDeployApiTestboxMigrations,
|
|
getDeployApiTestboxStatus,
|
|
} from "./getDeployApiInventory";
|
|
|
|
const STATUS_REFRESH_INTERVAL_MS = 15_000;
|
|
|
|
export function useDeployApiInventoryQuery() {
|
|
return useQuery({
|
|
queryFn: getDeployApiInventory,
|
|
queryKey: queryKeys.deployApiInventory(),
|
|
refetchInterval: STATUS_REFRESH_INTERVAL_MS,
|
|
retry: 0,
|
|
});
|
|
}
|
|
|
|
export function useDeployApiPlanQuery(services: string[], enabled = true) {
|
|
return useQuery({
|
|
enabled: enabled && services.length > 0,
|
|
queryFn: () => getDeployApiPlan(services),
|
|
queryKey: queryKeys.deployApiPlan(services),
|
|
retry: 0,
|
|
});
|
|
}
|
|
|
|
export function useDeployApiDiscoverQuery(services: string[], enabled: boolean) {
|
|
return useQuery({
|
|
enabled,
|
|
queryFn: () => getDeployApiDiscover(services, true),
|
|
queryKey: queryKeys.deployApiDiscover(services),
|
|
refetchInterval: enabled ? STATUS_REFRESH_INTERVAL_MS : false,
|
|
retry: 0,
|
|
});
|
|
}
|
|
|
|
export function useDeployApiTestboxConfigsQuery(services: string[], enabled = true) {
|
|
return useQuery({
|
|
enabled,
|
|
queryFn: () => getDeployApiTestboxConfigs(services),
|
|
queryKey: queryKeys.deployApiTestboxConfigs(services),
|
|
refetchInterval: 60_000,
|
|
retry: 0,
|
|
});
|
|
}
|
|
|
|
export function useDeployApiTestboxStatusQuery(services: string[], enabled = true) {
|
|
return useQuery({
|
|
enabled,
|
|
queryFn: () => getDeployApiTestboxStatus(services),
|
|
queryKey: queryKeys.deployApiTestboxStatus(services),
|
|
refetchInterval: enabled ? STATUS_REFRESH_INTERVAL_MS : false,
|
|
retry: 0,
|
|
});
|
|
}
|
|
|
|
export function useDeployApiTestboxMigrationsQuery(enabled = true) {
|
|
return useQuery({
|
|
enabled,
|
|
queryFn: getDeployApiTestboxMigrations,
|
|
queryKey: queryKeys.deployApiTestboxMigrations(),
|
|
refetchInterval: 60_000,
|
|
retry: 0,
|
|
});
|
|
}
|