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

import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * A key-value pair where the key is the `field_name` defined in the `trigger_input_schema` of the workflow definition,
 *
 * @remarks
 * and the value is the actual input data. Supported types include string, number, boolean, object, or array.
 */
export type TriggerInputs =
  | string
  | number
  | boolean
  | { [k: string]: any }
  | Array<any>;

/** @internal */
export const TriggerInputs$inboundSchema: z.ZodType<
  TriggerInputs,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.string(),
  z.number(),
  z.boolean(),
  z.record(z.any()),
  z.array(z.any()),
]);

/** @internal */
export type TriggerInputs$Outbound = string | number | boolean | {
  [k: string]: any;
} | Array<any>;

/** @internal */
export const TriggerInputs$outboundSchema: z.ZodType<
  TriggerInputs$Outbound,
  z.ZodTypeDef,
  TriggerInputs
> = z.union([
  z.string(),
  z.number(),
  z.boolean(),
  z.record(z.any()),
  z.array(z.any()),
]);

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace TriggerInputs$ {
  /** @deprecated use `TriggerInputs$inboundSchema` instead. */
  export const inboundSchema = TriggerInputs$inboundSchema;
  /** @deprecated use `TriggerInputs$outboundSchema` instead. */
  export const outboundSchema = TriggerInputs$outboundSchema;
  /** @deprecated use `TriggerInputs$Outbound` instead. */
  export type Outbound = TriggerInputs$Outbound;
}

export function triggerInputsToJSON(triggerInputs: TriggerInputs): string {
  return JSON.stringify(TriggerInputs$outboundSchema.parse(triggerInputs));
}

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