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

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

/**
 * Wrapper for encrypted patch values in selective json_patch encryption.
 *
 * @remarks
 *
 * When partial encryption mode is enabled and a patch targets an EncryptedStrField,
 * the patch value is encrypted and wrapped in this structure.
 *
 * The type field acts as a discriminator to distinguish this from user data.
 */
export type EncryptedPatchValue = {
  type: "__encrypted__";
  value: string;
};

/** @internal */
export const EncryptedPatchValue$inboundSchema: z.ZodType<
  EncryptedPatchValue,
  unknown
> = z.object({
  type: z.literal("__encrypted__"),
  value: z.string(),
});

export function encryptedPatchValueFromJSON(
  jsonString: string,
): SafeParseResult<EncryptedPatchValue, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => EncryptedPatchValue$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'EncryptedPatchValue' from JSON`,
  );
}
