Skip to content

Commit

Permalink
feat(api): Add namespace features (#174)
Browse files Browse the repository at this point in the history
* Update codegen: add namespace features

* Update API, generated by new codegen

* Update dependencies

* Update workflows

* Update README
  • Loading branch information
sugyan authored May 20, 2024
1 parent 7768c36 commit ccc0213
Show file tree
Hide file tree
Showing 14 changed files with 343 additions and 61 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build -p atrium-api --verbose
run: |
cargo build -p atrium-api --verbose
cargo build -p atrium-api --verbose --no-default-features
cargo build -p atrium-api --verbose --no-default-features --features agent
cargo build -p atrium-api --verbose --no-default-features --features bluesky
cargo build -p atrium-api --verbose --all-features
- name: Run tests
run: |
cargo test -p atrium-api --lib
cargo test -p atrium-api
cargo test -p atrium-api --lib --no-default-features
cargo test -p atrium-api --lib --no-default-features --features agent
cargo test -p atrium-api --lib --no-default-features --features bluesky
cargo test -p atrium-api --lib --all-features
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ serde_html_form = "0.2.6"
# Networking
futures = { version = "0.3.30", default-features = false, features = ["alloc"] }
http = "1.1.0"
tokio = { version = "1.36", default-features = false }
tokio = { version = "1.37", default-features = false }

# HTTP client integrations
isahc = "1.7.2"
Expand Down
6 changes: 5 additions & 1 deletion atrium-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ serde_bytes.workspace = true
tokio = { workspace = true, optional = true }

[features]
default = ["agent"]
default = ["agent", "bluesky"]
agent = ["tokio/sync"]
bluesky = ["namespace-appbsky", "namespace-chatbsky", "namespace-toolsozone"]
namespace-appbsky = []
namespace-chatbsky = []
namespace-toolsozone = []

[dev-dependencies]
atrium-xrpc-client.workspace = true
Expand Down
20 changes: 13 additions & 7 deletions atrium-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
```

### `AtpAgent`
### `AtpAgent` (`agent` feature)

While `AtpServiceClient` can be used for simple XRPC calls, it is better to use `AtpAgent`, which has practical features such as session management.

Expand All @@ -53,14 +53,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
agent.login("[email protected]", "hunter2").await?;
let result = agent
.api
.app
.bsky
.actor
.get_profile(atrium_api::app::bsky::actor::get_profile::Parameters {
actor: "bsky.app".parse()?,
})
.com
.atproto
.server
.get_session()
.await?;
println!("{:?}", result);
Ok(())
}
```

## Features

The `AtpAgent` used in the above example is included in the `agent` feature. atrium-api enables the `agent` and `bluesky` features by default. It is possible to opt-out if not needed.

- `agent`: enable the `agent` module.
- `bluesky`: enable bluesky-specific lexicon definitions and XRPC methods.
- It is also possible to enable only the namespace specified by `namespace-*`.
2 changes: 2 additions & 0 deletions atrium-api/src/app.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions atrium-api/src/chat.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ccc0213

Please sign in to comment.