@metaobjectsdev/codegen-ts 0.5.0-rc.1

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 (198) hide show
  1. package/LICENSE +189 -0
  2. package/README.md +101 -0
  3. package/dist/column-mapper.d.ts +38 -0
  4. package/dist/column-mapper.d.ts.map +1 -0
  5. package/dist/column-mapper.js +205 -0
  6. package/dist/column-mapper.js.map +1 -0
  7. package/dist/constants.d.ts +7 -0
  8. package/dist/constants.d.ts.map +1 -0
  9. package/dist/constants.js +8 -0
  10. package/dist/constants.js.map +1 -0
  11. package/dist/errors.d.ts +7 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/errors.js +11 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/format.d.ts +2 -0
  16. package/dist/format.d.ts.map +1 -0
  17. package/dist/format.js +47 -0
  18. package/dist/format.js.map +1 -0
  19. package/dist/generator.d.ts +44 -0
  20. package/dist/generator.d.ts.map +1 -0
  21. package/dist/generator.js +17 -0
  22. package/dist/generator.js.map +1 -0
  23. package/dist/generators/barrel.d.ts +6 -0
  24. package/dist/generators/barrel.d.ts.map +1 -0
  25. package/dist/generators/barrel.js +17 -0
  26. package/dist/generators/barrel.js.map +1 -0
  27. package/dist/generators/entity-file.d.ts +8 -0
  28. package/dist/generators/entity-file.d.ts.map +1 -0
  29. package/dist/generators/entity-file.js +27 -0
  30. package/dist/generators/entity-file.js.map +1 -0
  31. package/dist/generators/index.d.ts +5 -0
  32. package/dist/generators/index.d.ts.map +1 -0
  33. package/dist/generators/index.js +5 -0
  34. package/dist/generators/index.js.map +1 -0
  35. package/dist/generators/queries-file.d.ts +8 -0
  36. package/dist/generators/queries-file.d.ts.map +1 -0
  37. package/dist/generators/queries-file.js +26 -0
  38. package/dist/generators/queries-file.js.map +1 -0
  39. package/dist/generators/routes-file.d.ts +12 -0
  40. package/dist/generators/routes-file.d.ts.map +1 -0
  41. package/dist/generators/routes-file.js +30 -0
  42. package/dist/generators/routes-file.js.map +1 -0
  43. package/dist/import-path.d.ts +41 -0
  44. package/dist/import-path.d.ts.map +1 -0
  45. package/dist/import-path.js +95 -0
  46. package/dist/import-path.js.map +1 -0
  47. package/dist/index.d.ts +29 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +21 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/metaobjects-config.d.ts +56 -0
  52. package/dist/metaobjects-config.d.ts.map +1 -0
  53. package/dist/metaobjects-config.js +42 -0
  54. package/dist/metaobjects-config.js.map +1 -0
  55. package/dist/naming.d.ts +29 -0
  56. package/dist/naming.d.ts.map +1 -0
  57. package/dist/naming.js +67 -0
  58. package/dist/naming.js.map +1 -0
  59. package/dist/overwrite-policy.d.ts +8 -0
  60. package/dist/overwrite-policy.d.ts.map +1 -0
  61. package/dist/overwrite-policy.js +23 -0
  62. package/dist/overwrite-policy.js.map +1 -0
  63. package/dist/pk-resolver.d.ts +18 -0
  64. package/dist/pk-resolver.d.ts.map +1 -0
  65. package/dist/pk-resolver.js +36 -0
  66. package/dist/pk-resolver.js.map +1 -0
  67. package/dist/projection/extract-view-spec.d.ts +18 -0
  68. package/dist/projection/extract-view-spec.d.ts.map +1 -0
  69. package/dist/projection/extract-view-spec.js +272 -0
  70. package/dist/projection/extract-view-spec.js.map +1 -0
  71. package/dist/projection/index.d.ts +5 -0
  72. package/dist/projection/index.d.ts.map +1 -0
  73. package/dist/projection/index.js +5 -0
  74. package/dist/projection/index.js.map +1 -0
  75. package/dist/projection/projection-detector.d.ts +4 -0
  76. package/dist/projection/projection-detector.d.ts.map +1 -0
  77. package/dist/projection/projection-detector.js +13 -0
  78. package/dist/projection/projection-detector.js.map +1 -0
  79. package/dist/projection/view-ddl-emit.d.ts +10 -0
  80. package/dist/projection/view-ddl-emit.d.ts.map +1 -0
  81. package/dist/projection/view-ddl-emit.js +47 -0
  82. package/dist/projection/view-ddl-emit.js.map +1 -0
  83. package/dist/projection/view-spec.d.ts +56 -0
  84. package/dist/projection/view-spec.d.ts.map +1 -0
  85. package/dist/projection/view-spec.js +2 -0
  86. package/dist/projection/view-spec.js.map +1 -0
  87. package/dist/relation-resolver.d.ts +21 -0
  88. package/dist/relation-resolver.d.ts.map +1 -0
  89. package/dist/relation-resolver.js +62 -0
  90. package/dist/relation-resolver.js.map +1 -0
  91. package/dist/render-context.d.ts +65 -0
  92. package/dist/render-context.d.ts.map +1 -0
  93. package/dist/render-context.js +28 -0
  94. package/dist/render-context.js.map +1 -0
  95. package/dist/runner.d.ts +17 -0
  96. package/dist/runner.d.ts.map +1 -0
  97. package/dist/runner.js +135 -0
  98. package/dist/runner.js.map +1 -0
  99. package/dist/templates/barrel.d.ts +8 -0
  100. package/dist/templates/barrel.d.ts.map +1 -0
  101. package/dist/templates/barrel.js +12 -0
  102. package/dist/templates/barrel.js.map +1 -0
  103. package/dist/templates/drizzle-schema.d.ts +13 -0
  104. package/dist/templates/drizzle-schema.d.ts.map +1 -0
  105. package/dist/templates/drizzle-schema.js +251 -0
  106. package/dist/templates/drizzle-schema.js.map +1 -0
  107. package/dist/templates/entity-constants.d.ts +4 -0
  108. package/dist/templates/entity-constants.d.ts.map +1 -0
  109. package/dist/templates/entity-constants.js +215 -0
  110. package/dist/templates/entity-constants.js.map +1 -0
  111. package/dist/templates/entity-file.d.ts +4 -0
  112. package/dist/templates/entity-file.d.ts.map +1 -0
  113. package/dist/templates/entity-file.js +45 -0
  114. package/dist/templates/entity-file.js.map +1 -0
  115. package/dist/templates/field-meta.d.ts +24 -0
  116. package/dist/templates/field-meta.d.ts.map +1 -0
  117. package/dist/templates/field-meta.js +117 -0
  118. package/dist/templates/field-meta.js.map +1 -0
  119. package/dist/templates/filter-allowlist.d.ts +5 -0
  120. package/dist/templates/filter-allowlist.d.ts.map +1 -0
  121. package/dist/templates/filter-allowlist.js +86 -0
  122. package/dist/templates/filter-allowlist.js.map +1 -0
  123. package/dist/templates/filter-shared.d.ts +15 -0
  124. package/dist/templates/filter-shared.d.ts.map +1 -0
  125. package/dist/templates/filter-shared.js +30 -0
  126. package/dist/templates/filter-shared.js.map +1 -0
  127. package/dist/templates/filter-type.d.ts +4 -0
  128. package/dist/templates/filter-type.d.ts.map +1 -0
  129. package/dist/templates/filter-type.js +78 -0
  130. package/dist/templates/filter-type.js.map +1 -0
  131. package/dist/templates/inferred-types.d.ts +4 -0
  132. package/dist/templates/inferred-types.d.ts.map +1 -0
  133. package/dist/templates/inferred-types.js +14 -0
  134. package/dist/templates/inferred-types.js.map +1 -0
  135. package/dist/templates/projection-decl.d.ts +21 -0
  136. package/dist/templates/projection-decl.d.ts.map +1 -0
  137. package/dist/templates/projection-decl.js +116 -0
  138. package/dist/templates/projection-decl.js.map +1 -0
  139. package/dist/templates/queries-file.d.ts +4 -0
  140. package/dist/templates/queries-file.d.ts.map +1 -0
  141. package/dist/templates/queries-file.js +39 -0
  142. package/dist/templates/queries-file.js.map +1 -0
  143. package/dist/templates/queries.d.ts +9 -0
  144. package/dist/templates/queries.d.ts.map +1 -0
  145. package/dist/templates/queries.js +115 -0
  146. package/dist/templates/queries.js.map +1 -0
  147. package/dist/templates/relations-block.d.ts +9 -0
  148. package/dist/templates/relations-block.d.ts.map +1 -0
  149. package/dist/templates/relations-block.js +45 -0
  150. package/dist/templates/relations-block.js.map +1 -0
  151. package/dist/templates/routes-file.d.ts +4 -0
  152. package/dist/templates/routes-file.d.ts.map +1 -0
  153. package/dist/templates/routes-file.js +158 -0
  154. package/dist/templates/routes-file.js.map +1 -0
  155. package/dist/templates/zod-validators.d.ts +4 -0
  156. package/dist/templates/zod-validators.d.ts.map +1 -0
  157. package/dist/templates/zod-validators.js +129 -0
  158. package/dist/templates/zod-validators.js.map +1 -0
  159. package/package.json +59 -0
  160. package/src/column-mapper.ts +266 -0
  161. package/src/constants.ts +10 -0
  162. package/src/errors.ts +10 -0
  163. package/src/format.ts +50 -0
  164. package/src/generator.ts +73 -0
  165. package/src/generators/barrel.ts +28 -0
  166. package/src/generators/entity-file.ts +33 -0
  167. package/src/generators/index.ts +4 -0
  168. package/src/generators/queries-file.ts +32 -0
  169. package/src/generators/routes-file.ts +36 -0
  170. package/src/import-path.ts +153 -0
  171. package/src/index.ts +45 -0
  172. package/src/metaobjects-config.ts +95 -0
  173. package/src/naming.ts +84 -0
  174. package/src/overwrite-policy.ts +39 -0
  175. package/src/pk-resolver.ts +47 -0
  176. package/src/projection/extract-view-spec.ts +372 -0
  177. package/src/projection/index.ts +4 -0
  178. package/src/projection/projection-detector.ts +26 -0
  179. package/src/projection/view-ddl-emit.ts +66 -0
  180. package/src/projection/view-spec.ts +62 -0
  181. package/src/relation-resolver.ts +87 -0
  182. package/src/render-context.ts +93 -0
  183. package/src/runner.ts +178 -0
  184. package/src/templates/barrel.ts +23 -0
  185. package/src/templates/drizzle-schema.ts +286 -0
  186. package/src/templates/entity-constants.ts +248 -0
  187. package/src/templates/entity-file.ts +51 -0
  188. package/src/templates/field-meta.ts +150 -0
  189. package/src/templates/filter-allowlist.ts +104 -0
  190. package/src/templates/filter-shared.ts +30 -0
  191. package/src/templates/filter-type.ts +93 -0
  192. package/src/templates/inferred-types.ts +16 -0
  193. package/src/templates/projection-decl.ts +146 -0
  194. package/src/templates/queries-file.ts +56 -0
  195. package/src/templates/queries.ts +132 -0
  196. package/src/templates/relations-block.ts +65 -0
  197. package/src/templates/routes-file.ts +179 -0
  198. package/src/templates/zod-validators.ts +140 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,0DAA0D;AAE1D,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEtD,0EAA0E;AAC1E,2EAA2E;AAC3E,IAAI,aAAyC,CAAC;AAE9C,SAAS,QAAQ;IACf,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,YAAY,CA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AO,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,uCAAwC,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9E,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { MetaObject, MetaRoot } from "@metaobjectsdev/metadata";
2
+ import type { RenderContext } from "./render-context.js";
3
+ import type { ResolvedGenConfig } from "./metaobjects-config.js";
4
+ export interface EmittedFile {
5
+ /** Path relative to ResolvedGenConfig.outDir. */
6
+ path: string;
7
+ /** Final TypeScript source (formatted by the generator itself). */
8
+ content: string;
9
+ /** Set by the runner from generator.name — generators should not set this. */
10
+ generatedBy?: string;
11
+ }
12
+ export interface GenContext {
13
+ entities: MetaObject[];
14
+ loadedRoot: MetaRoot;
15
+ /** Pre-composed by the runner from generator.filter (returns true when no
16
+ * filter is set). Always call this from helpers; do not call generator.filter
17
+ * directly. */
18
+ matches: (entity: MetaObject) => boolean;
19
+ config: ResolvedGenConfig;
20
+ /** Pre-built by the runner for built-in generators that wrap existing
21
+ * templates. Third-party generators typically don't need this. Always
22
+ * present at run time when invoked via runGen(); optional in the type
23
+ * so tests and custom callers don't need a placeholder. */
24
+ renderContext?: RenderContext;
25
+ warn: (msg: string) => void;
26
+ }
27
+ export interface Generator {
28
+ /** kebab-case identifier; surfaces in diagnostics + drift logs. */
29
+ name: string;
30
+ /** Optional per-entity filter applied via ctx.matches inside generate(). */
31
+ filter?: (entity: MetaObject) => boolean;
32
+ generate: (ctx: GenContext) => EmittedFile[] | Promise<EmittedFile[]>;
33
+ /** Named output target (registry key). Defaults to "default". */
34
+ target?: string;
35
+ /** Marks the generator that produces entity modules — the runner uses its
36
+ * target as the entity-module target for cross-target import resolution. */
37
+ emitsEntityModule?: boolean;
38
+ }
39
+ export type GeneratorFactory<TOpts = void> = TOpts extends void ? () => Generator : (opts?: TOpts) => Generator;
40
+ /** One-file-per-entity convenience. Async-safe. */
41
+ export declare function perEntity(fn: (entity: MetaObject, ctx: GenContext) => EmittedFile | EmittedFile[] | Promise<EmittedFile | EmittedFile[]>): (ctx: GenContext) => Promise<EmittedFile[]>;
42
+ /** Called once with all matching entities. Use for barrels and cross-entity files. */
43
+ export declare function oncePerRun(fn: (entities: MetaObject[], ctx: GenContext) => EmittedFile | EmittedFile[] | Promise<EmittedFile | EmittedFile[]>): (ctx: GenContext) => Promise<EmittedFile[]>;
44
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,WAAW,WAAW;IAC1B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,UAAU,EAAE,QAAQ,CAAC;IACrB;;oBAEgB;IAChB,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;IACzC,MAAM,EAAE,iBAAiB,CAAC;IAC1B;;;gEAG4D;IAC5D,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,SAAS;IACxB,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;IACzC,QAAQ,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACtE,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;iFAC6E;IAC7E,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,gBAAgB,CAAC,KAAK,GAAG,IAAI,IAAI,KAAK,SAAS,IAAI,GAC3D,MAAM,SAAS,GACf,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,SAAS,CAAC;AAEhC,mDAAmD;AACnD,wBAAgB,SAAS,CACvB,EAAE,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,KACpC,WAAW,GACX,WAAW,EAAE,GACb,OAAO,CAAC,WAAW,GAAG,WAAW,EAAE,CAAC,GACvC,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,CAM7C;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CACxB,EAAE,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,UAAU,KACxC,WAAW,GACX,WAAW,EAAE,GACb,OAAO,CAAC,WAAW,GAAG,WAAW,EAAE,CAAC,GACvC,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,CAM7C"}
@@ -0,0 +1,17 @@
1
+ /** One-file-per-entity convenience. Async-safe. */
2
+ export function perEntity(fn) {
3
+ return async (ctx) => {
4
+ const matched = ctx.entities.filter(ctx.matches);
5
+ const results = await Promise.all(matched.map((e) => fn(e, ctx)));
6
+ return results.flatMap((r) => (Array.isArray(r) ? r : [r]));
7
+ };
8
+ }
9
+ /** Called once with all matching entities. Use for barrels and cross-entity files. */
10
+ export function oncePerRun(fn) {
11
+ return async (ctx) => {
12
+ const matched = ctx.entities.filter(ctx.matches);
13
+ const result = await fn(matched, ctx);
14
+ return Array.isArray(result) ? result : [result];
15
+ };
16
+ }
17
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AA8CA,mDAAmD;AACnD,MAAM,UAAU,SAAS,CACvB,EAGwC;IAExC,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE;QACnB,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QAClE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,UAAU,CACxB,EAGwC;IAExC,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE;QACnB,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACtC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type GeneratorFactory } from "../generator.js";
2
+ export interface BarrelOpts {
3
+ target?: string;
4
+ }
5
+ export declare const barrel: GeneratorFactory<BarrelOpts>;
6
+ //# sourceMappingURL=barrel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../../src/generators/barrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIpF,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,MAAM,EAmBd,gBAAgB,CAAC,UAAU,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { oncePerRun } from "../generator.js";
2
+ import { renderBarrel } from "../templates/barrel.js";
3
+ import { formatTs } from "../format.js";
4
+ export const barrel = function barrel(opts) {
5
+ const generator = {
6
+ name: "barrel",
7
+ generate: oncePerRun(async (entities, ctx) => ({
8
+ path: "index.ts",
9
+ content: await formatTs(renderBarrel(entities.map((e) => ({ name: e.name, package: e.package })), ctx.renderContext.extStyle, ctx.renderContext.selfTarget, ctx.renderContext.entityModuleTarget)),
10
+ })),
11
+ };
12
+ if (opts?.target) {
13
+ generator.target = opts.target;
14
+ }
15
+ return generator;
16
+ };
17
+ //# sourceMappingURL=barrel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"barrel.js","sourceRoot":"","sources":["../../src/generators/barrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyC,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAMxC,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,MAAM,CAAC,IAAiB;IACrD,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YAC7C,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,MAAM,QAAQ,CACrB,YAAY,CACV,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,EAC3D,GAAG,CAAC,aAAc,CAAC,QAAQ,EAC3B,GAAG,CAAC,aAAc,CAAC,UAAU,EAC7B,GAAG,CAAC,aAAc,CAAC,kBAAkB,CACtC,CACF;SACF,CAAC,CAAC;KACJ,CAAC;IACF,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAiC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { MetaObject } from "@metaobjectsdev/metadata";
2
+ import { type GeneratorFactory } from "../generator.js";
3
+ export interface EntityFileOpts {
4
+ filter?: (entity: MetaObject) => boolean;
5
+ target?: string;
6
+ }
7
+ export declare const entityFile: GeneratorFactory<EntityFileOpts>;
8
+ //# sourceMappingURL=entity-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-file.d.ts","sourceRoot":"","sources":["../../src/generators/entity-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKnF,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,UAAU,EAqBlB,gBAAgB,CAAC,cAAc,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { perEntity } from "../generator.js";
2
+ import { renderEntityFile } from "../templates/entity-file.js";
3
+ import { formatTs } from "../format.js";
4
+ import { entityOutputPath } from "../import-path.js";
5
+ export const entityFile = function entityFile(opts) {
6
+ const generator = {
7
+ name: "entity-file",
8
+ emitsEntityModule: true,
9
+ generate: perEntity(async (entity, ctx) => {
10
+ if (!ctx.renderContext) {
11
+ throw new Error("entity-file: renderContext is required (provided by runGen)");
12
+ }
13
+ return {
14
+ path: entityOutputPath(ctx.config.outputLayout ?? "flat", entity.package, `${entity.name}.ts`),
15
+ content: await formatTs(renderEntityFile(entity, ctx.renderContext)),
16
+ };
17
+ }),
18
+ };
19
+ if (opts?.filter) {
20
+ generator.filter = opts.filter;
21
+ }
22
+ if (opts?.target) {
23
+ generator.target = opts.target;
24
+ }
25
+ return generator;
26
+ };
27
+ //# sourceMappingURL=entity-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-file.js","sourceRoot":"","sources":["../../src/generators/entity-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAyC,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOrD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,UAAU,CAAC,IAAqB;IACjE,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,aAAa;QACnB,iBAAiB,EAAE,IAAI;QACvB,QAAQ,EAAE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;YACxC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;YACjF,CAAC;YACD,OAAO;gBACL,IAAI,EAAE,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,KAAK,CAAC;gBAC9F,OAAO,EAAE,MAAM,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;aACrE,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,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAqC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { entityFile, type EntityFileOpts } from "./entity-file.js";
2
+ export { queriesFile, type QueriesFileOpts } from "./queries-file.js";
3
+ export { routesFile, type RoutesFileOpts } from "./routes-file.js";
4
+ export { barrel, type BarrelOpts } from "./barrel.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { entityFile } from "./entity-file.js";
2
+ export { queriesFile } from "./queries-file.js";
3
+ export { routesFile } from "./routes-file.js";
4
+ export { barrel } from "./barrel.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAwB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAuB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAmB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { MetaObject } from "@metaobjectsdev/metadata";
2
+ import { type GeneratorFactory } from "../generator.js";
3
+ export interface QueriesFileOpts {
4
+ filter?: (entity: MetaObject) => boolean;
5
+ target?: string;
6
+ }
7
+ export declare const queriesFile: GeneratorFactory<QueriesFileOpts>;
8
+ //# sourceMappingURL=queries-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries-file.d.ts","sourceRoot":"","sources":["../../src/generators/queries-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,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;AAED,eAAO,MAAM,WAAW,EAoBnB,gBAAgB,CAAC,eAAe,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { perEntity } from "../generator.js";
2
+ import { renderQueriesFile } from "../templates/queries-file.js";
3
+ import { formatTs } from "../format.js";
4
+ import { entityOutputPath } from "../import-path.js";
5
+ export const queriesFile = function queriesFile(opts) {
6
+ const generator = {
7
+ name: "queries-file",
8
+ generate: perEntity(async (entity, ctx) => {
9
+ if (!ctx.renderContext) {
10
+ throw new Error("queries-file: renderContext is required (provided by runGen)");
11
+ }
12
+ return {
13
+ path: entityOutputPath(ctx.config.outputLayout ?? "flat", entity.package, `${entity.name}.queries.ts`),
14
+ content: await formatTs(renderQueriesFile(entity, ctx.renderContext)),
15
+ };
16
+ }),
17
+ };
18
+ if (opts?.filter) {
19
+ generator.filter = opts.filter;
20
+ }
21
+ if (opts?.target) {
22
+ generator.target = opts.target;
23
+ }
24
+ return generator;
25
+ };
26
+ //# sourceMappingURL=queries-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries-file.js","sourceRoot":"","sources":["../../src/generators/queries-file.ts"],"names":[],"mappings":"AACA,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,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,WAAW,CAAC,IAAsB;IACpE,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,cAAc;QACpB,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,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,12 @@
1
+ import type { MetaObject } from "@metaobjectsdev/metadata";
2
+ import { type GeneratorFactory } from "../generator.js";
3
+ export interface RoutesFileOpts {
4
+ filter?: (entity: MetaObject) => boolean;
5
+ target?: string;
6
+ }
7
+ /**
8
+ * Per-entity opt-out via `@emitRoutes: false` is honored. If the user supplies
9
+ * their own filter, both must pass (AND).
10
+ */
11
+ export declare const routesFile: GeneratorFactory<RoutesFileOpts>;
12
+ //# sourceMappingURL=routes-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes-file.d.ts","sourceRoot":"","sources":["../../src/generators/routes-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKnF,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAoBlB,gBAAgB,CAAC,cAAc,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { perEntity } from "../generator.js";
2
+ import { renderRoutesFile } from "../templates/routes-file.js";
3
+ import { formatTs } from "../format.js";
4
+ import { entityOutputPath } from "../import-path.js";
5
+ /**
6
+ * Per-entity opt-out via `@emitRoutes: false` is honored. If the user supplies
7
+ * their own filter, both must pass (AND).
8
+ */
9
+ export const routesFile = function routesFile(opts) {
10
+ const userFilter = opts?.filter ?? (() => true);
11
+ const generator = {
12
+ name: "routes-file",
13
+ // Always set: AND-composes metadata opt-out with optional user filter.
14
+ filter: (e) => e.ownAttr("emitRoutes") !== false && userFilter(e),
15
+ generate: perEntity(async (entity, ctx) => {
16
+ if (!ctx.renderContext) {
17
+ throw new Error("routes-file: renderContext is required (provided by runGen)");
18
+ }
19
+ return {
20
+ path: entityOutputPath(ctx.config.outputLayout ?? "flat", entity.package, `${entity.name}.routes.ts`),
21
+ content: await formatTs(renderRoutesFile(entity, ctx.renderContext)),
22
+ };
23
+ }),
24
+ };
25
+ if (opts?.target) {
26
+ generator.target = opts.target;
27
+ }
28
+ return generator;
29
+ };
30
+ //# sourceMappingURL=routes-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes-file.js","sourceRoot":"","sources":["../../src/generators/routes-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAyC,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOrD;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,UAAU,CAAC,IAAqB;IACjE,MAAM,UAAU,GAAG,IAAI,EAAE,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,aAAa;QACnB,uEAAuE;QACvE,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,6DAA6D,CAAC,CAAC;YACjF,CAAC;YACD,OAAO;gBACL,IAAI,EAAE,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,YAAY,CAAC;gBACrG,OAAO,EAAE,MAAM,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;aACrE,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,CAAqC,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { type ExtStyle } from "./render-context.js";
2
+ export type OutputLayout = "flat" | "package";
3
+ /** "a::b::c" → "a/b/c"; undefined / "" → "". */
4
+ export declare function packageToPath(pkg: string | undefined): string;
5
+ /** Output path (relative to outDir) for an entity's generated file. */
6
+ export declare function entityOutputPath(layout: OutputLayout, pkg: string | undefined, filename: string): string;
7
+ /** Module specifier to import `toEntity` (in `toPkg`) from a file in `fromPkg`.
8
+ * Flat → always "./<toEntity>". */
9
+ export declare function crossEntitySpecifier(layout: OutputLayout, fromPkg: string | undefined, toPkg: string | undefined, toEntity: string, extStyle: ExtStyle): string;
10
+ /** Barrel (at outDir root) re-export specifier for an entity.
11
+ * Equivalent to crossEntitySpecifier with fromPkg=undefined (barrel is always at root). */
12
+ export declare function barrelEntrySpecifier(layout: OutputLayout, pkg: string | undefined, entity: string, extStyle: ExtStyle): string;
13
+ /** A `dbImport` (or any module specifier) adjusted for a file at the given
14
+ * package depth. A non-relative specifier (alias / package) is depth-invariant
15
+ * and returned unchanged; a relative one gets extra "../" per package segment.
16
+ * Caller contract: a relative moduleSpec must be relative to outDir root (as
17
+ * dbImport is). */
18
+ export declare function relativeModuleSpecifier(layout: OutputLayout, pkg: string | undefined, moduleSpec: string): string;
19
+ /** A fully-resolved output destination. Import-identity belongs to the
20
+ * destination, not the generator. */
21
+ export interface ResolvedTarget {
22
+ name: string;
23
+ outDir: string;
24
+ /** Package-specifier prefix others use to import modules produced here.
25
+ * Required only when another target imports from this one. */
26
+ importBase: string | undefined;
27
+ outputLayout: OutputLayout;
28
+ dbImport: string;
29
+ }
30
+ /** Specifier to import entity `entityName` (in `entityPkg`, produced into
31
+ * `entityTarget`) from a file emitted into `selfTarget`. Same target → relative
32
+ * (extStyle honored); cross target → extension-less importBase path. */
33
+ export declare function entityModuleSpecifier(selfTarget: ResolvedTarget, entityTarget: ResolvedTarget, entityPkg: string | undefined, entityName: string, extStyle: ExtStyle): string;
34
+ /** A same-target sibling module (e.g. "<Entity>.columns"). Always relative,
35
+ * package-layout aware, extStyle honored. */
36
+ export declare function siblingSpecifier(selfTarget: ResolvedTarget, entityPkg: string | undefined, basename: string, extStyle: ExtStyle): string;
37
+ /** Barrel re-export specifier. Barrel sits at its target root, so same-target
38
+ * uses fromPkg=undefined (barrelEntrySpecifier); cross-target is the
39
+ * extension-less importBase path. */
40
+ export declare function barrelModuleSpecifier(selfTarget: ResolvedTarget, entityTarget: ResolvedTarget, entityPkg: string | undefined, entityName: string, extStyle: ExtStyle): string;
41
+ //# sourceMappingURL=import-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-path.d.ts","sourceRoot":"","sources":["../src/import-path.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;AAE9C,gDAAgD;AAChD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG7D;AAED,uEAAuE;AACvE,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,EAAE,MAAM,GACf,MAAM,CAIR;AAWD;oCACoC;AACpC,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAIR;AAED;4FAC4F;AAC5F,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAER;AAED;;;;oBAIoB;AACpB,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,UAAU,EAAE,MAAM,GACjB,MAAM,CASR;AAED;sCACsC;AACtC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf;mEAC+D;IAC/D,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAmBD;;yEAEyE;AACzE,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,cAAc,EAC1B,YAAY,EAAE,cAAc,EAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAKR;AAED;8CAC8C;AAC9C,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,cAAc,EAC1B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAER;AAED;;sCAEsC;AACtC,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,cAAc,EAC1B,YAAY,EAAE,cAAc,EAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAKR"}
@@ -0,0 +1,95 @@
1
+ // Package-driven output placement — path + import-specifier computation.
2
+ // In "flat" mode every function returns exactly today's value, so flat
3
+ // output is byte-identical. See
4
+ // docs/superpowers/specs/2026-05-18-phase4d-package-output-placement-design.md.
5
+ import { relative as posixRelative } from "node:path/posix";
6
+ import { PACKAGE_SEPARATOR } from "@metaobjectsdev/metadata";
7
+ import { withExt } from "./render-context.js";
8
+ /** "a::b::c" → "a/b/c"; undefined / "" → "". */
9
+ export function packageToPath(pkg) {
10
+ if (pkg === undefined || pkg === "")
11
+ return "";
12
+ return pkg.split(PACKAGE_SEPARATOR).join("/");
13
+ }
14
+ /** Output path (relative to outDir) for an entity's generated file. */
15
+ export function entityOutputPath(layout, pkg, filename) {
16
+ if (layout === "flat")
17
+ return filename;
18
+ const dir = packageToPath(pkg);
19
+ return dir === "" ? filename : `${dir}/${filename}`;
20
+ }
21
+ /** Relative dir prefix (ending in "/") from `fromDir` to `toDir`, both
22
+ * POSIX paths relative to outDir. Same dir → "./". */
23
+ function relativeDirPrefix(fromDir, toDir) {
24
+ let rel = posixRelative(fromDir, toDir);
25
+ if (rel === "")
26
+ rel = ".";
27
+ if (!rel.startsWith("."))
28
+ rel = `./${rel}`;
29
+ return `${rel}/`;
30
+ }
31
+ /** Module specifier to import `toEntity` (in `toPkg`) from a file in `fromPkg`.
32
+ * Flat → always "./<toEntity>". */
33
+ export function crossEntitySpecifier(layout, fromPkg, toPkg, toEntity, extStyle) {
34
+ if (layout === "flat")
35
+ return withExt(`./${toEntity}`, extStyle);
36
+ const prefix = relativeDirPrefix(packageToPath(fromPkg), packageToPath(toPkg));
37
+ return withExt(`${prefix}${toEntity}`, extStyle);
38
+ }
39
+ /** Barrel (at outDir root) re-export specifier for an entity.
40
+ * Equivalent to crossEntitySpecifier with fromPkg=undefined (barrel is always at root). */
41
+ export function barrelEntrySpecifier(layout, pkg, entity, extStyle) {
42
+ return crossEntitySpecifier(layout, undefined, pkg, entity, extStyle);
43
+ }
44
+ /** A `dbImport` (or any module specifier) adjusted for a file at the given
45
+ * package depth. A non-relative specifier (alias / package) is depth-invariant
46
+ * and returned unchanged; a relative one gets extra "../" per package segment.
47
+ * Caller contract: a relative moduleSpec must be relative to outDir root (as
48
+ * dbImport is). */
49
+ export function relativeModuleSpecifier(layout, pkg, moduleSpec) {
50
+ if (layout === "flat")
51
+ return moduleSpec;
52
+ const isRelative = moduleSpec.startsWith("./") || moduleSpec.startsWith("../");
53
+ if (!isRelative)
54
+ return moduleSpec;
55
+ const dir = packageToPath(pkg);
56
+ const depth = dir === "" ? 0 : dir.split("/").length;
57
+ if (depth === 0)
58
+ return moduleSpec;
59
+ const extra = "../".repeat(depth);
60
+ return moduleSpec.startsWith("./") ? extra + moduleSpec.slice(2) : extra + moduleSpec;
61
+ }
62
+ /** importBase + (package path when package layout) + entity, extension-less. */
63
+ function crossTargetEntityPath(entityTarget, entityPkg, entityName) {
64
+ const base = entityTarget.importBase;
65
+ if (base === undefined) {
66
+ throw new Error(`Cannot emit cross-target import: target "${entityTarget.name}" has no importBase. ` +
67
+ `Set importBase on the target that holds the entity modules.`);
68
+ }
69
+ const pkgPath = entityTarget.outputLayout === "package" ? packageToPath(entityPkg) : "";
70
+ return pkgPath === "" ? `${base}/${entityName}` : `${base}/${pkgPath}/${entityName}`;
71
+ }
72
+ /** Specifier to import entity `entityName` (in `entityPkg`, produced into
73
+ * `entityTarget`) from a file emitted into `selfTarget`. Same target → relative
74
+ * (extStyle honored); cross target → extension-less importBase path. */
75
+ export function entityModuleSpecifier(selfTarget, entityTarget, entityPkg, entityName, extStyle) {
76
+ if (selfTarget.name === entityTarget.name) {
77
+ return crossEntitySpecifier(entityTarget.outputLayout, entityPkg, entityPkg, entityName, extStyle);
78
+ }
79
+ return crossTargetEntityPath(entityTarget, entityPkg, entityName);
80
+ }
81
+ /** A same-target sibling module (e.g. "<Entity>.columns"). Always relative,
82
+ * package-layout aware, extStyle honored. */
83
+ export function siblingSpecifier(selfTarget, entityPkg, basename, extStyle) {
84
+ return crossEntitySpecifier(selfTarget.outputLayout, entityPkg, entityPkg, basename, extStyle);
85
+ }
86
+ /** Barrel re-export specifier. Barrel sits at its target root, so same-target
87
+ * uses fromPkg=undefined (barrelEntrySpecifier); cross-target is the
88
+ * extension-less importBase path. */
89
+ export function barrelModuleSpecifier(selfTarget, entityTarget, entityPkg, entityName, extStyle) {
90
+ if (selfTarget.name === entityTarget.name) {
91
+ return barrelEntrySpecifier(entityTarget.outputLayout, entityPkg, entityName, extStyle);
92
+ }
93
+ return crossTargetEntityPath(entityTarget, entityPkg, entityName);
94
+ }
95
+ //# sourceMappingURL=import-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-path.js","sourceRoot":"","sources":["../src/import-path.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,uEAAuE;AACvE,gCAAgC;AAChC,gFAAgF;AAEhF,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAiB,MAAM,qBAAqB,CAAC;AAI7D,gDAAgD;AAChD,MAAM,UAAU,aAAa,CAAC,GAAuB;IACnD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC/C,OAAO,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,gBAAgB,CAC9B,MAAoB,EACpB,GAAuB,EACvB,QAAgB;IAEhB,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,QAAQ,CAAC;IACvC,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,QAAQ,EAAE,CAAC;AACtD,CAAC;AAED;uDACuD;AACvD,SAAS,iBAAiB,CAAC,OAAe,EAAE,KAAa;IACvD,IAAI,GAAG,GAAG,aAAa,CAAC,OAAO,EAAE,KA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AqB,CAAC,YAAY,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC;AAED;8CAC8C;AAC9C,MAAM,UAAU,gBAAgB,CAC9B,UAA0B,EAC1B,SAA6B,EAC7B,QAAgB,EAChB,QAAkB;IAElB,OAAO,oBAAoB,CAAC,UAAU,CAAC,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACjG,CAAC;AAED;;sCAEsC;AACtC,MAAM,UAAU,qBAAqB,CACnC,UAA0B,EAC1B,YAA4B,EAC5B,SAA6B,EAC7B,UAAkB,EAClB,QAAkB;IAElB,IAAI,UAAU,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,EAAE,CAAC;QAC1C,OAAO,oBAAoB,CAAC,YAAY,CAAC,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,qBAAqB,CAAC,YAAY,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC"}
@@ -0,0 +1,29 @@
1
+ export { runGen } from "./runner.js";
2
+ export type { RunGenOpts, RunGenResult } from "./runner.js";
3
+ export type { Generator, GenContext, EmittedFile, GeneratorFactory } from "./generator.js";
4
+ export { perEntity, oncePerRun } from "./generator.js";
5
+ export type { MetaobjectsGenConfig, NormalizedMetaobjectsGenConfig, ResolvedGenConfig, Dialect, ExtStyle, ColumnNamingStrategy } from "./metaobjects-config.js";
6
+ export { defineConfig, normalizeConfig } from "./metaobjects-config.js";
7
+ export type { ColumnSpec, DefaultExpr } from "./column-mapper.js";
8
+ export { mapColumnType } from "./column-mapper.js";
9
+ export type { PkInfo } from "./pk-resolver.js";
10
+ export { buildPkMap } from "./pk-resolver.js";
11
+ export type { RelationEntry, RelationMap } from "./relation-resolver.js";
12
+ export { buildRelationMap } from "./relation-resolver.js";
13
+ export type { RenderContext } from "./render-context.js";
14
+ export { makeRenderContext } from "./render-context.js";
15
+ export type { WriteStatus, WriteResult, MergeStrategy } from "./overwrite-policy.js";
16
+ export { decideAndWrite } from "./overwrite-policy.js";
17
+ export { CodegenError } from "./errors.js";
18
+ export { GENERATED_HEADER, EXTRA_SUFFIX, DEFAULT_OUT_DIR } from "./constants.js";
19
+ export { formatTs } from "./format.js";
20
+ export { pluralize, columnNameFromField, tableNameFromEntity, viewNameFromProjection } from "./naming.js";
21
+ export { packageToPath, entityOutputPath, crossEntitySpecifier, barrelEntrySpecifier, relativeModuleSpecifier, entityModuleSpecifier, siblingSpecifier, barrelModuleSpecifier } from "./import-path.js";
22
+ export type { OutputLayout, ResolvedTarget } from "./import-path.js";
23
+ export { isProjection, isWriteThrough } from "./projection/projection-detector.js";
24
+ export { extractViewSpec } from "./projection/extract-view-spec.js";
25
+ export type { ExtractContext } from "./projection/extract-view-spec.js";
26
+ export { emitViewDdl } from "./projection/view-ddl-emit.js";
27
+ export type { EmitOptions as ViewDdlEmitOptions } from "./projection/view-ddl-emit.js";
28
+ export type { JoinNode, JoinTree, SelectColumn, SelectSpec, ViewSpec } from "./projection/view-spec.js";
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;AAChK,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AA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W,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"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ // Public API surface for @metaobjectsdev/codegen-ts.
2
+ //
3
+ // Architecture: Vite-style plugin model.
4
+ // See docs/superpowers/specs/2026-05-12-pluggable-generators-design.md.
5
+ export { runGen } from "./runner.js";
6
+ export { perEntity, oncePerRun } from "./generator.js";
7
+ export { defineConfig, normalizeConfig } from "./metaobjects-config.js";
8
+ export { mapColumnType } from "./column-mapper.js";
9
+ export { buildPkMap } from "./pk-resolver.js";
10
+ export { buildRelationMap } from "./relation-resolver.js";
11
+ export { makeRenderContext } from "./render-context.js";
12
+ export { decideAndWrite } from "./overwrite-policy.js";
13
+ export { CodegenError } from "./errors.js";
14
+ export { GENERATED_HEADER, EXTRA_SUFFIX, DEFAULT_OUT_DIR } from "./constants.js";
15
+ export { formatTs } from "./format.js";
16
+ export { pluralize, columnNameFromField, tableNameFromEntity, viewNameFromProjection } from "./naming.js";
17
+ export { packageToPath, entityOutputPath, crossEntitySpecifier, barrelEntrySpecifier, relativeModuleSpecifier, entityModuleSpecifier, siblingSpecifier, barrelModuleSpecifier } from "./import-path.js";
18
+ export { isProjection, isWriteThrough } from "./projection/projection-detector.js";
19
+ export { extractViewSpec } from "./projection/extract-view-spec.js";
20
+ export { emitViewDdl } from "./projection/view-ddl-emit.js";
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,yCAAyC;AACzC,wEAAwE;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAGxE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,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;AAGxM,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { Generator } from "./generator.js";
2
+ import type { ExtStyle } from "./render-context.js";
3
+ import type { OutputLayout, ResolvedTarget } from "./import-path.js";
4
+ export type Dialect = "sqlite" | "postgres";
5
+ export type ColumnNamingStrategy = "snake_case" | "literal" | "kebab-case";
6
+ export type { ExtStyle };
7
+ export type { OutputLayout };
8
+ export type { ResolvedTarget };
9
+ /** The implicit target synthesized from top-level config (outDir/outputLayout/dbImport). */
10
+ export declare const DEFAULT_TARGET_NAME = "default";
11
+ /** User-facing per-target output config. */
12
+ export interface TargetConfig {
13
+ outDir: string;
14
+ importBase?: string;
15
+ outputLayout?: OutputLayout;
16
+ dbImport?: string;
17
+ }
18
+ /** Subset of MetaobjectsGenConfig surfaced to generators via GenContext. */
19
+ export interface ResolvedGenConfig {
20
+ outDir: string;
21
+ extStyle: ExtStyle;
22
+ dbImport: string;
23
+ dialect: Dialect;
24
+ /** "flat" (default) — all files in outDir; "package" — files placed in a sub-path derived from each entity's metadata package. */
25
+ outputLayout?: OutputLayout;
26
+ }
27
+ export interface MetaobjectsGenConfig extends ResolvedGenConfig {
28
+ generators: Generator[];
29
+ /** How field names map to DB column names when @dbColumn is omitted. Defaults to "snake_case". */
30
+ columnNamingStrategy?: ColumnNamingStrategy;
31
+ /** Path prefix applied to generated route registrations + hook fetch URLs. Defaults to "". */
32
+ apiPrefix?: string;
33
+ /** Named output destinations. Generators reference one via `target`. */
34
+ targets?: Record<string, TargetConfig>;
35
+ /** importBase for the default target (top-level outDir). */
36
+ importBase?: string;
37
+ }
38
+ /** MetaobjectsGenConfig after applying defaults. All fields required.
39
+ * `targets` is Omitted from the base so it can narrow from the user-facing
40
+ * TargetConfig to the fully-resolved ResolvedTarget (incompatible under
41
+ * exactOptionalPropertyTypes otherwise). */
42
+ export interface NormalizedMetaobjectsGenConfig extends Omit<MetaobjectsGenConfig, "targets"> {
43
+ columnNamingStrategy: ColumnNamingStrategy;
44
+ apiPrefix: string;
45
+ outputLayout: OutputLayout;
46
+ targets: Record<string, ResolvedTarget>;
47
+ }
48
+ /** Identity passthrough; exists for IDE type-inference + autocomplete. */
49
+ export declare function defineConfig(config: MetaobjectsGenConfig): MetaobjectsGenConfig;
50
+ /** Synthesize the implicit "default" target from top-level fields and resolve
51
+ * each named target (outputLayout + dbImport fall back to top-level;
52
+ * importBase does NOT inherit — it is a per-target identity). */
53
+ export declare function resolveTargets(config: MetaobjectsGenConfig): Record<string, ResolvedTarget>;
54
+ /** Apply defaults to a MetaobjectsGenConfig, returning a NormalizedMetaobjectsGenConfig. */
55
+ export declare function normalizeConfig(config: MetaobjectsGenConfig): NormalizedMetaobjectsGenConfig;
56
+ //# sourceMappingURL=metaobjects-config.d.ts.map
@@ -0,0 +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;AAErE,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;AAC5C,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,CAAC;AAC3E,YAAY,EAAE,QAAQ,EAAE,CAAC;AACzB,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,4FAA4F;AAC5F,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAE7C,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,4EAA4E;AAC5E,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,kIAAkI;IAClI,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,kGAAkG;IAClG,oBAAoB,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;CACrB;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"}
@@ -0,0 +1,42 @@
1
+ /** The implicit target synthesized from top-level config (outDir/outputLayout/dbImport). */
2
+ export const DEFAULT_TARGET_NAME = "default";
3
+ /** Identity passthrough; exists for IDE type-inference + autocomplete. */
4
+ export function defineConfig(config) {
5
+ return config;
6
+ }
7
+ /** Synthesize the implicit "default" target from top-level fields and resolve
8
+ * each named target (outputLayout + dbImport fall back to top-level;
9
+ * importBase does NOT inherit — it is a per-target identity). */
10
+ export function resolveTargets(config) {
11
+ const layout = config.outputLayout ?? "flat";
12
+ const out = {
13
+ [DEFAULT_TARGET_NAME]: {
14
+ name: DEFAULT_TARGET_NAME,
15
+ outDir: config.outDir,
16
+ importBase: config.importBase,
17
+ outputLayout: layout,
18
+ dbImport: config.dbImport,
19
+ },
20
+ };
21
+ for (const [name, t] of Object.entries(config.targets ?? {})) {
22
+ out[name] = {
23
+ name,
24
+ outDir: t.outDir,
25
+ importBase: t.importBase,
26
+ outputLayout: t.outputLayout ?? layout,
27
+ dbImport: t.dbImport ?? config.dbImport,
28
+ };
29
+ }
30
+ return out;
31
+ }
32
+ /** Apply defaults to a MetaobjectsGenConfig, returning a NormalizedMetaobjectsGenConfig. */
33
+ export function normalizeConfig(config) {
34
+ return {
35
+ ...config,
36
+ columnNamingStrategy: config.columnNamingStrategy ?? "snake_case",
37
+ apiPrefix: config.apiPrefix ?? "",
38
+ outputLayout: config.outputLayout ?? "flat",
39
+ targets: resolveTargets(config),
40
+ };
41
+ }
42
+ //# sourceMappingURL=metaobjects-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metaobjects-config.js","sourceRoot":"","sources":["../src/metaobjects-config.ts"],"names":[],"mappings":"AAUA,4FAA4F;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AA2C7C,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,C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