import { z } from "zod"; import zodToCamelCase from "zod-to-camel-case"; import { _stateSchema, _cohortSchema, timestampsSchema, newState, publishedState, } from "@/schema/public/components/base/base.schema"; import { assetIngestStatesSchema, baseIngestStatesSchema, videoIngestStatesSchema, } from "@/schema/internal/components/internal/internal.schema"; const emptyJsonObjectSchema = z.object({}); const reviewLessonApprovalIngestStateSchema = z.union([ z.literal("ingest"), baseIngestStatesSchema, assetIngestStatesSchema, videoIngestStatesSchema, ]); const oakReviewStatusSchema = z.enum([ "approved", "complete", "in-progress", "n-a", "not-started", ]); const partnerReviewStatusSchema = z.enum([ "approved-not-used", "approved-oak", "in-progress", "not-started", "not-used", "oak-edits-complete", "oak-edits-required", "oak-subject-review-in-progress", "ready-for-techincal-review", "ready-subject-review", "reviewed-needs-amends", "reviewed-ready-oak", "subject-review-in-progress", "technical-review-in-progress", "working-on-amends", ]); const oakReviewsSchema = z .object({ stage_1_creation_progress_status: oakReviewStatusSchema, stage_1_oak_moderation_status: oakReviewStatusSchema, stage_1_oak_subject_qa_status: oakReviewStatusSchema, stage_1_oak_technical_qa_status: oakReviewStatusSchema, stage_2_creation_progress_status: oakReviewStatusSchema, stage_2_oak_moderation_status: oakReviewStatusSchema, stage_2_oak_subject_qa_status: oakReviewStatusSchema, stage_2_oak_technical_qa_status: oakReviewStatusSchema, }) .strict(); const partnerReviewsSchema = z .object({ exit_quiz_status: partnerReviewStatusSchema, lesson_info_status: partnerReviewStatusSchema, slide_deck_status: partnerReviewStatusSchema, starter_quiz_status: partnerReviewStatusSchema, supplementary_resource_status: partnerReviewStatusSchema, video_status: partnerReviewStatusSchema, worksheet_answers_status: partnerReviewStatusSchema, worksheet_status: partnerReviewStatusSchema, lesson_guide_status: partnerReviewStatusSchema.optional(), media_clips_status: partnerReviewStatusSchema.optional(), }) .strict(); const reviewLessonApprovalApproverSchema = z .object({ email: z.string().optional(), externalIdentifier: z.string().optional(), firstName: z.string().optional(), fullName: z.string().optional(), groups: z.string().optional(), id: z.string().optional(), lastName: z.string().optional(), metadata: z.record(z.string(), z.unknown()).optional(), name: z.string().optional(), profilePhotoUrl: z.string().optional(), sid: z.string().optional(), }) .catchall(z.unknown()); const reviewLessonApprovalSchema = z.object({ date: z.string(), approver: reviewLessonApprovalApproverSchema, ingest: z .object({ lesson_guide: reviewLessonApprovalIngestStateSchema.optional(), quiz: reviewLessonApprovalIngestStateSchema.optional(), slidedeck: reviewLessonApprovalIngestStateSchema.optional(), supplementary_resources: reviewLessonApprovalIngestStateSchema.optional(), video: reviewLessonApprovalIngestStateSchema.optional(), worksheet: reviewLessonApprovalIngestStateSchema.optional(), worksheet_answers: reviewLessonApprovalIngestStateSchema.optional(), }) .optional(), }); export const reviewLessonsSchema = timestampsSchema.extend({ lesson_id: z.number(), lesson_uid: z.string().nullable(), partner_reviews: partnerReviewsSchema, oak_reviews: oakReviewsSchema, // reviewers: reviewLessonJsonValueSchema.nullable(), -- not used // moderators: reviewLessonJsonValueSchema.nullable(), -- not used _cohort: _cohortSchema, _state: _stateSchema, _deleted: z.boolean(), oak_approval: z.union([ emptyJsonObjectSchema, z.array(reviewLessonApprovalSchema), ]), status_lesson: z.string(), status_slidedeck: z.string(), status_worksheet: z.string(), status_worksheet_answers: z.string(), status_supplementary_resources: z.string(), status_quiz: z.string(), status_video: z.string(), status_video_mux: z.string(), status_video_rev: z.string(), release_uid: z.string().nullable(), // linked_objects: reviewLessonJsonValueSchema, -- a denormalized array of linked objects, not used in the application _release_id: z.number().nullable(), status_lesson_guide: z.string(), status_media_clips: z.string(), status_downloadable_files: z.string(), }); export type ReviewLessons = z.infer; export const reviewLessonsNewSchema = reviewLessonsSchema.extend({ _state: newState, }); export type ReviewLessonsNew = z.infer; export const reviewLessonsPublishedSchema = reviewLessonsSchema.extend({ _state: publishedState, }); export type ReviewLessonsPublished = z.infer< typeof reviewLessonsPublishedSchema >; export const reviewLessonsSchemaCamel = zodToCamelCase(reviewLessonsSchema); export type ReviewLessonsCamel = z.infer; export const reviewLessonsNewSchemaCamel = zodToCamelCase( reviewLessonsNewSchema, ); export type ReviewLessonsNewCamel = z.infer; export const reviewLessonsPublishedSchemaCamel = zodToCamelCase( reviewLessonsPublishedSchema, ); export type ReviewLessonsPublishedCamel = z.infer< typeof reviewLessonsPublishedSchemaCamel >;