// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: sh.weaver.notebook.getEntryNotebooks
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{AtUri, Cid};
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::sh_weaver::actor::ProfileViewBasic;
use crate::sh_weaver::notebook::get_entry_notebooks;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetEntryNotebooks<'a> {
    #[serde(borrow)]
    pub entry: AtUri<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetEntryNotebooksOutput<'a> {
    #[serde(borrow)]
    pub notebooks: Vec<get_entry_notebooks::NotebookRef<'a>>,
}

/// Reference to a notebook containing this entry.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct NotebookRef<'a> {
    #[serde(borrow)]
    pub cid: Cid<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub owner: Option<ProfileViewBasic<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub title: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
}

/// Response type for sh.weaver.notebook.getEntryNotebooks
pub struct GetEntryNotebooksResponse;
impl jacquard_common::xrpc::XrpcResp for GetEntryNotebooksResponse {
    const NSID: &'static str = "sh.weaver.notebook.getEntryNotebooks";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GetEntryNotebooksOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for GetEntryNotebooks<'a> {
    const NSID: &'static str = "sh.weaver.notebook.getEntryNotebooks";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetEntryNotebooksResponse;
}

/// Endpoint type for sh.weaver.notebook.getEntryNotebooks
pub struct GetEntryNotebooksRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetEntryNotebooksRequest {
    const PATH: &'static str = "/xrpc/sh.weaver.notebook.getEntryNotebooks";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetEntryNotebooks<'de>;
    type Response = GetEntryNotebooksResponse;
}

impl<'a> LexiconSchema for NotebookRef<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.getEntryNotebooks"
    }
    fn def_name() -> &'static str {
        "notebookRef"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_getEntryNotebooks()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod get_entry_notebooks_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 Entry;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Entry = Unset;
    }
    ///State transition - sets the `entry` field to Set
    pub struct SetEntry<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetEntry<S> {}
    impl<S: State> State for SetEntry<S> {
        type Entry = Set<members::entry>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `entry` field
        pub struct entry(());
    }
}

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

impl<'a> GetEntryNotebooks<'a> {
    /// Create a new builder for this type
    pub fn new() -> GetEntryNotebooksBuilder<'a, get_entry_notebooks_state::Empty> {
        GetEntryNotebooksBuilder::new()
    }
}

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

impl<'a, S> GetEntryNotebooksBuilder<'a, S>
where
    S: get_entry_notebooks_state::State,
    S::Entry: get_entry_notebooks_state::IsUnset,
{
    /// Set the `entry` field (required)
    pub fn entry(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> GetEntryNotebooksBuilder<'a, get_entry_notebooks_state::SetEntry<S>> {
        self._fields.0 = Option::Some(value.into());
        GetEntryNotebooksBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> GetEntryNotebooksBuilder<'a, S>
where
    S: get_entry_notebooks_state::State,
    S::Entry: get_entry_notebooks_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> GetEntryNotebooks<'a> {
        GetEntryNotebooks {
            entry: self._fields.0.unwrap(),
        }
    }
}

pub mod notebook_ref_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 Uri;
        type Cid;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Uri = Unset;
        type Cid = Unset;
    }
    ///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 Uri = Set<members::uri>;
        type Cid = S::Cid;
    }
    ///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 Uri = S::Uri;
        type Cid = Set<members::cid>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `cid` field
        pub struct cid(());
    }
}

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

impl<'a> NotebookRef<'a> {
    /// Create a new builder for this type
    pub fn new() -> NotebookRefBuilder<'a, notebook_ref_state::Empty> {
        NotebookRefBuilder::new()
    }
}

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

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

impl<'a, S: notebook_ref_state::State> NotebookRefBuilder<'a, S> {
    /// Set the `owner` field (optional)
    pub fn owner(mut self, value: impl Into<Option<ProfileViewBasic<'a>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `owner` field to an Option value (optional)
    pub fn maybe_owner(mut self, value: Option<ProfileViewBasic<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: notebook_ref_state::State> NotebookRefBuilder<'a, S> {
    /// Set the `title` field (optional)
    pub fn title(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `title` field to an Option value (optional)
    pub fn maybe_title(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

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

impl<'a, S> NotebookRefBuilder<'a, S>
where
    S: notebook_ref_state::State,
    S::Uri: notebook_ref_state::IsSet,
    S::Cid: notebook_ref_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> NotebookRef<'a> {
        NotebookRef {
            cid: self._fields.0.unwrap(),
            owner: self._fields.1,
            title: self._fields.2,
            uri: self._fields.3.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>,
        >,
    ) -> NotebookRef<'a> {
        NotebookRef {
            cid: self._fields.0.unwrap(),
            owner: self._fields.1,
            title: self._fields.2,
            uri: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_sh_weaver_notebook_getEntryNotebooks() -> 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("sh.weaver.notebook.getEntryNotebooks"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(
                        LexXrpcQueryParameter::Params(LexXrpcParameters {
                            required: Some(vec![SmolStr::new_static("entry")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("entry"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static("AT URI of the entry"),
                                        ),
                                        format: Some(LexStringFormat::AtUri),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("notebookRef"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Reference to a notebook containing this entry.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("uri"), SmolStr::new_static("cid")],
                    ),
                    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("owner"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("title"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}