/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AuditRiskCia, AuditRiskCia$inboundSchema } from "./auditriskcia.js"; /** * Risk treatment strategy, or null if not set. */ export const Treatment = { Accept: "ACCEPT", Avoid: "AVOID", Mitigate: "MITIGATE", Transfer: "TRANSFER", } as const; /** * Risk treatment strategy, or null if not set. */ export type Treatment = ClosedEnum; /** * Treatment implementation status, or null if not set. */ export const TreatmentStatus = { InProgress: "IN_PROGRESS", Done: "DONE", } as const; /** * Treatment implementation status, or null if not set. */ export type TreatmentStatus = ClosedEnum; /** * Review status of the risk scenario, or null if not set. */ export const ReviewStatus = { Approved: "APPROVED", Draft: "DRAFT", NotReviewed: "NOT_REVIEWED", AwaitingSubmission: "AWAITING_SUBMISSION", PendingApproval: "PENDING_APPROVAL", RequestedChanges: "REQUESTED_CHANGES", } as const; /** * Review status of the risk scenario, or null if not set. */ export type ReviewStatus = ClosedEnum; /** * Risk owner information, or null if no owner assigned. */ export type AuditRiskOwner = { /** * Display name of the risk owner. */ displayName: string; /** * URL of the owner's profile image, or null if not available. */ imageUrl: string | null; }; /** * A risk record from the risk population. * * @remarks * * `id` and `riskId` are required. All other fields are optional to support customizable field visibility. * * Omitted keys mean the column is not in the response; `null` means the column is present but empty. */ export type AuditRisk = { /** * Unique identifier for the risk scenario version. */ id: string; /** * Custom risk ID (e.g., "RISK-001"), or null if not available. */ riskId: string | null; /** * Description of the risk scenario, or null if not available. */ riskScenario?: string | null | undefined; /** * Likelihood score of the risk, or null if not scored. * * @remarks * Full Audit View only - omitted in Controlled Audit View. */ likelihood?: number | null | undefined; /** * Impact score of the risk, or null if not scored. * * @remarks * Full Audit View only - omitted in Controlled Audit View. */ impact?: number | null | undefined; /** * Inherent risk score, or null if not scored. Defaults to the likelihood * impact product; when the organization scores risks by factors, this is the rolled-up factor score rounded to two decimals. */ inherentRisk?: number | null | undefined; /** * Risk treatment strategy, or null if not set. */ treatment?: Treatment | null | undefined; /** * Treatment implementation status, or null if not set. */ treatmentStatus?: TreatmentStatus | null | undefined; /** * Residual risk score after treatment, or null if not calculable. */ residualRisk?: number | null | undefined; /** * Review status of the risk scenario, or null if not set. */ reviewStatus?: ReviewStatus | null | undefined; /** * Risk owner information, or null if no owner assigned. */ owner?: AuditRiskOwner | null | undefined; /** * Risk category names, or empty array if not categorized. */ categories?: Array | undefined; /** * CIA triad categories, or empty array if not categorized. */ ciaCategories?: Array | undefined; /** * IDs of controls linked to this risk scenario, or empty array if none. * * @remarks * Full Audit View only - omitted in Controlled Audit View. */ linkedControlIds?: Array | undefined; /** * When the risk was identified, or null if not recorded. * * @remarks * ISO 8601 format. */ identified?: string | null | undefined; }; /** @internal */ export const Treatment$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Treatment); /** @internal */ export const TreatmentStatus$inboundSchema: z.ZodNativeEnum< typeof TreatmentStatus > = z.nativeEnum(TreatmentStatus); /** @internal */ export const ReviewStatus$inboundSchema: z.ZodNativeEnum = z.nativeEnum(ReviewStatus); /** @internal */ export const AuditRiskOwner$inboundSchema: z.ZodType< AuditRiskOwner, z.ZodTypeDef, unknown > = z.object({ displayName: z.string(), imageUrl: z.nullable(z.string()), }); export function auditRiskOwnerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AuditRiskOwner$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AuditRiskOwner' from JSON`, ); } /** @internal */ export const AuditRisk$inboundSchema: z.ZodType< AuditRisk, z.ZodTypeDef, unknown > = z.object({ id: z.string(), riskId: z.nullable(z.string()), riskScenario: z.nullable(z.string()).optional(), likelihood: z.nullable(z.number()).optional(), impact: z.nullable(z.number()).optional(), inherentRisk: z.nullable(z.number()).optional(), treatment: z.nullable(Treatment$inboundSchema).optional(), treatmentStatus: z.nullable(TreatmentStatus$inboundSchema).optional(), residualRisk: z.nullable(z.number()).optional(), reviewStatus: z.nullable(ReviewStatus$inboundSchema).optional(), owner: z.nullable(z.lazy(() => AuditRiskOwner$inboundSchema)).optional(), categories: z.array(z.string()).optional(), ciaCategories: z.array(AuditRiskCia$inboundSchema).optional(), linkedControlIds: z.array(z.string()).optional(), identified: z.nullable(z.string()).optional(), }); export function auditRiskFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AuditRisk$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AuditRisk' from JSON`, ); }