#[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::Datetime;
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::st_lifepo::profile;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LifeEvent<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub end_date: Option<Datetime>,
pub start_date: Datetime,
#[serde(borrow)]
pub title: CowStr<'a>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Profile<'a> {
#[serde(borrow)]
pub actor: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ProfileOutput<'a> {
#[serde(borrow)]
pub bio: CowStr<'a>,
#[serde(borrow)]
pub handle: CowStr<'a>,
#[serde(borrow)]
pub life_events: Vec<profile::LifeEvent<'a>>,
}
impl<'a> LexiconSchema for LifeEvent<'a> {
fn nsid() -> &'static str {
"st.lifepo.profile"
}
fn def_name() -> &'static str {
"lifeEvent"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_st_lifepo_profile()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct ProfileResponse;
impl jacquard_common::xrpc::XrpcResp for ProfileResponse {
const NSID: &'static str = "st.lifepo.profile";
const ENCODING: &'static str = "application/json";
type Output<'de> = ProfileOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for Profile<'a> {
const NSID: &'static str = "st.lifepo.profile";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = ProfileResponse;
}
pub struct ProfileRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ProfileRequest {
const PATH: &'static str = "/xrpc/st.lifepo.profile";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = Profile<'de>;
type Response = ProfileResponse;
}
pub mod life_event_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type StartDate;
type Title;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type StartDate = Unset;
type Title = Unset;
}
pub struct SetStartDate<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStartDate<S> {}
impl<S: State> State for SetStartDate<S> {
type StartDate = Set<members::start_date>;
type Title = S::Title;
}
pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTitle<S> {}
impl<S: State> State for SetTitle<S> {
type StartDate = S::StartDate;
type Title = Set<members::title>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct start_date(());
pub struct title(());
}
}
pub struct LifeEventBuilder<'a, S: life_event_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<Datetime>,
Option<Datetime>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> LifeEvent<'a> {
pub fn new() -> LifeEventBuilder<'a, life_event_state::Empty> {
LifeEventBuilder::new()
}
}
impl<'a> LifeEventBuilder<'a, life_event_state::Empty> {
pub fn new() -> Self {
LifeEventBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: life_event_state::State> LifeEventBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: life_event_state::State> LifeEventBuilder<'a, S> {
pub fn end_date(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_end_date(mut self, value: Option<Datetime>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> LifeEventBuilder<'a, S>
where
S: life_event_state::State,
S::StartDate: life_event_state::IsUnset,
{
pub fn start_date(
mut self,
value: impl Into<Datetime>,
) -> LifeEventBuilder<'a, life_event_state::SetStartDate<S>> {
self._fields.2 = Option::Some(value.into());
LifeEventBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LifeEventBuilder<'a, S>
where
S: life_event_state::State,
S::Title: life_event_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<CowStr<'a>>,
) -> LifeEventBuilder<'a, life_event_state::SetTitle<S>> {
self._fields.3 = Option::Some(value.into());
LifeEventBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LifeEventBuilder<'a, S>
where
S: life_event_state::State,
S::StartDate: life_event_state::IsSet,
S::Title: life_event_state::IsSet,
{
pub fn build(self) -> LifeEvent<'a> {
LifeEvent {
description: self._fields.0,
end_date: self._fields.1,
start_date: self._fields.2.unwrap(),
title: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> LifeEvent<'a> {
LifeEvent {
description: self._fields.0,
end_date: self._fields.1,
start_date: self._fields.2.unwrap(),
title: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_st_lifepo_profile() -> 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("st.lifepo.profile"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("lifeEvent"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("A single life event entry.")),
required: Some(
vec![
SmolStr::new_static("title"),
SmolStr::new_static("startDate")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("endDate"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("startDate"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(
LexXrpcQueryParameter::Params(LexXrpcParameters {
required: Some(vec![SmolStr::new_static("actor")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("actor"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static("The DID or handle of the user."),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod profile_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Actor;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Actor = Unset;
}
pub struct SetActor<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetActor<S> {}
impl<S: State> State for SetActor<S> {
type Actor = Set<members::actor>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct actor(());
}
}
pub struct ProfileBuilder<'a, S: profile_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Profile<'a> {
pub fn new() -> ProfileBuilder<'a, profile_state::Empty> {
ProfileBuilder::new()
}
}
impl<'a> ProfileBuilder<'a, profile_state::Empty> {
pub fn new() -> Self {
ProfileBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ProfileBuilder<'a, S>
where
S: profile_state::State,
S::Actor: profile_state::IsUnset,
{
pub fn actor(
mut self,
value: impl Into<CowStr<'a>>,
) -> ProfileBuilder<'a, profile_state::SetActor<S>> {
self._fields.0 = Option::Some(value.into());
ProfileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ProfileBuilder<'a, S>
where
S: profile_state::State,
S::Actor: profile_state::IsSet,
{
pub fn build(self) -> Profile<'a> {
Profile {
actor: self._fields.0.unwrap(),
}
}
}