mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 15:19:08 +03:00
* Add settings for queues: toggle expose through postgrest + permissions via table privileges * Ensure appropriate grants are granted when toggling, and revoked when disabling * Update to use queues_public schema * Update queue schema to pgmq_public and add/remove from data api when enabling/disabling * Fix query for retrieving toggle state * Add schema invalidation * Remove hard code * Use QueuesSettings from Queues folder, remove from NewQueues * Update SQL for toggling exposure + support RLS enabling * Support toggling RLS for a queue * Update admonition copy in queues for enabling/disable postgrest exposure * Add custom RLS policy for queue * Minor style fixes * Fix * Remove hard code * Update RLS to add message regarding relevancy only if exposure to PostgREST is enabled * Update message in exposing queues to postgREST * Address feedback * Address feedback * Don't revoke postgres role stuff * Remove hard code * Update copy * Update * Address Oli's feedback, ensure that queues ALL have RLS enabled prior to allowing exposure to PostgREST * Address remaining feedback * Remove hardcode * Update * Address feedback
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
import { get } from 'lib/common/fetch'
|
|
import { API_URL } from 'lib/constants'
|
|
import { configKeys } from './keys'
|
|
import { ResponseError } from 'types'
|
|
|
|
export type ProjectPostgrestConfigVariables = {
|
|
projectRef?: string
|
|
}
|
|
|
|
export type ProjectPostgrestConfigResponse = {
|
|
max_rows: number
|
|
role_claim_key: string
|
|
db_schema: string
|
|
db_anon_role: string
|
|
db_extra_search_path: string
|
|
db_pool: number | null
|
|
jwt_secret: string
|
|
}
|
|
|
|
export async function getProjectPostgrestConfig(
|
|
{ projectRef }: ProjectPostgrestConfigVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!projectRef) {
|
|
throw new Error('projectRef is required')
|
|
}
|
|
|
|
const response = await get(`${API_URL}/projects/${projectRef}/config/postgrest`, {
|
|
signal,
|
|
})
|
|
if (response.error) {
|
|
throw response.error
|
|
}
|
|
|
|
return response as ProjectPostgrestConfigResponse
|
|
}
|
|
|
|
export type ProjectPostgrestConfigData = Awaited<ReturnType<typeof getProjectPostgrestConfig>>
|
|
export type ProjectPostgrestConfigError = ResponseError
|
|
|
|
export const useProjectPostgrestConfigQuery = <TData = ProjectPostgrestConfigData>(
|
|
{ projectRef }: ProjectPostgrestConfigVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: UseQueryOptions<ProjectPostgrestConfigData, ProjectPostgrestConfigError, TData> = {}
|
|
) =>
|
|
useQuery<ProjectPostgrestConfigData, ProjectPostgrestConfigError, TData>(
|
|
configKeys.postgrest(projectRef),
|
|
({ signal }) => getProjectPostgrestConfig({ projectRef }, signal),
|
|
{
|
|
enabled: enabled && typeof projectRef !== 'undefined',
|
|
...options,
|
|
}
|
|
)
|