@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,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The terms the model layer reads and writes, and small helpers for building
|
|
3
|
+
* quads with them.
|
|
4
|
+
*
|
|
5
|
+
* Everything here is taken from the published core ontologies, not invented:
|
|
6
|
+
*
|
|
7
|
+
* - Membership (`core` 0.4.0, DD-30): a member names its container.
|
|
8
|
+
* `arch:inModel` on elements, relationships and views; `arch:inView` on each
|
|
9
|
+
* concept a view presents. Both are emitted alongside the geometry, never
|
|
10
|
+
* inferred from it, because geometry is droppable.
|
|
11
|
+
* - Conformance: `arch:modelConformsToMetamodel`, `arch:viewConformsToViewpoint`.
|
|
12
|
+
* - Relationships: an `arch:QualifiedRelationship` subclass instance with
|
|
13
|
+
* `arch:source` / `arch:target`, *and* the unqualified triple its class maps to
|
|
14
|
+
* through `arch:unqualifiedForm` (DD-10) — so SPARQL can traverse either.
|
|
15
|
+
* - Geometry (`core-vis`): an `arch-vis:ArchNode` per placement, naming its
|
|
16
|
+
* element with `arch-vis:archElement`; an `arch-vis:Link` per drawn
|
|
17
|
+
* relationship, naming it with `arch-vis:archRelationship` and its end nodes
|
|
18
|
+
* with `arch-vis:source` / `arch-vis:target`. Both carry `arch-vis:view`.
|
|
19
|
+
*
|
|
20
|
+
* The typing casts (`as unknown as NamedNode`) exist because n3's DataFactory
|
|
21
|
+
* terms and `@rdfjs/types` differ nominally while being the same objects; they
|
|
22
|
+
* are concentrated here so the managers read as plain RDF.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { DataFactory } from 'n3';
|
|
26
|
+
import type { Literal, NamedNode, Quad, Term } from '@rdfjs/types';
|
|
27
|
+
import { NAMESPACES } from '../rdf-engine/namespaces.js';
|
|
28
|
+
|
|
29
|
+
const factory = DataFactory;
|
|
30
|
+
|
|
31
|
+
/** A NamedNode typed for `@rdfjs/types`. */
|
|
32
|
+
export function nn(iri: string): NamedNode {
|
|
33
|
+
return factory.namedNode(iri) as unknown as NamedNode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A quad in the default graph. */
|
|
37
|
+
export function triple(subject: Term, predicate: Term, object: Term): Quad {
|
|
38
|
+
return factory.quad(
|
|
39
|
+
subject as never,
|
|
40
|
+
predicate as never,
|
|
41
|
+
object as never,
|
|
42
|
+
) as unknown as Quad;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* An RDF 1.2 triple term, `<<( s p o )>>` — what a qualified relationship
|
|
47
|
+
* `rdf:reifies`: the unqualified triple it stands for (the core's pattern).
|
|
48
|
+
*/
|
|
49
|
+
export function tripleTerm(subject: Term, predicate: Term, object: Term): Term {
|
|
50
|
+
return factory.quad(subject as never, predicate as never, object as never) as unknown as Term;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A language-tagged literal — the form the Linked.Archi shapes require for labels. */
|
|
54
|
+
export function langLiteral(value: string, language = 'en'): Literal {
|
|
55
|
+
return factory.literal(value, language) as unknown as Literal;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** An `xsd:double` literal, as `arch-vis` bounds and points are typed. */
|
|
59
|
+
export function doubleLiteral(value: number): Literal {
|
|
60
|
+
return factory.literal(String(value), factory.namedNode(NAMESPACES.xsd + 'double')) as unknown as Literal;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A plain `xsd:string` literal. */
|
|
64
|
+
export function stringLiteral(value: string): Literal {
|
|
65
|
+
return factory.literal(value) as unknown as Literal;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** An `xsd:dateTime` literal. */
|
|
69
|
+
export function dateTimeLiteral(date: Date = new Date()): Literal {
|
|
70
|
+
return factory.literal(
|
|
71
|
+
date.toISOString(),
|
|
72
|
+
factory.namedNode(NAMESPACES.xsd + 'dateTime'),
|
|
73
|
+
) as unknown as Literal;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const ARCH = NAMESPACES.arch;
|
|
77
|
+
const VIS = NAMESPACES['arch-vis'];
|
|
78
|
+
const SKOS = NAMESPACES.skos;
|
|
79
|
+
const SKOSXL = 'http://www.w3.org/2008/05/skos-xl#';
|
|
80
|
+
const SCHEMA = 'http://schema.org/';
|
|
81
|
+
|
|
82
|
+
/** IRIs, as strings, for comparisons. */
|
|
83
|
+
export const IRI = {
|
|
84
|
+
rdfType: NAMESPACES.rdf + 'type',
|
|
85
|
+
reifies: NAMESPACES.rdf + 'reifies',
|
|
86
|
+
rdfFirst: NAMESPACES.rdf + 'first',
|
|
87
|
+
rdfRest: NAMESPACES.rdf + 'rest',
|
|
88
|
+
rdfNil: NAMESPACES.rdf + 'nil',
|
|
89
|
+
subClassOf: NAMESPACES.rdfs + 'subClassOf',
|
|
90
|
+
subPropertyOf: NAMESPACES.rdfs + 'subPropertyOf',
|
|
91
|
+
inverseOf: NAMESPACES.owl + 'inverseOf',
|
|
92
|
+
rdfsLabel: NAMESPACES.rdfs + 'label',
|
|
93
|
+
prefLabel: NAMESPACES.skos + 'prefLabel',
|
|
94
|
+
definition: NAMESPACES.skos + 'definition',
|
|
95
|
+
dctermsTitle: NAMESPACES.dcterms + 'title',
|
|
96
|
+
dctermsDescription: NAMESPACES.dcterms + 'description',
|
|
97
|
+
dctermsCreated: NAMESPACES.dcterms + 'created',
|
|
98
|
+
dctermsModified: NAMESPACES.dcterms + 'modified',
|
|
99
|
+
dctermsIsPartOf: NAMESPACES.dcterms + 'isPartOf',
|
|
100
|
+
|
|
101
|
+
Model: ARCH + 'Model',
|
|
102
|
+
Folder: ARCH + 'Folder',
|
|
103
|
+
View: ARCH + 'View',
|
|
104
|
+
Diagram: ARCH + 'Diagram',
|
|
105
|
+
Catalog: ARCH + 'Catalog',
|
|
106
|
+
Matrix: ARCH + 'Matrix',
|
|
107
|
+
Element: ARCH + 'Element',
|
|
108
|
+
ModelConcept: ARCH + 'ModelConcept',
|
|
109
|
+
QualifiedRelationship: ARCH + 'QualifiedRelationship',
|
|
110
|
+
inModel: ARCH + 'inModel',
|
|
111
|
+
inView: ARCH + 'inView',
|
|
112
|
+
modelConformsToMetamodel: ARCH + 'modelConformsToMetamodel',
|
|
113
|
+
viewConformsToViewpoint: ARCH + 'viewConformsToViewpoint',
|
|
114
|
+
source: ARCH + 'source',
|
|
115
|
+
target: ARCH + 'target',
|
|
116
|
+
unqualifiedForm: ARCH + 'unqualifiedForm',
|
|
117
|
+
/** How many concepts may be at each end of a relationship (core 0.8.0; linked-archi-meta's DD-46). */
|
|
118
|
+
sourceMultiplicity: ARCH + 'sourceMultiplicity',
|
|
119
|
+
targetMultiplicity: ARCH + 'targetMultiplicity',
|
|
120
|
+
hasQualifiedRelationship: ARCH + 'hasQualifiedRelationship',
|
|
121
|
+
/** A more concrete representation of a concept — a view detailing an element — and its inverse. */
|
|
122
|
+
refines: ARCH + 'refines',
|
|
123
|
+
refinedInto: ARCH + 'refinedInto',
|
|
124
|
+
|
|
125
|
+
ArchNode: VIS + 'ArchNode',
|
|
126
|
+
Link: VIS + 'Link',
|
|
127
|
+
Point: VIS + 'Point',
|
|
128
|
+
LabelNode: VIS + 'LabelNode',
|
|
129
|
+
/** A node standing for no model element: a group, or a figure of a core-vis shape type. */
|
|
130
|
+
ContainerNode: VIS + 'ContainerNode',
|
|
131
|
+
/** The appearance of another view on a diagram, which it opens (core-vis 0.9). */
|
|
132
|
+
ViewReferenceNode: VIS + 'ViewReferenceNode',
|
|
133
|
+
visStyle: VIS + 'style',
|
|
134
|
+
Style: VIS + 'Style',
|
|
135
|
+
/** What a label says (core-vis 0.7): an `arch-vis:LabelExpression`, its text, the notation set it is for. */
|
|
136
|
+
labelExpression: VIS + 'labelExpression',
|
|
137
|
+
LabelExpression: VIS + 'LabelExpression',
|
|
138
|
+
expression: VIS + 'expression',
|
|
139
|
+
/** The presentation context a name or a label expression is for (core 0.5.0). */
|
|
140
|
+
inPresentationContext: ARCH + 'inPresentationContext',
|
|
141
|
+
/** A name as a resource (SKOS-XL), its text, an element's alternative names. */
|
|
142
|
+
skosxlLabel: SKOSXL + 'Label',
|
|
143
|
+
skosxlAltLabel: SKOSXL + 'altLabel',
|
|
144
|
+
skosxlLiteralForm: SKOSXL + 'literalForm',
|
|
145
|
+
altLabel: SKOS + 'altLabel',
|
|
146
|
+
/** An element's pictures (core 0.5.0): for every audience, and its others — one per audience an ImageObject. */
|
|
147
|
+
prefVisNotation: ARCH + 'prefVisNotation',
|
|
148
|
+
altVisNotation: ARCH + 'altVisNotation',
|
|
149
|
+
ImageObject: SCHEMA + 'ImageObject',
|
|
150
|
+
contentUrl: SCHEMA + 'contentUrl',
|
|
151
|
+
shapeType: VIS + 'shapeType',
|
|
152
|
+
fillColor: VIS + 'fillColor',
|
|
153
|
+
lineColor: VIS + 'lineColor',
|
|
154
|
+
fontColor: VIS + 'fontColor',
|
|
155
|
+
fontName: VIS + 'fontName',
|
|
156
|
+
fontSize: VIS + 'fontSize',
|
|
157
|
+
/** `bold`, `italic`, `underline`, separated by spaces (core-vis 0.7). */
|
|
158
|
+
fontStyle: VIS + 'fontStyle',
|
|
159
|
+
/** Width of a node's outline or a link's line (core-vis 0.7). */
|
|
160
|
+
lineWidth: VIS + 'lineWidth',
|
|
161
|
+
/** A node's outline: an `arch-vis:LineStyle`. */
|
|
162
|
+
borderStyle: VIS + 'borderStyle',
|
|
163
|
+
/** Where a node's text sits across it: an `arch-vis:TextAlignment` (core-vis 0.7). */
|
|
164
|
+
textAlignment: VIS + 'textAlignment',
|
|
165
|
+
/** Where a node's text sits down it: an `arch-vis:TextPosition` (core-vis 0.7). */
|
|
166
|
+
textPosition: VIS + 'textPosition',
|
|
167
|
+
visView: VIS + 'view',
|
|
168
|
+
/** A diagram element's `arch-vis:LabelNode`: where its text is drawn. */
|
|
169
|
+
visLabel: VIS + 'label',
|
|
170
|
+
archElement: VIS + 'archElement',
|
|
171
|
+
/** The view an `arch-vis:ViewReferenceNode` stands for and opens, as `archElement` names an ArchNode's element. */
|
|
172
|
+
referencesView: VIS + 'referencesView',
|
|
173
|
+
inNode: VIS + 'inNode',
|
|
174
|
+
/** A node's drawing order among the nodes in the same place, an integer; absent, 0 (core-vis 0.10). */
|
|
175
|
+
zOrder: VIS + 'zOrder',
|
|
176
|
+
archRelationship: VIS + 'archRelationship',
|
|
177
|
+
visSource: VIS + 'source',
|
|
178
|
+
visTarget: VIS + 'target',
|
|
179
|
+
points: VIS + 'points',
|
|
180
|
+
pointX: VIS + 'point-x',
|
|
181
|
+
pointY: VIS + 'point-y',
|
|
182
|
+
boundsX: VIS + 'bounds-x',
|
|
183
|
+
boundsY: VIS + 'bounds-y',
|
|
184
|
+
boundsW: VIS + 'bounds-w',
|
|
185
|
+
boundsH: VIS + 'bounds-h',
|
|
186
|
+
|
|
187
|
+
// Vocabulary retired from the core ontology; read (and migrated) on load only.
|
|
188
|
+
legacyRelSource: ARCH + 'relSource',
|
|
189
|
+
legacyRelTarget: ARCH + 'relTarget',
|
|
190
|
+
legacyRelPredicate: ARCH + 'relPredicate',
|
|
191
|
+
legacyPartOfModel: ARCH + 'partOfModel',
|
|
192
|
+
legacyExposedInView: ARCH + 'exposedInView',
|
|
193
|
+
legacyContains: ARCH + 'contains',
|
|
194
|
+
legacyConformsToMetamodel: ARCH + 'conformsToMetamodel',
|
|
195
|
+
legacyViewpoint: ARCH + 'viewpoint',
|
|
196
|
+
} as const;
|
|
197
|
+
|
|
198
|
+
/** The same, as NamedNodes, for writing. */
|
|
199
|
+
export const T = Object.fromEntries(
|
|
200
|
+
Object.entries(IRI).map(([key, value]) => [key, nn(value)]),
|
|
201
|
+
) as { readonly [K in keyof typeof IRI]: NamedNode };
|
|
202
|
+
|
|
203
|
+
/** The four `arch-vis` bounds predicates, in x/y/w/h order. */
|
|
204
|
+
export const BOUNDS_PREDICATES = [IRI.boundsX, IRI.boundsY, IRI.boundsW, IRI.boundsH] as const;
|
|
205
|
+
|
|
206
|
+
/** Read a numeric literal, or `undefined`. */
|
|
207
|
+
export function numberOf(term: Term | undefined): number | undefined {
|
|
208
|
+
if (!term) return undefined;
|
|
209
|
+
const n = Number(term.value);
|
|
210
|
+
return Number.isFinite(n) ? n : undefined;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Local name of an IRI (after the last `#`, `/` or — for URNs — `:`). */
|
|
214
|
+
export function localName(iri: string): string {
|
|
215
|
+
const hash = iri.lastIndexOf('#');
|
|
216
|
+
if (hash !== -1 && hash < iri.length - 1) return iri.slice(hash + 1);
|
|
217
|
+
const trimmed = iri.replace(/[/#:]+$/, '');
|
|
218
|
+
const match = /[^#/:]+$/.exec(trimmed);
|
|
219
|
+
return match ? match[0] : trimmed;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Turn a CamelCase / kebab local name into words: `BusinessActor` → `Business Actor`. */
|
|
223
|
+
export function humanize(fragment: string): string {
|
|
224
|
+
return fragment
|
|
225
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
226
|
+
.replace(/[-_]/g, ' ')
|
|
227
|
+
.replace(/\s+/g, ' ')
|
|
228
|
+
.trim();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** `influence Strength` → `Influence strength`. */
|
|
232
|
+
export function sentenceCase(words: string): string {
|
|
233
|
+
const lowered = words.replace(/ ([A-Z])(?=[a-z])/g, (_, c: string) => ` ${c.toLowerCase()}`);
|
|
234
|
+
return lowered.charAt(0).toUpperCase() + lowered.slice(1);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** A quad as a string, equal for equal quads: its terms, an object's language and datatype, its graph. */
|
|
238
|
+
export function quadKey(q: Quad): string {
|
|
239
|
+
return `${q.subject.value}\u0000${q.predicate.value}\u0000${q.object.termType}:${q.object.value}\u0000${
|
|
240
|
+
(q.object as { language?: string }).language ?? ''
|
|
241
|
+
}\u0000${(q.object as { datatype?: { value: string } }).datatype?.value ?? ''}\u0000${q.graph.value}`;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** A change with what it would remove and add again left out of both: only what differs. */
|
|
245
|
+
export function netChange(change: { remove: Quad[]; add: Quad[] }): { remove: Quad[]; add: Quad[] } {
|
|
246
|
+
const added = new Set(change.add.map(quadKey));
|
|
247
|
+
const removed = new Set(change.remove.map(quadKey));
|
|
248
|
+
return { remove: change.remove.filter((q) => !added.has(quadKey(q))), add: change.add.filter((q) => !removed.has(quadKey(q))) };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Drop duplicate quads (a quad reachable along two paths is removed once). */
|
|
252
|
+
export function dedupe(quads: Quad[]): Quad[] {
|
|
253
|
+
const seen = new Set<string>();
|
|
254
|
+
const out: Quad[] = [];
|
|
255
|
+
for (const q of quads) {
|
|
256
|
+
const key = quadKey(q);
|
|
257
|
+
if (seen.has(key)) continue;
|
|
258
|
+
seen.add(key);
|
|
259
|
+
out.push(q);
|
|
260
|
+
}
|
|
261
|
+
return out;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** The core's generic types, which a qualified relationship carries beside its class (the converters emit both). */
|
|
265
|
+
const GENERIC_RELATIONSHIP_TYPES = new Set<string>([IRI.QualifiedRelationship, IRI.ModelConcept]);
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* A relationship's class among its types: never a generic core type — a
|
|
269
|
+
* converter types a relationship `arch:QualifiedRelationship` and
|
|
270
|
+
* `arch:ModelConcept` besides its class, in any order — and, given the class
|
|
271
|
+
* hierarchy, the most specific of the rest. Only generic types: the qualified
|
|
272
|
+
* relationship class.
|
|
273
|
+
*/
|
|
274
|
+
export function relationshipClassAmong(types: readonly string[], closure?: (typeIri: string) => readonly string[]): string | undefined {
|
|
275
|
+
const own = types.filter((t) => !GENERIC_RELATIONSHIP_TYPES.has(t));
|
|
276
|
+
if (own.length === 0) return types.includes(IRI.QualifiedRelationship) ? IRI.QualifiedRelationship : types[0];
|
|
277
|
+
if (!closure || own.length === 1) return own[0];
|
|
278
|
+
return [...own].sort((a, b) => closure(b).length - closure(a).length)[0];
|
|
279
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shape a finding points to: its source shape when that is named, else
|
|
3
|
+
* the named shape it is written in (`withinShape`). A shape with neither — a
|
|
4
|
+
* blank node's id is no IRI — has none to point to.
|
|
5
|
+
*/
|
|
6
|
+
import type { ValidationResult } from './interfaces.js';
|
|
7
|
+
|
|
8
|
+
/** Whether a term's value is an IRI (`scheme:…`), not a blank node's id (`e7c5f6…`, `n3-4`, `_:b0`). */
|
|
9
|
+
export function isIri(value: string): boolean {
|
|
10
|
+
return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value) && !value.startsWith('_:');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The IRI of the shape a finding comes from, or of the named shape it is written in; none when neither has one. */
|
|
14
|
+
export function shapeIriOf(result: Pick<ValidationResult, 'sourceShape' | 'withinShape'>): string | undefined {
|
|
15
|
+
const named = (term: { termType?: string; value: string } | undefined) =>
|
|
16
|
+
term && term.termType !== 'BlankNode' && isIri(term.value) ? term.value : undefined;
|
|
17
|
+
return named(result.sourceShape) ?? named(result.withinShape);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Whether an IRI can be opened as a link (`http:`, `https:`). */
|
|
21
|
+
export function isLink(iri: string): boolean {
|
|
22
|
+
return /^https?:\/\//i.test(iri);
|
|
23
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Running a SELECT over the default graph *and* every named graph.
|
|
3
|
+
*
|
|
4
|
+
* ## The problem
|
|
5
|
+
*
|
|
6
|
+
* An unscoped SPARQL pattern matches the default graph only. That is the whole
|
|
7
|
+
* of SPARQL's dataset semantics, not an Oxigraph quirk. But
|
|
8
|
+
* `N3MetamodelLoader` deliberately loads each metamodel document into its own
|
|
9
|
+
* named graph keyed by its ontology IRI, so provenance survives ("what did the
|
|
10
|
+
* notation file say?"). Against the bundled ArchiMate 4.0 metamodel that puts
|
|
11
|
+
* 3 640 triples in nine named graphs and **nothing** in the default graph. Any
|
|
12
|
+
* metamodel query written unscoped therefore matches nothing at all.
|
|
13
|
+
*
|
|
14
|
+
* Model *data*, by contrast, does land in the default graph — `ElementManager`,
|
|
15
|
+
* `ViewManager` and `RelationshipManager` all write graph-less quads. So the
|
|
16
|
+
* dataset a metamodel query needs is "the default graph union every named
|
|
17
|
+
* graph", and neither half can be dropped.
|
|
18
|
+
*
|
|
19
|
+
* ## Why this is done in the query text
|
|
20
|
+
*
|
|
21
|
+
* Oxigraph's own `Store.query` takes a `use_default_graph_as_union: boolean`
|
|
22
|
+
* option that expresses exactly this, and it is the cleanest available
|
|
23
|
+
* mechanism. `OxigraphRdfStore.query(sparql)` does not forward options, though,
|
|
24
|
+
* and `rdf-store.ts` is outside the scope of this change — so the dataset has
|
|
25
|
+
* to be described inside the query.
|
|
26
|
+
*
|
|
27
|
+
* Two candidate encodings were measured against the real bundle:
|
|
28
|
+
*
|
|
29
|
+
* - `{ pattern } UNION { GRAPH ?g { pattern } }` evaluates the pattern once per
|
|
30
|
+
* graph. Property paths then cannot leave the graph they started in. The
|
|
31
|
+
* `rdfs:subClassOf*` closure of `am4:BusinessActor` came back with six
|
|
32
|
+
* entries, stopping at `arch:Element`, because
|
|
33
|
+
* `arch:Element rdfs:subClassOf arch:ModelConcept` is declared in the
|
|
34
|
+
* `core#` document and the walk began in `onto#`.
|
|
35
|
+
* - `FROM <g1> … FROM <gN>` merges the listed graphs into the query's default
|
|
36
|
+
* graph, so a path crosses document boundaries freely. The same closure came
|
|
37
|
+
* back with seven entries, `arch:ModelConcept` included.
|
|
38
|
+
*
|
|
39
|
+
* `FROM` is the better answer, with one catch: naming any graph in `FROM`
|
|
40
|
+
* *replaces* the default graph, and the store's own default graph has no name
|
|
41
|
+
* to list (`FROM DEFAULT` is not SPARQL and Oxigraph rejects it). Measured
|
|
42
|
+
* directly: a triple added graph-less is invisible to a query carrying `FROM`
|
|
43
|
+
* clauses.
|
|
44
|
+
*
|
|
45
|
+
* So {@link GraphScope.select} runs the query twice — once bare for the default
|
|
46
|
+
* graph, once with every named graph merged in — and concatenates the rows.
|
|
47
|
+
* Callers already de-duplicate by IRI, which is what makes the overlap
|
|
48
|
+
* harmless: a triple present in both the default graph and a named graph
|
|
49
|
+
* yields two identical rows, not two candidates.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
import type { RdfStore, SparqlResult } from './interfaces.js';
|
|
53
|
+
|
|
54
|
+
/** One SELECT result row, as `RdfStore.query` reports it. */
|
|
55
|
+
export type SparqlBindings = Extract<SparqlResult, { type: 'bindings' }>['results'][number];
|
|
56
|
+
|
|
57
|
+
/** The slice of `RdfStore` this module needs. Structural, so a stub works. */
|
|
58
|
+
export interface SparqlQueryable {
|
|
59
|
+
query(sparql: string): SparqlResult;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Characters that cannot appear in a SPARQL IRIREF. A graph name containing any
|
|
64
|
+
* of them is skipped rather than interpolated — it could otherwise break the
|
|
65
|
+
* query or inject syntax.
|
|
66
|
+
*/
|
|
67
|
+
const UNSAFE_IRI_CHARS = /[<>"{}|^`\\\s]/;
|
|
68
|
+
|
|
69
|
+
/** Whether an IRI can be safely interpolated into a SPARQL `<...>` term. */
|
|
70
|
+
export function isSafeIri(iri: string): boolean {
|
|
71
|
+
return iri.length > 0 && !UNSAFE_IRI_CHARS.test(iri);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A dataset spanning the default graph and every named graph the store holds.
|
|
76
|
+
*
|
|
77
|
+
* Build one per logical operation with {@link graphScope} and reuse it across
|
|
78
|
+
* the queries that operation needs: the named-graph list costs a scan, and
|
|
79
|
+
* answering "which relationship types may connect these two element types?"
|
|
80
|
+
* takes three queries.
|
|
81
|
+
*/
|
|
82
|
+
export class GraphScope {
|
|
83
|
+
/**
|
|
84
|
+
* @param store Store every query runs against.
|
|
85
|
+
* @param namedGraphs Named graphs to merge into the query's default graph.
|
|
86
|
+
*/
|
|
87
|
+
constructor(
|
|
88
|
+
private readonly store: SparqlQueryable,
|
|
89
|
+
readonly namedGraphs: readonly string[],
|
|
90
|
+
) {}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Run a SELECT across the whole dataset.
|
|
94
|
+
*
|
|
95
|
+
* `build` receives the `FROM` block to splice in between the projection and
|
|
96
|
+
* the `WHERE` clause — the only place SPARQL allows it:
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* scope.select((from) => `SELECT DISTINCT ?super ${from} WHERE { … }`);
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* It is called once with an empty string (the store's default graph) and, if
|
|
103
|
+
* there are any named graphs, once with the `FROM` block. Rows from both runs
|
|
104
|
+
* are concatenated in that order; overlapping triples produce duplicate rows,
|
|
105
|
+
* so callers must de-duplicate.
|
|
106
|
+
*/
|
|
107
|
+
select(build: (fromClauses: string) => string): SparqlBindings[] {
|
|
108
|
+
const rows: SparqlBindings[] = [];
|
|
109
|
+
|
|
110
|
+
const fromDefault = this.store.query(build(''));
|
|
111
|
+
if (fromDefault.type === 'bindings') rows.push(...fromDefault.results);
|
|
112
|
+
|
|
113
|
+
if (this.namedGraphs.length === 0) return rows;
|
|
114
|
+
|
|
115
|
+
const fromClauses = this.namedGraphs.map((iri) => `FROM <${iri}>`).join('\n ');
|
|
116
|
+
const fromNamed = this.store.query(build(fromClauses));
|
|
117
|
+
if (fromNamed.type === 'bindings') rows.push(...fromNamed.results);
|
|
118
|
+
|
|
119
|
+
return rows;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Enumerate the store's named graphs and return a scope over all of them plus
|
|
125
|
+
* the default graph.
|
|
126
|
+
*/
|
|
127
|
+
export function graphScope(store: SparqlQueryable | RdfStore): GraphScope {
|
|
128
|
+
// About the metamodels: through `queryMetamodels` where the store has it, which
|
|
129
|
+
// does not wait for a model just opened to reach Oxigraph (Task 22).
|
|
130
|
+
const metamodels = (store as { queryMetamodels?(sparql: string): SparqlResult }).queryMetamodels;
|
|
131
|
+
// The named graphs as the store keeps them listed, where it does: a SPARQL
|
|
132
|
+
// listing scans every quad of them, and a scope is made for every relationship
|
|
133
|
+
// lookup — forty for one context pad (Task 22).
|
|
134
|
+
const listed = (store as { namedGraphs?(): Array<{ termType: string; value: string }> }).namedGraphs;
|
|
135
|
+
if (typeof metamodels === 'function') {
|
|
136
|
+
const original = store;
|
|
137
|
+
store = { query: (sparql: string) => metamodels.call(original, sparql) };
|
|
138
|
+
if (typeof listed === 'function') {
|
|
139
|
+
const graphs: string[] = [];
|
|
140
|
+
for (const term of listed.call(original)) {
|
|
141
|
+
if (term.termType === 'NamedNode' && isSafeIri(term.value) && !graphs.includes(term.value)) graphs.push(term.value);
|
|
142
|
+
}
|
|
143
|
+
return new GraphScope(store, graphs);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const result = store.query('SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } }');
|
|
147
|
+
if (result.type !== 'bindings') return new GraphScope(store, []);
|
|
148
|
+
|
|
149
|
+
const graphs: string[] = [];
|
|
150
|
+
for (const row of result.results) {
|
|
151
|
+
const term = row['g'];
|
|
152
|
+
if (term === undefined) continue;
|
|
153
|
+
// Blank-node graph names cannot be written as an IRIREF, so they are
|
|
154
|
+
// reported here but unusable in FROM; skipping them is the honest choice.
|
|
155
|
+
// `RdfStore.query` reports an IRI as a `NamedNode` and everything else as a
|
|
156
|
+
// bare `{ value }`, and the label of a blank node is a perfectly safe
|
|
157
|
+
// string — so the term type, not the characters, is what distinguishes them.
|
|
158
|
+
if (!('termType' in term) || term.termType !== 'NamedNode') continue;
|
|
159
|
+
const iri = term.value;
|
|
160
|
+
if (iri && isSafeIri(iri) && !graphs.includes(iri)) graphs.push(iri);
|
|
161
|
+
}
|
|
162
|
+
return new GraphScope(store, graphs);
|
|
163
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// RDF Engine layer — triple store, SPARQL, TTL parser/serializer, SHACL validator
|
|
2
|
+
export type { TtlParser, TtlSerializer, RdfStore, ShaclValidator, ParseError, ParseResult, ValidationReport, ValidationResult, SparqlResult } from './interfaces.js';
|
|
3
|
+
export { NAMESPACES, PREFIXES } from './namespaces.js';
|
|
4
|
+
export { N3TtlParser } from './ttl-parser.js';
|
|
5
|
+
export { N3TtlSerializer } from './ttl-serializer.js';
|
|
6
|
+
export { OxigraphRdfStore, initOxigraph, isOxigraphReady } from './rdf-store.js';
|
|
7
|
+
export { RdfShaclValidator } from './shacl-validator.js';
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RDF Engine layer interfaces.
|
|
3
|
+
*
|
|
4
|
+
* Provides the core RDF infrastructure: TTL parsing/serialization,
|
|
5
|
+
* triple store with SPARQL, and SHACL validation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Quad, NamedNode, Term } from '@rdfjs/types';
|
|
9
|
+
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// TTL Parser
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
/** Error returned when TTL parsing fails. */
|
|
15
|
+
export interface ParseError {
|
|
16
|
+
/** Line number where the error occurred (1-based). */
|
|
17
|
+
line: number;
|
|
18
|
+
/** Human-readable description of the syntax error. */
|
|
19
|
+
message: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Discriminated union result of a TTL parse operation. */
|
|
23
|
+
export type ParseResult<T = Quad[]> =
|
|
24
|
+
| { ok: true; quads: T }
|
|
25
|
+
| { ok: false; error: ParseError };
|
|
26
|
+
|
|
27
|
+
/** Parses Turtle (TTL) strings into RDF quads. */
|
|
28
|
+
export interface TtlParser {
|
|
29
|
+
parse(input: string): ParseResult<Quad[]>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// TTL Serializer
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
/** Map of prefix labels to namespace IRIs. */
|
|
37
|
+
export type PrefixMap = Record<string, string>;
|
|
38
|
+
|
|
39
|
+
/** Serializes RDF quads to pretty-printed Turtle. */
|
|
40
|
+
export interface TtlSerializer {
|
|
41
|
+
/**
|
|
42
|
+
* @param model The model the quads are about, by its namespace and prefix: its IRIs are written as DD-41
|
|
43
|
+
* says (`turtle-writer.ts`). Without one, by the prefixes alone.
|
|
44
|
+
*/
|
|
45
|
+
serialize(quads: Quad[], prefixes: PrefixMap, model?: { namespace: string; prefix: string }): string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// RDF Store
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
/** Result of a SPARQL query execution. */
|
|
53
|
+
export type SparqlResult =
|
|
54
|
+
| { type: 'bindings'; results: Record<string, NamedNode | { value: string }>[] }
|
|
55
|
+
| { type: 'quads'; quads: Quad[] }
|
|
56
|
+
| { type: 'boolean'; value: boolean };
|
|
57
|
+
|
|
58
|
+
/** In-memory RDF triple store with SPARQL support. */
|
|
59
|
+
export interface RdfStore {
|
|
60
|
+
addQuads(quads: Quad[]): void;
|
|
61
|
+
removeQuads(quads: Quad[]): void;
|
|
62
|
+
getQuads(
|
|
63
|
+
subject?: NamedNode | null,
|
|
64
|
+
predicate?: NamedNode | null,
|
|
65
|
+
object?: NamedNode | null,
|
|
66
|
+
graph?: NamedNode | null,
|
|
67
|
+
): Quad[];
|
|
68
|
+
query(sparql: string): SparqlResult;
|
|
69
|
+
update(sparqlUpdate: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Bulk-load a serialized document straight into the store, bypassing the
|
|
72
|
+
* per-quad JavaScript→WASM round-trip. Optional: an implementation without a
|
|
73
|
+
* native parser leaves it out and callers fall back to parse + addQuads.
|
|
74
|
+
*
|
|
75
|
+
* @returns The number of quads the store grew by.
|
|
76
|
+
*/
|
|
77
|
+
load?(data: string, options: { format: string; graph?: string; baseIri?: string }): number;
|
|
78
|
+
/** Number of quads in the store (all graphs). Optional, like {@link load}. */
|
|
79
|
+
size?(): number;
|
|
80
|
+
/**
|
|
81
|
+
* The quads as the store holds them, and gives them back: a store may keep a
|
|
82
|
+
* literal in another form than the one added (Oxigraph keeps `"010"^^xsd:int`
|
|
83
|
+
* as `"10"^^xsd:integer`). Optional: a store that keeps every quad as added
|
|
84
|
+
* leaves it out.
|
|
85
|
+
*/
|
|
86
|
+
canonical?(quads: Quad[]): Quad[];
|
|
87
|
+
/** The named graphs it holds. Optional: a store without them leaves it out. */
|
|
88
|
+
namedGraphs?(): NamedNode[];
|
|
89
|
+
/**
|
|
90
|
+
* Throw as {@link addQuads} would for these quads, without adding them — a
|
|
91
|
+
* term the store cannot hold (an IRI that is not one, a bad language tag).
|
|
92
|
+
* Optional: what lets a store be given quads later and refuse them now.
|
|
93
|
+
*/
|
|
94
|
+
check?(quads: Quad[]): void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
// SHACL Validator
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
|
|
101
|
+
/** Severity level of a SHACL validation result. */
|
|
102
|
+
export type ValidationSeverity = 'Violation' | 'Warning' | 'Info';
|
|
103
|
+
|
|
104
|
+
/** A single SHACL validation result entry. */
|
|
105
|
+
export interface ValidationResult {
|
|
106
|
+
focusNode: NamedNode;
|
|
107
|
+
resultPath: NamedNode;
|
|
108
|
+
sourceShape: NamedNode;
|
|
109
|
+
message: string;
|
|
110
|
+
severity: ValidationSeverity;
|
|
111
|
+
/**
|
|
112
|
+
* The SHACL constraint component IRI that produced this result
|
|
113
|
+
* (e.g. sh:MinCountConstraintComponent). Optional: not every producer
|
|
114
|
+
* of a ValidationResult knows it.
|
|
115
|
+
*/
|
|
116
|
+
sourceConstraintComponent?: NamedNode;
|
|
117
|
+
/**
|
|
118
|
+
* When the source shape is written inline in another (a blank node — a
|
|
119
|
+
* property shape, a member of an `sh:or` list), the named shape it is
|
|
120
|
+
* written in: what a finding can point to.
|
|
121
|
+
*/
|
|
122
|
+
withinShape?: NamedNode;
|
|
123
|
+
/**
|
|
124
|
+
* The value the result is about (`sh:value`), when the report names one — an IRI or a literal: which of a property's
|
|
125
|
+
* values a finding is about, a custom property's pair among them (KD-17).
|
|
126
|
+
*/
|
|
127
|
+
value?: Term;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Full SHACL validation report. */
|
|
131
|
+
export interface ValidationReport {
|
|
132
|
+
conforms: boolean;
|
|
133
|
+
results: ValidationResult[];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Validates RDF data graphs against SHACL shapes. */
|
|
137
|
+
export interface ShaclValidator {
|
|
138
|
+
validate(dataGraph: Quad[], shapesGraph: Quad[]): ValidationReport;
|
|
139
|
+
validateIncremental(
|
|
140
|
+
changedResource: NamedNode,
|
|
141
|
+
dataGraph: Quad[],
|
|
142
|
+
shapesGraph: Quad[],
|
|
143
|
+
): ValidationReport;
|
|
144
|
+
}
|