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

pub mod at_proto_callback;
pub mod authorize;
pub mod github_callback;
pub mod google_callback;
pub mod request_email_update;
pub mod update_email;
pub mod update_handle;
pub mod whoami;


#[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::Did;
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};

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct AuthCallback<'a> {
    #[serde(borrow)]
    pub access_jwt: CowStr<'a>,
    #[serde(borrow)]
    pub did: Did<'a>,
    #[serde(borrow)]
    pub handle: CowStr<'a>,
    #[serde(borrow)]
    pub refresh_jwt: CowStr<'a>,
}

impl<'a> LexiconSchema for AuthCallback<'a> {
    fn nsid() -> &'static str {
        "app.ocho.auth.defs"
    }
    fn def_name() -> &'static str {
        "authCallback"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_ocho_auth_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod auth_callback_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 RefreshJwt;
        type Did;
        type Handle;
        type AccessJwt;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type RefreshJwt = Unset;
        type Did = Unset;
        type Handle = Unset;
        type AccessJwt = Unset;
    }
    ///State transition - sets the `refresh_jwt` field to Set
    pub struct SetRefreshJwt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRefreshJwt<S> {}
    impl<S: State> State for SetRefreshJwt<S> {
        type RefreshJwt = Set<members::refresh_jwt>;
        type Did = S::Did;
        type Handle = S::Handle;
        type AccessJwt = S::AccessJwt;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDid<S> {}
    impl<S: State> State for SetDid<S> {
        type RefreshJwt = S::RefreshJwt;
        type Did = Set<members::did>;
        type Handle = S::Handle;
        type AccessJwt = S::AccessJwt;
    }
    ///State transition - sets the `handle` field to Set
    pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetHandle<S> {}
    impl<S: State> State for SetHandle<S> {
        type RefreshJwt = S::RefreshJwt;
        type Did = S::Did;
        type Handle = Set<members::handle>;
        type AccessJwt = S::AccessJwt;
    }
    ///State transition - sets the `access_jwt` field to Set
    pub struct SetAccessJwt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAccessJwt<S> {}
    impl<S: State> State for SetAccessJwt<S> {
        type RefreshJwt = S::RefreshJwt;
        type Did = S::Did;
        type Handle = S::Handle;
        type AccessJwt = Set<members::access_jwt>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `refresh_jwt` field
        pub struct refresh_jwt(());
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `handle` field
        pub struct handle(());
        ///Marker type for the `access_jwt` field
        pub struct access_jwt(());
    }
}

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

impl<'a> AuthCallback<'a> {
    /// Create a new builder for this type
    pub fn new() -> AuthCallbackBuilder<'a, auth_callback_state::Empty> {
        AuthCallbackBuilder::new()
    }
}

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

impl<'a, S> AuthCallbackBuilder<'a, S>
where
    S: auth_callback_state::State,
    S::AccessJwt: auth_callback_state::IsUnset,
{
    /// Set the `accessJwt` field (required)
    pub fn access_jwt(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> AuthCallbackBuilder<'a, auth_callback_state::SetAccessJwt<S>> {
        self._fields.0 = Option::Some(value.into());
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> AuthCallbackBuilder<'a, S>
where
    S: auth_callback_state::State,
    S::Did: auth_callback_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<Did<'a>>,
    ) -> AuthCallbackBuilder<'a, auth_callback_state::SetDid<S>> {
        self._fields.1 = Option::Some(value.into());
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

impl<'a, S> AuthCallbackBuilder<'a, S>
where
    S: auth_callback_state::State,
    S::RefreshJwt: auth_callback_state::IsUnset,
{
    /// Set the `refreshJwt` field (required)
    pub fn refresh_jwt(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> AuthCallbackBuilder<'a, auth_callback_state::SetRefreshJwt<S>> {
        self._fields.3 = Option::Some(value.into());
        AuthCallbackBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> AuthCallbackBuilder<'a, S>
where
    S: auth_callback_state::State,
    S::RefreshJwt: auth_callback_state::IsSet,
    S::Did: auth_callback_state::IsSet,
    S::Handle: auth_callback_state::IsSet,
    S::AccessJwt: auth_callback_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> AuthCallback<'a> {
        AuthCallback {
            access_jwt: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            handle: self._fields.2.unwrap(),
            refresh_jwt: 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>,
        >,
    ) -> AuthCallback<'a> {
        AuthCallback {
            access_jwt: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            handle: self._fields.2.unwrap(),
            refresh_jwt: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_ocho_auth_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("app.ocho.auth.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("authCallback"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("refreshJwt"),
                            SmolStr::new_static("accessJwt"),
                            SmolStr::new_static("handle"), SmolStr::new_static("did")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("accessJwt"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("handle"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("refreshJwt"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}