#[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::net_anisota::chronicle::log::weekly;
#[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 ChronicleSignature<S: BosStr = DefaultStr> {
pub alg: S,
pub kid: S,
pub nonce: S,
pub sig: S,
pub signed_at: Datetime,
pub version: i64,
#[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 = "net.anisota.chronicle.log.weekly",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Weekly<S: BosStr = DefaultStr> {
pub aggregates: weekly::WeeklyAggregates<S>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub expedition_refs: Option<Vec<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub finalized_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub lower_log_refs: Option<Vec<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub patterns: Option<weekly::WeeklyPatterns<S>>,
pub signature: weekly::ChronicleSignature<S>,
pub status: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub trends: Option<weekly::TrendData<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub upper_log_refs: Option<Vec<S>>,
pub week: S,
#[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 WeeklyGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Weekly<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct TrendData<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_change: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub engagement_change: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub xp_change: Option<S>,
#[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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct WeeklyAggregates<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub days_active: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub likes_received: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub posts_created: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub posts_read: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub quotes_received: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub replies_received: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reposts_received: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub specimens_photographed: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub total_xp_gained: Option<i64>,
#[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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct WeeklyPatterns<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub avg_blocks_per_day: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub peak_blocks: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub total_active_blocks: Option<i64>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Weekly<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, WeeklyRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for ChronicleSignature<S> {
fn nsid() -> &'static str {
"net.anisota.chronicle.log.weekly"
}
fn def_name() -> &'static str {
"chronicleSignature"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_chronicle_log_weekly()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct WeeklyRecord;
impl XrpcResp for WeeklyRecord {
const NSID: &'static str = "net.anisota.chronicle.log.weekly";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = WeeklyGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<WeeklyGetRecordOutput<S>> for Weekly<S> {
fn from(output: WeeklyGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Weekly<S> {
const NSID: &'static str = "net.anisota.chronicle.log.weekly";
type Record = WeeklyRecord;
}
impl Collection for WeeklyRecord {
const NSID: &'static str = "net.anisota.chronicle.log.weekly";
type Record = WeeklyRecord;
}
impl<S: BosStr> LexiconSchema for Weekly<S> {
fn nsid() -> &'static str {
"net.anisota.chronicle.log.weekly"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_chronicle_log_weekly()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for TrendData<S> {
fn nsid() -> &'static str {
"net.anisota.chronicle.log.weekly"
}
fn def_name() -> &'static str {
"trendData"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_chronicle_log_weekly()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for WeeklyAggregates<S> {
fn nsid() -> &'static str {
"net.anisota.chronicle.log.weekly"
}
fn def_name() -> &'static str {
"weeklyAggregates"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_chronicle_log_weekly()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.days_active {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("days_active"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.likes_received {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("likes_received"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.posts_created {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("posts_created"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.posts_read {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("posts_read"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.quotes_received {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("quotes_received"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.replies_received {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("replies_received"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.reposts_received {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("reposts_received"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.specimens_photographed {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("specimens_photographed"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.total_xp_gained {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("total_xp_gained"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for WeeklyPatterns<S> {
fn nsid() -> &'static str {
"net.anisota.chronicle.log.weekly"
}
fn def_name() -> &'static str {
"weeklyPatterns"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_chronicle_log_weekly()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.avg_blocks_per_day {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("avg_blocks_per_day"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.peak_blocks {
if *value > 48i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("peak_blocks"),
max: 48i64,
actual: *value,
});
}
}
if let Some(ref value) = self.peak_blocks {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("peak_blocks"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.total_active_blocks {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("total_active_blocks"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
pub mod chronicle_signature_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 Alg;
type Kid;
type Nonce;
type Sig;
type SignedAt;
type Version;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Alg = Unset;
type Kid = Unset;
type Nonce = Unset;
type Sig = Unset;
type SignedAt = Unset;
type Version = Unset;
}
pub struct SetAlg<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAlg<St> {}
impl<St: State> State for SetAlg<St> {
type Alg = Set<members::alg>;
type Kid = St::Kid;
type Nonce = St::Nonce;
type Sig = St::Sig;
type SignedAt = St::SignedAt;
type Version = St::Version;
}
pub struct SetKid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetKid<St> {}
impl<St: State> State for SetKid<St> {
type Alg = St::Alg;
type Kid = Set<members::kid>;
type Nonce = St::Nonce;
type Sig = St::Sig;
type SignedAt = St::SignedAt;
type Version = St::Version;
}
pub struct SetNonce<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetNonce<St> {}
impl<St: State> State for SetNonce<St> {
type Alg = St::Alg;
type Kid = St::Kid;
type Nonce = Set<members::nonce>;
type Sig = St::Sig;
type SignedAt = St::SignedAt;
type Version = St::Version;
}
pub struct SetSig<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSig<St> {}
impl<St: State> State for SetSig<St> {
type Alg = St::Alg;
type Kid = St::Kid;
type Nonce = St::Nonce;
type Sig = Set<members::sig>;
type SignedAt = St::SignedAt;
type Version = St::Version;
}
pub struct SetSignedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSignedAt<St> {}
impl<St: State> State for SetSignedAt<St> {
type Alg = St::Alg;
type Kid = St::Kid;
type Nonce = St::Nonce;
type Sig = St::Sig;
type SignedAt = Set<members::signed_at>;
type Version = St::Version;
}
pub struct SetVersion<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetVersion<St> {}
impl<St: State> State for SetVersion<St> {
type Alg = St::Alg;
type Kid = St::Kid;
type Nonce = St::Nonce;
type Sig = St::Sig;
type SignedAt = St::SignedAt;
type Version = Set<members::version>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct alg(());
pub struct kid(());
pub struct nonce(());
pub struct sig(());
pub struct signed_at(());
pub struct version(());
}
}
pub struct ChronicleSignatureBuilder<St: chronicle_signature_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<Datetime>,
Option<i64>,
),
_type: PhantomData<fn() -> S>,
}
impl ChronicleSignature<DefaultStr> {
pub fn new() -> ChronicleSignatureBuilder<chronicle_signature_state::Empty, DefaultStr> {
ChronicleSignatureBuilder::new()
}
}
impl<S: BosStr> ChronicleSignature<S> {
pub fn builder() -> ChronicleSignatureBuilder<chronicle_signature_state::Empty, S> {
ChronicleSignatureBuilder::builder()
}
}
impl ChronicleSignatureBuilder<chronicle_signature_state::Empty, DefaultStr> {
pub fn new() -> Self {
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> ChronicleSignatureBuilder<chronicle_signature_state::Empty, S> {
pub fn builder() -> Self {
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Alg: chronicle_signature_state::IsUnset,
{
pub fn alg(
mut self,
value: impl Into<S>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetAlg<St>, S> {
self._fields.0 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Kid: chronicle_signature_state::IsUnset,
{
pub fn kid(
mut self,
value: impl Into<S>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetKid<St>, S> {
self._fields.1 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Nonce: chronicle_signature_state::IsUnset,
{
pub fn nonce(
mut self,
value: impl Into<S>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetNonce<St>, S> {
self._fields.2 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Sig: chronicle_signature_state::IsUnset,
{
pub fn sig(
mut self,
value: impl Into<S>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetSig<St>, S> {
self._fields.3 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::SignedAt: chronicle_signature_state::IsUnset,
{
pub fn signed_at(
mut self,
value: impl Into<Datetime>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetSignedAt<St>, S> {
self._fields.4 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Version: chronicle_signature_state::IsUnset,
{
pub fn version(
mut self,
value: impl Into<i64>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetVersion<St>, S> {
self._fields.5 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Alg: chronicle_signature_state::IsSet,
St::Kid: chronicle_signature_state::IsSet,
St::Nonce: chronicle_signature_state::IsSet,
St::Sig: chronicle_signature_state::IsSet,
St::SignedAt: chronicle_signature_state::IsSet,
St::Version: chronicle_signature_state::IsSet,
{
pub fn build(self) -> ChronicleSignature<S> {
ChronicleSignature {
alg: self._fields.0.unwrap(),
kid: self._fields.1.unwrap(),
nonce: self._fields.2.unwrap(),
sig: self._fields.3.unwrap(),
signed_at: self._fields.4.unwrap(),
version: self._fields.5.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ChronicleSignature<S> {
ChronicleSignature {
alg: self._fields.0.unwrap(),
kid: self._fields.1.unwrap(),
nonce: self._fields.2.unwrap(),
sig: self._fields.3.unwrap(),
signed_at: self._fields.4.unwrap(),
version: self._fields.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_net_anisota_chronicle_log_weekly() -> 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("net.anisota.chronicle.log.weekly"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("chronicleSignature"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"ES256 cryptographic signature proving record authenticity",
)),
required: Some(vec![
SmolStr::new_static("sig"),
SmolStr::new_static("alg"),
SmolStr::new_static("kid"),
SmolStr::new_static("signedAt"),
SmolStr::new_static("nonce"),
SmolStr::new_static("version"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("alg"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Signing algorithm (ES256)")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("kid"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Key identifier for the signing key",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("nonce"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Unique random nonce to prevent replay",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sig"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Base64-encoded ES256 signature",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("signedAt"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("When the record was signed")),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("version"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"Weekly aggregation of daily records. rkey is YYYY-WNN (ISO week). Updated once per day, finalized when week ends.",
),
),
key: Some(CowStr::new_static("any")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("week"),
SmolStr::new_static("aggregates"),
SmolStr::new_static("status"),
SmolStr::new_static("signature"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("aggregates"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#weeklyAggregates"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"When the weekly record was first created",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("expeditionRefs"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"AT URIs of expedition records that occurred during this week",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("finalizedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"When the weekly record was finalized (end of week)",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lowerLogRefs"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"AT URIs of daily log records included in this week",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("patterns"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#weeklyPatterns"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("signature"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#chronicleSignature"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Whether this week is still being updated or has been finalized",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("trends"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#trendData"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("upperLogRefs"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"AT URIs of containing logs (monthly, yearly) this week belongs to",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("week"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"ISO week string in YYYY-WNN format (e.g. 2026-W06)",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("trendData"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Week-over-week trend comparisons"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("activityChange"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Percentage change in activity compared to previous week",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("engagementChange"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Percentage change in engagement compared to previous week",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("xpChange"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Percentage change in XP compared to previous week (e.g. '+12%')",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("weeklyAggregates"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Rolled-up counts from daily records")),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("daysActive"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("likesReceived"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("postsCreated"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("postsRead"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("quotesReceived"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("repliesReceived"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("repostsReceived"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("specimensPhotographed"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("totalXPGained"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("weeklyPatterns"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Activity pattern aggregation for the week based on half-hour blocks",
)),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("avgBlocksPerDay"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("peakBlocks"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
maximum: Some(48i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("totalActiveBlocks"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod weekly_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 Aggregates;
type CreatedAt;
type Signature;
type Status;
type Week;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Aggregates = Unset;
type CreatedAt = Unset;
type Signature = Unset;
type Status = Unset;
type Week = Unset;
}
pub struct SetAggregates<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAggregates<St> {}
impl<St: State> State for SetAggregates<St> {
type Aggregates = Set<members::aggregates>;
type CreatedAt = St::CreatedAt;
type Signature = St::Signature;
type Status = St::Status;
type Week = St::Week;
}
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 Aggregates = St::Aggregates;
type CreatedAt = Set<members::created_at>;
type Signature = St::Signature;
type Status = St::Status;
type Week = St::Week;
}
pub struct SetSignature<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSignature<St> {}
impl<St: State> State for SetSignature<St> {
type Aggregates = St::Aggregates;
type CreatedAt = St::CreatedAt;
type Signature = Set<members::signature>;
type Status = St::Status;
type Week = St::Week;
}
pub struct SetStatus<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStatus<St> {}
impl<St: State> State for SetStatus<St> {
type Aggregates = St::Aggregates;
type CreatedAt = St::CreatedAt;
type Signature = St::Signature;
type Status = Set<members::status>;
type Week = St::Week;
}
pub struct SetWeek<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetWeek<St> {}
impl<St: State> State for SetWeek<St> {
type Aggregates = St::Aggregates;
type CreatedAt = St::CreatedAt;
type Signature = St::Signature;
type Status = St::Status;
type Week = Set<members::week>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct aggregates(());
pub struct created_at(());
pub struct signature(());
pub struct status(());
pub struct week(());
}
}
pub struct WeeklyBuilder<St: weekly_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<weekly::WeeklyAggregates<S>>,
Option<Datetime>,
Option<Vec<S>>,
Option<Datetime>,
Option<Vec<S>>,
Option<weekly::WeeklyPatterns<S>>,
Option<weekly::ChronicleSignature<S>>,
Option<S>,
Option<weekly::TrendData<S>>,
Option<Vec<S>>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl Weekly<DefaultStr> {
pub fn new() -> WeeklyBuilder<weekly_state::Empty, DefaultStr> {
WeeklyBuilder::new()
}
}
impl<S: BosStr> Weekly<S> {
pub fn builder() -> WeeklyBuilder<weekly_state::Empty, S> {
WeeklyBuilder::builder()
}
}
impl WeeklyBuilder<weekly_state::Empty, DefaultStr> {
pub fn new() -> Self {
WeeklyBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr> WeeklyBuilder<weekly_state::Empty, S> {
pub fn builder() -> Self {
WeeklyBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> WeeklyBuilder<St, S>
where
St: weekly_state::State,
St::Aggregates: weekly_state::IsUnset,
{
pub fn aggregates(
mut self,
value: impl Into<weekly::WeeklyAggregates<S>>,
) -> WeeklyBuilder<weekly_state::SetAggregates<St>, S> {
self._fields.0 = Option::Some(value.into());
WeeklyBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> WeeklyBuilder<St, S>
where
St: weekly_state::State,
St::CreatedAt: weekly_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> WeeklyBuilder<weekly_state::SetCreatedAt<St>, S> {
self._fields.1 = Option::Some(value.into());
WeeklyBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: weekly_state::State, S: BosStr> WeeklyBuilder<St, S> {
pub fn expedition_refs(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_expedition_refs(mut self, value: Option<Vec<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<St: weekly_state::State, S: BosStr> WeeklyBuilder<St, S> {
pub fn finalized_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_finalized_at(mut self, value: Option<Datetime>) -> Self {
self._fields.3 = value;
self
}
}
impl<St: weekly_state::State, S: BosStr> WeeklyBuilder<St, S> {
pub fn lower_log_refs(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_lower_log_refs(mut self, value: Option<Vec<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<St: weekly_state::State, S: BosStr> WeeklyBuilder<St, S> {
pub fn patterns(mut self, value: impl Into<Option<weekly::WeeklyPatterns<S>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_patterns(mut self, value: Option<weekly::WeeklyPatterns<S>>) -> Self {
self._fields.5 = value;
self
}
}
impl<St, S: BosStr> WeeklyBuilder<St, S>
where
St: weekly_state::State,
St::Signature: weekly_state::IsUnset,
{
pub fn signature(
mut self,
value: impl Into<weekly::ChronicleSignature<S>>,
) -> WeeklyBuilder<weekly_state::SetSignature<St>, S> {
self._fields.6 = Option::Some(value.into());
WeeklyBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> WeeklyBuilder<St, S>
where
St: weekly_state::State,
St::Status: weekly_state::IsUnset,
{
pub fn status(mut self, value: impl Into<S>) -> WeeklyBuilder<weekly_state::SetStatus<St>, S> {
self._fields.7 = Option::Some(value.into());
WeeklyBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: weekly_state::State, S: BosStr> WeeklyBuilder<St, S> {
pub fn trends(mut self, value: impl Into<Option<weekly::TrendData<S>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_trends(mut self, value: Option<weekly::TrendData<S>>) -> Self {
self._fields.8 = value;
self
}
}
impl<St: weekly_state::State, S: BosStr> WeeklyBuilder<St, S> {
pub fn upper_log_refs(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_upper_log_refs(mut self, value: Option<Vec<S>>) -> Self {
self._fields.9 = value;
self
}
}
impl<St, S: BosStr> WeeklyBuilder<St, S>
where
St: weekly_state::State,
St::Week: weekly_state::IsUnset,
{
pub fn week(mut self, value: impl Into<S>) -> WeeklyBuilder<weekly_state::SetWeek<St>, S> {
self._fields.10 = Option::Some(value.into());
WeeklyBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> WeeklyBuilder<St, S>
where
St: weekly_state::State,
St::Aggregates: weekly_state::IsSet,
St::CreatedAt: weekly_state::IsSet,
St::Signature: weekly_state::IsSet,
St::Status: weekly_state::IsSet,
St::Week: weekly_state::IsSet,
{
pub fn build(self) -> Weekly<S> {
Weekly {
aggregates: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
expedition_refs: self._fields.2,
finalized_at: self._fields.3,
lower_log_refs: self._fields.4,
patterns: self._fields.5,
signature: self._fields.6.unwrap(),
status: self._fields.7.unwrap(),
trends: self._fields.8,
upper_log_refs: self._fields.9,
week: self._fields.10.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Weekly<S> {
Weekly {
aggregates: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
expedition_refs: self._fields.2,
finalized_at: self._fields.3,
lower_log_refs: self._fields.4,
patterns: self._fields.5,
signature: self._fields.6.unwrap(),
status: self._fields.7.unwrap(),
trends: self._fields.8,
upper_log_refs: self._fields.9,
week: self._fields.10.unwrap(),
extra_data: Some(extra_data),
}
}
}