refactor(backup): build the export from per-domain slices

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.
This commit is contained in:
Marc-André Bombeck committed 2026-10-22 07:46:02 +02:00
1 parent 508e19f190
commit 322652a86e
32 files changed
+3113 -2623

No files matched your search

@@ -1,7 +1,7 @@
{
"$comment": "Production functions over 200 lines, keyed \"file :: name\", and their length. Maintained by src/__tests__/source-size-ratchet.test.ts.",
"count": 413,
"total": 149647,
"count": 410,
"total": 148267,
"entries": {
"app/achievements/page.tsx :: AchievementsPage": 206,
"app/api/admin/backups/upload/route.ts :: apiHandler(arg)": 314,
@@ -319,11 +319,8 @@
"lib/documents/fenced-chat.ts :: streamFencedReply": 309,
"lib/documents/ingest.ts :: ingestDocument": 272,
"lib/export/backup-json-scan.ts :: scanBackupJson": 225,
"lib/export/full-backup-payload.ts :: buildFullBackupPayload": 804,
"lib/export/full-backup-payload.ts :: buildFullBackupPayload > medications.map(arg) #3": 268,
"lib/export/profile-backup.ts :: buildProfileBackupSection": 270,
"lib/export/profile-backup.ts :: restoreProfileData": 291,
"lib/export/records-backup.ts :: buildRecordsBackupSection": 308,
"lib/export/vaccinations-backup.ts :: restoreVaccinationsData": 216,
"lib/export/visits-backup.ts :: restoreVisitsData": 261,
"lib/fhir/build-bundle.ts :: buildFhirDocumentBundle": 363,