mirror of
https://github.com/supabase/supabase.git
synced 2026-10-19 16:19:10 +03:00
* add basic feature * rename to datasource * rename elements in left sidebar * update copy in titles in left sidebar * Add optional 'enabled' parameter in useLogsQuery hook * Update warehouse query state and components * add template selector for warehouse query builder * update deprecated input compo * fix create token and console warnings * fix type errors * fix dupped import * update endpoints and add missing permissions * update queries with new api path * fix type errors * undo last commit * undo missing file * fix imports in logs page * import fixes * add settings link like in storage menu * sort imports, fix form submit * rename access tokens settings section * align dropdwn * add overflow to templates dropdown * add name as defaultvalue to udpate form * update rm collection dialog * capitalize * Update apps/studio/pages/project/[ref]/logs/explorer/index.tsx Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * fix typo --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
import { analyticsKeys } from './keys'
|
|
import { get, handleError } from 'data/fetchers'
|
|
import { ResponseError } from 'types'
|
|
|
|
export type WarehouseTenantVariables = {
|
|
projectRef: string
|
|
}
|
|
|
|
export type WarehouseTenantResponse = any
|
|
|
|
export async function getWarehouseTenant(
|
|
{ projectRef }: WarehouseTenantVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!projectRef) {
|
|
throw new Error('projectRef is required')
|
|
}
|
|
const { data, error } = await get(`/v1/projects/{ref}/analytics/warehouse/tenant`, {
|
|
params: { path: { ref: projectRef } },
|
|
signal,
|
|
})
|
|
if (error) {
|
|
handleError(error)
|
|
}
|
|
|
|
return data
|
|
}
|
|
|
|
export type WarehouseTenantData = Awaited<ReturnType<typeof getWarehouseTenant>>
|
|
export type WarehouseTenantError = ResponseError
|
|
|
|
export const useWarehouseTenantQuery = <TData = WarehouseTenantData>(
|
|
{ projectRef }: WarehouseTenantVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: UseQueryOptions<WarehouseTenantData, WarehouseTenantError, TData> = {}
|
|
) =>
|
|
useQuery<WarehouseTenantData, WarehouseTenantError, TData>(
|
|
analyticsKeys.warehouseTenant(projectRef),
|
|
({ signal }) => getWarehouseTenant({ projectRef }, signal),
|
|
{
|
|
enabled: enabled && !!projectRef,
|
|
staleTime: Infinity,
|
|
// 2H mins cache time
|
|
cacheTime: 120 * 60 * 1000,
|
|
refetchOnMount: false,
|
|
refetchInterval: false,
|
|
...options,
|
|
}
|
|
)
|