···22opam-version: "2.0"
33synopsis: "ActivityPub client library for OCaml with Eio"
44description:
55- "ActivityPub/ActivityStreams protocol implementation for OCaml. Provides typed representations of ActivityPub actors, activities, and objects with bidirectional JSON codecs using jsont. Includes an Eio-based HTTP client for federation with HTTP signature support."
55+ "ActivityPub/ActivityStreams protocol implementation for OCaml. Provides typed representations of ActivityPub actors, activities, and objects with bidirectional JSON codecs using nox-json. Includes an Eio-based HTTP client for federation with HTTP signature support."
66maintainer: ["Anil Madhavapeddy <anil@recoil.org>"]
77authors: ["Anil Madhavapeddy"]
88license: "ISC"
···1111depends: [
1212 "dune" {>= "3.21"}
1313 "ocaml" {>= "5.1.0"}
1414- "jsont" {>= "0.2.0"}
1414+ "nox-json"
1515 "bytesrw"
1616 "eio" {>= "1.0"}
1717 "eio_main" {>= "1.0"}
···2121 "fmt" {>= "0.9.0"}
2222 "ptime"
2323 "uri"
2424- "x509"
2424+ "nox-x509"
2525 "odoc" {with-doc}
2626]
2727build: [
+14-17
bin/apub.ml
···4343 try
4444 let jrd = Apubt.Webfinger.lookup client account in
4545 if json_output then begin
4646- match Jsont_bytesrw.encode_string Apubt.Proto.Webfinger.jsont jrd with
4747- | Ok s -> print_endline s
4848- | Error e -> Fmt.epr "JSON encoding error: %s@." e
4646+ (try print_endline (Json.to_string Apubt.Proto.Webfinger.jsont jrd)
4747+ with Json.Error e -> Fmt.epr "JSON encoding error: %a@." Json.Error.pp e)
4948 end else begin
5049 Fmt.pr "@[<v>";
5150 Fmt.pr "Subject: %s@," (Apubt.Proto.Webfinger.subject jrd);
···119118 Apubt.Actor.fetch client (Uri.of_string uri_or_acct)
120119 in
121120 if json_output then begin
122122- match Jsont_bytesrw.encode_string Apubt.Proto.Actor.jsont actor with
123123- | Ok s -> print_endline s
124124- | Error e -> Fmt.epr "JSON encoding error: %s@." e
121121+ (try print_endline (Json.to_string Apubt.Proto.Actor.jsont actor)
122122+ with Json.Error e -> Fmt.epr "JSON encoding error: %a@." Json.Error.pp e)
125123 end else begin
126124 Fmt.pr "@[<v>";
127125 Fmt.pr "ID: %s@," (Uri.to_string (Apubt.Proto.Actor.id actor));
···186184 in
187185 let outbox = Apubt.Actor.outbox client actor in
188186 if json_output then begin
189189- match Jsont_bytesrw.encode_string Apubt.Proto.Activity_collection.jsont outbox with
190190- | Ok s -> print_endline s
191191- | Error e -> Fmt.epr "JSON encoding error: %s@." e
187187+ (try print_endline (Json.to_string Apubt.Proto.Activity_collection.jsont outbox)
188188+ with Json.Error e -> Fmt.epr "JSON encoding error: %a@." Json.Error.pp e)
192189 end else begin
193190 Fmt.pr "@[<v>";
194191 Fmt.pr "Outbox for: %s@," (Uri.to_string (Apubt.Proto.Actor.id actor));
···376373 (* Use Mastodon API if OAuth is available *)
377374 match creds.auth with
378375 | OAuth_auth { instance; token } ->
379379- let timeout_config = Requests.Timeout.create ~connect:timeout ~read:timeout () in
380380- let requests = Requests.create ~sw ~timeout:timeout_config env in
376376+ let timeout_config = Requests.Timeout.v ~connect:timeout ~read:timeout () in
377377+ let requests = Requests.v ~sw ~timeout:timeout_config env in
381378 let visibility = if followers_only then Apub_mastodon_api.Private else Apub_mastodon_api.Public in
382379 let spoiler_text = if sensitive then cw_summary else None in
383380 (match Apub_mastodon_api.post_status requests ~instance ~token ~content
···448445 (* Use Mastodon API if OAuth is available *)
449446 match creds.auth with
450447 | OAuth_auth { instance; token } ->
451451- let timeout_config = Requests.Timeout.create ~connect:timeout ~read:timeout () in
452452- let requests = Requests.create ~sw ~timeout:timeout_config env in
448448+ let timeout_config = Requests.Timeout.v ~connect:timeout ~read:timeout () in
449449+ let requests = Requests.v ~sw ~timeout:timeout_config env in
453450 (* Look up the account first to get its ID *)
454451 (match Apub_mastodon_api.lookup_account requests ~instance ~token ~acct:target with
455452 | Ok account ->
···523520 (* Use Mastodon API if OAuth is available *)
524521 match creds.auth with
525522 | OAuth_auth { instance; token } ->
526526- let timeout_config = Requests.Timeout.create ~connect:timeout ~read:timeout () in
527527- let requests = Requests.create ~sw ~timeout:timeout_config env in
523523+ let timeout_config = Requests.Timeout.v ~connect:timeout ~read:timeout () in
524524+ let requests = Requests.v ~sw ~timeout:timeout_config env in
528525 (* Extract status ID from URL *)
529526 (match Apub_mastodon_api.status_id_of_url object_uri with
530527 | Some status_id ->
···587584 (* Use Mastodon API if OAuth is available *)
588585 match creds.auth with
589586 | OAuth_auth { instance; token } ->
590590- let timeout_config = Requests.Timeout.create ~connect:timeout ~read:timeout () in
591591- let requests = Requests.create ~sw ~timeout:timeout_config env in
587587+ let timeout_config = Requests.Timeout.v ~connect:timeout ~read:timeout () in
588588+ let requests = Requests.v ~sw ~timeout:timeout_config env in
592589 (* Extract status ID from URL *)
593590 (match Apub_mastodon_api.status_id_of_url object_uri with
594591 | Some status_id ->
···9595 "application/activity+json, application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""
96969797let create ~sw ?signing ?(user_agent = "Apubt/0.1") ?(timeout = 30.0) env =
9898- let timeout_config = Requests.Timeout.create ~connect:timeout ~read:timeout () in
9898+ let timeout_config = Requests.Timeout.v ~connect:timeout ~read:timeout () in
9999 let default_headers =
100100 Requests.Headers.empty
101101 |> Requests.Headers.add `Accept activitypub_accept
102102 |> Requests.Headers.add `User_agent user_agent
103103 in
104104- let requests = Requests.create ~sw ~default_headers ~timeout:timeout_config env in
104104+ let requests = Requests.v ~sw ~default_headers ~timeout:timeout_config env in
105105 let clock = Eio.Stdenv.clock env in
106106 T { requests; clock; signing; user_agent }
107107···116116 else if status = 429 then begin
117117 let retry_after =
118118 Requests.Response.headers resp
119119- |> Requests.Headers.get `Retry_after
119119+ |> Requests.Headers.find `Retry_after
120120 |> Option.map float_of_string
121121 in
122122 raise (E (Rate_limited retry_after))
···171171172172 (* Helper to encode JSON to string, raising on error *)
173173 let encode_json_exn jsont value =
174174- match Jsont_bytesrw.encode_string jsont value with
175175- | Ok s -> s
176176- | Error msg -> raise (E (Json_error msg))
174174+ try Json.to_string jsont value
175175+ with Json.Error err ->
176176+ raise (E (Json_error (Format.asprintf "%a" Json.Error.pp err)))
177177178178 let post (T t as client) uri body =
179179 let url = Uri.to_string uri in
180180- let body_str = encode_json_exn Jsont.json body in
180180+ let body_str = encode_json_exn Json.Codec.Value.t body in
181181 let headers =
182182 Requests.Headers.empty
183183 |> Requests.Headers.set `Content_type "application/activity+json"
···319319 }
320320321321 let jsont =
322322- Jsont.Object.map ~kind:"WellKnownLink"
322322+ Json.Codec.Object.map ~kind:"WellKnownLink"
323323 (fun rel href -> { rel; href })
324324- |> Jsont.Object.mem "rel" Jsont.string ~enc:(fun t -> t.rel)
325325- |> Jsont.Object.mem "href" Jsont.string ~enc:(fun t -> t.href)
326326- |> Jsont.Object.finish
324324+ |> Json.Codec.Object.member "rel" Json.Codec.string ~enc:(fun t -> t.rel)
325325+ |> Json.Codec.Object.member "href" Json.Codec.string ~enc:(fun t -> t.href)
326326+ |> Json.Codec.Object.seal
327327 end
328328329329 module Well_known = struct
···332332 }
333333334334 let jsont =
335335- Jsont.Object.map ~kind:"WellKnownNodeinfo"
335335+ Json.Codec.Object.map ~kind:"WellKnownNodeinfo"
336336 (fun links -> { links })
337337- |> Jsont.Object.mem "links" (Jsont.list Well_known_link.jsont)
337337+ |> Json.Codec.Object.member "links" (Json.Codec.list Well_known_link.jsont)
338338 ~enc:(fun t -> t.links)
339339- |> Jsont.Object.finish
339339+ |> Json.Codec.Object.seal
340340 end
341341342342 let fetch (T t) ~host =
+9-9
lib/client/apubt.mli
···499499 t ->
500500 ('a -> unit) ->
501501 'a Proto.Collection.t ->
502502- 'a Jsont.t ->
502502+ 'a Json.codec ->
503503 unit
504504 (** [iter client f collection item_jsont] iterates over all items in a collection,
505505 automatically fetching subsequent pages.
···511511 ('acc -> 'a -> 'acc) ->
512512 'acc ->
513513 'a Proto.Collection.t ->
514514- 'a Jsont.t ->
514514+ 'a Json.codec ->
515515 'acc
516516 (** [fold client f init collection item_jsont] folds over all items in a collection,
517517 automatically fetching subsequent pages.
···521521 val to_list :
522522 t ->
523523 'a Proto.Collection.t ->
524524- 'a Jsont.t ->
524524+ 'a Json.codec ->
525525 'a list
526526 (** [to_list client collection item_jsont] returns all items in a collection as a list.
527527···532532 val first_page :
533533 t ->
534534 'a Proto.Collection.t ->
535535- 'a Jsont.t ->
535535+ 'a Json.codec ->
536536 'a Proto.Collection_page.t option
537537 (** [first_page client collection item_jsont] fetches the first page of a collection.
538538···541541 val next_page :
542542 t ->
543543 'a Proto.Collection_page.t ->
544544- 'a Jsont.t ->
544544+ 'a Json.codec ->
545545 'a Proto.Collection_page.t option
546546 (** [next_page client page item_jsont] fetches the next page, if any.
547547···552552553553(** Low-level HTTP operations with ActivityPub content negotiation. *)
554554module Http : sig
555555- val get : t -> Uri.t -> Jsont.json
555555+ val get : t -> Uri.t -> Json.t
556556 (** [get client uri] performs a GET request with ActivityPub Accept header.
557557558558 @raise E on request failure *)
559559560560- val get_typed : t -> 'a Jsont.t -> Uri.t -> 'a
560560+ val get_typed : t -> 'a Json.codec -> Uri.t -> 'a
561561 (** [get_typed client jsont uri] performs a GET and decodes the response.
562562563563 @raise E on request failure *)
564564565565- val post : t -> Uri.t -> Jsont.json -> unit
565565+ val post : t -> Uri.t -> Json.t -> unit
566566 (** [post client uri body] performs a signed POST request.
567567568568 @raise E on request failure *)
569569570570- val post_typed : t -> 'a Jsont.t -> Uri.t -> 'a -> unit
570570+ val post_typed : t -> 'a Json.codec -> Uri.t -> 'a -> unit
571571 (** [post_typed client jsont uri value] encodes and POSTs a typed value.
572572573573 @raise E on request failure *)
···1414 type t
1515 val v : string -> t
1616 val to_string : t -> string
1717- val jsont : t Jsont.t
1717+ val jsont : t Json.codec
1818end = struct
1919 type t = string
2020 let v s = s
2121 let to_string t = t
2222- let jsont = Jsont.string |> Jsont.with_doc ~kind:"datetime"
2222+ let jsont = Json.Codec.string |> Json.Codec.with_doc ~kind:"datetime"
2323end
24242525(** JSON codec for [Uri.t] values. *)
2626-let uri_jsont : Uri.t Jsont.t =
2727- Jsont.string |> Jsont.map ~dec:Uri.of_string ~enc:Uri.to_string
2626+let uri_jsont : Uri.t Json.codec =
2727+ Json.Codec.string |> Json.Codec.map ~dec:Uri.of_string ~enc:Uri.to_string
28282929(** JSON-LD context. *)
3030module Context : sig
3131 type t
3232 val default : t
3333- val jsont : t Jsont.t
3333+ val jsont : t Json.codec
3434end = struct
3535- type t = Jsont.json
3535+ type t = Json.t
3636 let default =
3737- Jsont.Json.string "https://www.w3.org/ns/activitystreams"
3838- let jsont = Jsont.json |> Jsont.with_doc ~kind:"@context"
3737+ Json.Value.string "https://www.w3.org/ns/activitystreams"
3838+ let jsont = Json.Codec.Value.t |> Json.Codec.with_doc ~kind:"@context"
3939end
40404141(** Helper: JSON type that accepts either a single item or an array, normalizing to a list.
4242 On encoding, always outputs an array for consistency. *)
4343-let one_or_many (item_jsont : 'a Jsont.t) : 'a list Jsont.t =
4444- let dec_array = Jsont.list item_jsont in
4545- let dec_single = Jsont.map item_jsont
4343+let one_or_many (item_jsont : 'a Json.codec) : 'a list Json.codec =
4444+ let dec_array = Json.Codec.list item_jsont in
4545+ let dec_single = Json.Codec.map item_jsont
4646 ~dec:(fun x -> [x])
4747 ~enc:(fun _ -> assert false) (* never used for encoding *)
4848 in
4949- Jsont.any ~kind:"one or many"
4949+ Json.Codec.any ~kind:"one or many"
5050 ~dec_array
5151 ~dec_string:dec_single
5252 ~dec_object:dec_single
···5454 ()
55555656(** Helper: Nullable value - accepts null as None, value as Some value *)
5757-let nullable (jsont : 'a Jsont.t) : 'a option Jsont.t =
5858- let dec_null = Jsont.null None in
5959- let dec_value = Jsont.map jsont
5757+let nullable (jsont : 'a Json.codec) : 'a option Json.codec =
5858+ let dec_null = Json.Codec.null None in
5959+ let dec_value = Json.Codec.map jsont
6060 ~dec:(fun v -> Some v)
6161 ~enc:(function Some v -> v | None -> assert false)
6262 in
6363- Jsont.any ~kind:"nullable"
6363+ Json.Codec.any ~kind:"nullable"
6464 ~dec_null
6565 ~dec_string:dec_value
6666 ~dec_number:dec_value
···7575(** Helper: URI that can also be an object with an id field.
7676 This handles ActivityPub fields like 'replies' that can be either
7777 a URI string or an inline Collection object. *)
7878-let uri_or_object_with_id : Uri.t Jsont.t =
7878+let uri_or_object_with_id : Uri.t Json.codec =
7979 let id_jsont =
8080- Jsont.Object.map ~kind:"Object with id" (fun id -> id)
8181- |> Jsont.Object.mem "id" uri_jsont ~enc:Fun.id
8282- |> Jsont.Object.skip_unknown
8383- |> Jsont.Object.finish
8080+ Json.Codec.Object.map ~kind:"Object with id" (fun id -> id)
8181+ |> Json.Codec.Object.member "id" uri_jsont ~enc:Fun.id
8282+ |> Json.Codec.Object.skip_unknown
8383+ |> Json.Codec.Object.seal
8484 in
8585- Jsont.any ~kind:"URI or object"
8585+ Json.Codec.any ~kind:"URI or object"
8686 ~dec_string:uri_jsont
8787 ~dec_object:id_jsont
8888 ~enc:(fun _ -> uri_jsont)
···114114 val width : t -> int option
115115 val preview : t -> Uri.t option
116116117117- val jsont : t Jsont.t
117117+ val jsont : t Json.codec
118118end = struct
119119 type t = {
120120 href : Uri.t;
···138138 let preview t = t.preview
139139140140 let jsont =
141141- Jsont.Object.map ~kind:"Link"
141141+ Json.Codec.Object.map ~kind:"Link"
142142 (fun href media_type name hreflang height width preview ->
143143 { href; media_type; name; hreflang; height; width; preview })
144144- |> Jsont.Object.mem "href" uri_jsont ~enc:href
145145- |> Jsont.Object.opt_mem "mediaType" Jsont.string ~enc:media_type
146146- |> Jsont.Object.opt_mem "name" Jsont.string ~enc:name
147147- |> Jsont.Object.opt_mem "hreflang" Jsont.string ~enc:hreflang
148148- |> Jsont.Object.opt_mem "height" Jsont.int ~enc:height
149149- |> Jsont.Object.opt_mem "width" Jsont.int ~enc:width
150150- |> Jsont.Object.opt_mem "preview" uri_jsont ~enc:preview
151151- |> Jsont.Object.finish
144144+ |> Json.Codec.Object.member "href" uri_jsont ~enc:href
145145+ |> Json.Codec.Object.opt_member "mediaType" Json.Codec.string ~enc:media_type
146146+ |> Json.Codec.Object.opt_member "name" Json.Codec.string ~enc:name
147147+ |> Json.Codec.Object.opt_member "hreflang" Json.Codec.string ~enc:hreflang
148148+ |> Json.Codec.Object.opt_member "height" Json.Codec.int ~enc:height
149149+ |> Json.Codec.Object.opt_member "width" Json.Codec.int ~enc:width
150150+ |> Json.Codec.Object.opt_member "preview" uri_jsont ~enc:preview
151151+ |> Json.Codec.Object.seal
152152end
153153154154(** Reference that can be either a URI string or a Link object. *)
···159159160160 val uri : Uri.t -> t
161161 val link : Link.t -> t
162162- val jsont : t Jsont.t
162162+ val jsont : t Json.codec
163163end = struct
164164 type t =
165165 | Uri of Uri.t
···169169 let link l = Link l
170170171171 let jsont =
172172- let dec_string = Jsont.map uri_jsont ~dec:(fun u -> Uri u)
172172+ let dec_string = Json.Codec.map uri_jsont ~dec:(fun u -> Uri u)
173173 ~enc:(function Uri u -> u | Link _ -> assert false) in
174174- let dec_object = Jsont.map Link.jsont ~dec:(fun l -> Link l)
174174+ let dec_object = Json.Codec.map Link.jsont ~dec:(fun l -> Link l)
175175 ~enc:(function Link l -> l | Uri _ -> assert false) in
176176- Jsont.any ~kind:"Link or URI"
176176+ Json.Codec.any ~kind:"Link or URI"
177177 ~dec_string ~dec_object
178178 ~enc:(function
179179 | Uri _ -> dec_string
···204204 val width : t -> int option
205205 val height : t -> int option
206206207207- val jsont : t Jsont.t
207207+ val jsont : t Json.codec
208208end = struct
209209 type t = {
210210 id : Uri.t option;
···226226 let height t = t.height
227227228228 let jsont =
229229- Jsont.Object.map ~kind:"Image"
229229+ Json.Codec.Object.map ~kind:"Image"
230230 (fun id url name media_type width height ->
231231 { id; url; name; media_type; width; height })
232232- |> Jsont.Object.opt_mem "id" uri_jsont ~enc:id
233233- |> Jsont.Object.mem "url" Link_or_uri.jsont ~enc:url
234234- |> Jsont.Object.opt_mem "name" Jsont.string ~enc:name
235235- |> Jsont.Object.opt_mem "mediaType" Jsont.string ~enc:media_type
236236- |> Jsont.Object.opt_mem "width" Jsont.int ~enc:width
237237- |> Jsont.Object.opt_mem "height" Jsont.int ~enc:height
238238- |> Jsont.Object.finish
232232+ |> Json.Codec.Object.opt_member "id" uri_jsont ~enc:id
233233+ |> Json.Codec.Object.member "url" Link_or_uri.jsont ~enc:url
234234+ |> Json.Codec.Object.opt_member "name" Json.Codec.string ~enc:name
235235+ |> Json.Codec.Object.opt_member "mediaType" Json.Codec.string ~enc:media_type
236236+ |> Json.Codec.Object.opt_member "width" Json.Codec.int ~enc:width
237237+ |> Json.Codec.Object.opt_member "height" Json.Codec.int ~enc:height
238238+ |> Json.Codec.Object.seal
239239end
240240241241(** Image reference - can be URI, Link, or full Image object. *)
···248248 val uri : Uri.t -> t
249249 val link : Link.t -> t
250250 val image : Image.t -> t
251251- val jsont : t Jsont.t
251251+ val jsont : t Json.codec
252252end = struct
253253 type t =
254254 | Uri of Uri.t
···261261262262 let jsont =
263263 (* For string case: URI *)
264264- let dec_string = Jsont.map uri_jsont ~dec:(fun u -> Uri u)
264264+ let dec_string = Json.Codec.map uri_jsont ~dec:(fun u -> Uri u)
265265 ~enc:(function Uri u -> u | _ -> assert false) in
266266 (* For object case: either Link or Image *)
267267 let dec_object =
268268 (* Default: decode as Image if we can't determine type *)
269269- Jsont.map Image.jsont
269269+ Json.Codec.map Image.jsont
270270 ~dec:(fun i -> Image i)
271271 ~enc:(function Image i -> i | _ -> assert false)
272272 in
273273- Jsont.any ~kind:"Image reference"
273273+ Json.Codec.any ~kind:"Image reference"
274274 ~dec_string ~dec_object
275275 ~enc:(function
276276 | Uri _ -> dec_string
···299299 val make : ?type_:string -> Uri.t -> t
300300 val id : t -> Uri.t
301301 val type_ : t -> string option
302302- val jsont : t Jsont.t
302302+ val jsont : t Json.codec
303303end = struct
304304 type t = {
305305 id : Uri.t;
···311311 let type_ t = t.type_
312312313313 let jsont =
314314- let dec_string = Jsont.map uri_jsont
314314+ let dec_string = Json.Codec.map uri_jsont
315315 ~dec:(fun u -> { id = u; type_ = None })
316316 ~enc:(fun t -> t.id) in
317317 let dec_object =
318318- Jsont.Object.map ~kind:"Recipient"
318318+ Json.Codec.Object.map ~kind:"Recipient"
319319 (fun id type_ -> { id; type_ })
320320- |> Jsont.Object.mem "id" uri_jsont ~enc:id
321321- |> Jsont.Object.opt_mem "type" Jsont.string ~enc:type_
322322- |> Jsont.Object.finish
320320+ |> Json.Codec.Object.member "id" uri_jsont ~enc:id
321321+ |> Json.Codec.Object.opt_member "type" Json.Codec.string ~enc:type_
322322+ |> Json.Codec.Object.seal
323323 in
324324- Jsont.any ~kind:"Recipient"
324324+ Json.Codec.any ~kind:"Recipient"
325325 ~dec_string ~dec_object
326326 ~enc:(fun t ->
327327 match t.type_ with
···352352 val sign_client_key : t -> Uri.t option
353353 val shared_inbox : t -> Uri.t option
354354355355- val jsont : t Jsont.t
355355+ val jsont : t Json.codec
356356end = struct
357357 type t = {
358358 proxy_url : Uri.t option;
···376376 let shared_inbox t = t.shared_inbox
377377378378 let jsont =
379379- Jsont.Object.map ~kind:"Endpoints"
379379+ Json.Codec.Object.map ~kind:"Endpoints"
380380 (fun proxy_url oauth_authorization_endpoint oauth_token_endpoint
381381 provide_client_key sign_client_key shared_inbox ->
382382 { proxy_url; oauth_authorization_endpoint; oauth_token_endpoint;
383383 provide_client_key; sign_client_key; shared_inbox })
384384- |> Jsont.Object.opt_mem "proxyUrl" uri_jsont ~enc:proxy_url
385385- |> Jsont.Object.opt_mem "oauthAuthorizationEndpoint" uri_jsont
384384+ |> Json.Codec.Object.opt_member "proxyUrl" uri_jsont ~enc:proxy_url
385385+ |> Json.Codec.Object.opt_member "oauthAuthorizationEndpoint" uri_jsont
386386 ~enc:oauth_authorization_endpoint
387387- |> Jsont.Object.opt_mem "oauthTokenEndpoint" uri_jsont
387387+ |> Json.Codec.Object.opt_member "oauthTokenEndpoint" uri_jsont
388388 ~enc:oauth_token_endpoint
389389- |> Jsont.Object.opt_mem "provideClientKey" uri_jsont ~enc:provide_client_key
390390- |> Jsont.Object.opt_mem "signClientKey" uri_jsont ~enc:sign_client_key
391391- |> Jsont.Object.opt_mem "sharedInbox" uri_jsont ~enc:shared_inbox
392392- |> Jsont.Object.finish
389389+ |> Json.Codec.Object.opt_member "provideClientKey" uri_jsont ~enc:provide_client_key
390390+ |> Json.Codec.Object.opt_member "signClientKey" uri_jsont ~enc:sign_client_key
391391+ |> Json.Codec.Object.opt_member "sharedInbox" uri_jsont ~enc:shared_inbox
392392+ |> Json.Codec.Object.seal
393393end
394394395395(** {1 Public Key} *)
···408408 val owner : t -> Uri.t
409409 val public_key_pem : t -> string
410410411411- val jsont : t Jsont.t
411411+ val jsont : t Json.codec
412412end = struct
413413 type t = {
414414 id : Uri.t;
···424424 let public_key_pem t = t.public_key_pem
425425426426 let jsont =
427427- Jsont.Object.map ~kind:"PublicKey"
427427+ Json.Codec.Object.map ~kind:"PublicKey"
428428 (fun id owner public_key_pem -> { id; owner; public_key_pem })
429429- |> Jsont.Object.mem "id" uri_jsont ~enc:id
430430- |> Jsont.Object.mem "owner" uri_jsont ~enc:owner
431431- |> Jsont.Object.mem "publicKeyPem" Jsont.string ~enc:public_key_pem
432432- |> Jsont.Object.finish
429429+ |> Json.Codec.Object.member "id" uri_jsont ~enc:id
430430+ |> Json.Codec.Object.member "owner" uri_jsont ~enc:owner
431431+ |> Json.Codec.Object.member "publicKeyPem" Json.Codec.string ~enc:public_key_pem
432432+ |> Json.Codec.Object.seal
433433end
434434435435(** {1 Actor Types} *)
···445445446446 val to_string : t -> string
447447 val of_string : string -> t option
448448- val jsont : t Jsont.t
448448+ val jsont : t Json.codec
449449end = struct
450450 type t =
451451 | Person
···470470 | _ -> None
471471472472 let jsont =
473473- Jsont.enum ~kind:"ActorType" [
473473+ Json.Codec.enum ~kind:"ActorType" [
474474 "Person", Person;
475475 "Service", Service;
476476 "Organization", Organization;
···538538 val featured : t -> Uri.t option
539539 val featured_tags : t -> Uri.t option
540540541541- val jsont : t Jsont.t
541541+ val jsont : t Json.codec
542542end = struct
543543 type t = {
544544 context : Context.t option;
···604604 let featured_tags t = t.featured_tags
605605606606 let jsont =
607607- Jsont.Object.map ~kind:"Actor"
607607+ Json.Codec.Object.map ~kind:"Actor"
608608 (fun context id type_ name preferred_username summary url inbox outbox
609609 followers following liked streams endpoints public_key icon image
610610 manually_approves_followers also_known_as discoverable suspended
···614614 public_key; icon; image; manually_approves_followers;
615615 also_known_as; discoverable; suspended; moved_to; featured;
616616 featured_tags })
617617- |> Jsont.Object.opt_mem "@context" Context.jsont ~enc:context
618618- |> Jsont.Object.mem "id" uri_jsont ~enc:id
619619- |> Jsont.Object.mem "type" Actor_type.jsont ~enc:type_
620620- |> Jsont.Object.opt_mem "name" Jsont.string ~enc:name
621621- |> Jsont.Object.opt_mem "preferredUsername" Jsont.string
617617+ |> Json.Codec.Object.opt_member "@context" Context.jsont ~enc:context
618618+ |> Json.Codec.Object.member "id" uri_jsont ~enc:id
619619+ |> Json.Codec.Object.member "type" Actor_type.jsont ~enc:type_
620620+ |> Json.Codec.Object.opt_member "name" Json.Codec.string ~enc:name
621621+ |> Json.Codec.Object.opt_member "preferredUsername" Json.Codec.string
622622 ~enc:preferred_username
623623- |> Jsont.Object.opt_mem "summary" Jsont.string ~enc:summary
624624- |> Jsont.Object.opt_mem "url" uri_jsont ~enc:url
625625- |> Jsont.Object.mem "inbox" uri_jsont ~enc:inbox
626626- |> Jsont.Object.mem "outbox" uri_jsont ~enc:outbox
627627- |> Jsont.Object.opt_mem "followers" uri_jsont ~enc:followers
628628- |> Jsont.Object.opt_mem "following" uri_jsont ~enc:following
629629- |> Jsont.Object.opt_mem "liked" uri_jsont ~enc:liked
630630- |> Jsont.Object.opt_mem "streams" (Jsont.list uri_jsont) ~enc:streams
631631- |> Jsont.Object.opt_mem "endpoints" Endpoints.jsont ~enc:endpoints
632632- |> Jsont.Object.opt_mem "publicKey" Public_key.jsont ~enc:public_key
633633- |> Jsont.Object.opt_mem "icon" (one_or_many Image_ref.jsont) ~enc:icon
634634- |> Jsont.Object.opt_mem "image" (one_or_many Image_ref.jsont) ~enc:image
635635- |> Jsont.Object.opt_mem "manuallyApprovesFollowers" Jsont.bool
623623+ |> Json.Codec.Object.opt_member "summary" Json.Codec.string ~enc:summary
624624+ |> Json.Codec.Object.opt_member "url" uri_jsont ~enc:url
625625+ |> Json.Codec.Object.member "inbox" uri_jsont ~enc:inbox
626626+ |> Json.Codec.Object.member "outbox" uri_jsont ~enc:outbox
627627+ |> Json.Codec.Object.opt_member "followers" uri_jsont ~enc:followers
628628+ |> Json.Codec.Object.opt_member "following" uri_jsont ~enc:following
629629+ |> Json.Codec.Object.opt_member "liked" uri_jsont ~enc:liked
630630+ |> Json.Codec.Object.opt_member "streams" (Json.Codec.list uri_jsont) ~enc:streams
631631+ |> Json.Codec.Object.opt_member "endpoints" Endpoints.jsont ~enc:endpoints
632632+ |> Json.Codec.Object.opt_member "publicKey" Public_key.jsont ~enc:public_key
633633+ |> Json.Codec.Object.opt_member "icon" (one_or_many Image_ref.jsont) ~enc:icon
634634+ |> Json.Codec.Object.opt_member "image" (one_or_many Image_ref.jsont) ~enc:image
635635+ |> Json.Codec.Object.opt_member "manuallyApprovesFollowers" Json.Codec.bool
636636 ~enc:manually_approves_followers
637637- |> Jsont.Object.opt_mem "alsoKnownAs" (one_or_many uri_jsont)
637637+ |> Json.Codec.Object.opt_member "alsoKnownAs" (one_or_many uri_jsont)
638638 ~enc:also_known_as
639639- |> Jsont.Object.opt_mem "discoverable" Jsont.bool ~enc:discoverable
640640- |> Jsont.Object.opt_mem "suspended" Jsont.bool ~enc:suspended
641641- |> Jsont.Object.opt_mem "movedTo" uri_jsont ~enc:moved_to
642642- |> Jsont.Object.opt_mem "featured" uri_jsont ~enc:featured
643643- |> Jsont.Object.opt_mem "featuredTags" uri_jsont ~enc:featured_tags
644644- |> Jsont.Object.finish
639639+ |> Json.Codec.Object.opt_member "discoverable" Json.Codec.bool ~enc:discoverable
640640+ |> Json.Codec.Object.opt_member "suspended" Json.Codec.bool ~enc:suspended
641641+ |> Json.Codec.Object.opt_member "movedTo" uri_jsont ~enc:moved_to
642642+ |> Json.Codec.Object.opt_member "featured" uri_jsont ~enc:featured
643643+ |> Json.Codec.Object.opt_member "featuredTags" uri_jsont ~enc:featured_tags
644644+ |> Json.Codec.Object.seal
645645end
646646647647(** Actor reference - can be URI or full Actor object. *)
···652652653653 val uri : Uri.t -> t
654654 val actor : Actor.t -> t
655655- val jsont : t Jsont.t
655655+ val jsont : t Json.codec
656656end = struct
657657 type t =
658658 | Uri of Uri.t
···662662 let actor a = Actor a
663663664664 let jsont =
665665- let dec_string = Jsont.map uri_jsont
665665+ let dec_string = Json.Codec.map uri_jsont
666666 ~dec:(fun u -> Uri u)
667667 ~enc:(function Uri u -> u | Actor _ -> assert false) in
668668- let dec_object = Jsont.map Actor.jsont
668668+ let dec_object = Json.Codec.map Actor.jsont
669669 ~dec:(fun a -> Actor a)
670670 ~enc:(function Actor a -> a | Uri _ -> assert false) in
671671- Jsont.any ~kind:"Actor reference"
671671+ Json.Codec.any ~kind:"Actor reference"
672672 ~dec_string ~dec_object
673673 ~enc:(function
674674 | Uri _ -> dec_string
···697697698698 val to_string : t -> string
699699 val of_string : string -> t option
700700- val jsont : t Jsont.t
700700+ val jsont : t Json.codec
701701end = struct
702702 type t =
703703 | Note
···746746 | _ -> None
747747748748 let jsont =
749749- Jsont.enum ~kind:"ObjectType" [
749749+ Json.Codec.enum ~kind:"ObjectType" [
750750 "Note", Note;
751751 "Article", Article;
752752 "Page", Page;
···841841 val preview : t -> Link_or_uri.t option
842842 (** [preview t] returns a preview of the object, typically a smaller version. *)
843843844844- val jsont : t Jsont.t
844844+ val jsont : t Json.codec
845845 (** JSON type for Objects. *)
846846end = struct
847847 type t = {
···922922 let preview t = t.preview
923923924924 let jsont =
925925- Jsont.Object.map ~kind:"Object"
925925+ Json.Codec.Object.map ~kind:"Object"
926926 (fun context id type_ name summary content media_type url attributed_to
927927 in_reply_to published updated deleted to_ cc bto bcc replies
928928 attachment tag generator icon image start_time end_time duration
···932932 to_; cc; bto; bcc; replies; attachment; tag; generator;
933933 icon; image; start_time; end_time; duration; sensitive;
934934 conversation; audience; location; preview })
935935- |> Jsont.Object.opt_mem "@context" Context.jsont ~enc:context
936936- |> Jsont.Object.opt_mem "id" uri_jsont ~enc:id
937937- |> Jsont.Object.mem "type" Object_type.jsont ~enc:type_
938938- |> Jsont.Object.opt_mem "name" Jsont.string ~enc:name
939939- |> Jsont.Object.mem "summary" (nullable Jsont.string)
935935+ |> Json.Codec.Object.opt_member "@context" Context.jsont ~enc:context
936936+ |> Json.Codec.Object.opt_member "id" uri_jsont ~enc:id
937937+ |> Json.Codec.Object.member "type" Object_type.jsont ~enc:type_
938938+ |> Json.Codec.Object.opt_member "name" Json.Codec.string ~enc:name
939939+ |> Json.Codec.Object.member "summary" (nullable Json.Codec.string)
940940 ~dec_absent:None ~enc_omit:Option.is_none ~enc:summary
941941- |> Jsont.Object.mem "content" (nullable Jsont.string)
941941+ |> Json.Codec.Object.member "content" (nullable Json.Codec.string)
942942 ~dec_absent:None ~enc_omit:Option.is_none ~enc:content
943943- |> Jsont.Object.opt_mem "mediaType" Jsont.string ~enc:media_type
944944- |> Jsont.Object.opt_mem "url" (one_or_many Link_or_uri.jsont) ~enc:url
945945- |> Jsont.Object.opt_mem "attributedTo" Actor_ref.jsont ~enc:attributed_to
946946- |> Jsont.Object.mem "inReplyTo" (nullable uri_jsont)
943943+ |> Json.Codec.Object.opt_member "mediaType" Json.Codec.string ~enc:media_type
944944+ |> Json.Codec.Object.opt_member "url" (one_or_many Link_or_uri.jsont) ~enc:url
945945+ |> Json.Codec.Object.opt_member "attributedTo" Actor_ref.jsont ~enc:attributed_to
946946+ |> Json.Codec.Object.member "inReplyTo" (nullable uri_jsont)
947947 ~dec_absent:None ~enc_omit:Option.is_none ~enc:in_reply_to
948948- |> Jsont.Object.opt_mem "published" Datetime.jsont ~enc:published
949949- |> Jsont.Object.opt_mem "updated" Datetime.jsont ~enc:updated
950950- |> Jsont.Object.opt_mem "deleted" Datetime.jsont ~enc:deleted
951951- |> Jsont.Object.opt_mem "to" (Jsont.list Recipient.jsont) ~enc:to_
952952- |> Jsont.Object.opt_mem "cc" (Jsont.list Recipient.jsont) ~enc:cc
953953- |> Jsont.Object.opt_mem "bto" (Jsont.list Recipient.jsont) ~enc:bto
954954- |> Jsont.Object.opt_mem "bcc" (Jsont.list Recipient.jsont) ~enc:bcc
955955- |> Jsont.Object.opt_mem "replies" uri_or_object_with_id ~enc:replies
956956- |> Jsont.Object.opt_mem "attachment" (Jsont.list Link_or_uri.jsont)
948948+ |> Json.Codec.Object.opt_member "published" Datetime.jsont ~enc:published
949949+ |> Json.Codec.Object.opt_member "updated" Datetime.jsont ~enc:updated
950950+ |> Json.Codec.Object.opt_member "deleted" Datetime.jsont ~enc:deleted
951951+ |> Json.Codec.Object.opt_member "to" (Json.Codec.list Recipient.jsont) ~enc:to_
952952+ |> Json.Codec.Object.opt_member "cc" (Json.Codec.list Recipient.jsont) ~enc:cc
953953+ |> Json.Codec.Object.opt_member "bto" (Json.Codec.list Recipient.jsont) ~enc:bto
954954+ |> Json.Codec.Object.opt_member "bcc" (Json.Codec.list Recipient.jsont) ~enc:bcc
955955+ |> Json.Codec.Object.opt_member "replies" uri_or_object_with_id ~enc:replies
956956+ |> Json.Codec.Object.opt_member "attachment" (Json.Codec.list Link_or_uri.jsont)
957957 ~enc:attachment
958958- |> Jsont.Object.opt_mem "tag" (Jsont.list Link_or_uri.jsont) ~enc:tag
959959- |> Jsont.Object.opt_mem "generator" uri_jsont ~enc:generator
960960- |> Jsont.Object.opt_mem "icon" (one_or_many Image_ref.jsont) ~enc:icon
961961- |> Jsont.Object.opt_mem "image" (one_or_many Image_ref.jsont) ~enc:image
962962- |> Jsont.Object.opt_mem "startTime" Datetime.jsont ~enc:start_time
963963- |> Jsont.Object.opt_mem "endTime" Datetime.jsont ~enc:end_time
964964- |> Jsont.Object.opt_mem "duration" Jsont.string ~enc:duration
965965- |> Jsont.Object.opt_mem "sensitive" Jsont.bool ~enc:sensitive
966966- |> Jsont.Object.opt_mem "conversation" uri_jsont ~enc:conversation
967967- |> Jsont.Object.opt_mem "audience" (one_or_many Recipient.jsont) ~enc:audience
968968- |> Jsont.Object.opt_mem "location" Link_or_uri.jsont ~enc:location
969969- |> Jsont.Object.opt_mem "preview" Link_or_uri.jsont ~enc:preview
970970- |> Jsont.Object.finish
958958+ |> Json.Codec.Object.opt_member "tag" (Json.Codec.list Link_or_uri.jsont) ~enc:tag
959959+ |> Json.Codec.Object.opt_member "generator" uri_jsont ~enc:generator
960960+ |> Json.Codec.Object.opt_member "icon" (one_or_many Image_ref.jsont) ~enc:icon
961961+ |> Json.Codec.Object.opt_member "image" (one_or_many Image_ref.jsont) ~enc:image
962962+ |> Json.Codec.Object.opt_member "startTime" Datetime.jsont ~enc:start_time
963963+ |> Json.Codec.Object.opt_member "endTime" Datetime.jsont ~enc:end_time
964964+ |> Json.Codec.Object.opt_member "duration" Json.Codec.string ~enc:duration
965965+ |> Json.Codec.Object.opt_member "sensitive" Json.Codec.bool ~enc:sensitive
966966+ |> Json.Codec.Object.opt_member "conversation" uri_jsont ~enc:conversation
967967+ |> Json.Codec.Object.opt_member "audience" (one_or_many Recipient.jsont) ~enc:audience
968968+ |> Json.Codec.Object.opt_member "location" Link_or_uri.jsont ~enc:location
969969+ |> Json.Codec.Object.opt_member "preview" Link_or_uri.jsont ~enc:preview
970970+ |> Json.Codec.Object.seal
971971end
972972973973(** Object reference - can be URI or full Object. *)
···978978979979 val uri : Uri.t -> t
980980 val obj : Object.t -> t
981981- val jsont : t Jsont.t
981981+ val jsont : t Json.codec
982982end = struct
983983 type t =
984984 | Uri of Uri.t
···988988 let obj o = Object o
989989990990 let jsont =
991991- let dec_string = Jsont.map uri_jsont
991991+ let dec_string = Json.Codec.map uri_jsont
992992 ~dec:(fun u -> Uri u)
993993 ~enc:(function Uri u -> u | Object _ -> assert false) in
994994- let dec_object = Jsont.map Object.jsont
994994+ let dec_object = Json.Codec.map Object.jsont
995995 ~dec:(fun o -> Object o)
996996 ~enc:(function Object o -> o | Uri _ -> assert false) in
997997- Jsont.any ~kind:"Object reference"
997997+ Json.Codec.any ~kind:"Object reference"
998998 ~dec_string ~dec_object
999999 ~enc:(function
10001000 | Uri _ -> dec_string
···1037103710381038 val to_string : t -> string
10391039 val of_string : string -> t option
10401040- val jsont : t Jsont.t
10401040+ val jsont : t Json.codec
10411041end = struct
10421042 type t =
10431043 | Create
···11281128 | _ -> None
1129112911301130 let jsont =
11311131- Jsont.enum ~kind:"ActivityType" [
11311131+ Json.Codec.enum ~kind:"ActivityType" [
11321132 "Create", Create;
11331133 "Update", Update;
11341134 "Delete", Delete;
···12191219 val closed : t -> Datetime.t option
12201220 (** [closed t] returns when the poll was closed, for Question activities. *)
1221122112221222- val jsont : t Jsont.t
12221222+ val jsont : t Json.codec
12231223 (** JSON type for Activities. *)
12241224end = struct
12251225 type t = {
···12721272 let closed t = t.closed
1273127312741274 let jsont =
12751275- Jsont.Object.map ~kind:"Activity"
12751275+ Json.Codec.Object.map ~kind:"Activity"
12761276 (fun context id type_ actor object_ target result origin instrument
12771277 to_ cc bto bcc published updated summary one_of any_of closed ->
12781278 { context; id; type_; actor; object_; target; result; origin;
12791279 instrument; to_; cc; bto; bcc; published; updated; summary;
12801280 one_of; any_of; closed })
12811281- |> Jsont.Object.opt_mem "@context" Context.jsont ~enc:context
12821282- |> Jsont.Object.opt_mem "id" uri_jsont ~enc:id
12831283- |> Jsont.Object.mem "type" Activity_type.jsont ~enc:type_
12841284- |> Jsont.Object.mem "actor" Actor_ref.jsont ~enc:actor
12851285- |> Jsont.Object.opt_mem "object" Object_ref.jsont ~enc:object_
12861286- |> Jsont.Object.opt_mem "target" Object_ref.jsont ~enc:target
12871287- |> Jsont.Object.opt_mem "result" Object_ref.jsont ~enc:result
12881288- |> Jsont.Object.opt_mem "origin" Object_ref.jsont ~enc:origin
12891289- |> Jsont.Object.opt_mem "instrument" Object_ref.jsont ~enc:instrument
12901290- |> Jsont.Object.opt_mem "to" (Jsont.list Recipient.jsont) ~enc:to_
12911291- |> Jsont.Object.opt_mem "cc" (Jsont.list Recipient.jsont) ~enc:cc
12921292- |> Jsont.Object.opt_mem "bto" (Jsont.list Recipient.jsont) ~enc:bto
12931293- |> Jsont.Object.opt_mem "bcc" (Jsont.list Recipient.jsont) ~enc:bcc
12941294- |> Jsont.Object.opt_mem "published" Datetime.jsont ~enc:published
12951295- |> Jsont.Object.opt_mem "updated" Datetime.jsont ~enc:updated
12961296- |> Jsont.Object.opt_mem "summary" Jsont.string ~enc:summary
12971297- |> Jsont.Object.opt_mem "oneOf" (Jsont.list Object_ref.jsont) ~enc:one_of
12981298- |> Jsont.Object.opt_mem "anyOf" (Jsont.list Object_ref.jsont) ~enc:any_of
12991299- |> Jsont.Object.opt_mem "closed" Datetime.jsont ~enc:closed
13001300- |> Jsont.Object.finish
12811281+ |> Json.Codec.Object.opt_member "@context" Context.jsont ~enc:context
12821282+ |> Json.Codec.Object.opt_member "id" uri_jsont ~enc:id
12831283+ |> Json.Codec.Object.member "type" Activity_type.jsont ~enc:type_
12841284+ |> Json.Codec.Object.member "actor" Actor_ref.jsont ~enc:actor
12851285+ |> Json.Codec.Object.opt_member "object" Object_ref.jsont ~enc:object_
12861286+ |> Json.Codec.Object.opt_member "target" Object_ref.jsont ~enc:target
12871287+ |> Json.Codec.Object.opt_member "result" Object_ref.jsont ~enc:result
12881288+ |> Json.Codec.Object.opt_member "origin" Object_ref.jsont ~enc:origin
12891289+ |> Json.Codec.Object.opt_member "instrument" Object_ref.jsont ~enc:instrument
12901290+ |> Json.Codec.Object.opt_member "to" (Json.Codec.list Recipient.jsont) ~enc:to_
12911291+ |> Json.Codec.Object.opt_member "cc" (Json.Codec.list Recipient.jsont) ~enc:cc
12921292+ |> Json.Codec.Object.opt_member "bto" (Json.Codec.list Recipient.jsont) ~enc:bto
12931293+ |> Json.Codec.Object.opt_member "bcc" (Json.Codec.list Recipient.jsont) ~enc:bcc
12941294+ |> Json.Codec.Object.opt_member "published" Datetime.jsont ~enc:published
12951295+ |> Json.Codec.Object.opt_member "updated" Datetime.jsont ~enc:updated
12961296+ |> Json.Codec.Object.opt_member "summary" Json.Codec.string ~enc:summary
12971297+ |> Json.Codec.Object.opt_member "oneOf" (Json.Codec.list Object_ref.jsont) ~enc:one_of
12981298+ |> Json.Codec.Object.opt_member "anyOf" (Json.Codec.list Object_ref.jsont) ~enc:any_of
12991299+ |> Json.Codec.Object.opt_member "closed" Datetime.jsont ~enc:closed
13001300+ |> Json.Codec.Object.seal
13011301end
1302130213031303(** Activity reference - can be URI or full Activity. *)
···1308130813091309 val uri : Uri.t -> t
13101310 val activity : Activity.t -> t
13111311- val jsont : t Jsont.t
13111311+ val jsont : t Json.codec
13121312end = struct
13131313 type t =
13141314 | Uri of Uri.t
···13181318 let activity a = Activity a
1319131913201320 let jsont =
13211321- let dec_string = Jsont.map uri_jsont
13211321+ let dec_string = Json.Codec.map uri_jsont
13221322 ~dec:(fun u -> Uri u)
13231323 ~enc:(function Uri u -> u | Activity _ -> assert false) in
13241324- let dec_object = Jsont.map Activity.jsont
13241324+ let dec_object = Json.Codec.map Activity.jsont
13251325 ~dec:(fun a -> Activity a)
13261326 ~enc:(function Activity a -> a | Uri _ -> assert false) in
13271327- Jsont.any ~kind:"Activity reference"
13271327+ Json.Codec.any ~kind:"Activity reference"
13281328 ~dec_string ~dec_object
13291329 ~enc:(function
13301330 | Uri _ -> dec_string
···13591359 val items : 'a t -> 'a list option
13601360 val ordered : 'a t -> bool
1361136113621362- val jsont : 'a Jsont.t -> 'a t Jsont.t
13621362+ val jsont : 'a Json.codec -> 'a t Json.codec
13631363end = struct
13641364 type 'a t = {
13651365 context : Context.t option;
···1386138613871387 let jsont item_jsont =
13881388 let type_jsont =
13891389- Jsont.enum ~kind:"CollectionType" [
13891389+ Json.Codec.enum ~kind:"CollectionType" [
13901390 "Collection", false;
13911391 "OrderedCollection", true;
13921392 ]
13931393 in
13941394- let list_jsont = Jsont.list item_jsont in
13951395- Jsont.Object.map ~kind:"Collection"
13941394+ let list_jsont = Json.Codec.list item_jsont in
13951395+ Json.Codec.Object.map ~kind:"Collection"
13961396 (fun context id ordered total_items current first last items ordered_items ->
13971397 let items = match items, ordered_items with
13981398 | Some i, _ -> Some i
···14001400 | None, None -> None
14011401 in
14021402 { context; id; total_items; current; first; last; items; ordered })
14031403- |> Jsont.Object.opt_mem "@context" Context.jsont ~enc:context
14041404- |> Jsont.Object.opt_mem "id" uri_jsont ~enc:id
14051405- |> Jsont.Object.mem "type" type_jsont ~enc:ordered
14061406- |> Jsont.Object.opt_mem "totalItems" Jsont.int ~enc:total_items
14071407- |> Jsont.Object.opt_mem "current" uri_jsont ~enc:current
14081408- |> Jsont.Object.opt_mem "first" uri_jsont ~enc:first
14091409- |> Jsont.Object.opt_mem "last" uri_jsont ~enc:last
14101410- |> Jsont.Object.opt_mem "items" list_jsont
14031403+ |> Json.Codec.Object.opt_member "@context" Context.jsont ~enc:context
14041404+ |> Json.Codec.Object.opt_member "id" uri_jsont ~enc:id
14051405+ |> Json.Codec.Object.member "type" type_jsont ~enc:ordered
14061406+ |> Json.Codec.Object.opt_member "totalItems" Json.Codec.int ~enc:total_items
14071407+ |> Json.Codec.Object.opt_member "current" uri_jsont ~enc:current
14081408+ |> Json.Codec.Object.opt_member "first" uri_jsont ~enc:first
14091409+ |> Json.Codec.Object.opt_member "last" uri_jsont ~enc:last
14101410+ |> Json.Codec.Object.opt_member "items" list_jsont
14111411 ~enc:(fun t -> if t.ordered then None else t.items)
14121412- |> Jsont.Object.opt_mem "orderedItems" list_jsont
14121412+ |> Json.Codec.Object.opt_member "orderedItems" list_jsont
14131413 ~enc:(fun t -> if t.ordered then t.items else None)
14141414- |> Jsont.Object.finish
14141414+ |> Json.Codec.Object.seal
14151415end
1416141614171417(** {1 Collection Page} *)
···14471447 val items : 'a t -> 'a list option
14481448 val ordered : 'a t -> bool
1449144914501450- val jsont : 'a Jsont.t -> 'a t Jsont.t
14501450+ val jsont : 'a Json.codec -> 'a t Json.codec
14511451end = struct
14521452 type 'a t = {
14531453 context : Context.t option;
···1482148214831483 let jsont item_jsont =
14841484 let type_jsont =
14851485- Jsont.enum ~kind:"CollectionPageType" [
14851485+ Json.Codec.enum ~kind:"CollectionPageType" [
14861486 "CollectionPage", false;
14871487 "OrderedCollectionPage", true;
14881488 ]
14891489 in
14901490- let list_jsont = Jsont.list item_jsont in
14911491- Jsont.Object.map ~kind:"CollectionPage"
14901490+ let list_jsont = Json.Codec.list item_jsont in
14911491+ Json.Codec.Object.map ~kind:"CollectionPage"
14921492 (fun context id ordered total_items current first last prev next
14931493 part_of items ordered_items ->
14941494 let items = match items, ordered_items with
···14981498 in
14991499 { context; id; total_items; current; first; last; prev; next;
15001500 part_of; items; ordered })
15011501- |> Jsont.Object.opt_mem "@context" Context.jsont ~enc:context
15021502- |> Jsont.Object.opt_mem "id" uri_jsont ~enc:id
15031503- |> Jsont.Object.mem "type" type_jsont ~enc:ordered
15041504- |> Jsont.Object.opt_mem "totalItems" Jsont.int ~enc:total_items
15051505- |> Jsont.Object.opt_mem "current" uri_jsont ~enc:current
15061506- |> Jsont.Object.opt_mem "first" uri_jsont ~enc:first
15071507- |> Jsont.Object.opt_mem "last" uri_jsont ~enc:last
15081508- |> Jsont.Object.opt_mem "prev" uri_jsont ~enc:prev
15091509- |> Jsont.Object.opt_mem "next" uri_jsont ~enc:next
15101510- |> Jsont.Object.opt_mem "partOf" uri_jsont ~enc:part_of
15111511- |> Jsont.Object.opt_mem "items" list_jsont
15011501+ |> Json.Codec.Object.opt_member "@context" Context.jsont ~enc:context
15021502+ |> Json.Codec.Object.opt_member "id" uri_jsont ~enc:id
15031503+ |> Json.Codec.Object.member "type" type_jsont ~enc:ordered
15041504+ |> Json.Codec.Object.opt_member "totalItems" Json.Codec.int ~enc:total_items
15051505+ |> Json.Codec.Object.opt_member "current" uri_jsont ~enc:current
15061506+ |> Json.Codec.Object.opt_member "first" uri_jsont ~enc:first
15071507+ |> Json.Codec.Object.opt_member "last" uri_jsont ~enc:last
15081508+ |> Json.Codec.Object.opt_member "prev" uri_jsont ~enc:prev
15091509+ |> Json.Codec.Object.opt_member "next" uri_jsont ~enc:next
15101510+ |> Json.Codec.Object.opt_member "partOf" uri_jsont ~enc:part_of
15111511+ |> Json.Codec.Object.opt_member "items" list_jsont
15121512 ~enc:(fun t -> if t.ordered then None else t.items)
15131513- |> Jsont.Object.opt_mem "orderedItems" list_jsont
15131513+ |> Json.Codec.Object.opt_member "orderedItems" list_jsont
15141514 ~enc:(fun t -> if t.ordered then t.items else None)
15151515- |> Jsont.Object.finish
15151515+ |> Json.Codec.Object.seal
15161516end
1517151715181518(** {1 Convenience type aliases} *)
···15201520(** Activity collection. *)
15211521module Activity_collection : sig
15221522 type t = Activity.t Collection.t
15231523- val jsont : t Jsont.t
15231523+ val jsont : t Json.codec
15241524end = struct
15251525 type t = Activity.t Collection.t
15261526 let jsont = Collection.jsont Activity.jsont
···15291529(** Object collection. *)
15301530module Object_collection : sig
15311531 type t = Object.t Collection.t
15321532- val jsont : t Jsont.t
15321532+ val jsont : t Json.codec
15331533end = struct
15341534 type t = Object.t Collection.t
15351535 let jsont = Collection.jsont Object.jsont
···15381538(** Activity collection page. *)
15391539module Activity_collection_page : sig
15401540 type t = Activity.t Collection_page.t
15411541- val jsont : t Jsont.t
15411541+ val jsont : t Json.codec
15421542end = struct
15431543 type t = Activity.t Collection_page.t
15441544 let jsont = Collection_page.jsont Activity.jsont
···15471547(** Object collection page. *)
15481548module Object_collection_page : sig
15491549 type t = Object.t Collection_page.t
15501550- val jsont : t Jsont.t
15501550+ val jsont : t Json.codec
15511551end = struct
15521552 type t = Object.t Collection_page.t
15531553 let jsont = Collection_page.jsont Object.jsont
···15741574 val href : t -> Uri.t option
15751575 val template : t -> string option
1576157615771577- val jsont : t Jsont.t
15771577+ val jsont : t Json.codec
15781578 end
1579157915801580 (** The Webfinger JRD response. *)
···15921592 val properties : t -> (string * string) list option
15931593 val links : t -> Jrd_link.t list option
1594159415951595- val jsont : t Jsont.t
15951595+ val jsont : t Json.codec
15961596end = struct
15971597 module Jrd_link = struct
15981598 type t = {
···16111611 let template t = t.template
1612161216131613 let jsont =
16141614- Jsont.Object.map ~kind:"JrdLink"
16141614+ Json.Codec.Object.map ~kind:"JrdLink"
16151615 (fun rel type_ href template -> { rel; type_; href; template })
16161616- |> Jsont.Object.mem "rel" Jsont.string ~enc:rel
16171617- |> Jsont.Object.opt_mem "type" Jsont.string ~enc:type_
16181618- |> Jsont.Object.opt_mem "href" uri_jsont ~enc:href
16191619- |> Jsont.Object.opt_mem "template" Jsont.string ~enc:template
16201620- |> Jsont.Object.finish
16161616+ |> Json.Codec.Object.member "rel" Json.Codec.string ~enc:rel
16171617+ |> Json.Codec.Object.opt_member "type" Json.Codec.string ~enc:type_
16181618+ |> Json.Codec.Object.opt_member "href" uri_jsont ~enc:href
16191619+ |> Json.Codec.Object.opt_member "template" Json.Codec.string ~enc:template
16201620+ |> Json.Codec.Object.seal
16211621 end
1622162216231623 type t = {
···16381638 module String_map = Map.Make(String)
1639163916401640 let properties_jsont =
16411641- Jsont.Object.as_string_map Jsont.string
16421642- |> Jsont.map
16411641+ Json.Codec.Object.as_string_map Json.Codec.string
16421642+ |> Json.Codec.map
16431643 ~dec:(fun m -> String_map.bindings m)
16441644 ~enc:(fun l -> List.fold_left (fun m (k, v) ->
16451645 String_map.add k v m) String_map.empty l)
1646164616471647 let jsont =
16481648- Jsont.Object.map ~kind:"Webfinger"
16481648+ Json.Codec.Object.map ~kind:"Webfinger"
16491649 (fun subject aliases properties links ->
16501650 { subject; aliases; properties; links })
16511651- |> Jsont.Object.mem "subject" Jsont.string ~enc:subject
16521652- |> Jsont.Object.opt_mem "aliases" (Jsont.list Jsont.string) ~enc:aliases
16531653- |> Jsont.Object.opt_mem "properties" properties_jsont ~enc:properties
16541654- |> Jsont.Object.opt_mem "links" (Jsont.list Jrd_link.jsont) ~enc:links
16551655- |> Jsont.Object.finish
16511651+ |> Json.Codec.Object.member "subject" Json.Codec.string ~enc:subject
16521652+ |> Json.Codec.Object.opt_member "aliases" (Json.Codec.list Json.Codec.string) ~enc:aliases
16531653+ |> Json.Codec.Object.opt_member "properties" properties_jsont ~enc:properties
16541654+ |> Json.Codec.Object.opt_member "links" (Json.Codec.list Jrd_link.jsont) ~enc:links
16551655+ |> Json.Codec.Object.seal
16561656end
1657165716581658(** {1 NodeInfo} *)
···16761676 val repository : t -> Uri.t option
16771677 val homepage : t -> Uri.t option
1678167816791679- val jsont : t Jsont.t
16791679+ val jsont : t Json.codec
16801680 end
1681168116821682 (** Usage statistics. *)
···16971697 val local_posts : t -> int option
16981698 val local_comments : t -> int option
1699169917001700- val jsont : t Jsont.t
17001700+ val jsont : t Json.codec
17011701 end
1702170217031703 type t
···17081708 protocols:string list ->
17091709 usage:Usage.t ->
17101710 open_registrations:bool ->
17111711- ?metadata:Jsont.json ->
17111711+ ?metadata:Json.t ->
17121712 unit -> t
1713171317141714 val version : t -> string
···17161716 val protocols : t -> string list
17171717 val usage : t -> Usage.t
17181718 val open_registrations : t -> bool
17191719- val metadata : t -> Jsont.json option
17191719+ val metadata : t -> Json.t option
1720172017211721- val jsont : t Jsont.t
17211721+ val jsont : t Json.codec
17221722end = struct
17231723 module Software = struct
17241724 type t = {
···17371737 let homepage t = t.homepage
1738173817391739 let jsont =
17401740- Jsont.Object.map ~kind:"Software"
17401740+ Json.Codec.Object.map ~kind:"Software"
17411741 (fun name version repository homepage ->
17421742 { name; version; repository; homepage })
17431743- |> Jsont.Object.mem "name" Jsont.string ~enc:name
17441744- |> Jsont.Object.mem "version" Jsont.string ~enc:version
17451745- |> Jsont.Object.opt_mem "repository" uri_jsont ~enc:repository
17461746- |> Jsont.Object.opt_mem "homepage" uri_jsont ~enc:homepage
17471747- |> Jsont.Object.finish
17431743+ |> Json.Codec.Object.member "name" Json.Codec.string ~enc:name
17441744+ |> Json.Codec.Object.member "version" Json.Codec.string ~enc:version
17451745+ |> Json.Codec.Object.opt_member "repository" uri_jsont ~enc:repository
17461746+ |> Json.Codec.Object.opt_member "homepage" uri_jsont ~enc:homepage
17471747+ |> Json.Codec.Object.seal
17481748 end
1749174917501750 module Usage = struct
···17681768 let local_comments t = t.local_comments
1769176917701770 let users_jsont =
17711771- Jsont.Object.map ~kind:"Users"
17711771+ Json.Codec.Object.map ~kind:"Users"
17721772 (fun total active_half_year active_month ->
17731773 (total, active_half_year, active_month))
17741774- |> Jsont.Object.opt_mem "total" Jsont.int
17741774+ |> Json.Codec.Object.opt_member "total" Json.Codec.int
17751775 ~enc:(fun (t, _, _) -> t)
17761776- |> Jsont.Object.opt_mem "activeHalfyear" Jsont.int
17761776+ |> Json.Codec.Object.opt_member "activeHalfyear" Json.Codec.int
17771777 ~enc:(fun (_, h, _) -> h)
17781778- |> Jsont.Object.opt_mem "activeMonth" Jsont.int
17781778+ |> Json.Codec.Object.opt_member "activeMonth" Json.Codec.int
17791779 ~enc:(fun (_, _, m) -> m)
17801780- |> Jsont.Object.finish
17801780+ |> Json.Codec.Object.seal
1781178117821782 let jsont =
17831783- Jsont.Object.map ~kind:"Usage"
17831783+ Json.Codec.Object.map ~kind:"Usage"
17841784 (fun (users_total, users_active_half_year, users_active_month)
17851785 local_posts local_comments ->
17861786 { users_total; users_active_half_year; users_active_month;
17871787 local_posts; local_comments })
17881788- |> Jsont.Object.mem "users" users_jsont
17881788+ |> Json.Codec.Object.member "users" users_jsont
17891789 ~dec_absent:(None, None, None)
17901790 ~enc:(fun t -> (t.users_total, t.users_active_half_year,
17911791 t.users_active_month))
17921792- |> Jsont.Object.opt_mem "localPosts" Jsont.int ~enc:local_posts
17931793- |> Jsont.Object.opt_mem "localComments" Jsont.int ~enc:local_comments
17941794- |> Jsont.Object.finish
17921792+ |> Json.Codec.Object.opt_member "localPosts" Json.Codec.int ~enc:local_posts
17931793+ |> Json.Codec.Object.opt_member "localComments" Json.Codec.int ~enc:local_comments
17941794+ |> Json.Codec.Object.seal
17951795 end
1796179617971797 type t = {
···18001800 protocols : string list;
18011801 usage : Usage.t;
18021802 open_registrations : bool;
18031803- metadata : Jsont.json option;
18031803+ metadata : Json.t option;
18041804 }
1805180518061806 let make ~version ~software ~protocols ~usage ~open_registrations
···18151815 let metadata t = t.metadata
1816181618171817 let jsont =
18181818- Jsont.Object.map ~kind:"Nodeinfo"
18181818+ Json.Codec.Object.map ~kind:"Nodeinfo"
18191819 (fun version software protocols usage open_registrations metadata ->
18201820 { version; software; protocols; usage; open_registrations; metadata })
18211821- |> Jsont.Object.mem "version" Jsont.string ~enc:version
18221822- |> Jsont.Object.mem "software" Software.jsont ~enc:software
18231823- |> Jsont.Object.mem "protocols" (Jsont.list Jsont.string) ~enc:protocols
18241824- |> Jsont.Object.mem "usage" Usage.jsont ~enc:usage
18251825- |> Jsont.Object.mem "openRegistrations" Jsont.bool ~enc:open_registrations
18261826- |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:metadata
18271827- |> Jsont.Object.finish
18211821+ |> Json.Codec.Object.member "version" Json.Codec.string ~enc:version
18221822+ |> Json.Codec.Object.member "software" Software.jsont ~enc:software
18231823+ |> Json.Codec.Object.member "protocols" (Json.Codec.list Json.Codec.string) ~enc:protocols
18241824+ |> Json.Codec.Object.member "usage" Usage.jsont ~enc:usage
18251825+ |> Json.Codec.Object.member "openRegistrations" Json.Codec.bool ~enc:open_registrations
18261826+ |> Json.Codec.Object.opt_member "metadata" Json.Codec.Value.t ~enc:metadata
18271827+ |> Json.Codec.Object.seal
18281828end
+36-38
lib/proto/apubt_proto.mli
···11-(** ActivityPub/ActivityStreams protocol types with jsont codecs.
11+(** ActivityPub/ActivityStreams protocol types with nox-json codecs.
2233 This module provides OCaml types and bidirectional JSON codecs for the
44 ActivityPub and ActivityStreams 2.0 specifications. It is the wire format
···99 {[
1010 (* Decode an actor from JSON *)
1111 let json_str = {|{"@id": "...", "@type": "Person", ...}|} in
1212- match Jsont_bytesrw.decode_string Actor.jsont json_str with
1212+ match Json.of_string Actor.jsont json_str with
1313 | Ok actor -> Printf.printf "Actor: %s\n" (Option.value ~default:"" (Actor.name actor))
1414- | Error e -> Printf.eprintf "Error: %a\n" Jsont.Error.pp e
1414+ | Error e -> Printf.eprintf "Error: %a\n" Json.Error.pp e
15151616 (* Create and encode a Note *)
1717 let note = Object.make ~type_:Object_type.Note
1818 ~content:"Hello ActivityPub!" () in
1919- match Jsont_bytesrw.encode_string Object.jsont note with
2020- | Ok json_str -> print_endline json_str
2121- | Error e -> Printf.eprintf "Error: %a\n" Jsont.Error.pp e
1919+ print_endline (Json.to_string Object.jsont note)
2220 ]}
23212422 @see <https://www.w3.org/TR/activitypub/> ActivityPub specification
···3735 val to_string : t -> string
3836 (** [to_string t] returns the datetime as an ISO 8601 string. *)
39374040- val jsont : t Jsont.t
3838+ val jsont : t Json.codec
4139 (** JSON type for datetimes. *)
4240end
43414444-val uri_jsont : Uri.t Jsont.t
4242+val uri_jsont : Uri.t Json.codec
4543(** JSON codec for [Uri.t] values. *)
46444745(** JSON-LD context. *)
···5149 val default : t
5250 (** The default ActivityStreams context. *)
53515454- val jsont : t Jsont.t
5252+ val jsont : t Json.codec
5553 (** JSON type for contexts. *)
5654end
5755···8179 val width : t -> int option
8280 val preview : t -> Uri.t option
83818484- val jsont : t Jsont.t
8282+ val jsont : t Json.codec
8583 (** JSON type for Links. *)
8684end
8785···93919492 val uri : Uri.t -> t
9593 val link : Link.t -> t
9696- val jsont : t Jsont.t
9494+ val jsont : t Json.codec
9795end
98969997(** {1 Image} *)
···119117 val width : t -> int option
120118 val height : t -> int option
121119122122- val jsont : t Jsont.t
120120+ val jsont : t Json.codec
123121end
124122125123(** Image reference - can be URI, Link, or full Image object. *)
···132130 val uri : Uri.t -> t
133131 val link : Link.t -> t
134132 val image : Image.t -> t
135135- val jsont : t Jsont.t
133133+ val jsont : t Json.codec
136134end
137135138136(** {1 Public Collection} *)
···152150 val make : ?type_:string -> Uri.t -> t
153151 val id : t -> Uri.t
154152 val type_ : t -> string option
155155- val jsont : t Jsont.t
153153+ val jsont : t Json.codec
156154end
157155158156(** {1 Endpoints} *)
···177175 val sign_client_key : t -> Uri.t option
178176 val shared_inbox : t -> Uri.t option
179177180180- val jsont : t Jsont.t
178178+ val jsont : t Json.codec
181179end
182180183181(** {1 Public Key} *)
···196194 val owner : t -> Uri.t
197195 val public_key_pem : t -> string
198196199199- val jsont : t Jsont.t
197197+ val jsont : t Json.codec
200198end
201199202200(** {1 Actor Types} *)
···212210213211 val to_string : t -> string
214212 val of_string : string -> t option
215215- val jsont : t Jsont.t
213213+ val jsont : t Json.codec
216214end
217215218216(** {1 Actor} *)
···275273 val featured : t -> Uri.t option
276274 val featured_tags : t -> Uri.t option
277275278278- val jsont : t Jsont.t
276276+ val jsont : t Json.codec
279277 (** JSON type for Actors. *)
280278end
281279···287285288286 val uri : Uri.t -> t
289287 val actor : Actor.t -> t
290290- val jsont : t Jsont.t
288288+ val jsont : t Json.codec
291289end
292290293291(** {1 Object Types} *)
···311309312310 val to_string : t -> string
313311 val of_string : string -> t option
314314- val jsont : t Jsont.t
312312+ val jsont : t Json.codec
315313end
316314317315(** {1 Object} *)
···392390 val preview : t -> Link_or_uri.t option
393391 (** [preview t] returns a preview of the object, typically a smaller version. *)
394392395395- val jsont : t Jsont.t
393393+ val jsont : t Json.codec
396394 (** JSON type for Objects. *)
397395end
398396···404402405403 val uri : Uri.t -> t
406404 val obj : Object.t -> t
407407- val jsont : t Jsont.t
405405+ val jsont : t Json.codec
408406end
409407410408(** {1 Activity Types} *)
···442440443441 val to_string : t -> string
444442 val of_string : string -> t option
445445- val jsont : t Jsont.t
443443+ val jsont : t Json.codec
446444end
447445448446(** {1 Activity} *)
···505503 val closed : t -> Datetime.t option
506504 (** [closed t] returns when the poll was closed, for Question activities. *)
507505508508- val jsont : t Jsont.t
506506+ val jsont : t Json.codec
509507 (** JSON type for Activities. *)
510508end
511509···517515518516 val uri : Uri.t -> t
519517 val activity : Activity.t -> t
520520- val jsont : t Jsont.t
518518+ val jsont : t Json.codec
521519end
522520523521(** {1 Collection} *)
···548546 val items : 'a t -> 'a list option
549547 val ordered : 'a t -> bool
550548551551- val jsont : 'a Jsont.t -> 'a t Jsont.t
549549+ val jsont : 'a Json.codec -> 'a t Json.codec
552550 (** JSON type for Collections, parameterized by item type. *)
553551end
554552···586584 val items : 'a t -> 'a list option
587585 val ordered : 'a t -> bool
588586589589- val jsont : 'a Jsont.t -> 'a t Jsont.t
587587+ val jsont : 'a Json.codec -> 'a t Json.codec
590588 (** JSON type for CollectionPages, parameterized by item type. *)
591589end
592590···595593(** Activity collection. *)
596594module Activity_collection : sig
597595 type t = Activity.t Collection.t
598598- val jsont : t Jsont.t
596596+ val jsont : t Json.codec
599597end
600598601599(** Object collection. *)
602600module Object_collection : sig
603601 type t = Object.t Collection.t
604604- val jsont : t Jsont.t
602602+ val jsont : t Json.codec
605603end
606604607605(** Activity collection page. *)
608606module Activity_collection_page : sig
609607 type t = Activity.t Collection_page.t
610610- val jsont : t Jsont.t
608608+ val jsont : t Json.codec
611609end
612610613611(** Object collection page. *)
614612module Object_collection_page : sig
615613 type t = Object.t Collection_page.t
616616- val jsont : t Jsont.t
614614+ val jsont : t Json.codec
617615end
618616619617(** {1 Webfinger} *)
···637635 val href : t -> Uri.t option
638636 val template : t -> string option
639637640640- val jsont : t Jsont.t
638638+ val jsont : t Json.codec
641639 end
642640643641 type t
···654652 val properties : t -> (string * string) list option
655653 val links : t -> Jrd_link.t list option
656654657657- val jsont : t Jsont.t
655655+ val jsont : t Json.codec
658656end
659657660658(** {1 NodeInfo} *)
···678676 val repository : t -> Uri.t option
679677 val homepage : t -> Uri.t option
680678681681- val jsont : t Jsont.t
679679+ val jsont : t Json.codec
682680 end
683681684682 (** Usage statistics. *)
···699697 val local_posts : t -> int option
700698 val local_comments : t -> int option
701699702702- val jsont : t Jsont.t
700700+ val jsont : t Json.codec
703701 end
704702705703 type t
···710708 protocols:string list ->
711709 usage:Usage.t ->
712710 open_registrations:bool ->
713713- ?metadata:Jsont.json ->
711711+ ?metadata:Json.t ->
714712 unit -> t
715713716714 val version : t -> string
···718716 val protocols : t -> string list
719717 val usage : t -> Usage.t
720718 val open_registrations : t -> bool
721721- val metadata : t -> Jsont.json option
719719+ val metadata : t -> Json.t option
722720723723- val jsont : t Jsont.t
721721+ val jsont : t Json.codec
724722end