/* * 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 { Result as SafeParseResult } from "../../../types/fp.js"; import * as errors from "../errors/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ServerError = { code: string; message: string; errors?: Array | undefined; decisionId?: string | undefined; }; /** @internal */ export const ServerError$inboundSchema: z.ZodType< ServerError, z.ZodTypeDef, unknown > = z.object({ code: z.string(), message: z.string(), errors: z.array(z.lazy(() => errors.ServerErrorErrors$inboundSchema)) .optional(), decision_id: z.string().optional(), }).transform((v) => { return remap$(v, { "decision_id": "decisionId", }); }); /** @internal */ export type ServerError$Outbound = { code: string; message: string; errors?: Array | undefined; decision_id?: string | undefined; }; /** @internal */ export const ServerError$outboundSchema: z.ZodType< ServerError$Outbound, z.ZodTypeDef, ServerError > = z.object({ code: z.string(), message: z.string(), errors: z.array(z.lazy(() => errors.ServerErrorErrors$outboundSchema)) .optional(), decisionId: z.string().optional(), }).transform((v) => { return remap$(v, { decisionId: "decision_id", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ServerError$ { /** @deprecated use `ServerError$inboundSchema` instead. */ export const inboundSchema = ServerError$inboundSchema; /** @deprecated use `ServerError$outboundSchema` instead. */ export const outboundSchema = ServerError$outboundSchema; /** @deprecated use `ServerError$Outbound` instead. */ export type Outbound = ServerError$Outbound; } export function serverErrorToJSON(serverError: ServerError): string { return JSON.stringify(ServerError$outboundSchema.parse(serverError)); } export function serverErrorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ServerError$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ServerError' from JSON`, ); }