mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-25 06:36:37 +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>
61 lines
2 KiB
TypeScript
61 lines
2 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { useQuery } from '@tanstack/react-query'
|
|
|
|
import { get, handleError } from 'data/fetchers'
|
|
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
|
|
import type { ResponseError, UseCustomQueryOptions } from 'types'
|
|
import { subscriptionKeys } from './keys'
|
|
|
|
export type OrgSubscriptionVariables = {
|
|
orgSlug?: string
|
|
}
|
|
|
|
export async function getOrgSubscription(
|
|
{ orgSlug }: OrgSubscriptionVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!orgSlug) throw new Error('orgSlug is required')
|
|
|
|
const { error, data } = await get('/platform/organizations/{slug}/billing/subscription', {
|
|
params: { path: { slug: orgSlug } },
|
|
signal,
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
export type OrgSubscriptionData = Awaited<ReturnType<typeof getOrgSubscription>>
|
|
export type OrgSubscriptionError = ResponseError
|
|
|
|
export const useOrgSubscriptionQuery = <TData = OrgSubscriptionData>(
|
|
{ orgSlug }: OrgSubscriptionVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: UseCustomQueryOptions<OrgSubscriptionData, OrgSubscriptionError, TData> = {}
|
|
) => {
|
|
// [Joshen] Thinking it makes sense to add this check at the RQ level - prevent
|
|
// unnecessary requests, although this behaviour still needs handling on the UI
|
|
const { can: canReadSubscriptions } = useAsyncCheckPermissions(
|
|
PermissionAction.BILLING_READ,
|
|
'stripe.subscriptions'
|
|
)
|
|
|
|
return useQuery<OrgSubscriptionData, OrgSubscriptionError, TData>({
|
|
queryKey: subscriptionKeys.orgSubscription(orgSlug),
|
|
queryFn: ({ signal }) => getOrgSubscription({ orgSlug }, signal),
|
|
enabled: enabled && canReadSubscriptions && typeof orgSlug !== 'undefined',
|
|
staleTime: 60 * 60 * 1000,
|
|
...options,
|
|
})
|
|
}
|
|
|
|
export const useHasAccessToProjectLevelPermissions = (slug: string) => {
|
|
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: slug })
|
|
return (
|
|
subscription?.plan.id === 'enterprise' ||
|
|
subscription?.plan.id === 'team' ||
|
|
subscription?.plan.id === 'platform'
|
|
)
|
|
}
|