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

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 {
  JSONPayloadResponse,
  JSONPayloadResponse$inboundSchema,
} from "./jsonpayloadresponse.js";

/**
 * Attributes for workflow execution continued-as-new events.
 */
export type WorkflowExecutionContinuedAsNewAttributesResponse = {
  /**
   * Unique identifier for the task within the workflow execution.
   */
  taskId: string;
  /**
   * The run ID of the new workflow execution that continues this workflow.
   */
  newExecutionRunId: string;
  /**
   * The registered name of the continued workflow.
   */
  workflowName: string;
  /**
   * A payload containing arbitrary JSON data.
   *
   * @remarks
   *
   * Used for complete state snapshots or final results.
   * When encrypted, the value field contains base64-encoded encrypted data
   * and encoding_options indicates the type of encryption applied.
   */
  input: JSONPayloadResponse;
};

/** @internal */
export const WorkflowExecutionContinuedAsNewAttributesResponse$inboundSchema:
  z.ZodType<WorkflowExecutionContinuedAsNewAttributesResponse, unknown> = z
    .object({
      task_id: z.string(),
      new_execution_run_id: z.string(),
      workflow_name: z.string(),
      input: JSONPayloadResponse$inboundSchema,
    }).transform((v) => {
      return remap$(v, {
        "task_id": "taskId",
        "new_execution_run_id": "newExecutionRunId",
        "workflow_name": "workflowName",
      });
    });

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