···1+type t =
2+ { mutable imports: string list
3+ ; mutable generated_unions: string list
4+ ; mutable union_names: (string list * string) list (* refs -> context name *)
5+ ; buf: Buffer.t }
6+7+let make () =
8+ {imports= []; generated_unions= []; union_names= []; buf= Buffer.create 4096}
9+10+(** add an import if not already present *)
11+let add_import t module_name =
12+ if not (List.mem module_name t.imports) then
13+ t.imports <- module_name :: t.imports
14+15+let get_imports t = t.imports
16+17+(** mark a union type as generated to avoid duplicates *)
18+let mark_union_generated t union_name =
19+ if not (List.mem union_name t.generated_unions) then
20+ t.generated_unions <- union_name :: t.generated_unions
21+22+let is_union_generated t union_name = List.mem union_name t.generated_unions
23+24+(** register a context-based name for a union based on its refs,
25+ allowing inline unions to be reused when the same refs appear elsewhere *)
26+let register_union_name t refs context_name =
27+ let sorted_refs = List.sort String.compare refs in
28+ if not (List.exists (fun (r, _) -> r = sorted_refs) t.union_names) then
29+ t.union_names <- (sorted_refs, context_name) :: t.union_names
30+31+(** look up a union's registered context-based name *)
32+let lookup_union_name t refs =
33+ let sorted_refs = List.sort String.compare refs in
34+ List.assoc_opt sorted_refs t.union_names
35+36+let emit t s = Buffer.add_string t.buf s
37+38+let emitln t s = Buffer.add_string t.buf s ; Buffer.add_char t.buf '\n'
39+40+let emit_newline t = Buffer.add_char t.buf '\n'
41+42+let contents t = Buffer.contents t.buf
···1-type response =
2- { activated: bool
3- ; valid_did: bool [@key "validDid"]
4- ; repo_commit: string [@key "repoCommit"]
5- ; repo_rev: string [@key "repoRev"]
6- ; repo_blocks: int [@key "repoBlocks"]
7- ; indexed_records: int [@key "indexedRecords"]
8- ; private_state_values: int [@key "privateStateValues"]
9- ; expected_blobs: int [@key "expectedBlobs"]
10- ; imported_blobs: int [@key "importedBlobs"] }
11-[@@deriving yojson {strict= false}]
1213let get_account_status did =
14 let%lwt {db= us; commit; actor; _} = Repository.load did in
···48 let did = Auth.get_authed_did_exn auth in
49 match%lwt get_account_status did with
50 | Ok status ->
51- status |> response_to_yojson |> Yojson.Safe.to_string |> Dream.json
52 | Error msg ->
53 Errors.internal_error ~msg () )
···1+open Lexicons.Com_atproto_server_checkAccountStatus.Main
000000000023let get_account_status did =
4 let%lwt {db= us; commit; actor; _} = Repository.load did in
···38 let did = Auth.get_authed_did_exn auth in
39 match%lwt get_account_status did with
40 | Ok status ->
41+ status |> output_to_yojson |> Yojson.Safe.to_string |> Dream.json
42 | Error msg ->
43 Errors.internal_error ~msg () )
+2-3
pegasus/lib/api/server/confirmEmail.ml
···1-type request = {email: string; token: string}
2-[@@deriving yojson {strict= false}]
34type confirm_error = InvalidToken | ExpiredToken | EmailMismatch
5···23 Auth.assert_account_scope auth ~attr:Oauth.Scopes.Email
24 ~action:Oauth.Scopes.Manage ;
25 let did = Auth.get_authed_did_exn auth in
26- let%lwt {email; token} = Xrpc.parse_body req request_of_yojson in
27 match%lwt Data_store.get_actor_by_identifier did db with
28 | None ->
29 Errors.invalid_request ~name:"AccountNotFound" "account not found"
···1+open Lexicons.Com_atproto_server_confirmEmail.Main
023type confirm_error = InvalidToken | ExpiredToken | EmailMismatch
4···22 Auth.assert_account_scope auth ~attr:Oauth.Scopes.Email
23 ~action:Oauth.Scopes.Manage ;
24 let did = Auth.get_authed_did_exn auth in
25+ let%lwt {email; token} = Xrpc.parse_body req input_of_yojson in
26 match%lwt Data_store.get_actor_by_identifier did db with
27 | None ->
28 Errors.invalid_request ~name:"AccountNotFound" "account not found"
···1+open Lexicons.Com_atproto_server_refreshSession.Main
000000023let handler =
4 Xrpc.handler ~auth:Refresh (fun {db; auth; _} ->
···10 failwith "non-refresh auth"
11 in
12 let%lwt () = Data_store.revoke_token ~did ~jti db in
13+ let%lwt
14+ { handle
15+ ; did
16+ ; email
17+ ; email_auth_factor
18+ ; email_confirmed
19+ ; active
20+ ; status
21+ ; _ } =
22+ Auth.get_session_info did db
23+ in
24 let access_jwt, refresh_jwt = Jwt.generate_jwt did in
25 Dream.json @@ Yojson.Safe.to_string
26+ @@ output_to_yojson
27+ { access_jwt
28+ ; refresh_jwt
29+ ; handle
30+ ; did
31+ ; email
32+ ; email_auth_factor
33+ ; email_confirmed
34+ ; active
35+ ; status
36+ ; did_doc= None } )
+2-3
pegasus/lib/api/server/requestEmailUpdate.ml
···1-type response = {token_required: bool [@key "tokenRequired"]}
2-[@@deriving yojson]
34let request_email_update ?pending_email (actor : Data_store.Types.actor) db =
5 let token_required =
···65 | Some actor ->
66 let%lwt token_required = request_email_update actor db in
67 Dream.json @@ Yojson.Safe.to_string
68- @@ response_to_yojson {token_required} )
···1+open Lexicons.Com_atproto_server_requestEmailUpdate.Main
023let request_email_update ?pending_email (actor : Data_store.Types.actor) db =
4 let token_required =
···64 | Some actor ->
65 let%lwt token_required = request_email_update actor db in
66 Dream.json @@ Yojson.Safe.to_string
67+ @@ output_to_yojson {token_required} )
+2-2
pegasus/lib/api/server/requestPasswordReset.ml
···1-type request = {email: string} [@@deriving yojson {strict= false}]
23let request_password_reset (actor : Data_store.Types.actor) db =
4 let did = actor.did in
···36 | None ->
37 Errors.internal_error ~msg:"actor not found" () )
38 | _ -> (
39- let%lwt {email} = Xrpc.parse_body req request_of_yojson in
40 let email = String.lowercase_ascii email in
41 match%lwt Data_store.get_actor_by_identifier email db with
42 | Some actor ->
···1+open Lexicons.Com_atproto_server_requestPasswordReset.Main
23let request_password_reset (actor : Data_store.Types.actor) db =
4 let did = actor.did in
···36 | None ->
37 Errors.internal_error ~msg:"actor not found" () )
38 | _ -> (
39+ let%lwt {email} = Xrpc.parse_body req input_of_yojson in
40 let email = String.lowercase_ascii email in
41 match%lwt Data_store.get_actor_by_identifier email db with
42 | Some actor ->
+4-7
pegasus/lib/api/server/reserveSigningKey.ml
···1-type request = {did: string option [@default None]}
2-[@@deriving yojson {strict= false}]
3-4-type response = {signing_key: string [@key "signingKey"]} [@@deriving yojson]
56let handler =
7 Xrpc.handler (fun {req; db; _} ->
8- let%lwt {did} = Xrpc.parse_body req request_of_yojson in
9 let%lwt existing =
10 match did with
11 | Some did when did <> "" ->
···16 match existing with
17 | Some key ->
18 Dream.json @@ Yojson.Safe.to_string
19- @@ response_to_yojson {signing_key= key.key_did}
20 | None ->
21 let privkey, pubkey = Kleidos.K256.generate_keypair () in
22 let key_did = Kleidos.K256.pubkey_to_did_key pubkey in
···25 Data_store.create_reserved_key ~key_did ~did ~private_key db
26 in
27 Dream.json @@ Yojson.Safe.to_string
28- @@ response_to_yojson {signing_key= key_did} )
···1+open Lexicons.Com_atproto_server_reserveSigningKey.Main
00023let handler =
4 Xrpc.handler (fun {req; db; _} ->
5+ let%lwt {did} = Xrpc.parse_body req input_of_yojson in
6 let%lwt existing =
7 match did with
8 | Some did when did <> "" ->
···13 match existing with
14 | Some key ->
15 Dream.json @@ Yojson.Safe.to_string
16+ @@ output_to_yojson {signing_key= key.key_did}
17 | None ->
18 let privkey, pubkey = Kleidos.K256.generate_keypair () in
19 let key_did = Kleidos.K256.pubkey_to_did_key pubkey in
···22 Data_store.create_reserved_key ~key_did ~did ~private_key db
23 in
24 Dream.json @@ Yojson.Safe.to_string
25+ @@ output_to_yojson {signing_key= key_did} )
+2-3
pegasus/lib/api/server/resetPassword.ml
···1-type request = {token: string; password: string}
2-[@@deriving yojson {strict= false}]
34type reset_password_error = InvalidToken | ExpiredToken
5···27 ; calc_key= None
28 ; calc_points= None } ]
29 (fun {req; db; _} ->
30- let%lwt {token; password} = Xrpc.parse_body req request_of_yojson in
31 match%lwt reset_password ~token ~password db with
32 | Ok did ->
33 Dream.log "password reset completed for %s" did ;
···1+open Lexicons.Com_atproto_server_resetPassword.Main
023type reset_password_error = InvalidToken | ExpiredToken
4···26 ; calc_key= None
27 ; calc_points= None } ]
28 (fun {req; db; _} ->
29+ let%lwt {token; password} = Xrpc.parse_body req input_of_yojson in
30 match%lwt reset_password ~token ~password db with
31 | Ok did ->
32 Dream.log "password reset completed for %s" did ;
+2-6
pegasus/lib/api/server/updateEmail.ml
···1-type request =
2- { email: string
3- ; email_auth_factor: bool option [@key "emailAuthFactor"] [@default None]
4- ; token: string option [@default None] }
5-[@@deriving yojson {strict= false}]
67type update_email_error =
8 | TokenRequired
···46 Auth.assert_account_scope auth ~attr:Oauth.Scopes.Email
47 ~action:Oauth.Scopes.Manage ;
48 let did = Auth.get_authed_did_exn auth in
49- let%lwt {email; token; _} = Xrpc.parse_body req request_of_yojson in
50 let email = String.lowercase_ascii email in
51 match%lwt Data_store.get_actor_by_identifier did db with
52 | None ->
···1+open Lexicons.Com_atproto_server_updateEmail.Main
000023type update_email_error =
4 | TokenRequired
···42 Auth.assert_account_scope auth ~attr:Oauth.Scopes.Email
43 ~action:Oauth.Scopes.Manage ;
44 let did = Auth.get_authed_did_exn auth in
45+ let%lwt {email; token; _} = Xrpc.parse_body req input_of_yojson in
46 let email = String.lowercase_ascii email in
47 match%lwt Data_store.get_actor_by_identifier did db with
48 | None ->
+2-2
pegasus/lib/api/sync/getBlob.ml
···1-type query = {did: string; cid: string} [@@deriving yojson {strict= false}]
23let handler =
4 Xrpc.handler (fun ctx ->
5- let {did; cid} = Xrpc.parse_query ctx.req query_of_yojson in
6 let cid_parsed = Cid.as_cid cid in
7 let%lwt {db; _} = Repository.load did ~ensure_active:true in
8 let%lwt blob_meta = User_store.get_blob_metadata db cid_parsed in
···1+open Lexicons.Com_atproto_sync_getBlob.Main
23let handler =
4 Xrpc.handler (fun ctx ->
5+ let {did; cid} = Xrpc.parse_query ctx.req params_of_yojson in
6 let cid_parsed = Cid.as_cid cid in
7 let%lwt {db; _} = Repository.load did ~ensure_active:true in
8 let%lwt blob_meta = User_store.get_blob_metadata db cid_parsed in
+2-3
pegasus/lib/api/sync/getBlocks.ml
···1-type query = {did: string; cids: string list}
2-[@@deriving yojson {strict= false}]
34let handler =
5 Xrpc.handler (fun ctx ->
6- let {did; cids} : query = Xrpc.parse_query ctx.req query_of_yojson in
7 let%lwt {db; commit; _} = Repository.load did ~ensure_active:true in
8 let commit_cid, commit_signed = Option.get commit in
9 let commit_block =
···1+open Lexicons.Com_atproto_sync_getBlocks.Main
023let handler =
4 Xrpc.handler (fun ctx ->
5+ let {did; cids} = Xrpc.parse_query ctx.req params_of_yojson in
6 let%lwt {db; commit; _} = Repository.load did ~ensure_active:true in
7 let commit_cid, commit_signed = Option.get commit in
8 let commit_block =
+3-5
pegasus/lib/api/sync/getLatestCommit.ml
···1-type query = {did: string} [@@deriving yojson {strict= false}]
2-3-type response = {cid: string; rev: string} [@@deriving yojson]
45let handler =
6 Xrpc.handler (fun ctx ->
7- let {did} : query = Xrpc.parse_query ctx.req query_of_yojson in
8 match%lwt Repository.load did ~ensure_active:true with
9 | {commit= Some (cid, {rev; _}); _} ->
10 let cid = Cid.to_string cid in
11- Dream.json @@ Yojson.Safe.to_string @@ response_to_yojson {cid; rev}
12 | _ ->
13 failwith ("couldn't resolve commit for " ^ did) )
···1+open Lexicons.Com_atproto_sync_getLatestCommit.Main
0023let handler =
4 Xrpc.handler (fun ctx ->
5+ let {did} = Xrpc.parse_query ctx.req params_of_yojson in
6 match%lwt Repository.load did ~ensure_active:true with
7 | {commit= Some (cid, {rev; _}); _} ->
8 let cid = Cid.to_string cid in
9+ Dream.json @@ Yojson.Safe.to_string @@ output_to_yojson {cid; rev}
10 | _ ->
11 failwith ("couldn't resolve commit for " ^ did) )
+3-4
pegasus/lib/api/sync/getRecord.ml
···1module Mst = Mist.Mst.Make (User_store)
23-type query = {did: string; collection: string; rkey: string}
4-[@@deriving yojson {strict= false}]
56let handler =
7 Xrpc.handler (fun ctx ->
8- let {did; collection; rkey} : query =
9- Xrpc.parse_query ctx.req query_of_yojson
10 in
11 let path = collection ^ "/" ^ rkey in
12 let%lwt repo = Repository.load did ~ensure_active:true in
···1module Mst = Mist.Mst.Make (User_store)
23+open Lexicons.Com_atproto_sync_getRecord.Main
045let handler =
6 Xrpc.handler (fun ctx ->
7+ let {did; collection; rkey} =
8+ Xrpc.parse_query ctx.req params_of_yojson
9 in
10 let path = collection ^ "/" ^ rkey in
11 let%lwt repo = Repository.load did ~ensure_active:true in
+2-2
pegasus/lib/api/sync/getRepo.ml
···1-type query = {did: string} [@@deriving yojson {strict= false}]
23let handler =
4 Xrpc.handler (fun ctx ->
5- let {did} : query = Xrpc.parse_query ctx.req query_of_yojson in
6 let%lwt repo = Repository.load did ~ensure_active:true in
7 let%lwt car_stream = Repository.export_car repo in
8 Dream.stream
···1+open Lexicons.Com_atproto_sync_getRepo.Main
23let handler =
4 Xrpc.handler (fun ctx ->
5+ let {did; _} = Xrpc.parse_query ctx.req params_of_yojson in
6 let%lwt repo = Repository.load did ~ensure_active:true in
7 let%lwt car_stream = Repository.export_car repo in
8 Dream.stream
+3-7
pegasus/lib/api/sync/getRepoStatus.ml
···1-type query = {did: string} [@@deriving yojson {strict= false}]
2-3-type response =
4- {did: string; active: bool; status: string option; rev: string option}
5-[@@deriving yojson]
67let handler =
8 Xrpc.handler (fun ctx ->
9- let {did} : query = Xrpc.parse_query ctx.req query_of_yojson in
10 let%lwt actor =
11 match%lwt Data_store.get_actor_by_identifier did ctx.db with
12 | Some actor ->
···31 (true, None, Some commit.rev)
32 in
33 Dream.json @@ Yojson.Safe.to_string
34- @@ response_to_yojson {did; active; status; rev} )
···1+open Lexicons.Com_atproto_sync_getRepoStatus.Main
000023let handler =
4 Xrpc.handler (fun ctx ->
5+ let {did} : params = Xrpc.parse_query ctx.req params_of_yojson in
6 let%lwt actor =
7 match%lwt Data_store.get_actor_by_identifier did ctx.db with
8 | Some actor ->
···27 (true, None, Some commit.rev)
28 in
29 Dream.json @@ Yojson.Safe.to_string
30+ @@ output_to_yojson {did; active; status; rev} )
···1+(* generated from app.bsky.actor.getPreferences *)
2+3+(** Get private preferences attached to the current account. Expected use is synchronization between multiple devices, and import/export during account migration. Requires auth. *)
4+module Main = struct
5+ let nsid = "app.bsky.actor.getPreferences"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type output =
11+ {
12+ preferences: App_bsky_actor_defs.preferences;
13+ }
14+[@@deriving yojson {strict= false}]
15+16+ let call
17+ (client : Hermes.client) : output Lwt.t =
18+ Hermes.query client nsid (`Assoc []) output_of_yojson
19+end
20+
+22
pegasus/lib/lexicons/app_bsky_actor_getProfile.ml
···0000000000000000000000
···1+(* generated from app.bsky.actor.getProfile *)
2+3+(** Get detailed profile view of an actor. Does not require auth, but contains relevant metadata with auth. *)
4+module Main = struct
5+ let nsid = "app.bsky.actor.getProfile"
6+7+ type params =
8+ {
9+ actor: string;
10+ }
11+[@@deriving yojson {strict= false}]
12+13+ type output = App_bsky_actor_defs.profile_view_detailed
14+[@@deriving yojson {strict= false}]
15+16+ let call
17+ ~actor
18+ (client : Hermes.client) : output Lwt.t =
19+ let params : params = {actor} in
20+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
21+end
22+
···1+(* generated from app.bsky.actor.putPreferences *)
2+3+(** Set the private preferences attached to the account. *)
4+module Main = struct
5+ let nsid = "app.bsky.actor.putPreferences"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ preferences: App_bsky_actor_defs.preferences;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~preferences
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({preferences} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from app.bsky.bookmark.deleteBookmark *)
2+3+(** Deletes a private bookmark for the specified record. Currently, only `app.bsky.feed.post` records are supported. Requires authentication. *)
4+module Main = struct
5+ let nsid = "app.bsky.bookmark.deleteBookmark"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ uri: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~uri
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({uri} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from app.bsky.contact.dismissMatch *)
2+3+(** Removes a match that was found via contact import. It shouldn't appear again if the same contact is re-imported. Requires authentication. *)
4+module Main = struct
5+ let nsid = "app.bsky.contact.dismissMatch"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ subject: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+let output_of_yojson _ = Ok ()
18+let output_to_yojson () = `Assoc []
19+20+ let call
21+ ~subject
22+ (client : Hermes.client) : output Lwt.t =
23+ let params = () in
24+ let input = Some ({subject} |> input_to_yojson) in
25+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
26+end
27+
···1+(* generated from app.bsky.contact.removeData *)
2+3+(** Removes all stored hashes used for contact matching, existing matches, and sync status. Requires authentication. *)
4+module Main = struct
5+ let nsid = "app.bsky.contact.removeData"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input = unit
11+ let input_of_yojson _ = Ok ()
12+ let input_to_yojson () = `Assoc []
13+14+ type output = unit
15+let output_of_yojson _ = Ok ()
16+let output_to_yojson () = `Assoc []
17+18+ let call
19+ (client : Hermes.client) : output Lwt.t =
20+ let params = () in
21+ let input = Some (input_to_yojson ()) in
22+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
23+end
24+
···1+(* generated from app.bsky.contact.startPhoneVerification *)
2+3+(** 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. *)
4+module Main = struct
5+ let nsid = "app.bsky.contact.startPhoneVerification"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ phone: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+let output_of_yojson _ = Ok ()
18+let output_to_yojson () = `Assoc []
19+20+ let call
21+ ~phone
22+ (client : Hermes.client) : output Lwt.t =
23+ let params = () in
24+ let input = Some ({phone} |> input_to_yojson) in
25+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
26+end
27+
···1+(* generated from app.bsky.feed.getPostThread *)
2+3+(** Get posts in a thread. Does not require auth, but additional metadata and filtering will be applied for authed requests. *)
4+module Main = struct
5+ let nsid = "app.bsky.feed.getPostThread"
6+7+ type params =
8+ {
9+ uri: string;
10+ depth: int option [@default None];
11+ parent_height: int option [@key "parentHeight"] [@default None];
12+ }
13+[@@deriving yojson {strict= false}]
14+15+ type thread =
16+ | ThreadViewPost of App_bsky_feed_defs.thread_view_post
17+ | NotFoundPost of App_bsky_feed_defs.not_found_post
18+ | BlockedPost of App_bsky_feed_defs.blocked_post
19+ | Unknown of Yojson.Safe.t
20+21+let thread_of_yojson json =
22+ let open Yojson.Safe.Util in
23+ try
24+ match json |> member "$type" |> to_string with
25+ | "app.bsky.feed.defs#threadViewPost" ->
26+ (match App_bsky_feed_defs.thread_view_post_of_yojson json with
27+ | Ok v -> Ok (ThreadViewPost v)
28+ | Error e -> Error e)
29+ | "app.bsky.feed.defs#notFoundPost" ->
30+ (match App_bsky_feed_defs.not_found_post_of_yojson json with
31+ | Ok v -> Ok (NotFoundPost v)
32+ | Error e -> Error e)
33+ | "app.bsky.feed.defs#blockedPost" ->
34+ (match App_bsky_feed_defs.blocked_post_of_yojson json with
35+ | Ok v -> Ok (BlockedPost v)
36+ | Error e -> Error e)
37+ | _ -> Ok (Unknown json)
38+ with _ -> Error "failed to parse union"
39+40+let thread_to_yojson = function
41+ | ThreadViewPost v ->
42+ (match App_bsky_feed_defs.thread_view_post_to_yojson v with
43+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#threadViewPost") :: fields)
44+ | other -> other)
45+ | NotFoundPost v ->
46+ (match App_bsky_feed_defs.not_found_post_to_yojson v with
47+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#notFoundPost") :: fields)
48+ | other -> other)
49+ | BlockedPost v ->
50+ (match App_bsky_feed_defs.blocked_post_to_yojson v with
51+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.feed.defs#blockedPost") :: fields)
52+ | other -> other)
53+ | Unknown j -> j
54+55+type output =
56+ {
57+ thread: thread;
58+ threadgate: App_bsky_feed_defs.threadgate_view option [@default None];
59+ }
60+[@@deriving yojson {strict= false}]
61+62+ let call
63+ ~uri
64+ ?depth
65+ ?parent_height
66+ (client : Hermes.client) : output Lwt.t =
67+ let params : params = {uri; depth; parent_height} in
68+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
69+end
70+
+25
pegasus/lib/lexicons/app_bsky_feed_getPosts.ml
···0000000000000000000000000
···1+(* generated from app.bsky.feed.getPosts *)
2+3+(** Gets post views for a specified list of posts (by AT-URI). This is sometimes referred to as 'hydrating' a 'feed skeleton'. *)
4+module Main = struct
5+ let nsid = "app.bsky.feed.getPosts"
6+7+ type params =
8+ {
9+ uris: string list;
10+ }
11+[@@deriving yojson {strict= false}]
12+13+ type output =
14+ {
15+ posts: App_bsky_feed_defs.post_view list;
16+ }
17+[@@deriving yojson {strict= false}]
18+19+ let call
20+ ~uris
21+ (client : Hermes.client) : output Lwt.t =
22+ let params : params = {uris} in
23+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
24+end
25+
+34
pegasus/lib/lexicons/app_bsky_feed_getQuotes.ml
···0000000000000000000000000000000000
···1+(* generated from app.bsky.feed.getQuotes *)
2+3+(** Get a list of quotes for a given post. *)
4+module Main = struct
5+ let nsid = "app.bsky.feed.getQuotes"
6+7+ type params =
8+ {
9+ uri: string;
10+ cid: string option [@default None];
11+ limit: int option [@default None];
12+ cursor: string option [@default None];
13+ }
14+[@@deriving yojson {strict= false}]
15+16+ type output =
17+ {
18+ uri: string;
19+ cid: string option [@default None];
20+ cursor: string option [@default None];
21+ posts: App_bsky_feed_defs.post_view list;
22+ }
23+[@@deriving yojson {strict= false}]
24+25+ let call
26+ ~uri
27+ ?cid
28+ ?limit
29+ ?cursor
30+ (client : Hermes.client) : output Lwt.t =
31+ let params : params = {uri; cid; limit; cursor} in
32+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
33+end
34+
···1+(* generated from app.bsky.feed.sendInteractions *)
2+3+(** Send information about interactions with feed items back to the feed generator that served them. *)
4+module Main = struct
5+ let nsid = "app.bsky.feed.sendInteractions"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ interactions: App_bsky_feed_defs.interaction list;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+let output_of_yojson _ = Ok ()
18+let output_to_yojson () = `Assoc []
19+20+ let call
21+ ~interactions
22+ (client : Hermes.client) : output Lwt.t =
23+ let params = () in
24+ let input = Some ({interactions} |> input_to_yojson) in
25+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
26+end
27+
···1+(* generated from app.bsky.graph.muteActor *)
2+3+(** Creates a mute relationship for the specified account. Mutes are private in Bluesky. Requires auth. *)
4+module Main = struct
5+ let nsid = "app.bsky.graph.muteActor"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ actor: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~actor
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({actor} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from app.bsky.graph.muteActorList *)
2+3+(** Creates a mute relationship for the specified list of accounts. Mutes are private in Bluesky. Requires auth. *)
4+module Main = struct
5+ let nsid = "app.bsky.graph.muteActorList"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ list: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~list
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({list} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
+26
pegasus/lib/lexicons/app_bsky_graph_muteThread.ml
···00000000000000000000000000
···1+(* generated from app.bsky.graph.muteThread *)
2+3+(** Mutes a thread preventing notifications from the thread and any of its children. Mutes are private in Bluesky. Requires auth. *)
4+module Main = struct
5+ let nsid = "app.bsky.graph.muteThread"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ root: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~root
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({root} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from app.bsky.notification.unregisterPush *)
2+3+(** 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. *)
4+module Main = struct
5+ let nsid = "app.bsky.notification.unregisterPush"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ service_did: string [@key "serviceDid"];
13+ token: string;
14+ platform: string;
15+ app_id: string [@key "appId"];
16+ }
17+ [@@deriving yojson {strict= false}]
18+19+ type output = unit
20+ let output_of_yojson _ = Ok ()
21+22+ let call
23+ ~service_did
24+ ~token
25+ ~platform
26+ ~app_id
27+ (client : Hermes.client) : output Lwt.t =
28+ let params = () in
29+ let input = Some ({service_did; token; platform; app_id} |> input_to_yojson) in
30+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
31+end
32+
···1+(* generated from app.bsky.notification.updateSeen *)
2+3+(** Notify server that the requesting account has seen notifications. Requires auth. *)
4+module Main = struct
5+ let nsid = "app.bsky.notification.updateSeen"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ seen_at: string [@key "seenAt"];
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~seen_at
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({seen_at} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from app.bsky.unspecced.getAgeAssuranceState *)
2+3+(** 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. *)
4+module Main = struct
5+ let nsid = "app.bsky.unspecced.getAgeAssuranceState"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type output = App_bsky_unspecced_defs.age_assurance_state
11+[@@deriving yojson {strict= false}]
12+13+ let call
14+ (client : Hermes.client) : output Lwt.t =
15+ Hermes.query client nsid (`Assoc []) output_of_yojson
16+end
17+
···1+(* generated from app.bsky.unspecced.getPostThreadOtherV2 *)
2+3+type value =
4+ | ThreadItemPost of App_bsky_unspecced_defs.thread_item_post
5+ | Unknown of Yojson.Safe.t
6+7+let value_of_yojson json =
8+ let open Yojson.Safe.Util in
9+ try
10+ match json |> member "$type" |> to_string with
11+ | "app.bsky.unspecced.defs#threadItemPost" ->
12+ (match App_bsky_unspecced_defs.thread_item_post_of_yojson json with
13+ | Ok v -> Ok (ThreadItemPost v)
14+ | Error e -> Error e)
15+ | _ -> Ok (Unknown json)
16+ with _ -> Error "failed to parse union"
17+18+let value_to_yojson = function
19+ | ThreadItemPost v ->
20+ (match App_bsky_unspecced_defs.thread_item_post_to_yojson v with
21+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.unspecced.defs#threadItemPost") :: fields)
22+ | other -> other)
23+ | Unknown j -> j
24+25+type thread_item =
26+ {
27+ uri: string;
28+ depth: int;
29+ value: value;
30+ }
31+[@@deriving yojson {strict= false}]
32+33+(** (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. *)
34+module Main = struct
35+ let nsid = "app.bsky.unspecced.getPostThreadOtherV2"
36+37+ type params =
38+ {
39+ anchor: string;
40+ }
41+[@@deriving yojson {strict= false}]
42+43+ type output =
44+ {
45+ thread: thread_item list;
46+ }
47+[@@deriving yojson {strict= false}]
48+49+ let call
50+ ~anchor
51+ (client : Hermes.client) : output Lwt.t =
52+ let params : params = {anchor} in
53+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
54+end
55+
···1+(* generated from app.bsky.unspecced.getPostThreadV2 *)
2+3+type value =
4+ | ThreadItemPost of App_bsky_unspecced_defs.thread_item_post
5+ | ThreadItemNoUnauthenticated of App_bsky_unspecced_defs.thread_item_no_unauthenticated
6+ | ThreadItemNotFound of App_bsky_unspecced_defs.thread_item_not_found
7+ | ThreadItemBlocked of App_bsky_unspecced_defs.thread_item_blocked
8+ | Unknown of Yojson.Safe.t
9+10+let value_of_yojson json =
11+ let open Yojson.Safe.Util in
12+ try
13+ match json |> member "$type" |> to_string with
14+ | "app.bsky.unspecced.defs#threadItemPost" ->
15+ (match App_bsky_unspecced_defs.thread_item_post_of_yojson json with
16+ | Ok v -> Ok (ThreadItemPost v)
17+ | Error e -> Error e)
18+ | "app.bsky.unspecced.defs#threadItemNoUnauthenticated" ->
19+ (match App_bsky_unspecced_defs.thread_item_no_unauthenticated_of_yojson json with
20+ | Ok v -> Ok (ThreadItemNoUnauthenticated v)
21+ | Error e -> Error e)
22+ | "app.bsky.unspecced.defs#threadItemNotFound" ->
23+ (match App_bsky_unspecced_defs.thread_item_not_found_of_yojson json with
24+ | Ok v -> Ok (ThreadItemNotFound v)
25+ | Error e -> Error e)
26+ | "app.bsky.unspecced.defs#threadItemBlocked" ->
27+ (match App_bsky_unspecced_defs.thread_item_blocked_of_yojson json with
28+ | Ok v -> Ok (ThreadItemBlocked v)
29+ | Error e -> Error e)
30+ | _ -> Ok (Unknown json)
31+ with _ -> Error "failed to parse union"
32+33+let value_to_yojson = function
34+ | ThreadItemPost v ->
35+ (match App_bsky_unspecced_defs.thread_item_post_to_yojson v with
36+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.unspecced.defs#threadItemPost") :: fields)
37+ | other -> other)
38+ | ThreadItemNoUnauthenticated v ->
39+ (match App_bsky_unspecced_defs.thread_item_no_unauthenticated_to_yojson v with
40+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.unspecced.defs#threadItemNoUnauthenticated") :: fields)
41+ | other -> other)
42+ | ThreadItemNotFound v ->
43+ (match App_bsky_unspecced_defs.thread_item_not_found_to_yojson v with
44+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.unspecced.defs#threadItemNotFound") :: fields)
45+ | other -> other)
46+ | ThreadItemBlocked v ->
47+ (match App_bsky_unspecced_defs.thread_item_blocked_to_yojson v with
48+ | `Assoc fields -> `Assoc (("$type", `String "app.bsky.unspecced.defs#threadItemBlocked") :: fields)
49+ | other -> other)
50+ | Unknown j -> j
51+52+type thread_item =
53+ {
54+ uri: string;
55+ depth: int;
56+ value: value;
57+ }
58+[@@deriving yojson {strict= false}]
59+60+(** (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. *)
61+module Main = struct
62+ let nsid = "app.bsky.unspecced.getPostThreadV2"
63+64+ type params =
65+ {
66+ anchor: string;
67+ above: bool option [@default None];
68+ below: int option [@default None];
69+ branching_factor: int option [@key "branchingFactor"] [@default None];
70+ sort: string option [@default None];
71+ }
72+[@@deriving yojson {strict= false}]
73+74+ type output =
75+ {
76+ thread: thread_item list;
77+ threadgate: App_bsky_feed_defs.threadgate_view option [@default None];
78+ has_other_replies: bool [@key "hasOtherReplies"];
79+ }
80+[@@deriving yojson {strict= false}]
81+82+ let call
83+ ~anchor
84+ ?above
85+ ?below
86+ ?branching_factor
87+ ?sort
88+ (client : Hermes.client) : output Lwt.t =
89+ let params : params = {anchor; above; below; branching_factor; sort} in
90+ Hermes.query client nsid (params_to_yojson params) output_of_yojson
91+end
92+
···1+(* generated from app.bsky.unspecced.initAgeAssurance *)
2+3+(** Initiate age assurance for an account. This is a one-time action that will start the process of verifying the user's age. *)
4+module Main = struct
5+ let nsid = "app.bsky.unspecced.initAgeAssurance"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ email: string;
13+ language: string;
14+ country_code: string [@key "countryCode"];
15+ }
16+ [@@deriving yojson {strict= false}]
17+18+ type output = App_bsky_unspecced_defs.age_assurance_state
19+[@@deriving yojson {strict= false}]
20+21+ let call
22+ ~email
23+ ~language
24+ ~country_code
25+ (client : Hermes.client) : output Lwt.t =
26+ let params = () in
27+ let input = Some ({email; language; country_code} |> input_to_yojson) in
28+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
29+end
30+
···1+(* generated from com.atproto.admin.deleteAccount *)
2+3+(** Delete a user account as an administrator. *)
4+module Main = struct
5+ let nsid = "com.atproto.admin.deleteAccount"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ did: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~did
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({did} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from com.atproto.admin.disableInviteCodes *)
2+3+(** Disable some set of codes and/or all codes associated with a set of users. *)
4+module Main = struct
5+ let nsid = "com.atproto.admin.disableInviteCodes"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ codes: string list option [@default None];
13+ accounts: string list option [@default None];
14+ }
15+ [@@deriving yojson {strict= false}]
16+17+ type output = unit
18+ let output_of_yojson _ = Ok ()
19+20+ let call
21+ ?codes
22+ ?accounts
23+ (client : Hermes.client) : output Lwt.t =
24+ let params = () in
25+ let input = Some ({codes; accounts} |> input_to_yojson) in
26+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
27+end
28+
···1+(* generated from com.atproto.admin.updateAccountPassword *)
2+3+(** Update the password for a user account as an administrator. *)
4+module Main = struct
5+ let nsid = "com.atproto.admin.updateAccountPassword"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ did: string;
13+ password: string;
14+ }
15+ [@@deriving yojson {strict= false}]
16+17+ type output = unit
18+ let output_of_yojson _ = Ok ()
19+20+ let call
21+ ~did
22+ ~password
23+ (client : Hermes.client) : output Lwt.t =
24+ let params = () in
25+ let input = Some ({did; password} |> input_to_yojson) in
26+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
27+end
28+
···1+(* generated from com.atproto.identity.getRecommendedDidCredentials *)
2+3+(** Describe the credentials that should be included in the DID doc of an account that is migrating to this service. *)
4+module Main = struct
5+ let nsid = "com.atproto.identity.getRecommendedDidCredentials"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type output =
11+ {
12+ rotation_keys: string list option [@key "rotationKeys"] [@default None];
13+ also_known_as: string list option [@key "alsoKnownAs"] [@default None];
14+ verification_methods: Yojson.Safe.t option [@key "verificationMethods"] [@default None];
15+ services: Yojson.Safe.t option [@default None];
16+ }
17+[@@deriving yojson {strict= false}]
18+19+ let call
20+ (client : Hermes.client) : output Lwt.t =
21+ Hermes.query client nsid (`Assoc []) output_of_yojson
22+end
23+
···1+(* generated from com.atproto.identity.refreshIdentity *)
2+3+(** 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. *)
4+module Main = struct
5+ let nsid = "com.atproto.identity.refreshIdentity"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ identifier: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = Com_atproto_identity_defs.identity_info
17+[@@deriving yojson {strict= false}]
18+19+ let call
20+ ~identifier
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({identifier} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from com.atproto.identity.requestPlcOperationSignature *)
2+3+(** Request an email with a code to in order to request a signed PLC operation. Requires Auth. *)
4+module Main = struct
5+ let nsid = "com.atproto.identity.requestPlcOperationSignature"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type output = unit
11+ let output_of_yojson _ = Ok ()
12+13+ let call
14+ (client : Hermes.client) : output Lwt.t =
15+ let params = () in
16+ let input = None in
17+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
18+end
19+
···1+(* generated from com.atproto.identity.submitPlcOperation *)
2+3+(** 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 *)
4+module Main = struct
5+ let nsid = "com.atproto.identity.submitPlcOperation"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ operation: Yojson.Safe.t;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~operation
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({operation} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from com.atproto.identity.updateHandle *)
2+3+(** Updates the current account's handle. Verifies handle validity, and updates did:plc document if necessary. Implemented by PDS, and requires auth. *)
4+module Main = struct
5+ let nsid = "com.atproto.identity.updateHandle"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ handle: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~handle
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({handle} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from com.atproto.moderation.defs *)
2+3+(** String type with known values *)
4+type reason_type = string
5+let reason_type_of_yojson = function
6+ | `String s -> Ok s
7+ | _ -> Error "reason_type: expected string"
8+let reason_type_to_yojson s = `String s
9+10+(** Spam: frequent unwanted promotion, replies, mentions. Prefer new lexicon definition `tools.ozone.report.defs#reasonMisleadingSpam`. *)
11+let reason_spam = "com.atproto.moderation.defs#reasonSpam"
12+13+(** Direct violation of server rules, laws, terms of service. Prefer new lexicon definition `tools.ozone.report.defs#reasonRuleOther`. *)
14+let reason_violation = "com.atproto.moderation.defs#reasonViolation"
15+16+(** Misleading identity, affiliation, or content. Prefer new lexicon definition `tools.ozone.report.defs#reasonMisleadingOther`. *)
17+let reason_misleading = "com.atproto.moderation.defs#reasonMisleading"
18+19+(** Unwanted or mislabeled sexual content. Prefer new lexicon definition `tools.ozone.report.defs#reasonSexualUnlabeled`. *)
20+let reason_sexual = "com.atproto.moderation.defs#reasonSexual"
21+22+(** Rude, harassing, explicit, or otherwise unwelcoming behavior. Prefer new lexicon definition `tools.ozone.report.defs#reasonHarassmentOther`. *)
23+let reason_rude = "com.atproto.moderation.defs#reasonRude"
24+25+(** Reports not falling under another report category. Prefer new lexicon definition `tools.ozone.report.defs#reasonOther`. *)
26+let reason_other = "com.atproto.moderation.defs#reasonOther"
27+28+(** Appeal a previously taken moderation action *)
29+let reason_appeal = "com.atproto.moderation.defs#reasonAppeal"
30+31+(** String type with known values: Tag describing a type of subject that might be reported. *)
32+type subject_type = string
33+let subject_type_of_yojson = function
34+ | `String s -> Ok s
35+ | _ -> Error "subject_type: expected string"
36+let subject_type_to_yojson s = `String s
37+
···1+(* generated from com.atproto.repo.importRepo *)
2+3+(** Import a repo in the form of a CAR file. Requires Content-Length HTTP header to be set. *)
4+module Main = struct
5+ let nsid = "com.atproto.repo.importRepo"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type output = unit
11+ let output_of_yojson _ = Ok ()
12+13+ let call
14+ ?input
15+ (client : Hermes.client) : output Lwt.t =
16+ let params = () in
17+ let open Lwt.Syntax in
18+ let* _ = Hermes.procedure_bytes client nsid (params_to_yojson params) input ~content_type:"application/vnd.ipld.car" in
19+ Lwt.return ()
20+end
21+
···1+(* generated from com.atproto.repo.uploadBlob *)
2+3+(** 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. *)
4+module Main = struct
5+ let nsid = "com.atproto.repo.uploadBlob"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type output =
11+ {
12+ blob: Hermes.blob;
13+ }
14+[@@deriving yojson {strict= false}]
15+16+ let call
17+ ?input
18+ (client : Hermes.client) : output Lwt.t =
19+ let params = () in
20+ Hermes.procedure_blob client nsid (params_to_yojson params) (Bytes.of_string (Option.value input ~default:"")) ~content_type:"*/*" output_of_yojson
21+end
22+
···1+(* generated from com.atproto.server.activateAccount *)
2+3+(** Activates a currently deactivated account. Used to finalize account migration after the account's repo is imported and identity is setup. *)
4+module Main = struct
5+ let nsid = "com.atproto.server.activateAccount"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type output = unit
11+ let output_of_yojson _ = Ok ()
12+13+ let call
14+ (client : Hermes.client) : output Lwt.t =
15+ let params = () in
16+ let input = None in
17+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
18+end
19+
···1+(* generated from com.atproto.server.checkAccountStatus *)
2+3+(** 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. *)
4+module Main = struct
5+ let nsid = "com.atproto.server.checkAccountStatus"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type output =
11+ {
12+ activated: bool;
13+ valid_did: bool [@key "validDid"];
14+ repo_commit: string [@key "repoCommit"];
15+ repo_rev: string [@key "repoRev"];
16+ repo_blocks: int [@key "repoBlocks"];
17+ indexed_records: int [@key "indexedRecords"];
18+ private_state_values: int [@key "privateStateValues"];
19+ expected_blobs: int [@key "expectedBlobs"];
20+ imported_blobs: int [@key "importedBlobs"];
21+ }
22+[@@deriving yojson {strict= false}]
23+24+ let call
25+ (client : Hermes.client) : output Lwt.t =
26+ Hermes.query client nsid (`Assoc []) output_of_yojson
27+end
28+
···1+(* generated from com.atproto.server.deactivateAccount *)
2+3+(** 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. *)
4+module Main = struct
5+ let nsid = "com.atproto.server.deactivateAccount"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ delete_after: string option [@key "deleteAfter"] [@default None];
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ?delete_after
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({delete_after} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from com.atproto.server.deleteAccount *)
2+3+(** Delete an actor's account with a token and password. Can only be called after requesting a deletion token. Requires auth. *)
4+module Main = struct
5+ let nsid = "com.atproto.server.deleteAccount"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ did: string;
13+ password: string;
14+ token: string;
15+ }
16+ [@@deriving yojson {strict= false}]
17+18+ type output = unit
19+ let output_of_yojson _ = Ok ()
20+21+ let call
22+ ~did
23+ ~password
24+ ~token
25+ (client : Hermes.client) : output Lwt.t =
26+ let params = () in
27+ let input = Some ({did; password; token} |> input_to_yojson) in
28+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
29+end
30+
···1+(* generated from com.atproto.server.deleteSession *)
2+3+(** Delete the current session. Requires auth using the 'refreshJwt' (not the 'accessJwt'). *)
4+module Main = struct
5+ let nsid = "com.atproto.server.deleteSession"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type output = unit
11+ let output_of_yojson _ = Ok ()
12+13+ let call
14+ (client : Hermes.client) : output Lwt.t =
15+ let params = () in
16+ let input = None in
17+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
18+end
19+
···1+(* generated from com.atproto.server.requestAccountDelete *)
2+3+(** Initiate a user account deletion via email. *)
4+module Main = struct
5+ let nsid = "com.atproto.server.requestAccountDelete"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type output = unit
11+ let output_of_yojson _ = Ok ()
12+13+ let call
14+ (client : Hermes.client) : output Lwt.t =
15+ let params = () in
16+ let input = None in
17+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
18+end
19+
···1+(* generated from com.atproto.server.requestEmailConfirmation *)
2+3+(** Request an email with a code to confirm ownership of email. *)
4+module Main = struct
5+ let nsid = "com.atproto.server.requestEmailConfirmation"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type output = unit
11+ let output_of_yojson _ = Ok ()
12+13+ let call
14+ (client : Hermes.client) : output Lwt.t =
15+ let params = () in
16+ let input = None in
17+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
18+end
19+
···1+(* generated from com.atproto.server.reserveSigningKey *)
2+3+(** 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. *)
4+module Main = struct
5+ let nsid = "com.atproto.server.reserveSigningKey"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ did: string option [@default None];
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output =
17+ {
18+ signing_key: string [@key "signingKey"];
19+ }
20+[@@deriving yojson {strict= false}]
21+22+ let call
23+ ?did
24+ (client : Hermes.client) : output Lwt.t =
25+ let params = () in
26+ let input = Some ({did} |> input_to_yojson) in
27+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
28+end
29+
···1+(* generated from com.atproto.server.updateEmail *)
2+3+(** Update an account's email. *)
4+module Main = struct
5+ let nsid = "com.atproto.server.updateEmail"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ email: string;
13+ email_auth_factor: bool option [@key "emailAuthFactor"] [@default None];
14+ token: string option [@default None];
15+ }
16+ [@@deriving yojson {strict= false}]
17+18+ type output = unit
19+ let output_of_yojson _ = Ok ()
20+21+ let call
22+ ~email
23+ ?email_auth_factor
24+ ?token
25+ (client : Hermes.client) : output Lwt.t =
26+ let params = () in
27+ let input = Some ({email; email_auth_factor; token} |> input_to_yojson) in
28+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
29+end
30+
+9
pegasus/lib/lexicons/com_atproto_sync_defs.ml
···000000000
···1+(* generated from com.atproto.sync.defs *)
2+3+(** String type with known values *)
4+type host_status = string
5+let host_status_of_yojson = function
6+ | `String s -> Ok s
7+ | _ -> Error "host_status: expected string"
8+let host_status_to_yojson s = `String s
9+
+24
pegasus/lib/lexicons/com_atproto_sync_getBlob.ml
···000000000000000000000000
···1+(* generated from com.atproto.sync.getBlob *)
2+3+(** Get a blob associated with a given account. Returns the full blob as originally uploaded. Does not require auth; implemented by PDS. *)
4+module Main = struct
5+ let nsid = "com.atproto.sync.getBlob"
6+7+ type params =
8+ {
9+ did: string;
10+ cid: string;
11+ }
12+[@@deriving yojson {strict= false}]
13+14+ (** Raw bytes output with content type *)
15+ type output = string * string
16+17+ let call
18+ ~did
19+ ~cid
20+ (client : Hermes.client) : output Lwt.t =
21+ let params : params = {did; cid} in
22+ Hermes.query_bytes client nsid (params_to_yojson params)
23+end
24+
···1+(* generated from com.atproto.sync.getBlocks *)
2+3+(** Get data blocks from a given repo, by CID. For example, intermediate MST nodes, or records. Does not require auth; implemented by PDS. *)
4+module Main = struct
5+ let nsid = "com.atproto.sync.getBlocks"
6+7+ type params =
8+ {
9+ did: string;
10+ cids: string list;
11+ }
12+[@@deriving yojson {strict= false}]
13+14+ (** Raw bytes output with content type *)
15+ type output = string * string
16+17+ let call
18+ ~did
19+ ~cids
20+ (client : Hermes.client) : output Lwt.t =
21+ let params : params = {did; cids} in
22+ Hermes.query_bytes client nsid (params_to_yojson params)
23+end
24+
···1+(* generated from com.atproto.sync.getRecord *)
2+3+(** Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth. *)
4+module Main = struct
5+ let nsid = "com.atproto.sync.getRecord"
6+7+ type params =
8+ {
9+ did: string;
10+ collection: string;
11+ rkey: string;
12+ }
13+[@@deriving yojson {strict= false}]
14+15+ (** Raw bytes output with content type *)
16+ type output = string * string
17+18+ let call
19+ ~did
20+ ~collection
21+ ~rkey
22+ (client : Hermes.client) : output Lwt.t =
23+ let params : params = {did; collection; rkey} in
24+ Hermes.query_bytes client nsid (params_to_yojson params)
25+end
26+
+24
pegasus/lib/lexicons/com_atproto_sync_getRepo.ml
···000000000000000000000000
···1+(* generated from com.atproto.sync.getRepo *)
2+3+(** Download a repository export as CAR file. Optionally only a 'diff' since a previous revision. Does not require auth; implemented by PDS. *)
4+module Main = struct
5+ let nsid = "com.atproto.sync.getRepo"
6+7+ type params =
8+ {
9+ did: string;
10+ since: string option [@default None];
11+ }
12+[@@deriving yojson {strict= false}]
13+14+ (** Raw bytes output with content type *)
15+ type output = string * string
16+17+ let call
18+ ~did
19+ ?since
20+ (client : Hermes.client) : output Lwt.t =
21+ let params : params = {did; since} in
22+ Hermes.query_bytes client nsid (params_to_yojson params)
23+end
24+
···1+(* generated from com.atproto.sync.notifyOfUpdate *)
2+3+(** 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 *)
4+module Main = struct
5+ let nsid = "com.atproto.sync.notifyOfUpdate"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ hostname: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~hostname
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({hostname} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from com.atproto.sync.requestCrawl *)
2+3+(** Request a service to persistently crawl hosted repos. Expected use is new PDS instances declaring their existence to Relays. Does not require auth. *)
4+module Main = struct
5+ let nsid = "com.atproto.sync.requestCrawl"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ hostname: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~hostname
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({hostname} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from com.atproto.temp.requestPhoneVerification *)
2+3+(** Request a verification code to be sent to the supplied phone number *)
4+module Main = struct
5+ let nsid = "com.atproto.temp.requestPhoneVerification"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ phone_number: string [@key "phoneNumber"];
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~phone_number
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({phone_number} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+
···1+(* generated from com.atproto.temp.revokeAccountCredentials *)
2+3+(** Revoke sessions, password, and app passwords associated with account. May be resolved by a password reset. *)
4+module Main = struct
5+ let nsid = "com.atproto.temp.revokeAccountCredentials"
6+7+ type params = unit
8+ let params_to_yojson () = `Assoc []
9+10+ type input =
11+ {
12+ account: string;
13+ }
14+ [@@deriving yojson {strict= false}]
15+16+ type output = unit
17+ let output_of_yojson _ = Ok ()
18+19+ let call
20+ ~account
21+ (client : Hermes.client) : output Lwt.t =
22+ let params = () in
23+ let input = Some ({account} |> input_to_yojson) in
24+ Hermes.procedure client nsid (params_to_yojson params) input output_of_yojson
25+end
26+