@prefix : <https://ontology.inferal.com/mappings/relay-mailchimp-type-system/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix ts: <https://ontology.inferal.com/modules/type-system/> .

:ProjectedRecordShape
    a sh:NodeShape ;
    rdfs:label "projected record shape" ;
    rdfs:comment "Validates the source trace and generated namespace of each record type emitted by this projection." ;
    sh:targetClass ts:RecordType ;
    sh:nodeKind sh:IRI ;
    sh:pattern "^https://ontology\\.inferal\\.com/mappings/relay-mailchimp-type-system/generated/record/" ;
    sh:property [
        sh:path prov:wasDerivedFrom ;
        sh:nodeKind sh:IRI ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
    ] ;
    sh:property [
        sh:path ts:hasField ;
        sh:class ts:Field ;
        sh:minCount 1 ;
    ] .

:ProjectedFieldShape
    a sh:NodeShape ;
    rdfs:label "projected field shape" ;
    rdfs:comment "Validates generated fields, including their scalar-or-array type and explicit optionality." ;
    sh:targetClass ts:Field ;
    sh:property [
        sh:path ts:fieldType ;
        sh:class ts:Type ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
    ] ;
    sh:property [
        sh:path ts:isOptional ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
    ] .

:ProjectedArrayExpressionShape
    a sh:NodeShape ;
    rdfs:label "projected array expression shape" ;
    rdfs:comment "Requires every generated array expression to be used by a field and to identify exactly one element type." ;
    sh:targetClass ts:ArrayExpression ;
    sh:property [
        sh:path ts:arrayValueType ;
        sh:class ts:Type ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
    ] ;
    sh:property [
        sh:path [ sh:inversePath ts:fieldType ] ;
        sh:class ts:Field ;
        sh:minCount 1 ;
    ] .
