diff --git a/CHANGELOG.md b/CHANGELOG.md index 26ae10a..01a37c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v1.1.0] - 2026-07-17 +## [v2.0.0] - Unreleased ### Added @@ -14,3 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [possum/tangled] Added `get_pull_request` - [possum/tangled] Added `get_repository_by_did` - [possum/tangled] Added `get_repository_by_uri` + +### Changed + +- [possum/tangled] Added `list_issues` now takes an optional "author" parameter +- [possum/tangled] Added `list_pull_requests` now takes an optional "author" parameter diff --git a/README.md b/README.md index 83ec200..914bc63 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,9 @@ [![Package Version](https://img.shields.io/hexpm/v/possum_tangled)](https://hex.pm/packages/possum_tangled) [![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://possum-tangled.hexdocs.pm/) -Possum submodule targeting Bobbin, the Tangled xrpc API. Useful for fetching data -about repositories, issues, vouches, spindles and pull requests. +Possum submodule targeting Bobbin, the official Tangled xrpc API. +Useful for fetching data about repositories, issues, vouches, +spindles and pull requests. [What is possum?](https://possum.hexdocs.pm/) @@ -25,15 +26,28 @@ let assert Ok(did) = did.parse("did:plc:wibblewobble") let request = tangled.list_vouches(did, cursor: option.None, limit: option.None) -// List available issues of a repository -let request = - tangled.list_issues(did, cursor: option.None, limit: option.None) - -// List available pull requests of a repository -let request = - tangled.list_pull_requests(did, cursor: option.None, limit: option.None) +let assert Ok(repo_did) = did.parse("did:plc:j5hmlfdrwkvtxm7cjmu7j2is") +let assert Ok(user_did) = did.parse("did:plc:dvyyslcz7bicxdumlccviqyv") + +// List available issues of a repository authored by an User +let assert Ok(response) = + tangled.list_issues( + repo_did, + author: option.Some(user_did), + cursor: option.None, + limit: option.None, + ) + +// List available pull requests of a repository authored by an User +let assert Ok(response) = + tangled.list_pull_requests( + repo_did, + author: option.Some(user_did), + cursor: option.None, + limit: option.None, + ) // List all repositories created by an user let request = - tangled.list_repositories(did, cursor: option.None, limit: option.None) + tangled.list_repositories(user_did, cursor: option.None, limit: option.None) ``` diff --git a/gleam.toml b/gleam.toml index 7ed4bbd..e40a8dc 100644 --- a/gleam.toml +++ b/gleam.toml @@ -1,5 +1,5 @@ name = "possum_tangled" -version = "1.1.0" +version = "2.0.0" description = "🐑 Possum submodule for the Tangled API" licences = ["MIT"] diff --git a/src/possum/tangled.gleam b/src/possum/tangled.gleam index 7a06a41..a24e95b 100644 --- a/src/possum/tangled.gleam +++ b/src/possum/tangled.gleam @@ -336,7 +336,8 @@ pub fn list_knots( |> request.set_query(query) } -/// List all issues attached to a repository +/// List all issues attached to a repository. +/// You can restrict issues authored by a given User. /// /// ## Examples /// @@ -348,16 +349,27 @@ pub fn list_knots( /// let assert Ok(did) = did.parse("did:plc:j5hmlfdrwkvtxm7cjmu7j2is") /// /// let request = -/// tangled.list_issues(did, cursor: option.None, limit: option.None) +/// tangled.list_issues( +/// did, +/// author: option.None, +/// cursor: option.None, +/// limit: option.None, +/// ) /// ``` pub fn list_issues( did: did.Did, + author author: option.Option(did.Did), cursor cursor: option.Option(String), limit limit: option.Option(Int), ) -> request.Request(String) { let endpoint = ".repo.listIssues" let query = [#("subject", did.to_string(did))] + let query = case author { + option.Some(did) -> [#("author", did.to_string(did)), ..query] + option.None -> query + } + let query = case cursor { option.Some(value) -> [#("cursor", value), ..query] option.None -> query @@ -393,16 +405,27 @@ pub fn list_issues( /// let assert Ok(did) = did.parse("did:plc:j5hmlfdrwkvtxm7cjmu7j2is") /// /// let request = -/// tangled.list_pull_requests(did, cursor: option.None, limit: option.None) +/// tangled.list_pull_requests( +/// did, +/// author: option.None, +/// cursor: option.None, +/// limit: option.None, +/// ) /// ``` pub fn list_pull_requests( did: did.Did, + author author: option.Option(did.Did), cursor cursor: option.Option(String), limit limit: option.Option(Int), ) -> request.Request(String) { let endpoint = ".repo.listPulls" let query = [#("subject", did.to_string(did))] + let query = case author { + option.Some(did) -> [#("author", did.to_string(did)), ..query] + option.None -> query + } + let query = case cursor { option.Some(value) -> [#("cursor", value), ..query] option.None -> query diff --git a/test/possum_tangled_test.gleam b/test/possum_tangled_test.gleam index b8b2698..f985d09 100644 --- a/test/possum_tangled_test.gleam +++ b/test/possum_tangled_test.gleam @@ -137,7 +137,33 @@ pub fn list_issues_test() -> Nil { let assert Ok(did) = did.parse("did:plc:j5hmlfdrwkvtxm7cjmu7j2is") let assert Ok(response) = - tangled.list_issues(did, cursor: option.None, limit: option.None) + tangled.list_issues( + did, + author: option.None, + cursor: option.None, + limit: option.None, + ) + |> httpc.send + + let assert Ok(_) = + response.body + |> json.parse(lexicon_list_decoder("sh.tangled.repo.issue")) + + Nil +} + +/// https://api.tangled.org/xrpc/sh.tangled.repo.listIssues?subject=did:plc:j5hmlfdrwkvtxm7cjmu7j2is&author=did:plc:dvyyslcz7bicxdumlccviqyv +pub fn list_issues_by_user_test() -> Nil { + let assert Ok(did) = did.parse("did:plc:j5hmlfdrwkvtxm7cjmu7j2is") + let assert Ok(author) = did.parse("did:plc:dvyyslcz7bicxdumlccviqyv") + + let assert Ok(response) = + tangled.list_issues( + did, + author: option.Some(author), + cursor: option.None, + limit: option.None, + ) |> httpc.send let assert Ok(_) = @@ -152,7 +178,33 @@ pub fn list_pull_requests_test() -> Nil { let assert Ok(did) = did.parse("did:plc:j5hmlfdrwkvtxm7cjmu7j2is") let assert Ok(response) = - tangled.list_pull_requests(did, cursor: option.None, limit: option.None) + tangled.list_pull_requests( + did, + author: option.None, + cursor: option.None, + limit: option.None, + ) + |> httpc.send + + let assert Ok(_) = + response.body + |> json.parse(lexicon_list_decoder("sh.tangled.repo.pull")) + + Nil +} + +/// https://api.tangled.org/xrpc/sh.tangled.repo.listPulls?subject=did:plc:j5hmlfdrwkvtxm7cjmu7j2is&author=did:plc:3fwecdnvtcscjnrx2p4n7alz +pub fn list_pull_requests_by_author_test() -> Nil { + let assert Ok(did) = did.parse("did:plc:j5hmlfdrwkvtxm7cjmu7j2is") + let assert Ok(author) = did.parse("did:plc:3fwecdnvtcscjnrx2p4n7alz") + + let assert Ok(response) = + tangled.list_pull_requests( + did, + author: option.Some(author), + cursor: option.None, + limit: option.None, + ) |> httpc.send let assert Ok(_) =