Files
Genarrative/server-rs/crates/spacetime-client/src/mapper/runtime_profile.rs

1327 lines
47 KiB
Rust

use super::*;
impl From<module_runtime::RuntimeProfileDashboardGetInput> for RuntimeProfileDashboardGetInput {
fn from(input: module_runtime::RuntimeProfileDashboardGetInput) -> Self {
Self {
user_id: input.user_id,
}
}
}
impl From<module_runtime::RuntimeProfileWalletLedgerListInput>
for RuntimeProfileWalletLedgerListInput
{
fn from(input: module_runtime::RuntimeProfileWalletLedgerListInput) -> Self {
Self {
user_id: input.user_id,
}
}
}
impl From<module_runtime::RuntimeProfileWalletAdjustmentInput>
for RuntimeProfileWalletAdjustmentInput
{
fn from(input: module_runtime::RuntimeProfileWalletAdjustmentInput) -> Self {
Self {
user_id: input.user_id,
amount: input.amount,
ledger_id: input.ledger_id,
created_at_micros: input.created_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfileRechargeCenterGetInput>
for RuntimeProfileRechargeCenterGetInput
{
fn from(input: module_runtime::RuntimeProfileRechargeCenterGetInput) -> Self {
Self {
user_id: input.user_id,
}
}
}
impl From<module_runtime::RuntimeProfileRechargeOrderGetInput>
for RuntimeProfileRechargeOrderGetInput
{
fn from(input: module_runtime::RuntimeProfileRechargeOrderGetInput) -> Self {
Self {
order_id: input.order_id,
}
}
}
impl From<module_runtime::RuntimeProfileRechargeOrderCreateInput>
for RuntimeProfileRechargeOrderCreateInput
{
fn from(input: module_runtime::RuntimeProfileRechargeOrderCreateInput) -> Self {
Self {
user_id: input.user_id,
product_id: input.product_id,
payment_channel: input.payment_channel,
created_at_micros: input.created_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfileRechargeOrderPaidInput>
for RuntimeProfileRechargeOrderPaidInput
{
fn from(input: module_runtime::RuntimeProfileRechargeOrderPaidInput) -> Self {
Self {
order_id: input.order_id,
paid_at_micros: input.paid_at_micros,
provider_transaction_id: input.provider_transaction_id,
}
}
}
impl From<module_runtime::RuntimeProfileFeedbackSubmissionInput>
for RuntimeProfileFeedbackSubmissionInput
{
fn from(input: module_runtime::RuntimeProfileFeedbackSubmissionInput) -> Self {
Self {
user_id: input.user_id,
description: input.description,
contact_phone: input.contact_phone,
evidence_items: input.evidence_items.into_iter().map(Into::into).collect(),
created_at_micros: input.created_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfileFeedbackEvidenceSnapshot>
for RuntimeProfileFeedbackEvidenceSnapshot
{
fn from(input: module_runtime::RuntimeProfileFeedbackEvidenceSnapshot) -> Self {
Self {
evidence_id: input.evidence_id,
file_name: input.file_name,
content_type: input.content_type,
size_bytes: input.size_bytes,
data_url: input.data_url,
}
}
}
impl From<module_runtime::RuntimeProfileRewardCodeRedeemInput>
for RuntimeProfileRewardCodeRedeemInput
{
fn from(input: module_runtime::RuntimeProfileRewardCodeRedeemInput) -> Self {
Self {
user_id: input.user_id,
code: input.code,
redeemed_at_micros: input.redeemed_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfileTaskCenterGetInput> for RuntimeProfileTaskCenterGetInput {
fn from(input: module_runtime::RuntimeProfileTaskCenterGetInput) -> Self {
Self {
user_id: input.user_id,
}
}
}
impl From<module_runtime::AnalyticsMetricQueryInput> for AnalyticsMetricQueryInput {
fn from(input: module_runtime::AnalyticsMetricQueryInput) -> Self {
Self {
event_key: input.event_key,
scope_kind: map_runtime_tracking_scope_kind(input.scope_kind),
scope_id: input.scope_id,
granularity: map_analytics_granularity(input.granularity),
}
}
}
impl From<module_runtime::RuntimeProfileTaskClaimInput> for RuntimeProfileTaskClaimInput {
fn from(input: module_runtime::RuntimeProfileTaskClaimInput) -> Self {
Self {
user_id: input.user_id,
task_id: input.task_id,
}
}
}
impl From<module_runtime::RuntimeProfileTaskConfigAdminListInput>
for RuntimeProfileTaskConfigAdminListInput
{
fn from(input: module_runtime::RuntimeProfileTaskConfigAdminListInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
}
}
}
impl From<module_runtime::RuntimeProfileTaskConfigAdminUpsertInput>
for RuntimeProfileTaskConfigAdminUpsertInput
{
fn from(input: module_runtime::RuntimeProfileTaskConfigAdminUpsertInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
task_id: input.task_id,
title: input.title,
description: input.description,
event_key: input.event_key,
cycle: map_runtime_profile_task_cycle(input.cycle),
scope_kind: map_runtime_tracking_scope_kind(input.scope_kind),
threshold: input.threshold,
reward_points: input.reward_points,
enabled: input.enabled,
sort_order: input.sort_order,
updated_at_micros: input.updated_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfileTaskConfigAdminDisableInput>
for RuntimeProfileTaskConfigAdminDisableInput
{
fn from(input: module_runtime::RuntimeProfileTaskConfigAdminDisableInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
task_id: input.task_id,
updated_at_micros: input.updated_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfileRechargeProductAdminListInput>
for RuntimeProfileRechargeProductAdminListInput
{
fn from(input: module_runtime::RuntimeProfileRechargeProductAdminListInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
}
}
}
impl From<module_runtime::RuntimeProfileRechargeProductAdminUpsertInput>
for RuntimeProfileRechargeProductAdminUpsertInput
{
fn from(input: module_runtime::RuntimeProfileRechargeProductAdminUpsertInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
product_id: input.product_id,
title: input.title,
price_cents: input.price_cents,
kind: map_runtime_profile_recharge_product_kind(input.kind),
points_amount: input.points_amount,
bonus_points: input.bonus_points,
duration_days: input.duration_days,
badge_label: input.badge_label,
description: input.description,
tier: map_runtime_profile_membership_tier(input.tier),
enabled: input.enabled,
sort_order: input.sort_order,
updated_at_micros: input.updated_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfileRedeemCodeAdminUpsertInput>
for RuntimeProfileRedeemCodeAdminUpsertInput
{
fn from(input: module_runtime::RuntimeProfileRedeemCodeAdminUpsertInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
code: input.code,
mode: map_runtime_profile_redeem_code_mode(input.mode),
reward_points: input.reward_points,
max_uses: input.max_uses,
enabled: input.enabled,
allowed_user_ids: input.allowed_user_ids,
allowed_public_user_codes: input.allowed_public_user_codes,
updated_at_micros: input.updated_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfileRedeemCodeAdminDisableInput>
for RuntimeProfileRedeemCodeAdminDisableInput
{
fn from(input: module_runtime::RuntimeProfileRedeemCodeAdminDisableInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
code: input.code,
updated_at_micros: input.updated_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfileRedeemCodeAdminListInput>
for RuntimeProfileRedeemCodeAdminListInput
{
fn from(input: module_runtime::RuntimeProfileRedeemCodeAdminListInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
}
}
}
impl From<module_runtime::RuntimeProfileInviteCodeAdminUpsertInput>
for RuntimeProfileInviteCodeAdminUpsertInput
{
fn from(input: module_runtime::RuntimeProfileInviteCodeAdminUpsertInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
invite_code: input.invite_code,
metadata_json: input.metadata_json,
starts_at_micros: input.starts_at_micros,
expires_at_micros: input.expires_at_micros,
updated_at_micros: input.updated_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfileInviteCodeAdminListInput>
for RuntimeProfileInviteCodeAdminListInput
{
fn from(input: module_runtime::RuntimeProfileInviteCodeAdminListInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
}
}
}
impl From<module_runtime::RuntimeReferralInviteCenterGetInput>
for RuntimeReferralInviteCenterGetInput
{
fn from(input: module_runtime::RuntimeReferralInviteCenterGetInput) -> Self {
Self {
user_id: input.user_id,
}
}
}
impl From<module_runtime::RuntimeReferralRedeemInput> for RuntimeReferralRedeemInput {
fn from(input: module_runtime::RuntimeReferralRedeemInput) -> Self {
Self {
user_id: input.user_id,
invite_code: input.invite_code,
updated_at_micros: input.updated_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfilePlayStatsGetInput> for RuntimeProfilePlayStatsGetInput {
fn from(input: module_runtime::RuntimeProfilePlayStatsGetInput) -> Self {
Self {
user_id: input.user_id,
}
}
}
impl From<module_runtime::RuntimeProfileSaveArchiveListInput>
for RuntimeProfileSaveArchiveListInput
{
fn from(input: module_runtime::RuntimeProfileSaveArchiveListInput) -> Self {
Self {
user_id: input.user_id,
}
}
}
impl From<module_runtime::RuntimeProfileSaveArchiveResumeInput>
for RuntimeProfileSaveArchiveResumeInput
{
fn from(input: module_runtime::RuntimeProfileSaveArchiveResumeInput) -> Self {
Self {
user_id: input.user_id,
world_key: input.world_key,
}
}
}
pub(crate) fn map_runtime_profile_dashboard_procedure_result(
result: RuntimeProfileDashboardProcedureResult,
) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("profile dashboard 快照"))?;
Ok(build_runtime_profile_dashboard_record(
map_runtime_profile_dashboard_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_wallet_ledger_procedure_result(
result: RuntimeProfileWalletLedgerProcedureResult,
) -> Result<Vec<RuntimeProfileWalletLedgerEntryRecord>, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
Ok(result
.entries
.into_iter()
.map(|snapshot| {
build_runtime_profile_wallet_ledger_entry_record(
map_runtime_profile_wallet_ledger_entry_snapshot(snapshot),
)
})
.collect())
}
pub(crate) fn map_runtime_profile_wallet_adjustment_procedure_result(
result: RuntimeProfileWalletAdjustmentProcedureResult,
) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("profile dashboard 快照"))?;
Ok(build_runtime_profile_dashboard_record(
map_runtime_profile_dashboard_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_recharge_center_procedure_result(
result: RuntimeProfileRechargeCenterProcedureResult,
) -> Result<RuntimeProfileRechargeCenterRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("profile recharge center 快照"))?;
Ok(build_runtime_profile_recharge_center_record(
map_runtime_profile_recharge_center_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_recharge_order_procedure_result(
result: RuntimeProfileRechargeCenterProcedureResult,
) -> Result<
(
RuntimeProfileRechargeCenterRecord,
RuntimeProfileRechargeOrderRecord,
),
SpacetimeClientError,
> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let center = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("profile recharge center 快照"))?;
let order = result
.order
.ok_or_else(|| SpacetimeClientError::missing_snapshot("profile recharge order 快照"))?;
Ok((
build_runtime_profile_recharge_center_record(map_runtime_profile_recharge_center_snapshot(
center,
)),
module_runtime::build_runtime_profile_recharge_order_record(
map_runtime_profile_recharge_order_snapshot(order),
),
))
}
pub(crate) fn map_runtime_profile_feedback_submission_procedure_result(
result: RuntimeProfileFeedbackSubmissionProcedureResult,
) -> Result<RuntimeProfileFeedbackSubmissionRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("profile feedback 快照"))?;
build_runtime_profile_feedback_submission_record(
map_runtime_profile_feedback_submission_snapshot(snapshot),
)
.map_err(SpacetimeClientError::validation_failed)
}
pub(crate) fn map_runtime_referral_invite_center_procedure_result(
result: RuntimeReferralInviteCenterProcedureResult,
) -> Result<RuntimeReferralInviteCenterRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("referral invite center 快照"))?;
Ok(build_runtime_referral_invite_center_record(
map_runtime_referral_invite_center_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_referral_redeem_procedure_result(
result: RuntimeReferralRedeemProcedureResult,
) -> Result<RuntimeReferralRedeemRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("referral redeem 快照"))?;
Ok(build_runtime_referral_redeem_record(
map_runtime_referral_redeem_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_reward_code_redeem_procedure_result(
result: RuntimeProfileRewardCodeRedeemProcedureResult,
) -> Result<RuntimeProfileRewardCodeRedeemRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("reward redeem 快照"))?;
Ok(build_runtime_profile_reward_code_redeem_record(
map_runtime_profile_reward_code_redeem_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_task_center_procedure_result(
result: RuntimeProfileTaskCenterProcedureResult,
) -> Result<RuntimeProfileTaskCenterRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("profile task center 快照"))?;
Ok(build_runtime_profile_task_center_record(
map_runtime_profile_task_center_snapshot(snapshot),
))
}
pub(crate) fn map_analytics_metric_query_procedure_result(
result: AnalyticsMetricQueryProcedureResult,
) -> Result<DomainAnalyticsMetricQueryResponse, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
Ok(DomainAnalyticsMetricQueryResponse {
buckets: result
.buckets
.into_iter()
.map(map_analytics_bucket_metric)
.collect(),
})
}
pub(crate) fn map_runtime_profile_task_claim_procedure_result(
result: RuntimeProfileTaskClaimProcedureResult,
) -> Result<RuntimeProfileTaskClaimRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("profile task claim 快照"))?;
Ok(build_runtime_profile_task_claim_record(
map_runtime_profile_task_claim_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_task_config_admin_list_procedure_result(
result: RuntimeProfileTaskConfigAdminListProcedureResult,
) -> Result<Vec<RuntimeProfileTaskConfigRecord>, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
Ok(result
.entries
.into_iter()
.map(|snapshot| {
build_runtime_profile_task_config_record(map_runtime_profile_task_config_snapshot(
snapshot,
))
})
.collect())
}
pub(crate) fn map_runtime_profile_task_config_admin_procedure_result(
result: RuntimeProfileTaskConfigAdminProcedureResult,
) -> Result<RuntimeProfileTaskConfigRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("profile task config 快照"))?;
Ok(build_runtime_profile_task_config_record(
map_runtime_profile_task_config_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_recharge_product_admin_list_procedure_result(
result: RuntimeProfileRechargeProductAdminListProcedureResult,
) -> Result<Vec<RuntimeProfileRechargeProductConfigRecord>, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
Ok(result
.entries
.into_iter()
.map(|snapshot| {
build_runtime_profile_recharge_product_config_record(
map_runtime_profile_recharge_product_config_snapshot(snapshot),
)
})
.collect())
}
pub(crate) fn map_runtime_profile_recharge_product_admin_procedure_result(
result: RuntimeProfileRechargeProductAdminProcedureResult,
) -> Result<RuntimeProfileRechargeProductConfigRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("recharge product config 快照"))?;
Ok(build_runtime_profile_recharge_product_config_record(
map_runtime_profile_recharge_product_config_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_redeem_code_admin_procedure_result(
result: RuntimeProfileRedeemCodeAdminProcedureResult,
) -> Result<RuntimeProfileRedeemCodeRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("redeem code 快照"))?;
Ok(build_runtime_profile_redeem_code_record(
map_runtime_profile_redeem_code_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_redeem_code_admin_list_procedure_result(
result: RuntimeProfileRedeemCodeAdminListProcedureResult,
) -> Result<Vec<RuntimeProfileRedeemCodeRecord>, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
Ok(result
.entries
.into_iter()
.map(|snapshot| {
build_runtime_profile_redeem_code_record(map_runtime_profile_redeem_code_snapshot(
snapshot,
))
})
.collect())
}
pub(crate) fn map_runtime_profile_invite_code_admin_procedure_result(
result: RuntimeProfileInviteCodeAdminProcedureResult,
) -> Result<RuntimeProfileInviteCodeRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::Procedure(
result
.error_message
.unwrap_or_else(|| "SpacetimeDB procedure 返回未知错误".to_string()),
));
}
let snapshot = result.record.ok_or_else(|| {
SpacetimeClientError::Procedure("SpacetimeDB procedure 未返回 invite code 快照".to_string())
})?;
Ok(build_runtime_profile_invite_code_record(
map_runtime_profile_invite_code_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_invite_code_admin_list_procedure_result(
result: RuntimeProfileInviteCodeAdminListProcedureResult,
) -> Result<Vec<RuntimeProfileInviteCodeRecord>, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
Ok(result
.entries
.into_iter()
.map(|snapshot| {
build_runtime_profile_invite_code_record(map_runtime_profile_invite_code_snapshot(
snapshot,
))
})
.collect())
}
pub(crate) fn map_runtime_profile_play_stats_procedure_result(
result: RuntimeProfilePlayStatsProcedureResult,
) -> Result<RuntimeProfilePlayStatsRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("profile play stats 快照"))?;
Ok(build_runtime_profile_play_stats_record(
map_runtime_profile_play_stats_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_save_archive_list_procedure_result(
result: RuntimeProfileSaveArchiveProcedureResult,
) -> Result<Vec<RuntimeProfileSaveArchiveRecord>, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
result
.entries
.into_iter()
.map(|snapshot| {
build_runtime_profile_save_archive_record(map_runtime_profile_save_archive_snapshot(
snapshot,
))
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))
})
.collect()
}
pub(crate) fn map_runtime_profile_save_archive_resume_procedure_result(
result: RuntimeProfileSaveArchiveProcedureResult,
) -> Result<(RuntimeProfileSaveArchiveRecord, RuntimeSnapshotRecord), SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let archive = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("save archive 快照"))?;
let snapshot = result
.current_snapshot
.ok_or_else(|| SpacetimeClientError::missing_snapshot("恢复后的 runtime snapshot"))?;
Ok((
build_runtime_profile_save_archive_record(map_runtime_profile_save_archive_snapshot(
archive,
))
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
build_runtime_snapshot_record(map_runtime_snapshot_snapshot(snapshot))
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
))
}
pub(crate) fn map_runtime_profile_dashboard_snapshot(
snapshot: RuntimeProfileDashboardSnapshot,
) -> module_runtime::RuntimeProfileDashboardSnapshot {
module_runtime::RuntimeProfileDashboardSnapshot {
user_id: snapshot.user_id,
wallet_balance: snapshot.wallet_balance,
total_play_time_ms: snapshot.total_play_time_ms,
played_world_count: snapshot.played_world_count,
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_analytics_bucket_metric(
bucket: AnalyticsBucketMetric,
) -> module_runtime::AnalyticsBucketMetric {
module_runtime::AnalyticsBucketMetric {
bucket_key: bucket.bucket_key,
bucket_start_date_key: bucket.bucket_start_date_key,
bucket_end_date_key: bucket.bucket_end_date_key,
value: bucket.value,
}
}
pub(crate) fn map_runtime_profile_wallet_ledger_entry_snapshot(
snapshot: RuntimeProfileWalletLedgerEntrySnapshot,
) -> module_runtime::RuntimeProfileWalletLedgerEntrySnapshot {
module_runtime::RuntimeProfileWalletLedgerEntrySnapshot {
wallet_ledger_id: snapshot.wallet_ledger_id,
user_id: snapshot.user_id,
amount_delta: snapshot.amount_delta,
balance_after: snapshot.balance_after,
source_type: map_runtime_profile_wallet_ledger_source_type_back(snapshot.source_type),
created_at_micros: snapshot.created_at_micros,
}
}
pub(crate) fn map_runtime_profile_recharge_center_snapshot(
snapshot: RuntimeProfileRechargeCenterSnapshot,
) -> module_runtime::RuntimeProfileRechargeCenterSnapshot {
module_runtime::RuntimeProfileRechargeCenterSnapshot {
user_id: snapshot.user_id,
wallet_balance: snapshot.wallet_balance,
membership: map_runtime_profile_membership_snapshot(snapshot.membership),
point_products: snapshot
.point_products
.into_iter()
.map(map_runtime_profile_recharge_product_snapshot)
.collect(),
membership_products: snapshot
.membership_products
.into_iter()
.map(map_runtime_profile_recharge_product_snapshot)
.collect(),
benefits: snapshot
.benefits
.into_iter()
.map(map_runtime_profile_membership_benefit_snapshot)
.collect(),
latest_order: snapshot
.latest_order
.map(map_runtime_profile_recharge_order_snapshot),
has_points_recharged: snapshot.has_points_recharged,
}
}
pub(crate) fn map_runtime_profile_recharge_product_snapshot(
snapshot: RuntimeProfileRechargeProductSnapshot,
) -> module_runtime::RuntimeProfileRechargeProductSnapshot {
module_runtime::RuntimeProfileRechargeProductSnapshot {
product_id: snapshot.product_id,
title: snapshot.title,
price_cents: snapshot.price_cents,
kind: map_runtime_profile_recharge_product_kind_back(snapshot.kind),
points_amount: snapshot.points_amount,
bonus_points: snapshot.bonus_points,
duration_days: snapshot.duration_days,
badge_label: snapshot.badge_label,
description: snapshot.description,
tier: map_runtime_profile_membership_tier_back(snapshot.tier),
}
}
pub(crate) fn map_runtime_profile_recharge_product_config_snapshot(
snapshot: RuntimeProfileRechargeProductConfigSnapshot,
) -> module_runtime::RuntimeProfileRechargeProductConfigSnapshot {
module_runtime::RuntimeProfileRechargeProductConfigSnapshot {
product_id: snapshot.product_id,
title: snapshot.title,
price_cents: snapshot.price_cents,
kind: map_runtime_profile_recharge_product_kind_back(snapshot.kind),
points_amount: snapshot.points_amount,
bonus_points: snapshot.bonus_points,
duration_days: snapshot.duration_days,
badge_label: snapshot.badge_label,
description: snapshot.description,
tier: map_runtime_profile_membership_tier_back(snapshot.tier),
enabled: snapshot.enabled,
sort_order: snapshot.sort_order,
created_by: snapshot.created_by,
created_at_micros: snapshot.created_at_micros,
updated_by: snapshot.updated_by,
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_runtime_profile_membership_benefit_snapshot(
snapshot: RuntimeProfileMembershipBenefitSnapshot,
) -> module_runtime::RuntimeProfileMembershipBenefitSnapshot {
module_runtime::RuntimeProfileMembershipBenefitSnapshot {
benefit_name: snapshot.benefit_name,
normal_value: snapshot.normal_value,
month_value: snapshot.month_value,
season_value: snapshot.season_value,
year_value: snapshot.year_value,
}
}
pub(crate) fn map_runtime_profile_membership_snapshot(
snapshot: RuntimeProfileMembershipSnapshot,
) -> module_runtime::RuntimeProfileMembershipSnapshot {
module_runtime::RuntimeProfileMembershipSnapshot {
user_id: snapshot.user_id,
status: map_runtime_profile_membership_status_back(snapshot.status),
tier: map_runtime_profile_membership_tier_back(snapshot.tier),
started_at_micros: snapshot.started_at_micros,
expires_at_micros: snapshot.expires_at_micros,
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_runtime_profile_recharge_order_snapshot(
snapshot: RuntimeProfileRechargeOrderSnapshot,
) -> module_runtime::RuntimeProfileRechargeOrderSnapshot {
module_runtime::RuntimeProfileRechargeOrderSnapshot {
order_id: snapshot.order_id,
user_id: snapshot.user_id,
product_id: snapshot.product_id,
product_title: snapshot.product_title,
kind: map_runtime_profile_recharge_product_kind_back(snapshot.kind),
amount_cents: snapshot.amount_cents,
status: map_runtime_profile_recharge_order_status_back(snapshot.status),
payment_channel: snapshot.payment_channel,
paid_at_micros: snapshot.paid_at_micros,
provider_transaction_id: snapshot.provider_transaction_id,
created_at_micros: snapshot.created_at_micros,
points_delta: snapshot.points_delta,
membership_expires_at_micros: snapshot.membership_expires_at_micros,
}
}
pub(crate) fn map_runtime_profile_feedback_submission_snapshot(
snapshot: RuntimeProfileFeedbackSubmissionSnapshot,
) -> module_runtime::RuntimeProfileFeedbackSubmissionSnapshot {
module_runtime::RuntimeProfileFeedbackSubmissionSnapshot {
feedback_id: snapshot.feedback_id,
user_id: snapshot.user_id,
description: snapshot.description,
contact_phone: snapshot.contact_phone,
evidence_json: snapshot.evidence_json,
status: map_runtime_profile_feedback_status_back(snapshot.status),
created_at_micros: snapshot.created_at_micros,
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_runtime_referral_invite_center_snapshot(
snapshot: RuntimeReferralInviteCenterSnapshot,
) -> module_runtime::RuntimeReferralInviteCenterSnapshot {
module_runtime::RuntimeReferralInviteCenterSnapshot {
user_id: snapshot.user_id,
invite_code: snapshot.invite_code,
invite_link_path: snapshot.invite_link_path,
invited_count: snapshot.invited_count,
rewarded_invite_count: snapshot.rewarded_invite_count,
today_inviter_reward_count: snapshot.today_inviter_reward_count,
today_inviter_reward_remaining: snapshot.today_inviter_reward_remaining,
reward_points: snapshot.reward_points,
invited_users: snapshot
.invited_users
.into_iter()
.map(|user| module_runtime::RuntimeReferralInvitedUserSnapshot {
user_id: user.user_id,
display_name: user.display_name,
avatar_url: user.avatar_url,
bound_at_micros: user.bound_at_micros,
})
.collect(),
has_redeemed_code: snapshot.has_redeemed_code,
bound_inviter_user_id: snapshot.bound_inviter_user_id,
bound_at_micros: snapshot.bound_at_micros,
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_runtime_referral_redeem_snapshot(
snapshot: RuntimeReferralRedeemSnapshot,
) -> module_runtime::RuntimeReferralRedeemSnapshot {
module_runtime::RuntimeReferralRedeemSnapshot {
center: map_runtime_referral_invite_center_snapshot(snapshot.center),
invitee_reward_granted: snapshot.invitee_reward_granted,
inviter_reward_granted: snapshot.inviter_reward_granted,
invitee_balance_after: snapshot.invitee_balance_after,
inviter_balance_after: snapshot.inviter_balance_after,
}
}
pub(crate) fn map_runtime_profile_reward_code_redeem_snapshot(
snapshot: RuntimeProfileRewardCodeRedeemSnapshot,
) -> module_runtime::RuntimeProfileRewardCodeRedeemSnapshot {
module_runtime::RuntimeProfileRewardCodeRedeemSnapshot {
wallet_balance: snapshot.wallet_balance,
amount_granted: snapshot.amount_granted,
ledger_entry: map_runtime_profile_wallet_ledger_entry_snapshot(snapshot.ledger_entry),
}
}
pub(crate) fn map_runtime_profile_task_config_snapshot(
snapshot: RuntimeProfileTaskConfigSnapshot,
) -> module_runtime::RuntimeProfileTaskConfigSnapshot {
module_runtime::RuntimeProfileTaskConfigSnapshot {
task_id: snapshot.task_id,
title: snapshot.title,
description: snapshot.description,
event_key: snapshot.event_key,
cycle: map_runtime_profile_task_cycle_back(snapshot.cycle),
scope_kind: map_runtime_tracking_scope_kind_back(snapshot.scope_kind),
threshold: snapshot.threshold,
reward_points: snapshot.reward_points,
enabled: snapshot.enabled,
sort_order: snapshot.sort_order,
created_by: snapshot.created_by,
created_at_micros: snapshot.created_at_micros,
updated_by: snapshot.updated_by,
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_runtime_profile_task_item_snapshot(
snapshot: RuntimeProfileTaskItemSnapshot,
) -> module_runtime::RuntimeProfileTaskItemSnapshot {
module_runtime::RuntimeProfileTaskItemSnapshot {
task_id: snapshot.task_id,
title: snapshot.title,
description: snapshot.description,
event_key: snapshot.event_key,
cycle: map_runtime_profile_task_cycle_back(snapshot.cycle),
threshold: snapshot.threshold,
progress_count: snapshot.progress_count,
reward_points: snapshot.reward_points,
status: map_runtime_profile_task_status_back(snapshot.status),
day_key: snapshot.day_key,
claimed_at_micros: snapshot.claimed_at_micros,
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_runtime_profile_task_center_snapshot(
snapshot: RuntimeProfileTaskCenterSnapshot,
) -> module_runtime::RuntimeProfileTaskCenterSnapshot {
module_runtime::RuntimeProfileTaskCenterSnapshot {
user_id: snapshot.user_id,
day_key: snapshot.day_key,
wallet_balance: snapshot.wallet_balance,
tasks: snapshot
.tasks
.into_iter()
.map(map_runtime_profile_task_item_snapshot)
.collect(),
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_runtime_profile_task_claim_snapshot(
snapshot: RuntimeProfileTaskClaimSnapshot,
) -> module_runtime::RuntimeProfileTaskClaimSnapshot {
module_runtime::RuntimeProfileTaskClaimSnapshot {
user_id: snapshot.user_id,
task_id: snapshot.task_id,
day_key: snapshot.day_key,
reward_points: snapshot.reward_points,
wallet_balance: snapshot.wallet_balance,
ledger_entry: map_runtime_profile_wallet_ledger_entry_snapshot(snapshot.ledger_entry),
center: map_runtime_profile_task_center_snapshot(snapshot.center),
}
}
pub(crate) fn map_runtime_profile_redeem_code_snapshot(
snapshot: RuntimeProfileRedeemCodeSnapshot,
) -> module_runtime::RuntimeProfileRedeemCodeSnapshot {
module_runtime::RuntimeProfileRedeemCodeSnapshot {
code: snapshot.code,
mode: map_runtime_profile_redeem_code_mode_back(snapshot.mode),
reward_points: snapshot.reward_points,
max_uses: snapshot.max_uses,
global_used_count: snapshot.global_used_count,
enabled: snapshot.enabled,
allowed_user_ids: snapshot.allowed_user_ids,
created_by: snapshot.created_by,
created_at_micros: snapshot.created_at_micros,
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_runtime_profile_invite_code_snapshot(
snapshot: RuntimeProfileInviteCodeSnapshot,
) -> module_runtime::RuntimeProfileInviteCodeSnapshot {
module_runtime::RuntimeProfileInviteCodeSnapshot {
user_id: snapshot.user_id,
invite_code: snapshot.invite_code,
metadata_json: snapshot.metadata_json,
starts_at_micros: snapshot.starts_at_micros,
expires_at_micros: snapshot.expires_at_micros,
created_at_micros: snapshot.created_at_micros,
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_runtime_profile_played_world_snapshot(
snapshot: RuntimeProfilePlayedWorldSnapshot,
) -> module_runtime::RuntimeProfilePlayedWorldSnapshot {
module_runtime::RuntimeProfilePlayedWorldSnapshot {
played_world_id: snapshot.played_world_id,
user_id: snapshot.user_id,
world_key: snapshot.world_key,
owner_user_id: snapshot.owner_user_id,
profile_id: snapshot.profile_id,
world_type: snapshot.world_type,
world_title: snapshot.world_title,
world_subtitle: snapshot.world_subtitle,
first_played_at_micros: snapshot.first_played_at_micros,
last_played_at_micros: snapshot.last_played_at_micros,
last_observed_play_time_ms: snapshot.last_observed_play_time_ms,
}
}
pub(crate) fn map_runtime_profile_play_stats_snapshot(
snapshot: RuntimeProfilePlayStatsSnapshot,
) -> module_runtime::RuntimeProfilePlayStatsSnapshot {
module_runtime::RuntimeProfilePlayStatsSnapshot {
user_id: snapshot.user_id,
total_play_time_ms: snapshot.total_play_time_ms,
played_works: snapshot
.played_works
.into_iter()
.map(map_runtime_profile_played_world_snapshot)
.collect(),
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_analytics_granularity(
granularity: module_runtime::AnalyticsGranularity,
) -> AnalyticsGranularity {
match granularity {
module_runtime::AnalyticsGranularity::Day => AnalyticsGranularity::Day,
module_runtime::AnalyticsGranularity::Week => AnalyticsGranularity::Week,
module_runtime::AnalyticsGranularity::Month => AnalyticsGranularity::Month,
module_runtime::AnalyticsGranularity::Quarter => AnalyticsGranularity::Quarter,
module_runtime::AnalyticsGranularity::Year => AnalyticsGranularity::Year,
}
}
pub(crate) fn map_runtime_profile_task_cycle(
value: DomainRuntimeProfileTaskCycle,
) -> crate::module_bindings::RuntimeProfileTaskCycle {
match value {
DomainRuntimeProfileTaskCycle::Daily => {
crate::module_bindings::RuntimeProfileTaskCycle::Daily
}
}
}
pub(crate) fn map_runtime_profile_task_cycle_back(
value: crate::module_bindings::RuntimeProfileTaskCycle,
) -> DomainRuntimeProfileTaskCycle {
match value {
crate::module_bindings::RuntimeProfileTaskCycle::Daily => {
DomainRuntimeProfileTaskCycle::Daily
}
}
}
pub(crate) fn map_runtime_profile_task_status_back(
value: crate::module_bindings::RuntimeProfileTaskStatus,
) -> DomainRuntimeProfileTaskStatus {
match value {
crate::module_bindings::RuntimeProfileTaskStatus::Incomplete => {
DomainRuntimeProfileTaskStatus::Incomplete
}
crate::module_bindings::RuntimeProfileTaskStatus::Claimable => {
DomainRuntimeProfileTaskStatus::Claimable
}
crate::module_bindings::RuntimeProfileTaskStatus::Claimed => {
DomainRuntimeProfileTaskStatus::Claimed
}
crate::module_bindings::RuntimeProfileTaskStatus::Disabled => {
DomainRuntimeProfileTaskStatus::Disabled
}
}
}
pub(crate) fn map_runtime_profile_redeem_code_mode(
value: module_runtime::RuntimeProfileRedeemCodeMode,
) -> crate::module_bindings::RuntimeProfileRedeemCodeMode {
match value {
module_runtime::RuntimeProfileRedeemCodeMode::Public => {
crate::module_bindings::RuntimeProfileRedeemCodeMode::Public
}
module_runtime::RuntimeProfileRedeemCodeMode::Unique => {
crate::module_bindings::RuntimeProfileRedeemCodeMode::Unique
}
module_runtime::RuntimeProfileRedeemCodeMode::Private => {
crate::module_bindings::RuntimeProfileRedeemCodeMode::Private
}
}
}
pub(crate) fn map_runtime_profile_redeem_code_mode_back(
value: crate::module_bindings::RuntimeProfileRedeemCodeMode,
) -> module_runtime::RuntimeProfileRedeemCodeMode {
match value {
crate::module_bindings::RuntimeProfileRedeemCodeMode::Public => {
module_runtime::RuntimeProfileRedeemCodeMode::Public
}
crate::module_bindings::RuntimeProfileRedeemCodeMode::Unique => {
module_runtime::RuntimeProfileRedeemCodeMode::Unique
}
crate::module_bindings::RuntimeProfileRedeemCodeMode::Private => {
module_runtime::RuntimeProfileRedeemCodeMode::Private
}
}
}
pub(crate) fn map_runtime_profile_recharge_product_kind(
value: module_runtime::RuntimeProfileRechargeProductKind,
) -> crate::module_bindings::RuntimeProfileRechargeProductKind {
match value {
module_runtime::RuntimeProfileRechargeProductKind::Points => {
crate::module_bindings::RuntimeProfileRechargeProductKind::Points
}
module_runtime::RuntimeProfileRechargeProductKind::Membership => {
crate::module_bindings::RuntimeProfileRechargeProductKind::Membership
}
}
}
pub(crate) fn map_runtime_profile_recharge_product_kind_back(
value: crate::module_bindings::RuntimeProfileRechargeProductKind,
) -> module_runtime::RuntimeProfileRechargeProductKind {
match value {
crate::module_bindings::RuntimeProfileRechargeProductKind::Points => {
module_runtime::RuntimeProfileRechargeProductKind::Points
}
crate::module_bindings::RuntimeProfileRechargeProductKind::Membership => {
module_runtime::RuntimeProfileRechargeProductKind::Membership
}
}
}
pub(crate) fn map_runtime_profile_membership_tier(
value: module_runtime::RuntimeProfileMembershipTier,
) -> crate::module_bindings::RuntimeProfileMembershipTier {
match value {
module_runtime::RuntimeProfileMembershipTier::Normal => {
crate::module_bindings::RuntimeProfileMembershipTier::Normal
}
module_runtime::RuntimeProfileMembershipTier::Month => {
crate::module_bindings::RuntimeProfileMembershipTier::Month
}
module_runtime::RuntimeProfileMembershipTier::Season => {
crate::module_bindings::RuntimeProfileMembershipTier::Season
}
module_runtime::RuntimeProfileMembershipTier::Year => {
crate::module_bindings::RuntimeProfileMembershipTier::Year
}
}
}
pub(crate) fn map_runtime_profile_membership_status_back(
value: crate::module_bindings::RuntimeProfileMembershipStatus,
) -> module_runtime::RuntimeProfileMembershipStatus {
match value {
crate::module_bindings::RuntimeProfileMembershipStatus::Normal => {
module_runtime::RuntimeProfileMembershipStatus::Normal
}
crate::module_bindings::RuntimeProfileMembershipStatus::Active => {
module_runtime::RuntimeProfileMembershipStatus::Active
}
}
}
pub(crate) fn map_runtime_profile_membership_tier_back(
value: crate::module_bindings::RuntimeProfileMembershipTier,
) -> module_runtime::RuntimeProfileMembershipTier {
match value {
crate::module_bindings::RuntimeProfileMembershipTier::Normal => {
module_runtime::RuntimeProfileMembershipTier::Normal
}
crate::module_bindings::RuntimeProfileMembershipTier::Month => {
module_runtime::RuntimeProfileMembershipTier::Month
}
crate::module_bindings::RuntimeProfileMembershipTier::Season => {
module_runtime::RuntimeProfileMembershipTier::Season
}
crate::module_bindings::RuntimeProfileMembershipTier::Year => {
module_runtime::RuntimeProfileMembershipTier::Year
}
}
}
pub(crate) fn map_runtime_profile_recharge_order_status_back(
value: crate::module_bindings::RuntimeProfileRechargeOrderStatus,
) -> module_runtime::RuntimeProfileRechargeOrderStatus {
match value {
crate::module_bindings::RuntimeProfileRechargeOrderStatus::Pending => {
module_runtime::RuntimeProfileRechargeOrderStatus::Pending
}
crate::module_bindings::RuntimeProfileRechargeOrderStatus::Paid => {
module_runtime::RuntimeProfileRechargeOrderStatus::Paid
}
crate::module_bindings::RuntimeProfileRechargeOrderStatus::Failed => {
module_runtime::RuntimeProfileRechargeOrderStatus::Failed
}
crate::module_bindings::RuntimeProfileRechargeOrderStatus::Closed => {
module_runtime::RuntimeProfileRechargeOrderStatus::Closed
}
crate::module_bindings::RuntimeProfileRechargeOrderStatus::Refunded => {
module_runtime::RuntimeProfileRechargeOrderStatus::Refunded
}
}
}
pub(crate) fn map_runtime_profile_feedback_status_back(
value: crate::module_bindings::RuntimeProfileFeedbackStatus,
) -> module_runtime::RuntimeProfileFeedbackStatus {
match value {
crate::module_bindings::RuntimeProfileFeedbackStatus::Open => {
module_runtime::RuntimeProfileFeedbackStatus::Open
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SquareHoleDropFeedbackRecord {
pub accepted: bool,
pub reject_reason: Option<String>,
pub message: String,
}
#[derive(Clone, Debug, PartialEq)]
pub struct SquareHoleRunRecord {
pub run_id: String,
pub profile_id: String,
pub owner_user_id: String,
pub status: String,
pub snapshot_version: u64,
pub started_at_ms: u64,
pub duration_limit_ms: u64,
pub server_now_ms: Option<u64>,
pub remaining_ms: u64,
pub total_shape_count: u32,
pub completed_shape_count: u32,
pub combo: u32,
pub best_combo: u32,
pub score: u32,
pub rule_label: String,
pub background_image_src: Option<String>,
pub current_shape: Option<SquareHoleShapeSnapshotRecord>,
pub holes: Vec<SquareHoleHoleSnapshotRecord>,
pub last_feedback: Option<SquareHoleDropFeedbackRecord>,
pub last_confirmed_action_id: Option<String>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct SquareHoleDropConfirmationRecord {
pub status: String,
pub accepted: bool,
pub reject_reason: Option<String>,
pub failure_reason: Option<String>,
pub feedback: SquareHoleDropFeedbackRecord,
pub run: SquareHoleRunRecord,
}