@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,290 @@
|
|
|
1
|
+
/** Tool-neutral SHACL property descriptors and S01 presentation metadata (KReq 3). */
|
|
2
|
+
import { DataFactory } from 'n3';
|
|
3
|
+
import type { BlankNode, NamedNode, Term } from '@rdfjs/types';
|
|
4
|
+
import type { RdfStore } from '../rdf-engine/interfaces.js';
|
|
5
|
+
import { selectLocalizedLiteral } from '../rdf-engine/localized-text.js';
|
|
6
|
+
import { NAMESPACES } from '../rdf-engine/namespaces.js';
|
|
7
|
+
import { typeClosure, labelOf } from '../model-manager/model-queries.js';
|
|
8
|
+
import { IRI, nn } from '../model-manager/vocabulary.js';
|
|
9
|
+
|
|
10
|
+
const SH = NAMESPACES.sh;
|
|
11
|
+
const DECIMAL = NAMESPACES.xsd + 'decimal';
|
|
12
|
+
const INTEGER = NAMESPACES.xsd + 'integer';
|
|
13
|
+
|
|
14
|
+
export interface RdfValue {
|
|
15
|
+
value: string;
|
|
16
|
+
kind: 'literal' | 'iri';
|
|
17
|
+
language?: string;
|
|
18
|
+
datatype?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Shape identities are meaningful in the store that loaded the metamodel assets. */
|
|
22
|
+
export type NodeShapeRef = NamedNode | BlankNode;
|
|
23
|
+
|
|
24
|
+
export interface PropertyShape {
|
|
25
|
+
path: string;
|
|
26
|
+
label: string;
|
|
27
|
+
group: string;
|
|
28
|
+
groupIri?: string;
|
|
29
|
+
groupOrder?: number;
|
|
30
|
+
order?: number;
|
|
31
|
+
presentationIssues: string[];
|
|
32
|
+
minCount: number;
|
|
33
|
+
maxCount?: number;
|
|
34
|
+
datatype?: string;
|
|
35
|
+
classIri?: string;
|
|
36
|
+
nodeShape?: string;
|
|
37
|
+
/** All conjunctive `sh:node` constraints, including anonymous shapes. */
|
|
38
|
+
nodeShapes?: readonly NodeShapeRef[];
|
|
39
|
+
choices: RdfValue[];
|
|
40
|
+
languages: string[];
|
|
41
|
+
shapes: string[];
|
|
42
|
+
unsupported: string[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface NodeShapeProperties {
|
|
46
|
+
fields: PropertyShape[];
|
|
47
|
+
/** The classes required on the focus node itself by the explicit shapes. */
|
|
48
|
+
classIris: string[];
|
|
49
|
+
/** Shape features that prevent a complete predicate-based form. Validation can still run. */
|
|
50
|
+
unsupported: string[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const valueOf = (term: Term): RdfValue => term.termType === 'NamedNode'
|
|
54
|
+
? { kind: 'iri', value: term.value }
|
|
55
|
+
: {
|
|
56
|
+
kind: 'literal',
|
|
57
|
+
value: term.value,
|
|
58
|
+
...(term.termType === 'Literal' ? { language: term.language, datatype: term.datatype.value } : {}),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export function termOf(value: RdfValue): Term {
|
|
62
|
+
if (value.kind === 'iri') return DataFactory.namedNode(value.value) as Term;
|
|
63
|
+
const datatype = value.datatype ? DataFactory.namedNode(value.datatype) : undefined;
|
|
64
|
+
return DataFactory.literal(value.value, value.language || datatype) as Term;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function assetValues(store: RdfStore, subject: Term, predicate: string): Term[] {
|
|
68
|
+
return store.getQuads(subject as NamedNode, nn(predicate))
|
|
69
|
+
.filter(q => q.graph.termType !== 'DefaultGraph')
|
|
70
|
+
.map(q => q.object);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function isShapeRef(term: Term): term is NodeShapeRef {
|
|
74
|
+
return term.termType === 'NamedNode' || term.termType === 'BlankNode';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function shapeKey(term: Term): string {
|
|
78
|
+
return `${term.termType}:${term.value}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function hasDifferentTerms(terms: readonly Term[]): boolean {
|
|
82
|
+
return terms.some(term => !term.equals(terms[0]));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function allowsNamedResource(kind: Term): boolean {
|
|
86
|
+
return kind.termType === 'NamedNode' && ['IRI', 'BlankNodeOrIRI', 'IRIOrLiteral'].some(name => kind.value === SH + name);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function shapeReader(store: RdfStore) {
|
|
90
|
+
const values = (subject: Term, predicate: string) => assetValues(store, subject, predicate);
|
|
91
|
+
function list(head: Term): { items: Term[]; complete: boolean } {
|
|
92
|
+
const items: Term[] = [];
|
|
93
|
+
const seen = new Set<string>();
|
|
94
|
+
let complete = true;
|
|
95
|
+
while (isShapeRef(head) && !seen.has(shapeKey(head))) {
|
|
96
|
+
if (head.termType === 'NamedNode' && head.value === IRI.rdfNil) return { items, complete };
|
|
97
|
+
seen.add(shapeKey(head));
|
|
98
|
+
const first = values(head, IRI.rdfFirst);
|
|
99
|
+
const rest = values(head, IRI.rdfRest);
|
|
100
|
+
if (!first.length) break;
|
|
101
|
+
items.push(first[0]);
|
|
102
|
+
if (!rest.length) break;
|
|
103
|
+
if (hasDifferentTerms(first) || hasDifferentTerms(rest)) complete = false;
|
|
104
|
+
head = rest[0];
|
|
105
|
+
}
|
|
106
|
+
return { items, complete: false };
|
|
107
|
+
}
|
|
108
|
+
const truthy = (term: Term) => term.termType === 'Literal' && (term.value === 'true' || term.value === '1');
|
|
109
|
+
const deactivated = (shape: Term) => values(shape, SH + 'deactivated').some(truthy);
|
|
110
|
+
return { values, list, deactivated, truthy };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function compareText(a: string, b: string): number {
|
|
114
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function compareOrder(a?: number, b?: number): number {
|
|
118
|
+
if (a === b) return 0;
|
|
119
|
+
if (a === undefined) return 1;
|
|
120
|
+
if (b === undefined) return -1;
|
|
121
|
+
return a - b;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function comparePropertyShapes(a: PropertyShape, b: PropertyShape): number {
|
|
125
|
+
return compareOrder(a.groupOrder, b.groupOrder)
|
|
126
|
+
|| compareText(a.groupIri ?? '', b.groupIri ?? '')
|
|
127
|
+
|| compareOrder(a.order, b.order)
|
|
128
|
+
|| compareText(a.path, b.path);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function single<T>(values: readonly T[]): T | undefined {
|
|
132
|
+
const unique = new Set(values);
|
|
133
|
+
return unique.size === 1 ? unique.values().next().value : undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function numeric(term: Term): number | undefined {
|
|
137
|
+
if (term.termType !== 'Literal') return undefined;
|
|
138
|
+
if (term.datatype.value !== DECIMAL && term.datatype.value !== INTEGER) return undefined;
|
|
139
|
+
const value = Number(term.value);
|
|
140
|
+
return term.value.trim() && Number.isFinite(value) ? value : undefined;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Applicable predicate paths. Complex SHACL paths stay in the validator. */
|
|
144
|
+
export function propertyShapesForType(store: RdfStore, type: string, locale = 'en'): PropertyShape[] {
|
|
145
|
+
if (!type) return [];
|
|
146
|
+
const ancestors = new Set(typeClosure(store)(type));
|
|
147
|
+
const roots = store.getQuads(null, nn(SH + 'targetClass'))
|
|
148
|
+
.filter(q => q.graph.termType !== 'DefaultGraph' && ancestors.has(q.object.value))
|
|
149
|
+
.map(q => q.subject as Term).filter(isShapeRef);
|
|
150
|
+
const reader = shapeReader(store);
|
|
151
|
+
for (const iri of ancestors) {
|
|
152
|
+
const node = nn(iri);
|
|
153
|
+
if (reader.values(node, IRI.rdfType).some(t => t.value === SH + 'NodeShape')) roots.push(node);
|
|
154
|
+
}
|
|
155
|
+
return collectPropertyShapes(store, roots, locale, reader);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Read a referenced node shape without adding a synthetic class target to the assets (KReq 3.4). */
|
|
159
|
+
export function propertyShapesForNodeShapes(store: RdfStore, roots: readonly NodeShapeRef[], locale = 'en'): NodeShapeProperties {
|
|
160
|
+
const reader = shapeReader(store);
|
|
161
|
+
const { values, list, deactivated, truthy } = reader;
|
|
162
|
+
const unsupported = new Set<string>();
|
|
163
|
+
const classIris = new Set<string>();
|
|
164
|
+
const active = new Set<string>();
|
|
165
|
+
const visited = new Set<string>();
|
|
166
|
+
|
|
167
|
+
function inspect(shape: Term, property: boolean, focusNode: boolean) {
|
|
168
|
+
if (!isShapeRef(shape)) {
|
|
169
|
+
unsupported.add(property ? 'property' : 'node');
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (deactivated(shape)) return;
|
|
173
|
+
const key = shapeKey(shape);
|
|
174
|
+
if (active.has(key)) {
|
|
175
|
+
unsupported.add('recursive-node-shape');
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const visitKey = `${property}:${focusNode}:${key}`;
|
|
179
|
+
if (visited.has(visitKey)) return;
|
|
180
|
+
visited.add(visitKey);
|
|
181
|
+
active.add(key);
|
|
182
|
+
if (!store.getQuads(shape as NamedNode).some(quad => quad.graph.termType !== 'DefaultGraph')) {
|
|
183
|
+
unsupported.add('missing-node-shape');
|
|
184
|
+
}
|
|
185
|
+
const paths = values(shape, SH + 'path');
|
|
186
|
+
if (property ? paths[0]?.termType !== 'NamedNode' || hasDifferentTerms(paths) : paths.length > 0) {
|
|
187
|
+
unsupported.add('path');
|
|
188
|
+
}
|
|
189
|
+
if (!property) {
|
|
190
|
+
for (const name of ['or', 'xone', 'not', 'datatype', 'in', 'hasValue']) {
|
|
191
|
+
if (values(shape, SH + name).length) unsupported.add(name);
|
|
192
|
+
}
|
|
193
|
+
if (values(shape, SH + 'closed').some(truthy)) unsupported.add('closed');
|
|
194
|
+
if (values(shape, SH + 'nodeKind').some(kind => !allowsNamedResource(kind))) unsupported.add('nodeKind');
|
|
195
|
+
for (const term of values(shape, SH + 'class')) {
|
|
196
|
+
if (term.termType !== 'NamedNode') unsupported.add('class');
|
|
197
|
+
else if (focusNode) classIris.add(term.value);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
for (const nested of values(shape, SH + 'node')) inspect(nested, false, focusNode && !property);
|
|
201
|
+
for (const head of values(shape, SH + 'and')) {
|
|
202
|
+
const conjunction = list(head);
|
|
203
|
+
if (!conjunction.complete || property) unsupported.add('and');
|
|
204
|
+
for (const member of conjunction.items) inspect(member, false, focusNode && !property);
|
|
205
|
+
}
|
|
206
|
+
for (const nested of values(shape, SH + 'property')) {
|
|
207
|
+
if (property) unsupported.add('property');
|
|
208
|
+
inspect(nested, true, false);
|
|
209
|
+
}
|
|
210
|
+
active.delete(key);
|
|
211
|
+
}
|
|
212
|
+
for (const shape of roots) inspect(shape, false, true);
|
|
213
|
+
return {
|
|
214
|
+
fields: collectPropertyShapes(store, roots, locale, reader),
|
|
215
|
+
classIris: [...classIris].sort(compareText),
|
|
216
|
+
unsupported: [...unsupported].sort(compareText),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function collectPropertyShapes(store: RdfStore, roots: readonly NodeShapeRef[], locale: string, reader: ReturnType<typeof shapeReader>): PropertyShape[] {
|
|
221
|
+
const { values, list, deactivated } = reader;
|
|
222
|
+
|
|
223
|
+
const propertiesByPath = new Map<string, Term[]>();
|
|
224
|
+
const visited = new Set<string>();
|
|
225
|
+
function walk(shape: Term) {
|
|
226
|
+
const key = shapeKey(shape);
|
|
227
|
+
if (!isShapeRef(shape) || visited.has(key) || deactivated(shape)) return;
|
|
228
|
+
visited.add(key);
|
|
229
|
+
for (const inherited of [...values(shape, SH + 'node'), ...values(shape, SH + 'and').flatMap(head => list(head).items)]) walk(inherited);
|
|
230
|
+
for (const property of values(shape, SH + 'property')) {
|
|
231
|
+
if (!isShapeRef(property) || deactivated(property)) continue;
|
|
232
|
+
const path = values(property, SH + 'path')[0];
|
|
233
|
+
if (path?.termType !== 'NamedNode') continue;
|
|
234
|
+
const shapes = propertiesByPath.get(path.value) ?? [];
|
|
235
|
+
if (!shapes.some(s => s.equals(property))) shapes.push(property);
|
|
236
|
+
propertiesByPath.set(path.value, shapes);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
roots.forEach(walk);
|
|
240
|
+
|
|
241
|
+
return [...propertiesByPath].map(([path, shapes]): PropertyShape => {
|
|
242
|
+
const declared = (predicate: string) => shapes.flatMap(s => values(s, predicate));
|
|
243
|
+
const presentationIssues: string[] = [];
|
|
244
|
+
const consistent = <T>(values: T[], property: string): T | undefined => {
|
|
245
|
+
const result = single(values);
|
|
246
|
+
if (values.length && result === undefined) presentationIssues.push(property);
|
|
247
|
+
return result;
|
|
248
|
+
};
|
|
249
|
+
const names = shapes.map(s => selectLocalizedLiteral(values(s, SH + 'name'), locale)?.value).filter(v => v !== undefined);
|
|
250
|
+
const groupIri = consistent(declared(SH + 'group').map(t => t.termType === 'NamedNode' ? t.value : undefined), SH + 'group');
|
|
251
|
+
const order = consistent(declared(SH + 'order').map(t => numeric(t)), SH + 'order');
|
|
252
|
+
const groupOrder = groupIri
|
|
253
|
+
? consistent(values(nn(groupIri), SH + 'order').map(t => numeric(t)), SH + 'order')
|
|
254
|
+
: undefined;
|
|
255
|
+
const max = declared(SH + 'maxCount').map(t => Number(t.value));
|
|
256
|
+
const choiceLists = declared(SH + 'in').map(list);
|
|
257
|
+
const languageLists = declared(SH + 'languageIn').map(list);
|
|
258
|
+
const intersection = (lists: Term[][]) => (lists[0] ?? []).filter(term => lists.every(items => items.some(t => t.equals(term))));
|
|
259
|
+
const choices = intersection(choiceLists.map(({ items }) => items));
|
|
260
|
+
const languages = intersection(languageLists.map(({ items }) => items));
|
|
261
|
+
const nodeTargets = declared(SH + 'node');
|
|
262
|
+
const nodeShapes = new Map(nodeTargets.filter(isShapeRef).map(shape => [shapeKey(shape), shape]));
|
|
263
|
+
const unsupported = ['or', 'xone', 'not', 'qualifiedValueShape'].filter(name => declared(SH + name).length > 0);
|
|
264
|
+
if (choiceLists.length && (!choices.length || choiceLists.some(({ complete }) => !complete)
|
|
265
|
+
|| choices.some(term => term.termType !== 'Literal' && term.termType !== 'NamedNode'))) unsupported.push('in');
|
|
266
|
+
if (languageLists.length && (!languages.length || languageLists.some(({ complete }) => !complete)
|
|
267
|
+
|| languages.some(term => term.termType !== 'Literal'))) unsupported.push('languageIn');
|
|
268
|
+
if (nodeTargets.some(term => !isShapeRef(term))) unsupported.push('node');
|
|
269
|
+
if (nodeShapes.size && declared(SH + 'nodeKind').some(kind => !allowsNamedResource(kind))) unsupported.push('nodeKind');
|
|
270
|
+
return {
|
|
271
|
+
path,
|
|
272
|
+
label: consistent(names, SH + 'name') ?? labelOf(store, path, locale),
|
|
273
|
+
group: groupIri ? selectLocalizedLiteral(values(nn(groupIri), IRI.rdfsLabel), locale)?.value ?? labelOf(store, groupIri, locale) : '',
|
|
274
|
+
groupIri,
|
|
275
|
+
groupOrder,
|
|
276
|
+
order,
|
|
277
|
+
presentationIssues,
|
|
278
|
+
minCount: Math.max(0, ...declared(SH + 'minCount').map(t => Number(t.value))),
|
|
279
|
+
maxCount: max.length ? Math.min(...max) : undefined,
|
|
280
|
+
datatype: single(declared(SH + 'datatype').map(t => t.value)),
|
|
281
|
+
classIri: single(declared(SH + 'class').map(t => t.value)),
|
|
282
|
+
nodeShape: single(nodeTargets.map(t => t.value)),
|
|
283
|
+
...(nodeShapes.size ? { nodeShapes: [...nodeShapes.values()] } : {}),
|
|
284
|
+
choices: choices.map(valueOf),
|
|
285
|
+
languages: languages.map(t => t.value),
|
|
286
|
+
shapes: shapes.map(s => s.value),
|
|
287
|
+
unsupported,
|
|
288
|
+
};
|
|
289
|
+
}).sort(comparePropertyShapes);
|
|
290
|
+
}
|