@prefix nd: <https://ontology.inferal.com/modules/ads-native-projection-diagnostics/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
nd:RequestShape a sh:NodeShape; sh:targetClass nd:DiagnosticRequest;
 sh:nodeKind sh:IRI;
 sh:property [ sh:path nd:owner; sh:minCount 1; sh:maxCount 1; sh:nodeKind sh:IRI ];
 sh:property [ sh:path nd:account; sh:minCount 1; sh:maxCount 1; sh:nodeKind sh:IRI ];
 sh:property [ sh:path nd:provider; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string; sh:in ("meta" "googleads" "microsoftads") ];
 sh:property [ sh:path nd:family; sh:minCount 1; sh:maxCount 1; sh:in (nd:MetaCreative nd:MetaBreakdown nd:GoogleCurrency nd:MetaTimezone nd:MetaBidUnit) ];
 sh:property [ sh:path nd:wirePath; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string; sh:minLength 1 ];
 sh:property [ sh:path nd:affectedQuestion; sh:minCount 1; sh:maxCount 1; sh:nodeKind sh:IRI ];
 sh:property [ sh:path nd:affectedContract; sh:minCount 1; sh:maxCount 1; sh:nodeKind sh:IRI ]  ;
 sh:sparql [ sh:message "Provider, selected diagnostic family, wire path and question contract must agree."; sh:select """
 PREFIX nd: <https://ontology.inferal.com/modules/ads-native-projection-diagnostics/>
 SELECT $this WHERE { $this nd:provider ?provider; nd:family ?family; nd:wirePath ?wire; nd:affectedQuestion ?question; nd:affectedContract ?contract .
 FILTER(!((?provider="googleads" && ?family=nd:GoogleCurrency && ?wire="Customer.currency_code" && ?question=<https://ontology.inferal.com/questions/advertising-commerce/native-projection-diagnostics-v1> && ?contract=<https://ontology.inferal.com/modules/ads-native-projection-diagnostics/contractV1>) || (?provider="googleads" && ?family=nd:GoogleCurrency && ?wire="Customer.currency_code" && ?question=<https://ontology.inferal.com/questions/advertising-commerce/performance-observations> && ?contract=<https://ontology.inferal.com/profiles/advertising-questions/performance-observations/contracts/v1>) || (?provider="meta" && ?family=nd:MetaBidUnit && ?wire="AdSet.bid_amount" && ?question=<https://ontology.inferal.com/questions/advertising-commerce/native-projection-diagnostics-v1> && ?contract=<https://ontology.inferal.com/modules/ads-native-projection-diagnostics/contractV1>) || (?provider="meta" && ?family=nd:MetaBreakdown && ?wire="AdsInsights.app_id" && ?question=<https://ontology.inferal.com/questions/advertising-commerce/performance-observations> && ?contract=<https://ontology.inferal.com/profiles/advertising-questions/performance-observations/contracts/v1>) || (?provider="meta" && ?family=nd:MetaCreative && ?wire="Ad.creative" && ?question=<https://ontology.inferal.com/questions/advertising-commerce/resource-hierarchy> && ?contract=<https://ontology.inferal.com/profiles/advertising-questions/resource-hierarchy/contracts/v1>) || (?provider="meta" && ?family=nd:MetaTimezone && ?wire="AdAccount.timezone_name" && ?question=<https://ontology.inferal.com/questions/advertising-commerce/performance-observations> && ?contract=<https://ontology.inferal.com/profiles/advertising-questions/performance-observations/contracts/v1>)))
 } """ ] .
