The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Adjust Data API exposed schema (#46260)
Joshen Limba39e9c387b5
diff --git a/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx b/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsxindex db77567e9ce..2c9751d9e3c 100644--- a/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx+++ b/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx@@ -21,6 +21,14 @@ import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'import { INTERNAL_SCHEMAS } from '@/hooks/useProtectedSchemas'import { pluralize } from '@/lib/helpers'+/**+ * [Joshen] This would only affect graphql_public and pgmq_public, given that they're intended+ * to be public, we can let users expose them via the API, but not let them adjust the schema via the dashboard+ * */+export const internalSchemasCannotExpose = new Set(+ INTERNAL_SCHEMAS.filter((x) => !x.endsWith('_public'))+)+interface ExposedSchemaSelectorProps {disabled?: booleanselectedSchemas: string[]@@ -49,10 +57,7 @@ export const ExposedSchemaSelector = ({const schemas = useMemo(() =>(allSchemas ?? [])- .filter((s) => {- if (s.name === 'graphql_public') return true- return !INTERNAL_SCHEMAS.includes(s.name)- })+ .filter((s) => !internalSchemasCannotExpose.has(s.name)).sort((a, b) => a.name.localeCompare(b.name)),[allSchemas])@@ -129,9 +134,15 @@ export const ExposedSchemaSelector = ({<Check size={16} className="text-brand shrink-0" /><span className="truncate">{schema}</span></div>- <span className="pl-6 text-destructive text-[11px]">- This schema does not exist- </span>+ {internalSchemasCannotExpose.has(schema) ? (+ <span className="pl-6 text-warning text-xs tracking-tight">+ This schema is protected and should not be exposed+ </span>+ ) : (+ <span className="pl-6 text-foreground-lighter text-xs tracking-tight">+ This schema does not exist and can be safely removed+ </span>+ )}</div></CommandItem>))}diff --git a/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx b/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsxindex c62cad5a5a2..9749d72a3c2 100644--- a/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx+++ b/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx@@ -35,7 +35,7 @@ import {} from 'ui-patterns/multi-select'import { z } from 'zod'-import { ExposedSchemaSelector } from './ExposedSchemaSelector'+import { ExposedSchemaSelector, internalSchemasCannotExpose } from './ExposedSchemaSelector'import { HardenAPIModal } from './HardenAPIModal'import { ExposedFunctionSelector } from '@/components/interfaces/Settings/API/ExposedFunctionSelector'import { ExposedTableSelector } from '@/components/interfaces/Settings/API/ExposedTableSelector'@@ -264,6 +264,10 @@ export const PostgrestConfig = () => {() => watchedDbSchema.filter((schema) => !allSchemas.some((s) => s.name === schema)),[allSchemas, watchedDbSchema])+ const protectedSchemasExposed = useMemo(+ () => watchedDbSchema.filter((schema) => internalSchemasCannotExpose.has(schema)),+ [watchedDbSchema]+ )return (<PageSection id="postgrest-config" className="first:pt-0">@@ -287,9 +291,6 @@ export const PostgrestConfig = () => {layout="flex-row-reverse"label="Exposed schemas"description="Select schemas to include in the Data API. Schemas must be included before tables can be exposed."- error={- missingExposedSchema.length > 0 ? 'Some exposed schemas are missing' : null- }><ExposedSchemaSelectorselectedSchemas={watchedDbSchema}@@ -309,6 +310,19 @@ export const PostgrestConfig = () => {}}}/>+ {protectedSchemasExposed.length > 0 ? (+ <p className="mt-1 text-sm text-warning">+ {protectedSchemasExposed.length} protected schema+ {protectedSchemasExposed.length > 1 ? 's' : ''} is currently exposed and+ should be removed+ </p>+ ) : missingExposedSchema.length > 0 ? (+ <p className="mt-1 text-sm text-foreground-lighter">+ {missingExposedSchema.length} exposed schema+ {missingExposedSchema.length > 1 ? 's' : ''} does not exist — safe to+ remove+ </p>+ ) : null}</FormItemLayout><FormItemLayout