Schema.hs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  1. {-# LANGUAGE Rank2Types #-}
  2. {-# LANGUAGE OverloadedStrings #-}
  3. {-# LANGUAGE TemplateHaskell #-}
  4. {-|
  5. Module : Codec.ActivityStream.Schema
  6. Description : An interface to the Activity Streams Base Schema
  7. Copyright : (c) Getty Ritter, 2014
  8. Maintainer : gdritter@galois.com
  9. This is an interface to the extended ActivityStreams schema which defines
  10. an extensive set of @verb@ values, additional @objectType@ values, and a
  11. set of extended properties for 'Object's.
  12. Most of the inline documentation is drawn directly from the
  13. <https://github.com/activitystreams/activity-schema/blob/master/activity-schema.md Activity Base Schema draft>
  14. specification, with minor modifications
  15. to refer to the corresponding data types in this module and to clarify
  16. certain aspects. This is not an approved draft, and as such may be
  17. subject to changes which will be reflected in this module. In contrast to
  18. "Codec.ActivityStream", the API in this module makes
  19. __no guarantees about long-term stability__.
  20. -}
  21. module Codec.ActivityStream.Schema
  22. ( module Codec.ActivityStream
  23. -- * Verbs
  24. , SchemaVerb(..)
  25. -- * Object Types
  26. , SchemaObjectType(..)
  27. -- ** Audio/Video
  28. , avEmbedCode
  29. , avStream
  30. -- ** Binary
  31. , bnCompression
  32. , bnData
  33. , bnFileUrl
  34. , bnLength
  35. , bnMd5
  36. , bnMimeType
  37. -- ** Event
  38. , evAttendedBy
  39. , evAttending
  40. , evEndTime
  41. , evInvited
  42. , evMaybeAttending
  43. , evNotAttendedBy
  44. , evNotAttending
  45. , evStartTime
  46. -- ** Issue
  47. , isTypes
  48. -- ** Permission
  49. , pmScope
  50. , pmActions
  51. -- ** Place
  52. , plPosition
  53. , plAddress
  54. -- *** PlacePosition
  55. , PlacePosition
  56. -- *** PlaceAddress
  57. , PlaceAddress
  58. -- ** Role/Group
  59. , rlMembers
  60. -- ** Task
  61. , tsActor
  62. , tsBy
  63. , tsObject
  64. , tsPrerequisites
  65. , tsRequired
  66. , tsSupersedes
  67. , tsVerb
  68. -- * Basic Extension Properties
  69. , acContext
  70. , getLocation
  71. , oMood
  72. , oRating
  73. , acResult
  74. , getSource
  75. , getStartTime
  76. , getEndTime
  77. , oTags
  78. -- * Mood
  79. , Mood
  80. , moodRest
  81. , moodDisplayName
  82. , moodImage
  83. ) where
  84. import qualified Data.Aeson as Aeson
  85. import Data.Aeson.TH (deriveJSON)
  86. import Data.DateTime (DateTime)
  87. import Data.Aeson ( FromJSON(..), ToJSON(..) )
  88. import qualified Data.HashMap.Strict as HM
  89. import Data.Text (Text)
  90. import Codec.ActivityStream.Internal
  91. import Codec.ActivityStream.LensInternal
  92. import Codec.ActivityStream
  93. -- | The ActivityStreams Base Schema specification defines the
  94. -- following core verbs in addition to the default post verb that is
  95. -- defined in Section 6 of activitystreams:
  96. data SchemaVerb
  97. = Accept
  98. -- ^ Indicates that that the actor has accepted the object.
  99. -- For instance, a person accepting an award, or accepting an assignment.
  100. | Access
  101. -- ^ Indicates that the actor has accessed the object. For
  102. -- instance, a person accessing a room, or accessing a file.
  103. | Acknowledge
  104. -- ^ Indicates that the actor has acknowledged the object.
  105. -- This effectively signals that the actor is aware of the
  106. -- object's existence.
  107. | Add
  108. -- ^ Indicates that the actor has added the object to the target.
  109. -- For instance, adding a photo to an album.
  110. | Agree
  111. -- ^ Indicates that the actor agrees with the object. For example,
  112. -- a person agreeing with an argument, or expressing agreement
  113. -- with a particular issue.
  114. | Append
  115. -- ^ Indicates that the actor has appended the object to the
  116. -- target. For instance, a person appending a new record
  117. -- to a database.
  118. | Approve
  119. -- ^ Indicates that the actor has approved the object. For
  120. -- instance, a manager might approve a travel request.
  121. | Archive
  122. -- ^ Indicates that the actor has archived the object.
  123. | Assign
  124. -- ^ Indicates that the actor has assigned the object to the target.
  125. | At
  126. -- ^ Indicates that the actor is currently located at the object.
  127. -- For instance, a person being at a specific physical location.
  128. | Attach
  129. -- ^ Indicates that the actor has attached the object to the
  130. -- target. For instance, a person attaching a file to a wiki
  131. -- page or an email.
  132. | Attend
  133. -- ^ Indicates that the actor has attended the object. For
  134. -- instance, a person attending a meeting.
  135. | Author
  136. -- ^ Indicates that the actor has authored the object. Note that
  137. -- this is a more specific form of the verb \"create\".
  138. | Authorize
  139. -- ^ Indicates that the actor has authorized the object. If
  140. -- a target is specified, it means that the authorization is specifically
  141. -- in regards to the target. For instance, a service can authorize a
  142. -- person to access a given application; in which case the actor is
  143. -- the service, the object is the person, and the target is the
  144. -- application. In contrast, a person can authorize a request; in
  145. -- which case the actor is the person and the object is the request
  146. -- and there might be no explicit target.
  147. | Borrow
  148. -- ^ Indicates that the actor has borrowed the object. If a target
  149. -- is specified, it identifies the entity from which the object was
  150. -- borrowed. For instance, if a person borrows a book from a library,
  151. -- the person is the actor, the book is the object and the library is
  152. -- the target.
  153. | Build
  154. -- ^ Indicates that the actor has built the object. For example, if a
  155. -- person builds a model or compiles code.
  156. | Cancel
  157. -- ^ Indicates that the actor has canceled the object. For instance,
  158. -- canceling a calendar event.
  159. | Close
  160. -- ^ Indicates that the actor has closed the object. For instance, the
  161. -- object could represent a ticket being tracked in an issue management
  162. -- system.
  163. | Complete
  164. -- ^ Indicates that the actor has completed the object.
  165. | Confirm
  166. -- ^ Indicates that the actor has confirmed or agrees with the object.
  167. -- For instance, a software developer might confirm an issue reported
  168. -- against a product.
  169. | Consume
  170. -- ^ Indicates that the actor has consumed the object. The specific
  171. -- meaning is dependent largely on the object's type. For instance,
  172. -- an actor may \"consume\" an audio object, indicating that the actor
  173. -- has listened to it; or an actor may \"consume\" a book, indicating
  174. -- that the book has been read. As such, the \"consume\" verb is a
  175. -- more generic form of other more specific verbs such as \"read\" and
  176. -- \"play\".
  177. | Checkin
  178. -- ^ Indicates that the actor has checked-in to the object. For
  179. -- instance, a person checking-in to a Place.
  180. | Create
  181. -- ^ Indicates that the actor has created the object.
  182. | Delete
  183. -- ^ Indicates that the actor has deleted the object. This implies,
  184. -- but does not require, the permanent destruction of the object.
  185. | Deliver
  186. -- ^ Indicates that the actor has delivered the object. For example,
  187. -- delivering a package.
  188. | Deny
  189. -- ^ Indicates that the actor has denied the object. For example, a
  190. -- manager may deny a travel request.
  191. | Disagree
  192. -- ^ Indicates that the actor disagrees with the object.
  193. | Dislike
  194. -- ^ Indicates that the actor dislikes the object. Note that the
  195. -- \"dislike\" verb is distinct from the \"unlike\" verb which assumes
  196. -- that the object had been previously \"liked\".
  197. | Experience
  198. -- ^ Indicates that the actor has experienced the object in some
  199. -- manner. Note that, depending on the specific object types used for
  200. -- both the actor and object, the meaning of this verb can overlap
  201. -- that of the \"consume\" and \"play\" verbs. For instance, a person
  202. -- might \"experience\" a movie; or \"play\" the movie; or \"consume\"
  203. -- the movie. The \"experience\" verb can be considered a more generic
  204. -- form of other more specific verbs as \"consume\", \"play\", \"watch\",
  205. -- \"listen\", and \"read\"
  206. | Favorite
  207. -- ^ Indicates that the actor marked the object as an item of special
  208. -- interest.
  209. | Find
  210. -- ^ Indicates that the actor has found the object.
  211. | FlagAsInappropriate
  212. -- ^ Indicates that the actor has flagged the object as being
  213. -- inappropriate for some reason. When using this verb, the context
  214. -- property can be used to provide additional detail about why the
  215. -- object has been flagged.
  216. | Follow
  217. -- ^ Indicates that the actor began following the activity of the
  218. -- object. In most cases, the objectType will be a \"person\", but it
  219. -- can potentially be of any type that can sensibly generate activity.
  220. -- Processors MAY ignore (silently drop) successive identical \"follow\"
  221. -- activities.
  222. | Give -- ^ Indicates that the actor is giving an object to the
  223. -- target. Examples include one person giving a badge object to another
  224. -- person. The object identifies the object being given. The target
  225. -- identifies the receiver.
  226. | Host
  227. -- ^ Indicates that the actor is hosting the object. As in hosting
  228. -- an event, or hosting a service.
  229. | Ignore
  230. -- ^ Indicates that the actor has ignored the object. For
  231. -- instance, this verb may be used when an actor has ignored a friend
  232. -- request, in which case the object may be the request-friend activity.
  233. | Insert
  234. -- ^ Indicates that the actor has inserted the object into the target.
  235. | Install
  236. -- ^ Indicates that the actor has installed the object, as in installing
  237. -- an application.
  238. | Interact
  239. -- ^ Indicates that the actor has interacted with the object. For
  240. -- instance, when one person interacts with another.
  241. | Invite
  242. -- ^ Indicates that the actor has invited the object, typically a
  243. -- person object, to join or participate in the object described
  244. -- by the target. The target could, for instance, be an event,
  245. -- group or a service.
  246. | Join
  247. -- ^ Indicates that the actor has become a member of the
  248. -- object. This specification only defines the meaning of this
  249. -- verb when the object of the Activity has an objectType of
  250. -- group, though implementors need to be prepared to handle other
  251. -- types of objects.
  252. | Leave
  253. -- ^ Indicates that the actor has left the object. For instance, a
  254. -- Person leaving a Group or checking-out of a Place.
  255. | Like
  256. -- ^ Indicates that the actor marked the object as an item of
  257. -- special interest. The \"like\" verb is considered to be an alias
  258. -- of \"favorite\". The two verb are semantically identical.
  259. | Listen
  260. -- ^ Indicates that the actor has listened to the object. This is
  261. -- typically only applicable for objects representing audio
  262. -- content, such as music, an audio-book, or a radio
  263. -- broadcast. The \"listen\" verb is a more specific form of the
  264. -- \"consume\", \"experience\" and \"play\" verbs.
  265. | Lose
  266. -- ^ Indicates that the actor has lost the object. For instance,
  267. -- if a person loses a game.
  268. | MakeFriend
  269. -- ^ Indicates the creation of a friendship that is reciprocated
  270. -- by the object. Since this verb implies an activity on the part
  271. -- of its object, processors MUST NOT accept activities with this
  272. -- verb unless they are able to verify through some external means
  273. -- that there is in fact a reciprocated connection. For example, a
  274. -- processor may have received a guarantee from a particular
  275. -- publisher that the publisher will only use this Verb in cases
  276. -- where a reciprocal relationship exists.
  277. | Open
  278. -- ^ Indicates that the actor has opened the object. For instance,
  279. -- the object could represent a ticket being tracked in an issue
  280. -- management system.
  281. | Play
  282. -- ^ Indicates that the actor spent some time enjoying the
  283. -- object. For example, if the object is a video this indicates
  284. -- that the subject watched all or part of the video. The \"play\"
  285. -- verb is a more specific form of the \"consume\" verb.
  286. | Post
  287. -- ^ The default action.
  288. | Present
  289. -- ^ Indicates that the actor has presented the object. For
  290. -- instance, when a person gives a presentation at a conference.
  291. | Purchase
  292. -- ^ Indicates that the actor has purchased the object. If a
  293. -- target is specified, in indicates the entity from which the
  294. -- object was purchased.
  295. | Qualify
  296. -- ^ Indicates that the actor has qualified for the object. If a
  297. -- target is specified, it indicates the context within which the
  298. -- qualification applies.
  299. | Read
  300. -- ^ Indicates that the actor read the object. This is typically
  301. -- only applicable for objects representing printed or written
  302. -- content, such as a book, a message or a comment. The \"read\"
  303. -- verb is a more specific form of the \"consume\", \"experience\" and
  304. -- \"play\" verbs.
  305. | Receive
  306. -- ^ Indicates that the actor is receiving an object. Examples
  307. -- include a person receiving a badge object. The object
  308. -- identifies the object being received.
  309. | Reject
  310. -- ^ Indicates that the actor has rejected the object.
  311. | Remove
  312. -- ^ Indicates that the actor has removed the object from the target.
  313. | RemoveFriend
  314. -- ^ Indicates that the actor has removed the object from the
  315. -- collection of friends.
  316. | Replace
  317. -- ^ Indicates that the actor has replaced the target with the object.
  318. | Request
  319. -- ^ Indicates that the actor has requested the object. If a
  320. -- target is specified, it indicates the entity from which the
  321. -- object is being requested.
  322. | RequestFriend
  323. -- ^ Indicates the creation of a friendship that has not yet been
  324. -- reciprocated by the object.
  325. | Resolve
  326. -- ^ Indicates that the actor has resolved the object. For
  327. -- instance, the object could represent a ticket being tracked in
  328. -- an issue management system.
  329. | Return
  330. -- ^ Indicates that the actor has returned the object. If a target
  331. -- is specified, it indicates the entity to which the object was
  332. -- returned.
  333. | Retract
  334. -- ^ Indicates that the actor has retracted the object. For
  335. -- instance, if an actor wishes to retract a previously published
  336. -- activity, the object would be the previously published activity
  337. -- that is being retracted.
  338. | RsvpMaybe
  339. -- ^ The \"possible RSVP\" verb indicates that the actor has made a
  340. -- possible RSVP for the object. This specification only defines
  341. -- the meaning of this verb when its object is an event, though
  342. -- implementors need to be prepared to handle other object
  343. -- types. The use of this verb is only appropriate when the RSVP
  344. -- was created by an explicit action by the actor. It is not
  345. -- appropriate to use this verb when a user has been added as an
  346. -- attendee by an event organiser or administrator.
  347. | RsvpNo
  348. -- ^ The \"negative RSVP\" verb indicates that the actor has made a
  349. -- negative RSVP for the object. This specification only defines
  350. -- the meaning of this verb when its object is an event, though
  351. -- implementors need to be prepared to handle other object
  352. -- types. The use of this verb is only appropriate when the RSVP
  353. -- was created by an explicit action by the actor. It is not
  354. -- appropriate to use this verb when a user has been added as an
  355. -- attendee by an event organiser or administrator.
  356. | RsvpYes
  357. -- ^ The \"positive RSVP\" verb indicates that the actor has made a
  358. -- positive RSVP for an object. This specification only defines
  359. -- the meaning of this verb when its object is an event, though
  360. -- implementors need to be prepared to handle other object
  361. -- types. The use of this verb is only appropriate when the RSVP
  362. -- was created by an explicit action by the actor. It is not
  363. -- appropriate to use this verb when a user has been added as an
  364. -- attendee by an event organiser or administrator.
  365. | Satisfy
  366. -- ^ Indicates that the actor has satisfied the object. If a
  367. -- target is specified, it indicate the context within which the
  368. -- object was satisfied. For instance, if a person satisfies the
  369. -- requirements for a particular challenge, the person is the
  370. -- actor; the requirement is the object; and the challenge is the
  371. -- target.
  372. | Save
  373. -- ^ Indicates that the actor has called out the object as being
  374. -- of interest primarily to him- or herself. Though this action
  375. -- MAY be shared publicly, the implication is that the object has
  376. -- been saved primarily for the actor's own benefit rather than to
  377. -- show it to others as would be indicated by the \"share\" verb.
  378. | Schedule
  379. -- ^ Indicates that the actor has scheduled the object. For
  380. -- instance, scheduling a meeting.
  381. | Search
  382. -- ^ Indicates that the actor is or has searched for the
  383. -- object. If a target is specified, it indicates the context
  384. -- within which the search is or has been conducted.
  385. | Sell
  386. -- ^ Indicates that the actor has sold the object. If a target is
  387. -- specified, it indicates the entity to which the object was
  388. -- sold.
  389. | Send
  390. -- ^ Indicates that the actor has sent the object. If a target is
  391. -- specified, it indicates the entity to which the object was
  392. -- sent.
  393. | Share
  394. -- ^ Indicates that the actor has called out the object to
  395. -- readers. In most cases, the actor did not create the object
  396. -- being shared, but is instead drawing attention to it.
  397. | Sponsor
  398. -- ^ Indicates that the actor has sponsored the object. If a
  399. -- target is specified, it indicates the context within which the
  400. -- sponsorship is offered. For instance, a company can sponsor an
  401. -- event; or an individual can sponsor a project; etc.
  402. | Start
  403. -- ^ Indicates that the actor has started the object. For
  404. -- instance, when a person starts a project.
  405. | StopFollowing
  406. -- ^ Indicates that the actor has stopped following the object.
  407. | Submit
  408. -- ^ Indicates that the actor has submitted the object. If a
  409. -- target is specified, it indicates the entity to which the
  410. -- object was submitted.
  411. | Tag
  412. -- ^ Indicates that the actor has associated the object with the
  413. -- target. For example, if the actor specifies that a particular
  414. -- user appears in a photo. the object is the user and the target
  415. -- is the photo.
  416. | Terminate
  417. -- ^ Indicates that the actor has terminated the object.
  418. | Tie
  419. -- ^ Indicates that the actor has neither won or lost the
  420. -- object. This verb is generally only applicable when the object
  421. -- represents some form of competition, such as a game.
  422. | Unfavorite
  423. -- ^ Indicates that the actor has removed the object from the
  424. -- collection of favorited items.
  425. | Unlike
  426. -- ^ Indicates that the actor has removed the object from the
  427. -- collection of liked items.
  428. | Unsatisfy
  429. -- ^ Indicates that the actor has not satisfied the object. If a
  430. -- target is specified, it indicates the context within which the
  431. -- object was not satisfied. For instance, if a person fails to
  432. -- satisfy the requirements of some particular challenge, the
  433. -- person is the actor; the requirement is the object and the
  434. -- challenge is the target.
  435. | Unsave
  436. -- ^ Indicates that the actor has removed the object from the
  437. -- collection of saved items.
  438. | Unshare
  439. -- ^ Indicates that the actor is no longer sharing the object. If
  440. -- a target is specified, it indicates the entity with whom the
  441. -- object is no longer being shared.
  442. | Update
  443. -- ^ The \"update\" verb indicates that the actor has modified the
  444. -- object. Use of the \"update\" verb is generally reserved to
  445. -- indicate modifications to existing objects or data such as
  446. -- changing an existing user's profile information.
  447. | Use
  448. -- ^ Indicates that the actor has used the object in some manner.
  449. | Watch
  450. -- ^ Indicates that the actor has watched the object. This verb is
  451. -- typically applicable only when the object represents dynamic,
  452. -- visible content such as a movie, a television show or a public
  453. -- performance. This verb is a more specific form of the verbs
  454. -- \"experience\", \"play\" and \"consume\".
  455. | Win
  456. -- ^ Indicates that the actor has won the object. This verb is
  457. -- typically applicable only when the object represents some form
  458. -- of competition, such as a game.
  459. deriving (Eq, Show, Read)
  460. deriveJSON (commonOptsCC "") ''SchemaVerb
  461. -- | This data type contains the core set of common objectTypes in addition
  462. -- to the "activity" objectType defined in Section 7 of
  463. -- activitystreams.
  464. --
  465. -- All Activity Stream Objects inherit the same
  466. -- fundamental set of basic properties as defined in section 3.4 of
  467. -- activitystreams. In addition to these, objects of any specific type
  468. -- are permitted to introduce additional optional or required
  469. -- properties that are meaningful to objects of that type.
  470. data SchemaObjectType
  471. = Alert
  472. -- ^ Represents any kind of significant notification.
  473. | Application
  474. -- ^ Represents any kind of software application.
  475. | Article
  476. -- ^ Represents objects such as news articles, knowledge base
  477. -- entries, or other similar construct. Such objects generally
  478. -- consist of paragraphs of text, in some cases incorporating
  479. -- embedded media such as photos and inline hyperlinks to other
  480. -- resources.
  481. | Audio
  482. -- ^ Represents audio content of any kind. Objects of this type
  483. -- MAY contain an additional property as specified
  484. -- <https://github.com/activitystreams/activity-schema/blob/master/activity-schema.md#audio-video here>.
  485. | Badge
  486. -- ^ Represents a badge or award granted to an object (typically a
  487. -- @person@ object)
  488. | Binary
  489. -- ^ Objects of this type are used to carry arbirary
  490. -- Base64-encoded binary data within an Activity Stream object. It
  491. -- is primarily intended to attach binary data to other types of
  492. -- objects through the use of the @attachments@ property. Objects
  493. -- of this type will contain the additional properties specified
  494. -- <https://github.com/activitystreams/activity-schema/blob/master/activity-schema.md#binary here>.
  495. | Bookmark
  496. -- ^ Represents a pointer to some URL -- typically a web page. In
  497. -- most cases, bookmarks are specific to a given user and contain
  498. -- metadata chosen by that user. Bookmark Objects are similar in
  499. -- principle to the concept of bookmarks or favorites in a web
  500. -- browser. A bookmark represents a pointer to the URL, not the
  501. -- URL or the associated resource itself. Objects of this type
  502. -- SHOULD contain an additional @targetUrl@ property whose value
  503. -- is a String containing the IRI of the target of the bookmark.
  504. | Collection
  505. -- ^ Represents a generic collection of objects of any type. This
  506. -- object type can be used, for instance, to represent a
  507. -- collection of files like a folder; a collection of photos like
  508. -- an album; and so forth. Objects of this type MAY contain an
  509. -- additional @objectTypes@ property whose value is an Array of
  510. -- Strings specifying the expected objectType of objects contained
  511. -- within the collection.
  512. | Comment
  513. -- ^ Represents a textual response to another object. Objects of
  514. -- this type MAY contain an additional @inReplyTo@ property whose
  515. -- value is an Array of one or more other Activity Stream Objects
  516. -- for which the object is to be considered a response.
  517. | Device
  518. -- ^ Represents a device of any type.
  519. | Event
  520. -- ^ Represents an event that occurs at a certain location during
  521. -- a particular period of time. Objects of this type MAY contain
  522. -- the additional properties specified
  523. -- <https://github.com/activitystreams/activity-schema/blob/master/activity-schema.md#event here>.
  524. | File
  525. -- ^ Represents any form of document or file. Objects of this type
  526. -- MAY contain an additional @fileUrl@ property whose value a
  527. -- dereferenceable IRI that can be used to retrieve the file; and
  528. -- an additional @mimeType@ property whose value is the MIME type
  529. -- of the file described by the object.
  530. | Game
  531. -- ^ Represents a game or competition of any kind.
  532. | Group
  533. -- ^ Represents a grouping of objects in which member objects can
  534. -- join or leave. Objects of this type MAY contain the additional
  535. -- properties specified
  536. -- <https://github.com/activitystreams/activity-schema/blob/master/activity-schema.md#roleGroup here>.
  537. | Image
  538. -- ^ Represents a graphical image. Objects of this type MAY
  539. -- contain an additional @fullImage@ property whose value is an
  540. -- Activity Streams Media Link to a "full-sized" representation of
  541. -- the image.
  542. | Issue
  543. -- ^ Represents a report about a problem or situation that needs
  544. -- to be resolved. For instance, the @issue@ object can be used to
  545. -- represent reports detailing software defects, or reports of
  546. -- acceptable use violations, and so forth. Objects of this type
  547. -- MAY contain the additional properties specified
  548. -- <https://github.com/activitystreams/activity-schema/blob/master/activity-schema.md#issue here>.
  549. | Job
  550. -- ^ Represents information about a job or a job posting.
  551. | Note
  552. -- ^ Represents a short-form text message. This object is intended
  553. -- primarily for use in "micro-blogging" scenarios and in systems
  554. -- where users are invited to publish short, often plain-text
  555. -- messages whose useful lifespan is generally shorter than that
  556. -- of an article of weblog entry. A note is similar in structure
  557. -- to an article, but typically does not have a title or distinct
  558. -- paragraphs and tends to be much shorter in length.
  559. | Offer
  560. -- ^ Represents an offer of any kind.
  561. | Organization
  562. -- ^ Represents an organization of any kind.
  563. | Page
  564. -- ^ Represents an area, typically a web page, that is
  565. -- representative of, and generally managed by a particular
  566. -- entity. Such areas are usually dedicated to displaying
  567. -- descriptive information about the entity and showcasing recent
  568. -- content such as articles, photographs and videos. Most social
  569. -- networking applications, for example, provide individual users
  570. -- with their own dedicated "profile" pages. Several allow similar
  571. -- types of pages to be created for commercial entities,
  572. -- organizations or events. While the specific details of how
  573. -- pages are implemented, their characteristics and use may vary,
  574. -- the one unifying property is that they are typically "owned" by
  575. -- a single entity that is represented by the content provided by
  576. -- the page itself.
  577. | Permission
  578. -- ^ Represents a permission that can be granted to an
  579. -- individual. For instance, a person can be granted permission to
  580. -- modify a file. Objects of this type MAY contain the additional
  581. -- properties specified
  582. -- <https://github.com/activitystreams/activity-schema/blob/master/activity-schema.md#permissions here>.
  583. | Person
  584. -- ^ Represents an individual person.
  585. | Place
  586. -- ^ Represents a physical location. Locations can be represented
  587. -- using geographic coordinates, a physical address, a free-form
  588. -- location name, or any combination of these. Objects of this
  589. -- type MAY contain the additional properties specified
  590. -- <https://github.com/activitystreams/activity-schema/blob/master/activity-schema.md#place here>.
  591. | Process
  592. -- ^ Represents any form of process. For instance, a long-running
  593. -- task that is started and expected to continue operating for a
  594. -- period of time.
  595. | Product
  596. -- ^ Represents a commercial good or service. Objects of this type
  597. -- MAY contain an additional @fullImage@ property whose value is
  598. -- an Activity Streams Media Link to an image resource
  599. -- representative of the product.
  600. | Question
  601. -- ^ Represents a question or a poll. Objects of this type MAY
  602. -- contain an additional @options@ property whose value is an
  603. -- Array of possible answers to the question in the form of
  604. -- Activity Stream objects of any type.
  605. | Review
  606. -- ^ Represents a primarily prose-based commentary on another
  607. -- object. Objects of this type MAY contain a @rating@ property as
  608. -- specified
  609. -- <https://github.com/activitystreams/activity-schema/blob/master/activity-schema.md#rating-property here>.
  610. | Service
  611. -- ^ Represents any form of hosted or consumable service that
  612. -- performs some kind of work or benefit for other
  613. -- entities. Examples of such objects include websites,
  614. -- businesses, etc.
  615. | Task
  616. -- ^ Represents an activity that has yet to be completed. Objects
  617. -- of this type can contain additional properties as specified
  618. -- here.
  619. | Team
  620. -- ^ Represents a team of any type.
  621. | Video
  622. -- ^ Represents video content of any kind. Objects of this type
  623. -- MAY contain additional properties as specified here.
  624. deriving (Eq, Show, Read)
  625. deriveJSON (commonOptsCC "") ''SchemaObjectType
  626. -- audio/video
  627. -- | A fragment of HTML markup that, when embedded within another HTML
  628. -- page, provides an interactive user-interface for viewing or listening
  629. -- to the video or audio stream.
  630. avEmbedCode :: Lens' Object (Maybe Text)
  631. avEmbedCode = makeAesonLensMb "embedCode" oRest
  632. -- | An Activity Streams Media Link to the video or audio content itself.
  633. avStream :: Lens' Object (Maybe MediaLink)
  634. avStream = makeAesonLensMb "stream" oRest
  635. -- binary
  636. -- | An optional token identifying a compression algorithm applied to
  637. -- the binary data prior to Base64-encoding. Possible algorithms
  638. -- are "deflate" and "gzip", respectively indicating the use of
  639. -- the compression mechanisms defined by RFC 1951 and RFC 1952.
  640. -- Additional compression algorithms MAY be used but are not defined
  641. -- by this specification. Note that previous versions of this
  642. -- specification allowed for multiple compression algorithms to be
  643. -- applied and listed using a comma-separated format. The use of
  644. -- multiple compressions is no longer permitted.
  645. bnCompression :: Lens' Object (Maybe Text)
  646. bnCompression = makeAesonLensMb "compression" oRest
  647. -- | The URL-Safe Base64-encoded representation of the binary data
  648. bnData :: Lens' Object (Maybe Text)
  649. bnData = makeAesonLensMb "data" oRest
  650. -- | An optional IRI for the binary data described by this object.
  651. bnFileUrl :: Lens' Object (Maybe Text)
  652. bnFileUrl = makeAesonLensMb "fileUrl" oRest
  653. -- | The total number of unencoded, uncompressed octets contained
  654. -- within the "data" field.
  655. bnLength :: Lens' Object (Maybe Text)
  656. bnLength = makeAesonLensMb "length" oRest
  657. -- | An optional MD5 checksum calculated over the unencoded,
  658. -- uncompressed octets contained within the "data" field
  659. bnMd5 :: Lens' Object (Maybe Text)
  660. bnMd5 = makeAesonLensMb "md5" oRest
  661. -- | The MIME Media Type of the binary data contained within the object.
  662. bnMimeType :: Lens' Object (Maybe Text)
  663. bnMimeType = makeAesonLensMb "mimeType" oRest
  664. -- event
  665. -- | A collection object as defined in Section 3.5 of the JSON
  666. -- Activity Streams specification that provides information about
  667. -- entities that attended the event.
  668. evAttendedBy :: Lens' Object (Maybe Collection)
  669. evAttendedBy = makeAesonLensMb "attendedBy" oRest
  670. -- | A collection object as defined in Section 3.5 of the JSON
  671. -- Activity Streams specification that provides information about
  672. -- entities that intend to attend the event.
  673. evAttending :: Lens' Object (Maybe Collection)
  674. evAttending = makeAesonLensMb "attending" oRest
  675. -- | The date and time that the event ends represented as a String
  676. -- conforming to the "date-time" production in [RFC3339].
  677. evEndTime :: Lens' Object (Maybe DateTime)
  678. evEndTime = makeAesonLensMb "endTime" oRest
  679. -- | A collection object as defined in Section 3.5 of the JSON
  680. -- Activity Streams specification that provides information about
  681. -- entities that have been invited to the event.
  682. evInvited :: Lens' Object (Maybe Collection)
  683. evInvited = makeAesonLensMb "invited" oRest
  684. -- | A collection object as defined in Section 3.5 of the JSON
  685. -- Activity Streams specification that provides information about
  686. -- entities that possibly may attend the event.
  687. evMaybeAttending :: Lens' Object (Maybe Collection)
  688. evMaybeAttending = makeAesonLensMb "maybeAttending" oRest
  689. -- | A collection object as defined in Section 3.5 of the JSON
  690. -- Activity Streams specification that provides information about
  691. -- entities that did not attend the event.
  692. evNotAttendedBy :: Lens' Object (Maybe Collection)
  693. evNotAttendedBy = makeAesonLensMb "notAttendedBy" oRest
  694. -- | A collection object as defined in Section 3.5 of the JSON
  695. -- Activity Streams specification that provides information about
  696. -- entities that do not intend to attend the event.
  697. evNotAttending :: Lens' Object (Maybe Collection)
  698. evNotAttending = makeAesonLensMb "notAttending" oRest
  699. -- | The date and time that the event begins represented as a String
  700. -- confirming to the "date-time" production in RFC 3339.
  701. evStartTime :: Lens' Object (Maybe DateTime)
  702. evStartTime = makeAesonLensMb "startTime" oRest
  703. -- issue
  704. -- | An array of one or more absolute IRI's that describe the type of
  705. -- issue represented by the object. Note that the IRI's are intended
  706. -- for use as identifiers and MAY or MAY NOT be dereferenceable.
  707. isTypes :: Lens' Object (Maybe [Text])
  708. isTypes = makeAesonLensMb "types" oRest
  709. -- permission
  710. -- | A single Activity Streams Object, of any objectType, that
  711. -- identifies the scope of the permission. For example, if the
  712. -- permission objects describes write permissions for a given file,
  713. -- the scope property would be a file object describing that file.
  714. pmScope :: Lens' Object (Maybe Object)
  715. pmScope = makeAesonLensMb "scope" oRest
  716. -- | An array of Strings that identify the specific actions associated
  717. -- with the permission. The actions are application and scope
  718. -- specific. No common, core set of actions is defined by this
  719. -- specification.
  720. pmActions :: Lens' Object (Maybe [Text])
  721. pmActions = makeAesonLensMb "actions" oRest
  722. -- place
  723. -- | The latitude, longitude and altitude of the place as a point on
  724. -- Earth. Represented as a JSON Object as described below.
  725. plPosition :: Lens' Object (Maybe PlacePosition)
  726. plPosition = makeAesonLensMb "position" oRest
  727. -- | A physical address represented as a JSON object as described below.
  728. plAddress :: Lens' Object (Maybe PlaceAddress)
  729. plAddress = makeAesonLensMb "address" oRest
  730. newtype PlacePosition = PPO { fromPPO :: Aeson.Object } deriving (Eq, Show)
  731. instance FromJSON PlacePosition where
  732. parseJSON (Aeson.Object o) = do
  733. ensure "Position" o
  734. ["altitude", "latitude", "longitude"]
  735. return (PPO o)
  736. parseJSON _ = fail "\"Position\" not an object"
  737. instance ToJSON PlacePosition where
  738. toJSON = Aeson.Object . fromPPO
  739. newtype PlaceAddress = PAO { fromPAO :: Aeson.Object } deriving (Eq, Show)
  740. instance FromJSON PlaceAddress where
  741. parseJSON (Aeson.Object o) = do
  742. ensure "Address" o
  743. [ "formatted"
  744. , "streetAddress"
  745. , "locality"
  746. , "postalCode"
  747. , "country"
  748. ]
  749. return (PAO o)
  750. parseJSON _ = fail "Address not an object"
  751. instance ToJSON PlaceAddress where
  752. toJSON = Aeson.Object . fromPAO
  753. -- role/group
  754. -- | An optional Activity Streams Collection object listing the
  755. -- members of a group, or listing the entities assigned to a
  756. -- particular role.
  757. rlMembers :: Lens' Object (Maybe [Object])
  758. rlMembers = makeAesonLensMb "members" oRest
  759. -- Task
  760. -- | An Activity Streams Object that provides information about the
  761. -- actor that is expected to complete the task.
  762. tsActor :: Lens' Object (Maybe Object)
  763. tsActor = makeAesonLensMb "actor" oRest
  764. -- | A RFC 3339 date-time specifying the date and time by which the
  765. -- task is to be completed.
  766. tsBy :: Lens' Object (Maybe DateTime)
  767. tsBy = makeAesonLensMb "by" oRest
  768. -- | An Activity Streams object describing the object of the task.
  769. tsObject :: Lens' Object (Maybe Object)
  770. tsObject = makeAesonLensMb "object" oRest
  771. -- | An Array of other Task objects that are to be completed before
  772. -- this task can be completed.
  773. tsPrerequisites :: Lens' Object (Maybe [Object])
  774. tsPrerequisites = makeAesonLensMb "prerequisites" oRest
  775. -- | A boolean value indicating whether completion of this task is
  776. -- considered to be mandatory.
  777. tsRequired :: Lens' Object (Maybe Bool)
  778. tsRequired = makeAesonLensMb "required" oRest
  779. -- | An Array of other Task objects that are superseded by this task object.
  780. tsSupersedes :: Lens' Object (Maybe [Object])
  781. tsSupersedes = makeAesonLensMb "supersedes" oRest
  782. -- | A string indicating the verb for this task as defined in Section
  783. -- 3.2 of [activitystreams].
  784. tsVerb :: Lens' Object (Maybe SchemaVerb)
  785. tsVerb = makeAesonLensMb "verb" oRest
  786. -- extra properties
  787. -- | The additional @context@ property allows an 'Activity' to further
  788. -- include information about why a particular action occurred by
  789. -- providing details about the context within which a particular
  790. -- Activity was performed. The value of the @context@ property is an
  791. -- 'Object' of any @objectType@. The meaning of the @context@ property is
  792. -- only defined when used within an 'Activity' object.
  793. acContext :: Lens' Activity (Maybe Object)
  794. acContext = makeAesonLensMb "context" acRest
  795. -- | When appearing within an activity, the location data indicates
  796. -- the location where the activity occurred. When appearing within an
  797. -- object, the location data indicates the location of that object at
  798. -- the time the activity occurred.
  799. getLocation :: Lens' a Aeson.Object -> Lens' a (Maybe Object)
  800. getLocation = makeAesonLensMb "location"
  801. -- | Mood describes the mood of the user when the activity was
  802. -- performed. This is usually collected via an extra field in the user
  803. -- interface used to perform the activity. For the purpose of the
  804. -- schema, a mood is a freeform, short mood keyword or phrase along
  805. -- with an optional mood icon image.
  806. oMood :: Lens' Object (Maybe Mood)
  807. oMood = makeAesonLensMb "mood" oRest
  808. -- | A rating given as a number between 1.0 and 5.0 inclusive with one
  809. -- decimal place of precision. Represented in JSON as a property
  810. -- called @rating@ whose value is a JSON number giving the rating.
  811. oRating :: Lens' Object (Maybe Double)
  812. oRating = makeAesonLensMb "rating" oRest
  813. -- | The @result@ provides a description of the result of any particular
  814. -- activity. The value of the @result@ property is an Object of any
  815. -- objectType. The meaning of the @result@ property is only defined when
  816. -- used within an 'Activity' object.
  817. acResult :: Lens' Activity (Maybe Object)
  818. acResult = makeAesonLensMb "result" acRest
  819. -- | The @source@ property provides a reference to the original source of
  820. -- an object or activity. The value of the @source@ property is an
  821. -- Object of any objectType.
  822. --
  823. -- The @source@ property is closely related to
  824. -- the @generator@ and @provider@ properties but serves the distinct
  825. -- purpose of identifying where the activity or object was originally
  826. -- published as opposed to identifying the applications that generated
  827. -- or published it.
  828. getSource :: Lens' a Aeson.Object -> Lens' a (Maybe Object)
  829. getSource = makeAesonLensMb "source"
  830. -- | When an long running Activity occurs over a distinct period of
  831. -- time, or when an Object represents a long-running process or event,
  832. -- the @startTime@ propertiy can be used to specify the
  833. -- date and time at which the activity or object begins.
  834. -- The values for each are represented as JSON Strings
  835. -- conforming to the "date-time" production in RFC3339.
  836. getStartTime :: Lens' a Aeson.Object -> Lens' a (Maybe Text)
  837. getStartTime = makeAesonLensMb "startTime"
  838. -- | When an long running Activity occurs over a distinct period of
  839. -- time, or when an Object represents a long-running process or event,
  840. -- the @endTime@ propertiy can be used to specify the
  841. -- date and time at which the activity or object concludes.
  842. -- The values for each are represented as JSON Strings
  843. -- conforming to the "date-time" production in RFC3339.
  844. getEndTime :: Lens' a Aeson.Object -> Lens' a (Maybe Text)
  845. getEndTime = makeAesonLensMb "endTime"
  846. -- | A listing of the objects that have been associated with a
  847. -- particular object. Represented in JSON using a property named @tags@
  848. -- whose value is an Array of objects.
  849. oTags :: Lens' Object (Maybe [Object])
  850. oTags = makeAesonLensMb "tags" oRest
  851. -- mood
  852. -- | Mood describes the mood of the user when the activity was
  853. -- performed. This is usually collected via an extra field in the user
  854. -- interface used to perform the activity. For the purpose of this
  855. -- schema, a mood is a freeform, short mood keyword or phrase along
  856. -- with an optional mood icon image.
  857. newtype Mood = Mood { fromMood :: Aeson.Object } deriving (Eq, Show)
  858. instance FromJSON Mood where
  859. parseJSON (Aeson.Object o) = do
  860. ensure "Mood" o ["displayname", "image"]
  861. return (Mood o)
  862. parseJSON _ = fail "Mood not an object"
  863. instance ToJSON Mood where
  864. toJSON = Aeson.Object . fromMood
  865. -- | Access to the underlying JSON object of a 'Mood'
  866. moodRest :: Lens' Mood Aeson.Object
  867. moodRest = makeLens fromMood (\ o' m -> m { fromMood = o' })
  868. -- | The natural-language, human-readable and plain-text keyword or
  869. -- phrase describing the mood. HTML markup MUST NOT be included.
  870. moodDisplayName :: Lens' Mood Text
  871. moodDisplayName = makeAesonLens "displayName" moodRest
  872. -- | An optional image that provides a visual representation of the mood.
  873. moodImage :: Lens' Mood MediaLink
  874. moodImage = makeAesonLens "image" moodRest