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

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 {
  TempoTraceScope,
  TempoTraceScope$inboundSchema,
} from "./tempotracescope.js";
import {
  TempoTraceSpan,
  TempoTraceSpan$inboundSchema,
} from "./tempotracespan.js";

export type TempoTraceScopeSpan = {
  scope: TempoTraceScope;
  /**
   * The spans of the scope
   */
  spans?: Array<TempoTraceSpan> | undefined;
};

/** @internal */
export const TempoTraceScopeSpan$inboundSchema: z.ZodType<
  TempoTraceScopeSpan,
  unknown
> = z.object({
  scope: TempoTraceScope$inboundSchema,
  spans: z.array(TempoTraceSpan$inboundSchema).optional(),
});

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