BeechCMS / @beechcms/core / IRoleAssignmentRepository
Interface: IRoleAssignmentRepository
Storage contract for (user, role, scope) assignments.
Methods
create()
create(
input):Promise<string>
Creates an assignment. Returns its id; an existing identical triple is a no-op.
Parameters
input
Returns
Promise<string>
delete()
delete(
assignmentId):Promise<AdminGuardedResult>
Removes one assignment. not-found when it did not exist; last-global-admin when it is the global manage_users assignment of the last active global administrator.
Parameters
assignmentId
string
Returns
Promise<AdminGuardedResult>
findById()
findById(
assignmentId):Promise<PermissionAssignment|null>
One assignment by id, decay filter NOT applied. Null when absent.
Parameters
assignmentId
string
Returns
Promise<PermissionAssignment | null>
listActiveForUser()
listActiveForUser(
userId):Promise<PermissionAssignment[]>
Lists a user's assignments that currently grant anything.
An assignment is skipped when its scope names a seed that is absent or status != 'active', so scopes decay with their seed and revive with it. GLOBAL_SCOPE assignments are always returned.
Parameters
userId
string
Returns
Promise<PermissionAssignment[]>
listAllForUser()
listAllForUser(
userId):Promise<PermissionAssignment[]>
Every assignment of one user, decay filter NOT applied — administration screens must see (and be able to remove) a row whose seed is currently deleted, which listActiveForUser deliberately hides.
Parameters
userId
string
Returns
Promise<PermissionAssignment[]>
listByRole()
listByRole(
roleId):Promise<PermissionAssignment[]>
Lists every assignment referencing a role, decay filter NOT applied.
Parameters
roleId
string
Returns
Promise<PermissionAssignment[]>
listForUsers()
listForUsers(
userIds):Promise<PermissionAssignment[]>
Every assignment of the given users, decay filter NOT applied, in ONE round trip.
Exists so the account-list endpoint can resolve the scopes of one page of accounts without a query per account. Callers pass at most MAX_PAGE_SIZE ids (D1 caps bound parameters per statement); an empty list returns an empty list.
Parameters
userIds
readonly string[]
Returns
Promise<PermissionAssignment[]>