Files
HealthLog/tests/integration/routes/parity/__snapshots__/import-json.02-same-file.json.snap
T
Marc-André Bombeck a840e30fac feat(import): carry every field the app's own files write
The JSON import read six measurement fields and six mood fields while
the full backup and the JSON export carry twice that. A sleep night came
back as stageless rows, a range reading as a single value, an ECG alert
without its verdict, and a mood entry without its note, its level-A
values, its zone, its tag and factor links or its day context.

The import now reads valueMin/valueMax, sleepStage,
rhythmClassification and deviceType on a reading, and note, a1 to a5,
tz, factors, structuredTags and context on a mood entry. Each mood entry
is written with its links and context in one transaction, the way the
bulk mood ingest writes one. A link to a tag the importing account does
not have is dropped and named in droppedTagKeys / droppedFactorKeys, and
the import card says which. The schema moves to
src/lib/import/json/schema.ts so the guards can read it.

json-import-field-coverage.test.ts runs the JSON export and both backup
variants on an account with every column filled in: every field they
write is either read by the import or named with the reason it is not
(row ids, source, deletion records, ciphertext, sync bookkeeping), and a
reason for a field no exporter writes fails as stale. The round trip
imports each file into a fresh account and compares the re-export field
for field. The published contract is held to the runtime schema.
2026-10-23 21:33:06 +02:00

210 lines
4.6 KiB
Plaintext

{
"status": 200,
"body": {
"data": {
"measurements": 3,
"moodEntries": 1,
"skipped": 6
},
"error": null
},
"events": [
{
"status": 200,
"action": {
"name": "import.upload"
},
"meta": {
"import_stats": {
"measurements": 3,
"moodEntries": 1,
"skipped": 6
},
"import_dropped_link_keys": 0,
"external_id_rejected": 2,
"external_id_shapes": "object_description",
"external_id_surface": "import.json"
},
"warnings": null,
"error": null
}
],
"effects": [
{
"effect": "maybeEnqueueMorningRefresh",
"args": [
"<id:1>",
[]
]
},
{
"effect": "invalidateStatusInsightsForTypes",
"args": [
"<id:1>",
[
"WEIGHT",
"BLOOD_GLUCOSE",
"SLEEP_DURATION"
],
{
"source": "manual"
}
]
}
],
"stored": {
"measurements": [
{
"type": "WEIGHT",
"value": 81.4,
"unit": "kg",
"source": "IMPORT",
"externalId": "exp-w-1",
"measuredAt": "2026-10-10T06:30:00.000Z",
"notes": null,
"notesEncrypted": "<bytes:59>",
"glucoseContext": null
},
{
"type": "WEIGHT",
"value": 81.9,
"unit": "kg",
"source": "IMPORT",
"externalId": null,
"measuredAt": "2026-10-11T06:30:00.000Z",
"notes": null,
"notesEncrypted": null,
"glucoseContext": null
},
{
"type": "BLOOD_GLUCOSE",
"value": 104,
"unit": "mg/dL",
"source": "IMPORT",
"externalId": "exp-g-1",
"measuredAt": "2026-10-11T08:00:00.000Z",
"notes": null,
"notesEncrypted": null,
"glucoseContext": "FASTING"
},
{
"type": "SLEEP_DURATION",
"value": 412,
"unit": "min",
"source": "IMPORT",
"externalId": "exp-s-1",
"measuredAt": "2026-10-12T06:00:00.000Z",
"notes": null,
"notesEncrypted": null,
"glucoseContext": null
}
],
"mood": [
{
"date": "2026-10-10",
"mood": "GUT",
"score": 4,
"moodA1": 7,
"tags": "slept well",
"source": "IMPORT",
"externalId": "daylio-1",
"moodLoggedAt": "2026-10-10T07:00:00.000Z"
},
{
"date": "2026-10-11",
"mood": "OKAY",
"score": 3,
"moodA1": 5,
"tags": null,
"source": "IMPORT",
"externalId": null,
"moodLoggedAt": "2026-10-10T22:02:08.803Z"
},
{
"date": "2026-10-11",
"mood": "OKAY",
"score": 3,
"moodA1": 5,
"tags": null,
"source": "IMPORT",
"externalId": null,
"moodLoggedAt": "2026-10-10T22:02:32.701Z"
},
{
"date": "2026-10-12",
"mood": "SCHLECHT",
"score": 2,
"moodA1": 3,
"tags": null,
"source": "IMPORT",
"externalId": null,
"moodLoggedAt": "2026-10-12T20:00:00.000Z"
}
],
"measurementRollups": [
{
"type": "WEIGHT",
"granularity": "DAY",
"bucketStart": "2026-10-10T00:00:00.000Z",
"source": "IMPORT",
"count": 1,
"mean": 81.4
},
{
"type": "WEIGHT",
"granularity": "DAY",
"bucketStart": "2026-10-11T00:00:00.000Z",
"source": "IMPORT",
"count": 1,
"mean": 81.9
},
{
"type": "SLEEP_DURATION",
"granularity": "DAY",
"bucketStart": "2026-10-12T00:00:00.000Z",
"source": "IMPORT",
"count": 1,
"mean": 412
},
{
"type": "BLOOD_GLUCOSE",
"granularity": "DAY",
"bucketStart": "2026-10-11T00:00:00.000Z",
"source": "IMPORT",
"count": 1,
"mean": 104
}
],
"moodRollups": [
{
"granularity": "DAY",
"bucketStart": "2026-10-10T00:00:00.000Z",
"count": 1,
"mean": 4
},
{
"granularity": "DAY",
"bucketStart": "2026-10-11T00:00:00.000Z",
"count": 2,
"mean": 3
},
{
"granularity": "DAY",
"bucketStart": "2026-10-12T00:00:00.000Z",
"count": 1,
"mean": 2
}
],
"audit": [
{
"action": "import.upload",
"details": "{\"measurements\":4,\"moodEntries\":4,\"skipped\":2}"
},
{
"action": "import.upload",
"details": "{\"measurements\":3,\"moodEntries\":1,\"skipped\":6}"
}
]
}
}