/** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited */ import type { AdminStore } from '../../store.js'; import type { AdminRoleListResponse, AdminRoleResponse, CreateAdminRoleRequest, DeleteAdminRoleRequest, GetAdminRoleRequest, GetRolesForUserRequest, ReorderAdminRolesRequest, SetRolesForUserRequest, UpdateAdminRoleRequest, UserRolesResponse } from './schemas.js'; /** * Business logic for administering admin roles. * * Owns four concerns the repository deliberately avoids: * * 1. **Domain invariants.** `machine_name` uniqueness pre-check on * create — the unique index is the ultimate backstop, but the * pre-check produces a clean domain error rather than a raw * Postgres code. * 2. **DTO shaping.** Raw rows are shaped through `toAdminRole` so * the response contract is owned in one place. * 3. **Optimistic-concurrency plumbing.** The repo gates writes on * `expectedVid`; the service threads it from the validated request * shape. Version conflicts surface as * `AdminRolesError(VERSION_CONFLICT)` from the adapter; the service * does not catch them. * 4. **Cross-table validation.** The user-roles editor validates the * user and every referenced role exists before mutating the join * table — clean errors over raw FK violations. * * Roles do not need a self-target invariant the way users do * (no "self-delete" concept), so role-CRUD service methods are * actor-agnostic and the ability check at the command boundary is the * only authorisation. */ export declare class AdminRolesService { #private; constructor(deps: { store: AdminStore; }); listRoles(): Promise; getRole(request: GetAdminRoleRequest): Promise; createRole(request: CreateAdminRoleRequest): Promise; updateRole(request: UpdateAdminRoleRequest): Promise; deleteRole(request: DeleteAdminRoleRequest): Promise; reorderRoles(request: ReorderAdminRolesRequest): Promise; getRolesForUser(request: GetRolesForUserRequest): Promise; setRolesForUser(request: SetRolesForUserRequest): Promise; }