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

import * as z from "zod/v4";
import { smartUnion } from "../../types/smartUnion.js";
import {
  NetworkEncodedInput,
  NetworkEncodedInput$Outbound,
  NetworkEncodedInput$outboundSchema,
} from "./networkencodedinput.js";

/**
 * Input data for the query, matching its schema
 */
export type QueryInvocationBodyInput = NetworkEncodedInput | {
  [k: string]: any;
};

export type QueryInvocationBody = {
  /**
   * The name of the query to request
   */
  name: string;
  /**
   * Input data for the query, matching its schema
   */
  input?: NetworkEncodedInput | { [k: string]: any } | null | undefined;
};

/** @internal */
export type QueryInvocationBodyInput$Outbound = NetworkEncodedInput$Outbound | {
  [k: string]: any;
};

/** @internal */
export const QueryInvocationBodyInput$outboundSchema: z.ZodType<
  QueryInvocationBodyInput$Outbound,
  QueryInvocationBodyInput
> = smartUnion([
  NetworkEncodedInput$outboundSchema,
  z.record(z.string(), z.any()),
]);

export function queryInvocationBodyInputToJSON(
  queryInvocationBodyInput: QueryInvocationBodyInput,
): string {
  return JSON.stringify(
    QueryInvocationBodyInput$outboundSchema.parse(queryInvocationBodyInput),
  );
}

/** @internal */
export type QueryInvocationBody$Outbound = {
  name: string;
  input?:
    | NetworkEncodedInput$Outbound
    | { [k: string]: any }
    | null
    | undefined;
};

/** @internal */
export const QueryInvocationBody$outboundSchema: z.ZodType<
  QueryInvocationBody$Outbound,
  QueryInvocationBody
> = z.object({
  name: z.string(),
  input: z.nullable(
    smartUnion([
      NetworkEncodedInput$outboundSchema,
      z.record(z.string(), z.any()),
    ]),
  ).optional(),
});

export function queryInvocationBodyToJSON(
  queryInvocationBody: QueryInvocationBody,
): string {
  return JSON.stringify(
    QueryInvocationBody$outboundSchema.parse(queryInvocationBody),
  );
}
