diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 093e800..4d85c19 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -17,14 +17,6 @@ ::owl/DeprecatedProperty ::xsd/anyURI)) -;http://www.w3.org/ns/activitystreams#attachment -(s/def ::attachment - (s/and - ::owl/ObjectProperty - ::Class - ::Link - ::Object)) - ;http://www.w3.org/ns/activitystreams#result (s/def ::result (s/and @@ -33,26 +25,48 @@ ::Object ::Link)) +;http://www.w3.org/ns/activitystreams#attachment +(s/def ::attachment + (s/and + ::owl/ObjectProperty + ::Class + ::Link + ::Object)) + +;http://www.w3.org/ns/activitystreams#Relationship +;TODO: definition in progress +(s/def ::Relationship + (s/and (s/keys :opt-un [::object]))) + ;http://www.w3.org/ns/activitystreams#Activity ;TODO: definition in progress (s/def ::Activity (s/and ::Object - (s/keys :opt-un [::result]))) + (s/keys :opt-un [::result + ::object]))) -;http://www.w3.org/ns/activitystreams#Object -;TODO: definition in progress -(s/def ::Object (s/keys :opt-un [::id ::attachment])) +;http://www.w3.org/ns/activitystreams#object +(s/def ::object + (s/and + ::owl/ObjectProperty + ::Class + (s/or ::Object + ::Link))) +;http://www.w3.org/ns/activitystreams#object +(s/def ::Object + (s/keys :opt-un [::id ::Class])) ;http://www.w3.org/ns/activitystreams#Link ;TODO: definition in progress (s/def ::Link (s/keys :opt-un [::id])) ;TODO: There is no as:Class! Why do we need this? +;Answer jem: I do not want to enhance owl/Class inline from here. (s/def ::Class (s/merge ::owl/Class - (s/keys :opt-un [::id]))) + (s/keys :opt-un [::id ::object]))) ;http://www.w3.org/ns/activitystreams#Like diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj index c9109ac..72a6d86 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj @@ -14,16 +14,27 @@ (is (not (s/valid? ::sut/id nil))) (is (not (s/valid? ::sut/id 2))) (is (not (s/valid? ::sut/id "no-uri"))) - (is (not (s/valid? ::sut/id ["https://social.bla/alyssa/status/RANDOMHASH", "https://social.bla/alyssa/status/RANDOMHASH2"]))) - ) + (is (not (s/valid? ::sut/id ["https://social.bla/alyssa/status/RANDOMHASH", "https://social.bla/alyssa/status/RANDOMHASH2"])))) + +;TODO: where does the ability for a link reference come from ? +(deftest object-test + (is (s/valid? ::sut/object "http://example.org/posts/1")) + (is (s/valid? ::sut/object {:type "Note", + :content "A simple note"})) + (is (s/valid? ::sut/object ["http://example.org/posts/1", + {:type "Note", + :summary "A simple note", + :content "That is a tree."}]))) + +(deftest class-test + (is (s/valid? ::sut/Class "https://social.bla/alyssa/status/RANDOMHASH"))) (deftest result-test (is (s/valid? ::sut/result "https://social.bla/alyssa/result/RANDOMHASH")) (is (s/valid? ::sut/result {:type "http://www.types.example/flightstatus", :name "On Time"})) (is (s/valid? ::sut/result {:type "Link" :href "http://www.target.de"})) (is (not (s/valid? ::sut/result nil))) - (is (not (s/valid? ::sut/result 47))) -) + (is (not (s/valid? ::sut/result 47)))) ;(deftest attachment-test