/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: ee7517d8d8bf */ 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 { Person, Person$inboundSchema, Person$Outbound, Person$outboundSchema, } from "./person.js"; export type Reaction = { type?: string | undefined; /** * The count of the reaction type on the document. */ count?: number | undefined; reactors?: Array | undefined; /** * Whether the user in context reacted with this type to the document. */ reactedByViewer?: boolean | undefined; }; /** @internal */ export const Reaction$inboundSchema: z.ZodType< Reaction, z.ZodTypeDef, unknown > = z.object({ type: z.string().optional(), count: z.number().int().optional(), reactors: z.array(z.lazy(() => Person$inboundSchema)).optional(), reactedByViewer: z.boolean().optional(), }); /** @internal */ export type Reaction$Outbound = { type?: string | undefined; count?: number | undefined; reactors?: Array | undefined; reactedByViewer?: boolean | undefined; }; /** @internal */ export const Reaction$outboundSchema: z.ZodType< Reaction$Outbound, z.ZodTypeDef, Reaction > = z.object({ type: z.string().optional(), count: z.number().int().optional(), reactors: z.array(z.lazy(() => Person$outboundSchema)).optional(), reactedByViewer: z.boolean().optional(), }); export function reactionToJSON(reaction: Reaction): string { return JSON.stringify(Reaction$outboundSchema.parse(reaction)); } export function reactionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Reaction$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Reaction' from JSON`, ); }