mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 13:01:00 +00:00
fix(dashboard): split module maps into client-safe module to unblock build
The settings dashboard-layout client component imported WIDGET_MODULE_BY_ID from @/lib/dashboard/snapshot, which transitively pulls the server snapshot builder -> lib/db -> @prisma/adapter-pg -> pg -> node:dns. Turbopack tried to bundle pg for the browser and failed (Module not found: Can't resolve 'dns'), breaking next build and therefore e2e and both Docker arch builds. Move the two pure data maps (WIDGET_MODULE_BY_ID, SUMMARY_TYPE_MODULE) into @/lib/dashboard/widget-modules, which imports only the ModuleKey and MeasurementType types. snapshot.ts re-exports both for the server call sites and the existing tests; the client component imports from the new module.
This commit is contained in:
1 parent
0dbb70134c
commit
2057cb9d2b
3 files changed
+75
-42
No files matched your search
@@ -50,7 +50,7 @@ import {
|
||||
} from "@/components/ui/select";
|
||||
import { apiDelete, apiGet, apiPut } from "@/lib/api/api-fetch";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { WIDGET_MODULE_BY_ID } from "@/lib/dashboard/snapshot";
|
||||
import { WIDGET_MODULE_BY_ID } from "@/lib/dashboard/widget-modules";
|
||||
|
||||
/**
|
||||
* v1.4.47 W4 — pure reorder helper shared by the arrow buttons and the
|
||||
|
||||
@@ -84,48 +84,20 @@ import { resolveModuleMap, type ModuleKey } from "@/lib/modules/gate";
|
||||
const BRIEFING_TTL_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
/**
|
||||
* v1.18.0 — dashboard widget id → toggleable module key. When the user
|
||||
* disables the module, the matching widget is forced invisible on both
|
||||
* the web `layout` and the iOS `layoutCatalogue`, so the tile/chart never
|
||||
* paints. Only the toggleable surfaces appear here; CORE widgets
|
||||
* (weight / bp / pulse / bodyFat / medications / bpInTarget and the
|
||||
* vital-derived HealthKit metrics) carry NO entry and are never hidden.
|
||||
* v1.18.0 — the two dashboard module maps live in a client-safe module
|
||||
* (`@/lib/dashboard/widget-modules`) so the settings client component can
|
||||
* import them without pulling the server snapshot builder (and its
|
||||
* `pg` / `dns` chain) into the browser bundle. Re-exported here for the
|
||||
* server call sites and the existing tests.
|
||||
*/
|
||||
export const WIDGET_MODULE_BY_ID: Partial<Record<string, ModuleKey>> = {
|
||||
mood: "mood",
|
||||
sleep: "sleep",
|
||||
glucose: "glucose",
|
||||
achievements: "achievements",
|
||||
recentWorkouts: "workouts",
|
||||
// v1.18.0 B1 — recovery-domain HealthKit widgets belong to the recovery
|
||||
// module; the per-night breathing-disturbance widget belongs to sleep.
|
||||
cardioRecovery: "recovery",
|
||||
sixMinuteWalk: "recovery",
|
||||
stairAscentSpeed: "recovery",
|
||||
stairDescentSpeed: "recovery",
|
||||
breathingDisturbances: "sleep",
|
||||
};
|
||||
|
||||
/**
|
||||
* v1.18.0 — `MeasurementType` slim-summary keys that belong to a
|
||||
* toggleable module. When the module is off the key is stripped from
|
||||
* `tiles.summaries` / `tiles.lastSeenByType` (so `metricStates` and the
|
||||
* client data-floor gates also drop it) before the snapshot leaves the
|
||||
* server. Core vital types are absent here and always pass through.
|
||||
*/
|
||||
export const SUMMARY_TYPE_MODULE: Partial<Record<MeasurementType, ModuleKey>> = {
|
||||
SLEEP_DURATION: "sleep",
|
||||
BLOOD_GLUCOSE: "glucose",
|
||||
// v1.18.0 B1 — recovery-domain HealthKit metrics. The recovery page +
|
||||
// its tiles are the recovery module's surface; when it is off these
|
||||
// device-native signals must drop from the dashboard snapshot too.
|
||||
CARDIO_RECOVERY: "recovery",
|
||||
SIX_MINUTE_WALK_DISTANCE: "recovery",
|
||||
STAIR_ASCENT_SPEED: "recovery",
|
||||
STAIR_DESCENT_SPEED: "recovery",
|
||||
// Per-night breathing-disturbance index is a sleep-page signal.
|
||||
BREATHING_DISTURBANCES: "sleep",
|
||||
};
|
||||
export {
|
||||
WIDGET_MODULE_BY_ID,
|
||||
SUMMARY_TYPE_MODULE,
|
||||
} from "@/lib/dashboard/widget-modules";
|
||||
import {
|
||||
WIDGET_MODULE_BY_ID,
|
||||
SUMMARY_TYPE_MODULE,
|
||||
} from "@/lib/dashboard/widget-modules";
|
||||
|
||||
const GLUCOSE_CONTEXTS = [
|
||||
"FASTING",
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* v1.18.0 — client-safe module maps for dashboard widgets / summary types.
|
||||
*
|
||||
* These two maps are pure data (string → ModuleKey) with no runtime
|
||||
* dependency on the DB, Prisma, or the server-only module gate. They are
|
||||
* factored out of `@/lib/dashboard/snapshot` so the settings client
|
||||
* component (`dashboard-layout-section.tsx`) can import them without
|
||||
* dragging the whole server snapshot builder — and its transitive
|
||||
* `pg` / `dns` chain — into the browser bundle. `snapshot.ts` re-exports
|
||||
* both for the server call sites and the existing tests.
|
||||
*
|
||||
* `ModuleKey` comes from `@/lib/modules/registry` (pure constants, no
|
||||
* imports) and `MeasurementType` is a type-only import from the generated
|
||||
* Prisma client, so this file stays browser-bundle-safe.
|
||||
*/
|
||||
import type { MeasurementType } from "@/generated/prisma/client";
|
||||
import type { ModuleKey } from "@/lib/modules/registry";
|
||||
|
||||
/**
|
||||
* Dashboard widget id → toggleable module key. When the user disables the
|
||||
* module, the matching widget is forced invisible on both the web `layout`
|
||||
* and the iOS `layoutCatalogue`, so the tile/chart never paints. Only the
|
||||
* toggleable surfaces appear here; CORE widgets (weight / bp / pulse /
|
||||
* bodyFat / medications / bpInTarget and the vital-derived HealthKit
|
||||
* metrics) carry NO entry and are never hidden.
|
||||
*/
|
||||
export const WIDGET_MODULE_BY_ID: Partial<Record<string, ModuleKey>> = {
|
||||
mood: "mood",
|
||||
sleep: "sleep",
|
||||
glucose: "glucose",
|
||||
achievements: "achievements",
|
||||
recentWorkouts: "workouts",
|
||||
// v1.18.0 B1 — recovery-domain HealthKit widgets belong to the recovery
|
||||
// module; the per-night breathing-disturbance widget belongs to sleep.
|
||||
cardioRecovery: "recovery",
|
||||
sixMinuteWalk: "recovery",
|
||||
stairAscentSpeed: "recovery",
|
||||
stairDescentSpeed: "recovery",
|
||||
breathingDisturbances: "sleep",
|
||||
};
|
||||
|
||||
/**
|
||||
* `MeasurementType` slim-summary keys that belong to a toggleable module.
|
||||
* When the module is off the key is stripped from `tiles.summaries` /
|
||||
* `tiles.lastSeenByType` (so `metricStates` and the client data-floor
|
||||
* gates also drop it) before the snapshot leaves the server. Core vital
|
||||
* types are absent here and always pass through.
|
||||
*/
|
||||
export const SUMMARY_TYPE_MODULE: Partial<Record<MeasurementType, ModuleKey>> = {
|
||||
SLEEP_DURATION: "sleep",
|
||||
BLOOD_GLUCOSE: "glucose",
|
||||
// v1.18.0 B1 — recovery-domain HealthKit metrics. The recovery page +
|
||||
// its tiles are the recovery module's surface; when it is off these
|
||||
// device-native signals must drop from the dashboard snapshot too.
|
||||
CARDIO_RECOVERY: "recovery",
|
||||
SIX_MINUTE_WALK_DISTANCE: "recovery",
|
||||
STAIR_ASCENT_SPEED: "recovery",
|
||||
STAIR_DESCENT_SPEED: "recovery",
|
||||
// Per-night breathing-disturbance index is a sleep-page signal.
|
||||
BREATHING_DISTURBANCES: "sleep",
|
||||
};
|
||||
Reference in new issue
Block a user