@metaobjectsdev/codegen-ts 1.0.0-rc.2 → 1.0.0-rc.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaobjectsdev/codegen-ts",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.4",
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": "1.0.0-rc.2",
115
- "@metaobjectsdev/render": "1.0.0-rc.2",
114
+ "@metaobjectsdev/metadata": "1.0.0-rc.4",
115
+ "@metaobjectsdev/render": "1.0.0-rc.4",
116
116
  "@biomejs/js-api": "^0.7.0",
117
117
  "@biomejs/wasm-nodejs": "^1.9.4",
118
118
  "@toon-format/toon": "^2.3.0",
@@ -124,9 +124,9 @@
124
124
  },
125
125
  "devDependencies": {
126
126
  "@biomejs/biome": "^1.9.0",
127
- "@metaobjectsdev/codegen-ts-react": "1.0.0-rc.2",
128
- "@metaobjectsdev/migrate-ts": "1.0.0-rc.2",
129
- "@metaobjectsdev/runtime-ts": "1.0.0-rc.2",
127
+ "@metaobjectsdev/codegen-ts-react": "1.0.0-rc.4",
128
+ "@metaobjectsdev/migrate-ts": "1.0.0-rc.4",
129
+ "@metaobjectsdev/runtime-ts": "1.0.0-rc.4",
130
130
  "bun-types": "latest",
131
131
  "drizzle-orm": "^0.38.0",
132
132
  "hono": "^4.6.0",
@@ -54,17 +54,23 @@ export interface BarrelOpts {
54
54
  export const barrel = function barrel(opts?: BarrelOpts): Generator {
55
55
  const generator: Generator = {
56
56
  name: "barrel",
57
- generate: oncePerRun(async (entities, ctx) => ({
58
- path: "index.ts",
59
- content: await formatTs(
60
- renderBarrel(
61
- entities.map((e) => ({ name: ctx.renderContext!.valueObjectEmittedName(e), package: e.package })),
62
- ctx.renderContext!.extStyle,
63
- ctx.renderContext!.selfTarget,
64
- ctx.renderContext!.entityModuleTarget,
57
+ generate: oncePerRun(async (entities, ctx) => {
58
+ if (!ctx.renderContext) {
59
+ throw new Error("barrel: renderContext is required (provided by runGen)");
60
+ }
61
+ const rc = ctx.renderContext;
62
+ return {
63
+ path: "index.ts",
64
+ content: await formatTs(
65
+ renderBarrel(
66
+ entities.map((e) => ({ name: rc.valueObjectEmittedName(e), package: e.package })),
67
+ rc.extStyle,
68
+ rc.selfTarget,
69
+ rc.entityModuleTarget,
70
+ ),
65
71
  ),
66
- ),
67
- })),
72
+ };
73
+ }),
68
74
  };
69
75
  if (opts?.target) {
70
76
  generator.target = opts.target;
@@ -92,7 +92,7 @@ function renderQueries(obj: MetaObject, ctx: RenderContext): string {
92
92
  : `import type { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";`;
93
93
  const dbTypeAlias =
94
94
  ctx.dialect === "postgres"
95
- ? `type Db = PgDatabase<PgQueryResultHKT, Record<string, unknown>>;`
95
+ ? "type Db = PgDatabase<PgQueryResultHKT, Record<string, unknown>>;"
96
96
  : `type Db = BaseSQLiteDatabase<"sync" | "async", unknown, Record<string, unknown>>;`;
97
97
 
98
98
  // #203 — an @autoSet entity additionally imports its preserving-shape schema and emits
@@ -26,7 +26,7 @@
26
26
  // rejects them (ERR_UNKNOWN_ATTR).
27
27
  // composes-with: entity.ts (imports the table/schemas/allowlists), queries.ts.
28
28
 
29
- import { type MetaObject } from "@metaobjectsdev/metadata";
29
+ import type { MetaObject } from "@metaobjectsdev/metadata";
30
30
  import {
31
31
  perEntity,
32
32
  type Generator,
@@ -83,12 +83,12 @@ export const routesFileHono = function routesFileHono(opts?: RoutesFileHonoOpts)
83
83
  // `meta gen` time rather than discovered as missing endpoints in production.
84
84
  const skipped = ctx.entities.filter((e) => passesOtherGates(e) && isTphSubtype(e));
85
85
  if (skipped.length > 0) {
86
- ctx.warn(
87
- `no Hono routes emitted for the TPH subtype(s) ${skipped.map((e) => e.name).join(", ")} — ` +
86
+ const why =
88
87
  "the Hono adapter has no discriminator scoping yet, so per-subtype CRUD would " +
89
88
  "return and mutate OTHER subtypes' rows. Use routesFile() (Fastify), which " +
90
- "dispatches TPH correctly, or hand-write the scoped routes.",
91
- );
89
+ "dispatches TPH correctly, or hand-write the scoped routes.";
90
+ const names = skipped.map((e) => e.name).join(", ");
91
+ ctx.warn(`no Hono routes emitted for the TPH subtype(s) ${names} — ${why}`);
92
92
  }
93
93
  return emit(ctx);
94
94
  },
@@ -34,7 +34,7 @@
34
34
  // own handlers (auth, side effects).
35
35
  // composes-with: entity.ts (imports the table/schemas/allowlists), queries.ts.
36
36
 
37
- import { type MetaObject } from "@metaobjectsdev/metadata";
37
+ import type { MetaObject } from "@metaobjectsdev/metadata";
38
38
  import {
39
39
  perEntity,
40
40
  type Generator,