@metaobjectsdev/metadata 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 (392) hide show
  1. package/dist/attr-schema-validate.d.ts +1 -1
  2. package/dist/attr-schema-validate.d.ts.map +1 -1
  3. package/dist/attr-schema-validate.js +96 -11
  4. package/dist/attr-schema-validate.js.map +1 -1
  5. package/dist/constraint-merge.d.ts +18 -0
  6. package/dist/constraint-merge.d.ts.map +1 -0
  7. package/dist/constraint-merge.js +0 -0
  8. package/dist/constraint-merge.js.map +1 -0
  9. package/dist/constraint-validate.d.ts +6 -0
  10. package/dist/constraint-validate.d.ts.map +1 -0
  11. package/dist/constraint-validate.js +274 -0
  12. package/dist/constraint-validate.js.map +1 -0
  13. package/dist/core/attr/attr-constants.d.ts +13 -3
  14. package/dist/core/attr/attr-constants.d.ts.map +1 -1
  15. package/dist/core/attr/attr-constants.js +11 -2
  16. package/dist/core/attr/attr-constants.js.map +1 -1
  17. package/dist/core/attr/attr-definition.embedded.d.ts +3 -0
  18. package/dist/core/attr/attr-definition.embedded.d.ts.map +1 -0
  19. package/dist/core/attr/attr-definition.embedded.js +60 -0
  20. package/dist/core/attr/attr-definition.embedded.js.map +1 -0
  21. package/dist/core/documentation/doc-constants.d.ts +3 -2
  22. package/dist/core/documentation/doc-constants.d.ts.map +1 -1
  23. package/dist/core/documentation/doc-constants.js +3 -1
  24. package/dist/core/documentation/doc-constants.js.map +1 -1
  25. package/dist/core/documentation/doc-provider.d.ts.map +1 -1
  26. package/dist/core/documentation/doc-provider.js +6 -2
  27. package/dist/core/documentation/doc-provider.js.map +1 -1
  28. package/dist/core/documentation/documentation-definition.embedded.d.ts +3 -0
  29. package/dist/core/documentation/documentation-definition.embedded.d.ts.map +1 -0
  30. package/dist/core/documentation/documentation-definition.embedded.js +79 -0
  31. package/dist/core/documentation/documentation-definition.embedded.js.map +1 -0
  32. package/dist/core/field/field-constants.d.ts +7 -4
  33. package/dist/core/field/field-constants.d.ts.map +1 -1
  34. package/dist/core/field/field-constants.js +7 -7
  35. package/dist/core/field/field-constants.js.map +1 -1
  36. package/dist/core/field/field-definition.embedded.d.ts +3 -0
  37. package/dist/core/field/field-definition.embedded.d.ts.map +1 -0
  38. package/dist/core/field/field-definition.embedded.js +236 -0
  39. package/dist/core/field/field-definition.embedded.js.map +1 -0
  40. package/dist/core/field/meta-field.d.ts.map +1 -1
  41. package/dist/core/field/meta-field.js +7 -5
  42. package/dist/core/field/meta-field.js.map +1 -1
  43. package/dist/core/identity/identity-constants.d.ts.map +1 -1
  44. package/dist/core/identity/identity-constants.js +3 -0
  45. package/dist/core/identity/identity-constants.js.map +1 -1
  46. package/dist/core/identity/identity-definition.embedded.d.ts +3 -0
  47. package/dist/core/identity/identity-definition.embedded.d.ts.map +1 -0
  48. package/dist/core/identity/identity-definition.embedded.js +93 -0
  49. package/dist/core/identity/identity-definition.embedded.js.map +1 -0
  50. package/dist/core/identity/meta-identity.d.ts.map +1 -1
  51. package/dist/core/identity/meta-identity.js +8 -1
  52. package/dist/core/identity/meta-identity.js.map +1 -1
  53. package/dist/core/identity/validate-identity-passthrough.d.ts +42 -0
  54. package/dist/core/identity/validate-identity-passthrough.d.ts.map +1 -0
  55. package/dist/core/identity/validate-identity-passthrough.js +158 -0
  56. package/dist/core/identity/validate-identity-passthrough.js.map +1 -0
  57. package/dist/core/object/object-constants.d.ts +2 -1
  58. package/dist/core/object/object-constants.d.ts.map +1 -1
  59. package/dist/core/object/object-constants.js +3 -0
  60. package/dist/core/object/object-constants.js.map +1 -1
  61. package/dist/core/object/object-definition.embedded.d.ts +3 -0
  62. package/dist/core/object/object-definition.embedded.d.ts.map +1 -0
  63. package/dist/core/object/object-definition.embedded.js +110 -0
  64. package/dist/core/object/object-definition.embedded.js.map +1 -0
  65. package/dist/core/object/validate-discriminator.d.ts.map +1 -1
  66. package/dist/core/object/validate-discriminator.js +1 -3
  67. package/dist/core/object/validate-discriminator.js.map +1 -1
  68. package/dist/core/query/query-constants.d.ts.map +1 -1
  69. package/dist/core/query/query-constants.js +5 -3
  70. package/dist/core/query/query-constants.js.map +1 -1
  71. package/dist/core/relationship/derive-m2m-fields.d.ts +26 -0
  72. package/dist/core/relationship/derive-m2m-fields.d.ts.map +1 -0
  73. package/dist/core/relationship/derive-m2m-fields.js +102 -0
  74. package/dist/core/relationship/derive-m2m-fields.js.map +1 -0
  75. package/dist/core/relationship/meta-relationship.d.ts +6 -4
  76. package/dist/core/relationship/meta-relationship.d.ts.map +1 -1
  77. package/dist/core/relationship/meta-relationship.js +12 -8
  78. package/dist/core/relationship/meta-relationship.js.map +1 -1
  79. package/dist/core/relationship/relationship-constants.d.ts +6 -2
  80. package/dist/core/relationship/relationship-constants.d.ts.map +1 -1
  81. package/dist/core/relationship/relationship-constants.js +6 -2
  82. package/dist/core/relationship/relationship-constants.js.map +1 -1
  83. package/dist/core/relationship/relationship-definition.embedded.d.ts +3 -0
  84. package/dist/core/relationship/relationship-definition.embedded.d.ts.map +1 -0
  85. package/dist/core/relationship/relationship-definition.embedded.js +310 -0
  86. package/dist/core/relationship/relationship-definition.embedded.js.map +1 -0
  87. package/dist/core/validator/validator-constants.d.ts +14 -1
  88. package/dist/core/validator/validator-constants.d.ts.map +1 -1
  89. package/dist/core/validator/validator-constants.js +20 -1
  90. package/dist/core/validator/validator-constants.js.map +1 -1
  91. package/dist/core/validator/validator-definition.embedded.d.ts +3 -0
  92. package/dist/core/validator/validator-definition.embedded.d.ts.map +1 -0
  93. package/dist/core/validator/validator-definition.embedded.js +255 -0
  94. package/dist/core/validator/validator-definition.embedded.js.map +1 -0
  95. package/dist/core/yaml-desugar.d.ts.map +1 -1
  96. package/dist/core/yaml-desugar.js +88 -10
  97. package/dist/core/yaml-desugar.js.map +1 -1
  98. package/dist/core-types.d.ts +5 -2
  99. package/dist/core-types.d.ts.map +1 -1
  100. package/dist/core-types.js +285 -116
  101. package/dist/core-types.js.map +1 -1
  102. package/dist/errors.d.ts +3 -3
  103. package/dist/errors.d.ts.map +1 -1
  104. package/dist/errors.js +87 -0
  105. package/dist/errors.js.map +1 -1
  106. package/dist/index.d.ts +17 -2
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +26 -1
  109. package/dist/index.js.map +1 -1
  110. package/dist/library/embedded-library.generated.d.ts +2 -0
  111. package/dist/library/embedded-library.generated.d.ts.map +1 -0
  112. package/dist/library/embedded-library.generated.js +11 -0
  113. package/dist/library/embedded-library.generated.js.map +1 -0
  114. package/dist/library/library-sources.d.ts +12 -0
  115. package/dist/library/library-sources.d.ts.map +1 -0
  116. package/dist/library/library-sources.js +88 -0
  117. package/dist/library/library-sources.js.map +1 -0
  118. package/dist/loader/meta-data-loader.d.ts +10 -2
  119. package/dist/loader/meta-data-loader.d.ts.map +1 -1
  120. package/dist/loader/meta-data-loader.js +57 -6
  121. package/dist/loader/meta-data-loader.js.map +1 -1
  122. package/dist/loader/shortcuts.d.ts +2 -5
  123. package/dist/loader/shortcuts.d.ts.map +1 -1
  124. package/dist/loader/shortcuts.js.map +1 -1
  125. package/dist/loader/validation-passes.d.ts +3 -0
  126. package/dist/loader/validation-passes.d.ts.map +1 -1
  127. package/dist/loader/validation-passes.js +519 -34
  128. package/dist/loader/validation-passes.js.map +1 -1
  129. package/dist/loader/validation-registry.d.ts +10 -0
  130. package/dist/loader/validation-registry.d.ts.map +1 -0
  131. package/dist/loader/validation-registry.js +84 -0
  132. package/dist/loader/validation-registry.js.map +1 -0
  133. package/dist/metamodel-docs/index.d.ts +19 -0
  134. package/dist/metamodel-docs/index.d.ts.map +1 -0
  135. package/dist/metamodel-docs/index.js +37 -0
  136. package/dist/metamodel-docs/index.js.map +1 -0
  137. package/dist/metamodel-docs/provenance.d.ts +42 -0
  138. package/dist/metamodel-docs/provenance.d.ts.map +1 -0
  139. package/dist/metamodel-docs/provenance.js +148 -0
  140. package/dist/metamodel-docs/provenance.js.map +1 -0
  141. package/dist/metamodel-docs/provider-definitions.d.ts +8 -0
  142. package/dist/metamodel-docs/provider-definitions.d.ts.map +1 -0
  143. package/dist/metamodel-docs/provider-definitions.js +48 -0
  144. package/dist/metamodel-docs/provider-definitions.js.map +1 -0
  145. package/dist/metamodel-docs/render.d.ts +12 -0
  146. package/dist/metamodel-docs/render.d.ts.map +1 -0
  147. package/dist/metamodel-docs/render.js +252 -0
  148. package/dist/metamodel-docs/render.js.map +1 -0
  149. package/dist/naming-refs.d.ts +41 -0
  150. package/dist/naming-refs.d.ts.map +1 -0
  151. package/dist/naming-refs.js +144 -0
  152. package/dist/naming-refs.js.map +1 -0
  153. package/dist/naming.d.ts.map +1 -1
  154. package/dist/naming.js +10 -2
  155. package/dist/naming.js.map +1 -1
  156. package/dist/parser-core.d.ts.map +1 -1
  157. package/dist/parser-core.js +84 -9
  158. package/dist/parser-core.js.map +1 -1
  159. package/dist/persistence/db/db-constants.d.ts +10 -0
  160. package/dist/persistence/db/db-constants.d.ts.map +1 -1
  161. package/dist/persistence/db/db-constants.js +14 -0
  162. package/dist/persistence/db/db-constants.js.map +1 -1
  163. package/dist/persistence/db/db-definition.embedded.d.ts +3 -0
  164. package/dist/persistence/db/db-definition.embedded.d.ts.map +1 -0
  165. package/dist/persistence/db/db-definition.embedded.js +227 -0
  166. package/dist/persistence/db/db-definition.embedded.js.map +1 -0
  167. package/dist/persistence/db/db-provider.d.ts.map +1 -1
  168. package/dist/persistence/db/db-provider.js +13 -18
  169. package/dist/persistence/db/db-provider.js.map +1 -1
  170. package/dist/persistence/origin/origin-definition.embedded.d.ts +3 -0
  171. package/dist/persistence/origin/origin-definition.embedded.d.ts.map +1 -0
  172. package/dist/persistence/origin/origin-definition.embedded.js +88 -0
  173. package/dist/persistence/origin/origin-definition.embedded.js.map +1 -0
  174. package/dist/persistence/source/source-definition.embedded.d.ts +3 -0
  175. package/dist/persistence/source/source-definition.embedded.d.ts.map +1 -0
  176. package/dist/persistence/source/source-definition.embedded.js +17 -0
  177. package/dist/persistence/source/source-definition.embedded.js.map +1 -0
  178. package/dist/persistence/source/validate-source-parameter-ref.d.ts.map +1 -1
  179. package/dist/persistence/source/validate-source-parameter-ref.js +7 -1
  180. package/dist/persistence/source/validate-source-parameter-ref.js.map +1 -1
  181. package/dist/persistence/source/validate-source-roles.d.ts.map +1 -1
  182. package/dist/persistence/source/validate-source-roles.js +16 -1
  183. package/dist/persistence/source/validate-source-roles.js.map +1 -1
  184. package/dist/presentation/layout/layout-definition.embedded.d.ts +3 -0
  185. package/dist/presentation/layout/layout-definition.embedded.d.ts.map +1 -0
  186. package/dist/presentation/layout/layout-definition.embedded.js +16 -0
  187. package/dist/presentation/layout/layout-definition.embedded.js.map +1 -0
  188. package/dist/presentation/ui/ui-definition.embedded.d.ts +3 -0
  189. package/dist/presentation/ui/ui-definition.embedded.d.ts.map +1 -0
  190. package/dist/presentation/ui/ui-definition.embedded.js +114 -0
  191. package/dist/presentation/ui/ui-definition.embedded.js.map +1 -0
  192. package/dist/presentation/ui/ui-provider.d.ts +3 -0
  193. package/dist/presentation/ui/ui-provider.d.ts.map +1 -0
  194. package/dist/presentation/ui/ui-provider.js +21 -0
  195. package/dist/presentation/ui/ui-provider.js.map +1 -0
  196. package/dist/presentation/view/view-definition.embedded.d.ts +3 -0
  197. package/dist/presentation/view/view-definition.embedded.d.ts.map +1 -0
  198. package/dist/presentation/view/view-definition.embedded.js +76 -0
  199. package/dist/presentation/view/view-definition.embedded.js.map +1 -0
  200. package/dist/provider-data.d.ts +184 -0
  201. package/dist/provider-data.d.ts.map +1 -0
  202. package/dist/provider-data.js +271 -0
  203. package/dist/provider-data.js.map +1 -0
  204. package/dist/provider.d.ts +3 -1
  205. package/dist/provider.d.ts.map +1 -1
  206. package/dist/provider.js +15 -1
  207. package/dist/provider.js.map +1 -1
  208. package/dist/registry-coverage.d.ts +99 -0
  209. package/dist/registry-coverage.d.ts.map +1 -0
  210. package/dist/registry-coverage.js +294 -0
  211. package/dist/registry-coverage.js.map +1 -0
  212. package/dist/registry-manifest-exclusions.d.ts +62 -0
  213. package/dist/registry-manifest-exclusions.d.ts.map +1 -0
  214. package/dist/registry-manifest-exclusions.js +163 -0
  215. package/dist/registry-manifest-exclusions.js.map +1 -0
  216. package/dist/registry-manifest.d.ts +117 -0
  217. package/dist/registry-manifest.d.ts.map +1 -0
  218. package/dist/registry-manifest.js +242 -0
  219. package/dist/registry-manifest.js.map +1 -0
  220. package/dist/registry.d.ts +76 -2
  221. package/dist/registry.d.ts.map +1 -1
  222. package/dist/registry.js +37 -1
  223. package/dist/registry.js.map +1 -1
  224. package/dist/shared/structural.d.ts +7 -0
  225. package/dist/shared/structural.d.ts.map +1 -1
  226. package/dist/shared/structural.js +7 -0
  227. package/dist/shared/structural.js.map +1 -1
  228. package/dist/subtype-rules.d.ts.map +1 -1
  229. package/dist/subtype-rules.js +97 -13
  230. package/dist/subtype-rules.js.map +1 -1
  231. package/dist/super-resolve.d.ts +49 -2
  232. package/dist/super-resolve.d.ts.map +1 -1
  233. package/dist/super-resolve.js +128 -43
  234. package/dist/super-resolve.js.map +1 -1
  235. package/dist/template/meta-template.d.ts +3 -2
  236. package/dist/template/meta-template.d.ts.map +1 -1
  237. package/dist/template/meta-template.js +3 -2
  238. package/dist/template/meta-template.js.map +1 -1
  239. package/dist/template/prompt-definition.embedded.d.ts +3 -0
  240. package/dist/template/prompt-definition.embedded.d.ts.map +1 -0
  241. package/dist/template/prompt-definition.embedded.js +368 -0
  242. package/dist/template/prompt-definition.embedded.js.map +1 -0
  243. package/dist/template/prompt-provider.d.ts +3 -0
  244. package/dist/template/prompt-provider.d.ts.map +1 -0
  245. package/dist/template/prompt-provider.js +25 -0
  246. package/dist/template/prompt-provider.js.map +1 -0
  247. package/dist/template/template-constants.d.ts +2 -0
  248. package/dist/template/template-constants.d.ts.map +1 -1
  249. package/dist/template/template-constants.js +7 -0
  250. package/dist/template/template-constants.js.map +1 -1
  251. package/dist/template/template-definition.embedded.d.ts +3 -0
  252. package/dist/template/template-definition.embedded.d.ts.map +1 -0
  253. package/dist/template/template-definition.embedded.js +30 -0
  254. package/dist/template/template-definition.embedded.js.map +1 -0
  255. package/dist/validate-max-occurs.d.ts +5 -0
  256. package/dist/validate-max-occurs.d.ts.map +1 -0
  257. package/dist/validate-max-occurs.js +28 -0
  258. package/dist/validate-max-occurs.js.map +1 -0
  259. package/dist/validation-types.d.ts +36 -0
  260. package/dist/validation-types.d.ts.map +1 -0
  261. package/dist/validation-types.js +7 -0
  262. package/dist/validation-types.js.map +1 -0
  263. package/package.json +33 -22
  264. package/src/attr-schema-validate.ts +108 -8
  265. package/src/constraint-merge.ts +0 -0
  266. package/src/constraint-validate.ts +363 -0
  267. package/src/core/attr/attr-constants.ts +15 -3
  268. package/src/core/attr/attr-definition.embedded.ts +67 -0
  269. package/src/core/documentation/doc-constants.ts +3 -1
  270. package/src/core/documentation/doc-provider.ts +6 -2
  271. package/src/core/documentation/documentation-definition.embedded.ts +86 -0
  272. package/src/core/field/field-constants.ts +8 -7
  273. package/src/core/field/field-definition.embedded.ts +243 -0
  274. package/src/core/field/meta-field.ts +6 -7
  275. package/src/core/identity/identity-constants.ts +4 -0
  276. package/src/core/identity/identity-definition.embedded.ts +100 -0
  277. package/src/core/identity/meta-identity.ts +8 -1
  278. package/src/core/identity/validate-identity-passthrough.ts +194 -0
  279. package/src/core/object/object-constants.ts +3 -0
  280. package/src/core/object/object-definition.embedded.ts +117 -0
  281. package/src/core/object/validate-discriminator.ts +0 -4
  282. package/src/core/query/query-constants.ts +5 -3
  283. package/src/core/relationship/derive-m2m-fields.ts +145 -0
  284. package/src/core/relationship/meta-relationship.ts +15 -9
  285. package/src/core/relationship/relationship-constants.ts +6 -2
  286. package/src/core/relationship/relationship-definition.embedded.ts +317 -0
  287. package/src/core/validator/validator-constants.ts +22 -1
  288. package/src/core/validator/validator-definition.embedded.ts +262 -0
  289. package/src/core/yaml-desugar.ts +96 -7
  290. package/src/core-types.ts +314 -150
  291. package/src/errors.ts +89 -2
  292. package/src/index.ts +47 -2
  293. package/src/library/embedded-library.generated.ts +10 -0
  294. package/src/library/library-sources.ts +97 -0
  295. package/src/loader/meta-data-loader.ts +78 -7
  296. package/src/loader/shortcuts.ts +2 -2
  297. package/src/loader/validation-passes.ts +690 -34
  298. package/src/loader/validation-registry.ts +93 -0
  299. package/src/metamodel-docs/index.ts +41 -0
  300. package/src/metamodel-docs/provenance.ts +187 -0
  301. package/src/metamodel-docs/provider-definitions.ts +50 -0
  302. package/src/metamodel-docs/render.ts +309 -0
  303. package/src/naming-refs.ts +162 -0
  304. package/src/naming.ts +10 -2
  305. package/src/parser-core.ts +96 -9
  306. package/src/persistence/db/db-constants.ts +16 -0
  307. package/src/persistence/db/db-definition.embedded.ts +234 -0
  308. package/src/persistence/db/db-provider.ts +13 -18
  309. package/src/persistence/origin/origin-definition.embedded.ts +95 -0
  310. package/src/persistence/source/source-definition.embedded.ts +24 -0
  311. package/src/persistence/source/validate-source-parameter-ref.ts +7 -1
  312. package/src/persistence/source/validate-source-roles.ts +22 -1
  313. package/src/presentation/layout/layout-definition.embedded.ts +23 -0
  314. package/src/presentation/ui/ui-definition.embedded.ts +121 -0
  315. package/src/presentation/ui/ui-provider.ts +25 -0
  316. package/src/presentation/view/view-definition.embedded.ts +83 -0
  317. package/src/provider-data.ts +463 -0
  318. package/src/provider.ts +18 -0
  319. package/src/registry-coverage.ts +430 -0
  320. package/src/registry-manifest-exclusions.ts +176 -0
  321. package/src/registry-manifest.ts +334 -0
  322. package/src/registry.ts +106 -3
  323. package/src/shared/structural.ts +8 -0
  324. package/src/subtype-rules.ts +135 -18
  325. package/src/super-resolve.ts +153 -43
  326. package/src/template/meta-template.ts +3 -2
  327. package/src/template/prompt-definition.embedded.ts +375 -0
  328. package/src/template/prompt-provider.ts +29 -0
  329. package/src/template/template-constants.ts +8 -0
  330. package/src/template/template-definition.embedded.ts +37 -0
  331. package/src/validate-max-occurs.ts +39 -0
  332. package/src/validation-types.ts +57 -0
  333. package/dist/core/documentation/doc-schema.d.ts +0 -8
  334. package/dist/core/documentation/doc-schema.d.ts.map +0 -1
  335. package/dist/core/documentation/doc-schema.js +0 -53
  336. package/dist/core/documentation/doc-schema.js.map +0 -1
  337. package/dist/core/field/field-schema.d.ts +0 -22
  338. package/dist/core/field/field-schema.d.ts.map +0 -1
  339. package/dist/core/field/field-schema.js +0 -171
  340. package/dist/core/field/field-schema.js.map +0 -1
  341. package/dist/core/identity/identity-schema.d.ts +0 -6
  342. package/dist/core/identity/identity-schema.d.ts.map +0 -1
  343. package/dist/core/identity/identity-schema.js +0 -55
  344. package/dist/core/identity/identity-schema.js.map +0 -1
  345. package/dist/core/object/object-schema.d.ts +0 -4
  346. package/dist/core/object/object-schema.d.ts.map +0 -1
  347. package/dist/core/object/object-schema.js +0 -28
  348. package/dist/core/object/object-schema.js.map +0 -1
  349. package/dist/core/relationship/relationship-schema.d.ts +0 -4
  350. package/dist/core/relationship/relationship-schema.d.ts.map +0 -1
  351. package/dist/core/relationship/relationship-schema.js +0 -51
  352. package/dist/core/relationship/relationship-schema.js.map +0 -1
  353. package/dist/core/validator/validator-schema.d.ts +0 -4
  354. package/dist/core/validator/validator-schema.d.ts.map +0 -1
  355. package/dist/core/validator/validator-schema.js +0 -38
  356. package/dist/core/validator/validator-schema.js.map +0 -1
  357. package/dist/persistence/db/db-schema.d.ts +0 -14
  358. package/dist/persistence/db/db-schema.d.ts.map +0 -1
  359. package/dist/persistence/db/db-schema.js +0 -35
  360. package/dist/persistence/db/db-schema.js.map +0 -1
  361. package/dist/persistence/origin/origin-schema.d.ts +0 -4
  362. package/dist/persistence/origin/origin-schema.d.ts.map +0 -1
  363. package/dist/persistence/origin/origin-schema.js +0 -59
  364. package/dist/persistence/origin/origin-schema.js.map +0 -1
  365. package/dist/persistence/source/source-schema.d.ts +0 -4
  366. package/dist/persistence/source/source-schema.d.ts.map +0 -1
  367. package/dist/persistence/source/source-schema.js +0 -98
  368. package/dist/persistence/source/source-schema.js.map +0 -1
  369. package/dist/presentation/layout/layout-schema.d.ts +0 -4
  370. package/dist/presentation/layout/layout-schema.d.ts.map +0 -1
  371. package/dist/presentation/layout/layout-schema.js +0 -46
  372. package/dist/presentation/layout/layout-schema.js.map +0 -1
  373. package/dist/presentation/view/view-schema.d.ts +0 -4
  374. package/dist/presentation/view/view-schema.d.ts.map +0 -1
  375. package/dist/presentation/view/view-schema.js +0 -15
  376. package/dist/presentation/view/view-schema.js.map +0 -1
  377. package/dist/template/template-schema.d.ts +0 -3
  378. package/dist/template/template-schema.d.ts.map +0 -1
  379. package/dist/template/template-schema.js +0 -173
  380. package/dist/template/template-schema.js.map +0 -1
  381. package/src/core/documentation/doc-schema.ts +0 -64
  382. package/src/core/field/field-schema.ts +0 -228
  383. package/src/core/identity/identity-schema.ts +0 -80
  384. package/src/core/object/object-schema.ts +0 -35
  385. package/src/core/relationship/relationship-schema.ts +0 -67
  386. package/src/core/validator/validator-schema.ts +0 -50
  387. package/src/persistence/db/db-schema.ts +0 -50
  388. package/src/persistence/origin/origin-schema.ts +0 -80
  389. package/src/persistence/source/source-schema.ts +0 -129
  390. package/src/presentation/layout/layout-schema.ts +0 -62
  391. package/src/presentation/view/view-schema.ts +0 -21
  392. package/src/template/template-schema.ts +0 -211
@@ -0,0 +1,463 @@
1
+ // FR-033 — provider definitions as declarative data.
2
+ //
3
+ // A provider's *declarative* metamodel definition (vocabulary + attr constraints
4
+ // + child cardinality + descriptions + rule prose) lives as data; the factory
5
+ // (behavior) is supplied separately. `defineProviderFromData` turns that data +
6
+ // a code-supplied factory map into the `TypeDefinition`s a provider passes to
7
+ // `registry.register()`. This is the data/code boundary: declarative facts and
8
+ // rule *prose* are data; factories, imperative validation, and codegen stay code.
9
+ //
10
+ // See spec/superpowers/specs/2026-06-13-metamodel-self-description-design.md §3 +
11
+ // §3.1 (the constraint model). This module implements Plan Task 1, Task 2, and
12
+ // the format half of Task 7.
13
+
14
+ import type { AttrSchema, ChildRule, TypeDefinition, TypeRegistry } from "./registry.js";
15
+ import { TypeId } from "./registry.js";
16
+ import type { AttrSubType } from "./core/attr/attr-constants.js";
17
+ import type { AttrValue, MetaData } from "./shared/meta-data.js";
18
+ import type { DataType } from "./data-type.js";
19
+ import { CHILD_RULE_WILDCARD } from "./shared/structural.js";
20
+ import { SUBTYPE_BASE } from "./shared/base-types.js";
21
+
22
+ /**
23
+ * A UNIFIED child requirement (spec §3.1). Every constraint on a type — both its
24
+ * structural children AND its attributes — is one of these entries in a single
25
+ * `children` list, distinguished by `type`:
26
+ *
27
+ * - an **attribute** is a `{ type: "attr", … }` entry. Its `subType` is the
28
+ * attr's value-type (a single subtype — never a list), `max` is always 1
29
+ * (single-valued; a list-valued attr sets `isArray: true`), and it carries the
30
+ * attr-only facets `default` / `allowedValues` / `isArray`.
31
+ * - a **structural child** (`field`/`identity`/`source`/`validator`/…) carries
32
+ * full cardinality (`min`/`max`, `max: null` = unbounded) and may admit any of
33
+ * several subtypes via a `subType` list.
34
+ *
35
+ * `type` / `subType` / `name` accept the `"*"` wildcard.
36
+ */
37
+ export interface ChildDef {
38
+ /** Child type, or `"*"` for any. For attrs this is the literal `"attr"`. */
39
+ type: string;
40
+ /**
41
+ * Child subtype: a single subtype, a list of admitted subtypes, or `"*"`.
42
+ * For an `attr` entry this is the attr's value-type and MUST be a single
43
+ * subtype (a list is invalid for attrs). Optional on an `attr` entry: an
44
+ * omitted `subType` declares a polymorphic/untyped attr (e.g. `@default`,
45
+ * whose value-type follows the owning field's subtype). A structural child
46
+ * always supplies a `subType` (or `"*"`).
47
+ */
48
+ subType?: string | readonly string[];
49
+ /** Child name, or `"*"` for any. */
50
+ name: string;
51
+ /** Cardinality lower bound. An attr is required iff `min >= 1`. */
52
+ min: number;
53
+ /** Cardinality upper bound; `null` = unbounded. For an attr this is 1. */
54
+ max: number | null;
55
+ /** Whether the child must carry an explicit name. */
56
+ named?: boolean;
57
+ description?: string;
58
+ /** Prose documenting the complex rules enforced in code. */
59
+ rules?: string;
60
+ /** An example value/usage, shown only in the provider detail page. */
61
+ example?: string;
62
+ /** Guidance on when to reach for this child/attr. */
63
+ whenToUse?: string;
64
+ // --- attr-only facets (carried on a `type: "attr"` entry) ---
65
+ /** Default value applied when the attr is absent. */
66
+ default?: unknown;
67
+ /** Closed enum of allowed values. */
68
+ allowedValues?: readonly unknown[];
69
+ /** Whether the attr is array-valued (the only way an attr's `max` may be > 1). */
70
+ isArray?: boolean;
71
+ }
72
+
73
+ /**
74
+ * A declarative type/subtype definition (spec §3). The `factory` is NOT here — it
75
+ * is code, supplied via the `FactoryMap`. An attribute is a `type: "attr"` entry
76
+ * inside `children`; structural children are the non-`"attr"` entries.
77
+ */
78
+ export interface TypeDef {
79
+ type: string;
80
+ subType: string;
81
+ description: string;
82
+ dataType?: string;
83
+ rules?: string;
84
+ example?: string;
85
+ whenToUse?: string;
86
+ /** Unified children list: attrs (`type: "attr"`) + structural children. */
87
+ children?: ChildDef[];
88
+ /** Child-side placement: the `type.subType`s under which this type is allowed. */
89
+ parents?: readonly string[];
90
+ /**
91
+ * FR-033 base-composition opt-in. When `true` (and this is a non-base subtype),
92
+ * the subtype additively inherits its `<type>.base`'s attrs (dedup by name) and
93
+ * childRules (dedup structurally) — letting the JSON declare per-type-universal
94
+ * rules once on `base`. Default/absent = OFF, so a subtype that deliberately
95
+ * declares FEWER attrs than base (e.g. `validator.required`, which wants no
96
+ * `min`/`max`) is never silently widened. Opted in per-subtype in S1; inert (no
97
+ * registered output change) under S0.
98
+ */
99
+ extendsBase?: boolean;
100
+ /**
101
+ * Max number of children of this `type.subType` permitted under one parent.
102
+ * `1` marks a singleton child (e.g. `identity.primary` — one per entity). The
103
+ * loader enforces it. A singleton is the ONLY place a static `defaultName` is
104
+ * safe (no sibling can collide), so `defaultName` is honored only when
105
+ * `maxOccurs === 1`. Absent = unbounded.
106
+ */
107
+ maxOccurs?: number;
108
+ /**
109
+ * Author-omittable name for a singleton child. When a node of this type is
110
+ * declared with no `name` AND `maxOccurs === 1`, the loader assigns
111
+ * `defaultName` (e.g. `identity.primary` → `"primary"`). Keeps the one-and-only
112
+ * node addressable (`Entity.primary`) without forcing a hand-written name.
113
+ */
114
+ defaultName?: string;
115
+ }
116
+
117
+ /**
118
+ * FR-033 S1.5 — a declarative `registry.extend` directive. A **concern** provider
119
+ * (db / ui / prompt) does NOT register new `type.subType`s; it ADDS attrs to types
120
+ * an upstream provider (core) already registered. This entry is the data form of a
121
+ * `registry.extend(type, sub, { attributes })` call: `subType` selects the target
122
+ * subtype(s) and `children` are the `type: "attr"` entries (→ `AttrSchema`) to add.
123
+ */
124
+ export interface ExtendDef {
125
+ /** Target type whose subtype(s) are extended (e.g. `"field"`, `"source"`). */
126
+ type: string;
127
+ /**
128
+ * Target subtype(s): a single subtype name, a LIST of subtype names, or the
129
+ * `"*"` wildcard (= every currently-registered subtype of `type`). Resolved at
130
+ * apply time against the registry.
131
+ */
132
+ subType: string | readonly string[];
133
+ /**
134
+ * Attrs to add to each resolved target. Concern providers add attrs only — these
135
+ * must all be `type: "attr"` entries (lowered via `toAttrSchema`). A structural
136
+ * child here is rejected (concern providers do not contribute child rules).
137
+ */
138
+ children: ChildDef[];
139
+ }
140
+
141
+ export interface ProviderDefinition {
142
+ /** Owning provider id (groups doc pages). */
143
+ provider: string;
144
+ /**
145
+ * The provider's type definitions. ONE entry may be the **universal** `*.*`
146
+ * entry (`type: "*", subType: "*"`): it is NOT a registered type — its named
147
+ * `attr` children are COMMON attributes (accepted on every node, registered via
148
+ * `registry.registerCommonAttrs`). Every other entry is a real `type.subType`.
149
+ * Optional — a concern (extends-only) provider declares no new types and may
150
+ * omit this entirely (it carries only `extends`).
151
+ */
152
+ types?: TypeDef[];
153
+ /**
154
+ * FR-033 S1.5 — DATA-DRIVEN `registry.extend` directives. A **concern** provider
155
+ * (db / ui / prompt) declares no new types; it reads its attrs from data and ADDS
156
+ * them to already-registered types via these entries. Applied AFTER `types` in
157
+ * `applyProviderDefinition`. Optional — a provider with only `types` is unaffected.
158
+ */
159
+ extends?: ExtendDef[];
160
+ }
161
+
162
+ /**
163
+ * The code half of the data/code boundary: a `"<type>.<subType>"` → factory map.
164
+ * The factory constructs the node instance; it stays code (behavior).
165
+ */
166
+ export type FactoryMap = Record<string, (typeId: TypeId, name: string) => MetaData>;
167
+
168
+ const ATTR_CHILD_TYPE = "attr";
169
+
170
+ /** Whether a `ChildDef` declares an attribute (vs a structural child). */
171
+ function isAttrChild(child: ChildDef): boolean {
172
+ return child.type === ATTR_CHILD_TYPE;
173
+ }
174
+
175
+ /**
176
+ * Whether a `TypeDef` is the UNIVERSAL `*.*` entry — the carrier for COMMON
177
+ * attributes (attrs accepted on EVERY node). It is NOT a real registered type;
178
+ * its named `attr` children are routed to `registry.registerCommonAttrs(...)` by
179
+ * the unified apply path. Documentation uses this; ordinary providers do not.
180
+ */
181
+ function isUniversalEntry(t: TypeDef): boolean {
182
+ return t.type === CHILD_RULE_WILDCARD && t.subType === CHILD_RULE_WILDCARD;
183
+ }
184
+
185
+ /**
186
+ * Turn a declarative `ProviderDefinition` + a code-supplied factory map into the
187
+ * `TypeDefinition`s a provider passes to `registry.register()`.
188
+ *
189
+ * For each real `TypeDef` (every entry EXCEPT the universal `*.*` entry, which
190
+ * carries common attrs and is handled by `applyProviderDefinition`): look up its
191
+ * factory (throws if missing); fan its `children` out so `type: "attr"` entries
192
+ * become `AttrSchema`s and structural entries become `ChildRule`s; carry `parents`
193
+ * and the optional `rules`/`example`/`whenToUse` doc fields through onto the
194
+ * returned `TypeDefinition`.
195
+ *
196
+ * BASE-COMPOSITION (FR-033): a non-base subtype that opts in via
197
+ * `extendsBase: true` additively inherits its `<type>.base`'s `attributes` (dedup
198
+ * by name) and `childRules` (dedup structurally) — letting a JSON declare
199
+ * universal-per-type rules once on `base`. Purely additive (a subtype's own
200
+ * declarations win on a name/shape collision). OFF by default so a subtype that
201
+ * deliberately declares fewer attrs than base is never widened — inert under S0
202
+ * (no provider opts in yet), the rail S1 will use.
203
+ *
204
+ * Builder-local validation (cheap, structural): an attr entry must be
205
+ * single-valued (`max === 1`) unless `isArray`; an attr entry's `subType` must be
206
+ * a single subtype (not a list); every child must have `min >= 0` and
207
+ * (`max === null || max >= min`).
208
+ */
209
+ export function defineProviderFromData(
210
+ data: ProviderDefinition,
211
+ factories: FactoryMap,
212
+ ): TypeDefinition[] {
213
+ // Pre-compute each type's OWN lowered attrs + childRules, keyed by "type.subType",
214
+ // so base-composition can fold a base's contributions into its subtypes. A
215
+ // concern (extends-only) provider may omit `types` entirely.
216
+ const realTypes = (data.types ?? []).filter((t) => !isUniversalEntry(t));
217
+ const lowered = new Map<
218
+ string,
219
+ { attributes: AttrSchema[]; childRules: ChildRule[] }
220
+ >();
221
+
222
+ for (const t of realTypes) {
223
+ const key = `${t.type}.${t.subType}`;
224
+ const attributes: AttrSchema[] = [];
225
+ const childRules: ChildRule[] = [];
226
+ for (const child of t.children ?? []) {
227
+ validateCardinality(data.provider, key, child);
228
+ if (isAttrChild(child)) {
229
+ attributes.push(toAttrSchema(data.provider, key, child));
230
+ } else {
231
+ childRules.push(toChildRule(child));
232
+ }
233
+ }
234
+ lowered.set(key, { attributes, childRules });
235
+ }
236
+
237
+ return realTypes.map((t): TypeDefinition => {
238
+ const key = `${t.type}.${t.subType}`;
239
+ const factory = factories[key];
240
+ if (factory === undefined) {
241
+ throw new Error(`defineProviderFromData(${data.provider}): no factory for "${key}"`);
242
+ }
243
+
244
+ const self = lowered.get(key)!;
245
+ const { attributes, childRules } = composeWithBase(t, self, lowered);
246
+
247
+ return {
248
+ typeId: new TypeId(t.type, t.subType),
249
+ description: t.description,
250
+ factory,
251
+ childRules,
252
+ attributes,
253
+ ...(t.dataType !== undefined ? { dataType: t.dataType as DataType } : {}),
254
+ ...(t.parents !== undefined ? { parents: t.parents } : {}),
255
+ ...(t.rules !== undefined ? { rules: t.rules } : {}),
256
+ ...(t.example !== undefined ? { example: t.example } : {}),
257
+ ...(t.whenToUse !== undefined ? { whenToUse: t.whenToUse } : {}),
258
+ ...(t.maxOccurs !== undefined ? { maxOccurs: t.maxOccurs } : {}),
259
+ ...(t.defaultName !== undefined ? { defaultName: t.defaultName } : {}),
260
+ };
261
+ });
262
+ }
263
+
264
+ /**
265
+ * Apply a `ProviderDefinition` to a registry via the ONE uniform path: register
266
+ * every real `type.subType` (with base-composition) AND register the universal
267
+ * `*.*` entry's named `attr` children as COMMON attrs. This replaces the bespoke
268
+ * `commonAttrs` helper — documentation rides the same mechanism as every other
269
+ * provider.
270
+ */
271
+ export function applyProviderDefinition(
272
+ registry: TypeRegistry,
273
+ data: ProviderDefinition,
274
+ factories: FactoryMap,
275
+ ): void {
276
+ for (const def of defineProviderFromData(data, factories)) {
277
+ registry.register(def);
278
+ }
279
+ const commonAttrs = universalCommonAttrs(data);
280
+ if (commonAttrs.length > 0) {
281
+ registry.registerCommonAttrs(commonAttrs);
282
+ }
283
+ applyExtends(registry, data);
284
+ }
285
+
286
+ /**
287
+ * Apply a definition's `extends` directives (FR-033 S1.5) via `registry.extend`.
288
+ * For each directive: resolve the target subtypes (`"*"` → every registered subtype
289
+ * of the type; a list → each named subtype; a string → that one), lower its `attr`
290
+ * children to `AttrSchema[]`, and `registry.extend(type, sub, { attributes })`.
291
+ * Concern providers contribute attrs only — a non-`attr` child is rejected.
292
+ */
293
+ function applyExtends(registry: TypeRegistry, data: ProviderDefinition): void {
294
+ for (const ext of data.extends ?? []) {
295
+ const attributes: AttrSchema[] = [];
296
+ for (const child of ext.children) {
297
+ if (!isAttrChild(child)) {
298
+ throw new Error(
299
+ `applyProviderDefinition(${data.provider}): extends "${ext.type}" may only carry attr ` +
300
+ `children; found a structural child "${child.type}".`,
301
+ );
302
+ }
303
+ validateCardinality(data.provider, ext.type, child);
304
+ attributes.push(toAttrSchema(data.provider, ext.type, child));
305
+ }
306
+ for (const subType of resolveExtendSubTypes(registry, ext)) {
307
+ registry.extend(ext.type, subType, { attributes });
308
+ }
309
+ }
310
+ }
311
+
312
+ /**
313
+ * Resolve an `ExtendDef`'s `subType` selector to concrete subtype names:
314
+ * - `"*"` → every currently-registered subtype of `ext.type`;
315
+ * - a list → each named subtype, in declared order;
316
+ * - a single string → that one subtype.
317
+ */
318
+ function resolveExtendSubTypes(registry: TypeRegistry, ext: ExtendDef): readonly string[] {
319
+ if (ext.subType === CHILD_RULE_WILDCARD) {
320
+ return registry.allSubTypesOf(ext.type);
321
+ }
322
+ return Array.isArray(ext.subType) ? ext.subType : [ext.subType as string];
323
+ }
324
+
325
+ /**
326
+ * Lower the universal `*.*` entry's named `attr` children into `AttrSchema[]` for
327
+ * `registry.registerCommonAttrs(...)`. Returns `[]` when no `*.*` entry is present.
328
+ * Same field mapping as `toAttrSchema`. Exported for callers that register common
329
+ * attrs themselves; `applyProviderDefinition` is the usual door.
330
+ */
331
+ export function universalCommonAttrs(data: ProviderDefinition): AttrSchema[] {
332
+ const universal = (data.types ?? []).find(isUniversalEntry);
333
+ if (universal === undefined) return [];
334
+ const key = `${universal.type}.${universal.subType}`;
335
+ const out: AttrSchema[] = [];
336
+ for (const child of universal.children ?? []) {
337
+ if (!isAttrChild(child)) {
338
+ throw new Error(
339
+ `applyProviderDefinition(${data.provider}): the universal "${key}" entry may only ` +
340
+ `carry attr children (common attrs); found a structural child "${child.type}".`,
341
+ );
342
+ }
343
+ validateCardinality(data.provider, key, child);
344
+ out.push(toAttrSchema(data.provider, key, child));
345
+ }
346
+ return out;
347
+ }
348
+
349
+ /**
350
+ * Fold a real `TypeDef`'s OWN lowered attrs/childRules with its `<type>.base`'s
351
+ * (when the definition declares one and this subtype is not itself `base`).
352
+ * Additive: own entries win on a name (attr) / structural-shape (rule) collision;
353
+ * base entries the subtype lacks are appended. A NO-OP when there is no base in
354
+ * THIS definition, or when the subtype already declares the full base set.
355
+ */
356
+ function composeWithBase(
357
+ t: TypeDef,
358
+ self: { attributes: AttrSchema[]; childRules: ChildRule[] },
359
+ lowered: Map<string, { attributes: AttrSchema[]; childRules: ChildRule[] }>,
360
+ ): { attributes: AttrSchema[]; childRules: ChildRule[] } {
361
+ // OFF by default (S0): a subtype inherits its base only when it opts in via
362
+ // `extendsBase: true`. Keeps the current canonical byte-identical — no provider
363
+ // sets it yet — while the rail is in place for S1.
364
+ if (t.extendsBase !== true) return self;
365
+ if (t.subType === SUBTYPE_BASE) return self;
366
+ const base = lowered.get(`${t.type}.${SUBTYPE_BASE}`);
367
+ if (base === undefined) return self;
368
+
369
+ const attributes = [...self.attributes];
370
+ const haveAttr = new Set(attributes.map((a) => a.name));
371
+ for (const baseAttr of base.attributes) {
372
+ if (!haveAttr.has(baseAttr.name)) {
373
+ attributes.push(baseAttr);
374
+ haveAttr.add(baseAttr.name);
375
+ }
376
+ }
377
+
378
+ const childRules = [...self.childRules];
379
+ const haveRule = new Set(childRules.map(childRuleId));
380
+ for (const baseRule of base.childRules) {
381
+ const id = childRuleId(baseRule);
382
+ if (!haveRule.has(id)) {
383
+ childRules.push(baseRule);
384
+ haveRule.add(id);
385
+ }
386
+ }
387
+
388
+ return { attributes, childRules };
389
+ }
390
+
391
+ /** A stable structural identity for a ChildRule (base-composition dedup). */
392
+ function childRuleId(rule: ChildRule): string {
393
+ const sub =
394
+ typeof rule.childSubType === "string"
395
+ ? rule.childSubType
396
+ : [...rule.childSubType].sort().join("|");
397
+ return [
398
+ rule.childType,
399
+ sub,
400
+ rule.childName,
401
+ rule.min ?? "",
402
+ rule.max === null ? "null" : (rule.max ?? ""),
403
+ rule.named ?? "",
404
+ ].join(" ");
405
+ }
406
+
407
+ /** Validate the min/max axis (and attr single-valuedness) for one child entry. */
408
+ function validateCardinality(provider: string, typeKey: string, child: ChildDef): void {
409
+ if (child.min < 0) {
410
+ throw new Error(
411
+ `defineProviderFromData(${provider}): child "${child.name}" on "${typeKey}" has min ${child.min} < 0.`,
412
+ );
413
+ }
414
+ if (child.max !== null && child.max < child.min) {
415
+ throw new Error(
416
+ `defineProviderFromData(${provider}): child "${child.name}" on "${typeKey}" has max ${child.max} < min ${child.min}.`,
417
+ );
418
+ }
419
+ if (isAttrChild(child) && child.max !== 1 && child.isArray !== true) {
420
+ throw new Error(
421
+ `defineProviderFromData(${provider}): attr "${child.name}" on "${typeKey}" is single-valued ` +
422
+ `(max must be 1; a list-valued attr sets isArray: true).`,
423
+ );
424
+ }
425
+ }
426
+
427
+ /** An `type: "attr"` child entry IS an `AttrSchema`. */
428
+ function toAttrSchema(provider: string, typeKey: string, child: ChildDef): AttrSchema {
429
+ if (Array.isArray(child.subType)) {
430
+ throw new Error(
431
+ `defineProviderFromData(${provider}): attr "${child.name}" on "${typeKey}" declares a list subType ` +
432
+ `— an attr's value-type is a single subtype.`,
433
+ );
434
+ }
435
+ return {
436
+ name: child.name,
437
+ ...(child.subType !== undefined ? { valueType: child.subType as AttrSubType } : {}),
438
+ ...(child.isArray !== undefined ? { isArray: child.isArray } : {}),
439
+ required: child.min >= 1,
440
+ ...(child.default !== undefined ? { default: child.default as AttrValue } : {}),
441
+ ...(child.allowedValues !== undefined
442
+ ? { allowedValues: child.allowedValues as readonly AttrValue[] }
443
+ : {}),
444
+ description: child.description ?? "",
445
+ ...(child.rules !== undefined ? { rules: child.rules } : {}),
446
+ ...(child.example !== undefined ? { example: child.example } : {}),
447
+ ...(child.whenToUse !== undefined ? { whenToUse: child.whenToUse } : {}),
448
+ };
449
+ }
450
+
451
+ /** A structural (`type !== "attr"`) child entry IS a `ChildRule`. */
452
+ function toChildRule(child: ChildDef): ChildRule {
453
+ return {
454
+ childType: child.type,
455
+ // A structural child always supplies a subType; default to the `"*"`
456
+ // wildcard if (unusually) omitted, so the rule stays well-formed.
457
+ childSubType: child.subType ?? CHILD_RULE_WILDCARD,
458
+ childName: child.name,
459
+ min: child.min,
460
+ max: child.max,
461
+ ...(child.named !== undefined ? { named: child.named } : {}),
462
+ };
463
+ }
package/src/provider.ts CHANGED
@@ -7,6 +7,8 @@
7
7
 
8
8
  import { TypeRegistry } from "./registry.js";
9
9
  import { MetaModelError } from "./errors.js";
10
+ import { mergeConstraints } from "./constraint-merge.js";
11
+ import { validateConstraints } from "./constraint-validate.js";
10
12
 
11
13
  /** A unit of metamodel registration. One provider per package. */
12
14
  export interface MetaDataTypeProvider {
@@ -28,12 +30,28 @@ export interface MetaDataTypeProvider {
28
30
  */
29
31
  export function composeRegistry(
30
32
  providers: readonly MetaDataTypeProvider[],
33
+ opts?: { validate?: boolean },
31
34
  ): TypeRegistry {
32
35
  const ordered = topoSortProviders(providers);
33
36
  const registry = new TypeRegistry();
34
37
  for (const provider of ordered) {
35
38
  provider.registerTypes(registry);
36
39
  }
40
+ // FR-033 — opt-in metamodel contradiction gate. The library bootstrap (the
41
+ // loader's default registry) sets validate:true so a contradictory provider set
42
+ // fails fast at bootstrap (mirrors ADR-0023 strictness). Off by default so
43
+ // synthetic/partial registries (tests, incremental composition) are unaffected.
44
+ if (opts?.validate === true) {
45
+ const contradictions = validateConstraints(mergeConstraints(registry), registry);
46
+ if (contradictions.length > 0) {
47
+ throw new MetaModelError(
48
+ `composeRegistry: the provider set has ${contradictions.length} metamodel ` +
49
+ `constraint contradiction(s) (FR-033):\n` +
50
+ contradictions.map((e) => ` - ${e.message}`).join("\n"),
51
+ { code: "ERR_INVALID_METAMODEL_CONSTRAINT" },
52
+ );
53
+ }
54
+ }
37
55
  return registry;
38
56
  }
39
57