#[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::Datetime;
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::app_chronosky::plan::get_assignment;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetAssignmentOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub assignment: Option<get_assignment::PlanAssignment<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub message: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct PlanAssignment<'a> {
pub activated_at: Datetime,
pub expires_at: Datetime,
#[serde(borrow)]
pub id: CowStr<'a>,
#[serde(borrow)]
pub plan: get_assignment::PlanInfo<'a>,
#[serde(borrow)]
pub plan_id: CowStr<'a>,
#[serde(borrow)]
pub status: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub ticket: Option<get_assignment::TicketInfo<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct PlanInfo<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
#[serde(borrow)]
pub id: CowStr<'a>,
#[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>,
#[serde(borrow)]
pub name: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct TicketInfo<'a> {
#[serde(borrow)]
pub code: CowStr<'a>,
#[serde(borrow)]
pub id: CowStr<'a>,
}
#[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<'de> = GetAssignmentOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
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<'de> = GetAssignment;
type Response = GetAssignmentResponse;
}
impl<'a> LexiconSchema for PlanAssignment<'a> {
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<'a> LexiconSchema for PlanInfo<'a> {
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<'a> LexiconSchema for TicketInfo<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type ActivatedAt;
type Plan;
type ExpiresAt;
type PlanId;
type Status;
type Id;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ActivatedAt = Unset;
type Plan = Unset;
type ExpiresAt = Unset;
type PlanId = Unset;
type Status = Unset;
type Id = Unset;
}
pub struct SetActivatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetActivatedAt<S> {}
impl<S: State> State for SetActivatedAt<S> {
type ActivatedAt = Set<members::activated_at>;
type Plan = S::Plan;
type ExpiresAt = S::ExpiresAt;
type PlanId = S::PlanId;
type Status = S::Status;
type Id = S::Id;
}
pub struct SetPlan<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPlan<S> {}
impl<S: State> State for SetPlan<S> {
type ActivatedAt = S::ActivatedAt;
type Plan = Set<members::plan>;
type ExpiresAt = S::ExpiresAt;
type PlanId = S::PlanId;
type Status = S::Status;
type Id = S::Id;
}
pub struct SetExpiresAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetExpiresAt<S> {}
impl<S: State> State for SetExpiresAt<S> {
type ActivatedAt = S::ActivatedAt;
type Plan = S::Plan;
type ExpiresAt = Set<members::expires_at>;
type PlanId = S::PlanId;
type Status = S::Status;
type Id = S::Id;
}
pub struct SetPlanId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPlanId<S> {}
impl<S: State> State for SetPlanId<S> {
type ActivatedAt = S::ActivatedAt;
type Plan = S::Plan;
type ExpiresAt = S::ExpiresAt;
type PlanId = Set<members::plan_id>;
type Status = S::Status;
type Id = S::Id;
}
pub struct SetStatus<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStatus<S> {}
impl<S: State> State for SetStatus<S> {
type ActivatedAt = S::ActivatedAt;
type Plan = S::Plan;
type ExpiresAt = S::ExpiresAt;
type PlanId = S::PlanId;
type Status = Set<members::status>;
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 ActivatedAt = S::ActivatedAt;
type Plan = S::Plan;
type ExpiresAt = S::ExpiresAt;
type PlanId = S::PlanId;
type Status = S::Status;
type Id = Set<members::id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct activated_at(());
pub struct plan(());
pub struct expires_at(());
pub struct plan_id(());
pub struct status(());
pub struct id(());
}
}
pub struct PlanAssignmentBuilder<'a, S: plan_assignment_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Datetime>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<get_assignment::PlanInfo<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<get_assignment::TicketInfo<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> PlanAssignment<'a> {
pub fn new() -> PlanAssignmentBuilder<'a, plan_assignment_state::Empty> {
PlanAssignmentBuilder::new()
}
}
impl<'a> PlanAssignmentBuilder<'a, plan_assignment_state::Empty> {
pub fn new() -> Self {
PlanAssignmentBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> PlanAssignmentBuilder<'a, S>
where
S: plan_assignment_state::State,
S::ActivatedAt: plan_assignment_state::IsUnset,
{
pub fn activated_at(
mut self,
value: impl Into<Datetime>,
) -> PlanAssignmentBuilder<'a, plan_assignment_state::SetActivatedAt<S>> {
self._fields.0 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PlanAssignmentBuilder<'a, S>
where
S: plan_assignment_state::State,
S::ExpiresAt: plan_assignment_state::IsUnset,
{
pub fn expires_at(
mut self,
value: impl Into<Datetime>,
) -> PlanAssignmentBuilder<'a, plan_assignment_state::SetExpiresAt<S>> {
self._fields.1 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PlanAssignmentBuilder<'a, S>
where
S: plan_assignment_state::State,
S::Id: plan_assignment_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<CowStr<'a>>,
) -> PlanAssignmentBuilder<'a, plan_assignment_state::SetId<S>> {
self._fields.2 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PlanAssignmentBuilder<'a, S>
where
S: plan_assignment_state::State,
S::Plan: plan_assignment_state::IsUnset,
{
pub fn plan(
mut self,
value: impl Into<get_assignment::PlanInfo<'a>>,
) -> PlanAssignmentBuilder<'a, plan_assignment_state::SetPlan<S>> {
self._fields.3 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PlanAssignmentBuilder<'a, S>
where
S: plan_assignment_state::State,
S::PlanId: plan_assignment_state::IsUnset,
{
pub fn plan_id(
mut self,
value: impl Into<CowStr<'a>>,
) -> PlanAssignmentBuilder<'a, plan_assignment_state::SetPlanId<S>> {
self._fields.4 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PlanAssignmentBuilder<'a, S>
where
S: plan_assignment_state::State,
S::Status: plan_assignment_state::IsUnset,
{
pub fn status(
mut self,
value: impl Into<CowStr<'a>>,
) -> PlanAssignmentBuilder<'a, plan_assignment_state::SetStatus<S>> {
self._fields.5 = Option::Some(value.into());
PlanAssignmentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: plan_assignment_state::State> PlanAssignmentBuilder<'a, S> {
pub fn ticket(
mut self,
value: impl Into<Option<get_assignment::TicketInfo<'a>>>,
) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_ticket(
mut self,
value: Option<get_assignment::TicketInfo<'a>>,
) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S> PlanAssignmentBuilder<'a, S>
where
S: plan_assignment_state::State,
S::ActivatedAt: plan_assignment_state::IsSet,
S::Plan: plan_assignment_state::IsSet,
S::ExpiresAt: plan_assignment_state::IsSet,
S::PlanId: plan_assignment_state::IsSet,
S::Status: plan_assignment_state::IsSet,
S::Id: plan_assignment_state::IsSet,
{
pub fn build(self) -> PlanAssignment<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> PlanAssignment<'a> {
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> {
#[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("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()
}
}