/** * 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 { AdminAuth } from '@byline/auth'; import type { AdminUsersRepository } from './repository.js'; import type { AdminUserListResponse, AdminUserResponse, CreateAdminUserRequest, DeleteAdminUserRequest, DisableAdminUserRequest, EnableAdminUserRequest, GetAdminUserRequest, ListAdminUsersRequest, SetAdminUserPasswordRequest, UpdateAdminUserRequest } from './schemas.js'; /** * Business logic for administering admin users. * * The service owns four concerns the repository deliberately avoids: * * 1. **Password hashing.** `hashPassword` from `@byline/admin/auth` * runs here so every write path (create, setPassword, future * password-reset flows) hashes consistently. * 2. **Domain invariants.** Email conflict detection on create/update, * self-delete / self-disable prevention — rules the database * cannot enforce on its own. * 3. **DTO shaping.** Raw rows are shaped through `toAdminUser` so * the response contract is owned in one place. * 4. **Optimistic-concurrency plumbing.** The repo gates writes on * `expectedVid`; the service just threads it from the validated * request shape. Version conflicts surface as * `AdminUsersError(VERSION_CONFLICT)` from the adapter; the service * does not catch them. * * Commands call service methods after Zod-validating input and asserting * abilities; internal callers (seeds, other services) can call service * methods directly. Either way, the service is transport-agnostic. * * Service methods take the acting `AdminAuth` as an explicit first * argument when they need it for invariants (self-delete checks). Reads * do not need the actor — the ability check at the command boundary is * sufficient. */ export declare class AdminUsersService { #private; constructor(deps: { repo: AdminUsersRepository; }); listUsers(request: ListAdminUsersRequest): Promise; getUser(request: GetAdminUserRequest): Promise; createUser(request: CreateAdminUserRequest): Promise; updateUser(request: UpdateAdminUserRequest): Promise; setPassword(request: SetAdminUserPasswordRequest): Promise; enableUser(request: EnableAdminUserRequest): Promise; disableUser(actor: AdminAuth, request: DisableAdminUserRequest): Promise; deleteUser(actor: AdminAuth, request: DeleteAdminUserRequest): Promise; }