···423423 (* generate output type *)
424424 ( if output_is_bytes then begin
425425 emitln out " (** raw bytes output with content type *)" ;
426426- emitln out " type output = string * string" ;
426426+ emitln out " type output = bytes * string" ;
427427 emit_newline out
428428 end
429429 else
···564564 (* generate output type *)
565565 ( if output_is_bytes then begin
566566 emitln out " (** raw bytes output with content type *)" ;
567567- emitln out " type output = (string * string) option" ;
567567+ emitln out " type output = (bytes * string) option" ;
568568 emit_newline out
569569 end
570570 else
···281281Endpoints with non-JSON encoding are automatically detected and handled:
282282283283- **Queries with bytes output** (e.g., `com.atproto.sync.getBlob` with `encoding: "*/*"`):
284284- - Output type is `string * string` (data, content_type)
284284+ - Output type is `bytes * string` (data, content_type)
285285 - Generated code uses `Hermes.query_bytes`
286286287287- **Procedures with bytes input**:
+12-10
hermes/lib/client.ml
···3636 -> (Yojson.Safe.t -> ('a, string) result)
3737 -> 'a Lwt.t
38383939- val query_bytes : t -> string -> Yojson.Safe.t -> (string * string) Lwt.t
3939+ val query_bytes : t -> string -> Yojson.Safe.t -> (bytes * string) Lwt.t
40404141 val procedure_bytes :
4242 t
4343 -> string
4444 -> Yojson.Safe.t
4545- -> string option
4545+ -> bytes option
4646 -> content_type:string
4747- -> (string * string) option Lwt.t
4747+ -> (bytes * string) option Lwt.t
48484949 val procedure_blob :
5050 t
···229229 Types.raise_xrpc_error ~status payload
230230231231 let query_bytes (t : t) (nsid : string) (params : Yojson.Safe.t) :
232232- (string * string) Lwt.t =
232232+ (bytes * string) Lwt.t =
233233 (* call interceptor if present for token refresh *)
234234 let* () =
235235 match t.on_request with Some f -> f t | None -> Lwt.return_unit
···249249 in
250250 let status = Cohttp.Response.status resp |> Cohttp.Code.code_of_status in
251251 let* body_str = Cohttp_lwt.Body.to_string body in
252252+ let body = Bytes.of_string body_str in
252253 if status >= 200 && status < 300 then
253254 let content_type =
254255 Cohttp.Response.headers resp
···256257 Cohttp.Header.get h "content-type"
257258 |> Option.value ~default:"application/octet-stream"
258259 in
259259- Lwt.return (body_str, content_type)
260260+ Lwt.return (body, content_type)
260261 else
261262 let payload =
262263 try
···272273273274 (* execute procedure with raw bytes input, returns raw bytes or none if no output *)
274275 let procedure_bytes (t : t) (nsid : string) (params : Yojson.Safe.t)
275275- (input : string option) ~(content_type : string) :
276276- (string * string) option Lwt.t =
276276+ (input : bytes option) ~(content_type : string) :
277277+ (bytes * string) option Lwt.t =
277278 (* call interceptor if present for token refresh *)
278279 let* () =
279280 match t.on_request with Some f -> f t | None -> Lwt.return_unit
···286287 let body =
287288 match input with
288289 | Some data ->
289289- Cohttp_lwt.Body.of_string data
290290+ Cohttp_lwt.Body.of_string (Bytes.to_string data)
290291 | None ->
291292 Cohttp_lwt.Body.empty
292293 in
···303304 in
304305 let status = Cohttp.Response.status resp |> Cohttp.Code.code_of_status in
305306 let* body_str = Cohttp_lwt.Body.to_string resp_body in
307307+ let body = Bytes.of_string body_str in
306308 if status >= 200 && status < 300 then
307307- if String.length body_str = 0 then Lwt.return None
309309+ if Bytes.length body = 0 then Lwt.return None
308310 else
309311 let resp_content_type =
310312 Cohttp.Response.headers resp
···312314 Cohttp.Header.get h "content-type"
313315 |> Option.value ~default:"application/octet-stream"
314316 in
315315- Lwt.return (Some (body_str, resp_content_type))
317317+ Lwt.return (Some (body, resp_content_type))
316318 else
317319 let payload =
318320 try
···1919 check (list string) "single segment" ["Test"] result
20202121let test_build_call_expr () =
2222- let result = Hermes_ppx.build_call_expr ~loc "app.bsky.graph.getProfile" in
2323- let expected_str = "App.Bsky.Graph.GetProfile.call" in
2222+ let result = Hermes_ppx.build_call_expr ~loc "app.bsky.actor.getProfile" in
2323+ let expected_str = "App.Bsky.Actor.GetProfile.Main.call" in
2424 check string "call expr" expected_str
2525 (Ppxlib.Pprintast.string_of_expression result)
2626···38383939let test_expand_get_nsid () =
4040 let actual = expand_xrpc {|[%xrpc get "app.bsky.graph.getRelationships"]|} in
4141- let expected_str = "App.Bsky.Graph.GetRelationships.call" in
4141+ let expected_str = "App.Bsky.Graph.GetRelationships.Main.call" in
4242 check string "get expansion" expected_str
4343 (Ppxlib.Pprintast.string_of_expression actual)
4444···4646 let actual =
4747 expand_xrpc {|[%xrpc post "com.atproto.server.createSession"]|}
4848 in
4949- let expected_str = "Com.Atproto.Server.CreateSession.call" in
4949+ let expected_str = "Com.Atproto.Server.CreateSession.Main.call" in
5050 check string "post expansion" expected_str
5151 (Ppxlib.Pprintast.string_of_expression actual)
52525353let test_expand_nsid_only () =
5454 (* [%xrpc "nsid"] defaults to get *)
5555 let actual = expand_xrpc {|[%xrpc "app.bsky.actor.getProfile"]|} in
5656- let expected_str = "App.Bsky.Actor.GetProfile.call" in
5656+ let expected_str = "App.Bsky.Actor.GetProfile.Main.call" in
5757 check string "nsid only expansion" expected_str
5858 (Ppxlib.Pprintast.string_of_expression actual)
5959
+1-1
pegasus/lexicons/com_atproto_sync_getBlob.ml
···1212[@@deriving yojson {strict= false}]
13131414 (** raw bytes output with content type *)
1515- type output = string * string
1515+ type output = bytes * string
16161717 let call
1818 ~did
+1-1
pegasus/lexicons/com_atproto_sync_getBlocks.ml
···1212[@@deriving yojson {strict= false}]
13131414 (** raw bytes output with content type *)
1515- type output = string * string
1515+ type output = bytes * string
16161717 let call
1818 ~did
+1-1
pegasus/lexicons/com_atproto_sync_getCheckout.ml
···1111[@@deriving yojson {strict= false}]
12121313 (** raw bytes output with content type *)
1414- type output = string * string
1414+ type output = bytes * string
15151616 let call
1717 ~did
+1-1
pegasus/lexicons/com_atproto_sync_getRecord.ml
···1313[@@deriving yojson {strict= false}]
14141515 (** raw bytes output with content type *)
1616- type output = string * string
1616+ type output = bytes * string
17171818 let call
1919 ~did
+1-1
pegasus/lexicons/com_atproto_sync_getRepo.ml
···1212[@@deriving yojson {strict= false}]
13131414 (** raw bytes output with content type *)
1515- type output = string * string
1515+ type output = bytes * string
16161717 let call
1818 ~did
+8-18
pegasus/lib/api/account_/migrate/migrate.ml
···417417 match%lwt Remote.fetch_repo old_client ~did with
418418 | Error err ->
419419 render_err ~did ~handle ~old_pds ("Failed to fetch repository: " ^ err)
420420- | Ok car_data -> (
421421- match%lwt
422422- Ops.import_repo ~did ~car_data:(Bytes.of_string (fst car_data))
423423- with
420420+ | Ok (car_data, _) -> (
421421+ match%lwt Ops.import_repo ~did ~car_data with
424422 | Error err ->
425423 render_err ~did ~handle ~old_pds err
426424 | Ok () ->
···432430 match%lwt Remote.fetch_repo old_client ~did with
433431 | Error e ->
434432 render_err ("Failed to fetch repository: " ^ e)
435435- | Ok car_data -> (
436436- match%lwt
437437- Ops.import_repo ~did ~car_data:(Bytes.of_string (fst car_data))
438438- with
433433+ | Ok (car_data, _) -> (
434434+ match%lwt Ops.import_repo ~did ~car_data with
439435 | Error e ->
440436 render_err e
441437 | Ok () -> (
···784780 match%lwt Remote.fetch_repo client ~did with
785781 | Error e ->
786782 render_err ("Failed to fetch repository: " ^ e)
787787- | Ok car_data -> (
788788- match%lwt
789789- Ops.import_repo ~did
790790- ~car_data:(Bytes.of_string @@ fst car_data)
791791- with
783783+ | Ok (car_data, _) -> (
784784+ match%lwt Ops.import_repo ~did ~car_data with
792785 | Error e ->
793786 render_err e
794787 | Ok () ->
···885878 | Error e ->
886879 render_err ~did ~handle ~old_pds
887880 ("Failed to fetch repository: " ^ e)
888888- | Ok car_data -> (
889889- match%lwt
890890- Ops.import_repo ~did
891891- ~car_data:(Bytes.of_string @@ fst car_data)
892892- with
881881+ | Ok (car_data, _) -> (
882882+ match%lwt Ops.import_repo ~did ~car_data with
893883 | Error e ->
894884 render_err ~did ~handle ~old_pds e
895885 | Ok () -> (
+1-3
pegasus/lib/api/account_/migrate/ops.ml
···125125 | Error _ ->
126126 Lwt.return_error cid_str
127127 | Ok cid ->
128128- let%lwt _ =
129129- User_store.put_blob user_db cid mimetype (Bytes.of_string data)
130130- in
128128+ let%lwt _ = User_store.put_blob user_db cid mimetype data in
131129 Lwt.return_ok cid_str ) )
132130 cids
133131 in