Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ meta migrate --dry-run # preview without writing migration file
meta migrate apply-pending # replay the committed chain against --db (no diff, no metadata)
meta verify --codegen --templates # drift gates: generated code and docs pages, prompt bodies
meta verify --db | --replay # schema drift vs a live DB | the chain applies to an empty one
meta gen --generators docs,api-docs # only these declared entries; docs are generators (docsFile(), apiDocsFile(), agentDocsFile(), ...)
meta gen --generators docs-site,api-docs # only these declared entries; docs are generators (docsSiteFile(), apiDocsFile(), agentDocsFile(), ...)
meta upgrade --apply # rewrite metadata a retirement made illegal
meta types [<type>] --format json|toon # what vocabulary this build actually registers
meta fmt [<file>...] [--check] # rewrite metadata into canonical form; --check lists drift (#304, every port)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ A concrete report whose read source is `@kind: view` is served by every port's g
- **Every derived field with filter operators is filterable and sortable**, dimension and measure alike, with its type's own operators. You cannot narrow that set: a report has no field to put `@filterable` on. A field of the `@from` entity that the report does not expose is refused with a `400`.
- A time dimension at `day` or coarser is `YYYY-MM-DD`; a null measure is `null` with the key present (a measure with `@default` is never null); `currency` is integer minor units.
- **A decimal (`avg`, a ratio, a `sum` of a decimal) is written per the project's `wire` setting**: by default, the port's language-standard form (a JSON number in C#, Java and Kotlin; a string in Python and TypeScript), and under `"wire": { "decimals": "string" }` one canonical string in every port (`12.5`, never `12.50` or an exponent). Do not parse it as a float to compare.
- `meta gen` writes a model page for every report (`docsFile()`; a sourceless one is marked "Not served") and an API page for a served one (`apiDocsFile()`) — each an ordinary entry in `generators`.
- `meta gen` shows every report in the model explorer (`docsSiteFile()`; a sourceless one is marked "Not served") and writes an API page for a served one (`apiDocsFile()`) — each an ordinary entry in `generators`.

The files each port generates are in the `metaobjects-codegen` skill's reference for that language ("Reports").

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Everything a generator reads comes from `@metaobjectsdev/codegen-ts`: `perEntity
`perPackage` / `perModel`, `isAbstract`, `hasAnyRdbSource`, `isProjection`,
`servesReadApi` / `servesWriteApi`, `objectRefTarget`, `enumValues`, `effectivePackage`,
`packageToPath`, `servedPath`, `toCamelCase` / `toPascalCase` / `toSnakeCase` /
`pluralize`, and `formatTs` (a no-op kept so an owned copy still loads). The config's `apiPrefix` is
`pluralize`. (The `formatTs` no-op export was removed in 1.3.0; delete the import from an owned copy.) The config's `apiPrefix` is
`ctx.renderContext?.apiPrefix`. Worked JSON Schema and OpenAPI 3.1 generators to copy:
`docs/recipes/generators/typescript/` in the MetaObjects repository.

Expand Down Expand Up @@ -146,18 +146,19 @@ package, and an owned copy imports it from `@metaobjectsdev/codegen-ts/engine`.

Some ejectable entries behave differently from the rest:

- **`docs`, `api-docs`, `requirements` and `agent-docs` are run by `meta gen`, like any
- **`api-docs`, `requirements` and `agent-docs` are run by `meta gen`, like any
other entry.** There is no separate docs command (removed in 1.1.0, ADR-0034 Amendment
9): list `docsFile()`, `apiDocsFile()`, `requirementsFile()` and `agentDocsFile()` in
9): list `apiDocsFile()`, `requirementsFile()` and `agentDocsFile()` in
`generators` the same way you list `entityFile()`. Each defaults to a target named
`docs` (`targets.docs.outDir`) unless given its own `target`, and a run that lists one
while `targets` has no `docs` entry is refused, naming the generator. To change the
pages, `meta eject docs` (or `api-docs`, `requirements`, `agent-docs`) and list the copy
pages, `meta eject api-docs` (or `requirements`, `agent-docs`) and list the copy
in `generators` in place of the packaged factory — there is no separate `docs` block to
put it in. To change only a page's wording, put your own
`templates/docs/entity-page.md.mustache` in the project instead. Full reference:
put it in. To change only a page's wording, point the factory's `templates` option at your own
directory. For people, list `docsSiteFile()` (the model explorer); `docsFile()` (per-object
Markdown pages) was removed in 1.3.0 and `meta gen` refuses it. Full reference:
`typescript-docs.md`.
- **The ER diagram comes from `docsFile()`** (overview page, and each entity's page). The
- **The ER diagram is in the model explorer** (`docsSiteFile()`). The
standalone `mermaidErDiagram()` / `"mermaid-er"` generator was removed in 1.1; a config
that still wires it fails with a message saying so. Remove it and run `meta gen`.
- **`shared-model` ejects with its artifact builder.** The copy decides which source files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,28 @@ generate, docs included). Each factory is an ordinary entry in `generators`, fro

| Factory | Registry name | Writes |
|---|---|---|
| `docsFile()` | `docs` | the neutral model surface — one page per entity and per template (`<Entity>.md`, `<Template>.md`), plus an overview with the whole-model ER diagram. Options: `apiSurfaces`, `templates`. |
| `apiDocsFile()` | `api-docs` | the api reference — `api/<Entity>.md`, `api/README.md`, `api/AGENT-API.md`: the concrete imports, signatures, payload field shapes and runnable examples for THIS project's generated code. Options: `subDir` (default `api`), `modelBaseUrl`. |
| `requirementsFile()` | `requirements` | the declared `requirement.*` ledger, each entry headed by its dotted path and `title`. Writes nothing for a model with no `requirement.*` node. |
| `agentDocsFile()` | `agent-docs` | `agent/schema.md`, `agent/ui.md` (only when the run also lists a client-tier generator, OR the config sets `includeUiTier: true` — the escape hatch for a docs-only config whose UI is generated by a separate config; skipping it with a UI surface in the model and `includeUiTier` unset prints an advisory naming `includeUiTier`; `includeUiTier: false` says there is no UI anywhere and skips it without one) and `agent/requirements.md` — the three `agent/` pages the always-on pointer reads before touching a tier. |
| `metamodelDocsFile()` | `metamodel-docs` | the built-in vocabulary reference, under `metamodel/` (was `meta docs --metamodel`). |
| `docsSiteFile()` | `docs-site` | an HTML site under `site/` (was `meta docs --site`): the model explorer by default (what the software does, the model map, requirement pages, matrix, trace, API, gaps), drawn from an `explorer.json` built in the same run; `site: "classic"` writes the earlier site. Options: `site`, `prompts`. `meta eject docs-site` copies its templates and assets to `codegen/docs-site/` (was `meta docs --scaffold-site`). |
| `docsSiteFile()` | `docs-site` | an HTML site under `site/` (was `meta docs --site`): the model explorer by default (what the software does, the model map, requirement pages, matrix, trace, API, gaps), drawn from an `explorer.json` built in the same run; the earlier `site: "classic"` site was removed in 1.3.0. Options: `site`, `prompts`. `meta eject docs-site` copies its templates and assets to `codegen/docs-site/` (was `meta docs --scaffold-site`). |

```ts
import { defineConfig } from "@metaobjectsdev/cli";
import {
agentDocsFile, apiDocsFile, docsFile, entityFile, requirementsFile, routesFile,
agentDocsFile, apiDocsFile, docsSiteFile, entityFile, requirementsFile, routesFile,
} from "@metaobjectsdev/codegen-ts/generators";

export default defineConfig({
outDir: "src/generated",
targets: { docs: { outDir: "./docs/generated" } },
generators: [entityFile(), routesFile(), docsFile(), apiDocsFile(), requirementsFile(), agentDocsFile()],
generators: [entityFile(), routesFile(), docsSiteFile(), apiDocsFile(), requirementsFile(), agentDocsFile()],
});
```

```bash
npx meta gen # runs every listed generator, docs included
npx meta gen --generators docs,api-docs,requirements,agent-docs # documentation only
npx meta gen --generators docs-site,api-docs,requirements,agent-docs # documentation only
```

**Give docs factories a `docs` target.** Each defaults to the target named `docs`
Expand All @@ -58,12 +57,11 @@ before/after and the flag-to-option table: <https://github.com/metaobjectsdev/me
section "TypeScript".

**An owned docs generator goes in `generators`, like any other owned copy.** `meta eject
docs` (or `api-docs`, `requirements`, `agent-docs`, `metamodel-docs`) copies the generator
api-docs` (or `requirements`, `agent-docs`, `metamodel-docs`) copies the generator
and prints the import and the entry to add to `generators` — there is no separate
`docs: { generators: [...] }` block to put it in any more.

**There is no `mermaidErDiagram()` generator.** `docsFile()` draws the ER diagram on its
overview page and on each entity's page with nothing else wired. A config that still
**There is no `mermaidErDiagram()` generator.** `docsSiteFile()`, the model explorer, draws the ER diagram with nothing else wired. A config that still
imports it, or names `"mermaid-er"`, fails with a message that says so; delete the entry
and run `meta gen`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,10 @@ list with `{% if items | length %}` when the same template must render in Python

## See which fields a template consumes

List `docsFile()` in `generators` and run `meta gen` to emit the model surface to the
`docs` target — one page per `template.*` at `<outDir>/<Template>.md`. Each template page
has a `## Template source` section that shows the Mustache source with every `{{var}}`
linked to that field's doc page (`<outDir>/<Owner>.md#field-<name>`), plus a variables
table — so you can see exactly which payload fields a template reads. Those links are
build-time drift-gated against the render `verify()` engine, so a link can't claim a
field that `verify()` would reject. (`docsFile()` writes the model surface; `apiDocsFile()`
writes the SDK/API surface, by default under `api/` of the same target — both are ordinary
entries in `generators`, there is no separate docs command.)
List `docsSiteFile()` in `generators` and run `meta gen`: the model explorer (`docs-site`,
under `site/` of the `docs` target) shows each `template.*` with its payload fields, so you can
see which fields a template reads. `meta verify --templates` is the drift gate: it checks
each `{{var}}` against the render `verify()` engine, so a template can't name a field that
`verify()` would reject. (The per-object Markdown pages `docsFile()` wrote were removed in
1.3.0. `apiDocsFile()` writes the SDK/API surface, by default under `api/` of the `docs`
target; both are ordinary entries in `generators`, there is no separate docs command.)
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ stack are installed. The other files are topics: open one when its row matches t
| `references/typescript-prisma.md` | a TypeScript project that keeps Prisma as its ORM |
| `references/typescript-retargeting.md` | a TypeScript project on a framework other than Fastify, Hono or React |
| `references/typescript-templates.md` | declarative Mustache template-codegen in a TypeScript project |
| `references/typescript-docs.md` | the docs generators (`docsFile`, `apiDocsFile`, `agentDocsFile`, `requirementsFile`, `metamodelDocsFile`, `docsSiteFile`) in a TypeScript project |
| `references/typescript-docs.md` | the docs generators (`apiDocsFile`, `agentDocsFile`, `requirementsFile`, `metamodelDocsFile`, `docsSiteFile`) in a TypeScript project |

## When generated output does not fit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ directory: another port's generated pages count as foreign files, and in a share
directory each port's `verify --codegen` reports the other ports' pages as drift. Migrating a project that ran
`metaobjects docs`: <https://github.com/metaobjectsdev/metaobjects/blob/main/docs/features/migrations/docs-are-generators.md>, section "Python".

**The neutral model pages are a Node `meta gen` generator, not something this port emits.**
`meta docs`'s language-neutral model surface was retired along with the rest of
`meta docs` in 1.1.0 (ADR-0034 Amendment 9); a TypeScript project in the same repo lists
`docsFile()` in its own `generators` for that surface. This port's `api-docs` writes only
**There are no neutral Markdown model pages.** `meta docs`'s language-neutral model surface was
retired in 1.1.0 (ADR-0034 Amendment 9) and the TypeScript `docsFile()` that replaced it was
removed in 1.3.0; people read the model in the explorer (`docs-site`). This port's `api-docs` writes only
its own api reference.

## Write your own generator
Expand Down
Loading
Loading