@metaobjectsdev/codegen-ts 0.9.0 → 0.11.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 (342) hide show
  1. package/README.md +1 -1
  2. package/dist/column-mapper.d.ts +12 -6
  3. package/dist/column-mapper.d.ts.map +1 -1
  4. package/dist/column-mapper.js +68 -28
  5. package/dist/column-mapper.js.map +1 -1
  6. package/dist/constants.d.ts +8 -0
  7. package/dist/constants.d.ts.map +1 -1
  8. package/dist/constants.js +16 -0
  9. package/dist/constants.js.map +1 -1
  10. package/dist/docs-paths.d.ts +58 -0
  11. package/dist/docs-paths.d.ts.map +1 -0
  12. package/dist/docs-paths.js +89 -0
  13. package/dist/docs-paths.js.map +1 -0
  14. package/dist/enum-import.d.ts +14 -0
  15. package/dist/enum-import.d.ts.map +1 -0
  16. package/dist/enum-import.js +35 -0
  17. package/dist/enum-import.js.map +1 -0
  18. package/dist/enum-shared.d.ts +32 -0
  19. package/dist/enum-shared.d.ts.map +1 -0
  20. package/dist/enum-shared.js +83 -0
  21. package/dist/enum-shared.js.map +1 -0
  22. package/dist/generator-registry.d.ts +22 -0
  23. package/dist/generator-registry.d.ts.map +1 -0
  24. package/dist/generator-registry.js +161 -0
  25. package/dist/generator-registry.js.map +1 -0
  26. package/dist/generator.d.ts +6 -0
  27. package/dist/generator.d.ts.map +1 -1
  28. package/dist/generator.js.map +1 -1
  29. package/dist/generators/api-doc-render.d.ts +17 -0
  30. package/dist/generators/api-doc-render.d.ts.map +1 -0
  31. package/dist/generators/api-doc-render.js +431 -0
  32. package/dist/generators/api-doc-render.js.map +1 -0
  33. package/dist/generators/api-docs-file.d.ts +21 -0
  34. package/dist/generators/api-docs-file.d.ts.map +1 -0
  35. package/dist/generators/api-docs-file.js +112 -0
  36. package/dist/generators/api-docs-file.js.map +1 -0
  37. package/dist/generators/api-field-shape.d.ts +39 -0
  38. package/dist/generators/api-field-shape.d.ts.map +1 -0
  39. package/dist/generators/api-field-shape.js +92 -0
  40. package/dist/generators/api-field-shape.js.map +1 -0
  41. package/dist/generators/api-label.d.ts +3 -0
  42. package/dist/generators/api-label.d.ts.map +1 -0
  43. package/dist/generators/api-label.js +8 -0
  44. package/dist/generators/api-label.js.map +1 -0
  45. package/dist/generators/api-model.d.ts +122 -0
  46. package/dist/generators/api-model.d.ts.map +1 -0
  47. package/dist/generators/api-model.js +809 -0
  48. package/dist/generators/api-model.js.map +1 -0
  49. package/dist/generators/docs-data-builder.d.ts +26 -4
  50. package/dist/generators/docs-data-builder.d.ts.map +1 -1
  51. package/dist/generators/docs-data-builder.js +439 -167
  52. package/dist/generators/docs-data-builder.js.map +1 -1
  53. package/dist/generators/docs-data.d.ts +136 -27
  54. package/dist/generators/docs-data.d.ts.map +1 -1
  55. package/dist/generators/docs-data.js +1 -1
  56. package/dist/generators/docs-data.js.map +1 -1
  57. package/dist/generators/docs-file.d.ts +19 -0
  58. package/dist/generators/docs-file.d.ts.map +1 -1
  59. package/dist/generators/docs-file.js +154 -27
  60. package/dist/generators/docs-file.js.map +1 -1
  61. package/dist/generators/entity-file.d.ts.map +1 -1
  62. package/dist/generators/entity-file.js +29 -14
  63. package/dist/generators/entity-file.js.map +1 -1
  64. package/dist/generators/extractor-file.d.ts.map +1 -1
  65. package/dist/generators/extractor-file.js +2 -1
  66. package/dist/generators/extractor-file.js.map +1 -1
  67. package/dist/generators/field-anchor.d.ts +7 -0
  68. package/dist/generators/field-anchor.d.ts.map +1 -0
  69. package/dist/generators/field-anchor.js +23 -0
  70. package/dist/generators/field-anchor.js.map +1 -0
  71. package/dist/generators/index.d.ts +8 -1
  72. package/dist/generators/index.d.ts.map +1 -1
  73. package/dist/generators/index.js +6 -0
  74. package/dist/generators/index.js.map +1 -1
  75. package/dist/generators/mermaid-er.d.ts +14 -0
  76. package/dist/generators/mermaid-er.d.ts.map +1 -1
  77. package/dist/generators/mermaid-er.js +14 -0
  78. package/dist/generators/mermaid-er.js.map +1 -1
  79. package/dist/generators/output-parser-file.d.ts.map +1 -1
  80. package/dist/generators/output-parser-file.js +3 -4
  81. package/dist/generators/output-parser-file.js.map +1 -1
  82. package/dist/generators/output-prompt-file.d.ts.map +1 -1
  83. package/dist/generators/output-prompt-file.js +2 -2
  84. package/dist/generators/output-prompt-file.js.map +1 -1
  85. package/dist/generators/prompt-render-file.d.ts.map +1 -1
  86. package/dist/generators/prompt-render-file.js +3 -4
  87. package/dist/generators/prompt-render-file.js.map +1 -1
  88. package/dist/generators/queries-file.d.ts.map +1 -1
  89. package/dist/generators/queries-file.js +8 -3
  90. package/dist/generators/queries-file.js.map +1 -1
  91. package/dist/generators/render-helper-file.d.ts.map +1 -1
  92. package/dist/generators/render-helper-file.js +2 -2
  93. package/dist/generators/render-helper-file.js.map +1 -1
  94. package/dist/generators/routes-file-hono.d.ts.map +1 -1
  95. package/dist/generators/routes-file-hono.js +5 -1
  96. package/dist/generators/routes-file-hono.js.map +1 -1
  97. package/dist/generators/routes-file.d.ts +3 -0
  98. package/dist/generators/routes-file.d.ts.map +1 -1
  99. package/dist/generators/routes-file.js +6 -1
  100. package/dist/generators/routes-file.js.map +1 -1
  101. package/dist/generators/template-doc-builder.d.ts +19 -0
  102. package/dist/generators/template-doc-builder.d.ts.map +1 -0
  103. package/dist/generators/template-doc-builder.js +220 -0
  104. package/dist/generators/template-doc-builder.js.map +1 -0
  105. package/dist/generators/template-doc-data.d.ts +62 -0
  106. package/dist/generators/template-doc-data.d.ts.map +1 -0
  107. package/dist/generators/template-doc-data.js +16 -0
  108. package/dist/generators/template-doc-data.js.map +1 -0
  109. package/dist/generators/template-payload-tree.d.ts +15 -0
  110. package/dist/generators/template-payload-tree.d.ts.map +1 -0
  111. package/dist/generators/template-payload-tree.js +61 -0
  112. package/dist/generators/template-payload-tree.js.map +1 -0
  113. package/dist/generators/template-source-annotate.d.ts +74 -0
  114. package/dist/generators/template-source-annotate.d.ts.map +1 -0
  115. package/dist/generators/template-source-annotate.js +184 -0
  116. package/dist/generators/template-source-annotate.js.map +1 -0
  117. package/dist/generators/template-source-render.d.ts +24 -0
  118. package/dist/generators/template-source-render.d.ts.map +1 -0
  119. package/dist/generators/template-source-render.js +175 -0
  120. package/dist/generators/template-source-render.js.map +1 -0
  121. package/dist/generators/trace-helper-file.d.ts +9 -0
  122. package/dist/generators/trace-helper-file.d.ts.map +1 -0
  123. package/dist/generators/trace-helper-file.js +196 -0
  124. package/dist/generators/trace-helper-file.js.map +1 -0
  125. package/dist/import-path.d.ts +18 -0
  126. package/dist/import-path.d.ts.map +1 -1
  127. package/dist/import-path.js +21 -0
  128. package/dist/import-path.js.map +1 -1
  129. package/dist/index.d.ts +29 -4
  130. package/dist/index.d.ts.map +1 -1
  131. package/dist/index.js +28 -2
  132. package/dist/index.js.map +1 -1
  133. package/dist/metaobjects-config.d.ts +101 -2
  134. package/dist/metaobjects-config.d.ts.map +1 -1
  135. package/dist/metaobjects-config.js +46 -0
  136. package/dist/metaobjects-config.js.map +1 -1
  137. package/dist/naming.d.ts +39 -2
  138. package/dist/naming.d.ts.map +1 -1
  139. package/dist/naming.js +52 -3
  140. package/dist/naming.js.map +1 -1
  141. package/dist/payload-codegen.d.ts.map +1 -1
  142. package/dist/payload-codegen.js +14 -6
  143. package/dist/payload-codegen.js.map +1 -1
  144. package/dist/pk-resolver.d.ts.map +1 -1
  145. package/dist/pk-resolver.js +4 -2
  146. package/dist/pk-resolver.js.map +1 -1
  147. package/dist/projection/extract-view-spec.d.ts.map +1 -1
  148. package/dist/projection/extract-view-spec.js +52 -26
  149. package/dist/projection/extract-view-spec.js.map +1 -1
  150. package/dist/relation-resolver.d.ts +16 -0
  151. package/dist/relation-resolver.d.ts.map +1 -1
  152. package/dist/relation-resolver.js +82 -1
  153. package/dist/relation-resolver.js.map +1 -1
  154. package/dist/render-context.d.ts +25 -2
  155. package/dist/render-context.d.ts.map +1 -1
  156. package/dist/render-context.js +7 -0
  157. package/dist/render-context.js.map +1 -1
  158. package/dist/render-engine/embedded-templates.generated.d.ts +2 -0
  159. package/dist/render-engine/embedded-templates.generated.d.ts.map +1 -0
  160. package/dist/render-engine/embedded-templates.generated.js +15 -0
  161. package/dist/render-engine/embedded-templates.generated.js.map +1 -0
  162. package/dist/render-engine/framework-provider.d.ts.map +1 -1
  163. package/dist/render-engine/framework-provider.js +26 -13
  164. package/dist/render-engine/framework-provider.js.map +1 -1
  165. package/dist/runner.d.ts.map +1 -1
  166. package/dist/runner.js +20 -0
  167. package/dist/runner.js.map +1 -1
  168. package/dist/templates/docs-file.d.ts +2 -6
  169. package/dist/templates/docs-file.d.ts.map +1 -1
  170. package/dist/templates/docs-file.js +2 -5
  171. package/dist/templates/docs-file.js.map +1 -1
  172. package/dist/templates/drizzle-schema.d.ts.map +1 -1
  173. package/dist/templates/drizzle-schema.js +72 -23
  174. package/dist/templates/drizzle-schema.js.map +1 -1
  175. package/dist/templates/entity-constants.d.ts +7 -0
  176. package/dist/templates/entity-constants.d.ts.map +1 -1
  177. package/dist/templates/entity-constants.js +3 -3
  178. package/dist/templates/entity-constants.js.map +1 -1
  179. package/dist/templates/entity-file.d.ts.map +1 -1
  180. package/dist/templates/entity-file.js +16 -5
  181. package/dist/templates/entity-file.js.map +1 -1
  182. package/dist/templates/enums-file.d.ts +11 -0
  183. package/dist/templates/enums-file.d.ts.map +1 -0
  184. package/dist/templates/enums-file.js +44 -0
  185. package/dist/templates/enums-file.js.map +1 -0
  186. package/dist/templates/extract-delegate-emitter.d.ts.map +1 -1
  187. package/dist/templates/extract-delegate-emitter.js +6 -8
  188. package/dist/templates/extract-delegate-emitter.js.map +1 -1
  189. package/dist/templates/extractor.d.ts.map +1 -1
  190. package/dist/templates/extractor.js +58 -41
  191. package/dist/templates/extractor.js.map +1 -1
  192. package/dist/templates/field-meta.d.ts.map +1 -1
  193. package/dist/templates/field-meta.js +2 -6
  194. package/dist/templates/field-meta.js.map +1 -1
  195. package/dist/templates/filter-allowlist.d.ts +7 -2
  196. package/dist/templates/filter-allowlist.d.ts.map +1 -1
  197. package/dist/templates/filter-allowlist.js +18 -10
  198. package/dist/templates/filter-allowlist.js.map +1 -1
  199. package/dist/templates/filter-shared.js +2 -2
  200. package/dist/templates/filter-shared.js.map +1 -1
  201. package/dist/templates/filter-type.d.ts +7 -1
  202. package/dist/templates/filter-type.d.ts.map +1 -1
  203. package/dist/templates/filter-type.js +10 -6
  204. package/dist/templates/filter-type.js.map +1 -1
  205. package/dist/templates/find-templates.d.ts +4 -0
  206. package/dist/templates/find-templates.d.ts.map +1 -0
  207. package/dist/templates/find-templates.js +15 -0
  208. package/dist/templates/find-templates.js.map +1 -0
  209. package/dist/templates/fr010-field-mapping.d.ts +2 -0
  210. package/dist/templates/fr010-field-mapping.d.ts.map +1 -1
  211. package/dist/templates/fr010-field-mapping.js +15 -11
  212. package/dist/templates/fr010-field-mapping.js.map +1 -1
  213. package/dist/templates/inferred-types.d.ts +44 -7
  214. package/dist/templates/inferred-types.d.ts.map +1 -1
  215. package/dist/templates/inferred-types.js +121 -19
  216. package/dist/templates/inferred-types.js.map +1 -1
  217. package/dist/templates/mermaid-er.d.ts +35 -2
  218. package/dist/templates/mermaid-er.d.ts.map +1 -1
  219. package/dist/templates/mermaid-er.js +174 -7
  220. package/dist/templates/mermaid-er.js.map +1 -1
  221. package/dist/templates/output-format-spec-emitter.js +1 -1
  222. package/dist/templates/output-format-spec-emitter.js.map +1 -1
  223. package/dist/templates/output-parser.d.ts.map +1 -1
  224. package/dist/templates/output-parser.js +31 -80
  225. package/dist/templates/output-parser.js.map +1 -1
  226. package/dist/templates/output-prompt.d.ts.map +1 -1
  227. package/dist/templates/output-prompt.js +2 -2
  228. package/dist/templates/output-prompt.js.map +1 -1
  229. package/dist/templates/queries-file.d.ts.map +1 -1
  230. package/dist/templates/queries-file.js +113 -5
  231. package/dist/templates/queries-file.js.map +1 -1
  232. package/dist/templates/queries.d.ts +7 -2
  233. package/dist/templates/queries.d.ts.map +1 -1
  234. package/dist/templates/queries.js +15 -15
  235. package/dist/templates/queries.js.map +1 -1
  236. package/dist/templates/relations-block.d.ts.map +1 -1
  237. package/dist/templates/relations-block.js +12 -3
  238. package/dist/templates/relations-block.js.map +1 -1
  239. package/dist/templates/render-helper.d.ts.map +1 -1
  240. package/dist/templates/render-helper.js +5 -5
  241. package/dist/templates/render-helper.js.map +1 -1
  242. package/dist/templates/routes-file-hono.d.ts.map +1 -1
  243. package/dist/templates/routes-file-hono.js +1 -2
  244. package/dist/templates/routes-file-hono.js.map +1 -1
  245. package/dist/templates/routes-file.d.ts.map +1 -1
  246. package/dist/templates/routes-file.js +184 -7
  247. package/dist/templates/routes-file.js.map +1 -1
  248. package/dist/templates/tph-discriminator.d.ts +56 -0
  249. package/dist/templates/tph-discriminator.d.ts.map +1 -0
  250. package/dist/templates/tph-discriminator.js +180 -0
  251. package/dist/templates/tph-discriminator.js.map +1 -0
  252. package/dist/templates/value-object-file.d.ts +2 -1
  253. package/dist/templates/value-object-file.d.ts.map +1 -1
  254. package/dist/templates/value-object-file.js +33 -5
  255. package/dist/templates/value-object-file.js.map +1 -1
  256. package/dist/templates/zod-validators.d.ts +65 -2
  257. package/dist/templates/zod-validators.d.ts.map +1 -1
  258. package/dist/templates/zod-validators.js +202 -22
  259. package/dist/templates/zod-validators.js.map +1 -1
  260. package/package.json +103 -34
  261. package/src/column-mapper.ts +79 -32
  262. package/src/constants.ts +18 -0
  263. package/src/docs-paths.ts +128 -0
  264. package/src/enum-import.ts +43 -0
  265. package/src/enum-shared.ts +95 -0
  266. package/src/generator-registry.ts +204 -0
  267. package/src/generator.ts +6 -0
  268. package/src/generators/api-doc-render.ts +572 -0
  269. package/src/generators/api-docs-file.ts +146 -0
  270. package/src/generators/api-field-shape.ts +114 -0
  271. package/src/generators/api-label.ts +7 -0
  272. package/src/generators/api-model.ts +1067 -0
  273. package/src/generators/docs-data-builder.ts +483 -189
  274. package/src/generators/docs-data.ts +139 -28
  275. package/src/generators/docs-file.ts +205 -39
  276. package/src/generators/entity-file.ts +31 -15
  277. package/src/generators/extractor-file.ts +2 -1
  278. package/src/generators/field-anchor.ts +24 -0
  279. package/src/generators/index.ts +8 -1
  280. package/src/generators/mermaid-er.ts +14 -0
  281. package/src/generators/output-parser-file.ts +3 -4
  282. package/src/generators/output-prompt-file.ts +2 -1
  283. package/src/generators/prompt-render-file.ts +3 -4
  284. package/src/generators/queries-file.ts +9 -3
  285. package/src/generators/render-helper-file.ts +2 -1
  286. package/src/generators/routes-file-hono.ts +5 -1
  287. package/src/generators/routes-file.ts +7 -1
  288. package/src/generators/template-doc-builder.ts +306 -0
  289. package/src/generators/template-doc-data.ts +85 -0
  290. package/src/generators/template-payload-tree.ts +71 -0
  291. package/src/generators/template-source-annotate.ts +290 -0
  292. package/src/generators/template-source-render.ts +203 -0
  293. package/src/generators/trace-helper-file.ts +301 -0
  294. package/src/import-path.ts +28 -0
  295. package/src/index.ts +55 -4
  296. package/src/metaobjects-config.ts +146 -2
  297. package/src/naming.ts +73 -3
  298. package/src/payload-codegen.ts +16 -5
  299. package/src/pk-resolver.ts +4 -2
  300. package/src/projection/extract-view-spec.ts +50 -31
  301. package/src/relation-resolver.ts +103 -1
  302. package/src/render-context.ts +32 -2
  303. package/src/render-engine/embedded-templates.generated.ts +14 -0
  304. package/src/render-engine/framework-provider.ts +25 -11
  305. package/src/runner.ts +24 -0
  306. package/src/templates/docs-file.ts +2 -9
  307. package/src/templates/drizzle-schema.ts +80 -28
  308. package/src/templates/entity-constants.ts +3 -3
  309. package/src/templates/entity-file.ts +16 -5
  310. package/src/templates/enums-file.ts +50 -0
  311. package/src/templates/extract-delegate-emitter.ts +6 -7
  312. package/src/templates/extractor.ts +70 -40
  313. package/src/templates/field-meta.ts +1 -7
  314. package/src/templates/filter-allowlist.ts +18 -11
  315. package/src/templates/filter-shared.ts +2 -2
  316. package/src/templates/filter-type.ts +9 -7
  317. package/src/templates/find-templates.ts +15 -0
  318. package/src/templates/fr010-field-mapping.ts +15 -13
  319. package/src/templates/inferred-types.ts +122 -21
  320. package/src/templates/mermaid-er.ts +176 -8
  321. package/src/templates/output-format-spec-emitter.ts +1 -1
  322. package/src/templates/output-parser.ts +31 -80
  323. package/src/templates/output-prompt.ts +2 -1
  324. package/src/templates/queries-file.ts +133 -4
  325. package/src/templates/queries.ts +21 -15
  326. package/src/templates/relations-block.ts +19 -3
  327. package/src/templates/render-helper.ts +5 -4
  328. package/src/templates/routes-file-hono.ts +1 -2
  329. package/src/templates/routes-file.ts +234 -7
  330. package/src/templates/tph-discriminator.ts +232 -0
  331. package/src/templates/value-object-file.ts +39 -5
  332. package/src/templates/zod-validators.ts +225 -21
  333. package/templates/api/agent-api.md.mustache +30 -0
  334. package/templates/api/entity-api.md.mustache +69 -0
  335. package/templates/api/index.md.mustache +21 -0
  336. package/templates/docs/entity-page.md.mustache +33 -21
  337. package/templates/docs/template-page.md.mustache +56 -0
  338. package/dist/templates/extract-schema-emitter.d.ts +0 -8
  339. package/dist/templates/extract-schema-emitter.d.ts.map +0 -1
  340. package/dist/templates/extract-schema-emitter.js +0 -81
  341. package/dist/templates/extract-schema-emitter.js.map +0 -1
  342. package/src/templates/extract-schema-emitter.ts +0 -111
@@ -0,0 +1,431 @@
1
+ // api-doc-render.ts — the two documentation FORMS that an ApiModel feeds:
2
+ // • a per-unit HUMAN reference page (renderEntityApiPage)
3
+ // • a consolidated HUMAN index (renderApiIndex)
4
+ // • a condensed AGENT/LLM form (renderAgentApi)
5
+ //
6
+ // ADR-0022 Part 3: one ApiModel, two forms — the human prose page and the
7
+ // token-frugal agent form derive from the SAME IR, never re-derived. Rendering
8
+ // goes through the SHARED `render()` Mustache engine against canonical templates
9
+ // under `templates/api/` (resolved via the framework/project provider chain —
10
+ // the same mechanism docs-file.ts uses), so adopters can override a template by
11
+ // dropping their own `templates/api/<ref>.mustache` into their project root.
12
+ //
13
+ // The view-models are pre-rendered here (mirroring docs-data-builder) so the
14
+ // Mustache templates stay logic-light: section grouping, symbol counts, and the
15
+ // collision-safe index hrefs (docPageHref) are computed in TS.
16
+ import { render } from "@metaobjectsdev/render";
17
+ import { inlineShape } from "./api-field-shape.js";
18
+ import { docPageHref } from "../docs-paths.js";
19
+ import { GENERATED_HEADER } from "../constants.js";
20
+ // Template refs (resolved as `templates/api/<ref-tail>.mustache`).
21
+ const ENTITY_PAGE_REF = "api/entity-api.md";
22
+ const INDEX_REF = "api/index.md";
23
+ const AGENT_REF = "api/agent-api.md";
24
+ const GENERATED_MARKER = `<!-- ${GENERATED_HEADER} — DO NOT EDIT. -->`;
25
+ // ---------------------------------------------------------------------------
26
+ // Relative-import RENDER prefix.
27
+ //
28
+ // An `ApiSymbol.importPath` is the generated module's path RELATIVE TO the
29
+ // codegen output dir (flat → `Product.queries`; package → the package-folded
30
+ // `acme/shop/Product.queries`). It is the DATA the accuracy gate verifies
31
+ // against the emitted file, so it stays a bare module path.
32
+ //
33
+ // The generated files import each OTHER with `./`-prefixed RELATIVE specifiers
34
+ // (`from "./Product"`), so a copy-paste consumer co-located in the generated
35
+ // output dir must do the same — a BARE specifier (`from "Product.queries"`)
36
+ // only resolves with a non-default `baseUrl` and otherwise fails TS2307. The
37
+ // renderers therefore `./`-prefix the importPath in every rendered `from "…"`
38
+ // (the human page, the agent group headers, AND the example import blocks),
39
+ // without touching the underlying importPath data. A consumer importing from
40
+ // elsewhere adjusts the prefix (stated once in the page's import note).
41
+ // ---------------------------------------------------------------------------
42
+ /** The `./`-prefixed RELATIVE specifier for a documented module path (the form a
43
+ * co-located consumer copy-pastes). Already-relative paths pass through. */
44
+ function relSpecifier(importPath) {
45
+ return importPath.startsWith("./") || importPath.startsWith("../")
46
+ ? importPath
47
+ : `./${importPath}`;
48
+ }
49
+ /** Rewrite the `from "<module>"` tail of an example `import { … } from "<module>";`
50
+ * line to the `./`-prefixed relative specifier — the example imports are
51
+ * pre-composed in the ApiModel (reusing each symbol's bare importPath), so the
52
+ * `./` prefix is applied at render time alongside the section/header imports. */
53
+ function relImportLine(line) {
54
+ return line.replace(/(\bfrom\s+")([^"]+)(")/, (_m, pre, mod, post) => `${pre}${relSpecifier(mod)}${post}`);
55
+ }
56
+ // The human-facing section ORDER + HEADING per ApiSymbolKind. A unit's page
57
+ // renders only the kinds it actually carries, always in this canonical order
58
+ // (so two runs over the same model are byte-stable regardless of symbol order).
59
+ const KIND_ORDER = [
60
+ "model",
61
+ "relation",
62
+ "data-access",
63
+ "callable",
64
+ "rest",
65
+ "rest-hono",
66
+ "validation",
67
+ "extractor",
68
+ "render",
69
+ "prompt",
70
+ ];
71
+ const KIND_HEADING = {
72
+ model: "Model",
73
+ relation: "Relations",
74
+ "data-access": "Data access",
75
+ callable: "Callable",
76
+ rest: "REST",
77
+ "rest-hono": "REST (Hono)",
78
+ validation: "Validation",
79
+ extractor: "Extractor",
80
+ render: "Render",
81
+ prompt: "Prompt",
82
+ };
83
+ /** A docs-page name for the index href helper. The API index lives at the docs
84
+ * ROOT, so its links to per-unit pages are computed via the same docPageHref
85
+ * used elsewhere (resolves in flat AND package layout). */
86
+ const INDEX_NODE = { name: "index" };
87
+ /** The full set of handles a unit's example may reference. The per-unit page
88
+ * shows only the handles that unit's example actually uses; the agent + index
89
+ * forms show the full set once. */
90
+ /** Build a setup row, deriving the single-line agent snippet from the block one
91
+ * (newlines → `; `, collapsing any blank lines / double semicolons). */
92
+ function setupHandle(handle, note, snippet) {
93
+ const snippetInline = snippet
94
+ .split("\n")
95
+ .map((l) => l.trim())
96
+ .filter((l) => l.length > 0)
97
+ .map((l) => (l.endsWith(";") ? l.slice(0, -1) : l))
98
+ .join("; ");
99
+ return { handle, note, snippet, snippetInline };
100
+ }
101
+ const SETUP_HANDLES = {
102
+ db: setupHandle("db", "your Drizzle connection — the generated queries take `db: Db` (a `NodePgDatabase` / `BaseSQLiteDatabase` alias). Construct one over your own driver and pass any compatible Drizzle instance:", `import { drizzle } from "drizzle-orm/node-postgres";
103
+ import { Pool } from "pg";
104
+ const db = drizzle(new Pool({ connectionString: process.env.DATABASE_URL }));`),
105
+ provider: setupHandle("provider", "the render `Provider` (resolves a template ref to text) — import it from `@metaobjectsdev/render`; `InMemoryProvider` is built in (or supply your own filesystem-backed `Provider`):", `import { InMemoryProvider } from "@metaobjectsdev/render";
106
+ const provider = new InMemoryProvider({ "group/source": "Hello {{name}}" });`),
107
+ root: setupHandle("root", "the loaded `MetaRoot` `extract<Name>` parses against — load your metadata via `@metaobjectsdev/metadata` (the result carries `.root`):", `import { loadDirectory } from "@metaobjectsdev/metadata";
108
+ const { root } = await loadDirectory("./metadata");`),
109
+ };
110
+ /** Which handles a unit's example references (so the page shows only those). */
111
+ function setupHandlesFor(unit) {
112
+ const text = unit.example ? unit.example.body.join("\n") : "";
113
+ const out = [];
114
+ if (/\bdb\b/.test(text))
115
+ out.push(SETUP_HANDLES.db);
116
+ if (/\bprovider\b/.test(text))
117
+ out.push(SETUP_HANDLES.provider);
118
+ if (/\broot\b/.test(text))
119
+ out.push(SETUP_HANDLES.root);
120
+ return out;
121
+ }
122
+ /** A human-page caption for a symbol's field table, by kind + signature shape. */
123
+ function fieldsCaptionFor(s) {
124
+ if (s.kind === "model")
125
+ return "Fields";
126
+ if (s.kind === "validation")
127
+ return "Accepted fields";
128
+ if (s.kind === "prompt")
129
+ return "Payload";
130
+ if (s.kind === "extractor")
131
+ return "Returns";
132
+ if (s.kind === "relation")
133
+ return "Navigations";
134
+ if (s.kind === "callable")
135
+ return "Returns";
136
+ if (s.kind === "rest" || s.kind === "rest-hono") {
137
+ return s.name.startsWith("GET ") ? "Response body" : "Request body";
138
+ }
139
+ // data-access: a create/update takes a body; reads return the model.
140
+ return s.name.startsWith("create") || s.name.startsWith("update") ? "Request body (data)" : "Returns";
141
+ }
142
+ /** Markdown-escape a cell whose text may contain a `|` (TS union types do). */
143
+ function mdCell(text) {
144
+ return text.replace(/\|/g, "\\|");
145
+ }
146
+ /** Build the Field / Type / Required / Notes rows from a field shape. */
147
+ function fieldRows(fields) {
148
+ return fields.map((f) => ({
149
+ field: f.name,
150
+ type: mdCell(f.type),
151
+ required: f.optional ? "" : "yes",
152
+ notes: f.note ?? "",
153
+ }));
154
+ }
155
+ /** The exact `import { … } from "<importPath>"` an adopter writes for a symbol.
156
+ * REST endpoints aren't importable functions — the import is the entity's route
157
+ * registrar (`<entity>Routes`) from the routes module; the symbol's `name` is a
158
+ * "METHOD /path", not an identifier, so we import the registrar instead. Import
159
+ * paths are RELATIVE to the adopter's generated-output dir (a note at the top of
160
+ * the page states this once). */
161
+ function importLineFor(s) {
162
+ // REST + Hono endpoints aren't importable functions — import the route
163
+ // registrar named on the symbol instead of the "METHOD /path" name.
164
+ const isRouteKind = s.kind === "rest" || s.kind === "rest-hono";
165
+ const imported = isRouteKind ? s.registrar ?? s.name : s.name;
166
+ return `import { ${imported} } from "${relSpecifier(s.importPath)}"`;
167
+ }
168
+ /** Group a unit's symbols into ordered sections (one per present kind), each a
169
+ * list of {signature, usage, import, throws, example}. Empty kinds are omitted. */
170
+ function entityPageVM(unit) {
171
+ const sections = [];
172
+ for (const kind of KIND_ORDER) {
173
+ const ofKind = unit.symbols.filter((s) => s.kind === kind);
174
+ if (ofKind.length === 0)
175
+ continue;
176
+ sections.push({
177
+ heading: KIND_HEADING[kind],
178
+ symbols: ofKind.map(symbolVM),
179
+ });
180
+ }
181
+ const setup = setupHandlesFor(unit);
182
+ const vm = {
183
+ generatedMarker: GENERATED_MARKER,
184
+ node: unit.node,
185
+ hasSetup: setup.length > 0,
186
+ setup,
187
+ sections,
188
+ };
189
+ const ex = unitExampleBlock(unit.example);
190
+ if (ex !== undefined)
191
+ vm.unitExample = ex;
192
+ return vm;
193
+ }
194
+ /** The full worked-example block for a unit (imports + body), as one ```ts body
195
+ * string. Undefined when the unit has no runnable example. */
196
+ function unitExampleBlock(example) {
197
+ if (example === undefined)
198
+ return undefined;
199
+ // The example imports are pre-composed in the ApiModel from the symbols' bare
200
+ // importPaths; `./`-prefix each at render time so the copy-paste block resolves.
201
+ const lines = example.imports.map(relImportLine);
202
+ if (example.imports.length > 0 && example.body.length > 0)
203
+ lines.push("");
204
+ lines.push(...example.body);
205
+ return lines.join("\n");
206
+ }
207
+ function symbolVM(s) {
208
+ const vm = { signature: s.signature, usage: s.usage, importLine: importLineFor(s) };
209
+ // REST: tell the agent how to actually wire the endpoints once imported.
210
+ if (s.kind === "rest" && s.registrar !== undefined) {
211
+ vm.mountNote = `\`await ${s.registrar}(fastify)\``;
212
+ }
213
+ // Hono: the registrar mounts onto the Hono app with a per-request deps object.
214
+ if (s.kind === "rest-hono" && s.registrar !== undefined) {
215
+ vm.mountNote = `\`${s.registrar}(app, { db })\``;
216
+ }
217
+ if (s.throws !== undefined)
218
+ vm.throws = s.throws;
219
+ if (s.example !== undefined)
220
+ vm.example = s.example;
221
+ // Field shape → a Field / Type / Required / Notes table (only when there is at
222
+ // least one field; a shape with no fields is omitted to keep the page clean).
223
+ if (s.fields !== undefined && s.fields.length > 0) {
224
+ vm.hasFields = true;
225
+ vm.fieldsCaption = fieldsCaptionFor(s);
226
+ vm.fieldRows = fieldRows(s.fields);
227
+ }
228
+ return vm;
229
+ }
230
+ /** Render ONE per-unit human reference page from an ApiUnitDoc, via the shared
231
+ * render() engine + the canonical `api/entity-api.md` template. `modelPageHref`
232
+ * (when given) cross-links the page back to the entity's model/metadata page. */
233
+ export function renderEntityApiPage(unit, provider, modelPageHref) {
234
+ const payload = entityPageVM(unit);
235
+ if (modelPageHref !== undefined)
236
+ payload.modelPageHref = modelPageHref;
237
+ return render({
238
+ ref: ENTITY_PAGE_REF,
239
+ payload,
240
+ provider,
241
+ format: "markdown",
242
+ });
243
+ }
244
+ /** Lowercase summary label per kind (keeps the proper-noun acronym "REST"
245
+ * intact rather than ".toLowerCase()"-ing it to "rest"). */
246
+ const KIND_SUMMARY_LABEL = {
247
+ model: "model",
248
+ relation: "relations",
249
+ "data-access": "data access",
250
+ callable: "callable",
251
+ rest: "REST",
252
+ "rest-hono": "REST (Hono)",
253
+ validation: "validation",
254
+ extractor: "extractor",
255
+ render: "render",
256
+ prompt: "prompt",
257
+ };
258
+ /** A one-line summary for a unit's index row: the count of each present kind,
259
+ * in canonical order (e.g. "model, 5 data access, 5 REST, 2 validation"). */
260
+ function unitSummary(unit) {
261
+ const parts = [];
262
+ for (const kind of KIND_ORDER) {
263
+ const n = unit.symbols.filter((s) => s.kind === kind).length;
264
+ if (n === 0)
265
+ continue;
266
+ const label = KIND_SUMMARY_LABEL[kind];
267
+ parts.push(n === 1 ? label : `${n} ${label}`);
268
+ }
269
+ return parts.length > 0 ? parts.join(", ") : "no public symbols";
270
+ }
271
+ function indexRow(layout, unit) {
272
+ // The per-unit page is placed by {name, effective package} (see Task-3
273
+ // emission); link to it via the same docPageHref used for doc pages so it
274
+ // resolves in BOTH layouts — flat (`./Product.md`) and package
275
+ // (`./acme/shop/Product.md`), folding under the package path.
276
+ const href = docPageHref(layout, INDEX_NODE, { name: unit.node, package: unit.package });
277
+ return {
278
+ node: unit.node,
279
+ href,
280
+ summary: unitSummary(unit),
281
+ symbolCount: unit.symbols.length,
282
+ one: unit.symbols.length === 1,
283
+ };
284
+ }
285
+ /** Render the consolidated human API index (links to each unit page, grouped
286
+ * entity vs template) via the shared render() engine + `api/index.md`. */
287
+ export function renderApiIndex(model, layout, provider) {
288
+ const byName = (a, b) => a.node.localeCompare(b.node);
289
+ const entities = model.units.filter((u) => u.nodeKind === "entity").sort(byName);
290
+ const templates = model.units.filter((u) => u.nodeKind === "template").sort(byName);
291
+ const payload = {
292
+ generatedMarker: GENERATED_MARKER,
293
+ title: "API Reference",
294
+ intro: "Generated public API surface, one page per entity and output template.",
295
+ hasEntities: entities.length > 0,
296
+ entities: entities.map((u) => indexRow(layout, u)),
297
+ hasTemplates: templates.length > 0,
298
+ templates: templates.map((u) => indexRow(layout, u)),
299
+ };
300
+ return render({ ref: INDEX_REF, payload, provider, format: "markdown" });
301
+ }
302
+ /**
303
+ * The agent-form signature WITH the field shape inlined — so an LLM sees exactly
304
+ * what to pass / what it gets, not an opaque `unknown` / `ZodType` / type NAME.
305
+ * Token-frugal but complete. Shaping is per kind:
306
+ * • model → `interface <Name> <inlineShape>`;
307
+ * • data-access → swap the `data: unknown` param for `data: <inlineShape>`
308
+ * (create/update only; reads have no body shape);
309
+ * • validation → `<Name>InsertSchema: ZodType<<inlineShape>>`;
310
+ * • REST → append ` body: <inlineShape>` (write) / ` -> <inlineShape>`
311
+ * (GET response);
312
+ * • extractor → append ` // <Payload>: <inlineShape>`.
313
+ * Falls back to the bare signature when the symbol carries no field shape.
314
+ */
315
+ function agentSignature(s) {
316
+ if (s.fields === undefined || s.fields.length === 0)
317
+ return s.signature;
318
+ const shape = inlineShape(s.fields);
319
+ switch (s.kind) {
320
+ case "model":
321
+ return `interface ${s.name} ${shape}`;
322
+ case "data-access":
323
+ // create/update carry a `data: unknown` body param to specialize.
324
+ return s.signature.includes("data: unknown")
325
+ ? s.signature.replace("data: unknown", `data: ${shape}`)
326
+ : s.signature;
327
+ case "validation":
328
+ return s.signature.replace("ZodType", `ZodType<${shape}>`);
329
+ case "rest":
330
+ case "rest-hono":
331
+ return s.name.startsWith("GET ") ? `${s.signature} -> ${shape}` : `${s.signature} body: ${shape}`;
332
+ case "extractor":
333
+ case "prompt":
334
+ return `${s.signature} // ${s.returns ?? "payload"}: ${shape}`;
335
+ case "relation":
336
+ // The navigations ride in the shape; show them inline after the const decl.
337
+ return `const ${s.name} ${shape}`;
338
+ case "callable":
339
+ // Callable returns a typed row array; the model shape isn't its param, so
340
+ // keep the bare signature (its `args` shape is the @parameterRef VO, shown
341
+ // on that VO's own unit).
342
+ return s.signature;
343
+ default:
344
+ return s.signature;
345
+ }
346
+ }
347
+ /** Group a unit's symbols by their import MODULE (first-appearance order),
348
+ * emitting ONE `import { … } from "<module>"` header per module then the
349
+ * symbols under it. This is the token-frugal form that still tells the agent the
350
+ * exact import for EVERY symbol (one header amortized over N symbols, vs. an
351
+ * import line per symbol). REST endpoints aren't importable identifiers — they
352
+ * collapse under their entity's single route-registrar import (the registrar is
353
+ * the imported name; the endpoints list the verbs/paths it mounts). */
354
+ function agentGroups(unit) {
355
+ const order = [];
356
+ const byModule = new Map();
357
+ for (const s of unit.symbols) {
358
+ let g = byModule.get(s.importPath);
359
+ if (!g) {
360
+ g = { names: [], symbols: [] };
361
+ byModule.set(s.importPath, g);
362
+ order.push(s.importPath);
363
+ }
364
+ // The identifier an adopter imports: the symbol name, or — for REST / Hono —
365
+ // the shared route registrar (deduped across the entity's endpoints).
366
+ const isRouteKind = s.kind === "rest" || s.kind === "rest-hono";
367
+ const imported = isRouteKind ? s.registrar ?? s.name : s.name;
368
+ if (!g.names.includes(imported))
369
+ g.names.push(imported);
370
+ const sym = { signature: agentSignature(s), usage: s.usage };
371
+ if (s.throws !== undefined)
372
+ sym.throwsMarker = `[throws: ${s.throws}]`;
373
+ g.symbols.push(sym);
374
+ }
375
+ return order.map((mod) => {
376
+ const g = byModule.get(mod);
377
+ return {
378
+ importHeader: `import { ${g.names.join(", ")} } from "${relSpecifier(mod)}"`,
379
+ symbols: g.symbols,
380
+ };
381
+ });
382
+ }
383
+ /** Render the condensed agent/LLM form: per unit, symbols grouped under a single
384
+ * `import { … } from "<module>"` header then one compact `signature — usage`
385
+ * line each (with a `[throws: …]` marker when it throws), NO prose/examples
386
+ * (token budget). Units keep their ApiModel order; symbols keep their per-unit
387
+ * order (the canonical generator emission order). */
388
+ export function renderAgentApi(model, provider) {
389
+ const units = model.units
390
+ .filter((u) => u.symbols.length > 0)
391
+ .map((u) => {
392
+ const vm = { node: u.node, groups: agentGroups(u) };
393
+ // The compact agent example: body statements only (the imports are already
394
+ // amortized into the group headers above the example).
395
+ if (u.example !== undefined && u.example.body.length > 0) {
396
+ vm.example = u.example.body.join("\n");
397
+ }
398
+ return vm;
399
+ });
400
+ // The handles ANY unit's example references — shown once at the top so an agent
401
+ // knows where db / provider / root come from before the call sites below.
402
+ const setup = setupHandlesForModel(model);
403
+ const payload = {
404
+ generatedMarker: GENERATED_MARKER,
405
+ title: "Agent API Reference",
406
+ // The ApiModel carries no package itself, so the model-only entry point uses
407
+ // a generic, self-contained project label. (A richer label off the loaded
408
+ // root's package can be layered in by the Task-3 emission entrypoint, which
409
+ // has the root.)
410
+ project: "this project",
411
+ // Import paths are RELATIVE to the adopter's generated-output dir.
412
+ importNote: "Imports are relative to your generated-output directory.",
413
+ hasSetup: setup.length > 0,
414
+ setup,
415
+ units,
416
+ };
417
+ return render({ ref: AGENT_REF, payload, provider, format: "markdown" });
418
+ }
419
+ /** The union of setup handles referenced by ANY unit's example, in canonical
420
+ * db→provider→root order (shown once at the top of the agent form). */
421
+ function setupHandlesForModel(model) {
422
+ const used = new Set();
423
+ for (const u of model.units) {
424
+ for (const h of setupHandlesFor(u))
425
+ used.add(h.handle);
426
+ }
427
+ return ["db", "provider", "root"]
428
+ .filter((h) => used.has(h))
429
+ .map((h) => SETUP_HANDLES[h]);
430
+ }
431
+ //# sourceMappingURL=api-doc-render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-doc-render.js","sourceRoot":"","sources":["../../src/generators/api-doc-render.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,6DAA6D;AAC7D,wDAAwD;AACxD,yDAAyD;AACzD,EAAE;AACF,0EAA0E;AAC1E,+EAA+E;AAC/E,iFAAiF;AACjF,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,EAAE;AACF,6EAA6E;AAC7E,gFAAgF;AAChF,+DAA+D;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAmB,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAoB,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,mEAAmE;AACnE,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAC5C,MAAM,SAAS,GAAG,cAAc,CAAC;AACjC,MAAM,SAAS,GAAG,kBAAkB,CAAC;AAErC,MAAM,gBA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CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG;QACd,eAAe,EAAE,gBAAgB;QACjC,KAAK,EAAE,qBAAqB;QAC5B,6EAA6E;QAC7E,0EAA0E;QAC1E,4EAA4E;QAC5E,iBAAiB;QACjB,OAAO,EAAE,cAAc;QACvB,mEAAmE;QACnE,UAAU,EAAE,0DAA0D;QACtE,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;QAC1B,KAAK;QACL,KAAK;KACN,CAAC;IACF,OAAO,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED;wEACwE;AACxE,SAAS,oBAAoB,CAAC,KAAe;IAC3C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC5B,KAAK,MAAM,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IACD,OAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAW;SACzC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAC1B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { MetaObject } from "@metaobjectsdev/metadata";
2
+ import type { GeneratorFactory } from "../generator.js";
3
+ export interface ApiDocsFileOpts {
4
+ filter?: (entity: MetaObject) => boolean;
5
+ target?: string;
6
+ /** Output prefix for all api-docs artifacts. Default `docs/api`. */
7
+ subDir?: string;
8
+ /** When true, the model surface is emitted alongside the api surface (at the
9
+ * docs root), so each api entity page cross-links back to its model page. The
10
+ * href is computed via the shared `surfaceCrossHref` so it resolves in BOTH
11
+ * layouts. ABSENT/false ⇒ default api output byte-identical. */
12
+ modelSurface?: boolean;
13
+ }
14
+ /**
15
+ * @deprecated ADR-0025: `meta docs` is the single door for ALL docs. `apiDocsFile()`
16
+ * stays as the INTERNAL engine of the docs door's api surface — do NOT add it to a
17
+ * `meta gen` config / the generators array. Use `meta docs` (it emits the api surface
18
+ * alongside the model surface). A `meta gen` config that lists it is warned + skipped.
19
+ */
20
+ export declare const apiDocsFile: GeneratorFactory<ApiDocsFileOpts>;
21
+ //# sourceMappingURL=api-docs-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-docs-file.d.ts","sourceRoot":"","sources":["../../src/generators/api-docs-file.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAa,gBAAgB,EAAe,MAAM,iBAAiB,CAAC;AA2BhF,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;qEAGiE;IACjE,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAwEnB,gBAAgB,CAAC,eAAe,CAAC,CAAC"}
@@ -0,0 +1,112 @@
1
+ // apiDocsFile() — the `api-docs` GENERATOR (ADR-0022 Part 3, Tier-1 NATIVE).
2
+ //
3
+ // It documents the PUBLIC API surface the OTHER generators emit for a model —
4
+ // the generated code's own API, in two forms (a human reference + a condensed
5
+ // agent form). It is a thin wiring layer: it REUSES, without re-derivation,
6
+ // • Task-1's buildApiModel() — the accurate-by-construction IR, and
7
+ // • Task-2's renderEntityApiPage / renderApiIndex / renderAgentApi renderers,
8
+ // • the shared docs-paths placement (collision-safe, layout-aware) that
9
+ // docsFile() uses — so multi-package models never silently overwrite a page.
10
+ //
11
+ // Output (all under `docs/api/`):
12
+ // • one `<Node>.md` per entity + template.output unit (the human page),
13
+ // • `README.md` — the consolidated human index (GitHub treats it as landing),
14
+ // • `AGENT-API.md` — the token-frugal agent form.
15
+ //
16
+ // Unlike `docs`/`mermaid-er` (Tier-2 neutral, owned by `meta docs`), `api-docs`
17
+ // is a NATIVE generator: it is REGISTERED in the generator registry (ADR-0022
18
+ // Part 3) — so it appears in `gen --list` and is selectable by its stable name
19
+ // `api-docs`. It is NOT a `meta docs` mode.
20
+ //
21
+ // It is NOT (yet) part of the default `meta gen` scaffold suite: it is
22
+ // registry-listed but not auto-run. Turning it on by default in the scaffold,
23
+ // and surfacing the agent form (AGENT-API.md) to a coding agent via a pointer
24
+ // from the installed `.metaobjects/` context, are tracked as agent-context-
25
+ // coordination follow-ups — deliberately deferred here to avoid colliding with
26
+ // the live agent-context work.
27
+ import { docPageOutputPath, surfaceCrossHref, assertNoDuplicateDocPaths, } from "../docs-paths.js";
28
+ import { projectProvider } from "../render-engine/framework-provider.js";
29
+ import { buildApiModel } from "./api-model.js";
30
+ import { renderEntityApiPage, renderApiIndex, renderAgentApi, } from "./api-doc-render.js";
31
+ // All api-docs artifacts live under this sub-directory of the codegen out dir.
32
+ // Per-unit pages fold further under their package path (package layout); the
33
+ // index + agent form stay at the api root (their links are computed relative to
34
+ // it via the same docPageHref the renderers use).
35
+ //
36
+ // The DEFAULT prefix is `docs/api` — byte-identical to the historical `meta gen`
37
+ // behaviour + goldens. The unified `meta docs` command (which writes everything
38
+ // under one docs root, `./docs`) overrides it via `subDir:'api'` so the api
39
+ // surface emits `api/<Node>.md` rather than doubling to `./docs/docs/api`.
40
+ const DEFAULT_API_DIR = "docs/api";
41
+ /**
42
+ * @deprecated ADR-0025: `meta docs` is the single door for ALL docs. `apiDocsFile()`
43
+ * stays as the INTERNAL engine of the docs door's api surface — do NOT add it to a
44
+ * `meta gen` config / the generators array. Use `meta docs` (it emits the api surface
45
+ * alongside the model surface). A `meta gen` config that lists it is warned + skipped.
46
+ */
47
+ export const apiDocsFile = function apiDocsFile(opts) {
48
+ const generator = {
49
+ name: "api-docs",
50
+ generate(ctx) {
51
+ const provider = projectProvider(ctx.projectRoot ?? process.cwd());
52
+ const layout = ctx.config.outputLayout ?? "flat";
53
+ // Per-call output prefix. Default `docs/api`; `meta docs` passes `api`.
54
+ const apiDir = opts?.subDir ?? DEFAULT_API_DIR;
55
+ const indexFilename = `${apiDir}/README.md`;
56
+ const agentFilename = `${apiDir}/AGENT-API.md`;
57
+ // ONE ApiModel feeds every form (Task-1 builder; Task-2 renderers). The
58
+ // pkMap is reused from the run's renderContext when present (the real gen
59
+ // run always provides it) and derived otherwise.
60
+ // Auto-detect: document the OPT-IN Hono CRUD surface iff the Hono routes
61
+ // generator is actually in the run. The runner aggregates each generator's
62
+ // `emitsHonoRoutes` marker into ctx.config.includeHonoRoutes, so api-docs
63
+ // "just works" — it documents Hono exactly when `routesFileHono` is wired,
64
+ // and omits it (Fastify-only) otherwise. No explicit opt needed.
65
+ const model = buildApiModel(ctx.loadedRoot, {
66
+ loadedRoot: ctx.loadedRoot,
67
+ outputLayout: layout,
68
+ includeHonoRoutes: ctx.config.includeHonoRoutes ?? false,
69
+ ...(ctx.renderContext?.pkMap !== undefined && { pkMap: ctx.renderContext.pkMap }),
70
+ });
71
+ // Track (path, fqn) for the SAME hard collision backstop docsFile() uses —
72
+ // two units that resolve to one path (flat, cross-package short-name clash)
73
+ // throw rather than silently overwrite.
74
+ const placements = [];
75
+ // Per-unit human page. Placement is collision-safe via docPageOutputPath
76
+ // off {name, effective package}, prefixed under the api dir; the index
77
+ // (renderApiIndex) computes its links from the SAME {name, package}, so a
78
+ // link always points at the page's real location in BOTH layouts.
79
+ const files = model.units.map((unit) => {
80
+ const node = { name: unit.node, package: unit.package };
81
+ const path = `${apiDir}/${docPageOutputPath(layout, node)}`;
82
+ placements.push({ path, fqn: unit.package ? `${unit.package}::${unit.node}` : unit.node });
83
+ // Cross-link back to the sibling model page, when emitted. The model page
84
+ // lives at the docs root at `<placement>`; this api page lives at
85
+ // `<apiDir>/<placement>`. The href is derived from the SAME
86
+ // docPageOutputPath placement via surfaceCrossHref so it resolves in both
87
+ // layouts. ABSENT otherwise.
88
+ const modelPageHref = opts?.modelSurface
89
+ ? surfaceCrossHref(path, docPageOutputPath(layout, node))
90
+ : undefined;
91
+ return { path, content: renderEntityApiPage(unit, provider, modelPageHref) };
92
+ });
93
+ // The consolidated human index (README.md) + the condensed agent form,
94
+ // both at the api root. Only emitted when at least one unit page exists.
95
+ if (files.length > 0) {
96
+ placements.push({ path: indexFilename, fqn: "<the api-docs index page>" });
97
+ placements.push({ path: agentFilename, fqn: "<the api-docs agent form>" });
98
+ files.unshift({ path: indexFilename, content: renderApiIndex(model, layout, provider) }, { path: agentFilename, content: renderAgentApi(model, provider) });
99
+ }
100
+ // Hard backstop against silent overwrite (ALL layouts): throw naming both
101
+ // colliding FQNs + the path. Same guard docsFile() reuses.
102
+ assertNoDuplicateDocPaths(placements);
103
+ return files;
104
+ },
105
+ };
106
+ if (opts?.filter)
107
+ generator.filter = opts.filter;
108
+ if (opts?.target)
109
+ generator.target = opts.target;
110
+ return generator;
111
+ };
112
+ //# sourceMappingURL=api-docs-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-docs-file.js","sourceRoot":"","sources":["../../src/generators/api-docs-file.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,sEAAsE;AACtE,gFAAgF;AAChF,0EAA0E;AAC1E,iFAAiF;AACjF,EAAE;AACF,kCAAkC;AAClC,0EAA0E;AAC1E,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,+EAA+E;AAC/E,4CAA4C;AAC5C,EAAE;AACF,uEAAuE;AACvE,8EA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CAAC;YAEH,uEAAuE;YACvE,yEAAyE;YACzE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,2BAA2B,EAAE,CAAC,CAAC;gBAC3E,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,2BAA2B,EAAE,CAAC,CAAC;gBAC3E,KAAK,CAAC,OAAO,CACX,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,EACzE,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAClE,CAAC;YACJ,CAAC;YAED,0EAA0E;YAC1E,2DAA2D;YAC3D,yBAAyB,CAAC,UAAU,CAAC,CAAC;YAEtC,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;IACF,IAAI,IAAI,EAAE,MAAM;QAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACjD,IAAI,IAAI,EAAE,MAAM;QAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACjD,OAAO,SAAS,CAAC;AACnB,CAAsC,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { MetaObject, MetaRoot } from "@metaobjectsdev/metadata";
2
+ /** One documented field in a model / payload shape. Structured so BOTH renderers
3
+ * (the human field table + the agent inline shape) format it without re-deriving. */
4
+ export interface FieldShape {
5
+ /** The field name (the property key). */
6
+ name: string;
7
+ /** The TS type expression, e.g. `string`, `number`, `"active" | "archived"`,
8
+ * `Address[]`. Enum unions are inlined (self-contained for an agent). */
9
+ type: string;
10
+ /** Whether the property is optional in this shape (`name?: T`). */
11
+ optional: boolean;
12
+ /** A short note, e.g. `pinned "Bridge"` (TPH discriminator) or `server-set`
13
+ * (@autoSet). Undefined when there is nothing extra to say. */
14
+ note?: string;
15
+ }
16
+ /**
17
+ * The entity MODEL field shape — every field, with the value-object interface's
18
+ * TS type and the docs nullable rule (optional iff not required and not the PK).
19
+ * Mirrors `InferSelectModel` field-presence; the PK is reported required.
20
+ */
21
+ export declare function modelFieldShapes(obj: MetaObject): FieldShape[];
22
+ /** The create-payload (InsertSchema) field shape — what `create<Name>` / POST
23
+ * accepts. */
24
+ export declare function createFieldShapes(obj: MetaObject): FieldShape[];
25
+ /** The update-payload (UpdateSchema) field shape — what `update<Name>` / PATCH
26
+ * accepts (typically all-optional partial). */
27
+ export declare function updateFieldShapes(obj: MetaObject): FieldShape[];
28
+ /**
29
+ * The extractor PAYLOAD field shape — the field interface of the value object
30
+ * `extract<Name>` returns (the `@payloadRef` target). Same `fieldTsTypeString`
31
+ * mapping + `isFieldRequired` optionality the VO interface emitter uses, so it
32
+ * matches the emitted payload type. Returns undefined when the ref does not
33
+ * resolve to a loaded object.
34
+ */
35
+ export declare function payloadFieldShapes(root: MetaRoot, payloadRef: string): FieldShape[] | undefined;
36
+ /** Format a list of field shapes as a compact inline TS object type, e.g.
37
+ * `{ name: string; status?: "active" | "archived" }`. Empty list → `{}`. */
38
+ export declare function inlineShape(fields: FieldShape[]): string;
39
+ //# sourceMappingURL=api-field-shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-field-shape.d.ts","sourceRoot":"","sources":["../../src/generators/api-field-shape.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,UAAU,EAAa,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAShF;sFACsF;AACtF,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb;8EAC0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;IAClB;oEACgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,EAAE,CAW9D;AAuBD;eACe;AACf,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,EAAE,CAE/D;AAED;gDACgD;AAChD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,EAAE,CAE/D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,EAAE,GAAG,SAAS,CAI/F;AAED;6EAC6E;AAC7E,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAIxD"}