/* * 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"; /** * Type of operation: 'and' or 'or'. */ export const Filter2Type = { And: "and", Or: "or", } as const; /** * Type of operation: 'and' or 'or'. */ export type Filter2Type = ClosedEnum; /** * Type of operation: 'and' or 'or'. */ export const FilterFilters2Type = { And: "and", Or: "or", } as const; /** * Type of operation: 'and' or 'or'. */ export type FilterFilters2Type = ClosedEnum; /** * Comparison operator: eq (equals), ne (not equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), in (in), nin (not in). */ export const FilterFilters2FiltersType = { Eq: "eq", Ne: "ne", Gt: "gt", Gte: "gte", Lt: "lt", Lte: "lte", In: "in", Nin: "nin", } as const; /** * Comparison operator: eq (equals), ne (not equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), in (in), nin (not in). */ export type FilterFilters2FiltersType = ClosedEnum< typeof FilterFilters2FiltersType >; export type FilterValue24 = string | number | boolean; /** * The value to compare against the attribute key; supports string, number, boolean, or array types. */ export type FilterFiltersValue = | string | number | boolean | Array; /** * A filter used to compare a specified attribute key to a given value using a defined comparison operation. */ export type FilterFilters1 = { /** * Comparison operator: eq (equals), ne (not equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), in (in), nin (not in). */ type: FilterFilters2FiltersType; /** * The key to compare against the value. */ key: string; /** * The value to compare against the attribute key; supports string, number, boolean, or array types. */ value: string | number | boolean | Array; }; export type FilterFiltersFilters = FilterFilters1 | any; /** * Combine multiple filters using 'and' or 'or'. */ export type FilterFilters2 = { /** * Type of operation: 'and' or 'or'. */ type: FilterFilters2Type; /** * Array of filters to combine. Items can be ComparisonFilter or CompoundFilter. */ filters: Array; }; /** * Comparison operator: eq (equals), ne (not equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), in (in), nin (not in). */ export const FilterFiltersType = { Eq: "eq", Ne: "ne", Gt: "gt", Gte: "gte", Lt: "lt", Lte: "lte", In: "in", Nin: "nin", } as const; /** * Comparison operator: eq (equals), ne (not equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), in (in), nin (not in). */ export type FilterFiltersType = ClosedEnum; export type FilterValue4 = string | number | boolean; /** * The value to compare against the attribute key; supports string, number, boolean, or array types. */ export type FiltersValue = | string | number | boolean | Array; /** * A filter used to compare a specified attribute key to a given value using a defined comparison operation. */ export type Filters1 = { /** * Comparison operator: eq (equals), ne (not equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), in (in), nin (not in). */ type: FilterFiltersType; /** * The key to compare against the value. */ key: string; /** * The value to compare against the attribute key; supports string, number, boolean, or array types. */ value: string | number | boolean | Array; }; export type FilterFilters = | (Filters1 & { type: "eq" }) | (Filters1 & { type: "ne" }) | (Filters1 & { type: "gt" }) | (Filters1 & { type: "gte" }) | (Filters1 & { type: "lt" }) | (Filters1 & { type: "lte" }) | (Filters1 & { type: "in" }) | (Filters1 & { type: "nin" }) | (FilterFilters2 & { type: "and" }) | (FilterFilters2 & { type: "or" }); /** * Combine multiple filters using 'and' or 'or'. */ export type Filter2 = { /** * Type of operation: 'and' or 'or'. */ type: Filter2Type; /** * Array of filters to combine. Items can be ComparisonFilter or CompoundFilter. */ filters: Array< | (Filters1 & { type: "eq" }) | (Filters1 & { type: "ne" }) | (Filters1 & { type: "gt" }) | (Filters1 & { type: "gte" }) | (Filters1 & { type: "lt" }) | (Filters1 & { type: "lte" }) | (Filters1 & { type: "in" }) | (Filters1 & { type: "nin" }) | (FilterFilters2 & { type: "and" }) | (FilterFilters2 & { type: "or" }) >; }; /** * Comparison operator: eq (equals), ne (not equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), in (in), nin (not in). */ export const FilterType = { Eq: "eq", Ne: "ne", Gt: "gt", Gte: "gte", Lt: "lt", Lte: "lte", In: "in", Nin: "nin", } as const; /** * Comparison operator: eq (equals), ne (not equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), in (in), nin (not in). */ export type FilterType = ClosedEnum; export type Value4 = string | number | boolean; /** * The value to compare against the attribute key; supports string, number, boolean, or array types. */ export type FilterValue = | string | number | boolean | Array; /** * A filter used to compare a specified attribute key to a given value using a defined comparison operation. */ export type Filter1 = { /** * Comparison operator: eq (equals), ne (not equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), in (in), nin (not in). */ type: FilterType; /** * The key to compare against the value. */ key: string; /** * The value to compare against the attribute key; supports string, number, boolean, or array types. */ value: string | number | boolean | Array; }; export type Filter = | (Filter1 & { type: "eq" }) | (Filter1 & { type: "ne" }) | (Filter1 & { type: "gt" }) | (Filter1 & { type: "gte" }) | (Filter1 & { type: "lt" }) | (Filter1 & { type: "lte" }) | (Filter1 & { type: "in" }) | (Filter1 & { type: "nin" }) | (Filter2 & { type: "and" }) | (Filter2 & { type: "or" }); /** @internal */ export const Filter2Type$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Filter2Type); /** @internal */ export const Filter2Type$outboundSchema: z.ZodNativeEnum = Filter2Type$inboundSchema; /** @internal */ export const FilterFilters2Type$inboundSchema: z.ZodNativeEnum< typeof FilterFilters2Type > = z.nativeEnum(FilterFilters2Type); /** @internal */ export const FilterFilters2Type$outboundSchema: z.ZodNativeEnum< typeof FilterFilters2Type > = FilterFilters2Type$inboundSchema; /** @internal */ export const FilterFilters2FiltersType$inboundSchema: z.ZodNativeEnum< typeof FilterFilters2FiltersType > = z.nativeEnum(FilterFilters2FiltersType); /** @internal */ export const FilterFilters2FiltersType$outboundSchema: z.ZodNativeEnum< typeof FilterFilters2FiltersType > = FilterFilters2FiltersType$inboundSchema; /** @internal */ export const FilterValue24$inboundSchema: z.ZodType< FilterValue24, z.ZodTypeDef, unknown > = z.union([z.string(), z.number(), z.boolean()]); /** @internal */ export type FilterValue24$Outbound = string | number | boolean; /** @internal */ export const FilterValue24$outboundSchema: z.ZodType< FilterValue24$Outbound, z.ZodTypeDef, FilterValue24 > = z.union([z.string(), z.number(), z.boolean()]); export function filterValue24ToJSON(filterValue24: FilterValue24): string { return JSON.stringify(FilterValue24$outboundSchema.parse(filterValue24)); } export function filterValue24FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FilterValue24$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FilterValue24' from JSON`, ); } /** @internal */ export const FilterFiltersValue$inboundSchema: z.ZodType< FilterFiltersValue, z.ZodTypeDef, unknown > = z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]); /** @internal */ export type FilterFiltersValue$Outbound = | string | number | boolean | Array; /** @internal */ export const FilterFiltersValue$outboundSchema: z.ZodType< FilterFiltersValue$Outbound, z.ZodTypeDef, FilterFiltersValue > = z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]); export function filterFiltersValueToJSON( filterFiltersValue: FilterFiltersValue, ): string { return JSON.stringify( FilterFiltersValue$outboundSchema.parse(filterFiltersValue), ); } export function filterFiltersValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FilterFiltersValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FilterFiltersValue' from JSON`, ); } /** @internal */ export const FilterFilters1$inboundSchema: z.ZodType< FilterFilters1, z.ZodTypeDef, unknown > = z.object({ type: FilterFilters2FiltersType$inboundSchema, key: z.string(), value: z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]), }); /** @internal */ export type FilterFilters1$Outbound = { type: string; key: string; value: string | number | boolean | Array; }; /** @internal */ export const FilterFilters1$outboundSchema: z.ZodType< FilterFilters1$Outbound, z.ZodTypeDef, FilterFilters1 > = z.object({ type: FilterFilters2FiltersType$outboundSchema, key: z.string(), value: z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]), }); export function filterFilters1ToJSON(filterFilters1: FilterFilters1): string { return JSON.stringify(FilterFilters1$outboundSchema.parse(filterFilters1)); } export function filterFilters1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FilterFilters1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FilterFilters1' from JSON`, ); } /** @internal */ export const FilterFiltersFilters$inboundSchema: z.ZodType< FilterFiltersFilters, z.ZodTypeDef, unknown > = z.union([z.lazy(() => FilterFilters1$inboundSchema), z.any()]); /** @internal */ export type FilterFiltersFilters$Outbound = FilterFilters1$Outbound | any; /** @internal */ export const FilterFiltersFilters$outboundSchema: z.ZodType< FilterFiltersFilters$Outbound, z.ZodTypeDef, FilterFiltersFilters > = z.union([z.lazy(() => FilterFilters1$outboundSchema), z.any()]); export function filterFiltersFiltersToJSON( filterFiltersFilters: FilterFiltersFilters, ): string { return JSON.stringify( FilterFiltersFilters$outboundSchema.parse(filterFiltersFilters), ); } export function filterFiltersFiltersFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FilterFiltersFilters$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FilterFiltersFilters' from JSON`, ); } /** @internal */ export const FilterFilters2$inboundSchema: z.ZodType< FilterFilters2, z.ZodTypeDef, unknown > = z.object({ type: FilterFilters2Type$inboundSchema, filters: z.array( z.union([z.lazy(() => FilterFilters1$inboundSchema), z.any()]), ), }); /** @internal */ export type FilterFilters2$Outbound = { type: string; filters: Array; }; /** @internal */ export const FilterFilters2$outboundSchema: z.ZodType< FilterFilters2$Outbound, z.ZodTypeDef, FilterFilters2 > = z.object({ type: FilterFilters2Type$outboundSchema, filters: z.array( z.union([z.lazy(() => FilterFilters1$outboundSchema), z.any()]), ), }); export function filterFilters2ToJSON(filterFilters2: FilterFilters2): string { return JSON.stringify(FilterFilters2$outboundSchema.parse(filterFilters2)); } export function filterFilters2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FilterFilters2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FilterFilters2' from JSON`, ); } /** @internal */ export const FilterFiltersType$inboundSchema: z.ZodNativeEnum< typeof FilterFiltersType > = z.nativeEnum(FilterFiltersType); /** @internal */ export const FilterFiltersType$outboundSchema: z.ZodNativeEnum< typeof FilterFiltersType > = FilterFiltersType$inboundSchema; /** @internal */ export const FilterValue4$inboundSchema: z.ZodType< FilterValue4, z.ZodTypeDef, unknown > = z.union([z.string(), z.number(), z.boolean()]); /** @internal */ export type FilterValue4$Outbound = string | number | boolean; /** @internal */ export const FilterValue4$outboundSchema: z.ZodType< FilterValue4$Outbound, z.ZodTypeDef, FilterValue4 > = z.union([z.string(), z.number(), z.boolean()]); export function filterValue4ToJSON(filterValue4: FilterValue4): string { return JSON.stringify(FilterValue4$outboundSchema.parse(filterValue4)); } export function filterValue4FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FilterValue4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FilterValue4' from JSON`, ); } /** @internal */ export const FiltersValue$inboundSchema: z.ZodType< FiltersValue, z.ZodTypeDef, unknown > = z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]); /** @internal */ export type FiltersValue$Outbound = | string | number | boolean | Array; /** @internal */ export const FiltersValue$outboundSchema: z.ZodType< FiltersValue$Outbound, z.ZodTypeDef, FiltersValue > = z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]); export function filtersValueToJSON(filtersValue: FiltersValue): string { return JSON.stringify(FiltersValue$outboundSchema.parse(filtersValue)); } export function filtersValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FiltersValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FiltersValue' from JSON`, ); } /** @internal */ export const Filters1$inboundSchema: z.ZodType< Filters1, z.ZodTypeDef, unknown > = z.object({ type: FilterFiltersType$inboundSchema, key: z.string(), value: z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]), }); /** @internal */ export type Filters1$Outbound = { type: string; key: string; value: string | number | boolean | Array; }; /** @internal */ export const Filters1$outboundSchema: z.ZodType< Filters1$Outbound, z.ZodTypeDef, Filters1 > = z.object({ type: FilterFiltersType$outboundSchema, key: z.string(), value: z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]), }); export function filters1ToJSON(filters1: Filters1): string { return JSON.stringify(Filters1$outboundSchema.parse(filters1)); } export function filters1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Filters1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Filters1' from JSON`, ); } /** @internal */ export const FilterFilters$inboundSchema: z.ZodType< FilterFilters, z.ZodTypeDef, unknown > = z.union([ z.lazy(() => Filters1$inboundSchema).and(z.object({ type: z.literal("eq") })), z.lazy(() => Filters1$inboundSchema).and(z.object({ type: z.literal("ne") })), z.lazy(() => Filters1$inboundSchema).and(z.object({ type: z.literal("gt") })), z.lazy(() => Filters1$inboundSchema).and( z.object({ type: z.literal("gte") }), ), z.lazy(() => Filters1$inboundSchema).and(z.object({ type: z.literal("lt") })), z.lazy(() => Filters1$inboundSchema).and( z.object({ type: z.literal("lte") }), ), z.lazy(() => Filters1$inboundSchema).and(z.object({ type: z.literal("in") })), z.lazy(() => Filters1$inboundSchema).and( z.object({ type: z.literal("nin") }), ), z.lazy(() => FilterFilters2$inboundSchema).and( z.object({ type: z.literal("and") }), ), z.lazy(() => FilterFilters2$inboundSchema).and( z.object({ type: z.literal("or") }), ), ]); /** @internal */ export type FilterFilters$Outbound = | (Filters1$Outbound & { type: "eq" }) | (Filters1$Outbound & { type: "ne" }) | (Filters1$Outbound & { type: "gt" }) | (Filters1$Outbound & { type: "gte" }) | (Filters1$Outbound & { type: "lt" }) | (Filters1$Outbound & { type: "lte" }) | (Filters1$Outbound & { type: "in" }) | (Filters1$Outbound & { type: "nin" }) | (FilterFilters2$Outbound & { type: "and" }) | (FilterFilters2$Outbound & { type: "or" }); /** @internal */ export const FilterFilters$outboundSchema: z.ZodType< FilterFilters$Outbound, z.ZodTypeDef, FilterFilters > = z.union([ z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("eq") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("ne") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("gt") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("gte") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("lt") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("lte") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("in") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("nin") }), ), z.lazy(() => FilterFilters2$outboundSchema).and( z.object({ type: z.literal("and") }), ), z.lazy(() => FilterFilters2$outboundSchema).and( z.object({ type: z.literal("or") }), ), ]); export function filterFiltersToJSON(filterFilters: FilterFilters): string { return JSON.stringify(FilterFilters$outboundSchema.parse(filterFilters)); } export function filterFiltersFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FilterFilters$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FilterFilters' from JSON`, ); } /** @internal */ export const Filter2$inboundSchema: z.ZodType = z.object({ type: Filter2Type$inboundSchema, filters: z.array( z.union([ z.lazy(() => Filters1$inboundSchema).and( z.object({ type: z.literal("eq") }), ), z.lazy(() => Filters1$inboundSchema).and( z.object({ type: z.literal("ne") }), ), z.lazy(() => Filters1$inboundSchema).and( z.object({ type: z.literal("gt") }), ), z.lazy(() => Filters1$inboundSchema).and( z.object({ type: z.literal("gte") }), ), z.lazy(() => Filters1$inboundSchema).and( z.object({ type: z.literal("lt") }), ), z.lazy(() => Filters1$inboundSchema).and( z.object({ type: z.literal("lte") }), ), z.lazy(() => Filters1$inboundSchema).and( z.object({ type: z.literal("in") }), ), z.lazy(() => Filters1$inboundSchema).and( z.object({ type: z.literal("nin") }), ), z.lazy(() => FilterFilters2$inboundSchema).and( z.object({ type: z.literal("and") }), ), z.lazy(() => FilterFilters2$inboundSchema).and( z.object({ type: z.literal("or") }), ), ]), ), }); /** @internal */ export type Filter2$Outbound = { type: string; filters: Array< | (Filters1$Outbound & { type: "eq" }) | (Filters1$Outbound & { type: "ne" }) | (Filters1$Outbound & { type: "gt" }) | (Filters1$Outbound & { type: "gte" }) | (Filters1$Outbound & { type: "lt" }) | (Filters1$Outbound & { type: "lte" }) | (Filters1$Outbound & { type: "in" }) | (Filters1$Outbound & { type: "nin" }) | (FilterFilters2$Outbound & { type: "and" }) | (FilterFilters2$Outbound & { type: "or" }) >; }; /** @internal */ export const Filter2$outboundSchema: z.ZodType< Filter2$Outbound, z.ZodTypeDef, Filter2 > = z.object({ type: Filter2Type$outboundSchema, filters: z.array( z.union([ z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("eq") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("ne") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("gt") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("gte") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("lt") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("lte") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("in") }), ), z.lazy(() => Filters1$outboundSchema).and( z.object({ type: z.literal("nin") }), ), z.lazy(() => FilterFilters2$outboundSchema).and( z.object({ type: z.literal("and") }), ), z.lazy(() => FilterFilters2$outboundSchema).and( z.object({ type: z.literal("or") }), ), ]), ), }); export function filter2ToJSON(filter2: Filter2): string { return JSON.stringify(Filter2$outboundSchema.parse(filter2)); } export function filter2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Filter2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Filter2' from JSON`, ); } /** @internal */ export const FilterType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(FilterType); /** @internal */ export const FilterType$outboundSchema: z.ZodNativeEnum = FilterType$inboundSchema; /** @internal */ export const Value4$inboundSchema: z.ZodType = z .union([z.string(), z.number(), z.boolean()]); /** @internal */ export type Value4$Outbound = string | number | boolean; /** @internal */ export const Value4$outboundSchema: z.ZodType< Value4$Outbound, z.ZodTypeDef, Value4 > = z.union([z.string(), z.number(), z.boolean()]); export function value4ToJSON(value4: Value4): string { return JSON.stringify(Value4$outboundSchema.parse(value4)); } export function value4FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Value4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Value4' from JSON`, ); } /** @internal */ export const FilterValue$inboundSchema: z.ZodType< FilterValue, z.ZodTypeDef, unknown > = z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]); /** @internal */ export type FilterValue$Outbound = | string | number | boolean | Array; /** @internal */ export const FilterValue$outboundSchema: z.ZodType< FilterValue$Outbound, z.ZodTypeDef, FilterValue > = z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]); export function filterValueToJSON(filterValue: FilterValue): string { return JSON.stringify(FilterValue$outboundSchema.parse(filterValue)); } export function filterValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FilterValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FilterValue' from JSON`, ); } /** @internal */ export const Filter1$inboundSchema: z.ZodType = z.object({ type: FilterType$inboundSchema, key: z.string(), value: z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]), }); /** @internal */ export type Filter1$Outbound = { type: string; key: string; value: string | number | boolean | Array; }; /** @internal */ export const Filter1$outboundSchema: z.ZodType< Filter1$Outbound, z.ZodTypeDef, Filter1 > = z.object({ type: FilterType$outboundSchema, key: z.string(), value: z.union([ z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()])), ]), }); export function filter1ToJSON(filter1: Filter1): string { return JSON.stringify(Filter1$outboundSchema.parse(filter1)); } export function filter1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Filter1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Filter1' from JSON`, ); } /** @internal */ export const Filter$inboundSchema: z.ZodType = z .union([ z.lazy(() => Filter1$inboundSchema).and( z.object({ type: z.literal("eq") }), ), z.lazy(() => Filter1$inboundSchema).and( z.object({ type: z.literal("ne") }), ), z.lazy(() => Filter1$inboundSchema).and( z.object({ type: z.literal("gt") }), ), z.lazy(() => Filter1$inboundSchema).and( z.object({ type: z.literal("gte") }), ), z.lazy(() => Filter1$inboundSchema).and( z.object({ type: z.literal("lt") }), ), z.lazy(() => Filter1$inboundSchema).and( z.object({ type: z.literal("lte") }), ), z.lazy(() => Filter1$inboundSchema).and( z.object({ type: z.literal("in") }), ), z.lazy(() => Filter1$inboundSchema).and( z.object({ type: z.literal("nin") }), ), z.lazy(() => Filter2$inboundSchema).and( z.object({ type: z.literal("and") }), ), z.lazy(() => Filter2$inboundSchema).and( z.object({ type: z.literal("or") }), ), ]); /** @internal */ export type Filter$Outbound = | (Filter1$Outbound & { type: "eq" }) | (Filter1$Outbound & { type: "ne" }) | (Filter1$Outbound & { type: "gt" }) | (Filter1$Outbound & { type: "gte" }) | (Filter1$Outbound & { type: "lt" }) | (Filter1$Outbound & { type: "lte" }) | (Filter1$Outbound & { type: "in" }) | (Filter1$Outbound & { type: "nin" }) | (Filter2$Outbound & { type: "and" }) | (Filter2$Outbound & { type: "or" }); /** @internal */ export const Filter$outboundSchema: z.ZodType< Filter$Outbound, z.ZodTypeDef, Filter > = z.union([ z.lazy(() => Filter1$outboundSchema).and(z.object({ type: z.literal("eq") })), z.lazy(() => Filter1$outboundSchema).and(z.object({ type: z.literal("ne") })), z.lazy(() => Filter1$outboundSchema).and(z.object({ type: z.literal("gt") })), z.lazy(() => Filter1$outboundSchema).and( z.object({ type: z.literal("gte") }), ), z.lazy(() => Filter1$outboundSchema).and(z.object({ type: z.literal("lt") })), z.lazy(() => Filter1$outboundSchema).and( z.object({ type: z.literal("lte") }), ), z.lazy(() => Filter1$outboundSchema).and(z.object({ type: z.literal("in") })), z.lazy(() => Filter1$outboundSchema).and( z.object({ type: z.literal("nin") }), ), z.lazy(() => Filter2$outboundSchema).and( z.object({ type: z.literal("and") }), ), z.lazy(() => Filter2$outboundSchema).and(z.object({ type: z.literal("or") })), ]); export function filterToJSON(filter: Filter): string { return JSON.stringify(Filter$outboundSchema.parse(filter)); } export function filterFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Filter$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Filter' from JSON`, ); }