mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
feat: describe managed sharing activity
Every action a manage-level route files now renders as its own sentence in the owner's activity view, in all six locales. A write delegate can only add, so the generic "made a change" was at least the right shape of fact; a manager changes and removes entries the owner made themselves, and the generic line withholds the only part that matters — whether a reading was corrected or deleted, whether a dose history was purged. The inventory reads the routes and calls the map rather than matching `case` in its source, so an action that falls through to the fallback fails, and it follows each resolved key into all six bundles. Every sentence interpolates the actor's name and nothing else: the audit table is not encrypted and a value in a verb line would be a health figure in a second store. The revoke dialog's retention disclosure no longer depends on which of two requests answers first. `retentionDays` rides the grant list, so a client holding a row to revoke holds the window it must state, and the branch that omitted the sentence is gone.
This commit is contained in:
1 parent
25b1b0eab6
commit
c92a80ee4c
15 files changed
+1131
-61
No files matched your search
@@ -111,6 +111,12 @@ const grantListResponse = z
|
||||
.object({
|
||||
given: z.array(grantView),
|
||||
received: z.array(grantView),
|
||||
retentionDays: z
|
||||
.number()
|
||||
.int()
|
||||
.describe(
|
||||
"How long the record's activity feed can still attribute an entry to the person who made it, in days. Resolved from the instance's audit retention setting (365 by default, operator-configurable), NOT a constant. It rides this payload so a client ending an access can state the window in the same breath, without a second request whose timing would decide whether the owner was told.",
|
||||
),
|
||||
})
|
||||
.meta({
|
||||
id: "AccountGrantList",
|
||||
|
||||
@@ -65,6 +65,16 @@ export interface GrantList {
|
||||
given: GrantRow[];
|
||||
/** Grants offered to this account on somebody else's. */
|
||||
received: GrantRow[];
|
||||
/**
|
||||
* How long the activity feed can still say who entered what, in days —
|
||||
* resolved by the server from the same setting the purge job reads.
|
||||
*
|
||||
* On this payload rather than fetched beside it, because the revoke dialog
|
||||
* has to disclose the window and a client holding a grant to revoke is
|
||||
* already holding the answer. Reading it off a second request made the
|
||||
* sentence appear or not depending on which read landed first.
|
||||
*/
|
||||
retentionDays: number;
|
||||
}
|
||||
|
||||
export interface RecordActivityEntry {
|
||||
|
||||
@@ -16,10 +16,34 @@ type Translator = (
|
||||
* mark a dose taken — and "made a change" for seven different things is a way
|
||||
* of answering nothing. An owner reading this at breakfast wants the verb.
|
||||
*
|
||||
* The map keeps a line for allergies, family history and a tracked value even
|
||||
* though a delegate can no longer add any of the three: rows written while
|
||||
* they were admitted sit in the same table and still have to render as
|
||||
* something, which is the same reason the fallback below exists.
|
||||
* The map keeps a line for a tracked value even though a delegate can no
|
||||
* longer add one: rows written while it was admitted sit in the same table and
|
||||
* still have to render as something, which is the same reason the fallback
|
||||
* below exists.
|
||||
*
|
||||
* ## v1.37.0 — the MANAGE half
|
||||
*
|
||||
* A WRITE delegate can only add, so the generic line was at least the right
|
||||
* shape of fact. A MANAGE delegate changes and removes entries the owner made
|
||||
* themselves, and there "somebody made a change in your record" withholds the
|
||||
* only part that matters: whether a reading was corrected or deleted, whether
|
||||
* a medication was stopped, whether a whole dose history was purged. The level
|
||||
* ships under "reconstructable or refused", and a feed that cannot say which
|
||||
* verb ran reconstructs nothing.
|
||||
*
|
||||
* So every action a MANAGE-declared route files has an arm below, and
|
||||
* `src/__tests__/manage-activity-inventory.test.ts` reads the routes to prove
|
||||
* it — by CALLING this function, not by matching `case` in its source, so an
|
||||
* action that quietly falls through to the fallback fails there.
|
||||
*
|
||||
* ## What a line may say
|
||||
*
|
||||
* The verb and the kind of thing, never the value. Every sentence here takes
|
||||
* `name` and nothing else, and the inventory guard holds that across all six
|
||||
* bundles. The activity feed reads out of the audit table, which is not
|
||||
* encrypted and has its own retention: "changed your weight from 81 to 78"
|
||||
* would put a health figure in a second store with no rotation story. What
|
||||
* changed is a question the record itself answers.
|
||||
*
|
||||
* ## Why unknown actions fall back rather than fail
|
||||
*
|
||||
@@ -82,6 +106,156 @@ export function recordActivityVerbLine(
|
||||
// client sent them together.
|
||||
case "measurement.create.batch":
|
||||
return t("recordSharing.activityVerb.measurementCreate", { name });
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* v1.37.0 — MANAGE. Everything below can change or remove something */
|
||||
/* the owner put there themselves. */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
case "measurement.update":
|
||||
return t("recordSharing.activityVerb.measurementUpdate", { name });
|
||||
case "measurement.delete":
|
||||
return t("recordSharing.activityVerb.measurementDelete", { name });
|
||||
// Its own line rather than the singular one. "Removed a reading" for a
|
||||
// bulk delete is the sentence that would let a month of readings go
|
||||
// missing while the feed reported a tidy-up.
|
||||
case "measurement.delete.bulk":
|
||||
return t("recordSharing.activityVerb.measurementDeleteBulk", { name });
|
||||
case "measurement.restore":
|
||||
return t("recordSharing.activityVerb.measurementRestore", { name });
|
||||
case "measurementReminder.create":
|
||||
return t("recordSharing.activityVerb.measurementReminderCreate", {
|
||||
name,
|
||||
});
|
||||
case "measurementReminder.update":
|
||||
return t("recordSharing.activityVerb.measurementReminderUpdate", {
|
||||
name,
|
||||
});
|
||||
case "measurementReminder.delete":
|
||||
return t("recordSharing.activityVerb.measurementReminderDelete", {
|
||||
name,
|
||||
});
|
||||
case "measurementReminder.complete":
|
||||
return t("recordSharing.activityVerb.measurementReminderComplete", {
|
||||
name,
|
||||
});
|
||||
case "measurementReminder.satisfy":
|
||||
return t("recordSharing.activityVerb.measurementReminderSatisfy", {
|
||||
name,
|
||||
});
|
||||
|
||||
case "labResult.update":
|
||||
return t("recordSharing.activityVerb.labResultUpdate", { name });
|
||||
case "labResult.delete":
|
||||
return t("recordSharing.activityVerb.labResultDelete", { name });
|
||||
case "labResult.restore":
|
||||
return t("recordSharing.activityVerb.labResultRestore", { name });
|
||||
case "biomarker.update":
|
||||
return t("recordSharing.activityVerb.biomarkerUpdate", { name });
|
||||
case "biomarker.delete":
|
||||
return t("recordSharing.activityVerb.biomarkerDelete", { name });
|
||||
|
||||
case "allergy.update":
|
||||
return t("recordSharing.activityVerb.allergyUpdate", { name });
|
||||
case "allergy.delete":
|
||||
return t("recordSharing.activityVerb.allergyDelete", { name });
|
||||
case "family-history.update":
|
||||
return t("recordSharing.activityVerb.familyHistoryUpdate", { name });
|
||||
case "family-history.delete":
|
||||
return t("recordSharing.activityVerb.familyHistoryDelete", { name });
|
||||
|
||||
case "illness.episode.update":
|
||||
return t("recordSharing.activityVerb.illnessEpisodeUpdate", { name });
|
||||
case "illness.episode.delete":
|
||||
return t("recordSharing.activityVerb.illnessEpisodeDelete", { name });
|
||||
case "illness.episode.resolve":
|
||||
return t("recordSharing.activityVerb.illnessEpisodeResolve", { name });
|
||||
case "illness.episode.restore":
|
||||
return t("recordSharing.activityVerb.illnessEpisodeRestore", { name });
|
||||
case "illness.day-log.upsert":
|
||||
return t("recordSharing.activityVerb.illnessDayLogUpsert", { name });
|
||||
|
||||
case "medication.update":
|
||||
return t("recordSharing.activityVerb.medicationUpdate", { name });
|
||||
case "medication.delete":
|
||||
return t("recordSharing.activityVerb.medicationDelete", { name });
|
||||
case "medication.glp1.update":
|
||||
return t("recordSharing.activityVerb.medicationGlp1Update", { name });
|
||||
case "medication.schedule_revision.created":
|
||||
return t("recordSharing.activityVerb.medicationScheduleCreate", { name });
|
||||
case "medication.schedule_revision.updated":
|
||||
return t("recordSharing.activityVerb.medicationScheduleUpdate", { name });
|
||||
case "medication.schedule_revision.deleted":
|
||||
return t("recordSharing.activityVerb.medicationScheduleDelete", { name });
|
||||
case "medication.inventory.create":
|
||||
return t("recordSharing.activityVerb.medicationInventoryCreate", {
|
||||
name,
|
||||
});
|
||||
case "medication.inventory.update":
|
||||
return t("recordSharing.activityVerb.medicationInventoryUpdate", {
|
||||
name,
|
||||
});
|
||||
case "medication.inventory.delete":
|
||||
return t("recordSharing.activityVerb.medicationInventoryDelete", {
|
||||
name,
|
||||
});
|
||||
case "medication.sideEffect.delete":
|
||||
return t("recordSharing.activityVerb.medicationSideEffectDelete", {
|
||||
name,
|
||||
});
|
||||
case "medication.intake.update":
|
||||
return t("recordSharing.activityVerb.medicationIntakeUpdate", { name });
|
||||
case "medication.intake.delete":
|
||||
return t("recordSharing.activityVerb.medicationIntakeDelete", { name });
|
||||
case "medication.intake.bulk_delete":
|
||||
return t("recordSharing.activityVerb.medicationIntakeBulkDelete", {
|
||||
name,
|
||||
});
|
||||
// The one that empties a medication's whole history in one request. It
|
||||
// says so, because "removed several doses" would read as a correction.
|
||||
case "medication.intake.purge":
|
||||
return t("recordSharing.activityVerb.medicationIntakePurge", { name });
|
||||
case "medication.intake.import.kickoff":
|
||||
return t("recordSharing.activityVerb.medicationIntakeImport", { name });
|
||||
case "medication.intake.history.import.kickoff":
|
||||
return t("recordSharing.activityVerb.medicationIntakeHistoryImport", {
|
||||
name,
|
||||
});
|
||||
|
||||
case "moodEntry.create":
|
||||
return t("recordSharing.activityVerb.moodEntryCreate", { name });
|
||||
case "moodEntry.update":
|
||||
return t("recordSharing.activityVerb.moodEntryUpdate", { name });
|
||||
case "moodEntry.delete":
|
||||
return t("recordSharing.activityVerb.moodEntryDelete", { name });
|
||||
case "mood.delete.bulk":
|
||||
return t("recordSharing.activityVerb.moodDeleteBulk", { name });
|
||||
case "mood.restore":
|
||||
return t("recordSharing.activityVerb.moodRestore", { name });
|
||||
case "mental-health.create":
|
||||
return t("recordSharing.activityVerb.mentalHealthCreate", { name });
|
||||
|
||||
case "cycle.cycle.delete":
|
||||
return t("recordSharing.activityVerb.cycleDelete", { name });
|
||||
case "cycle.day-log.upsert":
|
||||
return t("recordSharing.activityVerb.cycleDayLogUpsert", { name });
|
||||
case "cycle.day-log.update":
|
||||
return t("recordSharing.activityVerb.cycleDayLogUpdate", { name });
|
||||
case "cycle.day-log.delete":
|
||||
return t("recordSharing.activityVerb.cycleDayLogDelete", { name });
|
||||
case "cycle.period.boundary":
|
||||
return t("recordSharing.activityVerb.cyclePeriodBoundary", { name });
|
||||
case "cycle.symptom.custom.create":
|
||||
return t("recordSharing.activityVerb.cycleSymptomCreate", { name });
|
||||
|
||||
case "nutrient.water.write":
|
||||
return t("recordSharing.activityVerb.nutrientWaterWrite", { name });
|
||||
|
||||
// Not a change to the record, and the one act on this list that takes a
|
||||
// copy of all of it out of the instance. Named plainly for that reason.
|
||||
case "health-record.export":
|
||||
return t("recordSharing.activityVerb.healthRecordExport", { name });
|
||||
|
||||
default:
|
||||
return t("recordSharing.activity.acted", { name });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user