/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { catchUnrecognizedEnum, OpenEnum, Unrecognized, } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The audit record type, one of: * * @remarks * - `AUDIT_TYPE_UNSPECIFIED` - Default/Null audit type. * - `INVESTIGATION_REQUEST_UPDATE` - Used to update an investigation request. * - `INVESTIGATION_STATE` - Used for recording investigation state changed events. * - `COMMENT` - Used for adding a comment to investigation. */ export enum AuditType { AuditTypeUnspecified = "AUDIT_TYPE_UNSPECIFIED", InvestigationRequestUpdate = "INVESTIGATION_REQUEST_UPDATE", InvestigationState = "INVESTIGATION_STATE", Comment = "COMMENT", } /** * The audit record type, one of: * * @remarks * - `AUDIT_TYPE_UNSPECIFIED` - Default/Null audit type. * - `INVESTIGATION_REQUEST_UPDATE` - Used to update an investigation request. * - `INVESTIGATION_STATE` - Used for recording investigation state changed events. * - `COMMENT` - Used for adding a comment to investigation. */ export type AuditTypeOpen = OpenEnum; /** * Audit trail details */ export type AuditTrail = { /** * The audit record type, one of: * * @remarks * - `AUDIT_TYPE_UNSPECIFIED` - Default/Null audit type. * - `INVESTIGATION_REQUEST_UPDATE` - Used to update an investigation request. * - `INVESTIGATION_STATE` - Used for recording investigation state changed events. * - `COMMENT` - Used for adding a comment to investigation. */ auditType?: AuditTypeOpen | undefined; /** * Comment relating to why the audit was saved */ comment?: string | undefined; /** * The name of the field that has been updated */ field?: string | undefined; /** * The new value for the field that was updated */ newValue?: string | undefined; /** * The prior value for the field that was updated */ oldValue?: string | undefined; /** * The date the user updated the investigation */ updateTime?: Date | null | undefined; /** * The user that made the update to the investigation */ updateUser?: string | undefined; }; /** @internal */ export const AuditType$inboundSchema: z.ZodType< AuditTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(AuditType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const AuditType$outboundSchema: z.ZodType< AuditTypeOpen, z.ZodTypeDef, AuditTypeOpen > = z.union([ z.nativeEnum(AuditType), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AuditType$ { /** @deprecated use `AuditType$inboundSchema` instead. */ export const inboundSchema = AuditType$inboundSchema; /** @deprecated use `AuditType$outboundSchema` instead. */ export const outboundSchema = AuditType$outboundSchema; } /** @internal */ export const AuditTrail$inboundSchema: z.ZodType< AuditTrail, z.ZodTypeDef, unknown > = z.object({ audit_type: AuditType$inboundSchema.optional(), comment: z.string().optional(), field: z.string().optional(), new_value: z.string().optional(), old_value: z.string().optional(), update_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), update_user: z.string().optional(), }).transform((v) => { return remap$(v, { "audit_type": "auditType", "new_value": "newValue", "old_value": "oldValue", "update_time": "updateTime", "update_user": "updateUser", }); }); /** @internal */ export type AuditTrail$Outbound = { audit_type?: string | undefined; comment?: string | undefined; field?: string | undefined; new_value?: string | undefined; old_value?: string | undefined; update_time?: string | null | undefined; update_user?: string | undefined; }; /** @internal */ export const AuditTrail$outboundSchema: z.ZodType< AuditTrail$Outbound, z.ZodTypeDef, AuditTrail > = z.object({ auditType: AuditType$outboundSchema.optional(), comment: z.string().optional(), field: z.string().optional(), newValue: z.string().optional(), oldValue: z.string().optional(), updateTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), updateUser: z.string().optional(), }).transform((v) => { return remap$(v, { auditType: "audit_type", newValue: "new_value", oldValue: "old_value", updateTime: "update_time", updateUser: "update_user", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AuditTrail$ { /** @deprecated use `AuditTrail$inboundSchema` instead. */ export const inboundSchema = AuditTrail$inboundSchema; /** @deprecated use `AuditTrail$outboundSchema` instead. */ export const outboundSchema = AuditTrail$outboundSchema; /** @deprecated use `AuditTrail$Outbound` instead. */ export type Outbound = AuditTrail$Outbound; } export function auditTrailToJSON(auditTrail: AuditTrail): string { return JSON.stringify(AuditTrail$outboundSchema.parse(auditTrail)); } export function auditTrailFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AuditTrail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AuditTrail' from JSON`, ); }