Skip to content

Interface: SyncDefinition<T, G> ​

Defined in: packages/core/src/sync.ts:36

Declarative description of the roles & permissions of ONE guard (and optionally one team).

ts
await rbac.sync({
  permissions: ['edit articles', 'delete articles'],
  roles: { admin: '*', writer: ['edit articles'] },
})

Pass an array of definitions to sync several guards / teams at once. With per-guard names (RbacTypeConfig['guards']), G is the guard whose names the block takes; see SyncDefinitions.

Type Parameters ​

Type ParameterDefault type
T extends RbacTypeConfigDefaultRbacTypes
G extends stringDefaultGuardName<T>

Properties ​

PropertyTypeDescriptionDefined in
guard?stringGuard of this block. Default: the guard option, then defaultGuard.packages/core/src/sync.ts:38
permissions?readonly PermissionsOf<GuardTypes<T, G>>[]Permissions of the guard. Permissions referenced by a role are created too, even if not listed here.packages/core/src/sync.ts:42
roles?{ readonly [R in string]?: SyncRolePermissions<T, G> }Roles and their permissions. Each role's permissions are synced (replaced) to exactly this list.packages/core/src/sync.ts:44
team?TeamIdTeam of the roles in this block (requires teams: true). Default: the team option, then global (null).packages/core/src/sync.ts:40

Released under the MIT License. Inspired by spatie/laravel-permission.