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

import * as z from "zod/v4";
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";
import { Failure, Failure$inboundSchema } from "./failure.js";

/**
 * Attributes for workflow execution failed events.
 */
export type WorkflowExecutionFailedAttributes = {
  /**
   * Unique identifier for the task within the workflow execution.
   */
  taskId: string;
  /**
   * Represents an error or exception that occurred during execution.
   */
  failure: Failure;
};

/** @internal */
export const WorkflowExecutionFailedAttributes$inboundSchema: z.ZodType<
  WorkflowExecutionFailedAttributes,
  unknown
> = z.object({
  task_id: z.string(),
  failure: Failure$inboundSchema,
}).transform((v) => {
  return remap$(v, {
    "task_id": "taskId",
  });
});

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