UNPKG

@langchain/core

Version:
1 lines 8.31 kB
{"version":3,"file":"core.d.cts","names":["PatchError","_deepClone","JsonPatchError","deepClone","Operation","AddOperation","RemoveOperation","ReplaceOperation","MoveOperation","CopyOperation","TestOperation","GetOperation","Validator","T","OperationResult","BaseOperation","PatchResult","Array","getValueByPointer","applyOperation","applyPatch","ReadonlyArray","applyReducer","validator","validate","_areEquals"],"sources":["../../../../src/utils/fast-json-patch/src/core.d.ts"],"sourcesContent":["import { PatchError, _deepClone } from \"./helpers.js\";\nexport declare const JsonPatchError: typeof PatchError;\nexport declare const deepClone: typeof _deepClone;\nexport type Operation = AddOperation<any> | RemoveOperation | ReplaceOperation<any> | MoveOperation | CopyOperation | TestOperation<any> | GetOperation<any>;\nexport interface Validator<T> {\n (operation: Operation, index: number, document: T, existingPathFragment: string): void;\n}\nexport interface OperationResult<T> {\n removed?: any;\n test?: boolean;\n newDocument: T;\n}\nexport interface BaseOperation {\n path: string;\n}\nexport interface AddOperation<T> extends BaseOperation {\n op: \"add\";\n value: T;\n}\nexport interface RemoveOperation extends BaseOperation {\n op: \"remove\";\n}\nexport interface ReplaceOperation<T> extends BaseOperation {\n op: \"replace\";\n value: T;\n}\nexport interface MoveOperation extends BaseOperation {\n op: \"move\";\n from: string;\n}\nexport interface CopyOperation extends BaseOperation {\n op: \"copy\";\n from: string;\n}\nexport interface TestOperation<T> extends BaseOperation {\n op: \"test\";\n value: T;\n}\nexport interface GetOperation<T> extends BaseOperation {\n op: \"_get\";\n value: T;\n}\nexport interface PatchResult<T> extends Array<OperationResult<T>> {\n newDocument: T;\n}\n/**\n * Retrieves a value from a JSON document by a JSON pointer.\n * Returns the value.\n *\n * @param document The document to get the value from\n * @param pointer an escaped JSON pointer\n * @return The retrieved value\n */\nexport declare function getValueByPointer(document: any, pointer: string): any;\n/**\n * Apply a single JSON Patch Operation on a JSON document.\n * Returns the {newDocument, result} of the operation.\n * It modifies the `document` and `operation` objects - it gets the values by reference.\n * If you would like to avoid touching your values, clone them:\n * `jsonpatch.applyOperation(document, jsonpatch._deepClone(operation))`.\n *\n * @param document The document to patch\n * @param operation The operation to apply\n * @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.\n * @param mutateDocument Whether to mutate the original document or clone it before applying\n * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.\n * @return `{newDocument, result}` after the operation\n */\nexport declare function applyOperation<T>(document: T, operation: Operation, validateOperation?: boolean | Validator<T>, mutateDocument?: boolean, banPrototypeModifications?: boolean, index?: number): OperationResult<T>;\n/**\n * Apply a full JSON Patch array on a JSON document.\n * Returns the {newDocument, result} of the patch.\n * It modifies the `document` object and `patch` - it gets the values by reference.\n * If you would like to avoid touching your values, clone them:\n * `jsonpatch.applyPatch(document, jsonpatch._deepClone(patch))`.\n *\n * @param document The document to patch\n * @param patch The patch to apply\n * @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.\n * @param mutateDocument Whether to mutate the original document or clone it before applying\n * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.\n * @return An array of `{newDocument, result}` after the patch\n */\nexport declare function applyPatch<T>(document: T, patch: ReadonlyArray<Operation>, validateOperation?: boolean | Validator<T>, mutateDocument?: boolean, banPrototypeModifications?: boolean): PatchResult<T>;\n/**\n * Apply a single JSON Patch Operation on a JSON document.\n * Returns the updated document.\n * Suitable as a reducer.\n *\n * @param document The document to patch\n * @param operation The operation to apply\n * @return The updated document\n */\nexport declare function applyReducer<T>(document: T, operation: Operation, index: number): T;\n/**\n * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.\n * @param {object} operation - operation object (patch)\n * @param {number} index - index of operation in the sequence\n * @param {object} [document] - object where the operation is supposed to be applied\n * @param {string} [existingPathFragment] - comes along with `document`\n */\nexport declare function validator(operation: Operation, index: number, document?: any, existingPathFragment?: string): void;\n/**\n * Validates a sequence of operations. If `document` parameter is provided, the sequence is additionally validated against the object document.\n * If error is encountered, returns a JsonPatchError object\n * @param sequence\n * @param document\n * @returns {JsonPatchError|undefined}\n */\nexport declare function validate<T>(sequence: ReadonlyArray<Operation>, document?: T, externalValidator?: Validator<T>): PatchError;\n// based on https://github.com/epoberezkin/fast-deep-equal\n// MIT License\n// Copyright (c) 2017 Evgeny Poberezkin\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\nexport declare function _areEquals(a: any, b: any): boolean;\n"],"mappings":";;AAGwBK,KAAZD,SAAAA,GAAYC,YAAAA,CAAAA,GAAAA,CAAAA,GAAoBC,eAApBD,GAAsCE,gBAAtCF,CAAAA,GAAAA,CAAAA,GAA8DG,aAA9DH,GAA8EI,aAA9EJ,GAA8FK,aAA9FL,CAAAA,GAAAA,CAAAA,GAAmHM,YAAnHN,CAAAA,GAAAA,CAAAA;AAAoBC,UAC3BM,SAD2BN,CAAAA,CAAAA,CAAAA,CAAAA;EAAe,CAAA,SAAGC,EAE9CH,SAF8CG,EAAAA,KAAAA,EAAAA,MAAAA,E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