The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: Create FDW for S3 Vectors buckets (#40206)
Ivan Vasilovc5bf65b0b454
diff --git a/apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsx b/apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsxindex 239763225b5..dae36f2de1e 100644--- a/apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsx+++ b/apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsx@@ -225,6 +225,14 @@ const pageMap = [},remoteFile: 's3.md',},+ {+ slug: 's3_vectors',+ meta: {+ title: 'AWS S3 Vectors',+ dashboardIntegrationPath: 's3_vectors_wrapper',+ },+ remoteFile: 's3vectors.md',+ },{slug: 'snowflake',meta: {diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.tsindex 6c969cff86a..b00b3698b5d 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts@@ -1293,6 +1293,10 @@ export const database: NavMenuConstant = {name: 'Connecting to AWS S3',url: '/guides/database/extensions/wrappers/s3' as `/${string}`,},+ {+ name: 'Connecting to AWS S3 Vectors',+ url: '/guides/database/extensions/wrappers/s3_vectors' as `/${string}`,+ },{name: 'Connecting to BigQuery',url: '/guides/database/extensions/wrappers/bigquery' as `/${string}`,diff --git a/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTab.tsx b/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTab.tsxindex cdedd52cfc1..88a3e09f160 100644--- a/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTab.tsx+++ b/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTab.tsx@@ -5,8 +5,7 @@ import { useParams } from 'common'import { Markdown } from 'components/interfaces/Markdown'import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'-import { Badge, Separator } from 'ui'-import { Admonition } from 'ui-patterns/admonition'+import { Alert_Shadcn_, AlertDescription_Shadcn_, Badge, Separator } from 'ui'import { INTEGRATIONS } from '../Landing/Integrations.constants'import { BuiltBySection } from './BuildBySection'import { MarkdownContent } from './MarkdownContent'@@ -51,37 +50,35 @@ export const IntegrationOverviewTab = ({<BuiltBySection integration={integration} />{dependsOnExtension && (<div className="px-4 md:px-10 max-w-4xl">- <Admonition- showIcon={false}- type="default"- className="[&>div]:flex [&>div]:flex-col [&>div]:gap-y-2"- >- <Badge className="bg-surface-300 bg-opacity-100 flex items-center gap-x-2 w-max">- <img- alt="Supabase"- src={`${router.basePath}/img/supabase-logo.svg`}- className=" h-2.5 cursor-pointer rounded"- />- <span>Postgres Module</span>- </Badge>- <Markdown- className="max-w-full"- content={`This integration uses the ${integration.requiredExtensions.map((x) => `\`${x}\``).join(', ')}+ <Alert_Shadcn_ variant="default" className="bg-surface-200/25 border border-default">+ <AlertDescription_Shadcn_ className="flex flex-col gap-y-2">+ <Badge className="bg-surface-300 bg-opacity-100 flex items-center gap-x-2 w-max">+ <img+ alt="Supabase"+ src={`${router.basePath}/img/supabase-logo.svg`}+ className=" h-2.5 cursor-pointer rounded"+ />+ <span>Postgres Module</span>+ </Badge>+ <Markdown+ className="max-w-full"+ content={`This integration uses the ${integration.requiredExtensions.map((x) => `\`${x}\``).join(', ')}extension${integration.requiredExtensions.length > 1 ? 's' : ''} directly in your Postgres database.${hasToInstallExtensions && !hasMissingExtensions ? `Install ${integration.requiredExtensions.length > 1 ? 'these' : 'this'} database extension${integration.requiredExtensions.length > 1 ? 's' : ''} to use ${integration.name} in your project.` : ''}`}- />+ />- {hasMissingExtensions ? (- integration.missingExtensionsAlert- ) : (- <div className="flex flex-row gap-x-2">- {installableExtensions.map((extension) => (- <MissingExtensionAlert key={extension.name} extension={extension} />- ))}- </div>- )}- </Admonition>+ {hasMissingExtensions ? (+ integration.missingExtensionsAlert+ ) : (+ <div className="flex flex-row gap-x-2">+ {installableExtensions.map((extension) => (+ <MissingExtensionAlert key={extension.name} extension={extension} />+ ))}+ </div>+ )}+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_></div>)}{!!actions && !hasToInstallExtensions && <div className="px-10 max-w-4xl">{actions}</div>}diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/CreateWrapperSheet.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/CreateWrapperSheet.tsxindex 1b613018ff7..47c1851edea 100644--- a/apps/studio/components/interfaces/Integrations/Wrappers/CreateWrapperSheet.tsx+++ b/apps/studio/components/interfaces/Integrations/Wrappers/CreateWrapperSheet.tsx@@ -129,7 +129,7 @@ export const CreateWrapperSheet = ({}}if (selectedMode === 'schema') {- if (values.source_schema.length === 0) {+ if (wrapperMeta.sourceSchemaOption && values.source_schema.length === 0) {errors.source_schema = 'Please provide a source schema'}if (values.target_schema.length === 0) {@@ -162,7 +162,12 @@ export const CreateWrapperSheet = ({server_name: `${values.wrapper_name}_server`,supabase_target_schema: selectedMode === 'schema' ? values.target_schema : undefined,},- mode: selectedMode,+ mode:+ selectedMode === 'schema'+ ? wrapperMeta.sourceSchemaOption+ ? 'schema'+ : 'skip'+ : 'tables',tables: newTables,sourceSchema: values.source_schema,targetSchema: values.target_schema,diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/Wrappers.constants.ts b/apps/studio/components/interfaces/Integrations/Wrappers/Wrappers.constants.tsindex 76deeca5c7c..113d6df59f5 100644--- a/apps/studio/components/interfaces/Integrations/Wrappers/Wrappers.constants.ts+++ b/apps/studio/components/interfaces/Integrations/Wrappers/Wrappers.constants.ts@@ -5,6 +5,7 @@ export const WRAPPER_HANDLERS = {STRIPE: 'stripe_fdw_handler',FIREBASE: 'firebase_fdw_handler',S3: 's3_fdw_handler',+ S3_VECTORS: 's3_vectors_fdw_handler',CLICK_HOUSE: 'click_house_fdw_handler',BIG_QUERY: 'big_query_fdw_handler',AIRTABLE: 'airtable_fdw_handler',@@ -1415,6 +1416,53 @@ export const WRAPPERS: WrapperMeta[] = [},],},+ {+ name: 's3_vectors_wrapper',+ handlerName: WRAPPER_HANDLERS.S3_VECTORS,+ validatorName: 's3_vectors_fdw_validator',+ icon: `${BASE_PATH}/img/icons/s3-icon.svg`,+ description: 'Cloud storage service for high-dimensional vectors',+ extensionName: 'S3VectorsFdw',+ label: 'S3 Vectors',+ docsUrl: `${DOCS_URL}/guides/database/extensions/wrappers/s3-vectors`,+ minimumExtensionVersion: '0.5.6',+ server: {+ options: [+ {+ name: 'vault_access_key_id',+ label: 'Access Key ID',+ required: true,+ encrypted: true,+ secureEntry: true,+ },+ {+ name: 'vault_secret_access_key',+ label: 'Access Key Secret',+ required: true,+ encrypted: true,+ secureEntry: true,+ },+ {+ name: 'aws_region',+ label: 'AWS Region',+ required: true,+ encrypted: false,+ secureEntry: false,+ defaultValue: 'us-east-1',+ },+ {+ name: 'endpoint_url',+ label: 'Endpoint URL',+ required: false,+ encrypted: false,+ secureEntry: false,+ defaultValue: '',+ },+ ],+ },+ canTargetSchema: true,+ tables: [],+ },{name: 'clickhouse_wrapper',handlerName: WRAPPER_HANDLERS.CLICK_HOUSE,diff --git a/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.utils.ts b/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.utils.tsindex 60c104e641e..e0ec2e1eed6 100644--- a/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.utils.ts+++ b/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.utils.ts@@ -44,3 +44,9 @@ export function getCatalogURI(projectRef: string, protocol: string, endpoint?: surl.pathname = '/storage/v1/iceberg'return url.toString()}++export function getVectorURI(projectRef: string, protocol: string, endpoint?: string) {+ const url = getStorageURL(projectRef, protocol, endpoint)+ url.pathname = '/storage/v1/vector'+ return url.toString()+}diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorBucketDialog.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorBucketDialog.tsxindex 354ae2596f3..d4e801dec5e 100644--- a/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorBucketDialog.tsx+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorBucketDialog.tsx@@ -8,11 +8,16 @@ import z from 'zod'import { useParams } from 'common'import { ButtonTooltip } from 'components/ui/ButtonTooltip'+import { InlineLink } from 'components/ui/InlineLink'+import { useSchemaCreateMutation } from 'data/database/schema-create-mutation'+import { useS3VectorsWrapperCreateMutation } from 'data/storage/s3-vectors-wrapper-create-mutation'import { useVectorBucketCreateMutation } from 'data/storage/vector-bucket-create-mutation'import { useVectorBucketsQuery } from 'data/storage/vector-buckets-query'import { useSendEventMutation } from 'data/telemetry/send-event-mutation'import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'+import { DOCS_URL } from 'lib/constants'import {Button,Dialog,@@ -28,8 +33,11 @@ import {FormField_Shadcn_,Input_Shadcn_,} from 'ui'+import { Admonition } from 'ui-patterns/admonition'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'import { inverseValidBucketNameRegex, validBucketNameRegex } from '../CreateBucketModal.utils'+import { useS3VectorsWrapperExtension } from './useS3VectorsWrapper'+import { getVectorBucketFDWSchemaName } from './VectorBuckets.utils'const FormSchema = z.object({name: z@@ -58,6 +66,8 @@ export type CreateBucketForm = z.infer<typeof FormSchema>export const CreateVectorBucketDialog = () => {const { ref } = useParams()const { data: org } = useSelectedOrganizationQuery()+ const { data: project } = useSelectedProjectQuery()+ const [isLoading, setIsLoading] = useState(false)const [visible, setVisible] = useState(false)const { can: canCreateBuckets } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')@@ -70,20 +80,16 @@ export const CreateVectorBucketDialog = () => {})const { mutate: sendEvent } = useSendEventMutation()- const { mutate: createVectorBucket, isLoading: isCreating } = useVectorBucketCreateMutation({- onSuccess: (values) => {- sendEvent({- action: 'storage_bucket_created',- properties: { bucketType: 'vector' },- groups: { project: ref ?? 'Unknown', organization: org?.slug ?? 'Unknown' },- })- toast.success(`Successfully created vector bucket ${values.name}`)- form.reset()- setVisible(false)- },- onError: (error) => {- toast.error(`Failed to create vector bucket: ${error.message}`)- },+ const { mutateAsync: createVectorBucket } = useVectorBucketCreateMutation({+ onError: () => {},+ })++ const { state: wrappersExtensionState } = useS3VectorsWrapperExtension()++ const { mutateAsync: createS3VectorsWrapper } = useS3VectorsWrapperCreateMutation()++ const { mutateAsync: createSchema } = useSchemaCreateMutation({+ onError: () => {},})const onSubmit: SubmitHandler<CreateBucketForm> = async (values) => {@@ -94,7 +100,40 @@ export const CreateVectorBucketDialog = () => {)if (hasExistingBucket) return toast.error('Bucket name already exists')- createVectorBucket({ projectRef: ref, bucketName: values.name })+ setIsLoading(true)+ try {+ await createVectorBucket({ projectRef: ref, bucketName: values.name })+ } catch (error: any) {+ toast.error(`Failed to create vector bucket: ${error.message}`)+ setIsLoading(false)+ return+ }++ try {+ if (wrappersExtensionState === 'installed') {+ await createS3VectorsWrapper({ bucketName: values.name })++ await createSchema({+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ name: getVectorBucketFDWSchemaName(values.name),+ })+ }+ } catch (error: any) {+ toast.warning(+ `Failed to create vector bucket integration: ${error.message}. The bucket will be created but you will need to manually install the integration.`+ )+ }+ setIsLoading(false)++ sendEvent({+ action: 'storage_bucket_created',+ properties: { bucketType: 'vector' },+ groups: { project: ref ?? 'Unknown', organization: org?.slug ?? 'Unknown' },+ })+ toast.success(`Successfully created vector bucket ${values.name}`)+ form.reset()+ setVisible(false)}useEffect(() => {@@ -160,15 +199,26 @@ export const CreateVectorBucketDialog = () => {</FormItemLayout>)}/>+ <Admonition type="default">+ <p>+ Supabase will install the{' '}+ {wrappersExtensionState !== 'installed' ? 'Wrappers extension and ' : ''}+ S3 Vectors Wrapper integration on your behalf.{' '}+ <InlineLink href={`${DOCS_URL}/guides/database/extensions/wrappers/s3-vectors`}>+ Learn more+ </InlineLink>+ .+ </p>+ </Admonition></DialogSection></form></Form_Shadcn_><DialogFooter>- <Button type="default" disabled={isCreating} onClick={() => setVisible(false)}>+ <Button type="default" disabled={isLoading} onClick={() => setVisible(false)}>Cancel</Button>- <Button form={formId} htmlType="submit" loading={isCreating} disabled={isCreating}>+ <Button form={formId} htmlType="submit" loading={isLoading}>Create</Button></DialogFooter>diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsxindex 6b512720d42..fe9d82bffa2 100644--- a/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsx+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsx@@ -6,9 +6,9 @@ import { SubmitHandler, useFieldArray, useForm } from 'react-hook-form'import { toast } from 'sonner'import z from 'zod'-import { useParams } from 'common'import { ButtonTooltip } from 'components/ui/ButtonTooltip'import { DocsButton } from 'components/ui/DocsButton'+import { useFDWImportForeignSchemaMutation } from 'data/fdw/fdw-import-foreign-schema-mutation'import { useVectorBucketIndexCreateMutation } from 'data/storage/vector-bucket-index-create-mutation'import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'@@ -34,6 +34,8 @@ import {import { Admonition } from 'ui-patterns'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'import { inverseValidBucketNameRegex } from '../CreateBucketModal.utils'+import { getVectorBucketFDWSchemaName } from './VectorBuckets.utils'+import { useS3VectorsWrapperInstance } from './useS3VectorsWrapperInstance'const isStagingLocal = process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod'@@ -75,7 +77,7 @@ const FormSchema = z.object({})}}),- targetSchema: z.string().default(''),+ bucketName: z.string().default(''),dimension: z.number().int('Dimension must be an integer')@@ -102,18 +104,19 @@ interface CreateVectorTableSheetProps {}export const CreateVectorTableSheet = ({ bucketName }: CreateVectorTableSheetProps) => {- const { ref } = useParams()const { data: project } = useSelectedProjectQuery()const [visible, setVisible] = useState(false)const { can: canCreateBuckets } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')+ const { data: wrapperInstance } = useS3VectorsWrapperInstance({ bucketId: bucketName })+// [Joshen] Can remove this once this restriction is removedconst showIndexCreationNotice = isStagingLocal && !!project && project?.region !== 'us-east-1'const defaultValues = {name: '',- targetSchema: bucketName,+ bucketName,dimension: undefined,distanceMetric: 'cosine' as 'cosine' | 'euclidean',metadataKeys: [],@@ -129,32 +132,52 @@ export const CreateVectorTableSheet = ({ bucketName }: CreateVectorTableSheetProname: 'metadataKeys',})- const { mutate: createVectorBucketTable, isLoading: isCreating } =- useVectorBucketIndexCreateMutation({- onSuccess: (values) => {- toast.success(`Successfully created vector table ${values.name}`)- form.reset()+ const { mutateAsync: createVectorBucketTable, isLoading: isCreatingVectorBucketTable } =+ useVectorBucketIndexCreateMutation()- setVisible(false)- },- onError: (error) => {- // For other errors, show a toast as fallback- toast.error(`Failed to create vector table: ${error.message}`)- },+ const { mutateAsync: importForeignSchema, isLoading: isImportingForeignSchema } =+ useFDWImportForeignSchemaMutation({+ onError: () => {},})+ const isCreating = isCreatingVectorBucketTable || isImportingForeignSchemaconst onSubmit: SubmitHandler<CreateVectorTableForm> = async (values) => {- if (!ref) return console.error('Project ref is required')+ if (!project?.ref) return console.error('Project ref is required')- createVectorBucketTable({- projectRef: ref,- bucketName: values.targetSchema,- indexName: values.name,- dataType: 'float32',- dimension: values.dimension!,- distanceMetric: values.distanceMetric,- metadataKeys: values.metadataKeys.map((key) => key.value),- })+ try {+ await createVectorBucketTable({+ projectRef: project.ref,+ bucketName: values.bucketName,+ indexName: values.name,+ dataType: 'float32',+ dimension: values.dimension!,+ distanceMetric: values.distanceMetric,+ metadataKeys: values.metadataKeys.map((key) => key.value),+ })+ } catch (error: any) {+ toast.error(`Failed to create vector table: ${error.message}`)+ return+ }++ try {+ if (wrapperInstance) {+ await importForeignSchema({+ projectRef: project.ref,+ connectionString: project?.connectionString,+ serverName: wrapperInstance.server_name,+ sourceSchema: getVectorBucketFDWSchemaName(values.bucketName),+ targetSchema: getVectorBucketFDWSchemaName(values.bucketName),+ schemaOptions: [`bucket_name '${values.bucketName}'`],+ })+ }+ } catch (error: any) {+ toast.warning(`Failed to connect vector table to the database: ${error.message}`)+ }++ toast.success(`Successfully created vector table ${values.name}`)+ form.reset()++ setVisible(false)}useEffect(() => {@@ -235,25 +258,14 @@ export const CreateVectorTableSheet = ({ bucketName }: CreateVectorTableSheetPro/><FormField_Shadcn_- key="targetSchema"- name="targetSchema"+ key="bucketName"+ name="bucketName"control={form.control}render={({ field }) => (- <FormItemLayout- name="targetSchema"- label="Target schema"- description="The bucket name will be used as the target schema."- layout="horizontal"- >+ <FormItemLayout name="bucketName" label="Bucket name" layout="horizontal"><FormControl_Shadcn_><div className="relative">- <Input_Shadcn_- id="targetSchema"- {...field}- value={field.value}- disabled- className="pr-10"- />+ <Input_Shadcn_ {...field} value={field.value} disabled className="pr-10" /><div className="absolute right-3 top-1/2 -translate-y-1/2"><Lock size={14} className="text-foreground-muted" /></div>diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorBucketModal.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorBucketModal.tsxindex a2946484160..8ddc6b4f9a8 100644--- a/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorBucketModal.tsx+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorBucketModal.tsx@@ -1,10 +1,13 @@+import { useState } from 'react'import { toast } from 'sonner'-import { useParams } from 'common'+import { useFDWDeleteMutation } from 'data/fdw/fdw-delete-mutation'import { useVectorBucketDeleteMutation } from 'data/storage/vector-bucket-delete-mutation'import { deleteVectorBucketIndex } from 'data/storage/vector-bucket-index-delete-mutation'import { useVectorBucketsIndexesQuery } from 'data/storage/vector-buckets-indexes-query'+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'+import { useS3VectorsWrapperInstance } from './useS3VectorsWrapperInstance'export interface DeleteVectorBucketModalProps {visible: boolean@@ -19,40 +22,61 @@ export const DeleteVectorBucketModal = ({onCancel,onSuccess,}: DeleteVectorBucketModalProps) => {- const { ref: projectRef } = useParams()+ const { data: project } = useSelectedProjectQuery()+ // Has to be a state because we're using a promise.all to delete the indexes+ const [isDeletingIndexes, setIsDeletingIndexes] = useState(false)- const { mutate: deleteBucket, isLoading: isDeletingBucket } = useVectorBucketDeleteMutation({+ const { data: vectorBucketWrapper, meta: wrapperMeta } = useS3VectorsWrapperInstance({+ bucketId: bucketName,+ })++ const { mutate: deleteFDW } = useFDWDeleteMutation()++ const { mutateAsync: deleteBucket, isLoading: isDeletingBucket } = useVectorBucketDeleteMutation({onSuccess: async () => {toast.success(`Bucket "${bucketName}" deleted successfully`)+ if (vectorBucketWrapper) {+ deleteFDW({+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ wrapper: vectorBucketWrapper,+ wrapperMeta: wrapperMeta!,+ })+ }onSuccess()},})- const { data: { indexes = [] } = {}, isLoading: isDeletingIndexes } =- useVectorBucketsIndexesQuery({- projectRef,+ const { data: { indexes = [] } = {}, isLoading: isLoadingIndexes } = useVectorBucketsIndexesQuery(+ {+ projectRef: project?.ref,vectorBucketName: bucketName,- })+ }+ )const onConfirmDelete = async () => {- if (!projectRef) return console.error('Project ref is required')+ if (!project?.ref) return console.error('Project ref is required')if (!bucketName) return console.error('No bucket is selected')try {+ setIsDeletingIndexes(true)// delete all indexes from the bucket firstconst promises = indexes.map((index) =>deleteVectorBucketIndex({- projectRef,+ projectRef: project?.ref,bucketName: bucketName,indexName: index.indexName,}))await Promise.all(promises)- deleteBucket({ projectRef, bucketName })++ await deleteBucket({ projectRef: project?.ref, bucketName })} catch (error) {toast.error(`Failed to delete bucket: ${error instanceof Error ? error.message : 'Unknown error'}`)+ } finally {+ setIsDeletingIndexes(false)}}@@ -62,7 +86,7 @@ export const DeleteVectorBucketModal = ({size="medium"variant="destructive"title={`Delete bucket “${bucketName}”`}- loading={isDeletingBucket || isDeletingIndexes}+ loading={isDeletingBucket || isDeletingIndexes || isLoadingIndexes}confirmPlaceholder="Type bucket name"confirmString={bucketName ?? ''}confirmLabel="Delete bucket"diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorTableModal.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorTableModal.tsxindex f9251980718..89ded2ebe2e 100644--- a/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorTableModal.tsx+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorTableModal.tsx@@ -1,9 +1,11 @@import { toast } from 'sonner'-import { useParams } from 'common'+import { useFDWDropForeignTableMutation } from 'data/fdw/fdw-drop-foreign-table-mutation'import { useVectorBucketIndexDeleteMutation } from 'data/storage/vector-bucket-index-delete-mutation'import { VectorBucketIndex } from 'data/storage/vector-buckets-indexes-query'+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'+import { getVectorBucketFDWSchemaName } from './VectorBuckets.utils'interface DeleteVectorTableModalProps {visible: boolean@@ -16,21 +18,31 @@ export const DeleteVectorTableModal = ({table,onClose,}: DeleteVectorTableModalProps) => {- const { ref: projectRef } = useParams()+ const { data: project } = useSelectedProjectQuery()++ const { mutate: deleteForeignTable } = useFDWDropForeignTableMutation({+ onError: () => {},+ })const { mutate: deleteIndex, isLoading: isDeleting } = useVectorBucketIndexDeleteMutation({onSuccess: (_, vars) => {+ deleteForeignTable({+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ schemaName: getVectorBucketFDWSchemaName(vars.bucketName),+ tableName: vars.indexName,+ })toast.success(`Table "${vars.indexName}" deleted successfully`)onClose()},})const onConfirmDelete = () => {- if (!projectRef) return console.error('Project ref is required')+ if (!project?.ref) return console.error('Project ref is required')if (!table) return console.error('Vector table is required')deleteIndex({- projectRef,+ projectRef: project?.ref,bucketName: table.vectorBucketName,indexName: table.indexName,})diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails.tsxindex 527819a055c..d2790905194 100644--- a/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails.tsx+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails.tsx@@ -2,8 +2,10 @@ import { Eye, MoreVertical, Search, Trash2 } from 'lucide-react'import Link from 'next/link'import { useRouter } from 'next/router'import { useState } from 'react'+import { toast } from 'sonner'import { useParams } from 'common'+import { WrapperMeta } from 'components/interfaces/Integrations/Wrappers/Wrappers.types'import {ScaffoldContainer,ScaffoldHeader,@@ -12,11 +14,17 @@ import {ScaffoldSectionTitle,} from 'components/layouts/Scaffold'import AlertError from 'components/ui/AlertError'+import { InlineLink } from 'components/ui/InlineLink'+import { DatabaseExtension } from 'data/database-extensions/database-extensions-query'+import { useSchemaCreateMutation } from 'data/database/schema-create-mutation'+import { useS3VectorsWrapperCreateMutation } from 'data/storage/s3-vectors-wrapper-create-mutation'import { useVectorBucketQuery } from 'data/storage/vector-bucket-query'import {useVectorBucketsIndexesQuery,VectorBucketIndex,} from 'data/storage/vector-buckets-indexes-query'+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'+import { DOCS_URL } from 'lib/constants'import {Button,Card,@@ -34,9 +42,13 @@ import {} from 'ui'import { Input } from 'ui-patterns/DataInputs/Input'import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'+import { Admonition } from 'ui-patterns/admonition'import { CreateVectorTableSheet } from './CreateVectorTableSheet'import { DeleteVectorBucketModal } from './DeleteVectorBucketModal'import { DeleteVectorTableModal } from './DeleteVectorTableModal'+import { getVectorBucketFDWSchemaName } from './VectorBuckets.utils'+import { useS3VectorsWrapperExtension } from './useS3VectorsWrapper'+import { useS3VectorsWrapperInstance } from './useS3VectorsWrapperInstance'export const VectorBucketDetails = () => {const router = useRouter()@@ -66,6 +78,25 @@ export const VectorBucketDetails = () => {index.indexName.toLowerCase().includes(filterString.toLowerCase()))+ const { extension: wrappersExtension, state: extensionState } = useS3VectorsWrapperExtension()+ const {+ data: wrapperInstance,+ meta: wrapperMeta,+ isLoading: isLoadingWrapper,+ } = useS3VectorsWrapperInstance({+ bucketId,+ })++ const isLoading = isLoadingIndexes || isLoadingWrapper++ const state = isLoading+ ? 'loading'+ : extensionState === 'installed'+ ? wrapperInstance+ ? 'added'+ : 'missing'+ : extensionState+return (<>{isErrorBucket ? (@@ -95,6 +126,24 @@ export const VectorBucketDetails = () => {<CreateVectorTableSheet bucketName={bucket?.vectorBucketName} /></div>+ {state === 'not-installed' && (+ <ExtensionNotInstalled+ bucketName={bucket?.vectorBucketName}+ projectRef={projectRef!}+ wrapperMeta={wrapperMeta!}+ wrappersExtension={wrappersExtension!}+ />+ )}+ {state === 'needs-upgrade' && (+ <ExtensionNeedsUpgrade+ bucketName={bucket?.vectorBucketName}+ projectRef={projectRef!}+ wrapperMeta={wrapperMeta!}+ wrappersExtension={wrappersExtension!}+ />+ )}++ {state === 'missing' && <WrapperMissing bucketName={bucket?.vectorBucketName} />}{isLoadingIndexes ? (<GenericSkeletonLoader />) : (@@ -157,18 +206,20 @@ export const VectorBucketDetails = () => {</TableCell><TableCell><div className="flex flex-row justify-end gap-2">- <Button- asChild- icon={<Eye size={14} className="text-foreground-lighter" />}- type="default"- >- {/* TODO: Proper URL for table editor */}- <Link- href={`/project/${projectRef}/editor/${encodeURIComponent(name)}?schema=${bucketId}`}+ {wrapperInstance ? (+ <Button+ asChild+ icon={<Eye size={14} className="text-foreground-lighter" />}+ type="default">- Table Editor- </Link>- </Button>+ {/* TODO: Proper URL for table editor */}+ <Link+ href={`/project/${projectRef}/editor/${encodeURIComponent(name)}?schema=${getVectorBucketFDWSchemaName(bucketId!)}`}+ >+ Table Editor+ </Link>+ </Button>+ ) : null}<DropdownMenu><DropdownMenuTrigger asChild><Button@@ -247,3 +298,129 @@ export const VectorBucketDetails = () => {</>)}++const ExtensionNotInstalled = ({+ bucketName,+ projectRef,+ wrapperMeta,+ wrappersExtension,+}: {+ bucketName?: string+ projectRef: string+ wrapperMeta: WrapperMeta+ wrappersExtension: DatabaseExtension+}) => {+ const databaseNeedsUpgrading =+ (wrappersExtension?.default_version ?? '') < (wrapperMeta.minimumExtensionVersion ?? '')++ return (+ <ScaffoldSection isFullWidth>+ <Admonition type="warning" title="Missing required extension" className="mb-0">+ <p>+ The Wrappers extension is required in order to query vector tables.{' '}+ {databaseNeedsUpgrading &&+ 'Please first upgrade your database and then install the extension.'}{' '}+ <InlineLink+ href={`${DOCS_URL}/guides/database/extensions/wrappers/s3_vectors`}+ target="_blank"+ >+ Learn more+ </InlineLink>+ </p>+ <Button type="default" asChild className="mt-2">+ <Link+ href={+ databaseNeedsUpgrading+ ? `/project/${projectRef}/settings/infrastructure`+ : `/project/${projectRef}/database/extensions?filter=wrappers`+ }+ >+ {databaseNeedsUpgrading ? 'Upgrade database' : 'Install extension'}+ </Link>+ </Button>+ </Admonition>+ </ScaffoldSection>+ )+}++const ExtensionNeedsUpgrade = ({+ bucketName,+ projectRef,+ wrapperMeta,+ wrappersExtension,+}: {+ bucketName?: string+ projectRef: string+ wrapperMeta: WrapperMeta+ wrappersExtension: DatabaseExtension+}) => {+ // [Joshen] Default version is what's on the DB, so if the installed version is already the default version+ // but still doesnt meet the minimum extension version, then DB upgrade is required+ const databaseNeedsUpgrading =+ wrappersExtension?.installed_version === wrappersExtension?.default_version++ return (+ <ScaffoldSection isFullWidth>+ <Admonition type="warning" title="Outdated extension version" className="mb-0">+ <p>+ The {wrapperMeta.label} wrapper requires a minimum extension version of{' '}+ {wrapperMeta.minimumExtensionVersion}. You have version{' '}+ {wrappersExtension?.installed_version} installed. Please{' '}+ {databaseNeedsUpgrading && 'first upgrade your database, and then '}update the extension+ by disabling and enabling the Wrappers extension.+ </p>+ <p>+ Before reinstalling the wrapper extension, you must first remove all existing wrappers.+ Afterward, you can recreate the wrappers.+ </p>+ <Button asChild type="default">+ <Link+ href={+ databaseNeedsUpgrading+ ? `/project/${projectRef}/settings/infrastructure`+ : `/project/${projectRef}/database/extensions?filter=wrappers`+ }+ >+ {databaseNeedsUpgrading ? 'Upgrade database' : 'Extensions'}+ </Link>+ </Button>+ </Admonition>+ </ScaffoldSection>+ )+}++const WrapperMissing = ({ bucketName }: { bucketName?: string }) => {+ const { data: project } = useSelectedProjectQuery()+ const { mutateAsync: createS3VectorsWrapper, isLoading: isCreatingS3VectorsWrapper } =+ useS3VectorsWrapperCreateMutation()+ const { mutateAsync: createSchema, isLoading: isCreatingSchema } = useSchemaCreateMutation()++ const onSetupWrapper = async () => {+ if (!bucketName) return console.error('Bucket name is required')+ try {+ await createS3VectorsWrapper({ bucketName })+ await createSchema({+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ name: getVectorBucketFDWSchemaName(bucketName),+ })+ } catch (error) {+ toast.error(+ `Failed to install wrapper: ${error instanceof Error ? error.message : 'Unknown error'}`+ )+ }+ }++ const isLoading = isCreatingS3VectorsWrapper || isCreatingSchema++ return (+ <ScaffoldSection isFullWidth>+ <Admonition type="warning" title="Missing integration" className="mb-0">+ <p>The S3 Vectors Wrapper integration is required in order to query vector tables.</p>+ <Button type="default" loading={isLoading} onClick={onSetupWrapper}>+ Install wrapper+ </Button>+ </Admonition>+ </ScaffoldSection>+ )+}diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBuckets.utils.ts b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBuckets.utils.tsnew file mode 100644index 00000000000..8f6b7152033--- /dev/null+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBuckets.utils.ts@@ -0,0 +1,13 @@+import { snakeCase } from 'lodash'++export const getVectorBucketS3KeyName = (bucketId: string) => {+ return `${snakeCase(bucketId)}_keys`+}++export const getVectorBucketFDWSchemaName = (bucketId: string) => {+ return `fdw_vector_${snakeCase(bucketId)}`+}++export const getVectorBucketFDWName = (bucketId: string) => {+ return `${snakeCase(bucketId)}_fdw`+}diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/useS3VectorsWrapper.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/useS3VectorsWrapper.tsxnew file mode 100644index 00000000000..89bec0b65c3--- /dev/null+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/useS3VectorsWrapper.tsx@@ -0,0 +1,42 @@+import { INTEGRATIONS } from 'components/interfaces/Integrations/Landing/Integrations.constants'+import {+ DatabaseExtension,+ useDatabaseExtensionsQuery,+} from 'data/database-extensions/database-extensions-query'+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'++export const useS3VectorsWrapperExtension = (): {+ extension: DatabaseExtension | undefined+ state: 'not-found' | 'loading' | 'installed' | 'needs-upgrade' | 'not-installed'+} => {+ const { data: project } = useSelectedProjectQuery()+ const { data: extensionsData, isLoading: isExtensionsLoading } = useDatabaseExtensionsQuery({+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ })++ const integration = INTEGRATIONS.find((i) => i.id === 's3_vectors_wrapper')++ if (!integration || integration.type !== 'wrapper') {+ // This should never happen+ return { extension: undefined, state: 'not-found' as const }+ }++ const wrapperMeta = integration.meta++ const wrappersExtension = extensionsData?.find((ext) => ext.name === 'wrappers')+ const isWrappersExtensionInstalled = !!wrappersExtension?.installed_version+ const hasRequiredVersion =+ (wrappersExtension?.installed_version ?? '') >= (wrapperMeta?.minimumExtensionVersion ?? '')++ const state: 'not-found' | 'loading' | 'installed' | 'needs-upgrade' | 'not-installed' =+ isExtensionsLoading+ ? 'loading'+ : isWrappersExtensionInstalled+ ? hasRequiredVersion+ ? 'installed'+ : 'needs-upgrade'+ : 'not-installed'++ return { extension: wrappersExtension, state }+}diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/useS3VectorsWrapperInstance.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/useS3VectorsWrapperInstance.tsxnew file mode 100644index 00000000000..ad110ddc018--- /dev/null+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/useS3VectorsWrapperInstance.tsx@@ -0,0 +1,49 @@+import { useMemo } from 'react'++import {+ WRAPPER_HANDLERS,+ WRAPPERS,+} from 'components/interfaces/Integrations/Wrappers/Wrappers.constants'+import { wrapperMetaComparator } from 'components/interfaces/Integrations/Wrappers/Wrappers.utils'+import { type FDW, useFDWsQuery } from 'data/fdw/fdws-query'+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'+import { getVectorBucketFDWName } from './VectorBuckets.utils'++export const useS3VectorsWrapperInstance = (+ { bucketId }: { bucketId?: string },+ options?: { enabled?: boolean; refetchInterval?: (data: FDW[] | undefined) => number | false }+) => {+ const { data: project, isLoading: isLoadingProject } = useSelectedProjectQuery()++ const defaultEnabled = options?.enabled ?? true+ const { data, isLoading: isLoadingFDWs } = useFDWsQuery(+ {+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ },+ {+ enabled: defaultEnabled && !!bucketId,+ refetchInterval: (data) =>+ !!options?.refetchInterval ? options.refetchInterval(data) : false,+ }+ )++ const s3VectorsWrapper = useMemo(() => {+ return data+ ?.filter((wrapper) =>+ wrapperMetaComparator(+ { handlerName: WRAPPER_HANDLERS.S3_VECTORS, server: { options: [] } },+ wrapper+ )+ )+ .find((w) => w.name === getVectorBucketFDWName(bucketId ?? ''))+ }, [data, bucketId])++ const s3VectorsWrapperMeta = WRAPPERS.find((w) => w.handlerName === WRAPPER_HANDLERS.S3_VECTORS)++ return {+ data: s3VectorsWrapper,+ meta: s3VectorsWrapperMeta!,+ isLoading: isLoadingProject || isLoadingFDWs,+ }+}diff --git a/apps/studio/components/ui/Forms/FormSection.tsx b/apps/studio/components/ui/Forms/FormSection.tsxindex 918bc306aaa..714ee501fb0 100644--- a/apps/studio/components/ui/Forms/FormSection.tsx+++ b/apps/studio/components/ui/Forms/FormSection.tsx@@ -1,4 +1,5 @@import { Children } from 'react'+import { cn } from 'ui'export const FormSection = ({children,@@ -39,7 +40,7 @@ export const FormSectionLabel = ({}) => {if (description !== undefined) {return (- <div className={`flex flex-col space-y-2 col-span-12 lg:col-span-5 ${className}`}>+ <div className={cn('flex flex-col space-y-2 col-span-12 lg:col-span-5', className)}><label className="text-foreground text-sm">{children}</label>{description}</div>diff --git a/apps/studio/data/fdw/fdw-create-mutation.ts b/apps/studio/data/fdw/fdw-create-mutation.tsindex 581983c99b0..9cd65975610 100644--- a/apps/studio/data/fdw/fdw-create-mutation.ts+++ b/apps/studio/data/fdw/fdw-create-mutation.ts@@ -25,6 +25,7 @@ export type FDWCreateVariables = {tables: any[]sourceSchema: stringtargetSchema: string+ schemaOptions?: string[]}export function getCreateFDWSql({@@ -34,10 +35,8 @@ export function getCreateFDWSql({tables,sourceSchema,targetSchema,-}: Pick<- FDWCreateVariables,- 'wrapperMeta' | 'formState' | 'tables' | 'mode' | 'sourceSchema' | 'targetSchema'->) {+ schemaOptions = [],+}: Omit<FDWCreateVariables, 'projectRef' | 'connectionString'>) {const newSchemasSql = tables.filter((table) => table.is_new_schema).map((table) => /* SQL */ `create schema if not exists ${table.schema_name};`)@@ -208,8 +207,10 @@ export function getCreateFDWSql({}).join('\n\n')+ const options = [...schemaOptions, "strict 'true'"].join(', ')+const importForeignSchemaSql = /* SQL */ `- import foreign schema "${sourceSchema}" from server ${formState.server_name} into ${targetSchema} options (strict 'true');+ import foreign schema "${sourceSchema}" from server ${formState.server_name} into ${targetSchema} options (${options});`const sql = /* SQL */ `diff --git a/apps/studio/data/fdw/fdw-delete-mutation.ts b/apps/studio/data/fdw/fdw-delete-mutation.tsindex 14c729fdfc8..179be61e648 100644--- a/apps/studio/data/fdw/fdw-delete-mutation.ts+++ b/apps/studio/data/fdw/fdw-delete-mutation.ts@@ -8,13 +8,12 @@ import { executeSql } from 'data/sql/execute-sql-query'import { wrapWithTransaction } from 'data/sql/utils/transaction'import { vaultSecretsKeys } from 'data/vault/keys'import type { ResponseError, UseCustomMutationOptions } from 'types'-import { FDW } from './fdws-query'import { fdwKeys } from './keys'export type FDWDeleteVariables = {projectRef?: stringconnectionString?: string | null- wrapper: FDW+ wrapper: { name: string }wrapperMeta: WrapperMeta}diff --git a/apps/studio/data/fdw/fdw-drop-foreign-table-mutation.ts b/apps/studio/data/fdw/fdw-drop-foreign-table-mutation.tsnew file mode 100644index 00000000000..fb8d243fec5--- /dev/null+++ b/apps/studio/data/fdw/fdw-drop-foreign-table-mutation.ts@@ -0,0 +1,73 @@+import { useMutation, useQueryClient } from '@tanstack/react-query'+import { toast } from 'sonner'++import { entityTypeKeys } from 'data/entity-types/keys'+import { foreignTableKeys } from 'data/foreign-tables/keys'+import { executeSql } from 'data/sql/execute-sql-query'+import { wrapWithTransaction } from 'data/sql/utils/transaction'+import type { ResponseError, UseCustomMutationOptions } from 'types'+import { fdwKeys } from './keys'++export type FDWDropForeignTableVariables = {+ projectRef?: string+ connectionString?: string | null+ schemaName: string+ tableName: string+}++export function getDropForeignTableSql({+ schemaName,+ tableName,+}: Omit<FDWDropForeignTableVariables, 'projectRef' | 'connectionString'>) {+ const sql = /* SQL */ `+drop foreign table if exists "${schemaName}"."${tableName}";+`++ return sql+}++export async function dropForeignTable({+ projectRef,+ connectionString,+ ...rest+}: FDWDropForeignTableVariables) {+ const sql = wrapWithTransaction(getDropForeignTableSql(rest))+ const { result } = await executeSql({ projectRef, connectionString, sql })+ return result+}++type DropForeignTableData = Awaited<ReturnType<typeof dropForeignTable>>++export const useFDWDropForeignTableMutation = ({+ onSuccess,+ onError,+ ...options+}: Omit<+ UseCustomMutationOptions<DropForeignTableData, ResponseError, FDWDropForeignTableVariables>,+ 'mutationFn'+> = {}) => {+ const queryClient = useQueryClient()++ return useMutation<DropForeignTableData, ResponseError, FDWDropForeignTableVariables>({+ mutationFn: (vars) => dropForeignTable(vars),+ async onSuccess(data, variables, context) {+ const { projectRef } = variables++ await Promise.all([+ queryClient.invalidateQueries({ queryKey: fdwKeys.list(projectRef), refetchType: 'all' }),+ queryClient.invalidateQueries({ queryKey: entityTypeKeys.list(projectRef) }),+ queryClient.invalidateQueries({ queryKey: foreignTableKeys.list(projectRef) }),+ ])++ await onSuccess?.(data, variables, context)+ },+ async onError(data, variables, context) {+ if (onError === undefined) {+ toast.error(`Failed to drop foreign table for foreign data wrapper: ${data.message}`)+ } else {+ onError(data, variables, context)+ }+ },+ ...options,+ })+}diff --git a/apps/studio/data/fdw/fdw-import-foreign-schema-mutation.ts b/apps/studio/data/fdw/fdw-import-foreign-schema-mutation.tsindex 603426a7283..95801c43452 100644--- a/apps/studio/data/fdw/fdw-import-foreign-schema-mutation.ts+++ b/apps/studio/data/fdw/fdw-import-foreign-schema-mutation.ts@@ -15,16 +15,21 @@ export type FDWImportForeignSchemaVariables = {serverName: stringsourceSchema: stringtargetSchema: string+ schemaOptions?: string[]}export function getImportForeignSchemaSql({serverName,sourceSchema,targetSchema,-}: Pick<FDWImportForeignSchemaVariables, 'serverName' | 'sourceSchema' | 'targetSchema'>) {+ schemaOptions = [],+}: Omit<FDWImportForeignSchemaVariables, 'projectRef' | 'connectionString'>) {+ const options = [...schemaOptions, "strict 'true'"].join(', ')+const sql = /* SQL */ `- import foreign schema "${sourceSchema}" from server ${serverName} into ${targetSchema};+ import foreign schema "${sourceSchema}" from server ${serverName} into ${targetSchema} options (${options});`+return sql}diff --git a/apps/studio/data/storage/s3-vectors-wrapper-create-mutation.ts b/apps/studio/data/storage/s3-vectors-wrapper-create-mutation.tsnew file mode 100644index 00000000000..2007dbb013b--- /dev/null+++ b/apps/studio/data/storage/s3-vectors-wrapper-create-mutation.ts@@ -0,0 +1,68 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'++import { WRAPPERS } from 'components/interfaces/Integrations/Wrappers/Wrappers.constants'+import { getVectorURI } from 'components/interfaces/Storage/StorageSettings/StorageSettings.utils'+import {+ getVectorBucketFDWName,+ getVectorBucketS3KeyName,+} from 'components/interfaces/Storage/VectorBuckets/VectorBuckets.utils'+import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'+import { FDWCreateVariables, useFDWCreateMutation } from 'data/fdw/fdw-create-mutation'+import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'+import { useS3AccessKeyCreateMutation } from './s3-access-key-create-mutation'++export const useS3VectorsWrapperCreateMutation = () => {+ const { data: project } = useSelectedProjectQuery()++ const { data: settings } = useProjectSettingsV2Query({ projectRef: project?.ref })+ const protocol = settings?.app_config?.protocol ?? 'https'+ const endpoint = settings?.app_config?.storage_endpoint || settings?.app_config?.endpoint++ const wrapperMeta = WRAPPERS.find((wrapper) => wrapper.name === 's3_vectors_wrapper')++ const { can: canCreateCredentials } = useAsyncCheckPermissions(+ PermissionAction.STORAGE_ADMIN_WRITE,+ '*'+ )++ const { mutateAsync: createS3AccessKey, isLoading: isCreatingS3AccessKey } =+ useS3AccessKeyCreateMutation()++ const { mutateAsync: createFDW, isLoading: isCreatingFDW } = useFDWCreateMutation()++ const mutateAsync = async ({ bucketName }: { bucketName: string }) => {+ const createS3KeyData = await createS3AccessKey({+ projectRef: project?.ref,+ description: getVectorBucketS3KeyName(bucketName),+ })++ const wrapperName = getVectorBucketFDWName(bucketName)++ const params: FDWCreateVariables = {+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ wrapperMeta: wrapperMeta!,+ formState: {+ wrapper_name: wrapperName,+ server_name: `${wrapperName}_server`,+ vault_access_key_id: createS3KeyData?.access_key,+ vault_secret_access_key: createS3KeyData?.secret_key,+ aws_region: settings!.region,+ endpoint_url: getVectorURI(project?.ref ?? '', protocol, endpoint),+ },+ mode: 'skip',+ tables: [],+ sourceSchema: '',+ targetSchema: '',+ }++ await createFDW(params)+ }++ return {+ mutateAsync,+ isLoading: isCreatingFDW || isCreatingS3AccessKey,+ hasPermission: canCreateCredentials,+ }+}diff --git a/apps/studio/static-data/integrations/s3_vectors_wrapper/overview.md b/apps/studio/static-data/integrations/s3_vectors_wrapper/overview.mdnew file mode 100644index 00000000000..339668d3013--- /dev/null+++ b/apps/studio/static-data/integrations/s3_vectors_wrapper/overview.md@@ -0,0 +1,3 @@+AWS S3 Vectors is a managed service that stores and queries high-dimensional vectors at scale, optimized for machine learning and artificial intelligence applications.++The S3 Vectors Wrapper allows you to read, write, and perform vector similarity search operations on S3 Vectors within your Postgres database.diff --git a/packages/ui-patterns/src/admonition.tsx b/packages/ui-patterns/src/admonition.tsxindex a04d8f99dc3..22cd48c6adc 100644--- a/packages/ui-patterns/src/admonition.tsx+++ b/packages/ui-patterns/src/admonition.tsx@@ -103,6 +103,7 @@ export const Admonition = forwardRef<children,layout = 'vertical',actions,+ childProps = {},...props},ref@@ -135,28 +136,25 @@ export const Admonition = forwardRef<{label || title ? (<div><AlertTitle_Shadcn_- {...props.childProps?.title}+ {...childProps.title}className={cn('text mt-0.5 flex gap-3 text-sm [&_p]:mb-1.5 [&_p]:mt-0',!label && 'flex-col',- props.childProps?.title?.className+ childProps.title?.className)}>{label || title}</AlertTitle_Shadcn_>{description && (- <AlertDescription_Shadcn_ className={props.childProps?.description?.className}>+ <AlertDescription_Shadcn_ className={childProps.description?.className}>{description}</AlertDescription_Shadcn_>)}{/* // children is to handle Docs and MDX issues with children and <p> elements */}{children && (<AlertDescription_Shadcn_- {...props.childProps?.description}- className={cn(- '[&_p]:mb-1.5 [&_p]:mt-0',- props.childProps?.description?.className- )}+ {...childProps.description}+ className={cn('[&_p]:mb-1.5 [&_p]:mt-0', childProps?.description?.className)}>{children}</AlertDescription_Shadcn_>