package activitypub

  1. Overview
  2. Docs

Objects pre-implementation and graph convenient functions.

Convenient functions to implement Types.object_s, including a virtual object_ class performing queries on its internal graph.

Errors

type E.error +=
  1. | Could_not_parse_graph of Iri.t * Ldp.Ct.t * string
  2. | Http_error of Iri.t * Cohttp.Code.meth * string

Content-types and mime-types

val ct_json : Ldp.Ct.t

 application/json

val mime_json : Ldp.Ct.mime
val ct_jsonld : Ldp.Ct.t

 application/ld+json

val mime_jsonld : Ldp.Ct.mime
val ct_activity_json : Ldp.Ct.t

 application/activity+json

val mime_activity_json : Ldp.Ct.mime
val accept_rdf_cts : Ldp.Ct.t list

List of accepted content-types: json-ld, activity_json, json, turtle, xmlrdf.

JSON remote loader and parser

val jsonld_load_remote : ?loader:(Iri.Map.key -> (string, exn) Stdlib.result Lwt.t) -> string option -> Iri.Map.key -> (string, exn) Stdlib.result Lwt.t
val jsonld_string_to_graph : ?g:Rdf.Graph.graph -> Rdf_json_ld.T.options -> string -> (Rdf.Graph.graph * Iri.t option) Lwt.t
val jsonld_parser : ?jsonld_loader:(Iri.Map.key -> (string, exn) Stdlib.result Lwt.t) -> string option -> Rdf.Graph.graph -> Ldp.Ct.t -> string -> (Rdf.Graph.graph * Iri.t option, E.error) Stdlib.result Lwt.t
val parse_graph : ?jsonld_loader:(Iri.Map.key -> (string, exn) Stdlib.result Lwt.t) -> string option -> Iri.t -> Ldp.Ct.t -> string -> (Rdf.Graph.graph * Iri.t option, E.error) Stdlib.result Lwt.t
module G : sig ... end

A module with convenient function to query an object_'s graph.

Implementations of objects

val none_if_iri_only : Rdf.Term.term -> Rdf.Graph.graph option -> Rdf.Graph.graph option

Implementation of a link.

class virtual object_ : ?g:Rdf.Graph.graph option -> Types.id -> object ... end

A pre-implementation of an Types.object_. Dereferencing and casting methods remain to be implemented.

val pp : 'a -> < pp : 'a -> unit -> 'b.. > -> 'b

pp ppf o pretty-prints the given object_ to ppf.

Convenient functions

val graph_roots : Rdf.Graph.graph -> Rdf.Term.term list

graph_roots g returns the list of root nodes, i.e. nodes which do not appear as object in edges of the graph. Some nodes are filtered out (blank nodes having a blank node as type, which are sent by Mastodon).

val activity_types : Iri.Set.t
val is_activity : Iri.Set.elt -> bool

is_activity typ returns whether typ corresponds to an activity type.

map_graph f g returns a new graph with all triples mapped with f. f is also applied to the graph name (an IRI) to get the name of the new graph (as an IRI).

val copy_addresses : src: < audience : [< `L of < href : Iri.t.. > | `O of < id : Rdf.Term.term.. > ] option ; bcc : [< `L of < href : Iri.t.. > | `O of < id : Rdf.Term.term.. > ] list ; bto : [< `L of < href : Iri.t.. > | `O of < id : Rdf.Term.term.. > ] list ; cc : [< `L of < href : Iri.t.. > | `O of < id : Rdf.Term.term.. > ] list ; to_ : [< `L of < href : Iri.t.. > | `O of < id : Rdf.Term.term.. > ] list.. > -> dst:Rdf.Graph.graph -> dstid:Rdf.Term.term -> bool

For each relation to_, bto, cc, bcc and audience of src, copy_addresses ~src ~dst ~dstid adds a triple in graph dst with dstid as subjet and the same predicates (to, cc, ...) and objects. Returns true if at least one address was copied in dst (but does not check if such a triple already existed).

val remove_addresses : Rdf.Graph.graph -> Rdf.Term.term -> unit

remove_addresses g sub removes all triples of g with subject sub and to, bto, cc, bcc or audience predicate.

id_of_link_or_object (`L link) returns Iri link#href. id_of_link_or_object (`O obj) returns obj#id.

val remove_bto_bcc : Rdf.Graph.graph -> unit

remove_bto_bcc g removes all triples having bto and bcc as predicate.

OCaml

Innovation. Community. Security.