ruvector/studio/data/edge-functions/edge-function-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

47 lines
1.5 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import { components } from 'api-types'
import { get, handleError } from 'data/fetchers'
import { IS_PLATFORM } from 'lib/constants'
import type { ResponseError, UseCustomQueryOptions } from 'types'
import { edgeFunctionsKeys } from './keys'
export type EdgeFunctionVariables = {
projectRef?: string
slug?: string
}
export type EdgeFunction = components['schemas']['FunctionSlugResponse']
export async function getEdgeFunction(
{ projectRef, slug }: EdgeFunctionVariables,
signal?: AbortSignal
) {
if (!projectRef) throw new Error('projectRef is required')
if (!slug) throw new Error('slug is required')
const { data, error } = await get(`/v1/projects/{ref}/functions/{function_slug}`, {
params: { path: { ref: projectRef, function_slug: slug } },
signal,
})
if (error) handleError(error)
return data
}
export type EdgeFunctionData = Awaited<ReturnType<typeof getEdgeFunction>>
export type EdgeFunctionError = ResponseError
export const useEdgeFunctionQuery = <TData = EdgeFunctionData>(
{ projectRef, slug }: EdgeFunctionVariables,
{
enabled = true,
...options
}: UseCustomQueryOptions<EdgeFunctionData, EdgeFunctionError, TData> = {}
) =>
useQuery<EdgeFunctionData, EdgeFunctionError, TData>({
queryKey: edgeFunctionsKeys.detail(projectRef, slug),
queryFn: ({ signal }) => getEdgeFunction({ projectRef, slug }, signal),
enabled:
IS_PLATFORM && enabled && typeof projectRef !== 'undefined' && typeof slug !== 'undefined',
...options,
})