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

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 task failed events.
 */
export type WorkflowTaskFailedAttributes = {
  /**
   * 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 WorkflowTaskFailedAttributes$inboundSchema: z.ZodType<
  WorkflowTaskFailedAttributes,
  unknown
> = z.object({
  task_id: z.string(),
  failure: Failure$inboundSchema,
}).transform((v) => {
  return remap$(v, {
    "task_id": "taskId",
  });
});

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