// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: sh.weaver.graph.defs
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

pub mod bookmark;
pub mod follow;
pub mod follow_accept;
pub mod follow_gate;
pub mod get_actor_bookmarks;
pub mod get_actor_likes;
pub mod get_actor_lists;
pub mod get_actor_subscriptions;
pub mod get_bookmarked_by;
pub mod get_followers;
pub mod get_following;
pub mod get_liked_by;
pub mod get_list;
pub mod get_popular_tags;
pub mod get_resource_tags;
pub mod get_subscribers;
pub mod get_tag_suggestions;
pub mod get_tagged_resources;
pub mod get_trending_tags;
pub mod like;
pub mod list;
pub mod listitem;
pub mod subscribe;
pub mod subscribe_accept;
pub mod tag;


#[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, Cid, Datetime, UriValue};
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::com_atproto::repo::strong_ref::StrongRef;
use crate::sh_weaver::actor::ProfileViewBasic;
use crate::sh_weaver::notebook::EntryView;
use crate::sh_weaver::notebook::NotebookView;
use crate::sh_weaver::graph;
/// A community tag with how many people applied it.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CommunityTagCount<'a> {
    pub count: i64,
    #[serde(borrow)]
    pub tag: CowStr<'a>,
}

/// A curated collection of notebooks/entries for sharing.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Curatelist;
impl core::fmt::Display for Curatelist {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "curatelist")
    }
}

/// An item in a list with hydrated subject.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ListItemView<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub added_at: Option<Datetime>,
    #[serde(borrow)]
    pub subject: ListItemViewSubject<'a>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum ListItemViewSubject<'a> {
    #[serde(rename = "sh.weaver.notebook.defs#notebookView")]
    NotebookView(Box<NotebookView<'a>>),
    #[serde(rename = "sh.weaver.notebook.defs#entryView")]
    EntryView(Box<EntryView<'a>>),
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ListPurpose<'a> {
    ShWeaverGraphDefsCuratelist,
    ShWeaverGraphDefsReadinglist,
    ShWeaverGraphDefsSerieslist,
    Other(CowStr<'a>),
}

impl<'a> ListPurpose<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::ShWeaverGraphDefsCuratelist => "sh.weaver.graph.defs#curatelist",
            Self::ShWeaverGraphDefsReadinglist => "sh.weaver.graph.defs#readinglist",
            Self::ShWeaverGraphDefsSerieslist => "sh.weaver.graph.defs#serieslist",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for ListPurpose<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "sh.weaver.graph.defs#curatelist" => Self::ShWeaverGraphDefsCuratelist,
            "sh.weaver.graph.defs#readinglist" => Self::ShWeaverGraphDefsReadinglist,
            "sh.weaver.graph.defs#serieslist" => Self::ShWeaverGraphDefsSerieslist,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for ListPurpose<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "sh.weaver.graph.defs#curatelist" => Self::ShWeaverGraphDefsCuratelist,
            "sh.weaver.graph.defs#readinglist" => Self::ShWeaverGraphDefsReadinglist,
            "sh.weaver.graph.defs#serieslist" => Self::ShWeaverGraphDefsSerieslist,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> AsRef<str> for ListPurpose<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<'a> core::fmt::Display for ListPurpose<'a> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<'a> serde::Serialize for ListPurpose<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for ListPurpose<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl jacquard_common::IntoStatic for ListPurpose<'_> {
    type Output = ListPurpose<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            ListPurpose::ShWeaverGraphDefsCuratelist => {
                ListPurpose::ShWeaverGraphDefsCuratelist
            }
            ListPurpose::ShWeaverGraphDefsReadinglist => {
                ListPurpose::ShWeaverGraphDefsReadinglist
            }
            ListPurpose::ShWeaverGraphDefsSerieslist => {
                ListPurpose::ShWeaverGraphDefsSerieslist
            }
            ListPurpose::Other(v) => ListPurpose::Other(v.into_static()),
        }
    }
}

/// Hydrated view of a list.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ListView<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub avatar: Option<UriValue<'a>>,
    #[serde(borrow)]
    pub cid: Cid<'a>,
    #[serde(borrow)]
    pub creator: ProfileViewBasic<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub description: Option<CowStr<'a>>,
    pub indexed_at: Datetime,
    pub item_count: i64,
    #[serde(borrow)]
    pub name: CowStr<'a>,
    #[serde(borrow)]
    pub purpose: graph::ListPurpose<'a>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub viewer_subscribed: Option<AtUri<'a>>,
}

/// A personal reading list.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Readinglist;
impl core::fmt::Display for Readinglist {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "readinglist")
    }
}

/// All tags for a resource, grouped by source.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ResourceTagsView<'a> {
    ///Tags from the record itself (author-applied).
    #[serde(borrow)]
    pub author_tags: Vec<CowStr<'a>>,
    ///Aggregated community-applied tags with counts.
    #[serde(borrow)]
    pub community_tags: Vec<graph::CommunityTagCount<'a>>,
    #[serde(borrow)]
    pub resource: StrongRef<'a>,
    ///Tags the current viewer has applied.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub viewer_applied_tags: Option<Vec<CowStr<'a>>>,
}

/// An ordered series of related works (sequels, spin-offs).

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Serieslist;
impl core::fmt::Display for Serieslist {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "serieslist")
    }
}

/// A single tag application with who applied it.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct TagApplicationView<'a> {
    #[serde(borrow)]
    pub applied_by: ProfileViewBasic<'a>,
    pub created_at: Datetime,
    #[serde(borrow)]
    pub tag: CowStr<'a>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
}

/// Aggregated view of a tag with usage statistics.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct TagView<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub entry_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub notebook_count: Option<i64>,
    ///Uses in the last 30 days.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recent_use_count: Option<i64>,
    #[serde(borrow)]
    pub tag: CowStr<'a>,
    ///Appview-computed trending score.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub trending_score: Option<i64>,
    ///Total number of resources tagged with this tag.
    pub use_count: i64,
}

impl<'a> LexiconSchema for CommunityTagCount<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "communityTagCount"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for ListItemView<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "listItemView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for ListView<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "listView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for ResourceTagsView<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "resourceTagsView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for TagApplicationView<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "tagApplicationView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for TagView<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "tagView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod community_tag_count_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Count;
        type Tag;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Count = Unset;
        type Tag = Unset;
    }
    ///State transition - sets the `count` field to Set
    pub struct SetCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCount<S> {}
    impl<S: State> State for SetCount<S> {
        type Count = Set<members::count>;
        type Tag = S::Tag;
    }
    ///State transition - sets the `tag` field to Set
    pub struct SetTag<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTag<S> {}
    impl<S: State> State for SetTag<S> {
        type Count = S::Count;
        type Tag = Set<members::tag>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `count` field
        pub struct count(());
        ///Marker type for the `tag` field
        pub struct tag(());
    }
}

/// Builder for constructing an instance of this type
pub struct CommunityTagCountBuilder<'a, S: community_tag_count_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<i64>, Option<CowStr<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> CommunityTagCount<'a> {
    /// Create a new builder for this type
    pub fn new() -> CommunityTagCountBuilder<'a, community_tag_count_state::Empty> {
        CommunityTagCountBuilder::new()
    }
}

impl<'a> CommunityTagCountBuilder<'a, community_tag_count_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        CommunityTagCountBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CommunityTagCountBuilder<'a, S>
where
    S: community_tag_count_state::State,
    S::Count: community_tag_count_state::IsUnset,
{
    /// Set the `count` field (required)
    pub fn count(
        mut self,
        value: impl Into<i64>,
    ) -> CommunityTagCountBuilder<'a, community_tag_count_state::SetCount<S>> {
        self._fields.0 = Option::Some(value.into());
        CommunityTagCountBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CommunityTagCountBuilder<'a, S>
where
    S: community_tag_count_state::State,
    S::Tag: community_tag_count_state::IsUnset,
{
    /// Set the `tag` field (required)
    pub fn tag(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> CommunityTagCountBuilder<'a, community_tag_count_state::SetTag<S>> {
        self._fields.1 = Option::Some(value.into());
        CommunityTagCountBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CommunityTagCountBuilder<'a, S>
where
    S: community_tag_count_state::State,
    S::Count: community_tag_count_state::IsSet,
    S::Tag: community_tag_count_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> CommunityTagCount<'a> {
        CommunityTagCount {
            count: self._fields.0.unwrap(),
            tag: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> CommunityTagCount<'a> {
        CommunityTagCount {
            count: self._fields.0.unwrap(),
            tag: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_sh_weaver_graph_defs() -> 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.graph.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("communityTagCount"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A community tag with how many people applied it.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("tag"), SmolStr::new_static("count")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("count"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("tag"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("curatelist"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("listItemView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("An item in a list with hydrated subject."),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("uri"), SmolStr::new_static("subject")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("addedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("subject"),
                            LexObjectProperty::Union(LexRefUnion {
                                refs: vec![
                                    CowStr::new_static("sh.weaver.notebook.defs#notebookView"),
                                    CowStr::new_static("sh.weaver.notebook.defs#entryView")
                                ],
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("listPurpose"),
                LexUserType::String(LexString { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("listView"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("Hydrated view of a list.")),
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("creator"), SmolStr::new_static("name"),
                            SmolStr::new_static("purpose"),
                            SmolStr::new_static("itemCount"),
                            SmolStr::new_static("indexedAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("avatar"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("creator"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("itemCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("purpose"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#listPurpose"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("viewerSubscribed"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("readinglist"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("resourceTagsView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("All tags for a resource, grouped by source."),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("resource"),
                            SmolStr::new_static("authorTags"),
                            SmolStr::new_static("communityTags")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("authorTags"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Tags from the record itself (author-applied).",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("communityTags"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Aggregated community-applied tags with counts.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#communityTagCount"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("resource"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("viewerAppliedTags"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static("Tags the current viewer has applied."),
                                ),
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("serieslist"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("tagApplicationView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A single tag application with who applied it.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("tag"),
                            SmolStr::new_static("appliedBy"),
                            SmolStr::new_static("createdAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("appliedBy"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("tag"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("tagView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Aggregated view of a tag with usage statistics.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("tag"), SmolStr::new_static("useCount")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("entryCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("notebookCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("recentUseCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("tag"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("trendingScore"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("useCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod list_item_view_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Subject;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Subject = Unset;
        type Uri = Unset;
    }
    ///State transition - sets the `subject` field to Set
    pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSubject<S> {}
    impl<S: State> State for SetSubject<S> {
        type Subject = Set<members::subject>;
        type Uri = S::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type Subject = S::Subject;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `subject` field
        pub struct subject(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type
pub struct ListItemViewBuilder<'a, S: list_item_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Datetime>, Option<ListItemViewSubject<'a>>, Option<AtUri<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> ListItemView<'a> {
    /// Create a new builder for this type
    pub fn new() -> ListItemViewBuilder<'a, list_item_view_state::Empty> {
        ListItemViewBuilder::new()
    }
}

impl<'a> ListItemViewBuilder<'a, list_item_view_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        ListItemViewBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: list_item_view_state::State> ListItemViewBuilder<'a, S> {
    /// Set the `addedAt` field (optional)
    pub fn added_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `addedAt` field to an Option value (optional)
    pub fn maybe_added_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> ListItemViewBuilder<'a, S>
where
    S: list_item_view_state::State,
    S::Subject: list_item_view_state::IsUnset,
{
    /// Set the `subject` field (required)
    pub fn subject(
        mut self,
        value: impl Into<ListItemViewSubject<'a>>,
    ) -> ListItemViewBuilder<'a, list_item_view_state::SetSubject<S>> {
        self._fields.1 = Option::Some(value.into());
        ListItemViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ListItemViewBuilder<'a, S>
where
    S: list_item_view_state::State,
    S::Uri: list_item_view_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> ListItemViewBuilder<'a, list_item_view_state::SetUri<S>> {
        self._fields.2 = Option::Some(value.into());
        ListItemViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ListItemViewBuilder<'a, S>
where
    S: list_item_view_state::State,
    S::Subject: list_item_view_state::IsSet,
    S::Uri: list_item_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ListItemView<'a> {
        ListItemView {
            added_at: self._fields.0,
            subject: self._fields.1.unwrap(),
            uri: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> ListItemView<'a> {
        ListItemView {
            added_at: self._fields.0,
            subject: self._fields.1.unwrap(),
            uri: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod list_view_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Cid;
        type Uri;
        type Name;
        type Creator;
        type ItemCount;
        type IndexedAt;
        type Purpose;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Cid = Unset;
        type Uri = Unset;
        type Name = Unset;
        type Creator = Unset;
        type ItemCount = Unset;
        type IndexedAt = Unset;
        type Purpose = Unset;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCid<S> {}
    impl<S: State> State for SetCid<S> {
        type Cid = Set<members::cid>;
        type Uri = S::Uri;
        type Name = S::Name;
        type Creator = S::Creator;
        type ItemCount = S::ItemCount;
        type IndexedAt = S::IndexedAt;
        type Purpose = S::Purpose;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type Cid = S::Cid;
        type Uri = Set<members::uri>;
        type Name = S::Name;
        type Creator = S::Creator;
        type ItemCount = S::ItemCount;
        type IndexedAt = S::IndexedAt;
        type Purpose = S::Purpose;
    }
    ///State transition - sets the `name` field to Set
    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 Cid = S::Cid;
        type Uri = S::Uri;
        type Name = Set<members::name>;
        type Creator = S::Creator;
        type ItemCount = S::ItemCount;
        type IndexedAt = S::IndexedAt;
        type Purpose = S::Purpose;
    }
    ///State transition - sets the `creator` field to Set
    pub struct SetCreator<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreator<S> {}
    impl<S: State> State for SetCreator<S> {
        type Cid = S::Cid;
        type Uri = S::Uri;
        type Name = S::Name;
        type Creator = Set<members::creator>;
        type ItemCount = S::ItemCount;
        type IndexedAt = S::IndexedAt;
        type Purpose = S::Purpose;
    }
    ///State transition - sets the `item_count` field to Set
    pub struct SetItemCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetItemCount<S> {}
    impl<S: State> State for SetItemCount<S> {
        type Cid = S::Cid;
        type Uri = S::Uri;
        type Name = S::Name;
        type Creator = S::Creator;
        type ItemCount = Set<members::item_count>;
        type IndexedAt = S::IndexedAt;
        type Purpose = S::Purpose;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
    impl<S: State> State for SetIndexedAt<S> {
        type Cid = S::Cid;
        type Uri = S::Uri;
        type Name = S::Name;
        type Creator = S::Creator;
        type ItemCount = S::ItemCount;
        type IndexedAt = Set<members::indexed_at>;
        type Purpose = S::Purpose;
    }
    ///State transition - sets the `purpose` field to Set
    pub struct SetPurpose<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetPurpose<S> {}
    impl<S: State> State for SetPurpose<S> {
        type Cid = S::Cid;
        type Uri = S::Uri;
        type Name = S::Name;
        type Creator = S::Creator;
        type ItemCount = S::ItemCount;
        type IndexedAt = S::IndexedAt;
        type Purpose = Set<members::purpose>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `creator` field
        pub struct creator(());
        ///Marker type for the `item_count` field
        pub struct item_count(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
        ///Marker type for the `purpose` field
        pub struct purpose(());
    }
}

/// Builder for constructing an instance of this type
pub struct ListViewBuilder<'a, S: list_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<UriValue<'a>>,
        Option<Cid<'a>>,
        Option<ProfileViewBasic<'a>>,
        Option<CowStr<'a>>,
        Option<Datetime>,
        Option<i64>,
        Option<CowStr<'a>>,
        Option<graph::ListPurpose<'a>>,
        Option<AtUri<'a>>,
        Option<AtUri<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> ListView<'a> {
    /// Create a new builder for this type
    pub fn new() -> ListViewBuilder<'a, list_view_state::Empty> {
        ListViewBuilder::new()
    }
}

impl<'a> ListViewBuilder<'a, list_view_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        ListViewBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: list_view_state::State> ListViewBuilder<'a, S> {
    /// Set the `avatar` field (optional)
    pub fn avatar(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `avatar` field to an Option value (optional)
    pub fn maybe_avatar(mut self, value: Option<UriValue<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> ListViewBuilder<'a, S>
where
    S: list_view_state::State,
    S::Cid: list_view_state::IsUnset,
{
    /// Set the `cid` field (required)
    pub fn cid(
        mut self,
        value: impl Into<Cid<'a>>,
    ) -> ListViewBuilder<'a, list_view_state::SetCid<S>> {
        self._fields.1 = Option::Some(value.into());
        ListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ListViewBuilder<'a, S>
where
    S: list_view_state::State,
    S::Creator: list_view_state::IsUnset,
{
    /// Set the `creator` field (required)
    pub fn creator(
        mut self,
        value: impl Into<ProfileViewBasic<'a>>,
    ) -> ListViewBuilder<'a, list_view_state::SetCreator<S>> {
        self._fields.2 = Option::Some(value.into());
        ListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: list_view_state::State> ListViewBuilder<'a, S> {
    /// Set the `description` field (optional)
    pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `description` field to an Option value (optional)
    pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S> ListViewBuilder<'a, S>
where
    S: list_view_state::State,
    S::IndexedAt: list_view_state::IsUnset,
{
    /// Set the `indexedAt` field (required)
    pub fn indexed_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> ListViewBuilder<'a, list_view_state::SetIndexedAt<S>> {
        self._fields.4 = Option::Some(value.into());
        ListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ListViewBuilder<'a, S>
where
    S: list_view_state::State,
    S::ItemCount: list_view_state::IsUnset,
{
    /// Set the `itemCount` field (required)
    pub fn item_count(
        mut self,
        value: impl Into<i64>,
    ) -> ListViewBuilder<'a, list_view_state::SetItemCount<S>> {
        self._fields.5 = Option::Some(value.into());
        ListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ListViewBuilder<'a, S>
where
    S: list_view_state::State,
    S::Name: list_view_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> ListViewBuilder<'a, list_view_state::SetName<S>> {
        self._fields.6 = Option::Some(value.into());
        ListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ListViewBuilder<'a, S>
where
    S: list_view_state::State,
    S::Purpose: list_view_state::IsUnset,
{
    /// Set the `purpose` field (required)
    pub fn purpose(
        mut self,
        value: impl Into<graph::ListPurpose<'a>>,
    ) -> ListViewBuilder<'a, list_view_state::SetPurpose<S>> {
        self._fields.7 = Option::Some(value.into());
        ListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ListViewBuilder<'a, S>
where
    S: list_view_state::State,
    S::Uri: list_view_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> ListViewBuilder<'a, list_view_state::SetUri<S>> {
        self._fields.8 = Option::Some(value.into());
        ListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: list_view_state::State> ListViewBuilder<'a, S> {
    /// Set the `viewerSubscribed` field (optional)
    pub fn viewer_subscribed(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `viewerSubscribed` field to an Option value (optional)
    pub fn maybe_viewer_subscribed(mut self, value: Option<AtUri<'a>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<'a, S> ListViewBuilder<'a, S>
where
    S: list_view_state::State,
    S::Cid: list_view_state::IsSet,
    S::Uri: list_view_state::IsSet,
    S::Name: list_view_state::IsSet,
    S::Creator: list_view_state::IsSet,
    S::ItemCount: list_view_state::IsSet,
    S::IndexedAt: list_view_state::IsSet,
    S::Purpose: list_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ListView<'a> {
        ListView {
            avatar: self._fields.0,
            cid: self._fields.1.unwrap(),
            creator: self._fields.2.unwrap(),
            description: self._fields.3,
            indexed_at: self._fields.4.unwrap(),
            item_count: self._fields.5.unwrap(),
            name: self._fields.6.unwrap(),
            purpose: self._fields.7.unwrap(),
            uri: self._fields.8.unwrap(),
            viewer_subscribed: self._fields.9,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> ListView<'a> {
        ListView {
            avatar: self._fields.0,
            cid: self._fields.1.unwrap(),
            creator: self._fields.2.unwrap(),
            description: self._fields.3,
            indexed_at: self._fields.4.unwrap(),
            item_count: self._fields.5.unwrap(),
            name: self._fields.6.unwrap(),
            purpose: self._fields.7.unwrap(),
            uri: self._fields.8.unwrap(),
            viewer_subscribed: self._fields.9,
            extra_data: Some(extra_data),
        }
    }
}

pub mod resource_tags_view_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type CommunityTags;
        type Resource;
        type AuthorTags;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CommunityTags = Unset;
        type Resource = Unset;
        type AuthorTags = Unset;
    }
    ///State transition - sets the `community_tags` field to Set
    pub struct SetCommunityTags<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCommunityTags<S> {}
    impl<S: State> State for SetCommunityTags<S> {
        type CommunityTags = Set<members::community_tags>;
        type Resource = S::Resource;
        type AuthorTags = S::AuthorTags;
    }
    ///State transition - sets the `resource` field to Set
    pub struct SetResource<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetResource<S> {}
    impl<S: State> State for SetResource<S> {
        type CommunityTags = S::CommunityTags;
        type Resource = Set<members::resource>;
        type AuthorTags = S::AuthorTags;
    }
    ///State transition - sets the `author_tags` field to Set
    pub struct SetAuthorTags<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAuthorTags<S> {}
    impl<S: State> State for SetAuthorTags<S> {
        type CommunityTags = S::CommunityTags;
        type Resource = S::Resource;
        type AuthorTags = Set<members::author_tags>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `community_tags` field
        pub struct community_tags(());
        ///Marker type for the `resource` field
        pub struct resource(());
        ///Marker type for the `author_tags` field
        pub struct author_tags(());
    }
}

/// Builder for constructing an instance of this type
pub struct ResourceTagsViewBuilder<'a, S: resource_tags_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Vec<CowStr<'a>>>,
        Option<Vec<graph::CommunityTagCount<'a>>>,
        Option<StrongRef<'a>>,
        Option<Vec<CowStr<'a>>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> ResourceTagsView<'a> {
    /// Create a new builder for this type
    pub fn new() -> ResourceTagsViewBuilder<'a, resource_tags_view_state::Empty> {
        ResourceTagsViewBuilder::new()
    }
}

impl<'a> ResourceTagsViewBuilder<'a, resource_tags_view_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        ResourceTagsViewBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ResourceTagsViewBuilder<'a, S>
where
    S: resource_tags_view_state::State,
    S::AuthorTags: resource_tags_view_state::IsUnset,
{
    /// Set the `authorTags` field (required)
    pub fn author_tags(
        mut self,
        value: impl Into<Vec<CowStr<'a>>>,
    ) -> ResourceTagsViewBuilder<'a, resource_tags_view_state::SetAuthorTags<S>> {
        self._fields.0 = Option::Some(value.into());
        ResourceTagsViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ResourceTagsViewBuilder<'a, S>
where
    S: resource_tags_view_state::State,
    S::CommunityTags: resource_tags_view_state::IsUnset,
{
    /// Set the `communityTags` field (required)
    pub fn community_tags(
        mut self,
        value: impl Into<Vec<graph::CommunityTagCount<'a>>>,
    ) -> ResourceTagsViewBuilder<'a, resource_tags_view_state::SetCommunityTags<S>> {
        self._fields.1 = Option::Some(value.into());
        ResourceTagsViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ResourceTagsViewBuilder<'a, S>
where
    S: resource_tags_view_state::State,
    S::Resource: resource_tags_view_state::IsUnset,
{
    /// Set the `resource` field (required)
    pub fn resource(
        mut self,
        value: impl Into<StrongRef<'a>>,
    ) -> ResourceTagsViewBuilder<'a, resource_tags_view_state::SetResource<S>> {
        self._fields.2 = Option::Some(value.into());
        ResourceTagsViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: resource_tags_view_state::State> ResourceTagsViewBuilder<'a, S> {
    /// Set the `viewerAppliedTags` field (optional)
    pub fn viewer_applied_tags(
        mut self,
        value: impl Into<Option<Vec<CowStr<'a>>>>,
    ) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `viewerAppliedTags` field to an Option value (optional)
    pub fn maybe_viewer_applied_tags(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S> ResourceTagsViewBuilder<'a, S>
where
    S: resource_tags_view_state::State,
    S::CommunityTags: resource_tags_view_state::IsSet,
    S::Resource: resource_tags_view_state::IsSet,
    S::AuthorTags: resource_tags_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ResourceTagsView<'a> {
        ResourceTagsView {
            author_tags: self._fields.0.unwrap(),
            community_tags: self._fields.1.unwrap(),
            resource: self._fields.2.unwrap(),
            viewer_applied_tags: self._fields.3,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> ResourceTagsView<'a> {
        ResourceTagsView {
            author_tags: self._fields.0.unwrap(),
            community_tags: self._fields.1.unwrap(),
            resource: self._fields.2.unwrap(),
            viewer_applied_tags: self._fields.3,
            extra_data: Some(extra_data),
        }
    }
}

pub mod tag_application_view_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type AppliedBy;
        type Uri;
        type CreatedAt;
        type Tag;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type AppliedBy = Unset;
        type Uri = Unset;
        type CreatedAt = Unset;
        type Tag = Unset;
    }
    ///State transition - sets the `applied_by` field to Set
    pub struct SetAppliedBy<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAppliedBy<S> {}
    impl<S: State> State for SetAppliedBy<S> {
        type AppliedBy = Set<members::applied_by>;
        type Uri = S::Uri;
        type CreatedAt = S::CreatedAt;
        type Tag = S::Tag;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type AppliedBy = S::AppliedBy;
        type Uri = Set<members::uri>;
        type CreatedAt = S::CreatedAt;
        type Tag = S::Tag;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
    impl<S: State> State for SetCreatedAt<S> {
        type AppliedBy = S::AppliedBy;
        type Uri = S::Uri;
        type CreatedAt = Set<members::created_at>;
        type Tag = S::Tag;
    }
    ///State transition - sets the `tag` field to Set
    pub struct SetTag<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTag<S> {}
    impl<S: State> State for SetTag<S> {
        type AppliedBy = S::AppliedBy;
        type Uri = S::Uri;
        type CreatedAt = S::CreatedAt;
        type Tag = Set<members::tag>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `applied_by` field
        pub struct applied_by(());
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `tag` field
        pub struct tag(());
    }
}

/// Builder for constructing an instance of this type
pub struct TagApplicationViewBuilder<'a, S: tag_application_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<ProfileViewBasic<'a>>,
        Option<Datetime>,
        Option<CowStr<'a>>,
        Option<AtUri<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> TagApplicationView<'a> {
    /// Create a new builder for this type
    pub fn new() -> TagApplicationViewBuilder<'a, tag_application_view_state::Empty> {
        TagApplicationViewBuilder::new()
    }
}

impl<'a> TagApplicationViewBuilder<'a, tag_application_view_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        TagApplicationViewBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TagApplicationViewBuilder<'a, S>
where
    S: tag_application_view_state::State,
    S::AppliedBy: tag_application_view_state::IsUnset,
{
    /// Set the `appliedBy` field (required)
    pub fn applied_by(
        mut self,
        value: impl Into<ProfileViewBasic<'a>>,
    ) -> TagApplicationViewBuilder<'a, tag_application_view_state::SetAppliedBy<S>> {
        self._fields.0 = Option::Some(value.into());
        TagApplicationViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TagApplicationViewBuilder<'a, S>
where
    S: tag_application_view_state::State,
    S::CreatedAt: tag_application_view_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> TagApplicationViewBuilder<'a, tag_application_view_state::SetCreatedAt<S>> {
        self._fields.1 = Option::Some(value.into());
        TagApplicationViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TagApplicationViewBuilder<'a, S>
where
    S: tag_application_view_state::State,
    S::Tag: tag_application_view_state::IsUnset,
{
    /// Set the `tag` field (required)
    pub fn tag(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> TagApplicationViewBuilder<'a, tag_application_view_state::SetTag<S>> {
        self._fields.2 = Option::Some(value.into());
        TagApplicationViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TagApplicationViewBuilder<'a, S>
where
    S: tag_application_view_state::State,
    S::Uri: tag_application_view_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> TagApplicationViewBuilder<'a, tag_application_view_state::SetUri<S>> {
        self._fields.3 = Option::Some(value.into());
        TagApplicationViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TagApplicationViewBuilder<'a, S>
where
    S: tag_application_view_state::State,
    S::AppliedBy: tag_application_view_state::IsSet,
    S::Uri: tag_application_view_state::IsSet,
    S::CreatedAt: tag_application_view_state::IsSet,
    S::Tag: tag_application_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> TagApplicationView<'a> {
        TagApplicationView {
            applied_by: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            tag: self._fields.2.unwrap(),
            uri: self._fields.3.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> TagApplicationView<'a> {
        TagApplicationView {
            applied_by: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            tag: self._fields.2.unwrap(),
            uri: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod tag_view_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type UseCount;
        type Tag;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type UseCount = Unset;
        type Tag = Unset;
    }
    ///State transition - sets the `use_count` field to Set
    pub struct SetUseCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUseCount<S> {}
    impl<S: State> State for SetUseCount<S> {
        type UseCount = Set<members::use_count>;
        type Tag = S::Tag;
    }
    ///State transition - sets the `tag` field to Set
    pub struct SetTag<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTag<S> {}
    impl<S: State> State for SetTag<S> {
        type UseCount = S::UseCount;
        type Tag = Set<members::tag>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `use_count` field
        pub struct use_count(());
        ///Marker type for the `tag` field
        pub struct tag(());
    }
}

/// Builder for constructing an instance of this type
pub struct TagViewBuilder<'a, S: tag_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<CowStr<'a>>,
        Option<i64>,
        Option<i64>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> TagView<'a> {
    /// Create a new builder for this type
    pub fn new() -> TagViewBuilder<'a, tag_view_state::Empty> {
        TagViewBuilder::new()
    }
}

impl<'a> TagViewBuilder<'a, tag_view_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        TagViewBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: tag_view_state::State> TagViewBuilder<'a, S> {
    /// Set the `entryCount` field (optional)
    pub fn entry_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `entryCount` field to an Option value (optional)
    pub fn maybe_entry_count(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: tag_view_state::State> TagViewBuilder<'a, S> {
    /// Set the `notebookCount` field (optional)
    pub fn notebook_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `notebookCount` field to an Option value (optional)
    pub fn maybe_notebook_count(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: tag_view_state::State> TagViewBuilder<'a, S> {
    /// Set the `recentUseCount` field (optional)
    pub fn recent_use_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `recentUseCount` field to an Option value (optional)
    pub fn maybe_recent_use_count(mut self, value: Option<i64>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S> TagViewBuilder<'a, S>
where
    S: tag_view_state::State,
    S::Tag: tag_view_state::IsUnset,
{
    /// Set the `tag` field (required)
    pub fn tag(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> TagViewBuilder<'a, tag_view_state::SetTag<S>> {
        self._fields.3 = Option::Some(value.into());
        TagViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: tag_view_state::State> TagViewBuilder<'a, S> {
    /// Set the `trendingScore` field (optional)
    pub fn trending_score(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `trendingScore` field to an Option value (optional)
    pub fn maybe_trending_score(mut self, value: Option<i64>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S> TagViewBuilder<'a, S>
where
    S: tag_view_state::State,
    S::UseCount: tag_view_state::IsUnset,
{
    /// Set the `useCount` field (required)
    pub fn use_count(
        mut self,
        value: impl Into<i64>,
    ) -> TagViewBuilder<'a, tag_view_state::SetUseCount<S>> {
        self._fields.5 = Option::Some(value.into());
        TagViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TagViewBuilder<'a, S>
where
    S: tag_view_state::State,
    S::UseCount: tag_view_state::IsSet,
    S::Tag: tag_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> TagView<'a> {
        TagView {
            entry_count: self._fields.0,
            notebook_count: self._fields.1,
            recent_use_count: self._fields.2,
            tag: self._fields.3.unwrap(),
            trending_score: self._fields.4,
            use_count: self._fields.5.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> TagView<'a> {
        TagView {
            entry_count: self._fields.0,
            notebook_count: self._fields.1,
            recent_use_count: self._fields.2,
            tag: self._fields.3.unwrap(),
            trending_score: self._fields.4,
            use_count: self._fields.5.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}