/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 4f8f44c118ad */ 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 { StructuredTextItem, StructuredTextItem$inboundSchema, StructuredTextItem$Outbound, StructuredTextItem$outboundSchema, } from "./structuredtextitem.js"; export type StructuredText = { text: string; /** * An array of objects each of which contains either a string or a link which optionally corresponds to a document. */ structuredList?: Array | undefined; }; /** @internal */ export const StructuredText$inboundSchema: z.ZodType< StructuredText, z.ZodTypeDef, unknown > = z.object({ text: z.string(), structuredList: z.array(z.lazy(() => StructuredTextItem$inboundSchema)) .optional(), }); /** @internal */ export type StructuredText$Outbound = { text: string; structuredList?: Array | undefined; }; /** @internal */ export const StructuredText$outboundSchema: z.ZodType< StructuredText$Outbound, z.ZodTypeDef, StructuredText > = z.object({ text: z.string(), structuredList: z.array(z.lazy(() => StructuredTextItem$outboundSchema)) .optional(), }); export function structuredTextToJSON(structuredText: StructuredText): string { return JSON.stringify(StructuredText$outboundSchema.parse(structuredText)); } export function structuredTextFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => StructuredText$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StructuredText' from JSON`, ); }