roles.ts83 lines · main
| 1 | export type KnownRole = |
| 2 | | 'anon' |
| 3 | | 'authenticated' |
| 4 | | 'service_role' |
| 5 | | 'postgres' |
| 6 | | 'authenticator' |
| 7 | | 'briven_auth_admin' |
| 8 | | 'briven_storage_admin' |
| 9 | | 'briven_etl_admin' |
| 10 | | 'briven_realtime_admin' |
| 11 | | 'briven_replication_admin' |
| 12 | | 'briven_read_only_user' |
| 13 | | 'dashboard_user' |
| 14 | | 'briven_admin' |
| 15 | |
| 16 | export const APP_ACCESS_ROLES: KnownRole[] = ['anon', 'authenticated', 'service_role'] as const |
| 17 | export const BRIVEN_SYSTEM_ROLES: KnownRole[] = [ |
| 18 | 'postgres', |
| 19 | 'authenticator', |
| 20 | 'briven_auth_admin', |
| 21 | 'briven_storage_admin', |
| 22 | 'briven_etl_admin', |
| 23 | 'briven_realtime_admin', |
| 24 | 'briven_replication_admin', |
| 25 | 'briven_read_only_user', |
| 26 | 'dashboard_user', |
| 27 | 'briven_admin', |
| 28 | ] as const |
| 29 | |
| 30 | export type RoleInfo = { |
| 31 | displayName: string |
| 32 | } |
| 33 | |
| 34 | export const ROLE_INFO: Record<KnownRole, RoleInfo> = { |
| 35 | anon: { |
| 36 | displayName: 'Anonymous (Logged Out)', |
| 37 | }, |
| 38 | authenticated: { |
| 39 | displayName: 'Authenticated (Logged In)', |
| 40 | }, |
| 41 | service_role: { |
| 42 | displayName: 'Service Role', |
| 43 | }, |
| 44 | postgres: { |
| 45 | displayName: 'Postgres', |
| 46 | }, |
| 47 | authenticator: { |
| 48 | displayName: 'Authenticator', |
| 49 | }, |
| 50 | briven_auth_admin: { |
| 51 | displayName: 'Auth Admin', |
| 52 | }, |
| 53 | briven_storage_admin: { |
| 54 | displayName: 'Storage Admin', |
| 55 | }, |
| 56 | briven_etl_admin: { |
| 57 | displayName: 'ETL Admin', |
| 58 | }, |
| 59 | briven_realtime_admin: { |
| 60 | displayName: 'Realtime Admin', |
| 61 | }, |
| 62 | briven_replication_admin: { |
| 63 | displayName: 'Replication Admin', |
| 64 | }, |
| 65 | briven_read_only_user: { |
| 66 | displayName: 'Read-Only User', |
| 67 | }, |
| 68 | dashboard_user: { |
| 69 | displayName: 'Dashboard User', |
| 70 | }, |
| 71 | briven_admin: { |
| 72 | displayName: 'Briven Admin', |
| 73 | }, |
| 74 | } |
| 75 | |
| 76 | export function isKnownRole(role: string): role is KnownRole { |
| 77 | return role in ROLE_INFO |
| 78 | } |
| 79 | |
| 80 | export type RoleGroup = { |
| 81 | name: string |
| 82 | options: string[] |
| 83 | } |