Files
spark a693057270
ci / rust (push) Successful in 7m1s
ci / typescript (push) Failing after 8m45s
Live client galleries, proofing (favourites, comments) and ZIP downloads; PATCH keeps fields
Live galleries fill themselves from their event (picks, or every ready photo) while the match is on; photos taken
out by hand stay out. Clients mark favourites and comment (approved by the photographer); the app shows the
selection, exports CSV, copies file names and labels the favourites in the library. Orders download as one ZIP,
and free galleries get "download all". Fixes PATCH on galleries, sites and print events resetting fields to their
defaults (a title change made a private gallery public).

Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-13 03:09:46 +01:00

17 lines
771 B
TypeScript

import { z } from "zod";
type Undefaulted<T> = T extends z.ZodDefault<infer Inner> ? Inner : T;
/**
* The schema for a PATCH: every field optional and no defaults. zod's `.partial()` keeps `.default()`s, so a
* PATCH that leaves a field out would reset it (a private gallery would turn public on a title change).
*/
export function patchOf<Shape extends z.ZodRawShape>(schema: z.ZodObject<Shape>) {
const shape: Record<string, z.ZodType> = {};
for (const [key, field] of Object.entries(schema.shape)) {
const inner = field instanceof z.ZodDefault ? (field.unwrap() as z.ZodType) : (field as z.ZodType);
shape[key] = inner.optional();
}
return z.object(shape) as unknown as z.ZodObject<{ [K in keyof Shape]: z.ZodOptional<Undefaulted<Shape[K]>> }>;
}