#[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::{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;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct CollectionData<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub catch_probability: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub inventory_record_uri: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub method: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub specimen_record_uri: Option<CowStr<'a>>,
#[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>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct DailyRewardsData<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub reward_items: Option<Vec<log::RewardItem<'a>>>,
#[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>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct FeedContext<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub feed_uri: Option<CowStr<'a>>,
#[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>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct GameCardData<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub card_type: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub card_uri: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub generation_seed: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub injection_position: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub item_id: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub quantity: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub rarity: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ItemUsageData<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub effect_applied: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub inventory_record_uri: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub item_id: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub quantity_used: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub remaining_quantity: Option<i64>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Log<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub collection_data: Option<log::CollectionData<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub daily_rewards_data: Option<log::DailyRewardsData<'a>>,
#[serde(borrow)]
pub event_type: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub feed_context: Option<log::FeedContext<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub game_card_data: Option<log::GameCardData<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub game_card_id: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub item_usage_data: Option<log::ItemUsageData<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub metadata: Option<log::Metadata<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub parent_log_uri: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub root_log_uri: Option<CowStr<'a>>,
#[serde(borrow)]
pub session_id: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub session_uri: Option<CowStr<'a>>,
pub timestamp: Datetime,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LogGetRecordOutput<'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: Log<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Metadata<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub client_version: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub network_latency: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub performance_timings: Option<Data<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub platform: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct RewardItem<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub item_id: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub quantity: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub rarity: Option<CowStr<'a>>,
}
impl<'a> Log<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, LogRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
impl<'a> LexiconSchema for CollectionData<'a> {
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<'a> LexiconSchema for DailyRewardsData<'a> {
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<'a> LexiconSchema for FeedContext<'a> {
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<'a> LexiconSchema for GameCardData<'a> {
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<'a> LexiconSchema for ItemUsageData<'a> {
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<'de> = LogGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<LogGetRecordOutput<'_>> for Log<'_> {
fn from(output: LogGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Log<'_> {
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<'a> LexiconSchema for Log<'a> {
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<'a> LexiconSchema for Metadata<'a> {
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<'a> LexiconSchema for RewardItem<'a> {
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 EventType;
type Timestamp;
type SessionId;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type EventType = Unset;
type Timestamp = Unset;
type SessionId = Unset;
}
pub struct SetEventType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetEventType<S> {}
impl<S: State> State for SetEventType<S> {
type EventType = Set<members::event_type>;
type Timestamp = S::Timestamp;
type SessionId = S::SessionId;
}
pub struct SetTimestamp<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTimestamp<S> {}
impl<S: State> State for SetTimestamp<S> {
type EventType = S::EventType;
type Timestamp = Set<members::timestamp>;
type SessionId = S::SessionId;
}
pub struct SetSessionId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSessionId<S> {}
impl<S: State> State for SetSessionId<S> {
type EventType = S::EventType;
type Timestamp = S::Timestamp;
type SessionId = Set<members::session_id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct event_type(());
pub struct timestamp(());
pub struct session_id(());
}
}
pub struct LogBuilder<'a, S: log_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<log::CollectionData<'a>>,
Option<Datetime>,
Option<log::DailyRewardsData<'a>>,
Option<CowStr<'a>>,
Option<log::FeedContext<'a>>,
Option<log::GameCardData<'a>>,
Option<CowStr<'a>>,
Option<log::ItemUsageData<'a>>,
Option<log::Metadata<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Log<'a> {
pub fn new() -> LogBuilder<'a, log_state::Empty> {
LogBuilder::new()
}
}
impl<'a> LogBuilder<'a, 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,
),
_lifetime: PhantomData,
}
}
}
impl<'a, S: log_state::State> LogBuilder<'a, S> {
pub fn collection_data(
mut self,
value: impl Into<Option<log::CollectionData<'a>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_collection_data(
mut self,
value: Option<log::CollectionData<'a>>,
) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: log_state::State> LogBuilder<'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: log_state::State> LogBuilder<'a, S> {
pub fn daily_rewards_data(
mut self,
value: impl Into<Option<log::DailyRewardsData<'a>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_daily_rewards_data(
mut self,
value: Option<log::DailyRewardsData<'a>>,
) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> LogBuilder<'a, S>
where
S: log_state::State,
S::EventType: log_state::IsUnset,
{
pub fn event_type(
mut self,
value: impl Into<CowStr<'a>>,
) -> LogBuilder<'a, log_state::SetEventType<S>> {
self._fields.3 = Option::Some(value.into());
LogBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: log_state::State> LogBuilder<'a, S> {
pub fn feed_context(
mut self,
value: impl Into<Option<log::FeedContext<'a>>>,
) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_feed_context(mut self, value: Option<log::FeedContext<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S: log_state::State> LogBuilder<'a, S> {
pub fn game_card_data(
mut self,
value: impl Into<Option<log::GameCardData<'a>>>,
) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_game_card_data(mut self, value: Option<log::GameCardData<'a>>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S: log_state::State> LogBuilder<'a, S> {
pub fn game_card_id(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_game_card_id(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S: log_state::State> LogBuilder<'a, S> {
pub fn item_usage_data(
mut self,
value: impl Into<Option<log::ItemUsageData<'a>>>,
) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_item_usage_data(
mut self,
value: Option<log::ItemUsageData<'a>>,
) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S: log_state::State> LogBuilder<'a, S> {
pub fn metadata(mut self, value: impl Into<Option<log::Metadata<'a>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_metadata(mut self, value: Option<log::Metadata<'a>>) -> Self {
self._fields.8 = value;
self
}
}
impl<'a, S: log_state::State> LogBuilder<'a, S> {
pub fn parent_log_uri(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_parent_log_uri(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.9 = value;
self
}
}
impl<'a, S: log_state::State> LogBuilder<'a, S> {
pub fn root_log_uri(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_root_log_uri(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.10 = value;
self
}
}
impl<'a, S> LogBuilder<'a, S>
where
S: log_state::State,
S::SessionId: log_state::IsUnset,
{
pub fn session_id(
mut self,
value: impl Into<CowStr<'a>>,
) -> LogBuilder<'a, log_state::SetSessionId<S>> {
self._fields.11 = Option::Some(value.into());
LogBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: log_state::State> LogBuilder<'a, S> {
pub fn session_uri(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.12 = value.into();
self
}
pub fn maybe_session_uri(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.12 = value;
self
}
}
impl<'a, S> LogBuilder<'a, S>
where
S: log_state::State,
S::Timestamp: log_state::IsUnset,
{
pub fn timestamp(
mut self,
value: impl Into<Datetime>,
) -> LogBuilder<'a, log_state::SetTimestamp<S>> {
self._fields.13 = Option::Some(value.into());
LogBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LogBuilder<'a, S>
where
S: log_state::State,
S::EventType: log_state::IsSet,
S::Timestamp: log_state::IsSet,
S::SessionId: log_state::IsSet,
{
pub fn build(self) -> Log<'a> {
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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> Log<'a> {
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),
}
}
}