/* * 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 * as types from "../../types/primitives.js"; import { SDKValidationError } from "./sdk-validation-error.js"; export type MeterFilter = { /** * Key is the key for the filter from $event.properties * * @remarks * Currently we support only first level keys in the properties and not nested keys */ key?: string | undefined; /** * Values are the possible values for the filter to be considered for the meter * * @remarks * For ex "model_name" could have values "o1-mini", "gpt-4o" etc */ values?: Array | undefined; }; /** @internal */ export const MeterFilter$inboundSchema: z.ZodMiniType = z .object({ key: types.optional(types.string()), values: types.optional(z.array(types.string())), }); /** @internal */ export type MeterFilter$Outbound = { key?: string | undefined; values?: Array | undefined; }; /** @internal */ export const MeterFilter$outboundSchema: z.ZodMiniType< MeterFilter$Outbound, MeterFilter > = z.object({ key: z.optional(z.string()), values: z.optional(z.array(z.string())), }); export function meterFilterToJSON(meterFilter: MeterFilter): string { return JSON.stringify(MeterFilter$outboundSchema.parse(meterFilter)); } export function meterFilterFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => MeterFilter$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MeterFilter' from JSON`, ); }