feat(supabase): files foundation — assets table, private buckets, avatar policies through assets, purge queue, browser and worker RPCs
Migration 20261013100000: asset_status enum, public.assets (server-built keys, lease token, closed rejection reasons), seven private buckets (avatars open with cap and MIME list, six closed), storage.objects SELECT/INSERT policies for avatars evaluated through assets, private.object_purge_queue fed by status and delete triggers (48 h / 1 h grace), storage ceiling, RPCs begin_avatar_upload / confirm_asset_upload / remove_avatar (authenticated) and claim_avatar_jobs / complete_avatar_job / reject_avatar_job / mark_quarantine_purged / claim_purges / ack_purge / claim_quarantine_leftovers / expire_pending_uploads (service_role), explicit revokes and column grants. pgTAP 010 (125 checks: allowed and denied twins, policy census, stale lease, supersede, removal, leftovers, cascade, ceiling), 001 census extended, database.types.ts regenerated from the real stack, schema-types test counts input arguments only.
This commit is contained in:
1 parent
3f1105bf39
commit
614887470c
5 files changed
+1346
-6
No files matched your search
@@ -239,6 +239,75 @@ export type Database = {
|
||||
},
|
||||
]
|
||||
}
|
||||
assets: {
|
||||
Row: {
|
||||
attempts: number
|
||||
bucket_id: string
|
||||
byte_size: number | null
|
||||
created_at: string
|
||||
declared_mime: string
|
||||
declared_size: number
|
||||
id: string
|
||||
kind: string
|
||||
lock_token: string | null
|
||||
locked_at: string | null
|
||||
object_key: string
|
||||
owner_id: string
|
||||
quarantine_key: string | null
|
||||
rejection_reason: string | null
|
||||
sha256: string | null
|
||||
status: Database['public']['Enums']['asset_status']
|
||||
updated_at: string
|
||||
}
|
||||
ComputedFields: never
|
||||
Insert: {
|
||||
attempts?: number
|
||||
bucket_id: string
|
||||
byte_size?: number | null
|
||||
created_at?: string
|
||||
declared_mime: string
|
||||
declared_size: number
|
||||
id?: string
|
||||
kind: string
|
||||
lock_token?: string | null
|
||||
locked_at?: string | null
|
||||
object_key: string
|
||||
owner_id: string
|
||||
quarantine_key?: string | null
|
||||
rejection_reason?: string | null
|
||||
sha256?: string | null
|
||||
status?: Database['public']['Enums']['asset_status']
|
||||
updated_at?: string
|
||||
}
|
||||
Update: {
|
||||
attempts?: number
|
||||
bucket_id?: string
|
||||
byte_size?: number | null
|
||||
created_at?: string
|
||||
declared_mime?: string
|
||||
declared_size?: number
|
||||
id?: string
|
||||
kind?: string
|
||||
lock_token?: string | null
|
||||
locked_at?: string | null
|
||||
object_key?: string
|
||||
owner_id?: string
|
||||
quarantine_key?: string | null
|
||||
rejection_reason?: string | null
|
||||
sha256?: string | null
|
||||
status?: Database['public']['Enums']['asset_status']
|
||||
updated_at?: string
|
||||
}
|
||||
Relationships: [
|
||||
{
|
||||
foreignKeyName: 'assets_owner_id_fkey'
|
||||
columns: ['owner_id']
|
||||
isOneToOne: false
|
||||
referencedRelation: 'profiles'
|
||||
referencedColumns: ['id']
|
||||
},
|
||||
]
|
||||
}
|
||||
profile_roles: {
|
||||
Row: {
|
||||
granted_at: string
|
||||
@@ -380,7 +449,50 @@ export type Database = {
|
||||
[_ in never]: never
|
||||
}
|
||||
Functions: {
|
||||
ack_purge: { Args: { purge_id: string }; Returns: undefined }
|
||||
archive_anatomical_sheet: { Args: { sheet_id: string }; Returns: string }
|
||||
begin_avatar_upload: {
|
||||
Args: { declared_mime: string; declared_size: number }
|
||||
Returns: Json
|
||||
}
|
||||
claim_avatar_jobs: {
|
||||
Args: { max_jobs: number }
|
||||
Returns: {
|
||||
asset_id: string
|
||||
attempts: number
|
||||
bucket_id: string
|
||||
lock_token: string
|
||||
object_key: string
|
||||
owner_id: string
|
||||
quarantine_key: string
|
||||
}[]
|
||||
}
|
||||
claim_purges: {
|
||||
Args: { max_items: number }
|
||||
Returns: {
|
||||
bucket_id: string
|
||||
object_name: string
|
||||
purge_id: string
|
||||
}[]
|
||||
}
|
||||
claim_quarantine_leftovers: {
|
||||
Args: { max_items: number; older_than_seconds: number }
|
||||
Returns: {
|
||||
asset_id: string
|
||||
bucket_id: string
|
||||
object_name: string
|
||||
}[]
|
||||
}
|
||||
complete_avatar_job: {
|
||||
Args: {
|
||||
asset_id: string
|
||||
byte_size: number
|
||||
lock_token: string
|
||||
sha256: string
|
||||
}
|
||||
Returns: undefined
|
||||
}
|
||||
confirm_asset_upload: { Args: { asset_id: string }; Returns: undefined }
|
||||
confirm_sheet_asset_upload: {
|
||||
Args: { asset_id: string }
|
||||
Returns: string
|
||||
@@ -412,6 +524,10 @@ export type Database = {
|
||||
Args: { reason?: string; version_id: string }
|
||||
Returns: string
|
||||
}
|
||||
expire_pending_uploads: {
|
||||
Args: { max_age_seconds: number }
|
||||
Returns: number
|
||||
}
|
||||
fork_anatomical_sheet: {
|
||||
Args: {
|
||||
name: string
|
||||
@@ -428,6 +544,7 @@ export type Database = {
|
||||
}
|
||||
Returns: string
|
||||
}
|
||||
mark_quarantine_purged: { Args: { asset_id: string }; Returns: undefined }
|
||||
publish_sheet_version: { Args: { version_id: string }; Returns: string }
|
||||
register_sheet_asset: {
|
||||
Args: {
|
||||
@@ -438,6 +555,11 @@ export type Database = {
|
||||
}
|
||||
Returns: string
|
||||
}
|
||||
reject_avatar_job: {
|
||||
Args: { asset_id: string; lock_token: string; reason: string }
|
||||
Returns: undefined
|
||||
}
|
||||
remove_avatar: { Args: Record<PropertyKey, never>; Returns: number }
|
||||
restore_anatomical_sheet: { Args: { sheet_id: string }; Returns: string }
|
||||
revoke_platform_role: {
|
||||
Args: {
|
||||
@@ -456,6 +578,12 @@ export type Database = {
|
||||
}
|
||||
}
|
||||
Enums: {
|
||||
asset_status:
|
||||
| 'pending_upload'
|
||||
| 'uploaded'
|
||||
| 'clean'
|
||||
| 'rejected'
|
||||
| 'deleted'
|
||||
platform_role: 'owner' | 'admin' | 'moderator' | 'support'
|
||||
sheet_status: 'active' | 'archived' | 'deleted'
|
||||
sheet_version_status: 'draft' | 'published' | 'deprecated'
|
||||
@@ -587,6 +715,13 @@ export type CompositeTypes<
|
||||
export const Constants = {
|
||||
public: {
|
||||
Enums: {
|
||||
asset_status: [
|
||||
'pending_upload',
|
||||
'uploaded',
|
||||
'clean',
|
||||
'rejected',
|
||||
'deleted',
|
||||
],
|
||||
platform_role: ['owner', 'admin', 'moderator', 'support'],
|
||||
sheet_status: ['active', 'archived', 'deleted'],
|
||||
sheet_version_status: ['draft', 'published', 'deprecated'],
|
||||
|
||||
Reference in new issue
Block a user