/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ErrorEvent = { type: "error"; sequenceNumber: number; code: string; message: string; param?: string | undefined; }; /** @internal */ export const ErrorEvent$inboundSchema: z.ZodType< ErrorEvent, z.ZodTypeDef, unknown > = z.object({ type: z.literal("error"), sequence_number: z.number().int(), code: z.string(), message: z.string(), param: z.string().optional(), }).transform((v) => { return remap$(v, { "sequence_number": "sequenceNumber", }); }); /** @internal */ export type ErrorEvent$Outbound = { type: "error"; sequence_number: number; code: string; message: string; param?: string | undefined; }; /** @internal */ export const ErrorEvent$outboundSchema: z.ZodType< ErrorEvent$Outbound, z.ZodTypeDef, ErrorEvent > = z.object({ type: z.literal("error"), sequenceNumber: z.number().int(), code: z.string(), message: z.string(), param: z.string().optional(), }).transform((v) => { return remap$(v, { sequenceNumber: "sequence_number", }); }); export function errorEventToJSON(errorEvent: ErrorEvent): string { return JSON.stringify(ErrorEvent$outboundSchema.parse(errorEvent)); } export function errorEventFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ErrorEvent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ErrorEvent' from JSON`, ); }