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

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

export type WorkflowListResponse = {
  /**
   * A list of workflows
   */
  workflows: Array<WorkflowBasicDefinition>;
  nextCursor: string | null;
};

/** @internal */
export const WorkflowListResponse$inboundSchema: z.ZodType<
  WorkflowListResponse,
  unknown
> = z.object({
  workflows: z.array(WorkflowBasicDefinition$inboundSchema),
  next_cursor: z.nullable(z.string()),
}).transform((v) => {
  return remap$(v, {
    "next_cursor": "nextCursor",
  });
});

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