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

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";

export type JSONPatchAppend = {
  /**
   * A JSON Pointer (RFC 6901) identifying the target location within the document. Can be a string path (e.g., '/foo/bar'), '/', '', or an empty list [] for root-level operations.
   */
  path: string;
  /**
   * The value to use for the operation. A string to append to the existing value
   */
  value: string;
  /**
   * 'append' is an extension for efficient string concatenation in streaming scenarios.
   */
  op: "append";
};

/** @internal */
export const JSONPatchAppend$inboundSchema: z.ZodType<
  JSONPatchAppend,
  unknown
> = z.object({
  path: z.string(),
  value: z.string(),
  op: z.literal("append"),
});

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