#[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::string::Datetime;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::app_chronosky::plan::get_assignment;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct GetAssignmentOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub assignment: Option<get_assignment::PlanAssignment<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<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 PlanAssignment<S: BosStr = DefaultStr> {
pub activated_at: Datetime,
pub expires_at: Datetime,
pub id: S,
pub plan: get_assignment::PlanInfo<S>,
pub plan_id: S,
pub status: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub ticket: Option<get_assignment::TicketInfo<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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct PlanInfo<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
pub id: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_concurrent_posts: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_images_per_post: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_posts_per_day: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_schedule_days: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_thread_posts: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_schedule_interval: Option<i64>,
pub name: 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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct TicketInfo<S: BosStr = DefaultStr> {
pub code: S,
pub id: 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, Copy)]
pub struct GetAssignment;
pub struct GetAssignmentResponse;
impl jacquard_common::xrpc::XrpcResp for GetAssignmentResponse {
const NSID: &'static str = "app.chronosky.plan.getAssignment";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = GetAssignmentOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl jacquard_common::xrpc::XrpcRequest for GetAssignment {
const NSID: &'static str = "app.chronosky.plan.getAssignment";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetAssignmentResponse;
}
pub struct GetAssignmentRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetAssignmentRequest {
const PATH: &'static str = "/xrpc/app.chronosky.plan.getAssignment";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = GetAssignment;
type Response = GetAssignmentResponse;
}
impl<S: BosStr> LexiconSchema for PlanAssignment<S> {
fn nsid() -> &'static str {
"app.chronosky.plan.getAssignment"
}
fn def_name() -> &'static str {
"planAssignment"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_chronosky_plan_getAssignment()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("id"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.plan_id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("plan_id"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.status;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 20usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("status"),
max: 20usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for PlanInfo<S> {
fn nsid() -> &'static str {
"app.chronosky.plan.getAssignment"
}
fn def_name() -> &'static str {
"planInfo"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_chronosky_plan_getAssignment()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("id"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 200usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 200usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for TicketInfo<S> {
fn nsid() -> &'static str {
"app.chronosky.plan.getAssignment"
}
fn def_name() -> &'static str {
"ticketInfo"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_chronosky_plan_getAssignment()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.code;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("code"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("id"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod plan_assignment_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 ActivatedAt;
type Id;
type Status;
type Plan;
type ExpiresAt;
type PlanId;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ActivatedAt = Unset;
type Id = Unset;
type Status = Unset;
type Plan = Unset;
type ExpiresAt = Unset;
type PlanId = Unset;
}
pub struct SetActivatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetActivatedAt<St> {}
impl<St: State> State for SetActivatedAt<St> {
type ActivatedAt = Set<members::activated_at>;
type Id = St::Id;
type Status = St::Status;
type Plan = St::Plan;
type ExpiresAt = St::ExpiresAt;
type PlanId = St::PlanId;
}
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 ActivatedAt = St::ActivatedAt;
type Id = Set<members::id>;
type Status = St::Status;
type Plan = St::Plan;
type ExpiresAt = St::ExpiresAt;
type PlanId = St::PlanId;
}
pub struct SetStatus<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStatus<St> {}
impl<St: State> State for SetStatus<St> {
type ActivatedAt = St::ActivatedAt;
type Id = St::Id;
type Status = Set<members::status>;
type Plan = St::Plan;
type ExpiresAt = St::ExpiresAt;
type PlanId = St::PlanId;
}
pub struct SetPlan<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPlan<St> {}
impl<St: State> State for SetPlan<St> {
type ActivatedAt = St::ActivatedAt;
type Id = St::Id;
type Status = St::Status;
type Plan = Set<members::plan>;
type ExpiresAt = St::ExpiresAt;
type PlanId = St::PlanId;
}
pub struct SetExpiresAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetExpiresAt<St> {}
impl<St: State> State for SetExpiresAt<St> {
type ActivatedAt = St::ActivatedAt;
type Id = St::Id;
type Status = St::Status;
type Plan = St::Plan;
type ExpiresAt = Set<members::expires_at>;
type PlanId = St::PlanId;
}
pub struct SetPlanId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPlanId<St> {}
impl<St: State> State for SetPlanId<St> {
type ActivatedAt = St::ActivatedAt;
type Id = St::Id;
type Status = St::Status;
type Plan = St::Plan;
type ExpiresAt = St::ExpiresAt;
type PlanId = Set<members::plan_id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct activated_at(());
pub struct id(());
pub struct status(());
pub struct plan(());
pub struct expires_at(());
pub struct plan_id(());
}
}
pub struct PlanAssignmentBuilder<S: BosStr, St: plan_assignment_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Datetime>,
Option<Datetime>,
Option<S>,
Option<get_assignment::PlanInfo<S>>,
Option<S>,
Option<S>,
Option<get_assignment::TicketInfo<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> PlanAssignment<S> {
pub fn new() -> PlanAssignmentBuilder<S, plan_assignment_state::Empty> {
PlanAssignmentBuilder::new()
}
}
impl<S: BosStr> PlanAssignmentBuilder<S, plan_assignment_state::Empty> {
pub fn new() -> Self {
PlanAssignmentBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PlanAssignmentBuilder<S, St>
where
St: plan_assignment_state::State,
St::ActivatedAt: plan_assignment_state::IsUnset,
{
pub fn activated_at(
mut self,
value: impl Into<Datetime>,
) -> PlanAssignmentBuilder<S, plan_assignment_state::SetActivatedAt<St>> {
self._fields.0 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PlanAssignmentBuilder<S, St>
where
St: plan_assignment_state::State,
St::ExpiresAt: plan_assignment_state::IsUnset,
{
pub fn expires_at(
mut self,
value: impl Into<Datetime>,
) -> PlanAssignmentBuilder<S, plan_assignment_state::SetExpiresAt<St>> {
self._fields.1 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PlanAssignmentBuilder<S, St>
where
St: plan_assignment_state::State,
St::Id: plan_assignment_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<S>,
) -> PlanAssignmentBuilder<S, plan_assignment_state::SetId<St>> {
self._fields.2 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PlanAssignmentBuilder<S, St>
where
St: plan_assignment_state::State,
St::Plan: plan_assignment_state::IsUnset,
{
pub fn plan(
mut self,
value: impl Into<get_assignment::PlanInfo<S>>,
) -> PlanAssignmentBuilder<S, plan_assignment_state::SetPlan<St>> {
self._fields.3 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PlanAssignmentBuilder<S, St>
where
St: plan_assignment_state::State,
St::PlanId: plan_assignment_state::IsUnset,
{
pub fn plan_id(
mut self,
value: impl Into<S>,
) -> PlanAssignmentBuilder<S, plan_assignment_state::SetPlanId<St>> {
self._fields.4 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PlanAssignmentBuilder<S, St>
where
St: plan_assignment_state::State,
St::Status: plan_assignment_state::IsUnset,
{
pub fn status(
mut self,
value: impl Into<S>,
) -> PlanAssignmentBuilder<S, plan_assignment_state::SetStatus<St>> {
self._fields.5 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: plan_assignment_state::State> PlanAssignmentBuilder<S, St> {
pub fn ticket(mut self, value: impl Into<Option<get_assignment::TicketInfo<S>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_ticket(mut self, value: Option<get_assignment::TicketInfo<S>>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St> PlanAssignmentBuilder<S, St>
where
St: plan_assignment_state::State,
St::ActivatedAt: plan_assignment_state::IsSet,
St::Id: plan_assignment_state::IsSet,
St::Status: plan_assignment_state::IsSet,
St::Plan: plan_assignment_state::IsSet,
St::ExpiresAt: plan_assignment_state::IsSet,
St::PlanId: plan_assignment_state::IsSet,
{
pub fn build(self) -> PlanAssignment<S> {
PlanAssignment {
activated_at: self._fields.0.unwrap(),
expires_at: self._fields.1.unwrap(),
id: self._fields.2.unwrap(),
plan: self._fields.3.unwrap(),
plan_id: self._fields.4.unwrap(),
status: self._fields.5.unwrap(),
ticket: self._fields.6,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> PlanAssignment<S> {
PlanAssignment {
activated_at: self._fields.0.unwrap(),
expires_at: self._fields.1.unwrap(),
id: self._fields.2.unwrap(),
plan: self._fields.3.unwrap(),
plan_id: self._fields.4.unwrap(),
status: self._fields.5.unwrap(),
ticket: self._fields.6,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_chronosky_plan_getAssignment() -> 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("app.chronosky.plan.getAssignment"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: None,
..Default::default()
}),
);
map.insert(
SmolStr::new_static("planAssignment"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Plan assignment details.")),
required: Some(vec![
SmolStr::new_static("id"),
SmolStr::new_static("planId"),
SmolStr::new_static("plan"),
SmolStr::new_static("activatedAt"),
SmolStr::new_static("expiresAt"),
SmolStr::new_static("status"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("activatedAt"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Plan activation timestamp")),
format: Some(LexStringFormat::Datetime),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("expiresAt"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Plan expiration timestamp")),
format: Some(LexStringFormat::Datetime),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Plan assignment ID")),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("plan"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#planInfo"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("planId"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Plan ID")),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Plan assignment status")),
max_length: Some(20usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("ticket"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#ticketInfo"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("planInfo"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Plan information.")),
required: Some(vec![SmolStr::new_static("id"), SmolStr::new_static("name")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Plan description")),
max_length: Some(1000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Plan ID")),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("maxConcurrentPosts"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("maxImagesPerPost"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("maxPostsPerDay"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("maxScheduleDays"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("maxThreadPosts"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("minScheduleInterval"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Plan name")),
max_length: Some(200usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("ticketInfo"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Ticket information.")),
required: Some(vec![SmolStr::new_static("id"), SmolStr::new_static("code")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("code"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Ticket code")),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Ticket ID")),
max_length: Some(100usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}