/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type Document = { /** * The unique identifier of the document */ docId: string; contentChunks: Array; /** * A cursor to fetch the next set of chunks (if available) */ nextCursor?: string | null | undefined; /** * Metadata associated with the document. Accepts key value pairs where the value can be a string, number, boolean, or list of strings. */ metadata?: { [k: string]: any } | undefined; /** * Title of the document */ title?: string | undefined; /** * URL associated with the document */ sourceUrl?: string | null | undefined; /** * Status of the document (pending, indexing, indexed) */ status?: string | undefined; /** * The URL of the image associated with the document */ imageUrl?: string | null | undefined; /** * The URL of the thumbnail associated with the document */ thumbnailUrl?: string | null | undefined; }; /** @internal */ export const Document$inboundSchema: z.ZodType< Document, z.ZodTypeDef, unknown > = z.object({ doc_id: z.string(), content_chunks: z.array(z.string()), next_cursor: z.nullable(z.string()).optional(), metadata: z.record(z.any()).optional(), title: z.string().optional(), source_url: z.nullable(z.string()).optional(), status: z.string().optional(), image_url: z.nullable(z.string()).optional(), thumbnail_url: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "doc_id": "docId", "content_chunks": "contentChunks", "next_cursor": "nextCursor", "source_url": "sourceUrl", "image_url": "imageUrl", "thumbnail_url": "thumbnailUrl", }); }); /** @internal */ export type Document$Outbound = { doc_id: string; content_chunks: Array; next_cursor?: string | null | undefined; metadata?: { [k: string]: any } | undefined; title?: string | undefined; source_url?: string | null | undefined; status?: string | undefined; image_url?: string | null | undefined; thumbnail_url?: string | null | undefined; }; /** @internal */ export const Document$outboundSchema: z.ZodType< Document$Outbound, z.ZodTypeDef, Document > = z.object({ docId: z.string(), contentChunks: z.array(z.string()), nextCursor: z.nullable(z.string()).optional(), metadata: z.record(z.any()).optional(), title: z.string().optional(), sourceUrl: z.nullable(z.string()).optional(), status: z.string().optional(), imageUrl: z.nullable(z.string()).optional(), thumbnailUrl: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { docId: "doc_id", contentChunks: "content_chunks", nextCursor: "next_cursor", sourceUrl: "source_url", imageUrl: "image_url", thumbnailUrl: "thumbnail_url", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Document$ { /** @deprecated use `Document$inboundSchema` instead. */ export const inboundSchema = Document$inboundSchema; /** @deprecated use `Document$outboundSchema` instead. */ export const outboundSchema = Document$outboundSchema; /** @deprecated use `Document$Outbound` instead. */ export type Outbound = Document$Outbound; } export function documentToJSON(document: Document): string { return JSON.stringify(Document$outboundSchema.parse(document)); } export function documentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Document$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Document' from JSON`, ); }