mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
buildFullBackupPayload now asks every domain for its slice at once and lays the slices out in the file's key order (backup-export-sections.ts), merging the manifest where it first appears. The measurement, medication, mood, instance-settings and nutrient readers and serialisers move out of the payload builder into their domain modules; the records section keeps its composition and manifest, while labs, illness, allergies, family history, workouts and documents each export from their own module. The measurement restore half moves to measurements-restore.ts so the export graph does not pull in the restore's dependencies. The file, its counts and their order are unchanged; the golden copies still match. The measurement completeness guard now reads the domain module and also checks that every carried column is written back.
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
/**
|
|
* What every domain's export is handed, and what it hands back.
|
|
*
|
|
* Each domain reads its own tables and returns its slice of the payload with
|
|
* its row counts. `buildFullBackupPayload` lays the slices out in the order
|
|
* `backup-domains.ts` lists them, which is the order the file has always had.
|
|
*/
|
|
import type { PrismaClient } from "@/generated/prisma/client";
|
|
|
|
export type BackupPurpose = "portable-export" | "disaster-recovery";
|
|
|
|
export interface BackupExportContext {
|
|
readonly prisma: PrismaClient;
|
|
readonly userId: string;
|
|
readonly purpose: BackupPurpose;
|
|
/** `purpose === "disaster-recovery"`, spelled out because every row asks. */
|
|
readonly disasterRecovery: boolean;
|
|
/**
|
|
* Leave the bulk tables unread and put `DeferredRows` markers where their
|
|
* arrays sit (`deferred-rows.ts`); only the streaming writer asks for this.
|
|
*/
|
|
readonly deferBulk: boolean;
|
|
}
|
|
|
|
export interface BackupExportPart {
|
|
/** The payload keys this domain writes, in the order they appear. */
|
|
section: Record<string, unknown>;
|
|
/** Row counts for the audit trail, in the order they appear. */
|
|
counts: Record<string, number>;
|
|
}
|