/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 328cab4f7342
 */

import * as z from "zod/v4";
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";
  conversationId: string;
  messages: Array<MessageEntries>;
};

/** @internal */
export const ConversationMessages$inboundSchema: z.ZodType<
  ConversationMessages,
  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`,
  );
}
