// Everything one account holds on the server, in the same file format the app's own "Download backup" // makes, so it can be restored from Settings on any device. export const BACKUP_APP = 'bible-study-project'; export const BACKUP_VERSION = 1; // `store` supplies the account's data: { projects(), prefs(), marks(), ink(), plans() }. export function buildAccountExport(user, store, now = new Date()) { const prefs = store.prefs() ?? {}; const marks = store.marks() ?? {}; const plans = store.plans() ?? {}; return { app: BACKUP_APP, version: BACKUP_VERSION, exportedAt: now.toISOString(), account: user.email, source: 'server', projects: store.projects(), reader: { bookmarks: marks.bookmarks ?? {}, highlights: marks.highlights ?? [], colorLabels: prefs.colorLabels?.v ?? {}, ink: store.ink() ?? {}, }, readingHistory: store.history?.() ?? { chapters: {}, days: [] }, readingPlans: { progress: plans.progress ?? [], customPlans: plans.customPlans ?? [], activity: plans.activity ?? [], }, }; } export const accountExportName = (now = new Date()) => `bible-study-account-${now.toISOString().slice(0, 10)}.json`;