#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::Datetime;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::sh_tangled::repo::get_default_branch;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetDefaultBranch<'a> {
#[serde(borrow)]
pub repo: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetDefaultBranchOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub author: Option<get_default_branch::Signature<'a>>,
#[serde(borrow)]
pub hash: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub message: Option<CowStr<'a>>,
#[serde(borrow)]
pub name: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub short_hash: Option<CowStr<'a>>,
pub when: Datetime,
}
#[open_union]
#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
Eq,
thiserror::Error,
miette::Diagnostic,
IntoStatic
)]
#[serde(tag = "error", content = "message")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum GetDefaultBranchError<'a> {
#[serde(rename = "RepoNotFound")]
RepoNotFound(Option<CowStr<'a>>),
#[serde(rename = "InvalidRequest")]
InvalidRequest(Option<CowStr<'a>>),
}
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::Unknown(err) => write!(f, "Unknown error: {:?}", err),
}
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Signature<'a> {
#[serde(borrow)]
pub email: CowStr<'a>,
#[serde(borrow)]
pub name: CowStr<'a>,
pub when: Datetime,
}
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<'de> = GetDefaultBranchOutput<'de>;
type Err<'de> = GetDefaultBranchError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetDefaultBranch<'a> {
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<'de> = GetDefaultBranch<'de>;
type Response = GetDefaultBranchResponse;
}
impl<'a> LexiconSchema for Signature<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRepo<S> {}
impl<S: State> State for SetRepo<S> {
type Repo = Set<members::repo>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct repo(());
}
}
pub struct GetDefaultBranchBuilder<'a, S: get_default_branch_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GetDefaultBranch<'a> {
pub fn new() -> GetDefaultBranchBuilder<'a, get_default_branch_state::Empty> {
GetDefaultBranchBuilder::new()
}
}
impl<'a> GetDefaultBranchBuilder<'a, get_default_branch_state::Empty> {
pub fn new() -> Self {
GetDefaultBranchBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetDefaultBranchBuilder<'a, S>
where
S: get_default_branch_state::State,
S::Repo: get_default_branch_state::IsUnset,
{
pub fn repo(
mut self,
value: impl Into<CowStr<'a>>,
) -> GetDefaultBranchBuilder<'a, get_default_branch_state::SetRepo<S>> {
self._fields.0 = Option::Some(value.into());
GetDefaultBranchBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetDefaultBranchBuilder<'a, S>
where
S: get_default_branch_state::State,
S::Repo: get_default_branch_state::IsSet,
{
pub fn build(self) -> GetDefaultBranch<'a> {
GetDefaultBranch {
repo: self._fields.0.unwrap(),
}
}
}
pub mod signature_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type When;
type Email;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type When = Unset;
type Email = Unset;
type Name = Unset;
}
pub struct SetWhen<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetWhen<S> {}
impl<S: State> State for SetWhen<S> {
type When = Set<members::when>;
type Email = S::Email;
type Name = S::Name;
}
pub struct SetEmail<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetEmail<S> {}
impl<S: State> State for SetEmail<S> {
type When = S::When;
type Email = Set<members::email>;
type Name = S::Name;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type When = S::When;
type Email = S::Email;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct when(());
pub struct email(());
pub struct name(());
}
}
pub struct SignatureBuilder<'a, S: signature_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<CowStr<'a>>, Option<Datetime>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Signature<'a> {
pub fn new() -> SignatureBuilder<'a, signature_state::Empty> {
SignatureBuilder::new()
}
}
impl<'a> SignatureBuilder<'a, signature_state::Empty> {
pub fn new() -> Self {
SignatureBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::Email: signature_state::IsUnset,
{
pub fn email(
mut self,
value: impl Into<CowStr<'a>>,
) -> SignatureBuilder<'a, signature_state::SetEmail<S>> {
self._fields.0 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::Name: signature_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> SignatureBuilder<'a, signature_state::SetName<S>> {
self._fields.1 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::When: signature_state::IsUnset,
{
pub fn when(
mut self,
value: impl Into<Datetime>,
) -> SignatureBuilder<'a, signature_state::SetWhen<S>> {
self._fields.2 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::When: signature_state::IsSet,
S::Email: signature_state::IsSet,
S::Name: signature_state::IsSet,
{
pub fn build(self) -> Signature<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Signature<'a> {
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> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
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()
}
}