/* * 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 { EmploymentStatus, EmploymentStatus$inboundSchema, } from "./employmentstatus.js"; import { LeaveStatus, LeaveStatus$inboundSchema } from "./leavestatus.js"; import { PersonInfoSource, PersonInfoSource$inboundSchema, } from "./personinfosource.js"; import { TasksSummaryStatus, TasksSummaryStatus$inboundSchema, } from "./taskssummarystatus.js"; import { TaskSummaryDetails, TaskSummaryDetails$inboundSchema, } from "./tasksummarydetails.js"; export type Employment = { /** * The employment status of a person: * * @remarks * - UPCOMING: The person is not yet employed and will start employment in the future. * - CURRENT: The person is currently employed. * - ON_LEAVE: The person is on leave. * - INACTIVE: The person's employment is inactive. * - FORMER: The person was previously employed. */ status: EmploymentStatus; /** * The date the person's employment started. */ startDate: Date; /** * The person's job title. */ jobTitle: string | null; /** * If present, the date the person's employment ended. */ endDate: Date | null; }; /** * If present, the user's active/upcoming leave. Empty if the user has no active/upcoming leave. */ export type LeaveInfo = { /** * The start of the person's leave. */ startDate: Date; /** * The end of the person's leave. Null endDate implies indefinite leave. */ endDate: Date | null; /** * User can be active or upcoming leave period */ status: LeaveStatus; }; export type Name = { /** * The person's first (given) name. */ first: string | null; /** * The person's last (family) name. */ last: string | null; /** * The person's display name, used in Vanta. */ display: string; }; export type PersonEmployment = { /** * The source of the person's information. */ endDate: PersonInfoSource; /** * The source of the person's information. */ startDate: PersonInfoSource; }; /** * The sources of the person's information. */ export type Sources = { employment: PersonEmployment; /** * The source of the person's information. */ emailAddress: PersonInfoSource; }; /** * The person's tasks summary, which aggregates their current status across * * @remarks * all of their relevant tasks. */ export type TasksSummary = { /** * All detailed information about a person's tasks, split across task categories. */ details: TaskSummaryDetails; /** * The overall status of a person's outstanding tasks: * * @remarks * - NONE: There are no tasks. * - DUE_SOON: At least one task is due soon. * - OVERDUE: At least one task is overdue. Has a higher priority than DUE_SOON. * - COMPLETE: All tasks are complete. * - PAUSED: All tasks are paused. * - OFFBOARDING_DUE_SOON: At least one offboarding task is due soon. * - OFFBOARDING_OVERDUE: At least one offboarding task is overdue. Has a higher priority than OFFBOARDING_DUE_SOON. * - OFFBOARDING_COMPLETE: All offboarding tasks are complete. */ status: TasksSummaryStatus; /** * The due date of the person's earliest-due task. */ dueDate: Date | null; /** * The date when person's tasks were completed. */ completionDate: Date | null; }; export type Person = { id: string; /** * The ID of the Vanta user account associated with this person, if one exists. */ userId: string | null; emailAddress: string; employment: Employment; /** * If present, the user's active/upcoming leave. Empty if the user has no active/upcoming leave. */ leaveInfo: LeaveInfo | null; /** * The id of each group the user belongs to. This includes both manually created groups in Vanta and groups imported from an identity provider. */ groupIds: Array; name: Name; /** * The sources of the person's information. */ sources: Sources; /** * The person's tasks summary, which aggregates their current status across * * @remarks * all of their relevant tasks. */ tasksSummary: TasksSummary; }; /** @internal */ export const Employment$inboundSchema: z.ZodType< Employment, z.ZodTypeDef, unknown > = z.object({ status: EmploymentStatus$inboundSchema, startDate: z.string().datetime({ offset: true }).transform(v => new Date(v)), jobTitle: z.nullable(z.string()), endDate: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), }); export function employmentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Employment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Employment' from JSON`, ); } /** @internal */ export const LeaveInfo$inboundSchema: z.ZodType< LeaveInfo, z.ZodTypeDef, unknown > = z.object({ startDate: z.string().datetime({ offset: true }).transform(v => new Date(v)), endDate: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), status: LeaveStatus$inboundSchema, }); export function leaveInfoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LeaveInfo$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LeaveInfo' from JSON`, ); } /** @internal */ export const Name$inboundSchema: z.ZodType = z .object({ first: z.nullable(z.string()), last: z.nullable(z.string()), display: z.string(), }); export function nameFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Name$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Name' from JSON`, ); } /** @internal */ export const PersonEmployment$inboundSchema: z.ZodType< PersonEmployment, z.ZodTypeDef, unknown > = z.object({ endDate: PersonInfoSource$inboundSchema, startDate: PersonInfoSource$inboundSchema, }); export function personEmploymentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PersonEmployment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PersonEmployment' from JSON`, ); } /** @internal */ export const Sources$inboundSchema: z.ZodType = z.object({ employment: z.lazy(() => PersonEmployment$inboundSchema), emailAddress: PersonInfoSource$inboundSchema, }); export function sourcesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Sources$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Sources' from JSON`, ); } /** @internal */ export const TasksSummary$inboundSchema: z.ZodType< TasksSummary, z.ZodTypeDef, unknown > = z.object({ details: TaskSummaryDetails$inboundSchema, status: TasksSummaryStatus$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)), ), }); export function tasksSummaryFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TasksSummary$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TasksSummary' from JSON`, ); } /** @internal */ export const Person$inboundSchema: z.ZodType = z .object({ id: z.string(), userId: z.nullable(z.string()), emailAddress: z.string(), employment: z.lazy(() => Employment$inboundSchema), leaveInfo: z.nullable(z.lazy(() => LeaveInfo$inboundSchema)), groupIds: z.array(z.string()), name: z.lazy(() => Name$inboundSchema), sources: z.lazy(() => Sources$inboundSchema), tasksSummary: z.lazy(() => TasksSummary$inboundSchema), }); export function personFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Person$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Person' from JSON`, ); }