[document-updater] address zod violations (#36147)

* [editor-core] address zod violation for group_id

* [monorepo] use discriminated union in zod schemas where possible

* [editor-core] v1_source_doc_id is a number

GitOrigin-RevId: 38f591b07cca4e22954bfe30bf855545a6af675d
This commit is contained in:
Jakob Ackermann
2026-09-17 11:46:42 +00:00
committed by Copybot
parent 7895541382
commit 0776357d1a
5 changed files with 201 additions and 9 deletions
@@ -651,7 +651,11 @@ const updateProjectSchema = z.object({
body: z.strictObject({
projectHistoryId: z.union([z.number(), zz.projectHistoryId()]).optional(),
userId: zz.objectId().nullish(),
updates: z.array(renameUpdateSchema.or(addUpdateSchema)).default([]),
updates: z
.array(
z.discriminatedUnion('type', [renameUpdateSchema, addUpdateSchema])
)
.default([]),
version: z.union([z.number(), z.string()]),
// `source` is polymorphic (see Utils.extractOriginOrSource): either a
// plain descriptive string (e.g. 'editor' for live user edits) or the
@@ -680,7 +684,12 @@ const updateProjectFallbackSchema = z.object({
projectHistoryId: z.union([z.number(), z.string()]).optional(),
userId: z.string().nullish(),
updates: z
.array(renameUpdateFallbackSchema.or(addUpdateFallbackSchema))
.array(
z.discriminatedUnion('type', [
renameUpdateFallbackSchema,
addUpdateFallbackSchema,
])
)
.default([]),
version: z.union([z.number(), z.string()]),
// loosened equivalent of editorCoreSchemas.rawOrigin -- see the same