rolessvc

package
v0.2.0-rc.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRoleNotFound            = roles.ErrNotFound
	ErrRoleSlugAlreadyExists   = roles.ErrSlugAlreadyExists
	ErrCannotDeleteDefaultRole = roles.ErrCannotDeleteSystemRole
	ErrUserNotMember           = roles.ErrUserNotMember
)

Re-exported from repository layer — single source of truth.

View Source
var (
	ErrInvalidOrgSlug           = xerror.InvalidInput(xerror.Organization)
	ErrInvalidRoleSlug          = xerror.InvalidInput(xerror.Role)
	ErrCannotUpdateDefaultRole  = xerror.CannotUpdateDefault(xerror.Role)
	ErrPermissionNotFound       = xerror.NotFound(xerror.Permission)
	ErrPermissionAlreadyGranted = xerror.AlreadyExists(xerror.Permission)
	ErrInvalidInput             = xerror.ValidationFailed()
)

Service-only errors.

Functions

This section is empty.

Types

type Service

type Service interface {
	CreateRoleWithPermissions(
		ctx context.Context,
		orgSlug slug.Slug,
		actor model.EventActor,
		newRole model.NewRole,
		permissions []model.RolePermission,
	) (*model.OrgRole, error)
	CreateDefaultRoles(ctx context.Context, orgSlug slug.Slug) error
	UpdateRoleWithPermissions(
		ctx context.Context,
		orgSlug, roleSlug slug.Slug,
		actor model.EventActor,
		update model.UpdateRole,
		permissions []model.RolePermission,
	) error
	DeleteRole(ctx context.Context, orgSlug, roleSlug slug.Slug, actor model.EventActor) error
	RestoreRole(ctx context.Context, orgSlug, roleSlug slug.Slug, actor model.EventActor) error
	GetRole(ctx context.Context, orgSlug, roleSlug slug.Slug) (*model.OrgRole, error)
	ListRoles(
		ctx context.Context,
		orgSlug slug.Slug,
		req model.ListRequest,
		includeDeleted bool,
		onlyDeleted bool,
	) (model.ListResponse[model.OrgRole], error)
	GetUserPermissionsInOrg(
		ctx context.Context,
		orgSlug, userSlug slug.Slug,
	) ([]model.RolePermission, error)
	ListRolePermissions(
		ctx context.Context,
		orgSlug, roleSlug slug.Slug,
	) ([]model.RolePermission, error)
}

func New

func New(
	txm postgres.TransactionManager,
	rolesRepo roles.Repository,
	permissionsRepo permissions.Repository,
	eventProducer workerproducer.EventProducer,
) Service

New creates a new roles service.

func NewServiceWithLogging

func NewServiceWithLogging(base Service, logger *slog.Logger) Service

NewServiceWithLogging wraps base with method completion logging.

type ServiceWithLogging

type ServiceWithLogging struct {
	// contains filtered or unexported fields
}

ServiceWithLogging implements Service with method completion logging.

func (ServiceWithLogging) CreateDefaultRoles

func (_d ServiceWithLogging) CreateDefaultRoles(ctx context.Context, orgSlug slug.Slug) (err error)

CreateDefaultRoles implements Service.

func (ServiceWithLogging) CreateRoleWithPermissions

func (_d ServiceWithLogging) CreateRoleWithPermissions(ctx context.Context, orgSlug slug.Slug, actor model.EventActor, newRole model.NewRole, permissions []model.RolePermission) (op1 *model.OrgRole, err error)

CreateRoleWithPermissions implements Service.

func (ServiceWithLogging) DeleteRole

func (_d ServiceWithLogging) DeleteRole(ctx context.Context, orgSlug slug.Slug, roleSlug slug.Slug, actor model.EventActor) (err error)

DeleteRole implements Service.

func (ServiceWithLogging) GetRole

func (_d ServiceWithLogging) GetRole(ctx context.Context, orgSlug slug.Slug, roleSlug slug.Slug) (op1 *model.OrgRole, err error)

GetRole implements Service.

func (ServiceWithLogging) GetUserPermissionsInOrg

func (_d ServiceWithLogging) GetUserPermissionsInOrg(ctx context.Context, orgSlug slug.Slug, userSlug slug.Slug) (ra1 []model.RolePermission, err error)

GetUserPermissionsInOrg implements Service.

func (ServiceWithLogging) ListRolePermissions

func (_d ServiceWithLogging) ListRolePermissions(ctx context.Context, orgSlug slug.Slug, roleSlug slug.Slug) (ra1 []model.RolePermission, err error)

ListRolePermissions implements Service.

func (ServiceWithLogging) ListRoles

func (_d ServiceWithLogging) ListRoles(ctx context.Context, orgSlug slug.Slug, req model.ListRequest, includeDeleted bool, onlyDeleted bool) (p1 model.ListResponse[model.OrgRole], err error)

ListRoles implements Service.

func (ServiceWithLogging) RestoreRole

func (_d ServiceWithLogging) RestoreRole(ctx context.Context, orgSlug slug.Slug, roleSlug slug.Slug, actor model.EventActor) (err error)

RestoreRole implements Service.

func (ServiceWithLogging) UpdateRoleWithPermissions

func (_d ServiceWithLogging) UpdateRoleWithPermissions(ctx context.Context, orgSlug slug.Slug, roleSlug slug.Slug, actor model.EventActor, update model.UpdateRole, permissions []model.RolePermission) (err error)

UpdateRoleWithPermissions implements Service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL