@@ -179,45 +179,32 @@ <h2 class="section-label">5 · Choose your generators</h2>
179179 < p class ="gs-note "> Ask the catalog what your model can generate. < code > --probe</ code > runs every generator against
180180 < em > your</ em > metadata and reports how many files each would emit:</ p >
181181 < pre class ="gs-code "> $ npx meta gen --list --probe
182- [25]:
183- - name: entity
184- kind: generator
185- layer: model
186- < span class ="c "> …</ span >
187- project:
188- wired: false
189- frameworkDetected: null
190- wouldEmit: 1
191- < span class ="c "> …</ span >
192- - name: routes
193- kind: generator
194- layer: api
195- framework: fastify
196- < span class ="c "> …</ span >
197- project:
198- wired: false
199- frameworkDetected: false
200- wouldEmit: null
201- probeError: "[routes-file] codegen config is missing dbImport — …"
202- < span class ="c "> # … every generator, grouped by layer: model, persistence, api, client,</ span >
203- < span class ="c "> # docs, capability — plus the ai and iam libraries</ span > </ pre >
204- < p class ="gs-note "> The < code > routes</ code > row is already telling you what it needs: a < code > dbImport</ code > ,
205- which you'll add below. Take the ones you want. < code > meta eject</ code > copies each into
182+ Generator catalog — nothing runs until you wire it in `generators: [...]`.
183+
184+ model — the entity modules and the constants beside them
185+ barrel — Single index.ts re-exporting every generated entity module. [would emit 1]
186+ requires: entity
187+ entity — Per-entity Drizzle table + typed model module (the entity module). [would emit 1]
188+ names — Per-entity physical database name constants (table/view, schema, columns). [would emit 1]
189+ persistence — how rows are read and written
190+ queries — Per-entity typed query helpers (findById/create/...). [would emit 1]
191+ requires: entity
192+ api — the HTTP surface — pick ONE framework
193+ routes — Per-entity Fastify CRUD routes (drizzle-fastify mountCrudRoutes). [fastify]
194+ requires: entity
195+ routes-hono — Per-entity Hono CRUD routes (runtime-ts/hono mountCrudRoutes). [hono, would emit 1]
196+ < span class ="c "> # … client, docs and capability generators, then the ai and iam libraries</ span > </ pre >
197+ < p class ="gs-note "> Take the ones you want. < code > meta eject</ code > copies each into
206198 < code > codegen/generators/</ code > and tells you exactly how to wire it:</ p >
207199 < pre class ="gs-code "> $ npx meta eject entity queries routes names barrel
208- ejected[5]:
209- - name: entity
210- path: codegen/generators/entity.ts
211- status: created
212- wire:
213- import: "import { entityFile } from \"./codegen/generators/entity.js\";"
214- entry: entityFile()
215- < span class ="c "> # … queries, routes, names, barrel</ span >
216- install:
217- dev[1]: @metaobjectsdev/codegen-ts@^< span data-registry ="npm "> 1.0.4</ span >
218- < span class ="c "> # … and the runtime packages the generated code imports</ span >
219- config:
220- keys[9]: apiPrefix,collectionNameOverrides,columnNamingStrategy,dbImport,dialect,extStyle,…</ pre >
200+ Ejected "entity" -> codegen/generators/entity.ts. You own it now (ADR-0034 scaffold-and-own).
201+ In metaobjects.config.ts, "entityFile" must resolve to this file:
202+ import { entityFile } from "./codegen/generators/entity.js";
203+ < span class ="c "> # … the same for queries, routes, names and barrel</ span >
204+
205+ Install what the ejected generators and their output need:
206+ < span class ="c "> # … the packages below</ span >
207+ These generators read config: apiPrefix, collectionNameOverrides, columnNamingStrategy, dbImport, dialect, extStyle, …</ pre >
221208 < p class ="gs-note "> Those five files are the point: they're plain TypeScript in your repo, and < strong > yours to
222209 edit</ strong > . < code > meta gen</ code > runs those local copies — not the ones inside the package — so changing
223210 the shape of the generated code is an ordinary edit to a file you own. Install what they import:</ p >
@@ -255,13 +242,15 @@ <h2 class="section-label">5 · Choose your generators</h2>
255242 < section >
256243 < h2 class ="section-label "> 6 · Generate</ h2 >
257244 < pre class ="gs-code "> $ npx meta gen
258- gen[5]{file,status}:
259- src/generated/Task.ts,< span class ="n "> new</ span >
260- src/generated/Task.queries.ts,< span class ="n "> new</ span >
261- src/generated/Task.routes.ts,< span class ="n "> new</ span >
262- src/generated/Task.names.ts,< span class ="n "> new</ span >
263- src/generated/index.ts,< span class ="n "> new</ span >
264- summary: 5 written</ pre >
245+ meta gen — sqlite, src/generated
246+
247+ < span class ="n "> NEW</ span > src/generated/Task.ts
248+ < span class ="n "> NEW</ span > src/generated/Task.queries.ts
249+ < span class ="n "> NEW</ span > src/generated/Task.routes.ts
250+ < span class ="n "> NEW</ span > src/generated/Task.names.ts
251+ < span class ="n "> NEW</ span > src/generated/index.ts
252+
253+ 5 written</ pre >
265254 < p class ="gs-note "> That's a real run. You get four things per entity (plus a barrel):</ p >
266255 < ul class ="gs-note ">
267256 < li > < code > Task.ts</ code > — the < strong > entity</ strong > : a Drizzle table, Zod insert/update schemas, a typed
@@ -310,9 +299,15 @@ <h2 class="section-label">7 · Wire your database</h2>
310299 generated queries</ a > . Then create the tables. < code > meta migrate</ code > diffs the live database against the
311300 model and writes a paired < code > up.sql</ code > /< code > down.sql</ code > under < code > .metaobjects/migrations/</ code > :</ p >
312301 < pre class ="gs-code "> $ npx meta migrate --from-db --db file:dev.sqlite --dialect sqlite --slug init --apply
313- changes[1]{kind,count}:
314- create-table,1
315- summary: 1 create-table; applied 1 migration(s)</ pre >
302+ meta migrate — sqlite, file:dev.sqlite
303+
304+ Changes: 1 create-table
305+
306+ Written:
307+ .metaobjects/migrations/<timestamp>-init/up.sql
308+ .metaobjects/migrations/<timestamp>-init/down.sql
309+
310+ migrate: applied 1 migration(s): <timestamp>-init</ pre >
316311 </ section >
317312
318313 < section >
0 commit comments