/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: a14d2184d891 */ 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 { TextRange, TextRange$inboundSchema, TextRange$Outbound, TextRange$outboundSchema, } from "./textrange.js"; export type SearchResultSnippet = { /** * The mime type of the snippets, currently either text/plain or text/html. */ mimeType?: string | undefined; /** * A matching snippet from the document with no highlights. */ text?: string | undefined; /** * Used for sorting based off the snippet's location within all_snippetable_text */ snippetTextOrdering?: number | undefined; /** * The bolded ranges within text. */ ranges?: Array | undefined; /** * A URL, generated based on availability, that links to the position of the snippet text or to the nearest header above the snippet text. */ url?: string | undefined; /** * A matching snippet from the document. Query term matches are marked by the unicode characters uE006 and uE007. Use 'text' field instead. * * @deprecated field: Deprecated on 2026-02-05, removal scheduled for 2026-10-15: Use 'text' field instead. */ snippet?: string | undefined; }; /** @internal */ export const SearchResultSnippet$inboundSchema: z.ZodType< SearchResultSnippet, z.ZodTypeDef, unknown > = z.object({ mimeType: z.string().optional(), text: z.string().optional(), snippetTextOrdering: z.number().int().optional(), ranges: z.array(z.lazy(() => TextRange$inboundSchema)).optional(), url: z.string().optional(), snippet: z.string().optional(), }); /** @internal */ export type SearchResultSnippet$Outbound = { mimeType?: string | undefined; text?: string | undefined; snippetTextOrdering?: number | undefined; ranges?: Array | undefined; url?: string | undefined; snippet?: string | undefined; }; /** @internal */ export const SearchResultSnippet$outboundSchema: z.ZodType< SearchResultSnippet$Outbound, z.ZodTypeDef, SearchResultSnippet > = z.object({ mimeType: z.string().optional(), text: z.string().optional(), snippetTextOrdering: z.number().int().optional(), ranges: z.array(z.lazy(() => TextRange$outboundSchema)).optional(), url: z.string().optional(), snippet: z.string().optional(), }); export function searchResultSnippetToJSON( searchResultSnippet: SearchResultSnippet, ): string { return JSON.stringify( SearchResultSnippet$outboundSchema.parse(searchResultSnippet), ); } export function searchResultSnippetFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SearchResultSnippet$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SearchResultSnippet' from JSON`, ); }