/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: f20a2cbff3b4 */ 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 { FacetFilter, FacetFilter$inboundSchema, FacetFilter$Outbound, FacetFilter$outboundSchema, } from "./facetfilter.js"; import { Person, Person$inboundSchema, Person$Outbound, Person$outboundSchema, } from "./person.js"; export type PinDocument = { /** * The query strings for which the pinned result will show. */ queries?: Array | undefined; /** * Filters which restrict who should see the pinned document. Values are taken from the corresponding filters in people search. */ audienceFilters?: Array | undefined; /** * The opaque id of the pin. */ id?: string | undefined; /** * The document which should be a pinned result. */ documentId: string; attribution?: Person | undefined; updatedBy?: Person | undefined; createTime?: Date | undefined; updateTime?: Date | undefined; }; /** @internal */ export const PinDocument$inboundSchema: z.ZodType< PinDocument, z.ZodTypeDef, unknown > = z.object({ queries: z.array(z.string()).optional(), audienceFilters: z.array(FacetFilter$inboundSchema).optional(), id: z.string().optional(), documentId: z.string(), attribution: z.lazy(() => Person$inboundSchema).optional(), updatedBy: 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(), }); /** @internal */ export type PinDocument$Outbound = { queries?: Array | undefined; audienceFilters?: Array | undefined; id?: string | undefined; documentId: string; attribution?: Person$Outbound | undefined; updatedBy?: Person$Outbound | undefined; createTime?: string | undefined; updateTime?: string | undefined; }; /** @internal */ export const PinDocument$outboundSchema: z.ZodType< PinDocument$Outbound, z.ZodTypeDef, PinDocument > = z.object({ queries: z.array(z.string()).optional(), audienceFilters: z.array(FacetFilter$outboundSchema).optional(), id: z.string().optional(), documentId: z.string(), attribution: z.lazy(() => Person$outboundSchema).optional(), updatedBy: z.lazy(() => Person$outboundSchema).optional(), createTime: z.date().transform(v => v.toISOString()).optional(), updateTime: z.date().transform(v => v.toISOString()).optional(), }); export function pinDocumentToJSON(pinDocument: PinDocument): string { return JSON.stringify(PinDocument$outboundSchema.parse(pinDocument)); } export function pinDocumentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PinDocument$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PinDocument' from JSON`, ); }