@prefix convo: <https://ontology.inferal.com/modules/conversation/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix prof: <http://www.w3.org/ns/dx/prof/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix role: <http://www.w3.org/ns/dx/prof/role/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

convo:AddressedMessageProfile
    a prof:Profile ;
    prof:isProfileOf convo: ;
    prof:hasResource <https://ontology.inferal.com/modules/conversation/profiles/addressed-message#constraints> .

<https://ontology.inferal.com/modules/conversation/profiles/addressed-message#constraints>
    a prof:ResourceDescriptor ;
    rdfs:label "Addressed Message constraints descriptor"@en ;
    rdfs:comment "Describes the SHACL artifact that validates addressing, transmission, and delivery data."@en ;
    prof:hasArtifact <https://ontology.inferal.com/modules/conversation/profiles/addressed-message.ttl> ;
    prof:hasRole role:constraints, role:validation ;
    dcterms:conformsTo <http://www.w3.org/ns/shacl#> ;
    dcterms:format <https://www.iana.org/assignments/media-types/text/turtle> .

convo:AddressingShape
    a sh:NodeShape ;
    rdfs:label "addressing shape"@en ;
    rdfs:comment "Requires a qualified addressing to identify one message, an addressee, and an addressing role while accepting either inverse direction."@en ;
    sh:targetClass convo:Addressing ;
    sh:property [
        sh:path [ sh:alternativePath ( convo:addressingOf [ sh:inversePath convo:hasAddressing ] ) ] ;
        sh:class convo:Message ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
    ] ;
    sh:property [ sh:path convo:addressee ; sh:minCount 1 ; sh:maxCount 1 ] ;
    sh:property [ sh:path convo:hasAddressingRole ; sh:class convo:AddressingRole ; sh:minCount 1 ; sh:maxCount 1 ] .

convo:MessageTransmissionShape
    a sh:NodeShape ;
    rdfs:label "message transmission shape"@en ;
    rdfs:comment "Requires a transmission to identify exactly one message and one sender represented as either a PROV agent or an account."@en ;
    sh:targetClass convo:MessageTransmission ;
    sh:property [ sh:path convo:transmitsContribution ; sh:class convo:Message ; sh:minCount 1 ; sh:maxCount 1 ] ;
    sh:property [
        sh:path convo:transmissionSender ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
        sh:or ( [ sh:class prov:Agent ] [ sh:class convo:Account ] ) ;
    ] .

convo:DeliveryShape
    a sh:NodeShape ;
    rdfs:label "delivery shape"@en ;
    rdfs:comment "Requires each delivery to identify one transmission and one recipient or destination while accepting either inverse direction."@en ;
    sh:targetClass convo:Delivery ;
    sh:property [
        sh:path [ sh:alternativePath ( convo:deliveryOf [ sh:inversePath convo:hasDelivery ] ) ] ;
        sh:class convo:MessageTransmission ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
    ] ;
    sh:property [ sh:path convo:deliveryRecipient ; sh:minCount 1 ; sh:maxCount 1 ] .
