@fluid-experimental/tree 0.58.2002 → 0.59.1000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -46
- package/dist/ChangeCompression.d.ts +39 -0
- package/dist/ChangeCompression.d.ts.map +1 -0
- package/dist/ChangeCompression.js +117 -0
- package/dist/ChangeCompression.js.map +1 -0
- package/{lib/default-edits/PersistedTypes.d.ts → dist/ChangeTypes.d.ts} +58 -105
- package/dist/ChangeTypes.d.ts.map +1 -0
- package/dist/{default-edits/PersistedTypes.js → ChangeTypes.js} +21 -76
- package/dist/ChangeTypes.js.map +1 -0
- package/dist/Checkout.d.ts +39 -27
- package/dist/Checkout.d.ts.map +1 -1
- package/dist/Checkout.js +61 -32
- package/dist/Checkout.js.map +1 -1
- package/dist/Common.d.ts +175 -38
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js +240 -103
- package/dist/Common.js.map +1 -1
- package/dist/EagerCheckout.d.ts +24 -0
- package/dist/EagerCheckout.d.ts.map +1 -0
- package/dist/{BasicCheckout.js → EagerCheckout.js} +9 -6
- package/dist/EagerCheckout.js.map +1 -0
- package/dist/EditLog.d.ts +77 -63
- package/dist/EditLog.d.ts.map +1 -1
- package/dist/EditLog.js +85 -48
- package/dist/EditLog.js.map +1 -1
- package/dist/EditUtilities.d.ts +168 -0
- package/dist/EditUtilities.d.ts.map +1 -0
- package/dist/EditUtilities.js +373 -0
- package/dist/EditUtilities.js.map +1 -0
- package/dist/EventTypes.d.ts +73 -0
- package/dist/EventTypes.d.ts.map +1 -0
- package/dist/EventTypes.js +78 -0
- package/dist/EventTypes.js.map +1 -0
- package/dist/Forest.d.ts +29 -7
- package/dist/Forest.d.ts.map +1 -1
- package/dist/Forest.js +60 -36
- package/dist/Forest.js.map +1 -1
- package/dist/HistoryEditFactory.d.ts +20 -0
- package/dist/HistoryEditFactory.d.ts.map +1 -0
- package/dist/HistoryEditFactory.js +226 -0
- package/dist/HistoryEditFactory.js.map +1 -0
- package/dist/IdConversion.d.ts +12 -0
- package/dist/IdConversion.d.ts.map +1 -0
- package/dist/IdConversion.js +98 -0
- package/dist/IdConversion.js.map +1 -0
- package/dist/Identifiers.d.ts +89 -2
- package/dist/Identifiers.d.ts.map +1 -1
- package/dist/Identifiers.js +10 -0
- package/dist/Identifiers.js.map +1 -1
- package/dist/InitialTree.d.ts +2 -2
- package/dist/InitialTree.d.ts.map +1 -1
- package/dist/InitialTree.js +2 -1
- package/dist/InitialTree.js.map +1 -1
- package/dist/LazyCheckout.d.ts +28 -0
- package/dist/LazyCheckout.d.ts.map +1 -0
- package/dist/LazyCheckout.js +44 -0
- package/dist/LazyCheckout.js.map +1 -0
- package/dist/LogViewer.d.ts +129 -85
- package/dist/LogViewer.d.ts.map +1 -1
- package/dist/LogViewer.js +111 -85
- package/dist/LogViewer.js.map +1 -1
- package/dist/MergeHealth.d.ts +221 -0
- package/dist/MergeHealth.d.ts.map +1 -0
- package/dist/MergeHealth.js +263 -0
- package/dist/MergeHealth.js.map +1 -0
- package/dist/NodeIdUtilities.d.ts +105 -0
- package/dist/NodeIdUtilities.d.ts.map +1 -0
- package/dist/NodeIdUtilities.js +60 -0
- package/dist/NodeIdUtilities.js.map +1 -0
- package/dist/PayloadUtilities.d.ts +42 -0
- package/dist/PayloadUtilities.d.ts.map +1 -0
- package/dist/PayloadUtilities.js +114 -0
- package/dist/PayloadUtilities.js.map +1 -0
- package/dist/ReconciliationPath.d.ts +18 -13
- package/dist/ReconciliationPath.d.ts.map +1 -1
- package/dist/ReconciliationPath.js.map +1 -1
- package/dist/RevisionValueCache.d.ts +11 -2
- package/dist/RevisionValueCache.d.ts.map +1 -1
- package/dist/RevisionValueCache.js +2 -3
- package/dist/RevisionValueCache.js.map +1 -1
- package/dist/RevisionView.d.ts +83 -0
- package/dist/RevisionView.d.ts.map +1 -0
- package/dist/RevisionView.js +182 -0
- package/dist/RevisionView.js.map +1 -0
- package/dist/SerializationUtilities.d.ts +36 -0
- package/dist/SerializationUtilities.d.ts.map +1 -0
- package/dist/SerializationUtilities.js +102 -0
- package/dist/SerializationUtilities.js.map +1 -0
- package/dist/SharedTree.d.ts +439 -0
- package/dist/SharedTree.d.ts.map +1 -0
- package/dist/SharedTree.js +1109 -0
- package/dist/SharedTree.js.map +1 -0
- package/dist/SharedTreeEncoder.d.ts +102 -0
- package/dist/SharedTreeEncoder.d.ts.map +1 -0
- package/dist/SharedTreeEncoder.js +313 -0
- package/dist/SharedTreeEncoder.js.map +1 -0
- package/dist/StringInterner.d.ts +46 -0
- package/dist/StringInterner.d.ts.map +1 -0
- package/dist/StringInterner.js +61 -0
- package/dist/StringInterner.js.map +1 -0
- package/dist/Summary.d.ts +40 -0
- package/dist/Summary.d.ts.map +1 -0
- package/dist/Summary.js +23 -0
- package/dist/Summary.js.map +1 -0
- package/dist/SummaryBackCompatibility.d.ts +22 -22
- package/dist/SummaryBackCompatibility.d.ts.map +1 -1
- package/dist/SummaryBackCompatibility.js +30 -33
- package/dist/SummaryBackCompatibility.js.map +1 -1
- package/dist/SummaryTestUtilities.d.ts +31 -0
- package/dist/SummaryTestUtilities.d.ts.map +1 -0
- package/dist/SummaryTestUtilities.js +37 -0
- package/dist/SummaryTestUtilities.js.map +1 -0
- package/dist/Transaction.d.ts +52 -0
- package/dist/Transaction.d.ts.map +1 -0
- package/dist/Transaction.js +72 -0
- package/dist/Transaction.js.map +1 -0
- package/dist/TransactionInternal.d.ts +540 -0
- package/dist/TransactionInternal.d.ts.map +1 -0
- package/dist/TransactionInternal.js +626 -0
- package/dist/TransactionInternal.js.map +1 -0
- package/dist/TreeCompressor.d.ts +36 -0
- package/dist/TreeCompressor.d.ts.map +1 -0
- package/dist/TreeCompressor.js +137 -0
- package/dist/TreeCompressor.js.map +1 -0
- package/dist/TreeNodeHandle.d.ts +12 -18
- package/dist/TreeNodeHandle.d.ts.map +1 -1
- package/dist/TreeNodeHandle.js +13 -23
- package/dist/TreeNodeHandle.js.map +1 -1
- package/dist/TreeView.d.ts +166 -0
- package/dist/TreeView.d.ts.map +1 -0
- package/dist/TreeView.js +218 -0
- package/dist/TreeView.js.map +1 -0
- package/dist/TreeViewUtilities.d.ts +21 -0
- package/dist/TreeViewUtilities.d.ts.map +1 -0
- package/dist/TreeViewUtilities.js +77 -0
- package/dist/TreeViewUtilities.js.map +1 -0
- package/dist/{default-edits/UndoRedoHandler.d.ts → UndoRedoHandler.d.ts} +2 -2
- package/dist/UndoRedoHandler.d.ts.map +1 -0
- package/dist/{default-edits/UndoRedoHandler.js → UndoRedoHandler.js} +5 -9
- package/dist/UndoRedoHandler.js.map +1 -0
- package/dist/id-compressor/AppendOnlySortedMap.d.ts +127 -0
- package/dist/id-compressor/AppendOnlySortedMap.d.ts.map +1 -0
- package/dist/id-compressor/AppendOnlySortedMap.js +283 -0
- package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -0
- package/dist/id-compressor/IdCompressor.d.ts +389 -0
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -0
- package/dist/id-compressor/IdCompressor.js +1353 -0
- package/dist/id-compressor/IdCompressor.js.map +1 -0
- package/dist/id-compressor/IdRange.d.ts +11 -0
- package/dist/id-compressor/IdRange.d.ts.map +1 -0
- package/dist/id-compressor/IdRange.js +29 -0
- package/dist/id-compressor/IdRange.js.map +1 -0
- package/dist/id-compressor/NumericUuid.d.ts +63 -0
- package/dist/id-compressor/NumericUuid.d.ts.map +1 -0
- package/dist/id-compressor/NumericUuid.js +377 -0
- package/dist/id-compressor/NumericUuid.js.map +1 -0
- package/dist/id-compressor/index.d.ts +12 -0
- package/dist/id-compressor/index.d.ts.map +1 -0
- package/dist/id-compressor/index.js +26 -0
- package/dist/id-compressor/index.js.map +1 -0
- package/dist/id-compressor/persisted-types/0.0.1.d.ts +156 -0
- package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -0
- package/dist/id-compressor/persisted-types/0.0.1.js +7 -0
- package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -0
- package/dist/id-compressor/persisted-types/index.d.ts +6 -0
- package/dist/id-compressor/persisted-types/index.d.ts.map +1 -0
- package/dist/id-compressor/persisted-types/index.js +18 -0
- package/dist/id-compressor/persisted-types/index.js.map +1 -0
- package/dist/index.d.ts +29 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -35
- package/dist/index.js.map +1 -1
- package/dist/persisted-types/0.0.2.d.ts +385 -0
- package/dist/persisted-types/0.0.2.d.ts.map +1 -0
- package/dist/persisted-types/0.0.2.js +113 -0
- package/dist/persisted-types/0.0.2.js.map +1 -0
- package/dist/persisted-types/0.1.1.d.ts +314 -0
- package/dist/persisted-types/0.1.1.d.ts.map +1 -0
- package/dist/persisted-types/0.1.1.js +153 -0
- package/dist/persisted-types/0.1.1.js.map +1 -0
- package/dist/persisted-types/index.d.ts +7 -0
- package/dist/persisted-types/index.d.ts.map +1 -0
- package/dist/persisted-types/index.js +20 -0
- package/dist/persisted-types/index.js.map +1 -0
- package/docs/0-1-1-Compression.md +228 -0
- package/docs/Breaking-Change-Migration.md +52 -0
- package/docs/Compression.md +2 -2
- package/docs/Telemetry.md +43 -0
- package/docs/Write-Format.md +19 -0
- package/lib/ChangeCompression.d.ts +39 -0
- package/lib/ChangeCompression.d.ts.map +1 -0
- package/lib/ChangeCompression.js +111 -0
- package/lib/ChangeCompression.js.map +1 -0
- package/{dist/default-edits/PersistedTypes.d.ts → lib/ChangeTypes.d.ts} +58 -105
- package/lib/ChangeTypes.d.ts.map +1 -0
- package/lib/{default-edits/PersistedTypes.js → ChangeTypes.js} +15 -68
- package/lib/ChangeTypes.js.map +1 -0
- package/lib/Checkout.d.ts +39 -27
- package/lib/Checkout.d.ts.map +1 -1
- package/lib/Checkout.js +53 -24
- package/lib/Checkout.js.map +1 -1
- package/lib/Common.d.ts +175 -38
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js +226 -101
- package/lib/Common.js.map +1 -1
- package/lib/EagerCheckout.d.ts +24 -0
- package/lib/EagerCheckout.d.ts.map +1 -0
- package/lib/{BasicCheckout.js → EagerCheckout.js} +7 -4
- package/lib/EagerCheckout.js.map +1 -0
- package/lib/EditLog.d.ts +77 -63
- package/lib/EditLog.d.ts.map +1 -1
- package/lib/EditLog.js +83 -47
- package/lib/EditLog.js.map +1 -1
- package/lib/EditUtilities.d.ts +168 -0
- package/lib/EditUtilities.d.ts.map +1 -0
- package/lib/EditUtilities.js +353 -0
- package/lib/EditUtilities.js.map +1 -0
- package/lib/EventTypes.d.ts +73 -0
- package/lib/EventTypes.d.ts.map +1 -0
- package/lib/EventTypes.js +75 -0
- package/lib/EventTypes.js.map +1 -0
- package/lib/Forest.d.ts +29 -7
- package/lib/Forest.d.ts.map +1 -1
- package/lib/Forest.js +58 -35
- package/lib/Forest.js.map +1 -1
- package/lib/HistoryEditFactory.d.ts +20 -0
- package/lib/HistoryEditFactory.d.ts.map +1 -0
- package/lib/{default-edits/HistoryEditFactory.js → HistoryEditFactory.js} +78 -39
- package/lib/HistoryEditFactory.js.map +1 -0
- package/lib/IdConversion.d.ts +12 -0
- package/lib/IdConversion.d.ts.map +1 -0
- package/lib/IdConversion.js +91 -0
- package/lib/IdConversion.js.map +1 -0
- package/lib/Identifiers.d.ts +89 -2
- package/lib/Identifiers.d.ts.map +1 -1
- package/lib/Identifiers.js +8 -1
- package/lib/Identifiers.js.map +1 -1
- package/lib/InitialTree.d.ts +2 -2
- package/lib/InitialTree.d.ts.map +1 -1
- package/lib/InitialTree.js +2 -1
- package/lib/InitialTree.js.map +1 -1
- package/lib/LazyCheckout.d.ts +28 -0
- package/lib/LazyCheckout.d.ts.map +1 -0
- package/lib/LazyCheckout.js +40 -0
- package/lib/LazyCheckout.js.map +1 -0
- package/lib/LogViewer.d.ts +129 -85
- package/lib/LogViewer.d.ts.map +1 -1
- package/lib/LogViewer.js +103 -77
- package/lib/LogViewer.js.map +1 -1
- package/lib/MergeHealth.d.ts +221 -0
- package/lib/MergeHealth.d.ts.map +1 -0
- package/lib/MergeHealth.js +258 -0
- package/lib/MergeHealth.js.map +1 -0
- package/lib/NodeIdUtilities.d.ts +105 -0
- package/lib/NodeIdUtilities.d.ts.map +1 -0
- package/lib/NodeIdUtilities.js +53 -0
- package/lib/NodeIdUtilities.js.map +1 -0
- package/lib/PayloadUtilities.d.ts +42 -0
- package/lib/PayloadUtilities.d.ts.map +1 -0
- package/lib/PayloadUtilities.js +110 -0
- package/lib/PayloadUtilities.js.map +1 -0
- package/lib/ReconciliationPath.d.ts +18 -13
- package/lib/ReconciliationPath.d.ts.map +1 -1
- package/lib/ReconciliationPath.js.map +1 -1
- package/lib/RevisionValueCache.d.ts +11 -2
- package/lib/RevisionValueCache.d.ts.map +1 -1
- package/lib/RevisionValueCache.js +2 -3
- package/lib/RevisionValueCache.js.map +1 -1
- package/lib/RevisionView.d.ts +83 -0
- package/lib/RevisionView.d.ts.map +1 -0
- package/lib/RevisionView.js +175 -0
- package/lib/RevisionView.js.map +1 -0
- package/lib/SerializationUtilities.d.ts +36 -0
- package/lib/SerializationUtilities.d.ts.map +1 -0
- package/lib/SerializationUtilities.js +95 -0
- package/lib/SerializationUtilities.js.map +1 -0
- package/lib/SharedTree.d.ts +439 -0
- package/lib/SharedTree.d.ts.map +1 -0
- package/lib/SharedTree.js +1104 -0
- package/lib/SharedTree.js.map +1 -0
- package/lib/SharedTreeEncoder.d.ts +102 -0
- package/lib/SharedTreeEncoder.d.ts.map +1 -0
- package/lib/SharedTreeEncoder.js +308 -0
- package/lib/SharedTreeEncoder.js.map +1 -0
- package/lib/StringInterner.d.ts +46 -0
- package/lib/StringInterner.d.ts.map +1 -0
- package/lib/StringInterner.js +57 -0
- package/lib/StringInterner.js.map +1 -0
- package/lib/Summary.d.ts +40 -0
- package/lib/Summary.d.ts.map +1 -0
- package/lib/Summary.js +19 -0
- package/lib/Summary.js.map +1 -0
- package/lib/SummaryBackCompatibility.d.ts +22 -22
- package/lib/SummaryBackCompatibility.d.ts.map +1 -1
- package/lib/SummaryBackCompatibility.js +29 -32
- package/lib/SummaryBackCompatibility.js.map +1 -1
- package/lib/SummaryTestUtilities.d.ts +31 -0
- package/lib/SummaryTestUtilities.d.ts.map +1 -0
- package/lib/SummaryTestUtilities.js +32 -0
- package/lib/SummaryTestUtilities.js.map +1 -0
- package/lib/Transaction.d.ts +52 -0
- package/lib/Transaction.d.ts.map +1 -0
- package/lib/Transaction.js +68 -0
- package/lib/Transaction.js.map +1 -0
- package/lib/TransactionInternal.d.ts +540 -0
- package/lib/TransactionInternal.d.ts.map +1 -0
- package/lib/TransactionInternal.js +622 -0
- package/lib/TransactionInternal.js.map +1 -0
- package/lib/TreeCompressor.d.ts +36 -0
- package/lib/TreeCompressor.d.ts.map +1 -0
- package/lib/TreeCompressor.js +133 -0
- package/lib/TreeCompressor.js.map +1 -0
- package/lib/TreeNodeHandle.d.ts +12 -18
- package/lib/TreeNodeHandle.d.ts.map +1 -1
- package/lib/TreeNodeHandle.js +14 -24
- package/lib/TreeNodeHandle.js.map +1 -1
- package/lib/TreeView.d.ts +166 -0
- package/lib/TreeView.d.ts.map +1 -0
- package/lib/TreeView.js +214 -0
- package/lib/TreeView.js.map +1 -0
- package/lib/TreeViewUtilities.d.ts +21 -0
- package/lib/TreeViewUtilities.d.ts.map +1 -0
- package/lib/TreeViewUtilities.js +71 -0
- package/lib/TreeViewUtilities.js.map +1 -0
- package/lib/{default-edits/UndoRedoHandler.d.ts → UndoRedoHandler.d.ts} +2 -2
- package/lib/UndoRedoHandler.d.ts.map +1 -0
- package/lib/{default-edits/UndoRedoHandler.js → UndoRedoHandler.js} +3 -7
- package/lib/UndoRedoHandler.js.map +1 -0
- package/lib/id-compressor/AppendOnlySortedMap.d.ts +127 -0
- package/lib/id-compressor/AppendOnlySortedMap.d.ts.map +1 -0
- package/lib/id-compressor/AppendOnlySortedMap.js +278 -0
- package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -0
- package/lib/id-compressor/IdCompressor.d.ts +389 -0
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -0
- package/lib/id-compressor/IdCompressor.js +1343 -0
- package/lib/id-compressor/IdCompressor.js.map +1 -0
- package/lib/id-compressor/IdRange.d.ts +11 -0
- package/lib/id-compressor/IdRange.d.ts.map +1 -0
- package/lib/id-compressor/IdRange.js +25 -0
- package/lib/id-compressor/IdRange.js.map +1 -0
- package/lib/id-compressor/NumericUuid.d.ts +63 -0
- package/lib/id-compressor/NumericUuid.d.ts.map +1 -0
- package/lib/id-compressor/NumericUuid.js +365 -0
- package/lib/id-compressor/NumericUuid.js.map +1 -0
- package/lib/id-compressor/index.d.ts +12 -0
- package/lib/id-compressor/index.d.ts.map +1 -0
- package/lib/id-compressor/index.js +12 -0
- package/lib/id-compressor/index.js.map +1 -0
- package/lib/id-compressor/persisted-types/0.0.1.d.ts +156 -0
- package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -0
- package/lib/{test/Snapshot.tests.d.ts → id-compressor/persisted-types/0.0.1.js} +1 -1
- package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -0
- package/lib/id-compressor/persisted-types/index.d.ts +6 -0
- package/lib/id-compressor/persisted-types/index.d.ts.map +1 -0
- package/lib/id-compressor/persisted-types/index.js +6 -0
- package/lib/id-compressor/persisted-types/index.js.map +1 -0
- package/lib/index.d.ts +29 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +23 -6
- package/lib/index.js.map +1 -1
- package/lib/persisted-types/0.0.2.d.ts +385 -0
- package/lib/persisted-types/0.0.2.d.ts.map +1 -0
- package/lib/persisted-types/0.0.2.js +110 -0
- package/lib/persisted-types/0.0.2.js.map +1 -0
- package/lib/persisted-types/0.1.1.d.ts +314 -0
- package/lib/persisted-types/0.1.1.d.ts.map +1 -0
- package/lib/persisted-types/0.1.1.js +150 -0
- package/lib/persisted-types/0.1.1.js.map +1 -0
- package/lib/persisted-types/index.d.ts +7 -0
- package/lib/persisted-types/index.d.ts.map +1 -0
- package/lib/persisted-types/index.js +8 -0
- package/lib/persisted-types/index.js.map +1 -0
- package/lib/test/AppendOnlySortedMap.tests.d.ts +6 -0
- package/lib/test/AppendOnlySortedMap.tests.d.ts.map +1 -0
- package/lib/test/AppendOnlySortedMap.tests.js +169 -0
- package/lib/test/AppendOnlySortedMap.tests.js.map +1 -0
- package/lib/test/{SnapshotUtilities.tests.d.ts → ChangeCompression.tests.d.ts} +1 -1
- package/lib/test/ChangeCompression.tests.d.ts.map +1 -0
- package/lib/test/ChangeCompression.tests.js +145 -0
- package/lib/test/ChangeCompression.tests.js.map +1 -0
- package/lib/test/Checkout.tests.d.ts +2 -3
- package/lib/test/Checkout.tests.d.ts.map +1 -1
- package/lib/test/Checkout.tests.js +126 -69
- package/lib/test/Checkout.tests.js.map +1 -1
- package/lib/test/Common.tests.js +60 -2
- package/lib/test/Common.tests.js.map +1 -1
- package/lib/test/{BasicCheckout.tests.d.ts → EagerCheckout.tests.d.ts} +1 -1
- package/lib/test/EagerCheckout.tests.d.ts.map +1 -0
- package/lib/test/EagerCheckout.tests.js +20 -0
- package/lib/test/EagerCheckout.tests.js.map +1 -0
- package/lib/test/Edit.tests.js +22 -14
- package/lib/test/Edit.tests.js.map +1 -1
- package/lib/test/{Anchors.glassBox.tests.d.ts → EditLog.perf.tests.d.ts} +1 -1
- package/lib/test/EditLog.perf.tests.d.ts.map +1 -0
- package/lib/test/EditLog.perf.tests.js +30 -0
- package/lib/test/EditLog.perf.tests.js.map +1 -0
- package/lib/test/EditLog.tests.js +10 -6
- package/lib/test/EditLog.tests.js.map +1 -1
- package/lib/test/EditUtilities.tests.d.ts +6 -0
- package/lib/test/EditUtilities.tests.d.ts.map +1 -0
- package/lib/test/EditUtilities.tests.js +503 -0
- package/lib/test/EditUtilities.tests.js.map +1 -0
- package/lib/test/Forest.perf.tests.d.ts +6 -0
- package/lib/test/Forest.perf.tests.d.ts.map +1 -0
- package/lib/test/Forest.perf.tests.js +133 -0
- package/lib/test/Forest.perf.tests.js.map +1 -0
- package/lib/test/Forest.tests.js +54 -27
- package/lib/test/Forest.tests.js.map +1 -1
- package/lib/test/GenericTransaction.tests.js +12 -3
- package/lib/test/GenericTransaction.tests.js.map +1 -1
- package/lib/test/HistoryEditFactory.tests.d.ts +6 -0
- package/lib/test/HistoryEditFactory.tests.d.ts.map +1 -0
- package/lib/test/HistoryEditFactory.tests.js +90 -0
- package/lib/test/HistoryEditFactory.tests.js.map +1 -0
- package/lib/test/IdCompressor.perf.tests.d.ts +6 -0
- package/lib/test/IdCompressor.perf.tests.d.ts.map +1 -0
- package/lib/test/IdCompressor.perf.tests.js +304 -0
- package/lib/test/IdCompressor.perf.tests.js.map +1 -0
- package/lib/test/IdCompressor.tests.d.ts +6 -0
- package/lib/test/IdCompressor.tests.d.ts.map +1 -0
- package/lib/test/IdCompressor.tests.js +1075 -0
- package/lib/test/IdCompressor.tests.js.map +1 -0
- package/lib/test/IdConversion.tests.d.ts +6 -0
- package/lib/test/IdConversion.tests.d.ts.map +1 -0
- package/lib/test/IdConversion.tests.js +36 -0
- package/lib/test/IdConversion.tests.js.map +1 -0
- package/lib/test/LazyCheckout.tests.d.ts +6 -0
- package/lib/test/LazyCheckout.tests.d.ts.map +1 -0
- package/lib/test/LazyCheckout.tests.js +22 -0
- package/lib/test/LazyCheckout.tests.js.map +1 -0
- package/lib/test/LogViewer.tests.js +276 -191
- package/lib/test/LogViewer.tests.js.map +1 -1
- package/lib/test/{SharedTreeWithAnchors.tests.d.ts → MergeHealthTelemetryHeartbeat.tests.d.ts} +1 -1
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.d.ts.map +1 -0
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js +342 -0
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js.map +1 -0
- package/lib/test/NumericUuid.perf.tests.d.ts +6 -0
- package/lib/test/NumericUuid.perf.tests.d.ts.map +1 -0
- package/lib/test/NumericUuid.perf.tests.js +68 -0
- package/lib/test/NumericUuid.perf.tests.js.map +1 -0
- package/lib/test/NumericUuid.tests.d.ts +6 -0
- package/lib/test/NumericUuid.tests.d.ts.map +1 -0
- package/lib/test/NumericUuid.tests.js +191 -0
- package/lib/test/NumericUuid.tests.js.map +1 -0
- package/lib/test/RevisionView.tests.d.ts +6 -0
- package/lib/test/RevisionView.tests.d.ts.map +1 -0
- package/lib/test/RevisionView.tests.js +133 -0
- package/lib/test/RevisionView.tests.js.map +1 -0
- package/lib/test/SharedTree.perf.tests.d.ts +6 -0
- package/lib/test/SharedTree.perf.tests.d.ts.map +1 -0
- package/lib/test/SharedTree.perf.tests.js +39 -0
- package/lib/test/SharedTree.perf.tests.js.map +1 -0
- package/lib/test/SharedTree.tests.js +15 -3
- package/lib/test/SharedTree.tests.js.map +1 -1
- package/lib/test/StringInterner.tests.d.ts +6 -0
- package/lib/test/StringInterner.tests.d.ts.map +1 -0
- package/lib/test/StringInterner.tests.js +71 -0
- package/lib/test/StringInterner.tests.js.map +1 -0
- package/lib/test/Summary.tests.d.ts +8 -0
- package/lib/test/Summary.tests.d.ts.map +1 -0
- package/lib/test/Summary.tests.js +407 -0
- package/lib/test/Summary.tests.js.map +1 -0
- package/lib/test/Transaction.tests.js +76 -330
- package/lib/test/Transaction.tests.js.map +1 -1
- package/lib/test/TransactionInternal.tests.d.ts +6 -0
- package/lib/test/TransactionInternal.tests.d.ts.map +1 -0
- package/lib/test/TransactionInternal.tests.js +568 -0
- package/lib/test/TransactionInternal.tests.js.map +1 -0
- package/lib/test/TreeCompression.tests.d.ts +6 -0
- package/lib/test/TreeCompression.tests.d.ts.map +1 -0
- package/lib/test/TreeCompression.tests.js +292 -0
- package/lib/test/TreeCompression.tests.js.map +1 -0
- package/lib/test/TreeView.tests.d.ts +6 -0
- package/lib/test/TreeView.tests.d.ts.map +1 -0
- package/lib/test/TreeView.tests.js +176 -0
- package/lib/test/TreeView.tests.js.map +1 -0
- package/lib/test/UndoRedoHandler.tests.js +2 -2
- package/lib/test/UndoRedoHandler.tests.js.map +1 -1
- package/lib/test/Virtualization.tests.js +146 -62
- package/lib/test/Virtualization.tests.js.map +1 -1
- package/lib/test/fuzz/Generators.d.ts +19 -0
- package/lib/test/fuzz/Generators.d.ts.map +1 -0
- package/lib/test/fuzz/Generators.js +420 -0
- package/lib/test/fuzz/Generators.js.map +1 -0
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +20 -0
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -0
- package/lib/test/fuzz/SharedTreeFuzzTests.js +217 -0
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -0
- package/lib/test/fuzz/Types.d.ts +133 -0
- package/lib/test/fuzz/Types.d.ts.map +1 -0
- package/lib/test/{GenericTransactionWithAnchors.tests.d.ts → fuzz/Types.js} +2 -2
- package/lib/test/fuzz/Types.js.map +1 -0
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts +180 -0
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -0
- package/lib/test/utilities/IdCompressorTestUtilities.js +528 -0
- package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -0
- package/lib/test/utilities/MockTransaction.d.ts +26 -7
- package/lib/test/utilities/MockTransaction.d.ts.map +1 -1
- package/lib/test/utilities/MockTransaction.js +40 -11
- package/lib/test/utilities/MockTransaction.js.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.d.ts +12 -0
- package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -0
- package/lib/test/utilities/PendingLocalStateTests.js +105 -0
- package/lib/test/utilities/PendingLocalStateTests.js.map +1 -0
- package/lib/test/utilities/SharedTreeTests.d.ts +3 -4
- package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeTests.js +696 -439
- package/lib/test/utilities/SharedTreeTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts +11 -0
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -0
- package/lib/test/utilities/SharedTreeVersioningTests.js +370 -0
- package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -0
- package/lib/test/utilities/SummaryLoadPerfTests.d.ts +10 -0
- package/lib/test/utilities/SummaryLoadPerfTests.d.ts.map +1 -0
- package/lib/test/utilities/SummaryLoadPerfTests.js +102 -0
- package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -0
- package/lib/test/utilities/SummarySizeTests.d.ts +11 -0
- package/lib/test/utilities/SummarySizeTests.d.ts.map +1 -0
- package/lib/test/utilities/SummarySizeTests.js +158 -0
- package/lib/test/utilities/SummarySizeTests.js.map +1 -0
- package/lib/test/utilities/TestCommon.d.ts +9 -0
- package/lib/test/utilities/TestCommon.d.ts.map +1 -0
- package/lib/test/utilities/TestCommon.js +13 -0
- package/lib/test/utilities/TestCommon.js.map +1 -0
- package/lib/test/utilities/TestNode.d.ts +140 -0
- package/lib/test/utilities/TestNode.d.ts.map +1 -0
- package/lib/test/utilities/TestNode.js +292 -0
- package/lib/test/utilities/TestNode.js.map +1 -0
- package/lib/test/utilities/TestUtilities.d.ts +84 -70
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js +218 -143
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/lib/test/utilities/UndoRedoTests.d.ts +4 -5
- package/lib/test/utilities/UndoRedoTests.d.ts.map +1 -1
- package/lib/test/utilities/UndoRedoTests.js +138 -149
- package/lib/test/utilities/UndoRedoTests.js.map +1 -1
- package/package.json +22 -17
- package/src/ChangeCompression.ts +159 -0
- package/src/{default-edits/PersistedTypes.ts → ChangeTypes.ts} +62 -125
- package/src/Checkout.ts +82 -53
- package/src/Common.ts +317 -117
- package/src/EagerCheckout.ts +38 -0
- package/src/EditLog.ts +153 -100
- package/src/EditUtilities.ts +559 -0
- package/src/EventTypes.ts +74 -0
- package/src/Forest.ts +81 -73
- package/src/{default-edits/HistoryEditFactory.ts → HistoryEditFactory.ts} +103 -53
- package/src/IdConversion.ts +125 -0
- package/src/Identifiers.ts +101 -1
- package/src/InitialTree.ts +5 -4
- package/src/LazyCheckout.ts +51 -0
- package/src/LogViewer.ts +242 -166
- package/src/MergeHealth.ts +447 -0
- package/src/NodeIdUtilities.ts +156 -0
- package/src/PayloadUtilities.ts +124 -0
- package/src/ReconciliationPath.ts +18 -13
- package/src/RevisionValueCache.ts +14 -5
- package/src/RevisionView.ts +252 -0
- package/src/SerializationUtilities.ts +130 -0
- package/src/SharedTree.ts +1501 -0
- package/src/SharedTreeEncoder.ts +493 -0
- package/src/StringInterner.ts +72 -0
- package/src/Summary.ts +48 -0
- package/src/SummaryBackCompatibility.ts +47 -57
- package/src/SummaryTestUtilities.ts +54 -0
- package/src/Transaction.ts +89 -0
- package/src/TransactionInternal.ts +1087 -0
- package/src/TreeCompressor.ts +213 -0
- package/src/TreeNodeHandle.ts +19 -32
- package/src/TreeView.ts +322 -0
- package/src/TreeViewUtilities.ts +77 -0
- package/src/{default-edits/UndoRedoHandler.ts → UndoRedoHandler.ts} +8 -13
- package/src/id-compressor/AppendOnlySortedMap.ts +325 -0
- package/src/id-compressor/IdCompressor.md +3 -0
- package/src/id-compressor/IdCompressor.ts +1848 -0
- package/src/id-compressor/IdRange.ts +33 -0
- package/src/id-compressor/NumericUuid.ts +414 -0
- package/src/id-compressor/index.ts +13 -0
- package/src/id-compressor/persisted-types/0.0.1.ts +179 -0
- package/src/id-compressor/persisted-types/README.md +3 -0
- package/src/id-compressor/persisted-types/index.ts +6 -0
- package/src/index.ts +118 -59
- package/src/persisted-types/0.0.2.ts +442 -0
- package/src/persisted-types/0.1.1.ts +476 -0
- package/src/persisted-types/README.md +22 -0
- package/src/persisted-types/index.ts +9 -0
- package/.mocharc.js +0 -41
- package/api/tree.api.md +0 -729
- package/dist/BasicCheckout.d.ts +0 -23
- package/dist/BasicCheckout.d.ts.map +0 -1
- package/dist/BasicCheckout.js.map +0 -1
- package/dist/Snapshot.d.ts +0 -198
- package/dist/Snapshot.d.ts.map +0 -1
- package/dist/Snapshot.js +0 -267
- package/dist/Snapshot.js.map +0 -1
- package/dist/SnapshotUtilities.d.ts +0 -29
- package/dist/SnapshotUtilities.d.ts.map +0 -1
- package/dist/SnapshotUtilities.js +0 -73
- package/dist/SnapshotUtilities.js.map +0 -1
- package/dist/anchored-edits/AnchorResolution.d.ts +0 -144
- package/dist/anchored-edits/AnchorResolution.d.ts.map +0 -1
- package/dist/anchored-edits/AnchorResolution.js +0 -162
- package/dist/anchored-edits/AnchorResolution.js.map +0 -1
- package/dist/anchored-edits/Factory.d.ts +0 -56
- package/dist/anchored-edits/Factory.d.ts.map +0 -1
- package/dist/anchored-edits/Factory.js +0 -79
- package/dist/anchored-edits/Factory.js.map +0 -1
- package/dist/anchored-edits/PersistedTypes.d.ts +0 -245
- package/dist/anchored-edits/PersistedTypes.d.ts.map +0 -1
- package/dist/anchored-edits/PersistedTypes.js +0 -131
- package/dist/anchored-edits/PersistedTypes.js.map +0 -1
- package/dist/anchored-edits/SharedTreeWithAnchors.d.ts +0 -120
- package/dist/anchored-edits/SharedTreeWithAnchors.d.ts.map +0 -1
- package/dist/anchored-edits/SharedTreeWithAnchors.js +0 -115
- package/dist/anchored-edits/SharedTreeWithAnchors.js.map +0 -1
- package/dist/anchored-edits/TransactionWithAnchors.d.ts +0 -28
- package/dist/anchored-edits/TransactionWithAnchors.d.ts.map +0 -1
- package/dist/anchored-edits/TransactionWithAnchors.js +0 -36
- package/dist/anchored-edits/TransactionWithAnchors.js.map +0 -1
- package/dist/anchored-edits/index.d.ts +0 -10
- package/dist/anchored-edits/index.d.ts.map +0 -1
- package/dist/anchored-edits/index.js +0 -34
- package/dist/anchored-edits/index.js.map +0 -1
- package/dist/default-edits/EditUtilities.d.ts +0 -57
- package/dist/default-edits/EditUtilities.d.ts.map +0 -1
- package/dist/default-edits/EditUtilities.js +0 -192
- package/dist/default-edits/EditUtilities.js.map +0 -1
- package/dist/default-edits/Factory.d.ts +0 -56
- package/dist/default-edits/Factory.d.ts.map +0 -1
- package/dist/default-edits/Factory.js +0 -79
- package/dist/default-edits/Factory.js.map +0 -1
- package/dist/default-edits/HistoryEditFactory.d.ts +0 -19
- package/dist/default-edits/HistoryEditFactory.d.ts.map +0 -1
- package/dist/default-edits/HistoryEditFactory.js +0 -187
- package/dist/default-edits/HistoryEditFactory.js.map +0 -1
- package/dist/default-edits/PersistedTypes.d.ts.map +0 -1
- package/dist/default-edits/PersistedTypes.js.map +0 -1
- package/dist/default-edits/SharedTree.d.ts +0 -111
- package/dist/default-edits/SharedTree.d.ts.map +0 -1
- package/dist/default-edits/SharedTree.js +0 -124
- package/dist/default-edits/SharedTree.js.map +0 -1
- package/dist/default-edits/Summary.d.ts +0 -15
- package/dist/default-edits/Summary.d.ts.map +0 -1
- package/dist/default-edits/Summary.js +0 -35
- package/dist/default-edits/Summary.js.map +0 -1
- package/dist/default-edits/Transaction.d.ts +0 -41
- package/dist/default-edits/Transaction.d.ts.map +0 -1
- package/dist/default-edits/Transaction.js +0 -225
- package/dist/default-edits/Transaction.js.map +0 -1
- package/dist/default-edits/UndoRedoHandler.d.ts.map +0 -1
- package/dist/default-edits/UndoRedoHandler.js.map +0 -1
- package/dist/default-edits/index.d.ts +0 -13
- package/dist/default-edits/index.d.ts.map +0 -1
- package/dist/default-edits/index.js +0 -41
- package/dist/default-edits/index.js.map +0 -1
- package/dist/generic/GenericEditUtilities.d.ts +0 -26
- package/dist/generic/GenericEditUtilities.d.ts.map +0 -1
- package/dist/generic/GenericEditUtilities.js +0 -45
- package/dist/generic/GenericEditUtilities.js.map +0 -1
- package/dist/generic/GenericSharedTree.d.ts +0 -221
- package/dist/generic/GenericSharedTree.d.ts.map +0 -1
- package/dist/generic/GenericSharedTree.js +0 -447
- package/dist/generic/GenericSharedTree.js.map +0 -1
- package/dist/generic/GenericTransaction.d.ts +0 -87
- package/dist/generic/GenericTransaction.d.ts.map +0 -1
- package/dist/generic/GenericTransaction.js +0 -144
- package/dist/generic/GenericTransaction.js.map +0 -1
- package/dist/generic/PersistedTypes.d.ts +0 -194
- package/dist/generic/PersistedTypes.d.ts.map +0 -1
- package/dist/generic/PersistedTypes.js +0 -42
- package/dist/generic/PersistedTypes.js.map +0 -1
- package/dist/generic/Summary.d.ts +0 -63
- package/dist/generic/Summary.d.ts.map +0 -1
- package/dist/generic/Summary.js +0 -64
- package/dist/generic/Summary.js.map +0 -1
- package/dist/generic/index.d.ts +0 -10
- package/dist/generic/index.d.ts.map +0 -1
- package/dist/generic/index.js +0 -26
- package/dist/generic/index.js.map +0 -1
- package/docs/Future.md +0 -155
- package/lib/BasicCheckout.d.ts +0 -23
- package/lib/BasicCheckout.d.ts.map +0 -1
- package/lib/BasicCheckout.js.map +0 -1
- package/lib/Snapshot.d.ts +0 -198
- package/lib/Snapshot.d.ts.map +0 -1
- package/lib/Snapshot.js +0 -263
- package/lib/Snapshot.js.map +0 -1
- package/lib/SnapshotUtilities.d.ts +0 -29
- package/lib/SnapshotUtilities.d.ts.map +0 -1
- package/lib/SnapshotUtilities.js +0 -67
- package/lib/SnapshotUtilities.js.map +0 -1
- package/lib/anchored-edits/AnchorResolution.d.ts +0 -144
- package/lib/anchored-edits/AnchorResolution.d.ts.map +0 -1
- package/lib/anchored-edits/AnchorResolution.js +0 -152
- package/lib/anchored-edits/AnchorResolution.js.map +0 -1
- package/lib/anchored-edits/Factory.d.ts +0 -56
- package/lib/anchored-edits/Factory.d.ts.map +0 -1
- package/lib/anchored-edits/Factory.js +0 -74
- package/lib/anchored-edits/Factory.js.map +0 -1
- package/lib/anchored-edits/PersistedTypes.d.ts +0 -245
- package/lib/anchored-edits/PersistedTypes.d.ts.map +0 -1
- package/lib/anchored-edits/PersistedTypes.js +0 -128
- package/lib/anchored-edits/PersistedTypes.js.map +0 -1
- package/lib/anchored-edits/SharedTreeWithAnchors.d.ts +0 -120
- package/lib/anchored-edits/SharedTreeWithAnchors.d.ts.map +0 -1
- package/lib/anchored-edits/SharedTreeWithAnchors.js +0 -110
- package/lib/anchored-edits/SharedTreeWithAnchors.js.map +0 -1
- package/lib/anchored-edits/TransactionWithAnchors.d.ts +0 -28
- package/lib/anchored-edits/TransactionWithAnchors.d.ts.map +0 -1
- package/lib/anchored-edits/TransactionWithAnchors.js +0 -32
- package/lib/anchored-edits/TransactionWithAnchors.js.map +0 -1
- package/lib/anchored-edits/index.d.ts +0 -10
- package/lib/anchored-edits/index.d.ts.map +0 -1
- package/lib/anchored-edits/index.js +0 -11
- package/lib/anchored-edits/index.js.map +0 -1
- package/lib/default-edits/EditUtilities.d.ts +0 -57
- package/lib/default-edits/EditUtilities.d.ts.map +0 -1
- package/lib/default-edits/EditUtilities.js +0 -181
- package/lib/default-edits/EditUtilities.js.map +0 -1
- package/lib/default-edits/Factory.d.ts +0 -56
- package/lib/default-edits/Factory.d.ts.map +0 -1
- package/lib/default-edits/Factory.js +0 -74
- package/lib/default-edits/Factory.js.map +0 -1
- package/lib/default-edits/HistoryEditFactory.d.ts +0 -19
- package/lib/default-edits/HistoryEditFactory.d.ts.map +0 -1
- package/lib/default-edits/HistoryEditFactory.js.map +0 -1
- package/lib/default-edits/PersistedTypes.d.ts.map +0 -1
- package/lib/default-edits/PersistedTypes.js.map +0 -1
- package/lib/default-edits/SharedTree.d.ts +0 -111
- package/lib/default-edits/SharedTree.d.ts.map +0 -1
- package/lib/default-edits/SharedTree.js +0 -100
- package/lib/default-edits/SharedTree.js.map +0 -1
- package/lib/default-edits/Summary.d.ts +0 -15
- package/lib/default-edits/Summary.d.ts.map +0 -1
- package/lib/default-edits/Summary.js +0 -31
- package/lib/default-edits/Summary.js.map +0 -1
- package/lib/default-edits/Transaction.d.ts +0 -41
- package/lib/default-edits/Transaction.d.ts.map +0 -1
- package/lib/default-edits/Transaction.js +0 -221
- package/lib/default-edits/Transaction.js.map +0 -1
- package/lib/default-edits/UndoRedoHandler.d.ts.map +0 -1
- package/lib/default-edits/UndoRedoHandler.js.map +0 -1
- package/lib/default-edits/index.d.ts +0 -13
- package/lib/default-edits/index.d.ts.map +0 -1
- package/lib/default-edits/index.js +0 -14
- package/lib/default-edits/index.js.map +0 -1
- package/lib/generic/GenericEditUtilities.d.ts +0 -26
- package/lib/generic/GenericEditUtilities.d.ts.map +0 -1
- package/lib/generic/GenericEditUtilities.js +0 -38
- package/lib/generic/GenericEditUtilities.js.map +0 -1
- package/lib/generic/GenericSharedTree.d.ts +0 -221
- package/lib/generic/GenericSharedTree.d.ts.map +0 -1
- package/lib/generic/GenericSharedTree.js +0 -443
- package/lib/generic/GenericSharedTree.js.map +0 -1
- package/lib/generic/GenericTransaction.d.ts +0 -87
- package/lib/generic/GenericTransaction.d.ts.map +0 -1
- package/lib/generic/GenericTransaction.js +0 -140
- package/lib/generic/GenericTransaction.js.map +0 -1
- package/lib/generic/PersistedTypes.d.ts +0 -194
- package/lib/generic/PersistedTypes.d.ts.map +0 -1
- package/lib/generic/PersistedTypes.js +0 -39
- package/lib/generic/PersistedTypes.js.map +0 -1
- package/lib/generic/Summary.d.ts +0 -63
- package/lib/generic/Summary.d.ts.map +0 -1
- package/lib/generic/Summary.js +0 -58
- package/lib/generic/Summary.js.map +0 -1
- package/lib/generic/index.d.ts +0 -10
- package/lib/generic/index.d.ts.map +0 -1
- package/lib/generic/index.js +0 -11
- package/lib/generic/index.js.map +0 -1
- package/lib/test/Anchors.glassBox.tests.d.ts.map +0 -1
- package/lib/test/Anchors.glassBox.tests.js +0 -410
- package/lib/test/Anchors.glassBox.tests.js.map +0 -1
- package/lib/test/BasicCheckout.tests.d.ts.map +0 -1
- package/lib/test/BasicCheckout.tests.js +0 -8
- package/lib/test/BasicCheckout.tests.js.map +0 -1
- package/lib/test/GenericTransactionWithAnchors.tests.d.ts.map +0 -1
- package/lib/test/GenericTransactionWithAnchors.tests.js +0 -25
- package/lib/test/GenericTransactionWithAnchors.tests.js.map +0 -1
- package/lib/test/SharedTreeWithAnchors.tests.d.ts.map +0 -1
- package/lib/test/SharedTreeWithAnchors.tests.js +0 -420
- package/lib/test/SharedTreeWithAnchors.tests.js.map +0 -1
- package/lib/test/Snapshot.tests.d.ts.map +0 -1
- package/lib/test/Snapshot.tests.js +0 -96
- package/lib/test/Snapshot.tests.js.map +0 -1
- package/lib/test/SnapshotUtilities.tests.d.ts.map +0 -1
- package/lib/test/SnapshotUtilities.tests.js +0 -168
- package/lib/test/SnapshotUtilities.tests.js.map +0 -1
- package/lib/test/undoRedoStackManager.d.ts +0 -26
- package/lib/test/undoRedoStackManager.d.ts.map +0 -1
- package/lib/test/undoRedoStackManager.js +0 -176
- package/lib/test/undoRedoStackManager.js.map +0 -1
- package/lib/test/utilities/SummaryFormatCompatibilityTests.d.ts +0 -13
- package/lib/test/utilities/SummaryFormatCompatibilityTests.d.ts.map +0 -1
- package/lib/test/utilities/SummaryFormatCompatibilityTests.js +0 -154
- package/lib/test/utilities/SummaryFormatCompatibilityTests.js.map +0 -1
- package/src/BasicCheckout.ts +0 -34
- package/src/Snapshot.ts +0 -363
- package/src/SnapshotUtilities.ts +0 -88
- package/src/anchored-edits/AnchorResolution.ts +0 -442
- package/src/anchored-edits/Factory.ts +0 -94
- package/src/anchored-edits/PersistedTypes.ts +0 -310
- package/src/anchored-edits/SharedTreeWithAnchors.ts +0 -200
- package/src/anchored-edits/TransactionWithAnchors.ts +0 -39
- package/src/anchored-edits/index.ts +0 -21
- package/src/default-edits/EditUtilities.ts +0 -220
- package/src/default-edits/Factory.ts +0 -94
- package/src/default-edits/SharedTree.ts +0 -174
- package/src/default-edits/Summary.ts +0 -44
- package/src/default-edits/Transaction.ts +0 -262
- package/src/default-edits/index.ts +0 -29
- package/src/generic/GenericEditUtilities.ts +0 -46
- package/src/generic/GenericSharedTree.ts +0 -593
- package/src/generic/GenericTransaction.ts +0 -194
- package/src/generic/PersistedTypes.ts +0 -221
- package/src/generic/Summary.ts +0 -113
- package/src/generic/index.ts +0 -41
|
@@ -0,0 +1,528 @@
|
|
|
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 { v5 } from 'uuid';
|
|
7
|
+
import Prando from 'prando';
|
|
8
|
+
import { expect } from 'chai';
|
|
9
|
+
import { assert, assertNotUndefined, fail, getOrCreate } from '../../Common';
|
|
10
|
+
import { IdCompressor, isLocalId } from '../../id-compressor/IdCompressor';
|
|
11
|
+
import { assertIsStableId, createSessionId, ensureSessionUuid, numericUuidFromStableId, stableIdFromNumericUuid, } from '../../id-compressor/NumericUuid';
|
|
12
|
+
import { getIds } from '../../id-compressor/IdRange';
|
|
13
|
+
/** Identifies a compressor in a network */
|
|
14
|
+
export var Client;
|
|
15
|
+
(function (Client) {
|
|
16
|
+
Client["Client1"] = "Client1";
|
|
17
|
+
Client["Client2"] = "Client2";
|
|
18
|
+
Client["Client3"] = "Client3";
|
|
19
|
+
})(Client || (Client = {}));
|
|
20
|
+
/** Identifies a compressor with respect to a specific operation */
|
|
21
|
+
export var SemanticClient;
|
|
22
|
+
(function (SemanticClient) {
|
|
23
|
+
SemanticClient["LocalClient"] = "LocalClient";
|
|
24
|
+
})(SemanticClient || (SemanticClient = {}));
|
|
25
|
+
/** Identifies categories of compressors */
|
|
26
|
+
export var MetaClient;
|
|
27
|
+
(function (MetaClient) {
|
|
28
|
+
MetaClient["All"] = "All";
|
|
29
|
+
})(MetaClient || (MetaClient = {}));
|
|
30
|
+
export const OriginatingClient = Object.assign(Object.assign({}, Client), SemanticClient);
|
|
31
|
+
export const DestinationClient = Object.assign(Object.assign({}, Client), MetaClient);
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new compressor with the supplied cluster capacity.
|
|
34
|
+
*/
|
|
35
|
+
export function createCompressor(client, clusterCapacity = 5, attributionInfo) {
|
|
36
|
+
const compressor = new IdCompressor(sessionIds.get(client), 1024, attributionInfo);
|
|
37
|
+
compressor.clusterCapacity = clusterCapacity;
|
|
38
|
+
return compressor;
|
|
39
|
+
}
|
|
40
|
+
function makeSessionIds() {
|
|
41
|
+
const stableIds = new Map();
|
|
42
|
+
const clients = Object.values(Client);
|
|
43
|
+
for (let i = 0; i < clients.length; i++) {
|
|
44
|
+
// Place session uuids roughly in the middle of uuid space to increase odds of encountering interesting
|
|
45
|
+
// orderings in sorted collections
|
|
46
|
+
const sessionId = ensureSessionUuid(assertIsStableId(`88888888-8888-4888-b${i}88-888888888888`));
|
|
47
|
+
stableIds.set(clients[i], sessionId);
|
|
48
|
+
}
|
|
49
|
+
return stableIds;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* An array of session ID strings corresponding to all non-local `Client` entries.
|
|
53
|
+
*/
|
|
54
|
+
export const sessionIds = makeSessionIds();
|
|
55
|
+
/**
|
|
56
|
+
* An array of session uuids corresponding to all non-local `Client` entries.
|
|
57
|
+
*/
|
|
58
|
+
export const sessionNumericUuids = new Map([...sessionIds.entries()].map(([client, sessionId]) => {
|
|
59
|
+
return [client, numericUuidFromStableId(sessionId)];
|
|
60
|
+
}));
|
|
61
|
+
/**
|
|
62
|
+
* Simulates a network of ID compressors.
|
|
63
|
+
* Not suitable for performance testing.
|
|
64
|
+
*/
|
|
65
|
+
export class IdCompressorTestNetwork {
|
|
66
|
+
constructor(initialClusterSize = 5, onIdReceived) {
|
|
67
|
+
this.initialClusterSize = initialClusterSize;
|
|
68
|
+
this.onIdReceived = onIdReceived;
|
|
69
|
+
/** The log of operations seen by the server so far. Append-only. */
|
|
70
|
+
this.serverOperations = [];
|
|
71
|
+
const compressors = new Map();
|
|
72
|
+
const clientProgress = new Map();
|
|
73
|
+
const clientIds = new Map();
|
|
74
|
+
const clientSequencedIds = new Map();
|
|
75
|
+
for (const client of Object.values(Client)) {
|
|
76
|
+
const compressor = createCompressor(client, initialClusterSize, client);
|
|
77
|
+
compressors.set(client, compressor);
|
|
78
|
+
clientProgress.set(client, 0);
|
|
79
|
+
clientIds.set(client, []);
|
|
80
|
+
clientSequencedIds.set(client, []);
|
|
81
|
+
}
|
|
82
|
+
this.compressors = compressors;
|
|
83
|
+
this.clientProgress = clientProgress;
|
|
84
|
+
this.idLogs = clientIds;
|
|
85
|
+
this.sequencedIdLogs = clientSequencedIds;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns an immutable handle to a compressor in the network.
|
|
89
|
+
*/
|
|
90
|
+
getCompressor(client) {
|
|
91
|
+
const compressors = this.compressors;
|
|
92
|
+
const handler = {
|
|
93
|
+
get(_, property) {
|
|
94
|
+
const compressor = compressors.get(client);
|
|
95
|
+
return compressor[property];
|
|
96
|
+
},
|
|
97
|
+
set(_, property, value) {
|
|
98
|
+
const compressor = compressors.get(client);
|
|
99
|
+
compressor[property] = value;
|
|
100
|
+
return true;
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
return new Proxy({}, handler);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Returns a mutable handle to a compressor in the network. Use of mutation methods will break the network invariants and
|
|
107
|
+
* should only be used if the network will not be used again.
|
|
108
|
+
*/
|
|
109
|
+
getCompressorUnsafe(client) {
|
|
110
|
+
return this.getCompressor(client);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns data for all IDs created and received by this client, including ack's of their own (i.e. their own IDs will appear twice)
|
|
114
|
+
*/
|
|
115
|
+
getIdLog(client) {
|
|
116
|
+
return this.idLogs.get(client);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns data for all IDs received by this client, including ack's of their own (i.e. their own IDs will appear twice)
|
|
120
|
+
*/
|
|
121
|
+
getSequencedIdLog(client) {
|
|
122
|
+
return this.sequencedIdLogs.get(client);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get all compressors for the given destination
|
|
126
|
+
*/
|
|
127
|
+
getTargetCompressors(clientTo) {
|
|
128
|
+
return clientTo === MetaClient.All
|
|
129
|
+
? [...this.compressors.entries()]
|
|
130
|
+
: [[clientTo, this.getCompressor(clientTo)]];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Submit a capacity change operation to the network. It will not take effect immediately but will be processed in sequence order.
|
|
134
|
+
*/
|
|
135
|
+
enqueueCapacityChange(newClusterCapacity) {
|
|
136
|
+
this.serverOperations.push(newClusterCapacity);
|
|
137
|
+
}
|
|
138
|
+
addNewId(client, id, expectedOverride, originatingClient, isSequenced) {
|
|
139
|
+
var _a;
|
|
140
|
+
const idData = {
|
|
141
|
+
id,
|
|
142
|
+
originatingClient,
|
|
143
|
+
sessionId: sessionIds.get(originatingClient),
|
|
144
|
+
sessionNumericUuid: sessionNumericUuids.get(originatingClient),
|
|
145
|
+
expectedOverride,
|
|
146
|
+
isSequenced,
|
|
147
|
+
};
|
|
148
|
+
const clientIds = this.idLogs.get(client);
|
|
149
|
+
clientIds.push(idData);
|
|
150
|
+
if (isSequenced) {
|
|
151
|
+
const sequencedIds = this.sequencedIdLogs.get(client);
|
|
152
|
+
sequencedIds.push(idData);
|
|
153
|
+
}
|
|
154
|
+
(_a = this.onIdReceived) === null || _a === void 0 ? void 0 : _a.call(this, this, client, clientIds);
|
|
155
|
+
}
|
|
156
|
+
allocateAndSendIds(client, numIds, overrides = {}) {
|
|
157
|
+
assert(numIds > 0, 'Must allocate a non-zero number of IDs');
|
|
158
|
+
const compressor = this.compressors.get(client);
|
|
159
|
+
let nextIdIndex = 0;
|
|
160
|
+
for (const [overrideIndex, uuid] of Object.entries(overrides)
|
|
161
|
+
.map(([id, uuid]) => [Number.parseInt(id, 10), uuid])
|
|
162
|
+
.sort(([a], [b]) => a - b)) {
|
|
163
|
+
while (nextIdIndex < overrideIndex) {
|
|
164
|
+
this.addNewId(client, compressor.generateCompressedId(), undefined, client, false);
|
|
165
|
+
nextIdIndex += 1;
|
|
166
|
+
}
|
|
167
|
+
this.addNewId(client, compressor.generateCompressedId(uuid), uuid, client, false);
|
|
168
|
+
nextIdIndex += 1;
|
|
169
|
+
}
|
|
170
|
+
const numTrailingIds = numIds - nextIdIndex;
|
|
171
|
+
let range;
|
|
172
|
+
if (numTrailingIds > 0) {
|
|
173
|
+
range = compressor.generateCompressedIdRange(numTrailingIds);
|
|
174
|
+
const ids = compressor.getIdsFromRange(range, compressor.localSessionId);
|
|
175
|
+
for (let i = 0; i < numTrailingIds; i++) {
|
|
176
|
+
this.addNewId(client, ids.get(i), undefined, client, false);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const creationRange = compressor.takeNextCreationRange();
|
|
180
|
+
this.serverOperations.push([creationRange, client]);
|
|
181
|
+
return nextIdIndex === 0 ? { range: range !== null && range !== void 0 ? range : fail(), sessionId: compressor.localSessionId } : creationRange;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Delivers all undelivered ID ranges and cluster capacity changes from the server to the target clients.
|
|
185
|
+
*/
|
|
186
|
+
deliverOperations(clientTakingDelivery) {
|
|
187
|
+
var _a;
|
|
188
|
+
for (const [clientTo, compressorTo] of this.getTargetCompressors(clientTakingDelivery)) {
|
|
189
|
+
for (let i = this.clientProgress.get(clientTo); i < this.serverOperations.length; i++) {
|
|
190
|
+
const operation = this.serverOperations[i];
|
|
191
|
+
if (typeof operation === 'number') {
|
|
192
|
+
compressorTo.clusterCapacity = operation;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
const [range, clientFrom] = operation;
|
|
196
|
+
compressorTo.finalizeCreationRange(range);
|
|
197
|
+
const ids = getIds(range);
|
|
198
|
+
if (ids !== undefined) {
|
|
199
|
+
let overrideIndex = 0;
|
|
200
|
+
const overrides = ids.overrides;
|
|
201
|
+
for (let id = ids.first; id >= ids.last; id--) {
|
|
202
|
+
let override;
|
|
203
|
+
if (overrides !== undefined &&
|
|
204
|
+
overrideIndex < overrides.length &&
|
|
205
|
+
id === overrides[overrideIndex][0]) {
|
|
206
|
+
override = overrides[overrideIndex][1];
|
|
207
|
+
overrideIndex++;
|
|
208
|
+
}
|
|
209
|
+
const sessionSpaceId = compressorTo.normalizeToSessionSpace(id, range.sessionId);
|
|
210
|
+
this.addNewId(clientTo, sessionSpaceId, override, clientFrom, true);
|
|
211
|
+
}
|
|
212
|
+
assert(overrideIndex === ((_a = overrides === null || overrides === void 0 ? void 0 : overrides.length) !== null && _a !== void 0 ? _a : 0));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
this.clientProgress.set(clientTo, this.serverOperations.length);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Simulate a client disconnecting (and serializing), then reconnecting (and deserializing)
|
|
221
|
+
*/
|
|
222
|
+
goOfflineThenResume(client) {
|
|
223
|
+
const compressor = this.compressors.get(client);
|
|
224
|
+
const [_, resumedCompressor] = roundtrip(compressor, true);
|
|
225
|
+
this.compressors.set(client, resumedCompressor);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Ensure general validity of the network state. Useful for calling periodically or at the end of test scenarios.
|
|
229
|
+
*/
|
|
230
|
+
assertNetworkState() {
|
|
231
|
+
const sequencedLogs = Object.values(Client).map((client) => [this.compressors.get(client), this.getSequencedIdLog(client)]);
|
|
232
|
+
const maxLogLength = sequencedLogs.map(([_, data]) => data.length).reduce((p, n) => Math.max(p, n));
|
|
233
|
+
function getNextLogWithEntryAt(logsIndex, entryIndex) {
|
|
234
|
+
for (let i = logsIndex; i < sequencedLogs.length; i++) {
|
|
235
|
+
const log = sequencedLogs[i];
|
|
236
|
+
if (log[1].length > entryIndex) {
|
|
237
|
+
return i;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
const uuids = new Set();
|
|
243
|
+
const finalIds = new Set();
|
|
244
|
+
const idIndicesAggregator = new Map();
|
|
245
|
+
function* getLogIndices(columnIndex) {
|
|
246
|
+
let current = getNextLogWithEntryAt(0, columnIndex);
|
|
247
|
+
while (current !== undefined) {
|
|
248
|
+
const next = getNextLogWithEntryAt(current + 1, columnIndex);
|
|
249
|
+
const [compressor, log] = sequencedLogs[current];
|
|
250
|
+
if (next === undefined) {
|
|
251
|
+
yield [[compressor, log[columnIndex]]];
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
const [compressorNext, logNext] = sequencedLogs[next];
|
|
255
|
+
yield [
|
|
256
|
+
[compressor, log[columnIndex]],
|
|
257
|
+
[compressorNext, logNext[columnIndex]],
|
|
258
|
+
];
|
|
259
|
+
}
|
|
260
|
+
current = next;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
for (let i = 0; i < maxLogLength; i++) {
|
|
264
|
+
const creator = [];
|
|
265
|
+
let originatingClient;
|
|
266
|
+
let localCount = 0;
|
|
267
|
+
let rowCount = 0;
|
|
268
|
+
for (const [current, next] of getLogIndices(i)) {
|
|
269
|
+
const [compressorA, idDataA] = current;
|
|
270
|
+
const sessionSpaceIdA = idDataA.id;
|
|
271
|
+
if (isLocalId(sessionSpaceIdA)) {
|
|
272
|
+
localCount += 1;
|
|
273
|
+
}
|
|
274
|
+
const idIndex = getOrCreate(idIndicesAggregator, idDataA.originatingClient, () => 0);
|
|
275
|
+
originatingClient !== null && originatingClient !== void 0 ? originatingClient : (originatingClient = idDataA.originatingClient);
|
|
276
|
+
assert(idDataA.originatingClient === originatingClient, 'Test infra gave wrong originating client to TestIdData');
|
|
277
|
+
// Only one client should have this ID as local in its session space, as only one client could have created this ID
|
|
278
|
+
if (isLocalId(sessionSpaceIdA)) {
|
|
279
|
+
localCount++;
|
|
280
|
+
expect(idDataA.sessionId).to.equal(this.compressors.get(originatingClient).localSessionId);
|
|
281
|
+
expect(creator.length === 0 || creator[creator.length - 1][1] === idDataA.expectedOverride).to.be
|
|
282
|
+
.true;
|
|
283
|
+
creator.push([originatingClient, idDataA.expectedOverride]);
|
|
284
|
+
}
|
|
285
|
+
const uuidASessionSpace = compressorA.decompress(sessionSpaceIdA);
|
|
286
|
+
if (idDataA.expectedOverride !== undefined) {
|
|
287
|
+
expect(uuidASessionSpace).to.equal(idDataA.expectedOverride);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
expect(uuidASessionSpace).to.equal(stableIdFromNumericUuid(idDataA.sessionNumericUuid, idIndex));
|
|
291
|
+
}
|
|
292
|
+
expect(compressorA.recompress(uuidASessionSpace)).to.equal(sessionSpaceIdA);
|
|
293
|
+
uuids.add(uuidASessionSpace);
|
|
294
|
+
const opSpaceIdA = compressorA.normalizeToOpSpace(sessionSpaceIdA);
|
|
295
|
+
if (isLocalId(opSpaceIdA)) {
|
|
296
|
+
expect.fail('IDs should have been finalized.');
|
|
297
|
+
}
|
|
298
|
+
// TODO: This cast can be removed on typescript 4.6
|
|
299
|
+
finalIds.add(opSpaceIdA);
|
|
300
|
+
const uuidAOpSpace = compressorA.decompress(opSpaceIdA);
|
|
301
|
+
expect(uuidASessionSpace).to.equal(uuidAOpSpace);
|
|
302
|
+
if (next !== undefined) {
|
|
303
|
+
const [compressorB, idDataB] = next;
|
|
304
|
+
const sessionSpaceIdB = idDataB.id;
|
|
305
|
+
const uuidBSessionSpace = compressorB.decompress(sessionSpaceIdB);
|
|
306
|
+
expect(uuidASessionSpace).to.equal(uuidBSessionSpace);
|
|
307
|
+
const opSpaceIdB = compressorB.normalizeToOpSpace(sessionSpaceIdB);
|
|
308
|
+
if (opSpaceIdA !== opSpaceIdB) {
|
|
309
|
+
compressorB.normalizeToOpSpace(sessionSpaceIdB);
|
|
310
|
+
compressorA.normalizeToOpSpace(sessionSpaceIdA);
|
|
311
|
+
}
|
|
312
|
+
expect(opSpaceIdA).to.equal(opSpaceIdB);
|
|
313
|
+
if (isLocalId(opSpaceIdB)) {
|
|
314
|
+
fail('IDs should have been finalized.');
|
|
315
|
+
}
|
|
316
|
+
const uuidBOpSpace = compressorB.decompress(opSpaceIdB);
|
|
317
|
+
expect(uuidAOpSpace).to.equal(uuidBOpSpace);
|
|
318
|
+
}
|
|
319
|
+
rowCount += 1;
|
|
320
|
+
}
|
|
321
|
+
// A local count > 1 indicates that this ID was unified, as more than one client has a local ID for it
|
|
322
|
+
// in their session space.
|
|
323
|
+
if (rowCount === this.sequencedIdLogs.size && localCount <= 1) {
|
|
324
|
+
expect(localCount).to.equal(1);
|
|
325
|
+
for (const [[compressor, { id, originatingClient }]] of getLogIndices(i)) {
|
|
326
|
+
expect(compressor.attributeId(id)).to.equal(originatingClient);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
expect(uuids.size).to.equal(finalIds.size);
|
|
330
|
+
assert(originatingClient !== undefined);
|
|
331
|
+
idIndicesAggregator.set(originatingClient, assertNotUndefined(idIndicesAggregator.get(originatingClient)) + 1);
|
|
332
|
+
}
|
|
333
|
+
for (const [compressor] of sequencedLogs) {
|
|
334
|
+
expectSerializes(compressor);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
export function roundtrip(compressor, withSession) {
|
|
339
|
+
if (withSession) {
|
|
340
|
+
const serialized = compressor.serialize(withSession);
|
|
341
|
+
return [serialized, IdCompressor.deserialize(serialized)];
|
|
342
|
+
}
|
|
343
|
+
const nonLocalSerialized = compressor.serialize(withSession);
|
|
344
|
+
return [nonLocalSerialized, IdCompressor.deserialize(nonLocalSerialized, createSessionId())];
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Asserts that the supplied compressor correctly roundtrips through serialization/deserialization.
|
|
348
|
+
*/
|
|
349
|
+
export function expectSerializes(compressor) {
|
|
350
|
+
function expectSerializes(withSession) {
|
|
351
|
+
let serialized;
|
|
352
|
+
let deserialized;
|
|
353
|
+
if (withSession) {
|
|
354
|
+
[serialized, deserialized] = roundtrip(compressor, true);
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
[serialized, deserialized] = roundtrip(compressor, false);
|
|
358
|
+
}
|
|
359
|
+
const chainCount = [];
|
|
360
|
+
for (let i = 0; i < serialized.sessions.length; i++) {
|
|
361
|
+
chainCount[i] = 0;
|
|
362
|
+
}
|
|
363
|
+
const chainProcessed = [...chainCount];
|
|
364
|
+
for (const cluster of serialized.clusters) {
|
|
365
|
+
const [sessionIndex] = cluster;
|
|
366
|
+
expect(sessionIndex < serialized.sessions.length);
|
|
367
|
+
chainCount[sessionIndex]++;
|
|
368
|
+
}
|
|
369
|
+
for (const cluster of serialized.clusters) {
|
|
370
|
+
const [sessionIndex, capacity, maybeSize] = cluster;
|
|
371
|
+
const chainIndex = chainProcessed[sessionIndex];
|
|
372
|
+
if (chainIndex < chainCount[sessionIndex] - 1) {
|
|
373
|
+
expect(maybeSize === undefined);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
expect(maybeSize === undefined || typeof maybeSize !== 'number' || maybeSize < capacity);
|
|
377
|
+
}
|
|
378
|
+
chainProcessed[sessionIndex]++;
|
|
379
|
+
}
|
|
380
|
+
expect(compressor.equals(deserialized, withSession)).to.be.true;
|
|
381
|
+
return serialized;
|
|
382
|
+
}
|
|
383
|
+
return [
|
|
384
|
+
expectSerializes(false),
|
|
385
|
+
expectSerializes(true),
|
|
386
|
+
];
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Merges 'from' into 'to', and returns 'to'.
|
|
390
|
+
*/
|
|
391
|
+
export function mergeArrayMaps(to, from) {
|
|
392
|
+
for (const [key, value] of from.entries()) {
|
|
393
|
+
const entry = to.get(key);
|
|
394
|
+
if (entry !== undefined) {
|
|
395
|
+
entry.push(...value);
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
to.set(key, [...value]);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return to;
|
|
402
|
+
}
|
|
403
|
+
var Operation;
|
|
404
|
+
(function (Operation) {
|
|
405
|
+
Operation[Operation["AllocateIds"] = 0] = "AllocateIds";
|
|
406
|
+
Operation[Operation["DeliverOperations"] = 1] = "DeliverOperations";
|
|
407
|
+
Operation[Operation["ChangeCapacity"] = 2] = "ChangeCapacity";
|
|
408
|
+
Operation[Operation["GenerateUnifyingIds"] = 3] = "GenerateUnifyingIds";
|
|
409
|
+
Operation[Operation["GoOfflineThenResume"] = 4] = "GoOfflineThenResume";
|
|
410
|
+
})(Operation || (Operation = {}));
|
|
411
|
+
/**
|
|
412
|
+
* Performs random actions on a test network.
|
|
413
|
+
* @param network the test network to test
|
|
414
|
+
* @param seed the seed for the random generation of the fuzz actions
|
|
415
|
+
* @param includeOverrides whether or not the fuzz actions will generate override UUIDs
|
|
416
|
+
* @param observerClient if provided, this client will never generate local ids
|
|
417
|
+
* @param synchronizeAtEnd if provided, all client will have all operations delivered from the server at the end of the test
|
|
418
|
+
* @param numUsages if provided, the number of operations to perform as part of this test. Defaults to 1000.
|
|
419
|
+
* @param validator if provided, this callback will be invoked periodically during the fuzz test.
|
|
420
|
+
*/
|
|
421
|
+
export function performFuzzActions(network, seed, includeOverrides, observerClient, synchronizeAtEnd = true, numUsages = 1000, maxClusterSize = 25, validator) {
|
|
422
|
+
const rand = new Prando(seed);
|
|
423
|
+
const selectableClients = network.getTargetCompressors(MetaClient.All).map(([client]) => client);
|
|
424
|
+
const activeClients = selectableClients.filter((c) => c !== observerClient);
|
|
425
|
+
// Ensure that the same UUIDs are generated for the same seed across different calls
|
|
426
|
+
let uuidNum = 0;
|
|
427
|
+
const uuidNamespace = 'ece2be2e-f374-4ca8-b034-a0bac2da69da';
|
|
428
|
+
let clusterSize = network.initialClusterSize;
|
|
429
|
+
if (clusterSize > maxClusterSize) {
|
|
430
|
+
network.enqueueCapacityChange(maxClusterSize);
|
|
431
|
+
clusterSize = maxClusterSize;
|
|
432
|
+
}
|
|
433
|
+
const opWeights = [
|
|
434
|
+
[Operation.ChangeCapacity, 1],
|
|
435
|
+
[Operation.AllocateIds, 8],
|
|
436
|
+
[Operation.DeliverOperations, 4],
|
|
437
|
+
[Operation.GenerateUnifyingIds, 1],
|
|
438
|
+
[Operation.GoOfflineThenResume, 1],
|
|
439
|
+
];
|
|
440
|
+
const opSums = [];
|
|
441
|
+
let prevWeight = 0;
|
|
442
|
+
for (const opWeight of opWeights) {
|
|
443
|
+
const weight = prevWeight + opWeight[1];
|
|
444
|
+
opSums.push([opWeight[0], weight]);
|
|
445
|
+
prevWeight = weight;
|
|
446
|
+
}
|
|
447
|
+
for (let i = 0; i < numUsages; i++) {
|
|
448
|
+
const weightSelected = rand.nextInt(1, prevWeight);
|
|
449
|
+
let opIndex = 0;
|
|
450
|
+
while (weightSelected > opSums[opIndex][1]) {
|
|
451
|
+
opIndex++;
|
|
452
|
+
}
|
|
453
|
+
const operation = opWeights[opIndex][0];
|
|
454
|
+
switch (operation) {
|
|
455
|
+
case Operation.ChangeCapacity: {
|
|
456
|
+
clusterSize = Math.min(Math.floor(rand.next(0, 1) ** 2 * maxClusterSize) + 1, maxClusterSize);
|
|
457
|
+
network.enqueueCapacityChange(clusterSize);
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
case Operation.AllocateIds: {
|
|
461
|
+
const client = rand.nextArrayItem(activeClients);
|
|
462
|
+
const maxIdsPerUsage = clusterSize * 2;
|
|
463
|
+
const numIds = Math.floor(rand.next(0, 1) ** 2 * maxIdsPerUsage) + 1;
|
|
464
|
+
const overrides = {};
|
|
465
|
+
if (includeOverrides && /* 25% chance: */ rand.nextInt(0, 3) === 0) {
|
|
466
|
+
for (let j = 0; j < numIds; j++) {
|
|
467
|
+
if ( /* 33% chance: */rand.nextInt(0, 2) === 0) {
|
|
468
|
+
overrides[j] = v5((uuidNum++).toString(), uuidNamespace);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
network.allocateAndSendIds(client, numIds, overrides);
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
case Operation.DeliverOperations: {
|
|
476
|
+
const client = rand.nextArrayItem([...selectableClients, MetaClient.All]);
|
|
477
|
+
network.deliverOperations(client);
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
case Operation.GenerateUnifyingIds: {
|
|
481
|
+
const clientA = rand.nextArrayItem(activeClients);
|
|
482
|
+
const clientB = rand.nextArrayItem(activeClients.filter((c) => c !== clientA));
|
|
483
|
+
const uuid = v5((uuidNum++).toString(), uuidNamespace);
|
|
484
|
+
network.allocateAndSendIds(clientA, 1, { 0: uuid });
|
|
485
|
+
network.allocateAndSendIds(clientB, 1, { 0: uuid });
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
case Operation.GoOfflineThenResume: {
|
|
489
|
+
const client = rand.nextArrayItem(activeClients);
|
|
490
|
+
network.goOfflineThenResume(client);
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
default:
|
|
494
|
+
throw new Error('Unknown operation.');
|
|
495
|
+
}
|
|
496
|
+
if (i !== 0 && i % Math.round(numUsages / 5) === 0) {
|
|
497
|
+
validator === null || validator === void 0 ? void 0 : validator(network);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
if (synchronizeAtEnd) {
|
|
501
|
+
network.deliverOperations(DestinationClient.All);
|
|
502
|
+
validator === null || validator === void 0 ? void 0 : validator(network);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Converts the supplied integer to a uuid.
|
|
507
|
+
*/
|
|
508
|
+
export function integerToStableId(num) {
|
|
509
|
+
const bigintNum = BigInt(num);
|
|
510
|
+
const upper = bigintNum >> BigInt(74);
|
|
511
|
+
const middle = (bigintNum & (BigInt(0xfff) << BigInt(62))) >> BigInt(62);
|
|
512
|
+
const lower = bigintNum & BigInt('0x3fffffffffffffff');
|
|
513
|
+
const upperString = padToLength(upper.toString(16), '0', 12);
|
|
514
|
+
const middleString = `4${padToLength(middle.toString(16), '0', 3)}`;
|
|
515
|
+
const lowerString = padToLength((BigInt('0x8000000000000000') | BigInt(lower)).toString(16), '0', 16);
|
|
516
|
+
const uuid = upperString + middleString + lowerString;
|
|
517
|
+
return assertIsStableId(`${uuid.substr(0, 8)}-${uuid.substr(8, 4)}-${uuid.substr(12, 4)}-${uuid.substr(16, 4)}-${uuid.substr(20)}`);
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Pads the strings to a length of 32 with zeroes.
|
|
521
|
+
*/
|
|
522
|
+
export function padToUuidLength(str) {
|
|
523
|
+
return padToLength(str, '0', 32);
|
|
524
|
+
}
|
|
525
|
+
function padToLength(str, char, length) {
|
|
526
|
+
return char.repeat(length - str.length) + str;
|
|
527
|
+
}
|
|
528
|
+
//# sourceMappingURL=IdCompressorTestUtilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdCompressorTestUtilities.js","sourceRoot":"","sources":["../../../src/test/utilities/IdCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAa,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,YAAY,EAAqB,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EAEjB,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAOrD,2CAA2C;AAC3C,MAAM,CAAN,IAAY,MAIX;AAJD,WAAY,MAAM;IACjB,6BAAmB,CAAA;IACnB,6BAAmB,CAAA;IACnB,6BAAmB,CAAA;AACpB,CAAC,EAJW,MAAM,KAAN,MAAM,QAIjB;AAED,mEAAmE;AACnE,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,6CAA2B,CAAA;AAC5B,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAED,2CAA2C;AAC3C,MAAM,CAAN,IAAY,UAEX;AAFD,WAAY,UAAU;IACrB,yBAAW,CAAA;AACZ,CAAC,EAFW,UAAU,KAAV,UAAU,QAErB;A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IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;IACpE,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IACtG,MAAM,IAAI,GAAG,WAAW,GAAG,YAAY,GAAG,WAAW,CAAC;IACtD,OAAO,gBAAgB,CACtB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAC1G,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IAC1C,OAAO,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,IAAY,EAAE,MAAc;IAC7D,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC;AAC/C,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 { v5 } from 'uuid';\nimport Prando from 'prando';\nimport { expect } from 'chai';\nimport { Serializable } from '@fluidframework/datastore-definitions';\nimport { assert, assertNotUndefined, ClosedMap, fail, getOrCreate } from '../../Common';\nimport { IdCompressor, IdRangeDescriptor, isLocalId } from '../../id-compressor/IdCompressor';\nimport {\n\tassertIsStableId,\n\tcreateSessionId,\n\tensureSessionUuid,\n\tNumericUuid,\n\tnumericUuidFromStableId,\n\tstableIdFromNumericUuid,\n} from '../../id-compressor/NumericUuid';\nimport { FinalCompressedId, SessionId, StableId, SessionSpaceCompressedId } from '../../Identifiers';\nimport { getIds } from '../../id-compressor/IdRange';\nimport type {\n\tIdCreationRange,\n\tSerializedIdCompressorWithOngoingSession,\n\tSerializedIdCompressorWithNoSession,\n} from '../../id-compressor';\n\n/** Identifies a compressor in a network */\nexport enum Client {\n\tClient1 = 'Client1',\n\tClient2 = 'Client2',\n\tClient3 = 'Client3',\n}\n\n/** Identifies a compressor with respect to a specific operation */\nexport enum SemanticClient {\n\tLocalClient = 'LocalClient',\n}\n\n/** Identifies categories of compressors */\nexport enum MetaClient {\n\tAll = 'All',\n}\n\n/**\n * Used to attribute actions to clients in a distributed collaboration session.\n * `Local` implies a local and unsequenced operation. All others imply sequenced operations.\n */\nexport type OriginatingClient = Client | SemanticClient;\nexport const OriginatingClient = { ...Client, ...SemanticClient };\n\n/** Identifies a compressor to which to send an operation */\nexport type DestinationClient = Client | MetaClient;\nexport const DestinationClient = { ...Client, ...MetaClient };\n\n/**\n * Creates a new compressor with the supplied cluster capacity.\n */\nexport function createCompressor<T>(\n\tclient: Client,\n\tclusterCapacity = 5,\n\tattributionInfo?: Serializable<T>\n): IdCompressor {\n\tconst compressor = new IdCompressor(sessionIds.get(client), 1024, attributionInfo);\n\tcompressor.clusterCapacity = clusterCapacity;\n\treturn compressor;\n}\n\n/**\n * A closed map from NamedClient to T.\n */\nexport type ClientMap<T> = ClosedMap<Client, T>;\n\nfunction makeSessionIds(): ClientMap<SessionId> {\n\tconst stableIds = new Map<Client, SessionId>();\n\tconst clients = Object.values(Client);\n\tfor (let i = 0; i < clients.length; i++) {\n\t\t// Place session uuids roughly in the middle of uuid space to increase odds of encountering interesting\n\t\t// orderings in sorted collections\n\t\tconst sessionId = ensureSessionUuid(assertIsStableId(`88888888-8888-4888-b${i}88-888888888888`));\n\t\tstableIds.set(clients[i], sessionId);\n\t}\n\treturn stableIds as ClientMap<SessionId>;\n}\n\n/**\n * An array of session ID strings corresponding to all non-local `Client` entries.\n */\nexport const sessionIds = makeSessionIds();\n\n/**\n * An array of session uuids corresponding to all non-local `Client` entries.\n */\nexport const sessionNumericUuids = new Map(\n\t[...sessionIds.entries()].map(([client, sessionId]) => {\n\t\treturn [client, numericUuidFromStableId(sessionId)];\n\t})\n) as ClientMap<NumericUuid>;\n\n/** An immutable view of an `IdCompressor` */\nexport interface ReadonlyIdCompressor\n\textends Omit<\n\t\tIdCompressor,\n\t\t'generateCompressedId' | 'generateCompressedIdRange' | 'takeNextCreationRange' | 'finalizeCreationRange'\n\t> {\n\treadonly clusterCapacity: number;\n}\n\n/** Information about a generated ID in a network to be validated by tests */\nexport interface TestIdData {\n\treadonly id: SessionSpaceCompressedId;\n\treadonly originatingClient: Client;\n\treadonly sessionId: SessionId;\n\treadonly sessionNumericUuid: NumericUuid;\n\treadonly expectedOverride: string | undefined;\n\treadonly isSequenced: boolean;\n}\n\n/**\n * Simulates a network of ID compressors.\n * Not suitable for performance testing.\n */\nexport class IdCompressorTestNetwork {\n\t/** The compressors used in this network */\n\tprivate readonly compressors: ClientMap<IdCompressor>;\n\t/** The log of operations seen by the server so far. Append-only. */\n\tprivate readonly serverOperations: ([range: IdCreationRange, clientFrom: Client] | number)[] = [];\n\t/** An index into `serverOperations` for each client which represents how many operations have been delivered to that client */\n\tprivate readonly clientProgress: ClientMap<number>;\n\t/** All ids (local and sequenced) that a client has created or received, in order. */\n\tprivate readonly idLogs: ClientMap<TestIdData[]>;\n\t/** All ids that a client has received from the server, in order. */\n\tprivate readonly sequencedIdLogs: ClientMap<TestIdData[]>;\n\n\tpublic constructor(\n\t\tpublic readonly initialClusterSize = 5,\n\t\tprivate readonly onIdReceived?: (network: IdCompressorTestNetwork, clientTo: Client, ids: TestIdData[]) => void\n\t) {\n\t\tconst compressors = new Map<Client, IdCompressor>();\n\t\tconst clientProgress = new Map<Client, number>();\n\t\tconst clientIds = new Map<Client, TestIdData[]>();\n\t\tconst clientSequencedIds = new Map<Client, TestIdData[]>();\n\t\tfor (const client of Object.values(Client)) {\n\t\t\tconst compressor = createCompressor(client, initialClusterSize, client);\n\t\t\tcompressors.set(client, compressor);\n\t\t\tclientProgress.set(client, 0);\n\t\t\tclientIds.set(client, []);\n\t\t\tclientSequencedIds.set(client, []);\n\t\t}\n\t\tthis.compressors = compressors as ClientMap<IdCompressor>;\n\t\tthis.clientProgress = clientProgress as ClientMap<number>;\n\t\tthis.idLogs = clientIds as ClientMap<TestIdData[]>;\n\t\tthis.sequencedIdLogs = clientSequencedIds as ClientMap<TestIdData[]>;\n\t}\n\n\t/**\n\t * Returns an immutable handle to a compressor in the network.\n\t */\n\tpublic getCompressor(client: Client): ReadonlyIdCompressor {\n\t\tconst compressors = this.compressors;\n\t\tconst handler = {\n\t\t\tget(_, property) {\n\t\t\t\tconst compressor = compressors.get(client);\n\t\t\t\treturn compressor[property];\n\t\t\t},\n\t\t\tset(_, property, value): boolean {\n\t\t\t\tconst compressor = compressors.get(client);\n\t\t\t\tcompressor[property] = value;\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\t\treturn new Proxy<IdCompressor>({} as unknown as IdCompressor, handler);\n\t}\n\n\t/**\n\t * Returns a mutable handle to a compressor in the network. Use of mutation methods will break the network invariants and\n\t * should only be used if the network will not be used again.\n\t */\n\tpublic getCompressorUnsafe(client: Client): IdCompressor {\n\t\treturn this.getCompressor(client) as IdCompressor;\n\t}\n\n\t/**\n\t * Returns data for all IDs created and received by this client, including ack's of their own (i.e. their own IDs will appear twice)\n\t */\n\tpublic getIdLog(client: Client): readonly TestIdData[] {\n\t\treturn this.idLogs.get(client);\n\t}\n\n\t/**\n\t * Returns data for all IDs received by this client, including ack's of their own (i.e. their own IDs will appear twice)\n\t */\n\tpublic getSequencedIdLog(client: Client): readonly TestIdData[] {\n\t\treturn this.sequencedIdLogs.get(client);\n\t}\n\n\t/**\n\t * Get all compressors for the given destination\n\t */\n\tpublic getTargetCompressors(clientTo: DestinationClient): [Client, IdCompressor][] {\n\t\treturn clientTo === MetaClient.All\n\t\t\t? [...this.compressors.entries()]\n\t\t\t: ([[clientTo, this.getCompressor(clientTo)]] as [Client, IdCompressor][]);\n\t}\n\n\t/**\n\t * Submit a capacity change operation to the network. It will not take effect immediately but will be processed in sequence order.\n\t */\n\tpublic enqueueCapacityChange(newClusterCapacity: number): void {\n\t\tthis.serverOperations.push(newClusterCapacity);\n\t}\n\n\tprivate addNewId(\n\t\tclient: Client,\n\t\tid: SessionSpaceCompressedId,\n\t\texpectedOverride: string | undefined,\n\t\toriginatingClient: Client,\n\t\tisSequenced: boolean\n\t): void {\n\t\tconst idData = {\n\t\t\tid,\n\t\t\toriginatingClient,\n\t\t\tsessionId: sessionIds.get(originatingClient),\n\t\t\tsessionNumericUuid: sessionNumericUuids.get(originatingClient),\n\t\t\texpectedOverride,\n\t\t\tisSequenced,\n\t\t};\n\t\tconst clientIds = this.idLogs.get(client);\n\t\tclientIds.push(idData);\n\t\tif (isSequenced) {\n\t\t\tconst sequencedIds = this.sequencedIdLogs.get(client);\n\t\t\tsequencedIds.push(idData);\n\t\t}\n\t\tthis.onIdReceived?.(this, client, clientIds);\n\t}\n\n\t/**\n\t * Allocates a new range of local IDs and enqueues them for future delivery via a `testIdDelivery` action.\n\t * Calls to this method determine the total order of delivery, regardless of when `deliverOperations` is called.\n\t */\n\tpublic allocateAndSendIds(\n\t\tclient: Client,\n\t\tnumIds: number\n\t): { range: IdRangeDescriptor<SessionSpaceCompressedId>; sessionId: SessionId };\n\n\t/**\n\t * Allocates a new range of local IDs and enqueues them for future delivery via a `testIdDelivery` action.\n\t * Calls to this method determine the total order of delivery, regardless of when `deliverOperations` is called.\n\t */\n\tpublic allocateAndSendIds(client: Client, numIds: number, overrides: { [index: number]: string }): IdCreationRange;\n\n\tpublic allocateAndSendIds(\n\t\tclient: Client,\n\t\tnumIds: number,\n\t\toverrides: { [index: number]: string } = {}\n\t): { range: IdRangeDescriptor<SessionSpaceCompressedId>; sessionId: SessionId } | IdCreationRange {\n\t\tassert(numIds > 0, 'Must allocate a non-zero number of IDs');\n\t\tconst compressor = this.compressors.get(client);\n\t\tlet nextIdIndex = 0;\n\t\tfor (const [overrideIndex, uuid] of Object.entries(overrides)\n\t\t\t.map(([id, uuid]) => [Number.parseInt(id, 10), uuid] as [number, string])\n\t\t\t.sort(([a], [b]) => a - b)) {\n\t\t\twhile (nextIdIndex < overrideIndex) {\n\t\t\t\tthis.addNewId(client, compressor.generateCompressedId(), undefined, client, false);\n\t\t\t\tnextIdIndex += 1;\n\t\t\t}\n\t\t\tthis.addNewId(client, compressor.generateCompressedId(uuid), uuid, client, false);\n\t\t\tnextIdIndex += 1;\n\t\t}\n\t\tconst numTrailingIds = numIds - nextIdIndex;\n\t\tlet range: IdRangeDescriptor<SessionSpaceCompressedId> | undefined;\n\t\tif (numTrailingIds > 0) {\n\t\t\trange = compressor.generateCompressedIdRange(numTrailingIds);\n\t\t\tconst ids = compressor.getIdsFromRange(range, compressor.localSessionId);\n\t\t\tfor (let i = 0; i < numTrailingIds; i++) {\n\t\t\t\tthis.addNewId(client, ids.get(i), undefined, client, false);\n\t\t\t}\n\t\t}\n\t\tconst creationRange = compressor.takeNextCreationRange();\n\t\tthis.serverOperations.push([creationRange, client]);\n\t\treturn nextIdIndex === 0 ? { range: range ?? fail(), sessionId: compressor.localSessionId } : creationRange;\n\t}\n\n\t/**\n\t * Delivers all undelivered ID ranges and cluster capacity changes from the server to the target clients.\n\t */\n\tpublic deliverOperations(clientTakingDelivery: DestinationClient) {\n\t\tfor (const [clientTo, compressorTo] of this.getTargetCompressors(clientTakingDelivery)) {\n\t\t\tfor (let i = this.clientProgress.get(clientTo); i < this.serverOperations.length; i++) {\n\t\t\t\tconst operation = this.serverOperations[i];\n\t\t\t\tif (typeof operation === 'number') {\n\t\t\t\t\tcompressorTo.clusterCapacity = operation;\n\t\t\t\t} else {\n\t\t\t\t\tconst [range, clientFrom] = operation;\n\t\t\t\t\tcompressorTo.finalizeCreationRange(range);\n\n\t\t\t\t\tconst ids = getIds(range);\n\t\t\t\t\tif (ids !== undefined) {\n\t\t\t\t\t\tlet overrideIndex = 0;\n\t\t\t\t\t\tconst overrides = ids.overrides;\n\t\t\t\t\t\tfor (let id = ids.first; id >= ids.last; id--) {\n\t\t\t\t\t\t\tlet override: string | undefined;\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\toverrides !== undefined &&\n\t\t\t\t\t\t\t\toverrideIndex < overrides.length &&\n\t\t\t\t\t\t\t\tid === overrides[overrideIndex][0]\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\toverride = overrides[overrideIndex][1];\n\t\t\t\t\t\t\t\toverrideIndex++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst sessionSpaceId = compressorTo.normalizeToSessionSpace(id, range.sessionId);\n\t\t\t\t\t\t\tthis.addNewId(clientTo, sessionSpaceId, override, clientFrom, true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tassert(overrideIndex === (overrides?.length ?? 0));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.clientProgress.set(clientTo, this.serverOperations.length);\n\t\t}\n\t}\n\n\t/**\n\t * Simulate a client disconnecting (and serializing), then reconnecting (and deserializing)\n\t */\n\tpublic goOfflineThenResume(client: Client): void {\n\t\tconst compressor = this.compressors.get(client);\n\t\tconst [_, resumedCompressor] = roundtrip(compressor, true);\n\t\tthis.compressors.set(client, resumedCompressor);\n\t}\n\n\t/**\n\t * Ensure general validity of the network state. Useful for calling periodically or at the end of test scenarios.\n\t */\n\tpublic assertNetworkState(): void {\n\t\tconst sequencedLogs = Object.values(Client).map(\n\t\t\t(client) => [this.compressors.get(client), this.getSequencedIdLog(client)] as [IdCompressor, TestIdData[]]\n\t\t);\n\n\t\tconst maxLogLength = sequencedLogs.map(([_, data]) => data.length).reduce((p, n) => Math.max(p, n));\n\n\t\tfunction getNextLogWithEntryAt(logsIndex: number, entryIndex: number): number | undefined {\n\t\t\tfor (let i = logsIndex; i < sequencedLogs.length; i++) {\n\t\t\t\tconst log = sequencedLogs[i];\n\t\t\t\tif (log[1].length > entryIndex) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst uuids = new Set<string>();\n\t\tconst finalIds = new Set<FinalCompressedId>();\n\t\tconst idIndicesAggregator = new Map<Client, number>();\n\n\t\tfunction* getLogIndices(\n\t\t\tcolumnIndex: number\n\t\t): Iterable<\n\t\t\t[\n\t\t\t\tcurrent: [compressor: IdCompressor, idData: TestIdData],\n\t\t\t\tnext?: [compressor: IdCompressor, idData: TestIdData]\n\t\t\t]\n\t\t> {\n\t\t\tlet current = getNextLogWithEntryAt(0, columnIndex);\n\t\t\twhile (current !== undefined) {\n\t\t\t\tconst next = getNextLogWithEntryAt(current + 1, columnIndex);\n\t\t\t\tconst [compressor, log] = sequencedLogs[current];\n\t\t\t\tif (next === undefined) {\n\t\t\t\t\tyield [[compressor, log[columnIndex]]];\n\t\t\t\t} else {\n\t\t\t\t\tconst [compressorNext, logNext] = sequencedLogs[next];\n\t\t\t\t\tyield [\n\t\t\t\t\t\t[compressor, log[columnIndex]],\n\t\t\t\t\t\t[compressorNext, logNext[columnIndex]],\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tcurrent = next;\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0; i < maxLogLength; i++) {\n\t\t\tconst creator: [creator: Client, override?: string][] = [];\n\t\t\tlet originatingClient: Client | undefined;\n\t\t\tlet localCount = 0;\n\t\t\tlet rowCount = 0;\n\t\t\tfor (const [current, next] of getLogIndices(i)) {\n\t\t\t\tconst [compressorA, idDataA] = current;\n\t\t\t\tconst sessionSpaceIdA = idDataA.id;\n\t\t\t\tif (isLocalId(sessionSpaceIdA)) {\n\t\t\t\t\tlocalCount += 1;\n\t\t\t\t}\n\t\t\t\tconst idIndex = getOrCreate(idIndicesAggregator, idDataA.originatingClient, () => 0);\n\t\t\t\toriginatingClient ??= idDataA.originatingClient;\n\t\t\t\tassert(\n\t\t\t\t\tidDataA.originatingClient === originatingClient,\n\t\t\t\t\t'Test infra gave wrong originating client to TestIdData'\n\t\t\t\t);\n\n\t\t\t\t// Only one client should have this ID as local in its session space, as only one client could have created this ID\n\t\t\t\tif (isLocalId(sessionSpaceIdA)) {\n\t\t\t\t\tlocalCount++;\n\t\t\t\t\texpect(idDataA.sessionId).to.equal(this.compressors.get(originatingClient).localSessionId);\n\t\t\t\t\texpect(creator.length === 0 || creator[creator.length - 1][1] === idDataA.expectedOverride).to.be\n\t\t\t\t\t\t.true;\n\t\t\t\t\tcreator.push([originatingClient, idDataA.expectedOverride]);\n\t\t\t\t}\n\n\t\t\t\tconst uuidASessionSpace = compressorA.decompress(sessionSpaceIdA);\n\t\t\t\tif (idDataA.expectedOverride !== undefined) {\n\t\t\t\t\texpect(uuidASessionSpace).to.equal(idDataA.expectedOverride);\n\t\t\t\t} else {\n\t\t\t\t\texpect(uuidASessionSpace).to.equal(stableIdFromNumericUuid(idDataA.sessionNumericUuid, idIndex));\n\t\t\t\t}\n\t\t\t\texpect(compressorA.recompress(uuidASessionSpace)).to.equal(sessionSpaceIdA);\n\t\t\t\tuuids.add(uuidASessionSpace);\n\t\t\t\tconst opSpaceIdA = compressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\tif (isLocalId(opSpaceIdA)) {\n\t\t\t\t\texpect.fail('IDs should have been finalized.');\n\t\t\t\t}\n\t\t\t\t// TODO: This cast can be removed on typescript 4.6\n\t\t\t\tfinalIds.add(opSpaceIdA as FinalCompressedId);\n\t\t\t\tconst uuidAOpSpace = compressorA.decompress(opSpaceIdA);\n\n\t\t\t\texpect(uuidASessionSpace).to.equal(uuidAOpSpace);\n\n\t\t\t\tif (next !== undefined) {\n\t\t\t\t\tconst [compressorB, idDataB] = next;\n\t\t\t\t\tconst sessionSpaceIdB = idDataB.id;\n\n\t\t\t\t\tconst uuidBSessionSpace = compressorB.decompress(sessionSpaceIdB);\n\t\t\t\t\texpect(uuidASessionSpace).to.equal(uuidBSessionSpace);\n\t\t\t\t\tconst opSpaceIdB = compressorB.normalizeToOpSpace(sessionSpaceIdB);\n\t\t\t\t\tif (opSpaceIdA !== opSpaceIdB) {\n\t\t\t\t\t\tcompressorB.normalizeToOpSpace(sessionSpaceIdB);\n\t\t\t\t\t\tcompressorA.normalizeToOpSpace(sessionSpaceIdA);\n\t\t\t\t\t}\n\t\t\t\t\texpect(opSpaceIdA).to.equal(opSpaceIdB);\n\t\t\t\t\tif (isLocalId(opSpaceIdB)) {\n\t\t\t\t\t\tfail('IDs should have been finalized.');\n\t\t\t\t\t}\n\t\t\t\t\tconst uuidBOpSpace = compressorB.decompress(opSpaceIdB);\n\t\t\t\t\texpect(uuidAOpSpace).to.equal(uuidBOpSpace);\n\t\t\t\t}\n\n\t\t\t\trowCount += 1;\n\t\t\t}\n\n\t\t\t// A local count > 1 indicates that this ID was unified, as more than one client has a local ID for it\n\t\t\t// in their session space.\n\t\t\tif (rowCount === this.sequencedIdLogs.size && localCount <= 1) {\n\t\t\t\texpect(localCount).to.equal(1);\n\t\t\t\tfor (const [[compressor, { id, originatingClient }]] of getLogIndices(i)) {\n\t\t\t\t\texpect(compressor.attributeId(id)).to.equal(originatingClient);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\texpect(uuids.size).to.equal(finalIds.size);\n\t\t\tassert(originatingClient !== undefined);\n\t\t\tidIndicesAggregator.set(\n\t\t\t\toriginatingClient,\n\t\t\t\tassertNotUndefined(idIndicesAggregator.get(originatingClient)) + 1\n\t\t\t);\n\t\t}\n\n\t\tfor (const [compressor] of sequencedLogs) {\n\t\t\texpectSerializes(compressor);\n\t\t}\n\t}\n}\n\n/**\n * Roundtrips the supplied compressor through serialization and deserialization.\n */\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: true\n): [SerializedIdCompressorWithOngoingSession, IdCompressor];\n\n/**\n * Roundtrips the supplied compressor through serialization and deserialization.\n */\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: false\n): [SerializedIdCompressorWithNoSession, IdCompressor];\n\nexport function roundtrip(\n\tcompressor: ReadonlyIdCompressor,\n\twithSession: boolean\n): [SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession, IdCompressor] {\n\tif (withSession) {\n\t\tconst serialized = compressor.serialize(withSession);\n\t\treturn [serialized, IdCompressor.deserialize(serialized)];\n\t}\n\n\tconst nonLocalSerialized = compressor.serialize(withSession);\n\treturn [nonLocalSerialized, IdCompressor.deserialize(nonLocalSerialized, createSessionId())];\n}\n\n/**\n * Asserts that the supplied compressor correctly roundtrips through serialization/deserialization.\n */\nexport function expectSerializes(\n\tcompressor: ReadonlyIdCompressor\n): [SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession] {\n\tfunction expectSerializes(\n\t\twithSession: boolean\n\t): SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession {\n\t\tlet serialized: SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession;\n\t\tlet deserialized: IdCompressor;\n\t\tif (withSession) {\n\t\t\t[serialized, deserialized] = roundtrip(compressor, true);\n\t\t} else {\n\t\t\t[serialized, deserialized] = roundtrip(compressor, false);\n\t\t}\n\t\tconst chainCount: number[] = [];\n\t\tfor (let i = 0; i < serialized.sessions.length; i++) {\n\t\t\tchainCount[i] = 0;\n\t\t}\n\t\tconst chainProcessed: number[] = [...chainCount];\n\n\t\tfor (const cluster of serialized.clusters) {\n\t\t\tconst [sessionIndex] = cluster;\n\t\t\texpect(sessionIndex < serialized.sessions.length);\n\t\t\tchainCount[sessionIndex]++;\n\t\t}\n\n\t\tfor (const cluster of serialized.clusters) {\n\t\t\tconst [sessionIndex, capacity, maybeSize] = cluster;\n\t\t\tconst chainIndex = chainProcessed[sessionIndex];\n\t\t\tif (chainIndex < chainCount[sessionIndex] - 1) {\n\t\t\t\texpect(maybeSize === undefined);\n\t\t\t} else {\n\t\t\t\texpect(maybeSize === undefined || typeof maybeSize !== 'number' || maybeSize < capacity);\n\t\t\t}\n\t\t\tchainProcessed[sessionIndex]++;\n\t\t}\n\n\t\texpect(compressor.equals(deserialized, withSession)).to.be.true;\n\t\treturn serialized;\n\t}\n\n\treturn [\n\t\texpectSerializes(false) as SerializedIdCompressorWithNoSession,\n\t\texpectSerializes(true) as SerializedIdCompressorWithOngoingSession,\n\t];\n}\n\n/**\n * Merges 'from' into 'to', and returns 'to'.\n */\nexport function mergeArrayMaps<K, V>(\n\tto: Pick<Map<K, V[]>, 'get' | 'set'>,\n\tfrom: ReadonlyMap<K, V[]>\n): Pick<Map<K, V[]>, 'get' | 'set'> {\n\tfor (const [key, value] of from.entries()) {\n\t\tconst entry = to.get(key);\n\t\tif (entry !== undefined) {\n\t\t\tentry.push(...value);\n\t\t} else {\n\t\t\tto.set(key, [...value]);\n\t\t}\n\t}\n\treturn to;\n}\n\nenum Operation {\n\tAllocateIds,\n\tDeliverOperations,\n\tChangeCapacity,\n\tGenerateUnifyingIds,\n\tGoOfflineThenResume,\n}\n\n/**\n * Performs random actions on a test network.\n * @param network the test network to test\n * @param seed the seed for the random generation of the fuzz actions\n * @param includeOverrides whether or not the fuzz actions will generate override UUIDs\n * @param observerClient if provided, this client will never generate local ids\n * @param synchronizeAtEnd if provided, all client will have all operations delivered from the server at the end of the test\n * @param numUsages if provided, the number of operations to perform as part of this test. Defaults to 1000.\n * @param validator if provided, this callback will be invoked periodically during the fuzz test.\n */\nexport function performFuzzActions(\n\tnetwork: IdCompressorTestNetwork,\n\tseed: number,\n\tincludeOverrides: boolean,\n\tobserverClient?: Client,\n\tsynchronizeAtEnd: boolean = true,\n\tnumUsages = 1000,\n\tmaxClusterSize = 25,\n\tvalidator?: (network: IdCompressorTestNetwork) => void\n): void {\n\tconst rand = new Prando(seed);\n\tconst selectableClients: Client[] = network.getTargetCompressors(MetaClient.All).map(([client]) => client);\n\tconst activeClients = selectableClients.filter((c) => c !== observerClient);\n\t// Ensure that the same UUIDs are generated for the same seed across different calls\n\tlet uuidNum = 0;\n\tconst uuidNamespace = 'ece2be2e-f374-4ca8-b034-a0bac2da69da';\n\tlet clusterSize: number = network.initialClusterSize;\n\tif (clusterSize > maxClusterSize) {\n\t\tnetwork.enqueueCapacityChange(maxClusterSize);\n\t\tclusterSize = maxClusterSize;\n\t}\n\n\tconst opWeights: [Operation, number][] = [\n\t\t[Operation.ChangeCapacity, 1],\n\t\t[Operation.AllocateIds, 8],\n\t\t[Operation.DeliverOperations, 4],\n\t\t[Operation.GenerateUnifyingIds, 1],\n\t\t[Operation.GoOfflineThenResume, 1],\n\t];\n\n\tconst opSums: [Operation, number][] = [];\n\tlet prevWeight = 0;\n\tfor (const opWeight of opWeights) {\n\t\tconst weight = prevWeight + opWeight[1];\n\t\topSums.push([opWeight[0], weight]);\n\t\tprevWeight = weight;\n\t}\n\n\tfor (let i = 0; i < numUsages; i++) {\n\t\tconst weightSelected = rand.nextInt(1, prevWeight);\n\t\tlet opIndex = 0;\n\t\twhile (weightSelected > opSums[opIndex][1]) {\n\t\t\topIndex++;\n\t\t}\n\t\tconst operation = opWeights[opIndex][0];\n\t\tswitch (operation) {\n\t\t\tcase Operation.ChangeCapacity: {\n\t\t\t\tclusterSize = Math.min(Math.floor(rand.next(0, 1) ** 2 * maxClusterSize) + 1, maxClusterSize);\n\t\t\t\tnetwork.enqueueCapacityChange(clusterSize);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Operation.AllocateIds: {\n\t\t\t\tconst client = rand.nextArrayItem(activeClients);\n\t\t\t\tconst maxIdsPerUsage = clusterSize * 2;\n\t\t\t\tconst numIds = Math.floor(rand.next(0, 1) ** 2 * maxIdsPerUsage) + 1;\n\t\t\t\tconst overrides: { [index: number]: string } = {};\n\t\t\t\tif (includeOverrides && /* 25% chance: */ rand.nextInt(0, 3) === 0) {\n\t\t\t\t\tfor (let j = 0; j < numIds; j++) {\n\t\t\t\t\t\tif (/* 33% chance: */ rand.nextInt(0, 2) === 0) {\n\t\t\t\t\t\t\toverrides[j] = v5((uuidNum++).toString(), uuidNamespace);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnetwork.allocateAndSendIds(client, numIds, overrides);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Operation.DeliverOperations: {\n\t\t\t\tconst client = rand.nextArrayItem([...selectableClients, MetaClient.All]);\n\t\t\t\tnetwork.deliverOperations(client);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Operation.GenerateUnifyingIds: {\n\t\t\t\tconst clientA = rand.nextArrayItem(activeClients);\n\t\t\t\tconst clientB = rand.nextArrayItem(activeClients.filter((c) => c !== clientA));\n\t\t\t\tconst uuid = v5((uuidNum++).toString(), uuidNamespace);\n\t\t\t\tnetwork.allocateAndSendIds(clientA, 1, { 0: uuid });\n\t\t\t\tnetwork.allocateAndSendIds(clientB, 1, { 0: uuid });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Operation.GoOfflineThenResume: {\n\t\t\t\tconst client = rand.nextArrayItem(activeClients);\n\t\t\t\tnetwork.goOfflineThenResume(client);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error('Unknown operation.');\n\t\t}\n\t\tif (i !== 0 && i % Math.round(numUsages / 5) === 0) {\n\t\t\tvalidator?.(network);\n\t\t}\n\t}\n\n\tif (synchronizeAtEnd) {\n\t\tnetwork.deliverOperations(DestinationClient.All);\n\t\tvalidator?.(network);\n\t}\n}\n\n/**\n * Converts the supplied integer to a uuid.\n */\nexport function integerToStableId(num: number | bigint): StableId {\n\tconst bigintNum = BigInt(num);\n\tconst upper = bigintNum >> BigInt(74);\n\tconst middle = (bigintNum & (BigInt(0xfff) << BigInt(62))) >> BigInt(62);\n\tconst lower = bigintNum & BigInt('0x3fffffffffffffff');\n\tconst upperString = padToLength(upper.toString(16), '0', 12);\n\tconst middleString = `4${padToLength(middle.toString(16), '0', 3)}`;\n\tconst lowerString = padToLength((BigInt('0x8000000000000000') | BigInt(lower)).toString(16), '0', 16);\n\tconst uuid = upperString + middleString + lowerString;\n\treturn assertIsStableId(\n\t\t`${uuid.substr(0, 8)}-${uuid.substr(8, 4)}-${uuid.substr(12, 4)}-${uuid.substr(16, 4)}-${uuid.substr(20)}`\n\t);\n}\n\n/**\n * Pads the strings to a length of 32 with zeroes.\n */\nexport function padToUuidLength(str: string): string {\n\treturn padToLength(str, '0', 32);\n}\n\nfunction padToLength(str: string, char: string, length: number): string {\n\treturn char.repeat(length - str.length) + str;\n}\n"]}
|