// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: social.arabica.alpha.brew
//
// 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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
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::social_arabica::alpha::brew;
/// Parameters specific to espresso brewing

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EspressoParams<S: BosStr = DefaultStr> {
    ///Pre-infusion time in seconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pre_infusion_seconds: Option<i64>,
    ///Brewing pressure in tenths of a bar (e.g., 90 = 9.0 bar)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pressure: Option<i64>,
    ///Espresso yield/output weight in tenths of a gram (e.g., 360 = 36.0g)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub yield_weight: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A coffee brewing session with parameters and notes

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "social.arabica.alpha.brew",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Brew<S: BosStr = DefaultStr> {
    ///AT-URI reference to the bean record used
    pub bean_ref: AtUri<S>,
    ///AT-URI reference to the brewer/device used
    #[serde(skip_serializing_if = "Option::is_none")]
    pub brewer_ref: Option<AtUri<S>>,
    ///Amount of coffee used in grams
    #[serde(skip_serializing_if = "Option::is_none")]
    pub coffee_amount: Option<i64>,
    ///Timestamp when the brew was made
    pub created_at: Datetime,
    ///Espresso-specific brewing parameters (optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub espresso_params: Option<brew::EspressoParams<S>>,
    ///Grind size setting (can be numeric like '18' or descriptive like 'Medium')
    #[serde(skip_serializing_if = "Option::is_none")]
    pub grind_size: Option<S>,
    ///AT-URI reference to the grinder used
    #[serde(skip_serializing_if = "Option::is_none")]
    pub grinder_ref: Option<AtUri<S>>,
    ///Brewing method (e.g., 'Pour Over', 'French Press', 'Espresso')
    #[serde(skip_serializing_if = "Option::is_none")]
    pub method: Option<S>,
    ///Pour-over-specific brewing parameters (optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pourover_params: Option<brew::PouroverParams<S>>,
    ///Array of pour information for multi-pour methods (e.g., V60)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pours: Option<Vec<brew::Pour<S>>>,
    ///Rating of the brew from 1 to 10
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rating: Option<i64>,
    ///AT-URI reference to the recipe used for this brew
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recipe_ref: Option<AtUri<S>>,
    ///Tasting notes and observations about the brew
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tasting_notes: Option<S>,
    ///Water temperature in tenths of a degree Celsius (e.g., 935 = 93.5°C)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub temperature: Option<i64>,
    ///Total brew time in seconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub time_seconds: Option<i64>,
    ///Amount of water used in grams or milliliters
    #[serde(skip_serializing_if = "Option::is_none")]
    pub water_amount: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct BrewGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Brew<S>,
}

/// Information about a single pour in a multi-pour brewing method

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Pour<S: BosStr = DefaultStr> {
    ///Time of this pour relative to brew start (seconds)
    pub time_seconds: i64,
    ///Amount of water in this pour (grams or ml)
    pub water_amount: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Parameters specific to pour-over brewing

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct PouroverParams<S: BosStr = DefaultStr> {
    ///Bloom wait time in seconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bloom_seconds: Option<i64>,
    ///Water used for bloom in grams
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bloom_water: Option<i64>,
    ///Bypass water added after brewing in grams
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bypass_water: Option<i64>,
    ///Drawdown time in seconds (time after last pour until bed is dry)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub drawdown_seconds: Option<i64>,
    ///Type of filter used (e.g. paper, metal, cloth)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub filter: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> Brew<S> {
    pub fn uri(uri: S) -> Result<RecordUri<S, BrewRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new(uri)?)
    }
}

impl<S: BosStr> LexiconSchema for EspressoParams<S> {
    fn nsid() -> &'static str {
        "social.arabica.alpha.brew"
    }
    fn def_name() -> &'static str {
        "espressoParams"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_arabica_alpha_brew()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.pre_infusion_seconds {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("pre_infusion_seconds"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.pressure {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("pressure"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.yield_weight {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("yield_weight"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

/// Marker type for deserializing records from this collection.

#[derive(Debug, Serialize, Deserialize)]
pub struct BrewRecord;
impl XrpcResp for BrewRecord {
    const NSID: &'static str = "social.arabica.alpha.brew";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = BrewGetRecordOutput<S>;
    type Err = RecordError;
}

impl<S: BosStr> From<BrewGetRecordOutput<S>> for Brew<S> {
    fn from(output: BrewGetRecordOutput<S>) -> Self {
        output.value
    }
}

impl<S: BosStr> Collection for Brew<S> {
    const NSID: &'static str = "social.arabica.alpha.brew";
    type Record = BrewRecord;
}

impl Collection for BrewRecord {
    const NSID: &'static str = "social.arabica.alpha.brew";
    type Record = BrewRecord;
}

impl<S: BosStr> LexiconSchema for Brew<S> {
    fn nsid() -> &'static str {
        "social.arabica.alpha.brew"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_arabica_alpha_brew()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.coffee_amount {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("coffee_amount"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.grind_size {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("grind_size"),
                    max: 50usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.method {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("method"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.rating {
            if *value > 10i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("rating"),
                    max: 10i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.rating {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("rating"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.tasting_notes {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("tasting_notes"),
                    max: 2000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.temperature {
            if *value > 1000i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("temperature"),
                    max: 1000i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.temperature {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("temperature"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.time_seconds {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("time_seconds"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.water_amount {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("water_amount"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Pour<S> {
    fn nsid() -> &'static str {
        "social.arabica.alpha.brew"
    }
    fn def_name() -> &'static str {
        "pour"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_arabica_alpha_brew()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.time_seconds;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("time_seconds"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.water_amount;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("water_amount"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for PouroverParams<S> {
    fn nsid() -> &'static str {
        "social.arabica.alpha.brew"
    }
    fn def_name() -> &'static str {
        "pouroverParams"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_arabica_alpha_brew()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.bloom_seconds {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("bloom_seconds"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.bloom_water {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("bloom_water"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.bypass_water {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("bypass_water"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.drawdown_seconds {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("drawdown_seconds"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.filter {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("filter"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

fn lexicon_doc_social_arabica_alpha_brew() -> 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("social.arabica.alpha.brew"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("espressoParams"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Parameters specific to espresso brewing"),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("preInfusionSeconds"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("pressure"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("yieldWeight"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A coffee brewing session with parameters and notes",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("beanRef"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("beanRef"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "AT-URI reference to the bean record used",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("brewerRef"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "AT-URI reference to the brewer/device used",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("coffeeAmount"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Timestamp when the brew was made"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("espressoParams"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#espressoParams"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("grindSize"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Grind size setting (can be numeric like '18' or descriptive like 'Medium')",
                                        ),
                                    ),
                                    max_length: Some(50usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("grinderRef"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("AT-URI reference to the grinder used"),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("method"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Brewing method (e.g., 'Pour Over', 'French Press', 'Espresso')",
                                        ),
                                    ),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("pouroverParams"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#pouroverParams"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("pours"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Array of pour information for multi-pour methods (e.g., V60)",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("#pour"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("rating"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(10i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("recipeRef"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "AT-URI reference to the recipe used for this brew",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("tastingNotes"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Tasting notes and observations about the brew",
                                        ),
                                    ),
                                    max_length: Some(2000usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("temperature"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    maximum: Some(1000i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("timeSeconds"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("waterAmount"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("pour"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Information about a single pour in a multi-pour brewing method",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("waterAmount"),
                            SmolStr::new_static("timeSeconds")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("timeSeconds"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("waterAmount"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("pouroverParams"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Parameters specific to pour-over brewing"),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("bloomSeconds"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("bloomWater"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("bypassWater"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("drawdownSeconds"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("filter"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Type of filter used (e.g. paper, metal, cloth)",
                                    ),
                                ),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

/// Builder for constructing an instance of this type.
pub struct BrewBuilder<St: brew_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<AtUri<S>>,
        Option<AtUri<S>>,
        Option<i64>,
        Option<Datetime>,
        Option<brew::EspressoParams<S>>,
        Option<S>,
        Option<AtUri<S>>,
        Option<S>,
        Option<brew::PouroverParams<S>>,
        Option<Vec<brew::Pour<S>>>,
        Option<i64>,
        Option<AtUri<S>>,
        Option<S>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Brew<S> {
    /// Create a new builder for this type
    pub fn builder() -> BrewBuilder<brew_state::Empty, S> {
        BrewBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> BrewBuilder<St, S>
where
    St: brew_state::State,
    St::BeanRef: brew_state::IsUnset,
{
    /// Set the `beanRef` field (required)
    pub fn bean_ref(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> BrewBuilder<brew_state::SetBeanRef<St>, S> {
        self._fields.0 = Option::Some(value.into());
        BrewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `brewerRef` field (optional)
    pub fn brewer_ref(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `brewerRef` field to an Option value (optional)
    pub fn maybe_brewer_ref(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `coffeeAmount` field (optional)
    pub fn coffee_amount(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `coffeeAmount` field to an Option value (optional)
    pub fn maybe_coffee_amount(mut self, value: Option<i64>) -> Self {
        self._fields.2 = value;
        self
    }
}

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

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `espressoParams` field (optional)
    pub fn espresso_params(
        mut self,
        value: impl Into<Option<brew::EspressoParams<S>>>,
    ) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `espressoParams` field to an Option value (optional)
    pub fn maybe_espresso_params(
        mut self,
        value: Option<brew::EspressoParams<S>>,
    ) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `grindSize` field (optional)
    pub fn grind_size(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `grindSize` field to an Option value (optional)
    pub fn maybe_grind_size(mut self, value: Option<S>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `grinderRef` field (optional)
    pub fn grinder_ref(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `grinderRef` field to an Option value (optional)
    pub fn maybe_grinder_ref(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `method` field (optional)
    pub fn method(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `method` field to an Option value (optional)
    pub fn maybe_method(mut self, value: Option<S>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `pouroverParams` field (optional)
    pub fn pourover_params(
        mut self,
        value: impl Into<Option<brew::PouroverParams<S>>>,
    ) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `pouroverParams` field to an Option value (optional)
    pub fn maybe_pourover_params(
        mut self,
        value: Option<brew::PouroverParams<S>>,
    ) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `pours` field (optional)
    pub fn pours(mut self, value: impl Into<Option<Vec<brew::Pour<S>>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `pours` field to an Option value (optional)
    pub fn maybe_pours(mut self, value: Option<Vec<brew::Pour<S>>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `rating` field (optional)
    pub fn rating(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `rating` field to an Option value (optional)
    pub fn maybe_rating(mut self, value: Option<i64>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `recipeRef` field (optional)
    pub fn recipe_ref(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `recipeRef` field to an Option value (optional)
    pub fn maybe_recipe_ref(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `tastingNotes` field (optional)
    pub fn tasting_notes(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `tastingNotes` field to an Option value (optional)
    pub fn maybe_tasting_notes(mut self, value: Option<S>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `temperature` field (optional)
    pub fn temperature(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `temperature` field to an Option value (optional)
    pub fn maybe_temperature(mut self, value: Option<i64>) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `timeSeconds` field (optional)
    pub fn time_seconds(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `timeSeconds` field to an Option value (optional)
    pub fn maybe_time_seconds(mut self, value: Option<i64>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<St: brew_state::State, S: BosStr> BrewBuilder<St, S> {
    /// Set the `waterAmount` field (optional)
    pub fn water_amount(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.15 = value.into();
        self
    }
    /// Set the `waterAmount` field to an Option value (optional)
    pub fn maybe_water_amount(mut self, value: Option<i64>) -> Self {
        self._fields.15 = value;
        self
    }
}

impl<St, S: BosStr> BrewBuilder<St, S>
where
    St: brew_state::State,
    St::BeanRef: brew_state::IsSet,
    St::CreatedAt: brew_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Brew<S> {
        Brew {
            bean_ref: self._fields.0.unwrap(),
            brewer_ref: self._fields.1,
            coffee_amount: self._fields.2,
            created_at: self._fields.3.unwrap(),
            espresso_params: self._fields.4,
            grind_size: self._fields.5,
            grinder_ref: self._fields.6,
            method: self._fields.7,
            pourover_params: self._fields.8,
            pours: self._fields.9,
            rating: self._fields.10,
            recipe_ref: self._fields.11,
            tasting_notes: self._fields.12,
            temperature: self._fields.13,
            time_seconds: self._fields.14,
            water_amount: self._fields.15,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Brew<S> {
        Brew {
            bean_ref: self._fields.0.unwrap(),
            brewer_ref: self._fields.1,
            coffee_amount: self._fields.2,
            created_at: self._fields.3.unwrap(),
            espresso_params: self._fields.4,
            grind_size: self._fields.5,
            grinder_ref: self._fields.6,
            method: self._fields.7,
            pourover_params: self._fields.8,
            pours: self._fields.9,
            rating: self._fields.10,
            recipe_ref: self._fields.11,
            tasting_notes: self._fields.12,
            temperature: self._fields.13,
            time_seconds: self._fields.14,
            water_amount: self._fields.15,
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> Pour<S> {
    /// Create a new builder for this type
    pub fn builder() -> PourBuilder<pour_state::Empty, S> {
        PourBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> PourBuilder<St, S>
where
    St: pour_state::State,
    St::TimeSeconds: pour_state::IsUnset,
{
    /// Set the `timeSeconds` field (required)
    pub fn time_seconds(
        mut self,
        value: impl Into<i64>,
    ) -> PourBuilder<pour_state::SetTimeSeconds<St>, S> {
        self._fields.0 = Option::Some(value.into());
        PourBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PourBuilder<St, S>
where
    St: pour_state::State,
    St::WaterAmount: pour_state::IsUnset,
{
    /// Set the `waterAmount` field (required)
    pub fn water_amount(
        mut self,
        value: impl Into<i64>,
    ) -> PourBuilder<pour_state::SetWaterAmount<St>, S> {
        self._fields.1 = Option::Some(value.into());
        PourBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PourBuilder<St, S>
where
    St: pour_state::State,
    St::TimeSeconds: pour_state::IsSet,
    St::WaterAmount: pour_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Pour<S> {
        Pour {
            time_seconds: self._fields.0.unwrap(),
            water_amount: 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>>) -> Pour<S> {
        Pour {
            time_seconds: self._fields.0.unwrap(),
            water_amount: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}