ruvector/studio/data/views/views-query.ts
rUv 814f595995 feat(studio): Add complete RuVector Studio application
Major additions:
- Complete Next.js studio application with 1600+ components
- Docker support (Dockerfile.combined, docker-compose.yml)
- GCP deployment documentation and benchmarks
- SQL benchmark scripts for performance testing
- Sentry integration for monitoring
- Comprehensive test suite and mocks

Studio features:
- Dashboard and admin interfaces
- Data visualization components
- Authentication and user management
- API integration with RuVector backend
- Static data and public assets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:04:48 +00:00

56 lines
1.8 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import { DEFAULT_PLATFORM_APPLICATION_NAME } from '@supabase/pg-meta/src/constants'
import { PostgresView } from '@supabase/postgres-meta'
import { get, handleError } from 'data/fetchers'
import type { ResponseError, UseCustomQueryOptions } from 'types'
import { viewKeys } from './keys'
export type ViewsVariables = {
projectRef?: string
connectionString?: string | null
schema?: string
}
export async function getViews(
{ projectRef, connectionString, schema }: ViewsVariables,
signal?: AbortSignal
) {
if (!projectRef) throw new Error('projectRef is required')
let headers = new Headers()
if (connectionString) headers.set('x-connection-encrypted', connectionString)
const { data, error } = await get('/platform/pg-meta/{ref}/views', {
params: {
header: {
'x-connection-encrypted': connectionString!,
'x-pg-application-name': DEFAULT_PLATFORM_APPLICATION_NAME,
},
path: { ref: projectRef },
query: {
included_schemas: schema || '',
} as any,
},
headers,
signal,
})
if (error) handleError(error)
return data as PostgresView[]
}
export type ViewsData = Awaited<ReturnType<typeof getViews>>
export type ViewsError = ResponseError
export const useViewsQuery = <TData = ViewsData>(
{ projectRef, connectionString, schema }: ViewsVariables,
{ enabled = true, ...options }: UseCustomQueryOptions<ViewsData, ViewsError, TData> = {}
) =>
useQuery<ViewsData, ViewsError, TData>({
queryKey: schema ? viewKeys.listBySchema(projectRef, schema) : viewKeys.list(projectRef),
queryFn: ({ signal }) => getViews({ projectRef, connectionString, schema }, signal),
enabled: enabled && typeof projectRef !== 'undefined',
staleTime: 0,
...options,
})