mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-25 23:24:03 +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>
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
|
|
import { get, handleError } from 'data/fetchers'
|
|
import { IS_PLATFORM } from 'lib/constants'
|
|
import type { ResponseError, UseCustomQueryOptions } from 'types'
|
|
import { branchKeys } from './keys'
|
|
|
|
export type BranchDiffVariables = {
|
|
branchRef: string
|
|
projectRef: string
|
|
includedSchemas?: string
|
|
}
|
|
|
|
export async function getBranchDiff({
|
|
branchRef,
|
|
includedSchemas,
|
|
}: Pick<BranchDiffVariables, 'branchRef' | 'includedSchemas'>) {
|
|
const { data: diffData, error } = await get('/v1/branches/{branch_id_or_ref}/diff', {
|
|
params: {
|
|
path: { branch_id_or_ref: branchRef },
|
|
query: includedSchemas ? { included_schemas: includedSchemas } : undefined,
|
|
},
|
|
headers: {
|
|
Accept: 'text/plain',
|
|
},
|
|
parseAs: 'text',
|
|
})
|
|
|
|
if (error) {
|
|
handleError(error)
|
|
}
|
|
|
|
// Handle empty object responses (when no diff exists)
|
|
if (typeof diffData === 'object' && Object.keys(diffData).length === 0) {
|
|
return ''
|
|
}
|
|
|
|
return diffData || ''
|
|
}
|
|
|
|
type BranchDiffData = Awaited<ReturnType<typeof getBranchDiff>>
|
|
|
|
export const useBranchDiffQuery = (
|
|
{ branchRef, projectRef, includedSchemas }: BranchDiffVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: Omit<UseCustomQueryOptions<BranchDiffData, ResponseError>, 'queryKey' | 'queryFn'> = {}
|
|
) =>
|
|
useQuery<BranchDiffData, ResponseError>({
|
|
queryKey: branchKeys.diff(projectRef, branchRef),
|
|
queryFn: () => getBranchDiff({ branchRef, includedSchemas }),
|
|
enabled: IS_PLATFORM && enabled && Boolean(branchRef),
|
|
...options,
|
|
})
|