@fluidframework/tree 2.4.0-297385 → 2.4.0-299374
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/.dependency-cruiser-known-violations.json +0 -14
- package/.vscode/settings.json +9 -1
- package/api-report/tree.alpha.api.md +178 -21
- package/api-report/tree.beta.api.md +46 -21
- package/api-report/tree.legacy.alpha.api.md +46 -21
- package/api-report/tree.legacy.public.api.md +46 -21
- package/api-report/tree.public.api.md +46 -21
- package/dist/alpha.d.ts +29 -1
- package/dist/beta.d.ts +2 -0
- package/dist/codec/codec.d.ts +4 -4
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/noopValidator.d.ts +1 -1
- package/dist/codec/noopValidator.js +1 -1
- package/dist/codec/noopValidator.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts +159 -2
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +54 -12
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/external-utilities/typeboxValidator.d.ts +1 -1
- package/dist/external-utilities/typeboxValidator.js +1 -1
- package/dist/external-utilities/typeboxValidator.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +4 -0
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +38 -6
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +0 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +46 -49
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/treeCompressionUtils.d.ts +1 -1
- package/dist/feature-libraries/treeCompressionUtils.js +1 -1
- package/dist/feature-libraries/treeCompressionUtils.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +2 -2
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/legacy.d.ts +2 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +2 -0
- package/dist/shared-tree/index.d.ts +2 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +5 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +1 -14
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +24 -9
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +20 -8
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeApi.d.ts +6 -6
- package/dist/shared-tree/treeApi.d.ts.map +1 -1
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts +29 -0
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -0
- package/dist/simple-tree/api/conciseTree.js +25 -0
- package/dist/simple-tree/api/conciseTree.js.map +1 -0
- package/dist/simple-tree/api/customTree.d.ts +44 -0
- package/dist/simple-tree/api/customTree.d.ts.map +1 -0
- package/dist/simple-tree/api/customTree.js +63 -0
- package/dist/simple-tree/api/customTree.js.map +1 -0
- package/dist/simple-tree/api/index.d.ts +7 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +5 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +41 -26
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js +43 -15
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +1 -2
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +8 -8
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -2
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +78 -0
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -0
- package/dist/simple-tree/api/storedSchema.js +107 -0
- package/dist/simple-tree/api/storedSchema.js.map +1 -0
- package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
- package/dist/simple-tree/api/tree.d.ts +12 -3
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +5 -5
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/{typesUnsafe.d.ts → api/typesUnsafe.d.ts} +58 -10
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -0
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -0
- package/dist/simple-tree/api/verboseTree.d.ts +6 -20
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +10 -48
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +14 -3
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +1 -2
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +1 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +2 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -0
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +14 -1
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +6 -5
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +3 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +3 -1
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js.map +1 -1
- package/dist/simple-tree/flexList.d.ts.map +1 -0
- package/dist/simple-tree/flexList.js.map +1 -0
- package/dist/simple-tree/index.d.ts +6 -7
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +5 -3
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +2 -3
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +3 -4
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +60 -7
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +11 -6
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/dist/simple-tree/toFlexSchema.js +13 -15
- package/dist/simple-tree/toFlexSchema.js.map +1 -1
- package/dist/simple-tree/toMapTree.d.ts +4 -2
- package/dist/simple-tree/toMapTree.d.ts.map +1 -1
- package/dist/simple-tree/toMapTree.js +3 -3
- package/dist/simple-tree/toMapTree.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +2 -1
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/treeFactory.d.ts +1 -0
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +1 -0
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/utils.d.ts +10 -8
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js.map +1 -1
- package/docs/main/detached-trees.md +8 -8
- package/lib/alpha.d.ts +29 -1
- package/lib/beta.d.ts +2 -0
- package/lib/codec/codec.d.ts +4 -4
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/noopValidator.d.ts +1 -1
- package/lib/codec/noopValidator.js +1 -1
- package/lib/codec/noopValidator.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts +159 -2
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +54 -12
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/external-utilities/typeboxValidator.d.ts +1 -1
- package/lib/external-utilities/typeboxValidator.js +1 -1
- package/lib/external-utilities/typeboxValidator.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +4 -0
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +36 -5
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +0 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +0 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/treeCompressionUtils.d.ts +1 -1
- package/lib/feature-libraries/treeCompressionUtils.js +1 -1
- package/lib/feature-libraries/treeCompressionUtils.js.map +1 -1
- package/lib/index.d.ts +6 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +2 -2
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/legacy.d.ts +2 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +2 -0
- package/lib/shared-tree/index.d.ts +2 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +2 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +2 -15
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +24 -9
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +19 -8
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeApi.d.ts +6 -6
- package/lib/shared-tree/treeApi.d.ts.map +1 -1
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts +29 -0
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -0
- package/lib/simple-tree/api/conciseTree.js +21 -0
- package/lib/simple-tree/api/conciseTree.js.map +1 -0
- package/lib/simple-tree/api/customTree.d.ts +44 -0
- package/lib/simple-tree/api/customTree.d.ts.map +1 -0
- package/lib/simple-tree/api/customTree.js +59 -0
- package/lib/simple-tree/api/customTree.js.map +1 -0
- package/lib/simple-tree/api/index.d.ts +7 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -0
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +41 -26
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js +43 -15
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +1 -2
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +1 -1
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -2
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +78 -0
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -0
- package/lib/simple-tree/api/storedSchema.js +101 -0
- package/lib/simple-tree/api/storedSchema.js.map +1 -0
- package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
- package/lib/simple-tree/api/tree.d.ts +12 -3
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +3 -3
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/{typesUnsafe.d.ts → api/typesUnsafe.d.ts} +58 -10
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -0
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -0
- package/lib/simple-tree/api/verboseTree.d.ts +6 -20
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +11 -49
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +14 -3
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +1 -2
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +1 -1
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +1 -1
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -0
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +12 -0
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +6 -5
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +3 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +3 -1
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/flexList.d.ts.map +1 -0
- package/lib/simple-tree/flexList.js.map +1 -0
- package/lib/simple-tree/index.d.ts +6 -7
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +3 -4
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +1 -2
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +1 -2
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +60 -7
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +6 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/lib/simple-tree/toFlexSchema.js +1 -3
- package/lib/simple-tree/toFlexSchema.js.map +1 -1
- package/lib/simple-tree/toMapTree.d.ts +4 -2
- package/lib/simple-tree/toMapTree.d.ts.map +1 -1
- package/lib/simple-tree/toMapTree.js +3 -3
- package/lib/simple-tree/toMapTree.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +2 -1
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/treeFactory.d.ts +1 -0
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +1 -0
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/utils.d.ts +10 -8
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js.map +1 -1
- package/package.json +41 -24
- package/src/codec/codec.ts +4 -4
- package/src/codec/noopValidator.ts +1 -1
- package/src/core/tree/anchorSet.ts +63 -13
- package/src/external-utilities/typeboxValidator.ts +1 -1
- package/src/feature-libraries/flex-tree/lazyField.ts +44 -7
- package/src/feature-libraries/index.ts +0 -10
- package/src/feature-libraries/treeCompressionUtils.ts +1 -1
- package/src/index.ts +26 -6
- package/src/internalTypes.ts +4 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +5 -0
- package/src/shared-tree/schematizingTreeView.ts +7 -16
- package/src/shared-tree/sharedTree.ts +52 -22
- package/src/shared-tree/treeApi.ts +19 -9
- package/src/simple-tree/api/conciseTree.ts +58 -0
- package/src/simple-tree/api/customTree.ts +119 -0
- package/src/simple-tree/api/index.ts +39 -1
- package/src/simple-tree/api/schemaCreationUtilities.ts +55 -36
- package/src/simple-tree/api/schemaFactory.ts +4 -6
- package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -2
- package/src/simple-tree/api/storedSchema.ts +126 -0
- package/src/simple-tree/api/tree.ts +24 -2
- package/src/simple-tree/api/treeNodeApi.ts +3 -8
- package/src/simple-tree/{typesUnsafe.ts → api/typesUnsafe.ts} +95 -21
- package/src/simple-tree/api/verboseTree.ts +21 -76
- package/src/simple-tree/arrayNode.ts +35 -15
- package/src/simple-tree/core/index.ts +1 -0
- package/src/simple-tree/core/treeNodeKernel.ts +13 -0
- package/src/simple-tree/core/treeNodeSchema.ts +7 -5
- package/src/simple-tree/core/unhydratedFlexTree.ts +6 -1
- package/src/simple-tree/core/withType.ts +10 -1
- package/src/simple-tree/index.ts +41 -21
- package/src/simple-tree/mapNode.ts +1 -1
- package/src/simple-tree/objectNode.ts +1 -1
- package/src/simple-tree/schemaTypes.ts +70 -11
- package/src/simple-tree/toFlexSchema.ts +1 -3
- package/src/simple-tree/toMapTree.ts +7 -4
- package/src/simple-tree/treeNodeValid.ts +2 -1
- package/src/treeFactory.ts +1 -0
- package/src/util/utils.ts +10 -8
- package/dist/feature-libraries/flex-tree/unboxed.d.ts +0 -12
- package/dist/feature-libraries/flex-tree/unboxed.d.ts.map +0 -1
- package/dist/feature-libraries/flex-tree/unboxed.js +0 -20
- package/dist/feature-libraries/flex-tree/unboxed.js.map +0 -1
- package/dist/feature-libraries/typed-schema/flexList.d.ts.map +0 -1
- package/dist/feature-libraries/typed-schema/flexList.js.map +0 -1
- package/dist/feature-libraries/typed-schema/index.d.ts +0 -7
- package/dist/feature-libraries/typed-schema/index.d.ts.map +0 -1
- package/dist/feature-libraries/typed-schema/index.js +0 -12
- package/dist/feature-libraries/typed-schema/index.js.map +0 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -14
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +0 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js +0 -7
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +0 -1
- package/dist/simple-tree/proxyBinding.d.ts +0 -15
- package/dist/simple-tree/proxyBinding.d.ts.map +0 -1
- package/dist/simple-tree/proxyBinding.js +0 -22
- package/dist/simple-tree/proxyBinding.js.map +0 -1
- package/dist/simple-tree/typesUnsafe.d.ts.map +0 -1
- package/dist/simple-tree/typesUnsafe.js.map +0 -1
- package/lib/feature-libraries/flex-tree/unboxed.d.ts +0 -12
- package/lib/feature-libraries/flex-tree/unboxed.d.ts.map +0 -1
- package/lib/feature-libraries/flex-tree/unboxed.js +0 -16
- package/lib/feature-libraries/flex-tree/unboxed.js.map +0 -1
- package/lib/feature-libraries/typed-schema/flexList.d.ts.map +0 -1
- package/lib/feature-libraries/typed-schema/flexList.js.map +0 -1
- package/lib/feature-libraries/typed-schema/index.d.ts +0 -7
- package/lib/feature-libraries/typed-schema/index.d.ts.map +0 -1
- package/lib/feature-libraries/typed-schema/index.js +0 -6
- package/lib/feature-libraries/typed-schema/index.js.map +0 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -14
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +0 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js +0 -6
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +0 -1
- package/lib/simple-tree/proxyBinding.d.ts +0 -15
- package/lib/simple-tree/proxyBinding.d.ts.map +0 -1
- package/lib/simple-tree/proxyBinding.js +0 -18
- package/lib/simple-tree/proxyBinding.js.map +0 -1
- package/lib/simple-tree/typesUnsafe.d.ts.map +0 -1
- package/lib/simple-tree/typesUnsafe.js.map +0 -1
- package/src/feature-libraries/flex-tree/unboxed.ts +0 -24
- package/src/feature-libraries/typed-schema/README.md +0 -6
- package/src/feature-libraries/typed-schema/index.ts +0 -16
- package/src/feature-libraries/typed-schema/typedTreeSchema.ts +0 -14
- package/src/simple-tree/proxyBinding.ts +0 -20
- /package/dist/simple-tree/{typesUnsafe.js → api/typesUnsafe.js} +0 -0
- /package/dist/{feature-libraries/typed-schema → simple-tree}/flexList.d.ts +0 -0
- /package/dist/{feature-libraries/typed-schema → simple-tree}/flexList.js +0 -0
- /package/lib/simple-tree/{typesUnsafe.js → api/typesUnsafe.js} +0 -0
- /package/lib/{feature-libraries/typed-schema → simple-tree}/flexList.d.ts +0 -0
- /package/lib/{feature-libraries/typed-schema → simple-tree}/flexList.js +0 -0
- /package/src/simple-tree/{ProxyBinding.md → core/TreeNodeBinding.md} +0 -0
- /package/src/{feature-libraries/typed-schema → simple-tree}/flexList.ts +0 -0
|
@@ -12,11 +12,7 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
|
12
12
|
import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
|
|
13
13
|
|
|
14
14
|
import type { TreeValue } from "../../core/index.js";
|
|
15
|
-
import {
|
|
16
|
-
type NodeKeyManager,
|
|
17
|
-
type Unenforced,
|
|
18
|
-
isLazy,
|
|
19
|
-
} from "../../feature-libraries/index.js";
|
|
15
|
+
import type { NodeKeyManager } from "../../feature-libraries/index.js";
|
|
20
16
|
import {
|
|
21
17
|
type RestrictiveStringRecord,
|
|
22
18
|
getOrCreate,
|
|
@@ -73,9 +69,11 @@ import type {
|
|
|
73
69
|
TreeArrayNodeUnsafe,
|
|
74
70
|
TreeMapNodeUnsafe,
|
|
75
71
|
TreeObjectNodeUnsafe,
|
|
76
|
-
|
|
72
|
+
Unenforced,
|
|
73
|
+
} from "./typesUnsafe.js";
|
|
77
74
|
import { createFieldSchemaUnsafe } from "./schemaFactoryRecursive.js";
|
|
78
75
|
import { TreeNodeValid } from "../treeNodeValid.js";
|
|
76
|
+
import { isLazy } from "../flexList.js";
|
|
79
77
|
/**
|
|
80
78
|
* Gets the leaf domain schema compatible with a given {@link TreeValue}.
|
|
81
79
|
*/
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { Unenforced } from "../../feature-libraries/index.js";
|
|
7
6
|
import type { RestrictiveStringRecord } from "../../util/index.js";
|
|
8
7
|
import type { InsertableObjectFromSchemaRecord } from "../objectNode.js";
|
|
9
8
|
|
|
@@ -22,7 +21,7 @@ import type {
|
|
|
22
21
|
WithType,
|
|
23
22
|
TreeNode,
|
|
24
23
|
} from "../core/index.js";
|
|
25
|
-
import type { FieldSchemaUnsafe } from "
|
|
24
|
+
import type { FieldSchemaUnsafe, Unenforced } from "./typesUnsafe.js";
|
|
26
25
|
|
|
27
26
|
export function createFieldSchemaUnsafe<
|
|
28
27
|
Kind extends FieldKind,
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ICodecOptions } from "../../codec/index.js";
|
|
7
|
+
import { Compatibility, type TreeStoredSchema } from "../../core/index.js";
|
|
8
|
+
import {
|
|
9
|
+
defaultSchemaPolicy,
|
|
10
|
+
encodeTreeSchema,
|
|
11
|
+
makeSchemaCodec,
|
|
12
|
+
} from "../../feature-libraries/index.js";
|
|
13
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
14
|
+
import type { Format } from "../../feature-libraries/schema-index/index.js";
|
|
15
|
+
import type { JsonCompatible } from "../../util/index.js";
|
|
16
|
+
import type { ImplicitFieldSchema } from "../schemaTypes.js";
|
|
17
|
+
import { toStoredSchema } from "../toFlexSchema.js";
|
|
18
|
+
import type { SchemaCompatibilityStatus } from "./tree.js";
|
|
19
|
+
import { ViewSchema } from "./view.js";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable, but unspecified format.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.
|
|
26
|
+
*
|
|
27
|
+
* This format may change across major versions of this package: such changes are considered breaking.
|
|
28
|
+
* Beyond that, no compatibility guarantee is provided for this format: it should never be relied upon to load data, it should only be used for comparing outputs from this function.
|
|
29
|
+
*
|
|
30
|
+
* This only includes the "persisted" subset of schema information, which means the portion which gets included in documents.
|
|
31
|
+
* It thus uses "persisted" keys, see {@link FieldProps.key}.
|
|
32
|
+
*
|
|
33
|
+
* If two schema have identical "persisted" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.
|
|
34
|
+
*
|
|
35
|
+
* See also {@link comparePersistedSchema}.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* An application could use this API to generate a `schema.json` file when it first releases,
|
|
39
|
+
* then test that the schema is sill compatible with documents from that version with a test like :
|
|
40
|
+
* ```typescript
|
|
41
|
+
* assert.deepEqual(extractPersistedSchema(MySchema), require("./schema.json"));
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @privateRemarks
|
|
45
|
+
* This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).
|
|
46
|
+
* This intentionally does not leak the format types in the API.
|
|
47
|
+
*
|
|
48
|
+
* Public API surface uses "persisted" terminology while internally we use "stored".
|
|
49
|
+
* @alpha
|
|
50
|
+
*/
|
|
51
|
+
export function extractPersistedSchema(schema: ImplicitFieldSchema): JsonCompatible {
|
|
52
|
+
const stored = toStoredSchema(schema);
|
|
53
|
+
return encodeTreeSchema(stored);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Compares two schema extracted using {@link extractPersistedSchema}.
|
|
58
|
+
* Reports the same compatibility that {@link TreeView.compatibility} would report if
|
|
59
|
+
* opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.
|
|
60
|
+
*
|
|
61
|
+
* @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.
|
|
62
|
+
* @param view - Schema which would be used to view persisted content. Use {@link extractPersistedSchema} to convert the view schema into this format.
|
|
63
|
+
* @param options - {@link ICodecOptions} used when parsing the provided schema.
|
|
64
|
+
* @param canInitialize - Passed through to the return value unchanged and otherwise unused.
|
|
65
|
+
* @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
* This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.
|
|
69
|
+
* It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,
|
|
73
|
+
* then test that documents using those schema can be upgraded to work with the current schema using a test like:
|
|
74
|
+
* ```typescript
|
|
75
|
+
* assert(
|
|
76
|
+
* comparePersistedSchema(
|
|
77
|
+
* require("./schema.json"),
|
|
78
|
+
* extractPersistedSchema(MySchema),
|
|
79
|
+
* { jsonValidator: typeboxValidator },
|
|
80
|
+
* false,
|
|
81
|
+
* ).canUpgrade,
|
|
82
|
+
* );
|
|
83
|
+
* ```
|
|
84
|
+
* @alpha
|
|
85
|
+
*/
|
|
86
|
+
export function comparePersistedSchema(
|
|
87
|
+
persisted: JsonCompatible,
|
|
88
|
+
view: JsonCompatible,
|
|
89
|
+
options: ICodecOptions,
|
|
90
|
+
canInitialize: boolean,
|
|
91
|
+
): SchemaCompatibilityStatus {
|
|
92
|
+
const schemaCodec = makeSchemaCodec(options);
|
|
93
|
+
const stored = schemaCodec.decode(persisted as Format);
|
|
94
|
+
const viewParsed = schemaCodec.decode(view as Format);
|
|
95
|
+
const viewSchema = new ViewSchema(defaultSchemaPolicy, {}, viewParsed);
|
|
96
|
+
return comparePersistedSchemaInternal(stored, viewSchema, canInitialize);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Compute compatibility for viewing a document with `stored` schema using `viewSchema`.
|
|
101
|
+
* `canInitialize` is passed through to the return value unchanged and otherwise unused.
|
|
102
|
+
*/
|
|
103
|
+
export function comparePersistedSchemaInternal(
|
|
104
|
+
stored: TreeStoredSchema,
|
|
105
|
+
viewSchema: ViewSchema,
|
|
106
|
+
canInitialize: boolean,
|
|
107
|
+
): SchemaCompatibilityStatus {
|
|
108
|
+
const result = viewSchema.checkCompatibility(stored);
|
|
109
|
+
|
|
110
|
+
// TODO: AB#8121: Weaken this check to support viewing under additional circumstances.
|
|
111
|
+
// In the near term, this should support viewing documents with additional optional fields in their schema on object types.
|
|
112
|
+
// Longer-term (as demand arises), we could also add APIs to constructing view schema to allow for more flexibility
|
|
113
|
+
// (e.g. out-of-schema content handlers could allow support for viewing docs which have extra allowed types in a particular field)
|
|
114
|
+
const canView =
|
|
115
|
+
result.write === Compatibility.Compatible && result.read === Compatibility.Compatible;
|
|
116
|
+
const canUpgrade = result.read === Compatibility.Compatible;
|
|
117
|
+
const isEquivalent = canView && canUpgrade;
|
|
118
|
+
const compatibility: SchemaCompatibilityStatus = {
|
|
119
|
+
canView,
|
|
120
|
+
canUpgrade,
|
|
121
|
+
isEquivalent,
|
|
122
|
+
canInitialize,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
return compatibility;
|
|
126
|
+
}
|
|
@@ -11,11 +11,14 @@ import type { Listenable } from "../../events/index.js";
|
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
type ImplicitFieldSchema,
|
|
14
|
+
type InsertableField,
|
|
14
15
|
type InsertableTreeFieldFromImplicitField,
|
|
15
16
|
type TreeFieldFromImplicitField,
|
|
17
|
+
type TreeLeafValue,
|
|
18
|
+
type UnsafeUnknownSchema,
|
|
16
19
|
FieldKind,
|
|
17
20
|
} from "../schemaTypes.js";
|
|
18
|
-
import { NodeKind, type TreeNodeSchema } from "../core/index.js";
|
|
21
|
+
import { NodeKind, type TreeNode, type TreeNodeSchema } from "../core/index.js";
|
|
19
22
|
import { toStoredSchema } from "../toFlexSchema.js";
|
|
20
23
|
import { LeafNodeSchema } from "../leafNodeSchema.js";
|
|
21
24
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
@@ -363,7 +366,7 @@ export function checkUnion(union: Iterable<TreeNodeSchema>, errors: string[]): v
|
|
|
363
366
|
* Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.
|
|
364
367
|
* @sealed @public
|
|
365
368
|
*/
|
|
366
|
-
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
|
369
|
+
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
|
367
370
|
/**
|
|
368
371
|
* The current root of the tree.
|
|
369
372
|
*
|
|
@@ -424,6 +427,25 @@ export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposab
|
|
|
424
427
|
readonly schema: TSchema;
|
|
425
428
|
}
|
|
426
429
|
|
|
430
|
+
/**
|
|
431
|
+
* {@link TreeView} with proposed changes to the schema aware typing to allow use with `UnsafeUnknownSchema`.
|
|
432
|
+
* @alpha
|
|
433
|
+
*/
|
|
434
|
+
export interface TreeViewAlpha<
|
|
435
|
+
in out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,
|
|
436
|
+
> extends Omit<
|
|
437
|
+
TreeView<TSchema extends ImplicitFieldSchema ? TSchema : ImplicitFieldSchema>,
|
|
438
|
+
"root" | "initialize"
|
|
439
|
+
> {
|
|
440
|
+
get root(): TSchema extends ImplicitFieldSchema
|
|
441
|
+
? TreeFieldFromImplicitField<TSchema>
|
|
442
|
+
: TreeLeafValue | TreeNode;
|
|
443
|
+
|
|
444
|
+
set root(newRoot: InsertableField<TSchema>);
|
|
445
|
+
|
|
446
|
+
initialize(content: InsertableField<TSchema>): void;
|
|
447
|
+
}
|
|
448
|
+
|
|
427
449
|
/**
|
|
428
450
|
* Information about a view schema's compatibility with the document's stored schema.
|
|
429
451
|
*
|
|
@@ -6,15 +6,8 @@
|
|
|
6
6
|
import { assert, oob } from "@fluidframework/core-utils/internal";
|
|
7
7
|
|
|
8
8
|
import { EmptyKey, rootFieldKey } from "../../core/index.js";
|
|
9
|
-
import {
|
|
10
|
-
type LazyItem,
|
|
11
|
-
type TreeStatus,
|
|
12
|
-
isLazy,
|
|
13
|
-
isTreeValue,
|
|
14
|
-
FieldKinds,
|
|
15
|
-
} from "../../feature-libraries/index.js";
|
|
9
|
+
import { type TreeStatus, isTreeValue, FieldKinds } from "../../feature-libraries/index.js";
|
|
16
10
|
import { fail, extractFromOpaque, isReadonlyArray } from "../../util/index.js";
|
|
17
|
-
import { getOrCreateInnerNode } from "../proxyBinding.js";
|
|
18
11
|
import {
|
|
19
12
|
type TreeLeafValue,
|
|
20
13
|
type ImplicitFieldSchema,
|
|
@@ -43,8 +36,10 @@ import {
|
|
|
43
36
|
getOrCreateNodeFromInnerNode,
|
|
44
37
|
UnhydratedFlexTreeNode,
|
|
45
38
|
typeSchemaSymbol,
|
|
39
|
+
getOrCreateInnerNode,
|
|
46
40
|
} from "../core/index.js";
|
|
47
41
|
import { isObjectNodeSchema } from "../objectNodeTypes.js";
|
|
42
|
+
import { isLazy, type LazyItem } from "../flexList.js";
|
|
48
43
|
|
|
49
44
|
/**
|
|
50
45
|
* Provides various functions for analyzing {@link TreeNode}s.
|
|
@@ -3,27 +3,27 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
7
|
-
import type { RestrictiveStringRecord, _InlineTrick } from "../util/index.js";
|
|
6
|
+
import type { RestrictiveStringRecord, _InlineTrick } from "../../util/index.js";
|
|
8
7
|
|
|
9
8
|
import type {
|
|
10
|
-
AllowedTypes,
|
|
11
9
|
ApplyKind,
|
|
12
10
|
FieldKind,
|
|
13
11
|
FieldSchema,
|
|
14
12
|
ImplicitAllowedTypes,
|
|
15
13
|
ImplicitFieldSchema,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from "./schemaTypes.js";
|
|
14
|
+
TreeLeafValue,
|
|
15
|
+
} from "../schemaTypes.js";
|
|
19
16
|
import type {
|
|
20
17
|
NodeKind,
|
|
21
|
-
TreeNodeSchema,
|
|
22
18
|
WithType,
|
|
23
19
|
TreeNode,
|
|
24
20
|
Unhydrated,
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
InternalTreeNode,
|
|
22
|
+
TreeNodeSchema,
|
|
23
|
+
TreeNodeSchemaCore,
|
|
24
|
+
} from "../core/index.js";
|
|
25
|
+
import type { TreeArrayNodeBase } from "../arrayNode.js";
|
|
26
|
+
import type { FlexListToUnion, LazyItem } from "../flexList.js";
|
|
27
27
|
|
|
28
28
|
/*
|
|
29
29
|
* TODO:
|
|
@@ -37,6 +37,16 @@ import type { TreeArrayNodeBase, TreeArrayNode } from "./arrayNode.js";
|
|
|
37
37
|
*/
|
|
38
38
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* A placeholder to use in {@link https://www.typescriptlang.org/docs/handbook/2/generics.html#generic-constraints | extends constraints} when using the real type breaks compilation of some recursive types due to {@link https://github.com/microsoft/TypeScript/issues/55758 | a design limitation of TypeScript}.
|
|
42
|
+
*
|
|
43
|
+
* These extends constraints only serve as documentation:
|
|
44
|
+
* to avoid breaking compilation, this type has to not actually enforce anything, and thus is just `unknown`.
|
|
45
|
+
* Therefore the type safety is the responsibility of the user of the API.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export type Unenforced<_DesiredExtendsConstraint> = unknown;
|
|
49
|
+
|
|
40
50
|
/**
|
|
41
51
|
* {@link Unenforced} version of `ObjectFromSchemaRecord`.
|
|
42
52
|
* @remarks
|
|
@@ -49,6 +59,65 @@ export type ObjectFromSchemaRecordUnsafe<
|
|
|
49
59
|
-readonly [Property in keyof T]: TreeFieldFromImplicitFieldUnsafe<T[Property]>;
|
|
50
60
|
};
|
|
51
61
|
|
|
62
|
+
/**
|
|
63
|
+
* {@link Unenforced} version of {@link TreeNodeSchema}.
|
|
64
|
+
* @remarks
|
|
65
|
+
* Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
66
|
+
* @system @public
|
|
67
|
+
*/
|
|
68
|
+
export type TreeNodeSchemaUnsafe<
|
|
69
|
+
Name extends string = string,
|
|
70
|
+
Kind extends NodeKind = NodeKind,
|
|
71
|
+
TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown,
|
|
72
|
+
TBuild = never,
|
|
73
|
+
ImplicitlyConstructable extends boolean = boolean,
|
|
74
|
+
Info = unknown,
|
|
75
|
+
> =
|
|
76
|
+
| TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>
|
|
77
|
+
| TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* {@link Unenforced} version of {@link TreeNodeSchemaClass}.
|
|
81
|
+
* @remarks
|
|
82
|
+
* Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
83
|
+
* @system @public
|
|
84
|
+
*/
|
|
85
|
+
export interface TreeNodeSchemaClassUnsafe<
|
|
86
|
+
out Name extends string,
|
|
87
|
+
out Kind extends NodeKind,
|
|
88
|
+
// TODO: maybe this can be more specific (exclude leaves)
|
|
89
|
+
out TNode extends Unenforced<TreeNode | TreeLeafValue>,
|
|
90
|
+
in TInsertable = never,
|
|
91
|
+
out ImplicitlyConstructable extends boolean = boolean,
|
|
92
|
+
out Info = unknown,
|
|
93
|
+
> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
|
94
|
+
/**
|
|
95
|
+
* Constructs an {@link Unhydrated} node with this schema.
|
|
96
|
+
* @remarks
|
|
97
|
+
* This constructor is also used internally to construct hydrated nodes with a different parameter type.
|
|
98
|
+
* Therefore, overriding this constructor with different argument types is not type-safe and is not supported.
|
|
99
|
+
* @sealed
|
|
100
|
+
*/
|
|
101
|
+
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* {@link Unenforced} version of {@link TreeNodeSchemaNonClass}.
|
|
106
|
+
* @remarks
|
|
107
|
+
* Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
108
|
+
* @system @public
|
|
109
|
+
*/
|
|
110
|
+
export interface TreeNodeSchemaNonClassUnsafe<
|
|
111
|
+
out Name extends string,
|
|
112
|
+
out Kind extends NodeKind,
|
|
113
|
+
out TNode extends Unenforced<TreeNode | TreeLeafValue>,
|
|
114
|
+
in TInsertable = never,
|
|
115
|
+
out ImplicitlyConstructable extends boolean = boolean,
|
|
116
|
+
out Info = unknown,
|
|
117
|
+
> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
|
118
|
+
create(data: TInsertable): TNode;
|
|
119
|
+
}
|
|
120
|
+
|
|
52
121
|
/**
|
|
53
122
|
* {@link Unenforced} version of {@link TreeObjectNode}.
|
|
54
123
|
* @remarks
|
|
@@ -73,6 +142,14 @@ export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<Implicit
|
|
|
73
142
|
? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema>
|
|
74
143
|
: unknown;
|
|
75
144
|
|
|
145
|
+
/**
|
|
146
|
+
* {@link Unenforced} version of {@link AllowedTypes}.
|
|
147
|
+
* @remarks
|
|
148
|
+
* Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
149
|
+
* @system @public
|
|
150
|
+
*/
|
|
151
|
+
export type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
|
152
|
+
|
|
76
153
|
/**
|
|
77
154
|
* {@link Unenforced} version of {@link TreeNodeFromImplicitAllowedTypes}.
|
|
78
155
|
* @remarks
|
|
@@ -81,13 +158,11 @@ export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<Implicit
|
|
|
81
158
|
*/
|
|
82
159
|
export type TreeNodeFromImplicitAllowedTypesUnsafe<
|
|
83
160
|
TSchema extends Unenforced<ImplicitAllowedTypes>,
|
|
84
|
-
> = TSchema extends
|
|
85
|
-
?
|
|
86
|
-
: TSchema extends
|
|
87
|
-
?
|
|
88
|
-
:
|
|
89
|
-
? NodeFromSchema<FlexListToUnion<TSchema>>
|
|
90
|
-
: unknown;
|
|
161
|
+
> = TSchema extends TreeNodeSchemaUnsafe
|
|
162
|
+
? NodeFromSchemaUnsafe<TSchema>
|
|
163
|
+
: TSchema extends AllowedTypesUnsafe
|
|
164
|
+
? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>>
|
|
165
|
+
: unknown;
|
|
91
166
|
|
|
92
167
|
/**
|
|
93
168
|
* {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.
|
|
@@ -97,7 +172,7 @@ export type TreeNodeFromImplicitAllowedTypesUnsafe<
|
|
|
97
172
|
*/
|
|
98
173
|
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<
|
|
99
174
|
TSchema extends Unenforced<ImplicitAllowedTypes>,
|
|
100
|
-
> = TSchema extends
|
|
175
|
+
> = TSchema extends AllowedTypesUnsafe
|
|
101
176
|
? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>>
|
|
102
177
|
: InsertableTypedNodeUnsafe<TSchema>;
|
|
103
178
|
|
|
@@ -119,7 +194,7 @@ export type InsertableTypedNodeUnsafe<T extends Unenforced<TreeNodeSchema>> = [
|
|
|
119
194
|
* @system @public
|
|
120
195
|
*/
|
|
121
196
|
export type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
122
|
-
T extends
|
|
197
|
+
T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
|
123
198
|
|
|
124
199
|
/**
|
|
125
200
|
* {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.
|
|
@@ -128,7 +203,7 @@ export type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
|
128
203
|
* @system @public
|
|
129
204
|
*/
|
|
130
205
|
export type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
131
|
-
T extends
|
|
206
|
+
T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
|
132
207
|
|
|
133
208
|
/**
|
|
134
209
|
* {@link Unenforced} version of {@link (TreeArrayNode:interface)}.
|
|
@@ -139,8 +214,7 @@ export type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
|
139
214
|
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>>
|
|
140
215
|
extends TreeArrayNodeBase<
|
|
141
216
|
TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>,
|
|
142
|
-
InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes
|
|
143
|
-
TreeArrayNode
|
|
217
|
+
InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>
|
|
144
218
|
> {}
|
|
145
219
|
|
|
146
220
|
/**
|
|
@@ -10,10 +10,7 @@ import { assert } from "@fluidframework/core-utils/internal";
|
|
|
10
10
|
import {
|
|
11
11
|
aboveRootPlaceholder,
|
|
12
12
|
EmptyKey,
|
|
13
|
-
forEachField,
|
|
14
|
-
inCursorField,
|
|
15
13
|
keyAsDetachedField,
|
|
16
|
-
mapCursorField,
|
|
17
14
|
type FieldKey,
|
|
18
15
|
type ITreeCursor,
|
|
19
16
|
type ITreeCursorSynchronous,
|
|
@@ -40,16 +37,22 @@ import {
|
|
|
40
37
|
stringSchema,
|
|
41
38
|
} from "../leafNodeSchema.js";
|
|
42
39
|
import { isObjectNodeSchema } from "../objectNodeTypes.js";
|
|
43
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
customFromCursorInner,
|
|
42
|
+
type CustomTreeNode,
|
|
43
|
+
type CustomTreeValue,
|
|
44
|
+
type EncodeOptions,
|
|
45
|
+
} from "./customTree.js";
|
|
44
46
|
import { getUnhydratedContext } from "../createContext.js";
|
|
45
47
|
|
|
46
48
|
/**
|
|
47
|
-
* Verbose encoding of a {@link TreeNode} or {@link
|
|
49
|
+
* Verbose encoding of a {@link TreeNode} or {@link TreeLeafValue}.
|
|
48
50
|
* @remarks
|
|
49
51
|
* This is verbose meaning that every {@link TreeNode} is a {@link VerboseTreeNode}.
|
|
50
52
|
* Any IFluidHandle values have been replaced by `THandle`.
|
|
51
53
|
* @privateRemarks
|
|
52
|
-
* This can store all possible simple trees,
|
|
54
|
+
* This can store all possible simple trees,
|
|
55
|
+
* but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.
|
|
53
56
|
*/
|
|
54
57
|
export type VerboseTree<THandle = IFluidHandle> =
|
|
55
58
|
| VerboseTreeNode<THandle>
|
|
@@ -77,7 +80,8 @@ export type VerboseTree<THandle = IFluidHandle> =
|
|
|
77
80
|
* This format allows for all simple-tree compatible trees to be represented.
|
|
78
81
|
*
|
|
79
82
|
* Unlike `JsonableTree`, leaf nodes are not boxed into node objects, and instead have their schema inferred from the value.
|
|
80
|
-
* Additionally, sequence fields can only occur on a node that has a single sequence field (with the empty key)
|
|
83
|
+
* Additionally, sequence fields can only occur on a node that has a single sequence field (with the empty key)
|
|
84
|
+
* replicating the behavior of simple-tree ArrayNodes.
|
|
81
85
|
*/
|
|
82
86
|
export interface VerboseTreeNode<THandle = IFluidHandle> {
|
|
83
87
|
/**
|
|
@@ -144,24 +148,6 @@ export interface SchemalessParseOptions<TCustom> {
|
|
|
144
148
|
};
|
|
145
149
|
}
|
|
146
150
|
|
|
147
|
-
/**
|
|
148
|
-
* Options for how to interpret a `VerboseTree<TCustom>` without relying on schema.
|
|
149
|
-
*/
|
|
150
|
-
export interface EncodeOptions<TCustom> {
|
|
151
|
-
/**
|
|
152
|
-
* Fixup custom input formats.
|
|
153
|
-
* @remarks
|
|
154
|
-
* See note on {@link ParseOptions.valueConverter}.
|
|
155
|
-
*/
|
|
156
|
-
valueConverter(data: IFluidHandle): TCustom;
|
|
157
|
-
/**
|
|
158
|
-
* If true, interpret the input keys of object nodes as stored keys.
|
|
159
|
-
* If false, interpret them as property keys.
|
|
160
|
-
* @defaultValue false.
|
|
161
|
-
*/
|
|
162
|
-
readonly useStoredKeys?: boolean;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
151
|
/**
|
|
166
152
|
* Use info from `schema` to convert `options` to {@link SchemalessParseOptions}.
|
|
167
153
|
*/
|
|
@@ -345,12 +331,7 @@ export function verboseFromCursor<TCustom>(
|
|
|
345
331
|
...options,
|
|
346
332
|
};
|
|
347
333
|
|
|
348
|
-
const schemaMap =
|
|
349
|
-
walkFieldSchema(rootSchema, {
|
|
350
|
-
node(schema) {
|
|
351
|
-
schemaMap.set(schema.identifier, schema);
|
|
352
|
-
},
|
|
353
|
-
});
|
|
334
|
+
const schemaMap = getUnhydratedContext(rootSchema).schema;
|
|
354
335
|
|
|
355
336
|
return verboseFromCursorInner(reader, config, schemaMap);
|
|
356
337
|
}
|
|
@@ -360,50 +341,14 @@ function verboseFromCursorInner<TCustom>(
|
|
|
360
341
|
options: Required<EncodeOptions<TCustom>>,
|
|
361
342
|
schema: ReadonlyMap<string, TreeNodeSchema>,
|
|
362
343
|
): VerboseTree<TCustom> {
|
|
363
|
-
const
|
|
364
|
-
const nodeSchema = schema.get(type) ?? fail("missing schema for type in cursor");
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
case numberSchema.identifier:
|
|
368
|
-
case booleanSchema.identifier:
|
|
369
|
-
case nullSchema.identifier:
|
|
370
|
-
case stringSchema.identifier:
|
|
371
|
-
assert(reader.value !== undefined, 0xa14 /* out of schema: missing value */);
|
|
372
|
-
assert(!isFluidHandle(reader.value), 0xa15 /* out of schema: unexpected FluidHandle */);
|
|
373
|
-
return reader.value;
|
|
374
|
-
case handleSchema.identifier:
|
|
375
|
-
assert(reader.value !== undefined, 0xa16 /* out of schema: missing value */);
|
|
376
|
-
assert(isFluidHandle(reader.value), 0xa17 /* out of schema: unexpected FluidHandle */);
|
|
377
|
-
return options.valueConverter(reader.value);
|
|
378
|
-
default: {
|
|
379
|
-
assert(reader.value === undefined, 0xa18 /* out of schema: unexpected value */);
|
|
380
|
-
if (nodeSchema.kind === NodeKind.Array) {
|
|
381
|
-
const fields = inCursorField(reader, EmptyKey, () =>
|
|
382
|
-
mapCursorField(reader, () => verboseFromCursorInner(reader, options, schema)),
|
|
383
|
-
);
|
|
384
|
-
return { type, fields };
|
|
385
|
-
} else {
|
|
386
|
-
const fields: Record<string, VerboseTree<TCustom>> = {};
|
|
387
|
-
forEachField(reader, () => {
|
|
388
|
-
const children = mapCursorField(reader, () =>
|
|
389
|
-
verboseFromCursorInner(reader, options, schema),
|
|
390
|
-
);
|
|
391
|
-
if (children.length === 1) {
|
|
392
|
-
const storedKey = reader.getFieldKey();
|
|
393
|
-
const key =
|
|
394
|
-
isObjectNodeSchema(nodeSchema) && !options.useStoredKeys
|
|
395
|
-
? nodeSchema.storedKeyToPropertyKey.get(storedKey) ??
|
|
396
|
-
fail("missing property key")
|
|
397
|
-
: storedKey;
|
|
398
|
-
// Length is checked above.
|
|
399
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
400
|
-
fields[key] = children[0]!;
|
|
401
|
-
} else {
|
|
402
|
-
assert(children.length === 0, 0xa19 /* invalid children number */);
|
|
403
|
-
}
|
|
404
|
-
});
|
|
405
|
-
return { type, fields };
|
|
406
|
-
}
|
|
407
|
-
}
|
|
344
|
+
const fields = customFromCursorInner(reader, options, schema, verboseFromCursorInner);
|
|
345
|
+
const nodeSchema = schema.get(reader.type) ?? fail("missing schema for type in cursor");
|
|
346
|
+
if (nodeSchema.kind === NodeKind.Leaf) {
|
|
347
|
+
return fields as CustomTreeValue<TCustom>;
|
|
408
348
|
}
|
|
349
|
+
|
|
350
|
+
return {
|
|
351
|
+
type: reader.type,
|
|
352
|
+
fields: fields as CustomTreeNode<TCustom>,
|
|
353
|
+
};
|
|
409
354
|
}
|