#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Datetime;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::sh_tangled::repo::get_default_branch;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct GetDefaultBranch<S: BosStr = DefaultStr> {
pub repo: S,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct GetDefaultBranchOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub author: Option<get_default_branch::Signature<S>>,
pub hash: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<S>,
pub name: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub short_hash: Option<S>,
pub when: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(
Serialize, Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic,
)]
#[serde(tag = "error", content = "message")]
pub enum GetDefaultBranchError {
#[serde(rename = "RepoNotFound")]
RepoNotFound(Option<SmolStr>),
#[serde(rename = "InvalidRequest")]
InvalidRequest(Option<SmolStr>),
#[serde(untagged)]
Other {
error: SmolStr,
message: Option<SmolStr>,
},
}
impl core::fmt::Display for GetDefaultBranchError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::RepoNotFound(msg) => {
write!(f, "RepoNotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::InvalidRequest(msg) => {
write!(f, "InvalidRequest")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Signature<S: BosStr = DefaultStr> {
pub email: S,
pub name: S,
pub when: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
pub struct GetDefaultBranchResponse;
impl jacquard_common::xrpc::XrpcResp for GetDefaultBranchResponse {
const NSID: &'static str = "sh.tangled.repo.getDefaultBranch";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = GetDefaultBranchOutput<S>;
type Err = GetDefaultBranchError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetDefaultBranch<S> {
const NSID: &'static str = "sh.tangled.repo.getDefaultBranch";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetDefaultBranchResponse;
}
pub struct GetDefaultBranchRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetDefaultBranchRequest {
const PATH: &'static str = "/xrpc/sh.tangled.repo.getDefaultBranch";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = GetDefaultBranch<S>;
type Response = GetDefaultBranchResponse;
}
impl<S: BosStr> LexiconSchema for Signature<S> {
fn nsid() -> &'static str {
"sh.tangled.repo.getDefaultBranch"
}
fn def_name() -> &'static str {
"signature"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_repo_getDefaultBranch()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod get_default_branch_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Repo;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Repo = Unset;
}
pub struct SetRepo<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRepo<St> {}
impl<St: State> State for SetRepo<St> {
type Repo = Set<members::repo>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct repo(());
}
}
pub struct GetDefaultBranchBuilder<S: BosStr, St: get_default_branch_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> GetDefaultBranch<S> {
pub fn new() -> GetDefaultBranchBuilder<S, get_default_branch_state::Empty> {
GetDefaultBranchBuilder::new()
}
}
impl<S: BosStr> GetDefaultBranchBuilder<S, get_default_branch_state::Empty> {
pub fn new() -> Self {
GetDefaultBranchBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GetDefaultBranchBuilder<S, St>
where
St: get_default_branch_state::State,
St::Repo: get_default_branch_state::IsUnset,
{
pub fn repo(
mut self,
value: impl Into<S>,
) -> GetDefaultBranchBuilder<S, get_default_branch_state::SetRepo<St>> {
self._fields.0 = Option::Some(value.into());
GetDefaultBranchBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GetDefaultBranchBuilder<S, St>
where
St: get_default_branch_state::State,
St::Repo: get_default_branch_state::IsSet,
{
pub fn build(self) -> GetDefaultBranch<S> {
GetDefaultBranch {
repo: self._fields.0.unwrap(),
}
}
}
pub mod signature_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Name;
type When;
type Email;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type When = Unset;
type Email = Unset;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Name = Set<members::name>;
type When = St::When;
type Email = St::Email;
}
pub struct SetWhen<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetWhen<St> {}
impl<St: State> State for SetWhen<St> {
type Name = St::Name;
type When = Set<members::when>;
type Email = St::Email;
}
pub struct SetEmail<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetEmail<St> {}
impl<St: State> State for SetEmail<St> {
type Name = St::Name;
type When = St::When;
type Email = Set<members::email>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct when(());
pub struct email(());
}
}
pub struct SignatureBuilder<S: BosStr, St: signature_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<S>, Option<Datetime>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Signature<S> {
pub fn new() -> SignatureBuilder<S, signature_state::Empty> {
SignatureBuilder::new()
}
}
impl<S: BosStr> SignatureBuilder<S, signature_state::Empty> {
pub fn new() -> Self {
SignatureBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::Email: signature_state::IsUnset,
{
pub fn email(
mut self,
value: impl Into<S>,
) -> SignatureBuilder<S, signature_state::SetEmail<St>> {
self._fields.0 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::Name: signature_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> SignatureBuilder<S, signature_state::SetName<St>> {
self._fields.1 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::When: signature_state::IsUnset,
{
pub fn when(
mut self,
value: impl Into<Datetime>,
) -> SignatureBuilder<S, signature_state::SetWhen<St>> {
self._fields.2 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::Name: signature_state::IsSet,
St::When: signature_state::IsSet,
St::Email: signature_state::IsSet,
{
pub fn build(self) -> Signature<S> {
Signature {
email: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
when: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Signature<S> {
Signature {
email: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
when: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_tangled_repo_getDefaultBranch() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("sh.tangled.repo.getDefaultBranch"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(LexXrpcQueryParameter::Params(LexXrpcParameters {
required: Some(vec![SmolStr::new_static("repo")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("repo"),
LexXrpcParametersProperty::String(LexString {
description: Some(CowStr::new_static(
"Repository identifier in format 'did:plc:.../repoName'",
)),
..Default::default()
}),
);
map
},
..Default::default()
})),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("signature"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("name"),
SmolStr::new_static("email"),
SmolStr::new_static("when"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("email"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Author email")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Author name")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("when"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Author timestamp")),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}