Commit ba34510
fix(codegen-ts): the routes template invites a copy that does not compile
FR-040's answer to "MetaObjects does not ship a codegen package per framework" is
that you own the generator and retarget its emit. Most tiers make that true by
RELOCATING the composition into the ejected file — `entity.ts` and `queries.ts`
carry the composer's body verbatim, so every primitive they call is public by
construction. The routes tier does not: its composition is richer (M:N junction
traversal, TPH per-subtype route sets) and stays in the engine as
`renderRoutesFile`, so the template's `customize:` note tells an adopter
retargeting to another HTTP framework to copy that body out of the package source.
Follow that instruction and you get a file that does not compile. Of the sixteen
symbols the body imports from inside the package, fourteen resolve from
`@metaobjectsdev/codegen-ts` and two do not — `routesHandlerName` and
`TPH_POLYMORPHIC_VERBS`, both `TS2305: has no exported member`. Verified against
the package's own exports map, not inferred: a probe importing all sixteen from the
public entry reported exactly those two.
It matters more than the two lines suggest. HTTP framework is the tier an adopter is
MOST likely to have an opinion about — anyone outside Fastify and Hono has to
retarget it, and everyone else can leave every other tier alone. So the one escape
that had to work is the one that did not, and it failed at the point where the
adopter has already committed to the approach.
Both are exported now, and the gate is the durable half. It DERIVES the required set
from `renderRoutesFile`'s own import statements rather than restating them, because a
hand-kept list reproduces the defect one level up: the body gains an import, nobody
re-reads the list, and the escape silently breaks again. It also asserts its own
premise — that the reference template still contains the sentence inviting the copy —
so if that instruction is withdrawn the test fails and asks to be re-read rather than
quietly guarding nothing.
Proven by breaking it: with `routesHandlerName` un-exported the gate goes red naming
it, and green again when restored.
Found while auditing how tightly the generated surface couples to the libraries the
maintainer's own adopter estates happen to use. All seven are TypeScript on Drizzle
with Postgres or D1, so the estate loop cannot see this class of problem — an escape
hatch nobody in the estate set needs to take.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3v6M6uqECZ2Sb5eUv6YY1 parent 0f152bf commit ba34510
2 files changed
Lines changed: 110 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
87 | 92 | | |
88 | 93 | | |
89 | 94 | | |
| |||
194 | 199 | | |
195 | 200 | | |
196 | 201 | | |
197 | | - | |
| 202 | + | |
198 | 203 | | |
199 | 204 | | |
200 | 205 | | |
| |||
Lines changed: 103 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
0 commit comments