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

pub mod accept;
pub mod get_collaboration_state;
pub mod get_invites;
pub mod get_resource_participants;
pub mod get_resource_sessions;
pub mod invite;
pub mod session;


#[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};
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::PublishedVersionView;
use crate::sh_weaver::collab;
/// Collaboration scoped to a chapter.

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

/// Full state of a collaboration relationship including version reconciliation. Tracks both current and former collaborators.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CollaborationStateView<'a> {
    ///The 'canonical' version URI (usually owner's)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub canonical_uri: Option<AtUri<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub first_collaborator_added_at: Option<Datetime>,
    ///People who used to collaborate but relationship ended
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub former_participants: Option<Vec<collab::FormerCollaboratorView<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_divergence: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_former_collaborators: Option<bool>,
    ///Published versions from former collaborators still exist
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_orphaned_versions: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_synced_at: Option<Datetime>,
    ///Current active + invited participants
    #[serde(borrow)]
    pub participants: Vec<collab::ParticipantStateView<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub published_versions: Option<Vec<PublishedVersionView<'a>>>,
    #[serde(borrow)]
    pub resource: StrongRef<'a>,
    ///active=normal, broken=all invites revoked/expired, diverged=versions differ, reconciled=was diverged but resolved
    #[serde(borrow)]
    pub status: CollaborationStateViewStatus<'a>,
}

/// active=normal, broken=all invites revoked/expired, diverged=versions differ, reconciled=was diverged but resolved

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum CollaborationStateViewStatus<'a> {
    Active,
    Broken,
    Diverged,
    Reconciled,
    Other(CowStr<'a>),
}

impl<'a> CollaborationStateViewStatus<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Active => "active",
            Self::Broken => "broken",
            Self::Diverged => "diverged",
            Self::Reconciled => "reconciled",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for CollaborationStateViewStatus<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "active" => Self::Active,
            "broken" => Self::Broken,
            "diverged" => Self::Diverged,
            "reconciled" => Self::Reconciled,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for CollaborationStateViewStatus<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "active" => Self::Active,
            "broken" => Self::Broken,
            "diverged" => Self::Diverged,
            "reconciled" => Self::Reconciled,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for CollaborationStateViewStatus<'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 CollaborationStateViewStatus<'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<'a> Default for CollaborationStateViewStatus<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for CollaborationStateViewStatus<'_> {
    type Output = CollaborationStateViewStatus<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            CollaborationStateViewStatus::Active => CollaborationStateViewStatus::Active,
            CollaborationStateViewStatus::Broken => CollaborationStateViewStatus::Broken,
            CollaborationStateViewStatus::Diverged => {
                CollaborationStateViewStatus::Diverged
            }
            CollaborationStateViewStatus::Reconciled => {
                CollaborationStateViewStatus::Reconciled
            }
            CollaborationStateViewStatus::Other(v) => {
                CollaborationStateViewStatus::Other(v.into_static())
            }
        }
    }
}

/// Collaboration scoped to a single entry.

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

/// Lightweight view for 'this person used to collaborate but doesn't anymore'.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct FormerCollaboratorView<'a> {
    ///Number of diffs they created while active
    #[serde(skip_serializing_if = "Option::is_none")]
    pub contribution_count: Option<i64>,
    #[serde(borrow)]
    pub end_reason: FormerCollaboratorViewEndReason<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_published_version: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub published_version_uri: Option<AtUri<'a>>,
    #[serde(borrow)]
    pub user: ProfileViewBasic<'a>,
    pub was_active_from: Datetime,
    pub was_active_until: Datetime,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum FormerCollaboratorViewEndReason<'a> {
    VoluntaryLeave,
    InviteRevoked,
    InviteExpired,
    OwnerDeletedResource,
    Other(CowStr<'a>),
}

impl<'a> FormerCollaboratorViewEndReason<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::VoluntaryLeave => "voluntary_leave",
            Self::InviteRevoked => "invite_revoked",
            Self::InviteExpired => "invite_expired",
            Self::OwnerDeletedResource => "owner_deleted_resource",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for FormerCollaboratorViewEndReason<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "voluntary_leave" => Self::VoluntaryLeave,
            "invite_revoked" => Self::InviteRevoked,
            "invite_expired" => Self::InviteExpired,
            "owner_deleted_resource" => Self::OwnerDeletedResource,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for FormerCollaboratorViewEndReason<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "voluntary_leave" => Self::VoluntaryLeave,
            "invite_revoked" => Self::InviteRevoked,
            "invite_expired" => Self::InviteExpired,
            "owner_deleted_resource" => Self::OwnerDeletedResource,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for FormerCollaboratorViewEndReason<'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 FormerCollaboratorViewEndReason<'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<'a> Default for FormerCollaboratorViewEndReason<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for FormerCollaboratorViewEndReason<'_> {
    type Output = FormerCollaboratorViewEndReason<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            FormerCollaboratorViewEndReason::VoluntaryLeave => {
                FormerCollaboratorViewEndReason::VoluntaryLeave
            }
            FormerCollaboratorViewEndReason::InviteRevoked => {
                FormerCollaboratorViewEndReason::InviteRevoked
            }
            FormerCollaboratorViewEndReason::InviteExpired => {
                FormerCollaboratorViewEndReason::InviteExpired
            }
            FormerCollaboratorViewEndReason::OwnerDeletedResource => {
                FormerCollaboratorViewEndReason::OwnerDeletedResource
            }
            FormerCollaboratorViewEndReason::Other(v) => {
                FormerCollaboratorViewEndReason::Other(v.into_static())
            }
        }
    }
}

/// Hydrated view of a collaboration invite with status.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct InviteView<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub accept_uri: Option<AtUri<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub accepted_at: Option<Datetime>,
    #[serde(borrow)]
    pub cid: Cid<'a>,
    pub created_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expires_at: Option<Datetime>,
    #[serde(borrow)]
    pub invitee: ProfileViewBasic<'a>,
    #[serde(borrow)]
    pub inviter: ProfileViewBasic<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub message: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub resource: StrongRef<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub resource_title: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub scope: Option<InviteViewScope<'a>>,
    #[serde(borrow)]
    pub status: InviteViewStatus<'a>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum InviteViewScope<'a> {
    Notebook,
    Entry,
    Chapter,
    Other(CowStr<'a>),
}

impl<'a> InviteViewScope<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Notebook => "notebook",
            Self::Entry => "entry",
            Self::Chapter => "chapter",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for InviteViewScope<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "notebook" => Self::Notebook,
            "entry" => Self::Entry,
            "chapter" => Self::Chapter,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for InviteViewScope<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "notebook" => Self::Notebook,
            "entry" => Self::Entry,
            "chapter" => Self::Chapter,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for InviteViewScope<'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 InviteViewScope<'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<'a> Default for InviteViewScope<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for InviteViewScope<'_> {
    type Output = InviteViewScope<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            InviteViewScope::Notebook => InviteViewScope::Notebook,
            InviteViewScope::Entry => InviteViewScope::Entry,
            InviteViewScope::Chapter => InviteViewScope::Chapter,
            InviteViewScope::Other(v) => InviteViewScope::Other(v.into_static()),
        }
    }
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum InviteViewStatus<'a> {
    Pending,
    Accepted,
    Expired,
    Revoked,
    Other(CowStr<'a>),
}

impl<'a> InviteViewStatus<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Pending => "pending",
            Self::Accepted => "accepted",
            Self::Expired => "expired",
            Self::Revoked => "revoked",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for InviteViewStatus<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "pending" => Self::Pending,
            "accepted" => Self::Accepted,
            "expired" => Self::Expired,
            "revoked" => Self::Revoked,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for InviteViewStatus<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "pending" => Self::Pending,
            "accepted" => Self::Accepted,
            "expired" => Self::Expired,
            "revoked" => Self::Revoked,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for InviteViewStatus<'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 InviteViewStatus<'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<'a> Default for InviteViewStatus<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for InviteViewStatus<'_> {
    type Output = InviteViewStatus<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            InviteViewStatus::Pending => InviteViewStatus::Pending,
            InviteViewStatus::Accepted => InviteViewStatus::Accepted,
            InviteViewStatus::Expired => InviteViewStatus::Expired,
            InviteViewStatus::Revoked => InviteViewStatus::Revoked,
            InviteViewStatus::Other(v) => InviteViewStatus::Other(v.into_static()),
        }
    }
}

/// Collaboration scoped to an entire notebook.

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

/// Individual participant's state in a collaboration. Distinguishes 'was collaborator' vs 'never was'.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ParticipantStateView<'a> {
    ///If they accepted (even if later broken)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub accept_uri: Option<AtUri<'a>>,
    ///Why the relationship ended, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub end_reason: Option<ParticipantStateViewEndReason<'a>>,
    ///When they first contributed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub first_edit_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub invite_uri: Option<AtUri<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_edit_at: Option<Datetime>,
    ///Their published copy if any
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub published_version: Option<StrongRef<'a>>,
    ///When left/removed/expired
    #[serde(skip_serializing_if = "Option::is_none")]
    pub relationship_ended_at: Option<Datetime>,
    #[serde(borrow)]
    pub role: ParticipantStateViewRole<'a>,
    ///active=can edit, invited=pending, left=voluntarily departed, removed=invite revoked, expired=invite timed out
    #[serde(borrow)]
    pub status: ParticipantStateViewStatus<'a>,
    #[serde(borrow)]
    pub user: ProfileViewBasic<'a>,
    ///True if they ever had active collaboration status
    #[serde(skip_serializing_if = "Option::is_none")]
    pub was_collaborator: Option<bool>,
}

/// Why the relationship ended, if applicable

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ParticipantStateViewEndReason<'a> {
    VoluntaryLeave,
    InviteRevoked,
    InviteExpired,
    OwnerDeletedResource,
    Other(CowStr<'a>),
}

impl<'a> ParticipantStateViewEndReason<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::VoluntaryLeave => "voluntary_leave",
            Self::InviteRevoked => "invite_revoked",
            Self::InviteExpired => "invite_expired",
            Self::OwnerDeletedResource => "owner_deleted_resource",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for ParticipantStateViewEndReason<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "voluntary_leave" => Self::VoluntaryLeave,
            "invite_revoked" => Self::InviteRevoked,
            "invite_expired" => Self::InviteExpired,
            "owner_deleted_resource" => Self::OwnerDeletedResource,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for ParticipantStateViewEndReason<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "voluntary_leave" => Self::VoluntaryLeave,
            "invite_revoked" => Self::InviteRevoked,
            "invite_expired" => Self::InviteExpired,
            "owner_deleted_resource" => Self::OwnerDeletedResource,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for ParticipantStateViewEndReason<'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 ParticipantStateViewEndReason<'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<'a> Default for ParticipantStateViewEndReason<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for ParticipantStateViewEndReason<'_> {
    type Output = ParticipantStateViewEndReason<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            ParticipantStateViewEndReason::VoluntaryLeave => {
                ParticipantStateViewEndReason::VoluntaryLeave
            }
            ParticipantStateViewEndReason::InviteRevoked => {
                ParticipantStateViewEndReason::InviteRevoked
            }
            ParticipantStateViewEndReason::InviteExpired => {
                ParticipantStateViewEndReason::InviteExpired
            }
            ParticipantStateViewEndReason::OwnerDeletedResource => {
                ParticipantStateViewEndReason::OwnerDeletedResource
            }
            ParticipantStateViewEndReason::Other(v) => {
                ParticipantStateViewEndReason::Other(v.into_static())
            }
        }
    }
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ParticipantStateViewRole<'a> {
    Owner,
    Collaborator,
    FormerCollaborator,
    Other(CowStr<'a>),
}

impl<'a> ParticipantStateViewRole<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Owner => "owner",
            Self::Collaborator => "collaborator",
            Self::FormerCollaborator => "former_collaborator",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for ParticipantStateViewRole<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "owner" => Self::Owner,
            "collaborator" => Self::Collaborator,
            "former_collaborator" => Self::FormerCollaborator,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for ParticipantStateViewRole<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "owner" => Self::Owner,
            "collaborator" => Self::Collaborator,
            "former_collaborator" => Self::FormerCollaborator,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for ParticipantStateViewRole<'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 ParticipantStateViewRole<'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<'a> Default for ParticipantStateViewRole<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for ParticipantStateViewRole<'_> {
    type Output = ParticipantStateViewRole<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            ParticipantStateViewRole::Owner => ParticipantStateViewRole::Owner,
            ParticipantStateViewRole::Collaborator => {
                ParticipantStateViewRole::Collaborator
            }
            ParticipantStateViewRole::FormerCollaborator => {
                ParticipantStateViewRole::FormerCollaborator
            }
            ParticipantStateViewRole::Other(v) => {
                ParticipantStateViewRole::Other(v.into_static())
            }
        }
    }
}

/// active=can edit, invited=pending, left=voluntarily departed, removed=invite revoked, expired=invite timed out

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ParticipantStateViewStatus<'a> {
    Active,
    Invited,
    Left,
    Removed,
    Expired,
    Other(CowStr<'a>),
}

impl<'a> ParticipantStateViewStatus<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Active => "active",
            Self::Invited => "invited",
            Self::Left => "left",
            Self::Removed => "removed",
            Self::Expired => "expired",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for ParticipantStateViewStatus<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "active" => Self::Active,
            "invited" => Self::Invited,
            "left" => Self::Left,
            "removed" => Self::Removed,
            "expired" => Self::Expired,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for ParticipantStateViewStatus<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "active" => Self::Active,
            "invited" => Self::Invited,
            "left" => Self::Left,
            "removed" => Self::Removed,
            "expired" => Self::Expired,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for ParticipantStateViewStatus<'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 ParticipantStateViewStatus<'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<'a> Default for ParticipantStateViewStatus<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for ParticipantStateViewStatus<'_> {
    type Output = ParticipantStateViewStatus<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            ParticipantStateViewStatus::Active => ParticipantStateViewStatus::Active,
            ParticipantStateViewStatus::Invited => ParticipantStateViewStatus::Invited,
            ParticipantStateViewStatus::Left => ParticipantStateViewStatus::Left,
            ParticipantStateViewStatus::Removed => ParticipantStateViewStatus::Removed,
            ParticipantStateViewStatus::Expired => ParticipantStateViewStatus::Expired,
            ParticipantStateViewStatus::Other(v) => {
                ParticipantStateViewStatus::Other(v.into_static())
            }
        }
    }
}

/// Active real-time collaboration session.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SessionView<'a> {
    pub created_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expires_at: Option<Datetime>,
    #[serde(borrow)]
    pub node_id: CowStr<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub relay_url: Option<UriValue<'a>>,
    #[serde(borrow)]
    pub resource: StrongRef<'a>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    #[serde(borrow)]
    pub user: ProfileViewBasic<'a>,
}

impl<'a> LexiconSchema for CollaborationStateView<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.collab.defs"
    }
    fn def_name() -> &'static str {
        "collaborationStateView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_collab_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for FormerCollaboratorView<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.collab.defs"
    }
    fn def_name() -> &'static str {
        "formerCollaboratorView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_collab_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for InviteView<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.collab.defs"
    }
    fn def_name() -> &'static str {
        "inviteView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_collab_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for ParticipantStateView<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.collab.defs"
    }
    fn def_name() -> &'static str {
        "participantStateView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_collab_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for SessionView<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.collab.defs"
    }
    fn def_name() -> &'static str {
        "sessionView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_collab_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod collaboration_state_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 Status;
        type Participants;
        type Resource;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Status = Unset;
        type Participants = Unset;
        type Resource = Unset;
    }
    ///State transition - sets the `status` field to Set
    pub struct SetStatus<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetStatus<S> {}
    impl<S: State> State for SetStatus<S> {
        type Status = Set<members::status>;
        type Participants = S::Participants;
        type Resource = S::Resource;
    }
    ///State transition - sets the `participants` field to Set
    pub struct SetParticipants<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetParticipants<S> {}
    impl<S: State> State for SetParticipants<S> {
        type Status = S::Status;
        type Participants = Set<members::participants>;
        type Resource = S::Resource;
    }
    ///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 Status = S::Status;
        type Participants = S::Participants;
        type Resource = Set<members::resource>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `status` field
        pub struct status(());
        ///Marker type for the `participants` field
        pub struct participants(());
        ///Marker type for the `resource` field
        pub struct resource(());
    }
}

/// Builder for constructing an instance of this type
pub struct CollaborationStateViewBuilder<'a, S: collaboration_state_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<AtUri<'a>>,
        Option<Datetime>,
        Option<Datetime>,
        Option<Vec<collab::FormerCollaboratorView<'a>>>,
        Option<bool>,
        Option<bool>,
        Option<bool>,
        Option<Datetime>,
        Option<Vec<collab::ParticipantStateView<'a>>>,
        Option<Vec<PublishedVersionView<'a>>>,
        Option<StrongRef<'a>>,
        Option<CollaborationStateViewStatus<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> CollaborationStateView<'a> {
    /// Create a new builder for this type
    pub fn new() -> CollaborationStateViewBuilder<
        'a,
        collaboration_state_view_state::Empty,
    > {
        CollaborationStateViewBuilder::new()
    }
}

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

impl<'a, S: collaboration_state_view_state::State> CollaborationStateViewBuilder<'a, S> {
    /// Set the `canonicalUri` field (optional)
    pub fn canonical_uri(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `canonicalUri` field to an Option value (optional)
    pub fn maybe_canonical_uri(mut self, value: Option<AtUri<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: collaboration_state_view_state::State> CollaborationStateViewBuilder<'a, S> {
    /// Set the `createdAt` field (optional)
    pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `createdAt` field to an Option value (optional)
    pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: collaboration_state_view_state::State> CollaborationStateViewBuilder<'a, S> {
    /// Set the `firstCollaboratorAddedAt` field (optional)
    pub fn first_collaborator_added_at(
        mut self,
        value: impl Into<Option<Datetime>>,
    ) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `firstCollaboratorAddedAt` field to an Option value (optional)
    pub fn maybe_first_collaborator_added_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: collaboration_state_view_state::State> CollaborationStateViewBuilder<'a, S> {
    /// Set the `formerParticipants` field (optional)
    pub fn former_participants(
        mut self,
        value: impl Into<Option<Vec<collab::FormerCollaboratorView<'a>>>>,
    ) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `formerParticipants` field to an Option value (optional)
    pub fn maybe_former_participants(
        mut self,
        value: Option<Vec<collab::FormerCollaboratorView<'a>>>,
    ) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: collaboration_state_view_state::State> CollaborationStateViewBuilder<'a, S> {
    /// Set the `hasDivergence` field (optional)
    pub fn has_divergence(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `hasDivergence` field to an Option value (optional)
    pub fn maybe_has_divergence(mut self, value: Option<bool>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: collaboration_state_view_state::State> CollaborationStateViewBuilder<'a, S> {
    /// Set the `hasFormerCollaborators` field (optional)
    pub fn has_former_collaborators(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `hasFormerCollaborators` field to an Option value (optional)
    pub fn maybe_has_former_collaborators(mut self, value: Option<bool>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: collaboration_state_view_state::State> CollaborationStateViewBuilder<'a, S> {
    /// Set the `hasOrphanedVersions` field (optional)
    pub fn has_orphaned_versions(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `hasOrphanedVersions` field to an Option value (optional)
    pub fn maybe_has_orphaned_versions(mut self, value: Option<bool>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S: collaboration_state_view_state::State> CollaborationStateViewBuilder<'a, S> {
    /// Set the `lastSyncedAt` field (optional)
    pub fn last_synced_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `lastSyncedAt` field to an Option value (optional)
    pub fn maybe_last_synced_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<'a, S> CollaborationStateViewBuilder<'a, S>
where
    S: collaboration_state_view_state::State,
    S::Participants: collaboration_state_view_state::IsUnset,
{
    /// Set the `participants` field (required)
    pub fn participants(
        mut self,
        value: impl Into<Vec<collab::ParticipantStateView<'a>>>,
    ) -> CollaborationStateViewBuilder<
        'a,
        collaboration_state_view_state::SetParticipants<S>,
    > {
        self._fields.8 = Option::Some(value.into());
        CollaborationStateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: collaboration_state_view_state::State> CollaborationStateViewBuilder<'a, S> {
    /// Set the `publishedVersions` field (optional)
    pub fn published_versions(
        mut self,
        value: impl Into<Option<Vec<PublishedVersionView<'a>>>>,
    ) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `publishedVersions` field to an Option value (optional)
    pub fn maybe_published_versions(
        mut self,
        value: Option<Vec<PublishedVersionView<'a>>>,
    ) -> Self {
        self._fields.9 = value;
        self
    }
}

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

impl<'a, S> CollaborationStateViewBuilder<'a, S>
where
    S: collaboration_state_view_state::State,
    S::Status: collaboration_state_view_state::IsUnset,
{
    /// Set the `status` field (required)
    pub fn status(
        mut self,
        value: impl Into<CollaborationStateViewStatus<'a>>,
    ) -> CollaborationStateViewBuilder<
        'a,
        collaboration_state_view_state::SetStatus<S>,
    > {
        self._fields.11 = Option::Some(value.into());
        CollaborationStateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CollaborationStateViewBuilder<'a, S>
where
    S: collaboration_state_view_state::State,
    S::Status: collaboration_state_view_state::IsSet,
    S::Participants: collaboration_state_view_state::IsSet,
    S::Resource: collaboration_state_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> CollaborationStateView<'a> {
        CollaborationStateView {
            canonical_uri: self._fields.0,
            created_at: self._fields.1,
            first_collaborator_added_at: self._fields.2,
            former_participants: self._fields.3,
            has_divergence: self._fields.4,
            has_former_collaborators: self._fields.5,
            has_orphaned_versions: self._fields.6,
            last_synced_at: self._fields.7,
            participants: self._fields.8.unwrap(),
            published_versions: self._fields.9,
            resource: self._fields.10.unwrap(),
            status: self._fields.11.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>,
        >,
    ) -> CollaborationStateView<'a> {
        CollaborationStateView {
            canonical_uri: self._fields.0,
            created_at: self._fields.1,
            first_collaborator_added_at: self._fields.2,
            former_participants: self._fields.3,
            has_divergence: self._fields.4,
            has_former_collaborators: self._fields.5,
            has_orphaned_versions: self._fields.6,
            last_synced_at: self._fields.7,
            participants: self._fields.8.unwrap(),
            published_versions: self._fields.9,
            resource: self._fields.10.unwrap(),
            status: self._fields.11.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_sh_weaver_collab_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.collab.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("chapter"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("collaborationStateView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Full state of a collaboration relationship including version reconciliation. Tracks both current and former collaborators.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("resource"),
                            SmolStr::new_static("status"),
                            SmolStr::new_static("participants")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("canonicalUri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The 'canonical' version URI (usually owner's)",
                                    ),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("firstCollaboratorAddedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("formerParticipants"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "People who used to collaborate but relationship ended",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#formerCollaboratorView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("hasDivergence"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("hasFormerCollaborators"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("hasOrphanedVersions"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lastSyncedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("participants"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static("Current active + invited participants"),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#participantStateView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("publishedVersions"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "sh.weaver.notebook.defs#publishedVersionView",
                                    ),
                                    ..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("status"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "active=normal, broken=all invites revoked/expired, diverged=versions differ, reconciled=was diverged but resolved",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("entry"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("formerCollaboratorView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Lightweight view for 'this person used to collaborate but doesn't anymore'.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("user"),
                            SmolStr::new_static("wasActiveFrom"),
                            SmolStr::new_static("wasActiveUntil"),
                            SmolStr::new_static("endReason")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("contributionCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("endReason"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("hasPublishedVersion"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("publishedVersionUri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("user"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("wasActiveFrom"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("wasActiveUntil"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("inviteView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Hydrated view of a collaboration invite with status.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("inviter"),
                            SmolStr::new_static("invitee"),
                            SmolStr::new_static("resource"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("status")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("acceptUri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("acceptedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("expiresAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("invitee"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("inviter"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("message"),
                            LexObjectProperty::String(LexString { ..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("resourceTitle"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("scope"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            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("notebook"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("participantStateView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Individual participant's state in a collaboration. Distinguishes 'was collaborator' vs 'never was'.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("user"), SmolStr::new_static("role"),
                            SmolStr::new_static("status")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("acceptUri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "If they accepted (even if later broken)",
                                    ),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("endReason"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Why the relationship ended, if applicable",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("firstEditAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When they first contributed"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("inviteUri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lastEditAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("publishedVersion"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("relationshipEndedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When left/removed/expired"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("role"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "active=can edit, invited=pending, left=voluntarily departed, removed=invite revoked, expired=invite timed out",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("user"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("wasCollaborator"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("sessionView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Active real-time collaboration session."),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("user"),
                            SmolStr::new_static("resource"),
                            SmolStr::new_static("nodeId"),
                            SmolStr::new_static("createdAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("expiresAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("nodeId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("relayUrl"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..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("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("user"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod former_collaborator_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 WasActiveFrom;
        type User;
        type WasActiveUntil;
        type EndReason;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type WasActiveFrom = Unset;
        type User = Unset;
        type WasActiveUntil = Unset;
        type EndReason = Unset;
    }
    ///State transition - sets the `was_active_from` field to Set
    pub struct SetWasActiveFrom<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetWasActiveFrom<S> {}
    impl<S: State> State for SetWasActiveFrom<S> {
        type WasActiveFrom = Set<members::was_active_from>;
        type User = S::User;
        type WasActiveUntil = S::WasActiveUntil;
        type EndReason = S::EndReason;
    }
    ///State transition - sets the `user` field to Set
    pub struct SetUser<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUser<S> {}
    impl<S: State> State for SetUser<S> {
        type WasActiveFrom = S::WasActiveFrom;
        type User = Set<members::user>;
        type WasActiveUntil = S::WasActiveUntil;
        type EndReason = S::EndReason;
    }
    ///State transition - sets the `was_active_until` field to Set
    pub struct SetWasActiveUntil<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetWasActiveUntil<S> {}
    impl<S: State> State for SetWasActiveUntil<S> {
        type WasActiveFrom = S::WasActiveFrom;
        type User = S::User;
        type WasActiveUntil = Set<members::was_active_until>;
        type EndReason = S::EndReason;
    }
    ///State transition - sets the `end_reason` field to Set
    pub struct SetEndReason<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetEndReason<S> {}
    impl<S: State> State for SetEndReason<S> {
        type WasActiveFrom = S::WasActiveFrom;
        type User = S::User;
        type WasActiveUntil = S::WasActiveUntil;
        type EndReason = Set<members::end_reason>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `was_active_from` field
        pub struct was_active_from(());
        ///Marker type for the `user` field
        pub struct user(());
        ///Marker type for the `was_active_until` field
        pub struct was_active_until(());
        ///Marker type for the `end_reason` field
        pub struct end_reason(());
    }
}

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

impl<'a> FormerCollaboratorView<'a> {
    /// Create a new builder for this type
    pub fn new() -> FormerCollaboratorViewBuilder<
        'a,
        former_collaborator_view_state::Empty,
    > {
        FormerCollaboratorViewBuilder::new()
    }
}

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

impl<'a, S: former_collaborator_view_state::State> FormerCollaboratorViewBuilder<'a, S> {
    /// Set the `contributionCount` field (optional)
    pub fn contribution_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `contributionCount` field to an Option value (optional)
    pub fn maybe_contribution_count(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> FormerCollaboratorViewBuilder<'a, S>
where
    S: former_collaborator_view_state::State,
    S::EndReason: former_collaborator_view_state::IsUnset,
{
    /// Set the `endReason` field (required)
    pub fn end_reason(
        mut self,
        value: impl Into<FormerCollaboratorViewEndReason<'a>>,
    ) -> FormerCollaboratorViewBuilder<
        'a,
        former_collaborator_view_state::SetEndReason<S>,
    > {
        self._fields.1 = Option::Some(value.into());
        FormerCollaboratorViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: former_collaborator_view_state::State> FormerCollaboratorViewBuilder<'a, S> {
    /// Set the `hasPublishedVersion` field (optional)
    pub fn has_published_version(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `hasPublishedVersion` field to an Option value (optional)
    pub fn maybe_has_published_version(mut self, value: Option<bool>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: former_collaborator_view_state::State> FormerCollaboratorViewBuilder<'a, S> {
    /// Set the `publishedVersionUri` field (optional)
    pub fn published_version_uri(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `publishedVersionUri` field to an Option value (optional)
    pub fn maybe_published_version_uri(mut self, value: Option<AtUri<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S> FormerCollaboratorViewBuilder<'a, S>
where
    S: former_collaborator_view_state::State,
    S::User: former_collaborator_view_state::IsUnset,
{
    /// Set the `user` field (required)
    pub fn user(
        mut self,
        value: impl Into<ProfileViewBasic<'a>>,
    ) -> FormerCollaboratorViewBuilder<'a, former_collaborator_view_state::SetUser<S>> {
        self._fields.4 = Option::Some(value.into());
        FormerCollaboratorViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> FormerCollaboratorViewBuilder<'a, S>
where
    S: former_collaborator_view_state::State,
    S::WasActiveFrom: former_collaborator_view_state::IsUnset,
{
    /// Set the `wasActiveFrom` field (required)
    pub fn was_active_from(
        mut self,
        value: impl Into<Datetime>,
    ) -> FormerCollaboratorViewBuilder<
        'a,
        former_collaborator_view_state::SetWasActiveFrom<S>,
    > {
        self._fields.5 = Option::Some(value.into());
        FormerCollaboratorViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> FormerCollaboratorViewBuilder<'a, S>
where
    S: former_collaborator_view_state::State,
    S::WasActiveUntil: former_collaborator_view_state::IsUnset,
{
    /// Set the `wasActiveUntil` field (required)
    pub fn was_active_until(
        mut self,
        value: impl Into<Datetime>,
    ) -> FormerCollaboratorViewBuilder<
        'a,
        former_collaborator_view_state::SetWasActiveUntil<S>,
    > {
        self._fields.6 = Option::Some(value.into());
        FormerCollaboratorViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> FormerCollaboratorViewBuilder<'a, S>
where
    S: former_collaborator_view_state::State,
    S::WasActiveFrom: former_collaborator_view_state::IsSet,
    S::User: former_collaborator_view_state::IsSet,
    S::WasActiveUntil: former_collaborator_view_state::IsSet,
    S::EndReason: former_collaborator_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> FormerCollaboratorView<'a> {
        FormerCollaboratorView {
            contribution_count: self._fields.0,
            end_reason: self._fields.1.unwrap(),
            has_published_version: self._fields.2,
            published_version_uri: self._fields.3,
            user: self._fields.4.unwrap(),
            was_active_from: self._fields.5.unwrap(),
            was_active_until: self._fields.6.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>,
        >,
    ) -> FormerCollaboratorView<'a> {
        FormerCollaboratorView {
            contribution_count: self._fields.0,
            end_reason: self._fields.1.unwrap(),
            has_published_version: self._fields.2,
            published_version_uri: self._fields.3,
            user: self._fields.4.unwrap(),
            was_active_from: self._fields.5.unwrap(),
            was_active_until: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod invite_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 Invitee;
        type Resource;
        type Cid;
        type Status;
        type Uri;
        type CreatedAt;
        type Inviter;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Invitee = Unset;
        type Resource = Unset;
        type Cid = Unset;
        type Status = Unset;
        type Uri = Unset;
        type CreatedAt = Unset;
        type Inviter = Unset;
    }
    ///State transition - sets the `invitee` field to Set
    pub struct SetInvitee<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetInvitee<S> {}
    impl<S: State> State for SetInvitee<S> {
        type Invitee = Set<members::invitee>;
        type Resource = S::Resource;
        type Cid = S::Cid;
        type Status = S::Status;
        type Uri = S::Uri;
        type CreatedAt = S::CreatedAt;
        type Inviter = S::Inviter;
    }
    ///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 Invitee = S::Invitee;
        type Resource = Set<members::resource>;
        type Cid = S::Cid;
        type Status = S::Status;
        type Uri = S::Uri;
        type CreatedAt = S::CreatedAt;
        type Inviter = S::Inviter;
    }
    ///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 Invitee = S::Invitee;
        type Resource = S::Resource;
        type Cid = Set<members::cid>;
        type Status = S::Status;
        type Uri = S::Uri;
        type CreatedAt = S::CreatedAt;
        type Inviter = S::Inviter;
    }
    ///State transition - sets the `status` field to Set
    pub struct SetStatus<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetStatus<S> {}
    impl<S: State> State for SetStatus<S> {
        type Invitee = S::Invitee;
        type Resource = S::Resource;
        type Cid = S::Cid;
        type Status = Set<members::status>;
        type Uri = S::Uri;
        type CreatedAt = S::CreatedAt;
        type Inviter = S::Inviter;
    }
    ///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 Invitee = S::Invitee;
        type Resource = S::Resource;
        type Cid = S::Cid;
        type Status = S::Status;
        type Uri = Set<members::uri>;
        type CreatedAt = S::CreatedAt;
        type Inviter = S::Inviter;
    }
    ///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 Invitee = S::Invitee;
        type Resource = S::Resource;
        type Cid = S::Cid;
        type Status = S::Status;
        type Uri = S::Uri;
        type CreatedAt = Set<members::created_at>;
        type Inviter = S::Inviter;
    }
    ///State transition - sets the `inviter` field to Set
    pub struct SetInviter<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetInviter<S> {}
    impl<S: State> State for SetInviter<S> {
        type Invitee = S::Invitee;
        type Resource = S::Resource;
        type Cid = S::Cid;
        type Status = S::Status;
        type Uri = S::Uri;
        type CreatedAt = S::CreatedAt;
        type Inviter = Set<members::inviter>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `invitee` field
        pub struct invitee(());
        ///Marker type for the `resource` field
        pub struct resource(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `status` field
        pub struct status(());
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `inviter` field
        pub struct inviter(());
    }
}

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

impl<'a> InviteView<'a> {
    /// Create a new builder for this type
    pub fn new() -> InviteViewBuilder<'a, invite_view_state::Empty> {
        InviteViewBuilder::new()
    }
}

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

impl<'a, S: invite_view_state::State> InviteViewBuilder<'a, S> {
    /// Set the `acceptUri` field (optional)
    pub fn accept_uri(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `acceptUri` field to an Option value (optional)
    pub fn maybe_accept_uri(mut self, value: Option<AtUri<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: invite_view_state::State> InviteViewBuilder<'a, S> {
    /// Set the `acceptedAt` field (optional)
    pub fn accepted_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `acceptedAt` field to an Option value (optional)
    pub fn maybe_accepted_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

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

impl<'a, S: invite_view_state::State> InviteViewBuilder<'a, S> {
    /// Set the `expiresAt` field (optional)
    pub fn expires_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `expiresAt` field to an Option value (optional)
    pub fn maybe_expires_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S> InviteViewBuilder<'a, S>
where
    S: invite_view_state::State,
    S::Invitee: invite_view_state::IsUnset,
{
    /// Set the `invitee` field (required)
    pub fn invitee(
        mut self,
        value: impl Into<ProfileViewBasic<'a>>,
    ) -> InviteViewBuilder<'a, invite_view_state::SetInvitee<S>> {
        self._fields.5 = Option::Some(value.into());
        InviteViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> InviteViewBuilder<'a, S>
where
    S: invite_view_state::State,
    S::Inviter: invite_view_state::IsUnset,
{
    /// Set the `inviter` field (required)
    pub fn inviter(
        mut self,
        value: impl Into<ProfileViewBasic<'a>>,
    ) -> InviteViewBuilder<'a, invite_view_state::SetInviter<S>> {
        self._fields.6 = Option::Some(value.into());
        InviteViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: invite_view_state::State> InviteViewBuilder<'a, S> {
    /// Set the `message` field (optional)
    pub fn message(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `message` field to an Option value (optional)
    pub fn maybe_message(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.7 = value;
        self
    }
}

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

impl<'a, S: invite_view_state::State> InviteViewBuilder<'a, S> {
    /// Set the `resourceTitle` field (optional)
    pub fn resource_title(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `resourceTitle` field to an Option value (optional)
    pub fn maybe_resource_title(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<'a, S: invite_view_state::State> InviteViewBuilder<'a, S> {
    /// Set the `scope` field (optional)
    pub fn scope(mut self, value: impl Into<Option<InviteViewScope<'a>>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `scope` field to an Option value (optional)
    pub fn maybe_scope(mut self, value: Option<InviteViewScope<'a>>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<'a, S> InviteViewBuilder<'a, S>
where
    S: invite_view_state::State,
    S::Status: invite_view_state::IsUnset,
{
    /// Set the `status` field (required)
    pub fn status(
        mut self,
        value: impl Into<InviteViewStatus<'a>>,
    ) -> InviteViewBuilder<'a, invite_view_state::SetStatus<S>> {
        self._fields.11 = Option::Some(value.into());
        InviteViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

impl<'a, S> InviteViewBuilder<'a, S>
where
    S: invite_view_state::State,
    S::Invitee: invite_view_state::IsSet,
    S::Resource: invite_view_state::IsSet,
    S::Cid: invite_view_state::IsSet,
    S::Status: invite_view_state::IsSet,
    S::Uri: invite_view_state::IsSet,
    S::CreatedAt: invite_view_state::IsSet,
    S::Inviter: invite_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> InviteView<'a> {
        InviteView {
            accept_uri: self._fields.0,
            accepted_at: self._fields.1,
            cid: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            expires_at: self._fields.4,
            invitee: self._fields.5.unwrap(),
            inviter: self._fields.6.unwrap(),
            message: self._fields.7,
            resource: self._fields.8.unwrap(),
            resource_title: self._fields.9,
            scope: self._fields.10,
            status: self._fields.11.unwrap(),
            uri: self._fields.12.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>,
        >,
    ) -> InviteView<'a> {
        InviteView {
            accept_uri: self._fields.0,
            accepted_at: self._fields.1,
            cid: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            expires_at: self._fields.4,
            invitee: self._fields.5.unwrap(),
            inviter: self._fields.6.unwrap(),
            message: self._fields.7,
            resource: self._fields.8.unwrap(),
            resource_title: self._fields.9,
            scope: self._fields.10,
            status: self._fields.11.unwrap(),
            uri: self._fields.12.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod participant_state_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 Status;
        type Role;
        type User;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Status = Unset;
        type Role = Unset;
        type User = Unset;
    }
    ///State transition - sets the `status` field to Set
    pub struct SetStatus<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetStatus<S> {}
    impl<S: State> State for SetStatus<S> {
        type Status = Set<members::status>;
        type Role = S::Role;
        type User = S::User;
    }
    ///State transition - sets the `role` field to Set
    pub struct SetRole<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRole<S> {}
    impl<S: State> State for SetRole<S> {
        type Status = S::Status;
        type Role = Set<members::role>;
        type User = S::User;
    }
    ///State transition - sets the `user` field to Set
    pub struct SetUser<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUser<S> {}
    impl<S: State> State for SetUser<S> {
        type Status = S::Status;
        type Role = S::Role;
        type User = Set<members::user>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `status` field
        pub struct status(());
        ///Marker type for the `role` field
        pub struct role(());
        ///Marker type for the `user` field
        pub struct user(());
    }
}

/// Builder for constructing an instance of this type
pub struct ParticipantStateViewBuilder<'a, S: participant_state_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<AtUri<'a>>,
        Option<ParticipantStateViewEndReason<'a>>,
        Option<Datetime>,
        Option<AtUri<'a>>,
        Option<Datetime>,
        Option<StrongRef<'a>>,
        Option<Datetime>,
        Option<ParticipantStateViewRole<'a>>,
        Option<ParticipantStateViewStatus<'a>>,
        Option<ProfileViewBasic<'a>>,
        Option<bool>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> ParticipantStateView<'a> {
    /// Create a new builder for this type
    pub fn new() -> ParticipantStateViewBuilder<
        'a,
        participant_state_view_state::Empty,
    > {
        ParticipantStateViewBuilder::new()
    }
}

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

impl<'a, S: participant_state_view_state::State> ParticipantStateViewBuilder<'a, S> {
    /// Set the `acceptUri` field (optional)
    pub fn accept_uri(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `acceptUri` field to an Option value (optional)
    pub fn maybe_accept_uri(mut self, value: Option<AtUri<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: participant_state_view_state::State> ParticipantStateViewBuilder<'a, S> {
    /// Set the `endReason` field (optional)
    pub fn end_reason(
        mut self,
        value: impl Into<Option<ParticipantStateViewEndReason<'a>>>,
    ) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `endReason` field to an Option value (optional)
    pub fn maybe_end_reason(
        mut self,
        value: Option<ParticipantStateViewEndReason<'a>>,
    ) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: participant_state_view_state::State> ParticipantStateViewBuilder<'a, S> {
    /// Set the `firstEditAt` field (optional)
    pub fn first_edit_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `firstEditAt` field to an Option value (optional)
    pub fn maybe_first_edit_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: participant_state_view_state::State> ParticipantStateViewBuilder<'a, S> {
    /// Set the `inviteUri` field (optional)
    pub fn invite_uri(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `inviteUri` field to an Option value (optional)
    pub fn maybe_invite_uri(mut self, value: Option<AtUri<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: participant_state_view_state::State> ParticipantStateViewBuilder<'a, S> {
    /// Set the `lastEditAt` field (optional)
    pub fn last_edit_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `lastEditAt` field to an Option value (optional)
    pub fn maybe_last_edit_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: participant_state_view_state::State> ParticipantStateViewBuilder<'a, S> {
    /// Set the `publishedVersion` field (optional)
    pub fn published_version(mut self, value: impl Into<Option<StrongRef<'a>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `publishedVersion` field to an Option value (optional)
    pub fn maybe_published_version(mut self, value: Option<StrongRef<'a>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: participant_state_view_state::State> ParticipantStateViewBuilder<'a, S> {
    /// Set the `relationshipEndedAt` field (optional)
    pub fn relationship_ended_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `relationshipEndedAt` field to an Option value (optional)
    pub fn maybe_relationship_ended_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S> ParticipantStateViewBuilder<'a, S>
where
    S: participant_state_view_state::State,
    S::Role: participant_state_view_state::IsUnset,
{
    /// Set the `role` field (required)
    pub fn role(
        mut self,
        value: impl Into<ParticipantStateViewRole<'a>>,
    ) -> ParticipantStateViewBuilder<'a, participant_state_view_state::SetRole<S>> {
        self._fields.7 = Option::Some(value.into());
        ParticipantStateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ParticipantStateViewBuilder<'a, S>
where
    S: participant_state_view_state::State,
    S::Status: participant_state_view_state::IsUnset,
{
    /// Set the `status` field (required)
    pub fn status(
        mut self,
        value: impl Into<ParticipantStateViewStatus<'a>>,
    ) -> ParticipantStateViewBuilder<'a, participant_state_view_state::SetStatus<S>> {
        self._fields.8 = Option::Some(value.into());
        ParticipantStateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ParticipantStateViewBuilder<'a, S>
where
    S: participant_state_view_state::State,
    S::User: participant_state_view_state::IsUnset,
{
    /// Set the `user` field (required)
    pub fn user(
        mut self,
        value: impl Into<ProfileViewBasic<'a>>,
    ) -> ParticipantStateViewBuilder<'a, participant_state_view_state::SetUser<S>> {
        self._fields.9 = Option::Some(value.into());
        ParticipantStateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: participant_state_view_state::State> ParticipantStateViewBuilder<'a, S> {
    /// Set the `wasCollaborator` field (optional)
    pub fn was_collaborator(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `wasCollaborator` field to an Option value (optional)
    pub fn maybe_was_collaborator(mut self, value: Option<bool>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<'a, S> ParticipantStateViewBuilder<'a, S>
where
    S: participant_state_view_state::State,
    S::Status: participant_state_view_state::IsSet,
    S::Role: participant_state_view_state::IsSet,
    S::User: participant_state_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ParticipantStateView<'a> {
        ParticipantStateView {
            accept_uri: self._fields.0,
            end_reason: self._fields.1,
            first_edit_at: self._fields.2,
            invite_uri: self._fields.3,
            last_edit_at: self._fields.4,
            published_version: self._fields.5,
            relationship_ended_at: self._fields.6,
            role: self._fields.7.unwrap(),
            status: self._fields.8.unwrap(),
            user: self._fields.9.unwrap(),
            was_collaborator: self._fields.10,
            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>,
        >,
    ) -> ParticipantStateView<'a> {
        ParticipantStateView {
            accept_uri: self._fields.0,
            end_reason: self._fields.1,
            first_edit_at: self._fields.2,
            invite_uri: self._fields.3,
            last_edit_at: self._fields.4,
            published_version: self._fields.5,
            relationship_ended_at: self._fields.6,
            role: self._fields.7.unwrap(),
            status: self._fields.8.unwrap(),
            user: self._fields.9.unwrap(),
            was_collaborator: self._fields.10,
            extra_data: Some(extra_data),
        }
    }
}

pub mod session_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 NodeId;
        type Resource;
        type User;
        type CreatedAt;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type NodeId = Unset;
        type Resource = Unset;
        type User = Unset;
        type CreatedAt = Unset;
        type Uri = Unset;
    }
    ///State transition - sets the `node_id` field to Set
    pub struct SetNodeId<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetNodeId<S> {}
    impl<S: State> State for SetNodeId<S> {
        type NodeId = Set<members::node_id>;
        type Resource = S::Resource;
        type User = S::User;
        type CreatedAt = S::CreatedAt;
        type Uri = S::Uri;
    }
    ///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 NodeId = S::NodeId;
        type Resource = Set<members::resource>;
        type User = S::User;
        type CreatedAt = S::CreatedAt;
        type Uri = S::Uri;
    }
    ///State transition - sets the `user` field to Set
    pub struct SetUser<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUser<S> {}
    impl<S: State> State for SetUser<S> {
        type NodeId = S::NodeId;
        type Resource = S::Resource;
        type User = Set<members::user>;
        type CreatedAt = S::CreatedAt;
        type Uri = S::Uri;
    }
    ///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 NodeId = S::NodeId;
        type Resource = S::Resource;
        type User = S::User;
        type CreatedAt = Set<members::created_at>;
        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 NodeId = S::NodeId;
        type Resource = S::Resource;
        type User = S::User;
        type CreatedAt = S::CreatedAt;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `node_id` field
        pub struct node_id(());
        ///Marker type for the `resource` field
        pub struct resource(());
        ///Marker type for the `user` field
        pub struct user(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

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

impl<'a> SessionView<'a> {
    /// Create a new builder for this type
    pub fn new() -> SessionViewBuilder<'a, session_view_state::Empty> {
        SessionViewBuilder::new()
    }
}

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

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

impl<'a, S: session_view_state::State> SessionViewBuilder<'a, S> {
    /// Set the `expiresAt` field (optional)
    pub fn expires_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `expiresAt` field to an Option value (optional)
    pub fn maybe_expires_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S> SessionViewBuilder<'a, S>
where
    S: session_view_state::State,
    S::NodeId: session_view_state::IsUnset,
{
    /// Set the `nodeId` field (required)
    pub fn node_id(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> SessionViewBuilder<'a, session_view_state::SetNodeId<S>> {
        self._fields.2 = Option::Some(value.into());
        SessionViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: session_view_state::State> SessionViewBuilder<'a, S> {
    /// Set the `relayUrl` field (optional)
    pub fn relay_url(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `relayUrl` field to an Option value (optional)
    pub fn maybe_relay_url(mut self, value: Option<UriValue<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

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

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

impl<'a, S> SessionViewBuilder<'a, S>
where
    S: session_view_state::State,
    S::User: session_view_state::IsUnset,
{
    /// Set the `user` field (required)
    pub fn user(
        mut self,
        value: impl Into<ProfileViewBasic<'a>>,
    ) -> SessionViewBuilder<'a, session_view_state::SetUser<S>> {
        self._fields.6 = Option::Some(value.into());
        SessionViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SessionViewBuilder<'a, S>
where
    S: session_view_state::State,
    S::NodeId: session_view_state::IsSet,
    S::Resource: session_view_state::IsSet,
    S::User: session_view_state::IsSet,
    S::CreatedAt: session_view_state::IsSet,
    S::Uri: session_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SessionView<'a> {
        SessionView {
            created_at: self._fields.0.unwrap(),
            expires_at: self._fields.1,
            node_id: self._fields.2.unwrap(),
            relay_url: self._fields.3,
            resource: self._fields.4.unwrap(),
            uri: self._fields.5.unwrap(),
            user: self._fields.6.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>,
        >,
    ) -> SessionView<'a> {
        SessionView {
            created_at: self._fields.0.unwrap(),
            expires_at: self._fields.1,
            node_id: self._fields.2.unwrap(),
            relay_url: self._fields.3,
            resource: self._fields.4.unwrap(),
            uri: self._fields.5.unwrap(),
            user: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}