|
| 1 | +import * as myzod from 'myzod' |
| 2 | +import { AttributeInput, ButtonComponentType, ComponentInput, DropDownComponentInput, EventArgumentInput, EventInput, EventOptionType, HttpInput, HttpMethod, LayoutInput, PageInput, PageType } from '../types' |
| 3 | + |
| 4 | +export const definedNonNullAnySchema = myzod.object({}); |
| 5 | + |
| 6 | +export function AttributeInputSchema(): myzod.Type<AttributeInput> { |
| 7 | + return myzod.object({ |
| 8 | + key: myzod.string().optional().nullable(), |
| 9 | + val: myzod.string().optional().nullable() |
| 10 | + }) |
| 11 | +} |
| 12 | + |
| 13 | +export const ButtonComponentTypeSchema = myzod.enum(ButtonComponentType); |
| 14 | + |
| 15 | +export function ComponentInputSchema(): myzod.Type<ComponentInput> { |
| 16 | + return myzod.object({ |
| 17 | + child: myzod.lazy(() => ComponentInputSchema().optional().nullable()), |
| 18 | + childrens: myzod.array(myzod.lazy(() => ComponentInputSchema().nullable())).optional().nullable(), |
| 19 | + event: myzod.lazy(() => EventInputSchema().optional().nullable()), |
| 20 | + name: myzod.string(), |
| 21 | + type: ButtonComponentTypeSchema |
| 22 | + }) |
| 23 | +} |
| 24 | + |
| 25 | +export function DropDownComponentInputSchema(): myzod.Type<DropDownComponentInput> { |
| 26 | + return myzod.object({ |
| 27 | + dropdownComponent: myzod.lazy(() => ComponentInputSchema().optional().nullable()), |
| 28 | + getEvent: myzod.lazy(() => EventInputSchema()) |
| 29 | + }) |
| 30 | +} |
| 31 | + |
| 32 | +export function EventArgumentInputSchema(): myzod.Type<EventArgumentInput> { |
| 33 | + return myzod.object({ |
| 34 | + name: myzod.string().min(5), |
| 35 | + value: myzod.string().pattern(/^foo/) |
| 36 | + }) |
| 37 | +} |
| 38 | + |
| 39 | +export function EventInputSchema(): myzod.Type<EventInput> { |
| 40 | + return myzod.object({ |
| 41 | + arguments: myzod.array(myzod.lazy(() => EventArgumentInputSchema())), |
| 42 | + options: myzod.array(EventOptionTypeSchema).optional().nullable() |
| 43 | + }) |
| 44 | +} |
| 45 | + |
| 46 | +export const EventOptionTypeSchema = myzod.enum(EventOptionType); |
| 47 | + |
| 48 | +export function HttpInputSchema(): myzod.Type<HttpInput> { |
| 49 | + return myzod.object({ |
| 50 | + method: HttpMethodSchema.optional().nullable(), |
| 51 | + url: definedNonNullAnySchema |
| 52 | + }) |
| 53 | +} |
| 54 | + |
| 55 | +export const HttpMethodSchema = myzod.enum(HttpMethod); |
| 56 | + |
| 57 | +export function LayoutInputSchema(): myzod.Type<LayoutInput> { |
| 58 | + return myzod.object({ |
| 59 | + dropdown: myzod.lazy(() => DropDownComponentInputSchema().optional().nullable()) |
| 60 | + }) |
| 61 | +} |
| 62 | + |
| 63 | +export function PageInputSchema(): myzod.Type<PageInput> { |
| 64 | + return myzod.object({ |
| 65 | + attributes: myzod.array(myzod.lazy(() => AttributeInputSchema())).optional().nullable(), |
| 66 | + date: definedNonNullAnySchema.optional().nullable(), |
| 67 | + height: myzod.number(), |
| 68 | + id: myzod.string(), |
| 69 | + layout: myzod.lazy(() => LayoutInputSchema()), |
| 70 | + pageType: PageTypeSchema, |
| 71 | + postIDs: myzod.array(myzod.string()).optional().nullable(), |
| 72 | + show: myzod.boolean(), |
| 73 | + tags: myzod.array(myzod.string().nullable()).optional().nullable(), |
| 74 | + title: myzod.string(), |
| 75 | + width: myzod.number() |
| 76 | + }) |
| 77 | +} |
| 78 | + |
| 79 | +export const PageTypeSchema = myzod.enum(PageType); |
0 commit comments