Merge branch 'v1422/autotaken' into release/v1.42.2

This commit is contained in:
Marc-André Bombeck committed 2026-10-11 14:41:28 +02:00
commit 2f780df0b0
52 files changed
+2552 -19

No files matched your search

@@ -101,6 +101,7 @@ describe("medications — documented shapes match the handlers", () => {
takenAt: "2026-07-19T08:05:00.000Z",
skipped: false,
autoMissed: false,
autoRecorded: false,
attributionSource: "AUTO",
source: "APPLE_HEALTH",
idempotencyKey: null,
@@ -278,6 +278,12 @@ export const medicationResource = z
),
pausedAt: z.iso.datetime({ offset: true }).nullable(),
snoozedUntil: z.iso.datetime({ offset: true }).nullable(),
remindersActive: z
.boolean()
.optional()
.describe(
"Present on the READ paths only (list and single GET). v1.42.2 — whether the server sends dose reminders for this medication: true only when `notificationsEnabled` is on, the medication is `active`, its intake is tracked (`trackIntake`), it is not `asNeeded`, and `autoMarkTaken` is off. The same decision gates every server-side reminder send. A client that arms local reminders arms them from this, not from `notificationsEnabled`. Read-only — computed, not stored.",
),
nextDueAt: z.iso
.datetime({ offset: true })
.nullable()
@@ -318,6 +324,17 @@ export const medicationResource = z
.describe(
"v1.39.1 — intake tracking. True (the default) for every medication that existed before the field. When false the medication is kept as a record: nothing is ever due (`nextDueAt` stays null), nothing reminds on any channel, and it is excluded from every adherence figure. Its stored schedule then travels in `recordedSchedules` while `schedules` is served empty, so a client that arms reminders from `schedules` stays silent without an update.",
),
autoMarkTaken: z
.boolean()
.describe(
"v1.42.2 — doses are recorded automatically. False (the default) for every medication that existed before the field. When true the server records each scheduled dose as taken (an intake with `autoRecorded: true`, `takenAt` = the slot time) shortly after its time passes, from `autoMarkTakenSince` on. A slot the person took, skipped or removed is never touched, and they can still change or skip any dose. No medication reminder is sent for it on any channel while it is on; a client that arms local reminders should not arm them for it either. `notificationsEnabled` keeps the person's own setting and applies again once this is switched off.",
),
autoMarkTakenSince: z.iso
.datetime({ offset: true })
.nullable()
.describe(
"v1.42.2 — when `autoMarkTaken` was last switched on. No slot anchored before it is ever recorded automatically. NULL while the option is off. Read-only — set by the server on the switch.",
),
createdAt: z.iso.datetime({ offset: true }),
updatedAt: z.iso.datetime({ offset: true }),
schedules: z
@@ -355,6 +372,11 @@ export const medicationListEntry = medicationResource
// even though the shared base leaves them optional for the write paths.
nextDueAt: z.iso.datetime({ offset: true }).nullable(),
nextDueOverdue: z.boolean(),
remindersActive: z
.boolean()
.describe(
"v1.42.2 — whether the server sends dose reminders for this medication: true only when `notificationsEnabled` is on, the medication is `active`, its intake is tracked (`trackIntake`), it is not `asNeeded`, and `autoMarkTaken` is off. The same decision gates every server-side reminder send. A client that arms local reminders arms them from this, not from `notificationsEnabled`. Read-only — computed, not stored.",
),
courseStatus: z
.enum(["UPCOMING", "CURRENT", "ENDED"])
.describe(
@@ -407,6 +429,12 @@ export const medicationListEntry = medicationResource
export const medicationDetailEntry = medicationResource
.extend({
// The single GET always computes it; required here like on the list.
remindersActive: z
.boolean()
.describe(
"v1.42.2 — whether the server sends dose reminders for this medication. See the `Medication` component.",
),
category: medicationCategoryEnum,
categoryLabel: medicationCategoryLabelField,
...medicationCourseFields,
@@ -562,6 +590,11 @@ export const medicationIntakeEventResource = z
.describe(
"True when the nightly cron closed the slot as missed (no user action). Auto-missed rows count against adherence but never consume inventory.",
),
autoRecorded: z
.boolean()
.describe(
'v1.42.2 — true when the server recorded this dose because the medication has `autoMarkTaken` on, not the person. It counts as taken everywhere (adherence, history, Coach) and consumed inventory like a manual take. Any take or skip the person records on the row clears it. Clients label such a dose "recorded automatically".',
),
attributionSource: z
.enum(["AUTO", "USER_PIN"])
.describe(
@@ -1110,6 +1143,11 @@ const doseHistoryRow = z
takenAt: z.iso.datetime({ offset: true }).nullable(),
skipped: z.boolean(),
autoMissed: z.boolean(),
autoRecorded: z
.boolean()
.describe(
"v1.42.2 — the dose was recorded automatically (`autoMarkTaken`), not by the person.",
),
doseTaken: z
.string()
.nullable()
+5
View File
@@ -158,6 +158,11 @@ const syncIntakeUpsert = z
takenAt: z.iso.datetime({ offset: true }).nullable(),
skipped: z.boolean(),
source: z.string(),
autoRecorded: z
.boolean()
.describe(
"v1.42.2 — the server recorded this dose because the medication has `autoMarkTaken` on. Counts as taken.",
),
syncVersion: z
.number()
.int()