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

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

/**
 * Deprecated: use WorkflowRunListResponse instead. Will be removed in the next major version.
 */
export type WorkflowExecutionListResponse = {
  /**
   * A list of workflow executions
   */
  executions: Array<WorkflowExecutionWithoutResultResponse>;
  /**
   * Token to use for fetching the next page of results. Null if this is the last page.
   */
  nextPageToken?: string | null | undefined;
};

/** @internal */
export const WorkflowExecutionListResponse$inboundSchema: z.ZodType<
  WorkflowExecutionListResponse,
  unknown
> = z.object({
  executions: z.array(WorkflowExecutionWithoutResultResponse$inboundSchema),
  next_page_token: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    "next_page_token": "nextPageToken",
  });
});

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