Commit 92396d4
feat(codegen-ts): jsonb value-object typing + collection-name control + shared VO module resolver (#49)
Three independent codegen-ts adoption fixes that share the same render
pipeline (so they land together to avoid intermingled-file rebases), plus a
timestamp-mode config knob.
1. Postgres jsonb value objects
- field.object no longer emits a native .array() — an object array lives in
ONE jsonb column, not jsonb[]. Suppressed when subType === object.
- jsonb object columns now carry .$type<VO>() / .$type<VO[]>() (the previous
.$type path was sqlite-only, so Postgres object columns inferred `unknown`).
Added an `array` flag to ColumnSpec.dollarTypeRef so the renderer picks the
single vs collection form. Applies to single objects too, not just arrays.
2. Collection (table) variable naming control
- New codegen config: `pluralizeCollections` (default true) and
`collectionNameOverrides` (per-entity exact names). Surfaced as a single
`ctx.collectionName(entity)` resolver used by every template that emits or
references a table var (schema, queries, routes, relations, inferred types),
so the declaration and all references stay consistent. Naming is a per-port
codegen concern, so this is config — not a metadata attribute — and carries
no cross-port conformance cost.
3. Shared value-object module resolver (consistency fix)
- New `valueObjectModuleSpecifier()` is the single source of truth feeding all
three places that reference a VO module — the field's TS type, its Zod
schema, and the Drizzle .$type<>(). Previously each hardcoded `./<VO>.js`,
which was wrong under package layout + cross-package refs and ignored
extStyle. Now layout/package/extStyle-aware (matching FK-reference
resolution); proven by a two-package end-to-end fixture.
4. `timestampMode` config ("date" | "string", default "string") applied
uniformly to the plain timestamp + timestamptz override branches, keeping the
Drizzle column aligned with the generated Zod + the cross-port wire contract.
Default config reproduces byte-identical output, so all golden/conformance
fixtures are unchanged. New coverage: jsonb-VO column cases, the
pluralize/override resolver, the VO module resolver (flat/same-pkg/cross-pkg/
extStyle), and an end-to-end cross-package VO fixture asserting all three
references resolve identically.
Tests: codegen-ts 799/0, codegen-ts-react/angular/tanstack + conformance 134/0,
migrate-ts 488/0, cli 277/0.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 95ed8a2 commit 92396d4
23 files changed
Lines changed: 507 additions & 78 deletions
File tree
- server/typescript/packages/codegen-ts
- src
- templates
- test
- fixtures
- templates
Lines changed: 51 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
139 | 140 | | |
140 | | - | |
141 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
142 | 147 | | |
143 | 148 | | |
144 | | - | |
145 | | - | |
| 149 | + | |
| 150 | + | |
146 | 151 | | |
147 | 152 | | |
148 | 153 | | |
| |||
163 | 168 | | |
164 | 169 | | |
165 | 170 | | |
| 171 | + | |
166 | 172 | | |
167 | 173 | | |
168 | 174 | | |
| |||
173 | 179 | | |
174 | 180 | | |
175 | 181 | | |
176 | | - | |
177 | | - | |
178 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
179 | 186 | | |
180 | 187 | | |
181 | 188 | | |
| |||
202 | 209 | | |
203 | 210 | | |
204 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
205 | 221 | | |
206 | 222 | | |
207 | 223 | | |
208 | 224 | | |
| 225 | + | |
209 | 226 | | |
210 | 227 | | |
211 | 228 | | |
| |||
271 | 288 | | |
272 | 289 | | |
273 | 290 | | |
274 | | - | |
| 291 | + | |
275 | 292 | | |
276 | 293 | | |
277 | 294 | | |
| |||
310 | 327 | | |
311 | 328 | | |
312 | 329 | | |
313 | | - | |
| 330 | + | |
314 | 331 | | |
315 | 332 | | |
316 | 333 | | |
| |||
374 | 391 | | |
375 | 392 | | |
376 | 393 | | |
377 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
378 | 399 | | |
379 | 400 | | |
380 | 401 | | |
| |||
421 | 442 | | |
422 | 443 | | |
423 | 444 | | |
424 | | - | |
425 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
426 | 454 | | |
427 | 455 | | |
428 | 456 | | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
435 | 460 | | |
436 | 461 | | |
437 | 462 | | |
438 | 463 | | |
439 | | - | |
| 464 | + | |
440 | 465 | | |
441 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
442 | 472 | | |
443 | 473 | | |
444 | 474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 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 | + | |
52 | 80 | | |
53 | 81 | | |
54 | 82 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
71 | 94 | | |
72 | 95 | | |
73 | 96 | | |
| |||
102 | 125 | | |
103 | 126 | | |
104 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
105 | 131 | | |
106 | 132 | | |
107 | 133 | | |
| |||
222 | 248 | | |
223 | 249 | | |
224 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
225 | 254 | | |
226 | 255 | | |
227 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | | - | |
| 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 | + | |
64 | 86 | | |
65 | 87 | | |
66 | 88 | | |
| |||
Lines changed: 28 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
40 | 48 | | |
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
46 | 61 | | |
47 | 62 | | |
48 | 63 | | |
| |||
58 | 73 | | |
59 | 74 | | |
60 | 75 | | |
61 | | - | |
62 | | - | |
| 76 | + | |
| 77 | + | |
63 | 78 | | |
64 | 79 | | |
65 | 80 | | |
| 81 | + | |
66 | 82 | | |
67 | 83 | | |
68 | 84 | | |
69 | 85 | | |
70 | 86 | | |
71 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
72 | 92 | | |
73 | 93 | | |
74 | 94 | | |
| |||
86 | 106 | | |
87 | 107 | | |
88 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
89 | 113 | | |
90 | 114 | | |
91 | 115 | | |
92 | 116 | | |
93 | 117 | | |
| 118 | + | |
94 | 119 | | |
95 | 120 | | |
96 | 121 | | |
97 | 122 | | |
98 | 123 | | |
99 | 124 | | |
| 125 | + | |
100 | 126 | | |
101 | 127 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
176 | 179 | | |
177 | 180 | | |
178 | 181 | | |
| |||
0 commit comments