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

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

/** @internal */
export const ActivityTaskRetryingAttributes$inboundSchema: z.ZodType<
  ActivityTaskRetryingAttributes,
  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 activityTaskRetryingAttributesFromJSON(
  jsonString: string,
): SafeParseResult<ActivityTaskRetryingAttributes, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ActivityTaskRetryingAttributes$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ActivityTaskRetryingAttributes' from JSON`,
  );
}
