#[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::AtUri;
use jacquard_derive::{IntoStatic, lexicon};
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::git::temp::analyze_merge;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ConflictInfo<'a> {
#[serde(borrow)]
pub filename: CowStr<'a>,
#[serde(borrow)]
pub reason: CowStr<'a>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct AnalyzeMerge<'a> {
#[serde(borrow)]
pub branch: CowStr<'a>,
#[serde(borrow)]
pub patch: CowStr<'a>,
#[serde(borrow)]
pub repo: AtUri<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct AnalyzeMergeOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub conflicts: Option<Vec<analyze_merge::ConflictInfo<'a>>>,
pub is_conflicted: bool,
}
impl<'a> LexiconSchema for ConflictInfo<'a> {
fn nsid() -> &'static str {
"sh.tangled.git.temp.analyzeMerge"
}
fn def_name() -> &'static str {
"conflictInfo"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_temp_analyzeMerge()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct AnalyzeMergeResponse;
impl jacquard_common::xrpc::XrpcResp for AnalyzeMergeResponse {
const NSID: &'static str = "sh.tangled.git.temp.analyzeMerge";
const ENCODING: &'static str = "application/json";
type Output<'de> = AnalyzeMergeOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for AnalyzeMerge<'a> {
const NSID: &'static str = "sh.tangled.git.temp.analyzeMerge";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = AnalyzeMergeResponse;
}
pub struct AnalyzeMergeRequest;
impl jacquard_common::xrpc::XrpcEndpoint for AnalyzeMergeRequest {
const PATH: &'static str = "/xrpc/sh.tangled.git.temp.analyzeMerge";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = AnalyzeMerge<'de>;
type Response = AnalyzeMergeResponse;
}
fn lexicon_doc_sh_tangled_git_temp_analyzeMerge() -> 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.git.temp.analyzeMerge"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("conflictInfo"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("filename"),
SmolStr::new_static("reason")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("filename"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Name of the conflicted file"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("reason"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Reason for the conflict"),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(
LexXrpcQueryParameter::Params(LexXrpcParameters {
required: Some(
vec![
SmolStr::new_static("repo"), SmolStr::new_static("patch"),
SmolStr::new_static("branch")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("branch"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static("Target branch to merge into"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("patch"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"Patch or pull request to check for merge conflicts",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("repo"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static("AT-URI of the repository"),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod analyze_merge_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 Branch;
type Repo;
type Patch;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Branch = Unset;
type Repo = Unset;
type Patch = Unset;
}
pub struct SetBranch<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetBranch<S> {}
impl<S: State> State for SetBranch<S> {
type Branch = Set<members::branch>;
type Repo = S::Repo;
type Patch = S::Patch;
}
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 Branch = S::Branch;
type Repo = Set<members::repo>;
type Patch = S::Patch;
}
pub struct SetPatch<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPatch<S> {}
impl<S: State> State for SetPatch<S> {
type Branch = S::Branch;
type Repo = S::Repo;
type Patch = Set<members::patch>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct branch(());
pub struct repo(());
pub struct patch(());
}
}
pub struct AnalyzeMergeBuilder<'a, S: analyze_merge_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<CowStr<'a>>, Option<AtUri<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> AnalyzeMerge<'a> {
pub fn new() -> AnalyzeMergeBuilder<'a, analyze_merge_state::Empty> {
AnalyzeMergeBuilder::new()
}
}
impl<'a> AnalyzeMergeBuilder<'a, analyze_merge_state::Empty> {
pub fn new() -> Self {
AnalyzeMergeBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> AnalyzeMergeBuilder<'a, S>
where
S: analyze_merge_state::State,
S::Branch: analyze_merge_state::IsUnset,
{
pub fn branch(
mut self,
value: impl Into<CowStr<'a>>,
) -> AnalyzeMergeBuilder<'a, analyze_merge_state::SetBranch<S>> {
self._fields.0 = Option::Some(value.into());
AnalyzeMergeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> AnalyzeMergeBuilder<'a, S>
where
S: analyze_merge_state::State,
S::Patch: analyze_merge_state::IsUnset,
{
pub fn patch(
mut self,
value: impl Into<CowStr<'a>>,
) -> AnalyzeMergeBuilder<'a, analyze_merge_state::SetPatch<S>> {
self._fields.1 = Option::Some(value.into());
AnalyzeMergeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> AnalyzeMergeBuilder<'a, S>
where
S: analyze_merge_state::State,
S::Repo: analyze_merge_state::IsUnset,
{
pub fn repo(
mut self,
value: impl Into<AtUri<'a>>,
) -> AnalyzeMergeBuilder<'a, analyze_merge_state::SetRepo<S>> {
self._fields.2 = Option::Some(value.into());
AnalyzeMergeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> AnalyzeMergeBuilder<'a, S>
where
S: analyze_merge_state::State,
S::Branch: analyze_merge_state::IsSet,
S::Repo: analyze_merge_state::IsSet,
S::Patch: analyze_merge_state::IsSet,
{
pub fn build(self) -> AnalyzeMerge<'a> {
AnalyzeMerge {
branch: self._fields.0.unwrap(),
patch: self._fields.1.unwrap(),
repo: self._fields.2.unwrap(),
}
}
}