Compare commits

...

2 Enmetoj

Author SHA1 Message Date
Jaidyn Ann cc81dee054 Remove ActivityStreams package; reorganize tests
The ActivityStreams package solely held the Object
JSON-type, which is now in the ActivityVocabulary
package.

Files and system definitions have been shuffled
around accordingly.
2024-08-21 23:37:11 -05:00
Jaidyn Ann c1e1da9a3b Redefine ActivityVocab. types to new JSON-LD lib
This is much cleaner. Compared to previous
version, we also add docstrings »ploinked« from
the ActivityVocabulary specification.
2024-08-21 23:19:25 -05:00
65 changed files with 371 additions and 252 deletions

View File

@ -15,16 +15,15 @@
:components ((:file "src/activity-servist")))
(asdf:defsystem "activity-servist/activity-streams"
(asdf:defsystem "activity-servist/activity-vocabulary"
:version "0.0"
:license "AGPLv3"
:description "A-S subpackage for handling ActivityStreams parsing/encoding."
:description "A-S subpackage containing ActivityVocabulary class-definitions."
:author "Jaidyn Ann <jadedctrl@posteo.at>"
:homepage "https://hak.xwx.moe/jadedctrl/activity-servist"
:depends-on ("alexandria" "closer-mop" "str" "yason")
:components ((:file "src/activity-streams")
(:file "src/activity-vocabulary")))
:depends-on ("activity-servist/json-ld")
:components ((:file "src/activity-vocabulary")))
(asdf:defsystem "activity-servist/json-ld"
@ -34,7 +33,7 @@
:author "Jaidyn Ann <jadedctrl@posteo.at>"
:homepage "https://hak.xwx.moe/jadedctrl/activity-servist"
:depends-on ("alexandria" "closer-mop" "str" "yason")
:depends-on ("alexandria" "dexador" "str" "yason")
:components ((:file "src/json-ld")))
@ -61,14 +60,15 @@
:depends-on (:activity-servist/json-ld :alexandria :lisp-unit2)
:components ((:file "t/json-ld")))
(asdf:defsystem "activity-servist/tests/activity-streams"
(asdf:defsystem "activity-servist/tests/activity-vocabulary"
:version "0.0"
:license "AGPLv3"
:author "Jaidyn Ann <jadedctrl@posteo.at>"
:description "Tests for the the activity-servist/activity-streams package."
:description "Tests for the the activity-servist/activity-vocabulary package."
:depends-on (:activity-servist/activity-streams :alexandria :lisp-unit2)
:components ((:file "t/activity-streams")))
:depends-on (:activity-servist/activity-vocabulary :alexandria :lisp-unit2)
:components ((:file "t/activity-vocabulary")))
(asdf:defsystem "activity-servist/tests/signatures"
@ -99,7 +99,7 @@
`(defmethod asdf:perform ((o asdf:test-op) (c (eql (asdf:find-system ',package))))
(eval (read-from-string (format nil "(~A:run-with-summary)" ',package)))))
(define-asdf-testing activity-servist/tests/activity-streams)
(define-asdf-testing activity-servist/tests/activity-vocabulary)
(define-asdf-testing activity-servist/tests/json-ld)
(define-asdf-testing activity-servist/tests/signatures)
(define-asdf-testing activity-servist/tests)

View File

@ -1,131 +0,0 @@
;;;; activity-streams: Serialize/deserialize ActivityStreams objects.
;; Copyright © 2024 Jaidyn Ann <jadedctrl@posteo.at>
;;
;; This program is free software: you can redistribute it and/or
;; modify it under the terms of the GNU Affero General Public License
;; as published by the Free Software Foundation, either version 3 of
;; the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(defpackage #:activity-servist/activity-streams
(:use #:cl)
(:nicknames "AS/AS" "ACTIVITY-STREAMS")
(:export
;; Classes
:object
;; Accessors
#'object-actor #'object-attachment #'object-attributed-to #'object-audience
#'object-content #'object-context #'object-name #'object-end-time
#'object-generator #'object-icon #'object-image #'object-in-reply-to
#'object-location #'object-preview #'object-published #'object-replies
#'object-start-time #'object-summary #'object-tag #'object-updated
#'object-url #'object-to #'object-bto #'object-cc #'object-bcc
#'object-media-type #'object-duration
;; Slots
:attachment :attributed-to :audience :content :context :name :end-time
:generator :icon :image :in-reply-to :location :preview :published :replies
:start-time :summary :tag :updated :url :to :bto :cc :bcc :media-type :duration))
(in-package #:activity-servist/activity-streams)
;;; Core class
;;; ————————————————————————————————————————
(json-ld::define-json-type (object "Object") () "https://www.w3.org/ns/activitystreams"
((actor
"actor"
:documentation "Describes one or more entities that either performed or are expected to perform the activity. Any single activity can have multiple actors. The actor MAY be specified using an indirect Link.")
(attachment
"attachment"
:documentation "Identifies a resource attached or related to an object that potentially requires special handling. The intent is to provide a model that is at least semantically similar to attachments in email.")
(attributed-to
"attributedTo"
:documentation "Identifies one or more entities to which this object is attributed. The attributed entities might not be Actors. For instance, an object might be attributed to the completion of another activity.")
(audience
"audience"
:documentation "Identifies one or more entities that represent the total population of entities for which the object can considered to be relevant.")
(content
"content"
:documentation "The content or textual representation of the Object encoded as a JSON string. By default, the value of content is HTML. The media-type property can be used in the object to indicate a different content type.
The content MAY be expressed using multiple language-tagged values. ")
(context
"context"
:documentation "Identifies the context within which the object exists or an activity was performed.
The notion of context used is intentionally vague. The intended function is to serve as a means of grouping objects and activities that share a common originating context or purpose. An example could be all activities relating to a common project or event.")
(name
"name"
:documentation "A simple, human-readable, plain-text name for the object. HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged values.")
(end-time
"endTime"
:documentation "The date and time describing the actual or expected ending time of the object. When used with an Activity object, for instance, the end-time property specifies the moment the activity concluded or is expected to conclude.")
(generator
"generator"
:documentation "Identifies the entity (e.g. an application) that generated the object.")
(icon
"icon"
:documentation "Indicates an entity that describes an icon for this object. The image should have an aspect ratio of one (horizontal) to one (vertical) and should be suitable for presentation at a small size.")
(image
"image"
:documentation "Indicates an entity that describes an image for this object. Unlike the icon property, there are no aspect ratio or display size limitations assumed.")
(in-reply-to
"inReplyTo"
:documentation "Indicates one or more entities for which this object is considered a response.")
(location
"location"
:documentation "Indicates one or more physical or logical locations associated with the object.")
(preview
"preview"
:documentation "Identifies an entity that provides a preview of this object.")
(published
"published"
:documentation "The date and time describing the actual or expected starting time of the object. When used with an Activity object, for instance, the start-time property specifies the moment the activity began or is scheduled to begin.")
(replies
"replies"
:documentation "Identifies a Collection containing objects considered to be responses to this object.")
(start-time
"startTime"
:documentation "The date and time describing the actual or expected starting time of the object. When used with an Activity object, for instance, the start-time property specifies the moment the activity began or is scheduled to begin.")
(summary
"summary"
:documentation "A natural language summarization of the object encoded as HTML. Multiple language tagged summaries MAY be provided.")
(tag
"tag"
:documentation "One or more “tags” that have been associated with an objects. A tag can be any kind of Object. The key difference between attachment and tag is that the former implies association by inclusion, while the latter implies associated by reference.")
(updated
"updated"
:documentation "The date and time at which the object was updated.")
(url
"url"
:documentation "Identifies one or more links to representations of the object.")
(to
"to"
:documentation "Identifies an entity considered to be part of the public primary audience of an Object.")
(bto
"bto"
:documentation "Identifies an Object that is part of the private primary audience of this Object.")
(cc
"cc"
:documentation "Identifies an Object that is part of the public secondary audience of this Object.")
(bcc
"bcc"
:documentation "Identifies one or more Objects that are part of the private secondary audience of this Object.")
(media-type
"mediaType"
:documentation "When used on a Link, identifies the MIME media type of the referenced resource.
When used on an Object, identifies the MIME media type of the value of the content property. If not specified, the content property is assumed to contain text/html content.")
(duration
"duration"
:documentation "When the object describes a time-bound resource, such as an audio or video, a meeting, etc, the duration property indicates the object's approximate duration. The value MUST be expressed as an xsd:duration as defined by [ xmlschema11-2], section 3.3.6 (e.g. a period of 5 seconds is represented as “PT5S”)."))
(:documentation
"Describes an object of any kind. The Object type serves as the base type for
most of the other kinds of objects defined in the Activity Vocabulary,
including other Core types such as Activity, IntransitiveActivity, Collection
and OrderedCollection."))

View File

@ -30,7 +30,7 @@
:ordered-collection-page :organization :page :person :place :profile
:question :read :reject :relationship :remove :service :tentative-accept
:tentative-reject :tombstone :travel :undo :update :video :view
;; Slots
;; Accessors
:activity-actor :activity-instrument :activity-object :activity-origin
:activity-result :activity-target
:collection-current :collection-first :collection-items :collection-last
@ -38,13 +38,13 @@
:collection-page-next :collection-page-part-of :collection-page-prev
:link-height :link-href :link-hreflang :link-media-type :link-name
:link-preview :link-rel :link-summary :link-width
:object-attachment :object-attributed-to :object-audience :object-bcc
:object-bto :object-cc :object-content :object-context :object-duration
:object-end-time :object-generator :object-icon :object-image
:object-in-reply-to :object-location :object-media-type :object-name
:object-preview :object-published :object-replies :object-start-time
:object-summary :object-tag :object-to :object-type :object-updated
:object-url
:object-actor :object-attachment :object-attributed-to :object-audience
:object-content :object-context :object-name :object-end-time
:object-generator :object-icon :object-image :object-in-reply-to
:object-location :object-preview :object-published :object-replies
:object-start-time :object-summary :object-tag :object-updated
:object-url :object-to :object-bto :object-cc :object-bcc
:object-media-type :object-duration
:ordered-collection-page-start-index ordered-collection-ordered-items
:place-accuracy :place-altitude :place-latitude :place-longitude
:place-radius :place-units
@ -55,42 +55,23 @@
(in-package #:activity-servist/activity-vocabulary)
(setq activity-servist/activity-streams:*default-class*
'activity-servist/activity-vocabulary:object)
;;; Macros
;;; ————————————————————————————————————————
(defmacro defclass-w-accessors (name direct-superclasses slots &rest options)
"Identical to DEFCLASS, but with one convenience: A slot definition, if being
simply a symbol, will default to a slot with an accessor and init-arg named after the
symbol. The init-arg will be :symbol, and the accessor will be classname-symbol.
For example, the following two forms are equivalent:
(defclass-w-accessors PERSON () (AGE
HEIGHT
(NAME :INIT-FORM Unknown)))
(defclass PERSON () ((AGE :INIT-ARG :AGE :ACCESSOR PERSON-AGE)
(HEIGHT :INIT-ARG :HEIGHT :ACCESSOR PERSON-HEIGHT)
(NAME :INIT-FORM Unknown)))"
`(defclass ,name ,direct-superclasses
,(mapcar
(lambda (slot)
(typecase slot
(list slot)
(t (list slot :accessor (intern (format nil "~A-~A" name slot))
:initarg (intern (symbol-name slot) "KEYWORD")
:initform nil))))
slots)
,@options))
(defmacro defclass-empty-children (name direct-children)
"For each name in the list DIRECT-CHILDREN, a subclass of NAME will be created.
(defmacro define-json-empty-types (superclass context &rest direct-children)
"For each list of DIRECT-CHILDREN, a hollow JSON subtype and CLOS subclass
of SUPERCLASS will be created, with the given JSON-LD context CONTEXT.
These new subclasses have no slots of its own they will be empty derivatives
of NAME."
of SUPERCLASS.
Items of DIRECT-CHILDREN should be of the form,
(CLASS-NAME typeName Documenation-string describing the subclass.)"
(append
'(progn)
(mapcar (lambda (a)
`(defclass ,a (,name) ()))
(mapcar (lambda (subclass-list)
(let ((class-name (first subclass-list))
(type-name (second subclass-list))
(documentation (third subclass-list)))
`(json-ld:define-json-type (,class-name ,type-name) (,superclass) ,context
()
(:documentation ,documentation))))
direct-children)))
@ -98,109 +79,378 @@ of NAME."
;;; Core types
;;; ————————————————————————————————————————
;; https://www.w3.org/ns/activitystreams#Object
(defclass-w-accessors object (activity-servist/activity-streams:object)
(
attachment attributed-to audience bcc bto cc content context
duration end-time generator icon id image in-reply-to location
media-type name preview published replies start-time summary
tag to updated url))
;; The root of all evil in the world.
(json-ld::define-json-type (object "Object") () "https://www.w3.org/ns/activitystreams"
((attachment
"attachment"
:documentation "Identifies a resource attached or related to an object that potentially requires special handling. The intent is to provide a model that is at least semantically similar to attachments in email.")
(attributed-to
"attributedTo"
:documentation "Identifies one or more entities to which this object is attributed. The attributed entities might not be Actors. For instance, an object might be attributed to the completion of another activity.")
(audience
"audience"
:documentation "Identifies one or more entities that represent the total population of entities for which the object can considered to be relevant.")
(content
"content"
:documentation "The content or textual representation of the Object encoded as a JSON string. By default, the value of content is HTML. The media-type property can be used in the object to indicate a different content type.
The content MAY be expressed using multiple language-tagged values. ")
(context
"context"
:documentation "Identifies the context within which the object exists or an activity was performed.
The notion of context used is intentionally vague. The intended function is to serve as a means of grouping objects and activities that share a common originating context or purpose. An example could be all activities relating to a common project or event.")
(name
"name"
:documentation "A simple, human-readable, plain-text name for the object. HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged values.")
(end-time
"endTime"
:documentation "The date and time describing the actual or expected ending time of the object. When used with an Activity object, for instance, the end-time property specifies the moment the activity concluded or is expected to conclude.")
(generator
"generator"
:documentation "Identifies the entity (e.g. an application) that generated the object.")
(icon
"icon"
:documentation "Indicates an entity that describes an icon for this object. The image should have an aspect ratio of one (horizontal) to one (vertical) and should be suitable for presentation at a small size.")
(image
"image"
:documentation "Indicates an entity that describes an image for this object. Unlike the icon property, there are no aspect ratio or display size limitations assumed.")
(in-reply-to
"inReplyTo"
:documentation "Indicates one or more entities for which this object is considered a response.")
(location
"location"
:documentation "Indicates one or more physical or logical locations associated with the object.")
(preview
"preview"
:documentation "Identifies an entity that provides a preview of this object.")
(published
"published"
:documentation "The date and time describing the actual or expected starting time of the object. When used with an Activity object, for instance, the start-time property specifies the moment the activity began or is scheduled to begin.")
(replies
"replies"
:documentation "Identifies a Collection containing objects considered to be responses to this object.")
(start-time
"startTime"
:documentation "The date and time describing the actual or expected starting time of the object. When used with an Activity object, for instance, the start-time property specifies the moment the activity began or is scheduled to begin.")
(summary
"summary"
:documentation "A natural language summarization of the object encoded as HTML. Multiple language tagged summaries MAY be provided.")
(tag
"tag"
:documentation "One or more “tags” that have been associated with an objects. A tag can be any kind of Object. The key difference between attachment and tag is that the former implies association by inclusion, while the latter implies associated by reference.")
(updated
"updated"
:documentation "The date and time at which the object was updated.")
(url
"url"
:documentation "Identifies one or more links to representations of the object.")
(to
"to"
:documentation "Identifies an entity considered to be part of the public primary audience of an Object.")
(bto
"bto"
:documentation "Identifies an Object that is part of the private primary audience of this Object.")
(cc
"cc"
:documentation "Identifies an Object that is part of the public secondary audience of this Object.")
(bcc
"bcc"
:documentation "Identifies one or more Objects that are part of the private secondary audience of this Object.")
(media-type
"mediaType"
:documentation "Identifies the MIME media type of the value of the content property. If not specified, the content property is assumed to contain text/html content.")
(duration
"duration"
:documentation "When the object describes a time-bound resource, such as an audio or video, a meeting, etc, the duration property indicates the object's approximate duration. The value MUST be expressed as an xsd:duration as defined by [ xmlschema11-2], section 3.3.6 (e.g. a period of 5 seconds is represented as “PT5S”)."))
(:documentation
"Describes an object of any kind. The Object type serves as the base type for most of the other kinds of objects defined in the Activity Vocabulary, including other Core types such as Activity, IntransitiveActivity, Collection and OrderedCollection."))
;; https://www.w3.org/ns/activitystreams#Link
;; “summary” here isnt real! Its not a property Link should have (just
;; looking at Links properties), but its implied by the Mention example.
(defclass-w-accessors link (activity-servist/activity-streams:object)
(height href hreflang media-type name preview rel summary width))
(json-ld:define-json-type (link "Link") ()
"https://www.w3.org/ns/activitystreams"
((height
"height"
:documentation "On a Link, specifies a hint as to the rendering height in device-independent pixels of the linked resource.")
(href
"href"
:documentation "The target resource pointed to by a Link.")
(hreflang
"hreflang"
:documentation "Hints as to the language used by the target resource. Value MUST be a [BCP47] Language-Tag.")
(media-type
"media-type"
:documentation "Identifies the MIME media type of the referenced resource.")
(name
"name"
:documentation "A simple, human-readable, plain-text name for the object. HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged values. ")
(preview
"preview"
:documentation "Identifies an entity that provides a preview of this object. ")
(rel
"rel"
:documentation "A link relation associated with a Link. The value MUST conform to both the [HTML5] and [RFC5988] link relation definitions.
In the [HTML5], any string not containing the space U+0020, tab (U+0009), LF (U+000A), FF (U+000C), CR (U+000D) or , (U+002C) characters can be used as a valid link relation.")
(summary
"summary"
:documentation "A natural language summarization of the object encoded as HTML. Multiple language tagged summaries MAY be provided.")
(width
"width"
:documentation "Specifies a hint as to the rendering width in device-independent pixels of the linked resource.")))
;; https://www.w3.org/ns/activitystreams#Activity
(defclass-w-accessors activity (object)
(actor instrument object origin result target))
(json-ld:define-json-type (activity "Activity") (object)
"https://www.w3.org/ns/activitystreams"
((actor
"actor"
:documentation "Describes one or more entities that either performed or are expected to perform the activity. Any single activity can have multiple actors. The actor MAY be specified using an indirect Link.")
(object
"object"
:documentation "Describes the direct object of the activity. For instance, in the activity “John added a movie to his wishlist”, the object of the activity is the movie added.")
(target
"target"
:documentation "Describes the indirect object, or target, of the activity. The precise meaning of the target is largely dependent on the type of action being described but will often be the object of the English preposition ”to”. For instance, in the activity “John added a movie to his wishlist”, the target of the activity is John's wishlist. An activity can have more than one target.")
(result
"result"
:documentation "Describes the result of the activity. For instance, if a particular action results in the creation of a new resource, the result property can be used to describe that new resource.")
(origin
"origin"
:documentation "Describes an indirect object of the activity from which the activity is directed. The precise meaning of the origin is the object of the English preposition “from”. For instance, in the activity “John moved an item to List B from List A”, the origin of the activity is “List A”.")
(instrument
"instrument"
:documentation "Identifies one or more objects used (or to be used) in the completion of an Activity."))
(:documentation "An Activity is a subtype of Object that describes some form of action that may happen, is currently happening, or has already happened. The Activity type itself serves as an abstract base type for all types of activities. It is important to note that the Activity type itself does not carry any specific semantics about the kind of action being taken."))
;; Should be ordinary Activity, sans `object`.
;; https://www.w3.org/ns/activitystreams#IntransitiveActivity
(defclass intransitive-activity (activity) ())
(json-ld:define-json-type (intransitive-activity "IntransitiveActivity") (activity)
"https://www.w3.org/ns/activitystreams"
()
(:documentation "Instances of IntransitiveActivity are a subtype of Activity representing intransitive actions. The object property is therefore inappropriate for these activities."))
;; https://www.w3.org/ns/activitystreams#Collection
(defclass-w-accessors collection (object)
(current first items last total-items))
(json-ld:define-json-type (collection "Collection") (object)
"https://www.w3.org/ns/activitystreams"
((total-items
"totalItems"
:documentation "A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance.")
(current
"current"
:documentation "In a paged Collection, indicates the page that contains the most recently updated member items.")
(first
"first"
:documentation "In a paged Collection, indicates the furthest preceeding page of items in the collection. ")
(last
"last"
:documentation "In a paged Collection, indicates the furthest proceeding page of the collection.")
(items
"items"
:documentation "Identifies the items contained in a collection. The items might be ordered or unordered."))
(:documentation "A Collection is a subtype of Object that represents ordered or unordered sets of Object or Link instances."))
;; https://www.w3.org/ns/activitystreams#OrderedCollection
;; Funnily enough, “orderedItems” is actually a ghost! Its only *implied*. :-P
;; https://jam.xwx.moe/notice/AjE1LkpLoBvWmDUmK8
(defclass-w-accessors ordered-collection (collection)
(ordered-items))
(json-ld:define-json-type (ordered-collection "OrderedCollection") (collection)
"https://www.w3.org/ns/activitystreams"
((ordered-items
"orderedItems"
:documentation "Identifies the items contained in a collection. The items are necessarily ordered."))
(:documentation "A subtype of Collection in which members of the logical collection are assumed to always be strictly ordered."))
;; https://www.w3.org/ns/activitystreams#CollectionPage
(defclass-w-accessors collection-page (collection)
(next part-of prev))
(json-ld:define-json-type (collection-page "CollectionPage") (collection)
"https://www.w3.org/ns/activitystreams"
((part-of
"partOf"
:documentation "Identifies the Collection to which a CollectionPage objects items belong.")
(next
"next"
:documentation "In a paged Collection, indicates the next page of items.")
(prev
"prev"
:documentation "In a paged Collection, identifies the previous page of items."))
(:documentation "Used to represent distinct subsets of items from a Collection."))
;; https://www.w3.org/ns/activitystreams#OrderedCollectionPage
(defclass-w-accessors ordered-collection-page (collection-page ordered-collection)
(start-index))
(json-ld:define-json-type (ordered-collection-page "OrderedCollectionPage") (collection-page ordered-collection)
"https://www.w3.org/ns/activitystreams"
((start-index
"startIndex"
:documentation "A non-negative integer value identifying the relative position within the logical view of a strictly ordered collection."))
(:documentation "Used to represent ordered subsets of items from an OrderedCollection."))
;;; Extended Activity types
;;; ————————————————————————————————————————
(defclass-empty-children activity
(accept add announce block create delete dislike flag follow ignore join leave
like listen move offer read reject remove travel undo update view))
(define-json-empty-types activity "https://www.w3.org/ns/activitystreams"
(accept "Accept" "Indicates that the actor accepts the object. The target property can be used in certain circumstances to indicate the context into which the object has been accepted.")
(add "Add" "Indicates that the actor has added the object to the target. If the target property is not explicitly specified, the target would need to be determined implicitly by context. The origin can be used to identify the context from which the object originated.")
(create "Create" "Indicates that the actor has created the object.")
(delete "Delete" "Indicates that the actor has deleted the object. If specified, the origin indicates the context from which the object was deleted.")
(follow "Follow" "Indicates that the actor is “following” the object. Following is defined in the sense typically used within Social systems in which the actor is interested in any activity performed by or on the object. The target and origin typically have no defined meaning.")
(ignore "Ignore" "Indicates that the actor is ignoring the object. The target and origin typically have no defined meaning.")
(join "Join" "Indicates that the actor has joined the object. The target and origin typically have no defined meaning.")
(leave "Leave" "Indicates that the actor has left the object. The target and origin typically have no meaning.")
(like "Like" "Indicates that the actor likes, recommends or endorses the object. The target and origin typically have no defined meaning.")
(offer "Offer" "Indicates that the actor is offering the object. If specified, the target indicates the entity to which the object is being offered.")
(reject "Reject" "Indicates that the actor is rejecting the object. The target and origin typically have no defined meaning.")
(remove "Remove" "Indicates that the actor is removing the object. If specified, the origin indicates the context from which the object is being removed.")
(undo "Undo" "Indicates that the actor is undoing the object. In most cases, the object will be an Activity describing some previously performed action (for instance, a person may have previously liked an article but, for whatever reason, might choose to undo that like at some later point in time).
The target and origin typically have no defined meaning.")
(update "Update" "Indicates that the actor has updated the object. Note, however, that this vocabulary does not define a mechanism for describing the actual set of modifications made to object.
The target and origin typically have no defined meaning.")
(view "View" "Indicates that the actor has viewed the object.")
(listen "Listen" "Indicates that the actor has listened to the object.")
(read "Read" "Indicates that the actor has read the object.")
(move "Move" "Indicates that the actor has moved object from origin to target. If the origin or target are not specified, either can be determined by context.")
(travel "Travel" "Indicates that the actor is traveling to target from origin. Travel is an IntransitiveObject whose actor specifies the direct object. If the target or origin are not specified, either can be determined by context.")
(announce "Announce" "Indicates that the actor is calling the target's attention the object.
The origin typically has no defined meaning.")
(flag "Flag" "Indicates that the actor is “flagging” the object. Flagging is defined in the sense common to many social platforms as reporting content as being inappropriate for any number of reasons.")
(dislike "Dislike" "Indicates that the actor dislikes the object."))
(defclass arrive (intransitive-activity) ())
(defclass ignore (block) ())
(defclass invite (offer) ())
(defclass question (intransitive-activity) ())
(defclass tentative-accept (accept) ())
(defclass tentative-reject (reject) ())
(defclass-w-accessors question (intransitive-activity)
(any-of closed one-of))
(json-ld:define-json-type (question "Question") (intransitive-activity)
"https://www.w3.org/ns/activitystreams"
((one-of
"oneOf"
:documentation "Identifies an exclusive option for a Question. Use of oneOf implies that the Question can have only a single answer. To indicate that a Question can have multiple answers, use anyOf.")
(any-of
"anyOf"
:documentation "Identifies an inclusive option for a Question. Use of anyOf implies that the Question can have multiple answers. To indicate that a Question can have only one answer, use oneOf.")
(closed
"closed"
:documentation "Indicates that a question has been closed, and answers are no longer accepted."))
(:documentation "Represents a question being asked. Question objects are an extension of IntransitiveActivity. That is, the Question object is an Activity, but the direct object is the question itself and therefore it would not contain an object property.
Either of the ANY-OF and ONE-OF properties MAY be used to express possible answers, but a Question object MUST NOT have both properties."))
(json-ld:define-json-type (arrive "Arrive") (intransitive-activity)
"https://www.w3.org/ns/activitystreams"
((arrive
"Arrive"
:documentation "Indicates that the actor has arrived at the location. The origin can be used to identify the context from which the actor originated. The target typically has no defined meaning."))
(:documentation "An IntransitiveActivity that indicates that the actor has arrived at the location. The origin can be used to identify the context from which the actor originated. The target typically has no defined meaning."))
(json-ld:define-json-type (block "Block") (ignore)
"https://www.w3.org/ns/activitystreams"
()
(:documentation "Indicates that the actor is blocking the object. Blocking is a stronger form of Ignore. The typical use is to support social systems that allow one user to block activities or content of other users. The target and origin typically have no defined meaning."))
(json-ld:define-json-type (invite "Invite") (offer)
"https://www.w3.org/ns/activitystreams"
()
(:documentation "A specialization of Offer in which the actor is extending an invitation for the object to the target."))
(json-ld:define-json-type (tentative-accept "TentativeAccept") (accept)
"https://www.w3.org/ns/activitystreams"
()
(:documentation "A specialization of Accept indicating that the acceptance is tentative."))
(json-ld:define-json-type (tentative-reject "TentativeReject") (reject)
"https://www.w3.org/ns/activitystreams"
()
(:documentation "A specialization of Reject indicating that the rejection is tentative."))
;;; Extended Actor types
;;; ————————————————————————————————————————
(defclass-empty-children object
(application group organization person service))
(define-json-empty-types object "https://www.w3.org/ns/activitystreams"
(application "Application" "Describes a software application.")
(group "Group" "Represents a formal or informal collective of Actors.")
(organization "Organization" "Represents an organization.")
(person "Person" "Represents an individual person.")
(service "Service" "Represents a service of any kind."))
;;; Extended Object types
;;; ————————————————————————————————————————
(defclass-empty-children object
(article document event note))
(define-json-empty-types object "https://www.w3.org/ns/activitystreams"
(article "Article" "Represents any kind of multi-paragraph written work.")
(document "Document" "Represents a document of any kind.")
(note "Note" "Represents a short written work typically less than a single paragraph in length.")
(event "Event" "Represents any kind of event."))
(define-json-empty-types document "https://www.w3.org/ns/activitystreams"
(audio "Audio" "Represents an audio document of any kind.")
(image "Image" "An image document of any kind.")
(video "Video" "Represents a video document of any kind.")
(page "Page" "Represents a Web Page."))
(defclass-empty-children document
(audio image page video))
;; https://www.w3.org/ns/activitystreams#Place
(defclass-w-accessors place (object)
(accuracy altitude latitude longitude radius units))
(json-ld:define-json-type (place "Place") (object)
"https://www.w3.org/ns/activitystreams"
((accuracy
"accuracy"
:documentation "Indicates the accuracy of position coordinates on a Place objects. Expressed in properties of percentage. e.g. “94.0” means “94.0% accurate”.")
(altitude
"altitude"
:documentation "Indicates the altitude of a place. The measurement units is indicated using the units property. If units is not specified, the default is assumed to be “m” indicating meters.")
(latitude
"latitude"
:documentation "The latitude of a place.")
(longitude
"longitude"
:documentation "The longitude of a place.")
(radius
"radius"
:documentation "The radius from the given latitude and longitude for a Place. The units is expressed by the units property. If units is not specified, the default is assumed to be “m” indicating “meters”.")
(units
"units"
:documentation "Specifies the measurement units for the radius and altitude properties on a Place object. If not specified, the default is assumed to be “m” for “meters”."))
(:documentation "Represents a logical or physical location."))
;; https://www.w3.org/ns/activitystreams#Profile
(defclass-w-accessors profile (object)
(describes))
(json-ld:define-json-type (profile "Profile") (object)
"https://www.w3.org/ns/activitystreams"
((describes
"describes"
:documentation "The describes property identifies the object described by a Profile."))
(:documentation "A Profile is a content object that describes another Object, typically used to describe Actor Type objects. The describes property is used to reference the object being described by the profile."))
;; https://www.w3.org/ns/activitystreams#Relationship
(defclass-w-accessors relationship (object)
(object relationship subject))
(json-ld:define-json-type (relationship "Relationship") (object)
"https://www.w3.org/ns/activitystreams"
((subject
"subject"
:documentation "On a Relationship object, the subject property identifies one of the connected individuals. For instance, for a Relationship object describing “John is related to Sally”, subject would refer to John.")
(relationship
"relationship"
:documentation "On a Relationship object, the relationship property identifies the kind of relationship that exists between subject and object."))
(:documentation "Describes a relationship between two individuals. The subject and object properties are used to identify the connected individuals."))
;; https://www.w3.org/ns/activitystreams#Tombstone
(defclass-w-accessors tombstone (object)
(former-type deleted))
(json-ld:define-json-type (tombstone "Tombstone") (object)
"https://www.w3.org/ns/activitystreams"
((former-type
"formerType"
:documentation "The formerType property identifies the type of the object that was deleted.")
(deleted
"deleted"
:documentation "The deleted property is a timestamp for when the object was deleted."))
(:documentation "A Tombstone represents a content object that has been deleted. It can be used in Collections to signify that there used to be an object at this position, but it has been deleted."))
;;; Extended Link types
;;; ————————————————————————————————————————
(defclass-empty-children link
(mention))
;;; Defining YASON:ENCODE-SLOTS
;;; ————————————————————————————————————————
;; On-the-fly define YASON:ENCODE-SLOTS for each of our distinct AP classes.
(as/as:define-class-encoders
(mapcar #'find-class
'(object link activity collection collection-page ordered-collection
ordered-collection-page place profile question relationship tombstone)))
(json-ld:define-json-type (mention "Mention") (link) "https://www.w3.org/ns/activitystreams"
()
(:documentation "A specialized Link that represents an @mention."))

View File

@ -19,7 +19,7 @@
(:use #:cl)
(:nicknames "AS/JSON-LD" "JSON-LD")
(:export
#:define-json-type
#:parse #:define-json-type
;; Accessors
#:json-ld-context #:json-ld-etc #:json-ld-id #:json-ld-type
;; Slots

View File

@ -1,4 +1,4 @@
;;;; activity-servist/tests/activity-streams: Testing activity-streams.
;;;; activity-servist/tests/activity-vocabulary: Testing activity-vocabulary.
;; Copyright © 2024 Jaidyn Levesque <jadedctrl@posteo.at>
;;
@ -15,19 +15,19 @@
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(defpackage :activity-servist/tests/activity-streams
(defpackage :activity-servist/tests/activity-vocabulary
(:use :cl :lisp-unit2)
(:nicknames "AS/T/AS")
(:nicknames "AS/T/AV")
(:export :run :run-with-summary))
(in-package :activity-servist/tests/activity-streams)
(in-package :activity-servist/tests/activity-vocabulary)
(defun run ()
"Run all ACTIVITY-STREAMS tests."
(lisp-unit2:run-tests :package :activity-servist/tests/activity-streams))
"Run all ACTIVITY-VOCABULARY tests."
(lisp-unit2:run-tests :package :activity-servist/tests/activity-vocabulary))
(defun run-with-summary ()
"Run tests with summary for ACTIVITY-STREAMS."
"Run tests with summary for ACTIVITY-VOCABULARY."
(lisp-unit2:with-summary()
(run)))
@ -53,7 +53,7 @@ ensuring they are semantically equivalent. White-space and key order are ignored
(yason:parse
(yason:with-output-to-string* ()
(yason:encode-object
(as/as:parse ,content)))))))))
(json-ld:parse ,content)))))))))
(defun sort-alist (alist predicate)
"Sort an associative list by its keys."
@ -91,4 +91,4 @@ Any nested hash-tables found as values are also sorted, recursively."
(mapcar (lambda (file)
(eval `(define-json-test ,file '(:activity-vocabulary))))
(uiop:directory-files
(relative-pathname "t/activity-streams/activity-vocabulary/")))
(relative-pathname "t/activity-vocabulary/")))