···11+type t =
22+ { mutable imports: string list
33+ ; mutable generated_unions: string list
44+ ; mutable union_names: (string list * string) list (* refs -> context name *)
55+ ; buf: Buffer.t }
66+77+let make () =
88+ {imports= []; generated_unions= []; union_names= []; buf= Buffer.create 4096}
99+1010+(** add an import if not already present *)
1111+let add_import t module_name =
1212+ if not (List.mem module_name t.imports) then
1313+ t.imports <- module_name :: t.imports
1414+1515+let get_imports t = t.imports
1616+1717+(** mark a union type as generated to avoid duplicates *)
1818+let mark_union_generated t union_name =
1919+ if not (List.mem union_name t.generated_unions) then
2020+ t.generated_unions <- union_name :: t.generated_unions
2121+2222+let is_union_generated t union_name = List.mem union_name t.generated_unions
2323+2424+(** register a context-based name for a union based on its refs,
2525+ allowing inline unions to be reused when the same refs appear elsewhere *)
2626+let register_union_name t refs context_name =
2727+ let sorted_refs = List.sort String.compare refs in
2828+ if not (List.exists (fun (r, _) -> r = sorted_refs) t.union_names) then
2929+ t.union_names <- (sorted_refs, context_name) :: t.union_names
3030+3131+(** look up a union's registered context-based name *)
3232+let lookup_union_name t refs =
3333+ let sorted_refs = List.sort String.compare refs in
3434+ List.assoc_opt sorted_refs t.union_names
3535+3636+let emit t s = Buffer.add_string t.buf s
3737+3838+let emitln t s = Buffer.add_string t.buf s ; Buffer.add_char t.buf '\n'
3939+4040+let emit_newline t = Buffer.add_char t.buf '\n'
4141+4242+let contents t = Buffer.contents t.buf
+226
hermes-cli/lib/scc.ml
···11+open Lexicon_types
22+33+(** returns SCCs in reverse topological order (dependencies first)
44+ each SCC is a list of nodes *)
55+let find_sccs (type node) (nodes : node list) ~(get_id : node -> string)
66+ ~(get_deps : node -> string list) : node list list =
77+ (* build node map: id -> node *)
88+ let node_map =
99+ List.fold_left (fun m node -> (get_id node, node) :: m) [] nodes
1010+ in
1111+ let node_ids = List.map get_id nodes in
1212+ (* build dependency map *)
1313+ let deps = List.map (fun node -> (get_id node, get_deps node)) nodes in
1414+ (* Tarjan's algorithm state *)
1515+ let index_counter = ref 0 in
1616+ let indices = Hashtbl.create 64 in
1717+ let lowlinks = Hashtbl.create 64 in
1818+ let on_stack = Hashtbl.create 64 in
1919+ let stack = ref [] in
2020+ let sccs = ref [] in
2121+ let rec strongconnect id =
2222+ let index = !index_counter in
2323+ incr index_counter ;
2424+ Hashtbl.add indices id index ;
2525+ Hashtbl.add lowlinks id index ;
2626+ Hashtbl.add on_stack id true ;
2727+ stack := id :: !stack ;
2828+ (* visit successors *)
2929+ let successors =
3030+ try List.assoc id deps |> List.filter (fun s -> List.mem s node_ids)
3131+ with Not_found -> []
3232+ in
3333+ List.iter
3434+ (fun succ ->
3535+ if not (Hashtbl.mem indices succ) then begin
3636+ (* successor not yet visited *)
3737+ strongconnect succ ;
3838+ Hashtbl.replace lowlinks id
3939+ (min (Hashtbl.find lowlinks id) (Hashtbl.find lowlinks succ))
4040+ end
4141+ else if Hashtbl.find_opt on_stack succ = Some true then
4242+ (* successor is on stack, part of current SCC *)
4343+ Hashtbl.replace lowlinks id
4444+ (min (Hashtbl.find lowlinks id) (Hashtbl.find indices succ)) )
4545+ successors ;
4646+ (* if this is a root node, pop the SCC *)
4747+ if Hashtbl.find lowlinks id = Hashtbl.find indices id then begin
4848+ let rec pop_scc acc =
4949+ match !stack with
5050+ | [] ->
5151+ acc
5252+ | top :: rest ->
5353+ stack := rest ;
5454+ Hashtbl.replace on_stack top false ;
5555+ if top = id then top :: acc else pop_scc (top :: acc)
5656+ in
5757+ let scc_ids = pop_scc [] in
5858+ (* convert IDs to nodes, preserving original order *)
5959+ let scc_nodes =
6060+ List.filter_map
6161+ (fun n -> List.assoc_opt n node_map)
6262+ (List.filter (fun n -> List.mem n scc_ids) node_ids)
6363+ in
6464+ if scc_nodes <> [] then sccs := scc_nodes :: !sccs
6565+ end
6666+ in
6767+ (* run on all nodes *)
6868+ List.iter
6969+ (fun id -> if not (Hashtbl.mem indices id) then strongconnect id)
7070+ node_ids ;
7171+ (* SCCs are prepended, so reverse to get topological order *)
7272+ List.rev !sccs
7373+7474+(** returns list of definition names that this type depends on within the same nsid *)
7575+let rec collect_local_refs nsid acc = function
7676+ | Array {items; _} ->
7777+ collect_local_refs nsid acc items
7878+ | Ref {ref_; _} ->
7979+ if String.length ref_ > 0 && ref_.[0] = '#' then
8080+ (* local ref: #foo *)
8181+ let def_name = String.sub ref_ 1 (String.length ref_ - 1) in
8282+ def_name :: acc
8383+ else begin
8484+ (* check if it's a self-reference: nsid#foo *)
8585+ match String.split_on_char '#' ref_ with
8686+ | [ext_nsid; def_name] when ext_nsid = nsid ->
8787+ def_name :: acc
8888+ | _ ->
8989+ acc
9090+ end
9191+ | Union {refs; _} ->
9292+ List.fold_left
9393+ (fun a r ->
9494+ if String.length r > 0 && r.[0] = '#' then
9595+ let def_name = String.sub r 1 (String.length r - 1) in
9696+ def_name :: a
9797+ else
9898+ match String.split_on_char '#' r with
9999+ | [ext_nsid; def_name] when ext_nsid = nsid ->
100100+ def_name :: a
101101+ | _ ->
102102+ a )
103103+ acc refs
104104+ | Object {properties; _} ->
105105+ List.fold_left
106106+ (fun a (_, (prop : property)) -> collect_local_refs nsid a prop.type_def)
107107+ acc properties
108108+ | Record {record; _} ->
109109+ List.fold_left
110110+ (fun a (_, (prop : property)) -> collect_local_refs nsid a prop.type_def)
111111+ acc record.properties
112112+ | Query {parameters; output; _} -> (
113113+ let acc =
114114+ match parameters with
115115+ | Some params ->
116116+ List.fold_left
117117+ (fun a (_, (prop : property)) ->
118118+ collect_local_refs nsid a prop.type_def )
119119+ acc params.properties
120120+ | None ->
121121+ acc
122122+ in
123123+ match output with
124124+ | Some body ->
125125+ Option.fold ~none:acc ~some:(collect_local_refs nsid acc) body.schema
126126+ | None ->
127127+ acc )
128128+ | Procedure {parameters; input; output; _} -> (
129129+ let acc =
130130+ match parameters with
131131+ | Some params ->
132132+ List.fold_left
133133+ (fun a (_, (prop : property)) ->
134134+ collect_local_refs nsid a prop.type_def )
135135+ acc params.properties
136136+ | None ->
137137+ acc
138138+ in
139139+ let acc =
140140+ match input with
141141+ | Some body ->
142142+ Option.fold ~none:acc
143143+ ~some:(collect_local_refs nsid acc)
144144+ body.schema
145145+ | None ->
146146+ acc
147147+ in
148148+ match output with
149149+ | Some body ->
150150+ Option.fold ~none:acc ~some:(collect_local_refs nsid acc) body.schema
151151+ | None ->
152152+ acc )
153153+ | _ ->
154154+ acc
155155+156156+(** find SCCs among definitions within a single lexicon
157157+ returns SCCs in reverse topological order *)
158158+let find_def_sccs nsid (defs : def_entry list) : def_entry list list =
159159+ find_sccs defs
160160+ ~get_id:(fun def -> def.name)
161161+ ~get_deps:(fun def -> collect_local_refs nsid [] def.type_def)
162162+163163+(** get external nsid dependencies for a lexicon *)
164164+let get_external_nsids (doc : lexicon_doc) : string list =
165165+ let nsids = ref [] in
166166+ let add_nsid s = if not (List.mem s !nsids) then nsids := s :: !nsids in
167167+ let rec collect_from_type = function
168168+ | Array {items; _} ->
169169+ collect_from_type items
170170+ | Ref {ref_; _} ->
171171+ if String.length ref_ > 0 && ref_.[0] <> '#' then begin
172172+ match String.split_on_char '#' ref_ with
173173+ | ext_nsid :: _ ->
174174+ add_nsid ext_nsid
175175+ | [] ->
176176+ ()
177177+ end
178178+ | Union {refs; _} ->
179179+ List.iter
180180+ (fun r ->
181181+ if String.length r > 0 && r.[0] <> '#' then
182182+ match String.split_on_char '#' r with
183183+ | ext_nsid :: _ ->
184184+ add_nsid ext_nsid
185185+ | [] ->
186186+ () )
187187+ refs
188188+ | Object {properties; _} ->
189189+ List.iter
190190+ (fun (_, (prop : property)) -> collect_from_type prop.type_def)
191191+ properties
192192+ | Query {parameters; output; _} ->
193193+ Option.iter
194194+ (fun p ->
195195+ List.iter
196196+ (fun (_, (prop : property)) -> collect_from_type prop.type_def)
197197+ p.properties )
198198+ parameters ;
199199+ Option.iter (fun o -> Option.iter collect_from_type o.schema) output
200200+ | Procedure {parameters; input; output; _} ->
201201+ Option.iter
202202+ (fun p ->
203203+ List.iter
204204+ (fun (_, (prop : property)) -> collect_from_type prop.type_def)
205205+ p.properties )
206206+ parameters ;
207207+ Option.iter (fun i -> Option.iter collect_from_type i.schema) input ;
208208+ Option.iter (fun o -> Option.iter collect_from_type o.schema) output
209209+ | Record {record; _} ->
210210+ List.iter
211211+ (fun (_, (prop : property)) -> collect_from_type prop.type_def)
212212+ record.properties
213213+ | _ ->
214214+ ()
215215+ in
216216+ List.iter (fun def -> collect_from_type def.type_def) doc.defs ;
217217+ !nsids
218218+219219+(** find SCCs between lexicon files, in reverse topological order *)
220220+let find_file_sccs (lexicons : lexicon_doc list) : lexicon_doc list list =
221221+ let nsids = List.map (fun doc -> doc.id) lexicons in
222222+ find_sccs lexicons
223223+ ~get_id:(fun doc -> doc.id)
224224+ ~get_deps:(fun doc ->
225225+ (* filter to only include nsids we have *)
226226+ get_external_nsids doc |> List.filter (fun n -> List.mem n nsids) )
+2-2
pegasus/lib/api/admin/deleteAccount.ml
···11-type request = {did: string} [@@deriving yojson {strict= false}]
11+open Lexicons.Com_atproto_admin_deleteAccount.Main
2233let handler =
44 Xrpc.handler ~auth:Admin (fun {req; db; _} ->
55- let%lwt {did} = Xrpc.parse_body req request_of_yojson in
55+ let%lwt {did} = Xrpc.parse_body req input_of_yojson in
66 match%lwt Data_store.get_actor_by_identifier did db with
77 | None ->
88 Errors.invalid_request "account not found"
···11+(* generated from app.bsky.actor.getPreferences *)
22+33+(** Get private preferences attached to the current account. Expected use is synchronization between multiple devices, and import/export during account migration. Requires auth. *)
44+module Main = struct
55+ let nsid = "app.bsky.actor.getPreferences"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type output =
1111+ {
1212+ preferences: App_bsky_actor_defs.preferences;
1313+ }
1414+[@@deriving yojson {strict= false}]
1515+1616+ let call
1717+ (client : Hermes.client) : output Lwt.t =
1818+ Hermes.query client nsid (`Assoc []) output_of_yojson
1919+end
2020+
+22
pegasus/lib/lexicons/app_bsky_actor_getProfile.ml
···11+(* generated from app.bsky.actor.getProfile *)
22+33+(** Get detailed profile view of an actor. Does not require auth, but contains relevant metadata with auth. *)
44+module Main = struct
55+ let nsid = "app.bsky.actor.getProfile"
66+77+ type params =
88+ {
99+ actor: string;
1010+ }
1111+[@@deriving yojson {strict= false}]
1212+1313+ type output = App_bsky_actor_defs.profile_view_detailed
1414+[@@deriving yojson {strict= false}]
1515+1616+ let call
1717+ ~actor
1818+ (client : Hermes.client) : output Lwt.t =
1919+ let params : params = {actor} in
2020+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
2121+end
2222+
···11+(* generated from app.bsky.actor.putPreferences *)
22+33+(** Set the private preferences attached to the account. *)
44+module Main = struct
55+ let nsid = "app.bsky.actor.putPreferences"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ preferences: App_bsky_actor_defs.preferences;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~preferences
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({preferences} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from app.bsky.bookmark.deleteBookmark *)
22+33+(** Deletes a private bookmark for the specified record. Currently, only `app.bsky.feed.post` records are supported. Requires authentication. *)
44+module Main = struct
55+ let nsid = "app.bsky.bookmark.deleteBookmark"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ uri: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~uri
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({uri} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from app.bsky.contact.dismissMatch *)
22+33+(** Removes a match that was found via contact import. It shouldn't appear again if the same contact is re-imported. Requires authentication. *)
44+module Main = struct
55+ let nsid = "app.bsky.contact.dismissMatch"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ subject: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+let output_of_yojson _ = Ok ()
1818+let output_to_yojson () = `Assoc []
1919+2020+ let call
2121+ ~subject
2222+ (client : Hermes.client) : output Lwt.t =
2323+ let params = () in
2424+ let input = Some ({subject} |> input_to_yojson) in
2525+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2626+end
2727+
···11+(* generated from app.bsky.contact.removeData *)
22+33+(** Removes all stored hashes used for contact matching, existing matches, and sync status. Requires authentication. *)
44+module Main = struct
55+ let nsid = "app.bsky.contact.removeData"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input = unit
1111+ let input_of_yojson _ = Ok ()
1212+ let input_to_yojson () = `Assoc []
1313+1414+ type output = unit
1515+let output_of_yojson _ = Ok ()
1616+let output_to_yojson () = `Assoc []
1717+1818+ let call
1919+ (client : Hermes.client) : output Lwt.t =
2020+ let params = () in
2121+ let input = Some (input_to_yojson ()) in
2222+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2323+end
2424+
···11+(* generated from app.bsky.contact.startPhoneVerification *)
22+33+(** Starts a phone verification flow. The phone passed will receive a code via SMS that should be passed to `app.bsky.contact.verifyPhone`. Requires authentication. *)
44+module Main = struct
55+ let nsid = "app.bsky.contact.startPhoneVerification"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ phone: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+let output_of_yojson _ = Ok ()
1818+let output_to_yojson () = `Assoc []
1919+2020+ let call
2121+ ~phone
2222+ (client : Hermes.client) : output Lwt.t =
2323+ let params = () in
2424+ let input = Some ({phone} |> input_to_yojson) in
2525+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2626+end
2727+
···11+(* generated from app.bsky.feed.getPostThread *)
22+33+(** Get posts in a thread. Does not require auth, but additional metadata and filtering will be applied for authed requests. *)
44+module Main = struct
55+ let nsid = "app.bsky.feed.getPostThread"
66+77+ type params =
88+ {
99+ uri: string;
1010+ depth: int option [@default None];
1111+ parent_height: int option [@key "parentHeight"] [@default None];
1212+ }
1313+[@@deriving yojson {strict= false}]
1414+1515+ type thread =
1616+ | ThreadViewPost of App_bsky_feed_defs.thread_view_post
1717+ | NotFoundPost of App_bsky_feed_defs.not_found_post
1818+ | BlockedPost of App_bsky_feed_defs.blocked_post
1919+ | Unknown of Yojson.Safe.t
2020+2121+let thread_of_yojson json =
2222+ let open Yojson.Safe.Util in
2323+ try
2424+ match json |> member "$type" |> to_string with
2525+ | "app.bsky.feed.defs#threadViewPost" ->
2626+ (match App_bsky_feed_defs.thread_view_post_of_yojson json with
2727+ | Ok v -> Ok (ThreadViewPost v)
2828+ | Error e -> Error e)
2929+ | "app.bsky.feed.defs#notFoundPost" ->
3030+ (match App_bsky_feed_defs.not_found_post_of_yojson json with
3131+ | Ok v -> Ok (NotFoundPost v)
3232+ | Error e -> Error e)
3333+ | "app.bsky.feed.defs#blockedPost" ->
3434+ (match App_bsky_feed_defs.blocked_post_of_yojson json with
3535+ | Ok v -> Ok (BlockedPost v)
3636+ | Error e -> Error e)
3737+ | _ -> Ok (Unknown json)
3838+ with _ -> Error "failed to parse union"
3939+4040+let thread_to_yojson = function
4141+ | ThreadViewPost v ->
4242+ (match App_bsky_feed_defs.thread_view_post_to_yojson v with
4343+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#threadViewPost") :: fields)
4444+ | other -> other)
4545+ | NotFoundPost v ->
4646+ (match App_bsky_feed_defs.not_found_post_to_yojson v with
4747+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#notFoundPost") :: fields)
4848+ | other -> other)
4949+ | BlockedPost v ->
5050+ (match App_bsky_feed_defs.blocked_post_to_yojson v with
5151+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#blockedPost") :: fields)
5252+ | other -> other)
5353+ | Unknown j -> j
5454+5555+type output =
5656+ {
5757+ thread: thread;
5858+ threadgate: App_bsky_feed_defs.threadgate_view option [@default None];
5959+ }
6060+[@@deriving yojson {strict= false}]
6161+6262+ let call
6363+ ~uri
6464+ ?depth
6565+ ?parent_height
6666+ (client : Hermes.client) : output Lwt.t =
6767+ let params : params = {uri; depth; parent_height} in
6868+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
6969+end
7070+
+25
pegasus/lib/lexicons/app_bsky_feed_getPosts.ml
···11+(* generated from app.bsky.feed.getPosts *)
22+33+(** Gets post views for a specified list of posts (by AT-URI). This is sometimes referred to as 'hydrating' a 'feed skeleton'. *)
44+module Main = struct
55+ let nsid = "app.bsky.feed.getPosts"
66+77+ type params =
88+ {
99+ uris: string list;
1010+ }
1111+[@@deriving yojson {strict= false}]
1212+1313+ type output =
1414+ {
1515+ posts: App_bsky_feed_defs.post_view list;
1616+ }
1717+[@@deriving yojson {strict= false}]
1818+1919+ let call
2020+ ~uris
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params : params = {uris} in
2323+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
2424+end
2525+
+34
pegasus/lib/lexicons/app_bsky_feed_getQuotes.ml
···11+(* generated from app.bsky.feed.getQuotes *)
22+33+(** Get a list of quotes for a given post. *)
44+module Main = struct
55+ let nsid = "app.bsky.feed.getQuotes"
66+77+ type params =
88+ {
99+ uri: string;
1010+ cid: string option [@default None];
1111+ limit: int option [@default None];
1212+ cursor: string option [@default None];
1313+ }
1414+[@@deriving yojson {strict= false}]
1515+1616+ type output =
1717+ {
1818+ uri: string;
1919+ cid: string option [@default None];
2020+ cursor: string option [@default None];
2121+ posts: App_bsky_feed_defs.post_view list;
2222+ }
2323+[@@deriving yojson {strict= false}]
2424+2525+ let call
2626+ ~uri
2727+ ?cid
2828+ ?limit
2929+ ?cursor
3030+ (client : Hermes.client) : output Lwt.t =
3131+ let params : params = {uri; cid; limit; cursor} in
3232+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
3333+end
3434+
···11+(* generated from app.bsky.feed.sendInteractions *)
22+33+(** Send information about interactions with feed items back to the feed generator that served them. *)
44+module Main = struct
55+ let nsid = "app.bsky.feed.sendInteractions"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ interactions: App_bsky_feed_defs.interaction list;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+let output_of_yojson _ = Ok ()
1818+let output_to_yojson () = `Assoc []
1919+2020+ let call
2121+ ~interactions
2222+ (client : Hermes.client) : output Lwt.t =
2323+ let params = () in
2424+ let input = Some ({interactions} |> input_to_yojson) in
2525+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2626+end
2727+
+78
pegasus/lib/lexicons/app_bsky_feed_threadgate.ml
···11+(* generated from app.bsky.feed.threadgate *)
22+33+type list_rule =
44+ {
55+ list: string;
66+ }
77+[@@deriving yojson {strict= false}]
88+99+type following_rule = unit
1010+let following_rule_of_yojson _ = Ok ()
1111+let following_rule_to_yojson () = `Assoc []
1212+1313+type follower_rule = unit
1414+let follower_rule_of_yojson _ = Ok ()
1515+let follower_rule_to_yojson () = `Assoc []
1616+1717+type mention_rule = unit
1818+let mention_rule_of_yojson _ = Ok ()
1919+let mention_rule_to_yojson () = `Assoc []
2020+2121+type allow_item =
2222+ | MentionRule of mention_rule
2323+ | FollowerRule of follower_rule
2424+ | FollowingRule of following_rule
2525+ | ListRule of list_rule
2626+ | Unknown of Yojson.Safe.t
2727+2828+let allow_item_of_yojson json =
2929+ let open Yojson.Safe.Util in
3030+ try
3131+ match json |> member "$type" |> to_string with
3232+ | "app.bsky.feed.threadgate#mentionRule" ->
3333+ (match mention_rule_of_yojson json with
3434+ | Ok v -> Ok (MentionRule v)
3535+ | Error e -> Error e)
3636+ | "app.bsky.feed.threadgate#followerRule" ->
3737+ (match follower_rule_of_yojson json with
3838+ | Ok v -> Ok (FollowerRule v)
3939+ | Error e -> Error e)
4040+ | "app.bsky.feed.threadgate#followingRule" ->
4141+ (match following_rule_of_yojson json with
4242+ | Ok v -> Ok (FollowingRule v)
4343+ | Error e -> Error e)
4444+ | "app.bsky.feed.threadgate#listRule" ->
4545+ (match list_rule_of_yojson json with
4646+ | Ok v -> Ok (ListRule v)
4747+ | Error e -> Error e)
4848+ | _ -> Ok (Unknown json)
4949+ with _ -> Error "failed to parse union"
5050+5151+let allow_item_to_yojson = function
5252+ | MentionRule v ->
5353+ (match mention_rule_to_yojson v with
5454+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.threadgate#mentionRule") :: fields)
5555+ | other -> other)
5656+ | FollowerRule v ->
5757+ (match follower_rule_to_yojson v with
5858+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.threadgate#followerRule") :: fields)
5959+ | other -> other)
6060+ | FollowingRule v ->
6161+ (match following_rule_to_yojson v with
6262+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.threadgate#followingRule") :: fields)
6363+ | other -> other)
6464+ | ListRule v ->
6565+ (match list_rule_to_yojson v with
6666+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.threadgate#listRule") :: fields)
6767+ | other -> other)
6868+ | Unknown j -> j
6969+7070+type main =
7171+ {
7272+ post: string;
7373+ allow: allow_item list option [@default None];
7474+ created_at: string [@key "createdAt"];
7575+ hidden_replies: string list option [@key "hiddenReplies"] [@default None];
7676+ }
7777+[@@deriving yojson {strict= false}]
7878+
···11+(* generated from app.bsky.graph.muteActor *)
22+33+(** Creates a mute relationship for the specified account. Mutes are private in Bluesky. Requires auth. *)
44+module Main = struct
55+ let nsid = "app.bsky.graph.muteActor"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ actor: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~actor
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({actor} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from app.bsky.graph.muteActorList *)
22+33+(** Creates a mute relationship for the specified list of accounts. Mutes are private in Bluesky. Requires auth. *)
44+module Main = struct
55+ let nsid = "app.bsky.graph.muteActorList"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ list: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~list
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({list} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
+26
pegasus/lib/lexicons/app_bsky_graph_muteThread.ml
···11+(* generated from app.bsky.graph.muteThread *)
22+33+(** Mutes a thread preventing notifications from the thread and any of its children. Mutes are private in Bluesky. Requires auth. *)
44+module Main = struct
55+ let nsid = "app.bsky.graph.muteThread"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ root: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~root
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({root} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from app.bsky.notification.unregisterPush *)
22+33+(** The inverse of registerPush - inform a specified service that push notifications should no longer be sent to the given token for the requesting account. Requires auth. *)
44+module Main = struct
55+ let nsid = "app.bsky.notification.unregisterPush"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ service_did: string [@key "serviceDid"];
1313+ token: string;
1414+ platform: string;
1515+ app_id: string [@key "appId"];
1616+ }
1717+ [@@deriving yojson {strict= false}]
1818+1919+ type output = unit
2020+ let output_of_yojson _ = Ok ()
2121+2222+ let call
2323+ ~service_did
2424+ ~token
2525+ ~platform
2626+ ~app_id
2727+ (client : Hermes.client) : output Lwt.t =
2828+ let params = () in
2929+ let input = Some ({service_did; token; platform; app_id} |> input_to_yojson) in
3030+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
3131+end
3232+
···11+(* generated from app.bsky.notification.updateSeen *)
22+33+(** Notify server that the requesting account has seen notifications. Requires auth. *)
44+module Main = struct
55+ let nsid = "app.bsky.notification.updateSeen"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ seen_at: string [@key "seenAt"];
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~seen_at
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({seen_at} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
+74
pegasus/lib/lexicons/app_bsky_richtext_facet.ml
···11+(* generated from app.bsky.richtext.facet *)
22+33+type tag =
44+ {
55+ tag: string;
66+ }
77+[@@deriving yojson {strict= false}]
88+99+type link =
1010+ {
1111+ uri: string;
1212+ }
1313+[@@deriving yojson {strict= false}]
1414+1515+type mention =
1616+ {
1717+ did: string;
1818+ }
1919+[@@deriving yojson {strict= false}]
2020+2121+type byte_slice =
2222+ {
2323+ byte_start: int [@key "byteStart"];
2424+ byte_end: int [@key "byteEnd"];
2525+ }
2626+[@@deriving yojson {strict= false}]
2727+2828+type features_item =
2929+ | Mention of mention
3030+ | Link of link
3131+ | Tag of tag
3232+ | Unknown of Yojson.Safe.t
3333+3434+let features_item_of_yojson json =
3535+ let open Yojson.Safe.Util in
3636+ try
3737+ match json |> member "$type" |> to_string with
3838+ | "app.bsky.richtext.facet#mention" ->
3939+ (match mention_of_yojson json with
4040+ | Ok v -> Ok (Mention v)
4141+ | Error e -> Error e)
4242+ | "app.bsky.richtext.facet#link" ->
4343+ (match link_of_yojson json with
4444+ | Ok v -> Ok (Link v)
4545+ | Error e -> Error e)
4646+ | "app.bsky.richtext.facet#tag" ->
4747+ (match tag_of_yojson json with
4848+ | Ok v -> Ok (Tag v)
4949+ | Error e -> Error e)
5050+ | _ -> Ok (Unknown json)
5151+ with _ -> Error "failed to parse union"
5252+5353+let features_item_to_yojson = function
5454+ | Mention v ->
5555+ (match mention_to_yojson v with
5656+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.richtext.facet#mention") :: fields)
5757+ | other -> other)
5858+ | Link v ->
5959+ (match link_to_yojson v with
6060+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.richtext.facet#link") :: fields)
6161+ | other -> other)
6262+ | Tag v ->
6363+ (match tag_to_yojson v with
6464+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.richtext.facet#tag") :: fields)
6565+ | other -> other)
6666+ | Unknown j -> j
6767+6868+type main =
6969+ {
7070+ index: byte_slice;
7171+ features: features_item list;
7272+ }
7373+[@@deriving yojson {strict= false}]
7474+
+1474
pegasus/lib/lexicons/app_bsky_shared_1.ml
···11+(* shared module for lexicons: app.bsky.actor.defs, app.bsky.embed.record, app.bsky.embed.recordWithMedia, app.bsky.feed.defs, app.bsky.graph.defs, app.bsky.labeler.defs *)
22+33+type actor_embed =
44+ | ExternalView of App_bsky_embed_external.view
55+ | Unknown of Yojson.Safe.t
66+77+let actor_embed_of_yojson json =
88+ let open Yojson.Safe.Util in
99+ try
1010+ match json |> member "$type" |> to_string with
1111+ | "app.bsky.embed.external#view" ->
1212+ (match App_bsky_embed_external.view_of_yojson json with
1313+ | Ok v -> Ok (ExternalView v)
1414+ | Error e -> Error e)
1515+ | _ -> Ok (Unknown json)
1616+ with _ -> Error "failed to parse union"
1717+1818+let actor_embed_to_yojson = function
1919+ | ExternalView v ->
2020+ (match App_bsky_embed_external.view_to_yojson v with
2121+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.external#view") :: fields)
2222+ | other -> other)
2323+ | Unknown j -> j
2424+2525+type status_view =
2626+ {
2727+ status: string;
2828+ record: Yojson.Safe.t;
2929+ embed: actor_embed option [@default None];
3030+ expires_at: string option [@key "expiresAt"] [@default None];
3131+ is_active: bool option [@key "isActive"] [@default None];
3232+ }
3333+[@@deriving yojson {strict= false}]
3434+3535+type verification_view =
3636+ {
3737+ issuer: string;
3838+ uri: string;
3939+ is_valid: bool [@key "isValid"];
4040+ created_at: string [@key "createdAt"];
4141+ }
4242+[@@deriving yojson {strict= false}]
4343+4444+type verification_state =
4545+ {
4646+ verifications: verification_view list;
4747+ verified_status: string [@key "verifiedStatus"];
4848+ trusted_verifier_status: string [@key "trustedVerifierStatus"];
4949+ }
5050+[@@deriving yojson {strict= false}]
5151+5252+type list_viewer_state =
5353+ {
5454+ muted: bool option [@default None];
5555+ blocked: string option [@default None];
5656+ }
5757+[@@deriving yojson {strict= false}]
5858+5959+(** String type with known values *)
6060+type list_purpose = string
6161+let list_purpose_of_yojson = function
6262+ | `String s -> Ok s
6363+ | _ -> Error "list_purpose: expected string"
6464+let list_purpose_to_yojson s = `String s
6565+6666+type list_view_basic =
6767+ {
6868+ uri: string;
6969+ cid: string;
7070+ name: string;
7171+ purpose: list_purpose;
7272+ avatar: string option [@default None];
7373+ list_item_count: int option [@key "listItemCount"] [@default None];
7474+ labels: Com_atproto_label_defs.label list option [@default None];
7575+ viewer: list_viewer_state option [@default None];
7676+ indexed_at: string option [@key "indexedAt"] [@default None];
7777+ }
7878+[@@deriving yojson {strict= false}]
7979+8080+type profile_associated_activity_subscription =
8181+ {
8282+ allow_subscriptions: string [@key "allowSubscriptions"];
8383+ }
8484+[@@deriving yojson {strict= false}]
8585+8686+type profile_associated_chat =
8787+ {
8888+ allow_incoming: string [@key "allowIncoming"];
8989+ }
9090+[@@deriving yojson {strict= false}]
9191+9292+type profile_associated =
9393+ {
9494+ lists: int option [@default None];
9595+ feedgens: int option [@default None];
9696+ starter_packs: int option [@key "starterPacks"] [@default None];
9797+ labeler: bool option [@default None];
9898+ chat: profile_associated_chat option [@default None];
9999+ activity_subscription: profile_associated_activity_subscription option [@key "activitySubscription"] [@default None];
100100+ }
101101+[@@deriving yojson {strict= false}]
102102+103103+type profile_view_basic = {
104104+ did: string;
105105+ handle: string;
106106+ display_name: string option [@key "displayName"] [@default None];
107107+ pronouns: string option [@default None];
108108+ avatar: string option [@default None];
109109+ associated: profile_associated option [@default None];
110110+ viewer: actor_viewer_state option [@default None];
111111+ labels: Com_atproto_label_defs.label list option [@default None];
112112+ created_at: string option [@key "createdAt"] [@default None];
113113+ verification: verification_state option [@default None];
114114+ status: status_view option [@default None];
115115+ debug: Yojson.Safe.t option [@default None];
116116+}
117117+and actor_viewer_state = {
118118+ muted: bool option [@default None];
119119+ muted_by_list: list_view_basic option [@key "mutedByList"] [@default None];
120120+ blocked_by: bool option [@key "blockedBy"] [@default None];
121121+ blocking: string option [@default None];
122122+ blocking_by_list: list_view_basic option [@key "blockingByList"] [@default None];
123123+ following: string option [@default None];
124124+ followed_by: string option [@key "followedBy"] [@default None];
125125+ known_followers: known_followers option [@key "knownFollowers"] [@default None];
126126+ activity_subscription: App_bsky_notification_defs.activity_subscription option [@key "activitySubscription"] [@default None];
127127+}
128128+and known_followers = {
129129+ count: int;
130130+ followers: profile_view_basic list;
131131+}
132132+133133+let rec profile_view_basic_of_yojson json =
134134+ let open Yojson.Safe.Util in
135135+ try
136136+ let did = json |> member "did" |> to_string in
137137+ let handle = json |> member "handle" |> to_string in
138138+ let display_name = json |> member "displayName" |> to_option to_string in
139139+ let pronouns = json |> member "pronouns" |> to_option to_string in
140140+ let avatar = json |> member "avatar" |> to_option to_string in
141141+ let associated = json |> member "associated" |> to_option (fun x -> match profile_associated_of_yojson x with Ok v -> Some v | _ -> None) |> Option.join in
142142+ let viewer = json |> member "viewer" |> to_option (fun x -> match actor_viewer_state_of_yojson x with Ok v -> Some v | _ -> None) |> Option.join in
143143+ let labels = json |> member "labels" |> to_option (fun j -> to_list j |> List.filter_map (fun x -> match Com_atproto_label_defs.label_of_yojson x with Ok v -> Some v | _ -> None)) in
144144+ let created_at = json |> member "createdAt" |> to_option to_string in
145145+ let verification = json |> member "verification" |> to_option (fun x -> match verification_state_of_yojson x with Ok v -> Some v | _ -> None) |> Option.join in
146146+ let status = json |> member "status" |> to_option (fun x -> match status_view_of_yojson x with Ok v -> Some v | _ -> None) |> Option.join in
147147+ let debug = json |> member "debug" |> to_option (fun j -> j) in
148148+ Ok { did; handle; display_name; pronouns; avatar; associated; viewer; labels; created_at; verification; status; debug }
149149+ with e -> Error (Printexc.to_string e)
150150+151151+and actor_viewer_state_of_yojson json =
152152+ let open Yojson.Safe.Util in
153153+ try
154154+ let muted = json |> member "muted" |> to_option to_bool in
155155+ let muted_by_list = json |> member "mutedByList" |> to_option (fun x -> match list_view_basic_of_yojson x with Ok v -> Some v | _ -> None) |> Option.join in
156156+ let blocked_by = json |> member "blockedBy" |> to_option to_bool in
157157+ let blocking = json |> member "blocking" |> to_option to_string in
158158+ let blocking_by_list = json |> member "blockingByList" |> to_option (fun x -> match list_view_basic_of_yojson x with Ok v -> Some v | _ -> None) |> Option.join in
159159+ let following = json |> member "following" |> to_option to_string in
160160+ let followed_by = json |> member "followedBy" |> to_option to_string in
161161+ let known_followers = json |> member "knownFollowers" |> to_option (fun x -> match known_followers_of_yojson x with Ok v -> Some v | _ -> None) |> Option.join in
162162+ let activity_subscription = json |> member "activitySubscription" |> to_option (fun x -> match App_bsky_notification_defs.activity_subscription_of_yojson x with Ok v -> Some v | _ -> None) |> Option.join in
163163+ Ok { muted; muted_by_list; blocked_by; blocking; blocking_by_list; following; followed_by; known_followers; activity_subscription }
164164+ with e -> Error (Printexc.to_string e)
165165+166166+and known_followers_of_yojson json =
167167+ let open Yojson.Safe.Util in
168168+ try
169169+ let count = json |> member "count" |> to_int in
170170+ let followers = json |> member "followers" |> (fun j -> to_list j |> List.filter_map (fun x -> match profile_view_basic_of_yojson x with Ok v -> Some v | _ -> None)) in
171171+ Ok { count; followers }
172172+ with e -> Error (Printexc.to_string e)
173173+174174+and profile_view_basic_to_yojson (r : profile_view_basic) =
175175+ `Assoc [
176176+ ("did", (fun s -> `String s) r.did);
177177+ ("handle", (fun s -> `String s) r.handle);
178178+ ("displayName", match r.display_name with Some v -> (fun s -> `String s) v | None -> `Null);
179179+ ("pronouns", match r.pronouns with Some v -> (fun s -> `String s) v | None -> `Null);
180180+ ("avatar", match r.avatar with Some v -> (fun s -> `String s) v | None -> `Null);
181181+ ("associated", match r.associated with Some v -> profile_associated_to_yojson v | None -> `Null);
182182+ ("viewer", match r.viewer with Some v -> actor_viewer_state_to_yojson v | None -> `Null);
183183+ ("labels", match r.labels with Some v -> (fun l -> `List (List.map Com_atproto_label_defs.label_to_yojson l)) v | None -> `Null);
184184+ ("createdAt", match r.created_at with Some v -> (fun s -> `String s) v | None -> `Null);
185185+ ("verification", match r.verification with Some v -> verification_state_to_yojson v | None -> `Null);
186186+ ("status", match r.status with Some v -> status_view_to_yojson v | None -> `Null);
187187+ ("debug", match r.debug with Some v -> (fun j -> j) v | None -> `Null)
188188+ ]
189189+190190+and actor_viewer_state_to_yojson (r : actor_viewer_state) =
191191+ `Assoc [
192192+ ("muted", match r.muted with Some v -> (fun b -> `Bool b) v | None -> `Null);
193193+ ("mutedByList", match r.muted_by_list with Some v -> list_view_basic_to_yojson v | None -> `Null);
194194+ ("blockedBy", match r.blocked_by with Some v -> (fun b -> `Bool b) v | None -> `Null);
195195+ ("blocking", match r.blocking with Some v -> (fun s -> `String s) v | None -> `Null);
196196+ ("blockingByList", match r.blocking_by_list with Some v -> list_view_basic_to_yojson v | None -> `Null);
197197+ ("following", match r.following with Some v -> (fun s -> `String s) v | None -> `Null);
198198+ ("followedBy", match r.followed_by with Some v -> (fun s -> `String s) v | None -> `Null);
199199+ ("knownFollowers", match r.known_followers with Some v -> known_followers_to_yojson v | None -> `Null);
200200+ ("activitySubscription", match r.activity_subscription with Some v -> App_bsky_notification_defs.activity_subscription_to_yojson v | None -> `Null)
201201+ ]
202202+203203+and known_followers_to_yojson (r : known_followers) =
204204+ `Assoc [
205205+ ("count", (fun i -> `Int i) r.count);
206206+ ("followers", (fun l -> `List (List.map profile_view_basic_to_yojson l)) r.followers)
207207+ ]
208208+209209+type profile_view =
210210+ {
211211+ did: string;
212212+ handle: string;
213213+ display_name: string option [@key "displayName"] [@default None];
214214+ pronouns: string option [@default None];
215215+ description: string option [@default None];
216216+ avatar: string option [@default None];
217217+ associated: profile_associated option [@default None];
218218+ indexed_at: string option [@key "indexedAt"] [@default None];
219219+ created_at: string option [@key "createdAt"] [@default None];
220220+ viewer: actor_viewer_state option [@default None];
221221+ labels: Com_atproto_label_defs.label list option [@default None];
222222+ verification: verification_state option [@default None];
223223+ status: status_view option [@default None];
224224+ debug: Yojson.Safe.t option [@default None];
225225+ }
226226+[@@deriving yojson {strict= false}]
227227+228228+type starter_pack_view_basic =
229229+ {
230230+ uri: string;
231231+ cid: string;
232232+ record: Yojson.Safe.t;
233233+ creator: profile_view_basic;
234234+ list_item_count: int option [@key "listItemCount"] [@default None];
235235+ joined_week_count: int option [@key "joinedWeekCount"] [@default None];
236236+ joined_all_time_count: int option [@key "joinedAllTimeCount"] [@default None];
237237+ labels: Com_atproto_label_defs.label list option [@default None];
238238+ indexed_at: string [@key "indexedAt"];
239239+ }
240240+[@@deriving yojson {strict= false}]
241241+242242+type profile_view_detailed =
243243+ {
244244+ did: string;
245245+ handle: string;
246246+ display_name: string option [@key "displayName"] [@default None];
247247+ description: string option [@default None];
248248+ pronouns: string option [@default None];
249249+ website: string option [@default None];
250250+ avatar: string option [@default None];
251251+ banner: string option [@default None];
252252+ followers_count: int option [@key "followersCount"] [@default None];
253253+ follows_count: int option [@key "followsCount"] [@default None];
254254+ posts_count: int option [@key "postsCount"] [@default None];
255255+ associated: profile_associated option [@default None];
256256+ joined_via_starter_pack: starter_pack_view_basic option [@key "joinedViaStarterPack"] [@default None];
257257+ indexed_at: string option [@key "indexedAt"] [@default None];
258258+ created_at: string option [@key "createdAt"] [@default None];
259259+ viewer: actor_viewer_state option [@default None];
260260+ labels: Com_atproto_label_defs.label list option [@default None];
261261+ pinned_post: Com_atproto_repo_strongRef.main option [@key "pinnedPost"] [@default None];
262262+ verification: verification_state option [@default None];
263263+ status: status_view option [@default None];
264264+ debug: Yojson.Safe.t option [@default None];
265265+ }
266266+[@@deriving yojson {strict= false}]
267267+268268+type verification_prefs =
269269+ {
270270+ hide_badges: bool option [@key "hideBadges"] [@default None];
271271+ }
272272+[@@deriving yojson {strict= false}]
273273+274274+type postgate_embedding_rules_item =
275275+ | PostgateDisableRule of App_bsky_feed_postgate.disable_rule
276276+ | Unknown of Yojson.Safe.t
277277+278278+let postgate_embedding_rules_item_of_yojson json =
279279+ let open Yojson.Safe.Util in
280280+ try
281281+ match json |> member "$type" |> to_string with
282282+ | "app.bsky.feed.postgate#disableRule" ->
283283+ (match App_bsky_feed_postgate.disable_rule_of_yojson json with
284284+ | Ok v -> Ok (PostgateDisableRule v)
285285+ | Error e -> Error e)
286286+ | _ -> Ok (Unknown json)
287287+ with _ -> Error "failed to parse union"
288288+289289+let postgate_embedding_rules_item_to_yojson = function
290290+ | PostgateDisableRule v ->
291291+ (match App_bsky_feed_postgate.disable_rule_to_yojson v with
292292+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.postgate#disableRule") :: fields)
293293+ | other -> other)
294294+ | Unknown j -> j
295295+296296+type threadgate_allow_rules_item =
297297+ | ThreadgateMentionRule of App_bsky_feed_threadgate.mention_rule
298298+ | ThreadgateFollowerRule of App_bsky_feed_threadgate.follower_rule
299299+ | ThreadgateFollowingRule of App_bsky_feed_threadgate.following_rule
300300+ | ThreadgateListRule of App_bsky_feed_threadgate.list_rule
301301+ | Unknown of Yojson.Safe.t
302302+303303+let threadgate_allow_rules_item_of_yojson json =
304304+ let open Yojson.Safe.Util in
305305+ try
306306+ match json |> member "$type" |> to_string with
307307+ | "app.bsky.feed.threadgate#mentionRule" ->
308308+ (match App_bsky_feed_threadgate.mention_rule_of_yojson json with
309309+ | Ok v -> Ok (ThreadgateMentionRule v)
310310+ | Error e -> Error e)
311311+ | "app.bsky.feed.threadgate#followerRule" ->
312312+ (match App_bsky_feed_threadgate.follower_rule_of_yojson json with
313313+ | Ok v -> Ok (ThreadgateFollowerRule v)
314314+ | Error e -> Error e)
315315+ | "app.bsky.feed.threadgate#followingRule" ->
316316+ (match App_bsky_feed_threadgate.following_rule_of_yojson json with
317317+ | Ok v -> Ok (ThreadgateFollowingRule v)
318318+ | Error e -> Error e)
319319+ | "app.bsky.feed.threadgate#listRule" ->
320320+ (match App_bsky_feed_threadgate.list_rule_of_yojson json with
321321+ | Ok v -> Ok (ThreadgateListRule v)
322322+ | Error e -> Error e)
323323+ | _ -> Ok (Unknown json)
324324+ with _ -> Error "failed to parse union"
325325+326326+let threadgate_allow_rules_item_to_yojson = function
327327+ | ThreadgateMentionRule v ->
328328+ (match App_bsky_feed_threadgate.mention_rule_to_yojson v with
329329+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.threadgate#mentionRule") :: fields)
330330+ | other -> other)
331331+ | ThreadgateFollowerRule v ->
332332+ (match App_bsky_feed_threadgate.follower_rule_to_yojson v with
333333+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.threadgate#followerRule") :: fields)
334334+ | other -> other)
335335+ | ThreadgateFollowingRule v ->
336336+ (match App_bsky_feed_threadgate.following_rule_to_yojson v with
337337+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.threadgate#followingRule") :: fields)
338338+ | other -> other)
339339+ | ThreadgateListRule v ->
340340+ (match App_bsky_feed_threadgate.list_rule_to_yojson v with
341341+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.threadgate#listRule") :: fields)
342342+ | other -> other)
343343+ | Unknown j -> j
344344+345345+type post_interaction_settings_pref =
346346+ {
347347+ threadgate_allow_rules: threadgate_allow_rules_item list option [@key "threadgateAllowRules"] [@default None];
348348+ postgate_embedding_rules: postgate_embedding_rules_item list option [@key "postgateEmbeddingRules"] [@default None];
349349+ }
350350+[@@deriving yojson {strict= false}]
351351+352352+type labeler_pref_item =
353353+ {
354354+ did: string;
355355+ }
356356+[@@deriving yojson {strict= false}]
357357+358358+type labelers_pref =
359359+ {
360360+ labelers: labeler_pref_item list;
361361+ }
362362+[@@deriving yojson {strict= false}]
363363+364364+type nux =
365365+ {
366366+ id: string;
367367+ completed: bool;
368368+ data: string option [@default None];
369369+ expires_at: string option [@key "expiresAt"] [@default None];
370370+ }
371371+[@@deriving yojson {strict= false}]
372372+373373+type bsky_app_progress_guide =
374374+ {
375375+ guide: string;
376376+ }
377377+[@@deriving yojson {strict= false}]
378378+379379+type bsky_app_state_pref =
380380+ {
381381+ active_progress_guide: bsky_app_progress_guide option [@key "activeProgressGuide"] [@default None];
382382+ queued_nudges: string list option [@key "queuedNudges"] [@default None];
383383+ nuxs: nux list option [@default None];
384384+ }
385385+[@@deriving yojson {strict= false}]
386386+387387+type hidden_posts_pref =
388388+ {
389389+ items: string list;
390390+ }
391391+[@@deriving yojson {strict= false}]
392392+393393+(** String type with known values *)
394394+type muted_word_target = string
395395+let muted_word_target_of_yojson = function
396396+ | `String s -> Ok s
397397+ | _ -> Error "muted_word_target: expected string"
398398+let muted_word_target_to_yojson s = `String s
399399+400400+type muted_word =
401401+ {
402402+ id: string option [@default None];
403403+ value: string;
404404+ targets: muted_word_target list;
405405+ actor_target: string option [@key "actorTarget"] [@default None];
406406+ expires_at: string option [@key "expiresAt"] [@default None];
407407+ }
408408+[@@deriving yojson {strict= false}]
409409+410410+type muted_words_pref =
411411+ {
412412+ items: muted_word list;
413413+ }
414414+[@@deriving yojson {strict= false}]
415415+416416+type interests_pref =
417417+ {
418418+ tags: string list;
419419+ }
420420+[@@deriving yojson {strict= false}]
421421+422422+type thread_view_pref =
423423+ {
424424+ sort: string option [@default None];
425425+ }
426426+[@@deriving yojson {strict= false}]
427427+428428+type feed_view_pref =
429429+ {
430430+ feed: string;
431431+ hide_replies: bool option [@key "hideReplies"] [@default None];
432432+ hide_replies_by_unfollowed: bool option [@key "hideRepliesByUnfollowed"] [@default None];
433433+ hide_replies_by_like_count: int option [@key "hideRepliesByLikeCount"] [@default None];
434434+ hide_reposts: bool option [@key "hideReposts"] [@default None];
435435+ hide_quote_posts: bool option [@key "hideQuotePosts"] [@default None];
436436+ }
437437+[@@deriving yojson {strict= false}]
438438+439439+type declared_age_pref =
440440+ {
441441+ is_over_age13: bool option [@key "isOverAge13"] [@default None];
442442+ is_over_age16: bool option [@key "isOverAge16"] [@default None];
443443+ is_over_age18: bool option [@key "isOverAge18"] [@default None];
444444+ }
445445+[@@deriving yojson {strict= false}]
446446+447447+type personal_details_pref =
448448+ {
449449+ birth_date: string option [@key "birthDate"] [@default None];
450450+ }
451451+[@@deriving yojson {strict= false}]
452452+453453+type saved_feed =
454454+ {
455455+ id: string;
456456+ type_: string [@key "type"];
457457+ value: string;
458458+ pinned: bool;
459459+ }
460460+[@@deriving yojson {strict= false}]
461461+462462+type saved_feeds_pref_v2 =
463463+ {
464464+ items: saved_feed list;
465465+ }
466466+[@@deriving yojson {strict= false}]
467467+468468+type saved_feeds_pref =
469469+ {
470470+ pinned: string list;
471471+ saved: string list;
472472+ timeline_index: int option [@key "timelineIndex"] [@default None];
473473+ }
474474+[@@deriving yojson {strict= false}]
475475+476476+type content_label_pref =
477477+ {
478478+ labeler_did: string option [@key "labelerDid"] [@default None];
479479+ label: string;
480480+ visibility: string;
481481+ }
482482+[@@deriving yojson {strict= false}]
483483+484484+type adult_content_pref =
485485+ {
486486+ enabled: bool;
487487+ }
488488+[@@deriving yojson {strict= false}]
489489+490490+type preferences_item =
491491+ | AdultContentPref of adult_content_pref
492492+ | ContentLabelPref of content_label_pref
493493+ | SavedFeedsPref of saved_feeds_pref
494494+ | SavedFeedsPrefV2 of saved_feeds_pref_v2
495495+ | PersonalDetailsPref of personal_details_pref
496496+ | DeclaredAgePref of declared_age_pref
497497+ | FeedViewPref of feed_view_pref
498498+ | ThreadViewPref of thread_view_pref
499499+ | InterestsPref of interests_pref
500500+ | MutedWordsPref of muted_words_pref
501501+ | HiddenPostsPref of hidden_posts_pref
502502+ | BskyAppStatePref of bsky_app_state_pref
503503+ | LabelersPref of labelers_pref
504504+ | PostInteractionSettingsPref of post_interaction_settings_pref
505505+ | VerificationPrefs of verification_prefs
506506+ | Unknown of Yojson.Safe.t
507507+508508+let preferences_item_of_yojson json =
509509+ let open Yojson.Safe.Util in
510510+ try
511511+ match json |> member "$type" |> to_string with
512512+ | "app.bsky.actor.defs#adultContentPref" ->
513513+ (match adult_content_pref_of_yojson json with
514514+ | Ok v -> Ok (AdultContentPref v)
515515+ | Error e -> Error e)
516516+ | "app.bsky.actor.defs#contentLabelPref" ->
517517+ (match content_label_pref_of_yojson json with
518518+ | Ok v -> Ok (ContentLabelPref v)
519519+ | Error e -> Error e)
520520+ | "app.bsky.actor.defs#savedFeedsPref" ->
521521+ (match saved_feeds_pref_of_yojson json with
522522+ | Ok v -> Ok (SavedFeedsPref v)
523523+ | Error e -> Error e)
524524+ | "app.bsky.actor.defs#savedFeedsPrefV2" ->
525525+ (match saved_feeds_pref_v2_of_yojson json with
526526+ | Ok v -> Ok (SavedFeedsPrefV2 v)
527527+ | Error e -> Error e)
528528+ | "app.bsky.actor.defs#personalDetailsPref" ->
529529+ (match personal_details_pref_of_yojson json with
530530+ | Ok v -> Ok (PersonalDetailsPref v)
531531+ | Error e -> Error e)
532532+ | "app.bsky.actor.defs#declaredAgePref" ->
533533+ (match declared_age_pref_of_yojson json with
534534+ | Ok v -> Ok (DeclaredAgePref v)
535535+ | Error e -> Error e)
536536+ | "app.bsky.actor.defs#feedViewPref" ->
537537+ (match feed_view_pref_of_yojson json with
538538+ | Ok v -> Ok (FeedViewPref v)
539539+ | Error e -> Error e)
540540+ | "app.bsky.actor.defs#threadViewPref" ->
541541+ (match thread_view_pref_of_yojson json with
542542+ | Ok v -> Ok (ThreadViewPref v)
543543+ | Error e -> Error e)
544544+ | "app.bsky.actor.defs#interestsPref" ->
545545+ (match interests_pref_of_yojson json with
546546+ | Ok v -> Ok (InterestsPref v)
547547+ | Error e -> Error e)
548548+ | "app.bsky.actor.defs#mutedWordsPref" ->
549549+ (match muted_words_pref_of_yojson json with
550550+ | Ok v -> Ok (MutedWordsPref v)
551551+ | Error e -> Error e)
552552+ | "app.bsky.actor.defs#hiddenPostsPref" ->
553553+ (match hidden_posts_pref_of_yojson json with
554554+ | Ok v -> Ok (HiddenPostsPref v)
555555+ | Error e -> Error e)
556556+ | "app.bsky.actor.defs#bskyAppStatePref" ->
557557+ (match bsky_app_state_pref_of_yojson json with
558558+ | Ok v -> Ok (BskyAppStatePref v)
559559+ | Error e -> Error e)
560560+ | "app.bsky.actor.defs#labelersPref" ->
561561+ (match labelers_pref_of_yojson json with
562562+ | Ok v -> Ok (LabelersPref v)
563563+ | Error e -> Error e)
564564+ | "app.bsky.actor.defs#postInteractionSettingsPref" ->
565565+ (match post_interaction_settings_pref_of_yojson json with
566566+ | Ok v -> Ok (PostInteractionSettingsPref v)
567567+ | Error e -> Error e)
568568+ | "app.bsky.actor.defs#verificationPrefs" ->
569569+ (match verification_prefs_of_yojson json with
570570+ | Ok v -> Ok (VerificationPrefs v)
571571+ | Error e -> Error e)
572572+ | _ -> Ok (Unknown json)
573573+ with _ -> Error "failed to parse union"
574574+575575+let preferences_item_to_yojson = function
576576+ | AdultContentPref v ->
577577+ (match adult_content_pref_to_yojson v with
578578+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#adultContentPref") :: fields)
579579+ | other -> other)
580580+ | ContentLabelPref v ->
581581+ (match content_label_pref_to_yojson v with
582582+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#contentLabelPref") :: fields)
583583+ | other -> other)
584584+ | SavedFeedsPref v ->
585585+ (match saved_feeds_pref_to_yojson v with
586586+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#savedFeedsPref") :: fields)
587587+ | other -> other)
588588+ | SavedFeedsPrefV2 v ->
589589+ (match saved_feeds_pref_v2_to_yojson v with
590590+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#savedFeedsPrefV2") :: fields)
591591+ | other -> other)
592592+ | PersonalDetailsPref v ->
593593+ (match personal_details_pref_to_yojson v with
594594+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#personalDetailsPref") :: fields)
595595+ | other -> other)
596596+ | DeclaredAgePref v ->
597597+ (match declared_age_pref_to_yojson v with
598598+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#declaredAgePref") :: fields)
599599+ | other -> other)
600600+ | FeedViewPref v ->
601601+ (match feed_view_pref_to_yojson v with
602602+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#feedViewPref") :: fields)
603603+ | other -> other)
604604+ | ThreadViewPref v ->
605605+ (match thread_view_pref_to_yojson v with
606606+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#threadViewPref") :: fields)
607607+ | other -> other)
608608+ | InterestsPref v ->
609609+ (match interests_pref_to_yojson v with
610610+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#interestsPref") :: fields)
611611+ | other -> other)
612612+ | MutedWordsPref v ->
613613+ (match muted_words_pref_to_yojson v with
614614+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#mutedWordsPref") :: fields)
615615+ | other -> other)
616616+ | HiddenPostsPref v ->
617617+ (match hidden_posts_pref_to_yojson v with
618618+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#hiddenPostsPref") :: fields)
619619+ | other -> other)
620620+ | BskyAppStatePref v ->
621621+ (match bsky_app_state_pref_to_yojson v with
622622+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#bskyAppStatePref") :: fields)
623623+ | other -> other)
624624+ | LabelersPref v ->
625625+ (match labelers_pref_to_yojson v with
626626+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#labelersPref") :: fields)
627627+ | other -> other)
628628+ | PostInteractionSettingsPref v ->
629629+ (match post_interaction_settings_pref_to_yojson v with
630630+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#postInteractionSettingsPref") :: fields)
631631+ | other -> other)
632632+ | VerificationPrefs v ->
633633+ (match verification_prefs_to_yojson v with
634634+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.actor.defs#verificationPrefs") :: fields)
635635+ | other -> other)
636636+ | Unknown j -> j
637637+638638+type preferences = preferences_item list
639639+let preferences_of_yojson json =
640640+ let open Yojson.Safe.Util in
641641+ Ok (to_list json |> List.filter_map (fun x -> match preferences_item_of_yojson x with Ok v -> Some v | _ -> None))
642642+let preferences_to_yojson l = `List (List.map preferences_item_to_yojson l)
643643+644644+type record_main =
645645+ {
646646+ record: Com_atproto_repo_strongRef.main;
647647+ }
648648+[@@deriving yojson {strict= false}]
649649+650650+type labeler_viewer_state =
651651+ {
652652+ like: string option [@default None];
653653+ }
654654+[@@deriving yojson {strict= false}]
655655+656656+type labeler_view =
657657+ {
658658+ uri: string;
659659+ cid: string;
660660+ creator: profile_view;
661661+ like_count: int option [@key "likeCount"] [@default None];
662662+ viewer: labeler_viewer_state option [@default None];
663663+ indexed_at: string [@key "indexedAt"];
664664+ labels: Com_atproto_label_defs.label list option [@default None];
665665+ }
666666+[@@deriving yojson {strict= false}]
667667+668668+type list_view =
669669+ {
670670+ uri: string;
671671+ cid: string;
672672+ creator: profile_view;
673673+ name: string;
674674+ purpose: list_purpose;
675675+ description: string option [@default None];
676676+ description_facets: App_bsky_richtext_facet.main list option [@key "descriptionFacets"] [@default None];
677677+ avatar: string option [@default None];
678678+ list_item_count: int option [@key "listItemCount"] [@default None];
679679+ labels: Com_atproto_label_defs.label list option [@default None];
680680+ viewer: list_viewer_state option [@default None];
681681+ indexed_at: string [@key "indexedAt"];
682682+ }
683683+[@@deriving yojson {strict= false}]
684684+685685+type generator_viewer_state =
686686+ {
687687+ like: string option [@default None];
688688+ }
689689+[@@deriving yojson {strict= false}]
690690+691691+type generator_view =
692692+ {
693693+ uri: string;
694694+ cid: string;
695695+ did: string;
696696+ creator: profile_view;
697697+ display_name: string [@key "displayName"];
698698+ description: string option [@default None];
699699+ description_facets: App_bsky_richtext_facet.main list option [@key "descriptionFacets"] [@default None];
700700+ avatar: string option [@default None];
701701+ like_count: int option [@key "likeCount"] [@default None];
702702+ accepts_interactions: bool option [@key "acceptsInteractions"] [@default None];
703703+ labels: Com_atproto_label_defs.label list option [@default None];
704704+ viewer: generator_viewer_state option [@default None];
705705+ content_mode: string option [@key "contentMode"] [@default None];
706706+ indexed_at: string [@key "indexedAt"];
707707+ }
708708+[@@deriving yojson {strict= false}]
709709+710710+type view_detached =
711711+ {
712712+ uri: string;
713713+ detached: bool;
714714+ }
715715+[@@deriving yojson {strict= false}]
716716+717717+type blocked_author =
718718+ {
719719+ did: string;
720720+ viewer: actor_viewer_state option [@default None];
721721+ }
722722+[@@deriving yojson {strict= false}]
723723+724724+type view_blocked =
725725+ {
726726+ uri: string;
727727+ blocked: bool;
728728+ author: blocked_author;
729729+ }
730730+[@@deriving yojson {strict= false}]
731731+732732+type view_not_found =
733733+ {
734734+ uri: string;
735735+ not_found: bool [@key "notFound"];
736736+ }
737737+[@@deriving yojson {strict= false}]
738738+739739+type record_with_media_media =
740740+ | Images of App_bsky_embed_images.main
741741+ | Video of App_bsky_embed_video.main
742742+ | External of App_bsky_embed_external.main
743743+ | Unknown of Yojson.Safe.t
744744+745745+let record_with_media_media_of_yojson json =
746746+ let open Yojson.Safe.Util in
747747+ try
748748+ match json |> member "$type" |> to_string with
749749+ | "app.bsky.embed.images" ->
750750+ (match App_bsky_embed_images.main_of_yojson json with
751751+ | Ok v -> Ok (Images v)
752752+ | Error e -> Error e)
753753+ | "app.bsky.embed.video" ->
754754+ (match App_bsky_embed_video.main_of_yojson json with
755755+ | Ok v -> Ok (Video v)
756756+ | Error e -> Error e)
757757+ | "app.bsky.embed.external" ->
758758+ (match App_bsky_embed_external.main_of_yojson json with
759759+ | Ok v -> Ok (External v)
760760+ | Error e -> Error e)
761761+ | _ -> Ok (Unknown json)
762762+ with _ -> Error "failed to parse union"
763763+764764+let record_with_media_media_to_yojson = function
765765+ | Images v ->
766766+ (match App_bsky_embed_images.main_to_yojson v with
767767+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.images") :: fields)
768768+ | other -> other)
769769+ | Video v ->
770770+ (match App_bsky_embed_video.main_to_yojson v with
771771+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.video") :: fields)
772772+ | other -> other)
773773+ | External v ->
774774+ (match App_bsky_embed_external.main_to_yojson v with
775775+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.external") :: fields)
776776+ | other -> other)
777777+ | Unknown j -> j
778778+779779+type embeds_item =
780780+ | ImagesView of App_bsky_embed_images.view
781781+ | VideoView of App_bsky_embed_video.view
782782+ | ExternalView of App_bsky_embed_external.view
783783+ | RecordView of record_view
784784+ | RecordWithMediaView of record_with_media_view
785785+ | Unknown of Yojson.Safe.t
786786+and record =
787787+ | ViewRecord of view_record
788788+ | ViewNotFound of view_not_found
789789+ | ViewBlocked of view_blocked
790790+ | ViewDetached of view_detached
791791+ | DefsGeneratorView of generator_view
792792+ | DefsListView of list_view
793793+ | DefsLabelerView of labeler_view
794794+ | DefsStarterPackViewBasic of starter_pack_view_basic
795795+ | Unknown of Yojson.Safe.t
796796+and record_view = {
797797+ record: record;
798798+}
799799+and view_record = {
800800+ uri: string;
801801+ cid: string;
802802+ author: profile_view_basic;
803803+ value: Yojson.Safe.t;
804804+ labels: Com_atproto_label_defs.label list option [@default None];
805805+ reply_count: int option [@key "replyCount"] [@default None];
806806+ repost_count: int option [@key "repostCount"] [@default None];
807807+ like_count: int option [@key "likeCount"] [@default None];
808808+ quote_count: int option [@key "quoteCount"] [@default None];
809809+ embeds: embeds_item list option [@default None];
810810+ indexed_at: string [@key "indexedAt"];
811811+}
812812+and record_with_media_view = {
813813+ record: record_view;
814814+ media: record_with_media_media;
815815+}
816816+817817+let rec embeds_item_of_yojson json =
818818+ let open Yojson.Safe.Util in
819819+ try
820820+ match json |> member "$type" |> to_string with
821821+ | "app.bsky.embed.images#view" ->
822822+ (match App_bsky_embed_images.view_of_yojson json with
823823+ | Ok v -> Ok (ImagesView v)
824824+ | Error e -> Error e)
825825+ | "app.bsky.embed.video#view" ->
826826+ (match App_bsky_embed_video.view_of_yojson json with
827827+ | Ok v -> Ok (VideoView v)
828828+ | Error e -> Error e)
829829+ | "app.bsky.embed.external#view" ->
830830+ (match App_bsky_embed_external.view_of_yojson json with
831831+ | Ok v -> Ok (ExternalView v)
832832+ | Error e -> Error e)
833833+ | "app.bsky.embed.record#view" ->
834834+ (match record_view_of_yojson json with
835835+ | Ok v -> Ok (RecordView v)
836836+ | Error e -> Error e)
837837+ | "app.bsky.embed.recordWithMedia#view" ->
838838+ (match record_with_media_view_of_yojson json with
839839+ | Ok v -> Ok (RecordWithMediaView v)
840840+ | Error e -> Error e)
841841+ | _ -> Ok (Unknown json)
842842+ with _ -> Error "failed to parse union"
843843+844844+and record_of_yojson json =
845845+ let open Yojson.Safe.Util in
846846+ try
847847+ match json |> member "$type" |> to_string with
848848+ | "app.bsky.embed.record#viewRecord" ->
849849+ (match view_record_of_yojson json with
850850+ | Ok v -> Ok (ViewRecord v)
851851+ | Error e -> Error e)
852852+ | "app.bsky.embed.record#viewNotFound" ->
853853+ (match view_not_found_of_yojson json with
854854+ | Ok v -> Ok (ViewNotFound v)
855855+ | Error e -> Error e)
856856+ | "app.bsky.embed.record#viewBlocked" ->
857857+ (match view_blocked_of_yojson json with
858858+ | Ok v -> Ok (ViewBlocked v)
859859+ | Error e -> Error e)
860860+ | "app.bsky.embed.record#viewDetached" ->
861861+ (match view_detached_of_yojson json with
862862+ | Ok v -> Ok (ViewDetached v)
863863+ | Error e -> Error e)
864864+ | "app.bsky.feed.defs#generatorView" ->
865865+ (match generator_view_of_yojson json with
866866+ | Ok v -> Ok (DefsGeneratorView v)
867867+ | Error e -> Error e)
868868+ | "app.bsky.graph.defs#listView" ->
869869+ (match list_view_of_yojson json with
870870+ | Ok v -> Ok (DefsListView v)
871871+ | Error e -> Error e)
872872+ | "app.bsky.labeler.defs#labelerView" ->
873873+ (match labeler_view_of_yojson json with
874874+ | Ok v -> Ok (DefsLabelerView v)
875875+ | Error e -> Error e)
876876+ | "app.bsky.graph.defs#starterPackViewBasic" ->
877877+ (match starter_pack_view_basic_of_yojson json with
878878+ | Ok v -> Ok (DefsStarterPackViewBasic v)
879879+ | Error e -> Error e)
880880+ | _ -> Ok (Unknown json)
881881+ with _ -> Error "failed to parse union"
882882+883883+and record_view_of_yojson json =
884884+ let open Yojson.Safe.Util in
885885+ try
886886+ let record = json |> member "record" |> record_of_yojson |> Result.get_ok in
887887+ Ok { record }
888888+ with e -> Error (Printexc.to_string e)
889889+890890+and view_record_of_yojson json =
891891+ let open Yojson.Safe.Util in
892892+ try
893893+ let uri = json |> member "uri" |> to_string in
894894+ let cid = json |> member "cid" |> to_string in
895895+ let author = json |> member "author" |> profile_view_basic_of_yojson |> Result.get_ok in
896896+ let value = json |> member "value" |> (fun j -> j) in
897897+ let labels = json |> member "labels" |> to_option (fun j -> to_list j |> List.filter_map (fun x -> match Com_atproto_label_defs.label_of_yojson x with Ok v -> Some v | _ -> None)) in
898898+ let reply_count = json |> member "replyCount" |> to_option to_int in
899899+ let repost_count = json |> member "repostCount" |> to_option to_int in
900900+ let like_count = json |> member "likeCount" |> to_option to_int in
901901+ let quote_count = json |> member "quoteCount" |> to_option to_int in
902902+ let embeds = json |> member "embeds" |> to_option (fun j -> to_list j |> List.filter_map (fun x -> match embeds_item_of_yojson x with Ok v -> Some v | _ -> None)) in
903903+ let indexed_at = json |> member "indexedAt" |> to_string in
904904+ Ok { uri; cid; author; value; labels; reply_count; repost_count; like_count; quote_count; embeds; indexed_at }
905905+ with e -> Error (Printexc.to_string e)
906906+907907+and record_with_media_view_of_yojson json =
908908+ let open Yojson.Safe.Util in
909909+ try
910910+ let record = json |> member "record" |> record_view_of_yojson |> Result.get_ok in
911911+ let media = json |> member "media" |> record_with_media_media_of_yojson |> Result.get_ok in
912912+ Ok { record; media }
913913+ with e -> Error (Printexc.to_string e)
914914+915915+and embeds_item_to_yojson = function
916916+ | ImagesView v ->
917917+ (match App_bsky_embed_images.view_to_yojson v with
918918+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.images#view") :: fields)
919919+ | other -> other)
920920+ | VideoView v ->
921921+ (match App_bsky_embed_video.view_to_yojson v with
922922+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.video#view") :: fields)
923923+ | other -> other)
924924+ | ExternalView v ->
925925+ (match App_bsky_embed_external.view_to_yojson v with
926926+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.external#view") :: fields)
927927+ | other -> other)
928928+ | RecordView v ->
929929+ (match record_view_to_yojson v with
930930+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.record#view") :: fields)
931931+ | other -> other)
932932+ | RecordWithMediaView v ->
933933+ (match record_with_media_view_to_yojson v with
934934+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.recordWithMedia#view") :: fields)
935935+ | other -> other)
936936+ | Unknown j -> j
937937+938938+and record_to_yojson = function
939939+ | ViewRecord v ->
940940+ (match view_record_to_yojson v with
941941+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.record#viewRecord") :: fields)
942942+ | other -> other)
943943+ | ViewNotFound v ->
944944+ (match view_not_found_to_yojson v with
945945+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.record#viewNotFound") :: fields)
946946+ | other -> other)
947947+ | ViewBlocked v ->
948948+ (match view_blocked_to_yojson v with
949949+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.record#viewBlocked") :: fields)
950950+ | other -> other)
951951+ | ViewDetached v ->
952952+ (match view_detached_to_yojson v with
953953+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.record#viewDetached") :: fields)
954954+ | other -> other)
955955+ | DefsGeneratorView v ->
956956+ (match generator_view_to_yojson v with
957957+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#generatorView") :: fields)
958958+ | other -> other)
959959+ | DefsListView v ->
960960+ (match list_view_to_yojson v with
961961+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.graph.defs#listView") :: fields)
962962+ | other -> other)
963963+ | DefsLabelerView v ->
964964+ (match labeler_view_to_yojson v with
965965+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.labeler.defs#labelerView") :: fields)
966966+ | other -> other)
967967+ | DefsStarterPackViewBasic v ->
968968+ (match starter_pack_view_basic_to_yojson v with
969969+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.graph.defs#starterPackViewBasic") :: fields)
970970+ | other -> other)
971971+ | Unknown j -> j
972972+973973+and record_view_to_yojson (r : record_view) =
974974+ `Assoc [
975975+ ("record", record_to_yojson r.record)
976976+ ]
977977+978978+and view_record_to_yojson (r : view_record) =
979979+ `Assoc [
980980+ ("uri", (fun s -> `String s) r.uri);
981981+ ("cid", (fun s -> `String s) r.cid);
982982+ ("author", profile_view_basic_to_yojson r.author);
983983+ ("value", (fun j -> j) r.value);
984984+ ("labels", match r.labels with Some v -> (fun l -> `List (List.map Com_atproto_label_defs.label_to_yojson l)) v | None -> `Null);
985985+ ("replyCount", match r.reply_count with Some v -> (fun i -> `Int i) v | None -> `Null);
986986+ ("repostCount", match r.repost_count with Some v -> (fun i -> `Int i) v | None -> `Null);
987987+ ("likeCount", match r.like_count with Some v -> (fun i -> `Int i) v | None -> `Null);
988988+ ("quoteCount", match r.quote_count with Some v -> (fun i -> `Int i) v | None -> `Null);
989989+ ("embeds", match r.embeds with Some v -> (fun l -> `List (List.map embeds_item_to_yojson l)) v | None -> `Null);
990990+ ("indexedAt", (fun s -> `String s) r.indexed_at)
991991+ ]
992992+993993+and record_with_media_view_to_yojson (r : record_with_media_view) =
994994+ `Assoc [
995995+ ("record", record_view_to_yojson r.record);
996996+ ("media", record_with_media_media_to_yojson r.media)
997997+ ]
998998+999999+type record_with_media_main =
10001000+ {
10011001+ record: record_main;
10021002+ media: record_with_media_media;
10031003+ }
10041004+[@@deriving yojson {strict= false}]
10051005+10061006+type threadgate_view =
10071007+ {
10081008+ uri: string option [@default None];
10091009+ cid: string option [@default None];
10101010+ record: Yojson.Safe.t option [@default None];
10111011+ lists: list_view_basic list option [@default None];
10121012+ }
10131013+[@@deriving yojson {strict= false}]
10141014+10151015+type feed_viewer_state =
10161016+ {
10171017+ repost: string option [@default None];
10181018+ like: string option [@default None];
10191019+ bookmarked: bool option [@default None];
10201020+ thread_muted: bool option [@key "threadMuted"] [@default None];
10211021+ reply_disabled: bool option [@key "replyDisabled"] [@default None];
10221022+ embedding_disabled: bool option [@key "embeddingDisabled"] [@default None];
10231023+ pinned: bool option [@default None];
10241024+ }
10251025+[@@deriving yojson {strict= false}]
10261026+10271027+type feed_embed =
10281028+ | ImagesView of App_bsky_embed_images.view
10291029+ | VideoView of App_bsky_embed_video.view
10301030+ | ExternalView of App_bsky_embed_external.view
10311031+ | RecordView of record_view
10321032+ | RecordWithMediaView of record_with_media_view
10331033+ | Unknown of Yojson.Safe.t
10341034+10351035+let feed_embed_of_yojson json =
10361036+ let open Yojson.Safe.Util in
10371037+ try
10381038+ match json |> member "$type" |> to_string with
10391039+ | "app.bsky.embed.images#view" ->
10401040+ (match App_bsky_embed_images.view_of_yojson json with
10411041+ | Ok v -> Ok (ImagesView v)
10421042+ | Error e -> Error e)
10431043+ | "app.bsky.embed.video#view" ->
10441044+ (match App_bsky_embed_video.view_of_yojson json with
10451045+ | Ok v -> Ok (VideoView v)
10461046+ | Error e -> Error e)
10471047+ | "app.bsky.embed.external#view" ->
10481048+ (match App_bsky_embed_external.view_of_yojson json with
10491049+ | Ok v -> Ok (ExternalView v)
10501050+ | Error e -> Error e)
10511051+ | "app.bsky.embed.record#view" ->
10521052+ (match record_view_of_yojson json with
10531053+ | Ok v -> Ok (RecordView v)
10541054+ | Error e -> Error e)
10551055+ | "app.bsky.embed.recordWithMedia#view" ->
10561056+ (match record_with_media_view_of_yojson json with
10571057+ | Ok v -> Ok (RecordWithMediaView v)
10581058+ | Error e -> Error e)
10591059+ | _ -> Ok (Unknown json)
10601060+ with _ -> Error "failed to parse union"
10611061+10621062+let feed_embed_to_yojson = function
10631063+ | ImagesView v ->
10641064+ (match App_bsky_embed_images.view_to_yojson v with
10651065+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.images#view") :: fields)
10661066+ | other -> other)
10671067+ | VideoView v ->
10681068+ (match App_bsky_embed_video.view_to_yojson v with
10691069+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.video#view") :: fields)
10701070+ | other -> other)
10711071+ | ExternalView v ->
10721072+ (match App_bsky_embed_external.view_to_yojson v with
10731073+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.external#view") :: fields)
10741074+ | other -> other)
10751075+ | RecordView v ->
10761076+ (match record_view_to_yojson v with
10771077+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.record#view") :: fields)
10781078+ | other -> other)
10791079+ | RecordWithMediaView v ->
10801080+ (match record_with_media_view_to_yojson v with
10811081+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.embed.recordWithMedia#view") :: fields)
10821082+ | other -> other)
10831083+ | Unknown j -> j
10841084+10851085+type post_view =
10861086+ {
10871087+ uri: string;
10881088+ cid: string;
10891089+ author: profile_view_basic;
10901090+ record: Yojson.Safe.t;
10911091+ embed: embeds_item option [@default None];
10921092+ bookmark_count: int option [@key "bookmarkCount"] [@default None];
10931093+ reply_count: int option [@key "replyCount"] [@default None];
10941094+ repost_count: int option [@key "repostCount"] [@default None];
10951095+ like_count: int option [@key "likeCount"] [@default None];
10961096+ quote_count: int option [@key "quoteCount"] [@default None];
10971097+ indexed_at: string [@key "indexedAt"];
10981098+ viewer: feed_viewer_state option [@default None];
10991099+ labels: Com_atproto_label_defs.label list option [@default None];
11001100+ threadgate: threadgate_view option [@default None];
11011101+ debug: Yojson.Safe.t option [@default None];
11021102+ }
11031103+[@@deriving yojson {strict= false}]
11041104+11051105+type thread_context =
11061106+ {
11071107+ root_author_like: string option [@key "rootAuthorLike"] [@default None];
11081108+ }
11091109+[@@deriving yojson {strict= false}]
11101110+11111111+type reason_pin = unit
11121112+let reason_pin_of_yojson _ = Ok ()
11131113+let reason_pin_to_yojson () = `Assoc []
11141114+11151115+type reason_repost =
11161116+ {
11171117+ by: profile_view_basic;
11181118+ uri: string option [@default None];
11191119+ cid: string option [@default None];
11201120+ indexed_at: string [@key "indexedAt"];
11211121+ }
11221122+[@@deriving yojson {strict= false}]
11231123+11241124+type blocked_post =
11251125+ {
11261126+ uri: string;
11271127+ blocked: bool;
11281128+ author: blocked_author;
11291129+ }
11301130+[@@deriving yojson {strict= false}]
11311131+11321132+type not_found_post =
11331133+ {
11341134+ uri: string;
11351135+ not_found: bool [@key "notFound"];
11361136+ }
11371137+[@@deriving yojson {strict= false}]
11381138+11391139+type feed_parent =
11401140+ | PostView of post_view
11411141+ | NotFoundPost of not_found_post
11421142+ | BlockedPost of blocked_post
11431143+ | Unknown of Yojson.Safe.t
11441144+11451145+let feed_parent_of_yojson json =
11461146+ let open Yojson.Safe.Util in
11471147+ try
11481148+ match json |> member "$type" |> to_string with
11491149+ | "app.bsky.feed.defs#postView" ->
11501150+ (match post_view_of_yojson json with
11511151+ | Ok v -> Ok (PostView v)
11521152+ | Error e -> Error e)
11531153+ | "app.bsky.feed.defs#notFoundPost" ->
11541154+ (match not_found_post_of_yojson json with
11551155+ | Ok v -> Ok (NotFoundPost v)
11561156+ | Error e -> Error e)
11571157+ | "app.bsky.feed.defs#blockedPost" ->
11581158+ (match blocked_post_of_yojson json with
11591159+ | Ok v -> Ok (BlockedPost v)
11601160+ | Error e -> Error e)
11611161+ | _ -> Ok (Unknown json)
11621162+ with _ -> Error "failed to parse union"
11631163+11641164+let feed_parent_to_yojson = function
11651165+ | PostView v ->
11661166+ (match post_view_to_yojson v with
11671167+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#postView") :: fields)
11681168+ | other -> other)
11691169+ | NotFoundPost v ->
11701170+ (match not_found_post_to_yojson v with
11711171+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#notFoundPost") :: fields)
11721172+ | other -> other)
11731173+ | BlockedPost v ->
11741174+ (match blocked_post_to_yojson v with
11751175+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#blockedPost") :: fields)
11761176+ | other -> other)
11771177+ | Unknown j -> j
11781178+11791179+type root =
11801180+ | PostView of post_view
11811181+ | NotFoundPost of not_found_post
11821182+ | BlockedPost of blocked_post
11831183+ | Unknown of Yojson.Safe.t
11841184+11851185+let root_of_yojson json =
11861186+ let open Yojson.Safe.Util in
11871187+ try
11881188+ match json |> member "$type" |> to_string with
11891189+ | "app.bsky.feed.defs#postView" ->
11901190+ (match post_view_of_yojson json with
11911191+ | Ok v -> Ok (PostView v)
11921192+ | Error e -> Error e)
11931193+ | "app.bsky.feed.defs#notFoundPost" ->
11941194+ (match not_found_post_of_yojson json with
11951195+ | Ok v -> Ok (NotFoundPost v)
11961196+ | Error e -> Error e)
11971197+ | "app.bsky.feed.defs#blockedPost" ->
11981198+ (match blocked_post_of_yojson json with
11991199+ | Ok v -> Ok (BlockedPost v)
12001200+ | Error e -> Error e)
12011201+ | _ -> Ok (Unknown json)
12021202+ with _ -> Error "failed to parse union"
12031203+12041204+let root_to_yojson = function
12051205+ | PostView v ->
12061206+ (match post_view_to_yojson v with
12071207+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#postView") :: fields)
12081208+ | other -> other)
12091209+ | NotFoundPost v ->
12101210+ (match not_found_post_to_yojson v with
12111211+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#notFoundPost") :: fields)
12121212+ | other -> other)
12131213+ | BlockedPost v ->
12141214+ (match blocked_post_to_yojson v with
12151215+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#blockedPost") :: fields)
12161216+ | other -> other)
12171217+ | Unknown j -> j
12181218+12191219+type reply_ref =
12201220+ {
12211221+ root: feed_parent;
12221222+ parent: feed_parent;
12231223+ grandparent_author: profile_view_basic option [@key "grandparentAuthor"] [@default None];
12241224+ }
12251225+[@@deriving yojson {strict= false}]
12261226+12271227+type feed_reason =
12281228+ | ReasonRepost of reason_repost
12291229+ | ReasonPin of reason_pin
12301230+ | Unknown of Yojson.Safe.t
12311231+12321232+let feed_reason_of_yojson json =
12331233+ let open Yojson.Safe.Util in
12341234+ try
12351235+ match json |> member "$type" |> to_string with
12361236+ | "app.bsky.feed.defs#reasonRepost" ->
12371237+ (match reason_repost_of_yojson json with
12381238+ | Ok v -> Ok (ReasonRepost v)
12391239+ | Error e -> Error e)
12401240+ | "app.bsky.feed.defs#reasonPin" ->
12411241+ (match reason_pin_of_yojson json with
12421242+ | Ok v -> Ok (ReasonPin v)
12431243+ | Error e -> Error e)
12441244+ | _ -> Ok (Unknown json)
12451245+ with _ -> Error "failed to parse union"
12461246+12471247+let feed_reason_to_yojson = function
12481248+ | ReasonRepost v ->
12491249+ (match reason_repost_to_yojson v with
12501250+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#reasonRepost") :: fields)
12511251+ | other -> other)
12521252+ | ReasonPin v ->
12531253+ (match reason_pin_to_yojson v with
12541254+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#reasonPin") :: fields)
12551255+ | other -> other)
12561256+ | Unknown j -> j
12571257+12581258+type feed_view_post =
12591259+ {
12601260+ post: post_view;
12611261+ reply: reply_ref option [@default None];
12621262+ reason: feed_reason option [@default None];
12631263+ feed_context: string option [@key "feedContext"] [@default None];
12641264+ req_id: string option [@key "reqId"] [@default None];
12651265+ }
12661266+[@@deriving yojson {strict= false}]
12671267+12681268+type replies_item =
12691269+ | ThreadViewPost of thread_view_post
12701270+ | NotFoundPost of not_found_post
12711271+ | BlockedPost of blocked_post
12721272+ | Unknown of Yojson.Safe.t
12731273+and thread_view_post = {
12741274+ post: post_view;
12751275+ parent: replies_item option [@default None];
12761276+ replies: replies_item list option [@default None];
12771277+ thread_context: thread_context option [@key "threadContext"] [@default None];
12781278+}
12791279+12801280+let rec replies_item_of_yojson json =
12811281+ let open Yojson.Safe.Util in
12821282+ try
12831283+ match json |> member "$type" |> to_string with
12841284+ | "app.bsky.feed.defs#threadViewPost" ->
12851285+ (match thread_view_post_of_yojson json with
12861286+ | Ok v -> Ok (ThreadViewPost v)
12871287+ | Error e -> Error e)
12881288+ | "app.bsky.feed.defs#notFoundPost" ->
12891289+ (match not_found_post_of_yojson json with
12901290+ | Ok v -> Ok (NotFoundPost v)
12911291+ | Error e -> Error e)
12921292+ | "app.bsky.feed.defs#blockedPost" ->
12931293+ (match blocked_post_of_yojson json with
12941294+ | Ok v -> Ok (BlockedPost v)
12951295+ | Error e -> Error e)
12961296+ | _ -> Ok (Unknown json)
12971297+ with _ -> Error "failed to parse union"
12981298+12991299+and thread_view_post_of_yojson json =
13001300+ let open Yojson.Safe.Util in
13011301+ try
13021302+ let post = json |> member "post" |> post_view_of_yojson |> Result.get_ok in
13031303+ let parent = json |> member "parent" |> to_option (fun x -> match replies_item_of_yojson x with Ok v -> Some v | _ -> None) |> Option.join in
13041304+ let replies = json |> member "replies" |> to_option (fun j -> to_list j |> List.filter_map (fun x -> match replies_item_of_yojson x with Ok v -> Some v | _ -> None)) in
13051305+ let thread_context = json |> member "threadContext" |> to_option (fun x -> match thread_context_of_yojson x with Ok v -> Some v | _ -> None) |> Option.join in
13061306+ Ok { post; parent; replies; thread_context }
13071307+ with e -> Error (Printexc.to_string e)
13081308+13091309+and replies_item_to_yojson = function
13101310+ | ThreadViewPost v ->
13111311+ (match thread_view_post_to_yojson v with
13121312+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#threadViewPost") :: fields)
13131313+ | other -> other)
13141314+ | NotFoundPost v ->
13151315+ (match not_found_post_to_yojson v with
13161316+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#notFoundPost") :: fields)
13171317+ | other -> other)
13181318+ | BlockedPost v ->
13191319+ (match blocked_post_to_yojson v with
13201320+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#blockedPost") :: fields)
13211321+ | other -> other)
13221322+ | Unknown j -> j
13231323+13241324+and thread_view_post_to_yojson (r : thread_view_post) =
13251325+ `Assoc [
13261326+ ("post", post_view_to_yojson r.post);
13271327+ ("parent", match r.parent with Some v -> replies_item_to_yojson v | None -> `Null);
13281328+ ("replies", match r.replies with Some v -> (fun l -> `List (List.map replies_item_to_yojson l)) v | None -> `Null);
13291329+ ("threadContext", match r.thread_context with Some v -> thread_context_to_yojson v | None -> `Null)
13301330+ ]
13311331+13321332+type skeleton_reason_pin = unit
13331333+let skeleton_reason_pin_of_yojson _ = Ok ()
13341334+let skeleton_reason_pin_to_yojson () = `Assoc []
13351335+13361336+type skeleton_reason_repost =
13371337+ {
13381338+ repost: string;
13391339+ }
13401340+[@@deriving yojson {strict= false}]
13411341+13421342+type skeleton_feed_post =
13431343+ {
13441344+ post: string;
13451345+ reason: feed_reason option [@default None];
13461346+ feed_context: string option [@key "feedContext"] [@default None];
13471347+ }
13481348+[@@deriving yojson {strict= false}]
13491349+13501350+type interaction =
13511351+ {
13521352+ item: string option [@default None];
13531353+ event: string option [@default None];
13541354+ feed_context: string option [@key "feedContext"] [@default None];
13551355+ req_id: string option [@key "reqId"] [@default None];
13561356+ }
13571357+[@@deriving yojson {strict= false}]
13581358+13591359+(** Request that less content like the given feed item be shown in the feed *)
13601360+let request_less = "app.bsky.feed.defs#requestLess"
13611361+13621362+(** Request that more content like the given feed item be shown in the feed *)
13631363+let request_more = "app.bsky.feed.defs#requestMore"
13641364+13651365+(** User clicked through to the feed item *)
13661366+let clickthrough_item = "app.bsky.feed.defs#clickthroughItem"
13671367+13681368+(** User clicked through to the author of the feed item *)
13691369+let clickthrough_author = "app.bsky.feed.defs#clickthroughAuthor"
13701370+13711371+(** User clicked through to the reposter of the feed item *)
13721372+let clickthrough_reposter = "app.bsky.feed.defs#clickthroughReposter"
13731373+13741374+(** User clicked through to the embedded content of the feed item *)
13751375+let clickthrough_embed = "app.bsky.feed.defs#clickthroughEmbed"
13761376+13771377+(** Declares the feed generator returns any types of posts. *)
13781378+let content_mode_unspecified = "app.bsky.feed.defs#contentModeUnspecified"
13791379+13801380+(** Declares the feed generator returns posts containing app.bsky.embed.video embeds. *)
13811381+let content_mode_video = "app.bsky.feed.defs#contentModeVideo"
13821382+13831383+(** Feed item was seen by user *)
13841384+let interaction_seen = "app.bsky.feed.defs#interactionSeen"
13851385+13861386+(** User liked the feed item *)
13871387+let interaction_like = "app.bsky.feed.defs#interactionLike"
13881388+13891389+(** User reposted the feed item *)
13901390+let interaction_repost = "app.bsky.feed.defs#interactionRepost"
13911391+13921392+(** User replied to the feed item *)
13931393+let interaction_reply = "app.bsky.feed.defs#interactionReply"
13941394+13951395+(** User quoted the feed item *)
13961396+let interaction_quote = "app.bsky.feed.defs#interactionQuote"
13971397+13981398+(** User shared the feed item *)
13991399+let interaction_share = "app.bsky.feed.defs#interactionShare"
14001400+14011401+type list_item_view =
14021402+ {
14031403+ uri: string;
14041404+ subject: profile_view;
14051405+ }
14061406+[@@deriving yojson {strict= false}]
14071407+14081408+type starter_pack_view =
14091409+ {
14101410+ uri: string;
14111411+ cid: string;
14121412+ record: Yojson.Safe.t;
14131413+ creator: profile_view_basic;
14141414+ list: list_view_basic option [@default None];
14151415+ list_items_sample: list_item_view list option [@key "listItemsSample"] [@default None];
14161416+ feeds: generator_view list option [@default None];
14171417+ joined_week_count: int option [@key "joinedWeekCount"] [@default None];
14181418+ joined_all_time_count: int option [@key "joinedAllTimeCount"] [@default None];
14191419+ labels: Com_atproto_label_defs.label list option [@default None];
14201420+ indexed_at: string [@key "indexedAt"];
14211421+ }
14221422+[@@deriving yojson {strict= false}]
14231423+14241424+(** A list of actors to apply an aggregate moderation action (mute/block) on. *)
14251425+let modlist = "app.bsky.graph.defs#modlist"
14261426+14271427+(** A list of actors used for curation purposes such as list feeds or interaction gating. *)
14281428+let curatelist = "app.bsky.graph.defs#curatelist"
14291429+14301430+(** A list of actors used for only for reference purposes such as within a starter pack. *)
14311431+let referencelist = "app.bsky.graph.defs#referencelist"
14321432+14331433+type not_found_actor =
14341434+ {
14351435+ actor: string;
14361436+ not_found: bool [@key "notFound"];
14371437+ }
14381438+[@@deriving yojson {strict= false}]
14391439+14401440+type relationship =
14411441+ {
14421442+ did: string;
14431443+ following: string option [@default None];
14441444+ followed_by: string option [@key "followedBy"] [@default None];
14451445+ blocking: string option [@default None];
14461446+ blocked_by: string option [@key "blockedBy"] [@default None];
14471447+ blocking_by_list: string option [@key "blockingByList"] [@default None];
14481448+ blocked_by_list: string option [@key "blockedByList"] [@default None];
14491449+ }
14501450+[@@deriving yojson {strict= false}]
14511451+14521452+type labeler_policies =
14531453+ {
14541454+ label_values: Com_atproto_label_defs.label_value list [@key "labelValues"];
14551455+ label_value_definitions: Com_atproto_label_defs.label_value_definition list option [@key "labelValueDefinitions"] [@default None];
14561456+ }
14571457+[@@deriving yojson {strict= false}]
14581458+14591459+type labeler_view_detailed =
14601460+ {
14611461+ uri: string;
14621462+ cid: string;
14631463+ creator: profile_view;
14641464+ policies: labeler_policies;
14651465+ like_count: int option [@key "likeCount"] [@default None];
14661466+ viewer: labeler_viewer_state option [@default None];
14671467+ indexed_at: string [@key "indexedAt"];
14681468+ labels: Com_atproto_label_defs.label list option [@default None];
14691469+ reason_types: Com_atproto_moderation_defs.reason_type list option [@key "reasonTypes"] [@default None];
14701470+ subject_types: Com_atproto_moderation_defs.subject_type list option [@key "subjectTypes"] [@default None];
14711471+ subject_collections: string list option [@key "subjectCollections"] [@default None];
14721472+ }
14731473+[@@deriving yojson {strict= false}]
14741474+
···11+(* generated from app.bsky.unspecced.getAgeAssuranceState *)
22+33+(** Returns the current state of the age assurance process for an account. This is used to check if the user has completed age assurance or if further action is required. *)
44+module Main = struct
55+ let nsid = "app.bsky.unspecced.getAgeAssuranceState"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type output = App_bsky_unspecced_defs.age_assurance_state
1111+[@@deriving yojson {strict= false}]
1212+1313+ let call
1414+ (client : Hermes.client) : output Lwt.t =
1515+ Hermes.query client nsid (`Assoc []) output_of_yojson
1616+end
1717+
···11+(* generated from app.bsky.unspecced.getPostThreadOtherV2 *)
22+33+type value =
44+ | ThreadItemPost of App_bsky_unspecced_defs.thread_item_post
55+ | Unknown of Yojson.Safe.t
66+77+let value_of_yojson json =
88+ let open Yojson.Safe.Util in
99+ try
1010+ match json |> member "$type" |> to_string with
1111+ | "app.bsky.unspecced.defs#threadItemPost" ->
1212+ (match App_bsky_unspecced_defs.thread_item_post_of_yojson json with
1313+ | Ok v -> Ok (ThreadItemPost v)
1414+ | Error e -> Error e)
1515+ | _ -> Ok (Unknown json)
1616+ with _ -> Error "failed to parse union"
1717+1818+let value_to_yojson = function
1919+ | ThreadItemPost v ->
2020+ (match App_bsky_unspecced_defs.thread_item_post_to_yojson v with
2121+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.unspecced.defs#threadItemPost") :: fields)
2222+ | other -> other)
2323+ | Unknown j -> j
2424+2525+type thread_item =
2626+ {
2727+ uri: string;
2828+ depth: int;
2929+ value: value;
3030+ }
3131+[@@deriving yojson {strict= false}]
3232+3333+(** (NOTE: this endpoint is under development and WILL change without notice. Don't use it until it is moved out of `unspecced` or your application WILL break) Get additional posts under a thread e.g. replies hidden by threadgate. Based on an anchor post at any depth of the tree, returns top-level replies below that anchor. It does not include ancestors nor the anchor itself. This should be called after exhausting `app.bsky.unspecced.getPostThreadV2`. Does not require auth, but additional metadata and filtering will be applied for authed requests. *)
3434+module Main = struct
3535+ let nsid = "app.bsky.unspecced.getPostThreadOtherV2"
3636+3737+ type params =
3838+ {
3939+ anchor: string;
4040+ }
4141+[@@deriving yojson {strict= false}]
4242+4343+ type output =
4444+ {
4545+ thread: thread_item list;
4646+ }
4747+[@@deriving yojson {strict= false}]
4848+4949+ let call
5050+ ~anchor
5151+ (client : Hermes.client) : output Lwt.t =
5252+ let params : params = {anchor} in
5353+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
5454+end
5555+
···11+(* generated from app.bsky.unspecced.getPostThreadV2 *)
22+33+type value =
44+ | ThreadItemPost of App_bsky_unspecced_defs.thread_item_post
55+ | ThreadItemNoUnauthenticated of App_bsky_unspecced_defs.thread_item_no_unauthenticated
66+ | ThreadItemNotFound of App_bsky_unspecced_defs.thread_item_not_found
77+ | ThreadItemBlocked of App_bsky_unspecced_defs.thread_item_blocked
88+ | Unknown of Yojson.Safe.t
99+1010+let value_of_yojson json =
1111+ let open Yojson.Safe.Util in
1212+ try
1313+ match json |> member "$type" |> to_string with
1414+ | "app.bsky.unspecced.defs#threadItemPost" ->
1515+ (match App_bsky_unspecced_defs.thread_item_post_of_yojson json with
1616+ | Ok v -> Ok (ThreadItemPost v)
1717+ | Error e -> Error e)
1818+ | "app.bsky.unspecced.defs#threadItemNoUnauthenticated" ->
1919+ (match App_bsky_unspecced_defs.thread_item_no_unauthenticated_of_yojson json with
2020+ | Ok v -> Ok (ThreadItemNoUnauthenticated v)
2121+ | Error e -> Error e)
2222+ | "app.bsky.unspecced.defs#threadItemNotFound" ->
2323+ (match App_bsky_unspecced_defs.thread_item_not_found_of_yojson json with
2424+ | Ok v -> Ok (ThreadItemNotFound v)
2525+ | Error e -> Error e)
2626+ | "app.bsky.unspecced.defs#threadItemBlocked" ->
2727+ (match App_bsky_unspecced_defs.thread_item_blocked_of_yojson json with
2828+ | Ok v -> Ok (ThreadItemBlocked v)
2929+ | Error e -> Error e)
3030+ | _ -> Ok (Unknown json)
3131+ with _ -> Error "failed to parse union"
3232+3333+let value_to_yojson = function
3434+ | ThreadItemPost v ->
3535+ (match App_bsky_unspecced_defs.thread_item_post_to_yojson v with
3636+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.unspecced.defs#threadItemPost") :: fields)
3737+ | other -> other)
3838+ | ThreadItemNoUnauthenticated v ->
3939+ (match App_bsky_unspecced_defs.thread_item_no_unauthenticated_to_yojson v with
4040+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.unspecced.defs#threadItemNoUnauthenticated") :: fields)
4141+ | other -> other)
4242+ | ThreadItemNotFound v ->
4343+ (match App_bsky_unspecced_defs.thread_item_not_found_to_yojson v with
4444+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.unspecced.defs#threadItemNotFound") :: fields)
4545+ | other -> other)
4646+ | ThreadItemBlocked v ->
4747+ (match App_bsky_unspecced_defs.thread_item_blocked_to_yojson v with
4848+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.unspecced.defs#threadItemBlocked") :: fields)
4949+ | other -> other)
5050+ | Unknown j -> j
5151+5252+type thread_item =
5353+ {
5454+ uri: string;
5555+ depth: int;
5656+ value: value;
5757+ }
5858+[@@deriving yojson {strict= false}]
5959+6060+(** (NOTE: this endpoint is under development and WILL change without notice. Don't use it until it is moved out of `unspecced` or your application WILL break) Get posts in a thread. It is based in an anchor post at any depth of the tree, and returns posts above it (recursively resolving the parent, without further branching to their replies) and below it (recursive replies, with branching to their replies). Does not require auth, but additional metadata and filtering will be applied for authed requests. *)
6161+module Main = struct
6262+ let nsid = "app.bsky.unspecced.getPostThreadV2"
6363+6464+ type params =
6565+ {
6666+ anchor: string;
6767+ above: bool option [@default None];
6868+ below: int option [@default None];
6969+ branching_factor: int option [@key "branchingFactor"] [@default None];
7070+ sort: string option [@default None];
7171+ }
7272+[@@deriving yojson {strict= false}]
7373+7474+ type output =
7575+ {
7676+ thread: thread_item list;
7777+ threadgate: App_bsky_feed_defs.threadgate_view option [@default None];
7878+ has_other_replies: bool [@key "hasOtherReplies"];
7979+ }
8080+[@@deriving yojson {strict= false}]
8181+8282+ let call
8383+ ~anchor
8484+ ?above
8585+ ?below
8686+ ?branching_factor
8787+ ?sort
8888+ (client : Hermes.client) : output Lwt.t =
8989+ let params : params = {anchor; above; below; branching_factor; sort} in
9090+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
9191+end
9292+
···11+(* generated from app.bsky.unspecced.initAgeAssurance *)
22+33+(** Initiate age assurance for an account. This is a one-time action that will start the process of verifying the user's age. *)
44+module Main = struct
55+ let nsid = "app.bsky.unspecced.initAgeAssurance"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ email: string;
1313+ language: string;
1414+ country_code: string [@key "countryCode"];
1515+ }
1616+ [@@deriving yojson {strict= false}]
1717+1818+ type output = App_bsky_unspecced_defs.age_assurance_state
1919+[@@deriving yojson {strict= false}]
2020+2121+ let call
2222+ ~email
2323+ ~language
2424+ ~country_code
2525+ (client : Hermes.client) : output Lwt.t =
2626+ let params = () in
2727+ let input = Some ({email; language; country_code} |> input_to_yojson) in
2828+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2929+end
3030+
···11+(* generated from com.atproto.admin.deleteAccount *)
22+33+(** Delete a user account as an administrator. *)
44+module Main = struct
55+ let nsid = "com.atproto.admin.deleteAccount"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ did: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~did
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({did} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from com.atproto.admin.disableInviteCodes *)
22+33+(** Disable some set of codes and/or all codes associated with a set of users. *)
44+module Main = struct
55+ let nsid = "com.atproto.admin.disableInviteCodes"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ codes: string list option [@default None];
1313+ accounts: string list option [@default None];
1414+ }
1515+ [@@deriving yojson {strict= false}]
1616+1717+ type output = unit
1818+ let output_of_yojson _ = Ok ()
1919+2020+ let call
2121+ ?codes
2222+ ?accounts
2323+ (client : Hermes.client) : output Lwt.t =
2424+ let params = () in
2525+ let input = Some ({codes; accounts} |> input_to_yojson) in
2626+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2727+end
2828+
···11+(* generated from com.atproto.admin.updateAccountPassword *)
22+33+(** Update the password for a user account as an administrator. *)
44+module Main = struct
55+ let nsid = "com.atproto.admin.updateAccountPassword"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ did: string;
1313+ password: string;
1414+ }
1515+ [@@deriving yojson {strict= false}]
1616+1717+ type output = unit
1818+ let output_of_yojson _ = Ok ()
1919+2020+ let call
2121+ ~did
2222+ ~password
2323+ (client : Hermes.client) : output Lwt.t =
2424+ let params = () in
2525+ let input = Some ({did; password} |> input_to_yojson) in
2626+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2727+end
2828+
···11+(* generated from com.atproto.identity.getRecommendedDidCredentials *)
22+33+(** Describe the credentials that should be included in the DID doc of an account that is migrating to this service. *)
44+module Main = struct
55+ let nsid = "com.atproto.identity.getRecommendedDidCredentials"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type output =
1111+ {
1212+ rotation_keys: string list option [@key "rotationKeys"] [@default None];
1313+ also_known_as: string list option [@key "alsoKnownAs"] [@default None];
1414+ verification_methods: Yojson.Safe.t option [@key "verificationMethods"] [@default None];
1515+ services: Yojson.Safe.t option [@default None];
1616+ }
1717+[@@deriving yojson {strict= false}]
1818+1919+ let call
2020+ (client : Hermes.client) : output Lwt.t =
2121+ Hermes.query client nsid (`Assoc []) output_of_yojson
2222+end
2323+
···11+(* generated from com.atproto.identity.refreshIdentity *)
22+33+(** Request that the server re-resolve an identity (DID and handle). The server may ignore this request, or require authentication, depending on the role, implementation, and policy of the server. *)
44+module Main = struct
55+ let nsid = "com.atproto.identity.refreshIdentity"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ identifier: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = Com_atproto_identity_defs.identity_info
1717+[@@deriving yojson {strict= false}]
1818+1919+ let call
2020+ ~identifier
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({identifier} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from com.atproto.identity.requestPlcOperationSignature *)
22+33+(** Request an email with a code to in order to request a signed PLC operation. Requires Auth. *)
44+module Main = struct
55+ let nsid = "com.atproto.identity.requestPlcOperationSignature"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type output = unit
1111+ let output_of_yojson _ = Ok ()
1212+1313+ let call
1414+ (client : Hermes.client) : output Lwt.t =
1515+ let params = () in
1616+ let input = None in
1717+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
1818+end
1919+
···11+(* generated from com.atproto.identity.submitPlcOperation *)
22+33+(** Validates a PLC operation to ensure that it doesn't violate a service's constraints or get the identity into a bad state, then submits it to the PLC registry *)
44+module Main = struct
55+ let nsid = "com.atproto.identity.submitPlcOperation"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ operation: Yojson.Safe.t;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~operation
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({operation} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from com.atproto.identity.updateHandle *)
22+33+(** Updates the current account's handle. Verifies handle validity, and updates did:plc document if necessary. Implemented by PDS, and requires auth. *)
44+module Main = struct
55+ let nsid = "com.atproto.identity.updateHandle"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ handle: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~handle
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({handle} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from com.atproto.moderation.defs *)
22+33+(** String type with known values *)
44+type reason_type = string
55+let reason_type_of_yojson = function
66+ | `String s -> Ok s
77+ | _ -> Error "reason_type: expected string"
88+let reason_type_to_yojson s = `String s
99+1010+(** Spam: frequent unwanted promotion, replies, mentions. Prefer new lexicon definition `tools.ozone.report.defs#reasonMisleadingSpam`. *)
1111+let reason_spam = "com.atproto.moderation.defs#reasonSpam"
1212+1313+(** Direct violation of server rules, laws, terms of service. Prefer new lexicon definition `tools.ozone.report.defs#reasonRuleOther`. *)
1414+let reason_violation = "com.atproto.moderation.defs#reasonViolation"
1515+1616+(** Misleading identity, affiliation, or content. Prefer new lexicon definition `tools.ozone.report.defs#reasonMisleadingOther`. *)
1717+let reason_misleading = "com.atproto.moderation.defs#reasonMisleading"
1818+1919+(** Unwanted or mislabeled sexual content. Prefer new lexicon definition `tools.ozone.report.defs#reasonSexualUnlabeled`. *)
2020+let reason_sexual = "com.atproto.moderation.defs#reasonSexual"
2121+2222+(** Rude, harassing, explicit, or otherwise unwelcoming behavior. Prefer new lexicon definition `tools.ozone.report.defs#reasonHarassmentOther`. *)
2323+let reason_rude = "com.atproto.moderation.defs#reasonRude"
2424+2525+(** Reports not falling under another report category. Prefer new lexicon definition `tools.ozone.report.defs#reasonOther`. *)
2626+let reason_other = "com.atproto.moderation.defs#reasonOther"
2727+2828+(** Appeal a previously taken moderation action *)
2929+let reason_appeal = "com.atproto.moderation.defs#reasonAppeal"
3030+3131+(** String type with known values: Tag describing a type of subject that might be reported. *)
3232+type subject_type = string
3333+let subject_type_of_yojson = function
3434+ | `String s -> Ok s
3535+ | _ -> Error "subject_type: expected string"
3636+let subject_type_to_yojson s = `String s
3737+
···11+(* generated from com.atproto.repo.importRepo *)
22+33+(** Import a repo in the form of a CAR file. Requires Content-Length HTTP header to be set. *)
44+module Main = struct
55+ let nsid = "com.atproto.repo.importRepo"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type output = unit
1111+ let output_of_yojson _ = Ok ()
1212+1313+ let call
1414+ ?input
1515+ (client : Hermes.client) : output Lwt.t =
1616+ let params = () in
1717+ let open Lwt.Syntax in
1818+ let* _ = Hermes.procedure_bytes client nsid (params_to_yojson params) input ~content_type:"application/vnd.ipld.car" in
1919+ Lwt.return ()
2020+end
2121+
···11+(* generated from com.atproto.repo.uploadBlob *)
22+33+(** Upload a new blob, to be referenced from a repository record. The blob will be deleted if it is not referenced within a time window (eg, minutes). Blob restrictions (mimetype, size, etc) are enforced when the reference is created. Requires auth, implemented by PDS. *)
44+module Main = struct
55+ let nsid = "com.atproto.repo.uploadBlob"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type output =
1111+ {
1212+ blob: Hermes.blob;
1313+ }
1414+[@@deriving yojson {strict= false}]
1515+1616+ let call
1717+ ?input
1818+ (client : Hermes.client) : output Lwt.t =
1919+ let params = () in
2020+ Hermes.procedure_blob client nsid (params_to_yojson params) (Bytes.of_string (Option.value input ~default:"")) ~content_type:"*/*" output_of_yojson
2121+end
2222+
···11+(* generated from com.atproto.server.activateAccount *)
22+33+(** Activates a currently deactivated account. Used to finalize account migration after the account's repo is imported and identity is setup. *)
44+module Main = struct
55+ let nsid = "com.atproto.server.activateAccount"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type output = unit
1111+ let output_of_yojson _ = Ok ()
1212+1313+ let call
1414+ (client : Hermes.client) : output Lwt.t =
1515+ let params = () in
1616+ let input = None in
1717+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
1818+end
1919+
···11+(* generated from com.atproto.server.checkAccountStatus *)
22+33+(** Returns the status of an account, especially as pertaining to import or recovery. Can be called many times over the course of an account migration. Requires auth and can only be called pertaining to oneself. *)
44+module Main = struct
55+ let nsid = "com.atproto.server.checkAccountStatus"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type output =
1111+ {
1212+ activated: bool;
1313+ valid_did: bool [@key "validDid"];
1414+ repo_commit: string [@key "repoCommit"];
1515+ repo_rev: string [@key "repoRev"];
1616+ repo_blocks: int [@key "repoBlocks"];
1717+ indexed_records: int [@key "indexedRecords"];
1818+ private_state_values: int [@key "privateStateValues"];
1919+ expected_blobs: int [@key "expectedBlobs"];
2020+ imported_blobs: int [@key "importedBlobs"];
2121+ }
2222+[@@deriving yojson {strict= false}]
2323+2424+ let call
2525+ (client : Hermes.client) : output Lwt.t =
2626+ Hermes.query client nsid (`Assoc []) output_of_yojson
2727+end
2828+
···11+(* generated from com.atproto.server.deactivateAccount *)
22+33+(** Deactivates a currently active account. Stops serving of repo, and future writes to repo until reactivated. Used to finalize account migration with the old host after the account has been activated on the new host. *)
44+module Main = struct
55+ let nsid = "com.atproto.server.deactivateAccount"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ delete_after: string option [@key "deleteAfter"] [@default None];
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ?delete_after
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({delete_after} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from com.atproto.server.deleteAccount *)
22+33+(** Delete an actor's account with a token and password. Can only be called after requesting a deletion token. Requires auth. *)
44+module Main = struct
55+ let nsid = "com.atproto.server.deleteAccount"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ did: string;
1313+ password: string;
1414+ token: string;
1515+ }
1616+ [@@deriving yojson {strict= false}]
1717+1818+ type output = unit
1919+ let output_of_yojson _ = Ok ()
2020+2121+ let call
2222+ ~did
2323+ ~password
2424+ ~token
2525+ (client : Hermes.client) : output Lwt.t =
2626+ let params = () in
2727+ let input = Some ({did; password; token} |> input_to_yojson) in
2828+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2929+end
3030+
···11+(* generated from com.atproto.server.deleteSession *)
22+33+(** Delete the current session. Requires auth using the 'refreshJwt' (not the 'accessJwt'). *)
44+module Main = struct
55+ let nsid = "com.atproto.server.deleteSession"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type output = unit
1111+ let output_of_yojson _ = Ok ()
1212+1313+ let call
1414+ (client : Hermes.client) : output Lwt.t =
1515+ let params = () in
1616+ let input = None in
1717+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
1818+end
1919+
···11+(* generated from com.atproto.server.requestAccountDelete *)
22+33+(** Initiate a user account deletion via email. *)
44+module Main = struct
55+ let nsid = "com.atproto.server.requestAccountDelete"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type output = unit
1111+ let output_of_yojson _ = Ok ()
1212+1313+ let call
1414+ (client : Hermes.client) : output Lwt.t =
1515+ let params = () in
1616+ let input = None in
1717+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
1818+end
1919+
···11+(* generated from com.atproto.server.requestEmailConfirmation *)
22+33+(** Request an email with a code to confirm ownership of email. *)
44+module Main = struct
55+ let nsid = "com.atproto.server.requestEmailConfirmation"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type output = unit
1111+ let output_of_yojson _ = Ok ()
1212+1313+ let call
1414+ (client : Hermes.client) : output Lwt.t =
1515+ let params = () in
1616+ let input = None in
1717+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
1818+end
1919+
···11+(* generated from com.atproto.server.reserveSigningKey *)
22+33+(** Reserve a repo signing key, for use with account creation. Necessary so that a DID PLC update operation can be constructed during an account migraiton. Public and does not require auth; implemented by PDS. NOTE: this endpoint may change when full account migration is implemented. *)
44+module Main = struct
55+ let nsid = "com.atproto.server.reserveSigningKey"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ did: string option [@default None];
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output =
1717+ {
1818+ signing_key: string [@key "signingKey"];
1919+ }
2020+[@@deriving yojson {strict= false}]
2121+2222+ let call
2323+ ?did
2424+ (client : Hermes.client) : output Lwt.t =
2525+ let params = () in
2626+ let input = Some ({did} |> input_to_yojson) in
2727+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2828+end
2929+
···11+(* generated from com.atproto.server.updateEmail *)
22+33+(** Update an account's email. *)
44+module Main = struct
55+ let nsid = "com.atproto.server.updateEmail"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ email: string;
1313+ email_auth_factor: bool option [@key "emailAuthFactor"] [@default None];
1414+ token: string option [@default None];
1515+ }
1616+ [@@deriving yojson {strict= false}]
1717+1818+ type output = unit
1919+ let output_of_yojson _ = Ok ()
2020+2121+ let call
2222+ ~email
2323+ ?email_auth_factor
2424+ ?token
2525+ (client : Hermes.client) : output Lwt.t =
2626+ let params = () in
2727+ let input = Some ({email; email_auth_factor; token} |> input_to_yojson) in
2828+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2929+end
3030+
+9
pegasus/lib/lexicons/com_atproto_sync_defs.ml
···11+(* generated from com.atproto.sync.defs *)
22+33+(** String type with known values *)
44+type host_status = string
55+let host_status_of_yojson = function
66+ | `String s -> Ok s
77+ | _ -> Error "host_status: expected string"
88+let host_status_to_yojson s = `String s
99+
+24
pegasus/lib/lexicons/com_atproto_sync_getBlob.ml
···11+(* generated from com.atproto.sync.getBlob *)
22+33+(** Get a blob associated with a given account. Returns the full blob as originally uploaded. Does not require auth; implemented by PDS. *)
44+module Main = struct
55+ let nsid = "com.atproto.sync.getBlob"
66+77+ type params =
88+ {
99+ did: string;
1010+ cid: string;
1111+ }
1212+[@@deriving yojson {strict= false}]
1313+1414+ (** Raw bytes output with content type *)
1515+ type output = string * string
1616+1717+ let call
1818+ ~did
1919+ ~cid
2020+ (client : Hermes.client) : output Lwt.t =
2121+ let params : params = {did; cid} in
2222+ Hermes.query_bytes client nsid (params_to_yojson params)
2323+end
2424+
···11+(* generated from com.atproto.sync.getBlocks *)
22+33+(** Get data blocks from a given repo, by CID. For example, intermediate MST nodes, or records. Does not require auth; implemented by PDS. *)
44+module Main = struct
55+ let nsid = "com.atproto.sync.getBlocks"
66+77+ type params =
88+ {
99+ did: string;
1010+ cids: string list;
1111+ }
1212+[@@deriving yojson {strict= false}]
1313+1414+ (** Raw bytes output with content type *)
1515+ type output = string * string
1616+1717+ let call
1818+ ~did
1919+ ~cids
2020+ (client : Hermes.client) : output Lwt.t =
2121+ let params : params = {did; cids} in
2222+ Hermes.query_bytes client nsid (params_to_yojson params)
2323+end
2424+
···11+(* generated from com.atproto.sync.getRecord *)
22+33+(** Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth. *)
44+module Main = struct
55+ let nsid = "com.atproto.sync.getRecord"
66+77+ type params =
88+ {
99+ did: string;
1010+ collection: string;
1111+ rkey: string;
1212+ }
1313+[@@deriving yojson {strict= false}]
1414+1515+ (** Raw bytes output with content type *)
1616+ type output = string * string
1717+1818+ let call
1919+ ~did
2020+ ~collection
2121+ ~rkey
2222+ (client : Hermes.client) : output Lwt.t =
2323+ let params : params = {did; collection; rkey} in
2424+ Hermes.query_bytes client nsid (params_to_yojson params)
2525+end
2626+
+24
pegasus/lib/lexicons/com_atproto_sync_getRepo.ml
···11+(* generated from com.atproto.sync.getRepo *)
22+33+(** Download a repository export as CAR file. Optionally only a 'diff' since a previous revision. Does not require auth; implemented by PDS. *)
44+module Main = struct
55+ let nsid = "com.atproto.sync.getRepo"
66+77+ type params =
88+ {
99+ did: string;
1010+ since: string option [@default None];
1111+ }
1212+[@@deriving yojson {strict= false}]
1313+1414+ (** Raw bytes output with content type *)
1515+ type output = string * string
1616+1717+ let call
1818+ ~did
1919+ ?since
2020+ (client : Hermes.client) : output Lwt.t =
2121+ let params : params = {did; since} in
2222+ Hermes.query_bytes client nsid (params_to_yojson params)
2323+end
2424+
···11+(* generated from com.atproto.sync.notifyOfUpdate *)
22+33+(** Notify a crawling service of a recent update, and that crawling should resume. Intended use is after a gap between repo stream events caused the crawling service to disconnect. Does not require auth; implemented by Relay. DEPRECATED: just use com.atproto.sync.requestCrawl *)
44+module Main = struct
55+ let nsid = "com.atproto.sync.notifyOfUpdate"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ hostname: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~hostname
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({hostname} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from com.atproto.sync.requestCrawl *)
22+33+(** Request a service to persistently crawl hosted repos. Expected use is new PDS instances declaring their existence to Relays. Does not require auth. *)
44+module Main = struct
55+ let nsid = "com.atproto.sync.requestCrawl"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ hostname: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~hostname
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({hostname} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from com.atproto.temp.requestPhoneVerification *)
22+33+(** Request a verification code to be sent to the supplied phone number *)
44+module Main = struct
55+ let nsid = "com.atproto.temp.requestPhoneVerification"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ phone_number: string [@key "phoneNumber"];
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~phone_number
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({phone_number} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+
···11+(* generated from com.atproto.temp.revokeAccountCredentials *)
22+33+(** Revoke sessions, password, and app passwords associated with account. May be resolved by a password reset. *)
44+module Main = struct
55+ let nsid = "com.atproto.temp.revokeAccountCredentials"
66+77+ type params = unit
88+ let params_to_yojson () = `Assoc []
99+1010+ type input =
1111+ {
1212+ account: string;
1313+ }
1414+ [@@deriving yojson {strict= false}]
1515+1616+ type output = unit
1717+ let output_of_yojson _ = Ok ()
1818+1919+ let call
2020+ ~account
2121+ (client : Hermes.client) : output Lwt.t =
2222+ let params = () in
2323+ let input = Some ({account} |> input_to_yojson) in
2424+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
2525+end
2626+