Skip to content

Commit

Permalink
Merge pull request #106 from str4d/lexicon-strings
Browse files Browse the repository at this point in the history
Introduce dedicated types for more Lexicon string formats
  • Loading branch information
sugyan authored Feb 19, 2024
2 parents 02042e3 + 9d33c92 commit f5d505f
Show file tree
Hide file tree
Showing 43 changed files with 577 additions and 83 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ libipld-core = "0.16"
serde_ipld_dagcbor = "0.3"

# Parsing and validation
chrono = "0.4"
langtag = "0.3"
regex = "1"
serde = "1.0.160"
serde_bytes = "0.11.9"
Expand All @@ -58,7 +60,6 @@ anyhow = "1.0.71"
thiserror = "1"

# CLI
chrono = "0.4.24"
clap = { version = "4.2.4", features = ["derive"] }
dirs = "5.0.1"

Expand Down
4 changes: 4 additions & 0 deletions atrium-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- `atrium_api::types`:
- `RecordKey`
- `LimitedU8`, `LimitedNonZeroU8`, `BoundedU8`
- `LimitedU16`, `LimitedNonZeroU16`, `BoundedU16`
- `LimitedU32`, `LimitedNonZeroU32`, `BoundedU32`
Expand All @@ -20,8 +21,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- All Lexicon string fields with one of the following formats now have the corresponding
dedicated type, instead of `String`:
- `at-identifier` (`atrium_api::types::string::AtIdentifier`)
- `datetime` (`atrium_api::types::string::Datetime`)
- `did` (`atrium_api::types::string::Did`)
- `handle` (`atrium_api::types::string::Handle`)
- `nsid` (`atrium_api::types::string::Nsid`)
- `language` (`atrium_api::types::string::Language`)

## [0.16.0](https://github.com/sugyan/atrium/compare/atrium-api-v0.15.0...atrium-api-v0.16.0) - 2024-02-09

Expand Down
2 changes: 2 additions & 0 deletions atrium-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ keywords.workspace = true
[dependencies]
atrium-xrpc.workspace = true
async-trait.workspace = true
chrono = { workspace = true, features = ["serde"] }
http.workspace = true
langtag = { workspace = true, features = ["serde"] }
regex.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_bytes.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions atrium-api/src/app/bsky/actor/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct InterestsPref {
pub struct PersonalDetailsPref {
///The birth date of account owner.
#[serde(skip_serializing_if = "Option::is_none")]
pub birth_date: Option<String>,
pub birth_date: Option<crate::types::string::Datetime>,
}
pub type Preferences = Vec<PreferencesItem>;
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
Expand All @@ -58,7 +58,7 @@ pub struct ProfileView {
pub display_name: Option<String>,
pub handle: crate::types::string::Handle,
#[serde(skip_serializing_if = "Option::is_none")]
pub indexed_at: Option<String>,
pub indexed_at: Option<crate::types::string::Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub labels: Option<Vec<crate::com::atproto::label::defs::Label>>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -96,7 +96,7 @@ pub struct ProfileViewDetailed {
pub follows_count: Option<i64>,
pub handle: crate::types::string::Handle,
#[serde(skip_serializing_if = "Option::is_none")]
pub indexed_at: Option<String>,
pub indexed_at: Option<crate::types::string::Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub labels: Option<Vec<crate::com::atproto::label::defs::Label>>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/embed/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct ViewRecord {
pub cid: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub embeds: Option<Vec<ViewRecordEmbedsItem>>,
pub indexed_at: String,
pub indexed_at: crate::types::string::Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub labels: Option<Vec<crate::com::atproto::label::defs::Label>>,
pub uri: String,
Expand Down
6 changes: 3 additions & 3 deletions atrium-api/src/app/bsky/feed/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct GeneratorView {
pub description_facets: Option<Vec<crate::app::bsky::richtext::facet::Main>>,
pub did: crate::types::string::Did,
pub display_name: String,
pub indexed_at: String,
pub indexed_at: crate::types::string::Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub like_count: Option<usize>,
pub uri: String,
Expand All @@ -62,7 +62,7 @@ pub struct PostView {
pub cid: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub embed: Option<PostViewEmbedEnum>,
pub indexed_at: String,
pub indexed_at: crate::types::string::Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub labels: Option<Vec<crate::com::atproto::label::defs::Label>>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -82,7 +82,7 @@ pub struct PostView {
#[serde(rename_all = "camelCase")]
pub struct ReasonRepost {
pub by: crate::app::bsky::actor::defs::ProfileViewBasic,
pub indexed_at: String,
pub indexed_at: crate::types::string::Datetime,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
Expand Down
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/feed/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pub struct Record {
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar: Option<crate::types::BlobRef>,
pub created_at: String,
pub created_at: crate::types::string::Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
4 changes: 2 additions & 2 deletions atrium-api/src/app/bsky/feed/get_likes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ pub enum Error {}
#[serde(rename_all = "camelCase")]
pub struct Like {
pub actor: crate::app::bsky::actor::defs::ProfileView,
pub created_at: String,
pub indexed_at: String,
pub created_at: crate::types::string::Datetime,
pub indexed_at: crate::types::string::Datetime,
}
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/feed/like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Record {
pub created_at: String,
pub created_at: crate::types::string::Datetime,
pub subject: crate::com::atproto::repo::strong_ref::Main,
}
4 changes: 2 additions & 2 deletions atrium-api/src/app/bsky/feed/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#[serde(rename_all = "camelCase")]
pub struct Record {
///Client-declared timestamp when this post was originally created.
pub created_at: String,
pub created_at: crate::types::string::Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub embed: Option<RecordEmbedEnum>,
///DEPRECATED: replaced by app.bsky.richtext.facet.
Expand All @@ -18,7 +18,7 @@ pub struct Record {
pub labels: Option<RecordLabelsEnum>,
///Indicates human language of post primary text content.
#[serde(skip_serializing_if = "Option::is_none")]
pub langs: Option<Vec<String>>,
pub langs: Option<Vec<crate::types::string::Language>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reply: Option<ReplyRef>,
///Additional hashtags, in addition to any included in post text and facets.
Expand Down
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/feed/repost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Record {
pub created_at: String,
pub created_at: crate::types::string::Datetime,
pub subject: crate::com::atproto::repo::strong_ref::Main,
}
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/feed/threadgate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pub struct Record {
#[serde(skip_serializing_if = "Option::is_none")]
pub allow: Option<Vec<RecordAllowItem>>,
pub created_at: String,
pub created_at: crate::types::string::Datetime,
///Reference (AT-URI) to the post record.
pub post: String,
}
Expand Down
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/graph/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Record {
pub created_at: String,
pub created_at: crate::types::string::Datetime,
///DID of the account to be blocked.
pub subject: crate::types::string::Did,
}
4 changes: 2 additions & 2 deletions atrium-api/src/app/bsky/graph/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct ListView {
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub description_facets: Option<Vec<crate::app::bsky::richtext::facet::Main>>,
pub indexed_at: String,
pub indexed_at: crate::types::string::Datetime,
pub name: String,
pub purpose: ListPurpose,
pub uri: String,
Expand All @@ -34,7 +34,7 @@ pub struct ListViewBasic {
pub avatar: Option<String>,
pub cid: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub indexed_at: Option<String>,
pub indexed_at: Option<crate::types::string::Datetime>,
pub name: String,
pub purpose: ListPurpose,
pub uri: String,
Expand Down
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/graph/follow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Record {
pub created_at: String,
pub created_at: crate::types::string::Datetime,
pub subject: crate::types::string::Did,
}
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/graph/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pub struct Record {
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar: Option<crate::types::BlobRef>,
pub created_at: String,
pub created_at: crate::types::string::Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/graph/listblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Record {
pub created_at: String,
pub created_at: crate::types::string::Datetime,
///Reference (AT-URI) to the mod list record.
pub subject: String,
}
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/graph/listitem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Record {
pub created_at: String,
pub created_at: crate::types::string::Datetime,
///Reference (AT-URI) to the list record (app.bsky.graph.list).
pub list: String,
///The account which is included on the list.
Expand Down
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/notification/get_unread_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#[serde(rename_all = "camelCase")]
pub struct Parameters {
#[serde(skip_serializing_if = "Option::is_none")]
pub seen_at: Option<String>,
pub seen_at: Option<crate::types::string::Datetime>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
Expand Down
6 changes: 3 additions & 3 deletions atrium-api/src/app/bsky/notification/list_notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Parameters {
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<crate::types::LimitedNonZeroU8<100u8>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub seen_at: Option<String>,
pub seen_at: Option<crate::types::string::Datetime>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
Expand All @@ -17,7 +17,7 @@ pub struct Output {
pub cursor: Option<String>,
pub notifications: Vec<Notification>,
#[serde(skip_serializing_if = "Option::is_none")]
pub seen_at: Option<String>,
pub seen_at: Option<crate::types::string::Datetime>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "error", content = "message")]
Expand All @@ -27,7 +27,7 @@ pub enum Error {}
pub struct Notification {
pub author: crate::app::bsky::actor::defs::ProfileView,
pub cid: String,
pub indexed_at: String,
pub indexed_at: crate::types::string::Datetime,
pub is_read: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub labels: Option<Vec<crate::com::atproto::label::defs::Label>>,
Expand Down
2 changes: 1 addition & 1 deletion atrium-api/src/app/bsky/notification/update_seen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Input {
pub seen_at: String,
pub seen_at: crate::types::string::Datetime,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "error", content = "message")]
Expand Down
Loading

0 comments on commit f5d505f

Please sign in to comment.