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

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

export type WorkflowBulkError = {
  /**
   * The requested workflow ID
   */
  workflowId: string;
  /**
   * The workflow, if found
   */
  workflow?: Workflow | null | undefined;
  /**
   * Error message describing why the operation failed
   */
  message: string;
};

/** @internal */
export const WorkflowBulkError$inboundSchema: z.ZodType<
  WorkflowBulkError,
  unknown
> = z.object({
  workflow_id: z.string(),
  workflow: z.nullable(Workflow$inboundSchema).optional(),
  message: z.string(),
}).transform((v) => {
  return remap$(v, {
    "workflow_id": "workflowId",
  });
});

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