#[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::{Did, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, 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;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CreateReport<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub mod_tool: Option<create_report::ModTool<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<S>,
pub reason_type: ReasonType<S>,
pub subject: CreateReportSubject<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum CreateReportSubject<S: BosStr = DefaultStr> {
#[serde(rename = "com.atproto.admin.defs#repoRef")]
RepoRef(Box<RepoRef<S>>),
#[serde(rename = "com.atproto.repo.strongRef")]
StrongRef(Box<StrongRef<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CreateReportOutput<S: BosStr = DefaultStr> {
pub created_at: Datetime,
pub id: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<S>,
pub reason_type: ReasonType<S>,
pub reported_by: Did<S>,
pub subject: CreateReportOutputSubject<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum CreateReportOutputSubject<S: BosStr = DefaultStr> {
#[serde(rename = "com.atproto.admin.defs#repoRef")]
RepoRef(Box<RepoRef<S>>),
#[serde(rename = "com.atproto.repo.strongRef")]
StrongRef(Box<StrongRef<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ModTool<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub meta: Option<Data<S>>,
pub name: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
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<S: BosStr> = CreateReportOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for CreateReport<S> {
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<S: BosStr> = CreateReport<S>;
type Response = CreateReportResponse;
}
impl<S: BosStr> LexiconSchema for ModTool<S> {
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 Subject;
type ReasonType;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Subject = Unset;
type ReasonType = Unset;
}
pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSubject<St> {}
impl<St: State> State for SetSubject<St> {
type Subject = Set<members::subject>;
type ReasonType = St::ReasonType;
}
pub struct SetReasonType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetReasonType<St> {}
impl<St: State> State for SetReasonType<St> {
type Subject = St::Subject;
type ReasonType = Set<members::reason_type>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct subject(());
pub struct reason_type(());
}
}
pub struct CreateReportBuilder<S: BosStr, St: create_report_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<create_report::ModTool<S>>,
Option<S>,
Option<ReasonType<S>>,
Option<CreateReportSubject<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> CreateReport<S> {
pub fn new() -> CreateReportBuilder<S, create_report_state::Empty> {
CreateReportBuilder::new()
}
}
impl<S: BosStr> CreateReportBuilder<S, create_report_state::Empty> {
pub fn new() -> Self {
CreateReportBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: create_report_state::State> CreateReportBuilder<S, St> {
pub fn mod_tool(
mut self,
value: impl Into<Option<create_report::ModTool<S>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_mod_tool(mut self, value: Option<create_report::ModTool<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: create_report_state::State> CreateReportBuilder<S, St> {
pub fn reason(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_reason(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> CreateReportBuilder<S, St>
where
St: create_report_state::State,
St::ReasonType: create_report_state::IsUnset,
{
pub fn reason_type(
mut self,
value: impl Into<ReasonType<S>>,
) -> CreateReportBuilder<S, create_report_state::SetReasonType<St>> {
self._fields.2 = Option::Some(value.into());
CreateReportBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CreateReportBuilder<S, St>
where
St: create_report_state::State,
St::Subject: create_report_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<CreateReportSubject<S>>,
) -> CreateReportBuilder<S, create_report_state::SetSubject<St>> {
self._fields.3 = Option::Some(value.into());
CreateReportBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CreateReportBuilder<S, St>
where
St: create_report_state::State,
St::Subject: create_report_state::IsSet,
St::ReasonType: create_report_state::IsSet,
{
pub fn build(self) -> CreateReport<S> {
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<SmolStr, Data<S>>,
) -> CreateReport<S> {
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()
}
}