@fluid-experimental/property-changeset 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.1
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/README.md +1 -0
- package/dist/changeset.d.ts +2 -2
- package/dist/changeset.d.ts.map +1 -1
- package/dist/changeset.js +61 -45
- package/dist/changeset.js.map +1 -1
- package/dist/changeset_operations/array.d.ts +6 -6
- package/dist/changeset_operations/array.d.ts.map +1 -1
- package/dist/changeset_operations/array.js +87 -56
- package/dist/changeset_operations/array.js.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.d.ts.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.js +43 -41
- package/dist/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.d.ts.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/dist/changeset_operations/indexedCollection.d.ts.map +1 -1
- package/dist/changeset_operations/indexedCollection.js +76 -44
- package/dist/changeset_operations/indexedCollection.js.map +1 -1
- package/dist/changeset_operations/isEmptyChangeset.d.ts.map +1 -1
- package/dist/changeset_operations/isEmptyChangeset.js +2 -1
- package/dist/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/dist/changeset_operations/operationTypes.d.ts.map +1 -1
- package/dist/changeset_operations/operationTypes.js.map +1 -1
- package/dist/helpers/typeidHelper.d.ts +10 -10
- package/dist/helpers/typeidHelper.d.ts.map +1 -1
- package/dist/helpers/typeidHelper.js +19 -17
- package/dist/helpers/typeidHelper.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/isReservedKeyword.d.ts.map +1 -1
- package/dist/isReservedKeyword.js.map +1 -1
- package/dist/pathHelper.d.ts.map +1 -1
- package/dist/pathHelper.js +16 -10
- package/dist/pathHelper.js.map +1 -1
- package/dist/rebase.d.ts.map +1 -1
- package/dist/rebase.js +20 -13
- package/dist/rebase.js.map +1 -1
- package/dist/templateSchema.d.ts.map +1 -1
- package/dist/templateSchema.js +10 -11
- package/dist/templateSchema.js.map +1 -1
- package/dist/templateValidator.d.ts.map +1 -1
- package/dist/templateValidator.js +135 -102
- package/dist/templateValidator.js.map +1 -1
- package/dist/test/array.spec.js +141 -343
- package/dist/test/array.spec.js.map +1 -1
- package/dist/test/pathHelper.spec.js +299 -166
- package/dist/test/pathHelper.spec.js.map +1 -1
- package/dist/test/reversibleCs.spec.js.map +1 -1
- package/dist/test/schemaValidator.js +3 -1
- package/dist/test/schemaValidator.js.map +1 -1
- package/dist/test/schemas/badBothPropertiesAndTypeid.js +8 -8
- package/dist/test/schemas/badBothPropertiesAndTypeid.js.map +1 -1
- package/dist/test/schemas/badInvalidSemverInTypeid.js +18 -16
- package/dist/test/schemas/badInvalidSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badMissingSemverInTypeid.js +18 -16
- package/dist/test/schemas/badMissingSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badNestedProperties.js +18 -17
- package/dist/test/schemas/badNestedProperties.js.map +1 -1
- package/dist/test/schemas/badPrimitiveTypeid.js +9 -8
- package/dist/test/schemas/badPrimitiveTypeid.js.map +1 -1
- package/dist/test/schemas/badVersionedTypeid.js +19 -17
- package/dist/test/schemas/badVersionedTypeid.js.map +1 -1
- package/dist/test/schemas/goodColorPalette.js +4 -4
- package/dist/test/schemas/goodColorPalette.js.map +1 -1
- package/dist/test/schemas/goodDraftAsVersion.js +2 -4
- package/dist/test/schemas/goodDraftAsVersion.js.map +1 -1
- package/dist/test/schemas/goodPointId.js +18 -16
- package/dist/test/schemas/goodPointId.js.map +1 -1
- package/dist/test/schemas/goodReferenceAndRegular.js +5 -5
- package/dist/test/schemas/goodReferenceAndRegular.js.map +1 -1
- package/dist/test/schemas/goodReservedTypes.js +8 -7
- package/dist/test/schemas/goodReservedTypes.js.map +1 -1
- package/dist/test/schemas/goodUIBorder.js +19 -16
- package/dist/test/schemas/goodUIBorder.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -1
- package/dist/test/validator/templateSyntax.spec.js.map +1 -1
- package/dist/test/validator/templateValidator.spec.js +329 -306
- package/dist/test/validator/templateValidator.spec.js.map +1 -1
- package/dist/test/validator/typeidHelper.spec.js +98 -65
- package/dist/test/validator/typeidHelper.spec.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +149 -95
- package/dist/utils.js.map +1 -1
- package/dist/validationResultBuilder.d.ts.map +1 -1
- package/dist/validationResultBuilder.js.map +1 -1
- package/lib/changeset.js +63 -47
- package/lib/changeset.js.map +1 -1
- package/lib/changeset_operations/array.js +88 -57
- package/lib/changeset_operations/array.js.map +1 -1
- package/lib/changeset_operations/arrayChangesetIterator.js +43 -41
- package/lib/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/lib/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/lib/changeset_operations/indexedCollection.js +76 -44
- package/lib/changeset_operations/indexedCollection.js.map +1 -1
- package/lib/changeset_operations/isEmptyChangeset.js +2 -1
- package/lib/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/lib/changeset_operations/operationTypes.js.map +1 -1
- package/lib/helpers/typeidHelper.js +19 -17
- package/lib/helpers/typeidHelper.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/isReservedKeyword.js.map +1 -1
- package/lib/pathHelper.js +17 -11
- package/lib/pathHelper.js.map +1 -1
- package/lib/rebase.js +20 -13
- package/lib/rebase.js.map +1 -1
- package/lib/templateSchema.js +10 -11
- package/lib/templateSchema.js.map +1 -1
- package/lib/templateValidator.js +135 -102
- package/lib/templateValidator.js.map +1 -1
- package/lib/utils.js +149 -95
- package/lib/utils.js.map +1 -1
- package/lib/validationResultBuilder.js.map +1 -1
- package/package.json +100 -100
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationResultBuilder.d.ts","sourceRoot":"","sources":["../src/validationResultBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AAEH,MAAM,CAAC,OAAO,WAAW,sBAAsB;
|
|
1
|
+
{"version":3,"file":"validationResultBuilder.d.ts","sourceRoot":"","sources":["../src/validationResultBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AAEH,MAAM,CAAC,OAAO,WAAW,sBAAsB;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,uBAAuB;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IAEjD;;;OAGG;gBACS,SAAS,EAAE,MAAM;IAc7B;;;OAGG;IACH,IAAW,MAAM,2BAEhB;IAED;;;OAGG;IACI,QAAQ,CAAC,QAAQ,EAAE,KAAK;IAQ/B;;;OAGG;IACI,UAAU,CAAC,MAAM,EAAE,MAAM;IAIhC;;;OAGG;IACI,OAAO,IAAI,OAAO;CAGzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationResultBuilder.js","sourceRoot":"","sources":["../src/validationResultBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgBH,MAAa,uBAAuB;
|
|
1
|
+
{"version":3,"file":"validationResultBuilder.js","sourceRoot":"","sources":["../src/validationResultBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgBH,MAAa,uBAAuB;IAGnC;;;OAGG;IACH,YAAY,SAAiB;QAC5B,IAAI,CAAC,OAAO,GAAG;YACd,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,EAAE;YACZ,aAAa,EAAE,EAAE;YACjB,eAAe,EAAE,EAAE;SACnB,CAAC;QAEF,IAAI,SAAS,EAAE;YACd,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;SAChC;IACF,CAAC;IAED;;;OAGG;IACH,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,QAAQ,CAAC,QAAe;QAC9B,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QAC7B,8CAA8C;QAC9C,IAAI,QAAQ,CAAC,OAAO,EAAE;YACrB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACnC;IACF,CAAC;IAED;;;OAGG;IACI,UAAU,CAAC,MAAc;QAC/B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,OAAO;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC7B,CAAC;CACD;AAxDD,0DAwDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @fileoverview The ValidationResultBuilder maintains validation context that ultimately gets returned as a\n * single result.\n */\n\nexport declare interface SchemaValidationResult {\n\tisValid: boolean;\n\terrors: Error[];\n\twarnings: string[];\n\tresolvedTypes: string[];\n\tunresolvedTypes: string[];\n\ttypeid?: string;\n}\n\nexport class ValidationResultBuilder {\n\tprivate readonly _result: SchemaValidationResult;\n\n\t/**\n\t * Instantiates a ValidationResultBuilder\n\t * @param in_typeid - A template typeid.\n\t */\n\tconstructor(in_typeid: string) {\n\t\tthis._result = {\n\t\t\tisValid: true,\n\t\t\terrors: [],\n\t\t\twarnings: [],\n\t\t\tresolvedTypes: [],\n\t\t\tunresolvedTypes: [],\n\t\t};\n\n\t\tif (in_typeid) {\n\t\t\tthis._result.typeid = in_typeid;\n\t\t}\n\t}\n\n\t/**\n\t * Add a validation error.\n\t * @param {Error} in_error - An Error instance.\n\t */\n\tpublic get result() {\n\t\treturn this._result;\n\t}\n\n\t/**\n\t * Add a validation error.\n\t * @param in_error - An Error instance.\n\t */\n\tpublic addError(in_error: Error) {\n\t\tthis._result.isValid = false;\n\t\t// remove empty error messages before logging.\n\t\tif (in_error.message) {\n\t\t\tthis._result.errors.push(in_error);\n\t\t}\n\t}\n\n\t/**\n\t * Add a validation warning.\n\t * @param in_msg - A warning description.\n\t */\n\tpublic addWarning(in_msg: string) {\n\t\tthis._result.warnings.push(in_msg);\n\t}\n\n\t/**\n\t * Fetches the boolean validation result.\n\t * @returns True if validation produced no error, false otherwise. Warnings don't affect this value.\n\t */\n\tpublic isValid(): boolean {\n\t\treturn this._result.isValid;\n\t}\n}\n"]}
|
package/lib/changeset.js
CHANGED
|
@@ -14,9 +14,9 @@ import each from "lodash/each";
|
|
|
14
14
|
// @ts-ignore
|
|
15
15
|
import { ConsoleUtils, joinPaths, constants } from "@fluid-experimental/property-common";
|
|
16
16
|
import { TypeIdHelper } from "./helpers/typeidHelper";
|
|
17
|
-
import { ChangeSetArrayFunctions } from
|
|
17
|
+
import { ChangeSetArrayFunctions } from "./changeset_operations/array";
|
|
18
18
|
import { ArrayChangeSetIterator } from "./changeset_operations/arrayChangesetIterator";
|
|
19
|
-
import { ConflictType } from
|
|
19
|
+
import { ConflictType } from "./changeset_operations/changesetConflictTypes";
|
|
20
20
|
// Add the indexed collection functions into the prototype of the ChangeSet
|
|
21
21
|
import { ChangeSetIndexedCollectionFunctions } from "./changeset_operations/indexedCollection";
|
|
22
22
|
import { isEmptyChangeSet } from "./changeset_operations/isEmptyChangeset";
|
|
@@ -40,7 +40,8 @@ export class ChangeSet {
|
|
|
40
40
|
if (in_changes === undefined || in_changes === null) {
|
|
41
41
|
this._changes = {};
|
|
42
42
|
}
|
|
43
|
-
else if (isString(in_changes)) {
|
|
43
|
+
else if (isString(in_changes)) {
|
|
44
|
+
// Stringified Serialized JSON
|
|
44
45
|
this._changes = JSON.parse(in_changes);
|
|
45
46
|
}
|
|
46
47
|
else if (in_changes instanceof ChangeSet) {
|
|
@@ -108,7 +109,9 @@ export class ChangeSet {
|
|
|
108
109
|
changes = in_changeSet.getSerializedChangeSet();
|
|
109
110
|
}
|
|
110
111
|
if (!isObject(this._changes) || Array.isArray(this._changes)) {
|
|
111
|
-
const oldValue = isObject(changes) && changes.value !== undefined
|
|
112
|
+
const oldValue = isObject(changes) && changes.value !== undefined
|
|
113
|
+
? changes.value
|
|
114
|
+
: changes;
|
|
112
115
|
this._changes = Array.isArray(oldValue) ? oldValue.slice() : oldValue;
|
|
113
116
|
}
|
|
114
117
|
else {
|
|
@@ -166,14 +169,16 @@ export class ChangeSet {
|
|
|
166
169
|
* @param in_appliedValue - applied changes to be applied
|
|
167
170
|
*/
|
|
168
171
|
_applyValue(io_baseChanges, in_baseKey, in_appliedValue) {
|
|
169
|
-
const newValue =
|
|
170
|
-
in_appliedValue.value
|
|
172
|
+
const newValue = in_appliedValue && in_appliedValue.hasOwnProperty("value")
|
|
173
|
+
? in_appliedValue.value
|
|
174
|
+
: in_appliedValue;
|
|
171
175
|
if (io_baseChanges[in_baseKey] && io_baseChanges[in_baseKey].hasOwnProperty("value")) {
|
|
172
176
|
io_baseChanges[in_baseKey].value = newValue;
|
|
173
177
|
}
|
|
174
178
|
else {
|
|
175
179
|
if (io_baseChanges[in_baseKey] === undefined &&
|
|
176
|
-
in_appliedValue &&
|
|
180
|
+
in_appliedValue &&
|
|
181
|
+
in_appliedValue.hasOwnProperty("oldValue")) {
|
|
177
182
|
io_baseChanges[in_baseKey] = {
|
|
178
183
|
value: newValue,
|
|
179
184
|
oldValue: in_appliedValue.oldValue,
|
|
@@ -198,8 +203,7 @@ export class ChangeSet {
|
|
|
198
203
|
*/
|
|
199
204
|
performApplyAfterOnPropertyWithTypeid(in_changedKey, in_baseChanges, in_appliedPropertyChanges, in_typeid, in_removeEmpty, in_options) {
|
|
200
205
|
const splitTypeid = extractContext(in_typeid);
|
|
201
|
-
if (splitTypeid.context === "set" ||
|
|
202
|
-
splitTypeid.context === "map") {
|
|
206
|
+
if (splitTypeid.context === "set" || splitTypeid.context === "map") {
|
|
203
207
|
in_baseChanges[in_changedKey] = in_baseChanges[in_changedKey] || {};
|
|
204
208
|
this._performApplyAfterOnPropertyIndexedCollection(in_baseChanges[in_changedKey], in_appliedPropertyChanges[in_changedKey], splitTypeid.typeid, in_options);
|
|
205
209
|
// Remove the key, when it no longer contains a changeset
|
|
@@ -208,27 +212,26 @@ export class ChangeSet {
|
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
214
|
else if (splitTypeid.context === "array" || splitTypeid.typeid === "String") {
|
|
211
|
-
in_baseChanges[in_changedKey] =
|
|
215
|
+
in_baseChanges[in_changedKey] =
|
|
216
|
+
in_baseChanges[in_changedKey] !== undefined ? in_baseChanges[in_changedKey] : {};
|
|
212
217
|
let baseIsSetChange = false;
|
|
213
218
|
let oldValue;
|
|
214
219
|
if (splitTypeid.typeid === "String" &&
|
|
215
220
|
(isString(in_baseChanges[in_changedKey]) ||
|
|
216
|
-
(in_baseChanges[in_changedKey] &&
|
|
221
|
+
(in_baseChanges[in_changedKey] &&
|
|
222
|
+
in_baseChanges[in_changedKey].hasOwnProperty("value")))) {
|
|
217
223
|
oldValue = in_baseChanges[in_changedKey].oldValue;
|
|
218
224
|
// we need to convert the format to allow the application of the changes
|
|
219
225
|
// since _performApplyAfterOnPropertyArray only understands insert/modify/remove commands
|
|
220
|
-
if (in_baseChanges[in_changedKey] &&
|
|
226
|
+
if (in_baseChanges[in_changedKey] &&
|
|
227
|
+
in_baseChanges[in_changedKey].hasOwnProperty("value")) {
|
|
221
228
|
in_baseChanges[in_changedKey] = {
|
|
222
|
-
insert: [
|
|
223
|
-
[0, in_baseChanges[in_changedKey].value],
|
|
224
|
-
],
|
|
229
|
+
insert: [[0, in_baseChanges[in_changedKey].value]],
|
|
225
230
|
};
|
|
226
231
|
}
|
|
227
232
|
else {
|
|
228
233
|
in_baseChanges[in_changedKey] = {
|
|
229
|
-
insert: [
|
|
230
|
-
[0, in_baseChanges[in_changedKey]],
|
|
231
|
-
],
|
|
234
|
+
insert: [[0, in_baseChanges[in_changedKey]]],
|
|
232
235
|
};
|
|
233
236
|
}
|
|
234
237
|
baseIsSetChange = true;
|
|
@@ -392,14 +395,16 @@ export class ChangeSet {
|
|
|
392
395
|
if (typeid === "modify" && "modify" in io_rebasePropertyChangeSet) {
|
|
393
396
|
for (let j = 0; j < paths.length; j++) {
|
|
394
397
|
const tempTypeid = paths[i];
|
|
395
|
-
if (
|
|
398
|
+
if (isPrimitiveType(tempTypeid) &&
|
|
396
399
|
tempTypeid in io_rebasePropertyChangeSet.modify) {
|
|
397
400
|
const tempPaths = Object.keys(in_ownPropertyChangeSet.modify[tempTypeid]);
|
|
398
401
|
for (let z = 0; z < tempPaths.length; z++) {
|
|
399
402
|
if (tempPaths[z] in io_rebasePropertyChangeSet.modify[tempTypeid]) {
|
|
400
403
|
let rebasedPropContent = io_rebasePropertyChangeSet.modify[tempTypeid][tempPaths[z]];
|
|
401
|
-
if (isObject(rebasedPropContent) &&
|
|
402
|
-
|
|
404
|
+
if (isObject(rebasedPropContent) &&
|
|
405
|
+
"oldValue" in rebasedPropContent) {
|
|
406
|
+
rebasedPropContent.oldValue =
|
|
407
|
+
in_ownPropertyChangeSet.modify[tempTypeid][tempPaths[z]].value;
|
|
403
408
|
}
|
|
404
409
|
}
|
|
405
410
|
}
|
|
@@ -411,13 +416,15 @@ export class ChangeSet {
|
|
|
411
416
|
// io_rebasePropertyChangeSet && in_ownPropertyChangeSet contain only property type, name and value, we update
|
|
412
417
|
// oldValue of io_rebasePropertyChangeSet.
|
|
413
418
|
for (let j = 0; j < paths.length; j++) {
|
|
414
|
-
if (typeid in io_rebasePropertyChangeSet &&
|
|
419
|
+
if (typeid in io_rebasePropertyChangeSet &&
|
|
420
|
+
paths[j] in io_rebasePropertyChangeSet[typeid]) {
|
|
415
421
|
let rebasedPropContent = io_rebasePropertyChangeSet[typeid][paths[j]];
|
|
416
422
|
if (isObject(rebasedPropContent) && "oldValue" in rebasedPropContent) {
|
|
417
423
|
// if oldValue already be update above, we don't need to update
|
|
418
424
|
if (io_rebasePropertyChangeSet[typeid][paths[j]].oldValue !==
|
|
419
425
|
in_ownPropertyChangeSet[typeid][paths[j]].value) {
|
|
420
|
-
io_rebasePropertyChangeSet[typeid][paths[j]].oldValue =
|
|
426
|
+
io_rebasePropertyChangeSet[typeid][paths[j]].oldValue =
|
|
427
|
+
in_ownPropertyChangeSet[typeid][paths[j]].value;
|
|
421
428
|
}
|
|
422
429
|
}
|
|
423
430
|
}
|
|
@@ -425,8 +432,7 @@ export class ChangeSet {
|
|
|
425
432
|
}
|
|
426
433
|
// The reserved keywords have already been handled above and changes which are not present in
|
|
427
434
|
// the other ChangeSet can be ignored
|
|
428
|
-
if (ChangeSet.isReservedKeyword(typeid) ||
|
|
429
|
-
!io_rebasePropertyChangeSet[typeid]) {
|
|
435
|
+
if (ChangeSet.isReservedKeyword(typeid) || !io_rebasePropertyChangeSet[typeid]) {
|
|
430
436
|
continue;
|
|
431
437
|
}
|
|
432
438
|
// Check, whether we have a collision in a path update
|
|
@@ -483,8 +489,7 @@ export class ChangeSet {
|
|
|
483
489
|
*/
|
|
484
490
|
rebaseChangeSetForPropertyEntryWithTypeid(in_key, in_ownPropertyChangeSet, io_rebasePropertyChangeSet, in_typeid, in_basePath, in_removeEmpty, out_conflicts, in_options) {
|
|
485
491
|
const splitTypeid = extractContext(in_typeid);
|
|
486
|
-
if (splitTypeid.context === "set" ||
|
|
487
|
-
splitTypeid.context === "map") {
|
|
492
|
+
if (splitTypeid.context === "set" || splitTypeid.context === "map") {
|
|
488
493
|
this._rebaseIndexedCollectionChangeSetForProperty(in_ownPropertyChangeSet[in_key], io_rebasePropertyChangeSet[in_key], in_basePath, splitTypeid.typeid, true, // use square brackets
|
|
489
494
|
out_conflicts, in_options);
|
|
490
495
|
// Remove the key, when it no longer contains a changeset
|
|
@@ -640,14 +645,13 @@ export class ChangeSet {
|
|
|
640
645
|
}
|
|
641
646
|
else if (splitType.context === "map" ||
|
|
642
647
|
// node property test: (we have to do the test this way, because of inheritance)
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
648
|
+
nestedChangeset.insert ||
|
|
649
|
+
nestedChangeset.modify ||
|
|
650
|
+
nestedChangeset.remove) {
|
|
646
651
|
// This prevents an error, if the changeset only contains an insert operation. In that case
|
|
647
652
|
// we don't actually need the corresponding old state and thus do not need to throw an error
|
|
648
653
|
// This type of situation can occur in the materialized history, if an insert happens right at a chunk boundary.
|
|
649
|
-
if (Object.keys(nestedChangeset).length === 1 &&
|
|
650
|
-
nestedChangeset.insert) {
|
|
654
|
+
if (Object.keys(nestedChangeset).length === 1 && nestedChangeset.insert) {
|
|
651
655
|
in_context._traversalStopped = true;
|
|
652
656
|
return;
|
|
653
657
|
}
|
|
@@ -700,7 +704,8 @@ export class ChangeSet {
|
|
|
700
704
|
if (!newRemove[oldTypeKeys[k]]) {
|
|
701
705
|
newRemove[oldTypeKeys[k]] = {};
|
|
702
706
|
}
|
|
703
|
-
newRemove[oldTypeKeys[k]][removedKeys[i]] =
|
|
707
|
+
newRemove[oldTypeKeys[k]][removedKeys[i]] =
|
|
708
|
+
cloneDeep(entry);
|
|
704
709
|
}
|
|
705
710
|
}
|
|
706
711
|
}
|
|
@@ -736,13 +741,16 @@ export class ChangeSet {
|
|
|
736
741
|
if (!isObject(in_oldSerializedState) || Array.isArray(in_oldSerializedState)) {
|
|
737
742
|
if (!isObject(this._changes) || Array.isArray(this._changes)) {
|
|
738
743
|
this._changes = {
|
|
739
|
-
oldValue: Array.isArray(in_oldSerializedState)
|
|
744
|
+
oldValue: Array.isArray(in_oldSerializedState)
|
|
745
|
+
? in_oldSerializedState.slice()
|
|
746
|
+
: in_oldSerializedState,
|
|
740
747
|
value: this._changes,
|
|
741
748
|
};
|
|
742
749
|
}
|
|
743
750
|
else {
|
|
744
|
-
this._changes.oldValue = Array.isArray(in_oldSerializedState)
|
|
745
|
-
in_oldSerializedState
|
|
751
|
+
this._changes.oldValue = Array.isArray(in_oldSerializedState)
|
|
752
|
+
? in_oldSerializedState.slice()
|
|
753
|
+
: in_oldSerializedState;
|
|
746
754
|
}
|
|
747
755
|
}
|
|
748
756
|
else {
|
|
@@ -819,7 +827,8 @@ export class ChangeSet {
|
|
|
819
827
|
// TODO: Remove in_withoutRoot when it will not be used anymore
|
|
820
828
|
}
|
|
821
829
|
else if (splitType.context === "map" ||
|
|
822
|
-
(!in_withoutRoot && splitType.context === "single")) {
|
|
830
|
+
(!in_withoutRoot && splitType.context === "single")) {
|
|
831
|
+
// For NodeProperty / inserts at the root
|
|
823
832
|
let nestedChangeset = in_context.getNestedChangeSet();
|
|
824
833
|
if (isPrimitiveType(splitType.typeid)) {
|
|
825
834
|
if (nestedChangeset.modify) {
|
|
@@ -921,7 +930,8 @@ export class ChangeSet {
|
|
|
921
930
|
(type === "String" && isString(nestedChangeset.oldValue))) {
|
|
922
931
|
// check if we were called with an irreversible changeset
|
|
923
932
|
if (in_context.getOperationType() === "modify" &&
|
|
924
|
-
(!isObject(nestedChangeset) ||
|
|
933
|
+
(!isObject(nestedChangeset) ||
|
|
934
|
+
typeof nestedChangeset.oldValue === "undefined")) {
|
|
925
935
|
throw new Error(MSG.OLD_VALUE_NOT_FOUND);
|
|
926
936
|
}
|
|
927
937
|
// switch oldValue and value
|
|
@@ -929,7 +939,8 @@ export class ChangeSet {
|
|
|
929
939
|
nestedChangeset.oldValue = nestedChangeset.value;
|
|
930
940
|
nestedChangeset.value = tmp;
|
|
931
941
|
}
|
|
932
|
-
else if ((type === "String" && !isString(nestedChangeset.oldValue)) ||
|
|
942
|
+
else if ((type === "String" && !isString(nestedChangeset.oldValue)) ||
|
|
943
|
+
splitType.context === "array") {
|
|
933
944
|
// String and Arrays need special treatment:
|
|
934
945
|
const arrayIterator = new ArrayChangeSetIterator(nestedChangeset);
|
|
935
946
|
const resultChangeset = {};
|
|
@@ -948,14 +959,16 @@ export class ChangeSet {
|
|
|
948
959
|
case ArrayIteratorOperationTypes.INSERT:
|
|
949
960
|
// Handle inserts
|
|
950
961
|
resultChangeset.remove.push([
|
|
951
|
-
arrayIterator.opDescription.operation[0] +
|
|
962
|
+
arrayIterator.opDescription.operation[0] +
|
|
963
|
+
arrayIterator.opDescription.offset,
|
|
952
964
|
arrayIterator.opDescription.operation[1],
|
|
953
965
|
]);
|
|
954
966
|
break;
|
|
955
967
|
case ArrayIteratorOperationTypes.REMOVE:
|
|
956
968
|
// Handle removes
|
|
957
969
|
resultChangeset.insert.push([
|
|
958
|
-
arrayIterator.opDescription.operation[0] +
|
|
970
|
+
arrayIterator.opDescription.operation[0] +
|
|
971
|
+
arrayIterator.opDescription.offset,
|
|
959
972
|
arrayIterator.opDescription.operation[1],
|
|
960
973
|
]);
|
|
961
974
|
break;
|
|
@@ -963,14 +976,16 @@ export class ChangeSet {
|
|
|
963
976
|
// Handle modifies
|
|
964
977
|
if (isPrimitiveType(splitType.typeid)) {
|
|
965
978
|
resultChangeset.modify.push([
|
|
966
|
-
arrayIterator.opDescription.operation[0] +
|
|
979
|
+
arrayIterator.opDescription.operation[0] +
|
|
980
|
+
arrayIterator.opDescription.offset,
|
|
967
981
|
arrayIterator.opDescription.operation[2],
|
|
968
982
|
arrayIterator.opDescription.operation[1],
|
|
969
983
|
]);
|
|
970
984
|
}
|
|
971
985
|
else {
|
|
972
986
|
resultChangeset.modify.push([
|
|
973
|
-
arrayIterator.opDescription.operation[0] +
|
|
987
|
+
arrayIterator.opDescription.operation[0] +
|
|
988
|
+
arrayIterator.opDescription.offset,
|
|
974
989
|
arrayIterator.opDescription.operation[1],
|
|
975
990
|
]);
|
|
976
991
|
}
|
|
@@ -1033,8 +1048,7 @@ export class ChangeSet {
|
|
|
1033
1048
|
* in a later release
|
|
1034
1049
|
*/
|
|
1035
1050
|
toInverseChangeSet() {
|
|
1036
|
-
if (this._changes.value !== undefined &&
|
|
1037
|
-
this._changes.oldValue !== undefined) {
|
|
1051
|
+
if (this._changes.value !== undefined && this._changes.oldValue !== undefined) {
|
|
1038
1052
|
const tmp = this._changes.value;
|
|
1039
1053
|
this._changes.value = this._changes.oldValue;
|
|
1040
1054
|
this._changes.oldValue = tmp;
|
|
@@ -1049,8 +1063,10 @@ export class ChangeSet {
|
|
|
1049
1063
|
ChangeSet.ConflictType = ConflictType;
|
|
1050
1064
|
ChangeSet.isEmptyChangeSet = isEmptyChangeSet;
|
|
1051
1065
|
ChangeSet.isReservedKeyword = isReservedKeyword;
|
|
1052
|
-
ChangeSet.prototype._performApplyAfterOnPropertyArray =
|
|
1053
|
-
|
|
1066
|
+
ChangeSet.prototype._performApplyAfterOnPropertyArray =
|
|
1067
|
+
ChangeSetArrayFunctions._performApplyAfterOnPropertyArray;
|
|
1068
|
+
ChangeSet.prototype._rebaseArrayChangeSetForProperty =
|
|
1069
|
+
ChangeSetArrayFunctions._rebaseArrayChangeSetForProperty;
|
|
1054
1070
|
ChangeSet.prototype._rebaseChangeSetForString = ChangeSetArrayFunctions._rebaseChangeSetForString;
|
|
1055
1071
|
// Add the indexed collection functions into the prototype of the ChangeSet
|
|
1056
1072
|
ChangeSet.prototype._performApplyAfterOnPropertyIndexedCollection =
|