Skip to content

Commit a1d41d1

Browse files
committed
docs(changelog): the expose option on both routes generators
Covers #348. States the two rulings rather than just the feature: why an option rather than the `filter` remedy that answered @emit* (filter decides whether the file emits at all, so it cannot express a verb subset), and why not metadata (which verbs a deployment exposes is a property of the app, not the model). Also records that the fixed read-only TPH mount INTERSECTS rather than being replaced, so the option can narrow it but never widen it into a route that fails at runtime.
1 parent f0699ad commit a1d41d1

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,42 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
77

88
## [Unreleased]
99

10+
### Added — `expose` on both routes generators: mount fewer than five CRUD verbs
11+
12+
([#348](https://github.com/metaobjectsdev/metaobjects/issues/348)) `expose` has always
13+
existed on the runtime mount helpers, and across **both** generated route emitters exactly
14+
one call site passed it — the TPH polymorphic mount's hardcoded `["list", "get"]`. For a
15+
vanilla or write-through entity, neither Fastify nor Hono could restrict verbs. The issue
16+
named Hono; the gap was both.
17+
18+
```ts
19+
routesFileHono({ expose: (e) => e.name === "AuditEntry" ? ["list", "get"] : undefined })
20+
routesFile({ expose: ["list", "get"] })
21+
```
22+
23+
Verbs, or a per-entity function. Absent — or a function returning `undefined` — means all
24+
five and emits **no `expose` key at all**, so output is byte-identical for every project
25+
that does not use it.
26+
27+
**Why an option rather than `filter`.** The remedy that answered the retired `@emit*`
28+
family — *narrow it with the generator's own `filter`* — cannot express this. `filter`
29+
decides whether the file emits **at all**, per entity, so it can only remove the whole
30+
surface; restricting to a subset of verbs is a different axis. Same reasoning that made a
31+
TPH subtype's opt-**IN** grid `tphSubtypeGrids` rather than a filter. And deliberately not
32+
metadata: which verbs a deployment exposes is a property of the app, not the model — the
33+
same entity is read-only in one service and writable in another.
34+
35+
**A read-only mount narrows but never widens.** A TPH polymorphic mount is read-only by
36+
construction, so an author-supplied `expose` **intersects** with that fixed set rather than
37+
replacing it: it may narrow to just `list`, and asking for `create` yields an empty set
38+
instead of a route that fails at runtime.
39+
40+
The reference templates carry the option too, so an ejected generator behaves identically.
41+
`CRUD_VERBS`, `resolveExpose`, `intersectExpose` and `exposeLine` are public, because an
42+
owned routes generator composes the same render call — and the verb union, which is
43+
restated in `codegen-ts` (it emits a call to the runtime helper, it never links against
44+
it), is now gated against **both** runtime declarations so the two cannot drift.
45+
1046
### Changed — `AGENT_DOCS_BODY` is removed; the agent context has one source
1147

1248
**BREAKING for anyone importing `AGENT_DOCS_BODY` from `@metaobjectsdev/sdk/agent-docs`.**

0 commit comments

Comments
 (0)