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

import * as z from "zod/v4";
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";
import {
  WorkflowBulkError,
  WorkflowBulkError$inboundSchema,
} from "./workflowbulkerror.js";

export type WorkflowBulkArchiveResponse = {
  /**
   * Workflows that were successfully archived or were already archived
   */
  archived: Array<Workflow>;
  /**
   * Workflows that could not be archived and the corresponding error messages
   */
  errored?: Array<WorkflowBulkError> | undefined;
};

/** @internal */
export const WorkflowBulkArchiveResponse$inboundSchema: z.ZodType<
  WorkflowBulkArchiveResponse,
  unknown
> = z.object({
  archived: z.array(Workflow$inboundSchema),
  errored: z.array(WorkflowBulkError$inboundSchema).optional(),
});

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