@fluid-experimental/property-changeset 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229
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 +69 -49
- 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/map.spec.js +19 -0
- package/dist/test/map.spec.js.map +1 -0
- 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 +71 -51
- 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 +37 -38
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;IAmMnC;;;;;;;;;;;;;;;;;;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
|
|
@@ -450,11 +456,15 @@ class ChangeSet {
|
|
|
450
456
|
// own internal ChangeSet and we want to be sure, nobody changes our internal data-structures
|
|
451
457
|
changeSet[typeid][paths[j]] = (0, fastest_json_copy_1.copy)(in_ownPropertyChangeSet[typeid][paths[j]]);
|
|
452
458
|
}
|
|
453
|
-
// Remove the typeid, when it no longer contains any keys
|
|
454
|
-
if ((0, isEmpty_1.default)(io_rebasePropertyChangeSet[typeid])) {
|
|
455
|
-
delete io_rebasePropertyChangeSet[typeid];
|
|
456
|
-
}
|
|
457
459
|
}
|
|
460
|
+
// Remove the typeid, when it no longer contains any keys
|
|
461
|
+
if ((0, isEmpty_1.default)(io_rebasePropertyChangeSet[typeid][paths[j]])) {
|
|
462
|
+
delete io_rebasePropertyChangeSet[typeid][paths[j]];
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
// Remove the typeid, when it no longer contains any keys
|
|
466
|
+
if ((0, isEmpty_1.default)(io_rebasePropertyChangeSet[typeid])) {
|
|
467
|
+
delete io_rebasePropertyChangeSet[typeid];
|
|
458
468
|
}
|
|
459
469
|
}
|
|
460
470
|
// If there were conflicts in the set operations, report them
|
|
@@ -489,8 +499,7 @@ class ChangeSet {
|
|
|
489
499
|
*/
|
|
490
500
|
rebaseChangeSetForPropertyEntryWithTypeid(in_key, in_ownPropertyChangeSet, io_rebasePropertyChangeSet, in_typeid, in_basePath, in_removeEmpty, out_conflicts, in_options) {
|
|
491
501
|
const splitTypeid = extractContext(in_typeid);
|
|
492
|
-
if (splitTypeid.context === "set" ||
|
|
493
|
-
splitTypeid.context === "map") {
|
|
502
|
+
if (splitTypeid.context === "set" || splitTypeid.context === "map") {
|
|
494
503
|
this._rebaseIndexedCollectionChangeSetForProperty(in_ownPropertyChangeSet[in_key], io_rebasePropertyChangeSet[in_key], in_basePath, splitTypeid.typeid, true, // use square brackets
|
|
495
504
|
out_conflicts, in_options);
|
|
496
505
|
// Remove the key, when it no longer contains a changeset
|
|
@@ -646,14 +655,13 @@ class ChangeSet {
|
|
|
646
655
|
}
|
|
647
656
|
else if (splitType.context === "map" ||
|
|
648
657
|
// node property test: (we have to do the test this way, because of inheritance)
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
658
|
+
nestedChangeset.insert ||
|
|
659
|
+
nestedChangeset.modify ||
|
|
660
|
+
nestedChangeset.remove) {
|
|
652
661
|
// This prevents an error, if the changeset only contains an insert operation. In that case
|
|
653
662
|
// we don't actually need the corresponding old state and thus do not need to throw an error
|
|
654
663
|
// 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) {
|
|
664
|
+
if (Object.keys(nestedChangeset).length === 1 && nestedChangeset.insert) {
|
|
657
665
|
in_context._traversalStopped = true;
|
|
658
666
|
return;
|
|
659
667
|
}
|
|
@@ -706,7 +714,8 @@ class ChangeSet {
|
|
|
706
714
|
if (!newRemove[oldTypeKeys[k]]) {
|
|
707
715
|
newRemove[oldTypeKeys[k]] = {};
|
|
708
716
|
}
|
|
709
|
-
newRemove[oldTypeKeys[k]][removedKeys[i]] =
|
|
717
|
+
newRemove[oldTypeKeys[k]][removedKeys[i]] =
|
|
718
|
+
(0, fastest_json_copy_1.copy)(entry);
|
|
710
719
|
}
|
|
711
720
|
}
|
|
712
721
|
}
|
|
@@ -742,13 +751,16 @@ class ChangeSet {
|
|
|
742
751
|
if (!(0, isObject_1.default)(in_oldSerializedState) || Array.isArray(in_oldSerializedState)) {
|
|
743
752
|
if (!(0, isObject_1.default)(this._changes) || Array.isArray(this._changes)) {
|
|
744
753
|
this._changes = {
|
|
745
|
-
oldValue: Array.isArray(in_oldSerializedState)
|
|
754
|
+
oldValue: Array.isArray(in_oldSerializedState)
|
|
755
|
+
? in_oldSerializedState.slice()
|
|
756
|
+
: in_oldSerializedState,
|
|
746
757
|
value: this._changes,
|
|
747
758
|
};
|
|
748
759
|
}
|
|
749
760
|
else {
|
|
750
|
-
this._changes.oldValue = Array.isArray(in_oldSerializedState)
|
|
751
|
-
in_oldSerializedState
|
|
761
|
+
this._changes.oldValue = Array.isArray(in_oldSerializedState)
|
|
762
|
+
? in_oldSerializedState.slice()
|
|
763
|
+
: in_oldSerializedState;
|
|
752
764
|
}
|
|
753
765
|
}
|
|
754
766
|
else {
|
|
@@ -825,7 +837,8 @@ class ChangeSet {
|
|
|
825
837
|
// TODO: Remove in_withoutRoot when it will not be used anymore
|
|
826
838
|
}
|
|
827
839
|
else if (splitType.context === "map" ||
|
|
828
|
-
(!in_withoutRoot && splitType.context === "single")) {
|
|
840
|
+
(!in_withoutRoot && splitType.context === "single")) {
|
|
841
|
+
// For NodeProperty / inserts at the root
|
|
829
842
|
let nestedChangeset = in_context.getNestedChangeSet();
|
|
830
843
|
if (isPrimitiveType(splitType.typeid)) {
|
|
831
844
|
if (nestedChangeset.modify) {
|
|
@@ -927,7 +940,8 @@ class ChangeSet {
|
|
|
927
940
|
(type === "String" && (0, isString_1.default)(nestedChangeset.oldValue))) {
|
|
928
941
|
// check if we were called with an irreversible changeset
|
|
929
942
|
if (in_context.getOperationType() === "modify" &&
|
|
930
|
-
(!(0, isObject_1.default)(nestedChangeset) ||
|
|
943
|
+
(!(0, isObject_1.default)(nestedChangeset) ||
|
|
944
|
+
typeof nestedChangeset.oldValue === "undefined")) {
|
|
931
945
|
throw new Error(MSG.OLD_VALUE_NOT_FOUND);
|
|
932
946
|
}
|
|
933
947
|
// switch oldValue and value
|
|
@@ -935,7 +949,8 @@ class ChangeSet {
|
|
|
935
949
|
nestedChangeset.oldValue = nestedChangeset.value;
|
|
936
950
|
nestedChangeset.value = tmp;
|
|
937
951
|
}
|
|
938
|
-
else if ((type === "String" && !(0, isString_1.default)(nestedChangeset.oldValue)) ||
|
|
952
|
+
else if ((type === "String" && !(0, isString_1.default)(nestedChangeset.oldValue)) ||
|
|
953
|
+
splitType.context === "array") {
|
|
939
954
|
// String and Arrays need special treatment:
|
|
940
955
|
const arrayIterator = new arrayChangesetIterator_1.ArrayChangeSetIterator(nestedChangeset);
|
|
941
956
|
const resultChangeset = {};
|
|
@@ -954,14 +969,16 @@ class ChangeSet {
|
|
|
954
969
|
case operationTypes_1.ArrayIteratorOperationTypes.INSERT:
|
|
955
970
|
// Handle inserts
|
|
956
971
|
resultChangeset.remove.push([
|
|
957
|
-
arrayIterator.opDescription.operation[0] +
|
|
972
|
+
arrayIterator.opDescription.operation[0] +
|
|
973
|
+
arrayIterator.opDescription.offset,
|
|
958
974
|
arrayIterator.opDescription.operation[1],
|
|
959
975
|
]);
|
|
960
976
|
break;
|
|
961
977
|
case operationTypes_1.ArrayIteratorOperationTypes.REMOVE:
|
|
962
978
|
// Handle removes
|
|
963
979
|
resultChangeset.insert.push([
|
|
964
|
-
arrayIterator.opDescription.operation[0] +
|
|
980
|
+
arrayIterator.opDescription.operation[0] +
|
|
981
|
+
arrayIterator.opDescription.offset,
|
|
965
982
|
arrayIterator.opDescription.operation[1],
|
|
966
983
|
]);
|
|
967
984
|
break;
|
|
@@ -969,14 +986,16 @@ class ChangeSet {
|
|
|
969
986
|
// Handle modifies
|
|
970
987
|
if (isPrimitiveType(splitType.typeid)) {
|
|
971
988
|
resultChangeset.modify.push([
|
|
972
|
-
arrayIterator.opDescription.operation[0] +
|
|
989
|
+
arrayIterator.opDescription.operation[0] +
|
|
990
|
+
arrayIterator.opDescription.offset,
|
|
973
991
|
arrayIterator.opDescription.operation[2],
|
|
974
992
|
arrayIterator.opDescription.operation[1],
|
|
975
993
|
]);
|
|
976
994
|
}
|
|
977
995
|
else {
|
|
978
996
|
resultChangeset.modify.push([
|
|
979
|
-
arrayIterator.opDescription.operation[0] +
|
|
997
|
+
arrayIterator.opDescription.operation[0] +
|
|
998
|
+
arrayIterator.opDescription.offset,
|
|
980
999
|
arrayIterator.opDescription.operation[1],
|
|
981
1000
|
]);
|
|
982
1001
|
}
|
|
@@ -1039,8 +1058,7 @@ class ChangeSet {
|
|
|
1039
1058
|
* in a later release
|
|
1040
1059
|
*/
|
|
1041
1060
|
toInverseChangeSet() {
|
|
1042
|
-
if (this._changes.value !== undefined &&
|
|
1043
|
-
this._changes.oldValue !== undefined) {
|
|
1061
|
+
if (this._changes.value !== undefined && this._changes.oldValue !== undefined) {
|
|
1044
1062
|
const tmp = this._changes.value;
|
|
1045
1063
|
this._changes.value = this._changes.oldValue;
|
|
1046
1064
|
this._changes.oldValue = tmp;
|
|
@@ -1056,8 +1074,10 @@ exports.ChangeSet = ChangeSet;
|
|
|
1056
1074
|
ChangeSet.ConflictType = changesetConflictTypes_1.ConflictType;
|
|
1057
1075
|
ChangeSet.isEmptyChangeSet = isEmptyChangeset_1.isEmptyChangeSet;
|
|
1058
1076
|
ChangeSet.isReservedKeyword = isReservedKeyword_1.isReservedKeyword;
|
|
1059
|
-
ChangeSet.prototype._performApplyAfterOnPropertyArray =
|
|
1060
|
-
|
|
1077
|
+
ChangeSet.prototype._performApplyAfterOnPropertyArray =
|
|
1078
|
+
array_1.ChangeSetArrayFunctions._performApplyAfterOnPropertyArray;
|
|
1079
|
+
ChangeSet.prototype._rebaseArrayChangeSetForProperty =
|
|
1080
|
+
array_1.ChangeSetArrayFunctions._rebaseArrayChangeSetForProperty;
|
|
1061
1081
|
ChangeSet.prototype._rebaseChangeSetForString = array_1.ChangeSetArrayFunctions._rebaseChangeSetForString;
|
|
1062
1082
|
// Add the indexed collection functions into the prototype of the ChangeSet
|
|
1063
1083
|
ChangeSet.prototype._performApplyAfterOnPropertyIndexedCollection =
|