/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { blobLikeSchema } from "../../types/blobs.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type UpdateDocumentFileParams22 = {}; export const UpdateDocumentFileParams21 = { HiRes: "hi_res", Fast: "fast", } as const; export type UpdateDocumentFileParams21 = ClosedEnum< typeof UpdateDocumentFileParams21 >; export type Mode2 = UpdateDocumentFileParams21 | UpdateDocumentFileParams22; export const UpdateDocumentFileParamsModeStatic = { HiRes: "hi_res", Fast: "fast", } as const; export type UpdateDocumentFileParamsModeStatic = ClosedEnum< typeof UpdateDocumentFileParamsModeStatic >; export const UpdateDocumentFileParamsModeVideo = { AudioOnly: "audio_only", VideoOnly: "video_only", AudioVideo: "audio_video", } as const; export type UpdateDocumentFileParamsModeVideo = ClosedEnum< typeof UpdateDocumentFileParamsModeVideo >; export type UpdateDocumentFileParamsMode1 = { static?: UpdateDocumentFileParamsModeStatic | null | undefined; audio?: boolean | null | undefined; video?: UpdateDocumentFileParamsModeVideo | null | undefined; }; /** * Partition strategy for the document. Different strategies exist for textual, audio and video file types and you can set the strategy you want for each file type, or just for textual types. For textual documents the options are `'hi_res'` or `'fast'`. When set to `'hi_res'`, images and tables will be extracted from the document. `'fast'` will only extract text. `'fast'` may be up to 20x faster than `'hi_res'`. `hi_res` is only applicable for Word documents, PDFs, Images, and PowerPoints. Images will always be processed in `hi_res`. If `hi_res` is set for an unsupported document type, it will be processed and billed in `fast` mode. For audio files, the options are true or false. True if you want to process audio, false otherwise. For video files, the options are `'audio_only'`, `'video_only'`, `'audio_video'`. `'audio_only'` will extract just the audio part of the video. `'video_only'` will similarly just extract the video part, ignoring audio. `'audio_video'` will extract both audio and video. To process all media types at the highest quality, use `'all'`. When you specify audio or video stategies, the format must be a JSON object. In this case, textual documents are denoted by the key "static". If you omit a key, that document type won't be processd. See examples below. Examples Textual documents only "fast" Video documents only { "video": "audio_video" } Specify multiple document types { "static": "hi_res", "audio": true, "video": "video_only" } Specify only textual or audio document types { "static": "fast", "audio": true } Highest quality processing for all media types "all" */ export type UpdateDocumentFileParamsMode = | UpdateDocumentFileParamsMode1 | UpdateDocumentFileParams21 | UpdateDocumentFileParams22; export type UpdateDocumentFileParamsFile = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; export type UpdateDocumentFileParams = { /** * Partition strategy for the document. Different strategies exist for textual, audio and video file types and you can set the strategy you want for each file type, or just for textual types. For textual documents the options are `'hi_res'` or `'fast'`. When set to `'hi_res'`, images and tables will be extracted from the document. `'fast'` will only extract text. `'fast'` may be up to 20x faster than `'hi_res'`. `hi_res` is only applicable for Word documents, PDFs, Images, and PowerPoints. Images will always be processed in `hi_res`. If `hi_res` is set for an unsupported document type, it will be processed and billed in `fast` mode. For audio files, the options are true or false. True if you want to process audio, false otherwise. For video files, the options are `'audio_only'`, `'video_only'`, `'audio_video'`. `'audio_only'` will extract just the audio part of the video. `'video_only'` will similarly just extract the video part, ignoring audio. `'audio_video'` will extract both audio and video. To process all media types at the highest quality, use `'all'`. When you specify audio or video stategies, the format must be a JSON object. In this case, textual documents are denoted by the key "static". If you omit a key, that document type won't be processd. See examples below. Examples Textual documents only "fast" Video documents only { "video": "audio_video" } Specify multiple document types { "static": "hi_res", "audio": true, "video": "video_only" } Specify only textual or audio document types { "static": "fast", "audio": true } Highest quality processing for all media types "all" */ mode?: | UpdateDocumentFileParamsMode1 | UpdateDocumentFileParams21 | UpdateDocumentFileParams22 | undefined; /** * The binary file to upload, extract, and index for retrieval. The following file types are supported: Plain Text: `.eml` `.html` `.json` `.md` `.msg` `.rst` `.rtf` `.txt` `.xml` * * @remarks * Images: `.png` `.webp` `.jpg` `.jpeg` `.tiff` `.bmp` `.heic` * Documents: `.csv` `.doc` `.docx` `.epub` `.epub+zip` `.odt` `.pdf` `.ppt` `.pptx` `.tsv` `.xlsx` `.xls`. PDF files over 2000 pages are not supported in hi_res mode. */ file: UpdateDocumentFileParamsFile | Blob; }; /** @internal */ export const UpdateDocumentFileParams22$inboundSchema: z.ZodType< UpdateDocumentFileParams22, z.ZodTypeDef, unknown > = z.object({}); /** @internal */ export type UpdateDocumentFileParams22$Outbound = {}; /** @internal */ export const UpdateDocumentFileParams22$outboundSchema: z.ZodType< UpdateDocumentFileParams22$Outbound, z.ZodTypeDef, UpdateDocumentFileParams22 > = z.object({}); export function updateDocumentFileParams22ToJSON( updateDocumentFileParams22: UpdateDocumentFileParams22, ): string { return JSON.stringify( UpdateDocumentFileParams22$outboundSchema.parse(updateDocumentFileParams22), ); } export function updateDocumentFileParams22FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UpdateDocumentFileParams22$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateDocumentFileParams22' from JSON`, ); } /** @internal */ export const UpdateDocumentFileParams21$inboundSchema: z.ZodNativeEnum< typeof UpdateDocumentFileParams21 > = z.nativeEnum(UpdateDocumentFileParams21); /** @internal */ export const UpdateDocumentFileParams21$outboundSchema: z.ZodNativeEnum< typeof UpdateDocumentFileParams21 > = UpdateDocumentFileParams21$inboundSchema; /** @internal */ export const Mode2$inboundSchema: z.ZodType = z .union([ UpdateDocumentFileParams21$inboundSchema, z.lazy(() => UpdateDocumentFileParams22$inboundSchema), ]); /** @internal */ export type Mode2$Outbound = string | UpdateDocumentFileParams22$Outbound; /** @internal */ export const Mode2$outboundSchema: z.ZodType< Mode2$Outbound, z.ZodTypeDef, Mode2 > = z.union([ UpdateDocumentFileParams21$outboundSchema, z.lazy(() => UpdateDocumentFileParams22$outboundSchema), ]); export function mode2ToJSON(mode2: Mode2): string { return JSON.stringify(Mode2$outboundSchema.parse(mode2)); } export function mode2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Mode2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Mode2' from JSON`, ); } /** @internal */ export const UpdateDocumentFileParamsModeStatic$inboundSchema: z.ZodNativeEnum< typeof UpdateDocumentFileParamsModeStatic > = z.nativeEnum(UpdateDocumentFileParamsModeStatic); /** @internal */ export const UpdateDocumentFileParamsModeStatic$outboundSchema: z.ZodNativeEnum< typeof UpdateDocumentFileParamsModeStatic > = UpdateDocumentFileParamsModeStatic$inboundSchema; /** @internal */ export const UpdateDocumentFileParamsModeVideo$inboundSchema: z.ZodNativeEnum< typeof UpdateDocumentFileParamsModeVideo > = z.nativeEnum(UpdateDocumentFileParamsModeVideo); /** @internal */ export const UpdateDocumentFileParamsModeVideo$outboundSchema: z.ZodNativeEnum< typeof UpdateDocumentFileParamsModeVideo > = UpdateDocumentFileParamsModeVideo$inboundSchema; /** @internal */ export const UpdateDocumentFileParamsMode1$inboundSchema: z.ZodType< UpdateDocumentFileParamsMode1, z.ZodTypeDef, unknown > = z.object({ static: z.nullable(UpdateDocumentFileParamsModeStatic$inboundSchema) .optional(), audio: z.nullable(z.boolean()).optional(), video: z.nullable(UpdateDocumentFileParamsModeVideo$inboundSchema).optional(), }); /** @internal */ export type UpdateDocumentFileParamsMode1$Outbound = { static?: string | null | undefined; audio?: boolean | null | undefined; video?: string | null | undefined; }; /** @internal */ export const UpdateDocumentFileParamsMode1$outboundSchema: z.ZodType< UpdateDocumentFileParamsMode1$Outbound, z.ZodTypeDef, UpdateDocumentFileParamsMode1 > = z.object({ static: z.nullable(UpdateDocumentFileParamsModeStatic$outboundSchema) .optional(), audio: z.nullable(z.boolean()).optional(), video: z.nullable(UpdateDocumentFileParamsModeVideo$outboundSchema) .optional(), }); export function updateDocumentFileParamsMode1ToJSON( updateDocumentFileParamsMode1: UpdateDocumentFileParamsMode1, ): string { return JSON.stringify( UpdateDocumentFileParamsMode1$outboundSchema.parse( updateDocumentFileParamsMode1, ), ); } export function updateDocumentFileParamsMode1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UpdateDocumentFileParamsMode1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateDocumentFileParamsMode1' from JSON`, ); } /** @internal */ export const UpdateDocumentFileParamsMode$inboundSchema: z.ZodType< UpdateDocumentFileParamsMode, z.ZodTypeDef, unknown > = z.union([ z.lazy(() => UpdateDocumentFileParamsMode1$inboundSchema), z.union([ UpdateDocumentFileParams21$inboundSchema, z.lazy(() => UpdateDocumentFileParams22$inboundSchema), ]), ]); /** @internal */ export type UpdateDocumentFileParamsMode$Outbound = | UpdateDocumentFileParamsMode1$Outbound | string | UpdateDocumentFileParams22$Outbound; /** @internal */ export const UpdateDocumentFileParamsMode$outboundSchema: z.ZodType< UpdateDocumentFileParamsMode$Outbound, z.ZodTypeDef, UpdateDocumentFileParamsMode > = z.union([ z.lazy(() => UpdateDocumentFileParamsMode1$outboundSchema), z.union([ UpdateDocumentFileParams21$outboundSchema, z.lazy(() => UpdateDocumentFileParams22$outboundSchema), ]), ]); export function updateDocumentFileParamsModeToJSON( updateDocumentFileParamsMode: UpdateDocumentFileParamsMode, ): string { return JSON.stringify( UpdateDocumentFileParamsMode$outboundSchema.parse( updateDocumentFileParamsMode, ), ); } export function updateDocumentFileParamsModeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UpdateDocumentFileParamsMode$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateDocumentFileParamsMode' from JSON`, ); } /** @internal */ export const UpdateDocumentFileParamsFile$inboundSchema: z.ZodType< UpdateDocumentFileParamsFile, z.ZodTypeDef, unknown > = z.object({ fileName: z.string(), content: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]), }); /** @internal */ export type UpdateDocumentFileParamsFile$Outbound = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; /** @internal */ export const UpdateDocumentFileParamsFile$outboundSchema: z.ZodType< UpdateDocumentFileParamsFile$Outbound, z.ZodTypeDef, UpdateDocumentFileParamsFile > = z.object({ fileName: z.string(), content: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]), }); export function updateDocumentFileParamsFileToJSON( updateDocumentFileParamsFile: UpdateDocumentFileParamsFile, ): string { return JSON.stringify( UpdateDocumentFileParamsFile$outboundSchema.parse( updateDocumentFileParamsFile, ), ); } export function updateDocumentFileParamsFileFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UpdateDocumentFileParamsFile$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateDocumentFileParamsFile' from JSON`, ); } /** @internal */ export const UpdateDocumentFileParams$inboundSchema: z.ZodType< UpdateDocumentFileParams, z.ZodTypeDef, unknown > = z.object({ mode: z.union([ z.lazy(() => UpdateDocumentFileParamsMode1$inboundSchema), z.union([ UpdateDocumentFileParams21$inboundSchema, z.lazy(() => UpdateDocumentFileParams22$inboundSchema), ]), ]).optional(), file: z.lazy(() => UpdateDocumentFileParamsFile$inboundSchema), }); /** @internal */ export type UpdateDocumentFileParams$Outbound = { mode?: | UpdateDocumentFileParamsMode1$Outbound | string | UpdateDocumentFileParams22$Outbound | undefined; file: UpdateDocumentFileParamsFile$Outbound | Blob; }; /** @internal */ export const UpdateDocumentFileParams$outboundSchema: z.ZodType< UpdateDocumentFileParams$Outbound, z.ZodTypeDef, UpdateDocumentFileParams > = z.object({ mode: z.union([ z.lazy(() => UpdateDocumentFileParamsMode1$outboundSchema), z.union([ UpdateDocumentFileParams21$outboundSchema, z.lazy(() => UpdateDocumentFileParams22$outboundSchema), ]), ]).optional(), file: z.lazy(() => UpdateDocumentFileParamsFile$outboundSchema).or( blobLikeSchema, ), }); export function updateDocumentFileParamsToJSON( updateDocumentFileParams: UpdateDocumentFileParams, ): string { return JSON.stringify( UpdateDocumentFileParams$outboundSchema.parse(updateDocumentFileParams), ); } export function updateDocumentFileParamsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UpdateDocumentFileParams$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateDocumentFileParams' from JSON`, ); }