projen 0.105.8 → 0.105.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +4 -4
- package/lib/ai-instructions.js +2 -2
- package/lib/awscdk/auto-discover.js +6 -6
- package/lib/awscdk/awscdk-app-java.js +1 -1
- package/lib/awscdk/awscdk-app-py.js +1 -1
- package/lib/awscdk/awscdk-app-ts.js +1 -1
- package/lib/awscdk/awscdk-construct.js +1 -1
- package/lib/awscdk/awscdk-deps-java.js +1 -1
- package/lib/awscdk/awscdk-deps-js.js +1 -1
- package/lib/awscdk/awscdk-deps-py.js +1 -1
- package/lib/awscdk/awscdk-deps.js +1 -1
- package/lib/awscdk/cdk-config.js +3 -3
- package/lib/awscdk/cdk-tasks.js +1 -1
- package/lib/awscdk/integration-test.js +1 -1
- package/lib/awscdk/lambda-extension.js +1 -1
- package/lib/awscdk/lambda-function.js +2 -2
- package/lib/build/build-workflow.js +1 -1
- package/lib/cdk/auto-discover-base.js +2 -2
- package/lib/cdk/construct-lib.js +1 -1
- package/lib/cdk/integration-test-base.js +1 -1
- package/lib/cdk/jsii-build.js +1 -1
- package/lib/cdk/jsii-docgen.js +1 -1
- package/lib/cdk/jsii-project.js +1 -1
- package/lib/cdk8s/auto-discover.js +2 -2
- package/lib/cdk8s/cdk8s-app-py.js +1 -1
- package/lib/cdk8s/cdk8s-app-ts.js +1 -1
- package/lib/cdk8s/cdk8s-construct.js +1 -1
- package/lib/cdk8s/cdk8s-deps-py.js +1 -1
- package/lib/cdk8s/cdk8s-deps.js +1 -1
- package/lib/cdk8s/integration-test.js +1 -1
- package/lib/cdktf/cdktf-construct.js +1 -1
- package/lib/cdktn/cdktn-app-ts.js +1 -1
- package/lib/cdktn/cdktn-config.js +1 -1
- package/lib/cdktn/cdktn-construct.js +1 -1
- package/lib/cdktn/cdktn-deps.js +1 -1
- package/lib/cdktn/cdktn-tasks.js +1 -1
- package/lib/circleci/circleci.js +1 -1
- package/lib/component.js +2 -2
- package/lib/dependencies.js +1 -1
- package/lib/dev-env.js +1 -1
- package/lib/docker-compose/docker-compose-service.js +1 -1
- package/lib/docker-compose/docker-compose.js +1 -1
- package/lib/file.js +1 -1
- package/lib/gitattributes.js +1 -1
- package/lib/github/actions-provider.js +1 -1
- package/lib/github/actions.const.d.ts +2 -2
- package/lib/github/actions.const.js +4 -4
- package/lib/github/auto-approve.js +1 -1
- package/lib/github/auto-merge.js +1 -1
- package/lib/github/auto-queue.js +1 -1
- package/lib/github/dependabot.js +1 -1
- package/lib/github/dependency-review.js +1 -1
- package/lib/github/github-credentials.js +1 -1
- package/lib/github/github-project.js +1 -1
- package/lib/github/github.js +1 -1
- package/lib/github/kodiak.js +1 -1
- package/lib/github/merge-queue.js +1 -1
- package/lib/github/mergify.js +1 -1
- package/lib/github/pr-template.js +1 -1
- package/lib/github/pull-request-backport.js +1 -1
- package/lib/github/pull-request-lint.js +1 -1
- package/lib/github/pull-request-source.js +1 -1
- package/lib/github/stale.js +1 -1
- package/lib/github/task-workflow-job.js +1 -1
- package/lib/github/task-workflow.js +1 -1
- package/lib/github/workflow-actions.js +1 -1
- package/lib/github/workflow-jobs.js +1 -1
- package/lib/github/workflow-steps.js +1 -1
- package/lib/github/workflows.js +1 -1
- package/lib/gitlab/configuration.js +1 -1
- package/lib/gitlab/gitlab-configuration.js +1 -1
- package/lib/gitlab/nested-configuration.js +1 -1
- package/lib/gitpod.js +1 -1
- package/lib/ignore-file.js +1 -1
- package/lib/ini.js +1 -1
- package/lib/inventory.d.ts +1 -0
- package/lib/inventory.js +36 -9
- package/lib/java/java-project.js +1 -1
- package/lib/java/junit.js +1 -1
- package/lib/java/maven-compile.js +1 -1
- package/lib/java/maven-packaging.js +1 -1
- package/lib/java/maven-sample.js +1 -1
- package/lib/java/pom.js +2 -2
- package/lib/java/projenrc.js +1 -1
- package/lib/javascript/biome/biome.js +1 -1
- package/lib/javascript/bundler.js +1 -1
- package/lib/javascript/eslint.js +1 -1
- package/lib/javascript/jest.js +4 -4
- package/lib/javascript/license-checker.js +1 -1
- package/lib/javascript/node-config-file.js +1 -1
- package/lib/javascript/node-native-test-runner.js +2 -2
- package/lib/javascript/node-package.js +1 -1
- package/lib/javascript/node-project.js +1 -1
- package/lib/javascript/npm-config.js +1 -1
- package/lib/javascript/pnpm-workspace-config.js +4 -4
- package/lib/javascript/pnpm-workspace.js +1 -1
- package/lib/javascript/prettier.js +1 -1
- package/lib/javascript/projenrc.js +1 -1
- package/lib/javascript/typescript-config.js +2 -2
- package/lib/javascript/upgrade-dependencies.js +2 -2
- package/lib/javascript/yarnrc.js +1 -1
- package/lib/json-patch.js +1 -1
- package/lib/json.js +1 -1
- package/lib/license.js +1 -1
- package/lib/logger.js +1 -1
- package/lib/makefile.js +1 -1
- package/lib/object-file.js +1 -1
- package/lib/polaris/coverity-go.js +1 -1
- package/lib/polaris/coverity-java.js +1 -1
- package/lib/polaris/coverity-javascript.js +1 -1
- package/lib/polaris/coverity.js +1 -1
- package/lib/project-build.js +1 -1
- package/lib/project-tree.js +1 -1
- package/lib/project.js +1 -1
- package/lib/projects.js +1 -1
- package/lib/projenrc-json.js +1 -1
- package/lib/projenrc.js +1 -1
- package/lib/properties-file.js +1 -1
- package/lib/python/pip.js +1 -1
- package/lib/python/poetry.js +2 -2
- package/lib/python/projenrc.js +1 -1
- package/lib/python/pyproject-toml-file.js +1 -1
- package/lib/python/pytest-sample.js +1 -1
- package/lib/python/pytest.js +1 -1
- package/lib/python/python-project.js +1 -1
- package/lib/python/python-sample.js +1 -1
- package/lib/python/requirements-file.js +1 -1
- package/lib/python/setuppy.js +1 -1
- package/lib/python/setuptools.js +1 -1
- package/lib/python/uv-config.js +1 -1
- package/lib/python/uv.js +1 -1
- package/lib/python/venv.js +1 -1
- package/lib/readme.js +1 -1
- package/lib/release/publisher.js +1 -1
- package/lib/release/release-trigger.js +1 -1
- package/lib/release/release.js +1 -1
- package/lib/renovatebot.js +1 -1
- package/lib/run-task.cjs +2 -2
- package/lib/sample-file.js +2 -2
- package/lib/script-runner.js +1 -1
- package/lib/sonarqube/javascript.js +1 -1
- package/lib/sonarqube/rust.js +1 -1
- package/lib/sonarqube/sonarqube.js +1 -1
- package/lib/sonarqube/typescript.js +1 -1
- package/lib/source-code.js +1 -1
- package/lib/task-shell.js +1 -1
- package/lib/task.js +1 -1
- package/lib/tasks.js +1 -1
- package/lib/testing.js +1 -1
- package/lib/textfile.js +1 -1
- package/lib/toml.js +1 -1
- package/lib/typescript/projenrc-ts.js +1 -1
- package/lib/typescript/projenrc.js +1 -1
- package/lib/typescript/typescript-runner.js +1 -1
- package/lib/typescript/typescript-typedoc.js +1 -1
- package/lib/typescript/typescript.js +5 -5
- package/lib/version.js +2 -2
- package/lib/vscode/devcontainer.js +1 -1
- package/lib/vscode/extensions.js +1 -1
- package/lib/vscode/launch-config.js +1 -1
- package/lib/vscode/settings.js +1 -1
- package/lib/vscode/vscode.js +1 -1
- package/lib/web/next.js +3 -3
- package/lib/web/postcss.js +1 -1
- package/lib/web/react.js +3 -3
- package/lib/web/tailwind.js +1 -1
- package/lib/xmlfile.js +1 -1
- package/lib/yaml.js +1 -1
- package/node_modules/fast-json-patch/README.md +2 -2
- package/node_modules/fast-json-patch/dist/fast-json-patch.js +604 -818
- package/node_modules/fast-json-patch/dist/fast-json-patch.min.js +4 -8
- package/node_modules/fast-json-patch/package.json +14 -17
- package/package.json +2 -2
- package/node_modules/fast-json-patch/webpack.config.js +0 -63
|
@@ -1,928 +1,714 @@
|
|
|
1
|
-
/*! fast-json-patch, version: 3.1.
|
|
2
|
-
var jsonpatch =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/******/ if(installedModules[moduleId]) {
|
|
12
|
-
/******/ return installedModules[moduleId].exports;
|
|
13
|
-
/******/ }
|
|
14
|
-
/******/ // Create a new module (and put it into the cache)
|
|
15
|
-
/******/ var module = installedModules[moduleId] = {
|
|
16
|
-
/******/ i: moduleId,
|
|
17
|
-
/******/ l: false,
|
|
18
|
-
/******/ exports: {}
|
|
19
|
-
/******/ };
|
|
20
|
-
/******/
|
|
21
|
-
/******/ // Execute the module function
|
|
22
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
23
|
-
/******/
|
|
24
|
-
/******/ // Flag the module as loaded
|
|
25
|
-
/******/ module.l = true;
|
|
26
|
-
/******/
|
|
27
|
-
/******/ // Return the exports of the module
|
|
28
|
-
/******/ return module.exports;
|
|
29
|
-
/******/ }
|
|
30
|
-
/******/
|
|
31
|
-
/******/
|
|
32
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
33
|
-
/******/ __webpack_require__.m = modules;
|
|
34
|
-
/******/
|
|
35
|
-
/******/ // expose the module cache
|
|
36
|
-
/******/ __webpack_require__.c = installedModules;
|
|
37
|
-
/******/
|
|
38
|
-
/******/ // define getter function for harmony exports
|
|
39
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
40
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
41
|
-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
42
|
-
/******/ }
|
|
43
|
-
/******/ };
|
|
44
|
-
/******/
|
|
45
|
-
/******/ // define __esModule on exports
|
|
46
|
-
/******/ __webpack_require__.r = function(exports) {
|
|
47
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
48
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
49
|
-
/******/ }
|
|
50
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
51
|
-
/******/ };
|
|
52
|
-
/******/
|
|
53
|
-
/******/ // create a fake namespace object
|
|
54
|
-
/******/ // mode & 1: value is a module id, require it
|
|
55
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
56
|
-
/******/ // mode & 4: return value when already ns object
|
|
57
|
-
/******/ // mode & 8|1: behave like require
|
|
58
|
-
/******/ __webpack_require__.t = function(value, mode) {
|
|
59
|
-
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
60
|
-
/******/ if(mode & 8) return value;
|
|
61
|
-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
62
|
-
/******/ var ns = Object.create(null);
|
|
63
|
-
/******/ __webpack_require__.r(ns);
|
|
64
|
-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
65
|
-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
66
|
-
/******/ return ns;
|
|
67
|
-
/******/ };
|
|
68
|
-
/******/
|
|
69
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
70
|
-
/******/ __webpack_require__.n = function(module) {
|
|
71
|
-
/******/ var getter = module && module.__esModule ?
|
|
72
|
-
/******/ function getDefault() { return module['default']; } :
|
|
73
|
-
/******/ function getModuleExports() { return module; };
|
|
74
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
75
|
-
/******/ return getter;
|
|
76
|
-
/******/ };
|
|
77
|
-
/******/
|
|
78
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
79
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
80
|
-
/******/
|
|
81
|
-
/******/ // __webpack_public_path__
|
|
82
|
-
/******/ __webpack_require__.p = "";
|
|
83
|
-
/******/
|
|
84
|
-
/******/
|
|
85
|
-
/******/ // Load entry module and return exports
|
|
86
|
-
/******/ return __webpack_require__(__webpack_require__.s = 2);
|
|
87
|
-
/******/ })
|
|
88
|
-
/************************************************************************/
|
|
89
|
-
/******/ ([
|
|
90
|
-
/* 0 */
|
|
91
|
-
/***/ (function(module, exports) {
|
|
92
|
-
|
|
93
|
-
/*!
|
|
94
|
-
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
95
|
-
* (c) 2017-2022 Joachim Wester
|
|
96
|
-
* MIT licensed
|
|
97
|
-
*/
|
|
98
|
-
var __extends = (this && this.__extends) || (function () {
|
|
99
|
-
var extendStatics = function (d, b) {
|
|
100
|
-
extendStatics = Object.setPrototypeOf ||
|
|
101
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
102
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
103
|
-
return extendStatics(d, b);
|
|
104
|
-
};
|
|
105
|
-
return function (d, b) {
|
|
106
|
-
extendStatics(d, b);
|
|
107
|
-
function __() { this.constructor = d; }
|
|
108
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1
|
+
/*! fast-json-patch, version: 3.1.2 */
|
|
2
|
+
var jsonpatch = (function() {
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __commonJS = function(cb, mod) {
|
|
5
|
+
return function __require() {
|
|
6
|
+
try {
|
|
7
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8
|
+
} catch (e) {
|
|
9
|
+
throw mod = 0, e;
|
|
10
|
+
}
|
|
109
11
|
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// commonjs/helpers.js
|
|
15
|
+
var require_helpers = __commonJS({
|
|
16
|
+
"commonjs/helpers.js": function(exports) {
|
|
17
|
+
/*!
|
|
18
|
+
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
19
|
+
* (c) 2017-2022 Joachim Wester
|
|
20
|
+
* MIT licensed
|
|
21
|
+
*/
|
|
22
|
+
var __extends = exports && exports.__extends || /* @__PURE__ */ (function() {
|
|
23
|
+
var extendStatics = function(d, b) {
|
|
24
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
25
|
+
d2.__proto__ = b2;
|
|
26
|
+
} || function(d2, b2) {
|
|
27
|
+
for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
|
|
28
|
+
};
|
|
29
|
+
return extendStatics(d, b);
|
|
30
|
+
};
|
|
31
|
+
return function(d, b) {
|
|
32
|
+
extendStatics(d, b);
|
|
33
|
+
function __() {
|
|
34
|
+
this.constructor = d;
|
|
35
|
+
}
|
|
36
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
41
|
+
function hasOwnProperty(obj, key) {
|
|
42
|
+
return _hasOwnProperty.call(obj, key);
|
|
43
|
+
}
|
|
44
|
+
exports.hasOwnProperty = hasOwnProperty;
|
|
45
|
+
function _objectKeys(obj) {
|
|
46
|
+
if (Array.isArray(obj)) {
|
|
47
|
+
var keys_1 = new Array(obj.length);
|
|
48
|
+
for (var k = 0; k < keys_1.length; k++) {
|
|
121
49
|
keys_1[k] = "" + k;
|
|
50
|
+
}
|
|
51
|
+
return keys_1;
|
|
122
52
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (Object.keys) {
|
|
126
|
-
return Object.keys(obj);
|
|
127
|
-
}
|
|
128
|
-
var keys = [];
|
|
129
|
-
for (var i in obj) {
|
|
130
|
-
if (hasOwnProperty(obj, i)) {
|
|
131
|
-
keys.push(i);
|
|
53
|
+
if (Object.keys) {
|
|
54
|
+
return Object.keys(obj);
|
|
132
55
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return obj;
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
exports._deepClone = _deepClone;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (charCode >= 48 && charCode <= 57) {
|
|
56
|
+
var keys = [];
|
|
57
|
+
for (var i in obj) {
|
|
58
|
+
if (hasOwnProperty(obj, i)) {
|
|
59
|
+
keys.push(i);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return keys;
|
|
63
|
+
}
|
|
64
|
+
exports._objectKeys = _objectKeys;
|
|
65
|
+
function _deepClone(obj) {
|
|
66
|
+
switch (typeof obj) {
|
|
67
|
+
case "object":
|
|
68
|
+
return JSON.parse(JSON.stringify(obj));
|
|
69
|
+
//Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5
|
|
70
|
+
case "undefined":
|
|
71
|
+
return null;
|
|
72
|
+
//this is how JSON.stringify behaves for array items
|
|
73
|
+
default:
|
|
74
|
+
return obj;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports._deepClone = _deepClone;
|
|
78
|
+
function isInteger(str) {
|
|
79
|
+
var i = 0;
|
|
80
|
+
var len = str.length;
|
|
81
|
+
var charCode;
|
|
82
|
+
while (i < len) {
|
|
83
|
+
charCode = str.charCodeAt(i);
|
|
84
|
+
if (charCode >= 48 && charCode <= 57) {
|
|
163
85
|
i++;
|
|
164
86
|
continue;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
165
89
|
}
|
|
166
|
-
return
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
* Unescapes a json pointer path
|
|
184
|
-
* @param path The escaped pointer
|
|
185
|
-
* @return The unescaped path
|
|
186
|
-
*/
|
|
187
|
-
function unescapePathComponent(path) {
|
|
188
|
-
return path.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
189
|
-
}
|
|
190
|
-
exports.unescapePathComponent = unescapePathComponent;
|
|
191
|
-
function _getPathRecursive(root, obj) {
|
|
192
|
-
var found;
|
|
193
|
-
for (var key in root) {
|
|
194
|
-
if (hasOwnProperty(root, key)) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
exports.isInteger = isInteger;
|
|
93
|
+
function escapePathComponent(path) {
|
|
94
|
+
if (path.indexOf("/") === -1 && path.indexOf("~") === -1)
|
|
95
|
+
return path;
|
|
96
|
+
return path.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
97
|
+
}
|
|
98
|
+
exports.escapePathComponent = escapePathComponent;
|
|
99
|
+
function unescapePathComponent(path) {
|
|
100
|
+
return path.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
101
|
+
}
|
|
102
|
+
exports.unescapePathComponent = unescapePathComponent;
|
|
103
|
+
function _getPathRecursive(root, obj) {
|
|
104
|
+
var found;
|
|
105
|
+
for (var key in root) {
|
|
106
|
+
if (hasOwnProperty(root, key)) {
|
|
195
107
|
if (root[key] === obj) {
|
|
196
|
-
|
|
108
|
+
return escapePathComponent(key) + "/";
|
|
109
|
+
} else if (typeof root[key] === "object") {
|
|
110
|
+
found = _getPathRecursive(root[key], obj);
|
|
111
|
+
if (found != "") {
|
|
112
|
+
return escapePathComponent(key) + "/" + found;
|
|
113
|
+
}
|
|
197
114
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Recursively checks whether an object has any undefined values inside.
|
|
222
|
-
*/
|
|
223
|
-
function hasUndefined(obj) {
|
|
224
|
-
if (obj === undefined) {
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
if (obj) {
|
|
228
|
-
if (Array.isArray(obj)) {
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return "";
|
|
118
|
+
}
|
|
119
|
+
exports._getPathRecursive = _getPathRecursive;
|
|
120
|
+
function getPath(root, obj) {
|
|
121
|
+
if (root === obj) {
|
|
122
|
+
return "/";
|
|
123
|
+
}
|
|
124
|
+
var path = _getPathRecursive(root, obj);
|
|
125
|
+
if (path === "") {
|
|
126
|
+
throw new Error("Object not found in root");
|
|
127
|
+
}
|
|
128
|
+
return "/" + path;
|
|
129
|
+
}
|
|
130
|
+
exports.getPath = getPath;
|
|
131
|
+
function hasUndefined(obj) {
|
|
132
|
+
if (obj === void 0) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
if (obj) {
|
|
136
|
+
if (Array.isArray(obj)) {
|
|
229
137
|
for (var i_1 = 0, len = obj.length; i_1 < len; i_1++) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
138
|
+
if (hasUndefined(obj[i_1])) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
233
141
|
}
|
|
234
|
-
|
|
235
|
-
else if (typeof obj === "object") {
|
|
142
|
+
} else if (typeof obj === "object") {
|
|
236
143
|
var objKeys = _objectKeys(obj);
|
|
237
144
|
var objKeysLength = objKeys.length;
|
|
238
145
|
for (var i = 0; i < objKeysLength; i++) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
146
|
+
if (hasUndefined(obj[objKeys[i]])) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
242
149
|
}
|
|
150
|
+
}
|
|
243
151
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
if (typeof value !== 'undefined') {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
exports.hasUndefined = hasUndefined;
|
|
155
|
+
function patchErrorMessageFormatter(message, args) {
|
|
156
|
+
var messageParts = [message];
|
|
157
|
+
for (var key in args) {
|
|
158
|
+
var value = typeof args[key] === "object" ? JSON.stringify(args[key], null, 2) : args[key];
|
|
159
|
+
if (typeof value !== "undefined") {
|
|
253
160
|
messageParts.push(key + ": " + value);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
var PatchError =
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return messageParts.join("\n");
|
|
164
|
+
}
|
|
165
|
+
var PatchError = (
|
|
166
|
+
/** @class */
|
|
167
|
+
(function(_super) {
|
|
168
|
+
__extends(PatchError2, _super);
|
|
169
|
+
function PatchError2(message, name, index, operation, tree) {
|
|
170
|
+
var _newTarget = this.constructor;
|
|
171
|
+
var _this = _super.call(this, patchErrorMessageFormatter(message, { name: name, index: index, operation: operation, tree: tree })) || this;
|
|
172
|
+
_this.name = name;
|
|
173
|
+
_this.index = index;
|
|
174
|
+
_this.operation = operation;
|
|
175
|
+
_this.tree = tree;
|
|
176
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
177
|
+
_this.message = patchErrorMessageFormatter(message, { name: name, index: index, operation: operation, tree: tree });
|
|
178
|
+
return _this;
|
|
179
|
+
}
|
|
180
|
+
return PatchError2;
|
|
181
|
+
})(Error)
|
|
182
|
+
);
|
|
183
|
+
exports.PatchError = PatchError;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
279
186
|
|
|
280
|
-
|
|
281
|
-
var
|
|
282
|
-
|
|
283
|
-
exports
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
},
|
|
306
|
-
move: function (obj, key, document) {
|
|
307
|
-
/* in case move target overwrites an existing value,
|
|
308
|
-
return the removed value, this can be taxing performance-wise,
|
|
309
|
-
and is potentially unneeded */
|
|
310
|
-
var removed = getValueByPointer(document, this.path);
|
|
311
|
-
if (removed) {
|
|
187
|
+
// commonjs/core.js
|
|
188
|
+
var require_core = __commonJS({
|
|
189
|
+
"commonjs/core.js": function(exports) {
|
|
190
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
191
|
+
var helpers_js_1 = require_helpers();
|
|
192
|
+
exports.JsonPatchError = helpers_js_1.PatchError;
|
|
193
|
+
exports.deepClone = helpers_js_1._deepClone;
|
|
194
|
+
var objOps = {
|
|
195
|
+
add: function(obj, key, document) {
|
|
196
|
+
obj[key] = this.value;
|
|
197
|
+
return { newDocument: document };
|
|
198
|
+
},
|
|
199
|
+
remove: function(obj, key, document) {
|
|
200
|
+
var removed = obj[key];
|
|
201
|
+
delete obj[key];
|
|
202
|
+
return { newDocument: document, removed: removed };
|
|
203
|
+
},
|
|
204
|
+
replace: function(obj, key, document) {
|
|
205
|
+
var removed = obj[key];
|
|
206
|
+
obj[key] = this.value;
|
|
207
|
+
return { newDocument: document, removed: removed };
|
|
208
|
+
},
|
|
209
|
+
move: function(obj, key, document) {
|
|
210
|
+
var removed = getValueByPointer(document, this.path);
|
|
211
|
+
if (removed) {
|
|
312
212
|
removed = helpers_js_1._deepClone(removed);
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
add: function (arr, i, document) {
|
|
335
|
-
if (helpers_js_1.isInteger(i)) {
|
|
213
|
+
}
|
|
214
|
+
var originalValue = applyOperation(document, { op: "remove", path: this.from }).removed;
|
|
215
|
+
applyOperation(document, { op: "add", path: this.path, value: originalValue });
|
|
216
|
+
return { newDocument: document, removed: removed };
|
|
217
|
+
},
|
|
218
|
+
copy: function(obj, key, document) {
|
|
219
|
+
var valueToCopy = getValueByPointer(document, this.from);
|
|
220
|
+
applyOperation(document, { op: "add", path: this.path, value: helpers_js_1._deepClone(valueToCopy) });
|
|
221
|
+
return { newDocument: document };
|
|
222
|
+
},
|
|
223
|
+
test: function(obj, key, document) {
|
|
224
|
+
return { newDocument: document, test: _areEquals(obj[key], this.value) };
|
|
225
|
+
},
|
|
226
|
+
_get: function(obj, key, document) {
|
|
227
|
+
this.value = obj[key];
|
|
228
|
+
return { newDocument: document };
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
var arrOps = {
|
|
232
|
+
add: function(arr, i, document) {
|
|
233
|
+
if (helpers_js_1.isInteger(i)) {
|
|
336
234
|
arr.splice(i, 0, this.value);
|
|
337
|
-
|
|
338
|
-
else { // array props
|
|
235
|
+
} else {
|
|
339
236
|
arr[i] = this.value;
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
function
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
*
|
|
382
|
-
* @param document The document to patch
|
|
383
|
-
* @param operation The operation to apply
|
|
384
|
-
* @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.
|
|
385
|
-
* @param mutateDocument Whether to mutate the original document or clone it before applying
|
|
386
|
-
* @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.
|
|
387
|
-
* @return `{newDocument, result}` after the operation
|
|
388
|
-
*/
|
|
389
|
-
function applyOperation(document, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {
|
|
390
|
-
if (validateOperation === void 0) { validateOperation = false; }
|
|
391
|
-
if (mutateDocument === void 0) { mutateDocument = true; }
|
|
392
|
-
if (banPrototypeModifications === void 0) { banPrototypeModifications = true; }
|
|
393
|
-
if (index === void 0) { index = 0; }
|
|
394
|
-
if (validateOperation) {
|
|
395
|
-
if (typeof validateOperation == 'function') {
|
|
237
|
+
}
|
|
238
|
+
return { newDocument: document, index: i };
|
|
239
|
+
},
|
|
240
|
+
remove: function(arr, i, document) {
|
|
241
|
+
var removedList = arr.splice(i, 1);
|
|
242
|
+
return { newDocument: document, removed: removedList[0] };
|
|
243
|
+
},
|
|
244
|
+
replace: function(arr, i, document) {
|
|
245
|
+
var removed = arr[i];
|
|
246
|
+
arr[i] = this.value;
|
|
247
|
+
return { newDocument: document, removed: removed };
|
|
248
|
+
},
|
|
249
|
+
move: objOps.move,
|
|
250
|
+
copy: objOps.copy,
|
|
251
|
+
test: objOps.test,
|
|
252
|
+
_get: objOps._get
|
|
253
|
+
};
|
|
254
|
+
function getValueByPointer(document, pointer) {
|
|
255
|
+
if (pointer == "") {
|
|
256
|
+
return document;
|
|
257
|
+
}
|
|
258
|
+
var getOriginalDestination = { op: "_get", path: pointer };
|
|
259
|
+
applyOperation(document, getOriginalDestination);
|
|
260
|
+
return getOriginalDestination.value;
|
|
261
|
+
}
|
|
262
|
+
exports.getValueByPointer = getValueByPointer;
|
|
263
|
+
function applyOperation(document, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {
|
|
264
|
+
if (validateOperation === void 0) {
|
|
265
|
+
validateOperation = false;
|
|
266
|
+
}
|
|
267
|
+
if (mutateDocument === void 0) {
|
|
268
|
+
mutateDocument = true;
|
|
269
|
+
}
|
|
270
|
+
if (banPrototypeModifications === void 0) {
|
|
271
|
+
banPrototypeModifications = true;
|
|
272
|
+
}
|
|
273
|
+
if (index === void 0) {
|
|
274
|
+
index = 0;
|
|
275
|
+
}
|
|
276
|
+
if (validateOperation) {
|
|
277
|
+
if (typeof validateOperation == "function") {
|
|
396
278
|
validateOperation(operation, 0, document, operation.path);
|
|
397
|
-
|
|
398
|
-
else {
|
|
279
|
+
} else {
|
|
399
280
|
validator(operation, 0);
|
|
281
|
+
}
|
|
400
282
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
var returnValue = { newDocument: document };
|
|
405
|
-
if (operation.op === 'add') {
|
|
283
|
+
if (operation.path === "") {
|
|
284
|
+
var returnValue = { newDocument: document };
|
|
285
|
+
if (operation.op === "add") {
|
|
406
286
|
returnValue.newDocument = operation.value;
|
|
407
287
|
return returnValue;
|
|
408
|
-
|
|
409
|
-
else if (operation.op === 'replace') {
|
|
288
|
+
} else if (operation.op === "replace") {
|
|
410
289
|
returnValue.newDocument = operation.value;
|
|
411
|
-
returnValue.removed = document;
|
|
290
|
+
returnValue.removed = document;
|
|
412
291
|
return returnValue;
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
returnValue.removed = document;
|
|
292
|
+
} else if (operation.op === "move" || operation.op === "copy") {
|
|
293
|
+
returnValue.newDocument = getValueByPointer(document, operation.from);
|
|
294
|
+
if (operation.op === "move") {
|
|
295
|
+
returnValue.removed = document;
|
|
418
296
|
}
|
|
419
297
|
return returnValue;
|
|
420
|
-
|
|
421
|
-
else if (operation.op === 'test') {
|
|
298
|
+
} else if (operation.op === "test") {
|
|
422
299
|
returnValue.test = _areEquals(document, operation.value);
|
|
423
300
|
if (returnValue.test === false) {
|
|
424
|
-
|
|
301
|
+
throw new exports.JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
425
302
|
}
|
|
426
303
|
returnValue.newDocument = document;
|
|
427
304
|
return returnValue;
|
|
428
|
-
|
|
429
|
-
else if (operation.op === 'remove') { // a remove on root
|
|
305
|
+
} else if (operation.op === "remove") {
|
|
430
306
|
returnValue.removed = document;
|
|
431
307
|
returnValue.newDocument = null;
|
|
432
308
|
return returnValue;
|
|
433
|
-
|
|
434
|
-
else if (operation.op === '_get') {
|
|
309
|
+
} else if (operation.op === "_get") {
|
|
435
310
|
operation.value = document;
|
|
436
311
|
return returnValue;
|
|
437
|
-
|
|
438
|
-
else { /* bad operation */
|
|
312
|
+
} else {
|
|
439
313
|
if (validateOperation) {
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
return returnValue;
|
|
314
|
+
throw new exports.JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
|
|
315
|
+
} else {
|
|
316
|
+
return returnValue;
|
|
444
317
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
if (!mutateDocument) {
|
|
318
|
+
}
|
|
319
|
+
} else {
|
|
320
|
+
if (!mutateDocument) {
|
|
449
321
|
document = helpers_js_1._deepClone(document);
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
322
|
+
}
|
|
323
|
+
var path = operation.path || "";
|
|
324
|
+
var keys = path.split("/");
|
|
325
|
+
var obj = document;
|
|
326
|
+
var t = 1;
|
|
327
|
+
var len = keys.length;
|
|
328
|
+
var existingPathFragment = void 0;
|
|
329
|
+
var key = void 0;
|
|
330
|
+
var validateFunction = void 0;
|
|
331
|
+
if (typeof validateOperation == "function") {
|
|
460
332
|
validateFunction = validateOperation;
|
|
461
|
-
|
|
462
|
-
else {
|
|
333
|
+
} else {
|
|
463
334
|
validateFunction = validator;
|
|
464
|
-
|
|
465
|
-
|
|
335
|
+
}
|
|
336
|
+
while (true) {
|
|
466
337
|
key = keys[t];
|
|
467
|
-
if (key && key.indexOf(
|
|
468
|
-
|
|
338
|
+
if (key && key.indexOf("~") != -1) {
|
|
339
|
+
key = helpers_js_1.unescapePathComponent(key);
|
|
469
340
|
}
|
|
470
|
-
if (banPrototypeModifications &&
|
|
471
|
-
|
|
472
|
-
(key == 'prototype' && t > 0 && keys[t - 1] == 'constructor'))) {
|
|
473
|
-
throw new TypeError('JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README');
|
|
341
|
+
if (banPrototypeModifications && (key == "__proto__" || key == "prototype" && t > 0 && keys[t - 1] == "constructor")) {
|
|
342
|
+
throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");
|
|
474
343
|
}
|
|
475
344
|
if (validateOperation) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
validateFunction(operation, 0, document, existingPathFragment);
|
|
485
|
-
}
|
|
345
|
+
if (existingPathFragment === void 0) {
|
|
346
|
+
if (obj[key] === void 0) {
|
|
347
|
+
existingPathFragment = keys.slice(0, t).join("/");
|
|
348
|
+
} else if (t == len - 1) {
|
|
349
|
+
existingPathFragment = operation.path;
|
|
350
|
+
}
|
|
351
|
+
if (existingPathFragment !== void 0) {
|
|
352
|
+
validateFunction(operation, 0, document, existingPathFragment);
|
|
486
353
|
}
|
|
354
|
+
}
|
|
487
355
|
}
|
|
488
356
|
t++;
|
|
489
357
|
if (Array.isArray(obj)) {
|
|
490
|
-
|
|
491
|
-
|
|
358
|
+
if (key === "-") {
|
|
359
|
+
key = obj.length;
|
|
360
|
+
} else {
|
|
361
|
+
if (validateOperation && !helpers_js_1.isInteger(key)) {
|
|
362
|
+
throw new exports.JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", index, operation, document);
|
|
363
|
+
} else if (helpers_js_1.isInteger(key)) {
|
|
364
|
+
key = ~~key;
|
|
492
365
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
else if (helpers_js_1.isInteger(key)) {
|
|
498
|
-
key = ~~key;
|
|
499
|
-
}
|
|
366
|
+
}
|
|
367
|
+
if (t >= len) {
|
|
368
|
+
if (validateOperation && operation.op === "add" && key > obj.length) {
|
|
369
|
+
throw new exports.JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", index, operation, document);
|
|
500
370
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
var returnValue = arrOps[operation.op].call(operation, obj, key, document); // Apply patch
|
|
506
|
-
if (returnValue.test === false) {
|
|
507
|
-
throw new exports.JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document);
|
|
508
|
-
}
|
|
509
|
-
return returnValue;
|
|
371
|
+
var returnValue = arrOps[operation.op].call(operation, obj, key, document);
|
|
372
|
+
if (returnValue.test === false) {
|
|
373
|
+
throw new exports.JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
510
374
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
return returnValue;
|
|
375
|
+
return returnValue;
|
|
376
|
+
}
|
|
377
|
+
} else {
|
|
378
|
+
if (t >= len) {
|
|
379
|
+
var returnValue = objOps[operation.op].call(operation, obj, key, document);
|
|
380
|
+
if (returnValue.test === false) {
|
|
381
|
+
throw new exports.JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
519
382
|
}
|
|
383
|
+
return returnValue;
|
|
384
|
+
}
|
|
520
385
|
}
|
|
521
386
|
obj = obj[key];
|
|
522
|
-
// If we have more keys in the path, but the next value isn't a non-null object,
|
|
523
|
-
// throw an OPERATION_PATH_UNRESOLVABLE error instead of iterating again.
|
|
524
387
|
if (validateOperation && t < len && (!obj || typeof obj !== "object")) {
|
|
525
|
-
|
|
388
|
+
throw new exports.JsonPatchError("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
|
|
526
389
|
}
|
|
390
|
+
}
|
|
527
391
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
* Returns the {newDocument, result} of the patch.
|
|
534
|
-
* It modifies the `document` object and `patch` - it gets the values by reference.
|
|
535
|
-
* If you would like to avoid touching your values, clone them:
|
|
536
|
-
* `jsonpatch.applyPatch(document, jsonpatch._deepClone(patch))`.
|
|
537
|
-
*
|
|
538
|
-
* @param document The document to patch
|
|
539
|
-
* @param patch The patch to apply
|
|
540
|
-
* @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.
|
|
541
|
-
* @param mutateDocument Whether to mutate the original document or clone it before applying
|
|
542
|
-
* @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.
|
|
543
|
-
* @return An array of `{newDocument, result}` after the patch
|
|
544
|
-
*/
|
|
545
|
-
function applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications) {
|
|
546
|
-
if (mutateDocument === void 0) { mutateDocument = true; }
|
|
547
|
-
if (banPrototypeModifications === void 0) { banPrototypeModifications = true; }
|
|
548
|
-
if (validateOperation) {
|
|
549
|
-
if (!Array.isArray(patch)) {
|
|
550
|
-
throw new exports.JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');
|
|
392
|
+
}
|
|
393
|
+
exports.applyOperation = applyOperation;
|
|
394
|
+
function applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications) {
|
|
395
|
+
if (mutateDocument === void 0) {
|
|
396
|
+
mutateDocument = true;
|
|
551
397
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
exports.
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
else if (typeof operation.path !== 'string') {
|
|
598
|
-
throw new exports.JsonPatchError('Operation `path` property is not a string', 'OPERATION_PATH_INVALID', index, operation, document);
|
|
599
|
-
}
|
|
600
|
-
else if (operation.path.indexOf('/') !== 0 && operation.path.length > 0) {
|
|
601
|
-
// paths that aren't empty string should start with "/"
|
|
602
|
-
throw new exports.JsonPatchError('Operation `path` property must start with "/"', 'OPERATION_PATH_INVALID', index, operation, document);
|
|
603
|
-
}
|
|
604
|
-
else if ((operation.op === 'move' || operation.op === 'copy') && typeof operation.from !== 'string') {
|
|
605
|
-
throw new exports.JsonPatchError('Operation `from` property is not present (applicable in `move` and `copy` operations)', 'OPERATION_FROM_REQUIRED', index, operation, document);
|
|
606
|
-
}
|
|
607
|
-
else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && operation.value === undefined) {
|
|
608
|
-
throw new exports.JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_REQUIRED', index, operation, document);
|
|
609
|
-
}
|
|
610
|
-
else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && helpers_js_1.hasUndefined(operation.value)) {
|
|
611
|
-
throw new exports.JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED', index, operation, document);
|
|
612
|
-
}
|
|
613
|
-
else if (document) {
|
|
614
|
-
if (operation.op == "add") {
|
|
398
|
+
if (banPrototypeModifications === void 0) {
|
|
399
|
+
banPrototypeModifications = true;
|
|
400
|
+
}
|
|
401
|
+
if (validateOperation) {
|
|
402
|
+
if (!Array.isArray(patch)) {
|
|
403
|
+
throw new exports.JsonPatchError("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (!mutateDocument) {
|
|
407
|
+
document = helpers_js_1._deepClone(document);
|
|
408
|
+
}
|
|
409
|
+
var results = new Array(patch.length);
|
|
410
|
+
for (var i = 0, length_1 = patch.length; i < length_1; i++) {
|
|
411
|
+
results[i] = applyOperation(document, patch[i], validateOperation, true, banPrototypeModifications, i);
|
|
412
|
+
document = results[i].newDocument;
|
|
413
|
+
}
|
|
414
|
+
results.newDocument = document;
|
|
415
|
+
return results;
|
|
416
|
+
}
|
|
417
|
+
exports.applyPatch = applyPatch;
|
|
418
|
+
function applyReducer(document, operation, index) {
|
|
419
|
+
var operationResult = applyOperation(document, operation);
|
|
420
|
+
if (operationResult.test === false) {
|
|
421
|
+
throw new exports.JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
422
|
+
}
|
|
423
|
+
return operationResult.newDocument;
|
|
424
|
+
}
|
|
425
|
+
exports.applyReducer = applyReducer;
|
|
426
|
+
function validator(operation, index, document, existingPathFragment) {
|
|
427
|
+
if (typeof operation !== "object" || operation === null || Array.isArray(operation)) {
|
|
428
|
+
throw new exports.JsonPatchError("Operation is not an object", "OPERATION_NOT_AN_OBJECT", index, operation, document);
|
|
429
|
+
} else if (!objOps[operation.op]) {
|
|
430
|
+
throw new exports.JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
|
|
431
|
+
} else if (typeof operation.path !== "string") {
|
|
432
|
+
throw new exports.JsonPatchError("Operation `path` property is not a string", "OPERATION_PATH_INVALID", index, operation, document);
|
|
433
|
+
} else if (operation.path.indexOf("/") !== 0 && operation.path.length > 0) {
|
|
434
|
+
throw new exports.JsonPatchError('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", index, operation, document);
|
|
435
|
+
} else if ((operation.op === "move" || operation.op === "copy") && typeof operation.from !== "string") {
|
|
436
|
+
throw new exports.JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", index, operation, document);
|
|
437
|
+
} else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && operation.value === void 0) {
|
|
438
|
+
throw new exports.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", index, operation, document);
|
|
439
|
+
} else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && helpers_js_1.hasUndefined(operation.value)) {
|
|
440
|
+
throw new exports.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", index, operation, document);
|
|
441
|
+
} else if (document) {
|
|
442
|
+
if (operation.op == "add") {
|
|
615
443
|
var pathLen = operation.path.split("/").length;
|
|
616
444
|
var existingPathLen = existingPathFragment.split("/").length;
|
|
617
445
|
if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
|
|
618
|
-
|
|
446
|
+
throw new exports.JsonPatchError("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", index, operation, document);
|
|
619
447
|
}
|
|
620
|
-
|
|
621
|
-
else if (operation.op === 'replace' || operation.op === 'remove' || operation.op === '_get') {
|
|
448
|
+
} else if (operation.op === "replace" || operation.op === "remove" || operation.op === "_get") {
|
|
622
449
|
if (operation.path !== existingPathFragment) {
|
|
623
|
-
|
|
450
|
+
throw new exports.JsonPatchError("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
|
|
624
451
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
var existingValue = { op: "_get", path: operation.from, value: undefined };
|
|
452
|
+
} else if (operation.op === "move" || operation.op === "copy") {
|
|
453
|
+
var existingValue = { op: "_get", path: operation.from, value: void 0 };
|
|
628
454
|
var error = validate([existingValue], document);
|
|
629
|
-
if (error && error.name ===
|
|
630
|
-
|
|
455
|
+
if (error && error.name === "OPERATION_PATH_UNRESOLVABLE") {
|
|
456
|
+
throw new exports.JsonPatchError("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", index, operation, document);
|
|
631
457
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}
|
|
635
|
-
exports.validator = validator;
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
*/
|
|
643
|
-
function validate(sequence, document, externalValidator) {
|
|
644
|
-
try {
|
|
645
|
-
if (!Array.isArray(sequence)) {
|
|
646
|
-
throw new exports.JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');
|
|
647
|
-
}
|
|
648
|
-
if (document) {
|
|
649
|
-
//clone document and sequence so that we can safely try applying operations
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
exports.validator = validator;
|
|
462
|
+
function validate(sequence, document, externalValidator) {
|
|
463
|
+
try {
|
|
464
|
+
if (!Array.isArray(sequence)) {
|
|
465
|
+
throw new exports.JsonPatchError("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
466
|
+
}
|
|
467
|
+
if (document) {
|
|
650
468
|
applyPatch(helpers_js_1._deepClone(document), helpers_js_1._deepClone(sequence), externalValidator || true);
|
|
651
|
-
|
|
652
|
-
else {
|
|
469
|
+
} else {
|
|
653
470
|
externalValidator = externalValidator || validator;
|
|
654
471
|
for (var i = 0; i < sequence.length; i++) {
|
|
655
|
-
|
|
472
|
+
externalValidator(sequence[i], i, document, void 0);
|
|
656
473
|
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
if (e instanceof exports.JsonPatchError) {
|
|
474
|
+
}
|
|
475
|
+
} catch (e) {
|
|
476
|
+
if (e instanceof exports.JsonPatchError) {
|
|
661
477
|
return e;
|
|
662
|
-
|
|
663
|
-
else {
|
|
478
|
+
} else {
|
|
664
479
|
throw e;
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
}
|
|
668
|
-
exports.validate = validate;
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
676
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
677
|
-
// furnished to do so, subject to the following conditions:
|
|
678
|
-
// The above copyright notice and this permission notice shall be included in all
|
|
679
|
-
// copies or substantial portions of the Software.
|
|
680
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
681
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
682
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
683
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
684
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
685
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
686
|
-
// SOFTWARE.
|
|
687
|
-
function _areEquals(a, b) {
|
|
688
|
-
if (a === b)
|
|
689
|
-
return true;
|
|
690
|
-
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
|
691
|
-
var arrA = Array.isArray(a), arrB = Array.isArray(b), i, length, key;
|
|
692
|
-
if (arrA && arrB) {
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
exports.validate = validate;
|
|
484
|
+
function _areEquals(a, b) {
|
|
485
|
+
if (a === b)
|
|
486
|
+
return true;
|
|
487
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
488
|
+
var arrA = Array.isArray(a), arrB = Array.isArray(b), i, length, key;
|
|
489
|
+
if (arrA && arrB) {
|
|
693
490
|
length = a.length;
|
|
694
491
|
if (length != b.length)
|
|
492
|
+
return false;
|
|
493
|
+
for (i = length; i-- !== 0; )
|
|
494
|
+
if (!_areEquals(a[i], b[i]))
|
|
695
495
|
return false;
|
|
696
|
-
for (i = length; i-- !== 0;)
|
|
697
|
-
if (!_areEquals(a[i], b[i]))
|
|
698
|
-
return false;
|
|
699
496
|
return true;
|
|
700
|
-
|
|
701
|
-
|
|
497
|
+
}
|
|
498
|
+
if (arrA != arrB)
|
|
702
499
|
return false;
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
500
|
+
var keys = Object.keys(a);
|
|
501
|
+
length = keys.length;
|
|
502
|
+
if (length !== Object.keys(b).length)
|
|
706
503
|
return false;
|
|
707
|
-
|
|
504
|
+
for (i = length; i-- !== 0; )
|
|
708
505
|
if (!b.hasOwnProperty(keys[i]))
|
|
709
|
-
|
|
710
|
-
|
|
506
|
+
return false;
|
|
507
|
+
for (i = length; i-- !== 0; ) {
|
|
711
508
|
key = keys[i];
|
|
712
509
|
if (!_areEquals(a[key], b[key]))
|
|
713
|
-
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
return true;
|
|
714
513
|
}
|
|
715
|
-
return
|
|
514
|
+
return a !== a && b !== b;
|
|
515
|
+
}
|
|
516
|
+
exports._areEquals = _areEquals;
|
|
716
517
|
}
|
|
717
|
-
|
|
718
|
-
}
|
|
719
|
-
exports._areEquals = _areEquals;
|
|
720
|
-
;
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
/***/ }),
|
|
724
|
-
/* 2 */
|
|
725
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
726
|
-
|
|
727
|
-
var core = __webpack_require__(1);
|
|
728
|
-
Object.assign(exports, core);
|
|
518
|
+
});
|
|
729
519
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
/*
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
var
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
var observerInfo = getObserverFromMirror(mirror, callback);
|
|
796
|
-
observer = observerInfo && observerInfo.observer;
|
|
797
|
-
}
|
|
798
|
-
if (observer) {
|
|
799
|
-
return observer;
|
|
800
|
-
}
|
|
801
|
-
observer = {};
|
|
802
|
-
mirror.value = helpers_js_1._deepClone(obj);
|
|
803
|
-
if (callback) {
|
|
804
|
-
observer.callback = callback;
|
|
805
|
-
observer.next = null;
|
|
806
|
-
var dirtyCheck = function () {
|
|
520
|
+
// commonjs/duplex.js
|
|
521
|
+
var require_duplex = __commonJS({
|
|
522
|
+
"commonjs/duplex.js": function(exports) {
|
|
523
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
524
|
+
/*!
|
|
525
|
+
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
526
|
+
* (c) 2017-2021 Joachim Wester
|
|
527
|
+
* MIT license
|
|
528
|
+
*/
|
|
529
|
+
var helpers_js_1 = require_helpers();
|
|
530
|
+
var core_js_1 = require_core();
|
|
531
|
+
var beforeDict = /* @__PURE__ */ new WeakMap();
|
|
532
|
+
var Mirror = (
|
|
533
|
+
/** @class */
|
|
534
|
+
/* @__PURE__ */ (function() {
|
|
535
|
+
function Mirror2(obj) {
|
|
536
|
+
this.observers = /* @__PURE__ */ new Map();
|
|
537
|
+
this.obj = obj;
|
|
538
|
+
}
|
|
539
|
+
return Mirror2;
|
|
540
|
+
})()
|
|
541
|
+
);
|
|
542
|
+
var ObserverInfo = (
|
|
543
|
+
/** @class */
|
|
544
|
+
/* @__PURE__ */ (function() {
|
|
545
|
+
function ObserverInfo2(callback, observer) {
|
|
546
|
+
this.callback = callback;
|
|
547
|
+
this.observer = observer;
|
|
548
|
+
}
|
|
549
|
+
return ObserverInfo2;
|
|
550
|
+
})()
|
|
551
|
+
);
|
|
552
|
+
function getMirror(obj) {
|
|
553
|
+
return beforeDict.get(obj);
|
|
554
|
+
}
|
|
555
|
+
function getObserverFromMirror(mirror, callback) {
|
|
556
|
+
return mirror.observers.get(callback);
|
|
557
|
+
}
|
|
558
|
+
function removeObserverFromMirror(mirror, observer) {
|
|
559
|
+
mirror.observers.delete(observer.callback);
|
|
560
|
+
}
|
|
561
|
+
function unobserve(root, observer) {
|
|
562
|
+
observer.unobserve();
|
|
563
|
+
}
|
|
564
|
+
exports.unobserve = unobserve;
|
|
565
|
+
function observe(obj, callback) {
|
|
566
|
+
var patches = [];
|
|
567
|
+
var observer;
|
|
568
|
+
var mirror = getMirror(obj);
|
|
569
|
+
if (!mirror) {
|
|
570
|
+
mirror = new Mirror(obj);
|
|
571
|
+
beforeDict.set(obj, mirror);
|
|
572
|
+
} else {
|
|
573
|
+
var observerInfo = getObserverFromMirror(mirror, callback);
|
|
574
|
+
observer = observerInfo && observerInfo.observer;
|
|
575
|
+
}
|
|
576
|
+
if (observer) {
|
|
577
|
+
return observer;
|
|
578
|
+
}
|
|
579
|
+
observer = {};
|
|
580
|
+
mirror.value = helpers_js_1._deepClone(obj);
|
|
581
|
+
if (callback) {
|
|
582
|
+
observer.callback = callback;
|
|
583
|
+
observer.next = null;
|
|
584
|
+
var dirtyCheck = function() {
|
|
807
585
|
generate(observer);
|
|
808
|
-
|
|
809
|
-
|
|
586
|
+
};
|
|
587
|
+
var fastCheck = function() {
|
|
810
588
|
clearTimeout(observer.next);
|
|
811
589
|
observer.next = setTimeout(dirtyCheck);
|
|
590
|
+
};
|
|
591
|
+
if (typeof window !== "undefined") {
|
|
592
|
+
window.addEventListener("mouseup", fastCheck);
|
|
593
|
+
window.addEventListener("keyup", fastCheck);
|
|
594
|
+
window.addEventListener("mousedown", fastCheck);
|
|
595
|
+
window.addEventListener("keydown", fastCheck);
|
|
596
|
+
window.addEventListener("change", fastCheck);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
observer.patches = patches;
|
|
600
|
+
observer.object = obj;
|
|
601
|
+
observer.unobserve = function() {
|
|
602
|
+
generate(observer);
|
|
603
|
+
clearTimeout(observer.next);
|
|
604
|
+
removeObserverFromMirror(mirror, observer);
|
|
605
|
+
if (typeof window !== "undefined") {
|
|
606
|
+
window.removeEventListener("mouseup", fastCheck);
|
|
607
|
+
window.removeEventListener("keyup", fastCheck);
|
|
608
|
+
window.removeEventListener("mousedown", fastCheck);
|
|
609
|
+
window.removeEventListener("keydown", fastCheck);
|
|
610
|
+
window.removeEventListener("change", fastCheck);
|
|
611
|
+
}
|
|
812
612
|
};
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
if (
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
window.removeEventListener('mousedown', fastCheck);
|
|
831
|
-
window.removeEventListener('keydown', fastCheck);
|
|
832
|
-
window.removeEventListener('change', fastCheck);
|
|
833
|
-
}
|
|
834
|
-
};
|
|
835
|
-
mirror.observers.set(callback, new ObserverInfo(callback, observer));
|
|
836
|
-
return observer;
|
|
837
|
-
}
|
|
838
|
-
exports.observe = observe;
|
|
839
|
-
/**
|
|
840
|
-
* Generate an array of patches from an observer
|
|
841
|
-
*/
|
|
842
|
-
function generate(observer, invertible) {
|
|
843
|
-
if (invertible === void 0) { invertible = false; }
|
|
844
|
-
var mirror = beforeDict.get(observer.object);
|
|
845
|
-
_generate(mirror.value, observer.object, observer.patches, "", invertible);
|
|
846
|
-
if (observer.patches.length) {
|
|
847
|
-
core_js_1.applyPatch(mirror.value, observer.patches);
|
|
848
|
-
}
|
|
849
|
-
var temp = observer.patches;
|
|
850
|
-
if (temp.length > 0) {
|
|
851
|
-
observer.patches = [];
|
|
852
|
-
if (observer.callback) {
|
|
613
|
+
mirror.observers.set(callback, new ObserverInfo(callback, observer));
|
|
614
|
+
return observer;
|
|
615
|
+
}
|
|
616
|
+
exports.observe = observe;
|
|
617
|
+
function generate(observer, invertible) {
|
|
618
|
+
if (invertible === void 0) {
|
|
619
|
+
invertible = false;
|
|
620
|
+
}
|
|
621
|
+
var mirror = beforeDict.get(observer.object);
|
|
622
|
+
_generate(mirror.value, observer.object, observer.patches, "", invertible);
|
|
623
|
+
if (observer.patches.length) {
|
|
624
|
+
core_js_1.applyPatch(mirror.value, observer.patches);
|
|
625
|
+
}
|
|
626
|
+
var temp = observer.patches;
|
|
627
|
+
if (temp.length > 0) {
|
|
628
|
+
observer.patches = [];
|
|
629
|
+
if (observer.callback) {
|
|
853
630
|
observer.callback(temp);
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}
|
|
858
|
-
exports.generate = generate;
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
var oldVal = mirror[key];
|
|
875
|
-
if (helpers_js_1.hasOwnProperty(obj, key) && !(obj[key] === undefined && oldVal !== undefined && Array.isArray(obj) === false)) {
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return temp;
|
|
634
|
+
}
|
|
635
|
+
exports.generate = generate;
|
|
636
|
+
function _generate(mirror, obj, patches, path, invertible) {
|
|
637
|
+
if (obj === mirror) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
if (typeof obj.toJSON === "function") {
|
|
641
|
+
obj = obj.toJSON();
|
|
642
|
+
}
|
|
643
|
+
var newKeys = helpers_js_1._objectKeys(obj);
|
|
644
|
+
var oldKeys = helpers_js_1._objectKeys(mirror);
|
|
645
|
+
var changed = false;
|
|
646
|
+
var deleted = false;
|
|
647
|
+
for (var t = oldKeys.length - 1; t >= 0; t--) {
|
|
648
|
+
var key = oldKeys[t];
|
|
649
|
+
var oldVal = mirror[key];
|
|
650
|
+
if (helpers_js_1.hasOwnProperty(obj, key) && !(obj[key] === void 0 && oldVal !== void 0 && Array.isArray(obj) === false)) {
|
|
876
651
|
var newVal = obj[key];
|
|
877
652
|
if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) {
|
|
878
|
-
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
patches.push({ op: "test", path: path + "/" + helpers_js_1.escapePathComponent(key), value: helpers_js_1._deepClone(oldVal) });
|
|
885
|
-
}
|
|
886
|
-
patches.push({ op: "replace", path: path + "/" + helpers_js_1.escapePathComponent(key), value: helpers_js_1._deepClone(newVal) });
|
|
653
|
+
_generate(oldVal, newVal, patches, path + "/" + helpers_js_1.escapePathComponent(key), invertible);
|
|
654
|
+
} else {
|
|
655
|
+
if (oldVal !== newVal) {
|
|
656
|
+
changed = true;
|
|
657
|
+
if (invertible) {
|
|
658
|
+
patches.push({ op: "test", path: path + "/" + helpers_js_1.escapePathComponent(key), value: helpers_js_1._deepClone(oldVal) });
|
|
887
659
|
}
|
|
660
|
+
patches.push({ op: "replace", path: path + "/" + helpers_js_1.escapePathComponent(key), value: helpers_js_1._deepClone(newVal) });
|
|
661
|
+
}
|
|
888
662
|
}
|
|
889
|
-
|
|
890
|
-
else if (Array.isArray(mirror) === Array.isArray(obj)) {
|
|
663
|
+
} else if (Array.isArray(mirror) === Array.isArray(obj)) {
|
|
891
664
|
if (invertible) {
|
|
892
|
-
|
|
665
|
+
patches.push({ op: "test", path: path + "/" + helpers_js_1.escapePathComponent(key), value: helpers_js_1._deepClone(oldVal) });
|
|
893
666
|
}
|
|
894
667
|
patches.push({ op: "remove", path: path + "/" + helpers_js_1.escapePathComponent(key) });
|
|
895
|
-
deleted = true;
|
|
896
|
-
|
|
897
|
-
else {
|
|
668
|
+
deleted = true;
|
|
669
|
+
} else {
|
|
898
670
|
if (invertible) {
|
|
899
|
-
|
|
671
|
+
patches.push({ op: "test", path: path, value: mirror });
|
|
900
672
|
}
|
|
901
673
|
patches.push({ op: "replace", path: path, value: obj });
|
|
902
674
|
changed = true;
|
|
675
|
+
}
|
|
903
676
|
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
if (!helpers_js_1.hasOwnProperty(mirror, key) && obj[key] !== undefined) {
|
|
677
|
+
if (!deleted && newKeys.length == oldKeys.length) {
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
for (var t = 0; t < newKeys.length; t++) {
|
|
681
|
+
var key = newKeys[t];
|
|
682
|
+
if (!helpers_js_1.hasOwnProperty(mirror, key) && obj[key] !== void 0) {
|
|
911
683
|
patches.push({ op: "add", path: path + "/" + helpers_js_1.escapePathComponent(key), value: helpers_js_1._deepClone(obj[key]) });
|
|
684
|
+
}
|
|
912
685
|
}
|
|
686
|
+
}
|
|
687
|
+
function compare(tree1, tree2, invertible) {
|
|
688
|
+
if (invertible === void 0) {
|
|
689
|
+
invertible = false;
|
|
690
|
+
}
|
|
691
|
+
var patches = [];
|
|
692
|
+
_generate(tree1, tree2, patches, "", invertible);
|
|
693
|
+
return patches;
|
|
694
|
+
}
|
|
695
|
+
exports.compare = compare;
|
|
913
696
|
}
|
|
914
|
-
}
|
|
915
|
-
/**
|
|
916
|
-
* Create an array of patches from the differences in two objects
|
|
917
|
-
*/
|
|
918
|
-
function compare(tree1, tree2, invertible) {
|
|
919
|
-
if (invertible === void 0) { invertible = false; }
|
|
920
|
-
var patches = [];
|
|
921
|
-
_generate(tree1, tree2, patches, '', invertible);
|
|
922
|
-
return patches;
|
|
923
|
-
}
|
|
924
|
-
exports.compare = compare;
|
|
925
|
-
|
|
697
|
+
});
|
|
926
698
|
|
|
927
|
-
|
|
928
|
-
|
|
699
|
+
// index.js
|
|
700
|
+
var require_index = __commonJS({
|
|
701
|
+
"index.js": function(exports) {
|
|
702
|
+
var core = require_core();
|
|
703
|
+
Object.assign(exports, core);
|
|
704
|
+
var duplex = require_duplex();
|
|
705
|
+
Object.assign(exports, duplex);
|
|
706
|
+
var helpers = require_helpers();
|
|
707
|
+
exports.JsonPatchError = helpers.PatchError;
|
|
708
|
+
exports.deepClone = helpers._deepClone;
|
|
709
|
+
exports.escapePathComponent = helpers.escapePathComponent;
|
|
710
|
+
exports.unescapePathComponent = helpers.unescapePathComponent;
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
return require_index();
|
|
714
|
+
})();
|