/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  MessageEntries,
  MessageEntries$inboundSchema,
} from "./messageentries.js";

/**
 * Similar to the conversation history but only keep the messages
 */
export type ConversationMessages = {
  object?: "conversation.messages" | undefined;
  conversationId: string;
  messages: Array<MessageEntries>;
};

/** @internal */
export const ConversationMessages$inboundSchema: z.ZodType<
  ConversationMessages,
  z.ZodTypeDef,
  unknown
> = z.object({
  object: z.literal("conversation.messages").default("conversation.messages"),
  conversation_id: z.string(),
  messages: z.array(MessageEntries$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "conversation_id": "conversationId",
  });
});

export function conversationMessagesFromJSON(
  jsonString: string,
): SafeParseResult<ConversationMessages, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ConversationMessages$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ConversationMessages' from JSON`,
  );
}
