@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,747 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation of the model, the same wherever it runs (Task 22): in a Web Worker
|
|
3
|
+
* in the browser and the desktop app (`validation.worker.ts`), on the calling
|
|
4
|
+
* thread in Node and the tests (`validation-service.ts`).
|
|
5
|
+
*
|
|
6
|
+
* It keeps its own copy of the model, given whole once ({@link load}) and then
|
|
7
|
+
* kept up to date by the store's changes ({@link apply}) — so a validation does
|
|
8
|
+
* not copy the model out of the store on the UI thread, and does not copy its
|
|
9
|
+
* own either: SHACL and the tables read the engine's store as it is — and what
|
|
10
|
+
* validation needs of the metamodels ({@link setup}): the shapes, the class
|
|
11
|
+
* hierarchy, the types of resources outside the model, and the relationship
|
|
12
|
+
* tables.
|
|
13
|
+
*
|
|
14
|
+
* What it validates is what `App.validationDataGraph` describes: the model, the
|
|
15
|
+
* `rdfs:subClassOf` axioms, and the types of resources the model refers to from
|
|
16
|
+
* outside it (a view's viewpoint) — what is found of such a resource itself is
|
|
17
|
+
* left out of the report: only its types are there to validate. How: the relationship shapes the tables cover
|
|
18
|
+
* by lookup in the tables (`relationship-validity.ts`), the rest by SHACL; the
|
|
19
|
+
* shapes' SPARQL-based constraints (`sh:sparql`), which the SHACL library cannot
|
|
20
|
+
* run, with Oxigraph (`sparql-constraints.ts`) on a copy of the same data and
|
|
21
|
+
* the metamodels' statements they read; and the references to what the model
|
|
22
|
+
* does not have (`missing-references.ts`).
|
|
23
|
+
*
|
|
24
|
+
* The Oxigraph copy is made only when the shapes have SPARQL-based
|
|
25
|
+
* constraints, and only where Oxigraph is ready (its WebAssembly loaded in the
|
|
26
|
+
* worker): about 0.7 KB a quad (78 MB at 100 000 triples, measured in Node). It
|
|
27
|
+
* is built in one native load, and built again rather than followed for a
|
|
28
|
+
* change too large to validate incrementally — a model opened (KD-29).
|
|
29
|
+
*/
|
|
30
|
+
import { DataFactory, Store as N3Store, termFromId, termToId } from 'n3';
|
|
31
|
+
import * as oxigraph from 'oxigraph';
|
|
32
|
+
import type { Quad, Term } from '@rdfjs/types';
|
|
33
|
+
import { RdfShaclValidator } from './shacl-validator.js';
|
|
34
|
+
import { isOxigraphReady, toOxQuad } from './rdf-store.js';
|
|
35
|
+
import { nTriples, splitForNativeLoad } from './native-load.js';
|
|
36
|
+
import { SparqlRunner, predicatesNamedBy, sparqlConstraintsOf, type ShapeTargets } from './sparql-constraints.js';
|
|
37
|
+
import { REFERENCE_PREDICATES, missingReferences } from '../model-manager/missing-references.js';
|
|
38
|
+
import { predicatesRead, shapesReach, type ShapesReach } from './shape-reach.js';
|
|
39
|
+
import type { ValidationReport, ValidationResult } from './interfaces.js';
|
|
40
|
+
import { NAMESPACES } from './namespaces.js';
|
|
41
|
+
import { decodeQuads, type EncodedQuad } from './term-codec.js';
|
|
42
|
+
import { NO_TABLE_PERMISSIONS, TablePermissions, type PlainTablePermissions } from '../model-manager/direct-permissions.js';
|
|
43
|
+
import { checkRelationshipsByTables, noTableShapes, splitTableShapes, type TableShapes } from '../model-manager/relationship-validity.js';
|
|
44
|
+
import type { TypeClosure } from '../model-manager/model-queries.js';
|
|
45
|
+
|
|
46
|
+
const RDF_TYPE = NAMESPACES.rdf + 'type';
|
|
47
|
+
const RDFS_SUBCLASS_OF = NAMESPACES.rdfs + 'subClassOf';
|
|
48
|
+
/** What the table check reads besides the predicates the tables cover: the types, and a qualified relationship's ends. */
|
|
49
|
+
const TABLES_READ = [RDF_TYPE, NAMESPACES.arch + 'source', NAMESPACES.arch + 'target'];
|
|
50
|
+
const PREF_LABEL = NAMESPACES.skos + 'prefLabel';
|
|
51
|
+
const QUALIFIED_RELATIONSHIP = NAMESPACES.arch + 'QualifiedRelationship';
|
|
52
|
+
|
|
53
|
+
/** What validation needs of the loaded metamodels. */
|
|
54
|
+
export interface EngineSetup {
|
|
55
|
+
/** Preferred language for labels quoted in generated SHACL findings. */
|
|
56
|
+
preferredLanguage?: string;
|
|
57
|
+
/** The whole shapes graph; the engine splits off what the tables check. */
|
|
58
|
+
shapes: EncodedQuad[];
|
|
59
|
+
/** Every `rdfs:subClassOf` axiom. */
|
|
60
|
+
hierarchy: EncodedQuad[];
|
|
61
|
+
/** `rdf:type` statements about resources outside the model (in the metamodel graphs). */
|
|
62
|
+
outsideTypes: EncodedQuad[];
|
|
63
|
+
/** Relationship class → its `arch:unqualifiedForm`. */
|
|
64
|
+
unqualifiedForms: Array<[string, string]>;
|
|
65
|
+
/** What the relationship tables permit (`permittedBy`); `null` when none are loaded. */
|
|
66
|
+
tables: PlainTablePermissions | null;
|
|
67
|
+
/**
|
|
68
|
+
* The metamodels' statements the SPARQL-based constraints read, besides types
|
|
69
|
+
* and the class hierarchy (a viewpoint's `arch:includesConcept`).
|
|
70
|
+
*/
|
|
71
|
+
sparqlContext?: EncodedQuad[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A result as plain data: IRIs as strings. */
|
|
75
|
+
export interface PlainResult {
|
|
76
|
+
focusNode: string;
|
|
77
|
+
resultPath: string;
|
|
78
|
+
sourceShape: string;
|
|
79
|
+
message: string;
|
|
80
|
+
severity: ValidationResult['severity'];
|
|
81
|
+
sourceConstraintComponent?: string;
|
|
82
|
+
/** The named shape an inline source shape is written in. */
|
|
83
|
+
withinShape?: string;
|
|
84
|
+
/** The value it is about (`sh:value`), as its n3 id: the IRI, or `"text"@en`. */
|
|
85
|
+
value?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** A report as plain data. */
|
|
89
|
+
export interface PlainReport {
|
|
90
|
+
conforms: boolean;
|
|
91
|
+
results: PlainResult[];
|
|
92
|
+
/**
|
|
93
|
+
* How long it took, in ms: SHACL, the tables, the SPARQL-based constraints,
|
|
94
|
+
* the references; and how many nodes were validated again — `all`, or after
|
|
95
|
+
* an edit only those it can change.
|
|
96
|
+
*/
|
|
97
|
+
timing: {
|
|
98
|
+
shacl: number;
|
|
99
|
+
tables: number;
|
|
100
|
+
sparql?: number;
|
|
101
|
+
references?: number;
|
|
102
|
+
nodes: number | 'all';
|
|
103
|
+
/** The SPARQL-based constraints that took {@link SLOW_RULE_MS} or more, by shape, slowest first (KD-30). */
|
|
104
|
+
slowRules?: Array<{ shape: string; ms: number }>;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A SPARQL-based constraint this slow, in ms, is named in the report's timing (KD-30): two published rules once took
|
|
110
|
+
* 111 of a validation's 120 s, and the report said only "SPARQL-based rules 110 901 ms".
|
|
111
|
+
*/
|
|
112
|
+
export const SLOW_RULE_MS = 500;
|
|
113
|
+
|
|
114
|
+
/** After this many validations of what edits changed, the whole model is validated again. */
|
|
115
|
+
const FULL_EVERY = 100;
|
|
116
|
+
/** When an edit can change the findings of more nodes than one in this many of the model's quads, the whole model is validated. */
|
|
117
|
+
const FULL_SHARE = 20;
|
|
118
|
+
/** …but not fewer than this many nodes. */
|
|
119
|
+
const FULL_FLOOR = 256;
|
|
120
|
+
|
|
121
|
+
/** The graph the SPARQL-based constraints' metamodel statements are kept in, in the Oxigraph copy. */
|
|
122
|
+
const CONTEXT_GRAPH = 'urn:la-gram:sparql-context';
|
|
123
|
+
/** Hops around what changed whose nodes the SPARQL-based constraints validate again — both ways. */
|
|
124
|
+
const SPARQL_HOPS = 1;
|
|
125
|
+
|
|
126
|
+
/** The class hierarchy as a closure function, from `rdfs:subClassOf` axioms. */
|
|
127
|
+
export function closureOf(hierarchy: readonly Quad[]): TypeClosure {
|
|
128
|
+
const parents = new Map<string, string[]>();
|
|
129
|
+
for (const q of hierarchy) {
|
|
130
|
+
if (q.subject.termType !== 'NamedNode' || q.object.termType !== 'NamedNode') continue;
|
|
131
|
+
const list = parents.get(q.subject.value);
|
|
132
|
+
if (list) list.push(q.object.value);
|
|
133
|
+
else parents.set(q.subject.value, [q.object.value]);
|
|
134
|
+
}
|
|
135
|
+
const cache = new Map<string, string[]>();
|
|
136
|
+
return (type: string) => {
|
|
137
|
+
const cached = cache.get(type);
|
|
138
|
+
if (cached) return cached;
|
|
139
|
+
const seen = new Set<string>([type]);
|
|
140
|
+
const stack = [...(parents.get(type) ?? [])];
|
|
141
|
+
while (stack.length > 0) {
|
|
142
|
+
const current = stack.pop() as string;
|
|
143
|
+
if (seen.has(current)) continue;
|
|
144
|
+
seen.add(current);
|
|
145
|
+
stack.push(...(parents.get(current) ?? []));
|
|
146
|
+
}
|
|
147
|
+
const closure = [...seen];
|
|
148
|
+
cache.set(type, closure);
|
|
149
|
+
return closure;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Validates a model it keeps a copy of. */
|
|
154
|
+
export class ValidationEngine {
|
|
155
|
+
/**
|
|
156
|
+
* What is validated, in one store, so that a validation copies nothing: the
|
|
157
|
+
* model, and its extras — the class hierarchy and the types of the outside
|
|
158
|
+
* resources the model refers to. A quad both the model and the extras hold
|
|
159
|
+
* stays until neither does.
|
|
160
|
+
*/
|
|
161
|
+
private data = new N3Store();
|
|
162
|
+
/** The extras, by key. */
|
|
163
|
+
private readonly extras = new Map<string, Quad>();
|
|
164
|
+
/** The extras the model holds too. */
|
|
165
|
+
private readonly alsoModel = new Set<string>();
|
|
166
|
+
/** An outside resource's types, from the metamodel graphs. */
|
|
167
|
+
private outsideTypes = new Map<string, Quad[]>();
|
|
168
|
+
/** How many of the model's quads refer to each outside resource with types. */
|
|
169
|
+
private readonly references = new Map<string, number>();
|
|
170
|
+
private readonly validator = new RdfShaclValidator();
|
|
171
|
+
private preferredLanguage?: string;
|
|
172
|
+
private hierarchy: Quad[] = [];
|
|
173
|
+
private split: TableShapes = noTableShapes([]);
|
|
174
|
+
private tables: TablePermissions = NO_TABLE_PERMISSIONS;
|
|
175
|
+
private closure: TypeClosure = (t) => [t];
|
|
176
|
+
private reach: ShapesReach = { hops: 0, inverse: false, recursive: false, valuesAsFocus: false };
|
|
177
|
+
private ready = false;
|
|
178
|
+
/** The same data in Oxigraph, with the metamodels' statements the SPARQL-based constraints read; none without such constraints. */
|
|
179
|
+
private sparqlData?: oxigraph.Store;
|
|
180
|
+
private sparqlRunner?: SparqlRunner;
|
|
181
|
+
private sparqlContext: Quad[] = [];
|
|
182
|
+
/**
|
|
183
|
+
* The predicates validation reads (KD-21): those the shapes, the table check and the reference check read — every
|
|
184
|
+
* one, until the shapes are given or when a shape is closed — and those the SPARQL-based constraints' queries name.
|
|
185
|
+
*/
|
|
186
|
+
private reads: { checks: ReadonlySet<string> | 'every'; queries: ReadonlySet<string> } = { checks: 'every', queries: new Set() };
|
|
187
|
+
|
|
188
|
+
/** The findings of the last validation, by focus node: SHACL's, the tables', the SPARQL-based constraints', the references'. */
|
|
189
|
+
private findings: {
|
|
190
|
+
shacl: Map<string, ValidationResult[]>;
|
|
191
|
+
tables: Map<string, ValidationResult[]>;
|
|
192
|
+
sparql: Map<string, ValidationResult[]>;
|
|
193
|
+
references: Map<string, ValidationResult[]>;
|
|
194
|
+
} | null = null;
|
|
195
|
+
/**
|
|
196
|
+
* What changed since — or so much that the whole model is validated — by the triples added and removed: the
|
|
197
|
+
* subjects and objects of those the shapes and the engine's checks read; the ends of those the SPARQL-based
|
|
198
|
+
* constraints' queries name; and the ends of the rest, validated alone (KD-21).
|
|
199
|
+
*/
|
|
200
|
+
private changed = {
|
|
201
|
+
subjects: new Map<string, Term>(),
|
|
202
|
+
objects: new Map<string, Term>(),
|
|
203
|
+
around: new Map<string, Term>(),
|
|
204
|
+
alone: new Map<string, Term>(),
|
|
205
|
+
all: true,
|
|
206
|
+
};
|
|
207
|
+
/** Validations of what edits changed since the whole model was last validated. */
|
|
208
|
+
private sinceWhole = 0;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @param options.sparql Whether to run the SPARQL-based constraints (on by default).
|
|
212
|
+
*/
|
|
213
|
+
constructor(private readonly options: { sparql?: boolean } = {}) {}
|
|
214
|
+
|
|
215
|
+
/** Why SPARQL-based constraints could not be run, by shape; what Oxigraph refused. */
|
|
216
|
+
get sparqlFailures(): ReadonlyMap<string, string> {
|
|
217
|
+
return this.sparqlRunner?.failures ?? new Map();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Take what validation needs of the metamodels; splits the shapes. */
|
|
221
|
+
setup(setup: EngineSetup): void {
|
|
222
|
+
this.preferredLanguage = setup.preferredLanguage;
|
|
223
|
+
for (const q of [...this.extras.values()]) this.removeExtra(q);
|
|
224
|
+
this.references.clear();
|
|
225
|
+
this.hierarchy = decodeQuads(setup.hierarchy).map(inDefaultGraph);
|
|
226
|
+
this.outsideTypes = new Map();
|
|
227
|
+
for (const q of decodeQuads(setup.outsideTypes).map(inDefaultGraph)) {
|
|
228
|
+
const list = this.outsideTypes.get(q.subject.value);
|
|
229
|
+
if (list) list.push(q);
|
|
230
|
+
else this.outsideTypes.set(q.subject.value, [q]);
|
|
231
|
+
}
|
|
232
|
+
this.addExtras();
|
|
233
|
+
this.closure = closureOf(this.hierarchy);
|
|
234
|
+
this.tables = setup.tables ? TablePermissions.fromPlain(setup.tables) : NO_TABLE_PERMISSIONS;
|
|
235
|
+
const formOf = new Map(setup.unqualifiedForms);
|
|
236
|
+
const closure = this.closure;
|
|
237
|
+
const shapes = decodeQuads(setup.shapes);
|
|
238
|
+
this.split = splitTableShapes(shapes, this.tables, formOf, (c) => closure(c).includes(QUALIFIED_RELATIONSHIP));
|
|
239
|
+
this.reach = shapesReach(this.split.kept);
|
|
240
|
+
const constraints = this.options.sparql === false ? [] : sparqlConstraintsOf(shapes).constraints;
|
|
241
|
+
const checks = predicatesRead(shapes);
|
|
242
|
+
this.reads = {
|
|
243
|
+
checks: checks === 'every' ? 'every' : new Set([...checks, ...TABLES_READ, ...REFERENCE_PREDICATES]),
|
|
244
|
+
// A class target reads the types too.
|
|
245
|
+
queries: new Set([RDF_TYPE, ...constraints.flatMap(predicatesNamedBy)]),
|
|
246
|
+
};
|
|
247
|
+
this.sparqlContext = decodeQuads(setup.sparqlContext ?? []);
|
|
248
|
+
this.sparqlRunner = undefined;
|
|
249
|
+
if (constraints.length > 0 && isOxigraphReady()) {
|
|
250
|
+
this.sparqlRunner = new SparqlRunner(
|
|
251
|
+
constraints,
|
|
252
|
+
{ select: (query) => (this.sparqlData?.query(query, { use_default_graph_as_union: true }) ?? []) as Array<Map<string, Term>> },
|
|
253
|
+
(iri) => this.nameOf(iri),
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
this.rebuildSparqlData();
|
|
257
|
+
this.ready = true;
|
|
258
|
+
this.changed.all = true;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Replace the model with these quads (default graph). */
|
|
262
|
+
load(quads: readonly EncodedQuad[]): void {
|
|
263
|
+
this.data = new N3Store();
|
|
264
|
+
this.extras.clear();
|
|
265
|
+
this.alsoModel.clear();
|
|
266
|
+
this.references.clear();
|
|
267
|
+
this.data.addQuads(decodeQuads(quads) as never);
|
|
268
|
+
this.addExtras();
|
|
269
|
+
this.rebuildSparqlData();
|
|
270
|
+
this.changed.all = true;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Apply a change to the model. One past the incremental limit — a model opened, or imported, is one — would have
|
|
275
|
+
* the whole model validated anyway, and is applied as a reload (KD-29): the copy and the references as ever, but
|
|
276
|
+
* nothing noted of what changed, and the Oxigraph copy built again at the end in one native load rather than
|
|
277
|
+
* followed quad by quad (55 s and 570 MiB for 365 000 triples, against 2.1 s and 402 MiB, in Node).
|
|
278
|
+
*/
|
|
279
|
+
apply(added: readonly EncodedQuad[], removed: readonly EncodedQuad[]): void {
|
|
280
|
+
const reload = added.length + removed.length > this.limit;
|
|
281
|
+
if (reload) {
|
|
282
|
+
this.changed.all = true;
|
|
283
|
+
this.rebuilding = true;
|
|
284
|
+
}
|
|
285
|
+
try {
|
|
286
|
+
for (const q of decodeQuads(removed)) {
|
|
287
|
+
const k = extraKey(q);
|
|
288
|
+
if (k !== undefined && this.extras.has(k)) this.alsoModel.delete(k);
|
|
289
|
+
else this.drop(q);
|
|
290
|
+
this.refer(q, -1);
|
|
291
|
+
this.touch(q);
|
|
292
|
+
}
|
|
293
|
+
for (const q of decodeQuads(added)) {
|
|
294
|
+
const k = extraKey(q);
|
|
295
|
+
if (k !== undefined && this.extras.has(k)) this.alsoModel.add(k);
|
|
296
|
+
else this.put(q);
|
|
297
|
+
this.refer(q, 1);
|
|
298
|
+
this.touch(q);
|
|
299
|
+
}
|
|
300
|
+
} finally {
|
|
301
|
+
if (reload) {
|
|
302
|
+
this.rebuilding = false;
|
|
303
|
+
this.rebuildSparqlData();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** Free the Oxigraph copy: WebAssembly memory is not collected with the engine. */
|
|
309
|
+
dispose(): void {
|
|
310
|
+
(this.sparqlData as { free?(): void } | undefined)?.free?.();
|
|
311
|
+
this.sparqlData = undefined;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** How many quads the model has. */
|
|
315
|
+
get size(): number {
|
|
316
|
+
return this.data.size - this.extras.size + this.alsoModel.size;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Validate the model as it is now: the whole of it after it was loaded, the
|
|
321
|
+
* metamodels changed, or now and then; else only the nodes whose findings
|
|
322
|
+
* what changed can change — the subjects of the changed triples and the
|
|
323
|
+
* nodes up to the shapes' reach before them, and the objects (a target of
|
|
324
|
+
* `sh:targetObjectsOf`); of a triple by a predicate nothing reads, its ends
|
|
325
|
+
* alone (KD-21) — their findings replacing theirs of the last time.
|
|
326
|
+
*/
|
|
327
|
+
validate(): PlainReport {
|
|
328
|
+
if (!this.ready || this.size === 0) {
|
|
329
|
+
this.findings = { shacl: new Map(), tables: new Map(), sparql: new Map(), references: new Map() };
|
|
330
|
+
this.clearChanged();
|
|
331
|
+
return { conforms: true, results: [], timing: { shacl: 0, tables: 0, nodes: 0 } };
|
|
332
|
+
}
|
|
333
|
+
const nodes = this.findings && !this.changed.all ? this.affected() : undefined;
|
|
334
|
+
// The SPARQL-based constraints reach as their queries do, not as the shapes say: around what changed, both ways.
|
|
335
|
+
const sparqlNodes = nodes && this.sparqlRunner ? this.around(SPARQL_HOPS) : undefined;
|
|
336
|
+
const timing = nodes ? this.validateNodes(nodes, sparqlNodes) : this.validateWhole();
|
|
337
|
+
this.clearChanged();
|
|
338
|
+
return this.report(timing);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
private validateWhole(): PlainReport['timing'] {
|
|
342
|
+
const t0 = now();
|
|
343
|
+
const options = { recursionGuard: this.reach.recursive, preferredLanguage: this.preferredLanguage };
|
|
344
|
+
const shacl = this.split.kept.length > 0 ? this.validator.validateStore(this.data, this.split.kept, options).results : [];
|
|
345
|
+
const t1 = now();
|
|
346
|
+
const byTables = checkRelationshipsByTables(this.data as unknown as Iterable<Quad>, this.split, this.tables, this.closure);
|
|
347
|
+
const t2 = now();
|
|
348
|
+
const sparql = this.sparqlRunner?.run() ?? [];
|
|
349
|
+
const t3 = now();
|
|
350
|
+
const references = missingReferences(this.data as never);
|
|
351
|
+
const t4 = now();
|
|
352
|
+
this.findings = { shacl: byFocus(shacl), tables: byFocus(byTables), sparql: byFocus(sparql), references: byFocus(references) };
|
|
353
|
+
this.sinceWhole = 0;
|
|
354
|
+
return { shacl: Math.round(t1 - t0), tables: Math.round(t2 - t1), sparql: Math.round(t3 - t2), references: Math.round(t4 - t3), nodes: 'all', ...this.slowRules() };
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** The SPARQL-based constraints of the last run that took {@link SLOW_RULE_MS} or more, slowest first — if any. */
|
|
358
|
+
private slowRules(): { slowRules?: Array<{ shape: string; ms: number }> } {
|
|
359
|
+
const slow = (this.sparqlRunner?.lastTimings ?? [])
|
|
360
|
+
.filter((t) => t.ms >= SLOW_RULE_MS)
|
|
361
|
+
.sort((a, b) => b.ms - a.ms)
|
|
362
|
+
.map((t) => ({ shape: t.shape, ms: Math.round(t.ms) }));
|
|
363
|
+
return slow.length > 0 ? { slowRules: slow } : {};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
private validateNodes(nodes: Map<string, Term>, sparqlNodes?: Map<string, Term>): PlainReport['timing'] {
|
|
367
|
+
const findings = this.findings as NonNullable<ValidationEngine['findings']>;
|
|
368
|
+
const focus = [...nodes.values()];
|
|
369
|
+
const t0 = now();
|
|
370
|
+
const options = { recursionGuard: this.reach.recursive, preferredLanguage: this.preferredLanguage };
|
|
371
|
+
const shacl = this.split.kept.length > 0 ? this.validator.validateNodes(this.data, this.split.kept, focus, options).results : [];
|
|
372
|
+
const t1 = now();
|
|
373
|
+
const byTables = checkRelationshipsByTables(this.triplesOf(focus), this.split, this.tables, this.closure);
|
|
374
|
+
const t2 = now();
|
|
375
|
+
// Too many nodes around what changed: the SPARQL-based constraints run on the whole model.
|
|
376
|
+
const sparql = this.sparqlRunner
|
|
377
|
+
? sparqlNodes
|
|
378
|
+
? this.sparqlRunner.run([...sparqlNodes.values()], this.targetTest())
|
|
379
|
+
: this.sparqlRunner.run()
|
|
380
|
+
: [];
|
|
381
|
+
const t3 = now();
|
|
382
|
+
const references = missingReferences(this.data as never, focus);
|
|
383
|
+
const t4 = now();
|
|
384
|
+
for (const key of nodes.keys()) {
|
|
385
|
+
findings.shacl.delete(key);
|
|
386
|
+
findings.tables.delete(key);
|
|
387
|
+
findings.references.delete(key);
|
|
388
|
+
}
|
|
389
|
+
if (sparqlNodes) for (const key of sparqlNodes.keys()) findings.sparql.delete(key);
|
|
390
|
+
else findings.sparql.clear();
|
|
391
|
+
for (const [key, results] of byFocus(shacl)) findings.shacl.set(key, results);
|
|
392
|
+
for (const [key, results] of byFocus(byTables)) findings.tables.set(key, results);
|
|
393
|
+
for (const [key, results] of byFocus(sparql)) findings.sparql.set(key, results);
|
|
394
|
+
for (const [key, results] of byFocus(references)) findings.references.set(key, results);
|
|
395
|
+
this.sinceWhole++;
|
|
396
|
+
return { shacl: Math.round(t1 - t0), tables: Math.round(t2 - t1), sparql: Math.round(t3 - t2), references: Math.round(t4 - t3), nodes: nodes.size, ...this.slowRules() };
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** The report from the findings kept — none about a resource the model only refers to. */
|
|
400
|
+
private report(timing: PlainReport['timing']): PlainReport {
|
|
401
|
+
const findings = this.findings as NonNullable<ValidationEngine['findings']>;
|
|
402
|
+
const keep = (r: ValidationResult) => !this.outsideOnly(r.focusNode.value);
|
|
403
|
+
const shacl = [...findings.shacl.values()].flat().filter(keep);
|
|
404
|
+
const others = [...findings.tables.values(), ...findings.sparql.values(), ...findings.references.values()].flat().filter(keep);
|
|
405
|
+
return {
|
|
406
|
+
// As SHACL reports it: conforming with no result at all; the rest with no violation.
|
|
407
|
+
conforms: shacl.length === 0 && !others.some((r) => r.severity === 'Violation'),
|
|
408
|
+
results: [...shacl, ...others].map(plain),
|
|
409
|
+
timing,
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* The nodes whose findings what changed can change, by key — or `undefined`
|
|
415
|
+
* when the whole model is to be validated: the class hierarchy changed, the
|
|
416
|
+
* shapes reach without bound or report one node's findings as another's, it
|
|
417
|
+
* is time to, or the nodes are too many.
|
|
418
|
+
*/
|
|
419
|
+
private affected(): Map<string, Term> | undefined {
|
|
420
|
+
if (this.sinceWhole >= FULL_EVERY || !Number.isFinite(this.reach.hops) || this.reach.valuesAsFocus) return undefined;
|
|
421
|
+
const { subjects, objects, alone } = this.changed;
|
|
422
|
+
// The table check reads a relationship's ends: one hop at least.
|
|
423
|
+
const hops = Math.max(1, this.reach.hops);
|
|
424
|
+
const from = this.reach.inverse ? [...subjects.values(), ...objects.values()] : [...subjects.values()];
|
|
425
|
+
// A shape reaches a node only along the predicates its paths name; the table check and the reference check, by
|
|
426
|
+
// theirs.
|
|
427
|
+
const nodes = this.near(from, hops, this.reach.inverse, (p) => this.checksRead(p));
|
|
428
|
+
if (!nodes) return undefined;
|
|
429
|
+
// Validated without what leads to them: the objects (a target of `sh:targetObjectsOf`), and the ends of what no
|
|
430
|
+
// shape reads. Added after the walk, so that one of them the walk comes to is walked on from.
|
|
431
|
+
for (const [key, term] of objects) nodes.set(key, term);
|
|
432
|
+
for (const [key, term] of alone) nodes.set(key, term);
|
|
433
|
+
return nodes.size > this.limit ? undefined : nodes;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* The nodes within `hops` of the triples the SPARQL-based constraints' queries
|
|
438
|
+
* name, both ways, and the ends of the rest — or `undefined` when they are too
|
|
439
|
+
* many and the whole model is to be validated.
|
|
440
|
+
*/
|
|
441
|
+
private around(hops: number): Map<string, Term> | undefined {
|
|
442
|
+
// Along any predicate: a query that matches any predicate of `$this` reaches its neighbours by every one.
|
|
443
|
+
const nodes = this.near([...this.changed.around.values()], hops, true, () => true);
|
|
444
|
+
if (!nodes) return undefined;
|
|
445
|
+
for (const [key, term] of this.changed.alone) nodes.set(key, term);
|
|
446
|
+
return nodes.size > this.limit ? undefined : nodes;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* `from`, and the nodes up to `hops` before it — and after it too, `both` —
|
|
451
|
+
* along the predicates that `follows`, by key; `undefined` when they are more
|
|
452
|
+
* than a share of the model.
|
|
453
|
+
*/
|
|
454
|
+
private near(from: readonly Term[], hops: number, both: boolean, follows: (predicate: string) => boolean): Map<string, Term> | undefined {
|
|
455
|
+
const limit = this.limit;
|
|
456
|
+
const nodes = new Map<string, Term>();
|
|
457
|
+
for (const term of from) nodes.set(keyOf(term), term);
|
|
458
|
+
let frontier = [...nodes.values()];
|
|
459
|
+
for (let hop = 0; hop < hops && frontier.length > 0; hop++) {
|
|
460
|
+
const next: Term[] = [];
|
|
461
|
+
const add = (term: Term) => {
|
|
462
|
+
if (term.termType !== 'NamedNode' && term.termType !== 'BlankNode') return;
|
|
463
|
+
const key = keyOf(term);
|
|
464
|
+
if (nodes.has(key)) return;
|
|
465
|
+
nodes.set(key, term);
|
|
466
|
+
next.push(term);
|
|
467
|
+
};
|
|
468
|
+
for (const node of frontier) {
|
|
469
|
+
for (const q of this.data.getQuads(null, null, node as never, null)) if (follows(q.predicate.value)) add(q.subject as unknown as Term);
|
|
470
|
+
if (both) for (const q of this.data.getQuads(node as never, null, null, null)) if (follows(q.predicate.value)) add(q.object as unknown as Term);
|
|
471
|
+
if (nodes.size > limit) return undefined;
|
|
472
|
+
}
|
|
473
|
+
frontier = next;
|
|
474
|
+
}
|
|
475
|
+
return nodes.size > limit ? undefined : nodes;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** The most nodes validated after an edit: past it, the whole model is (FULL_SHARE, FULL_FLOOR). */
|
|
479
|
+
private get limit(): number {
|
|
480
|
+
return Math.max(FULL_FLOOR, this.size / FULL_SHARE);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Whether a node is one of a SPARQL-based constraint's targets, as its query finds them in the same data
|
|
485
|
+
* (`targetPattern`): one of its nodes, a subject or an object of its predicates, or of one of its classes — by
|
|
486
|
+
* `rdf:type/rdfs:subClassOf*`. Each node's classes are read once, for one validation.
|
|
487
|
+
*/
|
|
488
|
+
private targetTest(): (targets: ShapeTargets, node: Term) => boolean {
|
|
489
|
+
const type = DataFactory.namedNode(RDF_TYPE);
|
|
490
|
+
const subClassOf = DataFactory.namedNode(RDFS_SUBCLASS_OF);
|
|
491
|
+
const classes = new Map<string, Set<string>>();
|
|
492
|
+
const classesOf = (node: Term): Set<string> => {
|
|
493
|
+
let found = classes.get(keyOf(node));
|
|
494
|
+
if (found) return found;
|
|
495
|
+
found = new Set<string>();
|
|
496
|
+
const stack = this.data.getQuads(node as never, type, null, null).map((q) => q.object as unknown as Term);
|
|
497
|
+
while (stack.length > 0) {
|
|
498
|
+
const c = stack.pop() as Term;
|
|
499
|
+
if (c.termType !== 'NamedNode' || found.has(c.value)) continue;
|
|
500
|
+
found.add(c.value);
|
|
501
|
+
for (const q of this.data.getQuads(c as never, subClassOf, null, null)) stack.push(q.object as unknown as Term);
|
|
502
|
+
}
|
|
503
|
+
classes.set(keyOf(node), found);
|
|
504
|
+
return found;
|
|
505
|
+
};
|
|
506
|
+
return (targets, node) =>
|
|
507
|
+
(node.termType === 'NamedNode' && targets.nodes.includes(node.value)) ||
|
|
508
|
+
targets.subjectsOf.some((p) => this.data.countQuads(node as never, DataFactory.namedNode(p), null, null) > 0) ||
|
|
509
|
+
targets.objectsOf.some((p) => this.data.countQuads(null, DataFactory.namedNode(p), node as never, null) > 0) ||
|
|
510
|
+
(targets.classes.length > 0 && targets.classes.some((c) => classesOf(node).has(c)));
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/** What the table check reads of these nodes: their triples, and the types of what they point to. */
|
|
514
|
+
private triplesOf(nodes: readonly Term[]): Quad[] {
|
|
515
|
+
const quads: Quad[] = [];
|
|
516
|
+
const typed = new Set<string>();
|
|
517
|
+
const type = DataFactory.namedNode(RDF_TYPE);
|
|
518
|
+
for (const node of nodes) {
|
|
519
|
+
for (const q of this.data.getQuads(node as never, null, null, null) as unknown as Quad[]) {
|
|
520
|
+
quads.push(q);
|
|
521
|
+
const o = q.object;
|
|
522
|
+
if ((o.termType === 'NamedNode' || o.termType === 'BlankNode') && !typed.has(keyOf(o))) {
|
|
523
|
+
typed.add(keyOf(o));
|
|
524
|
+
quads.push(...(this.data.getQuads(o as never, type, null, null) as unknown as Quad[]));
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return quads;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Note a changed triple (KD-21). A change to the class hierarchy changes everything. One the shapes, the table
|
|
533
|
+
* check or the reference check read: its subject, followed back by the shapes' reach, and its object, when a node;
|
|
534
|
+
* one the SPARQL-based constraints' queries name: its ends, and what is around them. One that nothing names — an
|
|
535
|
+
* edit's stamps on the model, `dcterms:modified` and the rest — can change no finding but its ends' own: a query
|
|
536
|
+
* reads a predicate it does not name only by a variable, and does so next to `$this`, as every published rule
|
|
537
|
+
* does. Unless it is its subject's first triple or its last: what refers to the subject is validated again too,
|
|
538
|
+
* the subject being in the model, or no longer.
|
|
539
|
+
*/
|
|
540
|
+
private touch(q: Quad): void {
|
|
541
|
+
if (this.changed.all) return;
|
|
542
|
+
const p = q.predicate.value;
|
|
543
|
+
if (p === RDFS_SUBCLASS_OF) {
|
|
544
|
+
this.changed.all = true;
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
let byChecks = this.checksRead(p);
|
|
548
|
+
let byQueries = this.reads.queries.has(p);
|
|
549
|
+
if ((!byChecks || !byQueries) && this.firstOrLast(q)) byChecks = byQueries = true;
|
|
550
|
+
const s = q.subject as Term;
|
|
551
|
+
const o = q.object as Term;
|
|
552
|
+
const ends = o.termType === 'NamedNode' || o.termType === 'BlankNode' ? [s, o] : [s];
|
|
553
|
+
if (byChecks) {
|
|
554
|
+
this.changed.subjects.set(keyOf(s), s);
|
|
555
|
+
if (ends.length > 1) this.changed.objects.set(keyOf(o), o);
|
|
556
|
+
}
|
|
557
|
+
if (byQueries) for (const t of ends) this.changed.around.set(keyOf(t), t);
|
|
558
|
+
if (!byChecks || !byQueries) for (const t of ends) this.changed.alone.set(keyOf(t), t);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/** Whether the shapes, the table check or the reference check read triples by this predicate. */
|
|
562
|
+
private checksRead(p: string): boolean {
|
|
563
|
+
const { checks } = this.reads;
|
|
564
|
+
return checks === 'every' || checks.has(p) || this.tables.covers(p);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/** Whether a triple just added or removed is the only one its subject has, or had. */
|
|
568
|
+
private firstOrLast(q: Quad): boolean {
|
|
569
|
+
return this.data.countQuads(q.subject as never, null, null, null) === (this.data.has(q as never) ? 1 : 0);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
private clearChanged(): void {
|
|
573
|
+
this.changed = { subjects: new Map(), objects: new Map(), around: new Map(), alone: new Map(), all: false };
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/** The extras for the model the store holds (and nothing else): the hierarchy, the types of what it refers to. */
|
|
577
|
+
private addExtras(): void {
|
|
578
|
+
for (const q of this.hierarchy) this.addExtra(q);
|
|
579
|
+
const type = DataFactory.namedNode(RDF_TYPE);
|
|
580
|
+
for (const [iri, types] of this.outsideTypes) {
|
|
581
|
+
const object = DataFactory.namedNode(iri);
|
|
582
|
+
const n = this.data.countQuads(null, null, object, null) - this.data.countQuads(null, type, object, null);
|
|
583
|
+
if (n <= 0) continue;
|
|
584
|
+
this.references.set(iri, n);
|
|
585
|
+
for (const q of types) this.addExtra(q);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/** A model quad added (+1) or removed (−1): the outside resource it refers to gains or loses a reference — and its types with the first or the last. */
|
|
590
|
+
private refer(q: Quad, delta: 1 | -1): void {
|
|
591
|
+
if (q.predicate.value === RDF_TYPE || q.object.termType !== 'NamedNode') return;
|
|
592
|
+
const types = this.outsideTypes.get(q.object.value);
|
|
593
|
+
if (!types) return;
|
|
594
|
+
const before = this.references.get(q.object.value) ?? 0;
|
|
595
|
+
const after = before + delta;
|
|
596
|
+
if (after > 0) this.references.set(q.object.value, after);
|
|
597
|
+
else this.references.delete(q.object.value);
|
|
598
|
+
if (before === 0 && after > 0) for (const t of types) this.addExtra(t);
|
|
599
|
+
if (before > 0 && after <= 0) for (const t of types) this.removeExtra(t);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
private addExtra(q: Quad): void {
|
|
603
|
+
const k = extraKey(q) as string;
|
|
604
|
+
if (this.extras.has(k)) return;
|
|
605
|
+
this.extras.set(k, q);
|
|
606
|
+
if (this.data.has(q as never)) this.alsoModel.add(k);
|
|
607
|
+
else this.put(q);
|
|
608
|
+
this.touch(q);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
private removeExtra(q: Quad): void {
|
|
612
|
+
const k = extraKey(q) as string;
|
|
613
|
+
if (!this.extras.delete(k)) return;
|
|
614
|
+
this.touch(q);
|
|
615
|
+
if (this.alsoModel.delete(k)) return; // the model holds it
|
|
616
|
+
this.drop(q);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Whether a node is a resource the model only refers to: outside it, its types
|
|
621
|
+
* among the extras, nothing else said of it in the data. What the shapes find
|
|
622
|
+
* of it is not the model's to fix — and not true either: only its types are
|
|
623
|
+
* validated, not the rest of what its metamodel says (a catalogue's viewpoint
|
|
624
|
+
* found to declare no concepts).
|
|
625
|
+
*/
|
|
626
|
+
private outsideOnly(iri: string): boolean {
|
|
627
|
+
if (!this.references.has(iri)) return false;
|
|
628
|
+
for (const q of this.data.getQuads(DataFactory.namedNode(iri), null, null, null)) {
|
|
629
|
+
const k = extraKey(q as unknown as Quad);
|
|
630
|
+
if (k === undefined || !this.extras.has(k) || this.alsoModel.has(k)) return false;
|
|
631
|
+
}
|
|
632
|
+
return true;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/** A node's name in the model (`skos:prefLabel`, English first), for the SPARQL-based constraints' messages. */
|
|
636
|
+
private nameOf(iri: string): string | undefined {
|
|
637
|
+
const names = this.data.getQuads(DataFactory.namedNode(iri), DataFactory.namedNode(PREF_LABEL), null, null);
|
|
638
|
+
const pick = names.find((q) => (q.object as { language?: string }).language === 'en') ?? names[0];
|
|
639
|
+
return pick?.object.value;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/** A quad into the data — and its Oxigraph copy, unless that is to be built again. */
|
|
643
|
+
private put(q: Quad): void {
|
|
644
|
+
this.data.addQuad(q as never);
|
|
645
|
+
if (!this.rebuilding) this.sparqlData?.add(toOxQuad(q));
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/** A quad out of the data — and its Oxigraph copy, unless that is to be built again. */
|
|
649
|
+
private drop(q: Quad): void {
|
|
650
|
+
this.data.removeQuad(q as never);
|
|
651
|
+
if (!this.rebuilding) this.sparqlData?.delete(toOxQuad(q));
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/** A change being applied as a reload: the Oxigraph copy is built again after it. */
|
|
655
|
+
private rebuilding = false;
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* The Oxigraph copy made again from the data and the context — or none, without SPARQL-based constraints to run:
|
|
659
|
+
* in one native load of what N-Triples carries as it is, the rest one by one (KD-29). The copy it replaces is
|
|
660
|
+
* freed, so that its WebAssembly memory is used again rather than grown past.
|
|
661
|
+
*/
|
|
662
|
+
private rebuildSparqlData(): void {
|
|
663
|
+
this.dispose();
|
|
664
|
+
if (!this.sparqlRunner) return;
|
|
665
|
+
const store = new oxigraph.Store();
|
|
666
|
+
const give = (quads: Iterable<Quad>, graph?: oxigraph.NamedNode) => {
|
|
667
|
+
const { native, oneByOne } = splitForNativeLoad(quads);
|
|
668
|
+
try {
|
|
669
|
+
if (native.length > 0) {
|
|
670
|
+
store.load(nTriples(native), { format: 'application/n-triples', no_transaction: true, ...(graph ? { to_graph_name: graph } : {}) });
|
|
671
|
+
}
|
|
672
|
+
} catch {
|
|
673
|
+
// Statements already loaded are added again harmlessly; one at a time, past the argument limit (KReq 1.6).
|
|
674
|
+
for (const q of native) oneByOne.push(q);
|
|
675
|
+
}
|
|
676
|
+
for (const q of oneByOne) {
|
|
677
|
+
const ox = toOxQuad(q);
|
|
678
|
+
store.add(graph ? oxigraph.quad(ox.subject, ox.predicate, ox.object, graph) : ox);
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
give(this.data as unknown as Iterable<Quad>);
|
|
682
|
+
give(this.sparqlContext, oxigraph.namedNode(CONTEXT_GRAPH));
|
|
683
|
+
this.sparqlData = store;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/** A node's key: its value — as a result's focus node carries it. */
|
|
688
|
+
function keyOf(term: Term): string {
|
|
689
|
+
return term.value;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/** Results by their focus node's key. */
|
|
693
|
+
function byFocus(results: readonly ValidationResult[]): Map<string, ValidationResult[]> {
|
|
694
|
+
const map = new Map<string, ValidationResult[]>();
|
|
695
|
+
for (const r of results) {
|
|
696
|
+
const list = map.get(r.focusNode.value);
|
|
697
|
+
if (list) list.push(r);
|
|
698
|
+
else map.set(r.focusNode.value, [r]);
|
|
699
|
+
}
|
|
700
|
+
return map;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/** The quad in the default graph, where the engine keeps everything. */
|
|
704
|
+
function inDefaultGraph(q: Quad): Quad {
|
|
705
|
+
return q.graph.termType === 'DefaultGraph' ? q : (DataFactory.quad(q.subject as never, q.predicate as never, q.object as never) as unknown as Quad);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/** A key for a quad that can be an extra — `rdfs:subClassOf` or `rdf:type` — else `undefined`. */
|
|
709
|
+
function extraKey(q: Quad): string | undefined {
|
|
710
|
+
const p = q.predicate.value;
|
|
711
|
+
if (p !== RDF_TYPE && p !== RDFS_SUBCLASS_OF) return undefined;
|
|
712
|
+
return `${termToId(q.subject as never)} ${p} ${termToId(q.object as never)}`;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function plain(r: ValidationResult): PlainResult {
|
|
716
|
+
return {
|
|
717
|
+
focusNode: r.focusNode.value,
|
|
718
|
+
resultPath: r.resultPath.value,
|
|
719
|
+
sourceShape: r.sourceShape.value,
|
|
720
|
+
message: r.message,
|
|
721
|
+
severity: r.severity,
|
|
722
|
+
...(r.sourceConstraintComponent ? { sourceConstraintComponent: r.sourceConstraintComponent.value } : {}),
|
|
723
|
+
...(r.withinShape ? { withinShape: r.withinShape.value } : {}),
|
|
724
|
+
...(r.value ? { value: termToId(r.value as never) } : {}),
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function now(): number {
|
|
729
|
+
return typeof performance !== 'undefined' ? performance.now() : Date.now();
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/** The report back from plain data, its IRIs as terms. */
|
|
733
|
+
export function fromPlainReport(report: Pick<PlainReport, 'conforms' | 'results'>, namedNode: (iri: string) => unknown): ValidationReport {
|
|
734
|
+
return {
|
|
735
|
+
conforms: report.conforms,
|
|
736
|
+
results: report.results.map((r) => ({
|
|
737
|
+
focusNode: namedNode(r.focusNode) as ValidationResult['focusNode'],
|
|
738
|
+
resultPath: namedNode(r.resultPath) as ValidationResult['resultPath'],
|
|
739
|
+
sourceShape: namedNode(r.sourceShape) as ValidationResult['sourceShape'],
|
|
740
|
+
message: r.message,
|
|
741
|
+
severity: r.severity,
|
|
742
|
+
...(r.sourceConstraintComponent ? { sourceConstraintComponent: namedNode(r.sourceConstraintComponent) as ValidationResult['focusNode'] } : {}),
|
|
743
|
+
...(r.withinShape ? { withinShape: namedNode(r.withinShape) as ValidationResult['focusNode'] } : {}),
|
|
744
|
+
...(r.value ? { value: termFromId(r.value, DataFactory as never) as unknown as Term } : {}),
|
|
745
|
+
})),
|
|
746
|
+
};
|
|
747
|
+
}
|