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

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 WorkflowBulkUnarchiveResponse = {
  /**
   * Workflows that were successfully unarchived or were already unarchived
   */
  unarchived: Array<Workflow>;
  /**
   * Workflows that could not be unarchived and the corresponding error messages
   */
  errored?: Array<WorkflowBulkError> | undefined;
};

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

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