@metaobjectsdev/codegen-ts-tanstack 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { code, imp, joinCode } from "ts-poet";
2
- import { GENERATED_HEADER, isProjection, pluralize, entityModuleSpecifier } from "@metaobjectsdev/codegen-ts";
1
+ import { code, imp, joinCode, Import } from "ts-poet";
2
+ import { GENERATED_HEADER, isProjection, pluralize, entityModuleSpecifier, isTphDiscriminatorBase, tphPlan, } from "@metaobjectsdev/codegen-ts";
3
3
  /**
4
4
  * Render <Entity>.hooks.ts — query-key factory + 2 query hooks + (for non-projections) 3 mutation hooks.
5
5
  *
@@ -20,19 +20,97 @@ export function renderHooksFile(entity, ctx) {
20
20
  // Import the entity's own file. Same target → relative "./Entity"; cross
21
21
  // target → importBase-qualified package path.
22
22
  const entityModule = entityModuleSpecifier(ctx.selfTarget, ctx.entityModuleTarget, entity.package, entity.name, ctx.extStyle);
23
+ // FR-017 Tier 3: a TPH discriminator base gets a polymorphic + per-subtype
24
+ // hooks file (the subtype entities are filtered out of this generator).
25
+ if (isTphDiscriminatorBase(entity, ctx.loadedRoot)) {
26
+ return renderTphHooksFile(entity, ctx, entityModule);
27
+ }
23
28
  if (isProjection(entity)) {
24
- return renderReadOnlyHooksFile(entity, entityModule);
29
+ return renderReadOnlyHooksFile(entity, entityModule, ctx);
25
30
  }
26
- return renderFullHooksFile(entity, entityModule);
31
+ return renderFullHooksFile(entity, entityModule, ctx);
32
+ }
33
+ // ---------------------------------------------------------------------------
34
+ // FR-018 — M:N collection hook(s).
35
+ //
36
+ // For each many-to-many relationship the source declares (`@cardinality: "many"`
37
+ // + `@through`), emit `use<Source><Relation>(sourceId, opts?)` — a useQuery that
38
+ // fetches the REST sub-resource `GET /<source-plural>/{sourceId}/<relationName>`
39
+ // (the exact URL mountM2mRoute serves) and returns the typed target collection
40
+ // (`Target[]`). The query is enabled only when sourceId is present, so callers
41
+ // can pass `undefined` before the parent row loads. A symmetric self-join is
42
+ // still ONE collection hook (the server unions both junction columns on read).
43
+ // ---------------------------------------------------------------------------
44
+ /** The M:N relation entries for an entity (cardinality 'many' + a junction). */
45
+ function m2mEntriesFor(entity, ctx) {
46
+ return (ctx.relationMap.get(entity.name) ?? []).filter((e) => e.cardinality === "many" && e.junctionEntity !== undefined);
47
+ }
48
+ /** The `relation: (relation, sourceId) => ...` query-key factory line, included
49
+ * in the keys factory ONLY when the entity has M:N relationships. */
50
+ function m2mKeyLine(keysVar) {
51
+ return (` relation: (relation: string, sourceId: number | undefined) =>\n` +
52
+ ` [...${keysVar}.all(), "relation", relation, sourceId ?? null] as const,`);
53
+ }
54
+ /**
55
+ * Render `use<Source><Relation>(sourceId, opts?)` per M:N relationship. Returns
56
+ * null when the entity has no M:N relationships (no extra hooks emitted).
57
+ */
58
+ function renderM2mHooks(entity, ctx, keysVar, entries) {
59
+ if (entries.length === 0)
60
+ return null;
61
+ const useQuerySym = imp("useQuery@@tanstack/react-query");
62
+ const useQueryOptionsSym = imp("t:UseQueryOptions@@tanstack/react-query");
63
+ const useQueryResultSym = imp("t:UseQueryResult@@tanstack/react-query");
64
+ const useEntityFetcherSym = imp("useEntityFetcher@@metaobjectsdev/tanstack");
65
+ const source = entity.name;
66
+ // Distinct target row types, imported (aliased) from each target's entity
67
+ // module. ts-poet's imp() tracks + hoists these into the import block. The
68
+ // <Target>RelRow alias avoids colliding with the source file's own
69
+ // `type <Source> as <Source>Row` import on a self-join (source === target).
70
+ const targetTypeSym = new Map();
71
+ for (const e of entries) {
72
+ if (targetTypeSym.has(e.targetEntity))
73
+ continue;
74
+ const mod = entityModuleSpecifier(ctx.selfTarget, ctx.entityModuleTarget, ctx.packageOf.get(e.targetEntity), e.targetEntity, ctx.extStyle);
75
+ // `import { type <Target> as <Target>RelRow } from "<mod>"` — the RelRow
76
+ // alias avoids colliding with the source file's own `type <Source> as
77
+ // <Source>Row` import on a self-join (source === target).
78
+ targetTypeSym.set(e.targetEntity, Import.importsName(`${e.targetEntity}RelRow`, mod, true, e.targetEntity));
79
+ }
80
+ const hooks = entries.map((e) => {
81
+ const targetSym = targetTypeSym.get(e.targetEntity);
82
+ const hookName = `use${source}${capitalize(e.name)}`;
83
+ const relLit = JSON.stringify(e.name);
84
+ return code `
85
+ export function ${hookName}(
86
+ sourceId: number | undefined,
87
+ opts?: Omit<${useQueryOptionsSym}<${targetSym}[]>, "queryKey" | "queryFn">,
88
+ ): ${useQueryResultSym}<${targetSym}[]> {
89
+ const fetcher = ${useEntityFetcherSym}();
90
+ return ${useQuerySym}<${targetSym}[]>({
91
+ queryKey: ${keysVar}.relation(${relLit}, sourceId),
92
+ queryFn: () => fetcher<${targetSym}[]>(\`\${${source}.$apiPrefix}\${${source}.$path}/\${sourceId}/${e.name}\`),
93
+ enabled: sourceId != null && (opts?.enabled ?? true),
94
+ ...opts,
95
+ });
96
+ }
97
+ `;
98
+ });
99
+ return joinCode(hooks, { on: "\n" });
100
+ }
101
+ function capitalize(s) {
102
+ return s.charAt(0).toUpperCase() + s.slice(1);
27
103
  }
28
104
  // ---------------------------------------------------------------------------
29
105
  // Read-only path (projections)
30
106
  // ---------------------------------------------------------------------------
31
- function renderReadOnlyHooksFile(entity, entityModule) {
107
+ function renderReadOnlyHooksFile(entity, entityModule, ctx) {
32
108
  const entityName = entity.name;
33
109
  const entityNamePlural = pluralize(entityName);
34
110
  const lcEntity = entityName.charAt(0).toLowerCase() + entityName.slice(1);
35
111
  const keysVar = `${lcEntity}Keys`;
112
+ const m2mEntries = m2mEntriesFor(entity, ctx);
113
+ const relationKeyLine = m2mEntries.length > 0 ? `\n${m2mKeyLine(keysVar)}` : "";
36
114
  const useQuerySym = imp("useQuery@@tanstack/react-query");
37
115
  const useQueryOptionsSym = imp("t:UseQueryOptions@@tanstack/react-query");
38
116
  const useQueryResultSym = imp("t:UseQueryResult@@tanstack/react-query");
@@ -51,7 +129,7 @@ export const ${keysVar} = {
51
129
  lists: () => [...${keysVar}.all(), "list"] as const,
52
130
  list: (filter?: ${entityName}Filter) => [...${keysVar}.lists(), filter ?? {}] as const,
53
131
  details: () => [...${keysVar}.all(), "detail"] as const,
54
- detail: (id: number) => [...${keysVar}.details(), id] as const,
132
+ detail: (id: number) => [...${keysVar}.details(), id] as const,${relationKeyLine}
55
133
  };
56
134
  `;
57
135
  const queries = code `
@@ -80,7 +158,8 @@ export function use${entityNamePlural}(
80
158
  });
81
159
  }
82
160
  `;
83
- const body = joinCode([queryKeys, queries], { on: "\n" });
161
+ const m2mHooks = renderM2mHooks(entity, ctx, keysVar, m2mEntries);
162
+ const body = joinCode(m2mHooks ? [queryKeys, queries, m2mHooks] : [queryKeys, queries], { on: "\n" });
84
163
  const header = `// ${GENERATED_HEADER}-tanstack — DO NOT EDIT.\n` +
85
164
  `// Source metadata: ${entityName} (${entity.fqn()})\n`;
86
165
  return header + entityImports.toString() + body.toString();
@@ -88,11 +167,13 @@ export function use${entityNamePlural}(
88
167
  // ---------------------------------------------------------------------------
89
168
  // Full path (writable entities — table-backed or write-through)
90
169
  // ---------------------------------------------------------------------------
91
- function renderFullHooksFile(entity, entityModule) {
170
+ function renderFullHooksFile(entity, entityModule, ctx) {
92
171
  const entityName = entity.name;
93
172
  const entityNamePlural = pluralize(entityName);
94
173
  const lcEntity = entityName.charAt(0).toLowerCase() + entityName.slice(1);
95
174
  const keysVar = `${lcEntity}Keys`;
175
+ const m2mEntries = m2mEntriesFor(entity, ctx);
176
+ const relationKeyLine = m2mEntries.length > 0 ? `\n${m2mKeyLine(keysVar)}` : "";
96
177
  const useMutationSym = imp("useMutation@@tanstack/react-query");
97
178
  const useQuerySym = imp("useQuery@@tanstack/react-query");
98
179
  const useQueryClientSym = imp("useQueryClient@@tanstack/react-query");
@@ -117,7 +198,7 @@ export const ${keysVar} = {
117
198
  lists: () => [...${keysVar}.all(), "list"] as const,
118
199
  list: (filter?: ${entityName}Filter) => [...${keysVar}.lists(), filter ?? {}] as const,
119
200
  details: () => [...${keysVar}.all(), "detail"] as const,
120
- detail: (id: number) => [...${keysVar}.details(), id] as const,
201
+ detail: (id: number) => [...${keysVar}.details(), id] as const,${relationKeyLine}
121
202
  };
122
203
  `;
123
204
  const queries = code `
@@ -146,6 +227,7 @@ export function use${entityNamePlural}(
146
227
  });
147
228
  }
148
229
  `;
230
+ const m2mHooks = renderM2mHooks(entity, ctx, keysVar, m2mEntries);
149
231
  const mutations = code `
150
232
  export function useCreate${entityName}(
151
233
  opts?: Omit<${useMutationOptionsSym}<${entityName}Row, Error, ${entityName}Insert>, "mutationFn">,
@@ -200,9 +282,178 @@ export function useDelete${entityName}(
200
282
  });
201
283
  }
202
284
  `;
203
- const body = joinCode([queryKeys, queries, mutations], { on: "\n" });
285
+ const body = joinCode(m2mHooks ? [queryKeys, queries, m2mHooks, mutations] : [queryKeys, queries, mutations], { on: "\n" });
204
286
  const header = `// ${GENERATED_HEADER}-tanstack — DO NOT EDIT.\n` +
205
287
  `// Source metadata: ${entityName} (${entity.fqn()})\n`;
206
288
  return header + entityImports.toString() + body.toString();
207
289
  }
290
+ // ---------------------------------------------------------------------------
291
+ // FR-017 Tier 3 — TPH discriminator base: polymorphic + per-subtype hooks.
292
+ // ---------------------------------------------------------------------------
293
+ function renderTphHooksFile(base, ctx, baseModule) {
294
+ const baseName = base.name;
295
+ const lcBase = baseName.charAt(0).toLowerCase() + baseName.slice(1);
296
+ const keysVar = `${lcBase}Keys`;
297
+ // Single source of truth for discriminator field + subtypes + route segments.
298
+ const plan = tphPlan(base, ctx.loadedRoot);
299
+ const discField = plan.discriminatorField;
300
+ const useQuerySym = imp("useQuery@@tanstack/react-query");
301
+ const useMutationSym = imp("useMutation@@tanstack/react-query");
302
+ const useQueryClientSym = imp("useQueryClient@@tanstack/react-query");
303
+ const useQueryOptionsSym = imp("t:UseQueryOptions@@tanstack/react-query");
304
+ const useMutationOptionsSym = imp("t:UseMutationOptions@@tanstack/react-query");
305
+ const useQueryResultSym = imp("t:UseQueryResult@@tanstack/react-query");
306
+ const useMutationResultSym = imp("t:UseMutationResult@@tanstack/react-query");
307
+ const useEntityFetcherSym = imp("useEntityFetcher@@metaobjectsdev/tanstack");
308
+ const buildFilterQsSym = imp("buildFilterQs@@metaobjectsdev/runtime-web");
309
+ const subtypes = plan.subtypes;
310
+ // `${baseName}` imports BOTH the constants value (for $path/$apiPrefix) and the
311
+ // discriminated-union type (declaration merge). Each subtype contributes its
312
+ // interface type AND its own filter type (discriminator-excluded — the route
313
+ // pins it), so per-subtype hooks filter on the fields the per-subtype
314
+ // allowlist actually permits.
315
+ const subImportLines = subtypes
316
+ .map((s) => {
317
+ const m = entityModuleSpecifier(ctx.selfTarget, ctx.entityModuleTarget, s.entity.package, s.entity.name, ctx.extStyle);
318
+ return `import { type ${s.entity.name}, type ${s.entity.name}Filter } from ${JSON.stringify(m)};`;
319
+ })
320
+ .join("\n");
321
+ const entityImports = code `
322
+ import { ${baseName}, type ${baseName}Filter } from ${JSON.stringify(baseModule)};
323
+ ${subImportLines}
324
+ `;
325
+ const queryKeys = code `
326
+ export const ${keysVar} = {
327
+ all: () => [${JSON.stringify(lcBase)}] as const,
328
+ lists: () => [...${keysVar}.all(), "list"] as const,
329
+ list: (filter?: ${baseName}Filter) => [...${keysVar}.lists(), filter ?? {}] as const,
330
+ details: () => [...${keysVar}.all(), "detail"] as const,
331
+ detail: (id: number) => [...${keysVar}.details(), id] as const,
332
+ subtypeLists: (sub: string) => [...${keysVar}.all(), sub, "list"] as const,
333
+ // filter is loosely typed here (cache-key identity only); the per-subtype
334
+ // hooks below type it precisely as <Sub>Filter.
335
+ subtypeList: (sub: string, filter?: unknown) => [...${keysVar}.subtypeLists(sub), filter ?? {}] as const,
336
+ subtypeDetails:(sub: string) => [...${keysVar}.all(), sub, "detail"] as const,
337
+ subtypeDetail: (sub: string, id: number) => [...${keysVar}.subtypeDetails(sub), id] as const,
338
+ };
339
+ `;
340
+ // Polymorphic reads — return the discriminated union.
341
+ const polymorphic = code `
342
+ export function use${baseName}(
343
+ id: number,
344
+ opts?: Omit<${useQueryOptionsSym}<${baseName}>, "queryKey" | "queryFn">,
345
+ ): ${useQueryResultSym}<${baseName}> {
346
+ const fetcher = ${useEntityFetcherSym}();
347
+ return ${useQuerySym}<${baseName}>({
348
+ queryKey: ${keysVar}.detail(id),
349
+ queryFn: () => fetcher<${baseName}>(\`\${${baseName}.$apiPrefix}\${${baseName}.$path}/\${id}\`),
350
+ ...opts,
351
+ });
352
+ }
353
+
354
+ export function use${pluralize(baseName)}(
355
+ filter?: ${baseName}Filter,
356
+ opts?: Omit<${useQueryOptionsSym}<${baseName}[]>, "queryKey" | "queryFn">,
357
+ ): ${useQueryResultSym}<${baseName}[]> {
358
+ const fetcher = ${useEntityFetcherSym}();
359
+ const qs = filter ? "?" + ${buildFilterQsSym}(filter as Record<string, unknown>) : "";
360
+ return ${useQuerySym}<${baseName}[]>({
361
+ queryKey: ${keysVar}.list(filter),
362
+ queryFn: () => fetcher<${baseName}[]>(\`\${${baseName}.$apiPrefix}\${${baseName}.$path}\${qs}\`),
363
+ ...opts,
364
+ });
365
+ }
366
+ `;
367
+ // Per-subtype hooks — scoped to each discriminator value's REST sub-path.
368
+ const subtypeSections = subtypes.map(({ entity: subEntity, value, routeSegment: seg }) => {
369
+ const subName = subEntity.name;
370
+ const valueLit = JSON.stringify(value);
371
+ const createInput = `Omit<${subName}, ${JSON.stringify(discField)}>`;
372
+ const updateInput = `Partial<${createInput}>`;
373
+ const subPath = `\`\${${baseName}.$apiPrefix}\${${baseName}.$path}/${seg}\``;
374
+ return code `
375
+ export function use${pluralize(subName)}(
376
+ filter?: ${subName}Filter,
377
+ opts?: Omit<${useQueryOptionsSym}<${subName}[]>, "queryKey" | "queryFn">,
378
+ ): ${useQueryResultSym}<${subName}[]> {
379
+ const fetcher = ${useEntityFetcherSym}();
380
+ const qs = filter ? "?" + ${buildFilterQsSym}(filter as Record<string, unknown>) : "";
381
+ return ${useQuerySym}<${subName}[]>({
382
+ queryKey: ${keysVar}.subtypeList(${valueLit}, filter),
383
+ queryFn: () => fetcher<${subName}[]>(\`\${${baseName}.$apiPrefix}\${${baseName}.$path}/${seg}\${qs}\`),
384
+ ...opts,
385
+ });
386
+ }
387
+
388
+ export function use${subName}(
389
+ id: number,
390
+ opts?: Omit<${useQueryOptionsSym}<${subName}>, "queryKey" | "queryFn">,
391
+ ): ${useQueryResultSym}<${subName}> {
392
+ const fetcher = ${useEntityFetcherSym}();
393
+ return ${useQuerySym}<${subName}>({
394
+ queryKey: ${keysVar}.subtypeDetail(${valueLit}, id),
395
+ queryFn: () => fetcher<${subName}>(\`\${${baseName}.$apiPrefix}\${${baseName}.$path}/${seg}/\${id}\`),
396
+ ...opts,
397
+ });
398
+ }
399
+
400
+ export function useCreate${subName}(
401
+ opts?: Omit<${useMutationOptionsSym}<${subName}, Error, ${createInput}>, "mutationFn">,
402
+ ): ${useMutationResultSym}<${subName}, Error, ${createInput}> {
403
+ const fetcher = ${useEntityFetcherSym}();
404
+ const qc = ${useQueryClientSym}();
405
+ return ${useMutationSym}<${subName}, Error, ${createInput}>({
406
+ mutationFn: (input) => fetcher<${subName}>(${subPath}, {
407
+ method: "POST",
408
+ headers: { "Content-Type": "application/json" },
409
+ body: JSON.stringify(input),
410
+ }),
411
+ ...opts,
412
+ onSuccess: (...args) => {
413
+ qc.invalidateQueries({ queryKey: ${keysVar}.all() });
414
+ opts?.onSuccess?.(...args);
415
+ },
416
+ });
417
+ }
418
+
419
+ export function useUpdate${subName}(
420
+ opts?: Omit<${useMutationOptionsSym}<${subName}, Error, { id: number; input: ${updateInput} }>, "mutationFn">,
421
+ ): ${useMutationResultSym}<${subName}, Error, { id: number; input: ${updateInput} }> {
422
+ const fetcher = ${useEntityFetcherSym}();
423
+ const qc = ${useQueryClientSym}();
424
+ return ${useMutationSym}({
425
+ mutationFn: ({ id, input }) => fetcher<${subName}>(\`\${${baseName}.$apiPrefix}\${${baseName}.$path}/${seg}/\${id}\`, {
426
+ method: "PATCH",
427
+ headers: { "Content-Type": "application/json" },
428
+ body: JSON.stringify(input),
429
+ }),
430
+ ...opts,
431
+ onSuccess: (...args) => {
432
+ qc.invalidateQueries({ queryKey: ${keysVar}.all() });
433
+ opts?.onSuccess?.(...args);
434
+ },
435
+ });
436
+ }
437
+
438
+ export function useDelete${subName}(
439
+ opts?: Omit<${useMutationOptionsSym}<void, Error, number>, "mutationFn">,
440
+ ): ${useMutationResultSym}<void, Error, number> {
441
+ const fetcher = ${useEntityFetcherSym}();
442
+ const qc = ${useQueryClientSym}();
443
+ return ${useMutationSym}({
444
+ mutationFn: (id) => fetcher<void>(\`\${${baseName}.$apiPrefix}\${${baseName}.$path}/${seg}/\${id}\`, { method: "DELETE" }),
445
+ ...opts,
446
+ onSuccess: (...args) => {
447
+ qc.invalidateQueries({ queryKey: ${keysVar}.all() });
448
+ opts?.onSuccess?.(...args);
449
+ },
450
+ });
451
+ }
452
+ `;
453
+ });
454
+ const body = joinCode([queryKeys, polymorphic, ...subtypeSections], { on: "\n" });
455
+ const header = `// ${GENERATED_HEADER}-tanstack — DO NOT EDIT.\n` +
456
+ `// Source metadata: ${baseName} (${base.fqn()}) — TPH discriminator base\n`;
457
+ return header + entityImports.toString() + body.toString();
458
+ }
208
459
  //# sourceMappingURL=hooks-file.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks-file.js","sourceRoot":"","sources":["../../src/templates/hooks-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAa,MAAM,SAAS,CAAC;AAGzD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAE9G;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe,CAAC,MAAkB,EAAE,GAAkB;IACpE,yEAAyE;IACzE,8CAA8C;IAC9C,MAAM,YAAY,GAAG,qBAAqB,CACxC,GAAG,CAAC,UAAU,EAC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AAW,EAAE,GAAG,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACxF,MAAM,MAAM,GACV,MAAM,gBAAgB,4BAA4B;QAClD,uBAAuB,QAAQ,KAAK,IAAI,CAAC,GAAG,EAAE,8BAA8B,CAAC;IAC/E,OAAO,MAAM,GAAG,aAAa,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;AAC7D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaobjectsdev/codegen-ts-tanstack",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "TanStack codegen for metaobjects — emits hooks and column definitions for TanStack Query and Table.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,7 +12,12 @@
12
12
  "default": "./dist/index.js"
13
13
  }
14
14
  },
15
- "files": ["dist", "src", "README.md", "LICENSE"],
15
+ "files": [
16
+ "dist",
17
+ "src",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
16
21
  "scripts": {
17
22
  "build": "tsc -p .",
18
23
  "typecheck": "tsc -p tsconfig.typecheck.json"
@@ -21,28 +26,34 @@
21
26
  "author": "Doug Mealing <doug@dougmealing.com>",
22
27
  "homepage": "https://metaobjects.dev",
23
28
  "bugs": {
24
- "url": "https://github.com/metaobjectsdev/metaobjects/issues"
25
- },
26
- "repository": {
27
- "type": "git",
28
- "url": "https://github.com/metaobjectsdev/metaobjects.git",
29
- "directory": "server/typescript/packages/codegen-ts-tanstack"
30
- },
31
- "keywords": ["metaobjects", "codegen", "tanstack", "react-query", "react-table"],
32
- "publishConfig": {
33
- "access": "public"
34
- },
35
- "dependencies": {
36
- "@metaobjectsdev/metadata": "0.9.0",
37
- "@metaobjectsdev/codegen-ts": "0.9.0",
38
- "ts-poet": "^6.10.0"
39
- },
40
- "peerDependencies": {
41
- "@biomejs/biome": ">=1.9.0"
42
- },
43
- "devDependencies": {
44
- "@biomejs/biome": "^1.9.0",
45
- "bun-types": "latest",
46
- "typescript": "^5.6.0"
47
- }
29
+ "url": "https://github.com/metaobjectsdev/metaobjects/issues"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/metaobjectsdev/metaobjects.git",
34
+ "directory": "server/typescript/packages/codegen-ts-tanstack"
35
+ },
36
+ "keywords": [
37
+ "metaobjects",
38
+ "codegen",
39
+ "tanstack",
40
+ "react-query",
41
+ "react-table"
42
+ ],
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "dependencies": {
47
+ "@metaobjectsdev/metadata": "0.10.0",
48
+ "@metaobjectsdev/codegen-ts": "0.10.0",
49
+ "ts-poet": "^6.10.0"
50
+ },
51
+ "peerDependencies": {
52
+ "@biomejs/biome": ">=1.9.0"
53
+ },
54
+ "devDependencies": {
55
+ "@biomejs/biome": "^1.9.0",
56
+ "bun-types": "latest",
57
+ "typescript": "^5.6.0"
58
+ }
48
59
  }
@@ -1,6 +1,6 @@
1
1
  import type { MetaObject } from "@metaobjectsdev/metadata";
2
2
  import { LAYOUT_SUBTYPE_DATA_GRID } from "@metaobjectsdev/metadata";
3
- import { perEntity, type Generator, type GeneratorFactory, formatTs, entityOutputPath, emitsInstanceArtifacts } from "@metaobjectsdev/codegen-ts";
3
+ import { perEntity, type Generator, type GeneratorFactory, formatTs, entityOutputPath, emitsInstanceArtifacts, CODEGEN_ATTR_EMIT_TANSTACK } from "@metaobjectsdev/codegen-ts";
4
4
  import { renderGridHookFile } from "./templates/grid-hook-file.js";
5
5
 
6
6
  export interface TanstackGridHookOpts {
@@ -28,7 +28,7 @@ export const tanstackGridHook = function tanstackGridHook(opts?: TanstackGridHoo
28
28
  // opt-out, user filter, and dataGrid layout presence.
29
29
  filter: (e: MetaObject) =>
30
30
  emitsInstanceArtifacts(e)
31
- && e.ownAttr("emitTanstack") !== false
31
+ && e.ownAttr(CODEGEN_ATTR_EMIT_TANSTACK) !== false
32
32
  && userFilter(e)
33
33
  && hasDataGridLayout(e),
34
34
  generate: perEntity(async (entity, ctx) => {
@@ -1,6 +1,6 @@
1
1
  import type { MetaObject } from "@metaobjectsdev/metadata";
2
2
  import { LAYOUT_SUBTYPE_DATA_GRID } from "@metaobjectsdev/metadata";
3
- import { perEntity, type Generator, type GeneratorFactory, formatTs, entityOutputPath, emitsInstanceArtifacts } from "@metaobjectsdev/codegen-ts";
3
+ import { perEntity, type Generator, type GeneratorFactory, formatTs, entityOutputPath, emitsInstanceArtifacts, isTphSubtype, CODEGEN_ATTR_EMIT_TANSTACK, CODEGEN_ATTR_EMIT_GRID } from "@metaobjectsdev/codegen-ts";
4
4
  import { renderColumnsFile } from "./templates/columns-file.js";
5
5
 
6
6
  export interface TanstackGridOpts {
@@ -24,11 +24,16 @@ export const tanstackGrid = function tanstackGrid(opts?: TanstackGridOpts): Gene
24
24
  name: "tanstack-grid",
25
25
  // Always set: AND-composes the framework instance-artifact guard (skips
26
26
  // abstract types), opt-out, user filter, and dataGrid layout presence.
27
+ // FR-017 Tier 3: a TPH discriminator base emits ONE polymorphic grid. Its
28
+ // subtypes inherit the base's dataGrid layout via extends, but per-subtype
29
+ // grids are opt-IN only (own `@emitGrid: true`) — otherwise the polymorphic
30
+ // grid is the single source of truth.
27
31
  filter: (e: MetaObject) =>
28
32
  emitsInstanceArtifacts(e)
29
- && e.ownAttr("emitTanstack") !== false
33
+ && e.ownAttr(CODEGEN_ATTR_EMIT_TANSTACK) !== false
30
34
  && userFilter(e)
31
- && hasDataGridLayout(e),
35
+ && hasDataGridLayout(e)
36
+ && (!isTphSubtype(e) || e.ownAttr(CODEGEN_ATTR_EMIT_GRID) === true),
32
37
  generate: perEntity(async (entity, ctx) => {
33
38
  if (!ctx.renderContext) {
34
39
  throw new Error("tanstack-grid: renderContext is required (provided by runGen)");
@@ -1,5 +1,5 @@
1
1
  import type { MetaObject } from "@metaobjectsdev/metadata";
2
- import { perEntity, type Generator, type GeneratorFactory, formatTs, entityOutputPath, emitsInstanceArtifacts } from "@metaobjectsdev/codegen-ts";
2
+ import { perEntity, type Generator, type GeneratorFactory, formatTs, entityOutputPath, emitsInstanceArtifacts, isTphSubtype, CODEGEN_ATTR_EMIT_TANSTACK } from "@metaobjectsdev/codegen-ts";
3
3
  import { renderHooksFile } from "./templates/hooks-file.js";
4
4
 
5
5
  export interface TanstackQueryOpts {
@@ -22,7 +22,9 @@ export const tanstackQuery = function tanstackQuery(opts?: TanstackQueryOpts): G
22
22
  // they contribute shape via inheritance only and have no instance to query),
23
23
  // the metadata opt-out, and the optional user filter. Projections still pass
24
24
  // here and get read-only hooks via renderHooksFile's isProjection branch.
25
- filter: (e: MetaObject) => emitsInstanceArtifacts(e) && e.ownAttr("emitTanstack") !== false && userFilter(e),
25
+ // FR-017 Tier 3: TPH subtypes get no standalone hooks file their per-subtype
26
+ // hooks live in the discriminator base's hooks file (polymorphic + per-subtype).
27
+ filter: (e: MetaObject) => emitsInstanceArtifacts(e) && e.ownAttr(CODEGEN_ATTR_EMIT_TANSTACK) !== false && !isTphSubtype(e) && userFilter(e),
26
28
  generate: perEntity(async (entity, ctx) => {
27
29
  if (!ctx.renderContext) {
28
30
  throw new Error(
@@ -8,9 +8,23 @@ import {
8
8
  LAYOUT_DATA_GRID_ATTR_FILTERABLE,
9
9
  LAYOUT_DATA_GRID_ATTR_FILTER,
10
10
  LAYOUT_DATA_GRID_ATTR_COLUMNS,
11
+ OBJECT_ATTR_DISCRIMINATOR,
11
12
  } from "@metaobjectsdev/metadata";
12
13
  import type { RenderContext } from "@metaobjectsdev/codegen-ts";
13
- import { GENERATED_HEADER, entityModuleSpecifier } from "@metaobjectsdev/codegen-ts";
14
+ import {
15
+ GENERATED_HEADER,
16
+ entityModuleSpecifier,
17
+ isTphDiscriminatorBase,
18
+ collectTphSubtypeFields,
19
+ } from "@metaobjectsdev/codegen-ts";
20
+
21
+ /** FR-017 TPH grid context, threaded into extractGrids when the entity is a
22
+ * discriminator base: the discriminator field name (badged in the polymorphic
23
+ * grid) and the subtype-only fields folded in as extra columns. */
24
+ interface TphGridInfo {
25
+ discField: string;
26
+ subtypeFields: MetaField[];
27
+ }
14
28
 
15
29
  interface ColumnSpec {
16
30
  id: string;
@@ -57,10 +71,12 @@ function fieldLabel(field: MetaField): string {
57
71
  * fall back to all fields on the entity (pre-E-T2 behaviour, kept for
58
72
  * backwards compat with metadata not yet migrated by E-T4).
59
73
  */
60
- function extractGrids(entity: MetaObject): GridSpec[] {
74
+ function extractGrids(entity: MetaObject, tph?: TphGridInfo): GridSpec[] {
61
75
  // fields() and layouts() are both effective (own + inherited via extends:/super:).
76
+ // For a TPH base, also index the subtype-only fields so they can be folded
77
+ // into the polymorphic grid's column set.
62
78
  const fieldsByName = new Map(
63
- entity.fields().map((f) => [f.name, f] as const),
79
+ [...entity.fields(), ...(tph?.subtypeFields ?? [])].map((f) => [f.name, f] as const),
64
80
  );
65
81
 
66
82
  const grids: GridSpec[] = [];
@@ -74,6 +90,16 @@ function extractGrids(entity: MetaObject): GridSpec[] {
74
90
  ? (columnsAttr as unknown[]).filter((x): x is string => typeof x === "string")
75
91
  : [...fieldsByName.keys()];
76
92
 
93
+ // FR-017: a polymorphic (TPH base) grid folds in every subtype-only column
94
+ // so mixed rows can render their subtype fields (the runtime grid renders a
95
+ // null cell as an em-dash for rows of other subtypes). Appended after the
96
+ // declared columns, deduped.
97
+ if (tph) {
98
+ for (const f of tph.subtypeFields) {
99
+ if (!columnNames.includes(f.name)) columnNames.push(f.name);
100
+ }
101
+ }
102
+
77
103
  const columns: ColumnSpec[] = columnNames.flatMap((name) => {
78
104
  const field = fieldsByName.get(name);
79
105
  if (!field) return []; // columns ref that doesn't exist on entity; defensive skip
@@ -82,6 +108,8 @@ function extractGrids(entity: MetaObject): GridSpec[] {
82
108
  header: fieldLabel(field),
83
109
  viewKind: fieldViewKind(field),
84
110
  };
111
+ // FR-017: the discriminator column renders as a subtype badge.
112
+ if (tph && name === tph.discField) spec.renderer = "badge";
85
113
  return [spec];
86
114
  });
87
115
 
@@ -121,7 +149,17 @@ function renderColumnDef(col: ColumnSpec): string {
121
149
  export function renderColumnsFile(entity: MetaObject, ctx: RenderContext): string {
122
150
  const entityName = entity.name;
123
151
  const lcEntity = entityName.charAt(0).toLowerCase() + entityName.slice(1);
124
- const grids = extractGrids(entity);
152
+ // FR-017: a TPH discriminator base emits a polymorphic grid typed against the
153
+ // raw single-table row (<Base>Row — all columns, subtype-only nullable),
154
+ // NOT the discriminated union (whose members lack the other subtypes' fields).
155
+ const tphBase = isTphDiscriminatorBase(entity, ctx.loadedRoot);
156
+ const tph: TphGridInfo | undefined = tphBase
157
+ ? {
158
+ discField: (entity.ownAttr(OBJECT_ATTR_DISCRIMINATOR) as string) ?? "",
159
+ subtypeFields: collectTphSubtypeFields(entity, ctx.loadedRoot),
160
+ }
161
+ : undefined;
162
+ const grids = extractGrids(entity, tph);
125
163
 
126
164
  const ColumnDefSym = imp("t:ColumnDef@@tanstack/react-table");
127
165
 
@@ -179,9 +217,12 @@ export const ${filterConstName}: ${entityName}Filter = ${JSON.stringify(grid.fil
179
217
  ctx.extStyle,
180
218
  );
181
219
  // Import <Entity>Row always; import <Entity>Filter only when a filter const is emitted.
220
+ // TPH base: <Base>Row is a distinct export (the all-columns row); import it
221
+ // directly. Non-TPH: the entity type IS the row, imported under the Row alias.
222
+ const rowImport = tphBase ? `${entityName}Row` : `${entityName} as ${entityName}Row`;
182
223
  const entityImportCode = hasFilterConst
183
- ? code`import type { ${entityName} as ${entityName}Row, ${entityName}Filter } from ${JSON.stringify(entityModule)};`
184
- : code`import type { ${entityName} as ${entityName}Row } from ${JSON.stringify(entityModule)};`;
224
+ ? code`import type { ${rowImport}, ${entityName}Filter } from ${JSON.stringify(entityModule)};`
225
+ : code`import type { ${rowImport} } from ${JSON.stringify(entityModule)};`;
185
226
 
186
227
  const body: Code = joinCode(sections, { on: "\n" });
187
228
  return header + entityImportCode.toString() + "\n" + body.toString();