/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FileSearchComparisonFilter, FileSearchComparisonFilter$inboundSchema, FileSearchComparisonFilter$Outbound, FileSearchComparisonFilter$outboundSchema, } from "./filesearchcomparisonfilter.js"; export const FileSearchCompoundFilterType = { And: "and", Or: "or", } as const; export type FileSearchCompoundFilterType = ClosedEnum< typeof FileSearchCompoundFilterType >; export type FileSearchCompoundFilter = { type: FileSearchCompoundFilterType; filters: Array< | (FileSearchComparisonFilter & { type: "eq" }) | (FileSearchComparisonFilter & { type: "ne" }) | (FileSearchComparisonFilter & { type: "gt" }) | (FileSearchComparisonFilter & { type: "gte" }) | (FileSearchComparisonFilter & { type: "lt" }) | (FileSearchComparisonFilter & { type: "lte" }) | (FileSearchCompoundFilter & { type: "and" }) | (FileSearchCompoundFilter & { type: "or" }) >; }; export type FileSearchCompoundFilterFilters = | (FileSearchComparisonFilter & { type: "eq" }) | (FileSearchComparisonFilter & { type: "ne" }) | (FileSearchComparisonFilter & { type: "gt" }) | (FileSearchComparisonFilter & { type: "gte" }) | (FileSearchComparisonFilter & { type: "lt" }) | (FileSearchComparisonFilter & { type: "lte" }) | (FileSearchCompoundFilter & { type: "and" }) | (FileSearchCompoundFilter & { type: "or" }); /** @internal */ export const FileSearchCompoundFilterType$inboundSchema: z.ZodNativeEnum< typeof FileSearchCompoundFilterType > = z.nativeEnum(FileSearchCompoundFilterType); /** @internal */ export const FileSearchCompoundFilterType$outboundSchema: z.ZodNativeEnum< typeof FileSearchCompoundFilterType > = FileSearchCompoundFilterType$inboundSchema; /** @internal */ export const FileSearchCompoundFilter$inboundSchema: z.ZodType< FileSearchCompoundFilter, z.ZodTypeDef, unknown > = z.object({ type: FileSearchCompoundFilterType$inboundSchema, filters: z.array( z.union([ FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("eq") }), ), FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("ne") }), ), FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("gt") }), ), FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("gte") }), ), FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("lt") }), ), FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("lte") }), ), z.lazy(() => FileSearchCompoundFilter$inboundSchema).and( z.object({ type: z.literal("and") }), ), z.lazy(() => FileSearchCompoundFilter$inboundSchema).and( z.object({ type: z.literal("or") }), ), ]), ), }); /** @internal */ export type FileSearchCompoundFilter$Outbound = { type: string; filters: Array< | (FileSearchComparisonFilter$Outbound & { type: "eq" }) | (FileSearchComparisonFilter$Outbound & { type: "ne" }) | (FileSearchComparisonFilter$Outbound & { type: "gt" }) | (FileSearchComparisonFilter$Outbound & { type: "gte" }) | (FileSearchComparisonFilter$Outbound & { type: "lt" }) | (FileSearchComparisonFilter$Outbound & { type: "lte" }) | (FileSearchCompoundFilter$Outbound & { type: "and" }) | (FileSearchCompoundFilter$Outbound & { type: "or" }) >; }; /** @internal */ export const FileSearchCompoundFilter$outboundSchema: z.ZodType< FileSearchCompoundFilter$Outbound, z.ZodTypeDef, FileSearchCompoundFilter > = z.object({ type: FileSearchCompoundFilterType$outboundSchema, filters: z.array( z.union([ FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("eq") }), ), FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("ne") }), ), FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("gt") }), ), FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("gte") }), ), FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("lt") }), ), FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("lte") }), ), z.lazy(() => FileSearchCompoundFilter$outboundSchema).and( z.object({ type: z.literal("and") }), ), z.lazy(() => FileSearchCompoundFilter$outboundSchema).and( z.object({ type: z.literal("or") }), ), ]), ), }); export function fileSearchCompoundFilterToJSON( fileSearchCompoundFilter: FileSearchCompoundFilter, ): string { return JSON.stringify( FileSearchCompoundFilter$outboundSchema.parse(fileSearchCompoundFilter), ); } export function fileSearchCompoundFilterFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FileSearchCompoundFilter$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FileSearchCompoundFilter' from JSON`, ); } /** @internal */ export const FileSearchCompoundFilterFilters$inboundSchema: z.ZodType< FileSearchCompoundFilterFilters, z.ZodTypeDef, unknown > = z.union([ FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("eq") }), ), FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("ne") }), ), FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("gt") }), ), FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("gte") }), ), FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("lt") }), ), FileSearchComparisonFilter$inboundSchema.and( z.object({ type: z.literal("lte") }), ), z.lazy(() => FileSearchCompoundFilter$inboundSchema).and( z.object({ type: z.literal("and") }), ), z.lazy(() => FileSearchCompoundFilter$inboundSchema).and( z.object({ type: z.literal("or") }), ), ]); /** @internal */ export type FileSearchCompoundFilterFilters$Outbound = | (FileSearchComparisonFilter$Outbound & { type: "eq" }) | (FileSearchComparisonFilter$Outbound & { type: "ne" }) | (FileSearchComparisonFilter$Outbound & { type: "gt" }) | (FileSearchComparisonFilter$Outbound & { type: "gte" }) | (FileSearchComparisonFilter$Outbound & { type: "lt" }) | (FileSearchComparisonFilter$Outbound & { type: "lte" }) | (FileSearchCompoundFilter$Outbound & { type: "and" }) | (FileSearchCompoundFilter$Outbound & { type: "or" }); /** @internal */ export const FileSearchCompoundFilterFilters$outboundSchema: z.ZodType< FileSearchCompoundFilterFilters$Outbound, z.ZodTypeDef, FileSearchCompoundFilterFilters > = z.union([ FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("eq") }), ), FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("ne") }), ), FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("gt") }), ), FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("gte") }), ), FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("lt") }), ), FileSearchComparisonFilter$outboundSchema.and( z.object({ type: z.literal("lte") }), ), z.lazy(() => FileSearchCompoundFilter$outboundSchema).and( z.object({ type: z.literal("and") }), ), z.lazy(() => FileSearchCompoundFilter$outboundSchema).and( z.object({ type: z.literal("or") }), ), ]); export function fileSearchCompoundFilterFiltersToJSON( fileSearchCompoundFilterFilters: FileSearchCompoundFilterFilters, ): string { return JSON.stringify( FileSearchCompoundFilterFilters$outboundSchema.parse( fileSearchCompoundFilterFilters, ), ); } export function fileSearchCompoundFilterFiltersFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FileSearchCompoundFilterFilters$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FileSearchCompoundFilterFilters' from JSON`, ); }