mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-26 07:44:05 +00:00
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>
70 lines
2 KiB
TypeScript
70 lines
2 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { operations } from 'api-types'
|
|
import { get, handleError } from 'data/fetchers'
|
|
import { analyticsKeys } from './keys'
|
|
import { UseCustomQueryOptions } from 'types'
|
|
|
|
export type FunctionsResourceUsageVariables = {
|
|
projectRef?: string
|
|
functionId?: string
|
|
interval?: operations['FunctionsLogsController_getRequestStats']['parameters']['query']['interval']
|
|
}
|
|
|
|
export type FunctionsResourceUsageResponse = any
|
|
|
|
export async function getFunctionsResourceUsage(
|
|
{ projectRef, functionId, interval }: FunctionsResourceUsageVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!projectRef) {
|
|
throw new Error('projectRef is required')
|
|
}
|
|
if (!functionId) {
|
|
throw new Error('functionId is required')
|
|
}
|
|
if (!interval) {
|
|
throw new Error('interval is required')
|
|
}
|
|
|
|
const { data, error } = await get(
|
|
'/platform/projects/{ref}/analytics/endpoints/functions.resource-usage',
|
|
{
|
|
params: {
|
|
path: {
|
|
ref: projectRef,
|
|
},
|
|
query: {
|
|
function_id: functionId,
|
|
interval,
|
|
},
|
|
},
|
|
signal,
|
|
}
|
|
)
|
|
|
|
if (error) handleError(error)
|
|
|
|
return data
|
|
}
|
|
|
|
export type FunctionsResourceUsageData = Awaited<ReturnType<typeof getFunctionsResourceUsage>>
|
|
export type FunctionsResourceUsageError = unknown
|
|
|
|
export const useFunctionsResourceUsageQuery = <TData = FunctionsResourceUsageData>(
|
|
{ projectRef, functionId, interval }: FunctionsResourceUsageVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: UseCustomQueryOptions<FunctionsResourceUsageData, FunctionsResourceUsageError, TData> = {}
|
|
) =>
|
|
useQuery<FunctionsResourceUsageData, FunctionsResourceUsageError, TData>({
|
|
queryKey: analyticsKeys.functionsResourceUsage(projectRef, { functionId, interval }),
|
|
queryFn: ({ signal }) =>
|
|
getFunctionsResourceUsage({ projectRef, functionId, interval }, signal),
|
|
enabled:
|
|
enabled &&
|
|
typeof projectRef !== 'undefined' &&
|
|
typeof functionId !== 'undefined' &&
|
|
typeof interval !== 'undefined',
|
|
...options,
|
|
})
|