@metaobjectsdev/codegen-ts 0.7.0-rc.8 → 0.7.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.
- package/dist/generator.d.ts +9 -0
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js.map +1 -1
- package/dist/generators/docs-data-builder.d.ts +16 -0
- package/dist/generators/docs-data-builder.d.ts.map +1 -0
- package/dist/generators/docs-data-builder.js +381 -0
- package/dist/generators/docs-data-builder.js.map +1 -0
- package/dist/generators/docs-data.d.ts +98 -0
- package/dist/generators/docs-data.d.ts.map +1 -0
- package/dist/generators/docs-data.js +43 -0
- package/dist/generators/docs-data.js.map +1 -0
- package/dist/generators/docs-file.d.ts +8 -0
- package/dist/generators/docs-file.d.ts.map +1 -0
- package/dist/generators/docs-file.js +77 -0
- package/dist/generators/docs-file.js.map +1 -0
- package/dist/generators/index.d.ts +5 -0
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +4 -0
- package/dist/generators/index.js.map +1 -1
- package/dist/generators/routes-file-hono.d.ts +21 -0
- package/dist/generators/routes-file-hono.d.ts.map +1 -0
- package/dist/generators/routes-file-hono.js +38 -0
- package/dist/generators/routes-file-hono.js.map +1 -0
- package/dist/generators/template-generator.d.ts +41 -0
- package/dist/generators/template-generator.d.ts.map +1 -0
- package/dist/generators/template-generator.js +62 -0
- package/dist/generators/template-generator.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/overwrite-policy.d.ts +39 -2
- package/dist/overwrite-policy.d.ts.map +1 -1
- package/dist/overwrite-policy.js +233 -13
- package/dist/overwrite-policy.js.map +1 -1
- package/dist/render-engine/framework-provider.d.ts +28 -0
- package/dist/render-engine/framework-provider.d.ts.map +1 -0
- package/dist/render-engine/framework-provider.js +104 -0
- package/dist/render-engine/framework-provider.js.map +1 -0
- package/dist/runner.d.ts +15 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +44 -6
- package/dist/runner.js.map +1 -1
- package/dist/templates/docs-file.d.ts +17 -0
- package/dist/templates/docs-file.d.ts.map +1 -0
- package/dist/templates/docs-file.js +37 -0
- package/dist/templates/docs-file.js.map +1 -0
- package/dist/templates/routes-file-hono.d.ts +4 -0
- package/dist/templates/routes-file-hono.d.ts.map +1 -0
- package/dist/templates/routes-file-hono.js +119 -0
- package/dist/templates/routes-file-hono.js.map +1 -0
- package/package.json +6 -5
- package/src/generator.ts +9 -0
- package/src/generators/docs-data-builder.ts +470 -0
- package/src/generators/docs-data.ts +154 -0
- package/src/generators/docs-file.ts +87 -0
- package/src/generators/index.ts +17 -0
- package/src/generators/routes-file-hono.ts +48 -0
- package/src/generators/template-generator.ts +106 -0
- package/src/index.ts +33 -2
- package/src/overwrite-policy.ts +325 -14
- package/src/render-engine/framework-provider.ts +107 -0
- package/src/runner.ts +65 -6
- package/src/templates/docs-file.ts +51 -0
- package/src/templates/routes-file-hono.ts +142 -0
- package/templates/docs/entity-page.md.mustache +54 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Backward-compatible facade over the rc.12+ template-driven docsFile()
|
|
2
|
+
// implementation. The Markdown structure now lives in
|
|
3
|
+
// `templates/docs/entity-page.md.mustache`; this module preserves the
|
|
4
|
+
// `renderDocsFile()` + `DocsRenderOpts` exports so the per-section unit
|
|
5
|
+
// tests in `test/templates/docs-file.test.ts` keep working without
|
|
6
|
+
// modification.
|
|
7
|
+
//
|
|
8
|
+
// Adopters writing custom docs templates should import the public surface
|
|
9
|
+
// from `@metaobjectsdev/codegen-ts/generators` instead:
|
|
10
|
+
// - `buildEntityDocData(entity, opts)` for the typed data dict
|
|
11
|
+
// - `templateGenerator({ template: "docs/entity-page.md", ... })` for the
|
|
12
|
+
// standard end-to-end generator
|
|
13
|
+
import { render } from "@metaobjectsdev/render";
|
|
14
|
+
import { buildEntityDocData } from "../generators/docs-data-builder.js";
|
|
15
|
+
import { frameworkTemplatesProvider } from "../render-engine/framework-provider.js";
|
|
16
|
+
/** Backward-compatible entry point: builds the EntityDocData payload and
|
|
17
|
+
* renders it via the framework template. Byte-identical to the hand-coded
|
|
18
|
+
* rc.11 output (gated by `docs-file-conformance.test.ts`). */
|
|
19
|
+
export function renderDocsFile(entity, opts) {
|
|
20
|
+
const data = buildEntityDocData(entity, {
|
|
21
|
+
dialect: opts.dialect,
|
|
22
|
+
...(opts.columnNamingStrategy !== undefined
|
|
23
|
+
? { columnNamingStrategy: opts.columnNamingStrategy }
|
|
24
|
+
: {}),
|
|
25
|
+
loadedRoot: opts.loadedRoot,
|
|
26
|
+
...(opts.generatorNames !== undefined
|
|
27
|
+
? { generatorNames: opts.generatorNames }
|
|
28
|
+
: {}),
|
|
29
|
+
});
|
|
30
|
+
return render({
|
|
31
|
+
ref: "docs/entity-page.md",
|
|
32
|
+
payload: data,
|
|
33
|
+
provider: frameworkTemplatesProvider,
|
|
34
|
+
format: "markdown",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=docs-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-file.js","sourceRoot":"","sources":["../../src/templates/docs-file.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,sDAAsD;AACtD,sEAAsE;AACtE,wEAAwE;AACxE,mEAAmE;AACnE,gBAAgB;AAChB,EAAE;AACF,0EAA0E;AAC1E,wDAAwD;AACxD,iEAAiE;AACjE,4EAA4E;AAC5E,oCAAoC;AAKpC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAYpF;;+DAE+D;AAC/D,MAAM,UAAU,cAAc,CAAC,MAAkB,EAAE,IAAoB;IACrE,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,EAAE;QACtC,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,GAAG,CAAC,IAAI,CAAC,oBAAoB,KAAK,SAAS;YACzC,CAAC,CAAC,EAAE,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,EAAE;YACrD,CAAC,CAAC,EAAE,CAAC;QACP,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,GAAG,CAAC,IAAI,CAAC,cAAc,KAAK,SAAS;YACnC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE;YACzC,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;QACZ,GAAG,EAAE,qBAAqB;QAC1B,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,0BAA0B;QACpC,MAAM,EAAE,UAAU;KACnB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-file-hono.d.ts","sourceRoot":"","sources":["../../src/templates/routes-file-hono.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAM1D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,GAAG,MAAM,CA2GnF"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Hono route template — emits a per-entity routes file that delegates
|
|
2
|
+
// CRUD verbs to helpers from @metaobjectsdev/runtime-ts/hono.
|
|
3
|
+
//
|
|
4
|
+
// Hono parallel of templates/routes-file.ts. Two emit-shape differences
|
|
5
|
+
// vs the Fastify flavor, both reflecting Hono idioms rather than contract
|
|
6
|
+
// drift:
|
|
7
|
+
//
|
|
8
|
+
// 1) Exported function shape — `registerXxxRoutes(app, deps)` instead of
|
|
9
|
+
// `xxxRoutes(fastify)`. Workers/Bun consumers typically pass `db`
|
|
10
|
+
// through a per-request deps object (so a Worker can attach the
|
|
11
|
+
// D1 client pulled off bindings) rather than reaching for a
|
|
12
|
+
// module-level singleton. The Fastify flavor uses `import { db }`
|
|
13
|
+
// because Fastify apps are long-lived Node processes where a
|
|
14
|
+
// singleton is the norm. Both flavors talk to mountCrudRoutes /
|
|
15
|
+
// mountReadOnlyCrudRoutes with identical wire behavior.
|
|
16
|
+
//
|
|
17
|
+
// 2) apiPrefix is composed into the resource path (`${apiPrefix}${path}`)
|
|
18
|
+
// rather than wrapping the registration. Hono has no fastify.register
|
|
19
|
+
// / prefix-wrapping primitive; sub-apps via `app.route(prefix, sub)`
|
|
20
|
+
// exist but bloat the generated code. String concat is simpler and
|
|
21
|
+
// produces identical URL grammar.
|
|
22
|
+
//
|
|
23
|
+
// Dispatch logic mirrors Fastify:
|
|
24
|
+
// isProjection(entity) → mountReadOnlyCrudRoutes (GET list + GET :id)
|
|
25
|
+
// vanilla / write-through entity → mountCrudRoutes (all 5 CRUD verbs)
|
|
26
|
+
import { code, imp } from "ts-poet";
|
|
27
|
+
import {} from "../render-context.js";
|
|
28
|
+
import { entityModuleSpecifier } from "../import-path.js";
|
|
29
|
+
import { GENERATED_HEADER } from "../constants.js";
|
|
30
|
+
import { variableNameFromEntity } from "../naming.js";
|
|
31
|
+
import { isProjection } from "../projection/projection-detector.js";
|
|
32
|
+
export function renderRoutesFileHono(entity, ctx) {
|
|
33
|
+
const entityName = entity.name;
|
|
34
|
+
const handlerName = `register${entityName}Routes`;
|
|
35
|
+
const entityFileSpec = entityModuleSpecifier(ctx.selfTarget, ctx.entityModuleTarget, entity.package, entityName, ctx.extStyle);
|
|
36
|
+
const header = `// ${GENERATED_HEADER} — DO NOT EDIT.\n` +
|
|
37
|
+
`// Source metadata: ${entityName} (${entity.fqn()})\n` +
|
|
38
|
+
`// Customize via ${entityName}.extra.ts in this directory (e.g., auth, additional handlers).\n`;
|
|
39
|
+
// Path composition: apiPrefix is a literal string in the URL.
|
|
40
|
+
const pathExpr = ctx.apiPrefix
|
|
41
|
+
? `\`${ctx.apiPrefix}\${${entityName}.$path}\``
|
|
42
|
+
: `${entityName}.$path`;
|
|
43
|
+
// --- Projection path: read-only routes (GET list + GET :id) ---
|
|
44
|
+
if (isProjection(entity)) {
|
|
45
|
+
const camelName = entityName.charAt(0).toLowerCase() + entityName.slice(1);
|
|
46
|
+
const HonoSym = imp("t:Hono@hono");
|
|
47
|
+
const mountReadOnlyCrudRoutesSym = imp("mountReadOnlyCrudRoutes@@metaobjectsdev/runtime-ts/hono");
|
|
48
|
+
const literalImports = code `
|
|
49
|
+
import {
|
|
50
|
+
${entityName},
|
|
51
|
+
${camelName}View,
|
|
52
|
+
${entityName}FilterAllowlist,
|
|
53
|
+
${entityName}SortAllowlist,
|
|
54
|
+
} from ${JSON.stringify(entityFileSpec)};
|
|
55
|
+
`;
|
|
56
|
+
const body = code `
|
|
57
|
+
/**
|
|
58
|
+
* Mount read-only REST endpoints for ${entityName} (projection — view-backed, no writes).
|
|
59
|
+
*
|
|
60
|
+
* Exposes GET list + GET :id only. POST/PATCH/DELETE return 405.
|
|
61
|
+
* Customize: register this as-is, or import individual route helpers from
|
|
62
|
+
* @metaobjectsdev/runtime-ts/hono.
|
|
63
|
+
*/
|
|
64
|
+
// biome-ignore lint/suspicious/noExplicitAny: consumer-defined Hono bindings/variables
|
|
65
|
+
export function ${handlerName}(app: ${HonoSym}<any, any, any>, deps: { db: unknown }): void {
|
|
66
|
+
${mountReadOnlyCrudRoutesSym}({
|
|
67
|
+
app,
|
|
68
|
+
path: ${pathExpr},
|
|
69
|
+
db: deps.db,
|
|
70
|
+
view: ${camelName}View,
|
|
71
|
+
filterAllowlist: ${entityName}FilterAllowlist,
|
|
72
|
+
sortAllowlist: ${entityName}SortAllowlist,
|
|
73
|
+
dialect: ${JSON.stringify(ctx.dialect)},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
return header + literalImports.toString() + body.toString();
|
|
78
|
+
}
|
|
79
|
+
// --- Vanilla / write-through entity path: full CRUD routes ---
|
|
80
|
+
const tableVar = variableNameFromEntity(entityName);
|
|
81
|
+
const HonoSym = imp("t:Hono@hono");
|
|
82
|
+
const mountCrudRoutesSym = imp("mountCrudRoutes@@metaobjectsdev/runtime-ts/hono");
|
|
83
|
+
const literalImports = code `
|
|
84
|
+
import {
|
|
85
|
+
${entityName},
|
|
86
|
+
${tableVar},
|
|
87
|
+
${entityName}InsertSchema,
|
|
88
|
+
${entityName}UpdateSchema,
|
|
89
|
+
${entityName}FilterAllowlist,
|
|
90
|
+
${entityName}SortAllowlist,
|
|
91
|
+
} from ${JSON.stringify(entityFileSpec)};
|
|
92
|
+
`;
|
|
93
|
+
const body = code `
|
|
94
|
+
/**
|
|
95
|
+
* Mount the 5 standard REST endpoints for ${entityName} using Drizzle directly.
|
|
96
|
+
*
|
|
97
|
+
* Customize: register this as-is for stock CRUD, OR import the per-verb
|
|
98
|
+
* helpers (mountListRoute, mountGetRoute, ...) from
|
|
99
|
+
* @metaobjectsdev/runtime-ts/hono and mix with your own handlers
|
|
100
|
+
* (auth, side effects, etc.).
|
|
101
|
+
*/
|
|
102
|
+
// biome-ignore lint/suspicious/noExplicitAny: consumer-defined Hono bindings/variables
|
|
103
|
+
export function ${handlerName}(app: ${HonoSym}<any, any, any>, deps: { db: unknown }): void {
|
|
104
|
+
${mountCrudRoutesSym}({
|
|
105
|
+
app,
|
|
106
|
+
path: ${pathExpr},
|
|
107
|
+
db: deps.db,
|
|
108
|
+
table: ${tableVar},
|
|
109
|
+
insertSchema: ${entityName}InsertSchema,
|
|
110
|
+
updateSchema: ${entityName}UpdateSchema,
|
|
111
|
+
filterAllowlist: ${entityName}FilterAllowlist,
|
|
112
|
+
sortAllowlist: ${entityName}SortAllowlist,
|
|
113
|
+
dialect: ${JSON.stringify(ctx.dialect)},
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
`;
|
|
117
|
+
return header + literalImports.toString() + body.toString();
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=routes-file-hono.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-file-hono.js","sourceRoot":"","sources":["../../src/templates/routes-file-hono.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metaobjectsdev/codegen-ts",
|
|
3
|
-
"version": "0.7.0
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "TypeScript codegen engine for MetaObjects — emits Drizzle, Zod, and Fastify artifacts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"default": "./dist/generators/index.js"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
"files": ["dist", "src", "README.md", "LICENSE"],
|
|
20
|
+
"files": ["dist", "src", "templates", "README.md", "LICENSE"],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsc -p .",
|
|
23
23
|
"typecheck": "tsc -p tsconfig.typecheck.json"
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@metaobjectsdev/metadata": "0.7.0
|
|
41
|
+
"@metaobjectsdev/metadata": "0.7.0",
|
|
42
|
+
"@metaobjectsdev/render": "0.7.0",
|
|
42
43
|
"@biomejs/js-api": "^0.7.0",
|
|
43
44
|
"@biomejs/wasm-nodejs": "^1.9.4",
|
|
44
45
|
"ts-poet": "^6.10.0"
|
|
@@ -49,10 +50,10 @@
|
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@biomejs/biome": "^1.9.0",
|
|
52
|
-
"@metaobjectsdev/codegen-ts-react": "0.7.0
|
|
53
|
-
"@metaobjectsdev/render": "0.7.0-rc.8",
|
|
53
|
+
"@metaobjectsdev/codegen-ts-react": "0.7.0",
|
|
54
54
|
"bun-types": "latest",
|
|
55
55
|
"drizzle-orm": "^0.36.0",
|
|
56
|
+
"hono": "^4.6.0",
|
|
56
57
|
"typescript": "^5.6.0",
|
|
57
58
|
"zod": "^3.23.0"
|
|
58
59
|
}
|
package/src/generator.ts
CHANGED
|
@@ -24,6 +24,15 @@ export interface GenContext {
|
|
|
24
24
|
* present at run time when invoked via runGen(); optional in the type
|
|
25
25
|
* so tests and custom callers don't need a placeholder. */
|
|
26
26
|
renderContext?: RenderContext;
|
|
27
|
+
/** Resolved absolute project root — what the runner derives from
|
|
28
|
+
* `opts.projectRoot` (the directory holding `.metaobjects/config.json`).
|
|
29
|
+
* Generators that resolve project-scoped resources (e.g.
|
|
30
|
+
* `templateGenerator` looking up the project's `templates/` directory)
|
|
31
|
+
* should read this rather than `process.cwd()`, which is whatever
|
|
32
|
+
* directory the CLI was invoked from and breaks when `meta gen` runs
|
|
33
|
+
* in a sub-directory. Undefined only when the runner was driven
|
|
34
|
+
* programmatically without an explicit projectRoot. */
|
|
35
|
+
projectRoot?: string;
|
|
27
36
|
warn: (msg: string) => void;
|
|
28
37
|
}
|
|
29
38
|
|