Skip to content

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

Swap analytics buckets endpoint (#39610)

Joshen Lim0910908561f7
diff --git a/apps/studio/components/interfaces/LogDrains/LogDrains.constants.tsx b/apps/studio/components/interfaces/LogDrains/LogDrains.constants.tsx
index 8a6801bc82a..02530e37222 100644
--- a/apps/studio/components/interfaces/LogDrains/LogDrains.constants.tsx
+++ b/apps/studio/components/interfaces/LogDrains/LogDrains.constants.tsx
@@ -1,5 +1,5 @@
-import { Datadog, Grafana, Sentry } from 'icons'
import { components } from 'api-types'
+import { Datadog, Grafana, Sentry } from 'icons'
import { BracesIcon } from 'lucide-react'
const iconProps = {
@@ -8,6 +8,8 @@ const iconProps = {
className: 'text-foreground-light',
}
+export type LogDrainType = components['schemas']['CreateBackendParamsOpenapi']['type']
+
export const LOG_DRAIN_TYPES = [
{
value: 'webhook',
@@ -39,14 +41,6 @@ export const LOG_DRAIN_TYPES = [
export const LOG_DRAIN_SOURCE_VALUES = LOG_DRAIN_TYPES.map((source) => source.value)
-// export type LogDrainType =
-// | (typeof LOG_DRAIN_TYPES)[number]['value']
-// | 'postgres'
-// | 'bigquery'
-// | 'elastic'
-
-export type LogDrainType = components['schemas']['LFBackend']['type']
-
export const DATADOG_REGIONS = [
{
label: 'AP1',
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/AnalyticsBucketDetails.utils.ts b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/AnalyticsBucketDetails.utils.ts
new file mode 100644
index 00000000000..828b6ec314d
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/AnalyticsBucketDetails.utils.ts
@@ -0,0 +1,13 @@
+import { snakeCase } from 'lodash'
+
+export const getAnalyticsBucketPublicationName = (bucketId: string) => {
+ return `analytics_${snakeCase(bucketId)}_publication`
+}
+
+export const getAnalyticsBucketS3KeyName = (bucketId: string) => {
+ return `${snakeCase(bucketId)}_keys`
+}
+
+export const getAnalyticsBucketFDWName = (bucketId: string) => {
+ return `${snakeCase(bucketId)}_fdw`
+}
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/ConnectTablesDialog.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/ConnectTablesDialog.tsx
new file mode 100644
index 00000000000..430558b4127
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/ConnectTablesDialog.tsx
@@ -0,0 +1,275 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import { Plus } from 'lucide-react'
+import { 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 { getKeys, useAPIKeysQuery } from 'data/api-keys/api-keys-query'
+import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
+import { useCreateDestinationPipelineMutation } from 'data/replication/create-destination-pipeline-mutation'
+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,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogSection,
+ DialogSectionSeparator,
+ DialogTitle,
+ DialogTrigger,
+ Form_Shadcn_,
+ FormControl_Shadcn_,
+ FormField_Shadcn_,
+} 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'
+
+/**
+ * [Joshen] So far this is purely just setting up a "Connect from empty state" flow
+ * Doing it bit by bit as this is quite an unknown territory, will adjust as we figure out
+ * limitations, correctness, etc, etc. ETL is also only available on staging so its quite hard
+ * to test things locally (Local set up is technically available but quite high friction)
+ *
+ * What's missing afaict:
+ * - Deleting namespaces
+ * - Removing tables
+ * - Adding more tables
+ * - Error handling due to multiple async processes
+ */
+
+const FormSchema = z.object({
+ tables: z.array(z.string()).min(1, 'At least one table is required'),
+})
+
+const formId = 'connect-tables-form'
+const isEnabled = false // Kill switch if we wanna hold off supporting connecting tables
+
+type ConnectTablesForm = z.infer<typeof FormSchema>
+
+export const ConnectTablesDialog = ({ bucket }: { bucket: AnalyticsBucket }) => {
+ const form = useForm<ConnectTablesForm>({
+ resolver: zodResolver(FormSchema),
+ defaultValues: { tables: [] },
+ })
+
+ const [visible, setVisible] = useState(false)
+ const { ref: projectRef } = useParams()
+ const { data: project } = useSelectedProjectQuery()
+
+ const { data: wrapperInstance } = useAnalyticsBucketWrapperInstance({ bucketId: bucket.id })
+ const wrapperValues = convertKVStringArrayToJson(wrapperInstance?.server_options ?? [])
+
+ const { data: projectSettings } = useProjectSettingsV2Query({ projectRef })
+ const { data: apiKeys } = useAPIKeysQuery({ projectRef, reveal: true })
+ const { serviceKey } = getKeys(apiKeys)
+
+ const { data: tables } = useTablesQuery({
+ projectRef,
+ connectionString: project?.connectionString,
+ includeColumns: false,
+ })
+
+ const { data: sourcesData } = useReplicationSourcesQuery({ projectRef })
+ const sourceId = sourcesData?.sources.find((s) => s.name === projectRef)?.id
+
+ const { mutateAsync: createNamespace, isLoading: isCreatingNamespace } =
+ useIcebergNamespaceCreateMutation()
+
+ const { mutateAsync: createPublication, isLoading: isCreatingPublication } =
+ useCreatePublicationMutation()
+
+ const { mutateAsync: createDestinationPipeline, isLoading: creatingDestinationPipeline } =
+ useCreateDestinationPipelineMutation({
+ onSuccess: () => {},
+ })
+
+ const { mutateAsync: startPipeline } = useStartPipelineMutation()
+
+ const isConnecting = isCreatingNamespace || creatingDestinationPipeline || isCreatingPublication
+
+ 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
+
+ if (!projectRef) return console.error('Project ref is required')
+ if (!sourceId) return toast.error('Source ID is required')
+
+ try {
+ const publicationName = getAnalyticsBucketPublicationName(bucket.id)
+ await createPublication({
+ projectRef,
+ sourceId,
+ name: publicationName,
+ tables: values.tables.map((table) => {
+ const [schema, name] = table.split('.')
+ return { schema, name }
+ }),
+ })
+
+ const keysToDecrypt = Object.entries(wrapperValues)
+ .filter(([name]) =>
+ ['vault_aws_access_key_id', 'vault_aws_secret_access_key'].includes(name)
+ )
+ .map(([_, keyId]) => keyId)
+ const decryptedValues = await getDecryptedValues({
+ projectRef,
+ connectionString: project?.connectionString,
+ ids: keysToDecrypt,
+ })
+
+ const warehouseName = bucket.id
+ const catalogToken = serviceKey?.api_key ?? ''
+ const s3AccessKeyId = decryptedValues[wrapperValues['vault_aws_access_key_id']]
+ const s3SecretAccessKey = decryptedValues[wrapperValues['vault_aws_secret_access_key']]
+ const s3Region = projectSettings?.region ?? ''
+
+ const protocol = projectSettings?.app_config?.protocol ?? 'https'
+ const endpoint =
+ projectSettings?.app_config?.storage_endpoint || projectSettings?.app_config?.endpoint
+ const catalogUri = getCatalogURI(project?.ref ?? '', protocol, endpoint)
+ const namespace = `${bucket.id}_namespace`
+ await createNamespace({
+ catalogUri,
+ warehouse: warehouseName,
+ token: catalogToken,
+ namespace,
+ })
+
+ const icebergConfiguration = {
+ projectRef,
+ warehouseName,
+ namespace,
+ catalogToken,
+ s3AccessKeyId,
+ s3SecretAccessKey,
+ s3Region,
+ }
+ const destinationName = `${snakeCase(bucket.id)}_destination`
+
+ const { pipeline_id: pipelineId } = await createDestinationPipeline({
+ projectRef,
+ destinationName,
+ destinationConfig: { iceberg: icebergConfiguration },
+ sourceId,
+ pipelineConfig: { publicationName },
+ })
+
+ // Pipeline can start behind the scenes, don't need to await
+ startPipeline({ projectRef, pipelineId })
+ toast.success(`Connected ${values.tables.length} tables to Analytics bucket!`)
+ form.reset()
+ setVisible(false)
+ } catch (error: any) {
+ // [Joshen] JFYI there's several async processes here so if something goes wrong midway - we need to figure out how to roll back cleanly
+ // e.g publication gets created, but namespace creation fails -> should the old publication get deleted?
+ // Another question is probably whether all of these step by step logic should be at the API level instead of client level
+ // Same issue present within DestinationPanel - it's alright for now as we do an Alpha but this needs to be addressed before GA
+ toast.error(`Failed to connect tables: ${error.message}`)
+ }
+ }
+
+ const handleClose = () => {
+ form.reset()
+ setVisible(false)
+ }
+
+ return (
+ <Dialog
+ open={visible}
+ onOpenChange={(open) => {
+ if (!open) handleClose()
+ }}
+ >
+ <DialogTrigger asChild>
+ <ButtonTooltip
+ disabled={!isEnabled}
+ size="tiny"
+ type="primary"
+ icon={<Plus size={14} />}
+ onClick={() => setVisible(true)}
+ tooltip={{ content: { side: 'bottom', text: !isEnabled ? 'Coming soon' : undefined } }}
+ >
+ Connect tables
+ </ButtonTooltip>
+ </DialogTrigger>
+
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Connect tables</DialogTitle>
+ </DialogHeader>
+
+ <DialogSectionSeparator />
+
+ <Form_Shadcn_ {...form}>
+ <form id={formId} onSubmit={form.handleSubmit(onSubmit)}>
+ <DialogSection className="flex flex-col gap-y-4">
+ <p className="text-sm">
+ Select the database tables to send data from. A destination analytics table will be
+ created for each, and data will replicate automatically.
+ </p>
+ </DialogSection>
+ <DialogSectionSeparator />
+ <DialogSection className="overflow-visible">
+ <FormField_Shadcn_
+ control={form.control}
+ name="tables"
+ render={({ field }) => (
+ <FormItemLayout label="Tables">
+ <FormControl_Shadcn_>
+ <MultiSelector
+ values={field.value}
+ onValuesChange={field.onChange}
+ disabled={isConnecting}
+ >
+ <MultiSelector.Trigger label="Select tables..." badgeLimit="wrap" />
+ <MultiSelector.Content>
+ <MultiSelector.List>
+ {tables?.map((table) => (
+ <MultiSelector.Item
+ key={`${table.schema}.${table.name}`}
+ value={`${table.schema}.${table.name}`}
+ >
+ {`${table.schema}.${table.name}`}
+ </MultiSelector.Item>
+ ))}
+ </MultiSelector.List>
+ </MultiSelector.Content>
+ </MultiSelector>
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </DialogSection>
+ </form>
+ </Form_Shadcn_>
+
+ <DialogFooter>
+ <Button type="default" disabled={isConnecting} onClick={() => setVisible(false)}>
+ Cancel
+ </Button>
+ <Button form={formId} htmlType="submit" loading={isConnecting} disabled={isConnecting}>
+ Connect
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/apps/studio/components/interfaces/Storage/AnalyticBucketDetails/CopyEnvButton.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/CopyEnvButton.tsx
similarity index 95%
rename from apps/studio/components/interfaces/Storage/AnalyticBucketDetails/CopyEnvButton.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/CopyEnvButton.tsx
index a4aa58474a6..d1261e3bc02 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticBucketDetails/CopyEnvButton.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/CopyEnvButton.tsx
@@ -34,7 +34,7 @@ export const CopyEnvButton = ({
).then((values) => values.join('\n'))
copyToClipboard(envFile, () => {
- toast.success('Copied to clipboard as .env file')
+ toast.success('Copied to clipboard as environment variables')
setIsLoading(false)
})
}, [serverOptions, values])
diff --git a/apps/studio/components/interfaces/Storage/AnalyticBucketDetails/DecryptedReadOnlyInput.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/DecryptedReadOnlyInput.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Storage/AnalyticBucketDetails/DecryptedReadOnlyInput.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/DecryptedReadOnlyInput.tsx
diff --git a/apps/studio/components/interfaces/Storage/AnalyticBucketDetails/NamespaceRow.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/NamespaceRow.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Storage/AnalyticBucketDetails/NamespaceRow.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/NamespaceRow.tsx
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/NamespaceWithTables.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/NamespaceWithTables.tsx
new file mode 100644
index 00000000000..2faad51fe88
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/NamespaceWithTables.tsx
@@ -0,0 +1,336 @@
+import { ChevronRight, Code, Info, MoreVertical, Plus, Replace, Trash2 } from 'lucide-react'
+import Link from 'next/link'
+import { useMemo, useState } from 'react'
+
+import type { WrapperMeta } from 'components/interfaces/Integrations/Wrappers/Wrappers.types'
+import { FormattedWrapperTable } from 'components/interfaces/Integrations/Wrappers/Wrappers.utils'
+import { ImportForeignSchemaDialog } from 'components/interfaces/Storage/ImportForeignSchemaDialog'
+import { useFDWImportForeignSchemaMutation } from 'data/fdw/fdw-import-foreign-schema-mutation'
+import { FDW } from 'data/fdw/fdws-query'
+import { useIcebergNamespaceTablesQuery } from 'data/storage/iceberg-namespace-tables-query'
+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import {
+ Button,
+ Card,
+ CardHeader,
+ CardTitle,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from 'ui'
+
+type NamespaceWithTablesProps = {
+ bucketName: string
+ namespace: string
+ sourceType: 'replication' | 'direct'
+ schema: string
+ tables: (FormattedWrapperTable & { id: number })[]
+ token: string
+ wrapperInstance: FDW
+ wrapperValues: Record<string, string>
+ wrapperMeta: WrapperMeta
+}
+
+// Component for individual table rows within a namespace
+const TableRowComponent = ({
+ index,
+ tableName,
+ isConnected,
+ isLoading,
+}: {
+ index: number
+ tableName: string
+ isConnected: boolean
+ isLoading?: boolean
+}) => {
+ const { data: project } = useSelectedProjectQuery()
+
+ const handleQueryTable = () => {
+ // TODO: Implement query table functionality
+ console.log('Query table:', tableName)
+ }
+
+ const handleDeleteTable = () => {
+ // TODO: Implement delete table functionality
+ console.log('Delete table:', tableName)
+ }
+
+ return (
+ <TableRow>
+ <TableCell className="min-w-[120px]">{tableName}</TableCell>
+ <TableCell colSpan={isConnected ? 1 : 2} className="min-w-[150px]">
+ <div className="flex flex-row items-center text-foregroung-lighter">
+ <div className="relative mr-2 align-middle w-3 h-3">
+ {/* Outer faded dot with pulsing background */}
+ <span
+ className={`absolute inset-0 rounded-full ${
+ isConnected
+ ? isLoading
+ ? 'bg-brand/20 animate-ping'
+ : 'bg-brand/20 animate-ping'
+ : isLoading
+ ? 'bg-warning-500/20 animate-ping'
+ : 'hidden'
+ }`}
+ style={{
+ // Stagger the animation delay for each table
+ animationDelay: `${1 + index * 0.15}s`,
+ // Slow the animation
+ animationDuration: '2s',
+ }}
+ />
+ {/* Inner colored dot */}
+ <span
+ className={`absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 inline-block w-2 h-2 rounded-full ${
+ isConnected ? 'bg-brand' : 'bg-warning-500'
+ }`}
+ />
+ </div>
+ <span className="text-foreground-lighter">
+ {isLoading && !isConnected
+ ? 'Connecting...'
+ : isConnected
+ ? 'Connected'
+ : 'Not connected'}
+ </span>
+ </div>
+ </TableCell>
+ {isConnected && (
+ <TableCell className="text-right flex flex-row items-center gap-x-2 justify-end">
+ <>
+ <Button asChild type="default" size="tiny">
+ <Link href={`/project/${project?.ref}/editor/${tableName}`}>
+ <p>View table</p>
+ </Link>
+ </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button type="default" className="px-1" icon={<MoreVertical />} />
+ </DropdownMenuTrigger>
+
+ <DropdownMenuContent side="bottom" align="end" className="w-fit min-w-[180px]">
+ <DropdownMenuItem className="flex items-center gap-x-2" onClick={handleQueryTable}>
+ <Code size={12} className="text-foreground-lighter" />
+ <p>Query in SQL Editor</p>
+ </DropdownMenuItem>
+ <DropdownMenuItem asChild className="flex items-center gap-x-2">
+ <Link href={`/project/${project?.ref}/database/replication/${tableName}`}>
+ <Replace size={12} className="text-foreground-lighter" />
+ <p>View replication status</p>
+ </Link>
+ </DropdownMenuItem>
+
+ <DropdownMenuItem className="flex items-center gap-x-2" onClick={handleDeleteTable}>
+ <Trash2 size={12} className="text-foreground-lighter" />
+ <p>Delete table</p>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </>
+ </TableCell>
+ )}
+ </TableRow>
+ )
+}
+
+export const NamespaceWithTables = ({
+ bucketName,
+ namespace,
+ sourceType = 'direct',
+ schema,
+ tables,
+ token,
+ wrapperInstance,
+ wrapperValues,
+ wrapperMeta,
+}: NamespaceWithTablesProps) => {
+ const { data: project } = useSelectedProjectQuery()
+ const [importForeignSchemaShown, setImportForeignSchemaShown] = useState(false)
+
+ const { data: tablesData, isLoading: isLoadingNamespaceTables } = useIcebergNamespaceTablesQuery(
+ {
+ catalogUri: wrapperValues.catalog_uri,
+ warehouse: wrapperValues.warehouse,
+ token: token,
+ namespace: namespace,
+ },
+ { enabled: !!token }
+ )
+
+ const { mutateAsync: importForeignSchema, isLoading: isImportingForeignSchema } =
+ useFDWImportForeignSchemaMutation()
+
+ const rescanNamespace = async () => {
+ await importForeignSchema({
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ serverName: wrapperInstance.server_name,
+ sourceSchema: namespace,
+ targetSchema: schema,
+ })
+ }
+
+ const missingTables = useMemo(() => {
+ return (tablesData || []).filter(
+ (t) => !tables.find((table) => table.table.split('.')[1] === t)
+ )
+ }, [tablesData, tables])
+
+ let scanTooltip = useMemo(() => {
+ if (isImportingForeignSchema) return 'Looking for new tables...'
+ if (isLoadingNamespaceTables) return 'Loading new tables...'
+ if (missingTables.length > 0)
+ return `${missingTables.length} new table${missingTables.length > 1 ? 's' : ''} found`
+ if (tables.length === 0) return 'No new tables found'
+ return 'All tables are up to date'
+ }, [isImportingForeignSchema, isLoadingNamespaceTables, missingTables.length, tables.length])
+
+ // Get all tables (connected + missing) for display
+ const allTables = useMemo(() => {
+ const connectedTableNames = tables.map((table) => table.table.split('.')[1])
+ const allTableNames = [...new Set([...connectedTableNames, ...missingTables])]
+
+ return allTableNames.map((tableName) => ({
+ name: tableName,
+ isConnected: connectedTableNames.includes(tableName),
+ }))
+ }, [tables, missingTables])
+
+ // Determine if schema is valid (no clashes with Postgres schema)
+ // TODO: Replace with actual clash check logic
+ const validSchema = useMemo(() => {
+ // If schema exists and has tables, it's always valid
+ if (schema && tables.length > 0) return true
+
+ // For uploaded namespaces without tables, check for clashes against incoming schema (namespace name)
+ // TODO: Replace with actual clash check against Postgres schema
+ const hasClashes = false // Mock: no clashes for now
+
+ // Show incoming schema if no clashes (even without tables)
+ return !hasClashes
+ }, [schema, tables.length])
+
+ // Determine what schema name to display
+ const displaySchema = useMemo(() => {
+ // If we have a target schema, use it
+ if (schema) return schema
+
+ // Otherwise, show the incoming schema (namespace name)
+ return `fdw_analytics_${namespace.replaceAll('-', '_')}`
+ }, [schema, namespace])
+
+ return (
+ <Card>
+ <CardHeader className="flex flex-row justify-between items-center px-4 py-5 space-y-0">
+ <CardTitle className="text-sm font-normal font-sans normal-case leading-none flex flex-row items-center gap-x-1">
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="flex flex-row items-center gap-x-1 text-foreground-lighter">
+ {sourceType === 'direct' ? namespace : 'public'}
+ <ChevronRight size={12} className="text-foreground-muted" />
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>{sourceType === 'direct' ? 'Analytics' : 'Postgres'} schema</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ {validSchema && (
+ <Tooltip>
+ <TooltipTrigger
+ asChild
+ className={tables.length === 0 ? `flex flex-row items-center gap-x-1` : undefined}
+ >
+ <span
+ className={
+ tables.length > 0
+ ? `text-foreground`
+ : `text-foreground-muted flex flex-row items-center gap-x-1`
+ }
+ >
+ {displaySchema}
+ {tables.length === 0 && <Info size={12} />}
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>Postgres schema{tables.length === 0 && ' that will be created'}</p>
+ </TooltipContent>
+ </Tooltip>
+ )}
+ </CardTitle>
+
+ <div className="flex flex-row gap-x-2">
+ {/* [Joshen] Temporarily commented out, will be introduced once language and UI details are finalized */}
+ {/* {tables.length > 0 && <p className="text-sm text-foreground-muted">{scanTooltip}</p>} */}
+ {/* {scanTooltip && <p className="text-sm text-foreground-muted">{scanTooltip}</p>} */}
+ {missingTables.length > 0 && (
+ <Button
+ type={missingTables.length > 0 ? 'warning' : 'default'}
+ size="tiny"
+ icon={<Plus size={14} />}
+ onClick={() => (schema ? rescanNamespace() : setImportForeignSchemaShown(true))}
+ loading={isImportingForeignSchema || isLoadingNamespaceTables}
+ >
+ Connect to table{missingTables.length > 1 ? 's' : ''}
+ </Button>
+ )}
+ </div>
+ </CardHeader>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead className={allTables.length === 0 ? 'text-foreground-muted' : undefined}>
+ Table name
+ </TableHead>
+ <TableHead className={allTables.length === 0 ? 'hidden' : undefined}>Status</TableHead>
+ <TableHead />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {allTables.length === 0 ? (
+ <TableRow className="[&>td]:hover:bg-inherit">
+ <TableCell colSpan={3}>
+ <p className="text-sm text-foreground">No tables yet</p>
+ <p className="text-sm text-foreground-lighter">
+ {sourceType === 'direct'
+ ? ' Publish an analytics table from your Iceberg client'
+ : 'Connect a table from your database'}
+ </p>
+ </TableCell>
+ </TableRow>
+ ) : (
+ allTables.map(({ name, isConnected }, index) => (
+ <TableRowComponent
+ key={name}
+ tableName={name}
+ isConnected={isConnected}
+ isLoading={isImportingForeignSchema || isLoadingNamespaceTables}
+ index={index}
+ />
+ ))
+ )}
+ </TableBody>
+ </Table>
+ <ImportForeignSchemaDialog
+ bucketName={bucketName}
+ namespace={namespace}
+ circumstance="clash"
+ wrapperMeta={wrapperMeta}
+ visible={importForeignSchemaShown}
+ onClose={() => setImportForeignSchemaShown(false)}
+ />
+ </Card>
+ )
+}
diff --git a/apps/studio/components/interfaces/Storage/AnalyticBucketDetails/SimpleConfigurationDetails.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/SimpleConfigurationDetails.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Storage/AnalyticBucketDetails/SimpleConfigurationDetails.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/SimpleConfigurationDetails.tsx
diff --git a/apps/studio/components/interfaces/Storage/AnalyticBucketDetails/constants.ts b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/constants.ts
similarity index 93%
rename from apps/studio/components/interfaces/Storage/AnalyticBucketDetails/constants.ts
rename to apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/constants.ts
index d7a2711792d..21957b2208b 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticBucketDetails/constants.ts
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/constants.ts
@@ -20,7 +20,7 @@ export const DESCRIPTIONS: Record<string, string> = {
vault_aws_access_key_id: 'Matches the AWS access key ID from an S3 access key.',
vault_aws_secret_access_key: 'Matches the AWS secret access from an S3 access key.',
vault_token: 'Corresponds to the service role key.',
- warehouse: 'Matches the name of the bucket.',
+ warehouse: 'Matches the name of this bucket.',
's3.endpoint': '',
catalog_uri: '',
}
diff --git a/apps/studio/components/interfaces/Storage/AnalyticBucketDetails/index.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/index.tsx
similarity index 84%
rename from apps/studio/components/interfaces/Storage/AnalyticBucketDetails/index.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/index.tsx
index 13e365d7f2d..5685cc1affe 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticBucketDetails/index.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/index.tsx
@@ -1,11 +1,14 @@
+import { uniq } from 'lodash'
+import { SquarePlus } from 'lucide-react'
+import Link from 'next/link'
+import { useMemo, useState } from 'react'
+
import { useIsNewStorageUIEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { INTEGRATIONS } from 'components/interfaces/Integrations/Landing/Integrations.constants'
-import { WRAPPER_HANDLERS } from 'components/interfaces/Integrations/Wrappers/Wrappers.constants'
import { WrapperMeta } from 'components/interfaces/Integrations/Wrappers/Wrappers.types'
import {
convertKVStringArrayToJson,
formatWrapperTables,
- wrapperMetaComparator,
} from 'components/interfaces/Integrations/Wrappers/Wrappers.utils'
import { BUCKET_TYPES } from 'components/interfaces/Storage/Storage.constants'
import { PageLayout } from 'components/layouts/PageLayout/PageLayout'
@@ -22,17 +25,12 @@ import {
DatabaseExtension,
useDatabaseExtensionsQuery,
} from 'data/database-extensions/database-extensions-query'
-import { useFDWsQuery } from 'data/fdw/fdws-query'
-import { Bucket } from 'data/storage/buckets-query'
+import { AnalyticsBucket } from 'data/storage/analytics-buckets-query'
import { useIcebergNamespacesQuery } from 'data/storage/iceberg-namespaces-query'
import { useIcebergWrapperCreateMutation } from 'data/storage/iceberg-wrapper-create-mutation'
import { useVaultSecretDecryptedValueQuery } from 'data/vault/vault-secret-decrypted-value-query'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { DOCS_URL } from 'lib/constants'
-import { snakeCase, uniq } from 'lodash'
-import { Plus } from 'lucide-react'
-import Link from 'next/link'
-import { useMemo, useState } from 'react'
import {
Button,
Card,
@@ -47,51 +45,36 @@ import {
import { Admonition } from 'ui-patterns/admonition'
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
import { DeleteBucketModal } from '../DeleteBucketModal'
+import { ConnectTablesDialog } from './ConnectTablesDialog'
import { DESCRIPTIONS, LABELS, OPTION_ORDER } from './constants'
import { CopyEnvButton } from './CopyEnvButton'
import { DecryptedReadOnlyInput } from './DecryptedReadOnlyInput'
import { NamespaceRow } from './NamespaceRow'
+import { NamespaceWithTables } from './NamespaceWithTables'
import { SimpleConfigurationDetails } from './SimpleConfigurationDetails'
+import { useAnalyticsBucketWrapperInstance } from './useAnalyticsBucketWrapperInstance'
import { useIcebergWrapperExtension } from './useIcebergWrapper'
-export const AnalyticBucketDetails = ({ bucket }: { bucket: Bucket }) => {
+export const AnalyticBucketDetails = ({ bucket }: { bucket: AnalyticsBucket }) => {
+ const config = BUCKET_TYPES.analytics
const [modal, setModal] = useState<'delete' | null>(null)
const isStorageV2 = useIsNewStorageUIEnabled()
const { data: project } = useSelectedProjectQuery()
+ const { state: extensionState } = useIcebergWrapperExtension()
- const { data: extensionsData } = useDatabaseExtensionsQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
+ /** The wrapper instance is the wrapper that is installed for this Analytics bucket. */
+ const { data: wrapperInstance, isLoading } = useAnalyticsBucketWrapperInstance({
+ bucketId: bucket.id,
})
+ const wrapperValues = convertKVStringArrayToJson(wrapperInstance?.server_options ?? [])
+ const integration = INTEGRATIONS.find((i) => i.id === 'iceberg_wrapper' && i.type === 'wrapper')
+ const wrapperMeta = (integration?.type === 'wrapper' && integration.meta) as WrapperMeta
- const { data, isLoading: isFDWsLoading } = useFDWsQuery({
+ const { data: extensionsData } = useDatabaseExtensionsQuery({
projectRef: project?.ref,
connectionString: project?.connectionString,
})
-
- /** The wrapper instance is the wrapper that is installed for this Analytics bucket. */
- const wrapperInstance = useMemo(() => {
- return data
- ?.filter((wrapper) =>
- wrapperMetaComparator(
- {
- handlerName: WRAPPER_HANDLERS.ICEBERG,
- server: {
- options: [],
- },
- },
- wrapper
- )
- )
- .find((w) => w.name === snakeCase(`${bucket.name}_fdw`))
- }, [data, bucket.name])
-
- const { state: extensionState } = useIcebergWrapperExtension()
-
- const integration = INTEGRATIONS.find((i) => i.id === 'iceberg_wrapper' && i.type === 'wrapper')
-
- const wrapperValues = convertKVStringArrayToJson(wrapperInstance?.server_options ?? [])
- const wrapperMeta = (integration?.type === 'wrapper' && integration.meta) as WrapperMeta
+ const wrappersExtension = extensionsData?.find((ext) => ext.name === 'wrappers')
const { data: token, isSuccess: isSuccessToken } = useVaultSecretDecryptedValueQuery(
{
@@ -99,9 +82,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: Bucket }) => {
connectionString: project?.connectionString,
id: wrapperValues.vault_token,
},
- {
- enabled: wrapperValues.vault_token !== undefined,
- }
+ { enabled: wrapperValues.vault_token !== undefined }
)
const { data: namespacesData, isLoading: isLoadingNamespaces } = useIcebergNamespacesQuery(
@@ -135,11 +116,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: Bucket }) => {
})
}, [wrapperTables, namespacesData])
- const wrappersExtension = extensionsData?.find((ext) => ext.name === 'wrappers')
-
- const config = BUCKET_TYPES['analytics']
-
- const state = isFDWsLoading
+ const state = isLoading
? 'loading'
: extensionState === 'installed'
? wrapperInstance
@@ -150,7 +127,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: Bucket }) => {
return (
<>
<PageLayout
- title={bucket.name}
+ title={bucket.id}
breadcrumbs={
isStorageV2
? [
@@ -171,7 +148,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: Bucket }) => {
)}
{state === 'not-installed' && (
<ExtensionNotInstalled
- bucketName={bucket.name}
+ bucketName={bucket.id}
projectRef={project?.ref!}
wrapperMeta={wrapperMeta}
wrappersExtension={wrappersExtension!}
@@ -179,7 +156,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: Bucket }) => {
)}
{state === 'needs-upgrade' && (
<ExtensionNeedsUpgrade
- bucketName={bucket.name}
+ bucketName={bucket.id}
projectRef={project?.ref!}
wrapperMeta={wrapperMeta}
wrappersExtension={wrappersExtension!}
@@ -190,39 +167,47 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: Bucket }) => {
<>
{isStorageV2 ? (
<ScaffoldSection isFullWidth>
- <ScaffoldHeader className="flex flex-row justify-between items-end gap-x-8">
+ <ScaffoldHeader className="pt-0 flex flex-row justify-between items-end gap-x-8">
<div>
<ScaffoldSectionTitle>Tables</ScaffoldSectionTitle>
<ScaffoldSectionDescription>
- Analytics tables connected to this bucket.
+ Analytics tables stored in this bucket
</ScaffoldSectionDescription>
</div>
- <Button type="primary" size="tiny" icon={<Plus size={14} />} onClick={() => {}}>
- New table
- </Button>
+ {namespaces.length > 0 && <ConnectTablesDialog bucket={bucket} />}
</ScaffoldHeader>
- <Card>
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead className="text-foreground-muted">Name</TableHead>
- <TableHead className="text-foreground-muted">Schema</TableHead>
- <TableHead className="text-foreground-muted">Created at</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- <TableRow>
- <TableCell colSpan={4}>
- <p className="text-sm text-foreground">No tables yet</p>
- <p className="text-sm text-foreground-lighter">
- Create an analytics table to get started
- </p>
- </TableCell>
- </TableRow>
- </TableBody>
- </Table>
- </Card>
+ {isLoadingNamespaces || isLoading ? (
+ <GenericSkeletonLoader />
+ ) : namespaces.length === 0 ? (
+ <aside className="border border-dashed w-full bg-surface-100 rounded-lg px-4 py-10 flex flex-col gap-y-3 items-center text-center gap-1 text-balance">
+ <SquarePlus size={24} strokeWidth={1.5} className="text-foreground-muted" />
+ <div className="flex flex-col items-center text-center">
+ <h3>Connect database tables</h3>
+ <p className="text-foreground-light text-sm">
+ Stream data from tables for archival, backups, or analytical queries.
+ </p>
+ </div>
+ <ConnectTablesDialog bucket={bucket} />
+ </aside>
+ ) : (
+ <div className="flex flex-col gap-y-10">
+ {namespaces.map(({ namespace, schema, tables }) => (
+ <NamespaceWithTables
+ key={namespace}
+ bucketName={bucket.id}
+ namespace={namespace}
+ sourceType="direct"
+ schema={schema}
+ tables={tables as any}
+ token={token!}
+ wrapperInstance={wrapperInstance}
+ wrapperValues={wrapperValues}
+ wrapperMeta={wrapperMeta}
+ />
+ ))}
+ </div>
+ )}
</ScaffoldSection>
) : (
<ScaffoldSection isFullWidth>
@@ -233,7 +218,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: Bucket }) => {
</ScaffoldSectionDescription>
</ScaffoldHeader>
- {isLoadingNamespaces || isFDWsLoading ? (
+ {isLoadingNamespaces || isLoading ? (
<GenericSkeletonLoader />
) : namespaces.length === 0 ? (
<Card>
@@ -275,7 +260,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: Bucket }) => {
{namespaces.map(({ namespace, schema, tables }) => (
<NamespaceRow
key={namespace}
- bucketName={bucket.name}
+ bucketName={bucket.id}
namespace={namespace}
schema={schema}
tables={tables as any}
@@ -295,9 +280,9 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: Bucket }) => {
<ScaffoldSection isFullWidth>
<ScaffoldHeader className="flex flex-row justify-between items-end gap-x-8">
<div>
- <ScaffoldSectionTitle>Configuration</ScaffoldSectionTitle>
+ <ScaffoldSectionTitle>Connection details</ScaffoldSectionTitle>
<ScaffoldSectionDescription>
- Connect to this bucket from an Iceberg client.{' '}
+ Connect an Iceberg client to this bucket.{' '}
<InlineLink
href={`${DOCS_URL}/guides/storage/analytics/connecting-to-analytics-bucket`}
>
@@ -332,7 +317,7 @@ export const AnalyticBucketDetails = ({ bucket }: { bucket: Bucket }) => {
</ScaffoldSection>
</>
)}
- {state === 'missing' && <WrapperMissing bucketName={bucket.name} />}
+ {state === 'missing' && <WrapperMissing bucketName={bucket.id} />}
<ScaffoldSection isFullWidth className="flex flex-col gap-y-4">
<header>
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx
new file mode 100644
index 00000000000..e9c153e401a
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx
@@ -0,0 +1,118 @@
+import { PermissionAction } from '@supabase/shared-types/out/constants'
+
+import { useIsNewStorageUIEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { WrapperMeta } from 'components/interfaces/Integrations/Wrappers/Wrappers.types'
+import { useFDWDeleteMutation } from 'data/fdw/fdw-delete-mutation'
+import { FDW } from 'data/fdw/fdws-query'
+import {
+ ReplicationPublication,
+ useReplicationPublicationsQuery,
+} from 'data/replication/publications-query'
+import { useReplicationSourcesQuery } from 'data/replication/sources-query'
+import { useS3AccessKeyDeleteMutation } from 'data/storage/s3-access-key-delete-mutation'
+import { S3AccessKey, useStorageCredentialsQuery } from 'data/storage/s3-access-key-query'
+import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
+import {
+ getAnalyticsBucketPublicationName,
+ getAnalyticsBucketS3KeyName,
+} from './AnalyticsBucketDetails.utils'
+import { useAnalyticsBucketWrapperInstance } from './useAnalyticsBucketWrapperInstance'
+
+/**
+ * Returns all the data that's associated to a specified analytics bucket (e.g publications, S3 keys, etc)
+ * Used for cleaning up analytics bucket after deletion
+ */
+export const useAnalyticsBucketAssociatedEntities = (
+ { projectRef, bucketId }: { projectRef?: string; bucketId: string },
+ options: { enabled: boolean } = { enabled: true }
+) => {
+ // [Joshen] Opting to skip cleaning up ETL related entities within old UI
+ // Also to prevent an unnecessary call to /sources for existing UI
+ const isStorageV2 = useIsNewStorageUIEnabled()
+
+ const { can: canReadS3Credentials } = useAsyncCheckPermissions(
+ PermissionAction.STORAGE_ADMIN_READ,
+ '*'
+ )
+
+ const { data: icebergWrapper, meta: icebergWrapperMeta } = useAnalyticsBucketWrapperInstance(
+ { bucketId },
+ { enabled: options.enabled }
+ )
+
+ const { data: s3AccessKeys } = useStorageCredentialsQuery(
+ { projectRef },
+ { enabled: canReadS3Credentials && options.enabled }
+ )
+ const s3AccessKey = (s3AccessKeys?.data ?? []).find(
+ (x) => x.description === getAnalyticsBucketS3KeyName(bucketId)
+ )
+
+ const { data: sourcesData } = useReplicationSourcesQuery(
+ { projectRef },
+ { enabled: isStorageV2 && options.enabled }
+ )
+ const sourceId = sourcesData?.sources.find((s) => s.name === projectRef)?.id
+
+ const { data: publications = [] } = useReplicationPublicationsQuery(
+ { projectRef, sourceId },
+ { enabled: options.enabled }
+ )
+ const publication = publications.find(
+ (p) => p.name === getAnalyticsBucketPublicationName(bucketId)
+ )
+
+ return { icebergWrapper, icebergWrapperMeta, s3AccessKey, publication }
+}
+
+export const useAnalyticsBucketDeleteCleanUp = () => {
+ const { mutateAsync: deleteFDW, isLoading: isDeletingWrapper } = useFDWDeleteMutation()
+
+ const { mutateAsync: deleteS3AccessKey, isLoading: isDeletingKey } =
+ useS3AccessKeyDeleteMutation()
+
+ const isDeleting = isDeletingWrapper || isDeletingKey
+
+ const mutateAsync = async ({
+ bucketId,
+ projectRef,
+ connectionString,
+ icebergWrapper,
+ icebergWrapperMeta,
+ s3AccessKey,
+ publication,
+ }: {
+ bucketId?: string
+ projectRef?: string
+ connectionString?: string
+ icebergWrapper?: FDW
+ icebergWrapperMeta?: WrapperMeta
+ s3AccessKey?: S3AccessKey
+ publication?: ReplicationPublication
+ }) => {
+ if (!!icebergWrapper && !!icebergWrapperMeta) {
+ await deleteFDW({
+ projectRef,
+ connectionString,
+ wrapper: icebergWrapper,
+ wrapperMeta: icebergWrapperMeta,
+ })
+ } else {
+ console.warn(`Unable to find and delete iceberg wrapper for ${bucketId}`)
+ }
+
+ if (!!s3AccessKey) {
+ await deleteS3AccessKey({ projectRef, id: s3AccessKey.id })
+ } else {
+ console.warn(`Unable to find and delete corresponding S3 access key for ${bucketId}`)
+ }
+
+ if (!!publication) {
+ // [TODO] Delete the publication
+ } else {
+ console.log(`Unable to find and delete corresponding publication for ${bucketId}`)
+ }
+ }
+
+ return { mutateAsync, isLoading: isDeleting }
+}
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketWrapperInstance.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketWrapperInstance.tsx
new file mode 100644
index 00000000000..409b4b8a85d
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketWrapperInstance.tsx
@@ -0,0 +1,44 @@
+import { snakeCase } from 'lodash'
+import { useMemo } from 'react'
+
+import { WRAPPER_HANDLERS } from 'components/interfaces/Integrations/Wrappers/Wrappers.constants'
+import {
+ getWrapperMetaForWrapper,
+ wrapperMetaComparator,
+} from 'components/interfaces/Integrations/Wrappers/Wrappers.utils'
+import { useFDWsQuery } from 'data/fdw/fdws-query'
+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+
+export const useAnalyticsBucketWrapperInstance = (
+ { bucketId }: { bucketId: string },
+ options?: { enabled?: boolean }
+) => {
+ const { data: project, isLoading: isLoadingProject } = useSelectedProjectQuery()
+
+ const { data, isLoading: isLoadingFDWs } = useFDWsQuery(
+ {
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ },
+ options
+ )
+
+ const icebergWrapper = useMemo(() => {
+ return data
+ ?.filter((wrapper) =>
+ wrapperMetaComparator(
+ { handlerName: WRAPPER_HANDLERS.ICEBERG, server: { options: [] } },
+ wrapper
+ )
+ )
+ .find((w) => w.name === snakeCase(`${bucketId}_fdw`))
+ }, [data, bucketId])
+
+ const icebergWrapperMeta = getWrapperMetaForWrapper(icebergWrapper)
+
+ return {
+ data: icebergWrapper,
+ meta: icebergWrapperMeta,
+ isLoading: isLoadingProject || isLoadingFDWs,
+ }
+}
diff --git a/apps/studio/components/interfaces/Storage/AnalyticBucketDetails/useIcebergWrapper.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useIcebergWrapper.tsx
similarity index 100%
rename from apps/studio/components/interfaces/Storage/AnalyticBucketDetails/useIcebergWrapper.tsx
rename to apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useIcebergWrapper.tsx
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBuckets.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets.tsx
index 3071838300e..84abf828ce6 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBuckets.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets.tsx
@@ -6,7 +6,7 @@ import { useState } from 'react'
import { useParams } from 'common'
import { ScaffoldHeader, ScaffoldSection, ScaffoldSectionTitle } from 'components/layouts/Scaffold'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
-import { Bucket, useBucketsQuery } from 'data/storage/buckets-query'
+import { AnalyticsBucket, useAnalyticsBucketsQuery } from 'data/storage/analytics-buckets-query'
import {
Button,
Card,
@@ -31,19 +31,17 @@ export const AnalyticsBuckets = () => {
const router = useRouter()
const { ref } = useParams()
- const [modal, setModal] = useState<'edit' | 'empty' | 'delete' | null>(null)
- const [selectedBucket, setSelectedBucket] = useState<Bucket>()
const [filterString, setFilterString] = useState('')
+ const [selectedBucket, setSelectedBucket] = useState<AnalyticsBucket>()
+ const [modal, setModal] = useState<'edit' | 'empty' | 'delete' | null>(null)
- const { data: buckets = [], isLoading: isLoadingBuckets } = useBucketsQuery({ projectRef: ref })
+ const { data: buckets = [], isLoading: isLoadingBuckets } = useAnalyticsBucketsQuery({
+ projectRef: ref,
+ })
- const analyticsBuckets = buckets
- .filter((bucket) => !('type' in bucket) || bucket.type === 'ANALYTICS')
- .filter((bucket) =>
- filterString.length === 0
- ? true
- : bucket.name.toLowerCase().includes(filterString.toLowerCase())
- )
+ const analyticsBuckets = buckets.filter((bucket) =>
+ filterString.length === 0 ? true : bucket.id.toLowerCase().includes(filterString.toLowerCase())
+ )
return (
<>
@@ -87,7 +85,7 @@ export const AnalyticsBuckets = () => {
</TableHeader>
<TableBody>
{analyticsBuckets.length === 0 && filterString.length > 0 && (
- <TableRow>
+ <TableRow className="[&>td]:hover:bg-inherit">
<TableCell colSpan={3}>
<p className="text-sm text-foreground">No results found</p>
<p className="text-sm text-foreground-light">
@@ -97,17 +95,9 @@ export const AnalyticsBuckets = () => {
</TableRow>
)}
{analyticsBuckets.map((bucket) => (
- <TableRow
- key={bucket.id}
- className="cursor-pointer"
- onClick={(event) => {
- const url = `/project/${ref}/storage/analytics/buckets/${bucket.id}`
- if (event.metaKey) window.open(url, '_blank')
- else router.push(url)
- }}
- >
+ <TableRow key={bucket.id}>
<TableCell>
- <p className="text-foreground">{bucket.name}</p>
+ <p className="text-foreground">{bucket.id}</p>
</TableCell>
<TableCell>
@@ -124,25 +114,18 @@ export const AnalyticsBuckets = () => {
<Button asChild type="default">
<Link
href={`/project/${ref}/storage/analytics/buckets/${encodeURIComponent(bucket.id)}`}
- onClick={(e) => e.stopPropagation()}
>
View contents
</Link>
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button
- type="default"
- className="px-1"
- icon={<MoreVertical />}
- onClick={(e) => e.stopPropagation()}
- />
+ <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={(e) => {
- e.stopPropagation()
setModal('delete')
setSelectedBucket(bucket)
}}
@@ -165,7 +148,7 @@ export const AnalyticsBuckets = () => {
{selectedBucket && (
<DeleteBucketModal
- visible={modal === `delete`}
+ visible={modal === 'delete'}
bucket={selectedBucket}
onClose={() => setModal(null)}
/>
diff --git a/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx b/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx
index 6f5171d26be..e045aaaf671 100644
--- a/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx
+++ b/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx
@@ -9,7 +9,7 @@ import { toast } from 'sonner'
import z from 'zod'
import { useParams } from 'common'
-import { useIcebergWrapperExtension } from 'components/interfaces/Storage/AnalyticBucketDetails/useIcebergWrapper'
+import { useIcebergWrapperExtension } from 'components/interfaces/Storage/AnalyticsBucketDetails/useIcebergWrapper'
import { StorageSizeUnits } from 'components/interfaces/Storage/StorageSettings/StorageSettings.constants'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import { InlineLink } from 'components/ui/InlineLink'
diff --git a/apps/studio/components/interfaces/Storage/CreateSpecializedBucketModal.tsx b/apps/studio/components/interfaces/Storage/CreateSpecializedBucketModal.tsx
index d5cb4444dd4..7bfffb2222a 100644
--- a/apps/studio/components/interfaces/Storage/CreateSpecializedBucketModal.tsx
+++ b/apps/studio/components/interfaces/Storage/CreateSpecializedBucketModal.tsx
@@ -12,7 +12,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import { InlineLink } from 'components/ui/InlineLink'
import { useProjectStorageConfigQuery } from 'data/config/project-storage-config-query'
import { useDatabaseExtensionEnableMutation } from 'data/database-extensions/database-extension-enable-mutation'
-import { useBucketCreateMutation } from 'data/storage/bucket-create-mutation'
+import { useAnalyticsBucketCreateMutation } from 'data/storage/analytics-bucket-create-mutation'
import { useIcebergWrapperCreateMutation } from 'data/storage/iceberg-wrapper-create-mutation'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
@@ -37,7 +37,7 @@ import {
} from 'ui'
import { Admonition } from 'ui-patterns'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
-import { useIcebergWrapperExtension } from './AnalyticBucketDetails/useIcebergWrapper'
+import { useIcebergWrapperExtension } from './AnalyticsBucketDetails/useIcebergWrapper'
import { inverseValidBucketNameRegex, validBucketNameRegex } from './CreateBucketModal.utils'
import { BUCKET_TYPES } from './Storage.constants'
@@ -110,23 +110,25 @@ export const CreateSpecializedBucketModal = ({
const icebergCatalogEnabled = data?.features?.icebergCatalog?.enabled
const { mutate: sendEvent } = useSendEventMutation()
- const { mutateAsync: createBucket, isLoading: isCreatingBucket } = useBucketCreateMutation({
- // [Joshen] Silencing the error here as it's being handled in onSubmit
- onError: () => {},
- })
+
+ const { mutateAsync: createAnalyticsBucket, isLoading: isCreatingAnalyticsBucket } =
+ useAnalyticsBucketCreateMutation({
+ // [Joshen] Silencing the error here as it's being handled in onSubmit
+ onError: () => {},
+ })
+
const { mutateAsync: createIcebergWrapper, isLoading: isCreatingIcebergWrapper } =
useIcebergWrapperCreateMutation()
+
const { mutateAsync: enableExtension, isLoading: isEnablingExtension } =
useDatabaseExtensionEnableMutation()
const config = BUCKET_TYPES['analytics']
- const isCreating = isCreatingBucket || isEnablingExtension || isCreatingIcebergWrapper
+ const isCreating = isEnablingExtension || isCreatingIcebergWrapper || isCreatingAnalyticsBucket
const form = useForm<CreateSpecializedBucketForm>({
resolver: zodResolver(FormSchema),
- defaultValues: {
- name: '',
- },
+ defaultValues: { name: '' },
})
const onSubmit: SubmitHandler<CreateSpecializedBucketForm> = async (values) => {
@@ -149,43 +151,39 @@ export const CreateSpecializedBucketModal = ({
)
}
- // Determine bucket type based on the bucketType prop
- // [Danny] Change STANDARD to VECTORS when ready
- const bucketTypeValue = bucketType === 'analytics' ? 'ANALYTICS' : 'STANDARD'
-
try {
- await createBucket({
- projectRef: ref,
- id: values.name,
- type: bucketTypeValue,
- isPublic: false, // Specialized buckets are not public by default
- file_size_limit: undefined, // Specialized buckets do not have a file size limit
- allowed_mime_types: undefined, // Specialized buckets do not have allowed MIME types
- })
+ if (bucketType === 'analytics') {
+ 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
+ }
sendEvent({
action: 'storage_bucket_created',
- properties: { bucketType: bucketTypeValue },
+ properties: { bucketType },
groups: { project: ref ?? 'Unknown', organization: org?.slug ?? 'Unknown' },
})
- 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 })
- }
-
toast.success(`Created bucket “${values.name}”`)
form.reset()
setVisible(false)
- router.push(`/project/${ref}/storage/${bucketType}/${values.name}`)
+ router.push(`/project/${ref}/storage/${bucketType}/buckets/${values.name}`)
} catch (error: any) {
toast.error(`Failed to create bucket: ${error.message}`)
}
diff --git a/apps/studio/components/interfaces/Storage/DeleteBucketModal.tsx b/apps/studio/components/interfaces/Storage/DeleteBucketModal.tsx
index 5099a03e181..8f6d3124025 100644
--- a/apps/studio/components/interfaces/Storage/DeleteBucketModal.tsx
+++ b/apps/studio/components/interfaces/Storage/DeleteBucketModal.tsx
@@ -8,6 +8,8 @@ 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'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
@@ -27,11 +29,16 @@ import {
} from 'ui'
import { Admonition } from 'ui-patterns'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+import { useIsNewStorageUIEnabled } from '../App/FeaturePreview/FeaturePreviewContext'
+import {
+ useAnalyticsBucketAssociatedEntities,
+ useAnalyticsBucketDeleteCleanUp,
+} from './AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities'
import { formatPoliciesForStorage } from './Storage.utils'
export interface DeleteBucketModalProps {
visible: boolean
- bucket: Bucket
+ bucket: Bucket | AnalyticsBucket
onClose: () => void
}
@@ -41,10 +48,13 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
const router = useRouter()
const { ref: projectRef } = useParams()
const { data: project } = useSelectedProjectQuery()
+ const isStorageV2 = useIsNewStorageUIEnabled()
+
+ const isStandardBucketSelected = 'type' in bucket && bucket.type === 'STANDARD'
const schema = z.object({
- confirm: z.literal(bucket.name, {
- errorMap: () => ({ message: `Please enter "${bucket.name}" to confirm` }),
+ confirm: z.literal(bucket.id, {
+ errorMap: () => ({ message: `Please enter "${bucket.id}" to confirm` }),
}),
})
@@ -53,14 +63,23 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
})
const { data } = useBucketsQuery({ projectRef })
+ const buckets = data ?? []
+
const { data: policies } = useDatabasePoliciesQuery({
projectRef: project?.ref,
connectionString: project?.connectionString,
schema: 'storage',
})
+
+ const { icebergWrapper, icebergWrapperMeta, s3AccessKey, publication } =
+ useAnalyticsBucketAssociatedEntities(
+ { projectRef, bucketId: bucket.id },
+ { enabled: !isStandardBucketSelected }
+ )
+
const { mutateAsync: deletePolicy } = useDatabasePolicyDeleteMutation()
- const { mutate: deleteBucket, isLoading } = useBucketDeleteMutation({
+ const { mutate: deleteBucket, isLoading: isDeletingBucket } = useBucketDeleteMutation({
onSuccess: async () => {
if (!project) return console.error('Project is required')
@@ -71,7 +90,7 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
storageObjectsPolicies
)
const bucketPolicies = _get(
- find(formattedStorageObjectPolicies, { name: bucket.name }),
+ find(formattedStorageObjectPolicies, { name: bucket.id }),
['policies'],
[]
)
@@ -87,25 +106,64 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
)
)
- toast.success(`Successfully deleted bucket ${bucket.name}`)
- router.push(`/project/${projectRef}/storage/buckets`)
+ toast.success(`Successfully deleted bucket ${bucket.id}`)
+ if (isStorageV2) {
+ router.push(`/project/${projectRef}/storage/files`)
+ } else {
+ router.push(`/project/${projectRef}/storage/buckets`)
+ }
onClose()
} catch (error) {
toast.success(
- `Successfully deleted bucket ${bucket.name}. However, there was a problem deleting the policies tied to the bucket. Please review them in the storage policies section`
+ `Successfully deleted bucket ${bucket.id}. However, there was a problem deleting the policies tied to the bucket. Please review them in the storage policies section`
)
}
},
})
- const buckets = data ?? []
+ const { mutateAsync: deleteAnalyticsBucketCleanUp, isLoading: isCleaningUpAnalyticsBucket } =
+ useAnalyticsBucketDeleteCleanUp()
+
+ const { mutate: deleteAnalyticsBucket, isLoading: isDeletingAnalyticsBucket } =
+ useAnalyticsBucketDeleteMutation({
+ onSuccess: async () => {
+ await deleteAnalyticsBucketCleanUp({
+ projectRef,
+ bucketId: bucket.id,
+ icebergWrapper,
+ icebergWrapperMeta,
+ s3AccessKey,
+ publication,
+ })
+
+ toast.success(`Successfully deleted analytics bucket ${bucket.id}`)
+ if (isStorageV2) {
+ router.push(`/project/${projectRef}/storage/analytics`)
+ } else {
+ router.push(`/project/${projectRef}/storage/buckets`)
+ }
+ 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')
- deleteBucket({ projectRef, id: bucket.id, type: bucket.type })
+
+ // [Joshen] We'll need a third case to figure out for vector buckets
+ if (isStandardBucketSelected) {
+ deleteBucket({ projectRef, id: bucket.id })
+ } else {
+ if (isStorageV2) {
+ deleteAnalyticsBucket({ projectRef, id: bucket.id })
+ } else {
+ deleteBucket({ projectRef, id: bucket.id })
+ }
+ }
}
+ const isDeleting = isDeletingBucket || isDeletingAnalyticsBucket || isCleaningUpAnalyticsBucket
+
return (
<Dialog
open={visible}
@@ -115,7 +173,7 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
>
<DialogContent>
<DialogHeader>
- <DialogTitle>Confirm deletion of {bucket.name}</DialogTitle>
+ <DialogTitle>Confirm deletion of {bucket.id}</DialogTitle>
</DialogHeader>
<DialogSectionSeparator />
@@ -129,7 +187,7 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
<DialogSection>
<p className="text-sm">
- Your bucket <span className="font-bold text-foreground">{bucket.name}</span> and all its
+ Your bucket <span className="font-bold text-foreground">{bucket.id}</span> and all its
contents will be permanently deleted.
</p>
</DialogSection>
@@ -146,7 +204,7 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
name="confirm"
label={
<>
- Type <span className="font-bold text-foreground">{bucket.name}</span> to
+ Type <span className="font-bold text-foreground">{bucket.id}</span> to
confirm.
</>
}
@@ -166,10 +224,10 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
</Form_Shadcn_>
</DialogSection>
<DialogFooter>
- <Button type="default" disabled={isLoading} onClick={onClose}>
+ <Button type="default" disabled={isDeleting} onClick={onClose}>
Cancel
</Button>
- <Button form={formId} htmlType="submit" type="danger" loading={isLoading}>
+ <Button form={formId} htmlType="submit" type="danger" loading={isDeleting}>
Delete bucket
</Button>
</DialogFooter>
diff --git a/apps/studio/components/interfaces/Storage/FilesBuckets.tsx b/apps/studio/components/interfaces/Storage/FilesBuckets.tsx
index 1f04b7f6104..a628ce5b465 100644
--- a/apps/studio/components/interfaces/Storage/FilesBuckets.tsx
+++ b/apps/studio/components/interfaces/Storage/FilesBuckets.tsx
@@ -92,7 +92,7 @@ export const FilesBuckets = () => {
</TableHeader>
<TableBody>
{filesBuckets.length === 0 && filterString.length > 0 && (
- <TableRow>
+ <TableRow className="[&>td]:hover:bg-inherit">
<TableCell colSpan={3}>
<p className="text-sm text-foreground">No results found</p>
<p className="text-sm text-foreground-light">
@@ -102,15 +102,7 @@ export const FilesBuckets = () => {
</TableRow>
)}
{filesBuckets.map((bucket) => (
- <TableRow
- key={bucket.id}
- className="cursor-pointer"
- onClick={(event) => {
- const url = `/project/${ref}/storage/files/buckets/${bucket.id}`
- if (event.metaKey) window.open(url, '_blank')
- else router.push(url)
- }}
- >
+ <TableRow key={bucket.id}>
<TableCell>
<div className="flex items-center gap-2">
<p className="text-foreground">{bucket.name}</p>
@@ -153,25 +145,18 @@ export const FilesBuckets = () => {
<Button asChild type="default">
<Link
href={`/project/${ref}/storage/files/buckets/${encodeURIComponent(bucket.id)}`}
- onClick={(e) => e.stopPropagation()}
>
View files
</Link>
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button
- type="default"
- className="px-1"
- icon={<MoreVertical />}
- onClick={(e) => e.stopPropagation()}
- />
+ <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={(e) => {
- e.stopPropagation()
setModal('edit')
setSelectedBucket(bucket)
}}
@@ -183,7 +168,6 @@ export const FilesBuckets = () => {
<DropdownMenuItem
className="flex items-center space-x-2"
onClick={(e) => {
- e.stopPropagation()
setModal('empty')
setSelectedBucket(bucket)
}}
@@ -195,7 +179,6 @@ export const FilesBuckets = () => {
<DropdownMenuItem
className="flex items-center space-x-2"
onClick={(e) => {
- e.stopPropagation()
setModal('delete')
setSelectedBucket(bucket)
}}
diff --git a/apps/studio/components/interfaces/Storage/ImportForeignSchemaDialog.tsx b/apps/studio/components/interfaces/Storage/ImportForeignSchemaDialog.tsx
index 869f88b7f04..6efe28e4835 100644
--- a/apps/studio/components/interfaces/Storage/ImportForeignSchemaDialog.tsx
+++ b/apps/studio/components/interfaces/Storage/ImportForeignSchemaDialog.tsx
@@ -12,7 +12,7 @@ import { useFDWImportForeignSchemaMutation } from 'data/fdw/fdw-import-foreign-s
import { useFDWUpdateMutation } from 'data/fdw/fdw-update-mutation'
import { getFDWs } from 'data/fdw/fdws-query'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
-import { Button, Form_Shadcn_, FormField_Shadcn_, Input_Shadcn_, Modal } from 'ui'
+import { Button, Form_Shadcn_, FormField_Shadcn_, Input_Shadcn_, Modal, Separator } from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import type { WrapperMeta } from '../Integrations/Wrappers/Wrappers.types'
import { formatWrapperTables } from '../Integrations/Wrappers/Wrappers.utils'
@@ -23,6 +23,7 @@ export interface ImportForeignSchemaDialogProps {
bucketName: string
namespace: string
wrapperMeta: WrapperMeta
+ circumstance?: 'fresh' | 'clash'
visible: boolean
onClose: () => void
}
@@ -33,6 +34,7 @@ export const ImportForeignSchemaDialog = ({
wrapperMeta,
visible,
onClose,
+ circumstance = 'fresh',
}: ImportForeignSchemaDialogProps) => {
const { data: project } = useSelectedProjectQuery()
const { ref } = useParams()
@@ -42,7 +44,7 @@ export const ImportForeignSchemaDialog = ({
const { mutateAsync: importForeignSchema } = useFDWImportForeignSchemaMutation({})
const { mutateAsync: updateFDW } = useFDWUpdateMutation({
onSuccess: () => {
- toast.success(`Successfully connected ${bucketName} to the database.`)
+ toast.success(`Successfully connected “${bucketName}” to the database.`)
onClose()
},
})
@@ -158,20 +160,27 @@ export const ImportForeignSchemaDialog = ({
hideFooter
visible={visible}
size="medium"
- header={<span>Connect namespace "{namespace}"</span>}
+ header={<span>Create target schema</span>}
onCancel={() => onClose()}
>
<Form_Shadcn_ {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
<Modal.Content className="flex flex-col gap-y-4">
+ <p className="text-sm">
+ Namespace “<strong>{namespace}</strong>”{' '}
+ {circumstance === 'fresh'
+ ? 'must be linked to a new schema before tables can be paired.'
+ : 'clashes with an existing database schema. Create a new schema to use as the destination for this data.'}
+ </p>
+ <Separator />
<FormField_Shadcn_
control={form.control}
name="targetSchema"
render={({ field }) => (
<FormItemLayout
layout="vertical"
- label="Specify a new schema for where the Iceberg data will be accessible"
- description="A new schema will be created. For security purposes, the wrapper tables from the foreign schema cannot be created within an existing schema."
+ label="Target schema"
+ description="Where your analytics tables will be stored."
>
<Input_Shadcn_ {...field} placeholder="Enter schema name" />
</FormItemLayout>
@@ -184,7 +193,7 @@ export const ImportForeignSchemaDialog = ({
Cancel
</Button>
<Button type="primary" htmlType="submit" loading={loading}>
- Save
+ Create
</Button>
</Modal.Content>
</form>
diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/useSelectedBucket.ts b/apps/studio/components/interfaces/Storage/StorageExplorer/useSelectedBucket.ts
index ad340ad84d2..d8eba0f9e57 100644
--- a/apps/studio/components/interfaces/Storage/StorageExplorer/useSelectedBucket.ts
+++ b/apps/studio/components/interfaces/Storage/StorageExplorer/useSelectedBucket.ts
@@ -1,19 +1,41 @@
import { useParams } from 'common'
+import { useIsNewStorageUIEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { useAnalyticsBucketsQuery } from 'data/storage/analytics-buckets-query'
import { useBucketsQuery } from 'data/storage/buckets-query'
import { useStorageV2Page } from '../Storage.utils'
+// [Joshen] Adding isStorageV2 checks here to support the existing UI while API changes are not on prod just yet
+
export const useSelectedBucket = () => {
- const page = useStorageV2Page()
const { ref, bucketId } = useParams()
+ const isStorageV2 = useIsNewStorageUIEnabled()
+ const page = useStorageV2Page()
+
+ const {
+ data: analyticsBuckets = [],
+ isSuccess: isSuccessAnalyticsBuckets,
+ isError: isErrorAnalyticsBuckets,
+ error: errorAnalyticsBuckets,
+ } = useAnalyticsBucketsQuery({ projectRef: ref }, { enabled: isStorageV2 })
+
+ const {
+ data: buckets = [],
+ isSuccess: isSuccessBuckets,
+ isError: isErrorBuckets,
+ error: errorBuckets,
+ } = useBucketsQuery({ projectRef: ref })
+
+ const isSuccess = isStorageV2 ? isSuccessBuckets && isSuccessAnalyticsBuckets : isSuccessBuckets
+ const isError = isStorageV2 ? isErrorBuckets || isErrorAnalyticsBuckets : isErrorBuckets
+ const error = isStorageV2 ? errorBuckets || errorAnalyticsBuckets : errorBuckets
- const { data: buckets = [], isSuccess, isError, error } = useBucketsQuery({ projectRef: ref })
- const bucketsByType =
+ const bucket =
page === 'files'
- ? buckets.filter((b) => b.type === 'STANDARD')
+ ? buckets.find((b) => b.id === bucketId)
: page === 'analytics'
- ? buckets.filter((b) => b.type === 'ANALYTICS')
- : buckets
- const bucket = bucketsByType.find((b) => b.id === bucketId)
+ ? analyticsBuckets.find((b) => b.id === bucketId)
+ : // [Joshen] Temp fallback to buckets for backwards compatibility old UI
+ buckets.find((b) => b.id === bucketId)
return { bucket, isSuccess, isError, error }
}
diff --git a/apps/studio/components/interfaces/Storage/StorageSettings/RevokeCredentialModal.tsx b/apps/studio/components/interfaces/Storage/StorageSettings/RevokeCredentialModal.tsx
index 2d775349fc5..a310de9eb1d 100644
--- a/apps/studio/components/interfaces/Storage/StorageSettings/RevokeCredentialModal.tsx
+++ b/apps/studio/components/interfaces/Storage/StorageSettings/RevokeCredentialModal.tsx
@@ -34,7 +34,7 @@ export const RevokeCredentialModal = ({
})
return (
- <Dialog open={visible}>
+ <Dialog open={visible} onOpenChange={onClose}>
<DialogContent size="small">
<DialogHeader>
<DialogTitle>
diff --git a/apps/studio/components/interfaces/Storage/__tests__/DeleteBucketModal.test.tsx b/apps/studio/components/interfaces/Storage/__tests__/DeleteBucketModal.test.tsx
index 4f173c4a520..ed7f36359b3 100644
--- a/apps/studio/components/interfaces/Storage/__tests__/DeleteBucketModal.test.tsx
+++ b/apps/studio/components/interfaces/Storage/__tests__/DeleteBucketModal.test.tsx
@@ -12,8 +12,8 @@ import { routerMock } from 'tests/lib/route-mock'
import { DeleteBucketModal } from '../DeleteBucketModal'
const bucket: Bucket = {
- id: faker.string.uuid(),
- name: `test`,
+ id: 'test',
+ name: 'test',
owner: faker.string.uuid(),
public: faker.datatype.boolean(),
allowed_mime_types: faker.helpers.multiple(() => faker.system.mimeType(), {
diff --git a/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx b/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx
index 10057b90760..81be39cbbad 100644
--- a/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx
+++ b/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx
@@ -25,6 +25,8 @@ const StorageLayout = ({ title, children }: StorageLayoutProps) => {
const { pathname } = router
const suffix = !!featurePreviewModal ? `?featurePreviewModal=${featurePreviewModal}` : ''
+ if (!ref) return
+
if (isStorageV2) {
// From old UI to new UI
if (pathname.endsWith('/storage/settings')) {
@@ -58,7 +60,7 @@ const StorageLayout = ({ title, children }: StorageLayoutProps) => {
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [isStorageV2])
+ }, [ref, isStorageV2])
return (
<ProjectLayout
diff --git a/apps/studio/data/fdw/fdw-delete-mutation.ts b/apps/studio/data/fdw/fdw-delete-mutation.ts
index 48c9fa56ab6..3f3a73fbd51 100644
--- a/apps/studio/data/fdw/fdw-delete-mutation.ts
+++ b/apps/studio/data/fdw/fdw-delete-mutation.ts
@@ -12,7 +12,7 @@ import { FDW } from './fdws-query'
import { fdwKeys } from './keys'
export type FDWDeleteVariables = {
- projectRef: string
+ projectRef?: string
connectionString?: string | null
wrapper: FDW
wrapperMeta: WrapperMeta
diff --git a/apps/studio/data/replication/publication-delete-mutation.ts b/apps/studio/data/replication/publication-delete-mutation.ts
new file mode 100644
index 00000000000..f1fca52927a
--- /dev/null
+++ b/apps/studio/data/replication/publication-delete-mutation.ts
@@ -0,0 +1,65 @@
+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
+import { toast } from 'sonner'
+
+import { del, handleError } from 'data/fetchers'
+import type { ResponseError } from 'types'
+import { replicationKeys } from './keys'
+
+export type DeletePublicationParams = {
+ projectRef: string
+ sourceId: number
+ publicationName: string
+}
+
+async function deletePublication(
+ { projectRef, sourceId, publicationName }: DeletePublicationParams,
+ signal?: AbortSignal
+) {
+ if (!projectRef) throw new Error('projectRef is required')
+
+ const { data, error } = await del(
+ '/platform/replication/{ref}/sources/{source_id}/publications/{publication_name}',
+ {
+ params: {
+ path: {
+ ref: projectRef,
+ source_id: sourceId,
+ publication_name: publicationName,
+ },
+ },
+ signal,
+ }
+ )
+ if (error) handleError(error)
+ return data
+}
+
+type DeletePublicationData = Awaited<ReturnType<typeof deletePublication>>
+
+export const useDeletePublicationMutation = ({
+ onSuccess,
+ onError,
+ ...options
+}: Omit<
+ UseMutationOptions<DeletePublicationData, ResponseError, DeletePublicationParams>,
+ 'mutationFn'
+> = {}) => {
+ const queryClient = useQueryClient()
+
+ return useMutation<DeletePublicationData, ResponseError, DeletePublicationParams>({
+ mutationFn: (vars) => deletePublication(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef, sourceId } = variables
+ await queryClient.invalidateQueries(replicationKeys.publications(projectRef, sourceId))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to delete publication: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
+}
diff --git a/apps/studio/data/replication/publications-query.ts b/apps/studio/data/replication/publications-query.ts
index 576424cd09a..8a10561946b 100644
--- a/apps/studio/data/replication/publications-query.ts
+++ b/apps/studio/data/replication/publications-query.ts
@@ -1,11 +1,15 @@
import { UseQueryOptions, useQuery } from '@tanstack/react-query'
+import { components } from 'api-types'
import { get, handleError } from 'data/fetchers'
import { ResponseError } from 'types'
import { replicationKeys } from './keys'
type ReplicationPublicationsParams = { projectRef?: string; sourceId?: number }
+export type ReplicationPublication =
+ components['schemas']['ReplicationPublicationsResponse']['publications'][number]
+
async function fetchReplicationPublications(
{ projectRef, sourceId }: ReplicationPublicationsParams,
signal?: AbortSignal
diff --git a/apps/studio/data/storage/analytics-bucket-create-mutation.ts b/apps/studio/data/storage/analytics-bucket-create-mutation.ts
new file mode 100644
index 00000000000..5b7479970c6
--- /dev/null
+++ b/apps/studio/data/storage/analytics-bucket-create-mutation.ts
@@ -0,0 +1,56 @@
+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
+import { toast } from 'sonner'
+
+import { components } from 'api-types'
+import { handleError, post } from 'data/fetchers'
+import type { ResponseError } from 'types'
+import { storageKeys } from './keys'
+
+type AnalyticsBucketCreateVariables = CreateAnalyticsBucketBody & {
+ projectRef: string
+}
+
+type CreateAnalyticsBucketBody = components['schemas']['CreateStorageAnalyticsBucketBody']
+
+async function createAnalyticsBucket({ projectRef, bucketName }: AnalyticsBucketCreateVariables) {
+ 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}/analytics-buckets', {
+ params: { path: { ref: projectRef } },
+ body: { bucketName },
+ })
+
+ if (error) handleError(error)
+ return data
+}
+
+type AnalyticsBucketCreateData = Awaited<ReturnType<typeof createAnalyticsBucket>>
+
+export const useAnalyticsBucketCreateMutation = ({
+ onSuccess,
+ onError,
+ ...options
+}: Omit<
+ UseMutationOptions<AnalyticsBucketCreateData, ResponseError, AnalyticsBucketCreateVariables>,
+ 'mutationFn'
+> = {}) => {
+ const queryClient = useQueryClient()
+
+ return useMutation<AnalyticsBucketCreateData, ResponseError, AnalyticsBucketCreateVariables>({
+ mutationFn: (vars) => createAnalyticsBucket(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(storageKeys.analyticsBuckets(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to create analytics bucket: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
+}
diff --git a/apps/studio/data/storage/analytics-bucket-delete-mutation.ts b/apps/studio/data/storage/analytics-bucket-delete-mutation.ts
new file mode 100644
index 00000000000..4adc67fd946
--- /dev/null
+++ b/apps/studio/data/storage/analytics-bucket-delete-mutation.ts
@@ -0,0 +1,59 @@
+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
+import { toast } from 'sonner'
+
+import { useIsNewStorageUIEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { del, handleError } from 'data/fetchers'
+import type { ResponseError } from 'types'
+import { storageKeys } from './keys'
+
+type AnalyticsBucketDeleteVariables = {
+ projectRef: string
+ id: string
+}
+
+async function deleteAnalyticsBucket({ projectRef, id }: AnalyticsBucketDeleteVariables) {
+ if (!projectRef) throw new Error('projectRef is required')
+ if (!id) throw new Error('Bucket name is requried')
+
+ const { data, error } = await del('/platform/storage/{ref}/analytics-buckets/{id}', {
+ params: { path: { ref: projectRef, id } },
+ } as any)
+
+ if (error) handleError(error)
+ return data
+}
+
+type AnalyticsBucketDeleteData = Awaited<ReturnType<typeof deleteAnalyticsBucket>>
+
+export const useAnalyticsBucketDeleteMutation = ({
+ onSuccess,
+ onError,
+ ...options
+}: Omit<
+ UseMutationOptions<AnalyticsBucketDeleteData, ResponseError, AnalyticsBucketDeleteVariables>,
+ 'mutationFn'
+> = {}) => {
+ const queryClient = useQueryClient()
+ const isStorageV2 = useIsNewStorageUIEnabled()
+
+ return useMutation<AnalyticsBucketDeleteData, ResponseError, AnalyticsBucketDeleteVariables>({
+ mutationFn: (vars) => deleteAnalyticsBucket(vars),
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ if (isStorageV2) {
+ await queryClient.invalidateQueries(storageKeys.analyticsBuckets(projectRef))
+ } else {
+ await queryClient.invalidateQueries(storageKeys.buckets(projectRef))
+ }
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to delete analytics bucket: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ })
+}
diff --git a/apps/studio/data/storage/analytics-buckets-query.ts b/apps/studio/data/storage/analytics-buckets-query.ts
new file mode 100644
index 00000000000..4f3cb05f787
--- /dev/null
+++ b/apps/studio/data/storage/analytics-buckets-query.ts
@@ -0,0 +1,64 @@
+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 AnalyticsBucketsVariables = { projectRef?: string }
+export type AnalyticsBucket = components['schemas']['StorageAnalyticsBucketResponse']
+export type AnalyticsBuckets = components['schemas'][]
+
+export async function getAnalyticsBuckets(
+ { projectRef }: AnalyticsBucketsVariables,
+ signal?: AbortSignal
+) {
+ if (!projectRef) throw new Error('projectRef is required')
+
+ const { data, error } = await get('/platform/storage/{ref}/analytics-buckets', {
+ params: { path: { ref: projectRef } },
+ signal,
+ })
+
+ if (error) handleError(error)
+ return data.data
+}
+
+export type AnalyticsBucketsData = Awaited<ReturnType<typeof getAnalyticsBuckets>>
+export type AnalyticsBucketsError = ResponseError
+
+export const useAnalyticsBucketsQuery = <TData = AnalyticsBucketsData>(
+ { projectRef }: AnalyticsBucketsVariables,
+ {
+ enabled = true,
+ ...options
+ }: UseQueryOptions<AnalyticsBucketsData, AnalyticsBucketsError, TData> = {}
+) => {
+ const { data: project } = useSelectedProjectQuery()
+ const isActive = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY
+
+ return useQuery<AnalyticsBucketsData, AnalyticsBucketsError, TData>({
+ queryKey: storageKeys.analyticsBuckets(projectRef),
+ queryFn: ({ signal }) => getAnalyticsBuckets({ projectRef }, signal),
+ enabled: enabled && typeof projectRef !== 'undefined' && isActive,
+ ...options,
+ retry: (failureCount, error) => {
+ if (
+ typeof error === 'object' &&
+ error !== null &&
+ error.message.startsWith('Tenant config') &&
+ error.message.endsWith('not found')
+ ) {
+ return false
+ }
+
+ if (failureCount < 3) {
+ return true
+ }
+
+ return false
+ },
+ })
+}
diff --git a/apps/studio/data/storage/bucket-delete-mutation.ts b/apps/studio/data/storage/bucket-delete-mutation.ts
index 77f2db79911..7586d152453 100644
--- a/apps/studio/data/storage/bucket-delete-mutation.ts
+++ b/apps/studio/data/storage/bucket-delete-mutation.ts
@@ -3,29 +3,26 @@ import { toast } from 'sonner'
import { del, handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
-import { BucketType } from './buckets-query'
import { storageKeys } from './keys'
type BucketDeleteVariables = {
projectRef: string
id: string
- type: BucketType
}
-async function deleteBucket({ projectRef, id, type }: BucketDeleteVariables) {
+async function deleteBucket({ projectRef, id }: BucketDeleteVariables) {
if (!projectRef) throw new Error('projectRef is required')
if (!id) throw new Error('Bucket name is requried')
- if (type !== 'ANALYTICS') {
- const { error: emptyBucketError } = await post('/platform/storage/{ref}/buckets/{id}/empty', {
- params: { path: { ref: projectRef, id } },
- })
- if (emptyBucketError) handleError(emptyBucketError)
- }
+ const { error: emptyBucketError } = await post('/platform/storage/{ref}/buckets/{id}/empty', {
+ params: { path: { ref: projectRef, id } },
+ })
+ if (emptyBucketError) handleError(emptyBucketError)
const { data, error: deleteBucketError } = await del('/platform/storage/{ref}/buckets/{id}', {
- params: { path: { ref: projectRef, id }, query: { type } },
+ params: { path: { ref: projectRef, id } },
} as any)
+
if (deleteBucketError) handleError(deleteBucketError)
return data
}
diff --git a/apps/studio/data/storage/buckets-query.ts b/apps/studio/data/storage/buckets-query.ts
index 0779e0d9f63..621e069d9d4 100644
--- a/apps/studio/data/storage/buckets-query.ts
+++ b/apps/studio/data/storage/buckets-query.ts
@@ -44,8 +44,7 @@ export const useBucketsQuery = <TData = BucketsData>(
if (
typeof error === 'object' &&
error !== null &&
- error.message.startsWith('Tenant config') &&
- error.message.endsWith('not found')
+ error.message.includes('Missing tenant config')
) {
return false
}
diff --git a/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts b/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts
index 56752fd6346..0b2c08edf97 100644
--- a/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts
+++ b/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts
@@ -1,7 +1,10 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { snakeCase } from 'lodash'
import { WRAPPERS } from 'components/interfaces/Integrations/Wrappers/Wrappers.constants'
+import {
+ getAnalyticsBucketFDWName,
+ getAnalyticsBucketS3KeyName,
+} from 'components/interfaces/Storage/AnalyticsBucketDetails/AnalyticsBucketDetails.utils'
import {
getCatalogURI,
getConnectionURL,
@@ -40,10 +43,10 @@ export const useIcebergWrapperCreateMutation = () => {
const mutateAsync = async ({ bucketName }: { bucketName: string }) => {
const createS3KeyData = await createS3AccessKey({
projectRef: project?.ref,
- description: `${snakeCase(bucketName)}_keys`,
+ description: getAnalyticsBucketS3KeyName(bucketName),
})
- const wrapperName = `${snakeCase(bucketName)}_fdw`
+ const wrapperName = getAnalyticsBucketFDWName(bucketName)
const params: FDWCreateVariables = {
projectRef: project?.ref,
diff --git a/apps/studio/data/storage/keys.ts b/apps/studio/data/storage/keys.ts
index e68911d547c..5d796b07b0d 100644
--- a/apps/studio/data/storage/keys.ts
+++ b/apps/studio/data/storage/keys.ts
@@ -1,5 +1,7 @@
export const storageKeys = {
buckets: (projectRef: string | undefined) => ['projects', projectRef, 'buckets'] as const,
+ analyticsBuckets: (projectRef: string | undefined) =>
+ ['projects', projectRef, 'analytics-buckets'] 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/s3-access-key-query.ts b/apps/studio/data/storage/s3-access-key-query.ts
index ffdc0243653..61adee253ac 100644
--- a/apps/studio/data/storage/s3-access-key-query.ts
+++ b/apps/studio/data/storage/s3-access-key-query.ts
@@ -1,12 +1,17 @@
import { UseQueryOptions, useQuery } from '@tanstack/react-query'
+import { components } from 'api-types'
import { get, handleError } from 'data/fetchers'
+import { IS_PLATFORM } from 'lib/constants'
import { ResponseError } from 'types'
import { storageCredentialsKeys } from './s3-access-key-keys'
-import { IS_PLATFORM } from 'lib/constants'
type StorageCredentialsVariables = { projectRef?: string }
+export type S3AccessKey = components['schemas']['GetStorageCredentialsResponse']['data'][number] & {
+ access_key: string
+}
+
async function fetchStorageCredentials(
{ projectRef }: StorageCredentialsVariables,
signal?: AbortSignal
@@ -19,16 +24,7 @@ async function fetchStorageCredentials(
})
if (error) handleError(error)
-
- // Generated types by openapi are wrong so we need to cast it.
- return data as unknown as {
- data: {
- id: string
- created_at: string
- access_key: string
- description: string
- }[]
- }
+ return data as { data: S3AccessKey[] }
}
export type StorageCredentialsData = Awaited<ReturnType<typeof fetchStorageCredentials>>
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 19e8e676817..7ea03e11ad7 100644
--- a/apps/studio/pages/project/[ref]/storage/analytics/buckets/[bucketId].tsx
+++ b/apps/studio/pages/project/[ref]/storage/analytics/buckets/[bucketId].tsx
@@ -1,13 +1,17 @@
-import { useParams } from 'common'
+import Link from 'next/link'
-import { AnalyticBucketDetails } from 'components/interfaces/Storage/AnalyticBucketDetails'
+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 DefaultLayout from 'components/layouts/DefaultLayout'
import StorageLayout from 'components/layouts/StorageLayout/StorageLayout'
+import { AnalyticsBucket } from 'data/storage/analytics-buckets-query'
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 { bucketId } = useParams()
@@ -16,23 +20,29 @@ const AnalyticsBucketPage: NextPageWithLayout = () => {
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 p-4">
+ <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">
- <p className="text-sm text-foreground-light">Bucket {bucketId} cannot be found</p>
+ <Admonition
+ className="max-w-md"
+ type="default"
+ title="Unable to find bucket"
+ description={`${bucketId ? `The template "${bucketId}"` : 'This template'} doesn’t seem to exist.`}
+ >
+ <Button asChild type="default" className="mt-2">
+ <Link href={`/project/${projectRef}/storage/analytics`}>Head back</Link>
+ </Button>
+ </Admonition>
</div>
- ) : bucket.type === 'ANALYTICS' ? (
- <AnalyticBucketDetails bucket={bucket} />
) : (
- <div className="flex h-full w-full items-center justify-center">
- <p className="text-sm text-foreground-light">This bucket is not an analytics bucket</p>
- </div>
+ <AnalyticBucketDetails bucket={bucket as AnalyticsBucket} />
)
) : null}
</div>
diff --git a/apps/studio/pages/project/[ref]/storage/buckets/[bucketId].tsx b/apps/studio/pages/project/[ref]/storage/buckets/[bucketId].tsx
index 241ecb1f31d..8965ff4b64e 100644
--- a/apps/studio/pages/project/[ref]/storage/buckets/[bucketId].tsx
+++ b/apps/studio/pages/project/[ref]/storage/buckets/[bucketId].tsx
@@ -1,11 +1,12 @@
import { useParams } from 'common'
-import { AnalyticBucketDetails } from 'components/interfaces/Storage/AnalyticBucketDetails'
+import { AnalyticBucketDetails } from 'components/interfaces/Storage/AnalyticsBucketDetails'
import StorageBucketsError from 'components/interfaces/Storage/StorageBucketsError'
import { StorageExplorer } from 'components/interfaces/Storage/StorageExplorer/StorageExplorer'
import { useSelectedBucket } from 'components/interfaces/Storage/StorageExplorer/useSelectedBucket'
import DefaultLayout from 'components/layouts/DefaultLayout'
import StorageLayout from 'components/layouts/StorageLayout/StorageLayout'
+import { AnalyticsBucket } from 'data/storage/analytics-buckets-query'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { useStorageExplorerStateSnapshot } from 'state/storage-explorer'
import type { NextPageWithLayout } from 'types'
@@ -29,7 +30,7 @@ const PageLayout: NextPageWithLayout = () => {
<p className="text-sm text-foreground-light">Bucket {bucketId} cannot be found</p>
</div>
) : bucket.type === 'ANALYTICS' ? (
- <AnalyticBucketDetails bucket={bucket} />
+ <AnalyticBucketDetails bucket={bucket as AnalyticsBucket} />
) : (
<StorageExplorer bucket={bucket} />
)
diff --git a/apps/studio/pages/project/[ref]/storage/files/buckets/[bucketId].tsx b/apps/studio/pages/project/[ref]/storage/files/buckets/[bucketId].tsx
index 40903b99a29..8a8b7416209 100644
--- a/apps/studio/pages/project/[ref]/storage/files/buckets/[bucketId].tsx
+++ b/apps/studio/pages/project/[ref]/storage/files/buckets/[bucketId].tsx
@@ -10,6 +10,7 @@ import { useSelectedBucket } from 'components/interfaces/Storage/StorageExplorer
import DefaultLayout from 'components/layouts/DefaultLayout'
import { PageLayout } from 'components/layouts/PageLayout/PageLayout'
import StorageLayout from 'components/layouts/StorageLayout/StorageLayout'
+import { Bucket } from 'data/storage/buckets-query'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { useStoragePolicyCounts } from 'hooks/storage/useStoragePolicyCounts'
import { useStorageExplorerStateSnapshot } from 'state/storage-explorer'
@@ -23,8 +24,8 @@ const BucketPage: NextPageWithLayout = () => {
const { bucket, error, isSuccess, isError } = useSelectedBucket()
const [showEditModal, setShowEditModal] = useState(false)
- const { getPolicyCount } = useStoragePolicyCounts(bucket ? [bucket] : [])
- const policyCount = bucket ? getPolicyCount(bucket.name) : 0
+ const { getPolicyCount } = useStoragePolicyCounts(bucket ? [bucket as Bucket] : [])
+ const policyCount = bucket ? getPolicyCount(bucket.id) : 0
// [Joshen] Checking against projectRef from storage explorer to check if the store has initialized
if (!project || !projectRef || !isSuccess) return null
diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.ts
index 1985673d9ae..89941bc713e 100644
--- a/packages/api-types/types/api.d.ts
+++ b/packages/api-types/types/api.d.ts
@@ -3086,6 +3086,7 @@ export interface components {
root_key: string
}
PostgresConfigResponse: {
+ checkpoint_timeout?: number
effective_cache_size?: string
hot_standby_feedback?: boolean
logical_decoding_work_mem?: string
@@ -3725,6 +3726,7 @@ export interface components {
root_key: string
}
UpdatePostgresConfigBody: {
+ checkpoint_timeout?: number
effective_cache_size?: string
hot_standby_feedback?: boolean
logical_decoding_work_mem?: string
diff --git a/packages/api-types/types/platform.d.ts b/packages/api-types/types/platform.d.ts
index bbc76eb612c..0137b18fe03 100644
--- a/packages/api-types/types/platform.d.ts
+++ b/packages/api-types/types/platform.d.ts
@@ -3867,6 +3867,41 @@ export interface paths {
patch?: never
trace?: never
}
+ '/platform/storage/{ref}/analytics-buckets': {
+ parameters: {
+ query?: never
+ header?: never
+ path?: never
+ cookie?: never
+ }
+ /** Gets list of analytics buckets */
+ get: operations['StorageAnalyticsBucketsController_getBuckets']
+ put?: never
+ /** Create an analytics bucket */
+ post: operations['StorageAnalyticsBucketsController_createBucket']
+ delete?: never
+ options?: never
+ head?: never
+ patch?: never
+ trace?: never
+ }
+ '/platform/storage/{ref}/analytics-buckets/{id}': {
+ parameters: {
+ query?: never
+ header?: never
+ path?: never
+ cookie?: never
+ }
+ get?: never
+ put?: never
+ post?: never
+ /** Deletes an analytics bucket */
+ delete: operations['StorageAnalyticsBucketIdController_deleteBucket']
+ options?: never
+ head?: never
+ patch?: never
+ trace?: never
+ }
'/platform/storage/{ref}/archive': {
parameters: {
query?: never
@@ -4127,6 +4162,77 @@ export interface paths {
patch?: never
trace?: never
}
+ '/platform/storage/{ref}/vector-buckets': {
+ parameters: {
+ query?: never
+ header?: never
+ path?: never
+ cookie?: never
+ }
+ /** Gets list of vector buckets */
+ get: operations['StorageVectorBucketsController_getBuckets']
+ put?: never
+ /** Create vector bucket */
+ post: operations['StorageVectorBucketsController_createBucket']
+ delete?: never
+ options?: never
+ head?: never
+ patch?: never
+ trace?: never
+ }
+ '/platform/storage/{ref}/vector-buckets/{id}': {
+ parameters: {
+ query?: never
+ header?: never
+ path?: never
+ cookie?: never
+ }
+ /** Gets bucket */
+ get: operations['StorageVectorBucketIdController_getBucket']
+ put?: never
+ post?: never
+ /** Deletes bucket */
+ delete: operations['StorageVectorBucketIdController_deleteBucket']
+ options?: never
+ head?: never
+ patch?: never
+ trace?: never
+ }
+ '/platform/storage/{ref}/vector-buckets/{id}/indexes': {
+ parameters: {
+ query?: never
+ header?: never
+ path?: never
+ cookie?: never
+ }
+ /** Gets bucket indexes */
+ get: operations['StorageVectorBucketIdIndexesController_getBucketIndexes']
+ put?: never
+ /** Create index in vector bucket */
+ post: operations['StorageVectorBucketIdIndexesController_createBucketIndex']
+ delete?: never
+ options?: never
+ head?: never
+ patch?: never
+ trace?: never
+ }
+ '/platform/storage/{ref}/vector-buckets/{id}/indexes/{indexName}': {
+ parameters: {
+ query?: never
+ header?: never
+ path?: never
+ cookie?: never
+ }
+ get?: never
+ put?: never
+ post?: never
+ /** Deletes bucket index */
+ delete: operations['StorageVectorBucketIdIndexesController_deleteBucketIndex']
+ options?: never
+ head?: never
+ patch?: never
+ trace?: never
+ }
'/platform/stripe/invoices/overdue': {
parameters: {
query?: never
@@ -4697,6 +4803,16 @@ export interface components {
| 'sentry'
| 's3'
}
+ CreateBucketIndexBody: {
+ /** @enum {string} */
+ dataType: 'float32'
+ dimension: number
+ /** @enum {string} */
+ distanceMetric: 'cosine' | 'euclidean'
+ indexName: string
+ /** @default [] */
+ metadataKeys?: string[]
+ }
CreateCliLoginSessionBody: {
public_key: string
/** Format: uuid */
@@ -5446,6 +5562,9 @@ export interface components {
metadata_xml_url: string
user_name_mapping?: string[]
}
+ CreateStorageAnalyticsBucketBody: {
+ bucketName: string
+ }
CreateStorageBucketBody: {
allowed_mime_types?: string[]
file_size_limit?: number
@@ -6842,6 +6961,7 @@ export interface components {
}
| {
enabled: boolean
+ unit: string
unlimited: boolean
value: number
}
@@ -7514,6 +7634,7 @@ export interface components {
relation_schema: string
}
PostgresConfigResponse: {
+ checkpoint_timeout?: number
effective_cache_size?: string
hot_standby_feedback?: boolean
logical_decoding_work_mem?: string
@@ -8962,6 +9083,24 @@ export interface components {
/** Format: uri */
redirectTo?: string
}
+ StorageAnalyticsBucketResponse: {
+ created_at: string
+ format: string
+ id: string
+ /** @enum {string} */
+ type: 'ANALYTICS'
+ updated_at: string
+ }
+ StorageAnalyticsBucketsResponse: {
+ data: {
+ created_at: string
+ format: string
+ id: string
+ /** @enum {string} */
+ type: 'ANALYTICS'
+ updated_at: string
+ }[]
+ }
StorageBucketResponse: {
allowed_mime_types?: string[]
created_at: string
@@ -9048,6 +9187,31 @@ export interface components {
owner: string
updated_at: string
}
+ StorageVectorBucketListIndexesResponse: {
+ indexes: {
+ creationTime?: number
+ /** @enum {string} */
+ dataType: 'float32'
+ dimension: number
+ /** @enum {string} */
+ distanceMetric: 'cosine' | 'euclidean' | 'dotproduct'
+ indexName: string
+ metadataConfiguration?: {
+ nonFilterableMetadataKeys?: string[]
+ }
+ vectorBucketName: string
+ }[]
+ nextToken?: string
+ }
+ StorageVectorBucketResponse: {
+ vectorBucketName: string
+ }
+ StorageVectorBucketsResponse: {
+ nextToken?: string
+ vectorBuckets: {
+ vectorBucketName: string
+ }[]
+ }
StreamableFile: Record<string, never>
SupavisorConfigResponse: {
connection_string: string
@@ -9780,6 +9944,7 @@ export interface components {
server_lifetime?: number
}
UpdatePostgresConfigBody: {
+ checkpoint_timeout?: number
effective_cache_size?: string
hot_standby_feedback?: boolean
logical_decoding_work_mem?: string
@@ -23853,9 +24018,20 @@ export interface operations {
}
}
}
- StorageArchiveController_getArchive: {
+ StorageAnalyticsBucketsController_getBuckets: {
parameters: {
- query?: never
+ query?: {
+ /** @description Number of buckets to return per page */
+ limit?: number
+ /** @description Number of buckets to skip */
+ offset?: number
+ /** @description Search buckets by name */
+ search?: string
+ /** @description Sort column for buckets */
+ sortColumn?: 'id' | 'name' | 'created_at' | 'updated_at'
+ /** @description Sort order for buckets */
+ sortOrder?: 'asc' | 'desc'
+ }
header?: never
path: {
/** @description Project ref */
@@ -23870,7 +24046,7 @@ export interface operations {
[name: string]: unknown
}
content: {
- 'application/json': components['schemas']['GetArchiveResponse']
+ 'application/json': components['schemas']['StorageAnalyticsBucketsResponse']
}
}
/** @description Unauthorized */
@@ -23894,7 +24070,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to get project storage archive */
+ /** @description Failed to get list of analytics buckets */
500: {
headers: {
[name: string]: unknown
@@ -23903,7 +24079,7 @@ export interface operations {
}
}
}
- StorageArchiveController_createArchive: {
+ StorageAnalyticsBucketsController_createBucket: {
parameters: {
query?: never
header?: never
@@ -23913,13 +24089,19 @@ export interface operations {
}
cookie?: never
}
- requestBody?: never
+ requestBody: {
+ content: {
+ 'application/json': components['schemas']['CreateStorageAnalyticsBucketBody']
+ }
+ }
responses: {
201: {
headers: {
[name: string]: unknown
}
- content?: never
+ content: {
+ 'application/json': components['schemas']['StorageAnalyticsBucketResponse']
+ }
}
/** @description Unauthorized */
401: {
@@ -23942,7 +24124,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to create project storage archive */
+ /** @description Failed to create analytics bucket */
500: {
headers: {
[name: string]: unknown
@@ -23951,11 +24133,13 @@ export interface operations {
}
}
}
- StorageBucketsController_getBuckets: {
+ StorageAnalyticsBucketIdController_deleteBucket: {
parameters: {
query?: never
header?: never
path: {
+ /** @description Storage bucket id */
+ id: string
/** @description Project ref */
ref: string
}
@@ -23967,9 +24151,7 @@ export interface operations {
headers: {
[name: string]: unknown
}
- content: {
- 'application/json': components['schemas']['StorageBucketResponse'][]
- }
+ content?: never
}
/** @description Unauthorized */
401: {
@@ -23992,7 +24174,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to get list of buckets */
+ /** @description Failed to delete analytics bucket */
500: {
headers: {
[name: string]: unknown
@@ -24001,7 +24183,7 @@ export interface operations {
}
}
}
- StorageBucketsController_createBucket: {
+ StorageArchiveController_getArchive: {
parameters: {
query?: never
header?: never
@@ -24011,17 +24193,15 @@ export interface operations {
}
cookie?: never
}
- requestBody: {
- content: {
- 'application/json': components['schemas']['CreateStorageBucketBody']
- }
- }
+ requestBody?: never
responses: {
- 201: {
+ 200: {
headers: {
[name: string]: unknown
}
- content?: never
+ content: {
+ 'application/json': components['schemas']['GetArchiveResponse']
+ }
}
/** @description Unauthorized */
401: {
@@ -24044,7 +24224,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to create bucket */
+ /** @description Failed to get project storage archive */
500: {
headers: {
[name: string]: unknown
@@ -24053,13 +24233,11 @@ export interface operations {
}
}
}
- StorageBucketIdController_getBucket: {
+ StorageArchiveController_createArchive: {
parameters: {
query?: never
header?: never
path: {
- /** @description Storage bucket id */
- id: string
/** @description Project ref */
ref: string
}
@@ -24067,13 +24245,11 @@ export interface operations {
}
requestBody?: never
responses: {
- 200: {
+ 201: {
headers: {
[name: string]: unknown
}
- content: {
- 'application/json': components['schemas']['StorageBucketResponse']
- }
+ content?: never
}
/** @description Unauthorized */
401: {
@@ -24096,7 +24272,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to get bucket */
+ /** @description Failed to create project storage archive */
500: {
headers: {
[name: string]: unknown
@@ -24105,13 +24281,11 @@ export interface operations {
}
}
}
- StorageBucketIdController_deleteBucket: {
+ StorageBucketsController_getBuckets: {
parameters: {
query?: never
header?: never
path: {
- /** @description Storage bucket id */
- id: string
/** @description Project ref */
ref: string
}
@@ -24123,7 +24297,9 @@ export interface operations {
headers: {
[name: string]: unknown
}
- content?: never
+ content: {
+ 'application/json': components['schemas']['StorageBucketResponse'][]
+ }
}
/** @description Unauthorized */
401: {
@@ -24146,7 +24322,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to delete bucket */
+ /** @description Failed to get list of buckets */
500: {
headers: {
[name: string]: unknown
@@ -24155,13 +24331,11 @@ export interface operations {
}
}
}
- StorageBucketIdController_updateBucket: {
+ StorageBucketsController_createBucket: {
parameters: {
query?: never
header?: never
path: {
- /** @description Storage bucket id */
- id: string
/** @description Project ref */
ref: string
}
@@ -24169,11 +24343,11 @@ export interface operations {
}
requestBody: {
content: {
- 'application/json': components['schemas']['UpdateStorageBucketBody']
+ 'application/json': components['schemas']['CreateStorageBucketBody']
}
}
responses: {
- 200: {
+ 201: {
headers: {
[name: string]: unknown
}
@@ -24200,7 +24374,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to update bucket */
+ /** @description Failed to create bucket */
500: {
headers: {
[name: string]: unknown
@@ -24209,7 +24383,7 @@ export interface operations {
}
}
}
- StorageBucketIdController_emptyBucket: {
+ StorageBucketIdController_getBucket: {
parameters: {
query?: never
header?: never
@@ -24223,11 +24397,13 @@ export interface operations {
}
requestBody?: never
responses: {
- 201: {
+ 200: {
headers: {
[name: string]: unknown
}
- content?: never
+ content: {
+ 'application/json': components['schemas']['StorageBucketResponse']
+ }
}
/** @description Unauthorized */
401: {
@@ -24250,7 +24426,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to empty bucket */
+ /** @description Failed to get bucket */
500: {
headers: {
[name: string]: unknown
@@ -24259,7 +24435,7 @@ export interface operations {
}
}
}
- StorageObjectsController_deleteObjects: {
+ StorageBucketIdController_deleteBucket: {
parameters: {
query?: never
header?: never
@@ -24271,11 +24447,7 @@ export interface operations {
}
cookie?: never
}
- requestBody: {
- content: {
- 'application/json': components['schemas']['DeleteObjectsBody']
- }
- }
+ requestBody?: never
responses: {
200: {
headers: {
@@ -24304,7 +24476,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to delete objects */
+ /** @description Failed to delete bucket */
500: {
headers: {
[name: string]: unknown
@@ -24313,7 +24485,7 @@ export interface operations {
}
}
}
- StorageObjectsController_copyObject: {
+ StorageBucketIdController_updateBucket: {
parameters: {
query?: never
header?: never
@@ -24327,17 +24499,15 @@ export interface operations {
}
requestBody: {
content: {
- 'application/json': components['schemas']['CopyObjectBody']
+ 'application/json': components['schemas']['UpdateStorageBucketBody']
}
}
responses: {
- 201: {
+ 200: {
headers: {
[name: string]: unknown
}
- content: {
- 'application/json': components['schemas']['CopyObjectResponse']
- }
+ content?: never
}
/** @description Unauthorized */
401: {
@@ -24360,7 +24530,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to copy object */
+ /** @description Failed to update bucket */
500: {
headers: {
[name: string]: unknown
@@ -24369,7 +24539,7 @@ export interface operations {
}
}
}
- StorageObjectsController_download: {
+ StorageBucketIdController_emptyBucket: {
parameters: {
query?: never
header?: never
@@ -24381,19 +24551,13 @@ export interface operations {
}
cookie?: never
}
- requestBody: {
- content: {
- 'application/json': components['schemas']['DownloadObjectBody']
- }
- }
+ requestBody?: never
responses: {
201: {
headers: {
[name: string]: unknown
}
- content: {
- 'application/json': components['schemas']['StreamableFile']
- }
+ content?: never
}
/** @description Unauthorized */
401: {
@@ -24416,7 +24580,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to download the file */
+ /** @description Failed to empty bucket */
500: {
headers: {
[name: string]: unknown
@@ -24425,7 +24589,7 @@ export interface operations {
}
}
}
- StorageObjectsController_getObjects: {
+ StorageObjectsController_deleteObjects: {
parameters: {
query?: never
header?: never
@@ -24439,17 +24603,15 @@ export interface operations {
}
requestBody: {
content: {
- 'application/json': components['schemas']['GetObjectsBody']
+ 'application/json': components['schemas']['DeleteObjectsBody']
}
}
responses: {
- 201: {
+ 200: {
headers: {
[name: string]: unknown
}
- content: {
- 'application/json': components['schemas']['StorageObject'][]
- }
+ content?: never
}
/** @description Unauthorized */
401: {
@@ -24472,7 +24634,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to get list of objects with the given bucket */
+ /** @description Failed to delete objects */
500: {
headers: {
[name: string]: unknown
@@ -24481,7 +24643,7 @@ export interface operations {
}
}
}
- StorageObjectsController_getObjectsV2: {
+ StorageObjectsController_copyObject: {
parameters: {
query?: never
header?: never
@@ -24495,7 +24657,7 @@ export interface operations {
}
requestBody: {
content: {
- 'application/json': components['schemas']['GetObjectsV2Body']
+ 'application/json': components['schemas']['CopyObjectBody']
}
}
responses: {
@@ -24504,7 +24666,7 @@ export interface operations {
[name: string]: unknown
}
content: {
- 'application/json': components['schemas']['StorageListResponseV2']
+ 'application/json': components['schemas']['CopyObjectResponse']
}
}
/** @description Unauthorized */
@@ -24528,7 +24690,7 @@ export interface operations {
}
content?: never
}
- /** @description Failed to get list of objects with the given bucket */
+ /** @description Failed to copy object */
500: {
headers: {
[name: string]: unknown
@@ -24537,7 +24699,7 @@ export interface operations {
}
}
}
- StorageObjectsController_moveObject: {
+ StorageObjectsController_download: {
parameters: {
query?: never
header?: never
@@ -24551,7 +24713,7 @@ export interface operations {
}
requestBody: {
content: {
- 'application/json': components['schemas']['MoveObjectBody']
+ 'application/json': components['schemas']['DownloadObjectBody']
}
}
responses: {
@@ -24559,9 +24721,177 @@ export interface operations {
headers: {
[name: string]: unknown
}
- content?: never
- }
- /** @description Unauthorized */
+ content: {
+ 'application/json': components['schemas']['StreamableFile']
+ }
+ }
+ /** @description Unauthorized */
+ 401: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Forbidden action */
+ 403: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Rate limit exceeded */
+ 429: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Failed to download the file */
+ 500: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ }
+ }
+ StorageObjectsController_getObjects: {
+ parameters: {
+ query?: never
+ header?: never
+ path: {
+ /** @description Storage bucket id */
+ id: string
+ /** @description Project ref */
+ ref: string
+ }
+ cookie?: never
+ }
+ requestBody: {
+ content: {
+ 'application/json': components['schemas']['GetObjectsBody']
+ }
+ }
+ responses: {
+ 201: {
+ headers: {
+ [name: string]: unknown
+ }
+ content: {
+ 'application/json': components['schemas']['StorageObject'][]
+ }
+ }
+ /** @description Unauthorized */
+ 401: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Forbidden action */
+ 403: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Rate limit exceeded */
+ 429: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Failed to get list of objects with the given bucket */
+ 500: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ }
+ }
+ StorageObjectsController_getObjectsV2: {
+ parameters: {
+ query?: never
+ header?: never
+ path: {
+ /** @description Storage bucket id */
+ id: string
+ /** @description Project ref */
+ ref: string
+ }
+ cookie?: never
+ }
+ requestBody: {
+ content: {
+ 'application/json': components['schemas']['GetObjectsV2Body']
+ }
+ }
+ responses: {
+ 201: {
+ headers: {
+ [name: string]: unknown
+ }
+ content: {
+ 'application/json': components['schemas']['StorageListResponseV2']
+ }
+ }
+ /** @description Unauthorized */
+ 401: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Forbidden action */
+ 403: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Rate limit exceeded */
+ 429: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Failed to get list of objects with the given bucket */
+ 500: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ }
+ }
+ StorageObjectsController_moveObject: {
+ parameters: {
+ query?: never
+ header?: never
+ path: {
+ /** @description Storage bucket id */
+ id: string
+ /** @description Project ref */
+ ref: string
+ }
+ cookie?: never
+ }
+ requestBody: {
+ content: {
+ 'application/json': components['schemas']['MoveObjectBody']
+ }
+ }
+ responses: {
+ 201: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Unauthorized */
401: {
headers: {
[name: string]: unknown
@@ -24913,6 +25243,364 @@ export interface operations {
}
}
}
+ StorageVectorBucketsController_getBuckets: {
+ parameters: {
+ query?: never
+ header?: never
+ path: {
+ /** @description Project ref */
+ ref: string
+ }
+ cookie?: never
+ }
+ requestBody?: never
+ responses: {
+ 200: {
+ headers: {
+ [name: string]: unknown
+ }
+ content: {
+ 'application/json': components['schemas']['StorageVectorBucketsResponse']
+ }
+ }
+ /** @description Unauthorized */
+ 401: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Forbidden action */
+ 403: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Rate limit exceeded */
+ 429: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Failed to get list of vector buckets */
+ 500: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ }
+ }
+ StorageVectorBucketsController_createBucket: {
+ parameters: {
+ query?: never
+ header?: never
+ path: {
+ /** @description Project ref */
+ ref: string
+ }
+ cookie?: never
+ }
+ requestBody?: never
+ responses: {
+ 201: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Unauthorized */
+ 401: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Forbidden action */
+ 403: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Rate limit exceeded */
+ 429: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Failed to create vector bucket */
+ 500: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ }
+ }
+ StorageVectorBucketIdController_getBucket: {
+ parameters: {
+ query?: never
+ header?: never
+ path: {
+ /** @description Vector storage bucket name */
+ id: string
+ /** @description Project ref */
+ ref: string
+ }
+ cookie?: never
+ }
+ requestBody?: never
+ responses: {
+ 200: {
+ headers: {
+ [name: string]: unknown
+ }
+ content: {
+ 'application/json': components['schemas']['StorageVectorBucketResponse']
+ }
+ }
+ /** @description Unauthorized */
+ 401: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Forbidden action */
+ 403: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Rate limit exceeded */
+ 429: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Failed to get bucket */
+ 500: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ }
+ }
+ StorageVectorBucketIdController_deleteBucket: {
+ parameters: {
+ query?: never
+ header?: never
+ path: {
+ /** @description Vector storage bucket name */
+ id: string
+ /** @description Project ref */
+ ref: string
+ }
+ cookie?: never
+ }
+ requestBody?: never
+ responses: {
+ 200: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Unauthorized */
+ 401: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Forbidden action */
+ 403: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Rate limit exceeded */
+ 429: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Failed to delete bucket */
+ 500: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ }
+ }
+ StorageVectorBucketIdIndexesController_getBucketIndexes: {
+ parameters: {
+ query?: never
+ header?: never
+ path: {
+ /** @description Vector storage bucket name */
+ id: string
+ /** @description Project ref */
+ ref: string
+ }
+ cookie?: never
+ }
+ requestBody?: never
+ responses: {
+ 200: {
+ headers: {
+ [name: string]: unknown
+ }
+ content: {
+ 'application/json': components['schemas']['StorageVectorBucketListIndexesResponse']
+ }
+ }
+ /** @description Unauthorized */
+ 401: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Forbidden action */
+ 403: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Rate limit exceeded */
+ 429: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Failed to get bucket indexes */
+ 500: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ }
+ }
+ StorageVectorBucketIdIndexesController_createBucketIndex: {
+ parameters: {
+ query?: never
+ header?: never
+ path: {
+ /** @description Vector storage bucket name */
+ id: string
+ /** @description Project ref */
+ ref: string
+ }
+ cookie?: never
+ }
+ requestBody: {
+ content: {
+ 'application/json': components['schemas']['CreateBucketIndexBody']
+ }
+ }
+ responses: {
+ 201: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Unauthorized */
+ 401: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Forbidden action */
+ 403: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Rate limit exceeded */
+ 429: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Failed to create vector bucket index */
+ 500: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ }
+ }
+ StorageVectorBucketIdIndexesController_deleteBucketIndex: {
+ parameters: {
+ query?: never
+ header?: never
+ path: {
+ /** @description Vector storage bucket name */
+ id: string
+ /** @description Vector storage bucket index name */
+ indexName: string
+ /** @description Project ref */
+ ref: string
+ }
+ cookie?: never
+ }
+ requestBody?: never
+ responses: {
+ 200: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Unauthorized */
+ 401: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Forbidden action */
+ 403: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Rate limit exceeded */
+ 429: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ /** @description Failed to delete bucket index */
+ 500: {
+ headers: {
+ [name: string]: unknown
+ }
+ content?: never
+ }
+ }
+ }
InvoicesController_getOverdueInvoices: {
parameters: {
query?: never