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

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";
import {
  ChatCompletionEventPreview,
  ChatCompletionEventPreview$inboundSchema,
} from "./chatcompletioneventpreview.js";

export type FeedResultChatCompletionEventPreview = {
  results?: Array<ChatCompletionEventPreview> | undefined;
  next?: string | null | undefined;
  cursor?: string | null | undefined;
};

/** @internal */
export const FeedResultChatCompletionEventPreview$inboundSchema: z.ZodType<
  FeedResultChatCompletionEventPreview,
  unknown
> = z.object({
  results: z.array(ChatCompletionEventPreview$inboundSchema).optional(),
  next: z.nullable(z.string()).optional(),
  cursor: z.nullable(z.string()).optional(),
});

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