@fluid-experimental/tree 2.0.0-rc.2.0.1 → 2.0.0-rc.3.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 +23 -0
- package/api-report/experimental-tree.api.md +2 -2
- package/dist/ChangeCompression.d.ts +2 -2
- package/dist/ChangeCompression.d.ts.map +1 -1
- package/dist/ChangeCompression.js +1 -1
- package/dist/ChangeCompression.js.map +1 -1
- package/dist/ChangeTypes.d.ts +1 -1
- package/dist/ChangeTypes.d.ts.map +1 -1
- package/dist/ChangeTypes.js +4 -4
- package/dist/ChangeTypes.js.map +1 -1
- package/dist/Checkout.d.ts +3 -3
- package/dist/Checkout.d.ts.map +1 -1
- package/dist/Checkout.js +17 -17
- package/dist/Checkout.js.map +1 -1
- package/dist/EditLog.d.ts +1 -1
- package/dist/EditLog.d.ts.map +1 -1
- package/dist/EditLog.js +9 -9
- package/dist/EditLog.js.map +1 -1
- package/dist/EditUtilities.d.ts +3 -3
- package/dist/EditUtilities.d.ts.map +1 -1
- package/dist/EditUtilities.js +6 -6
- package/dist/EditUtilities.js.map +1 -1
- package/dist/Forest.d.ts.map +1 -1
- package/dist/Forest.js +23 -23
- package/dist/Forest.js.map +1 -1
- package/dist/HistoryEditFactory.d.ts +1 -1
- package/dist/HistoryEditFactory.d.ts.map +1 -1
- package/dist/HistoryEditFactory.js +7 -7
- package/dist/HistoryEditFactory.js.map +1 -1
- package/dist/IdConversion.d.ts.map +1 -1
- package/dist/IdConversion.js.map +1 -1
- package/dist/LogViewer.d.ts +2 -2
- package/dist/LogViewer.d.ts.map +1 -1
- package/dist/LogViewer.js +7 -7
- package/dist/LogViewer.js.map +1 -1
- package/dist/MergeHealth.d.ts.map +1 -1
- package/dist/MergeHealth.js +1 -1
- package/dist/MergeHealth.js.map +1 -1
- package/dist/NodeIdUtilities.d.ts +1 -1
- package/dist/NodeIdUtilities.d.ts.map +1 -1
- package/dist/NodeIdUtilities.js +1 -1
- package/dist/NodeIdUtilities.js.map +1 -1
- package/dist/PayloadUtilities.d.ts.map +1 -1
- package/dist/PayloadUtilities.js +2 -2
- package/dist/PayloadUtilities.js.map +1 -1
- package/dist/ReconciliationPath.d.ts +1 -1
- package/dist/ReconciliationPath.d.ts.map +1 -1
- package/dist/ReconciliationPath.js.map +1 -1
- package/dist/RevisionValueCache.d.ts.map +1 -1
- package/dist/RevisionValueCache.js +2 -2
- package/dist/RevisionValueCache.js.map +1 -1
- package/dist/RevisionView.d.ts +2 -2
- package/dist/RevisionView.d.ts.map +1 -1
- package/dist/RevisionView.js.map +1 -1
- package/dist/SerializationUtilities.d.ts +1 -1
- package/dist/SerializationUtilities.d.ts.map +1 -1
- package/dist/SerializationUtilities.js.map +1 -1
- package/dist/SharedTree.d.ts +8 -7
- package/dist/SharedTree.d.ts.map +1 -1
- package/dist/SharedTree.js +78 -78
- package/dist/SharedTree.js.map +1 -1
- package/dist/SharedTreeEncoder.d.ts +1 -1
- package/dist/SharedTreeEncoder.d.ts.map +1 -1
- package/dist/SharedTreeEncoder.js +31 -31
- package/dist/SharedTreeEncoder.js.map +1 -1
- package/dist/Summary.d.ts +2 -2
- package/dist/Summary.d.ts.map +1 -1
- package/dist/Summary.js +2 -2
- package/dist/Summary.js.map +1 -1
- package/dist/SummaryBackCompatibility.d.ts.map +1 -1
- package/dist/SummaryBackCompatibility.js.map +1 -1
- package/dist/SummaryTestUtilities.d.ts +1 -1
- package/dist/SummaryTestUtilities.d.ts.map +1 -1
- package/dist/SummaryTestUtilities.js.map +1 -1
- package/dist/Transaction.d.ts +3 -3
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +3 -3
- package/dist/Transaction.js.map +1 -1
- package/dist/TransactionInternal.d.ts +3 -3
- package/dist/TransactionInternal.d.ts.map +1 -1
- package/dist/TransactionInternal.js +6 -6
- package/dist/TransactionInternal.js.map +1 -1
- package/dist/TreeCompressor.d.ts +5 -1
- package/dist/TreeCompressor.d.ts.map +1 -1
- package/dist/TreeCompressor.js +5 -5
- package/dist/TreeCompressor.js.map +1 -1
- package/dist/TreeNodeHandle.d.ts +1 -1
- package/dist/TreeNodeHandle.d.ts.map +1 -1
- package/dist/TreeNodeHandle.js.map +1 -1
- package/dist/TreeView.d.ts +1 -1
- package/dist/TreeView.d.ts.map +1 -1
- package/dist/TreeView.js +2 -3
- package/dist/TreeView.js.map +1 -1
- package/dist/UuidUtilities.d.ts.map +1 -1
- package/dist/UuidUtilities.js.map +1 -1
- package/dist/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
- package/dist/id-compressor/AppendOnlySortedMap.js +3 -3
- package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/dist/id-compressor/IdCompressor.d.ts +1 -1
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
- package/dist/id-compressor/IdCompressor.js +25 -26
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/id-compressor/IdRange.d.ts.map +1 -1
- package/dist/id-compressor/IdRange.js +2 -2
- package/dist/id-compressor/IdRange.js.map +1 -1
- package/dist/id-compressor/NumericUuid.d.ts.map +1 -1
- package/dist/id-compressor/NumericUuid.js +2 -1
- package/dist/id-compressor/NumericUuid.js.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.js +8 -9
- package/dist/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/dist/migration-shim/migrationDeltaHandler.d.ts +1 -1
- package/dist/migration-shim/migrationDeltaHandler.d.ts.map +1 -1
- package/dist/migration-shim/migrationDeltaHandler.js +11 -11
- package/dist/migration-shim/migrationDeltaHandler.js.map +1 -1
- package/dist/migration-shim/migrationShim.d.ts +8 -4
- package/dist/migration-shim/migrationShim.d.ts.map +1 -1
- package/dist/migration-shim/migrationShim.js +13 -13
- package/dist/migration-shim/migrationShim.js.map +1 -1
- package/dist/migration-shim/migrationShimFactory.d.ts +2 -2
- package/dist/migration-shim/migrationShimFactory.d.ts.map +1 -1
- package/dist/migration-shim/migrationShimFactory.js +2 -2
- package/dist/migration-shim/migrationShimFactory.js.map +1 -1
- package/dist/migration-shim/packageVersion.d.ts +0 -2
- package/dist/migration-shim/packageVersion.d.ts.map +1 -1
- package/dist/migration-shim/packageVersion.js +0 -2
- package/dist/migration-shim/packageVersion.js.map +1 -1
- package/dist/migration-shim/sharedTreeDeltaHandler.d.ts.map +1 -1
- package/dist/migration-shim/sharedTreeDeltaHandler.js +8 -8
- package/dist/migration-shim/sharedTreeDeltaHandler.js.map +1 -1
- package/dist/migration-shim/sharedTreeShim.d.ts +2 -2
- package/dist/migration-shim/sharedTreeShim.d.ts.map +1 -1
- package/dist/migration-shim/sharedTreeShim.js +8 -4
- package/dist/migration-shim/sharedTreeShim.js.map +1 -1
- package/dist/migration-shim/sharedTreeShimFactory.d.ts +1 -1
- package/dist/migration-shim/sharedTreeShimFactory.d.ts.map +1 -1
- package/dist/migration-shim/sharedTreeShimFactory.js +2 -2
- package/dist/migration-shim/sharedTreeShimFactory.js.map +1 -1
- package/dist/migration-shim/shimChannelServices.d.ts +1 -1
- package/dist/migration-shim/shimChannelServices.d.ts.map +1 -1
- package/dist/migration-shim/shimChannelServices.js.map +1 -1
- package/dist/migration-shim/shimDeltaConnection.d.ts +1 -1
- package/dist/migration-shim/shimDeltaConnection.d.ts.map +1 -1
- package/dist/migration-shim/shimDeltaConnection.js +2 -2
- package/dist/migration-shim/shimDeltaConnection.js.map +1 -1
- package/dist/migration-shim/shimHandle.d.ts.map +1 -1
- package/dist/migration-shim/shimHandle.js.map +1 -1
- package/dist/migration-shim/types.d.ts +1 -1
- package/dist/migration-shim/types.d.ts.map +1 -1
- package/dist/migration-shim/types.js.map +1 -1
- package/dist/migration-shim/utils.d.ts +1 -1
- package/dist/migration-shim/utils.d.ts.map +1 -1
- package/dist/migration-shim/utils.js.map +1 -1
- package/dist/persisted-types/0.0.2.d.ts +1 -1
- package/dist/persisted-types/0.0.2.d.ts.map +1 -1
- package/dist/persisted-types/0.0.2.js.map +1 -1
- package/dist/persisted-types/0.1.1.d.ts +1 -1
- package/dist/persisted-types/0.1.1.d.ts.map +1 -1
- package/dist/persisted-types/0.1.1.js +3 -3
- package/dist/persisted-types/0.1.1.js.map +1 -1
- package/lib/ChangeCompression.d.ts +2 -2
- package/lib/ChangeCompression.d.ts.map +1 -1
- package/lib/ChangeCompression.js +1 -1
- package/lib/ChangeCompression.js.map +1 -1
- package/lib/ChangeTypes.d.ts +1 -1
- package/lib/ChangeTypes.d.ts.map +1 -1
- package/lib/ChangeTypes.js +2 -2
- package/lib/ChangeTypes.js.map +1 -1
- package/lib/Checkout.d.ts +3 -3
- package/lib/Checkout.d.ts.map +1 -1
- package/lib/Checkout.js +4 -4
- package/lib/Checkout.js.map +1 -1
- package/lib/EditLog.d.ts +1 -1
- package/lib/EditLog.d.ts.map +1 -1
- package/lib/EditLog.js +2 -2
- package/lib/EditLog.js.map +1 -1
- package/lib/EditUtilities.d.ts +3 -3
- package/lib/EditUtilities.d.ts.map +1 -1
- package/lib/EditUtilities.js +5 -5
- package/lib/EditUtilities.js.map +1 -1
- package/lib/Forest.d.ts.map +1 -1
- package/lib/Forest.js +2 -2
- package/lib/Forest.js.map +1 -1
- package/lib/HistoryEditFactory.d.ts +1 -1
- package/lib/HistoryEditFactory.d.ts.map +1 -1
- package/lib/HistoryEditFactory.js +5 -5
- package/lib/HistoryEditFactory.js.map +1 -1
- package/lib/IdConversion.d.ts.map +1 -1
- package/lib/IdConversion.js.map +1 -1
- package/lib/LogViewer.d.ts +2 -2
- package/lib/LogViewer.d.ts.map +1 -1
- package/lib/LogViewer.js +3 -3
- package/lib/LogViewer.js.map +1 -1
- package/lib/MergeHealth.d.ts.map +1 -1
- package/lib/MergeHealth.js +1 -1
- package/lib/MergeHealth.js.map +1 -1
- package/lib/NodeIdUtilities.d.ts +1 -1
- package/lib/NodeIdUtilities.d.ts.map +1 -1
- package/lib/NodeIdUtilities.js +1 -1
- package/lib/NodeIdUtilities.js.map +1 -1
- package/lib/PayloadUtilities.d.ts.map +1 -1
- package/lib/PayloadUtilities.js +1 -1
- package/lib/PayloadUtilities.js.map +1 -1
- package/lib/ReconciliationPath.d.ts +1 -1
- package/lib/ReconciliationPath.d.ts.map +1 -1
- package/lib/ReconciliationPath.js.map +1 -1
- package/lib/RevisionValueCache.d.ts.map +1 -1
- package/lib/RevisionValueCache.js +2 -2
- package/lib/RevisionValueCache.js.map +1 -1
- package/lib/RevisionView.d.ts +2 -2
- package/lib/RevisionView.d.ts.map +1 -1
- package/lib/RevisionView.js.map +1 -1
- package/lib/SerializationUtilities.d.ts +1 -1
- package/lib/SerializationUtilities.d.ts.map +1 -1
- package/lib/SerializationUtilities.js.map +1 -1
- package/lib/SharedTree.d.ts +8 -7
- package/lib/SharedTree.d.ts.map +1 -1
- package/lib/SharedTree.js +13 -13
- package/lib/SharedTree.js.map +1 -1
- package/lib/SharedTreeEncoder.d.ts +1 -1
- package/lib/SharedTreeEncoder.d.ts.map +1 -1
- package/lib/SharedTreeEncoder.js +5 -5
- package/lib/SharedTreeEncoder.js.map +1 -1
- package/lib/Summary.d.ts +2 -2
- package/lib/Summary.d.ts.map +1 -1
- package/lib/Summary.js +1 -1
- package/lib/Summary.js.map +1 -1
- package/lib/SummaryBackCompatibility.d.ts.map +1 -1
- package/lib/SummaryBackCompatibility.js.map +1 -1
- package/lib/SummaryTestUtilities.d.ts +1 -1
- package/lib/SummaryTestUtilities.d.ts.map +1 -1
- package/lib/SummaryTestUtilities.js.map +1 -1
- package/lib/Transaction.d.ts +3 -3
- package/lib/Transaction.d.ts.map +1 -1
- package/lib/Transaction.js +3 -3
- package/lib/Transaction.js.map +1 -1
- package/lib/TransactionInternal.d.ts +3 -3
- package/lib/TransactionInternal.d.ts.map +1 -1
- package/lib/TransactionInternal.js +3 -3
- package/lib/TransactionInternal.js.map +1 -1
- package/lib/TreeCompressor.d.ts +5 -1
- package/lib/TreeCompressor.d.ts.map +1 -1
- package/lib/TreeCompressor.js +2 -2
- package/lib/TreeCompressor.js.map +1 -1
- package/lib/TreeNodeHandle.d.ts +1 -1
- package/lib/TreeNodeHandle.d.ts.map +1 -1
- package/lib/TreeNodeHandle.js.map +1 -1
- package/lib/TreeView.d.ts +1 -1
- package/lib/TreeView.d.ts.map +1 -1
- package/lib/TreeView.js +1 -2
- package/lib/TreeView.js.map +1 -1
- package/lib/UuidUtilities.d.ts.map +1 -1
- package/lib/UuidUtilities.js +1 -1
- package/lib/UuidUtilities.js.map +1 -1
- package/lib/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
- package/lib/id-compressor/AppendOnlySortedMap.js +1 -1
- package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/lib/id-compressor/IdCompressor.d.ts +1 -1
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
- package/lib/id-compressor/IdCompressor.js +4 -5
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/id-compressor/IdRange.d.ts.map +1 -1
- package/lib/id-compressor/IdRange.js +1 -1
- package/lib/id-compressor/IdRange.js.map +1 -1
- package/lib/id-compressor/NumericUuid.d.ts.map +1 -1
- package/lib/id-compressor/NumericUuid.js +2 -1
- package/lib/id-compressor/NumericUuid.js.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.js +1 -2
- package/lib/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/lib/migration-shim/migrationDeltaHandler.d.ts +1 -1
- package/lib/migration-shim/migrationDeltaHandler.d.ts.map +1 -1
- package/lib/migration-shim/migrationDeltaHandler.js +1 -1
- package/lib/migration-shim/migrationDeltaHandler.js.map +1 -1
- package/lib/migration-shim/migrationShim.d.ts +8 -4
- package/lib/migration-shim/migrationShim.d.ts.map +1 -1
- package/lib/migration-shim/migrationShim.js +3 -3
- package/lib/migration-shim/migrationShim.js.map +1 -1
- package/lib/migration-shim/migrationShimFactory.d.ts +2 -2
- package/lib/migration-shim/migrationShimFactory.d.ts.map +1 -1
- package/lib/migration-shim/migrationShimFactory.js +1 -1
- package/lib/migration-shim/migrationShimFactory.js.map +1 -1
- package/lib/migration-shim/packageVersion.d.ts +0 -2
- package/lib/migration-shim/packageVersion.d.ts.map +1 -1
- package/lib/migration-shim/packageVersion.js +0 -2
- package/lib/migration-shim/packageVersion.js.map +1 -1
- package/lib/migration-shim/sharedTreeDeltaHandler.d.ts.map +1 -1
- package/lib/migration-shim/sharedTreeDeltaHandler.js +1 -1
- package/lib/migration-shim/sharedTreeDeltaHandler.js.map +1 -1
- package/lib/migration-shim/sharedTreeShim.d.ts +2 -2
- package/lib/migration-shim/sharedTreeShim.d.ts.map +1 -1
- package/lib/migration-shim/sharedTreeShim.js +6 -2
- package/lib/migration-shim/sharedTreeShim.js.map +1 -1
- package/lib/migration-shim/sharedTreeShimFactory.d.ts +1 -1
- package/lib/migration-shim/sharedTreeShimFactory.d.ts.map +1 -1
- package/lib/migration-shim/sharedTreeShimFactory.js +1 -1
- package/lib/migration-shim/sharedTreeShimFactory.js.map +1 -1
- package/lib/migration-shim/shimChannelServices.d.ts +1 -1
- package/lib/migration-shim/shimChannelServices.d.ts.map +1 -1
- package/lib/migration-shim/shimChannelServices.js.map +1 -1
- package/lib/migration-shim/shimDeltaConnection.d.ts +1 -1
- package/lib/migration-shim/shimDeltaConnection.d.ts.map +1 -1
- package/lib/migration-shim/shimDeltaConnection.js +1 -1
- package/lib/migration-shim/shimDeltaConnection.js.map +1 -1
- package/lib/migration-shim/shimHandle.d.ts.map +1 -1
- package/lib/migration-shim/shimHandle.js.map +1 -1
- package/lib/migration-shim/types.d.ts +1 -1
- package/lib/migration-shim/types.d.ts.map +1 -1
- package/lib/migration-shim/types.js.map +1 -1
- package/lib/migration-shim/utils.d.ts +1 -1
- package/lib/migration-shim/utils.d.ts.map +1 -1
- package/lib/migration-shim/utils.js.map +1 -1
- package/lib/persisted-types/0.0.2.d.ts +1 -1
- package/lib/persisted-types/0.0.2.d.ts.map +1 -1
- package/lib/persisted-types/0.0.2.js.map +1 -1
- package/lib/persisted-types/0.1.1.d.ts +1 -1
- package/lib/persisted-types/0.1.1.d.ts.map +1 -1
- package/lib/persisted-types/0.1.1.js +1 -1
- package/lib/persisted-types/0.1.1.js.map +1 -1
- package/package.json +33 -32
- package/src/ChangeCompression.ts +8 -8
- package/src/ChangeTypes.ts +5 -4
- package/src/Checkout.ts +9 -7
- package/src/EditLog.ts +4 -3
- package/src/EditUtilities.ts +9 -8
- package/src/Forest.ts +3 -2
- package/src/HistoryEditFactory.ts +12 -11
- package/src/IdConversion.ts +2 -2
- package/src/LogViewer.ts +5 -4
- package/src/MergeHealth.ts +2 -1
- package/src/NodeIdUtilities.ts +2 -2
- package/src/PayloadUtilities.ts +2 -1
- package/src/ReconciliationPath.ts +1 -1
- package/src/RevisionValueCache.ts +3 -2
- package/src/RevisionView.ts +3 -3
- package/src/SerializationUtilities.ts +1 -1
- package/src/SharedTree.ts +46 -49
- package/src/SharedTreeEncoder.ts +30 -29
- package/src/Summary.ts +5 -3
- package/src/SummaryBackCompatibility.ts +1 -0
- package/src/SummaryTestUtilities.ts +2 -1
- package/src/Transaction.ts +7 -6
- package/src/TransactionInternal.ts +17 -16
- package/src/TreeCompressor.ts +6 -4
- package/src/TreeNodeHandle.ts +2 -2
- package/src/TreeView.ts +3 -3
- package/src/UuidUtilities.ts +2 -1
- package/src/id-compressor/AppendOnlySortedMap.ts +2 -1
- package/src/id-compressor/IdCompressor.ts +18 -17
- package/src/id-compressor/IdRange.ts +2 -1
- package/src/id-compressor/NumericUuid.ts +1 -1
- package/src/id-compressor/SessionIdNormalizer.ts +3 -3
- package/src/migration-shim/migrationDeltaHandler.ts +3 -2
- package/src/migration-shim/migrationShim.ts +14 -10
- package/src/migration-shim/migrationShimFactory.ts +6 -4
- package/src/migration-shim/packageVersion.ts +0 -2
- package/src/migration-shim/sharedTreeDeltaHandler.ts +3 -2
- package/src/migration-shim/sharedTreeShim.ts +7 -5
- package/src/migration-shim/sharedTreeShimFactory.ts +3 -3
- package/src/migration-shim/shimChannelServices.ts +1 -1
- package/src/migration-shim/shimDeltaConnection.ts +3 -2
- package/src/migration-shim/shimHandle.ts +1 -0
- package/src/migration-shim/types.ts +3 -1
- package/src/migration-shim/utils.ts +2 -1
- package/src/persisted-types/0.0.2.ts +2 -2
- package/src/persisted-types/0.1.1.ts +10 -8
- package/dist/tree-alpha.d.ts +0 -2901
- package/dist/tree-beta.d.ts +0 -348
- package/dist/tree-public.d.ts +0 -348
- package/dist/tree-untrimmed.d.ts +0 -3820
- package/lib/test/AppendOnlySortedMap.perf.tests.d.ts +0 -6
- package/lib/test/AppendOnlySortedMap.perf.tests.d.ts.map +0 -1
- package/lib/test/AppendOnlySortedMap.perf.tests.js +0 -49
- package/lib/test/AppendOnlySortedMap.perf.tests.js.map +0 -1
- package/lib/test/AppendOnlySortedMap.tests.d.ts +0 -6
- package/lib/test/AppendOnlySortedMap.tests.d.ts.map +0 -1
- package/lib/test/AppendOnlySortedMap.tests.js +0 -213
- package/lib/test/AppendOnlySortedMap.tests.js.map +0 -1
- package/lib/test/ChangeCompression.tests.d.ts +0 -6
- package/lib/test/ChangeCompression.tests.d.ts.map +0 -1
- package/lib/test/ChangeCompression.tests.js +0 -154
- package/lib/test/ChangeCompression.tests.js.map +0 -1
- package/lib/test/Checkout.tests.d.ts +0 -10
- package/lib/test/Checkout.tests.d.ts.map +0 -1
- package/lib/test/Checkout.tests.js +0 -460
- package/lib/test/Checkout.tests.js.map +0 -1
- package/lib/test/Common.tests.d.ts +0 -6
- package/lib/test/Common.tests.d.ts.map +0 -1
- package/lib/test/Common.tests.js +0 -102
- package/lib/test/Common.tests.js.map +0 -1
- package/lib/test/EagerCheckout.tests.d.ts +0 -6
- package/lib/test/EagerCheckout.tests.d.ts.map +0 -1
- package/lib/test/EagerCheckout.tests.js +0 -20
- package/lib/test/EagerCheckout.tests.js.map +0 -1
- package/lib/test/Edit.tests.d.ts +0 -6
- package/lib/test/Edit.tests.d.ts.map +0 -1
- package/lib/test/Edit.tests.js +0 -60
- package/lib/test/Edit.tests.js.map +0 -1
- package/lib/test/EditLog.perf.tests.d.ts +0 -6
- package/lib/test/EditLog.perf.tests.d.ts.map +0 -1
- package/lib/test/EditLog.perf.tests.js +0 -41
- package/lib/test/EditLog.perf.tests.js.map +0 -1
- package/lib/test/EditLog.tests.d.ts +0 -6
- package/lib/test/EditLog.tests.d.ts.map +0 -1
- package/lib/test/EditLog.tests.js +0 -355
- package/lib/test/EditLog.tests.js.map +0 -1
- package/lib/test/EditUtilities.tests.d.ts +0 -6
- package/lib/test/EditUtilities.tests.d.ts.map +0 -1
- package/lib/test/EditUtilities.tests.js +0 -512
- package/lib/test/EditUtilities.tests.js.map +0 -1
- package/lib/test/Forest.perf.tests.d.ts +0 -6
- package/lib/test/Forest.perf.tests.d.ts.map +0 -1
- package/lib/test/Forest.perf.tests.js +0 -135
- package/lib/test/Forest.perf.tests.js.map +0 -1
- package/lib/test/Forest.tests.d.ts +0 -6
- package/lib/test/Forest.tests.d.ts.map +0 -1
- package/lib/test/Forest.tests.js +0 -213
- package/lib/test/Forest.tests.js.map +0 -1
- package/lib/test/GenericTransaction.tests.d.ts +0 -6
- package/lib/test/GenericTransaction.tests.d.ts.map +0 -1
- package/lib/test/GenericTransaction.tests.js +0 -31
- package/lib/test/GenericTransaction.tests.js.map +0 -1
- package/lib/test/HistoryEditFactory.tests.d.ts +0 -6
- package/lib/test/HistoryEditFactory.tests.d.ts.map +0 -1
- package/lib/test/HistoryEditFactory.tests.js +0 -170
- package/lib/test/HistoryEditFactory.tests.js.map +0 -1
- package/lib/test/IdCompressor.perf.tests.d.ts +0 -6
- package/lib/test/IdCompressor.perf.tests.d.ts.map +0 -1
- package/lib/test/IdCompressor.perf.tests.js +0 -290
- package/lib/test/IdCompressor.perf.tests.js.map +0 -1
- package/lib/test/IdCompressor.tests.d.ts +0 -6
- package/lib/test/IdCompressor.tests.d.ts.map +0 -1
- package/lib/test/IdCompressor.tests.js +0 -1542
- package/lib/test/IdCompressor.tests.js.map +0 -1
- package/lib/test/IdConversion.tests.d.ts +0 -6
- package/lib/test/IdConversion.tests.d.ts.map +0 -1
- package/lib/test/IdConversion.tests.js +0 -36
- package/lib/test/IdConversion.tests.js.map +0 -1
- package/lib/test/LazyCheckout.tests.d.ts +0 -6
- package/lib/test/LazyCheckout.tests.d.ts.map +0 -1
- package/lib/test/LazyCheckout.tests.js +0 -22
- package/lib/test/LazyCheckout.tests.js.map +0 -1
- package/lib/test/LogViewer.tests.d.ts +0 -6
- package/lib/test/LogViewer.tests.d.ts.map +0 -1
- package/lib/test/LogViewer.tests.js +0 -588
- package/lib/test/LogViewer.tests.js.map +0 -1
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.d.ts +0 -6
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.d.ts.map +0 -1
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js +0 -351
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js.map +0 -1
- package/lib/test/NumericUuid.perf.tests.d.ts +0 -6
- package/lib/test/NumericUuid.perf.tests.d.ts.map +0 -1
- package/lib/test/NumericUuid.perf.tests.js +0 -68
- package/lib/test/NumericUuid.perf.tests.js.map +0 -1
- package/lib/test/NumericUuid.tests.d.ts +0 -6
- package/lib/test/NumericUuid.tests.d.ts.map +0 -1
- package/lib/test/NumericUuid.tests.js +0 -192
- package/lib/test/NumericUuid.tests.js.map +0 -1
- package/lib/test/RevisionValueCache.tests.d.ts +0 -6
- package/lib/test/RevisionValueCache.tests.d.ts.map +0 -1
- package/lib/test/RevisionValueCache.tests.js +0 -106
- package/lib/test/RevisionValueCache.tests.js.map +0 -1
- package/lib/test/RevisionView.tests.d.ts +0 -6
- package/lib/test/RevisionView.tests.d.ts.map +0 -1
- package/lib/test/RevisionView.tests.js +0 -131
- package/lib/test/RevisionView.tests.js.map +0 -1
- package/lib/test/SessionIdNormalizer.tests.d.ts +0 -6
- package/lib/test/SessionIdNormalizer.tests.d.ts.map +0 -1
- package/lib/test/SessionIdNormalizer.tests.js +0 -377
- package/lib/test/SessionIdNormalizer.tests.js.map +0 -1
- package/lib/test/SharedTree.fuzz.tests.d.ts +0 -6
- package/lib/test/SharedTree.fuzz.tests.d.ts.map +0 -1
- package/lib/test/SharedTree.fuzz.tests.js +0 -9
- package/lib/test/SharedTree.fuzz.tests.js.map +0 -1
- package/lib/test/SharedTree.perf.tests.d.ts +0 -6
- package/lib/test/SharedTree.perf.tests.d.ts.map +0 -1
- package/lib/test/SharedTree.perf.tests.js +0 -39
- package/lib/test/SharedTree.perf.tests.js.map +0 -1
- package/lib/test/SharedTree.tests.d.ts +0 -6
- package/lib/test/SharedTree.tests.d.ts.map +0 -1
- package/lib/test/SharedTree.tests.js +0 -22
- package/lib/test/SharedTree.tests.js.map +0 -1
- package/lib/test/StringInterner.tests.d.ts +0 -6
- package/lib/test/StringInterner.tests.d.ts.map +0 -1
- package/lib/test/StringInterner.tests.js +0 -73
- package/lib/test/StringInterner.tests.js.map +0 -1
- package/lib/test/Summary.tests.d.ts +0 -7
- package/lib/test/Summary.tests.d.ts.map +0 -1
- package/lib/test/Summary.tests.js +0 -386
- package/lib/test/Summary.tests.js.map +0 -1
- package/lib/test/Transaction.tests.d.ts +0 -6
- package/lib/test/Transaction.tests.d.ts.map +0 -1
- package/lib/test/Transaction.tests.js +0 -124
- package/lib/test/Transaction.tests.js.map +0 -1
- package/lib/test/TransactionInternal.tests.d.ts +0 -6
- package/lib/test/TransactionInternal.tests.d.ts.map +0 -1
- package/lib/test/TransactionInternal.tests.js +0 -576
- package/lib/test/TransactionInternal.tests.js.map +0 -1
- package/lib/test/TreeCompression.tests.d.ts +0 -6
- package/lib/test/TreeCompression.tests.d.ts.map +0 -1
- package/lib/test/TreeCompression.tests.js +0 -291
- package/lib/test/TreeCompression.tests.js.map +0 -1
- package/lib/test/TreeView.tests.d.ts +0 -6
- package/lib/test/TreeView.tests.d.ts.map +0 -1
- package/lib/test/TreeView.tests.js +0 -178
- package/lib/test/TreeView.tests.js.map +0 -1
- package/lib/test/UndoRedoHandler.tests.d.ts +0 -6
- package/lib/test/UndoRedoHandler.tests.d.ts.map +0 -1
- package/lib/test/UndoRedoHandler.tests.js +0 -37
- package/lib/test/UndoRedoHandler.tests.js.map +0 -1
- package/lib/test/fuzz/Generators.d.ts +0 -8
- package/lib/test/fuzz/Generators.d.ts.map +0 -1
- package/lib/test/fuzz/Generators.js +0 -345
- package/lib/test/fuzz/Generators.js.map +0 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +0 -23
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +0 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js +0 -241
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +0 -1
- package/lib/test/fuzz/Types.d.ts +0 -136
- package/lib/test/fuzz/Types.d.ts.map +0 -1
- package/lib/test/fuzz/Types.js +0 -6
- package/lib/test/fuzz/Types.js.map +0 -1
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts +0 -246
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +0 -1
- package/lib/test/utilities/IdCompressorTestUtilities.js +0 -608
- package/lib/test/utilities/IdCompressorTestUtilities.js.map +0 -1
- package/lib/test/utilities/MockTransaction.d.ts +0 -35
- package/lib/test/utilities/MockTransaction.d.ts.map +0 -1
- package/lib/test/utilities/MockTransaction.js +0 -51
- package/lib/test/utilities/MockTransaction.js.map +0 -1
- package/lib/test/utilities/PendingLocalStateTests.d.ts +0 -12
- package/lib/test/utilities/PendingLocalStateTests.d.ts.map +0 -1
- package/lib/test/utilities/PendingLocalStateTests.js +0 -223
- package/lib/test/utilities/PendingLocalStateTests.js.map +0 -1
- package/lib/test/utilities/SharedTreeTests.d.ts +0 -12
- package/lib/test/utilities/SharedTreeTests.d.ts.map +0 -1
- package/lib/test/utilities/SharedTreeTests.js +0 -949
- package/lib/test/utilities/SharedTreeTests.js.map +0 -1
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts +0 -11
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +0 -1
- package/lib/test/utilities/SharedTreeVersioningTests.js +0 -439
- package/lib/test/utilities/SharedTreeVersioningTests.js.map +0 -1
- package/lib/test/utilities/SummaryLoadPerfTests.d.ts +0 -10
- package/lib/test/utilities/SummaryLoadPerfTests.d.ts.map +0 -1
- package/lib/test/utilities/SummaryLoadPerfTests.js +0 -105
- package/lib/test/utilities/SummaryLoadPerfTests.js.map +0 -1
- package/lib/test/utilities/SummarySizeTests.d.ts +0 -11
- package/lib/test/utilities/SummarySizeTests.d.ts.map +0 -1
- package/lib/test/utilities/SummarySizeTests.js +0 -160
- package/lib/test/utilities/SummarySizeTests.js.map +0 -1
- package/lib/test/utilities/TestCommon.d.ts +0 -13
- package/lib/test/utilities/TestCommon.d.ts.map +0 -1
- package/lib/test/utilities/TestCommon.js +0 -19
- package/lib/test/utilities/TestCommon.js.map +0 -1
- package/lib/test/utilities/TestNode.d.ts +0 -140
- package/lib/test/utilities/TestNode.d.ts.map +0 -1
- package/lib/test/utilities/TestNode.js +0 -282
- package/lib/test/utilities/TestNode.js.map +0 -1
- package/lib/test/utilities/TestSerializer.d.ts +0 -24
- package/lib/test/utilities/TestSerializer.d.ts.map +0 -1
- package/lib/test/utilities/TestSerializer.js +0 -40
- package/lib/test/utilities/TestSerializer.js.map +0 -1
- package/lib/test/utilities/TestUtilities.d.ts +0 -212
- package/lib/test/utilities/TestUtilities.d.ts.map +0 -1
- package/lib/test/utilities/TestUtilities.js +0 -413
- package/lib/test/utilities/TestUtilities.js.map +0 -1
- package/lib/test/utilities/UndoRedoTests.d.ts +0 -32
- package/lib/test/utilities/UndoRedoTests.d.ts.map +0 -1
- package/lib/test/utilities/UndoRedoTests.js +0 -317
- package/lib/test/utilities/UndoRedoTests.js.map +0 -1
- /package/{dist → lib}/tsdoc-metadata.json +0 -0
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { benchmark, BenchmarkType } from '@fluid-tools/benchmark';
|
|
6
|
-
import { defaultClusterCapacity } from '../id-compressor/IdCompressor.js';
|
|
7
|
-
import { getPositiveDelta, incrementUuid, numericUuidFromStableId, stableIdFromNumericUuid, } from '../id-compressor/NumericUuid.js';
|
|
8
|
-
import { assertIsStableId, generateStableId } from '../UuidUtilities.js';
|
|
9
|
-
describe('NumericUuid Perf', () => {
|
|
10
|
-
const stableId = assertIsStableId('4779fbf2-2012-4510-b4f0-28a99a9f8946');
|
|
11
|
-
const stableId2 = assertIsStableId('5ccf492c-6a82-438c-9129-d76467525912');
|
|
12
|
-
const stableId3 = assertIsStableId('5ccf492c-6a82-438c-9129-d76467515912');
|
|
13
|
-
const uuid = numericUuidFromStableId(stableId);
|
|
14
|
-
const uuid2 = numericUuidFromStableId(stableId2);
|
|
15
|
-
const uuid3 = numericUuidFromStableId(stableId3);
|
|
16
|
-
const deltaMax = 2 ** 52 - 1;
|
|
17
|
-
const type = BenchmarkType.Measurement;
|
|
18
|
-
benchmark({
|
|
19
|
-
type,
|
|
20
|
-
title: `convert uuid string to numeric uuid`,
|
|
21
|
-
benchmarkFn: () => {
|
|
22
|
-
numericUuidFromStableId(stableId);
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
benchmark({
|
|
26
|
-
type,
|
|
27
|
-
title: `incrementing a uuid`,
|
|
28
|
-
benchmarkFn: () => {
|
|
29
|
-
incrementUuid(uuid, defaultClusterCapacity);
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
benchmark({
|
|
33
|
-
type,
|
|
34
|
-
title: `convert a uuid string into a session uuid`,
|
|
35
|
-
benchmarkFn: () => {
|
|
36
|
-
numericUuidFromStableId(stableId);
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
benchmark({
|
|
40
|
-
type,
|
|
41
|
-
title: `convert an numeric uuid into a uuid string`,
|
|
42
|
-
benchmarkFn: () => {
|
|
43
|
-
stableIdFromNumericUuid(uuid);
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
benchmark({
|
|
47
|
-
type,
|
|
48
|
-
title: `compute the delta between two distant numeric uuids`,
|
|
49
|
-
benchmarkFn: () => {
|
|
50
|
-
getPositiveDelta(uuid, uuid2, deltaMax);
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
benchmark({
|
|
54
|
-
type,
|
|
55
|
-
title: `compute the delta between two close numeric uuids`,
|
|
56
|
-
benchmarkFn: () => {
|
|
57
|
-
getPositiveDelta(uuid2, uuid3, deltaMax);
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
benchmark({
|
|
61
|
-
type,
|
|
62
|
-
title: `generate a random v4 uuid string`,
|
|
63
|
-
benchmarkFn: () => {
|
|
64
|
-
generateStableId();
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
//# sourceMappingURL=NumericUuid.perf.tests.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NumericUuid.perf.tests.js","sourceRoot":"","sources":["../../src/test/NumericUuid.perf.tests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EACN,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IACjC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,sCAAsC,CAAC,CAAC;IAC1E,MAAM,SAAS,GAAG,gBAAgB,CAAC,sCAAs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AAE,GAAG,EAAE;YACjB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC1C,CAAC;KACD,CAAC,CAAC;IACH,SAAS,CAAC;QACT,IAAI;QACJ,KAAK,EAAE,kCAAkC;QACzC,WAAW,EAAE,GAAG,EAAE;YACjB,gBAAgB,EAAE,CAAC;QACpB,CAAC;KACD,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 { benchmark, BenchmarkType } from '@fluid-tools/benchmark';\nimport { defaultClusterCapacity } from '../id-compressor/IdCompressor.js';\nimport {\n\tgetPositiveDelta,\n\tincrementUuid,\n\tnumericUuidFromStableId,\n\tstableIdFromNumericUuid,\n} from '../id-compressor/NumericUuid.js';\nimport { assertIsStableId, generateStableId } from '../UuidUtilities.js';\n\ndescribe('NumericUuid Perf', () => {\n\tconst stableId = assertIsStableId('4779fbf2-2012-4510-b4f0-28a99a9f8946');\n\tconst stableId2 = assertIsStableId('5ccf492c-6a82-438c-9129-d76467525912');\n\tconst stableId3 = assertIsStableId('5ccf492c-6a82-438c-9129-d76467515912');\n\tconst uuid = numericUuidFromStableId(stableId);\n\tconst uuid2 = numericUuidFromStableId(stableId2);\n\tconst uuid3 = numericUuidFromStableId(stableId3);\n\tconst deltaMax = 2 ** 52 - 1;\n\tconst type = BenchmarkType.Measurement;\n\tbenchmark({\n\t\ttype,\n\t\ttitle: `convert uuid string to numeric uuid`,\n\t\tbenchmarkFn: () => {\n\t\t\tnumericUuidFromStableId(stableId);\n\t\t},\n\t});\n\tbenchmark({\n\t\ttype,\n\t\ttitle: `incrementing a uuid`,\n\t\tbenchmarkFn: () => {\n\t\t\tincrementUuid(uuid, defaultClusterCapacity);\n\t\t},\n\t});\n\tbenchmark({\n\t\ttype,\n\t\ttitle: `convert a uuid string into a session uuid`,\n\t\tbenchmarkFn: () => {\n\t\t\tnumericUuidFromStableId(stableId);\n\t\t},\n\t});\n\tbenchmark({\n\t\ttype,\n\t\ttitle: `convert an numeric uuid into a uuid string`,\n\t\tbenchmarkFn: () => {\n\t\t\tstableIdFromNumericUuid(uuid);\n\t\t},\n\t});\n\tbenchmark({\n\t\ttype,\n\t\ttitle: `compute the delta between two distant numeric uuids`,\n\t\tbenchmarkFn: () => {\n\t\t\tgetPositiveDelta(uuid, uuid2, deltaMax);\n\t\t},\n\t});\n\tbenchmark({\n\t\ttype,\n\t\ttitle: `compute the delta between two close numeric uuids`,\n\t\tbenchmarkFn: () => {\n\t\t\tgetPositiveDelta(uuid2, uuid3, deltaMax);\n\t\t},\n\t});\n\tbenchmark({\n\t\ttype,\n\t\ttitle: `generate a random v4 uuid string`,\n\t\tbenchmarkFn: () => {\n\t\t\tgenerateStableId();\n\t\t},\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NumericUuid.tests.d.ts","sourceRoot":"","sources":["../../src/test/NumericUuid.tests.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/* eslint-disable no-bitwise */
|
|
6
|
-
import { strict as assert } from 'assert';
|
|
7
|
-
import { expect } from 'chai';
|
|
8
|
-
import { makeRandom } from '@fluid-private/stochastic-test-utils';
|
|
9
|
-
import { validateAssertionError } from '@fluidframework/test-runtime-utils';
|
|
10
|
-
import { compareStrings } from '../Common.js';
|
|
11
|
-
import { numericUuidEquals, createSessionId, getPositiveDelta, incrementUuid, numericUuidFromStableId, stableIdFromNumericUuid, ensureSessionUuid, } from '../id-compressor/NumericUuid.js';
|
|
12
|
-
import { assertIsStableId, isStableId } from '../UuidUtilities.js';
|
|
13
|
-
import { integerToStableId } from './utilities/IdCompressorTestUtilities.js';
|
|
14
|
-
describe('NumericUuid', () => {
|
|
15
|
-
it('can detect non-v4 variant 2 UUIDs', () => {
|
|
16
|
-
expect(isStableId('00000000-0000-0000-0000-000000000000')).to.be.false;
|
|
17
|
-
expect(isStableId('ffffffff-ffff-ffff-ffff-ffffffffffff')).to.be.false;
|
|
18
|
-
expect(isStableId('8e8fec9a10ea4d158308ed35bc7f1e66')).to.be.false;
|
|
19
|
-
expect(isStableId('8e8fec9a-10ea-4d15-8308-ed35bc7f1e66')).to.be.true;
|
|
20
|
-
[...new Array(16).keys()]
|
|
21
|
-
.map((n) => [n, n.toString(16)])
|
|
22
|
-
.forEach(([n, char]) => {
|
|
23
|
-
const expectUuidVersion = expect(isStableId(`00000000-0000-${char}000-b000-000000000000`));
|
|
24
|
-
if (char === '4') {
|
|
25
|
-
expectUuidVersion.to.be.true;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
expectUuidVersion.to.be.false;
|
|
29
|
-
}
|
|
30
|
-
const expectUuidVariant = expect(isStableId(`00000000-0000-4000-${char}000-000000000000`));
|
|
31
|
-
if (n >= 8 && n <= 11) {
|
|
32
|
-
expectUuidVariant.to.be.true;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
expectUuidVariant.to.be.false;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
const maxStableId = assertIsStableId('ffffffff-ffff-4fff-bfff-ffffffffffff');
|
|
40
|
-
it('detects increment overflow', () => {
|
|
41
|
-
const uuid = numericUuidFromStableId(maxStableId);
|
|
42
|
-
assert.throws(() => stableIdFromNumericUuid(uuid, 1), (e) => validateAssertionError(e, 'Exceeded maximum numeric UUID'));
|
|
43
|
-
assert.throws(() => stableIdFromNumericUuid(incrementUuid(uuid, 1)), (e) => validateAssertionError(e, 'Exceeded maximum numeric UUID'));
|
|
44
|
-
assert.throws(() => stableIdFromNumericUuid(uuid, 256), (e) => validateAssertionError(e, 'Exceeded maximum numeric UUID'));
|
|
45
|
-
assert.throws(() => stableIdFromNumericUuid(incrementUuid(uuid, 256)), (e) => validateAssertionError(e, 'Exceeded maximum numeric UUID'));
|
|
46
|
-
assert.throws(() => stableIdFromNumericUuid(uuid, Number.MAX_SAFE_INTEGER), (e) => validateAssertionError(e, 'Exceeded maximum numeric UUID'));
|
|
47
|
-
assert.throws(() => stableIdFromNumericUuid(incrementUuid(uuid, Number.MAX_SAFE_INTEGER)), (e) => validateAssertionError(e, 'Exceeded maximum numeric UUID'));
|
|
48
|
-
});
|
|
49
|
-
it('can rehydrate a valid session UUID', () => {
|
|
50
|
-
const uuid = assertIsStableId('44f95a8b-c52b-4828-a000-0000f0000003');
|
|
51
|
-
const sessionUuid = numericUuidFromStableId(uuid);
|
|
52
|
-
expect(stableIdFromNumericUuid(sessionUuid)).to.equal(uuid);
|
|
53
|
-
});
|
|
54
|
-
it('can create valid session UUIDs', () => {
|
|
55
|
-
for (let i = 0; i < 100; i++) {
|
|
56
|
-
const sessionId = createSessionId();
|
|
57
|
-
expect(sessionId.length).to.equal(36);
|
|
58
|
-
const sessionNumericUuid = numericUuidFromStableId(sessionId);
|
|
59
|
-
expect(stableIdFromNumericUuid(sessionNumericUuid)).to.equal(sessionId);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
const maxUuidBigint = bigIntFromStableId(maxStableId);
|
|
63
|
-
it('ensures that session UUIDs are resistant to overflow', () => {
|
|
64
|
-
const uuid = assertIsStableId('ffffffff-ffff-4fff-bfff-ffffffffffff');
|
|
65
|
-
for (let i = 0; i < 128; i++) {
|
|
66
|
-
const ensuredUuid = ensureSessionUuid(uuid);
|
|
67
|
-
expect(isStableId(ensuredUuid)).to.be.true;
|
|
68
|
-
const ensuredBigint = bigIntFromStableId(ensuredUuid);
|
|
69
|
-
expect(maxUuidBigint - ensuredBigint > Number.MAX_SAFE_INTEGER).to.be.true;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
it('correctly adjusts session UUIDs that are in danger of overflow', () => {
|
|
73
|
-
const dangerous = [
|
|
74
|
-
assertIsStableId('ffffffff-ffff-4fff-bfff-ffffffffffff'),
|
|
75
|
-
assertIsStableId('ffffffff-ffff-4fff-bff0-000000000000'),
|
|
76
|
-
assertIsStableId('ffffffff-ffff-4fff-bf00-000000000000'),
|
|
77
|
-
];
|
|
78
|
-
const safe = [
|
|
79
|
-
assertIsStableId('ffffffff-ffff-4fff-beff-ffffffffffff'),
|
|
80
|
-
assertIsStableId('ffffffff-ffff-4fff-bef0-000000000000'),
|
|
81
|
-
assertIsStableId('ffffffff-ffff-4fff-be00-000000000000'),
|
|
82
|
-
];
|
|
83
|
-
dangerous.forEach((stableId) => expect(ensureSessionUuid(stableId)).to.not.equal(stableId));
|
|
84
|
-
safe.forEach((stableId) => expect(ensureSessionUuid(stableId)).to.equal(stableId));
|
|
85
|
-
});
|
|
86
|
-
const stableIds = [
|
|
87
|
-
assertIsStableId('748540ca-b7c5-4c99-83ff-c1b8e02c09d6'),
|
|
88
|
-
assertIsStableId('748540ca-b7c5-4c99-83ef-c1b8e02c09d6'),
|
|
89
|
-
assertIsStableId('748540ca-b7c5-4c99-831f-c1b8e02c09d6'),
|
|
90
|
-
assertIsStableId('0002c79e-b536-4776-b000-000266c252d5'),
|
|
91
|
-
assertIsStableId('082533b9-6d05-4068-a008-fe2cc43543f7'),
|
|
92
|
-
assertIsStableId('2c9fa1f8-48d5-4554-a466-000000000000'),
|
|
93
|
-
assertIsStableId('2c9fa1f8-48d5-4000-a000-000000000000'),
|
|
94
|
-
assertIsStableId('10000000-0000-4000-b000-000000000000'),
|
|
95
|
-
assertIsStableId('10000000-0000-4000-b020-000000000000'),
|
|
96
|
-
assertIsStableId('10000000-0000-4000-b00f-ffffffffffff'),
|
|
97
|
-
assertIsStableId('10000000-0000-4000-b040-000000000000'),
|
|
98
|
-
assertIsStableId('f0000000-0000-4000-8000-000000000000'),
|
|
99
|
-
assertIsStableId('efffffff-ffff-4fff-bfff-ffffffffffff'),
|
|
100
|
-
integerToStableId(0),
|
|
101
|
-
integerToStableId(1),
|
|
102
|
-
integerToStableId(77),
|
|
103
|
-
integerToStableId(1024),
|
|
104
|
-
integerToStableId(2 ** 32 - 1),
|
|
105
|
-
integerToStableId(2 ** 52 - 1),
|
|
106
|
-
integerToStableId(Number.MAX_SAFE_INTEGER),
|
|
107
|
-
integerToStableId(Number.MAX_SAFE_INTEGER - 1),
|
|
108
|
-
];
|
|
109
|
-
describe('incrementing', () => {
|
|
110
|
-
const rand = makeRandom(0);
|
|
111
|
-
const incrementAmounts = [
|
|
112
|
-
...[...new Array(53).keys()].map((n) => 2 ** n - 1),
|
|
113
|
-
...[...new Array(10).keys()].map((_) => rand.integer(0, Number.MAX_SAFE_INTEGER)),
|
|
114
|
-
];
|
|
115
|
-
stableIds.forEach((stableId) => {
|
|
116
|
-
it(`can increment ${stableId}`, () => {
|
|
117
|
-
const uuid = numericUuidFromStableId(stableId);
|
|
118
|
-
incrementAmounts.forEach((incrementAmount) => {
|
|
119
|
-
const bigintIncremented = bigIntFromStableId(stableId) + BigInt(incrementAmount);
|
|
120
|
-
const incremented = incrementUuid(uuid, incrementAmount);
|
|
121
|
-
const bigintStr = integerToStableId(bigintIncremented);
|
|
122
|
-
expect(stableIdFromNumericUuid(incremented)).to.equal(bigintStr);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
it('delta calculation can calculate the integer delta between stable ids', () => {
|
|
128
|
-
stableIds.forEach((stableIdA) => {
|
|
129
|
-
const uuidA = numericUuidFromStableId(stableIdA);
|
|
130
|
-
const bigintA = bigIntFromStableId(stableIdA);
|
|
131
|
-
const arbitraryMaxDelta = 2 ** 32 - 1;
|
|
132
|
-
stableIds.forEach((stableIdB) => {
|
|
133
|
-
const uuidB = numericUuidFromStableId(stableIdB);
|
|
134
|
-
const bigintB = bigIntFromStableId(stableIdB);
|
|
135
|
-
const realDelta = bigintA - bigintB;
|
|
136
|
-
const numericDelta = getPositiveDelta(uuidA, uuidB, Number.MAX_SAFE_INTEGER);
|
|
137
|
-
if (realDelta > Number.MAX_SAFE_INTEGER || realDelta < 0) {
|
|
138
|
-
expect(numericDelta).to.equal(undefined);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
expect(numericDelta).to.equal(Number(realDelta));
|
|
142
|
-
}
|
|
143
|
-
const numericDeltaCapped = getPositiveDelta(uuidA, uuidB, arbitraryMaxDelta);
|
|
144
|
-
if (realDelta >= 0 && realDelta <= arbitraryMaxDelta) {
|
|
145
|
-
expect(numericDeltaCapped).to.equal(Number(realDelta));
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
expect(numericDeltaCapped).to.equal(undefined);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
it('can round trip between stable ID and uuid', () => {
|
|
154
|
-
stableIds.forEach((stableId) => {
|
|
155
|
-
const uuid = numericUuidFromStableId(stableId);
|
|
156
|
-
const roundTripped = stableIdFromNumericUuid(uuid);
|
|
157
|
-
expect(stableId).to.equal(roundTripped);
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
it('can compare numeric uuids', () => {
|
|
161
|
-
stableIds.forEach((stableIdA) => {
|
|
162
|
-
stableIds.forEach((stableIdB) => {
|
|
163
|
-
const numericA = numericUuidFromStableId(stableIdA);
|
|
164
|
-
const numericB = numericUuidFromStableId(stableIdB);
|
|
165
|
-
const comparedNumeric = numericUuidEquals(numericA, numericB);
|
|
166
|
-
const comparedStrings = compareStrings(stableIdA, stableIdB);
|
|
167
|
-
expect(comparedNumeric).to.equal(comparedStrings === 0);
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
function bigIntFromStableId(id) {
|
|
173
|
-
const minimized = id.replace(/-/g, '');
|
|
174
|
-
// UUID | xxxxxxxx-xxxx-Vxxx-vxxx-xxxxxxxxxxxx | The StableId passed to this function, shown here in standard UUID notation
|
|
175
|
-
// nibbles | hhhhhhhh hhhh mmm llll llllllllllll | Whether or not each nibble is part of the "high", "middle" or "low" group below
|
|
176
|
-
// bit count | 44444444-4444-0444-2444-444444444444 | The number of bits per nibble that are used to encode the number
|
|
177
|
-
// Interpret numerically...
|
|
178
|
-
const highNibbles = BigInt(`0x${minimized.substr(0, 12)}`); // ...all nibbles above the version nibble,
|
|
179
|
-
const midNibbles = BigInt(`0x${minimized.substr(13, 3)}`); // the nibbles below the version nibble and above the variant nibble,
|
|
180
|
-
const lowNibbles = BigInt(`0x${minimized.substr(16, 16)}`); // and the variant nibble and all nibbles below
|
|
181
|
-
// Count the number of bits that contribute to the number (i.e. are not reserved for version/variant) in...
|
|
182
|
-
const lowBitCount = BigInt(62); // ...the low nibbles
|
|
183
|
-
const midBitCount = BigInt(12); // and the mid nibbles
|
|
184
|
-
// Shift the values of each region by the appropriate number of bits
|
|
185
|
-
const highNumber = highNibbles << (midBitCount + lowBitCount);
|
|
186
|
-
const midNumber = midNibbles << lowBitCount;
|
|
187
|
-
// The low nibbles include the variant nibble because its two low bits are numerical (but its two upper bits are not). So mask them out:
|
|
188
|
-
const lowNumber = lowNibbles & BigInt('0x3fffffffffffffff'); // A nibble '0011' followed by 15 nibbles '1111'.
|
|
189
|
-
// Now that high and mid are shifted correctly, the final number is their sum:
|
|
190
|
-
return highNumber + midNumber + lowNumber;
|
|
191
|
-
}
|
|
192
|
-
//# sourceMappingURL=NumericUuid.tests.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NumericUuid.tests.js","sourceRoot":"","sources":["../../src/test/NumericUuid.tests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,EAA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D,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,sBAAsB;IACtD,oEAAoE;IACpE,MAAM,UAAU,GAAG,WAAW,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC;IAC9D,MAAM,SAAS,GAAG,UAAU,IAAI,WAAW,CAAC;IAC5C,wIAAwI;IACxI,MAAM,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,iDAAiD;IAC9G,8EAA8E;IAC9E,OAAO,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAC3C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { strict as assert } from 'assert';\nimport { expect } from 'chai';\nimport { makeRandom } from '@fluid-private/stochastic-test-utils';\nimport { validateAssertionError } from '@fluidframework/test-runtime-utils';\nimport { compareStrings } from '../Common.js';\nimport {\n\tnumericUuidEquals,\n\tcreateSessionId,\n\tgetPositiveDelta,\n\tincrementUuid,\n\tnumericUuidFromStableId,\n\tstableIdFromNumericUuid,\n\tensureSessionUuid,\n} from '../id-compressor/NumericUuid.js';\nimport { StableId } from '../Identifiers.js';\nimport { assertIsStableId, isStableId } from '../UuidUtilities.js';\nimport { integerToStableId } from './utilities/IdCompressorTestUtilities.js';\n\ndescribe('NumericUuid', () => {\n\tit('can detect non-v4 variant 2 UUIDs', () => {\n\t\texpect(isStableId('00000000-0000-0000-0000-000000000000')).to.be.false;\n\t\texpect(isStableId('ffffffff-ffff-ffff-ffff-ffffffffffff')).to.be.false;\n\t\texpect(isStableId('8e8fec9a10ea4d158308ed35bc7f1e66')).to.be.false;\n\t\texpect(isStableId('8e8fec9a-10ea-4d15-8308-ed35bc7f1e66')).to.be.true;\n\t\t[...new Array(16).keys()]\n\t\t\t.map<[number, string]>((n) => [n, n.toString(16)])\n\t\t\t.forEach(([n, char]) => {\n\t\t\t\tconst expectUuidVersion = expect(isStableId(`00000000-0000-${char}000-b000-000000000000`));\n\t\t\t\tif (char === '4') {\n\t\t\t\t\texpectUuidVersion.to.be.true;\n\t\t\t\t} else {\n\t\t\t\t\texpectUuidVersion.to.be.false;\n\t\t\t\t}\n\n\t\t\t\tconst expectUuidVariant = expect(isStableId(`00000000-0000-4000-${char}000-000000000000`));\n\t\t\t\tif (n >= 8 && n <= 11) {\n\t\t\t\t\texpectUuidVariant.to.be.true;\n\t\t\t\t} else {\n\t\t\t\t\texpectUuidVariant.to.be.false;\n\t\t\t\t}\n\t\t\t});\n\t});\n\n\tconst maxStableId = assertIsStableId('ffffffff-ffff-4fff-bfff-ffffffffffff');\n\n\tit('detects increment overflow', () => {\n\t\tconst uuid = numericUuidFromStableId(maxStableId);\n\t\tassert.throws(\n\t\t\t() => stableIdFromNumericUuid(uuid, 1),\n\t\t\t(e: Error) => validateAssertionError(e, 'Exceeded maximum numeric UUID')\n\t\t);\n\t\tassert.throws(\n\t\t\t() => stableIdFromNumericUuid(incrementUuid(uuid, 1)),\n\t\t\t(e: Error) => validateAssertionError(e, 'Exceeded maximum numeric UUID')\n\t\t);\n\t\tassert.throws(\n\t\t\t() => stableIdFromNumericUuid(uuid, 256),\n\t\t\t(e: Error) => validateAssertionError(e, 'Exceeded maximum numeric UUID')\n\t\t);\n\t\tassert.throws(\n\t\t\t() => stableIdFromNumericUuid(incrementUuid(uuid, 256)),\n\t\t\t(e: Error) => validateAssertionError(e, 'Exceeded maximum numeric UUID')\n\t\t);\n\t\tassert.throws(\n\t\t\t() => stableIdFromNumericUuid(uuid, Number.MAX_SAFE_INTEGER),\n\t\t\t(e: Error) => validateAssertionError(e, 'Exceeded maximum numeric UUID')\n\t\t);\n\t\tassert.throws(\n\t\t\t() => stableIdFromNumericUuid(incrementUuid(uuid, Number.MAX_SAFE_INTEGER)),\n\t\t\t(e: Error) => validateAssertionError(e, 'Exceeded maximum numeric UUID')\n\t\t);\n\t});\n\n\tit('can rehydrate a valid session UUID', () => {\n\t\tconst uuid = assertIsStableId('44f95a8b-c52b-4828-a000-0000f0000003');\n\t\tconst sessionUuid = numericUuidFromStableId(uuid);\n\t\texpect(stableIdFromNumericUuid(sessionUuid)).to.equal(uuid);\n\t});\n\n\tit('can create valid session UUIDs', () => {\n\t\tfor (let i = 0; i < 100; i++) {\n\t\t\tconst sessionId = createSessionId();\n\t\t\texpect(sessionId.length).to.equal(36);\n\n\t\t\tconst sessionNumericUuid = numericUuidFromStableId(sessionId);\n\t\t\texpect(stableIdFromNumericUuid(sessionNumericUuid)).to.equal(sessionId);\n\t\t}\n\t});\n\n\tconst maxUuidBigint = bigIntFromStableId(maxStableId);\n\n\tit('ensures that session UUIDs are resistant to overflow', () => {\n\t\tconst uuid = assertIsStableId('ffffffff-ffff-4fff-bfff-ffffffffffff');\n\t\tfor (let i = 0; i < 128; i++) {\n\t\t\tconst ensuredUuid = ensureSessionUuid(uuid);\n\t\t\texpect(isStableId(ensuredUuid)).to.be.true;\n\t\t\tconst ensuredBigint = bigIntFromStableId(ensuredUuid);\n\t\t\texpect(maxUuidBigint - ensuredBigint > Number.MAX_SAFE_INTEGER).to.be.true;\n\t\t}\n\t});\n\n\tit('correctly adjusts session UUIDs that are in danger of overflow', () => {\n\t\tconst dangerous = [\n\t\t\tassertIsStableId('ffffffff-ffff-4fff-bfff-ffffffffffff'),\n\t\t\tassertIsStableId('ffffffff-ffff-4fff-bff0-000000000000'),\n\t\t\tassertIsStableId('ffffffff-ffff-4fff-bf00-000000000000'),\n\t\t];\n\n\t\tconst safe = [\n\t\t\tassertIsStableId('ffffffff-ffff-4fff-beff-ffffffffffff'),\n\t\t\tassertIsStableId('ffffffff-ffff-4fff-bef0-000000000000'),\n\t\t\tassertIsStableId('ffffffff-ffff-4fff-be00-000000000000'),\n\t\t];\n\n\t\tdangerous.forEach((stableId) => expect(ensureSessionUuid(stableId)).to.not.equal(stableId));\n\t\tsafe.forEach((stableId) => expect(ensureSessionUuid(stableId)).to.equal(stableId));\n\t});\n\n\tconst stableIds = [\n\t\tassertIsStableId('748540ca-b7c5-4c99-83ff-c1b8e02c09d6'),\n\t\tassertIsStableId('748540ca-b7c5-4c99-83ef-c1b8e02c09d6'),\n\t\tassertIsStableId('748540ca-b7c5-4c99-831f-c1b8e02c09d6'),\n\t\tassertIsStableId('0002c79e-b536-4776-b000-000266c252d5'),\n\t\tassertIsStableId('082533b9-6d05-4068-a008-fe2cc43543f7'),\n\t\tassertIsStableId('2c9fa1f8-48d5-4554-a466-000000000000'),\n\t\tassertIsStableId('2c9fa1f8-48d5-4000-a000-000000000000'),\n\t\tassertIsStableId('10000000-0000-4000-b000-000000000000'),\n\t\tassertIsStableId('10000000-0000-4000-b020-000000000000'), // 2^52\n\t\tassertIsStableId('10000000-0000-4000-b00f-ffffffffffff'),\n\t\tassertIsStableId('10000000-0000-4000-b040-000000000000'),\n\t\tassertIsStableId('f0000000-0000-4000-8000-000000000000'),\n\t\tassertIsStableId('efffffff-ffff-4fff-bfff-ffffffffffff'),\n\t\tintegerToStableId(0),\n\t\tintegerToStableId(1),\n\t\tintegerToStableId(77),\n\t\tintegerToStableId(1024),\n\t\tintegerToStableId(2 ** 32 - 1),\n\t\tintegerToStableId(2 ** 52 - 1),\n\t\tintegerToStableId(Number.MAX_SAFE_INTEGER),\n\t\tintegerToStableId(Number.MAX_SAFE_INTEGER - 1),\n\t];\n\n\tdescribe('incrementing', () => {\n\t\tconst rand = makeRandom(0);\n\t\tconst incrementAmounts = [\n\t\t\t...[...new Array(53).keys()].map((n) => 2 ** n - 1),\n\t\t\t...[...new Array(10).keys()].map((_) => rand.integer(0, Number.MAX_SAFE_INTEGER)),\n\t\t];\n\t\tstableIds.forEach((stableId) => {\n\t\t\tit(`can increment ${stableId}`, () => {\n\t\t\t\tconst uuid = numericUuidFromStableId(stableId);\n\n\t\t\t\tincrementAmounts.forEach((incrementAmount) => {\n\t\t\t\t\tconst bigintIncremented = bigIntFromStableId(stableId) + BigInt(incrementAmount);\n\t\t\t\t\tconst incremented = incrementUuid(uuid, incrementAmount);\n\t\t\t\t\tconst bigintStr = integerToStableId(bigintIncremented);\n\t\t\t\t\texpect(stableIdFromNumericUuid(incremented)).to.equal(bigintStr);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t});\n\n\tit('delta calculation can calculate the integer delta between stable ids', () => {\n\t\tstableIds.forEach((stableIdA) => {\n\t\t\tconst uuidA = numericUuidFromStableId(stableIdA);\n\t\t\tconst bigintA = bigIntFromStableId(stableIdA);\n\t\t\tconst arbitraryMaxDelta = 2 ** 32 - 1;\n\t\t\tstableIds.forEach((stableIdB) => {\n\t\t\t\tconst uuidB = numericUuidFromStableId(stableIdB);\n\t\t\t\tconst bigintB = bigIntFromStableId(stableIdB);\n\t\t\t\tconst realDelta = bigintA - bigintB;\n\t\t\t\tconst numericDelta = getPositiveDelta(uuidA, uuidB, Number.MAX_SAFE_INTEGER);\n\t\t\t\tif (realDelta > Number.MAX_SAFE_INTEGER || realDelta < 0) {\n\t\t\t\t\texpect(numericDelta).to.equal(undefined);\n\t\t\t\t} else {\n\t\t\t\t\texpect(numericDelta).to.equal(Number(realDelta));\n\t\t\t\t}\n\t\t\t\tconst numericDeltaCapped = getPositiveDelta(uuidA, uuidB, arbitraryMaxDelta);\n\t\t\t\tif (realDelta >= 0 && realDelta <= arbitraryMaxDelta) {\n\t\t\t\t\texpect(numericDeltaCapped).to.equal(Number(realDelta));\n\t\t\t\t} else {\n\t\t\t\t\texpect(numericDeltaCapped).to.equal(undefined);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t});\n\n\tit('can round trip between stable ID and uuid', () => {\n\t\tstableIds.forEach((stableId) => {\n\t\t\tconst uuid = numericUuidFromStableId(stableId);\n\t\t\tconst roundTripped = stableIdFromNumericUuid(uuid);\n\t\t\texpect(stableId).to.equal(roundTripped);\n\t\t});\n\t});\n\n\tit('can compare numeric uuids', () => {\n\t\tstableIds.forEach((stableIdA) => {\n\t\t\tstableIds.forEach((stableIdB) => {\n\t\t\t\tconst numericA = numericUuidFromStableId(stableIdA);\n\t\t\t\tconst numericB = numericUuidFromStableId(stableIdB);\n\t\t\t\tconst comparedNumeric = numericUuidEquals(numericA, numericB);\n\t\t\t\tconst comparedStrings = compareStrings(stableIdA, stableIdB);\n\t\t\t\texpect(comparedNumeric).to.equal(comparedStrings === 0);\n\t\t\t});\n\t\t});\n\t});\n});\n\nfunction bigIntFromStableId(id: StableId): bigint {\n\tconst minimized = id.replace(/-/g, '');\n\t// UUID | xxxxxxxx-xxxx-Vxxx-vxxx-xxxxxxxxxxxx | The StableId passed to this function, shown here in standard UUID notation\n\t// nibbles | hhhhhhhh hhhh mmm llll llllllllllll | Whether or not each nibble is part of the \"high\", \"middle\" or \"low\" group below\n\t// bit count | 44444444-4444-0444-2444-444444444444 | The number of bits per nibble that are used to encode the number\n\n\t// Interpret numerically...\n\tconst highNibbles = BigInt(`0x${minimized.substr(0, 12)}`); // ...all nibbles above the version nibble,\n\tconst midNibbles = BigInt(`0x${minimized.substr(13, 3)}`); // the nibbles below the version nibble and above the variant nibble,\n\tconst lowNibbles = BigInt(`0x${minimized.substr(16, 16)}`); // and the variant nibble and all nibbles below\n\t// Count the number of bits that contribute to the number (i.e. are not reserved for version/variant) in...\n\tconst lowBitCount = BigInt(62); // ...the low nibbles\n\tconst midBitCount = BigInt(12); // and the mid nibbles\n\t// Shift the values of each region by the appropriate number of bits\n\tconst highNumber = highNibbles << (midBitCount + lowBitCount);\n\tconst midNumber = midNibbles << lowBitCount;\n\t// The low nibbles include the variant nibble because its two low bits are numerical (but its two upper bits are not). So mask them out:\n\tconst lowNumber = lowNibbles & BigInt('0x3fffffffffffffff'); // A nibble '0011' followed by 15 nibbles '1111'.\n\t// Now that high and mid are shifted correctly, the final number is their sum:\n\treturn highNumber + midNumber + lowNumber;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RevisionValueCache.tests.d.ts","sourceRoot":"","sources":["../../src/test/RevisionValueCache.tests.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { strict as assert } from 'assert';
|
|
6
|
-
import { expect } from 'chai';
|
|
7
|
-
import { validateAssertionError } from '@fluidframework/test-runtime-utils';
|
|
8
|
-
import { fail } from '../Common.js';
|
|
9
|
-
import { RevisionValueCache } from '../RevisionValueCache.js';
|
|
10
|
-
const dummyValue = -1;
|
|
11
|
-
describe('RevisionValueCache', () => {
|
|
12
|
-
function closestEntry(cache, revision) {
|
|
13
|
-
return (cache.getClosestEntry(revision) ?? fail('No prior revision'))[0];
|
|
14
|
-
}
|
|
15
|
-
it('cannot be created with a negative retention window', () => {
|
|
16
|
-
assert.throws(() => new RevisionValueCache(1, -1), (e) => validateAssertionError(e, 'retentionWindowStart must be initialized >= 0'));
|
|
17
|
-
});
|
|
18
|
-
it('cannot move the retention window backwards', () => {
|
|
19
|
-
const cache = new RevisionValueCache(1, 0);
|
|
20
|
-
assert.throws(() => cache.updateRetentionWindow(-1), (e) => validateAssertionError(e, 'retention window boundary must not move backwards'));
|
|
21
|
-
});
|
|
22
|
-
it('can find closest entry to a queried revision', () => {
|
|
23
|
-
const cache = new RevisionValueCache(1, 0, [0, dummyValue]);
|
|
24
|
-
cache.cacheValue(2, dummyValue);
|
|
25
|
-
expect(closestEntry(cache, 1)).to.equal(0);
|
|
26
|
-
expect(closestEntry(cache, 2)).to.equal(2);
|
|
27
|
-
expect(closestEntry(cache, 3)).to.equal(2);
|
|
28
|
-
});
|
|
29
|
-
it('evicts entries when full', () => {
|
|
30
|
-
const size = 3;
|
|
31
|
-
const cache = new RevisionValueCache(size, size * 3 /* ensure all entries are outside of window */, [0, dummyValue]);
|
|
32
|
-
// Fill the cache
|
|
33
|
-
// Start at 1 because the initial revision is never evicted
|
|
34
|
-
for (let i = 1; i <= size; i++) {
|
|
35
|
-
cache.cacheValue(i, dummyValue);
|
|
36
|
-
}
|
|
37
|
-
for (let i = size + 1; i <= size * 2; i++) {
|
|
38
|
-
cache.cacheValue(i, dummyValue);
|
|
39
|
-
// Should have evicted the oldest entry
|
|
40
|
-
expect(closestEntry(cache, i - size)).to.equal(0);
|
|
41
|
-
}
|
|
42
|
-
for (let i = size + 1; i <= size * 2; i++) {
|
|
43
|
-
expect(closestEntry(cache, i)).to.equal(i);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
it('retains entries within the retention window', () => {
|
|
47
|
-
const windowStart = 3;
|
|
48
|
-
const windowEnd = windowStart + 3;
|
|
49
|
-
const cache = new RevisionValueCache(1, windowStart, [0, dummyValue]);
|
|
50
|
-
// Add entries within retention window
|
|
51
|
-
for (let i = windowStart; i <= windowEnd; i++) {
|
|
52
|
-
cache.cacheValue(i, dummyValue);
|
|
53
|
-
}
|
|
54
|
-
// Add entries outside the retention window. These should not cause the in-window entries to be evicted.
|
|
55
|
-
for (let i = 1; i <= windowStart; i++) {
|
|
56
|
-
cache.cacheValue(i, dummyValue);
|
|
57
|
-
}
|
|
58
|
-
for (let i = windowStart; i <= windowEnd; i++) {
|
|
59
|
-
expect(closestEntry(cache, i)).to.equal(i);
|
|
60
|
-
}
|
|
61
|
-
for (let i = 1; i < windowStart - 1; i++) {
|
|
62
|
-
expect(closestEntry(cache, i)).to.equal(0);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
it('can evict entries that move out of the retention window', () => {
|
|
66
|
-
const cache = new RevisionValueCache(1, 0);
|
|
67
|
-
cache.cacheValue(5, dummyValue);
|
|
68
|
-
cache.cacheValue(1, dummyValue);
|
|
69
|
-
expect(closestEntry(cache, 5)).to.equal(5);
|
|
70
|
-
cache.updateRetentionWindow(6); // adds 5 to LRU, evicts 1
|
|
71
|
-
cache.cacheValue(2, dummyValue); // evicts 5
|
|
72
|
-
expect(closestEntry(cache, 5)).to.equal(2);
|
|
73
|
-
});
|
|
74
|
-
it('only keeps one explicitly retained value', () => {
|
|
75
|
-
const cache = new RevisionValueCache(1, 3, [0, dummyValue]);
|
|
76
|
-
cache.cacheValue(1, dummyValue);
|
|
77
|
-
// Add a retained entry outside of the retention window
|
|
78
|
-
cache.cacheRetainedValue(5, dummyValue); // This evicts the previously retained value, 0
|
|
79
|
-
expect(closestEntry(cache, 1)).to.equal(1);
|
|
80
|
-
expect(closestEntry(cache, 5)).to.equal(5);
|
|
81
|
-
cache.cacheValue(2, dummyValue); // Evict 1
|
|
82
|
-
cache.updateRetentionWindow(10); // Should not add 5, so 2 will still be in cache
|
|
83
|
-
assert.throws(() => closestEntry(cache, 1)); // 0 will no longer be retained so 1 should be inaccessible
|
|
84
|
-
expect(closestEntry(cache, 2)).to.equal(2);
|
|
85
|
-
expect(closestEntry(cache, 5)).to.equal(5);
|
|
86
|
-
cache.cacheValue(3, dummyValue); // Evict 2
|
|
87
|
-
assert.throws(() => closestEntry(cache, 2));
|
|
88
|
-
expect(closestEntry(cache, 5)).to.equal(5);
|
|
89
|
-
});
|
|
90
|
-
it('can update retention window to a new range that moves > evictableSize entries', () => {
|
|
91
|
-
const cacheSize = 5;
|
|
92
|
-
const cache = new RevisionValueCache(cacheSize, 0);
|
|
93
|
-
cache.cacheRetainedValue(0, dummyValue);
|
|
94
|
-
for (let i = 0; i < cacheSize * 3; i++) {
|
|
95
|
-
cache.cacheValue(i, dummyValue);
|
|
96
|
-
}
|
|
97
|
-
for (let i = 0; i < cacheSize * 3; i++) {
|
|
98
|
-
expect(closestEntry(cache, i)).to.equal(i); // All entries are cached since they are in the window.
|
|
99
|
-
}
|
|
100
|
-
cache.updateRetentionWindow(cacheSize * 2 + 1); // adds 2 * cache size to LRU, so [0, cacheSize] should be evicted
|
|
101
|
-
for (let i = 1; i <= cacheSize; i++) {
|
|
102
|
-
expect(closestEntry(cache, i)).to.equal(0);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
//# sourceMappingURL=RevisionValueCache.tests.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RevisionValueCache.tests.js","sourceRoot":"","sources":["../../src/test/RevisionValueCache.tests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,MAAM,UAAU,GAAG,CAAC,CAAC,CAAC;AAEtB,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IACnC,SAAS,YAAY,CAAC,KAAqC,EAAE,QAAgB;QAC5E,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC7D,MAAM,CAAC,MAAM,CACZ,GAAG,EAAE,CAAC,IAAI,kBAAkB,CAAa,CAAC,EAAE,CAAC,CAAC,CAAC,EAC/C,CAAC,CAAQ,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAC,EAAE,+CAA+C,CAAC,CACxF,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACrD,MAAM,KAAK,GAAG,IAAI,kBAAkB,CAAa,CAAC,EAAE,CAAC,CAAC,CAAC;QACvD,MAAM,CAAC,MAAM,CACZ,GAAG,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,EACrC,CAAC,CAAQ,EAAE,EAAE,CAAC,sBA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AAC,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YACvC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,uDAAuD;SACnG;QACD,KAAK,CAAC,qBAAqB,CAAC,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,kEAAkE;QAClH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC,EAAE,EAAE;YACpC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAC3C;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 { expect } from 'chai';\nimport { validateAssertionError } from '@fluidframework/test-runtime-utils';\nimport { fail } from '../Common.js';\nimport { RevisionValueCache } from '../RevisionValueCache.js';\n\ntype DummyValue = number;\nconst dummyValue = -1;\n\ndescribe('RevisionValueCache', () => {\n\tfunction closestEntry(cache: RevisionValueCache<DummyValue>, revision: number): number {\n\t\treturn (cache.getClosestEntry(revision) ?? fail('No prior revision'))[0];\n\t}\n\n\tit('cannot be created with a negative retention window', () => {\n\t\tassert.throws(\n\t\t\t() => new RevisionValueCache<DummyValue>(1, -1),\n\t\t\t(e: Error) => validateAssertionError(e, 'retentionWindowStart must be initialized >= 0')\n\t\t);\n\t});\n\n\tit('cannot move the retention window backwards', () => {\n\t\tconst cache = new RevisionValueCache<DummyValue>(1, 0);\n\t\tassert.throws(\n\t\t\t() => cache.updateRetentionWindow(-1),\n\t\t\t(e: Error) => validateAssertionError(e, 'retention window boundary must not move backwards')\n\t\t);\n\t});\n\n\tit('can find closest entry to a queried revision', () => {\n\t\tconst cache = new RevisionValueCache<DummyValue>(1, 0, [0, dummyValue]);\n\t\tcache.cacheValue(2, dummyValue);\n\t\texpect(closestEntry(cache, 1)).to.equal(0);\n\t\texpect(closestEntry(cache, 2)).to.equal(2);\n\t\texpect(closestEntry(cache, 3)).to.equal(2);\n\t});\n\n\tit('evicts entries when full', () => {\n\t\tconst size = 3;\n\t\tconst cache = new RevisionValueCache<DummyValue>(\n\t\t\tsize,\n\t\t\tsize * 3 /* ensure all entries are outside of window */,\n\t\t\t[0, dummyValue]\n\t\t);\n\n\t\t// Fill the cache\n\t\t// Start at 1 because the initial revision is never evicted\n\t\tfor (let i = 1; i <= size; i++) {\n\t\t\tcache.cacheValue(i, dummyValue);\n\t\t}\n\t\tfor (let i = size + 1; i <= size * 2; i++) {\n\t\t\tcache.cacheValue(i, dummyValue);\n\t\t\t// Should have evicted the oldest entry\n\t\t\texpect(closestEntry(cache, i - size)).to.equal(0);\n\t\t}\n\t\tfor (let i = size + 1; i <= size * 2; i++) {\n\t\t\texpect(closestEntry(cache, i)).to.equal(i);\n\t\t}\n\t});\n\n\tit('retains entries within the retention window', () => {\n\t\tconst windowStart = 3;\n\t\tconst windowEnd = windowStart + 3;\n\t\tconst cache = new RevisionValueCache<DummyValue>(1, windowStart, [0, dummyValue]);\n\n\t\t// Add entries within retention window\n\t\tfor (let i = windowStart; i <= windowEnd; i++) {\n\t\t\tcache.cacheValue(i, dummyValue);\n\t\t}\n\t\t// Add entries outside the retention window. These should not cause the in-window entries to be evicted.\n\t\tfor (let i = 1; i <= windowStart; i++) {\n\t\t\tcache.cacheValue(i, dummyValue);\n\t\t}\n\t\tfor (let i = windowStart; i <= windowEnd; i++) {\n\t\t\texpect(closestEntry(cache, i)).to.equal(i);\n\t\t}\n\t\tfor (let i = 1; i < windowStart - 1; i++) {\n\t\t\texpect(closestEntry(cache, i)).to.equal(0);\n\t\t}\n\t});\n\n\tit('can evict entries that move out of the retention window', () => {\n\t\tconst cache = new RevisionValueCache<DummyValue>(1, 0);\n\t\tcache.cacheValue(5, dummyValue);\n\t\tcache.cacheValue(1, dummyValue);\n\t\texpect(closestEntry(cache, 5)).to.equal(5);\n\t\tcache.updateRetentionWindow(6); // adds 5 to LRU, evicts 1\n\t\tcache.cacheValue(2, dummyValue); // evicts 5\n\t\texpect(closestEntry(cache, 5)).to.equal(2);\n\t});\n\n\tit('only keeps one explicitly retained value', () => {\n\t\tconst cache = new RevisionValueCache<DummyValue>(1, 3, [0, dummyValue]);\n\t\tcache.cacheValue(1, dummyValue);\n\t\t// Add a retained entry outside of the retention window\n\t\tcache.cacheRetainedValue(5, dummyValue); // This evicts the previously retained value, 0\n\t\texpect(closestEntry(cache, 1)).to.equal(1);\n\t\texpect(closestEntry(cache, 5)).to.equal(5);\n\t\tcache.cacheValue(2, dummyValue); // Evict 1\n\t\tcache.updateRetentionWindow(10); // Should not add 5, so 2 will still be in cache\n\t\tassert.throws(() => closestEntry(cache, 1)); // 0 will no longer be retained so 1 should be inaccessible\n\t\texpect(closestEntry(cache, 2)).to.equal(2);\n\t\texpect(closestEntry(cache, 5)).to.equal(5);\n\t\tcache.cacheValue(3, dummyValue); // Evict 2\n\t\tassert.throws(() => closestEntry(cache, 2));\n\t\texpect(closestEntry(cache, 5)).to.equal(5);\n\t});\n\n\tit('can update retention window to a new range that moves > evictableSize entries', () => {\n\t\tconst cacheSize = 5;\n\t\tconst cache = new RevisionValueCache<DummyValue>(cacheSize, 0);\n\t\tcache.cacheRetainedValue(0, dummyValue);\n\t\tfor (let i = 0; i < cacheSize * 3; i++) {\n\t\t\tcache.cacheValue(i, dummyValue);\n\t\t}\n\t\tfor (let i = 0; i < cacheSize * 3; i++) {\n\t\t\texpect(closestEntry(cache, i)).to.equal(i); // All entries are cached since they are in the window.\n\t\t}\n\t\tcache.updateRetentionWindow(cacheSize * 2 + 1); // adds 2 * cache size to LRU, so [0, cacheSize] should be evicted\n\t\tfor (let i = 1; i <= cacheSize; i++) {\n\t\t\texpect(closestEntry(cache, i)).to.equal(0);\n\t\t}\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RevisionView.tests.d.ts","sourceRoot":"","sources":["../../src/test/RevisionView.tests.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { expect } from 'chai';
|
|
6
|
-
import { getChangeNodeFromViewNode } from '../SerializationUtilities.js';
|
|
7
|
-
import { convertTreeNodesToViewNodes, RevisionView } from '../RevisionView.js';
|
|
8
|
-
import { StablePlace, StableRange } from '../ChangeTypes.js';
|
|
9
|
-
import { detachRange, insertIntoTrait } from '../EditUtilities.js';
|
|
10
|
-
import { expectDefined } from './utilities/TestCommon.js';
|
|
11
|
-
import { refreshTestTree } from './utilities/TestUtilities.js';
|
|
12
|
-
describe('RevisionView', () => {
|
|
13
|
-
const testTree = refreshTestTree();
|
|
14
|
-
describe('creation from a ChangeNode', () => {
|
|
15
|
-
it('ignores empty traits', () => {
|
|
16
|
-
const leaf = testTree.buildLeaf(testTree.generateNodeId());
|
|
17
|
-
const node = {
|
|
18
|
-
traits: {
|
|
19
|
-
trait: [leaf],
|
|
20
|
-
emptyTrait: [],
|
|
21
|
-
},
|
|
22
|
-
definition: testTree.definition,
|
|
23
|
-
identifier: testTree.identifier,
|
|
24
|
-
};
|
|
25
|
-
const view = RevisionView.fromTree(node);
|
|
26
|
-
const changeNode = getChangeNodeFromViewNode(view, testTree.identifier);
|
|
27
|
-
expect(changeNode.traits.trait[0].identifier).to.equal(leaf.identifier);
|
|
28
|
-
expect(changeNode.traits.emptyTrait).to.equal(undefined);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
it('correctly converts tree nodes', () => {
|
|
32
|
-
const viewNodes = expectDefined(convertTreeNodesToViewNodes(testTree, (node) => ({
|
|
33
|
-
definition: node.definition,
|
|
34
|
-
identifier: node.identifier,
|
|
35
|
-
})));
|
|
36
|
-
let createdRoot = false;
|
|
37
|
-
let createdLeft = false;
|
|
38
|
-
let createdRight = false;
|
|
39
|
-
for (let viewNode = viewNodes.pop(); viewNode !== undefined; viewNode = viewNodes.pop()) {
|
|
40
|
-
switch (viewNode.identifier) {
|
|
41
|
-
case testTree.identifier:
|
|
42
|
-
expect(createdRoot).to.be.false;
|
|
43
|
-
expect(viewNode.definition).to.equal(testTree.definition);
|
|
44
|
-
expect(viewNode.traits.size).to.equal(2);
|
|
45
|
-
expect(viewNode.traits.get(testTree.left.traitLabel)).to.deep.equal([testTree.left.identifier]);
|
|
46
|
-
expect(viewNode.traits.get(testTree.right.traitLabel)).to.deep.equal([testTree.right.identifier]);
|
|
47
|
-
createdRoot = true;
|
|
48
|
-
break;
|
|
49
|
-
case testTree.left.identifier:
|
|
50
|
-
expect(createdLeft).to.be.false;
|
|
51
|
-
expect(viewNode.definition).to.equal(testTree.left.definition);
|
|
52
|
-
expect(viewNode.traits.size).to.equal(0);
|
|
53
|
-
createdLeft = true;
|
|
54
|
-
break;
|
|
55
|
-
case testTree.right.identifier:
|
|
56
|
-
expect(createdRight).to.be.false;
|
|
57
|
-
expect(viewNode.definition).to.equal(testTree.right.definition);
|
|
58
|
-
expect(viewNode.traits.size).to.equal(0);
|
|
59
|
-
createdRight = true;
|
|
60
|
-
break;
|
|
61
|
-
default:
|
|
62
|
-
expect.fail('Unexpected view node ID');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
it('correctly handles tree node conversion failure', () => {
|
|
67
|
-
let nodesConverted = 0;
|
|
68
|
-
const viewNodes = convertTreeNodesToViewNodes(testTree, (node) => {
|
|
69
|
-
if (nodesConverted++ >= 2) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
definition: node.definition,
|
|
74
|
-
identifier: node.identifier,
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
expect(viewNodes).to.be.undefined;
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
describe('TransactionView', () => {
|
|
81
|
-
const testTree = refreshTestTree();
|
|
82
|
-
const traitLabel = 'trait';
|
|
83
|
-
function getTree() {
|
|
84
|
-
const childA = testTree.buildLeaf(testTree.generateNodeId());
|
|
85
|
-
const childB = testTree.buildLeaf(testTree.generateNodeId());
|
|
86
|
-
const parent = {
|
|
87
|
-
traits: {
|
|
88
|
-
[traitLabel]: [childA, childB],
|
|
89
|
-
},
|
|
90
|
-
definition: testTree.definition,
|
|
91
|
-
identifier: testTree.identifier,
|
|
92
|
-
};
|
|
93
|
-
return { parent, childA, childB };
|
|
94
|
-
}
|
|
95
|
-
it('can detach a single node in a trait', () => {
|
|
96
|
-
const { parent, childA, childB } = getTree();
|
|
97
|
-
const startingView = RevisionView.fromTree(parent).openForTransaction();
|
|
98
|
-
const { view } = detachRange(startingView, StableRange.only(childA));
|
|
99
|
-
expect(view.size).to.equal(3);
|
|
100
|
-
expect(view.hasNode(childA.identifier)).to.be.true;
|
|
101
|
-
expect(view.tryGetParentViewNode(childA.identifier)).to.be.undefined;
|
|
102
|
-
expect(view.tryGetParentViewNode(childB.identifier)?.identifier).to.equal(parent.identifier);
|
|
103
|
-
expect(view.getIndexInTrait(childB.identifier)).to.equal(0);
|
|
104
|
-
});
|
|
105
|
-
it('can detach an entire trait', () => {
|
|
106
|
-
const { parent, childA, childB } = getTree();
|
|
107
|
-
const startingView = RevisionView.fromTree(parent).openForTransaction();
|
|
108
|
-
const { view, detached } = detachRange(startingView, StableRange.all({ parent: parent.identifier, label: traitLabel }));
|
|
109
|
-
expect(detached).deep.equals([childA.identifier, childB.identifier]);
|
|
110
|
-
expect(view.size).to.equal(3);
|
|
111
|
-
expect(view.hasNode(childA.identifier)).to.be.true;
|
|
112
|
-
expect(view.hasNode(childB.identifier)).to.be.true;
|
|
113
|
-
expect(view.tryGetParentViewNode(childA.identifier)).to.be.undefined;
|
|
114
|
-
expect(view.tryGetParentViewNode(childB.identifier)).to.be.undefined;
|
|
115
|
-
});
|
|
116
|
-
it('can insert a node', () => {
|
|
117
|
-
const { parent, childA, childB } = getTree();
|
|
118
|
-
const startingView = RevisionView.fromTree(parent).openForTransaction();
|
|
119
|
-
const newNode = testTree.buildLeaf(testTree.generateNodeId());
|
|
120
|
-
let view = startingView.addNodes([{ ...newNode, traits: new Map() }]);
|
|
121
|
-
expect(view.size).to.equal(4);
|
|
122
|
-
expect(view.hasNode(newNode.identifier)).to.be.true;
|
|
123
|
-
expect(view.tryGetParentViewNode(newNode.identifier)).to.be.undefined;
|
|
124
|
-
view = insertIntoTrait(view, [newNode.identifier], StablePlace.atStartOf({ parent: parent.identifier, label: traitLabel }));
|
|
125
|
-
expect(view.tryGetParentViewNode(newNode.identifier)?.identifier).to.equal(parent.identifier);
|
|
126
|
-
expect(view.getIndexInTrait(newNode.identifier)).to.equal(0);
|
|
127
|
-
expect(view.getIndexInTrait(childA.identifier)).to.equal(1);
|
|
128
|
-
expect(view.getIndexInTrait(childB.identifier)).to.equal(2);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
//# sourceMappingURL=RevisionView.tests.js.map
|