/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: c1f7bf936709 */ 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 { ContentType, ContentType$inboundSchema, ContentType$outboundSchema, } from "./contenttype.js"; export type MessageTextBlock = { text: string; type: ContentType; }; export type Message = { /** * The role of the message. */ role?: string | undefined; /** * The content of the message. */ content?: Array | undefined; }; /** @internal */ export const MessageTextBlock$inboundSchema: z.ZodType< MessageTextBlock, z.ZodTypeDef, unknown > = z.object({ text: z.string(), type: ContentType$inboundSchema, }); /** @internal */ export type MessageTextBlock$Outbound = { text: string; type: string; }; /** @internal */ export const MessageTextBlock$outboundSchema: z.ZodType< MessageTextBlock$Outbound, z.ZodTypeDef, MessageTextBlock > = z.object({ text: z.string(), type: ContentType$outboundSchema, }); export function messageTextBlockToJSON( messageTextBlock: MessageTextBlock, ): string { return JSON.stringify( MessageTextBlock$outboundSchema.parse(messageTextBlock), ); } export function messageTextBlockFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => MessageTextBlock$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MessageTextBlock' from JSON`, ); } /** @internal */ export const Message$inboundSchema: z.ZodType = z.object({ role: z.string().optional(), content: z.array(z.lazy(() => MessageTextBlock$inboundSchema)).optional(), }); /** @internal */ export type Message$Outbound = { role?: string | undefined; content?: Array | undefined; }; /** @internal */ export const Message$outboundSchema: z.ZodType< Message$Outbound, z.ZodTypeDef, Message > = z.object({ role: z.string().optional(), content: z.array(z.lazy(() => MessageTextBlock$outboundSchema)).optional(), }); export function messageToJSON(message: Message): string { return JSON.stringify(Message$outboundSchema.parse(message)); } export function messageFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Message$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Message' from JSON`, ); }