/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { TaskStatus, TaskStatus$inboundSchema } from "./taskstatus.js"; import { TaskTypeCOMPLETETRAININGS, TaskTypeCOMPLETETRAININGS$inboundSchema, } from "./tasktypecompletetrainings.js"; import { Training, Training$inboundSchema } from "./training.js"; /** * If the task is disabled, the reason and date when it was disabled. */ export type Disabled = { date: Date; reason: string | null; }; /** * Task summary for completing all trainings. */ export type CompleteTrainingsTaskSummary = { taskType: TaskTypeCOMPLETETRAININGS; /** * The status of a task. * * @remarks * - COMPLETE: The task has been completed. * - DUE_SOON: The task is due soon. * - OVERDUE: The task is overdue. * - NONE: The task is not assigned. */ status: TaskStatus; /** * The due date of the task. */ dueDate: Date | null; /** * The date the task was completed. */ completionDate: Date | null; /** * If the task is disabled, the reason and date when it was disabled. */ disabled: Disabled | null; /** * Incomplete security trainings that are relevant given a person's requirements. */ incompleteTrainings: Array; /** * Security trainings that have been completed and are relevant given a person's current requirements. */ completedTrainings: Array; }; /** @internal */ export const Disabled$inboundSchema: z.ZodType< Disabled, z.ZodTypeDef, unknown > = z.object({ date: z.string().datetime({ offset: true }).transform(v => new Date(v)), reason: z.nullable(z.string()), }); export function disabledFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Disabled$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Disabled' from JSON`, ); } /** @internal */ export const CompleteTrainingsTaskSummary$inboundSchema: z.ZodType< CompleteTrainingsTaskSummary, z.ZodTypeDef, unknown > = z.object({ taskType: TaskTypeCOMPLETETRAININGS$inboundSchema, status: TaskStatus$inboundSchema, dueDate: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), completionDate: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), disabled: z.nullable(z.lazy(() => Disabled$inboundSchema)), incompleteTrainings: z.array(Training$inboundSchema), completedTrainings: z.array(Training$inboundSchema), }); export function completeTrainingsTaskSummaryFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CompleteTrainingsTaskSummary$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompleteTrainingsTaskSummary' from JSON`, ); }