/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: cebabd4425f8 */ 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 { Answer, Answer$inboundSchema, Answer$Outbound, Answer$outboundSchema, } from "./answer.js"; import { AppResult, AppResult$inboundSchema, AppResult$Outbound, AppResult$outboundSchema, } from "./appresult.js"; import { ChatMetadata, ChatMetadata$inboundSchema, ChatMetadata$Outbound, ChatMetadata$outboundSchema, } from "./chatmetadata.js"; import { Code, Code$inboundSchema, Code$Outbound, Code$outboundSchema, } from "./code.js"; import { Collection, Collection$inboundSchema, Collection$Outbound, Collection$outboundSchema, } from "./collection.js"; import { CustomEntity, CustomEntity$inboundSchema, CustomEntity$Outbound, CustomEntity$outboundSchema, } from "./customentity.js"; import { Customer, Customer$inboundSchema, Customer$Outbound, Customer$outboundSchema, } from "./customer.js"; import { Disambiguation, Disambiguation$inboundSchema, Disambiguation$Outbound, Disambiguation$outboundSchema, } from "./disambiguation.js"; import { Document, Document$inboundSchema, Document$Outbound, Document$outboundSchema, } from "./document.js"; import { ExtractedQnA, ExtractedQnA$inboundSchema, ExtractedQnA$Outbound, ExtractedQnA$outboundSchema, } from "./extractedqna.js"; import { GeneratedQna, GeneratedQna$inboundSchema, GeneratedQna$Outbound, GeneratedQna$outboundSchema, } from "./generatedqna.js"; import { Meeting, Meeting$inboundSchema, Meeting$Outbound, Meeting$outboundSchema, } from "./meeting.js"; import { Person, Person$inboundSchema, Person$Outbound, Person$outboundSchema, } from "./person.js"; import { QuerySuggestionList, QuerySuggestionList$inboundSchema, QuerySuggestionList$Outbound, QuerySuggestionList$outboundSchema, } from "./querysuggestionlist.js"; import { RelatedDocuments, RelatedDocuments$inboundSchema, RelatedDocuments$Outbound, RelatedDocuments$outboundSchema, } from "./relateddocuments.js"; import { RelatedQuestion, RelatedQuestion$inboundSchema, RelatedQuestion$Outbound, RelatedQuestion$outboundSchema, } from "./relatedquestion.js"; import { SearchResultSnippet, SearchResultSnippet$inboundSchema, SearchResultSnippet$Outbound, SearchResultSnippet$outboundSchema, } from "./searchresultsnippet.js"; import { Shortcut, Shortcut$inboundSchema, Shortcut$Outbound, Shortcut$outboundSchema, } from "./shortcut.js"; import { Team, Team$inboundSchema, Team$Outbound, Team$outboundSchema, } from "./team.js"; /** * The level of visual distinction that should be given to a result. */ export const Prominence = { /** * A high-confidence result that should feature prominently on the page. */ Hero: "HERO", /** * May not be the best result but should be given additional visual distinction. */ Promoted: "PROMOTED", /** * Should not be distinct from any other results. */ Standard: "STANDARD", } as const; /** * The level of visual distinction that should be given to a result. */ export type Prominence = OpenEnum; /** * Source context for this result. Possible values depend on the result type. */ export const StructuredResultSource = { ExpertDetection: "EXPERT_DETECTION", EntityNlq: "ENTITY_NLQ", CalendarEvent: "CALENDAR_EVENT", Agent: "AGENT", } as const; /** * Source context for this result. Possible values depend on the result type. */ export type StructuredResultSource = OpenEnum; /** * A single object that can support any object in the work graph. Only a single object will be populated. */ export type StructuredResult = { document?: Document | undefined; person?: Person | undefined; customer?: Customer | undefined; team?: Team | undefined; customEntity?: CustomEntity | undefined; answer?: Answer | undefined; generatedQna?: GeneratedQna | undefined; extractedQnA?: ExtractedQnA | undefined; meeting?: Meeting | undefined; app?: AppResult | undefined; collection?: Collection | undefined; code?: Code | undefined; shortcut?: Shortcut | undefined; querySuggestions?: QuerySuggestionList | undefined; /** * Metadata of a Chat a user had with Glean Assistant. This contains no actual conversational content. */ chat?: ChatMetadata | undefined; /** * A list of documents related to this structured result. */ relatedDocuments?: Array | undefined; relatedQuestion?: RelatedQuestion | undefined; /** * A disambiguation between multiple entities with the same name */ disambiguation?: Disambiguation | undefined; /** * Any snippets associated to the populated object. */ snippets?: Array | undefined; /** * An opaque token that represents this particular result in this particular query. To be used for /feedback reporting. */ trackingToken?: string | undefined; /** * The level of visual distinction that should be given to a result. */ prominence?: Prominence | undefined; /** * Source context for this result. Possible values depend on the result type. */ source?: StructuredResultSource | undefined; }; /** @internal */ export const Prominence$inboundSchema: z.ZodType< Prominence, z.ZodTypeDef, unknown > = openEnums.inboundSchema(Prominence); /** @internal */ export const Prominence$outboundSchema: z.ZodType< string, z.ZodTypeDef, Prominence > = openEnums.outboundSchema(Prominence); /** @internal */ export const StructuredResultSource$inboundSchema: z.ZodType< StructuredResultSource, z.ZodTypeDef, unknown > = openEnums.inboundSchema(StructuredResultSource); /** @internal */ export const StructuredResultSource$outboundSchema: z.ZodType< string, z.ZodTypeDef, StructuredResultSource > = openEnums.outboundSchema(StructuredResultSource); /** @internal */ export const StructuredResult$inboundSchema: z.ZodType< StructuredResult, z.ZodTypeDef, unknown > = z.object({ document: z.lazy(() => Document$inboundSchema).optional(), person: z.lazy(() => Person$inboundSchema).optional(), customer: z.lazy(() => Customer$inboundSchema).optional(), team: z.lazy(() => Team$inboundSchema).optional(), customEntity: z.lazy(() => CustomEntity$inboundSchema).optional(), answer: z.lazy(() => Answer$inboundSchema).optional(), generatedQna: z.lazy(() => GeneratedQna$inboundSchema).optional(), extractedQnA: z.lazy(() => ExtractedQnA$inboundSchema).optional(), meeting: z.lazy(() => Meeting$inboundSchema).optional(), app: AppResult$inboundSchema.optional(), collection: z.lazy(() => Collection$inboundSchema).optional(), code: z.lazy(() => Code$inboundSchema).optional(), shortcut: z.lazy(() => Shortcut$inboundSchema).optional(), querySuggestions: z.lazy(() => QuerySuggestionList$inboundSchema).optional(), chat: z.lazy(() => ChatMetadata$inboundSchema).optional(), relatedDocuments: z.array(z.lazy(() => RelatedDocuments$inboundSchema)) .optional(), relatedQuestion: z.lazy(() => RelatedQuestion$inboundSchema).optional(), disambiguation: Disambiguation$inboundSchema.optional(), snippets: z.array(z.lazy(() => SearchResultSnippet$inboundSchema)).optional(), trackingToken: z.string().optional(), prominence: Prominence$inboundSchema.optional(), source: StructuredResultSource$inboundSchema.optional(), }); /** @internal */ export type StructuredResult$Outbound = { document?: Document$Outbound | undefined; person?: Person$Outbound | undefined; customer?: Customer$Outbound | undefined; team?: Team$Outbound | undefined; customEntity?: CustomEntity$Outbound | undefined; answer?: Answer$Outbound | undefined; generatedQna?: GeneratedQna$Outbound | undefined; extractedQnA?: ExtractedQnA$Outbound | undefined; meeting?: Meeting$Outbound | undefined; app?: AppResult$Outbound | undefined; collection?: Collection$Outbound | undefined; code?: Code$Outbound | undefined; shortcut?: Shortcut$Outbound | undefined; querySuggestions?: QuerySuggestionList$Outbound | undefined; chat?: ChatMetadata$Outbound | undefined; relatedDocuments?: Array | undefined; relatedQuestion?: RelatedQuestion$Outbound | undefined; disambiguation?: Disambiguation$Outbound | undefined; snippets?: Array | undefined; trackingToken?: string | undefined; prominence?: string | undefined; source?: string | undefined; }; /** @internal */ export const StructuredResult$outboundSchema: z.ZodType< StructuredResult$Outbound, z.ZodTypeDef, StructuredResult > = z.object({ document: z.lazy(() => Document$outboundSchema).optional(), person: z.lazy(() => Person$outboundSchema).optional(), customer: z.lazy(() => Customer$outboundSchema).optional(), team: z.lazy(() => Team$outboundSchema).optional(), customEntity: z.lazy(() => CustomEntity$outboundSchema).optional(), answer: z.lazy(() => Answer$outboundSchema).optional(), generatedQna: z.lazy(() => GeneratedQna$outboundSchema).optional(), extractedQnA: z.lazy(() => ExtractedQnA$outboundSchema).optional(), meeting: z.lazy(() => Meeting$outboundSchema).optional(), app: AppResult$outboundSchema.optional(), collection: z.lazy(() => Collection$outboundSchema).optional(), code: z.lazy(() => Code$outboundSchema).optional(), shortcut: z.lazy(() => Shortcut$outboundSchema).optional(), querySuggestions: z.lazy(() => QuerySuggestionList$outboundSchema).optional(), chat: z.lazy(() => ChatMetadata$outboundSchema).optional(), relatedDocuments: z.array(z.lazy(() => RelatedDocuments$outboundSchema)) .optional(), relatedQuestion: z.lazy(() => RelatedQuestion$outboundSchema).optional(), disambiguation: Disambiguation$outboundSchema.optional(), snippets: z.array(z.lazy(() => SearchResultSnippet$outboundSchema)) .optional(), trackingToken: z.string().optional(), prominence: Prominence$outboundSchema.optional(), source: StructuredResultSource$outboundSchema.optional(), }); export function structuredResultToJSON( structuredResult: StructuredResult, ): string { return JSON.stringify( StructuredResult$outboundSchema.parse(structuredResult), ); } export function structuredResultFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => StructuredResult$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StructuredResult' from JSON`, ); }