/* * 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 IndexTextRequest = { /** * The name of the index to add the document to */ indexName: string; /** * The ID of the document. If not provided, a unique document ID will be automatically generated by the server. * * @remarks */ docId?: string | undefined; /** * The text content of the document to be indexed */ content: string; /** * Title of the document to be indexed */ title?: string | undefined; /** * URL associated with the document to be indexed */ url?: string | undefined; /** * The ID of the file. If not provided, a unique file ID will be automatically generated by the server */ fileId?: string | 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; }; /** @internal */ export const IndexTextRequest$inboundSchema: z.ZodType< IndexTextRequest, z.ZodTypeDef, unknown > = z.object({ index_name: z.string(), doc_id: z.string().optional(), content: z.string(), title: z.string().optional(), url: z.string().optional(), file_id: z.string().optional(), metadata: z.record(z.any()).optional(), }).transform((v) => { return remap$(v, { "index_name": "indexName", "doc_id": "docId", "file_id": "fileId", }); }); /** @internal */ export type IndexTextRequest$Outbound = { index_name: string; doc_id?: string | undefined; content: string; title?: string | undefined; url?: string | undefined; file_id?: string | undefined; metadata?: { [k: string]: any } | undefined; }; /** @internal */ export const IndexTextRequest$outboundSchema: z.ZodType< IndexTextRequest$Outbound, z.ZodTypeDef, IndexTextRequest > = z.object({ indexName: z.string(), docId: z.string().optional(), content: z.string(), title: z.string().optional(), url: z.string().optional(), fileId: z.string().optional(), metadata: z.record(z.any()).optional(), }).transform((v) => { return remap$(v, { indexName: "index_name", docId: "doc_id", fileId: "file_id", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace IndexTextRequest$ { /** @deprecated use `IndexTextRequest$inboundSchema` instead. */ export const inboundSchema = IndexTextRequest$inboundSchema; /** @deprecated use `IndexTextRequest$outboundSchema` instead. */ export const outboundSchema = IndexTextRequest$outboundSchema; /** @deprecated use `IndexTextRequest$Outbound` instead. */ export type Outbound = IndexTextRequest$Outbound; } export function indexTextRequestToJSON( indexTextRequest: IndexTextRequest, ): string { return JSON.stringify( IndexTextRequest$outboundSchema.parse(indexTextRequest), ); } export function indexTextRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => IndexTextRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'IndexTextRequest' from JSON`, ); }