> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ooneex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Book Resource

> A ready-to-run spec that scaffolds the `book` module and only the resources the domain needs, with owner/admin permissions wired onto every mutation.

## The prompt

```yaml theme={null}
title: "Scaffold the book module and its resources"
context: |
  Build a `book` domain: users own books they manage; admins manage any. Auth is
  owner-or-admin on every mutation. If `modules/book/` already exists, this work
  is void — do not run.
goal: |
  Create the `book` module + needed resources, wired owner-or-admin on mutations.

  ## Notes
  - If `modules/book/` exists, STOP and report. Else `/module:create` book, then
    build each resource via its `*:create` skill (`--module=book`), respecting
    controllers → services → repositories → entities, registering all.
  - Dependency — `user`. Resolve before the `/module:create` step above: if
    `modules/user/` is missing, create it FIRST from its prompt at
    https://docs.ooneex.com/ai/prompts/resources/user-resource.
  - Judge each resource; create the justified, skip the rest with a reason.
    Defaults: entity + repository always; service + controller per use case;
    permission always (owner-or-admin on update/delete, reuse the permission
    service); migration/seed/event/translation/queue only if applicable;
    storage only if covers are uploaded files; workflow only if there is a
    genuine reversible lifecycle (e.g. draft → review → published).
  - Throw typed exceptions (e.g. `BookNotFoundException`), never return null.

  ### Data Model
  - `Book.owner` ↔ `User.books` — ManyToOne / OneToMany
dod: |
  - [ ] Aborts with a report if `modules/book/` exists
  - [ ] Missing dependency module (`user`) created first from its docs prompt
  - [ ] `book` module created and registered into the app and `SharedModule`
  - [ ] `Book` entity with fields: `title`, `slug` (unique), `isbn`, `author`,
    `description`, `pageCount`, `icon`, `color` (`SimpleColorType`), `thumbnail`,
    `src`, `price`, `status` (draft → review → published), `publishedAt`, `lang`
    (`LocaleType`), `owner`, `createdAt`, `updatedAt`
  - [ ] Full CRUD; user mutates only their own, admin any; non-owner/non-admin
    rejected
  - [ ] If queues are used, book mutations run through a queue
  - [ ] Unneeded resources skipped and reported with a reason
  - [ ] `bun run fmt`, `bun run lint`, `bun run test` pass from the root
```
