@fluidframework/tree 2.50.0 → 2.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +3 -2
- package/.vscode/Tree.code-workspace +14 -1
- package/.vscode/settings.json +16 -0
- package/CHANGELOG.md +51 -2
- package/api-report/tree.alpha.api.md +7 -7
- package/dist/core/schema-stored/schema.d.ts +14 -1
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js +3 -0
- package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts +7 -2
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js +4 -4
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +1 -0
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js +3 -1
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +5 -5
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +3 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +5 -3
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +3 -4
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +2 -2
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +3 -8
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.js +0 -3
- package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +0 -1
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +1 -8
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/index.d.ts +0 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +1 -3
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +1 -1
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +7 -10
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +11 -13
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +60 -83
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeTypes.d.ts +1 -1
- package/dist/shared-tree/sharedTreeChangeTypes.js.map +1 -1
- package/dist/shared-tree/tree.d.ts.map +1 -1
- package/dist/shared-tree/tree.js +4 -3
- package/dist/shared-tree/tree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +7 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +7 -2
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +4 -1
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +1 -1
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js +5 -5
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +3 -1
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +2 -0
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +1 -2
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/getJsonSchema.d.ts +1 -1
- package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/getSimpleSchema.d.ts +1 -1
- package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
- package/dist/simple-tree/api/identifierIndex.d.ts +1 -1
- package/dist/simple-tree/api/identifierIndex.js +2 -2
- package/dist/simple-tree/api/identifierIndex.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +4 -19
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js +31 -82
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +14 -2
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js +41 -4
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +36 -3
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +18 -18
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +16 -16
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +2 -2
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js +2 -2
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +4 -4
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +2 -2
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.d.ts +2 -2
- package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +2 -2
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +2 -1
- 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/treeBeta.d.ts +4 -1
- package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts +1 -2
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +3 -3
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +2 -3
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts +2 -1
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +2 -2
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts +316 -0
- package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -0
- package/dist/simple-tree/core/allowedTypes.js +173 -0
- package/dist/simple-tree/core/allowedTypes.js.map +1 -0
- package/dist/simple-tree/core/context.d.ts +3 -9
- package/dist/simple-tree/core/context.d.ts.map +1 -1
- package/dist/simple-tree/core/context.js +3 -11
- package/dist/simple-tree/core/context.js.map +1 -1
- package/dist/simple-tree/core/flexList.d.ts.map +1 -0
- package/dist/simple-tree/core/flexList.js.map +1 -0
- package/dist/simple-tree/core/getOrCreateNode.d.ts +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +9 -3
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +19 -3
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +8 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +24 -20
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +182 -39
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js +47 -17
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/{lib/simple-tree → dist/simple-tree/core}/treeNodeValid.d.ts +18 -4
- package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -0
- package/dist/simple-tree/{treeNodeValid.js → core/treeNodeValid.js} +41 -11
- package/dist/simple-tree/core/treeNodeValid.js.map +1 -0
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/core/walkSchema.d.ts +2 -1
- package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/walkSchema.js +6 -2
- package/dist/simple-tree/core/walkSchema.js.map +1 -1
- package/dist/simple-tree/createContext.d.ts +6 -2
- package/dist/simple-tree/createContext.d.ts.map +1 -1
- package/dist/simple-tree/createContext.js +15 -3
- package/dist/simple-tree/createContext.js.map +1 -1
- package/dist/{feature-libraries/modular-schema → simple-tree}/discrepancies.d.ts +22 -29
- package/dist/simple-tree/discrepancies.d.ts.map +1 -0
- package/dist/simple-tree/discrepancies.js +382 -0
- package/dist/simple-tree/discrepancies.js.map +1 -0
- package/dist/simple-tree/fieldSchema.d.ts +423 -0
- package/dist/simple-tree/fieldSchema.d.ts.map +1 -0
- package/dist/simple-tree/{schemaTypes.js → fieldSchema.js} +5 -195
- package/dist/simple-tree/fieldSchema.js.map +1 -0
- package/dist/simple-tree/index.d.ts +7 -6
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +17 -11
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +14 -5
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +117 -2
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +97 -26
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +2 -2
- package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
- package/dist/simple-tree/node-kinds/common.d.ts +16 -0
- package/dist/simple-tree/node-kinds/common.d.ts.map +1 -0
- package/dist/simple-tree/node-kinds/common.js +42 -0
- package/dist/simple-tree/node-kinds/common.js.map +1 -0
- package/dist/simple-tree/node-kinds/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts +2 -3
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +64 -26
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts +2 -2
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.d.ts +2 -2
- package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +19 -5
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +131 -27
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +11 -4
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts +2 -2
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +41 -13
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts +2 -2
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/dist/simple-tree/prepareForInsertion.js +3 -3
- package/dist/simple-tree/prepareForInsertion.js.map +1 -1
- package/dist/simple-tree/simpleSchema.d.ts +2 -2
- 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 +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +6 -7
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +5 -11
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +25 -395
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/dist/simple-tree/unsafeUnknownSchema.d.ts +52 -0
- package/dist/simple-tree/unsafeUnknownSchema.d.ts.map +1 -0
- package/dist/simple-tree/unsafeUnknownSchema.js +13 -0
- package/dist/simple-tree/unsafeUnknownSchema.js.map +1 -0
- package/dist/simple-tree/walkFieldSchema.d.ts +1 -1
- package/dist/simple-tree/walkFieldSchema.js +2 -2
- package/dist/simple-tree/walkFieldSchema.js.map +1 -1
- package/dist/tableSchema.d.ts +12 -12
- package/dist/treeFactory.d.ts +0 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +0 -1
- package/dist/treeFactory.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +14 -1
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js +3 -0
- package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts +7 -2
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js +4 -4
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +1 -0
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js +1 -0
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +6 -6
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +3 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +3 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +1 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +2 -2
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +2 -2
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.js +0 -3
- package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +0 -1
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +0 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/index.d.ts +0 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +0 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +1 -1
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +5 -8
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +11 -13
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +61 -83
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeTypes.d.ts +1 -1
- package/lib/shared-tree/sharedTreeChangeTypes.js.map +1 -1
- package/lib/shared-tree/tree.d.ts.map +1 -1
- package/lib/shared-tree/tree.js +4 -3
- package/lib/shared-tree/tree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +7 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +7 -2
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +5 -2
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +1 -1
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js +2 -2
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +3 -1
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +2 -0
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +1 -2
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/getJsonSchema.d.ts +1 -1
- package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/getSimpleSchema.d.ts +1 -1
- package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
- package/lib/simple-tree/api/identifierIndex.d.ts +1 -1
- package/lib/simple-tree/api/identifierIndex.js +1 -1
- package/lib/simple-tree/api/identifierIndex.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +4 -19
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.js +25 -76
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +14 -2
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js +40 -4
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +36 -3
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +2 -2
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +16 -16
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +2 -2
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.d.ts +2 -2
- package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.js +2 -2
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +2 -2
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +2 -1
- 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/treeBeta.d.ts +4 -1
- package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts +1 -2
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +2 -2
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +2 -3
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts +2 -1
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +316 -0
- package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -0
- package/lib/simple-tree/core/allowedTypes.js +162 -0
- package/lib/simple-tree/core/allowedTypes.js.map +1 -0
- package/lib/simple-tree/core/context.d.ts +3 -9
- package/lib/simple-tree/core/context.d.ts.map +1 -1
- package/lib/simple-tree/core/context.js +0 -8
- package/lib/simple-tree/core/context.js.map +1 -1
- package/lib/simple-tree/core/flexList.d.ts.map +1 -0
- package/lib/simple-tree/core/flexList.js.map +1 -0
- package/lib/simple-tree/core/getOrCreateNode.d.ts +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +9 -3
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +6 -3
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +8 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +10 -6
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +182 -39
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js +44 -14
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/{dist/simple-tree → lib/simple-tree/core}/treeNodeValid.d.ts +18 -4
- package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -0
- package/lib/simple-tree/{treeNodeValid.js → core/treeNodeValid.js} +31 -3
- package/lib/simple-tree/core/treeNodeValid.js.map +1 -0
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/core/walkSchema.d.ts +2 -1
- package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/walkSchema.js +7 -3
- package/lib/simple-tree/core/walkSchema.js.map +1 -1
- package/lib/simple-tree/createContext.d.ts +6 -2
- package/lib/simple-tree/createContext.d.ts.map +1 -1
- package/lib/simple-tree/createContext.js +13 -2
- package/lib/simple-tree/createContext.js.map +1 -1
- package/lib/{feature-libraries/modular-schema → simple-tree}/discrepancies.d.ts +22 -29
- package/lib/simple-tree/discrepancies.d.ts.map +1 -0
- package/lib/simple-tree/discrepancies.js +376 -0
- package/lib/simple-tree/discrepancies.js.map +1 -0
- package/lib/simple-tree/fieldSchema.d.ts +423 -0
- package/lib/simple-tree/fieldSchema.d.ts.map +1 -0
- package/lib/simple-tree/{schemaTypes.js → fieldSchema.js} +3 -183
- package/lib/simple-tree/fieldSchema.js.map +1 -0
- package/lib/simple-tree/index.d.ts +7 -6
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +4 -3
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +14 -5
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +117 -3
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +86 -15
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +2 -2
- package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
- package/lib/simple-tree/node-kinds/common.d.ts +16 -0
- package/lib/simple-tree/node-kinds/common.d.ts.map +1 -0
- package/lib/simple-tree/node-kinds/common.js +38 -0
- package/lib/simple-tree/node-kinds/common.js.map +1 -0
- package/lib/simple-tree/node-kinds/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts +2 -3
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +51 -13
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts +2 -2
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.js +1 -1
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.d.ts +2 -2
- package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +19 -5
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +116 -14
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +11 -4
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.js +1 -1
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts +2 -2
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +40 -12
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.js +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts +2 -2
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/lib/simple-tree/prepareForInsertion.js +2 -2
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/simple-tree/simpleSchema.d.ts +2 -2
- 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 +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +2 -3
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +5 -11
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +10 -381
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/lib/simple-tree/unsafeUnknownSchema.d.ts +52 -0
- package/lib/simple-tree/unsafeUnknownSchema.d.ts.map +1 -0
- package/lib/simple-tree/unsafeUnknownSchema.js +10 -0
- package/lib/simple-tree/unsafeUnknownSchema.js.map +1 -0
- package/lib/simple-tree/walkFieldSchema.d.ts +1 -1
- package/lib/simple-tree/walkFieldSchema.js +1 -1
- package/lib/simple-tree/walkFieldSchema.js.map +1 -1
- package/lib/tableSchema.d.ts +12 -12
- package/lib/treeFactory.d.ts +0 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +0 -1
- package/lib/treeFactory.js.map +1 -1
- package/package.json +22 -23
- package/src/core/schema-stored/schema.ts +14 -1
- package/src/feature-libraries/default-schema/schemaChecker.ts +3 -0
- package/src/feature-libraries/flex-tree/context.ts +10 -5
- package/src/feature-libraries/flex-tree/index.ts +2 -0
- package/src/feature-libraries/flex-tree/lazyField.ts +10 -6
- package/src/feature-libraries/flex-tree/lazyNode.ts +6 -1
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -2
- package/src/feature-libraries/index.ts +1 -15
- package/src/feature-libraries/modular-schema/comparison.ts +0 -4
- package/src/feature-libraries/modular-schema/index.ts +0 -17
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +0 -2
- package/src/shared-tree/schematizeTree.ts +5 -9
- package/src/shared-tree/schematizingTreeView.ts +75 -113
- package/src/shared-tree/sharedTreeChangeTypes.ts +1 -1
- package/src/shared-tree/tree.ts +4 -3
- package/src/shared-tree/treeAlpha.ts +7 -1
- package/src/shared-tree/treeCheckout.ts +15 -2
- package/src/simple-tree/api/conciseTree.ts +1 -2
- package/src/simple-tree/api/configuration.ts +7 -4
- package/src/simple-tree/api/create.ts +3 -1
- package/src/simple-tree/api/customTree.ts +1 -2
- package/src/simple-tree/api/getJsonSchema.ts +1 -1
- package/src/simple-tree/api/getSimpleSchema.ts +1 -1
- package/src/simple-tree/api/identifierIndex.ts +1 -1
- package/src/simple-tree/api/index.ts +2 -0
- package/src/simple-tree/api/schemaCompatibilityTester.ts +38 -128
- package/src/simple-tree/api/schemaCreationUtilities.ts +50 -5
- package/src/simple-tree/api/schemaFactory.ts +45 -10
- package/src/simple-tree/api/schemaFactoryAlpha.ts +4 -7
- package/src/simple-tree/api/schemaFactoryRecursive.ts +9 -4
- package/src/simple-tree/api/schemaFromSimple.ts +2 -3
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
- package/src/simple-tree/api/simpleTreeIndex.ts +8 -3
- package/src/simple-tree/api/storedSchema.ts +1 -2
- package/src/simple-tree/api/tree.ts +2 -2
- package/src/simple-tree/api/treeBeta.ts +4 -1
- package/src/simple-tree/api/treeNodeApi.ts +5 -8
- package/src/simple-tree/api/typesUnsafe.ts +5 -4
- package/src/simple-tree/api/verboseTree.ts +3 -6
- package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +1 -1
- package/src/simple-tree/core/README.md +1 -1
- package/src/simple-tree/core/allowedTypes.ts +496 -0
- package/src/simple-tree/core/context.ts +3 -10
- package/src/simple-tree/core/getOrCreateNode.ts +1 -1
- package/src/simple-tree/core/index.ts +62 -9
- package/src/simple-tree/core/treeNodeKernel.ts +12 -6
- package/src/simple-tree/core/treeNodeSchema.ts +247 -63
- package/src/simple-tree/{treeNodeValid.ts → core/treeNodeValid.ts} +59 -15
- package/src/simple-tree/core/unhydratedFlexTree.ts +1 -1
- package/src/simple-tree/core/walkSchema.ts +9 -5
- package/src/simple-tree/createContext.ts +26 -2
- package/src/simple-tree/discrepancies.ts +648 -0
- package/src/simple-tree/fieldSchema.ts +734 -0
- package/src/simple-tree/index.ts +41 -31
- package/src/simple-tree/leafNodeSchema.ts +137 -5
- package/src/simple-tree/node-kinds/array/arrayNode.ts +141 -30
- package/src/simple-tree/node-kinds/array/arrayNodeTypes.ts +5 -7
- package/src/simple-tree/node-kinds/common.ts +60 -0
- package/src/simple-tree/node-kinds/index.ts +2 -0
- package/src/simple-tree/node-kinds/map/mapNode.ts +91 -33
- package/src/simple-tree/node-kinds/map/mapNodeTypes.ts +5 -7
- package/src/simple-tree/node-kinds/object/index.ts +2 -0
- package/src/simple-tree/node-kinds/object/objectNode.ts +205 -25
- package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +22 -5
- package/src/simple-tree/node-kinds/record/recordNode.ts +68 -26
- package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +6 -8
- package/src/simple-tree/prepareForInsertion.ts +7 -6
- package/src/simple-tree/simpleSchema.ts +2 -2
- package/src/simple-tree/toStoredSchema.ts +2 -3
- package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +12 -494
- package/src/simple-tree/unsafeUnknownSchema.ts +70 -0
- package/src/simple-tree/walkFieldSchema.ts +1 -1
- package/src/treeFactory.ts +0 -1
- package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +0 -1
- package/dist/feature-libraries/modular-schema/discrepancies.js +0 -361
- package/dist/feature-libraries/modular-schema/discrepancies.js.map +0 -1
- package/dist/shared-tree/checkoutFlexTreeView.d.ts +0 -58
- package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +0 -1
- package/dist/shared-tree/checkoutFlexTreeView.js +0 -77
- package/dist/shared-tree/checkoutFlexTreeView.js.map +0 -1
- package/dist/simple-tree/flexList.d.ts.map +0 -1
- package/dist/simple-tree/flexList.js.map +0 -1
- package/dist/simple-tree/schemaTypes.d.ts +0 -856
- package/dist/simple-tree/schemaTypes.d.ts.map +0 -1
- package/dist/simple-tree/schemaTypes.js.map +0 -1
- package/dist/simple-tree/treeNodeValid.d.ts.map +0 -1
- package/dist/simple-tree/treeNodeValid.js.map +0 -1
- package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +0 -1
- package/lib/feature-libraries/modular-schema/discrepancies.js +0 -354
- package/lib/feature-libraries/modular-schema/discrepancies.js.map +0 -1
- package/lib/shared-tree/checkoutFlexTreeView.d.ts +0 -58
- package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +0 -1
- package/lib/shared-tree/checkoutFlexTreeView.js +0 -72
- package/lib/shared-tree/checkoutFlexTreeView.js.map +0 -1
- package/lib/simple-tree/flexList.d.ts.map +0 -1
- package/lib/simple-tree/flexList.js.map +0 -1
- package/lib/simple-tree/schemaTypes.d.ts +0 -856
- package/lib/simple-tree/schemaTypes.d.ts.map +0 -1
- package/lib/simple-tree/schemaTypes.js.map +0 -1
- package/lib/simple-tree/treeNodeValid.d.ts.map +0 -1
- package/lib/simple-tree/treeNodeValid.js.map +0 -1
- package/src/feature-libraries/modular-schema/discrepancies.ts +0 -567
- package/src/shared-tree/checkoutFlexTreeView.ts +0 -100
- package/src/simple-tree/schemaTypes.ts +0 -1420
- /package/dist/simple-tree/{flexList.d.ts → core/flexList.d.ts} +0 -0
- /package/dist/simple-tree/{flexList.js → core/flexList.js} +0 -0
- /package/lib/simple-tree/{flexList.d.ts → core/flexList.d.ts} +0 -0
- /package/lib/simple-tree/{flexList.js → core/flexList.js} +0 -0
- /package/src/simple-tree/{flexList.ts → core/flexList.ts} +0 -0
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
6
|
-
import type { AllowedTypeMetadata, AllowedTypesMetadata, AnnotatedAllowedTypes, ImplicitAnnotatedAllowedTypes, TreeLeafValue } from "../schemaTypes.js";
|
|
5
|
+
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
6
|
import type { SimpleNodeSchemaBase } from "../simpleSchema.js";
|
|
8
7
|
import type { TreeNode } from "./treeNode.js";
|
|
9
8
|
import type { InternalTreeNode, Unhydrated } from "./types.js";
|
|
9
|
+
import type { UnionToIntersection } from "../../util/index.js";
|
|
10
|
+
import type { ImplicitAnnotatedAllowedTypes, NormalizedAnnotatedAllowedTypes } from "./allowedTypes.js";
|
|
11
|
+
import type { Context } from "./context.js";
|
|
12
|
+
import type { FieldKey, NodeData } from "../../core/index.js";
|
|
13
|
+
import type { UnhydratedFlexTreeField } from "./unhydratedFlexTree.js";
|
|
14
|
+
import type { FactoryContent } from "../unhydratedFlexTreeFromInsertable.js";
|
|
10
15
|
/**
|
|
11
16
|
* Schema for a {@link TreeNode} or {@link TreeLeafValue}.
|
|
12
17
|
*
|
|
@@ -29,38 +34,6 @@ import type { InternalTreeNode, Unhydrated } from "./types.js";
|
|
|
29
34
|
* @sealed @public
|
|
30
35
|
*/
|
|
31
36
|
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown, TCustomMetadata = unknown> = (TNode extends TreeNode ? TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info, never, TCustomMetadata> : never) | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info, never, TCustomMetadata>;
|
|
32
|
-
/**
|
|
33
|
-
* Stores annotations for an individual allowed type.
|
|
34
|
-
* @alpha
|
|
35
|
-
*/
|
|
36
|
-
export interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {
|
|
37
|
-
/**
|
|
38
|
-
* Annotations for the allowed type.
|
|
39
|
-
*/
|
|
40
|
-
readonly metadata: AllowedTypeMetadata;
|
|
41
|
-
/**
|
|
42
|
-
* The allowed type the annotations apply to in a particular schema.
|
|
43
|
-
*/
|
|
44
|
-
readonly type: T;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Stores annotations for a set of evaluated annotated allowed types.
|
|
48
|
-
* @alpha
|
|
49
|
-
*/
|
|
50
|
-
export interface NormalizedAnnotatedAllowedTypes {
|
|
51
|
-
/**
|
|
52
|
-
* Annotations that apply to a set of allowed types.
|
|
53
|
-
*/
|
|
54
|
-
readonly metadata: AllowedTypesMetadata;
|
|
55
|
-
/**
|
|
56
|
-
* All the evaluated allowed types that the annotations apply to. The types themselves are also individually annotated.
|
|
57
|
-
*/
|
|
58
|
-
readonly types: readonly AnnotatedAllowedType<TreeNodeSchema>[];
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Checks if the input is an {@link AnnotatedAllowedTypes}.
|
|
62
|
-
*/
|
|
63
|
-
export declare function isAnnotatedAllowedTypes(allowedTypes: ImplicitAnnotatedAllowedTypes): allowedTypes is AnnotatedAllowedTypes;
|
|
64
37
|
/**
|
|
65
38
|
* Schema which is not a class.
|
|
66
39
|
* @remarks
|
|
@@ -235,10 +208,61 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
|
|
|
235
208
|
*/
|
|
236
209
|
createFromInsertable(data: TInsertable): Unhydrated<TreeNode | TreeLeafValue>;
|
|
237
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Symbol for use by {@link TreeNodeSchemaCorePrivate}.
|
|
213
|
+
*/
|
|
214
|
+
export declare const privateDataSymbol: unique symbol;
|
|
238
215
|
/**
|
|
239
216
|
* {@link TreeNodeSchemaCore} extended with some non-exported APIs.
|
|
240
217
|
*/
|
|
241
218
|
export interface TreeNodeSchemaCorePrivate<Name extends string = string, Kind extends NodeKind = NodeKind, TInsertable = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown, TCustomMetadata = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info, TInsertable, TCustomMetadata> {
|
|
219
|
+
/**
|
|
220
|
+
* Package private data provided by all {@link TreeNodeSchema}.
|
|
221
|
+
* @remarks
|
|
222
|
+
* Users can add custom statics to schema classes.
|
|
223
|
+
* To reduce the risk of such statics colliding with properties used to implement the schema,
|
|
224
|
+
* some of the private APIs are grouped together under this symbol.
|
|
225
|
+
*
|
|
226
|
+
* Note that there are still some properties which are not under a symbol and thus expose some risk of name collisions.
|
|
227
|
+
* See {@link TreeNodeValid} for some such properties.
|
|
228
|
+
*/
|
|
229
|
+
readonly [privateDataSymbol]: TreeNodeSchemaPrivateData;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Package private data provided by all {@link TreeNodeSchema}.
|
|
233
|
+
* @remarks
|
|
234
|
+
* This data needs to be available before lazy schema references are resolved.
|
|
235
|
+
* For data which is only available after lazy schema references are resolved,
|
|
236
|
+
* see {@link TreeNodeSchemaInitializedData}, which can be accessed via {@link TreeNodeSchemaPrivateData.idempotentInitialize}.
|
|
237
|
+
*/
|
|
238
|
+
export interface TreeNodeSchemaPrivateData {
|
|
239
|
+
/**
|
|
240
|
+
* All possible annotated allowed types that a field under a node with this schema could have.
|
|
241
|
+
* @remarks
|
|
242
|
+
* In this case "field" includes anything that is a field in the internal (flex-tree) abstraction layer.
|
|
243
|
+
* This includes the content field for arrays, and all the fields for map nodes.
|
|
244
|
+
* If this node does not have fields (and thus is a leaf), the array will be empty.
|
|
245
|
+
*
|
|
246
|
+
* This set cannot be used before the schema in it have been defined:
|
|
247
|
+
* more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),
|
|
248
|
+
* users must wait until after the schema are defined to access this array.
|
|
249
|
+
*
|
|
250
|
+
* @privateRemarks
|
|
251
|
+
* If this is stabilized, it will live alongside the childTypes property on {@link TreeNodeSchemaCore}.
|
|
252
|
+
* @system
|
|
253
|
+
*/
|
|
254
|
+
readonly childAnnotatedAllowedTypes: readonly ImplicitAnnotatedAllowedTypes[];
|
|
255
|
+
/**
|
|
256
|
+
* Idempotent initialization function that pre-caches data and can dereference lazy schema references.
|
|
257
|
+
*/
|
|
258
|
+
idempotentInitialize(): TreeNodeSchemaInitializedData;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Additional data about a given schema which is private to this package.
|
|
262
|
+
* @remarks
|
|
263
|
+
* Created by {@link TreeNodeValid.oneTimeSetup} and can involve dereferencing lazy schema references.
|
|
264
|
+
*/
|
|
265
|
+
export interface TreeNodeSchemaInitializedData {
|
|
242
266
|
/**
|
|
243
267
|
* All possible annotated allowed types that a field under a node with this schema could have.
|
|
244
268
|
* @remarks
|
|
@@ -255,15 +279,63 @@ export interface TreeNodeSchemaCorePrivate<Name extends string = string, Kind ex
|
|
|
255
279
|
* @system
|
|
256
280
|
*/
|
|
257
281
|
readonly childAnnotatedAllowedTypes: readonly NormalizedAnnotatedAllowedTypes[];
|
|
282
|
+
/**
|
|
283
|
+
* A {@link Context} which can be used for unhydrated nodes of this schema.
|
|
284
|
+
*/
|
|
285
|
+
readonly context: Context;
|
|
286
|
+
/**
|
|
287
|
+
* Checks if data might be schema-compatible.
|
|
288
|
+
*
|
|
289
|
+
* @returns false if `data` is incompatible with `type` based on a cheap/shallow check.
|
|
290
|
+
*
|
|
291
|
+
* Note that this may return true for cases where data is incompatible, but it must not return false in cases where the data is compatible.
|
|
292
|
+
*/
|
|
293
|
+
shallowCompatibilityTest(data: FactoryContent): CompatibilityLevel;
|
|
294
|
+
/**
|
|
295
|
+
* Convert data to a {@link FlexContent} representation.
|
|
296
|
+
* @remarks
|
|
297
|
+
* Data must be compatible with the schema according to {@link shallowCompatibilityTest}.
|
|
298
|
+
*
|
|
299
|
+
* TODO: use of `allowedTypes` is for fallbacks (for example NaN -\> null).
|
|
300
|
+
* This behavior should be moved to shallowCompatibilityTest instead.
|
|
301
|
+
*/
|
|
302
|
+
toFlexContent(data: FactoryContent, allowedTypes: ReadonlySet<TreeNodeSchema>): FlexContent;
|
|
258
303
|
}
|
|
304
|
+
export type FlexContent = [NodeData, Map<FieldKey, UnhydratedFlexTreeField>];
|
|
259
305
|
/**
|
|
260
|
-
*
|
|
261
|
-
*
|
|
306
|
+
* Indicates a compatibility level for inferring a schema to apply to insertable data.
|
|
262
307
|
* @remarks
|
|
263
|
-
*
|
|
264
|
-
*
|
|
308
|
+
* Each schema allowed at a location in the tree has its compatibility level checked against the data being inserted.
|
|
309
|
+
* The compatibility is considered unambiguous if there is a single schema with a higher compatibility than all others.
|
|
310
|
+
*
|
|
311
|
+
* This approach allows adding new compatible formats as a non breaking change.
|
|
312
|
+
* If the new format was already compatible with some other schema, it can still be added as non-breaking as long as a lower compatibility level is used.
|
|
313
|
+
* For example, support for constructing maps from record like objects was added in Fluid Framework 2.2.
|
|
314
|
+
* This format (an object with fields) was already compatible with Object nodes at compatibility level Normal so the new format support for maps was added at compatibility level Low.
|
|
315
|
+
* This ensures that existing code that was using object literals as insertable content where both objects and maps were allowed will continue to work,
|
|
316
|
+
* assuming the objects are intended as ObjectNodes.
|
|
317
|
+
* However new code can now be written using record like objects to construct maps, as long as the schema does not also allow Object nodes which are compatible with the data in that location.
|
|
318
|
+
*
|
|
319
|
+
* @see {@link ITreeConfigurationOptions.preventAmbiguity} for a related setting which interacts with this in a somewhat complex way.
|
|
320
|
+
*/
|
|
321
|
+
export declare enum CompatibilityLevel {
|
|
322
|
+
/**
|
|
323
|
+
* Not compatible. Constructor typing indicates incompatibility.
|
|
324
|
+
*/
|
|
325
|
+
None = 0,
|
|
326
|
+
/**
|
|
327
|
+
* Additional compatibility cases added in Fluid Framework 2.2.
|
|
328
|
+
*/
|
|
329
|
+
Low = 1,
|
|
330
|
+
/**
|
|
331
|
+
* Compatible in Fluid Framework 2.0.
|
|
332
|
+
*/
|
|
333
|
+
Normal = 2
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Downcasts a {@link TreeNodeSchemaCore} to {@link TreeNodeSchemaCorePrivate} and get its {@link TreeNodeSchemaPrivateData}.
|
|
265
337
|
*/
|
|
266
|
-
export declare function
|
|
338
|
+
export declare function getTreeNodeSchemaPrivateData(schema: TreeNodeSchemaCore<string, NodeKind, boolean>): TreeNodeSchemaPrivateData;
|
|
267
339
|
/**
|
|
268
340
|
* Kind of tree node.
|
|
269
341
|
* @remarks
|
|
@@ -294,4 +366,75 @@ export declare enum NodeKind {
|
|
|
294
366
|
*/
|
|
295
367
|
Record = 4
|
|
296
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* Metadata associated with a Node Schema.
|
|
371
|
+
*
|
|
372
|
+
* @remarks Specified via {@link NodeSchemaOptions.metadata}.
|
|
373
|
+
*
|
|
374
|
+
* @sealed
|
|
375
|
+
* @public
|
|
376
|
+
*/
|
|
377
|
+
export interface NodeSchemaMetadata<out TCustomMetadata = unknown> {
|
|
378
|
+
/**
|
|
379
|
+
* User-defined metadata.
|
|
380
|
+
*/
|
|
381
|
+
readonly custom?: TCustomMetadata | undefined;
|
|
382
|
+
/**
|
|
383
|
+
* The description of the Node Schema.
|
|
384
|
+
*
|
|
385
|
+
* @remarks
|
|
386
|
+
*
|
|
387
|
+
* If provided, will be used by the system in scenarios where a description of the kind of node is useful.
|
|
388
|
+
* E.g., when converting a Node Schema to {@link https://json-schema.org/ | JSON Schema}, this description will be
|
|
389
|
+
* used as the `description` property.
|
|
390
|
+
*/
|
|
391
|
+
readonly description?: string | undefined;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Returns true if the given schema is a {@link TreeNodeSchemaClass}, or otherwise false if it is a {@link TreeNodeSchemaNonClass}.
|
|
395
|
+
* @internal
|
|
396
|
+
*/
|
|
397
|
+
export declare function isTreeNodeSchemaClass<Name extends string, Kind extends NodeKind, TNode extends TreeNode | TreeLeafValue, TBuild, ImplicitlyConstructable extends boolean, Info>(schema: TreeNodeSchema<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaClass<Name, Kind, TNode & TreeNode, TBuild, ImplicitlyConstructable, Info>): schema is TreeNodeSchemaClass<Name, Kind, TNode & TreeNode, TBuild, ImplicitlyConstructable, Info>;
|
|
398
|
+
/**
|
|
399
|
+
* Takes in `TreeNodeSchema[]` and returns a TypedNode union.
|
|
400
|
+
* @privateRemarks
|
|
401
|
+
* If a schema is both TreeNodeSchemaClass and TreeNodeSchemaNonClass, prefer TreeNodeSchemaClass since that includes subclasses properly.
|
|
402
|
+
* @public
|
|
403
|
+
*/
|
|
404
|
+
export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchemaClass<string, NodeKind, infer TNode> ? TNode : T extends TreeNodeSchemaNonClass<string, NodeKind, infer TNode> ? TNode : never;
|
|
405
|
+
/**
|
|
406
|
+
* Data which can be used as a node to be inserted.
|
|
407
|
+
* Either an unhydrated node, or content to build a new node.
|
|
408
|
+
*
|
|
409
|
+
* @see {@link Input}
|
|
410
|
+
*
|
|
411
|
+
* @typeparam TSchemaInput - Schema to process.
|
|
412
|
+
* @typeparam T - Do not specify: default value used as implementation detail.
|
|
413
|
+
* @privateRemarks
|
|
414
|
+
* This can't really be fully correct, since TreeNodeSchema's TNode is generally use covariantly but this code uses it contravariantly.
|
|
415
|
+
* That makes this TreeNodeSchema actually invariant with respect to TNode, but doing that would break all `extends TreeNodeSchema` clauses.
|
|
416
|
+
* As is, this works correctly in most realistic use-cases.
|
|
417
|
+
*
|
|
418
|
+
* One special case this makes is if the result of NodeFromSchema contains TreeNode, this must be an under constrained schema, so the result is set to never.
|
|
419
|
+
* Note that applying UnionToIntersection on the result of NodeFromSchema<T> does not work since it breaks booleans.
|
|
420
|
+
*
|
|
421
|
+
* @public
|
|
422
|
+
*/
|
|
423
|
+
export type InsertableTypedNode<TSchema extends TreeNodeSchema, T = UnionToIntersection<TSchema>> = (T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, never, true> ? NodeBuilderData<T> : never) | (T extends TreeNodeSchema ? Unhydrated<TreeNode extends NodeFromSchema<T> ? never : NodeFromSchema<T>> : never);
|
|
424
|
+
/**
|
|
425
|
+
* Given a node's schema, return the corresponding object from which the node could be built.
|
|
426
|
+
* @privateRemarks
|
|
427
|
+
* This uses TreeNodeSchemaCore, and thus depends on TreeNodeSchemaCore.createFromInsertable for the typing.
|
|
428
|
+
* This works almost the same as using TreeNodeSchema,
|
|
429
|
+
* except that the more complex typing in TreeNodeSchema case breaks for non-class schema and leaks in `undefined` from optional crete parameters.
|
|
430
|
+
* @system @public
|
|
431
|
+
*/
|
|
432
|
+
export type NodeBuilderData<T extends TreeNodeSchemaCore<string, NodeKind, boolean>> = T extends TreeNodeSchemaCore<string, NodeKind, boolean, unknown, infer TBuild> ? TBuild : never;
|
|
433
|
+
/**
|
|
434
|
+
* Value that may be stored as a leaf node.
|
|
435
|
+
* @remarks
|
|
436
|
+
* Some limitations apply, see the documentation for {@link SchemaStatics.number} and {@link SchemaStatics.string} for those restrictions.
|
|
437
|
+
* @public
|
|
438
|
+
*/
|
|
439
|
+
export type TreeLeafValue = number | string | boolean | IFluidHandle | null;
|
|
297
440
|
//# sourceMappingURL=treeNodeSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeNodeSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeS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GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,IAAI,CAAC"}
|
|
@@ -4,30 +4,52 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.NodeKind = exports.
|
|
7
|
+
exports.isTreeNodeSchemaClass = exports.NodeKind = exports.getTreeNodeSchemaPrivateData = exports.CompatibilityLevel = exports.privateDataSymbol = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Symbol for use by {@link TreeNodeSchemaCorePrivate}.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
// Class based schema, and lazy schema references report type "function": filtering them out with typeof makes narrowing based on members mostly safe
|
|
15
|
-
typeof allowedTypes === "object" && "metadata" in allowedTypes && "types" in allowedTypes);
|
|
16
|
-
}
|
|
17
|
-
exports.isAnnotatedAllowedTypes = isAnnotatedAllowedTypes;
|
|
12
|
+
exports.privateDataSymbol = Symbol("PrivateData");
|
|
18
13
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
14
|
+
* Indicates a compatibility level for inferring a schema to apply to insertable data.
|
|
21
15
|
* @remarks
|
|
22
|
-
*
|
|
23
|
-
*
|
|
16
|
+
* Each schema allowed at a location in the tree has its compatibility level checked against the data being inserted.
|
|
17
|
+
* The compatibility is considered unambiguous if there is a single schema with a higher compatibility than all others.
|
|
18
|
+
*
|
|
19
|
+
* This approach allows adding new compatible formats as a non breaking change.
|
|
20
|
+
* If the new format was already compatible with some other schema, it can still be added as non-breaking as long as a lower compatibility level is used.
|
|
21
|
+
* For example, support for constructing maps from record like objects was added in Fluid Framework 2.2.
|
|
22
|
+
* This format (an object with fields) was already compatible with Object nodes at compatibility level Normal so the new format support for maps was added at compatibility level Low.
|
|
23
|
+
* This ensures that existing code that was using object literals as insertable content where both objects and maps were allowed will continue to work,
|
|
24
|
+
* assuming the objects are intended as ObjectNodes.
|
|
25
|
+
* However new code can now be written using record like objects to construct maps, as long as the schema does not also allow Object nodes which are compatible with the data in that location.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link ITreeConfigurationOptions.preventAmbiguity} for a related setting which interacts with this in a somewhat complex way.
|
|
24
28
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
var CompatibilityLevel;
|
|
30
|
+
(function (CompatibilityLevel) {
|
|
31
|
+
/**
|
|
32
|
+
* Not compatible. Constructor typing indicates incompatibility.
|
|
33
|
+
*/
|
|
34
|
+
CompatibilityLevel[CompatibilityLevel["None"] = 0] = "None";
|
|
35
|
+
/**
|
|
36
|
+
* Additional compatibility cases added in Fluid Framework 2.2.
|
|
37
|
+
*/
|
|
38
|
+
CompatibilityLevel[CompatibilityLevel["Low"] = 1] = "Low";
|
|
39
|
+
/**
|
|
40
|
+
* Compatible in Fluid Framework 2.0.
|
|
41
|
+
*/
|
|
42
|
+
CompatibilityLevel[CompatibilityLevel["Normal"] = 2] = "Normal";
|
|
43
|
+
})(CompatibilityLevel || (exports.CompatibilityLevel = CompatibilityLevel = {}));
|
|
44
|
+
/**
|
|
45
|
+
* Downcasts a {@link TreeNodeSchemaCore} to {@link TreeNodeSchemaCorePrivate} and get its {@link TreeNodeSchemaPrivateData}.
|
|
46
|
+
*/
|
|
47
|
+
function getTreeNodeSchemaPrivateData(schema) {
|
|
48
|
+
(0, internal_1.assert)(exports.privateDataSymbol in schema, 0xbc9 /* All implementations of TreeNodeSchemaCore must also implement TreeNodeSchemaCorePrivate */);
|
|
49
|
+
const schemaValid = schema;
|
|
50
|
+
return schemaValid[exports.privateDataSymbol];
|
|
29
51
|
}
|
|
30
|
-
exports.
|
|
52
|
+
exports.getTreeNodeSchemaPrivateData = getTreeNodeSchemaPrivateData;
|
|
31
53
|
/**
|
|
32
54
|
* Kind of tree node.
|
|
33
55
|
* @remarks
|
|
@@ -59,4 +81,12 @@ var NodeKind;
|
|
|
59
81
|
*/
|
|
60
82
|
NodeKind[NodeKind["Record"] = 4] = "Record";
|
|
61
83
|
})(NodeKind || (exports.NodeKind = NodeKind = {}));
|
|
84
|
+
/**
|
|
85
|
+
* Returns true if the given schema is a {@link TreeNodeSchemaClass}, or otherwise false if it is a {@link TreeNodeSchemaNonClass}.
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
function isTreeNodeSchemaClass(schema) {
|
|
89
|
+
return schema.constructor !== undefined;
|
|
90
|
+
}
|
|
91
|
+
exports.isTreeNodeSchemaClass = isTreeNodeSchemaClass;
|
|
62
92
|
//# sourceMappingURL=treeNodeSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeNodeSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAiG7D;;GAEG;AACH,SAAgB,uBAAuB,CACtC,YAA2C;IAE3C,OAAO;IACN,qJAAqJ;IACrJ,OAAO,YAAY,KAAK,QAAQ,IAAI,UAAU,IAAI,YAAY,IAAI,OAAO,IAAI,YAAY,CACzF,CAAC;AACH,CAAC;AAPD,0DAOC;AAySD;;;;;;GAMG;AACH,SAAgB,2BAA2B,CAC1C,MAAqD;IAErD,IAAA,iBAAM,EACL,4BAA4B,IAAI,MAAM,EACtC,KAAK,CAAC,6FAA6F,CACnG,CAAC;IACF,IAAA,iBAAM,EACL,KAAK,CAAC,OAAO,CAAE,MAAoC,CAAC,0BAA0B,CAAC,EAC/E,KAAK,CAAC,6FAA6F,CACnG,CAAC;IACF,OAAO,MAAmC,CAAC;AAC5C,CAAC;AAZD,kEAYC;AAED;;;;;GAKG;AACH,IAAY,QAuBX;AAvBD,WAAY,QAAQ;IACnB;;OAEG;IACH,qCAAO,CAAA;IACP;;OAEG;IACH,yCAAS,CAAA;IACT;;;;OAIG;IACH,2CAAU,CAAA;IACV;;OAEG;IACH,uCAAQ,CAAA;IACR;;OAEG;IACH,2CAAU,CAAA;AACX,CAAC,EAvBW,QAAQ,wBAAR,QAAQ,QAuBnB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { LazyItem } from \"../flexList.js\";\nimport type {\n\tAllowedTypeMetadata,\n\tAllowedTypesMetadata,\n\tAnnotatedAllowedTypes,\n\tImplicitAnnotatedAllowedTypes,\n\tTreeLeafValue,\n} from \"../schemaTypes.js\";\nimport type { SimpleNodeSchemaBase } from \"../simpleSchema.js\";\n\nimport type { TreeNode } from \"./treeNode.js\";\nimport type { InternalTreeNode, Unhydrated } from \"./types.js\";\n\n/**\n * Schema for a {@link TreeNode} or {@link TreeLeafValue}.\n *\n * @typeParam Name - The full (including scope) name/identifier for the schema.\n * @typeParam Kind - Which kind of node this schema is for.\n * @typeParam TNode - API for nodes that use this schema.\n * @typeParam TBuild - Data which can be used to construct an {@link Unhydrated} node of this type.\n * @typeParam Info - Data used when defining this schema.\n * @remarks\n * Captures the schema both as runtime data and compile time type information.\n * Use {@link SchemaFactory} to define schema.\n * Use `Tree.schema(value)` to lookup the schema for a {@link TreeNode} or {@link TreeLeafValue}.\n * @privateRemarks\n * TODO:\n * The long lists of type parameters here are awkward to deal with.\n * Switching to (or adding an option to use)\n * an interface based pattern with unordered named parameters for types like this would be a good idea.\n * The related `@system` types should be simple to port to the new pattern, but stable public one like this will need to support both:\n * the new one could either be added as a system type, or be recommended to replace this one (deprecating it).\n * @sealed @public\n */\nexport type TreeNodeSchema<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTBuild = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTCustomMetadata = unknown,\n> =\n\t| (TNode extends TreeNode\n\t\t\t? TreeNodeSchemaClass<\n\t\t\t\t\tName,\n\t\t\t\t\tKind,\n\t\t\t\t\tTNode,\n\t\t\t\t\tTBuild,\n\t\t\t\t\tImplicitlyConstructable,\n\t\t\t\t\tInfo,\n\t\t\t\t\tnever,\n\t\t\t\t\tTCustomMetadata\n\t\t\t\t>\n\t\t\t: never)\n\t| TreeNodeSchemaNonClass<\n\t\t\tName,\n\t\t\tKind,\n\t\t\tTNode,\n\t\t\tTBuild,\n\t\t\tImplicitlyConstructable,\n\t\t\tInfo,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t >;\n\n/**\n * Stores annotations for an individual allowed type.\n * @alpha\n */\nexport interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {\n\t/**\n\t * Annotations for the allowed type.\n\t */\n\treadonly metadata: AllowedTypeMetadata;\n\t/**\n\t * The allowed type the annotations apply to in a particular schema.\n\t */\n\treadonly type: T;\n}\n\n/**\n * Stores annotations for a set of evaluated annotated allowed types.\n * @alpha\n */\nexport interface NormalizedAnnotatedAllowedTypes {\n\t/**\n\t * Annotations that apply to a set of allowed types.\n\t */\n\treadonly metadata: AllowedTypesMetadata;\n\t/**\n\t * All the evaluated allowed types that the annotations apply to. The types themselves are also individually annotated.\n\t */\n\treadonly types: readonly AnnotatedAllowedType<TreeNodeSchema>[];\n}\n\n/**\n * Checks if the input is an {@link AnnotatedAllowedTypes}.\n */\nexport function isAnnotatedAllowedTypes(\n\tallowedTypes: ImplicitAnnotatedAllowedTypes,\n): allowedTypes is AnnotatedAllowedTypes {\n\treturn (\n\t\t// Class based schema, and lazy schema references report type \"function\": filtering them out with typeof makes narrowing based on members mostly safe\n\t\ttypeof allowedTypes === \"object\" && \"metadata\" in allowedTypes && \"types\" in allowedTypes\n\t);\n}\n\n/**\n * Schema which is not a class.\n * @remarks\n * This is used for schema which cannot have their instances constructed using constructors, like leaf schema.\n * @privateRemarks\n * Non-class based schema can have issues with recursive types due to https://github.com/microsoft/TypeScript/issues/55832.\n * @system @sealed @public\n */\nexport type TreeNodeSchemaNonClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Also allows InternalTreeNode.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data?: TInsertable | TConstructorExtra): TNode;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Also allows InternalTreeNode.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data: TInsertable | TConstructorExtra): TNode;\n\t\t\t});\n\n/**\n * Tree node schema which is implemented using a class.\n * @remarks\n * Instances of this class are nodes in the tree.\n * This is also a constructor so that it can be subclassed.\n *\n * Using classes in this way allows introducing a named type and a named value at the same time, helping keep the runtime and compile time information together and easy to refer to un a uniform way.\n * Additionally, this works around https://github.com/microsoft/TypeScript/issues/55832 which causes similar patterns with less explicit types to infer \"any\" in the d.ts file.\n *\n * When sub-classing a a `TreeNodeSchemaClass`, some extra rules must be followed:\n *\n * - Only ever use a single class from the schema's class hierarchy within a document and its schema.\n * For example, if using {@link SchemaFactory.object} you can do:\n * ```typescript\n * // Recommended \"customizable\" object schema pattern.\n * class Good extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \tpublic exampleCustomMethod(): void {\n * \t\tthis.exampleField++;\n * \t}\n * }\n * ```\n * But should avoid:\n * ```typescript\n * // This by itself is ok, and opts into \"POJO mode\".\n * const base = schemaFactory.object(\"A\", {});\n * // This is a bad pattern since it leaves two classes in scope which derive from the same SchemaFactory defined class.\n * // If both get used, its an error!\n * class Invalid extends base {}\n * ```\n *\n * - Do not modify the constructor input parameter types or values:\n * ```typescript\n * class Invalid extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \t// This Modifies the type of the constructor input.\n * \t// This is unsupported due to programmatic access to the constructor being used internally.\n * \tpublic constructor(a: number) {\n * \t\tsuper({ exampleField: a });\n * \t}\n * }\n * ```\n * @sealed @public\n */\nexport type TreeNodeSchemaClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data?: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t});\n\n/**\n * Internal helper for utilities that return schema which can be used in class and non class formats depending on the API exposing it.\n */\nexport type TreeNodeSchemaBoth<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaClass<\n\tName,\n\tKind,\n\tTNode,\n\tTInsertable,\n\tImplicitlyConstructable,\n\tInfo,\n\tTConstructorExtra,\n\tTCustomMetadata\n> &\n\tTreeNodeSchemaNonClass<\n\t\tName,\n\t\tKind,\n\t\tTNode,\n\t\tTInsertable,\n\t\tImplicitlyConstructable,\n\t\tInfo,\n\t\tTConstructorExtra,\n\t\tTCustomMetadata\n\t>;\n\n/**\n * Data common to all tree node schema.\n *\n * @remarks\n * Implementation detail of {@link TreeNodeSchema} which should be accessed instead of referring to this type directly.\n *\n * @privateRemarks\n * All implementations must implement {@link TreeNodeSchemaCorePrivate} as well.\n *\n * @sealed @public\n */\nexport interface TreeNodeSchemaCore<\n\tout Name extends string,\n\tout Kind extends NodeKind,\n\tout ImplicitlyConstructable extends boolean,\n\tout Info = unknown,\n\tout TInsertable = never,\n\tout TCustomMetadata = unknown,\n> extends SimpleNodeSchemaBase<Kind, TCustomMetadata> {\n\t/**\n\t * Unique (within a document's schema) identifier used to associate nodes with their schema.\n\t * @remarks\n\t * This is used when encoding nodes, and when decoding nodes to re-associate them with the schema.\n\t * Since this decoding may happen in a different version of the application (or even a different application altogether),\n\t * this identifier should generally correspond to some specific semantics for the data (how to interpret the node with this identifier).\n\t * Any time the semantics change such that data would be misinterpreted if the old semantics were applied\n\t * (for example the units of a value are changed),\n\t * it is best practice to pick a new identifier.\n\t */\n\treadonly identifier: Name;\n\n\t/**\n\t * Data used to define this schema.\n\t *\n\t * @remarks\n\t * The format depends on the kind of node it is for.\n\t * For example, the \"object\" node kind could store the field schema here.\n\t */\n\treadonly info: Info;\n\n\t/**\n\t * When constructing insertable content,\n\t * data that could be passed to the node's constructor can be used instead of an {@link Unhydrated} node\n\t * iff implicitlyConstructable is true.\n\t * @privateRemarks\n\t * Currently the logic for traversing insertable content,\n\t * both to build trees and to hydrate them does not defer to the schema classes to handle the policy,\n\t * so if their constructors differ from what is supported, some cases will not work.\n\t * Setting this to false adjusts the insertable types to disallow cases which could be impacted by these inconsistencies.\n\t */\n\treadonly implicitlyConstructable: ImplicitlyConstructable;\n\n\t/**\n\t * All possible schema that a direct child of a node with this schema could have.\n\t *\n\t * Equivalently, this is also all schema directly referenced when defining this schema's allowed child types,\n\t * which is also the same as the set of schema referenced directly by the `Info` type parameter and the `info` property.\n\t * This property is simply re-exposing that information in an easier to traverse format consistent across all node kinds.\n\t * @remarks\n\t * Some kinds of nodes may have additional restrictions on children:\n\t * this set simply enumerates all directly referenced schema, and can be use to walk over all referenced schema types.\n\t *\n\t * This set cannot be used before the schema in it have been defined:\n\t * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),\n\t * users must wait until after the schema are defined to access this set.\n\t * @privateRemarks\n\t * Currently there isn't much use for this in the public API,\n\t * and it's possible this will want to be tweaked or renamed as part of a larger schema reflection API surface that might be added later.\n\t * To keep options option, this is marked `@system` for now.\n\t * @system\n\t */\n\treadonly childTypes: ReadonlySet<TreeNodeSchema>;\n\n\t/**\n\t * Constructs an instance of this node type.\n\t * @remarks\n\t * Due to TypeScript limitations, the return type of this method can not be very specific.\n\t * For {@link TreeNodeSchemaClass} prefer using the constructor directly for better typing.\n\t * For {@link TreeNodeSchemaNonClass} use `create`.\n\t *\n\t * @privateRemarks\n\t * This method signature provides a way to infer `TInsertable` without relying on the constructor, and to construct nodes from schema of unknown kind.\n\t * This makes customizations of the constructor not impact the typing of insertable content, allowing customization of the constructor,\n\t * as long as doing so only adds additional supported cases.\n\t *\n\t * This cannot be required to return `TNode`:\n\t * doing so breaks sub-classing of schema since they don't overload this method with a more specific return type.\n\t * @sealed @system\n\t */\n\tcreateFromInsertable(data: TInsertable): Unhydrated<TreeNode | TreeLeafValue>;\n}\n\n/**\n * {@link TreeNodeSchemaCore} extended with some non-exported APIs.\n */\nexport interface TreeNodeSchemaCorePrivate<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTCustomMetadata = unknown,\n> extends TreeNodeSchemaCore<\n\t\tName,\n\t\tKind,\n\t\tImplicitlyConstructable,\n\t\tInfo,\n\t\tTInsertable,\n\t\tTCustomMetadata\n\t> {\n\t/**\n\t * All possible annotated allowed types that a field under a node with this schema could have.\n\t * @remarks\n\t * In this case \"field\" includes anything that is a field in the internal (flex-tree) abstraction layer.\n\t * This includes the content field for arrays, and all the fields for map nodes.\n\t * If this node does not have fields (and thus is a leaf), the array will be empty.\n\t *\n\t * This set cannot be used before the schema in it have been defined:\n\t * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),\n\t * users must wait until after the schema are defined to access this array.\n\t *\n\t * @privateRemarks\n\t * If this is stabilized, it will live alongside the childTypes property on {@link TreeNodeSchemaCore}.\n\t * @system\n\t */\n\treadonly childAnnotatedAllowedTypes: readonly NormalizedAnnotatedAllowedTypes[];\n}\n\n/**\n * Downcasts a {@link TreeNodeSchemaCore} to {@link TreeNodeSchemaCorePrivate} if it is one.\n *\n * @remarks\n * This function should only be used internally. The result should not be exposed publicly\n * in any exported types or API return values.\n */\nexport function asTreeNodeSchemaCorePrivate(\n\tschema: TreeNodeSchemaCore<string, NodeKind, boolean>,\n): TreeNodeSchemaCorePrivate {\n\tassert(\n\t\t\"childAnnotatedAllowedTypes\" in schema,\n\t\t0xbc9 /* All implementations of TreeNodeSchemaCore must also implement TreeNodeSchemaCorePrivate */,\n\t);\n\tassert(\n\t\tArray.isArray((schema as TreeNodeSchemaCorePrivate).childAnnotatedAllowedTypes),\n\t\t0xbca /* All implementations of TreeNodeSchemaCore must also implement TreeNodeSchemaCorePrivate */,\n\t);\n\treturn schema as TreeNodeSchemaCorePrivate;\n}\n\n/**\n * Kind of tree node.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * @public\n */\nexport enum NodeKind {\n\t/**\n\t * A node which serves as a map, storing children under string keys.\n\t */\n\tMap = 0,\n\t/**\n\t * A node which serves as an array, storing children in an ordered sequence.\n\t */\n\tArray = 1,\n\t/**\n\t * A node which stores a heterogenous collection of children in named fields.\n\t * @remarks\n\t * Each field gets its own schema.\n\t */\n\tObject = 2,\n\t/**\n\t * A node which stores a single leaf value.\n\t */\n\tLeaf = 3,\n\t/**\n\t * A node which serves as a record, storing children under string keys.\n\t */\n\tRecord = 4,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"treeNodeSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAwU7D;;GAEG;AACU,QAAA,iBAAiB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAkHvD;;;;;;;;;;;;;;;GAeG;AACH,IAAY,kBAaX;AAbD,WAAY,kBAAkB;IAC7B;;OAEG;IACH,2DAAQ,CAAA;IACR;;OAEG;IACH,yDAAO,CAAA;IACP;;OAEG;IACH,+DAAU,CAAA;AACX,CAAC,EAbW,kBAAkB,kCAAlB,kBAAkB,QAa7B;AAED;;GAEG;AACH,SAAgB,4BAA4B,CAC3C,MAAqD;IAErD,IAAA,iBAAM,EACL,yBAAiB,IAAI,MAAM,EAC3B,KAAK,CAAC,6FAA6F,CACnG,CAAC;IACF,MAAM,WAAW,GAAG,MAAmC,CAAC;IACxD,OAAO,WAAW,CAAC,yBAAiB,CAAC,CAAC;AACvC,CAAC;AATD,oEASC;AAED;;;;;GAKG;AACH,IAAY,QAuBX;AAvBD,WAAY,QAAQ;IACnB;;OAEG;IACH,qCAAO,CAAA;IACP;;OAEG;IACH,yCAAS,CAAA;IACT;;;;OAIG;IACH,2CAAU,CAAA;IACV;;OAEG;IACH,uCAAQ,CAAA;IACR;;OAEG;IACH,2CAAU,CAAA;AACX,CAAC,EAvBW,QAAQ,wBAAR,QAAQ,QAuBnB;AA4BD;;;GAGG;AACH,SAAgB,qBAAqB,CAQpC,MAE2F;IAS3F,OAAO,MAAM,CAAC,WAAW,KAAK,SAAS,CAAC;AACzC,CAAC;AApBD,sDAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\nimport type { SimpleNodeSchemaBase } from \"../simpleSchema.js\";\nimport type { TreeNode } from \"./treeNode.js\";\nimport type { InternalTreeNode, Unhydrated } from \"./types.js\";\nimport type { UnionToIntersection } from \"../../util/index.js\";\nimport type {\n\tImplicitAnnotatedAllowedTypes,\n\tNormalizedAnnotatedAllowedTypes,\n} from \"./allowedTypes.js\";\nimport type { Context } from \"./context.js\";\nimport type { FieldKey, NodeData } from \"../../core/index.js\";\nimport type { UnhydratedFlexTreeField } from \"./unhydratedFlexTree.js\";\nimport type { FactoryContent } from \"../unhydratedFlexTreeFromInsertable.js\";\n\n/**\n * Schema for a {@link TreeNode} or {@link TreeLeafValue}.\n *\n * @typeParam Name - The full (including scope) name/identifier for the schema.\n * @typeParam Kind - Which kind of node this schema is for.\n * @typeParam TNode - API for nodes that use this schema.\n * @typeParam TBuild - Data which can be used to construct an {@link Unhydrated} node of this type.\n * @typeParam Info - Data used when defining this schema.\n * @remarks\n * Captures the schema both as runtime data and compile time type information.\n * Use {@link SchemaFactory} to define schema.\n * Use `Tree.schema(value)` to lookup the schema for a {@link TreeNode} or {@link TreeLeafValue}.\n * @privateRemarks\n * TODO:\n * The long lists of type parameters here are awkward to deal with.\n * Switching to (or adding an option to use)\n * an interface based pattern with unordered named parameters for types like this would be a good idea.\n * The related `@system` types should be simple to port to the new pattern, but stable public one like this will need to support both:\n * the new one could either be added as a system type, or be recommended to replace this one (deprecating it).\n * @sealed @public\n */\nexport type TreeNodeSchema<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTBuild = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTCustomMetadata = unknown,\n> =\n\t| (TNode extends TreeNode\n\t\t\t? TreeNodeSchemaClass<\n\t\t\t\t\tName,\n\t\t\t\t\tKind,\n\t\t\t\t\tTNode,\n\t\t\t\t\tTBuild,\n\t\t\t\t\tImplicitlyConstructable,\n\t\t\t\t\tInfo,\n\t\t\t\t\tnever,\n\t\t\t\t\tTCustomMetadata\n\t\t\t\t>\n\t\t\t: never)\n\t| TreeNodeSchemaNonClass<\n\t\t\tName,\n\t\t\tKind,\n\t\t\tTNode,\n\t\t\tTBuild,\n\t\t\tImplicitlyConstructable,\n\t\t\tInfo,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t >;\n\n/**\n * Schema which is not a class.\n * @remarks\n * This is used for schema which cannot have their instances constructed using constructors, like leaf schema.\n * @privateRemarks\n * Non-class based schema can have issues with recursive types due to https://github.com/microsoft/TypeScript/issues/55832.\n * @system @sealed @public\n */\nexport type TreeNodeSchemaNonClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Also allows InternalTreeNode.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data?: TInsertable | TConstructorExtra): TNode;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Also allows InternalTreeNode.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data: TInsertable | TConstructorExtra): TNode;\n\t\t\t});\n\n/**\n * Tree node schema which is implemented using a class.\n * @remarks\n * Instances of this class are nodes in the tree.\n * This is also a constructor so that it can be subclassed.\n *\n * Using classes in this way allows introducing a named type and a named value at the same time, helping keep the runtime and compile time information together and easy to refer to un a uniform way.\n * Additionally, this works around https://github.com/microsoft/TypeScript/issues/55832 which causes similar patterns with less explicit types to infer \"any\" in the d.ts file.\n *\n * When sub-classing a a `TreeNodeSchemaClass`, some extra rules must be followed:\n *\n * - Only ever use a single class from the schema's class hierarchy within a document and its schema.\n * For example, if using {@link SchemaFactory.object} you can do:\n * ```typescript\n * // Recommended \"customizable\" object schema pattern.\n * class Good extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \tpublic exampleCustomMethod(): void {\n * \t\tthis.exampleField++;\n * \t}\n * }\n * ```\n * But should avoid:\n * ```typescript\n * // This by itself is ok, and opts into \"POJO mode\".\n * const base = schemaFactory.object(\"A\", {});\n * // This is a bad pattern since it leaves two classes in scope which derive from the same SchemaFactory defined class.\n * // If both get used, its an error!\n * class Invalid extends base {}\n * ```\n *\n * - Do not modify the constructor input parameter types or values:\n * ```typescript\n * class Invalid extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \t// This Modifies the type of the constructor input.\n * \t// This is unsupported due to programmatic access to the constructor being used internally.\n * \tpublic constructor(a: number) {\n * \t\tsuper({ exampleField: a });\n * \t}\n * }\n * ```\n * @sealed @public\n */\nexport type TreeNodeSchemaClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data?: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t});\n\n/**\n * Internal helper for utilities that return schema which can be used in class and non class formats depending on the API exposing it.\n */\nexport type TreeNodeSchemaBoth<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaClass<\n\tName,\n\tKind,\n\tTNode,\n\tTInsertable,\n\tImplicitlyConstructable,\n\tInfo,\n\tTConstructorExtra,\n\tTCustomMetadata\n> &\n\tTreeNodeSchemaNonClass<\n\t\tName,\n\t\tKind,\n\t\tTNode,\n\t\tTInsertable,\n\t\tImplicitlyConstructable,\n\t\tInfo,\n\t\tTConstructorExtra,\n\t\tTCustomMetadata\n\t>;\n\n/**\n * Data common to all tree node schema.\n *\n * @remarks\n * Implementation detail of {@link TreeNodeSchema} which should be accessed instead of referring to this type directly.\n *\n * @privateRemarks\n * All implementations must implement {@link TreeNodeSchemaCorePrivate} as well.\n *\n * @sealed @public\n */\nexport interface TreeNodeSchemaCore<\n\tout Name extends string,\n\tout Kind extends NodeKind,\n\tout ImplicitlyConstructable extends boolean,\n\tout Info = unknown,\n\tout TInsertable = never,\n\tout TCustomMetadata = unknown,\n> extends SimpleNodeSchemaBase<Kind, TCustomMetadata> {\n\t/**\n\t * Unique (within a document's schema) identifier used to associate nodes with their schema.\n\t * @remarks\n\t * This is used when encoding nodes, and when decoding nodes to re-associate them with the schema.\n\t * Since this decoding may happen in a different version of the application (or even a different application altogether),\n\t * this identifier should generally correspond to some specific semantics for the data (how to interpret the node with this identifier).\n\t * Any time the semantics change such that data would be misinterpreted if the old semantics were applied\n\t * (for example the units of a value are changed),\n\t * it is best practice to pick a new identifier.\n\t */\n\treadonly identifier: Name;\n\n\t/**\n\t * Data used to define this schema.\n\t *\n\t * @remarks\n\t * The format depends on the kind of node it is for.\n\t * For example, the \"object\" node kind could store the field schema here.\n\t */\n\treadonly info: Info;\n\n\t/**\n\t * When constructing insertable content,\n\t * data that could be passed to the node's constructor can be used instead of an {@link Unhydrated} node\n\t * iff implicitlyConstructable is true.\n\t * @privateRemarks\n\t * Currently the logic for traversing insertable content,\n\t * both to build trees and to hydrate them does not defer to the schema classes to handle the policy,\n\t * so if their constructors differ from what is supported, some cases will not work.\n\t * Setting this to false adjusts the insertable types to disallow cases which could be impacted by these inconsistencies.\n\t */\n\treadonly implicitlyConstructable: ImplicitlyConstructable;\n\n\t/**\n\t * All possible schema that a direct child of a node with this schema could have.\n\t *\n\t * Equivalently, this is also all schema directly referenced when defining this schema's allowed child types,\n\t * which is also the same as the set of schema referenced directly by the `Info` type parameter and the `info` property.\n\t * This property is simply re-exposing that information in an easier to traverse format consistent across all node kinds.\n\t * @remarks\n\t * Some kinds of nodes may have additional restrictions on children:\n\t * this set simply enumerates all directly referenced schema, and can be use to walk over all referenced schema types.\n\t *\n\t * This set cannot be used before the schema in it have been defined:\n\t * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),\n\t * users must wait until after the schema are defined to access this set.\n\t * @privateRemarks\n\t * Currently there isn't much use for this in the public API,\n\t * and it's possible this will want to be tweaked or renamed as part of a larger schema reflection API surface that might be added later.\n\t * To keep options option, this is marked `@system` for now.\n\t * @system\n\t */\n\treadonly childTypes: ReadonlySet<TreeNodeSchema>;\n\n\t/**\n\t * Constructs an instance of this node type.\n\t * @remarks\n\t * Due to TypeScript limitations, the return type of this method can not be very specific.\n\t * For {@link TreeNodeSchemaClass} prefer using the constructor directly for better typing.\n\t * For {@link TreeNodeSchemaNonClass} use `create`.\n\t *\n\t * @privateRemarks\n\t * This method signature provides a way to infer `TInsertable` without relying on the constructor, and to construct nodes from schema of unknown kind.\n\t * This makes customizations of the constructor not impact the typing of insertable content, allowing customization of the constructor,\n\t * as long as doing so only adds additional supported cases.\n\t *\n\t * This cannot be required to return `TNode`:\n\t * doing so breaks sub-classing of schema since they don't overload this method with a more specific return type.\n\t * @sealed @system\n\t */\n\tcreateFromInsertable(data: TInsertable): Unhydrated<TreeNode | TreeLeafValue>;\n}\n\n/**\n * Symbol for use by {@link TreeNodeSchemaCorePrivate}.\n */\nexport const privateDataSymbol = Symbol(\"PrivateData\");\n\n/**\n * {@link TreeNodeSchemaCore} extended with some non-exported APIs.\n */\nexport interface TreeNodeSchemaCorePrivate<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTCustomMetadata = unknown,\n> extends TreeNodeSchemaCore<\n\t\tName,\n\t\tKind,\n\t\tImplicitlyConstructable,\n\t\tInfo,\n\t\tTInsertable,\n\t\tTCustomMetadata\n\t> {\n\t/**\n\t * Package private data provided by all {@link TreeNodeSchema}.\n\t * @remarks\n\t * Users can add custom statics to schema classes.\n\t * To reduce the risk of such statics colliding with properties used to implement the schema,\n\t * some of the private APIs are grouped together under this symbol.\n\t *\n\t * Note that there are still some properties which are not under a symbol and thus expose some risk of name collisions.\n\t * See {@link TreeNodeValid} for some such properties.\n\t */\n\treadonly [privateDataSymbol]: TreeNodeSchemaPrivateData;\n}\n\n/**\n * Package private data provided by all {@link TreeNodeSchema}.\n * @remarks\n * This data needs to be available before lazy schema references are resolved.\n * For data which is only available after lazy schema references are resolved,\n * see {@link TreeNodeSchemaInitializedData}, which can be accessed via {@link TreeNodeSchemaPrivateData.idempotentInitialize}.\n */\nexport interface TreeNodeSchemaPrivateData {\n\t/**\n\t * All possible annotated allowed types that a field under a node with this schema could have.\n\t * @remarks\n\t * In this case \"field\" includes anything that is a field in the internal (flex-tree) abstraction layer.\n\t * This includes the content field for arrays, and all the fields for map nodes.\n\t * If this node does not have fields (and thus is a leaf), the array will be empty.\n\t *\n\t * This set cannot be used before the schema in it have been defined:\n\t * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),\n\t * users must wait until after the schema are defined to access this array.\n\t *\n\t * @privateRemarks\n\t * If this is stabilized, it will live alongside the childTypes property on {@link TreeNodeSchemaCore}.\n\t * @system\n\t */\n\treadonly childAnnotatedAllowedTypes: readonly ImplicitAnnotatedAllowedTypes[];\n\n\t/**\n\t * Idempotent initialization function that pre-caches data and can dereference lazy schema references.\n\t */\n\tidempotentInitialize(): TreeNodeSchemaInitializedData;\n}\n\n/**\n * Additional data about a given schema which is private to this package.\n * @remarks\n * Created by {@link TreeNodeValid.oneTimeSetup} and can involve dereferencing lazy schema references.\n */\nexport interface TreeNodeSchemaInitializedData {\n\t/**\n\t * All possible annotated allowed types that a field under a node with this schema could have.\n\t * @remarks\n\t * In this case \"field\" includes anything that is a field in the internal (flex-tree) abstraction layer.\n\t * This includes the content field for arrays, and all the fields for map nodes.\n\t * If this node does not have fields (and thus is a leaf), the array will be empty.\n\t *\n\t * This set cannot be used before the schema in it have been defined:\n\t * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),\n\t * users must wait until after the schema are defined to access this array.\n\t *\n\t * @privateRemarks\n\t * If this is stabilized, it will live alongside the childTypes property on {@link TreeNodeSchemaCore}.\n\t * @system\n\t */\n\treadonly childAnnotatedAllowedTypes: readonly NormalizedAnnotatedAllowedTypes[];\n\n\t/**\n\t * A {@link Context} which can be used for unhydrated nodes of this schema.\n\t */\n\treadonly context: Context;\n\n\t/**\n\t * Checks if data might be schema-compatible.\n\t *\n\t * @returns false if `data` is incompatible with `type` based on a cheap/shallow check.\n\t *\n\t * Note that this may return true for cases where data is incompatible, but it must not return false in cases where the data is compatible.\n\t */\n\tshallowCompatibilityTest(data: FactoryContent): CompatibilityLevel;\n\n\t/**\n\t * Convert data to a {@link FlexContent} representation.\n\t * @remarks\n\t * Data must be compatible with the schema according to {@link shallowCompatibilityTest}.\n\t *\n\t * TODO: use of `allowedTypes` is for fallbacks (for example NaN -\\> null).\n\t * This behavior should be moved to shallowCompatibilityTest instead.\n\t */\n\ttoFlexContent(data: FactoryContent, allowedTypes: ReadonlySet<TreeNodeSchema>): FlexContent;\n}\n\nexport type FlexContent = [NodeData, Map<FieldKey, UnhydratedFlexTreeField>];\n\n/**\n * Indicates a compatibility level for inferring a schema to apply to insertable data.\n * @remarks\n * Each schema allowed at a location in the tree has its compatibility level checked against the data being inserted.\n * The compatibility is considered unambiguous if there is a single schema with a higher compatibility than all others.\n *\n * This approach allows adding new compatible formats as a non breaking change.\n * If the new format was already compatible with some other schema, it can still be added as non-breaking as long as a lower compatibility level is used.\n * For example, support for constructing maps from record like objects was added in Fluid Framework 2.2.\n * This format (an object with fields) was already compatible with Object nodes at compatibility level Normal so the new format support for maps was added at compatibility level Low.\n * This ensures that existing code that was using object literals as insertable content where both objects and maps were allowed will continue to work,\n * assuming the objects are intended as ObjectNodes.\n * However new code can now be written using record like objects to construct maps, as long as the schema does not also allow Object nodes which are compatible with the data in that location.\n *\n * @see {@link ITreeConfigurationOptions.preventAmbiguity} for a related setting which interacts with this in a somewhat complex way.\n */\nexport enum CompatibilityLevel {\n\t/**\n\t * Not compatible. Constructor typing indicates incompatibility.\n\t */\n\tNone = 0,\n\t/**\n\t * Additional compatibility cases added in Fluid Framework 2.2.\n\t */\n\tLow = 1,\n\t/**\n\t * Compatible in Fluid Framework 2.0.\n\t */\n\tNormal = 2,\n}\n\n/**\n * Downcasts a {@link TreeNodeSchemaCore} to {@link TreeNodeSchemaCorePrivate} and get its {@link TreeNodeSchemaPrivateData}.\n */\nexport function getTreeNodeSchemaPrivateData(\n\tschema: TreeNodeSchemaCore<string, NodeKind, boolean>,\n): TreeNodeSchemaPrivateData {\n\tassert(\n\t\tprivateDataSymbol in schema,\n\t\t0xbc9 /* All implementations of TreeNodeSchemaCore must also implement TreeNodeSchemaCorePrivate */,\n\t);\n\tconst schemaValid = schema as TreeNodeSchemaCorePrivate;\n\treturn schemaValid[privateDataSymbol];\n}\n\n/**\n * Kind of tree node.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * @public\n */\nexport enum NodeKind {\n\t/**\n\t * A node which serves as a map, storing children under string keys.\n\t */\n\tMap = 0,\n\t/**\n\t * A node which serves as an array, storing children in an ordered sequence.\n\t */\n\tArray = 1,\n\t/**\n\t * A node which stores a heterogenous collection of children in named fields.\n\t * @remarks\n\t * Each field gets its own schema.\n\t */\n\tObject = 2,\n\t/**\n\t * A node which stores a single leaf value.\n\t */\n\tLeaf = 3,\n\t/**\n\t * A node which serves as a record, storing children under string keys.\n\t */\n\tRecord = 4,\n}\n\n/**\n * Metadata associated with a Node Schema.\n *\n * @remarks Specified via {@link NodeSchemaOptions.metadata}.\n *\n * @sealed\n * @public\n */\nexport interface NodeSchemaMetadata<out TCustomMetadata = unknown> {\n\t/**\n\t * User-defined metadata.\n\t */\n\treadonly custom?: TCustomMetadata | undefined;\n\n\t/**\n\t * The description of the Node Schema.\n\t *\n\t * @remarks\n\t *\n\t * If provided, will be used by the system in scenarios where a description of the kind of node is useful.\n\t * E.g., when converting a Node Schema to {@link https://json-schema.org/ | JSON Schema}, this description will be\n\t * used as the `description` property.\n\t */\n\treadonly description?: string | undefined;\n}\n\n/**\n * Returns true if the given schema is a {@link TreeNodeSchemaClass}, or otherwise false if it is a {@link TreeNodeSchemaNonClass}.\n * @internal\n */\nexport function isTreeNodeSchemaClass<\n\tName extends string,\n\tKind extends NodeKind,\n\tTNode extends TreeNode | TreeLeafValue,\n\tTBuild,\n\tImplicitlyConstructable extends boolean,\n\tInfo,\n>(\n\tschema:\n\t\t| TreeNodeSchema<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>\n\t\t| TreeNodeSchemaClass<Name, Kind, TNode & TreeNode, TBuild, ImplicitlyConstructable, Info>,\n): schema is TreeNodeSchemaClass<\n\tName,\n\tKind,\n\tTNode & TreeNode,\n\tTBuild,\n\tImplicitlyConstructable,\n\tInfo\n> {\n\treturn schema.constructor !== undefined;\n}\n\n/**\n * Takes in `TreeNodeSchema[]` and returns a TypedNode union.\n * @privateRemarks\n * If a schema is both TreeNodeSchemaClass and TreeNodeSchemaNonClass, prefer TreeNodeSchemaClass since that includes subclasses properly.\n * @public\n */\nexport type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchemaClass<\n\tstring,\n\tNodeKind,\n\tinfer TNode\n>\n\t? TNode\n\t: T extends TreeNodeSchemaNonClass<string, NodeKind, infer TNode>\n\t\t? TNode\n\t\t: never;\n\n/**\n * Data which can be used as a node to be inserted.\n * Either an unhydrated node, or content to build a new node.\n *\n * @see {@link Input}\n *\n * @typeparam TSchemaInput - Schema to process.\n * @typeparam T - Do not specify: default value used as implementation detail.\n * @privateRemarks\n * This can't really be fully correct, since TreeNodeSchema's TNode is generally use covariantly but this code uses it contravariantly.\n * That makes this TreeNodeSchema actually invariant with respect to TNode, but doing that would break all `extends TreeNodeSchema` clauses.\n * As is, this works correctly in most realistic use-cases.\n *\n * One special case this makes is if the result of NodeFromSchema contains TreeNode, this must be an under constrained schema, so the result is set to never.\n * Note that applying UnionToIntersection on the result of NodeFromSchema<T> does not work since it breaks booleans.\n *\n * @public\n */\nexport type InsertableTypedNode<\n\tTSchema extends TreeNodeSchema,\n\tT = UnionToIntersection<TSchema>,\n> =\n\t| (T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, never, true>\n\t\t\t? NodeBuilderData<T>\n\t\t\t: never)\n\t| (T extends TreeNodeSchema\n\t\t\t? Unhydrated<TreeNode extends NodeFromSchema<T> ? never : NodeFromSchema<T>>\n\t\t\t: never);\n\n/**\n * Given a node's schema, return the corresponding object from which the node could be built.\n * @privateRemarks\n * This uses TreeNodeSchemaCore, and thus depends on TreeNodeSchemaCore.createFromInsertable for the typing.\n * This works almost the same as using TreeNodeSchema,\n * except that the more complex typing in TreeNodeSchema case breaks for non-class schema and leaks in `undefined` from optional crete parameters.\n * @system @public\n */\nexport type NodeBuilderData<T extends TreeNodeSchemaCore<string, NodeKind, boolean>> =\n\tT extends TreeNodeSchemaCore<string, NodeKind, boolean, unknown, infer TBuild>\n\t\t? TBuild\n\t\t: never;\n\n/**\n * Value that may be stored as a leaf node.\n * @remarks\n * Some limitations apply, see the documentation for {@link SchemaStatics.number} and {@link SchemaStatics.string} for those restrictions.\n * @public\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport type TreeLeafValue = number | string | boolean | IFluidHandle | null;\n"]}
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { type FlexTreeNode } from "
|
|
6
|
-
import {
|
|
5
|
+
import { type FlexTreeNode } from "../../feature-libraries/index.js";
|
|
6
|
+
import { TreeNode } from "./treeNode.js";
|
|
7
|
+
import type { UnhydratedFlexTreeNode } from "./unhydratedFlexTree.js";
|
|
8
|
+
import { NodeKind, type TreeNodeSchema, type TreeNodeSchemaCore, type TreeNodeSchemaInitializedData, type TreeNodeSchemaPrivateData } from "./treeNodeSchema.js";
|
|
9
|
+
import type { InternalTreeNode } from "./types.js";
|
|
10
|
+
import type { ImplicitAnnotatedAllowedTypes } from "./allowedTypes.js";
|
|
7
11
|
/**
|
|
8
12
|
* Class which all {@link TreeNode}s must extend.
|
|
9
13
|
* Since this is not exported, it allows robust detection of attempts to create TreeNodes which do not go through SchemaFactory which is the only place which exposes classes that extend this.
|
|
@@ -32,7 +36,7 @@ export declare abstract class TreeNodeValid<TInput> extends TreeNode {
|
|
|
32
36
|
* @remarks
|
|
33
37
|
* It is valid to dereference LazyItem schema references in this function (or anything that runs after it).
|
|
34
38
|
*/
|
|
35
|
-
protected static oneTimeSetup<T>(this: typeof TreeNodeValid<T>):
|
|
39
|
+
protected static oneTimeSetup<T>(this: typeof TreeNodeValid<T>): TreeNodeSchemaInitializedData;
|
|
36
40
|
/**
|
|
37
41
|
* The most derived constructor (the one invoked with the `new` operator, not a parent class constructor invoked with as `super`) used to construct an instance of this type.
|
|
38
42
|
* @remarks
|
|
@@ -87,6 +91,16 @@ export declare abstract class TreeNodeValid<TInput> extends TreeNode {
|
|
|
87
91
|
*/
|
|
88
92
|
export interface MostDerivedData {
|
|
89
93
|
readonly constructor: typeof TreeNodeValid & TreeNodeSchema;
|
|
90
|
-
oneTimeInitialized?:
|
|
94
|
+
oneTimeInitialized?: TreeNodeSchemaInitializedData;
|
|
91
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Cast `schema` to a {@link TreeNodeValid}, asserting it actually extends it.
|
|
98
|
+
*/
|
|
99
|
+
export declare function schemaAsTreeNodeValid(schema: TreeNodeSchemaCore<string, NodeKind, boolean>): typeof TreeNodeValid & TreeNodeSchema;
|
|
100
|
+
/**
|
|
101
|
+
* Provides the {@link TreeNodeSchemaPrivateData} for class based implementations of {@link asTreeNodeSchemaCorePrivate}.
|
|
102
|
+
* @remarks
|
|
103
|
+
* Such schema must extends {@link TreeNodeValid}.
|
|
104
|
+
*/
|
|
105
|
+
export declare function createTreeNodeSchemaPrivateData(schema: TreeNodeSchemaCore<string, NodeKind, boolean>, childAnnotatedAllowedTypes: readonly ImplicitAnnotatedAllowedTypes[]): TreeNodeSchemaPrivateData;
|
|
92
106
|
//# sourceMappingURL=treeNodeValid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeNodeValid.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeValid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,kCAAkC,CAAC;AAGrF,OAAO,EAAkC,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACN,QAAQ,EACR,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EAClC,KAAK,yBAAyB,EAC9B,MAAM,qBAAqB,CAAC;AAO7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE;;;;;;;GAOG;AACH,8BAAsB,aAAa,CAAC,MAA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