|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
(ns org.domaindrivenarchitecture.activity-pub-poc.activitystreams2
|
|
|
|
|
(:require [clojure.spec.alpha :as s]
|
|
|
|
|
[orchestra.core :refer [defn-spec]]
|
|
|
|
|
[org.domaindrivenarchitecture.activity-pub-poc.spec-helper :as sh]
|
|
|
|
|
[org.domaindrivenarchitecture.activity-pub-poc.owl :as owl]
|
|
|
|
|
[org.domaindrivenarchitecture.activity-pub-poc.xsd :as xsd]))
|
|
|
|
|
|
|
|
|
@ -10,16 +11,6 @@
|
|
|
|
|
[spec keyword?]
|
|
|
|
|
(some #(clojure.string/includes? % "FunctionalProperty") (s/describe spec)))
|
|
|
|
|
|
|
|
|
|
(defn-spec map-class-spec s/spec?
|
|
|
|
|
"Spec which checks whether a value is a ::Class
|
|
|
|
|
and if it is a map, if it validates the given map-spec."
|
|
|
|
|
[map-spec s/spec?]
|
|
|
|
|
(s/and
|
|
|
|
|
::Class
|
|
|
|
|
(s/or
|
|
|
|
|
:no-map #(not (map? %))
|
|
|
|
|
:map map-spec)))
|
|
|
|
|
|
|
|
|
|
;=======================
|
|
|
|
|
|
|
|
|
|
;TODO: There is no as:Class! Why do we need this?
|
|
|
|
@ -33,47 +24,46 @@
|
|
|
|
|
;http://www.w3.org/ns/activitystreams#object
|
|
|
|
|
(s/def ::Object
|
|
|
|
|
(s/and
|
|
|
|
|
::Class
|
|
|
|
|
(s/keys :opt-un [::id ::type ::attachment])))
|
|
|
|
|
::owl/Class
|
|
|
|
|
(sh/map-spec (s/keys :opt-un [::id ::type ::attachment]))))
|
|
|
|
|
|
|
|
|
|
;http://www.w3.org/ns/activitystreams#Link
|
|
|
|
|
(s/def ::Link
|
|
|
|
|
(s/and
|
|
|
|
|
::Class
|
|
|
|
|
(s/keys :opt-un [::id ::type])))
|
|
|
|
|
::owl/Class
|
|
|
|
|
(sh/map-spec (s/keys :opt-un [::id ::type]))))
|
|
|
|
|
|
|
|
|
|
;http://www.w3.org/ns/activitystreams#Activity
|
|
|
|
|
;TODO: Define more properties necessary for Like
|
|
|
|
|
(s/def ::Activity
|
|
|
|
|
(s/and
|
|
|
|
|
::Class
|
|
|
|
|
::owl/Class
|
|
|
|
|
::Object
|
|
|
|
|
(s/keys :opt-un [::result ::object])))
|
|
|
|
|
(sh/map-spec (s/keys :opt-un [::result ::object]))))
|
|
|
|
|
|
|
|
|
|
;http://www.w3.org/ns/activitystreams#Relationship
|
|
|
|
|
;We only have this class, since the property "object" is in the domain "Activity" and "Relationship"
|
|
|
|
|
; TODO: What means: "as:Relationship a rdf:Statement". Relevant for spec?
|
|
|
|
|
(s/def ::Relationship
|
|
|
|
|
(s/and
|
|
|
|
|
::Class
|
|
|
|
|
::owl/Class
|
|
|
|
|
::Object
|
|
|
|
|
(s/keys :opt-un [::object])))
|
|
|
|
|
(sh/map-spec (s/keys :opt-un [::object]))))
|
|
|
|
|
|
|
|
|
|
;http://www.w3.org/ns/activitystreams#Like
|
|
|
|
|
(s/def ::Like
|
|
|
|
|
(s/and
|
|
|
|
|
::Class
|
|
|
|
|
::owl/Class
|
|
|
|
|
::Activity))
|
|
|
|
|
|
|
|
|
|
;http://www.w3.org/ns/activitystreams#attachment
|
|
|
|
|
; TODO: Why do we need to model this? Is this necessary for a Like-Activity?
|
|
|
|
|
(s/def ::attachment
|
|
|
|
|
(s/and
|
|
|
|
|
::owl/Class
|
|
|
|
|
::owl/ObjectProperty
|
|
|
|
|
(map-class-spec
|
|
|
|
|
(s/or
|
|
|
|
|
:object ::Object
|
|
|
|
|
:link ::Link))))
|
|
|
|
|
::Object
|
|
|
|
|
::Link))
|
|
|
|
|
|
|
|
|
|
;http://www.w3.org/ns/activitystreams#id
|
|
|
|
|
(s/def ::id
|
|
|
|
@ -92,38 +82,29 @@
|
|
|
|
|
;http://www.w3.org/ns/activitystreams#result
|
|
|
|
|
(s/def ::result
|
|
|
|
|
(s/and
|
|
|
|
|
::owl/Class
|
|
|
|
|
::owl/ObjectProperty
|
|
|
|
|
(map-class-spec
|
|
|
|
|
(s/or :object ::Object
|
|
|
|
|
:link ::Link))))
|
|
|
|
|
::Object
|
|
|
|
|
::Link))
|
|
|
|
|
|
|
|
|
|
;http://www.w3.org/ns/activitystreams#object
|
|
|
|
|
(s/def ::object
|
|
|
|
|
(s/and
|
|
|
|
|
::owl/Class
|
|
|
|
|
::owl/ObjectProperty
|
|
|
|
|
(map-class-spec
|
|
|
|
|
(s/or
|
|
|
|
|
:object ::Object
|
|
|
|
|
:link ::Link))))
|
|
|
|
|
::Object
|
|
|
|
|
::Link))
|
|
|
|
|
|
|
|
|
|
;http://www.w3.org/ns/activitystreams#object
|
|
|
|
|
(defmulti object-type map?)
|
|
|
|
|
(defmethod object-type true [_]
|
|
|
|
|
(s/and ::Class
|
|
|
|
|
(s/keys :opt-un [::id])))
|
|
|
|
|
(defmethod object-type false [_]
|
|
|
|
|
(s/and ::Class))
|
|
|
|
|
(s/def ::Object object-type)
|
|
|
|
|
(s/def ::Object
|
|
|
|
|
(s/and ::owl/Class
|
|
|
|
|
(sh/map-spec (s/keys :opt-un [::id]))))
|
|
|
|
|
|
|
|
|
|
;http://www.w3.org/ns/activitystreams#Link
|
|
|
|
|
;TODO: definition in progress
|
|
|
|
|
(defmulti link-type map?)
|
|
|
|
|
(defmethod link-type true [_]
|
|
|
|
|
(s/and ::Class
|
|
|
|
|
(s/keys :opt-un [::id])))
|
|
|
|
|
(defmethod link-type false [_]
|
|
|
|
|
(s/and ::Class))
|
|
|
|
|
(s/def ::Link link-type)
|
|
|
|
|
(s/def ::Link
|
|
|
|
|
(s/and ::owl/Class
|
|
|
|
|
(sh/map-spec (s/keys :opt-un [::id]))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|