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;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Did, Datetime, Language};
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 TemplateView<'a> {
#[serde(borrow)]
pub content_markdown: CowStr<'a>,
pub created_at: Datetime,
pub disabled: bool,
#[serde(borrow)]
pub id: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub lang: Option<Language>,
#[serde(borrow)]
pub last_updated_by: Did<'a>,
#[serde(borrow)]
pub name: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub subject: Option<CowStr<'a>>,
pub updated_at: Datetime,
}
impl<'a> LexiconSchema for TemplateView<'a> {
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 ContentMarkdown;
type Name;
type Disabled;
type LastUpdatedBy;
type UpdatedAt;
type CreatedAt;
type Id;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ContentMarkdown = Unset;
type Name = Unset;
type Disabled = Unset;
type LastUpdatedBy = Unset;
type UpdatedAt = Unset;
type CreatedAt = Unset;
type Id = Unset;
}
pub struct SetContentMarkdown<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContentMarkdown<S> {}
impl<S: State> State for SetContentMarkdown<S> {
type ContentMarkdown = Set<members::content_markdown>;
type Name = S::Name;
type Disabled = S::Disabled;
type LastUpdatedBy = S::LastUpdatedBy;
type UpdatedAt = S::UpdatedAt;
type CreatedAt = S::CreatedAt;
type Id = S::Id;
}
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 ContentMarkdown = S::ContentMarkdown;
type Name = Set<members::name>;
type Disabled = S::Disabled;
type LastUpdatedBy = S::LastUpdatedBy;
type UpdatedAt = S::UpdatedAt;
type CreatedAt = S::CreatedAt;
type Id = S::Id;
}
pub struct SetDisabled<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDisabled<S> {}
impl<S: State> State for SetDisabled<S> {
type ContentMarkdown = S::ContentMarkdown;
type Name = S::Name;
type Disabled = Set<members::disabled>;
type LastUpdatedBy = S::LastUpdatedBy;
type UpdatedAt = S::UpdatedAt;
type CreatedAt = S::CreatedAt;
type Id = S::Id;
}
pub struct SetLastUpdatedBy<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLastUpdatedBy<S> {}
impl<S: State> State for SetLastUpdatedBy<S> {
type ContentMarkdown = S::ContentMarkdown;
type Name = S::Name;
type Disabled = S::Disabled;
type LastUpdatedBy = Set<members::last_updated_by>;
type UpdatedAt = S::UpdatedAt;
type CreatedAt = S::CreatedAt;
type Id = S::Id;
}
pub struct SetUpdatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUpdatedAt<S> {}
impl<S: State> State for SetUpdatedAt<S> {
type ContentMarkdown = S::ContentMarkdown;
type Name = S::Name;
type Disabled = S::Disabled;
type LastUpdatedBy = S::LastUpdatedBy;
type UpdatedAt = Set<members::updated_at>;
type CreatedAt = S::CreatedAt;
type Id = S::Id;
}
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 ContentMarkdown = S::ContentMarkdown;
type Name = S::Name;
type Disabled = S::Disabled;
type LastUpdatedBy = S::LastUpdatedBy;
type UpdatedAt = S::UpdatedAt;
type CreatedAt = Set<members::created_at>;
type Id = S::Id;
}
pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetId<S> {}
impl<S: State> State for SetId<S> {
type ContentMarkdown = S::ContentMarkdown;
type Name = S::Name;
type Disabled = S::Disabled;
type LastUpdatedBy = S::LastUpdatedBy;
type UpdatedAt = S::UpdatedAt;
type CreatedAt = S::CreatedAt;
type Id = Set<members::id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct content_markdown(());
pub struct name(());
pub struct disabled(());
pub struct last_updated_by(());
pub struct updated_at(());
pub struct created_at(());
pub struct id(());
}
}
pub struct TemplateViewBuilder<'a, S: template_view_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<Datetime>,
Option<bool>,
Option<CowStr<'a>>,
Option<Language>,
Option<Did<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> TemplateView<'a> {
pub fn new() -> TemplateViewBuilder<'a, template_view_state::Empty> {
TemplateViewBuilder::new()
}
}
impl<'a> TemplateViewBuilder<'a, template_view_state::Empty> {
pub fn new() -> Self {
TemplateViewBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> TemplateViewBuilder<'a, S>
where
S: template_view_state::State,
S::ContentMarkdown: template_view_state::IsUnset,
{
pub fn content_markdown(
mut self,
value: impl Into<CowStr<'a>>,
) -> TemplateViewBuilder<'a, template_view_state::SetContentMarkdown<S>> {
self._fields.0 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TemplateViewBuilder<'a, S>
where
S: template_view_state::State,
S::CreatedAt: template_view_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> TemplateViewBuilder<'a, template_view_state::SetCreatedAt<S>> {
self._fields.1 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TemplateViewBuilder<'a, S>
where
S: template_view_state::State,
S::Disabled: template_view_state::IsUnset,
{
pub fn disabled(
mut self,
value: impl Into<bool>,
) -> TemplateViewBuilder<'a, template_view_state::SetDisabled<S>> {
self._fields.2 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TemplateViewBuilder<'a, S>
where
S: template_view_state::State,
S::Id: template_view_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<CowStr<'a>>,
) -> TemplateViewBuilder<'a, template_view_state::SetId<S>> {
self._fields.3 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: template_view_state::State> TemplateViewBuilder<'a, S> {
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<'a, S> TemplateViewBuilder<'a, S>
where
S: template_view_state::State,
S::LastUpdatedBy: template_view_state::IsUnset,
{
pub fn last_updated_by(
mut self,
value: impl Into<Did<'a>>,
) -> TemplateViewBuilder<'a, template_view_state::SetLastUpdatedBy<S>> {
self._fields.5 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TemplateViewBuilder<'a, S>
where
S: template_view_state::State,
S::Name: template_view_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> TemplateViewBuilder<'a, template_view_state::SetName<S>> {
self._fields.6 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: template_view_state::State> TemplateViewBuilder<'a, S> {
pub fn subject(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_subject(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S> TemplateViewBuilder<'a, S>
where
S: template_view_state::State,
S::UpdatedAt: template_view_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> TemplateViewBuilder<'a, template_view_state::SetUpdatedAt<S>> {
self._fields.8 = Option::Some(value.into());
TemplateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TemplateViewBuilder<'a, S>
where
S: template_view_state::State,
S::ContentMarkdown: template_view_state::IsSet,
S::Name: template_view_state::IsSet,
S::Disabled: template_view_state::IsSet,
S::LastUpdatedBy: template_view_state::IsSet,
S::UpdatedAt: template_view_state::IsSet,
S::CreatedAt: template_view_state::IsSet,
S::Id: template_view_state::IsSet,
{
pub fn build(self) -> TemplateView<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> TemplateView<'a> {
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()
}
}