#[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_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::sh_weaver::notebook::EntryView;
use crate::sh_weaver::notebook::NotebookView;
use crate::sh_weaver::notebook::ReadingProgress;
use crate::sh_weaver::notebook::get_reading_history;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetReadingHistory<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cursor: Option<CowStr<'a>>,
#[serde(default = "_default_limit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(default = "_default_status")]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub status: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetReadingHistoryOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cursor: Option<CowStr<'a>>,
#[serde(borrow)]
pub history: Vec<get_reading_history::ReadingHistoryItem<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ReadingHistoryItem<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub current_entry: Option<EntryView<'a>>,
#[serde(borrow)]
pub notebook: NotebookView<'a>,
#[serde(borrow)]
pub progress: ReadingProgress<'a>,
}
pub struct GetReadingHistoryResponse;
impl jacquard_common::xrpc::XrpcResp for GetReadingHistoryResponse {
const NSID: &'static str = "sh.weaver.notebook.getReadingHistory";
const ENCODING: &'static str = "application/json";
type Output<'de> = GetReadingHistoryOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetReadingHistory<'a> {
const NSID: &'static str = "sh.weaver.notebook.getReadingHistory";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetReadingHistoryResponse;
}
pub struct GetReadingHistoryRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetReadingHistoryRequest {
const PATH: &'static str = "/xrpc/sh.weaver.notebook.getReadingHistory";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = GetReadingHistory<'de>;
type Response = GetReadingHistoryResponse;
}
impl<'a> LexiconSchema for ReadingHistoryItem<'a> {
fn nsid() -> &'static str {
"sh.weaver.notebook.getReadingHistory"
}
fn def_name() -> &'static str {
"readingHistoryItem"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_getReadingHistory()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
fn _default_limit() -> Option<i64> {
Some(50i64)
}
fn _default_status() -> Option<CowStr<'static>> {
Some(CowStr::from("all"))
}
pub mod get_reading_history_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 {}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {}
#[allow(non_camel_case_types)]
pub mod members {}
}
pub struct GetReadingHistoryBuilder<'a, S: get_reading_history_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<i64>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GetReadingHistory<'a> {
pub fn new() -> GetReadingHistoryBuilder<'a, get_reading_history_state::Empty> {
GetReadingHistoryBuilder::new()
}
}
impl<'a> GetReadingHistoryBuilder<'a, get_reading_history_state::Empty> {
pub fn new() -> Self {
GetReadingHistoryBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: get_reading_history_state::State> GetReadingHistoryBuilder<'a, S> {
pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: get_reading_history_state::State> GetReadingHistoryBuilder<'a, S> {
pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: get_reading_history_state::State> GetReadingHistoryBuilder<'a, S> {
pub fn status(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_status(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> GetReadingHistoryBuilder<'a, S>
where
S: get_reading_history_state::State,
{
pub fn build(self) -> GetReadingHistory<'a> {
GetReadingHistory {
cursor: self._fields.0,
limit: self._fields.1,
status: self._fields.2,
}
}
}
pub mod reading_history_item_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 Notebook;
type Progress;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Notebook = Unset;
type Progress = Unset;
}
pub struct SetNotebook<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetNotebook<S> {}
impl<S: State> State for SetNotebook<S> {
type Notebook = Set<members::notebook>;
type Progress = S::Progress;
}
pub struct SetProgress<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetProgress<S> {}
impl<S: State> State for SetProgress<S> {
type Notebook = S::Notebook;
type Progress = Set<members::progress>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct notebook(());
pub struct progress(());
}
}
pub struct ReadingHistoryItemBuilder<'a, S: reading_history_item_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<EntryView<'a>>,
Option<NotebookView<'a>>,
Option<ReadingProgress<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ReadingHistoryItem<'a> {
pub fn new() -> ReadingHistoryItemBuilder<'a, reading_history_item_state::Empty> {
ReadingHistoryItemBuilder::new()
}
}
impl<'a> ReadingHistoryItemBuilder<'a, reading_history_item_state::Empty> {
pub fn new() -> Self {
ReadingHistoryItemBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: reading_history_item_state::State> ReadingHistoryItemBuilder<'a, S> {
pub fn current_entry(mut self, value: impl Into<Option<EntryView<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_current_entry(mut self, value: Option<EntryView<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> ReadingHistoryItemBuilder<'a, S>
where
S: reading_history_item_state::State,
S::Notebook: reading_history_item_state::IsUnset,
{
pub fn notebook(
mut self,
value: impl Into<NotebookView<'a>>,
) -> ReadingHistoryItemBuilder<'a, reading_history_item_state::SetNotebook<S>> {
self._fields.1 = Option::Some(value.into());
ReadingHistoryItemBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ReadingHistoryItemBuilder<'a, S>
where
S: reading_history_item_state::State,
S::Progress: reading_history_item_state::IsUnset,
{
pub fn progress(
mut self,
value: impl Into<ReadingProgress<'a>>,
) -> ReadingHistoryItemBuilder<'a, reading_history_item_state::SetProgress<S>> {
self._fields.2 = Option::Some(value.into());
ReadingHistoryItemBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ReadingHistoryItemBuilder<'a, S>
where
S: reading_history_item_state::State,
S::Notebook: reading_history_item_state::IsSet,
S::Progress: reading_history_item_state::IsSet,
{
pub fn build(self) -> ReadingHistoryItem<'a> {
ReadingHistoryItem {
current_entry: self._fields.0,
notebook: self._fields.1.unwrap(),
progress: self._fields.2.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>,
>,
) -> ReadingHistoryItem<'a> {
ReadingHistoryItem {
current_entry: self._fields.0,
notebook: self._fields.1.unwrap(),
progress: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_weaver_notebook_getReadingHistory() -> 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("sh.weaver.notebook.getReadingHistory"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(
LexXrpcQueryParameter::Params(LexXrpcParameters {
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cursor"),
LexXrpcParametersProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("limit"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static("Filter by reading status."),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("readingHistoryItem"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("notebook"),
SmolStr::new_static("progress")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("currentEntry"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"sh.weaver.notebook.defs#entryView",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("notebook"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"sh.weaver.notebook.defs#notebookView",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("progress"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"sh.weaver.notebook.defs#readingProgress",
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}