| 1 |
|
| 2 |
|
| 3 |
use chrono::{DateTime, Utc}; |
| 4 |
use serde::Serialize; |
| 5 |
use sqlx::FromRow; |
| 6 |
|
| 7 |
use super::super::id_types::*; |
| 8 |
|
| 9 |
|
| 10 |
#[derive(Debug, Clone, FromRow, Serialize)] |
| 11 |
pub struct DbSyncApp { |
| 12 |
|
| 13 |
pub id: SyncAppId, |
| 14 |
|
| 15 |
pub creator_id: UserId, |
| 16 |
|
| 17 |
pub name: String, |
| 18 |
|
| 19 |
pub api_key_hash: String, |
| 20 |
|
| 21 |
pub api_key_prefix: String, |
| 22 |
|
| 23 |
pub is_active: bool, |
| 24 |
|
| 25 |
pub created_at: DateTime<Utc>, |
| 26 |
|
| 27 |
pub project_id: Option<ProjectId>, |
| 28 |
|
| 29 |
pub item_id: Option<ItemId>, |
| 30 |
|
| 31 |
pub slug: Option<String>, |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
#[derive(Debug, Clone, FromRow, Serialize)] |
| 36 |
pub struct DbSyncDevice { |
| 37 |
|
| 38 |
pub id: SyncDeviceId, |
| 39 |
|
| 40 |
pub app_id: SyncAppId, |
| 41 |
|
| 42 |
pub user_id: UserId, |
| 43 |
|
| 44 |
pub device_name: String, |
| 45 |
|
| 46 |
pub platform: super::super::SyncPlatform, |
| 47 |
|
| 48 |
pub last_seen_at: DateTime<Utc>, |
| 49 |
|
| 50 |
pub created_at: DateTime<Utc>, |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
#[derive(Debug, Clone, FromRow, Serialize)] |
| 55 |
pub struct DbSyncLogEntry { |
| 56 |
|
| 57 |
pub seq: i64, |
| 58 |
|
| 59 |
pub app_id: SyncAppId, |
| 60 |
|
| 61 |
pub user_id: UserId, |
| 62 |
|
| 63 |
pub device_id: SyncDeviceId, |
| 64 |
|
| 65 |
pub table_name: String, |
| 66 |
|
| 67 |
pub operation: super::super::SyncOperation, |
| 68 |
|
| 69 |
pub row_id: String, |
| 70 |
|
| 71 |
pub client_timestamp: DateTime<Utc>, |
| 72 |
|
| 73 |
pub data: Option<serde_json::Value>, |
| 74 |
|
| 75 |
pub created_at: DateTime<Utc>, |
| 76 |
|
| 77 |
pub key_id: Option<i32>, |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
#[derive(Debug, Clone, FromRow)] |
| 82 |
pub struct DbSyncKeyRotation { |
| 83 |
pub id: uuid::Uuid, |
| 84 |
pub app_id: SyncAppId, |
| 85 |
pub user_id: UserId, |
| 86 |
pub device_id: SyncDeviceId, |
| 87 |
pub new_encrypted_key: String, |
| 88 |
pub old_key_version: i32, |
| 89 |
pub new_key_id: i32, |
| 90 |
pub re_encrypted_through_seq: i64, |
| 91 |
pub target_seq: i64, |
| 92 |
pub created_at: DateTime<Utc>, |
| 93 |
pub updated_at: DateTime<Utc>, |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
#[derive(Debug, Clone, FromRow, Serialize)] |
| 98 |
pub struct DbSyncBlob { |
| 99 |
|
| 100 |
pub id: SyncBlobId, |
| 101 |
|
| 102 |
pub app_id: SyncAppId, |
| 103 |
|
| 104 |
pub user_id: UserId, |
| 105 |
|
| 106 |
pub hash: String, |
| 107 |
|
| 108 |
pub s3_key: String, |
| 109 |
|
| 110 |
pub size_bytes: i64, |
| 111 |
|
| 112 |
|
| 113 |
pub key: String, |
| 114 |
|
| 115 |
pub uploaded_at: DateTime<Utc>, |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
#[derive(Debug, Clone, FromRow, Serialize)] |
| 124 |
pub struct DbSyncAppBilling { |
| 125 |
|
| 126 |
pub id: SyncAppId, |
| 127 |
pub creator_id: UserId, |
| 128 |
pub name: String, |
| 129 |
|
| 130 |
pub is_internal: bool, |
| 131 |
|
| 132 |
pub stripe_customer_id: Option<String>, |
| 133 |
|
| 134 |
pub stripe_subscription_id: Option<String>, |
| 135 |
|
| 136 |
pub billing_status: String, |
| 137 |
|
| 138 |
|
| 139 |
pub storage_gb_cap: Option<i32>, |
| 140 |
|
| 141 |
pub enforcement_mode: String, |
| 142 |
|
| 143 |
pub key_cap: Option<i32>, |
| 144 |
|
| 145 |
|
| 146 |
pub gb_per_key: Option<i32>, |
| 147 |
pub current_period_start: Option<DateTime<Utc>>, |
| 148 |
pub current_period_end: Option<DateTime<Utc>>, |
| 149 |
|
| 150 |
pub bytes_stored: Option<i64>, |
| 151 |
pub bytes_egress_period: Option<i64>, |
| 152 |
pub keys_claimed: Option<i32>, |
| 153 |
pub last_warning_pct: Option<i16>, |
| 154 |
pub period_started_at: Option<DateTime<Utc>>, |
| 155 |
|
| 156 |
|
| 157 |
pub project_slug: Option<String>, |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
#[derive(Debug, Clone, FromRow, Serialize)] |
| 165 |
pub struct DbSyncAppKey { |
| 166 |
pub id: uuid::Uuid, |
| 167 |
pub key: String, |
| 168 |
pub claimed_at: DateTime<Utc>, |
| 169 |
|
| 170 |
|
| 171 |
pub bytes_stored: i64, |
| 172 |
} |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
#[derive(Debug, Clone, FromRow)] |
| 178 |
pub struct DbOtaRelease { |
| 179 |
pub id: OtaReleaseId, |
| 180 |
pub app_id: SyncAppId, |
| 181 |
pub version: String, |
| 182 |
pub notes: String, |
| 183 |
pub signature: String, |
| 184 |
pub pub_date: DateTime<Utc>, |
| 185 |
pub created_at: DateTime<Utc>, |
| 186 |
} |
| 187 |
|
| 188 |
|
| 189 |
#[derive(Debug, Clone, FromRow)] |
| 190 |
pub struct DbOtaArtifact { |
| 191 |
pub id: OtaArtifactId, |
| 192 |
pub release_id: OtaReleaseId, |
| 193 |
pub target: String, |
| 194 |
pub arch: String, |
| 195 |
pub s3_key: String, |
| 196 |
pub file_size: i64, |
| 197 |
pub created_at: DateTime<Utc>, |
| 198 |
} |
| 199 |
|