feat: roles SPA Users, Profile, API keys, Activity
This commit is contained in:
1 parent
3db490a615
commit
34dffe222f
98 files changed
+4957
-434
No files matched your search
@@ -1,5 +1,11 @@
|
||||
export type Scope = 'none' | 'own' | 'all'
|
||||
|
||||
export const SCOPE_RANK: Record<Scope, number> = { none: 0, own: 1, all: 2 }
|
||||
|
||||
export function isScope(value: unknown): value is Scope {
|
||||
return typeof value === 'string' && Object.keys(SCOPE_RANK).includes(value)
|
||||
}
|
||||
|
||||
export interface Grant {
|
||||
key: string
|
||||
scope: Scope
|
||||
@@ -12,9 +18,23 @@ export interface RoleRef {
|
||||
locked: boolean
|
||||
}
|
||||
|
||||
export interface AssignedBy {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface Access {
|
||||
role: RoleRef
|
||||
permissions: Grant[]
|
||||
roleAssignedBy?: AssignedBy | null
|
||||
}
|
||||
|
||||
export function parseRoleAssignedBy(value: unknown): AssignedBy | null {
|
||||
if (typeof value !== 'object' || value === null) {
|
||||
return null
|
||||
}
|
||||
const { id, name } = value as { id?: unknown; name?: unknown }
|
||||
return typeof id === 'number' && typeof name === 'string' && name !== '' ? { id, name } : null
|
||||
}
|
||||
|
||||
export interface CanOptions {
|
||||
|
||||
Reference in new issue
Block a user