import { z } from "zod/mini" import type { GroupModel } from "./group" import { GroupModelSchema } from "./group" import type { NestableModel } from "./nestable" import { NestableModelSchema } from "./nestable" import { SliceModelTypeSchema } from "./slice" import type { DynamicSlicesModel, StaticSlicesModel } from "./slices" import { DynamicSlicesModelSchema, StaticSlicesModelSchema } from "./slices" import type { UIDModel } from "./uid" import { UIDModelSchema } from "./uid" // StaticWidget = UID | Nestable | Group | StaticSlices export const StaticWidgetModelSchema: z.ZodMiniType = z.discriminatedUnion( "type", [UIDModelSchema, NestableModelSchema, GroupModelSchema, StaticSlicesModelSchema], ) export type StaticWidgetModel = UIDModel | NestableModel | GroupModel | StaticSlicesModel // DynamicWidget = UID | Nestable | Group | DynamicSlices export const DynamicWidgetModelSchema: z.ZodMiniType = z.discriminatedUnion( "type", [UIDModelSchema, NestableModelSchema, GroupModelSchema, DynamicSlicesModelSchema], ) export type DynamicWidgetModel = UIDModel | NestableModel | GroupModel | DynamicSlicesModel // FieldModelType - all possible field type strings export const FieldModelTypeSchema = z.enum([ "Color", "Boolean", "Number", "Embed", "GeoPoint", "Date", "Range", "StructuredText", "Select", "Separator", "Table", "Text", "Timestamp", "Link", "Image", "IntegrationFields", "UID", "Group", "Slices", "Choice", ]) export type FieldModelType = z.infer // Field and slice types export const FieldOrSliceTypeSchema = z.union([ FieldModelTypeSchema, SliceModelTypeSchema, // Repeatable links are "meta" types like slices and shared slices z.literal("Repeatable.Link"), ]) export type FieldOrSliceType = z.infer