#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, 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::{Did, AtUri, Cid, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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::list_issues;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct IssueListItem<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub comment_count: i64,
pub state: IssueListItemState<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub state_updated_at: Option<Datetime>,
pub uri: AtUri<S>,
pub value: Data<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum IssueListItemState<S: BosStr = DefaultStr> {
Open,
Closed,
Other(S),
}
impl<S: BosStr> IssueListItemState<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Open => "open",
Self::Closed => "closed",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"open" => Self::Open,
"closed" => Self::Closed,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for IssueListItemState<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for IssueListItemState<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for IssueListItemState<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for IssueListItemState<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for IssueListItemState<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for IssueListItemState<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = IssueListItemState<S::Output>;
fn into_static(self) -> Self::Output {
match self {
IssueListItemState::Open => IssueListItemState::Open,
IssueListItemState::Closed => IssueListItemState::Closed,
IssueListItemState::Other(v) => IssueListItemState::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListIssues<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub author: Option<Did<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<S>,
#[serde(default = "_default_limit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(default = "_default_order")]
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<S>,
pub subject: Did<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListIssuesOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<S>,
pub items: Vec<list_issues::IssueListItem<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for IssueListItem<S> {
fn nsid() -> &'static str {
"sh.tangled.repo.listIssues"
}
fn def_name() -> &'static str {
"issueListItem"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_repo_listIssues()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.comment_count;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("comment_count"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
pub struct ListIssuesResponse;
impl jacquard_common::xrpc::XrpcResp for ListIssuesResponse {
const NSID: &'static str = "sh.tangled.repo.listIssues";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ListIssuesOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for ListIssues<S> {
const NSID: &'static str = "sh.tangled.repo.listIssues";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = ListIssuesResponse;
}
pub struct ListIssuesRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ListIssuesRequest {
const PATH: &'static str = "/xrpc/sh.tangled.repo.listIssues";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = ListIssues<S>;
type Response = ListIssuesResponse;
}
pub mod issue_list_item_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 CommentCount;
type State;
type Uri;
type Value;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CommentCount = Unset;
type State = Unset;
type Uri = Unset;
type Value = Unset;
}
pub struct SetCommentCount<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCommentCount<St> {}
impl<St: State> State for SetCommentCount<St> {
type CommentCount = Set<members::comment_count>;
type State = St::State;
type Uri = St::Uri;
type Value = St::Value;
}
pub struct SetState<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetState<St> {}
impl<St: State> State for SetState<St> {
type CommentCount = St::CommentCount;
type State = Set<members::state>;
type Uri = St::Uri;
type Value = St::Value;
}
pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUri<St> {}
impl<St: State> State for SetUri<St> {
type CommentCount = St::CommentCount;
type State = St::State;
type Uri = Set<members::uri>;
type Value = St::Value;
}
pub struct SetValue<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetValue<St> {}
impl<St: State> State for SetValue<St> {
type CommentCount = St::CommentCount;
type State = St::State;
type Uri = St::Uri;
type Value = Set<members::value>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct comment_count(());
pub struct state(());
pub struct uri(());
pub struct value(());
}
}
pub struct IssueListItemBuilder<
St: issue_list_item_state::State,
S: BosStr = DefaultStr,
> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Cid<S>>,
Option<i64>,
Option<IssueListItemState<S>>,
Option<Datetime>,
Option<AtUri<S>>,
Option<Data<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl IssueListItem<DefaultStr> {
pub fn new() -> IssueListItemBuilder<issue_list_item_state::Empty, DefaultStr> {
IssueListItemBuilder::new()
}
}
impl<S: BosStr> IssueListItem<S> {
pub fn builder() -> IssueListItemBuilder<issue_list_item_state::Empty, S> {
IssueListItemBuilder::builder()
}
}
impl IssueListItemBuilder<issue_list_item_state::Empty, DefaultStr> {
pub fn new() -> Self {
IssueListItemBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> IssueListItemBuilder<issue_list_item_state::Empty, S> {
pub fn builder() -> Self {
IssueListItemBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<St: issue_list_item_state::State, S: BosStr> IssueListItemBuilder<St, S> {
pub fn cid(mut self, value: impl Into<Option<Cid<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_cid(mut self, value: Option<Cid<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<St, S: BosStr> IssueListItemBuilder<St, S>
where
St: issue_list_item_state::State,
St::CommentCount: issue_list_item_state::IsUnset,
{
pub fn comment_count(
mut self,
value: impl Into<i64>,
) -> IssueListItemBuilder<issue_list_item_state::SetCommentCount<St>, S> {
self._fields.1 = Option::Some(value.into());
IssueListItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> IssueListItemBuilder<St, S>
where
St: issue_list_item_state::State,
St::State: issue_list_item_state::IsUnset,
{
pub fn state(
mut self,
value: impl Into<IssueListItemState<S>>,
) -> IssueListItemBuilder<issue_list_item_state::SetState<St>, S> {
self._fields.2 = Option::Some(value.into());
IssueListItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: issue_list_item_state::State, S: BosStr> IssueListItemBuilder<St, S> {
pub fn state_updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_state_updated_at(mut self, value: Option<Datetime>) -> Self {
self._fields.3 = value;
self
}
}
impl<St, S: BosStr> IssueListItemBuilder<St, S>
where
St: issue_list_item_state::State,
St::Uri: issue_list_item_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> IssueListItemBuilder<issue_list_item_state::SetUri<St>, S> {
self._fields.4 = Option::Some(value.into());
IssueListItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> IssueListItemBuilder<St, S>
where
St: issue_list_item_state::State,
St::Value: issue_list_item_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<Data<S>>,
) -> IssueListItemBuilder<issue_list_item_state::SetValue<St>, S> {
self._fields.5 = Option::Some(value.into());
IssueListItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> IssueListItemBuilder<St, S>
where
St: issue_list_item_state::State,
St::CommentCount: issue_list_item_state::IsSet,
St::State: issue_list_item_state::IsSet,
St::Uri: issue_list_item_state::IsSet,
St::Value: issue_list_item_state::IsSet,
{
pub fn build(self) -> IssueListItem<S> {
IssueListItem {
cid: self._fields.0,
comment_count: self._fields.1.unwrap(),
state: self._fields.2.unwrap(),
state_updated_at: self._fields.3,
uri: self._fields.4.unwrap(),
value: self._fields.5.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> IssueListItem<S> {
IssueListItem {
cid: self._fields.0,
comment_count: self._fields.1.unwrap(),
state: self._fields.2.unwrap(),
state_updated_at: self._fields.3,
uri: self._fields.4.unwrap(),
value: self._fields.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_tangled_repo_listIssues() -> 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.listIssues"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("issueListItem"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("uri"), SmolStr::new_static("value"),
SmolStr::new_static("state"),
SmolStr::new_static("commentCount")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("commentCount"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("state"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Latest derived state."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("stateUpdatedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"TID-derived timestamp of the latest state record.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("value"),
LexObjectProperty::Unknown(LexUnknown {
..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("subject")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("author"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"Restrict to issues authored by this user DID.",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cursor"),
LexXrpcParametersProperty::String(LexString {
description: Some(CowStr::new_static("Pagination cursor")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("limit"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("order"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static("Sort direction by createdAt."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("state"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"Restrict to issues whose latest derived state matches.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static("Repo DID to list issues for"),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map
},
..Default::default()
}
}
fn _default_limit() -> Option<i64> {
Some(50i64)
}
fn _default_order<S: jacquard_common::FromStaticStr>() -> Option<S> {
Some(S::from_static("desc"))
}
pub mod list_issues_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 Subject;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Subject = Unset;
}
pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSubject<St> {}
impl<St: State> State for SetSubject<St> {
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct subject(());
}
}
pub struct ListIssuesBuilder<St: list_issues_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Did<S>>,
Option<S>,
Option<i64>,
Option<S>,
Option<S>,
Option<Did<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl ListIssues<DefaultStr> {
pub fn new() -> ListIssuesBuilder<list_issues_state::Empty, DefaultStr> {
ListIssuesBuilder::new()
}
}
impl<S: BosStr> ListIssues<S> {
pub fn builder() -> ListIssuesBuilder<list_issues_state::Empty, S> {
ListIssuesBuilder::builder()
}
}
impl ListIssuesBuilder<list_issues_state::Empty, DefaultStr> {
pub fn new() -> Self {
ListIssuesBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> ListIssuesBuilder<list_issues_state::Empty, S> {
pub fn builder() -> Self {
ListIssuesBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<St: list_issues_state::State, S: BosStr> ListIssuesBuilder<St, S> {
pub fn author(mut self, value: impl Into<Option<Did<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_author(mut self, value: Option<Did<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<St: list_issues_state::State, S: BosStr> ListIssuesBuilder<St, S> {
pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_cursor(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<St: list_issues_state::State, S: BosStr> ListIssuesBuilder<St, S> {
pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
self._fields.2 = value;
self
}
}
impl<St: list_issues_state::State, S: BosStr> ListIssuesBuilder<St, S> {
pub fn order(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_order(mut self, value: Option<S>) -> Self {
self._fields.3 = value;
self
}
}
impl<St: list_issues_state::State, S: BosStr> ListIssuesBuilder<St, S> {
pub fn state(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_state(mut self, value: Option<S>) -> Self {
self._fields.4 = value;
self
}
}
impl<St, S: BosStr> ListIssuesBuilder<St, S>
where
St: list_issues_state::State,
St::Subject: list_issues_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<Did<S>>,
) -> ListIssuesBuilder<list_issues_state::SetSubject<St>, S> {
self._fields.5 = Option::Some(value.into());
ListIssuesBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ListIssuesBuilder<St, S>
where
St: list_issues_state::State,
St::Subject: list_issues_state::IsSet,
{
pub fn build(self) -> ListIssues<S> {
ListIssues {
author: self._fields.0,
cursor: self._fields.1,
limit: self._fields.2,
order: self._fields.3,
state: self._fields.4,
subject: self._fields.5.unwrap(),
}
}
}