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

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type ConversationPayload = {
  messages: Array<{ [k: string]: any }>;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const ConversationPayload$inboundSchema: z.ZodType<
  ConversationPayload,
  unknown
> = z.object({
  messages: z.array(z.record(z.string(), z.any())),
}).catchall(z.any());
/** @internal */
export type ConversationPayload$Outbound = {
  messages: Array<{ [k: string]: any }>;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const ConversationPayload$outboundSchema: z.ZodType<
  ConversationPayload$Outbound,
  ConversationPayload
> = z.object({
  messages: z.array(z.record(z.string(), z.any())),
}).catchall(z.any());

export function conversationPayloadToJSON(
  conversationPayload: ConversationPayload,
): string {
  return JSON.stringify(
    ConversationPayload$outboundSchema.parse(conversationPayload),
  );
}
export function conversationPayloadFromJSON(
  jsonString: string,
): SafeParseResult<ConversationPayload, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ConversationPayload$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ConversationPayload' from JSON`,
  );
}
