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

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

export type AIConfigTargetingPatch = {
  /**
   * A comment describing the change
   */
  comment?: string | undefined;
  /**
   * The environment key
   */
  environmentKey: string;
  /**
   * The semantic patch instructions to apply
   */
  instructions: Array<{ [k: string]: any }>;
};

/** @internal */
export const AIConfigTargetingPatch$inboundSchema: z.ZodType<
  AIConfigTargetingPatch,
  z.ZodTypeDef,
  unknown
> = z.object({
  comment: z.string().optional(),
  environmentKey: z.string(),
  instructions: z.array(z.record(z.any())),
});
/** @internal */
export type AIConfigTargetingPatch$Outbound = {
  comment?: string | undefined;
  environmentKey: string;
  instructions: Array<{ [k: string]: any }>;
};

/** @internal */
export const AIConfigTargetingPatch$outboundSchema: z.ZodType<
  AIConfigTargetingPatch$Outbound,
  z.ZodTypeDef,
  AIConfigTargetingPatch
> = z.object({
  comment: z.string().optional(),
  environmentKey: z.string(),
  instructions: z.array(z.record(z.any())),
});

export function aiConfigTargetingPatchToJSON(
  aiConfigTargetingPatch: AIConfigTargetingPatch,
): string {
  return JSON.stringify(
    AIConfigTargetingPatch$outboundSchema.parse(aiConfigTargetingPatch),
  );
}
export function aiConfigTargetingPatchFromJSON(
  jsonString: string,
): SafeParseResult<AIConfigTargetingPatch, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AIConfigTargetingPatch$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AIConfigTargetingPatch' from JSON`,
  );
}
