import { z } from "zod/mini" import { CompositeSliceContentSchema, SharedSliceContentSchema, LegacySliceContentSchema, SliceContentSchema, } from "./slice" // Item const getSliceItemContentSchema = < TWidgetSchema extends | typeof LegacySliceContentSchema | typeof CompositeSliceContentSchema | typeof SharedSliceContentSchema | typeof SliceContentSchema, >( widgetSchema: TWidgetSchema, ) => { return z.object({ key: z.string(), name: z.string(), maybeLabel: z.optional(z.string()), widget: widgetSchema, }) } export const LegacySliceItemContentSchema = getSliceItemContentSchema(LegacySliceContentSchema) export type LegacySliceItemContent = z.infer export const CompositeSliceItemContentSchema = getSliceItemContentSchema( CompositeSliceContentSchema, ) export type CompositeSliceItemContent = z.infer export const SharedSliceItemContentSchema = getSliceItemContentSchema(SharedSliceContentSchema) export type SharedSliceItemContent = z.infer // All export const SliceItemContentSchema = getSliceItemContentSchema(SliceContentSchema) export type SliceItemContent = z.infer // Slices // Typo (missing `s`) is legacy... export const SlicesContentType = "SliceContentType" as const export const SlicesContentSchema = z.object({ __TYPE__: z.literal(SlicesContentType), value: z.array(SliceItemContentSchema), }) export type SlicesContent = z.infer