/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 0d07d9ebb1ef
 */

import * as z from "zod/v4";
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";

export type ScalarMetricValue = number | number;

/**
 * Scalar metric with a single value.
 */
export type ScalarMetric = {
  value: number | number;
};

/** @internal */
export const ScalarMetricValue$inboundSchema: z.ZodType<
  ScalarMetricValue,
  unknown
> = smartUnion([z.int(), z.number()]);

export function scalarMetricValueFromJSON(
  jsonString: string,
): SafeParseResult<ScalarMetricValue, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ScalarMetricValue$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ScalarMetricValue' from JSON`,
  );
}

/** @internal */
export const ScalarMetric$inboundSchema: z.ZodType<ScalarMetric, unknown> = z
  .object({
    value: smartUnion([z.int(), z.number()]),
  });

export function scalarMetricFromJSON(
  jsonString: string,
): SafeParseResult<ScalarMetric, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ScalarMetric$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ScalarMetric' from JSON`,
  );
}
