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

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 {
  DatasetPreview,
  DatasetPreview$inboundSchema,
} from "./datasetpreview.js";

export type PaginatedResultDatasetPreview = {
  results?: Array<DatasetPreview> | undefined;
  count: number;
  next?: string | null | undefined;
  previous?: string | null | undefined;
};

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

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