/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 975be41ec095 */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { SearchResultSnippet, SearchResultSnippet$inboundSchema, SearchResultSnippet$Outbound, SearchResultSnippet$outboundSchema, } from "./searchresultsnippet.js"; import { TextRange, TextRange$inboundSchema, TextRange$Outbound, TextRange$outboundSchema, } from "./textrange.js"; /** * Each text range from the response can correspond to an array of snippets from the citation source. */ export type ReferenceRange = { /** * A subsection of a given string to which some special formatting should be applied. */ textRange?: TextRange | undefined; snippets?: Array | undefined; }; /** @internal */ export const ReferenceRange$inboundSchema: z.ZodType< ReferenceRange, z.ZodTypeDef, unknown > = z.object({ textRange: TextRange$inboundSchema.optional(), snippets: z.array(SearchResultSnippet$inboundSchema).optional(), }); /** @internal */ export type ReferenceRange$Outbound = { textRange?: TextRange$Outbound | undefined; snippets?: Array | undefined; }; /** @internal */ export const ReferenceRange$outboundSchema: z.ZodType< ReferenceRange$Outbound, z.ZodTypeDef, ReferenceRange > = z.object({ textRange: TextRange$outboundSchema.optional(), snippets: z.array(SearchResultSnippet$outboundSchema).optional(), }); export function referenceRangeToJSON(referenceRange: ReferenceRange): string { return JSON.stringify(ReferenceRange$outboundSchema.parse(referenceRange)); } export function referenceRangeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ReferenceRange$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ReferenceRange' from JSON`, ); }