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

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 PaginatedResultChatCompletionEventPreview = {
  results?: Array<ChatCompletionEventPreview> | undefined;
  count: number;
  next?: string | null | undefined;
  previous?: string | null | undefined;
};

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

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