Codegen
Two ace commands and a generated registry that keeps document names, spaces and anchors typed on both sides of the wire — derived from the files on disk instead of a list you maintain.
A document name is a string, and strings drift. Someone renames a route, someone else keeps typing
researches/42/writting, and nothing complains until a user sees an empty editor. The codegen layer
turns that string into a type.
There are two moving parts:
make:collab-documentwrites a file per document type underapp/collaboration/documents/, declaring its name, its comment spaces and its allowed anchor kinds. That file is types-only, so the frontend can import it without pulling in server code.- An Assembler
inithook scans that folder and regenerates.adonisjs/collaboration/documents.ts, where every document name becomes a union member.
Neither is a registry you maintain. Both are derived from what is on disk, which means they cannot disagree with it.
node ace collaboration:init # scaffold the folders and migrations
node ace make:collab-document researches/writing # declare a document type
node ace codegen # refresh the registry (also runs on dev/build)import type { CollabDocumentName } from '.adonisjs/collaboration/documents.js'
function open(name: CollabDocumentName) { /* autocompleted, exhaustive */ }Custom storage
Implement CollaborationStorage yourself — the ten methods, the contracts that are easy to get subtly wrong, and a worked S3-backed example.
Commands
collaboration:init, collaboration:prune and make:collab-document — what each one writes, every flag, and the generated document-types file explained line by line.