mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 06:06:10 +00:00
Merge branch 'feat/v144-userneeds' into release/v1.44.0
# Conflicts: # src/__tests__/sharing-surface-guard.test.ts # src/__tests__/workout-canonical-identity-guard.test.ts
This commit is contained in:
commit
aa899a9d54
86 files changed
+12949
-9
No files matched your search
@@ -61,6 +61,7 @@ import {
|
||||
import { UNREADABLE_EXPORT_MARKER } from "@/lib/export/unreadable-marker";
|
||||
import { locales } from "@/lib/i18n/config";
|
||||
import { thresholdsUpdateSchema } from "@/lib/validations/thresholds";
|
||||
import { activityGoalsSchema } from "@/lib/validations/activity-goals";
|
||||
import { isPublicUrl } from "@/lib/validations/notifications";
|
||||
import {
|
||||
glucoseUnitPatchSchema,
|
||||
@@ -267,6 +268,37 @@ const thresholds: SettingCodec = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The activity goals, goal by goal. A goal outside its bounds, or a key this
|
||||
* release does not know, is dropped and named; the valid goals beside it
|
||||
* still come back.
|
||||
*/
|
||||
const activityGoals: SettingCodec = {
|
||||
write: (row) => ({ activityGoalsJson: row.activityGoalsJson ?? null }),
|
||||
read: (entry) => {
|
||||
if (!has(entry, "activityGoalsJson")) return undefined;
|
||||
const value = entry.activityGoalsJson;
|
||||
if (value === null) return Prisma.DbNull;
|
||||
if (typeof value !== "object" || Array.isArray(value)) {
|
||||
return new Refused("activityGoalsJson");
|
||||
}
|
||||
const kept: Record<string, number> = {};
|
||||
const refused: string[] = [];
|
||||
for (const [key, goal] of Object.entries(value)) {
|
||||
const parsed = activityGoalsSchema.safeParse({ [key]: goal });
|
||||
if (!parsed.success) {
|
||||
refused.push(`activityGoalsJson.${key}`);
|
||||
} else if (typeof goal === "number") {
|
||||
kept[key] = goal;
|
||||
}
|
||||
}
|
||||
return new PartlyRefused(
|
||||
Object.keys(kept).length === 0 ? Prisma.DbNull : kept,
|
||||
refused,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
const injectionSites = Object.values(InjectionSite) as string[];
|
||||
|
||||
/** The injection sites to avoid everywhere; an unknown site is dropped. */
|
||||
@@ -505,6 +537,7 @@ const ACCOUNT_SETTING_CODECS: Readonly<
|
||||
documentsLayoutJson: json("documentsLayoutJson"),
|
||||
moduleListLayoutJson: json("moduleListLayoutJson"),
|
||||
previewFeaturesJson: json("previewFeaturesJson"),
|
||||
activityGoalsJson: activityGoals,
|
||||
reportSelectionJson: json("reportSelectionJson"),
|
||||
globalExcludedInjectionSites: excludedSites,
|
||||
healthKitConfigJson: json("healthKitConfigJson"),
|
||||
|
||||
@@ -1019,6 +1019,7 @@ export const USER_COLUMN_BACKUP_CLASS = {
|
||||
documentsLayoutJson: "SETTING",
|
||||
moduleListLayoutJson: "SETTING",
|
||||
previewFeaturesJson: "SETTING",
|
||||
activityGoalsJson: "SETTING",
|
||||
reportSelectionJson: "SETTING",
|
||||
globalExcludedInjectionSites: "SETTING",
|
||||
healthKitConfigJson: "SETTING",
|
||||
|
||||
Reference in new issue
Block a user