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

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 {
  MessageInputEntry,
  MessageInputEntry$inboundSchema,
} from "./messageinputentry.js";
import {
  MessageOutputEntry,
  MessageOutputEntry$inboundSchema,
} from "./messageoutputentry.js";

export type MessageEntries = MessageInputEntry | MessageOutputEntry;

/** @internal */
export const MessageEntries$inboundSchema: z.ZodType<
  MessageEntries,
  z.ZodTypeDef,
  unknown
> = z.union([
  MessageInputEntry$inboundSchema,
  MessageOutputEntry$inboundSchema,
]);

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