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

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

/**
 * The type of the dependent resource
 */
export const AIConfigDependencyType = {
  AgentGraph: "agent-graph",
} as const;
/**
 * The type of the dependent resource
 */
export type AIConfigDependencyType = ClosedEnum<typeof AIConfigDependencyType>;

/**
 * A resource that depends on this config
 */
export type AIConfigDependency = {
  /**
   * The type of the dependent resource
   */
  type: AIConfigDependencyType;
  /**
   * The key of the dependent resource
   */
  key: string;
};

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

/** @internal */
export const AIConfigDependency$inboundSchema: z.ZodType<
  AIConfigDependency,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: AIConfigDependencyType$inboundSchema,
  key: z.string(),
});
/** @internal */
export type AIConfigDependency$Outbound = {
  type: string;
  key: string;
};

/** @internal */
export const AIConfigDependency$outboundSchema: z.ZodType<
  AIConfigDependency$Outbound,
  z.ZodTypeDef,
  AIConfigDependency
> = z.object({
  type: AIConfigDependencyType$outboundSchema,
  key: z.string(),
});

export function aiConfigDependencyToJSON(
  aiConfigDependency: AIConfigDependency,
): string {
  return JSON.stringify(
    AIConfigDependency$outboundSchema.parse(aiConfigDependency),
  );
}
export function aiConfigDependencyFromJSON(
  jsonString: string,
): SafeParseResult<AIConfigDependency, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AIConfigDependency$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AIConfigDependency' from JSON`,
  );
}
