ontology.scm
1 | ;;;; Copyright (C) 2020 Julien Lepiller <julien@lepiller.eu> |
2 | ;;;; |
3 | ;;;; This library is free software; you can redistribute it and/or |
4 | ;;;; modify it under the terms of the GNU Lesser General Public |
5 | ;;;; License as published by the Free Software Foundation; either |
6 | ;;;; version 3 of the License, or (at your option) any later version. |
7 | ;;;; |
8 | ;;;; This library is distributed in the hope that it will be useful, |
9 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | ;;;; Lesser General Public License for more details. |
12 | ;;;; |
13 | ;;;; You should have received a copy of the GNU Lesser General Public |
14 | ;;;; License along with this library; if not, write to the Free Software |
15 | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
16 | ;;;; |
17 | ;;;; |
18 | ;;;; |
19 | ;;;; Note that most of this file is a direct translation of the activitystreams |
20 | ;;;; vocabulary specification (esp. comments in as:type and as:property) which |
21 | ;;;; is under these terms: |
22 | ;;;; |
23 | ;;;; Copyright © 2017 Activity Streams Working Group, IBM & W3C® (MIT, |
24 | ;;;; ERCIM, Keio, Beihang). W3C liability, trademark and permissive |
25 | ;;;; document license rules apply. |
26 | ;;;; |
27 | ;;;; You should have received a copy of the Permissive Document License along |
28 | ;;;; with this library; if not, that document license is accessible online at: |
29 | ;;;; https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document |
30 | ;;;; |
31 | ;;;; The origin document used to develop this can be found at: |
32 | ;;;; https://www.w3.org/TR/activitystreams-vocabulary |
33 | |
34 | (define-module (activitystreams ontology) |
35 | #:use-module (activitystreams activitystreams) |
36 | #:use-module (ice-9 match) |
37 | #:use-module (jsonld json) |
38 | #:use-module (web uri) |
39 | #:export (activitystreams-ontology)) |
40 | |
41 | ;; Core types |
42 | |
43 | (define as:Object |
44 | (make-as-type |
45 | "Object" |
46 | #:comment |
47 | "Describes an object of any kind. The Object type serves as the base type |
48 | for most of the other kinds of objects defined in the Activity Vocabulary, |
49 | including other Core types such as Activity, IntransitiveActivity, Collection |
50 | and OrderedCollection.")) |
51 | |
52 | (define as:Link |
53 | (make-as-type |
54 | "Link" |
55 | #:comment |
56 | "A Link is an indirect, qualified reference to a resource identified by a |
57 | URL. The fundamental model for links is established by [RFC5988]. Many of the |
58 | properties defined by the Activity Vocabulary allow values that are either |
59 | instances of Object or Link. When a Link is used, it establishes a qualified |
60 | relation connecting the subject (the containing object) to the resource |
61 | identified by the href. Properties of the Link are properties of the |
62 | reference as opposed to properties of the resource.")) |
63 | |
64 | (define as:Activity |
65 | (make-as-type |
66 | "Activity" |
67 | #:subclass-of (list as:Object) |
68 | #:comment |
69 | "An Activity is a subtype of Object that describes some form of action that |
70 | may happen, is currently happening, or has already happened. The Activity type |
71 | itself serves as an abstract base type for all types of activities. It is |
72 | important to note that the Activity type itself does not carry any specific |
73 | semantics about the kind of action being taken.")) |
74 | |
75 | (define as:IntransitiveActivity |
76 | (make-as-type |
77 | "IntrasitiveActivity" |
78 | #:subclass-of (list as:Activity) |
79 | #:comment |
80 | "Instances of IntransitiveActivity are a subtype of Activity representing |
81 | intransitive actions. The object property is therefore inappropriate for |
82 | these activities.")) |
83 | |
84 | (define as:Collection |
85 | (make-as-type |
86 | "Collection" |
87 | #:subclass-of (list as:Object) |
88 | #:comment |
89 | "A Collection is a subtype of Object that represents ordered or unordered |
90 | sets of Object or Link instances. Refer to the Activity Streams 2.0 Core |
91 | specification for a complete description of the Collection type.")) |
92 | |
93 | (define as:OrderedCollection |
94 | (make-as-type |
95 | "OrderedCollection" |
96 | #:subclass-of (list as:Collection) |
97 | #:comment |
98 | "A subtype of Collection in which members of the logical collection are |
99 | assumed to always be strictly ordered.")) |
100 | |
101 | (define as:CollectionPage |
102 | (make-as-type |
103 | "CollectionPage" |
104 | #:subclass-of (list as:Collection) |
105 | #:comment |
106 | "Used to represent distinct subsets of items from a Collection. Refer to |
107 | the Activity Streams 2.0 Core for a complete description of the CollectionPage |
108 | object.")) |
109 | |
110 | (define as:OrderedCollectionPage |
111 | (make-as-type |
112 | "OrderedCollectionPage" |
113 | #:subclass-of (list as:OrderedCollection as:CollectionPage) |
114 | #:comment |
115 | "Used to represent ordered subsets of items from an OrderedCollection. |
116 | Refer to the Activity Streams 2.0 Core for a complete description of the |
117 | OrderedCollectionPage object.")) |
118 | |
119 | (define as-core-types (list as:Object as:Link as:Activity as:IntransitiveActivity |
120 | as:Collection as:OrderedCollection as:CollectionPage |
121 | as:OrderedCollectionPage)) |
122 | |
123 | ;; Extended Types |
124 | ;; Activity Types |
125 | |
126 | (define as:Accept |
127 | (make-as-type |
128 | "Accept" |
129 | #:subclass-of (list as:Activity) |
130 | #:comment |
131 | "Indicates that the actor accepts the object. The target property can be |
132 | used in certain circumstances to indicate the context into which the object has |
133 | been accepted.")) |
134 | |
135 | (define as:TentativeAccept |
136 | (make-as-type |
137 | "TentativeAccept" |
138 | #:subclass-of (list as:Accept) |
139 | #:comment |
140 | "A specialization of Accept indicating that the acceptance is tentative.")) |
141 | |
142 | (define as:Add |
143 | (make-as-type |
144 | "Add" |
145 | #:subclass-of (list as:Activity) |
146 | #:comment |
147 | "Indicates that the actor has added the object to the target. If the target |
148 | property is not explicitly specified, the target would need to be determined |
149 | implicitly by context. The origin can be used to identify the context from |
150 | which the object originated.")) |
151 | |
152 | (define as:Arrive |
153 | (make-as-type |
154 | "Arrive" |
155 | #:subclass-of (list as:IntransitiveActivity) |
156 | #:comment |
157 | "An IntransitiveActivity that indicates that the actor has arrived at the |
158 | location. The origin can be used to identify the context from which the actor |
159 | originated. The target typically has no defined meaning.")) |
160 | |
161 | (define as:Create |
162 | (make-as-type |
163 | "Create" |
164 | #:subclass-of (list as:Activity) |
165 | #:comment |
166 | "Indicates that the actor has created the object.")) |
167 | |
168 | (define as:Delete |
169 | (make-as-type |
170 | "Delete" |
171 | #:subclass-of (list as:Activity) |
172 | #:comment |
173 | "Indicates that the actor has deleted the object. If specified, the origin |
174 | indicates the context from which the object was deleted.")) |
175 | |
176 | (define as:Follow |
177 | (make-as-type |
178 | "Follow" |
179 | #:subclass-of (list as:Activity) |
180 | #:comment |
181 | "Indicates that the actor is ``following'' the object. Following is defined |
182 | in the sense typically used within Social systems in which the actor is |
183 | interested in any activity performed by or on the object. The target and |
184 | origin typically have no defined meaning.")) |
185 | |
186 | (define as:Ignore |
187 | (make-as-type |
188 | "Ignore" |
189 | #:subclass-of (list as:Activity) |
190 | #:comment |
191 | "Indicates that the actor is ignoring the object. The target and origin |
192 | typically have no defined meaning.")) |
193 | |
194 | (define as:Join |
195 | (make-as-type |
196 | "Join" |
197 | #:subclass-of (list as:Activity) |
198 | #:comment |
199 | "Indicates that the actor has joined the object. The target and origin |
200 | typically have no defined meaning.")) |
201 | |
202 | (define as:Leave |
203 | (make-as-type |
204 | "Leave" |
205 | #:subclass-of (list as:Activity) |
206 | #:comment |
207 | "Indicates that the actor has left the object. The target and origin |
208 | typically have no meaning.")) |
209 | |
210 | (define as:Like |
211 | (make-as-type |
212 | "Like" |
213 | #:subclass-of (list as:Activity) |
214 | #:comment |
215 | "Indicates that the actor likes, recommends or endorses the object. The |
216 | target and origin typically have no defined meaning.")) |
217 | |
218 | (define as:Offer |
219 | (make-as-type |
220 | "Offer" |
221 | #:subclass-of (list as:Activity) |
222 | #:comment |
223 | "Indicates that the actor is offering the object. If specified, the target |
224 | indicates the entity to which the object is being offered.")) |
225 | |
226 | (define as:Invite |
227 | (make-as-type |
228 | "Invite" |
229 | #:subclass-of (list as:Offer) |
230 | #:comment |
231 | "A specialization of Offer in which the actor is extending an invitation |
232 | for the object to the target.")) |
233 | |
234 | (define as:Reject |
235 | (make-as-type |
236 | "Reject" |
237 | #:subclass-of (list as:Activity) |
238 | #:comment |
239 | "Indicates that the actor is rejecting the object. The target and origin |
240 | typically have no defined meaning.")) |
241 | |
242 | (define as:TentativeReject |
243 | (make-as-type |
244 | "TentativeReject" |
245 | #:subclass-of (list as:Reject) |
246 | #:comment |
247 | "A specialization of Reject in which the rejection is considered tentative.")) |
248 | |
249 | (define as:Remove |
250 | (make-as-type |
251 | "Remove" |
252 | #:subclass-of (list as:Activity) |
253 | #:comment |
254 | "Indicates that the actor is removing the object. If specified, the |
255 | origin indicates the context from which the object is being removed.")) |
256 | |
257 | (define as:Undo |
258 | (make-as-type |
259 | "Undo" |
260 | #:subclass-of (list as:Activity) |
261 | #:comment |
262 | "Indicates that the actor is undoing the object. In most cases, the object |
263 | will be an Activity describing some previously performed action (for instance, |
264 | a person may have previously ``liked'' an article but, for whatever reason, |
265 | might choose to undo that like at some later point in time). The target and |
266 | origin typically have no defined meaning.")) |
267 | |
268 | (define as:Update |
269 | (make-as-type |
270 | "Update" |
271 | #:subclass-of (list as:Activity) |
272 | #:comment |
273 | "Indicates that the actor has updated the object. Note, however, that this |
274 | vocabulary does not define a mechanism for describing the actual set of |
275 | modifications made to object. The target and origin typically have no defined |
276 | meaning.")) |
277 | |
278 | (define as:View |
279 | (make-as-type |
280 | "View" |
281 | #:subclass-of (list as:Activity) |
282 | #:comment |
283 | "Indicates that the actor has viewed the object.")) |
284 | |
285 | (define as:Listen |
286 | (make-as-type |
287 | "Listen" |
288 | #:subclass-of (list as:Activity) |
289 | #:comment |
290 | "Indicates that the actor has listened to the object.")) |
291 | |
292 | (define as:Read |
293 | (make-as-type |
294 | "Read" |
295 | #:subclass-of (list as:Activity) |
296 | #:comment |
297 | "Indicates that the actor has read the object.")) |
298 | |
299 | (define as:Move |
300 | (make-as-type |
301 | "Move" |
302 | #:subclass-of (list as:Activity) |
303 | #:comment |
304 | "Indicates that the actor has moved object from origin to target. If the |
305 | origin or target are not specified, either can be determined by context.")) |
306 | |
307 | (define as:Travel |
308 | (make-as-type |
309 | "Travel" |
310 | #:subclass-of (list as:IntransitiveActivity) |
311 | #:comment |
312 | "Indicates that the actor is traveling to target from origin. Travel is |
313 | an IntransitiveObject whose actor specifies the direct object. If the target |
314 | or origin are not specified, either can be determined by context.")) |
315 | |
316 | (define as:Announce |
317 | (make-as-type |
318 | "Announce" |
319 | #:subclass-of (list as:Activity) |
320 | #:comment |
321 | "Indicates that the actor is calling the target's attention the object. The |
322 | origin typically has no defined meaning.")) |
323 | |
324 | (define as:Block |
325 | (make-as-type |
326 | "Block" |
327 | #:subclass-of (list as:Ignore) |
328 | #:comment |
329 | "Indicates that the actor is blocking the object. Blocking is a stronger |
330 | form of Ignore. The typical use is to support social systems that allow one |
331 | user to block activities or content of other users. The target and origin |
332 | typically have no defined meaning.")) |
333 | |
334 | (define as:Flag |
335 | (make-as-type |
336 | "Flag" |
337 | #:subclass-of (list as:Activity) |
338 | #:comment |
339 | "Indicates that the actor is ``flagging'' the object. Flagging is defined |
340 | in the sense common to many social platforms as reporting content as being |
341 | inappropriate for any number of reasons.")) |
342 | |
343 | (define as:Dislike |
344 | (make-as-type |
345 | "Dislike" |
346 | #:subclass-of (list as:Activity) |
347 | #:comment |
348 | "Indicates that the actor dislikes the object.")) |
349 | |
350 | (define as:Question |
351 | (make-as-type |
352 | "Question" |
353 | #:subclass-of (list as:IntransitiveActivity) |
354 | #:comment |
355 | "Represents a question being asked. Question objects are an extension of |
356 | IntransitiveActivity. That is, the Question object is an Activity, but the |
357 | direct object is the question itself and therefore it would not contain an |
358 | object property. Either of the anyOf and oneOf properties MAY be used to |
359 | express possible answers, but a Question object MUST NOT have both properties.")) |
360 | |
361 | (define as-activity-types |
362 | (list as:Accept as:Add as:Announce as:Arrive as:Block as:Create as:Delete |
363 | as:Dislike as:Flag as:Follow as:Ignore as:Invite as:Join as:Leave |
364 | as:Like as:Listen as:Move as:Offer as:Question as:Reject as:Read |
365 | as:Remove as:TentativeReject as:TentativeAccept as:Travel as:Undo |
366 | as:Update as:View)) |
367 | |
368 | ;; Actor Types |
369 | (define as:Application |
370 | (make-as-type |
371 | "Application" |
372 | #:subclass-of (list as:Object) |
373 | #:comment |
374 | "Describes a software application.")) |
375 | |
376 | (define as:Group |
377 | (make-as-type |
378 | "Group" |
379 | #:subclass-of (list as:Object) |
380 | #:comment |
381 | "Represents a formal or informal collective of Actors.")) |
382 | |
383 | (define as:Organisation |
384 | (make-as-type |
385 | "Organisation" |
386 | #:subclass-of (list as:Object) |
387 | #:comment |
388 | "Represents an organization.")) |
389 | |
390 | (define as:Person |
391 | (make-as-type |
392 | "Person" |
393 | #:subclass-of (list as:Object) |
394 | #:comment |
395 | "Represents an individual person.")) |
396 | |
397 | (define as:Service |
398 | (make-as-type |
399 | "Service" |
400 | #:subclass-of (list as:Object) |
401 | #:comment |
402 | "Represents a service of any kind.")) |
403 | |
404 | (define as-actor-types |
405 | (list as:Application as:Group as:Organisation as:Person as:Service)) |
406 | |
407 | ;; |
408 | |
409 | (define as:Relationship |
410 | (make-as-type |
411 | "Relationship" |
412 | #:subclass-of (list as:Object) |
413 | #:comment |
414 | "Describes a relationship between two individuals. The subject and object |
415 | properties are used to identify the connected individuals. See 5.2 Representing |
416 | Relationships Between Entities for additional information.")) |
417 | |
418 | (define as:Article |
419 | (make-as-type |
420 | "Article" |
421 | #:subclass-of (list as:Object) |
422 | #:comment |
423 | "Represents any kind of multi-paragraph written work.")) |
424 | |
425 | (define as:Document |
426 | (make-as-type |
427 | "Document" |
428 | #:subclass-of (list as:Object) |
429 | #:comment |
430 | "Represents a document of any kind.")) |
431 | |
432 | (define as:Audio |
433 | (make-as-type |
434 | "Audio" |
435 | #:subclass-of (list as:Document) |
436 | #:comment |
437 | "Represents an audio document of any kind.")) |
438 | |
439 | (define as:Image |
440 | (make-as-type |
441 | "Image" |
442 | #:subclass-of (list as:Document) |
443 | #:comment |
444 | "An image document of any kind.")) |
445 | |
446 | (define as:Video |
447 | (make-as-type |
448 | "Video" |
449 | #:subclass-of (list as:Document) |
450 | #:comment |
451 | "Represents a video document of any kind.")) |
452 | |
453 | (define as:Note |
454 | (make-as-type |
455 | "Note" |
456 | #:subclass-of (list as:Object) |
457 | #:comment |
458 | "Represents a short written work typically less than a single paragraph in |
459 | length.")) |
460 | |
461 | (define as:Page |
462 | (make-as-type |
463 | "Page" |
464 | #:subclass-of (list as:Document) |
465 | #:comment |
466 | "Represents a Web Page.")) |
467 | |
468 | (define as:Event |
469 | (make-as-type |
470 | "Event" |
471 | #:subclass-of (list as:Object) |
472 | #:comment |
473 | "Represents any kind of event.")) |
474 | |
475 | (define as:Place |
476 | (make-as-type |
477 | "Place" |
478 | #:subclass-of (list as:Object) |
479 | #:comment |
480 | "Represents a logical or physical location. See 5.3 Representing Places |
481 | for additional information.")) |
482 | |
483 | (define as:Mention |
484 | (make-as-type |
485 | "Mention" |
486 | #:subclass-of (list as:Link) |
487 | #:comment |
488 | "A specialized Link that represents an @mention.")) |
489 | |
490 | (define as:Profile |
491 | (make-as-type |
492 | "Profile" |
493 | #:subclass-of (list as:Object) |
494 | #:comment |
495 | "A Profile is a content object that describes another Object, typically |
496 | used to describe Actor Type objects. The describes property is used to |
497 | reference the object being described by the profile")) |
498 | |
499 | (define as:Tombstone |
500 | (make-as-type |
501 | "Tombstone" |
502 | #:subclass-of (list as:Object) |
503 | #:comment |
504 | "A Tombstone represents a content object that has been deleted. It can be |
505 | used in Collections to signify that there used to be an object at this |
506 | position, but it has been deleted.")) |
507 | |
508 | (define as-object-and-link-types |
509 | (list as:Article as:Audio as:Document as:Event as:Image as:Note as:Page |
510 | as:Place as:Profile as:Relationship as:Tombstone as:Video as:Mention)) |
511 | |
512 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
513 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
514 | ;; Properties ;; |
515 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
516 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
517 | |
518 | ;; procedures for type checking |
519 | |
520 | (define (any l proc) |
521 | (match l |
522 | (() #t) |
523 | ((p l ...) |
524 | (or (proc p) (any l proc))) |
525 | (#(p l ...) |
526 | (or (proc p) (any l proc))))) |
527 | |
528 | (define (forall l proc) |
529 | (match l |
530 | (() #t) |
531 | ((p l ...) |
532 | (and (proc p) (forall l proc))) |
533 | (#(p l ...) |
534 | (and (proc p) (forall l proc))))) |
535 | |
536 | (define (string-or-lang-string? s) |
537 | (match s |
538 | ((("@value" . s)) (string? s)) |
539 | ((("@value" . s) ("@language" . l)) (string? s)) |
540 | ((("@language" . l) ("@value" . s)) (string? s)))) |
541 | |
542 | (define (uri? s) |
543 | (if (list? s) |
544 | (forall s uri?) |
545 | (and (string? s) (string->uri s)))) |
546 | |
547 | (define (bool? s) |
548 | (and (json-object? s) |
549 | (json-has-key? s "@value") |
550 | (member (assoc-ref s "@value") '(#t #f)))) |
551 | |
552 | ;; TODO: really specify these |
553 | (define (date? s) |
554 | (and (json-object? s) |
555 | (json-has-key? s "@value") |
556 | (string? (assoc-ref s "@value")))) |
557 | |
558 | (define (link-relation? s) |
559 | (and (json-object? s) |
560 | (json-has-key? s "@value") |
561 | (string? (assoc-ref s "@value")))) |
562 | |
563 | (define (duration? s) |
564 | (and (json-object? s) |
565 | (json-has-key? s "@value") |
566 | (string? (assoc-ref s "@value")))) |
567 | |
568 | (define (langtag? s) |
569 | (and (json-object? s) |
570 | (json-has-key? s "@value") |
571 | (string? (assoc-ref s "@value")))) |
572 | |
573 | (define (mime-type? s) |
574 | (and (json-object? s) |
575 | (json-has-key? s "@value") |
576 | (string? (assoc-ref s "@value")))) |
577 | |
578 | (define (non-negative-integer? i) |
579 | (and (integer? i) |
580 | (>= i 0))) |
581 | |
582 | (define (float? i) |
583 | (number? i)) |
584 | |
585 | ;; Properties |
586 | |
587 | (define as:id |
588 | (make-as-property |
589 | "id" '("Object" "Link") uri? |
590 | #:uri "@id" |
591 | #:comment "Provides the globally unique identifier for an Object or Link." |
592 | #:functional? #t)) |
593 | |
594 | (define as:type |
595 | (make-as-property |
596 | "type" '("Object" "Link") uri? |
597 | #:uri "@type" |
598 | #:comment "Identifies the Object or Link type. Multiple values may be |
599 | specified.")) |
600 | |
601 | (define as:actor |
602 | (make-as-property |
603 | "actor" "Activity" '("Object" "Link") |
604 | #:subproperty-of '("attributedTo") |
605 | #:comment |
606 | "Describes one or more entities that either performed or are expected to |
607 | perform the activity. Any single activity can have multiple actors. The actor |
608 | MAY be specified using an indirect Link.")) |
609 | |
610 | (define as:attachment |
611 | (make-as-property |
612 | "attachment" "Object" '("Object" "Link") |
613 | #:comment |
614 | "Identifies a resource attached or related to an object that potentially |
615 | requires special handling. The intent is to provide a model that is at least |
616 | semantically similar to attachments in email.")) |
617 | |
618 | (define as:attributedTo |
619 | (make-as-property |
620 | "attributedTo" '("Link" "Object") '("Link" "Object") |
621 | #:comment |
622 | "Identifies one or more entities to which this object is attributed. The |
623 | attributed entities might not be Actors. For instance, an object might be |
624 | attributed to the completion of another activity.")) |
625 | |
626 | (define as:audience |
627 | (make-as-property |
628 | "audience" "Object" '("Object" "Link") |
629 | #:comment |
630 | "Identifies one or more entities that represent the total population of |
631 | entities for which the object can considered to be relevant.")) |
632 | |
633 | (define as:bcc |
634 | (make-as-property |
635 | "bcc" "Object" '("Object" "Link") |
636 | #:comment |
637 | "Identifies one or more Objects that are part of the private secondary |
638 | audience of this Object.")) |
639 | |
640 | (define as:bto |
641 | (make-as-property |
642 | "bto" "Object" '("Object" "Link") |
643 | #:comment |
644 | "Identifies an Object that is part of the private primary audience of this |
645 | Object.")) |
646 | |
647 | (define as:cc |
648 | (make-as-property |
649 | "cc" "Object" '("Object" "Link") |
650 | #:comment |
651 | "Identifies an Object that is part of the public secondary audience of |
652 | this Object.")) |
653 | |
654 | (define as:context |
655 | (make-as-property |
656 | "context" "Object" '("Object" "Link") |
657 | #:comment |
658 | "Identifies the context within which the object exists or an activity was |
659 | performed. The notion of ``context'' used is intentionally vague. The |
660 | intended function is to serve as a means of grouping objects and activities |
661 | that share a common originating context or purpose. An example could be all |
662 | activities relating to a common project or event.")) |
663 | |
664 | (define as:current |
665 | (make-as-property |
666 | "current" "Collection" '("CollectionPage" "Link") |
667 | #:functional? #t |
668 | #:comment |
669 | "In a paged Collection, indicates the page that contains the most recently |
670 | updated member items.")) |
671 | |
672 | (define as:first |
673 | (make-as-property |
674 | "first" "Collection" '("CollectionPage" "Link") |
675 | #:functional? #t |
676 | #:comment |
677 | "In a paged Collection, indicates the furthest preceeding page of items in |
678 | the collection.")) |
679 | |
680 | (define as:generator |
681 | (make-as-property |
682 | "generator" "Object" '("Object" "Link") |
683 | #:comment |
684 | "Identifies the entity (e.g. an application) that generated the object.")) |
685 | |
686 | (define as:icon |
687 | (make-as-property |
688 | "icon" "Object" '("Image" "Link") |
689 | #:comment |
690 | "Indicates an entity that describes an icon for this object. The image |
691 | should have an aspect ratio of one (horizontal) to one (vertical) and should |
692 | be suitable for presentation at a small size.")) |
693 | |
694 | (define as:image |
695 | (make-as-property |
696 | "image" "Object" '("Image" "Link") |
697 | #:comment |
698 | "Indicates an entity that describes an image for this object. Unlike the |
699 | icon property, there are no aspect ratio or display size limitations assumed.")) |
700 | |
701 | (define as:inReplyTo |
702 | (make-as-property |
703 | "inReplyTo" "Object" '("Object" "Link") |
704 | #:comment |
705 | "Indicates one or more entities for which this object is considered a |
706 | response.")) |
707 | |
708 | (define as:instrument |
709 | (make-as-property |
710 | "instrument" "Activity" '("Object" "Link") |
711 | #:comment |
712 | "Identifies one or more objects used (or to be used) in the completion of |
713 | an Activity.")) |
714 | |
715 | (define as:last |
716 | (make-as-property |
717 | "last" "Collection" '("CollectionPage" "Link") |
718 | #:functional? #t |
719 | #:comment |
720 | "")) |
721 | |
722 | (define as:location |
723 | (make-as-property |
724 | "location" "Object" '("Object" "Link") |
725 | #:comment |
726 | "Indicates one or more physical or logical locations associated with the |
727 | object.")) |
728 | |
729 | (define as:items |
730 | (make-as-property |
731 | "items" "Collection" '("Object" "Link") |
732 | #:comment |
733 | "Identifies the items contained in a collection. The items might be ordered |
734 | or unordered.")) |
735 | |
736 | (define as:oneOf |
737 | (make-as-property |
738 | "oneOf" "Question" '("Object" "Link") |
739 | #:comment |
740 | "Identifies an exclusive option for a Question. Use of oneOf implies that |
741 | the Question can have only a single answer. To indicate that a Question can |
742 | have multiple answers, use anyOf.")) |
743 | |
744 | (define as:anyOf |
745 | (make-as-property |
746 | "oneOf" "Question" '("Object" "Link") |
747 | #:comment |
748 | "Identifies an inclusive option for a Question. Use of anyOf implies that |
749 | the Question can have multiple answers. To indicate that a Question can have |
750 | only one answer, use oneOf.")) |
751 | |
752 | (define as:closed |
753 | (make-as-property |
754 | "closed" "Question" '("Object" "Link" date? boolean?) |
755 | #:comment |
756 | "Indicates that a question has been closed, and answers are no longer |
757 | accepted.")) |
758 | |
759 | (define as:origin |
760 | (make-as-property |
761 | "origin" "Activity" '("Object" "Link") |
762 | #:comment |
763 | "Describes an indirect object of the activity from which the activity is |
764 | directed. The precise meaning of the origin is the object of the English |
765 | preposition ``from''. For instance, in the activity ``John moved an item to |
766 | List B from List A'', the origin of the activity is ``List A''.")) |
767 | |
768 | (define as:next |
769 | (make-as-property |
770 | "next" "CollectionPage" '("CollectionPage" "Link") |
771 | #:functional? #t |
772 | #:comment |
773 | "In a paged Collection, indicates the next page of items.")) |
774 | |
775 | (define as:object |
776 | (make-as-property |
777 | "object" '("Activity" "Relationship") '("Object" "Link") |
778 | #:comment |
779 | "When used within an Activity, describes the direct object of the activity. |
780 | For instance, in the activity ``John added a movie to his wishlist'', the |
781 | object of the activity is the movie added. When used within a Relationship |
782 | describes the entity to which the subject is related.")) |
783 | |
784 | (define as:prev |
785 | (make-as-property |
786 | "prev" "CollectionPage" '("CollectionPage" "Link") |
787 | #:functional? #t |
788 | #:comment |
789 | "In a paged Collection, identifies the previous page of items.")) |
790 | |
791 | (define as:preview |
792 | (make-as-property |
793 | "preview" '("Object" "Link") '("Object" "Link") |
794 | #:comment |
795 | "Identifies an entity that provides a preview of this object.")) |
796 | |
797 | (define as:result |
798 | (make-as-property |
799 | "result" "Activity" '("Object" "Link") |
800 | #:comment |
801 | "Describes the result of the activity. For instance, if a particular |
802 | action results in the creation of a new resource, the result property can be |
803 | used to describe that new resource.")) |
804 | |
805 | (define as:replies |
806 | (make-as-property |
807 | "replise" "Object" "Collection" |
808 | #:functional? #t |
809 | #:comment |
810 | "Identifies a Collection containing objects considered to be responses to |
811 | this object.")) |
812 | |
813 | (define as:tag |
814 | (make-as-property |
815 | "tag" "Object" '("Object" "Link") |
816 | #:comment |
817 | "One or more ``tags'' that have been associated with an object. A tag can |
818 | be any kind of Object. The key difference between attachment and tag is that |
819 | the former implies association by inclusion, while the latter implies |
820 | associated by reference.")) |
821 | |
822 | (define as:target |
823 | (make-as-property |
824 | "target" "Activity" '("Object" "Link") |
825 | #:comment |
826 | "Describes the indirect object, or target, of the activity. The precise |
827 | meaning of the target is largely dependent on the type of action being |
828 | described but will often be the object of the English preposition ``to''. For |
829 | instance, in the activity ``John added a movie to his wishlist'', the target |
830 | of the activity is John's wishlist. An activity can have more than one target.")) |
831 | |
832 | (define as:to |
833 | (make-as-property |
834 | "to" "Object" '("Object" "Link") |
835 | #:comment |
836 | "Identifies an entity considered to be part of the public primary audience |
837 | of an Object.")) |
838 | |
839 | (define as:url |
840 | (make-as-property |
841 | "url" "Object" '(uri? "Link") |
842 | #:comment |
843 | "Identifies one or more links to representations of the object.")) |
844 | |
845 | (define as:accuracy |
846 | (make-as-property |
847 | "accuracy" "Place" float? |
848 | #:comment |
849 | "Indicates the accuracy of position coordinates on a Place objects. |
850 | Expressed in properties of percentage. e.g. ``94.0'' means ``94.0% accurate''.")) |
851 | |
852 | (define as:altitude |
853 | (make-as-property |
854 | "altitude" "Object" float? |
855 | #:functional? #t |
856 | #:comment |
857 | "Indicates the altitude of a place. The measurement units is indicated |
858 | using the units property. If units is not specified, the default is assumed |
859 | to be ``m'' indicating meters.")) |
860 | |
861 | (define as:content |
862 | (make-as-property |
863 | "content" "Object" string-or-lang-string? |
864 | #:comment |
865 | "The content or textual representation of the Object encoded as a JSON |
866 | string. By default, the value of content is HTML. The mediaType property can |
867 | be used in the object to indicate a different content type. The content MAY |
868 | be expressed using multiple language-tagged values.")) |
869 | |
870 | (define as:name |
871 | (make-as-property |
872 | "name" '("Object" "Link") string-or-lang-string? |
873 | #:comment |
874 | "A simple, human-readable, plain-text name for the object. HTML markup |
875 | MUST NOT be included. The name MAY be expressed using multiple language-tagged |
876 | values.")) |
877 | |
878 | (define as:duration |
879 | (make-as-property |
880 | "duration" "Object" duration? |
881 | #:functional? #t |
882 | #:comment |
883 | "When the object describes a time-bound resource, such as an audio or video, |
884 | a meeting, etc, the duration property indicates the object's approximate |
885 | duration. The value MUST be expressed as an xsd:duration as defined by |
886 | [xmlschema11-2], section 3.3.6 (e.g. a period of 5 seconds is represented as |
887 | ``PT5S'').")) |
888 | |
889 | (define as:height |
890 | (make-as-property |
891 | "height" "Link" non-negative-integer? |
892 | #:functional? #t |
893 | #:comment |
894 | "On a Link, specifies a hint as to the rendering height in device-independent |
895 | pixels of the linked resource.")) |
896 | |
897 | (define as:href |
898 | (make-as-property |
899 | "href" "Link" uri? |
900 | #:functional? #t |
901 | #:comment |
902 | "The target resource pointed to by a Link.")) |
903 | |
904 | (define as:hreflang |
905 | (make-as-property |
906 | "hreflang" "Link" langtag? |
907 | #:functional? #t |
908 | #:comment |
909 | "Hints as to the language used by the target resource. Value MUST be a |
910 | [BCP47] Language-Tag.")) |
911 | |
912 | (define as:partOf |
913 | (make-as-property |
914 | "partOf" "CollectionPage" '("Collection" "Link") |
915 | #:functional? #t |
916 | #:comment |
917 | "Identifies the Collection to which a CollectionPage objects items belong.")) |
918 | |
919 | (define as:latitude |
920 | (make-as-property |
921 | "latitude" "Place" float? |
922 | #:functional? #t |
923 | #:comment |
924 | "The latitude of a place.")) |
925 | |
926 | (define as:longitude |
927 | (make-as-property |
928 | "longitude" "Place" float? |
929 | #:functional? #t |
930 | #:comment |
931 | "The longitude of a place.")) |
932 | |
933 | (define as:mediaType |
934 | (make-as-property |
935 | "mediaType" '("Link" "Object") mime-type? |
936 | #:functional? #t |
937 | #:comment |
938 | "When used on a Link, identifies the MIME media type of the referenced |
939 | resource. When used on an Object, identifies the MIME media type of the value |
940 | of the content property. If not specified, the content property is assumed to |
941 | contain text/html content.")) |
942 | |
943 | (define as:endTime |
944 | (make-as-property |
945 | "endTime" "Object" date? |
946 | #:functional? #t |
947 | #:comment |
948 | "The date and time describing the actual or expected ending time of the |
949 | object. When used with an Activity object, for instance, the endTime property |
950 | specifies the moment the activity concluded or is expected to conclude.")) |
951 | |
952 | (define as:published |
953 | (make-as-property |
954 | "published" "Object" date? |
955 | #:functional? #t |
956 | #:comment |
957 | "The date and time at which the object was published.")) |
958 | |
959 | (define as:startTime |
960 | (make-as-property |
961 | "startTime" "Object" date? |
962 | #:functional? #t |
963 | #:comment |
964 | "The date and time describing the actual or expected starting time of the |
965 | object. When used with an Activity object, for instance, the startTime |
966 | property specifies the moment the activity began or is scheduled to begin.")) |
967 | |
968 | (define as:radius |
969 | (make-as-property |
970 | "radius" "Place" float? |
971 | #:functional? #t |
972 | #:comment |
973 | "The radius from the given latitude and longitude for a Place. The units |
974 | is expressed by the units property. If units is not specified, the default is |
975 | assumed to be ``m'' indicating ``meters''.")) |
976 | |
977 | (define as:rel |
978 | (make-as-property |
979 | "rel" "Link" link-relation? |
980 | #:comment |
981 | "A link relation associated with a Link. The value MUST conform to both the |
982 | [HTML5] and [RFC5988] ``link relation'' definitions. In the [HTML5], any |
983 | string not containing the ``space'' U+0020, ``tab'' (U+0009), ``LF'' (U+000A), |
984 | ``FF'' (U+000C), ``CR'' (U+000D) or ``,'' (U+002C) characters can be used as a |
985 | valid link relation.")) |
986 | |
987 | (define as:startIndex |
988 | (make-as-property |
989 | "startIndex" "OrderedCollectionPage" non-negative-integer? |
990 | #:functional? #t |
991 | #:comment |
992 | "A non-negative integer value identifying the relative position within the |
993 | logical view of a strictly ordered collection.")) |
994 | |
995 | (define as:summary |
996 | (make-as-property |
997 | "summary" "Object" string-or-lang-string? |
998 | #:comment |
999 | "A natural language summarization of the object encoded as HTML. Multiple |
1000 | language tagged summaries MAY be provided.")) |
1001 | |
1002 | (define as:totalItems |
1003 | (make-as-property |
1004 | "totalItems" "Collection" non-negative-integer? |
1005 | #:functional? #t |
1006 | #:comment |
1007 | "A non-negative integer specifying the total number of objects contained by |
1008 | the logical view of the collection. This number might not reflect the actual |
1009 | number of items serialized within the Collection object instance.")) |
1010 | |
1011 | (define as:units |
1012 | (make-as-property |
1013 | "units" "Place" (list uri? (lambda (s) (member s '("cm" "feet" "inches" "km" |
1014 | "m" "miles")))) |
1015 | #:functional? #t |
1016 | #:comment |
1017 | "Specifies the measurement units for the radius and altitude properties on |
1018 | a Place object. If not specified, the default is assumed to be ``m'' for |
1019 | ``meters''.")) |
1020 | |
1021 | (define as:updated |
1022 | (make-as-property |
1023 | "updated" "Object" date? |
1024 | #:functional? #t |
1025 | #:comment |
1026 | "The date and time at which the object was updated.")) |
1027 | |
1028 | (define as:width |
1029 | (make-as-property |
1030 | "width" "Link" non-negative-integer? |
1031 | #:functional? #t |
1032 | #:comment |
1033 | "On a Link, specifies a hint as to the rendering width in device-independent |
1034 | pixels of the linked resource.")) |
1035 | |
1036 | (define as:subject |
1037 | (make-as-property |
1038 | "subject" "Relationship" '("Link" "Object") |
1039 | #:functional? #t |
1040 | #:comment |
1041 | "On a Relationship object, the subject property identifies one of the |
1042 | connected individuals. For instance, for a Relationship object describing |
1043 | ``John is related to Sally'', subject would refer to John.")) |
1044 | |
1045 | (define as:relationship |
1046 | (make-as-property |
1047 | "relationship" "Relationship" "Object" |
1048 | #:comment |
1049 | "On a Relationship object, the relationship property identifies the kind of |
1050 | relationship that exists between subject and object.")) |
1051 | |
1052 | (define as:describes |
1053 | (make-as-property |
1054 | "describes" "Profile" "Object" |
1055 | #:functional? #t |
1056 | #:comment |
1057 | "On a Profile object, the describes property identifies the object described |
1058 | by the Profile.")) |
1059 | |
1060 | (define as:formerType |
1061 | (make-as-property |
1062 | "formerType" "Tombstone" "Object" |
1063 | #:comment |
1064 | "On a Tombstone object, the formerType property identifies the type of the |
1065 | object that was deleted.")) |
1066 | |
1067 | (define as:deleted |
1068 | (make-as-property |
1069 | "deleted" "Tombstone" date? |
1070 | #:functional? #t |
1071 | #:comment |
1072 | "On a Tombstone object, the deleted property is a timestamp for when the |
1073 | object was deleted.")) |
1074 | |
1075 | (define as-properties |
1076 | (list as:actor as:attachment as:attributedTo as:audience as:bcc as:bto |
1077 | as:cc as:context as:current as:first as:generator as:icon as:id |
1078 | as:image as:inReplyTo as:instrument as:last as:location as:items |
1079 | as:oneOf as:anyOf as:closed as:origin as:next as:object as:prev |
1080 | as:preview as:result as:replies as:tag as:target as:to as:type |
1081 | as:url as:accuracy as:altitude as:content as:name as:duration |
1082 | as:height as:href as:hreflang as:partOf as:latitude as:longitude |
1083 | as:mediaType as:endTime as:published as:startTime as:radius |
1084 | as:rel as:startIndex as:summary as:totalItems as:units as:updated |
1085 | as:width as:subject as:relationship as:describes as:formerType |
1086 | as:deleted)) |
1087 | |
1088 | (define activitystreams-ontology |
1089 | (append as-core-types as-activity-types as-actor-types as-object-and-link-types |
1090 | as-properties)) |
1091 | |
1092 |