import type { FaunosteoClient } from './client' import type { Enums } from './database.types' export type PlatformRole = Enums<'platform_role'> /** Active platform roles of the signed-in user (RLS: own rows, or any as admin). */ export async function fetchOwnPlatformRoles( client: FaunosteoClient, userId: string, ): Promise { const { data, error } = await client .from('profile_roles') .select('role') .eq('user_id', userId) .is('revoked_at', null) if (error) throw new Error(error.message, { cause: error }) return data.map((row) => row.role) }