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

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

export type WorkflowRegistrationListResponse = {
  /**
   * A list of workflow registrations
   */
  workflowRegistrations: Array<WorkflowRegistration>;
  nextCursor: string | null;
  /**
   * Deprecated: use workflow_registrations
   */
  workflowVersions: Array<WorkflowRegistration>;
};

/** @internal */
export const WorkflowRegistrationListResponse$inboundSchema: z.ZodType<
  WorkflowRegistrationListResponse,
  unknown
> = z.object({
  workflow_registrations: z.array(WorkflowRegistration$inboundSchema),
  next_cursor: z.nullable(z.string()),
  workflow_versions: z.array(WorkflowRegistration$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "workflow_registrations": "workflowRegistrations",
    "next_cursor": "nextCursor",
    "workflow_versions": "workflowVersions",
  });
});

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