Skip to content

Commit

Permalink
Fix codegen, update API codes
Browse files Browse the repository at this point in the history
  • Loading branch information
sugyan committed Feb 8, 2024
1 parent ad02a16 commit 3bf79c5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions atrium-api/src/com/atproto/label/subscribe_labels.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file is generated by atrium-codegen. DO NOT EDIT.
//!Definitions for the `com.atproto.label.subscribeLabels` namespace.
pub const NSID: &str = "com.atproto.label.subscribeLabels";
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Parameters {
Expand Down
9 changes: 5 additions & 4 deletions atrium-api/src/com/atproto/sync/subscribe_repos.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file is generated by atrium-codegen. DO NOT EDIT.
//!Definitions for the `com.atproto.sync.subscribeRepos` namespace.
pub const NSID: &str = "com.atproto.sync.subscribeRepos";
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Parameters {
Expand All @@ -16,14 +17,14 @@ pub enum Error {
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Commit {
pub blobs: Vec<cid::Cid>,
pub blobs: Vec<crate::types::CidLink>,
///CAR file containing relevant blocks.
#[serde(with = "serde_bytes")]
pub blocks: Vec<u8>,
pub commit: cid::Cid,
pub commit: crate::types::CidLink,
pub ops: Vec<RepoOp>,
#[serde(skip_serializing_if = "Option::is_none")]
pub prev: Option<cid::Cid>,
pub prev: Option<crate::types::CidLink>,
pub rebase: bool,
pub repo: String,
///The rev of the emitted commit.
Expand Down Expand Up @@ -65,7 +66,7 @@ pub struct Migrate {
pub struct RepoOp {
pub action: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<cid::Cid>,
pub cid: Option<crate::types::CidLink>,
pub path: String,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
Expand Down
9 changes: 8 additions & 1 deletion atrium-codegen/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ pub(crate) fn generate_schemas(
if let Some(basename) = paths.pop() {
let mut tokens = Vec::new();
let mut names = Vec::new();
// main def
for (name, def) in &schema.defs {
// NSID (for XrpcSubscription only)
if let LexUserType::XrpcSubscription(_) = &def {
let nsid = schema.id.clone();
tokens.push(quote! {
pub const NSID: &str = #nsid;
});
}
// main def
if name == "main" {
tokens.push(user_type(def, basename, true)?);
} else {
Expand Down
3 changes: 1 addition & 2 deletions atrium-codegen/src/token_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ fn lex_subscription(subscription: &LexXrpcSubscription) -> Result<TokenStream> {
} else {
quote!()
};
// TODO: message
let errors = xrpc_errors(&subscription.errors)?;
Ok(quote! {
#params
Expand Down Expand Up @@ -328,7 +327,7 @@ fn bytes_type(bytes: &LexBytes) -> Result<(TokenStream, TokenStream)> {

fn cid_link_type(cid_link: &LexCidLink) -> Result<(TokenStream, TokenStream)> {
let description = description(&cid_link.description);
Ok((description, quote!(cid::Cid)))
Ok((description, quote!(crate::types::CidLink)))
}

fn array_type(
Expand Down

0 comments on commit 3bf79c5

Please sign in to comment.