//! GENERATED FILE — DO NOT EDIT. //! Source: packages/core-contracts/schemas/*.schema.json (run `pnpm gen`) #![allow(clippy::all, rustdoc::all, dead_code, unused_imports)] #![allow(clippy::needless_lifetimes)] #![allow(clippy::match_single_binding)] #![allow(clippy::clone_on_copy)] #[doc = "Prefixed, URL-safe identifier, e.g. site_01HZX8K3Q9. The prefix names the entity kind; agents and the MCP server pass these as opaque handles."] #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] #[serde(transparent)] pub struct Id(::std::string::String); impl ::std::ops::Deref for Id { type Target = ::std::string::String; fn deref(&self) -> &::std::string::String { &self.0 } } impl ::std::convert::From for ::std::string::String { fn from(value: Id) -> Self { value.0 } } impl ::std::str::FromStr for Id { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { if value.chars().count() > 48usize { return Err("longer than 48 characters".into()); } if value.chars().count() < 8usize { return Err("shorter than 8 characters".into()); } static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(|| { ::regress::Regex::new("^[a-z]+_[A-Za-z0-9]{6,32}$").unwrap() }); if PATTERN.find(value).is_none() { return Err("doesn't match pattern \"^[a-z]+_[A-Za-z0-9]{6,32}$\"".into()); } Ok(Self(value.to_string())) } } impl ::std::convert::TryFrom<&str> for Id { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for Id { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } impl<'de> ::serde::Deserialize<'de> for Id { fn deserialize(deserializer: D) -> ::std::result::Result where D: ::serde::Deserializer<'de>, { ::std::string::String::deserialize(deserializer)? .parse() .map_err(|e: self::error::ConversionError| { ::custom(e.to_string()) }) } } #[doc = "BCP 47 language tag, e.g. en, tr, en-US."] #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] #[serde(transparent)] pub struct Locale(::std::string::String); impl ::std::ops::Deref for Locale { type Target = ::std::string::String; fn deref(&self) -> &::std::string::String { &self.0 } } impl ::std::convert::From for ::std::string::String { fn from(value: Locale) -> Self { value.0 } } impl ::std::str::FromStr for Locale { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(|| { ::regress::Regex::new("^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$").unwrap() }); if PATTERN.find(value).is_none() { return Err("doesn't match pattern \"^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$\"".into()); } Ok(Self(value.to_string())) } } impl ::std::convert::TryFrom<&str> for Locale { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for Locale { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } impl<'de> ::serde::Deserialize<'de> for Locale { fn deserialize(deserializer: D) -> ::std::result::Result where D: ::serde::Deserializer<'de>, { ::std::string::String::deserialize(deserializer)? .parse() .map_err(|e: self::error::ConversionError| { ::custom(e.to_string()) }) } } #[doc = "A named navigation menu of a site (e.g. 'primary', 'footer', 'sidebar'): an ordered tree of items. Items point at pages, entries and terms by id, so renames and slug changes never break them; an item whose target is gone, retired or unpublished is hidden by the renderer, never rendered as a dead link (RFC-0003)."] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(deny_unknown_fields)] pub struct Menu { #[serde(rename = "createdAt")] pub created_at: Timestamp, pub id: Id, #[doc = "Top-level items in display order. Empty means the site deliberately shows no items here (a missing menu means the theme's derived default)."] pub items: ::std::vec::Vec, #[doc = "Where themes place the menu ('primary', 'footer', 'sidebar', …). Unique per site and immutable once created."] pub key: Slug, #[doc = "Deepest level an item may sit at; top-level items are level 1. The store refuses deeper trees."] #[serde(rename = "maxDepth")] pub max_depth: ::std::num::NonZeroU64, #[serde(skip_serializing_if = "::std::option::Option::is_none")] pub metadata: ::std::option::Option, pub rev: Revision, #[serde(rename = "schemaVersion")] pub schema_version: SchemaVersion, #[serde(rename = "siteId")] pub site_id: Id, #[serde(rename = "updatedAt")] pub updated_at: Timestamp, } #[doc = "RFC-0025 25d (RFC-0003 amendment): how a top-level item with children opens in the header. `mega`: one wide panel, its children as columns (a group's children are the column's links)."] #[derive( :: serde :: Deserialize, :: serde :: Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, )] pub enum MenuDisplay { #[serde(rename = "mega")] Mega, } impl ::std::fmt::Display for MenuDisplay { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Self::Mega => f.write_str("mega"), } } } impl ::std::str::FromStr for MenuDisplay { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { match value { "mega" => Ok(Self::Mega), _ => Err("invalid value".into()), } } } impl ::std::convert::TryFrom<&str> for MenuDisplay { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for MenuDisplay { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } #[doc = "One item, discriminated by `kind` (what it links to). Children, in display order, form the tree; an item has exactly one parent by construction, so the tree has no cycles."] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(tag = "kind", deny_unknown_fields)] pub enum MenuItem { #[doc = "PageMenuItem\n\nLinks to a page by id; the label falls back to the page title."] #[serde(rename = "page")] Page { #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] children: ::std::vec::Vec, #[serde(skip_serializing_if = "::std::option::Option::is_none")] display: ::std::option::Option, id: Id, #[serde(skip_serializing_if = "::std::option::Option::is_none")] labels: ::std::option::Option, #[serde(rename = "pageId")] page_id: Id, }, #[doc = "EntryMenuItem\n\nLinks to a content entry by id (at //); the label falls back to the entry title."] #[serde(rename = "contentEntry")] ContentEntry { #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] children: ::std::vec::Vec, #[serde(skip_serializing_if = "::std::option::Option::is_none")] display: ::std::option::Option, #[serde(rename = "entryId")] entry_id: Id, id: Id, #[serde(skip_serializing_if = "::std::option::Option::is_none")] labels: ::std::option::Option, }, #[doc = "TermMenuItem\n\nLinks to a term's archive by term id; the label falls back to the term name in the locale."] #[serde(rename = "term")] Term { #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] children: ::std::vec::Vec, #[serde(skip_serializing_if = "::std::option::Option::is_none")] display: ::std::option::Option, id: Id, #[serde(skip_serializing_if = "::std::option::Option::is_none")] labels: ::std::option::Option, #[serde(rename = "termId")] term_id: Id, }, #[doc = "CollectionMenuItem\n\nLinks to the index of a content collection, wherever the theme serves it. Collections have no node and no title, so labels are required."] #[serde(rename = "collection")] Collection { #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] children: ::std::vec::Vec, collection: Slug, #[serde(skip_serializing_if = "::std::option::Option::is_none")] display: ::std::option::Option, id: Id, labels: MenuLabels, }, #[doc = "UrlMenuItem\n\nLinks to an external https URL. The host is ASCII (internationalised names in punycode) and carries no user-info, so a label cannot hide where the link goes."] #[serde(rename = "url")] Url { #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] children: ::std::vec::Vec, #[serde(skip_serializing_if = "::std::option::Option::is_none")] display: ::std::option::Option, href: MenuItemHref, id: Id, labels: MenuLabels, #[doc = "Open in a new tab (rendered with rel=\"noopener noreferrer\")."] #[serde( rename = "newTab", skip_serializing_if = "::std::option::Option::is_none" )] new_tab: ::std::option::Option, }, #[doc = "GroupMenuItem\n\nA label without a link that holds other items: a dropdown parent or a sidebar section heading. Hidden when none of its children is shown."] #[serde(rename = "group")] Group { children: ::std::vec::Vec, #[serde(skip_serializing_if = "::std::option::Option::is_none")] display: ::std::option::Option, id: Id, labels: MenuLabels, }, } #[doc = "`MenuItemHref`"] #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] #[serde(transparent)] pub struct MenuItemHref(::std::string::String); impl ::std::ops::Deref for MenuItemHref { type Target = ::std::string::String; fn deref(&self) -> &::std::string::String { &self.0 } } impl ::std::convert::From for ::std::string::String { fn from(value: MenuItemHref) -> Self { value.0 } } impl ::std::str::FromStr for MenuItemHref { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { if value.chars().count() > 2048usize { return Err("longer than 2048 characters".into()); } static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new( || { :: regress :: Regex :: new ("^https://[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?(?::[0-9]{1,5})?(?:[/?#][^\\s\\\\\\x00-\\x1F\\x7F]*)?$") . unwrap () }, ); if PATTERN.find(value).is_none() { return Err ("doesn't match pattern \"^https://[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?(?::[0-9]{1,5})?(?:[/?#][^\\s\\\\\\x00-\\x1F\\x7F]*)?$\"" . into ()) ; } Ok(Self(value.to_string())) } } impl ::std::convert::TryFrom<&str> for MenuItemHref { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for MenuItemHref { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } impl<'de> ::serde::Deserialize<'de> for MenuItemHref { fn deserialize(deserializer: D) -> ::std::result::Result where D: ::serde::Deserializer<'de>, { ::std::string::String::deserialize(deserializer)? .parse() .map_err(|e: self::error::ConversionError| { ::custom(e.to_string()) }) } } #[doc = "Item label per locale; plain text, no control characters or surrounding whitespace. A locale without a label falls back to the default locale's label, then to the target's own title or name."] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(transparent)] pub struct MenuLabels(pub ::std::collections::HashMap); impl ::std::ops::Deref for MenuLabels { type Target = ::std::collections::HashMap; fn deref(&self) -> &::std::collections::HashMap { &self.0 } } impl ::std::convert::From for ::std::collections::HashMap { fn from(value: MenuLabels) -> Self { value.0 } } impl ::std::convert::From<::std::collections::HashMap> for MenuLabels { fn from(value: ::std::collections::HashMap) -> Self { Self(value) } } #[doc = "`MenuLabelsValue`"] #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] #[serde(transparent)] pub struct MenuLabelsValue(::std::string::String); impl ::std::ops::Deref for MenuLabelsValue { type Target = ::std::string::String; fn deref(&self) -> &::std::string::String { &self.0 } } impl ::std::convert::From for ::std::string::String { fn from(value: MenuLabelsValue) -> Self { value.0 } } impl ::std::str::FromStr for MenuLabelsValue { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { if value.chars().count() > 100usize { return Err("longer than 100 characters".into()); } if value.chars().count() < 1usize { return Err("shorter than 1 characters".into()); } static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(|| { ::regress::Regex::new( "^[^\\s\\x00-\\x1F\\x7F](?:[^\\x00-\\x1F\\x7F]*[^\\s\\x00-\\x1F\\x7F])?$", ) .unwrap() }); if PATTERN.find(value).is_none() { return Err ("doesn't match pattern \"^[^\\s\\x00-\\x1F\\x7F](?:[^\\x00-\\x1F\\x7F]*[^\\s\\x00-\\x1F\\x7F])?$\"" . into ()) ; } Ok(Self(value.to_string())) } } impl ::std::convert::TryFrom<&str> for MenuLabelsValue { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for MenuLabelsValue { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } impl<'de> ::serde::Deserialize<'de> for MenuLabelsValue { fn deserialize(deserializer: D) -> ::std::result::Result where D: ::serde::Deserializer<'de>, { ::std::string::String::deserialize(deserializer)? .parse() .map_err(|e: self::error::ConversionError| { ::custom(e.to_string()) }) } } #[doc = "Free-form string-to-string map for extensions. Keys should be namespaced (e.g. cloudhal.source)."] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(transparent)] pub struct Metadata(pub ::std::collections::HashMap<::std::string::String, ::std::string::String>); impl ::std::ops::Deref for Metadata { type Target = ::std::collections::HashMap<::std::string::String, ::std::string::String>; fn deref(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { &self.0 } } impl ::std::convert::From for ::std::collections::HashMap<::std::string::String, ::std::string::String> { fn from(value: Metadata) -> Self { value.0 } } impl ::std::convert::From<::std::collections::HashMap<::std::string::String, ::std::string::String>> for Metadata { fn from( value: ::std::collections::HashMap<::std::string::String, ::std::string::String>, ) -> Self { Self(value) } } #[doc = "Monotonic per-node revision used for optimistic locking (compare-and-swap on write)."] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(transparent)] pub struct Revision(pub u64); impl ::std::ops::Deref for Revision { type Target = u64; fn deref(&self) -> &u64 { &self.0 } } impl ::std::convert::From for u64 { fn from(value: Revision) -> Self { value.0 } } impl ::std::convert::From for Revision { fn from(value: u64) -> Self { Self(value) } } impl ::std::fmt::Display for Revision { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { self.0.fmt(f) } } impl ::std::str::FromStr for Revision { type Err = ::Err; fn from_str(value: &str) -> ::std::result::Result { Ok(Self(value.parse()?)) } } impl ::std::convert::TryFrom<&str> for Revision { type Error = ::Err; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom for Revision { type Error = ::Err; fn try_from(value: String) -> ::std::result::Result { value.parse() } } #[doc = "Version of this contract. Readers reject unknown versions; migrations move documents forward one version at a time."] #[derive(:: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(transparent)] pub struct SchemaVersion(i64); impl ::std::ops::Deref for SchemaVersion { type Target = i64; fn deref(&self) -> &i64 { &self.0 } } impl ::std::convert::From for i64 { fn from(value: SchemaVersion) -> Self { value.0 } } impl ::std::convert::TryFrom for SchemaVersion { type Error = self::error::ConversionError; fn try_from(value: i64) -> ::std::result::Result { if ![1_i64].contains(&value) { Err("invalid value".into()) } else { Ok(Self(value)) } } } impl<'de> ::serde::Deserialize<'de> for SchemaVersion { fn deserialize(deserializer: D) -> ::std::result::Result where D: ::serde::Deserializer<'de>, { Self::try_from(::deserialize(deserializer)?) .map_err(|e| ::custom(e.to_string())) } } #[doc = "Lower-case URL segment."] #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] #[serde(transparent)] pub struct Slug(::std::string::String); impl ::std::ops::Deref for Slug { type Target = ::std::string::String; fn deref(&self) -> &::std::string::String { &self.0 } } impl ::std::convert::From for ::std::string::String { fn from(value: Slug) -> Self { value.0 } } impl ::std::str::FromStr for Slug { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { if value.chars().count() > 128usize { return Err("longer than 128 characters".into()); } if value.chars().count() < 1usize { return Err("shorter than 1 characters".into()); } static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(|| { ::regress::Regex::new("^[a-z0-9]+(?:-[a-z0-9]+)*$").unwrap() }); if PATTERN.find(value).is_none() { return Err("doesn't match pattern \"^[a-z0-9]+(?:-[a-z0-9]+)*$\"".into()); } Ok(Self(value.to_string())) } } impl ::std::convert::TryFrom<&str> for Slug { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for Slug { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } impl<'de> ::serde::Deserialize<'de> for Slug { fn deserialize(deserializer: D) -> ::std::result::Result where D: ::serde::Deserializer<'de>, { ::std::string::String::deserialize(deserializer)? .parse() .map_err(|e: self::error::ConversionError| { ::custom(e.to_string()) }) } } #[doc = "RFC 3339 / ISO 8601 instant in UTC."] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(transparent)] pub struct Timestamp(pub ::chrono::DateTime<::chrono::offset::Utc>); impl ::std::ops::Deref for Timestamp { type Target = ::chrono::DateTime<::chrono::offset::Utc>; fn deref(&self) -> &::chrono::DateTime<::chrono::offset::Utc> { &self.0 } } impl ::std::convert::From for ::chrono::DateTime<::chrono::offset::Utc> { fn from(value: Timestamp) -> Self { value.0 } } impl ::std::convert::From<::chrono::DateTime<::chrono::offset::Utc>> for Timestamp { fn from(value: ::chrono::DateTime<::chrono::offset::Utc>) -> Self { Self(value) } } impl ::std::fmt::Display for Timestamp { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { self.0.fmt(f) } } impl ::std::str::FromStr for Timestamp { type Err = <::chrono::DateTime<::chrono::offset::Utc> as ::std::str::FromStr>::Err; fn from_str(value: &str) -> ::std::result::Result { Ok(Self(value.parse()?)) } } impl ::std::convert::TryFrom<&str> for Timestamp { type Error = <::chrono::DateTime<::chrono::offset::Utc> as ::std::str::FromStr>::Err; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom for Timestamp { type Error = <::chrono::DateTime<::chrono::offset::Utc> as ::std::str::FromStr>::Err; fn try_from(value: String) -> ::std::result::Result { value.parse() } } #[doc = " Error types."] pub mod error { #[doc = r" Error from a `TryFrom` or `FromStr` implementation."] pub struct ConversionError(::std::borrow::Cow<'static, str>); impl ::std::error::Error for ConversionError {} impl ::std::fmt::Display for ConversionError { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { ::std::fmt::Display::fmt(&self.0, f) } } impl ::std::fmt::Debug for ConversionError { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { ::std::fmt::Debug::fmt(&self.0, f) } } impl From<&'static str> for ConversionError { fn from(value: &'static str) -> Self { Self(value.into()) } } impl From for ConversionError { fn from(value: String) -> Self { Self(value.into()) } } }