Agora
Codegen

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-document writes a file per document type under app/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 init hook 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 */ }