@metaobjectsdev/codegen-ts 0.6.0 → 0.7.0-rc.10
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/README.md +161 -4
- package/dist/column-mapper.d.ts +16 -0
- package/dist/column-mapper.d.ts.map +1 -1
- package/dist/column-mapper.js +73 -2
- package/dist/column-mapper.js.map +1 -1
- 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 +52 -0
- package/dist/generators/docs-file.js.map +1 -0
- package/dist/generators/entity-file.d.ts +15 -0
- package/dist/generators/entity-file.d.ts.map +1 -1
- package/dist/generators/entity-file.js +2 -1
- package/dist/generators/entity-file.js.map +1 -1
- package/dist/generators/index.d.ts +4 -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/output-parser-file.d.ts +9 -0
- package/dist/generators/output-parser-file.d.ts.map +1 -0
- package/dist/generators/output-parser-file.js +37 -0
- package/dist/generators/output-parser-file.js.map +1 -0
- package/dist/generators/prompt-render-file.d.ts +9 -0
- package/dist/generators/prompt-render-file.d.ts.map +1 -0
- package/dist/generators/prompt-render-file.js +70 -0
- package/dist/generators/prompt-render-file.js.map +1 -0
- package/dist/generators/queries-file.d.ts +1 -1
- package/dist/generators/queries-file.d.ts.map +1 -1
- package/dist/generators/queries-file.js +11 -3
- package/dist/generators/queries-file.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/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metaobjects-config.d.ts +10 -1
- package/dist/metaobjects-config.d.ts.map +1 -1
- package/dist/metaobjects-config.js +2 -1
- package/dist/metaobjects-config.js.map +1 -1
- package/dist/naming.d.ts +3 -12
- package/dist/naming.d.ts.map +1 -1
- package/dist/naming.js +14 -44
- package/dist/naming.js.map +1 -1
- package/dist/payload-codegen.d.ts +8 -0
- package/dist/payload-codegen.d.ts.map +1 -1
- package/dist/payload-codegen.js +33 -3
- package/dist/payload-codegen.js.map +1 -1
- package/dist/projection/extract-view-spec.d.ts +1 -1
- package/dist/projection/extract-view-spec.js +1 -1
- package/dist/source-detect.d.ts +10 -0
- package/dist/source-detect.d.ts.map +1 -0
- package/dist/source-detect.js +30 -0
- package/dist/source-detect.js.map +1 -0
- package/dist/templates/docs-file.d.ts +48 -0
- package/dist/templates/docs-file.d.ts.map +1 -0
- package/dist/templates/docs-file.js +445 -0
- package/dist/templates/docs-file.js.map +1 -0
- package/dist/templates/drizzle-schema.js +27 -3
- package/dist/templates/drizzle-schema.js.map +1 -1
- package/dist/templates/entity-file.d.ts +15 -1
- package/dist/templates/entity-file.d.ts.map +1 -1
- package/dist/templates/entity-file.js +15 -5
- package/dist/templates/entity-file.js.map +1 -1
- package/dist/templates/inferred-types.d.ts +9 -0
- package/dist/templates/inferred-types.d.ts.map +1 -1
- package/dist/templates/inferred-types.js +88 -2
- package/dist/templates/inferred-types.js.map +1 -1
- package/dist/templates/output-parser.d.ts +8 -0
- package/dist/templates/output-parser.d.ts.map +1 -0
- package/dist/templates/output-parser.js +129 -0
- package/dist/templates/output-parser.js.map +1 -0
- package/dist/templates/projection-decl.d.ts +1 -1
- package/dist/templates/projection-decl.js +1 -1
- package/dist/templates/queries-file.d.ts.map +1 -1
- package/dist/templates/queries-file.js +15 -4
- package/dist/templates/queries-file.js.map +1 -1
- package/dist/templates/queries.d.ts.map +1 -1
- package/dist/templates/queries.js +11 -30
- package/dist/templates/queries.js.map +1 -1
- 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/dist/templates/value-object-file.d.ts +3 -0
- package/dist/templates/value-object-file.d.ts.map +1 -0
- package/dist/templates/value-object-file.js +27 -0
- package/dist/templates/value-object-file.js.map +1 -0
- package/dist/templates/zod-validators.d.ts +10 -0
- package/dist/templates/zod-validators.d.ts.map +1 -1
- package/dist/templates/zod-validators.js +108 -30
- package/dist/templates/zod-validators.js.map +1 -1
- package/package.json +5 -4
- package/src/column-mapper.ts +86 -1
- package/src/generators/docs-file.ts +64 -0
- package/src/generators/entity-file.ts +17 -1
- package/src/generators/index.ts +4 -0
- package/src/generators/output-parser-file.ts +50 -0
- package/src/generators/prompt-render-file.ts +95 -0
- package/src/generators/queries-file.ts +13 -4
- package/src/generators/routes-file-hono.ts +48 -0
- package/src/index.ts +2 -2
- package/src/metaobjects-config.ts +11 -2
- package/src/naming.ts +22 -46
- package/src/payload-codegen.ts +34 -2
- package/src/projection/extract-view-spec.ts +1 -1
- package/src/source-detect.ts +28 -0
- package/src/templates/docs-file.ts +545 -0
- package/src/templates/drizzle-schema.ts +27 -3
- package/src/templates/entity-file.ts +36 -5
- package/src/templates/inferred-types.ts +117 -3
- package/src/templates/output-parser.ts +143 -0
- package/src/templates/projection-decl.ts +1 -1
- package/src/templates/queries-file.ts +18 -4
- package/src/templates/queries.ts +11 -33
- package/src/templates/routes-file-hono.ts +142 -0
- package/src/templates/value-object-file.ts +30 -0
- package/src/templates/zod-validators.ts +121 -35
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Stock generator that wraps generatePayloadInterfaces() + generateRenderHandle()
|
|
2
|
+
// from payload-codegen.ts into a Generator factory. Emits ONE file aggregating
|
|
3
|
+
// typed payload interfaces (for object.value entities) and render handles (for
|
|
4
|
+
// template.prompt nodes).
|
|
5
|
+
//
|
|
6
|
+
// Consumer wiring (metaobjects.config.ts):
|
|
7
|
+
// generators: [..., promptRender()]
|
|
8
|
+
//
|
|
9
|
+
// Custom output path:
|
|
10
|
+
// generators: [..., promptRender({ outFile: "src/render/generated/prompts.ts" })]
|
|
11
|
+
import { TYPE_TEMPLATE, TEMPLATE_SUBTYPE_PROMPT, OBJECT_SUBTYPE_VALUE } from "@metaobjectsdev/metadata";
|
|
12
|
+
import { oncePerRun, } from "../generator.js";
|
|
13
|
+
import { generatePayloadInterfacesBatch, generateRenderHandle, } from "../payload-codegen.js";
|
|
14
|
+
import { GENERATED_HEADER } from "../constants.js";
|
|
15
|
+
// Hoisted into the emitted file once. generateRenderHandle() emits this line
|
|
16
|
+
// per-handle (for the standalone scenario); we strip its per-handle copies.
|
|
17
|
+
const RENDER_IMPORT = `import { render, type Provider } from "@metaobjectsdev/render";`;
|
|
18
|
+
// Matches the `import type { ... } from "./payloads.js";` that generateRenderHandle
|
|
19
|
+
// emits for the standalone two-file scenario. In the single-file output here the
|
|
20
|
+
// payload interfaces are already defined above, so the import is dead.
|
|
21
|
+
function isStandalonePayloadImport(line) {
|
|
22
|
+
return line.startsWith("import type {") && line.includes('"./payloads.js"');
|
|
23
|
+
}
|
|
24
|
+
export const promptRender = function promptRender(opts) {
|
|
25
|
+
const outFile = opts?.outFile ?? "prompts.ts";
|
|
26
|
+
const generator = {
|
|
27
|
+
name: "prompt-render",
|
|
28
|
+
generate: oncePerRun((entities, ctx) => {
|
|
29
|
+
const payloads = entities.filter((e) => e.subType === OBJECT_SUBTYPE_VALUE);
|
|
30
|
+
const prompts = ctx.loadedRoot
|
|
31
|
+
.ownChildren()
|
|
32
|
+
.filter((c) => c.type === TYPE_TEMPLATE && c.subType === TEMPLATE_SUBTYPE_PROMPT);
|
|
33
|
+
if (payloads.length === 0 && prompts.length === 0) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
const parts = [`// ${GENERATED_HEADER} — DO NOT EDIT.`];
|
|
37
|
+
// Hoist the @metaobjectsdev/render import once (only when prompts emit handles).
|
|
38
|
+
if (prompts.length > 0) {
|
|
39
|
+
parts.push(RENDER_IMPORT);
|
|
40
|
+
}
|
|
41
|
+
// Emit payload interfaces with a single shared dedupe set so a lens
|
|
42
|
+
// referenced by multiple payloads appears exactly once.
|
|
43
|
+
const payloadInterfaces = generatePayloadInterfacesBatch(ctx.loadedRoot, payloads.map((p) => p.name));
|
|
44
|
+
if (payloadInterfaces.length > 0) {
|
|
45
|
+
parts.push(payloadInterfaces);
|
|
46
|
+
}
|
|
47
|
+
// Append each render handle with its per-handle imports stripped — both
|
|
48
|
+
// the now-hoisted render/Provider import and the standalone payloads.js
|
|
49
|
+
// import. Also drop any leading blank lines left behind by the strip so
|
|
50
|
+
// the joined output doesn't accumulate double blank gaps between parts.
|
|
51
|
+
for (const t of prompts) {
|
|
52
|
+
const lines = generateRenderHandle(ctx.loadedRoot, t.name)
|
|
53
|
+
.split("\n")
|
|
54
|
+
.filter((line) => line !== RENDER_IMPORT && !isStandalonePayloadImport(line));
|
|
55
|
+
while (lines.length > 0 && lines[0].trim() === "")
|
|
56
|
+
lines.shift();
|
|
57
|
+
parts.push(lines.join("\n"));
|
|
58
|
+
}
|
|
59
|
+
return [{
|
|
60
|
+
path: outFile,
|
|
61
|
+
content: parts.filter((s) => s.length > 0).map((s) => s.trimEnd()).join("\n\n") + "\n",
|
|
62
|
+
}];
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
if (opts?.target) {
|
|
66
|
+
generator.target = opts.target;
|
|
67
|
+
}
|
|
68
|
+
return generator;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=prompt-render-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-render-file.js","sourceRoot":"","sources":["../../src/generators/prompt-render-file.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,+EAA+E;AAC/E,+EAA+E;AAC/E,0BAA0B;AAC1B,EAAE;AACF,2CAA2C;AAC3C,sCAAsC;AACtC,EAAE;AACF,sBAAsB;AACtB,oFAAoF;AAEpF,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0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G,IAAI;iBACvF,CAAC,CAAC;QACL,CAAC,CAAC;KACH,CAAC;IACF,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries-file.d.ts","sourceRoot":"","sources":["../../src/generators/queries-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"queries-file.d.ts","sourceRoot":"","sources":["../../src/generators/queries-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKnF,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAQD,eAAO,MAAM,WAAW,EAuBnB,gBAAgB,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
import { OBJECT_SUBTYPE_VALUE } from "@metaobjectsdev/metadata";
|
|
1
2
|
import { perEntity } from "../generator.js";
|
|
2
3
|
import { renderQueriesFile } from "../templates/queries-file.js";
|
|
3
4
|
import { formatTs } from "../format.js";
|
|
4
5
|
import { entityOutputPath } from "../import-path.js";
|
|
6
|
+
// object.value records have no primary identity, so the rendered queries module
|
|
7
|
+
// emits findById/updateById/deleteById against a non-existent column. Skipping
|
|
8
|
+
// value subtypes is unconditional — the user-supplied filter (if any) is applied
|
|
9
|
+
// on top via boolean AND.
|
|
10
|
+
const skipValueTypes = (e) => e.subType !== OBJECT_SUBTYPE_VALUE;
|
|
5
11
|
export const queriesFile = function queriesFile(opts) {
|
|
12
|
+
const userFilter = opts?.filter;
|
|
13
|
+
const filter = userFilter
|
|
14
|
+
? (e) => skipValueTypes(e) && userFilter(e)
|
|
15
|
+
: skipValueTypes;
|
|
6
16
|
const generator = {
|
|
7
17
|
name: "queries-file",
|
|
18
|
+
filter,
|
|
8
19
|
generate: perEntity(async (entity, ctx) => {
|
|
9
20
|
if (!ctx.renderContext) {
|
|
10
21
|
throw new Error("queries-file: renderContext is required (provided by runGen)");
|
|
@@ -15,9 +26,6 @@ export const queriesFile = function queriesFile(opts) {
|
|
|
15
26
|
};
|
|
16
27
|
}),
|
|
17
28
|
};
|
|
18
|
-
if (opts?.filter) {
|
|
19
|
-
generator.filter = opts.filter;
|
|
20
|
-
}
|
|
21
29
|
if (opts?.target) {
|
|
22
30
|
generator.target = opts.target;
|
|
23
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries-file.js","sourceRoot":"","sources":["../../src/generators/queries-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queries-file.js","sourceRoot":"","sources":["../../src/generators/queries-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,SAAS,EAAyC,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOrD,gFAAgF;AAChF,+EAA+E;AAC/E,iFAAiF;AACjF,0BAA0B;AAC1B,MAAM,cAAc,GAAG,CAAC,CAAa,EAAW,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,oBAAoB,CAAC;AAEtF,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,WAAW,CAAC,IAAsB;IACpE,MAAM,UAAU,GAAG,IAAI,EAAE,MAAM,CAAC;IAChC,MAAM,MAAM,GAA+B,UAAU;QACnD,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,cAAc,CAAC;IAEnB,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,cAAc;QACpB,MAAM;QACN,QAAQ,EAAE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;YACxC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;YAClF,CAAC;YACD,OAAO;gBACL,IAAI,EAAE,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,aAAa,CAAC;gBACtG,OAAO,EAAE,MAAM,QAAQ,CAAC,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;aACtE,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;IACF,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAsC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MetaObject } from "@metaobjectsdev/metadata";
|
|
2
|
+
import { type GeneratorFactory } from "../generator.js";
|
|
3
|
+
export interface RoutesFileHonoOpts {
|
|
4
|
+
filter?: (entity: MetaObject) => boolean;
|
|
5
|
+
target?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Hono variant of routesFile() — emits `<Entity>.routes.hono.ts` mounting
|
|
9
|
+
* the same five CRUD verbs (GET list / GET :id / POST / PATCH+PUT / DELETE)
|
|
10
|
+
* against `@metaobjectsdev/runtime-ts/hono` rather than `…/drizzle-fastify`.
|
|
11
|
+
*
|
|
12
|
+
* Same cross-port wire contract (envelope shape, status codes, filter +
|
|
13
|
+
* sort + withCount semantics) as the Fastify flavor. Workers / Bun / Node
|
|
14
|
+
* consumers running Hono can replace hand-written route registration with
|
|
15
|
+
* this generator output one entity at a time.
|
|
16
|
+
*
|
|
17
|
+
* Per-entity opt-out via `@emitRoutes: false` is honored. If the user
|
|
18
|
+
* supplies their own filter, both must pass (AND).
|
|
19
|
+
*/
|
|
20
|
+
export declare const routesFileHono: GeneratorFactory<RoutesFileHonoOpts>;
|
|
21
|
+
//# sourceMappingURL=routes-file-hono.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-file-hono.d.ts","sourceRoot":"","sources":["../../src/generators/routes-file-hono.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKnF,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,EAuBtB,gBAAgB,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { perEntity } from "../generator.js";
|
|
2
|
+
import { renderRoutesFileHono } from "../templates/routes-file-hono.js";
|
|
3
|
+
import { formatTs } from "../format.js";
|
|
4
|
+
import { entityOutputPath } from "../import-path.js";
|
|
5
|
+
/**
|
|
6
|
+
* Hono variant of routesFile() — emits `<Entity>.routes.hono.ts` mounting
|
|
7
|
+
* the same five CRUD verbs (GET list / GET :id / POST / PATCH+PUT / DELETE)
|
|
8
|
+
* against `@metaobjectsdev/runtime-ts/hono` rather than `…/drizzle-fastify`.
|
|
9
|
+
*
|
|
10
|
+
* Same cross-port wire contract (envelope shape, status codes, filter +
|
|
11
|
+
* sort + withCount semantics) as the Fastify flavor. Workers / Bun / Node
|
|
12
|
+
* consumers running Hono can replace hand-written route registration with
|
|
13
|
+
* this generator output one entity at a time.
|
|
14
|
+
*
|
|
15
|
+
* Per-entity opt-out via `@emitRoutes: false` is honored. If the user
|
|
16
|
+
* supplies their own filter, both must pass (AND).
|
|
17
|
+
*/
|
|
18
|
+
export const routesFileHono = function routesFileHono(opts) {
|
|
19
|
+
const userFilter = opts?.filter ?? (() => true);
|
|
20
|
+
const generator = {
|
|
21
|
+
name: "routes-file-hono",
|
|
22
|
+
filter: (e) => e.ownAttr("emitRoutes") !== false && userFilter(e),
|
|
23
|
+
generate: perEntity(async (entity, ctx) => {
|
|
24
|
+
if (!ctx.renderContext) {
|
|
25
|
+
throw new Error("routes-file-hono: renderContext is required (provided by runGen)");
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
path: entityOutputPath(ctx.config.outputLayout ?? "flat", entity.package, `${entity.name}.routes.hono.ts`),
|
|
29
|
+
content: await formatTs(renderRoutesFileHono(entity, ctx.renderContext)),
|
|
30
|
+
};
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
if (opts?.target) {
|
|
34
|
+
generator.target = opts.target;
|
|
35
|
+
}
|
|
36
|
+
return generator;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=routes-file-hono.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-file-hono.js","sourceRoot":"","sources":["../../src/generators/routes-file-hono.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAyC,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOrD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,cAAc,CAAC,IAAyB;IAC7E,MAAM,UAAU,GAAG,IAAI,EAAE,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC;QAC7E,QAAQ,EAAE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;YACxC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;YACtF,CAAC;YACD,OAAO;gBACL,IAAI,EAAE,gBAAgB,CACpB,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,MAAM,EACjC,MAAM,CAAC,OAAO,EACd,GAAG,MAAM,CAAC,IAAI,iBAAiB,CAChC;gBACD,OAAO,EAAE,MAAM,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;aACzE,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;IACF,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAyC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { runGen } from "./runner.js";
|
|
|
2
2
|
export type { RunGenOpts, RunGenResult } from "./runner.js";
|
|
3
3
|
export type { Generator, GenContext, EmittedFile, GeneratorFactory } from "./generator.js";
|
|
4
4
|
export { perEntity, oncePerRun } from "./generator.js";
|
|
5
|
-
export type { MetaobjectsGenConfig, NormalizedMetaobjectsGenConfig, ResolvedGenConfig, Dialect, ExtStyle, ColumnNamingStrategy } from "./metaobjects-config.js";
|
|
5
|
+
export type { MetaobjectsGenConfig, NormalizedMetaobjectsGenConfig, ResolvedGenConfig, Dialect, ExtStyle, ColumnNamingStrategy, MetaDataTypeProvider } from "./metaobjects-config.js";
|
|
6
6
|
export { defineConfig, normalizeConfig } from "./metaobjects-config.js";
|
|
7
7
|
export type { ColumnSpec, DefaultExpr } from "./column-mapper.js";
|
|
8
8
|
export { mapColumnType } from "./column-mapper.js";
|
|
@@ -26,5 +26,5 @@ export type { ExtractContext } from "./projection/extract-view-spec.js";
|
|
|
26
26
|
export { emitViewDdl } from "./projection/view-ddl-emit.js";
|
|
27
27
|
export type { EmitOptions as ViewDdlEmitOptions } from "./projection/view-ddl-emit.js";
|
|
28
28
|
export type { JoinNode, JoinTree, SelectColumn, SelectSpec, ViewSpec } from "./projection/view-spec.js";
|
|
29
|
-
export { generatePayloadInterfaces, generateRenderHandle } from "./payload-codegen.js";
|
|
29
|
+
export { generatePayloadInterfaces, generatePayloadInterfacesBatch, generateRenderHandle } from "./payload-codegen.js";
|
|
30
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE5D,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvD,YAAY,EAAE,oBAAoB,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":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vC,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1G,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACxM,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,YAAY,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,YAAY,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACvF,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAExG,OAAO,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,5 +19,5 @@ export { isProjection, isWriteThrough } from "./projection/projection-detector.j
|
|
|
19
19
|
export { extractViewSpec } from "./projection/extract-view-spec.js";
|
|
20
20
|
export { emitViewDdl } from "./projection/view-ddl-emit.js";
|
|
21
21
|
// Prompt construction (FR-004): typed payload + render-handle codegen.
|
|
22
|
-
export { generatePayloadInterfaces, generateRenderHandle } from "./payload-codegen.js";
|
|
22
|
+
export { generatePayloadInterfaces, generatePayloadInterfacesBatch, generateRenderHandle } from "./payload-codegen.js";
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":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 @@
|
|
|
1
|
+
import { type ColumnNamingStrategy, type MetaDataTypeProvider } from "@metaobjectsdev/metadata";
|
|
1
2
|
import type { Generator } from "./generator.js";
|
|
2
3
|
import type { ExtStyle } from "./render-context.js";
|
|
3
4
|
import type { OutputLayout, ResolvedTarget } from "./import-path.js";
|
|
4
5
|
export type Dialect = "sqlite" | "postgres";
|
|
5
|
-
|
|
6
|
+
/** Re-exported from metadata so codegen-ts consumers see one canonical type. */
|
|
7
|
+
export type { ColumnNamingStrategy, MetaDataTypeProvider } from "@metaobjectsdev/metadata";
|
|
6
8
|
export type { ExtStyle };
|
|
7
9
|
export type { OutputLayout };
|
|
8
10
|
export type { ResolvedTarget };
|
|
@@ -34,6 +36,13 @@ export interface MetaobjectsGenConfig extends ResolvedGenConfig {
|
|
|
34
36
|
targets?: Record<string, TargetConfig>;
|
|
35
37
|
/** importBase for the default target (top-level outDir). */
|
|
36
38
|
importBase?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Consumer-supplied {@link MetaDataTypeProvider}s. Threaded to `loadMemory`
|
|
41
|
+
* by the CLI's gen/migrate commands so a project can register its own
|
|
42
|
+
* subtypes/attrs (e.g. a `template.toolcall` subtype) without forking the
|
|
43
|
+
* loader. Composed AFTER the default core+forge bundle.
|
|
44
|
+
*/
|
|
45
|
+
providers?: readonly MetaDataTypeProvider[];
|
|
37
46
|
}
|
|
38
47
|
/** MetaobjectsGenConfig after applying defaults. All fields required.
|
|
39
48
|
* `targets` is Omitted from the base so it can narrow from the user-facing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metaobjects-config.d.ts","sourceRoot":"","sources":["../src/metaobjects-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEr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CAAC,EAAE,oBAAoB,CAAC;IAC5C,8FAA8F;IAC9F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACvC,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;CAC7C;AAED;;;6CAG6C;AAC7C,MAAM,WAAW,8BAA+B,SAAQ,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC;IAC3F,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACzC;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAE/E;AAED;;kEAEkE;AAClE,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAqB3F;AAED,4FAA4F;AAC5F,wBAAgB,eAAe,CAAC,MAAM,EAAE,oBAAoB,GAAG,8BAA8B,CAQ5F"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_COLUMN_NAMING_STRATEGY } from "@metaobjectsdev/metadata";
|
|
1
2
|
/** The implicit target synthesized from top-level config (outDir/outputLayout/dbImport). */
|
|
2
3
|
export const DEFAULT_TARGET_NAME = "default";
|
|
3
4
|
/** Identity passthrough; exists for IDE type-inference + autocomplete. */
|
|
@@ -33,7 +34,7 @@ export function resolveTargets(config) {
|
|
|
33
34
|
export function normalizeConfig(config) {
|
|
34
35
|
return {
|
|
35
36
|
...config,
|
|
36
|
-
columnNamingStrategy: config.columnNamingStrategy ??
|
|
37
|
+
columnNamingStrategy: config.columnNamingStrategy ?? DEFAULT_COLUMN_NAMING_STRATEGY,
|
|
37
38
|
apiPrefix: config.apiPrefix ?? "",
|
|
38
39
|
outputLayout: config.outputLayout ?? "flat",
|
|
39
40
|
targets: resolveTargets(config),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metaobjects-config.js","sourceRoot":"","sources":["../src/metaobjects-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metaobjects-config.js","sourceRoot":"","sources":["../src/metaobjects-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAwD,MAAM,0BAA0B,CAAC;AAYhI,4FAA4F;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAkD7C,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAAC,MAA4B;IACvD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;kEAEkE;AAClE,MAAM,UAAU,cAAc,CAAC,MAA4B;IACzD,MAAM,MAAM,GAAiB,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC;IAC3D,MAAM,GAAG,GAAmC;QAC1C,CAAC,mBAAmB,CAAC,EAAE;YACrB,IAAI,EAAE,mBAAmB;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,YAAY,EAAE,MAAM;YACpB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B;KACF,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,IAAI,CAAC,GAAG;YACV,IAAI;YACJ,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,YAAY,EAAE,CAAC,CAAC,YAAY,IAAI,MAAM;YACtC,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ;SACxC,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,eAAe,CAAC,MAA4B;IAC1D,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,IAAI,8BAA8B;QACnF,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE;QACjC,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,MAAM;QAC3C,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC;KAChC,CAAC;AACJ,CAAC"}
|
package/dist/naming.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
* Convert PascalCase or camelCase to snake_case.
|
|
4
|
-
* Treats consecutive capitals (e.g., "APIKey") as a single word: "api_key".
|
|
5
|
-
*/
|
|
6
|
-
export declare function toSnakeCase(s: string): string;
|
|
1
|
+
import { toKebabCase, type ColumnNamingStrategy } from "@metaobjectsdev/metadata";
|
|
2
|
+
export { pluralize, toSnakeCase } from "@metaobjectsdev/metadata";
|
|
7
3
|
/**
|
|
8
4
|
* Convert snake_case to camelCase. Preserves already-camelCase input.
|
|
9
5
|
*/
|
|
@@ -12,12 +8,6 @@ export declare function toCamelCase(s: string): string;
|
|
|
12
8
|
* Capitalize the first character of a string (camelCase → PascalCase).
|
|
13
9
|
*/
|
|
14
10
|
export declare function toPascalCase(s: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Simple English pluralization. Documented imperfection per design §13 #1:
|
|
17
|
-
* irregular plurals (Person → Persons, not People) are not handled.
|
|
18
|
-
* Users override via source[dbTable]@name in metadata.
|
|
19
|
-
*/
|
|
20
|
-
export declare function pluralize(s: string): string;
|
|
21
11
|
/** PascalCase entity → strategy-applied plural for DB table name. */
|
|
22
12
|
export declare function tableNameFromEntity(entityName: string, strategy?: ColumnNamingStrategy): string;
|
|
23
13
|
/** camelCase or PascalCase field → strategy-applied DB column name. */
|
|
@@ -30,4 +20,5 @@ export declare function columnNameFromField(fieldName: string, strategy?: Column
|
|
|
30
20
|
export declare function viewNameFromProjection(projectionName: string, strategy: ColumnNamingStrategy): string;
|
|
31
21
|
/** PascalCase entity → camelCase plural for the Drizzle table variable. */
|
|
32
22
|
export declare function variableNameFromEntity(entityName: string): string;
|
|
23
|
+
export { toKebabCase };
|
|
33
24
|
//# sourceMappingURL=naming.d.ts.map
|
package/dist/naming.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../src/naming.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../src/naming.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,WAAW,EAEX,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAElE;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,qEAAqE;AACrE,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,oBAAqD,GAC9D,MAAM,CAER;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,oBAAqD,GAC9D,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,oBAAoB,GAC7B,MAAM,CAGR;AAED,2EAA2E;AAC3E,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEjE;AAGD,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/naming.js
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
// Naming helpers — case conversion + pluralization for codegen output.
|
|
2
|
-
// All functions are pure.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
return s
|
|
9
|
-
.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2")
|
|
10
|
-
.replace(/([a-z0-9])([A-Z])/g, "$1_$2")
|
|
11
|
-
.toLowerCase();
|
|
12
|
-
}
|
|
13
|
-
/** Convert PascalCase or camelCase to kebab-case. */
|
|
14
|
-
function toKebabCase(s) {
|
|
15
|
-
return toSnakeCase(s).replace(/_/g, "-");
|
|
16
|
-
}
|
|
17
|
-
/** Apply a ColumnNamingStrategy to a name. */
|
|
18
|
-
function applyStrategy(name, strategy) {
|
|
19
|
-
switch (strategy) {
|
|
20
|
-
case "snake_case": return toSnakeCase(name);
|
|
21
|
-
case "literal": return name;
|
|
22
|
-
case "kebab-case": return toKebabCase(name);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
2
|
+
// All functions are pure. The strategy primitives (toSnakeCase, toKebabCase,
|
|
3
|
+
// applyColumnNamingStrategy, pluralize, DEFAULT_COLUMN_NAMING_STRATEGY) are
|
|
4
|
+
// re-exported from @metaobjectsdev/metadata so codegen + runtime + migrate
|
|
5
|
+
// share a single source of truth for how field/table names lower to columns.
|
|
6
|
+
import { applyColumnNamingStrategy, DEFAULT_COLUMN_NAMING_STRATEGY, pluralize, toKebabCase, toSnakeCase, } from "@metaobjectsdev/metadata";
|
|
7
|
+
export { pluralize, toSnakeCase } from "@metaobjectsdev/metadata";
|
|
25
8
|
/**
|
|
26
9
|
* Convert snake_case to camelCase. Preserves already-camelCase input.
|
|
27
10
|
*/
|
|
@@ -34,25 +17,13 @@ export function toCamelCase(s) {
|
|
|
34
17
|
export function toPascalCase(s) {
|
|
35
18
|
return s.length > 0 ? s[0].toUpperCase() + s.slice(1) : s;
|
|
36
19
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Simple English pluralization. Documented imperfection per design §13 #1:
|
|
39
|
-
* irregular plurals (Person → Persons, not People) are not handled.
|
|
40
|
-
* Users override via source[dbTable]@name in metadata.
|
|
41
|
-
*/
|
|
42
|
-
export function pluralize(s) {
|
|
43
|
-
if (/(s|x|z|ch|sh)$/i.test(s))
|
|
44
|
-
return s + "es";
|
|
45
|
-
if (/[^aeiou]y$/i.test(s))
|
|
46
|
-
return s.slice(0, -1) + "ies";
|
|
47
|
-
return s + "s";
|
|
48
|
-
}
|
|
49
20
|
/** PascalCase entity → strategy-applied plural for DB table name. */
|
|
50
|
-
export function tableNameFromEntity(entityName, strategy =
|
|
51
|
-
return
|
|
21
|
+
export function tableNameFromEntity(entityName, strategy = DEFAULT_COLUMN_NAMING_STRATEGY) {
|
|
22
|
+
return applyColumnNamingStrategy(pluralize(entityName), strategy);
|
|
52
23
|
}
|
|
53
24
|
/** camelCase or PascalCase field → strategy-applied DB column name. */
|
|
54
|
-
export function columnNameFromField(fieldName, strategy =
|
|
55
|
-
return
|
|
25
|
+
export function columnNameFromField(fieldName, strategy = DEFAULT_COLUMN_NAMING_STRATEGY) {
|
|
26
|
+
return applyColumnNamingStrategy(fieldName, strategy);
|
|
56
27
|
}
|
|
57
28
|
/**
|
|
58
29
|
* PascalCase projection name → "v_" prefix + strategy applied (not pluralized).
|
|
@@ -60,14 +31,13 @@ export function columnNameFromField(fieldName, strategy = "snake_case") {
|
|
|
60
31
|
* With kebab-case the separator prefix is "v-" to stay consistent.
|
|
61
32
|
*/
|
|
62
33
|
export function viewNameFromProjection(projectionName, strategy) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
case "literal": return "v_" + projectionName;
|
|
66
|
-
case "kebab-case": return "v-" + toKebabCase(projectionName);
|
|
67
|
-
}
|
|
34
|
+
const sep = strategy === "kebab-case" ? "-" : "_";
|
|
35
|
+
return "v" + sep + applyColumnNamingStrategy(projectionName, strategy);
|
|
68
36
|
}
|
|
69
37
|
/** PascalCase entity → camelCase plural for the Drizzle table variable. */
|
|
70
38
|
export function variableNameFromEntity(entityName) {
|
|
71
39
|
return pluralize(toCamelCase(entityName.charAt(0).toLowerCase() + entityName.slice(1)));
|
|
72
40
|
}
|
|
41
|
+
// Re-exported here for callers that import from codegen-ts's naming module.
|
|
42
|
+
export { toKebabCase };
|
|
73
43
|
//# sourceMappingURL=naming.js.map
|
package/dist/naming.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../src/naming.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,
|
|
1
|
+
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../src/naming.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAE7E,OAAO,EACL,yBAAyB,EACzB,8BAA8B,EAC9B,SAAS,EACT,WAAW,EACX,WAAW,GAEZ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAElE;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,CAAS;IACnC,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACnE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,CAAS;IACpC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,mBAAmB,CACjC,UAAkB,EAClB,WAAiC,8BAA8B;IAE/D,OAAO,yBAAyB,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAC;AACpE,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,WAAiC,8BAA8B;IAE/D,OAAO,yBAAyB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,cAAsB,EACtB,QAA8B;IAE9B,MAAM,GAAG,GAAG,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAClD,OAAO,GAAG,GAAG,GAAG,GAAG,yBAAyB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AACzE,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,sBAAsB,CAAC,UAAkB;IACvD,OAAO,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1F,CAAC;AAED,4EAA4E;AAC5E,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { type MetaData } from "@metaobjectsdev/metadata";
|
|
2
2
|
/** Emit the payload `interface` (+ nested element interfaces) for an object.value view-object. */
|
|
3
3
|
export declare function generatePayloadInterfaces(root: MetaData, voName: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Emit interfaces for several payloads at once, using a single shared dedupe
|
|
6
|
+
* set so nested types (e.g. lens projections referenced by multiple payloads)
|
|
7
|
+
* appear exactly once in the combined output.
|
|
8
|
+
*
|
|
9
|
+
* Returns the empty string when `voNames` is empty.
|
|
10
|
+
*/
|
|
11
|
+
export declare function generatePayloadInterfacesBatch(root: MetaData, voNames: readonly string[]): string;
|
|
4
12
|
/** Emit a typed render handle binding a template's @textRef + @format and typing its payload. */
|
|
5
13
|
export declare function generateRenderHandle(root: MetaData, templateName: string): string;
|
|
6
14
|
//# sourceMappingURL=payload-codegen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload-codegen.d.ts","sourceRoot":"","sources":["../src/payload-codegen.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"payload-codegen.d.ts","sourceRoot":"","sources":["../src/payload-codegen.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,QAAQ,EAUd,MAAM,0BAA0B,CAAC;AAqElC,kGAAkG;AAClG,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIhF;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAQjG;AAMD,iGAAiG;AACjG,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAgBjF"}
|
package/dist/payload-codegen.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// should reuse codegen-ts's canonical field mapping + ts-poet emit + the
|
|
10
10
|
// Generator/runner integration. Assembler (RDB materialization + host overlay)
|
|
11
11
|
// is out of scope — this only emits the contract.
|
|
12
|
-
import { TYPE_OBJECT, TYPE_FIELD, TYPE_TEMPLATE, FIELD_SUBTYPE_OBJECT, FIELD_ATTR_OBJECT_REF, TEMPLATE_ATTR_PAYLOAD_REF, TEMPLATE_ATTR_TEXT_REF, TEMPLATE_ATTR_FORMAT, } from "@metaobjectsdev/metadata";
|
|
12
|
+
import { TYPE_OBJECT, TYPE_FIELD, TYPE_TEMPLATE, FIELD_SUBTYPE_OBJECT, FIELD_ATTR_OBJECT_REF, FIELD_ATTR_REQUIRED, TEMPLATE_ATTR_PAYLOAD_REF, TEMPLATE_ATTR_TEXT_REF, TEMPLATE_ATTR_FORMAT, } from "@metaobjectsdev/metadata";
|
|
13
13
|
const SCALAR_TS = {
|
|
14
14
|
string: "string",
|
|
15
15
|
class: "string",
|
|
@@ -42,7 +42,12 @@ function fieldTsType(field) {
|
|
|
42
42
|
result.refVo = ref;
|
|
43
43
|
return result;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
const scalar = SCALAR_TS[field.subType] ?? "unknown";
|
|
46
|
+
return { type: field.isArray ? `${scalar}[]` : scalar };
|
|
47
|
+
}
|
|
48
|
+
/** True iff the field's @required is explicitly set to true. */
|
|
49
|
+
function isFieldRequired(field) {
|
|
50
|
+
return field.ownAttr(FIELD_ATTR_REQUIRED) === true;
|
|
46
51
|
}
|
|
47
52
|
function emitInterface(root, voName, emitted, out) {
|
|
48
53
|
if (emitted.has(voName))
|
|
@@ -55,7 +60,15 @@ function emitInterface(root, voName, emitted, out) {
|
|
|
55
60
|
const refs = [];
|
|
56
61
|
for (const f of vo.children().filter((c) => c.type === TYPE_FIELD)) {
|
|
57
62
|
const { type, refVo } = fieldTsType(f);
|
|
58
|
-
|
|
63
|
+
// Required fields: `name: T;`
|
|
64
|
+
// Optional fields: `name?: T | null;` — the `| null` lets values from
|
|
65
|
+
// Drizzle entity rows (which return `null` for nullable columns) flow
|
|
66
|
+
// straight in. Without it, TS treats undefined-vs-null as a hard error
|
|
67
|
+
// at the entity → payload boundary.
|
|
68
|
+
const isRequired = isFieldRequired(f);
|
|
69
|
+
const tsType = isRequired ? type : `${type} | null`;
|
|
70
|
+
const optional = isRequired ? "" : "?";
|
|
71
|
+
lines.push(` ${f.name}${optional}: ${tsType};`);
|
|
59
72
|
if (refVo)
|
|
60
73
|
refs.push(refVo);
|
|
61
74
|
}
|
|
@@ -70,6 +83,23 @@ export function generatePayloadInterfaces(root, voName) {
|
|
|
70
83
|
emitInterface(root, voName, new Set(), out);
|
|
71
84
|
return out.join("\n\n") + "\n";
|
|
72
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Emit interfaces for several payloads at once, using a single shared dedupe
|
|
88
|
+
* set so nested types (e.g. lens projections referenced by multiple payloads)
|
|
89
|
+
* appear exactly once in the combined output.
|
|
90
|
+
*
|
|
91
|
+
* Returns the empty string when `voNames` is empty.
|
|
92
|
+
*/
|
|
93
|
+
export function generatePayloadInterfacesBatch(root, voNames) {
|
|
94
|
+
if (voNames.length === 0)
|
|
95
|
+
return "";
|
|
96
|
+
const out = [];
|
|
97
|
+
const emitted = new Set();
|
|
98
|
+
for (const name of voNames) {
|
|
99
|
+
emitInterface(root, name, emitted, out);
|
|
100
|
+
}
|
|
101
|
+
return out.length === 0 ? "" : out.join("\n\n") + "\n";
|
|
102
|
+
}
|
|
73
103
|
function pascal(s) {
|
|
74
104
|
return s.length > 0 ? s[0].toUpperCase() + s.slice(1) : s;
|
|
75
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload-codegen.js","sourceRoot":"","sources":["../src/payload-codegen.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,EAAE;AACF,+EAA+E;AAC/E,iFAAiF;AACjF,+EAA+E;AAC/E,sEAAsE;AACtE,EAAE;AACF,8EAA8E;AAC9E,yEAAyE;AACzE,+EAA+E;AAC/E,kDAAkD;AAElD,OAAO,EAEL,WAAW,EACX,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAElC,MAAM,SAAS,GAA2B;IACxC,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,GAAG,EAAE,QAAQ;IACb,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,QAAQ;IACd,IAAI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AO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,oBAAoB,CAAC,IAAc,EAAE,YAAoB;IACvE,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;IACjG,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,YAAY,aAAa,CAAC,CAAC;IACnE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC3D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACrD,MAAM,MAAM,GAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAwB,IAAI,MAAM,CAAC;IACpF,MAAM,EAAE,GAAG,SAAS,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;IAC3C,OAAO;QACL,iEAAiE;QACjE,iBAAiB,UAAU,0BAA0B;QACrD,EAAE;QACF,mBAAmB,EAAE,aAAa,UAAU,iCAAiC;QAC7E,0BAA0B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,sBAAsB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB;QAC7G,GAAG;QACH,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -11,7 +11,7 @@ export interface ExtractContext {
|
|
|
11
11
|
* and extends a writable entity).
|
|
12
12
|
* @param root The loader's MetaRoot — all top-level objects are
|
|
13
13
|
* direct children of root (returned by `MetaDataLoader.load()`
|
|
14
|
-
*
|
|
14
|
+
* or `MetaDataLoader.fromDirectory()` as `result.root`).
|
|
15
15
|
* @param ctx Column naming strategy for SQL identifiers.
|
|
16
16
|
*/
|
|
17
17
|
export declare function extractViewSpec(projection: MetaObject, root: MetaRoot, ctx: ExtractContext): ViewSpec;
|
|
@@ -255,7 +255,7 @@ function buildGroupBy(spec) {
|
|
|
255
255
|
* and extends a writable entity).
|
|
256
256
|
* @param root The loader's MetaRoot — all top-level objects are
|
|
257
257
|
* direct children of root (returned by `MetaDataLoader.load()`
|
|
258
|
-
*
|
|
258
|
+
* or `MetaDataLoader.fromDirectory()` as `result.root`).
|
|
259
259
|
* @param ctx Column naming strategy for SQL identifiers.
|
|
260
260
|
*/
|
|
261
261
|
export function extractViewSpec(projection, root, ctx) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MetaObject } from "@metaobjectsdev/metadata";
|
|
2
|
+
/**
|
|
3
|
+
* True when the entity declares at least one writable source.rdb child.
|
|
4
|
+
* Discriminates table-backed entities (full Drizzle file: table + Insert/Update
|
|
5
|
+
* schemas + filter allowlists + constants) from value-only objects (TS
|
|
6
|
+
* interface + Zod schema only). Absence of source.rdb means in-memory /
|
|
7
|
+
* transit data — no migration, no ORM table to point at.
|
|
8
|
+
*/
|
|
9
|
+
export declare function hasWritableRdbSource(entity: MetaObject): boolean;
|
|
10
|
+
//# sourceMappingURL=source-detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-detect.d.ts","sourceRoot":"","sources":["../src/source-detect.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAQhE"}
|