#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{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;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::ooo_bsky::authfetch::fetch_records;
use crate::ooo_bsky::authfetch::strategy::Strategy;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct FetchRecords<S: BosStr = DefaultStr> {
pub uris: Vec<AtUri<S>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct FetchRecordsOutput<S: BosStr = DefaultStr> {
pub results: Vec<fetch_records::FetchRecordsResult<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 FetchRecordsResult<S: BosStr = DefaultStr> {
pub record: Data<S>,
pub strategy: Strategy<S>,
pub uri: AtUri<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
pub struct FetchRecordsResponse;
impl jacquard_common::xrpc::XrpcResp for FetchRecordsResponse {
const NSID: &'static str = "ooo.bsky.authfetch.fetchRecords";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = FetchRecordsOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for FetchRecords<S> {
const NSID: &'static str = "ooo.bsky.authfetch.fetchRecords";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = FetchRecordsResponse;
}
pub struct FetchRecordsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for FetchRecordsRequest {
const PATH: &'static str = "/xrpc/ooo.bsky.authfetch.fetchRecords";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = FetchRecords<S>;
type Response = FetchRecordsResponse;
}
impl<S: BosStr> LexiconSchema for FetchRecordsResult<S> {
fn nsid() -> &'static str {
"ooo.bsky.authfetch.fetchRecords"
}
fn def_name() -> &'static str {
"result"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_ooo_bsky_authfetch_fetchRecords()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod fetch_records_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 Uris;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uris = Unset;
}
pub struct SetUris<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUris<St> {}
impl<St: State> State for SetUris<St> {
type Uris = Set<members::uris>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uris(());
}
}
pub struct FetchRecordsBuilder<S: BosStr, St: fetch_records_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<AtUri<S>>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> FetchRecords<S> {
pub fn new() -> FetchRecordsBuilder<S, fetch_records_state::Empty> {
FetchRecordsBuilder::new()
}
}
impl<S: BosStr> FetchRecordsBuilder<S, fetch_records_state::Empty> {
pub fn new() -> Self {
FetchRecordsBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FetchRecordsBuilder<S, St>
where
St: fetch_records_state::State,
St::Uris: fetch_records_state::IsUnset,
{
pub fn uris(
mut self,
value: impl Into<Vec<AtUri<S>>>,
) -> FetchRecordsBuilder<S, fetch_records_state::SetUris<St>> {
self._fields.0 = Option::Some(value.into());
FetchRecordsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FetchRecordsBuilder<S, St>
where
St: fetch_records_state::State,
St::Uris: fetch_records_state::IsSet,
{
pub fn build(self) -> FetchRecords<S> {
FetchRecords {
uris: self._fields.0.unwrap(),
}
}
}
pub mod fetch_records_result_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 Uri;
type Strategy;
type Record;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
type Strategy = Unset;
type Record = 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>;
type Strategy = St::Strategy;
type Record = St::Record;
}
pub struct SetStrategy<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStrategy<St> {}
impl<St: State> State for SetStrategy<St> {
type Uri = St::Uri;
type Strategy = Set<members::strategy>;
type Record = St::Record;
}
pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRecord<St> {}
impl<St: State> State for SetRecord<St> {
type Uri = St::Uri;
type Strategy = St::Strategy;
type Record = Set<members::record>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
pub struct strategy(());
pub struct record(());
}
}
pub struct FetchRecordsResultBuilder<S: BosStr, St: fetch_records_result_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Data<S>>, Option<Strategy<S>>, Option<AtUri<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> FetchRecordsResult<S> {
pub fn new() -> FetchRecordsResultBuilder<S, fetch_records_result_state::Empty> {
FetchRecordsResultBuilder::new()
}
}
impl<S: BosStr> FetchRecordsResultBuilder<S, fetch_records_result_state::Empty> {
pub fn new() -> Self {
FetchRecordsResultBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FetchRecordsResultBuilder<S, St>
where
St: fetch_records_result_state::State,
St::Record: fetch_records_result_state::IsUnset,
{
pub fn record(
mut self,
value: impl Into<Data<S>>,
) -> FetchRecordsResultBuilder<S, fetch_records_result_state::SetRecord<St>> {
self._fields.0 = Option::Some(value.into());
FetchRecordsResultBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FetchRecordsResultBuilder<S, St>
where
St: fetch_records_result_state::State,
St::Strategy: fetch_records_result_state::IsUnset,
{
pub fn strategy(
mut self,
value: impl Into<Strategy<S>>,
) -> FetchRecordsResultBuilder<S, fetch_records_result_state::SetStrategy<St>> {
self._fields.1 = Option::Some(value.into());
FetchRecordsResultBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FetchRecordsResultBuilder<S, St>
where
St: fetch_records_result_state::State,
St::Uri: fetch_records_result_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> FetchRecordsResultBuilder<S, fetch_records_result_state::SetUri<St>> {
self._fields.2 = Option::Some(value.into());
FetchRecordsResultBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FetchRecordsResultBuilder<S, St>
where
St: fetch_records_result_state::State,
St::Uri: fetch_records_result_state::IsSet,
St::Strategy: fetch_records_result_state::IsSet,
St::Record: fetch_records_result_state::IsSet,
{
pub fn build(self) -> FetchRecordsResult<S> {
FetchRecordsResult {
record: self._fields.0.unwrap(),
strategy: self._fields.1.unwrap(),
uri: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> FetchRecordsResult<S> {
FetchRecordsResult {
record: self._fields.0.unwrap(),
strategy: self._fields.1.unwrap(),
uri: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_ooo_bsky_authfetch_fetchRecords() -> 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("ooo.bsky.authfetch.fetchRecords"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(LexXrpcQueryParameter::Params(LexXrpcParameters {
required: Some(vec![SmolStr::new_static("uris")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("uris"),
LexXrpcParametersProperty::Array(LexPrimitiveArray {
items: LexPrimitiveArrayItem::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
min_length: Some(1usize),
max_length: Some(50usize),
..Default::default()
}),
);
map
},
..Default::default()
})),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("result"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Successful result, with the record value.",
)),
required: Some(vec![
SmolStr::new_static("uri"),
SmolStr::new_static("strategy"),
SmolStr::new_static("record"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("record"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("strategy"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("ooo.bsky.authfetch.strategy"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The AT URI of the record.")),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}