import { PatchError, _deepClone } from './helpers.js'; export declare const JsonPatchError: typeof PatchError; export declare const deepClone: typeof _deepClone; export declare type Operation = AddOperation | RemoveOperation | ReplaceOperation | MoveOperation | CopyOperation | TestOperation | GetOperation; export interface Validator { (operation: Operation, index: number, document: T, existingPathFragment: string): void; } export interface OperationResult { removed?: any; test?: boolean; newDocument: T; } export interface BaseOperation { path: string; } export interface AddOperation extends BaseOperation { op: 'add'; value: T; } export interface RemoveOperation extends BaseOperation { op: 'remove'; } export interface ReplaceOperation extends BaseOperation { op: 'replace'; value: T; } export interface MoveOperation extends BaseOperation { op: 'move'; from: string; } export interface CopyOperation extends BaseOperation { op: 'copy'; from: string; } export interface TestOperation extends BaseOperation { op: 'test'; value: T; } export interface GetOperation extends BaseOperation { op: '_get'; value: T; } export interface PatchResult extends Array> { newDocument: T; } /** * Retrieves a value from a JSON document by a JSON pointer. * Returns the value. * * @param document The document to get the value from * @param pointer an escaped JSON pointer * @return The retrieved value */ export declare function getValueByPointer(document: any, pointer: string): any; /** * Apply a single JSON Patch Operation on a JSON document. * Returns the {newDocument, result} of the operation. * It modifies the `document` and `operation` objects - it gets the values by reference. * If you would like to avoid touching your values, clone them: * `jsonpatch.applyOperation(document, jsonpatch._deepClone(operation))`. * * @param document The document to patch * @param operation The operation to apply * @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation. * @param mutateDocument Whether to mutate the original document or clone it before applying * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`. * @return `{newDocument, result}` after the operation */ export declare function applyOperation(document: T, operation: Operation, validateOperation?: boolean | Validator, mutateDocument?: boolean, banPrototypeModifications?: boolean, index?: number): OperationResult; /** * Apply a full JSON Patch array on a JSON document. * Returns the {newDocument, result} of the patch. * It modifies the `document` object and `patch` - it gets the values by reference. * If you would like to avoid touching your values, clone them: * `jsonpatch.applyPatch(document, jsonpatch._deepClone(patch))`. * * @param document The document to patch * @param patch The patch to apply * @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation. * @param mutateDocument Whether to mutate the original document or clone it before applying * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`. * @return An array of `{newDocument, result}` after the patch */ export declare function applyPatch(document: T, patch: ReadonlyArray, validateOperation?: boolean | Validator, mutateDocument?: boolean, banPrototypeModifications?: boolean): PatchResult; /** * Apply a single JSON Patch Operation on a JSON document. * Returns the updated document. * Suitable as a reducer. * * @param document The document to patch * @param operation The operation to apply * @return The updated document */ export declare function applyReducer(document: T, operation: Operation, index: number): T; /** * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error. * @param {object} operation - operation object (patch) * @param {number} index - index of operation in the sequence * @param {object} [document] - object where the operation is supposed to be applied * @param {string} [existingPathFragment] - comes along with `document` */ export declare function validator(operation: Operation, index: number, document?: any, existingPathFragment?: string): void; /** * Validates a sequence of operations. If `document` parameter is provided, the sequence is additionally validated against the object document. * If error is encountered, returns a JsonPatchError object * @param sequence * @param document * @returns {JsonPatchError|undefined} */ export declare function validate(sequence: ReadonlyArray, document?: T, externalValidator?: Validator): PatchError; export declare function _areEquals(a: any, b: any): boolean;