// @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.

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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
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::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;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Slice<'a> {
    ///When the slice was created
    pub created_at: Datetime,
    ///Primary domain namespace for this slice (e.g. social.grain)
    #[serde(borrow)]
    pub domain: CowStr<'a>,
    ///Name of the slice
    #[serde(borrow)]
    pub name: CowStr<'a>,
}

/// 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<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cid: Option<Cid<'a>>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    #[serde(borrow)]
    pub value: Slice<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SliceView<'a> {
    #[serde(borrow)]
    pub cid: Cid<'a>,
    pub created_at: Datetime,
    ///Profile of the slice creator
    #[serde(borrow)]
    pub creator: ProfileViewBasic<'a>,
    ///Primary domain namespace for this slice (e.g. social.grain)
    #[serde(borrow)]
    pub domain: CowStr<'a>,
    ///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
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Recent activity sparkline data points for the last 24 hours
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub sparkline: Option<Vec<slice::SparklinePoint<'a>>>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    ///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>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SparklinePoint<'a> {
    pub count: i64,
    pub timestamp: Datetime,
}

impl<'a> Slice<'a> {
    pub fn uri(
        uri: impl Into<CowStr<'a>>,
    ) -> Result<RecordUri<'a, SliceRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
    }
}

/// 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<'de> = SliceGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

impl From<SliceGetRecordOutput<'_>> for Slice<'_> {
    fn from(output: SliceGetRecordOutput<'_>) -> Self {
        use jacquard_common::IntoStatic;
        output.value.into_static()
    }
}

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

/// Builder for constructing an instance of this type
pub struct SliceBuilder<'a, S: slice_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Datetime>, Option<CowStr<'a>>, Option<CowStr<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

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

impl<'a, S> SliceBuilder<'a, S>
where
    S: slice_state::State,
    S::Name: slice_state::IsSet,
    S::Domain: slice_state::IsSet,
    S::CreatedAt: slice_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Slice<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Slice<'a> {
        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 Creator;
        type CreatedAt;
        type Uri;
        type Cid;
        type Domain;
        type Name;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Creator = Unset;
        type CreatedAt = Unset;
        type Uri = Unset;
        type Cid = Unset;
        type Domain = Unset;
        type Name = Unset;
    }
    ///State transition - sets the `creator` field to Set
    pub struct SetCreator<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreator<S> {}
    impl<S: State> State for SetCreator<S> {
        type Creator = Set<members::creator>;
        type CreatedAt = S::CreatedAt;
        type Uri = S::Uri;
        type Cid = S::Cid;
        type Domain = S::Domain;
        type Name = S::Name;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
    impl<S: State> State for SetCreatedAt<S> {
        type Creator = S::Creator;
        type CreatedAt = Set<members::created_at>;
        type Uri = S::Uri;
        type Cid = S::Cid;
        type Domain = S::Domain;
        type Name = S::Name;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type Creator = S::Creator;
        type CreatedAt = S::CreatedAt;
        type Uri = Set<members::uri>;
        type Cid = S::Cid;
        type Domain = S::Domain;
        type Name = S::Name;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCid<S> {}
    impl<S: State> State for SetCid<S> {
        type Creator = S::Creator;
        type CreatedAt = S::CreatedAt;
        type Uri = S::Uri;
        type Cid = Set<members::cid>;
        type Domain = S::Domain;
        type Name = S::Name;
    }
    ///State transition - sets the `domain` field to Set
    pub struct SetDomain<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDomain<S> {}
    impl<S: State> State for SetDomain<S> {
        type Creator = S::Creator;
        type CreatedAt = S::CreatedAt;
        type Uri = S::Uri;
        type Cid = S::Cid;
        type Domain = Set<members::domain>;
        type Name = S::Name;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetName<S> {}
    impl<S: State> State for SetName<S> {
        type Creator = S::Creator;
        type CreatedAt = S::CreatedAt;
        type Uri = S::Uri;
        type Cid = S::Cid;
        type Domain = S::Domain;
        type Name = Set<members::name>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `creator` field
        pub struct creator(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///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 SliceViewBuilder<'a, S: slice_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Cid<'a>>,
        Option<Datetime>,
        Option<ProfileViewBasic<'a>>,
        Option<CowStr<'a>>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<CowStr<'a>>,
        Option<Vec<slice::SparklinePoint<'a>>>,
        Option<AtUri<'a>>,
        Option<i64>,
        Option<i64>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

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

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

impl<'a, S: slice_view_state::State> SliceViewBuilder<'a, 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<'a, S: slice_view_state::State> SliceViewBuilder<'a, 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<'a, S: slice_view_state::State> SliceViewBuilder<'a, 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<'a, S> SliceViewBuilder<'a, S>
where
    S: slice_view_state::State,
    S::Name: slice_view_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> SliceViewBuilder<'a, slice_view_state::SetName<S>> {
        self._fields.7 = Option::Some(value.into());
        SliceViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: slice_view_state::State> SliceViewBuilder<'a, S> {
    /// Set the `sparkline` field (optional)
    pub fn sparkline(
        mut self,
        value: impl Into<Option<Vec<slice::SparklinePoint<'a>>>>,
    ) -> 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<'a>>>,
    ) -> Self {
        self._fields.8 = value;
        self
    }
}

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

impl<'a, S: slice_view_state::State> SliceViewBuilder<'a, 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<'a, S: slice_view_state::State> SliceViewBuilder<'a, 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<'a, S> SliceViewBuilder<'a, S>
where
    S: slice_view_state::State,
    S::Creator: slice_view_state::IsSet,
    S::CreatedAt: slice_view_state::IsSet,
    S::Uri: slice_view_state::IsSet,
    S::Cid: slice_view_state::IsSet,
    S::Domain: slice_view_state::IsSet,
    S::Name: slice_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SliceView<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> SliceView<'a> {
        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 Timestamp;
        type Count;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Timestamp = Unset;
        type Count = Unset;
    }
    ///State transition - sets the `timestamp` field to Set
    pub struct SetTimestamp<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTimestamp<S> {}
    impl<S: State> State for SetTimestamp<S> {
        type Timestamp = Set<members::timestamp>;
        type Count = S::Count;
    }
    ///State transition - sets the `count` field to Set
    pub struct SetCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCount<S> {}
    impl<S: State> State for SetCount<S> {
        type Timestamp = S::Timestamp;
        type Count = Set<members::count>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `timestamp` field
        pub struct timestamp(());
        ///Marker type for the `count` field
        pub struct count(());
    }
}

/// Builder for constructing an instance of this type
pub struct SparklinePointBuilder<'a, S: sparkline_point_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<i64>, Option<Datetime>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S> SparklinePointBuilder<'a, S>
where
    S: sparkline_point_state::State,
    S::Timestamp: sparkline_point_state::IsSet,
    S::Count: sparkline_point_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SparklinePoint<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> SparklinePoint<'a> {
        SparklinePoint {
            count: self._fields.0.unwrap(),
            timestamp: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}