Files
supabase/apps/studio/components/interfaces/Storage/StorageProtection.constants.ts
T
Claude ca875d2e0d feat(studio): add bucket versioning, object versions, and deleted files prototype
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
2026-08-03 16:58:25 +00:00

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'