The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: vercel custom public env var prefix (#28058)
Alaister Young560d239100ab
diff --git a/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelIntegrationConnectionForm.tsx b/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelIntegrationConnectionForm.tsxindex 2d644fd2e22..bd6d8821ace 100644--- a/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelIntegrationConnectionForm.tsx+++ b/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelIntegrationConnectionForm.tsx@@ -3,6 +3,7 @@ import { useForm } from 'react-hook-form'import toast from 'react-hot-toast'import * as z from 'zod'+import { FormActions } from 'components/ui/Forms/FormActions'import type {EnvironmentTargets,Integration,@@ -15,10 +16,14 @@ import {FormField_Shadcn_,FormItem_Shadcn_,FormLabel_Shadcn_,+ FormMessage_Shadcn_,Form_Shadcn_,+ Input_Shadcn_,Switch,} from 'ui'+const VERCEL_CONNECTION_FORM_ID = 'vercel-connection-form'+const VercelIntegrationConnectionForm = ({disabled,connection,@@ -34,6 +39,7 @@ const VercelIntegrationConnectionForm = ({environmentVariablesProduction: z.boolean().default(envSyncTargets.includes('production')),environmentVariablesPreview: z.boolean().default(envSyncTargets.includes('preview')),environmentVariablesDevelopment: z.boolean().default(envSyncTargets.includes('development')),+ publicEnvVarPrefix: z.string().optional(),})const form = useForm<z.infer<typeof FormSchema>>({@@ -42,11 +48,15 @@ const VercelIntegrationConnectionForm = ({environmentVariablesProduction: envSyncTargets.includes('production'),environmentVariablesPreview: envSyncTargets.includes('preview'),environmentVariablesDevelopment: envSyncTargets.includes('development'),+ publicEnvVarPrefix: connection.public_env_var_prefix,},})- const { mutate: updateVercelConnection } = useVercelConnectionUpdateMutation({- onSuccess: () => toast.success(`Updated Vercel connection`),+ const { mutate: updateVercelConnection, isLoading } = useVercelConnectionUpdateMutation({+ onSuccess: () => {+ form.reset(form.getValues())+ toast.success(`Updated Vercel connection`)+ },})function onSubmit(data: z.infer<typeof FormSchema>) {@@ -65,13 +75,18 @@ const VercelIntegrationConnectionForm = ({updateVercelConnection({id: connection.id,envSyncTargets: envSyncTargets as EnvironmentTargets[],+ publicEnvVarPrefix: data.publicEnvVarPrefix?.trim(),organizationIntegrationId: integration.id,})}return (<Form_Shadcn_ {...form}>- <form onSubmit={form.handleSubmit(onSubmit)} className={'w-full space-y-6'}>+ <form+ id={VERCEL_CONNECTION_FORM_ID}+ onSubmit={form.handleSubmit(onSubmit)}+ className={'w-full space-y-6'}+ ><div className="px-6 py-4 flex flex-col gap-y-4"><h5 className="text-foreground text-sm">Sync environment variables for selected target environments@@ -87,10 +102,7 @@ const VercelIntegrationConnectionForm = ({disabled={disabled}className="mt-1"checked={field.value}- onCheckedChange={(e) => {- field.onChange(e)- form.handleSubmit(onSubmit)()- }}+ onCheckedChange={field.onChange}/></FormControl_Shadcn_><div>@@ -112,10 +124,7 @@ const VercelIntegrationConnectionForm = ({disabled={disabled}className="mt-1"checked={field.value}- onCheckedChange={(e) => {- field.onChange(e)- form.handleSubmit(onSubmit)()- }}+ onCheckedChange={field.onChange}/></FormControl_Shadcn_><div>@@ -137,10 +146,7 @@ const VercelIntegrationConnectionForm = ({disabled={disabled}className="mt-1"checked={field.value}- onCheckedChange={(e) => {- field.onChange(e)- form.handleSubmit(onSubmit)()- }}+ onCheckedChange={field.onChange}/></FormControl_Shadcn_><div>@@ -153,6 +159,80 @@ const VercelIntegrationConnectionForm = ({)}/></div>+ <h5 className="mt-2 text-foreground text-sm">+ Customize public environment variable prefix+ </h5>+ <div className="flex flex-col gap-4">+ <FormField_Shadcn_+ control={form.control}+ name="publicEnvVarPrefix"+ render={({ field }) => (+ <FormItem_Shadcn_ className="grid gap-2 md:grid md:grid-cols-12 space-y-0">+ <FormLabel_Shadcn_ className="flex flex-col space-y-2 col-span-4 text-sm justify-center text-foreground-light">+ Prefix+ </FormLabel_Shadcn_>+ <FormControl_Shadcn_ className="col-span-8">+ <Input_Shadcn_+ {...field}+ className="w-full"+ placeholder="An empty prefix will result in no public env vars"+ />+ </FormControl_Shadcn_>+ <FormDescription_Shadcn_ className="col-start-5 col-span-8 text-xs">+ e.g.{' '}+ <code+ className="cursor-pointer"+ role="button"+ onClick={() => {+ field.onChange('NEXT_PUBLIC_')+ }}+ >+ NEXT_PUBLIC_+ </code>+ ,{' '}+ <code+ className="cursor-pointer"+ role="button"+ onClick={() => {+ field.onChange('VITE_PUBLIC_')+ }}+ >+ VITE_PUBLIC_+ </code>+ ,{' '}+ <code+ className="cursor-pointer"+ role="button"+ onClick={() => {+ field.onChange('PUBLIC_')+ }}+ >+ PUBLIC_+ </code>+ , etc.+ </FormDescription_Shadcn_>++ <FormMessage_Shadcn_ className="col-start-5 col-span-8" />+ </FormItem_Shadcn_>+ )}+ />+ </div>++ {form.formState.isDirty ? (+ <p className="mt-2 text-sm text-warning-600">+ Note: Changing these settings will <strong>not</strong> trigger a resync of+ environment variables.+ </p>+ ) : (+ <div className="mt-2 h-5 w-full" />+ )}++ <FormActions+ form={VERCEL_CONNECTION_FORM_ID}+ hasChanges={form.formState.isDirty}+ isSubmitting={isLoading}+ handleReset={() => form.reset()}+ /></div></form></Form_Shadcn_>diff --git a/apps/studio/data/integrations/integrations.types.ts b/apps/studio/data/integrations/integrations.types.tsindex 9ba950b4b3d..f79843b59e5 100644--- a/apps/studio/data/integrations/integrations.types.ts+++ b/apps/studio/data/integrations/integrations.types.ts@@ -156,6 +156,7 @@ export type IntegrationProjectConnection = {foreign_project_id: stringorganization_integration_id: stringenv_sync_targets?: string[]+ public_env_var_prefix?: stringmetadata: Imetadata}@@ -272,4 +273,5 @@ export type UpdateConnectionPayload = {id: stringorganizationIntegrationId: stringenvSyncTargets: EnvironmentTargets[]+ publicEnvVarPrefix?: string}diff --git a/apps/studio/data/integrations/vercel-connection-update-mutate.ts b/apps/studio/data/integrations/vercel-connection-update-mutate.tsindex 1d5c5904de4..eeddcc19f38 100644--- a/apps/studio/data/integrations/vercel-connection-update-mutate.ts+++ b/apps/studio/data/integrations/vercel-connection-update-mutate.ts@@ -6,13 +6,18 @@ import type { ResponseError } from 'types'import type { UpdateConnectionPayload } from './integrations.types'import { integrationKeys } from './keys'-export async function updateVercelConnection({ id, envSyncTargets }: UpdateConnectionPayload) {+export async function updateVercelConnection({+ id,+ envSyncTargets,+ publicEnvVarPrefix,+}: UpdateConnectionPayload) {const { data, error } = await patch('/platform/integrations/vercel/connections/{connection_id}', {params: {path: { connection_id: id },},body: {env_sync_targets: envSyncTargets,+ public_env_var_prefix: publicEnvVarPrefix,},})diff --git a/packages/api-types/package.json b/packages/api-types/package.jsonindex 69ea1dacb6f..a71266edcba 100644--- a/packages/api-types/package.json+++ b/packages/api-types/package.json@@ -5,7 +5,7 @@"main": "./index.ts","types": "./index.ts","scripts": {- "codegen": "openapi-typescript http://localhost:8080/api.json -o types/api.d.ts --alphabetize && prettier --write types/api.d.ts"+ "codegen": "openapi-typescript http://localhost:8080/api-json -o types/api.d.ts --alphabetize && prettier --write types/api.d.ts"},"author": "","license": "MIT",diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.tsindex 8bb1e54da2c..f1ad7619ef2 100644--- a/packages/api-types/types/api.d.ts+++ b/packages/api-types/types/api.d.ts@@ -3137,7 +3137,6 @@ export interface components {expires_at: stringicon?: stringname: string- organization_slug?: stringscopes?: (| 'analytics:read'| 'analytics:write'@@ -3912,6 +3911,7 @@ export interface components {| 'STORAGE_IMAGES_TRANSFORMED'| 'REALTIME_MESSAGE_COUNT'| 'REALTIME_PEAK_CONNECTIONS'+ | 'DISK_GB_HOURS'| 'COMPUTE_HOURS_BRANCH'| 'COMPUTE_HOURS_XS'| 'COMPUTE_HOURS_SM'@@ -5892,6 +5892,7 @@ export interface components {}UpdateVercelConnectionsBody: {env_sync_targets?: ('production' | 'preview' | 'development')[]+ public_env_var_prefix?: string}UpgradeDatabaseBody: {target_version: number@@ -6029,7 +6030,7 @@ export interface components {inserted_at: stringis_physical_backup: boolean/** @enum {string} */- status: 'COMPLETED' | 'FAILED' | 'PENDING' | 'REMOVED' | 'ARCHIVED'+ status: 'COMPLETED' | 'FAILED' | 'PENDING' | 'REMOVED' | 'ARCHIVED' | 'CANCELLED'}V1BackupsResponse: {backups: components['schemas']['V1Backup'][]@@ -7802,6 +7803,7 @@ export interface operations {| 'STORAGE_IMAGES_TRANSFORMED'| 'REALTIME_MESSAGE_COUNT'| 'REALTIME_PEAK_CONNECTIONS'+ | 'DISK_GB_HOURS'| 'COMPUTE_HOURS_BRANCH'| 'COMPUTE_HOURS_XS'| 'COMPUTE_HOURS_SM'