import {z} from 'zod' export type AssessmentAnswer = {id?: (string | null) | undefined, answer: string, correct?: (boolean | null) | undefined, position?: number | undefined, explanation?: (string | null) | undefined}; export type LessonImageInQuestionSerializers = {id?: string | undefined, company?: (string | null) | undefined, image_name?: (string | null) | undefined, image_url?: (string | null) | undefined, image_url_public?: (string | null) | undefined, editor_content?: (string | null) | undefined, content_type?: ('lesson' | 'quiz' | 'engagement_question' | 'engagement_message' | 'assessment_question_content' | null) | undefined}; export type EditorStateInQuestionSerializers = {id?: string | undefined, note_editor_state?: (string | null) | undefined, summary_editor_state?: (string | null) | undefined, question_editor_state?: (string | null) | undefined, quiz_editor_state?: (string | null) | undefined, quiz_message_state?: (string | null) | undefined, content?: Array | undefined}; export type AssessmentQuestion = {id?: (string | null) | undefined, position?: number | undefined, answers?: Array | undefined, editor_content?: EditorStateInQuestionSerializers | undefined, image_ids?: (Array) | undefined, slack_markup?: string | undefined, single_select?: boolean | undefined, single_correct?: boolean | undefined}; export type Assessment = {id?: string | undefined, questions: Array, created?: string | undefined, modified?: string | undefined, title: string, company?: (string | null) | undefined}; export type TrainingCompanyAssessment = {id?: string | undefined, assessment: Assessment, created?: string | undefined, modified?: string | undefined, passing_grade?: number | undefined, retake_status?: ('optional' | 'force_retake' | 'force_continue') | undefined, is_active?: boolean | undefined, position?: number | undefined, polymorphic_ctype?: number | undefined, company: string, created_by?: (string | null) | undefined, curriculum: string, lessons_to_skip?: Array | undefined}; export type CurriculumContent = {lessons?: string | undefined, assessments: Array}; export type PatchApiApiCurriculumsIdReorderContentArgs = {body: CurriculumContent}; export type PatchApiApiCurriculumsIdReorderContentOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const assessmentAnswer = z.object({id: z.string().nullable().optional(), answer: z.string().min(1).max(150), correct: z.boolean().nullable().optional(), position: z.number().int().gte(-32768).lte(32767).optional(), explanation: z.string().nullable().optional()}); export const lessonImageInQuestionSerializers = z.object({id: z.string().optional(), company: z.string().nullable().optional(), image_name: z.string().max(200).nullable().optional(), image_url: z.string().nullable().optional(), image_url_public: z.string().nullable().optional(), editor_content: z.string().nullable().optional(), content_type: z.enum(["lesson", "quiz", "engagement_question", "engagement_message", "assessment_question_content"]).nullable().optional()}); export const editorStateInQuestionSerializers = z.object({id: z.string().optional(), note_editor_state: z.string().nullable().optional(), summary_editor_state: z.string().nullable().optional(), question_editor_state: z.string().nullable().optional(), quiz_editor_state: z.string().nullable().optional(), quiz_message_state: z.string().nullable().optional(), content: z.array(lessonImageInQuestionSerializers).optional()}); export const assessmentQuestion = z.object({id: z.string().nullable().optional(), position: z.number().int().gte(-32768).lte(32767).optional(), answers: z.array(assessmentAnswer).optional(), editor_content: editorStateInQuestionSerializers.optional(), image_ids: z.array(z.string().nullable()).optional(), slack_markup: z.string().optional(), single_select: z.boolean().optional(), single_correct: z.boolean().optional()}); export const assessment = z.object({id: z.string().optional(), questions: z.array(assessmentQuestion), created: z.string().optional(), modified: z.string().optional(), title: z.string().min(1).max(200), company: z.string().nullable().optional()}); export const trainingCompanyAssessment = z.object({id: z.string().optional(), assessment: assessment, created: z.string().optional(), modified: z.string().optional(), passing_grade: z.number().int().gte(-2147483648).lte(2147483647).optional(), retake_status: z.enum(["optional", "force_retake", "force_continue"]).optional(), is_active: z.boolean().optional(), position: z.number().int().gte(-32768).lte(32767).optional(), polymorphic_ctype: z.number().int().optional(), company: z.string(), created_by: z.string().nullable().optional(), curriculum: z.string(), lessons_to_skip: z.array(z.string()).optional()}); export const curriculumContent = z.object({lessons: z.string().optional(), assessments: z.array(trainingCompanyAssessment)}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * PATCH /api/curriculums/{id}/reorder_content */ export const patchApiApiCurriculumsIdReorderContent = async (args: PatchApiApiCurriculumsIdReorderContentArgs, options?: PatchApiApiCurriculumsIdReorderContentOptions) => { const {baseUrl = "https://app.haekka.com", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/api/curriculums/${encodeURIComponent(String(args.id))}/reorder_content${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(curriculumContent, await res.json()) };