Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Support using API schema in create project (#27918)

Joshen Lim5d0d63284b9e
diff --git a/apps/studio/components/ui/PasswordStrengthBar.tsx b/apps/studio/components/ui/PasswordStrengthBar.tsx
index 45fdc93b2c7..f1c6f4cd402 100644
--- a/apps/studio/components/ui/PasswordStrengthBar.tsx
+++ b/apps/studio/components/ui/PasswordStrengthBar.tsx
@@ -31,7 +31,7 @@ const PasswordStrengthBar = ({
className={`relative h-1 w-full ${
(PASSWORD_STRENGTH_COLOR as any)[passwordStrengthScore]
} transition-all duration-500 ease-out shadow-inner`}
- ></div>
+ />
</div>
)}
<p>
diff --git a/apps/studio/data/projects/project-create-mutation.ts b/apps/studio/data/projects/project-create-mutation.ts
index bbb189d8b26..6e44d918ff0 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 = {
customSupabaseRequest?: object
dbInstanceSize?: DbInstanceSize
dataApiExposedSchemas?: string[]
+ dataApiUseApiSchema?: boolean
}
export async function createProject({
@@ -40,6 +41,7 @@ export async function createProject({
customSupabaseRequest,
dbInstanceSize,
dataApiExposedSchemas,
+ dataApiUseApiSchema,
}: ProjectCreateVariables) {
const body: components['schemas']['CreateProjectBody'] = {
cloud_provider: cloudProvider,
@@ -54,6 +56,7 @@ export async function createProject({
}),
desired_instance_size: dbInstanceSize,
data_api_exposed_schemas: dataApiExposedSchemas,
+ data_api_use_api_schema: dataApiUseApiSchema,
}
const { data, error } = await post(`/platform/projects`, {
diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsx
index d2a06d245a6..177eb67d667 100644
--- a/apps/studio/pages/new/[slug].tsx
+++ b/apps/studio/pages/new/[slug].tsx
@@ -1,4 +1,5 @@
import { zodResolver } from '@hookform/resolvers/zod'
+import { PermissionAction } from '@supabase/shared-types/out/constants'
import generator from 'generate-password-browser'
import { debounce } from 'lodash'
import { ChevronRight, ExternalLink } from 'lucide-react'
@@ -9,7 +10,6 @@ import { useForm } from 'react-hook-form'
import toast from 'react-hot-toast'
import { z } from 'zod'
-import { PermissionAction } from '@supabase/shared-types/out/constants'
import { PopoverSeparator } from '@ui/components/shadcn/ui/popover'
import { components } from 'api-types'
import { useParams } from 'common'
@@ -287,6 +287,7 @@ const Wizard: NextPageWithLayout = () => {
.min(1, 'Password is required.'),
instanceSize: z.string(),
dataApi: z.boolean(),
+ useApiSchema: z.boolean(),
})
.superRefine(({ dbPassStrength }, refinementContext) => {
if (dbPassStrength < DEFAULT_MINIMUM_PASSWORD_STRENGTH) {
@@ -311,6 +312,7 @@ const Wizard: NextPageWithLayout = () => {
dbRegion: defaultRegion || undefined,
instanceSize: sizes[0],
dataApi: true,
+ useApiSchema: false,
},
})
@@ -344,8 +346,16 @@ const Wizard: NextPageWithLayout = () => {
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, dataApi } =
- values
+ const {
+ cloudProvider,
+ projectName,
+ dbPass,
+ dbRegion,
+ postgresVersion,
+ instanceSize,
+ dataApi,
+ useApiSchema,
+ } = values
const data: ProjectCreateVariables = {
cloudProvider: cloudProvider,
@@ -359,6 +369,7 @@ const Wizard: NextPageWithLayout = () => {
dbInstanceSize:
orgSubscription?.plan.id === 'free' ? undefined : (instanceSize as DesiredInstanceSize),
dataApiExposedSchemas: !dataApi ? [] : undefined,
+ dataApiUseApiSchema: !dataApi ? false : useApiSchema,
}
if (postgresVersion) {
if (!postgresVersion.match(/1[2-9]\..*/)) {
@@ -422,7 +433,7 @@ const Wizard: NextPageWithLayout = () => {
<div key="panel-title">
<h3>Create a new project</h3>
<p className="text-sm text-foreground-lighter">
- Your project will have its own dedicated instance and full postgres database.
+ Your project will have its own dedicated instance and full Postgres database.
<br />
An API will be set up so you can easily interact with your new database.
<br />
@@ -839,14 +850,12 @@ const Wizard: NextPageWithLayout = () => {
label="Database Password"
layout="horizontal"
description={
- <>
- <PasswordStrengthBar
- passwordStrengthScore={form.getValues('dbPassStrength')}
- password={field.value}
- passwordStrengthMessage={passwordStrengthMessage}
- generateStrongPassword={generateStrongPassword}
- />
- </>
+ <PasswordStrengthBar
+ passwordStrengthScore={form.getValues('dbPassStrength')}
+ password={field.value}
+ passwordStrengthMessage={passwordStrengthMessage}
+ generateStrongPassword={generateStrongPassword}
+ />
}
>
<FormControl_Shadcn_>
@@ -898,16 +907,19 @@ const Wizard: NextPageWithLayout = () => {
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">
+ <CollapsibleContent_Shadcn_
+ className={cn(
+ 'pt-5 data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down'
+ )}
+ >
<FormField_Shadcn_
- control={form.control}
name="dataApi"
+ control={form.control}
render={({ field }) => (
<>
<FormItemLayout
- label="What connections do you plan to use?"
- description="This setting can be changed after the project is created"
layout="horizontal"
+ label="What connections do you plan to use?"
>
<FormControl_Shadcn_>
<RadioGroupStacked
@@ -919,9 +931,10 @@ const Wizard: NextPageWithLayout = () => {
<FormItem_Shadcn_ asChild>
<FormControl_Shadcn_>
<RadioGroupStackedItem
- value={'true'}
+ value="true"
+ className="[&>div>div>p]:text-left"
label="Data API + Connection String"
- description="For connecting from the browser, mobile and server."
+ description="Connect to Postgres via autogenerated HTTP APIs or the Postgres protocol"
/>
</FormControl_Shadcn_>
</FormItem_Shadcn_>
@@ -930,7 +943,7 @@ const Wizard: NextPageWithLayout = () => {
<RadioGroupStackedItem
label="Only Connection String"
value="false"
- description="For connecting via server."
+ description="Use Postgres without the autogenerated APIs"
className={cn(
!form.getValues('dataApi') && '!rounded-b-none'
)}
@@ -942,7 +955,7 @@ const Wizard: NextPageWithLayout = () => {
{!form.getValues('dataApi') && (
<Admonition
className="rounded-t-none"
- type={'warning'}
+ type="warning"
title="Data API will effectively be disabled"
>
PostgREST which powers the Data API will have no schemas
@@ -953,6 +966,72 @@ const Wizard: NextPageWithLayout = () => {
</>
)}
/>
+
+ {form.getValues('dataApi') && (
+ <FormField_Shadcn_
+ name="useApiSchema"
+ control={form.control}
+ render={({ field }) => (
+ <>
+ <FormItemLayout
+ className="mt-6"
+ layout="horizontal"
+ label="Data API Configuration"
+ >
+ <FormControl_Shadcn_>
+ <RadioGroupStacked
+ defaultValue={field.value.toString()}
+ onValueChange={(value) => field.onChange(value === 'true')}
+ >
+ <FormItem_Shadcn_ asChild>
+ <FormControl_Shadcn_>
+ <RadioGroupStackedItem
+ value="false"
+ // @ts-ignore
+ label={
+ <>
+ Use public schema for Data API
+ <Badge color="scale" className="ml-2">
+ Default
+ </Badge>
+ </>
+ }
+ // @ts-ignore
+ description={
+ <>
+ Query all tables in the{' '}
+ <code className="text-xs">public</code> schema
+ </>
+ }
+ />
+ </FormControl_Shadcn_>
+ </FormItem_Shadcn_>
+ <FormItem_Shadcn_ asChild>
+ <FormControl_Shadcn_>
+ <RadioGroupStackedItem
+ value="true"
+ label="Use dedicated API schema for Data API"
+ // @ts-ignore
+ description={
+ <>
+ Query allowlisted tables in a dedicated{' '}
+ <code className="text-xs">api</code> schema
+ </>
+ }
+ />
+ </FormControl_Shadcn_>
+ </FormItem_Shadcn_>
+ </RadioGroupStacked>
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ </>
+ )}
+ />
+ )}
+ <p className="text-xs text-foreground-lighter text-right mt-3">
+ These settings can be changed after the project is created via the
+ project's settings
+ </p>
</CollapsibleContent_Shadcn_>
</Collapsible_Shadcn_>
</Panel.Content>
diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.ts
index 0c1d0585436..46baec31ea0 100644
--- a/packages/api-types/types/api.d.ts
+++ b/packages/api-types/types/api.d.ts
@@ -31,6 +31,10 @@ export interface paths {
/** Starts Fly single sign on */
get: operations['ExtensionController_startFlyioSSO']
}
+ '/partners/flyio/extensions/eligibility': {
+ /** Checks database provisioning eligibility */
+ post: operations['FlyExtensionsController_checkEligibility']
+ }
'/partners/flyio/organizations/{organization_id}': {
/** Gets details of the organization linked to the provided Fly organization id */
get: operations['FlyOrganizationsController_getOrganization']
@@ -999,6 +1003,10 @@ export interface paths {
/** Processes Vercel event */
post: operations['VercelWebhooksController_processEvent']
}
+ '/system/orb/webhooks': {
+ /** Processes Orb events */
+ post: operations['OrbWebhooksController_processEvent']
+ }
'/system/organizations/{slug}/billing/partner/usage-and-costs': {
/** Gets the partner usage and costs */
get: operations['PartnerBillingSystemController_getPartnerUsageAndCosts']
@@ -1795,6 +1803,18 @@ export interface paths {
/** Removes a SSO provider by its UUID */
delete: operations['v1-delete-a-sso-provider']
}
+ '/v1/projects/{ref}/config/auth/third-party-auth': {
+ /** [Alpha] Lists all third-party auth integrations */
+ get: operations['ThirdPartyAuthController_listTPAForProject']
+ /** [Alpha] Creates a new third-party auth integration */
+ post: operations['ThirdPartyAuthController_createTPAForProject']
+ }
+ '/v1/projects/{ref}/config/auth/third-party-auth/{tpa_id}': {
+ /** [Alpha] Get a third-party integration */
+ get: operations['ThirdPartyAuthController_getTPAForProject']
+ /** [Alpha] Removes a third-party auth integration */
+ delete: operations['ThirdPartyAuthController_deleteTPAForProject']
+ }
'/v1/projects/{ref}/config/database/pgbouncer': {
/** Get project's pgbouncer config */
get: operations['v1-get-project-pgbouncer-config']
@@ -2202,6 +2222,7 @@ export interface components {
rate_limit_verify: number | null
refresh_token_rotation_enabled: boolean | null
saml_enabled: boolean | null
+ saml_external_url: string | null
security_captcha_enabled: boolean | null
security_captcha_provider: string | null
security_captcha_secret: string | null
@@ -2576,6 +2597,7 @@ export interface components {
cloud_provider: string
custom_supabase_internal_requests?: components['schemas']['CustomSupabaseInternalRequests']
data_api_exposed_schemas?: string[]
+ data_api_use_api_schema?: boolean
db_pass: string
db_pricing_tier_id?: string
db_region: string
@@ -2692,6 +2714,11 @@ export interface components {
type: string
value: string
}
+ CreateThirdPartyAuthBody: {
+ custom_jwks?: Record<string, never>
+ jwks_url?: string
+ oidc_issuer_url?: string
+ }
CreateTriggerBody: {
/** @enum {string} */
activation: 'AFTER' | 'BEFORE'
@@ -3138,6 +3165,7 @@ export interface components {
GetUserContentByIdResponse: {
content: Record<string, never>
description?: string
+ favorite: boolean | null
folder_id?: string
id: string
inserted_at: string
@@ -3345,6 +3373,7 @@ export interface components {
RATE_LIMIT_VERIFY: number
REFRESH_TOKEN_ROTATION_ENABLED: boolean
SAML_ENABLED: boolean
+ SAML_EXTERNAL_URL: string
SECURITY_CAPTCHA_ENABLED: boolean
SECURITY_CAPTCHA_PROVIDER: string
SECURITY_CAPTCHA_SECRET: string
@@ -4567,6 +4596,21 @@ export interface components {
*/
DATABASE_URL: string
}
+ ResourceProvisioningEligibilityBody: {
+ /** @description A random unique string identifying the individual request */
+ nonce: string
+ /** @description Unique ID representing an organization */
+ organization_id: string
+ /** @description A UNIX epoch timestamp value */
+ timestamp: number
+ /** @description The full request target URL */
+ url: string
+ /** @description Obfuscated email that routes to the provisioning user */
+ user_email: string
+ }
+ ResourceProvisioningEligibilityResponse: {
+ free_db_eligible: boolean
+ }
ResourceProvisioningResponse: {
/** @description Supabase envs config */
config: components['schemas']['ResourceProvisioningConfigResponse']
@@ -4669,6 +4713,7 @@ export interface components {
grace_period_end?: string
/** @enum {string} */
restrictions?: 'drop_requests_402'
+ usage_stats?: components['schemas']['UsageStats']
violations?: (
| 'exceed_db_size_quota'
| 'exceed_egress_quota'
@@ -5157,6 +5202,17 @@ export interface components {
referrer: string
title: string
}
+ ThirdPartyAuth: {
+ custom_jwks?: unknown
+ id: string
+ inserted_at: string
+ jwks_url?: string | null
+ oidc_issuer_url?: string | null
+ resolved_at?: string | null
+ resolved_jwks?: unknown
+ type: string
+ updated_at: string
+ }
TransferOrganizationBody: {
member_gotrue_id: string
member_id: number
@@ -5304,6 +5360,7 @@ export interface components {
rate_limit_verify?: number
refresh_token_rotation_enabled?: boolean
saml_enabled?: boolean
+ saml_external_url?: string
security_captcha_enabled?: boolean
security_captcha_provider?: string
security_captcha_secret?: string
@@ -5538,6 +5595,7 @@ export interface components {
RATE_LIMIT_VERIFY?: number
REFRESH_TOKEN_ROTATION_ENABLED?: boolean
SAML_ENABLED?: boolean
+ SAML_EXTERNAL_URL?: string
SECURITY_CAPTCHA_ENABLED?: boolean
SECURITY_CAPTCHA_PROVIDER?: string
SECURITY_CAPTCHA_SECRET?: string
@@ -5800,7 +5858,7 @@ export interface components {
id?: string
name: string
owner_id?: number
- project_id: number
+ project_id?: number
/** @enum {string} */
type: 'sql' | 'report' | 'log_sql'
/** @enum {string} */
@@ -5813,12 +5871,20 @@ export interface components {
id?: string
name: string
owner_id?: number
- project_id: number
+ project_id?: number
/** @enum {string} */
type: 'sql' | 'report' | 'log_sql'
/** @enum {string} */
visibility: 'user' | 'project' | 'org' | 'public'
}
+ UsageStats: {
+ report_date: string
+ total_auth_billing_period_mau_billing_period?: number
+ total_db_size_gb_billing_period?: number
+ total_realtime_message_count_billing_period?: number
+ total_storage_size_gb_billing_period?: number
+ total_unified_egress_gb_billing_period?: number
+ }
UserBody: {
aud?: string
banned_until?: string
@@ -5880,6 +5946,7 @@ export interface components {
}
UserContentObjectMeta: {
description?: string
+ favorite: boolean | null
folder_id?: string
id: string
inserted_at: string
@@ -5896,6 +5963,7 @@ export interface components {
UserContentObjectV2: {
content: Record<string, never>
description?: string
+ favorite: boolean | null
folder_id?: string
id: string
inserted_at: string
@@ -6191,6 +6259,21 @@ export interface operations {
}
}
}
+ /** Checks database provisioning eligibility */
+ FlyExtensionsController_checkEligibility: {
+ requestBody: {
+ content: {
+ 'application/json': components['schemas']['ResourceProvisioningEligibilityBody']
+ }
+ }
+ responses: {
+ 201: {
+ content: {
+ 'application/json': components['schemas']['ResourceProvisioningEligibilityResponse']
+ }
+ }
+ }
+ }
/** Gets details of the organization linked to the provided Fly organization id */
FlyOrganizationsController_getOrganization: {
parameters: {
@@ -7007,9 +7090,6 @@ export interface operations {
204: {
content: never
}
- 403: {
- content: never
- }
/** @description Failed to update GitHub connection */
500: {
content: never
@@ -11023,6 +11103,12 @@ export interface operations {
}
/** Updates project's content */
ContentController_updateWholeContentV2: {
+ parameters: {
+ path: {
+ /** @description Project ref */
+ ref: string
+ }
+ }
requestBody: {
content: {
'application/json': components['schemas']['UpsertContentBodyV2']
@@ -12614,6 +12700,23 @@ export interface operations {
}
}
}
+ /** Processes Orb events */
+ OrbWebhooksController_processEvent: {
+ requestBody: {
+ content: {
+ 'application/json': components['schemas']['Buffer']
+ }
+ }
+ responses: {
+ 200: {
+ content: never
+ }
+ /** @description Failed to process Orb event */
+ 500: {
+ content: never
+ }
+ }
+ }
/** Gets the partner usage and costs */
PartnerBillingSystemController_getPartnerUsageAndCosts: {
parameters: {
@@ -13973,6 +14076,89 @@ export interface operations {
}
}
}
+ /** [Alpha] Lists all third-party auth integrations */
+ ThirdPartyAuthController_listTPAForProject: {
+ parameters: {
+ path: {
+ /** @description Project ref */
+ ref: string
+ }
+ }
+ responses: {
+ 200: {
+ content: {
+ 'application/json': components['schemas']['ThirdPartyAuth'][]
+ }
+ }
+ 403: {
+ content: never
+ }
+ }
+ }
+ /** [Alpha] Creates a new third-party auth integration */
+ ThirdPartyAuthController_createTPAForProject: {
+ parameters: {
+ path: {
+ /** @description Project ref */
+ ref: string
+ }
+ }
+ requestBody: {
+ content: {
+ 'application/json': components['schemas']['CreateThirdPartyAuthBody']
+ }
+ }
+ responses: {
+ 201: {
+ content: {
+ 'application/json': components['schemas']['ThirdPartyAuth']
+ }
+ }
+ 403: {
+ content: never
+ }
+ }
+ }
+ /** [Alpha] Get a third-party integration */
+ ThirdPartyAuthController_getTPAForProject: {
+ parameters: {
+ path: {
+ /** @description Project ref */
+ ref: string
+ tpa_id: string
+ }
+ }
+ responses: {
+ 200: {
+ content: {
+ 'application/json': components['schemas']['ThirdPartyAuth']
+ }
+ }
+ 403: {
+ content: never
+ }
+ }
+ }
+ /** [Alpha] Removes a third-party auth integration */
+ ThirdPartyAuthController_deleteTPAForProject: {
+ parameters: {
+ path: {
+ /** @description Project ref */
+ ref: string
+ tpa_id: string
+ }
+ }
+ responses: {
+ 200: {
+ content: {
+ 'application/json': components['schemas']['ThirdPartyAuth']
+ }
+ }
+ 403: {
+ content: never
+ }
+ }
+ }
/** Get project's pgbouncer config */
'v1-get-project-pgbouncer-config': {
parameters: {
@@ -14496,9 +14682,6 @@ export interface operations {
201: {
content: never
}
- 403: {
- content: never
- }
/** @description Failed to remove read replica */
500: {
content: never
@@ -14522,9 +14705,6 @@ export interface operations {
201: {
content: never
}
- 403: {
- content: never
- }
/** @description Failed to set up read replica */
500: {
content: never
diff --git a/packages/ui/src/components/radio-group-stacked.tsx b/packages/ui/src/components/radio-group-stacked.tsx
index 890581768f1..20c51211d89 100644
--- a/packages/ui/src/components/radio-group-stacked.tsx
+++ b/packages/ui/src/components/radio-group-stacked.tsx
@@ -59,18 +59,18 @@ const RadioGroupStackedItem = React.forwardRef<
<div className="flex gap-3 w-full px-[21px] py-3">
{showIndicator && (
<div
- className="
- aspect-square h-4 w-4
- rounded-full border group-data-[state=checked]:border-foreground-muted
- group-focus:border-foreground-muted
- group-hover:border-foreground-muted
- ring-offset-background
- group-focus:outline-none
- group-focus-visible:ring-2 group-focus-visible:ring-ring group-focus-visible:ring-offset-2
- group-disabled:cursor-not-allowed group-disabled:opacity-50
- flex items-center justify-center
- transition
- "
+ className={cn(
+ 'aspect-square h-4 w-4 min-w-4 min-h-4',
+ 'rounded-full border group-data-[state=checked]:border-foreground-muted',
+ 'group-focus:border-foreground-muted',
+ 'group-hover:border-foreground-muted',
+ 'ring-offset-background',
+ 'group-focus:outline-none',
+ 'group-focus-visible:ring-2 group-focus-visible:ring-ring group-focus-visible:ring-offset-2',
+ 'group-disabled:cursor-not-allowed group-disabled:opacity-50',
+ 'flex items-center justify-center',
+ 'transition'
+ )}
>
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
<Circle className="h-2.5 w-2.5 fill-current text-current" />