@fluidframework/tree 2.52.0 → 2.53.0-350190
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/api-report/tree.alpha.api.md +38 -29
- package/dist/alpha.d.ts +2 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -0
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +49 -20
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +3 -0
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/jsonDomainSchema.d.ts +5 -3
- package/dist/jsonDomainSchema.d.ts.map +1 -1
- package/dist/jsonDomainSchema.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +1 -1
- 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/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +9 -3
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +3 -0
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js +5 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +4 -4
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +3 -6
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.d.ts +5 -9
- package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/dist/simple-tree/api/discrepancies.js +11 -10
- package/dist/simple-tree/api/discrepancies.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +3 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +3 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js +3 -4
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +9 -155
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +4 -47
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +33 -11
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js +1 -7
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/api/schemaStatics.d.ts +158 -0
- package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -0
- package/dist/simple-tree/api/schemaStatics.js +59 -0
- package/dist/simple-tree/api/schemaStatics.js.map +1 -0
- package/dist/simple-tree/api/storedSchema.d.ts +5 -3
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +4 -2
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeBeta.js +12 -6
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts +33 -17
- package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/dist/simple-tree/core/allowedTypes.js +20 -12
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +5 -3
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +6 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
- package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
- package/dist/simple-tree/core/simpleNodeSchemaBase.js +7 -0
- package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
- package/dist/simple-tree/core/toStored.d.ts +32 -0
- package/dist/simple-tree/core/toStored.d.ts.map +1 -0
- package/dist/simple-tree/core/toStored.js +37 -0
- package/dist/simple-tree/core/toStored.js.map +1 -0
- package/dist/simple-tree/core/treeNodeSchema.d.ts +7 -2
- 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/treeNodeValid.d.ts +6 -1
- package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.js +11 -3
- package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
- package/dist/simple-tree/core/walkSchema.d.ts +19 -5
- package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/walkSchema.js +4 -2
- package/dist/simple-tree/core/walkSchema.js.map +1 -1
- package/dist/simple-tree/createContext.d.ts.map +1 -1
- package/dist/simple-tree/createContext.js +1 -1
- package/dist/simple-tree/createContext.js.map +1 -1
- package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/fieldSchema.js +1 -1
- package/dist/simple-tree/fieldSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +4 -4
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +7 -1
- package/dist/simple-tree/index.js.map +1 -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.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +17 -3
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +9 -2
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +2 -2
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +37 -26
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +9 -2
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts +5 -5
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/dist/simple-tree/prepareForInsertion.js +10 -10
- package/dist/simple-tree/prepareForInsertion.js.map +1 -1
- package/dist/simple-tree/simpleSchema.d.ts +6 -21
- 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 +35 -11
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +68 -33
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/alpha.d.ts +2 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -0
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +50 -21
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +3 -0
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/jsonDomainSchema.d.ts +5 -3
- package/lib/jsonDomainSchema.d.ts.map +1 -1
- package/lib/jsonDomainSchema.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +2 -2
- 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/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +10 -4
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +3 -0
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js +6 -2
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +4 -4
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +3 -6
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.d.ts +5 -9
- package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/lib/simple-tree/api/discrepancies.js +11 -10
- package/lib/simple-tree/api/discrepancies.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +3 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +2 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.js +4 -5
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +9 -155
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +2 -45
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +23 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js +0 -5
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/api/schemaStatics.d.ts +158 -0
- package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -0
- package/lib/simple-tree/api/schemaStatics.js +56 -0
- package/lib/simple-tree/api/schemaStatics.js.map +1 -0
- package/lib/simple-tree/api/storedSchema.d.ts +5 -3
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +6 -4
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeBeta.js +8 -2
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +33 -17
- package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/lib/simple-tree/core/allowedTypes.js +23 -12
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +5 -3
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +3 -2
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
- package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
- package/lib/simple-tree/core/simpleNodeSchemaBase.js +6 -0
- package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
- package/lib/simple-tree/core/toStored.d.ts +32 -0
- package/lib/simple-tree/core/toStored.d.ts.map +1 -0
- package/lib/simple-tree/core/toStored.js +32 -0
- package/lib/simple-tree/core/toStored.js.map +1 -0
- package/lib/simple-tree/core/treeNodeSchema.d.ts +7 -2
- 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/treeNodeValid.d.ts +6 -1
- package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.js +9 -2
- package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
- package/lib/simple-tree/core/walkSchema.d.ts +19 -5
- package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/walkSchema.js +4 -2
- package/lib/simple-tree/core/walkSchema.js.map +1 -1
- package/lib/simple-tree/createContext.d.ts.map +1 -1
- package/lib/simple-tree/createContext.js +2 -2
- package/lib/simple-tree/createContext.js.map +1 -1
- package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/fieldSchema.js +1 -1
- package/lib/simple-tree/fieldSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +4 -4
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts.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.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +20 -6
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +12 -5
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +2 -2
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +16 -5
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +12 -5
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts +5 -5
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/lib/simple-tree/prepareForInsertion.js +10 -10
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/simple-tree/simpleSchema.d.ts +6 -21
- 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 +35 -11
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +67 -34
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/package.json +21 -21
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -0
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +9 -0
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -0
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +61 -19
- package/src/feature-libraries/optional-field/optionalField.ts +4 -0
- package/src/feature-libraries/sequence-field/sequenceFieldChangeRebaser.ts +4 -0
- package/src/index.ts +2 -1
- package/src/jsonDomainSchema.ts +4 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizeTree.ts +2 -2
- package/src/shared-tree/schematizingTreeView.ts +9 -3
- package/src/shared-tree/treeAlpha.ts +18 -4
- package/src/simple-tree/api/configuration.ts +10 -2
- package/src/simple-tree/api/create.ts +5 -10
- package/src/simple-tree/api/discrepancies.ts +18 -17
- package/src/simple-tree/api/index.ts +2 -3
- package/src/simple-tree/api/schemaCompatibilityTester.ts +5 -9
- package/src/simple-tree/api/schemaFactory.ts +6 -250
- package/src/simple-tree/api/schemaFactoryAlpha.ts +174 -1
- package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -25
- package/src/simple-tree/api/schemaStatics.ts +291 -0
- package/src/simple-tree/api/storedSchema.ts +12 -5
- package/src/simple-tree/api/treeBeta.ts +9 -2
- package/src/simple-tree/core/allowedTypes.ts +46 -26
- package/src/simple-tree/core/index.ts +9 -1
- package/src/simple-tree/core/simpleNodeSchemaBase.ts +30 -0
- package/src/simple-tree/core/toStored.ts +58 -0
- package/src/simple-tree/core/treeNodeSchema.ts +8 -2
- package/src/simple-tree/core/treeNodeValid.ts +14 -2
- package/src/simple-tree/core/walkSchema.ts +23 -6
- package/src/simple-tree/createContext.ts +5 -2
- package/src/simple-tree/fieldSchema.ts +2 -1
- package/src/simple-tree/index.ts +14 -3
- package/src/simple-tree/leafNodeSchema.ts +2 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +32 -4
- package/src/simple-tree/node-kinds/map/mapNode.ts +23 -2
- package/src/simple-tree/node-kinds/object/objectNode.ts +34 -4
- package/src/simple-tree/node-kinds/record/recordNode.ts +20 -2
- package/src/simple-tree/prepareForInsertion.ts +12 -7
- package/src/simple-tree/simpleSchema.ts +6 -26
- package/src/simple-tree/toStoredSchema.ts +107 -44
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
normalizeAnnotatedAllowedTypes,
|
|
8
|
+
type AnnotatedAllowedType,
|
|
8
9
|
type NormalizedAnnotatedAllowedTypes,
|
|
9
10
|
} from "./allowedTypes.js";
|
|
10
11
|
import { getTreeNodeSchemaPrivateData, type TreeNodeSchema } from "./treeNodeSchema.js";
|
|
@@ -50,26 +51,42 @@ export function walkAllowedTypes(
|
|
|
50
51
|
visitor: SchemaVisitor,
|
|
51
52
|
visitedSet: Set<TreeNodeSchema> = new Set(),
|
|
52
53
|
): void {
|
|
53
|
-
for (const
|
|
54
|
-
|
|
54
|
+
for (const allowedType of annotatedAllowedTypes.types) {
|
|
55
|
+
if ((visitor.allowedTypeFilter ?? (() => true))(allowedType)) {
|
|
56
|
+
walkNodeSchema(allowedType.type, visitor, visitedSet);
|
|
57
|
+
}
|
|
55
58
|
}
|
|
56
59
|
visitor.allowedTypes?.(annotatedAllowedTypes);
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
/**
|
|
60
|
-
* Callbacks for use in {@link walkFieldSchema} / {@link walkAllowedTypes} / {@link walkNodeSchema}.
|
|
63
|
+
* Callbacks and options for use in {@link walkFieldSchema} / {@link walkAllowedTypes} / {@link walkNodeSchema}.
|
|
61
64
|
* @internal
|
|
62
65
|
*/
|
|
63
66
|
export interface SchemaVisitor {
|
|
64
67
|
/**
|
|
65
|
-
* Called once for each node schema.
|
|
68
|
+
* Called once for each node schema reached.
|
|
66
69
|
*/
|
|
67
70
|
node?: (schema: TreeNodeSchema) => void;
|
|
68
71
|
/**
|
|
69
72
|
* Called once for each set of allowed types.
|
|
70
|
-
*
|
|
73
|
+
* @remarks
|
|
74
|
+
* This includes every field, as well as the allowed types for maps and arrays nodes and the root if starting at {@link walkAllowedTypes}.
|
|
71
75
|
*
|
|
72
|
-
*
|
|
76
|
+
* Each allowed types in the schema is visited as it was in the original schema except for normalization.
|
|
77
|
+
*
|
|
78
|
+
* After this is called {@link SchemaVisitor.allowedTypeFilter} is applied to each allowed type in the schema to determine which of them are walked into.
|
|
73
79
|
*/
|
|
74
80
|
allowedTypes?: (allowedTypes: NormalizedAnnotatedAllowedTypes) => void;
|
|
81
|
+
/**
|
|
82
|
+
* If true, will walk into this `allowedType`.
|
|
83
|
+
* If false, the `allowedType` will not be walked into.
|
|
84
|
+
*
|
|
85
|
+
* If not provided, all allowedTypes will be walked into.
|
|
86
|
+
* @remarks
|
|
87
|
+
* Called after {@link SchemaVisitor.allowedTypes}.
|
|
88
|
+
* @privateRemarks
|
|
89
|
+
* It would be possible to combine this with `allowedTypes` into a single callback, but for the current usage this separation is more convenient.
|
|
90
|
+
*/
|
|
91
|
+
allowedTypeFilter?: (allowedType: AnnotatedAllowedType<TreeNodeSchema>) => boolean;
|
|
75
92
|
}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
type TreeNodeSchemaInitializedData,
|
|
16
16
|
} from "./core/index.js";
|
|
17
17
|
import { normalizeFieldSchema, type ImplicitFieldSchema } from "./fieldSchema.js";
|
|
18
|
-
import { toStoredSchema } from "./toStoredSchema.js";
|
|
18
|
+
import { toStoredSchema, toUnhydratedSchema } from "./toStoredSchema.js";
|
|
19
19
|
|
|
20
20
|
const contextCache: WeakMap<ImplicitFieldSchema, Context> = new WeakMap();
|
|
21
21
|
|
|
@@ -28,7 +28,10 @@ export function getUnhydratedContext(schema: ImplicitFieldSchema): Context {
|
|
|
28
28
|
return getOrCreate(contextCache, schema, (s) => {
|
|
29
29
|
const normalized = normalizeFieldSchema(schema);
|
|
30
30
|
|
|
31
|
-
const flexContext = new UnhydratedContext(
|
|
31
|
+
const flexContext = new UnhydratedContext(
|
|
32
|
+
defaultSchemaPolicy,
|
|
33
|
+
toStoredSchema(schema, toUnhydratedSchema),
|
|
34
|
+
);
|
|
32
35
|
return new Context(
|
|
33
36
|
flexContext,
|
|
34
37
|
Context.schemaMapFromRootSchema(normalized.annotatedAllowedTypesNormalized),
|
|
@@ -468,7 +468,8 @@ export class FieldSchemaAlpha<
|
|
|
468
468
|
normalizeAnnotatedAllowedTypes(annotatedAllowedTypes),
|
|
469
469
|
);
|
|
470
470
|
this.lazyIdentifiers = new Lazy(
|
|
471
|
-
() =>
|
|
471
|
+
() =>
|
|
472
|
+
new Set(this.annotatedAllowedTypesNormalized.types.map(({ type }) => type.identifier)),
|
|
472
473
|
);
|
|
473
474
|
this.propsAlpha = props;
|
|
474
475
|
}
|
package/src/simple-tree/index.ts
CHANGED
|
@@ -47,9 +47,9 @@ export {
|
|
|
47
47
|
type UnannotateAllowedTypes,
|
|
48
48
|
type UnannotateAllowedType,
|
|
49
49
|
type UnannotateAllowedTypesList,
|
|
50
|
-
type UnannotateAllowedTypeOrLazyItem,
|
|
51
50
|
type AllowedTypeMetadata,
|
|
52
51
|
type AnnotatedAllowedTypes,
|
|
52
|
+
type SchemaUpgrade,
|
|
53
53
|
type LazyItem,
|
|
54
54
|
type FlexList,
|
|
55
55
|
type FlexListToUnion,
|
|
@@ -57,6 +57,7 @@ export {
|
|
|
57
57
|
walkNodeSchema,
|
|
58
58
|
walkAllowedTypes,
|
|
59
59
|
type SchemaVisitor,
|
|
60
|
+
type SimpleNodeSchemaBase,
|
|
60
61
|
} from "./core/index.js";
|
|
61
62
|
export { walkFieldSchema } from "./walkFieldSchema.js";
|
|
62
63
|
export type { UnsafeUnknownSchema, Insertable } from "./unsafeUnknownSchema.js";
|
|
@@ -161,6 +162,7 @@ export {
|
|
|
161
162
|
type TreeChangeEvents,
|
|
162
163
|
type NodeSchemaOptions,
|
|
163
164
|
type NodeSchemaOptionsAlpha,
|
|
165
|
+
type SchemaStaticsAlpha,
|
|
164
166
|
} from "./api/index.js";
|
|
165
167
|
export type {
|
|
166
168
|
SimpleTreeSchema,
|
|
@@ -170,7 +172,6 @@ export type {
|
|
|
170
172
|
SimpleMapNodeSchema,
|
|
171
173
|
SimpleArrayNodeSchema,
|
|
172
174
|
SimpleObjectNodeSchema,
|
|
173
|
-
SimpleNodeSchemaBase,
|
|
174
175
|
SimpleNodeSchemaBaseAlpha,
|
|
175
176
|
SimpleObjectFieldSchema,
|
|
176
177
|
SimpleRecordNodeSchema,
|
|
@@ -240,7 +241,17 @@ export {
|
|
|
240
241
|
prepareForInsertion,
|
|
241
242
|
prepareForInsertionContextless,
|
|
242
243
|
} from "./prepareForInsertion.js";
|
|
243
|
-
export {
|
|
244
|
+
export {
|
|
245
|
+
toStoredSchema,
|
|
246
|
+
getStoredSchema,
|
|
247
|
+
convertFieldKind,
|
|
248
|
+
toUpgradeSchema,
|
|
249
|
+
toInitialSchema,
|
|
250
|
+
convertField,
|
|
251
|
+
toUnhydratedSchema,
|
|
252
|
+
restrictiveStoredSchemaGenerationOptions,
|
|
253
|
+
permissiveStoredSchemaGenerationOptions,
|
|
254
|
+
} from "./toStoredSchema.js";
|
|
244
255
|
export {
|
|
245
256
|
numberSchema,
|
|
246
257
|
stringSchema,
|
|
@@ -7,7 +7,7 @@ import { assert } from "@fluidframework/core-utils/internal";
|
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
|
|
9
9
|
|
|
10
|
-
import { type TreeValue, ValueSchema } from "../core/index.js";
|
|
10
|
+
import { LeafNodeStoredSchema, type TreeValue, ValueSchema } from "../core/index.js";
|
|
11
11
|
import {
|
|
12
12
|
type FlexTreeNode,
|
|
13
13
|
isFlexTreeNode,
|
|
@@ -64,6 +64,7 @@ export class LeafNodeSchema<Name extends string, const T extends ValueSchema>
|
|
|
64
64
|
): FlexContent => leafToFlexContent(data, this, allowedTypes),
|
|
65
65
|
})),
|
|
66
66
|
childAnnotatedAllowedTypes: [],
|
|
67
|
+
toStored: () => new LeafNodeStoredSchema(this.leafKind),
|
|
67
68
|
};
|
|
68
69
|
#initializedData: TreeNodeSchemaInitializedData | undefined;
|
|
69
70
|
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Lazy, oob, fail } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { Lazy, oob, fail, assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
|
|
9
|
-
import { EmptyKey } from "../../../core/index.js";
|
|
9
|
+
import { EmptyKey, ObjectNodeStoredSchema } from "../../../core/index.js";
|
|
10
10
|
import type {
|
|
11
11
|
FlexibleFieldContent,
|
|
12
12
|
FlexTreeNode,
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
createTreeNodeSchemaPrivateData,
|
|
49
49
|
type FlexContent,
|
|
50
50
|
type TreeNodeSchemaPrivateData,
|
|
51
|
+
convertAllowedTypes,
|
|
51
52
|
} from "../../core/index.js";
|
|
52
53
|
import {
|
|
53
54
|
type FactoryContent,
|
|
@@ -68,6 +69,7 @@ import type {
|
|
|
68
69
|
} from "./arrayNodeTypes.js";
|
|
69
70
|
import { brand, type JsonCompatibleReadOnlyObject } from "../../../util/index.js";
|
|
70
71
|
import { nullSchema } from "../../leafNodeSchema.js";
|
|
72
|
+
import { arrayNodeStoredSchema } from "../../toStoredSchema.js";
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
75
|
* A covariant base type for {@link (TreeArrayNode:interface)}.
|
|
@@ -888,10 +890,21 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAnnotatedAllowedTypes
|
|
|
888
890
|
const contentArray = content.flatMap((c): InsertableContent[] =>
|
|
889
891
|
c instanceof IterableTreeArrayContent ? Array.from(c) : [c],
|
|
890
892
|
);
|
|
893
|
+
|
|
894
|
+
const kernel = getKernel(this);
|
|
895
|
+
const flexContext = kernel.getOrCreateInnerNode().context;
|
|
896
|
+
assert(flexContext === kernel.context.flexContext, "Expected flexContext to match");
|
|
897
|
+
const innerSchema = kernel.context.flexContext.schema.nodeSchema.get(
|
|
898
|
+
brand(kernel.schema.identifier),
|
|
899
|
+
);
|
|
900
|
+
assert(innerSchema instanceof ObjectNodeStoredSchema, "Expected ObjectNodeStoredSchema");
|
|
901
|
+
const fieldSchema = innerSchema.getFieldSchema(EmptyKey);
|
|
902
|
+
|
|
891
903
|
const mapTrees = prepareArrayContentForInsertion(
|
|
892
904
|
contentArray,
|
|
893
905
|
this.simpleSchema,
|
|
894
906
|
sequenceField.context,
|
|
907
|
+
fieldSchema.types,
|
|
895
908
|
);
|
|
896
909
|
|
|
897
910
|
return mapTrees;
|
|
@@ -1029,6 +1042,11 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAnnotatedAllowedTypes
|
|
|
1029
1042
|
): void {
|
|
1030
1043
|
const destinationField = getSequenceField(this);
|
|
1031
1044
|
const destinationSchema = this.allowedTypes;
|
|
1045
|
+
const kernel = getKernel(this);
|
|
1046
|
+
const destinationStored = (
|
|
1047
|
+
kernel.context.flexContext.schema.nodeSchema.get(brand(kernel.schema.identifier)) ??
|
|
1048
|
+
fail("missing schema for array node")
|
|
1049
|
+
).getFieldSchema(EmptyKey).types;
|
|
1032
1050
|
const sourceField = source !== undefined ? getSequenceField(source) : destinationField;
|
|
1033
1051
|
|
|
1034
1052
|
validateIndex(destinationGap, destinationField, "moveRangeToIndex", true);
|
|
@@ -1040,7 +1058,15 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAnnotatedAllowedTypes
|
|
|
1040
1058
|
const sourceNode = sourceField.boxedAt(i) ?? oob();
|
|
1041
1059
|
const sourceSchema = getSimpleNodeSchemaFromInnerNode(sourceNode);
|
|
1042
1060
|
if (!destinationSchema.has(sourceSchema)) {
|
|
1043
|
-
throw new UsageError(
|
|
1061
|
+
throw new UsageError(
|
|
1062
|
+
`Type ${sourceNode.type} in source sequence is not allowed in destination.`,
|
|
1063
|
+
);
|
|
1064
|
+
}
|
|
1065
|
+
if (!destinationStored.has(sourceNode.type)) {
|
|
1066
|
+
// TODO: better and centralized messages for missing staged schema updates.
|
|
1067
|
+
throw new UsageError(
|
|
1068
|
+
`Type ${sourceNode.type} in source sequence is not allowed in destination's stored schema: this would likely require upgrading the document to permit a staged schema.`,
|
|
1069
|
+
);
|
|
1044
1070
|
}
|
|
1045
1071
|
}
|
|
1046
1072
|
}
|
|
@@ -1250,7 +1276,9 @@ export function arraySchema<
|
|
|
1250
1276
|
}
|
|
1251
1277
|
|
|
1252
1278
|
public static get [privateDataSymbol](): TreeNodeSchemaPrivateData {
|
|
1253
|
-
return (privateData ??= createTreeNodeSchemaPrivateData(this, [info])
|
|
1279
|
+
return (privateData ??= createTreeNodeSchemaPrivateData(this, [info], (storedOptions) =>
|
|
1280
|
+
arrayNodeStoredSchema(convertAllowedTypes(info, storedOptions), persistedMetadata),
|
|
1281
|
+
));
|
|
1254
1282
|
}
|
|
1255
1283
|
}
|
|
1256
1284
|
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Lazy } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { assert, Lazy } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
+
FieldKinds,
|
|
10
11
|
isTreeValue,
|
|
11
12
|
type FlexibleNodeContent,
|
|
12
13
|
type FlexTreeNode,
|
|
@@ -44,6 +45,7 @@ import {
|
|
|
44
45
|
createTreeNodeSchemaPrivateData,
|
|
45
46
|
type FlexContent,
|
|
46
47
|
type TreeNodeSchemaPrivateData,
|
|
48
|
+
convertAllowedTypes,
|
|
47
49
|
} from "../../core/index.js";
|
|
48
50
|
import {
|
|
49
51
|
unhydratedFlexTreeFromInsertable,
|
|
@@ -65,6 +67,7 @@ import type {
|
|
|
65
67
|
MapNodeSchema,
|
|
66
68
|
} from "./mapNodeTypes.js";
|
|
67
69
|
import { recordLikeDataToFlexContent } from "../common.js";
|
|
70
|
+
import { MapNodeStoredSchema } from "../../../core/index.js";
|
|
68
71
|
|
|
69
72
|
/**
|
|
70
73
|
* A map of string keys to tree objects.
|
|
@@ -209,10 +212,16 @@ abstract class CustomMapNodeBase<const T extends ImplicitAllowedTypes> extends T
|
|
|
209
212
|
public set(key: string, value: InsertableTreeNodeFromImplicitAllowedTypes<T>): this {
|
|
210
213
|
const kernel = getKernel(this);
|
|
211
214
|
const node = this.innerNode;
|
|
215
|
+
const innerSchema = this.innerNode.context.schema.nodeSchema.get(
|
|
216
|
+
brand(kernel.schema.identifier),
|
|
217
|
+
);
|
|
218
|
+
assert(innerSchema instanceof MapNodeStoredSchema, "Expected MapNodeStoredSchema");
|
|
219
|
+
|
|
212
220
|
const mapTree = prepareForInsertion(
|
|
213
221
|
value as InsertableContent | undefined,
|
|
214
222
|
createFieldSchema(FieldKind.Optional, kernel.schema.info as ImplicitAllowedTypes),
|
|
215
223
|
node.context,
|
|
224
|
+
innerSchema.mapFields,
|
|
216
225
|
);
|
|
217
226
|
|
|
218
227
|
const field = node.getBoxed(brand(key));
|
|
@@ -328,7 +337,19 @@ export function mapSchema<
|
|
|
328
337
|
}
|
|
329
338
|
|
|
330
339
|
public static get [privateDataSymbol](): TreeNodeSchemaPrivateData {
|
|
331
|
-
return (privateData ??= createTreeNodeSchemaPrivateData(
|
|
340
|
+
return (privateData ??= createTreeNodeSchemaPrivateData(
|
|
341
|
+
this,
|
|
342
|
+
[info],
|
|
343
|
+
(storedOptions) =>
|
|
344
|
+
new MapNodeStoredSchema(
|
|
345
|
+
{
|
|
346
|
+
kind: FieldKinds.optional.identifier,
|
|
347
|
+
types: convertAllowedTypes(info, storedOptions),
|
|
348
|
+
persistedMetadata,
|
|
349
|
+
},
|
|
350
|
+
persistedMetadata,
|
|
351
|
+
),
|
|
352
|
+
));
|
|
332
353
|
}
|
|
333
354
|
}
|
|
334
355
|
const schemaErased: MapNodeCustomizableSchema<
|
|
@@ -7,7 +7,11 @@ import { assert, Lazy, fail, debugAssert } from "@fluidframework/core-utils/inte
|
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import {
|
|
11
|
+
ObjectNodeStoredSchema,
|
|
12
|
+
type FieldKey,
|
|
13
|
+
type TreeFieldStoredSchema,
|
|
14
|
+
} from "../../../core/index.js";
|
|
11
15
|
import {
|
|
12
16
|
FieldKinds,
|
|
13
17
|
isTreeValue,
|
|
@@ -86,7 +90,7 @@ import {
|
|
|
86
90
|
type FactoryContentObject,
|
|
87
91
|
type InsertableContent,
|
|
88
92
|
} from "../../unhydratedFlexTreeFromInsertable.js";
|
|
89
|
-
import { convertFieldKind } from "../../toStoredSchema.js";
|
|
93
|
+
import { convertField, convertFieldKind } from "../../toStoredSchema.js";
|
|
90
94
|
|
|
91
95
|
/**
|
|
92
96
|
* Generates the properties for an ObjectNode from its field schema object.
|
|
@@ -288,10 +292,16 @@ function createProxyHandler(
|
|
|
288
292
|
: false;
|
|
289
293
|
}
|
|
290
294
|
|
|
295
|
+
const innerNode = getOrCreateInnerNode(proxy);
|
|
296
|
+
|
|
297
|
+
const innerSchema = innerNode.context.schema.nodeSchema.get(brand(schema.identifier));
|
|
298
|
+
assert(innerSchema instanceof ObjectNodeStoredSchema, "Expected ObjectNodeStoredSchema");
|
|
299
|
+
|
|
291
300
|
setField(
|
|
292
|
-
|
|
301
|
+
innerNode.getBoxed(fieldInfo.storedKey),
|
|
293
302
|
fieldInfo.schema,
|
|
294
303
|
value,
|
|
304
|
+
innerSchema.getFieldSchema(fieldInfo.storedKey),
|
|
295
305
|
);
|
|
296
306
|
return true;
|
|
297
307
|
},
|
|
@@ -348,8 +358,14 @@ export function setField(
|
|
|
348
358
|
field: FlexTreeField,
|
|
349
359
|
simpleFieldSchema: FieldSchema,
|
|
350
360
|
value: InsertableContent | undefined,
|
|
361
|
+
destinationSchema: TreeFieldStoredSchema,
|
|
351
362
|
): void {
|
|
352
|
-
const mapTree = prepareForInsertion(
|
|
363
|
+
const mapTree = prepareForInsertion(
|
|
364
|
+
value,
|
|
365
|
+
simpleFieldSchema,
|
|
366
|
+
field.context,
|
|
367
|
+
destinationSchema,
|
|
368
|
+
);
|
|
353
369
|
|
|
354
370
|
switch (field.schema) {
|
|
355
371
|
case FieldKinds.required.identifier: {
|
|
@@ -585,6 +601,20 @@ export function objectSchema<
|
|
|
585
601
|
flexKeyMap.values(),
|
|
586
602
|
({ schema }) => normalizeFieldSchema(schema).annotatedAllowedTypes,
|
|
587
603
|
),
|
|
604
|
+
(storedOptions) => {
|
|
605
|
+
const fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();
|
|
606
|
+
for (const fieldSchema of flexKeyMap.values()) {
|
|
607
|
+
assert(
|
|
608
|
+
fieldSchema.schema instanceof FieldSchemaAlpha,
|
|
609
|
+
"Expected FieldSchemaAlpha",
|
|
610
|
+
);
|
|
611
|
+
fields.set(
|
|
612
|
+
brand(fieldSchema.storedKey),
|
|
613
|
+
convertField(fieldSchema.schema, storedOptions),
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
return new ObjectNodeStoredSchema(fields, persistedMetadata);
|
|
617
|
+
},
|
|
588
618
|
));
|
|
589
619
|
}
|
|
590
620
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Lazy } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { assert, Lazy } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
|
|
9
9
|
import { type JsonCompatibleReadOnlyObject, brand } from "../../../util/index.js";
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
type FlexContent,
|
|
35
35
|
CompatibilityLevel,
|
|
36
36
|
type TreeNodeSchemaPrivateData,
|
|
37
|
+
convertAllowedTypes,
|
|
37
38
|
} from "../../core/index.js";
|
|
38
39
|
import { getTreeNodeSchemaInitializedData } from "../../createContext.js";
|
|
39
40
|
import { tryGetTreeNodeForField } from "../../getTreeNodeForField.js";
|
|
@@ -51,12 +52,14 @@ import type {
|
|
|
51
52
|
TreeRecordNode,
|
|
52
53
|
} from "./recordNodeTypes.js";
|
|
53
54
|
import {
|
|
55
|
+
FieldKinds,
|
|
54
56
|
isTreeValue,
|
|
55
57
|
type FlexTreeNode,
|
|
56
58
|
type FlexTreeOptionalField,
|
|
57
59
|
} from "../../../feature-libraries/index.js";
|
|
58
60
|
import { prepareForInsertion } from "../../prepareForInsertion.js";
|
|
59
61
|
import { recordLikeDataToFlexContent } from "../common.js";
|
|
62
|
+
import { MapNodeStoredSchema } from "../../../core/index.js";
|
|
60
63
|
|
|
61
64
|
/**
|
|
62
65
|
* Create a proxy which implements the {@link TreeRecordNode} API.
|
|
@@ -122,11 +125,14 @@ function createRecordNodeProxy(
|
|
|
122
125
|
const innerNode = getOrCreateInnerNode(receiver);
|
|
123
126
|
const field = innerNode.getBoxed(brand(key)) as FlexTreeOptionalField;
|
|
124
127
|
const kernel = getKernel(receiver);
|
|
128
|
+
const innerSchema = innerNode.context.schema.nodeSchema.get(brand(schema.identifier));
|
|
129
|
+
assert(innerSchema instanceof MapNodeStoredSchema, "Expected MapNodeStoredSchema");
|
|
125
130
|
|
|
126
131
|
const mapTree = prepareForInsertion(
|
|
127
132
|
value,
|
|
128
133
|
createFieldSchema(FieldKind.Optional, kernel.schema.info as ImplicitAllowedTypes),
|
|
129
134
|
innerNode.context,
|
|
135
|
+
innerSchema.mapFields,
|
|
130
136
|
);
|
|
131
137
|
|
|
132
138
|
field.editor.set(mapTree, field.length === 0);
|
|
@@ -390,7 +396,19 @@ export function recordSchema<
|
|
|
390
396
|
}
|
|
391
397
|
|
|
392
398
|
public static get [privateDataSymbol](): TreeNodeSchemaPrivateData {
|
|
393
|
-
return (privateData ??= createTreeNodeSchemaPrivateData(
|
|
399
|
+
return (privateData ??= createTreeNodeSchemaPrivateData(
|
|
400
|
+
this,
|
|
401
|
+
[info],
|
|
402
|
+
(storedOptions) =>
|
|
403
|
+
new MapNodeStoredSchema(
|
|
404
|
+
{
|
|
405
|
+
kind: FieldKinds.optional.identifier,
|
|
406
|
+
types: convertAllowedTypes(info, storedOptions),
|
|
407
|
+
persistedMetadata,
|
|
408
|
+
},
|
|
409
|
+
persistedMetadata,
|
|
410
|
+
),
|
|
411
|
+
));
|
|
394
412
|
}
|
|
395
413
|
}
|
|
396
414
|
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
FieldKey,
|
|
12
12
|
DetachedField,
|
|
13
13
|
TreeFieldStoredSchema,
|
|
14
|
+
TreeTypeSet,
|
|
14
15
|
} from "../core/index.js";
|
|
15
16
|
import {
|
|
16
17
|
type FlexTreeContext,
|
|
@@ -21,7 +22,7 @@ import {
|
|
|
21
22
|
type FlexibleNodeContent,
|
|
22
23
|
throwOutOfSchema,
|
|
23
24
|
} from "../feature-libraries/index.js";
|
|
24
|
-
import {
|
|
25
|
+
import type { ImplicitAnnotatedFieldSchema } from "./fieldSchema.js";
|
|
25
26
|
import {
|
|
26
27
|
type InsertableContent,
|
|
27
28
|
unhydratedFlexTreeFromInsertable,
|
|
@@ -36,7 +37,6 @@ import {
|
|
|
36
37
|
} from "./core/index.js";
|
|
37
38
|
import { debugAssert, oob } from "@fluidframework/core-utils/internal";
|
|
38
39
|
import { isFieldInSchema } from "../feature-libraries/index.js";
|
|
39
|
-
import { convertField } from "./toStoredSchema.js";
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* For now, schema validation for inserted content is always enabled.
|
|
@@ -58,12 +58,14 @@ export function prepareForInsertion<TIn extends InsertableContent | undefined>(
|
|
|
58
58
|
data: TIn,
|
|
59
59
|
schema: ImplicitAnnotatedFieldSchema,
|
|
60
60
|
destinationContext: FlexTreeContext,
|
|
61
|
+
destinationSchema: TreeFieldStoredSchema,
|
|
61
62
|
): TIn extends undefined ? undefined : FlexibleNodeContent {
|
|
62
63
|
return prepareForInsertionContextless(
|
|
63
64
|
data,
|
|
64
65
|
schema,
|
|
65
66
|
getSchemaAndPolicy(destinationContext),
|
|
66
67
|
destinationContext.isHydrated() ? destinationContext : undefined,
|
|
68
|
+
destinationSchema,
|
|
67
69
|
);
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -84,19 +86,18 @@ export function prepareArrayContentForInsertion(
|
|
|
84
86
|
data: readonly InsertableContent[],
|
|
85
87
|
schema: ImplicitAnnotatedAllowedTypes,
|
|
86
88
|
destinationContext: FlexTreeContext,
|
|
89
|
+
destinationSchema: TreeTypeSet,
|
|
87
90
|
): FlexibleFieldContent {
|
|
88
91
|
const mapTrees: UnhydratedFlexTreeNode[] = data.map((item) =>
|
|
89
92
|
unhydratedFlexTreeFromInsertable(item, schema),
|
|
90
93
|
);
|
|
91
94
|
|
|
92
|
-
const fieldSchema = convertField(normalizeFieldSchema(schema));
|
|
93
|
-
|
|
94
95
|
validateAndPrepare(
|
|
95
96
|
getSchemaAndPolicy(destinationContext),
|
|
96
97
|
destinationContext.isHydrated() ? destinationContext : undefined,
|
|
97
98
|
{
|
|
98
99
|
kind: FieldKinds.sequence.identifier,
|
|
99
|
-
types:
|
|
100
|
+
types: destinationSchema,
|
|
100
101
|
persistedMetadata: undefined,
|
|
101
102
|
},
|
|
102
103
|
mapTrees,
|
|
@@ -119,12 +120,12 @@ export function prepareForInsertionContextless<TIn extends InsertableContent | u
|
|
|
119
120
|
schema: ImplicitAnnotatedFieldSchema,
|
|
120
121
|
schemaAndPolicy: SchemaAndPolicy,
|
|
121
122
|
hydratedData: FlexTreeHydratedContextMinimal | undefined,
|
|
123
|
+
destinationSchema: TreeFieldStoredSchema,
|
|
122
124
|
): TIn extends undefined ? undefined : FlexibleNodeContent {
|
|
123
125
|
const mapTree = unhydratedFlexTreeFromInsertable(data, schema);
|
|
124
126
|
|
|
125
127
|
const contentArray = mapTree === undefined ? [] : [mapTree];
|
|
126
|
-
|
|
127
|
-
validateAndPrepare(schemaAndPolicy, hydratedData, fieldSchema, contentArray);
|
|
128
|
+
validateAndPrepare(schemaAndPolicy, hydratedData, destinationSchema, contentArray);
|
|
128
129
|
|
|
129
130
|
return mapTree;
|
|
130
131
|
}
|
|
@@ -146,6 +147,10 @@ function validateAndPrepare(
|
|
|
146
147
|
// This ensures that when `isFieldInSchema` requests identifiers (or any other contextual defaults),
|
|
147
148
|
// they were already creating used the more specific context we have access to from `hydratedData`.
|
|
148
149
|
prepareContentForHydration(mapTrees, hydratedData.checkout.forest, hydratedData);
|
|
150
|
+
// TODO: AB#45723
|
|
151
|
+
// Now that staged schema rely on this validation, its a bit odd we don't do it for insertion into unhydrated contexts.
|
|
152
|
+
// We can't simply enable it for them however due to contextual default fields which would not have been created yet (see comment above).
|
|
153
|
+
// Specifically at least clone can result in unhydrated trees which can end up violating their stored schema (but not view schema) just using the type safe APIs.
|
|
149
154
|
if (validateSchema === true) {
|
|
150
155
|
isFieldInSchema(mapTrees, fieldSchema, schemaAndPolicy, throwOutOfSchema);
|
|
151
156
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { ValueSchema } from "../core/index.js";
|
|
7
7
|
import type { JsonCompatibleReadOnlyObject } from "../util/index.js";
|
|
8
|
-
import type { NodeKind,
|
|
8
|
+
import type { NodeKind, SimpleNodeSchemaBase } from "./core/index.js";
|
|
9
9
|
import type { FieldKind, FieldSchemaMetadata } from "./fieldSchema.js";
|
|
10
10
|
|
|
11
11
|
/*
|
|
@@ -13,30 +13,6 @@ import type { FieldKind, FieldSchemaMetadata } from "./fieldSchema.js";
|
|
|
13
13
|
* - Customize their JSON serialization to use these formats or provide some other serialization scheme.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Base interface for {@link TreeNodeSchema} and {@link SimpleNodeSchema} types.
|
|
18
|
-
* Once simple schema is stable this doesn't have a reason to be kept `@system`, but it could be.
|
|
19
|
-
* @system
|
|
20
|
-
* @public
|
|
21
|
-
* @sealed
|
|
22
|
-
*/
|
|
23
|
-
export interface SimpleNodeSchemaBase<
|
|
24
|
-
out TNodeKind extends NodeKind,
|
|
25
|
-
out TCustomMetadata = unknown,
|
|
26
|
-
> {
|
|
27
|
-
/**
|
|
28
|
-
* The {@link NodeKind}.
|
|
29
|
-
*
|
|
30
|
-
* @remarks can be used to type-switch between implementations.
|
|
31
|
-
*/
|
|
32
|
-
readonly kind: TNodeKind;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* User-provided {@link NodeSchemaMetadata} for this schema.
|
|
36
|
-
*/
|
|
37
|
-
readonly metadata: NodeSchemaMetadata<TCustomMetadata>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
16
|
/**
|
|
41
17
|
* A {@link SimpleNodeSchema} containing fields for alpha features.
|
|
42
18
|
*
|
|
@@ -230,7 +206,11 @@ export interface SimpleTreeSchema {
|
|
|
230
206
|
/**
|
|
231
207
|
* The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.root}.
|
|
232
208
|
*
|
|
233
|
-
* @remarks
|
|
209
|
+
* @remarks
|
|
210
|
+
* The keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.
|
|
211
|
+
*
|
|
212
|
+
* Information about if a schema is {@link SchemaStaticsAlpha.staged | staged} or not is not available as the "Simple Schema" layer of abstraction: they are included unconditionally.
|
|
213
|
+
* Options for filtering out staged schemas from view schema are available in {@link extractPersistedSchema}.
|
|
234
214
|
*/
|
|
235
215
|
readonly definitions: ReadonlyMap<string, SimpleNodeSchema>;
|
|
236
216
|
}
|