import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { analyticsKeys } from './keys' import { get } from 'data/fetchers' export type WarehouseEndpointsVariables = { projectRef: string } export type WarehouseEndpointsResponse = any export async function getWarehouseEndpoints( { projectRef }: WarehouseEndpointsResponse, signal?: AbortSignal ) { if (!projectRef) { throw new Error('projectRef is required') } // [Jordi]: commented out because it's not used yet and will throw an error // const response = await get( // '/projects/{ref}/analytics/warehouse/endpoints', // { // params: { path: { ref: projectRef } }, // } // ) // if (response.error) { // throw response.error // } // return response } export type WarehouseEndpointsData = Awaited> export type WarehouseEndpointsError = unknown export const useWarehouseEndpointsQuery = ( { projectRef }: WarehouseEndpointsVariables, { enabled = true, ...options }: UseQueryOptions = {} ) => useQuery( analyticsKeys.warehouseEndpoints(projectRef), ({ signal }) => getWarehouseEndpoints({ projectRef }, signal), { enabled: enabled && typeof projectRef !== 'undefined', ...options, } )