Files
supabase/apps/studio/data/database/backups-query.ts
Joshen Lim a4243f438f Add restrictions for orioledb technical preview (#30410)
* Add restrictions for orioledb technical preview

* Add callouts to pgvector and postgis if orioledb

* Restrict restore to new project for orioledb

* Scaffold client side validation for preventing org upgrade if org has oriole db present

* Hook up proper logic for oriole

* Fix

* Remove console log

* Fix type

* Disable version selector if only one version is available

* chore: oriole badges

* UI updates based on requests

* Update copy

* Fix

* Dont open assistant if opt is selected

* Fix

* Fix

* Update badge

* Add feature flag for orioleDB

* Feature flag oriole check in plan update

---------

Co-authored-by: Paul Cioanca <paul.cioanca@supabase.io>
2024-11-30 17:36:15 +08:00

43 lines
1.4 KiB
TypeScript

import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import type { components } from 'data/api'
import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databaseKeys } from './keys'
import { useIsOrioleDb } from 'hooks/misc/useSelectedProject'
export type BackupsVariables = {
projectRef?: string
}
export type DatabaseBackup = components['schemas']['Backup']
export async function getBackups({ projectRef }: BackupsVariables, signal?: AbortSignal) {
if (!projectRef) throw new Error('Project ref is required')
const { data, error } = await get(`/platform/database/{ref}/backups`, {
params: { path: { ref: projectRef } },
signal,
})
if (error) handleError(error)
return data
}
export type BackupsData = Awaited<ReturnType<typeof getBackups>>
export type BackupsError = ResponseError
export const useBackupsQuery = <TData = BackupsData>(
{ projectRef }: BackupsVariables,
{ enabled = true, ...options }: UseQueryOptions<BackupsData, BackupsError, TData> = {}
) => {
// [Joshen] Check for specifically false to account for project not loaded yet
const isOrioleDb = useIsOrioleDb()
return useQuery<BackupsData, BackupsError, TData>(
databaseKeys.backups(projectRef),
({ signal }) => getBackups({ projectRef }, signal),
{ enabled: enabled && isOrioleDb === false && typeof projectRef !== 'undefined', ...options }
)
}