/* * 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 { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; export const ChatMessageContentType = { ImageUrl: "image_url", } as const; export type ChatMessageContentType = ClosedEnum; export type ChatMessageContentImageUrl = { /** * base64 encoded string for image formatted as MIME_TYPE,\ * * @remarks * eg. data:image/jpeg;base64,\ */ url?: string | undefined; }; /** * A message containing image */ export type ChatMessageContent2 = { type?: ChatMessageContentType | undefined; imageUrl?: ChatMessageContentImageUrl | undefined; }; export const ChatMessageContent1Type = { Text: "text", } as const; export type ChatMessageContent1Type = ClosedEnum< typeof ChatMessageContent1Type >; /** * A message containing text */ export type One = { type?: ChatMessageContent1Type | undefined; /** * The content of the message. */ text?: string | undefined; }; /** * The content of the message. Can either be text or image_url. * * @remarks */ export type ChatMessageContent = One | ChatMessageContent2; /** @internal */ export const ChatMessageContentType$inboundSchema: z.ZodNativeEnum< typeof ChatMessageContentType > = z.nativeEnum(ChatMessageContentType); /** @internal */ export const ChatMessageContentType$outboundSchema: z.ZodNativeEnum< typeof ChatMessageContentType > = ChatMessageContentType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatMessageContentType$ { /** @deprecated use `ChatMessageContentType$inboundSchema` instead. */ export const inboundSchema = ChatMessageContentType$inboundSchema; /** @deprecated use `ChatMessageContentType$outboundSchema` instead. */ export const outboundSchema = ChatMessageContentType$outboundSchema; } /** @internal */ export const ChatMessageContentImageUrl$inboundSchema: z.ZodType< ChatMessageContentImageUrl, z.ZodTypeDef, unknown > = z.object({ url: z.string().optional(), }); /** @internal */ export type ChatMessageContentImageUrl$Outbound = { url?: string | undefined; }; /** @internal */ export const ChatMessageContentImageUrl$outboundSchema: z.ZodType< ChatMessageContentImageUrl$Outbound, z.ZodTypeDef, ChatMessageContentImageUrl > = z.object({ url: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatMessageContentImageUrl$ { /** @deprecated use `ChatMessageContentImageUrl$inboundSchema` instead. */ export const inboundSchema = ChatMessageContentImageUrl$inboundSchema; /** @deprecated use `ChatMessageContentImageUrl$outboundSchema` instead. */ export const outboundSchema = ChatMessageContentImageUrl$outboundSchema; /** @deprecated use `ChatMessageContentImageUrl$Outbound` instead. */ export type Outbound = ChatMessageContentImageUrl$Outbound; } export function chatMessageContentImageUrlToJSON( chatMessageContentImageUrl: ChatMessageContentImageUrl, ): string { return JSON.stringify( ChatMessageContentImageUrl$outboundSchema.parse(chatMessageContentImageUrl), ); } export function chatMessageContentImageUrlFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChatMessageContentImageUrl$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatMessageContentImageUrl' from JSON`, ); } /** @internal */ export const ChatMessageContent2$inboundSchema: z.ZodType< ChatMessageContent2, z.ZodTypeDef, unknown > = z.object({ type: ChatMessageContentType$inboundSchema.optional(), image_url: z.lazy(() => ChatMessageContentImageUrl$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "image_url": "imageUrl", }); }); /** @internal */ export type ChatMessageContent2$Outbound = { type?: string | undefined; image_url?: ChatMessageContentImageUrl$Outbound | undefined; }; /** @internal */ export const ChatMessageContent2$outboundSchema: z.ZodType< ChatMessageContent2$Outbound, z.ZodTypeDef, ChatMessageContent2 > = z.object({ type: ChatMessageContentType$outboundSchema.optional(), imageUrl: z.lazy(() => ChatMessageContentImageUrl$outboundSchema).optional(), }).transform((v) => { return remap$(v, { imageUrl: "image_url", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatMessageContent2$ { /** @deprecated use `ChatMessageContent2$inboundSchema` instead. */ export const inboundSchema = ChatMessageContent2$inboundSchema; /** @deprecated use `ChatMessageContent2$outboundSchema` instead. */ export const outboundSchema = ChatMessageContent2$outboundSchema; /** @deprecated use `ChatMessageContent2$Outbound` instead. */ export type Outbound = ChatMessageContent2$Outbound; } export function chatMessageContent2ToJSON( chatMessageContent2: ChatMessageContent2, ): string { return JSON.stringify( ChatMessageContent2$outboundSchema.parse(chatMessageContent2), ); } export function chatMessageContent2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChatMessageContent2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatMessageContent2' from JSON`, ); } /** @internal */ export const ChatMessageContent1Type$inboundSchema: z.ZodNativeEnum< typeof ChatMessageContent1Type > = z.nativeEnum(ChatMessageContent1Type); /** @internal */ export const ChatMessageContent1Type$outboundSchema: z.ZodNativeEnum< typeof ChatMessageContent1Type > = ChatMessageContent1Type$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatMessageContent1Type$ { /** @deprecated use `ChatMessageContent1Type$inboundSchema` instead. */ export const inboundSchema = ChatMessageContent1Type$inboundSchema; /** @deprecated use `ChatMessageContent1Type$outboundSchema` instead. */ export const outboundSchema = ChatMessageContent1Type$outboundSchema; } /** @internal */ export const One$inboundSchema: z.ZodType = z .object({ type: ChatMessageContent1Type$inboundSchema.optional(), text: z.string().optional(), }); /** @internal */ export type One$Outbound = { type?: string | undefined; text?: string | undefined; }; /** @internal */ export const One$outboundSchema: z.ZodType = z .object({ type: ChatMessageContent1Type$outboundSchema.optional(), text: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace One$ { /** @deprecated use `One$inboundSchema` instead. */ export const inboundSchema = One$inboundSchema; /** @deprecated use `One$outboundSchema` instead. */ export const outboundSchema = One$outboundSchema; /** @deprecated use `One$Outbound` instead. */ export type Outbound = One$Outbound; } export function oneToJSON(one: One): string { return JSON.stringify(One$outboundSchema.parse(one)); } export function oneFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => One$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'One' from JSON`, ); } /** @internal */ export const ChatMessageContent$inboundSchema: z.ZodType< ChatMessageContent, z.ZodTypeDef, unknown > = z.union([ z.lazy(() => One$inboundSchema), z.lazy(() => ChatMessageContent2$inboundSchema), ]); /** @internal */ export type ChatMessageContent$Outbound = | One$Outbound | ChatMessageContent2$Outbound; /** @internal */ export const ChatMessageContent$outboundSchema: z.ZodType< ChatMessageContent$Outbound, z.ZodTypeDef, ChatMessageContent > = z.union([ z.lazy(() => One$outboundSchema), z.lazy(() => ChatMessageContent2$outboundSchema), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatMessageContent$ { /** @deprecated use `ChatMessageContent$inboundSchema` instead. */ export const inboundSchema = ChatMessageContent$inboundSchema; /** @deprecated use `ChatMessageContent$outboundSchema` instead. */ export const outboundSchema = ChatMessageContent$outboundSchema; /** @deprecated use `ChatMessageContent$Outbound` instead. */ export type Outbound = ChatMessageContent$Outbound; } export function chatMessageContentToJSON( chatMessageContent: ChatMessageContent, ): string { return JSON.stringify( ChatMessageContent$outboundSchema.parse(chatMessageContent), ); } export function chatMessageContentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChatMessageContent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatMessageContent' from JSON`, ); }