You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 17d7f87
Browse filesBrowse the repository at this point in the historyBrowse files
Typed projection views + target runtime flag (0.11.6) (#72)
* feat(codegen-ts): typed projection view columns + honor allowlists:false
Projection (view) codegen had two gaps that made a generated `.existing()`
pgView unusable for a typed read:
- It emitted `pgView(name, {})` with no column map, so `db.select().from(view)`
yielded `{}` rows. Now emits the typed column map from the projection fields
(honoring @dbColumnType — e.g. a passthrough of a jsonb column → `jsonb(...)`,
timestamps → `timestamp(..., { mode })`), carrying `.notNull()` (the only table
modifier valid on an existing view).
- It always imported `@metaobjectsdev/runtime-ts` for the filter/sort allowlists,
ignoring the `allowlists` flag that entity-file already honors. renderEntityFile
now threads `allowlists` (+ `timestampMode`) to renderProjectionDecl, which omits
the allowlists (and the runtime-ts import) when false — so a dependency-free
consumer gets compilable output.
Adds projection-decl regression tests. Verified end-to-end against a real
consumer (typed view-backed reads compile + run).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* feat(codegen-ts): projection passthroughs resolve value-object refs
A field.object passthrough in a projection collapsed to z.unknown() (Zod) and a
bare jsonb column (no $type), losing the value-object shape. Now the projection
declaration resolves @objectref the same way the entity codegen does:
- the read Zod schema references the VO's <Ref>InsertSchema (so z.infer carries
the VO shape, not unknown),
- the .existing() view column narrows to .$type<VO>() so a typed db.select()
returns the VO type.
Import modules resolve layout/package/extStyle-aware via the shared
valueObjectModuleSpecifier when a RenderContext is threaded (entity-file now
passes ctx), with a flat same-dir fallback for bare unit-test calls. Adds a
projection-decl regression test. Verified against a real consumer (view-backed
reads now carry the precise VO types).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* feat(codegen-ts): contract-only projection output (includeViewDecl flag)
Add an includeViewDecl option (default true) on the entityFile generator,
threaded to renderProjectionDecl. When false, the projection emits only the
read Zod schema + inferred type + constants — NO Drizzle .existing() view
declaration and no drizzle-orm import. This lets a projection's contract type
be generated into a runtime-free types package (e.g. a shared package consumed
by a web client) while the Drizzle view stays in the DB-layer target.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(codegen-ts): replace includeViewDecl with a target-level runtime flag
The `includeViewDecl` option (added on this branch) was scoped to the wrong
concept — it singled out the projection's view declaration, when the real axis
is the TARGET's audience: a server package wants the full DB layer, a contract
package consumed by a UI client wants types only. Per-artifact "drop this one
binding" booleans don't generalize: the next consumer needs `includeTableDecl`,
then `includeQueryHelpers`, and each target has to remember to set them all.
Replace it with one flag on the target: `runtime` (default true).
- `runtime: false` = a contract-only target. Every object renders as its plain
shape (interface + Zod), every projection as its read schema + inferred type.
No drizzle-orm (no pgTable / pgView), no runtime-ts allowlists. The flag lives
on ResolvedTarget, so it reaches every template as `ctx.selfTarget.runtime`
with no new plumbing.
- `allowlists` stays as the finer Fastify-vs-Hono opt-out WITHIN a runtime
target — it's a different axis (runtime-ts dependency, not drizzle).
Views stop being special: a contract projection drops its pgView the same way a
contract entity drops its pgTable. EntityFileOpts loses `includeViewDecl`; the
low-level renderProjectionDecl keeps its opt (driven from the target now).
Tests: add a contract-target (runtime:false) block asserting a projection keeps
its Zod schema + type but emits no pgView/drizzle-orm, and a write-through entity
renders its plain shape with no pgTable. 818 pass.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* fix(codegen-ts-react,tanstack): add runtime to cross-target test ResolvedTarget literals
The new required `runtime` field on ResolvedTarget broke the workspace typecheck
in the two client codegen packages, whose cross-target tests construct target
literals directly. codegen-ts's own tests were already updated; these two siblings
typecheck against codegen-ts's built dist and were missed.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments