1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::types::string::AtUri;
18use jacquard_derive::{IntoStatic, lexicon, open_union};
19use jacquard_lexicon::lexicon::LexiconDoc;
20use jacquard_lexicon::schema::LexiconSchema;
21
22#[allow(unused_imports)]
23use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
24use serde::{Serialize, Deserialize};
25use crate::app_bsky::feed::ThreadgateView;
26use crate::app_bsky::unspecced::ThreadItemBlocked;
27use crate::app_bsky::unspecced::ThreadItemNoUnauthenticated;
28use crate::app_bsky::unspecced::ThreadItemNotFound;
29use crate::app_bsky::unspecced::ThreadItemPost;
30use crate::app_bsky::unspecced::get_post_thread_v2;
31
32#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
33#[serde(rename_all = "camelCase")]
34pub struct GetPostThreadV2<'a> {
35 #[serde(default = "_default_above")]
37 #[serde(skip_serializing_if = "Option::is_none")]
38 pub above: Option<bool>,
39 #[serde(borrow)]
40 pub anchor: AtUri<'a>,
41 #[serde(default = "_default_below")]
43 #[serde(skip_serializing_if = "Option::is_none")]
44 pub below: Option<i64>,
45 #[serde(default = "_default_branching_factor")]
47 #[serde(skip_serializing_if = "Option::is_none")]
48 pub branching_factor: Option<i64>,
49 #[serde(default = "_default_sort")]
51 #[serde(skip_serializing_if = "Option::is_none")]
52 #[serde(borrow)]
53 pub sort: Option<CowStr<'a>>,
54}
55
56
57#[lexicon]
58#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
59#[serde(rename_all = "camelCase")]
60pub struct GetPostThreadV2Output<'a> {
61 pub has_other_replies: bool,
63 #[serde(borrow)]
65 pub thread: Vec<get_post_thread_v2::ThreadItem<'a>>,
66 #[serde(skip_serializing_if = "Option::is_none")]
67 #[serde(borrow)]
68 pub threadgate: Option<ThreadgateView<'a>>,
69}
70
71
72#[lexicon]
73#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
74#[serde(rename_all = "camelCase")]
75pub struct ThreadItem<'a> {
76 pub depth: i64,
78 #[serde(borrow)]
79 pub uri: AtUri<'a>,
80 #[serde(borrow)]
81 pub value: ThreadItemValue<'a>,
82}
83
84
85#[open_union]
86#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
87#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
88pub enum ThreadItemValue<'a> {
89 #[serde(rename = "app.bsky.unspecced.defs#threadItemPost")]
90 ThreadItemPost(Box<ThreadItemPost<'a>>),
91 #[serde(rename = "app.bsky.unspecced.defs#threadItemNoUnauthenticated")]
92 ThreadItemNoUnauthenticated(Box<ThreadItemNoUnauthenticated<'a>>),
93 #[serde(rename = "app.bsky.unspecced.defs#threadItemNotFound")]
94 ThreadItemNotFound(Box<ThreadItemNotFound<'a>>),
95 #[serde(rename = "app.bsky.unspecced.defs#threadItemBlocked")]
96 ThreadItemBlocked(Box<ThreadItemBlocked<'a>>),
97}
98
99pub struct GetPostThreadV2Response;
101impl jacquard_common::xrpc::XrpcResp for GetPostThreadV2Response {
102 const NSID: &'static str = "app.bsky.unspecced.getPostThreadV2";
103 const ENCODING: &'static str = "application/json";
104 type Output<'de> = GetPostThreadV2Output<'de>;
105 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
106}
107
108impl<'a> jacquard_common::xrpc::XrpcRequest for GetPostThreadV2<'a> {
109 const NSID: &'static str = "app.bsky.unspecced.getPostThreadV2";
110 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
111 type Response = GetPostThreadV2Response;
112}
113
114pub struct GetPostThreadV2Request;
116impl jacquard_common::xrpc::XrpcEndpoint for GetPostThreadV2Request {
117 const PATH: &'static str = "/xrpc/app.bsky.unspecced.getPostThreadV2";
118 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
119 type Request<'de> = GetPostThreadV2<'de>;
120 type Response = GetPostThreadV2Response;
121}
122
123impl<'a> LexiconSchema for ThreadItem<'a> {
124 fn nsid() -> &'static str {
125 "app.bsky.unspecced.getPostThreadV2"
126 }
127 fn def_name() -> &'static str {
128 "threadItem"
129 }
130 fn lexicon_doc() -> LexiconDoc<'static> {
131 lexicon_doc_app_bsky_unspecced_getPostThreadV2()
132 }
133 fn validate(&self) -> Result<(), ConstraintError> {
134 Ok(())
135 }
136}
137
138fn _default_above() -> Option<bool> {
139 Some(true)
140}
141
142fn _default_below() -> Option<i64> {
143 Some(6i64)
144}
145
146fn _default_branching_factor() -> Option<i64> {
147 Some(10i64)
148}
149
150fn _default_sort() -> Option<CowStr<'static>> {
151 Some(CowStr::from("oldest"))
152}
153
154pub mod get_post_thread_v2_state {
155
156 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
157 #[allow(unused)]
158 use ::core::marker::PhantomData;
159 mod sealed {
160 pub trait Sealed {}
161 }
162 pub trait State: sealed::Sealed {
164 type Anchor;
165 }
166 pub struct Empty(());
168 impl sealed::Sealed for Empty {}
169 impl State for Empty {
170 type Anchor = Unset;
171 }
172 pub struct SetAnchor<S: State = Empty>(PhantomData<fn() -> S>);
174 impl<S: State> sealed::Sealed for SetAnchor<S> {}
175 impl<S: State> State for SetAnchor<S> {
176 type Anchor = Set<members::anchor>;
177 }
178 #[allow(non_camel_case_types)]
180 pub mod members {
181 pub struct anchor(());
183 }
184}
185
186pub struct GetPostThreadV2Builder<'a, S: get_post_thread_v2_state::State> {
188 _state: PhantomData<fn() -> S>,
189 _fields: (
190 Option<bool>,
191 Option<AtUri<'a>>,
192 Option<i64>,
193 Option<i64>,
194 Option<CowStr<'a>>,
195 ),
196 _lifetime: PhantomData<&'a ()>,
197}
198
199impl<'a> GetPostThreadV2<'a> {
200 pub fn new() -> GetPostThreadV2Builder<'a, get_post_thread_v2_state::Empty> {
202 GetPostThreadV2Builder::new()
203 }
204}
205
206impl<'a> GetPostThreadV2Builder<'a, get_post_thread_v2_state::Empty> {
207 pub fn new() -> Self {
209 GetPostThreadV2Builder {
210 _state: PhantomData,
211 _fields: (None, None, None, None, None),
212 _lifetime: PhantomData,
213 }
214 }
215}
216
217impl<'a, S: get_post_thread_v2_state::State> GetPostThreadV2Builder<'a, S> {
218 pub fn above(mut self, value: impl Into<Option<bool>>) -> Self {
220 self._fields.0 = value.into();
221 self
222 }
223 pub fn maybe_above(mut self, value: Option<bool>) -> Self {
225 self._fields.0 = value;
226 self
227 }
228}
229
230impl<'a, S> GetPostThreadV2Builder<'a, S>
231where
232 S: get_post_thread_v2_state::State,
233 S::Anchor: get_post_thread_v2_state::IsUnset,
234{
235 pub fn anchor(
237 mut self,
238 value: impl Into<AtUri<'a>>,
239 ) -> GetPostThreadV2Builder<'a, get_post_thread_v2_state::SetAnchor<S>> {
240 self._fields.1 = Option::Some(value.into());
241 GetPostThreadV2Builder {
242 _state: PhantomData,
243 _fields: self._fields,
244 _lifetime: PhantomData,
245 }
246 }
247}
248
249impl<'a, S: get_post_thread_v2_state::State> GetPostThreadV2Builder<'a, S> {
250 pub fn below(mut self, value: impl Into<Option<i64>>) -> Self {
252 self._fields.2 = value.into();
253 self
254 }
255 pub fn maybe_below(mut self, value: Option<i64>) -> Self {
257 self._fields.2 = value;
258 self
259 }
260}
261
262impl<'a, S: get_post_thread_v2_state::State> GetPostThreadV2Builder<'a, S> {
263 pub fn branching_factor(mut self, value: impl Into<Option<i64>>) -> Self {
265 self._fields.3 = value.into();
266 self
267 }
268 pub fn maybe_branching_factor(mut self, value: Option<i64>) -> Self {
270 self._fields.3 = value;
271 self
272 }
273}
274
275impl<'a, S: get_post_thread_v2_state::State> GetPostThreadV2Builder<'a, S> {
276 pub fn sort(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
278 self._fields.4 = value.into();
279 self
280 }
281 pub fn maybe_sort(mut self, value: Option<CowStr<'a>>) -> Self {
283 self._fields.4 = value;
284 self
285 }
286}
287
288impl<'a, S> GetPostThreadV2Builder<'a, S>
289where
290 S: get_post_thread_v2_state::State,
291 S::Anchor: get_post_thread_v2_state::IsSet,
292{
293 pub fn build(self) -> GetPostThreadV2<'a> {
295 GetPostThreadV2 {
296 above: self._fields.0,
297 anchor: self._fields.1.unwrap(),
298 below: self._fields.2,
299 branching_factor: self._fields.3,
300 sort: self._fields.4,
301 }
302 }
303}
304
305pub mod thread_item_state {
306
307 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
308 #[allow(unused)]
309 use ::core::marker::PhantomData;
310 mod sealed {
311 pub trait Sealed {}
312 }
313 pub trait State: sealed::Sealed {
315 type Value;
316 type Depth;
317 type Uri;
318 }
319 pub struct Empty(());
321 impl sealed::Sealed for Empty {}
322 impl State for Empty {
323 type Value = Unset;
324 type Depth = Unset;
325 type Uri = Unset;
326 }
327 pub struct SetValue<S: State = Empty>(PhantomData<fn() -> S>);
329 impl<S: State> sealed::Sealed for SetValue<S> {}
330 impl<S: State> State for SetValue<S> {
331 type Value = Set<members::value>;
332 type Depth = S::Depth;
333 type Uri = S::Uri;
334 }
335 pub struct SetDepth<S: State = Empty>(PhantomData<fn() -> S>);
337 impl<S: State> sealed::Sealed for SetDepth<S> {}
338 impl<S: State> State for SetDepth<S> {
339 type Value = S::Value;
340 type Depth = Set<members::depth>;
341 type Uri = S::Uri;
342 }
343 pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
345 impl<S: State> sealed::Sealed for SetUri<S> {}
346 impl<S: State> State for SetUri<S> {
347 type Value = S::Value;
348 type Depth = S::Depth;
349 type Uri = Set<members::uri>;
350 }
351 #[allow(non_camel_case_types)]
353 pub mod members {
354 pub struct value(());
356 pub struct depth(());
358 pub struct uri(());
360 }
361}
362
363pub struct ThreadItemBuilder<'a, S: thread_item_state::State> {
365 _state: PhantomData<fn() -> S>,
366 _fields: (Option<i64>, Option<AtUri<'a>>, Option<ThreadItemValue<'a>>),
367 _lifetime: PhantomData<&'a ()>,
368}
369
370impl<'a> ThreadItem<'a> {
371 pub fn new() -> ThreadItemBuilder<'a, thread_item_state::Empty> {
373 ThreadItemBuilder::new()
374 }
375}
376
377impl<'a> ThreadItemBuilder<'a, thread_item_state::Empty> {
378 pub fn new() -> Self {
380 ThreadItemBuilder {
381 _state: PhantomData,
382 _fields: (None, None, None),
383 _lifetime: PhantomData,
384 }
385 }
386}
387
388impl<'a, S> ThreadItemBuilder<'a, S>
389where
390 S: thread_item_state::State,
391 S::Depth: thread_item_state::IsUnset,
392{
393 pub fn depth(
395 mut self,
396 value: impl Into<i64>,
397 ) -> ThreadItemBuilder<'a, thread_item_state::SetDepth<S>> {
398 self._fields.0 = Option::Some(value.into());
399 ThreadItemBuilder {
400 _state: PhantomData,
401 _fields: self._fields,
402 _lifetime: PhantomData,
403 }
404 }
405}
406
407impl<'a, S> ThreadItemBuilder<'a, S>
408where
409 S: thread_item_state::State,
410 S::Uri: thread_item_state::IsUnset,
411{
412 pub fn uri(
414 mut self,
415 value: impl Into<AtUri<'a>>,
416 ) -> ThreadItemBuilder<'a, thread_item_state::SetUri<S>> {
417 self._fields.1 = Option::Some(value.into());
418 ThreadItemBuilder {
419 _state: PhantomData,
420 _fields: self._fields,
421 _lifetime: PhantomData,
422 }
423 }
424}
425
426impl<'a, S> ThreadItemBuilder<'a, S>
427where
428 S: thread_item_state::State,
429 S::Value: thread_item_state::IsUnset,
430{
431 pub fn value(
433 mut self,
434 value: impl Into<ThreadItemValue<'a>>,
435 ) -> ThreadItemBuilder<'a, thread_item_state::SetValue<S>> {
436 self._fields.2 = Option::Some(value.into());
437 ThreadItemBuilder {
438 _state: PhantomData,
439 _fields: self._fields,
440 _lifetime: PhantomData,
441 }
442 }
443}
444
445impl<'a, S> ThreadItemBuilder<'a, S>
446where
447 S: thread_item_state::State,
448 S::Value: thread_item_state::IsSet,
449 S::Depth: thread_item_state::IsSet,
450 S::Uri: thread_item_state::IsSet,
451{
452 pub fn build(self) -> ThreadItem<'a> {
454 ThreadItem {
455 depth: self._fields.0.unwrap(),
456 uri: self._fields.1.unwrap(),
457 value: self._fields.2.unwrap(),
458 extra_data: Default::default(),
459 }
460 }
461 pub fn build_with_data(
463 self,
464 extra_data: BTreeMap<
465 jacquard_common::deps::smol_str::SmolStr,
466 jacquard_common::types::value::Data<'a>,
467 >,
468 ) -> ThreadItem<'a> {
469 ThreadItem {
470 depth: self._fields.0.unwrap(),
471 uri: self._fields.1.unwrap(),
472 value: self._fields.2.unwrap(),
473 extra_data: Some(extra_data),
474 }
475 }
476}
477
478fn lexicon_doc_app_bsky_unspecced_getPostThreadV2() -> LexiconDoc<'static> {
479 #[allow(unused_imports)]
480 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
481 use jacquard_lexicon::lexicon::*;
482 use alloc::collections::BTreeMap;
483 LexiconDoc {
484 lexicon: Lexicon::Lexicon1,
485 id: CowStr::new_static("app.bsky.unspecced.getPostThreadV2"),
486 defs: {
487 let mut map = BTreeMap::new();
488 map.insert(
489 SmolStr::new_static("main"),
490 LexUserType::XrpcQuery(LexXrpcQuery {
491 parameters: Some(
492 LexXrpcQueryParameter::Params(LexXrpcParameters {
493 required: Some(vec![SmolStr::new_static("anchor")]),
494 properties: {
495 #[allow(unused_mut)]
496 let mut map = BTreeMap::new();
497 map.insert(
498 SmolStr::new_static("above"),
499 LexXrpcParametersProperty::Boolean(LexBoolean {
500 ..Default::default()
501 }),
502 );
503 map.insert(
504 SmolStr::new_static("anchor"),
505 LexXrpcParametersProperty::String(LexString {
506 description: Some(
507 CowStr::new_static(
508 "Reference (AT-URI) to post record. This is the anchor post, and the thread will be built around it. It can be any post in the tree, not necessarily a root post.",
509 ),
510 ),
511 format: Some(LexStringFormat::AtUri),
512 ..Default::default()
513 }),
514 );
515 map.insert(
516 SmolStr::new_static("below"),
517 LexXrpcParametersProperty::Integer(LexInteger {
518 ..Default::default()
519 }),
520 );
521 map.insert(
522 SmolStr::new_static("branchingFactor"),
523 LexXrpcParametersProperty::Integer(LexInteger {
524 ..Default::default()
525 }),
526 );
527 map.insert(
528 SmolStr::new_static("sort"),
529 LexXrpcParametersProperty::String(LexString {
530 description: Some(
531 CowStr::new_static("Sorting for the thread replies."),
532 ),
533 ..Default::default()
534 }),
535 );
536 map
537 },
538 ..Default::default()
539 }),
540 ),
541 ..Default::default()
542 }),
543 );
544 map.insert(
545 SmolStr::new_static("threadItem"),
546 LexUserType::Object(LexObject {
547 required: Some(
548 vec![
549 SmolStr::new_static("uri"), SmolStr::new_static("depth"),
550 SmolStr::new_static("value")
551 ],
552 ),
553 properties: {
554 #[allow(unused_mut)]
555 let mut map = BTreeMap::new();
556 map.insert(
557 SmolStr::new_static("depth"),
558 LexObjectProperty::Integer(LexInteger {
559 ..Default::default()
560 }),
561 );
562 map.insert(
563 SmolStr::new_static("uri"),
564 LexObjectProperty::String(LexString {
565 format: Some(LexStringFormat::AtUri),
566 ..Default::default()
567 }),
568 );
569 map.insert(
570 SmolStr::new_static("value"),
571 LexObjectProperty::Union(LexRefUnion {
572 refs: vec![
573 CowStr::new_static("app.bsky.unspecced.defs#threadItemPost"),
574 CowStr::new_static("app.bsky.unspecced.defs#threadItemNoUnauthenticated"),
575 CowStr::new_static("app.bsky.unspecced.defs#threadItemNotFound"),
576 CowStr::new_static("app.bsky.unspecced.defs#threadItemBlocked")
577 ],
578 ..Default::default()
579 }),
580 );
581 map
582 },
583 ..Default::default()
584 }),
585 );
586 map
587 },
588 ..Default::default()
589 }
590}