Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ import { EntityFetcherProvider, EntityGrid } from "@metaobjectsdev/tanstack";
- **TS runtime**: Bun-first for development (zero-config TS, native test runner). Node-compatible for distribution; users install via npm/pnpm/bun without lock-in to Bun's runtime.
- **Module system**: ESM only. No CommonJS, no transpile step required.
- **Storage format**: JSON files in `metaobjects/meta.<concept>.json` at project root. `.metaobjects/.gen-state/` holds the codegen merge base: the snapshot **bodies are gitignored** (a second full copy of all generated output), but **`.hashes/` (one file per model package) is COMMITTED** — one hash per generated path, and the only thing that lets `meta gen` tell "this file is exactly what I wrote" from "somebody edited this" on a machine that did not generate it. Ignore it and a fresh clone or CI runner silently overwrites hand edits; commit it and an edited file is refused by name instead.
- **Codegen substrate**: the vendored ts-poet printer (`codegen-ts/src/poet.ts`) for greenfield emit, ts-morph for in-place edits, Biome for format pass, `git merge-file --diff3` for hand-edit-preserving regen.
- **Codegen substrate**: the vendored ts-poet printer (`codegen-ts/src/poet.ts`) for greenfield emit, ts-morph for in-place edits, no formatter in generation (the generator's writer lays out the text, ADR-0063), `git merge-file --diff3` for hand-edit-preserving regen.
- **Runtime substrate**: Kysely for TS (user-provided connection, async-only).
- **Migration substrate**: Postgres + SQLite for TS v0.3.
- **Metadata location**: resolved via `resolveCollection()` (`@metaobjectsdev/sdk`) — the single authority. `metaobjects/` is the **default value of `sources`** and nothing else: no other module, command or user-facing message may assert that a directory of that name exists or is where metadata lives. Exactly five sites may name it — `sdk/src/metadata-files.ts` (`DEFAULT_METADATA_DIR`, its single definition), `sdk/src/sources.ts` (`DEFAULT_SOURCES`, **the** default), `sdk/src/collection.ts` (inside `resolveCollection`, *applying* that default), `sdk/src/index.ts` (the barrel re-export of the constant, no use), and `cli/src/commands/init.ts` (the scaffolder **writing** the layout). Enforced by `sdk/test/no-hardcoded-metadata-dir.test.ts`, whose allowlist demands a written reason per entry. See [docs/features/metadata-sources.md](docs/features/metadata-sources.md).
Expand Down
42 changes: 37 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,31 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
integer.
- **C# and Java: a names class no longer extends its base's** when that would make a base constant
that is not a column of its own table reachable through it. It is emitted complete instead.
- **TypeScript generation runs no formatter.** `meta gen` used to pass every generated `.ts` file
through Biome after the template had laid it out; it no longer does, so `@metaobjectsdev/codegen-ts`
no longer depends on `@biomejs/js-api` or `@biomejs/wasm-nodejs`. Each file keeps the layout its
generator writes (the ts-poet printer's 120 columns, where a template used it), so the **first
`meta gen` rewrites most generated files once, in layout only**; a hand edit in a generated
file meets the three-way merge against a base with the new layout. The Hono routes no longer
carry a `// biome-ignore` line above `registerAllRoutes` and each `mount...Routes` function; a
project that lints generated code with Biome adds its own ignore. `formatTs` is still exported from
`@metaobjectsdev/codegen-ts` and now returns its input unchanged, so a generator ejected in 1.2
keeps loading and running. Run your formatter over the generated tree if you want your layout.
- **`drizzle-orm` and `zod` are optional peers of `@metaobjectsdev/codegen-ts`.** Installing the
CLI no longer installs the ORM (about 17 MB); only the code `meta gen` writes imports it. A
project installs both when it takes a generator that writes code importing them: `meta eject`
and `meta gen --list` print the install set. A project that relied on the CLI pulling them in
adds `drizzle-orm` and `zod` to its own `package.json`. A check installs the packed CLI, fails
when the ORM or a formatter comes back, and holds the install to a size budget that only moves
down (`scripts/check-install-size.mjs`, in the full CI run).
- **The SQLite driver is no longer installed with the CLI.** `@libsql/kysely-libsql` is an
optional peer of `@metaobjectsdev/cli`: it brought its own HTTP client, a polyfill and a native
binary for each libc (about 28 MB), which a Postgres or D1 project never used. `meta init`
now adds it to the `dependencies` of a SQLite project (the default dialect) and says so; a
project that already ran `init` adds it with its package manager. Without it, `meta migrate` and
`meta verify --db` against a SQLite URL stop with the install command. Postgres, MySQL and D1
projects install nothing new. With the ORM and the formatter gone as well, installing the CLI is
about 51 MB.
- **`metamodelVersion` is `1.3`.** Upgrade every port together.

### Security
Expand Down Expand Up @@ -440,7 +465,7 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
lists what the approach cannot do. It is an example on the TypeScript port, not a package.

- **A working loop first in the agent context.** The always-on file `meta init` scaffolds
(`.metaobjects/AGENTS.md` and `CLAUDE.md`) now opens with the whole loop for the declared
(`.metaobjects/AGENTS.md`) now opens with the whole loop for the declared
stack, in order: configure and run the generators (one step per declared server, with the
import or class names to wire, plus the web client when one is declared), the schema
(`meta migrate --from-db` for the first migration, `apply-pending` at boot, and a later
Expand Down Expand Up @@ -556,7 +581,8 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
- **A view the lowering cannot express is refused, not shortened.** The TypeScript view extractor
skipped any origin it could not lower, so a projection loaded clean and `meta migrate` created a
view missing a column its generated type declares. Each such shape now fails, naming the
projection and the field: an aggregate-derived entity field read where a row-level value is
projection and the field, at load where the loader can see it and in the view extractor for a
model built another way: an aggregate-derived entity field read where a row-level value is
needed, a computed reference cycle, a relative date on a field that is not temporal, and an
unknown origin or aggregate.
- **The view vocabulary lowers to SQL.** `meta migrate` builds every port's views, and it now
Expand All @@ -580,7 +606,8 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
`error-origin-passthrough-reverse-hop` (new) and `error-origin-passthrough-to-many` pin the
message.

- **An int-backed enum can be an array.** `@intValueMap` together with `isArray: true` (the
- **An int-backed enum array loads in every port, and stores in TypeScript, C# and Python.**
`@intValueMap` together with `isArray: true` (the
map on the field, or inherited from a shared enum) now loads in every port instead of
failing with `ERR_ENUM_INT_VALUE_MAP_ARRAY`, which is removed. Each element is stored as its
declared integer and read back as its member: `integer[]` on Postgres, and a JSON array of
Expand Down Expand Up @@ -786,7 +813,12 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
parameters, the error envelope, and those shapes as components. The output follows the REST contract
and the `wire` setting, and a project on any port runs them through the Node `meta` CLI. They are
reference helpers: opt-in, listed by `meta gen --list`, ejectable and gated by `verify --codegen`
(ADR-0034 Amendment 10). Protobuf is not built. See `docs/features/contract-emitters.md`.
(ADR-0034 Amendment 10). Protobuf is not built. See `docs/features/contract-emitters.md`. The
document also states this release's own API behaviour: a list's `limit` carries the project's
`api.pagination` default and maximum, a write's body says an undeclared key is refused with
`unknown_fields` (or dropped under `api.unknownFields: drop`), the error envelope carries
`issues`, `fields` and `maxLimit`, and a read-only resource says a write answers `405`. A project
that wires `openApiFile()` sees `openapi.json` change on the next `meta gen`.
- **The data spine for a model explorer.** These changes are data only. No screen reads the new
data yet.
- `meta export --effective` writes the effective canonical JSON. Every field, child and attribute
Expand Down Expand Up @@ -1710,7 +1742,7 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
- **`@metaobjectsdev/cli` no longer installs the native Biome binary.** `codegen-ts-react`,
`codegen-ts-tanstack` and the source-only `codegen-ts-angular` declared `@biomejs/biome` as a
peer dependency, which npm installs automatically, so every CLI install carried the ~94 MB
`@biomejs/cli-<platform>` binary that nothing runs: codegen formats through the WebAssembly
`@biomejs/cli-<platform>` binary that nothing runs: the CLI used the WebAssembly
build (`@biomejs/wasm-nodejs`). The peer is gone (it stays a devDependency for this repo's own
lint gate), and a fresh npm install of the CLI drops from 245 MB to 151 MB of `node_modules`.
`scripts/check-peer-ranges.ts` now fails a publishable package that requires `@biomejs/biome`
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` for TypeScript output. The config's `apiPrefix` is
`pluralize`, and `formatTs` (a no-op kept so an owned copy still loads). 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 All @@ -59,6 +59,11 @@ npm install --save-dev @metaobjectsdev/cli @metaobjectsdev/codegen-ts
npm install @metaobjectsdev/metadata @metaobjectsdev/runtime-ts
```

`drizzle-orm` and `zod` are optional peers of `@metaobjectsdev/codegen-ts`, so npm does not install
them with the CLI. Install them when a generator you take writes code that imports them.
`meta gen --list --format json` gives each generator's `install.dev` and `install.runtime`, and
`meta eject <name>...` prints the consolidated install set.

For the React + TanStack codegen packages, also:

```bash
Expand Down
10 changes: 7 additions & 3 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/features/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ command surface splits in two:

| Capability | Tool | Invocation | Notes |
|---|---|---|---|
| Project scaffold (`init`) | Node `meta` | `meta init` | TS projects; `--dialect sqlite\|postgres\|mysql\|d1` writes the codegen `dialect` in `metaobjects.config.ts` and, for sqlite, postgres and d1, `migrate.dialect` in `.metaobjects/config.json` (d1 is `--d1`; MySQL schema is not `meta migrate`'s). A new `.metaobjects/config.json` also carries `"api": { "pagination": { "defaultLimit": 50, "maxLimit": 1000 }, "unknownFields": "reject" }`, the generated list routes' page size and the refusal of undeclared write keys ([api-contract.md](api-contract.md)); `--force` over an existing config does not add it |
| Project scaffold (`init`) | Node `meta` | `meta init` | TS projects; `--dialect sqlite\|postgres\|mysql\|d1` writes the codegen `dialect` in `metaobjects.config.ts` and, for sqlite, postgres and d1, `migrate.dialect` in `.metaobjects/config.json` (d1 is `--d1`; MySQL schema is not `meta migrate`'s). A new `.metaobjects/config.json` also carries `"api": { "pagination": { "defaultLimit": 50, "maxLimit": 1000 }, "unknownFields": "reject" }`, the generated list routes' page size and the refusal of undeclared write keys ([api-contract.md](api-contract.md)); for `--dialect sqlite` it also adds `@libsql/kysely-libsql` to the project's `dependencies`, the SQLite driver the CLI's optional peer names (run your package manager's install afterwards); `--force` over an existing config does not add it |
| **Agent-context scaffold** (`agent-docs`) | **Node `meta`** | `npx meta agent-docs --server <lang>` | **any backend** — single assembler (ADR-0033); non-Node CLIs redirect here |
| **Schema migrate** | **Node `meta`** | `meta migrate` | **any backend** — schema is Node-only (ADR-0015) |
| **Schema drift** (`verify --db`) | **Node `meta`** | `meta verify --db` | **any backend** — live-DB drift, Node-only |
Expand Down
22 changes: 19 additions & 3 deletions docs/features/contract-emitters.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ port actually send and take, under the project's [`wire` setting](api-contract.m

**What they do not do.** They generate no client and no server, and they do not validate anything at
runtime. Run openapi-generator, Kiota or orval on the document for a client. The protobuf emitter in
the [design](../superpowers/specs/2026-06-11-fr-022-contract-emitters-design.md) is not built; it is
planned with binary protocols for 1.3.
the [design](../superpowers/specs/2026-06-11-fr-022-contract-emitters-design.md) is not built, and no
release is planned for it.

**Entirely opt-in.** `meta init` wires no generator. A project that does not list them gets no file.

Expand Down Expand Up @@ -160,6 +160,21 @@ field's allowed operators, `sort`, `limit`, `offset` and `withCount`, M:N traver
and per-subtype mounts, projections, reports (with the `format` parameter when `report-export` is
wired), and the error envelope.

It also states what the routes do beyond the happy path:

- **Page size.** When the project sets `api.pagination`, a list's `limit` carries that `default` and
`maximum`, and the description names the `limit_too_large` answer. Without the setting `limit`
states neither, because the server serves what it always did. A report keeps its own row cap and
states neither either.
- **Undeclared body keys.** A create, `PUT` or `PATCH` body description says an undeclared key is
refused with `400 unknown_fields` (the default) or dropped under `api.unknownFields: drop`.
The shapes stay open: the server still drops a declared key a client may not set, such as the
generated key, so a client that echoes back a row it read keeps working.
- **Validation issues.** `ApiError` carries `issues` (every problem, as `code`, `path` and
`message`), `fields` (the undeclared keys) and `maxLimit`.
- **Read-only resources.** A projection or a report has no write operations, and each of its
operations says a write answers `405 method_not_allowed`.

A list answers an array, or `{ rows, total }` with `withCount=1`, so its response is a `oneOf` of
`<Name>List` and `<Name>Page`.

Expand Down Expand Up @@ -187,7 +202,8 @@ openApiFile({
- `readOnly` and `writeOnly`: the shapes are separate.
- The TypeScript-only `search`, `filter[or]` and `filter[and]` extensions: the document states the
cross-port contract ([api-contract.md](api-contract.md)).
- 405 answers: a verb a read-only surface does not serve is absent from the document.
- 405 answers as operations: a verb a read-only surface does not serve is absent from the document,
and the surface's operations say so in prose.
- Routes you wrote by hand. Eject `openapi` and add them in `buildOpenApiDocument` if you want them
documented.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ meta gen # the regeneration, now on its own
```

**Why `--baseline=adopt` and not a plain `meta gen`.** A plain run works only if your
committed output still matches fresh output. If it does not — an engine or formatter moved
committed output still matches fresh output. If it does not — an engine moved
it, which is the usual state of a project that has not regenerated in a few releases — every
such file is refused, and a run where *everything* refuses writes **no manifest at all**:
there is then nothing to commit, and the next run refuses identically. `--baseline=adopt`
Expand Down Expand Up @@ -84,7 +84,7 @@ two people who both regenerated do not conflict over ordering.

| situation | before | after |
|---|---|---|
| File matches its recorded hash (a formatter or engine bump moved the output) | overwritten, reported `NEW` | overwritten, reported `overwrite` |
| File matches its recorded hash (an engine bump moved the output) | overwritten, reported `NEW` | overwritten, reported `overwrite` |
| File carries a hand edit | **overwritten silently** | `refused`, path named, exit code 1 |
| File we have no record of writing | **overwritten silently** | `refused`, path named, exit code 1 |
| Snapshot body present (the machine that generated it) | three-way merge | three-way merge, unchanged |
Expand Down
17 changes: 12 additions & 5 deletions docs/ports/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,18 @@ npm install --save-dev @metaobjectsdev/codegen-ts-react @metaobjectsdev/codegen-
npm install @metaobjectsdev/react @metaobjectsdev/tanstack @metaobjectsdev/runtime-web
```

`@metaobjectsdev/codegen-ts` declares `drizzle-orm` and `zod` as non-optional
peer dependencies, so npm installs both automatically. The default Fastify
routes generator (`routesFile()`) additionally needs `fastify` at runtime — it
is an **optional** peer of `@metaobjectsdev/runtime-ts` (so it is *not*
auto-installed); add it explicitly:
`@metaobjectsdev/codegen-ts` declares `drizzle-orm` and `zod` as **optional** peer
dependencies, so npm installs neither with it. Install them when the generators you
take write code that imports them; `meta gen --list --format json` gives each
generator's install set. The stock `entity`, `queries` and `routes` pair needs both:

```bash
npm install drizzle-orm zod
```

The default Fastify routes generator (`routesFile()`) additionally needs `fastify`
at runtime — it is an **optional** peer of `@metaobjectsdev/runtime-ts` (so it is
*not* auto-installed); add it explicitly:

```bash
npm install fastify
Expand Down
Loading
Loading