s-private API Documentation - v3.8.1
    Preparing search index...

    Domain service for Book business logic.

    Encapsulates complex business rules that don't belong to a single entity. Uses dependency injection for repository access.

    const queryRepo: IBooksQueryRepository = new PrismaBooksQueryRepository();
    const domainService = new BooksDomainService(queryRepo);

    try {
    await domainService.ensureNoDuplicate(isbn, userId);
    // Safe to create the book
    } catch (error) {
    if (error instanceof DuplicateError) {
    // Handle duplicate ISBN
    }
    }
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Validates that no book with the same ISBN exists for the user.

      Parameters

      • isbn: string & $brand<"ISBN">

        The ISBN to check for duplicates

      • userId: string & $brand<"UserId">

        The user ID for tenant isolation

      Returns Promise<void>

      When a book with this ISBN already exists

      This is a domain invariant check that should be called before creating books.