#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
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;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct GetReadingHistory<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<S>,
#[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")]
pub status: Option<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct GetReadingHistoryOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<S>,
pub history: Vec<get_reading_history::ReadingHistoryItem<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ReadingHistoryItem<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub current_entry: Option<EntryView<S>>,
pub notebook: NotebookView<S>,
pub progress: ReadingProgress<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
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<S: BosStr> = GetReadingHistoryOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetReadingHistory<S> {
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<S: BosStr> = GetReadingHistory<S>;
type Response = GetReadingHistoryResponse;
}
impl<S: BosStr> LexiconSchema for ReadingHistoryItem<S> {
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<S: jacquard_common::FromStaticStr>() -> Option<S> {
Some(S::from_static("all"))
}
pub mod get_reading_history_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[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<S: BosStr, St: get_reading_history_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<i64>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> GetReadingHistory<S> {
pub fn new() -> GetReadingHistoryBuilder<S, get_reading_history_state::Empty> {
GetReadingHistoryBuilder::new()
}
}
impl<S: BosStr> GetReadingHistoryBuilder<S, get_reading_history_state::Empty> {
pub fn new() -> Self {
GetReadingHistoryBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: get_reading_history_state::State> GetReadingHistoryBuilder<S, St> {
pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_cursor(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: get_reading_history_state::State> GetReadingHistoryBuilder<S, St> {
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<S: BosStr, St: get_reading_history_state::State> GetReadingHistoryBuilder<S, St> {
pub fn status(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_status(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> GetReadingHistoryBuilder<S, St>
where
St: get_reading_history_state::State,
{
pub fn build(self) -> GetReadingHistory<S> {
GetReadingHistory {
cursor: self._fields.0,
limit: self._fields.1,
status: self._fields.2,
}
}
}
pub mod reading_history_item_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetNotebook<St> {}
impl<St: State> State for SetNotebook<St> {
type Notebook = Set<members::notebook>;
type Progress = St::Progress;
}
pub struct SetProgress<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetProgress<St> {}
impl<St: State> State for SetProgress<St> {
type Notebook = St::Notebook;
type Progress = Set<members::progress>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct notebook(());
pub struct progress(());
}
}
pub struct ReadingHistoryItemBuilder<S: BosStr, St: reading_history_item_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<EntryView<S>>,
Option<NotebookView<S>>,
Option<ReadingProgress<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ReadingHistoryItem<S> {
pub fn new() -> ReadingHistoryItemBuilder<S, reading_history_item_state::Empty> {
ReadingHistoryItemBuilder::new()
}
}
impl<S: BosStr> ReadingHistoryItemBuilder<S, reading_history_item_state::Empty> {
pub fn new() -> Self {
ReadingHistoryItemBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: reading_history_item_state::State> ReadingHistoryItemBuilder<S, St> {
pub fn current_entry(mut self, value: impl Into<Option<EntryView<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_current_entry(mut self, value: Option<EntryView<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> ReadingHistoryItemBuilder<S, St>
where
St: reading_history_item_state::State,
St::Notebook: reading_history_item_state::IsUnset,
{
pub fn notebook(
mut self,
value: impl Into<NotebookView<S>>,
) -> ReadingHistoryItemBuilder<S, reading_history_item_state::SetNotebook<St>> {
self._fields.1 = Option::Some(value.into());
ReadingHistoryItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ReadingHistoryItemBuilder<S, St>
where
St: reading_history_item_state::State,
St::Progress: reading_history_item_state::IsUnset,
{
pub fn progress(
mut self,
value: impl Into<ReadingProgress<S>>,
) -> ReadingHistoryItemBuilder<S, reading_history_item_state::SetProgress<St>> {
self._fields.2 = Option::Some(value.into());
ReadingHistoryItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ReadingHistoryItemBuilder<S, St>
where
St: reading_history_item_state::State,
St::Notebook: reading_history_item_state::IsSet,
St::Progress: reading_history_item_state::IsSet,
{
pub fn build(self) -> ReadingHistoryItem<S> {
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<SmolStr, Data<S>>) -> ReadingHistoryItem<S> {
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> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
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()
}
}