#[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, Language};
use jacquard_derive::{IntoStatic, lexicon, open_union};
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_bsky::embed::external::ExternalRecord;
use crate::app_bsky::embed::images::Images;
use crate::app_bsky::embed::record::Record;
use crate::app_bsky::embed::record_with_media::RecordWithMedia;
use crate::app_bsky::embed::video::Video;
use crate::app_bsky::feed::threadgate::FollowerRule;
use crate::app_bsky::feed::threadgate::FollowingRule;
use crate::app_bsky::feed::threadgate::ListRule;
use crate::app_bsky::feed::threadgate::MentionRule;
use crate::app_bsky::richtext::facet::Facet;
use crate::com_atproto::label::SelfLabels;
use crate::app_chronosky::schedule::create_post;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CreatePost<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_quote_posts: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub parent_post_id: Option<CowStr<'a>>,
#[serde(borrow)]
pub posts: Vec<create_post::ThreadPostInput<'a>>,
pub scheduled_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub threadgate_rules: Option<Vec<CreatePostThreadgateRulesItem<'a>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum CreatePostThreadgateRulesItem<'a> {
#[serde(rename = "app.bsky.feed.threadgate#mentionRule")]
ThreadgateMentionRule(Box<MentionRule<'a>>),
#[serde(rename = "app.bsky.feed.threadgate#followerRule")]
ThreadgateFollowerRule(Box<FollowerRule<'a>>),
#[serde(rename = "app.bsky.feed.threadgate#followingRule")]
ThreadgateFollowingRule(Box<FollowingRule<'a>>),
#[serde(rename = "app.bsky.feed.threadgate#listRule")]
ThreadgateListRule(Box<ListRule<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CreatePostOutput<'a> {
#[serde(borrow)]
pub id: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub post_count: Option<i64>,
pub scheduled_at: Datetime,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ThreadPostInput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub embed: Option<ThreadPostInputEmbed<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub facets: Option<Vec<Facet<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub labels: Option<SelfLabels<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub langs: Option<Vec<Language>>,
#[serde(borrow)]
pub text: CowStr<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum ThreadPostInputEmbed<'a> {
#[serde(rename = "app.bsky.embed.images")]
Images(Box<Images<'a>>),
#[serde(rename = "app.bsky.embed.external")]
External(Box<ExternalRecord<'a>>),
#[serde(rename = "app.bsky.embed.record")]
Record(Box<Record<'a>>),
#[serde(rename = "app.bsky.embed.video")]
Video(Box<Video<'a>>),
#[serde(rename = "app.bsky.embed.recordWithMedia")]
RecordWithMedia(Box<RecordWithMedia<'a>>),
}
pub struct CreatePostResponse;
impl jacquard_common::xrpc::XrpcResp for CreatePostResponse {
const NSID: &'static str = "app.chronosky.schedule.createPost";
const ENCODING: &'static str = "application/json";
type Output<'de> = CreatePostOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for CreatePost<'a> {
const NSID: &'static str = "app.chronosky.schedule.createPost";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = CreatePostResponse;
}
pub struct CreatePostRequest;
impl jacquard_common::xrpc::XrpcEndpoint for CreatePostRequest {
const PATH: &'static str = "/xrpc/app.chronosky.schedule.createPost";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<'de> = CreatePost<'de>;
type Response = CreatePostResponse;
}
impl<'a> LexiconSchema for ThreadPostInput<'a> {
fn nsid() -> &'static str {
"app.chronosky.schedule.createPost"
}
fn def_name() -> &'static str {
"threadPostInput"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_chronosky_schedule_createPost()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.facets {
#[allow(unused_comparisons)]
if value.len() > 50usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("facets"),
max: 50usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.langs {
#[allow(unused_comparisons)]
if value.len() > 3usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("langs"),
max: 3usize,
actual: value.len(),
});
}
}
{
let value = &self.text;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 3000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("text"),
max: 3000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.text;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 300usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("text"),
max: 300usize,
actual: count,
});
}
}
}
Ok(())
}
}
pub mod create_post_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 Posts;
type ScheduledAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Posts = Unset;
type ScheduledAt = Unset;
}
pub struct SetPosts<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPosts<S> {}
impl<S: State> State for SetPosts<S> {
type Posts = Set<members::posts>;
type ScheduledAt = S::ScheduledAt;
}
pub struct SetScheduledAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetScheduledAt<S> {}
impl<S: State> State for SetScheduledAt<S> {
type Posts = S::Posts;
type ScheduledAt = Set<members::scheduled_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct posts(());
pub struct scheduled_at(());
}
}
pub struct CreatePostBuilder<'a, S: create_post_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<bool>,
Option<CowStr<'a>>,
Option<Vec<create_post::ThreadPostInput<'a>>>,
Option<Datetime>,
Option<Vec<CreatePostThreadgateRulesItem<'a>>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> CreatePost<'a> {
pub fn new() -> CreatePostBuilder<'a, create_post_state::Empty> {
CreatePostBuilder::new()
}
}
impl<'a> CreatePostBuilder<'a, create_post_state::Empty> {
pub fn new() -> Self {
CreatePostBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: create_post_state::State> CreatePostBuilder<'a, S> {
pub fn disable_quote_posts(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_disable_quote_posts(mut self, value: Option<bool>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: create_post_state::State> CreatePostBuilder<'a, S> {
pub fn parent_post_id(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_parent_post_id(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> CreatePostBuilder<'a, S>
where
S: create_post_state::State,
S::Posts: create_post_state::IsUnset,
{
pub fn posts(
mut self,
value: impl Into<Vec<create_post::ThreadPostInput<'a>>>,
) -> CreatePostBuilder<'a, create_post_state::SetPosts<S>> {
self._fields.2 = Option::Some(value.into());
CreatePostBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CreatePostBuilder<'a, S>
where
S: create_post_state::State,
S::ScheduledAt: create_post_state::IsUnset,
{
pub fn scheduled_at(
mut self,
value: impl Into<Datetime>,
) -> CreatePostBuilder<'a, create_post_state::SetScheduledAt<S>> {
self._fields.3 = Option::Some(value.into());
CreatePostBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: create_post_state::State> CreatePostBuilder<'a, S> {
pub fn threadgate_rules(
mut self,
value: impl Into<Option<Vec<CreatePostThreadgateRulesItem<'a>>>>,
) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_threadgate_rules(
mut self,
value: Option<Vec<CreatePostThreadgateRulesItem<'a>>>,
) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> CreatePostBuilder<'a, S>
where
S: create_post_state::State,
S::Posts: create_post_state::IsSet,
S::ScheduledAt: create_post_state::IsSet,
{
pub fn build(self) -> CreatePost<'a> {
CreatePost {
disable_quote_posts: self._fields.0,
parent_post_id: self._fields.1,
posts: self._fields.2.unwrap(),
scheduled_at: self._fields.3.unwrap(),
threadgate_rules: self._fields.4,
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>,
>,
) -> CreatePost<'a> {
CreatePost {
disable_quote_posts: self._fields.0,
parent_post_id: self._fields.1,
posts: self._fields.2.unwrap(),
scheduled_at: self._fields.3.unwrap(),
threadgate_rules: self._fields.4,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_chronosky_schedule_createPost() -> 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.schedule.createPost"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcProcedure(LexXrpcProcedure {
input: Some(LexXrpcBody {
encoding: CowStr::new_static("application/json"),
schema: Some(
LexXrpcBodySchema::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("posts"),
SmolStr::new_static("scheduledAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("disableQuotePosts"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("parentPostId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Chronosky-internal scheduled post ID of the parent post (for scheduling threads or replies). Not an AT Protocol URI or Record Key.",
),
),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("posts"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Array of posts to schedule (1 element = single post, multiple = thread)",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#threadPostInput"),
..Default::default()
}),
min_length: Some(1usize),
max_length: Some(25usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("scheduledAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Scheduled publish time"),
),
format: Some(LexStringFormat::Datetime),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("threadgateRules"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Thread gate rules to control who can reply",
),
),
items: LexArrayItem::Union(LexRefUnion {
refs: vec![
CowStr::new_static("app.bsky.feed.threadgate#mentionRule"),
CowStr::new_static("app.bsky.feed.threadgate#followerRule"),
CowStr::new_static("app.bsky.feed.threadgate#followingRule"),
CowStr::new_static("app.bsky.feed.threadgate#listRule")
],
..Default::default()
}),
max_length: Some(5usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("threadPostInput"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Individual post input for thread scheduling.",
),
),
required: Some(vec![SmolStr::new_static("text")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Post creation timestamp (optional)"),
),
format: Some(LexStringFormat::Datetime),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("embed"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"Embedded content (images, external links, records).",
),
),
refs: vec![
CowStr::new_static("app.bsky.embed.images"),
CowStr::new_static("app.bsky.embed.external"),
CowStr::new_static("app.bsky.embed.record"),
CowStr::new_static("app.bsky.embed.video"),
CowStr::new_static("app.bsky.embed.recordWithMedia")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("facets"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Rich text facets (mentions, links, tags)",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("app.bsky.richtext.facet"),
..Default::default()
}),
max_length: Some(50usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("labels"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"com.atproto.label.defs#selfLabels",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("langs"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("Language codes (ISO 639-1)"),
),
items: LexArrayItem::String(LexString {
format: Some(LexStringFormat::Language),
..Default::default()
}),
max_length: Some(3usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Post text content")),
max_length: Some(3000usize),
max_graphemes: Some(300usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}