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

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

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

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

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