/* * 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 { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type MetricsDataPoint = { /** * Start of the time bucket. Null when no granularity is specified. */ timeBucket?: Date | null | undefined; /** * Dimension values for this data point. Empty object when no dimensions are requested. */ dimensions?: { [k: string]: string } | undefined; /** * Requested measure values for this data point. */ metrics?: { [k: string]: any } | undefined; }; /** @internal */ export const MetricsDataPoint$inboundSchema: z.ZodType< MetricsDataPoint, z.ZodTypeDef, unknown > = z.object({ time_bucket: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), dimensions: z.record(z.string()).optional(), metrics: z.record(z.any()).optional(), }).transform((v) => { return remap$(v, { "time_bucket": "timeBucket", }); }); /** @internal */ export type MetricsDataPoint$Outbound = { time_bucket?: string | null | undefined; dimensions?: { [k: string]: string } | undefined; metrics?: { [k: string]: any } | undefined; }; /** @internal */ export const MetricsDataPoint$outboundSchema: z.ZodType< MetricsDataPoint$Outbound, z.ZodTypeDef, MetricsDataPoint > = z.object({ timeBucket: z.nullable(z.date().transform(v => v.toISOString())).optional(), dimensions: z.record(z.string()).optional(), metrics: z.record(z.any()).optional(), }).transform((v) => { return remap$(v, { timeBucket: "time_bucket", }); }); export function metricsDataPointToJSON( metricsDataPoint: MetricsDataPoint, ): string { return JSON.stringify( MetricsDataPoint$outboundSchema.parse(metricsDataPoint), ); } export function metricsDataPointFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => MetricsDataPoint$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MetricsDataPoint' from JSON`, ); }