// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: io.atcr.hold.notifyManifest
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

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

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

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Did, AtUri};
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::io_atcr::hold::notify_manifest;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct BlobInfo<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub digest: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub size: Option<i64>,
    #[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 ChildManifestInfo<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub digest: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub media_type: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub platform: Option<notify_manifest::PlatformInfo<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub size: Option<i64>,
    #[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 LayerInfo<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub digest: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub media_type: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub size: Option<i64>,
    #[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 NotifyManifest<S: BosStr = DefaultStr> {
    pub manifest: notify_manifest::ManifestInfo<S>,
    ///Manifest digest for building layer record AT-URIs
    pub manifest_digest: S,
    ///Operation type (defaults to 'push' for backward compatibility)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub operation: Option<NotifyManifestOperation<S>>,
    ///Image repository name
    pub repository: S,
    ///Image tag (optional, required for Bluesky posts)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tag: Option<S>,
    ///DID of the image owner
    pub user_did: Did<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Operation type (defaults to 'push' for backward compatibility)

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum NotifyManifestOperation<S: BosStr = DefaultStr> {
    Push,
    Pull,
    Other(S),
}

impl<S: BosStr> NotifyManifestOperation<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Push => "push",
            Self::Pull => "pull",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "push" => Self::Push,
            "pull" => Self::Pull,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for NotifyManifestOperation<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for NotifyManifestOperation<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for NotifyManifestOperation<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for NotifyManifestOperation<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = NotifyManifestOperation<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            NotifyManifestOperation::Push => NotifyManifestOperation::Push,
            NotifyManifestOperation::Pull => NotifyManifestOperation::Pull,
            NotifyManifestOperation::Other(v) => {
                NotifyManifestOperation::Other(v.into_static())
            }
        }
    }
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct NotifyManifestOutput<S: BosStr = DefaultStr> {
    ///Number of layer records created (push only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub layers_created: Option<i64>,
    ///The operation that was performed ('push' or 'pull')
    pub operation: S,
    ///Whether a Bluesky post was created (push only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub post_created: Option<bool>,
    ///AT-URI of the created Bluesky post (if postCreated is true)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub post_uri: Option<AtUri<S>>,
    ///Whether stats were successfully updated
    pub stats_updated: bool,
    ///Whether the operation completed successfully
    pub success: bool,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(
    Serialize,
    Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    thiserror::Error,
    miette::Diagnostic
)]

#[serde(tag = "error", content = "message")]
pub enum NotifyManifestError {
    #[serde(rename = "InvalidOperation")]
    InvalidOperation(Option<SmolStr>),
    #[serde(rename = "UserMismatch")]
    UserMismatch(Option<SmolStr>),
    #[serde(rename = "QuotaExceeded")]
    QuotaExceeded(Option<SmolStr>),
    /// Catch-all for unknown error codes.
    #[serde(untagged)]
    Other { error: SmolStr, message: Option<SmolStr> },
}

impl core::fmt::Display for NotifyManifestError {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::InvalidOperation(msg) => {
                write!(f, "InvalidOperation")?;
                if let Some(msg) = msg {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
            Self::UserMismatch(msg) => {
                write!(f, "UserMismatch")?;
                if let Some(msg) = msg {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
            Self::QuotaExceeded(msg) => {
                write!(f, "QuotaExceeded")?;
                if let Some(msg) = msg {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
            Self::Other { error, message } => {
                write!(f, "{}", error)?;
                if let Some(msg) = message {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
        }
    }
}

/// OCI manifest information

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ManifestInfo<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub config: Option<notify_manifest::BlobInfo<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub layers: Option<Vec<notify_manifest::LayerInfo<S>>>,
    ///Child manifests for multi-arch images
    #[serde(skip_serializing_if = "Option::is_none")]
    pub manifests: Option<Vec<notify_manifest::ChildManifestInfo<S>>>,
    ///OCI media type
    #[serde(skip_serializing_if = "Option::is_none")]
    pub media_type: Option<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 PlatformInfo<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub architecture: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub os: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for BlobInfo<S> {
    fn nsid() -> &'static str {
        "io.atcr.hold.notifyManifest"
    }
    fn def_name() -> &'static str {
        "blobInfo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_atcr_hold_notifyManifest()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.digest {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("digest"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ChildManifestInfo<S> {
    fn nsid() -> &'static str {
        "io.atcr.hold.notifyManifest"
    }
    fn def_name() -> &'static str {
        "childManifestInfo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_atcr_hold_notifyManifest()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.digest {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("digest"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.media_type {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("media_type"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for LayerInfo<S> {
    fn nsid() -> &'static str {
        "io.atcr.hold.notifyManifest"
    }
    fn def_name() -> &'static str {
        "layerInfo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_atcr_hold_notifyManifest()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.digest {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("digest"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.media_type {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("media_type"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

/** Response marker for the `io.atcr.hold.notifyManifest` procedure.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `NotifyManifestOutput<S>` for this endpoint.*/
pub struct NotifyManifestResponse;
impl jacquard_common::xrpc::XrpcResp for NotifyManifestResponse {
    const NSID: &'static str = "io.atcr.hold.notifyManifest";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = NotifyManifestOutput<S>;
    type Err = NotifyManifestError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for NotifyManifest<S> {
    const NSID: &'static str = "io.atcr.hold.notifyManifest";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = NotifyManifestResponse;
}

/** Endpoint marker for the `io.atcr.hold.notifyManifest` procedure.

Path: `/xrpc/io.atcr.hold.notifyManifest`. The request payload type is `NotifyManifest<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
pub struct NotifyManifestRequest;
impl jacquard_common::xrpc::XrpcEndpoint for NotifyManifestRequest {
    const PATH: &'static str = "/xrpc/io.atcr.hold.notifyManifest";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<S: BosStr> = NotifyManifest<S>;
    type Response = NotifyManifestResponse;
}

impl<S: BosStr> LexiconSchema for ManifestInfo<S> {
    fn nsid() -> &'static str {
        "io.atcr.hold.notifyManifest"
    }
    fn def_name() -> &'static str {
        "manifestInfo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_atcr_hold_notifyManifest()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.media_type {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("media_type"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for PlatformInfo<S> {
    fn nsid() -> &'static str {
        "io.atcr.hold.notifyManifest"
    }
    fn def_name() -> &'static str {
        "platformInfo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_atcr_hold_notifyManifest()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.architecture {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("architecture"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.os {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("os"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

fn lexicon_doc_io_atcr_hold_notifyManifest() -> 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("io.atcr.hold.notifyManifest"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("blobInfo"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("digest"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("size"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("childManifestInfo"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("digest"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("mediaType"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("platform"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#platformInfo"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("size"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("layerInfo"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("digest"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("mediaType"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("size"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcProcedure(LexXrpcProcedure {
                    input: Some(LexXrpcBody {
                        encoding: CowStr::new_static("application/json"),
                        schema: Some(
                            LexXrpcBodySchema::Object(LexObject {
                                required: Some(
                                    vec![
                                        SmolStr::new_static("repository"),
                                        SmolStr::new_static("userDid"),
                                        SmolStr::new_static("manifestDigest"),
                                        SmolStr::new_static("manifest")
                                    ],
                                ),
                                properties: {
                                    #[allow(unused_mut)]
                                    let mut map = BTreeMap::new();
                                    map.insert(
                                        SmolStr::new_static("manifest"),
                                        LexObjectProperty::Ref(LexRef {
                                            r#ref: CowStr::new_static("#manifestInfo"),
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("manifestDigest"),
                                        LexObjectProperty::String(LexString {
                                            description: Some(
                                                CowStr::new_static(
                                                    "Manifest digest for building layer record AT-URIs",
                                                ),
                                            ),
                                            max_length: Some(128usize),
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("operation"),
                                        LexObjectProperty::String(LexString {
                                            description: Some(
                                                CowStr::new_static(
                                                    "Operation type (defaults to 'push' for backward compatibility)",
                                                ),
                                            ),
                                            max_length: Some(16usize),
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("repository"),
                                        LexObjectProperty::String(LexString {
                                            description: Some(
                                                CowStr::new_static("Image repository name"),
                                            ),
                                            max_length: Some(256usize),
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("tag"),
                                        LexObjectProperty::String(LexString {
                                            description: Some(
                                                CowStr::new_static(
                                                    "Image tag (optional, required for Bluesky posts)",
                                                ),
                                            ),
                                            max_length: Some(128usize),
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("userDid"),
                                        LexObjectProperty::String(LexString {
                                            description: Some(
                                                CowStr::new_static("DID of the image owner"),
                                            ),
                                            format: Some(LexStringFormat::Did),
                                            ..Default::default()
                                        }),
                                    );
                                    map
                                },
                                ..Default::default()
                            }),
                        ),
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("manifestInfo"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("OCI manifest information")),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("config"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#blobInfo"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("layers"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#layerInfo"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("manifests"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static("Child manifests for multi-arch images"),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#childManifestInfo"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("mediaType"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("OCI media type")),
                                max_length: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("platformInfo"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("architecture"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("os"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod notify_manifest_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 Manifest;
        type ManifestDigest;
        type Repository;
        type UserDid;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Manifest = Unset;
        type ManifestDigest = Unset;
        type Repository = Unset;
        type UserDid = Unset;
    }
    ///State transition - sets the `manifest` field to Set
    pub struct SetManifest<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetManifest<St> {}
    impl<St: State> State for SetManifest<St> {
        type Manifest = Set<members::manifest>;
        type ManifestDigest = St::ManifestDigest;
        type Repository = St::Repository;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `manifest_digest` field to Set
    pub struct SetManifestDigest<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetManifestDigest<St> {}
    impl<St: State> State for SetManifestDigest<St> {
        type Manifest = St::Manifest;
        type ManifestDigest = Set<members::manifest_digest>;
        type Repository = St::Repository;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `repository` field to Set
    pub struct SetRepository<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRepository<St> {}
    impl<St: State> State for SetRepository<St> {
        type Manifest = St::Manifest;
        type ManifestDigest = St::ManifestDigest;
        type Repository = Set<members::repository>;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `user_did` field to Set
    pub struct SetUserDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUserDid<St> {}
    impl<St: State> State for SetUserDid<St> {
        type Manifest = St::Manifest;
        type ManifestDigest = St::ManifestDigest;
        type Repository = St::Repository;
        type UserDid = Set<members::user_did>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `manifest` field
        pub struct manifest(());
        ///Marker type for the `manifest_digest` field
        pub struct manifest_digest(());
        ///Marker type for the `repository` field
        pub struct repository(());
        ///Marker type for the `user_did` field
        pub struct user_did(());
    }
}

/// Builder for constructing an instance of this type.
pub struct NotifyManifestBuilder<
    St: notify_manifest_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<notify_manifest::ManifestInfo<S>>,
        Option<S>,
        Option<NotifyManifestOperation<S>>,
        Option<S>,
        Option<S>,
        Option<Did<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> NotifyManifest<S> {
    /// Create a new builder for this type
    pub fn builder() -> NotifyManifestBuilder<notify_manifest_state::Empty, S> {
        NotifyManifestBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> NotifyManifestBuilder<St, S>
where
    St: notify_manifest_state::State,
    St::Manifest: notify_manifest_state::IsUnset,
{
    /// Set the `manifest` field (required)
    pub fn manifest(
        mut self,
        value: impl Into<notify_manifest::ManifestInfo<S>>,
    ) -> NotifyManifestBuilder<notify_manifest_state::SetManifest<St>, S> {
        self._fields.0 = Option::Some(value.into());
        NotifyManifestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> NotifyManifestBuilder<St, S>
where
    St: notify_manifest_state::State,
    St::ManifestDigest: notify_manifest_state::IsUnset,
{
    /// Set the `manifestDigest` field (required)
    pub fn manifest_digest(
        mut self,
        value: impl Into<S>,
    ) -> NotifyManifestBuilder<notify_manifest_state::SetManifestDigest<St>, S> {
        self._fields.1 = Option::Some(value.into());
        NotifyManifestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: notify_manifest_state::State, S: BosStr> NotifyManifestBuilder<St, S> {
    /// Set the `operation` field (optional)
    pub fn operation(
        mut self,
        value: impl Into<Option<NotifyManifestOperation<S>>>,
    ) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `operation` field to an Option value (optional)
    pub fn maybe_operation(mut self, value: Option<NotifyManifestOperation<S>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> NotifyManifestBuilder<St, S>
where
    St: notify_manifest_state::State,
    St::Repository: notify_manifest_state::IsUnset,
{
    /// Set the `repository` field (required)
    pub fn repository(
        mut self,
        value: impl Into<S>,
    ) -> NotifyManifestBuilder<notify_manifest_state::SetRepository<St>, S> {
        self._fields.3 = Option::Some(value.into());
        NotifyManifestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: notify_manifest_state::State, S: BosStr> NotifyManifestBuilder<St, S> {
    /// Set the `tag` field (optional)
    pub fn tag(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `tag` field to an Option value (optional)
    pub fn maybe_tag(mut self, value: Option<S>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> NotifyManifestBuilder<St, S>
where
    St: notify_manifest_state::State,
    St::UserDid: notify_manifest_state::IsUnset,
{
    /// Set the `userDid` field (required)
    pub fn user_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> NotifyManifestBuilder<notify_manifest_state::SetUserDid<St>, S> {
        self._fields.5 = Option::Some(value.into());
        NotifyManifestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> NotifyManifestBuilder<St, S>
where
    St: notify_manifest_state::State,
    St::Manifest: notify_manifest_state::IsSet,
    St::ManifestDigest: notify_manifest_state::IsSet,
    St::Repository: notify_manifest_state::IsSet,
    St::UserDid: notify_manifest_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> NotifyManifest<S> {
        NotifyManifest {
            manifest: self._fields.0.unwrap(),
            manifest_digest: self._fields.1.unwrap(),
            operation: self._fields.2,
            repository: self._fields.3.unwrap(),
            tag: self._fields.4,
            user_did: self._fields.5.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> NotifyManifest<S> {
        NotifyManifest {
            manifest: self._fields.0.unwrap(),
            manifest_digest: self._fields.1.unwrap(),
            operation: self._fields.2,
            repository: self._fields.3.unwrap(),
            tag: self._fields.4,
            user_did: self._fields.5.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}