mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 10:55:06 +03:00
Scoped-down storage protection prototype with three features: - Bucket-level versioning policy (retention days, max versions) in create/edit modals - Object version history in the file preview pane with restore/delete actions - Per-bucket deleted files (trash) view with bulk selection, restore, and permanent delete All data is mock-backed behind the STORAGE_PROTECTION_ENABLED feature flag. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TiUEvmC84bRsteqsWXHY2p
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
/**
|
|
* Shared constants + gating for the Storage Object Versioning prototype.
|
|
*/
|
|
|
|
// Prototype flag: force-enabled so the surfaces are visible via `pnpm dev:studio`.
|
|
// A real rollout would replace this with `useFlag('storageObjectVersioning')`.
|
|
export const STORAGE_PROTECTION_ENABLED = true
|
|
|
|
export const useIsStorageProtectionEnabled = () => STORAGE_PROTECTION_ENABLED
|
|
|
|
export type BucketVersioningState = 'enabled' | 'suspended' | 'disabled'
|
|
|
|
export const PROJECT_VERSIONING_DEFAULTS = {
|
|
versionExpiryDays: 30,
|
|
maxNoncurrentVersions: 100,
|
|
} as const
|
|
|
|
export interface BucketProtection {
|
|
versioning: BucketVersioningState
|
|
versionExpiryDays: number | null
|
|
maxNoncurrentVersions: number | null
|
|
}
|
|
|
|
const PROTECTED_BUCKETS: Record<string, BucketProtection> = {
|
|
'match-media': {
|
|
versioning: 'enabled',
|
|
versionExpiryDays: PROJECT_VERSIONING_DEFAULTS.versionExpiryDays,
|
|
maxNoncurrentVersions: PROJECT_VERSIONING_DEFAULTS.maxNoncurrentVersions,
|
|
},
|
|
avatars: {
|
|
versioning: 'enabled',
|
|
versionExpiryDays: 30,
|
|
maxNoncurrentVersions: 10,
|
|
},
|
|
}
|
|
|
|
const DEFAULT_PROTECTION: BucketProtection = {
|
|
versioning: 'disabled',
|
|
versionExpiryDays: null,
|
|
maxNoncurrentVersions: null,
|
|
}
|
|
|
|
export const getMockBucketProtection = (bucketName: string | undefined): BucketProtection =>
|
|
(bucketName && PROTECTED_BUCKETS[bucketName]) || DEFAULT_PROTECTION
|
|
|
|
export const isBucketVersioned = (bucketName: string | undefined) =>
|
|
getMockBucketProtection(bucketName).versioning === 'enabled'
|