@fluidframework/tree 2.116.1 → 2.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +202 -0
- package/api-report/tree.alpha.api.md +122 -31
- package/api-report/tree.beta.api.md +50 -9
- package/api-report/tree.legacy.beta.api.md +50 -9
- package/dist/codec/codec.d.ts +18 -0
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +18 -0
- package/dist/codec/codec.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +1 -1
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +2 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +39 -2
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +37 -2
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/rebase/utils.d.ts.map +1 -1
- package/dist/core/rebase/utils.js +1 -0
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/revertible.d.ts +62 -6
- package/dist/core/revertible.d.ts.map +1 -1
- package/dist/core/revertible.js.map +1 -1
- package/dist/entrypoints/alpha.d.ts +1 -1
- package/dist/entrypoints/alpha.d.ts.map +1 -1
- package/dist/entrypoints/alpha.js.map +1 -1
- package/dist/entrypoints/beta.d.ts +1 -1
- package/dist/entrypoints/beta.d.ts.map +1 -1
- package/dist/entrypoints/beta.js.map +1 -1
- package/dist/entrypoints/legacy.d.ts +1 -1
- package/dist/entrypoints/legacy.d.ts.map +1 -1
- package/dist/entrypoints/legacy.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/types.d.ts +1 -1
- package/dist/feature-libraries/indexing/types.js.map +1 -1
- package/dist/feature-libraries/schemaChecker.d.ts +9 -19
- package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/schemaChecker.js +130 -46
- package/dist/feature-libraries/schemaChecker.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/history.d.ts +22 -0
- package/dist/shared-tree/history.d.ts.map +1 -0
- package/dist/shared-tree/history.js +66 -0
- package/dist/shared-tree/history.js.map +1 -0
- package/dist/shared-tree/schematizingTreeView.d.ts +24 -9
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +61 -11
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +3 -2
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +2 -0
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/tree.js +1 -1
- package/dist/shared-tree/tree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +8 -20
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +9 -12
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +16 -9
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +122 -25
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree/unhydratedTreeContext.d.ts +3 -2
- package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
- package/dist/shared-tree/unhydratedTreeContext.js +3 -0
- package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +16 -2
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +20 -2
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/branchCommitCounter.d.ts +31 -0
- package/dist/shared-tree-core/branchCommitCounter.d.ts.map +1 -0
- package/dist/shared-tree-core/branchCommitCounter.js +79 -0
- package/dist/shared-tree-core/branchCommitCounter.js.map +1 -0
- package/dist/shared-tree-core/customMetadataCodec.d.ts +9 -0
- package/dist/shared-tree-core/customMetadataCodec.d.ts.map +1 -0
- package/dist/shared-tree-core/customMetadataCodec.js +37 -0
- package/dist/shared-tree-core/customMetadataCodec.js.map +1 -0
- package/dist/shared-tree-core/customMetadataFormat.d.ts +18 -0
- package/dist/shared-tree-core/customMetadataFormat.d.ts.map +1 -0
- package/dist/shared-tree-core/customMetadataFormat.js +15 -0
- package/dist/shared-tree-core/customMetadataFormat.js.map +1 -0
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +15 -3
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +5 -0
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.js +17 -5
- package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js +4 -2
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +17 -6
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +18 -8
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +7 -5
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.js +4 -3
- package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +4 -0
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.js +2 -2
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +2 -1
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +3 -1
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js +12 -3
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js +8 -2
- package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +5 -0
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/messageFormat.d.ts +1 -0
- package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormat.js +6 -0
- package/dist/shared-tree-core/messageFormat.js.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +10 -3
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js +10 -2
- package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -0
- package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormatVSharedBranches.js +2 -0
- package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +4 -2
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +9 -0
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +26 -4
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +4 -4
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.d.ts +36 -3
- package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/dist/simple-tree/api/discrepancies.js +40 -14
- package/dist/simple-tree/api/discrepancies.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +3 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +3 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +22 -3
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js +140 -10
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts +28 -2
- package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/dist/simple-tree/api/transactionTypes.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +353 -68
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/core/toStored.d.ts +7 -0
- package/dist/simple-tree/core/toStored.d.ts.map +1 -1
- package/dist/simple-tree/core/toStored.js.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.js +2 -2
- package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
- package/dist/simple-tree/index.d.ts +1 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +4 -3
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/tableSchema.js +10 -10
- package/dist/tableSchema.js.map +1 -1
- package/docs/main/glossary.md +163 -0
- package/lib/codec/codec.d.ts +18 -0
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +18 -0
- package/lib/codec/codec.js.map +1 -1
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/index.d.ts +1 -1
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +39 -2
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +35 -1
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +1 -0
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/revertible.d.ts +62 -6
- package/lib/core/revertible.d.ts.map +1 -1
- package/lib/core/revertible.js.map +1 -1
- package/lib/entrypoints/alpha.d.ts +1 -1
- package/lib/entrypoints/alpha.d.ts.map +1 -1
- package/lib/entrypoints/alpha.js.map +1 -1
- package/lib/entrypoints/beta.d.ts +1 -1
- package/lib/entrypoints/beta.d.ts.map +1 -1
- package/lib/entrypoints/beta.js.map +1 -1
- package/lib/entrypoints/legacy.d.ts +1 -1
- package/lib/entrypoints/legacy.d.ts.map +1 -1
- package/lib/entrypoints/legacy.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/types.d.ts +1 -1
- package/lib/feature-libraries/indexing/types.js.map +1 -1
- package/lib/feature-libraries/schemaChecker.d.ts +9 -19
- package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/schemaChecker.js +133 -49
- package/lib/feature-libraries/schemaChecker.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/history.d.ts +22 -0
- package/lib/shared-tree/history.d.ts.map +1 -0
- package/lib/shared-tree/history.js +62 -0
- package/lib/shared-tree/history.js.map +1 -0
- package/lib/shared-tree/schematizingTreeView.d.ts +24 -9
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +62 -12
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +3 -2
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +2 -0
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/tree.js +1 -1
- package/lib/shared-tree/tree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +8 -20
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +9 -12
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +16 -9
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +123 -26
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree/unhydratedTreeContext.d.ts +3 -2
- package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
- package/lib/shared-tree/unhydratedTreeContext.js +3 -0
- package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +16 -2
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +20 -2
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/branchCommitCounter.d.ts +31 -0
- package/lib/shared-tree-core/branchCommitCounter.d.ts.map +1 -0
- package/lib/shared-tree-core/branchCommitCounter.js +75 -0
- package/lib/shared-tree-core/branchCommitCounter.js.map +1 -0
- package/lib/shared-tree-core/customMetadataCodec.d.ts +9 -0
- package/lib/shared-tree-core/customMetadataCodec.d.ts.map +1 -0
- package/lib/shared-tree-core/customMetadataCodec.js +32 -0
- package/lib/shared-tree-core/customMetadataCodec.js.map +1 -0
- package/lib/shared-tree-core/customMetadataFormat.d.ts +18 -0
- package/lib/shared-tree-core/customMetadataFormat.d.ts.map +1 -0
- package/lib/shared-tree-core/customMetadataFormat.js +11 -0
- package/lib/shared-tree-core/customMetadataFormat.js.map +1 -0
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +16 -4
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +5 -0
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.js +17 -5
- package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js +4 -2
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +17 -6
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +18 -8
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +7 -5
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.js +4 -3
- package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +4 -0
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.js +2 -2
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +2 -1
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js +1 -0
- package/lib/shared-tree-core/index.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js +12 -3
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js +8 -2
- package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +5 -0
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/messageFormat.d.ts +1 -0
- package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormat.js +6 -0
- package/lib/shared-tree-core/messageFormat.js.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +10 -3
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js +10 -2
- package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -0
- package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.js +2 -0
- package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +5 -3
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +9 -0
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +27 -5
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +4 -4
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.d.ts +36 -3
- package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/lib/simple-tree/api/discrepancies.js +40 -14
- package/lib/simple-tree/api/discrepancies.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +3 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +22 -3
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.js +136 -7
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts +28 -2
- package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/lib/simple-tree/api/transactionTypes.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +353 -68
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/core/toStored.d.ts +7 -0
- package/lib/simple-tree/core/toStored.d.ts.map +1 -1
- package/lib/simple-tree/core/toStored.js.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.js +3 -3
- package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
- package/lib/simple-tree/index.d.ts +1 -1
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/tableSchema.js +10 -10
- package/lib/tableSchema.js.map +1 -1
- package/package.json +22 -22
- package/src/codec/codec.ts +19 -0
- package/src/core/index.ts +4 -0
- package/src/core/rebase/index.ts +2 -0
- package/src/core/rebase/types.ts +72 -2
- package/src/core/rebase/utils.ts +1 -0
- package/src/core/revertible.ts +67 -6
- package/src/entrypoints/alpha.ts +11 -0
- package/src/entrypoints/beta.ts +3 -0
- package/src/entrypoints/legacy.ts +3 -0
- package/src/feature-libraries/index.ts +1 -1
- package/src/feature-libraries/indexing/types.ts +1 -1
- package/src/feature-libraries/schemaChecker.ts +198 -82
- package/src/index.ts +11 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/history.ts +99 -0
- package/src/shared-tree/schematizingTreeView.ts +100 -29
- package/src/shared-tree/sharedTree.ts +5 -2
- package/src/shared-tree/tree.ts +1 -1
- package/src/shared-tree/treeAlpha.ts +17 -35
- package/src/shared-tree/treeCheckout.ts +170 -31
- package/src/shared-tree/unhydratedTreeContext.ts +6 -2
- package/src/shared-tree-core/branch.ts +34 -2
- package/src/shared-tree-core/branchCommitCounter.ts +103 -0
- package/src/shared-tree-core/customMetadataCodec.ts +42 -0
- package/src/shared-tree-core/customMetadataFormat.ts +39 -0
- package/src/shared-tree-core/editManager.ts +22 -3
- package/src/shared-tree-core/editManagerCodecs.ts +12 -0
- package/src/shared-tree-core/editManagerCodecsCommons.ts +41 -15
- package/src/shared-tree-core/editManagerCodecsV1toV4.ts +7 -1
- package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +2 -0
- package/src/shared-tree-core/editManagerFormatCommons.ts +46 -12
- package/src/shared-tree-core/editManagerFormatV1toV4.ts +13 -5
- package/src/shared-tree-core/editManagerFormatVSharedBranches.ts +2 -2
- package/src/shared-tree-core/index.ts +3 -0
- package/src/shared-tree-core/messageCodecV1ToV4.ts +18 -5
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +9 -2
- package/src/shared-tree-core/messageCodecs.ts +12 -0
- package/src/shared-tree-core/messageFormat.ts +6 -0
- package/src/shared-tree-core/messageFormatV1ToV4.ts +21 -3
- package/src/shared-tree-core/messageFormatVSharedBranches.ts +8 -0
- package/src/shared-tree-core/sharedTreeCore.ts +5 -2
- package/src/shared-tree-core/transaction.ts +56 -4
- package/src/simple-tree/api/configuration.ts +4 -4
- package/src/simple-tree/api/discrepancies.ts +100 -5
- package/src/simple-tree/api/index.ts +12 -1
- package/src/simple-tree/api/schemaCompatibilityTester.ts +185 -11
- package/src/simple-tree/api/transactionTypes.ts +29 -2
- package/src/simple-tree/api/tree.ts +384 -68
- package/src/simple-tree/core/toStored.ts +8 -0
- package/src/simple-tree/core/treeNodeValid.ts +3 -1
- package/src/simple-tree/index.ts +9 -0
- package/src/tableSchema.ts +9 -9
- package/docs/main/runtime-schema-upgrade.md +0 -208
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
Listenable,
|
|
11
11
|
} from "@fluidframework/core-interfaces/internal";
|
|
12
12
|
import { assert, unreachableCase, fail } from "@fluidframework/core-utils/internal";
|
|
13
|
-
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
13
|
+
import type { IIdCompressor, StableId } from "@fluidframework/id-compressor";
|
|
14
14
|
import { type TelemetryLoggerExt, UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
15
15
|
|
|
16
16
|
import {
|
|
@@ -45,6 +45,9 @@ import {
|
|
|
45
45
|
visitDelta,
|
|
46
46
|
type RevertibleAlphaFactory,
|
|
47
47
|
type RevertibleAlpha,
|
|
48
|
+
type RevertOptionsAlpha,
|
|
49
|
+
type RevertToOptionsAlpha,
|
|
50
|
+
type CustomMetadataTree,
|
|
48
51
|
type GraphCommit,
|
|
49
52
|
isAncestor,
|
|
50
53
|
moveToDetachedField,
|
|
@@ -63,6 +66,7 @@ import {
|
|
|
63
66
|
findCommonAncestor,
|
|
64
67
|
rebaseBranch,
|
|
65
68
|
type LocalCommitEvents,
|
|
69
|
+
findAncestor,
|
|
66
70
|
} from "../core/index.js";
|
|
67
71
|
import {
|
|
68
72
|
type FieldBatchCodec,
|
|
@@ -91,8 +95,8 @@ import {
|
|
|
91
95
|
type TreeViewConfiguration,
|
|
92
96
|
type UnsafeUnknownSchema,
|
|
93
97
|
type ViewableTree,
|
|
94
|
-
type
|
|
95
|
-
type
|
|
98
|
+
type UntypedTreeView,
|
|
99
|
+
type UntypedTreeViewAlpha,
|
|
96
100
|
type VerboseTree,
|
|
97
101
|
type VoidTransactionCallbackStatusAlpha,
|
|
98
102
|
type TransactionCallbackStatusAlpha,
|
|
@@ -115,10 +119,12 @@ import {
|
|
|
115
119
|
hasSome,
|
|
116
120
|
throwIfBroken,
|
|
117
121
|
type JsonCompatibleReadOnly,
|
|
122
|
+
type JsonCompatibleReadOnlyObject,
|
|
118
123
|
type WithBreakable,
|
|
119
124
|
} from "../util/index.js";
|
|
120
125
|
|
|
121
126
|
import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
127
|
+
import { DefaultTreeBranchHistory } from "./history.js";
|
|
122
128
|
import { SharedTreeChangeEnricher } from "./sharedTreeChangeEnricher.js";
|
|
123
129
|
import type { SharedTreeChangeProcessingContext } from "./sharedTreeChangeFamily.js";
|
|
124
130
|
import {
|
|
@@ -132,6 +138,46 @@ import type { ISharedTreeEditor, SharedTreeEditBuilder } from "./sharedTreeEditB
|
|
|
132
138
|
import { extractTransactionChangeProcessor } from "./transactionPostProcessor.js";
|
|
133
139
|
import { SerializedChange } from "./serializedChange.js";
|
|
134
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Returns a defensive copy of the given metadata, validating that it can be persisted.
|
|
143
|
+
* @remarks
|
|
144
|
+
* The round-trip through JSON ensures that the value read back locally is exactly the value that peers and
|
|
145
|
+
* future summaries will see, and that later mutation of the caller's object cannot affect an existing commit.
|
|
146
|
+
* @throws A `UsageError` if the value cannot be represented as a JSON object.
|
|
147
|
+
*/
|
|
148
|
+
function snapshotCustomMetadata(
|
|
149
|
+
customMetadata: JsonCompatibleReadOnlyObject | undefined,
|
|
150
|
+
): JsonCompatibleReadOnlyObject | undefined {
|
|
151
|
+
if (customMetadata === undefined) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
let serialized: string | undefined;
|
|
155
|
+
try {
|
|
156
|
+
serialized = JSON.stringify(customMetadata);
|
|
157
|
+
} catch (error: unknown) {
|
|
158
|
+
throw new UsageError(
|
|
159
|
+
`"customMetadata" must be JSON-serializable: ${error instanceof Error ? error.message : String(error)}`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (serialized === undefined) {
|
|
163
|
+
throw new UsageError(`"customMetadata" must be JSON-serializable.`);
|
|
164
|
+
}
|
|
165
|
+
const snapshot: unknown = JSON.parse(serialized);
|
|
166
|
+
if (typeof snapshot !== "object" || snapshot === null || Array.isArray(snapshot)) {
|
|
167
|
+
throw new UsageError(`"customMetadata" must be a JSON object.`);
|
|
168
|
+
}
|
|
169
|
+
return snapshot as JsonCompatibleReadOnlyObject;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Wraps metadata for an operation which produces a single commit.
|
|
174
|
+
*/
|
|
175
|
+
function toMetadataTree(
|
|
176
|
+
customMetadata: JsonCompatibleReadOnlyObject | undefined,
|
|
177
|
+
): CustomMetadataTree | undefined {
|
|
178
|
+
return customMetadata === undefined ? undefined : { metadata: customMetadata, children: [] };
|
|
179
|
+
}
|
|
180
|
+
|
|
135
181
|
/**
|
|
136
182
|
* Yields all defined (non-`undefined`) labels from a {@link LabelTree}, depth-first.
|
|
137
183
|
*/
|
|
@@ -235,7 +281,7 @@ export type TreeTransactor = Transactor<
|
|
|
235
281
|
* Implementations of this interface must implement the {@link branchKey} property.
|
|
236
282
|
*/
|
|
237
283
|
export interface ITreeCheckout
|
|
238
|
-
extends
|
|
284
|
+
extends UntypedTreeViewAlpha,
|
|
239
285
|
AnchorLocator,
|
|
240
286
|
ViewableTree,
|
|
241
287
|
WithBreakable {
|
|
@@ -362,6 +408,7 @@ export function createTreeCheckout(
|
|
|
362
408
|
{
|
|
363
409
|
change: changeFamily.rebaser.compose([]),
|
|
364
410
|
revision: "root",
|
|
411
|
+
customMetadata: undefined,
|
|
365
412
|
},
|
|
366
413
|
changeFamily,
|
|
367
414
|
() => idCompressor.generateCompressedId(),
|
|
@@ -395,9 +442,9 @@ export interface RevertMetrics {
|
|
|
395
442
|
}
|
|
396
443
|
|
|
397
444
|
/**
|
|
398
|
-
* Get the {@link TreeCheckout} associated with a given {@link
|
|
445
|
+
* Get the {@link TreeCheckout} associated with a given {@link UntypedTreeView}.
|
|
399
446
|
*/
|
|
400
|
-
function getCheckout(context:
|
|
447
|
+
function getCheckout(context: UntypedTreeView): TreeCheckout {
|
|
401
448
|
if (context instanceof TreeCheckout) {
|
|
402
449
|
return context;
|
|
403
450
|
}
|
|
@@ -566,9 +613,10 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
566
613
|
|
|
567
614
|
readonly #events = createEmitter<CheckoutEvents>();
|
|
568
615
|
public events: Listenable<CheckoutEvents> = this.#events;
|
|
616
|
+
private _branchHistory?: DefaultTreeBranchHistory;
|
|
569
617
|
|
|
570
618
|
public constructor(
|
|
571
|
-
branch: SharedTreeBranch<
|
|
619
|
+
private branch: SharedTreeBranch<
|
|
572
620
|
SharedTreeEditBuilder,
|
|
573
621
|
SharedTreeChange,
|
|
574
622
|
SharedTreeChangeProcessingContext
|
|
@@ -593,6 +641,11 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
593
641
|
this.registerForBranchEvents();
|
|
594
642
|
}
|
|
595
643
|
|
|
644
|
+
public get branchHistory(): DefaultTreeBranchHistory {
|
|
645
|
+
this._branchHistory ??= new DefaultTreeBranchHistory(this.branch, this.idCompressor);
|
|
646
|
+
return this._branchHistory;
|
|
647
|
+
}
|
|
648
|
+
|
|
596
649
|
/**
|
|
597
650
|
* Pushes a new label node for a transaction nesting level.
|
|
598
651
|
*
|
|
@@ -962,17 +1015,21 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
962
1015
|
serializedChange,
|
|
963
1016
|
);
|
|
964
1017
|
// Apply the change to the branch, but _not_ the `activeBranch` - we do not support squashing serialized commits in a transaction.
|
|
965
|
-
this.#transaction.branch.apply(change);
|
|
1018
|
+
this.#transaction.branch.apply(change, CommitKind.Default, undefined);
|
|
966
1019
|
}
|
|
967
1020
|
|
|
968
|
-
// #region
|
|
1021
|
+
// #region UntypedTreeViewAlpha
|
|
969
1022
|
|
|
970
1023
|
@throwIfBroken
|
|
971
1024
|
public applyChange(change: JsonCompatibleReadOnly): void {
|
|
972
1025
|
this.applySerializedChange(change);
|
|
973
1026
|
}
|
|
974
1027
|
|
|
975
|
-
public isBranch(): this is
|
|
1028
|
+
public isBranch(): this is UntypedTreeViewAlpha {
|
|
1029
|
+
return this.isView();
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
public isView(): this is UntypedTreeViewAlpha {
|
|
976
1033
|
return true;
|
|
977
1034
|
}
|
|
978
1035
|
|
|
@@ -1047,6 +1104,9 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1047
1104
|
this.pushLabelFrame(params?.label);
|
|
1048
1105
|
this.transaction.start({
|
|
1049
1106
|
postProcessor: extractTransactionChangeProcessor(params?.postProcessor),
|
|
1107
|
+
// Like the validation described above, rejecting malformed metadata breaks the checkout rather
|
|
1108
|
+
// than being recoverable. Tracked by https://github.com/microsoft/FluidFramework/issues/28085.
|
|
1109
|
+
customMetadata: snapshotCustomMetadata(params?.customMetadata),
|
|
1050
1110
|
});
|
|
1051
1111
|
|
|
1052
1112
|
addConstraintsToTransaction(this, false, params?.preconditions);
|
|
@@ -1084,7 +1144,7 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1084
1144
|
: { success: true, value: value as TSuccessValue };
|
|
1085
1145
|
}
|
|
1086
1146
|
|
|
1087
|
-
// #endregion
|
|
1147
|
+
// #endregion UntypedTreeViewAlpha
|
|
1088
1148
|
|
|
1089
1149
|
// Revision is the revision of the commit, if any, which caused this change.
|
|
1090
1150
|
private applyInternalChange(change: SharedTreeChange, revision?: RevisionTag): void {
|
|
@@ -1182,24 +1242,33 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1182
1242
|
? RevertibleStatus.Disposed
|
|
1183
1243
|
: RevertibleStatus.Valid;
|
|
1184
1244
|
},
|
|
1185
|
-
revert: (
|
|
1245
|
+
revert: (releaseOrOptions: boolean | RevertOptionsAlpha = true) => {
|
|
1186
1246
|
if (revertible.status === RevertibleStatus.Disposed) {
|
|
1187
1247
|
throw new UsageError("Unable to revert a revertible that has been disposed.");
|
|
1188
1248
|
}
|
|
1189
1249
|
|
|
1190
|
-
const
|
|
1250
|
+
const options =
|
|
1251
|
+
typeof releaseOrOptions === "boolean"
|
|
1252
|
+
? { dispose: releaseOrOptions }
|
|
1253
|
+
: releaseOrOptions;
|
|
1254
|
+
const revertMetrics = checkout.revertRevertible(
|
|
1255
|
+
revision,
|
|
1256
|
+
kind,
|
|
1257
|
+
labelTree,
|
|
1258
|
+
snapshotCustomMetadata(options.customMetadata),
|
|
1259
|
+
);
|
|
1191
1260
|
checkout.logger?.sendTelemetryEvent({
|
|
1192
1261
|
eventName: TreeCheckout.revertTelemetryEventName,
|
|
1193
1262
|
...revertMetrics,
|
|
1194
1263
|
});
|
|
1195
1264
|
|
|
1196
|
-
if (
|
|
1265
|
+
if (options.dispose ?? true) {
|
|
1197
1266
|
revertible.dispose();
|
|
1198
1267
|
}
|
|
1199
1268
|
},
|
|
1200
|
-
clone: (
|
|
1269
|
+
clone: (targetView: UntypedTreeView) => {
|
|
1201
1270
|
// TODO:#23442: When a revertible is cloned for a forked branch, optimize to create a fork of a revertible branch once per revision NOT once per revision per checkout.
|
|
1202
|
-
const targetCheckout = getCheckout(
|
|
1271
|
+
const targetCheckout = getCheckout(targetView);
|
|
1203
1272
|
|
|
1204
1273
|
const revertibleBranch = this.revertibleCommitBranches.get(revision);
|
|
1205
1274
|
if (revertibleBranch === undefined) {
|
|
@@ -1334,11 +1403,15 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1334
1403
|
SharedTreeChangeProcessingContext
|
|
1335
1404
|
>,
|
|
1336
1405
|
): void {
|
|
1337
|
-
// TODO: Dispose old branch, if necessary
|
|
1338
1406
|
assert(
|
|
1339
1407
|
this.#transaction.size === 0,
|
|
1340
1408
|
0xc55 /* Cannot switch branches during a transaction */,
|
|
1341
1409
|
);
|
|
1410
|
+
if (this.isSharedBranch) {
|
|
1411
|
+
throw new UsageError(
|
|
1412
|
+
"Cannot switch a view away from a shared branch. Consider forking first.",
|
|
1413
|
+
);
|
|
1414
|
+
}
|
|
1342
1415
|
const diff = diffHistories(
|
|
1343
1416
|
this.changeFamily.rebaser,
|
|
1344
1417
|
this.#transaction.branch.getHead(),
|
|
@@ -1349,6 +1422,9 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1349
1422
|
this.unregisterFromBranchEvents();
|
|
1350
1423
|
|
|
1351
1424
|
this.#transaction = this.createTransactionStack(branch);
|
|
1425
|
+
this.branch = branch;
|
|
1426
|
+
this._branchHistory?.dispose();
|
|
1427
|
+
this._branchHistory = undefined;
|
|
1352
1428
|
this.editLock = new EditLock(this.#transaction.activeBranchEditor);
|
|
1353
1429
|
this.registerForBranchEvents();
|
|
1354
1430
|
|
|
@@ -1357,8 +1433,67 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1357
1433
|
this.#events.emit("afterBatch");
|
|
1358
1434
|
}
|
|
1359
1435
|
|
|
1360
|
-
|
|
1361
|
-
|
|
1436
|
+
public rewindTo(revisionString: string): void {
|
|
1437
|
+
this.checkNotDisposed("The branch has already been disposed and cannot be rewound.");
|
|
1438
|
+
if (this.#transaction.size > 0) {
|
|
1439
|
+
throw new UsageError("Rewinding is not supported during transactions.");
|
|
1440
|
+
}
|
|
1441
|
+
const revision = this.idCompressor.tryRecompress(revisionString as StableId);
|
|
1442
|
+
if (revision === undefined) {
|
|
1443
|
+
throw new UsageError(`Unrecognized revision id: ${revisionString}`);
|
|
1444
|
+
}
|
|
1445
|
+
const targetCommit = findAncestor(
|
|
1446
|
+
this.#transaction.branch.getHead(),
|
|
1447
|
+
(commit) => commit.revision === revision,
|
|
1448
|
+
);
|
|
1449
|
+
if (targetCommit === undefined) {
|
|
1450
|
+
throw new UsageError(`No commit found with revision: ${revisionString}`);
|
|
1451
|
+
}
|
|
1452
|
+
this.switchBranch(this.#transaction.branch.fork(targetCommit));
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
public revertTo(revisionString: string, options?: RevertToOptionsAlpha): void {
|
|
1456
|
+
this.checkNotDisposed(
|
|
1457
|
+
"The branch has already been disposed and prior revisions cannot be reverted to.",
|
|
1458
|
+
);
|
|
1459
|
+
this.editLock.checkUnlocked("Reverting to a revision");
|
|
1460
|
+
if (this.#transaction.size > 0) {
|
|
1461
|
+
throw new UsageError("Reverting to a revision is not supported during transactions.");
|
|
1462
|
+
}
|
|
1463
|
+
const customMetadata = snapshotCustomMetadata(options?.customMetadata);
|
|
1464
|
+
const revision = this.idCompressor.tryRecompress(revisionString as StableId);
|
|
1465
|
+
if (revision === undefined) {
|
|
1466
|
+
throw new UsageError(`Unrecognized revision id: ${revisionString}`);
|
|
1467
|
+
}
|
|
1468
|
+
// Populated with the commits that came after the target commit, from oldest to newest.
|
|
1469
|
+
const commitsToUndo: GraphCommit<SharedTreeChange>[] = [];
|
|
1470
|
+
const targetCommit = findAncestor(
|
|
1471
|
+
[this.#transaction.activeBranch.getHead(), commitsToUndo],
|
|
1472
|
+
(commit) => commit.revision === revision,
|
|
1473
|
+
);
|
|
1474
|
+
if (targetCommit === undefined) {
|
|
1475
|
+
throw new UsageError(`No commit found with revision: ${revisionString}`);
|
|
1476
|
+
}
|
|
1477
|
+
if (!hasSome(commitsToUndo)) {
|
|
1478
|
+
// The target commit is already the head of the branch, so there is nothing to revert.
|
|
1479
|
+
return;
|
|
1480
|
+
}
|
|
1481
|
+
const revisionForInvert = this.mintRevisionTag();
|
|
1482
|
+
const toUndo = this.changeFamily.rebaser.compose(commitsToUndo);
|
|
1483
|
+
const inverse = this.changeFamily.rebaser.invert(
|
|
1484
|
+
makeAnonChange(toUndo),
|
|
1485
|
+
false,
|
|
1486
|
+
revisionForInvert,
|
|
1487
|
+
);
|
|
1488
|
+
this.#transaction.branch.apply(
|
|
1489
|
+
tagChange(inverse, revisionForInvert),
|
|
1490
|
+
CommitKind.Default,
|
|
1491
|
+
toMetadataTree(customMetadata),
|
|
1492
|
+
);
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
private rebase(view: UntypedTreeView): void {
|
|
1496
|
+
const checkout = getCheckout(view);
|
|
1362
1497
|
this.checkNotDisposed(
|
|
1363
1498
|
"The target branch of the rebase has been disposed and cannot be rebased.",
|
|
1364
1499
|
);
|
|
@@ -1384,15 +1519,15 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1384
1519
|
checkout.#transaction.branch.rebaseOnto(this.#transaction.branch);
|
|
1385
1520
|
}
|
|
1386
1521
|
|
|
1387
|
-
public rebaseOnto(
|
|
1388
|
-
getCheckout(
|
|
1522
|
+
public rebaseOnto(view: UntypedTreeView): void {
|
|
1523
|
+
getCheckout(view).rebase(this);
|
|
1389
1524
|
}
|
|
1390
1525
|
|
|
1391
|
-
public isMissingEditsFrom(
|
|
1392
|
-
const
|
|
1526
|
+
public isMissingEditsFrom(view: UntypedTreeView): boolean {
|
|
1527
|
+
const viewCheckout = getCheckout(view);
|
|
1393
1528
|
const targetPath: GraphCommit<unknown>[] = [];
|
|
1394
1529
|
const ancestor = findCommonAncestor(this.mainBranch.getHead(), [
|
|
1395
|
-
|
|
1530
|
+
viewCheckout.mainBranch.getHead(),
|
|
1396
1531
|
targetPath,
|
|
1397
1532
|
]);
|
|
1398
1533
|
if (ancestor === undefined) {
|
|
@@ -1402,14 +1537,14 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1402
1537
|
}
|
|
1403
1538
|
|
|
1404
1539
|
public computeNetChangeIfRebasedOnto(
|
|
1405
|
-
|
|
1540
|
+
view: UntypedTreeView,
|
|
1406
1541
|
): JsonCompatibleReadOnly | undefined {
|
|
1407
|
-
const
|
|
1542
|
+
const viewCheckout = getCheckout(view);
|
|
1408
1543
|
const rebased = rebaseBranch(
|
|
1409
1544
|
this.mintRevisionTag,
|
|
1410
1545
|
this.changeFamily.rebaser,
|
|
1411
1546
|
this.#transaction.branch.getHead(),
|
|
1412
|
-
|
|
1547
|
+
viewCheckout.#transaction.branch.getHead(),
|
|
1413
1548
|
);
|
|
1414
1549
|
|
|
1415
1550
|
if (rebased.sourceChange === undefined) {
|
|
@@ -1425,10 +1560,10 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1425
1560
|
);
|
|
1426
1561
|
}
|
|
1427
1562
|
|
|
1428
|
-
public merge(
|
|
1429
|
-
public merge(
|
|
1430
|
-
public merge(
|
|
1431
|
-
const checkout = getCheckout(
|
|
1563
|
+
public merge(view: UntypedTreeView): void;
|
|
1564
|
+
public merge(view: UntypedTreeView, disposeMerged: boolean): void;
|
|
1565
|
+
public merge(view: UntypedTreeView, disposeMerged = true): void {
|
|
1566
|
+
const checkout = getCheckout(view);
|
|
1432
1567
|
this.checkNotDisposed(
|
|
1433
1568
|
"The target branch of the merge has been disposed and cannot be merged.",
|
|
1434
1569
|
);
|
|
@@ -1481,6 +1616,8 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1481
1616
|
view.dispose();
|
|
1482
1617
|
}
|
|
1483
1618
|
this.#events.emit("dispose");
|
|
1619
|
+
this._branchHistory?.dispose();
|
|
1620
|
+
this._branchHistory = undefined;
|
|
1484
1621
|
}
|
|
1485
1622
|
|
|
1486
1623
|
public getRemovedRoots(): [string | number | undefined, number, JsonableTree][] {
|
|
@@ -1529,6 +1666,7 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1529
1666
|
revision: RevisionTag,
|
|
1530
1667
|
kind: CommitKind,
|
|
1531
1668
|
labelTree: LabelTree | undefined,
|
|
1669
|
+
customMetadata: JsonCompatibleReadOnlyObject | undefined,
|
|
1532
1670
|
): RevertMetrics {
|
|
1533
1671
|
this.editLock.checkUnlocked("Reverting a commit");
|
|
1534
1672
|
if (this.transaction.size > 0) {
|
|
@@ -1583,6 +1721,7 @@ export class TreeCheckout implements ITreeCheckout {
|
|
|
1583
1721
|
kind === CommitKind.Default || kind === CommitKind.Redo
|
|
1584
1722
|
? CommitKind.Undo
|
|
1585
1723
|
: CommitKind.Redo,
|
|
1724
|
+
toMetadataTree(customMetadata),
|
|
1586
1725
|
);
|
|
1587
1726
|
} finally {
|
|
1588
1727
|
this.labelTreeNode = previousLabelTreeNode;
|
|
@@ -7,7 +7,7 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
|
7
7
|
|
|
8
8
|
import type {
|
|
9
9
|
TreeContextAlpha,
|
|
10
|
-
|
|
10
|
+
UntypedTreeViewAlpha,
|
|
11
11
|
RunTransactionParamsAlpha,
|
|
12
12
|
TransactionVoidResult,
|
|
13
13
|
TransactionValueResult,
|
|
@@ -24,7 +24,11 @@ export class UnhydratedTreeContext implements TreeContextAlpha {
|
|
|
24
24
|
private transactionCount = 0;
|
|
25
25
|
private constructor() {}
|
|
26
26
|
|
|
27
|
-
public isBranch(): this is
|
|
27
|
+
public isBranch(): this is UntypedTreeViewAlpha {
|
|
28
|
+
return this.isView();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public isView(): this is UntypedTreeViewAlpha {
|
|
28
32
|
return false;
|
|
29
33
|
}
|
|
30
34
|
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
type ChangeFamily,
|
|
18
18
|
type ChangeFamilyEditor,
|
|
19
19
|
CommitKind,
|
|
20
|
+
type CustomMetadataTree,
|
|
20
21
|
type GraphCommit,
|
|
21
22
|
type RevisionTag,
|
|
22
23
|
type TaggedChange,
|
|
@@ -56,6 +57,10 @@ export type SharedTreeBranchChange<TChange> =
|
|
|
56
57
|
| {
|
|
57
58
|
type: "rebase";
|
|
58
59
|
change: TaggedChange<TChange> | undefined;
|
|
60
|
+
/** The commits removed from the head of the branch by this operation */
|
|
61
|
+
removedCommits: readonly GraphCommit<TChange>[];
|
|
62
|
+
/** The commits appended to the head of the branch by this operation */
|
|
63
|
+
newCommits: readonly GraphCommit<TChange>[];
|
|
59
64
|
};
|
|
60
65
|
|
|
61
66
|
/**
|
|
@@ -152,7 +157,7 @@ export class SharedTreeBranch<
|
|
|
152
157
|
>,
|
|
153
158
|
) {
|
|
154
159
|
this.editor = this.changeFamily.buildEditor(mintRevisionTag, (change) =>
|
|
155
|
-
this.apply(change),
|
|
160
|
+
this.apply(change, CommitKind.Default, undefined),
|
|
156
161
|
);
|
|
157
162
|
this.unsubscribeBranchTrimmer = branchTrimmer?.on("ancestryTrimmed", (commit) => {
|
|
158
163
|
this.#events.emit("ancestryTrimmed", commit);
|
|
@@ -173,9 +178,15 @@ export class SharedTreeBranch<
|
|
|
173
178
|
* Apply a change to this branch.
|
|
174
179
|
* @param change - the change to apply
|
|
175
180
|
* @param kind - the kind of change to apply
|
|
181
|
+
* @param customMetadata - {@link GraphCommit.customMetadata | metadata} to attach to the new commit.
|
|
182
|
+
* Callers reconstructing an existing commit, rather than minting one, must pass that commit's metadata.
|
|
176
183
|
* @returns the change that was applied and the new head commit of the branch
|
|
177
184
|
*/
|
|
178
|
-
public apply(
|
|
185
|
+
public apply(
|
|
186
|
+
change: TaggedChange<TChange>,
|
|
187
|
+
kind: CommitKind,
|
|
188
|
+
customMetadata: CustomMetadataTree | undefined,
|
|
189
|
+
): void {
|
|
179
190
|
this.assertNotDisposed();
|
|
180
191
|
|
|
181
192
|
const revisionTag = change.revision;
|
|
@@ -184,6 +195,7 @@ export class SharedTreeBranch<
|
|
|
184
195
|
const newHead = mintCommit(this.head, {
|
|
185
196
|
revision: revisionTag,
|
|
186
197
|
change: change.change,
|
|
198
|
+
customMetadata,
|
|
187
199
|
});
|
|
188
200
|
|
|
189
201
|
const changeEvent = {
|
|
@@ -213,6 +225,26 @@ export class SharedTreeBranch<
|
|
|
213
225
|
return this.head;
|
|
214
226
|
}
|
|
215
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Gets the number of commits in this branch.
|
|
230
|
+
* This includes commits on ancestor branches but excludes the sentinel commit at the root of all branches.
|
|
231
|
+
* @remarks
|
|
232
|
+
* This method has linear complexity in the number of commits in the branch.
|
|
233
|
+
* See {@link BranchCommitCounter} for a cached version.
|
|
234
|
+
*/
|
|
235
|
+
public getCommitCount(): number {
|
|
236
|
+
let count = 0;
|
|
237
|
+
for (
|
|
238
|
+
let commit: GraphCommit<TChange> | undefined = this.head;
|
|
239
|
+
commit !== undefined;
|
|
240
|
+
commit = commit.parent
|
|
241
|
+
) {
|
|
242
|
+
count++;
|
|
243
|
+
}
|
|
244
|
+
// Exclude the sentinel commit that serves as the base to all branches.
|
|
245
|
+
return count - 1;
|
|
246
|
+
}
|
|
247
|
+
|
|
216
248
|
/**
|
|
217
249
|
* Spawn a new branch that is based off of the current state of this branch.
|
|
218
250
|
* @param commit - The commit to base the new branch off of. Defaults to the head of this branch.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
7
|
+
|
|
8
|
+
import type { ChangeFamilyEditor, RevisionTag } from "../core/index.js";
|
|
9
|
+
import type { SharedTreeBranch, SharedTreeBranchChange } from "./branch.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A utility class that counts the number of commits in a branch and keeps the count updated as the branch changes.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* This class has no inside knowledge of what the commits represent.
|
|
16
|
+
* It is therefore oblivious to any scheme where some root commit is considered "special" and should not be counted.
|
|
17
|
+
*/
|
|
18
|
+
export class BranchCommitCounter<
|
|
19
|
+
TEditor extends ChangeFamilyEditor,
|
|
20
|
+
TChange,
|
|
21
|
+
TChangeProcessingContext,
|
|
22
|
+
> {
|
|
23
|
+
private unsubscribeAfterChange?: () => void;
|
|
24
|
+
private unsubscribeAncestryTrimmed?: () => void;
|
|
25
|
+
private commitCountInitialized: boolean = false;
|
|
26
|
+
private cachedCommitCount: number = 0;
|
|
27
|
+
|
|
28
|
+
public constructor(
|
|
29
|
+
private readonly branch: SharedTreeBranch<TEditor, TChange, TChangeProcessingContext>,
|
|
30
|
+
) {}
|
|
31
|
+
|
|
32
|
+
public dispose(): void {
|
|
33
|
+
this.unsubscribeFromBranch();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Gets the number of commits in the branch.
|
|
38
|
+
*/
|
|
39
|
+
public get count(): number {
|
|
40
|
+
if (!this.commitCountInitialized) {
|
|
41
|
+
this.cachedCommitCount = this.branch.getCommitCount();
|
|
42
|
+
this.subscribeToBranch();
|
|
43
|
+
this.commitCountInitialized = true;
|
|
44
|
+
}
|
|
45
|
+
return this.cachedCommitCount;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private subscribeToBranch(): void {
|
|
49
|
+
this.unsubscribeFromBranch();
|
|
50
|
+
this.unsubscribeAfterChange = this.branch.events.on(
|
|
51
|
+
"afterChange",
|
|
52
|
+
this.onAfterBranchChange,
|
|
53
|
+
);
|
|
54
|
+
this.unsubscribeAncestryTrimmed = this.branch.events.on(
|
|
55
|
+
"ancestryTrimmed",
|
|
56
|
+
this.onAncestryTrimmed,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private unsubscribeFromBranch(): void {
|
|
61
|
+
this.unsubscribeAfterChange?.();
|
|
62
|
+
this.unsubscribeAfterChange = undefined;
|
|
63
|
+
this.unsubscribeAncestryTrimmed?.();
|
|
64
|
+
this.unsubscribeAncestryTrimmed = undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private readonly onAfterBranchChange = (event: SharedTreeBranchChange<TChange>): void => {
|
|
68
|
+
if (!this.commitCountInitialized) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
switch (event.type) {
|
|
73
|
+
case "append": {
|
|
74
|
+
this.cachedCommitCount += event.newCommits.length;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
case "remove": {
|
|
78
|
+
this.cachedCommitCount -= event.removedCommits.length;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
case "rebase": {
|
|
82
|
+
this.cachedCommitCount += event.newCommits.length;
|
|
83
|
+
this.cachedCommitCount -= event.removedCommits.length;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
default: {
|
|
87
|
+
unreachableCase(event);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
private readonly onAncestryTrimmed = (trimmedRevisions: RevisionTag[]): void => {
|
|
93
|
+
if (!this.commitCountInitialized) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
assert(
|
|
98
|
+
this.cachedCommitCount >= trimmedRevisions.length,
|
|
99
|
+
0xd35 /* Trimmed more commits than exist in the branch */,
|
|
100
|
+
);
|
|
101
|
+
this.cachedCommitCount = this.cachedCommitCount - trimmedRevisions.length;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { CustomMetadataTree } from "../core/index.js";
|
|
7
|
+
import type { Mutable } from "../util/index.js";
|
|
8
|
+
|
|
9
|
+
import type { EncodedCustomMetadataTree } from "./customMetadataFormat.js";
|
|
10
|
+
|
|
11
|
+
export function encodeCustomMetadataTree(tree: CustomMetadataTree): EncodedCustomMetadataTree {
|
|
12
|
+
const encoded: Mutable<EncodedCustomMetadataTree> = {};
|
|
13
|
+
if (tree.metadata !== undefined) {
|
|
14
|
+
encoded.m = tree.metadata;
|
|
15
|
+
}
|
|
16
|
+
if (tree.children.length > 0) {
|
|
17
|
+
encoded.c = tree.children.map(encodeCustomMetadataTree);
|
|
18
|
+
}
|
|
19
|
+
return encoded;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function decodeCustomMetadataTree(
|
|
23
|
+
encoded: EncodedCustomMetadataTree | undefined,
|
|
24
|
+
): CustomMetadataTree | undefined {
|
|
25
|
+
if (encoded === undefined) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const decoded = decodeNode(encoded);
|
|
29
|
+
// A tree in which no node supplied metadata carries no information.
|
|
30
|
+
return hasMetadata(decoded) ? decoded : undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function decodeNode(encoded: EncodedCustomMetadataTree): CustomMetadataTree {
|
|
34
|
+
return {
|
|
35
|
+
metadata: encoded.m,
|
|
36
|
+
children: encoded.c?.map(decodeNode) ?? [],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function hasMetadata(node: CustomMetadataTree): boolean {
|
|
41
|
+
return node.metadata !== undefined || node.children.some(hasMetadata);
|
|
42
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as Type from "@sinclair/typebox";
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
type JsonCompatibleReadOnlyObject,
|
|
10
|
+
JsonCompatibleReadOnlySchema,
|
|
11
|
+
} from "../util/index.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The persisted form of a {@link CustomMetadataTree}.
|
|
15
|
+
* @remarks
|
|
16
|
+
* The property names (`m` for metadata, `c` for children) are abbreviated and both are optional because
|
|
17
|
+
* this rides on every annotated op and occupies summary space for as long as its commit survives.
|
|
18
|
+
*/
|
|
19
|
+
// Declared as a type alias rather than an interface so that it satisfies the index signature of
|
|
20
|
+
// `JsonCompatibleReadOnlyObject`, which the encoded message and summary types are constrained to.
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
22
|
+
export type EncodedCustomMetadataTree = {
|
|
23
|
+
readonly m?: JsonCompatibleReadOnlyObject;
|
|
24
|
+
readonly c?: readonly EncodedCustomMetadataTree[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const EncodedCustomMetadataTree = Type.Recursive((Self) =>
|
|
28
|
+
Type.Object(
|
|
29
|
+
{
|
|
30
|
+
m: Type.Optional(
|
|
31
|
+
Type.Unsafe<JsonCompatibleReadOnlyObject>(
|
|
32
|
+
Type.Record(Type.String(), JsonCompatibleReadOnlySchema),
|
|
33
|
+
),
|
|
34
|
+
),
|
|
35
|
+
c: Type.Optional(Type.Array(Self)),
|
|
36
|
+
},
|
|
37
|
+
{ additionalProperties: false },
|
|
38
|
+
),
|
|
39
|
+
) as unknown as Type.TSchema;
|