/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 89a265e58c26 */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Document, Document$inboundSchema, Document$Outbound, Document$outboundSchema, } from "./document.js"; export const TextRangeType = { Bold: "BOLD", Citation: "CITATION", Highlight: "HIGHLIGHT", Link: "LINK", } as const; export type TextRangeType = OpenEnum; /** * A subsection of a given string to which some special formatting should be applied. */ export type TextRange = { /** * The inclusive start index of the range. */ startIndex: number; /** * The exclusive end index of the range. */ endIndex?: number | undefined; type?: TextRangeType | undefined; /** * The URL associated with the range, if applicable. For example, the linked URL for a LINK range. */ url?: string | undefined; document?: Document | undefined; }; /** @internal */ export const TextRangeType$inboundSchema: z.ZodType< TextRangeType, z.ZodTypeDef, unknown > = openEnums.inboundSchema(TextRangeType); /** @internal */ export const TextRangeType$outboundSchema: z.ZodType< string, z.ZodTypeDef, TextRangeType > = openEnums.outboundSchema(TextRangeType); /** @internal */ export const TextRange$inboundSchema: z.ZodType< TextRange, z.ZodTypeDef, unknown > = z.object({ startIndex: z.number().int(), endIndex: z.number().int().optional(), type: TextRangeType$inboundSchema.optional(), url: z.string().optional(), document: z.lazy(() => Document$inboundSchema).optional(), }); /** @internal */ export type TextRange$Outbound = { startIndex: number; endIndex?: number | undefined; type?: string | undefined; url?: string | undefined; document?: Document$Outbound | undefined; }; /** @internal */ export const TextRange$outboundSchema: z.ZodType< TextRange$Outbound, z.ZodTypeDef, TextRange > = z.object({ startIndex: z.number().int(), endIndex: z.number().int().optional(), type: TextRangeType$outboundSchema.optional(), url: z.string().optional(), document: z.lazy(() => Document$outboundSchema).optional(), }); export function textRangeToJSON(textRange: TextRange): string { return JSON.stringify(TextRange$outboundSchema.parse(textRange)); } export function textRangeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TextRange$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TextRange' from JSON`, ); }