@linked.archi/kernel 0.0.0-stage → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +11 -0
- package/README.md +96 -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 +923 -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 +893 -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 +7302 -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 +840 -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 +470 -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/observable-store.ts +631 -0
- package/src/rdf-engine/rdf-store.ts +508 -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 +334 -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 +682 -0
- package/src/rdf-engine/validation-service.ts +184 -0
- package/src/rdf-engine/validation.worker.ts +47 -0
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual notation extraction.
|
|
3
|
+
*
|
|
4
|
+
* Reads the `arch-vis:` visual-notation layer out of a loaded metamodel graph:
|
|
5
|
+
*
|
|
6
|
+
* ```
|
|
7
|
+
* PresentationContext --arch:usesNotationSet--> NotationSet
|
|
8
|
+
* NotationSet <--arch-vis:inNotationSet-- VisualNotation
|
|
9
|
+
* VisualNotation --arch-vis:notationFor--> element/relationship class
|
|
10
|
+
* VisualNotation --arch-vis:defaultStyle--> Style
|
|
11
|
+
* VisualNotation --arch:prefVisNotation--> pre-rendered composite image
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* This module deliberately works on a plain n3 `Store` rather than the
|
|
15
|
+
* `RdfStore` abstraction so it stays synchronous and directly unit-testable.
|
|
16
|
+
*
|
|
17
|
+
* `Style` nodes are usually Turtle blank nodes (`[ ... ]`). All lookups pass the
|
|
18
|
+
* n3 `Term` straight through to `Store.getObjects()`, which accepts any term as
|
|
19
|
+
* subject — never reconstruct a subject from its string value.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { DataFactory } from 'n3';
|
|
23
|
+
import type { Store, Term } from 'n3';
|
|
24
|
+
import { NAMESPACES } from '../rdf-engine/namespaces.js';
|
|
25
|
+
import { APPEARANCE_PREDICATES, appearanceValue, type Appearance } from '../model-manager/appearance.js';
|
|
26
|
+
|
|
27
|
+
const { namedNode } = DataFactory;
|
|
28
|
+
|
|
29
|
+
const ARCH = NAMESPACES.arch;
|
|
30
|
+
const ARCH_VIS = NAMESPACES['arch-vis'];
|
|
31
|
+
const SKOS = NAMESPACES.skos;
|
|
32
|
+
const RDFS = NAMESPACES.rdfs;
|
|
33
|
+
const RDF_TYPE = `${NAMESPACES.rdf}type`;
|
|
34
|
+
|
|
35
|
+
/** `arch:` and `arch-vis:` terms used by the notation layer. */
|
|
36
|
+
const T = {
|
|
37
|
+
metamodel: `${ARCH}Metamodel`,
|
|
38
|
+
notationSet: `${ARCH}notationSet`,
|
|
39
|
+
usesNotationSet: `${ARCH}usesNotationSet`,
|
|
40
|
+
prefVisNotation: `${ARCH}prefVisNotation`,
|
|
41
|
+
notationSetClass: `${ARCH_VIS}NotationSet`,
|
|
42
|
+
visualNotationClass: `${ARCH_VIS}VisualNotation`,
|
|
43
|
+
inNotationSet: `${ARCH_VIS}inNotationSet`,
|
|
44
|
+
notationFor: `${ARCH_VIS}notationFor`,
|
|
45
|
+
defaultStyle: `${ARCH_VIS}defaultStyle`,
|
|
46
|
+
alternativeStyle: `${ARCH_VIS}alternativeStyle`,
|
|
47
|
+
shapeType: `${ARCH_VIS}shapeType`,
|
|
48
|
+
fillColor: `${ARCH_VIS}fillColor`,
|
|
49
|
+
lineColor: `${ARCH_VIS}lineColor`,
|
|
50
|
+
fontColor: `${ARCH_VIS}fontColor`,
|
|
51
|
+
iconSymbol: `${ARCH_VIS}iconSymbol`,
|
|
52
|
+
iconPlacement: `${ARCH_VIS}iconPlacement`,
|
|
53
|
+
renderingMode: `${ARCH_VIS}renderingMode`,
|
|
54
|
+
defaultWidth: `${ARCH_VIS}defaultWidth`,
|
|
55
|
+
defaultHeight: `${ARCH_VIS}defaultHeight`,
|
|
56
|
+
borderStyle: `${ARCH_VIS}borderStyle`,
|
|
57
|
+
fallbackShape: `${ARCH_VIS}fallbackShape`,
|
|
58
|
+
shapeVariables: `${ARCH_VIS}shapeVariables`,
|
|
59
|
+
outlinePath: `${ARCH_VIS}outlinePath`,
|
|
60
|
+
detailPath: `${ARCH_VIS}detailPath`,
|
|
61
|
+
contentBox: `${ARCH_VIS}contentBox`,
|
|
62
|
+
labelBox: `${ARCH_VIS}labelBox`,
|
|
63
|
+
lineStyle: `${ARCH_VIS}lineStyle`,
|
|
64
|
+
sourceDecor: `${ARCH_VIS}sourceDecor`,
|
|
65
|
+
targetDecor: `${ARCH_VIS}targetDecor`,
|
|
66
|
+
nestedEnd: `${ARCH_VIS}nestedEnd`,
|
|
67
|
+
labelAnchor: `${ARCH_VIS}labelAnchor`,
|
|
68
|
+
labelExpression: `${ARCH_VIS}labelExpression`,
|
|
69
|
+
expression: `${ARCH_VIS}expression`,
|
|
70
|
+
inPresentationContext: `${ARCH}inPresentationContext`,
|
|
71
|
+
prefLabel: `${SKOS}prefLabel`,
|
|
72
|
+
rdfsLabel: `${RDFS}label`,
|
|
73
|
+
} as const;
|
|
74
|
+
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// Type vocabulary
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
/** How shape and icon are composed when rendering an element. */
|
|
80
|
+
export type RenderingMode = 'ShapeWithBadge' | 'IconCentric' | 'ShapeOnly';
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The core shapes (`core-vis`), which every renderer draws natively. A
|
|
84
|
+
* notation's own shapes are {@link CustomShape}s: declared in its namespace with
|
|
85
|
+
* a core fallback and their geometry as path templates.
|
|
86
|
+
*/
|
|
87
|
+
export type ShapeType =
|
|
88
|
+
| 'RoundedRectangle'
|
|
89
|
+
| 'Rectangle'
|
|
90
|
+
| 'Octagon'
|
|
91
|
+
| 'Ellipse'
|
|
92
|
+
| 'Circle'
|
|
93
|
+
| 'Hexagon'
|
|
94
|
+
| 'Diamond'
|
|
95
|
+
| 'Parallelogram';
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A shape a notation declares itself (an `arch-vis:ShapeType` outside core-vis),
|
|
99
|
+
* read from its data: the core shape to fall back to and its geometry as path
|
|
100
|
+
* templates — SVG path data whose numbers may be `{expressions}` over `w`, `h`
|
|
101
|
+
* and the variables. `notation-shapes.ts` evaluates them.
|
|
102
|
+
*/
|
|
103
|
+
export interface CustomShape {
|
|
104
|
+
iri: string;
|
|
105
|
+
/** Its name (`skos:prefLabel`), for offering it as a figure. */
|
|
106
|
+
label?: string;
|
|
107
|
+
/** `arch-vis:fallbackShape`: drawn when the templates cannot be. */
|
|
108
|
+
fallback?: ShapeType;
|
|
109
|
+
/** `arch-vis:shapeVariables`: `name = expression` assignments, `;`-separated. */
|
|
110
|
+
variables?: string;
|
|
111
|
+
/** `arch-vis:outlinePath`: filled, stroked, docked against. */
|
|
112
|
+
outline: string;
|
|
113
|
+
/** `arch-vis:detailPath`: inner lines, stroked only. */
|
|
114
|
+
details?: string;
|
|
115
|
+
/** `arch-vis:contentBox`: `x y width height` for the badge and label. */
|
|
116
|
+
contentBox?: string;
|
|
117
|
+
/** `arch-vis:labelBox`: `x y width height` for the label, when elsewhere. */
|
|
118
|
+
labelBox?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Icon position within (or relative to) the shape. */
|
|
122
|
+
export type IconPlacement = 'TopRight' | 'TopLeft' | 'TopCenter' | 'Center' | 'BottomCenter';
|
|
123
|
+
|
|
124
|
+
/** Line rendering for relationship notation. */
|
|
125
|
+
export type LineStyle = 'SolidLine' | 'DashedLine' | 'DottedLine';
|
|
126
|
+
|
|
127
|
+
/** Endpoint decoration for relationship arrows. */
|
|
128
|
+
export type Decoration =
|
|
129
|
+
| 'NoDecoration'
|
|
130
|
+
| 'OpenArrowhead'
|
|
131
|
+
| 'ClosedArrowhead'
|
|
132
|
+
| 'HollowArrowhead'
|
|
133
|
+
| 'HollowDiamond'
|
|
134
|
+
| 'FilledDiamond'
|
|
135
|
+
| 'HalfArrowhead'
|
|
136
|
+
| 'CircleDot';
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* What a notation's style may say of the look an element's or a relationship's
|
|
140
|
+
* own style may set too (core-vis 0.7): drawn beneath that, over la-gram's.
|
|
141
|
+
*/
|
|
142
|
+
export type NotationLook = Pick<
|
|
143
|
+
Appearance,
|
|
144
|
+
'lineWidth' | 'fontName' | 'fontSize' | 'fontStyle' | 'textAlignment' | 'textPosition' | 'gradient' | 'iconColor'
|
|
145
|
+
>;
|
|
146
|
+
|
|
147
|
+
const NOTATION_LOOK_KEYS = ['lineWidth', 'fontName', 'fontSize', 'fontStyle', 'textAlignment', 'textPosition', 'gradient', 'iconColor'] as const;
|
|
148
|
+
|
|
149
|
+
/** Visual style for an element type — the construction recipe. */
|
|
150
|
+
export interface VisualStyle extends NotationLook {
|
|
151
|
+
/**
|
|
152
|
+
* What the label of a concept drawn so says (core-vis 0.7's
|
|
153
|
+
* `arch-vis:labelExpression`): its notation's expressions, each for one
|
|
154
|
+
* presentation context (core's `arch:inPresentationContext`) or — without
|
|
155
|
+
* one — for every context. The name alone when there are none.
|
|
156
|
+
*/
|
|
157
|
+
labelExpressions?: LabelExpression[];
|
|
158
|
+
/** A core shape — for a notation's own shape, its fallback. */
|
|
159
|
+
shapeType?: ShapeType;
|
|
160
|
+
/** A notation's own shape, drawn from its templates in place of {@link shapeType}. */
|
|
161
|
+
customShape?: CustomShape;
|
|
162
|
+
fillColor?: string;
|
|
163
|
+
lineColor?: string;
|
|
164
|
+
/** Colour of the label (`arch-vis:fontColor`); the line colour when absent. */
|
|
165
|
+
fontColor?: string;
|
|
166
|
+
/** URI of the icon (SVG) to draw. */
|
|
167
|
+
iconSymbol?: string;
|
|
168
|
+
iconPlacement?: IconPlacement;
|
|
169
|
+
renderingMode?: RenderingMode;
|
|
170
|
+
defaultWidth?: number;
|
|
171
|
+
defaultHeight?: number;
|
|
172
|
+
/** Line style of the shape's outline (`arch-vis:borderStyle`); solid when absent. */
|
|
173
|
+
borderStyle?: LineStyle;
|
|
174
|
+
/**
|
|
175
|
+
* The other figures the concept may be drawn as (`arch-vis:alternativeStyle`
|
|
176
|
+
* on its notation): each its shape and rendering mode, an outline's style —
|
|
177
|
+
* its colours and glyph this style's. A diagram element drawn as one says so
|
|
178
|
+
* with the alternative's shape type on its own style.
|
|
179
|
+
*/
|
|
180
|
+
alternatives?: VisualStyle[];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Visual style for a relationship type. */
|
|
184
|
+
export interface RelationshipVisualStyle extends Pick<NotationLook, 'lineWidth' | 'fontName' | 'fontSize' | 'fontStyle'> {
|
|
185
|
+
lineStyle?: LineStyle;
|
|
186
|
+
sourceDecor?: Decoration;
|
|
187
|
+
targetDecor?: Decoration;
|
|
188
|
+
lineColor?: string;
|
|
189
|
+
/** Colour of its name; its line colour when absent. */
|
|
190
|
+
fontColor?: string;
|
|
191
|
+
/** Where along its lines its name sits (`arch-vis:labelAnchor`); at their middle when absent. */
|
|
192
|
+
labelAnchor?: 'source' | 'middle' | 'target';
|
|
193
|
+
/**
|
|
194
|
+
* The ends nesting may draw inside the other instead of a line
|
|
195
|
+
* (`arch-vis:nestedEnd`): `target` for a part inside its whole, `source` for
|
|
196
|
+
* ArchiMate's specialized element inside the generic one.
|
|
197
|
+
*/
|
|
198
|
+
nestedEnds?: Array<'source' | 'target'>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Visual notation for a single concept (element or relationship class). */
|
|
202
|
+
export interface VisualNotation {
|
|
203
|
+
/** The element/relationship class this notation describes. */
|
|
204
|
+
conceptIri: string;
|
|
205
|
+
/** The notation set this notation belongs to. */
|
|
206
|
+
notationSetIri: string;
|
|
207
|
+
/** URI of a pre-rendered composite image, when published. */
|
|
208
|
+
prefVisNotation?: string;
|
|
209
|
+
/** Element style (present for element notations). */
|
|
210
|
+
style?: VisualStyle;
|
|
211
|
+
/** Relationship style (present for relationship notations). */
|
|
212
|
+
relationshipStyle?: RelationshipVisualStyle;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** A named collection of visual notation descriptors. */
|
|
216
|
+
/** A label expression as a notation or a presentation context gives it: its text, and the context it is for. */
|
|
217
|
+
export interface LabelExpression {
|
|
218
|
+
expression: string;
|
|
219
|
+
/** The presentation context it is for; every context when absent. */
|
|
220
|
+
context?: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface NotationSet {
|
|
224
|
+
iri: string;
|
|
225
|
+
label: string;
|
|
226
|
+
/** conceptIri → notation. */
|
|
227
|
+
notations: Map<string, VisualNotation>;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const SHAPE_TYPES: ReadonlySet<string> = new Set<ShapeType>([
|
|
231
|
+
'RoundedRectangle',
|
|
232
|
+
'Rectangle',
|
|
233
|
+
'Octagon',
|
|
234
|
+
'Ellipse',
|
|
235
|
+
'Circle',
|
|
236
|
+
'Hexagon',
|
|
237
|
+
'Diamond',
|
|
238
|
+
'Parallelogram',
|
|
239
|
+
]);
|
|
240
|
+
|
|
241
|
+
/** A core shape by IRI: only core-vis's own names count, not a namesake in another namespace. */
|
|
242
|
+
function coreShape(iri: string | undefined): ShapeType | undefined {
|
|
243
|
+
if (!iri?.startsWith(ARCH_VIS)) return undefined;
|
|
244
|
+
const name = iri.slice(ARCH_VIS.length);
|
|
245
|
+
return SHAPE_TYPES.has(name) ? (name as ShapeType) : undefined;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* A style's shape: a core shape, or a notation's own with its templates (and
|
|
250
|
+
* its fallback as the core shape). An own shape without an outline draws as its
|
|
251
|
+
* fallback; one without either, as the default.
|
|
252
|
+
*/
|
|
253
|
+
function readShape(store: Store, styleTerm: Term): { shapeType?: ShapeType; customShape?: CustomShape } {
|
|
254
|
+
const term = store.getObjects(styleTerm, namedNode(T.shapeType), null).find((o) => o.termType === 'NamedNode');
|
|
255
|
+
if (!term) return {};
|
|
256
|
+
const core = coreShape(term.value);
|
|
257
|
+
if (core) return { shapeType: core };
|
|
258
|
+
const customShape = readCustomShape(store, term.value);
|
|
259
|
+
const fallback = customShape?.fallback ?? coreShape(objectValue(store, term, T.fallbackShape) ?? undefined);
|
|
260
|
+
return { ...(fallback ? { shapeType: fallback } : {}), ...(customShape ? { customShape } : {}) };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* A notation's own shape as the store describes it: its fallback and its
|
|
265
|
+
* templates. `undefined` for a core shape, or one with no outline to draw.
|
|
266
|
+
*/
|
|
267
|
+
export function readCustomShape(store: Store, iri: string): CustomShape | undefined {
|
|
268
|
+
if (coreShape(iri)) return undefined;
|
|
269
|
+
const subject = namedNode(iri);
|
|
270
|
+
const outline = objectValue(store, subject, T.outlinePath);
|
|
271
|
+
if (!outline) return undefined;
|
|
272
|
+
const fallback = coreShape(objectValue(store, subject, T.fallbackShape) ?? undefined);
|
|
273
|
+
const optional = (predicate: string) => objectValue(store, subject, predicate) ?? undefined;
|
|
274
|
+
return {
|
|
275
|
+
iri,
|
|
276
|
+
outline,
|
|
277
|
+
...(fallback ? { fallback } : {}),
|
|
278
|
+
...(optional(T.shapeVariables) ? { variables: optional(T.shapeVariables) } : {}),
|
|
279
|
+
...(optional(T.detailPath) ? { details: optional(T.detailPath) } : {}),
|
|
280
|
+
...(optional(T.contentBox) ? { contentBox: optional(T.contentBox) } : {}),
|
|
281
|
+
...(optional(T.labelBox) ? { labelBox: optional(T.labelBox) } : {}),
|
|
282
|
+
...(store.getObjects(subject, namedNode(T.prefLabel), null).length > 0 ? { label: labelFor(store, iri) } : {}),
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const ICON_PLACEMENTS: ReadonlySet<string> = new Set<IconPlacement>([
|
|
287
|
+
'TopRight',
|
|
288
|
+
'TopLeft',
|
|
289
|
+
'TopCenter',
|
|
290
|
+
'Center',
|
|
291
|
+
'BottomCenter',
|
|
292
|
+
]);
|
|
293
|
+
|
|
294
|
+
const RENDERING_MODES: ReadonlySet<string> = new Set<RenderingMode>([
|
|
295
|
+
'ShapeWithBadge',
|
|
296
|
+
'IconCentric',
|
|
297
|
+
'ShapeOnly',
|
|
298
|
+
]);
|
|
299
|
+
|
|
300
|
+
const LINE_STYLES: ReadonlySet<string> = new Set<LineStyle>(['SolidLine', 'DashedLine', 'DottedLine']);
|
|
301
|
+
|
|
302
|
+
const DECORATIONS: ReadonlySet<string> = new Set<Decoration>([
|
|
303
|
+
'NoDecoration',
|
|
304
|
+
'OpenArrowhead',
|
|
305
|
+
'ClosedArrowhead',
|
|
306
|
+
'HollowArrowhead',
|
|
307
|
+
'HollowDiamond',
|
|
308
|
+
'FilledDiamond',
|
|
309
|
+
'HalfArrowhead',
|
|
310
|
+
'CircleDot',
|
|
311
|
+
]);
|
|
312
|
+
|
|
313
|
+
// ---------------------------------------------------------------------------
|
|
314
|
+
// Term helpers
|
|
315
|
+
// ---------------------------------------------------------------------------
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* First object value for a subject term + predicate, whatever the term type.
|
|
319
|
+
*
|
|
320
|
+
* The subject is passed through as a term so blank-node `Style` nodes resolve
|
|
321
|
+
* exactly like named ones.
|
|
322
|
+
*/
|
|
323
|
+
/**
|
|
324
|
+
* The marker symbol published for each decoration: `arch-vis:decorSymbol` on
|
|
325
|
+
* the `arch-vis:Decoration` individuals of the core-vis ontology.
|
|
326
|
+
*
|
|
327
|
+
* A renderer draws a decoration from its symbol — anchored and oriented as the
|
|
328
|
+
* vocabulary's description of `arch-vis:decorSymbol` says — and from built-in
|
|
329
|
+
* geometry only where nothing is published. Only the core-vis individuals are
|
|
330
|
+
* read: the decoration names are that vocabulary's.
|
|
331
|
+
*/
|
|
332
|
+
export function buildDecorationSymbols(store: Store): Partial<Record<Decoration, string>> {
|
|
333
|
+
const symbols: Partial<Record<Decoration, string>> = {};
|
|
334
|
+
for (const subject of store.getSubjects(namedNode(RDF_TYPE), namedNode(`${ARCH_VIS}Decoration`), null)) {
|
|
335
|
+
if (subject.termType !== 'NamedNode' || !subject.value.startsWith(ARCH_VIS)) continue;
|
|
336
|
+
const decoration = parseEnum<Decoration>(subject.value, DECORATIONS);
|
|
337
|
+
if (!decoration || decoration === 'NoDecoration') continue;
|
|
338
|
+
const symbol = objectValue(store, subject, `${ARCH_VIS}decorSymbol`);
|
|
339
|
+
if (symbol) symbols[decoration] = symbol;
|
|
340
|
+
}
|
|
341
|
+
return symbols;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function objectValue(store: Store, subject: Term, predicate: string): string | null {
|
|
345
|
+
for (const object of store.getObjects(subject, namedNode(predicate), null)) {
|
|
346
|
+
return object.value;
|
|
347
|
+
}
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** First object value, preferring IRIs over literals (for image/concept links). */
|
|
352
|
+
function iriOrLiteralValue(store: Store, subject: Term, predicate: string): string | null {
|
|
353
|
+
const objects = store.getObjects(subject, namedNode(predicate), null);
|
|
354
|
+
const named = objects.find((object) => object.termType === 'NamedNode');
|
|
355
|
+
if (named) return named.value;
|
|
356
|
+
const literal = objects.find((object) => object.termType === 'Literal');
|
|
357
|
+
return literal ? literal.value : null;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** Reduce an enumeration IRI to its local fragment (`arch-vis:TopRight` → `TopRight`). */
|
|
361
|
+
function parseEnumFragment(iri: string | null): string | undefined {
|
|
362
|
+
if (!iri) return undefined;
|
|
363
|
+
const fragment = iri.includes('#')
|
|
364
|
+
? iri.slice(iri.lastIndexOf('#') + 1)
|
|
365
|
+
: iri.includes('/')
|
|
366
|
+
? iri.slice(iri.lastIndexOf('/') + 1)
|
|
367
|
+
: iri;
|
|
368
|
+
return fragment || undefined;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** Reduce to fragment and keep it only if it is a member of the enumeration. */
|
|
372
|
+
function parseEnum<T extends string>(iri: string | null, allowed: ReadonlySet<string>): T | undefined {
|
|
373
|
+
const fragment = parseEnumFragment(iri);
|
|
374
|
+
if (fragment === undefined) return undefined;
|
|
375
|
+
return allowed.has(fragment) ? (fragment as T) : undefined;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function parseNumber(raw: string | null): number | undefined {
|
|
379
|
+
if (raw === null || raw.trim() === '') return undefined;
|
|
380
|
+
const value = Number.parseFloat(raw);
|
|
381
|
+
return Number.isNaN(value) ? undefined : value;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** Human label: English `skos:prefLabel`, any `skos:prefLabel`, `rdfs:label`, else the IRI fragment. */
|
|
385
|
+
function labelFor(store: Store, iri: string): string {
|
|
386
|
+
const subject = namedNode(iri);
|
|
387
|
+
for (const predicate of [T.prefLabel, T.rdfsLabel]) {
|
|
388
|
+
const literals = store
|
|
389
|
+
.getObjects(subject, namedNode(predicate), null)
|
|
390
|
+
.filter((object) => object.termType === 'Literal');
|
|
391
|
+
const english = literals.find((object) => 'language' in object && object.language === 'en');
|
|
392
|
+
const chosen = english ?? literals[0];
|
|
393
|
+
if (chosen) return chosen.value;
|
|
394
|
+
}
|
|
395
|
+
return parseEnumFragment(iri) ?? iri;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// ---------------------------------------------------------------------------
|
|
399
|
+
// Notation set discovery
|
|
400
|
+
// ---------------------------------------------------------------------------
|
|
401
|
+
|
|
402
|
+
/** All notation sets declared in the graph, sorted by label. */
|
|
403
|
+
export function listNotationSets(store: Store): Array<{ iri: string; label: string }> {
|
|
404
|
+
const iris = new Set<string>();
|
|
405
|
+
for (const subject of store.getSubjects(namedNode(RDF_TYPE), namedNode(T.notationSetClass), null)) {
|
|
406
|
+
if (subject.termType === 'NamedNode') iris.add(subject.value);
|
|
407
|
+
}
|
|
408
|
+
// Sets referenced but not typed locally (e.g. the notation file was not loaded).
|
|
409
|
+
for (const predicate of [T.notationSet, T.usesNotationSet]) {
|
|
410
|
+
for (const quad of store.getQuads(null, namedNode(predicate), null, null)) {
|
|
411
|
+
if (quad.object.termType === 'NamedNode') iris.add(quad.object.value);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return [...iris]
|
|
415
|
+
.map((iri) => ({ iri, label: labelFor(store, iri) }))
|
|
416
|
+
.sort((a, b) => a.label.localeCompare(b.label));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Resolve the notation set a PresentationContext asks for via
|
|
421
|
+
* `arch:usesNotationSet`. Returns `null` when the context declares none —
|
|
422
|
+
* callers then fall back to the metamodel default (see `buildVisualNotations`).
|
|
423
|
+
*/
|
|
424
|
+
export function resolveNotationSetForContext(store: Store, presentationContextIri: string): string | null {
|
|
425
|
+
const objects = store.getObjects(
|
|
426
|
+
namedNode(presentationContextIri),
|
|
427
|
+
namedNode(T.usesNotationSet),
|
|
428
|
+
null,
|
|
429
|
+
);
|
|
430
|
+
const named = objects.find((object) => object.termType === 'NamedNode');
|
|
431
|
+
return named ? named.value : null;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* The namespace of the core's own notation (`core/core-notation.ttl`): the notation of the core's relationship
|
|
436
|
+
* types, which no manifest names — loaded with the core, consulted last, never the set a palette is styled by
|
|
437
|
+
* (VC-DD-5, `coreNotationSetIris`).
|
|
438
|
+
*/
|
|
439
|
+
export const CORE_NOTATION_NS = 'https://meta.linked.archi/core-notation#';
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Default notation set: `arch:notationSet` on an `arch:Metamodel`, then any
|
|
443
|
+
* `arch:notationSet` statement, then any declared `arch-vis:NotationSet` — the
|
|
444
|
+
* core notation's aside, which no language is drawn with.
|
|
445
|
+
*/
|
|
446
|
+
function resolveDefaultNotationSet(store: Store): string | null {
|
|
447
|
+
for (const metamodel of store.getSubjects(namedNode(RDF_TYPE), namedNode(T.metamodel), null)) {
|
|
448
|
+
for (const object of store.getObjects(metamodel, namedNode(T.notationSet), null)) {
|
|
449
|
+
if (object.termType === 'NamedNode') return object.value;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
for (const quad of store.getQuads(null, namedNode(T.notationSet), null, null)) {
|
|
453
|
+
if (quad.object.termType === 'NamedNode') return quad.object.value;
|
|
454
|
+
}
|
|
455
|
+
for (const subject of store.getSubjects(namedNode(RDF_TYPE), namedNode(T.notationSetClass), null)) {
|
|
456
|
+
if (subject.termType === 'NamedNode' && !subject.value.startsWith(CORE_NOTATION_NS)) return subject.value;
|
|
457
|
+
}
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// ---------------------------------------------------------------------------
|
|
462
|
+
// Extraction
|
|
463
|
+
// ---------------------------------------------------------------------------
|
|
464
|
+
|
|
465
|
+
/** What a style says of the look core-vis 0.7 names: font, line width, text placement, gradient, icon colour. */
|
|
466
|
+
function readLook(store: Store, styleTerm: Term): NotationLook {
|
|
467
|
+
const look: Record<string, unknown> = {};
|
|
468
|
+
for (const key of NOTATION_LOOK_KEYS) {
|
|
469
|
+
const object = store.getObjects(styleTerm, namedNode(APPEARANCE_PREDICATES[key]), null)[0];
|
|
470
|
+
const value = object ? appearanceValue(key, object) : undefined;
|
|
471
|
+
if (value !== undefined) look[key] = value;
|
|
472
|
+
}
|
|
473
|
+
return look as NotationLook;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function extractElementStyle(store: Store, styleTerm: Term): VisualStyle | undefined {
|
|
477
|
+
const { shapeType, customShape } = readShape(store, styleTerm);
|
|
478
|
+
const fillColor = objectValue(store, styleTerm, T.fillColor) ?? undefined;
|
|
479
|
+
const lineColor = objectValue(store, styleTerm, T.lineColor) ?? undefined;
|
|
480
|
+
const fontColor = objectValue(store, styleTerm, T.fontColor) ?? undefined;
|
|
481
|
+
const iconSymbol = objectValue(store, styleTerm, T.iconSymbol) ?? undefined;
|
|
482
|
+
const renderingMode = parseEnum<RenderingMode>(
|
|
483
|
+
objectValue(store, styleTerm, T.renderingMode),
|
|
484
|
+
RENDERING_MODES,
|
|
485
|
+
);
|
|
486
|
+
const defaultWidth = parseNumber(objectValue(store, styleTerm, T.defaultWidth));
|
|
487
|
+
const defaultHeight = parseNumber(objectValue(store, styleTerm, T.defaultHeight));
|
|
488
|
+
const borderStyle = parseEnum<LineStyle>(objectValue(store, styleTerm, T.borderStyle), LINE_STYLES);
|
|
489
|
+
|
|
490
|
+
const declaredPlacement = parseEnum<IconPlacement>(
|
|
491
|
+
objectValue(store, styleTerm, T.iconPlacement),
|
|
492
|
+
ICON_PLACEMENTS,
|
|
493
|
+
);
|
|
494
|
+
// Fallback rule: iconPlacement absent but iconSymbol present → TopRight.
|
|
495
|
+
const iconPlacement = declaredPlacement ?? (iconSymbol ? 'TopRight' : undefined);
|
|
496
|
+
const look = readLook(store, styleTerm);
|
|
497
|
+
|
|
498
|
+
const hasAny =
|
|
499
|
+
shapeType !== undefined ||
|
|
500
|
+
fillColor !== undefined ||
|
|
501
|
+
lineColor !== undefined ||
|
|
502
|
+
iconSymbol !== undefined ||
|
|
503
|
+
renderingMode !== undefined ||
|
|
504
|
+
defaultWidth !== undefined ||
|
|
505
|
+
defaultHeight !== undefined ||
|
|
506
|
+
borderStyle !== undefined ||
|
|
507
|
+
fontColor !== undefined ||
|
|
508
|
+
customShape !== undefined ||
|
|
509
|
+
Object.keys(look).length > 0;
|
|
510
|
+
if (!hasAny) return undefined;
|
|
511
|
+
|
|
512
|
+
const style: VisualStyle = { shapeType, fillColor, lineColor, iconSymbol, iconPlacement, renderingMode, defaultWidth, defaultHeight };
|
|
513
|
+
if (customShape) style.customShape = customShape;
|
|
514
|
+
if (borderStyle) style.borderStyle = borderStyle;
|
|
515
|
+
if (fontColor) style.fontColor = fontColor;
|
|
516
|
+
Object.assign(style, look);
|
|
517
|
+
return style;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function extractRelationshipStyle(store: Store, subject: Term): RelationshipVisualStyle | undefined {
|
|
521
|
+
const lineStyle = parseEnum<LineStyle>(objectValue(store, subject, T.lineStyle), LINE_STYLES);
|
|
522
|
+
const sourceDecor = parseEnum<Decoration>(objectValue(store, subject, T.sourceDecor), DECORATIONS);
|
|
523
|
+
const targetDecor = parseEnum<Decoration>(objectValue(store, subject, T.targetDecor), DECORATIONS);
|
|
524
|
+
const nestedEnds = store
|
|
525
|
+
.getObjects(subject, namedNode(T.nestedEnd), null)
|
|
526
|
+
.map((end) => (end.value === `${ARCH_VIS}SourceEnd` ? 'source' : end.value === `${ARCH_VIS}TargetEnd` ? 'target' : undefined))
|
|
527
|
+
.filter((end): end is 'source' | 'target' => end !== undefined)
|
|
528
|
+
.sort();
|
|
529
|
+
const { lineWidth, fontName, fontSize, fontStyle } = readLook(store, subject);
|
|
530
|
+
const fontColor = objectValue(store, subject, T.fontColor) ?? undefined;
|
|
531
|
+
const anchor = objectValue(store, subject, T.labelAnchor);
|
|
532
|
+
const labelAnchor: RelationshipVisualStyle['labelAnchor'] =
|
|
533
|
+
anchor === `${ARCH_VIS}AnchorSource` ? 'source' : anchor === `${ARCH_VIS}AnchorMiddle` ? 'middle' : anchor === `${ARCH_VIS}AnchorTarget` ? 'target' : undefined;
|
|
534
|
+
const look = {
|
|
535
|
+
...(lineWidth !== undefined ? { lineWidth } : {}),
|
|
536
|
+
...(fontName !== undefined ? { fontName } : {}),
|
|
537
|
+
...(fontSize !== undefined ? { fontSize } : {}),
|
|
538
|
+
...(fontStyle !== undefined ? { fontStyle } : {}),
|
|
539
|
+
...(fontColor !== undefined ? { fontColor } : {}),
|
|
540
|
+
...(labelAnchor !== undefined ? { labelAnchor } : {}),
|
|
541
|
+
};
|
|
542
|
+
if (lineStyle === undefined && sourceDecor === undefined && targetDecor === undefined && nestedEnds.length === 0 && Object.keys(look).length === 0) {
|
|
543
|
+
return undefined;
|
|
544
|
+
}
|
|
545
|
+
const lineColor = objectValue(store, subject, T.lineColor) ?? undefined;
|
|
546
|
+
return { lineStyle, sourceDecor, targetDecor, lineColor, ...look, ...(nestedEnds.length > 0 ? { nestedEnds } : {}) };
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Build the notation set with the given IRI (or the graph default when omitted).
|
|
551
|
+
*
|
|
552
|
+
* Relationship properties (`lineStyle`, `sourceDecor`, `targetDecor`) are read
|
|
553
|
+
* from the `VisualNotation` node itself as well as from its `defaultStyle`,
|
|
554
|
+
* because published notation files put them directly on the notation.
|
|
555
|
+
*
|
|
556
|
+
* Returns `null` when no notation set can be resolved or the resolved set has
|
|
557
|
+
* no `VisualNotation` members.
|
|
558
|
+
*/
|
|
559
|
+
export function buildVisualNotations(store: Store, notationSetIri?: string): NotationSet | null {
|
|
560
|
+
const setIri = notationSetIri ?? resolveDefaultNotationSet(store);
|
|
561
|
+
if (!setIri) return null;
|
|
562
|
+
|
|
563
|
+
const notations = new Map<string, VisualNotation>();
|
|
564
|
+
|
|
565
|
+
for (const quad of store.getQuads(null, namedNode(T.inNotationSet), namedNode(setIri), null)) {
|
|
566
|
+
const notationTerm = quad.subject;
|
|
567
|
+
if (notationTerm.termType !== 'NamedNode') continue;
|
|
568
|
+
|
|
569
|
+
const conceptIri = iriOrLiteralValue(store, notationTerm, T.notationFor);
|
|
570
|
+
if (!conceptIri) continue;
|
|
571
|
+
|
|
572
|
+
const prefVisNotation = iriOrLiteralValue(store, notationTerm, T.prefVisNotation) ?? undefined;
|
|
573
|
+
|
|
574
|
+
let style: VisualStyle | undefined;
|
|
575
|
+
let relationshipStyle = extractRelationshipStyle(store, notationTerm);
|
|
576
|
+
|
|
577
|
+
for (const styleTerm of store.getObjects(notationTerm, namedNode(T.defaultStyle), null)) {
|
|
578
|
+
style = extractElementStyle(store, styleTerm) ?? style;
|
|
579
|
+
relationshipStyle = extractRelationshipStyle(store, styleTerm) ?? relationshipStyle;
|
|
580
|
+
}
|
|
581
|
+
// Its other figures, in the order the notation gives them.
|
|
582
|
+
const alternatives = store
|
|
583
|
+
.getObjects(notationTerm, namedNode(T.alternativeStyle), null)
|
|
584
|
+
.map((term) => extractElementStyle(store, term))
|
|
585
|
+
.filter((alternative): alternative is VisualStyle => alternative !== undefined);
|
|
586
|
+
if (style && alternatives.length > 0) style = { ...style, alternatives };
|
|
587
|
+
// What its label says: the notation's own, and its default style's.
|
|
588
|
+
const labelExpressions = [
|
|
589
|
+
...labelExpressionsOf(store, notationTerm),
|
|
590
|
+
...store.getObjects(notationTerm, namedNode(T.defaultStyle), null).flatMap((term) => labelExpressionsOf(store, term)),
|
|
591
|
+
];
|
|
592
|
+
if (labelExpressions.length > 0) style = { ...(style ?? {}), labelExpressions };
|
|
593
|
+
|
|
594
|
+
notations.set(conceptIri, {
|
|
595
|
+
conceptIri,
|
|
596
|
+
notationSetIri: setIri,
|
|
597
|
+
prefVisNotation,
|
|
598
|
+
style,
|
|
599
|
+
relationshipStyle,
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
if (notations.size === 0) return null;
|
|
604
|
+
|
|
605
|
+
return { iri: setIri, label: labelFor(store, setIri), notations };
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/** The label expressions `subject` gives (`arch-vis:labelExpression`), each with the presentation context it is for. */
|
|
609
|
+
export function labelExpressionsOf(store: Store, subject: Term): LabelExpression[] {
|
|
610
|
+
const found: LabelExpression[] = [];
|
|
611
|
+
for (const label of store.getObjects(subject, namedNode(T.labelExpression), null)) {
|
|
612
|
+
const expression = objectValue(store, label, T.expression);
|
|
613
|
+
if (expression === null) continue;
|
|
614
|
+
const context = objectValue(store, label, T.inPresentationContext);
|
|
615
|
+
found.push({ expression, ...(context !== null ? { context } : {}) });
|
|
616
|
+
}
|
|
617
|
+
return found;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Of the label expressions a place gives, the one that applies in
|
|
622
|
+
* `context`: the one for it, else one for every context.
|
|
623
|
+
*/
|
|
624
|
+
export function labelExpressionIn(expressions: readonly LabelExpression[] | undefined, context: string | undefined): string | undefined {
|
|
625
|
+
if (!expressions) return undefined;
|
|
626
|
+
return (
|
|
627
|
+
(context ? expressions.find((e) => e.context === context)?.expression : undefined) ??
|
|
628
|
+
expressions.find((e) => e.context === undefined)?.expression
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/** A presentation context's name, as a palette shows it. */
|
|
633
|
+
export function presentationContextLabel(store: Store, contextIri: string): string {
|
|
634
|
+
return labelFor(store, contextIri);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* The rendering mode a tool should actually use, after the guide's fallbacks:
|
|
639
|
+
*
|
|
640
|
+
* - `renderingMode` absent → `ShapeWithBadge`
|
|
641
|
+
* - `ShapeWithBadge` without `iconSymbol` → `ShapeOnly` (graceful degradation)
|
|
642
|
+
* - `IconCentric` without `iconSymbol` → warn, `ShapeOnly`
|
|
643
|
+
*
|
|
644
|
+
* This is the single place that decision is made.
|
|
645
|
+
*/
|
|
646
|
+
export function effectiveRenderingMode(style: VisualStyle | undefined): RenderingMode {
|
|
647
|
+
const declared = style?.renderingMode ?? 'ShapeWithBadge';
|
|
648
|
+
const hasIcon = Boolean(style?.iconSymbol);
|
|
649
|
+
|
|
650
|
+
if (declared === 'ShapeOnly') return 'ShapeOnly';
|
|
651
|
+
|
|
652
|
+
if (declared === 'IconCentric') {
|
|
653
|
+
if (hasIcon) return 'IconCentric';
|
|
654
|
+
console.warn('[notation] IconCentric rendering requires arch-vis:iconSymbol — falling back to ShapeOnly');
|
|
655
|
+
return 'ShapeOnly';
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return hasIcon ? 'ShapeWithBadge' : 'ShapeOnly';
|
|
659
|
+
}
|