#[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::{Did, AtUri, Nsid, 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, 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::at_inlay::ViaValtown;
use crate::at_inlay::component;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct BodyExternal<'a> {
#[serde(borrow)]
pub did: Did<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct BodyTemplate<'a> {
#[serde(borrow)]
pub node: Data<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Component<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub body: Option<ComponentBody<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub imports: Option<Vec<AtUri<'a>>>,
#[serde(borrow)]
pub r#type: Nsid<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub via: Option<ViaValtown<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub view: Option<component::View<'a>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum ComponentBody<'a> {
#[serde(rename = "at.inlay.component#bodyExternal")]
BodyExternal(Box<component::BodyExternal<'a>>),
#[serde(rename = "at.inlay.component#bodyTemplate")]
BodyTemplate(Box<component::BodyTemplate<'a>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ComponentGetRecordOutput<'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: Component<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct View<'a> {
#[serde(borrow)]
pub accepts: Vec<ViewAcceptsItem<'a>>,
#[serde(borrow)]
pub prop: CowStr<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum ViewAcceptsItem<'a> {
#[serde(rename = "at.inlay.component#viewRecord")]
ViewRecord(Box<component::ViewRecord<'a>>),
#[serde(rename = "at.inlay.component#viewPrimitive")]
ViewPrimitive(Box<component::ViewPrimitive<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ViewPrimitive<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub format: Option<ViewPrimitiveFormat<'a>>,
#[serde(borrow)]
pub r#type: ViewPrimitiveType<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ViewPrimitiveFormat<'a> {
AtUri,
Did,
Datetime,
Uri,
Handle,
AtIdentifier,
Nsid,
Cid,
Language,
RecordKey,
Tid,
Other(CowStr<'a>),
}
impl<'a> ViewPrimitiveFormat<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::AtUri => "at-uri",
Self::Did => "did",
Self::Datetime => "datetime",
Self::Uri => "uri",
Self::Handle => "handle",
Self::AtIdentifier => "at-identifier",
Self::Nsid => "nsid",
Self::Cid => "cid",
Self::Language => "language",
Self::RecordKey => "record-key",
Self::Tid => "tid",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for ViewPrimitiveFormat<'a> {
fn from(s: &'a str) -> Self {
match s {
"at-uri" => Self::AtUri,
"did" => Self::Did,
"datetime" => Self::Datetime,
"uri" => Self::Uri,
"handle" => Self::Handle,
"at-identifier" => Self::AtIdentifier,
"nsid" => Self::Nsid,
"cid" => Self::Cid,
"language" => Self::Language,
"record-key" => Self::RecordKey,
"tid" => Self::Tid,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for ViewPrimitiveFormat<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"at-uri" => Self::AtUri,
"did" => Self::Did,
"datetime" => Self::Datetime,
"uri" => Self::Uri,
"handle" => Self::Handle,
"at-identifier" => Self::AtIdentifier,
"nsid" => Self::Nsid,
"cid" => Self::Cid,
"language" => Self::Language,
"record-key" => Self::RecordKey,
"tid" => Self::Tid,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for ViewPrimitiveFormat<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for ViewPrimitiveFormat<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for ViewPrimitiveFormat<'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 ViewPrimitiveFormat<'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 ViewPrimitiveFormat<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for ViewPrimitiveFormat<'_> {
type Output = ViewPrimitiveFormat<'static>;
fn into_static(self) -> Self::Output {
match self {
ViewPrimitiveFormat::AtUri => ViewPrimitiveFormat::AtUri,
ViewPrimitiveFormat::Did => ViewPrimitiveFormat::Did,
ViewPrimitiveFormat::Datetime => ViewPrimitiveFormat::Datetime,
ViewPrimitiveFormat::Uri => ViewPrimitiveFormat::Uri,
ViewPrimitiveFormat::Handle => ViewPrimitiveFormat::Handle,
ViewPrimitiveFormat::AtIdentifier => ViewPrimitiveFormat::AtIdentifier,
ViewPrimitiveFormat::Nsid => ViewPrimitiveFormat::Nsid,
ViewPrimitiveFormat::Cid => ViewPrimitiveFormat::Cid,
ViewPrimitiveFormat::Language => ViewPrimitiveFormat::Language,
ViewPrimitiveFormat::RecordKey => ViewPrimitiveFormat::RecordKey,
ViewPrimitiveFormat::Tid => ViewPrimitiveFormat::Tid,
ViewPrimitiveFormat::Other(v) => ViewPrimitiveFormat::Other(v.into_static()),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ViewPrimitiveType<'a> {
String,
Integer,
Boolean,
Blob,
CidLink,
Bytes,
Other(CowStr<'a>),
}
impl<'a> ViewPrimitiveType<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::String => "string",
Self::Integer => "integer",
Self::Boolean => "boolean",
Self::Blob => "blob",
Self::CidLink => "cid-link",
Self::Bytes => "bytes",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for ViewPrimitiveType<'a> {
fn from(s: &'a str) -> Self {
match s {
"string" => Self::String,
"integer" => Self::Integer,
"boolean" => Self::Boolean,
"blob" => Self::Blob,
"cid-link" => Self::CidLink,
"bytes" => Self::Bytes,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for ViewPrimitiveType<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"string" => Self::String,
"integer" => Self::Integer,
"boolean" => Self::Boolean,
"blob" => Self::Blob,
"cid-link" => Self::CidLink,
"bytes" => Self::Bytes,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for ViewPrimitiveType<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for ViewPrimitiveType<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for ViewPrimitiveType<'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 ViewPrimitiveType<'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 ViewPrimitiveType<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for ViewPrimitiveType<'_> {
type Output = ViewPrimitiveType<'static>;
fn into_static(self) -> Self::Output {
match self {
ViewPrimitiveType::String => ViewPrimitiveType::String,
ViewPrimitiveType::Integer => ViewPrimitiveType::Integer,
ViewPrimitiveType::Boolean => ViewPrimitiveType::Boolean,
ViewPrimitiveType::Blob => ViewPrimitiveType::Blob,
ViewPrimitiveType::CidLink => ViewPrimitiveType::CidLink,
ViewPrimitiveType::Bytes => ViewPrimitiveType::Bytes,
ViewPrimitiveType::Other(v) => ViewPrimitiveType::Other(v.into_static()),
}
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ViewRecord<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub collection: Option<Nsid<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub rkey: Option<CowStr<'a>>,
}
impl<'a> Component<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, ComponentRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
impl<'a> LexiconSchema for BodyExternal<'a> {
fn nsid() -> &'static str {
"at.inlay.component"
}
fn def_name() -> &'static str {
"bodyExternal"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_at_inlay_component()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for BodyTemplate<'a> {
fn nsid() -> &'static str {
"at.inlay.component"
}
fn def_name() -> &'static str {
"bodyTemplate"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_at_inlay_component()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ComponentRecord;
impl XrpcResp for ComponentRecord {
const NSID: &'static str = "at.inlay.component";
const ENCODING: &'static str = "application/json";
type Output<'de> = ComponentGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<ComponentGetRecordOutput<'_>> for Component<'_> {
fn from(output: ComponentGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Component<'_> {
const NSID: &'static str = "at.inlay.component";
type Record = ComponentRecord;
}
impl Collection for ComponentRecord {
const NSID: &'static str = "at.inlay.component";
type Record = ComponentRecord;
}
impl<'a> LexiconSchema for Component<'a> {
fn nsid() -> &'static str {
"at.inlay.component"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_at_inlay_component()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref 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()),
});
}
}
if let Some(ref value) = self.description {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 1000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("description"),
max: 1000usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<'a> LexiconSchema for View<'a> {
fn nsid() -> &'static str {
"at.inlay.component"
}
fn def_name() -> &'static str {
"view"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_at_inlay_component()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.accepts;
#[allow(unused_comparisons)]
if value.len() < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("accepts"),
min: 1usize,
actual: value.len(),
});
}
}
{
let value = &self.prop;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("prop"),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for ViewPrimitive<'a> {
fn nsid() -> &'static str {
"at.inlay.component"
}
fn def_name() -> &'static str {
"viewPrimitive"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_at_inlay_component()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.format {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("format"),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.r#type;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("type"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for ViewRecord<'a> {
fn nsid() -> &'static str {
"at.inlay.component"
}
fn def_name() -> &'static str {
"viewRecord"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_at_inlay_component()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.rkey {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 512usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("rkey"),
max: 512usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod body_external_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 Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Did = Unset;
}
pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDid<S> {}
impl<S: State> State for SetDid<S> {
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
}
}
pub struct BodyExternalBuilder<'a, S: body_external_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Did<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> BodyExternal<'a> {
pub fn new() -> BodyExternalBuilder<'a, body_external_state::Empty> {
BodyExternalBuilder::new()
}
}
impl<'a> BodyExternalBuilder<'a, body_external_state::Empty> {
pub fn new() -> Self {
BodyExternalBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> BodyExternalBuilder<'a, S>
where
S: body_external_state::State,
S::Did: body_external_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<'a>>,
) -> BodyExternalBuilder<'a, body_external_state::SetDid<S>> {
self._fields.0 = Option::Some(value.into());
BodyExternalBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BodyExternalBuilder<'a, S>
where
S: body_external_state::State,
S::Did: body_external_state::IsSet,
{
pub fn build(self) -> BodyExternal<'a> {
BodyExternal {
did: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> BodyExternal<'a> {
BodyExternal {
did: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_at_inlay_component() -> 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("at.inlay.component"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("bodyExternal"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Component rendered by calling a remote XRPC endpoint",
),
),
required: Some(vec![SmolStr::new_static("did")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"DID of the service hosting this component",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("bodyTemplate"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Component rendered by the host from a serialized element tree",
),
),
required: Some(vec![SmolStr::new_static("node")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("node"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"Component record - declares an implementation of a type",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(vec![SmolStr::new_static("type")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("body"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"How this component is rendered. Omit for primitives rendered by the host.",
),
),
refs: vec![
CowStr::new_static("#bodyExternal"),
CowStr::new_static("#bodyTemplate")
],
..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(1000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("imports"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Ordered list of pack URIs (import stack). First pack that exports an NSID wins.",
),
),
items: LexArrayItem::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("type"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"NSID this component implements (also the XRPC procedure)",
),
),
format: Some(LexStringFormat::Nsid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Last update timestamp. Set by the publish flow to bust cached responses.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("via"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static("Platform-managed deployment metadata"),
),
refs: vec![CowStr::new_static("at.inlay.defs#viaValtown")],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("view"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#view"),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("view"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Declares what data this component views and which prop receives it.",
),
),
required: Some(
vec![SmolStr::new_static("prop"), SmolStr::new_static("accepts")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("accepts"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("Data types this view accepts."),
),
items: LexArrayItem::Union(LexRefUnion {
refs: vec![
CowStr::new_static("#viewRecord"),
CowStr::new_static("#viewPrimitive")
],
..Default::default()
}),
min_length: Some(1usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("prop"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Which component prop receives the view data.",
),
),
max_length: Some(256usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("viewPrimitive"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("View accepts a primitive value type."),
),
required: Some(vec![SmolStr::new_static("type")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("format"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"String format constraint. Only applies when type is 'string'.",
),
),
max_length: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("type"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Lexicon primitive type."),
),
max_length: Some(128usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("viewRecord"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"View accepts individual records of a collection. Omit collection for a generic record view. When rkey is present, the component accepts bare DIDs (expanded to full AT URIs) and appears on identity pages.",
),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("collection"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The collection this component views. Omit for any-collection.",
),
),
format: Some(LexStringFormat::Nsid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rkey"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The record key, baked from the collection's lexicon at authoring time. Presence enables DID expansion and identity page routing.",
),
),
max_length: Some(512usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod body_template_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 Node;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Node = Unset;
}
pub struct SetNode<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetNode<S> {}
impl<S: State> State for SetNode<S> {
type Node = Set<members::node>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct node(());
}
}
pub struct BodyTemplateBuilder<'a, S: body_template_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Data<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> BodyTemplate<'a> {
pub fn new() -> BodyTemplateBuilder<'a, body_template_state::Empty> {
BodyTemplateBuilder::new()
}
}
impl<'a> BodyTemplateBuilder<'a, body_template_state::Empty> {
pub fn new() -> Self {
BodyTemplateBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> BodyTemplateBuilder<'a, S>
where
S: body_template_state::State,
S::Node: body_template_state::IsUnset,
{
pub fn node(
mut self,
value: impl Into<Data<'a>>,
) -> BodyTemplateBuilder<'a, body_template_state::SetNode<S>> {
self._fields.0 = Option::Some(value.into());
BodyTemplateBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BodyTemplateBuilder<'a, S>
where
S: body_template_state::State,
S::Node: body_template_state::IsSet,
{
pub fn build(self) -> BodyTemplate<'a> {
BodyTemplate {
node: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> BodyTemplate<'a> {
BodyTemplate {
node: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod component_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 Type;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Type = Unset;
}
pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetType<S> {}
impl<S: State> State for SetType<S> {
type Type = Set<members::r#type>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct r#type(());
}
}
pub struct ComponentBuilder<'a, S: component_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<ComponentBody<'a>>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<Vec<AtUri<'a>>>,
Option<Nsid<'a>>,
Option<Datetime>,
Option<ViaValtown<'a>>,
Option<component::View<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Component<'a> {
pub fn new() -> ComponentBuilder<'a, component_state::Empty> {
ComponentBuilder::new()
}
}
impl<'a> ComponentBuilder<'a, component_state::Empty> {
pub fn new() -> Self {
ComponentBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: component_state::State> ComponentBuilder<'a, S> {
pub fn body(mut self, value: impl Into<Option<ComponentBody<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_body(mut self, value: Option<ComponentBody<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: component_state::State> ComponentBuilder<'a, S> {
pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: component_state::State> ComponentBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S: component_state::State> ComponentBuilder<'a, S> {
pub fn imports(mut self, value: impl Into<Option<Vec<AtUri<'a>>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_imports(mut self, value: Option<Vec<AtUri<'a>>>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S> ComponentBuilder<'a, S>
where
S: component_state::State,
S::Type: component_state::IsUnset,
{
pub fn r#type(
mut self,
value: impl Into<Nsid<'a>>,
) -> ComponentBuilder<'a, component_state::SetType<S>> {
self._fields.4 = Option::Some(value.into());
ComponentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: component_state::State> ComponentBuilder<'a, S> {
pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S: component_state::State> ComponentBuilder<'a, S> {
pub fn via(mut self, value: impl Into<Option<ViaValtown<'a>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_via(mut self, value: Option<ViaValtown<'a>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S: component_state::State> ComponentBuilder<'a, S> {
pub fn view(mut self, value: impl Into<Option<component::View<'a>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_view(mut self, value: Option<component::View<'a>>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S> ComponentBuilder<'a, S>
where
S: component_state::State,
S::Type: component_state::IsSet,
{
pub fn build(self) -> Component<'a> {
Component {
body: self._fields.0,
created_at: self._fields.1,
description: self._fields.2,
imports: self._fields.3,
r#type: self._fields.4.unwrap(),
updated_at: self._fields.5,
via: self._fields.6,
view: self._fields.7,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> Component<'a> {
Component {
body: self._fields.0,
created_at: self._fields.1,
description: self._fields.2,
imports: self._fields.3,
r#type: self._fields.4.unwrap(),
updated_at: self._fields.5,
via: self._fields.6,
view: self._fields.7,
extra_data: Some(extra_data),
}
}
}
pub mod 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 Prop;
type Accepts;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Prop = Unset;
type Accepts = Unset;
}
pub struct SetProp<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetProp<S> {}
impl<S: State> State for SetProp<S> {
type Prop = Set<members::prop>;
type Accepts = S::Accepts;
}
pub struct SetAccepts<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAccepts<S> {}
impl<S: State> State for SetAccepts<S> {
type Prop = S::Prop;
type Accepts = Set<members::accepts>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct prop(());
pub struct accepts(());
}
}
pub struct ViewBuilder<'a, S: view_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Vec<ViewAcceptsItem<'a>>>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> View<'a> {
pub fn new() -> ViewBuilder<'a, view_state::Empty> {
ViewBuilder::new()
}
}
impl<'a> ViewBuilder<'a, view_state::Empty> {
pub fn new() -> Self {
ViewBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ViewBuilder<'a, S>
where
S: view_state::State,
S::Accepts: view_state::IsUnset,
{
pub fn accepts(
mut self,
value: impl Into<Vec<ViewAcceptsItem<'a>>>,
) -> ViewBuilder<'a, view_state::SetAccepts<S>> {
self._fields.0 = Option::Some(value.into());
ViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ViewBuilder<'a, S>
where
S: view_state::State,
S::Prop: view_state::IsUnset,
{
pub fn prop(
mut self,
value: impl Into<CowStr<'a>>,
) -> ViewBuilder<'a, view_state::SetProp<S>> {
self._fields.1 = Option::Some(value.into());
ViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ViewBuilder<'a, S>
where
S: view_state::State,
S::Prop: view_state::IsSet,
S::Accepts: view_state::IsSet,
{
pub fn build(self) -> View<'a> {
View {
accepts: self._fields.0.unwrap(),
prop: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> View<'a> {
View {
accepts: self._fields.0.unwrap(),
prop: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}