mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 21:32:18 +00:00
chore(format): prettier sweep across develop
Mostly table column normalisation under docs/audit/ + planning, object- literal expansion in src/lib/ai/coach/snapshot.ts after the W4 F6 Apple Health metric block landed, and small wrap/unwrap line adjustments in the device + APNs routes / tests touched across W3/W4/W5 sessions. No behavioural change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5dcd3954a0
commit
f1e6630958
70 files changed
+899
-660
No files matched your search
@@ -52,7 +52,9 @@ describe("getStrictInsightsSystemPrompt — EN", () => {
|
||||
});
|
||||
|
||||
it("documents the additive sourceMetric tokens in the OUTPUT FORMAT", () => {
|
||||
expect(prompt).toMatch(/hrv \| sleep \| resting_hr \| steps \| active_energy/);
|
||||
expect(prompt).toMatch(
|
||||
/hrv \| sleep \| resting_hr \| steps \| active_energy/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -70,6 +72,8 @@ describe("getStrictInsightsSystemPrompt — DE", () => {
|
||||
});
|
||||
|
||||
it("documents the additive sourceMetric tokens in the German OUTPUT FORMAT", () => {
|
||||
expect(prompt).toMatch(/hrv \| sleep \| resting_hr \| steps \| active_energy/);
|
||||
expect(prompt).toMatch(
|
||||
/hrv \| sleep \| resting_hr \| steps \| active_energy/,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -523,15 +523,60 @@ export async function buildCoachSnapshot(
|
||||
// Apple Health source maps to exactly one MeasurementType (BP is
|
||||
// the only fan-out and lives in its own legacy block above).
|
||||
const appleHealthBlocks: AppleHealthBlock[] = [
|
||||
{ metric: "hrv", snapshotKey: "heartRateVariability", type: "HEART_RATE_VARIABILITY", enabled: sources.has("hrv") },
|
||||
{ metric: "sleep", snapshotKey: "sleep", type: "SLEEP_DURATION", enabled: sources.has("sleep") },
|
||||
{ metric: "resting_hr", snapshotKey: "restingHeartRate", type: "RESTING_HEART_RATE", enabled: sources.has("resting_hr") },
|
||||
{ metric: "steps", snapshotKey: "steps", type: "ACTIVITY_STEPS", enabled: sources.has("steps") },
|
||||
{ metric: "active_energy", snapshotKey: "activeEnergy", type: "ACTIVE_ENERGY_BURNED", enabled: sources.has("active_energy") },
|
||||
{ metric: "flights", snapshotKey: "flightsClimbed", type: "FLIGHTS_CLIMBED", enabled: sources.has("flights") },
|
||||
{ metric: "distance", snapshotKey: "walkingRunningDistance", type: "WALKING_RUNNING_DISTANCE", enabled: sources.has("distance") },
|
||||
{ metric: "vo2_max", snapshotKey: "vo2Max", type: "VO2_MAX", enabled: sources.has("vo2_max") },
|
||||
{ metric: "body_temp", snapshotKey: "bodyTemperature", type: "BODY_TEMPERATURE", enabled: sources.has("body_temp") },
|
||||
{
|
||||
metric: "hrv",
|
||||
snapshotKey: "heartRateVariability",
|
||||
type: "HEART_RATE_VARIABILITY",
|
||||
enabled: sources.has("hrv"),
|
||||
},
|
||||
{
|
||||
metric: "sleep",
|
||||
snapshotKey: "sleep",
|
||||
type: "SLEEP_DURATION",
|
||||
enabled: sources.has("sleep"),
|
||||
},
|
||||
{
|
||||
metric: "resting_hr",
|
||||
snapshotKey: "restingHeartRate",
|
||||
type: "RESTING_HEART_RATE",
|
||||
enabled: sources.has("resting_hr"),
|
||||
},
|
||||
{
|
||||
metric: "steps",
|
||||
snapshotKey: "steps",
|
||||
type: "ACTIVITY_STEPS",
|
||||
enabled: sources.has("steps"),
|
||||
},
|
||||
{
|
||||
metric: "active_energy",
|
||||
snapshotKey: "activeEnergy",
|
||||
type: "ACTIVE_ENERGY_BURNED",
|
||||
enabled: sources.has("active_energy"),
|
||||
},
|
||||
{
|
||||
metric: "flights",
|
||||
snapshotKey: "flightsClimbed",
|
||||
type: "FLIGHTS_CLIMBED",
|
||||
enabled: sources.has("flights"),
|
||||
},
|
||||
{
|
||||
metric: "distance",
|
||||
snapshotKey: "walkingRunningDistance",
|
||||
type: "WALKING_RUNNING_DISTANCE",
|
||||
enabled: sources.has("distance"),
|
||||
},
|
||||
{
|
||||
metric: "vo2_max",
|
||||
snapshotKey: "vo2Max",
|
||||
type: "VO2_MAX",
|
||||
enabled: sources.has("vo2_max"),
|
||||
},
|
||||
{
|
||||
metric: "body_temp",
|
||||
snapshotKey: "bodyTemperature",
|
||||
type: "BODY_TEMPERATURE",
|
||||
enabled: sources.has("body_temp"),
|
||||
},
|
||||
];
|
||||
for (const block of appleHealthBlocks) {
|
||||
if (!block.enabled) continue;
|
||||
|
||||
@@ -142,8 +142,8 @@ describe("revokeDeviceCascade", () => {
|
||||
new Error("postgres-blip"),
|
||||
);
|
||||
|
||||
await expect(
|
||||
revokeDeviceCascade("user-1", "dev-3"),
|
||||
).rejects.toThrow("postgres-blip");
|
||||
await expect(revokeDeviceCascade("user-1", "dev-3")).rejects.toThrow(
|
||||
"postgres-blip",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -38,7 +38,8 @@ describe("APPLE_HEALTH_TYPE_MAP", () => {
|
||||
});
|
||||
|
||||
it("converts oxygen saturation from 0..1 fraction to 0..100 percent", () => {
|
||||
const mapping = APPLE_HEALTH_TYPE_MAP.HKQuantityTypeIdentifierOxygenSaturation;
|
||||
const mapping =
|
||||
APPLE_HEALTH_TYPE_MAP.HKQuantityTypeIdentifierOxygenSaturation;
|
||||
expect(mapping.convertToDbUnit(0.97)).toBeCloseTo(97);
|
||||
});
|
||||
|
||||
|
||||
@@ -12,10 +12,7 @@
|
||||
* DB unit, and the aggregation hint all live alongside the identifier
|
||||
* so future analytics work has a single discoverable surface.
|
||||
*/
|
||||
import type {
|
||||
MeasurementType,
|
||||
SleepStage,
|
||||
} from "@/generated/prisma/client";
|
||||
import type { MeasurementType, SleepStage } from "@/generated/prisma/client";
|
||||
|
||||
/**
|
||||
* How a batch of HealthKit samples for the same identifier should be
|
||||
|
||||
@@ -74,8 +74,7 @@ const VALID_ENV = {
|
||||
APNS_KEY_ID: "ABCDE12345",
|
||||
APNS_TEAM_ID: "TEAM123456",
|
||||
APNS_BUNDLE_ID: "test.healthlog.ios",
|
||||
APNS_KEY:
|
||||
"-----BEGIN PRIVATE KEY-----\\nMOCKKEY\\n-----END PRIVATE KEY-----",
|
||||
APNS_KEY: "-----BEGIN PRIVATE KEY-----\\nMOCKKEY\\n-----END PRIVATE KEY-----",
|
||||
};
|
||||
|
||||
function setEnv(over: Record<string, string | undefined> = {}): void {
|
||||
@@ -269,7 +268,6 @@ describe("sendApnsPush — failure classification", () => {
|
||||
expect(r.reason).toBe("apns_network_error");
|
||||
expect(r.shouldDisable).toBeFalsy();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("sendApnsPush — config disabled paths", () => {
|
||||
@@ -325,7 +323,11 @@ describe("sendViaApns — dispatcher fan-out", () => {
|
||||
.mockResolvedValueOnce({
|
||||
sent: [],
|
||||
failed: [
|
||||
{ device: "tok-b", status: 410, response: { reason: "Unregistered" } },
|
||||
{
|
||||
device: "tok-b",
|
||||
status: 410,
|
||||
response: { reason: "Unregistered" },
|
||||
},
|
||||
],
|
||||
});
|
||||
const r = await sendViaApns("u-1", {
|
||||
@@ -349,13 +351,21 @@ describe("sendViaApns — dispatcher fan-out", () => {
|
||||
.mockResolvedValueOnce({
|
||||
sent: [],
|
||||
failed: [
|
||||
{ device: "tok-a", status: 410, response: { reason: "Unregistered" } },
|
||||
{
|
||||
device: "tok-a",
|
||||
status: 410,
|
||||
response: { reason: "Unregistered" },
|
||||
},
|
||||
],
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
sent: [],
|
||||
failed: [
|
||||
{ device: "tok-b", status: 400, response: { reason: "BadDeviceToken" } },
|
||||
{
|
||||
device: "tok-b",
|
||||
status: 400,
|
||||
response: { reason: "BadDeviceToken" },
|
||||
},
|
||||
],
|
||||
});
|
||||
const r = await sendViaApns("u-1", {
|
||||
|
||||
@@ -126,9 +126,7 @@ export function loadApnsConfig(): ApnsConfig | null {
|
||||
// configuring and stopped — surface that as a warning so the
|
||||
// half-finished state is visible in logs.
|
||||
const anySet = Boolean(keyId || teamId || bundleId || inlineKey || keyFile);
|
||||
const allSet = Boolean(
|
||||
keyId && teamId && bundleId && (inlineKey || keyFile),
|
||||
);
|
||||
const allSet = Boolean(keyId && teamId && bundleId && (inlineKey || keyFile));
|
||||
|
||||
if (!anySet) {
|
||||
cachedConfig = null;
|
||||
|
||||
@@ -58,9 +58,7 @@ function dataEnvelope<T extends z.ZodType>(payload: T, id: string) {
|
||||
.object({
|
||||
data: payload,
|
||||
error: z.null(),
|
||||
meta: z
|
||||
.object({ requestId: z.string().optional() })
|
||||
.optional(),
|
||||
meta: z.object({ requestId: z.string().optional() }).optional(),
|
||||
})
|
||||
.meta({ id });
|
||||
}
|
||||
@@ -118,7 +116,10 @@ const coachMessageFeedbackBody = z
|
||||
|
||||
const passkeyLoginVerifyRequest = z
|
||||
.object({
|
||||
challengeId: z.string().min(1).describe("Server-issued WebAuthn challenge id."),
|
||||
challengeId: z
|
||||
.string()
|
||||
.min(1)
|
||||
.describe("Server-issued WebAuthn challenge id."),
|
||||
credential: z
|
||||
.object({
|
||||
id: z.string(),
|
||||
@@ -157,9 +158,7 @@ const refreshRequest = z
|
||||
|
||||
const accessRefreshBundle = z
|
||||
.object({
|
||||
user: z
|
||||
.object({ id: z.string(), username: z.string() })
|
||||
.optional(),
|
||||
user: z.object({ id: z.string(), username: z.string() }).optional(),
|
||||
token: z.string().describe("Access token (`hlk_<64hex>`)."),
|
||||
tokenExpiresAt: z.iso.datetime({ offset: true }),
|
||||
refreshToken: z
|
||||
@@ -216,7 +215,9 @@ const batchEntrySchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(120)
|
||||
.describe("HealthKit identifier (e.g. `HKQuantityTypeIdentifierBodyMass`)."),
|
||||
.describe(
|
||||
"HealthKit identifier (e.g. `HKQuantityTypeIdentifierBodyMass`).",
|
||||
),
|
||||
value: z.number().finite(),
|
||||
unit: z.string().min(1).max(60),
|
||||
startDate: z.iso.datetime({ offset: true }),
|
||||
|
||||
Reference in new issue
Block a user