title: "Scaffold the video module and its resources"
context: |
Build a `video` domain: users upload videos they own; admins manage any. The
source file and thumbnail are stored by the app (not external URLs), and a new
video runs through a pipeline (upload → processing → published) before it is
playable. Auth is owner-or-admin on every mutation. If `modules/video/`
already exists, this work is void — do not run.
goal: |
Create the `video` module + needed resources, wired owner-or-admin on mutations.
## Notes
- If `modules/video/` exists, STOP and report. Else `/module:create` video,
then build each resource via its `*:create` skill (`--module=video`),
respecting controllers → services → repositories → entities, registering all.
- 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); storage always (file + thumbnail); queue if the project uses queues
(route uploads/re-processing — transcoding is long-running); workflow yes
(reversible upload → processing → published that rolls back artifacts + DB
together on failure); migration/seed/event/translation only if applicable.
- On delete, remove the stored file and thumbnail; never orphan blobs.
- Throw typed exceptions (e.g. `VideoNotFoundException`), never return null.
### Data Model
- `Video.owner` ↔ `User.videos` — ManyToOne / OneToMany
dod: |
- [ ] Aborts with a report if `modules/video/` exists
- [ ] `video` module created and registered into the app and `SharedModule`
- [ ] `Video` entity with fields: `title`, `slug` (unique), `description`,
`icon`, `color` (`SimpleColorType`), `src`, `thumbnail`, `duration`, `status`
(upload → processing → published), `views`, `publishedAt`, `lang`
(`LocaleType`), `owner`, `createdAt`, `updatedAt`
- [ ] Full CRUD (create = upload); file + thumbnail stored via storage, not URLs
- [ ] User mutates only their own, admin any; non-owner/non-admin rejected
- [ ] Delete removes stored file + thumbnail
- [ ] Lifecycle rolls back artifacts + DB together on failure
- [ ] If queues are used, uploads/re-processing 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