/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: be3790f19e46 */ 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"; import { QuerySuggestion, QuerySuggestion$inboundSchema, QuerySuggestion$Outbound, QuerySuggestion$outboundSchema, } from "./querysuggestion.js"; import { SearchResult, SearchResult$inboundSchema, SearchResult$Outbound, SearchResult$outboundSchema, } from "./searchresult.js"; /** * How this document relates to the including entity. */ export const Relation = { Attachment: "ATTACHMENT", /** * Canonical documents for the entity, such as overview docs, architecture docs elastic. */ Canonical: "CANONICAL", Case: "CASE", ContactLower: "contact", ContactUpper: "CONTACT", ConversationMessages: "CONVERSATION_MESSAGES", Expert: "EXPERT", From: "FROM", Highlight: "HIGHLIGHT", OpportunityLower: "opportunity", OpportunityUpper: "OPPORTUNITY", Recent: "RECENT", Source: "SOURCE", Ticket: "TICKET", Transcript: "TRANSCRIPT", With: "WITH", } as const; /** * How this document relates to the including entity. */ export type Relation = OpenEnum; export type RelatedDocuments = { /** * How this document relates to the including entity. */ relation?: Relation | undefined; /** * Which entity in the response that this entity relates to. Relevant when there are multiple entities associated with the response (such as merged customers) */ associatedEntityId?: string | undefined; querySuggestion?: QuerySuggestion | undefined; /** * A truncated list of documents with this relation. TO BE DEPRECATED. * * @deprecated field: Deprecated on 2026-02-05, removal scheduled for 2026-10-15: Field is deprecated. */ documents?: Array | undefined; /** * A truncated list of documents associated with this relation. To be used in favor of `documents` because it contains a trackingToken. */ results?: Array | undefined; }; /** @internal */ export const Relation$inboundSchema: z.ZodType< Relation, z.ZodTypeDef, unknown > = openEnums.inboundSchema(Relation); /** @internal */ export const Relation$outboundSchema: z.ZodType< string, z.ZodTypeDef, Relation > = openEnums.outboundSchema(Relation); /** @internal */ export const RelatedDocuments$inboundSchema: z.ZodType< RelatedDocuments, z.ZodTypeDef, unknown > = z.object({ relation: Relation$inboundSchema.optional(), associatedEntityId: z.string().optional(), querySuggestion: z.lazy(() => QuerySuggestion$inboundSchema).optional(), documents: z.array(z.lazy(() => Document$inboundSchema)).optional(), results: z.array(z.lazy(() => SearchResult$inboundSchema)).optional(), }); /** @internal */ export type RelatedDocuments$Outbound = { relation?: string | undefined; associatedEntityId?: string | undefined; querySuggestion?: QuerySuggestion$Outbound | undefined; documents?: Array | undefined; results?: Array | undefined; }; /** @internal */ export const RelatedDocuments$outboundSchema: z.ZodType< RelatedDocuments$Outbound, z.ZodTypeDef, RelatedDocuments > = z.object({ relation: Relation$outboundSchema.optional(), associatedEntityId: z.string().optional(), querySuggestion: z.lazy(() => QuerySuggestion$outboundSchema).optional(), documents: z.array(z.lazy(() => Document$outboundSchema)).optional(), results: z.array(z.lazy(() => SearchResult$outboundSchema)).optional(), }); export function relatedDocumentsToJSON( relatedDocuments: RelatedDocuments, ): string { return JSON.stringify( RelatedDocuments$outboundSchema.parse(relatedDocuments), ); } export function relatedDocumentsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RelatedDocuments$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RelatedDocuments' from JSON`, ); }