pub mod grant_verifications;
pub mod list_verifications;
pub mod revoke_verifications;
#[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, Handle, AtUri, 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::tools_ozone::moderation::RepoViewDetail;
use crate::tools_ozone::moderation::RepoViewNotFound;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct VerificationView<S: BosStr = DefaultStr> {
pub created_at: Datetime,
pub display_name: S,
pub handle: Handle<S>,
pub issuer: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub issuer_profile: Option<Data<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub issuer_repo: Option<VerificationViewIssuerRepo<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub revoke_reason: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub revoked_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub revoked_by: Option<Did<S>>,
pub subject: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub subject_profile: Option<Data<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub subject_repo: Option<VerificationViewSubjectRepo<S>>,
pub uri: AtUri<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 VerificationViewIssuerRepo<S: BosStr = DefaultStr> {
#[serde(rename = "tools.ozone.moderation.defs#repoViewDetail")]
RepoViewDetail(Box<RepoViewDetail<S>>),
#[serde(rename = "tools.ozone.moderation.defs#repoViewNotFound")]
RepoViewNotFound(Box<RepoViewNotFound<S>>),
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum VerificationViewSubjectRepo<S: BosStr = DefaultStr> {
#[serde(rename = "tools.ozone.moderation.defs#repoViewDetail")]
RepoViewDetail(Box<RepoViewDetail<S>>),
#[serde(rename = "tools.ozone.moderation.defs#repoViewNotFound")]
RepoViewNotFound(Box<RepoViewNotFound<S>>),
}
impl<S: BosStr> LexiconSchema for VerificationView<S> {
fn nsid() -> &'static str {
"tools.ozone.verification.defs"
}
fn def_name() -> &'static str {
"verificationView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_tools_ozone_verification_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod verification_view_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 Uri;
type Subject;
type Handle;
type Issuer;
type DisplayName;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
type Subject = Unset;
type Handle = Unset;
type Issuer = Unset;
type DisplayName = Unset;
type CreatedAt = 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 Subject = St::Subject;
type Handle = St::Handle;
type Issuer = St::Issuer;
type DisplayName = St::DisplayName;
type CreatedAt = St::CreatedAt;
}
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 Uri = St::Uri;
type Subject = Set<members::subject>;
type Handle = St::Handle;
type Issuer = St::Issuer;
type DisplayName = St::DisplayName;
type CreatedAt = St::CreatedAt;
}
pub struct SetHandle<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetHandle<St> {}
impl<St: State> State for SetHandle<St> {
type Uri = St::Uri;
type Subject = St::Subject;
type Handle = Set<members::handle>;
type Issuer = St::Issuer;
type DisplayName = St::DisplayName;
type CreatedAt = St::CreatedAt;
}
pub struct SetIssuer<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetIssuer<St> {}
impl<St: State> State for SetIssuer<St> {
type Uri = St::Uri;
type Subject = St::Subject;
type Handle = St::Handle;
type Issuer = Set<members::issuer>;
type DisplayName = St::DisplayName;
type CreatedAt = St::CreatedAt;
}
pub struct SetDisplayName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDisplayName<St> {}
impl<St: State> State for SetDisplayName<St> {
type Uri = St::Uri;
type Subject = St::Subject;
type Handle = St::Handle;
type Issuer = St::Issuer;
type DisplayName = Set<members::display_name>;
type CreatedAt = St::CreatedAt;
}
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 Uri = St::Uri;
type Subject = St::Subject;
type Handle = St::Handle;
type Issuer = St::Issuer;
type DisplayName = St::DisplayName;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
pub struct subject(());
pub struct handle(());
pub struct issuer(());
pub struct display_name(());
pub struct created_at(());
}
}
pub struct VerificationViewBuilder<S: BosStr, St: verification_view_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Datetime>,
Option<S>,
Option<Handle<S>>,
Option<Did<S>>,
Option<Data<S>>,
Option<VerificationViewIssuerRepo<S>>,
Option<S>,
Option<Datetime>,
Option<Did<S>>,
Option<Did<S>>,
Option<Data<S>>,
Option<VerificationViewSubjectRepo<S>>,
Option<AtUri<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> VerificationView<S> {
pub fn new() -> VerificationViewBuilder<S, verification_view_state::Empty> {
VerificationViewBuilder::new()
}
}
impl<S: BosStr> VerificationViewBuilder<S, verification_view_state::Empty> {
pub fn new() -> Self {
VerificationViewBuilder {
_state: PhantomData,
_fields: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> VerificationViewBuilder<S, St>
where
St: verification_view_state::State,
St::CreatedAt: verification_view_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> VerificationViewBuilder<S, verification_view_state::SetCreatedAt<St>> {
self._fields.0 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> VerificationViewBuilder<S, St>
where
St: verification_view_state::State,
St::DisplayName: verification_view_state::IsUnset,
{
pub fn display_name(
mut self,
value: impl Into<S>,
) -> VerificationViewBuilder<S, verification_view_state::SetDisplayName<St>> {
self._fields.1 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> VerificationViewBuilder<S, St>
where
St: verification_view_state::State,
St::Handle: verification_view_state::IsUnset,
{
pub fn handle(
mut self,
value: impl Into<Handle<S>>,
) -> VerificationViewBuilder<S, verification_view_state::SetHandle<St>> {
self._fields.2 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> VerificationViewBuilder<S, St>
where
St: verification_view_state::State,
St::Issuer: verification_view_state::IsUnset,
{
pub fn issuer(
mut self,
value: impl Into<Did<S>>,
) -> VerificationViewBuilder<S, verification_view_state::SetIssuer<St>> {
self._fields.3 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: verification_view_state::State> VerificationViewBuilder<S, St> {
pub fn issuer_profile(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_issuer_profile(mut self, value: Option<Data<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St: verification_view_state::State> VerificationViewBuilder<S, St> {
pub fn issuer_repo(
mut self,
value: impl Into<Option<VerificationViewIssuerRepo<S>>>,
) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_issuer_repo(
mut self,
value: Option<VerificationViewIssuerRepo<S>>,
) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: verification_view_state::State> VerificationViewBuilder<S, St> {
pub fn revoke_reason(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_revoke_reason(mut self, value: Option<S>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St: verification_view_state::State> VerificationViewBuilder<S, St> {
pub fn revoked_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_revoked_at(mut self, value: Option<Datetime>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St: verification_view_state::State> VerificationViewBuilder<S, St> {
pub fn revoked_by(mut self, value: impl Into<Option<Did<S>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_revoked_by(mut self, value: Option<Did<S>>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> VerificationViewBuilder<S, St>
where
St: verification_view_state::State,
St::Subject: verification_view_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<Did<S>>,
) -> VerificationViewBuilder<S, verification_view_state::SetSubject<St>> {
self._fields.9 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: verification_view_state::State> VerificationViewBuilder<S, St> {
pub fn subject_profile(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_subject_profile(mut self, value: Option<Data<S>>) -> Self {
self._fields.10 = value;
self
}
}
impl<S: BosStr, St: verification_view_state::State> VerificationViewBuilder<S, St> {
pub fn subject_repo(
mut self,
value: impl Into<Option<VerificationViewSubjectRepo<S>>>,
) -> Self {
self._fields.11 = value.into();
self
}
pub fn maybe_subject_repo(
mut self,
value: Option<VerificationViewSubjectRepo<S>>,
) -> Self {
self._fields.11 = value;
self
}
}
impl<S: BosStr, St> VerificationViewBuilder<S, St>
where
St: verification_view_state::State,
St::Uri: verification_view_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> VerificationViewBuilder<S, verification_view_state::SetUri<St>> {
self._fields.12 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> VerificationViewBuilder<S, St>
where
St: verification_view_state::State,
St::Uri: verification_view_state::IsSet,
St::Subject: verification_view_state::IsSet,
St::Handle: verification_view_state::IsSet,
St::Issuer: verification_view_state::IsSet,
St::DisplayName: verification_view_state::IsSet,
St::CreatedAt: verification_view_state::IsSet,
{
pub fn build(self) -> VerificationView<S> {
VerificationView {
created_at: self._fields.0.unwrap(),
display_name: self._fields.1.unwrap(),
handle: self._fields.2.unwrap(),
issuer: self._fields.3.unwrap(),
issuer_profile: self._fields.4,
issuer_repo: self._fields.5,
revoke_reason: self._fields.6,
revoked_at: self._fields.7,
revoked_by: self._fields.8,
subject: self._fields.9.unwrap(),
subject_profile: self._fields.10,
subject_repo: self._fields.11,
uri: self._fields.12.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> VerificationView<S> {
VerificationView {
created_at: self._fields.0.unwrap(),
display_name: self._fields.1.unwrap(),
handle: self._fields.2.unwrap(),
issuer: self._fields.3.unwrap(),
issuer_profile: self._fields.4,
issuer_repo: self._fields.5,
revoke_reason: self._fields.6,
revoked_at: self._fields.7,
revoked_by: self._fields.8,
subject: self._fields.9.unwrap(),
subject_profile: self._fields.10,
subject_repo: self._fields.11,
uri: self._fields.12.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_tools_ozone_verification_defs() -> 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("tools.ozone.verification.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("verificationView"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Verification data for the associated subject.",
),
),
required: Some(
vec![
SmolStr::new_static("issuer"), SmolStr::new_static("uri"),
SmolStr::new_static("subject"),
SmolStr::new_static("handle"),
SmolStr::new_static("displayName"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Timestamp when the verification was created.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("displayName"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Display name of the subject the verification applies to at the moment of verifying, which might not be the same at the time of viewing. The verification is only valid if the current displayName matches the one at the time of verifying.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("handle"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Handle of the subject the verification applies to at the moment of verifying, which might not be the same at the time of viewing. The verification is only valid if the current handle matches the one at the time of verifying.",
),
),
format: Some(LexStringFormat::Handle),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("issuer"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The user who issued this verification."),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("issuerProfile"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("issuerRepo"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("tools.ozone.moderation.defs#repoViewDetail"),
CowStr::new_static("tools.ozone.moderation.defs#repoViewNotFound")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("revokeReason"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Describes the reason for revocation, also indicating that the verification is no longer valid.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("revokedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Timestamp when the verification was revoked.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("revokedBy"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The user who revoked this verification.",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The subject of the verification."),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subjectProfile"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subjectRepo"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("tools.ozone.moderation.defs#repoViewDetail"),
CowStr::new_static("tools.ozone.moderation.defs#repoViewNotFound")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The AT-URI of the verification record."),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}