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

import * as z from "zod/v3";
import { ClosedEnum } from "../types/enums.js";
import { smartUnion } from "../types/smartUnion.js";

export const Environments1 = {
  Development: "development",
  Preview: "preview",
  Production: "production",
} as const;
export type Environments1 = ClosedEnum<typeof Environments1>;

/**
 * A built-in environment name or the stable env_* ID of a custom environment.
 */
export type Environments = Environments1 | string;

/**
 * Environments enabled for a connector project connection.
 */
export type ConnectUpsertProjectConnectionRequest = {
  /**
   * One or more built-in environment names or stable custom environment IDs that belong to the project. Duplicate values are accepted and removed.
   */
  environments: Array<Environments1 | string>;
};

/** @internal */
export const Environments1$outboundSchema: z.ZodNativeEnum<
  typeof Environments1
> = z.nativeEnum(Environments1);

/** @internal */
export type Environments$Outbound = string | string;

/** @internal */
export const Environments$outboundSchema: z.ZodType<
  Environments$Outbound,
  z.ZodTypeDef,
  Environments
> = smartUnion([Environments1$outboundSchema, z.string()]);

export function environmentsToJSON(environments: Environments): string {
  return JSON.stringify(Environments$outboundSchema.parse(environments));
}

/** @internal */
export type ConnectUpsertProjectConnectionRequest$Outbound = {
  environments: Array<string | string>;
};

/** @internal */
export const ConnectUpsertProjectConnectionRequest$outboundSchema: z.ZodType<
  ConnectUpsertProjectConnectionRequest$Outbound,
  z.ZodTypeDef,
  ConnectUpsertProjectConnectionRequest
> = z.object({
  environments: z.array(smartUnion([Environments1$outboundSchema, z.string()])),
});

export function connectUpsertProjectConnectionRequestToJSON(
  connectUpsertProjectConnectionRequest: ConnectUpsertProjectConnectionRequest,
): string {
  return JSON.stringify(
    ConnectUpsertProjectConnectionRequest$outboundSchema.parse(
      connectUpsertProjectConnectionRequest,
    ),
  );
}
