pub mod comment;
pub mod issue;
pub mod response;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::network_slices::tools::Images;
use crate::network_slices::tools::richtext::facet::Facet;
#[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",
rename = "network.slices.tools.bug",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Bug<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub app_used: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub attachments: Option<Images<S>>,
pub created_at: Datetime,
pub description: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub description_facets: Option<Vec<Facet<S>>>,
pub namespace: S,
pub severity: BugSeverity<S>,
pub steps_to_reproduce: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub steps_to_reproduce_facets: Option<Vec<Facet<S>>>,
pub title: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BugSeverity<S: BosStr = DefaultStr> {
Cosmetic,
Annoying,
Broken,
Unusable,
Other(S),
}
impl<S: BosStr> BugSeverity<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Cosmetic => "cosmetic",
Self::Annoying => "annoying",
Self::Broken => "broken",
Self::Unusable => "unusable",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"cosmetic" => Self::Cosmetic,
"annoying" => Self::Annoying,
"broken" => Self::Broken,
"unusable" => Self::Unusable,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for BugSeverity<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for BugSeverity<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for BugSeverity<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for BugSeverity<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for BugSeverity<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for BugSeverity<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = BugSeverity<S::Output>;
fn into_static(self) -> Self::Output {
match self {
BugSeverity::Cosmetic => BugSeverity::Cosmetic,
BugSeverity::Annoying => BugSeverity::Annoying,
BugSeverity::Broken => BugSeverity::Broken,
BugSeverity::Unusable => BugSeverity::Unusable,
BugSeverity::Other(v) => BugSeverity::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct BugGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Bug<S>,
}
impl<S: BosStr> Bug<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, BugRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct BugRecord;
impl XrpcResp for BugRecord {
const NSID: &'static str = "network.slices.tools.bug";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = BugGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<BugGetRecordOutput<S>> for Bug<S> {
fn from(output: BugGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Bug<S> {
const NSID: &'static str = "network.slices.tools.bug";
type Record = BugRecord;
}
impl Collection for BugRecord {
const NSID: &'static str = "network.slices.tools.bug";
type Record = BugRecord;
}
impl<S: BosStr> LexiconSchema for Bug<S> {
fn nsid() -> &'static str {
"network.slices.tools.bug"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_network_slices_tools_bug()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.app_used {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 300usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("app_used"),
max: 300usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.description;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 10000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.description;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 3000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("description"),
max: 3000usize,
actual: count,
});
}
}
}
{
let value = &self.steps_to_reproduce;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 5000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("steps_to_reproduce"),
max: 5000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.steps_to_reproduce;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 1500usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("steps_to_reproduce"),
max: 1500usize,
actual: count,
});
}
}
}
{
let value = &self.title;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 300usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("title"),
max: 300usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.title;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 100usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("title"),
max: 100usize,
actual: count,
});
}
}
}
Ok(())
}
}
pub mod bug_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 Namespace;
type Title;
type Severity;
type CreatedAt;
type StepsToReproduce;
type Description;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Namespace = Unset;
type Title = Unset;
type Severity = Unset;
type CreatedAt = Unset;
type StepsToReproduce = Unset;
type Description = Unset;
}
pub struct SetNamespace<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetNamespace<St> {}
impl<St: State> State for SetNamespace<St> {
type Namespace = Set<members::namespace>;
type Title = St::Title;
type Severity = St::Severity;
type CreatedAt = St::CreatedAt;
type StepsToReproduce = St::StepsToReproduce;
type Description = St::Description;
}
pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTitle<St> {}
impl<St: State> State for SetTitle<St> {
type Namespace = St::Namespace;
type Title = Set<members::title>;
type Severity = St::Severity;
type CreatedAt = St::CreatedAt;
type StepsToReproduce = St::StepsToReproduce;
type Description = St::Description;
}
pub struct SetSeverity<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSeverity<St> {}
impl<St: State> State for SetSeverity<St> {
type Namespace = St::Namespace;
type Title = St::Title;
type Severity = Set<members::severity>;
type CreatedAt = St::CreatedAt;
type StepsToReproduce = St::StepsToReproduce;
type Description = St::Description;
}
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 Namespace = St::Namespace;
type Title = St::Title;
type Severity = St::Severity;
type CreatedAt = Set<members::created_at>;
type StepsToReproduce = St::StepsToReproduce;
type Description = St::Description;
}
pub struct SetStepsToReproduce<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStepsToReproduce<St> {}
impl<St: State> State for SetStepsToReproduce<St> {
type Namespace = St::Namespace;
type Title = St::Title;
type Severity = St::Severity;
type CreatedAt = St::CreatedAt;
type StepsToReproduce = Set<members::steps_to_reproduce>;
type Description = St::Description;
}
pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDescription<St> {}
impl<St: State> State for SetDescription<St> {
type Namespace = St::Namespace;
type Title = St::Title;
type Severity = St::Severity;
type CreatedAt = St::CreatedAt;
type StepsToReproduce = St::StepsToReproduce;
type Description = Set<members::description>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct namespace(());
pub struct title(());
pub struct severity(());
pub struct created_at(());
pub struct steps_to_reproduce(());
pub struct description(());
}
}
pub struct BugBuilder<S: BosStr, St: bug_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<Images<S>>,
Option<Datetime>,
Option<S>,
Option<Vec<Facet<S>>>,
Option<S>,
Option<BugSeverity<S>>,
Option<S>,
Option<Vec<Facet<S>>>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Bug<S> {
pub fn new() -> BugBuilder<S, bug_state::Empty> {
BugBuilder::new()
}
}
impl<S: BosStr> BugBuilder<S, bug_state::Empty> {
pub fn new() -> Self {
BugBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: bug_state::State> BugBuilder<S, St> {
pub fn app_used(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_app_used(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: bug_state::State> BugBuilder<S, St> {
pub fn attachments(mut self, value: impl Into<Option<Images<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_attachments(mut self, value: Option<Images<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> BugBuilder<S, St>
where
St: bug_state::State,
St::CreatedAt: bug_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> BugBuilder<S, bug_state::SetCreatedAt<St>> {
self._fields.2 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BugBuilder<S, St>
where
St: bug_state::State,
St::Description: bug_state::IsUnset,
{
pub fn description(
mut self,
value: impl Into<S>,
) -> BugBuilder<S, bug_state::SetDescription<St>> {
self._fields.3 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: bug_state::State> BugBuilder<S, St> {
pub fn description_facets(mut self, value: impl Into<Option<Vec<Facet<S>>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_description_facets(mut self, value: Option<Vec<Facet<S>>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> BugBuilder<S, St>
where
St: bug_state::State,
St::Namespace: bug_state::IsUnset,
{
pub fn namespace(mut self, value: impl Into<S>) -> BugBuilder<S, bug_state::SetNamespace<St>> {
self._fields.5 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BugBuilder<S, St>
where
St: bug_state::State,
St::Severity: bug_state::IsUnset,
{
pub fn severity(
mut self,
value: impl Into<BugSeverity<S>>,
) -> BugBuilder<S, bug_state::SetSeverity<St>> {
self._fields.6 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BugBuilder<S, St>
where
St: bug_state::State,
St::StepsToReproduce: bug_state::IsUnset,
{
pub fn steps_to_reproduce(
mut self,
value: impl Into<S>,
) -> BugBuilder<S, bug_state::SetStepsToReproduce<St>> {
self._fields.7 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: bug_state::State> BugBuilder<S, St> {
pub fn steps_to_reproduce_facets(mut self, value: impl Into<Option<Vec<Facet<S>>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_steps_to_reproduce_facets(mut self, value: Option<Vec<Facet<S>>>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> BugBuilder<S, St>
where
St: bug_state::State,
St::Title: bug_state::IsUnset,
{
pub fn title(mut self, value: impl Into<S>) -> BugBuilder<S, bug_state::SetTitle<St>> {
self._fields.9 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BugBuilder<S, St>
where
St: bug_state::State,
St::Namespace: bug_state::IsSet,
St::Title: bug_state::IsSet,
St::Severity: bug_state::IsSet,
St::CreatedAt: bug_state::IsSet,
St::StepsToReproduce: bug_state::IsSet,
St::Description: bug_state::IsSet,
{
pub fn build(self) -> Bug<S> {
Bug {
app_used: self._fields.0,
attachments: self._fields.1,
created_at: self._fields.2.unwrap(),
description: self._fields.3.unwrap(),
description_facets: self._fields.4,
namespace: self._fields.5.unwrap(),
severity: self._fields.6.unwrap(),
steps_to_reproduce: self._fields.7.unwrap(),
steps_to_reproduce_facets: self._fields.8,
title: self._fields.9.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Bug<S> {
Bug {
app_used: self._fields.0,
attachments: self._fields.1,
created_at: self._fields.2.unwrap(),
description: self._fields.3.unwrap(),
description_facets: self._fields.4,
namespace: self._fields.5.unwrap(),
severity: self._fields.6.unwrap(),
steps_to_reproduce: self._fields.7.unwrap(),
steps_to_reproduce_facets: self._fields.8,
title: self._fields.9.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_network_slices_tools_bug() -> 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("network.slices.tools.bug"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(vec![
SmolStr::new_static("title"),
SmolStr::new_static("namespace"),
SmolStr::new_static("description"),
SmolStr::new_static("stepsToReproduce"),
SmolStr::new_static("severity"),
SmolStr::new_static("createdAt"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("appUsed"),
LexObjectProperty::String(LexString {
max_length: Some(300usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("attachments"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![CowStr::new_static(
"network.slices.tools.defs#images",
)],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
max_length: Some(10000usize),
max_graphemes: Some(3000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("descriptionFacets"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"Annotations of description (mentions and links)",
)),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static(
"network.slices.tools.richtext.facet",
),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("namespace"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Target namespace like 'social.grain' or 'app.bsky'",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("severity"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("stepsToReproduce"),
LexObjectProperty::String(LexString {
max_length: Some(5000usize),
max_graphemes: Some(1500usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("stepsToReproduceFacets"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"Annotations of steps to reproduce (mentions and links)",
)),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static(
"network.slices.tools.richtext.facet",
),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
max_length: Some(300usize),
max_graphemes: Some(100usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}