feat(contracts): todo, settings, collab and file routes declare their response schemas

shared gains the response schemas these routes answer with (rows in their
storage spelling, as the routes have always sent them) plus the common
success and empty answers, all exported for the client to type its calls
with. Every JSON handler in the four controllers carries its
@ResponseContract; the file download, which streams, is marked exempt. The
files e2e fixture table gains the note_id column the real one has.
This commit is contained in:
Maurice
2026-10-10 15:54:15 +02:00
parent 87071bf738
commit 8e01dbb92f
12 changed files with 378 additions and 7 deletions
+32
View File
@@ -34,3 +34,35 @@ export const weekStartSchema = z.enum(WEEK_START_VALUES);
export const DEFAULT_WEEK_START: WeekStart = 'monday';
/** Date#getDay() of each value, the number a calendar grid computes with. */
export const WEEK_START_DAY: Record<WeekStart, number> = { monday: 1, sunday: 0, saturday: 6 };
// ── Responses ───────────────────────────────────────────────────────────────
/** GET /api/settings: the user's preferences by key, each value as getUserSettings parsed it (secrets masked). */
export const settingsListResponseSchema = z.object({ settings: z.record(z.string(), z.unknown()) });
export type SettingsListResponse = z.infer<typeof settingsListResponseSchema>;
/**
* PUT /api/settings: the key echoed back with what happened to it. `value` when it was
* written, `unchanged` when the masked secret came back as it was, `managed` when a
* managed install keeps the key.
*/
export const settingUpsertResponseSchema = z.object({
success: z.literal(true),
key: z.string(),
value: z.unknown().optional(),
unchanged: z.literal(true).optional(),
managed: z.literal(true).optional(),
});
export type SettingUpsertResponse = z.infer<typeof settingUpsertResponseSchema>;
/** POST /api/settings/bulk: how many keys were written, and the managed keys left alone (only when there were any). */
export const settingsBulkResponseSchema = z.object({
success: z.literal(true),
updated: z.number(),
managed_keys: z.array(z.string()).optional(),
});
export type SettingsBulkResponse = z.infer<typeof settingsBulkResponseSchema>;
/** GET/PUT /api/admin/default-user-settings: the stored defaults a new account starts with, by key. */
export const adminDefaultUserSettingsResponseSchema = z.record(z.string(), z.unknown());
export type AdminDefaultUserSettingsResponse = z.infer<typeof adminDefaultUserSettingsResponseSchema>;