@fluid-experimental/property-changeset 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.3.1.0.125672
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 +0 -5
- package/dist/templateValidator.d.ts.map +1 -1
- package/dist/templateValidator.js +140 -108
- package/dist/templateValidator.js.map +1 -1
- package/dist/test/array.spec.js +142 -345
- 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 +330 -309
- package/dist/test/validator/templateValidator.spec.js.map +1 -1
- package/dist/test/validator/typeidHelper.spec.js +99 -69
- 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 -103
- 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 +8 -8
package/README.md
CHANGED
package/dist/changeset.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @fileoverview Serialized representation of the changes in a repository
|
|
7
7
|
*/
|
|
8
|
-
import { ChangeSetArrayFunctions } from
|
|
9
|
-
import { ConflictType } from
|
|
8
|
+
import { ChangeSetArrayFunctions } from "./changeset_operations/array";
|
|
9
|
+
import { ConflictType } from "./changeset_operations/changesetConflictTypes";
|
|
10
10
|
import { ChangeSetIndexedCollectionFunctions } from "./changeset_operations/indexedCollection";
|
|
11
11
|
export interface ApplyChangeSetOptions {
|
|
12
12
|
/**
|
package/dist/changeset.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeset.d.ts","sourceRoot":"","sources":["../src/changeset.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAaH,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,EAAE,mCAAmC,EAAE,MAAM,0CAA0C,CAAC;AAW/F,MAAM,WAAW,qBAAqB;
|
|
1
|
+
{"version":3,"file":"changeset.d.ts","sourceRoot":"","sources":["../src/changeset.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAaH,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,EAAE,mCAAmC,EAAE,MAAM,0CAA0C,CAAC;AAW/F,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,yBAAyB,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAE1C;;OAEG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,sBAAuB,SAAQ,qBAAqB;IACpE,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,oBAAY,mBAAmB,GAAG,GAAG,CAAC;AACtC,oBAAY,aAAa,GAAG,GAAG,CAAC;AAChC,MAAM,WAAW,YAAY;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;IACnB,iBAAiB,CAAC,EAAE,mBAAmB,CAAC;CACxC;AAED;;;;GAIG;AACH,qBAAa,SAAS;IACrB,MAAM,CAAC,YAAY,sBAAgB;IACnC,MAAM,CAAC,gBAAgB,iCAAoB;IAC3C,MAAM,CAAC,iBAAiB,8BAAqB;IAE9B,gCAAgC,EAAE,OAAO,mCAAmC,CAAC,gCAAgC,CAAC;IAC9G,iCAAiC,EAAE,OAAO,uBAAuB,CAAC,iCAAiC,CAAC;IACpG,gCAAgC,EAAE,OAAO,uBAAuB,CAAC,gCAAgC,CAAC;IAClG,yBAAyB,EAAE,OAAO,uBAAuB,CAAC,yBAAyB,CAAC;IACpF,6CAA6C,EAAE,OAAO,mCAAmC,CAAC,6CAA6C,CAAC;IACxI,4CAA4C,EAAE,OAAO,mCAAmC,CAAC,4CAA4C,CAAC;IAErJ,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,aAAa,EAAE,OAAO,CAAC;IAEvB;;;OAGG;gBACS,UAAU,CAAC,EAAE,aAAa;IAgBtC;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,sBAAsB,IAAI,mBAAmB;IAI7C;;;;;OAKG;IACH,eAAe,CAAC,eAAe,EAAE,OAAO;IAIxC;;;;;OAKG;IACH,eAAe,IAAI,OAAO;IAI1B;;;;OAIG;IACH,KAAK,IAAI,SAAS;IAIlB;;;;;;;;OAQG;IACH,cAAc,CAAC,YAAY,EAAE,mBAAmB,EAAE,UAAU,CAAC,EAAE,qBAAqB;IAsBpF;;;;;;;;;OASG;IACH,OAAO,CAAC,4BAA4B;IAyDpC;;;;;;;;OAQG;IACH,OAAO,CAAC,WAAW;IA2BnB;;;;;;;;;;;OAWG;IACI,qCAAqC,CAC3C,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,mBAAmB,EACnC,yBAAyB,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAC/C,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,OAAO,EACvB,UAAU,CAAC,EAAE,qBAAqB;IAsInC;;;;;;;;;;;;OAYG;IACI,gBAAgB,CACtB,YAAY,EAAE,mBAAmB,EACjC,aAAa,EAAE,YAAY,EAAE,EAC7B,UAAU,CAAC,EAAE,sBAAsB,GACjC,mBAAmB;IAWtB;;;;;;;;;OASG;IACH,OAAO,CAAC,2BAA2B;IA8LnC;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,yCAAyC;IAiFjD;;;;;OAKG;IACH,OAAO,CAAC,oCAAoC;IAqN5C;;;;;;;OAOG;IACI,sBAAsB,CAAC,qBAAqB,EAAE,mBAAmB;IA8BxE;;;;;;OAMG;IACI,yBAAyB,CAAC,cAAc,EAAE,OAAO;IA0HxD;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;IAmB/B;;;OAGG;IACH,OAAO,CAAC,qCAAqC;IAsK7C;;;;;OAKG;IACI,kBAAkB;CAWzB"}
|
package/dist/changeset.js
CHANGED
|
@@ -46,7 +46,8 @@ class ChangeSet {
|
|
|
46
46
|
if (in_changes === undefined || in_changes === null) {
|
|
47
47
|
this._changes = {};
|
|
48
48
|
}
|
|
49
|
-
else if ((0, isString_1.default)(in_changes)) {
|
|
49
|
+
else if ((0, isString_1.default)(in_changes)) {
|
|
50
|
+
// Stringified Serialized JSON
|
|
50
51
|
this._changes = JSON.parse(in_changes);
|
|
51
52
|
}
|
|
52
53
|
else if (in_changes instanceof ChangeSet) {
|
|
@@ -114,7 +115,9 @@ class ChangeSet {
|
|
|
114
115
|
changes = in_changeSet.getSerializedChangeSet();
|
|
115
116
|
}
|
|
116
117
|
if (!(0, isObject_1.default)(this._changes) || Array.isArray(this._changes)) {
|
|
117
|
-
const oldValue = (0, isObject_1.default)(changes) && changes.value !== undefined
|
|
118
|
+
const oldValue = (0, isObject_1.default)(changes) && changes.value !== undefined
|
|
119
|
+
? changes.value
|
|
120
|
+
: changes;
|
|
118
121
|
this._changes = Array.isArray(oldValue) ? oldValue.slice() : oldValue;
|
|
119
122
|
}
|
|
120
123
|
else {
|
|
@@ -172,14 +175,16 @@ class ChangeSet {
|
|
|
172
175
|
* @param in_appliedValue - applied changes to be applied
|
|
173
176
|
*/
|
|
174
177
|
_applyValue(io_baseChanges, in_baseKey, in_appliedValue) {
|
|
175
|
-
const newValue =
|
|
176
|
-
in_appliedValue.value
|
|
178
|
+
const newValue = in_appliedValue && in_appliedValue.hasOwnProperty("value")
|
|
179
|
+
? in_appliedValue.value
|
|
180
|
+
: in_appliedValue;
|
|
177
181
|
if (io_baseChanges[in_baseKey] && io_baseChanges[in_baseKey].hasOwnProperty("value")) {
|
|
178
182
|
io_baseChanges[in_baseKey].value = newValue;
|
|
179
183
|
}
|
|
180
184
|
else {
|
|
181
185
|
if (io_baseChanges[in_baseKey] === undefined &&
|
|
182
|
-
in_appliedValue &&
|
|
186
|
+
in_appliedValue &&
|
|
187
|
+
in_appliedValue.hasOwnProperty("oldValue")) {
|
|
183
188
|
io_baseChanges[in_baseKey] = {
|
|
184
189
|
value: newValue,
|
|
185
190
|
oldValue: in_appliedValue.oldValue,
|
|
@@ -204,8 +209,7 @@ class ChangeSet {
|
|
|
204
209
|
*/
|
|
205
210
|
performApplyAfterOnPropertyWithTypeid(in_changedKey, in_baseChanges, in_appliedPropertyChanges, in_typeid, in_removeEmpty, in_options) {
|
|
206
211
|
const splitTypeid = extractContext(in_typeid);
|
|
207
|
-
if (splitTypeid.context === "set" ||
|
|
208
|
-
splitTypeid.context === "map") {
|
|
212
|
+
if (splitTypeid.context === "set" || splitTypeid.context === "map") {
|
|
209
213
|
in_baseChanges[in_changedKey] = in_baseChanges[in_changedKey] || {};
|
|
210
214
|
this._performApplyAfterOnPropertyIndexedCollection(in_baseChanges[in_changedKey], in_appliedPropertyChanges[in_changedKey], splitTypeid.typeid, in_options);
|
|
211
215
|
// Remove the key, when it no longer contains a changeset
|
|
@@ -214,27 +218,26 @@ class ChangeSet {
|
|
|
214
218
|
}
|
|
215
219
|
}
|
|
216
220
|
else if (splitTypeid.context === "array" || splitTypeid.typeid === "String") {
|
|
217
|
-
in_baseChanges[in_changedKey] =
|
|
221
|
+
in_baseChanges[in_changedKey] =
|
|
222
|
+
in_baseChanges[in_changedKey] !== undefined ? in_baseChanges[in_changedKey] : {};
|
|
218
223
|
let baseIsSetChange = false;
|
|
219
224
|
let oldValue;
|
|
220
225
|
if (splitTypeid.typeid === "String" &&
|
|
221
226
|
((0, isString_1.default)(in_baseChanges[in_changedKey]) ||
|
|
222
|
-
(in_baseChanges[in_changedKey] &&
|
|
227
|
+
(in_baseChanges[in_changedKey] &&
|
|
228
|
+
in_baseChanges[in_changedKey].hasOwnProperty("value")))) {
|
|
223
229
|
oldValue = in_baseChanges[in_changedKey].oldValue;
|
|
224
230
|
// we need to convert the format to allow the application of the changes
|
|
225
231
|
// since _performApplyAfterOnPropertyArray only understands insert/modify/remove commands
|
|
226
|
-
if (in_baseChanges[in_changedKey] &&
|
|
232
|
+
if (in_baseChanges[in_changedKey] &&
|
|
233
|
+
in_baseChanges[in_changedKey].hasOwnProperty("value")) {
|
|
227
234
|
in_baseChanges[in_changedKey] = {
|
|
228
|
-
insert: [
|
|
229
|
-
[0, in_baseChanges[in_changedKey].value],
|
|
230
|
-
],
|
|
235
|
+
insert: [[0, in_baseChanges[in_changedKey].value]],
|
|
231
236
|
};
|
|
232
237
|
}
|
|
233
238
|
else {
|
|
234
239
|
in_baseChanges[in_changedKey] = {
|
|
235
|
-
insert: [
|
|
236
|
-
[0, in_baseChanges[in_changedKey]],
|
|
237
|
-
],
|
|
240
|
+
insert: [[0, in_baseChanges[in_changedKey]]],
|
|
238
241
|
};
|
|
239
242
|
}
|
|
240
243
|
baseIsSetChange = true;
|
|
@@ -398,14 +401,16 @@ class ChangeSet {
|
|
|
398
401
|
if (typeid === "modify" && "modify" in io_rebasePropertyChangeSet) {
|
|
399
402
|
for (let j = 0; j < paths.length; j++) {
|
|
400
403
|
const tempTypeid = paths[i];
|
|
401
|
-
if (
|
|
404
|
+
if (isPrimitiveType(tempTypeid) &&
|
|
402
405
|
tempTypeid in io_rebasePropertyChangeSet.modify) {
|
|
403
406
|
const tempPaths = Object.keys(in_ownPropertyChangeSet.modify[tempTypeid]);
|
|
404
407
|
for (let z = 0; z < tempPaths.length; z++) {
|
|
405
408
|
if (tempPaths[z] in io_rebasePropertyChangeSet.modify[tempTypeid]) {
|
|
406
409
|
let rebasedPropContent = io_rebasePropertyChangeSet.modify[tempTypeid][tempPaths[z]];
|
|
407
|
-
if ((0, isObject_1.default)(rebasedPropContent) &&
|
|
408
|
-
|
|
410
|
+
if ((0, isObject_1.default)(rebasedPropContent) &&
|
|
411
|
+
"oldValue" in rebasedPropContent) {
|
|
412
|
+
rebasedPropContent.oldValue =
|
|
413
|
+
in_ownPropertyChangeSet.modify[tempTypeid][tempPaths[z]].value;
|
|
409
414
|
}
|
|
410
415
|
}
|
|
411
416
|
}
|
|
@@ -417,13 +422,15 @@ class ChangeSet {
|
|
|
417
422
|
// io_rebasePropertyChangeSet && in_ownPropertyChangeSet contain only property type, name and value, we update
|
|
418
423
|
// oldValue of io_rebasePropertyChangeSet.
|
|
419
424
|
for (let j = 0; j < paths.length; j++) {
|
|
420
|
-
if (typeid in io_rebasePropertyChangeSet &&
|
|
425
|
+
if (typeid in io_rebasePropertyChangeSet &&
|
|
426
|
+
paths[j] in io_rebasePropertyChangeSet[typeid]) {
|
|
421
427
|
let rebasedPropContent = io_rebasePropertyChangeSet[typeid][paths[j]];
|
|
422
428
|
if ((0, isObject_1.default)(rebasedPropContent) && "oldValue" in rebasedPropContent) {
|
|
423
429
|
// if oldValue already be update above, we don't need to update
|
|
424
430
|
if (io_rebasePropertyChangeSet[typeid][paths[j]].oldValue !==
|
|
425
431
|
in_ownPropertyChangeSet[typeid][paths[j]].value) {
|
|
426
|
-
io_rebasePropertyChangeSet[typeid][paths[j]].oldValue =
|
|
432
|
+
io_rebasePropertyChangeSet[typeid][paths[j]].oldValue =
|
|
433
|
+
in_ownPropertyChangeSet[typeid][paths[j]].value;
|
|
427
434
|
}
|
|
428
435
|
}
|
|
429
436
|
}
|
|
@@ -431,8 +438,7 @@ class ChangeSet {
|
|
|
431
438
|
}
|
|
432
439
|
// The reserved keywords have already been handled above and changes which are not present in
|
|
433
440
|
// the other ChangeSet can be ignored
|
|
434
|
-
if (ChangeSet.isReservedKeyword(typeid) ||
|
|
435
|
-
!io_rebasePropertyChangeSet[typeid]) {
|
|
441
|
+
if (ChangeSet.isReservedKeyword(typeid) || !io_rebasePropertyChangeSet[typeid]) {
|
|
436
442
|
continue;
|
|
437
443
|
}
|
|
438
444
|
// Check, whether we have a collision in a path update
|
|
@@ -489,8 +495,7 @@ class ChangeSet {
|
|
|
489
495
|
*/
|
|
490
496
|
rebaseChangeSetForPropertyEntryWithTypeid(in_key, in_ownPropertyChangeSet, io_rebasePropertyChangeSet, in_typeid, in_basePath, in_removeEmpty, out_conflicts, in_options) {
|
|
491
497
|
const splitTypeid = extractContext(in_typeid);
|
|
492
|
-
if (splitTypeid.context === "set" ||
|
|
493
|
-
splitTypeid.context === "map") {
|
|
498
|
+
if (splitTypeid.context === "set" || splitTypeid.context === "map") {
|
|
494
499
|
this._rebaseIndexedCollectionChangeSetForProperty(in_ownPropertyChangeSet[in_key], io_rebasePropertyChangeSet[in_key], in_basePath, splitTypeid.typeid, true, // use square brackets
|
|
495
500
|
out_conflicts, in_options);
|
|
496
501
|
// Remove the key, when it no longer contains a changeset
|
|
@@ -646,14 +651,13 @@ class ChangeSet {
|
|
|
646
651
|
}
|
|
647
652
|
else if (splitType.context === "map" ||
|
|
648
653
|
// node property test: (we have to do the test this way, because of inheritance)
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
654
|
+
nestedChangeset.insert ||
|
|
655
|
+
nestedChangeset.modify ||
|
|
656
|
+
nestedChangeset.remove) {
|
|
652
657
|
// This prevents an error, if the changeset only contains an insert operation. In that case
|
|
653
658
|
// we don't actually need the corresponding old state and thus do not need to throw an error
|
|
654
659
|
// This type of situation can occur in the materialized history, if an insert happens right at a chunk boundary.
|
|
655
|
-
if (Object.keys(nestedChangeset).length === 1 &&
|
|
656
|
-
nestedChangeset.insert) {
|
|
660
|
+
if (Object.keys(nestedChangeset).length === 1 && nestedChangeset.insert) {
|
|
657
661
|
in_context._traversalStopped = true;
|
|
658
662
|
return;
|
|
659
663
|
}
|
|
@@ -706,7 +710,8 @@ class ChangeSet {
|
|
|
706
710
|
if (!newRemove[oldTypeKeys[k]]) {
|
|
707
711
|
newRemove[oldTypeKeys[k]] = {};
|
|
708
712
|
}
|
|
709
|
-
newRemove[oldTypeKeys[k]][removedKeys[i]] =
|
|
713
|
+
newRemove[oldTypeKeys[k]][removedKeys[i]] =
|
|
714
|
+
(0, fastest_json_copy_1.copy)(entry);
|
|
710
715
|
}
|
|
711
716
|
}
|
|
712
717
|
}
|
|
@@ -742,13 +747,16 @@ class ChangeSet {
|
|
|
742
747
|
if (!(0, isObject_1.default)(in_oldSerializedState) || Array.isArray(in_oldSerializedState)) {
|
|
743
748
|
if (!(0, isObject_1.default)(this._changes) || Array.isArray(this._changes)) {
|
|
744
749
|
this._changes = {
|
|
745
|
-
oldValue: Array.isArray(in_oldSerializedState)
|
|
750
|
+
oldValue: Array.isArray(in_oldSerializedState)
|
|
751
|
+
? in_oldSerializedState.slice()
|
|
752
|
+
: in_oldSerializedState,
|
|
746
753
|
value: this._changes,
|
|
747
754
|
};
|
|
748
755
|
}
|
|
749
756
|
else {
|
|
750
|
-
this._changes.oldValue = Array.isArray(in_oldSerializedState)
|
|
751
|
-
in_oldSerializedState
|
|
757
|
+
this._changes.oldValue = Array.isArray(in_oldSerializedState)
|
|
758
|
+
? in_oldSerializedState.slice()
|
|
759
|
+
: in_oldSerializedState;
|
|
752
760
|
}
|
|
753
761
|
}
|
|
754
762
|
else {
|
|
@@ -825,7 +833,8 @@ class ChangeSet {
|
|
|
825
833
|
// TODO: Remove in_withoutRoot when it will not be used anymore
|
|
826
834
|
}
|
|
827
835
|
else if (splitType.context === "map" ||
|
|
828
|
-
(!in_withoutRoot && splitType.context === "single")) {
|
|
836
|
+
(!in_withoutRoot && splitType.context === "single")) {
|
|
837
|
+
// For NodeProperty / inserts at the root
|
|
829
838
|
let nestedChangeset = in_context.getNestedChangeSet();
|
|
830
839
|
if (isPrimitiveType(splitType.typeid)) {
|
|
831
840
|
if (nestedChangeset.modify) {
|
|
@@ -927,7 +936,8 @@ class ChangeSet {
|
|
|
927
936
|
(type === "String" && (0, isString_1.default)(nestedChangeset.oldValue))) {
|
|
928
937
|
// check if we were called with an irreversible changeset
|
|
929
938
|
if (in_context.getOperationType() === "modify" &&
|
|
930
|
-
(!(0, isObject_1.default)(nestedChangeset) ||
|
|
939
|
+
(!(0, isObject_1.default)(nestedChangeset) ||
|
|
940
|
+
typeof nestedChangeset.oldValue === "undefined")) {
|
|
931
941
|
throw new Error(MSG.OLD_VALUE_NOT_FOUND);
|
|
932
942
|
}
|
|
933
943
|
// switch oldValue and value
|
|
@@ -935,7 +945,8 @@ class ChangeSet {
|
|
|
935
945
|
nestedChangeset.oldValue = nestedChangeset.value;
|
|
936
946
|
nestedChangeset.value = tmp;
|
|
937
947
|
}
|
|
938
|
-
else if ((type === "String" && !(0, isString_1.default)(nestedChangeset.oldValue)) ||
|
|
948
|
+
else if ((type === "String" && !(0, isString_1.default)(nestedChangeset.oldValue)) ||
|
|
949
|
+
splitType.context === "array") {
|
|
939
950
|
// String and Arrays need special treatment:
|
|
940
951
|
const arrayIterator = new arrayChangesetIterator_1.ArrayChangeSetIterator(nestedChangeset);
|
|
941
952
|
const resultChangeset = {};
|
|
@@ -954,14 +965,16 @@ class ChangeSet {
|
|
|
954
965
|
case operationTypes_1.ArrayIteratorOperationTypes.INSERT:
|
|
955
966
|
// Handle inserts
|
|
956
967
|
resultChangeset.remove.push([
|
|
957
|
-
arrayIterator.opDescription.operation[0] +
|
|
968
|
+
arrayIterator.opDescription.operation[0] +
|
|
969
|
+
arrayIterator.opDescription.offset,
|
|
958
970
|
arrayIterator.opDescription.operation[1],
|
|
959
971
|
]);
|
|
960
972
|
break;
|
|
961
973
|
case operationTypes_1.ArrayIteratorOperationTypes.REMOVE:
|
|
962
974
|
// Handle removes
|
|
963
975
|
resultChangeset.insert.push([
|
|
964
|
-
arrayIterator.opDescription.operation[0] +
|
|
976
|
+
arrayIterator.opDescription.operation[0] +
|
|
977
|
+
arrayIterator.opDescription.offset,
|
|
965
978
|
arrayIterator.opDescription.operation[1],
|
|
966
979
|
]);
|
|
967
980
|
break;
|
|
@@ -969,14 +982,16 @@ class ChangeSet {
|
|
|
969
982
|
// Handle modifies
|
|
970
983
|
if (isPrimitiveType(splitType.typeid)) {
|
|
971
984
|
resultChangeset.modify.push([
|
|
972
|
-
arrayIterator.opDescription.operation[0] +
|
|
985
|
+
arrayIterator.opDescription.operation[0] +
|
|
986
|
+
arrayIterator.opDescription.offset,
|
|
973
987
|
arrayIterator.opDescription.operation[2],
|
|
974
988
|
arrayIterator.opDescription.operation[1],
|
|
975
989
|
]);
|
|
976
990
|
}
|
|
977
991
|
else {
|
|
978
992
|
resultChangeset.modify.push([
|
|
979
|
-
arrayIterator.opDescription.operation[0] +
|
|
993
|
+
arrayIterator.opDescription.operation[0] +
|
|
994
|
+
arrayIterator.opDescription.offset,
|
|
980
995
|
arrayIterator.opDescription.operation[1],
|
|
981
996
|
]);
|
|
982
997
|
}
|
|
@@ -1039,8 +1054,7 @@ class ChangeSet {
|
|
|
1039
1054
|
* in a later release
|
|
1040
1055
|
*/
|
|
1041
1056
|
toInverseChangeSet() {
|
|
1042
|
-
if (this._changes.value !== undefined &&
|
|
1043
|
-
this._changes.oldValue !== undefined) {
|
|
1057
|
+
if (this._changes.value !== undefined && this._changes.oldValue !== undefined) {
|
|
1044
1058
|
const tmp = this._changes.value;
|
|
1045
1059
|
this._changes.value = this._changes.oldValue;
|
|
1046
1060
|
this._changes.oldValue = tmp;
|
|
@@ -1056,8 +1070,10 @@ exports.ChangeSet = ChangeSet;
|
|
|
1056
1070
|
ChangeSet.ConflictType = changesetConflictTypes_1.ConflictType;
|
|
1057
1071
|
ChangeSet.isEmptyChangeSet = isEmptyChangeset_1.isEmptyChangeSet;
|
|
1058
1072
|
ChangeSet.isReservedKeyword = isReservedKeyword_1.isReservedKeyword;
|
|
1059
|
-
ChangeSet.prototype._performApplyAfterOnPropertyArray =
|
|
1060
|
-
|
|
1073
|
+
ChangeSet.prototype._performApplyAfterOnPropertyArray =
|
|
1074
|
+
array_1.ChangeSetArrayFunctions._performApplyAfterOnPropertyArray;
|
|
1075
|
+
ChangeSet.prototype._rebaseArrayChangeSetForProperty =
|
|
1076
|
+
array_1.ChangeSetArrayFunctions._rebaseArrayChangeSetForProperty;
|
|
1061
1077
|
ChangeSet.prototype._rebaseChangeSetForString = array_1.ChangeSetArrayFunctions._rebaseChangeSetForString;
|
|
1062
1078
|
// Add the indexed collection functions into the prototype of the ChangeSet
|
|
1063
1079
|
ChangeSet.prototype._performApplyAfterOnPropertyIndexedCollection =
|