Skip to content

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

feat: Vector buckets - initial work (#39597)

Ivan Vasilov47e1134a1d16
diff --git a/.cursor/rules/studio-ui.mdc b/.cursor/rules/studio-ui.mdc
index 67db62a0ba1..c6f48881525 100644
--- a/.cursor/rules/studio-ui.mdc
+++ b/.cursor/rules/studio-ui.mdc
@@ -128,6 +128,7 @@ export const MyPageComponent = () => (
- Use our `_Shadcn_` form primitives from `ui` and prefer `FormItemLayout` with layout="flex-row-reverse" for most controls (see `apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx`).
- Keep imports from `ui` with `_Shadcn_` suffixes.
- Forms should generally be wrapped in a Card unless specified
+- If the submit button is outside the form, add a new variable named formId outside the component, and set it as property id on the form element and formId on the button.
### Example (single field)
@@ -143,6 +144,8 @@ const profileSchema = z.object({
username: z.string().min(2, 'Username must be at least 2 characters'),
})
+const formId = `profile-form`
+
export function ProfileForm() {
const form = useForm<z.infer<typeof profileSchema>>({
resolver: zodResolver(profileSchema),
@@ -200,6 +203,11 @@ export function ProfileForm() {
- Use a sheet when needing to reveal more complicated forms or information relating to an object and context switching away to a new page would be disruptive e.g. we list auth providers, clicking an auth provider opens a sheet with information about that provider and a form to enable, user can close sheet to go back to providers list
+## React Query
+
+- When doing a mutation, always use the mutate function. Always use onSuccess and onError with a toast.success and toast.error.
+- Use mutateAsync only if the mutation is part of multiple async actions. Wrap the mutateAsync call with try/catch block and add toast.success and toast.error.
+
## Tables
- Use the generic ui table components for most tables
diff --git a/apps/studio/components/interfaces/Database/Triggers/TriggerSheet.tsx b/apps/studio/components/interfaces/Database/Triggers/TriggerSheet.tsx
index 6cc885670ae..384391b597d 100644
--- a/apps/studio/components/interfaces/Database/Triggers/TriggerSheet.tsx
+++ b/apps/studio/components/interfaces/Database/Triggers/TriggerSheet.tsx
@@ -412,7 +412,7 @@ export const TriggerSheet = ({
<FormItemLayout layout="vertical" className="px-5">
<FormControl_Shadcn_>
<div className="flex flex-col gap-y-2">
- <p className="text-smn">Function to trigger</p>
+ <p className="text-sm">Function to trigger</p>
{function_name.length === 0 ? (
<button
type="button"
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/AnalyticsBucketDetails.utils.ts b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/AnalyticsBucketDetails.utils.ts
similarity index 100%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/AnalyticsBucketDetails.utils.ts
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/AnalyticsBucketDetails.utils.ts
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/ConnectTablesDialog.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/ConnectTablesDialog.tsx
similarity index 93%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/ConnectTablesDialog.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/ConnectTablesDialog.tsx
index 430558b4127..536f577160a 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/ConnectTablesDialog.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/ConnectTablesDialog.tsx
@@ -1,4 +1,5 @@
import { zodResolver } from '@hookform/resolvers/zod'
+import { snakeCase } from 'lodash'
import { Plus } from 'lucide-react'
import { useState } from 'react'
import { SubmitHandler, useForm } from 'react-hook-form'
@@ -6,6 +7,8 @@ import { toast } from 'sonner'
import z from 'zod'
import { useParams } from 'common'
+import { convertKVStringArrayToJson } from 'components/interfaces/Integrations/Wrappers/Wrappers.utils'
+import { getCatalogURI } from 'components/interfaces/Storage/StorageSettings/StorageSettings.utils'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import { getKeys, useAPIKeysQuery } from 'data/api-keys/api-keys-query'
import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
@@ -13,12 +16,10 @@ import { useCreateDestinationPipelineMutation } from 'data/replication/create-de
import { useCreatePublicationMutation } from 'data/replication/create-publication-mutation'
import { useReplicationSourcesQuery } from 'data/replication/sources-query'
import { useStartPipelineMutation } from 'data/replication/start-pipeline-mutation'
-import { AnalyticsBucket } from 'data/storage/analytics-buckets-query'
import { useIcebergNamespaceCreateMutation } from 'data/storage/iceberg-namespace-create-mutation'
import { useTablesQuery } from 'data/tables/tables-query'
import { getDecryptedValues } from 'data/vault/vault-secret-decrypted-value-query'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
-import { snakeCase } from 'lodash'
import {
Button,
Dialog,
@@ -35,8 +36,6 @@ import {
} from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { MultiSelector } from 'ui-patterns/multi-select'
-import { convertKVStringArrayToJson } from '../../Integrations/Wrappers/Wrappers.utils'
-import { getCatalogURI } from '../StorageSettings/StorageSettings.utils'
import { getAnalyticsBucketPublicationName } from './AnalyticsBucketDetails.utils'
import { useAnalyticsBucketWrapperInstance } from './useAnalyticsBucketWrapperInstance'
@@ -62,7 +61,7 @@ const isEnabled = false // Kill switch if we wanna hold off supporting connectin
type ConnectTablesForm = z.infer<typeof FormSchema>
-export const ConnectTablesDialog = ({ bucket }: { bucket: AnalyticsBucket }) => {
+export const ConnectTablesDialog = ({ bucketId }: { bucketId?: string }) => {
const form = useForm<ConnectTablesForm>({
resolver: zodResolver(FormSchema),
defaultValues: { tables: [] },
@@ -72,7 +71,7 @@ export const ConnectTablesDialog = ({ bucket }: { bucket: AnalyticsBucket }) =>
const { ref: projectRef } = useParams()
const { data: project } = useSelectedProjectQuery()
- const { data: wrapperInstance } = useAnalyticsBucketWrapperInstance({ bucketId: bucket.id })
+ const { data: wrapperInstance } = useAnalyticsBucketWrapperInstance({ bucketId: bucketId })
const wrapperValues = convertKVStringArrayToJson(wrapperInstance?.server_options ?? [])
const { data: projectSettings } = useProjectSettingsV2Query({ projectRef })
@@ -106,14 +105,15 @@ export const ConnectTablesDialog = ({ bucket }: { bucket: AnalyticsBucket }) =>
const onSubmit: SubmitHandler<ConnectTablesForm> = async (values) => {
// [Joshen] Currently creates the destination for the analytics bucket here
// Which also involves creating a namespace + publication
- // Publication name is automatically generated as {bucket.id}_publication
- // Destination name is automatically generated as {bucket.id}_destination
+ // Publication name is automatically generated as {bucketId}_publication
+ // Destination name is automatically generated as {bucketId}_destination
if (!projectRef) return console.error('Project ref is required')
if (!sourceId) return toast.error('Source ID is required')
+ if (!bucketId) return toast.error('Bucket ID is required')
try {
- const publicationName = getAnalyticsBucketPublicationName(bucket.id)
+ const publicationName = getAnalyticsBucketPublicationName(bucketId)
await createPublication({
projectRef,
sourceId,
@@ -135,7 +135,7 @@ export const ConnectTablesDialog = ({ bucket }: { bucket: AnalyticsBucket }) =>
ids: keysToDecrypt,
})
- const warehouseName = bucket.id
+ const warehouseName = bucketId
const catalogToken = serviceKey?.api_key ?? ''
const s3AccessKeyId = decryptedValues[wrapperValues['vault_aws_access_key_id']]
const s3SecretAccessKey = decryptedValues[wrapperValues['vault_aws_secret_access_key']]
@@ -145,7 +145,7 @@ export const ConnectTablesDialog = ({ bucket }: { bucket: AnalyticsBucket }) =>
const endpoint =
projectSettings?.app_config?.storage_endpoint || projectSettings?.app_config?.endpoint
const catalogUri = getCatalogURI(project?.ref ?? '', protocol, endpoint)
- const namespace = `${bucket.id}_namespace`
+ const namespace = `${bucketId}_namespace`
await createNamespace({
catalogUri,
warehouse: warehouseName,
@@ -162,7 +162,7 @@ export const ConnectTablesDialog = ({ bucket }: { bucket: AnalyticsBucket }) =>
s3SecretAccessKey,
s3Region,
}
- const destinationName = `${snakeCase(bucket.id)}_destination`
+ const destinationName = `${snakeCase(bucketId)}_destination`
const { pipeline_id: pipelineId } = await createDestinationPipeline({
projectRef,
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/CopyEnvButton.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/CopyEnvButton.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/CopyEnvButton.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/CopyEnvButton.tsx
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/DecryptedReadOnlyInput.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/DecryptedReadOnlyInput.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/DecryptedReadOnlyInput.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/DecryptedReadOnlyInput.tsx
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/NamespaceRow.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceRow.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/NamespaceRow.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceRow.tsx
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/NamespaceWithTables.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceWithTables.tsx
similarity index 99%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/NamespaceWithTables.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceWithTables.tsx
index 2faad51fe88..7c85ce811bf 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/NamespaceWithTables.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceWithTables.tsx
@@ -31,7 +31,7 @@ import {
} from 'ui'
type NamespaceWithTablesProps = {
- bucketName: string
+ bucketName?: string
namespace: string
sourceType: 'replication' | 'direct'
schema: string
@@ -324,7 +324,7 @@ export const NamespaceWithTables = ({
</TableBody>
</Table>
<ImportForeignSchemaDialog
- bucketName={bucketName}
+ bucketName={bucketName ?? ''}
namespace={namespace}
circumstance="clash"
wrapperMeta={wrapperMeta}
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/SimpleConfigurationDetails.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/SimpleConfigurationDetails.tsx
similarity index 93%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/SimpleConfigurationDetails.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/SimpleConfigurationDetails.tsx
index eddf1305688..622121118c7 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/SimpleConfigurationDetails.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/SimpleConfigurationDetails.tsx
@@ -1,3 +1,7 @@
+import {
+ getCatalogURI,
+ getConnectionURL,
+} from 'components/interfaces/Storage/StorageSettings/StorageSettings.utils'
import {
ScaffoldHeader,
ScaffoldSection,
@@ -10,7 +14,6 @@ import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { DOCS_URL } from 'lib/constants'
import { Card } from 'ui'
-import { getCatalogURI, getConnectionURL } from '../StorageSettings/StorageSettings.utils'
import { DESCRIPTIONS } from './constants'
import { CopyEnvButton } from './CopyEnvButton'
import { DecryptedReadOnlyInput } from './DecryptedReadOnlyInput'
@@ -24,7 +27,7 @@ const wrapperMeta = {
],
}
-export const SimpleConfigurationDetails = ({ bucketName }: { bucketName: string }) => {
+export const SimpleConfigurationDetails = ({ bucketName }: { bucketName?: string }) => {
const { data: project } = useSelectedProjectQuery()
const { data: apiKeys } = useAPIKeysQuery({ projectRef: project?.ref })
@@ -37,7 +40,7 @@ export const SimpleConfigurationDetails = ({ bucketName }: { bucketName: string
const values: Record<string, string> = {
vault_token: serviceApiKey,
- warehouse: bucketName,
+ warehouse: bucketName ?? '',
's3.endpoint': getConnectionURL(project?.ref ?? '', protocol, endpoint),
catalog_uri: getCatalogURI(project?.ref ?? '', protocol, endpoint),
}
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/constants.ts b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/constants.ts
similarity index 100%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/constants.ts
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/constants.ts
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/index.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/index.tsx
similarity index 89%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/index.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/index.tsx
index de7b2a1d9c0..e993bf67e83 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/index.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/index.tsx
@@ -1,16 +1,17 @@
import { uniq } from 'lodash'
import { SquarePlus } from 'lucide-react'
import Link from 'next/link'
+import { useRouter } from 'next/router'
import { useMemo, useState } from 'react'
+import { useParams } from 'common'
import { INTEGRATIONS } from 'components/interfaces/Integrations/Landing/Integrations.constants'
import { WrapperMeta } from 'components/interfaces/Integrations/Wrappers/Wrappers.types'
import {
convertKVStringArrayToJson,
formatWrapperTables,
} from 'components/interfaces/Integrations/Wrappers/Wrappers.utils'
-import { BUCKET_TYPES } from 'components/interfaces/Storage/Storage.constants'
-import { PageLayout } from 'components/layouts/PageLayout/PageLayout'
+import { useSelectedBucket } from 'components/interfaces/Storage/StorageExplorer/useSelectedBucket'
import {
ScaffoldContainer,
ScaffoldHeader,
@@ -18,7 +19,7 @@ import {
ScaffoldSectionDescription,
ScaffoldSectionTitle,
} from 'components/layouts/Scaffold'
-import { DocsButton } from 'components/ui/DocsButton'
+import AlertError from 'components/ui/AlertError'
import { InlineLink } from 'components/ui/InlineLink'
import {
DatabaseExtension,
@@ -33,7 +34,7 @@ import { DOCS_URL } from 'lib/constants'
import { Button, Card, CardContent } from 'ui'
import { Admonition } from 'ui-patterns/admonition'
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
-import { DeleteBucketModal } from '../DeleteBucketModal'
+import { DeleteAnalyticsBucketModal } from '../DeleteAnalyticsBucketModal'
import { ConnectTablesDialog } from './ConnectTablesDialog'
import { DESCRIPTIONS, LABELS, OPTION_ORDER } from './constants'
import { CopyEnvButton } from './CopyEnvButton'
@@ -43,15 +44,24 @@ import { SimpleConfigurationDetails } from './SimpleConfigurationDetails'
import { useAnalyticsBucketWrapperInstance } from './useAnalyticsBucketWrapperInstance'
import { useIcebergWrapperExtension } from './useIcebergWrapper'
-export const AnalyticBucketDetails = ({ bucket }: { bucket: AnalyticsBucket }) => {
- const config = BUCKET_TYPES.analytics
- const [modal, setModal] = useState<'delete' | null>(null)
+export const AnalyticBucketDetails = () => {
+ const router = useRouter()
+ const { ref: projectRef } = useParams()
const { data: project } = useSelectedProjectQuery()
const { state: extensionState } = useIcebergWrapperExtension()
+ const {
+ bucket: _bucket,
+ error: bucketError,
+ isSuccess: isSuccessBucket,
+ isError: isErrorBucket,
+ } = useSelectedBucket()
+ const bucket = _bucket as undefined | AnalyticsBucket
+
+ const [modal, setModal] = useState<'delete' | null>(null)
/** The wrapper instance is the wrapper that is installed for this Analytics bucket. */
const { data: wrapperInstance, isLoading } = useAnalyticsBucketWrapperInstance({
- bucketId: bucket.id,
+ bucketId: bucket?.id,
})
const wrapperValues = convertKVStringArrayToJson(wrapperInstance?.server_options ?? [])
const integration = INTEGRATIONS.find((i) => i.id === 'iceberg_wrapper' && i.type === 'wrapper')
@@ -113,16 +123,13 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: AnalyticsBucket }) =
return (
<>
- <PageLayout
- title={bucket.id}
- breadcrumbs={[
- {
- label: 'Analytics',
- href: `/project/${project?.ref}/storage/analytics`,
- },
- ]}
- secondaryActions={config?.docsUrl ? [<DocsButton key="docs" href={config.docsUrl} />] : []}
- >
+ {isErrorBucket ? (
+ <ScaffoldContainer bottomPadding>
+ <ScaffoldSection isFullWidth>
+ <AlertError subject="Failed to fetch analytics buckets" error={bucketError} />
+ </ScaffoldSection>
+ </ScaffoldContainer>
+ ) : (
<ScaffoldContainer bottomPadding>
{state === 'loading' && (
<ScaffoldSection isFullWidth>
@@ -131,7 +138,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: AnalyticsBucket }) =
)}
{state === 'not-installed' && (
<ExtensionNotInstalled
- bucketName={bucket.id}
+ bucketName={bucket?.id}
projectRef={project?.ref!}
wrapperMeta={wrapperMeta}
wrappersExtension={wrappersExtension!}
@@ -139,7 +146,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: AnalyticsBucket }) =
)}
{state === 'needs-upgrade' && (
<ExtensionNeedsUpgrade
- bucketName={bucket.id}
+ bucketName={bucket?.id}
projectRef={project?.ref!}
wrapperMeta={wrapperMeta}
wrappersExtension={wrappersExtension!}
@@ -156,7 +163,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: AnalyticsBucket }) =
Analytics tables stored in this bucket
</ScaffoldSectionDescription>
</div>
- {namespaces.length > 0 && <ConnectTablesDialog bucket={bucket} />}
+ {namespaces.length > 0 && <ConnectTablesDialog bucketId={bucket?.id} />}
</ScaffoldHeader>
{isLoadingNamespaces || isLoading ? (
@@ -170,14 +177,14 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: AnalyticsBucket }) =
Stream data from tables for archival, backups, or analytical queries.
</p>
</div>
- <ConnectTablesDialog bucket={bucket} />
+ <ConnectTablesDialog bucketId={bucket?.id} />
</aside>
) : (
<div className="flex flex-col gap-y-10">
{namespaces.map(({ namespace, schema, tables }) => (
<NamespaceWithTables
key={namespace}
- bucketName={bucket.id}
+ bucketName={bucket?.id}
namespace={namespace}
sourceType="direct"
schema={schema}
@@ -232,7 +239,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: AnalyticsBucket }) =
</ScaffoldSection>
</>
)}
- {state === 'missing' && <WrapperMissing bucketName={bucket.id} />}
+ {state === 'missing' && <WrapperMissing bucketName={bucket?.id} />}
<ScaffoldSection isFullWidth className="flex flex-col gap-y-4">
<header>
@@ -249,9 +256,8 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: AnalyticsBucket }) =
</div>
<Button
type="danger"
- onClick={() => {
- setModal('delete')
- }}
+ disabled={!isSuccessBucket}
+ onClick={() => setModal('delete')}
>
Delete bucket
</Button>
@@ -259,12 +265,13 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: AnalyticsBucket }) =
</Card>
</ScaffoldSection>
</ScaffoldContainer>
- </PageLayout>
+ )}
- <DeleteBucketModal
+ <DeleteAnalyticsBucketModal
visible={modal === `delete`}
- bucket={bucket}
+ bucketId={bucket?.id}
onClose={() => setModal(null)}
+ onSuccess={() => router.push(`/project/${projectRef}/storage/analytics`)}
/>
</>
)
@@ -276,7 +283,7 @@ const ExtensionNotInstalled = ({
wrapperMeta,
wrappersExtension,
}: {
- bucketName: string
+ bucketName?: string
projectRef: string
wrapperMeta: WrapperMeta
wrappersExtension: DatabaseExtension
@@ -325,7 +332,7 @@ const ExtensionNeedsUpgrade = ({
wrapperMeta,
wrappersExtension,
}: {
- bucketName: string
+ bucketName?: string
projectRef: string
wrapperMeta: WrapperMeta
wrappersExtension: DatabaseExtension
@@ -368,11 +375,12 @@ const ExtensionNeedsUpgrade = ({
)
}
-const WrapperMissing = ({ bucketName }: { bucketName: string }) => {
+const WrapperMissing = ({ bucketName }: { bucketName?: string }) => {
const { mutateAsync: createIcebergWrapper, isLoading: isCreatingIcebergWrapper } =
useIcebergWrapperCreateMutation()
const onSetupWrapper = async () => {
+ if (!bucketName) return console.error('Bucket name is required')
await createIcebergWrapper({ bucketName })
}
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx
similarity index 97%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx
index 8aa21db79fb..539aa0a836f 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx
@@ -22,7 +22,7 @@ import { useAnalyticsBucketWrapperInstance } from './useAnalyticsBucketWrapperIn
* Used for cleaning up analytics bucket after deletion
*/
export const useAnalyticsBucketAssociatedEntities = (
- { projectRef, bucketId }: { projectRef?: string; bucketId: string },
+ { projectRef, bucketId }: { projectRef?: string; bucketId?: string },
options: { enabled: boolean } = { enabled: true }
) => {
const { can: canReadS3Credentials } = useAsyncCheckPermissions(
@@ -40,7 +40,7 @@ export const useAnalyticsBucketAssociatedEntities = (
{ enabled: canReadS3Credentials && options.enabled }
)
const s3AccessKey = (s3AccessKeys?.data ?? []).find(
- (x) => x.description === getAnalyticsBucketS3KeyName(bucketId)
+ (x) => x.description === getAnalyticsBucketS3KeyName(bucketId ?? '')
)
const { data: sourcesData } = useReplicationSourcesQuery(
@@ -54,7 +54,7 @@ export const useAnalyticsBucketAssociatedEntities = (
{ enabled: options.enabled }
)
const publication = publications.find(
- (p) => p.name === getAnalyticsBucketPublicationName(bucketId)
+ (p) => p.name === getAnalyticsBucketPublicationName(bucketId ?? '')
)
return { icebergWrapper, icebergWrapperMeta, s3AccessKey, publication }
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketWrapperInstance.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useAnalyticsBucketWrapperInstance.tsx
similarity index 90%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketWrapperInstance.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useAnalyticsBucketWrapperInstance.tsx
index 409b4b8a85d..b685e212e87 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketWrapperInstance.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useAnalyticsBucketWrapperInstance.tsx
@@ -10,17 +10,18 @@ import { useFDWsQuery } from 'data/fdw/fdws-query'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
export const useAnalyticsBucketWrapperInstance = (
- { bucketId }: { bucketId: string },
+ { bucketId }: { bucketId?: string },
options?: { enabled?: boolean }
) => {
const { data: project, isLoading: isLoadingProject } = useSelectedProjectQuery()
+ const defaultEnabled = options?.enabled ?? true
const { data, isLoading: isLoadingFDWs } = useFDWsQuery(
{
projectRef: project?.ref,
connectionString: project?.connectionString,
},
- options
+ { enabled: defaultEnabled && !!bucketId }
)
const icebergWrapper = useMemo(() => {
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useIcebergWrapper.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useIcebergWrapper.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useIcebergWrapper.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useIcebergWrapper.tsx
diff --git a/apps/studio/components/interfaces/Storage/CreateSpecializedBucketModal.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/CreateAnalyticsBucketModal.tsx
similarity index 71%
rename from apps/studio/components/interfaces/Storage/CreateSpecializedBucketModal.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/CreateAnalyticsBucketModal.tsx
index 7783ebe2a57..2e2afe50d13 100644
--- a/apps/studio/components/interfaces/Storage/CreateSpecializedBucketModal.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/CreateAnalyticsBucketModal.tsx
@@ -13,6 +13,7 @@ import { InlineLink } from 'components/ui/InlineLink'
import { useIsAnalyticsBucketsEnabled } from 'data/config/project-storage-config-query'
import { useDatabaseExtensionEnableMutation } from 'data/database-extensions/database-extension-enable-mutation'
import { useAnalyticsBucketCreateMutation } from 'data/storage/analytics-bucket-create-mutation'
+import { useAnalyticsBucketsQuery } from 'data/storage/analytics-buckets-query'
import { useIcebergWrapperCreateMutation } from 'data/storage/iceberg-wrapper-create-mutation'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
@@ -37,9 +38,9 @@ import {
} from 'ui'
import { Admonition } from 'ui-patterns'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+import { inverseValidBucketNameRegex, validBucketNameRegex } from '../CreateBucketModal.utils'
+import { BUCKET_TYPES } from '../Storage.constants'
import { useIcebergWrapperExtension } from './AnalyticsBucketDetails/useIcebergWrapper'
-import { inverseValidBucketNameRegex, validBucketNameRegex } from './CreateBucketModal.utils'
-import { BUCKET_TYPES } from './Storage.constants'
const FormSchema = z
.object({
@@ -70,12 +71,11 @@ const FormSchema = z
}
})
-const formId = 'create-specialized-storage-bucket-form'
+const formId = 'create-analytics-storage-bucket-form'
-export type CreateSpecializedBucketForm = z.infer<typeof FormSchema>
+export type CreateAnalyticsBucketForm = z.infer<typeof FormSchema>
-interface CreateSpecializedBucketModalProps {
- bucketType: 'analytics' | 'vectors'
+interface CreateAnalyticsBucketModalProps {
buttonSize?: 'tiny' | 'small'
buttonType?: 'default' | 'primary'
buttonClassName?: string
@@ -88,14 +88,13 @@ interface CreateSpecializedBucketModalProps {
}
}
-export const CreateSpecializedBucketModal = ({
- bucketType,
+export const CreateAnalyticsBucketModal = ({
buttonSize = 'tiny',
buttonType = 'default',
buttonClassName,
disabled = false,
tooltip,
-}: CreateSpecializedBucketModalProps) => {
+}: CreateAnalyticsBucketModalProps) => {
const router = useRouter()
const { ref } = useParams()
const { data: org } = useSelectedOrganizationQuery()
@@ -106,6 +105,7 @@ export const CreateSpecializedBucketModal = ({
const [visible, setVisible] = useState(false)
+ const { data: buckets = [] } = useAnalyticsBucketsQuery({ projectRef: ref })
const icebergCatalogEnabled = useIsAnalyticsBucketsEnabled({ projectRef: ref })
const wrappersExtenstionNeedsUpgrading = wrappersExtensionState === 'needs-upgrade'
@@ -126,49 +126,48 @@ export const CreateSpecializedBucketModal = ({
const config = BUCKET_TYPES['analytics']
const isCreating = isEnablingExtension || isCreatingIcebergWrapper || isCreatingAnalyticsBucket
- const form = useForm<CreateSpecializedBucketForm>({
+ const form = useForm<CreateAnalyticsBucketForm>({
resolver: zodResolver(FormSchema),
defaultValues: { name: '' },
})
- const onSubmit: SubmitHandler<CreateSpecializedBucketForm> = async (values) => {
+ const onSubmit: SubmitHandler<CreateAnalyticsBucketForm> = async (values) => {
if (!ref) return console.error('Project ref is required')
if (!project) return console.error('Project details is required')
if (!wrappersExtension) return console.error('Unable to find wrappers extension')
+ const hasExistingBucket = buckets.some((x) => x.id === values.name)
+ if (hasExistingBucket) return toast.error('Bucket name already exists')
+
try {
- if (bucketType === 'analytics') {
- await createAnalyticsBucket({
- projectRef: ref,
- bucketName: values.name,
- })
+ await createAnalyticsBucket({
+ projectRef: ref,
+ bucketName: values.name,
+ })
- if (wrappersExtensionState === 'not-installed') {
- await enableExtension({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- name: wrappersExtension.name,
- schema: wrappersExtension.schema ?? 'extensions',
- version: wrappersExtension.default_version,
- })
- await createIcebergWrapper({ bucketName: values.name })
- } else if (wrappersExtensionState === 'installed') {
- await createIcebergWrapper({ bucketName: values.name })
- }
- } else {
- // TODO for vectors bucket
+ if (wrappersExtensionState === 'not-installed') {
+ await enableExtension({
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ name: wrappersExtension.name,
+ schema: wrappersExtension.schema ?? 'extensions',
+ version: wrappersExtension.default_version,
+ })
+ await createIcebergWrapper({ bucketName: values.name })
+ } else if (wrappersExtensionState === 'installed') {
+ await createIcebergWrapper({ bucketName: values.name })
}
sendEvent({
action: 'storage_bucket_created',
- properties: { bucketType },
+ properties: { bucketType: 'analytics' },
groups: { project: ref ?? 'Unknown', organization: org?.slug ?? 'Unknown' },
})
toast.success(`Created bucket “${values.name}”`)
form.reset()
setVisible(false)
- router.push(`/project/${ref}/storage/${bucketType}/buckets/${values.name}`)
+ router.push(`/project/${ref}/storage/analytics/buckets/${values.name}`)
} catch (error: any) {
toast.error(`Failed to create bucket: ${error.message}`)
}
@@ -248,44 +247,36 @@ export const CreateSpecializedBucketModal = ({
)}
/>
- {bucketType === 'analytics' && (
- <>
- {wrappersExtenstionNeedsUpgrading ? (
- <Admonition
- type="warning"
- title="Wrappers extension must be updated for Iceberg Wrapper support"
- >
- <p className="prose max-w-full text-sm !leading-normal">
- Update the <code className="text-xs">wrappers</code> extension by disabling
- and enabling it in{' '}
- <InlineLink href={`/project/${ref}/database/extensions?filter=wrappers`}>
- database extensions
- </InlineLink>{' '}
- before creating an Analytics bucket.{' '}
- <InlineLink
- href={`${DOCS_URL}/guides/database/extensions/wrappers/iceberg`}
- >
- Learn more
- </InlineLink>
- .
- </p>
- </Admonition>
- ) : (
- <Admonition type="default">
- <p className="!leading-normal">
- Supabase will install the{' '}
- {wrappersExtensionState !== 'installed' ? 'Wrappers extension and ' : ''}
- Iceberg Wrapper integration on your behalf.{' '}
- <InlineLink
- href={`${DOCS_URL}/guides/database/extensions/wrappers/iceberg`}
- >
- Learn more
- </InlineLink>
- .
- </p>
- </Admonition>
- )}
- </>
+ {wrappersExtenstionNeedsUpgrading ? (
+ <Admonition
+ type="warning"
+ title="Wrappers extension must be updated for Iceberg Wrapper support"
+ >
+ <p className="prose max-w-full text-sm !leading-normal">
+ Update the <code className="text-xs">wrappers</code> extension by disabling and
+ enabling it in{' '}
+ <InlineLink href={`/project/${ref}/database/extensions?filter=wrappers`}>
+ database extensions
+ </InlineLink>{' '}
+ before creating an Analytics bucket.{' '}
+ <InlineLink href={`${DOCS_URL}/guides/database/extensions/wrappers/iceberg`}>
+ Learn more
+ </InlineLink>
+ .
+ </p>
+ </Admonition>
+ ) : (
+ <Admonition type="default">
+ <p className="!leading-normal">
+ Supabase will install the{' '}
+ {wrappersExtensionState !== 'installed' ? 'Wrappers extension and ' : ''}
+ Iceberg Wrapper integration on your behalf.{' '}
+ <InlineLink href={`${DOCS_URL}/guides/database/extensions/wrappers/iceberg`}>
+ Learn more
+ </InlineLink>
+ .
+ </p>
+ </Admonition>
)}
</DialogSection>
</form>
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/DeleteAnalyticsBucketModal.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/DeleteAnalyticsBucketModal.tsx
new file mode 100644
index 00000000000..0568c24ceb0
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/DeleteAnalyticsBucketModal.tsx
@@ -0,0 +1,164 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import { SubmitHandler, useForm } from 'react-hook-form'
+import { toast } from 'sonner'
+import z from 'zod'
+
+import { useParams } from 'common'
+import { useAnalyticsBucketDeleteMutation } from 'data/storage/analytics-bucket-delete-mutation'
+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import {
+ Button,
+ Dialog,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogSection,
+ DialogSectionSeparator,
+ DialogTitle,
+ Form_Shadcn_,
+ FormControl_Shadcn_,
+ FormField_Shadcn_,
+ Input_Shadcn_,
+} from 'ui'
+import { Admonition } from 'ui-patterns'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+import {
+ useAnalyticsBucketAssociatedEntities,
+ useAnalyticsBucketDeleteCleanUp,
+} from './AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities'
+
+export interface DeleteAnalyticsBucketModalProps {
+ visible: boolean
+ bucketId?: string
+ onClose: () => void
+ onSuccess?: () => void
+}
+
+const formId = `delete-analytics-bucket-form`
+
+// [Joshen] Can refactor to use TextConfirmModal
+
+export const DeleteAnalyticsBucketModal = ({
+ visible,
+ bucketId,
+ onClose,
+ onSuccess,
+}: DeleteAnalyticsBucketModalProps) => {
+ const { ref: projectRef } = useParams()
+ const { data: project } = useSelectedProjectQuery()
+
+ const schema = z.object({
+ confirm: z.literal(bucketId, {
+ errorMap: () => ({ message: `Please enter "${bucketId}" to confirm` }),
+ }),
+ })
+
+ const form = useForm<z.infer<typeof schema>>({
+ resolver: zodResolver(schema),
+ })
+
+ const { icebergWrapper, icebergWrapperMeta, s3AccessKey, publication } =
+ useAnalyticsBucketAssociatedEntities({ projectRef, bucketId: bucketId })
+
+ const { mutateAsync: deleteAnalyticsBucketCleanUp, isLoading: isCleaningUpAnalyticsBucket } =
+ useAnalyticsBucketDeleteCleanUp()
+
+ const { mutate: deleteAnalyticsBucket, isLoading: isDeletingAnalyticsBucket } =
+ useAnalyticsBucketDeleteMutation({
+ onSuccess: async () => {
+ if (project?.connectionString) {
+ await deleteAnalyticsBucketCleanUp({
+ projectRef,
+ connectionString: project.connectionString,
+ bucketId: bucketId,
+ icebergWrapper,
+ icebergWrapperMeta,
+ s3AccessKey,
+ publication,
+ })
+ }
+ toast.success(`Successfully deleted analytics bucket ${bucketId}`)
+ onClose()
+ onSuccess?.()
+ },
+ })
+
+ const onSubmit: SubmitHandler<z.infer<typeof schema>> = async () => {
+ if (!projectRef) return console.error('Project ref is required')
+ if (!bucketId) return console.error('No bucket is selected')
+ deleteAnalyticsBucket({ projectRef, id: bucketId })
+ }
+
+ const isDeleting = isDeletingAnalyticsBucket || isCleaningUpAnalyticsBucket
+
+ return (
+ <Dialog
+ open={visible}
+ onOpenChange={(open) => {
+ if (!open) onClose()
+ }}
+ >
+ <DialogContent aria-describedby={undefined}>
+ <DialogHeader>
+ <DialogTitle>Confirm deletion of {bucketId}</DialogTitle>
+ </DialogHeader>
+
+ <DialogSectionSeparator />
+
+ <Admonition
+ type="destructive"
+ className="rounded-none border-x-0 border-t-0 mb-0"
+ title="You cannot recover this bucket once deleted."
+ description="All bucket data will be lost."
+ />
+
+ <DialogSection>
+ <p className="text-sm">
+ Your bucket <span className="font-bold text-foreground">{bucketId}</span> and all its
+ contents will be permanently deleted.
+ </p>
+ </DialogSection>
+ <DialogSectionSeparator />
+ <DialogSection>
+ <Form_Shadcn_ {...form}>
+ <form id={formId} onSubmit={form.handleSubmit(onSubmit)}>
+ <FormField_Shadcn_
+ key="confirm"
+ name="confirm"
+ control={form.control}
+ render={({ field }) => (
+ <FormItemLayout
+ name="confirm"
+ label={
+ <>
+ Type <span className="font-bold text-foreground">{bucketId}</span> to
+ confirm.
+ </>
+ }
+ >
+ <FormControl_Shadcn_>
+ <Input_Shadcn_
+ id="confirm"
+ autoComplete="off"
+ {...field}
+ placeholder="Type bucket name"
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </form>
+ </Form_Shadcn_>
+ </DialogSection>
+ <DialogFooter>
+ <Button type="default" disabled={isDeleting} onClick={onClose}>
+ Cancel
+ </Button>
+ <Button form={formId} htmlType="submit" type="danger" loading={isDeleting}>
+ Delete bucket
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBuckets.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/index.tsx
similarity index 93%
rename from apps/studio/components/interfaces/Storage/AnalyticsBuckets.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBuckets/index.tsx
index b95c0daba94..f02ae2c05e4 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBuckets.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/index.tsx
@@ -22,9 +22,9 @@ import {
} from 'ui'
import { Admonition, TimestampInfo } from 'ui-patterns'
import { Input } from 'ui-patterns/DataInputs/Input'
-import { CreateSpecializedBucketModal } from './CreateSpecializedBucketModal'
-import { DeleteBucketModal } from './DeleteBucketModal'
-import { EmptyBucketState } from './EmptyBucketState'
+import { EmptyBucketState } from '../EmptyBucketState'
+import { CreateAnalyticsBucketModal } from './CreateAnalyticsBucketModal'
+import { DeleteAnalyticsBucketModal } from './DeleteAnalyticsBucketModal'
export const AnalyticsBuckets = () => {
const { ref } = useParams()
@@ -84,11 +84,7 @@ export const AnalyticsBuckets = () => {
onChange={(e) => setFilterString(e.target.value)}
icon={<Search size={12} />}
/>
- <CreateSpecializedBucketModal
- buttonType="primary"
- buttonClassName="w-fit"
- bucketType="analytics"
- />
+ <CreateAnalyticsBucketModal buttonType="primary" buttonClassName="w-fit" />
</div>
{isLoadingBuckets ? (
@@ -167,9 +163,9 @@ export const AnalyticsBuckets = () => {
)}
{selectedBucket && (
- <DeleteBucketModal
+ <DeleteAnalyticsBucketModal
visible={modal === 'delete'}
- bucket={selectedBucket}
+ bucketId={selectedBucket.id}
onClose={() => setModal(null)}
/>
)}
diff --git a/apps/studio/components/interfaces/Storage/DeleteBucketModal.tsx b/apps/studio/components/interfaces/Storage/DeleteBucketModal.tsx
index d4a723180b7..c75c54bc234 100644
--- a/apps/studio/components/interfaces/Storage/DeleteBucketModal.tsx
+++ b/apps/studio/components/interfaces/Storage/DeleteBucketModal.tsx
@@ -8,7 +8,6 @@ import z from 'zod'
import { useParams } from 'common'
import { useDatabasePoliciesQuery } from 'data/database-policies/database-policies-query'
import { useDatabasePolicyDeleteMutation } from 'data/database-policies/database-policy-delete-mutation'
-import { useAnalyticsBucketDeleteMutation } from 'data/storage/analytics-bucket-delete-mutation'
import { AnalyticsBucket } from 'data/storage/analytics-buckets-query'
import { useBucketDeleteMutation } from 'data/storage/bucket-delete-mutation'
import { Bucket, useBucketsQuery } from 'data/storage/buckets-query'
@@ -29,10 +28,6 @@ import {
} from 'ui'
import { Admonition } from 'ui-patterns'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
-import {
- useAnalyticsBucketAssociatedEntities,
- useAnalyticsBucketDeleteCleanUp,
-} from './AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities'
import { formatPoliciesForStorage } from './Storage.utils'
export interface DeleteBucketModalProps {
@@ -48,8 +43,6 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
const { ref: projectRef, bucketId } = useParams()
const { data: project } = useSelectedProjectQuery()
- const isStandardBucketSelected = 'type' in bucket && bucket.type === 'STANDARD'
-
const schema = z.object({
confirm: z.literal(bucket.id, {
errorMap: () => ({ message: `Please enter "${bucket.id}" to confirm` }),
@@ -69,12 +62,6 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
schema: 'storage',
})
- const { icebergWrapper, icebergWrapperMeta, s3AccessKey, publication } =
- useAnalyticsBucketAssociatedEntities(
- { projectRef, bucketId: bucket.id },
- { enabled: !isStandardBucketSelected }
- )
-
const { mutateAsync: deletePolicy } = useDatabasePolicyDeleteMutation()
const { mutate: deleteBucket, isLoading: isDeletingBucket } = useBucketDeleteMutation({
@@ -115,43 +102,12 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
},
})
- const { mutateAsync: deleteAnalyticsBucketCleanUp, isLoading: isCleaningUpAnalyticsBucket } =
- useAnalyticsBucketDeleteCleanUp()
-
- const { mutate: deleteAnalyticsBucket, isLoading: isDeletingAnalyticsBucket } =
- useAnalyticsBucketDeleteMutation({
- onSuccess: async () => {
- if (project?.connectionString) {
- await deleteAnalyticsBucketCleanUp({
- projectRef,
- connectionString: project.connectionString,
- bucketId: bucket.id,
- icebergWrapper,
- icebergWrapperMeta,
- s3AccessKey,
- publication,
- })
- }
- toast.success(`Successfully deleted analytics bucket ${bucket.id}`)
- if (!!bucketId) router.push(`/project/${projectRef}/storage/analytics`)
- onClose()
- },
- })
-
const onSubmit: SubmitHandler<z.infer<typeof schema>> = async () => {
if (!projectRef) return console.error('Project ref is required')
if (!bucket) return console.error('No bucket is selected')
-
- // [Joshen] We'll need a third case to figure out for vector buckets
- if (isStandardBucketSelected) {
- deleteBucket({ projectRef, id: bucket.id })
- } else {
- deleteAnalyticsBucket({ projectRef, id: bucket.id })
- }
+ deleteBucket({ projectRef, id: bucket.id })
}
- const isDeleting = isDeletingBucket || isDeletingAnalyticsBucket || isCleaningUpAnalyticsBucket
-
return (
<Dialog
open={visible}
@@ -212,10 +168,10 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
</Form_Shadcn_>
</DialogSection>
<DialogFooter>
- <Button type="default" disabled={isDeleting} onClick={onClose}>
+ <Button type="default" disabled={isDeletingBucket} onClick={onClose}>
Cancel
</Button>
- <Button form={formId} htmlType="submit" type="danger" loading={isDeleting}>
+ <Button form={formId} htmlType="submit" type="danger" loading={isDeletingBucket}>
Delete bucket
</Button>
</DialogFooter>
diff --git a/apps/studio/components/interfaces/Storage/EmptyBucketState.tsx b/apps/studio/components/interfaces/Storage/EmptyBucketState.tsx
index 56ca9f17592..8a917dae18e 100644
--- a/apps/studio/components/interfaces/Storage/EmptyBucketState.tsx
+++ b/apps/studio/components/interfaces/Storage/EmptyBucketState.tsx
@@ -1,8 +1,9 @@
import { BucketAdd } from 'icons'
import { cn } from 'ui'
+import { CreateAnalyticsBucketModal } from './AnalyticsBuckets/CreateAnalyticsBucketModal'
import { CreateBucketModal } from './CreateBucketModal'
-import { CreateSpecializedBucketModal } from './CreateSpecializedBucketModal'
import { BUCKET_TYPES } from './Storage.constants'
+import { CreateVectorBucketDialog } from './VectorBuckets/CreateVectorBucketDialog'
interface EmptyBucketStateProps {
bucketType: keyof typeof BUCKET_TYPES
@@ -28,27 +29,17 @@ export const EmptyBucketState = ({ bucketType, className }: EmptyBucketStateProp
<p className="text-foreground-light text-sm">{config.valueProp}</p>
</div>
- {bucketType === 'files' ? (
+ {bucketType === 'files' && (
<CreateBucketModal buttonSize="tiny" buttonType="primary" buttonClassName="w-fit" />
- ) : (
- <CreateSpecializedBucketModal
- bucketType={bucketType}
+ )}
+ {bucketType === 'analytics' && (
+ <CreateAnalyticsBucketModal
buttonSize="tiny"
buttonType="primary"
buttonClassName="w-fit"
- disabled={bucketType === 'vectors'}
- tooltip={
- bucketType === 'vectors'
- ? {
- content: {
- side: 'bottom',
- text: 'Vector buckets are not supported yet',
- },
- }
- : undefined
- }
/>
)}
+ {bucketType === 'vectors' && <CreateVectorBucketDialog />}
</aside>
)
}
diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/useSelectedBucket.ts b/apps/studio/components/interfaces/Storage/StorageExplorer/useSelectedBucket.ts
index aae911f33b4..b44317600dd 100644
--- a/apps/studio/components/interfaces/Storage/StorageExplorer/useSelectedBucket.ts
+++ b/apps/studio/components/interfaces/Storage/StorageExplorer/useSelectedBucket.ts
@@ -34,9 +34,7 @@ export const useSelectedBucket = () => {
? buckets.find((b) => b.id === bucketId)
: page === 'analytics'
? analyticsBuckets.find((b: any) => b.id === bucketId)
- : // [Joshen] Remove typecasts bucket: any once infra changes for analytics bucket is in
- // [Joshen] Temp fallback to buckets for backwards compatibility old UI
- buckets.find((b) => b.id === bucketId)
+ : buckets.find((b) => b.id === bucketId)
return { bucket, isSuccess, isError, error }
}
diff --git a/apps/studio/components/interfaces/Storage/StorageMenuV2.tsx b/apps/studio/components/interfaces/Storage/StorageMenuV2.tsx
index 8a08b41ad70..3bd7d775962 100644
--- a/apps/studio/components/interfaces/Storage/StorageMenuV2.tsx
+++ b/apps/studio/components/interfaces/Storage/StorageMenuV2.tsx
@@ -1,7 +1,10 @@
import Link from 'next/link'
import { IS_PLATFORM, useParams } from 'common'
-import { useIsAnalyticsBucketsEnabled } from 'data/config/project-storage-config-query'
+import {
+ useIsAnalyticsBucketsEnabled,
+ useIsVectorBucketsEnabled,
+} from 'data/config/project-storage-config-query'
import { Badge, Menu } from 'ui'
import { BUCKET_TYPES, BUCKET_TYPE_KEYS } from './Storage.constants'
import { useStorageV2Page } from './Storage.utils'
@@ -11,6 +14,7 @@ export const StorageMenuV2 = () => {
const page = useStorageV2Page()
const isAnalyticsBucketsEnabled = useIsAnalyticsBucketsEnabled({ projectRef: ref })
+ const isVectorBucketsEnabled = useIsVectorBucketsEnabled({ projectRef: ref })
return (
<Menu type="pills" className="my-6 flex flex-grow flex-col">
@@ -21,15 +25,16 @@ export const StorageMenuV2 = () => {
{BUCKET_TYPE_KEYS.map((bucketTypeKey) => {
const isSelected = page === bucketTypeKey
const config = BUCKET_TYPES[bucketTypeKey]
+ const isAlphaEnabled =
+ (bucketTypeKey === 'analytics' && isAnalyticsBucketsEnabled) ||
+ (bucketTypeKey === 'vectors' && isVectorBucketsEnabled)
return (
<Link key={bucketTypeKey} href={`/project/${ref}/storage/${bucketTypeKey}`}>
<Menu.Item rounded active={isSelected}>
<div className="flex items-center justify-between">
<p className="truncate">{config.displayName}</p>
- {bucketTypeKey === 'analytics' && isAnalyticsBucketsEnabled && (
- <Badge variant="warning">ALPHA</Badge>
- )}
+ {isAlphaEnabled && <Badge variant="warning">ALPHA</Badge>}
</div>
</Menu.Item>
</Link>
diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorBucketDialog.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorBucketDialog.tsx
new file mode 100644
index 00000000000..354ae2596f3
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorBucketDialog.tsx
@@ -0,0 +1,178 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import { PermissionAction } from '@supabase/shared-types/out/constants'
+import { Plus } from 'lucide-react'
+import { useEffect, useState } from 'react'
+import { SubmitHandler, useForm } from 'react-hook-form'
+import { toast } from 'sonner'
+import z from 'zod'
+
+import { useParams } from 'common'
+import { ButtonTooltip } from 'components/ui/ButtonTooltip'
+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 {
+ Button,
+ Dialog,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogSection,
+ DialogSectionSeparator,
+ DialogTitle,
+ DialogTrigger,
+ Form_Shadcn_,
+ FormControl_Shadcn_,
+ FormField_Shadcn_,
+ Input_Shadcn_,
+} from 'ui'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+import { inverseValidBucketNameRegex, validBucketNameRegex } from '../CreateBucketModal.utils'
+
+const FormSchema = z.object({
+ name: z
+ .string()
+ .trim()
+ .min(1, 'Please provide a name for your bucket')
+ .max(100, 'Bucket name should be below 100 characters')
+ .superRefine((name, ctx) => {
+ if (!validBucketNameRegex.test(name)) {
+ const [match] = name.match(inverseValidBucketNameRegex) ?? []
+ ctx.addIssue({
+ path: [],
+ code: z.ZodIssueCode.custom,
+ message: !!match
+ ? `Bucket name cannot contain the "${match}" character`
+ : 'Bucket name contains an invalid special character',
+ })
+ }
+ }),
+})
+
+const formId = 'create-storage-bucket-form'
+
+export type CreateBucketForm = z.infer<typeof FormSchema>
+
+export const CreateVectorBucketDialog = () => {
+ const { ref } = useParams()
+ const { data: org } = useSelectedOrganizationQuery()
+
+ const [visible, setVisible] = useState(false)
+ const { can: canCreateBuckets } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')
+
+ const { data } = useVectorBucketsQuery({ projectRef: ref })
+
+ const form = useForm<CreateBucketForm>({
+ resolver: zodResolver(FormSchema),
+ defaultValues: { name: '' },
+ })
+
+ 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 onSubmit: SubmitHandler<CreateBucketForm> = async (values) => {
+ if (!ref) return console.error('Project ref is required')
+
+ const hasExistingBucket = (data?.vectorBuckets ?? []).some(
+ (x) => x.vectorBucketName === values.name
+ )
+ if (hasExistingBucket) return toast.error('Bucket name already exists')
+
+ createVectorBucket({ projectRef: ref, bucketName: values.name })
+ }
+
+ useEffect(() => {
+ if (!visible) form.reset()
+ }, [visible])
+
+ return (
+ <Dialog open={visible} onOpenChange={setVisible}>
+ <DialogTrigger asChild>
+ <ButtonTooltip
+ block
+ size="tiny"
+ type="primary"
+ className="w-fit"
+ icon={<Plus size={14} />}
+ disabled={!canCreateBuckets}
+ onClick={() => setVisible(true)}
+ tooltip={{
+ content: {
+ side: 'bottom',
+ text: !canCreateBuckets
+ ? 'You need additional permissions to create buckets'
+ : undefined,
+ },
+ }}
+ >
+ New bucket
+ </ButtonTooltip>
+ </DialogTrigger>
+
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Create vector bucket</DialogTitle>
+ </DialogHeader>
+
+ <DialogSectionSeparator />
+
+ <Form_Shadcn_ {...form}>
+ <form id={formId} onSubmit={form.handleSubmit(onSubmit)}>
+ <DialogSection className="flex flex-col gap-y-4">
+ <FormField_Shadcn_
+ key="name"
+ name="name"
+ control={form.control}
+ render={({ field }) => (
+ <FormItemLayout
+ name="name"
+ label="Bucket name"
+ labelOptional="Cannot be changed after creation"
+ description="A target schema will be created that matches this name."
+ >
+ <FormControl_Shadcn_>
+ <Input_Shadcn_
+ id="name"
+ data-1p-ignore
+ data-lpignore="true"
+ data-form-type="other"
+ data-bwignore
+ {...field}
+ placeholder="Enter bucket name"
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </DialogSection>
+ </form>
+ </Form_Shadcn_>
+
+ <DialogFooter>
+ <Button type="default" disabled={isCreating} onClick={() => setVisible(false)}>
+ Cancel
+ </Button>
+ <Button form={formId} htmlType="submit" loading={isCreating} disabled={isCreating}>
+ Create
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsx
new file mode 100644
index 00000000000..6b512720d42
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/CreateVectorTableSheet.tsx
@@ -0,0 +1,399 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import { PermissionAction } from '@supabase/shared-types/out/constants'
+import { Lock, Plus, Trash2 } from 'lucide-react'
+import { useEffect, useState } from 'react'
+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 { useVectorBucketIndexCreateMutation } from 'data/storage/vector-bucket-index-create-mutation'
+import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import {
+ Button,
+ Form_Shadcn_,
+ FormControl_Shadcn_,
+ FormField_Shadcn_,
+ FormItem_Shadcn_,
+ FormMessage_Shadcn_,
+ Input_Shadcn_,
+ RadioGroupStacked,
+ RadioGroupStackedItem,
+ Separator,
+ Sheet,
+ SheetContent,
+ SheetFooter,
+ SheetHeader,
+ SheetSection,
+ SheetTitle,
+ SheetTrigger,
+} from 'ui'
+import { Admonition } from 'ui-patterns'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+import { inverseValidBucketNameRegex } from '../CreateBucketModal.utils'
+
+const isStagingLocal = process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod'
+
+const BUCKET_INDEX_NAME_REGEX = /^[a-z0-9](?:[a-z0-9.-]{1,61})?[a-z0-9]$/
+
+const DISTANCE_METRICS = [
+ {
+ value: 'cosine',
+ label: 'Cosine',
+ description: 'Measures similarity between two vectors, based on directions, not magnitude.',
+ },
+ {
+ value: 'euclidean',
+ label: 'Euclidean',
+ description:
+ 'Measures straight-line distance between two vectors, using both directions and magnitudes.',
+ },
+] as const
+
+const FormSchema = z.object({
+ name: z
+ .string()
+ .trim()
+ .min(3, 'Name must be at least 3 characters')
+ .max(63, 'Name must be below 63 characters')
+ .refine(
+ (value) => value !== 'public',
+ '"public" is a reserved name. Please choose another name'
+ )
+ .superRefine((name, ctx) => {
+ if (!BUCKET_INDEX_NAME_REGEX.test(name)) {
+ const [match] = name.match(inverseValidBucketNameRegex) ?? []
+ ctx.addIssue({
+ path: [],
+ code: z.ZodIssueCode.custom,
+ message: !!match
+ ? `Bucket name cannot contain the "${match}" character`
+ : 'Bucket name contains an invalid special character',
+ })
+ }
+ }),
+ targetSchema: z.string().default(''),
+ dimension: z
+ .number()
+ .int('Dimension must be an integer')
+ .min(1, 'Dimension must be at least 1')
+ .max(4096, 'Dimension must be at most 4096'),
+ distanceMetric: z.enum(['cosine', 'euclidean'], {
+ required_error: 'Please select a distance metric',
+ }),
+ metadataKeys: z
+ .array(
+ z.object({
+ value: z.string().min(1, 'The metadata key needs to be at least 1 character long'),
+ })
+ )
+ .default([]),
+})
+
+const formId = 'create-vector-table-form'
+
+export type CreateVectorTableForm = z.infer<typeof FormSchema>
+
+interface CreateVectorTableSheetProps {
+ bucketName?: string
+}
+
+export const CreateVectorTableSheet = ({ bucketName }: CreateVectorTableSheetProps) => {
+ const { ref } = useParams()
+ const { data: project } = useSelectedProjectQuery()
+
+ const [visible, setVisible] = useState(false)
+ const { can: canCreateBuckets } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')
+
+ // [Joshen] Can remove this once this restriction is removed
+ const showIndexCreationNotice = isStagingLocal && !!project && project?.region !== 'us-east-1'
+
+ const defaultValues = {
+ name: '',
+ targetSchema: bucketName,
+ dimension: undefined,
+ distanceMetric: 'cosine' as 'cosine' | 'euclidean',
+ metadataKeys: [],
+ }
+ const form = useForm<CreateVectorTableForm>({
+ resolver: zodResolver(FormSchema),
+ defaultValues,
+ values: defaultValues as any,
+ })
+
+ const { fields, append, remove } = useFieldArray({
+ control: form.control,
+ name: 'metadataKeys',
+ })
+
+ const { mutate: createVectorBucketTable, isLoading: isCreating } =
+ useVectorBucketIndexCreateMutation({
+ onSuccess: (values) => {
+ toast.success(`Successfully created vector table ${values.name}`)
+ form.reset()
+
+ setVisible(false)
+ },
+ onError: (error) => {
+ // For other errors, show a toast as fallback
+ toast.error(`Failed to create vector table: ${error.message}`)
+ },
+ })
+
+ const onSubmit: SubmitHandler<CreateVectorTableForm> = async (values) => {
+ if (!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),
+ })
+ }
+
+ useEffect(() => {
+ if (!visible) {
+ form.reset()
+ }
+ }, [visible])
+
+ return (
+ <Sheet open={visible} onOpenChange={setVisible}>
+ <SheetTrigger asChild>
+ <ButtonTooltip
+ block
+ size="tiny"
+ type="primary"
+ className="w-fit"
+ icon={<Plus size={14} />}
+ disabled={!canCreateBuckets}
+ onClick={() => setVisible(true)}
+ tooltip={{
+ content: {
+ side: 'bottom',
+ text: !canCreateBuckets
+ ? 'You need additional permissions to create buckets'
+ : undefined,
+ },
+ }}
+ >
+ Create table
+ </ButtonTooltip>
+ </SheetTrigger>
+
+ <SheetContent size="lg" className="flex flex-col gap-0 p-0">
+ <SheetHeader>
+ <SheetTitle>Create vector table</SheetTitle>
+ </SheetHeader>
+
+ {showIndexCreationNotice && (
+ <Admonition
+ type="warning"
+ className="mb-0 border-x-0 border-t-0 rounded-none"
+ title="Vector table creation is currently only supported for projects in us-east-1"
+ description={`This is only applicable to projects on local/staging (Project is currently in ${project.region})`}
+ />
+ )}
+
+ <Form_Shadcn_ {...form}>
+ <form
+ id={formId}
+ onSubmit={form.handleSubmit(onSubmit)}
+ className="overflow-auto flex-grow px-0"
+ >
+ <SheetSection className="flex flex-col gap-y-4">
+ <FormField_Shadcn_
+ key="name"
+ name="name"
+ control={form.control}
+ render={({ field }) => (
+ <FormItemLayout
+ name="name"
+ label="Name"
+ description="Must be between 3–63 characters. Valid characters are a-z, 0-9, hyphens, and periods."
+ layout="horizontal"
+ >
+ <FormControl_Shadcn_>
+ <Input_Shadcn_
+ id="name"
+ data-1p-ignore
+ data-lpignore="true"
+ data-form-type="other"
+ data-bwignore
+ {...field}
+ placeholder="Enter a table name"
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+
+ <FormField_Shadcn_
+ key="targetSchema"
+ name="targetSchema"
+ control={form.control}
+ render={({ field }) => (
+ <FormItemLayout
+ name="targetSchema"
+ label="Target schema"
+ description="The bucket name will be used as the target schema."
+ layout="horizontal"
+ >
+ <FormControl_Shadcn_>
+ <div className="relative">
+ <Input_Shadcn_
+ id="targetSchema"
+ {...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>
+ </div>
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </SheetSection>
+ <Separator />
+ <SheetSection className="flex flex-col gap-y-4">
+ <FormField_Shadcn_
+ key="dimension"
+ name="dimension"
+ control={form.control}
+ render={({ field }) => (
+ <FormItemLayout
+ name="dimension"
+ label="Dimension"
+ description="Must be an integer between 1 and 4096."
+ layout="horizontal"
+ >
+ <FormControl_Shadcn_>
+ <Input_Shadcn_
+ id="dimension"
+ type="number"
+ placeholder="Enter a numeric value"
+ {...field}
+ onChange={(e) => {
+ const value = e.target.value
+ field.onChange(value === '' ? undefined : Number(value))
+ }}
+ value={field.value ?? ''}
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+
+ <FormField_Shadcn_
+ key="distanceMetric"
+ name="distanceMetric"
+ control={form.control}
+ render={({ field }) => (
+ <FormItemLayout
+ name="distanceMetric"
+ label="Distance metric"
+ layout="horizontal"
+ className="gap-1"
+ >
+ <FormControl_Shadcn_>
+ <RadioGroupStacked
+ id="distance_metric"
+ name="distance_metric"
+ value={field.value}
+ disabled={field.disabled}
+ onValueChange={field.onChange}
+ >
+ {DISTANCE_METRICS.map((metric) => (
+ <RadioGroupStackedItem
+ key={metric.value}
+ id={metric.value}
+ value={metric.value}
+ label=""
+ showIndicator={false}
+ >
+ <div className="flex flex-col gap-y-1">
+ <p className="text-foreground text-left">{metric.label}</p>
+ <p className="text-foreground-lighter text-left">
+ {metric.description}
+ </p>
+ </div>
+ </RadioGroupStackedItem>
+ ))}
+ </RadioGroupStacked>
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </SheetSection>
+ <Separator />
+ <SheetSection className="space-y-4">
+ <div className="flex items-center justify-between">
+ <label className="text-sm text-foreground">Metadata keys</label>
+ <DocsButton href="https://supabase.com/docs/guides/storage/vector" />
+ </div>
+
+ <div className="space-y-2">
+ {fields.map((field, index) => (
+ <div key={field.id} className="flex items-start gap-2">
+ <FormField_Shadcn_
+ control={form.control}
+ name={`metadataKeys.${index}.value`}
+ render={({ field }) => (
+ <FormItem_Shadcn_ className="flex-1">
+ <FormControl_Shadcn_>
+ <Input_Shadcn_
+ {...field}
+ value={field.value}
+ size="small"
+ className="w-full"
+ placeholder="Header value"
+ data-1p-ignore
+ data-lpignore="true"
+ data-form-type="other"
+ data-bwignore
+ />
+ </FormControl_Shadcn_>
+ <FormMessage_Shadcn_ />
+ </FormItem_Shadcn_>
+ )}
+ />
+ <Button
+ type="outline"
+ className="px-2"
+ size="small"
+ icon={<Trash2 className="w-2 h-2" size={12} />}
+ onClick={() => remove(index)}
+ />
+ </div>
+ ))}
+ </div>
+ <div className="flex items-center justify-center rounded border border-strong border-dashed py-3">
+ <Button type="default" size="tiny" onClick={() => append({ value: '' })}>
+ Add metadata key
+ </Button>
+ </div>
+ </SheetSection>
+ </form>
+ </Form_Shadcn_>
+
+ <SheetFooter>
+ <Button type="default" disabled={isCreating} onClick={() => setVisible(false)}>
+ Cancel
+ </Button>
+ <Button form={formId} htmlType="submit" loading={isCreating} disabled={isCreating}>
+ Create
+ </Button>
+ </SheetFooter>
+ </SheetContent>
+ </Sheet>
+ )
+}
diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorBucketModal.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorBucketModal.tsx
new file mode 100644
index 00000000000..9d66974412c
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorBucketModal.tsx
@@ -0,0 +1,161 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import { SubmitHandler, useForm } from 'react-hook-form'
+import { toast } from 'sonner'
+import z from 'zod'
+
+import { useParams } from 'common'
+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 {
+ Button,
+ Dialog,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogSection,
+ DialogSectionSeparator,
+ DialogTitle,
+ Form_Shadcn_,
+ FormControl_Shadcn_,
+ FormField_Shadcn_,
+ Input_Shadcn_,
+} from 'ui'
+import { Admonition } from 'ui-patterns/admonition'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+
+export interface DeleteVectorBucketModalProps {
+ visible: boolean
+ bucketName?: string
+ onCancel: () => void
+ onSuccess: () => void
+}
+
+const formId = `delete-storage-vector-bucket-form`
+
+// [Joshen] Can refactor to use TextConfirmModal
+
+export const DeleteVectorBucketModal = ({
+ visible,
+ bucketName,
+ onCancel,
+ onSuccess,
+}: DeleteVectorBucketModalProps) => {
+ const { ref: projectRef } = useParams()
+
+ const schema = z.object({
+ confirm: z.literal(bucketName, {
+ errorMap: () => ({ message: `Please enter "${bucketName}" to confirm` }),
+ }),
+ })
+
+ const form = useForm<z.infer<typeof schema>>({
+ resolver: zodResolver(schema),
+ })
+
+ const { mutate: deleteBucket, isLoading } = useVectorBucketDeleteMutation({
+ onSuccess: async () => {
+ toast.success(`Bucket "${bucketName}" deleted successfully`)
+ onSuccess()
+ },
+ })
+
+ const { data: { indexes = [] } = {} } = useVectorBucketsIndexesQuery({
+ projectRef,
+ vectorBucketName: bucketName,
+ })
+
+ const onSubmit: SubmitHandler<z.infer<typeof schema>> = async () => {
+ if (!projectRef) return console.error('Project ref is required')
+ if (!bucketName) return console.error('No bucket is selected')
+
+ try {
+ // delete all indexes from the bucket first
+ const promises = indexes.map((index) =>
+ deleteVectorBucketIndex({
+ projectRef,
+ bucketName: bucketName,
+ indexName: index.indexName,
+ })
+ )
+ await Promise.all(promises)
+
+ deleteBucket({ projectRef, bucketName })
+ } catch (error) {
+ toast.error(
+ `Failed to delete bucket: ${error instanceof Error ? error.message : 'Unknown error'}`
+ )
+ }
+ }
+
+ return (
+ <Dialog
+ open={visible}
+ onOpenChange={(open) => {
+ if (!open) onCancel()
+ }}
+ >
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Confirm deletion of {bucketName}</DialogTitle>
+ </DialogHeader>
+
+ <DialogSectionSeparator />
+
+ <Admonition
+ type="destructive"
+ className="rounded-none border-x-0 border-t-0 mb-0"
+ title="You cannot recover this bucket once deleted."
+ description="All bucket data will be lost."
+ />
+
+ <DialogSection>
+ <p className="text-sm">
+ Your bucket <span className="font-bold text-foreground">{bucketName}</span> and all its
+ contents will be permanently deleted.
+ </p>
+ </DialogSection>
+ <DialogSectionSeparator />
+ <DialogSection>
+ <Form_Shadcn_ {...form}>
+ <form id={formId} onSubmit={form.handleSubmit(onSubmit)}>
+ <FormField_Shadcn_
+ key="confirm"
+ name="confirm"
+ control={form.control}
+ render={({ field }) => (
+ <FormItemLayout
+ name="confirm"
+ label={
+ <>
+ Type <span className="font-bold text-foreground">{bucketName}</span> to
+ confirm.
+ </>
+ }
+ >
+ <FormControl_Shadcn_>
+ <Input_Shadcn_
+ id="confirm"
+ autoComplete="off"
+ {...field}
+ placeholder="Type bucket name"
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </form>
+ </Form_Shadcn_>
+ </DialogSection>
+ <DialogFooter>
+ <Button type="default" disabled={isLoading} onClick={onCancel}>
+ Cancel
+ </Button>
+ <Button form={formId} htmlType="submit" type="danger" loading={isLoading}>
+ Delete bucket
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorTableModal.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorTableModal.tsx
new file mode 100644
index 00000000000..f9251980718
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/DeleteVectorTableModal.tsx
@@ -0,0 +1,52 @@
+import { toast } from 'sonner'
+
+import { useParams } from 'common'
+import { useVectorBucketIndexDeleteMutation } from 'data/storage/vector-bucket-index-delete-mutation'
+import { VectorBucketIndex } from 'data/storage/vector-buckets-indexes-query'
+import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
+
+interface DeleteVectorTableModalProps {
+ visible: boolean
+ table?: VectorBucketIndex
+ onClose: () => void
+}
+
+export const DeleteVectorTableModal = ({
+ visible,
+ table,
+ onClose,
+}: DeleteVectorTableModalProps) => {
+ const { ref: projectRef } = useParams()
+
+ const { mutate: deleteIndex, isLoading: isDeleting } = useVectorBucketIndexDeleteMutation({
+ onSuccess: (_, vars) => {
+ toast.success(`Table "${vars.indexName}" deleted successfully`)
+ onClose()
+ },
+ })
+
+ const onConfirmDelete = () => {
+ if (!projectRef) return console.error('Project ref is required')
+ if (!table) return console.error('Vector table is required')
+
+ deleteIndex({
+ projectRef,
+ bucketName: table.vectorBucketName,
+ indexName: table.indexName,
+ })
+ }
+
+ return (
+ <ConfirmationModal
+ visible={visible}
+ loading={isDeleting}
+ variant="destructive"
+ title={`Confirm to delete table "${table?.indexName}"`}
+ onConfirm={onConfirmDelete}
+ onCancel={onClose}
+ >
+ {/* [Joshen] Can probably beef up more details here - what are potential side effects of deleting a table */}
+ <p className="text-sm">This action cannot be undone.</p>
+ </ConfirmationModal>
+ )
+}
diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails.tsx
new file mode 100644
index 00000000000..527819a055c
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketDetails.tsx
@@ -0,0 +1,249 @@
+import { Eye, MoreVertical, Search, Trash2 } from 'lucide-react'
+import Link from 'next/link'
+import { useRouter } from 'next/router'
+import { useState } from 'react'
+
+import { useParams } from 'common'
+import {
+ ScaffoldContainer,
+ ScaffoldHeader,
+ ScaffoldSection,
+ ScaffoldSectionDescription,
+ ScaffoldSectionTitle,
+} from 'components/layouts/Scaffold'
+import AlertError from 'components/ui/AlertError'
+import { useVectorBucketQuery } from 'data/storage/vector-bucket-query'
+import {
+ useVectorBucketsIndexesQuery,
+ VectorBucketIndex,
+} from 'data/storage/vector-buckets-indexes-query'
+import {
+ Button,
+ Card,
+ CardContent,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from 'ui'
+import { Input } from 'ui-patterns/DataInputs/Input'
+import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
+import { CreateVectorTableSheet } from './CreateVectorTableSheet'
+import { DeleteVectorBucketModal } from './DeleteVectorBucketModal'
+import { DeleteVectorTableModal } from './DeleteVectorTableModal'
+
+export const VectorBucketDetails = () => {
+ const router = useRouter()
+ const { ref: projectRef, bucketId } = useParams()
+
+ const [filterString, setFilterString] = useState('')
+ const [showDeleteModal, setShowDeleteModal] = useState(false)
+ const [selectedTableToDelete, setSelectedTableToDelete] = useState<VectorBucketIndex>()
+
+ const {
+ data: bucket,
+ error: bucketError,
+ isSuccess: isSuccessBucket,
+ isError: isErrorBucket,
+ } = useVectorBucketQuery({ projectRef, vectorBucketName: bucketId })
+
+ const { data, isLoading: isLoadingIndexes } = useVectorBucketsIndexesQuery({
+ projectRef,
+ vectorBucketName: bucket?.vectorBucketName,
+ })
+ const allIndexes = data?.indexes ?? []
+
+ const filteredList =
+ filterString.length === 0
+ ? allIndexes
+ : allIndexes.filter((index) =>
+ index.indexName.toLowerCase().includes(filterString.toLowerCase())
+ )
+
+ return (
+ <>
+ {isErrorBucket ? (
+ <ScaffoldContainer bottomPadding>
+ <ScaffoldSection isFullWidth>
+ <AlertError subject="Failed to fetch vector buckets" error={bucketError} />
+ </ScaffoldSection>
+ </ScaffoldContainer>
+ ) : (
+ <ScaffoldContainer bottomPadding>
+ <ScaffoldSection isFullWidth className="gap-y-4">
+ <ScaffoldHeader className="pt-0 pb-3">
+ <ScaffoldSectionTitle>Tables</ScaffoldSectionTitle>
+ <ScaffoldSectionDescription>
+ Vector tables stored in this bucket.
+ </ScaffoldSectionDescription>
+ </ScaffoldHeader>
+ <div className="flex flex-row justify-between">
+ <Input
+ size="tiny"
+ placeholder="Search for a table"
+ value={filterString}
+ onChange={(e) => setFilterString(e.target.value)}
+ icon={<Search size={12} />}
+ className="w-48"
+ />
+ <CreateVectorTableSheet bucketName={bucket?.vectorBucketName} />
+ </div>
+
+ {isLoadingIndexes ? (
+ <GenericSkeletonLoader />
+ ) : (
+ <Card>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead
+ className={filteredList.length === 0 ? 'text-foreground-muted' : undefined}
+ >
+ Name
+ </TableHead>
+ <TableHead
+ className={filteredList.length === 0 ? 'text-foreground-muted' : undefined}
+ >
+ Dimension
+ </TableHead>
+ <TableHead
+ className={filteredList.length === 0 ? 'text-foreground-muted' : undefined}
+ >
+ Distance metric
+ </TableHead>
+ <TableHead />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {filteredList.length === 0 ? (
+ <TableRow className="[&>td]:hover:bg-inherit">
+ <TableCell colSpan={3}>
+ {filterString.length > 0 ? (
+ <>
+ <p className="text-sm text-foreground">No results found</p>
+ <p className="text-sm text-foreground-lighter">
+ Your search for "{filterString}" did not return any results
+ </p>
+ </>
+ ) : (
+ <>
+ <p className="text-sm text-foreground">No tables yet</p>
+ <p className="text-sm text-foreground-lighter">
+ Create your first table to get started
+ </p>
+ </>
+ )}
+ </TableCell>
+ </TableRow>
+ ) : (
+ filteredList.map((index, idx: number) => {
+ const id = `index-${idx}`
+ const name = index.indexName
+
+ return (
+ <TableRow key={id}>
+ <TableCell>{name}</TableCell>
+ <TableCell>
+ <p className="text-foreground-lighter">{index.dimension}</p>
+ </TableCell>
+ <TableCell>
+ <p className="text-foreground-lighter">{index.distanceMetric}</p>
+ </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}`}
+ >
+ Table Editor
+ </Link>
+ </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="default"
+ className="px-1"
+ icon={<MoreVertical />}
+ onClick={(e) => e.stopPropagation()}
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent side="bottom" align="end" className="w-40">
+ <DropdownMenuItem
+ className="flex items-center space-x-2"
+ onClick={(e) => {
+ e.stopPropagation()
+ setSelectedTableToDelete(index)
+ }}
+ >
+ <Trash2 size={12} />
+ <p>Delete table</p>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </TableCell>
+ </TableRow>
+ )
+ })
+ )}
+ </TableBody>
+ </Table>
+ </Card>
+ )}
+ </ScaffoldSection>
+
+ <ScaffoldSection isFullWidth className="flex flex-col gap-y-4">
+ <header>
+ <ScaffoldSectionTitle>Manage</ScaffoldSectionTitle>
+ </header>
+ <Card>
+ <CardContent className="flex flex-col md:flex-row md:justify-between gap-y-4 gap-x-8 md:items-center">
+ <div className="flex flex-col">
+ <h3>Delete bucket</h3>
+ <p className="text-sm text-foreground-lighter">
+ This will also delete any data in your bucket. Make sure you have a backup if
+ you want to keep your data.
+ </p>
+ </div>
+ <Button
+ type="danger"
+ disabled={!isSuccessBucket}
+ onClick={() => setShowDeleteModal(true)}
+ >
+ Delete bucket
+ </Button>
+ </CardContent>
+ </Card>
+ </ScaffoldSection>
+ </ScaffoldContainer>
+ )}
+
+ <DeleteVectorTableModal
+ visible={!!selectedTableToDelete}
+ table={selectedTableToDelete}
+ onClose={() => setSelectedTableToDelete(undefined)}
+ />
+
+ <DeleteVectorBucketModal
+ visible={showDeleteModal}
+ bucketName={bucket?.vectorBucketName}
+ onCancel={() => setShowDeleteModal(false)}
+ onSuccess={() => {
+ setShowDeleteModal(false)
+ router.push(`/project/${projectRef}/storage/vectors`)
+ }}
+ />
+ </>
+ )
+}
diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/index.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/index.tsx
new file mode 100644
index 00000000000..16cc1e006a2
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/index.tsx
@@ -0,0 +1,184 @@
+import { ExternalLink, MoreVertical, Search, Trash2 } from 'lucide-react'
+import Link from 'next/link'
+import { useState } from 'react'
+
+import { useParams } from 'common'
+import { ScaffoldHeader, ScaffoldSection, ScaffoldSectionTitle } from 'components/layouts/Scaffold'
+import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
+import { useVectorBucketsQuery } from 'data/storage/vector-buckets-query'
+import {
+ Button,
+ Card,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from 'ui'
+import { Admonition } from 'ui-patterns'
+import { Input } from 'ui-patterns/DataInputs/Input'
+import { TimestampInfo } from 'ui-patterns/TimestampInfo'
+import { EmptyBucketState } from '../EmptyBucketState'
+import { CreateVectorBucketDialog } from './CreateVectorBucketDialog'
+import { DeleteVectorBucketModal } from './DeleteVectorBucketModal'
+
+/**
+ * [Joshen] Low-priority refactor: We should use a virtualized table here as per how we do it
+ * for the files buckets for consistency. Not pressing, just an optimization area.
+ */
+
+export const VectorsBuckets = () => {
+ const { ref: projectRef } = useParams()
+
+ const [filterString, setFilterString] = useState('')
+ const [bucketForDeletion, setBucketForDeletion] = useState<{
+ vectorBucketName: string
+ creationTime: string
+ } | null>(null)
+
+ const { data, isLoading: isLoadingBuckets } = useVectorBucketsQuery({ projectRef })
+ const bucketsList = data?.vectorBuckets ?? []
+
+ const filteredBuckets =
+ filterString.length === 0
+ ? bucketsList
+ : bucketsList.filter((bucket) =>
+ bucket.vectorBucketName.toLowerCase().includes(filterString.toLowerCase())
+ )
+
+ return (
+ <ScaffoldSection isFullWidth>
+ <Admonition
+ type="warning"
+ layout="horizontal"
+ className="mb-12 [&>div]:!translate-y-0 [&>svg]:!translate-y-1"
+ title="Vector buckets are in alpha"
+ actions={
+ <Button asChild type="default" icon={<ExternalLink />}>
+ <a
+ target="_blank"
+ rel="noopener noreferrer"
+ // [Joshen] To update with Vector specific GH discussion
+ href="https://github.com/orgs/supabase/discussions/40116"
+ >
+ Leave feedback
+ </a>
+ </Button>
+ }
+ >
+ <p className="!leading-normal !mb-0">
+ Expect rapid changes, limited features, and possible breaking updates as we expand access.
+ </p>
+ <p className="!leading-normal !mb-0">Please share feedback as we refine the experience!</p>
+ </Admonition>
+
+ {!isLoadingBuckets && bucketsList.length === 0 ? (
+ <EmptyBucketState bucketType="vectors" />
+ ) : (
+ <div className="flex flex-col gap-y-4">
+ <ScaffoldHeader className="py-0">
+ <ScaffoldSectionTitle>Buckets</ScaffoldSectionTitle>
+ </ScaffoldHeader>
+ <div className="flex flex-grow justify-between gap-x-2 items-center">
+ <Input
+ size="tiny"
+ className="flex-grow lg:flex-grow-0 w-52"
+ placeholder="Search for a bucket"
+ value={filterString}
+ onChange={(e) => setFilterString(e.target.value)}
+ icon={<Search size={12} />}
+ />
+ <CreateVectorBucketDialog />
+ </div>
+
+ {isLoadingBuckets ? (
+ <GenericSkeletonLoader />
+ ) : (
+ <Card>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Name</TableHead>
+ <TableHead>Created at</TableHead>
+ <TableHead />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {filteredBuckets.length === 0 && filterString.length > 0 && (
+ <TableRow>
+ <TableCell colSpan={3}>
+ <p className="text-sm text-foreground">No results found</p>
+ <p className="text-sm text-foreground-lighter">
+ Your search for "{filterString}" did not return any results
+ </p>
+ </TableCell>
+ </TableRow>
+ )}
+ {filteredBuckets.map((bucket, idx: number) => {
+ const id = `bucket-${idx}`
+ const name = bucket.vectorBucketName
+ // the creation time is in seconds, convert it to milliseconds
+ const created = +bucket.creationTime * 1000
+
+ return (
+ <TableRow key={id}>
+ <TableCell>{name}</TableCell>
+ <TableCell>
+ <p className="text-foreground-light">
+ <TimestampInfo
+ utcTimestamp={created}
+ className="text-sm text-foreground-light"
+ />
+ </p>
+ </TableCell>
+ <TableCell>
+ <div className="flex justify-end gap-2">
+ <Button asChild type="default">
+ <Link
+ href={`/project/${projectRef}/storage/vectors/buckets/${encodeURIComponent(name)}`}
+ >
+ View contents
+ </Link>
+ </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button type="default" className="px-1" icon={<MoreVertical />} />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent side="bottom" align="end" className="w-40">
+ <DropdownMenuItem
+ className="flex items-center space-x-2"
+ onClick={() => {
+ setBucketForDeletion(bucket)
+ }}
+ >
+ <Trash2 size={12} />
+ <p>Delete bucket</p>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </TableCell>
+ </TableRow>
+ )
+ })}
+ </TableBody>
+ </Table>
+ </Card>
+ )}
+ </div>
+ )}
+
+ <DeleteVectorBucketModal
+ visible={!!bucketForDeletion}
+ bucketName={bucketForDeletion?.vectorBucketName!}
+ onCancel={() => setBucketForDeletion(null)}
+ onSuccess={() => setBucketForDeletion(null)}
+ />
+ </ScaffoldSection>
+ )
+}
diff --git a/apps/studio/components/interfaces/Storage/VectorsBuckets.tsx b/apps/studio/components/interfaces/Storage/VectorsBuckets.tsx
deleted file mode 100644
index 87e2dbbab12..00000000000
--- a/apps/studio/components/interfaces/Storage/VectorsBuckets.tsx
+++ /dev/null
@@ -1,6 +0,0 @@
-import { EmptyBucketState } from './EmptyBucketState'
-
-export const VectorsBuckets = () => {
- // Placeholder component - will be implemented in a later PR
- return <EmptyBucketState bucketType="vectors" />
-}
diff --git a/apps/studio/data/config/project-storage-config-query.ts b/apps/studio/data/config/project-storage-config-query.ts
index aab5b975dc9..ab1bc6350a2 100644
--- a/apps/studio/data/config/project-storage-config-query.ts
+++ b/apps/studio/data/config/project-storage-config-query.ts
@@ -1,5 +1,6 @@
import { useQuery } from '@tanstack/react-query'
+import { useFlag } from 'common'
import { components } from 'data/api'
import { get, handleError } from 'data/fetchers'
import { IS_PLATFORM } from 'lib/constants'
@@ -56,3 +57,9 @@ export const useIsAnalyticsBucketsEnabled = ({ projectRef }: { projectRef?: stri
const { data } = useProjectStorageConfigQuery({ projectRef })
return !!data?.features.icebergCatalog?.enabled
}
+
+export const useIsVectorBucketsEnabled = ({ projectRef }: { projectRef?: string }) => {
+ // [Joshen] Temp using feature flag - will need to shift to storage config like analytics bucket once ready
+ const isVectorBucketsEnabled = useFlag('storageAnalyticsVector')
+ return isVectorBucketsEnabled
+}
diff --git a/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts b/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts
index 0b2c08edf97..d8703c18241 100644
--- a/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts
+++ b/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts
@@ -4,7 +4,7 @@ import { WRAPPERS } from 'components/interfaces/Integrations/Wrappers/Wrappers.c
import {
getAnalyticsBucketFDWName,
getAnalyticsBucketS3KeyName,
-} from 'components/interfaces/Storage/AnalyticsBucketDetails/AnalyticsBucketDetails.utils'
+} from 'components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/AnalyticsBucketDetails.utils'
import {
getCatalogURI,
getConnectionURL,
diff --git a/apps/studio/data/storage/keys.ts b/apps/studio/data/storage/keys.ts
index 5d796b07b0d..2ff2c226d0e 100644
--- a/apps/studio/data/storage/keys.ts
+++ b/apps/studio/data/storage/keys.ts
@@ -2,6 +2,12 @@ export const storageKeys = {
buckets: (projectRef: string | undefined) => ['projects', projectRef, 'buckets'] as const,
analyticsBuckets: (projectRef: string | undefined) =>
['projects', projectRef, 'analytics-buckets'] as const,
+ vectorBuckets: (projectRef: string | undefined) =>
+ ['projects', projectRef, 'vector-buckets'] as const,
+ vectorBucket: (projectRef: string | undefined, vectorbucketName: string | undefined) =>
+ ['projects', projectRef, 'vector-bucket', vectorbucketName] as const,
+ vectorBucketsIndexes: (projectRef: string | undefined, vectorBucketName: string | undefined) =>
+ ['projects', projectRef, 'vector-buckets', vectorBucketName, 'indexes'] as const,
archive: (projectRef: string | undefined) => ['projects', projectRef, 'archive'] as const,
icebergNamespaces: (catalog: string, warehouse: string) =>
['catalog', catalog, 'warehouse', warehouse, 'namespaces'] as const,
diff --git a/apps/studio/data/storage/vector-bucket-create-mutation.ts b/apps/studio/data/storage/vector-bucket-create-mutation.ts
new file mode 100644
index 00000000000..749b2a906e1
--- /dev/null
+++ b/apps/studio/data/storage/vector-bucket-create-mutation.ts
@@ -0,0 +1,56 @@
+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
+import { toast } from 'sonner'
+
+import { handleError, post } from 'data/fetchers'
+import type { ResponseError } from 'types'
+import { storageKeys } from './keys'
+
+type VectorBucketCreateVariables = {
+ projectRef: string
+ bucketName: string
+}
+
+async function createVectorBucket({ projectRef, bucketName }: VectorBucketCreateVariables) {
+ if (!projectRef) throw new Error('projectRef is required')
+ if (!bucketName) throw new Error('Bucket name is required')
+
+ const { data, error } = await post('/platform/storage/{ref}/vector-buckets', {
+ params: { path: { ref: projectRef } },
+ body: { bucketName: bucketName },
+ })
+
+ if (error) handleError(error)
+
+ // [Joshen] JFYI typed incorrectly in API, to fix
+ return data as { name: string }
+}
+
+type VectorBucketCreateData = Awaited<ReturnType<typeof createVectorBucket>>
+
+export const useVectorBucketCreateMutation = ({
+ onSuccess,
+ onError,
+ ...options
+}: Omit<
+ UseMutationOptions<VectorBucketCreateData, ResponseError, VectorBucketCreateVariables>,
+ 'mutationFn'
+> = {}) => {
+ const queryClient = useQueryClient()
+
+ return useMutation<VectorBucketCreateData, ResponseError, VectorBucketCreateVariables>({
+ mutationFn: (vars) => createVectorBucket(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(storageKeys.vectorBuckets(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to create vector bucket: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
+}
diff --git a/apps/studio/data/storage/vector-bucket-delete-mutation.ts b/apps/studio/data/storage/vector-bucket-delete-mutation.ts
new file mode 100644
index 00000000000..2627fb9dd75
--- /dev/null
+++ b/apps/studio/data/storage/vector-bucket-delete-mutation.ts
@@ -0,0 +1,55 @@
+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
+import { toast } from 'sonner'
+
+import { del, handleError } from 'data/fetchers'
+import type { ResponseError } from 'types'
+import { storageKeys } from './keys'
+
+type VectorBucketDeleteVariables = {
+ projectRef: string
+ bucketName: string
+}
+
+async function deleteVectorBucket({ projectRef, bucketName }: VectorBucketDeleteVariables) {
+ if (!projectRef) throw new Error('projectRef is required')
+ if (!bucketName) throw new Error('Bucket name is required')
+
+ const { data, error } = await del('/platform/storage/{ref}/vector-buckets/{id}', {
+ params: { path: { ref: projectRef, id: bucketName } },
+ })
+
+ if (error) handleError(error)
+
+ // [Joshen] JFYI typed incorrectly in API, to fix
+ return data as { name: string }
+}
+
+type VectorBucketDeleteData = Awaited<ReturnType<typeof deleteVectorBucket>>
+
+export const useVectorBucketDeleteMutation = ({
+ onSuccess,
+ onError,
+ ...options
+}: Omit<
+ UseMutationOptions<VectorBucketDeleteData, ResponseError, VectorBucketDeleteVariables>,
+ 'mutationFn'
+> = {}) => {
+ const queryClient = useQueryClient()
+
+ return useMutation<VectorBucketDeleteData, ResponseError, VectorBucketDeleteVariables>({
+ mutationFn: (vars) => deleteVectorBucket(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(storageKeys.vectorBuckets(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to delete vector bucket: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
+}
diff --git a/apps/studio/data/storage/vector-bucket-index-create-mutation.ts b/apps/studio/data/storage/vector-bucket-index-create-mutation.ts
new file mode 100644
index 00000000000..ed78cbb21fb
--- /dev/null
+++ b/apps/studio/data/storage/vector-bucket-index-create-mutation.ts
@@ -0,0 +1,67 @@
+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
+import { toast } from 'sonner'
+
+import type { components } from 'api-types'
+import { handleError, post } from 'data/fetchers'
+import type { ResponseError } from 'types'
+import { storageKeys } from './keys'
+
+type VectorBucketIndexCreateVariables = components['schemas']['CreateBucketIndexBody'] & {
+ projectRef: string
+ bucketName: string
+}
+
+async function createVectorBucketIndex({
+ projectRef,
+ bucketName,
+ ...rest
+}: VectorBucketIndexCreateVariables) {
+ if (!projectRef) throw new Error('projectRef is required')
+ if (!bucketName) throw new Error('Bucket name is required')
+
+ const { data, error } = await post('/platform/storage/{ref}/vector-buckets/{id}/indexes', {
+ params: { path: { ref: projectRef, id: bucketName } },
+ body: {
+ dataType: 'float32',
+ dimension: rest.dimension,
+ distanceMetric: rest.distanceMetric,
+ indexName: rest.indexName,
+ metadataKeys: rest.metadataKeys,
+ },
+ })
+
+ if (error) handleError(error)
+
+ // [Joshen] JFYI typed incorrectly in API, to fix
+ return data as { name: string }
+}
+
+type VectorBucketIndexCreateData = Awaited<ReturnType<typeof createVectorBucketIndex>>
+
+export const useVectorBucketIndexCreateMutation = ({
+ onSuccess,
+ onError,
+ ...options
+}: Omit<
+ UseMutationOptions<VectorBucketIndexCreateData, ResponseError, VectorBucketIndexCreateVariables>,
+ 'mutationFn'
+> = {}) => {
+ const queryClient = useQueryClient()
+
+ return useMutation<VectorBucketIndexCreateData, ResponseError, VectorBucketIndexCreateVariables>({
+ mutationFn: (vars) => createVectorBucketIndex(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef, bucketName } = variables
+ await queryClient.invalidateQueries(storageKeys.vectorBucketsIndexes(projectRef, bucketName))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to create vector bucket index: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
+}
diff --git a/apps/studio/data/storage/vector-bucket-index-delete-mutation.ts b/apps/studio/data/storage/vector-bucket-index-delete-mutation.ts
new file mode 100644
index 00000000000..1f3f8514f51
--- /dev/null
+++ b/apps/studio/data/storage/vector-bucket-index-delete-mutation.ts
@@ -0,0 +1,64 @@
+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
+import { toast } from 'sonner'
+
+import { del, handleError } from 'data/fetchers'
+import type { ResponseError } from 'types'
+import { storageKeys } from './keys'
+
+type VectorBucketIndexDeleteVariables = {
+ projectRef: string
+ bucketName: string
+ indexName: string
+}
+
+export async function deleteVectorBucketIndex({
+ projectRef,
+ bucketName,
+ indexName,
+}: VectorBucketIndexDeleteVariables) {
+ if (!projectRef) throw new Error('projectRef is required')
+ if (!bucketName) throw new Error('Bucket name is required')
+ if (!indexName) throw new Error('Index name is required')
+
+ const { data, error } = await del(
+ '/platform/storage/{ref}/vector-buckets/{id}/indexes/{indexName}',
+ {
+ params: { path: { ref: projectRef, id: bucketName, indexName } },
+ }
+ )
+
+ if (error) handleError(error)
+
+ // [Joshen] JFYI typed incorrectly in API, to fix
+ return data as { name: string }
+}
+
+type VectorBucketIndexDeleteData = Awaited<ReturnType<typeof deleteVectorBucketIndex>>
+
+export const useVectorBucketIndexDeleteMutation = ({
+ onSuccess,
+ onError,
+ ...options
+}: Omit<
+ UseMutationOptions<VectorBucketIndexDeleteData, ResponseError, VectorBucketIndexDeleteVariables>,
+ 'mutationFn'
+> = {}) => {
+ const queryClient = useQueryClient()
+
+ return useMutation<VectorBucketIndexDeleteData, ResponseError, VectorBucketIndexDeleteVariables>({
+ mutationFn: (vars) => deleteVectorBucketIndex(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef, bucketName } = variables
+ await queryClient.invalidateQueries(storageKeys.vectorBucketsIndexes(projectRef, bucketName))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to delete vector bucket index: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
+}
diff --git a/apps/studio/data/storage/vector-bucket-query.ts b/apps/studio/data/storage/vector-bucket-query.ts
new file mode 100644
index 00000000000..7d270036199
--- /dev/null
+++ b/apps/studio/data/storage/vector-bucket-query.ts
@@ -0,0 +1,49 @@
+import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+
+import { components } from 'api-types'
+import { get, handleError } from 'data/fetchers'
+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import { PROJECT_STATUS } from 'lib/constants'
+import type { ResponseError } from 'types'
+import { storageKeys } from './keys'
+
+// [Joshen] JFYI typed incorrectly in API, to fix by adding creationTime to APi
+export type VectorBucket = components['schemas']['StorageVectorBucketResponse'] & {
+ creationTime: string
+}
+
+export type VectorBucketVariables = { projectRef?: string; vectorBucketName?: string }
+
+export async function getVectorBucket(
+ { projectRef, vectorBucketName }: VectorBucketVariables,
+ signal?: AbortSignal
+) {
+ if (!projectRef) throw new Error('projectRef is required')
+ if (!vectorBucketName) throw new Error('vectorBucketName is required')
+
+ const { data, error } = await get('/platform/storage/{ref}/vector-buckets/{id}', {
+ params: { path: { ref: projectRef, id: vectorBucketName } },
+ signal,
+ })
+
+ if (error) handleError(error)
+ return data as VectorBucket
+}
+
+export type VectorBucketData = Awaited<ReturnType<typeof getVectorBucket>>
+export type VectorBucketError = ResponseError
+
+export const useVectorBucketQuery = <TData = VectorBucketData>(
+ { projectRef, vectorBucketName }: VectorBucketVariables,
+ { enabled = true, ...options }: UseQueryOptions<VectorBucketData, VectorBucketError, TData> = {}
+) => {
+ const { data: project } = useSelectedProjectQuery()
+ const isActive = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY
+
+ return useQuery<VectorBucketData, VectorBucketError, TData>({
+ queryKey: storageKeys.vectorBucket(projectRef, vectorBucketName),
+ queryFn: ({ signal }) => getVectorBucket({ projectRef, vectorBucketName }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined' && isActive,
+ ...options,
+ })
+}
diff --git a/apps/studio/data/storage/vector-buckets-indexes-query.ts b/apps/studio/data/storage/vector-buckets-indexes-query.ts
new file mode 100644
index 00000000000..16804b1babe
--- /dev/null
+++ b/apps/studio/data/storage/vector-buckets-indexes-query.ts
@@ -0,0 +1,53 @@
+import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+
+import { components } from 'api-types'
+import { get, handleError } from 'data/fetchers'
+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import { PROJECT_STATUS } from 'lib/constants'
+import type { ResponseError } from 'types'
+import { storageKeys } from './keys'
+
+export type VectorBucketIndex =
+ components['schemas']['StorageVectorBucketListIndexesResponse']['indexes'][number]
+export type GetVectorBucketsIndexesVariables = { projectRef?: string; vectorBucketName?: string }
+
+export async function getVectorBucketsIndexes(
+ { projectRef, vectorBucketName }: GetVectorBucketsIndexesVariables,
+ signal?: AbortSignal
+) {
+ if (!projectRef) throw new Error('projectRef is required')
+ if (!vectorBucketName) throw new Error('vectorBucketName is required')
+
+ const { data, error } = await get('/platform/storage/{ref}/vector-buckets/{id}/indexes', {
+ params: { path: { ref: projectRef, id: vectorBucketName } },
+ signal,
+ })
+
+ if (error) handleError(error)
+ return data
+}
+
+export type VectorBucketsIndexesData = Awaited<ReturnType<typeof getVectorBucketsIndexes>>
+export type VectorBucketsIndexesError = ResponseError
+
+export const useVectorBucketsIndexesQuery = <TData = VectorBucketsIndexesData>(
+ { projectRef, vectorBucketName }: GetVectorBucketsIndexesVariables,
+ {
+ enabled = true,
+ ...options
+ }: UseQueryOptions<VectorBucketsIndexesData, VectorBucketsIndexesError, TData> = {}
+) => {
+ const { data: project } = useSelectedProjectQuery()
+ const isActive = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY
+
+ return useQuery<VectorBucketsIndexesData, VectorBucketsIndexesError, TData>({
+ queryKey: storageKeys.vectorBucketsIndexes(projectRef, vectorBucketName),
+ queryFn: ({ signal }) => getVectorBucketsIndexes({ projectRef, vectorBucketName }, signal),
+ enabled:
+ enabled &&
+ isActive &&
+ typeof projectRef !== 'undefined' &&
+ typeof vectorBucketName !== 'undefined',
+ ...options,
+ })
+}
diff --git a/apps/studio/data/storage/vector-buckets-query.ts b/apps/studio/data/storage/vector-buckets-query.ts
new file mode 100644
index 00000000000..79ca60b04e4
--- /dev/null
+++ b/apps/studio/data/storage/vector-buckets-query.ts
@@ -0,0 +1,44 @@
+import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+
+import { get, handleError } from 'data/fetchers'
+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import { PROJECT_STATUS } from 'lib/constants'
+import type { ResponseError } from 'types'
+import { storageKeys } from './keys'
+
+export type VectorBucketsVariables = { projectRef?: string }
+
+export async function getVectorBuckets(
+ { projectRef }: VectorBucketsVariables,
+ signal?: AbortSignal
+) {
+ if (!projectRef) throw new Error('projectRef is required')
+
+ const { data, error } = await get('/platform/storage/{ref}/vector-buckets', {
+ params: { path: { ref: projectRef } },
+ signal,
+ })
+
+ if (error) handleError(error)
+
+ // [Joshen] JFYI typed incorrectly in API, to fix by adding creationTime to API
+ return data as { vectorBuckets: { vectorBucketName: string; creationTime: string }[] }
+}
+
+export type VectorBucketsData = Awaited<ReturnType<typeof getVectorBuckets>>
+export type VectorBucketsError = ResponseError
+
+export const useVectorBucketsQuery = <TData = VectorBucketsData>(
+ { projectRef }: VectorBucketsVariables,
+ { enabled = true, ...options }: UseQueryOptions<VectorBucketsData, VectorBucketsError, TData> = {}
+) => {
+ const { data: project } = useSelectedProjectQuery()
+ const isActive = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY
+
+ return useQuery<VectorBucketsData, VectorBucketsError, TData>({
+ queryKey: storageKeys.vectorBuckets(projectRef),
+ queryFn: ({ signal }) => getVectorBuckets({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined' && isActive,
+ ...options,
+ })
+}
diff --git a/apps/studio/pages/project/[ref]/storage/analytics/buckets/[bucketId].tsx b/apps/studio/pages/project/[ref]/storage/analytics/buckets/[bucketId].tsx
index 8330211db67..81f27b65765 100644
--- a/apps/studio/pages/project/[ref]/storage/analytics/buckets/[bucketId].tsx
+++ b/apps/studio/pages/project/[ref]/storage/analytics/buckets/[bucketId].tsx
@@ -1,51 +1,31 @@
-import Link from 'next/link'
-
import { useParams } from 'common'
-import { AnalyticBucketDetails } from 'components/interfaces/Storage/AnalyticsBucketDetails'
-import StorageBucketsError from 'components/interfaces/Storage/StorageBucketsError'
-import { useSelectedBucket } from 'components/interfaces/Storage/StorageExplorer/useSelectedBucket'
+import { AnalyticBucketDetails } from 'components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails'
+import { BUCKET_TYPES } from 'components/interfaces/Storage/Storage.constants'
import DefaultLayout from 'components/layouts/DefaultLayout'
+import { PageLayout } from 'components/layouts/PageLayout/PageLayout'
import StorageLayout from 'components/layouts/StorageLayout/StorageLayout'
-import { AnalyticsBucket } from 'data/storage/analytics-buckets-query'
+import { DocsButton } from 'components/ui/DocsButton'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
-import { useStorageExplorerStateSnapshot } from 'state/storage-explorer'
import type { NextPageWithLayout } from 'types'
-import { Button } from 'ui'
-import { Admonition } from 'ui-patterns'
const AnalyticsBucketPage: NextPageWithLayout = () => {
+ const config = BUCKET_TYPES.analytics
const { bucketId } = useParams()
const { data: project } = useSelectedProjectQuery()
- const { projectRef } = useStorageExplorerStateSnapshot()
- const { bucket, error, isSuccess, isError } = useSelectedBucket()
-
- // [Joshen] Checking against projectRef from storage explorer to check if the store has initialized
- // We can probably replace this with a better skeleton loader that's more representative of the page layout
- if (!project || !projectRef) return null
return (
- <div className="storage-container flex flex-grow">
- {isError && <StorageBucketsError error={error as any} />}
-
- {isSuccess ? (
- !bucket ? (
- <div className="flex h-full w-full items-center justify-center">
- <Admonition
- className="max-w-md"
- type="default"
- title="Unable to find bucket"
- description={`${bucketId ? `The bucket "${bucketId}"` : 'This bucket'} doesn’t seem to exist.`}
- >
- <Button asChild type="default" className="mt-2">
- <Link href={`/project/${projectRef}/storage/analytics`}>Head back</Link>
- </Button>
- </Admonition>
- </div>
- ) : (
- <AnalyticBucketDetails bucket={bucket as AnalyticsBucket} />
- )
- ) : null}
- </div>
+ <PageLayout
+ title={bucketId}
+ breadcrumbs={[
+ {
+ label: 'Analytics',
+ href: `/project/${project?.ref}/storage/analytics`,
+ },
+ ]}
+ secondaryActions={config?.docsUrl ? [<DocsButton key="docs" href={config.docsUrl} />] : []}
+ >
+ <AnalyticBucketDetails />
+ </PageLayout>
)
}
diff --git a/apps/studio/pages/project/[ref]/storage/vectors/buckets/[bucketId].tsx b/apps/studio/pages/project/[ref]/storage/vectors/buckets/[bucketId].tsx
new file mode 100644
index 00000000000..7dc4b3559b7
--- /dev/null
+++ b/apps/studio/pages/project/[ref]/storage/vectors/buckets/[bucketId].tsx
@@ -0,0 +1,35 @@
+import { useParams } from 'common'
+import { BUCKET_TYPES } from 'components/interfaces/Storage/Storage.constants'
+import { VectorBucketDetails } from 'components/interfaces/Storage/VectorBuckets/VectorBucketDetails'
+import DefaultLayout from 'components/layouts/DefaultLayout'
+import { PageLayout } from 'components/layouts/PageLayout/PageLayout'
+import StorageLayout from 'components/layouts/StorageLayout/StorageLayout'
+import { DocsButton } from 'components/ui/DocsButton'
+import { useStorageExplorerStateSnapshot } from 'state/storage-explorer'
+import type { NextPageWithLayout } from 'types'
+
+const VectorsBucketPage: NextPageWithLayout = () => {
+ const config = BUCKET_TYPES['vectors']
+ const { bucketId } = useParams()
+ const { projectRef } = useStorageExplorerStateSnapshot()
+
+ return (
+ <PageLayout
+ title={bucketId}
+ breadcrumbs={[{ label: 'Vectors', href: `/project/${projectRef}/storage/vectors` }]}
+ secondaryActions={config?.docsUrl ? [<DocsButton key="docs" href={config.docsUrl} />] : []}
+ >
+ <div className="storage-container flex flex-grow">
+ <VectorBucketDetails />
+ </div>
+ </PageLayout>
+ )
+}
+
+VectorsBucketPage.getLayout = (page) => (
+ <DefaultLayout>
+ <StorageLayout title="Buckets">{page}</StorageLayout>
+ </DefaultLayout>
+)
+
+export default VectorsBucketPage
diff --git a/apps/studio/pages/project/[ref]/storage/vectors/index.tsx b/apps/studio/pages/project/[ref]/storage/vectors/index.tsx
index 5064b24ef35..0177e3311f7 100644
--- a/apps/studio/pages/project/[ref]/storage/vectors/index.tsx
+++ b/apps/studio/pages/project/[ref]/storage/vectors/index.tsx
@@ -1,12 +1,15 @@
+import { useParams } from 'common'
import { BucketsComingSoon } from 'components/interfaces/Storage/BucketsComingSoon'
-import { VectorsBuckets } from 'components/interfaces/Storage/VectorsBuckets'
+import { VectorsBuckets } from 'components/interfaces/Storage/VectorBuckets'
import DefaultLayout from 'components/layouts/DefaultLayout'
import { StorageBucketsLayout } from 'components/layouts/StorageLayout/StorageBucketsLayout'
import StorageLayout from 'components/layouts/StorageLayout/StorageLayout'
+import { useIsVectorBucketsEnabled } from 'data/config/project-storage-config-query'
import type { NextPageWithLayout } from 'types'
const StorageVectorsPage: NextPageWithLayout = () => {
- const isVectorBucketsEnabled = false
+ const { ref: projectRef } = useParams()
+ const isVectorBucketsEnabled = useIsVectorBucketsEnabled({ projectRef })
return isVectorBucketsEnabled ? <VectorsBuckets /> : <BucketsComingSoon type="vector" />
}
diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.ts
index 89941bc713e..c5085b443b4 100644
--- a/packages/api-types/types/api.d.ts
+++ b/packages/api-types/types/api.d.ts
@@ -471,10 +471,12 @@ export interface paths {
* Gets project's logs
* @description Executes a SQL query on the project's logs.
*
- * Either the 'iso_timestamp_start' and 'iso_timestamp_end' parameters must be provided.
+ * Either the `iso_timestamp_start` and `iso_timestamp_end` parameters must be provided.
* If both are not provided, only the last 1 minute of logs will be queried.
* The timestamp range must be no more than 24 hours and is rounded to the nearest minute. If the range is more than 24 hours, a validation error will be thrown.
*
+ * Note: Unless the `sql` parameter is provided, only edge_logs will be queried. See the [log query docs](/docs/guides/telemetry/logs?queryGroups=product&product=postgres&queryGroups=source&source=edge_logs#querying-with-the-logs-explorer:~:text=logs%20from%20the-,Sources,-drop%2Ddown%3A) for all available sources.
+ *
*/
get: operations['v1-get-project-logs']
put?: never
@@ -2537,6 +2539,7 @@ export interface components {
/** @enum {string} */
message: 'ok'
}
+ DeleteSecretsBody: string[]
DeployFunctionResponse: {
/** Format: int64 */
created_at?: number
@@ -3349,6 +3352,7 @@ export interface components {
iceberg_catalog: boolean
list_v2: boolean
}
+ databasePoolMode: string
external: {
/** @enum {string} */
upstreamTarget: 'main' | 'canary'
@@ -3366,6 +3370,7 @@ export interface components {
}
/** Format: int64 */
fileSizeLimit: number
+ migrationVersion: string
}
StreamableFile: Record<string, never>
SubdomainAvailabilityResponse: {
@@ -4300,7 +4305,7 @@ export interface components {
V1RestorePointResponse: {
name: string
/** @enum {string} */
- status: 'AVAILABLE' | 'PENDING' | 'REMOVED'
+ status: 'AVAILABLE' | 'PENDING' | 'REMOVED' | 'FAILED'
}
V1RunQueryBody: {
parameters?: unknown[]
@@ -5517,6 +5522,7 @@ export interface operations {
query?: {
iso_timestamp_end?: string
iso_timestamp_start?: string
+ /** @description Custom SQL query to execute on the logs. See [querying logs](/docs/guides/telemetry/logs?queryGroups=product&product=postgres&queryGroups=source&source=edge_logs#querying-with-the-logs-explorer) for more details. */
sql?: string
}
header?: never
@@ -10399,7 +10405,7 @@ export interface operations {
}
requestBody: {
content: {
- 'application/json': string[]
+ 'application/json': components['schemas']['DeleteSecretsBody']
}
}
responses: {
diff --git a/packages/api-types/types/platform.d.ts b/packages/api-types/types/platform.d.ts
index 9c9e5ade4b4..2a9186388b7 100644
--- a/packages/api-types/types/platform.d.ts
+++ b/packages/api-types/types/platform.d.ts
@@ -2029,23 +2029,6 @@ export interface paths {
patch?: never
trace?: never
}
- '/platform/profile/password-check': {
- parameters: {
- query?: never
- header?: never
- path?: never
- cookie?: never
- }
- get?: never
- put?: never
- /** Check password strength */
- post: operations['PasswordCheckController_checkPassword']
- delete?: never
- options?: never
- head?: never
- patch?: never
- trace?: never
- }
'/platform/profile/permissions': {
parameters: {
query?: never
@@ -5232,7 +5215,7 @@ export interface components {
* @description Namespace
* @example my-namespace
*/
- namespace: string
+ namespace?: string
/**
* @description Project ref
* @example abcdefghijklmnopqrst
@@ -5308,7 +5291,7 @@ export interface components {
* @description Namespace
* @example my-namespace
*/
- namespace: string
+ namespace?: string
/**
* @description Project ref
* @example abcdefghijklmnopqrst
@@ -5585,6 +5568,9 @@ export interface components {
id: string
secret_key: string
}
+ CreateStorageVectorBucketBody: {
+ bucketName: string
+ }
CreateTaxIdBody: {
country?: string
type: string
@@ -7534,18 +7520,6 @@ export interface components {
organization_id: number
overdue_invoice_count: number
}
- PasswordCheckBody: {
- password: string
- }
- PasswordCheckResponse: {
- result: {
- feedback: {
- suggestions: string[]
- warning: string
- }
- score: number
- }
- }
PauseStatusResponse: {
can_restore: boolean
last_paused_on: string | null
@@ -8326,7 +8300,7 @@ export interface components {
* @description Namespace
* @example my-namespace
*/
- namespace: string
+ namespace?: string
/**
* @description Project ref
* @example abcdefghijklmnopqrst
@@ -8414,7 +8388,7 @@ export interface components {
* @description Namespace
* @example my-namespace
*/
- namespace: string
+ namespace?: string
/**
* @description Project ref
* @example abcdefghijklmnopqrst
@@ -9112,6 +9086,7 @@ export interface components {
iceberg_catalog: boolean
list_v2: boolean
}
+ databasePoolMode: string
external: {
/** @enum {string} */
upstreamTarget: 'main' | 'canary'
@@ -9129,6 +9104,7 @@ export interface components {
}
/** Format: int64 */
fileSizeLimit: number
+ migrationVersion: string
}
StorageListResponseV2: {
folders: {
@@ -10054,7 +10030,7 @@ export interface components {
* @description Namespace
* @example my-namespace
*/
- namespace: string
+ namespace?: string
/**
* @description Project ref
* @example abcdefghijklmnopqrst
@@ -10130,7 +10106,7 @@ export interface components {
* @description Namespace
* @example my-namespace
*/
- namespace: string
+ namespace?: string
/**
* @description Project ref
* @example abcdefghijklmnopqrst
@@ -17006,36 +16982,6 @@ export interface operations {
}
}
}
- PasswordCheckController_checkPassword: {
- parameters: {
- query?: never
- header?: never
- path?: never
- cookie?: never
- }
- requestBody: {
- content: {
- 'application/json': components['schemas']['PasswordCheckBody']
- }
- }
- responses: {
- 201: {
- headers: {
- [name: string]: unknown
- }
- content: {
- 'application/json': components['schemas']['PasswordCheckResponse']
- }
- }
- /** @description Failed to check password strength */
- 500: {
- headers: {
- [name: string]: unknown
- }
- content?: never
- }
- }
- }
PermissionsController_getPermissions: {
parameters: {
query?: never
@@ -25280,7 +25226,9 @@ export interface operations {
}
StorageVectorBucketsController_getBuckets: {
parameters: {
- query?: never
+ query?: {
+ nextToken?: string
+ }
header?: never
path: {
/** @description Project ref */
@@ -25338,7 +25286,11 @@ export interface operations {
}
cookie?: never
}
- requestBody?: never
+ requestBody: {
+ content: {
+ 'application/json': components['schemas']['CreateStorageVectorBucketBody']
+ }
+ }
responses: {
201: {
headers: {