pub mod entry;
pub mod get_author_posts;
pub mod get_entry_metadata_by_name;
pub mod get_mentions_by_entry;
pub mod notify_of_new_entry;
#[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::blob::BlobRef;
use jacquard_common::types::string::{AtUri, Datetime, UriValue};
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 BlobMetadata<'a> {
#[serde(borrow)]
pub blobref: BlobRef<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub name: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct BlogEntry<'a> {
#[serde(borrow)]
pub content: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Comment<'a> {
#[serde(borrow)]
pub content: CowStr<'a>,
#[serde(borrow)]
pub entry_uri: AtUri<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Ogp<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub height: Option<i64>,
#[serde(borrow)]
pub url: UriValue<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub width: Option<i64>,
}
impl<'a> LexiconSchema for BlobMetadata<'a> {
fn nsid() -> &'static str {
"com.whtwnd.blog.defs"
}
fn def_name() -> &'static str {
"blobMetadata"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_whtwnd_blog_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.blobref;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["*/*"];
let matched = accepted
.iter()
.any(|pattern| {
if *pattern == "*/*" {
true
} else if pattern.ends_with("/*") {
let prefix = &pattern[..pattern.len() - 2];
mime.starts_with(prefix)
&& mime.as_bytes().get(prefix.len()) == Some(&b'/')
} else {
mime == *pattern
}
});
if !matched {
return Err(ConstraintError::BlobMimeTypeNotAccepted {
path: ValidationPath::from_field("blobref"),
accepted: vec!["*/*".to_string()],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
impl<'a> LexiconSchema for BlogEntry<'a> {
fn nsid() -> &'static str {
"com.whtwnd.blog.defs"
}
fn def_name() -> &'static str {
"blogEntry"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_whtwnd_blog_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.content;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("content"),
max: 100000usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for Comment<'a> {
fn nsid() -> &'static str {
"com.whtwnd.blog.defs"
}
fn def_name() -> &'static str {
"comment"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_whtwnd_blog_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.content;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("content"),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for Ogp<'a> {
fn nsid() -> &'static str {
"com.whtwnd.blog.defs"
}
fn def_name() -> &'static str {
"ogp"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_whtwnd_blog_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod blob_metadata_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 Blobref;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Blobref = Unset;
}
pub struct SetBlobref<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetBlobref<S> {}
impl<S: State> State for SetBlobref<S> {
type Blobref = Set<members::blobref>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct blobref(());
}
}
pub struct BlobMetadataBuilder<'a, S: blob_metadata_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<BlobRef<'a>>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> BlobMetadata<'a> {
pub fn new() -> BlobMetadataBuilder<'a, blob_metadata_state::Empty> {
BlobMetadataBuilder::new()
}
}
impl<'a> BlobMetadataBuilder<'a, blob_metadata_state::Empty> {
pub fn new() -> Self {
BlobMetadataBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> BlobMetadataBuilder<'a, S>
where
S: blob_metadata_state::State,
S::Blobref: blob_metadata_state::IsUnset,
{
pub fn blobref(
mut self,
value: impl Into<BlobRef<'a>>,
) -> BlobMetadataBuilder<'a, blob_metadata_state::SetBlobref<S>> {
self._fields.0 = Option::Some(value.into());
BlobMetadataBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: blob_metadata_state::State> BlobMetadataBuilder<'a, S> {
pub fn name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_name(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> BlobMetadataBuilder<'a, S>
where
S: blob_metadata_state::State,
S::Blobref: blob_metadata_state::IsSet,
{
pub fn build(self) -> BlobMetadata<'a> {
BlobMetadata {
blobref: self._fields.0.unwrap(),
name: self._fields.1,
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>,
>,
) -> BlobMetadata<'a> {
BlobMetadata {
blobref: self._fields.0.unwrap(),
name: self._fields.1,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_com_whtwnd_blog_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("com.whtwnd.blog.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blobMetadata"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("blobref")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blobref"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("blogEntry"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("content")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("content"),
LexObjectProperty::String(LexString {
max_length: Some(100000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("comment"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("content"),
SmolStr::new_static("entryUri")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("content"),
LexObjectProperty::String(LexString {
max_length: Some(1000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("entryUri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("ogp"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("url")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("height"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("url"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("width"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod comment_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 EntryUri;
type Content;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type EntryUri = Unset;
type Content = Unset;
}
pub struct SetEntryUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetEntryUri<S> {}
impl<S: State> State for SetEntryUri<S> {
type EntryUri = Set<members::entry_uri>;
type Content = S::Content;
}
pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContent<S> {}
impl<S: State> State for SetContent<S> {
type EntryUri = S::EntryUri;
type Content = Set<members::content>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct entry_uri(());
pub struct content(());
}
}
pub struct CommentBuilder<'a, S: comment_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<AtUri<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Comment<'a> {
pub fn new() -> CommentBuilder<'a, comment_state::Empty> {
CommentBuilder::new()
}
}
impl<'a> CommentBuilder<'a, comment_state::Empty> {
pub fn new() -> Self {
CommentBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommentBuilder<'a, S>
where
S: comment_state::State,
S::Content: comment_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<CowStr<'a>>,
) -> CommentBuilder<'a, comment_state::SetContent<S>> {
self._fields.0 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommentBuilder<'a, S>
where
S: comment_state::State,
S::EntryUri: comment_state::IsUnset,
{
pub fn entry_uri(
mut self,
value: impl Into<AtUri<'a>>,
) -> CommentBuilder<'a, comment_state::SetEntryUri<S>> {
self._fields.1 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommentBuilder<'a, S>
where
S: comment_state::State,
S::EntryUri: comment_state::IsSet,
S::Content: comment_state::IsSet,
{
pub fn build(self) -> Comment<'a> {
Comment {
content: self._fields.0.unwrap(),
entry_uri: self._fields.1.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>,
>,
) -> Comment<'a> {
Comment {
content: self._fields.0.unwrap(),
entry_uri: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod ogp_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 Url;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Url = Unset;
}
pub struct SetUrl<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUrl<S> {}
impl<S: State> State for SetUrl<S> {
type Url = Set<members::url>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct url(());
}
}
pub struct OgpBuilder<'a, S: ogp_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<UriValue<'a>>, Option<i64>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Ogp<'a> {
pub fn new() -> OgpBuilder<'a, ogp_state::Empty> {
OgpBuilder::new()
}
}
impl<'a> OgpBuilder<'a, ogp_state::Empty> {
pub fn new() -> Self {
OgpBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: ogp_state::State> OgpBuilder<'a, S> {
pub fn height(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_height(mut self, value: Option<i64>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> OgpBuilder<'a, S>
where
S: ogp_state::State,
S::Url: ogp_state::IsUnset,
{
pub fn url(
mut self,
value: impl Into<UriValue<'a>>,
) -> OgpBuilder<'a, ogp_state::SetUrl<S>> {
self._fields.1 = Option::Some(value.into());
OgpBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: ogp_state::State> OgpBuilder<'a, S> {
pub fn width(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_width(mut self, value: Option<i64>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> OgpBuilder<'a, S>
where
S: ogp_state::State,
S::Url: ogp_state::IsSet,
{
pub fn build(self) -> Ogp<'a> {
Ogp {
height: self._fields.0,
url: self._fields.1.unwrap(),
width: self._fields.2,
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>,
>,
) -> Ogp<'a> {
Ogp {
height: self._fields.0,
url: self._fields.1.unwrap(),
width: self._fields.2,
extra_data: Some(extra_data),
}
}
}