๐Ÿ€ ATproto library for gleam
atproto library gleam
34

Configure Feed

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

possum: add delete_record

kacaii.dev (Jul 2, 2026, 12:16 AM -0300) 68f31d56 1828fb7c

+78 -6
+78 -6
src/possum.gleam
··· 338 338 /// let request = 339 339 /// request.new() 340 340 /// |> request.set_host("personal.data-server.pds") 341 - /// |> possum.authorized("my-access-token") 341 + /// |> possum.authorized("access-token") 342 342 /// ``` 343 343 /// 344 344 pub fn authorized( ··· 412 412 /// |> request.set_host("personal.data-server.pds") 413 413 /// |> possum.authorized("access-token") 414 414 /// |> possum.create_record( 415 - /// did: did, 415 + /// did, 416 416 /// rkey: "wibble", 417 417 /// collection: "wibble.wobble.woo", 418 418 /// record: [], ··· 439 439 pub fn create_record( 440 440 request: request.Request(_), 441 441 did: did.Did, 442 - rkey rkey: option.Option(String), 443 442 collection collection: String, 443 + rkey rkey: option.Option(String), 444 444 record record: List(#(String, json.Json)), 445 445 swap_commit swap_commit: option.Option(String), 446 446 validate validate: option.Option(Bool), ··· 490 490 /// request.new() 491 491 /// |> request.set_host("personal.data-server.pds") 492 492 /// |> possum.get_record( 493 - /// repository: did, 493 + /// did, 494 494 /// rkey: "3mn6n3lvibc2b", 495 495 /// collection: "site.standard.document", 496 496 /// cursor: option.None, ··· 513 513 pub fn get_record( 514 514 request: request.Request(_), 515 515 did: did.Did, 516 - rkey rkey: String, 517 516 collection collection: String, 517 + rkey rkey: String, 518 518 cid cid: option.Option(String), 519 519 ) -> request.Request(_) { 520 520 let query = [ ··· 547 547 /// request.new() 548 548 /// |> request.set_host("personal.data-server.pds") 549 549 /// |> possum.list_records( 550 - /// did: did, 550 + /// did, 551 551 /// collection: "site.standard.document", 552 552 /// limit: option.Some(3), 553 553 /// cursor: option.None, ··· 641 641 reverse: option.None, 642 642 ) 643 643 } 644 + 645 + /// Delete a repository record, or ensure it doesn't exist. 646 + /// Requires auth, implemented by PDS. 647 + /// 648 + /// - **collection**: The NSID of the record collection. 649 + /// - **repo**: The handle or DID of the repo (aka, current account). 650 + /// - **rkey**: The Record Key. 651 + /// - **swapCommit**: Compare and swap with the previous commit by CID. 652 + /// - **swapRecord**: Compare and swap with the previous record by CID. 653 + /// 654 + /// ## Examples 655 + /// 656 + /// ```gleam 657 + /// import gleam/http/request 658 + /// import possum 659 + /// 660 + /// let request = 661 + /// request.new() 662 + /// |> request.set_host("personal.data-server.pds") 663 + /// |> possum.authorized("access-token") 664 + /// |> possum.delete_record( 665 + /// did, 666 + /// collection: "target.collection.data", 667 + /// rkey: "wibble-wobble", 668 + /// swap_commit: option.None, 669 + /// swap_record: option.None, 670 + /// ) 671 + /// ``` 672 + /// 673 + /// ## Response 674 + /// 675 + /// ```json 676 + /// { 677 + /// "commit": { 678 + /// "cid": "string", 679 + /// "rev": "string" 680 + /// } 681 + /// } 682 + /// ``` 683 + /// 684 + /// Endpoint Docs: [/xrpc/com.atproto.repo.deleteRecord](https://endpoints.bsky.app/#bluesky-app/tag/comatprotorepo/POST/xrpc/com.atproto.repo.deleteRecord) 685 + pub fn delete_record( 686 + request: request.Request(_), 687 + did: did.Did, 688 + collection collection: String, 689 + rkey rkey: String, 690 + swap_commit swap_commit: option.Option(String), 691 + swap_record swap_record: option.Option(String), 692 + ) -> request.Request(_) { 693 + let body = [ 694 + #("repo", json.string(did.to_string(did))), 695 + #("collection", json.string(collection)), 696 + #("rkey", json.string(rkey)), 697 + ] 698 + 699 + let body = case swap_commit { 700 + option.Some(value) -> [#("swapCommit", json.string(value)), ..body] 701 + option.None -> body 702 + } 703 + 704 + let body = case swap_record { 705 + option.Some(value) -> [#("swapRecord", json.string(value)), ..body] 706 + option.None -> body 707 + } 708 + 709 + request 710 + |> request.prepend_header("accept", "application/json") 711 + |> request.prepend_header("content-type", "application/json") 712 + |> request.set_body(json.to_string(json.object(body))) 713 + |> request.set_method(http.Post) 714 + |> request.set_path(com_atproto_repo <> ".deleteRecord") 715 + }