objective categorical abstract machine language personal data server
65
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix cid parsing in input/output

futurGH 6292de9b 4c1ef90c

+40 -32
+6 -4
pegasus/lib/api/repo/applyWrites.ml
··· 2 2 { repo: string 3 3 ; validate: bool option 4 4 ; writes: Repository.repo_write list 5 - ; swap_commit: Cid.t option [@key "swapCommit"] } 5 + ; swap_commit: string option [@key "swapCommit"] } 6 6 [@@deriving yojson] 7 7 8 8 type response = 9 9 {commit: res_commit option; results: Repository.apply_writes_result list} 10 10 [@@deriving yojson] 11 11 12 - and res_commit = {cid: Cid.t; rev: string} [@@deriving yojson] 12 + and res_commit = {cid: string; rev: string} [@@deriving yojson] 13 13 14 14 let handler = 15 15 Xrpc.handler ~auth:Auth.Verifiers.authorization (fun ctx -> ··· 36 36 in 37 37 let%lwt repo = Repository.load did in 38 38 let%lwt {commit= commit_cid, {rev; _}; results} = 39 - Repository.apply_writes repo input.writes input.swap_commit 39 + Repository.apply_writes repo input.writes 40 + (Option.map Cid.as_cid input.swap_commit) 40 41 in 41 42 Dream.json @@ Yojson.Safe.to_string 42 - @@ response_to_yojson {commit= Some {cid= commit_cid; rev}; results} ) 43 + @@ response_to_yojson 44 + {commit= Some {cid= Cid.to_string commit_cid; rev}; results} )
+9 -8
pegasus/lib/api/repo/createRecord.ml
··· 4 4 ; rkey: string option 5 5 ; validate: bool option 6 6 ; record: Mist.Lex.repo_record 7 - ; swap_record: Cid.t option [@key "swapRecord"] 8 - ; swap_commit: Cid.t option [@key "swapCommit"] } 7 + ; swap_record: string option [@key "swapRecord"] 8 + ; swap_commit: string option [@key "swapCommit"] } 9 9 [@@deriving yojson] 10 10 11 11 type response = 12 12 { uri: string 13 - ; cid: Cid.t 13 + ; cid: string 14 14 ; commit: res_commit option 15 15 ; validation_status: string option [@key "validationStatus"] } 16 16 [@@deriving yojson] 17 17 18 - and res_commit = {cid: Cid.t; rev: string} [@@deriving yojson] 18 + and res_commit = {cid: string; rev: string} [@@deriving yojson] 19 19 20 20 let handler = 21 21 Xrpc.handler ~auth:Auth.Verifiers.authorization (fun ctx -> ··· 51 51 ; collection= input.collection 52 52 ; rkey 53 53 ; value= input.record 54 - ; swap_record= Some swap_record } 54 + ; swap_record= Some (Cid.as_cid swap_record) } 55 55 | None -> 56 56 Errors.invalid_request "rkey is required for swap_record" ) 57 57 | None -> ··· 62 62 ; value= input.record } 63 63 in 64 64 let%lwt {commit= commit_cid, {rev; _}; results} = 65 - Repository.apply_writes repo [write] input.swap_commit 65 + Repository.apply_writes repo [write] 66 + (Option.map Cid.as_cid input.swap_commit) 66 67 in 67 68 match List.hd results with 68 69 | Create {uri; cid; _} | Update {uri; cid; _} -> 69 70 Dream.json @@ Yojson.Safe.to_string 70 71 @@ response_to_yojson 71 72 { uri 72 - ; cid 73 - ; commit= Some {cid= commit_cid; rev} 73 + ; cid= Cid.to_string cid 74 + ; commit= Some {cid= Cid.to_string commit_cid; rev} 74 75 ; validation_status= Some "valid" } 75 76 | _ -> 76 77 Errors.invalid_request "unexpected delete result" )
+8 -6
pegasus/lib/api/repo/deleteRecord.ml
··· 2 2 { repo: string 3 3 ; collection: string 4 4 ; rkey: string 5 - ; swap_record: Cid.t option [@key "swapRecord"] 6 - ; swap_commit: Cid.t option [@key "swapCommit"] } 5 + ; swap_record: string option [@key "swapRecord"] 6 + ; swap_commit: string option [@key "swapCommit"] } 7 7 [@@deriving yojson] 8 8 9 9 type response = {commit: res_commit option} [@@deriving yojson] 10 10 11 - and res_commit = {cid: Cid.t; rev: string} [@@deriving yojson] 11 + and res_commit = {cid: string; rev: string} [@@deriving yojson] 12 12 13 13 let handler = 14 14 Xrpc.handler ~auth:Auth.Verifiers.authorization (fun ctx -> ··· 39 39 { type'= Repository.Write_op.delete 40 40 ; collection= input.collection 41 41 ; rkey= input.rkey 42 - ; swap_record= input.swap_record } 42 + ; swap_record= Option.map Cid.as_cid input.swap_record } 43 43 in 44 44 let%lwt {commit= commit_cid, {rev; _}; results} = 45 - Repository.apply_writes repo [write] input.swap_commit 45 + Repository.apply_writes repo [write] 46 + (Option.map Cid.as_cid input.swap_commit) 46 47 in 47 48 match List.hd results with 48 49 | Delete _ -> 49 50 Dream.json @@ Yojson.Safe.to_string 50 - @@ response_to_yojson {commit= Some {cid= commit_cid; rev}} 51 + @@ response_to_yojson 52 + {commit= Some {cid= Cid.to_string commit_cid; rev}} 51 53 | _ -> 52 54 Errors.invalid_request "unexpected create or update result" )
+5 -4
pegasus/lib/api/repo/getRecord.ml
··· 1 - type query = {repo: string; collection: string; rkey: string; cid: Cid.t option} 1 + type query = {repo: string; collection: string; rkey: string; cid: string option} 2 2 [@@deriving yojson] 3 3 4 - type response = {uri: string; cid: Cid.t; value: Mist.Lex.repo_record} 4 + type response = {uri: string; cid: string; value: Mist.Lex.repo_record} 5 5 [@@deriving yojson] 6 6 7 7 let handler = ··· 21 21 let path = input.collection ^ "/" ^ input.rkey in 22 22 let uri = "at://" ^ input_did ^ "/" ^ path in 23 23 match%lwt Repository.get_record repo path with 24 - | Some {cid; value; _} when input.cid = None || input.cid = Some cid -> 24 + | Some {cid; value; _} 25 + when input.cid = None || input.cid = Some (Cid.to_string cid) -> 25 26 Dream.json @@ Yojson.Safe.to_string 26 - @@ response_to_yojson {uri; cid; value} 27 + @@ response_to_yojson {uri; cid= Cid.to_string cid; value} 27 28 | _ -> 28 29 Errors.internal_error ~name:"RecordNotFound" 29 30 ~msg:("could not find record " ^ uri)
+3 -2
pegasus/lib/api/repo/listRecords.ml
··· 9 9 type response = {cursor: string option; records: response_record list} 10 10 [@@deriving yojson] 11 11 12 - and response_record = {uri: string; cid: Cid.t; value: Mist.Lex.repo_record} 12 + and response_record = {uri: string; cid: string; value: Mist.Lex.repo_record} 13 13 [@@deriving yojson] 14 14 15 15 let handler = ··· 42 42 (fun (_cursor, results_rev) (record : User_store.Types.record) -> 43 43 let uri = "at://" ^ input_did ^ "/" ^ record.path in 44 44 ( record.since 45 - , {uri; cid= record.cid; value= record.value} :: results_rev ) ) 45 + , {uri; cid= Cid.to_string record.cid; value= record.value} 46 + :: results_rev ) ) 46 47 ("", []) results 47 48 in 48 49 Dream.json @@ Yojson.Safe.to_string
+9 -8
pegasus/lib/api/repo/putRecord.ml
··· 4 4 ; rkey: string 5 5 ; validate: bool option 6 6 ; record: Mist.Lex.repo_record 7 - ; swap_record: Cid.t option [@key "swapRecord"] 8 - ; swap_commit: Cid.t option [@key "swapCommit"] } 7 + ; swap_record: string option [@key "swapRecord"] 8 + ; swap_commit: string option [@key "swapCommit"] } 9 9 [@@deriving yojson] 10 10 11 11 type response = 12 12 { uri: string 13 - ; cid: Cid.t 13 + ; cid: string 14 14 ; commit: res_commit option 15 15 ; validation_status: string option [@key "validationStatus"] } 16 16 [@@deriving yojson] 17 17 18 - and res_commit = {cid: Cid.t; rev: string} [@@deriving yojson] 18 + and res_commit = {cid: string; rev: string} [@@deriving yojson] 19 19 20 20 let handler = 21 21 Xrpc.handler ~auth:Auth.Verifiers.authorization (fun ctx -> ··· 47 47 ; collection= input.collection 48 48 ; rkey= input.rkey 49 49 ; value= input.record 50 - ; swap_record= input.swap_record } 50 + ; swap_record= Option.map Cid.as_cid input.swap_record } 51 51 in 52 52 let%lwt {commit= commit_cid, {rev; _}; results} = 53 - Repository.apply_writes repo [write] input.swap_commit 53 + Repository.apply_writes repo [write] 54 + (Option.map Cid.as_cid input.swap_commit) 54 55 in 55 56 match List.hd results with 56 57 | Create {uri; cid; _} | Update {uri; cid; _} -> 57 58 Dream.json @@ Yojson.Safe.to_string 58 59 @@ response_to_yojson 59 60 { uri 60 - ; cid 61 - ; commit= Some {cid= commit_cid; rev} 61 + ; cid= Cid.to_string cid 62 + ; commit= Some {cid= Cid.to_string commit_cid; rev} 62 63 ; validation_status= Some "valid" } 63 64 | _ -> 64 65 Errors.invalid_request "unexpected delete result" )