@fluidframework/tree 2.1.0-276985 → 2.1.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/.eslintrc.cjs +7 -0
- package/.vscode/Tree.code-workspace +9 -2
- package/CHANGELOG.md +38 -0
- package/README.md +55 -12
- package/api-report/tree.alpha.api.md +2 -1
- package/api-report/tree.beta.api.md +2 -1
- package/api-report/tree.public.api.md +2 -1
- package/beta.d.ts +1 -1
- package/dist/beta.d.ts +1 -1
- package/dist/core/forest/editableForest.d.ts +6 -3
- package/dist/core/forest/editableForest.d.ts.map +1 -1
- package/dist/core/forest/editableForest.js +16 -4
- package/dist/core/forest/editableForest.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -1
- 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 +3 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +2 -0
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +9 -1
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts +1 -0
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +13 -0
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +48 -11
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +144 -20
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodec.js +13 -4
- package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormat.d.ts +1 -1
- package/dist/core/tree/detachedFieldIndexFormat.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormat.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexTypes.d.ts +39 -4
- package/dist/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
- package/dist/core/tree/index.d.ts +2 -1
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/visitDelta.d.ts +3 -1
- package/dist/core/tree/visitDelta.d.ts.map +1 -1
- package/dist/core/tree/visitDelta.js +31 -15
- package/dist/core/tree/visitDelta.js.map +1 -1
- package/dist/core/tree/visitorUtils.d.ts +3 -3
- package/dist/core/tree/visitorUtils.d.ts.map +1 -1
- package/dist/core/tree/visitorUtils.js +4 -4
- package/dist/core/tree/visitorUtils.js.map +1 -1
- package/dist/events/events.d.ts +4 -1
- package/dist/events/events.d.ts.map +1 -1
- package/dist/events/events.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/editableTreeBinder.js +1 -1
- package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +1 -10
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +0 -72
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -51
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js +0 -2
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +3 -2
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js +5 -1
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +1 -2
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +1 -6
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +11 -32
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +1 -5
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +0 -30
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +1 -1
- 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 +6 -3
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +11 -0
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/dist/feature-libraries/modular-schema/discrepancies.d.ts +96 -0
- package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/discrepancies.js +264 -0
- package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -0
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -2
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +3 -0
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +2 -1
- 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/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +42 -26
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +51 -2
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +827 -245
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js +2 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +44 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/node-key/index.d.ts +0 -1
- package/dist/feature-libraries/node-key/index.d.ts.map +1 -1
- package/dist/feature-libraries/node-key/index.js +1 -3
- package/dist/feature-libraries/node-key/index.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.d.ts +3 -2
- package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +5 -4
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +1 -0
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/sequence-field/index.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/index.js +1 -2
- package/dist/feature-libraries/sequence-field/index.js.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.js +1 -1
- package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
- package/dist/feature-libraries/sequence-field/rebase.js +6 -1
- package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +1 -0
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.d.ts +2 -17
- package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +31 -39
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +1 -0
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js +2 -0
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
- package/dist/index.d.ts +1 -1
- 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.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +4 -2
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +240 -184
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +5 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +157 -90
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.js +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/dist/shared-tree/treeApi.js +1 -1
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +10 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +47 -3
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree/treeView.d.ts.map +1 -1
- package/dist/shared-tree/treeView.js +7 -3
- package/dist/shared-tree/treeView.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +6 -0
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +3 -0
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +8 -6
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +271 -209
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +4 -0
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +36 -19
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/index.d.ts +3 -3
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +2 -1
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +22 -1
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +2 -1
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +2 -1
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/proxies.d.ts.map +1 -1
- package/dist/simple-tree/proxies.js +9 -25
- package/dist/simple-tree/proxies.js.map +1 -1
- package/dist/simple-tree/proxyBinding.d.ts +4 -0
- package/dist/simple-tree/proxyBinding.d.ts.map +1 -1
- package/dist/simple-tree/proxyBinding.js +23 -1
- package/dist/simple-tree/proxyBinding.js.map +1 -1
- package/dist/simple-tree/schemaFactory.d.ts +16 -1
- package/dist/simple-tree/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/schemaFactory.js +32 -4
- package/dist/simple-tree/schemaFactory.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +36 -1
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toFlexSchema.d.ts +2 -2
- package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/dist/simple-tree/toFlexSchema.js +3 -2
- package/dist/simple-tree/toFlexSchema.js.map +1 -1
- package/dist/simple-tree/tree.d.ts +4 -1
- package/dist/simple-tree/tree.d.ts.map +1 -1
- package/dist/simple-tree/tree.js +48 -1
- package/dist/simple-tree/tree.js.map +1 -1
- package/dist/simple-tree/treeNodeApi.d.ts +2 -75
- package/dist/simple-tree/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeApi.js +17 -25
- package/dist/simple-tree/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/treeNodeKernel.d.ts +26 -0
- package/dist/simple-tree/treeNodeKernel.d.ts.map +1 -0
- package/dist/simple-tree/treeNodeKernel.js +83 -0
- package/dist/simple-tree/treeNodeKernel.js.map +1 -0
- package/dist/simple-tree/types.d.ts +95 -3
- package/dist/simple-tree/types.d.ts.map +1 -1
- package/dist/simple-tree/types.js +120 -21
- package/dist/simple-tree/types.js.map +1 -1
- package/dist/util/breakable.d.ts +83 -0
- package/dist/util/breakable.d.ts.map +1 -0
- package/dist/util/breakable.js +178 -0
- package/dist/util/breakable.js.map +1 -0
- package/dist/util/index.d.ts +3 -2
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +9 -2
- package/dist/util/index.js.map +1 -1
- package/dist/util/nestedMap.d.ts +17 -3
- package/dist/util/nestedMap.d.ts.map +1 -1
- package/dist/util/nestedMap.js +21 -1
- package/dist/util/nestedMap.js.map +1 -1
- package/dist/util/utils.d.ts +7 -0
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +15 -1
- package/dist/util/utils.js.map +1 -1
- package/internal.d.ts +1 -1
- package/lib/beta.d.ts +1 -1
- package/lib/core/forest/editableForest.d.ts +6 -3
- package/lib/core/forest/editableForest.d.ts.map +1 -1
- package/lib/core/forest/editableForest.js +17 -5
- package/lib/core/forest/editableForest.js.map +1 -1
- package/lib/core/index.d.ts +1 -1
- 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 +2 -0
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +7 -1
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts +1 -0
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +13 -0
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +48 -11
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +145 -21
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodec.js +13 -4
- package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormat.d.ts +1 -1
- package/lib/core/tree/detachedFieldIndexFormat.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormat.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexTypes.d.ts +39 -4
- package/lib/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
- package/lib/core/tree/index.d.ts +2 -1
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/visitDelta.d.ts +3 -1
- package/lib/core/tree/visitDelta.d.ts.map +1 -1
- package/lib/core/tree/visitDelta.js +31 -15
- package/lib/core/tree/visitDelta.js.map +1 -1
- package/lib/core/tree/visitorUtils.d.ts +3 -3
- package/lib/core/tree/visitorUtils.d.ts.map +1 -1
- package/lib/core/tree/visitorUtils.js +4 -4
- package/lib/core/tree/visitorUtils.js.map +1 -1
- package/lib/events/events.d.ts +4 -1
- package/lib/events/events.d.ts.map +1 -1
- package/lib/events/events.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/editableTreeBinder.js +1 -1
- package/lib/feature-libraries/editableTreeBinder.js.map +1 -1
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +1 -10
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +2 -74
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -51
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -2
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +3 -2
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js +2 -1
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +1 -2
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +1 -6
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +13 -34
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +1 -5
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +3 -33
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +1 -1
- 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 +3 -3
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +11 -0
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/lib/feature-libraries/modular-schema/discrepancies.d.ts +96 -0
- package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/discrepancies.js +260 -0
- package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -0
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -2
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +3 -0
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +2 -1
- 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/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +42 -26
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +51 -2
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +826 -247
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js +2 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +44 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/node-key/index.d.ts +0 -1
- package/lib/feature-libraries/node-key/index.d.ts.map +1 -1
- package/lib/feature-libraries/node-key/index.js +0 -1
- package/lib/feature-libraries/node-key/index.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.d.ts +3 -2
- package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +5 -4
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +1 -0
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/sequence-field/index.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/index.js +1 -1
- package/lib/feature-libraries/sequence-field/index.js.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.js +1 -1
- package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
- package/lib/feature-libraries/sequence-field/rebase.js +6 -1
- package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +2 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.d.ts +2 -17
- package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +31 -39
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +1 -0
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js +4 -2
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
- package/lib/index.d.ts +1 -1
- 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.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +4 -2
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +242 -185
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +5 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +158 -90
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.js +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/lib/shared-tree/treeApi.js +1 -1
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +10 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +47 -3
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree/treeView.d.ts.map +1 -1
- package/lib/shared-tree/treeView.js +4 -0
- package/lib/shared-tree/treeView.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +6 -0
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +3 -0
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +8 -6
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +273 -210
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +4 -0
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +39 -22
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/index.d.ts +3 -3
- 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/leafNodeSchema.d.ts +22 -1
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +1 -1
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +3 -2
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/proxies.d.ts.map +1 -1
- package/lib/simple-tree/proxies.js +9 -25
- package/lib/simple-tree/proxies.js.map +1 -1
- package/lib/simple-tree/proxyBinding.d.ts +4 -0
- package/lib/simple-tree/proxyBinding.d.ts.map +1 -1
- package/lib/simple-tree/proxyBinding.js +19 -0
- package/lib/simple-tree/proxyBinding.js.map +1 -1
- package/lib/simple-tree/schemaFactory.d.ts +16 -1
- package/lib/simple-tree/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/schemaFactory.js +30 -3
- package/lib/simple-tree/schemaFactory.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +36 -1
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toFlexSchema.d.ts +2 -2
- package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/lib/simple-tree/toFlexSchema.js +3 -2
- package/lib/simple-tree/toFlexSchema.js.map +1 -1
- package/lib/simple-tree/tree.d.ts +4 -1
- package/lib/simple-tree/tree.d.ts.map +1 -1
- package/lib/simple-tree/tree.js +44 -0
- package/lib/simple-tree/tree.js.map +1 -1
- package/lib/simple-tree/treeNodeApi.d.ts +2 -75
- package/lib/simple-tree/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeApi.js +20 -28
- package/lib/simple-tree/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/treeNodeKernel.d.ts +26 -0
- package/lib/simple-tree/treeNodeKernel.d.ts.map +1 -0
- package/lib/simple-tree/treeNodeKernel.js +79 -0
- package/lib/simple-tree/treeNodeKernel.js.map +1 -0
- package/lib/simple-tree/types.d.ts +95 -3
- package/lib/simple-tree/types.d.ts.map +1 -1
- package/lib/simple-tree/types.js +121 -22
- package/lib/simple-tree/types.js.map +1 -1
- package/lib/util/breakable.d.ts +83 -0
- package/lib/util/breakable.d.ts.map +1 -0
- package/lib/util/breakable.js +171 -0
- package/lib/util/breakable.js.map +1 -0
- package/lib/util/index.d.ts +3 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +3 -2
- package/lib/util/index.js.map +1 -1
- package/lib/util/nestedMap.d.ts +17 -3
- package/lib/util/nestedMap.d.ts.map +1 -1
- package/lib/util/nestedMap.js +19 -0
- package/lib/util/nestedMap.js.map +1 -1
- package/lib/util/utils.d.ts +7 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +13 -0
- package/lib/util/utils.js.map +1 -1
- package/package.json +29 -27
- package/src/core/forest/editableForest.ts +25 -4
- package/src/core/index.ts +2 -0
- package/src/core/rebase/index.ts +2 -0
- package/src/core/rebase/types.ts +17 -0
- package/src/core/tree/anchorSet.ts +14 -0
- package/src/core/tree/detachedFieldIndex.ts +217 -35
- package/src/core/tree/detachedFieldIndexCodec.ts +17 -8
- package/src/core/tree/detachedFieldIndexFormat.ts +1 -1
- package/src/core/tree/detachedFieldIndexTypes.ts +41 -5
- package/src/core/tree/index.ts +2 -1
- package/src/core/tree/visitDelta.ts +58 -16
- package/src/core/tree/visitorUtils.ts +7 -4
- package/src/events/events.ts +4 -2
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +1 -1
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -0
- package/src/feature-libraries/editableTreeBinder.ts +1 -1
- package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +1 -95
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +0 -62
- package/src/feature-libraries/flex-tree/index.ts +7 -2
- package/src/feature-libraries/flex-tree/lazyEntity.ts +0 -3
- package/src/feature-libraries/flex-tree/lazyField.ts +15 -47
- package/src/feature-libraries/flex-tree/lazyNode.ts +1 -48
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -0
- package/src/feature-libraries/index.ts +4 -2
- package/src/feature-libraries/modular-schema/crossFieldQueries.ts +18 -0
- package/src/feature-libraries/modular-schema/discrepancies.ts +395 -0
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +10 -2
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +3 -0
- package/src/feature-libraries/modular-schema/index.ts +2 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +81 -35
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +1521 -444
- package/src/feature-libraries/modular-schema/modularChangeFormat.ts +2 -0
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +51 -0
- package/src/feature-libraries/node-key/index.ts +0 -1
- package/src/feature-libraries/object-forest/objectForest.ts +7 -3
- package/src/feature-libraries/optional-field/optionalField.ts +1 -0
- package/src/feature-libraries/sequence-field/index.ts +0 -2
- package/src/feature-libraries/sequence-field/invert.ts +1 -1
- package/src/feature-libraries/sequence-field/rebase.ts +7 -1
- package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +2 -1
- package/src/feature-libraries/sequence-field/utils.ts +37 -85
- package/src/feature-libraries/typed-schema/typedTreeSchema.ts +10 -0
- package/src/index.ts +0 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +6 -2
- package/src/shared-tree/sharedTree.ts +12 -1
- package/src/shared-tree/sharedTreeChangeEnricher.ts +1 -1
- package/src/shared-tree/treeApi.ts +1 -1
- package/src/shared-tree/treeCheckout.ts +60 -5
- package/src/shared-tree/treeView.ts +5 -0
- package/src/shared-tree-core/branch.ts +10 -0
- package/src/shared-tree-core/sharedTreeCore.ts +25 -6
- package/src/simple-tree/arrayNode.ts +50 -23
- package/src/simple-tree/index.ts +3 -3
- package/src/simple-tree/leafNodeSchema.ts +1 -1
- package/src/simple-tree/mapNode.ts +2 -2
- package/src/simple-tree/objectNode.ts +9 -3
- package/src/simple-tree/proxies.ts +10 -33
- package/src/simple-tree/proxyBinding.ts +23 -0
- package/src/simple-tree/schemaFactory.ts +37 -2
- package/src/simple-tree/schemaTypes.ts +36 -1
- package/src/simple-tree/toFlexSchema.ts +5 -4
- package/src/simple-tree/tree.ts +68 -4
- package/src/simple-tree/treeNodeApi.ts +29 -111
- package/src/simple-tree/treeNodeKernel.ts +91 -0
- package/src/simple-tree/types.ts +292 -31
- package/src/util/breakable.ts +214 -0
- package/src/util/index.ts +11 -0
- package/src/util/nestedMap.ts +33 -3
- package/src/util/utils.ts +17 -0
- package/dist/feature-libraries/node-key/nodeKeyIndex.d.ts +0 -41
- package/dist/feature-libraries/node-key/nodeKeyIndex.d.ts.map +0 -1
- package/dist/feature-libraries/node-key/nodeKeyIndex.js +0 -101
- package/dist/feature-libraries/node-key/nodeKeyIndex.js.map +0 -1
- package/lib/feature-libraries/node-key/nodeKeyIndex.d.ts +0 -41
- package/lib/feature-libraries/node-key/nodeKeyIndex.d.ts.map +0 -1
- package/lib/feature-libraries/node-key/nodeKeyIndex.js +0 -97
- package/lib/feature-libraries/node-key/nodeKeyIndex.js.map +0 -1
- package/src/feature-libraries/node-key/nodeKeyIndex.ts +0 -132
|
@@ -130,6 +130,7 @@ export {
|
|
|
130
130
|
type FieldChangeEncodingContext,
|
|
131
131
|
type FieldKindConfiguration,
|
|
132
132
|
type FieldKindConfigurationEntry,
|
|
133
|
+
getAllowedContentIncompatibilities,
|
|
133
134
|
} from "./modular-schema/index.js";
|
|
134
135
|
|
|
135
136
|
export {
|
|
@@ -203,7 +204,6 @@ export {
|
|
|
203
204
|
isStableNodeKey,
|
|
204
205
|
type LocalNodeKey,
|
|
205
206
|
MockNodeKeyManager,
|
|
206
|
-
NodeKeyIndex,
|
|
207
207
|
type NodeKeyManager,
|
|
208
208
|
nodeKeyTreeIdentifier,
|
|
209
209
|
type StableNodeKey,
|
|
@@ -267,7 +267,6 @@ export {
|
|
|
267
267
|
type FlexTreeUnboxField,
|
|
268
268
|
type FlexTreeUnboxNode,
|
|
269
269
|
type FlexTreeUnboxNodeUnion,
|
|
270
|
-
type FlexTreeNodeKeyField,
|
|
271
270
|
type IsArrayOfOne,
|
|
272
271
|
type FlexibleNodeSubSequence,
|
|
273
272
|
flexTreeMarker,
|
|
@@ -281,6 +280,9 @@ export {
|
|
|
281
280
|
assertFlexTreeEntityNotFreed,
|
|
282
281
|
flexTreeSlot,
|
|
283
282
|
getSchemaAndPolicy,
|
|
283
|
+
isFreedSymbol,
|
|
284
|
+
LazyEntity,
|
|
285
|
+
treeStatusFromAnchorCache,
|
|
284
286
|
} from "./flex-tree/index.js";
|
|
285
287
|
|
|
286
288
|
export { treeSchemaFromStoredSchema } from "./storedToViewSchema.js";
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getOrAddInMap,
|
|
12
12
|
setInRangeMap,
|
|
13
13
|
} from "../../util/index.js";
|
|
14
|
+
import type { NodeId } from "./modularChangeTypes.js";
|
|
14
15
|
|
|
15
16
|
export type CrossFieldMap<T> = Map<RevisionTag | undefined, RangeMap<T>>;
|
|
16
17
|
export type CrossFieldQuerySet = CrossFieldMap<boolean>;
|
|
@@ -82,4 +83,21 @@ export interface CrossFieldManager<T = unknown> {
|
|
|
82
83
|
newValue: T,
|
|
83
84
|
invalidateDependents: boolean,
|
|
84
85
|
): void;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* This must be called whenever a new node is moved into this field as part of the current rebase, compose, or invert.
|
|
89
|
+
* Calling this for a node which was already in the field is tolerated.
|
|
90
|
+
*/
|
|
91
|
+
onMoveIn(id: NodeId): void;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* This must be called whenever a new cross field key is moved into this field as part of the current rebase or compose.
|
|
95
|
+
* Calling this for a key which was already in the field is tolerated.
|
|
96
|
+
*/
|
|
97
|
+
moveKey(
|
|
98
|
+
target: CrossFieldTarget,
|
|
99
|
+
revision: RevisionTag | undefined,
|
|
100
|
+
id: ChangesetLocalId,
|
|
101
|
+
count: number,
|
|
102
|
+
): void;
|
|
85
103
|
}
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
type FieldKey,
|
|
10
|
+
type FieldKindIdentifier,
|
|
11
|
+
LeafNodeStoredSchema,
|
|
12
|
+
MapNodeStoredSchema,
|
|
13
|
+
ObjectNodeStoredSchema,
|
|
14
|
+
type TreeFieldStoredSchema,
|
|
15
|
+
type TreeNodeSchemaIdentifier,
|
|
16
|
+
type TreeStoredSchema,
|
|
17
|
+
type TreeTypeSet,
|
|
18
|
+
type ValueSchema,
|
|
19
|
+
} from "../../core/index.js";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @remarks
|
|
23
|
+
*
|
|
24
|
+
* 1. FieldIncompatibility
|
|
25
|
+
*
|
|
26
|
+
* `FieldIncompatibility` represents the differences between two `TreeFieldStoredSchema` objects. It consists of
|
|
27
|
+
* three types of incompatibilities:
|
|
28
|
+
*
|
|
29
|
+
* - FieldKindIncompatibility: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`
|
|
30
|
+
* objects (e.g., optional, required, sequence, etc.).
|
|
31
|
+
* - AllowedTypesIncompatibility: Indicates the differences in the allowed child types between the two schemas.
|
|
32
|
+
* - ValueSchemaIncompatibility: Specifically indicates the differences in the `ValueSchema` of two
|
|
33
|
+
* `LeafNodeStoredSchema` objects.
|
|
34
|
+
*
|
|
35
|
+
* 2. NodeIncompatibility
|
|
36
|
+
*
|
|
37
|
+
* `NodeIncompatibility` represents the differences between two `TreeNodeStoredSchema` objects and includes:
|
|
38
|
+
*
|
|
39
|
+
* - NodeKindIncompatibility: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports
|
|
40
|
+
* `ObjectNodeStoredSchema`, `MapNodeStoredSchema`, and `LeafNodeStoredSchema`).
|
|
41
|
+
* - NodeFieldsIncompatibility: Indicates the `FieldIncompatibility` of `TreeFieldStoredSchema` within two
|
|
42
|
+
* `TreeNodeStoredSchema`. It includes an array of `FieldIncompatibility` instances in the `differences` field.
|
|
43
|
+
*
|
|
44
|
+
* When comparing two nodes for compatibility, it only makes sense to compare their fields if the nodes are of
|
|
45
|
+
* the same kind (map, object, leaf).
|
|
46
|
+
*
|
|
47
|
+
* 3. Incompatibility
|
|
48
|
+
*
|
|
49
|
+
* Incompatibility consists of both `NodeIncompatibility` and `FieldIncompatibility`, representing any kind of
|
|
50
|
+
* schema differences. See {@link getAllowedContentIncompatibilities} for more details about how we process it
|
|
51
|
+
* and the ordering.
|
|
52
|
+
*/
|
|
53
|
+
export type Incompatibility = FieldIncompatibility | NodeIncompatibility;
|
|
54
|
+
|
|
55
|
+
export type NodeIncompatibility = NodeKindIncompatibility | NodeFieldsIncompatibility;
|
|
56
|
+
|
|
57
|
+
export type FieldIncompatibility =
|
|
58
|
+
| AllowedTypeIncompatibility
|
|
59
|
+
| FieldKindIncompatibility
|
|
60
|
+
| ValueSchemaIncompatibility;
|
|
61
|
+
|
|
62
|
+
export interface AllowedTypeIncompatibility {
|
|
63
|
+
identifier: string | undefined; // undefined indicates root field schema
|
|
64
|
+
mismatch: "allowedTypes";
|
|
65
|
+
/**
|
|
66
|
+
* List of allowed type identifiers in viewed schema
|
|
67
|
+
*/
|
|
68
|
+
view: string[];
|
|
69
|
+
/**
|
|
70
|
+
* List of allowed type identifiers in stored schema
|
|
71
|
+
*/
|
|
72
|
+
stored: string[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface FieldKindIncompatibility {
|
|
76
|
+
identifier: string | undefined; // undefined indicates root field schema
|
|
77
|
+
mismatch: "fieldKind";
|
|
78
|
+
view: FieldKindIdentifier | undefined;
|
|
79
|
+
stored: FieldKindIdentifier | undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ValueSchemaIncompatibility {
|
|
83
|
+
identifier: string;
|
|
84
|
+
mismatch: "valueSchema";
|
|
85
|
+
view: ValueSchema | undefined;
|
|
86
|
+
stored: ValueSchema | undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface NodeKindIncompatibility {
|
|
90
|
+
identifier: string;
|
|
91
|
+
mismatch: "nodeKind";
|
|
92
|
+
view: SchemaFactoryNodeKind | undefined;
|
|
93
|
+
stored: SchemaFactoryNodeKind | undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface NodeFieldsIncompatibility {
|
|
97
|
+
identifier: string;
|
|
98
|
+
mismatch: "fields";
|
|
99
|
+
differences: FieldIncompatibility[];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
type SchemaFactoryNodeKind = "object" | "leaf" | "map";
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @remarks
|
|
106
|
+
*
|
|
107
|
+
* The workflow for finding schema incompatibilities:
|
|
108
|
+
* 1. Compare the two root schemas to identify any `FieldIncompatibility`.
|
|
109
|
+
*
|
|
110
|
+
* 2. For each node schema in the `view`:
|
|
111
|
+
* - Verify if the node schema exists in the stored. If it does, ensure that the `SchemaFactoryNodeKind` are
|
|
112
|
+
* consistent. Otherwise this difference is treated as `NodeKindIncompatibility`
|
|
113
|
+
* - If a node schema with the same identifier exists in both view and stored, and their `SchemaFactoryNodeKind`
|
|
114
|
+
* are consistent, perform a exhaustive validation to identify all `FieldIncompatibility`.
|
|
115
|
+
*
|
|
116
|
+
* 3. For each node schema in the stored, verify if it exists in the view. The overlapping parts were already
|
|
117
|
+
* addressed in the previous step.
|
|
118
|
+
*
|
|
119
|
+
* @returns the discrepancies between two TreeStoredSchema objects
|
|
120
|
+
*/
|
|
121
|
+
export function getAllowedContentIncompatibilities(
|
|
122
|
+
view: TreeStoredSchema,
|
|
123
|
+
stored: TreeStoredSchema,
|
|
124
|
+
): Incompatibility[] {
|
|
125
|
+
const incompatibilities: Incompatibility[] = [];
|
|
126
|
+
|
|
127
|
+
// check root schema discrepancies
|
|
128
|
+
incompatibilities.push(
|
|
129
|
+
...trackFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema),
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
// Verify the existence and type of a node schema given its identifier (key), then determine if
|
|
133
|
+
// an exhaustive search is necessary.
|
|
134
|
+
const viewNodeKeys = new Set<TreeNodeSchemaIdentifier>();
|
|
135
|
+
for (const [key, viewNodeSchema] of view.nodeSchema) {
|
|
136
|
+
viewNodeKeys.add(key);
|
|
137
|
+
|
|
138
|
+
if (viewNodeSchema instanceof ObjectNodeStoredSchema) {
|
|
139
|
+
if (!stored.nodeSchema.has(key)) {
|
|
140
|
+
incompatibilities.push({
|
|
141
|
+
identifier: key,
|
|
142
|
+
mismatch: "nodeKind",
|
|
143
|
+
view: "object",
|
|
144
|
+
stored: undefined,
|
|
145
|
+
});
|
|
146
|
+
} else {
|
|
147
|
+
const storedNodeSchema = stored.nodeSchema.get(key);
|
|
148
|
+
assert(
|
|
149
|
+
storedNodeSchema !== undefined,
|
|
150
|
+
0x9be /* The storedNodeSchema in stored.nodeSchema should not be undefined */,
|
|
151
|
+
);
|
|
152
|
+
if (storedNodeSchema instanceof MapNodeStoredSchema) {
|
|
153
|
+
incompatibilities.push({
|
|
154
|
+
identifier: key,
|
|
155
|
+
mismatch: "nodeKind",
|
|
156
|
+
view: "object",
|
|
157
|
+
stored: "map",
|
|
158
|
+
} satisfies NodeKindIncompatibility);
|
|
159
|
+
} else if (storedNodeSchema instanceof LeafNodeStoredSchema) {
|
|
160
|
+
incompatibilities.push({
|
|
161
|
+
identifier: key,
|
|
162
|
+
mismatch: "nodeKind",
|
|
163
|
+
view: "object",
|
|
164
|
+
stored: "leaf",
|
|
165
|
+
} satisfies NodeKindIncompatibility);
|
|
166
|
+
} else if (storedNodeSchema instanceof ObjectNodeStoredSchema) {
|
|
167
|
+
const differences = trackObjectNodeDiscrepancies(viewNodeSchema, storedNodeSchema);
|
|
168
|
+
if (differences.length > 0) {
|
|
169
|
+
incompatibilities.push({
|
|
170
|
+
identifier: key,
|
|
171
|
+
mismatch: "fields",
|
|
172
|
+
differences,
|
|
173
|
+
} satisfies NodeFieldsIncompatibility);
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
throwUnsupportedNodeType(storedNodeSchema.constructor.name);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} else if (viewNodeSchema instanceof MapNodeStoredSchema) {
|
|
180
|
+
if (!stored.nodeSchema.has(key)) {
|
|
181
|
+
incompatibilities.push({
|
|
182
|
+
identifier: key,
|
|
183
|
+
mismatch: "nodeKind",
|
|
184
|
+
view: "map",
|
|
185
|
+
stored: undefined,
|
|
186
|
+
} satisfies NodeKindIncompatibility);
|
|
187
|
+
} else {
|
|
188
|
+
const storedNodeSchema = stored.nodeSchema.get(key);
|
|
189
|
+
assert(
|
|
190
|
+
storedNodeSchema !== undefined,
|
|
191
|
+
0x9bf /* The storedNodeSchema in stored.nodeSchema should not be undefined */,
|
|
192
|
+
);
|
|
193
|
+
if (storedNodeSchema instanceof ObjectNodeStoredSchema) {
|
|
194
|
+
incompatibilities.push({
|
|
195
|
+
identifier: key,
|
|
196
|
+
mismatch: "nodeKind",
|
|
197
|
+
view: "map",
|
|
198
|
+
stored: "object",
|
|
199
|
+
} satisfies NodeKindIncompatibility);
|
|
200
|
+
} else if (storedNodeSchema instanceof LeafNodeStoredSchema) {
|
|
201
|
+
incompatibilities.push({
|
|
202
|
+
identifier: key,
|
|
203
|
+
mismatch: "nodeKind",
|
|
204
|
+
view: "map",
|
|
205
|
+
stored: "leaf",
|
|
206
|
+
} satisfies NodeKindIncompatibility);
|
|
207
|
+
} else if (storedNodeSchema instanceof MapNodeStoredSchema) {
|
|
208
|
+
incompatibilities.push(
|
|
209
|
+
...trackFieldDiscrepancies(
|
|
210
|
+
viewNodeSchema.mapFields,
|
|
211
|
+
storedNodeSchema.mapFields,
|
|
212
|
+
key,
|
|
213
|
+
),
|
|
214
|
+
);
|
|
215
|
+
} else {
|
|
216
|
+
throwUnsupportedNodeType(storedNodeSchema.constructor.name);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
} else if (viewNodeSchema instanceof LeafNodeStoredSchema) {
|
|
220
|
+
if (!stored.nodeSchema.has(key)) {
|
|
221
|
+
incompatibilities.push({
|
|
222
|
+
identifier: key,
|
|
223
|
+
mismatch: "nodeKind",
|
|
224
|
+
view: "leaf",
|
|
225
|
+
stored: undefined,
|
|
226
|
+
});
|
|
227
|
+
} else {
|
|
228
|
+
const storedNodeSchema = stored.nodeSchema.get(key);
|
|
229
|
+
assert(
|
|
230
|
+
storedNodeSchema !== undefined,
|
|
231
|
+
0x9c0 /* The storedNodeSchema in stored.nodeSchema should not be undefined */,
|
|
232
|
+
);
|
|
233
|
+
if (storedNodeSchema instanceof MapNodeStoredSchema) {
|
|
234
|
+
incompatibilities.push({
|
|
235
|
+
identifier: key,
|
|
236
|
+
mismatch: "nodeKind",
|
|
237
|
+
view: "leaf",
|
|
238
|
+
stored: "map",
|
|
239
|
+
} satisfies NodeKindIncompatibility);
|
|
240
|
+
} else if (storedNodeSchema instanceof ObjectNodeStoredSchema) {
|
|
241
|
+
incompatibilities.push({
|
|
242
|
+
identifier: key,
|
|
243
|
+
mismatch: "nodeKind",
|
|
244
|
+
view: "leaf",
|
|
245
|
+
stored: "object",
|
|
246
|
+
} satisfies NodeKindIncompatibility);
|
|
247
|
+
} else if (storedNodeSchema instanceof LeafNodeStoredSchema) {
|
|
248
|
+
if (viewNodeSchema.leafValue !== storedNodeSchema.leafValue) {
|
|
249
|
+
incompatibilities.push({
|
|
250
|
+
identifier: key,
|
|
251
|
+
mismatch: "valueSchema",
|
|
252
|
+
view: viewNodeSchema.leafValue,
|
|
253
|
+
stored: storedNodeSchema.leafValue,
|
|
254
|
+
} satisfies ValueSchemaIncompatibility);
|
|
255
|
+
}
|
|
256
|
+
} else {
|
|
257
|
+
throwUnsupportedNodeType(storedNodeSchema.constructor.name);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
throwUnsupportedNodeType(viewNodeSchema.constructor.name);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
for (const [key, storedNodeSchema] of stored.nodeSchema) {
|
|
266
|
+
if (!viewNodeKeys.has(key)) {
|
|
267
|
+
incompatibilities.push({
|
|
268
|
+
identifier: key,
|
|
269
|
+
mismatch: "nodeKind",
|
|
270
|
+
view: undefined,
|
|
271
|
+
stored:
|
|
272
|
+
storedNodeSchema instanceof MapNodeStoredSchema
|
|
273
|
+
? "map"
|
|
274
|
+
: storedNodeSchema instanceof ObjectNodeStoredSchema
|
|
275
|
+
? "object"
|
|
276
|
+
: "leaf",
|
|
277
|
+
} satisfies NodeKindIncompatibility);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return incompatibilities;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* The function to track the discrepancies between two field stored schemas.
|
|
286
|
+
*
|
|
287
|
+
* @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.
|
|
288
|
+
*/
|
|
289
|
+
function trackFieldDiscrepancies(
|
|
290
|
+
view: TreeFieldStoredSchema,
|
|
291
|
+
stored: TreeFieldStoredSchema,
|
|
292
|
+
keyOrRoot?: string,
|
|
293
|
+
): FieldIncompatibility[] {
|
|
294
|
+
const differences: FieldIncompatibility[] = [];
|
|
295
|
+
|
|
296
|
+
// Only track the intersection of the two sets.
|
|
297
|
+
const findSetDiscrepancies = (
|
|
298
|
+
a: TreeTypeSet,
|
|
299
|
+
b: TreeTypeSet,
|
|
300
|
+
): [TreeNodeSchemaIdentifier[], TreeNodeSchemaIdentifier[]] => {
|
|
301
|
+
if (a === undefined && b === undefined) {
|
|
302
|
+
return [[], []];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (a !== undefined && b !== undefined) {
|
|
306
|
+
const aDiff = [...a].filter((value) => !b.has(value));
|
|
307
|
+
const bDiff = [...b].filter((value) => !a.has(value));
|
|
308
|
+
return [aDiff, bDiff];
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (a !== undefined) {
|
|
312
|
+
return [[...a], []];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
316
|
+
return [[], [...b!]];
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const allowedTypesDiscrepancies = findSetDiscrepancies(view.types, stored.types);
|
|
320
|
+
if (allowedTypesDiscrepancies[0].length > 0 || allowedTypesDiscrepancies[1].length > 0) {
|
|
321
|
+
differences.push({
|
|
322
|
+
identifier: keyOrRoot,
|
|
323
|
+
mismatch: "allowedTypes",
|
|
324
|
+
view: allowedTypesDiscrepancies[0],
|
|
325
|
+
stored: allowedTypesDiscrepancies[1],
|
|
326
|
+
} satisfies AllowedTypeIncompatibility);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (view.kind !== stored.kind) {
|
|
330
|
+
differences.push({
|
|
331
|
+
identifier: keyOrRoot,
|
|
332
|
+
mismatch: "fieldKind",
|
|
333
|
+
view: view.kind,
|
|
334
|
+
stored: stored.kind,
|
|
335
|
+
} satisfies FieldKindIncompatibility);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return differences;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function trackObjectNodeDiscrepancies(
|
|
342
|
+
view: ObjectNodeStoredSchema,
|
|
343
|
+
stored: ObjectNodeStoredSchema,
|
|
344
|
+
): FieldIncompatibility[] {
|
|
345
|
+
const differences: FieldIncompatibility[] = [];
|
|
346
|
+
const viewFieldKeys = new Set<FieldKey>();
|
|
347
|
+
/**
|
|
348
|
+
* Similar to the logic used for tracking discrepancies between two node schemas, we will identify
|
|
349
|
+
* three types of differences:
|
|
350
|
+
* 1. Fields that exist in the view schema but not in the stored schema.
|
|
351
|
+
* 2. Fields that exist in both schemas but have different contents.
|
|
352
|
+
* 3. Fields that exist in the stored schema but not in the view schema.
|
|
353
|
+
*
|
|
354
|
+
* First, the view schema is iterated to track the first two types of differences.
|
|
355
|
+
* Then, the stored schema is iterated to find the third type.
|
|
356
|
+
*/
|
|
357
|
+
|
|
358
|
+
for (const [fieldKey, fieldStoredSchema] of view.objectNodeFields) {
|
|
359
|
+
viewFieldKeys.add(fieldKey);
|
|
360
|
+
if (!stored.objectNodeFields.has(fieldKey)) {
|
|
361
|
+
differences.push({
|
|
362
|
+
identifier: fieldKey,
|
|
363
|
+
mismatch: "fieldKind",
|
|
364
|
+
view: fieldStoredSchema.kind,
|
|
365
|
+
stored: undefined,
|
|
366
|
+
} satisfies FieldKindIncompatibility);
|
|
367
|
+
} else {
|
|
368
|
+
differences.push(
|
|
369
|
+
...trackFieldDiscrepancies(
|
|
370
|
+
view.objectNodeFields.get(fieldKey) as TreeFieldStoredSchema,
|
|
371
|
+
stored.objectNodeFields.get(fieldKey) as TreeFieldStoredSchema,
|
|
372
|
+
fieldKey,
|
|
373
|
+
),
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
for (const [fieldKey, fieldStoredSchema] of stored.objectNodeFields) {
|
|
379
|
+
if (viewFieldKeys.has(fieldKey)) {
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
differences.push({
|
|
383
|
+
identifier: fieldKey,
|
|
384
|
+
mismatch: "fieldKind",
|
|
385
|
+
view: undefined,
|
|
386
|
+
stored: fieldStoredSchema.kind,
|
|
387
|
+
} satisfies FieldKindIncompatibility);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return differences;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function throwUnsupportedNodeType(type: string): never {
|
|
394
|
+
throw new TypeError(`Unsupported node stored schema type: ${type}`);
|
|
395
|
+
}
|
|
@@ -17,7 +17,7 @@ import type { IdAllocator, Invariant } from "../../util/index.js";
|
|
|
17
17
|
import type { MemoizedIdRangeAllocator } from "../memoizedIdRangeAllocator.js";
|
|
18
18
|
|
|
19
19
|
import type { CrossFieldManager } from "./crossFieldQueries.js";
|
|
20
|
-
import type { NodeId } from "./modularChangeTypes.js";
|
|
20
|
+
import type { CrossFieldKeyRange, NodeId } from "./modularChangeTypes.js";
|
|
21
21
|
import type { EncodedNodeChangeset } from "./modularChangeFormat.js";
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -83,13 +83,21 @@ export interface FieldChangeHandler<
|
|
|
83
83
|
*/
|
|
84
84
|
getNestedChanges(change: TChangeset): [NodeId, number | undefined][];
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* @returns A list of all cross-field keys contained in the change.
|
|
88
|
+
* This should not include cross-field keys in descendant fields.
|
|
89
|
+
*/
|
|
90
|
+
getCrossFieldKeys(change: TChangeset): CrossFieldKeyRange[];
|
|
91
|
+
|
|
86
92
|
createEmpty(): TChangeset;
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
export interface FieldChangeRebaser<TChangeset> {
|
|
90
96
|
/**
|
|
91
97
|
* Compose a collection of changesets into a single one.
|
|
92
|
-
*
|
|
98
|
+
* For each node which has a change in both changesets, `composeChild` must be called
|
|
99
|
+
* and the result used as the composite node change.
|
|
100
|
+
* Calling `composeChild` when one of the changesets has no node change is unnecessary but tolerated.
|
|
93
101
|
* See `ChangeRebaser` for more details.
|
|
94
102
|
*/
|
|
95
103
|
compose(
|
|
@@ -103,6 +103,7 @@ export const genericChangeHandler: FieldChangeHandler<GenericChangeset> = {
|
|
|
103
103
|
isEmpty: (change: GenericChangeset): boolean => change.length === 0,
|
|
104
104
|
getNestedChanges,
|
|
105
105
|
createEmpty: (): GenericChangeset => [],
|
|
106
|
+
getCrossFieldKeys: (_change) => [],
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
function getNestedChanges(change: GenericChangeset): [NodeId, number | undefined][] {
|
|
@@ -227,6 +228,8 @@ const invalidFunc = (): never => fail("Should not be called when converting gene
|
|
|
227
228
|
const invalidCrossFieldManager: CrossFieldManager = {
|
|
228
229
|
set: invalidFunc,
|
|
229
230
|
get: invalidFunc,
|
|
231
|
+
onMoveIn: invalidFunc,
|
|
232
|
+
moveKey: invalidFunc,
|
|
230
233
|
};
|
|
231
234
|
|
|
232
235
|
export function newGenericChangeset(): GenericChangeset {
|
|
@@ -43,6 +43,7 @@ export {
|
|
|
43
43
|
type FieldChangeEncodingContext,
|
|
44
44
|
} from "./fieldChangeHandler.js";
|
|
45
45
|
export type {
|
|
46
|
+
CrossFieldKeyRange,
|
|
46
47
|
FieldChange,
|
|
47
48
|
FieldChangeMap,
|
|
48
49
|
FieldChangeset,
|
|
@@ -73,3 +74,4 @@ export type {
|
|
|
73
74
|
FieldKindConfiguration,
|
|
74
75
|
FieldKindConfigurationEntry,
|
|
75
76
|
} from "./fieldKindConfiguration.js";
|
|
77
|
+
export { getAllowedContentIncompatibilities } from "./discrepancies.js";
|
|
@@ -61,11 +61,13 @@ import {
|
|
|
61
61
|
import type {
|
|
62
62
|
FieldChangeMap,
|
|
63
63
|
FieldChangeset,
|
|
64
|
+
FieldId,
|
|
64
65
|
ModularChangeset,
|
|
65
66
|
NodeChangeset,
|
|
66
67
|
NodeId,
|
|
67
68
|
} from "./modularChangeTypes.js";
|
|
68
|
-
import type { FieldChangeEncodingContext } from "./fieldChangeHandler.js";
|
|
69
|
+
import type { FieldChangeEncodingContext, FieldChangeHandler } from "./fieldChangeHandler.js";
|
|
70
|
+
import { newCrossFieldKeyTable } from "./modularChangeFamily.js";
|
|
69
71
|
|
|
70
72
|
export function makeModularChangeCodecFamily(
|
|
71
73
|
fieldKindConfigurations: ReadonlyMap<number, FieldKindConfiguration>,
|
|
@@ -228,33 +230,10 @@ function makeModularChangeCodec(
|
|
|
228
230
|
|
|
229
231
|
function decodeFieldChangesFromJson(
|
|
230
232
|
encodedChange: EncodedFieldChangeMap,
|
|
233
|
+
parentId: NodeId | undefined,
|
|
234
|
+
decoded: ModularChangeset,
|
|
231
235
|
context: ChangeEncodingContext,
|
|
232
236
|
idAllocator: IdAllocator,
|
|
233
|
-
): [FieldChangeMap, ChangeAtomIdMap<NodeChangeset>] {
|
|
234
|
-
const decodedNodes: ChangeAtomIdMap<NodeChangeset> = new Map();
|
|
235
|
-
const fieldContext: FieldChangeEncodingContext = {
|
|
236
|
-
baseContext: context,
|
|
237
|
-
|
|
238
|
-
encodeNode: () => fail("Should not encode nodes during field decoding"),
|
|
239
|
-
|
|
240
|
-
decodeNode: (encodedNode: EncodedNodeChangeset): NodeId => {
|
|
241
|
-
const node = decodeNodeChangesetFromJson(encodedNode, fieldContext);
|
|
242
|
-
const nodeId: NodeId = {
|
|
243
|
-
revision: context.revision,
|
|
244
|
-
localId: brand(idAllocator.allocate()),
|
|
245
|
-
};
|
|
246
|
-
setInNestedMap(decodedNodes, nodeId.revision, nodeId.localId, node);
|
|
247
|
-
return nodeId;
|
|
248
|
-
},
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
const decodedFields = decodeFieldChangesFromJsonI(encodedChange, fieldContext);
|
|
252
|
-
return [decodedFields, decodedNodes];
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function decodeFieldChangesFromJsonI(
|
|
256
|
-
encodedChange: EncodedFieldChangeMap,
|
|
257
|
-
context: FieldChangeEncodingContext,
|
|
258
237
|
): FieldChangeMap {
|
|
259
238
|
const decodedFields: FieldChangeMap = new Map();
|
|
260
239
|
for (const field of encodedChange) {
|
|
@@ -262,7 +241,46 @@ function makeModularChangeCodec(
|
|
|
262
241
|
if (compiledSchema !== undefined && !compiledSchema.check(field.change)) {
|
|
263
242
|
fail("Encoded change didn't pass schema validation.");
|
|
264
243
|
}
|
|
265
|
-
|
|
244
|
+
|
|
245
|
+
const fieldId: FieldId = {
|
|
246
|
+
nodeId: parentId,
|
|
247
|
+
field: field.fieldKey,
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const fieldContext: FieldChangeEncodingContext = {
|
|
251
|
+
baseContext: context,
|
|
252
|
+
|
|
253
|
+
encodeNode: () => fail("Should not encode nodes during field decoding"),
|
|
254
|
+
|
|
255
|
+
decodeNode: (encodedNode: EncodedNodeChangeset): NodeId => {
|
|
256
|
+
const nodeId: NodeId = {
|
|
257
|
+
revision: context.revision,
|
|
258
|
+
localId: brand(idAllocator.allocate()),
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
const node = decodeNodeChangesetFromJson(
|
|
262
|
+
encodedNode,
|
|
263
|
+
nodeId,
|
|
264
|
+
decoded,
|
|
265
|
+
context,
|
|
266
|
+
idAllocator,
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
setInNestedMap(decoded.nodeChanges, nodeId.revision, nodeId.localId, node);
|
|
270
|
+
setInNestedMap(decoded.nodeToParent, nodeId.revision, nodeId.localId, fieldId);
|
|
271
|
+
return nodeId;
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const fieldChangeset = codec.json.decode(field.change, fieldContext);
|
|
276
|
+
|
|
277
|
+
const crossFieldKeys = getChangeHandler(fieldKinds, field.fieldKind).getCrossFieldKeys(
|
|
278
|
+
fieldChangeset,
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
for (const crossFieldKey of crossFieldKeys) {
|
|
282
|
+
decoded.crossFieldKeys.set(crossFieldKey, fieldId);
|
|
283
|
+
}
|
|
266
284
|
|
|
267
285
|
const fieldKey: FieldKey = brand<FieldKey>(field.fieldKey);
|
|
268
286
|
|
|
@@ -277,13 +295,22 @@ function makeModularChangeCodec(
|
|
|
277
295
|
|
|
278
296
|
function decodeNodeChangesetFromJson(
|
|
279
297
|
encodedChange: EncodedNodeChangeset,
|
|
280
|
-
|
|
298
|
+
id: NodeId,
|
|
299
|
+
decoded: ModularChangeset,
|
|
300
|
+
context: ChangeEncodingContext,
|
|
301
|
+
idAllocator: IdAllocator,
|
|
281
302
|
): NodeChangeset {
|
|
282
303
|
const decodedChange: NodeChangeset = {};
|
|
283
304
|
const { fieldChanges, nodeExistsConstraint } = encodedChange;
|
|
284
305
|
|
|
285
306
|
if (fieldChanges !== undefined) {
|
|
286
|
-
decodedChange.fieldChanges =
|
|
307
|
+
decodedChange.fieldChanges = decodeFieldChangesFromJson(
|
|
308
|
+
fieldChanges,
|
|
309
|
+
id,
|
|
310
|
+
decoded,
|
|
311
|
+
context,
|
|
312
|
+
idAllocator,
|
|
313
|
+
);
|
|
287
314
|
}
|
|
288
315
|
|
|
289
316
|
if (nodeExistsConstraint !== undefined) {
|
|
@@ -434,21 +461,27 @@ function makeModularChangeCodec(
|
|
|
434
461
|
},
|
|
435
462
|
|
|
436
463
|
decode: (encodedChange: EncodedModularChangeset, context) => {
|
|
437
|
-
const
|
|
464
|
+
const decoded: Mutable<ModularChangeset> = {
|
|
465
|
+
fieldChanges: new Map(),
|
|
466
|
+
nodeChanges: new Map(),
|
|
467
|
+
nodeToParent: new Map(),
|
|
468
|
+
nodeAliases: new Map(),
|
|
469
|
+
crossFieldKeys: newCrossFieldKeyTable(),
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
decoded.fieldChanges = decodeFieldChangesFromJson(
|
|
438
473
|
encodedChange.changes,
|
|
474
|
+
undefined,
|
|
475
|
+
decoded,
|
|
439
476
|
context,
|
|
440
477
|
idAllocatorFromMaxId(encodedChange.maxId),
|
|
441
478
|
);
|
|
442
|
-
const decoded: Mutable<ModularChangeset> = {
|
|
443
|
-
fieldChanges,
|
|
444
|
-
nodeChanges,
|
|
445
|
-
};
|
|
446
479
|
|
|
447
480
|
if (encodedChange.builds !== undefined) {
|
|
448
481
|
decoded.builds = decodeDetachedNodes(encodedChange.builds, context);
|
|
449
482
|
}
|
|
450
483
|
if (encodedChange.refreshers !== undefined) {
|
|
451
|
-
decoded.refreshers = decodeDetachedNodes(encodedChange.
|
|
484
|
+
decoded.refreshers = decodeDetachedNodes(encodedChange.refreshers, context);
|
|
452
485
|
}
|
|
453
486
|
|
|
454
487
|
if (encodedChange.violations !== undefined) {
|
|
@@ -468,3 +501,16 @@ function makeModularChangeCodec(
|
|
|
468
501
|
|
|
469
502
|
return withSchemaValidation(EncodedModularChangeset, modularChangeCodec, validator);
|
|
470
503
|
}
|
|
504
|
+
|
|
505
|
+
function getChangeHandler(
|
|
506
|
+
fieldKinds: FieldKindConfiguration,
|
|
507
|
+
fieldKind: FieldKindIdentifier,
|
|
508
|
+
): FieldChangeHandler<unknown> {
|
|
509
|
+
if (fieldKind === genericFieldKind.identifier) {
|
|
510
|
+
return genericFieldKind.changeHandler;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const handler = fieldKinds.get(fieldKind)?.kind.changeHandler;
|
|
514
|
+
assert(handler !== undefined, 0x9c1 /* Unknown field kind */);
|
|
515
|
+
return handler;
|
|
516
|
+
}
|