spa hardening, offline logging, rate limit fixes
server: - backup exporter, auth extractors, error shapes, CONTEXT (prior work) - spa assets served outside the rate limit via route_layer - requests_per_second went to per_second(), which takes an interval not a rate: 50 meant one request per 50s once burst was spent. now converted properly. 15/s, burst 60 spa fixes: - account delete cleared snake_case token keys that were never written - refresh interceptor could retry forever - date ranges used local day boundaries stamped +00:00 - "all" period trend plotted one page; calendar days fabricated mood 3 - chart grid invisible: hsl(var(--border)) against rgba tokens - blob url leak, orphaned media on failed save, devtools in prod bundle - pt-safe/safe-area-pb classes never existed spa features: - offline outbox: entries queue to IndexedDB, replay with backoff, only server refusals count against an entry - drafts persist, quick-log sheet, diary infinite scroll + filters - route error boundary, stale-chunk recovery, no service worker in dev a11y + perf: - mood picker is a radiogroup, activity picker keyboard-operable, text alternatives for colour/emoji, locale week start - dark glass over the bright photo: worst case 1.4:1 -> 4.9-9.6:1 - initial payload 1095->769kB raw, 306->230kB gzip; 38 unused components and 5 deps dropped; fonts 218->133kB 53 tests added (43 spa, 10 server)
This commit is contained in:
@@ -15,7 +15,7 @@ use domain::reminder::Reminder;
|
||||
|
||||
use super::shared::{io_err, json_err, zip_err};
|
||||
|
||||
pub const BACKUP_FORMAT_VERSION: u32 = 2;
|
||||
pub const BACKUP_FORMAT_VERSION: u32 = 3;
|
||||
pub const BACKUP_MANIFEST: &str = "backup.json";
|
||||
|
||||
pub struct ZipBackupWriter;
|
||||
@@ -67,6 +67,7 @@ fn manifest(backup: &UserBackup) -> Result<Vec<u8>, DomainError> {
|
||||
.map(BackedUpReminder::from)
|
||||
.collect(),
|
||||
tracks_cycle: backup.preferences.tracks_cycle(),
|
||||
media: backed_up_media(backup),
|
||||
};
|
||||
|
||||
serde_json::to_vec_pretty(&manifest).map_err(json_err)
|
||||
@@ -82,6 +83,37 @@ pub struct BackupManifest {
|
||||
pub activities: Vec<BackedUpActivity>,
|
||||
pub reminders: Vec<BackedUpReminder>,
|
||||
pub tracks_cycle: bool,
|
||||
#[serde(default)]
|
||||
pub media: Vec<BackedUpMedia>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BackedUpMedia {
|
||||
pub id: String,
|
||||
pub kind: String,
|
||||
pub content_type: String,
|
||||
}
|
||||
|
||||
pub const PHOTO_KIND: &str = "photo";
|
||||
pub const VOICE_MEMO_KIND: &str = "voice_memo";
|
||||
|
||||
fn backed_up_media(backup: &UserBackup) -> Vec<BackedUpMedia> {
|
||||
let photos = backup.media.photos.iter().map(|blob| (PHOTO_KIND, blob));
|
||||
let memos = backup
|
||||
.media
|
||||
.voice_memos
|
||||
.iter()
|
||||
.map(|blob| (VOICE_MEMO_KIND, blob));
|
||||
|
||||
photos
|
||||
.chain(memos)
|
||||
.map(|(kind, blob)| BackedUpMedia {
|
||||
id: blob.id.clone(),
|
||||
kind: kind.to_string(),
|
||||
content_type: blob.content_type.value().to_string(),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
|
||||
@@ -3,7 +3,7 @@ mod extract;
|
||||
mod shared;
|
||||
|
||||
pub use backup::{
|
||||
BACKUP_FORMAT_VERSION, BACKUP_MANIFEST, BackedUpActivity, BackedUpEntry, BackedUpMetric,
|
||||
BackedUpReminder, BackupManifest, ZipBackupWriter,
|
||||
BACKUP_FORMAT_VERSION, BACKUP_MANIFEST, BackedUpActivity, BackedUpEntry, BackedUpMedia,
|
||||
BackedUpMetric, BackedUpReminder, BackupManifest, PHOTO_KIND, VOICE_MEMO_KIND, ZipBackupWriter,
|
||||
};
|
||||
pub use extract::MarkdownExtractWriter;
|
||||
|
||||
Reference in New Issue
Block a user