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

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 TimeSeriesMetricValue1 = number | number;

export type TimeSeriesMetricValue2 = number | number | number;

/**
 * Time-series metric with timestamp-value pairs.
 */
export type TimeSeriesMetric = {
  value: Array<Array<number | number | number>>;
};

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

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

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

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

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

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