/* * 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"; /** * Code change data. * * @remarks * * `id` and `codeChange` 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 CodeChange = { /** * Code change record ID - always present. */ id: string; /** * Code change title (e.g. PR title) - always present. */ codeChange: string; /** * IDs of the audit segments this code change is in scope for. * * @remarks * Omitted when segment scoping is disabled. */ segmentIds?: Array | undefined; /** * Code change identifier (e.g. PR number). */ identifier?: string | undefined; /** * Version control source where the change originated. * * @remarks * Known values are listed in {@link ApiCodeChangeSource}; other strings may * appear if a new source is onboarded before this enum is updated. */ service?: string | undefined; /** * Repository name. */ repository?: string | undefined; /** * Date the code change was opened. */ openedAt?: Date | undefined; /** * Date the code change was merged/closed. */ closedAt?: Date | undefined; }; /** @internal */ export const CodeChange$inboundSchema: z.ZodType< CodeChange, z.ZodTypeDef, unknown > = z.object({ id: z.string(), codeChange: z.string(), segmentIds: z.array(z.string()).optional(), identifier: z.string().optional(), service: z.string().optional(), repository: z.string().optional(), openedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), closedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), }); export function codeChangeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CodeChange$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CodeChange' from JSON`, ); }