@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,284 @@
1
+ /**
2
+ * Turtle and TriG with the IRIs of the Linked.Archi layout written short (DD-41, meta's *IRI Minting*, Turtle).
3
+ *
4
+ * A model's IRIs are `{ns}{kind}/{id}`, `{view}#{node|link}-{id}` for the shapes drawn in a view, and parts
5
+ * under their owner, joined with `/`, or with `-` after a view's `#`. A prefixed name holds a `/` or a `#` only
6
+ * escaped, so an IRI of the model a file is about is written with the first of these that applies:
7
+ *
8
+ * 1. a prefix, where the rest is a plain local name: `m:model`, `me:{id}`, and la-gram's earlier flat names,
9
+ * `m:element-{uuid}`;
10
+ * 2. a prefix per view, for a shape and its parts, its fragment escaped where it must be (it need not when
11
+ * it is la-gram's or a converter's): `mv3ef7da72:node-{id}`, `mv3ef7da72:link-{id}-point-0`;
12
+ * 3. a reference relative to `@base <{ns}>`: `<element/component/default/payments>`;
13
+ * 4. the full IRI.
14
+ *
15
+ * N3.js cannot do this as it is. Given a `baseIRI` it makes an IRI relative before it looks for a prefix, so an
16
+ * element comes out `<element/…>`, never `me:…`; it leaves an IRI in full when a later segment is shorter than
17
+ * three characters (`…/points/0`); and it never escapes a `/`. So the writer here is N3's with one method of
18
+ * its own, `_encodeIriOrBlank`, the one N3 calls for every IRI it writes. That method is internal: `package.json`
19
+ * pins n3 to {@link N3_VERSION}, and a test fails when another is installed (`.agents/tasks/iri-layout/design.md`).
20
+ */
21
+
22
+ import { Writer as N3Writer } from 'n3';
23
+ import type { Quad, Term } from '@rdfjs/types';
24
+ import type { PrefixMap } from './interfaces.js';
25
+ import { isPathNamespace } from './iri.js';
26
+ import { sha256Hex } from '../model-manager/short-hash.js';
27
+
28
+ export { isPathNamespace };
29
+
30
+ /** The n3 version whose internal `_encodeIriOrBlank` {@link LayoutWriter} overrides. */
31
+ export const N3_VERSION = '2.13.12';
32
+
33
+ /** The model a file is about: its namespace and the prefix it declares (`vann:preferredNamespace…`). */
34
+ export interface TurtleModel {
35
+ namespace: string;
36
+ prefix: string;
37
+ }
38
+
39
+ /** Options for {@link writeTurtle}. */
40
+ export interface TurtleOptions {
41
+ /** `text/turtle` unless TriG is asked for. */
42
+ format?: 'text/turtle' | 'application/trig';
43
+ /** The prefixes known: the standard ones, the loaded vocabularies' and the model's own. */
44
+ prefixes: PrefixMap;
45
+ /** Write only the known prefixes some IRI in the file starts with; otherwise all of them. */
46
+ onlyUsed?: boolean;
47
+ /** The model the file is about; without one, prefixes only, as N3 writes them. */
48
+ model?: TurtleModel;
49
+ }
50
+
51
+ /**
52
+ * The kinds of resource with a prefix of their own: the letters the model's prefix is followed by, and the
53
+ * path segment of the kind (`{p}e:` for `{ns}element/`). DD-41's table, in its order.
54
+ */
55
+ export const KIND_PREFIXES: ReadonlyArray<readonly [suffix: string, segment: string]> = [
56
+ ['e', 'element/'],
57
+ ['r', 'relationship/'],
58
+ ['v', 'view/'],
59
+ ['f', 'folder/'],
60
+ ['d', 'decision/'],
61
+ ['doc', 'documentation/'],
62
+ ['s', 'stakeholder/'],
63
+ ['p', 'provenance/'],
64
+ ['g', 'graph/'],
65
+ ];
66
+
67
+ /** The prefix a view's shapes are written with: `{p}v` and the first 8 hex characters of the SHA-256 of its IRI. */
68
+ export function viewPrefixLabel(prefix: string, viewIri: string): string {
69
+ return `${prefix}v${sha256Hex(viewIri).slice(0, 8)}`;
70
+ }
71
+
72
+ /**
73
+ * The prefixes a file about `model` binds besides the known ones: one per kind its IRIs use, and one per view
74
+ * whose shapes it writes — `{view}#` for each IRI of the model with a `#` after the namespace.
75
+ *
76
+ * A derived prefix whose label a known prefix holds for another namespace is not bound: the vocabulary keeps
77
+ * it, and those IRIs are written by the next rule that applies. Nor is one whose namespace a known prefix
78
+ * already names. Of two views with one label, the view whose IRI sorts first keeps it.
79
+ */
80
+ export function modelPrefixes(model: TurtleModel, iris: Iterable<string>, known: PrefixMap): PrefixMap {
81
+ const ns = model.namespace;
82
+ const derived: PrefixMap = {};
83
+ const named = new Set(Object.values(known));
84
+ const bind = (label: string, uri: string): void => {
85
+ if (label in derived || named.has(uri)) return;
86
+ if (label in known && known[label] !== uri) return;
87
+ derived[label] = uri;
88
+ };
89
+ const used = new Set<string>();
90
+ const views = new Set<string>();
91
+ for (const iri of iris) {
92
+ if (!iri.startsWith(ns) || iri.length === ns.length) continue;
93
+ used.add(iri);
94
+ const hash = iri.indexOf('#', ns.length);
95
+ if (hash > 0) views.add(iri.slice(0, hash + 1));
96
+ }
97
+ if (used.size > 0 && !(model.prefix in known)) bind(model.prefix, ns);
98
+ for (const [suffix, segment] of KIND_PREFIXES) {
99
+ const uri = ns + segment;
100
+ for (const iri of used) {
101
+ if (iri.startsWith(uri) && iri.length > uri.length) {
102
+ bind(model.prefix + suffix, uri);
103
+ break;
104
+ }
105
+ }
106
+ }
107
+ for (const view of [...views].sort()) bind(viewPrefixLabel(model.prefix, view.slice(0, -1)), view);
108
+ return derived;
109
+ }
110
+
111
+ /**
112
+ * Keep only the prefixes some IRI in the quads starts with: a subject, predicate, object or graph, or a
113
+ * literal's datatype. Not the inside of a triple term, as before the layout, so that a file la-gram wrote
114
+ * then keeps its prefixes.
115
+ */
116
+ export function usedPrefixes(prefixes: PrefixMap, quads: readonly Quad[]): PrefixMap {
117
+ const iris = new Set<string>();
118
+ for (const q of quads) {
119
+ for (const term of [q.subject, q.predicate, q.object, q.graph]) {
120
+ if (term.termType === 'NamedNode') iris.add(term.value);
121
+ if (term.termType === 'Literal') iris.add(term.datatype.value);
122
+ }
123
+ }
124
+ const used: PrefixMap = {};
125
+ for (const [prefix, uri] of Object.entries(prefixes)) {
126
+ for (const iri of iris) {
127
+ if (iri.startsWith(uri) && iri.length > uri.length) {
128
+ used[prefix] = uri;
129
+ break;
130
+ }
131
+ }
132
+ }
133
+ return used;
134
+ }
135
+
136
+ /** Write quads as Turtle or TriG, in the order given. */
137
+ export function writeTurtle(quads: readonly Quad[], options: TurtleOptions): string {
138
+ const known = options.prefixes;
139
+ const derived = options.model ? modelPrefixes(options.model, iriSet(quads), known) : {};
140
+ const prefixes = { ...(options.onlyUsed ? usedPrefixes(known, quads) : known), ...derived };
141
+ const layout = options.model ? new Layout(options.model.namespace, prefixes) : undefined;
142
+ const writer = new LayoutWriter({ prefixes, format: options.format ?? 'text/turtle' }, layout);
143
+ for (const q of quads) writer.addQuad(q as never);
144
+ let output = '';
145
+ writer.end((_error: Error | null, result: string) => {
146
+ output = result ?? '';
147
+ });
148
+ return layout && writer.wroteRelative ? `@base <${layout.base}>.\n${output}` : output;
149
+ }
150
+
151
+ /** Every IRI in the quads, those inside an RDF 1.2 triple term and a literal's datatype included. */
152
+ function iriSet(quads: readonly Quad[]): Set<string> {
153
+ const iris = new Set<string>();
154
+ const visit = (term: Term): void => {
155
+ if (term.termType === 'NamedNode') iris.add(term.value);
156
+ else if (term.termType === 'Literal') iris.add(term.datatype.value);
157
+ else if (term.termType === 'Quad') {
158
+ visit(term.subject);
159
+ visit(term.predicate);
160
+ visit(term.object);
161
+ visit(term.graph);
162
+ }
163
+ };
164
+ for (const q of quads) {
165
+ visit(q.subject);
166
+ visit(q.predicate);
167
+ visit(q.object);
168
+ visit(q.graph);
169
+ }
170
+ return iris;
171
+ }
172
+
173
+ /** How the IRIs of one model's namespace are written where N3 writes them in full. */
174
+ class Layout {
175
+ /** `{view}#` → the label of its prefix. */
176
+ private readonly views = new Map<string, string>();
177
+ /** The namespace, when references relative to it resolve; `undefined` otherwise. */
178
+ readonly base: string | undefined;
179
+
180
+ constructor(
181
+ private readonly namespace: string,
182
+ prefixes: PrefixMap,
183
+ ) {
184
+ this.base = isPathNamespace(namespace) ? namespace : undefined;
185
+ for (const [label, uri] of Object.entries(prefixes)) {
186
+ if (uri.startsWith(namespace) && uri.endsWith('#') && uri.indexOf('#', namespace.length) === uri.length - 1) {
187
+ this.views.set(uri, label);
188
+ }
189
+ }
190
+ }
191
+
192
+ /**
193
+ * `iri` written by the view prefix or relative to the namespace, from `full`, N3's `<…>` of it; `undefined`
194
+ * when neither applies.
195
+ */
196
+ encode(iri: string, full: string): { text: string; relative: boolean } | undefined {
197
+ if (!iri.startsWith(this.namespace)) return undefined;
198
+ const hash = iri.indexOf('#', this.namespace.length);
199
+ if (hash > 0) {
200
+ const label = this.views.get(iri.slice(0, hash + 1));
201
+ const local = label === undefined ? undefined : escapedLocalName(iri.slice(hash + 1));
202
+ if (local !== undefined) return { text: `${label}:${local}`, relative: false };
203
+ }
204
+ const base = this.base;
205
+ if (base !== undefined && resolvesBack(iri.slice(base.length)) && full.startsWith(`<${base}`)) {
206
+ return { text: `<${full.slice(1 + base.length)}`, relative: true };
207
+ }
208
+ return undefined;
209
+ }
210
+ }
211
+
212
+ /**
213
+ * Whether `reference`, the rest of an IRI after a namespace ending in `/`, resolves back to that IRI against
214
+ * it: not empty, not a path from the root, no `:` in its first segment, where it would be read as a scheme,
215
+ * and no `.` or `..` segment, which resolving removes.
216
+ */
217
+ function resolvesBack(reference: string): boolean {
218
+ if (reference === '' || reference.startsWith('/')) return false;
219
+ if (/^[^/?#]*/.exec(reference)![0].includes(':')) return false;
220
+ return !/^[^?#]*/.exec(reference)![0].split('/').some((segment) => segment === '.' || segment === '..');
221
+ }
222
+
223
+ /** Characters a Turtle local name may hold escaped (`PN_LOCAL_ESC`). */
224
+ const LOCAL_ESCAPABLE = new Set("_~.-!$&'()*+,;=/?#@%");
225
+ /** A character that may start a local name (`PN_CHARS_U`, `:` and digits). */
226
+ const LOCAL_START = /^[A-Za-z0-9_:\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]$/u;
227
+ /** A character that may follow it (`PN_CHARS` and `:`), `.` aside. */
228
+ const LOCAL_CHAR = /^[A-Za-z0-9_:\-\u00B7\u0300-\u036F\u203F\u2040\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]$/u;
229
+
230
+ /**
231
+ * `local` as a Turtle local name (`PN_LOCAL`): each `/` as `\/`, and any other character a local name cannot
232
+ * hold where it stands escaped with `\`, a `%` and two hex digits left as they are. `undefined` when a
233
+ * character can be neither written nor escaped.
234
+ */
235
+ export function escapedLocalName(local: string): string | undefined {
236
+ const chars = [...local];
237
+ let out = '';
238
+ for (let i = 0; i < chars.length; i += 1) {
239
+ const c = chars[i]!;
240
+ if (c === '%' && /^[0-9A-Fa-f]{2}$/.test((chars[i + 1] ?? '') + (chars[i + 2] ?? ''))) {
241
+ out += c + chars[i + 1] + chars[i + 2];
242
+ i += 2;
243
+ } else if (i === 0 ? LOCAL_START.test(c) : LOCAL_CHAR.test(c) || (c === '.' && i < chars.length - 1)) {
244
+ out += c;
245
+ } else if (LOCAL_ESCAPABLE.has(c)) {
246
+ out += `\\${c}`;
247
+ } else {
248
+ return undefined;
249
+ }
250
+ }
251
+ return out;
252
+ }
253
+
254
+ /** N3's own encoding of an IRI or blank node, which {@link LayoutWriter} starts from. */
255
+ type Encode = (this: N3Writer, entity: Term) => string;
256
+ const n3Encode = (N3Writer.prototype as unknown as { _encodeIriOrBlank?: Encode })._encodeIriOrBlank;
257
+ if (typeof n3Encode !== 'function') {
258
+ throw new Error(`n3's Writer has no _encodeIriOrBlank: turtle-writer.ts was written against n3 ${N3_VERSION}`);
259
+ }
260
+
261
+ /**
262
+ * N3's writer, encoding an IRI of the model by {@link Layout} where N3 would write it in full. Subjects,
263
+ * predicates, objects, graphs, datatypes and triple terms all reach it.
264
+ */
265
+ class LayoutWriter extends N3Writer {
266
+ /** Whether an IRI was written relative to the namespace, so the file needs its `@base`. */
267
+ wroteRelative = false;
268
+
269
+ constructor(
270
+ options: { prefixes: PrefixMap; format: string },
271
+ private readonly layout: Layout | undefined,
272
+ ) {
273
+ super(options);
274
+ }
275
+
276
+ _encodeIriOrBlank(entity: Term): string {
277
+ const encoded = n3Encode!.call(this, entity);
278
+ if (!this.layout || entity.termType !== 'NamedNode' || !encoded.startsWith('<')) return encoded;
279
+ const shorter = this.layout.encode(entity.value, encoded);
280
+ if (!shorter) return encoded;
281
+ if (shorter.relative) this.wroteRelative = true;
282
+ return shorter.text;
283
+ }
284
+ }