@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
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.comparePosetElements = exports.PosetComparisonResult = exports.fieldRealizer = exports.findExtraAllowedTypes = exports.getAllowedContentDiscrepancies = void 0;
|
|
8
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
+
const index_js_1 = require("../core/index.js");
|
|
10
|
+
const index_js_2 = require("../util/index.js");
|
|
11
|
+
const index_js_3 = require("./core/index.js");
|
|
12
|
+
const index_js_4 = require("./node-kinds/index.js");
|
|
13
|
+
const toStoredSchema_js_1 = require("./toStoredSchema.js");
|
|
14
|
+
const walkFieldSchema_js_1 = require("./walkFieldSchema.js");
|
|
15
|
+
const fieldSchema_js_1 = require("./fieldSchema.js");
|
|
16
|
+
const leafNodeSchema_js_1 = require("./leafNodeSchema.js");
|
|
17
|
+
function getStoredNodeSchemaType(nodeSchema) {
|
|
18
|
+
if (nodeSchema instanceof index_js_1.ObjectNodeStoredSchema) {
|
|
19
|
+
return index_js_1.ObjectNodeStoredSchema;
|
|
20
|
+
}
|
|
21
|
+
if (nodeSchema instanceof index_js_1.MapNodeStoredSchema) {
|
|
22
|
+
return index_js_1.MapNodeStoredSchema;
|
|
23
|
+
}
|
|
24
|
+
if (nodeSchema instanceof index_js_1.LeafNodeStoredSchema) {
|
|
25
|
+
return index_js_1.LeafNodeStoredSchema;
|
|
26
|
+
}
|
|
27
|
+
(0, internal_1.fail)(0xbe8 /* Invalid stored node schema type */);
|
|
28
|
+
}
|
|
29
|
+
function doesNodeKindMatchStoredNodeKind(viewKind, storedType) {
|
|
30
|
+
switch (viewKind) {
|
|
31
|
+
case index_js_3.NodeKind.Leaf:
|
|
32
|
+
return storedType === index_js_1.LeafNodeStoredSchema;
|
|
33
|
+
case index_js_3.NodeKind.Array:
|
|
34
|
+
case index_js_3.NodeKind.Object:
|
|
35
|
+
return storedType === index_js_1.ObjectNodeStoredSchema;
|
|
36
|
+
case index_js_3.NodeKind.Map:
|
|
37
|
+
case index_js_3.NodeKind.Record:
|
|
38
|
+
return storedType === index_js_1.MapNodeStoredSchema;
|
|
39
|
+
default:
|
|
40
|
+
(0, internal_1.unreachableCase)(viewKind);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function getViewNodeSchemaType(schema) {
|
|
44
|
+
switch (schema.kind) {
|
|
45
|
+
case index_js_3.NodeKind.Leaf: {
|
|
46
|
+
return index_js_1.LeafNodeStoredSchema;
|
|
47
|
+
}
|
|
48
|
+
case index_js_3.NodeKind.Map:
|
|
49
|
+
case index_js_3.NodeKind.Record: {
|
|
50
|
+
return index_js_1.MapNodeStoredSchema;
|
|
51
|
+
}
|
|
52
|
+
case index_js_3.NodeKind.Object:
|
|
53
|
+
case index_js_3.NodeKind.Array: {
|
|
54
|
+
return index_js_1.ObjectNodeStoredSchema;
|
|
55
|
+
}
|
|
56
|
+
default:
|
|
57
|
+
(0, internal_1.unreachableCase)(schema.kind);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Finds and reports discrepancies between a view schema and a stored schema.
|
|
62
|
+
*
|
|
63
|
+
* See documentation on {@link Discrepancy} for details of possible discrepancies.
|
|
64
|
+
* @remarks
|
|
65
|
+
* This function does not attempt to distinguish between equivalent representations of a node/field involving extraneous never trees.
|
|
66
|
+
* For example, a Forbidden field with allowed type set `[]` is equivalent to an optional field with allowed type set `[]`,
|
|
67
|
+
* as well as an optional field with an allowed type set containing only unconstructable types.
|
|
68
|
+
*
|
|
69
|
+
* It is up to the caller to determine whether such discrepancies matter.
|
|
70
|
+
*/
|
|
71
|
+
function* getAllowedContentDiscrepancies(view, stored) {
|
|
72
|
+
// check root schema discrepancies
|
|
73
|
+
yield* getFieldDiscrepancies(view, stored.rootFieldSchema, undefined, undefined);
|
|
74
|
+
const viewNodeSchema = new Map();
|
|
75
|
+
(0, walkFieldSchema_js_1.walkFieldSchema)(view, {
|
|
76
|
+
node: (schema) => {
|
|
77
|
+
const identifier = (0, index_js_2.brand)(schema.identifier);
|
|
78
|
+
(0, internal_1.debugAssert)(() => !viewNodeSchema.has(identifier));
|
|
79
|
+
viewNodeSchema.set(identifier, schema);
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
for (const [identifier, viewSchema] of viewNodeSchema) {
|
|
83
|
+
const storedSchema = stored.nodeSchema.get(identifier);
|
|
84
|
+
// if the view schema has a node that's not in the stored schema
|
|
85
|
+
if (storedSchema === undefined) {
|
|
86
|
+
const viewType = getViewNodeSchemaType(viewSchema);
|
|
87
|
+
// TODO does it make sense to have this mismatch when there will also be an allowedTypes mismatch?
|
|
88
|
+
yield {
|
|
89
|
+
identifier,
|
|
90
|
+
mismatch: "nodeKind",
|
|
91
|
+
view: viewType,
|
|
92
|
+
stored: undefined,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
yield* getNodeDiscrepancies(identifier, viewSchema, storedSchema);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const [identifier, storedSchema] of stored.nodeSchema) {
|
|
100
|
+
if (!viewNodeSchema.has(identifier)) {
|
|
101
|
+
const storedType = getStoredNodeSchemaType(storedSchema);
|
|
102
|
+
yield {
|
|
103
|
+
identifier,
|
|
104
|
+
mismatch: "nodeKind",
|
|
105
|
+
view: undefined,
|
|
106
|
+
stored: storedType,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.getAllowedContentDiscrepancies = getAllowedContentDiscrepancies;
|
|
112
|
+
function* getNodeDiscrepancies(identifier, view, stored) {
|
|
113
|
+
if (!doesNodeKindMatchStoredNodeKind(view.kind, getStoredNodeSchemaType(stored))) {
|
|
114
|
+
yield {
|
|
115
|
+
identifier,
|
|
116
|
+
mismatch: "nodeKind",
|
|
117
|
+
view: getViewNodeSchemaType(view),
|
|
118
|
+
stored: getStoredNodeSchemaType(stored),
|
|
119
|
+
};
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
switch (view.kind) {
|
|
123
|
+
case index_js_3.NodeKind.Object: {
|
|
124
|
+
(0, internal_1.assert)((0, index_js_4.isObjectNodeSchema)(view), 0xbe9 /* schema with node kind of object must implement ObjectNodeSchema */);
|
|
125
|
+
const fields = view.flexKeyMap;
|
|
126
|
+
const differences = Array.from(computeObjectNodeDiscrepancies(identifier, fields, stored));
|
|
127
|
+
if (differences.length > 0) {
|
|
128
|
+
yield {
|
|
129
|
+
identifier,
|
|
130
|
+
mismatch: "fields",
|
|
131
|
+
differences,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case index_js_3.NodeKind.Array: {
|
|
137
|
+
(0, internal_1.assert)((0, index_js_4.isArrayNodeSchema)(view), 0xbea /* schema with node kind of array must implement ArrayNodeSchema */);
|
|
138
|
+
const fields = new Map([
|
|
139
|
+
[
|
|
140
|
+
index_js_1.EmptyKey,
|
|
141
|
+
{
|
|
142
|
+
storedKey: index_js_1.EmptyKey,
|
|
143
|
+
schema: (0, fieldSchema_js_1.createFieldSchema)(fieldSchema_js_1.FieldKind.Optional, view.info),
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
]);
|
|
147
|
+
const differences = Array.from(computeObjectNodeDiscrepancies(identifier, fields, stored, true));
|
|
148
|
+
if (differences.length > 0) {
|
|
149
|
+
yield {
|
|
150
|
+
identifier,
|
|
151
|
+
mismatch: "fields",
|
|
152
|
+
differences,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
case index_js_3.NodeKind.Map: {
|
|
158
|
+
(0, internal_1.assert)((0, index_js_4.isMapNodeSchema)(view), 0xbeb /* schema with node kind of map must implement MapNodeSchema */);
|
|
159
|
+
yield* getFieldDiscrepancies((0, fieldSchema_js_1.createFieldSchema)(fieldSchema_js_1.FieldKind.Optional, view.info), stored.mapFields, identifier, undefined);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case index_js_3.NodeKind.Record: {
|
|
163
|
+
(0, internal_1.assert)((0, index_js_4.isRecordNodeSchema)(view), 0xbec /* schema with node kind of record must implement RecordNodeSchema */);
|
|
164
|
+
yield* getFieldDiscrepancies((0, fieldSchema_js_1.createFieldSchema)(fieldSchema_js_1.FieldKind.Optional, view.info), stored.mapFields, identifier, undefined);
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case index_js_3.NodeKind.Leaf: {
|
|
168
|
+
(0, internal_1.assert)(view instanceof leafNodeSchema_js_1.LeafNodeSchema, 0xbed /* schema with node kind of leaf must implement LeafNodeSchema */);
|
|
169
|
+
// TODO: leafKind seems like a bad name
|
|
170
|
+
const viewValue = view.leafKind;
|
|
171
|
+
const storedValue = stored.leafValue;
|
|
172
|
+
if (viewValue !== storedValue) {
|
|
173
|
+
yield {
|
|
174
|
+
identifier,
|
|
175
|
+
mismatch: "valueSchema",
|
|
176
|
+
view: viewValue,
|
|
177
|
+
stored: storedValue,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
default:
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Returns the allowed types that are not present in both the given view and stored schemas.
|
|
188
|
+
* It returns a tuple containing two arrays:
|
|
189
|
+
* 1. The first array contains the allowed types that are present in the view schema but not in the stored schema.
|
|
190
|
+
* 2. The second array contains the allowed types that are present in the stored schema but not in the view schema.
|
|
191
|
+
*/
|
|
192
|
+
function findExtraAllowedTypes(viewAllowedTypes, storedAllowedTypes) {
|
|
193
|
+
const viewNodeSchemaIdentifiers = new Set(viewAllowedTypes.map((value) => value.type.identifier));
|
|
194
|
+
const viewExtraneousAllowedTypes = [...viewAllowedTypes].filter((value) => !storedAllowedTypes.has((0, index_js_2.brand)(value.type.identifier)));
|
|
195
|
+
const storedExtraneousAllowedTypes = [...storedAllowedTypes].filter((value) => !viewNodeSchemaIdentifiers.has(value));
|
|
196
|
+
return [viewExtraneousAllowedTypes, storedExtraneousAllowedTypes];
|
|
197
|
+
}
|
|
198
|
+
exports.findExtraAllowedTypes = findExtraAllowedTypes;
|
|
199
|
+
/**
|
|
200
|
+
* The function to track the discrepancies between a field view schema and a stored schema.
|
|
201
|
+
*
|
|
202
|
+
* @remarks
|
|
203
|
+
* This function yields discrepancies in the following cases:
|
|
204
|
+
* 1. If the view schema has allowed types that are not present in the stored schema.
|
|
205
|
+
* 2. If the stored schema has allowed types that are not present in the view schema.
|
|
206
|
+
* 3. If the field kind in the view schema is not compatible with the stored schema.
|
|
207
|
+
*
|
|
208
|
+
* This function does not recurse into the nodes of the view schema and only makes comparisons at the field level.
|
|
209
|
+
*
|
|
210
|
+
* @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.
|
|
211
|
+
*/
|
|
212
|
+
function* getFieldDiscrepancies(view, stored, identifier, fieldKey,
|
|
213
|
+
// TODO: This is a temporary workaround until the comparison logic is redesigned.
|
|
214
|
+
viewKindIsSequence = false) {
|
|
215
|
+
(0, internal_1.assert)(view instanceof fieldSchema_js_1.FieldSchemaAlpha, 0xbee /* all field schema should be FieldSchemaAlpha */);
|
|
216
|
+
const [viewExtra, storedExtra] = findExtraAllowedTypes(view.annotatedAllowedTypesNormalized.types, stored.types);
|
|
217
|
+
if (viewExtra.length > 0 || storedExtra.length > 0) {
|
|
218
|
+
yield {
|
|
219
|
+
identifier,
|
|
220
|
+
fieldKey,
|
|
221
|
+
mismatch: "allowedTypes",
|
|
222
|
+
view: viewExtra,
|
|
223
|
+
stored: storedExtra,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
const viewKind = toStoredSchema_js_1.convertFieldKind.get(view.kind) ??
|
|
227
|
+
(0, internal_1.fail)(0xbef /* A conversion from a FieldKind to a FlexFieldKind should exist */);
|
|
228
|
+
// This checks if the field kind in the view schema is not compatible with the stored schema.
|
|
229
|
+
// We cannot detect if the view schema is a sequence using the kind property so it is passed in separately.
|
|
230
|
+
if ((viewKindIsSequence && stored.kind !== "Sequence") ||
|
|
231
|
+
(!viewKindIsSequence && viewKind.identifier !== stored.kind)) {
|
|
232
|
+
yield {
|
|
233
|
+
identifier,
|
|
234
|
+
fieldKey,
|
|
235
|
+
mismatch: "fieldKind",
|
|
236
|
+
view: viewKind.identifier,
|
|
237
|
+
stored: stored.kind,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Computes discrepancies between a view schema and a stored schema for nodes that are treated as object nodes in the stored schema.
|
|
243
|
+
* This includes both view object nodes and view array nodes.
|
|
244
|
+
*
|
|
245
|
+
* This function yields discrepancies in the following cases:
|
|
246
|
+
*
|
|
247
|
+
* 1. If the view schema has fields that are not present in the stored schema.
|
|
248
|
+
* 2. If the stored schema has fields that are not present in the view schema.
|
|
249
|
+
* 3. If the field kind or allowed types of a field in the view schema is not compatible with the stored schema.
|
|
250
|
+
*
|
|
251
|
+
* This function includes discrepancies within the common fields and their allowed types, but does NOT recurse to report and discrepancies within the node types referenced by those fields.
|
|
252
|
+
*/
|
|
253
|
+
function* computeObjectNodeDiscrepancies(identifier, view, stored, viewKindIsSequence = false) {
|
|
254
|
+
/**
|
|
255
|
+
* Similar to the logic used for tracking discrepancies between two node schemas, we will identify
|
|
256
|
+
* three types of differences:
|
|
257
|
+
* 1. Fields that exist in the view schema but not in the stored schema.
|
|
258
|
+
* 2. Fields that exist in both schemas but have different contents.
|
|
259
|
+
* 3. Fields that exist in the stored schema but not in the view schema.
|
|
260
|
+
*
|
|
261
|
+
* First, the view schema is iterated to track the first two types of differences.
|
|
262
|
+
* Then, the stored schema is iterated to find the third type.
|
|
263
|
+
*/
|
|
264
|
+
const viewKeys = new Set();
|
|
265
|
+
for (const [_, { storedKey: fieldKey, schema: fieldSchema }] of view) {
|
|
266
|
+
const storedSchema = stored.objectNodeFields.get(fieldKey);
|
|
267
|
+
viewKeys.add(fieldKey);
|
|
268
|
+
// If the view schema has a field that's not in the stored schema
|
|
269
|
+
if (storedSchema === undefined) {
|
|
270
|
+
const viewKind = toStoredSchema_js_1.convertFieldKind.get(fieldSchema.kind) ??
|
|
271
|
+
(0, internal_1.fail)(0xbf0 /* A conversion from a FieldKind to a FlexFieldKind should exist */);
|
|
272
|
+
yield {
|
|
273
|
+
identifier,
|
|
274
|
+
fieldKey,
|
|
275
|
+
mismatch: "fieldKind",
|
|
276
|
+
view: viewKind.identifier,
|
|
277
|
+
stored: index_js_1.storedEmptyFieldSchema.kind,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
yield* getFieldDiscrepancies(fieldSchema, storedSchema, identifier, fieldKey, viewKindIsSequence);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
for (const [fieldKey, schema] of stored.objectNodeFields) {
|
|
285
|
+
// If the stored schema has a field that's not in the view schema
|
|
286
|
+
if (!viewKeys.has(fieldKey)) {
|
|
287
|
+
if (schema.kind === index_js_1.forbiddenFieldKindIdentifier) {
|
|
288
|
+
// In the stored schema the field is explicitly forbidden.
|
|
289
|
+
// This has the same semantics of the field not being mentioned in the stored schema,
|
|
290
|
+
// and thus is compatible with the view schema which does not mention this field.
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
yield {
|
|
294
|
+
identifier,
|
|
295
|
+
fieldKey,
|
|
296
|
+
mismatch: "fieldKind",
|
|
297
|
+
view: index_js_1.storedEmptyFieldSchema.kind,
|
|
298
|
+
stored: schema.kind,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* @privateRemarks
|
|
305
|
+
* TODO: Knowledge of specific field kinds is not appropriate for modular schema.
|
|
306
|
+
* This bit of field comparison should be dependency injected by default-schema if this comparison logic remains in modular-schema
|
|
307
|
+
* (this is analogous to what is done in comparison.ts).
|
|
308
|
+
*/
|
|
309
|
+
const FieldKindIdentifiers = {
|
|
310
|
+
forbidden: (0, index_js_2.brand)("Forbidden"),
|
|
311
|
+
required: (0, index_js_2.brand)("Value"),
|
|
312
|
+
identifier: (0, index_js_2.brand)("Identifier"),
|
|
313
|
+
optional: (0, index_js_2.brand)("Optional"),
|
|
314
|
+
sequence: (0, index_js_2.brand)("Sequence"),
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* A realizer for the partial order of field kind relaxability.
|
|
318
|
+
*
|
|
319
|
+
* It seems extremely likely that this partial order will remain dimension 2 over time (i.e. the set of allowed relaxations can be visualized
|
|
320
|
+
* with a [dominance drawing](https://en.wikipedia.org/wiki/Dominance_drawing)), so this strategy allows efficient comarison between field kinds
|
|
321
|
+
* without excessive casework.
|
|
322
|
+
*
|
|
323
|
+
* Hasse diagram for the partial order is shown below (lower fields can be relaxed to higher fields):
|
|
324
|
+
* ```
|
|
325
|
+
* sequence
|
|
326
|
+
* |
|
|
327
|
+
* optional
|
|
328
|
+
* | \
|
|
329
|
+
* required forbidden
|
|
330
|
+
* |
|
|
331
|
+
* identifier
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
exports.fieldRealizer = [
|
|
335
|
+
[
|
|
336
|
+
FieldKindIdentifiers.forbidden,
|
|
337
|
+
FieldKindIdentifiers.identifier,
|
|
338
|
+
FieldKindIdentifiers.required,
|
|
339
|
+
FieldKindIdentifiers.optional,
|
|
340
|
+
FieldKindIdentifiers.sequence,
|
|
341
|
+
],
|
|
342
|
+
[
|
|
343
|
+
FieldKindIdentifiers.identifier,
|
|
344
|
+
FieldKindIdentifiers.required,
|
|
345
|
+
FieldKindIdentifiers.forbidden,
|
|
346
|
+
FieldKindIdentifiers.optional,
|
|
347
|
+
FieldKindIdentifiers.sequence,
|
|
348
|
+
],
|
|
349
|
+
].map((extension) => new Map(extension.map((identifier, index) => [identifier, index])));
|
|
350
|
+
exports.PosetComparisonResult = {
|
|
351
|
+
Less: "<",
|
|
352
|
+
Greater: ">",
|
|
353
|
+
Equal: "=",
|
|
354
|
+
Incomparable: "||",
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* TODO: This is used by SchemaCompatibilityTester, revisit it during redesign and document
|
|
358
|
+
*/
|
|
359
|
+
function comparePosetElements(a, b, realizer) {
|
|
360
|
+
let hasLessThanResult = false;
|
|
361
|
+
let hasGreaterThanResult = false;
|
|
362
|
+
for (const extension of realizer) {
|
|
363
|
+
const aIndex = extension.get(a);
|
|
364
|
+
const bIndex = extension.get(b);
|
|
365
|
+
(0, internal_1.assert)(aIndex !== undefined && bIndex !== undefined, 0xbf1 /* Invalid realizer */);
|
|
366
|
+
if (aIndex < bIndex) {
|
|
367
|
+
hasLessThanResult = true;
|
|
368
|
+
}
|
|
369
|
+
else if (aIndex > bIndex) {
|
|
370
|
+
hasGreaterThanResult = true;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return hasLessThanResult
|
|
374
|
+
? hasGreaterThanResult
|
|
375
|
+
? exports.PosetComparisonResult.Incomparable
|
|
376
|
+
: exports.PosetComparisonResult.Less
|
|
377
|
+
: hasGreaterThanResult
|
|
378
|
+
? exports.PosetComparisonResult.Greater
|
|
379
|
+
: exports.PosetComparisonResult.Equal;
|
|
380
|
+
}
|
|
381
|
+
exports.comparePosetElements = comparePosetElements;
|
|
382
|
+
//# sourceMappingURL=discrepancies.js.map
|
|
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C;AAIX;;GAEG;AACH,SAAgB,oBAAoB,CACnC,CAAI,EACJ,CAAI,EACJ,QAAqB;IAErB,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAC9B,IAAI,oBAAoB,GAAG,KAAK,CAAC;IACjC,KAAK,MAAM,SAAS,IAAI,QAAQ,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChC,IAAA,iBAAM,EAAC,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACnF,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;YACrB,iBAAiB,GAAG,IAAI,CAAC;QAC1B,CAAC;aAAM,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;YAC5B,oBAAoB,GAAG,IAAI,CAAC;QAC7B,CAAC;IACF,CAAC;IAED,OAAO,iBAAiB;QACvB,CAAC,CAAC,oBAAoB;YACrB,CAAC,CAAC,6BAAqB,CAAC,YAAY;YACpC,CAAC,CAAC,6BAAqB,CAAC,IAAI;QAC7B,CAAC,CAAC,oBAAoB;YACrB,CAAC,CAAC,6BAAqB,CAAC,OAAO;YAC/B,CAAC,CAAC,6BAAqB,CAAC,KAAK,CAAC;AACjC,CAAC;AAzBD,oDAyBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tdebugAssert,\n\tfail,\n\tunreachableCase,\n} from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tEmptyKey,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\tforbiddenFieldKindIdentifier,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tstoredEmptyFieldSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n\ttype ValueSchema,\n} from \"../core/index.js\";\nimport { brand } from \"../util/index.js\";\nimport { NodeKind, type AnnotatedAllowedType, type TreeNodeSchema } from \"./core/index.js\";\nimport {\n\tisArrayNodeSchema,\n\tisMapNodeSchema,\n\tisObjectNodeSchema,\n\tisRecordNodeSchema,\n\ttype SimpleKeyMap,\n} from \"./node-kinds/index.js\";\nimport { convertFieldKind } from \"./toStoredSchema.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\nimport {\n\tcreateFieldSchema,\n\tFieldKind,\n\tFieldSchemaAlpha,\n\ttype FieldSchema,\n} from \"./fieldSchema.js\";\nimport { LeafNodeSchema } from \"./leafNodeSchema.js\";\n\n/**\n * Discriminated union (keyed on `mismatch`) of discrepancies between a view and stored schema.\n * @remarks\n *\n * 1. FieldDiscrepancy\n *\n * `FieldDiscrepancy` represents the differences between two `TreeFieldStoredSchema` objects. It consists of\n * three types of incompatibilities:\n *\n * - FieldKindDiscrepancy: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`\n * objects (e.g., optional, required, sequence, etc.).\n * - AllowedTypesDiscrepancy: Indicates the differences in the allowed child types between the two schemas.\n * - ValueSchemaDiscrepancy: Specifically indicates the differences in the `ValueSchema` of two\n * `LeafNodeStoredSchema` objects.\n *\n * 2. NodeDiscrepancy\n *\n * `NodeDiscrepancy` represents the differences between two `TreeNodeStoredSchema` objects and includes:\n *\n * - NodeKindDiscrepancy: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports\n * `ObjectNodeStoredSchema`, `MapNodeStoredSchema`, and `LeafNodeStoredSchema`).\n * - NodeFieldsDiscrepancy: Indicates the `FieldDiscrepancy` of `TreeFieldStoredSchema` within two\n * `TreeNodeStoredSchema`. It includes an array of `FieldDiscrepancy` instances in the `differences` field.\n *\n * When comparing two nodes for compatibility, it only makes sense to compare their fields if the nodes are of\n * the same kind (map, object, leaf).\n *\n * 3. Discrepancy\n *\n * Discrepancy consists of both `NodeDiscrepancy` and `FieldDiscrepancy`, representing any kind of\n * schema differences. See {@link getAllowedContentDiscrepancies} for more details about how we process it\n * and the ordering.\n */\nexport type Discrepancy = FieldDiscrepancy | NodeDiscrepancy;\n\nexport type NodeDiscrepancy = NodeKindDiscrepancy | NodeFieldsDiscrepancy;\n\n/**\n * A discrepancy in the declaration of a field.\n */\nexport type FieldDiscrepancy =\n\t| AllowedTypeDiscrepancy\n\t| FieldKindDiscrepancy\n\t| ValueSchemaDiscrepancy;\n\n/**\n * Information about where a field discrepancy is located within a collection of schema.\n */\nexport interface FieldDiscrepancyLocation {\n\t/**\n\t * The {@link TreeNodeSchemaIdentifier} that contains the discrepancy.\n\t *\n\t * Undefined iff the discrepancy is part of the root field schema.\n\t */\n\treadonly identifier: TreeNodeSchemaIdentifier | undefined;\n\t/**\n\t * The {@link FieldKey} for the field that contains the discrepancy.\n\t * Undefined when:\n\t * - the discrepancy is part of the root field schema\n\t * - the discrepancy is for 'all fields' of a map node\n\t */\n\treadonly fieldKey: FieldKey | undefined;\n}\n\n/**\n * A discrepancy in the allowed types of a field.\n *\n * @remarks\n * This reports the symmetric difference of allowed types in view/stored to enable more efficient checks for compatibility\n */\nexport interface AllowedTypeDiscrepancy extends FieldDiscrepancyLocation {\n\treadonly mismatch: \"allowedTypes\";\n\t/**\n\t * List of annotated allowed types in viewed schema which are not allowed in stored schema\n\t */\n\treadonly view: readonly AnnotatedAllowedType<TreeNodeSchema>[];\n\t/**\n\t * List of allowed type identifiers in stored schema which are not allowed in view schema\n\t */\n\treadonly stored: readonly TreeNodeSchemaIdentifier[];\n}\n\nexport interface FieldKindDiscrepancy extends FieldDiscrepancyLocation {\n\treadonly mismatch: \"fieldKind\";\n\treadonly view: FieldKindIdentifier;\n\treadonly stored: FieldKindIdentifier;\n}\n\nexport interface ValueSchemaDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"valueSchema\";\n\tview: ValueSchema | undefined;\n\tstored: ValueSchema | undefined;\n}\n\nexport interface NodeKindDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"nodeKind\";\n\tview: SchemaFactoryNodeKind | undefined;\n\tstored: SchemaFactoryNodeKind | undefined;\n}\n\nexport interface NodeFieldsDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"fields\";\n\tdifferences: FieldDiscrepancy[];\n}\n\ntype SchemaFactoryNodeKind =\n\t| typeof ObjectNodeStoredSchema\n\t| typeof MapNodeStoredSchema\n\t| typeof LeafNodeStoredSchema;\n\nfunction getStoredNodeSchemaType(nodeSchema: TreeNodeStoredSchema): SchemaFactoryNodeKind {\n\tif (nodeSchema instanceof ObjectNodeStoredSchema) {\n\t\treturn ObjectNodeStoredSchema;\n\t}\n\tif (nodeSchema instanceof MapNodeStoredSchema) {\n\t\treturn MapNodeStoredSchema;\n\t}\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\treturn LeafNodeStoredSchema;\n\t}\n\tfail(0xbe8 /* Invalid stored node schema type */);\n}\n\nfunction doesNodeKindMatchStoredNodeKind(\n\tviewKind: NodeKind,\n\tstoredType: SchemaFactoryNodeKind,\n): boolean {\n\tswitch (viewKind) {\n\t\tcase NodeKind.Leaf:\n\t\t\treturn storedType === LeafNodeStoredSchema;\n\t\tcase NodeKind.Array:\n\t\tcase NodeKind.Object:\n\t\t\treturn storedType === ObjectNodeStoredSchema;\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record:\n\t\t\treturn storedType === MapNodeStoredSchema;\n\t\tdefault:\n\t\t\tunreachableCase(viewKind);\n\t}\n}\n\nfunction getViewNodeSchemaType(schema: TreeNodeSchema): SchemaFactoryNodeKind {\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn LeafNodeStoredSchema;\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\treturn MapNodeStoredSchema;\n\t\t}\n\t\tcase NodeKind.Object:\n\t\tcase NodeKind.Array: {\n\t\t\treturn ObjectNodeStoredSchema;\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(schema.kind);\n\t}\n}\n\n/**\n * Finds and reports discrepancies between a view schema and a stored schema.\n *\n * See documentation on {@link Discrepancy} for details of possible discrepancies.\n * @remarks\n * This function does not attempt to distinguish between equivalent representations of a node/field involving extraneous never trees.\n * For example, a Forbidden field with allowed type set `[]` is equivalent to an optional field with allowed type set `[]`,\n * as well as an optional field with an allowed type set containing only unconstructable types.\n *\n * It is up to the caller to determine whether such discrepancies matter.\n */\nexport function* getAllowedContentDiscrepancies(\n\tview: FieldSchema,\n\tstored: TreeStoredSchema,\n): Iterable<Discrepancy> {\n\t// check root schema discrepancies\n\tyield* getFieldDiscrepancies(view, stored.rootFieldSchema, undefined, undefined);\n\n\tconst viewNodeSchema = new Map<TreeNodeSchemaIdentifier, TreeNodeSchema>();\n\n\twalkFieldSchema(view, {\n\t\tnode: (schema) => {\n\t\t\tconst identifier: TreeNodeSchemaIdentifier = brand(schema.identifier);\n\n\t\t\tdebugAssert(() => !viewNodeSchema.has(identifier));\n\t\t\tviewNodeSchema.set(identifier, schema);\n\t\t},\n\t});\n\n\tfor (const [identifier, viewSchema] of viewNodeSchema) {\n\t\tconst storedSchema = stored.nodeSchema.get(identifier);\n\n\t\t// if the view schema has a node that's not in the stored schema\n\t\tif (storedSchema === undefined) {\n\t\t\tconst viewType = getViewNodeSchemaType(viewSchema);\n\t\t\t// TODO does it make sense to have this mismatch when there will also be an allowedTypes mismatch?\n\t\t\tyield {\n\t\t\t\tidentifier,\n\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\tview: viewType,\n\t\t\t\tstored: undefined,\n\t\t\t};\n\t\t} else {\n\t\t\tyield* getNodeDiscrepancies(identifier, viewSchema, storedSchema);\n\t\t}\n\t}\n\n\tfor (const [identifier, storedSchema] of stored.nodeSchema) {\n\t\tif (!viewNodeSchema.has(identifier)) {\n\t\t\tconst storedType = getStoredNodeSchemaType(storedSchema);\n\t\t\tyield {\n\t\t\t\tidentifier,\n\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\tview: undefined,\n\t\t\t\tstored: storedType,\n\t\t\t};\n\t\t}\n\t}\n}\n\nfunction* getNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: TreeNodeSchema,\n\tstored: TreeNodeStoredSchema,\n): Iterable<Discrepancy> {\n\tif (!doesNodeKindMatchStoredNodeKind(view.kind, getStoredNodeSchemaType(stored))) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tmismatch: \"nodeKind\",\n\t\t\tview: getViewNodeSchemaType(view),\n\t\t\tstored: getStoredNodeSchemaType(stored),\n\t\t};\n\t\treturn;\n\t}\n\n\tswitch (view.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tassert(\n\t\t\t\tisObjectNodeSchema(view),\n\t\t\t\t0xbe9 /* schema with node kind of object must implement ObjectNodeSchema */,\n\t\t\t);\n\t\t\tconst fields: SimpleKeyMap | undefined = view.flexKeyMap;\n\t\t\tconst differences = Array.from(\n\t\t\t\tcomputeObjectNodeDiscrepancies(identifier, fields, stored as ObjectNodeStoredSchema),\n\t\t\t);\n\n\t\t\tif (differences.length > 0) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"fields\",\n\t\t\t\t\tdifferences,\n\t\t\t\t} satisfies NodeFieldsDiscrepancy;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\tassert(\n\t\t\t\tisArrayNodeSchema(view),\n\t\t\t\t0xbea /* schema with node kind of array must implement ArrayNodeSchema */,\n\t\t\t);\n\t\t\tconst fields: SimpleKeyMap = new Map([\n\t\t\t\t[\n\t\t\t\t\tEmptyKey,\n\t\t\t\t\t{\n\t\t\t\t\t\tstoredKey: EmptyKey,\n\t\t\t\t\t\tschema: createFieldSchema(FieldKind.Optional, view.info),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t]);\n\n\t\t\tconst differences = Array.from(\n\t\t\t\tcomputeObjectNodeDiscrepancies(\n\t\t\t\t\tidentifier,\n\t\t\t\t\tfields,\n\t\t\t\t\tstored as ObjectNodeStoredSchema,\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tif (differences.length > 0) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"fields\",\n\t\t\t\t\tdifferences,\n\t\t\t\t} satisfies NodeFieldsDiscrepancy;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\tassert(\n\t\t\t\tisMapNodeSchema(view),\n\t\t\t\t0xbeb /* schema with node kind of map must implement MapNodeSchema */,\n\t\t\t);\n\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\tcreateFieldSchema(FieldKind.Optional, view.info),\n\t\t\t\t(stored as MapNodeStoredSchema).mapFields,\n\t\t\t\tidentifier,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Record: {\n\t\t\tassert(\n\t\t\t\tisRecordNodeSchema(view),\n\t\t\t\t0xbec /* schema with node kind of record must implement RecordNodeSchema */,\n\t\t\t);\n\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\tcreateFieldSchema(FieldKind.Optional, view.info),\n\t\t\t\t(stored as MapNodeStoredSchema).mapFields,\n\t\t\t\tidentifier,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Leaf: {\n\t\t\tassert(\n\t\t\t\tview instanceof LeafNodeSchema,\n\t\t\t\t0xbed /* schema with node kind of leaf must implement LeafNodeSchema */,\n\t\t\t);\n\t\t\t// TODO: leafKind seems like a bad name\n\t\t\tconst viewValue = view.leafKind;\n\t\t\tconst storedValue = (stored as LeafNodeStoredSchema).leafValue;\n\t\t\tif (viewValue !== storedValue) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"valueSchema\",\n\t\t\t\t\tview: viewValue,\n\t\t\t\t\tstored: storedValue,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tbreak;\n\t}\n}\n\n/**\n * Returns the allowed types that are not present in both the given view and stored schemas.\n * It returns a tuple containing two arrays:\n * 1. The first array contains the allowed types that are present in the view schema but not in the stored schema.\n * 2. The second array contains the allowed types that are present in the stored schema but not in the view schema.\n */\nexport function findExtraAllowedTypes(\n\tviewAllowedTypes: readonly AnnotatedAllowedType<TreeNodeSchema>[],\n\tstoredAllowedTypes: TreeTypeSet,\n): [readonly AnnotatedAllowedType<TreeNodeSchema>[], TreeNodeSchemaIdentifier[]] {\n\tconst viewNodeSchemaIdentifiers = new Set(\n\t\tviewAllowedTypes.map((value) => value.type.identifier),\n\t);\n\tconst viewExtraneousAllowedTypes = [...viewAllowedTypes].filter(\n\t\t(value) => !storedAllowedTypes.has(brand(value.type.identifier)),\n\t);\n\tconst storedExtraneousAllowedTypes = [...storedAllowedTypes].filter(\n\t\t(value) => !viewNodeSchemaIdentifiers.has(value),\n\t);\n\treturn [viewExtraneousAllowedTypes, storedExtraneousAllowedTypes];\n}\n\n/**\n * The function to track the discrepancies between a field view schema and a stored schema.\n *\n * @remarks\n * This function yields discrepancies in the following cases:\n * 1. If the view schema has allowed types that are not present in the stored schema.\n * 2. If the stored schema has allowed types that are not present in the view schema.\n * 3. If the field kind in the view schema is not compatible with the stored schema.\n *\n * This function does not recurse into the nodes of the view schema and only makes comparisons at the field level.\n *\n * @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.\n */\nfunction* getFieldDiscrepancies(\n\tview: FieldSchema,\n\tstored: TreeFieldStoredSchema,\n\tidentifier: TreeNodeSchemaIdentifier | undefined,\n\tfieldKey: FieldKey | undefined,\n\t// TODO: This is a temporary workaround until the comparison logic is redesigned.\n\tviewKindIsSequence = false,\n): Iterable<FieldDiscrepancy> {\n\tassert(\n\t\tview instanceof FieldSchemaAlpha,\n\t\t0xbee /* all field schema should be FieldSchemaAlpha */,\n\t);\n\tconst [viewExtra, storedExtra] = findExtraAllowedTypes(\n\t\tview.annotatedAllowedTypesNormalized.types,\n\t\tstored.types,\n\t);\n\tif (viewExtra.length > 0 || storedExtra.length > 0) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tfieldKey,\n\t\t\tmismatch: \"allowedTypes\",\n\t\t\tview: viewExtra,\n\t\t\tstored: storedExtra,\n\t\t} satisfies AllowedTypeDiscrepancy;\n\t}\n\n\tconst viewKind =\n\t\tconvertFieldKind.get(view.kind) ??\n\t\tfail(0xbef /* A conversion from a FieldKind to a FlexFieldKind should exist */);\n\n\t// This checks if the field kind in the view schema is not compatible with the stored schema.\n\t// We cannot detect if the view schema is a sequence using the kind property so it is passed in separately.\n\tif (\n\t\t(viewKindIsSequence && stored.kind !== \"Sequence\") ||\n\t\t(!viewKindIsSequence && viewKind.identifier !== stored.kind)\n\t) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tfieldKey,\n\t\t\tmismatch: \"fieldKind\",\n\t\t\tview: viewKind.identifier,\n\t\t\tstored: stored.kind,\n\t\t} satisfies FieldKindDiscrepancy;\n\t}\n}\n\n/**\n * Computes discrepancies between a view schema and a stored schema for nodes that are treated as object nodes in the stored schema.\n * This includes both view object nodes and view array nodes.\n *\n * This function yields discrepancies in the following cases:\n *\n * 1. If the view schema has fields that are not present in the stored schema.\n * 2. If the stored schema has fields that are not present in the view schema.\n * 3. If the field kind or allowed types of a field in the view schema is not compatible with the stored schema.\n *\n * This function includes discrepancies within the common fields and their allowed types, but does NOT recurse to report and discrepancies within the node types referenced by those fields.\n */\nfunction* computeObjectNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: SimpleKeyMap,\n\tstored: ObjectNodeStoredSchema,\n\tviewKindIsSequence = false,\n): Iterable<FieldDiscrepancy> {\n\t/**\n\t * Similar to the logic used for tracking discrepancies between two node schemas, we will identify\n\t * three types of differences:\n\t * 1. Fields that exist in the view schema but not in the stored schema.\n\t * 2. Fields that exist in both schemas but have different contents.\n\t * 3. Fields that exist in the stored schema but not in the view schema.\n\t *\n\t * First, the view schema is iterated to track the first two types of differences.\n\t * Then, the stored schema is iterated to find the third type.\n\t */\n\n\tconst viewKeys = new Set<FieldKey>();\n\n\tfor (const [_, { storedKey: fieldKey, schema: fieldSchema }] of view) {\n\t\tconst storedSchema = stored.objectNodeFields.get(fieldKey);\n\t\tviewKeys.add(fieldKey);\n\n\t\t// If the view schema has a field that's not in the stored schema\n\t\tif (storedSchema === undefined) {\n\t\t\tconst viewKind =\n\t\t\t\tconvertFieldKind.get(fieldSchema.kind) ??\n\t\t\t\tfail(0xbf0 /* A conversion from a FieldKind to a FlexFieldKind should exist */);\n\t\t\tyield {\n\t\t\t\tidentifier,\n\t\t\t\tfieldKey,\n\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\tview: viewKind.identifier,\n\t\t\t\tstored: storedEmptyFieldSchema.kind,\n\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t} else {\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\tfieldSchema,\n\t\t\t\tstoredSchema,\n\t\t\t\tidentifier,\n\t\t\t\tfieldKey,\n\t\t\t\tviewKindIsSequence,\n\t\t\t);\n\t\t}\n\t}\n\n\tfor (const [fieldKey, schema] of stored.objectNodeFields) {\n\t\t// If the stored schema has a field that's not in the view schema\n\t\tif (!viewKeys.has(fieldKey)) {\n\t\t\tif (schema.kind === forbiddenFieldKindIdentifier) {\n\t\t\t\t// In the stored schema the field is explicitly forbidden.\n\t\t\t\t// This has the same semantics of the field not being mentioned in the stored schema,\n\t\t\t\t// and thus is compatible with the view schema which does not mention this field.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tyield {\n\t\t\t\tidentifier,\n\t\t\t\tfieldKey,\n\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\tview: storedEmptyFieldSchema.kind,\n\t\t\t\tstored: schema.kind,\n\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t}\n\t}\n}\n\n/**\n * A linear extension of a partially-ordered set of `T`s. See:\n * https://en.wikipedia.org/wiki/Linear_extension\n *\n * The linear extension is represented as a lookup from each poset element to its index in the linear extension.\n */\nexport type LinearExtension<T> = Map<T, number>;\n\n/**\n * A realizer for a partially-ordered set. See:\n * https://en.wikipedia.org/wiki/Order_dimension\n */\nexport type Realizer<T> = LinearExtension<T>[];\n\n/**\n * @privateRemarks\n * TODO: Knowledge of specific field kinds is not appropriate for modular schema.\n * This bit of field comparison should be dependency injected by default-schema if this comparison logic remains in modular-schema\n * (this is analogous to what is done in comparison.ts).\n */\nconst FieldKindIdentifiers = {\n\tforbidden: brand<FieldKindIdentifier>(\"Forbidden\"),\n\trequired: brand<FieldKindIdentifier>(\"Value\"),\n\tidentifier: brand<FieldKindIdentifier>(\"Identifier\"),\n\toptional: brand<FieldKindIdentifier>(\"Optional\"),\n\tsequence: brand<FieldKindIdentifier>(\"Sequence\"),\n};\n\n/**\n * A realizer for the partial order of field kind relaxability.\n *\n * It seems extremely likely that this partial order will remain dimension 2 over time (i.e. the set of allowed relaxations can be visualized\n * with a [dominance drawing](https://en.wikipedia.org/wiki/Dominance_drawing)), so this strategy allows efficient comarison between field kinds\n * without excessive casework.\n *\n * Hasse diagram for the partial order is shown below (lower fields can be relaxed to higher fields):\n * ```\n * sequence\n * |\n * optional\n * | \\\n * required forbidden\n * |\n * identifier\n * ```\n */\nexport const fieldRealizer: Realizer<FieldKindIdentifier> = [\n\t[\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n\t[\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n].map((extension) => new Map(extension.map((identifier, index) => [identifier, index])));\n\nexport const PosetComparisonResult = {\n\tLess: \"<\",\n\tGreater: \">\",\n\tEqual: \"=\",\n\tIncomparable: \"||\",\n} as const;\ntype PosetComparisonResult =\n\t(typeof PosetComparisonResult)[keyof typeof PosetComparisonResult];\n\n/**\n * TODO: This is used by SchemaCompatibilityTester, revisit it during redesign and document\n */\nexport function comparePosetElements<T>(\n\ta: T,\n\tb: T,\n\trealizer: Realizer<T>,\n): PosetComparisonResult {\n\tlet hasLessThanResult = false;\n\tlet hasGreaterThanResult = false;\n\tfor (const extension of realizer) {\n\t\tconst aIndex = extension.get(a);\n\t\tconst bIndex = extension.get(b);\n\t\tassert(aIndex !== undefined && bIndex !== undefined, 0xbf1 /* Invalid realizer */);\n\t\tif (aIndex < bIndex) {\n\t\t\thasLessThanResult = true;\n\t\t} else if (aIndex > bIndex) {\n\t\t\thasGreaterThanResult = true;\n\t\t}\n\t}\n\n\treturn hasLessThanResult\n\t\t? hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Incomparable\n\t\t\t: PosetComparisonResult.Less\n\t\t: hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Greater\n\t\t\t: PosetComparisonResult.Equal;\n}\n"]}
|