The RolesService is a core component of the Roles API, responsible for handling the business logic and operations related to roles and their permissions within an application.

It offers a set of methods to create, update, delete, and fetch roles, as well as to manage their associated permissions and permission groups.

Type Parameters

Constructors

Properties

dataSource: DataSource
idService: IdService
loggerFactory: WinstonLoggerFactory
organizationAdminRoleId?: string
superadminRoleId: string

Accessors

  • get roleRepository(): Repository<R>

    Returns Repository<R>

Methods

  • Parameters

    Returns void

  • Returns string

  • This method is responsible for fetching a list of roles that can be assigned to other users by the calling user. Based on the calling user's permissions, this method returns a filtered list of roles that they are authorized to assign.

    This ensures that users can only assign roles within their allowed scope, maintaining the integrity and security of the application.

    Parameters

    Returns Promise<[R[], ListMeta]>

  • Get role by id

    Parameters

    • id: string

      role id

    Returns Promise<MaybeNull<R>>

    role if exists, null otherwise

  • Get role by id or throw an error if role not found

    Parameters

    Returns Promise<R>

    role if exists, throws an error otherwise

  • Returns void