/** * Generated by orval v8.5.3 🍺 * Do not edit manually. * Api * API specification * OpenAPI spec version: 0.1.0 */ import { useQuery } from "@tanstack/react-query"; import type { QueryFunction, QueryKey, UseQueryOptions, UseQueryResult, } from "@tanstack/react-query"; import type { HealthStatus } from "./api.schemas"; import { customFetch } from "../custom-fetch"; import type { ErrorType } from "../custom-fetch"; type AwaitedInput = PromiseLike | T; type Awaited = O extends AwaitedInput ? T : never; type SecondParameter unknown> = Parameters[1]; /** * Returns server health status * @summary Health check */ export const getHealthCheckUrl = () => { return `/api/healthz`; }; export const healthCheck = async ( options?: RequestInit, ): Promise => { return customFetch(getHealthCheckUrl(), { ...options, method: "GET", }); }; export const getHealthCheckQueryKey = () => { return [`/api/healthz`] as const; }; export const getHealthCheckQueryOptions = < TData = Awaited>, TError = ErrorType, >(options?: { query?: UseQueryOptions< Awaited>, TError, TData >; request?: SecondParameter; }) => { const { query: queryOptions, request: requestOptions } = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHealthCheckQueryKey(); const queryFn: QueryFunction>> = ({ signal, }) => healthCheck({ signal, ...requestOptions }); return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< Awaited>, TError, TData > & { queryKey: QueryKey }; }; export type HealthCheckQueryResult = NonNullable< Awaited> >; export type HealthCheckQueryError = ErrorType; /** * @summary Health check */ export function useHealthCheck< TData = Awaited>, TError = ErrorType, >(options?: { query?: UseQueryOptions< Awaited>, TError, TData >; request?: SecondParameter; }): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getHealthCheckQueryOptions(options); const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey; }; return { ...query, queryKey: queryOptions.queryKey }; }