# Shapes for a work's meta.ttl: what it must say, so that any app can find and list works it didn't make. A shape
# checks the description, not the content: whether an .sb3 file is valid is a question for Scratch.
#
# A description says which shape it meets with dcterms:conformsTo, and a reader checks it against that shape, so the
# shapes have no targets of their own. That one triple is also what marks a container as a work, and its version is in
# the shape's address: a format that isn't compatible gets a new file, v2.ttl.
#
# What kind of work it is isn't Solid Accord's to list. The app says it with schema.org's types and properties, pointing
# at shared concepts such as Wikidata's, so the shape doesn't constrain it.
#
# The shapes are open, never sh:closed, so that an app can add its own data to a work without making it invalid.
#
# A work has exactly one title, in any language or none. Titles in other languages, if they're ever wanted, would be a
# separate idea, such as alternative titles, rather than more than one schema:name.
#
# The address is for now: before v1, it may change, and work saved with it may not keep working. A lasting one is
# chosen for v1. GitHub Pages serves the file only at an address that ends in .ttl.

@base <https://solid-accord.viboko.dev/ns/shapes/work/v1.ttl> .

@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema:  <https://schema.org/> .
@prefix sh:      <http://www.w3.org/ns/shacl#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .

<#WorkV1>
    a sh:NodeShape ;
    sh:name "WorkV1" ;
    rdfs:comment "Format 1 of a work's description, meta.ttl, which describes the container the work is in: it conforms to this shape, and has exactly one title, in any language or none, at least one content file and exactly one last change."@en ;
    sh:nodeKind sh:IRI ;
    sh:message "A work is the container it's in, named by its IRI."@en ;
    sh:property <#conformsTo> , <#name> , <#encoding> , <#dateModified> .

<#conformsTo>
    a sh:PropertyShape ;
    sh:path dcterms:conformsTo ;
    sh:hasValue <#WorkV1> ;
    sh:message "A work in format 1 says so, with dcterms:conformsTo and this shape's IRI."@en .

<#name>
    a sh:PropertyShape ;
    sh:path schema:name ;
    sh:or ( [ sh:datatype xsd:string ] [ sh:datatype rdf:langString ] ) ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:message "A work has one title, a string, in any language or none."@en .

<#encoding>
    a sh:PropertyShape ;
    sh:path schema:encoding ;
    sh:nodeKind sh:IRI ;
    sh:minCount 1 ;
    sh:message "A work names at least one content file, each by its IRI."@en .

<#dateModified>
    a sh:PropertyShape ;
    sh:path schema:dateModified ;
    sh:datatype xsd:dateTime ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:message "A work has one last change, an xsd:dateTime."@en .
