@fluidframework/merge-tree 2.0.0-internal.8.0.0 → 2.0.0-rc.1.0.0
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/CHANGELOG.md +38 -0
- package/README.md +0 -6
- package/api-extractor-esm.json +17 -0
- package/api-extractor-lint.json +1 -10
- package/api-extractor.json +0 -4
- package/api-report/merge-tree.api.md +4 -9
- package/dist/client.d.ts +0 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +0 -7
- package/dist/client.js.map +1 -1
- package/dist/merge-tree-alpha.d.ts +27 -12
- package/dist/merge-tree-beta.d.ts +0 -16
- package/dist/merge-tree-public.d.ts +0 -16
- package/dist/merge-tree-untrimmed.d.ts +5 -29
- package/dist/mergeTree.d.ts +0 -17
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +0 -130
- package/dist/mergeTree.js.map +1 -1
- package/dist/ops.d.ts +1 -1
- package/dist/ops.js +1 -1
- package/dist/ops.js.map +1 -1
- package/dist/revertibles.d.ts +4 -4
- package/dist/revertibles.js +3 -3
- package/dist/revertibles.js.map +1 -1
- package/dist/test/Insertion.perf.spec.d.ts +6 -0
- package/dist/test/Insertion.perf.spec.d.ts.map +1 -0
- package/dist/test/Insertion.perf.spec.js +113 -0
- package/dist/test/Insertion.perf.spec.js.map +1 -0
- package/dist/test/PartialLengths.perf.spec.d.ts +6 -0
- package/dist/test/PartialLengths.perf.spec.d.ts.map +1 -0
- package/dist/test/PartialLengths.perf.spec.js +67 -0
- package/dist/test/PartialLengths.perf.spec.js.map +1 -0
- package/dist/test/Removal.perf.spec.d.ts +6 -0
- package/dist/test/Removal.perf.spec.d.ts.map +1 -0
- package/dist/test/Removal.perf.spec.js +166 -0
- package/dist/test/Removal.perf.spec.js.map +1 -0
- package/dist/test/Snapshot.perf.spec.d.ts +6 -0
- package/dist/test/Snapshot.perf.spec.d.ts.map +1 -0
- package/dist/test/Snapshot.perf.spec.js +33 -0
- package/dist/test/Snapshot.perf.spec.js.map +1 -0
- package/dist/test/attributionCollection.perf.spec.d.ts +6 -0
- package/dist/test/attributionCollection.perf.spec.d.ts.map +1 -0
- package/dist/test/attributionCollection.perf.spec.js +231 -0
- package/dist/test/attributionCollection.perf.spec.js.map +1 -0
- package/dist/test/attributionCollection.spec.d.ts +6 -0
- package/dist/test/attributionCollection.spec.d.ts.map +1 -0
- package/dist/test/attributionCollection.spec.js +486 -0
- package/dist/test/attributionCollection.spec.js.map +1 -0
- package/dist/test/attributionPolicy.spec.d.ts +6 -0
- package/dist/test/attributionPolicy.spec.d.ts.map +1 -0
- package/dist/test/attributionPolicy.spec.js +189 -0
- package/dist/test/attributionPolicy.spec.js.map +1 -0
- package/dist/test/beastTest.d.ts +54 -0
- package/dist/test/beastTest.d.ts.map +1 -0
- package/dist/test/beastTest.js +1333 -0
- package/dist/test/beastTest.js.map +1 -0
- package/dist/test/client.annotateMarker.spec.d.ts +6 -0
- package/dist/test/client.annotateMarker.spec.d.ts.map +1 -0
- package/dist/test/client.annotateMarker.spec.js +45 -0
- package/dist/test/client.annotateMarker.spec.js.map +1 -0
- package/dist/test/client.apis.d.ts +7 -0
- package/dist/test/client.apis.d.ts.map +1 -0
- package/dist/test/client.apis.js +72 -0
- package/dist/test/client.apis.js.map +1 -0
- package/dist/test/client.applyMsg.spec.d.ts +6 -0
- package/dist/test/client.applyMsg.spec.d.ts.map +1 -0
- package/dist/test/client.applyMsg.spec.js +500 -0
- package/dist/test/client.applyMsg.spec.js.map +1 -0
- package/dist/test/client.applyStashedOpFarm.spec.d.ts +12 -0
- package/dist/test/client.applyStashedOpFarm.spec.d.ts.map +1 -0
- package/dist/test/client.applyStashedOpFarm.spec.js +144 -0
- package/dist/test/client.applyStashedOpFarm.spec.js.map +1 -0
- package/dist/test/client.attributionFarm.spec.d.ts +7 -0
- package/dist/test/client.attributionFarm.spec.d.ts.map +1 -0
- package/dist/test/client.attributionFarm.spec.js +96 -0
- package/dist/test/client.attributionFarm.spec.js.map +1 -0
- package/dist/test/client.conflictFarm.spec.d.ts +15 -0
- package/dist/test/client.conflictFarm.spec.d.ts.map +1 -0
- package/dist/test/client.conflictFarm.spec.js +88 -0
- package/dist/test/client.conflictFarm.spec.js.map +1 -0
- package/dist/test/client.getPosition.spec.d.ts +6 -0
- package/dist/test/client.getPosition.spec.d.ts.map +1 -0
- package/dist/test/client.getPosition.spec.js +54 -0
- package/dist/test/client.getPosition.spec.js.map +1 -0
- package/dist/test/client.localReference.spec.d.ts +6 -0
- package/dist/test/client.localReference.spec.d.ts.map +1 -0
- package/dist/test/client.localReference.spec.js +439 -0
- package/dist/test/client.localReference.spec.js.map +1 -0
- package/dist/test/client.localReferenceFarm.spec.d.ts +6 -0
- package/dist/test/client.localReferenceFarm.spec.d.ts.map +1 -0
- package/dist/test/client.localReferenceFarm.spec.js +88 -0
- package/dist/test/client.localReferenceFarm.spec.js.map +1 -0
- package/dist/test/client.rebasePosition.spec.d.ts +6 -0
- package/dist/test/client.rebasePosition.spec.d.ts.map +1 -0
- package/dist/test/client.rebasePosition.spec.js +102 -0
- package/dist/test/client.rebasePosition.spec.js.map +1 -0
- package/dist/test/client.reconnectFarm.spec.d.ts +12 -0
- package/dist/test/client.reconnectFarm.spec.d.ts.map +1 -0
- package/dist/test/client.reconnectFarm.spec.js +91 -0
- package/dist/test/client.reconnectFarm.spec.js.map +1 -0
- package/dist/test/client.replay.spec.d.ts +6 -0
- package/dist/test/client.replay.spec.d.ts.map +1 -0
- package/dist/test/client.replay.spec.js +85 -0
- package/dist/test/client.replay.spec.js.map +1 -0
- package/dist/test/client.rollback.spec.d.ts +6 -0
- package/dist/test/client.rollback.spec.d.ts.map +1 -0
- package/dist/test/client.rollback.spec.js +453 -0
- package/dist/test/client.rollback.spec.js.map +1 -0
- package/dist/test/client.rollbackFarm.spec.d.ts +6 -0
- package/dist/test/client.rollbackFarm.spec.d.ts.map +1 -0
- package/dist/test/client.rollbackFarm.spec.js +48 -0
- package/dist/test/client.rollbackFarm.spec.js.map +1 -0
- package/dist/test/client.searchForMarker.spec.d.ts +6 -0
- package/dist/test/client.searchForMarker.spec.d.ts.map +1 -0
- package/dist/test/client.searchForMarker.spec.js +446 -0
- package/dist/test/client.searchForMarker.spec.js.map +1 -0
- package/dist/test/client.walkSegments.spec.d.ts +6 -0
- package/dist/test/client.walkSegments.spec.d.ts.map +1 -0
- package/dist/test/client.walkSegments.spec.js +54 -0
- package/dist/test/client.walkSegments.spec.js.map +1 -0
- package/dist/test/collections.list.spec.d.ts +6 -0
- package/dist/test/collections.list.spec.d.ts.map +1 -0
- package/dist/test/collections.list.spec.js +84 -0
- package/dist/test/collections.list.spec.js.map +1 -0
- package/dist/test/createInsertOnlyAttributionPolicy.spec.d.ts +6 -0
- package/dist/test/createInsertOnlyAttributionPolicy.spec.d.ts.map +1 -0
- package/dist/test/createInsertOnlyAttributionPolicy.spec.js +35 -0
- package/dist/test/createInsertOnlyAttributionPolicy.spec.js.map +1 -0
- package/dist/test/index.d.ts +13 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +88 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/mergeTree.annotate.deltaCallback.spec.d.ts +6 -0
- package/dist/test/mergeTree.annotate.deltaCallback.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.annotate.deltaCallback.spec.js +142 -0
- package/dist/test/mergeTree.annotate.deltaCallback.spec.js.map +1 -0
- package/dist/test/mergeTree.annotate.spec.d.ts +6 -0
- package/dist/test/mergeTree.annotate.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.annotate.spec.js +448 -0
- package/dist/test/mergeTree.annotate.spec.js.map +1 -0
- package/dist/test/mergeTree.insert.deltaCallback.spec.d.ts +6 -0
- package/dist/test/mergeTree.insert.deltaCallback.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.insert.deltaCallback.spec.js +126 -0
- package/dist/test/mergeTree.insert.deltaCallback.spec.js.map +1 -0
- package/dist/test/mergeTree.insertingWalk.spec.d.ts +6 -0
- package/dist/test/mergeTree.insertingWalk.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.insertingWalk.spec.js +279 -0
- package/dist/test/mergeTree.insertingWalk.spec.js.map +1 -0
- package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.d.ts +6 -0
- package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.js +178 -0
- package/dist/test/mergeTree.markRangeRemoved.deltaCallback.spec.js.map +1 -0
- package/dist/test/mergeTree.markRangeRemoved.spec.d.ts +6 -0
- package/dist/test/mergeTree.markRangeRemoved.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.markRangeRemoved.spec.js +130 -0
- package/dist/test/mergeTree.markRangeRemoved.spec.js.map +1 -0
- package/dist/test/mergeTree.walk.spec.d.ts +6 -0
- package/dist/test/mergeTree.walk.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.walk.spec.js +63 -0
- package/dist/test/mergeTree.walk.spec.js.map +1 -0
- package/dist/test/mergeTree.zamboni.spec.d.ts +6 -0
- package/dist/test/mergeTree.zamboni.spec.d.ts.map +1 -0
- package/dist/test/mergeTree.zamboni.spec.js +52 -0
- package/dist/test/mergeTree.zamboni.spec.js.map +1 -0
- package/dist/test/mergeTreeOperationRunner.d.ts +63 -0
- package/dist/test/mergeTreeOperationRunner.d.ts.map +1 -0
- package/dist/test/mergeTreeOperationRunner.js +245 -0
- package/dist/test/mergeTreeOperationRunner.js.map +1 -0
- package/dist/test/mergeTreeOperationRunner.spec.d.ts +6 -0
- package/dist/test/mergeTreeOperationRunner.spec.d.ts.map +1 -0
- package/dist/test/mergeTreeOperationRunner.spec.js +156 -0
- package/dist/test/mergeTreeOperationRunner.spec.js.map +1 -0
- package/dist/test/obliterate.concurrent.spec.d.ts +6 -0
- package/dist/test/obliterate.concurrent.spec.d.ts.map +1 -0
- package/dist/test/obliterate.concurrent.spec.js +1446 -0
- package/dist/test/obliterate.concurrent.spec.js.map +1 -0
- package/dist/test/obliterate.partialLength.spec.d.ts +6 -0
- package/dist/test/obliterate.partialLength.spec.d.ts.map +1 -0
- package/dist/test/obliterate.partialLength.spec.js +279 -0
- package/dist/test/obliterate.partialLength.spec.js.map +1 -0
- package/dist/test/obliterate.reconnect.spec.d.ts +6 -0
- package/dist/test/obliterate.reconnect.spec.d.ts.map +1 -0
- package/dist/test/obliterate.reconnect.spec.js +164 -0
- package/dist/test/obliterate.reconnect.spec.js.map +1 -0
- package/dist/test/obliterate.spec.d.ts +6 -0
- package/dist/test/obliterate.spec.d.ts.map +1 -0
- package/dist/test/obliterate.spec.js +162 -0
- package/dist/test/obliterate.spec.js.map +1 -0
- package/dist/test/ordinal.spec.d.ts +2 -0
- package/dist/test/ordinal.spec.d.ts.map +1 -0
- package/dist/test/ordinal.spec.js +43 -0
- package/dist/test/ordinal.spec.js.map +1 -0
- package/dist/test/partialLength.spec.d.ts +6 -0
- package/dist/test/partialLength.spec.d.ts.map +1 -0
- package/dist/test/partialLength.spec.js +282 -0
- package/dist/test/partialLength.spec.js.map +1 -0
- package/dist/test/properties.spec.d.ts +6 -0
- package/dist/test/properties.spec.d.ts.map +1 -0
- package/dist/test/properties.spec.js +55 -0
- package/dist/test/properties.spec.js.map +1 -0
- package/dist/test/reconnectHelper.d.ts +48 -0
- package/dist/test/reconnectHelper.d.ts.map +1 -0
- package/dist/test/reconnectHelper.js +86 -0
- package/dist/test/reconnectHelper.js.map +1 -0
- package/dist/test/resetPendingSegmentsToOp.spec.d.ts +6 -0
- package/dist/test/resetPendingSegmentsToOp.spec.d.ts.map +1 -0
- package/dist/test/resetPendingSegmentsToOp.spec.js +218 -0
- package/dist/test/resetPendingSegmentsToOp.spec.js.map +1 -0
- package/dist/test/revertibleFarm.spec.d.ts +6 -0
- package/dist/test/revertibleFarm.spec.d.ts.map +1 -0
- package/dist/test/revertibleFarm.spec.js +124 -0
- package/dist/test/revertibleFarm.spec.js.map +1 -0
- package/dist/test/revertibles.spec.d.ts +17 -0
- package/dist/test/revertibles.spec.d.ts.map +1 -0
- package/dist/test/revertibles.spec.js +385 -0
- package/dist/test/revertibles.spec.js.map +1 -0
- package/dist/test/segmentGroupCollection.spec.d.ts +6 -0
- package/dist/test/segmentGroupCollection.spec.d.ts.map +1 -0
- package/dist/test/segmentGroupCollection.spec.js +60 -0
- package/dist/test/segmentGroupCollection.spec.js.map +1 -0
- package/dist/test/snapshot.spec.d.ts +6 -0
- package/dist/test/snapshot.spec.d.ts.map +1 -0
- package/dist/test/snapshot.spec.js +178 -0
- package/dist/test/snapshot.spec.js.map +1 -0
- package/dist/test/snapshot.utils.d.ts +33 -0
- package/dist/test/snapshot.utils.d.ts.map +1 -0
- package/dist/test/snapshot.utils.js +109 -0
- package/dist/test/snapshot.utils.js.map +1 -0
- package/dist/test/snapshotlegacy.spec.d.ts +6 -0
- package/dist/test/snapshotlegacy.spec.d.ts.map +1 -0
- package/dist/test/snapshotlegacy.spec.js +139 -0
- package/dist/test/snapshotlegacy.spec.js.map +1 -0
- package/dist/test/sortedSegmentSet.spec.d.ts +6 -0
- package/dist/test/sortedSegmentSet.spec.d.ts.map +1 -0
- package/dist/test/sortedSegmentSet.spec.js +95 -0
- package/dist/test/sortedSegmentSet.spec.js.map +1 -0
- package/dist/test/testClient.d.ts +119 -0
- package/dist/test/testClient.d.ts.map +1 -0
- package/dist/test/testClient.js +439 -0
- package/dist/test/testClient.js.map +1 -0
- package/dist/test/testClientLogger.d.ts +44 -0
- package/dist/test/testClientLogger.d.ts.map +1 -0
- package/dist/test/testClientLogger.js +287 -0
- package/dist/test/testClientLogger.js.map +1 -0
- package/dist/test/testSerializer.d.ts +18 -0
- package/dist/test/testSerializer.d.ts.map +1 -0
- package/dist/test/testSerializer.js +33 -0
- package/dist/test/testSerializer.js.map +1 -0
- package/dist/test/testServer.d.ts +36 -0
- package/dist/test/testServer.d.ts.map +1 -0
- package/dist/test/testServer.js +138 -0
- package/dist/test/testServer.js.map +1 -0
- package/dist/test/testUtils.d.ts +69 -0
- package/dist/test/testUtils.d.ts.map +1 -0
- package/dist/test/testUtils.js +149 -0
- package/dist/test/testUtils.js.map +1 -0
- package/dist/test/text.d.ts +9 -0
- package/dist/test/text.d.ts.map +1 -0
- package/dist/test/text.js +76 -0
- package/dist/test/text.js.map +1 -0
- package/dist/test/tracking.spec.d.ts +6 -0
- package/dist/test/tracking.spec.d.ts.map +1 -0
- package/dist/test/tracking.spec.js +120 -0
- package/dist/test/tracking.spec.js.map +1 -0
- package/dist/test/wordUnitTests.d.ts +6 -0
- package/dist/test/wordUnitTests.d.ts.map +1 -0
- package/dist/test/wordUnitTests.js +172 -0
- package/dist/test/wordUnitTests.js.map +1 -0
- package/lib/{MergeTreeTextHelper.d.ts → MergeTreeTextHelper.d.mts} +3 -3
- package/lib/MergeTreeTextHelper.d.mts.map +1 -0
- package/lib/{MergeTreeTextHelper.js → MergeTreeTextHelper.mjs} +5 -10
- package/lib/MergeTreeTextHelper.mjs.map +1 -0
- package/lib/{attributionCollection.d.ts → attributionCollection.d.mts} +2 -2
- package/lib/attributionCollection.d.mts.map +1 -0
- package/lib/{attributionCollection.js → attributionCollection.mjs} +9 -14
- package/lib/attributionCollection.mjs.map +1 -0
- package/lib/{attributionPolicy.d.ts → attributionPolicy.d.mts} +2 -2
- package/lib/attributionPolicy.d.mts.map +1 -0
- package/lib/{attributionPolicy.js → attributionPolicy.mjs} +21 -27
- package/lib/attributionPolicy.mjs.map +1 -0
- package/lib/{client.d.ts → client.d.mts} +9 -16
- package/lib/client.d.mts.map +1 -0
- package/lib/{client.js → client.mjs} +101 -110
- package/lib/client.mjs.map +1 -0
- package/lib/collections/{index.d.ts → index.d.mts} +3 -3
- package/lib/collections/index.d.mts.map +1 -0
- package/lib/collections/index.mjs +7 -0
- package/lib/collections/index.mjs.map +1 -0
- package/lib/collections/{list.d.ts → list.d.mts} +1 -1
- package/lib/collections/list.d.mts.map +1 -0
- package/lib/collections/{list.js → list.mjs} +6 -11
- package/lib/collections/list.mjs.map +1 -0
- package/lib/collections/{rbTree.d.ts → rbTree.d.mts} +1 -1
- package/lib/collections/rbTree.d.mts.map +1 -0
- package/lib/collections/{rbTree.js → rbTree.mjs} +16 -20
- package/lib/collections/rbTree.mjs.map +1 -0
- package/lib/{constants.d.ts → constants.d.mts} +1 -1
- package/lib/constants.d.mts.map +1 -0
- package/lib/constants.mjs +32 -0
- package/lib/constants.mjs.map +1 -0
- package/lib/{endOfTreeSegment.d.ts → endOfTreeSegment.d.mts} +4 -4
- package/lib/endOfTreeSegment.d.mts.map +1 -0
- package/lib/{endOfTreeSegment.js → endOfTreeSegment.mjs} +13 -18
- package/lib/endOfTreeSegment.mjs.map +1 -0
- package/lib/{index.d.ts → index.d.mts} +21 -21
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +24 -0
- package/lib/index.mjs.map +1 -0
- package/lib/{localReference.d.ts → localReference.d.mts} +7 -7
- package/lib/localReference.d.mts.map +1 -0
- package/lib/{localReference.js → localReference.mjs} +38 -47
- package/lib/localReference.mjs.map +1 -0
- package/lib/{merge-tree-alpha.d.ts → merge-tree-alpha.d.mts} +27 -12
- package/lib/{merge-tree-beta.d.ts → merge-tree-beta.d.mts} +0 -16
- package/lib/{merge-tree-public.d.ts → merge-tree-public.d.mts} +0 -16
- package/lib/{merge-tree-untrimmed.d.ts → merge-tree-untrimmed.d.mts} +5 -29
- package/lib/{mergeTree.d.ts → mergeTree.d.mts} +12 -29
- package/lib/mergeTree.d.mts.map +1 -0
- package/lib/{mergeTree.js → mergeTree.mjs} +203 -340
- package/lib/mergeTree.mjs.map +1 -0
- package/lib/{mergeTreeDeltaCallback.d.ts → mergeTreeDeltaCallback.d.mts} +4 -8
- package/lib/mergeTreeDeltaCallback.d.mts.map +1 -0
- package/lib/{mergeTreeDeltaCallback.js → mergeTreeDeltaCallback.mjs} +2 -5
- package/lib/mergeTreeDeltaCallback.mjs.map +1 -0
- package/lib/{mergeTreeNodeWalk.d.ts → mergeTreeNodeWalk.d.mts} +2 -2
- package/lib/mergeTreeNodeWalk.d.mts.map +1 -0
- package/lib/{mergeTreeNodeWalk.js → mergeTreeNodeWalk.mjs} +14 -21
- package/lib/mergeTreeNodeWalk.mjs.map +1 -0
- package/lib/{mergeTreeNodes.d.ts → mergeTreeNodes.d.mts} +12 -12
- package/lib/mergeTreeNodes.d.mts.map +1 -0
- package/lib/{mergeTreeNodes.js → mergeTreeNodes.mjs} +60 -76
- package/lib/mergeTreeNodes.mjs.map +1 -0
- package/lib/{mergeTreeTracking.d.ts → mergeTreeTracking.d.mts} +3 -3
- package/lib/mergeTreeTracking.d.mts.map +1 -0
- package/lib/{mergeTreeTracking.js → mergeTreeTracking.mjs} +6 -13
- package/lib/mergeTreeTracking.mjs.map +1 -0
- package/lib/{opBuilder.d.ts → opBuilder.d.mts} +4 -4
- package/lib/opBuilder.d.mts.map +1 -0
- package/lib/{opBuilder.js → opBuilder.mjs} +15 -25
- package/lib/opBuilder.mjs.map +1 -0
- package/lib/{ops.d.ts → ops.d.mts} +2 -2
- package/lib/ops.d.mts.map +1 -0
- package/lib/{ops.js → ops.mjs} +5 -8
- package/lib/ops.mjs.map +1 -0
- package/lib/{ordinal.d.ts → ordinal.d.mts} +1 -1
- package/lib/ordinal.d.mts.map +1 -0
- package/lib/{ordinal.js → ordinal.mjs} +4 -9
- package/lib/ordinal.mjs.map +1 -0
- package/lib/{partialLengths.d.ts → partialLengths.d.mts} +4 -4
- package/lib/partialLengths.d.mts.map +1 -0
- package/lib/{partialLengths.js → partialLengths.mjs} +38 -46
- package/lib/partialLengths.mjs.map +1 -0
- package/lib/{properties.d.ts → properties.d.mts} +1 -1
- package/lib/properties.d.mts.map +1 -0
- package/lib/{properties.js → properties.mjs} +7 -16
- package/lib/properties.mjs.map +1 -0
- package/lib/{referencePositions.d.ts → referencePositions.d.mts} +5 -5
- package/lib/referencePositions.d.mts.map +1 -0
- package/lib/referencePositions.mjs +70 -0
- package/lib/referencePositions.mjs.map +1 -0
- package/lib/{revertibles.d.ts → revertibles.d.mts} +12 -12
- package/lib/revertibles.d.mts.map +1 -0
- package/lib/{revertibles.js → revertibles.mjs} +60 -67
- package/lib/revertibles.mjs.map +1 -0
- package/lib/{segmentGroupCollection.d.ts → segmentGroupCollection.d.mts} +2 -2
- package/lib/segmentGroupCollection.d.mts.map +1 -0
- package/lib/{segmentGroupCollection.js → segmentGroupCollection.mjs} +5 -9
- package/lib/segmentGroupCollection.mjs.map +1 -0
- package/lib/{segmentPropertiesManager.d.ts → segmentPropertiesManager.d.mts} +3 -3
- package/lib/segmentPropertiesManager.d.mts.map +1 -0
- package/lib/{segmentPropertiesManager.js → segmentPropertiesManager.mjs} +14 -20
- package/lib/{segmentPropertiesManager.js.map → segmentPropertiesManager.mjs.map} +1 -1
- package/lib/{snapshotChunks.d.ts → snapshotChunks.d.mts} +4 -4
- package/lib/snapshotChunks.d.mts.map +1 -0
- package/lib/{snapshotChunks.js → snapshotChunks.mjs} +10 -17
- package/lib/snapshotChunks.mjs.map +1 -0
- package/lib/{snapshotLoader.d.ts → snapshotLoader.d.mts} +3 -3
- package/lib/snapshotLoader.d.mts.map +1 -0
- package/lib/{snapshotLoader.js → snapshotLoader.mjs} +33 -38
- package/lib/snapshotLoader.mjs.map +1 -0
- package/lib/{snapshotV1.d.ts → snapshotV1.d.mts} +4 -4
- package/lib/snapshotV1.d.mts.map +1 -0
- package/lib/{snapshotV1.js → snapshotV1.mjs} +28 -32
- package/lib/snapshotV1.mjs.map +1 -0
- package/lib/{snapshotlegacy.d.ts → snapshotlegacy.d.mts} +3 -3
- package/lib/snapshotlegacy.d.mts.map +1 -0
- package/lib/{snapshotlegacy.js → snapshotlegacy.mjs} +21 -26
- package/lib/snapshotlegacy.mjs.map +1 -0
- package/lib/{sortedSegmentSet.d.ts → sortedSegmentSet.d.mts} +4 -4
- package/lib/sortedSegmentSet.d.mts.map +1 -0
- package/lib/{sortedSegmentSet.js → sortedSegmentSet.mjs} +3 -8
- package/lib/sortedSegmentSet.mjs.map +1 -0
- package/lib/{sortedSet.d.ts → sortedSet.d.mts} +1 -1
- package/lib/sortedSet.d.mts.map +1 -0
- package/lib/{sortedSet.js → sortedSet.mjs} +2 -6
- package/lib/sortedSet.mjs.map +1 -0
- package/lib/{textSegment.d.ts → textSegment.d.mts} +4 -4
- package/lib/textSegment.d.mts.map +1 -0
- package/lib/{textSegment.js → textSegment.mjs} +8 -12
- package/lib/textSegment.mjs.map +1 -0
- package/lib/{zamboni.d.ts → zamboni.d.mts} +3 -3
- package/lib/zamboni.d.mts.map +1 -0
- package/lib/{zamboni.js → zamboni.mjs} +22 -28
- package/lib/zamboni.mjs.map +1 -0
- package/package.json +95 -164
- package/src/client.ts +0 -8
- package/src/mergeTree.ts +0 -226
- package/src/ops.ts +1 -1
- package/src/revertibles.ts +4 -4
- package/lib/MergeTreeTextHelper.d.ts.map +0 -1
- package/lib/MergeTreeTextHelper.js.map +0 -1
- package/lib/attributionCollection.d.ts.map +0 -1
- package/lib/attributionCollection.js.map +0 -1
- package/lib/attributionPolicy.d.ts.map +0 -1
- package/lib/attributionPolicy.js.map +0 -1
- package/lib/client.d.ts.map +0 -1
- package/lib/client.js.map +0 -1
- package/lib/collections/index.d.ts.map +0 -1
- package/lib/collections/index.js +0 -14
- package/lib/collections/index.js.map +0 -1
- package/lib/collections/list.d.ts.map +0 -1
- package/lib/collections/list.js.map +0 -1
- package/lib/collections/rbTree.d.ts.map +0 -1
- package/lib/collections/rbTree.js.map +0 -1
- package/lib/constants.d.ts.map +0 -1
- package/lib/constants.js +0 -35
- package/lib/constants.js.map +0 -1
- package/lib/endOfTreeSegment.d.ts.map +0 -1
- package/lib/endOfTreeSegment.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -80
- package/lib/index.js.map +0 -1
- package/lib/localReference.d.ts.map +0 -1
- package/lib/localReference.js.map +0 -1
- package/lib/mergeTree.d.ts.map +0 -1
- package/lib/mergeTree.js.map +0 -1
- package/lib/mergeTreeDeltaCallback.d.ts.map +0 -1
- package/lib/mergeTreeDeltaCallback.js.map +0 -1
- package/lib/mergeTreeNodeWalk.d.ts.map +0 -1
- package/lib/mergeTreeNodeWalk.js.map +0 -1
- package/lib/mergeTreeNodes.d.ts.map +0 -1
- package/lib/mergeTreeNodes.js.map +0 -1
- package/lib/mergeTreeTracking.d.ts.map +0 -1
- package/lib/mergeTreeTracking.js.map +0 -1
- package/lib/opBuilder.d.ts.map +0 -1
- package/lib/opBuilder.js.map +0 -1
- package/lib/ops.d.ts.map +0 -1
- package/lib/ops.js.map +0 -1
- package/lib/ordinal.d.ts.map +0 -1
- package/lib/ordinal.js.map +0 -1
- package/lib/partialLengths.d.ts.map +0 -1
- package/lib/partialLengths.js.map +0 -1
- package/lib/properties.d.ts.map +0 -1
- package/lib/properties.js.map +0 -1
- package/lib/referencePositions.d.ts.map +0 -1
- package/lib/referencePositions.js +0 -80
- package/lib/referencePositions.js.map +0 -1
- package/lib/revertibles.d.ts.map +0 -1
- package/lib/revertibles.js.map +0 -1
- package/lib/segmentGroupCollection.d.ts.map +0 -1
- package/lib/segmentGroupCollection.js.map +0 -1
- package/lib/segmentPropertiesManager.d.ts.map +0 -1
- package/lib/snapshotChunks.d.ts.map +0 -1
- package/lib/snapshotChunks.js.map +0 -1
- package/lib/snapshotLoader.d.ts.map +0 -1
- package/lib/snapshotLoader.js.map +0 -1
- package/lib/snapshotV1.d.ts.map +0 -1
- package/lib/snapshotV1.js.map +0 -1
- package/lib/snapshotlegacy.d.ts.map +0 -1
- package/lib/snapshotlegacy.js.map +0 -1
- package/lib/sortedSegmentSet.d.ts.map +0 -1
- package/lib/sortedSegmentSet.js.map +0 -1
- package/lib/sortedSet.d.ts.map +0 -1
- package/lib/sortedSet.js.map +0 -1
- package/lib/textSegment.d.ts.map +0 -1
- package/lib/textSegment.js.map +0 -1
- package/lib/zamboni.d.ts.map +0 -1
- package/lib/zamboni.js.map +0 -1
- package/merge-tree.test-files.tar +0 -0
- package/src/mergeTreeExample1.pdf +0 -0
- package/tsconfig.esnext.json +0 -6
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const assert_1 = require("assert");
|
|
8
|
+
const stochastic_test_utils_1 = require("@fluid-private/stochastic-test-utils");
|
|
9
|
+
const attributionCollection_1 = require("../attributionCollection");
|
|
10
|
+
const mergeTreeNodes_1 = require("../mergeTreeNodes");
|
|
11
|
+
const opKey = (seq) => ({ type: "op", seq });
|
|
12
|
+
const detachedKey = { type: "detached", id: 0 };
|
|
13
|
+
describe("AttributionCollection", () => {
|
|
14
|
+
const makeCollectionWithChannel = ({ length, seq }) => {
|
|
15
|
+
const collection = new attributionCollection_1.AttributionCollection(length, null);
|
|
16
|
+
collection.update("foo", new attributionCollection_1.AttributionCollection(length, opKey(seq)));
|
|
17
|
+
return collection;
|
|
18
|
+
};
|
|
19
|
+
describe(".getAtOffset", () => {
|
|
20
|
+
describe("on a collection with a single entry", () => {
|
|
21
|
+
const collection = new attributionCollection_1.AttributionCollection(5, opKey(100));
|
|
22
|
+
it("returns the entry for offsets within the length range", () => {
|
|
23
|
+
for (let i = 0; i < 5; i++) {
|
|
24
|
+
assert_1.strict.deepEqual(collection.getAtOffset(i), opKey(100));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
it("throws for queries outside the range", () => {
|
|
28
|
+
assert_1.strict.throws(() => collection.getAtOffset(-1));
|
|
29
|
+
assert_1.strict.throws(() => collection.getAtOffset(5));
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe("on a collection with multiple entries", () => {
|
|
33
|
+
const collection = new attributionCollection_1.AttributionCollection(3, opKey(100));
|
|
34
|
+
collection.append(new attributionCollection_1.AttributionCollection(5, opKey(101)));
|
|
35
|
+
it("returns the correct entries", () => {
|
|
36
|
+
for (let i = 0; i < 3; i++) {
|
|
37
|
+
assert_1.strict.deepEqual(collection.getAtOffset(i), opKey(100));
|
|
38
|
+
}
|
|
39
|
+
for (let i = 3; i < 8; i++) {
|
|
40
|
+
assert_1.strict.deepEqual(collection.getAtOffset(i), opKey(101));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
it("works on collections with entries in channels", () => {
|
|
45
|
+
const collection = makeCollectionWithChannel({ length: 3, seq: 300 });
|
|
46
|
+
for (const offset of [0, 1, 2]) {
|
|
47
|
+
assert_1.strict.deepEqual(collection.getAtOffset(offset, "foo"), opKey(300));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe(".splitAt", () => {
|
|
52
|
+
describe("on a collection with 3 entries", () => {
|
|
53
|
+
let collection;
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
collection = new attributionCollection_1.AttributionCollection(3, opKey(100));
|
|
56
|
+
collection.append(new attributionCollection_1.AttributionCollection(2, opKey(101)));
|
|
57
|
+
collection.append(new attributionCollection_1.AttributionCollection(1, opKey(102)));
|
|
58
|
+
});
|
|
59
|
+
it("can split on non-breakpoints", () => {
|
|
60
|
+
const splitCollection = collection.splitAt(4);
|
|
61
|
+
assert_1.strict.deepEqual(collection.getAll().root, [
|
|
62
|
+
{ offset: 0, key: opKey(100) },
|
|
63
|
+
{ offset: 3, key: opKey(101) },
|
|
64
|
+
]);
|
|
65
|
+
assert_1.strict.equal(collection.length, 4);
|
|
66
|
+
assert_1.strict.deepEqual(splitCollection.getAll().root, [
|
|
67
|
+
{ offset: 0, key: opKey(101) },
|
|
68
|
+
{ offset: 1, key: opKey(102) },
|
|
69
|
+
]);
|
|
70
|
+
assert_1.strict.equal(splitCollection.length, 2);
|
|
71
|
+
});
|
|
72
|
+
it("can split on breakpoints", () => {
|
|
73
|
+
const splitCollection = collection.splitAt(5);
|
|
74
|
+
assert_1.strict.deepEqual(collection.getAll().root, [
|
|
75
|
+
{ offset: 0, key: opKey(100) },
|
|
76
|
+
{ offset: 3, key: opKey(101) },
|
|
77
|
+
]);
|
|
78
|
+
assert_1.strict.equal(collection.length, 5);
|
|
79
|
+
assert_1.strict.deepEqual(splitCollection.getAll().root, [{ offset: 0, key: opKey(102) }]);
|
|
80
|
+
assert_1.strict.equal(splitCollection.length, 1);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
it("can split collection with a single value", () => {
|
|
84
|
+
const collection = new attributionCollection_1.AttributionCollection(5, opKey(100));
|
|
85
|
+
const splitCollection = collection.splitAt(3);
|
|
86
|
+
assert_1.strict.equal(collection.length, 3);
|
|
87
|
+
assert_1.strict.equal(splitCollection.length, 2);
|
|
88
|
+
assert_1.strict.deepEqual(collection.getAll().root, [{ offset: 0, key: opKey(100) }]);
|
|
89
|
+
assert_1.strict.deepEqual(splitCollection.getAll().root, [{ offset: 0, key: opKey(100) }]);
|
|
90
|
+
});
|
|
91
|
+
it("splits channels", () => {
|
|
92
|
+
const collection = new attributionCollection_1.AttributionCollection(5, null);
|
|
93
|
+
collection.update("foo", new attributionCollection_1.AttributionCollection(5, opKey(100)));
|
|
94
|
+
const splitCollection = collection.splitAt(2);
|
|
95
|
+
assert_1.strict.deepEqual(collection.getAll().channels, {
|
|
96
|
+
foo: [{ offset: 0, key: opKey(100) }],
|
|
97
|
+
});
|
|
98
|
+
assert_1.strict.deepEqual(splitCollection.getAll().channels, {
|
|
99
|
+
foo: [{ offset: 0, key: opKey(100) }],
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
describe(".append", () => {
|
|
104
|
+
it("modifies the receiving collection", () => {
|
|
105
|
+
const collection = new attributionCollection_1.AttributionCollection(2, opKey(100));
|
|
106
|
+
assert_1.strict.deepEqual(collection.getAll().root, [{ offset: 0, key: opKey(100) }]);
|
|
107
|
+
collection.append(new attributionCollection_1.AttributionCollection(1, opKey(101)));
|
|
108
|
+
assert_1.strict.deepEqual(collection.getAll().root, [
|
|
109
|
+
{ offset: 0, key: opKey(100) },
|
|
110
|
+
{ offset: 2, key: opKey(101) },
|
|
111
|
+
]);
|
|
112
|
+
});
|
|
113
|
+
it("does not modify the argument collection", () => {
|
|
114
|
+
const collection = new attributionCollection_1.AttributionCollection(2, opKey(100));
|
|
115
|
+
const appendedCollection = new attributionCollection_1.AttributionCollection(1, opKey(101));
|
|
116
|
+
assert_1.strict.deepEqual(appendedCollection.getAll().root, [{ offset: 0, key: opKey(101) }]);
|
|
117
|
+
collection.append(appendedCollection);
|
|
118
|
+
assert_1.strict.deepEqual(appendedCollection.getAll().root, [{ offset: 0, key: opKey(101) }]);
|
|
119
|
+
});
|
|
120
|
+
it("coalesces referentially equal values at the join point", () => {
|
|
121
|
+
const collection = new attributionCollection_1.AttributionCollection(2, opKey(100));
|
|
122
|
+
collection.append(new attributionCollection_1.AttributionCollection(7, opKey(100)));
|
|
123
|
+
assert_1.strict.deepEqual(collection.getAll().root, [{ offset: 0, key: opKey(100) }]);
|
|
124
|
+
assert_1.strict.equal(collection.length, 9);
|
|
125
|
+
});
|
|
126
|
+
describe("appends channels", () => {
|
|
127
|
+
it("when both collections have the channel", () => {
|
|
128
|
+
const appender = makeCollectionWithChannel({ length: 2, seq: 100 });
|
|
129
|
+
appender.append(makeCollectionWithChannel({ length: 5, seq: 200 }));
|
|
130
|
+
assert_1.strict.deepEqual(appender.getAll(), {
|
|
131
|
+
length: 7,
|
|
132
|
+
root: [{ offset: 0, key: null }],
|
|
133
|
+
channels: {
|
|
134
|
+
foo: [
|
|
135
|
+
{
|
|
136
|
+
offset: 0,
|
|
137
|
+
key: opKey(100),
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
offset: 2,
|
|
141
|
+
key: opKey(200),
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
it("when only appended collection has a channel", () => {
|
|
148
|
+
const appender = new attributionCollection_1.AttributionCollection(2, null);
|
|
149
|
+
appender.append(makeCollectionWithChannel({ length: 5, seq: 200 }));
|
|
150
|
+
assert_1.strict.deepEqual(appender.getAll(), {
|
|
151
|
+
length: 7,
|
|
152
|
+
root: [{ offset: 0, key: null }],
|
|
153
|
+
channels: {
|
|
154
|
+
foo: [
|
|
155
|
+
{
|
|
156
|
+
offset: 0,
|
|
157
|
+
key: null,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
offset: 2,
|
|
161
|
+
key: opKey(200),
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
it("when only segment being appended to has a channel", () => {
|
|
168
|
+
const appender = makeCollectionWithChannel({ length: 2, seq: 100 });
|
|
169
|
+
appender.append(new attributionCollection_1.AttributionCollection(5, null));
|
|
170
|
+
assert_1.strict.deepEqual(appender.getAll(), {
|
|
171
|
+
length: 7,
|
|
172
|
+
root: [{ offset: 0, key: null }],
|
|
173
|
+
channels: {
|
|
174
|
+
foo: [
|
|
175
|
+
{
|
|
176
|
+
offset: 0,
|
|
177
|
+
key: opKey(100),
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
offset: 2,
|
|
181
|
+
key: null,
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
describe(".channelNames", () => {
|
|
190
|
+
it("is empty when collection has no channels", () => {
|
|
191
|
+
const collection = new attributionCollection_1.AttributionCollection(2, opKey(100));
|
|
192
|
+
assert_1.strict.deepEqual(collection.channelNames, []);
|
|
193
|
+
});
|
|
194
|
+
it("returns all channels with content for collection with channels", () => {
|
|
195
|
+
const collection = new attributionCollection_1.AttributionCollection(2, opKey(100));
|
|
196
|
+
collection.update("foo", new attributionCollection_1.AttributionCollection(2));
|
|
197
|
+
collection.update("bar", new attributionCollection_1.AttributionCollection(2));
|
|
198
|
+
assert_1.strict.deepEqual(collection.channelNames, ["foo", "bar"]);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
describe(".populateAttributionCollections", () => {
|
|
202
|
+
it("correctly splits segment boundaries on breakpoints", () => {
|
|
203
|
+
const segments = [{ cachedLength: 5 }, { cachedLength: 4 }];
|
|
204
|
+
attributionCollection_1.AttributionCollection.populateAttributionCollections(segments, {
|
|
205
|
+
length: 9,
|
|
206
|
+
posBreakpoints: [0, 2, 5, 7],
|
|
207
|
+
seqs: [10, 12, 15, 17],
|
|
208
|
+
});
|
|
209
|
+
assert_1.strict.deepEqual(segments[0].attribution?.getAll().root, [
|
|
210
|
+
{ offset: 0, key: opKey(10) },
|
|
211
|
+
{ offset: 2, key: opKey(12) },
|
|
212
|
+
]);
|
|
213
|
+
assert_1.strict.deepEqual(segments[1].attribution?.getAll().root, [
|
|
214
|
+
{ offset: 0, key: opKey(15) },
|
|
215
|
+
{ offset: 2, key: opKey(17) },
|
|
216
|
+
]);
|
|
217
|
+
for (const segment of segments) {
|
|
218
|
+
assert_1.strict.equal(segment.attribution?.length, segment.cachedLength);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
it("correctly splits segment boundaries between breakpoints", () => {
|
|
222
|
+
const segments = [{ cachedLength: 4 }, { cachedLength: 5 }];
|
|
223
|
+
attributionCollection_1.AttributionCollection.populateAttributionCollections(segments, {
|
|
224
|
+
length: 9,
|
|
225
|
+
posBreakpoints: [0, 2, 5, 7],
|
|
226
|
+
seqs: [10, 12, 15, 17],
|
|
227
|
+
});
|
|
228
|
+
assert_1.strict.deepEqual(segments[0].attribution?.getAll().root, [
|
|
229
|
+
{ offset: 0, key: opKey(10) },
|
|
230
|
+
{ offset: 2, key: opKey(12) },
|
|
231
|
+
]);
|
|
232
|
+
assert_1.strict.deepEqual(segments[1].attribution?.getAll().root, [
|
|
233
|
+
{ offset: 0, key: opKey(12) },
|
|
234
|
+
{ offset: 1, key: opKey(15) },
|
|
235
|
+
{ offset: 3, key: opKey(17) },
|
|
236
|
+
]);
|
|
237
|
+
for (const segment of segments) {
|
|
238
|
+
assert_1.strict.equal(segment.attribution?.length, segment.cachedLength);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
describe("serializeAttributionCollections", () => {
|
|
243
|
+
it("combines equal values on endpoints", () => {
|
|
244
|
+
const segments = [
|
|
245
|
+
{
|
|
246
|
+
attribution: new attributionCollection_1.AttributionCollection(4, opKey(0)),
|
|
247
|
+
cachedLength: 4,
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
attribution: new attributionCollection_1.AttributionCollection(5, opKey(0)),
|
|
251
|
+
cachedLength: 5,
|
|
252
|
+
},
|
|
253
|
+
];
|
|
254
|
+
const blob = attributionCollection_1.AttributionCollection.serializeAttributionCollections(segments);
|
|
255
|
+
assert_1.strict.deepEqual(blob, {
|
|
256
|
+
posBreakpoints: [0],
|
|
257
|
+
seqs: [0],
|
|
258
|
+
length: 9,
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
describe("serializeAttributionCollections and populateAttributionCollections round-trip", () => {
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
264
|
+
const seg = (length) => ({ cachedLength: length });
|
|
265
|
+
const testCases = [
|
|
266
|
+
{
|
|
267
|
+
name: "single key",
|
|
268
|
+
blob: {
|
|
269
|
+
length: 3,
|
|
270
|
+
posBreakpoints: [0],
|
|
271
|
+
seqs: [51],
|
|
272
|
+
},
|
|
273
|
+
segments: [seg(3)],
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
name: "several keys on a single segment",
|
|
277
|
+
blob: {
|
|
278
|
+
length: 7,
|
|
279
|
+
posBreakpoints: [0, 1, 3, 5],
|
|
280
|
+
seqs: [1, 2, 3, 4],
|
|
281
|
+
},
|
|
282
|
+
segments: [seg(7)],
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: "key spanning multiple segments",
|
|
286
|
+
blob: {
|
|
287
|
+
length: 7,
|
|
288
|
+
posBreakpoints: [0],
|
|
289
|
+
seqs: [1],
|
|
290
|
+
},
|
|
291
|
+
segments: [seg(3), seg(4)],
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: "key and segment boundary that align",
|
|
295
|
+
blob: {
|
|
296
|
+
length: 7,
|
|
297
|
+
posBreakpoints: [0, 3],
|
|
298
|
+
seqs: [0, 1],
|
|
299
|
+
},
|
|
300
|
+
segments: [seg(3), seg(4)],
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: "detached attribution keys",
|
|
304
|
+
blob: {
|
|
305
|
+
length: 7,
|
|
306
|
+
posBreakpoints: [0, 3],
|
|
307
|
+
seqs: [1, detachedKey],
|
|
308
|
+
},
|
|
309
|
+
segments: [seg(3), seg(4)],
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: "entry with channels",
|
|
313
|
+
blob: {
|
|
314
|
+
length: 7,
|
|
315
|
+
posBreakpoints: [0, 5],
|
|
316
|
+
seqs: [3, null],
|
|
317
|
+
channels: {
|
|
318
|
+
foo: {
|
|
319
|
+
posBreakpoints: [0, 3, 5],
|
|
320
|
+
seqs: [4, null, 5],
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
segments: [seg(3), seg(4)],
|
|
325
|
+
},
|
|
326
|
+
];
|
|
327
|
+
for (const { name, blob, segments } of testCases) {
|
|
328
|
+
it(name, () => {
|
|
329
|
+
attributionCollection_1.AttributionCollection.populateAttributionCollections(segments, blob);
|
|
330
|
+
assert_1.strict.deepEqual(attributionCollection_1.AttributionCollection.serializeAttributionCollections(segments), blob);
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
describe(".clone", () => {
|
|
335
|
+
it("copies the original collection", () => {
|
|
336
|
+
const collection = new attributionCollection_1.AttributionCollection(2, opKey(100));
|
|
337
|
+
const appendedCollection = new attributionCollection_1.AttributionCollection(1, opKey(101));
|
|
338
|
+
const copy = collection.clone();
|
|
339
|
+
collection.append(appendedCollection);
|
|
340
|
+
assert_1.strict.deepEqual(collection.getAll().root, [
|
|
341
|
+
{ offset: 0, key: opKey(100) },
|
|
342
|
+
{ offset: 2, key: opKey(101) },
|
|
343
|
+
]);
|
|
344
|
+
assert_1.strict.deepEqual(copy.getAll().root, [{ offset: 0, key: opKey(100) }]);
|
|
345
|
+
});
|
|
346
|
+
it("copies channels", () => {
|
|
347
|
+
const collection = makeCollectionWithChannel({ length: 2, seq: 25 });
|
|
348
|
+
const appendedCollection = makeCollectionWithChannel({ length: 3, seq: 26 });
|
|
349
|
+
const copy = collection.clone();
|
|
350
|
+
collection.append(appendedCollection);
|
|
351
|
+
assert_1.strict.deepEqual(collection.getAll().channels?.foo, [
|
|
352
|
+
{ offset: 0, key: opKey(25) },
|
|
353
|
+
{ offset: 2, key: opKey(26) },
|
|
354
|
+
]);
|
|
355
|
+
assert_1.strict.deepEqual(copy.getAll().channels?.foo, [{ offset: 0, key: opKey(25) }]);
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
describe(".update", () => {
|
|
359
|
+
let collection;
|
|
360
|
+
beforeEach(() => {
|
|
361
|
+
collection = new attributionCollection_1.AttributionCollection(2, null);
|
|
362
|
+
collection.update("bar", new attributionCollection_1.AttributionCollection(2, opKey(10)));
|
|
363
|
+
assert_1.strict.deepEqual(collection.getAtOffset(0, "foo"), undefined, "channel should be undefined on creation");
|
|
364
|
+
});
|
|
365
|
+
afterEach(() => {
|
|
366
|
+
assert_1.strict.deepEqual(collection.getAtOffset(0, "bar"), opKey(10), "update should never modify unrelated channels");
|
|
367
|
+
});
|
|
368
|
+
it("creates a new channel when updating from an undefined state", () => {
|
|
369
|
+
collection.update("foo", new attributionCollection_1.AttributionCollection(2, opKey(5)));
|
|
370
|
+
assert_1.strict.deepEqual(collection.getAtOffset(0, "foo"), opKey(5));
|
|
371
|
+
});
|
|
372
|
+
it("overrides earlier calls with later ones", () => {
|
|
373
|
+
collection.update("foo", new attributionCollection_1.AttributionCollection(2, opKey(3)));
|
|
374
|
+
collection.update("foo", new attributionCollection_1.AttributionCollection(2, opKey(5)));
|
|
375
|
+
assert_1.strict.deepEqual(collection.getAtOffset(0, "foo"), opKey(5));
|
|
376
|
+
});
|
|
377
|
+
it("can update the root channel", () => {
|
|
378
|
+
collection.update(undefined, new attributionCollection_1.AttributionCollection(2, opKey(3)));
|
|
379
|
+
assert_1.strict.deepEqual(collection.getAtOffset(0), opKey(3));
|
|
380
|
+
});
|
|
381
|
+
it("doesn't tolerate updates to channels having inconsistent length fields", () => {
|
|
382
|
+
assert_1.strict.throws(() => collection.update("foo", new attributionCollection_1.AttributionCollection(3, null)));
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
describe("serialized structure is independent of segment lengths", () => {
|
|
386
|
+
class Segment extends mergeTreeNodes_1.BaseSegment {
|
|
387
|
+
constructor(length) {
|
|
388
|
+
super();
|
|
389
|
+
this.type = "testSeg";
|
|
390
|
+
this.cachedLength = length;
|
|
391
|
+
}
|
|
392
|
+
toJSONObject() {
|
|
393
|
+
return { length: this.cachedLength, props: this.properties };
|
|
394
|
+
}
|
|
395
|
+
clone() {
|
|
396
|
+
const seg = new Segment(this.cachedLength);
|
|
397
|
+
this.cloneInto(seg);
|
|
398
|
+
return seg;
|
|
399
|
+
}
|
|
400
|
+
createSplitSegmentAt(pos) {
|
|
401
|
+
if (pos > 0) {
|
|
402
|
+
const leafSegment = new Segment(this.cachedLength - pos);
|
|
403
|
+
this.cachedLength = pos;
|
|
404
|
+
return leafSegment;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
for (let seed = 0; seed < 10; seed++) {
|
|
409
|
+
const segmentCount = 100;
|
|
410
|
+
it(`with randomly generated segments, seed ${seed}`, () => {
|
|
411
|
+
const generateAttributionKey = (random) => random.bool(0.8)
|
|
412
|
+
? opKey(random.integer(0, 10))
|
|
413
|
+
: random.bool()
|
|
414
|
+
? detachedKey
|
|
415
|
+
: null;
|
|
416
|
+
const channelNamePool = ["ch1", "ch2", "ch3"];
|
|
417
|
+
const insertGenerator = (0, stochastic_test_utils_1.take)(segmentCount, ({ random }) => {
|
|
418
|
+
const length = random.integer(1, 20);
|
|
419
|
+
const collection = new attributionCollection_1.AttributionCollection(length, generateAttributionKey(random));
|
|
420
|
+
if (random.bool(0.25)) {
|
|
421
|
+
for (const channel of channelNamePool) {
|
|
422
|
+
if (random.bool()) {
|
|
423
|
+
collection.update(channel, new attributionCollection_1.AttributionCollection(length, generateAttributionKey(random)));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
type: "insert",
|
|
429
|
+
collection,
|
|
430
|
+
};
|
|
431
|
+
});
|
|
432
|
+
const initialState = (0, stochastic_test_utils_1.performFuzzActions)(insertGenerator, {
|
|
433
|
+
insert: (state, { collection }) => {
|
|
434
|
+
const { segments } = state;
|
|
435
|
+
const seg = new Segment(collection.length);
|
|
436
|
+
seg.attribution = collection;
|
|
437
|
+
segments.push(seg);
|
|
438
|
+
return state;
|
|
439
|
+
},
|
|
440
|
+
}, { random: (0, stochastic_test_utils_1.makeRandom)(seed), segments: [] });
|
|
441
|
+
const expected = attributionCollection_1.AttributionCollection.serializeAttributionCollections(initialState.segments);
|
|
442
|
+
const split = ({ segments, random }) => {
|
|
443
|
+
const validIndices = segments
|
|
444
|
+
.map((seg, i) => (seg.cachedLength > 1 ? i : -1))
|
|
445
|
+
.filter((i) => i >= 0);
|
|
446
|
+
const segIndex = random.pick(validIndices);
|
|
447
|
+
const offset = random.integer(1, segments[segIndex].cachedLength - 1);
|
|
448
|
+
return {
|
|
449
|
+
type: "split",
|
|
450
|
+
segIndex,
|
|
451
|
+
offset,
|
|
452
|
+
};
|
|
453
|
+
};
|
|
454
|
+
const append = ({ random, segments }) => {
|
|
455
|
+
return {
|
|
456
|
+
type: "append",
|
|
457
|
+
segIndex: random.integer(0, segments.length - 2),
|
|
458
|
+
};
|
|
459
|
+
};
|
|
460
|
+
const finalState = (0, stochastic_test_utils_1.performFuzzActions)((0, stochastic_test_utils_1.take)(segmentCount,
|
|
461
|
+
// Note: if playing around with constants in this test, it may be necessary to
|
|
462
|
+
// introduce acceptance criteria here for split.
|
|
463
|
+
(0, stochastic_test_utils_1.createWeightedGenerator)([
|
|
464
|
+
[split, 1],
|
|
465
|
+
[append, 1, ({ segments }) => segments.length > 1],
|
|
466
|
+
])), {
|
|
467
|
+
split: (state, { segIndex, offset }) => {
|
|
468
|
+
const { segments } = state;
|
|
469
|
+
const splitSeg = segments[segIndex].splitAt(offset);
|
|
470
|
+
(0, assert_1.strict)(splitSeg !== undefined);
|
|
471
|
+
segments.splice(segIndex + 1, 0, splitSeg);
|
|
472
|
+
return state;
|
|
473
|
+
},
|
|
474
|
+
append: (state, { segIndex }) => {
|
|
475
|
+
const { segments } = state;
|
|
476
|
+
segments[segIndex].append(segments[segIndex + 1]);
|
|
477
|
+
segments.splice(segIndex + 1, 1);
|
|
478
|
+
return state;
|
|
479
|
+
},
|
|
480
|
+
}, initialState);
|
|
481
|
+
assert_1.strict.deepEqual(attributionCollection_1.AttributionCollection.serializeAttributionCollections(finalState.segments), expected);
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
//# sourceMappingURL=attributionCollection.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributionCollection.spec.js","sourceRoot":"","sources":["../../src/test/attributionCollection.spec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,mCAA0C;AAC1C,gFAO8C;AAE9C,oEAAkG;AAClG,sDAA0D;AAE1D,MAAM,KAAK,GAAG,CAAC,GAAW,EAAkB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AACrE,MAAM,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OAAO,KAAK,CAAC;oBACd,CAAC;oBACD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;wBAC/B,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;wBAC3B,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;wBAClD,QAAQ,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;wBACjC,OAAO,KAAK,CAAC;oBACd,CAAC;iBACD,EACD,YAAY,CACZ,CAAC;gBAEF,eAAM,CAAC,SAAS,CACf,6CAAqB,CAAC,+BAA+B,CAAC,UAAU,CAAC,QAAQ,CAAC,EAC1E,QAAQ,CACR,CAAC;YACH,CAAC,CAAC,CAAC;SACH;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"assert\";\nimport {\n\tcreateWeightedGenerator,\n\tGenerator,\n\tIRandom,\n\tmakeRandom,\n\tperformFuzzActions,\n\ttake,\n} from \"@fluid-private/stochastic-test-utils\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions\";\nimport { AttributionCollection, SerializedAttributionCollection } from \"../attributionCollection\";\nimport { BaseSegment, ISegment } from \"../mergeTreeNodes\";\n\nconst opKey = (seq: number): AttributionKey => ({ type: \"op\", seq });\nconst detachedKey: AttributionKey = { type: \"detached\", id: 0 };\n\ndescribe(\"AttributionCollection\", () => {\n\tconst makeCollectionWithChannel = ({ length, seq }: { length: number; seq: number }) => {\n\t\tconst collection = new AttributionCollection(length, null);\n\t\tcollection.update(\"foo\", new AttributionCollection(length, opKey(seq)));\n\t\treturn collection;\n\t};\n\n\tdescribe(\".getAtOffset\", () => {\n\t\tdescribe(\"on a collection with a single entry\", () => {\n\t\t\tconst collection = new AttributionCollection(5, opKey(100));\n\n\t\t\tit(\"returns the entry for offsets within the length range\", () => {\n\t\t\t\tfor (let i = 0; i < 5; i++) {\n\t\t\t\t\tassert.deepEqual(collection.getAtOffset(i), opKey(100));\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tit(\"throws for queries outside the range\", () => {\n\t\t\t\tassert.throws(() => collection.getAtOffset(-1));\n\t\t\t\tassert.throws(() => collection.getAtOffset(5));\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\"on a collection with multiple entries\", () => {\n\t\t\tconst collection = new AttributionCollection(3, opKey(100));\n\t\t\tcollection.append(new AttributionCollection(5, opKey(101)));\n\t\t\tit(\"returns the correct entries\", () => {\n\t\t\t\tfor (let i = 0; i < 3; i++) {\n\t\t\t\t\tassert.deepEqual(collection.getAtOffset(i), opKey(100));\n\t\t\t\t}\n\n\t\t\t\tfor (let i = 3; i < 8; i++) {\n\t\t\t\t\tassert.deepEqual(collection.getAtOffset(i), opKey(101));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tit(\"works on collections with entries in channels\", () => {\n\t\t\tconst collection = makeCollectionWithChannel({ length: 3, seq: 300 });\n\t\t\tfor (const offset of [0, 1, 2]) {\n\t\t\t\tassert.deepEqual(collection.getAtOffset(offset, \"foo\"), opKey(300));\n\t\t\t}\n\t\t});\n\t});\n\n\tdescribe(\".splitAt\", () => {\n\t\tdescribe(\"on a collection with 3 entries\", () => {\n\t\t\tlet collection: AttributionCollection;\n\t\t\tbeforeEach(() => {\n\t\t\t\tcollection = new AttributionCollection(3, opKey(100));\n\t\t\t\tcollection.append(new AttributionCollection(2, opKey(101)));\n\t\t\t\tcollection.append(new AttributionCollection(1, opKey(102)));\n\t\t\t});\n\n\t\t\tit(\"can split on non-breakpoints\", () => {\n\t\t\t\tconst splitCollection = collection.splitAt(4);\n\t\t\t\tassert.deepEqual(collection.getAll().root, [\n\t\t\t\t\t{ offset: 0, key: opKey(100) },\n\t\t\t\t\t{ offset: 3, key: opKey(101) },\n\t\t\t\t]);\n\t\t\t\tassert.equal(collection.length, 4);\n\t\t\t\tassert.deepEqual(splitCollection.getAll().root, [\n\t\t\t\t\t{ offset: 0, key: opKey(101) },\n\t\t\t\t\t{ offset: 1, key: opKey(102) },\n\t\t\t\t]);\n\t\t\t\tassert.equal(splitCollection.length, 2);\n\t\t\t});\n\n\t\t\tit(\"can split on breakpoints\", () => {\n\t\t\t\tconst splitCollection = collection.splitAt(5);\n\t\t\t\tassert.deepEqual(collection.getAll().root, [\n\t\t\t\t\t{ offset: 0, key: opKey(100) },\n\t\t\t\t\t{ offset: 3, key: opKey(101) },\n\t\t\t\t]);\n\t\t\t\tassert.equal(collection.length, 5);\n\t\t\t\tassert.deepEqual(splitCollection.getAll().root, [{ offset: 0, key: opKey(102) }]);\n\t\t\t\tassert.equal(splitCollection.length, 1);\n\t\t\t});\n\t\t});\n\n\t\tit(\"can split collection with a single value\", () => {\n\t\t\tconst collection = new AttributionCollection(5, opKey(100));\n\t\t\tconst splitCollection = collection.splitAt(3);\n\t\t\tassert.equal(collection.length, 3);\n\t\t\tassert.equal(splitCollection.length, 2);\n\t\t\tassert.deepEqual(collection.getAll().root, [{ offset: 0, key: opKey(100) }]);\n\t\t\tassert.deepEqual(splitCollection.getAll().root, [{ offset: 0, key: opKey(100) }]);\n\t\t});\n\n\t\tit(\"splits channels\", () => {\n\t\t\tconst collection = new AttributionCollection(5, null);\n\t\t\tcollection.update(\"foo\", new AttributionCollection(5, opKey(100)));\n\t\t\tconst splitCollection = collection.splitAt(2);\n\t\t\tassert.deepEqual(collection.getAll().channels, {\n\t\t\t\tfoo: [{ offset: 0, key: opKey(100) }],\n\t\t\t});\n\t\t\tassert.deepEqual(splitCollection.getAll().channels, {\n\t\t\t\tfoo: [{ offset: 0, key: opKey(100) }],\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\".append\", () => {\n\t\tit(\"modifies the receiving collection\", () => {\n\t\t\tconst collection = new AttributionCollection(2, opKey(100));\n\t\t\tassert.deepEqual(collection.getAll().root, [{ offset: 0, key: opKey(100) }]);\n\t\t\tcollection.append(new AttributionCollection(1, opKey(101)));\n\t\t\tassert.deepEqual(collection.getAll().root, [\n\t\t\t\t{ offset: 0, key: opKey(100) },\n\t\t\t\t{ offset: 2, key: opKey(101) },\n\t\t\t]);\n\t\t});\n\n\t\tit(\"does not modify the argument collection\", () => {\n\t\t\tconst collection = new AttributionCollection(2, opKey(100));\n\t\t\tconst appendedCollection = new AttributionCollection(1, opKey(101));\n\t\t\tassert.deepEqual(appendedCollection.getAll().root, [{ offset: 0, key: opKey(101) }]);\n\t\t\tcollection.append(appendedCollection);\n\t\t\tassert.deepEqual(appendedCollection.getAll().root, [{ offset: 0, key: opKey(101) }]);\n\t\t});\n\n\t\tit(\"coalesces referentially equal values at the join point\", () => {\n\t\t\tconst collection = new AttributionCollection(2, opKey(100));\n\t\t\tcollection.append(new AttributionCollection(7, opKey(100)));\n\t\t\tassert.deepEqual(collection.getAll().root, [{ offset: 0, key: opKey(100) }]);\n\t\t\tassert.equal(collection.length, 9);\n\t\t});\n\n\t\tdescribe(\"appends channels\", () => {\n\t\t\tit(\"when both collections have the channel\", () => {\n\t\t\t\tconst appender = makeCollectionWithChannel({ length: 2, seq: 100 });\n\t\t\t\tappender.append(makeCollectionWithChannel({ length: 5, seq: 200 }));\n\t\t\t\tassert.deepEqual(appender.getAll(), {\n\t\t\t\t\tlength: 7,\n\t\t\t\t\troot: [{ offset: 0, key: null }],\n\t\t\t\t\tchannels: {\n\t\t\t\t\t\tfoo: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toffset: 0,\n\t\t\t\t\t\t\t\tkey: opKey(100),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toffset: 2,\n\t\t\t\t\t\t\t\tkey: opKey(200),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tit(\"when only appended collection has a channel\", () => {\n\t\t\t\tconst appender = new AttributionCollection(2, null);\n\t\t\t\tappender.append(makeCollectionWithChannel({ length: 5, seq: 200 }));\n\t\t\t\tassert.deepEqual(appender.getAll(), {\n\t\t\t\t\tlength: 7,\n\t\t\t\t\troot: [{ offset: 0, key: null }],\n\t\t\t\t\tchannels: {\n\t\t\t\t\t\tfoo: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toffset: 0,\n\t\t\t\t\t\t\t\tkey: null,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toffset: 2,\n\t\t\t\t\t\t\t\tkey: opKey(200),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tit(\"when only segment being appended to has a channel\", () => {\n\t\t\t\tconst appender = makeCollectionWithChannel({ length: 2, seq: 100 });\n\t\t\t\tappender.append(new AttributionCollection(5, null));\n\t\t\t\tassert.deepEqual(appender.getAll(), {\n\t\t\t\t\tlength: 7,\n\t\t\t\t\troot: [{ offset: 0, key: null }],\n\t\t\t\t\tchannels: {\n\t\t\t\t\t\tfoo: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toffset: 0,\n\t\t\t\t\t\t\t\tkey: opKey(100),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\toffset: 2,\n\t\t\t\t\t\t\t\tkey: null,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\".channelNames\", () => {\n\t\tit(\"is empty when collection has no channels\", () => {\n\t\t\tconst collection = new AttributionCollection(2, opKey(100));\n\t\t\tassert.deepEqual(collection.channelNames, []);\n\t\t});\n\n\t\tit(\"returns all channels with content for collection with channels\", () => {\n\t\t\tconst collection = new AttributionCollection(2, opKey(100));\n\t\t\tcollection.update(\"foo\", new AttributionCollection(2));\n\t\t\tcollection.update(\"bar\", new AttributionCollection(2));\n\t\t\tassert.deepEqual(collection.channelNames, [\"foo\", \"bar\"]);\n\t\t});\n\t});\n\n\tdescribe(\".populateAttributionCollections\", () => {\n\t\tit(\"correctly splits segment boundaries on breakpoints\", () => {\n\t\t\tconst segments = [{ cachedLength: 5 }, { cachedLength: 4 }] as ISegment[];\n\t\t\tAttributionCollection.populateAttributionCollections(segments, {\n\t\t\t\tlength: 9,\n\t\t\t\tposBreakpoints: [0, 2, 5, 7],\n\t\t\t\tseqs: [10, 12, 15, 17],\n\t\t\t});\n\t\t\tassert.deepEqual(segments[0].attribution?.getAll().root, [\n\t\t\t\t{ offset: 0, key: opKey(10) },\n\t\t\t\t{ offset: 2, key: opKey(12) },\n\t\t\t]);\n\n\t\t\tassert.deepEqual(segments[1].attribution?.getAll().root, [\n\t\t\t\t{ offset: 0, key: opKey(15) },\n\t\t\t\t{ offset: 2, key: opKey(17) },\n\t\t\t]);\n\n\t\t\tfor (const segment of segments) {\n\t\t\t\tassert.equal(segment.attribution?.length, segment.cachedLength);\n\t\t\t}\n\t\t});\n\n\t\tit(\"correctly splits segment boundaries between breakpoints\", () => {\n\t\t\tconst segments = [{ cachedLength: 4 }, { cachedLength: 5 }] as ISegment[];\n\t\t\tAttributionCollection.populateAttributionCollections(segments, {\n\t\t\t\tlength: 9,\n\t\t\t\tposBreakpoints: [0, 2, 5, 7],\n\t\t\t\tseqs: [10, 12, 15, 17],\n\t\t\t});\n\t\t\tassert.deepEqual(segments[0].attribution?.getAll().root, [\n\t\t\t\t{ offset: 0, key: opKey(10) },\n\t\t\t\t{ offset: 2, key: opKey(12) },\n\t\t\t]);\n\n\t\t\tassert.deepEqual(segments[1].attribution?.getAll().root, [\n\t\t\t\t{ offset: 0, key: opKey(12) },\n\t\t\t\t{ offset: 1, key: opKey(15) },\n\t\t\t\t{ offset: 3, key: opKey(17) },\n\t\t\t]);\n\n\t\t\tfor (const segment of segments) {\n\t\t\t\tassert.equal(segment.attribution?.length, segment.cachedLength);\n\t\t\t}\n\t\t});\n\t});\n\n\tdescribe(\"serializeAttributionCollections\", () => {\n\t\tit(\"combines equal values on endpoints\", () => {\n\t\t\tconst segments = [\n\t\t\t\t{\n\t\t\t\t\tattribution: new AttributionCollection(4, opKey(0)),\n\t\t\t\t\tcachedLength: 4,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tattribution: new AttributionCollection(5, opKey(0)),\n\t\t\t\t\tcachedLength: 5,\n\t\t\t\t},\n\t\t\t] as unknown as ISegment[];\n\t\t\tconst blob = AttributionCollection.serializeAttributionCollections(segments);\n\t\t\tassert.deepEqual(blob, {\n\t\t\t\tposBreakpoints: [0],\n\t\t\t\tseqs: [0],\n\t\t\t\tlength: 9,\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\"serializeAttributionCollections and populateAttributionCollections round-trip\", () => {\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\tconst seg = (length: number): ISegment => ({ cachedLength: length }) as ISegment;\n\t\tconst testCases: {\n\t\t\tname: string;\n\t\t\tblob: SerializedAttributionCollection;\n\t\t\tsegments: ISegment[];\n\t\t}[] = [\n\t\t\t{\n\t\t\t\tname: \"single key\",\n\t\t\t\tblob: {\n\t\t\t\t\tlength: 3,\n\t\t\t\t\tposBreakpoints: [0],\n\t\t\t\t\tseqs: [51],\n\t\t\t\t},\n\t\t\t\tsegments: [seg(3)],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: \"several keys on a single segment\",\n\t\t\t\tblob: {\n\t\t\t\t\tlength: 7,\n\t\t\t\t\tposBreakpoints: [0, 1, 3, 5],\n\t\t\t\t\tseqs: [1, 2, 3, 4],\n\t\t\t\t},\n\t\t\t\tsegments: [seg(7)],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: \"key spanning multiple segments\",\n\t\t\t\tblob: {\n\t\t\t\t\tlength: 7,\n\t\t\t\t\tposBreakpoints: [0],\n\t\t\t\t\tseqs: [1],\n\t\t\t\t},\n\t\t\t\tsegments: [seg(3), seg(4)],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: \"key and segment boundary that align\",\n\t\t\t\tblob: {\n\t\t\t\t\tlength: 7,\n\t\t\t\t\tposBreakpoints: [0, 3],\n\t\t\t\t\tseqs: [0, 1],\n\t\t\t\t},\n\t\t\t\tsegments: [seg(3), seg(4)],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: \"detached attribution keys\",\n\t\t\t\tblob: {\n\t\t\t\t\tlength: 7,\n\t\t\t\t\tposBreakpoints: [0, 3],\n\t\t\t\t\tseqs: [1, detachedKey],\n\t\t\t\t},\n\t\t\t\tsegments: [seg(3), seg(4)],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: \"entry with channels\",\n\t\t\t\tblob: {\n\t\t\t\t\tlength: 7,\n\t\t\t\t\tposBreakpoints: [0, 5],\n\t\t\t\t\tseqs: [3, null],\n\t\t\t\t\tchannels: {\n\t\t\t\t\t\tfoo: {\n\t\t\t\t\t\t\tposBreakpoints: [0, 3, 5],\n\t\t\t\t\t\t\tseqs: [4, null, 5],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tsegments: [seg(3), seg(4)],\n\t\t\t},\n\t\t];\n\n\t\tfor (const { name, blob, segments } of testCases) {\n\t\t\tit(name, () => {\n\t\t\t\tAttributionCollection.populateAttributionCollections(segments, blob);\n\t\t\t\tassert.deepEqual(\n\t\t\t\t\tAttributionCollection.serializeAttributionCollections(segments),\n\t\t\t\t\tblob,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t});\n\n\tdescribe(\".clone\", () => {\n\t\tit(\"copies the original collection\", () => {\n\t\t\tconst collection = new AttributionCollection(2, opKey(100));\n\t\t\tconst appendedCollection = new AttributionCollection(1, opKey(101));\n\t\t\tconst copy = collection.clone();\n\t\t\tcollection.append(appendedCollection);\n\t\t\tassert.deepEqual(collection.getAll().root, [\n\t\t\t\t{ offset: 0, key: opKey(100) },\n\t\t\t\t{ offset: 2, key: opKey(101) },\n\t\t\t]);\n\t\t\tassert.deepEqual(copy.getAll().root, [{ offset: 0, key: opKey(100) }]);\n\t\t});\n\n\t\tit(\"copies channels\", () => {\n\t\t\tconst collection = makeCollectionWithChannel({ length: 2, seq: 25 });\n\t\t\tconst appendedCollection = makeCollectionWithChannel({ length: 3, seq: 26 });\n\t\t\tconst copy = collection.clone();\n\t\t\tcollection.append(appendedCollection);\n\t\t\tassert.deepEqual(collection.getAll().channels?.foo, [\n\t\t\t\t{ offset: 0, key: opKey(25) },\n\t\t\t\t{ offset: 2, key: opKey(26) },\n\t\t\t]);\n\t\t\tassert.deepEqual(copy.getAll().channels?.foo, [{ offset: 0, key: opKey(25) }]);\n\t\t});\n\t});\n\n\tdescribe(\".update\", () => {\n\t\tlet collection: AttributionCollection;\n\t\tbeforeEach(() => {\n\t\t\tcollection = new AttributionCollection(2, null);\n\t\t\tcollection.update(\"bar\", new AttributionCollection(2, opKey(10)));\n\t\t\tassert.deepEqual(\n\t\t\t\tcollection.getAtOffset(0, \"foo\"),\n\t\t\t\tundefined,\n\t\t\t\t\"channel should be undefined on creation\",\n\t\t\t);\n\t\t});\n\n\t\tafterEach(() => {\n\t\t\tassert.deepEqual(\n\t\t\t\tcollection.getAtOffset(0, \"bar\"),\n\t\t\t\topKey(10),\n\t\t\t\t\"update should never modify unrelated channels\",\n\t\t\t);\n\t\t});\n\n\t\tit(\"creates a new channel when updating from an undefined state\", () => {\n\t\t\tcollection.update(\"foo\", new AttributionCollection(2, opKey(5)));\n\t\t\tassert.deepEqual(collection.getAtOffset(0, \"foo\"), opKey(5));\n\t\t});\n\n\t\tit(\"overrides earlier calls with later ones\", () => {\n\t\t\tcollection.update(\"foo\", new AttributionCollection(2, opKey(3)));\n\t\t\tcollection.update(\"foo\", new AttributionCollection(2, opKey(5)));\n\t\t\tassert.deepEqual(collection.getAtOffset(0, \"foo\"), opKey(5));\n\t\t});\n\n\t\tit(\"can update the root channel\", () => {\n\t\t\tcollection.update(undefined, new AttributionCollection(2, opKey(3)));\n\t\t\tassert.deepEqual(collection.getAtOffset(0), opKey(3));\n\t\t});\n\n\t\tit(\"doesn't tolerate updates to channels having inconsistent length fields\", () => {\n\t\t\tassert.throws(() => collection.update(\"foo\", new AttributionCollection(3, null)));\n\t\t});\n\t});\n\n\tdescribe(\"serialized structure is independent of segment lengths\", () => {\n\t\tinterface State {\n\t\t\trandom: IRandom;\n\t\t\tsegments: ISegment[];\n\t\t}\n\n\t\tinterface InsertAction {\n\t\t\ttype: \"insert\";\n\t\t\tcollection: AttributionCollection;\n\t\t}\n\n\t\tinterface SplitAction {\n\t\t\ttype: \"split\";\n\t\t\tsegIndex: number;\n\t\t\toffset: number;\n\t\t}\n\n\t\tinterface AppendAction {\n\t\t\ttype: \"append\";\n\t\t\tsegIndex: number;\n\t\t}\n\n\t\tclass Segment extends BaseSegment {\n\t\t\tpublic readonly type = \"testSeg\";\n\t\t\tpublic constructor(length: number) {\n\t\t\t\tsuper();\n\t\t\t\tthis.cachedLength = length;\n\t\t\t}\n\n\t\t\tpublic toJSONObject() {\n\t\t\t\treturn { length: this.cachedLength, props: this.properties };\n\t\t\t}\n\n\t\t\tpublic clone(): ISegment {\n\t\t\t\tconst seg = new Segment(this.cachedLength);\n\t\t\t\tthis.cloneInto(seg);\n\t\t\t\treturn seg;\n\t\t\t}\n\n\t\t\tprotected createSplitSegmentAt(pos: number): BaseSegment | undefined {\n\t\t\t\tif (pos > 0) {\n\t\t\t\t\tconst leafSegment = new Segment(this.cachedLength - pos);\n\t\t\t\t\tthis.cachedLength = pos;\n\t\t\t\t\treturn leafSegment;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (let seed = 0; seed < 10; seed++) {\n\t\t\tconst segmentCount = 100;\n\t\t\tit(`with randomly generated segments, seed ${seed}`, () => {\n\t\t\t\tconst generateAttributionKey = (random: IRandom): AttributionKey | null =>\n\t\t\t\t\trandom.bool(0.8)\n\t\t\t\t\t\t? opKey(random.integer(0, 10))\n\t\t\t\t\t\t: random.bool()\n\t\t\t\t\t\t? detachedKey\n\t\t\t\t\t\t: null;\n\n\t\t\t\tconst channelNamePool = [\"ch1\", \"ch2\", \"ch3\"];\n\t\t\t\tconst insertGenerator: Generator<InsertAction, State> = take(\n\t\t\t\t\tsegmentCount,\n\t\t\t\t\t({ random }) => {\n\t\t\t\t\t\tconst length = random.integer(1, 20);\n\t\t\t\t\t\tconst collection = new AttributionCollection(\n\t\t\t\t\t\t\tlength,\n\t\t\t\t\t\t\tgenerateAttributionKey(random),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (random.bool(0.25)) {\n\t\t\t\t\t\t\tfor (const channel of channelNamePool) {\n\t\t\t\t\t\t\t\tif (random.bool()) {\n\t\t\t\t\t\t\t\t\tcollection.update(\n\t\t\t\t\t\t\t\t\t\tchannel,\n\t\t\t\t\t\t\t\t\t\tnew AttributionCollection(\n\t\t\t\t\t\t\t\t\t\t\tlength,\n\t\t\t\t\t\t\t\t\t\t\tgenerateAttributionKey(random),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: \"insert\",\n\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tconst initialState = performFuzzActions<InsertAction, State>(\n\t\t\t\t\tinsertGenerator,\n\t\t\t\t\t{\n\t\t\t\t\t\tinsert: (state, { collection }) => {\n\t\t\t\t\t\t\tconst { segments } = state;\n\t\t\t\t\t\t\tconst seg = new Segment(collection.length);\n\t\t\t\t\t\t\tseg.attribution = collection;\n\t\t\t\t\t\t\tsegments.push(seg);\n\t\t\t\t\t\t\treturn state;\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{ random: makeRandom(seed), segments: [] },\n\t\t\t\t);\n\n\t\t\t\tconst expected = AttributionCollection.serializeAttributionCollections(\n\t\t\t\t\tinitialState.segments,\n\t\t\t\t);\n\n\t\t\t\tconst split: Generator<SplitAction, State> = ({ segments, random }) => {\n\t\t\t\t\tconst validIndices = segments\n\t\t\t\t\t\t.map((seg, i) => (seg.cachedLength > 1 ? i : -1))\n\t\t\t\t\t\t.filter((i) => i >= 0);\n\n\t\t\t\t\tconst segIndex = random.pick(validIndices);\n\t\t\t\t\tconst offset = random.integer(1, segments[segIndex].cachedLength - 1);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"split\",\n\t\t\t\t\t\tsegIndex,\n\t\t\t\t\t\toffset,\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\tconst append: Generator<AppendAction, State> = ({ random, segments }) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"append\",\n\t\t\t\t\t\tsegIndex: random.integer(0, segments.length - 2),\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\tconst finalState = performFuzzActions<SplitAction | AppendAction, State>(\n\t\t\t\t\ttake(\n\t\t\t\t\t\tsegmentCount,\n\t\t\t\t\t\t// Note: if playing around with constants in this test, it may be necessary to\n\t\t\t\t\t\t// introduce acceptance criteria here for split.\n\t\t\t\t\t\tcreateWeightedGenerator<SplitAction | AppendAction, State>([\n\t\t\t\t\t\t\t[split, 1],\n\t\t\t\t\t\t\t[append, 1, ({ segments }) => segments.length > 1],\n\t\t\t\t\t\t]),\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tsplit: (state, { segIndex, offset }) => {\n\t\t\t\t\t\t\tconst { segments } = state;\n\t\t\t\t\t\t\tconst splitSeg = segments[segIndex].splitAt(offset);\n\t\t\t\t\t\t\tassert(splitSeg !== undefined);\n\t\t\t\t\t\t\tsegments.splice(segIndex + 1, 0, splitSeg);\n\t\t\t\t\t\t\treturn state;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tappend: (state, { segIndex }) => {\n\t\t\t\t\t\t\tconst { segments } = state;\n\t\t\t\t\t\t\tsegments[segIndex].append(segments[segIndex + 1]);\n\t\t\t\t\t\t\tsegments.splice(segIndex + 1, 1);\n\t\t\t\t\t\t\treturn state;\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tinitialState,\n\t\t\t\t);\n\n\t\t\t\tassert.deepEqual(\n\t\t\t\t\tAttributionCollection.serializeAttributionCollections(finalState.segments),\n\t\t\t\t\texpected,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t});\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributionPolicy.spec.d.ts","sourceRoot":"","sources":["../../src/test/attributionPolicy.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|