/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 1bc812c19de1 */ 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 { AnswerLikes, AnswerLikes$inboundSchema, AnswerLikes$Outbound, AnswerLikes$outboundSchema, } from "./answerlikes.js"; import { Collection, Collection$inboundSchema, Collection$Outbound, Collection$outboundSchema, } from "./collection.js"; import { Document, Document$inboundSchema, Document$Outbound, Document$outboundSchema, } from "./document.js"; import { DocumentSpecUnion, DocumentSpecUnion$inboundSchema, DocumentSpecUnion$Outbound, DocumentSpecUnion$outboundSchema, } from "./documentspecunion.js"; import { FacetFilter, FacetFilter$inboundSchema, FacetFilter$Outbound, FacetFilter$outboundSchema, } from "./facetfilter.js"; import { ObjectPermissions, ObjectPermissions$inboundSchema, ObjectPermissions$Outbound, ObjectPermissions$outboundSchema, } from "./objectpermissions.js"; import { Person, Person$inboundSchema, Person$Outbound, Person$outboundSchema, } from "./person.js"; import { StructuredText, StructuredText$inboundSchema, StructuredText$Outbound, StructuredText$outboundSchema, } from "./structuredtext.js"; import { UserRoleSpecification, UserRoleSpecification$inboundSchema, UserRoleSpecification$Outbound, UserRoleSpecification$outboundSchema, } from "./userrolespecification.js"; import { Verification, Verification$inboundSchema, Verification$Outbound, Verification$outboundSchema, } from "./verification.js"; export const AnswerSourceType = { Document: "DOCUMENT", Assistant: "ASSISTANT", } as const; export type AnswerSourceType = OpenEnum; export type Answer = { /** * The opaque ID of the Answer. */ id: number; /** * Glean Document ID of the Answer. The Glean Document ID is supported for cases where the Answer ID isn't available. If both are available, using the Answer ID is preferred. */ docId?: string | undefined; question?: string | undefined; /** * Additional ways of phrasing this question. */ questionVariations?: Array | undefined; /** * The plain text answer to the question. */ bodyText?: string | undefined; /** * The parent board ID of this Answer, or 0 if it's a floating Answer. Adding Answers to Answer Boards is no longer permitted. * * @deprecated field: Deprecated on 2026-02-05, removal scheduled for 2026-10-15: Answer Boards no longer supported. */ boardId?: number | undefined; /** * Filters which restrict who should see the answer. Values are taken from the corresponding filters in people search. */ audienceFilters?: Array | undefined; /** * A list of user roles for the answer added by the owner. */ addedRoles?: Array | undefined; /** * A list of user roles for the answer removed by the owner. */ removedRoles?: Array | undefined; /** * A list of roles for this answer explicitly granted by an owner, editor, or admin. */ roles?: Array | undefined; sourceDocumentSpec?: DocumentSpecUnion | undefined; sourceType?: AnswerSourceType | undefined; permissions?: ObjectPermissions | undefined; combinedAnswerText?: StructuredText | undefined; likes?: AnswerLikes | undefined; author?: Person | undefined; /** * The time the answer was created in ISO format (ISO 8601). */ createTime?: Date | undefined; /** * The time the answer was last updated in ISO format (ISO 8601). */ updateTime?: Date | undefined; updatedBy?: Person | undefined; verification?: Verification | undefined; /** * The collections to which the answer belongs. */ collections?: Array | undefined; /** * The document's document_category(.proto). */ documentCategory?: string | undefined; sourceDocument?: Document | undefined; }; /** @internal */ export const AnswerSourceType$inboundSchema: z.ZodType< AnswerSourceType, z.ZodTypeDef, unknown > = openEnums.inboundSchema(AnswerSourceType); /** @internal */ export const AnswerSourceType$outboundSchema: z.ZodType< string, z.ZodTypeDef, AnswerSourceType > = openEnums.outboundSchema(AnswerSourceType); /** @internal */ export const Answer$inboundSchema: z.ZodType = z .object({ id: z.number().int(), docId: z.string().optional(), question: z.string().optional(), questionVariations: z.array(z.string()).optional(), bodyText: z.string().optional(), boardId: z.number().int().optional(), audienceFilters: z.array(FacetFilter$inboundSchema).optional(), addedRoles: z.array(z.lazy(() => UserRoleSpecification$inboundSchema)) .optional(), removedRoles: z.array(z.lazy(() => UserRoleSpecification$inboundSchema)) .optional(), roles: z.array(z.lazy(() => UserRoleSpecification$inboundSchema)) .optional(), sourceDocumentSpec: DocumentSpecUnion$inboundSchema.optional(), sourceType: AnswerSourceType$inboundSchema.optional(), permissions: ObjectPermissions$inboundSchema.optional(), combinedAnswerText: z.lazy(() => StructuredText$inboundSchema).optional(), likes: z.lazy(() => AnswerLikes$inboundSchema).optional(), author: z.lazy(() => Person$inboundSchema).optional(), createTime: z.string().datetime({ offset: true }).transform(v => new Date(v) ).optional(), updateTime: z.string().datetime({ offset: true }).transform(v => new Date(v) ).optional(), updatedBy: z.lazy(() => Person$inboundSchema).optional(), verification: z.lazy(() => Verification$inboundSchema).optional(), collections: z.array(z.lazy(() => Collection$inboundSchema)).optional(), documentCategory: z.string().optional(), sourceDocument: z.lazy(() => Document$inboundSchema).optional(), }); /** @internal */ export type Answer$Outbound = { id: number; docId?: string | undefined; question?: string | undefined; questionVariations?: Array | undefined; bodyText?: string | undefined; boardId?: number | undefined; audienceFilters?: Array | undefined; addedRoles?: Array | undefined; removedRoles?: Array | undefined; roles?: Array | undefined; sourceDocumentSpec?: DocumentSpecUnion$Outbound | undefined; sourceType?: string | undefined; permissions?: ObjectPermissions$Outbound | undefined; combinedAnswerText?: StructuredText$Outbound | undefined; likes?: AnswerLikes$Outbound | undefined; author?: Person$Outbound | undefined; createTime?: string | undefined; updateTime?: string | undefined; updatedBy?: Person$Outbound | undefined; verification?: Verification$Outbound | undefined; collections?: Array | undefined; documentCategory?: string | undefined; sourceDocument?: Document$Outbound | undefined; }; /** @internal */ export const Answer$outboundSchema: z.ZodType< Answer$Outbound, z.ZodTypeDef, Answer > = z.object({ id: z.number().int(), docId: z.string().optional(), question: z.string().optional(), questionVariations: z.array(z.string()).optional(), bodyText: z.string().optional(), boardId: z.number().int().optional(), audienceFilters: z.array(FacetFilter$outboundSchema).optional(), addedRoles: z.array(z.lazy(() => UserRoleSpecification$outboundSchema)) .optional(), removedRoles: z.array(z.lazy(() => UserRoleSpecification$outboundSchema)) .optional(), roles: z.array(z.lazy(() => UserRoleSpecification$outboundSchema)).optional(), sourceDocumentSpec: DocumentSpecUnion$outboundSchema.optional(), sourceType: AnswerSourceType$outboundSchema.optional(), permissions: ObjectPermissions$outboundSchema.optional(), combinedAnswerText: z.lazy(() => StructuredText$outboundSchema).optional(), likes: z.lazy(() => AnswerLikes$outboundSchema).optional(), author: z.lazy(() => Person$outboundSchema).optional(), createTime: z.date().transform(v => v.toISOString()).optional(), updateTime: z.date().transform(v => v.toISOString()).optional(), updatedBy: z.lazy(() => Person$outboundSchema).optional(), verification: z.lazy(() => Verification$outboundSchema).optional(), collections: z.array(z.lazy(() => Collection$outboundSchema)).optional(), documentCategory: z.string().optional(), sourceDocument: z.lazy(() => Document$outboundSchema).optional(), }); export function answerToJSON(answer: Answer): string { return JSON.stringify(Answer$outboundSchema.parse(answer)); } export function answerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Answer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Answer' from JSON`, ); }