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

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 * as components from "../components/index.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type GetWorkflowsV1WorkflowsGetRequest = {
  /**
   * Whether to only return active workflows
   */
  activeOnly?: boolean | undefined;
  /**
   * Whether to include shared workflows
   */
  includeShared?: boolean | undefined;
  /**
   * Whether to only return workflows available in chat assistant
   */
  availableInChatAssistant?: boolean | null | undefined;
  /**
   * Filter by archived state. False=exclude archived, True=only archived, None=include all
   */
  archived?: boolean | null | undefined;
  /**
   * The cursor for pagination
   */
  cursor?: string | null | undefined;
  /**
   * The maximum number of workflows to return
   */
  limit?: number | undefined;
};

export type GetWorkflowsV1WorkflowsGetResponse = {
  result: components.WorkflowListResponse;
};

/** @internal */
export type GetWorkflowsV1WorkflowsGetRequest$Outbound = {
  active_only: boolean;
  include_shared: boolean;
  available_in_chat_assistant?: boolean | null | undefined;
  archived?: boolean | null | undefined;
  cursor?: string | null | undefined;
  limit: number;
};

/** @internal */
export const GetWorkflowsV1WorkflowsGetRequest$outboundSchema: z.ZodType<
  GetWorkflowsV1WorkflowsGetRequest$Outbound,
  GetWorkflowsV1WorkflowsGetRequest
> = z.object({
  activeOnly: z.boolean().default(false),
  includeShared: z.boolean().default(true),
  availableInChatAssistant: z.nullable(z.boolean()).optional(),
  archived: z.nullable(z.boolean()).optional(),
  cursor: z.nullable(z.string()).optional(),
  limit: z.int().default(50),
}).transform((v) => {
  return remap$(v, {
    activeOnly: "active_only",
    includeShared: "include_shared",
    availableInChatAssistant: "available_in_chat_assistant",
  });
});

export function getWorkflowsV1WorkflowsGetRequestToJSON(
  getWorkflowsV1WorkflowsGetRequest: GetWorkflowsV1WorkflowsGetRequest,
): string {
  return JSON.stringify(
    GetWorkflowsV1WorkflowsGetRequest$outboundSchema.parse(
      getWorkflowsV1WorkflowsGetRequest,
    ),
  );
}

/** @internal */
export const GetWorkflowsV1WorkflowsGetResponse$inboundSchema: z.ZodType<
  GetWorkflowsV1WorkflowsGetResponse,
  unknown
> = z.object({
  Result: components.WorkflowListResponse$inboundSchema,
}).transform((v) => {
  return remap$(v, {
    "Result": "result",
  });
});

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