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

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * Format of the table
 */
export const Format = {
  Markdown: "markdown",
  Html: "html",
} as const;
/**
 * Format of the table
 */
export type Format = ClosedEnum<typeof Format>;

export type OCRTableObject = {
  /**
   * Table ID for extracted table in a page
   */
  id: string;
  /**
   * Content of the table in the given format
   */
  content: string;
  /**
   * Format of the table
   */
  format: Format;
};

/** @internal */
export const Format$inboundSchema: z.ZodNativeEnum<typeof Format> = z
  .nativeEnum(Format);

/** @internal */
export const OCRTableObject$inboundSchema: z.ZodType<
  OCRTableObject,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
  content: z.string(),
  format: Format$inboundSchema,
});

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