// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: net.anisota.beta.game.inventory
//
// 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::net_anisota::beta::game::inventory;
/// Beta version: Record representing an item in a player's game inventory

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "net.anisota.beta.game.inventory",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Inventory<S: BosStr = DefaultStr> {
    ///When the item was acquired
    pub acquired_at: Datetime,
    ///When the record was created
    pub created_at: Datetime,
    ///Unique identifier for the item from gameItems.json
    pub item_id: S,
    ///Display name of the item
    #[serde(skip_serializing_if = "Option::is_none")]
    pub item_name: Option<S>,
    ///Type category of the item (consumable, tool, equipment, etc.)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub item_type: Option<S>,
    ///Base value of the item in game currency
    #[serde(skip_serializing_if = "Option::is_none")]
    pub item_value: Option<i64>,
    ///When the record was last modified
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_modified: Option<Datetime>,
    ///URI of the game.log record that documents the acquisition of this item
    #[serde(skip_serializing_if = "Option::is_none")]
    pub log_record_uri: Option<S>,
    ///Maximum stack size for this item
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_stack: Option<i64>,
    ///Additional item-specific data (stats, attributes, enchantments, etc.)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub metadata: Option<Data<S>>,
    ///Number of items in the stack
    pub quantity: i64,
    ///Rarity level of the item
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rarity: Option<S>,
    ///How the item was acquired
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source_details: Option<inventory::SourceDetails<S>>,
    ///Whether this item can be stacked with others of the same type
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stackable: Option<bool>,
    #[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 InventoryGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Inventory<S>,
}

/// Additional details about how the item was acquired

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SourceDetails<S: BosStr = DefaultStr> {
    ///URI of the game card that provided this item
    #[serde(skip_serializing_if = "Option::is_none")]
    pub game_card_uri: Option<S>,
    ///ID of the quest that rewarded this item
    #[serde(skip_serializing_if = "Option::is_none")]
    pub quest_id: Option<S>,
    ///Daily reward streak when item was acquired
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reward_streak: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

#[derive(Debug, Serialize, Deserialize)]
pub struct InventoryRecord;
impl XrpcResp for InventoryRecord {
    const NSID: &'static str = "net.anisota.beta.game.inventory";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = InventoryGetRecordOutput<S>;
    type Err = RecordError;
}

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

impl<S: BosStr> Collection for Inventory<S> {
    const NSID: &'static str = "net.anisota.beta.game.inventory";
    type Record = InventoryRecord;
}

impl Collection for InventoryRecord {
    const NSID: &'static str = "net.anisota.beta.game.inventory";
    type Record = InventoryRecord;
}

impl<S: BosStr> LexiconSchema for Inventory<S> {
    fn nsid() -> &'static str {
        "net.anisota.beta.game.inventory"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_beta_game_inventory()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.item_id;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("item_id"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.item_name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 200usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("item_name"),
                    max: 200usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.item_type {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("item_type"),
                    max: 50usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.item_value {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("item_value"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.max_stack {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("max_stack"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.quantity;
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("quantity"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SourceDetails<S> {
    fn nsid() -> &'static str {
        "net.anisota.beta.game.inventory"
    }
    fn def_name() -> &'static str {
        "sourceDetails"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_beta_game_inventory()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod inventory_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 AcquiredAt;
        type CreatedAt;
        type ItemId;
        type Quantity;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type AcquiredAt = Unset;
        type CreatedAt = Unset;
        type ItemId = Unset;
        type Quantity = Unset;
    }
    ///State transition - sets the `acquired_at` field to Set
    pub struct SetAcquiredAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAcquiredAt<St> {}
    impl<St: State> State for SetAcquiredAt<St> {
        type AcquiredAt = Set<members::acquired_at>;
        type CreatedAt = St::CreatedAt;
        type ItemId = St::ItemId;
        type Quantity = St::Quantity;
    }
    ///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 AcquiredAt = St::AcquiredAt;
        type CreatedAt = Set<members::created_at>;
        type ItemId = St::ItemId;
        type Quantity = St::Quantity;
    }
    ///State transition - sets the `item_id` field to Set
    pub struct SetItemId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetItemId<St> {}
    impl<St: State> State for SetItemId<St> {
        type AcquiredAt = St::AcquiredAt;
        type CreatedAt = St::CreatedAt;
        type ItemId = Set<members::item_id>;
        type Quantity = St::Quantity;
    }
    ///State transition - sets the `quantity` field to Set
    pub struct SetQuantity<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetQuantity<St> {}
    impl<St: State> State for SetQuantity<St> {
        type AcquiredAt = St::AcquiredAt;
        type CreatedAt = St::CreatedAt;
        type ItemId = St::ItemId;
        type Quantity = Set<members::quantity>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `acquired_at` field
        pub struct acquired_at(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `item_id` field
        pub struct item_id(());
        ///Marker type for the `quantity` field
        pub struct quantity(());
    }
}

/// Builder for constructing an instance of this type.
pub struct InventoryBuilder<St: inventory_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Datetime>,
        Option<Datetime>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<i64>,
        Option<Datetime>,
        Option<S>,
        Option<i64>,
        Option<Data<S>>,
        Option<i64>,
        Option<S>,
        Option<S>,
        Option<inventory::SourceDetails<S>>,
        Option<bool>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Inventory<S> {
    /// Create a new builder for this type
    pub fn builder() -> InventoryBuilder<inventory_state::Empty, S> {
        InventoryBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> InventoryBuilder<St, S>
where
    St: inventory_state::State,
    St::AcquiredAt: inventory_state::IsUnset,
{
    /// Set the `acquiredAt` field (required)
    pub fn acquired_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> InventoryBuilder<inventory_state::SetAcquiredAt<St>, S> {
        self._fields.0 = Option::Some(value.into());
        InventoryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> InventoryBuilder<St, S>
where
    St: inventory_state::State,
    St::ItemId: inventory_state::IsUnset,
{
    /// Set the `itemId` field (required)
    pub fn item_id(
        mut self,
        value: impl Into<S>,
    ) -> InventoryBuilder<inventory_state::SetItemId<St>, S> {
        self._fields.2 = Option::Some(value.into());
        InventoryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
    /// Set the `itemName` field (optional)
    pub fn item_name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `itemName` field to an Option value (optional)
    pub fn maybe_item_name(mut self, value: Option<S>) -> Self {
        self._fields.3 = value;
        self
    }
}

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

impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
    /// Set the `itemValue` field (optional)
    pub fn item_value(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `itemValue` field to an Option value (optional)
    pub fn maybe_item_value(mut self, value: Option<i64>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
    /// Set the `lastModified` field (optional)
    pub fn last_modified(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `lastModified` field to an Option value (optional)
    pub fn maybe_last_modified(mut self, value: Option<Datetime>) -> Self {
        self._fields.6 = value;
        self
    }
}

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

impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
    /// Set the `maxStack` field (optional)
    pub fn max_stack(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `maxStack` field to an Option value (optional)
    pub fn maybe_max_stack(mut self, value: Option<i64>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
    /// Set the `metadata` field (optional)
    pub fn metadata(mut self, value: impl Into<Option<Data<S>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `metadata` field to an Option value (optional)
    pub fn maybe_metadata(mut self, value: Option<Data<S>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St, S: BosStr> InventoryBuilder<St, S>
where
    St: inventory_state::State,
    St::Quantity: inventory_state::IsUnset,
{
    /// Set the `quantity` field (required)
    pub fn quantity(
        mut self,
        value: impl Into<i64>,
    ) -> InventoryBuilder<inventory_state::SetQuantity<St>, S> {
        self._fields.10 = Option::Some(value.into());
        InventoryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
    /// Set the `rarity` field (optional)
    pub fn rarity(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `rarity` field to an Option value (optional)
    pub fn maybe_rarity(mut self, value: Option<S>) -> Self {
        self._fields.11 = value;
        self
    }
}

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

impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
    /// Set the `sourceDetails` field (optional)
    pub fn source_details(
        mut self,
        value: impl Into<Option<inventory::SourceDetails<S>>>,
    ) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `sourceDetails` field to an Option value (optional)
    pub fn maybe_source_details(
        mut self,
        value: Option<inventory::SourceDetails<S>>,
    ) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
    /// Set the `stackable` field (optional)
    pub fn stackable(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `stackable` field to an Option value (optional)
    pub fn maybe_stackable(mut self, value: Option<bool>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<St, S: BosStr> InventoryBuilder<St, S>
where
    St: inventory_state::State,
    St::AcquiredAt: inventory_state::IsSet,
    St::CreatedAt: inventory_state::IsSet,
    St::ItemId: inventory_state::IsSet,
    St::Quantity: inventory_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Inventory<S> {
        Inventory {
            acquired_at: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            item_id: self._fields.2.unwrap(),
            item_name: self._fields.3,
            item_type: self._fields.4,
            item_value: self._fields.5,
            last_modified: self._fields.6,
            log_record_uri: self._fields.7,
            max_stack: self._fields.8,
            metadata: self._fields.9,
            quantity: self._fields.10.unwrap(),
            rarity: self._fields.11,
            source: self._fields.12,
            source_details: self._fields.13,
            stackable: self._fields.14,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> Inventory<S> {
        Inventory {
            acquired_at: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            item_id: self._fields.2.unwrap(),
            item_name: self._fields.3,
            item_type: self._fields.4,
            item_value: self._fields.5,
            last_modified: self._fields.6,
            log_record_uri: self._fields.7,
            max_stack: self._fields.8,
            metadata: self._fields.9,
            quantity: self._fields.10.unwrap(),
            rarity: self._fields.11,
            source: self._fields.12,
            source_details: self._fields.13,
            stackable: self._fields.14,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_net_anisota_beta_game_inventory() -> 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("net.anisota.beta.game.inventory"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "Beta version: Record representing an item in a player's game inventory",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("itemId"),
                                SmolStr::new_static("quantity"),
                                SmolStr::new_static("acquiredAt"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("acquiredAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the item was acquired"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the record was created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("itemId"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Unique identifier for the item from gameItems.json",
                                        ),
                                    ),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("itemName"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Display name of the item"),
                                    ),
                                    max_length: Some(200usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("itemType"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Type category of the item (consumable, tool, equipment, etc.)",
                                        ),
                                    ),
                                    max_length: Some(50usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("itemValue"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lastModified"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the record was last modified"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("logRecordUri"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "URI of the game.log record that documents the acquisition of this item",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("maxStack"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("metadata"),
                                LexObjectProperty::Unknown(LexUnknown {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("quantity"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("rarity"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Rarity level of the item"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("source"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("How the item was acquired"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("sourceDetails"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#sourceDetails"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("stackable"),
                                LexObjectProperty::Boolean(LexBoolean {
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("sourceDetails"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Additional details about how the item was acquired",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("gameCardUri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "URI of the game card that provided this item",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("questId"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "ID of the quest that rewarded this item",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rewardStreak"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}