The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: new wrappers 16/07/24 (#28014)
Alaister Young3f0cd49a062c
diff --git a/apps/studio/components/interfaces/Auth/Hooks/FunctionSelector.tsx b/apps/studio/components/interfaces/Auth/Hooks/FunctionSelector.tsxindex f0d598dda3e..ab25e4294d1 100644--- a/apps/studio/components/interfaces/Auth/Hooks/FunctionSelector.tsx+++ b/apps/studio/components/interfaces/Auth/Hooks/FunctionSelector.tsx@@ -20,7 +20,7 @@ import {import { convertArgumentTypes } from 'components/interfaces/Database/Functions/Functions.utils'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'import { useDatabaseFunctionsQuery } from 'data/database-functions/database-functions-query'-import { Code } from 'lucide-react'+import { Check, Code } from 'lucide-react'interface FunctionSelectorProps {className?: string@@ -136,7 +136,7 @@ const FunctionSelector = ({><span>{func.name}</span>{value === func.name && (- <IconCheck className="text-brand" strokeWidth={2} />+ <Check className="text-brand" size={14} strokeWidth={2} />)}</CommandItem_Shadcn_>))}diff --git a/apps/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx b/apps/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsxindex b7d6aa41d53..bca67bcb7b1 100644--- a/apps/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx+++ b/apps/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx@@ -16,8 +16,16 @@ import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-eximport { invalidateSchemasQuery } from 'data/database/schemas-query'import { useFDWCreateMutation } from 'data/fdw/fdw-create-mutation'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'-import { ArrowLeft, ExternalLink } from 'lucide-react'-import { Button, Form, IconEdit, IconTrash, Input } from 'ui'+import { ArrowLeft, Edit, ExternalLink, Trash } from 'lucide-react'+import {+ AlertDescription_Shadcn_,+ AlertTitle_Shadcn_,+ Alert_Shadcn_,+ Button,+ Form,+ Input,+} from 'ui'+import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'import InputField from './InputField'import WrapperTableEditor from './WrapperTableEditor'import { WRAPPERS } from './Wrappers.constants'@@ -87,36 +95,8 @@ const CreateWrapper = () => {)}- if (!hasRequiredVersion) {- const databaseNeedsUpgrading =- wrappersExtension?.installed_version !== wrappersExtension?.default_version-- return (- <div className="flex flex-col items-center justify-center w-full h-full space-y-4">- <div className="space-y-2 flex flex-col items-center w-[400px]">- <p>Your extension version is outdated for this wrapper.</p>- <p className="text-sm text-center text-foreground-light">- The wrapper type {type} requires a minimum extension version of{' '}- {wrapperMeta.minimumExtensionVersion}. You have version{' '}- {wrappersExtension?.installed_version} installed. Please{' '}- {databaseNeedsUpgrading && 'upgrade your database then '}reinstall the extension to- create this wrapper.- </p>- </div>- <Button asChild type="default">- <Link- href={- databaseNeedsUpgrading- ? `/project/${ref}/settings/infrastructure`- : `/project/${ref}/database/extensions?filter=wrappers`- }- >- {databaseNeedsUpgrading ? 'Upgrade Database' : 'Reinstall Extension'}- </Link>- </Button>- </div>- )- }+ const databaseNeedsUpgrading =+ wrappersExtension?.installed_version !== wrappersExtension?.default_versionconst onUpdateTable = (values: any) => {setNewTables((prev) => {@@ -179,135 +159,173 @@ const CreateWrapper = () => {</div></div>- <Form id={formId} initialValues={initialValues} onSubmit={onSubmit}>- {({ handleReset, values, initialValues }: any) => {- const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)- return (- <FormPanel- disabled={!canCreateWrapper}- footer={- <div className="flex px-8 py-4">- <FormActions- form={formId}- isSubmitting={isCreating}- hasChanges={hasChanges}- handleReset={handleReset}- disabled={!canCreateWrapper}- helper={- !canCreateWrapper- ? 'You need additional permissions to create a foreign data wrapper'- : undefined- }- />- </div>- }- >- <FormSection header={<FormSectionLabel>Wrapper Configuration</FormSectionLabel>}>- <FormSectionContent loading={false}>- <Input- id="wrapper_name"- label="Wrapper Name"- error={formErrors.wrapper_name}- descriptionText={- (values?.wrapper_name ?? '').length > 0 ? (- <>- Your wrapper's server name will be{' '}- <code className="text-xs">{values.wrapper_name}_server</code>- </>- ) : (- ''- )- }- />- </FormSectionContent>- </FormSection>- <FormSection- header={<FormSectionLabel>{wrapperMeta.label} Configuration</FormSectionLabel>}- >- <FormSectionContent loading={false}>- {wrapperMeta.server.options.map((option) => (- <InputField- key={option.name}- option={option}- loading={false}- error={formErrors[option.name]}+ {hasRequiredVersion ? (+ <Form id={formId} initialValues={initialValues} onSubmit={onSubmit}>+ {({ handleReset, values, initialValues }: any) => {+ const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)+ return (+ <FormPanel+ disabled={!canCreateWrapper}+ footer={+ <div className="flex px-8 py-4">+ <FormActions+ form={formId}+ isSubmitting={isCreating}+ hasChanges={hasChanges}+ handleReset={handleReset}+ disabled={!canCreateWrapper}+ helper={+ !canCreateWrapper+ ? 'You need additional permissions to create a foreign data wrapper'+ : undefined+ }/>- ))}- </FormSectionContent>- </FormSection>- <FormSection- header={- <FormSectionLabel>- <p>Foreign Tables</p>- <p className="text-foreground-light mt-2 w-[90%]">- You can query your data from these foreign tables after the wrapper is- created- </p>- </FormSectionLabel>+ </div>}>- <FormSectionContent loading={false}>- {newTables.length === 0 ? (- <div className="flex justify-end translate-y-4">- <Button type="default" onClick={() => setIsEditingTable(true)}>- Add foreign table- </Button>- </div>- ) : (- <div className="space-y-2">- {newTables.map((table, i) => (- <div- key={`${table.schema_name}.${table.table_name}`}- className="flex items-center justify-between px-4 py-2 border rounded-md border-control"- >- <div>- <p className="text-sm">- {table.schema_name}.{table.table_name}- </p>- <p className="text-sm text-foreground-light">- Columns:{' '}- {table.columns.map((column: any) => column.name).join(', ')}- </p>- </div>- <div className="flex items-center space-x-2">- <Button- type="default"- className="px-1"- icon={<IconEdit />}- onClick={() => {- setIsEditingTable(true)- setSelectedTableToEdit({ ...table, tableIndex: i })- }}- />- <Button- type="default"- className="px-1"- icon={<IconTrash />}- onClick={() => {- setNewTables((prev) => prev.filter((_, j) => j !== i))- }}- />- </div>- </div>+ <FormSection header={<FormSectionLabel>Wrapper Configuration</FormSectionLabel>}>+ <FormSectionContent loading={false}>+ <Input+ id="wrapper_name"+ label="Wrapper Name"+ error={formErrors.wrapper_name}+ descriptionText={+ (values?.wrapper_name ?? '').length > 0 ? (+ <>+ Your wrapper's server name will be{' '}+ <code className="text-xs">{values.wrapper_name}_server</code>+ </>+ ) : (+ ''+ )+ }+ />+ </FormSectionContent>+ </FormSection>+ <FormSection+ header={<FormSectionLabel>{wrapperMeta.label} Configuration</FormSectionLabel>}+ >+ <FormSectionContent loading={false}>+ {wrapperMeta.server.options+ .filter((option) => !option.hidden)+ .map((option) => (+ <InputField+ key={option.name}+ option={option}+ loading={false}+ error={formErrors[option.name]}+ />))}- </div>- )}- {newTables.length > 0 && (- <div className="flex justify-end">- <Button type="default" onClick={() => setIsEditingTable(true)}>- Add foreign table- </Button>- </div>- )}- {newTables.length === 0 && formErrors.tables && (- <p className="text-sm text-right text-red-900">{formErrors.tables}</p>- )}- </FormSectionContent>- </FormSection>- </FormPanel>- )- }}- </Form>+ </FormSectionContent>+ </FormSection>+ <FormSection+ header={+ <FormSectionLabel>+ <p>Foreign Tables</p>+ <p className="text-foreground-light mt-2 w-[90%]">+ You can query your data from these foreign tables after the wrapper is+ created+ </p>+ </FormSectionLabel>+ }+ >+ <FormSectionContent loading={false}>+ {newTables.length === 0 ? (+ <div className="flex justify-end translate-y-4">+ <Button type="default" onClick={() => setIsEditingTable(true)}>+ Add foreign table+ </Button>+ </div>+ ) : (+ <div className="space-y-2">+ {newTables.map((table, i) => (+ <div+ key={`${table.schema_name}.${table.table_name}`}+ className="flex items-center justify-between px-4 py-2 border rounded-md border-control"+ >+ <div>+ <p className="text-sm">+ {table.schema_name}.{table.table_name}+ </p>+ <p className="text-sm text-foreground-light">+ Columns:{' '}+ {table.columns.map((column: any) => column.name).join(', ')}+ </p>+ </div>+ <div className="flex items-center space-x-2">+ <Button+ type="default"+ className="px-1"+ icon={<Edit />}+ onClick={() => {+ setIsEditingTable(true)+ setSelectedTableToEdit({ ...table, tableIndex: i })+ }}+ />+ <Button+ type="default"+ className="px-1"+ icon={<Trash />}+ onClick={() => {+ setNewTables((prev) => prev.filter((_, j) => j !== i))+ }}+ />+ </div>+ </div>+ ))}+ </div>+ )}+ {newTables.length > 0 && (+ <div className="flex justify-end">+ <Button type="default" onClick={() => setIsEditingTable(true)}>+ Add foreign table+ </Button>+ </div>+ )}+ {newTables.length === 0 && formErrors.tables && (+ <p className="text-sm text-right text-red-900">{formErrors.tables}</p>+ )}+ </FormSectionContent>+ </FormSection>+ </FormPanel>+ )+ }}+ </Form>+ ) : (+ <Alert_Shadcn_ variant="warning">+ <WarningIcon />+ <AlertTitle_Shadcn_>+ Your extension version is outdated for this wrapper.+ </AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_ className="flex flex-col gap-y-2">+ <p>+ The {wrapperMeta.label} wrapper requires a minimum extension version of{' '}+ {wrapperMeta.minimumExtensionVersion}. You have version{' '}+ {wrappersExtension?.installed_version} installed. Please{' '}+ {databaseNeedsUpgrading && 'upgrade your database then '}update the extension by+ disabling and enabling the <code className="text-xs">wrappers</code> extension to+ create this wrapper.+ </p>+ <p className="text-warning">+ Warning: Before reinstalling the wrapper extension, you must first remove all+ existing wrappers. Afterward, you can recreate the wrappers.+ </p>+ </AlertDescription_Shadcn_>+ <AlertDescription_Shadcn_ className="mt-3">+ <Button asChild type="default">+ <Link+ href={+ databaseNeedsUpgrading+ ? `/project/${ref}/settings/infrastructure`+ : `/project/${ref}/database/extensions?filter=wrappers`+ }+ >+ {databaseNeedsUpgrading ? 'Upgrade database' : 'View wrappers extension'}+ </Link>+ </Button>+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_>+ )}</div><WrapperTableEditordiff --git a/apps/studio/components/interfaces/Database/Wrappers/DeleteWrapperModal.tsx b/apps/studio/components/interfaces/Database/Wrappers/DeleteWrapperModal.tsxindex 428d0a183d3..770f740f1b7 100644--- a/apps/studio/components/interfaces/Database/Wrappers/DeleteWrapperModal.tsx+++ b/apps/studio/components/interfaces/Database/Wrappers/DeleteWrapperModal.tsx@@ -4,7 +4,7 @@ import { Modal } from 'ui'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'import { useFDWDeleteMutation } from 'data/fdw/fdw-delete-mutation'import type { FDW } from 'data/fdw/fdws-query'-import { WRAPPERS } from './Wrappers.constants'+import { getWrapperMetaForWrapper } from './Wrappers.utils'interface DeleteWrapperModalProps {selectedWrapper?: FDW@@ -19,7 +19,7 @@ const DeleteWrapperModal = ({ selectedWrapper, onClose }: DeleteWrapperModalProponClose()},})- const wrapperMeta = WRAPPERS.find((meta) => meta.handlerName === selectedWrapper?.handler)+ const wrapperMeta = getWrapperMetaForWrapper(selectedWrapper)const onConfirmDelete = async () => {if (!project?.ref) return console.error('Project ref is required')diff --git a/apps/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx b/apps/studio/components/interfaces/Database/Wrappers/EditWrapper.tsxindex 0788a3f726f..d69d07978ae 100644--- a/apps/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx+++ b/apps/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx@@ -20,14 +20,14 @@ import { getDecryptedValue } from 'data/vault/vault-secret-decrypted-value-queryimport { useVaultSecretsQuery } from 'data/vault/vault-secrets-query'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'import { useImmutableValue } from 'hooks/misc/useImmutableValue'-import { ArrowLeft, ExternalLink } from 'lucide-react'-import { Button, Form, IconEdit, IconLoader, IconTrash, Input } from 'ui'+import { ArrowLeft, Edit, ExternalLink, Trash } from 'lucide-react'+import { Button, Form, IconLoader, Input } from 'ui'import InputField from './InputField'import WrapperTableEditor from './WrapperTableEditor'-import { WRAPPERS } from './Wrappers.constants'import {convertKVStringArrayToJson,formatWrapperTables,+ getWrapperMetaForWrapper,makeValidateRequired,} from './Wrappers.utils'@@ -52,7 +52,7 @@ const EditWrapper = () => {const foundWrapper = wrappers.find((w) => Number(w.id) === Number(id))// this call to useImmutableValue should be removed if the redirect after update is also removedconst wrapper = useImmutableValue(foundWrapper)- const wrapperMeta = WRAPPERS.find((w) => w.handlerName === wrapper?.handler)+ const wrapperMeta = getWrapperMetaForWrapper(wrapper)const { mutate: updateFDW, isLoading: isSaving } = useFDWUpdateMutation({onSuccess: () => {@@ -228,7 +228,7 @@ const EditWrapper = () => {connectionString: project?.connectionString,id: secret.id,})- return { [option.name]: value[0].decrypted_secret }+ return { [option.name]: value[0]?.decrypted_secret ?? '' }} else {return { [option.name]: '' }}@@ -298,14 +298,16 @@ const EditWrapper = () => {header={<FormSectionLabel>{wrapperMeta.label} Configuration</FormSectionLabel>}><FormSectionContent loading={false}>- {wrapperMeta.server.options.map((option) => (- <InputField- key={option.name}- option={option}- loading={option.encrypted ? loadingSecrets : false}- error={formErrors[option.name]}- />- ))}+ {wrapperMeta.server.options+ .filter((option) => !option.hidden)+ .map((option) => (+ <InputField+ key={option.name}+ option={option}+ loading={option.encrypted ? loadingSecrets : false}+ error={formErrors[option.name]}+ />+ ))}</FormSectionContent></FormSection><FormSection@@ -329,7 +331,6 @@ const EditWrapper = () => {) : (<div className="space-y-2">{wrapperTables.map((table, i) => {- const label = wrapperMeta.tables[table.index]?.labelconst target = table?.table ?? table.objectreturn (@@ -353,7 +354,7 @@ const EditWrapper = () => {<Buttontype="default"className="px-1"- icon={<IconEdit />}+ icon={<Edit />}onClick={() => {setIsEditingTable(true)setSelectedTableToEdit({ ...table, tableIndex: i })@@ -362,7 +363,7 @@ const EditWrapper = () => {<Buttontype="default"className="px-1"- icon={<IconTrash />}+ icon={<Trash />}onClick={() => {setWrapperTables((prev) => prev.filter((_, j) => j !== i))}}diff --git a/apps/studio/components/interfaces/Database/Wrappers/InputField.tsx b/apps/studio/components/interfaces/Database/Wrappers/InputField.tsxindex 500b950c9a2..48f5bb5ffca 100644--- a/apps/studio/components/interfaces/Database/Wrappers/InputField.tsx+++ b/apps/studio/components/interfaces/Database/Wrappers/InputField.tsx@@ -11,7 +11,7 @@ interface InputFieldProps {}const InputField = ({ option, loading, error }: InputFieldProps) => {- const [showHidden, setShowHidden] = useState(!option.hidden)+ const [showHidden, setShowHidden] = useState(!option.secureEntry)if (option.isTextArea) {return (<div className="text-area-text-sm text-area-resize-none">@@ -66,14 +66,14 @@ const InputField = ({ option, loading, error }: InputFieldProps) => {defaultValue={option.defaultValue ?? ''}error={error}value={loading ? 'Fetching value from Vault...' : undefined}- type={!option.hidden || loading ? 'text' : showHidden ? 'text' : 'password'}+ type={!option.secureEntry || loading ? 'text' : showHidden ? 'text' : 'password'}disabled={loading}actions={loading ? (<div className="flex items-center justify-center mr-1"><Button disabled type="default" icon={<IconLoader className="animate-spin" />} /></div>- ) : option.hidden ? (+ ) : option.secureEntry ? (<div className="flex items-center justify-center mr-1"><Buttontype="default"diff --git a/apps/studio/components/interfaces/Database/Wrappers/WrapperDynamicColumns.tsx b/apps/studio/components/interfaces/Database/Wrappers/WrapperDynamicColumns.tsxindex 1f23ca8f297..0afed348d51 100644--- a/apps/studio/components/interfaces/Database/Wrappers/WrapperDynamicColumns.tsx+++ b/apps/studio/components/interfaces/Database/Wrappers/WrapperDynamicColumns.tsx@@ -1,7 +1,8 @@import ColumnType from 'components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType'import useLatest from 'hooks/misc/useLatest'+import { X } from 'lucide-react'import { useEffect, useReducer } from 'react'-import { Button, IconX, Input } from 'ui'+import { Button, Input } from 'ui'export type SimpleColumn = {id: number@@ -136,10 +137,10 @@ const WrapperDynamicColumns = ({</div><Button- onClick={() => onRemoveColumn(column.id)}- icon={<IconX size={14} strokeWidth={1.5} />}type="outline"- className="self-end -translate-y-1 !px-2 !py-2"+ icon={<X strokeWidth={1.5} />}+ onClick={() => onRemoveColumn(column.id)}+ className="self-end -translate-y-1.5 px-1.5"/></div>diff --git a/apps/studio/components/interfaces/Database/Wrappers/WrapperRow.tsx b/apps/studio/components/interfaces/Database/Wrappers/WrapperRow.tsxindex 61f19327e5c..a793b273f14 100644--- a/apps/studio/components/interfaces/Database/Wrappers/WrapperRow.tsx+++ b/apps/studio/components/interfaces/Database/Wrappers/WrapperRow.tsx@@ -3,11 +3,12 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'import { partition } from 'lodash'import Image from 'next/legacy/image'import Link from 'next/link'-import { Button, Collapsible, IconChevronUp, IconEdit, IconExternalLink, IconTrash } from 'ui'+import { Button, Collapsible, IconChevronUp, IconEdit, IconTrash } from 'ui'import { useParams } from 'common/hooks'import type { FDW } from 'data/fdw/fdws-query'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'+import { Edit, ExternalLink, Trash } from 'lucide-react'import type { WrapperMeta } from './Wrappers.types'interface WrapperRowProps {@@ -80,8 +81,8 @@ const WrapperRow = ({wrapper.server_options.map((option: any) => option.split('=')))const [encryptedMetadata, visibleMetadata] = partition(- wrapperMeta.server.options,- 'hidden'+ wrapperMeta.server.options.filter((option) => !option.hidden),+ 'secureEntry')return (@@ -107,7 +108,7 @@ const WrapperRow = ({className="transition text-foreground-light hover:text-foreground flex items-center space-x-2"><span>Encrypted in Vault</span>- <IconExternalLink size={14} strokeWidth={1.5} />+ <ExternalLink size={14} strokeWidth={1.5} /></Link></div>))}@@ -135,18 +136,18 @@ const WrapperRow = ({<Link href={`/project/${ref}/database/wrappers/${wrapper.id}`}><Buttontype="default"- icon={<IconEdit strokeWidth={1.5} />}- className="py-2"+ icon={<Edit strokeWidth={1.5} />}+ className="px-1.5"/></Link>) : (<Tooltip.Root delayDuration={0}><Tooltip.Trigger asChild><Button- type="default"disabled- icon={<IconEdit strokeWidth={1.5} />}- className="py-2"+ type="default"+ icon={<Edit strokeWidth={1.5} />}+ className="px-1.5"/></Tooltip.Trigger>{!canManageWrappers && (@@ -173,8 +174,8 @@ const WrapperRow = ({<Buttontype="default"disabled={!canManageWrappers}- icon={<IconTrash strokeWidth={1.5} />}- className="py-2"+ icon={<Trash strokeWidth={1.5} />}+ className="px-1.5"onClick={() => onSelectDelete(wrapper)}/></Tooltip.Trigger>diff --git a/apps/studio/components/interfaces/Database/Wrappers/WrapperTableEditor.tsx b/apps/studio/components/interfaces/Database/Wrappers/WrapperTableEditor.tsxindex 997cff04d64..7c6606254bb 100644--- a/apps/studio/components/interfaces/Database/Wrappers/WrapperTableEditor.tsx+++ b/apps/studio/components/interfaces/Database/Wrappers/WrapperTableEditor.tsx@@ -122,7 +122,7 @@ const Option = ({ option }: { option: TableOption }) => {{[...(!option.required? [- <Listbox.Option key="empty" value="" label="---">+ <Listbox.Option key="empty" value="" label="---" className="!w-96">---</Listbox.Option>,]@@ -133,6 +133,7 @@ const Option = ({ option }: { option: TableOption }) => {id={option.name + subOption.value}value={subOption.value}label={subOption.label}+ className="!w-96">{subOption.label}</Listbox.Option>diff --git a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.constants.ts b/apps/studio/components/interfaces/Database/Wrappers/Wrappers.constants.tsindex 9251ff5ffe1..c0f507d70d5 100644--- a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.constants.ts+++ b/apps/studio/components/interfaces/Database/Wrappers/Wrappers.constants.ts@@ -13,6 +13,8 @@ export const WRAPPER_HANDLERS = {COGNITO: 'cognito_fdw_handler',MSSQL: 'mssql_fdw_handler',REDIS: 'redis_fdw_handler',+ PADDLE: 'wasm_fdw_handler',+ SNOWFLAKE: 'wasm_fdw_handler',}export const WRAPPERS: WrapperMeta[] = [@@ -31,7 +33,7 @@ export const WRAPPERS: WrapperMeta[] = [label: 'Stripe Secret Key',required: true,encrypted: true,- hidden: true,+ secureEntry: true,urlHelper: 'https://stripe.com/docs/keys',},{@@ -40,7 +42,7 @@ export const WRAPPERS: WrapperMeta[] = [defaultValue: 'https://api.stripe.com/v1',required: false,encrypted: false,- hidden: false,+ secureEntry: false,},],},@@ -497,14 +499,14 @@ export const WRAPPERS: WrapperMeta[] = [label: 'Project ID',required: true,encrypted: false,- hidden: false,+ secureEntry: false,},{name: 'sa_key_id',label: 'Service Account Key',required: true,encrypted: true,- hidden: true,+ secureEntry: true,isTextArea: true,urlHelper: 'https://firebase.google.com/docs/admin/setup#initialize-sdk',},@@ -623,21 +625,21 @@ export const WRAPPERS: WrapperMeta[] = [label: 'Access Key ID',required: true,encrypted: true,- hidden: true,+ secureEntry: true,},{name: 'vault_secret_access_key',label: 'Access Key Secret',required: true,encrypted: true,- hidden: true,+ secureEntry: true,},{name: 'aws_region',label: 'AWS Region',required: true,encrypted: false,- hidden: false,+ secureEntry: false,defaultValue: 'us-east-1',},],@@ -706,7 +708,7 @@ export const WRAPPERS: WrapperMeta[] = [label: 'ClickHouse Connection String',required: true,encrypted: true,- hidden: true,+ secureEntry: true,},],},@@ -750,21 +752,21 @@ export const WRAPPERS: WrapperMeta[] = [label: 'Service Account Key',required: true,encrypted: true,- hidden: true,+ secureEntry: true,},{name: 'project_id',label: 'Project ID',required: true,encrypted: false,- hidden: false,+ secureEntry: false,},{name: 'dataset_id',label: 'Dataset ID',required: true,encrypted: false,- hidden: false,+ secureEntry: false,},],},@@ -824,7 +826,7 @@ export const WRAPPERS: WrapperMeta[] = [label: 'API Key ID',required: true,encrypted: true,- hidden: true,+ secureEntry: true,},],},@@ -866,7 +868,7 @@ export const WRAPPERS: WrapperMeta[] = [label: 'API Key ID',required: true,encrypted: true,- hidden: true,+ secureEntry: true,},],},@@ -902,7 +904,7 @@ export const WRAPPERS: WrapperMeta[] = [label: 'Auth0 API key or PAT',required: true,encrypted: true,- hidden: true,+ secureEntry: true,},{name: 'url',@@ -910,7 +912,7 @@ export const WRAPPERS: WrapperMeta[] = [defaultValue: 'https://dev-<tenant-id>.us.auth0.com/api/v2/users',required: false,encrypted: false,- hidden: false,+ secureEntry: false,},],},@@ -1032,28 +1034,28 @@ export const WRAPPERS: WrapperMeta[] = [label: 'AWS Access Key ID',required: true,encrypted: false,- hidden: false,+ secureEntry: false,},{name: 'api_key_id',label: 'AWS Secret Key',required: true,encrypted: true,- hidden: true,+ secureEntry: true,},{name: 'region',label: 'Region',required: true,encrypted: false,- hidden: false,+ secureEntry: false,},{name: 'user_pool_id',label: 'User Pool ID',required: true,encrypted: false,- hidden: false,+ secureEntry: false,},],},@@ -1115,7 +1117,7 @@ export const WRAPPERS: WrapperMeta[] = [label: 'Connection String',required: true,encrypted: true,- hidden: true,+ secureEntry: true,},],},@@ -1151,7 +1153,7 @@ export const WRAPPERS: WrapperMeta[] = [label: 'Connection URL',required: true,encrypted: true,- hidden: true,+ secureEntry: true,},],},@@ -1217,4 +1219,206 @@ export const WRAPPERS: WrapperMeta[] = [},],},+ {+ name: 'paddle_wrapper',+ handlerName: WRAPPER_HANDLERS.PADDLE,+ validatorName: 'wasm_fdw_validator',+ icon: `${BASE_PATH}/img/icons/paddle-icon.svg`,+ extensionName: 'paddleFdw',+ label: 'Paddle',+ docsUrl: 'https://supabase.com/docs/guides/database/extensions/wrappers/paddle',+ minimumExtensionVersion: '0.4.0',+ server: {+ options: [+ {+ name: 'fdw_package_url',+ label: 'FDW Package URL',+ required: true,+ encrypted: false,+ secureEntry: false,+ defaultValue:+ 'https://github.com/supabase/wrappers/releases/download/wasm_paddle_fdw_v0.1.0/paddle_fdw.wasm',+ hidden: true,+ },+ {+ name: 'fdw_package_name',+ label: 'FDW Package Name',+ required: true,+ encrypted: false,+ secureEntry: false,+ defaultValue: 'supabase:paddle-fdw',+ hidden: true,+ },+ {+ name: 'fdw_package_version',+ label: 'FDW Package Version',+ required: true,+ encrypted: false,+ secureEntry: false,+ defaultValue: '0.1.0',+ hidden: true,+ },+ {+ name: 'fdw_package_checksum',+ label: 'FDW Package Checksum',+ required: true,+ encrypted: false,+ secureEntry: false,+ defaultValue: '7d0b902440ac2ef1af85d09807145247f14d1d8fd4d700227e5a4d84c8145409',+ hidden: true,+ },+ {+ name: 'api_url',+ label: 'Paddle API URL',+ defaultValue: 'https://api.paddle.com',+ required: true,+ encrypted: false,+ secureEntry: false,+ },+ {+ name: 'api_key_id',+ label: 'Paddle API Key',+ required: true,+ encrypted: true,+ secureEntry: true,+ },+ ],+ },+ tables: [+ {+ label: 'Paddle Object',+ description: 'Map to an Paddle Object',+ options: [+ {+ name: 'object',+ label: 'Object',+ editable: true,+ required: true,+ type: 'select',+ defaultValue: 'products',+ options: [+ { label: 'Products', value: 'products' },+ { label: 'Prices', value: 'prices' },+ { label: 'Discounts', value: 'discounts' },+ { label: 'Customers', value: 'customers' },+ { label: 'Transactions', value: 'transactions' },+ { label: 'Reports', value: 'reports' },+ { label: 'Notification Settings', value: 'notification-settings' },+ { label: 'notifications', value: 'notifications' },+ ],+ },+ {+ name: 'rowid_column',+ label: 'Row ID Column',+ defaultValue: 'id',+ editable: true,+ required: true,+ type: 'text',+ },+ ],+ },+ ],+ },+ {+ name: 'snowflake_wrapper',+ handlerName: WRAPPER_HANDLERS.SNOWFLAKE,+ validatorName: 'wasm_fdw_validator',+ icon: `${BASE_PATH}/img/icons/snowflake-icon.svg`,+ extensionName: 'snowflakeFdw',+ label: 'Snowflake',+ docsUrl: 'https://supabase.com/docs/guides/database/extensions/wrappers/snowflake',+ minimumExtensionVersion: '0.4.0',+ server: {+ options: [+ {+ name: 'fdw_package_url',+ label: 'FDW Package URL',+ required: true,+ encrypted: false,+ secureEntry: false,+ defaultValue:+ 'https://github.com/supabase/wrappers/releases/download/wasm_snowflake_fdw_v0.1.0/snowflake_fdw.wasm',+ hidden: true,+ },+ {+ name: 'fdw_package_name',+ label: 'FDW Package Name',+ required: true,+ encrypted: false,+ secureEntry: false,+ defaultValue: 'supabase:snowflake-fdw',+ hidden: true,+ },+ {+ name: 'fdw_package_version',+ label: 'FDW Package Version',+ required: true,+ encrypted: false,+ secureEntry: false,+ defaultValue: '0.1.0',+ hidden: true,+ },+ {+ name: 'fdw_package_checksum',+ label: 'FDW Package Checksum',+ required: true,+ encrypted: false,+ secureEntry: false,+ defaultValue: '2fb46fd8afa63f3975dadf772338106b609b131861849356e0c09dde032d1af8',+ hidden: true,+ },+ {+ name: 'account_identifier',+ label: 'Account Identifier',+ required: true,+ encrypted: false,+ secureEntry: false,+ },+ {+ name: 'user',+ label: 'User',+ required: true,+ encrypted: false,+ secureEntry: false,+ },+ {+ name: 'public_key_fingerprint',+ label: 'Public Key Fingerprint',+ required: true,+ encrypted: false,+ secureEntry: false,+ },+ {+ name: 'private_key_id',+ label: 'Private Key',+ required: true,+ encrypted: true,+ secureEntry: true,+ },+ ],+ },+ tables: [+ {+ label: 'Snowflake Table',+ description: 'Map to an Snowflake Table',+ options: [+ {+ name: 'table',+ label: 'Table',+ editable: true,+ required: true,+ type: 'text',+ },+ {+ name: 'rowid_column',+ label: 'Row ID Column',+ defaultValue: 'id',+ editable: true,+ required: true,+ type: 'text',+ },+ ],+ },+ ],+ },]diff --git a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.tsx b/apps/studio/components/interfaces/Database/Wrappers/Wrappers.tsxindex 07192e18e4f..a4e1f78a1a5 100644--- a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.tsx+++ b/apps/studio/components/interfaces/Database/Wrappers/Wrappers.tsx@@ -1,4 +1,3 @@-import { groupBy } from 'lodash'import { useState } from 'react'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'@@ -6,6 +5,7 @@ import { FDW, useFDWsQuery } from 'data/fdw/fdws-query'import DeleteWrapperModal from './DeleteWrapperModal'import WrapperRow from './WrapperRow'import { WRAPPERS } from './Wrappers.constants'+import { wrapperMetaComparator } from './Wrappers.utils'import WrappersDisabledState from './WrappersDisabledState'import WrappersDropdown from './WrappersDropdown'@@ -20,7 +20,6 @@ const Wrappers = ({ isEnabled }: { isEnabled: boolean }) => {const [selectedWrapperToDelete, setSelectedWrapperToDelete] = useState<FDW>()const wrappers = data?.result ?? []- const groupedWrappers = groupBy(wrappers, 'handler')return (<>@@ -30,7 +29,7 @@ const Wrappers = ({ isEnabled }: { isEnabled: boolean }) => {<divclassName={['border rounded border-default px-20 py-16',- 'flex flex-col items-center justify-center space-y-4',+ 'flex flex-col items-center justify-center gap-y-4',].join(' ')}><p className="text-foreground-light text-sm">No wrappers created yet</p>@@ -38,9 +37,9 @@ const Wrappers = ({ isEnabled }: { isEnabled: boolean }) => {</div>) : (<>- {/* [Joshen] This probably needs to change anyways so dont get too stuck with this */}{WRAPPERS.map((wrapper, i) => {- const createdWrappers = groupedWrappers[wrapper.handlerName] ?? []+ const createdWrappers = wrappers.filter((w) => wrapperMetaComparator(wrapper, w))+if (createdWrappers.length > 0) {return (<WrapperRowdiff --git a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.types.ts b/apps/studio/components/interfaces/Database/Wrappers/Wrappers.types.tsindex a95aaed81b5..786db021133 100644--- a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.types.ts+++ b/apps/studio/components/interfaces/Database/Wrappers/Wrappers.types.ts@@ -16,7 +16,8 @@ export type ServerOption = {label: stringrequired: booleanencrypted: boolean- hidden: boolean+ secureEntry: boolean+ hidden?: booleanisTextArea?: booleanurlHelper?: stringdefaultValue?: stringdiff --git a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.utils.ts b/apps/studio/components/interfaces/Database/Wrappers/Wrappers.utils.tsindex 80ceb01f40c..fd7cf3cf2b9 100644--- a/apps/studio/components/interfaces/Database/Wrappers/Wrappers.utils.ts+++ b/apps/studio/components/interfaces/Database/Wrappers/Wrappers.utils.ts@@ -1,4 +1,5 @@-import { WRAPPER_HANDLERS } from './Wrappers.constants'+import { FDW } from 'data/fdw/fdws-query'+import { WRAPPERS, WRAPPER_HANDLERS } from './Wrappers.constants'import type { WrapperMeta } from './Wrappers.types'export const makeValidateRequired = (options: { name: string; required: boolean }[]) => {@@ -96,3 +97,19 @@ export const formatWrapperTables = (wrapper: any, wrapperMeta?: WrapperMeta) =>export const convertKVStringArrayToJson = (values: string[]) => {return Object.fromEntries(values.map((value) => value.split('=')))}++export function wrapperMetaComparator(wrapperMeta: WrapperMeta, wrapper: FDW | undefined) {+ if (wrapperMeta.handlerName === 'wasm_fdw_handler') {+ const serverOptions = convertKVStringArrayToJson(wrapper?.server_options ?? [])+ return (+ wrapperMeta.server.options.find((option) => option.name === 'fdw_package_name')+ ?.defaultValue === serverOptions['fdw_package_name']+ )+ }++ return wrapperMeta.handlerName === wrapper?.handler+}++export function getWrapperMetaForWrapper(wrapper: FDW | undefined) {+ return WRAPPERS.find((w) => wrapperMetaComparator(w, wrapper))+}diff --git a/apps/studio/components/interfaces/Database/Wrappers/WrappersDropdown.tsx b/apps/studio/components/interfaces/Database/Wrappers/WrappersDropdown.tsxindex b3f83d9e741..bc46ce59b54 100644--- a/apps/studio/components/interfaces/Database/Wrappers/WrappersDropdown.tsx+++ b/apps/studio/components/interfaces/Database/Wrappers/WrappersDropdown.tsx@@ -1,19 +1,24 @@import * as Tooltip from '@radix-ui/react-tooltip'import { PermissionAction } from '@supabase/shared-types/out/constants'+import { Plus } from 'lucide-react'import Image from 'next/legacy/image'-import Link from 'next/link'-import { Fragment } from 'react'+import { useRouter } from 'next/router'+import { useState } from 'react'import { useParams } from 'common'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'import {Button,- DropdownMenu,- DropdownMenuContent,- DropdownMenuItem,- DropdownMenuSeparator,- DropdownMenuTrigger,+ CommandEmpty_Shadcn_,+ CommandGroup_Shadcn_,+ CommandInput_Shadcn_,+ CommandItem_Shadcn_,+ Command_Shadcn_,IconPlus,+ PopoverContent_Shadcn_,+ PopoverTrigger_Shadcn_,+ Popover_Shadcn_,+ ScrollArea,} from 'ui'import { WRAPPERS } from './Wrappers.constants'@@ -23,8 +28,10 @@ interface WrapperDropdownProps {}const WrapperDropdown = ({ buttonText = 'Add wrapper', align = 'end' }: WrapperDropdownProps) => {+ const router = useRouter()const { ref } = useParams()const canManageWrappers = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'wrappers')+ const [open, setOpen] = useState(false)if (!canManageWrappers) {return (@@ -54,33 +61,49 @@ const WrapperDropdown = ({ buttonText = 'Add wrapper', align = 'end' }: WrapperD}return (- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button type="primary" icon={<IconPlus strokeWidth={1.5} />}>+ <Popover_Shadcn_ open={open} onOpenChange={setOpen}>+ <PopoverTrigger_Shadcn_ asChild>+ <Button+ type="primary"+ role="combobox"+ aria-expanded={open}+ icon={<Plus className="h-4 w-4 shrink-0" />}+ >{buttonText}</Button>- </DropdownMenuTrigger>- <DropdownMenuContent side="bottom" align={align}>- {WRAPPERS.map((wrapper, idx) => (- <Fragment key={idx}>- <DropdownMenuItem key={wrapper.name} className="space-x-2" asChild>- <Link- href={`/project/${ref}/database/wrappers/new?type=${wrapper.name.toLowerCase()}`}- >- <Image- src={wrapper.icon}- width={20}- height={20}- alt={`${wrapper.name} wrapper icon`}- />- <p>{wrapper.label}</p>- </Link>- </DropdownMenuItem>- {idx !== WRAPPERS.length - 1 && <DropdownMenuSeparator />}- </Fragment>- ))}- </DropdownMenuContent>- </DropdownMenu>+ </PopoverTrigger_Shadcn_>+ <PopoverContent_Shadcn_ className="w-[200px] p-0" align={align}>+ <Command_Shadcn_>+ <CommandInput_Shadcn_ placeholder="Search wrappers..." />+ <CommandEmpty_Shadcn_ className="py-3">No wrappers found</CommandEmpty_Shadcn_>+ <CommandGroup_Shadcn_>+ <ScrollArea className="max-h-[270px] overflow-scroll">+ {WRAPPERS.map((wrapper) => (+ <CommandItem_Shadcn_+ key={wrapper.name}+ value={wrapper.name}+ onSelect={() => {+ setOpen(false)+ router.push(+ `/project/${ref}/database/wrappers/new?type=${wrapper.name.toLowerCase()}`+ )+ }}+ className="gap-2 cursor-pointer"+ >+ <Image+ width={20}+ height={20}+ src={wrapper.icon}+ alt={`${wrapper.name} wrapper icon`}+ />+ {wrapper.label}+ </CommandItem_Shadcn_>+ ))}+ </ScrollArea>+ </CommandGroup_Shadcn_>+ </Command_Shadcn_>+ </PopoverContent_Shadcn_>+ </Popover_Shadcn_>)}diff --git a/apps/studio/pages/project/[ref]/database/wrappers/index.tsx b/apps/studio/pages/project/[ref]/database/wrappers/index.tsxindex 23063018077..0e2aeeed20a 100644--- a/apps/studio/pages/project/[ref]/database/wrappers/index.tsx+++ b/apps/studio/pages/project/[ref]/database/wrappers/index.tsx@@ -45,14 +45,14 @@ const DatabaseWrappers: NextPageWithLayout = () => {return (<ScaffoldContainer><ScaffoldSection>- <ScaffoldSectionContent>+ <ScaffoldSectionContent className="xl:!col-span-8"><FormHeaderclassName="!mb-0"title="Foreign Data Wrappers"description="Query your data warehouse directly from your database, or third-party APIs using SQL"/></ScaffoldSectionContent>- <ScaffoldSectionDetail className="flex items-center justify-end gap-x-2">+ <ScaffoldSectionDetail className="xl:!col-span-4 flex items-center justify-end gap-x-2"><Button asChild type="default" icon={<ExternalLink size={14} strokeWidth={1.5} />}><atarget="_blank"diff --git a/apps/studio/public/img/icons/paddle-icon.svg b/apps/studio/public/img/icons/paddle-icon.svgnew file mode 100644index 00000000000..371498cab09--- /dev/null+++ b/apps/studio/public/img/icons/paddle-icon.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24.6 30.6" style="enable-background:new 0 0 24.6 30.6" xml:space="preserve"><path d="M0 11.2v-1.1c1.3 0 2.6-.5 3.6-1.5C4.5 7.7 5 6.4 5 5.1h1c0 1.3.5 2.6 1.5 3.5.9.9 2.2 1.5 3.6 1.5v1.1c-1.3 0-2.6.5-3.6 1.5-.9.9-1.5 2.1-1.5 3.5H5c0-1.3-.5-2.6-1.5-3.5-.9-1-2.2-1.5-3.5-1.5zm5-8h8.7c4.2 0 7.3 3 7.3 7.4S18 18 13.7 18H5v12.6h3.6v-9.4h5c6.1 0 10.9-4.8 10.9-10.6C24.6 4.8 19.8 0 13.7 0H5v3.2z" style="fill:#0e1414"/></svg>\ No newline at end of filediff --git a/apps/studio/public/img/icons/snowflake-icon.svg b/apps/studio/public/img/icons/snowflake-icon.svgnew file mode 100644index 00000000000..1a70dd0d29f--- /dev/null+++ b/apps/studio/public/img/icons/snowflake-icon.svg@@ -0,0 +1 @@+<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 146.36 139.16"><path d="m134.81 60.1-16.47 9.49L134.81 79a8.65 8.65 0 1 1-8.67 15L96.63 77a8.68 8.68 0 0 1-4.33-7.75 8.48 8.48 0 0 1 .31-2 8.68 8.68 0 0 1 4-5.19l29.51-16.94A8.69 8.69 0 0 1 138 48.31a8.58 8.58 0 0 1-3.19 11.79Zm-15.59 46-29.5-16.97a8.72 8.72 0 0 0-13.06 7.48v33.9a8.69 8.69 0 0 0 17.37 0v-19l16.51 9.49a8.66 8.66 0 1 0 8.68-15Zm-34-33.16-12.3 12.15a2.44 2.44 0 0 1-1.54.65h-3.61a2.51 2.51 0 0 1-1.54-.65L54 72.9a2.45 2.45 0 0 1-.64-1.52v-3.6a2.5 2.5 0 0 1 .64-1.53l12.23-12.19a2.5 2.5 0 0 1 1.54-.64h3.61a2.45 2.45 0 0 1 1.54.64l12.26 12.19a2.49 2.49 0 0 1 .63 1.53v3.6a2.44 2.44 0 0 1-.63 1.52Zm-9.8-3.38a2.59 2.59 0 0 0-.69-1.56l-3.55-3.51a2.51 2.51 0 0 0-1.54-.64h-.13a2.46 2.46 0 0 0-1.53.64L64.43 68a2.51 2.51 0 0 0-.63 1.55v.13a2.41 2.41 0 0 0 .63 1.52L68 74.7a2.48 2.48 0 0 0 1.53.64h.13a2.51 2.51 0 0 0 1.54-.64l3.55-3.53a2.49 2.49 0 0 0 .65-1.52ZM19.93 33.08 49.44 50a8.73 8.73 0 0 0 13.07-7.49V8.64a8.69 8.69 0 0 0-17.37 0v19l-16.53-9.5a8.65 8.65 0 1 0-8.68 15Zm64.76 18.08a8.64 8.64 0 0 0 5-1.13l29.5-17a8.65 8.65 0 1 0-8.68-15L94 27.61v-19a8.69 8.69 0 0 0-17.37 0v33.9a8.66 8.66 0 0 0 8.06 8.65ZM54.48 88a8.58 8.58 0 0 0-5 1.13l-29.55 16.93a8.66 8.66 0 1 0 8.68 15l16.53-9.49v19a8.69 8.69 0 0 0 17.37 0V96.61A8.65 8.65 0 0 0 54.48 88Zm-8-15.87a8.61 8.61 0 0 0-4-10L13 45.14a8.69 8.69 0 0 0-11.83 3.17A8.59 8.59 0 0 0 4.35 60.1l16.47 9.49L4.35 79A8.65 8.65 0 1 0 13 94l29.48-17a8.59 8.59 0 0 0 3.99-4.87Zm93.15-56.22h-1.33v1.63h1.32c.61 0 1-.28 1-.8s-.36-.83-1-.83Zm-2.94-1.5h3c1.62 0 2.7.89 2.7 2.27a2.16 2.16 0 0 1-1.08 1.9l1.17 1.68v.34h-1.69l-1.17-1.6h-1.32v1.6h-1.62Zm8.3 3.22a5.48 5.48 0 0 0-5.58-5.83c-3.31 0-5.51 2.39-5.51 5.83 0 3.28 2.2 5.82 5.51 5.82a5.47 5.47 0 0 0 5.59-5.82Zm1.38 0c0 3.89-2.6 7.14-7 7.14s-6.89-3.28-6.89-7.14 2.57-7.14 6.89-7.14 6.99 3.24 6.99 7.14Z" style="fill:#29b5e8;fill-rule:evenodd"/></svg>\ No newline at end of file