The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Small fixes
Joshen Lim78854b06fa7c
diff --git a/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx b/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsxindex 4058fb2b0c2..e97ddf91e98 100644--- a/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx+++ b/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx@@ -99,7 +99,7 @@ const CreateWrapper = () => {await createFDW({projectRef: project?.ref,connectionString: project?.connectionString,- wrapper: wrapperMeta,+ wrapperMeta,formState: { ...values, server_name: `${wrapper_name}_server` },tables: newTables,})diff --git a/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx b/studio/components/interfaces/Database/Wrappers/EditWrapper.tsxindex 7fc186b1552..85519c91539 100644--- a/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx+++ b/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx@@ -148,7 +148,7 @@ const EditWrapper = () => {await updateFDW({projectRef: project?.ref,connectionString: project?.connectionString,- wrapper: wrapperMeta,+ wrapper,wrapperMeta,formState: { ...values, server_name: `${wrapper_name}_server` },tables: wrapperTables,@@ -206,7 +206,12 @@ const EditWrapper = () => {<Form id={formId} initialValues={initialValues} onSubmit={onSubmit}>{({ isSubmitting, handleReset, values, initialValues, resetForm }: any) => {const [loadingSecrets, setLoadingSecrets] = useState(false)- const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)++ const initialTables = formatWrapperTables(wrapper?.tables ?? [])+ const hasFormChanges = JSON.stringify(values) !== JSON.stringify(initialValues)+ const hasTableChanges = JSON.stringify(initialTables) !== JSON.stringify(wrapperTables)+ const hasChanges = hasFormChanges || hasTableChanges+const encryptedOptions = wrapperMeta.server.options.filter((option) => option.encrypted)useEffect(() => {@@ -249,7 +254,10 @@ const EditWrapper = () => {form={formId}isSubmitting={isSubmitting}hasChanges={hasChanges}- handleReset={handleReset}+ handleReset={() => {+ handleReset()+ setWrapperTables(initialTables)+ }}helper={!canCreateWrapper? 'You need additional permissions to create a foreign data wrapper'diff --git a/studio/components/interfaces/Database/Wrappers/WrapperRow.tsx b/studio/components/interfaces/Database/Wrappers/WrapperRow.tsxindex 0e336cdf86d..a79ca3d972b 100644--- a/studio/components/interfaces/Database/Wrappers/WrapperRow.tsx+++ b/studio/components/interfaces/Database/Wrappers/WrapperRow.tsx@@ -1,6 +1,6 @@import Link from 'next/link'import Image from 'next/image'-import { FC, useState } from 'react'+import { FC } from 'react'import {Collapsible,IconChevronUp,@@ -10,28 +10,28 @@ import {IconTrash,IconEdit,} from 'ui'+import { partition } from 'lodash'import { useParams, useStore } from 'hooks'-import { Wrapper } from './Wrappers.types'+import { WrapperMeta } from './Wrappers.types'+import { FDW } from 'data/fdw/fdws-query'import { useFDWDeleteMutation } from 'data/fdw/fdw-delete-mutation'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'import { confirmAlert } from 'components/to-be-cleaned/ModalsDeprecated/ConfirmModal'-import { partition } from 'lodash'interface Props {- wrapperMeta: Wrapper- wrappers: any[]+ wrappers: FDW[]+ wrapperMeta: WrapperMetaisOpen: booleanisLoading: booleanonOpen: (wrapper: string) => void}-const WrapperRow: FC<Props> = ({ wrapperMeta, wrappers = [], isOpen, isLoading, onOpen }) => {+const WrapperRow: FC<Props> = ({ wrappers = [], wrapperMeta, isOpen, isLoading, onOpen }) => {const { ui } = useStore()const { ref } = useParams()const { project } = useProjectContext()const { mutateAsync: deleteFDW } = useFDWDeleteMutation()- const [isSubmitting, setIsSubmitting] = useState(false)const onDeleteWrapper = (wrapper: any) => {confirmAlert({@@ -176,7 +176,6 @@ const WrapperRow: FC<Props> = ({ wrapperMeta, wrappers = [], isOpen, isLoading,<a><Buttontype="default"- loading={isSubmitting}icon={<IconEdit strokeWidth={1.5} />}className="py-2"/>@@ -184,7 +183,6 @@ const WrapperRow: FC<Props> = ({ wrapperMeta, wrappers = [], isOpen, isLoading,</Link><Buttontype="default"- loading={isSubmitting}icon={<IconTrash strokeWidth={1.5} />}className="py-2"onClick={() => onDeleteWrapper(wrapper)}diff --git a/studio/components/interfaces/Database/Wrappers/Wrappers.constants.ts b/studio/components/interfaces/Database/Wrappers/Wrappers.constants.tsindex 75c10baf29a..cbb51c09408 100644--- a/studio/components/interfaces/Database/Wrappers/Wrappers.constants.ts+++ b/studio/components/interfaces/Database/Wrappers/Wrappers.constants.ts@@ -1,6 +1,6 @@-import { Wrapper } from './Wrappers.types'+import { WrapperMeta } from './Wrappers.types'-export const WRAPPERS: Wrapper[] = [+export const WRAPPERS: WrapperMeta[] = [{name: 'stripe_wrapper',handlerName: 'stripe_fdw_handler',diff --git a/studio/components/interfaces/Database/Wrappers/Wrappers.types.ts b/studio/components/interfaces/Database/Wrappers/Wrappers.types.tsindex 800e3d3cfd3..c0da532e9f1 100644--- a/studio/components/interfaces/Database/Wrappers/Wrappers.types.ts+++ b/studio/components/interfaces/Database/Wrappers/Wrappers.types.ts@@ -1,4 +1,4 @@-export type Wrapper = {+export type WrapperMeta = {name: stringhandlerName: stringvalidatorName: stringdiff --git a/studio/data/fdw/fdw-create-mutation.ts b/studio/data/fdw/fdw-create-mutation.tsindex 1cc30aaf0a1..3611b08d305 100644--- a/studio/data/fdw/fdw-create-mutation.ts+++ b/studio/data/fdw/fdw-create-mutation.ts@@ -1,5 +1,8 @@import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'-import { AvailableColumn, Wrapper } from 'components/interfaces/Database/Wrappers/Wrappers.types'+import {+ AvailableColumn,+ WrapperMeta,+} from 'components/interfaces/Database/Wrappers/Wrappers.types'import { executeSql } from 'data/sql/execute-sql-query'import { sqlKeys } from 'data/sql/keys'import { wrapWithTransaction } from 'data/sql/utils/transaction'@@ -8,7 +11,7 @@ import { useStore } from 'hooks'export type FDWCreateVariables = {projectRef?: stringconnectionString?: string- wrapper: Wrapper+ wrapperMeta: WrapperMetaformState: {[k: string]: string}@@ -16,10 +19,10 @@ export type FDWCreateVariables = {}export function getCreateFDWSql({- wrapper,+ wrapperMeta,formState,tables,-}: Pick<FDWCreateVariables, 'wrapper' | 'formState' | 'tables'>) {+}: Pick<FDWCreateVariables, 'wrapperMeta' | 'formState' | 'tables'>) {const newSchemasSql = tables.filter((table) => table.is_new_schema).map((table) => /* SQL */ `create schema if not exists ${table.schema_name};`)@@ -27,12 +30,12 @@ export function getCreateFDWSql({const createWrapperSql = /* SQL */ `create foreign data wrapper ${formState.wrapper_name}- handler ${wrapper.handlerName}- validator ${wrapper.validatorName};+ handler ${wrapperMeta.handlerName}+ validator ${wrapperMeta.validatorName};`- const encryptedOptions = wrapper.server.options.filter((option) => option.encrypted)- const unencryptedOptions = wrapper.server.options.filter((option) => !option.encrypted)+ const encryptedOptions = wrapperMeta.server.options.filter((option) => option.encrypted)+ const unencryptedOptions = wrapperMeta.server.options.filter((option) => !option.encrypted)const createEncryptedKeysSqlArray = encryptedOptions.map((option) => {const key = `${formState.wrapper_name}_${option.name}`@@ -85,7 +88,7 @@ export function getCreateFDWSql({const createTablesSql = tables.map((newTable) => {- const table = wrapper.tables[newTable.index]+ const table = wrapperMeta.tables[newTable.index]const columns: AvailableColumn[] = newTable.columns.map((name: string) => table.availableColumns.find((c) => c.name === name))@@ -130,11 +133,11 @@ export function getCreateFDWSql({export async function createFDW({projectRef,connectionString,- wrapper,+ wrapperMeta,formState,tables,}: FDWCreateVariables) {- const sql = wrapWithTransaction(getCreateFDWSql({ wrapper, formState, tables }))+ const sql = wrapWithTransaction(getCreateFDWSql({ wrapperMeta, formState, tables }))const { result } = await executeSql({ projectRef, connectionString, sql })diff --git a/studio/data/fdw/fdw-delete-mutation.ts b/studio/data/fdw/fdw-delete-mutation.tsindex c3d4940fc31..d3183fa1fe7 100644--- a/studio/data/fdw/fdw-delete-mutation.ts+++ b/studio/data/fdw/fdw-delete-mutation.ts@@ -1,15 +1,16 @@import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'-import { Wrapper } from 'components/interfaces/Database/Wrappers/Wrappers.types'+import { WrapperMeta } from 'components/interfaces/Database/Wrappers/Wrappers.types'import { executeSql } from 'data/sql/execute-sql-query'import { sqlKeys } from 'data/sql/keys'import { wrapWithTransaction } from 'data/sql/utils/transaction'import { useStore } from 'hooks'+import { FDW } from './fdws-query'export type FDWDeleteVariables = {projectRef?: stringconnectionString?: string- wrapper: any- wrapperMeta: Wrapper+ wrapper: FDW+ wrapperMeta: WrapperMeta}export const getDeleteFDWSql = ({diff --git a/studio/data/fdw/fdw-update-mutation.ts b/studio/data/fdw/fdw-update-mutation.tsindex d3e2fe130da..8e7df030945 100644--- a/studio/data/fdw/fdw-update-mutation.ts+++ b/studio/data/fdw/fdw-update-mutation.ts@@ -1,17 +1,18 @@import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'-import { Wrapper } from 'components/interfaces/Database/Wrappers/Wrappers.types'+import { WrapperMeta } from 'components/interfaces/Database/Wrappers/Wrappers.types'import { executeSql } from 'data/sql/execute-sql-query'import { sqlKeys } from 'data/sql/keys'import { wrapWithTransaction } from 'data/sql/utils/transaction'import { useStore } from 'hooks'import { getCreateFDWSql } from './fdw-create-mutation'import { getDeleteFDWSql } from './fdw-delete-mutation'+import { FDW } from './fdws-query'export type FDWUpdateVariables = {projectRef?: stringconnectionString?: string- wrapper: Wrapper- wrapperMeta: Wrapper+ wrapper: FDW+ wrapperMeta: WrapperMetaformState: {[k: string]: string}@@ -25,11 +26,7 @@ export const getUpdateFDWSql = ({tables,}: Pick<FDWUpdateVariables, 'wrapper' | 'wrapperMeta' | 'formState' | 'tables'>) => {const deleteWrapperSql = getDeleteFDWSql({ wrapper, wrapperMeta })- const createWrapperSql = getCreateFDWSql({- wrapper: wrapperMeta,- formState,- tables,- })+ const createWrapperSql = getCreateFDWSql({ wrapperMeta, formState, tables })const sql = /* SQL */ `${deleteWrapperSql}diff --git a/studio/data/fdw/fdws-query.ts b/studio/data/fdw/fdws-query.tsindex 674881c77e4..ee423692068 100644--- a/studio/data/fdw/fdws-query.ts+++ b/studio/data/fdw/fdws-query.ts@@ -14,7 +14,7 @@ export const getFDWsSql = () => {(select jsonb_agg(jsonb_build_object(- 'id', c.oid,+ 'id', c.oid::bigint,'schema', relnamespace::regnamespace::text,'name', c.relname,'columns', (