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

import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  Workflow,
  Workflow$inboundSchema,
  Workflow$Outbound,
  Workflow$outboundSchema,
} from "./workflow.js";

/**
 * A list of workflows
 */
export type WorkflowList = {
  workflows?: Array<Workflow> | undefined;
};

/** @internal */
export const WorkflowList$inboundSchema: z.ZodType<
  WorkflowList,
  z.ZodTypeDef,
  unknown
> = z.object({
  workflows: z.array(Workflow$inboundSchema).optional(),
});

/** @internal */
export type WorkflowList$Outbound = {
  workflows?: Array<Workflow$Outbound> | undefined;
};

/** @internal */
export const WorkflowList$outboundSchema: z.ZodType<
  WorkflowList$Outbound,
  z.ZodTypeDef,
  WorkflowList
> = z.object({
  workflows: z.array(Workflow$outboundSchema).optional(),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace WorkflowList$ {
  /** @deprecated use `WorkflowList$inboundSchema` instead. */
  export const inboundSchema = WorkflowList$inboundSchema;
  /** @deprecated use `WorkflowList$outboundSchema` instead. */
  export const outboundSchema = WorkflowList$outboundSchema;
  /** @deprecated use `WorkflowList$Outbound` instead. */
  export type Outbound = WorkflowList$Outbound;
}

export function workflowListToJSON(workflowList: WorkflowList): string {
  return JSON.stringify(WorkflowList$outboundSchema.parse(workflowList));
}

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