// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: buzz.bookhive.hiveBook
//
// 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::buzz_bookhive::BookIdentifiers;
/// A book within the hive

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "buzz.bookhive.hiveBook",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct HiveBook<S: BosStr = DefaultStr> {
    ///The authors of the book (tab separated)
    pub authors: S,
    ///URL to full-size cover image
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cover: Option<S>,
    pub created_at: Datetime,
    ///Book description/summary
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    ///The book's hive id, used to correlate user's books with the hive
    pub id: S,
    ///External identifiers for the book
    #[serde(skip_serializing_if = "Option::is_none")]
    pub identifiers: Option<BookIdentifiers<S>>,
    ///Average rating (0-1000)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rating: Option<i64>,
    ///Number of ratings
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ratings_count: Option<i64>,
    ///The source service name (e.g. Goodreads)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source: Option<S>,
    ///ID of the book in the source service
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source_id: Option<S>,
    ///URL to the book on the source service
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source_url: Option<S>,
    ///URL to thumbnail image
    pub thumbnail: S,
    ///The title of the book
    pub title: S,
    pub updated_at: Datetime,
    #[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 HiveBookGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: HiveBook<S>,
}

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

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

#[derive(Debug, Serialize, Deserialize)]
pub struct HiveBookRecord;
impl XrpcResp for HiveBookRecord {
    const NSID: &'static str = "buzz.bookhive.hiveBook";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = HiveBookGetRecordOutput<S>;
    type Err = RecordError;
}

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

impl<S: BosStr> Collection for HiveBook<S> {
    const NSID: &'static str = "buzz.bookhive.hiveBook";
    type Record = HiveBookRecord;
}

impl Collection for HiveBookRecord {
    const NSID: &'static str = "buzz.bookhive.hiveBook";
    type Record = HiveBookRecord;
}

impl<S: BosStr> LexiconSchema for HiveBook<S> {
    fn nsid() -> &'static str {
        "buzz.bookhive.hiveBook"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_buzz_bookhive_hiveBook()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.authors;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 512usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("authors"),
                    max: 512usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.authors;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 1usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("authors"),
                    min: 1usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.description {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 5000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("description"),
                    max: 5000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.rating {
            if *value > 1000i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("rating"),
                    max: 1000i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.rating {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("rating"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.title;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 512usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("title"),
                    max: 512usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.title;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 1usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("title"),
                    min: 1usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

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

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

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

impl<S: BosStr> HiveBook<S> {
    /// Create a new builder for this type
    pub fn builder() -> HiveBookBuilder<hive_book_state::Empty, S> {
        HiveBookBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> HiveBookBuilder<St, S>
where
    St: hive_book_state::State,
    St::Authors: hive_book_state::IsUnset,
{
    /// Set the `authors` field (required)
    pub fn authors(
        mut self,
        value: impl Into<S>,
    ) -> HiveBookBuilder<hive_book_state::SetAuthors<St>, S> {
        self._fields.0 = Option::Some(value.into());
        HiveBookBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

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

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

impl<St: hive_book_state::State, S: BosStr> HiveBookBuilder<St, S> {
    /// Set the `identifiers` field (optional)
    pub fn identifiers(mut self, value: impl Into<Option<BookIdentifiers<S>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `identifiers` field to an Option value (optional)
    pub fn maybe_identifiers(mut self, value: Option<BookIdentifiers<S>>) -> Self {
        self._fields.5 = value;
        self
    }
}

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

impl<St: hive_book_state::State, S: BosStr> HiveBookBuilder<St, S> {
    /// Set the `ratingsCount` field (optional)
    pub fn ratings_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `ratingsCount` field to an Option value (optional)
    pub fn maybe_ratings_count(mut self, value: Option<i64>) -> Self {
        self._fields.7 = value;
        self
    }
}

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

impl<St: hive_book_state::State, S: BosStr> HiveBookBuilder<St, S> {
    /// Set the `sourceId` field (optional)
    pub fn source_id(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `sourceId` field to an Option value (optional)
    pub fn maybe_source_id(mut self, value: Option<S>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St: hive_book_state::State, S: BosStr> HiveBookBuilder<St, S> {
    /// Set the `sourceUrl` field (optional)
    pub fn source_url(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `sourceUrl` field to an Option value (optional)
    pub fn maybe_source_url(mut self, value: Option<S>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St, S: BosStr> HiveBookBuilder<St, S>
where
    St: hive_book_state::State,
    St::Thumbnail: hive_book_state::IsUnset,
{
    /// Set the `thumbnail` field (required)
    pub fn thumbnail(
        mut self,
        value: impl Into<S>,
    ) -> HiveBookBuilder<hive_book_state::SetThumbnail<St>, S> {
        self._fields.11 = Option::Some(value.into());
        HiveBookBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> HiveBookBuilder<St, S>
where
    St: hive_book_state::State,
    St::Title: hive_book_state::IsUnset,
{
    /// Set the `title` field (required)
    pub fn title(
        mut self,
        value: impl Into<S>,
    ) -> HiveBookBuilder<hive_book_state::SetTitle<St>, S> {
        self._fields.12 = Option::Some(value.into());
        HiveBookBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> HiveBookBuilder<St, S>
where
    St: hive_book_state::State,
    St::Authors: hive_book_state::IsSet,
    St::CreatedAt: hive_book_state::IsSet,
    St::Id: hive_book_state::IsSet,
    St::Thumbnail: hive_book_state::IsSet,
    St::Title: hive_book_state::IsSet,
    St::UpdatedAt: hive_book_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> HiveBook<S> {
        HiveBook {
            authors: self._fields.0.unwrap(),
            cover: self._fields.1,
            created_at: self._fields.2.unwrap(),
            description: self._fields.3,
            id: self._fields.4.unwrap(),
            identifiers: self._fields.5,
            rating: self._fields.6,
            ratings_count: self._fields.7,
            source: self._fields.8,
            source_id: self._fields.9,
            source_url: self._fields.10,
            thumbnail: self._fields.11.unwrap(),
            title: self._fields.12.unwrap(),
            updated_at: self._fields.13.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>>) -> HiveBook<S> {
        HiveBook {
            authors: self._fields.0.unwrap(),
            cover: self._fields.1,
            created_at: self._fields.2.unwrap(),
            description: self._fields.3,
            id: self._fields.4.unwrap(),
            identifiers: self._fields.5,
            rating: self._fields.6,
            ratings_count: self._fields.7,
            source: self._fields.8,
            source_id: self._fields.9,
            source_url: self._fields.10,
            thumbnail: self._fields.11.unwrap(),
            title: self._fields.12.unwrap(),
            updated_at: self._fields.13.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_buzz_bookhive_hiveBook() -> 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("buzz.bookhive.hiveBook"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(CowStr::new_static("A book within the hive")),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("id"), SmolStr::new_static("title"),
                                SmolStr::new_static("authors"),
                                SmolStr::new_static("createdAt"),
                                SmolStr::new_static("updatedAt"),
                                SmolStr::new_static("thumbnail")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("authors"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The authors of the book (tab separated)",
                                        ),
                                    ),
                                    min_length: Some(1usize),
                                    max_length: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("cover"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("URL to full-size cover image"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("description"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Book description/summary"),
                                    ),
                                    max_length: Some(5000usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("id"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The book's hive id, used to correlate user's books with the hive",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("identifiers"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "buzz.bookhive.defs#bookIdentifiers",
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("rating"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    maximum: Some(1000i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("ratingsCount"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("source"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The source service name (e.g. Goodreads)",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("sourceId"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("ID of the book in the source service"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("sourceUrl"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("URL to the book on the source service"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("thumbnail"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("URL to thumbnail image"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("title"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("The title of the book"),
                                    ),
                                    min_length: Some(1usize),
                                    max_length: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("updatedAt"),
                                LexObjectProperty::String(LexString {
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}