@linked.archi/kernel 0.0.0-stage → 0.1.6
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.
- package/LICENSE +202 -0
- package/NOTICE +11 -0
- package/README.md +102 -2
- package/assets/arch-decision/arch-decision-metamodel.ttl +44 -0
- package/assets/arch-decision/arch-decision-onto.ttl +1566 -0
- package/assets/arch-decision/arch-decision-shapes.ttl +582 -0
- package/assets/arch-decision/arch-decision-tax.ttl +129 -0
- package/assets/arch-processes/arch-processes-metamodel.ttl +42 -0
- package/assets/arch-processes/arch-processes-tax.ttl +136 -0
- package/assets/arch-processes/archProcesses-shapes.ttl +189 -0
- package/assets/arch-processes/archProcesses.ttl +953 -0
- package/assets/archimate3/archimate3.2-element-shapes.ttl +379 -0
- package/assets/archimate3/archimate3.2-metamodel.ttl +205 -0
- package/assets/archimate3/archimate3.2-notation.ttl +1503 -0
- package/assets/archimate3/archimate3.2-onto.ttl +1579 -0
- package/assets/archimate3/archimate3.2-presentation-contexts.ttl +90 -0
- package/assets/archimate3/archimate3.2-principle-shapes.ttl +917 -0
- package/assets/archimate3/archimate3.2-questions.ttl +1125 -0
- package/assets/archimate3/archimate3.2-reference-data.ttl +74 -0
- package/assets/archimate3/archimate3.2-relationship-shapes.ttl +30956 -0
- package/assets/archimate3/archimate3.2-relationship-tables.ttl +5992 -0
- package/assets/archimate3/archimate3.2-tax.ttl +724 -0
- package/assets/archimate3/archimate3.2-viewpoint-shapes.ttl +59 -0
- package/assets/archimate3/archimate3.2-viewpoints.ttl +793 -0
- package/assets/archimate3/icons/and-junction.svg +3 -0
- package/assets/archimate3/icons/application-collaboration.svg +22 -0
- package/assets/archimate3/icons/application-component.svg +18 -0
- package/assets/archimate3/icons/application-event.svg +15 -0
- package/assets/archimate3/icons/application-function.svg +14 -0
- package/assets/archimate3/icons/application-interaction.svg +17 -0
- package/assets/archimate3/icons/application-interface.svg +16 -0
- package/assets/archimate3/icons/application-process.svg +14 -0
- package/assets/archimate3/icons/application-service.svg +14 -0
- package/assets/archimate3/icons/artifact.svg +16 -0
- package/assets/archimate3/icons/assessment.svg +17 -0
- package/assets/archimate3/icons/business-actor.svg +22 -0
- package/assets/archimate3/icons/business-collaboration.svg +21 -0
- package/assets/archimate3/icons/business-event.svg +15 -0
- package/assets/archimate3/icons/business-function.svg +14 -0
- package/assets/archimate3/icons/business-interaction.svg +18 -0
- package/assets/archimate3/icons/business-interface.svg +16 -0
- package/assets/archimate3/icons/business-object.svg +14 -0
- package/assets/archimate3/icons/business-process.svg +15 -0
- package/assets/archimate3/icons/business-role.svg +16 -0
- package/assets/archimate3/icons/business-service.svg +14 -0
- package/assets/archimate3/icons/capability.svg +40 -0
- package/assets/archimate3/icons/communication-network.svg +18 -0
- package/assets/archimate3/icons/constraint.svg +18 -0
- package/assets/archimate3/icons/contract.svg +13 -0
- package/assets/archimate3/icons/course-of-action.svg +20 -0
- package/assets/archimate3/icons/data-object.svg +14 -0
- package/assets/archimate3/icons/deliverable.svg +11 -0
- package/assets/archimate3/icons/device.svg +18 -0
- package/assets/archimate3/icons/distribution-network.svg +19 -0
- package/assets/archimate3/icons/driver.svg +24 -0
- package/assets/archimate3/icons/equipment.svg +31 -0
- package/assets/archimate3/icons/facility.svg +16 -0
- package/assets/archimate3/icons/gap.svg +22 -0
- package/assets/archimate3/icons/glyphs/activity.svg +3 -0
- package/assets/archimate3/icons/glyphs/actor.svg +14 -0
- package/assets/archimate3/icons/glyphs/application-component.svg +12 -0
- package/assets/archimate3/icons/glyphs/artifact.svg +9 -0
- package/assets/archimate3/icons/glyphs/assessment.svg +9 -0
- package/assets/archimate3/icons/glyphs/capability.svg +32 -0
- package/assets/archimate3/icons/glyphs/cloud-gear.svg +3 -0
- package/assets/archimate3/icons/glyphs/collaboration.svg +15 -0
- package/assets/archimate3/icons/glyphs/communication-network.svg +12 -0
- package/assets/archimate3/icons/glyphs/constraint.svg +10 -0
- package/assets/archimate3/icons/glyphs/contract.svg +5 -0
- package/assets/archimate3/icons/glyphs/course-of-action.svg +12 -0
- package/assets/archimate3/icons/glyphs/data-object.svg +4 -0
- package/assets/archimate3/icons/glyphs/deliverable.svg +3 -0
- package/assets/archimate3/icons/glyphs/device.svg +10 -0
- package/assets/archimate3/icons/glyphs/distribution-network.svg +11 -0
- package/assets/archimate3/icons/glyphs/driver.svg +16 -0
- package/assets/archimate3/icons/glyphs/equipment.svg +22 -0
- package/assets/archimate3/icons/glyphs/event.svg +6 -0
- package/assets/archimate3/icons/glyphs/facility.svg +7 -0
- package/assets/archimate3/icons/glyphs/function.svg +6 -0
- package/assets/archimate3/icons/glyphs/gap.svg +14 -0
- package/assets/archimate3/icons/glyphs/goal.svg +10 -0
- package/assets/archimate3/icons/glyphs/grouping.svg +4 -0
- package/assets/archimate3/icons/glyphs/interaction.svg +10 -0
- package/assets/archimate3/icons/glyphs/interface.svg +8 -0
- package/assets/archimate3/icons/glyphs/location.svg +6 -0
- package/assets/archimate3/icons/glyphs/material.svg +12 -0
- package/assets/archimate3/icons/glyphs/meaning.svg +3 -0
- package/assets/archimate3/icons/glyphs/node.svg +8 -0
- package/assets/archimate3/icons/glyphs/object.svg +4 -0
- package/assets/archimate3/icons/glyphs/outcome.svg +16 -0
- package/assets/archimate3/icons/glyphs/path.svg +10 -0
- package/assets/archimate3/icons/glyphs/person-silhouette.svg +3 -0
- package/assets/archimate3/icons/glyphs/plateau.svg +8 -0
- package/assets/archimate3/icons/glyphs/principle.svg +12 -0
- package/assets/archimate3/icons/glyphs/process.svg +6 -0
- package/assets/archimate3/icons/glyphs/product.svg +4 -0
- package/assets/archimate3/icons/glyphs/representation.svg +4 -0
- package/assets/archimate3/icons/glyphs/requirement.svg +6 -0
- package/assets/archimate3/icons/glyphs/resource.svg +14 -0
- package/assets/archimate3/icons/glyphs/role.svg +6 -0
- package/assets/archimate3/icons/glyphs/service.svg +6 -0
- package/assets/archimate3/icons/glyphs/stakeholder.svg +6 -0
- package/assets/archimate3/icons/glyphs/system-software.svg +14 -0
- package/assets/archimate3/icons/glyphs/value-stream.svg +3 -0
- package/assets/archimate3/icons/glyphs/value.svg +3 -0
- package/assets/archimate3/icons/glyphs/work-package.svg +4 -0
- package/assets/archimate3/icons/goal.svg +18 -0
- package/assets/archimate3/icons/grouping.svg +12 -0
- package/assets/archimate3/icons/implementation-event.svg +15 -0
- package/assets/archimate3/icons/location.svg +14 -0
- package/assets/archimate3/icons/material.svg +21 -0
- package/assets/archimate3/icons/meaning.svg +11 -0
- package/assets/archimate3/icons/node.svg +14 -0
- package/assets/archimate3/icons/or-junction.svg +3 -0
- package/assets/archimate3/icons/outcome.svg +25 -0
- package/assets/archimate3/icons/path.svg +18 -0
- package/assets/archimate3/icons/plateau.svg +16 -0
- package/assets/archimate3/icons/principle.svg +21 -0
- package/assets/archimate3/icons/product.svg +12 -0
- package/assets/archimate3/icons/representation.svg +12 -0
- package/assets/archimate3/icons/requirement.svg +14 -0
- package/assets/archimate3/icons/resource.svg +23 -0
- package/assets/archimate3/icons/stakeholder.svg +15 -0
- package/assets/archimate3/icons/system-software.svg +22 -0
- package/assets/archimate3/icons/technology-collaboration.svg +22 -0
- package/assets/archimate3/icons/technology-event.svg +15 -0
- package/assets/archimate3/icons/technology-function.svg +14 -0
- package/assets/archimate3/icons/technology-interaction.svg +18 -0
- package/assets/archimate3/icons/technology-interface.svg +16 -0
- package/assets/archimate3/icons/technology-process.svg +14 -0
- package/assets/archimate3/icons/technology-service.svg +14 -0
- package/assets/archimate3/icons/value-stream.svg +11 -0
- package/assets/archimate3/icons/value.svg +11 -0
- package/assets/archimate3/icons/work-package.svg +12 -0
- package/assets/archimate4/archimate4-element-shapes.ttl +404 -0
- package/assets/archimate4/archimate4-metamodel.ttl +179 -0
- package/assets/archimate4/archimate4-notation.ttl +1147 -0
- package/assets/archimate4/archimate4-onto.ttl +1559 -0
- package/assets/archimate4/archimate4-presentation-contexts.ttl +60 -0
- package/assets/archimate4/archimate4-principle-shapes.ttl +895 -0
- package/assets/archimate4/archimate4-questions.ttl +1224 -0
- package/assets/archimate4/archimate4-reference-data.ttl +56 -0
- package/assets/archimate4/archimate4-relationship-shapes.ttl +16920 -0
- package/assets/archimate4/archimate4-relationship-tables.ttl +3200 -0
- package/assets/archimate4/archimate4-tax.ttl +749 -0
- package/assets/archimate4/archimate4-viewpoint-shapes.ttl +55 -0
- package/assets/archimate4/archimate4-viewpoints.ttl +777 -0
- package/assets/archimate4/icons/and-junction.svg +3 -0
- package/assets/archimate4/icons/application-component.svg +18 -0
- package/assets/archimate4/icons/application-interface.svg +16 -0
- package/assets/archimate4/icons/artifact.svg +16 -0
- package/assets/archimate4/icons/assessment.svg +17 -0
- package/assets/archimate4/icons/business-actor.svg +22 -0
- package/assets/archimate4/icons/business-interface.svg +16 -0
- package/assets/archimate4/icons/business-object.svg +14 -0
- package/assets/archimate4/icons/capability.svg +40 -0
- package/assets/archimate4/icons/collaboration.svg +21 -0
- package/assets/archimate4/icons/communication-network.svg +18 -0
- package/assets/archimate4/icons/course-of-action.svg +20 -0
- package/assets/archimate4/icons/data-object.svg +14 -0
- package/assets/archimate4/icons/deliverable.svg +11 -0
- package/assets/archimate4/icons/device.svg +18 -0
- package/assets/archimate4/icons/distribution-network.svg +19 -0
- package/assets/archimate4/icons/driver.svg +24 -0
- package/assets/archimate4/icons/equipment.svg +31 -0
- package/assets/archimate4/icons/event.svg +15 -0
- package/assets/archimate4/icons/facility.svg +16 -0
- package/assets/archimate4/icons/function.svg +13 -0
- package/assets/archimate4/icons/glyphs/activity.svg +3 -0
- package/assets/archimate4/icons/glyphs/actor.svg +14 -0
- package/assets/archimate4/icons/glyphs/application-component.svg +12 -0
- package/assets/archimate4/icons/glyphs/artifact.svg +9 -0
- package/assets/archimate4/icons/glyphs/assessment.svg +9 -0
- package/assets/archimate4/icons/glyphs/capability.svg +32 -0
- package/assets/archimate4/icons/glyphs/cloud-gear.svg +3 -0
- package/assets/archimate4/icons/glyphs/collaboration.svg +15 -0
- package/assets/archimate4/icons/glyphs/communication-network.svg +12 -0
- package/assets/archimate4/icons/glyphs/constraint.svg +10 -0
- package/assets/archimate4/icons/glyphs/contract.svg +5 -0
- package/assets/archimate4/icons/glyphs/course-of-action.svg +12 -0
- package/assets/archimate4/icons/glyphs/data-object.svg +4 -0
- package/assets/archimate4/icons/glyphs/deliverable.svg +3 -0
- package/assets/archimate4/icons/glyphs/device.svg +10 -0
- package/assets/archimate4/icons/glyphs/distribution-network.svg +11 -0
- package/assets/archimate4/icons/glyphs/driver.svg +16 -0
- package/assets/archimate4/icons/glyphs/equipment.svg +22 -0
- package/assets/archimate4/icons/glyphs/event.svg +6 -0
- package/assets/archimate4/icons/glyphs/facility.svg +7 -0
- package/assets/archimate4/icons/glyphs/function.svg +6 -0
- package/assets/archimate4/icons/glyphs/gap.svg +14 -0
- package/assets/archimate4/icons/glyphs/goal.svg +10 -0
- package/assets/archimate4/icons/glyphs/grouping.svg +4 -0
- package/assets/archimate4/icons/glyphs/interaction.svg +10 -0
- package/assets/archimate4/icons/glyphs/interface.svg +8 -0
- package/assets/archimate4/icons/glyphs/location.svg +6 -0
- package/assets/archimate4/icons/glyphs/material.svg +12 -0
- package/assets/archimate4/icons/glyphs/meaning.svg +3 -0
- package/assets/archimate4/icons/glyphs/node.svg +8 -0
- package/assets/archimate4/icons/glyphs/object.svg +4 -0
- package/assets/archimate4/icons/glyphs/outcome.svg +16 -0
- package/assets/archimate4/icons/glyphs/path.svg +10 -0
- package/assets/archimate4/icons/glyphs/person-silhouette.svg +3 -0
- package/assets/archimate4/icons/glyphs/plateau.svg +8 -0
- package/assets/archimate4/icons/glyphs/principle.svg +12 -0
- package/assets/archimate4/icons/glyphs/process.svg +6 -0
- package/assets/archimate4/icons/glyphs/product.svg +4 -0
- package/assets/archimate4/icons/glyphs/representation.svg +4 -0
- package/assets/archimate4/icons/glyphs/requirement.svg +6 -0
- package/assets/archimate4/icons/glyphs/resource.svg +14 -0
- package/assets/archimate4/icons/glyphs/role.svg +6 -0
- package/assets/archimate4/icons/glyphs/service.svg +6 -0
- package/assets/archimate4/icons/glyphs/stakeholder.svg +6 -0
- package/assets/archimate4/icons/glyphs/system-software.svg +14 -0
- package/assets/archimate4/icons/glyphs/value-stream.svg +3 -0
- package/assets/archimate4/icons/glyphs/value.svg +3 -0
- package/assets/archimate4/icons/glyphs/work-package.svg +4 -0
- package/assets/archimate4/icons/goal.svg +18 -0
- package/assets/archimate4/icons/grouping.svg +12 -0
- package/assets/archimate4/icons/location.svg +14 -0
- package/assets/archimate4/icons/material.svg +21 -0
- package/assets/archimate4/icons/meaning.svg +11 -0
- package/assets/archimate4/icons/node.svg +14 -0
- package/assets/archimate4/icons/or-junction.svg +3 -0
- package/assets/archimate4/icons/outcome.svg +25 -0
- package/assets/archimate4/icons/path.svg +18 -0
- package/assets/archimate4/icons/plateau.svg +16 -0
- package/assets/archimate4/icons/principle.svg +21 -0
- package/assets/archimate4/icons/process.svg +15 -0
- package/assets/archimate4/icons/product.svg +12 -0
- package/assets/archimate4/icons/requirement.svg +14 -0
- package/assets/archimate4/icons/resource.svg +23 -0
- package/assets/archimate4/icons/role.svg +16 -0
- package/assets/archimate4/icons/service.svg +13 -0
- package/assets/archimate4/icons/stakeholder.svg +15 -0
- package/assets/archimate4/icons/system-software.svg +22 -0
- package/assets/archimate4/icons/technology-interface.svg +16 -0
- package/assets/archimate4/icons/value-stream.svg +11 -0
- package/assets/archimate4/icons/value.svg +11 -0
- package/assets/archimate4/icons/work-package.svg +12 -0
- package/assets/basic/basic-metamodel.ttl +100 -0
- package/assets/basic/basic-notation-bubble.ttl +175 -0
- package/assets/basic/basic-notation.ttl +172 -0
- package/assets/basic/basic-onto.ttl +171 -0
- package/assets/basic/basic-presentation-contexts.ttl +70 -0
- package/assets/basic/basic-tax.ttl +130 -0
- package/assets/basic/icons/aggregation.svg +7 -0
- package/assets/basic/icons/association.svg +6 -0
- package/assets/basic/icons/element.svg +5 -0
- package/assets/basic/icons/glyphs/aggregation.svg +6 -0
- package/assets/basic/icons/glyphs/association.svg +5 -0
- package/assets/basic/icons/glyphs/element.svg +5 -0
- package/assets/basic/icons/glyphs/relationship.svg +5 -0
- package/assets/basic/icons/relationship.svg +7 -0
- package/assets/basic/notation-bubble/icons/aggregation.svg +7 -0
- package/assets/basic/notation-bubble/icons/association.svg +6 -0
- package/assets/basic/notation-bubble/icons/element.svg +5 -0
- package/assets/basic/notation-bubble/icons/glyphs/aggregation.svg +6 -0
- package/assets/basic/notation-bubble/icons/glyphs/association.svg +5 -0
- package/assets/basic/notation-bubble/icons/glyphs/element.svg +5 -0
- package/assets/basic/notation-bubble/icons/glyphs/relationship.svg +5 -0
- package/assets/basic/notation-bubble/icons/relationship.svg +7 -0
- package/assets/catalog.ttl +7406 -0
- package/assets/core/core-notation.ttl +131 -0
- package/assets/core/core-onto.ttl +2811 -0
- package/assets/core/core-questions.ttl +957 -0
- package/assets/core/core-shapes.ttl +915 -0
- package/assets/core/core-vis-onto.ttl +1408 -0
- package/assets/core/core-vis-shapes.ttl +851 -0
- package/assets/core-vis/markers/circle-dot.svg +3 -0
- package/assets/core-vis/markers/closed-arrowhead.svg +3 -0
- package/assets/core-vis/markers/filled-diamond.svg +3 -0
- package/assets/core-vis/markers/half-arrowhead.svg +3 -0
- package/assets/core-vis/markers/hollow-arrowhead.svg +3 -0
- package/assets/core-vis/markers/hollow-diamond.svg +3 -0
- package/assets/core-vis/markers/open-arrowhead.svg +3 -0
- package/fixtures/interoperability/archimate4-demo.trig +259 -0
- package/fixtures/interoperability/expected-findings.json +26 -0
- package/fixtures/interoperability/shop-seed.ttl +225 -0
- package/package.json +136 -4
- package/scripts/sync-assets.mjs +252 -0
- package/src/conformance.ts +66 -0
- package/src/import-export/model-io.ts +426 -0
- package/src/index.ts +11 -0
- package/src/metamodel-manager/asset-sources.ts +754 -0
- package/src/metamodel-manager/bundled-assets.ts +599 -0
- package/src/metamodel-manager/catalogue.ts +114 -0
- package/src/metamodel-manager/class-hierarchy.ts +155 -0
- package/src/metamodel-manager/index.ts +65 -0
- package/src/metamodel-manager/interfaces.ts +422 -0
- package/src/metamodel-manager/metamodel-completeness.ts +162 -0
- package/src/metamodel-manager/metamodel-loader.ts +864 -0
- package/src/metamodel-manager/notation-resolver.ts +284 -0
- package/src/metamodel-manager/notation.ts +659 -0
- package/src/metamodel-manager/palette-generator.ts +882 -0
- package/src/metamodel-manager/property-shapes.ts +290 -0
- package/src/metamodel-manager/taxonomy.ts +904 -0
- package/src/metamodel-manager/type-guide.ts +241 -0
- package/src/metamodel-manager/viewpoint-manager.ts +147 -0
- package/src/model-manager/appearance.ts +389 -0
- package/src/model-manager/cascade.ts +246 -0
- package/src/model-manager/clipboard.ts +566 -0
- package/src/model-manager/context-names.ts +108 -0
- package/src/model-manager/custom-properties.ts +549 -0
- package/src/model-manager/derivations.ts +166 -0
- package/src/model-manager/direct-permissions.ts +182 -0
- package/src/model-manager/drawing-order.ts +119 -0
- package/src/model-manager/element-manager.ts +69 -0
- package/src/model-manager/element-pictures.ts +118 -0
- package/src/model-manager/field-names.ts +42 -0
- package/src/model-manager/folders.ts +354 -0
- package/src/model-manager/grid.ts +6 -0
- package/src/model-manager/index.ts +43 -0
- package/src/model-manager/interfaces.ts +417 -0
- package/src/model-manager/iri-conformance.ts +183 -0
- package/src/model-manager/label-expression.ts +233 -0
- package/src/model-manager/legacy-migration.ts +200 -0
- package/src/model-manager/missing-references.ts +86 -0
- package/src/model-manager/model-diff-text.ts +150 -0
- package/src/model-manager/model-diff.ts +534 -0
- package/src/model-manager/model-merge.ts +1160 -0
- package/src/model-manager/model-namespace.ts +199 -0
- package/src/model-manager/model-operations.ts +132 -0
- package/src/model-manager/model-queries.ts +616 -0
- package/src/model-manager/model-session.ts +759 -0
- package/src/model-manager/multiplicity.ts +74 -0
- package/src/model-manager/nested-resources.ts +145 -0
- package/src/model-manager/own-metamodel.ts +157 -0
- package/src/model-manager/placement-copy.ts +116 -0
- package/src/model-manager/property-catalog.ts +787 -0
- package/src/model-manager/proposal-order.ts +203 -0
- package/src/model-manager/provenance.ts +396 -0
- package/src/model-manager/questions.ts +475 -0
- package/src/model-manager/rdf-scope.ts +97 -0
- package/src/model-manager/relationship-graph.ts +462 -0
- package/src/model-manager/relationship-manager.ts +962 -0
- package/src/model-manager/relationship-table.ts +189 -0
- package/src/model-manager/relationship-validity.ts +261 -0
- package/src/model-manager/resource-edits.ts +28 -0
- package/src/model-manager/short-hash.ts +104 -0
- package/src/model-manager/snapshot-lines.ts +88 -0
- package/src/model-manager/version-history.ts +205 -0
- package/src/model-manager/view-from-results.ts +81 -0
- package/src/model-manager/view-manager.ts +1410 -0
- package/src/model-manager/vocabulary.ts +279 -0
- package/src/rdf-engine/finding-shape.ts +23 -0
- package/src/rdf-engine/graph-scope.ts +163 -0
- package/src/rdf-engine/index.ts +7 -0
- package/src/rdf-engine/interfaces.ts +144 -0
- package/src/rdf-engine/iri.ts +203 -0
- package/src/rdf-engine/localized-text.ts +13 -0
- package/src/rdf-engine/namespaces.ts +41 -0
- package/src/rdf-engine/native-load.ts +37 -0
- package/src/rdf-engine/observable-store.ts +609 -0
- package/src/rdf-engine/rdf-store.ts +520 -0
- package/src/rdf-engine/shacl-validator.ts +602 -0
- package/src/rdf-engine/shape-reach.ts +140 -0
- package/src/rdf-engine/shape-switches.ts +165 -0
- package/src/rdf-engine/single-valued.ts +219 -0
- package/src/rdf-engine/sparql-constraints.ts +349 -0
- package/src/rdf-engine/term-codec.ts +51 -0
- package/src/rdf-engine/ttl-parser.ts +51 -0
- package/src/rdf-engine/ttl-serializer.ts +79 -0
- package/src/rdf-engine/turtle-writer.ts +284 -0
- package/src/rdf-engine/validation-engine.ts +747 -0
- package/src/rdf-engine/validation-service.ts +186 -0
- package/src/rdf-engine/validation.worker.ts +47 -0
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metamodel Loader implementation.
|
|
3
|
+
*
|
|
4
|
+
* A real metamodel is not one file. The Linked.Archi languages publish an
|
|
5
|
+
* `arch:Metamodel` *manifest* that points at the separate documents making up
|
|
6
|
+
* the language definition:
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
9
|
+
* am4mm:ArchiMate4 a arch:Metamodel ;
|
|
10
|
+
* arch:modelConcepts <.../archimate4/onto#> ; # the OWL classes
|
|
11
|
+
* arch:conceptClassification <.../archimate4/tax#> ; # the SKOS taxonomy
|
|
12
|
+
* arch:notationSet am4not:ArchiMate40StandardNotation ;
|
|
13
|
+
* arch:formalRules <.../element-shapes#>, … ; # SHACL
|
|
14
|
+
* arch:architectureViewpoints <.../viewpoints#> ;
|
|
15
|
+
* arch:presentationContextScheme am4pc:ArchiMatePresentationContexts .
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Note that some of those values name a *document* (`…/tax#`) while others name
|
|
19
|
+
* an *individual inside* a document (`am4not:ArchiMate40StandardNotation`).
|
|
20
|
+
* {@link documentIriFor} normalises both to the document IRI, which is what the
|
|
21
|
+
* bundled-asset registry is keyed by and what each graph is named after.
|
|
22
|
+
*
|
|
23
|
+
* Discovery follows those properties, every loaded document's `owl:imports`,
|
|
24
|
+
* and the `arch:usesNotationSet` of the presentation contexts — the one place
|
|
25
|
+
* an alternative notation set (Basic's bubble set) is named.
|
|
26
|
+
*
|
|
27
|
+
* ## One graph per document
|
|
28
|
+
*
|
|
29
|
+
* Every discovered document lands in its own named graph, keyed by its ontology
|
|
30
|
+
* IRI. That keeps provenance intact — a caller can ask "what did the notation
|
|
31
|
+
* file say" — and it is what {@link LoadedMetamodel.graphsByRole} reports back.
|
|
32
|
+
*
|
|
33
|
+
* ## Where documents come from
|
|
34
|
+
*
|
|
35
|
+
* Each document IRI is handed to an {@link AssetSource}: the bundle under
|
|
36
|
+
* `assets/`, the network (`meta.linked.archi` or any dereferenceable IRI), or
|
|
37
|
+
* files the user uploaded — chained, see `asset-sources.ts`. The loader does not
|
|
38
|
+
* care which answered; the status entry records it.
|
|
39
|
+
*
|
|
40
|
+
* ## Honest partial loads
|
|
41
|
+
*
|
|
42
|
+
* A manifest references more than an editor needs — derivation rules,
|
|
43
|
+
* deliverable templates, reference models — and a source may not reach every
|
|
44
|
+
* document. Rather than fail or silently skip, every discovered asset gets a
|
|
45
|
+
* {@link MetamodelAssetStatus} entry, so a caller can tell the user exactly
|
|
46
|
+
* which layer is missing and why.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import { DataFactory } from 'n3';
|
|
50
|
+
import type { Quad } from '@rdfjs/types';
|
|
51
|
+
import type { TtlParser, RdfStore } from '../rdf-engine/interfaces.js';
|
|
52
|
+
import { NAMESPACES } from '../rdf-engine/namespaces.js';
|
|
53
|
+
import { isSafeIri } from '../rdf-engine/graph-scope.js';
|
|
54
|
+
import type {
|
|
55
|
+
MetamodelLoader,
|
|
56
|
+
MetamodelInfo,
|
|
57
|
+
LoadedMetamodel,
|
|
58
|
+
MetamodelAssetStatus,
|
|
59
|
+
} from './interfaces.js';
|
|
60
|
+
import {
|
|
61
|
+
BUNDLED_ASSETS,
|
|
62
|
+
DEFAULT_METAMODEL,
|
|
63
|
+
fetchAssetText,
|
|
64
|
+
getAssetByIri,
|
|
65
|
+
getAssetsByRole,
|
|
66
|
+
getBundledMetamodel,
|
|
67
|
+
type BundledAsset,
|
|
68
|
+
type BundledAssetRole,
|
|
69
|
+
} from './bundled-assets.js';
|
|
70
|
+
import {
|
|
71
|
+
BundledAssetSource,
|
|
72
|
+
parseRdf,
|
|
73
|
+
type AssetDocument,
|
|
74
|
+
type AssetFormat,
|
|
75
|
+
type AssetOrigin,
|
|
76
|
+
type AssetSource,
|
|
77
|
+
} from './asset-sources.js';
|
|
78
|
+
import { compareIris } from './class-hierarchy.js';
|
|
79
|
+
|
|
80
|
+
const { namedNode, quad } = DataFactory;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* `dcterms:` — what the published Linked.Archi files actually use for title and
|
|
84
|
+
* description. `NAMESPACES.dc` is the older `dc:` elements namespace; both are
|
|
85
|
+
* read so hand-written and published metamodels behave the same.
|
|
86
|
+
*/
|
|
87
|
+
const DCTERMS = 'http://purl.org/dc/terms/';
|
|
88
|
+
|
|
89
|
+
const RDF_TYPE = namedNode(NAMESPACES.rdf + 'type');
|
|
90
|
+
const OWL_ONTOLOGY = namedNode(NAMESPACES.owl + 'Ontology');
|
|
91
|
+
const OWL_IMPORTS = namedNode(NAMESPACES.owl + 'imports');
|
|
92
|
+
const OWL_VERSION_INFO = namedNode(NAMESPACES.owl + 'versionInfo');
|
|
93
|
+
const DC_TITLE = namedNode(NAMESPACES.dc + 'title');
|
|
94
|
+
const DC_DESCRIPTION = namedNode(NAMESPACES.dc + 'description');
|
|
95
|
+
const DCTERMS_TITLE = namedNode(DCTERMS + 'title');
|
|
96
|
+
const DCTERMS_DESCRIPTION = namedNode(DCTERMS + 'description');
|
|
97
|
+
const SKOS_PREF_LABEL = namedNode(NAMESPACES.skos + 'prefLabel');
|
|
98
|
+
const ARCH_METAMODEL = namedNode(NAMESPACES.arch + 'Metamodel');
|
|
99
|
+
const ARCH_NOTATION_SET = namedNode(NAMESPACES.arch + 'notationSet');
|
|
100
|
+
const ARCH_USES_NOTATION_SET = namedNode(NAMESPACES.arch + 'usesNotationSet');
|
|
101
|
+
|
|
102
|
+
/** Default graph IRI used for SHACL shapes. */
|
|
103
|
+
const SHAPES_GRAPH = namedNode('urn:la-gram:shapes');
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Manifest properties that point at another part of the language definition,
|
|
107
|
+
* in the order they are followed.
|
|
108
|
+
*
|
|
109
|
+
* Ordering is cosmetic — everything ends up as quads either way — but following
|
|
110
|
+
* concepts before classification before notation makes the status list read the
|
|
111
|
+
* way the layers stack.
|
|
112
|
+
*/
|
|
113
|
+
const MANIFEST_ASSET_PROPERTIES: readonly string[] = [
|
|
114
|
+
'modelConcepts',
|
|
115
|
+
'conceptClassification',
|
|
116
|
+
'notationSet',
|
|
117
|
+
'formalRules',
|
|
118
|
+
'architectureViewpoints',
|
|
119
|
+
'viewpointLibrary',
|
|
120
|
+
'architectureViewpointsRestrictions',
|
|
121
|
+
'presentationContextScheme',
|
|
122
|
+
'derivationRules',
|
|
123
|
+
'referenceData',
|
|
124
|
+
'referenceModels',
|
|
125
|
+
'hasDeliverableTemplate',
|
|
126
|
+
'hasQuestionSet',
|
|
127
|
+
'basedOnFramework',
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Normalise a manifest value to the IRI of the document that defines it.
|
|
132
|
+
*
|
|
133
|
+
* `https://…/archimate4/tax#` is already a document IRI. `am4not:ArchiMate40-
|
|
134
|
+
* StandardNotation` is an individual, and the document that defines it is
|
|
135
|
+
* `https://…/archimate4/notation#` — everything up to and including the `#`.
|
|
136
|
+
*/
|
|
137
|
+
function documentIriFor(iri: string): string {
|
|
138
|
+
// A bundled document, by its IRI or its owl:versionIRI: the graph is named by the former.
|
|
139
|
+
const bundled = getAssetByIri(iri);
|
|
140
|
+
if (bundled) return bundled.ontologyIri;
|
|
141
|
+
const hash = iri.indexOf('#');
|
|
142
|
+
if (hash === -1) return iri;
|
|
143
|
+
return iri.slice(0, hash + 1);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Manifest properties whose targets the editor never reads. They are recorded
|
|
148
|
+
* with outcome `skipped` instead of being fetched: derivation rules need a
|
|
149
|
+
* SHACL-AF engine, and the rest feed document generation. Reference data is
|
|
150
|
+
* loaded: its concepts name the values a property may take.
|
|
151
|
+
*/
|
|
152
|
+
const SKIPPED_VIA: readonly string[] = [
|
|
153
|
+
'derivationRules',
|
|
154
|
+
'referenceModels',
|
|
155
|
+
'hasDeliverableTemplate',
|
|
156
|
+
'basedOnFramework',
|
|
157
|
+
];
|
|
158
|
+
|
|
159
|
+
/** The role a document plays, judged by the manifest property that named it. */
|
|
160
|
+
function roleFromVia(via: string): BundledAssetRole | undefined {
|
|
161
|
+
switch (via) {
|
|
162
|
+
case 'arch:modelConcepts':
|
|
163
|
+
return 'ontology';
|
|
164
|
+
case 'arch:conceptClassification':
|
|
165
|
+
return 'taxonomy';
|
|
166
|
+
case 'arch:notationSet':
|
|
167
|
+
case 'arch:usesNotationSet':
|
|
168
|
+
return 'notation';
|
|
169
|
+
case 'arch:formalRules':
|
|
170
|
+
case 'arch:architectureViewpointsRestrictions':
|
|
171
|
+
return 'shapes';
|
|
172
|
+
case 'arch:architectureViewpoints':
|
|
173
|
+
case 'arch:viewpointLibrary':
|
|
174
|
+
return 'viewpoints';
|
|
175
|
+
case 'arch:presentationContextScheme':
|
|
176
|
+
return 'presentationContexts';
|
|
177
|
+
case 'arch:derivationRules':
|
|
178
|
+
return 'derivationRules';
|
|
179
|
+
case 'arch:referenceData':
|
|
180
|
+
return 'referenceData';
|
|
181
|
+
case 'arch:hasQuestionSet':
|
|
182
|
+
return 'questions';
|
|
183
|
+
default:
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** A base IRI for resolving relative IRIs in a document: its IRI without the fragment. */
|
|
189
|
+
function dereferenceBase(documentIri: string): string {
|
|
190
|
+
const hash = documentIri.indexOf('#');
|
|
191
|
+
return hash === -1 ? documentIri : documentIri.slice(0, hash);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** An IRI queued for loading, with a note on how it was discovered. */
|
|
195
|
+
interface DiscoveredRef {
|
|
196
|
+
referencedIri: string;
|
|
197
|
+
via: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** The core's documents — the ontology, core-vis, their shapes, questions and viewpoints: every metamodel's, never unloaded with one. */
|
|
201
|
+
const CORE_DOCUMENTS = 'https://meta.linked.archi/core';
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Concrete MetamodelLoader backed by a TtlParser and RdfStore.
|
|
205
|
+
*
|
|
206
|
+
* Each document is loaded into a named graph keyed by its ontology IRI.
|
|
207
|
+
* SHACL shapes loaded through {@link loadShapes} go to a dedicated shapes graph
|
|
208
|
+
* so the validator can find them without knowing the language.
|
|
209
|
+
*/
|
|
210
|
+
export class N3MetamodelLoader implements MetamodelLoader {
|
|
211
|
+
/** Document IRIs already loaded — dedup key for both manifests and imports. */
|
|
212
|
+
private loadedOntologies = new Set<string>();
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @param source Where documents come from. Defaults to the bundle alone, which
|
|
216
|
+
* is what tests and offline use want; the application passes a chain that
|
|
217
|
+
* also dereferences IRIs over the network.
|
|
218
|
+
*/
|
|
219
|
+
constructor(
|
|
220
|
+
private parser: TtlParser,
|
|
221
|
+
private store: RdfStore,
|
|
222
|
+
private source: AssetSource = new BundledAssetSource(),
|
|
223
|
+
) {}
|
|
224
|
+
|
|
225
|
+
/** Swap the document source (e.g. when the user goes offline). */
|
|
226
|
+
setSource(source: AssetSource): void {
|
|
227
|
+
this.source = source;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ── Raw single-document loading ──────────────────────────────────────
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Load one TTL document into a named graph keyed by its ontology IRI.
|
|
234
|
+
*
|
|
235
|
+
* Kept for raw TTL — hand-written test metamodels, a file the user opened —
|
|
236
|
+
* where there is no manifest to follow.
|
|
237
|
+
*/
|
|
238
|
+
async loadMetamodel(ttlContent: string): Promise<MetamodelInfo> {
|
|
239
|
+
const quads = this.parseOrThrow(ttlContent, 'metamodel TTL');
|
|
240
|
+
|
|
241
|
+
const ontologyIri = this.findOntologyIri(quads);
|
|
242
|
+
if (!ontologyIri) {
|
|
243
|
+
throw new Error('No ontology IRI found in metamodel (expected rdf:type owl:Ontology or dc:title)');
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
this.addToGraph(quads, ontologyIri);
|
|
247
|
+
this.loadedOntologies.add(ontologyIri);
|
|
248
|
+
|
|
249
|
+
return this.readInfo(quads, ontologyIri);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// ── Manifest-driven loading ──────────────────────────────────────────
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Load a metamodel from its manifest, pulling in every document the manifest
|
|
256
|
+
* points at plus their transitive `owl:imports`, from whatever the configured
|
|
257
|
+
* {@link AssetSource} can reach. A presentation-contexts document adds the
|
|
258
|
+
* notation sets its contexts select (`arch:usesNotationSet`): an alternative
|
|
259
|
+
* set is named only there. The manifest's `arch:notationSet` stays the
|
|
260
|
+
* default ({@link LoadedMetamodel.notationSetIri}).
|
|
261
|
+
*
|
|
262
|
+
* The manifest itself is loaded first so the `arch:Metamodel` subject is
|
|
263
|
+
* queryable even if nothing else resolves. Discovered documents are fetched a
|
|
264
|
+
* level at a time and in parallel: over the network the difference between
|
|
265
|
+
* nine sequential round-trips and two parallel batches is most of cold start.
|
|
266
|
+
*
|
|
267
|
+
* @param manifestText The manifest document.
|
|
268
|
+
* @param options.format Its serialization (Turtle by default).
|
|
269
|
+
* @param options.metamodelIri Which `arch:Metamodel` subject to use when the
|
|
270
|
+
* document declares more than one.
|
|
271
|
+
*/
|
|
272
|
+
async loadMetamodelFromManifest(
|
|
273
|
+
manifestText: string,
|
|
274
|
+
options: { format?: AssetFormat; metamodelIri?: string; origin?: AssetOrigin; location?: string } = {},
|
|
275
|
+
): Promise<LoadedMetamodel> {
|
|
276
|
+
const manifestQuads = this.parseDocument(manifestText, options.format, 'metamodel manifest');
|
|
277
|
+
|
|
278
|
+
const metamodelIri = this.findMetamodelSubject(manifestQuads, options.metamodelIri);
|
|
279
|
+
if (!metamodelIri) {
|
|
280
|
+
throw new Error('No arch:Metamodel subject found in the manifest');
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const manifestGraphIri = this.findOntologyIri(manifestQuads) ?? documentIriFor(metamodelIri);
|
|
284
|
+
this.addToGraph(manifestQuads, manifestGraphIri);
|
|
285
|
+
this.loadedOntologies.add(manifestGraphIri);
|
|
286
|
+
|
|
287
|
+
const assets: MetamodelAssetStatus[] = [
|
|
288
|
+
{
|
|
289
|
+
referencedIri: metamodelIri,
|
|
290
|
+
documentIri: manifestGraphIri,
|
|
291
|
+
via: 'manifest',
|
|
292
|
+
role: 'manifest',
|
|
293
|
+
outcome: 'loaded',
|
|
294
|
+
quadCount: manifestQuads.length,
|
|
295
|
+
...(options.origin ? { origin: options.origin } : {}),
|
|
296
|
+
...(options.origin === 'uploaded' && options.location ? { location: options.location } : {}),
|
|
297
|
+
},
|
|
298
|
+
];
|
|
299
|
+
const graphsByRole: Partial<Record<BundledAssetRole, string[]>> = { manifest: [manifestGraphIri] };
|
|
300
|
+
|
|
301
|
+
// Everything the manifest points at, then everything those documents import.
|
|
302
|
+
let level: DiscoveredRef[] = [
|
|
303
|
+
...this.discoverManifestRefs(manifestQuads, metamodelIri),
|
|
304
|
+
...this.discoverImports(manifestQuads, manifestGraphIri),
|
|
305
|
+
];
|
|
306
|
+
const seen = new Set<string>([manifestGraphIri]);
|
|
307
|
+
|
|
308
|
+
while (level.length > 0) {
|
|
309
|
+
// De-duplicate the level first so two references to one document cost one
|
|
310
|
+
// fetch, and so the status list names the first way it was reached.
|
|
311
|
+
const batch: Array<{ ref: DiscoveredRef; documentIri: string }> = [];
|
|
312
|
+
for (const ref of level) {
|
|
313
|
+
const documentIri = documentIriFor(ref.referencedIri);
|
|
314
|
+
if (seen.has(documentIri)) continue;
|
|
315
|
+
seen.add(documentIri);
|
|
316
|
+
batch.push({ ref, documentIri });
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const results = await Promise.all(
|
|
320
|
+
batch.map(({ ref, documentIri }) => this.resolveRef(ref, documentIri)),
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
const next: DiscoveredRef[] = [];
|
|
324
|
+
for (const status of results) {
|
|
325
|
+
assets.push(status);
|
|
326
|
+
if (status.role && (status.outcome === 'loaded' || status.outcome === 'already-loaded')) {
|
|
327
|
+
this.recordRole(graphsByRole, status.role, status.documentIri);
|
|
328
|
+
}
|
|
329
|
+
if (status.outcome === 'loaded') {
|
|
330
|
+
// Follow this document's own imports, still deduping by document IRI.
|
|
331
|
+
// Only the owl:imports quads are read back — materialising a 70 000-quad
|
|
332
|
+
// shapes graph to find its one import would undo the bulk load.
|
|
333
|
+
const importQuads = this.store.getQuads(null, OWL_IMPORTS, null, namedNode(status.documentIri));
|
|
334
|
+
next.push(...this.discoverImports(importQuads, status.documentIri));
|
|
335
|
+
// The alternative notation sets live where the contexts choose them,
|
|
336
|
+
// not on the manifest — load them too, or choosing the context finds nothing.
|
|
337
|
+
if (status.role === 'presentationContexts') {
|
|
338
|
+
next.push(...this.discoverContextNotationSets(status.documentIri));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
level = next;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const notationSetIri = this.firstObject(manifestQuads, metamodelIri, ARCH_NOTATION_SET.value);
|
|
346
|
+
const presentationContextSchemeIri = this.firstObject(
|
|
347
|
+
manifestQuads,
|
|
348
|
+
metamodelIri,
|
|
349
|
+
NAMESPACES.arch + 'presentationContextScheme',
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
return {
|
|
353
|
+
metamodelIri,
|
|
354
|
+
manifestGraphIri,
|
|
355
|
+
info: this.readManifestInfo(manifestQuads, metamodelIri, manifestGraphIri),
|
|
356
|
+
graphsByRole,
|
|
357
|
+
notationSetIri,
|
|
358
|
+
...(presentationContextSchemeIri ? { presentationContextSchemeIri } : {}),
|
|
359
|
+
assets,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Load a metamodel given any IRI naming it — the `arch:Metamodel` subject
|
|
365
|
+
* (`…/archimate4/metamodel#ArchiMate4`), the manifest document
|
|
366
|
+
* (`…/archimate4/metamodel#`) or its dereferenceable URL.
|
|
367
|
+
*
|
|
368
|
+
* The manifest is fetched through the configured source, so this works for
|
|
369
|
+
* the bundled languages offline and for every published language online.
|
|
370
|
+
*/
|
|
371
|
+
async loadMetamodelByIri(iri: string): Promise<LoadedMetamodel> {
|
|
372
|
+
const bundled = getBundledMetamodel(iri);
|
|
373
|
+
const documentIri = bundled?.manifestIri ?? documentIriFor(iri.includes('#') ? iri : `${iri}#`);
|
|
374
|
+
const doc = await this.source.fetch(documentIri);
|
|
375
|
+
if (!doc) {
|
|
376
|
+
throw new Error(`No source could provide the metamodel manifest <${documentIri}>`);
|
|
377
|
+
}
|
|
378
|
+
const preferred = bundled?.metamodelIri ?? (iri.includes('#') && !iri.endsWith('#') ? iri : undefined);
|
|
379
|
+
return this.loadMetamodelFromManifest(doc.text, {
|
|
380
|
+
format: doc.format,
|
|
381
|
+
origin: doc.origin,
|
|
382
|
+
...(doc.location ? { location: doc.location } : {}),
|
|
383
|
+
...(preferred ? { metamodelIri: preferred } : {}),
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Load a bundled metamodel — ArchiMate 4.0 unless another bundled id or IRI
|
|
389
|
+
* is given. Convenience over {@link loadMetamodelFromManifest}: reads the
|
|
390
|
+
* bundled manifest and follows it from there.
|
|
391
|
+
*/
|
|
392
|
+
async loadBundledMetamodel(idOrIri?: string): Promise<LoadedMetamodel> {
|
|
393
|
+
const bundled = idOrIri ? getBundledMetamodel(idOrIri) : DEFAULT_METAMODEL;
|
|
394
|
+
const manifest: BundledAsset | undefined = bundled
|
|
395
|
+
? getAssetsByRole('manifest', bundled.id)[0]
|
|
396
|
+
: undefined;
|
|
397
|
+
if (!manifest) {
|
|
398
|
+
throw new Error(
|
|
399
|
+
`No bundled manifest for '${idOrIri ?? 'default'}' (${BUNDLED_ASSETS.length} assets registered)`,
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
const ttl = await fetchAssetText(manifest);
|
|
403
|
+
return this.loadMetamodelFromManifest(ttl, {
|
|
404
|
+
origin: 'bundled',
|
|
405
|
+
...(bundled ? { metamodelIri: bundled.metamodelIri } : {}),
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Load the core documents every model is validated against, whether or not a
|
|
411
|
+
* manifest imports them: `core`, `core-vis` and their two shapes graphs.
|
|
412
|
+
*
|
|
413
|
+
* @returns The graph IRIs that are now present, keyed by role.
|
|
414
|
+
*/
|
|
415
|
+
async loadCoreAssets(): Promise<Partial<Record<BundledAssetRole, string[]>>> {
|
|
416
|
+
const graphsByRole: Partial<Record<BundledAssetRole, string[]>> = {};
|
|
417
|
+
const core = BUNDLED_ASSETS.filter((asset) => asset.metamodel === undefined);
|
|
418
|
+
const results = await Promise.all(
|
|
419
|
+
core.map((asset) =>
|
|
420
|
+
this.resolveRef({ referencedIri: asset.ontologyIri, via: 'core' }, asset.ontologyIri),
|
|
421
|
+
),
|
|
422
|
+
);
|
|
423
|
+
for (const status of results) {
|
|
424
|
+
if (status.role && (status.outcome === 'loaded' || status.outcome === 'already-loaded')) {
|
|
425
|
+
this.recordRole(graphsByRole, status.role, status.documentIri);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return graphsByRole;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Remove a metamodel's graphs from the store.
|
|
433
|
+
*
|
|
434
|
+
* Graphs still used by a metamodel in `keep` — the shared core ontologies,
|
|
435
|
+
* above all — stay. The model data in the default graph is never touched:
|
|
436
|
+
* switching language must not delete anybody's work.
|
|
437
|
+
*
|
|
438
|
+
* @returns The graph IRIs that were dropped.
|
|
439
|
+
*/
|
|
440
|
+
unloadMetamodel(loaded: LoadedMetamodel, keep: readonly LoadedMetamodel[] = []): string[] {
|
|
441
|
+
// Every document the metamodel loaded, or found loaded: those its manifest names (by role) and those they
|
|
442
|
+
// import (an extension ontology, another version's ontology — no role), which stayed behind when only the
|
|
443
|
+
// roles were dropped: LeanIX v3 left v4's types on the palette.
|
|
444
|
+
const documentsOf = (m: LoadedMetamodel): string[] => [
|
|
445
|
+
...Object.values(m.graphsByRole).flatMap((graphs) => graphs ?? []),
|
|
446
|
+
...m.assets.filter((a) => a.outcome === 'loaded' || a.outcome === 'already-loaded').map((a) => a.documentIri),
|
|
447
|
+
];
|
|
448
|
+
const retained = new Set(keep.flatMap(documentsOf));
|
|
449
|
+
const core = new Set(
|
|
450
|
+
(['coreOntology', 'coreVisOntology', 'coreShapes'] as const).flatMap((role) => loaded.graphsByRole[role] ?? []),
|
|
451
|
+
);
|
|
452
|
+
const dropped: string[] = [];
|
|
453
|
+
for (const graph of new Set(documentsOf(loaded))) {
|
|
454
|
+
if (retained.has(graph) || core.has(graph) || graph.startsWith(CORE_DOCUMENTS)) continue;
|
|
455
|
+
// One SPARQL DROP rather than materialising and removing each quad:
|
|
456
|
+
// the relationship-shapes graphs alone are 70 000 quads.
|
|
457
|
+
if (isSafeIri(graph)) {
|
|
458
|
+
this.store.update(`DROP SILENT GRAPH <${graph}>`);
|
|
459
|
+
} else {
|
|
460
|
+
const quads = this.store.getQuads(null, null, null, namedNode(graph));
|
|
461
|
+
if (quads.length > 0) this.store.removeQuads(quads);
|
|
462
|
+
}
|
|
463
|
+
this.loadedOntologies.delete(graph);
|
|
464
|
+
dropped.push(graph);
|
|
465
|
+
}
|
|
466
|
+
return dropped;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/** Document IRIs currently loaded through this loader. */
|
|
470
|
+
loadedDocuments(): string[] {
|
|
471
|
+
return [...this.loadedOntologies];
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Load one standalone document — an extension ontology, a shapes file — into
|
|
476
|
+
* its own graph, and follow its `owl:imports`.
|
|
477
|
+
*
|
|
478
|
+
* @param role How the document should be treated (`shapes` graphs join
|
|
479
|
+
* validation; `ontology`, `taxonomy`, `notation` feed the palette).
|
|
480
|
+
*/
|
|
481
|
+
async loadDocument(
|
|
482
|
+
text: string,
|
|
483
|
+
options: { format?: AssetFormat; role?: BundledAssetRole; documentIri?: string; location?: string } = {},
|
|
484
|
+
): Promise<MetamodelAssetStatus> {
|
|
485
|
+
const quads = this.parseDocument(text, options.format, 'document');
|
|
486
|
+
const documentIri =
|
|
487
|
+
options.documentIri ?? this.findOntologyIri(quads) ?? this.findSchemeIri(quads);
|
|
488
|
+
if (!documentIri) {
|
|
489
|
+
throw new Error('The document declares no owl:Ontology or skos:ConceptScheme to name its graph');
|
|
490
|
+
}
|
|
491
|
+
this.addToGraph(quads, documentIri);
|
|
492
|
+
this.loadedOntologies.add(documentIri);
|
|
493
|
+
for (const ref of this.discoverImports(quads, documentIri)) {
|
|
494
|
+
await this.resolveRef(ref, documentIriFor(ref.referencedIri));
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
referencedIri: documentIri,
|
|
498
|
+
documentIri,
|
|
499
|
+
via: 'upload',
|
|
500
|
+
role: options.role ?? this.inferRoleFromContent(quads),
|
|
501
|
+
outcome: 'loaded',
|
|
502
|
+
quadCount: quads.length,
|
|
503
|
+
origin: 'uploaded',
|
|
504
|
+
...(options.location ? { location: options.location } : {}),
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// ── SHACL shapes ─────────────────────────────────────────────────────
|
|
509
|
+
|
|
510
|
+
async loadShapes(ttlContent: string): Promise<void> {
|
|
511
|
+
const quads = this.parseOrThrow(ttlContent, 'SHACL shapes TTL');
|
|
512
|
+
this.store.addQuads(
|
|
513
|
+
quads.map((q) => quad(q.subject as Quad['subject'], q.predicate, q.object, SHAPES_GRAPH) as unknown as Quad),
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// ── owl:imports over already-loaded graphs ───────────────────────────
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Walk `owl:imports` from an already-loaded ontology, loading any document
|
|
521
|
+
* the source can provide that is not in the store yet.
|
|
522
|
+
*
|
|
523
|
+
* Unlike the manifest walk this starts from the store rather than from parsed
|
|
524
|
+
* text, so it also works for documents a caller loaded by other means.
|
|
525
|
+
*/
|
|
526
|
+
async resolveImports(ontologyIri: string): Promise<void> {
|
|
527
|
+
const visited = new Set<string>();
|
|
528
|
+
const queue: string[] = [ontologyIri];
|
|
529
|
+
|
|
530
|
+
while (queue.length > 0) {
|
|
531
|
+
const current = queue.shift() as string;
|
|
532
|
+
if (visited.has(current)) continue;
|
|
533
|
+
visited.add(current);
|
|
534
|
+
|
|
535
|
+
const importQuads = this.store.getQuads(
|
|
536
|
+
namedNode(current),
|
|
537
|
+
OWL_IMPORTS,
|
|
538
|
+
null,
|
|
539
|
+
namedNode(current),
|
|
540
|
+
);
|
|
541
|
+
|
|
542
|
+
for (const q of importQuads) {
|
|
543
|
+
const importedIri = documentIriFor(q.object.value);
|
|
544
|
+
if (!this.loadedOntologies.has(importedIri)) {
|
|
545
|
+
const status = await this.resolveRef(
|
|
546
|
+
{ referencedIri: q.object.value, via: 'owl:imports' },
|
|
547
|
+
importedIri,
|
|
548
|
+
);
|
|
549
|
+
// Unresolvable: record it as seen so repeated calls stay cheap, and
|
|
550
|
+
// leave the graph absent.
|
|
551
|
+
if (status.outcome !== 'loaded') this.loadedOntologies.add(importedIri);
|
|
552
|
+
}
|
|
553
|
+
queue.push(importedIri);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// ── Private helpers ──────────────────────────────────────────────────
|
|
559
|
+
|
|
560
|
+
/** Parse TTL, throwing a message that names what failed. */
|
|
561
|
+
private parseOrThrow(ttlContent: string, what: string): Quad[] {
|
|
562
|
+
const result = this.parser.parse(ttlContent);
|
|
563
|
+
if (!result.ok) {
|
|
564
|
+
throw new Error(`Failed to parse ${what}: ${result.error.message}`);
|
|
565
|
+
}
|
|
566
|
+
return result.quads;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/** Parse any supported serialization; Turtle goes through the injected parser. */
|
|
570
|
+
private parseDocument(text: string, format: AssetFormat | undefined, what: string): Quad[] {
|
|
571
|
+
if (!format || format === 'text/turtle') return this.parseOrThrow(text, `${what} TTL`);
|
|
572
|
+
try {
|
|
573
|
+
return parseRdf(text, format);
|
|
574
|
+
} catch (err: unknown) {
|
|
575
|
+
throw new Error(`Failed to parse ${what} (${format}): ${err instanceof Error ? err.message : String(err)}`);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Resolve one discovered reference: skip it, report it as already present,
|
|
581
|
+
* or fetch, parse and load it into its own named graph.
|
|
582
|
+
*/
|
|
583
|
+
private async resolveRef(ref: DiscoveredRef, documentIri: string): Promise<MetamodelAssetStatus> {
|
|
584
|
+
const bundledRole = getAssetByIri(documentIri)?.role;
|
|
585
|
+
const role = bundledRole ?? roleFromVia(ref.via);
|
|
586
|
+
const base: MetamodelAssetStatus = {
|
|
587
|
+
referencedIri: ref.referencedIri,
|
|
588
|
+
documentIri,
|
|
589
|
+
via: ref.via,
|
|
590
|
+
...(role ? { role } : {}),
|
|
591
|
+
outcome: 'loaded',
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
if (this.loadedOntologies.has(documentIri)) {
|
|
595
|
+
return { ...base, outcome: 'already-loaded' };
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
if (SKIPPED_VIA.some((property) => ref.via === `arch:${property}`)) {
|
|
599
|
+
return {
|
|
600
|
+
...base,
|
|
601
|
+
outcome: 'skipped',
|
|
602
|
+
message: 'Not used by the editor (server-side or document-generation asset)',
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
let doc: AssetDocument | null;
|
|
607
|
+
try {
|
|
608
|
+
doc = await this.source.fetch(documentIri);
|
|
609
|
+
} catch (err: unknown) {
|
|
610
|
+
return { ...base, outcome: 'error', message: err instanceof Error ? err.message : String(err) };
|
|
611
|
+
}
|
|
612
|
+
if (!doc) {
|
|
613
|
+
// Under an uploaded metamodel's namespace, the network was not asked (KReq 3.7).
|
|
614
|
+
if (this.source.claims?.(documentIri)) {
|
|
615
|
+
return { ...base, outcome: 'unavailable', message: `Not among the uploaded files: <${documentIri}>` };
|
|
616
|
+
}
|
|
617
|
+
return this.source.kind === 'bundled'
|
|
618
|
+
? { ...base, outcome: 'not-bundled', message: `No bundled asset defines <${documentIri}>` }
|
|
619
|
+
: { ...base, outcome: 'unavailable', message: `No source could provide <${documentIri}>` };
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// The graph is named as the source names the document: an uploaded file by its own name, so two spellings of one
|
|
623
|
+
// file load it once (KD-27).
|
|
624
|
+
const graphIri = doc.documentIri || documentIri;
|
|
625
|
+
const found = {
|
|
626
|
+
...base,
|
|
627
|
+
documentIri: graphIri,
|
|
628
|
+
origin: doc.origin,
|
|
629
|
+
...(doc.origin === 'uploaded' && doc.location ? { location: doc.location } : {}),
|
|
630
|
+
};
|
|
631
|
+
try {
|
|
632
|
+
// The document may have loaded concurrently via another branch.
|
|
633
|
+
if (this.loadedOntologies.has(graphIri)) return { ...found, outcome: 'already-loaded' };
|
|
634
|
+
const quadCount = this.insertDocument(doc, graphIri);
|
|
635
|
+
this.loadedOntologies.add(graphIri);
|
|
636
|
+
return {
|
|
637
|
+
...found,
|
|
638
|
+
...(doc.role ? { role: doc.role } : {}),
|
|
639
|
+
quadCount,
|
|
640
|
+
};
|
|
641
|
+
} catch (err: unknown) {
|
|
642
|
+
return { ...found, outcome: 'error', message: err instanceof Error ? err.message : String(err) };
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Put a fetched document into its named graph.
|
|
648
|
+
*
|
|
649
|
+
* Uses the store's native bulk loader when it has one — an order of
|
|
650
|
+
* magnitude faster on the large relationship-shapes files — and the injected
|
|
651
|
+
* parser otherwise. A document is a *graph*: its triples are taken as they
|
|
652
|
+
* stand, and any graph names inside a quad format are flattened into it.
|
|
653
|
+
*
|
|
654
|
+
* @returns The number of quads loaded.
|
|
655
|
+
*/
|
|
656
|
+
private insertDocument(doc: AssetDocument, documentIri: string): number {
|
|
657
|
+
const flat = doc.format !== 'application/trig' && doc.format !== 'application/n-quads';
|
|
658
|
+
if (this.store.load && flat) {
|
|
659
|
+
return this.store.load(doc.text, {
|
|
660
|
+
format: doc.format,
|
|
661
|
+
graph: documentIri,
|
|
662
|
+
baseIri: doc.location && /^https?:/.test(doc.location) ? doc.location : dereferenceBase(documentIri),
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
const quads =
|
|
666
|
+
doc.format === 'text/turtle'
|
|
667
|
+
? this.parseOrThrow(doc.text, `${doc.origin} asset '${doc.location ?? documentIri}'`)
|
|
668
|
+
: parseRdf(doc.text, doc.format);
|
|
669
|
+
this.addToGraph(quads, documentIri);
|
|
670
|
+
return quads.length;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/** A document's role judged by what it declares, for uploads. */
|
|
674
|
+
private inferRoleFromContent(quads: Quad[]): BundledAssetRole {
|
|
675
|
+
const types = new Set(
|
|
676
|
+
quads.filter((q) => q.predicate.value === RDF_TYPE.value).map((q) => q.object.value),
|
|
677
|
+
);
|
|
678
|
+
if (types.has(NAMESPACES.sh + 'NodeShape') || types.has(NAMESPACES.sh + 'PropertyShape')) {
|
|
679
|
+
return 'shapes';
|
|
680
|
+
}
|
|
681
|
+
if (types.has(NAMESPACES.arch + 'Metamodel')) return 'manifest';
|
|
682
|
+
if (types.has(NAMESPACES.arch + 'QuestionSet') || types.has(NAMESPACES.arch + 'ModelQuestion')) return 'questions';
|
|
683
|
+
if (types.has(NAMESPACES['arch-vis'] + 'VisualNotation')) return 'notation';
|
|
684
|
+
if (types.has(NAMESPACES.arch + 'Viewpoint')) return 'viewpoints';
|
|
685
|
+
if (types.has(NAMESPACES.skos + 'ConceptScheme') && !types.has(NAMESPACES.owl + 'Class')) {
|
|
686
|
+
return 'taxonomy';
|
|
687
|
+
}
|
|
688
|
+
return 'ontology';
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/** The `skos:ConceptScheme` subject — the graph name for a taxonomy file. */
|
|
692
|
+
private findSchemeIri(quads: Quad[]): string | null {
|
|
693
|
+
for (const q of quads) {
|
|
694
|
+
if (
|
|
695
|
+
q.predicate.value === RDF_TYPE.value &&
|
|
696
|
+
q.object.value === NAMESPACES.skos + 'ConceptScheme' &&
|
|
697
|
+
q.subject.termType === 'NamedNode'
|
|
698
|
+
) {
|
|
699
|
+
return q.subject.value;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
return null;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/** Re-graph the quads and add them to the store. */
|
|
706
|
+
private addToGraph(quads: Quad[], graphIri: string): void {
|
|
707
|
+
const graphNode = namedNode(graphIri);
|
|
708
|
+
this.store.addQuads(
|
|
709
|
+
quads.map((q) => quad(q.subject as Quad['subject'], q.predicate, q.object, graphNode) as unknown as Quad),
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
private recordRole(
|
|
714
|
+
graphsByRole: Partial<Record<BundledAssetRole, string[]>>,
|
|
715
|
+
role: BundledAssetRole,
|
|
716
|
+
documentIri: string,
|
|
717
|
+
): void {
|
|
718
|
+
const existing = graphsByRole[role];
|
|
719
|
+
if (existing) {
|
|
720
|
+
if (!existing.includes(documentIri)) existing.push(documentIri);
|
|
721
|
+
} else {
|
|
722
|
+
graphsByRole[role] = [documentIri];
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/** Every asset-pointing property value on the `arch:Metamodel` subject. */
|
|
727
|
+
private discoverManifestRefs(quads: Quad[], metamodelIri: string): DiscoveredRef[] {
|
|
728
|
+
const refs: DiscoveredRef[] = [];
|
|
729
|
+
for (const property of MANIFEST_ASSET_PROPERTIES) {
|
|
730
|
+
const predicate = NAMESPACES.arch + property;
|
|
731
|
+
for (const q of quads) {
|
|
732
|
+
if (q.subject.value !== metamodelIri) continue;
|
|
733
|
+
if (q.predicate.value !== predicate) continue;
|
|
734
|
+
if (q.object.termType !== 'NamedNode') continue;
|
|
735
|
+
refs.push({ referencedIri: q.object.value, via: `arch:${property}` });
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
return refs;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* The notation sets a loaded presentation-contexts document selects with
|
|
743
|
+
* `arch:usesNotationSet`, read back from its graph.
|
|
744
|
+
*
|
|
745
|
+
* Each is queued like a manifest reference, so the level's dedup reduces it to
|
|
746
|
+
* its document and skips the default set the manifest already named. Sorted
|
|
747
|
+
* so the status list does not depend on store order.
|
|
748
|
+
*/
|
|
749
|
+
private discoverContextNotationSets(documentIri: string): DiscoveredRef[] {
|
|
750
|
+
const sets = new Set<string>();
|
|
751
|
+
for (const q of this.store.getQuads(null, ARCH_USES_NOTATION_SET, null, namedNode(documentIri))) {
|
|
752
|
+
if (q.object.termType === 'NamedNode') sets.add(q.object.value);
|
|
753
|
+
}
|
|
754
|
+
return [...sets]
|
|
755
|
+
.sort(compareIris)
|
|
756
|
+
.map((referencedIri) => ({ referencedIri, via: 'arch:usesNotationSet' }));
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/** `owl:imports` values declared by a document (any subject in it). */
|
|
760
|
+
private discoverImports(quads: Quad[], documentIri: string): DiscoveredRef[] {
|
|
761
|
+
const refs: DiscoveredRef[] = [];
|
|
762
|
+
for (const q of quads) {
|
|
763
|
+
if (q.predicate.value !== OWL_IMPORTS.value) continue;
|
|
764
|
+
if (q.object.termType !== 'NamedNode') continue;
|
|
765
|
+
refs.push({ referencedIri: q.object.value, via: `owl:imports (${documentIri})` });
|
|
766
|
+
}
|
|
767
|
+
return refs;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/** The `arch:Metamodel` subject, if the document declares one. */
|
|
771
|
+
private findMetamodelSubject(quads: Quad[], preferred?: string): string | null {
|
|
772
|
+
if (preferred) {
|
|
773
|
+
const declared = quads.some(
|
|
774
|
+
(q) =>
|
|
775
|
+
q.subject.value === preferred &&
|
|
776
|
+
q.predicate.value === RDF_TYPE.value &&
|
|
777
|
+
q.object.value === ARCH_METAMODEL.value,
|
|
778
|
+
);
|
|
779
|
+
if (declared) return preferred;
|
|
780
|
+
}
|
|
781
|
+
for (const q of quads) {
|
|
782
|
+
if (
|
|
783
|
+
q.predicate.value === RDF_TYPE.value &&
|
|
784
|
+
q.object.value === ARCH_METAMODEL.value &&
|
|
785
|
+
q.subject.termType === 'NamedNode'
|
|
786
|
+
) {
|
|
787
|
+
return q.subject.value;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return null;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Find the ontology IRI from parsed quads.
|
|
795
|
+
* Looks for `?s rdf:type owl:Ontology` first, then falls back to
|
|
796
|
+
* the first subject with a title.
|
|
797
|
+
*/
|
|
798
|
+
private findOntologyIri(quads: Quad[]): string | null {
|
|
799
|
+
for (const q of quads) {
|
|
800
|
+
if (q.predicate.value === RDF_TYPE.value && q.object.value === OWL_ONTOLOGY.value) {
|
|
801
|
+
return q.subject.value;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
for (const q of quads) {
|
|
805
|
+
if (q.predicate.value === DC_TITLE.value || q.predicate.value === DCTERMS_TITLE.value) {
|
|
806
|
+
return q.subject.value;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
return null;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/** Metadata for a single-document load. */
|
|
813
|
+
private readInfo(quads: Quad[], subjectIri: string): MetamodelInfo {
|
|
814
|
+
return {
|
|
815
|
+
iri: subjectIri,
|
|
816
|
+
name: this.firstLiteral(quads, subjectIri, [DC_TITLE.value, DCTERMS_TITLE.value, SKOS_PREF_LABEL.value]) ?? '',
|
|
817
|
+
version: this.firstLiteral(quads, subjectIri, [OWL_VERSION_INFO.value]) ?? '',
|
|
818
|
+
description:
|
|
819
|
+
this.firstLiteral(quads, subjectIri, [DC_DESCRIPTION.value, DCTERMS_DESCRIPTION.value]) ?? '',
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Metadata for a manifest load: the `arch:Metamodel` subject carries the
|
|
825
|
+
* label and version, while title and description often sit on the ontology
|
|
826
|
+
* declaration instead — so both subjects are consulted.
|
|
827
|
+
*/
|
|
828
|
+
private readManifestInfo(quads: Quad[], metamodelIri: string, ontologyIri: string): MetamodelInfo {
|
|
829
|
+
const fromMetamodel = this.readInfo(quads, metamodelIri);
|
|
830
|
+
const fromOntology = this.readInfo(quads, ontologyIri);
|
|
831
|
+
return {
|
|
832
|
+
iri: metamodelIri,
|
|
833
|
+
name: fromMetamodel.name || fromOntology.name,
|
|
834
|
+
version: fromMetamodel.version || fromOntology.version,
|
|
835
|
+
description: fromMetamodel.description || fromOntology.description,
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/** First literal value for a subject across a list of candidate predicates. */
|
|
840
|
+
private firstLiteral(quads: Quad[], subjectIri: string, predicates: string[]): string | null {
|
|
841
|
+
for (const predicate of predicates) {
|
|
842
|
+
for (const q of quads) {
|
|
843
|
+
if (q.subject.value === subjectIri && q.predicate.value === predicate) {
|
|
844
|
+
return q.object.value;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
return null;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/** First named-node object for a subject + predicate. */
|
|
852
|
+
private firstObject(quads: Quad[], subjectIri: string, predicate: string): string | undefined {
|
|
853
|
+
for (const q of quads) {
|
|
854
|
+
if (
|
|
855
|
+
q.subject.value === subjectIri &&
|
|
856
|
+
q.predicate.value === predicate &&
|
|
857
|
+
q.object.termType === 'NamedNode'
|
|
858
|
+
) {
|
|
859
|
+
return q.object.value;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return undefined;
|
|
863
|
+
}
|
|
864
|
+
}
|