import { z } from "zod/mini" import { GroupItemContentSchema, NestableAndGroupContentSchema } from "./group" import { NestableContentSchema } from "./nestable" // Legacy (before 2020) export const LegacySliceContentSchema = NestableAndGroupContentSchema export type LegacySliceContent = z.infer // Composite (2020 to 2021) export const CompositeSliceContentType = "CompositeSliceContent" as const export const CompositeSliceContentSchema = z.object({ __TYPE__: z.literal(CompositeSliceContentType), nonRepeat: z.record(z.string(), NestableContentSchema), repeat: z.array(GroupItemContentSchema), }) export type CompositeSliceContent = z.infer // Shared (2021 to present) export const SharedSliceContentType = "SharedSliceContent" as const export const SharedSliceContentSchema = z.object({ __TYPE__: z.literal(SharedSliceContentType), variation: z.string(), primary: z.record(z.string(), NestableAndGroupContentSchema), items: z.array(GroupItemContentSchema), }) export type SharedSliceContent = z.infer // All export const SliceContentSchema: z.ZodMiniType = z.discriminatedUnion("__TYPE__", [ LegacySliceContentSchema, CompositeSliceContentSchema, SharedSliceContentSchema, ]) export type SliceContent = LegacySliceContent | CompositeSliceContent | SharedSliceContent