pub mod create_template;
pub mod delete_template;
pub mod list_templates;
pub mod update_template;
#[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::string::{Did, Datetime, Language};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct TemplateView<S: BosStr = DefaultStr> {
pub content_markdown: S,
pub created_at: Datetime,
pub disabled: bool,
pub id: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub lang: Option<Language>,
pub last_updated_by: Did<S>,
pub name: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub subject: Option<S>,
pub updated_at: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for TemplateView<S> {
fn nsid() -> &'static str {
"tools.ozone.communication.defs"
}
fn def_name() -> &'static str {
"templateView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_tools_ozone_communication_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod template_view_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 LastUpdatedBy;
type CreatedAt;
type Disabled;
type Id;
type UpdatedAt;
type ContentMarkdown;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type LastUpdatedBy = Unset;
type CreatedAt = Unset;
type Disabled = Unset;
type Id = Unset;
type UpdatedAt = Unset;
type ContentMarkdown = Unset;
type Name = Unset;
}
pub struct SetLastUpdatedBy<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLastUpdatedBy<St> {}
impl<St: State> State for SetLastUpdatedBy<St> {
type LastUpdatedBy = Set<members::last_updated_by>;
type CreatedAt = St::CreatedAt;
type Disabled = St::Disabled;
type Id = St::Id;
type UpdatedAt = St::UpdatedAt;
type ContentMarkdown = St::ContentMarkdown;
type Name = St::Name;
}
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 LastUpdatedBy = St::LastUpdatedBy;
type CreatedAt = Set<members::created_at>;
type Disabled = St::Disabled;
type Id = St::Id;
type UpdatedAt = St::UpdatedAt;
type ContentMarkdown = St::ContentMarkdown;
type Name = St::Name;
}
pub struct SetDisabled<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDisabled<St> {}
impl<St: State> State for SetDisabled<St> {
type LastUpdatedBy = St::LastUpdatedBy;
type CreatedAt = St::CreatedAt;
type Disabled = Set<members::disabled>;
type Id = St::Id;
type UpdatedAt = St::UpdatedAt;
type ContentMarkdown = St::ContentMarkdown;
type Name = St::Name;
}
pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetId<St> {}
impl<St: State> State for SetId<St> {
type LastUpdatedBy = St::LastUpdatedBy;
type CreatedAt = St::CreatedAt;
type Disabled = St::Disabled;
type Id = Set<members::id>;
type UpdatedAt = St::UpdatedAt;
type ContentMarkdown = St::ContentMarkdown;
type Name = St::Name;
}
pub struct SetUpdatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUpdatedAt<St> {}
impl<St: State> State for SetUpdatedAt<St> {
type LastUpdatedBy = St::LastUpdatedBy;
type CreatedAt = St::CreatedAt;
type Disabled = St::Disabled;
type Id = St::Id;
type UpdatedAt = Set<members::updated_at>;
type ContentMarkdown = St::ContentMarkdown;
type Name = St::Name;
}
pub struct SetContentMarkdown<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContentMarkdown<St> {}
impl<St: State> State for SetContentMarkdown<St> {
type LastUpdatedBy = St::LastUpdatedBy;
type CreatedAt = St::CreatedAt;
type Disabled = St::Disabled;
type Id = St::Id;
type UpdatedAt = St::UpdatedAt;
type ContentMarkdown = Set<members::content_markdown>;
type Name = St::Name;
}
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 LastUpdatedBy = St::LastUpdatedBy;
type CreatedAt = St::CreatedAt;
type Disabled = St::Disabled;
type Id = St::Id;
type UpdatedAt = St::UpdatedAt;
type ContentMarkdown = St::ContentMarkdown;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct last_updated_by(());
pub struct created_at(());
pub struct disabled(());
pub struct id(());
pub struct updated_at(());
pub struct content_markdown(());
pub struct name(());
}
}
pub struct TemplateViewBuilder<S: BosStr, St: template_view_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<Datetime>,
Option<bool>,
Option<S>,
Option<Language>,
Option<Did<S>>,
Option<S>,
Option<S>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> TemplateView<S> {
pub fn new() -> TemplateViewBuilder<S, template_view_state::Empty> {
TemplateViewBuilder::new()
}
}
impl<S: BosStr> TemplateViewBuilder<S, template_view_state::Empty> {
pub fn new() -> Self {
TemplateViewBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TemplateViewBuilder<S, St>
where
St: template_view_state::State,
St::ContentMarkdown: template_view_state::IsUnset,
{
pub fn content_markdown(
mut self,
value: impl Into<S>,
) -> TemplateViewBuilder<S, template_view_state::SetContentMarkdown<St>> {
self._fields.0 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TemplateViewBuilder<S, St>
where
St: template_view_state::State,
St::CreatedAt: template_view_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> TemplateViewBuilder<S, template_view_state::SetCreatedAt<St>> {
self._fields.1 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TemplateViewBuilder<S, St>
where
St: template_view_state::State,
St::Disabled: template_view_state::IsUnset,
{
pub fn disabled(
mut self,
value: impl Into<bool>,
) -> TemplateViewBuilder<S, template_view_state::SetDisabled<St>> {
self._fields.2 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TemplateViewBuilder<S, St>
where
St: template_view_state::State,
St::Id: template_view_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<S>,
) -> TemplateViewBuilder<S, template_view_state::SetId<St>> {
self._fields.3 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: template_view_state::State> TemplateViewBuilder<S, St> {
pub fn lang(mut self, value: impl Into<Option<Language>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_lang(mut self, value: Option<Language>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> TemplateViewBuilder<S, St>
where
St: template_view_state::State,
St::LastUpdatedBy: template_view_state::IsUnset,
{
pub fn last_updated_by(
mut self,
value: impl Into<Did<S>>,
) -> TemplateViewBuilder<S, template_view_state::SetLastUpdatedBy<St>> {
self._fields.5 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TemplateViewBuilder<S, St>
where
St: template_view_state::State,
St::Name: template_view_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> TemplateViewBuilder<S, template_view_state::SetName<St>> {
self._fields.6 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: template_view_state::State> TemplateViewBuilder<S, St> {
pub fn subject(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_subject(mut self, value: Option<S>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St> TemplateViewBuilder<S, St>
where
St: template_view_state::State,
St::UpdatedAt: template_view_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> TemplateViewBuilder<S, template_view_state::SetUpdatedAt<St>> {
self._fields.8 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TemplateViewBuilder<S, St>
where
St: template_view_state::State,
St::LastUpdatedBy: template_view_state::IsSet,
St::CreatedAt: template_view_state::IsSet,
St::Disabled: template_view_state::IsSet,
St::Id: template_view_state::IsSet,
St::UpdatedAt: template_view_state::IsSet,
St::ContentMarkdown: template_view_state::IsSet,
St::Name: template_view_state::IsSet,
{
pub fn build(self) -> TemplateView<S> {
TemplateView {
content_markdown: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
disabled: self._fields.2.unwrap(),
id: self._fields.3.unwrap(),
lang: self._fields.4,
last_updated_by: self._fields.5.unwrap(),
name: self._fields.6.unwrap(),
subject: self._fields.7,
updated_at: self._fields.8.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> TemplateView<S> {
TemplateView {
content_markdown: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
disabled: self._fields.2.unwrap(),
id: self._fields.3.unwrap(),
lang: self._fields.4,
last_updated_by: self._fields.5.unwrap(),
name: self._fields.6.unwrap(),
subject: self._fields.7,
updated_at: self._fields.8.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_tools_ozone_communication_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("tools.ozone.communication.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("templateView"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("id"), SmolStr::new_static("name"),
SmolStr::new_static("contentMarkdown"),
SmolStr::new_static("disabled"),
SmolStr::new_static("lastUpdatedBy"),
SmolStr::new_static("createdAt"),
SmolStr::new_static("updatedAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("contentMarkdown"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Subject of the message, used in emails.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("disabled"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("lang"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Message language.")),
format: Some(LexStringFormat::Language),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lastUpdatedBy"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"DID of the user who last updated the template.",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Name of the template."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Content of the template, can contain markdown and variable placeholders.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}