// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: network.slices.slice.defs
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

//! Generated bindings for the `network.slices.slice` Lexicon namespace/module.
pub mod clear_slice_records;
pub mod create_o_auth_client;
pub mod delete_o_auth_client;
pub mod get_actors;
pub mod get_jetstream_logs;
pub mod get_jetstream_status;
pub mod get_job_logs;
pub mod get_job_status;
pub mod get_o_auth_clients;
pub mod get_slice_records;
pub mod get_sparklines;
pub mod get_sync_summary;
pub mod start_sync;
pub mod stats;
pub mod sync_user_collections;
pub mod update_o_auth_client;


#[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::network_slices::actor::ProfileViewBasic;
use crate::network_slices::slice;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "network.slices.slice",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Slice<S: BosStr = DefaultStr> {
    ///When the slice was created
    pub created_at: Datetime,
    ///Primary domain namespace for this slice (e.g. social.grain)
    pub domain: S,
    ///Name of the slice
    pub name: S,
    #[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 SliceGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Slice<S>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SliceView<S: BosStr = DefaultStr> {
    pub cid: Cid<S>,
    pub created_at: Datetime,
    ///Profile of the slice creator
    pub creator: ProfileViewBasic<S>,
    ///Primary domain namespace for this slice (e.g. social.grain)
    pub domain: S,
    ///Total number of unique indexed actors in this slice
    #[serde(skip_serializing_if = "Option::is_none")]
    pub indexed_actor_count: Option<i64>,
    ///Number of collections with indexed records
    #[serde(skip_serializing_if = "Option::is_none")]
    pub indexed_collection_count: Option<i64>,
    ///Total number of indexed records in this slice
    #[serde(skip_serializing_if = "Option::is_none")]
    pub indexed_record_count: Option<i64>,
    ///Display name of the slice
    pub name: S,
    ///Recent activity sparkline data points for the last 24 hours
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sparkline: Option<Vec<slice::SparklinePoint<S>>>,
    pub uri: AtUri<S>,
    ///Total number of waitlist invites for this slice
    #[serde(skip_serializing_if = "Option::is_none")]
    pub waitlist_invite_count: Option<i64>,
    ///Total number of waitlist requests for this slice
    #[serde(skip_serializing_if = "Option::is_none")]
    pub waitlist_request_count: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SparklinePoint<S: BosStr = DefaultStr> {
    pub count: i64,
    pub timestamp: Datetime,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

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

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

impl<S: BosStr> Collection for Slice<S> {
    const NSID: &'static str = "network.slices.slice";
    type Record = SliceRecord;
}

impl Collection for SliceRecord {
    const NSID: &'static str = "network.slices.slice";
    type Record = SliceRecord;
}

impl<S: BosStr> LexiconSchema for Slice<S> {
    fn nsid() -> &'static str {
        "network.slices.slice"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_network_slices_slice()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.domain;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("domain"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.name;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SliceView<S> {
    fn nsid() -> &'static str {
        "network.slices.slice.defs"
    }
    fn def_name() -> &'static str {
        "sliceView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_network_slices_slice_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SparklinePoint<S> {
    fn nsid() -> &'static str {
        "network.slices.slice.defs"
    }
    fn def_name() -> &'static str {
        "sparklinePoint"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_network_slices_slice_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.count;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("count"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

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

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

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

impl<S: BosStr> Slice<S> {
    /// Create a new builder for this type
    pub fn builder() -> SliceBuilder<slice_state::Empty, S> {
        SliceBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> SliceBuilder<St, S>
where
    St: slice_state::State,
    St::Domain: slice_state::IsUnset,
{
    /// Set the `domain` field (required)
    pub fn domain(
        mut self,
        value: impl Into<S>,
    ) -> SliceBuilder<slice_state::SetDomain<St>, S> {
        self._fields.1 = Option::Some(value.into());
        SliceBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SliceBuilder<St, S>
where
    St: slice_state::State,
    St::Name: slice_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<S>,
    ) -> SliceBuilder<slice_state::SetName<St>, S> {
        self._fields.2 = Option::Some(value.into());
        SliceBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SliceBuilder<St, S>
where
    St: slice_state::State,
    St::CreatedAt: slice_state::IsSet,
    St::Domain: slice_state::IsSet,
    St::Name: slice_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Slice<S> {
        Slice {
            created_at: self._fields.0.unwrap(),
            domain: self._fields.1.unwrap(),
            name: self._fields.2.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>>) -> Slice<S> {
        Slice {
            created_at: self._fields.0.unwrap(),
            domain: self._fields.1.unwrap(),
            name: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_network_slices_slice() -> 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("network.slices.slice"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("name"), SmolStr::new_static("domain"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the slice was created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("domain"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Primary domain namespace for this slice (e.g. social.grain)",
                                        ),
                                    ),
                                    max_length: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("name"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("Name of the slice")),
                                    max_length: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod slice_view_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 Cid;
        type CreatedAt;
        type Creator;
        type Domain;
        type Name;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Cid = Unset;
        type CreatedAt = Unset;
        type Creator = Unset;
        type Domain = Unset;
        type Name = Unset;
        type Uri = Unset;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCid<St> {}
    impl<St: State> State for SetCid<St> {
        type Cid = Set<members::cid>;
        type CreatedAt = St::CreatedAt;
        type Creator = St::Creator;
        type Domain = St::Domain;
        type Name = St::Name;
        type Uri = St::Uri;
    }
    ///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 Cid = St::Cid;
        type CreatedAt = Set<members::created_at>;
        type Creator = St::Creator;
        type Domain = St::Domain;
        type Name = St::Name;
        type Uri = St::Uri;
    }
    ///State transition - sets the `creator` field to Set
    pub struct SetCreator<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreator<St> {}
    impl<St: State> State for SetCreator<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type Creator = Set<members::creator>;
        type Domain = St::Domain;
        type Name = St::Name;
        type Uri = St::Uri;
    }
    ///State transition - sets the `domain` field to Set
    pub struct SetDomain<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDomain<St> {}
    impl<St: State> State for SetDomain<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type Creator = St::Creator;
        type Domain = Set<members::domain>;
        type Name = St::Name;
        type Uri = St::Uri;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type Creator = St::Creator;
        type Domain = St::Domain;
        type Name = Set<members::name>;
        type Uri = St::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type Creator = St::Creator;
        type Domain = St::Domain;
        type Name = St::Name;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `creator` field
        pub struct creator(());
        ///Marker type for the `domain` field
        pub struct domain(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct SliceViewBuilder<St: slice_view_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Cid<S>>,
        Option<Datetime>,
        Option<ProfileViewBasic<S>>,
        Option<S>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<S>,
        Option<Vec<slice::SparklinePoint<S>>>,
        Option<AtUri<S>>,
        Option<i64>,
        Option<i64>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> SliceView<S> {
    /// Create a new builder for this type
    pub fn builder() -> SliceViewBuilder<slice_view_state::Empty, S> {
        SliceViewBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> SliceViewBuilder<St, S>
where
    St: slice_view_state::State,
    St::Cid: slice_view_state::IsUnset,
{
    /// Set the `cid` field (required)
    pub fn cid(
        mut self,
        value: impl Into<Cid<S>>,
    ) -> SliceViewBuilder<slice_view_state::SetCid<St>, S> {
        self._fields.0 = Option::Some(value.into());
        SliceViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> SliceViewBuilder<St, S>
where
    St: slice_view_state::State,
    St::Creator: slice_view_state::IsUnset,
{
    /// Set the `creator` field (required)
    pub fn creator(
        mut self,
        value: impl Into<ProfileViewBasic<S>>,
    ) -> SliceViewBuilder<slice_view_state::SetCreator<St>, S> {
        self._fields.2 = Option::Some(value.into());
        SliceViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SliceViewBuilder<St, S>
where
    St: slice_view_state::State,
    St::Domain: slice_view_state::IsUnset,
{
    /// Set the `domain` field (required)
    pub fn domain(
        mut self,
        value: impl Into<S>,
    ) -> SliceViewBuilder<slice_view_state::SetDomain<St>, S> {
        self._fields.3 = Option::Some(value.into());
        SliceViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: slice_view_state::State, S: BosStr> SliceViewBuilder<St, S> {
    /// Set the `indexedActorCount` field (optional)
    pub fn indexed_actor_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `indexedActorCount` field to an Option value (optional)
    pub fn maybe_indexed_actor_count(mut self, value: Option<i64>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St: slice_view_state::State, S: BosStr> SliceViewBuilder<St, S> {
    /// Set the `indexedCollectionCount` field (optional)
    pub fn indexed_collection_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `indexedCollectionCount` field to an Option value (optional)
    pub fn maybe_indexed_collection_count(mut self, value: Option<i64>) -> Self {
        self._fields.5 = value;
        self
    }
}

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

impl<St, S: BosStr> SliceViewBuilder<St, S>
where
    St: slice_view_state::State,
    St::Name: slice_view_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<S>,
    ) -> SliceViewBuilder<slice_view_state::SetName<St>, S> {
        self._fields.7 = Option::Some(value.into());
        SliceViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: slice_view_state::State, S: BosStr> SliceViewBuilder<St, S> {
    /// Set the `sparkline` field (optional)
    pub fn sparkline(
        mut self,
        value: impl Into<Option<Vec<slice::SparklinePoint<S>>>>,
    ) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `sparkline` field to an Option value (optional)
    pub fn maybe_sparkline(
        mut self,
        value: Option<Vec<slice::SparklinePoint<S>>>,
    ) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St, S: BosStr> SliceViewBuilder<St, S>
where
    St: slice_view_state::State,
    St::Uri: slice_view_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> SliceViewBuilder<slice_view_state::SetUri<St>, S> {
        self._fields.9 = Option::Some(value.into());
        SliceViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St: slice_view_state::State, S: BosStr> SliceViewBuilder<St, S> {
    /// Set the `waitlistRequestCount` field (optional)
    pub fn waitlist_request_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `waitlistRequestCount` field to an Option value (optional)
    pub fn maybe_waitlist_request_count(mut self, value: Option<i64>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St, S: BosStr> SliceViewBuilder<St, S>
where
    St: slice_view_state::State,
    St::Cid: slice_view_state::IsSet,
    St::CreatedAt: slice_view_state::IsSet,
    St::Creator: slice_view_state::IsSet,
    St::Domain: slice_view_state::IsSet,
    St::Name: slice_view_state::IsSet,
    St::Uri: slice_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SliceView<S> {
        SliceView {
            cid: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            creator: self._fields.2.unwrap(),
            domain: self._fields.3.unwrap(),
            indexed_actor_count: self._fields.4,
            indexed_collection_count: self._fields.5,
            indexed_record_count: self._fields.6,
            name: self._fields.7.unwrap(),
            sparkline: self._fields.8,
            uri: self._fields.9.unwrap(),
            waitlist_invite_count: self._fields.10,
            waitlist_request_count: self._fields.11,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> SliceView<S> {
        SliceView {
            cid: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            creator: self._fields.2.unwrap(),
            domain: self._fields.3.unwrap(),
            indexed_actor_count: self._fields.4,
            indexed_collection_count: self._fields.5,
            indexed_record_count: self._fields.6,
            name: self._fields.7.unwrap(),
            sparkline: self._fields.8,
            uri: self._fields.9.unwrap(),
            waitlist_invite_count: self._fields.10,
            waitlist_request_count: self._fields.11,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_network_slices_slice_defs() -> 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("network.slices.slice.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("sliceView"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("name"), SmolStr::new_static("domain"),
                            SmolStr::new_static("creator"),
                            SmolStr::new_static("createdAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("creator"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "network.slices.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("domain"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Primary domain namespace for this slice (e.g. social.grain)",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedActorCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedCollectionCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedRecordCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Display name of the slice"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("sparkline"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Recent activity sparkline data points for the last 24 hours",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#sparklinePoint"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("waitlistInviteCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("waitlistRequestCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("sparklinePoint"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("timestamp"),
                            SmolStr::new_static("count")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("count"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("timestamp"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

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

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

impl<S: BosStr> SparklinePoint<S> {
    /// Create a new builder for this type
    pub fn builder() -> SparklinePointBuilder<sparkline_point_state::Empty, S> {
        SparklinePointBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> SparklinePointBuilder<St, S>
where
    St: sparkline_point_state::State,
    St::Count: sparkline_point_state::IsUnset,
{
    /// Set the `count` field (required)
    pub fn count(
        mut self,
        value: impl Into<i64>,
    ) -> SparklinePointBuilder<sparkline_point_state::SetCount<St>, S> {
        self._fields.0 = Option::Some(value.into());
        SparklinePointBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SparklinePointBuilder<St, S>
where
    St: sparkline_point_state::State,
    St::Timestamp: sparkline_point_state::IsUnset,
{
    /// Set the `timestamp` field (required)
    pub fn timestamp(
        mut self,
        value: impl Into<Datetime>,
    ) -> SparklinePointBuilder<sparkline_point_state::SetTimestamp<St>, S> {
        self._fields.1 = Option::Some(value.into());
        SparklinePointBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SparklinePointBuilder<St, S>
where
    St: sparkline_point_state::State,
    St::Count: sparkline_point_state::IsSet,
    St::Timestamp: sparkline_point_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SparklinePoint<S> {
        SparklinePoint {
            count: self._fields.0.unwrap(),
            timestamp: 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>>,
    ) -> SparklinePoint<S> {
        SparklinePoint {
            count: self._fields.0.unwrap(),
            timestamp: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}