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

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";

/**
 * Attributes for workflow execution canceled events.
 */
export type WorkflowExecutionCanceledAttributes = {
  /**
   * Unique identifier for the task within the workflow execution.
   */
  taskId: string;
  /**
   * Optional reason provided for the cancellation.
   */
  reason?: string | null | undefined;
};

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

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