#[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::org_user_intents::demo::declaration;
#[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",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Intent<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub allow: Option<bool>,
pub updated_at: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "org.user-intents.demo.declaration",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Declaration<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub bulk_dataset: Option<declaration::Intent<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub protocol_bridging: Option<declaration::Intent<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub public_access_archive: Option<declaration::Intent<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub synthetic_content_generation: Option<declaration::Intent<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<Datetime>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct DeclarationGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Declaration<S>,
}
impl<S: BosStr> Declaration<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, DeclarationRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for Intent<S> {
fn nsid() -> &'static str {
"org.user-intents.demo.declaration"
}
fn def_name() -> &'static str {
"intent"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_user_intents_demo_declaration()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct DeclarationRecord;
impl XrpcResp for DeclarationRecord {
const NSID: &'static str = "org.user-intents.demo.declaration";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = DeclarationGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<DeclarationGetRecordOutput<S>> for Declaration<S> {
fn from(output: DeclarationGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Declaration<S> {
const NSID: &'static str = "org.user-intents.demo.declaration";
type Record = DeclarationRecord;
}
impl Collection for DeclarationRecord {
const NSID: &'static str = "org.user-intents.demo.declaration";
type Record = DeclarationRecord;
}
impl<S: BosStr> LexiconSchema for Declaration<S> {
fn nsid() -> &'static str {
"org.user-intents.demo.declaration"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_user_intents_demo_declaration()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod intent_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 UpdatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type UpdatedAt = Unset;
}
pub struct SetUpdatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUpdatedAt<St> {}
impl<St: State> State for SetUpdatedAt<St> {
type UpdatedAt = Set<members::updated_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct updated_at(());
}
}
pub struct IntentBuilder<S: BosStr, St: intent_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<bool>, Option<Datetime>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Intent<S> {
pub fn new() -> IntentBuilder<S, intent_state::Empty> {
IntentBuilder::new()
}
}
impl<S: BosStr> IntentBuilder<S, intent_state::Empty> {
pub fn new() -> Self {
IntentBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: intent_state::State> IntentBuilder<S, St> {
pub fn allow(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_allow(mut self, value: Option<bool>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> IntentBuilder<S, St>
where
St: intent_state::State,
St::UpdatedAt: intent_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> IntentBuilder<S, intent_state::SetUpdatedAt<St>> {
self._fields.1 = Option::Some(value.into());
IntentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IntentBuilder<S, St>
where
St: intent_state::State,
St::UpdatedAt: intent_state::IsSet,
{
pub fn build(self) -> Intent<S> {
Intent {
allow: self._fields.0,
updated_at: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Intent<S> {
Intent {
allow: self._fields.0,
updated_at: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_org_user_intents_demo_declaration() -> 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("org.user-intents.demo.declaration"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("intent"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("updatedAt")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("allow"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("")),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(CowStr::new_static("TODO")),
key: Some(CowStr::new_static("literal:self")),
record: LexRecordRecord::Object(LexObject {
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("bulkDataset"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#intent"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("protocolBridging"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#intent"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("publicAccessArchive"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#intent"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("syntheticContentGeneration"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#intent"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("")),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod declaration_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 {}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {}
#[allow(non_camel_case_types)]
pub mod members {}
}
pub struct DeclarationBuilder<S: BosStr, St: declaration_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<declaration::Intent<S>>,
Option<declaration::Intent<S>>,
Option<declaration::Intent<S>>,
Option<declaration::Intent<S>>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Declaration<S> {
pub fn new() -> DeclarationBuilder<S, declaration_state::Empty> {
DeclarationBuilder::new()
}
}
impl<S: BosStr> DeclarationBuilder<S, declaration_state::Empty> {
pub fn new() -> Self {
DeclarationBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: declaration_state::State> DeclarationBuilder<S, St> {
pub fn bulk_dataset(mut self, value: impl Into<Option<declaration::Intent<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_bulk_dataset(mut self, value: Option<declaration::Intent<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: declaration_state::State> DeclarationBuilder<S, St> {
pub fn protocol_bridging(mut self, value: impl Into<Option<declaration::Intent<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_protocol_bridging(mut self, value: Option<declaration::Intent<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: declaration_state::State> DeclarationBuilder<S, St> {
pub fn public_access_archive(
mut self,
value: impl Into<Option<declaration::Intent<S>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_public_access_archive(mut self, value: Option<declaration::Intent<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: declaration_state::State> DeclarationBuilder<S, St> {
pub fn synthetic_content_generation(
mut self,
value: impl Into<Option<declaration::Intent<S>>>,
) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_synthetic_content_generation(
mut self,
value: Option<declaration::Intent<S>>,
) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St: declaration_state::State> DeclarationBuilder<S, St> {
pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> DeclarationBuilder<S, St>
where
St: declaration_state::State,
{
pub fn build(self) -> Declaration<S> {
Declaration {
bulk_dataset: self._fields.0,
protocol_bridging: self._fields.1,
public_access_archive: self._fields.2,
synthetic_content_generation: self._fields.3,
updated_at: self._fields.4,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Declaration<S> {
Declaration {
bulk_dataset: self._fields.0,
protocol_bridging: self._fields.1,
public_access_archive: self._fields.2,
synthetic_content_generation: self._fields.3,
updated_at: self._fields.4,
extra_data: Some(extra_data),
}
}
}