/* * 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"; import { MediaModeParam, MediaModeParam$inboundSchema, MediaModeParam$Outbound, MediaModeParam$outboundSchema, } from "./mediamodeparam.js"; export type CreateDocumentFromUrlParamsMetadata = | string | number | number | boolean | Array; export const Mode1 = { HiRes: "hi_res", Fast: "fast", } as const; export type Mode1 = ClosedEnum; /** * 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 CreateDocumentFromUrlParamsMode = Mode1 | MediaModeParam; export type CreateDocumentFromUrlParams = { name?: string | undefined; /** * Metadata for the document. Keys must be strings. Values may be strings, numbers, booleans, or lists of strings. Numbers may be integers or floating point and will be converted to 64 bit floating point. 1000 total values are allowed. Each item in an array counts towards the total. The following keys are reserved for internal use: `document_id`, `document_type`, `document_source`, `document_name`, `document_uploaded_at`, `start_time`, `end_time`, `chunk_content_type`. */ metadata?: | { [k: string]: string | number | number | boolean | Array } | 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" */ mode?: Mode1 | MediaModeParam | undefined; /** * An optional identifier for the document. A common value might be an id in an external system or the URL where the source file may be found. */ externalId?: string | null | undefined; /** * An optional partition identifier. Documents can be scoped to a partition. Partitions must be lowercase alphanumeric and may only include the special characters `_` and `-`. A partition is created any time a document is created. */ partition?: string | undefined; /** * Url of the file to download. Must be publicly accessible and HTTP or HTTPS scheme. */ url: string; }; /** @internal */ export const CreateDocumentFromUrlParamsMetadata$inboundSchema: z.ZodType< CreateDocumentFromUrlParamsMetadata, z.ZodTypeDef, unknown > = z.union([ z.string(), z.number().int(), z.number(), z.boolean(), z.array(z.string()), ]); /** @internal */ export type CreateDocumentFromUrlParamsMetadata$Outbound = | string | number | number | boolean | Array; /** @internal */ export const CreateDocumentFromUrlParamsMetadata$outboundSchema: z.ZodType< CreateDocumentFromUrlParamsMetadata$Outbound, z.ZodTypeDef, CreateDocumentFromUrlParamsMetadata > = z.union([ z.string(), z.number().int(), z.number(), z.boolean(), z.array(z.string()), ]); export function createDocumentFromUrlParamsMetadataToJSON( createDocumentFromUrlParamsMetadata: CreateDocumentFromUrlParamsMetadata, ): string { return JSON.stringify( CreateDocumentFromUrlParamsMetadata$outboundSchema.parse( createDocumentFromUrlParamsMetadata, ), ); } export function createDocumentFromUrlParamsMetadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateDocumentFromUrlParamsMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateDocumentFromUrlParamsMetadata' from JSON`, ); } /** @internal */ export const Mode1$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Mode1, ); /** @internal */ export const Mode1$outboundSchema: z.ZodNativeEnum = Mode1$inboundSchema; /** @internal */ export const CreateDocumentFromUrlParamsMode$inboundSchema: z.ZodType< CreateDocumentFromUrlParamsMode, z.ZodTypeDef, unknown > = z.union([Mode1$inboundSchema, MediaModeParam$inboundSchema]); /** @internal */ export type CreateDocumentFromUrlParamsMode$Outbound = | string | MediaModeParam$Outbound; /** @internal */ export const CreateDocumentFromUrlParamsMode$outboundSchema: z.ZodType< CreateDocumentFromUrlParamsMode$Outbound, z.ZodTypeDef, CreateDocumentFromUrlParamsMode > = z.union([Mode1$outboundSchema, MediaModeParam$outboundSchema]); export function createDocumentFromUrlParamsModeToJSON( createDocumentFromUrlParamsMode: CreateDocumentFromUrlParamsMode, ): string { return JSON.stringify( CreateDocumentFromUrlParamsMode$outboundSchema.parse( createDocumentFromUrlParamsMode, ), ); } export function createDocumentFromUrlParamsModeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateDocumentFromUrlParamsMode$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateDocumentFromUrlParamsMode' from JSON`, ); } /** @internal */ export const CreateDocumentFromUrlParams$inboundSchema: z.ZodType< CreateDocumentFromUrlParams, z.ZodTypeDef, unknown > = z.object({ name: z.string().optional(), metadata: z.record( z.union([ z.string(), z.number().int(), z.number(), z.boolean(), z.array(z.string()), ]), ).optional(), mode: z.union([Mode1$inboundSchema, MediaModeParam$inboundSchema]).optional(), external_id: z.nullable(z.string()).optional(), partition: z.string().optional(), url: z.string(), }).transform((v) => { return remap$(v, { "external_id": "externalId", }); }); /** @internal */ export type CreateDocumentFromUrlParams$Outbound = { name?: string | undefined; metadata?: | { [k: string]: string | number | number | boolean | Array } | undefined; mode?: string | MediaModeParam$Outbound | undefined; external_id?: string | null | undefined; partition?: string | undefined; url: string; }; /** @internal */ export const CreateDocumentFromUrlParams$outboundSchema: z.ZodType< CreateDocumentFromUrlParams$Outbound, z.ZodTypeDef, CreateDocumentFromUrlParams > = z.object({ name: z.string().optional(), metadata: z.record( z.union([ z.string(), z.number().int(), z.number(), z.boolean(), z.array(z.string()), ]), ).optional(), mode: z.union([Mode1$outboundSchema, MediaModeParam$outboundSchema]) .optional(), externalId: z.nullable(z.string()).optional(), partition: z.string().optional(), url: z.string(), }).transform((v) => { return remap$(v, { externalId: "external_id", }); }); export function createDocumentFromUrlParamsToJSON( createDocumentFromUrlParams: CreateDocumentFromUrlParams, ): string { return JSON.stringify( CreateDocumentFromUrlParams$outboundSchema.parse( createDocumentFromUrlParams, ), ); } export function createDocumentFromUrlParamsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateDocumentFromUrlParams$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateDocumentFromUrlParams' from JSON`, ); }