mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
## Context Just some clean up as I was going through stuff - `useExecuteSqlQuery` is deprecated and not used at all - As such `execute-sql-query` is technically irrelevant, the more relevant file is `execute-sql-mutation` - Hence opting to consolidate `execute-sql-query` into `execute-sql-mutation` - Also removing `ExecuteSqlError` since its just re-exporting the `ResponseError` type There's a lot of file changes but its essentially just updating the importing statements across the files
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { getDeleteBucketPrefixSQL } from '@supabase/pg-meta'
|
|
|
|
import { executeSql } from '@/data/sql/execute-sql-mutation'
|
|
|
|
/**
|
|
* [Joshen] JFYI this is solely being used in storage-explorer.tsx and hence doesn't have a useMutation hook
|
|
* It's solely supposed to aid users to self-remediate a known issue with orphan prefixes so the condition to
|
|
* clean the prefix from the storage.prefixes is intentionally strict here (e.g only level 1)
|
|
*
|
|
* We can make this a bit more loose if needed, but ideal case is that this issue is addressed at the storage level
|
|
*/
|
|
|
|
type DeleteBucketPrefixParams = {
|
|
projectRef?: string
|
|
connectionString?: string
|
|
bucketId?: string
|
|
prefix?: string
|
|
}
|
|
export const deleteBucketPrefix = async (
|
|
{ projectRef, connectionString, bucketId, prefix }: DeleteBucketPrefixParams,
|
|
signal?: AbortSignal
|
|
) => {
|
|
if (!projectRef) throw new Error('projectRef is required')
|
|
if (!connectionString) throw new Error('connectionString is required')
|
|
if (!bucketId) throw new Error('bucketId is required')
|
|
if (!prefix) throw new Error('prefix is required')
|
|
|
|
const sql = getDeleteBucketPrefixSQL({ bucketId, prefix })
|
|
|
|
const { result } = await executeSql(
|
|
{ projectRef, connectionString, sql, queryKey: ['delete-bucket-prefix'] },
|
|
signal
|
|
)
|
|
|
|
return result
|
|
}
|