mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 07:42:23 +00:00
Give custom-metric values the same second chance as every other entry
Refs A3-11. Deleting a logged custom-metric value was the one hard delete left on an entry surface — everywhere else a deletion tombstones and the toast offers Undo. The DELETE verb now stamps deletedAt, every read (list, latest-value, counts, revive check) filters the tombstone, and the new entries/restore endpoint clears it scoped to owner and parent metric — a foreign, live or mismatched id is a silent no-op, never an existence leak. The history table's delete toast carries the Undo action.
This commit is contained in:
1 parent
689cacc039
commit
7bf8dbd8af
14 files changed
+467
-23
No files matched your search
@@ -340,7 +340,7 @@ export const customMetricPaths: NonNullable<ZodOpenApiObject["paths"]> = {
|
||||
tags: ["Custom metrics"],
|
||||
summary: "Delete a logged value",
|
||||
description:
|
||||
"Hard-deletes the value. Audits as `customMetricEntry.delete`.",
|
||||
"Tombstones the value (soft delete, v1.37.20); the sibling entries/restore endpoint clears the tombstone. Audits as `customMetricEntry.delete`.",
|
||||
requestParams: {
|
||||
path: z.object({ id: z.string(), entryId: z.string() }),
|
||||
},
|
||||
@@ -361,4 +361,37 @@ export const customMetricPaths: NonNullable<ZodOpenApiObject["paths"]> = {
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/custom-metrics/{id}/entries/restore": {
|
||||
post: {
|
||||
tags: ["Custom metrics"],
|
||||
summary: "Restore tombstoned values (v1.37.20)",
|
||||
description:
|
||||
"Clears deletedAt on every owned, currently-tombstoned entry of this metric named in ids (1..200). A foreign, live or mismatched-parent id is a silent no-op, never an existence leak. Backs the delete toast's Undo. Audits as `customMetricEntry.restore`.",
|
||||
requestParams: { path: z.object({ id: z.string() }) },
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z
|
||||
.object({ ids: z.array(z.string().min(1)).min(1).max(200) })
|
||||
.meta({ id: "RestoreCustomMetricEntriesRequest" }),
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "Count of entries restored.",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: dataEnvelope(
|
||||
z.object({ restored: z.number().int() }),
|
||||
"RestoreCustomMetricEntriesResponse",
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
...stdResponses,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user