@fluidframework/tree 2.41.0 → 2.42.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 +33 -0
- package/api-report/tree.alpha.api.md +11 -7
- package/dist/alpha.d.ts +1 -0
- package/dist/codec/codec.d.ts +23 -3
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +35 -2
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +38 -3
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +2 -2
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +5 -1
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/mapTree.d.ts +2 -1
- package/dist/core/tree/mapTree.d.ts.map +1 -1
- package/dist/core/tree/mapTree.js +11 -5
- package/dist/core/tree/mapTree.js.map +1 -1
- package/dist/core/tree/visitorUtils.d.ts +2 -2
- package/dist/core/tree/visitorUtils.d.ts.map +1 -1
- package/dist/core/tree/visitorUtils.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -2
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts +4 -3
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js +4 -3
- package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts +14 -6
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +34 -14
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js +4 -0
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +2 -2
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +6 -6
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +3 -2
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +3 -0
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +7 -7
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +2 -2
- 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/mapTreeCursor.d.ts +39 -3
- package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.js +45 -7
- package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +5 -5
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.d.ts +5 -1
- package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +8 -2
- package/dist/feature-libraries/treeCursorUtils.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.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +11 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +36 -22
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +3 -3
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +1 -0
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/tree.d.ts.map +1 -1
- package/dist/shared-tree/tree.js +8 -24
- package/dist/shared-tree/tree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +2 -3
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +13 -15
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +5 -2
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +2 -2
- package/dist/simple-tree/api/configuration.js +1 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +9 -4
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +29 -16
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +4 -0
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +9 -1
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +1 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +10 -2
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +38 -9
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts +14 -3
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +32 -17
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +12 -9
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js +2 -1
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +2 -2
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +3 -4
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +15 -25
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +26 -33
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +128 -59
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +169 -182
- package/dist/simple-tree/core/unhydratedFlexTree.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 +5 -5
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +5 -6
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/index.js +1 -2
- package/dist/simple-tree/node-kinds/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.js +1 -2
- package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +3 -14
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +12 -43
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts +20 -6
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/dist/simple-tree/prepareForInsertion.js +26 -19
- package/dist/simple-tree/prepareForInsertion.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +8 -8
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts +6 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +6 -3
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/{toMapTree.d.ts → unhydratedFlexTreeFromInsertable.d.ts} +12 -23
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -0
- package/dist/simple-tree/{toMapTree.js → unhydratedFlexTreeFromInsertable.js} +103 -185
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -0
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +6 -1
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +2 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/utils.d.ts +4 -0
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +8 -1
- package/dist/util/utils.js.map +1 -1
- package/docs/user-facing/schema-evolution.md +1 -1
- package/lib/alpha.d.ts +1 -0
- package/lib/codec/codec.d.ts +23 -3
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/codec/versioned/codec.d.ts +35 -2
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +36 -2
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +2 -2
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +6 -2
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/mapTree.d.ts +2 -1
- package/lib/core/tree/mapTree.d.ts.map +1 -1
- package/lib/core/tree/mapTree.js +11 -5
- package/lib/core/tree/mapTree.js.map +1 -1
- package/lib/core/tree/visitorUtils.d.ts +2 -2
- package/lib/core/tree/visitorUtils.d.ts.map +1 -1
- package/lib/core/tree/visitorUtils.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -2
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts +4 -3
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js +4 -3
- package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts +14 -6
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +34 -14
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js +4 -0
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +2 -2
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +6 -6
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +3 -2
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +3 -0
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +2 -2
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.d.ts +39 -3
- package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.js +43 -7
- package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +5 -5
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.d.ts +5 -1
- package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +8 -2
- package/lib/feature-libraries/treeCursorUtils.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.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +11 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +34 -21
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +3 -3
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +2 -1
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/tree.d.ts.map +1 -1
- package/lib/shared-tree/tree.js +2 -18
- package/lib/shared-tree/tree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +2 -3
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +4 -6
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +6 -3
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +2 -2
- package/lib/simple-tree/api/configuration.js +1 -1
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +9 -4
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +22 -9
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +4 -0
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +7 -0
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- 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/schemaFactory.d.ts +10 -2
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +40 -11
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts +14 -3
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +35 -20
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +13 -10
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js +3 -2
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +2 -2
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +2 -2
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +15 -25
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +24 -32
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +128 -59
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +166 -181
- package/lib/simple-tree/core/unhydratedFlexTree.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 +3 -3
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +4 -5
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/index.js +1 -1
- package/lib/simple-tree/node-kinds/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +3 -3
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.js +1 -1
- package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +3 -14
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +3 -33
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts +20 -6
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/lib/simple-tree/prepareForInsertion.js +25 -19
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +8 -8
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts +6 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +4 -1
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/{toMapTree.d.ts → unhydratedFlexTreeFromInsertable.d.ts} +12 -23
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -0
- package/lib/simple-tree/{toMapTree.js → unhydratedFlexTreeFromInsertable.js} +105 -186
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -0
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +6 -1
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/utils.d.ts +4 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +6 -0
- package/lib/util/utils.js.map +1 -1
- package/package.json +21 -21
- package/src/codec/codec.ts +24 -3
- package/src/codec/index.ts +1 -0
- package/src/codec/versioned/codec.ts +42 -5
- package/src/core/tree/detachedFieldIndex.ts +13 -4
- package/src/core/tree/mapTree.ts +22 -7
- package/src/core/tree/visitorUtils.ts +2 -2
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +3 -2
- package/src/feature-libraries/default-schema/schemaChecker.ts +7 -6
- package/src/feature-libraries/flex-tree/context.ts +17 -7
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +36 -15
- package/src/feature-libraries/flex-tree/index.ts +4 -0
- package/src/feature-libraries/flex-tree/lazyField.ts +8 -6
- package/src/feature-libraries/flex-tree/lazyNode.ts +6 -2
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +3 -2
- package/src/feature-libraries/index.ts +9 -0
- package/src/feature-libraries/mapTreeCursor.ts +103 -16
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +9 -5
- package/src/feature-libraries/treeCursorUtils.ts +21 -10
- package/src/index.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +40 -22
- package/src/shared-tree/sharedTree.ts +9 -3
- package/src/shared-tree/tree.ts +5 -20
- package/src/shared-tree/treeAlpha.ts +17 -11
- package/src/shared-tree/treeCheckout.ts +6 -3
- package/src/simple-tree/api/configuration.ts +3 -3
- package/src/simple-tree/api/create.ts +49 -19
- package/src/simple-tree/api/customTree.ts +10 -0
- package/src/simple-tree/api/index.ts +1 -4
- package/src/simple-tree/api/schemaFactory.ts +62 -13
- package/src/simple-tree/api/treeNodeApi.ts +48 -27
- package/src/simple-tree/api/verboseTree.ts +15 -12
- package/src/simple-tree/core/getOrCreateNode.ts +4 -2
- package/src/simple-tree/core/index.ts +2 -3
- package/src/simple-tree/core/treeNodeKernel.ts +37 -54
- package/src/simple-tree/core/unhydratedFlexTree.ts +222 -261
- package/src/simple-tree/index.ts +3 -3
- package/src/simple-tree/node-kinds/array/arrayNode.ts +12 -13
- package/src/simple-tree/node-kinds/index.ts +0 -1
- package/src/simple-tree/node-kinds/map/mapNode.ts +6 -9
- package/src/simple-tree/node-kinds/object/index.ts +0 -1
- package/src/simple-tree/node-kinds/object/objectNode.ts +7 -49
- package/src/simple-tree/prepareForInsertion.ts +49 -42
- package/src/simple-tree/schemaTypes.ts +9 -8
- package/src/simple-tree/toStoredSchema.ts +7 -1
- package/src/simple-tree/{toMapTree.ts → unhydratedFlexTreeFromInsertable.ts} +134 -226
- package/src/treeFactory.ts +6 -1
- package/src/util/index.ts +1 -0
- package/src/util/utils.ts +7 -0
- package/dist/simple-tree/toMapTree.d.ts.map +0 -1
- package/dist/simple-tree/toMapTree.js.map +0 -1
- package/lib/simple-tree/toMapTree.d.ts.map +0 -1
- package/lib/simple-tree/toMapTree.js.map +0 -1
|
@@ -247,28 +247,7 @@ export class SchematizingSimpleTreeView<
|
|
|
247
247
|
constraintsOnRevert: boolean,
|
|
248
248
|
constraints: readonly TransactionConstraint[] = [],
|
|
249
249
|
): void => {
|
|
250
|
-
|
|
251
|
-
switch (constraint.type) {
|
|
252
|
-
case "nodeInDocument": {
|
|
253
|
-
const node = getOrCreateInnerNode(constraint.node);
|
|
254
|
-
const nodeStatus = getKernel(constraint.node).getStatus();
|
|
255
|
-
if (nodeStatus !== TreeStatus.InDocument) {
|
|
256
|
-
const revertText = constraintsOnRevert ? " on revert" : "";
|
|
257
|
-
throw new UsageError(
|
|
258
|
-
`Attempted to add a "nodeInDocument" constraint${revertText}, but the node is not currently in the document. Node status: ${nodeStatus}`,
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
if (constraintsOnRevert) {
|
|
262
|
-
this.checkout.editor.addNodeExistsConstraintOnRevert(node.anchorNode);
|
|
263
|
-
} else {
|
|
264
|
-
this.checkout.editor.addNodeExistsConstraint(node.anchorNode);
|
|
265
|
-
}
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
default:
|
|
269
|
-
unreachableCase(constraint.type);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
250
|
+
addConstraintsToTransaction(this.checkout, constraintsOnRevert, constraints);
|
|
272
251
|
};
|
|
273
252
|
|
|
274
253
|
this.checkout.transaction.start();
|
|
@@ -520,3 +499,42 @@ export function requireSchema(
|
|
|
520
499
|
|
|
521
500
|
return view;
|
|
522
501
|
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Adds constraints to a `checkout`'s pending transaction.
|
|
505
|
+
*
|
|
506
|
+
* @param checkout - The checkout's who's transaction will have the constraints added to it.
|
|
507
|
+
* @param constraintsOnRevert - If true, use {@link ISharedTreeEditor.addNodeExistsConstraintOnRevert}.
|
|
508
|
+
* @param constraints - The constraints to add to the transaction.
|
|
509
|
+
*
|
|
510
|
+
* @see {@link RunTransactionParams.preconditions}.
|
|
511
|
+
*/
|
|
512
|
+
export function addConstraintsToTransaction(
|
|
513
|
+
checkout: ITreeCheckout,
|
|
514
|
+
constraintsOnRevert: boolean,
|
|
515
|
+
constraints: readonly TransactionConstraint[] = [],
|
|
516
|
+
): void {
|
|
517
|
+
for (const constraint of constraints) {
|
|
518
|
+
switch (constraint.type) {
|
|
519
|
+
case "nodeInDocument": {
|
|
520
|
+
const node = getOrCreateInnerNode(constraint.node);
|
|
521
|
+
const nodeStatus = getKernel(constraint.node).getStatus();
|
|
522
|
+
if (nodeStatus !== TreeStatus.InDocument) {
|
|
523
|
+
const revertText = constraintsOnRevert ? " on revert" : "";
|
|
524
|
+
throw new UsageError(
|
|
525
|
+
`Attempted to add a "nodeInDocument" constraint${revertText}, but the node is not currently in the document. Node status: ${nodeStatus}`,
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
assert(node.isHydrated(), "In document node must be hydrated.");
|
|
529
|
+
if (constraintsOnRevert) {
|
|
530
|
+
checkout.editor.addNodeExistsConstraintOnRevert(node.anchorNode);
|
|
531
|
+
} else {
|
|
532
|
+
checkout.editor.addNodeExistsConstraint(node.anchorNode);
|
|
533
|
+
}
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
default:
|
|
537
|
+
unreachableCase(constraint.type);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
@@ -21,7 +21,12 @@ import {
|
|
|
21
21
|
type ITelemetryLoggerExt,
|
|
22
22
|
} from "@fluidframework/telemetry-utils/internal";
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
type CodecWriteOptions,
|
|
26
|
+
FluidClientVersion,
|
|
27
|
+
type ICodecOptions,
|
|
28
|
+
noopValidator,
|
|
29
|
+
} from "../codec/index.js";
|
|
25
30
|
import {
|
|
26
31
|
type FieldKey,
|
|
27
32
|
type GraphCommit,
|
|
@@ -585,9 +590,9 @@ export type SharedTreeFormatVersion = typeof SharedTreeFormatVersion;
|
|
|
585
590
|
|
|
586
591
|
/**
|
|
587
592
|
* Configuration options for SharedTree.
|
|
588
|
-
* @alpha
|
|
593
|
+
* @alpha @input
|
|
589
594
|
*/
|
|
590
|
-
export type SharedTreeOptions = Partial<
|
|
595
|
+
export type SharedTreeOptions = Partial<CodecWriteOptions> &
|
|
591
596
|
Partial<SharedTreeFormatOptions> &
|
|
592
597
|
ForestOptions;
|
|
593
598
|
|
|
@@ -702,6 +707,7 @@ export function buildConfiguredForest(
|
|
|
702
707
|
|
|
703
708
|
export const defaultSharedTreeOptions: Required<SharedTreeOptionsInternal> = {
|
|
704
709
|
jsonValidator: noopValidator,
|
|
710
|
+
oldestCompatibleClient: FluidClientVersion.v2_0,
|
|
705
711
|
forest: ForestTypeReference,
|
|
706
712
|
treeEncodeType: TreeCompressionStrategy.Compressed,
|
|
707
713
|
formatVersion: SharedTreeFormatVersion.v3,
|
package/src/shared-tree/tree.ts
CHANGED
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { unreachableCase } from "@fluidframework/core-utils/internal";
|
|
7
6
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
7
|
|
|
9
|
-
import { TreeStatus } from "../feature-libraries/index.js";
|
|
10
8
|
import {
|
|
11
9
|
type ImplicitFieldSchema,
|
|
12
10
|
type TreeNode,
|
|
@@ -19,7 +17,10 @@ import {
|
|
|
19
17
|
} from "../simple-tree/index.js";
|
|
20
18
|
|
|
21
19
|
import { getCheckoutFlexTreeView } from "./checkoutFlexTreeView.js";
|
|
22
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
addConstraintsToTransaction,
|
|
22
|
+
SchematizingSimpleTreeView,
|
|
23
|
+
} from "./schematizingTreeView.js";
|
|
23
24
|
import type { ITreeCheckout } from "./treeCheckout.js";
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -463,23 +464,7 @@ function runTransactionInCheckout<TResult>(
|
|
|
463
464
|
preconditions: readonly TransactionConstraint[],
|
|
464
465
|
): TResult | typeof rollback {
|
|
465
466
|
checkout.transaction.start();
|
|
466
|
-
|
|
467
|
-
switch (constraint.type) {
|
|
468
|
-
case "nodeInDocument": {
|
|
469
|
-
const node = getOrCreateInnerNode(constraint.node);
|
|
470
|
-
const nodeStatus = Tree.status(constraint.node);
|
|
471
|
-
if (nodeStatus !== TreeStatus.InDocument) {
|
|
472
|
-
throw new UsageError(
|
|
473
|
-
`Attempted to add a "nodeInDocument" constraint, but the node is not currently in the document. Node status: ${nodeStatus}`,
|
|
474
|
-
);
|
|
475
|
-
}
|
|
476
|
-
checkout.editor.addNodeExistsConstraint(node.anchorNode);
|
|
477
|
-
break;
|
|
478
|
-
}
|
|
479
|
-
default:
|
|
480
|
-
unreachableCase(constraint.type);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
467
|
+
addConstraintsToTransaction(checkout, false, preconditions);
|
|
483
468
|
|
|
484
469
|
let result: ReturnType<typeof transaction>;
|
|
485
470
|
try {
|
|
@@ -38,10 +38,11 @@ import {
|
|
|
38
38
|
getPropertyKeyFromStoredKey,
|
|
39
39
|
treeNodeApi,
|
|
40
40
|
getIdentifierFromNode,
|
|
41
|
-
|
|
41
|
+
unhydratedFlexTreeFromInsertable,
|
|
42
|
+
getOrCreateNodeFromInnerNode,
|
|
42
43
|
} from "../simple-tree/index.js";
|
|
43
44
|
import { extractFromOpaque, type JsonCompatible } from "../util/index.js";
|
|
44
|
-
import {
|
|
45
|
+
import type { CodecWriteOptions, ICodecOptions } from "../codec/index.js";
|
|
45
46
|
import type { ITreeCursorSynchronous } from "../core/index.js";
|
|
46
47
|
import {
|
|
47
48
|
cursorForMapTreeField,
|
|
@@ -57,8 +58,7 @@ import {
|
|
|
57
58
|
} from "../feature-libraries/index.js";
|
|
58
59
|
import { independentInitializedView, type ViewContent } from "./independentView.js";
|
|
59
60
|
import { SchematizingSimpleTreeView, ViewSlot } from "./schematizingTreeView.js";
|
|
60
|
-
import { currentVersion } from "../codec/index.js";
|
|
61
|
-
import { createFromMapTree } from "../simple-tree/index.js";
|
|
61
|
+
import { currentVersion, noopValidator } from "../codec/index.js";
|
|
62
62
|
|
|
63
63
|
const identifier: TreeIdentifierUtils = (node: TreeNode): string | undefined => {
|
|
64
64
|
const nodeIdentifier = getIdentifierFromNode(node, "uncompressed");
|
|
@@ -295,7 +295,10 @@ export interface TreeAlpha {
|
|
|
295
295
|
*/
|
|
296
296
|
exportCompressed(
|
|
297
297
|
tree: TreeNode | TreeLeafValue,
|
|
298
|
-
options: {
|
|
298
|
+
options: { idCompressor?: IIdCompressor } & Pick<
|
|
299
|
+
CodecWriteOptions,
|
|
300
|
+
"oldestCompatibleClient"
|
|
301
|
+
>,
|
|
299
302
|
): JsonCompatible<IFluidHandle>;
|
|
300
303
|
|
|
301
304
|
/**
|
|
@@ -367,8 +370,11 @@ export const TreeAlpha: TreeAlpha = {
|
|
|
367
370
|
? TreeFieldFromImplicitField<TSchema>
|
|
368
371
|
: TreeNode | TreeLeafValue | undefined
|
|
369
372
|
> {
|
|
370
|
-
const mapTree =
|
|
371
|
-
|
|
373
|
+
const mapTree = unhydratedFlexTreeFromInsertable(
|
|
374
|
+
data as InsertableField<UnsafeUnknownSchema>,
|
|
375
|
+
schema,
|
|
376
|
+
);
|
|
377
|
+
const result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);
|
|
372
378
|
return result as Unhydrated<
|
|
373
379
|
TSchema extends ImplicitFieldSchema
|
|
374
380
|
? TreeFieldFromImplicitField<TSchema>
|
|
@@ -426,10 +432,10 @@ export const TreeAlpha: TreeAlpha = {
|
|
|
426
432
|
|
|
427
433
|
exportCompressed(
|
|
428
434
|
node: TreeNode | TreeLeafValue,
|
|
429
|
-
options: {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
435
|
+
options: { idCompressor?: IIdCompressor } & Pick<
|
|
436
|
+
CodecWriteOptions,
|
|
437
|
+
"oldestCompatibleClient"
|
|
438
|
+
>,
|
|
433
439
|
): JsonCompatible<IFluidHandle> {
|
|
434
440
|
const schema = tryGetSchema(node) ?? fail(0xacf /* invalid input */);
|
|
435
441
|
const format = fluidVersionToFieldBatchCodecWriteVersion(options.oldestCompatibleClient);
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
UsageError,
|
|
12
12
|
type ITelemetryLoggerExt,
|
|
13
13
|
} from "@fluidframework/telemetry-utils/internal";
|
|
14
|
-
import { noopValidator } from "../codec/index.js";
|
|
14
|
+
import { FluidClientVersion, noopValidator } from "../codec/index.js";
|
|
15
15
|
import {
|
|
16
16
|
type Anchor,
|
|
17
17
|
type AnchorLocator,
|
|
@@ -279,7 +279,10 @@ export function createTreeCheckout(
|
|
|
279
279
|
const breaker = args?.breaker ?? new Breakable("TreeCheckout");
|
|
280
280
|
const schema = args?.schema ?? new TreeStoredSchemaRepository();
|
|
281
281
|
const forest = args?.forest ?? buildForest(breaker, schema);
|
|
282
|
-
const defaultCodecOptions = {
|
|
282
|
+
const defaultCodecOptions = {
|
|
283
|
+
jsonValidator: noopValidator,
|
|
284
|
+
oldestCompatibleClient: FluidClientVersion.v2_0,
|
|
285
|
+
};
|
|
283
286
|
const defaultFieldBatchVersion = 1;
|
|
284
287
|
const changeFamily =
|
|
285
288
|
args?.changeFamily ??
|
|
@@ -287,7 +290,7 @@ export function createTreeCheckout(
|
|
|
287
290
|
revisionTagCodec,
|
|
288
291
|
args?.fieldBatchCodec ??
|
|
289
292
|
makeFieldBatchCodec(defaultCodecOptions, defaultFieldBatchVersion),
|
|
290
|
-
|
|
293
|
+
defaultCodecOptions,
|
|
291
294
|
args?.chunkCompressionStrategy,
|
|
292
295
|
idCompressor,
|
|
293
296
|
);
|
|
@@ -107,8 +107,8 @@ export interface ITreeConfigurationOptions {
|
|
|
107
107
|
*
|
|
108
108
|
* To make this more permissive in the future we can:
|
|
109
109
|
*
|
|
110
|
-
* - Make
|
|
111
|
-
* - Update this check to more tightly match
|
|
110
|
+
* - Make unhydratedFlexTreeFromInsertable more permissive (ex: allow disambiguation based on leaf type)
|
|
111
|
+
* - Update this check to more tightly match unhydratedFlexTreeFromInsertable
|
|
112
112
|
* - Add options to help schema authors disambiguate their types, such as "constant fields" which are not persisted, and always have a constant value.
|
|
113
113
|
*
|
|
114
114
|
* The above examples exist in executable form in this files tests, and should be updated there then copied back here.
|
|
@@ -343,7 +343,7 @@ export function checkUnion(union: Iterable<TreeNodeSchema>, errors: string[]): v
|
|
|
343
343
|
// Allow using the type of the field to disambiguate, at least for leaf types.
|
|
344
344
|
// Add "constant" fields which can be used to disambiguate even more cases without adding persisted data: maybe make them optional in constructor?
|
|
345
345
|
// Consider separating unambiguous implicit construction format from constructor arguments at type level, allowing constructor to superset the implicit construction options (ex: optional constant fields).
|
|
346
|
-
// The policy here however must remain at least as conservative as shallowCompatibilityTest in src/simple-tree/
|
|
346
|
+
// The policy here however must remain at least as conservative as shallowCompatibilityTest in src/simple-tree/unhydratedFlexTreeFromInsertable.ts.
|
|
347
347
|
|
|
348
348
|
errors.push(
|
|
349
349
|
`The required fields of ${JSON.stringify(schema.identifier)} are insufficient to differentiate it from the following types: ${formatTypes(possiblyAmbiguous)}. For objects to be considered unambiguous, each must have required fields that do not all occur on any other object in the union.`,
|
|
@@ -5,35 +5,46 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import {
|
|
9
|
+
CursorLocationType,
|
|
10
|
+
mapCursorField,
|
|
11
|
+
mapCursorFields,
|
|
12
|
+
type ITreeCursorSynchronous,
|
|
13
|
+
type SchemaAndPolicy,
|
|
12
14
|
} from "../../core/index.js";
|
|
13
15
|
import type { ImplicitFieldSchema, TreeFieldFromImplicitField } from "../schemaTypes.js";
|
|
14
16
|
import {
|
|
17
|
+
type Context,
|
|
15
18
|
getOrCreateNodeFromInnerNode,
|
|
16
|
-
|
|
19
|
+
type NodeKind,
|
|
17
20
|
type Unhydrated,
|
|
21
|
+
UnhydratedFlexTreeNode,
|
|
22
|
+
createField,
|
|
18
23
|
} from "../core/index.js";
|
|
19
24
|
import {
|
|
20
25
|
defaultSchemaPolicy,
|
|
21
26
|
inSchemaOrThrow,
|
|
22
|
-
mapTreeFromCursor,
|
|
23
27
|
isFieldInSchema,
|
|
24
28
|
} from "../../feature-libraries/index.js";
|
|
25
29
|
import { getUnhydratedContext } from "../createContext.js";
|
|
26
30
|
import { createUnknownOptionalFieldPolicy } from "../node-kinds/index.js";
|
|
31
|
+
import type { SimpleNodeSchema, SimpleNodeSchemaBase } from "../simpleSchema.js";
|
|
32
|
+
import { getStoredSchema } from "../toStoredSchema.js";
|
|
33
|
+
import { unknownTypeError } from "./customTree.js";
|
|
27
34
|
|
|
28
35
|
/**
|
|
29
36
|
* Creates an unhydrated simple-tree field from a cursor in nodes mode.
|
|
37
|
+
* @remarks
|
|
38
|
+
* Does not support defaults.
|
|
39
|
+
* Validates the field is in schema.
|
|
30
40
|
*/
|
|
31
41
|
export function createFromCursor<const TSchema extends ImplicitFieldSchema>(
|
|
32
42
|
schema: TSchema,
|
|
33
43
|
cursor: ITreeCursorSynchronous | undefined,
|
|
34
44
|
): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
|
|
35
|
-
const mapTrees = cursor === undefined ? [] : [mapTreeFromCursor(cursor)];
|
|
36
45
|
const context = getUnhydratedContext(schema);
|
|
46
|
+
const mapTrees = cursor === undefined ? [] : [unhydratedFlexTreeFromCursor(context, cursor)];
|
|
47
|
+
|
|
37
48
|
const flexSchema = context.flexContext.schema;
|
|
38
49
|
|
|
39
50
|
const schemaValidationPolicy: SchemaAndPolicy = {
|
|
@@ -58,21 +69,40 @@ export function createFromCursor<const TSchema extends ImplicitFieldSchema>(
|
|
|
58
69
|
// Length asserted above, so this is safe. This assert is done instead of checking for undefined after indexing to ensure a length greater than 1 also errors.
|
|
59
70
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
60
71
|
const mapTree = mapTrees[0]!;
|
|
61
|
-
|
|
72
|
+
|
|
73
|
+
return getOrCreateNodeFromInnerNode(mapTree) as Unhydrated<
|
|
74
|
+
TreeFieldFromImplicitField<TSchema>
|
|
75
|
+
>;
|
|
62
76
|
}
|
|
63
77
|
|
|
64
78
|
/**
|
|
65
|
-
*
|
|
79
|
+
* Construct an {@link UnhydratedFlexTreeNode} from a cursor in Nodes mode.
|
|
80
|
+
* @remarks
|
|
81
|
+
* This does not validate the node is in schema.
|
|
66
82
|
*/
|
|
67
|
-
export function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
):
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
export function unhydratedFlexTreeFromCursor(
|
|
84
|
+
context: Context,
|
|
85
|
+
cursor: ITreeCursorSynchronous,
|
|
86
|
+
): UnhydratedFlexTreeNode {
|
|
87
|
+
assert(cursor.mode === CursorLocationType.Nodes, 0xbb4 /* Expected nodes cursor */);
|
|
88
|
+
const schema = context.schema.get(cursor.type) ?? unknownTypeError(cursor.type);
|
|
89
|
+
const storedSchema = getStoredSchema(
|
|
90
|
+
schema as SimpleNodeSchemaBase<NodeKind> as SimpleNodeSchema,
|
|
91
|
+
);
|
|
92
|
+
const fields = new Map(
|
|
93
|
+
mapCursorFields(cursor, () => [
|
|
94
|
+
cursor.getFieldKey(),
|
|
95
|
+
createField(
|
|
96
|
+
context.flexContext,
|
|
97
|
+
storedSchema.getFieldSchema(cursor.getFieldKey()).kind,
|
|
98
|
+
cursor.getFieldKey(),
|
|
99
|
+
mapCursorField(cursor, () => unhydratedFlexTreeFromCursor(context, cursor)),
|
|
100
|
+
),
|
|
101
|
+
]),
|
|
102
|
+
);
|
|
103
|
+
return new UnhydratedFlexTreeNode(
|
|
104
|
+
{ type: cursor.type, value: cursor.value },
|
|
105
|
+
fields,
|
|
106
|
+
context,
|
|
74
107
|
);
|
|
75
|
-
|
|
76
|
-
const result = getOrCreateNodeFromInnerNode(mapTreeNode);
|
|
77
|
-
return result as Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
78
108
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { assert, fail } from "@fluidframework/core-utils/internal";
|
|
8
8
|
import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
|
|
9
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
10
|
|
|
10
11
|
import {
|
|
11
12
|
EmptyKey,
|
|
@@ -231,3 +232,12 @@ export function replaceHandles<T>(tree: unknown, replacer: HandleConverter<T>):
|
|
|
231
232
|
}
|
|
232
233
|
});
|
|
233
234
|
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Throws a `UsageError` indicating that a type is unknown in the current context.
|
|
238
|
+
*/
|
|
239
|
+
export function unknownTypeError(type: string): never {
|
|
240
|
+
throw new UsageError(
|
|
241
|
+
`Failed to parse tree due to occurrence of type ${JSON.stringify(type)} which is not defined in this context.`,
|
|
242
|
+
);
|
|
243
|
+
}
|
|
@@ -52,10 +52,7 @@ export {
|
|
|
52
52
|
getPropertyKeyFromStoredKey,
|
|
53
53
|
getIdentifierFromNode,
|
|
54
54
|
} from "./treeNodeApi.js";
|
|
55
|
-
export {
|
|
56
|
-
createFromCursor,
|
|
57
|
-
createFromMapTree,
|
|
58
|
-
} from "./create.js";
|
|
55
|
+
export { createFromCursor } from "./create.js";
|
|
59
56
|
export {
|
|
60
57
|
type JsonSchemaId,
|
|
61
58
|
type JsonSchemaType,
|
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
8
8
|
import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
|
|
9
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
10
|
|
|
10
11
|
import type { TreeValue } from "../../core/index.js";
|
|
11
|
-
import type { NodeIdentifierManager } from "../../feature-libraries/index.js";
|
|
12
12
|
// This import is required for intellisense in @link doc comments on mouseover in VSCode.
|
|
13
13
|
// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars
|
|
14
14
|
import type { TreeAlpha } from "../../shared-tree/index.js";
|
|
15
15
|
import {
|
|
16
16
|
type RestrictiveStringRecord,
|
|
17
|
+
compareSets,
|
|
17
18
|
getOrCreate,
|
|
18
19
|
isReadonlyArray,
|
|
19
20
|
} from "../../util/index.js";
|
|
@@ -24,6 +25,7 @@ import type {
|
|
|
24
25
|
TreeNodeSchemaClass,
|
|
25
26
|
TreeNodeSchemaNonClass,
|
|
26
27
|
TreeNodeSchemaBoth,
|
|
28
|
+
UnhydratedFlexTreeNode,
|
|
27
29
|
} from "../core/index.js";
|
|
28
30
|
import { isLazy } from "../flexList.js";
|
|
29
31
|
import {
|
|
@@ -60,10 +62,15 @@ import {
|
|
|
60
62
|
type ImplicitAnnotatedAllowedTypes,
|
|
61
63
|
type UnannotateImplicitAllowedTypes,
|
|
62
64
|
type UnannotateSchemaRecord,
|
|
65
|
+
normalizeAllowedTypes,
|
|
63
66
|
} from "../schemaTypes.js";
|
|
64
67
|
|
|
65
68
|
import { createFieldSchemaUnsafe } from "./schemaFactoryRecursive.js";
|
|
66
69
|
import type { System_Unsafe, FieldSchemaAlphaUnsafe } from "./typesUnsafe.js";
|
|
70
|
+
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
71
|
+
import { createIdCompressor } from "@fluidframework/id-compressor/internal";
|
|
72
|
+
import type { FlexTreeHydratedContextMinimal } from "../../feature-libraries/index.js";
|
|
73
|
+
import { unhydratedFlexTreeFromInsertable } from "../unhydratedFlexTreeFromInsertable.js";
|
|
67
74
|
|
|
68
75
|
/**
|
|
69
76
|
* Gets the leaf domain schema compatible with a given {@link TreeValue}.
|
|
@@ -293,9 +300,7 @@ export interface SchemaStatics {
|
|
|
293
300
|
) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Required, T, TCustomMetadata>;
|
|
294
301
|
}
|
|
295
302
|
|
|
296
|
-
const defaultOptionalProvider: DefaultProvider = getDefaultProvider(() =>
|
|
297
|
-
return undefined;
|
|
298
|
-
});
|
|
303
|
+
const defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => []);
|
|
299
304
|
|
|
300
305
|
// The following overloads for optional and required are used to get around the fact that
|
|
301
306
|
// the compiler can't infer that UnannotateImplicitAllowedTypes<T> is equal to T when T is known to extend ImplicitAllowedTypes
|
|
@@ -766,9 +771,9 @@ export class SchemaFactory<
|
|
|
766
771
|
if (allowedTypes === undefined) {
|
|
767
772
|
const types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];
|
|
768
773
|
const fullName = structuralName("Map", types);
|
|
769
|
-
return
|
|
770
|
-
this.structuralTypes,
|
|
774
|
+
return this.getStructuralType(
|
|
771
775
|
fullName,
|
|
776
|
+
types,
|
|
772
777
|
() =>
|
|
773
778
|
this.namedMap(
|
|
774
779
|
fullName as TName,
|
|
@@ -954,7 +959,7 @@ export class SchemaFactory<
|
|
|
954
959
|
if (allowedTypes === undefined) {
|
|
955
960
|
const types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];
|
|
956
961
|
const fullName = structuralName("Array", types);
|
|
957
|
-
return
|
|
962
|
+
return this.getStructuralType(fullName, types, () =>
|
|
958
963
|
this.namedArray(fullName, nameOrAllowedTypes as T, false, true),
|
|
959
964
|
) as TreeNodeSchemaClass<
|
|
960
965
|
ScopedSchemaName<TScope, string>,
|
|
@@ -978,6 +983,35 @@ export class SchemaFactory<
|
|
|
978
983
|
return out;
|
|
979
984
|
}
|
|
980
985
|
|
|
986
|
+
/**
|
|
987
|
+
* Retrieves or creates a structural {@link TreeNodeSchema} with the specified name and types.
|
|
988
|
+
*
|
|
989
|
+
* @param fullName - The name for the structural schema.
|
|
990
|
+
* @param types - The input schema(s) used to define the structural schema.
|
|
991
|
+
* @param builder - A function that builds the schema if it does not already exist.
|
|
992
|
+
* @returns The structural {@link TreeNodeSchema} associated with the given name and types.
|
|
993
|
+
* @throws `UsageError` if a schema structurally named schema with the same name is cached in `structuralTypes` but had different input types.
|
|
994
|
+
*/
|
|
995
|
+
private getStructuralType(
|
|
996
|
+
fullName: string,
|
|
997
|
+
types: TreeNodeSchema | readonly TreeNodeSchema[],
|
|
998
|
+
builder: () => TreeNodeSchema,
|
|
999
|
+
): TreeNodeSchema {
|
|
1000
|
+
const structural = getOrCreate(this.structuralTypes, fullName, builder);
|
|
1001
|
+
const inputTypes = new Set(normalizeAllowedTypes(types));
|
|
1002
|
+
const outputTypes = new Set(
|
|
1003
|
+
normalizeAllowedTypes(structural.info as TreeNodeSchema | readonly TreeNodeSchema[]),
|
|
1004
|
+
);
|
|
1005
|
+
// If our cached value had a different set of types then were requested, the user must have caused a collision.
|
|
1006
|
+
const same = compareSets({ a: inputTypes, b: outputTypes });
|
|
1007
|
+
if (!same) {
|
|
1008
|
+
throw new UsageError(
|
|
1009
|
+
`Structurally named schema collision: two schema named "${fullName}" were defined with different input schema.`,
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
return structural;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
981
1015
|
/**
|
|
982
1016
|
* Define a {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.
|
|
983
1017
|
*
|
|
@@ -1080,8 +1114,6 @@ export class SchemaFactory<
|
|
|
1080
1114
|
*
|
|
1081
1115
|
* - A compressed form of the identifier can be accessed at runtime via the {@link TreeNodeApi.shortId|Tree.shortId()} API.
|
|
1082
1116
|
*
|
|
1083
|
-
* - It will not be present in the object's iterable properties until explicitly read or until having been inserted into a tree.
|
|
1084
|
-
*
|
|
1085
1117
|
* However, a user may alternatively supply their own string as the identifier if desired (for example, if importing identifiers from another system).
|
|
1086
1118
|
* In that case, if the user requires it to be unique, it is up to them to ensure uniqueness.
|
|
1087
1119
|
* User-supplied identifiers may be read immediately, even before insertion into the tree.
|
|
@@ -1090,10 +1122,19 @@ export class SchemaFactory<
|
|
|
1090
1122
|
*/
|
|
1091
1123
|
public get identifier(): FieldSchema<FieldKind.Identifier, typeof this.string> {
|
|
1092
1124
|
const defaultIdentifierProvider: DefaultProvider = getDefaultProvider(
|
|
1093
|
-
(
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1125
|
+
(
|
|
1126
|
+
context: FlexTreeHydratedContextMinimal | "UseGlobalContext",
|
|
1127
|
+
): UnhydratedFlexTreeNode[] => {
|
|
1128
|
+
const id =
|
|
1129
|
+
context === "UseGlobalContext"
|
|
1130
|
+
? globalIdentifierAllocator.decompress(
|
|
1131
|
+
globalIdentifierAllocator.generateCompressedId(),
|
|
1132
|
+
)
|
|
1133
|
+
: context.nodeKeyManager.stabilizeNodeIdentifier(
|
|
1134
|
+
context.nodeKeyManager.generateLocalNodeIdentifier(),
|
|
1135
|
+
);
|
|
1136
|
+
|
|
1137
|
+
return [unhydratedFlexTreeFromInsertable(id, this.string)];
|
|
1097
1138
|
},
|
|
1098
1139
|
);
|
|
1099
1140
|
return createFieldSchema(FieldKind.Identifier, this.string, {
|
|
@@ -1266,3 +1307,11 @@ export function structuralName<const T extends string>(
|
|
|
1266
1307
|
}
|
|
1267
1308
|
return `${collectionName}<${inner}>`;
|
|
1268
1309
|
}
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* Used to allocate default identifiers for unhydrated nodes when no context is available.
|
|
1313
|
+
* @remarks
|
|
1314
|
+
* The identifiers allocated by this will never be compressed to Short Ids.
|
|
1315
|
+
* Using this is only better than creating fully random V4 UUIDs because it reduces the entropy making it possible for things like text compression to work slightly better.
|
|
1316
|
+
*/
|
|
1317
|
+
const globalIdentifierAllocator: IIdCompressor = createIdCompressor();
|