#[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::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;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::net_anisota::beta::game::log;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CollectionData<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub catch_probability: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub inventory_record_uri: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub method: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub specimen_record_uri: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub success: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub time_since_generation: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub time_since_viewed: 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 DailyRewardsData<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub reward_items: Option<Vec<log::RewardItem<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub rewards_count: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub streak: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub time_since_last_claim: 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 FeedContext<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub feed_uri: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub game_card_count: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub post_count: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub scroll_position: 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 GameCardData<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub card_type: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub card_uri: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub generation_seed: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub injection_position: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub item_id: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub quantity: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub rarity: 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 ItemUsageData<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub effect_applied: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub inventory_record_uri: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub item_id: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub quantity_used: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub remaining_quantity: 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)]
#[serde(
rename_all = "camelCase",
rename = "net.anisota.beta.game.log",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Log<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub collection_data: Option<log::CollectionData<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub daily_rewards_data: Option<log::DailyRewardsData<S>>,
pub event_type: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub feed_context: Option<log::FeedContext<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub game_card_data: Option<log::GameCardData<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub game_card_id: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub item_usage_data: Option<log::ItemUsageData<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<log::Metadata<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_log_uri: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub root_log_uri: Option<S>,
pub session_id: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub session_uri: Option<S>,
pub timestamp: 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 LogGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Log<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Metadata<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub client_version: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub network_latency: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub performance_timings: Option<Data<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub platform: 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 RewardItem<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub item_id: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub quantity: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub rarity: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Log<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, LogRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for CollectionData<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.log"
}
fn def_name() -> &'static str {
"collectionData"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_log()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.time_since_generation {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("time_since_generation"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.time_since_viewed {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("time_since_viewed"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DailyRewardsData<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.log"
}
fn def_name() -> &'static str {
"dailyRewardsData"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_log()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.rewards_count {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("rewards_count"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.streak {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("streak"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.time_since_last_claim {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("time_since_last_claim"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for FeedContext<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.log"
}
fn def_name() -> &'static str {
"feedContext"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_log()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.game_card_count {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("game_card_count"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.post_count {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("post_count"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.scroll_position {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("scroll_position"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for GameCardData<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.log"
}
fn def_name() -> &'static str {
"gameCardData"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_log()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.injection_position {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("injection_position"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.quantity {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("quantity"),
min: 1i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for ItemUsageData<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.log"
}
fn def_name() -> &'static str {
"itemUsageData"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_log()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.quantity_used {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("quantity_used"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.remaining_quantity {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("remaining_quantity"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct LogRecord;
impl XrpcResp for LogRecord {
const NSID: &'static str = "net.anisota.beta.game.log";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = LogGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<LogGetRecordOutput<S>> for Log<S> {
fn from(output: LogGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Log<S> {
const NSID: &'static str = "net.anisota.beta.game.log";
type Record = LogRecord;
}
impl Collection for LogRecord {
const NSID: &'static str = "net.anisota.beta.game.log";
type Record = LogRecord;
}
impl<S: BosStr> LexiconSchema for Log<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.log"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_log()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.session_id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("session_id"),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Metadata<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.log"
}
fn def_name() -> &'static str {
"metadata"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_log()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.network_latency {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("network_latency"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for RewardItem<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.log"
}
fn def_name() -> &'static str {
"rewardItem"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_log()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.quantity {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("quantity"),
min: 1i64,
actual: *value,
});
}
}
Ok(())
}
}
fn lexicon_doc_net_anisota_beta_game_log() -> 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("net.anisota.beta.game.log"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("collectionData"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Details about item/specimen collection"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("catchProbability"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Catch probability for specimens (decimal string between 0.0 and 1.0)",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("inventoryRecordUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("URI of the created inventory record"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("method"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("How the item was obtained"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("specimenRecordUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("URI of the created specimen record"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("success"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("timeSinceGeneration"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("timeSinceViewed"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("dailyRewardsData"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Details about daily rewards claim"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("rewardItems"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#rewardItem"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rewardsCount"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("streak"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("timeSinceLastClaim"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("feedContext"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Context about the feed when event occurred"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("feedUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("URI of the feed being viewed"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("gameCardCount"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("postCount"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("scrollPosition"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("gameCardData"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Details about game cards generated or interacted with",
),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cardType"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Type of game card")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cardUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Unique identifier for the game card"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("generationSeed"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Random seed used for generation (for verification)",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("injectionPosition"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("itemId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("ID of the item/specimen"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("quantity"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rarity"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Rarity of the item/specimen"),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("itemUsageData"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Details about item usage")),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("effectApplied"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Effect that was applied"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("inventoryRecordUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("URI of the modified inventory record"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("itemId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("ID of the item used"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("quantityUsed"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("remainingQuantity"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A log record for tracking game events and user actions for provenance and anti-bot analysis",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("eventType"),
SmolStr::new_static("timestamp"),
SmolStr::new_static("sessionId")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("collectionData"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#collectionData"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the log record was created"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("dailyRewardsData"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#dailyRewardsData"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("eventType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Type of event being logged"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("feedContext"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#feedContext"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("gameCardData"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#gameCardData"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("gameCardId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Unique ID of the game card this event relates to",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("itemUsageData"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#itemUsageData"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("metadata"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#metadata"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("parentLogUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"URI of the parent log record that triggered this event",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rootLogUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"URI of the root log record in this event chain",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sessionId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Unique session identifier to group related events",
),
),
max_length: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sessionUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"URI of the session record this event belongs to (at://did/collection/rkey)",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("timestamp"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the event occurred (ISO 8601)"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("metadata"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Additional event-specific metadata"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("clientVersion"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Version of the client application"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("networkLatency"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("performanceTimings"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("platform"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Platform (web, mobile, etc.)"),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rewardItem"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Item received as a reward")),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("itemId"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("quantity"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rarity"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod log_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 SessionId;
type Timestamp;
type EventType;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type SessionId = Unset;
type Timestamp = Unset;
type EventType = Unset;
}
pub struct SetSessionId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSessionId<St> {}
impl<St: State> State for SetSessionId<St> {
type SessionId = Set<members::session_id>;
type Timestamp = St::Timestamp;
type EventType = St::EventType;
}
pub struct SetTimestamp<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTimestamp<St> {}
impl<St: State> State for SetTimestamp<St> {
type SessionId = St::SessionId;
type Timestamp = Set<members::timestamp>;
type EventType = St::EventType;
}
pub struct SetEventType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetEventType<St> {}
impl<St: State> State for SetEventType<St> {
type SessionId = St::SessionId;
type Timestamp = St::Timestamp;
type EventType = Set<members::event_type>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct session_id(());
pub struct timestamp(());
pub struct event_type(());
}
}
pub struct LogBuilder<S: BosStr, St: log_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<log::CollectionData<S>>,
Option<Datetime>,
Option<log::DailyRewardsData<S>>,
Option<S>,
Option<log::FeedContext<S>>,
Option<log::GameCardData<S>>,
Option<S>,
Option<log::ItemUsageData<S>>,
Option<log::Metadata<S>>,
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Log<S> {
pub fn new() -> LogBuilder<S, log_state::Empty> {
LogBuilder::new()
}
}
impl<S: BosStr> LogBuilder<S, log_state::Empty> {
pub fn new() -> Self {
LogBuilder {
_state: PhantomData,
_fields: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: log_state::State> LogBuilder<S, St> {
pub fn collection_data(
mut self,
value: impl Into<Option<log::CollectionData<S>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_collection_data(
mut self,
value: Option<log::CollectionData<S>>,
) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: log_state::State> LogBuilder<S, St> {
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<S: BosStr, St: log_state::State> LogBuilder<S, St> {
pub fn daily_rewards_data(
mut self,
value: impl Into<Option<log::DailyRewardsData<S>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_daily_rewards_data(
mut self,
value: Option<log::DailyRewardsData<S>>,
) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> LogBuilder<S, St>
where
St: log_state::State,
St::EventType: log_state::IsUnset,
{
pub fn event_type(
mut self,
value: impl Into<S>,
) -> LogBuilder<S, log_state::SetEventType<St>> {
self._fields.3 = Option::Some(value.into());
LogBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: log_state::State> LogBuilder<S, St> {
pub fn feed_context(
mut self,
value: impl Into<Option<log::FeedContext<S>>>,
) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_feed_context(mut self, value: Option<log::FeedContext<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St: log_state::State> LogBuilder<S, St> {
pub fn game_card_data(
mut self,
value: impl Into<Option<log::GameCardData<S>>>,
) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_game_card_data(mut self, value: Option<log::GameCardData<S>>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: log_state::State> LogBuilder<S, St> {
pub fn game_card_id(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_game_card_id(mut self, value: Option<S>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St: log_state::State> LogBuilder<S, St> {
pub fn item_usage_data(
mut self,
value: impl Into<Option<log::ItemUsageData<S>>>,
) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_item_usage_data(
mut self,
value: Option<log::ItemUsageData<S>>,
) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St: log_state::State> LogBuilder<S, St> {
pub fn metadata(mut self, value: impl Into<Option<log::Metadata<S>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_metadata(mut self, value: Option<log::Metadata<S>>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St: log_state::State> LogBuilder<S, St> {
pub fn parent_log_uri(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_parent_log_uri(mut self, value: Option<S>) -> Self {
self._fields.9 = value;
self
}
}
impl<S: BosStr, St: log_state::State> LogBuilder<S, St> {
pub fn root_log_uri(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_root_log_uri(mut self, value: Option<S>) -> Self {
self._fields.10 = value;
self
}
}
impl<S: BosStr, St> LogBuilder<S, St>
where
St: log_state::State,
St::SessionId: log_state::IsUnset,
{
pub fn session_id(
mut self,
value: impl Into<S>,
) -> LogBuilder<S, log_state::SetSessionId<St>> {
self._fields.11 = Option::Some(value.into());
LogBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: log_state::State> LogBuilder<S, St> {
pub fn session_uri(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.12 = value.into();
self
}
pub fn maybe_session_uri(mut self, value: Option<S>) -> Self {
self._fields.12 = value;
self
}
}
impl<S: BosStr, St> LogBuilder<S, St>
where
St: log_state::State,
St::Timestamp: log_state::IsUnset,
{
pub fn timestamp(
mut self,
value: impl Into<Datetime>,
) -> LogBuilder<S, log_state::SetTimestamp<St>> {
self._fields.13 = Option::Some(value.into());
LogBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LogBuilder<S, St>
where
St: log_state::State,
St::SessionId: log_state::IsSet,
St::Timestamp: log_state::IsSet,
St::EventType: log_state::IsSet,
{
pub fn build(self) -> Log<S> {
Log {
collection_data: self._fields.0,
created_at: self._fields.1,
daily_rewards_data: self._fields.2,
event_type: self._fields.3.unwrap(),
feed_context: self._fields.4,
game_card_data: self._fields.5,
game_card_id: self._fields.6,
item_usage_data: self._fields.7,
metadata: self._fields.8,
parent_log_uri: self._fields.9,
root_log_uri: self._fields.10,
session_id: self._fields.11.unwrap(),
session_uri: self._fields.12,
timestamp: self._fields.13.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Log<S> {
Log {
collection_data: self._fields.0,
created_at: self._fields.1,
daily_rewards_data: self._fields.2,
event_type: self._fields.3.unwrap(),
feed_context: self._fields.4,
game_card_data: self._fields.5,
game_card_id: self._fields.6,
item_usage_data: self._fields.7,
metadata: self._fields.8,
parent_log_uri: self._fields.9,
root_log_uri: self._fields.10,
session_id: self._fields.11.unwrap(),
session_uri: self._fields.12,
timestamp: self._fields.13.unwrap(),
extra_data: Some(extra_data),
}
}
}