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::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
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::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
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::network_slices::tools::Images;
use crate::network_slices::tools::richtext::facet::Facet;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Bug<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub app_used: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub attachments: Option<Images<'a>>,
pub created_at: Datetime,
#[serde(borrow)]
pub description: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description_facets: Option<Vec<Facet<'a>>>,
#[serde(borrow)]
pub namespace: CowStr<'a>,
#[serde(borrow)]
pub severity: BugSeverity<'a>,
#[serde(borrow)]
pub steps_to_reproduce: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub steps_to_reproduce_facets: Option<Vec<Facet<'a>>>,
#[serde(borrow)]
pub title: CowStr<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BugSeverity<'a> {
Cosmetic,
Annoying,
Broken,
Unusable,
Other(CowStr<'a>),
}
impl<'a> BugSeverity<'a> {
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(),
}
}
}
impl<'a> From<&'a str> for BugSeverity<'a> {
fn from(s: &'a str) -> Self {
match s {
"cosmetic" => Self::Cosmetic,
"annoying" => Self::Annoying,
"broken" => Self::Broken,
"unusable" => Self::Unusable,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for BugSeverity<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"cosmetic" => Self::Cosmetic,
"annoying" => Self::Annoying,
"broken" => Self::Broken,
"unusable" => Self::Unusable,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for BugSeverity<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for BugSeverity<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for BugSeverity<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for BugSeverity<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for BugSeverity<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for BugSeverity<'_> {
type Output = BugSeverity<'static>;
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<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Bug<'a>,
}
impl<'a> Bug<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, BugRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[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<'de> = BugGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<BugGetRecordOutput<'_>> for Bug<'_> {
fn from(output: BugGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Bug<'_> {
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<'a> LexiconSchema for Bug<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type StepsToReproduce;
type CreatedAt;
type Severity;
type Namespace;
type Title;
type Description;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type StepsToReproduce = Unset;
type CreatedAt = Unset;
type Severity = Unset;
type Namespace = Unset;
type Title = Unset;
type Description = Unset;
}
pub struct SetStepsToReproduce<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStepsToReproduce<S> {}
impl<S: State> State for SetStepsToReproduce<S> {
type StepsToReproduce = Set<members::steps_to_reproduce>;
type CreatedAt = S::CreatedAt;
type Severity = S::Severity;
type Namespace = S::Namespace;
type Title = S::Title;
type Description = S::Description;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type StepsToReproduce = S::StepsToReproduce;
type CreatedAt = Set<members::created_at>;
type Severity = S::Severity;
type Namespace = S::Namespace;
type Title = S::Title;
type Description = S::Description;
}
pub struct SetSeverity<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSeverity<S> {}
impl<S: State> State for SetSeverity<S> {
type StepsToReproduce = S::StepsToReproduce;
type CreatedAt = S::CreatedAt;
type Severity = Set<members::severity>;
type Namespace = S::Namespace;
type Title = S::Title;
type Description = S::Description;
}
pub struct SetNamespace<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetNamespace<S> {}
impl<S: State> State for SetNamespace<S> {
type StepsToReproduce = S::StepsToReproduce;
type CreatedAt = S::CreatedAt;
type Severity = S::Severity;
type Namespace = Set<members::namespace>;
type Title = S::Title;
type Description = S::Description;
}
pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTitle<S> {}
impl<S: State> State for SetTitle<S> {
type StepsToReproduce = S::StepsToReproduce;
type CreatedAt = S::CreatedAt;
type Severity = S::Severity;
type Namespace = S::Namespace;
type Title = Set<members::title>;
type Description = S::Description;
}
pub struct SetDescription<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDescription<S> {}
impl<S: State> State for SetDescription<S> {
type StepsToReproduce = S::StepsToReproduce;
type CreatedAt = S::CreatedAt;
type Severity = S::Severity;
type Namespace = S::Namespace;
type Title = S::Title;
type Description = Set<members::description>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct steps_to_reproduce(());
pub struct created_at(());
pub struct severity(());
pub struct namespace(());
pub struct title(());
pub struct description(());
}
}
pub struct BugBuilder<'a, S: bug_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<Images<'a>>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<Vec<Facet<'a>>>,
Option<CowStr<'a>>,
Option<BugSeverity<'a>>,
Option<CowStr<'a>>,
Option<Vec<Facet<'a>>>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Bug<'a> {
pub fn new() -> BugBuilder<'a, bug_state::Empty> {
BugBuilder::new()
}
}
impl<'a> BugBuilder<'a, bug_state::Empty> {
pub fn new() -> Self {
BugBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: bug_state::State> BugBuilder<'a, S> {
pub fn app_used(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_app_used(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: bug_state::State> BugBuilder<'a, S> {
pub fn attachments(mut self, value: impl Into<Option<Images<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_attachments(mut self, value: Option<Images<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> BugBuilder<'a, S>
where
S: bug_state::State,
S::CreatedAt: bug_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> BugBuilder<'a, bug_state::SetCreatedAt<S>> {
self._fields.2 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BugBuilder<'a, S>
where
S: bug_state::State,
S::Description: bug_state::IsUnset,
{
pub fn description(
mut self,
value: impl Into<CowStr<'a>>,
) -> BugBuilder<'a, bug_state::SetDescription<S>> {
self._fields.3 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: bug_state::State> BugBuilder<'a, S> {
pub fn description_facets(
mut self,
value: impl Into<Option<Vec<Facet<'a>>>>,
) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_description_facets(mut self, value: Option<Vec<Facet<'a>>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> BugBuilder<'a, S>
where
S: bug_state::State,
S::Namespace: bug_state::IsUnset,
{
pub fn namespace(
mut self,
value: impl Into<CowStr<'a>>,
) -> BugBuilder<'a, bug_state::SetNamespace<S>> {
self._fields.5 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BugBuilder<'a, S>
where
S: bug_state::State,
S::Severity: bug_state::IsUnset,
{
pub fn severity(
mut self,
value: impl Into<BugSeverity<'a>>,
) -> BugBuilder<'a, bug_state::SetSeverity<S>> {
self._fields.6 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BugBuilder<'a, S>
where
S: bug_state::State,
S::StepsToReproduce: bug_state::IsUnset,
{
pub fn steps_to_reproduce(
mut self,
value: impl Into<CowStr<'a>>,
) -> BugBuilder<'a, bug_state::SetStepsToReproduce<S>> {
self._fields.7 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: bug_state::State> BugBuilder<'a, S> {
pub fn steps_to_reproduce_facets(
mut self,
value: impl Into<Option<Vec<Facet<'a>>>>,
) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_steps_to_reproduce_facets(
mut self,
value: Option<Vec<Facet<'a>>>,
) -> Self {
self._fields.8 = value;
self
}
}
impl<'a, S> BugBuilder<'a, S>
where
S: bug_state::State,
S::Title: bug_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<CowStr<'a>>,
) -> BugBuilder<'a, bug_state::SetTitle<S>> {
self._fields.9 = Option::Some(value.into());
BugBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BugBuilder<'a, S>
where
S: bug_state::State,
S::StepsToReproduce: bug_state::IsSet,
S::CreatedAt: bug_state::IsSet,
S::Severity: bug_state::IsSet,
S::Namespace: bug_state::IsSet,
S::Title: bug_state::IsSet,
S::Description: bug_state::IsSet,
{
pub fn build(self) -> Bug<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Bug<'a> {
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> {
#[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("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()
}
}