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>
49 lines
1.4 KiB
TypeScript
49 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 WarehouseAccessTokensVariables = {
|
|
projectRef: string
|
|
}
|
|
|
|
export async function getWarehouseAccessTokens(
|
|
{ projectRef }: WarehouseAccessTokensVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!projectRef) {
|
|
throw new Error('projectRef is required')
|
|
}
|
|
|
|
// TODO: Remove typecast when codegen types are fixed
|
|
const response = await get(`/v1/projects/{ref}/analytics/warehouse/access-tokens`, {
|
|
params: { path: { ref: projectRef } },
|
|
signal,
|
|
})
|
|
|
|
if (response.error) {
|
|
handleError(response)
|
|
}
|
|
|
|
return response
|
|
}
|
|
|
|
export type WarehouseAccessTokensData = Awaited<ReturnType<typeof getWarehouseAccessTokens>>
|
|
export type WarehouseAccessTokensError = ResponseError
|
|
|
|
export const useWarehouseAccessTokensQuery = <TData = WarehouseAccessTokensData>(
|
|
{ projectRef }: WarehouseAccessTokensVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: UseQueryOptions<WarehouseAccessTokensData, WarehouseAccessTokensError, TData> = {}
|
|
) =>
|
|
useQuery<WarehouseAccessTokensData, WarehouseAccessTokensError, TData>(
|
|
analyticsKeys.warehouseAccessTokens(projectRef),
|
|
({ signal }) => getWarehouseAccessTokens({ projectRef }, signal),
|
|
{
|
|
enabled: enabled && typeof projectRef !== 'undefined',
|
|
...options,
|
|
}
|
|
)
|