import { z } from "zod"; import { bucketSchema, googleSchema } from "@/schema/public/asset/asset.schema"; // bucket fields may be absent in partially-populated JSONB asset objects const partialBucketSchema = bucketSchema.partial().nullable(); const partialGoogleSchema = googleSchema.partial().nullable(); /** * Covers all file format types in the asset_object JSONB column, including * text formats (word, opendocument_text) used by supplementary and lesson guide assets. * * Uses partial+nullable bucket schemas because asset_object JSONB can contain * bucket entries with absent fields when content has not been fully populated. */ export const publishedAssetObjectSchema = z .object({ pdf: partialBucketSchema, powerpoint: partialBucketSchema, opendocument_presentation: partialBucketSchema, word: partialBucketSchema, opendocument_text: partialBucketSchema, google_drive: partialGoogleSchema, google_slide: partialGoogleSchema, }) .partial(); export type PublishedAssetObject = z.infer;