/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; 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"; export const One = { TextPlain: "text/plain", AudioMpeg: "audio/mpeg", VideoMp4: "video/mp4", ImageWebp: "image/webp", ImageHeic: "image/heic", ImageBmp: "image/bmp", ImagePng: "image/png", ImageJpeg: "image/jpeg", ImageTiff: "image/tiff", } as const; export type One = ClosedEnum; /** * The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document's type. */ export type QueryParamMediaType = One | string; export type GetDocumentContentRequest = { /** * The id of the document. */ documentId: string; /** * The desired media type of the content to return described as a mime type. An error will be returned if the requested media type is not supported for the document's type. */ mediaType?: One | string | null | undefined; /** * Whether to return the content as a file download or a raw stream. If set to `true`, the content will be returned as a named file for download. */ download?: boolean | undefined; /** * An optional partition to scope the request to. If omitted, accounts created after 1/9/2025 will have the request scoped to the default partition, while older accounts will have the request scoped to all partitions. Older accounts may opt in to strict partition scoping by contacting support@ragie.ai. Older accounts using the partitions feature are strongly recommended to scope the request to a partition. */ partition?: string | null | undefined; range?: string | null | undefined; }; /** @internal */ export const One$inboundSchema: z.ZodNativeEnum = z.nativeEnum(One); /** @internal */ export const One$outboundSchema: z.ZodNativeEnum = One$inboundSchema; /** @internal */ export const QueryParamMediaType$inboundSchema: z.ZodType< QueryParamMediaType, z.ZodTypeDef, unknown > = z.union([One$inboundSchema, z.string()]); /** @internal */ export type QueryParamMediaType$Outbound = string | string; /** @internal */ export const QueryParamMediaType$outboundSchema: z.ZodType< QueryParamMediaType$Outbound, z.ZodTypeDef, QueryParamMediaType > = z.union([One$outboundSchema, z.string()]); export function queryParamMediaTypeToJSON( queryParamMediaType: QueryParamMediaType, ): string { return JSON.stringify( QueryParamMediaType$outboundSchema.parse(queryParamMediaType), ); } export function queryParamMediaTypeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => QueryParamMediaType$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'QueryParamMediaType' from JSON`, ); } /** @internal */ export const GetDocumentContentRequest$inboundSchema: z.ZodType< GetDocumentContentRequest, z.ZodTypeDef, unknown > = z.object({ document_id: z.string(), media_type: z.nullable(z.union([One$inboundSchema, z.string()])).optional(), download: z.boolean().default(false), partition: z.nullable(z.string()).optional(), range: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "document_id": "documentId", "media_type": "mediaType", }); }); /** @internal */ export type GetDocumentContentRequest$Outbound = { document_id: string; media_type?: string | string | null | undefined; download: boolean; partition?: string | null | undefined; range?: string | null | undefined; }; /** @internal */ export const GetDocumentContentRequest$outboundSchema: z.ZodType< GetDocumentContentRequest$Outbound, z.ZodTypeDef, GetDocumentContentRequest > = z.object({ documentId: z.string(), mediaType: z.nullable(z.union([One$outboundSchema, z.string()])).optional(), download: z.boolean().default(false), partition: z.nullable(z.string()).optional(), range: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { documentId: "document_id", mediaType: "media_type", }); }); export function getDocumentContentRequestToJSON( getDocumentContentRequest: GetDocumentContentRequest, ): string { return JSON.stringify( GetDocumentContentRequest$outboundSchema.parse(getDocumentContentRequest), ); } export function getDocumentContentRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetDocumentContentRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetDocumentContentRequest' from JSON`, ); }