@fluid-experimental/property-changeset 1.2.7 → 2.0.0-dev.1.3.0.96595

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.
Files changed (58) hide show
  1. package/dist/changeset.d.ts +39 -45
  2. package/dist/changeset.d.ts.map +1 -1
  3. package/dist/changeset.js +42 -51
  4. package/dist/changeset.js.map +1 -1
  5. package/dist/changeset_operations/array.d.ts +34 -3
  6. package/dist/changeset_operations/array.d.ts.map +1 -1
  7. package/dist/changeset_operations/array.js +97 -94
  8. package/dist/changeset_operations/array.js.map +1 -1
  9. package/dist/changeset_operations/indexedCollection.d.ts +13 -15
  10. package/dist/changeset_operations/indexedCollection.d.ts.map +1 -1
  11. package/dist/changeset_operations/indexedCollection.js +14 -15
  12. package/dist/changeset_operations/indexedCollection.js.map +1 -1
  13. package/dist/helpers/typeidHelper.d.ts +14 -14
  14. package/dist/helpers/typeidHelper.d.ts.map +1 -1
  15. package/dist/helpers/typeidHelper.js +24 -34
  16. package/dist/helpers/typeidHelper.js.map +1 -1
  17. package/dist/pathHelper.d.ts +5 -5
  18. package/dist/pathHelper.d.ts.map +1 -1
  19. package/dist/pathHelper.js +54 -56
  20. package/dist/pathHelper.js.map +1 -1
  21. package/dist/templateValidator.d.ts +62 -30
  22. package/dist/templateValidator.d.ts.map +1 -1
  23. package/dist/templateValidator.js +128 -94
  24. package/dist/templateValidator.js.map +1 -1
  25. package/dist/test/array.spec.js +3 -6
  26. package/dist/test/array.spec.js.map +1 -1
  27. package/dist/test/pathHelper.spec.js +2 -4
  28. package/dist/test/pathHelper.spec.js.map +1 -1
  29. package/dist/test/reversibleCs.spec.js +2 -4
  30. package/dist/test/reversibleCs.spec.js.map +1 -1
  31. package/dist/test/tsconfig.tsbuildinfo +1 -1
  32. package/dist/test/validator/templateValidator.spec.js +5 -10
  33. package/dist/test/validator/templateValidator.spec.js.map +1 -1
  34. package/dist/utils.d.ts +137 -109
  35. package/dist/utils.d.ts.map +1 -1
  36. package/dist/utils.js +167 -174
  37. package/dist/utils.js.map +1 -1
  38. package/dist/validationResultBuilder.d.ts +6 -8
  39. package/dist/validationResultBuilder.d.ts.map +1 -1
  40. package/dist/validationResultBuilder.js +5 -11
  41. package/dist/validationResultBuilder.js.map +1 -1
  42. package/lib/changeset.js +42 -51
  43. package/lib/changeset.js.map +1 -1
  44. package/lib/changeset_operations/array.js +97 -94
  45. package/lib/changeset_operations/array.js.map +1 -1
  46. package/lib/changeset_operations/indexedCollection.js +14 -15
  47. package/lib/changeset_operations/indexedCollection.js.map +1 -1
  48. package/lib/helpers/typeidHelper.js +24 -34
  49. package/lib/helpers/typeidHelper.js.map +1 -1
  50. package/lib/pathHelper.js +54 -56
  51. package/lib/pathHelper.js.map +1 -1
  52. package/lib/templateValidator.js +128 -94
  53. package/lib/templateValidator.js.map +1 -1
  54. package/lib/utils.js +167 -174
  55. package/lib/utils.js.map +1 -1
  56. package/lib/validationResultBuilder.js +5 -11
  57. package/lib/validationResultBuilder.js.map +1 -1
  58. package/package.json +5 -5
@@ -23,21 +23,44 @@ const { isPrimitiveType } = TypeIdHelper;
23
23
  */
24
24
  var ArrayChangeSetRangeType;
25
25
  (function (ArrayChangeSetRangeType) {
26
+ /**
27
+ * A complete operation of change set A.
28
+ */
26
29
  ArrayChangeSetRangeType[ArrayChangeSetRangeType["completeA"] = 0] = "completeA";
30
+ /**
31
+ * A complete operation of change set B.
32
+ */
27
33
  ArrayChangeSetRangeType[ArrayChangeSetRangeType["completeB"] = 1] = "completeB";
34
+ /**
35
+ * A partial operation of change set A.
36
+ */
28
37
  ArrayChangeSetRangeType[ArrayChangeSetRangeType["partOfA"] = 2] = "partOfA";
38
+ /**
39
+ * A partial operation of change set B.
40
+ */
29
41
  ArrayChangeSetRangeType[ArrayChangeSetRangeType["partOfB"] = 3] = "partOfB";
42
+ /**
43
+ * A complete operation of change set A overlapping with a partial operation of change set B.
44
+ */
30
45
  ArrayChangeSetRangeType[ArrayChangeSetRangeType["completeApartOfB"] = 4] = "completeApartOfB";
46
+ /**
47
+ * A complete operation of change set B overlapping with a partial operation of change set A.
48
+ */
31
49
  ArrayChangeSetRangeType[ArrayChangeSetRangeType["completeBpartOfA"] = 5] = "completeBpartOfA";
50
+ /**
51
+ * A complete operation of change set A overlapping a complete operation of change set B.
52
+ */
32
53
  ArrayChangeSetRangeType[ArrayChangeSetRangeType["completeAcompleteB"] = 6] = "completeAcompleteB";
54
+ /**
55
+ * A partial operation of change set A, a partial operation of change set B.
56
+ */
33
57
  ArrayChangeSetRangeType[ArrayChangeSetRangeType["partOfApartOfB"] = 7] = "partOfApartOfB";
34
58
  })(ArrayChangeSetRangeType || (ArrayChangeSetRangeType = {}));
35
59
  /**
36
- * compute a range for an operation of the current change set
37
- * @param io_operation input
38
- * @param in_aOffset the offset that needs to be added to transform the operation
39
- * @param io_resultingRange
40
- * the computed range
60
+ * Computes a range for an operation of the current change set
61
+ * @param io_operation - Input
62
+ * @param in_aOffset - The offset that needs to be added to transform the operation
63
+ * @param io_resultingRange - The computed range
41
64
  */
42
65
  const getRangeForCurrentStateOperation = function (io_operation, in_aOffset, io_resultingRange) {
43
66
  if (!io_operation) {
@@ -81,10 +104,10 @@ const getRangeForCurrentStateOperation = function (io_operation, in_aOffset, io_
81
104
  };
82
105
  const getOpLength = (op) => isNumber(op[1]) ? op[1] : op[1].length;
83
106
  /**
84
- * computes the impact range for a given operation of the applied change set
85
- * @param in_operation the op
86
- * @param io_resultingRange the computed range
87
- * @param in_flag the flag for the resulting range, default is 'complete B'
107
+ * Computes the impact range for a given operation of the applied change set
108
+ * @param in_operation - The op
109
+ * @param io_resultingRange - The computed range
110
+ * @param in_flag - The flag for the resulting range, default is 'complete B'
88
111
  * @param in_options - Optional additional parameters
89
112
  */
90
113
  const getRangeForAppliedOperation = function (in_operation, io_resultingRange, in_flag, in_options) {
@@ -106,12 +129,7 @@ const getRangeForAppliedOperation = function (in_operation, io_resultingRange, i
106
129
  io_resultingRange.op.operation[0] = in_operation.operation[0];
107
130
  io_resultingRange.begin = in_operation.operation[0];
108
131
  io_resultingRange.op._absoluteBegin = in_operation.operation[0];
109
- if (in_flag !== undefined) {
110
- io_resultingRange.flag = in_flag;
111
- }
112
- else {
113
- io_resultingRange.flag = ArrayChangeSetRangeType.completeB;
114
- }
132
+ io_resultingRange.flag = in_flag !== undefined ? in_flag : ArrayChangeSetRangeType.completeB;
115
133
  switch (in_operation.type) {
116
134
  case ArrayChangeSetIterator.types.INSERT:
117
135
  io_resultingRange.end = in_operation.operation[0];
@@ -126,12 +144,9 @@ const getRangeForAppliedOperation = function (in_operation, io_resultingRange, i
126
144
  case ArrayChangeSetIterator.types.REMOVE:
127
145
  let numberOfRemovedElements = getOpLength(in_operation.operation);
128
146
  io_resultingRange.end = in_operation.operation[0] + numberOfRemovedElements;
129
- if (Array.isArray(in_operation.operation[1])) {
130
- io_resultingRange.op.operation[1] = in_operation.operation[1].slice();
131
- }
132
- else {
133
- io_resultingRange.op.operation[1] = in_operation.operation[1];
134
- }
147
+ io_resultingRange.op.operation[1] = Array.isArray(in_operation.operation[1])
148
+ ? in_operation.operation[1].slice()
149
+ : in_operation.operation[1];
135
150
  io_resultingRange.removeInsertOperation = in_operation.removeInsertOperation;
136
151
  return;
137
152
  case ArrayChangeSetIterator.types.MODIFY:
@@ -149,10 +164,10 @@ const getRangeForAppliedOperation = function (in_operation, io_resultingRange, i
149
164
  * Splits the second and third parameter in an array remove or modify operation into two segments.
150
165
  * This treats the three possible cases array, string and length that are allowed in a remove operation
151
166
  *
152
- * @param in_firstResult - Place where the first half is stored
167
+ * @param in_firstResult - Place where the first half is stored
153
168
  * @param in_secondResult - Place where the second half is stored
154
- * @param in_data - The original operation
155
- * @param in_start - Index at which the operation is split
169
+ * @param in_data - The original operation
170
+ * @param in_start - Index at which the operation is split
156
171
  * @private
157
172
  */
158
173
  const _splitArrayParameter = function (in_firstResult, in_secondResult, in_data, in_start) {
@@ -230,13 +245,13 @@ const _copyOperation = function (in_sourceOperation, in_targetOperation) {
230
245
  /**
231
246
  * cut overlapping ranges in non-overlapping and completely overlapping segments
232
247
  * ranges of length 0 just cut lengthy ranges
233
- * @param io_rangeA input A
234
- * @param io_rangeB input B
235
- * @param io_resultingSegment the resulting overlapping segment
236
- * @param in_rebasing is this function called for rebasing - we have to implement two different
237
- * behaviors of this function: one for squashing and one for rebasing, because an insert-insert
238
- * operation in squashing should be separte segments, while for rebasing, we need one segment
239
- * for both inserts to be able to report a conflict.
248
+ * @param io_rangeA - Input A
249
+ * @param io_rangeB - Input B
250
+ * @param io_resultingSegment - The resulting overlapping segment
251
+ * @param in_rebasing - Is this function called for rebasing - we have to implement two different
252
+ * behaviors of this function: one for squashing and one for rebasing, because an insert-insert
253
+ * operation in squashing should be separte segments, while for rebasing, we need one segment
254
+ * for both inserts to be able to report a conflict.
240
255
  * overlapping range or
241
256
  * (partial) A or B
242
257
  */
@@ -394,22 +409,14 @@ const splitOverlapping = function (io_rangeA, io_rangeB, io_resultingSegment, in
394
409
  io_resultingSegment.end = io_rangeA.end;
395
410
  io_resultingSegment.op = undefined; // This is used to indicate that we don't need any operation
396
411
  if (io_rangeB.op.operation[1].length === rangeLength) {
397
- if (io_rangeA.op.operation[1].length === rangeLength) {
398
- // We consume both A and B
399
- io_resultingSegment.flag = ArrayChangeSetRangeType.completeAcompleteB;
400
- }
401
- else {
402
- io_resultingSegment.flag = ArrayChangeSetRangeType.completeBpartOfA;
403
- }
412
+ io_resultingSegment.flag = io_rangeA.op.operation[1].length === rangeLength
413
+ ? ArrayChangeSetRangeType.completeAcompleteB
414
+ : ArrayChangeSetRangeType.completeBpartOfA;
404
415
  }
405
416
  else {
406
- if (io_rangeA.op.operation[1].length === rangeLength) {
407
- // We consume A and leave a part of B
408
- io_resultingSegment.flag = ArrayChangeSetRangeType.completeApartOfB;
409
- }
410
- else {
411
- io_resultingSegment.flag = ArrayChangeSetRangeType.partOfApartOfB;
412
- }
417
+ io_resultingSegment.flag = io_rangeA.op.operation[1].length === rangeLength
418
+ ? ArrayChangeSetRangeType.completeApartOfB
419
+ : ArrayChangeSetRangeType.partOfApartOfB;
413
420
  }
414
421
  // cut the remaining segment entry
415
422
  if (io_resultingSegment.flag === ArrayChangeSetRangeType.partOfApartOfB ||
@@ -550,9 +557,9 @@ const splitOverlapping = function (io_rangeA, io_rangeB, io_resultingSegment, in
550
557
  /**
551
558
  * merge in_op with the last op of that category in io_changeset (if possible)
552
559
  * e.g. merge an delete [1,3] with delete [3,2] to delete [1,5]
553
- * @param in_op - the op to merge
554
- * @param io_changeset - the changeset to merge the op to
555
- * @param in_targetIndex the transformed target index offset
560
+ * @param in_op - The op to merge
561
+ * @param io_changeset - The changeset to merge the op to
562
+ * @param in_targetIndex - The transformed target index offset
556
563
  * @returns true if the merge was possible and executed
557
564
  */
558
565
  const mergeWithLastIfPossible = function (in_op, io_changeset, in_targetIndex, in_options) {
@@ -640,12 +647,12 @@ const mergeWithLastIfPossible = function (in_op, io_changeset, in_targetIndex, i
640
647
  };
641
648
  /**
642
649
  * push an operation to a changeset, will try to merge the op if possible
643
- * @param in_op the operation we want to push
644
- * @param io_changeset target
645
- * @param the current offset
650
+ * @param in_op - The operation we want to push
651
+ * @param io_changeset - The target
652
+ * @param the - The current offset
646
653
  * @param in_options - Optional additional parameters
647
- * @param in_lastIteratorARemove - Information about the last remove operation in iterator A
648
- * @param in_segment - Segment this operation is part of
654
+ * @param in_lastIteratorARemove - The information about the last remove operation in iterator A
655
+ * @param in_segment - The segment this operation is part of
649
656
  */
650
657
  const pushOp = function (in_op, io_changeset, in_indexOffset, in_options, in_lastIteratorARemove, in_segment) {
651
658
  let writeTargetIndex;
@@ -723,8 +730,8 @@ const pushOp = function (in_op, io_changeset, in_indexOffset, in_options, in_las
723
730
  /**
724
731
  * handle combinations of range operations
725
732
  * e.g. an insert and delete at the same place and same length nullify each other
726
- * @param in_segment the two ops to be combined
727
- * @param in_isPrimitiveType is it an array of primitive types
733
+ * @param in_segment - The two ops to be combined
734
+ * @param in_isPrimitiveType - Is it an array of primitive types
728
735
  * ATTENTION: We overwrite opB to save garbage (instead of creating a result OP)
729
736
  */
730
737
  const handleCombinations = function (in_segment, in_isPrimitiveType) {
@@ -740,13 +747,7 @@ const handleCombinations = function (in_segment, in_isPrimitiveType) {
740
747
  }
741
748
  case ArrayChangeSetIterator.types.REMOVE: {
742
749
  // Attention: B removes A completely, kill A to avoid zero inserts
743
- let opBLen;
744
- if (isNumber(opB.operation[1])) {
745
- opBLen = opB.operation[1];
746
- }
747
- else {
748
- opBLen = opB.operation[1].length;
749
- }
750
+ const opBLen = isNumber(opB.operation[1]) ? opB.operation[1] : opB.operation[1].length;
750
751
  if (opBLen !== opA.operation[1].length) {
751
752
  throw new Error("handleCombinations: insert-remove: unequal number of affected entries");
752
753
  }
@@ -850,21 +851,27 @@ const arraysHaveSameValues = function (in_arr1, in_arr2) {
850
851
  *
851
852
  * We have to handle the conflicting rebase changes. The changes we do, are summarized in this table.
852
853
  * Other is the modified, rebased (on own) changeset.
854
+ *
855
+ * ```
853
856
  * BASE
854
857
  * / \
855
858
  * / \
856
859
  * OWN OTHER
860
+ * ```
857
861
  *
858
862
  * gets rebased to:
859
863
  *
864
+ * ```
860
865
  * BASE
861
866
  * /
862
867
  * OWN
863
868
  * \
864
869
  * OTHER
870
+ * ```
865
871
  *
866
872
  * conflict default behavior in ()
867
873
  *
874
+ * ```
868
875
  * -------|-----------------+------------------+------------------|
869
876
  * \Own| insert | modify | remove |
870
877
  * \ | | | |
@@ -883,16 +890,16 @@ const arraysHaveSameValues = function (in_arr1, in_arr2) {
883
890
  * remove | change | change | change |
884
891
  * | [rem orig. data]| (note the user) | [rem dupl. rem] |
885
892
  * -------|-----------------+------------------+------------------|
893
+ * ```
886
894
  *
887
- * @param {{opA:{}, opB:{}}} in_segment the two ops to be combined
888
- * @param {Array.<property-changeset.ChangeSet.ConflictInfo>} out_conflicts -
889
- * A list of paths that resulted in conflicts together with the type of the conflict
890
- * @param {string} in_basePath -
891
- * Base path to get to the property processed by this function
892
- * @param {boolean} in_isPrimitiveType is it an array of primitive types
895
+ * @param {{opA:{}, opB:{}}} in_segment - The two ops to be combined
896
+ * @param {Array.<property-changeset.ChangeSet.ConflictInfo>} out_conflicts - A list of paths that resulted in
897
+ * conflicts together with the type of the conflict
898
+ * @param {string} in_basePath - Base path to get to the property processed by this function
899
+ * @param {boolean} in_isPrimitiveType - is it an array of primitive types
893
900
  * @param {Object} [in_options] - Optional additional parameters
894
901
  * @param {Map} [in_options.applyAfterMetaInformation] - Additional meta information which help later to obtain
895
- * more compact changeset during the apply operation
902
+ * more compact changeset during the apply operation
896
903
  */
897
904
  const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePath, in_isPrimitiveType, in_options) {
898
905
  const opA = in_segment.opA;
@@ -968,20 +975,8 @@ const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePat
968
975
  }
969
976
  case ArrayChangeSetIterator.types.REMOVE: {
970
977
  // Remove already in A, no need to add the same again -> write nop
971
- let opBLen;
972
- let opALen;
973
- if (isNumber(opB.operation[1])) {
974
- opBLen = opB.operation[1];
975
- }
976
- else {
977
- opBLen = opB.operation[1].length;
978
- }
979
- if (isNumber(opA.operation[1])) {
980
- opALen = opA.operation[1];
981
- }
982
- else {
983
- opALen = opA.operation[1].length;
984
- }
978
+ const opBLen = isNumber(opB.operation[1]) ? opB.operation[1] : opB.operation[1].length;
979
+ const opALen = isNumber(opA.operation[1]) ? opA.operation[1] : opA.operation[1].length;
985
980
  if (opBLen !== opALen) {
986
981
  throw new Error("handleRebaseCombinations: remove-remove: unequal number of affected entries, " +
987
982
  "this should never happen! Probably a bug in splitRange.");
@@ -1068,10 +1063,10 @@ const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePat
1068
1063
  };
1069
1064
  /**
1070
1065
  * apply a range's operation to the changeset
1071
- * @param in_segment to be applied
1072
- * @param io_changeset target
1073
- * @param in_currentIndexOffset current offset
1074
- * @param in_isPrimitiveType is it an array of primitive types
1066
+ * @param in_segment - to be applied
1067
+ * @param io_changeset - target
1068
+ * @param in_currentIndexOffset - current offset
1069
+ * @param in_isPrimitiveType - is it an array of primitive types
1075
1070
  */
1076
1071
  const applySegment = function (in_segment, io_changeset, in_currentIndexOffset, lastIteratorARemove, in_isPrimitiveType, in_options) {
1077
1072
  if (!in_segment) {
@@ -1097,12 +1092,12 @@ const applySegment = function (in_segment, io_changeset, in_currentIndexOffset,
1097
1092
  };
1098
1093
  /**
1099
1094
  * apply a range's operation to the rebased changeset
1100
- * @param in_segment to be applied
1101
- * @param io_changeset target
1102
- * @param in_currentIndexOffset current offset
1095
+ * @param in_segment - to be applied
1096
+ * @param io_changeset - target
1097
+ * @param in_currentIndexOffset - current offset
1103
1098
  * @param out_conflicts - A list of paths that resulted in conflicts together with the type of the conflict
1104
1099
  * @param in_basePath - Base path to get to the property processed by this function
1105
- * @param in_isPrimitiveType is it an array of primitive types
1100
+ * @param in_isPrimitiveType - is it an array of primitive types
1106
1101
  */
1107
1102
  const applyRebaseSegment = function (in_segment, io_changeset, in_currentIndexOffset, out_conflicts, in_basePath, in_isPrimitiveType, in_options) {
1108
1103
  if (!in_segment) {
@@ -1123,6 +1118,7 @@ const applyRebaseSegment = function (in_segment, io_changeset, in_currentIndexOf
1123
1118
  pushOp(in_segment.opB, io_changeset, in_currentIndexOffset, in_options);
1124
1119
  }
1125
1120
  };
1121
+ // eslint-disable-next-line @typescript-eslint/no-namespace
1126
1122
  export var ChangeSetArrayFunctions;
1127
1123
  (function (ChangeSetArrayFunctions) {
1128
1124
  /**
@@ -1130,9 +1126,9 @@ export var ChangeSetArrayFunctions;
1130
1126
  * property root and it will be applied behind the base ChangeSet (assuming that the changes are relative to the
1131
1127
  * state after the base ChangeSet has been applied. It will change the base ChangeSet.)
1132
1128
  *
1133
- * @param io_basePropertyChanges - The ChangeSet describing the initial state
1129
+ * @param io_basePropertyChanges - The ChangeSet describing the initial state
1134
1130
  * @param in_appliedPropertyChanges - The ChangeSet to apply to this state
1135
- * @param in_typeid - The typeid of the contents of the collection (without the collection type)
1131
+ * @param in_typeid - The typeid of the contents of the collection (without the collection type)
1136
1132
  */
1137
1133
  function _performApplyAfterOnPropertyArray(io_basePropertyChanges, in_appliedPropertyChanges, in_typeid, in_options) {
1138
1134
  ConsoleUtils.assert(in_typeid, "_performApplyAfterOnPropertyArray: typeid missing");
@@ -1386,21 +1382,27 @@ export var ChangeSetArrayFunctions;
1386
1382
  *
1387
1383
  * We have to handle the conflicting rebase changes. The changes we do, are summarized in this table.
1388
1384
  * Other is the modified, rebased (on own) changeset.
1385
+ *
1386
+ * ```
1389
1387
  * BASE
1390
1388
  * / \
1391
1389
  * / \
1392
1390
  * OWN OTHER
1391
+ * ```
1393
1392
  *
1394
1393
  * gets rebased to:
1395
1394
  *
1395
+ * ```
1396
1396
  * BASE
1397
1397
  * /
1398
1398
  * OWN
1399
1399
  * \
1400
1400
  * OTHER
1401
+ * ```
1401
1402
  *
1402
1403
  * conflict default behavior in ()
1403
1404
  *
1405
+ * ```
1404
1406
  * -------|-----------------+------------------+------------------|----------------|
1405
1407
  * \Own| insert | modify | remove | String set |
1406
1408
  * \ | | | | |
@@ -1421,10 +1423,11 @@ export var ChangeSetArrayFunctions;
1421
1423
  * set | 'other's set overwrites whatever happend before |
1422
1424
  * | | | | |
1423
1425
  * --------------------------------------------------------------------------------|
1426
+ * ```
1424
1427
  *
1425
1428
  * @param in_ownPropertyChangeSet - The ChangeSet for the property stored in this object
1426
1429
  * @param io_rebasePropertyChangeSetParent - The Array containing the ChangeSet for the property to be rebased
1427
- * @param in_key the key to the ChangeSet in io_rebasePropertyChangeSetParent we are rebasing on
1430
+ * @param in_key - The key to the ChangeSet in io_rebasePropertyChangeSetParent we are rebasing on
1428
1431
  * @param in_basePath - Base path to get to the property processed by this function
1429
1432
  * @param out_conflicts - A list of paths that resulted in conflicts together with the type of the conflict
1430
1433
  */