@fluidframework/tree 2.42.0 → 2.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +189 -0
- package/api-report/tree.alpha.api.md +72 -25
- package/api-report/tree.beta.api.md +34 -0
- package/api-report/tree.legacy.alpha.api.md +1 -0
- package/api-report/tree.legacy.public.api.md +1 -0
- package/api-report/tree.public.api.md +1 -0
- package/dist/alpha.d.ts +12 -6
- package/dist/beta.d.ts +6 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +5 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/schema-stored/formatV2.d.ts +80 -0
- package/dist/core/schema-stored/formatV2.d.ts.map +1 -0
- package/dist/core/schema-stored/formatV2.js +55 -0
- package/dist/core/schema-stored/formatV2.js.map +1 -0
- package/dist/core/schema-stored/index.d.ts +3 -1
- package/dist/core/schema-stored/index.d.ts.map +1 -1
- package/dist/core/schema-stored/index.js +5 -2
- package/dist/core/schema-stored/index.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +49 -17
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +65 -22
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +9 -7
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +13 -9
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +3 -3
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +6 -6
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +3 -3
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +8 -3
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js +2 -5
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +24 -25
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +0 -1
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js +1 -7
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +2 -2
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.js +3 -0
- package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +1 -2
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +2 -5
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +5 -5
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +15 -7
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +8 -3
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +2 -5
- 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 +1 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.d.ts +16 -2
- package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js +2 -0
- package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +2 -0
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -4
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -36
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +59 -9
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/schema-index/formatV1.d.ts +1 -1
- package/dist/feature-libraries/schema-index/formatV2.d.ts +42 -0
- package/dist/feature-libraries/schema-index/formatV2.d.ts.map +1 -0
- package/dist/feature-libraries/schema-index/formatV2.js +26 -0
- package/dist/feature-libraries/schema-index/formatV2.js.map +1 -0
- package/dist/feature-libraries/schema-index/index.d.ts +2 -1
- package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/index.js +4 -2
- package/dist/feature-libraries/schema-index/index.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +7 -2
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +6 -6
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +1 -0
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +3 -3
- 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 +34 -5
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +39 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +117 -11
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts +8 -3
- package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +2 -5
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +18 -7
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +15 -2
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +15 -3
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js +40 -22
- package/dist/simple-tree/api/configuration.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 +4 -4
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
- package/dist/simple-tree/api/schemaCreationUtilities.js +3 -3
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +15 -11
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +4 -0
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +41 -11
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +31 -4
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +2 -2
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/treeChangeEvents.d.ts +8 -3
- package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
- package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts +3 -0
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +1 -1
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +5 -0
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/dist/simple-tree/core/context.d.ts +3 -3
- package/dist/simple-tree/core/context.d.ts.map +1 -1
- package/dist/simple-tree/core/context.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts +9 -0
- package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js +12 -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 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +2 -2
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +68 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js +24 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +5 -9
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +12 -31
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/core/walkSchema.d.ts +3 -3
- package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/walkSchema.js +9 -5
- package/dist/simple-tree/core/walkSchema.js.map +1 -1
- package/dist/simple-tree/createContext.js +1 -1
- package/dist/simple-tree/createContext.js.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.d.ts +1 -1
- package/dist/simple-tree/getTreeNodeForField.d.ts.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.js +3 -3
- package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
- package/dist/simple-tree/index.d.ts +6 -6
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +8 -5
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +4 -1
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +1 -0
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +21 -16
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts +3 -2
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +11 -5
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +3 -2
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +12 -7
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/dist/simple-tree/prepareForInsertion.js +5 -1
- package/dist/simple-tree/prepareForInsertion.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +63 -30
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +73 -40
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/simpleSchema.d.ts +22 -4
- package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/simpleSchema.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts +4 -0
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +15 -4
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +1 -2
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/walkFieldSchema.js +1 -1
- package/dist/simple-tree/walkFieldSchema.js.map +1 -1
- package/dist/tableSchema.d.ts +1 -1
- package/dist/util/typeUtils.d.ts +2 -2
- package/dist/util/typeUtils.js.map +1 -1
- package/dist/util/utils.d.ts +2 -0
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +12 -6
- package/lib/beta.d.ts +6 -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/schema-stored/formatV2.d.ts +80 -0
- package/lib/core/schema-stored/formatV2.d.ts.map +1 -0
- package/lib/core/schema-stored/formatV2.js +52 -0
- package/lib/core/schema-stored/formatV2.js.map +1 -0
- package/lib/core/schema-stored/index.d.ts +3 -1
- package/lib/core/schema-stored/index.d.ts.map +1 -1
- package/lib/core/schema-stored/index.js +3 -1
- package/lib/core/schema-stored/index.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +49 -17
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +63 -21
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +9 -7
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +11 -7
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +3 -3
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +7 -7
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +3 -3
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +8 -3
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js +2 -5
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +24 -25
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +0 -1
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js +0 -1
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +2 -2
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.js +3 -0
- package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +1 -2
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +3 -6
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +5 -5
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +15 -7
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +8 -3
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -5
- 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 +16 -2
- package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js +2 -0
- package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +2 -0
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -4
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -36
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +60 -10
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/schema-index/formatV1.d.ts +1 -1
- package/lib/feature-libraries/schema-index/formatV2.d.ts +42 -0
- package/lib/feature-libraries/schema-index/formatV2.d.ts.map +1 -0
- package/lib/feature-libraries/schema-index/formatV2.js +23 -0
- package/lib/feature-libraries/schema-index/formatV2.js.map +1 -0
- package/lib/feature-libraries/schema-index/index.d.ts +2 -1
- package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/index.js +2 -1
- package/lib/feature-libraries/schema-index/index.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +7 -2
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +6 -6
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +1 -0
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +4 -4
- 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 +34 -5
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +39 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +111 -5
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts +8 -3
- package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +2 -5
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +18 -7
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +15 -2
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +15 -3
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js +42 -24
- package/lib/simple-tree/api/configuration.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/schemaCompatibilityTester.js +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
- package/lib/simple-tree/api/schemaCreationUtilities.js +3 -3
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +15 -11
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +4 -0
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +41 -11
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +31 -4
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +2 -2
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/treeChangeEvents.d.ts +8 -3
- package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
- package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts +3 -0
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +2 -2
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +5 -0
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/lib/simple-tree/core/context.d.ts +3 -3
- package/lib/simple-tree/core/context.d.ts.map +1 -1
- package/lib/simple-tree/core/context.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts +9 -0
- package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js +10 -0
- 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.js +2 -2
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +68 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js +21 -0
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +5 -9
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +15 -34
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/core/walkSchema.d.ts +3 -3
- package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/walkSchema.js +9 -5
- package/lib/simple-tree/core/walkSchema.js.map +1 -1
- package/lib/simple-tree/createContext.js +1 -1
- package/lib/simple-tree/createContext.js.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.d.ts +1 -1
- package/lib/simple-tree/getTreeNodeForField.d.ts.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.js +1 -1
- package/lib/simple-tree/getTreeNodeForField.js.map +1 -1
- package/lib/simple-tree/index.d.ts +6 -6
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +4 -4
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +4 -1
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +2 -1
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +13 -8
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts +3 -2
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +14 -8
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +3 -2
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +14 -9
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/lib/simple-tree/prepareForInsertion.js +5 -1
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +63 -30
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +70 -36
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/simpleSchema.d.ts +22 -4
- package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/simpleSchema.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts +4 -0
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +15 -4
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +1 -2
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/walkFieldSchema.js +1 -1
- package/lib/simple-tree/walkFieldSchema.js.map +1 -1
- package/lib/tableSchema.d.ts +1 -1
- package/lib/util/typeUtils.d.ts +2 -2
- package/lib/util/typeUtils.js.map +1 -1
- package/lib/util/utils.d.ts +2 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js.map +1 -1
- package/package.json +23 -23
- package/src/core/index.ts +3 -1
- package/src/core/schema-stored/formatV2.ts +78 -0
- package/src/core/schema-stored/index.ts +4 -1
- package/src/core/schema-stored/schema.ts +123 -33
- package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +16 -11
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +16 -7
- package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +4 -4
- package/src/feature-libraries/detachedFieldIndexSummarizer.ts +9 -16
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +33 -30
- package/src/feature-libraries/flex-tree/index.ts +0 -8
- package/src/feature-libraries/flex-tree/lazyEntity.ts +5 -1
- package/src/feature-libraries/flex-tree/lazyField.ts +5 -8
- package/src/feature-libraries/flex-tree/lazyNode.ts +17 -8
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +9 -16
- package/src/feature-libraries/index.ts +1 -1
- package/src/feature-libraries/mapTreeCursor.ts +17 -8
- package/src/feature-libraries/modular-schema/fieldKindWithEditor.ts +2 -0
- package/src/feature-libraries/object-forest/objectForest.ts +3 -0
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +11 -6
- package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -3
- package/src/feature-libraries/schema-index/codec.ts +73 -14
- package/src/feature-libraries/schema-index/formatV2.ts +30 -0
- package/src/feature-libraries/schema-index/index.ts +2 -1
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +11 -18
- package/src/index.ts +6 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizeTree.ts +1 -0
- package/src/shared-tree/schematizingTreeView.ts +8 -5
- package/src/shared-tree/sharedTree.ts +42 -12
- package/src/shared-tree/treeAlpha.ts +196 -6
- package/src/shared-tree-core/editManagerSummarizer.ts +9 -16
- package/src/shared-tree-core/sharedTreeCore.ts +33 -24
- package/src/simple-tree/api/configuration.ts +59 -27
- package/src/simple-tree/api/index.ts +3 -3
- package/src/simple-tree/api/schemaCompatibilityTester.ts +1 -1
- package/src/simple-tree/api/schemaCreationUtilities.ts +3 -3
- package/src/simple-tree/api/schemaFactory.ts +16 -11
- package/src/simple-tree/api/schemaFactoryAlpha.ts +53 -8
- package/src/simple-tree/api/storedSchema.ts +4 -4
- package/src/simple-tree/api/treeChangeEvents.ts +8 -3
- package/src/simple-tree/api/treeNodeApi.ts +5 -2
- package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +5 -0
- package/src/simple-tree/core/context.ts +3 -3
- package/src/simple-tree/core/getOrCreateNode.ts +14 -0
- package/src/simple-tree/core/index.ts +7 -1
- package/src/simple-tree/core/treeNodeKernel.ts +2 -2
- package/src/simple-tree/core/treeNodeSchema.ts +113 -1
- package/src/simple-tree/core/unhydratedFlexTree.ts +22 -44
- package/src/simple-tree/core/walkSchema.ts +16 -7
- package/src/simple-tree/createContext.ts +1 -1
- package/src/simple-tree/getTreeNodeForField.ts +3 -1
- package/src/simple-tree/index.ts +12 -5
- package/src/simple-tree/leafNodeSchema.ts +9 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +20 -9
- package/src/simple-tree/node-kinds/map/mapNode.ts +21 -6
- package/src/simple-tree/node-kinds/object/objectNode.ts +29 -12
- package/src/simple-tree/prepareForInsertion.ts +5 -1
- package/src/simple-tree/schemaTypes.ts +151 -71
- package/src/simple-tree/simpleSchema.ts +27 -5
- package/src/simple-tree/toStoredSchema.ts +17 -4
- package/src/simple-tree/treeNodeValid.ts +1 -1
- package/src/simple-tree/walkFieldSchema.ts +5 -1
- package/src/util/typeUtils.ts +2 -2
- package/src/util/utils.ts +2 -0
- package/dist/feature-libraries/flex-tree/navigation.d.ts +0 -46
- package/dist/feature-libraries/flex-tree/navigation.d.ts.map +0 -1
- package/dist/feature-libraries/flex-tree/navigation.js +0 -104
- package/dist/feature-libraries/flex-tree/navigation.js.map +0 -1
- package/lib/feature-libraries/flex-tree/navigation.d.ts +0 -46
- package/lib/feature-libraries/flex-tree/navigation.d.ts.map +0 -1
- package/lib/feature-libraries/flex-tree/navigation.js +0 -97
- package/lib/feature-libraries/flex-tree/navigation.js.map +0 -1
- package/src/feature-libraries/flex-tree/navigation.ts +0 -121
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
makeTreeChunker,
|
|
65
65
|
} from "../feature-libraries/index.js";
|
|
66
66
|
// eslint-disable-next-line import/no-internal-modules
|
|
67
|
-
import type {
|
|
67
|
+
import type { FormatV1 } from "../feature-libraries/schema-index/index.js";
|
|
68
68
|
import {
|
|
69
69
|
type ClonableSchemaAndPolicy,
|
|
70
70
|
DefaultResubmitMachine,
|
|
@@ -92,12 +92,6 @@ import {
|
|
|
92
92
|
type ITreeAlpha,
|
|
93
93
|
type SimpleObjectFieldSchema,
|
|
94
94
|
} from "../simple-tree/index.js";
|
|
95
|
-
import {
|
|
96
|
-
type Breakable,
|
|
97
|
-
breakingClass,
|
|
98
|
-
type JsonCompatible,
|
|
99
|
-
throwIfBroken,
|
|
100
|
-
} from "../util/index.js";
|
|
101
95
|
|
|
102
96
|
import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
103
97
|
import { SharedTreeReadonlyChangeEnricher } from "./sharedTreeChangeEnricher.js";
|
|
@@ -105,6 +99,12 @@ import { SharedTreeChangeFamily } from "./sharedTreeChangeFamily.js";
|
|
|
105
99
|
import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
|
|
106
100
|
import type { SharedTreeEditBuilder } from "./sharedTreeEditBuilder.js";
|
|
107
101
|
import { type TreeCheckout, type BranchableTree, createTreeCheckout } from "./treeCheckout.js";
|
|
102
|
+
import {
|
|
103
|
+
type Breakable,
|
|
104
|
+
breakingClass,
|
|
105
|
+
type JsonCompatible,
|
|
106
|
+
throwIfBroken,
|
|
107
|
+
} from "../util/index.js";
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Copy of data from an {@link ITreePrivate} at some point in time.
|
|
@@ -192,6 +192,10 @@ const formatVersionToTopLevelCodecVersions = new Map<number, ExplicitCodecVersio
|
|
|
192
192
|
4,
|
|
193
193
|
{ forest: 1, schema: 1, detachedFieldIndex: 1, editManager: 4, message: 4, fieldBatch: 1 },
|
|
194
194
|
],
|
|
195
|
+
[
|
|
196
|
+
5,
|
|
197
|
+
{ forest: 1, schema: 2, detachedFieldIndex: 1, editManager: 4, message: 4, fieldBatch: 1 },
|
|
198
|
+
],
|
|
195
199
|
]);
|
|
196
200
|
|
|
197
201
|
function getCodecVersions(formatVersion: number): ExplicitCodecVersions {
|
|
@@ -511,7 +515,7 @@ export function persistedToSimpleSchema(
|
|
|
511
515
|
options: ICodecOptions,
|
|
512
516
|
): SimpleTreeSchema {
|
|
513
517
|
const schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);
|
|
514
|
-
const stored = schemaCodec.decode(persisted as
|
|
518
|
+
const stored = schemaCodec.decode(persisted as FormatV1);
|
|
515
519
|
return exportSimpleSchema(stored);
|
|
516
520
|
}
|
|
517
521
|
|
|
@@ -572,6 +576,11 @@ export const SharedTreeFormatVersion = {
|
|
|
572
576
|
* Requires \@fluidframework/tree \>= 2.0.0.
|
|
573
577
|
*/
|
|
574
578
|
v3: 3,
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Requires \@fluidframework/tree \>= 2.0.0.
|
|
582
|
+
*/
|
|
583
|
+
v5: 5,
|
|
575
584
|
} as const;
|
|
576
585
|
|
|
577
586
|
/**
|
|
@@ -750,20 +759,35 @@ function exportSimpleFieldSchemaStored(schema: TreeFieldStoredSchema): SimpleFie
|
|
|
750
759
|
default:
|
|
751
760
|
fail(0xaca /* invalid field kind */);
|
|
752
761
|
}
|
|
753
|
-
return {
|
|
762
|
+
return {
|
|
763
|
+
kind,
|
|
764
|
+
allowedTypesIdentifiers: schema.types,
|
|
765
|
+
metadata: {},
|
|
766
|
+
persistedMetadata: schema.persistedMetadata,
|
|
767
|
+
};
|
|
754
768
|
}
|
|
755
769
|
|
|
770
|
+
/**
|
|
771
|
+
* Export a {@link SimpleNodeSchema} from a {@link TreeNodeStoredSchema}.
|
|
772
|
+
* @privateRemarks
|
|
773
|
+
* TODO: Persist node metadata once schema FormatV2 is supported.
|
|
774
|
+
*/
|
|
756
775
|
function exportSimpleNodeSchemaStored(schema: TreeNodeStoredSchema): SimpleNodeSchema {
|
|
757
776
|
const arrayTypes = tryStoredSchemaAsArray(schema);
|
|
758
777
|
if (arrayTypes !== undefined) {
|
|
759
|
-
return {
|
|
778
|
+
return {
|
|
779
|
+
kind: NodeKind.Array,
|
|
780
|
+
allowedTypesIdentifiers: arrayTypes,
|
|
781
|
+
metadata: {},
|
|
782
|
+
persistedMetadata: schema.metadata,
|
|
783
|
+
};
|
|
760
784
|
}
|
|
761
785
|
if (schema instanceof ObjectNodeStoredSchema) {
|
|
762
786
|
const fields = new Map<FieldKey, SimpleObjectFieldSchema>();
|
|
763
787
|
for (const [storedKey, field] of schema.objectNodeFields) {
|
|
764
788
|
fields.set(storedKey, { ...exportSimpleFieldSchemaStored(field), storedKey });
|
|
765
789
|
}
|
|
766
|
-
return { kind: NodeKind.Object, fields, metadata: {} };
|
|
790
|
+
return { kind: NodeKind.Object, fields, metadata: {}, persistedMetadata: schema.metadata };
|
|
767
791
|
}
|
|
768
792
|
if (schema instanceof MapNodeStoredSchema) {
|
|
769
793
|
assert(
|
|
@@ -774,10 +798,16 @@ function exportSimpleNodeSchemaStored(schema: TreeNodeStoredSchema): SimpleNodeS
|
|
|
774
798
|
kind: NodeKind.Map,
|
|
775
799
|
allowedTypesIdentifiers: schema.mapFields.types,
|
|
776
800
|
metadata: {},
|
|
801
|
+
persistedMetadata: schema.metadata,
|
|
777
802
|
};
|
|
778
803
|
}
|
|
779
804
|
if (schema instanceof LeafNodeStoredSchema) {
|
|
780
|
-
return {
|
|
805
|
+
return {
|
|
806
|
+
kind: NodeKind.Leaf,
|
|
807
|
+
leafKind: schema.leafValue,
|
|
808
|
+
metadata: {},
|
|
809
|
+
persistedMetadata: schema.metadata,
|
|
810
|
+
};
|
|
781
811
|
}
|
|
782
812
|
fail(0xacb /* invalid schema kind */);
|
|
783
813
|
}
|
|
@@ -3,13 +3,19 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
assert,
|
|
8
|
+
debugAssert,
|
|
9
|
+
fail,
|
|
10
|
+
unreachableCase,
|
|
11
|
+
} from "@fluidframework/core-utils/internal";
|
|
7
12
|
import { createIdCompressor } from "@fluidframework/id-compressor/internal";
|
|
8
13
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
14
|
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
10
15
|
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
11
16
|
|
|
12
17
|
import {
|
|
18
|
+
asIndex,
|
|
13
19
|
getKernel,
|
|
14
20
|
type TreeNode,
|
|
15
21
|
type Unhydrated,
|
|
@@ -40,10 +46,20 @@ import {
|
|
|
40
46
|
getIdentifierFromNode,
|
|
41
47
|
unhydratedFlexTreeFromInsertable,
|
|
42
48
|
getOrCreateNodeFromInnerNode,
|
|
49
|
+
getOrCreateNodeFromInnerUnboxedNode,
|
|
50
|
+
getOrCreateInnerNode,
|
|
51
|
+
NodeKind,
|
|
52
|
+
tryGetTreeNodeForField,
|
|
53
|
+
isObjectNodeSchema,
|
|
43
54
|
} from "../simple-tree/index.js";
|
|
44
|
-
import { extractFromOpaque, type JsonCompatible } from "../util/index.js";
|
|
45
|
-
import
|
|
46
|
-
|
|
55
|
+
import { brand, extractFromOpaque, type JsonCompatible } from "../util/index.js";
|
|
56
|
+
import {
|
|
57
|
+
FluidClientVersion,
|
|
58
|
+
noopValidator,
|
|
59
|
+
type ICodecOptions,
|
|
60
|
+
type CodecWriteOptions,
|
|
61
|
+
} from "../codec/index.js";
|
|
62
|
+
import { EmptyKey, type ITreeCursorSynchronous } from "../core/index.js";
|
|
47
63
|
import {
|
|
48
64
|
cursorForMapTreeField,
|
|
49
65
|
defaultSchemaPolicy,
|
|
@@ -55,10 +71,10 @@ import {
|
|
|
55
71
|
type FieldBatchEncodingContext,
|
|
56
72
|
fluidVersionToFieldBatchCodecWriteVersion,
|
|
57
73
|
type LocalNodeIdentifier,
|
|
74
|
+
type FlexTreeSequenceField,
|
|
58
75
|
} from "../feature-libraries/index.js";
|
|
59
76
|
import { independentInitializedView, type ViewContent } from "./independentView.js";
|
|
60
77
|
import { SchematizingSimpleTreeView, ViewSlot } from "./schematizingTreeView.js";
|
|
61
|
-
import { currentVersion, noopValidator } from "../codec/index.js";
|
|
62
78
|
|
|
63
79
|
const identifier: TreeIdentifierUtils = (node: TreeNode): string | undefined => {
|
|
64
80
|
const nodeIdentifier = getIdentifierFromNode(node, "uncompressed");
|
|
@@ -339,6 +355,48 @@ export interface TreeAlpha {
|
|
|
339
355
|
* Otherwise, this returns the key of the field that it is under (a `string`).
|
|
340
356
|
*/
|
|
341
357
|
key2(node: TreeNode): string | number | undefined;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Gets the child of the given node with the given property key if a child exists under that key.
|
|
361
|
+
*
|
|
362
|
+
* @remarks {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | Unknown optional fields} of Object nodes will not be returned by this method.
|
|
363
|
+
*
|
|
364
|
+
* @param node - The parent node whose child is being requested.
|
|
365
|
+
* @param key - The property key under the node under which the child is being requested.
|
|
366
|
+
* For Object nodes, this is the developer-facing "property key", not the "{@link SimpleObjectFieldSchema.storedKey | stored keys}".
|
|
367
|
+
*
|
|
368
|
+
* @returns The child node or leaf value under the given key, or `undefined` if no such child exists.
|
|
369
|
+
*
|
|
370
|
+
* @see {@link (TreeAlpha:interface).key2}
|
|
371
|
+
* @see {@link (TreeNodeApi:interface).parent}
|
|
372
|
+
*/
|
|
373
|
+
child(node: TreeNode, key: string | number): TreeNode | TreeLeafValue | undefined;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Gets the children of the provided node, paired with their property keys under the node.
|
|
377
|
+
*
|
|
378
|
+
* @remarks
|
|
379
|
+
* No guarantees are made regarding the order of the children in the returned array.
|
|
380
|
+
*
|
|
381
|
+
* Optional properties of Object nodes with no value are not included in the result.
|
|
382
|
+
*
|
|
383
|
+
* {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | Unknown optional fields} of Object nodes are not included in the result.
|
|
384
|
+
*
|
|
385
|
+
* @param node - The node whose children are being requested.
|
|
386
|
+
*
|
|
387
|
+
* @returns
|
|
388
|
+
* An array of pairs of the form `[propertyKey, child]`.
|
|
389
|
+
*
|
|
390
|
+
* For Array nodes, the `propertyKey` is the index of the child in the array.
|
|
391
|
+
*
|
|
392
|
+
* For Object nodes, the returned `propertyKey`s are the developer-facing "property keys", not the "{@link SimpleObjectFieldSchema.storedKey | stored keys}".
|
|
393
|
+
*
|
|
394
|
+
* @see {@link (TreeAlpha:interface).key2}
|
|
395
|
+
* @see {@link (TreeNodeApi:interface).parent}
|
|
396
|
+
*/
|
|
397
|
+
children(
|
|
398
|
+
node: TreeNode,
|
|
399
|
+
): Iterable<[propertyKey: string | number, child: TreeNode | TreeLeafValue]>;
|
|
342
400
|
}
|
|
343
401
|
|
|
344
402
|
/**
|
|
@@ -463,7 +521,8 @@ export const TreeAlpha: TreeAlpha = {
|
|
|
463
521
|
): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
|
|
464
522
|
const config = new TreeViewConfigurationAlpha({ schema });
|
|
465
523
|
const content: ViewContent = {
|
|
466
|
-
schema
|
|
524
|
+
// Always use a v1 schema codec for consistency.
|
|
525
|
+
schema: extractPersistedSchema(config, FluidClientVersion.v2_0),
|
|
467
526
|
tree: compressedData,
|
|
468
527
|
idCompressor: options.idCompressor ?? createIdCompressor(),
|
|
469
528
|
};
|
|
@@ -487,6 +546,137 @@ export const TreeAlpha: TreeAlpha = {
|
|
|
487
546
|
const parentSchema = treeNodeApi.schema(parent);
|
|
488
547
|
return getPropertyKeyFromStoredKey(parentSchema, storedKey);
|
|
489
548
|
},
|
|
549
|
+
|
|
550
|
+
child: (
|
|
551
|
+
node: TreeNode,
|
|
552
|
+
propertyKey: string | number,
|
|
553
|
+
): TreeNode | TreeLeafValue | undefined => {
|
|
554
|
+
const flexNode = getOrCreateInnerNode(node);
|
|
555
|
+
debugAssert(
|
|
556
|
+
() => !flexNode.context.isDisposed() || "The provided tree node has been disposed.",
|
|
557
|
+
);
|
|
558
|
+
|
|
559
|
+
const schema = treeNodeApi.schema(node);
|
|
560
|
+
|
|
561
|
+
switch (schema.kind) {
|
|
562
|
+
case NodeKind.Array: {
|
|
563
|
+
const sequence = flexNode.tryGetField(EmptyKey) as FlexTreeSequenceField | undefined;
|
|
564
|
+
|
|
565
|
+
// Empty sequence - cannot have children.
|
|
566
|
+
if (sequence === undefined) {
|
|
567
|
+
return undefined;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const index =
|
|
571
|
+
typeof propertyKey === "number"
|
|
572
|
+
? propertyKey
|
|
573
|
+
: asIndex(propertyKey, Number.POSITIVE_INFINITY);
|
|
574
|
+
|
|
575
|
+
// If the key is not a valid index, then there is no corresponding child.
|
|
576
|
+
if (index === undefined) {
|
|
577
|
+
return undefined;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
const childFlexTree = sequence.at(index);
|
|
581
|
+
|
|
582
|
+
// No child at the given index.
|
|
583
|
+
if (childFlexTree === undefined) {
|
|
584
|
+
return undefined;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
return getOrCreateNodeFromInnerUnboxedNode(childFlexTree);
|
|
588
|
+
}
|
|
589
|
+
case NodeKind.Map:
|
|
590
|
+
if (typeof propertyKey !== "string") {
|
|
591
|
+
// Map nodes only support string keys.
|
|
592
|
+
return undefined;
|
|
593
|
+
}
|
|
594
|
+
// Fall through
|
|
595
|
+
case NodeKind.Object: {
|
|
596
|
+
let storedKey: string | number = propertyKey;
|
|
597
|
+
if (isObjectNodeSchema(schema)) {
|
|
598
|
+
const fieldSchema = schema.fields.get(String(propertyKey));
|
|
599
|
+
if (fieldSchema === undefined) {
|
|
600
|
+
return undefined;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
storedKey = fieldSchema.storedKey;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const field = flexNode.tryGetField(brand(String(storedKey)));
|
|
607
|
+
if (field !== undefined) {
|
|
608
|
+
return tryGetTreeNodeForField(field);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
return undefined;
|
|
612
|
+
}
|
|
613
|
+
case NodeKind.Leaf: {
|
|
614
|
+
fail(0xbc3 /* Leaf schema associated with non-leaf tree node. */);
|
|
615
|
+
}
|
|
616
|
+
default: {
|
|
617
|
+
unreachableCase(schema.kind);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
|
|
622
|
+
children(node: TreeNode): [propertyKey: string | number, child: TreeNode | TreeLeafValue][] {
|
|
623
|
+
const flexNode = getOrCreateInnerNode(node);
|
|
624
|
+
debugAssert(
|
|
625
|
+
() => !flexNode.context.isDisposed() || "The provided tree node has been disposed.",
|
|
626
|
+
);
|
|
627
|
+
|
|
628
|
+
const schema = treeNodeApi.schema(node);
|
|
629
|
+
|
|
630
|
+
const result: [string | number, TreeNode | TreeLeafValue][] = [];
|
|
631
|
+
switch (schema.kind) {
|
|
632
|
+
case NodeKind.Array: {
|
|
633
|
+
const sequence = flexNode.tryGetField(EmptyKey) as FlexTreeSequenceField | undefined;
|
|
634
|
+
if (sequence === undefined) {
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
for (let index = 0; index < sequence.length; index++) {
|
|
639
|
+
const childFlexTree = sequence.at(index);
|
|
640
|
+
assert(childFlexTree !== undefined, 0xbc4 /* Sequence child was undefined. */);
|
|
641
|
+
const childTree = getOrCreateNodeFromInnerUnboxedNode(childFlexTree);
|
|
642
|
+
result.push([index, childTree]);
|
|
643
|
+
}
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
case NodeKind.Map: {
|
|
647
|
+
for (const [key, flexField] of flexNode.fields) {
|
|
648
|
+
const childTreeNode = tryGetTreeNodeForField(flexField);
|
|
649
|
+
if (childTreeNode !== undefined) {
|
|
650
|
+
result.push([key, childTreeNode]);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
case NodeKind.Object: {
|
|
656
|
+
assert(isObjectNodeSchema(schema), 0xbc5 /* Expected object schema. */);
|
|
657
|
+
for (const [propertyKey, fieldSchema] of schema.fields) {
|
|
658
|
+
const storedKey = fieldSchema.storedKey;
|
|
659
|
+
const flexField = flexNode.tryGetField(brand(String(storedKey)));
|
|
660
|
+
if (flexField !== undefined) {
|
|
661
|
+
const childTreeNode = tryGetTreeNodeForField(flexField);
|
|
662
|
+
assert(
|
|
663
|
+
childTreeNode !== undefined,
|
|
664
|
+
0xbc6 /* Expected child tree node for field. */,
|
|
665
|
+
);
|
|
666
|
+
result.push([propertyKey, childTreeNode]);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
case NodeKind.Leaf: {
|
|
672
|
+
fail(0xbc7 /* Leaf schema associated with non-leaf tree node. */);
|
|
673
|
+
}
|
|
674
|
+
default: {
|
|
675
|
+
unreachableCase(schema.kind);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
return result;
|
|
679
|
+
},
|
|
490
680
|
};
|
|
491
681
|
|
|
492
682
|
function exportConcise(
|
|
@@ -8,6 +8,7 @@ import { assert } from "@fluidframework/core-utils/internal";
|
|
|
8
8
|
import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
9
9
|
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
10
10
|
import type {
|
|
11
|
+
IExperimentalIncrementalSummaryContext,
|
|
11
12
|
ISummaryTreeWithStats,
|
|
12
13
|
ITelemetryContext,
|
|
13
14
|
} from "@fluidframework/runtime-definitions/internal";
|
|
@@ -49,22 +50,14 @@ export class EditManagerSummarizer<TChangeset> implements Summarizable {
|
|
|
49
50
|
private readonly schemaAndPolicy?: SchemaAndPolicy,
|
|
50
51
|
) {}
|
|
51
52
|
|
|
52
|
-
public
|
|
53
|
-
stringify: SummaryElementStringifier
|
|
54
|
-
fullTree?: boolean
|
|
55
|
-
trackState?: boolean
|
|
56
|
-
telemetryContext?: ITelemetryContext
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
public async summarize(
|
|
62
|
-
stringify: SummaryElementStringifier,
|
|
63
|
-
fullTree?: boolean,
|
|
64
|
-
trackState?: boolean,
|
|
65
|
-
telemetryContext?: ITelemetryContext,
|
|
66
|
-
): Promise<ISummaryTreeWithStats> {
|
|
67
|
-
return this.summarizeCore(stringify);
|
|
53
|
+
public summarize(props: {
|
|
54
|
+
stringify: SummaryElementStringifier;
|
|
55
|
+
fullTree?: boolean;
|
|
56
|
+
trackState?: boolean;
|
|
57
|
+
telemetryContext?: ITelemetryContext;
|
|
58
|
+
incrementalSummaryContext?: IExperimentalIncrementalSummaryContext;
|
|
59
|
+
}): ISummaryTreeWithStats {
|
|
60
|
+
return this.summarizeCore(props.stringify);
|
|
68
61
|
}
|
|
69
62
|
|
|
70
63
|
private summarizeCore(stringify: SummaryElementStringifier): ISummaryTreeWithStats {
|
|
@@ -212,20 +212,30 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
212
212
|
serializer: IFluidSerializer,
|
|
213
213
|
telemetryContext?: ITelemetryContext,
|
|
214
214
|
incrementalSummaryContext?: IExperimentalIncrementalSummaryContext,
|
|
215
|
+
fullTree?: boolean,
|
|
215
216
|
): ISummaryTreeWithStats {
|
|
216
217
|
const builder = new SummaryTreeBuilder();
|
|
217
218
|
const summarizableBuilder = new SummaryTreeBuilder();
|
|
218
219
|
// Merge the summaries of all summarizables together under a single ISummaryTree
|
|
219
220
|
for (const s of this.summarizables) {
|
|
221
|
+
// Add the summarizable's path in the summary tree to the incremental summary context's
|
|
222
|
+
// summary path, so that the summarizable can use it to generate incremental summaries.
|
|
223
|
+
const childIncrementalSummaryContext =
|
|
224
|
+
incrementalSummaryContext === undefined
|
|
225
|
+
? undefined
|
|
226
|
+
: {
|
|
227
|
+
...incrementalSummaryContext,
|
|
228
|
+
summaryPath: `${incrementalSummaryContext.summaryPath}/${summarizablesTreeKey}/${s.key}`,
|
|
229
|
+
};
|
|
220
230
|
summarizableBuilder.addWithStats(
|
|
221
231
|
s.key,
|
|
222
|
-
s.
|
|
223
|
-
(contents) =>
|
|
224
|
-
|
|
225
|
-
|
|
232
|
+
s.summarize({
|
|
233
|
+
stringify: (contents: unknown) =>
|
|
234
|
+
serializer.stringify(contents, this.sharedObject.handle),
|
|
235
|
+
fullTree,
|
|
226
236
|
telemetryContext,
|
|
227
|
-
incrementalSummaryContext,
|
|
228
|
-
),
|
|
237
|
+
incrementalSummaryContext: childIncrementalSummaryContext,
|
|
238
|
+
}),
|
|
229
239
|
);
|
|
230
240
|
}
|
|
231
241
|
|
|
@@ -434,28 +444,27 @@ export interface Summarizable {
|
|
|
434
444
|
*/
|
|
435
445
|
readonly key: string;
|
|
436
446
|
|
|
437
|
-
/**
|
|
438
|
-
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}
|
|
439
|
-
* @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.
|
|
440
|
-
*/
|
|
441
|
-
getAttachSummary(
|
|
442
|
-
stringify: SummaryElementStringifier,
|
|
443
|
-
fullTree?: boolean,
|
|
444
|
-
trackState?: boolean,
|
|
445
|
-
telemetryContext?: ITelemetryContext,
|
|
446
|
-
incrementalSummaryContext?: IExperimentalIncrementalSummaryContext,
|
|
447
|
-
): ISummaryTreeWithStats;
|
|
448
|
-
|
|
449
447
|
/**
|
|
450
448
|
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}
|
|
451
449
|
* @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.
|
|
450
|
+
* @param fullTree - A flag indicating whether the attempt should generate a full
|
|
451
|
+
* summary tree without any handles for unchanged subtrees. It should only be set to true when generating
|
|
452
|
+
* a summary from the entire container. The default value is false.
|
|
453
|
+
* @param trackState - An optimization for tracking state of objects across summaries. If the state
|
|
454
|
+
* of an object did not change since last successful summary, an
|
|
455
|
+
* {@link @fluidframework/protocol-definitions#ISummaryHandle} can be used
|
|
456
|
+
* instead of re-summarizing it. If this is `false`, the expectation is that you should never
|
|
457
|
+
* send an `ISummaryHandle`, since you are not expected to track state. The default value is true.
|
|
458
|
+
* @param telemetryContext - See {@link @fluidframework/runtime-definitions#ITelemetryContext}.
|
|
459
|
+
* @param incrementalSummaryContext - See {@link @fluidframework/runtime-definitions#IExperimentalIncrementalSummaryContext}.
|
|
452
460
|
*/
|
|
453
|
-
summarize(
|
|
454
|
-
stringify: SummaryElementStringifier
|
|
455
|
-
fullTree?: boolean
|
|
456
|
-
trackState?: boolean
|
|
457
|
-
telemetryContext?: ITelemetryContext
|
|
458
|
-
|
|
461
|
+
summarize(props: {
|
|
462
|
+
stringify: SummaryElementStringifier;
|
|
463
|
+
fullTree?: boolean;
|
|
464
|
+
trackState?: boolean;
|
|
465
|
+
telemetryContext?: ITelemetryContext;
|
|
466
|
+
incrementalSummaryContext?: IExperimentalIncrementalSummaryContext;
|
|
467
|
+
}): ISummaryTreeWithStats;
|
|
459
468
|
|
|
460
469
|
/**
|
|
461
470
|
* Allows the component to perform custom loading. The storage service is scoped to this component and therefore
|
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert, fail } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { assert, debugAssert, fail } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
type FieldSchemaAlpha,
|
|
11
11
|
type ImplicitFieldSchema,
|
|
12
|
+
evaluateLazySchema,
|
|
12
13
|
FieldKind,
|
|
14
|
+
isAnnotatedAllowedType,
|
|
13
15
|
markSchemaMostDerived,
|
|
14
16
|
normalizeFieldSchema,
|
|
15
17
|
} from "../schemaTypes.js";
|
|
@@ -159,6 +161,11 @@ export class TreeViewConfiguration<
|
|
|
159
161
|
*/
|
|
160
162
|
public readonly preventAmbiguity: boolean;
|
|
161
163
|
|
|
164
|
+
/**
|
|
165
|
+
* {@link TreeSchema.definitions} but with public types.
|
|
166
|
+
*/
|
|
167
|
+
protected readonly definitionsInternal: ReadonlyMap<string, TreeNodeSchema>;
|
|
168
|
+
|
|
162
169
|
/**
|
|
163
170
|
* Construct a new {@link TreeViewConfiguration}.
|
|
164
171
|
*
|
|
@@ -181,27 +188,38 @@ export class TreeViewConfiguration<
|
|
|
181
188
|
// Ambiguity errors are lower priority to report than invalid schema errors, so collect these in an array and report them all at once.
|
|
182
189
|
const ambiguityErrors: string[] = [];
|
|
183
190
|
|
|
191
|
+
// Eagerly perform this conversion to surface errors sooner.
|
|
192
|
+
// Includes detection of duplicate schema identifiers.
|
|
193
|
+
toStoredSchema(config.schema);
|
|
194
|
+
|
|
195
|
+
const definitions = new Map<string, SimpleNodeSchema & TreeNodeSchema>();
|
|
196
|
+
|
|
184
197
|
walkFieldSchema(config.schema, {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
198
|
+
node: (schema) => {
|
|
199
|
+
// Ensure all reachable schema are marked as most derived.
|
|
200
|
+
// This ensures if multiple schema extending the same schema factory generated class are present (or have had instances of them constructed, or get instances of them constructed in the future),
|
|
201
|
+
// an error is reported.
|
|
202
|
+
markSchemaMostDerived(schema, true);
|
|
203
|
+
|
|
204
|
+
debugAssert(() => !definitions.has(schema.identifier));
|
|
205
|
+
definitions.set(schema.identifier, schema as SimpleNodeSchema & TreeNodeSchema);
|
|
206
|
+
},
|
|
207
|
+
allowedTypes({ types }): void {
|
|
208
|
+
checkUnion(
|
|
209
|
+
types.map((t) => evaluateLazySchema(isAnnotatedAllowedType(t) ? t.type : t)),
|
|
210
|
+
config.preventAmbiguity,
|
|
211
|
+
ambiguityErrors,
|
|
212
|
+
);
|
|
194
213
|
},
|
|
195
214
|
});
|
|
196
215
|
|
|
216
|
+
this.definitionsInternal = definitions;
|
|
217
|
+
|
|
197
218
|
if (ambiguityErrors.length !== 0) {
|
|
198
219
|
// Duplicate errors are common since when two types conflict, both orders error:
|
|
199
220
|
const deduplicated = new Set(ambiguityErrors);
|
|
200
221
|
throw new UsageError(`Ambiguous schema found:\n${[...deduplicated].join("\n")}`);
|
|
201
222
|
}
|
|
202
|
-
|
|
203
|
-
// Eagerly perform this conversion to surface errors sooner.
|
|
204
|
-
toStoredSchema(config.schema);
|
|
205
223
|
}
|
|
206
224
|
}
|
|
207
225
|
|
|
@@ -219,20 +237,17 @@ export class TreeViewConfigurationAlpha<
|
|
|
219
237
|
* {@inheritDoc TreeSchema.root}
|
|
220
238
|
*/
|
|
221
239
|
public readonly root: FieldSchemaAlpha;
|
|
240
|
+
|
|
222
241
|
/**
|
|
223
242
|
* {@inheritDoc TreeSchema.definitions}
|
|
224
243
|
*/
|
|
225
|
-
public
|
|
244
|
+
public get definitions(): ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema> {
|
|
245
|
+
return this.definitionsInternal as ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;
|
|
246
|
+
}
|
|
226
247
|
|
|
227
248
|
public constructor(props: ITreeViewConfiguration<TSchema>) {
|
|
228
249
|
super(props);
|
|
229
250
|
this.root = normalizeFieldSchema(props.schema);
|
|
230
|
-
const definitions = new Map<string, SimpleNodeSchema & TreeNodeSchema>();
|
|
231
|
-
walkFieldSchema(props.schema, {
|
|
232
|
-
node: (schema) =>
|
|
233
|
-
definitions.set(schema.identifier, schema as SimpleNodeSchema & TreeNodeSchema),
|
|
234
|
-
});
|
|
235
|
-
this.definitions = definitions;
|
|
236
251
|
}
|
|
237
252
|
}
|
|
238
253
|
|
|
@@ -262,9 +277,21 @@ function formatTypes(allowed: Iterable<TreeNodeSchema>): string {
|
|
|
262
277
|
}
|
|
263
278
|
|
|
264
279
|
/**
|
|
265
|
-
*
|
|
280
|
+
* Check if union contents are valid (shallowly).
|
|
281
|
+
*
|
|
282
|
+
* @param union - The union of {@link TreeNodeSchema} to check.
|
|
283
|
+
* @param preventAmbiguity - If true, detect cases documented in {@link ITreeConfigurationOptions.preventAmbiguity}, reporting them to `ambiguityErrors`.
|
|
284
|
+
* @param ambiguityErrors - An array into which this function inserts any ambiguity errors, see {@link ITreeConfigurationOptions.preventAmbiguity}.
|
|
285
|
+
*
|
|
286
|
+
* @remarks
|
|
287
|
+
* Includes checks for non-ambiguity errors as well: such as duplicate schemas in the union.
|
|
288
|
+
* Any non-ambiguity errors are thrown as exceptions: `UsageError`s if causable by incorrect API use, and asserts if violating internal invariants.
|
|
266
289
|
*/
|
|
267
|
-
export function checkUnion(
|
|
290
|
+
export function checkUnion(
|
|
291
|
+
union: Iterable<TreeNodeSchema>,
|
|
292
|
+
preventAmbiguity: boolean,
|
|
293
|
+
ambiguityErrors: string[],
|
|
294
|
+
): void {
|
|
268
295
|
const checked: Set<TreeNodeSchema> = new Set();
|
|
269
296
|
const maps: TreeNodeSchema[] = [];
|
|
270
297
|
const arrays: TreeNodeSchema[] = [];
|
|
@@ -294,26 +321,31 @@ export function checkUnion(union: Iterable<TreeNodeSchema>, errors: string[]): v
|
|
|
294
321
|
}
|
|
295
322
|
}
|
|
296
323
|
|
|
324
|
+
if (!preventAmbiguity) {
|
|
325
|
+
// All remaining checks are for the preventAmbiguity case, so skip them if not enabled.
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
|
|
297
329
|
if (arrays.length > 1) {
|
|
298
|
-
|
|
330
|
+
ambiguityErrors.push(
|
|
299
331
|
`More than one kind of array allowed within union (${formatTypes(arrays)}). This would require type disambiguation which is not supported by arrays during import or export.`,
|
|
300
332
|
);
|
|
301
333
|
}
|
|
302
334
|
|
|
303
335
|
if (maps.length > 1) {
|
|
304
|
-
|
|
336
|
+
ambiguityErrors.push(
|
|
305
337
|
`More than one kind of map allowed within union (${formatTypes(maps)}). This would require type disambiguation which is not supported by maps during import or export.`,
|
|
306
338
|
);
|
|
307
339
|
}
|
|
308
340
|
|
|
309
341
|
if (maps.length > 0 && arrays.length > 0) {
|
|
310
|
-
|
|
342
|
+
ambiguityErrors.push(
|
|
311
343
|
`Both a map and an array allowed within union (${formatTypes([...arrays, ...maps])}). Both can be implicitly constructed from iterables like arrays, which are ambiguous when the array is empty.`,
|
|
312
344
|
);
|
|
313
345
|
}
|
|
314
346
|
|
|
315
347
|
if (objects.length > 0 && maps.length > 0) {
|
|
316
|
-
|
|
348
|
+
ambiguityErrors.push(
|
|
317
349
|
`Both a object and a map allowed within union (${formatTypes([...objects, ...maps])}). Both can be constructed from objects and can be ambiguous.`,
|
|
318
350
|
);
|
|
319
351
|
}
|
|
@@ -345,7 +377,7 @@ export function checkUnion(union: Iterable<TreeNodeSchema>, errors: string[]): v
|
|
|
345
377
|
// 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
378
|
// The policy here however must remain at least as conservative as shallowCompatibilityTest in src/simple-tree/unhydratedFlexTreeFromInsertable.ts.
|
|
347
379
|
|
|
348
|
-
|
|
380
|
+
ambiguityErrors.push(
|
|
349
381
|
`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.`,
|
|
350
382
|
);
|
|
351
383
|
}
|
|
@@ -45,12 +45,12 @@ export {
|
|
|
45
45
|
singletonSchema,
|
|
46
46
|
} from "./schemaCreationUtilities.js";
|
|
47
47
|
export {
|
|
48
|
+
getIdentifierFromNode,
|
|
49
|
+
getPropertyKeyFromStoredKey,
|
|
50
|
+
getStoredKey,
|
|
48
51
|
treeNodeApi,
|
|
49
52
|
type TreeNodeApi,
|
|
50
53
|
tryGetSchema,
|
|
51
|
-
getStoredKey,
|
|
52
|
-
getPropertyKeyFromStoredKey,
|
|
53
|
-
getIdentifierFromNode,
|
|
54
54
|
} from "./treeNodeApi.js";
|
|
55
55
|
export { createFromCursor } from "./create.js";
|
|
56
56
|
export {
|