feat(core): initial implementation of syncing (#17814)
This commit is contained in:
13
packages/opencode/src/util/update-schema.ts
Normal file
13
packages/opencode/src/util/update-schema.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import z from "zod"
|
||||
|
||||
export function updateSchema<T extends z.ZodRawShape>(schema: z.ZodObject<T>) {
|
||||
const next = {} as {
|
||||
[K in keyof T]: z.ZodOptional<z.ZodNullable<T[K]>>
|
||||
}
|
||||
|
||||
for (const [k, v] of Object.entries(schema.required().shape) as [keyof T & string, z.ZodTypeAny][]) {
|
||||
next[k] = v.nullable() as unknown as (typeof next)[typeof k]
|
||||
}
|
||||
|
||||
return z.object(next)
|
||||
}
|
||||
Reference in New Issue
Block a user