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

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 { Workflow, Workflow$inboundSchema } from "./workflow.js";
import {
  WorkflowCodeDefinition,
  WorkflowCodeDefinition$inboundSchema,
} from "./workflowcodedefinition.js";

export type WorkflowRegistration = {
  /**
   * Unique identifier of the workflow registration
   */
  id: string;
  /**
   * Deployment ID this registration belongs to
   */
  deploymentId?: string | null | undefined;
  /**
   * Deprecated. Use deployment_id instead. Will be removed in a future release.
   *
   * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
   */
  taskQueue?: string | null | undefined;
  definition: WorkflowCodeDefinition;
  /**
   * Workflow ID of the workflow
   */
  workflowId: string;
  /**
   * Workflow of the workflow registration
   */
  workflow?: Workflow | null | undefined;
  /**
   * Whether the workflow is compatible with chat assistant
   */
  compatibleWithChatAssistant: boolean;
};

/** @internal */
export const WorkflowRegistration$inboundSchema: z.ZodType<
  WorkflowRegistration,
  unknown
> = z.object({
  id: z.string(),
  deployment_id: z.nullable(z.string()).optional(),
  task_queue: z.nullable(z.string()).optional(),
  definition: WorkflowCodeDefinition$inboundSchema,
  workflow_id: z.string(),
  workflow: z.nullable(Workflow$inboundSchema).optional(),
  compatible_with_chat_assistant: z.boolean().default(false),
}).transform((v) => {
  return remap$(v, {
    "deployment_id": "deploymentId",
    "task_queue": "taskQueue",
    "workflow_id": "workflowId",
    "compatible_with_chat_assistant": "compatibleWithChatAssistant",
  });
});

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