mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user