/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { smartUnion } from "../../types/smartUnion.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FilterOperator, FilterOperator$inboundSchema, FilterOperator$outboundSchema, } from "./filteroperator.js"; export type Value = string | number | boolean; export type FilterClause = { property: string; operator: FilterOperator; value: string | number | boolean; }; /** @internal */ export const Value$inboundSchema: z.ZodMiniType = smartUnion([ z.string(), z.int(), z.boolean(), ]); /** @internal */ export type Value$Outbound = string | number | boolean; /** @internal */ export const Value$outboundSchema: z.ZodMiniType = smartUnion([z.string(), z.int(), z.boolean()]); export function valueToJSON(value: Value): string { return JSON.stringify(Value$outboundSchema.parse(value)); } export function valueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Value$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Value' from JSON`, ); } /** @internal */ export const FilterClause$inboundSchema: z.ZodMiniType = z.object({ property: z.string(), operator: FilterOperator$inboundSchema, value: smartUnion([z.string(), z.int(), z.boolean()]), }); /** @internal */ export type FilterClause$Outbound = { property: string; operator: string; value: string | number | boolean; }; /** @internal */ export const FilterClause$outboundSchema: z.ZodMiniType< FilterClause$Outbound, FilterClause > = z.object({ property: z.string(), operator: FilterOperator$outboundSchema, value: smartUnion([z.string(), z.int(), z.boolean()]), }); export function filterClauseToJSON(filterClause: FilterClause): string { return JSON.stringify(FilterClause$outboundSchema.parse(filterClause)); } export function filterClauseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FilterClause$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FilterClause' from JSON`, ); }