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

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

export type UniqueAggregation = {
  func: "unique";
  property: string;
};

/** @internal */
export const UniqueAggregation$inboundSchema: z.ZodMiniType<
  UniqueAggregation,
  unknown
> = z.object({
  func: z.literal("unique"),
  property: z.string(),
});
/** @internal */
export type UniqueAggregation$Outbound = {
  func: "unique";
  property: string;
};

/** @internal */
export const UniqueAggregation$outboundSchema: z.ZodMiniType<
  UniqueAggregation$Outbound,
  UniqueAggregation
> = z.object({
  func: z.literal("unique"),
  property: z.string(),
});

export function uniqueAggregationToJSON(
  uniqueAggregation: UniqueAggregation,
): string {
  return JSON.stringify(
    UniqueAggregation$outboundSchema.parse(uniqueAggregation),
  );
}
export function uniqueAggregationFromJSON(
  jsonString: string,
): SafeParseResult<UniqueAggregation, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => UniqueAggregation$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'UniqueAggregation' from JSON`,
  );
}
