//! SyncKit developer billing and the sync traffic it meters. use super::str_enum::impl_str_enum; use serde::{Deserialize, Serialize}; // --- SyncKit developer billing --- /// Lifecycle of a SyncKit developer app's billing record (the `sync_apps.billing_status` /// TEXT column, CHECK-constrained in migration 117). Replaces the raw string the /// `DbSyncAppBilling` model used to carry, so a status comparison can't drift from the /// CHECK set. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum SyncBillingStatus { #[serde(rename = "draft")] Draft, #[serde(rename = "active")] Active, #[serde(rename = "suspended_unpaid")] SuspendedUnpaid, #[serde(rename = "canceled")] Canceled, } impl_str_enum!(SyncBillingStatus { Draft => "draft", Active => "active", SuspendedUnpaid => "suspended_unpaid", Canceled => "canceled", }); /// How a SyncKit developer app's storage billing is enforced (the /// `sync_apps.enforcement_mode` TEXT column, CHECK-constrained to `('per_key','bulk')` /// in migration 118). Replaces the raw string the `DbSyncAppBilling` model used to /// carry. Lifting this to an enum makes `monthly_price_cents` match exhaustively, so an /// unrecognized mode is no longer silently priced at the floor (Pay-S2). The historical /// `app_wide` value was renamed to `bulk` in migration 118; only these two are live. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum SyncEnforcementMode { #[serde(rename = "per_key")] PerKey, #[serde(rename = "bulk")] Bulk, } impl_str_enum!(SyncEnforcementMode { PerKey => "per_key", Bulk => "bulk", }); // --- SyncKit --- #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum SyncOperation { #[serde(rename = "INSERT")] Insert, #[serde(rename = "UPDATE")] Update, #[serde(rename = "DELETE")] Delete, } impl_str_enum!(SyncOperation { Insert => "INSERT", Update => "UPDATE", Delete => "DELETE", }); #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum SyncPlatform { Macos, Ios, Android, Windows, Linux, Web, } impl_str_enum!(SyncPlatform { Macos => "macos", Ios => "ios", Android => "android", Windows => "windows", Linux => "linux", Web => "web", });