001  (ns dog-and-duck.quack.picky.constants
002    "Constants supporting the picky validator.")
003  
004  ;;;     Copyright (C) Simon Brooke, 2022
005  
006  ;;;     This program is free software; you can redistribute it and/or
007  ;;;     modify it under the terms of the GNU General Public License
008  ;;;     as published by the Free Software Foundation; either version 2
009  ;;;     of the License, or (at your option) any later version.
010  
011  ;;;     This program is distributed in the hope that it will be useful,
012  ;;;     but WITHOUT ANY WARRANTY; without even the implied warranty of
013  ;;;     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014  ;;;     GNU General Public License for more details.
015  
016  ;;;     You should have received a copy of the GNU General Public License
017  ;;;     along with this program; if not, write to the Free Software
018  ;;;     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019  
020  (def ^:const activitystreams-context-uri
021    "The URI of the context of an ActivityStreams object is expected to be this
022     literal string.
023     
024     **NOTE THAT** the URI actually used in the published suite of 
025     activitystreams-test-documents use this URI with 'http' rather than
026     'https' as the property part, but the spec itself specifies 'https'."
027    "https://www.w3.org/ns/activitystreams")
028  
029  (def ^:const actor-types
030    "The set of types we will accept as actors.
031     
032     There's an [explicit set of allowed actor types]
033     (https://www.w3.org/TR/activitystreams-vocabulary/#actor-types)."
034    #{"Application"
035      "Group"
036      "Organization"
037      "Person"
038      "Service"})
039  
040  (def ^:const context-key
041    "The Clojure reader barfs on `:@context`, although it is in principle a valid 
042     keyword. So we'll make it once, here, to make the code more performant and
043     easier to read."
044    (keyword "@context"))
045  
046  (def ^:const re-rfc5646 
047    "A regex which tests conformity to RFC 5646. Cribbed from
048     https://newbedev.com/regex-to-detect-locales"
049    #"^[a-z]{2,4}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$")
050  
051  (def ^:const severity
052    "Severity of faults found, as follows:
053     
054     0. `:info` not actually a fault, but an issue noted during validation;
055     1. `:minor` things which I consider to be faults, but which 
056        don't actually breach the spec;
057     2. `:should` instances where the spec says something SHOULD
058        be done, which isn't;
059     3. `:must` instances where the spec says something MUST
060        be done, which isn't;
061     4. `:critical` instances where I believe the fault means that
062        the object cannot be meaningfully processed."
063    #{:info :minor :should :must :critical})
064  
065  (def ^:const severity-filters
066    "Hack for implementing a severity hierarchy"
067    {:all #{}
068     :info #{}
069     :minor #{:info}
070     :should #{:info :minor}
071     :must #{:info :minor :should}
072     :critical #{:info :minor :should :must}})
073  
074  (def ^:const validation-fault-context-uri
075    "The URI of the context of a validation fault report object shall be this
076     literal string."
077    "https://simon-brooke.github.io/dog-and-duck/codox/Validation_Faults.html")
078  
079  (def ^:const activity-types
080    "The set of types we will accept as activities.
081     
082     There's an [explicit set of allowed activity types]
083     (https://www.w3.org/TR/activitystreams-vocabulary/#activity-types)."
084    #{"Accept" "Add" "Announce" "Arrive" "Block" "Create" "Delete" "Dislike"
085      "Flag" "Follow" "Ignore" "Invite" "Join" "Leave" "Like" "Listen" "Move"
086      "Offer" "Question" "Reject" "Read" "Remove" "TentativeAccept"
087      "TentativeReject" "Travel" "Undo" "Update" "View"})
088  
089  (def ^:const noun-types
090    "The set of object types we will accept as nouns.
091     
092     There's an [explicit set of allowed 'object types']
093     (https://www.w3.org/TR/activitystreams-vocabulary/#object-types), but by 
094     implication it is not exhaustive."
095    #{"Article" 
096      "Audio" 
097      "Document"
098      "Event"
099      "Image"
100      "Link"
101      "Mention"
102      "Note"
103      "Object"
104      "Page"
105      "Place"
106      "Profile"
107      "Relationsip"
108      "Tombstone"
109      "Video"})
110  
111  (def ^:const implicit-noun-types
112    "These types are not explicitly listed in [Section 3.3 of the spec]
113     (https://www.w3.org/TR/activitystreams-vocabulary/#object-types), but are 
114     mentioned in narrative"
115    #{"Link"})
116