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

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 completed events.
 */
export type WorkflowExecutionCompletedAttributesResponse = {
  /**
   * Unique identifier for the task within the workflow execution.
   */
  taskId: 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.
   */
  result: JSONPayloadResponse;
};

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

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