ruvector/studio/components/interfaces/Billing/Subscription/Subscription.utils.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

85 lines
2.2 KiB
TypeScript

import type { OrgSubscription, PlanId, ProjectSelectedAddon } from 'data/subscriptions/types'
import { IS_PLATFORM } from 'lib/constants'
export const getAddons = (selectedAddons: ProjectSelectedAddon[]) => {
const computeInstance = selectedAddons.find((addon) => addon.type === 'compute_instance')
const pitr = selectedAddons.find((addon) => addon.type === 'pitr')
const customDomain = selectedAddons.find((addon) => addon.type === 'custom_domain')
const ipv4 = selectedAddons.find((addon) => addon.type === 'ipv4')
return { computeInstance, pitr, customDomain, ipv4 }
}
export const subscriptionHasHipaaAddon = (subscription?: OrgSubscription): boolean => {
if (!IS_PLATFORM) return false
return (subscription?.addons ?? []).some(
(addon) => addon.supabase_prod_id === 'addon_security_hipaa'
)
}
export const billingPartnerLabel = (billingPartner?: string) => {
if (!billingPartner) return billingPartner
switch (billingPartner) {
case 'fly':
return 'Fly.io'
case 'aws':
return 'AWS'
case 'vercel_marketplace':
return 'Vercel'
default:
return billingPartner
}
}
type PlanChangeType = 'upgrade' | 'downgrade' | 'none'
export const getPlanChangeType = (
fromPlan: PlanId | undefined,
toPlan: PlanId | undefined
): PlanChangeType => {
const planChangeTypes: Record<PlanId, Record<PlanId, PlanChangeType>> = {
free: {
free: 'none',
pro: 'upgrade',
team: 'upgrade',
enterprise: 'upgrade',
platform: 'upgrade',
},
pro: {
free: 'downgrade',
pro: 'none',
team: 'upgrade',
enterprise: 'upgrade',
platform: 'upgrade',
},
team: {
free: 'downgrade',
pro: 'downgrade',
team: 'none',
enterprise: 'upgrade',
platform: 'upgrade',
},
enterprise: {
free: 'downgrade',
pro: 'downgrade',
team: 'downgrade',
enterprise: 'none',
platform: 'upgrade',
},
platform: {
free: 'downgrade',
pro: 'downgrade',
team: 'downgrade',
enterprise: 'downgrade',
platform: 'none',
},
}
if (!fromPlan || !toPlan) {
return 'none'
}
return planChangeTypes[fromPlan]?.[toPlan] ?? 'none'
}