@linked.archi/kernel 0.0.0-stage → 0.1.5

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 (365) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +11 -0
  3. package/README.md +96 -2
  4. package/assets/arch-decision/arch-decision-metamodel.ttl +44 -0
  5. package/assets/arch-decision/arch-decision-onto.ttl +1566 -0
  6. package/assets/arch-decision/arch-decision-shapes.ttl +582 -0
  7. package/assets/arch-decision/arch-decision-tax.ttl +129 -0
  8. package/assets/arch-processes/arch-processes-metamodel.ttl +42 -0
  9. package/assets/arch-processes/arch-processes-tax.ttl +136 -0
  10. package/assets/arch-processes/archProcesses-shapes.ttl +189 -0
  11. package/assets/arch-processes/archProcesses.ttl +953 -0
  12. package/assets/archimate3/archimate3.2-element-shapes.ttl +379 -0
  13. package/assets/archimate3/archimate3.2-metamodel.ttl +205 -0
  14. package/assets/archimate3/archimate3.2-notation.ttl +1503 -0
  15. package/assets/archimate3/archimate3.2-onto.ttl +1579 -0
  16. package/assets/archimate3/archimate3.2-presentation-contexts.ttl +90 -0
  17. package/assets/archimate3/archimate3.2-principle-shapes.ttl +923 -0
  18. package/assets/archimate3/archimate3.2-questions.ttl +1125 -0
  19. package/assets/archimate3/archimate3.2-reference-data.ttl +74 -0
  20. package/assets/archimate3/archimate3.2-relationship-shapes.ttl +30956 -0
  21. package/assets/archimate3/archimate3.2-relationship-tables.ttl +5992 -0
  22. package/assets/archimate3/archimate3.2-tax.ttl +724 -0
  23. package/assets/archimate3/archimate3.2-viewpoint-shapes.ttl +59 -0
  24. package/assets/archimate3/archimate3.2-viewpoints.ttl +793 -0
  25. package/assets/archimate3/icons/and-junction.svg +3 -0
  26. package/assets/archimate3/icons/application-collaboration.svg +22 -0
  27. package/assets/archimate3/icons/application-component.svg +18 -0
  28. package/assets/archimate3/icons/application-event.svg +15 -0
  29. package/assets/archimate3/icons/application-function.svg +14 -0
  30. package/assets/archimate3/icons/application-interaction.svg +17 -0
  31. package/assets/archimate3/icons/application-interface.svg +16 -0
  32. package/assets/archimate3/icons/application-process.svg +14 -0
  33. package/assets/archimate3/icons/application-service.svg +14 -0
  34. package/assets/archimate3/icons/artifact.svg +16 -0
  35. package/assets/archimate3/icons/assessment.svg +17 -0
  36. package/assets/archimate3/icons/business-actor.svg +22 -0
  37. package/assets/archimate3/icons/business-collaboration.svg +21 -0
  38. package/assets/archimate3/icons/business-event.svg +15 -0
  39. package/assets/archimate3/icons/business-function.svg +14 -0
  40. package/assets/archimate3/icons/business-interaction.svg +18 -0
  41. package/assets/archimate3/icons/business-interface.svg +16 -0
  42. package/assets/archimate3/icons/business-object.svg +14 -0
  43. package/assets/archimate3/icons/business-process.svg +15 -0
  44. package/assets/archimate3/icons/business-role.svg +16 -0
  45. package/assets/archimate3/icons/business-service.svg +14 -0
  46. package/assets/archimate3/icons/capability.svg +40 -0
  47. package/assets/archimate3/icons/communication-network.svg +18 -0
  48. package/assets/archimate3/icons/constraint.svg +18 -0
  49. package/assets/archimate3/icons/contract.svg +13 -0
  50. package/assets/archimate3/icons/course-of-action.svg +20 -0
  51. package/assets/archimate3/icons/data-object.svg +14 -0
  52. package/assets/archimate3/icons/deliverable.svg +11 -0
  53. package/assets/archimate3/icons/device.svg +18 -0
  54. package/assets/archimate3/icons/distribution-network.svg +19 -0
  55. package/assets/archimate3/icons/driver.svg +24 -0
  56. package/assets/archimate3/icons/equipment.svg +31 -0
  57. package/assets/archimate3/icons/facility.svg +16 -0
  58. package/assets/archimate3/icons/gap.svg +22 -0
  59. package/assets/archimate3/icons/glyphs/activity.svg +3 -0
  60. package/assets/archimate3/icons/glyphs/actor.svg +14 -0
  61. package/assets/archimate3/icons/glyphs/application-component.svg +12 -0
  62. package/assets/archimate3/icons/glyphs/artifact.svg +9 -0
  63. package/assets/archimate3/icons/glyphs/assessment.svg +9 -0
  64. package/assets/archimate3/icons/glyphs/capability.svg +32 -0
  65. package/assets/archimate3/icons/glyphs/cloud-gear.svg +3 -0
  66. package/assets/archimate3/icons/glyphs/collaboration.svg +15 -0
  67. package/assets/archimate3/icons/glyphs/communication-network.svg +12 -0
  68. package/assets/archimate3/icons/glyphs/constraint.svg +10 -0
  69. package/assets/archimate3/icons/glyphs/contract.svg +5 -0
  70. package/assets/archimate3/icons/glyphs/course-of-action.svg +12 -0
  71. package/assets/archimate3/icons/glyphs/data-object.svg +4 -0
  72. package/assets/archimate3/icons/glyphs/deliverable.svg +3 -0
  73. package/assets/archimate3/icons/glyphs/device.svg +10 -0
  74. package/assets/archimate3/icons/glyphs/distribution-network.svg +11 -0
  75. package/assets/archimate3/icons/glyphs/driver.svg +16 -0
  76. package/assets/archimate3/icons/glyphs/equipment.svg +22 -0
  77. package/assets/archimate3/icons/glyphs/event.svg +6 -0
  78. package/assets/archimate3/icons/glyphs/facility.svg +7 -0
  79. package/assets/archimate3/icons/glyphs/function.svg +6 -0
  80. package/assets/archimate3/icons/glyphs/gap.svg +14 -0
  81. package/assets/archimate3/icons/glyphs/goal.svg +10 -0
  82. package/assets/archimate3/icons/glyphs/grouping.svg +4 -0
  83. package/assets/archimate3/icons/glyphs/interaction.svg +10 -0
  84. package/assets/archimate3/icons/glyphs/interface.svg +8 -0
  85. package/assets/archimate3/icons/glyphs/location.svg +6 -0
  86. package/assets/archimate3/icons/glyphs/material.svg +12 -0
  87. package/assets/archimate3/icons/glyphs/meaning.svg +3 -0
  88. package/assets/archimate3/icons/glyphs/node.svg +8 -0
  89. package/assets/archimate3/icons/glyphs/object.svg +4 -0
  90. package/assets/archimate3/icons/glyphs/outcome.svg +16 -0
  91. package/assets/archimate3/icons/glyphs/path.svg +10 -0
  92. package/assets/archimate3/icons/glyphs/person-silhouette.svg +3 -0
  93. package/assets/archimate3/icons/glyphs/plateau.svg +8 -0
  94. package/assets/archimate3/icons/glyphs/principle.svg +12 -0
  95. package/assets/archimate3/icons/glyphs/process.svg +6 -0
  96. package/assets/archimate3/icons/glyphs/product.svg +4 -0
  97. package/assets/archimate3/icons/glyphs/representation.svg +4 -0
  98. package/assets/archimate3/icons/glyphs/requirement.svg +6 -0
  99. package/assets/archimate3/icons/glyphs/resource.svg +14 -0
  100. package/assets/archimate3/icons/glyphs/role.svg +6 -0
  101. package/assets/archimate3/icons/glyphs/service.svg +6 -0
  102. package/assets/archimate3/icons/glyphs/stakeholder.svg +6 -0
  103. package/assets/archimate3/icons/glyphs/system-software.svg +14 -0
  104. package/assets/archimate3/icons/glyphs/value-stream.svg +3 -0
  105. package/assets/archimate3/icons/glyphs/value.svg +3 -0
  106. package/assets/archimate3/icons/glyphs/work-package.svg +4 -0
  107. package/assets/archimate3/icons/goal.svg +18 -0
  108. package/assets/archimate3/icons/grouping.svg +12 -0
  109. package/assets/archimate3/icons/implementation-event.svg +15 -0
  110. package/assets/archimate3/icons/location.svg +14 -0
  111. package/assets/archimate3/icons/material.svg +21 -0
  112. package/assets/archimate3/icons/meaning.svg +11 -0
  113. package/assets/archimate3/icons/node.svg +14 -0
  114. package/assets/archimate3/icons/or-junction.svg +3 -0
  115. package/assets/archimate3/icons/outcome.svg +25 -0
  116. package/assets/archimate3/icons/path.svg +18 -0
  117. package/assets/archimate3/icons/plateau.svg +16 -0
  118. package/assets/archimate3/icons/principle.svg +21 -0
  119. package/assets/archimate3/icons/product.svg +12 -0
  120. package/assets/archimate3/icons/representation.svg +12 -0
  121. package/assets/archimate3/icons/requirement.svg +14 -0
  122. package/assets/archimate3/icons/resource.svg +23 -0
  123. package/assets/archimate3/icons/stakeholder.svg +15 -0
  124. package/assets/archimate3/icons/system-software.svg +22 -0
  125. package/assets/archimate3/icons/technology-collaboration.svg +22 -0
  126. package/assets/archimate3/icons/technology-event.svg +15 -0
  127. package/assets/archimate3/icons/technology-function.svg +14 -0
  128. package/assets/archimate3/icons/technology-interaction.svg +18 -0
  129. package/assets/archimate3/icons/technology-interface.svg +16 -0
  130. package/assets/archimate3/icons/technology-process.svg +14 -0
  131. package/assets/archimate3/icons/technology-service.svg +14 -0
  132. package/assets/archimate3/icons/value-stream.svg +11 -0
  133. package/assets/archimate3/icons/value.svg +11 -0
  134. package/assets/archimate3/icons/work-package.svg +12 -0
  135. package/assets/archimate4/archimate4-element-shapes.ttl +404 -0
  136. package/assets/archimate4/archimate4-metamodel.ttl +179 -0
  137. package/assets/archimate4/archimate4-notation.ttl +1147 -0
  138. package/assets/archimate4/archimate4-onto.ttl +1559 -0
  139. package/assets/archimate4/archimate4-presentation-contexts.ttl +60 -0
  140. package/assets/archimate4/archimate4-principle-shapes.ttl +893 -0
  141. package/assets/archimate4/archimate4-questions.ttl +1224 -0
  142. package/assets/archimate4/archimate4-reference-data.ttl +56 -0
  143. package/assets/archimate4/archimate4-relationship-shapes.ttl +16920 -0
  144. package/assets/archimate4/archimate4-relationship-tables.ttl +3200 -0
  145. package/assets/archimate4/archimate4-tax.ttl +749 -0
  146. package/assets/archimate4/archimate4-viewpoint-shapes.ttl +55 -0
  147. package/assets/archimate4/archimate4-viewpoints.ttl +777 -0
  148. package/assets/archimate4/icons/and-junction.svg +3 -0
  149. package/assets/archimate4/icons/application-component.svg +18 -0
  150. package/assets/archimate4/icons/application-interface.svg +16 -0
  151. package/assets/archimate4/icons/artifact.svg +16 -0
  152. package/assets/archimate4/icons/assessment.svg +17 -0
  153. package/assets/archimate4/icons/business-actor.svg +22 -0
  154. package/assets/archimate4/icons/business-interface.svg +16 -0
  155. package/assets/archimate4/icons/business-object.svg +14 -0
  156. package/assets/archimate4/icons/capability.svg +40 -0
  157. package/assets/archimate4/icons/collaboration.svg +21 -0
  158. package/assets/archimate4/icons/communication-network.svg +18 -0
  159. package/assets/archimate4/icons/course-of-action.svg +20 -0
  160. package/assets/archimate4/icons/data-object.svg +14 -0
  161. package/assets/archimate4/icons/deliverable.svg +11 -0
  162. package/assets/archimate4/icons/device.svg +18 -0
  163. package/assets/archimate4/icons/distribution-network.svg +19 -0
  164. package/assets/archimate4/icons/driver.svg +24 -0
  165. package/assets/archimate4/icons/equipment.svg +31 -0
  166. package/assets/archimate4/icons/event.svg +15 -0
  167. package/assets/archimate4/icons/facility.svg +16 -0
  168. package/assets/archimate4/icons/function.svg +13 -0
  169. package/assets/archimate4/icons/glyphs/activity.svg +3 -0
  170. package/assets/archimate4/icons/glyphs/actor.svg +14 -0
  171. package/assets/archimate4/icons/glyphs/application-component.svg +12 -0
  172. package/assets/archimate4/icons/glyphs/artifact.svg +9 -0
  173. package/assets/archimate4/icons/glyphs/assessment.svg +9 -0
  174. package/assets/archimate4/icons/glyphs/capability.svg +32 -0
  175. package/assets/archimate4/icons/glyphs/cloud-gear.svg +3 -0
  176. package/assets/archimate4/icons/glyphs/collaboration.svg +15 -0
  177. package/assets/archimate4/icons/glyphs/communication-network.svg +12 -0
  178. package/assets/archimate4/icons/glyphs/constraint.svg +10 -0
  179. package/assets/archimate4/icons/glyphs/contract.svg +5 -0
  180. package/assets/archimate4/icons/glyphs/course-of-action.svg +12 -0
  181. package/assets/archimate4/icons/glyphs/data-object.svg +4 -0
  182. package/assets/archimate4/icons/glyphs/deliverable.svg +3 -0
  183. package/assets/archimate4/icons/glyphs/device.svg +10 -0
  184. package/assets/archimate4/icons/glyphs/distribution-network.svg +11 -0
  185. package/assets/archimate4/icons/glyphs/driver.svg +16 -0
  186. package/assets/archimate4/icons/glyphs/equipment.svg +22 -0
  187. package/assets/archimate4/icons/glyphs/event.svg +6 -0
  188. package/assets/archimate4/icons/glyphs/facility.svg +7 -0
  189. package/assets/archimate4/icons/glyphs/function.svg +6 -0
  190. package/assets/archimate4/icons/glyphs/gap.svg +14 -0
  191. package/assets/archimate4/icons/glyphs/goal.svg +10 -0
  192. package/assets/archimate4/icons/glyphs/grouping.svg +4 -0
  193. package/assets/archimate4/icons/glyphs/interaction.svg +10 -0
  194. package/assets/archimate4/icons/glyphs/interface.svg +8 -0
  195. package/assets/archimate4/icons/glyphs/location.svg +6 -0
  196. package/assets/archimate4/icons/glyphs/material.svg +12 -0
  197. package/assets/archimate4/icons/glyphs/meaning.svg +3 -0
  198. package/assets/archimate4/icons/glyphs/node.svg +8 -0
  199. package/assets/archimate4/icons/glyphs/object.svg +4 -0
  200. package/assets/archimate4/icons/glyphs/outcome.svg +16 -0
  201. package/assets/archimate4/icons/glyphs/path.svg +10 -0
  202. package/assets/archimate4/icons/glyphs/person-silhouette.svg +3 -0
  203. package/assets/archimate4/icons/glyphs/plateau.svg +8 -0
  204. package/assets/archimate4/icons/glyphs/principle.svg +12 -0
  205. package/assets/archimate4/icons/glyphs/process.svg +6 -0
  206. package/assets/archimate4/icons/glyphs/product.svg +4 -0
  207. package/assets/archimate4/icons/glyphs/representation.svg +4 -0
  208. package/assets/archimate4/icons/glyphs/requirement.svg +6 -0
  209. package/assets/archimate4/icons/glyphs/resource.svg +14 -0
  210. package/assets/archimate4/icons/glyphs/role.svg +6 -0
  211. package/assets/archimate4/icons/glyphs/service.svg +6 -0
  212. package/assets/archimate4/icons/glyphs/stakeholder.svg +6 -0
  213. package/assets/archimate4/icons/glyphs/system-software.svg +14 -0
  214. package/assets/archimate4/icons/glyphs/value-stream.svg +3 -0
  215. package/assets/archimate4/icons/glyphs/value.svg +3 -0
  216. package/assets/archimate4/icons/glyphs/work-package.svg +4 -0
  217. package/assets/archimate4/icons/goal.svg +18 -0
  218. package/assets/archimate4/icons/grouping.svg +12 -0
  219. package/assets/archimate4/icons/location.svg +14 -0
  220. package/assets/archimate4/icons/material.svg +21 -0
  221. package/assets/archimate4/icons/meaning.svg +11 -0
  222. package/assets/archimate4/icons/node.svg +14 -0
  223. package/assets/archimate4/icons/or-junction.svg +3 -0
  224. package/assets/archimate4/icons/outcome.svg +25 -0
  225. package/assets/archimate4/icons/path.svg +18 -0
  226. package/assets/archimate4/icons/plateau.svg +16 -0
  227. package/assets/archimate4/icons/principle.svg +21 -0
  228. package/assets/archimate4/icons/process.svg +15 -0
  229. package/assets/archimate4/icons/product.svg +12 -0
  230. package/assets/archimate4/icons/requirement.svg +14 -0
  231. package/assets/archimate4/icons/resource.svg +23 -0
  232. package/assets/archimate4/icons/role.svg +16 -0
  233. package/assets/archimate4/icons/service.svg +13 -0
  234. package/assets/archimate4/icons/stakeholder.svg +15 -0
  235. package/assets/archimate4/icons/system-software.svg +22 -0
  236. package/assets/archimate4/icons/technology-interface.svg +16 -0
  237. package/assets/archimate4/icons/value-stream.svg +11 -0
  238. package/assets/archimate4/icons/value.svg +11 -0
  239. package/assets/archimate4/icons/work-package.svg +12 -0
  240. package/assets/basic/basic-metamodel.ttl +100 -0
  241. package/assets/basic/basic-notation-bubble.ttl +175 -0
  242. package/assets/basic/basic-notation.ttl +172 -0
  243. package/assets/basic/basic-onto.ttl +171 -0
  244. package/assets/basic/basic-presentation-contexts.ttl +70 -0
  245. package/assets/basic/basic-tax.ttl +130 -0
  246. package/assets/basic/icons/aggregation.svg +7 -0
  247. package/assets/basic/icons/association.svg +6 -0
  248. package/assets/basic/icons/element.svg +5 -0
  249. package/assets/basic/icons/glyphs/aggregation.svg +6 -0
  250. package/assets/basic/icons/glyphs/association.svg +5 -0
  251. package/assets/basic/icons/glyphs/element.svg +5 -0
  252. package/assets/basic/icons/glyphs/relationship.svg +5 -0
  253. package/assets/basic/icons/relationship.svg +7 -0
  254. package/assets/basic/notation-bubble/icons/aggregation.svg +7 -0
  255. package/assets/basic/notation-bubble/icons/association.svg +6 -0
  256. package/assets/basic/notation-bubble/icons/element.svg +5 -0
  257. package/assets/basic/notation-bubble/icons/glyphs/aggregation.svg +6 -0
  258. package/assets/basic/notation-bubble/icons/glyphs/association.svg +5 -0
  259. package/assets/basic/notation-bubble/icons/glyphs/element.svg +5 -0
  260. package/assets/basic/notation-bubble/icons/glyphs/relationship.svg +5 -0
  261. package/assets/basic/notation-bubble/icons/relationship.svg +7 -0
  262. package/assets/catalog.ttl +7302 -0
  263. package/assets/core/core-notation.ttl +131 -0
  264. package/assets/core/core-onto.ttl +2811 -0
  265. package/assets/core/core-questions.ttl +957 -0
  266. package/assets/core/core-shapes.ttl +915 -0
  267. package/assets/core/core-vis-onto.ttl +1408 -0
  268. package/assets/core/core-vis-shapes.ttl +840 -0
  269. package/assets/core-vis/markers/circle-dot.svg +3 -0
  270. package/assets/core-vis/markers/closed-arrowhead.svg +3 -0
  271. package/assets/core-vis/markers/filled-diamond.svg +3 -0
  272. package/assets/core-vis/markers/half-arrowhead.svg +3 -0
  273. package/assets/core-vis/markers/hollow-arrowhead.svg +3 -0
  274. package/assets/core-vis/markers/hollow-diamond.svg +3 -0
  275. package/assets/core-vis/markers/open-arrowhead.svg +3 -0
  276. package/fixtures/interoperability/archimate4-demo.trig +259 -0
  277. package/fixtures/interoperability/expected-findings.json +26 -0
  278. package/fixtures/interoperability/shop-seed.ttl +225 -0
  279. package/package.json +136 -4
  280. package/scripts/sync-assets.mjs +252 -0
  281. package/src/conformance.ts +66 -0
  282. package/src/import-export/model-io.ts +426 -0
  283. package/src/index.ts +11 -0
  284. package/src/metamodel-manager/asset-sources.ts +754 -0
  285. package/src/metamodel-manager/bundled-assets.ts +599 -0
  286. package/src/metamodel-manager/catalogue.ts +114 -0
  287. package/src/metamodel-manager/class-hierarchy.ts +155 -0
  288. package/src/metamodel-manager/index.ts +65 -0
  289. package/src/metamodel-manager/interfaces.ts +422 -0
  290. package/src/metamodel-manager/metamodel-completeness.ts +162 -0
  291. package/src/metamodel-manager/metamodel-loader.ts +864 -0
  292. package/src/metamodel-manager/notation-resolver.ts +284 -0
  293. package/src/metamodel-manager/notation.ts +659 -0
  294. package/src/metamodel-manager/palette-generator.ts +882 -0
  295. package/src/metamodel-manager/property-shapes.ts +290 -0
  296. package/src/metamodel-manager/taxonomy.ts +904 -0
  297. package/src/metamodel-manager/type-guide.ts +241 -0
  298. package/src/metamodel-manager/viewpoint-manager.ts +147 -0
  299. package/src/model-manager/appearance.ts +389 -0
  300. package/src/model-manager/cascade.ts +246 -0
  301. package/src/model-manager/clipboard.ts +566 -0
  302. package/src/model-manager/context-names.ts +108 -0
  303. package/src/model-manager/custom-properties.ts +549 -0
  304. package/src/model-manager/derivations.ts +166 -0
  305. package/src/model-manager/direct-permissions.ts +182 -0
  306. package/src/model-manager/drawing-order.ts +119 -0
  307. package/src/model-manager/element-manager.ts +69 -0
  308. package/src/model-manager/element-pictures.ts +118 -0
  309. package/src/model-manager/field-names.ts +42 -0
  310. package/src/model-manager/folders.ts +354 -0
  311. package/src/model-manager/grid.ts +6 -0
  312. package/src/model-manager/index.ts +43 -0
  313. package/src/model-manager/interfaces.ts +417 -0
  314. package/src/model-manager/iri-conformance.ts +183 -0
  315. package/src/model-manager/label-expression.ts +233 -0
  316. package/src/model-manager/legacy-migration.ts +200 -0
  317. package/src/model-manager/missing-references.ts +86 -0
  318. package/src/model-manager/model-diff-text.ts +150 -0
  319. package/src/model-manager/model-diff.ts +534 -0
  320. package/src/model-manager/model-merge.ts +1160 -0
  321. package/src/model-manager/model-namespace.ts +199 -0
  322. package/src/model-manager/model-operations.ts +132 -0
  323. package/src/model-manager/model-queries.ts +616 -0
  324. package/src/model-manager/model-session.ts +759 -0
  325. package/src/model-manager/multiplicity.ts +74 -0
  326. package/src/model-manager/nested-resources.ts +145 -0
  327. package/src/model-manager/own-metamodel.ts +157 -0
  328. package/src/model-manager/placement-copy.ts +116 -0
  329. package/src/model-manager/property-catalog.ts +787 -0
  330. package/src/model-manager/proposal-order.ts +203 -0
  331. package/src/model-manager/provenance.ts +396 -0
  332. package/src/model-manager/questions.ts +470 -0
  333. package/src/model-manager/rdf-scope.ts +97 -0
  334. package/src/model-manager/relationship-graph.ts +462 -0
  335. package/src/model-manager/relationship-manager.ts +962 -0
  336. package/src/model-manager/relationship-table.ts +189 -0
  337. package/src/model-manager/relationship-validity.ts +261 -0
  338. package/src/model-manager/resource-edits.ts +28 -0
  339. package/src/model-manager/short-hash.ts +104 -0
  340. package/src/model-manager/snapshot-lines.ts +88 -0
  341. package/src/model-manager/version-history.ts +205 -0
  342. package/src/model-manager/view-from-results.ts +81 -0
  343. package/src/model-manager/view-manager.ts +1410 -0
  344. package/src/model-manager/vocabulary.ts +279 -0
  345. package/src/rdf-engine/finding-shape.ts +23 -0
  346. package/src/rdf-engine/graph-scope.ts +163 -0
  347. package/src/rdf-engine/index.ts +7 -0
  348. package/src/rdf-engine/interfaces.ts +144 -0
  349. package/src/rdf-engine/iri.ts +203 -0
  350. package/src/rdf-engine/localized-text.ts +13 -0
  351. package/src/rdf-engine/namespaces.ts +41 -0
  352. package/src/rdf-engine/observable-store.ts +631 -0
  353. package/src/rdf-engine/rdf-store.ts +508 -0
  354. package/src/rdf-engine/shacl-validator.ts +602 -0
  355. package/src/rdf-engine/shape-reach.ts +140 -0
  356. package/src/rdf-engine/shape-switches.ts +165 -0
  357. package/src/rdf-engine/single-valued.ts +219 -0
  358. package/src/rdf-engine/sparql-constraints.ts +334 -0
  359. package/src/rdf-engine/term-codec.ts +51 -0
  360. package/src/rdf-engine/ttl-parser.ts +51 -0
  361. package/src/rdf-engine/ttl-serializer.ts +79 -0
  362. package/src/rdf-engine/turtle-writer.ts +284 -0
  363. package/src/rdf-engine/validation-engine.ts +682 -0
  364. package/src/rdf-engine/validation-service.ts +184 -0
  365. package/src/rdf-engine/validation.worker.ts +47 -0
@@ -0,0 +1,422 @@
1
+ /**
2
+ * Metamodel Manager layer interfaces.
3
+ *
4
+ * Handles loading metamodel ontologies from a manifest, generating palettes
5
+ * from the taxonomy + visual-notation layers, and viewpoint filtering.
6
+ */
7
+
8
+ import type { BundledAssetRole } from './bundled-assets.js';
9
+ import type { Decoration, RelationshipVisualStyle, RenderingMode, VisualStyle } from './notation.js';
10
+ import type { NotationIndexEntry } from './notation-resolver.js';
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // Metamodel Loader
14
+ // ---------------------------------------------------------------------------
15
+
16
+ /** Metadata extracted from a loaded metamodel ontology. */
17
+ export interface MetamodelInfo {
18
+ /** The ontology IRI. */
19
+ iri: string;
20
+ /** dc:title / dcterms:title / skos:prefLabel of the metamodel. */
21
+ name: string;
22
+ /** owl:versionInfo of the metamodel. */
23
+ version: string;
24
+ /** dc:description / dcterms:description of the metamodel. */
25
+ description: string;
26
+ }
27
+
28
+ /** Outcome of trying to load one asset discovered from a manifest. */
29
+ export type MetamodelAssetOutcome =
30
+ /** Fetched, parsed and loaded into its own named graph. */
31
+ | 'loaded'
32
+ /** Already present in the store from an earlier step (dedup by document IRI). */
33
+ | 'already-loaded'
34
+ /** Referenced by the manifest but not shipped in this bundle (bundle-only source). */
35
+ | 'not-bundled'
36
+ /** No configured source (upload, network, bundle) could provide it. */
37
+ | 'unavailable'
38
+ /** Deliberately not fetched: the editor has no use for it (derivation rules, templates). */
39
+ | 'skipped'
40
+ /** A source should have had it but the fetch or the parse failed. */
41
+ | 'error';
42
+
43
+ /**
44
+ * Per-asset record of what happened while loading a metamodel.
45
+ *
46
+ * A caller that wants to report a partial load honestly ("viewpoints and
47
+ * derivation rules are missing") has everything it needs here.
48
+ */
49
+ export interface MetamodelAssetStatus {
50
+ /** The IRI as written in the manifest (may name an individual, not a document). */
51
+ referencedIri: string;
52
+ /** The document IRI it resolved to — the named graph key when loaded. */
53
+ documentIri: string;
54
+ /** Which manifest property (or `owl:imports`) pointed at it. */
55
+ via: string;
56
+ /** Role of the bundled asset, when the document IRI matched one. */
57
+ role?: BundledAssetRole;
58
+ outcome: MetamodelAssetOutcome;
59
+ /** Quads loaded into the graph. Present when `outcome === 'loaded'`. */
60
+ quadCount?: number;
61
+ /** Failure detail when `outcome === 'error'`, reason for `skipped`/`unavailable`. */
62
+ message?: string;
63
+ /** Which source answered, when one did. */
64
+ origin?: 'bundled' | 'remote' | 'uploaded';
65
+ /** The uploaded file it was read from, by its path in the upload (KReq 3.6). */
66
+ location?: string;
67
+ }
68
+
69
+ /**
70
+ * Handle describing a metamodel that was loaded from a manifest.
71
+ *
72
+ * `graphsByRole` is the practical part: it names the graph each layer of the
73
+ * language landed in, so a caller can query the taxonomy or the notation graph
74
+ * directly instead of guessing IRIs.
75
+ */
76
+ export interface LoadedMetamodel {
77
+ /** IRI of the `arch:Metamodel` subject (e.g. `am4mm:ArchiMate4`). */
78
+ metamodelIri: string;
79
+ /** Graph the manifest document itself was loaded into. */
80
+ manifestGraphIri: string;
81
+ /** Metadata read off the `arch:Metamodel` subject and its ontology. */
82
+ info: MetamodelInfo;
83
+ /** Graph IRIs per bundled-asset role. Multi-valued because `shapes` is. */
84
+ graphsByRole: Partial<Record<BundledAssetRole, string[]>>;
85
+ /** Notation set the manifest names via `arch:notationSet`, when it does. */
86
+ notationSetIri?: string;
87
+ /** Concept scheme the manifest names via `arch:presentationContextScheme`. */
88
+ presentationContextSchemeIri?: string;
89
+ /** One entry per discovered asset, in discovery order. */
90
+ assets: MetamodelAssetStatus[];
91
+ }
92
+
93
+ /** Loads metamodel TTL ontologies and SHACL shapes into the RDF store. */
94
+ export interface MetamodelLoader {
95
+ /**
96
+ * Load a single raw TTL document into a named graph keyed by its ontology
97
+ * IRI. Use {@link loadMetamodelFromManifest} for a real multi-file metamodel.
98
+ */
99
+ loadMetamodel(ttlContent: string): Promise<MetamodelInfo>;
100
+ /**
101
+ * Load a metamodel from its `arch:Metamodel` manifest, following the
102
+ * manifest's asset-pointing properties and `owl:imports` transitively.
103
+ */
104
+ loadMetamodelFromManifest(manifestTtl: string): Promise<LoadedMetamodel>;
105
+ /** Load a bundled metamodel (ArchiMate 4.0 by default) with no network. */
106
+ loadBundledMetamodel(idOrIri?: string): Promise<LoadedMetamodel>;
107
+ /** Load a metamodel by its `arch:Metamodel` IRI or manifest document IRI. */
108
+ loadMetamodelByIri(iri: string): Promise<LoadedMetamodel>;
109
+ /** Load the core ontologies and core shapes every model is validated against. */
110
+ loadCoreAssets(): Promise<Partial<Record<BundledAssetRole, string[]>>>;
111
+ /** Drop a metamodel's graphs, keeping those shared with `keep`. */
112
+ unloadMetamodel(loaded: LoadedMetamodel, keep?: readonly LoadedMetamodel[]): string[];
113
+ /** Load one standalone document (extension ontology, shapes file). */
114
+ loadDocument(
115
+ text: string,
116
+ options?: {
117
+ format?: import('./asset-sources.js').AssetFormat;
118
+ role?: BundledAssetRole;
119
+ documentIri?: string;
120
+ /** The uploaded file's path, recorded on the status. */
121
+ location?: string;
122
+ },
123
+ ): Promise<MetamodelAssetStatus>;
124
+ loadShapes(ttlContent: string): Promise<void>;
125
+ resolveImports(ontologyIri: string): Promise<void>;
126
+ }
127
+
128
+ // ---------------------------------------------------------------------------
129
+ // Palette Generator
130
+ // ---------------------------------------------------------------------------
131
+
132
+ /**
133
+ * A URI from the metamodel together with its offline resolution.
134
+ *
135
+ * Icon URIs are published as absolute `https://meta.linked.archi/...` URLs.
136
+ * Offline, they resolve to paths under the bundled asset root — but only for
137
+ * the icon sets this bundle actually ships. Keeping both forms lets a renderer
138
+ * use the bundled path while a caller that has network access (or wants to
139
+ * report what is missing) can still see what the metamodel really said.
140
+ */
141
+ export interface ResolvedUri {
142
+ /** The URI exactly as published in the metamodel. */
143
+ sourceUri: string;
144
+ /** Asset-root-relative bundled path, when this bundle ships the file. */
145
+ bundledPath?: string;
146
+ /** What to render: `bundledPath` when present, otherwise `sourceUri`. */
147
+ url: string;
148
+ }
149
+
150
+ /** A classification axis a palette can be grouped by. */
151
+ export interface PaletteAxis {
152
+ /** IRI of the axis concept (e.g. "Domain"). */
153
+ iri: string;
154
+ /** Human-readable axis label. */
155
+ label: string;
156
+ /** Group labels under this axis, in palette order. */
157
+ groups: string[];
158
+ }
159
+
160
+ /** Information about a single element type discovered from the metamodel. */
161
+ export interface ElementTypeInfo {
162
+ /** IRI of the element type class. */
163
+ iri: string;
164
+ /** skos:prefLabel display label. */
165
+ label: string;
166
+ /** skos:definition / rdfs:comment, when published. */
167
+ definition?: string;
168
+ /**
169
+ * Icon to show in a palette or on a shape, already resolved for offline use.
170
+ *
171
+ * The composite `arch:prefVisNotation` image when there is one, otherwise the
172
+ * `arch-vis:iconSymbol` badge glyph.
173
+ */
174
+ iconUrl?: string;
175
+ /** `arch:prefVisNotation` composite image, source and resolved form. */
176
+ prefVisNotation?: ResolvedUri;
177
+ /** `arch-vis:iconSymbol` badge glyph, source and resolved form. */
178
+ iconSymbol?: ResolvedUri;
179
+ /**
180
+ * Full visual style from the notation lookup (`notation-resolver.ts`): a
181
+ * descriptor for the class itself in the active set or a fallback layer, or,
182
+ * failing that and its own image, the nearest superclass's descriptor in
183
+ * either.
184
+ *
185
+ * `style.iconSymbol` carries the *resolved* URL so a renderer can use it
186
+ * directly; {@link iconSymbol} keeps the published URI.
187
+ */
188
+ style?: VisualStyle;
189
+ /** Rendering mode after the notation guide's fallbacks are applied. */
190
+ renderingMode?: RenderingMode;
191
+ /** Group label under the axis the palette is currently grouped by. */
192
+ group?: string;
193
+ /** Group label per classification axis IRI — the dual-classification result. */
194
+ groupsByAxis?: Record<string, string>;
195
+ /** Whether this type is abstract (should not appear in palette). */
196
+ isAbstract: boolean;
197
+ }
198
+
199
+ /** A group of element types under the active classification axis. */
200
+ export interface ElementGroup {
201
+ /** Group label, e.g. "Business Domain". */
202
+ category: string;
203
+ /** IRI of the axis this grouping came from, when a taxonomy supplied it. */
204
+ axisIri?: string;
205
+ /** Element types in this group. */
206
+ elements: ElementTypeInfo[];
207
+ }
208
+
209
+ /** Information about a relationship type discovered from the metamodel. */
210
+ export interface RelationshipTypeInfo {
211
+ /** IRI of the relationship type. */
212
+ iri: string;
213
+ /** skos:prefLabel display label. */
214
+ label: string;
215
+ /** skos:definition, when published. */
216
+ definition?: string;
217
+ /** Icon URL, resolved for offline use. */
218
+ iconUrl?: string;
219
+ /** `arch:prefVisNotation` image, source and resolved form. */
220
+ prefVisNotation?: ResolvedUri;
221
+ /**
222
+ * Line style and endpoint decorations from the notation lookup. Carries a
223
+ * colour only when the descriptor states one; renderers draw black otherwise.
224
+ */
225
+ relationshipStyle?: RelationshipVisualStyle;
226
+ /**
227
+ * Its category: its group under the taxonomy axis that classifies relationship types (ArchiMate's
228
+ * Structural Relationship, Dependency Relationship…), through its nearest superclass for a kind of
229
+ * relationship the taxonomy does not list. Absent when no axis classifies relationship types; the palette
230
+ * then lists them in one section.
231
+ */
232
+ category?: string;
233
+ /** IRIs of valid source element types (arch:domainIncludes). */
234
+ domainTypes: string[];
235
+ /** IRIs of valid target element types (arch:rangeIncludes). */
236
+ rangeTypes: string[];
237
+ /**
238
+ * IRI of the unqualified (direct) predicate form, from `arch:unqualifiedForm`.
239
+ *
240
+ * Relationship types are modelled twice in the Linked.Archi ontologies: as an
241
+ * `owl:Class` subclassing `arch:QualifiedRelationship` (the palette concept)
242
+ * and as an `owl:ObjectProperty` (the direct triple predicate). This links the
243
+ * former to the latter. Absent when the metamodel declares no mapping.
244
+ */
245
+ unqualifiedPredicateIri?: string;
246
+ /**
247
+ * Ranking score used to order candidates for a given source/target pair.
248
+ *
249
+ * Higher is a better fit. Only populated by rankers such as
250
+ * `RelationshipManager.getValidRelationships`; undefined when the type is
251
+ * listed without reference to a concrete pair (e.g. in a palette).
252
+ */
253
+ score?: number;
254
+ /**
255
+ * Human-readable explanation of why this type was allowed for the queried
256
+ * source/target pair. Undefined outside a pair-specific query.
257
+ */
258
+ reason?: string;
259
+ /**
260
+ * For the queried pair: `true` when the metamodel's relationship tables let a
261
+ * modeller draw this relationship directly, `false` when they permit it only as
262
+ * the conclusion of a derivation. Undefined when the tables do not say, or
263
+ * outside a pair-specific query.
264
+ */
265
+ direct?: boolean;
266
+ /**
267
+ * For the queried pair: a generic relationship — one whose hints name only
268
+ * core classes, so that it relates any two elements of its metamodel, and
269
+ * which no relationship table restricts. Ranked after the metamodel's other
270
+ * relationships. Undefined outside a pair-specific query.
271
+ */
272
+ generic?: boolean;
273
+ /**
274
+ * One of the core's own relationship types (Association, Depends On, Has Part, Refines): offered where the loaded
275
+ * metamodels permit nothing between two elements (Req 4.21), and not listed in the palette.
276
+ */
277
+ core?: boolean;
278
+ /**
279
+ * For the queried pair: the language's metamodel figures draw this relationship
280
+ * between the two element types (the relationship tables' `draws…`). Said, not
281
+ * ranked by. Undefined when they do not, or outside a pair-specific query.
282
+ */
283
+ drawn?: boolean;
284
+ /**
285
+ * For the queried pair: Association, a kind of it, or a generic relationship —
286
+ * always permitted, saying least. Undefined otherwise, or outside a
287
+ * pair-specific query.
288
+ */
289
+ fallback?: boolean;
290
+ }
291
+
292
+ /** Complete palette definition generated from a metamodel. */
293
+ /** One thing a loaded metamodel leaves out, or leaves the palette to guess. */
294
+ export interface MetamodelFinding {
295
+ kind: 'nothing-to-draw' | 'no-classification' | 'unclassified-elements' | 'unclassified-relationships';
296
+ /** What is missing and what la-gram does about it, to follow "‹metamodel› is incomplete: " — "it names no classification…". */
297
+ message: string;
298
+ /** The labels of the types concerned. */
299
+ types?: string[];
300
+ }
301
+
302
+ /** What is incomplete about one loaded metamodel. */
303
+ export interface MetamodelCompleteness {
304
+ metamodelIri: string;
305
+ label: string;
306
+ findings: MetamodelFinding[];
307
+ }
308
+
309
+ export interface PaletteDefinition {
310
+ /** The loaded metamodels that are incomplete, each with what is missing; none when all are complete. */
311
+ completeness?: MetamodelCompleteness[];
312
+ elementGroups: ElementGroup[];
313
+ relationshipTypes: RelationshipTypeInfo[];
314
+ /** Every classification axis the taxonomy offers — drives a "Group by" UI. */
315
+ axes?: PaletteAxis[];
316
+ /** IRI of the axis the `elementGroups` are grouped by. */
317
+ activeAxisIri?: string;
318
+ /**
319
+ * How the element types were found and grouped: `taxonomy` from the
320
+ * metamodel's classification (`arch:conceptClassification`, SKOS), `owl` by
321
+ * the OWL-only fallback — every non-abstract `arch:Element` subclass, grouped
322
+ * by a heuristic on its name — when no classification is loaded. The palette
323
+ * says so in the second case.
324
+ */
325
+ grouping?: 'taxonomy' | 'owl';
326
+ /** IRI of the active notation set: the one consulted first. */
327
+ notationSetIri?: string;
328
+ /** Label of that notation set. */
329
+ notationSetLabel?: string;
330
+ /** The presentation context the palette was made for — the audience — and its name; none when none is chosen. */
331
+ presentationContextIri?: string;
332
+ presentationContextLabel?: string;
333
+ /** What that context says every label says, where nothing else does (its `arch-vis:labelExpression`). */
334
+ presentationContextLabelExpression?: string;
335
+ /**
336
+ * The resolved notation of every class the generator could resolve, keyed by
337
+ * class IRI, plus each relationship class's `arch:unqualifiedForm` predicate.
338
+ *
339
+ * Entries come from the same lookup as the palette entries, so the two agree;
340
+ * the canvas reads this for types the palette does not list (a class no
341
+ * taxonomy names). Classes that resolve to nothing are absent.
342
+ */
343
+ notationIndex?: Record<string, NotationIndexEntry>;
344
+
345
+ /**
346
+ * The published marker symbol of each relationship-end decoration
347
+ * (`arch-vis:decorSymbol`), resolved to the bundled copy where this bundle
348
+ * ships one. Renderers draw decorations from these, falling back to built-in
349
+ * geometry for a decoration with no symbol.
350
+ */
351
+ decorationSymbols?: Partial<Record<Decoration, ResolvedUri>>;
352
+ }
353
+
354
+ /** How to build a palette: which axis groups it, which notation styles it. */
355
+ export interface PaletteOptions {
356
+ /** Preferred language of the authored labels. Defaults to English. */
357
+ preferredLanguage?: string;
358
+ /**
359
+ * Classification axis to group elements by. Defaults to the taxonomy's
360
+ * preferred (first) axis. Ignored when the metamodel declares no such axis.
361
+ */
362
+ axisIri?: string;
363
+ /** Notation set to take visual styles from. Defaults to the metamodel's. */
364
+ notationSetIri?: string;
365
+ /**
366
+ * Presentation context whose `arch:usesNotationSet` selects the notation set.
367
+ * Ignored when {@link notationSetIri} is given.
368
+ */
369
+ presentationContextIri?: string;
370
+ /**
371
+ * The loaded metamodels' default sets (`arch:notationSet`), in load order.
372
+ *
373
+ * With no set chosen, the first that has descriptors is the active set. Every
374
+ * set here except the active one is a fallback layer, consulted for a class
375
+ * the active set does not describe; when a context or an explicit choice
376
+ * picked another set, that includes the first. Without it, the graph's
377
+ * metamodels are used, in IRI order.
378
+ */
379
+ defaultNotationSetIris?: readonly string[];
380
+ /**
381
+ * The loaded metamodels (`arch:Metamodel` subjects), in load order. Their
382
+ * classifications' axes come in that order, so a language added beside
383
+ * another never becomes the default grouping. Without it, axes are ordered by
384
+ * label after the structural/aspect rule.
385
+ */
386
+ metamodelIris?: readonly string[];
387
+ /**
388
+ * The loaded metamodels with the graphs of the documents each loaded, and which of them its manifest names as
389
+ * its concepts: what each is checked for ({@link PaletteDefinition.completeness}), and whose classes are offered —
390
+ * not those of a document only a shapes or mappings document imports. Without it, nothing is checked and every
391
+ * class in the store is offered.
392
+ */
393
+ metamodels?: ReadonlyArray<{ iri: string; label: string; documents: readonly string[]; conceptDocuments?: readonly string[] }>;
394
+ }
395
+
396
+ /** Generates UI palettes from metamodel definitions. */
397
+ export interface PaletteGenerator {
398
+ generatePalette(metamodelGraph?: string, options?: PaletteOptions): PaletteDefinition;
399
+ filterByViewpoint(palette: PaletteDefinition, viewpointIri: string): PaletteDefinition;
400
+ }
401
+
402
+ // ---------------------------------------------------------------------------
403
+ // Viewpoint Manager
404
+ // ---------------------------------------------------------------------------
405
+
406
+ /** Information about a viewpoint defined in the metamodel. */
407
+ export interface ViewpointInfo {
408
+ /** IRI of the viewpoint. */
409
+ iri: string;
410
+ /** Display label. */
411
+ label: string;
412
+ /** Permitted element type IRIs. */
413
+ permittedElements: string[];
414
+ /** Permitted relationship type IRIs. */
415
+ permittedRelationships: string[];
416
+ }
417
+
418
+ /** Manages viewpoint definitions and type filtering. */
419
+ export interface ViewpointManager {
420
+ getViewpoints(): ViewpointInfo[];
421
+ getPermittedTypes(viewpointIri: string): { elements: string[]; relationships: string[] };
422
+ }
@@ -0,0 +1,162 @@
1
+ /**
2
+ * What a loaded metamodel leaves out of the palette, or leaves the palette to guess (Req 2.24): a metamodel that
3
+ * defines nothing to draw, one that names no classification, one whose classification names part of its element
4
+ * types. The palette says so, and *Show loaded assets…* lists the types.
5
+ *
6
+ * A type is a metamodel's when one of the documents it takes its types from declares it — its ontology, or one
7
+ * that ontology imports ({@link typeSources}); the core documents are nobody's.
8
+ */
9
+
10
+ import { DataFactory, type Store } from 'n3';
11
+ import type { MetamodelCompleteness, MetamodelFinding, RelationshipTypeInfo } from './interfaces.js';
12
+ import type { SemanticClass } from './taxonomy.js';
13
+
14
+ const { namedNode } = DataFactory;
15
+
16
+ const RDF_TYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
17
+ const RDFS_SUBCLASS = 'http://www.w3.org/2000/01/rdf-schema#subClassOf';
18
+ const OWL_CLASS = 'http://www.w3.org/2002/07/owl#Class';
19
+ const SKOS_CONCEPT = 'http://www.w3.org/2004/02/skos/core#Concept';
20
+ const CORE = 'https://meta.linked.archi/core';
21
+ const ARCH_CONCEPT_CLASSIFICATION = 'https://meta.linked.archi/core#conceptClassification';
22
+
23
+ /** A loaded metamodel, as the completeness check needs it. */
24
+ export interface CheckedMetamodel {
25
+ /** The `arch:Metamodel` subject. */
26
+ iri: string;
27
+ label: string;
28
+ /** The graphs of the documents it loaded, or found loaded. */
29
+ documents: readonly string[];
30
+ /**
31
+ * Those its manifest names as its concepts (`arch:modelConcepts`). With them, only they and what they import
32
+ * give the metamodel its types ({@link typeSources}); without, every document does.
33
+ */
34
+ conceptDocuments?: readonly string[];
35
+ }
36
+
37
+ const OWL_IMPORTS = 'http://www.w3.org/2002/07/owl#imports';
38
+
39
+ /**
40
+ * The documents a metamodel takes its types from: those its manifest names as its concepts, and what they import,
41
+ * and so on. A document only its shapes, mappings or viewpoints import — another version's ontology, which the
42
+ * shapes of both cover — is loaded, for validation, and gives it no types.
43
+ */
44
+ export function typeSources(graph: Store, metamodel: CheckedMetamodel): Set<string> {
45
+ if (!metamodel.conceptDocuments) return new Set(metamodel.documents);
46
+ const loaded = new Set(metamodel.documents);
47
+ const sources = new Set<string>();
48
+ const queue = metamodel.conceptDocuments.filter((d) => loaded.has(d));
49
+ while (queue.length > 0) {
50
+ const document = queue.pop() as string;
51
+ if (sources.has(document)) continue;
52
+ sources.add(document);
53
+ for (const q of graph.getQuads(null, namedNode(OWL_IMPORTS), null, namedNode(document))) {
54
+ const hash = q.object.value.indexOf('#');
55
+ const imported = [q.object.value, hash === -1 ? `${q.object.value}#` : q.object.value.slice(0, hash + 1)].find((d) => loaded.has(d));
56
+ if (imported) queue.push(imported);
57
+ }
58
+ }
59
+ return sources;
60
+ }
61
+
62
+ /**
63
+ * The loaded documents that give no metamodel its types ({@link typeSources}): a class only they declare is not
64
+ * offered. The core's are left out: its classes are never offered anyway.
65
+ */
66
+ export function documentsWithoutTypes(graph: Store, metamodels: readonly CheckedMetamodel[]): Set<string> {
67
+ const sources = new Set(metamodels.flatMap((m) => [...typeSources(graph, m)]));
68
+ return new Set(metamodels.flatMap((m) => m.documents).filter((d) => !sources.has(d) && !d.startsWith(CORE)));
69
+ }
70
+
71
+ /** Whether a class is declared in a document other than `excluded` ones — or in none of the store's graphs known. */
72
+ export function declaredOutside(graph: Store, iri: string, excluded: ReadonlySet<string>): boolean {
73
+ if (excluded.size === 0) return true;
74
+ const graphs = [RDF_TYPE, RDFS_SUBCLASS].flatMap((p) => graph.getQuads(namedNode(iri), namedNode(p), null, null).map((q) => q.graph.value));
75
+ return graphs.length === 0 || graphs.some((g) => !excluded.has(g));
76
+ }
77
+
78
+ const plural = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
79
+
80
+ /**
81
+ * Each metamodel's findings; a metamodel with none is left out.
82
+ *
83
+ * @param classes The palette's element classes ({@link SemanticClass.unclassified} set by `buildClasses`).
84
+ * @param relationships The palette's relationship types, each with the category its taxonomy gives it.
85
+ * @param groupedByName The palette groups by a guess from the names: no scheme classifies any class.
86
+ */
87
+ export function metamodelCompleteness(
88
+ graph: Store,
89
+ metamodels: readonly CheckedMetamodel[],
90
+ classes: readonly SemanticClass[],
91
+ relationships: readonly RelationshipTypeInfo[],
92
+ groupedByName: boolean,
93
+ ): MetamodelCompleteness[] {
94
+ const result: MetamodelCompleteness[] = [];
95
+ const relationshipsClassified = relationships.some((rel) => rel.category !== undefined);
96
+ for (const metamodel of metamodels) {
97
+ const documents = new Set(metamodel.documents.filter((d) => !d.startsWith(CORE)));
98
+ const sources = new Set([...typeSources(graph, metamodel)].filter((d) => !d.startsWith(CORE)));
99
+ const declaredHere = (iri: string): boolean =>
100
+ [RDF_TYPE, RDFS_SUBCLASS].some((p) =>
101
+ graph.getQuads(namedNode(iri), namedNode(p), null, null).some((q) => sources.has(q.graph.value)),
102
+ );
103
+ const count = (type: string): number => {
104
+ const subjects = new Set<string>();
105
+ for (const d of type === OWL_CLASS ? sources : documents) {
106
+ for (const q of graph.getQuads(null, namedNode(RDF_TYPE), namedNode(type), namedNode(d))) subjects.add(q.subject.value);
107
+ }
108
+ return subjects.size;
109
+ };
110
+ const elements = classes.filter((cls) => declaredHere(cls.iri));
111
+ const own = relationships.filter((rel) => declaredHere(rel.iri));
112
+ const findings: MetamodelFinding[] = [];
113
+
114
+ if (elements.length === 0 && own.length === 0) {
115
+ const owlClasses = count(OWL_CLASS);
116
+ const concepts = count(SKOS_CONCEPT);
117
+ findings.push({
118
+ kind: 'nothing-to-draw',
119
+ message:
120
+ owlClasses === 0
121
+ ? `it defines no element or relationship types: its documents hold ${concepts > 0 ? `${plural(concepts, 'concept')} and ` : ''}no classes, so nothing of it can be drawn`
122
+ : `it defines no element or relationship types: none of its ${plural(owlClasses, 'class', 'classes')} is a subclass of arch:Element or arch:QualifiedRelationship, so nothing of it can be drawn`,
123
+ });
124
+ }
125
+
126
+ const unclassified = elements.filter((cls) => cls.unclassified);
127
+ const namesClassification =
128
+ graph.getQuads(namedNode(metamodel.iri), namedNode(ARCH_CONCEPT_CLASSIFICATION), null, null).length > 0;
129
+ if (elements.length > 0 && !namesClassification) {
130
+ findings.push({
131
+ kind: 'no-classification',
132
+ message: `it names no classification (arch:conceptClassification): its ${plural(elements.length, 'element type')} ${elements.length === 1 ? 'is' : 'are'} ${groupedByName ? 'grouped by a guess from their names' : 'listed under “Other”'}`,
133
+ types: elements.map((cls) => cls.label).sort((a, b) => a.localeCompare(b)),
134
+ });
135
+ } else if (elements.length > 0 && groupedByName) {
136
+ findings.push({
137
+ kind: 'unclassified-elements',
138
+ message: `its classification names none of its ${plural(elements.length, 'element type')}: ${elements.length === 1 ? 'it is' : 'they are'} grouped by a guess from ${elements.length === 1 ? 'its name' : 'their names'}`,
139
+ types: elements.map((cls) => cls.label).sort((a, b) => a.localeCompare(b)),
140
+ });
141
+ } else if (unclassified.length > 0) {
142
+ findings.push({
143
+ kind: 'unclassified-elements',
144
+ message: `its classification names ${elements.length - unclassified.length} of its ${plural(elements.length, 'element type')}: the other ${unclassified.length} ${unclassified.length === 1 ? 'is' : 'are'} listed under “Other”`,
145
+ types: unclassified.map((cls) => cls.label).sort((a, b) => a.localeCompare(b)),
146
+ });
147
+ }
148
+
149
+ // A relationship type no dimension lists, where dimensions list others: it has no category.
150
+ const uncategorised = relationshipsClassified ? own.filter((rel) => rel.category === undefined) : [];
151
+ if (uncategorised.length > 0) {
152
+ findings.push({
153
+ kind: 'unclassified-relationships',
154
+ message: `${uncategorised.length} of its ${plural(own.length, 'relationship type')} ${uncategorised.length === 1 ? 'is' : 'are'} in no category, and listed under “Other”`,
155
+ types: uncategorised.map((rel) => rel.label).sort((a, b) => a.localeCompare(b)),
156
+ });
157
+ }
158
+
159
+ if (findings.length > 0) result.push({ metamodelIri: metamodel.iri, label: metamodel.label, findings });
160
+ }
161
+ return result;
162
+ }