/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 607d251000a8 */ 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 { FacetFilterValue, FacetFilterValue$inboundSchema, FacetFilterValue$Outbound, FacetFilterValue$outboundSchema, } from "./facetfiltervalue.js"; export type FacetFilter = { fieldName?: string | undefined; /** * Within a single FacetFilter, the values are to be treated like an OR. For example, fieldName type with values [EQUALS Presentation, EQUALS Spreadsheet] means we want to show a document if it's a Presentation OR a Spreadsheet. */ values?: Array | undefined; /** * Indicates the value of a facet, if any, that the given facet is grouped under. This is only used for nested facets, for example, fieldName could be owner and groupName would be Spreadsheet if showing all owners for spreadsheets as a nested facet. */ groupName?: string | undefined; }; /** @internal */ export const FacetFilter$inboundSchema: z.ZodType< FacetFilter, z.ZodTypeDef, unknown > = z.object({ fieldName: z.string().optional(), values: z.array(FacetFilterValue$inboundSchema).optional(), groupName: z.string().optional(), }); /** @internal */ export type FacetFilter$Outbound = { fieldName?: string | undefined; values?: Array | undefined; groupName?: string | undefined; }; /** @internal */ export const FacetFilter$outboundSchema: z.ZodType< FacetFilter$Outbound, z.ZodTypeDef, FacetFilter > = z.object({ fieldName: z.string().optional(), values: z.array(FacetFilterValue$outboundSchema).optional(), groupName: z.string().optional(), }); export function facetFilterToJSON(facetFilter: FacetFilter): string { return JSON.stringify(FacetFilter$outboundSchema.parse(facetFilter)); } export function facetFilterFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FacetFilter$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FacetFilter' from JSON`, ); }