@metaobjectsdev/codegen-ts 0.7.0-rc.9 → 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.
Files changed (56) hide show
  1. package/dist/generator.d.ts +9 -0
  2. package/dist/generator.d.ts.map +1 -1
  3. package/dist/generator.js.map +1 -1
  4. package/dist/generators/docs-data-builder.d.ts +16 -0
  5. package/dist/generators/docs-data-builder.d.ts.map +1 -0
  6. package/dist/generators/docs-data-builder.js +381 -0
  7. package/dist/generators/docs-data-builder.js.map +1 -0
  8. package/dist/generators/docs-data.d.ts +98 -0
  9. package/dist/generators/docs-data.d.ts.map +1 -0
  10. package/dist/generators/docs-data.js +43 -0
  11. package/dist/generators/docs-data.js.map +1 -0
  12. package/dist/generators/docs-file.d.ts +8 -0
  13. package/dist/generators/docs-file.d.ts.map +1 -0
  14. package/dist/generators/docs-file.js +77 -0
  15. package/dist/generators/docs-file.js.map +1 -0
  16. package/dist/generators/index.d.ts +4 -0
  17. package/dist/generators/index.d.ts.map +1 -1
  18. package/dist/generators/index.js +3 -0
  19. package/dist/generators/index.js.map +1 -1
  20. package/dist/generators/template-generator.d.ts +41 -0
  21. package/dist/generators/template-generator.d.ts.map +1 -0
  22. package/dist/generators/template-generator.js +62 -0
  23. package/dist/generators/template-generator.js.map +1 -0
  24. package/dist/index.d.ts +6 -2
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +7 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/overwrite-policy.d.ts +39 -2
  29. package/dist/overwrite-policy.d.ts.map +1 -1
  30. package/dist/overwrite-policy.js +233 -13
  31. package/dist/overwrite-policy.js.map +1 -1
  32. package/dist/render-engine/framework-provider.d.ts +28 -0
  33. package/dist/render-engine/framework-provider.d.ts.map +1 -0
  34. package/dist/render-engine/framework-provider.js +104 -0
  35. package/dist/render-engine/framework-provider.js.map +1 -0
  36. package/dist/runner.d.ts +15 -1
  37. package/dist/runner.d.ts.map +1 -1
  38. package/dist/runner.js +44 -6
  39. package/dist/runner.js.map +1 -1
  40. package/dist/templates/docs-file.d.ts +17 -0
  41. package/dist/templates/docs-file.d.ts.map +1 -0
  42. package/dist/templates/docs-file.js +37 -0
  43. package/dist/templates/docs-file.js.map +1 -0
  44. package/package.json +5 -5
  45. package/src/generator.ts +9 -0
  46. package/src/generators/docs-data-builder.ts +470 -0
  47. package/src/generators/docs-data.ts +154 -0
  48. package/src/generators/docs-file.ts +87 -0
  49. package/src/generators/index.ts +16 -0
  50. package/src/generators/template-generator.ts +106 -0
  51. package/src/index.ts +33 -2
  52. package/src/overwrite-policy.ts +325 -14
  53. package/src/render-engine/framework-provider.ts +107 -0
  54. package/src/runner.ts +65 -6
  55. package/src/templates/docs-file.ts +51 -0
  56. package/templates/docs/entity-page.md.mustache +54 -0
@@ -0,0 +1,28 @@
1
+ import type { Provider } from "@metaobjectsdev/render";
2
+ /** Provider backed by an arbitrary on-disk template directory. References
3
+ * resolve as `<dir>/<ref>.mustache`. Used by both the framework default
4
+ * and adopter override paths. */
5
+ export declare class FileSystemProvider implements Provider {
6
+ private readonly root;
7
+ constructor(root: string);
8
+ resolve(ref: string): string | undefined;
9
+ }
10
+ /** The framework defaults provider — resolves refs against codegen-ts's own
11
+ * `templates/` directory. */
12
+ export declare const frameworkTemplatesProvider: Provider;
13
+ /** Compose providers: first match wins. Adopters typically chain
14
+ * `[projectProvider, frameworkTemplatesProvider]` so their own templates
15
+ * override the framework defaults. */
16
+ export declare class ProviderChain implements Provider {
17
+ private readonly providers;
18
+ constructor(providers: readonly Provider[]);
19
+ resolve(ref: string): string | undefined;
20
+ }
21
+ /** Build a project-scoped Provider: layers an optional project `templates/`
22
+ * directory over the framework defaults. Returns just the framework provider
23
+ * when `projectRoot` is undefined / its `templates/` dir doesn't exist. */
24
+ export declare function projectProvider(projectRoot?: string): Provider;
25
+ /** Exposed for tests that want to inspect / clear the resolved framework
26
+ * templates directory (don't use outside tests). */
27
+ export declare const __frameworkTemplatesDirForTests: string;
28
+ //# sourceMappingURL=framework-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-provider.d.ts","sourceRoot":"","sources":["../../src/render-engine/framework-provider.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AA6CvD;;kCAEkC;AAClC,qBAAa,kBAAmB,YAAW,QAAQ;IACrC,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,MAAM;IACzC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAKzC;AAED;8BAC8B;AAC9B,eAAO,MAAM,0BAA0B,EAAE,QAExC,CAAC;AAEF;;uCAEuC;AACvC,qBAAa,aAAc,YAAW,QAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS,QAAQ,EAAE;IAC3D,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAOzC;AAED;;4EAE4E;AAC5E,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ,CAQ9D;AAED;qDACqD;AACrD,eAAO,MAAM,+BAA+B,QAA0B,CAAC"}
@@ -0,0 +1,104 @@
1
+ // FrameworkTemplateProvider — resolves template refs (e.g. "docs/entity-page.md")
2
+ // against the codegen-ts package's `templates/` directory. Adopters who want
3
+ // to override a framework template create their own `templates/<ref>.mustache`
4
+ // file in their project; `ProviderChain` (below) consults the project first
5
+ // and falls back to the framework defaults.
6
+ //
7
+ // Decision D1 from the template-driven-codegen design — hybrid: framework
8
+ // ships defaults, adopters override by file-system convention.
9
+ //
10
+ // The framework Provider is filesystem-backed so it works identically whether
11
+ // codegen-ts runs from source (bun, dev) or from `dist/` (npm install). The
12
+ // `templates/` directory is included in the published tarball via
13
+ // package.json `files: ["dist", "src", "templates", ...]`.
14
+ import { existsSync, readFileSync } from "node:fs";
15
+ import { join, resolve, dirname } from "node:path";
16
+ import { fileURLToPath } from "node:url";
17
+ /** Canonical shipped template — used to verify a candidate framework
18
+ * templates directory actually contains our defaults. Without this check a
19
+ * hoisted-install layout (pnpm/bun workspaces) can walk up to a CONSUMER
20
+ * package.json and silently return a templates dir that doesn't exist. */
21
+ const CANONICAL_TEMPLATE_REL = "docs/entity-page.md.mustache";
22
+ /** Walk up from `start` until we find a `package.json` whose neighbour
23
+ * `templates/` directory contains our canonical shipped template (i.e., the
24
+ * codegen-ts package root). Works the same way from
25
+ * `src/render-engine/framework-provider.ts` (during dev) and
26
+ * `dist/render-engine/framework-provider.js` (after `npm install`). */
27
+ function findFrameworkTemplatesDir(start) {
28
+ let dir = start;
29
+ while (true) {
30
+ const pkgJson = join(dir, "package.json");
31
+ if (existsSync(pkgJson)) {
32
+ const templatesDir = join(dir, "templates");
33
+ // Assert we landed at the codegen-ts package root, not a consumer's.
34
+ if (existsSync(join(templatesDir, CANONICAL_TEMPLATE_REL))) {
35
+ return templatesDir;
36
+ }
37
+ }
38
+ const parent = dirname(dir);
39
+ if (parent === dir)
40
+ break;
41
+ dir = parent;
42
+ }
43
+ throw new Error(`framework templates dir unresolved: walked up from ${start} without finding a package.json ` +
44
+ `whose templates/${CANONICAL_TEMPLATE_REL} exists. This usually means codegen-ts was installed ` +
45
+ `via a hoisted layout (pnpm/bun workspaces) into an unexpected location, or the published ` +
46
+ `tarball is missing the templates/ directory.`);
47
+ }
48
+ // In ESM (CLAUDE.md: "ESM only. No CommonJS."), `import.meta.url` is
49
+ // guaranteed to be a file: URL; no defensive try/catch needed.
50
+ const SELF_DIR = dirname(fileURLToPath(import.meta.url));
51
+ const FRAMEWORK_TEMPLATES_DIR = findFrameworkTemplatesDir(SELF_DIR);
52
+ /** Provider backed by an arbitrary on-disk template directory. References
53
+ * resolve as `<dir>/<ref>.mustache`. Used by both the framework default
54
+ * and adopter override paths. */
55
+ export class FileSystemProvider {
56
+ root;
57
+ constructor(root) {
58
+ this.root = root;
59
+ }
60
+ resolve(ref) {
61
+ const path = join(this.root, `${ref}.mustache`);
62
+ if (!existsSync(path))
63
+ return undefined;
64
+ return readFileSync(path, "utf-8");
65
+ }
66
+ }
67
+ /** The framework defaults provider — resolves refs against codegen-ts's own
68
+ * `templates/` directory. */
69
+ export const frameworkTemplatesProvider = new FileSystemProvider(FRAMEWORK_TEMPLATES_DIR);
70
+ /** Compose providers: first match wins. Adopters typically chain
71
+ * `[projectProvider, frameworkTemplatesProvider]` so their own templates
72
+ * override the framework defaults. */
73
+ export class ProviderChain {
74
+ providers;
75
+ constructor(providers) {
76
+ this.providers = providers;
77
+ }
78
+ resolve(ref) {
79
+ for (const p of this.providers) {
80
+ const text = p.resolve(ref);
81
+ if (text !== undefined)
82
+ return text;
83
+ }
84
+ return undefined;
85
+ }
86
+ }
87
+ /** Build a project-scoped Provider: layers an optional project `templates/`
88
+ * directory over the framework defaults. Returns just the framework provider
89
+ * when `projectRoot` is undefined / its `templates/` dir doesn't exist. */
90
+ export function projectProvider(projectRoot) {
91
+ if (projectRoot === undefined)
92
+ return frameworkTemplatesProvider;
93
+ const projTemplates = resolve(projectRoot, "templates");
94
+ if (!existsSync(projTemplates))
95
+ return frameworkTemplatesProvider;
96
+ return new ProviderChain([
97
+ new FileSystemProvider(projTemplates),
98
+ frameworkTemplatesProvider,
99
+ ]);
100
+ }
101
+ /** Exposed for tests that want to inspect / clear the resolved framework
102
+ * templates directory (don't use outside tests). */
103
+ export const __frameworkTemplatesDirForTests = FRAMEWORK_TEMPLATES_DIR;
104
+ //# sourceMappingURL=framework-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-provider.js","sourceRoot":"","sources":["../../src/render-engine/framework-provider.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,6EAA6E;AAC7E,+EAA+E;AAC/E,4EAA4E;AAC5E,4CAA4C;AAC5C,EAAE;AACF,0EAA0E;AAC1E,+DAA+D;AAC/D,EAAE;AACF,8EAA8E;AAC9E,4EAA4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@@ -1,6 +1,6 @@
1
1
  import type { MetaData } from "@metaobjectsdev/metadata";
2
2
  import type { MetaobjectsGenConfig } from "./metaobjects-config.js";
3
- import { type WriteResult, type MergeStrategy } from "./overwrite-policy.js";
3
+ import { type WriteResult, type MergeStrategy, type BaselineMode } from "./overwrite-policy.js";
4
4
  export interface RunGenOpts {
5
5
  config: MetaobjectsGenConfig;
6
6
  metadata: MetaData;
@@ -8,10 +8,24 @@ export interface RunGenOpts {
8
8
  entityFilter?: string[];
9
9
  /** Overwrite strategy passed to decideAndWrite. Defaults to "overwrite". */
10
10
  mergeStrategy?: MergeStrategy;
11
+ /** Project root (used to derive the .gen-state/ snapshot directory and to
12
+ * key snapshots by project-relative output path). When omitted, falls back
13
+ * to process.cwd(). */
14
+ projectRoot?: string;
15
+ /** Override the snapshot directory location. Defaults to
16
+ * `<projectRoot>/.metaobjects/.gen-state/`. */
17
+ genStateDir?: string;
18
+ /** First-time-on-existing-file behavior. Defaults to "default" (write-if-
19
+ * different). "fresh" → overwrite and re-baseline (the `--baseline=fresh`
20
+ * CLI flag). */
21
+ baseline?: BaselineMode;
11
22
  }
12
23
  export interface RunGenResult {
13
24
  files: WriteResult[];
14
25
  warnings: string[];
26
+ /** Subset of `files` with status "conflict" — surfaced separately so the
27
+ * CLI can print the end-of-run summary. */
28
+ conflicts: WriteResult[];
15
29
  }
16
30
  export declare function runGen(opts: RunGenOpts): Promise<RunGenResult>;
17
31
  //# sourceMappingURL=runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,0BAA0B,CAAC;AAGrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAMpE,OAAO,EAAkB,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAM7F,MAAM,WAAW,UAAU;IACzB,MAAM,EA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pE"}
package/dist/runner.js CHANGED
@@ -1,16 +1,35 @@
1
- import { join } from "node:path";
1
+ import { join, relative, resolve, isAbsolute } from "node:path";
2
+ import { tmpdir } from "node:os";
2
3
  import { MetaRoot } from "@metaobjectsdev/metadata";
3
4
  import { normalizeConfig, DEFAULT_TARGET_NAME } from "./metaobjects-config.js";
4
5
  import { buildPkMap } from "./pk-resolver.js";
5
6
  import { buildRelationMap } from "./relation-resolver.js";
6
7
  import { makeRenderContext } from "./render-context.js";
7
- import { decideAndWrite } from "./overwrite-policy.js";
8
+ import { decideAndWrite, } from "./overwrite-policy.js";
8
9
  /** JS-identifier-shape only. Prevents filesystem traversal when metadata comes
9
10
  * from untrusted sources (e.g. MCP). Mirrors the guard in legacy generate.ts. */
10
11
  const VALID_ENTITY_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
11
12
  export async function runGen(opts) {
12
13
  const warnings = [];
13
14
  const strategy = opts.mergeStrategy ?? "overwrite";
15
+ const baseline = opts.baseline ?? "default";
16
+ // When projectRoot is not supplied we DON'T fall back to process.cwd() —
17
+ // that would leak .gen-state/ into whatever directory happens to be cwd
18
+ // (e.g. the package dir during a unit-test run). Instead, fall back to a
19
+ // process-isolated tmpdir, which gives the new-write semantics every call
20
+ // (the snapshot exists only for the current process). The CLI's
21
+ // `genCommand` always passes a real projectRoot, so this fallback only
22
+ // affects programmatic callers (tests, library embedding).
23
+ const projectRoot = opts.projectRoot !== undefined
24
+ ? (isAbsolute(opts.projectRoot) ? opts.projectRoot : resolve(opts.projectRoot))
25
+ : undefined;
26
+ const genStateDir = opts.genStateDir !== undefined
27
+ ? (isAbsolute(opts.genStateDir)
28
+ ? opts.genStateDir
29
+ : resolve(projectRoot ?? process.cwd(), opts.genStateDir))
30
+ : (projectRoot !== undefined
31
+ ? join(projectRoot, ".metaobjects", ".gen-state")
32
+ : join(tmpdir(), `meta-gen-state-${process.pid}`));
14
33
  // loadMemory now returns MetaRoot; guard here also covers callers that pass a
15
34
  // plain MetaData (e.g. test helpers that build trees programmatically).
16
35
  if (!(opts.metadata instanceof MetaRoot)) {
@@ -28,7 +47,7 @@ export async function runGen(opts) {
28
47
  ? "no object children match the provided entityFilter"
29
48
  : "root has no object children";
30
49
  warnings.push(`No entities to generate — ${reason}.`);
31
- return { files: [], warnings };
50
+ return { files: [], warnings, conflicts: [] };
32
51
  }
33
52
  const safeEntities = [];
34
53
  for (const entity of filtered) {
@@ -39,7 +58,7 @@ export async function runGen(opts) {
39
58
  safeEntities.push(entity);
40
59
  }
41
60
  if (safeEntities.length === 0) {
42
- return { files: [], warnings };
61
+ return { files: [], warnings, conflicts: [] };
43
62
  }
44
63
  // 2. Resolve targets + entity-module target.
45
64
  const config = normalizeConfig(opts.config);
@@ -99,6 +118,7 @@ export async function runGen(opts) {
99
118
  outputLayout: selfTarget.outputLayout,
100
119
  },
101
120
  renderContext,
121
+ ...(projectRoot !== undefined && { projectRoot }),
102
122
  warn: (msg) => warnings.push(`[${generator.name}] ${msg}`),
103
123
  };
104
124
  let files;
@@ -122,14 +142,32 @@ export async function runGen(opts) {
122
142
  }
123
143
  // 5. Write phase.
124
144
  const writes = [];
145
+ const conflicts = [];
125
146
  for (const file of emitted) {
126
- const result = decideAndWrite(file.fullPath, file.content, strategy);
147
+ // Key the snapshot by project-relative path so multi-target projects keep
148
+ // distinct entries (e.g. `database/Post.ts` vs `web/Post.queries.ts`).
149
+ // Without an explicit projectRoot we let decideAndWrite derive a stable
150
+ // hash-of-path key — fine for ephemeral test runs.
151
+ const policyOpts = {
152
+ strategy,
153
+ genStateDir,
154
+ baseline,
155
+ };
156
+ if (projectRoot !== undefined) {
157
+ policyOpts.outputRelPath = relative(projectRoot, file.fullPath);
158
+ }
159
+ const result = decideAndWrite(file.fullPath, file.content, policyOpts);
127
160
  writes.push(result);
161
+ if (result.status === "conflict") {
162
+ conflicts.push(result);
163
+ warnings.push(`Merge conflict in ${file.fullPath}: resolve diff3 markers and re-run ` +
164
+ `'meta gen' to advance the canonical state.`);
165
+ }
128
166
  if (result.status === "refused") {
129
167
  warnings.push(`Refused to overwrite ${file.fullPath}: file exists without @generated header. ` +
130
168
  `Move to a different outDir, delete the file, or add the header to opt in.`);
131
169
  }
132
170
  }
133
- return { files: writes, warnings };
171
+ return { files: writes, warnings, conflicts };
134
172
  }
135
173
  //# sourceMappingURL=runner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAwC,MAAM,uBAAuB,CAAC;AAE7F;kFACkF;AAClF,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AAgBrD,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAgB;IAC3C,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,IAAI,WAAW,CAAC;IAEnD,8EAA8E;IAC9E,wEAAwE;IACxE,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,YAAY,QAAQ,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;IAE3B,+CAA+C;IAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAClC,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;IACvC,MAAM,QAAQ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pB,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACjC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvB,QAAQ,CAAC,IAAI,CACX,qBAAqB,IAAI,CAAC,QAAQ,qCAAqC;gBACvE,4CAA4C,CAC7C,CAAC;QACJ,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,QAAQ,CAAC,IAAI,CACX,wBAAwB,IAAI,CAAC,QAAQ,2CAA2C;gBAChF,2EAA2E,CAC5E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AAChD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { MetaObject, MetaRoot } from "@metaobjectsdev/metadata";
2
+ import type { Dialect } from "../column-mapper.js";
3
+ import type { ColumnNamingStrategy } from "../metaobjects-config.js";
4
+ export interface DocsRenderOpts {
5
+ dialect: Dialect;
6
+ columnNamingStrategy?: ColumnNamingStrategy;
7
+ loadedRoot: MetaRoot;
8
+ /** Names of generators present in the pipeline — drives the "Generated code"
9
+ * section. Always includes "entity-file" implicitly. Recognized names:
10
+ * "queries-file", "routes-file", "routes-file-hono". */
11
+ generatorNames?: ReadonlySet<string>;
12
+ }
13
+ /** Backward-compatible entry point: builds the EntityDocData payload and
14
+ * renders it via the framework template. Byte-identical to the hand-coded
15
+ * rc.11 output (gated by `docs-file-conformance.test.ts`). */
16
+ export declare function renderDocsFile(entity: MetaObject, opts: DocsRenderOpts): string;
17
+ //# sourceMappingURL=docs-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-file.d.ts","sourceRoot":"","sources":["../../src/templates/docs-file.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAKrE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,UAAU,EAAE,QAAQ,CAAC;IACrB;;6DAEyD;IACzD,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACtC;AAED;;+DAE+D;AAC/D,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAiB/E"}
@@ -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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaobjectsdev/codegen-ts",
3
- "version": "0.7.0-rc.9",
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-rc.9",
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,8 +50,7 @@
49
50
  },
50
51
  "devDependencies": {
51
52
  "@biomejs/biome": "^1.9.0",
52
- "@metaobjectsdev/codegen-ts-react": "0.7.0-rc.9",
53
- "@metaobjectsdev/render": "0.7.0-rc.9",
53
+ "@metaobjectsdev/codegen-ts-react": "0.7.0",
54
54
  "bun-types": "latest",
55
55
  "drizzle-orm": "^0.36.0",
56
56
  "hono": "^4.6.0",
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