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

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  TempoTraceAttribute,
  TempoTraceAttribute$inboundSchema,
} from "./tempotraceattribute.js";

export type TempoTraceEvent = {
  /**
   * The name of the event
   */
  name: string;
  /**
   * The time of the event in Unix nano
   */
  timeUnixNano: string;
  /**
   * The attributes of the event
   */
  attributes?: Array<TempoTraceAttribute> | undefined;
};

/** @internal */
export const TempoTraceEvent$inboundSchema: z.ZodType<
  TempoTraceEvent,
  unknown
> = z.object({
  name: z.string(),
  timeUnixNano: z.string(),
  attributes: z.array(TempoTraceAttribute$inboundSchema).optional(),
});

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