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

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 activity task failed events (final failure after all retries).
 */
export type ActivityTaskFailedAttributes = {
  /**
   * Unique identifier for the activity task within the workflow.
   */
  taskId: string;
  /**
   * The registered name of the activity being executed.
   */
  activityName: string;
  /**
   * The final attempt number that failed (1-indexed).
   */
  attempt: number;
  /**
   * Represents an error or exception that occurred during execution.
   */
  failure: Failure;
};

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

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