@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
|
@@ -10,10 +10,9 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
type AnchorEvents,
|
|
13
|
-
|
|
13
|
+
dummyRoot,
|
|
14
14
|
type FieldKey,
|
|
15
15
|
type FieldKindIdentifier,
|
|
16
|
-
forbiddenFieldKindIdentifier,
|
|
17
16
|
type ITreeCursorSynchronous,
|
|
18
17
|
type NodeData,
|
|
19
18
|
type NormalizedFieldUpPath,
|
|
@@ -49,8 +48,10 @@ import {
|
|
|
49
48
|
type MapTreeFieldViewGeneric,
|
|
50
49
|
type MapTreeNodeViewGeneric,
|
|
51
50
|
type HydratedFlexTreeNode,
|
|
51
|
+
cursorForMapTreeField,
|
|
52
|
+
type MinimalFieldMap,
|
|
52
53
|
} from "../../feature-libraries/index.js";
|
|
53
|
-
import { brand, filterIterable, getOrCreate } from "../../util/index.js";
|
|
54
|
+
import { brand, filterIterable, getOrCreate, mapIterable } from "../../util/index.js";
|
|
54
55
|
|
|
55
56
|
import type { Context } from "./context.js";
|
|
56
57
|
import type { ContextualFieldProvider } from "../schemaTypes.js";
|
|
@@ -62,10 +63,7 @@ interface UnhydratedTreeSequenceFieldEditBuilder
|
|
|
62
63
|
type UnhydratedFlexTreeNodeEvents = Pick<AnchorEvents, "childrenChangedAfterBatch">;
|
|
63
64
|
|
|
64
65
|
/** A node's parent field and its index in that field */
|
|
65
|
-
|
|
66
|
-
readonly parent: FlexTreeField;
|
|
67
|
-
readonly index: number;
|
|
68
|
-
}
|
|
66
|
+
type LocationInField = FlexTreeNode["parentField"];
|
|
69
67
|
|
|
70
68
|
/**
|
|
71
69
|
* The {@link Unhydrated} implementation of {@link FlexTreeNode}.
|
|
@@ -140,15 +138,16 @@ export class UnhydratedFlexTreeNode
|
|
|
140
138
|
* Due to having to detect if a field is empty, this forces the evaluation of any pending defaults in the fields.
|
|
141
139
|
* Use {@link allFieldsLazy} to avoid evaluating pending defaults.
|
|
142
140
|
*/
|
|
143
|
-
public readonly fields:
|
|
144
|
-
Map<FieldKey, UnhydratedFlexTreeField>,
|
|
145
|
-
typeof Symbol.iterator | "get"
|
|
146
|
-
> = {
|
|
141
|
+
public readonly fields: MinimalFieldMap<UnhydratedFlexTreeField> = {
|
|
147
142
|
get: (key: FieldKey): UnhydratedFlexTreeField | undefined => this.tryGetField(key),
|
|
148
143
|
[Symbol.iterator]: (): IterableIterator<[FieldKey, UnhydratedFlexTreeField]> =>
|
|
149
144
|
filterIterable(this.fieldsAll, ([, field]) => field.length > 0),
|
|
150
145
|
};
|
|
151
146
|
|
|
147
|
+
public [Symbol.iterator](): IterableIterator<UnhydratedFlexTreeField> {
|
|
148
|
+
return mapIterable(this.fields, ([, field]) => field)[Symbol.iterator]();
|
|
149
|
+
}
|
|
150
|
+
|
|
152
151
|
/**
|
|
153
152
|
* Gets all fields, without filtering out empty ones.
|
|
154
153
|
* @remarks
|
|
@@ -162,10 +161,6 @@ export class UnhydratedFlexTreeNode
|
|
|
162
161
|
return this.data.type;
|
|
163
162
|
}
|
|
164
163
|
|
|
165
|
-
public get schema(): TreeNodeSchemaIdentifier {
|
|
166
|
-
return this.data.type;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
164
|
private getOrCreateField(key: FieldKey): UnhydratedFlexTreeField {
|
|
170
165
|
return getOrCreate(this.fieldsAll, key, () => {
|
|
171
166
|
const stored = this.storedSchema.getFieldSchema(key).kind;
|
|
@@ -239,10 +234,6 @@ export class UnhydratedFlexTreeNode
|
|
|
239
234
|
return this.getOrCreateField(fieldKey);
|
|
240
235
|
}
|
|
241
236
|
|
|
242
|
-
public boxedIterator(): IterableIterator<FlexTreeField> {
|
|
243
|
-
return Array.from(this.fields, ([key, field]) => field)[Symbol.iterator]();
|
|
244
|
-
}
|
|
245
|
-
|
|
246
237
|
public keys(): IterableIterator<FieldKey> {
|
|
247
238
|
return Array.from(this.fields, ([key]) => key)[Symbol.iterator]();
|
|
248
239
|
}
|
|
@@ -288,31 +279,16 @@ export class UnhydratedContext implements FlexTreeContext {
|
|
|
288
279
|
* However, this field cannot be used in any practical way because it is empty, i.e. it does not actually contain the children that claim to be parented under it.
|
|
289
280
|
* It has the "empty" schema and it will always contain zero children if queried.
|
|
290
281
|
* Any nodes with this location will have a dummy parent index of `-1`.
|
|
282
|
+
*
|
|
283
|
+
* TODO: make this make sense.
|
|
291
284
|
*/
|
|
292
285
|
const unparentedLocation: LocationInField = {
|
|
293
286
|
parent: {
|
|
294
|
-
|
|
295
|
-
length: 0,
|
|
296
|
-
key: EmptyKey,
|
|
287
|
+
key: dummyRoot,
|
|
297
288
|
parent: undefined,
|
|
298
|
-
|
|
299
|
-
return this.schema === kind.identifier;
|
|
300
|
-
},
|
|
301
|
-
boxedIterator(): IterableIterator<FlexTreeNode> {
|
|
302
|
-
return [].values();
|
|
303
|
-
},
|
|
304
|
-
boxedAt(index: number): FlexTreeNode | undefined {
|
|
305
|
-
return undefined;
|
|
306
|
-
},
|
|
307
|
-
schema: brand(forbiddenFieldKindIdentifier),
|
|
308
|
-
get context(): never {
|
|
309
|
-
return fail(0xb48 /* unsupported */);
|
|
310
|
-
},
|
|
311
|
-
getFieldPath() {
|
|
312
|
-
fail(0xb49 /* unsupported */);
|
|
313
|
-
},
|
|
289
|
+
schema: brand(FieldKinds.optional.identifier),
|
|
314
290
|
},
|
|
315
|
-
index:
|
|
291
|
+
index: 0,
|
|
316
292
|
};
|
|
317
293
|
|
|
318
294
|
/**
|
|
@@ -347,6 +323,12 @@ export class UnhydratedFlexTreeField
|
|
|
347
323
|
}
|
|
348
324
|
}
|
|
349
325
|
|
|
326
|
+
public borrowCursor(): ITreeCursorSynchronous {
|
|
327
|
+
return cursorForMapTreeField<MapTreeNodeViewGeneric<UnhydratedFlexTreeNode>>(
|
|
328
|
+
this.children,
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
350
332
|
private getPendingDefault(): ContextualFieldProvider | undefined {
|
|
351
333
|
return !Array.isArray(this.lazyChildren) ? this.lazyChildren : undefined;
|
|
352
334
|
}
|
|
@@ -389,10 +371,6 @@ export class UnhydratedFlexTreeField
|
|
|
389
371
|
return this.schema === kind.identifier;
|
|
390
372
|
}
|
|
391
373
|
|
|
392
|
-
public boxedIterator(): IterableIterator<UnhydratedFlexTreeNode> {
|
|
393
|
-
return this.children[Symbol.iterator]();
|
|
394
|
-
}
|
|
395
|
-
|
|
396
374
|
public boxedAt(index: number): FlexTreeNode | undefined {
|
|
397
375
|
const i = indexForAt(index, this.length);
|
|
398
376
|
if (i === undefined) {
|
|
@@ -403,7 +381,7 @@ export class UnhydratedFlexTreeField
|
|
|
403
381
|
}
|
|
404
382
|
|
|
405
383
|
public [Symbol.iterator](): IterableIterator<UnhydratedFlexTreeNode> {
|
|
406
|
-
return this.
|
|
384
|
+
return this.children[Symbol.iterator]();
|
|
407
385
|
}
|
|
408
386
|
|
|
409
387
|
/**
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
|
+
asTreeNodeSchemaCorePrivate,
|
|
8
|
+
type NormalizedAnnotatedAllowedTypes,
|
|
9
|
+
type TreeNodeSchema,
|
|
10
|
+
} from "./treeNodeSchema.js";
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
* Traverses all {@link TreeNodeSchema} schema reachable from `schema`, applying the visitor pattern.
|
|
@@ -16,9 +20,14 @@ export function walkNodeSchema(
|
|
|
16
20
|
if (visitedSet.has(schema)) {
|
|
17
21
|
return;
|
|
18
22
|
}
|
|
23
|
+
|
|
19
24
|
visitedSet.add(schema);
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
const annotatedAllowedTypes = asTreeNodeSchemaCorePrivate(schema).childAnnotatedAllowedTypes;
|
|
27
|
+
|
|
28
|
+
for (const fieldAllowedTypes of annotatedAllowedTypes) {
|
|
29
|
+
walkAllowedTypes(fieldAllowedTypes, visitor, visitedSet);
|
|
30
|
+
}
|
|
22
31
|
|
|
23
32
|
// This visit is done at the end so the traversal order is most inner types first.
|
|
24
33
|
// This was picked since when fixing errors,
|
|
@@ -31,14 +40,14 @@ export function walkNodeSchema(
|
|
|
31
40
|
* Traverses all {@link TreeNodeSchema} schema reachable from `allowedTypes`, applying the visitor pattern.
|
|
32
41
|
*/
|
|
33
42
|
export function walkAllowedTypes(
|
|
34
|
-
|
|
43
|
+
annotatedAllowedTypes: NormalizedAnnotatedAllowedTypes,
|
|
35
44
|
visitor: SchemaVisitor,
|
|
36
45
|
visitedSet: Set<TreeNodeSchema> = new Set(),
|
|
37
46
|
): void {
|
|
38
|
-
for (const
|
|
39
|
-
walkNodeSchema(
|
|
47
|
+
for (const { type } of annotatedAllowedTypes.types) {
|
|
48
|
+
walkNodeSchema(type, visitor, visitedSet);
|
|
40
49
|
}
|
|
41
|
-
visitor.allowedTypes?.(
|
|
50
|
+
visitor.allowedTypes?.(annotatedAllowedTypes);
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
/**
|
|
@@ -55,5 +64,5 @@ export interface SchemaVisitor {
|
|
|
55
64
|
*
|
|
56
65
|
* This includes every field, but also the allowed types array for maps and arrays and the root if starting at {@link walkAllowedTypes}.
|
|
57
66
|
*/
|
|
58
|
-
allowedTypes?: (allowedTypes:
|
|
67
|
+
allowedTypes?: (allowedTypes: NormalizedAnnotatedAllowedTypes) => void;
|
|
59
68
|
}
|
|
@@ -20,6 +20,6 @@ export function getUnhydratedContext(schema: ImplicitFieldSchema): Context {
|
|
|
20
20
|
const normalized = normalizeFieldSchema(schema);
|
|
21
21
|
|
|
22
22
|
const flexContext = new UnhydratedContext(defaultSchemaPolicy, toStoredSchema(schema));
|
|
23
|
-
return new Context(normalized.
|
|
23
|
+
return new Context(normalized.annotatedAllowedTypesNormalized, flexContext);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -19,7 +19,9 @@ import { type TreeNode, getOrCreateNodeFromInnerNode } from "./core/index.js";
|
|
|
19
19
|
/**
|
|
20
20
|
* Retrieve the associated {@link TreeNode} for the given field's content.
|
|
21
21
|
*/
|
|
22
|
-
export function
|
|
22
|
+
export function tryGetTreeNodeForField(
|
|
23
|
+
field: FlexTreeField,
|
|
24
|
+
): TreeNode | TreeValue | undefined {
|
|
23
25
|
function tryToUnboxLeaves(
|
|
24
26
|
flexField: FlexTreeOptionalField | FlexTreeRequiredField,
|
|
25
27
|
): TreeNode | TreeValue | undefined {
|
package/src/simple-tree/index.ts
CHANGED
|
@@ -8,6 +8,8 @@ export {
|
|
|
8
8
|
typeSchemaSymbol,
|
|
9
9
|
type WithType,
|
|
10
10
|
type TreeNodeSchema,
|
|
11
|
+
type AnnotatedAllowedType,
|
|
12
|
+
type NormalizedAnnotatedAllowedTypes,
|
|
11
13
|
NodeKind,
|
|
12
14
|
type TreeNodeSchemaClass,
|
|
13
15
|
type TreeNodeSchemaNonClass,
|
|
@@ -23,6 +25,7 @@ export {
|
|
|
23
25
|
SimpleContextSlot,
|
|
24
26
|
getOrCreateInnerNode,
|
|
25
27
|
getOrCreateNodeFromInnerNode,
|
|
28
|
+
getOrCreateNodeFromInnerUnboxedNode,
|
|
26
29
|
getKernel,
|
|
27
30
|
} from "./core/index.js";
|
|
28
31
|
export {
|
|
@@ -83,9 +86,9 @@ export {
|
|
|
83
86
|
type TreeViewAlpha,
|
|
84
87
|
type TreeBranch,
|
|
85
88
|
type TreeBranchEvents,
|
|
86
|
-
tryGetSchema,
|
|
87
|
-
getStoredKey,
|
|
88
89
|
getPropertyKeyFromStoredKey,
|
|
90
|
+
getStoredKey,
|
|
91
|
+
tryGetSchema,
|
|
89
92
|
applySchemaToParserOptions,
|
|
90
93
|
cursorFromVerbose,
|
|
91
94
|
verboseFromCursor,
|
|
@@ -131,13 +134,12 @@ export type {
|
|
|
131
134
|
SimpleArrayNodeSchema,
|
|
132
135
|
SimpleObjectNodeSchema,
|
|
133
136
|
SimpleNodeSchemaBase,
|
|
137
|
+
SimpleNodeSchemaBaseAlpha,
|
|
134
138
|
SimpleObjectFieldSchema,
|
|
135
139
|
} from "./simpleSchema.js";
|
|
136
140
|
export {
|
|
137
141
|
type NodeFromSchema,
|
|
138
142
|
isTreeNodeSchemaClass,
|
|
139
|
-
type AnnotatedAllowedType,
|
|
140
|
-
type AnnotatedAllowedTypes,
|
|
141
143
|
type ImplicitFieldSchema,
|
|
142
144
|
type ImplicitAnnotatedFieldSchema,
|
|
143
145
|
type TreeFieldFromImplicitField,
|
|
@@ -156,6 +158,7 @@ export {
|
|
|
156
158
|
type AllowedTypes,
|
|
157
159
|
type AllowedTypeMetadata,
|
|
158
160
|
type AllowedTypesMetadata,
|
|
161
|
+
type AnnotatedAllowedTypes,
|
|
159
162
|
FieldKind,
|
|
160
163
|
FieldSchema,
|
|
161
164
|
type FieldSchemaAlpha,
|
|
@@ -164,6 +167,7 @@ export {
|
|
|
164
167
|
type NodeBuilderData,
|
|
165
168
|
type DefaultProvider,
|
|
166
169
|
type FieldProps,
|
|
170
|
+
type FieldPropsAlpha,
|
|
167
171
|
normalizeFieldSchema,
|
|
168
172
|
areFieldSchemaEqual,
|
|
169
173
|
areImplicitFieldSchemaEqual,
|
|
@@ -179,14 +183,16 @@ export {
|
|
|
179
183
|
type ReadableField,
|
|
180
184
|
type ReadSchema,
|
|
181
185
|
type NodeSchemaOptions,
|
|
186
|
+
type NodeSchemaOptionsAlpha,
|
|
182
187
|
type NodeSchemaMetadata,
|
|
183
188
|
evaluateLazySchema,
|
|
184
189
|
} from "./schemaTypes.js";
|
|
185
|
-
export {
|
|
190
|
+
export { tryGetTreeNodeForField } from "./getTreeNodeForField.js";
|
|
186
191
|
export {
|
|
187
192
|
type ArrayNodeCustomizableSchema,
|
|
188
193
|
type ArrayNodePojoEmulationSchema,
|
|
189
194
|
ArrayNodeSchema,
|
|
195
|
+
asIndex,
|
|
190
196
|
isArrayNodeSchema,
|
|
191
197
|
IterableTreeArrayContent,
|
|
192
198
|
type ReadonlyArrayNode,
|
|
@@ -201,6 +207,7 @@ export {
|
|
|
201
207
|
type InsertableObjectFromSchemaRecord,
|
|
202
208
|
type ObjectFromSchemaRecord,
|
|
203
209
|
ObjectNodeSchema,
|
|
210
|
+
isObjectNodeSchema,
|
|
204
211
|
type InsertableObjectFromAnnotatedSchemaRecord,
|
|
205
212
|
type TreeObjectNode,
|
|
206
213
|
setField,
|
|
@@ -12,9 +12,15 @@ import {
|
|
|
12
12
|
valueSchemaAllows,
|
|
13
13
|
} from "../feature-libraries/index.js";
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
NodeKind,
|
|
17
|
+
type NormalizedAnnotatedAllowedTypes,
|
|
18
|
+
type TreeNodeSchema,
|
|
19
|
+
type TreeNodeSchemaNonClass,
|
|
20
|
+
} from "./core/index.js";
|
|
16
21
|
import type { NodeSchemaMetadata, TreeLeafValue } from "./schemaTypes.js";
|
|
17
22
|
import type { SimpleLeafNodeSchema } from "./simpleSchema.js";
|
|
23
|
+
import type { JsonCompatibleReadOnlyObject } from "../util/index.js";
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
26
|
* Instances of this class are schema for leaf nodes.
|
|
@@ -33,6 +39,7 @@ export class LeafNodeSchema<Name extends string, const T extends ValueSchema>
|
|
|
33
39
|
public readonly info: T;
|
|
34
40
|
public readonly implicitlyConstructable = true as const;
|
|
35
41
|
public readonly childTypes: ReadonlySet<TreeNodeSchema> = new Set();
|
|
42
|
+
public readonly childAnnotatedAllowedTypes: readonly NormalizedAnnotatedAllowedTypes[] = [];
|
|
36
43
|
|
|
37
44
|
public create(data: TreeValue<T> | FlexTreeNode): TreeValue<T> {
|
|
38
45
|
if (isFlexTreeNode(data)) {
|
|
@@ -50,6 +57,7 @@ export class LeafNodeSchema<Name extends string, const T extends ValueSchema>
|
|
|
50
57
|
public readonly leafKind: ValueSchema;
|
|
51
58
|
|
|
52
59
|
public readonly metadata: NodeSchemaMetadata = {};
|
|
60
|
+
public readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined;
|
|
53
61
|
|
|
54
62
|
public constructor(name: Name, t: T) {
|
|
55
63
|
this.identifier = name;
|
|
@@ -7,14 +7,14 @@ import { Lazy, oob, fail } from "@fluidframework/core-utils/internal";
|
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
|
|
9
9
|
import { EmptyKey } from "../../../core/index.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
isFlexTreeNode,
|
|
10
|
+
import type {
|
|
11
|
+
FlexibleFieldContent,
|
|
12
|
+
FlexTreeNode,
|
|
13
|
+
FlexTreeSequenceField,
|
|
15
14
|
} from "../../../feature-libraries/index.js";
|
|
16
15
|
import {
|
|
17
16
|
normalizeAllowedTypes,
|
|
17
|
+
normalizeAnnotatedAllowedTypes,
|
|
18
18
|
unannotateImplicitAllowedTypes,
|
|
19
19
|
type ImplicitAllowedTypes,
|
|
20
20
|
type ImplicitAnnotatedAllowedTypes,
|
|
@@ -41,6 +41,8 @@ import {
|
|
|
41
41
|
getKernel,
|
|
42
42
|
type UnhydratedFlexTreeNode,
|
|
43
43
|
UnhydratedSequenceField,
|
|
44
|
+
getOrCreateNodeFromInnerUnboxedNode,
|
|
45
|
+
type NormalizedAnnotatedAllowedTypes,
|
|
44
46
|
} from "../../core/index.js";
|
|
45
47
|
import {
|
|
46
48
|
type InsertableContent,
|
|
@@ -54,6 +56,7 @@ import type {
|
|
|
54
56
|
ArrayNodeCustomizableSchema,
|
|
55
57
|
ArrayNodePojoEmulationSchema,
|
|
56
58
|
} from "./arrayNodeTypes.js";
|
|
59
|
+
import type { JsonCompatibleReadOnlyObject } from "../../../util/index.js";
|
|
57
60
|
|
|
58
61
|
/**
|
|
59
62
|
* A covariant base type for {@link (TreeArrayNode:interface)}.
|
|
@@ -734,9 +737,9 @@ function createArrayNodeProxy(
|
|
|
734
737
|
}
|
|
735
738
|
|
|
736
739
|
const maybeContent = field.at(maybeIndex);
|
|
737
|
-
return
|
|
738
|
-
?
|
|
739
|
-
: maybeContent;
|
|
740
|
+
return maybeContent === undefined
|
|
741
|
+
? undefined
|
|
742
|
+
: getOrCreateNodeFromInnerUnboxedNode(maybeContent);
|
|
740
743
|
},
|
|
741
744
|
set: (target, key, newValue, receiver) => {
|
|
742
745
|
if (key === "length") {
|
|
@@ -795,7 +798,7 @@ function createArrayNodeProxy(
|
|
|
795
798
|
// To satisfy 'deepEquals' level scrutiny, the property descriptor for indexed properties must
|
|
796
799
|
// be a simple value property (as opposed to using getter) and declared writable/enumerable/configurable.
|
|
797
800
|
return {
|
|
798
|
-
value:
|
|
801
|
+
value: val === undefined ? undefined : getOrCreateNodeFromInnerUnboxedNode(val),
|
|
799
802
|
writable: true, // For MVP, setting indexed properties is reported as allowed here (for deep equals compatibility noted above), but not actually supported.
|
|
800
803
|
enumerable: true,
|
|
801
804
|
configurable: true,
|
|
@@ -1082,6 +1085,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
1082
1085
|
* Define a {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.
|
|
1083
1086
|
*
|
|
1084
1087
|
* @param name - Unique identifier for this schema including the factory's scope.
|
|
1088
|
+
* @param persistedMetadata - Optional persisted metadata for the object node schema.
|
|
1085
1089
|
*/
|
|
1086
1090
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
1087
1091
|
export function arraySchema<
|
|
@@ -1095,6 +1099,7 @@ export function arraySchema<
|
|
|
1095
1099
|
implicitlyConstructable: ImplicitlyConstructable,
|
|
1096
1100
|
customizable: boolean,
|
|
1097
1101
|
metadata?: NodeSchemaMetadata<TCustomMetadata>,
|
|
1102
|
+
persistedMetadata?: JsonCompatibleReadOnlyObject | undefined,
|
|
1098
1103
|
) {
|
|
1099
1104
|
type Output = ArrayNodeCustomizableSchema<
|
|
1100
1105
|
TName,
|
|
@@ -1107,6 +1112,7 @@ export function arraySchema<
|
|
|
1107
1112
|
const unannotatedTypes = unannotateImplicitAllowedTypes(info);
|
|
1108
1113
|
|
|
1109
1114
|
const lazyChildTypes = new Lazy(() => normalizeAllowedTypes(unannotatedTypes));
|
|
1115
|
+
const lazyAnnotatedTypes = new Lazy(() => [normalizeAnnotatedAllowedTypes(info)]);
|
|
1110
1116
|
const lazyAllowedTypesIdentifiers = new Lazy(
|
|
1111
1117
|
() => new Set([...lazyChildTypes.value].map((type) => type.identifier)),
|
|
1112
1118
|
);
|
|
@@ -1189,7 +1195,12 @@ export function arraySchema<
|
|
|
1189
1195
|
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
1190
1196
|
return lazyChildTypes.value;
|
|
1191
1197
|
}
|
|
1198
|
+
public static get childAnnotatedAllowedTypes(): readonly NormalizedAnnotatedAllowedTypes[] {
|
|
1199
|
+
return lazyAnnotatedTypes.value;
|
|
1200
|
+
}
|
|
1192
1201
|
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> = metadata ?? {};
|
|
1202
|
+
public static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =
|
|
1203
|
+
persistedMetadata;
|
|
1193
1204
|
|
|
1194
1205
|
// eslint-disable-next-line import/no-deprecated
|
|
1195
1206
|
public get [typeNameSymbol](): TName {
|
|
@@ -10,11 +10,12 @@ import type {
|
|
|
10
10
|
FlexTreeOptionalField,
|
|
11
11
|
OptionalFieldEditBuilder,
|
|
12
12
|
} from "../../../feature-libraries/index.js";
|
|
13
|
-
import {
|
|
13
|
+
import { tryGetTreeNodeForField } from "../../getTreeNodeForField.js";
|
|
14
14
|
import {
|
|
15
15
|
createFieldSchema,
|
|
16
16
|
FieldKind,
|
|
17
17
|
normalizeAllowedTypes,
|
|
18
|
+
normalizeAnnotatedAllowedTypes,
|
|
18
19
|
unannotateImplicitAllowedTypes,
|
|
19
20
|
type ImplicitAllowedTypes,
|
|
20
21
|
type ImplicitAnnotatedAllowedTypes,
|
|
@@ -36,6 +37,7 @@ import {
|
|
|
36
37
|
getOrCreateInnerNode,
|
|
37
38
|
type InternalTreeNode,
|
|
38
39
|
type UnhydratedFlexTreeNode,
|
|
40
|
+
type NormalizedAnnotatedAllowedTypes,
|
|
39
41
|
} from "../../core/index.js";
|
|
40
42
|
import {
|
|
41
43
|
unhydratedFlexTreeFromInsertable,
|
|
@@ -43,7 +45,12 @@ import {
|
|
|
43
45
|
type InsertableContent,
|
|
44
46
|
} from "../../unhydratedFlexTreeFromInsertable.js";
|
|
45
47
|
import { prepareForInsertion } from "../../prepareForInsertion.js";
|
|
46
|
-
import {
|
|
48
|
+
import {
|
|
49
|
+
brand,
|
|
50
|
+
count,
|
|
51
|
+
type JsonCompatibleReadOnlyObject,
|
|
52
|
+
type RestrictiveStringRecord,
|
|
53
|
+
} from "../../../util/index.js";
|
|
47
54
|
import { TreeNodeValid, type MostDerivedData } from "../../treeNodeValid.js";
|
|
48
55
|
import { getUnhydratedContext } from "../../createContext.js";
|
|
49
56
|
import type { MapNodeCustomizableSchema, MapNodePojoEmulationSchema } from "./mapNodeTypes.js";
|
|
@@ -172,14 +179,14 @@ abstract class CustomMapNodeBase<const T extends ImplicitAllowedTypes> extends T
|
|
|
172
179
|
for (const key of node.keys()) {
|
|
173
180
|
yield [
|
|
174
181
|
key,
|
|
175
|
-
|
|
182
|
+
tryGetTreeNodeForField(node.getBoxed(key)) as TreeNodeFromImplicitAllowedTypes<T>,
|
|
176
183
|
];
|
|
177
184
|
}
|
|
178
185
|
}
|
|
179
186
|
public get(key: string): TreeNodeFromImplicitAllowedTypes<T> {
|
|
180
187
|
const node = this.innerNode;
|
|
181
188
|
const field = node.getBoxed(brand(key));
|
|
182
|
-
return
|
|
189
|
+
return tryGetTreeNodeForField(field) as TreeNodeFromImplicitAllowedTypes<T>;
|
|
183
190
|
}
|
|
184
191
|
public has(key: string): boolean {
|
|
185
192
|
return this.innerNode.tryGetField(brand(key)) !== undefined;
|
|
@@ -215,8 +222,8 @@ abstract class CustomMapNodeBase<const T extends ImplicitAllowedTypes> extends T
|
|
|
215
222
|
callbackFn: (value: TreeNodeFromImplicitAllowedTypes<T>, key: string, map: TThis) => void,
|
|
216
223
|
thisArg?: unknown,
|
|
217
224
|
): void {
|
|
218
|
-
for (const field of getOrCreateInnerNode(this)
|
|
219
|
-
const node =
|
|
225
|
+
for (const field of getOrCreateInnerNode(this)) {
|
|
226
|
+
const node = tryGetTreeNodeForField(field) as TreeNodeFromImplicitAllowedTypes<T>;
|
|
220
227
|
callbackFn.call(thisArg, node, field.key, this);
|
|
221
228
|
}
|
|
222
229
|
}
|
|
@@ -228,6 +235,7 @@ abstract class CustomMapNodeBase<const T extends ImplicitAllowedTypes> extends T
|
|
|
228
235
|
*
|
|
229
236
|
* @param base - base schema type to extend.
|
|
230
237
|
* @param useMapPrototype - should this type emulate a ES6 Map object (by faking its prototype with a proxy).
|
|
238
|
+
* @param persistedMetadata - Optional persisted metadata for the object node schema.
|
|
231
239
|
*/
|
|
232
240
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
233
241
|
export function mapSchema<
|
|
@@ -241,10 +249,12 @@ export function mapSchema<
|
|
|
241
249
|
implicitlyConstructable: ImplicitlyConstructable,
|
|
242
250
|
useMapPrototype: boolean,
|
|
243
251
|
metadata?: NodeSchemaMetadata<TCustomMetadata>,
|
|
252
|
+
persistedMetadata?: JsonCompatibleReadOnlyObject | undefined,
|
|
244
253
|
) {
|
|
245
254
|
const lazyChildTypes = new Lazy(() =>
|
|
246
255
|
normalizeAllowedTypes(unannotateImplicitAllowedTypes(info)),
|
|
247
256
|
);
|
|
257
|
+
const lazyAnnotatedTypes = new Lazy(() => [normalizeAnnotatedAllowedTypes(info)]);
|
|
248
258
|
const lazyAllowedTypesIdentifiers = new Lazy(
|
|
249
259
|
() => new Set([...lazyChildTypes.value].map((type) => type.identifier)),
|
|
250
260
|
);
|
|
@@ -293,7 +303,12 @@ export function mapSchema<
|
|
|
293
303
|
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
294
304
|
return lazyChildTypes.value;
|
|
295
305
|
}
|
|
306
|
+
public static get childAnnotatedAllowedTypes(): readonly NormalizedAnnotatedAllowedTypes[] {
|
|
307
|
+
return lazyAnnotatedTypes.value;
|
|
308
|
+
}
|
|
296
309
|
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> = metadata ?? {};
|
|
310
|
+
public static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =
|
|
311
|
+
persistedMetadata;
|
|
297
312
|
|
|
298
313
|
// eslint-disable-next-line import/no-deprecated
|
|
299
314
|
public get [typeNameSymbol](): TName {
|
|
@@ -14,7 +14,11 @@ import {
|
|
|
14
14
|
type FlexTreeOptionalField,
|
|
15
15
|
type FlexTreeRequiredField,
|
|
16
16
|
} from "../../../feature-libraries/index.js";
|
|
17
|
-
import type {
|
|
17
|
+
import type {
|
|
18
|
+
RestrictiveStringRecord,
|
|
19
|
+
FlattenKeys,
|
|
20
|
+
JsonCompatibleReadOnlyObject,
|
|
21
|
+
} from "../../../util/index.js";
|
|
18
22
|
|
|
19
23
|
import {
|
|
20
24
|
type TreeNodeSchema,
|
|
@@ -28,9 +32,10 @@ import {
|
|
|
28
32
|
type Context,
|
|
29
33
|
type UnhydratedFlexTreeNode,
|
|
30
34
|
getOrCreateInnerNode,
|
|
35
|
+
type NormalizedAnnotatedAllowedTypes,
|
|
31
36
|
} from "../../core/index.js";
|
|
32
37
|
import { getUnhydratedContext } from "../../createContext.js";
|
|
33
|
-
import {
|
|
38
|
+
import { tryGetTreeNodeForField } from "../../getTreeNodeForField.js";
|
|
34
39
|
import {
|
|
35
40
|
isObjectNodeSchema,
|
|
36
41
|
type ObjectNodeSchema,
|
|
@@ -50,7 +55,6 @@ import {
|
|
|
50
55
|
type FieldSchemaAlpha,
|
|
51
56
|
ObjectFieldSchema,
|
|
52
57
|
type ImplicitAnnotatedFieldSchema,
|
|
53
|
-
unannotateSchemaRecord,
|
|
54
58
|
type UnannotateSchemaRecord,
|
|
55
59
|
} from "../../schemaTypes.js";
|
|
56
60
|
import type { SimpleObjectFieldSchema } from "../../simpleSchema.js";
|
|
@@ -190,7 +194,9 @@ export type SimpleKeyMap = ReadonlyMap<
|
|
|
190
194
|
/**
|
|
191
195
|
* Caches the mappings from property keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.
|
|
192
196
|
*/
|
|
193
|
-
function createFlexKeyMapping(
|
|
197
|
+
function createFlexKeyMapping(
|
|
198
|
+
fields: Record<string, ImplicitAnnotatedFieldSchema>,
|
|
199
|
+
): SimpleKeyMap {
|
|
194
200
|
const keyMap: Map<string | symbol, { storedKey: FieldKey; schema: FieldSchema }> = new Map();
|
|
195
201
|
for (const [propertyKey, fieldSchema] of Object.entries(fields)) {
|
|
196
202
|
const storedKey = getStoredKey(propertyKey, fieldSchema);
|
|
@@ -230,13 +236,13 @@ function createProxyHandler(
|
|
|
230
236
|
debugAssert(() => !flexNode.context.isDisposed() || "FlexTreeNode is disposed");
|
|
231
237
|
const field = flexNode.tryGetField(fieldInfo.storedKey);
|
|
232
238
|
if (field !== undefined) {
|
|
233
|
-
return
|
|
239
|
+
return tryGetTreeNodeForField(field);
|
|
234
240
|
}
|
|
235
241
|
|
|
236
242
|
return undefined;
|
|
237
243
|
}
|
|
238
244
|
|
|
239
|
-
// POJO mode objects don't have TreeNode's
|
|
245
|
+
// POJO mode objects don't have TreeNode's built in members on their targets, so special case them:
|
|
240
246
|
if (propertyKey === typeSchemaSymbol) {
|
|
241
247
|
return schema;
|
|
242
248
|
}
|
|
@@ -298,7 +304,7 @@ function createProxyHandler(
|
|
|
298
304
|
const field = getOrCreateInnerNode(proxy).tryGetField(fieldInfo.storedKey);
|
|
299
305
|
|
|
300
306
|
const p: PropertyDescriptor = {
|
|
301
|
-
value: field === undefined ? undefined :
|
|
307
|
+
value: field === undefined ? undefined : tryGetTreeNodeForField(field),
|
|
302
308
|
writable: true,
|
|
303
309
|
// Report empty fields as own properties so they shadow inherited properties (even when empty) to match TypeScript typing.
|
|
304
310
|
// Make empty fields not enumerable so they get skipped when iterating over an object to better align with
|
|
@@ -349,6 +355,7 @@ abstract class CustomObjectNodeBase<
|
|
|
349
355
|
*
|
|
350
356
|
* @param name - Unique identifier for this schema within this factory's scope.
|
|
351
357
|
* @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.
|
|
358
|
+
* @param persistedMetadata - Optional persisted metadata for the object node schema.
|
|
352
359
|
*/
|
|
353
360
|
export function objectSchema<
|
|
354
361
|
TName extends string,
|
|
@@ -361,19 +368,18 @@ export function objectSchema<
|
|
|
361
368
|
implicitlyConstructable: ImplicitlyConstructable,
|
|
362
369
|
allowUnknownOptionalFields: boolean,
|
|
363
370
|
metadata?: NodeSchemaMetadata<TCustomMetadata>,
|
|
371
|
+
persistedMetadata?: JsonCompatibleReadOnlyObject | undefined,
|
|
364
372
|
): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &
|
|
365
373
|
ObjectNodeSchemaInternalData {
|
|
366
374
|
// Field set can't be modified after this since derived data is stored in maps.
|
|
367
375
|
Object.freeze(info);
|
|
368
376
|
|
|
369
|
-
const unannotatedInfo = unannotateSchemaRecord(info);
|
|
370
|
-
|
|
371
377
|
// Ensure no collisions between final set of property keys, and final set of stored keys (including those
|
|
372
378
|
// implicitly derived from property keys)
|
|
373
|
-
assertUniqueKeys(identifier,
|
|
379
|
+
assertUniqueKeys(identifier, info);
|
|
374
380
|
|
|
375
381
|
// Performance optimization: cache property key => stored key and schema.
|
|
376
|
-
const flexKeyMap: SimpleKeyMap = createFlexKeyMapping(
|
|
382
|
+
const flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);
|
|
377
383
|
|
|
378
384
|
const identifierFieldKeys: FieldKey[] = [];
|
|
379
385
|
for (const item of flexKeyMap.values()) {
|
|
@@ -385,6 +391,12 @@ export function objectSchema<
|
|
|
385
391
|
const lazyChildTypes = new Lazy(
|
|
386
392
|
() => new Set(Array.from(flexKeyMap.values(), (f) => [...f.schema.allowedTypeSet]).flat()),
|
|
387
393
|
);
|
|
394
|
+
const lazyAnnotatedTypes = new Lazy(() =>
|
|
395
|
+
Array.from(
|
|
396
|
+
flexKeyMap.values(),
|
|
397
|
+
({ schema }) => normalizeFieldSchema(schema).annotatedAllowedTypesNormalized,
|
|
398
|
+
),
|
|
399
|
+
);
|
|
388
400
|
|
|
389
401
|
let handler: ProxyHandler<object>;
|
|
390
402
|
let customizable: boolean;
|
|
@@ -503,7 +515,12 @@ export function objectSchema<
|
|
|
503
515
|
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
504
516
|
return lazyChildTypes.value;
|
|
505
517
|
}
|
|
518
|
+
public static get childAnnotatedAllowedTypes(): readonly NormalizedAnnotatedAllowedTypes[] {
|
|
519
|
+
return lazyAnnotatedTypes.value;
|
|
520
|
+
}
|
|
506
521
|
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> = metadata ?? {};
|
|
522
|
+
public static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =
|
|
523
|
+
persistedMetadata;
|
|
507
524
|
|
|
508
525
|
// eslint-disable-next-line import/no-deprecated
|
|
509
526
|
public get [typeNameSymbol](): TName {
|
|
@@ -529,7 +546,7 @@ const targetToProxy: WeakMap<object, TreeNode> = new WeakMap();
|
|
|
529
546
|
*/
|
|
530
547
|
function assertUniqueKeys<
|
|
531
548
|
const Name extends number | string,
|
|
532
|
-
const Fields extends RestrictiveStringRecord<
|
|
549
|
+
const Fields extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,
|
|
533
550
|
>(schemaName: Name, fields: Fields): void {
|
|
534
551
|
// Verify that there are no duplicates among the explicitly specified stored keys.
|
|
535
552
|
const explicitStoredKeys = new Set<string>();
|
|
@@ -84,7 +84,11 @@ export function prepareArrayContentForInsertion(
|
|
|
84
84
|
validateAndPrepare(
|
|
85
85
|
getSchemaAndPolicy(destinationContext),
|
|
86
86
|
destinationContext.isHydrated() ? destinationContext : undefined,
|
|
87
|
-
{
|
|
87
|
+
{
|
|
88
|
+
kind: FieldKinds.sequence.identifier,
|
|
89
|
+
types: fieldSchema.types,
|
|
90
|
+
persistedMetadata: undefined,
|
|
91
|
+
},
|
|
88
92
|
mapTrees,
|
|
89
93
|
);
|
|
90
94
|
|