@fluidframework/tree 2.110.0 → 2.112.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/.vscode/settings.json +1 -0
- package/CHANGELOG.md +193 -0
- package/api-report/tree.alpha.api.md +96 -36
- package/api-report/tree.beta.api.md +39 -1
- package/api-report/tree.legacy.beta.api.md +39 -1
- package/api-report/tree.legacy.public.api.md +1 -1
- package/api-report/tree.public.api.md +1 -1
- package/dist/componentApi.d.ts +198 -0
- package/dist/componentApi.d.ts.map +1 -0
- package/dist/componentApi.js +138 -0
- package/dist/componentApi.js.map +1 -0
- package/dist/core/change-family/changeFamily.d.ts +3 -10
- package/dist/core/change-family/changeFamily.d.ts.map +1 -1
- package/dist/core/change-family/changeFamily.js.map +1 -1
- package/dist/core/rebase/types.d.ts +2 -2
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.d.ts +2 -2
- package/dist/core/schema-stored/storedSchemaRepository.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 +4 -2
- 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/chunked-forest/codec/chunkDecoding.d.ts +1 -20
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +13 -32
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +73 -28
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +76 -9
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +4 -2
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +11 -0
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js +2 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +3 -15
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.js +2 -1
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts +3 -3
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -6
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +3 -3
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +4 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +1 -0
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +3 -1
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
- package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/minimizeModularChange.js +29 -0
- package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +9 -9
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/dist/feature-libraries/schemaChecker.d.ts +22 -3
- package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/schemaChecker.js +48 -5
- package/dist/feature-libraries/schemaChecker.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- 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/independentView.d.ts +17 -4
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +15 -12
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +3 -2
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +3 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +6 -5
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +6 -3
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/serializedChange.d.ts +41 -0
- package/dist/shared-tree/serializedChange.d.ts.map +1 -0
- package/dist/shared-tree/serializedChange.js +87 -0
- package/dist/shared-tree/serializedChange.js.map +1 -0
- package/dist/shared-tree/sharedTree.d.ts +18 -0
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +9 -4
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +8 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/transactionMinimize.d.ts +35 -0
- package/dist/shared-tree/transactionMinimize.d.ts.map +1 -0
- package/dist/shared-tree/transactionMinimize.js +65 -0
- package/dist/shared-tree/transactionMinimize.js.map +1 -0
- package/dist/shared-tree/transactionPostProcessor.d.ts +28 -0
- package/dist/shared-tree/transactionPostProcessor.d.ts.map +1 -0
- package/dist/shared-tree/transactionPostProcessor.js +28 -0
- package/dist/shared-tree/transactionPostProcessor.js.map +1 -0
- package/dist/shared-tree/treeAlpha.js +3 -3
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +19 -13
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +54 -71
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree/unhydratedTreeContext.d.ts +5 -5
- package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
- package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts +6 -3
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +35 -14
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -2
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -9
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -4
- package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -3
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -3
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts +5 -9
- package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +5 -10
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +1 -1
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +3 -2
- package/dist/shared-tree-core/index.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/messageFormat.d.ts +1 -1
- package/dist/shared-tree-core/messageFormat.js +1 -1
- package/dist/shared-tree-core/messageFormat.js.map +1 -1
- package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
- package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormatVSharedBranches.js +1 -0
- package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageTypes.d.ts +1 -0
- package/dist/shared-tree-core/messageTypes.d.ts.map +1 -1
- package/dist/shared-tree-core/messageTypes.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +9 -3
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +27 -12
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +84 -9
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +88 -7
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +2 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +2 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +9 -24
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js +31 -44
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
- package/dist/simple-tree/api/schemaCreationUtilities.js +3 -3
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +1 -1
- package/dist/simple-tree/api/schemaFactory.js +2 -2
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +2 -2
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js +3 -4
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +1 -2
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts +91 -28
- 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 +108 -24
- 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/api/treeBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +2 -2
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +7 -7
- package/dist/simple-tree/core/treeNodeSchema.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 +2 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +83 -4
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +39 -0
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/simpleSchemaFormatV1.js +1 -1
- package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
- package/dist/text/index.d.ts +1 -0
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +3 -1
- package/dist/text/index.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +69 -758
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/text/textDomainFormatted.js +275 -322
- package/dist/text/textDomainFormatted.js.map +1 -1
- package/dist/text/textDomainFormattedDefault.d.ts +273 -0
- package/dist/text/textDomainFormattedDefault.d.ts.map +1 -0
- package/dist/text/textDomainFormattedDefault.js +94 -0
- package/dist/text/textDomainFormattedDefault.js.map +1 -0
- package/dist/treeFactory.js +1 -1
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/breakable.d.ts +16 -1
- package/dist/util/breakable.d.ts.map +1 -1
- package/dist/util/breakable.js +9 -1
- package/dist/util/breakable.js.map +1 -1
- package/dist/util/compressedIds.d.ts +185 -0
- package/dist/util/compressedIds.d.ts.map +1 -0
- package/dist/util/compressedIds.js +164 -0
- package/dist/util/compressedIds.js.map +1 -0
- package/dist/util/index.d.ts +2 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +10 -2
- package/dist/util/index.js.map +1 -1
- package/dist/util/nestedMap.d.ts.map +1 -1
- package/dist/util/nestedMap.js +16 -3
- package/dist/util/nestedMap.js.map +1 -1
- package/dist/util/nestedSet.d.ts +1 -1
- package/dist/util/nestedSet.d.ts.map +1 -1
- package/dist/util/nestedSet.js.map +1 -1
- package/dist/util/utils.d.ts +0 -6
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +1 -15
- package/dist/util/utils.js.map +1 -1
- package/lib/componentApi.d.ts +198 -0
- package/lib/componentApi.d.ts.map +1 -0
- package/lib/componentApi.js +135 -0
- package/lib/componentApi.js.map +1 -0
- package/lib/core/change-family/changeFamily.d.ts +3 -10
- package/lib/core/change-family/changeFamily.d.ts.map +1 -1
- package/lib/core/change-family/changeFamily.js.map +1 -1
- package/lib/core/rebase/types.d.ts +2 -2
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.d.ts +2 -2
- package/lib/core/schema-stored/storedSchemaRepository.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 +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/chunked-forest/codec/chunkDecoding.d.ts +1 -20
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +14 -33
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +73 -28
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +75 -9
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +4 -2
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +12 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +3 -15
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts +3 -3
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +4 -6
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +3 -3
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +2 -2
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +1 -0
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +1 -0
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
- package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/minimizeModularChange.js +25 -0
- package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +10 -10
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/lib/feature-libraries/schemaChecker.d.ts +22 -3
- package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/schemaChecker.js +48 -5
- package/lib/feature-libraries/schemaChecker.js.map +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- 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/independentView.d.ts +17 -4
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +13 -10
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +3 -2
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -0
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +6 -5
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +7 -4
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/serializedChange.d.ts +41 -0
- package/lib/shared-tree/serializedChange.d.ts.map +1 -0
- package/lib/shared-tree/serializedChange.js +84 -0
- package/lib/shared-tree/serializedChange.js.map +1 -0
- package/lib/shared-tree/sharedTree.d.ts +18 -0
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +10 -5
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +7 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/transactionMinimize.d.ts +35 -0
- package/lib/shared-tree/transactionMinimize.d.ts.map +1 -0
- package/lib/shared-tree/transactionMinimize.js +62 -0
- package/lib/shared-tree/transactionMinimize.js.map +1 -0
- package/lib/shared-tree/transactionPostProcessor.d.ts +28 -0
- package/lib/shared-tree/transactionPostProcessor.d.ts.map +1 -0
- package/lib/shared-tree/transactionPostProcessor.js +23 -0
- package/lib/shared-tree/transactionPostProcessor.js.map +1 -0
- package/lib/shared-tree/treeAlpha.js +3 -3
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +19 -13
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +36 -53
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree/unhydratedTreeContext.d.ts +5 -5
- package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
- package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts +6 -3
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +36 -15
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -2
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -9
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.js +3 -5
- package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -3
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -3
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts +5 -9
- package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +5 -10
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +1 -1
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js +1 -1
- package/lib/shared-tree-core/index.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/messageFormat.d.ts +1 -1
- package/lib/shared-tree-core/messageFormat.js +1 -1
- package/lib/shared-tree-core/messageFormat.js.map +1 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.js +1 -0
- package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageTypes.d.ts +1 -0
- package/lib/shared-tree-core/messageTypes.d.ts.map +1 -1
- package/lib/shared-tree-core/messageTypes.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +9 -3
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +28 -13
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +84 -9
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +87 -6
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +2 -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 +9 -24
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.js +29 -42
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
- package/lib/simple-tree/api/schemaCreationUtilities.js +3 -3
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +1 -1
- package/lib/simple-tree/api/schemaFactory.js +2 -2
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +2 -2
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js +4 -5
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +2 -3
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts +91 -28
- 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 +108 -24
- 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/api/treeBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +2 -2
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +7 -7
- package/lib/simple-tree/core/treeNodeSchema.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/simple-tree/node-kinds/array/arrayNode.d.ts +83 -4
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +39 -0
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/simpleSchemaFormatV1.js +1 -1
- package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -1
- package/lib/text/index.d.ts +1 -0
- package/lib/text/index.d.ts.map +1 -1
- package/lib/text/index.js +1 -0
- package/lib/text/index.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +69 -758
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/text/textDomainFormatted.js +277 -324
- package/lib/text/textDomainFormatted.js.map +1 -1
- package/lib/text/textDomainFormattedDefault.d.ts +273 -0
- package/lib/text/textDomainFormattedDefault.d.ts.map +1 -0
- package/lib/text/textDomainFormattedDefault.js +91 -0
- package/lib/text/textDomainFormattedDefault.js.map +1 -0
- package/lib/treeFactory.js +1 -1
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/breakable.d.ts +16 -1
- package/lib/util/breakable.d.ts.map +1 -1
- package/lib/util/breakable.js +9 -1
- package/lib/util/breakable.js.map +1 -1
- package/lib/util/compressedIds.d.ts +185 -0
- package/lib/util/compressedIds.d.ts.map +1 -0
- package/lib/util/compressedIds.js +154 -0
- package/lib/util/compressedIds.js.map +1 -0
- package/lib/util/index.d.ts +2 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +2 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/nestedMap.d.ts.map +1 -1
- package/lib/util/nestedMap.js +17 -4
- package/lib/util/nestedMap.js.map +1 -1
- package/lib/util/nestedSet.d.ts +1 -1
- package/lib/util/nestedSet.d.ts.map +1 -1
- package/lib/util/nestedSet.js.map +1 -1
- package/lib/util/utils.d.ts +0 -6
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +0 -13
- package/lib/util/utils.js.map +1 -1
- package/package.json +23 -23
- package/src/componentApi.ts +354 -0
- package/src/core/change-family/changeFamily.ts +3 -12
- package/src/core/rebase/types.ts +2 -2
- package/src/core/schema-stored/storedSchemaRepository.ts +2 -2
- package/src/entrypoints/alpha.ts +15 -8
- package/src/entrypoints/beta.ts +8 -0
- package/src/entrypoints/legacy.ts +8 -0
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +22 -72
- package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -2
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +110 -41
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +32 -4
- package/src/feature-libraries/chunked-forest/codec/index.ts +1 -0
- package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +7 -19
- package/src/feature-libraries/chunked-forest/index.ts +3 -0
- package/src/feature-libraries/forest-summary/codec.ts +5 -3
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +4 -5
- package/src/feature-libraries/index.ts +5 -0
- package/src/feature-libraries/modular-schema/index.ts +1 -0
- package/src/feature-libraries/modular-schema/minimizeModularChange.ts +33 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +13 -9
- package/src/feature-libraries/schemaChecker.ts +86 -9
- package/src/index.ts +16 -8
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +40 -15
- package/src/shared-tree/index.ts +4 -0
- package/src/shared-tree/schematizingTreeView.ts +40 -30
- package/src/shared-tree/serializedChange.ts +127 -0
- package/src/shared-tree/sharedTree.ts +32 -4
- package/src/shared-tree/sharedTreeChangeFamily.ts +7 -1
- package/src/shared-tree/transactionMinimize.ts +74 -0
- package/src/shared-tree/transactionPostProcessor.ts +40 -0
- package/src/shared-tree/treeAlpha.ts +3 -3
- package/src/shared-tree/treeCheckout.ts +103 -101
- package/src/shared-tree/unhydratedTreeContext.ts +18 -15
- package/src/shared-tree-core/editManager.ts +42 -6
- package/src/shared-tree-core/editManagerCodecs.ts +3 -2
- package/src/shared-tree-core/editManagerCodecsCommons.ts +10 -14
- package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -2
- package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -2
- package/src/shared-tree-core/editManagerFormatCommons.ts +1 -1
- package/src/shared-tree-core/editManagerSummarizer.ts +5 -9
- package/src/shared-tree-core/index.ts +8 -5
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +8 -1
- package/src/shared-tree-core/messageFormat.ts +1 -1
- package/src/shared-tree-core/messageFormatVSharedBranches.ts +10 -0
- package/src/shared-tree-core/messageTypes.ts +1 -0
- package/src/shared-tree-core/sharedTreeCore.ts +36 -12
- package/src/shared-tree-core/transaction.ts +165 -18
- package/src/simple-tree/api/index.ts +14 -10
- package/src/simple-tree/api/schemaCompatibilityTester.ts +36 -48
- package/src/simple-tree/api/schemaCreationUtilities.ts +3 -3
- package/src/simple-tree/api/schemaFactory.ts +2 -2
- package/src/simple-tree/api/schemaFactoryAlpha.ts +56 -15
- package/src/simple-tree/api/schemaFactoryBeta.ts +0 -3
- package/src/simple-tree/api/snapshotCompatibilityChecker.ts +4 -5
- package/src/simple-tree/api/storedSchema.ts +2 -3
- package/src/simple-tree/api/transactionTypes.ts +111 -39
- package/src/simple-tree/api/tree.ts +165 -49
- package/src/simple-tree/api/treeBeta.ts +2 -0
- package/src/simple-tree/api/typesUnsafe.ts +2 -1
- package/src/simple-tree/core/treeNodeSchema.ts +7 -7
- package/src/simple-tree/index.ts +13 -9
- package/src/simple-tree/node-kinds/array/arrayNode.ts +168 -4
- package/src/simple-tree/simpleSchemaFormatV1.ts +1 -1
- package/src/text/index.ts +1 -0
- package/src/text/textDomainFormatted.ts +520 -415
- package/src/text/textDomainFormattedDefault.ts +150 -0
- package/src/treeFactory.ts +1 -1
- package/src/util/breakable.ts +8 -1
- package/src/util/compressedIds.ts +304 -0
- package/src/util/index.ts +18 -1
- package/src/util/nestedMap.ts +21 -4
- package/src/util/nestedSet.ts +1 -1
- package/src/util/utils.ts +0 -18
|
@@ -40,15 +40,17 @@ export enum TransactionResult {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* A simple API for managing transactions.
|
|
43
|
+
* @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
|
|
43
44
|
*/
|
|
44
|
-
export interface Transactor {
|
|
45
|
+
export interface Transactor<TOptions> {
|
|
45
46
|
/**
|
|
46
47
|
* Start a new transaction.
|
|
48
|
+
* @param options - Options controlling how the transaction is committed.
|
|
47
49
|
* @remarks
|
|
48
50
|
* If a transaction is already in progress when this new transaction starts, then this transaction will be "nested" inside of it,
|
|
49
51
|
* i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.
|
|
50
52
|
*/
|
|
51
|
-
start(): void;
|
|
53
|
+
start(options?: TOptions): void;
|
|
52
54
|
/**
|
|
53
55
|
* Close this transaction by squashing its edits and committing them as a single edit.
|
|
54
56
|
* @remarks If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.
|
|
@@ -89,8 +91,9 @@ export interface TransactionEvents {
|
|
|
89
91
|
|
|
90
92
|
/**
|
|
91
93
|
* Callbacks for transaction lifecycle events.
|
|
94
|
+
* @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
|
|
92
95
|
*/
|
|
93
|
-
export interface Callbacks {
|
|
96
|
+
export interface Callbacks<TOptions> {
|
|
94
97
|
/**
|
|
95
98
|
* Called when the current transaction is popped from the {@link TransactionStack | stack}.
|
|
96
99
|
*/
|
|
@@ -104,37 +107,42 @@ export interface Callbacks {
|
|
|
104
107
|
* Put another way, a transaction always results in a call to exactly one `OnPush` callback - whichever is closest to the transaction.
|
|
105
108
|
* The event "bubbles up" to (and no further past) its first registered callback.
|
|
106
109
|
*/
|
|
107
|
-
readonly onPush?: OnPush
|
|
110
|
+
readonly onPush?: OnPush<TOptions>;
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
/**
|
|
111
114
|
* A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.
|
|
112
115
|
* @remarks This function may return other functions that will be called when the transaction is popped from the stack or a nested transaction is pushed onto the stack.
|
|
113
116
|
* This function runs just before the transaction begins, so if this is the beginning of an outermost (not nested) transaction then {@link Transactor.size} will be 0 during its execution.
|
|
117
|
+
* @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
|
|
118
|
+
* @param options - The options passed to {@link Transactor.start | start}.
|
|
114
119
|
*/
|
|
115
|
-
export type OnPush = () => Callbacks | void;
|
|
120
|
+
export type OnPush<TOptions> = (options?: TOptions) => Callbacks<TOptions> | void;
|
|
116
121
|
|
|
117
122
|
/**
|
|
118
123
|
* A function that will be called when a transaction is popped from the {@link TransactionStack | stack}.
|
|
119
124
|
* @remarks This function runs just after the transaction ends, so if this is the end of an outermost (not nested) transaction then {@link Transactor.size} will be 0 during its execution.
|
|
125
|
+
* @param result - The result of the transaction.
|
|
120
126
|
*/
|
|
121
127
|
export type OnPop = (result: TransactionResult) => void;
|
|
122
128
|
|
|
123
129
|
/**
|
|
124
130
|
* A frame in the transaction stack.
|
|
131
|
+
* @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
|
|
125
132
|
*/
|
|
126
|
-
interface TransactionStackFrame {
|
|
133
|
+
interface TransactionStackFrame<TOptions> {
|
|
127
134
|
/** The callbacks provided when this transaction frame was pushed onto the stack. */
|
|
128
|
-
readonly callbacks: Callbacks
|
|
135
|
+
readonly callbacks: Callbacks<TOptions>;
|
|
129
136
|
}
|
|
130
137
|
|
|
131
138
|
/**
|
|
132
139
|
* An implementation of {@link Transactor} that uses a stack to manage transactions.
|
|
133
140
|
* @remarks Using a stack allows transactions to nest - i.e. an inner transaction may be started while an outer transaction is already in progress.
|
|
141
|
+
* @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
|
|
134
142
|
*/
|
|
135
|
-
export class TransactionStack implements Transactor
|
|
136
|
-
readonly #stack: TransactionStackFrame[] = [];
|
|
137
|
-
readonly #onPush?: OnPush
|
|
143
|
+
export class TransactionStack<TOptions> implements Transactor<TOptions>, IDisposable {
|
|
144
|
+
readonly #stack: TransactionStackFrame<TOptions>[] = [];
|
|
145
|
+
readonly #onPush?: OnPush<TOptions>;
|
|
138
146
|
|
|
139
147
|
readonly #events = createEmitter<TransactionEvents>();
|
|
140
148
|
public get events(): Listenable<TransactionEvents> {
|
|
@@ -150,7 +158,7 @@ export class TransactionStack implements Transactor, IDisposable {
|
|
|
150
158
|
* Construct a new {@link TransactionStack}.
|
|
151
159
|
* @param onPush - A {@link OnPush | function} that will be called when a transaction begins.
|
|
152
160
|
*/
|
|
153
|
-
public constructor(onPush?: OnPush) {
|
|
161
|
+
public constructor(onPush?: OnPush<TOptions>) {
|
|
154
162
|
this.#onPush = onPush;
|
|
155
163
|
}
|
|
156
164
|
|
|
@@ -159,11 +167,11 @@ export class TransactionStack implements Transactor, IDisposable {
|
|
|
159
167
|
return this.#stack.length;
|
|
160
168
|
}
|
|
161
169
|
|
|
162
|
-
public start(): void {
|
|
170
|
+
public start(options?: TOptions): void {
|
|
163
171
|
this.ensureNotDisposed();
|
|
164
172
|
const last = getLast(this.#stack);
|
|
165
173
|
const onPushCurrent = last === undefined ? this.#onPush : last.callbacks.onPush;
|
|
166
|
-
const { onPush, onPop } = onPushCurrent?.() ?? {};
|
|
174
|
+
const { onPush, onPop } = onPushCurrent?.(options) ?? {};
|
|
167
175
|
this.#stack.push({
|
|
168
176
|
callbacks: { onPop, onPush: onPush ?? onPushCurrent },
|
|
169
177
|
});
|
|
@@ -216,6 +224,73 @@ export type OnPopWithViewUpdate<TChange> = (
|
|
|
216
224
|
viewUpdate: TChange | undefined,
|
|
217
225
|
) => void;
|
|
218
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Informs the caller of {@link ChangeProcessor} what context it should be invoked for.
|
|
229
|
+
* @remarks This is purely a recommendation to the caller of the processor and
|
|
230
|
+
* not a strict rule.
|
|
231
|
+
*/
|
|
232
|
+
export enum ChangeProcessorApplicability {
|
|
233
|
+
/**
|
|
234
|
+
* Invoke the processor if no later (outer) instance of this change processor
|
|
235
|
+
* may be applied to related changes before changes are "visible".
|
|
236
|
+
*
|
|
237
|
+
* @remarks
|
|
238
|
+
* This designation is meant for processors that only need to be applied
|
|
239
|
+
* once to a set of related changes independent of scope or nesting,
|
|
240
|
+
* with the understanding that the processor should still be applied no
|
|
241
|
+
* later than when the changes are "visible" (e.g. committed to a branch).
|
|
242
|
+
* For example, a processor that removes extraneous information from a
|
|
243
|
+
* change (e.g. data for nodes that were both created and removed within a
|
|
244
|
+
* transaction) only needs to be applied once to the squashed change
|
|
245
|
+
* produced by the outermost transaction.
|
|
246
|
+
*/
|
|
247
|
+
IfOutermost,
|
|
248
|
+
/**
|
|
249
|
+
* Invoke the processor in all contexts.
|
|
250
|
+
*/
|
|
251
|
+
Always,
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Processes a change altering its representation.
|
|
256
|
+
*
|
|
257
|
+
* @remarks
|
|
258
|
+
* A change processor receives a change and returns a change with the
|
|
259
|
+
* same observable effect but otherwise transformed.
|
|
260
|
+
*
|
|
261
|
+
* Currently this is the internal counterpart of the type-erased post-processor
|
|
262
|
+
* exposed on the public transaction API. The public boundary type-erases this
|
|
263
|
+
* (see the conversion helpers in the `shared-tree` layer) so that its internal
|
|
264
|
+
* change representation does not leak into the public API.
|
|
265
|
+
*/
|
|
266
|
+
export interface ChangeProcessor<TChange> {
|
|
267
|
+
/**
|
|
268
|
+
* Informs what context it should be invoked for.
|
|
269
|
+
*/
|
|
270
|
+
readonly applicability: ChangeProcessorApplicability;
|
|
271
|
+
/**
|
|
272
|
+
* Processes the given change, returning a change with the same observable effect.
|
|
273
|
+
*/
|
|
274
|
+
readonly processChange: (change: TChange) => TChange;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Options for {@link Transactor.start | starting} a transaction.
|
|
279
|
+
*/
|
|
280
|
+
export interface SquashingTransactionOptions<TChange> {
|
|
281
|
+
/**
|
|
282
|
+
* An optional {@link ChangeProcessor} applied to the squashed change produced when a transaction that was started
|
|
283
|
+
* with this option is committed.
|
|
284
|
+
*
|
|
285
|
+
* @remarks
|
|
286
|
+
* When omitted, the transaction's edits are squashed without any post-processing.
|
|
287
|
+
*
|
|
288
|
+
* How often the processor is invoked across nested transactions is governed by its
|
|
289
|
+
* {@link ChangeProcessor.applicability | applicability}.
|
|
290
|
+
*/
|
|
291
|
+
readonly postProcessor?: ChangeProcessor<TChange>;
|
|
292
|
+
}
|
|
293
|
+
|
|
219
294
|
/**
|
|
220
295
|
* An implementation of {@link Transactor} that {@link TransactionStack | uses a stack} and a {@link SharedTreeBranch | branch} to manage transactions.
|
|
221
296
|
* @remarks Given a branch, this class will fork the branch when a transaction begins and squash the forked branch back into the original branch when the transaction ends.
|
|
@@ -225,7 +300,7 @@ export type OnPopWithViewUpdate<TChange> = (
|
|
|
225
300
|
export class SquashingTransactionStack<
|
|
226
301
|
TEditor extends ChangeFamilyEditor,
|
|
227
302
|
TChange,
|
|
228
|
-
> extends TransactionStack {
|
|
303
|
+
> extends TransactionStack<SquashingTransactionOptions<TChange>> {
|
|
229
304
|
#transactionBranch?: SharedTreeBranch<TEditor, TChange>;
|
|
230
305
|
|
|
231
306
|
/**
|
|
@@ -284,15 +359,41 @@ export class SquashingTransactionStack<
|
|
|
284
359
|
* Construct a new {@link SquashingTransactionStack}.
|
|
285
360
|
* @param branch - The {@link SquashingTransactionStack.branch | branch} that will be forked off of when a transaction begins.
|
|
286
361
|
* @param onPush - A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.
|
|
362
|
+
* @remarks To post-process the squashed change produced when a transaction is committed (for example, to "minimize"
|
|
363
|
+
* it so that it contains no extraneous information), start the transaction with a
|
|
364
|
+
* {@link SquashingTransactionOptions.postProcessor | post-processor}. The post-processor is injected via the transaction
|
|
365
|
+
* options rather than baked into this stack, so different transactions may supply different post-processors (or none).
|
|
287
366
|
*/
|
|
288
367
|
public constructor(
|
|
289
368
|
public readonly branch: SharedTreeBranch<TEditor, TChange>,
|
|
290
369
|
mintRevisionTag: () => RevisionTag,
|
|
291
370
|
onPush?: () => OnPopWithViewUpdate<TChange> | void,
|
|
292
371
|
) {
|
|
372
|
+
// A stack of the post-processors to apply when each in-progress transaction commits, ordered from outermost to
|
|
373
|
+
// innermost. Each in-progress transaction contributes exactly one entry: either the processor to apply when it
|
|
374
|
+
// commits, or `undefined` when none should be applied.
|
|
375
|
+
const postProcessorStack: (ChangeProcessor<TChange> | undefined)[] = [];
|
|
376
|
+
// Determines the entry to push for a transaction that was started with the given `requested` processor (if any).
|
|
377
|
+
// A processor with "outermost" applicability that is already active in an enclosing transaction resolves to
|
|
378
|
+
// `undefined` so that it is only applied once (at the outermost transaction that supplied it).
|
|
379
|
+
const resolvePostProcessor = (
|
|
380
|
+
requested: ChangeProcessor<TChange> | undefined,
|
|
381
|
+
): ChangeProcessor<TChange> | undefined => {
|
|
382
|
+
if (
|
|
383
|
+
requested?.applicability === ChangeProcessorApplicability.IfOutermost &&
|
|
384
|
+
postProcessorStack.includes(requested)
|
|
385
|
+
) {
|
|
386
|
+
return undefined;
|
|
387
|
+
}
|
|
388
|
+
return requested;
|
|
389
|
+
};
|
|
390
|
+
|
|
293
391
|
super(
|
|
294
392
|
// Invoked when an outer transaction starts
|
|
295
|
-
(
|
|
393
|
+
(
|
|
394
|
+
startOptions?: SquashingTransactionOptions<TChange>,
|
|
395
|
+
): Callbacks<SquashingTransactionOptions<TChange>> => {
|
|
396
|
+
postProcessorStack.push(resolvePostProcessor(startOptions?.postProcessor));
|
|
296
397
|
// Keep track of the commit that each transaction was on when it started
|
|
297
398
|
const startHead = this.activeBranch.getHead();
|
|
298
399
|
const rebaser = this.branch.changeFamily.rebaser;
|
|
@@ -309,6 +410,7 @@ export class SquashingTransactionStack<
|
|
|
309
410
|
// Invoked when an outer transaction ends
|
|
310
411
|
const onOuterTransactionPop: OnPop = (result) => {
|
|
311
412
|
assert(this.size === 0, 0xcae /* The outer transaction should be ending */);
|
|
413
|
+
const postProcessor = postProcessorStack.pop();
|
|
312
414
|
transactionBranch.editor.exitTransaction();
|
|
313
415
|
|
|
314
416
|
const sourcePath: GraphCommit<TChange>[] = [];
|
|
@@ -357,16 +459,31 @@ export class SquashingTransactionStack<
|
|
|
357
459
|
}
|
|
358
460
|
// Squash all the new commits on the transaction branch into a new commit on the original branch
|
|
359
461
|
const squash = rebaser.compose(transactionSteps);
|
|
462
|
+
// Apply this transaction's post-processor (if any) to the squashed change (for example, to
|
|
463
|
+
// "minimize" it so that it contains no extraneous information).
|
|
464
|
+
const change =
|
|
465
|
+
postProcessor === undefined ? squash : postProcessor.processChange(squash);
|
|
466
|
+
|
|
467
|
+
if (change !== squash) {
|
|
468
|
+
// The post-processor produced a change that differs from the
|
|
469
|
+
// one that was applied to the view as the transaction's edits
|
|
470
|
+
// were made. Roll back the transaction's changes on the transaction
|
|
471
|
+
// branch (which rolls back the view) and apply the post-processed
|
|
472
|
+
// change in their place so that the view fully reflects the modified
|
|
473
|
+
// `change`.
|
|
474
|
+
transactionBranch.removeAfter(startHead);
|
|
475
|
+
transactionBranch.apply(tagChange(change, transactionRevision));
|
|
476
|
+
}
|
|
360
477
|
|
|
361
478
|
if (targetPath.length === 0) {
|
|
362
479
|
// No changes were made on the original branch since the transaction began
|
|
363
480
|
// The transaction commit can be applied directly
|
|
364
|
-
this.branch.apply(tagChange(
|
|
481
|
+
this.branch.apply(tagChange(change, transactionRevision));
|
|
365
482
|
// The view is already up-to-date so there's nothing more to do
|
|
366
483
|
} else {
|
|
367
484
|
// Some changes were made on `branch` since the transaction began
|
|
368
485
|
const unrebasedHead = mintCommit(startHead, {
|
|
369
|
-
change
|
|
486
|
+
change,
|
|
370
487
|
revision: transactionRevision,
|
|
371
488
|
});
|
|
372
489
|
// We need to rebase the transaction commit on top of the new changes
|
|
@@ -407,13 +524,17 @@ export class SquashingTransactionStack<
|
|
|
407
524
|
outerOnPop?.(result, viewUpdate);
|
|
408
525
|
};
|
|
409
526
|
// Invoked when a nested transaction begins
|
|
410
|
-
const onNestedTransactionPush: OnPush = (
|
|
527
|
+
const onNestedTransactionPush: OnPush<SquashingTransactionOptions<TChange>> = (
|
|
528
|
+
nestedStartOptions,
|
|
529
|
+
) => {
|
|
530
|
+
postProcessorStack.push(resolvePostProcessor(nestedStartOptions?.postProcessor));
|
|
411
531
|
const nestedStartHead = this.activeBranch.getHead();
|
|
412
532
|
const nestedOuterOnPop = onPush?.();
|
|
413
533
|
transactionBranch.editor.enterTransaction();
|
|
414
534
|
return {
|
|
415
535
|
// Invoked when a nested transaction ends
|
|
416
536
|
onPop: (result) => {
|
|
537
|
+
const nestedPostProcessor = postProcessorStack.pop();
|
|
417
538
|
transactionBranch.editor.exitTransaction();
|
|
418
539
|
switch (result) {
|
|
419
540
|
case TransactionResult.Abort: {
|
|
@@ -422,6 +543,32 @@ export class SquashingTransactionStack<
|
|
|
422
543
|
break;
|
|
423
544
|
}
|
|
424
545
|
case TransactionResult.Commit: {
|
|
546
|
+
// When this nested transaction supplied a post-processor that should be applied here, squash its
|
|
547
|
+
// edits into a single (post-processed) commit on the transaction branch rather than leaving them to
|
|
548
|
+
// be squashed only when the outermost transaction is committed.
|
|
549
|
+
if (nestedPostProcessor !== undefined) {
|
|
550
|
+
const nestedSteps: GraphCommit<TChange>[] = [];
|
|
551
|
+
findAncestor(
|
|
552
|
+
[transactionBranch.getHead(), nestedSteps],
|
|
553
|
+
(c) => c === nestedStartHead,
|
|
554
|
+
);
|
|
555
|
+
if (nestedSteps.length > 0) {
|
|
556
|
+
assert(
|
|
557
|
+
transactionRevision !== undefined,
|
|
558
|
+
0xd07 /* Expected transaction revision in the presence of transaction steps */,
|
|
559
|
+
);
|
|
560
|
+
const squash = rebaser.compose(nestedSteps);
|
|
561
|
+
const processedSquash = nestedPostProcessor.processChange(squash);
|
|
562
|
+
// Roll back the transaction branch to the nested start head and apply the
|
|
563
|
+
// processed change if it differs from the original change.
|
|
564
|
+
if (processedSquash !== squash) {
|
|
565
|
+
transactionBranch.removeAfter(nestedStartHead);
|
|
566
|
+
transactionBranch.apply(
|
|
567
|
+
tagChange(processedSquash, transactionRevision),
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
425
572
|
break;
|
|
426
573
|
}
|
|
427
574
|
default: {
|
|
@@ -100,7 +100,7 @@ export {
|
|
|
100
100
|
export type { TreeSchemaEncodingOptions } from "./getJsonSchema.js";
|
|
101
101
|
export { getJsonSchema } from "./getJsonSchema.js";
|
|
102
102
|
export { getSimpleSchema } from "./getSimpleSchema.js";
|
|
103
|
-
export {
|
|
103
|
+
export { checkSchemaCompatibility } from "./schemaCompatibilityTester.js";
|
|
104
104
|
export type {
|
|
105
105
|
Unenforced,
|
|
106
106
|
FieldSchemaAlphaUnsafe,
|
|
@@ -179,19 +179,23 @@ export {
|
|
|
179
179
|
} from "./storedSchema.js";
|
|
180
180
|
|
|
181
181
|
export {
|
|
182
|
+
type NoChangeConstraint,
|
|
183
|
+
type NodeInDocumentConstraint,
|
|
184
|
+
rollback,
|
|
185
|
+
type RunTransactionParamsAlpha,
|
|
186
|
+
type RunTransactionParamsBeta,
|
|
187
|
+
type TransactionCallbackStatusAlpha,
|
|
188
|
+
type TransactionCallbackStatusBeta,
|
|
182
189
|
type TransactionConstraint,
|
|
183
190
|
type TransactionConstraintAlpha,
|
|
184
|
-
type
|
|
185
|
-
type NoChangeConstraint,
|
|
186
|
-
type RunTransactionParams,
|
|
187
|
-
type VoidTransactionCallbackStatus,
|
|
188
|
-
type TransactionCallbackStatus,
|
|
189
|
-
type TransactionResult,
|
|
190
|
-
type TransactionResultExt,
|
|
191
|
-
type TransactionResultSuccess,
|
|
191
|
+
type TransactionPostProcessor,
|
|
192
192
|
type TransactionResultFailed,
|
|
193
|
+
type TransactionResultSuccess,
|
|
194
|
+
type TransactionValueResult,
|
|
195
|
+
type TransactionVoidResult,
|
|
196
|
+
type VoidTransactionCallbackStatusAlpha,
|
|
197
|
+
type VoidTransactionCallbackStatusBeta,
|
|
193
198
|
type WithValue,
|
|
194
|
-
rollback,
|
|
195
199
|
} from "./transactionTypes.js";
|
|
196
200
|
|
|
197
201
|
export { generateSchemaFromSimpleSchema } from "./schemaFromSimple.js";
|
|
@@ -12,58 +12,46 @@ import { getDiscrepanciesInAllowedContent } from "./discrepancies.js";
|
|
|
12
12
|
import type { SchemaCompatibilityStatus } from "./tree.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Determines the compatibility of a stored document
|
|
16
|
+
* (based on its stored schema) with a viewer (based on its view schema).
|
|
17
|
+
*
|
|
16
18
|
* @remarks
|
|
17
|
-
*
|
|
19
|
+
* Adapters can be provided to handle differences between the two schema.
|
|
20
|
+
* Adapters should only use to types in the `view` SchemaRepository.
|
|
21
|
+
*
|
|
22
|
+
* TODO: this API violates the parse don't validate design philosophy.
|
|
23
|
+
* It should be wrapped with (or replaced by) a parse style API.
|
|
18
24
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*/
|
|
37
|
-
public checkCompatibility(
|
|
38
|
-
stored: TreeStoredSchema,
|
|
39
|
-
): Omit<SchemaCompatibilityStatus, "canInitialize"> {
|
|
40
|
-
// The public API surface assumes defaultSchemaPolicy
|
|
41
|
-
const policy = defaultSchemaPolicy;
|
|
42
|
-
|
|
43
|
-
// View schema allows a subset of documents that stored schema does, and the discrepancies are allowed by policy
|
|
44
|
-
// determined by the view schema (i.e. objects with extra optional fields in the stored schema have opted into allowing this.
|
|
45
|
-
// In the future, this would also include things like:
|
|
46
|
-
// - fields with more allowed types in the stored schema than in the view schema have out-of-schema "unknown content" adapters
|
|
47
|
-
let canView = true;
|
|
48
|
-
|
|
49
|
-
for (const _discrepancy of getDiscrepanciesInAllowedContent(this.viewSchema, stored)) {
|
|
50
|
-
canView = false;
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
25
|
+
export function checkSchemaCompatibility(
|
|
26
|
+
viewSchema: TreeSchema,
|
|
27
|
+
stored: TreeStoredSchema,
|
|
28
|
+
): Omit<SchemaCompatibilityStatus, "canInitialize"> {
|
|
29
|
+
// The public API surface assumes defaultSchemaPolicy
|
|
30
|
+
const policy = defaultSchemaPolicy;
|
|
31
|
+
|
|
32
|
+
// View schema allows a subset of documents that stored schema does, and the discrepancies are allowed by policy
|
|
33
|
+
// determined by the view schema (i.e. objects with extra optional fields in the stored schema have opted into allowing this.
|
|
34
|
+
// In the future, this would also include things like:
|
|
35
|
+
// - fields with more allowed types in the stored schema than in the view schema have out-of-schema "unknown content" adapters
|
|
36
|
+
let canView = true;
|
|
37
|
+
|
|
38
|
+
for (const _discrepancy of getDiscrepanciesInAllowedContent(viewSchema, stored)) {
|
|
39
|
+
canView = false;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
53
42
|
|
|
54
|
-
|
|
43
|
+
const wouldUpgradeTo = toUpgradeSchema(viewSchema.root);
|
|
55
44
|
|
|
56
|
-
|
|
45
|
+
const canUpgrade = allowsRepoSuperset(policy, stored, wouldUpgradeTo);
|
|
57
46
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
// If true, then upgrading has no effect on what can be stored in the document.
|
|
48
|
+
// TODO: This should likely be changed to indicate up a schema upgrade would be a no-op, including stored schema metadata.
|
|
49
|
+
const isEquivalent =
|
|
50
|
+
canView && canUpgrade && allowsRepoSuperset(policy, wouldUpgradeTo, stored);
|
|
62
51
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
52
|
+
return {
|
|
53
|
+
canView,
|
|
54
|
+
canUpgrade,
|
|
55
|
+
isEquivalent,
|
|
56
|
+
};
|
|
69
57
|
}
|
|
@@ -78,7 +78,7 @@ export function singletonSchema<TScope extends string, TName extends string | nu
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* Converts an enum into a collection of
|
|
81
|
+
* Converts an enum into a collection of schemas which can be used in a union.
|
|
82
82
|
*
|
|
83
83
|
* @typeParam TScope - The scope of the provided factory.
|
|
84
84
|
* There is a known issue where if a factory is provided that is typed as a {@link SchemaFactoryAlpha}, and its scope contains a "." character,
|
|
@@ -88,7 +88,7 @@ export function singletonSchema<TScope extends string, TName extends string | nu
|
|
|
88
88
|
* @remarks
|
|
89
89
|
* The string value of the enum is used as the name of the schema: callers must ensure that it is stable and unique.
|
|
90
90
|
* Numeric enums values have the value implicitly converted into a string.
|
|
91
|
-
* Consider making a dedicated schema factory with a nested scope (for example using {@link SchemaFactoryBeta.scopedFactory}) to avoid the enum members colliding with other
|
|
91
|
+
* Consider making a dedicated schema factory with a nested scope (for example using {@link SchemaFactoryBeta.scopedFactory}) to avoid the enum members colliding with other schemas.
|
|
92
92
|
* @example
|
|
93
93
|
* ```typescript
|
|
94
94
|
* const schemaFactory = new SchemaFactory("com.myApp");
|
|
@@ -213,7 +213,7 @@ export function enumEntries(
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
/**
|
|
216
|
-
* Converts an array of distinct strings into a collection of
|
|
216
|
+
* Converts an array of distinct strings into a collection of schemas which can be used like an enum style union.
|
|
217
217
|
* @remarks
|
|
218
218
|
* The returned collection is also a function which can be used to convert strings into {@link Unhydrated} nodes in the union.
|
|
219
219
|
* Each node type has a `.value` getter which returns the associated string.
|
|
@@ -339,7 +339,7 @@ export class SchemaFactory<
|
|
|
339
339
|
/**
|
|
340
340
|
* Construct a SchemaFactory with a given {@link SchemaFactory.scope|scope}.
|
|
341
341
|
* @remarks
|
|
342
|
-
* There are no restrictions on mixing
|
|
342
|
+
* There are no restrictions on mixing schemas from different schema factories.
|
|
343
343
|
* Typically each library will create one or more SchemaFactories and use them to define its schema.
|
|
344
344
|
*/
|
|
345
345
|
public constructor(
|
|
@@ -698,7 +698,7 @@ export class SchemaFactory<
|
|
|
698
698
|
const same = compareSets({ a: inputTypes, b: outputTypes });
|
|
699
699
|
if (!same) {
|
|
700
700
|
throw new UsageError(
|
|
701
|
-
`Structurally named schema collision: two
|
|
701
|
+
`Structurally named schema collision: two schemas named "${fullName}" were defined with different input schemas.`,
|
|
702
702
|
);
|
|
703
703
|
}
|
|
704
704
|
return structural;
|
|
@@ -80,6 +80,8 @@ import type {
|
|
|
80
80
|
* Values should be preferred over generator functions when possible, as they are simpler and more efficient.
|
|
81
81
|
* Generator functions should be used when the default value needs to be dynamic or when it is not possible to provide a value directly.
|
|
82
82
|
*
|
|
83
|
+
* See {@link SchemaStaticsAlpha.withDefault} for the primary API that uses this type.
|
|
84
|
+
*
|
|
83
85
|
* @example
|
|
84
86
|
* ```typescript
|
|
85
87
|
* // Provide a value directly
|
|
@@ -102,27 +104,63 @@ export type NodeProvider<T> = T | (() => T);
|
|
|
102
104
|
*/
|
|
103
105
|
export interface SchemaStaticsAlpha {
|
|
104
106
|
/**
|
|
105
|
-
* Creates a field schema with a default value.
|
|
106
|
-
*
|
|
107
|
+
* Creates a field schema with a default value.
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
* Fields with defaults are optional in constructors, allowing them to be omitted when creating new nodes.
|
|
111
|
+
* This works with both {@link SchemaStatics.required | required} and {@link SchemaStatics.optional | optional} fields:
|
|
112
|
+
*
|
|
113
|
+
* - **Required fields with defaults**: The field is always present in the tree, but can be omitted from the constructor.
|
|
114
|
+
* The default value is used when the field is not provided.
|
|
115
|
+
*
|
|
116
|
+
* - **Optional fields with defaults**: Optional fields already default to `undefined`, but `withDefault` lets you
|
|
117
|
+
* specify a different default value.
|
|
118
|
+
*
|
|
119
|
+
* The default value can be provided in two ways (see {@link NodeProvider}):
|
|
120
|
+
*
|
|
121
|
+
* 1. **A value**: The value is deep-copied for each use, ensuring independence between instances.
|
|
122
|
+
* Prefer this when the default is a fixed value.
|
|
123
|
+
*
|
|
124
|
+
* 2. **A generator function**: A function called each time a default is needed. Use this for dynamic defaults
|
|
125
|
+
* (e.g., timestamps, UUIDs) or when explicit control over value creation is required.
|
|
126
|
+
*
|
|
127
|
+
* Defaults are evaluated eagerly during node construction.
|
|
128
|
+
*
|
|
129
|
+
* For recursive schemas, use {@link SchemaStaticsAlpha.withDefaultRecursive} instead.
|
|
130
|
+
*
|
|
131
|
+
* See the {@link https://fluidframework.com/docs/data-structures/tree/schema-definition/default-field-values | Default Field Values documentation}
|
|
132
|
+
* for a comprehensive guide with additional examples.
|
|
107
133
|
*
|
|
108
134
|
* @param fieldSchema - The field schema to add a default to (e.g., `factory.required(factory.string)` or `factory.optional(factory.number)`)
|
|
109
135
|
* @param defaultValue - A {@link NodeProvider} specifying the default value.
|
|
110
136
|
*
|
|
111
137
|
* @example
|
|
138
|
+
* A schema with a mix of required, defaulted, and dynamic fields:
|
|
112
139
|
* ```typescript
|
|
113
|
-
* const
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* //
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
140
|
+
* const factory = new SchemaFactoryAlpha("example");
|
|
141
|
+
*
|
|
142
|
+
* class Task extends factory.objectAlpha("Task", {
|
|
143
|
+
* // No default — must always be provided in the constructor
|
|
144
|
+
* title: factory.required(factory.string),
|
|
145
|
+
*
|
|
146
|
+
* // Required field with a static default
|
|
147
|
+
* status: factory.withDefault(factory.required(factory.string), "todo"),
|
|
148
|
+
*
|
|
149
|
+
* // Optional field with a custom default (instead of `undefined`)
|
|
150
|
+
* priority: factory.withDefault(factory.optional(factory.number), 0),
|
|
151
|
+
*
|
|
152
|
+
* // Dynamic default using a generator function
|
|
153
|
+
* createdAt: factory.withDefault(factory.required(factory.number), () => Date.now()),
|
|
154
|
+
* }) {}
|
|
155
|
+
*
|
|
156
|
+
* // Only `title` is required in the constructor; the rest use their defaults
|
|
157
|
+
* const task = new Task({ title: "Write docs" });
|
|
158
|
+
* // task.status === "todo"
|
|
159
|
+
* // task.priority === 0
|
|
160
|
+
* // task.createdAt is set to the current timestamp
|
|
161
|
+
*
|
|
162
|
+
* // Defaults can be overridden by providing explicit values
|
|
163
|
+
* const urgentTask = new Task({ title: "Fix bug", status: "in-progress", priority: 1 });
|
|
126
164
|
* ```
|
|
127
165
|
*
|
|
128
166
|
* @privateRemarks
|
|
@@ -208,6 +246,9 @@ export interface SchemaStaticsAlpha {
|
|
|
208
246
|
* @remarks
|
|
209
247
|
* This version of {@link SchemaStaticsAlpha.withDefault} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
|
|
210
248
|
* See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
|
|
249
|
+
*
|
|
250
|
+
* See the {@link https://fluidframework.com/docs/data-structures/tree/schema-definition/default-field-values#recursive-types | Default Field Values — Recursive Types documentation}
|
|
251
|
+
* for usage examples and guidance on avoiding infinite recursion with recursive defaults.
|
|
211
252
|
*/
|
|
212
253
|
withDefaultRecursive: <
|
|
213
254
|
Kind extends FieldKind,
|
|
@@ -94,9 +94,6 @@ export interface SchemaStaticsBeta {
|
|
|
94
94
|
* A full code example of the schema migration process can be found in our {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/src/test/simple-tree/api/stagedSchemaUpgrade.spec.ts | tests}.
|
|
95
95
|
*
|
|
96
96
|
* @privateRemarks
|
|
97
|
-
* TODO:#44317 staged allowed types rely on schema validation of stored schema to output errors, these errors are not very
|
|
98
|
-
* user friendly and should be improved, particularly in the case of staged allowed types
|
|
99
|
-
*
|
|
100
97
|
* TODO: AB#45711: Update the docs above when recursive type support is added.
|
|
101
98
|
*/
|
|
102
99
|
readonly staged: <const T extends LazyItem<TreeNodeSchema>>(
|
|
@@ -13,7 +13,7 @@ import { toInitialSchema } from "../toStoredSchema.js";
|
|
|
13
13
|
import { createTreeSchema } from "../treeSchema.js";
|
|
14
14
|
|
|
15
15
|
import { TreeViewConfigurationAlpha, TreeViewConfiguration } from "./configuration.js";
|
|
16
|
-
import {
|
|
16
|
+
import { checkSchemaCompatibility } from "./schemaCompatibilityTester.js";
|
|
17
17
|
import { generateSchemaFromSimpleSchema } from "./schemaFromSimple.js";
|
|
18
18
|
import {
|
|
19
19
|
decodeSchemaCompatibilitySnapshot,
|
|
@@ -78,8 +78,7 @@ export function checkCompatibility(
|
|
|
78
78
|
): Omit<SchemaCompatibilityStatus, "canInitialize"> {
|
|
79
79
|
const viewAsAlpha = new TreeViewConfigurationAlpha({ schema: view.schema });
|
|
80
80
|
const stored = toInitialSchema(viewWhichCreatedStoredSchema.schema);
|
|
81
|
-
|
|
82
|
-
return tester.checkCompatibility(stored);
|
|
81
|
+
return checkSchemaCompatibility(viewAsAlpha, stored);
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
/**
|
|
@@ -422,11 +421,11 @@ export interface SnapshotSchemaCompatibilityOptions {
|
|
|
422
421
|
* Libraries which export schema for use by others will need to take special care to ensure the stability contract they offer their users aligns which what is validated by this utility.
|
|
423
422
|
*
|
|
424
423
|
* This utility only tests compatibility of the historical snapshots against the current schema; it does not test them against each-other.
|
|
425
|
-
* Generally any historical
|
|
424
|
+
* Generally any historical schemas should have been tested against the ones before them at the time they were current.
|
|
426
425
|
* If for some reason a version of a schema made it into production that was not compatible with a previous version,
|
|
427
426
|
* that can still be represented here (but may require manually generating a snapshot for that version)
|
|
428
427
|
* and this will still allow testing that all historical version can be upgraded to the current one.
|
|
429
|
-
* If a sufficiently incompatible historical
|
|
428
|
+
* If a sufficiently incompatible historical schemas were used in production, it may be impossible to make a single schema which can accommodate all of them:
|
|
430
429
|
* this utility can be used to confirm that is the case, as well as to avoid the problem in the first place by testing schema before each one is deployed.
|
|
431
430
|
*
|
|
432
431
|
* @example Mocha test which validates the current `config` can collaborate with all historical version back to 2.0.0, and load and update any versions older than that.
|