#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, 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::{AtUri, Cid, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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::actor::ProfileView;
use crate::app_bsky::feed::get_likes;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Like<S: BosStr = DefaultStr> {
pub actor: ProfileView<S>,
pub created_at: Datetime,
pub indexed_at: Datetime,
#[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 GetLikes<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
#[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>,
pub uri: AtUri<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetLikesOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<S>,
pub likes: Vec<get_likes::Like<S>>,
pub uri: AtUri<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for Like<S> {
fn nsid() -> &'static str {
"app.bsky.feed.getLikes"
}
fn def_name() -> &'static str {
"like"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_feed_getLikes()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct GetLikesResponse;
impl jacquard_common::xrpc::XrpcResp for GetLikesResponse {
const NSID: &'static str = "app.bsky.feed.getLikes";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = GetLikesOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetLikes<S> {
const NSID: &'static str = "app.bsky.feed.getLikes";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetLikesResponse;
}
pub struct GetLikesRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetLikesRequest {
const PATH: &'static str = "/xrpc/app.bsky.feed.getLikes";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = GetLikes<S>;
type Response = GetLikesResponse;
}
pub mod like_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 IndexedAt;
type CreatedAt;
type Actor;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type IndexedAt = Unset;
type CreatedAt = Unset;
type Actor = Unset;
}
pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
impl<St: State> State for SetIndexedAt<St> {
type IndexedAt = Set<members::indexed_at>;
type CreatedAt = St::CreatedAt;
type Actor = St::Actor;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type IndexedAt = St::IndexedAt;
type CreatedAt = Set<members::created_at>;
type Actor = St::Actor;
}
pub struct SetActor<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetActor<St> {}
impl<St: State> State for SetActor<St> {
type IndexedAt = St::IndexedAt;
type CreatedAt = St::CreatedAt;
type Actor = Set<members::actor>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct indexed_at(());
pub struct created_at(());
pub struct actor(());
}
}
pub struct LikeBuilder<S: BosStr, St: like_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<ProfileView<S>>, Option<Datetime>, Option<Datetime>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Like<S> {
pub fn new() -> LikeBuilder<S, like_state::Empty> {
LikeBuilder::new()
}
}
impl<S: BosStr> LikeBuilder<S, like_state::Empty> {
pub fn new() -> Self {
LikeBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LikeBuilder<S, St>
where
St: like_state::State,
St::Actor: like_state::IsUnset,
{
pub fn actor(
mut self,
value: impl Into<ProfileView<S>>,
) -> LikeBuilder<S, like_state::SetActor<St>> {
self._fields.0 = Option::Some(value.into());
LikeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LikeBuilder<S, St>
where
St: like_state::State,
St::CreatedAt: like_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> LikeBuilder<S, like_state::SetCreatedAt<St>> {
self._fields.1 = Option::Some(value.into());
LikeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LikeBuilder<S, St>
where
St: like_state::State,
St::IndexedAt: like_state::IsUnset,
{
pub fn indexed_at(
mut self,
value: impl Into<Datetime>,
) -> LikeBuilder<S, like_state::SetIndexedAt<St>> {
self._fields.2 = Option::Some(value.into());
LikeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LikeBuilder<S, St>
where
St: like_state::State,
St::IndexedAt: like_state::IsSet,
St::CreatedAt: like_state::IsSet,
St::Actor: like_state::IsSet,
{
pub fn build(self) -> Like<S> {
Like {
actor: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
indexed_at: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Like<S> {
Like {
actor: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
indexed_at: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_bsky_feed_getLikes() -> 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.bsky.feed.getLikes"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("like"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("indexedAt"),
SmolStr::new_static("createdAt"),
SmolStr::new_static("actor")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("actor"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"app.bsky.actor.defs#profileView",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("indexedAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(
LexXrpcQueryParameter::Params(LexXrpcParameters {
required: Some(vec![SmolStr::new_static("uri")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cid"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"CID of the subject record (aka, specific version of record), to filter likes.",
),
),
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
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("uri"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"AT-URI of the subject (eg, a post record).",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map
},
..Default::default()
}
}
fn _default_limit() -> Option<i64> {
Some(50i64)
}
pub mod get_likes_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 Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
}
pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUri<St> {}
impl<St: State> State for SetUri<St> {
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct GetLikesBuilder<S: BosStr, St: get_likes_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Cid<S>>, Option<S>, Option<i64>, Option<AtUri<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> GetLikes<S> {
pub fn new() -> GetLikesBuilder<S, get_likes_state::Empty> {
GetLikesBuilder::new()
}
}
impl<S: BosStr> GetLikesBuilder<S, get_likes_state::Empty> {
pub fn new() -> Self {
GetLikesBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: get_likes_state::State> GetLikesBuilder<S, St> {
pub fn cid(mut self, value: impl Into<Option<Cid<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_cid(mut self, value: Option<Cid<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: get_likes_state::State> GetLikesBuilder<S, St> {
pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_cursor(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: get_likes_state::State> GetLikesBuilder<S, St> {
pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> GetLikesBuilder<S, St>
where
St: get_likes_state::State,
St::Uri: get_likes_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> GetLikesBuilder<S, get_likes_state::SetUri<St>> {
self._fields.3 = Option::Some(value.into());
GetLikesBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GetLikesBuilder<S, St>
where
St: get_likes_state::State,
St::Uri: get_likes_state::IsSet,
{
pub fn build(self) -> GetLikes<S> {
GetLikes {
cid: self._fields.0,
cursor: self._fields.1,
limit: self._fields.2,
uri: self._fields.3.unwrap(),
}
}
}