@metaobjectsdev/codegen-ts 0.15.20 → 0.15.21

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 +1 @@
1
- {"version":3,"file":"build-projection-views.d.ts","sourceRoot":"","sources":["../../src/projection/build-projection-views.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,QAAQ,EAId,MAAM,0BAA0B,CAAC;AAKlC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,8FAA8F;AAC9F,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAC;IACtC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,2BAA2B,GAChC,YAAY,EAAE,CA2BhB"}
1
+ {"version":3,"file":"build-projection-views.d.ts","sourceRoot":"","sources":["../../src/projection/build-projection-views.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,QAAQ,EAMd,MAAM,0BAA0B,CAAC;AAKlC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,8FAA8F;AAC9F,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAC;IACtC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,2BAA2B,GAChC,YAAY,EAAE,CA8ChB"}
@@ -7,7 +7,7 @@
7
7
  // migrate-ts stays dependency-pure: it never imports codegen-ts. Callers (the CLI,
8
8
  // integration tests) compute views here and thread them into buildExpectedSchema /
9
9
  // drift / snapshot as the `views` input. This is the ONE place view SQL is produced.
10
- import { MetaRoot, resolveTableName, resolveTableSchema, } from "@metaobjectsdev/metadata";
10
+ import { MetaRoot, MetaSource, SOURCE_KIND_VIEW, resolveTableName, resolveTableSchema, } from "@metaobjectsdev/metadata";
11
11
  import { isProjection } from "./projection-detector.js";
12
12
  import { extractViewSpec } from "./extract-view-spec.js";
13
13
  import { emitViewDdl } from "./view-ddl-emit.js";
@@ -23,6 +23,24 @@ export function buildProjectionViews(root, opts) {
23
23
  joinTables[obj.name] = resolveTableName(obj);
24
24
  const out = [];
25
25
  for (const projection of root.objects().filter(isProjection)) {
26
+ // Only PLAIN-VIEW projections produce managed CREATE VIEW DDL. The other
27
+ // read-only kinds must be skipped, not fed to extractViewSpec:
28
+ // - storedProc / tableFunction (FR-015) are CALLABLES, not views. They are
29
+ // base-less (no extends-bound identity), so extractViewSpec THROWS for
30
+ // them — and the CLI calls this function unconditionally, so one proc
31
+ // projection used to crash `meta migrate` outright.
32
+ // - materializedView cannot be managed by the migrate pipeline today:
33
+ // there is no CREATE MATERIALIZED VIEW emit, and PG introspection cannot
34
+ // even see matviews (information_schema.views excludes them), so a
35
+ // "managed" matview would re-propose create-view on every run and the
36
+ // apply would collide with the existing object. Worse, feeding it
37
+ // through here silently created a PLAIN view under the matview's name.
38
+ // Matviews are hand-managed, like the documented custom-SQL-view
39
+ // exception: migrate neither creates nor drops them.
40
+ // ADR-0039: own — mirrors isProjection/viewName's own-source classification.
41
+ const readOnlySource = projection.ownChildren().find((c) => c instanceof MetaSource && c.isReadOnly());
42
+ if (readOnlySource?.effectiveKind !== SOURCE_KIND_VIEW)
43
+ continue;
26
44
  const spec = extractViewSpec(projection, root, { columnNamingStrategy });
27
45
  const baseTableName = joinTables[spec.joinTree.baseEntity];
28
46
  if (!baseTableName)
@@ -1 +1 @@
1
- {"version":3,"file":"build-projection-views.js","sourceRoot":"","sources":["../../src/projection/build-projection-views.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,iFAAiF;AACjF,kFAAkF;AAClF,oFAAoF;AACpF,+EAA+E;AAC/E,EAAE;AACF,mFAAmF;AACnF,mFAAmF;AACnF,qFAAqF;AAErF,OAAO,EAEL,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAuBjD,MAAM,UAAU,oBAAoB,CAClC,IAAc,EACd,IAAiC;IAEjC,IAAI,CAAC,CAAC,IAAI,YAAY,QAAQ,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,iCAAiC;IACjC,MAAM,OAAO,GAA0B,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACvF,MAAM,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,IAAI,YAAY,CAAC;IAEvE,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE;QAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAE/E,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,KAAK,MAAM,UAAU,IAAI,IA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KAAK,CAAC,CAAC;IACjD,CAAC,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,KAAK;QAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AACrB,CAAC"}
1
+ {"version":3,"file":"build-projection-views.js","sourceRoot":"","sources":["../../src/projection/build-projection-views.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,iFAAiF;AACjF,kFAAkF;AAClF,oFAAoF;AACpF,+EAA+E;AAC/E,EAAE;AACF,mFAAmF;AACnF,mFAAmF;AACnF,qFAAqF;AAErF,OAAO,EAEL,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAuBjD,MAAM,UAAU,oBAAoB,CAClC,IAAc,EACd,IAAiC;IAEjC,IAAI,CAAC,CAAC,IAAI,YAAY,QAAQ,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,iCAAiC;IACjC,MAAM,OAAO,GAA0B,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACvF,MAAM,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,IAAI,YAAY,CAAC;IAEvE,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE;QAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAE/E,MAAM,GAAG,GAAmB,EAAE,CAAC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,EAAE,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,4FAA4F;AAC5F,SAAS,gBAAgB,CACvB,QAAkB,EAClB,aAAqB,EACrB,UAA4C;IAE5C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAS,CAAC,aAAa,CAAC,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,CAAC,IAAc,EAAQ,EAAE;QACpC,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACxC,IAAI,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACrB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ;YAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,KAAK;QAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AACrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaobjectsdev/codegen-ts",
3
- "version": "0.15.20",
3
+ "version": "0.15.21",
4
4
  "description": "TypeScript codegen engine for MetaObjects — emits Drizzle, Zod, and Fastify artifacts.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -111,8 +111,8 @@
111
111
  "access": "public"
112
112
  },
113
113
  "dependencies": {
114
- "@metaobjectsdev/metadata": "0.15.20",
115
- "@metaobjectsdev/render": "0.15.20",
114
+ "@metaobjectsdev/metadata": "0.15.21",
115
+ "@metaobjectsdev/render": "0.15.21",
116
116
  "@biomejs/js-api": "^0.7.0",
117
117
  "@biomejs/wasm-nodejs": "^1.9.4",
118
118
  "ts-poet": "^6.10.0"
@@ -123,9 +123,9 @@
123
123
  },
124
124
  "devDependencies": {
125
125
  "@biomejs/biome": "^1.9.0",
126
- "@metaobjectsdev/codegen-ts-react": "0.15.20",
127
- "@metaobjectsdev/migrate-ts": "0.15.20",
128
- "@metaobjectsdev/runtime-ts": "0.15.20",
126
+ "@metaobjectsdev/codegen-ts-react": "0.15.21",
127
+ "@metaobjectsdev/migrate-ts": "0.15.21",
128
+ "@metaobjectsdev/runtime-ts": "0.15.21",
129
129
  "bun-types": "latest",
130
130
  "drizzle-orm": "^0.36.0",
131
131
  "hono": "^4.6.0",
@@ -11,6 +11,8 @@
11
11
  import {
12
12
  type MetaData,
13
13
  MetaRoot,
14
+ MetaSource,
15
+ SOURCE_KIND_VIEW,
14
16
  resolveTableName,
15
17
  resolveTableSchema,
16
18
  } from "@metaobjectsdev/metadata";
@@ -55,6 +57,25 @@ export function buildProjectionViews(
55
57
 
56
58
  const out: ExpectedView[] = [];
57
59
  for (const projection of root.objects().filter(isProjection)) {
60
+ // Only PLAIN-VIEW projections produce managed CREATE VIEW DDL. The other
61
+ // read-only kinds must be skipped, not fed to extractViewSpec:
62
+ // - storedProc / tableFunction (FR-015) are CALLABLES, not views. They are
63
+ // base-less (no extends-bound identity), so extractViewSpec THROWS for
64
+ // them — and the CLI calls this function unconditionally, so one proc
65
+ // projection used to crash `meta migrate` outright.
66
+ // - materializedView cannot be managed by the migrate pipeline today:
67
+ // there is no CREATE MATERIALIZED VIEW emit, and PG introspection cannot
68
+ // even see matviews (information_schema.views excludes them), so a
69
+ // "managed" matview would re-propose create-view on every run and the
70
+ // apply would collide with the existing object. Worse, feeding it
71
+ // through here silently created a PLAIN view under the matview's name.
72
+ // Matviews are hand-managed, like the documented custom-SQL-view
73
+ // exception: migrate neither creates nor drops them.
74
+ // ADR-0039: own — mirrors isProjection/viewName's own-source classification.
75
+ const readOnlySource = projection.ownChildren().find(
76
+ (c): c is MetaSource => c instanceof MetaSource && c.isReadOnly(),
77
+ );
78
+ if (readOnlySource?.effectiveKind !== SOURCE_KIND_VIEW) continue;
58
79
  const spec = extractViewSpec(projection, root, { columnNamingStrategy });
59
80
  const baseTableName = joinTables[spec.joinTree.baseEntity];
60
81
  if (!baseTableName) continue; // unresolved base — skip (loader/codegen surface the error elsewhere)