#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
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::app_bsky::actor::ProfileViewBasic;
use crate::sh_weaver::actor::ProfileView;
use crate::sh_weaver::notebook::authors;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct AuthorListItem<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub profile: Option<AuthorListItemProfile<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum AuthorListItemProfile<S: BosStr = DefaultStr> {
#[serde(rename = "app.bsky.actor.defs#profileViewBasic")]
ProfileViewBasic(Box<ProfileViewBasic<S>>),
#[serde(rename = "sh.weaver.actor.defs#profileView")]
ProfileView(Box<ProfileView<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "sh.weaver.notebook.authors",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Authors<S: BosStr = DefaultStr> {
pub author_list: Vec<authors::AuthorListItem<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<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, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct AuthorsGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Authors<S>,
}
impl<S: BosStr> Authors<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, AuthorsRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for AuthorListItem<S> {
fn nsid() -> &'static str {
"sh.weaver.notebook.authors"
}
fn def_name() -> &'static str {
"authorListItem"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_authors()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AuthorsRecord;
impl XrpcResp for AuthorsRecord {
const NSID: &'static str = "sh.weaver.notebook.authors";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = AuthorsGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<AuthorsGetRecordOutput<S>> for Authors<S> {
fn from(output: AuthorsGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Authors<S> {
const NSID: &'static str = "sh.weaver.notebook.authors";
type Record = AuthorsRecord;
}
impl Collection for AuthorsRecord {
const NSID: &'static str = "sh.weaver.notebook.authors";
type Record = AuthorsRecord;
}
impl<S: BosStr> LexiconSchema for Authors<S> {
fn nsid() -> &'static str {
"sh.weaver.notebook.authors"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_authors()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod author_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 ProfileIndex;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ProfileIndex = Unset;
}
pub struct SetProfileIndex<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetProfileIndex<St> {}
impl<St: State> State for SetProfileIndex<St> {
type ProfileIndex = Set<members::profile_index>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct profile_index(());
}
}
pub struct AuthorListItemBuilder<S: BosStr, St: author_list_item_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<AuthorListItemProfile<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> AuthorListItem<S> {
pub fn new() -> AuthorListItemBuilder<S, author_list_item_state::Empty> {
AuthorListItemBuilder::new()
}
}
impl<S: BosStr> AuthorListItemBuilder<S, author_list_item_state::Empty> {
pub fn new() -> Self {
AuthorListItemBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: author_list_item_state::State> AuthorListItemBuilder<S, St> {
pub fn index(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_index(mut self, value: Option<i64>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: author_list_item_state::State> AuthorListItemBuilder<S, St> {
pub fn profile(
mut self,
value: impl Into<Option<AuthorListItemProfile<S>>>,
) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_profile(mut self, value: Option<AuthorListItemProfile<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> AuthorListItemBuilder<S, St>
where
St: author_list_item_state::State,
St::ProfileIndex: author_list_item_state::IsSet,
{
pub fn build(self) -> AuthorListItem<S> {
AuthorListItem {
index: self._fields.0,
profile: self._fields.1,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> AuthorListItem<S> {
AuthorListItem {
index: self._fields.0,
profile: self._fields.1,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_weaver_notebook_authors() -> 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.weaver.notebook.authors"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("authorListItem"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("A single author in a Weaver notebook."),
),
required: Some(vec![SmolStr::new_static("profile, index")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("index"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("profile"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("app.bsky.actor.defs#profileViewBasic"),
CowStr::new_static("sh.weaver.actor.defs#profileView")
],
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static("Authors of a Weaver notebook."),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(vec![SmolStr::new_static("authorList")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("authorList"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#authorListItem"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod authors_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 AuthorList;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type AuthorList = Unset;
}
pub struct SetAuthorList<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAuthorList<St> {}
impl<St: State> State for SetAuthorList<St> {
type AuthorList = Set<members::author_list>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct author_list(());
}
}
pub struct AuthorsBuilder<S: BosStr, St: authors_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<authors::AuthorListItem<S>>>, Option<Datetime>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Authors<S> {
pub fn new() -> AuthorsBuilder<S, authors_state::Empty> {
AuthorsBuilder::new()
}
}
impl<S: BosStr> AuthorsBuilder<S, authors_state::Empty> {
pub fn new() -> Self {
AuthorsBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AuthorsBuilder<S, St>
where
St: authors_state::State,
St::AuthorList: authors_state::IsUnset,
{
pub fn author_list(
mut self,
value: impl Into<Vec<authors::AuthorListItem<S>>>,
) -> AuthorsBuilder<S, authors_state::SetAuthorList<St>> {
self._fields.0 = Option::Some(value.into());
AuthorsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: authors_state::State> AuthorsBuilder<S, St> {
pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> AuthorsBuilder<S, St>
where
St: authors_state::State,
St::AuthorList: authors_state::IsSet,
{
pub fn build(self) -> Authors<S> {
Authors {
author_list: self._fields.0.unwrap(),
created_at: self._fields.1,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Authors<S> {
Authors {
author_list: self._fields.0.unwrap(),
created_at: self._fields.1,
extra_data: Some(extra_data),
}
}
}