Skip to main content

max / makenotwork

2.3 KB · 87 lines History Blame Raw
1 //! SyncKit developer billing and the sync traffic it meters.
2
3 use super::str_enum::impl_str_enum;
4 use serde::{Deserialize, Serialize};
5
6 // --- SyncKit developer billing ---
7
8 /// Lifecycle of a SyncKit developer app's billing record (the `sync_apps.billing_status`
9 /// TEXT column, CHECK-constrained in migration 117). Replaces the raw string the
10 /// `DbSyncAppBilling` model used to carry, so a status comparison can't drift from the
11 /// CHECK set.
12 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
13 pub enum SyncBillingStatus {
14 #[serde(rename = "draft")]
15 Draft,
16 #[serde(rename = "active")]
17 Active,
18 #[serde(rename = "suspended_unpaid")]
19 SuspendedUnpaid,
20 #[serde(rename = "canceled")]
21 Canceled,
22 }
23
24 impl_str_enum!(SyncBillingStatus {
25 Draft => "draft",
26 Active => "active",
27 SuspendedUnpaid => "suspended_unpaid",
28 Canceled => "canceled",
29 });
30
31 /// How a SyncKit developer app's storage billing is enforced (the
32 /// `sync_apps.enforcement_mode` TEXT column, CHECK-constrained to `('per_key','bulk')`
33 /// in migration 118). Replaces the raw string the `DbSyncAppBilling` model used to
34 /// carry. Lifting this to an enum makes `monthly_price_cents` match exhaustively, so an
35 /// unrecognized mode is no longer silently priced at the floor (Pay-S2). The historical
36 /// `app_wide` value was renamed to `bulk` in migration 118; only these two are live.
37 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
38 pub enum SyncEnforcementMode {
39 #[serde(rename = "per_key")]
40 PerKey,
41 #[serde(rename = "bulk")]
42 Bulk,
43 }
44
45 impl_str_enum!(SyncEnforcementMode {
46 PerKey => "per_key",
47 Bulk => "bulk",
48 });
49
50 // --- SyncKit ---
51
52 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
53 pub enum SyncOperation {
54 #[serde(rename = "INSERT")]
55 Insert,
56 #[serde(rename = "UPDATE")]
57 Update,
58 #[serde(rename = "DELETE")]
59 Delete,
60 }
61
62 impl_str_enum!(SyncOperation {
63 Insert => "INSERT",
64 Update => "UPDATE",
65 Delete => "DELETE",
66 });
67
68 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
69 #[serde(rename_all = "lowercase")]
70 pub enum SyncPlatform {
71 Macos,
72 Ios,
73 Android,
74 Windows,
75 Linux,
76 Web,
77 }
78
79 impl_str_enum!(SyncPlatform {
80 Macos => "macos",
81 Ios => "ios",
82 Android => "android",
83 Windows => "windows",
84 Linux => "linux",
85 Web => "web",
86 });
87