The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
[Dashboard] add data api option to new project form (#26809)
Jonathan Summers-Muireb55650d764a
diff --git a/apps/studio/data/projects/project-create-mutation.ts b/apps/studio/data/projects/project-create-mutation.tsindex 5ba8b0c5246..cc253f778eb 100644--- a/apps/studio/data/projects/project-create-mutation.ts+++ b/apps/studio/data/projects/project-create-mutation.ts@@ -27,6 +27,7 @@ export type ProjectCreateVariables = {authSiteUrl?: stringcustomSupabaseRequest?: objectdbInstanceSize?: DbInstanceSize+ dataApiExposedSchemas?: string[]}export async function createProject({@@ -40,6 +41,7 @@ export async function createProject({authSiteUrl,customSupabaseRequest,dbInstanceSize,+ dataApiExposedSchemas,}: ProjectCreateVariables) {const body: components['schemas']['CreateProjectBody'] = {cloud_provider: cloudProvider,@@ -54,6 +56,7 @@ export async function createProject({custom_supabase_internal_requests: customSupabaseRequest as any,}),desired_instance_size: dbInstanceSize,+ data_api_exposed_schemas: dataApiExposedSchemas,}const { data, error } = await post(`/platform/projects`, {diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsxindex b0ed5dafb40..becbd70eb8f 100644--- a/apps/studio/pages/new/[slug].tsx+++ b/apps/studio/pages/new/[slug].tsx@@ -33,7 +33,7 @@ import {} from 'lib/constants'import { passwordStrength } from 'lib/helpers'import { debounce } from 'lodash'-import { ExternalLink } from 'lucide-react'+import { ChevronRight, ExternalLink } from 'lucide-react'import Link from 'next/link'import { useRouter } from 'next/router'import { PropsWithChildren, useEffect, useRef, useState } from 'react'@@ -41,12 +41,19 @@ import { useForm } from 'react-hook-form'import toast from 'react-hot-toast'import type { NextPageWithLayout } from 'types'import {+ Admonition,Badge,Button,+ CollapsibleContent_Shadcn_,+ CollapsibleTrigger_Shadcn_,+ Collapsible_Shadcn_,FormControl_Shadcn_,FormField_Shadcn_,+ FormItem_Shadcn_,Form_Shadcn_,Input_Shadcn_,+ RadioGroupStacked,+ RadioGroupStackedItem,SelectContent_Shadcn_,SelectGroup_Shadcn_,SelectItem_Shadcn_,@@ -59,6 +66,7 @@ import {TableHead,TableHeader,TableRow,+ cn,} from 'ui'import { Input } from 'ui-patterns/DataInputs/Input'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'@@ -255,6 +263,7 @@ const Wizard: NextPageWithLayout = () => {}).min(1, 'Password is required.'),instanceSize: z.string(),+ dataApi: z.boolean(),}).superRefine(({ dbPassStrength }, refinementContext) => {if (dbPassStrength < DEFAULT_MINIMUM_PASSWORD_STRENGTH) {@@ -278,6 +287,7 @@ const Wizard: NextPageWithLayout = () => {dbPassStrength: 0,dbRegion: defaultRegion || undefined,instanceSize: sizes[0],+ dataApi: true,},})@@ -308,10 +318,11 @@ const Wizard: NextPageWithLayout = () => {delayedCheckPasswordStrength(password)}- const onClickNext = async (values: z.infer<typeof FormSchema>) => {+ const onSubmit = async (values: z.infer<typeof FormSchema>) => {if (!currentOrg) return console.error('Unable to retrieve current organization')- const { cloudProvider, projectName, dbPass, dbRegion, postgresVersion, instanceSize } = values+ const { cloudProvider, projectName, dbPass, dbRegion, postgresVersion, instanceSize, dataApi } =+ valuesconst data: ProjectCreateVariables = {cloudProvider: cloudProvider,@@ -324,6 +335,7 @@ const Wizard: NextPageWithLayout = () => {// only set the instance size on pro+ plans. Free plans always use micro (nano in the future) size.dbInstanceSize:orgSubscription?.plan.id === 'free' ? undefined : (instanceSize as DesiredInstanceSize),+ dataApiExposedSchemas: !dataApi ? [] : undefined,}if (postgresVersion) {if (!postgresVersion.match(/1[2-9]\..*/)) {@@ -380,7 +392,7 @@ const Wizard: NextPageWithLayout = () => {return (<Form_Shadcn_ {...form}>- <form onSubmit={form.handleSubmit(onClickNext)}>+ <form onSubmit={form.handleSubmit(onSubmit)}><Panelloading={!isOrganizationsSuccess || isLoadingFreeProjectLimitCheck}title={@@ -680,6 +692,75 @@ const Wizard: NextPageWithLayout = () => {)}/></Panel.Content>++ <Panel.Content>+ <Collapsible_Shadcn_>+ <CollapsibleTrigger_Shadcn_ className="group/advanced-trigger font-mono uppercase tracking-widest text-xs flex items-center gap-1 text-foreground-lighter/75 hover:text-foreground-light transition data-[state=open]:text-foreground-light">+ Advanced options+ <ChevronRight+ size={16}+ strokeWidth={1}+ className="mr-2 group-data-[state=open]/advanced-trigger:rotate-90 group-hover/advanced-trigger:text-foreground-light transition"+ />+ </CollapsibleTrigger_Shadcn_>+ <CollapsibleContent_Shadcn_ className="pt-5 data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down">+ <FormField_Shadcn_+ control={form.control}+ name="dataApi"+ render={({ field }) => (+ <>+ <FormItemLayout+ label="What connections do you plan to use?"+ description="This setting can be changed after the project is created"+ layout="horizontal"+ >+ <FormControl_Shadcn_>+ <RadioGroupStacked+ // Due to radio group not supporting boolean values+ // value is converted to boolean+ onValueChange={(value) => field.onChange(value === 'true')}+ defaultValue={field.value.toString()}+ >+ <FormItem_Shadcn_ asChild>+ <FormControl_Shadcn_>+ <RadioGroupStackedItem+ value={'true'}+ label="Data API + Connection String"+ description="For connecting from the browser, mobile and server."+ />+ </FormControl_Shadcn_>+ </FormItem_Shadcn_>+ <FormItem_Shadcn_ asChild>+ <FormControl_Shadcn_>+ <RadioGroupStackedItem+ label="Only Connection String"+ value="false"+ description="For connecting via server."+ className={cn(+ !form.getValues('dataApi') && '!rounded-b-none'+ )}+ />+ </FormControl_Shadcn_>+ </FormItem_Shadcn_>+ </RadioGroupStacked>+ </FormControl_Shadcn_>+ {!form.getValues('dataApi') && (+ <Admonition+ className="rounded-t-none"+ type={'warning'}+ title="Data API will effectively be disabled"+ >+ PostgREST which powers the Data API will have no schemas+ available to it.+ </Admonition>+ )}+ </FormItemLayout>+ </>+ )}+ />+ </CollapsibleContent_Shadcn_>+ </Collapsible_Shadcn_>+ </Panel.Content>{orgSubscription && orgSubscription.plan.id !== 'free' && (<Panel.Content><FormItemLayoutdiff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.tsindex 49294c36d6f..b47000ecc80 100644--- a/packages/api-types/types/api.d.ts+++ b/packages/api-types/types/api.d.ts@@ -307,11 +307,13 @@ export interface paths {'/platform/organizations/{slug}/members/{gotrue_id}': {/** Removes organization member */delete: operations['MembersController_deleteMember']- /** Updates organization member role */- patch: operations['MembersController_updateMemberRoleV2']+ /** Assign organization member with new role */+ patch: operations['MembersController_assignMemberRoleV2']}'/platform/organizations/{slug}/members/{gotrue_id}/roles/{role_id}': {- /** Removes organization member */+ /** Update organization member role */+ put: operations['MembersController_UpdateMemberRole']+ /** Removes organization member role */delete: operations['MembersController_deleteMemberRole']}'/platform/organizations/{slug}/members/invitations': {@@ -1229,11 +1231,13 @@ export interface paths {'/v0/organizations/{slug}/members/{gotrue_id}': {/** Removes organization member */delete: operations['MembersController_deleteMember']- /** Updates organization member role */- patch: operations['MembersController_updateMemberRoleV2']+ /** Assign organization member with new role */+ patch: operations['MembersController_assignMemberRoleV2']}'/v0/organizations/{slug}/members/{gotrue_id}/roles/{role_id}': {- /** Removes organization member */+ /** Update organization member role */+ put: operations['MembersController_UpdateMemberRole']+ /** Removes organization member role */delete: operations['MembersController_deleteMemberRole']}'/v0/organizations/{slug}/members/invite': {@@ -2077,6 +2081,10 @@ export interface components {ApiResponse: {autoApiService: components['schemas']['AutoApiService']}+ AssignMemberRoleBodyV2: {+ role_id: number+ role_scoped_projects?: string[]+ }AttributeMapping: {keys: {[key: string]: components['schemas']['AttributeValue']@@ -2146,6 +2154,9 @@ export interface components {external_phone_enabled: boolean | nullexternal_slack_client_id: string | nullexternal_slack_enabled: boolean | null+ external_slack_oidc_client_id: string | null+ external_slack_oidc_enabled: boolean | null+ external_slack_oidc_secret: string | nullexternal_slack_secret: string | nullexternal_spotify_client_id: string | nullexternal_spotify_enabled: boolean | null@@ -3199,6 +3210,9 @@ export interface components {EXTERNAL_PHONE_ENABLED: booleanEXTERNAL_SLACK_CLIENT_ID: stringEXTERNAL_SLACK_ENABLED: boolean+ EXTERNAL_SLACK_OIDC_CLIENT_ID: string+ EXTERNAL_SLACK_OIDC_ENABLED: boolean+ EXTERNAL_SLACK_OIDC_SECRET: stringEXTERNAL_SLACK_SECRET: stringEXTERNAL_SPOTIFY_CLIENT_ID: stringEXTERNAL_SPOTIFY_ENABLED: boolean@@ -5095,6 +5109,9 @@ export interface components {external_phone_enabled?: booleanexternal_slack_client_id?: stringexternal_slack_enabled?: boolean+ external_slack_oidc_client_id?: string+ external_slack_oidc_enabled?: boolean+ external_slack_oidc_secret?: stringexternal_slack_secret?: stringexternal_spotify_client_id?: stringexternal_spotify_enabled?: boolean@@ -5326,6 +5343,9 @@ export interface components {EXTERNAL_PHONE_ENABLED?: booleanEXTERNAL_SLACK_CLIENT_ID?: stringEXTERNAL_SLACK_ENABLED?: boolean+ EXTERNAL_SLACK_OIDC_CLIENT_ID?: string+ EXTERNAL_SLACK_OIDC_ENABLED?: boolean+ EXTERNAL_SLACK_OIDC_SECRET?: stringEXTERNAL_SLACK_SECRET?: stringEXTERNAL_SPOTIFY_CLIENT_ID?: stringEXTERNAL_SPOTIFY_ENABLED?: boolean@@ -5438,9 +5458,10 @@ export interface components {UpdateMemberBody: {role_id: number}- UpdateMemberRoleBodyV2: {- role_id: number- role_scoped_projects?: string[]+ UpdateMemberRoleBody: {+ description?: string+ name: string+ role_scoped_projects: string[]}UpdateNotificationBodyV2: {id: string@@ -7636,18 +7657,43 @@ export interface operations {}}}- /** Updates organization member role */- MembersController_updateMemberRoleV2: {+ /** Assign organization member with new role */+ MembersController_assignMemberRoleV2: {+ parameters: {+ path: {+ /** @description Organization slug */+ slug: string+ gotrue_id: string+ }+ }+ requestBody: {+ content: {+ 'application/json': components['schemas']['AssignMemberRoleBodyV2']+ }+ }+ responses: {+ 200: {+ content: never+ }+ /** @description Failed to assign organization member with new role */+ 500: {+ content: never+ }+ }+ }+ /** Update organization member role */+ MembersController_UpdateMemberRole: {parameters: {path: {/** @description Organization slug */slug: stringgotrue_id: string+ role_id: string}}requestBody: {content: {- 'application/json': components['schemas']['UpdateMemberRoleBodyV2']+ 'application/json': components['schemas']['UpdateMemberRoleBody']}}responses: {@@ -7660,7 +7706,7 @@ export interface operations {}}}- /** Removes organization member */+ /** Removes organization member role */MembersController_deleteMemberRole: {parameters: {path: {@@ -7674,7 +7720,7 @@ export interface operations {200: {content: never}- /** @description Failed to remove organization member */+ /** @description Failed to remove organization member role */500: {content: never}diff --git a/packages/ui/src/components/radio-group-stacked.tsx b/packages/ui/src/components/radio-group-stacked.tsxindex 8073403887c..f875185fce6 100644--- a/packages/ui/src/components/radio-group-stacked.tsx+++ b/packages/ui/src/components/radio-group-stacked.tsx@@ -42,7 +42,7 @@ const RadioGroupStackedItem = React.forwardRef<'w-full','bg-overlay/50','border',- 'first-of-type:rounded-t-md last-of-type:rounded-b-md',+ 'first-of-type:rounded-t-lg last-of-type:rounded-b-lg','shadow-sm','hover:bg-surface-300','hover:border-foreground-muted',@@ -56,7 +56,7 @@ const RadioGroupStackedItem = React.forwardRef<props.className)}>- <div className="flex gap-3 w-full px-[21px] py-[16px]">+ <div className="flex gap-3 w-full px-[21px] py-3">{showIndicator && (<divclassName="@@ -77,12 +77,12 @@ const RadioGroupStackedItem = React.forwardRef<</RadioGroupPrimitive.Indicator></div>)}- <div className="flex flex-col gap-1">+ <div className="flex flex-col gap-0.25 items-start"><Label_Shadcn_htmlFor={props.value}className={cn('block',- '-mt-[0.05rem]',+ '-mt-[0.15rem]','text-sm transition-colors text-left','text-light','group-hover:text-foreground group-data-[state=checked]:text-foreground',@@ -92,7 +92,7 @@ const RadioGroupStackedItem = React.forwardRef<{label}</Label_Shadcn_>{props.description && (- <p className="text-xs text-foreground-lighter">{props.description}</p>+ <p className="text-sm text-foreground-lighter">{props.description}</p>)}{props.children}</div>