/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: dbe38074e538 */ import * as z from "zod/v3"; 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"; import { FacetFilter, FacetFilter$inboundSchema } from "./facetfilter.js"; import { FacetResult, FacetResult$inboundSchema } from "./facetresult.js"; import { GeneratedQna, GeneratedQna$inboundSchema } from "./generatedqna.js"; import { GleanDataError, GleanDataError$inboundSchema, } from "./gleandataerror.js"; import { ResultsDescription, ResultsDescription$inboundSchema, } from "./resultsdescription.js"; import { ResultTab, ResultTab$inboundSchema } from "./resulttab.js"; import { SearchResponseMetadata, SearchResponseMetadata$inboundSchema, } from "./searchresponsemetadata.js"; import { SearchResult, SearchResult$inboundSchema } from "./searchresult.js"; import { SessionInfo, SessionInfo$inboundSchema } from "./sessioninfo.js"; import { StructuredResult, StructuredResult$inboundSchema, } from "./structuredresult.js"; export type SearchResponse = { /** * A token that should be passed for additional requests related to this request (such as more results requests). */ trackingToken?: string | undefined; sessionInfo?: SessionInfo | undefined; results?: Array | undefined; structuredResults?: Array | undefined; generatedQnaResult?: GeneratedQna | undefined; gleanDataError?: GleanDataError | undefined; /** * A platform-generated request ID to correlate backend logs. */ requestID?: string | undefined; /** * Time in milliseconds the backend took to respond to the request. */ backendTimeMillis?: number | undefined; /** * List of experiment ids for the corresponding request. */ experimentIds?: Array | undefined; metadata?: SearchResponseMetadata | undefined; facetResults?: Array | undefined; /** * All result tabs available for the current query. Populated if QUERY_METADATA is specified in the request. */ resultTabs?: Array | undefined; /** * The unique IDs of the result tabs to which this response belongs. */ resultTabIds?: Array | undefined; resultsDescription?: ResultsDescription | undefined; /** * The actual applied facet filters based on the operators and facetFilters in the query. Useful for mapping typed operators to visual facets. */ rewrittenFacetFilters?: Array | undefined; /** * Cursor that indicates the start of the next page of results. To be passed in "more" requests for this query. */ cursor?: string | undefined; /** * Whether more results are available. Use cursor to retrieve them. */ hasMoreResults?: boolean | undefined; }; /** @internal */ export const SearchResponse$inboundSchema: z.ZodType< SearchResponse, z.ZodTypeDef, unknown > = z.object({ trackingToken: z.string().optional(), sessionInfo: SessionInfo$inboundSchema.optional(), results: z.array(SearchResult$inboundSchema).optional(), structuredResults: z.array(StructuredResult$inboundSchema).optional(), generatedQnaResult: GeneratedQna$inboundSchema.optional(), errorInfo: GleanDataError$inboundSchema.optional(), requestID: z.string().optional(), backendTimeMillis: z.number().int().optional(), experimentIds: z.array(z.number().int()).optional(), metadata: SearchResponseMetadata$inboundSchema.optional(), facetResults: z.array(FacetResult$inboundSchema).optional(), resultTabs: z.array(ResultTab$inboundSchema).optional(), resultTabIds: z.array(z.string()).optional(), resultsDescription: ResultsDescription$inboundSchema.optional(), rewrittenFacetFilters: z.array(FacetFilter$inboundSchema).optional(), cursor: z.string().optional(), hasMoreResults: z.boolean().optional(), }).transform((v) => { return remap$(v, { "errorInfo": "gleanDataError", }); }); export function searchResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SearchResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SearchResponse' from JSON`, ); }