#[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::{Did, Datetime};
use jacquard_common::types::value::Data;
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::com_atproto::admin::RepoRef;
use crate::com_atproto::moderation::ReasonType;
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::com_atproto::moderation::create_report;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CreateReport<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub mod_tool: Option<create_report::ModTool<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub reason: Option<CowStr<'a>>,
#[serde(borrow)]
pub reason_type: ReasonType<'a>,
#[serde(borrow)]
pub subject: CreateReportSubject<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum CreateReportSubject<'a> {
#[serde(rename = "com.atproto.admin.defs#repoRef")]
RepoRef(Box<RepoRef<'a>>),
#[serde(rename = "com.atproto.repo.strongRef")]
StrongRef(Box<StrongRef<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CreateReportOutput<'a> {
pub created_at: Datetime,
pub id: i64,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub reason: Option<CowStr<'a>>,
#[serde(borrow)]
pub reason_type: ReasonType<'a>,
#[serde(borrow)]
pub reported_by: Did<'a>,
#[serde(borrow)]
pub subject: CreateReportOutputSubject<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum CreateReportOutputSubject<'a> {
#[serde(rename = "com.atproto.admin.defs#repoRef")]
RepoRef(Box<RepoRef<'a>>),
#[serde(rename = "com.atproto.repo.strongRef")]
StrongRef(Box<StrongRef<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ModTool<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub meta: Option<Data<'a>>,
#[serde(borrow)]
pub name: CowStr<'a>,
}
pub struct CreateReportResponse;
impl jacquard_common::xrpc::XrpcResp for CreateReportResponse {
const NSID: &'static str = "com.atproto.moderation.createReport";
const ENCODING: &'static str = "application/json";
type Output<'de> = CreateReportOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for CreateReport<'a> {
const NSID: &'static str = "com.atproto.moderation.createReport";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = CreateReportResponse;
}
pub struct CreateReportRequest;
impl jacquard_common::xrpc::XrpcEndpoint for CreateReportRequest {
const PATH: &'static str = "/xrpc/com.atproto.moderation.createReport";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<'de> = CreateReport<'de>;
type Response = CreateReportResponse;
}
impl<'a> LexiconSchema for ModTool<'a> {
fn nsid() -> &'static str {
"com.atproto.moderation.createReport"
}
fn def_name() -> &'static str {
"modTool"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_moderation_createReport()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod create_report_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 ReasonType;
type Subject;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ReasonType = Unset;
type Subject = Unset;
}
pub struct SetReasonType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetReasonType<S> {}
impl<S: State> State for SetReasonType<S> {
type ReasonType = Set<members::reason_type>;
type Subject = S::Subject;
}
pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSubject<S> {}
impl<S: State> State for SetSubject<S> {
type ReasonType = S::ReasonType;
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct reason_type(());
pub struct subject(());
}
}
pub struct CreateReportBuilder<'a, S: create_report_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<create_report::ModTool<'a>>,
Option<CowStr<'a>>,
Option<ReasonType<'a>>,
Option<CreateReportSubject<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> CreateReport<'a> {
pub fn new() -> CreateReportBuilder<'a, create_report_state::Empty> {
CreateReportBuilder::new()
}
}
impl<'a> CreateReportBuilder<'a, create_report_state::Empty> {
pub fn new() -> Self {
CreateReportBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: create_report_state::State> CreateReportBuilder<'a, S> {
pub fn mod_tool(
mut self,
value: impl Into<Option<create_report::ModTool<'a>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_mod_tool(mut self, value: Option<create_report::ModTool<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: create_report_state::State> CreateReportBuilder<'a, S> {
pub fn reason(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_reason(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> CreateReportBuilder<'a, S>
where
S: create_report_state::State,
S::ReasonType: create_report_state::IsUnset,
{
pub fn reason_type(
mut self,
value: impl Into<ReasonType<'a>>,
) -> CreateReportBuilder<'a, create_report_state::SetReasonType<S>> {
self._fields.2 = Option::Some(value.into());
CreateReportBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CreateReportBuilder<'a, S>
where
S: create_report_state::State,
S::Subject: create_report_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<CreateReportSubject<'a>>,
) -> CreateReportBuilder<'a, create_report_state::SetSubject<S>> {
self._fields.3 = Option::Some(value.into());
CreateReportBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CreateReportBuilder<'a, S>
where
S: create_report_state::State,
S::ReasonType: create_report_state::IsSet,
S::Subject: create_report_state::IsSet,
{
pub fn build(self) -> CreateReport<'a> {
CreateReport {
mod_tool: self._fields.0,
reason: self._fields.1,
reason_type: self._fields.2.unwrap(),
subject: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> CreateReport<'a> {
CreateReport {
mod_tool: self._fields.0,
reason: self._fields.1,
reason_type: self._fields.2.unwrap(),
subject: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_com_atproto_moderation_createReport() -> 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("com.atproto.moderation.createReport"),
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("reasonType"),
SmolStr::new_static("subject")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("modTool"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#modTool"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("reason"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Additional context about the content and violation.",
),
),
max_length: Some(20000usize),
max_graphemes: Some(2000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("reasonType"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"com.atproto.moderation.defs#reasonType",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("com.atproto.admin.defs#repoRef"),
CowStr::new_static("com.atproto.repo.strongRef")
],
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("modTool"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Moderation tool information for tracing the source of the action",
),
),
required: Some(vec![SmolStr::new_static("name")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("meta"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Name/identifier of the source (e.g., 'bsky-app/android', 'bsky-web/chrome')",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}