/* * 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"; import { JSONObjectResponseFormat, JSONObjectResponseFormat$inboundSchema, JSONObjectResponseFormat$Outbound, JSONObjectResponseFormat$outboundSchema, } from "./jsonobjectresponseformat.js"; import { JSONSchemaResponseFormat, JSONSchemaResponseFormat$inboundSchema, JSONSchemaResponseFormat$Outbound, JSONSchemaResponseFormat$outboundSchema, } from "./jsonschemaresponseformat.js"; import { TextResponseFormat, TextResponseFormat$inboundSchema, TextResponseFormat$Outbound, TextResponseFormat$outboundSchema, } from "./textresponseformat.js"; export type ResponseFormat = | TextResponseFormat | JSONSchemaResponseFormat | JSONObjectResponseFormat; /** @internal */ export const ResponseFormat$inboundSchema: z.ZodType< ResponseFormat, z.ZodTypeDef, unknown > = z.union([ TextResponseFormat$inboundSchema, JSONSchemaResponseFormat$inboundSchema, JSONObjectResponseFormat$inboundSchema, ]); /** @internal */ export type ResponseFormat$Outbound = | TextResponseFormat$Outbound | JSONSchemaResponseFormat$Outbound | JSONObjectResponseFormat$Outbound; /** @internal */ export const ResponseFormat$outboundSchema: z.ZodType< ResponseFormat$Outbound, z.ZodTypeDef, ResponseFormat > = z.union([ TextResponseFormat$outboundSchema, JSONSchemaResponseFormat$outboundSchema, JSONObjectResponseFormat$outboundSchema, ]); export function responseFormatToJSON(responseFormat: ResponseFormat): string { return JSON.stringify(ResponseFormat$outboundSchema.parse(responseFormat)); } export function responseFormatFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResponseFormat$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseFormat' from JSON`, ); }