/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { collectExtraKeys as collectExtraKeys$, 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"; export const Aggregation = { Mean: "mean", None: "none", } as const; export type Aggregation = ClosedEnum; export type EvalMetric = { id: string; aggregation?: Aggregation | undefined; higherIsBetter?: boolean | undefined; description?: string | undefined; additionalProperties?: { [k: string]: any } | undefined; }; /** @internal */ export const Aggregation$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Aggregation); /** @internal */ export const Aggregation$outboundSchema: z.ZodNativeEnum = Aggregation$inboundSchema; /** @internal */ export const EvalMetric$inboundSchema: z.ZodType< EvalMetric, z.ZodTypeDef, unknown > = collectExtraKeys$( z.object({ id: z.string(), aggregation: Aggregation$inboundSchema.default("mean"), higher_is_better: z.boolean().default(true), description: z.string().optional(), }).catchall(z.any()), "additionalProperties", true, ).transform((v) => { return remap$(v, { "higher_is_better": "higherIsBetter", }); }); /** @internal */ export type EvalMetric$Outbound = { id: string; aggregation: string; higher_is_better: boolean; description?: string | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const EvalMetric$outboundSchema: z.ZodType< EvalMetric$Outbound, z.ZodTypeDef, EvalMetric > = z.object({ id: z.string(), aggregation: Aggregation$outboundSchema.default("mean"), higherIsBetter: z.boolean().default(true), description: z.string().optional(), additionalProperties: z.record(z.any()).optional(), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { higherIsBetter: "higher_is_better", additionalProperties: null, }), }; }); export function evalMetricToJSON(evalMetric: EvalMetric): string { return JSON.stringify(EvalMetric$outboundSchema.parse(evalMetric)); } export function evalMetricFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EvalMetric$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EvalMetric' from JSON`, ); }