Files
HealthLog/scripts
Marc-André Bombeck c79fc6cc7b feat: lay down the day view and timeline contract
Land every file the day view, the timeline and life events share before
any of them is built, so the server, the day view and the timeline can be
built side by side without editing the same file (#613).

Schema and migration 0387: LifeEvent with a short category list, calendar
start and end dates, a day/month/year precision, encrypted title and note,
a soft-delete tombstone and an index for the per-user live list. Every new
column is annotated for the column-reader sweep. Life events travel in both
backup purposes with their two ends in one file, are wiped with the
account, and are registered for key rotation.

src/lib/day/contract.ts carries the constants and wire types for
GET /api/day/{date}, /api/day/index, /api/timeline, /api/timeline/readiness
and the life-event routes, free of Zod so the navigation chrome can import
it; the schemas beside it feed the routes and the published contract. The
Coach and MCP tool name get_day is reserved there, and life events are
listed as the one section no model ever sees.

The opt-in timeline module, its navigation entry, the day-section and
timeline-lane surfaces, the day and timeline query keys (evicted by every
record data bundle), and stub routes that answer 501 behind their
admissions. The four cross-section reads declare the whole record for now;
the life-event list is a profile read, and life events join the profile
sharing domain and its consent copy in all seven locales. The day,
timeline and lifeEvents message namespaces carry their base copy as
release-pending keys.

The aggregate bundle cap moves to 4400: the branch already measured 4365
against 4335, and the new copy adds 10 KB.
2026-10-08 13:03:37 +02:00
..
…

scripts/

One-shot operator and build scripts. These are not part of the running application — they are run by hand during a deploy, a backfill, or a release, or wired into CI. Recurring work belongs on pg-boss (src/lib/jobs/), not here.

How to run them

From a source checkout:

pnpm dlx tsx scripts/<file>.ts

The production image intentionally removes npm, pnpm, and Corepack. Only container-safe scripts named by an operator runbook use its pinned healthlog-tsx launcher; scripts that import the full application dependency graph must run from a source checkout. scripts/ is excluded from the project typecheck.

What lives here

  • generate-openapi.ts — emits docs/api/openapi.yaml from the registered Zod schemas (pnpm openapi:generate).
  • check-openapi.ts — compares a freshly generated spec against the committed YAML; CI fails on drift (pnpm openapi:check).
  • check-env.ts — pre-deploy env-var sanity check against env-manifest.json (pnpm check-env); wired into CI.
  • assert-deploy.ts — post-deploy /api/version assertion.
  • rotate-encryption-key.ts — AES-256-GCM key rotation; see docs/ops/encryption-key-rotation.md.
  • restore-backup.ts — restore an off-host AES-GCM backup from an S3-compatible bucket.
  • repair-apple-health-distance.ts — repair walking-distance rows the export.zip import stored 1000x too small; dry-run by default, see docs/ops/apple-health-distance-repair.md.
  • repair-intake-anomalies.ts — repair historic medication-ledger defects (duplicate dose-slot rows, implausible taken_at); dry-run by default, see docs/ops/intake-repair.md.
  • backfill-rollups.ts, drain-per-sample-cumulative.ts, backfill-mood-note-column.ts — historical data backfills (note: the boot-time rollup-full-backfill queue handles new accounts automatically; the CLI is the manual fallback).
  • seed-demo.ts + seed-demo-v15.sql — populate a demo tenant.
  • test-notifications.ts — exercise the notification dispatcher + reminder check.
  • fetch-geolite2.sh — download the MaxMind GeoLite2 MMDBs (needs a licence key) before docker build.
  • install-hooks.sh — install the local git hooks.
  • generate-sw-version.mjs, print-bundle-report.mjs — service-worker version stamp and bundle-size report.
  • i18n/ — locale tooling; __tests__/ — tests for the scripts above.

Conventions

See ../CLAUDE.md "Tests and commands" + "Self-hosting gotchas". Operator runbooks that drive these scripts live in ../docs/ops/.