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

//! Generated bindings for the `app.bsky.draft` Lexicon namespace/module.
pub mod create_draft;
pub mod delete_draft;
pub mod get_drafts;
pub mod update_draft;


#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Tid, Datetime, Language, UriValue};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_bsky::feed::postgate::DisableRule;
use crate::app_bsky::feed::threadgate::FollowerRule;
use crate::app_bsky::feed::threadgate::FollowingRule;
use crate::app_bsky::feed::threadgate::ListRule;
use crate::app_bsky::feed::threadgate::MentionRule;
use crate::com_atproto::label::SelfLabels;
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::app_bsky::draft;
/// A draft containing an array of draft posts.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Draft<S: BosStr = DefaultStr> {
    ///UUIDv4 identifier of the device that created this draft.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub device_id: Option<S>,
    ///The device and/or platform on which the draft was created.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub device_name: Option<S>,
    ///Indicates human language of posts primary text content.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub langs: Option<Vec<Language>>,
    ///Embedding rules for the postgates to be created when this draft is published.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub postgate_embedding_rules: Option<Vec<DisableRule<S>>>,
    ///Array of draft posts that compose this draft.
    pub posts: Vec<draft::DraftPost<S>>,
    ///Allow-rules for the threadgate to be created when this draft is published.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub threadgate_allow: Option<Vec<DraftThreadgateAllowItem<S>>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum DraftThreadgateAllowItem<S: BosStr = DefaultStr> {
    #[serde(rename = "app.bsky.feed.threadgate#mentionRule")]
    ThreadgateMentionRule(Box<MentionRule<S>>),
    #[serde(rename = "app.bsky.feed.threadgate#followerRule")]
    ThreadgateFollowerRule(Box<FollowerRule<S>>),
    #[serde(rename = "app.bsky.feed.threadgate#followingRule")]
    ThreadgateFollowingRule(Box<FollowingRule<S>>),
    #[serde(rename = "app.bsky.feed.threadgate#listRule")]
    ThreadgateListRule(Box<ListRule<S>>),
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DraftEmbedCaption<S: BosStr = DefaultStr> {
    pub content: S,
    pub lang: Language,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DraftEmbedExternal<S: BosStr = DefaultStr> {
    pub uri: UriValue<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DraftEmbedGallery<S: BosStr = DefaultStr> {
    pub items: draft::DraftEmbedGalleryItems<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum DraftEmbedGalleryItemsItem<S: BosStr = DefaultStr> {
    #[serde(rename = "app.bsky.draft.defs#draftEmbedImage")]
    DraftEmbedImage(Box<draft::DraftEmbedImage<S>>),
}

/// The schema-level maxLength of 20 is a future-proof ceiling. Clients should currently enforce a soft limit of 10 items in authoring UIs.
pub type DraftEmbedGalleryItems<S = DefaultStr> = Vec<DraftEmbedGalleryItemsItem<S>>;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DraftEmbedImage<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alt: Option<S>,
    pub local_ref: draft::DraftEmbedLocalRef<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DraftEmbedLocalRef<S: BosStr = DefaultStr> {
    ///Local, on-device ref to file to be embedded. Embeds are currently device-bound for drafts.
    pub path: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DraftEmbedRecord<S: BosStr = DefaultStr> {
    pub record: StrongRef<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DraftEmbedVideo<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alt: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub captions: Option<Vec<draft::DraftEmbedCaption<S>>>,
    pub local_ref: draft::DraftEmbedLocalRef<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// One of the posts that compose a draft.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DraftPost<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub embed_externals: Option<Vec<draft::DraftEmbedExternal<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub embed_gallery: Option<draft::DraftEmbedGallery<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub embed_images: Option<Vec<draft::DraftEmbedImage<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub embed_records: Option<Vec<draft::DraftEmbedRecord<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub embed_videos: Option<Vec<draft::DraftEmbedVideo<S>>>,
    ///Self-label values for this post. Effectively content warnings.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub labels: Option<SelfLabels<S>>,
    ///The primary post content. It has a higher limit than post contents to allow storing a larger text that can later be refined into smaller posts.
    pub text: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// View to present drafts data to users.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DraftView<S: BosStr = DefaultStr> {
    ///The time the draft was created.
    pub created_at: Datetime,
    pub draft: draft::Draft<S>,
    ///A TID to be used as a draft identifier.
    pub id: Tid,
    ///The time the draft was last updated.
    pub updated_at: Datetime,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A draft with an identifier, used to store drafts in private storage (stash).

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DraftWithId<S: BosStr = DefaultStr> {
    pub draft: draft::Draft<S>,
    ///A TID to be used as a draft identifier.
    pub id: Tid,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for Draft<S> {
    fn nsid() -> &'static str {
        "app.bsky.draft.defs"
    }
    fn def_name() -> &'static str {
        "draft"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_draft_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.device_id {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("device_id"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.device_name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("device_name"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.langs {
            #[allow(unused_comparisons)]
            if value.len() > 3usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("langs"),
                    max: 3usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.postgate_embedding_rules {
            #[allow(unused_comparisons)]
            if value.len() > 5usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("postgate_embedding_rules"),
                    max: 5usize,
                    actual: value.len(),
                });
            }
        }
        {
            let value = &self.posts;
            #[allow(unused_comparisons)]
            if value.len() > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("posts"),
                    max: 100usize,
                    actual: value.len(),
                });
            }
        }
        {
            let value = &self.posts;
            #[allow(unused_comparisons)]
            if value.len() < 1usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("posts"),
                    min: 1usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.threadgate_allow {
            #[allow(unused_comparisons)]
            if value.len() > 5usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("threadgate_allow"),
                    max: 5usize,
                    actual: value.len(),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DraftEmbedCaption<S> {
    fn nsid() -> &'static str {
        "app.bsky.draft.defs"
    }
    fn def_name() -> &'static str {
        "draftEmbedCaption"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_draft_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.content;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 10000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("content"),
                    max: 10000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DraftEmbedExternal<S> {
    fn nsid() -> &'static str {
        "app.bsky.draft.defs"
    }
    fn def_name() -> &'static str {
        "draftEmbedExternal"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_draft_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DraftEmbedGallery<S> {
    fn nsid() -> &'static str {
        "app.bsky.draft.defs"
    }
    fn def_name() -> &'static str {
        "draftEmbedGallery"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_draft_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DraftEmbedImage<S> {
    fn nsid() -> &'static str {
        "app.bsky.draft.defs"
    }
    fn def_name() -> &'static str {
        "draftEmbedImage"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_draft_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.alt {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("alt"),
                        max: 2000usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DraftEmbedLocalRef<S> {
    fn nsid() -> &'static str {
        "app.bsky.draft.defs"
    }
    fn def_name() -> &'static str {
        "draftEmbedLocalRef"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_draft_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.path;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 1024usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("path"),
                    max: 1024usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.path;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 1usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("path"),
                    min: 1usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DraftEmbedRecord<S> {
    fn nsid() -> &'static str {
        "app.bsky.draft.defs"
    }
    fn def_name() -> &'static str {
        "draftEmbedRecord"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_draft_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DraftEmbedVideo<S> {
    fn nsid() -> &'static str {
        "app.bsky.draft.defs"
    }
    fn def_name() -> &'static str {
        "draftEmbedVideo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_draft_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.alt {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("alt"),
                        max: 2000usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.captions {
            #[allow(unused_comparisons)]
            if value.len() > 20usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("captions"),
                    max: 20usize,
                    actual: value.len(),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DraftPost<S> {
    fn nsid() -> &'static str {
        "app.bsky.draft.defs"
    }
    fn def_name() -> &'static str {
        "draftPost"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_draft_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.embed_externals {
            #[allow(unused_comparisons)]
            if value.len() > 1usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("embed_externals"),
                    max: 1usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.embed_images {
            #[allow(unused_comparisons)]
            if value.len() > 4usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("embed_images"),
                    max: 4usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.embed_records {
            #[allow(unused_comparisons)]
            if value.len() > 1usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("embed_records"),
                    max: 1usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.embed_videos {
            #[allow(unused_comparisons)]
            if value.len() > 1usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("embed_videos"),
                    max: 1usize,
                    actual: value.len(),
                });
            }
        }
        {
            let value = &self.text;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 10000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("text"),
                    max: 10000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.text;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("text"),
                        max: 1000usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DraftView<S> {
    fn nsid() -> &'static str {
        "app.bsky.draft.defs"
    }
    fn def_name() -> &'static str {
        "draftView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_draft_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DraftWithId<S> {
    fn nsid() -> &'static str {
        "app.bsky.draft.defs"
    }
    fn def_name() -> &'static str {
        "draftWithId"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_draft_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod draft_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 Posts;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Posts = Unset;
    }
    ///State transition - sets the `posts` field to Set
    pub struct SetPosts<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPosts<St> {}
    impl<St: State> State for SetPosts<St> {
        type Posts = Set<members::posts>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `posts` field
        pub struct posts(());
    }
}

/// Builder for constructing an instance of this type.
pub struct DraftBuilder<St: draft_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<S>,
        Option<Vec<Language>>,
        Option<Vec<DisableRule<S>>>,
        Option<Vec<draft::DraftPost<S>>>,
        Option<Vec<DraftThreadgateAllowItem<S>>>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl Draft<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> DraftBuilder<draft_state::Empty, DefaultStr> {
        DraftBuilder::new()
    }
}

impl<S: BosStr> Draft<S> {
    /// Create a new builder for this type
    pub fn builder() -> DraftBuilder<draft_state::Empty, S> {
        DraftBuilder::builder()
    }
}

impl DraftBuilder<draft_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        DraftBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> DraftBuilder<draft_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        DraftBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
    /// Set the `deviceId` field (optional)
    pub fn device_id(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `deviceId` field to an Option value (optional)
    pub fn maybe_device_id(mut self, value: Option<S>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
    /// Set the `deviceName` field (optional)
    pub fn device_name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `deviceName` field to an Option value (optional)
    pub fn maybe_device_name(mut self, value: Option<S>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
    /// Set the `langs` field (optional)
    pub fn langs(mut self, value: impl Into<Option<Vec<Language>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `langs` field to an Option value (optional)
    pub fn maybe_langs(mut self, value: Option<Vec<Language>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
    /// Set the `postgateEmbeddingRules` field (optional)
    pub fn postgate_embedding_rules(
        mut self,
        value: impl Into<Option<Vec<DisableRule<S>>>>,
    ) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `postgateEmbeddingRules` field to an Option value (optional)
    pub fn maybe_postgate_embedding_rules(
        mut self,
        value: Option<Vec<DisableRule<S>>>,
    ) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> DraftBuilder<St, S>
where
    St: draft_state::State,
    St::Posts: draft_state::IsUnset,
{
    /// Set the `posts` field (required)
    pub fn posts(
        mut self,
        value: impl Into<Vec<draft::DraftPost<S>>>,
    ) -> DraftBuilder<draft_state::SetPosts<St>, S> {
        self._fields.4 = Option::Some(value.into());
        DraftBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
    /// Set the `threadgateAllow` field (optional)
    pub fn threadgate_allow(
        mut self,
        value: impl Into<Option<Vec<DraftThreadgateAllowItem<S>>>>,
    ) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `threadgateAllow` field to an Option value (optional)
    pub fn maybe_threadgate_allow(
        mut self,
        value: Option<Vec<DraftThreadgateAllowItem<S>>>,
    ) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St, S: BosStr> DraftBuilder<St, S>
where
    St: draft_state::State,
    St::Posts: draft_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Draft<S> {
        Draft {
            device_id: self._fields.0,
            device_name: self._fields.1,
            langs: self._fields.2,
            postgate_embedding_rules: self._fields.3,
            posts: self._fields.4.unwrap(),
            threadgate_allow: self._fields.5,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Draft<S> {
        Draft {
            device_id: self._fields.0,
            device_name: self._fields.1,
            langs: self._fields.2,
            postgate_embedding_rules: self._fields.3,
            posts: self._fields.4.unwrap(),
            threadgate_allow: self._fields.5,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_bsky_draft_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("app.bsky.draft.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("draft"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("A draft containing an array of draft posts."),
                    ),
                    required: Some(vec![SmolStr::new_static("posts")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("deviceId"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "UUIDv4 identifier of the device that created this draft.",
                                    ),
                                ),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("deviceName"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The device and/or platform on which the draft was created.",
                                    ),
                                ),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("langs"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Indicates human language of posts primary text content.",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    format: Some(LexStringFormat::Language),
                                    ..Default::default()
                                }),
                                max_length: Some(3usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("postgateEmbeddingRules"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Embedding rules for the postgates to be created when this draft is published.",
                                    ),
                                ),
                                items: LexArrayItem::Union(LexRefUnion {
                                    refs: vec![
                                        CowStr::new_static("app.bsky.feed.postgate#disableRule")
                                    ],
                                    ..Default::default()
                                }),
                                max_length: Some(5usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("posts"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Array of draft posts that compose this draft.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#draftPost"),
                                    ..Default::default()
                                }),
                                min_length: Some(1usize),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("threadgateAllow"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Allow-rules for the threadgate to be created when this draft is published.",
                                    ),
                                ),
                                items: LexArrayItem::Union(LexRefUnion {
                                    refs: vec![
                                        CowStr::new_static("app.bsky.feed.threadgate#mentionRule"),
                                        CowStr::new_static("app.bsky.feed.threadgate#followerRule"),
                                        CowStr::new_static("app.bsky.feed.threadgate#followingRule"),
                                        CowStr::new_static("app.bsky.feed.threadgate#listRule")
                                    ],
                                    ..Default::default()
                                }),
                                max_length: Some(5usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("draftEmbedCaption"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("lang"), SmolStr::new_static("content")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("content"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(10000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lang"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Language),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("draftEmbedExternal"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("uri")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("draftEmbedGallery"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("items")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("items"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#draftEmbedGalleryItems"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("draftEmbedGalleryItems"),
                LexUserType::Array(LexArray {
                    items: LexArrayItem::Union(LexRefUnion {
                        refs: vec![CowStr::new_static("#draftEmbedImage")],
                        ..Default::default()
                    }),
                    max_length: Some(20usize),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("draftEmbedImage"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("localRef")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("alt"),
                            LexObjectProperty::String(LexString {
                                max_graphemes: Some(2000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("localRef"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#draftEmbedLocalRef"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("draftEmbedLocalRef"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("path")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("path"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Local, on-device ref to file to be embedded. Embeds are currently device-bound for drafts.",
                                    ),
                                ),
                                min_length: Some(1usize),
                                max_length: Some(1024usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("draftEmbedRecord"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("record")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("record"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("draftEmbedVideo"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("localRef")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("alt"),
                            LexObjectProperty::String(LexString {
                                max_graphemes: Some(2000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("captions"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#draftEmbedCaption"),
                                    ..Default::default()
                                }),
                                max_length: Some(20usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("localRef"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#draftEmbedLocalRef"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("draftPost"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("One of the posts that compose a draft."),
                    ),
                    required: Some(vec![SmolStr::new_static("text")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("embedExternals"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#draftEmbedExternal"),
                                    ..Default::default()
                                }),
                                max_length: Some(1usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("embedGallery"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#draftEmbedGallery"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("embedImages"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#draftEmbedImage"),
                                    ..Default::default()
                                }),
                                max_length: Some(4usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("embedRecords"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#draftEmbedRecord"),
                                    ..Default::default()
                                }),
                                max_length: Some(1usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("embedVideos"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#draftEmbedVideo"),
                                    ..Default::default()
                                }),
                                max_length: Some(1usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("labels"),
                            LexObjectProperty::Union(LexRefUnion {
                                description: Some(
                                    CowStr::new_static(
                                        "Self-label values for this post. Effectively content warnings.",
                                    ),
                                ),
                                refs: vec![
                                    CowStr::new_static("com.atproto.label.defs#selfLabels")
                                ],
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("text"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The primary post content. It has a higher limit than post contents to allow storing a larger text that can later be refined into smaller posts.",
                                    ),
                                ),
                                max_length: Some(10000usize),
                                max_graphemes: Some(1000usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("draftView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("View to present drafts data to users."),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("id"), SmolStr::new_static("draft"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("updatedAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The time the draft was created."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("draft"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#draft"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "A TID to be used as a draft identifier.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Tid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("updatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The time the draft was last updated."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("draftWithId"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A draft with an identifier, used to store drafts in private storage (stash).",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("id"), SmolStr::new_static("draft")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("draft"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#draft"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "A TID to be used as a draft identifier.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Tid),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod draft_embed_caption_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 Content;
        type Lang;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Content = Unset;
        type Lang = Unset;
    }
    ///State transition - sets the `content` field to Set
    pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetContent<St> {}
    impl<St: State> State for SetContent<St> {
        type Content = Set<members::content>;
        type Lang = St::Lang;
    }
    ///State transition - sets the `lang` field to Set
    pub struct SetLang<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLang<St> {}
    impl<St: State> State for SetLang<St> {
        type Content = St::Content;
        type Lang = Set<members::lang>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `content` field
        pub struct content(());
        ///Marker type for the `lang` field
        pub struct lang(());
    }
}

/// Builder for constructing an instance of this type.
pub struct DraftEmbedCaptionBuilder<
    St: draft_embed_caption_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<S>, Option<Language>),
    _type: PhantomData<fn() -> S>,
}

impl DraftEmbedCaption<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> DraftEmbedCaptionBuilder<
        draft_embed_caption_state::Empty,
        DefaultStr,
    > {
        DraftEmbedCaptionBuilder::new()
    }
}

impl<S: BosStr> DraftEmbedCaption<S> {
    /// Create a new builder for this type
    pub fn builder() -> DraftEmbedCaptionBuilder<draft_embed_caption_state::Empty, S> {
        DraftEmbedCaptionBuilder::builder()
    }
}

impl DraftEmbedCaptionBuilder<draft_embed_caption_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        DraftEmbedCaptionBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> DraftEmbedCaptionBuilder<draft_embed_caption_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        DraftEmbedCaptionBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftEmbedCaptionBuilder<St, S>
where
    St: draft_embed_caption_state::State,
    St::Content: draft_embed_caption_state::IsUnset,
{
    /// Set the `content` field (required)
    pub fn content(
        mut self,
        value: impl Into<S>,
    ) -> DraftEmbedCaptionBuilder<draft_embed_caption_state::SetContent<St>, S> {
        self._fields.0 = Option::Some(value.into());
        DraftEmbedCaptionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftEmbedCaptionBuilder<St, S>
where
    St: draft_embed_caption_state::State,
    St::Lang: draft_embed_caption_state::IsUnset,
{
    /// Set the `lang` field (required)
    pub fn lang(
        mut self,
        value: impl Into<Language>,
    ) -> DraftEmbedCaptionBuilder<draft_embed_caption_state::SetLang<St>, S> {
        self._fields.1 = Option::Some(value.into());
        DraftEmbedCaptionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftEmbedCaptionBuilder<St, S>
where
    St: draft_embed_caption_state::State,
    St::Content: draft_embed_caption_state::IsSet,
    St::Lang: draft_embed_caption_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> DraftEmbedCaption<S> {
        DraftEmbedCaption {
            content: self._fields.0.unwrap(),
            lang: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> DraftEmbedCaption<S> {
        DraftEmbedCaption {
            content: self._fields.0.unwrap(),
            lang: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod draft_embed_external_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 Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Uri = Unset;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct DraftEmbedExternalBuilder<
    St: draft_embed_external_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<UriValue<S>>,),
    _type: PhantomData<fn() -> S>,
}

impl DraftEmbedExternal<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> DraftEmbedExternalBuilder<
        draft_embed_external_state::Empty,
        DefaultStr,
    > {
        DraftEmbedExternalBuilder::new()
    }
}

impl<S: BosStr> DraftEmbedExternal<S> {
    /// Create a new builder for this type
    pub fn builder() -> DraftEmbedExternalBuilder<draft_embed_external_state::Empty, S> {
        DraftEmbedExternalBuilder::builder()
    }
}

impl DraftEmbedExternalBuilder<draft_embed_external_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        DraftEmbedExternalBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> DraftEmbedExternalBuilder<draft_embed_external_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        DraftEmbedExternalBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftEmbedExternalBuilder<St, S>
where
    St: draft_embed_external_state::State,
    St::Uri: draft_embed_external_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<UriValue<S>>,
    ) -> DraftEmbedExternalBuilder<draft_embed_external_state::SetUri<St>, S> {
        self._fields.0 = Option::Some(value.into());
        DraftEmbedExternalBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftEmbedExternalBuilder<St, S>
where
    St: draft_embed_external_state::State,
    St::Uri: draft_embed_external_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> DraftEmbedExternal<S> {
        DraftEmbedExternal {
            uri: self._fields.0.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> DraftEmbedExternal<S> {
        DraftEmbedExternal {
            uri: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod draft_embed_gallery_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 Items;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Items = Unset;
    }
    ///State transition - sets the `items` field to Set
    pub struct SetItems<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetItems<St> {}
    impl<St: State> State for SetItems<St> {
        type Items = Set<members::items>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `items` field
        pub struct items(());
    }
}

/// Builder for constructing an instance of this type.
pub struct DraftEmbedGalleryBuilder<
    St: draft_embed_gallery_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<draft::DraftEmbedGalleryItems<S>>,),
    _type: PhantomData<fn() -> S>,
}

impl DraftEmbedGallery<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> DraftEmbedGalleryBuilder<
        draft_embed_gallery_state::Empty,
        DefaultStr,
    > {
        DraftEmbedGalleryBuilder::new()
    }
}

impl<S: BosStr> DraftEmbedGallery<S> {
    /// Create a new builder for this type
    pub fn builder() -> DraftEmbedGalleryBuilder<draft_embed_gallery_state::Empty, S> {
        DraftEmbedGalleryBuilder::builder()
    }
}

impl DraftEmbedGalleryBuilder<draft_embed_gallery_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        DraftEmbedGalleryBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> DraftEmbedGalleryBuilder<draft_embed_gallery_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        DraftEmbedGalleryBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftEmbedGalleryBuilder<St, S>
where
    St: draft_embed_gallery_state::State,
    St::Items: draft_embed_gallery_state::IsUnset,
{
    /// Set the `items` field (required)
    pub fn items(
        mut self,
        value: impl Into<draft::DraftEmbedGalleryItems<S>>,
    ) -> DraftEmbedGalleryBuilder<draft_embed_gallery_state::SetItems<St>, S> {
        self._fields.0 = Option::Some(value.into());
        DraftEmbedGalleryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftEmbedGalleryBuilder<St, S>
where
    St: draft_embed_gallery_state::State,
    St::Items: draft_embed_gallery_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> DraftEmbedGallery<S> {
        DraftEmbedGallery {
            items: self._fields.0.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> DraftEmbedGallery<S> {
        DraftEmbedGallery {
            items: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod draft_embed_image_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 LocalRef;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type LocalRef = Unset;
    }
    ///State transition - sets the `local_ref` field to Set
    pub struct SetLocalRef<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLocalRef<St> {}
    impl<St: State> State for SetLocalRef<St> {
        type LocalRef = Set<members::local_ref>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `local_ref` field
        pub struct local_ref(());
    }
}

/// Builder for constructing an instance of this type.
pub struct DraftEmbedImageBuilder<
    St: draft_embed_image_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<S>, Option<draft::DraftEmbedLocalRef<S>>),
    _type: PhantomData<fn() -> S>,
}

impl DraftEmbedImage<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> DraftEmbedImageBuilder<draft_embed_image_state::Empty, DefaultStr> {
        DraftEmbedImageBuilder::new()
    }
}

impl<S: BosStr> DraftEmbedImage<S> {
    /// Create a new builder for this type
    pub fn builder() -> DraftEmbedImageBuilder<draft_embed_image_state::Empty, S> {
        DraftEmbedImageBuilder::builder()
    }
}

impl DraftEmbedImageBuilder<draft_embed_image_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        DraftEmbedImageBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> DraftEmbedImageBuilder<draft_embed_image_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        DraftEmbedImageBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _type: PhantomData,
        }
    }
}

impl<St: draft_embed_image_state::State, S: BosStr> DraftEmbedImageBuilder<St, S> {
    /// Set the `alt` field (optional)
    pub fn alt(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `alt` field to an Option value (optional)
    pub fn maybe_alt(mut self, value: Option<S>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> DraftEmbedImageBuilder<St, S>
where
    St: draft_embed_image_state::State,
    St::LocalRef: draft_embed_image_state::IsUnset,
{
    /// Set the `localRef` field (required)
    pub fn local_ref(
        mut self,
        value: impl Into<draft::DraftEmbedLocalRef<S>>,
    ) -> DraftEmbedImageBuilder<draft_embed_image_state::SetLocalRef<St>, S> {
        self._fields.1 = Option::Some(value.into());
        DraftEmbedImageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftEmbedImageBuilder<St, S>
where
    St: draft_embed_image_state::State,
    St::LocalRef: draft_embed_image_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> DraftEmbedImage<S> {
        DraftEmbedImage {
            alt: self._fields.0,
            local_ref: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> DraftEmbedImage<S> {
        DraftEmbedImage {
            alt: self._fields.0,
            local_ref: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod draft_embed_record_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 Record;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Record = Unset;
    }
    ///State transition - sets the `record` field to Set
    pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRecord<St> {}
    impl<St: State> State for SetRecord<St> {
        type Record = Set<members::record>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `record` field
        pub struct record(());
    }
}

/// Builder for constructing an instance of this type.
pub struct DraftEmbedRecordBuilder<
    St: draft_embed_record_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<StrongRef<S>>,),
    _type: PhantomData<fn() -> S>,
}

impl DraftEmbedRecord<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> DraftEmbedRecordBuilder<
        draft_embed_record_state::Empty,
        DefaultStr,
    > {
        DraftEmbedRecordBuilder::new()
    }
}

impl<S: BosStr> DraftEmbedRecord<S> {
    /// Create a new builder for this type
    pub fn builder() -> DraftEmbedRecordBuilder<draft_embed_record_state::Empty, S> {
        DraftEmbedRecordBuilder::builder()
    }
}

impl DraftEmbedRecordBuilder<draft_embed_record_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        DraftEmbedRecordBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> DraftEmbedRecordBuilder<draft_embed_record_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        DraftEmbedRecordBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftEmbedRecordBuilder<St, S>
where
    St: draft_embed_record_state::State,
    St::Record: draft_embed_record_state::IsUnset,
{
    /// Set the `record` field (required)
    pub fn record(
        mut self,
        value: impl Into<StrongRef<S>>,
    ) -> DraftEmbedRecordBuilder<draft_embed_record_state::SetRecord<St>, S> {
        self._fields.0 = Option::Some(value.into());
        DraftEmbedRecordBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftEmbedRecordBuilder<St, S>
where
    St: draft_embed_record_state::State,
    St::Record: draft_embed_record_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> DraftEmbedRecord<S> {
        DraftEmbedRecord {
            record: self._fields.0.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> DraftEmbedRecord<S> {
        DraftEmbedRecord {
            record: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod draft_embed_video_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 LocalRef;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type LocalRef = Unset;
    }
    ///State transition - sets the `local_ref` field to Set
    pub struct SetLocalRef<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLocalRef<St> {}
    impl<St: State> State for SetLocalRef<St> {
        type LocalRef = Set<members::local_ref>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `local_ref` field
        pub struct local_ref(());
    }
}

/// Builder for constructing an instance of this type.
pub struct DraftEmbedVideoBuilder<
    St: draft_embed_video_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<Vec<draft::DraftEmbedCaption<S>>>,
        Option<draft::DraftEmbedLocalRef<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl DraftEmbedVideo<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> DraftEmbedVideoBuilder<draft_embed_video_state::Empty, DefaultStr> {
        DraftEmbedVideoBuilder::new()
    }
}

impl<S: BosStr> DraftEmbedVideo<S> {
    /// Create a new builder for this type
    pub fn builder() -> DraftEmbedVideoBuilder<draft_embed_video_state::Empty, S> {
        DraftEmbedVideoBuilder::builder()
    }
}

impl DraftEmbedVideoBuilder<draft_embed_video_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        DraftEmbedVideoBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> DraftEmbedVideoBuilder<draft_embed_video_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        DraftEmbedVideoBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St: draft_embed_video_state::State, S: BosStr> DraftEmbedVideoBuilder<St, S> {
    /// Set the `alt` field (optional)
    pub fn alt(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `alt` field to an Option value (optional)
    pub fn maybe_alt(mut self, value: Option<S>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: draft_embed_video_state::State, S: BosStr> DraftEmbedVideoBuilder<St, S> {
    /// Set the `captions` field (optional)
    pub fn captions(
        mut self,
        value: impl Into<Option<Vec<draft::DraftEmbedCaption<S>>>>,
    ) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `captions` field to an Option value (optional)
    pub fn maybe_captions(
        mut self,
        value: Option<Vec<draft::DraftEmbedCaption<S>>>,
    ) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St, S: BosStr> DraftEmbedVideoBuilder<St, S>
where
    St: draft_embed_video_state::State,
    St::LocalRef: draft_embed_video_state::IsUnset,
{
    /// Set the `localRef` field (required)
    pub fn local_ref(
        mut self,
        value: impl Into<draft::DraftEmbedLocalRef<S>>,
    ) -> DraftEmbedVideoBuilder<draft_embed_video_state::SetLocalRef<St>, S> {
        self._fields.2 = Option::Some(value.into());
        DraftEmbedVideoBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftEmbedVideoBuilder<St, S>
where
    St: draft_embed_video_state::State,
    St::LocalRef: draft_embed_video_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> DraftEmbedVideo<S> {
        DraftEmbedVideo {
            alt: self._fields.0,
            captions: self._fields.1,
            local_ref: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> DraftEmbedVideo<S> {
        DraftEmbedVideo {
            alt: self._fields.0,
            captions: self._fields.1,
            local_ref: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod draft_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 CreatedAt;
        type Draft;
        type Id;
        type UpdatedAt;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Draft = Unset;
        type Id = Unset;
        type UpdatedAt = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type Draft = St::Draft;
        type Id = St::Id;
        type UpdatedAt = St::UpdatedAt;
    }
    ///State transition - sets the `draft` field to Set
    pub struct SetDraft<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDraft<St> {}
    impl<St: State> State for SetDraft<St> {
        type CreatedAt = St::CreatedAt;
        type Draft = Set<members::draft>;
        type Id = St::Id;
        type UpdatedAt = St::UpdatedAt;
    }
    ///State transition - sets the `id` field to Set
    pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetId<St> {}
    impl<St: State> State for SetId<St> {
        type CreatedAt = St::CreatedAt;
        type Draft = St::Draft;
        type Id = Set<members::id>;
        type UpdatedAt = St::UpdatedAt;
    }
    ///State transition - sets the `updated_at` field to Set
    pub struct SetUpdatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUpdatedAt<St> {}
    impl<St: State> State for SetUpdatedAt<St> {
        type CreatedAt = St::CreatedAt;
        type Draft = St::Draft;
        type Id = St::Id;
        type UpdatedAt = Set<members::updated_at>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `draft` field
        pub struct draft(());
        ///Marker type for the `id` field
        pub struct id(());
        ///Marker type for the `updated_at` field
        pub struct updated_at(());
    }
}

/// Builder for constructing an instance of this type.
pub struct DraftViewBuilder<St: draft_view_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<Datetime>, Option<draft::Draft<S>>, Option<Tid>, Option<Datetime>),
    _type: PhantomData<fn() -> S>,
}

impl DraftView<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> DraftViewBuilder<draft_view_state::Empty, DefaultStr> {
        DraftViewBuilder::new()
    }
}

impl<S: BosStr> DraftView<S> {
    /// Create a new builder for this type
    pub fn builder() -> DraftViewBuilder<draft_view_state::Empty, S> {
        DraftViewBuilder::builder()
    }
}

impl DraftViewBuilder<draft_view_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        DraftViewBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> DraftViewBuilder<draft_view_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        DraftViewBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None),
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> DraftViewBuilder<St, S>
where
    St: draft_view_state::State,
    St::Draft: draft_view_state::IsUnset,
{
    /// Set the `draft` field (required)
    pub fn draft(
        mut self,
        value: impl Into<draft::Draft<S>>,
    ) -> DraftViewBuilder<draft_view_state::SetDraft<St>, S> {
        self._fields.1 = Option::Some(value.into());
        DraftViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftViewBuilder<St, S>
where
    St: draft_view_state::State,
    St::Id: draft_view_state::IsUnset,
{
    /// Set the `id` field (required)
    pub fn id(
        mut self,
        value: impl Into<Tid>,
    ) -> DraftViewBuilder<draft_view_state::SetId<St>, S> {
        self._fields.2 = Option::Some(value.into());
        DraftViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftViewBuilder<St, S>
where
    St: draft_view_state::State,
    St::UpdatedAt: draft_view_state::IsUnset,
{
    /// Set the `updatedAt` field (required)
    pub fn updated_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> DraftViewBuilder<draft_view_state::SetUpdatedAt<St>, S> {
        self._fields.3 = Option::Some(value.into());
        DraftViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftViewBuilder<St, S>
where
    St: draft_view_state::State,
    St::CreatedAt: draft_view_state::IsSet,
    St::Draft: draft_view_state::IsSet,
    St::Id: draft_view_state::IsSet,
    St::UpdatedAt: draft_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> DraftView<S> {
        DraftView {
            created_at: self._fields.0.unwrap(),
            draft: self._fields.1.unwrap(),
            id: self._fields.2.unwrap(),
            updated_at: self._fields.3.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> DraftView<S> {
        DraftView {
            created_at: self._fields.0.unwrap(),
            draft: self._fields.1.unwrap(),
            id: self._fields.2.unwrap(),
            updated_at: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod draft_with_id_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 Draft;
        type Id;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Draft = Unset;
        type Id = Unset;
    }
    ///State transition - sets the `draft` field to Set
    pub struct SetDraft<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDraft<St> {}
    impl<St: State> State for SetDraft<St> {
        type Draft = Set<members::draft>;
        type Id = St::Id;
    }
    ///State transition - sets the `id` field to Set
    pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetId<St> {}
    impl<St: State> State for SetId<St> {
        type Draft = St::Draft;
        type Id = Set<members::id>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `draft` field
        pub struct draft(());
        ///Marker type for the `id` field
        pub struct id(());
    }
}

/// Builder for constructing an instance of this type.
pub struct DraftWithIdBuilder<St: draft_with_id_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<draft::Draft<S>>, Option<Tid>),
    _type: PhantomData<fn() -> S>,
}

impl DraftWithId<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> DraftWithIdBuilder<draft_with_id_state::Empty, DefaultStr> {
        DraftWithIdBuilder::new()
    }
}

impl<S: BosStr> DraftWithId<S> {
    /// Create a new builder for this type
    pub fn builder() -> DraftWithIdBuilder<draft_with_id_state::Empty, S> {
        DraftWithIdBuilder::builder()
    }
}

impl DraftWithIdBuilder<draft_with_id_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        DraftWithIdBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> DraftWithIdBuilder<draft_with_id_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        DraftWithIdBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftWithIdBuilder<St, S>
where
    St: draft_with_id_state::State,
    St::Draft: draft_with_id_state::IsUnset,
{
    /// Set the `draft` field (required)
    pub fn draft(
        mut self,
        value: impl Into<draft::Draft<S>>,
    ) -> DraftWithIdBuilder<draft_with_id_state::SetDraft<St>, S> {
        self._fields.0 = Option::Some(value.into());
        DraftWithIdBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftWithIdBuilder<St, S>
where
    St: draft_with_id_state::State,
    St::Id: draft_with_id_state::IsUnset,
{
    /// Set the `id` field (required)
    pub fn id(
        mut self,
        value: impl Into<Tid>,
    ) -> DraftWithIdBuilder<draft_with_id_state::SetId<St>, S> {
        self._fields.1 = Option::Some(value.into());
        DraftWithIdBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DraftWithIdBuilder<St, S>
where
    St: draft_with_id_state::State,
    St::Draft: draft_with_id_state::IsSet,
    St::Id: draft_with_id_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> DraftWithId<S> {
        DraftWithId {
            draft: self._fields.0.unwrap(),
            id: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> DraftWithId<S> {
        DraftWithId {
            draft: self._fields.0.unwrap(),
            id: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}