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

import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import {
  TriggerInputs,
  TriggerInputs$Outbound,
  TriggerInputs$outboundSchema,
} from "./triggerinputs.js";

/**
 * The input information needed to trigger a new instance of a Workflow Builder workflow.
 *
 * @remarks
 * This request body contains the metadata to describe the instance being created,
 * along with the input data required to trigger the workflow.
 *
 * - `instance_name` provides a user-defined name for the workflow instance.
 * - `trigger_inputs` contains the key-value pairs corresponding to the inputs required by the workflow, as described in the `trigger_input_schema` from the workflow definition.
 */
export type TriggerWorkflow = {
  /**
   * A descriptive name for the specific instance of the workflow being triggered.
   *
   * @remarks
   * This is typically used for identification and tracking purposes.
   * Example: "User Registration Workflow Instance"
   */
  instanceName: string;
  /**
   * Key-value pairs representing the input data required to trigger the workflow.
   *
   * @remarks
   * The keys correspond to the `field_name` values defined in the `trigger_input_schema` of the workflow definition.
   * The values should match the specified `field_data_type` (e.g., string, number, boolean).
   * Example: {"name": "John Doe", "email": "johndoe@example.com"}
   */
  triggerInputs: { [k: string]: TriggerInputs };
};

/** @internal */
export type TriggerWorkflow$Outbound = {
  instance_name: string;
  trigger_inputs: { [k: string]: TriggerInputs$Outbound };
};

/** @internal */
export const TriggerWorkflow$outboundSchema: z.ZodType<
  TriggerWorkflow$Outbound,
  z.ZodTypeDef,
  TriggerWorkflow
> = z.object({
  instanceName: z.string(),
  triggerInputs: z.record(TriggerInputs$outboundSchema),
}).transform((v) => {
  return remap$(v, {
    instanceName: "instance_name",
    triggerInputs: "trigger_inputs",
  });
});

export function triggerWorkflowToJSON(
  triggerWorkflow: TriggerWorkflow,
): string {
  return JSON.stringify(TriggerWorkflow$outboundSchema.parse(triggerWorkflow));
}
