@fluidframework/tree 2.43.0 → 2.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +100 -0
- package/api-report/tree.alpha.api.md +73 -16
- package/api-report/tree.beta.api.md +9 -3
- package/api-report/tree.legacy.alpha.api.md +8 -2
- package/api-report/tree.legacy.public.api.md +8 -2
- package/api-report/tree.public.api.md +8 -2
- package/dist/alpha.d.ts +9 -0
- package/dist/core/forest/editableForest.d.ts +0 -2
- package/dist/core/forest/editableForest.d.ts.map +1 -1
- package/dist/core/forest/editableForest.js.map +1 -1
- package/dist/core/forest/forest.d.ts +0 -4
- package/dist/core/forest/forest.d.ts.map +1 -1
- package/dist/core/forest/forest.js +0 -4
- package/dist/core/forest/forest.js.map +1 -1
- package/dist/core/rebase/changeRebaser.d.ts +0 -6
- package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
- package/dist/core/rebase/changeRebaser.js.map +1 -1
- package/dist/core/rebase/types.d.ts +0 -2
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +0 -8
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +0 -8
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/schema-view/view.d.ts +0 -2
- package/dist/core/schema-view/view.d.ts.map +1 -1
- package/dist/core/schema-view/view.js.map +1 -1
- package/dist/core/tree/cursor.d.ts +0 -2
- package/dist/core/tree/cursor.d.ts.map +1 -1
- package/dist/core/tree/cursor.js +0 -2
- package/dist/core/tree/cursor.js.map +1 -1
- package/dist/core/tree/delta.d.ts +0 -2
- package/dist/core/tree/delta.d.ts.map +1 -1
- package/dist/core/tree/delta.js.map +1 -1
- package/dist/core/tree/types.d.ts +0 -4
- package/dist/core/tree/types.d.ts.map +1 -1
- package/dist/core/tree/types.js +0 -2
- package/dist/core/tree/types.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +0 -4
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -10
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +0 -2
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js +0 -2
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +0 -2
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js +0 -2
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +0 -10
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +0 -2
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +0 -6
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +0 -12
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/sequence-field/types.d.ts +0 -2
- package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/jsonDomainSchema.d.ts +2 -6
- package/dist/jsonDomainSchema.d.ts.map +1 -1
- package/dist/jsonDomainSchema.js +2 -2
- package/dist/jsonDomainSchema.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/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +3 -1
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts +8 -12
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.js +54 -46
- package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/dist/shared-tree-core/resubmitMachine.d.ts +6 -0
- package/dist/shared-tree-core/resubmitMachine.d.ts.map +1 -1
- package/dist/shared-tree-core/resubmitMachine.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +16 -3
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js +49 -17
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +1 -1
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +3 -4
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +2 -2
- 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/jsonSchema.d.ts +32 -8
- package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/jsonSchema.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +2 -2
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +1 -1
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +97 -3
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +75 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +5 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +2 -0
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +4 -4
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/treeBeta.d.ts +1 -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.js +1 -1
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +12 -0
- 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/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +5 -3
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +1 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +2 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +5 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js +4 -0
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +3 -3
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +3 -1
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts +2 -1
- package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/index.js +5 -1
- package/dist/simple-tree/node-kinds/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
- 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.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +5 -1
- 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/index.d.ts +7 -0
- package/dist/simple-tree/node-kinds/record/index.d.ts.map +1 -0
- package/dist/simple-tree/node-kinds/record/index.js +13 -0
- package/dist/simple-tree/node-kinds/record/index.js.map +1 -0
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts +39 -0
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -0
- package/dist/simple-tree/node-kinds/record/recordNode.js +234 -0
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -0
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +70 -0
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -0
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.js +30 -0
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -0
- package/dist/simple-tree/simpleSchema.d.ts +16 -1
- 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.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +4 -2
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +56 -32
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/dist/tableSchema.d.ts +7 -2
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +21 -7
- package/dist/tableSchema.js.map +1 -1
- package/dist/util/brandedMap.d.ts +0 -2
- package/dist/util/brandedMap.d.ts.map +1 -1
- package/dist/util/brandedMap.js.map +1 -1
- package/docs/main/compatibility.md +15 -1
- package/lib/alpha.d.ts +9 -0
- package/lib/core/forest/editableForest.d.ts +0 -2
- package/lib/core/forest/editableForest.d.ts.map +1 -1
- package/lib/core/forest/editableForest.js.map +1 -1
- package/lib/core/forest/forest.d.ts +0 -4
- package/lib/core/forest/forest.d.ts.map +1 -1
- package/lib/core/forest/forest.js +0 -4
- package/lib/core/forest/forest.js.map +1 -1
- package/lib/core/rebase/changeRebaser.d.ts +0 -6
- package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
- package/lib/core/rebase/changeRebaser.js.map +1 -1
- package/lib/core/rebase/types.d.ts +0 -2
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +0 -8
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +0 -8
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/schema-view/view.d.ts +0 -2
- package/lib/core/schema-view/view.d.ts.map +1 -1
- package/lib/core/schema-view/view.js.map +1 -1
- package/lib/core/tree/cursor.d.ts +0 -2
- package/lib/core/tree/cursor.d.ts.map +1 -1
- package/lib/core/tree/cursor.js +0 -2
- package/lib/core/tree/cursor.js.map +1 -1
- package/lib/core/tree/delta.d.ts +0 -2
- package/lib/core/tree/delta.d.ts.map +1 -1
- package/lib/core/tree/delta.js.map +1 -1
- package/lib/core/tree/types.d.ts +0 -4
- package/lib/core/tree/types.d.ts.map +1 -1
- package/lib/core/tree/types.js +0 -2
- package/lib/core/tree/types.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +0 -4
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -10
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +0 -2
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -2
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +0 -2
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js +0 -2
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +0 -10
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +0 -2
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +0 -6
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +0 -12
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/sequence-field/types.d.ts +0 -2
- package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/types.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/jsonDomainSchema.d.ts +2 -6
- package/lib/jsonDomainSchema.d.ts.map +1 -1
- package/lib/jsonDomainSchema.js +3 -3
- package/lib/jsonDomainSchema.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/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +3 -1
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts +8 -12
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.js +55 -47
- package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/lib/shared-tree-core/resubmitMachine.d.ts +6 -0
- package/lib/shared-tree-core/resubmitMachine.d.ts.map +1 -1
- package/lib/shared-tree-core/resubmitMachine.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +16 -3
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js +51 -19
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +1 -1
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +2 -3
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +2 -2
- 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/jsonSchema.d.ts +32 -8
- package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/jsonSchema.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +2 -2
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +1 -1
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +97 -3
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +77 -2
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +5 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +2 -0
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +5 -5
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/treeBeta.d.ts +1 -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.js +2 -2
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +12 -0
- 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/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +6 -4
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +1 -1
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +1 -1
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +5 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js +4 -0
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +3 -3
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts +2 -1
- package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/index.js +1 -0
- package/lib/simple-tree/node-kinds/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.js +1 -1
- package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +5 -1
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/index.d.ts +7 -0
- package/lib/simple-tree/node-kinds/record/index.d.ts.map +1 -0
- package/lib/simple-tree/node-kinds/record/index.js +7 -0
- package/lib/simple-tree/node-kinds/record/index.js.map +1 -0
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts +39 -0
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -0
- package/lib/simple-tree/node-kinds/record/recordNode.js +232 -0
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -0
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +70 -0
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -0
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.js +26 -0
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -0
- package/lib/simple-tree/simpleSchema.d.ts +16 -1
- 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.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +4 -2
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +58 -34
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/lib/tableSchema.d.ts +7 -2
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +22 -8
- package/lib/tableSchema.js.map +1 -1
- package/lib/util/brandedMap.d.ts +0 -2
- package/lib/util/brandedMap.d.ts.map +1 -1
- package/lib/util/brandedMap.js.map +1 -1
- package/package.json +34 -22
- package/src/core/forest/editableForest.ts +0 -2
- package/src/core/forest/forest.ts +0 -4
- package/src/core/rebase/changeRebaser.ts +0 -6
- package/src/core/rebase/types.ts +0 -2
- package/src/core/schema-stored/schema.ts +0 -8
- package/src/core/schema-view/view.ts +0 -2
- package/src/core/tree/cursor.ts +0 -2
- package/src/core/tree/delta.ts +0 -2
- package/src/core/tree/types.ts +0 -4
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +0 -4
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +0 -10
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +0 -2
- package/src/feature-libraries/modular-schema/crossFieldQueries.ts +0 -2
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +0 -10
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +0 -8
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +0 -12
- package/src/feature-libraries/sequence-field/types.ts +0 -2
- package/src/index.ts +9 -0
- package/src/jsonDomainSchema.ts +3 -3
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/treeAlpha.ts +3 -1
- package/src/shared-tree-core/defaultResubmitMachine.ts +99 -52
- package/src/shared-tree-core/resubmitMachine.ts +7 -0
- package/src/shared-tree-core/sharedTreeCore.ts +18 -6
- package/src/simple-tree/api/configuration.ts +73 -19
- package/src/simple-tree/api/customTree.ts +3 -3
- package/src/simple-tree/api/index.ts +3 -0
- package/src/simple-tree/api/jsonSchema.ts +35 -8
- package/src/simple-tree/api/schemaFactory.ts +5 -13
- package/src/simple-tree/api/schemaFactoryAlpha.ts +268 -1
- package/src/simple-tree/api/schemaFactoryRecursive.ts +5 -1
- package/src/simple-tree/api/schemaFromSimple.ts +6 -0
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +16 -7
- package/src/simple-tree/api/treeBeta.ts +2 -2
- package/src/simple-tree/api/treeNodeApi.ts +2 -2
- package/src/simple-tree/api/typesUnsafe.ts +15 -0
- package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +14 -6
- package/src/simple-tree/core/index.ts +1 -0
- package/src/simple-tree/core/treeNodeSchema.ts +8 -4
- package/src/simple-tree/index.ts +11 -0
- package/src/simple-tree/node-kinds/index.ts +11 -0
- package/src/simple-tree/node-kinds/object/index.ts +5 -1
- package/src/simple-tree/node-kinds/object/objectNode.ts +3 -2
- package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +6 -3
- package/src/simple-tree/node-kinds/record/index.ts +14 -0
- package/src/simple-tree/node-kinds/record/recordNode.ts +410 -0
- package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +136 -0
- package/src/simple-tree/simpleSchema.ts +19 -1
- package/src/simple-tree/toStoredSchema.ts +4 -2
- package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +83 -40
- package/src/tableSchema.ts +27 -8
- package/src/util/brandedMap.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTreeCore.js","sourceRoot":"","sources":["../../src/shared-tree-core/sharedTreeCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAS7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAK5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAG7E,OAAO,EAGN,YAAY,EAGZ,gBAAgB,GAKhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEN,KAAK,EAGL,aAAa,EACb,aAAa,GACb,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAuC,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAA+B,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAInF,yDAAyD;AACzD,MAAM,oBAAoB,GA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AC5C,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI;YACd,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tIRuntimeMessageCollection,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport type {\n\tIChannelView,\n\tIFluidSerializer,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { ICodecOptions, IJsonCodec } from \"../codec/index.js\";\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\tfindAncestor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tRevisionTagCodec,\n\ttype SchemaAndPolicy,\n\ttype SchemaPolicy,\n\ttype TaggedChange,\n\ttype TreeStoredSchemaRepository,\n} from \"../core/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\tbrand,\n\ttype Breakable,\n\ttype WithBreakable,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"../util/index.js\";\n\nimport type { SharedTreeBranch } from \"./branch.js\";\nimport { BranchCommitEnricher } from \"./branchCommitEnricher.js\";\nimport { type ChangeEnricherReadonlyCheckout, NoOpChangeEnricher } from \"./changeEnricher.js\";\nimport { DefaultResubmitMachine } from \"./defaultResubmitMachine.js\";\nimport { EditManager, minimumPossibleSequenceNumber } from \"./editManager.js\";\nimport { makeEditManagerCodec } from \"./editManagerCodecs.js\";\nimport type { SeqNumber } from \"./editManagerFormat.js\";\nimport { EditManagerSummarizer } from \"./editManagerSummarizer.js\";\nimport { type MessageEncodingContext, makeMessageCodec } from \"./messageCodecs.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\nimport type { ResubmitMachine } from \"./resubmitMachine.js\";\n\n// TODO: Organize this to be adjacent to persisted types.\nconst summarizablesTreeKey = \"indexes\";\n\nexport interface ExplicitCoreCodecVersions {\n\teditManager: number;\n\tmessage: number;\n}\n\nexport interface ClonableSchemaAndPolicy extends SchemaAndPolicy {\n\tschema: TreeStoredSchemaRepository;\n}\n\n/**\n * Generic shared tree, which needs to be configured with indexes, field kinds and other configuration.\n */\n@breakingClass\nexport class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>\n\timplements WithBreakable\n{\n\tprivate readonly editManager: EditManager<TEditor, TChange, ChangeFamily<TEditor, TChange>>;\n\tprivate readonly summarizables: readonly [EditManagerSummarizer<TChange>, ...Summarizable[]];\n\t/**\n\t * The sequence number that this instance is at.\n\t * This number is artificial in that it is made up by this instance as opposed to being provided by the runtime.\n\t * Is `undefined` after (and only after) this instance is attached.\n\t */\n\tprivate detachedRevision: SeqNumber | undefined = minimumPossibleSequenceNumber;\n\n\t/**\n\t * Used to encode/decode messages sent to/received from the Fluid runtime.\n\t *\n\t * @remarks Since there is currently only one format, this can just be cached on the class.\n\t * With more write formats active, it may make sense to keep around the \"usual\" format codec\n\t * (the one for the current persisted configuration) and resolve codecs for different versions\n\t * as necessary (e.g. an upgrade op came in, or the configuration changed within the collab window\n\t * and an op needs to be interpreted which isn't written with the current configuration).\n\t */\n\tprivate readonly messageCodec: IJsonCodec<\n\t\tDecodedMessage<TChange>,\n\t\tunknown,\n\t\tunknown,\n\t\tMessageEncodingContext\n\t>;\n\n\tprivate readonly resubmitMachine: ResubmitMachine<TChange>;\n\tpublic readonly commitEnricher: BranchCommitEnricher<TChange>;\n\n\tpublic readonly mintRevisionTag: () => RevisionTag;\n\n\tprivate readonly schemaAndPolicy: ClonableSchemaAndPolicy;\n\n\t/**\n\t * @param summarizables - Summarizers for all indexes used by this tree\n\t * @param changeFamily - The change family\n\t * @param editManager - The edit manager\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param editor - Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\tpublic constructor(\n\t\tpublic readonly breaker: Breakable,\n\t\tpublic readonly sharedObject: IChannelView & IFluidLoadable,\n\t\tpublic readonly serializer: IFluidSerializer,\n\t\tpublic readonly submitLocalMessage: (content: unknown, localOpMetadata?: unknown) => void,\n\t\tlogger: ITelemetryBaseLogger | undefined,\n\t\tsummarizables: readonly Summarizable[],\n\t\tchangeFamily: ChangeFamily<TEditor, TChange>,\n\t\toptions: ICodecOptions,\n\t\tformatOptions: ExplicitCoreCodecVersions,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tschema: TreeStoredSchemaRepository,\n\t\tschemaPolicy: SchemaPolicy,\n\t\tresubmitMachine?: ResubmitMachine<TChange>,\n\t\tenricher?: ChangeEnricherReadonlyCheckout<TChange>,\n\t\tpublic readonly getEditor: () => TEditor = () => this.getLocalBranch().editor,\n\t) {\n\t\tthis.schemaAndPolicy = {\n\t\t\tschema,\n\t\t\tpolicy: schemaPolicy,\n\t\t};\n\n\t\tconst rebaseLogger = createChildLogger({\n\t\t\tlogger,\n\t\t\tnamespace: \"Rebase\",\n\t\t});\n\n\t\tthis.mintRevisionTag = () => this.idCompressor.generateCompressedId();\n\t\t/**\n\t\t * A random ID that uniquely identifies this client in the collab session.\n\t\t * This is sent alongside every op to identify which client the op originated from.\n\t\t * This is used rather than the Fluid client ID because the Fluid client ID is not stable across reconnections.\n\t\t */\n\t\tconst localSessionId = idCompressor.localSessionId;\n\t\tthis.editManager = new EditManager(\n\t\t\tchangeFamily,\n\t\t\tlocalSessionId,\n\t\t\tthis.mintRevisionTag,\n\t\t\trebaseLogger,\n\t\t);\n\n\t\tthis.editManager.localBranch.events.on(\"beforeChange\", (change) => {\n\t\t\tif (this.detachedRevision === undefined) {\n\t\t\t\t// Commit enrichment is only necessary for changes that will be submitted as ops, and changes issued while detached are not submitted.\n\t\t\t\tthis.commitEnricher.processChange(change);\n\t\t\t}\n\t\t\tif (change.type === \"append\") {\n\t\t\t\tfor (const commit of change.newCommits) {\n\t\t\t\t\tthis.submitCommit(commit, this.schemaAndPolicy, false);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tconst revisionTagCodec = new RevisionTagCodec(idCompressor);\n\t\tconst editManagerCodec = makeEditManagerCodec(\n\t\t\tthis.editManager.changeFamily.codecs,\n\t\t\trevisionTagCodec,\n\t\t\toptions,\n\t\t\tformatOptions.editManager,\n\t\t);\n\t\tthis.summarizables = [\n\t\t\tnew EditManagerSummarizer(\n\t\t\t\tthis.editManager,\n\t\t\t\teditManagerCodec,\n\t\t\t\tthis.idCompressor,\n\t\t\t\tthis.schemaAndPolicy,\n\t\t\t),\n\t\t\t...summarizables,\n\t\t];\n\t\tassert(\n\t\t\tnew Set(this.summarizables.map((e) => e.key)).size === this.summarizables.length,\n\t\t\t0x350 /* Index summary element keys must be unique */,\n\t\t);\n\n\t\tthis.messageCodec = makeMessageCodec(\n\t\t\tchangeFamily.codecs,\n\t\t\tnew RevisionTagCodec(idCompressor),\n\t\t\toptions,\n\t\t\tformatOptions.message,\n\t\t);\n\n\t\tconst changeEnricher = enricher ?? new NoOpChangeEnricher();\n\t\tthis.resubmitMachine =\n\t\t\tresubmitMachine ??\n\t\t\tnew DefaultResubmitMachine(\n\t\t\t\t(change: TaggedChange<TChange>) =>\n\t\t\t\t\tchangeFamily.rebaser.invert(change, true, this.mintRevisionTag()),\n\t\t\t\tchangeEnricher,\n\t\t\t);\n\t\tthis.commitEnricher = new BranchCommitEnricher(changeFamily.rebaser, changeEnricher);\n\t}\n\n\t// TODO: SharedObject's merging of the two summary methods into summarizeCore is not what we want here:\n\t// We might want to not subclass it, or override/reimplement most of its functionality.\n\t@throwIfBroken\n\tpublic summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tconst summarizableBuilder = new SummaryTreeBuilder();\n\t\t// Merge the summaries of all summarizables together under a single ISummaryTree\n\t\tfor (const s of this.summarizables) {\n\t\t\t// Add the summarizable's path in the summary tree to the incremental summary context's\n\t\t\t// summary path, so that the summarizable can use it to generate incremental summaries.\n\t\t\tconst childIncrementalSummaryContext =\n\t\t\t\tincrementalSummaryContext === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...incrementalSummaryContext,\n\t\t\t\t\t\t\tsummaryPath: `${incrementalSummaryContext.summaryPath}/${summarizablesTreeKey}/${s.key}`,\n\t\t\t\t\t\t};\n\t\t\tsummarizableBuilder.addWithStats(\n\t\t\t\ts.key,\n\t\t\t\ts.summarize({\n\t\t\t\t\tstringify: (contents: unknown) =>\n\t\t\t\t\t\tserializer.stringify(contents, this.sharedObject.handle),\n\t\t\t\t\tfullTree,\n\t\t\t\t\ttelemetryContext,\n\t\t\t\t\tincrementalSummaryContext: childIncrementalSummaryContext,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tbuilder.addWithStats(summarizablesTreeKey, summarizableBuilder.getSummaryTree());\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tpublic async loadCore(services: IChannelStorageService): Promise<void> {\n\t\tassert(\n\t\t\tthis.editManager.localBranch.getHead() === this.editManager.getTrunkHead(),\n\t\t\t0xaaa /* All local changes should be applied to the trunk before loading from summary */,\n\t\t);\n\t\tconst [editManagerSummarizer, ...summarizables] = this.summarizables;\n\t\tconst loadEditManager = this.loadSummarizable(editManagerSummarizer, services);\n\t\tconst loadSummarizables = summarizables.map(async (s) =>\n\t\t\tthis.loadSummarizable(s, services),\n\t\t);\n\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\t// If we are detached but loading from a summary, then we need to update our detached revision to ensure that it is ahead of all detached revisions in the summary.\n\t\t\t// First, finish loading the edit manager so that we can inspect the sequence numbers of the commits on the trunk.\n\t\t\tawait loadEditManager;\n\t\t\t// Find the most recent detached revision in the summary trunk...\n\t\t\tlet latestDetachedSequenceNumber: SeqNumber | undefined;\n\t\t\tfindAncestor(this.editManager.getTrunkHead(), (c) => {\n\t\t\t\tconst sequenceNumber = this.editManager.getSequenceNumber(c);\n\t\t\t\tif (sequenceNumber !== undefined && sequenceNumber < 0) {\n\t\t\t\t\tlatestDetachedSequenceNumber = sequenceNumber;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t});\n\t\t\t// ...and set our detached revision to be as it would be if we had been already created that revision.\n\t\t\tthis.detachedRevision = latestDetachedSequenceNumber ?? this.detachedRevision;\n\t\t\tawait Promise.all(loadSummarizables);\n\t\t} else {\n\t\t\tawait Promise.all([loadEditManager, ...loadSummarizables]);\n\t\t}\n\t}\n\n\tprivate async loadSummarizable(\n\t\tsummarizable: Summarizable,\n\t\tservices: IChannelStorageService,\n\t): Promise<void> {\n\t\treturn summarizable.load(\n\t\t\tscopeStorageService(services, summarizablesTreeKey, summarizable.key),\n\t\t\t(contents) => this.serializer.parse(contents),\n\t\t);\n\t}\n\n\t/**\n\t * Submits an op to the Fluid runtime containing the given commit\n\t * @param commit - the commit to submit\n\t * @returns the submitted commit. This is undefined if the underlying `SharedObject` is not attached,\n\t * and may differ from `commit` due to enrichments like detached tree refreshers.\n\t */\n\tprotected submitCommit(\n\t\tcommit: GraphCommit<TChange>,\n\t\tschemaAndPolicy: ClonableSchemaAndPolicy,\n\t\tisResubmit: boolean,\n\t): void {\n\t\tassert(\n\t\t\tthis.sharedObject.isAttached() === (this.detachedRevision === undefined),\n\t\t\t0x95a /* Detached revision should only be set when not attached */,\n\t\t);\n\n\t\tconst enrichedCommit =\n\t\t\tthis.detachedRevision === undefined && !isResubmit\n\t\t\t\t? this.commitEnricher.enrich(commit)\n\t\t\t\t: commit;\n\n\t\t// Edits submitted before the first attach are treated as sequenced because they will be included\n\t\t// in the attach summary that is uploaded to the service.\n\t\t// Until this attach workflow happens, this instance essentially behaves as a centralized data structure.\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\tconst newRevision: SeqNumber = brand((this.detachedRevision as number) + 1);\n\t\t\tthis.detachedRevision = newRevision;\n\t\t\tthis.editManager.addSequencedChanges(\n\t\t\t\t[enrichedCommit],\n\t\t\t\tthis.editManager.localSessionId,\n\t\t\t\tnewRevision,\n\t\t\t\tthis.detachedRevision,\n\t\t\t);\n\t\t\tthis.editManager.advanceMinimumSequenceNumber(newRevision, false);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst message = this.messageCodec.encode(\n\t\t\t{\n\t\t\t\tcommit: enrichedCommit,\n\t\t\t\tsessionId: this.editManager.localSessionId,\n\t\t\t},\n\t\t\t{\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t\tschema: schemaAndPolicy,\n\t\t\t},\n\t\t);\n\t\tthis.submitLocalMessage(message, {\n\t\t\t// Clone the schema to ensure that during resubmit the schema has not been mutated by later changes\n\t\t\tschema: schemaAndPolicy.schema.clone(),\n\t\t\tpolicy: schemaAndPolicy.policy,\n\t\t});\n\t\tthis.resubmitMachine.onCommitSubmitted(enrichedCommit);\n\t}\n\n\t/**\n\t * Process a bunch of messages from the runtime. SharedObject will call this method with a bunch of messages.\n\t */\n\tpublic processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tconst commits: GraphCommit<TChange>[] = [];\n\t\tlet messagesSessionId: SessionId | undefined;\n\n\t\t// Get a list of all the commits from the messages.\n\t\tfor (const messageContent of messagesContent) {\n\t\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\t\tconst { commit, sessionId } = this.messageCodec.decode(messageContent.contents, {\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t});\n\t\t\tcommits.push(commit);\n\n\t\t\tif (messagesSessionId !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tmessagesSessionId === sessionId,\n\t\t\t\t\t0xad9 /* All messages in a bunch must have the same session ID */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tmessagesSessionId = sessionId;\n\t\t}\n\n\t\tassert(messagesSessionId !== undefined, 0xada /* Messages must have a session ID */);\n\n\t\tthis.editManager.addSequencedChanges(\n\t\t\tcommits,\n\t\t\tmessagesSessionId,\n\t\t\tbrand(envelope.sequenceNumber),\n\t\t\tbrand(envelope.referenceSequenceNumber),\n\t\t);\n\n\t\t// Update the resubmit machine for each commit applied.\n\t\tfor (const _ of messagesContent) {\n\t\t\tthis.resubmitMachine.onSequencedCommitApplied(local);\n\t\t}\n\n\t\tthis.editManager.advanceMinimumSequenceNumber(brand(envelope.minimumSequenceNumber));\n\t}\n\n\tpublic getLocalBranch(): SharedTreeBranch<TEditor, TChange> {\n\t\treturn this.editManager.localBranch;\n\t}\n\n\tpublic didAttach(): void {\n\t\tthis.detachedRevision = undefined;\n\t}\n\n\tpublic reSubmitCore(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision },\n\t\t} = this.messageCodec.decode(this.serializer.decode(content), {\n\t\t\tidCompressor: this.idCompressor,\n\t\t});\n\t\tconst [commit] = this.editManager.findLocalCommit(revision);\n\t\t// If a resubmit phase is not already in progress, then this must be the first commit of a new resubmit phase.\n\t\tif (this.resubmitMachine.isInResubmitPhase === false) {\n\t\t\tconst toResubmit = this.editManager.getLocalCommits();\n\t\t\tassert(\n\t\t\t\tcommit === toResubmit[0],\n\t\t\t\t0x95d /* Resubmit phase should start with the oldest local commit */,\n\t\t\t);\n\t\t\tthis.resubmitMachine.prepareForResubmit(toResubmit);\n\t\t}\n\t\tassert(\n\t\t\tisClonableSchemaPolicy(localOpMetadata),\n\t\t\t0x95e /* Local metadata must contain schema and policy. */,\n\t\t);\n\t\tassert(\n\t\t\tthis.resubmitMachine.isInResubmitPhase !== false,\n\t\t\t0x984 /* Invalid resubmit outside of resubmit phase */,\n\t\t);\n\t\tconst enrichedCommit = this.resubmitMachine.peekNextCommit();\n\t\tthis.submitCommit(enrichedCommit, localOpMetadata, true);\n\t}\n\n\tpublic applyStashedOp(content: JsonCompatibleReadOnly): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision, change },\n\t\t} = this.messageCodec.decode(content, { idCompressor: this.idCompressor });\n\t\tthis.editManager.localBranch.apply({ change, revision });\n\t}\n}\n\nfunction isClonableSchemaPolicy(\n\tmaybeSchemaPolicy: unknown,\n): maybeSchemaPolicy is ClonableSchemaAndPolicy {\n\tconst schemaAndPolicy = maybeSchemaPolicy as ClonableSchemaAndPolicy;\n\treturn schemaAndPolicy.schema !== undefined && schemaAndPolicy.policy !== undefined;\n}\n\n/**\n * Specifies the behavior of a component that puts data in a summary.\n */\nexport interface Summarizable {\n\t/**\n\t * Field name in summary json under which this element stores its data.\n\t */\n\treadonly key: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.\n\t * @param fullTree - A flag indicating whether the attempt should generate a full\n\t * summary tree without any handles for unchanged subtrees. It should only be set to true when generating\n\t * a summary from the entire container. The default value is false.\n\t * @param trackState - An optimization for tracking state of objects across summaries. If the state\n\t * of an object did not change since last successful summary, an\n\t * {@link @fluidframework/protocol-definitions#ISummaryHandle} can be used\n\t * instead of re-summarizing it. If this is `false`, the expectation is that you should never\n\t * send an `ISummaryHandle`, since you are not expected to track state. The default value is true.\n\t * @param telemetryContext - See {@link @fluidframework/runtime-definitions#ITelemetryContext}.\n\t * @param incrementalSummaryContext - See {@link @fluidframework/runtime-definitions#IExperimentalIncrementalSummaryContext}.\n\t */\n\tsummarize(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t}): ISummaryTreeWithStats;\n\n\t/**\n\t * Allows the component to perform custom loading. The storage service is scoped to this component and therefore\n\t * paths in this component will not collide with those in other components, even if they are the same string.\n\t * @param service - Storage used by the component\n\t * @param parse - Parses serialized data from storage into runtime objects for the component\n\t */\n\tload(service: IChannelStorageService, parse: SummaryElementParser): Promise<void>;\n}\n\n/**\n * Serializes the given contents into a string acceptable for storing in summaries, i.e. all\n * Fluid handles have been replaced appropriately by an IFluidSerializer\n */\nexport type SummaryElementStringifier = (contents: unknown) => string;\n\n/**\n * Parses a serialized/summarized string into an object, rehydrating any Fluid handles as necessary\n */\nexport type SummaryElementParser = (contents: string) => unknown;\n\n/**\n * Compose an {@link IChannelStorageService} which prefixes all paths before forwarding them to the original service\n */\nfunction scopeStorageService(\n\tservice: IChannelStorageService,\n\t...pathElements: string[]\n): IChannelStorageService {\n\tconst scope = `${pathElements.join(\"/\")}/`;\n\n\treturn {\n\t\tasync readBlob(path: string): Promise<ArrayBufferLike> {\n\t\t\treturn service.readBlob(`${scope}${path}`);\n\t\t},\n\t\tasync contains(path) {\n\t\t\treturn service.contains(`${scope}${path}`);\n\t\t},\n\t\tasync list(path) {\n\t\t\treturn service.list(`${scope}${path}`);\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedTreeCore.js","sourceRoot":"","sources":["../../src/shared-tree-core/sharedTreeCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,MAAM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,CAAC,GAAG,CAAC,GAAG,CAAC;IAE3C,OAAO;QACN,KAAK,CAAC,QAAQ,CAAC,IAAY;YAC1B,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,IAAI;YAClB,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI;YACd,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tIRuntimeMessageCollection,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport type {\n\tIChannelView,\n\tIFluidSerializer,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { ICodecOptions, IJsonCodec } from \"../codec/index.js\";\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\tfindAncestor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tRevisionTagCodec,\n\ttype SchemaAndPolicy,\n\ttype SchemaPolicy,\n\ttype TaggedChange,\n\ttype TreeStoredSchemaRepository,\n} from \"../core/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\tbrand,\n\ttype Breakable,\n\ttype WithBreakable,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"../util/index.js\";\n\nimport type { SharedTreeBranch } from \"./branch.js\";\nimport { BranchCommitEnricher } from \"./branchCommitEnricher.js\";\nimport { type ChangeEnricherReadonlyCheckout, NoOpChangeEnricher } from \"./changeEnricher.js\";\nimport { DefaultResubmitMachine } from \"./defaultResubmitMachine.js\";\nimport { EditManager, minimumPossibleSequenceNumber } from \"./editManager.js\";\nimport { makeEditManagerCodec } from \"./editManagerCodecs.js\";\nimport type { SeqNumber } from \"./editManagerFormat.js\";\nimport { EditManagerSummarizer } from \"./editManagerSummarizer.js\";\nimport { type MessageEncodingContext, makeMessageCodec } from \"./messageCodecs.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\nimport type { ResubmitMachine } from \"./resubmitMachine.js\";\n\n// TODO: Organize this to be adjacent to persisted types.\nconst summarizablesTreeKey = \"indexes\";\n\nexport interface ExplicitCoreCodecVersions {\n\teditManager: number;\n\tmessage: number;\n}\n\nexport interface ClonableSchemaAndPolicy extends SchemaAndPolicy {\n\tschema: TreeStoredSchemaRepository;\n}\n\n/**\n * Generic shared tree, which needs to be configured with indexes, field kinds and other configuration.\n */\n@breakingClass\nexport class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>\n\timplements WithBreakable\n{\n\tprivate readonly editManager: EditManager<TEditor, TChange, ChangeFamily<TEditor, TChange>>;\n\tprivate readonly summarizables: readonly [EditManagerSummarizer<TChange>, ...Summarizable[]];\n\t/**\n\t * The sequence number that this instance is at.\n\t * This number is artificial in that it is made up by this instance as opposed to being provided by the runtime.\n\t * Is `undefined` after (and only after) this instance is attached.\n\t */\n\tprivate detachedRevision: SeqNumber | undefined = minimumPossibleSequenceNumber;\n\n\t/**\n\t * Used to encode/decode messages sent to/received from the Fluid runtime.\n\t *\n\t * @remarks Since there is currently only one format, this can just be cached on the class.\n\t * With more write formats active, it may make sense to keep around the \"usual\" format codec\n\t * (the one for the current persisted configuration) and resolve codecs for different versions\n\t * as necessary (e.g. an upgrade op came in, or the configuration changed within the collab window\n\t * and an op needs to be interpreted which isn't written with the current configuration).\n\t */\n\tprivate readonly messageCodec: IJsonCodec<\n\t\tDecodedMessage<TChange>,\n\t\tunknown,\n\t\tunknown,\n\t\tMessageEncodingContext\n\t>;\n\n\tprivate readonly resubmitMachine: ResubmitMachine<TChange>;\n\tpublic readonly commitEnricher: BranchCommitEnricher<TChange>;\n\n\tpublic readonly mintRevisionTag: () => RevisionTag;\n\n\tprivate readonly schemaAndPolicy: ClonableSchemaAndPolicy;\n\n\t/**\n\t * @param summarizables - Summarizers for all indexes used by this tree\n\t * @param changeFamily - The change family\n\t * @param editManager - The edit manager\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param editor - Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\tpublic constructor(\n\t\tpublic readonly breaker: Breakable,\n\t\tpublic readonly sharedObject: IChannelView & IFluidLoadable,\n\t\tpublic readonly serializer: IFluidSerializer,\n\t\tpublic readonly submitLocalMessage: (content: unknown, localOpMetadata?: unknown) => void,\n\t\tlogger: ITelemetryBaseLogger | undefined,\n\t\tsummarizables: readonly Summarizable[],\n\t\tchangeFamily: ChangeFamily<TEditor, TChange>,\n\t\toptions: ICodecOptions,\n\t\tformatOptions: ExplicitCoreCodecVersions,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tschema: TreeStoredSchemaRepository,\n\t\tschemaPolicy: SchemaPolicy,\n\t\tresubmitMachine?: ResubmitMachine<TChange>,\n\t\tenricher?: ChangeEnricherReadonlyCheckout<TChange>,\n\t\tpublic readonly getEditor: () => TEditor = () => this.getLocalBranch().editor,\n\t) {\n\t\tthis.schemaAndPolicy = {\n\t\t\tschema,\n\t\t\tpolicy: schemaPolicy,\n\t\t};\n\n\t\tconst rebaseLogger = createChildLogger({\n\t\t\tlogger,\n\t\t\tnamespace: \"Rebase\",\n\t\t});\n\n\t\tthis.mintRevisionTag = () => this.idCompressor.generateCompressedId();\n\t\t/**\n\t\t * A random ID that uniquely identifies this client in the collab session.\n\t\t * This is sent alongside every op to identify which client the op originated from.\n\t\t * This is used rather than the Fluid client ID because the Fluid client ID is not stable across reconnections.\n\t\t */\n\t\tconst localSessionId = idCompressor.localSessionId;\n\t\tthis.editManager = new EditManager(\n\t\t\tchangeFamily,\n\t\t\tlocalSessionId,\n\t\t\tthis.mintRevisionTag,\n\t\t\trebaseLogger,\n\t\t);\n\n\t\tthis.editManager.localBranch.events.on(\"beforeChange\", (change) => {\n\t\t\tif (this.detachedRevision === undefined) {\n\t\t\t\t// Commit enrichment is only necessary for changes that will be submitted as ops, and changes issued while detached are not submitted.\n\t\t\t\tthis.commitEnricher.processChange(change);\n\t\t\t}\n\t\t\tif (change.type === \"append\") {\n\t\t\t\tfor (const commit of change.newCommits) {\n\t\t\t\t\tthis.submitCommit(commit, this.schemaAndPolicy, false);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tconst revisionTagCodec = new RevisionTagCodec(idCompressor);\n\t\tconst editManagerCodec = makeEditManagerCodec(\n\t\t\tthis.editManager.changeFamily.codecs,\n\t\t\trevisionTagCodec,\n\t\t\toptions,\n\t\t\tformatOptions.editManager,\n\t\t);\n\t\tthis.summarizables = [\n\t\t\tnew EditManagerSummarizer(\n\t\t\t\tthis.editManager,\n\t\t\t\teditManagerCodec,\n\t\t\t\tthis.idCompressor,\n\t\t\t\tthis.schemaAndPolicy,\n\t\t\t),\n\t\t\t...summarizables,\n\t\t];\n\t\tassert(\n\t\t\tnew Set(this.summarizables.map((e) => e.key)).size === this.summarizables.length,\n\t\t\t0x350 /* Index summary element keys must be unique */,\n\t\t);\n\n\t\tthis.messageCodec = makeMessageCodec(\n\t\t\tchangeFamily.codecs,\n\t\t\tnew RevisionTagCodec(idCompressor),\n\t\t\toptions,\n\t\t\tformatOptions.message,\n\t\t);\n\n\t\tconst changeEnricher = enricher ?? new NoOpChangeEnricher();\n\t\tthis.resubmitMachine =\n\t\t\tresubmitMachine ??\n\t\t\tnew DefaultResubmitMachine(\n\t\t\t\t(change: TaggedChange<TChange>) =>\n\t\t\t\t\tchangeFamily.rebaser.invert(change, true, this.mintRevisionTag()),\n\t\t\t\tchangeEnricher,\n\t\t\t);\n\t\tthis.commitEnricher = new BranchCommitEnricher(changeFamily.rebaser, changeEnricher);\n\t}\n\n\t// TODO: SharedObject's merging of the two summary methods into summarizeCore is not what we want here:\n\t// We might want to not subclass it, or override/reimplement most of its functionality.\n\t@throwIfBroken\n\tpublic summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tconst summarizableBuilder = new SummaryTreeBuilder();\n\t\t// Merge the summaries of all summarizables together under a single ISummaryTree\n\t\tfor (const s of this.summarizables) {\n\t\t\t// Add the summarizable's path in the summary tree to the incremental summary context's\n\t\t\t// summary path, so that the summarizable can use it to generate incremental summaries.\n\t\t\tconst childIncrementalSummaryContext =\n\t\t\t\tincrementalSummaryContext === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...incrementalSummaryContext,\n\t\t\t\t\t\t\tsummaryPath: `${incrementalSummaryContext.summaryPath}/${summarizablesTreeKey}/${s.key}`,\n\t\t\t\t\t\t};\n\t\t\tsummarizableBuilder.addWithStats(\n\t\t\t\ts.key,\n\t\t\t\ts.summarize({\n\t\t\t\t\tstringify: (contents: unknown) =>\n\t\t\t\t\t\tserializer.stringify(contents, this.sharedObject.handle),\n\t\t\t\t\tfullTree,\n\t\t\t\t\ttelemetryContext,\n\t\t\t\t\tincrementalSummaryContext: childIncrementalSummaryContext,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tbuilder.addWithStats(summarizablesTreeKey, summarizableBuilder.getSummaryTree());\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tpublic async loadCore(services: IChannelStorageService): Promise<void> {\n\t\tassert(\n\t\t\tthis.editManager.localBranch.getHead() === this.editManager.getTrunkHead(),\n\t\t\t0xaaa /* All local changes should be applied to the trunk before loading from summary */,\n\t\t);\n\t\tconst [editManagerSummarizer, ...summarizables] = this.summarizables;\n\t\tconst loadEditManager = this.loadSummarizable(editManagerSummarizer, services);\n\t\tconst loadSummarizables = summarizables.map(async (s) =>\n\t\t\tthis.loadSummarizable(s, services),\n\t\t);\n\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\t// If we are detached but loading from a summary, then we need to update our detached revision to ensure that it is ahead of all detached revisions in the summary.\n\t\t\t// First, finish loading the edit manager so that we can inspect the sequence numbers of the commits on the trunk.\n\t\t\tawait loadEditManager;\n\t\t\t// Find the most recent detached revision in the summary trunk...\n\t\t\tlet latestDetachedSequenceNumber: SeqNumber | undefined;\n\t\t\tfindAncestor(this.editManager.getTrunkHead(), (c) => {\n\t\t\t\tconst sequenceNumber = this.editManager.getSequenceNumber(c);\n\t\t\t\tif (sequenceNumber !== undefined && sequenceNumber < 0) {\n\t\t\t\t\tlatestDetachedSequenceNumber = sequenceNumber;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t});\n\t\t\t// ...and set our detached revision to be as it would be if we had been already created that revision.\n\t\t\tthis.detachedRevision = latestDetachedSequenceNumber ?? this.detachedRevision;\n\t\t\tawait Promise.all(loadSummarizables);\n\t\t} else {\n\t\t\tawait Promise.all([loadEditManager, ...loadSummarizables]);\n\t\t}\n\t}\n\n\tprivate async loadSummarizable(\n\t\tsummarizable: Summarizable,\n\t\tservices: IChannelStorageService,\n\t): Promise<void> {\n\t\treturn summarizable.load(\n\t\t\tscopeStorageService(services, summarizablesTreeKey, summarizable.key),\n\t\t\t(contents) => this.serializer.parse(contents),\n\t\t);\n\t}\n\n\t/**\n\t * Submits an op to the Fluid runtime containing the given commit\n\t * @param commit - the commit to submit\n\t * @returns the submitted commit. This is undefined if the underlying `SharedObject` is not attached,\n\t * and may differ from `commit` due to enrichments like detached tree refreshers.\n\t */\n\tprotected submitCommit(\n\t\tcommit: GraphCommit<TChange>,\n\t\tschemaAndPolicy: ClonableSchemaAndPolicy,\n\t\tisResubmit: boolean,\n\t): void {\n\t\tassert(\n\t\t\tthis.sharedObject.isAttached() === (this.detachedRevision === undefined),\n\t\t\t0x95a /* Detached revision should only be set when not attached */,\n\t\t);\n\n\t\tconst enrichedCommit =\n\t\t\tthis.detachedRevision === undefined && !isResubmit\n\t\t\t\t? this.commitEnricher.enrich(commit)\n\t\t\t\t: commit;\n\n\t\t// Edits submitted before the first attach are treated as sequenced because they will be included\n\t\t// in the attach summary that is uploaded to the service.\n\t\t// Until this attach workflow happens, this instance essentially behaves as a centralized data structure.\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\tconst newRevision: SeqNumber = brand((this.detachedRevision as number) + 1);\n\t\t\tthis.detachedRevision = newRevision;\n\t\t\tthis.editManager.addSequencedChanges(\n\t\t\t\t[enrichedCommit],\n\t\t\t\tthis.editManager.localSessionId,\n\t\t\t\tnewRevision,\n\t\t\t\tthis.detachedRevision,\n\t\t\t);\n\t\t\tthis.editManager.advanceMinimumSequenceNumber(newRevision, false);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst message = this.messageCodec.encode(\n\t\t\t{\n\t\t\t\tcommit: enrichedCommit,\n\t\t\t\tsessionId: this.editManager.localSessionId,\n\t\t\t},\n\t\t\t{\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t\tschema: schemaAndPolicy,\n\t\t\t},\n\t\t);\n\t\tthis.submitLocalMessage(message, {\n\t\t\t// Clone the schema to ensure that during resubmit the schema has not been mutated by later changes\n\t\t\tschema: schemaAndPolicy.schema.clone(),\n\t\t\tpolicy: schemaAndPolicy.policy,\n\t\t});\n\t\tthis.resubmitMachine.onCommitSubmitted(enrichedCommit);\n\t}\n\n\t/**\n\t * Process a bunch of messages from the runtime. SharedObject will call this method with a bunch of messages.\n\t */\n\tpublic processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tconst commits: GraphCommit<TChange>[] = [];\n\t\tlet messagesSessionId: SessionId | undefined;\n\n\t\t// Get a list of all the commits from the messages.\n\t\tfor (const messageContent of messagesContent) {\n\t\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\t\tconst { commit, sessionId } = this.messageCodec.decode(messageContent.contents, {\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t});\n\t\t\tcommits.push(commit);\n\n\t\t\tif (messagesSessionId !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tmessagesSessionId === sessionId,\n\t\t\t\t\t0xad9 /* All messages in a bunch must have the same session ID */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tmessagesSessionId = sessionId;\n\t\t}\n\n\t\tassert(messagesSessionId !== undefined, 0xada /* Messages must have a session ID */);\n\n\t\tthis.editManager.addSequencedChanges(\n\t\t\tcommits,\n\t\t\tmessagesSessionId,\n\t\t\tbrand(envelope.sequenceNumber),\n\t\t\tbrand(envelope.referenceSequenceNumber),\n\t\t);\n\n\t\t// Update the resubmit machine for each commit applied.\n\t\tfor (const _ of messagesContent) {\n\t\t\tthis.resubmitMachine.onSequencedCommitApplied(local);\n\t\t}\n\n\t\tthis.editManager.advanceMinimumSequenceNumber(brand(envelope.minimumSequenceNumber));\n\t}\n\n\tpublic getLocalBranch(): SharedTreeBranch<TEditor, TChange> {\n\t\treturn this.editManager.localBranch;\n\t}\n\n\tpublic didAttach(): void {\n\t\tthis.detachedRevision = undefined;\n\t}\n\n\tpublic reSubmitCore(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision },\n\t\t} = this.messageCodec.decode(this.serializer.decode(content), {\n\t\t\tidCompressor: this.idCompressor,\n\t\t});\n\t\t// If a resubmit phase is not already in progress, then this must be the first commit of a new resubmit phase.\n\t\tif (this.resubmitMachine.isInResubmitPhase === false) {\n\t\t\tconst localCommits = this.editManager.getLocalCommits();\n\t\t\tconst revisionIndex = localCommits.findIndex((c) => c.revision === revision);\n\t\t\tassert(revisionIndex >= 0, 0xbdb /* revision must exist in local commits */);\n\t\t\tconst toResubmit = localCommits.slice(revisionIndex);\n\t\t\tthis.resubmitMachine.prepareForResubmit(toResubmit);\n\t\t}\n\t\tassert(\n\t\t\tisClonableSchemaPolicy(localOpMetadata),\n\t\t\t0x95e /* Local metadata must contain schema and policy. */,\n\t\t);\n\t\tassert(\n\t\t\tthis.resubmitMachine.isInResubmitPhase !== false,\n\t\t\t0x984 /* Invalid resubmit outside of resubmit phase */,\n\t\t);\n\t\tconst enrichedCommit = this.resubmitMachine.peekNextCommit();\n\t\tthis.submitCommit(enrichedCommit, localOpMetadata, true);\n\t}\n\tpublic rollback(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision },\n\t\t} = this.messageCodec.decode(this.serializer.decode(content), {\n\t\t\tidCompressor: this.idCompressor,\n\t\t});\n\t\tconst [commit] = this.editManager.findLocalCommit(revision);\n\t\tconst { parent } = commit;\n\t\tassert(parent !== undefined, 0xbdc /* must have parent */);\n\t\tconst [precedingCommit] = this.editManager.findLocalCommit(parent.revision);\n\t\tthis.editManager.localBranch.removeAfter(precedingCommit);\n\t\tthis.resubmitMachine.onCommitRollback(commit);\n\t}\n\n\tpublic applyStashedOp(content: JsonCompatibleReadOnly): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision, change },\n\t\t} = this.messageCodec.decode(content, { idCompressor: this.idCompressor });\n\t\tthis.editManager.localBranch.apply({ change, revision });\n\t}\n}\n\nfunction isClonableSchemaPolicy(\n\tmaybeSchemaPolicy: unknown,\n): maybeSchemaPolicy is ClonableSchemaAndPolicy {\n\tconst schemaAndPolicy = maybeSchemaPolicy as ClonableSchemaAndPolicy;\n\treturn schemaAndPolicy.schema !== undefined && schemaAndPolicy.policy !== undefined;\n}\n\n/**\n * Specifies the behavior of a component that puts data in a summary.\n */\nexport interface Summarizable {\n\t/**\n\t * Field name in summary json under which this element stores its data.\n\t */\n\treadonly key: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.\n\t * @param fullTree - A flag indicating whether the attempt should generate a full\n\t * summary tree without any handles for unchanged subtrees. It should only be set to true when generating\n\t * a summary from the entire container. The default value is false.\n\t * @param trackState - An optimization for tracking state of objects across summaries. If the state\n\t * of an object did not change since last successful summary, an\n\t * {@link @fluidframework/protocol-definitions#ISummaryHandle} can be used\n\t * instead of re-summarizing it. If this is `false`, the expectation is that you should never\n\t * send an `ISummaryHandle`, since you are not expected to track state. The default value is true.\n\t * @param telemetryContext - See {@link @fluidframework/runtime-definitions#ITelemetryContext}.\n\t * @param incrementalSummaryContext - See {@link @fluidframework/runtime-definitions#IExperimentalIncrementalSummaryContext}.\n\t */\n\tsummarize(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t}): ISummaryTreeWithStats;\n\n\t/**\n\t * Allows the component to perform custom loading. The storage service is scoped to this component and therefore\n\t * paths in this component will not collide with those in other components, even if they are the same string.\n\t * @param service - Storage used by the component\n\t * @param parse - Parses serialized data from storage into runtime objects for the component\n\t */\n\tload(service: IChannelStorageService, parse: SummaryElementParser): Promise<void>;\n}\n\n/**\n * Serializes the given contents into a string acceptable for storing in summaries, i.e. all\n * Fluid handles have been replaced appropriately by an IFluidSerializer\n */\nexport type SummaryElementStringifier = (contents: unknown) => string;\n\n/**\n * Parses a serialized/summarized string into an object, rehydrating any Fluid handles as necessary\n */\nexport type SummaryElementParser = (contents: string) => unknown;\n\n/**\n * Compose an {@link IChannelStorageService} which prefixes all paths before forwarding them to the original service\n */\nfunction scopeStorageService(\n\tservice: IChannelStorageService,\n\t...pathElements: string[]\n): IChannelStorageService {\n\tconst scope = `${pathElements.join(\"/\")}/`;\n\n\treturn {\n\t\tasync readBlob(path: string): Promise<ArrayBufferLike> {\n\t\t\treturn service.readBlob(`${scope}${path}`);\n\t\t},\n\t\tasync contains(path) {\n\t\t\treturn service.contains(`${scope}${path}`);\n\t\t},\n\t\tasync list(path) {\n\t\t\treturn service.list(`${scope}${path}`);\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/configuration.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/configuration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EAMxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAajE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACzC;;;;;;;;;OASG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyEG;IACH,QAAQ,CAAC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AC,MAAM,EAAE,gBAAgB,GAAG,cAAc,CAAC,CAAC;CAC7E;AAWD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,EAC/B,gBAAgB,EAAE,OAAO,EACzB,eAAe,EAAE,MAAM,EAAE,GACvB,IAAI,CAmIN"}
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { assert, debugAssert, fail } from "@fluidframework/core-utils/internal";
|
|
5
|
+
import { assert, debugAssert, fail, oob, unreachableCase, } from "@fluidframework/core-utils/internal";
|
|
6
6
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
7
|
import { evaluateLazySchema, FieldKind, isAnnotatedAllowedType, markSchemaMostDerived, normalizeFieldSchema, } from "../schemaTypes.js";
|
|
8
8
|
import { NodeKind } from "../core/index.js";
|
|
9
9
|
import { toStoredSchema } from "../toStoredSchema.js";
|
|
10
|
-
import {
|
|
11
|
-
import { isObjectNodeSchema } from "../node-kinds/index.js";
|
|
10
|
+
import { isArrayNodeSchema, isMapNodeSchema, isObjectNodeSchema, isRecordNodeSchema, } from "../node-kinds/index.js";
|
|
12
11
|
import { getOrCreate } from "../../util/index.js";
|
|
13
12
|
import { walkFieldSchema } from "../walkFieldSchema.js";
|
|
14
13
|
const defaultTreeConfigurationOptions = {
|
|
@@ -104,6 +103,7 @@ export function checkUnion(union, preventAmbiguity, ambiguityErrors) {
|
|
|
104
103
|
const checked = new Set();
|
|
105
104
|
const maps = [];
|
|
106
105
|
const arrays = [];
|
|
106
|
+
const records = [];
|
|
107
107
|
const objects = [];
|
|
108
108
|
// Map from key to schema using that key
|
|
109
109
|
const allObjectKeys = new Map();
|
|
@@ -112,21 +112,37 @@ export function checkUnion(union, preventAmbiguity, ambiguityErrors) {
|
|
|
112
112
|
throw new UsageError(`Duplicate schema in allowed types: ${schema.identifier}`);
|
|
113
113
|
}
|
|
114
114
|
checked.add(schema);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
switch (schema.kind) {
|
|
116
|
+
case NodeKind.Leaf: {
|
|
117
|
+
// nothing to do
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
case NodeKind.Object: {
|
|
121
|
+
assert(isObjectNodeSchema(schema), 0xbde /* Expected object schema. */);
|
|
122
|
+
objects.push(schema);
|
|
123
|
+
for (const key of schema.fields.keys()) {
|
|
124
|
+
getOrCreate(allObjectKeys, key, () => new Set()).add(schema);
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case NodeKind.Array: {
|
|
129
|
+
assert(isArrayNodeSchema(schema), 0xbdf /* Expected array schema. */);
|
|
130
|
+
arrays.push(schema);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case NodeKind.Map: {
|
|
134
|
+
assert(isMapNodeSchema(schema), 0xbe0 /* Expected map schema. */);
|
|
135
|
+
maps.push(schema);
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case NodeKind.Record: {
|
|
139
|
+
assert(isRecordNodeSchema(schema), 0xbe1 /* Expected record schema. */);
|
|
140
|
+
records.push(schema);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
default: {
|
|
144
|
+
unreachableCase(schema.kind);
|
|
122
145
|
}
|
|
123
|
-
}
|
|
124
|
-
else if (schema.kind === NodeKind.Array) {
|
|
125
|
-
arrays.push(schema);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
assert(schema.kind === NodeKind.Map, 0x9e7 /* invalid schema */);
|
|
129
|
-
maps.push(schema);
|
|
130
146
|
}
|
|
131
147
|
}
|
|
132
148
|
if (!preventAmbiguity) {
|
|
@@ -139,11 +155,27 @@ export function checkUnion(union, preventAmbiguity, ambiguityErrors) {
|
|
|
139
155
|
if (maps.length > 1) {
|
|
140
156
|
ambiguityErrors.push(`More than one kind of map allowed within union (${formatTypes(maps)}). This would require type disambiguation which is not supported by maps during import or export.`);
|
|
141
157
|
}
|
|
158
|
+
if (records.length > 1) {
|
|
159
|
+
ambiguityErrors.push(`More than one kind of record allowed within union (${formatTypes(records)}). This would require type disambiguation which is not supported by records during import or export.`);
|
|
160
|
+
}
|
|
142
161
|
if (maps.length > 0 && arrays.length > 0) {
|
|
143
162
|
ambiguityErrors.push(`Both a map and an array allowed within union (${formatTypes([...arrays, ...maps])}). Both can be implicitly constructed from iterables like arrays, which are ambiguous when the array is empty.`);
|
|
144
163
|
}
|
|
145
|
-
|
|
146
|
-
|
|
164
|
+
const nodeKindListEntries = [];
|
|
165
|
+
if (objects.length > 0) {
|
|
166
|
+
nodeKindListEntries.push("objects");
|
|
167
|
+
}
|
|
168
|
+
if (maps.length > 0) {
|
|
169
|
+
nodeKindListEntries.push("maps");
|
|
170
|
+
}
|
|
171
|
+
if (records.length > 0) {
|
|
172
|
+
nodeKindListEntries.push("records");
|
|
173
|
+
}
|
|
174
|
+
if (nodeKindListEntries.length > 1) {
|
|
175
|
+
const nodeKindListString = nodeKindListEntries.length === 2
|
|
176
|
+
? `${nodeKindListEntries[0] ?? oob()} and ${nodeKindListEntries[1] ?? oob()}`
|
|
177
|
+
: `${nodeKindListEntries.slice(0, -1).join(", ")}, and ${nodeKindListEntries[nodeKindListEntries.length - 1]}`;
|
|
178
|
+
ambiguityErrors.push(`A combination of ${nodeKindListString} is allowed within union (${formatTypes([...objects, ...maps, ...records])}). These can be constructed from objects and can be ambiguous.`);
|
|
147
179
|
}
|
|
148
180
|
// Check for objects which fully overlap:
|
|
149
181
|
for (const schema of objects) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/simple-tree/api/configuration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA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C,MAAM,CAAC,MAAM,CAAC,CAAC;QAEjC,6FAA6F;QAC7F,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAC1C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,QAAQ,EAAE,CAAC;gBACvC,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;gBAC3E,KAAK,MAAM,SAAS,IAAI,iBAAiB,EAAE,CAAC;oBAC3C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;wBAC7B,iBAAiB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;oBACrC,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,iBAAiB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAChC,yCAAyC;YACzC,8EAA8E;YAC9E,kJAAkJ;YAClJ,4MAA4M;YAC5M,mJAAmJ;YAEnJ,eAAe,CAAC,IAAI,CACnB,0BAA0B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,mEAAmE,WAAW,CAAC,iBAAiB,CAAC,oIAAoI,CAChS,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, debugAssert, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype FieldSchemaAlpha,\n\ttype ImplicitFieldSchema,\n\tevaluateLazySchema,\n\tFieldKind,\n\tisAnnotatedAllowedType,\n\tmarkSchemaMostDerived,\n\tnormalizeFieldSchema,\n} from \"../schemaTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema, type ObjectNodeSchema } from \"../node-kinds/index.js\";\nimport { getOrCreate } from \"../../util/index.js\";\nimport type { MakeNominal } from \"../../util/index.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.js\";\nimport type { SimpleNodeSchema, SimpleTreeSchema } from \"../simpleSchema.js\";\n\n/**\n * Options when constructing a tree view.\n * @public\n */\nexport interface ITreeConfigurationOptions {\n\t/**\n\t * If `true`, the tree will validate new content against its stored schema at insertion time\n\t * and throw an error if the new content doesn't match the expected schema.\n\t *\n\t * @defaultValue `false`.\n\t *\n\t * @remarks Enabling schema validation has a performance penalty when inserting new content into the tree because\n\t * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a\n\t * bit slower.\n\t */\n\tenableSchemaValidation?: boolean;\n\n\t/**\n\t * A flag used to opt into strict rules ensuring that the schema avoids cases which can make the type of nodes ambiguous when importing or exporting data.\n\t * @defaultValue `false`.\n\t *\n\t * @remarks\n\t * When this is true, it ensures that the compile time type safety for data when constructing nodes is sufficient to ensure that the runtime behavior will not give node data ambiguity errors.\n\t *\n\t * This ensures that the canonical JSON-like representation of all unions in the tree are lossless and unambiguous.\n\t * This canonical JSON-like representation consists of arrays, plain old JavaScript objects with string keys, booleans, numbers (excluding NaN, -0 and infinities), strings, null and {@link @fluidframework/core-interfaces#IFluidHandle}s.\n\t * It is compatible with the node creation APIs (such as schema class constructors) and is also compatible with JSON assuming any IFluidHandles get special handling (since they are not JSON compatible).\n\t * Currently these cases can cause ambiguity in a union:\n\t *\n\t * - More than one ArrayNode type: it's impossible to tell which array type is intended in the case of empty arrays (`[]`).\n\t *\n\t * - More than one MapNode type: it's impossible to tell which map type is intended in the case of an empty map (`{}`).\n\t *\n\t * - Both a MapNode and an ArrayNode: this case is not a problem for the canonical JSON representation, but is an issue when constructing from an Iterable, which is supported for both MapNode and ArrayNode.\n\t *\n\t * - Both a MapNode and an ObjectNode: when the input is valid for the ObjectNode, the current parser always considers it ambiguous with being a MapNode.\n\t *\n\t * - ObjectNodes which have fields (required or optional) which include all required fields of another ObjectNode: currently each ObjectNode is differentiated by the presence of its required fields.\n\t *\n\t * This check is conservative: some complex cases may error if the current simple algorithm cannot show no ambiguity is possible.\n\t * This check may become more permissive over time.\n\t *\n\t * @example Ambiguous schema (with `preventAmbiguity: false`), and how to disambiguate it using {@link Unhydrated} nodes:\n\t * ```typescript\n\t * const schemaFactory = new SchemaFactory(\"com.example\");\n\t * class Feet extends schemaFactory.object(\"Feet\", { length: schemaFactory.number }) {}\n\t * class Meters extends schemaFactory.object(\"Meters\", { length: schemaFactory.number }) {}\n\t * const config = new TreeViewConfiguration({\n\t * \t// This combination of schema can lead to ambiguous cases and will error if `preventAmbiguity` is true.\n\t * \tschema: [Feet, Meters],\n\t * \tpreventAmbiguity: false,\n\t * });\n\t * const view = tree.viewWith(config);\n\t * // This is invalid since it is ambiguous which type of node is being constructed:\n\t * // view.initialize({ length: 5 });\n\t * // To work, an explicit type can be provided by using an {@link Unhydrated} Node:\n\t * view.initialize(new Meters({ length: 5 }));\n\t * ```\n\t *\n\t * @example Schema disambiguated by adjusting field names, validated with `preventAmbiguity: true:`\n\t * ```typescript\n\t * const schemaFactory = new SchemaFactory(\"com.example\");\n\t * class Feet extends schemaFactory.object(\"Feet\", { length: schemaFactory.number }) {}\n\t * class Meters extends schemaFactory.object(\"Meters\", {\n\t * \t// To avoid ambiguity when parsing unions of Feet and Meters, this renames the length field to \"meters\".\n\t * \t// To preserve compatibility with existing data from the ambiguous case,\n\t * \t// `{ key: \"length\" }` is set, so when persisted in the tree \"length\" is used as the field name.\n\t * \tmeters: schemaFactory.required(schemaFactory.number, { key: \"length\" }),\n\t * }) {}\n\t * const config = new TreeViewConfiguration({\n\t * \t// This combination of schema is not ambiguous because `Feet` and `Meters` have different required keys.\n\t * \tschema: [Feet, Meters],\n\t * \tpreventAmbiguity: true,\n\t * });\n\t * const view = tree.viewWith(config);\n\t * // This now works, since the field is sufficient to determine this is a `Meters` node.\n\t * view.initialize({ meters: 5 });\n\t * ```\n\t *\n\t * @privateRemarks\n\t * In the future, we can support lossless round tripping via the canonical JSON-like representation above when unambiguous.\n\t * This could be done via methods added to `Tree` to export and import such objects, which would give us a place to explicitly define the type of this representation.\n\t *\n\t * To make this more permissive in the future we can:\n\t *\n\t * - Make unhydratedFlexTreeFromInsertable more permissive (ex: allow disambiguation based on leaf type)\n\t * - Update this check to more tightly match unhydratedFlexTreeFromInsertable\n\t * - Add options to help schema authors disambiguate their types, such as \"constant fields\" which are not persisted, and always have a constant value.\n\t *\n\t * The above examples exist in executable form in this files tests, and should be updated there then copied back here.\n\t */\n\treadonly preventAmbiguity?: boolean;\n}\n\nconst defaultTreeConfigurationOptions: Required<ITreeConfigurationOptions> = {\n\tenableSchemaValidation: false,\n\tpreventAmbiguity: false,\n};\n\n/**\n * Property-bag configuration for {@link TreeViewConfiguration} construction.\n * @public\n */\nexport interface ITreeViewConfiguration<\n\tTSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> extends ITreeConfigurationOptions {\n\t/**\n\t * The schema which the application wants to view the tree with.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * Configuration for {@link ViewableTree.viewWith}.\n * @sealed @public\n */\nexport class TreeViewConfiguration<\n\tconst TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> implements Required<ITreeViewConfiguration<TSchema>>\n{\n\tprotected _typeCheck!: MakeNominal;\n\n\t/**\n\t * {@inheritDoc ITreeViewConfiguration.schema}\n\t */\n\tpublic readonly schema: TSchema;\n\n\t/**\n\t * {@inheritDoc ITreeConfigurationOptions.enableSchemaValidation}\n\t */\n\tpublic readonly enableSchemaValidation: boolean;\n\n\t/**\n\t * {@inheritDoc ITreeConfigurationOptions.preventAmbiguity}\n\t */\n\tpublic readonly preventAmbiguity: boolean;\n\n\t/**\n\t * {@link TreeSchema.definitions} but with public types.\n\t */\n\tprotected readonly definitionsInternal: ReadonlyMap<string, TreeNodeSchema>;\n\n\t/**\n\t * Construct a new {@link TreeViewConfiguration}.\n\t *\n\t * @param props - Property bag of configuration options.\n\t *\n\t * @remarks\n\t * Performing this construction deeply validates the provided schema.\n\t * This means that when this constructor is called, all {@link LazyItem} {@link TreeNodeSchema} references will be evaluated (using {@link evaluateLazySchema}).\n\t * This means that the declarations for all transitively reachable {@link TreeNodeSchema} must be available at this time.\n\t *\n\t * For example, a schema reachable from this configuration cannot reference this configuration during its declaration,\n\t * since this would be a cyclic dependency that will cause an error when constructing this configuration.\n\t */\n\tpublic constructor(props: ITreeViewConfiguration<TSchema>) {\n\t\tconst config = { ...defaultTreeConfigurationOptions, ...props };\n\t\tthis.schema = config.schema;\n\t\tthis.enableSchemaValidation = config.enableSchemaValidation;\n\t\tthis.preventAmbiguity = config.preventAmbiguity;\n\n\t\t// Ambiguity errors are lower priority to report than invalid schema errors, so collect these in an array and report them all at once.\n\t\tconst ambiguityErrors: string[] = [];\n\n\t\t// Eagerly perform this conversion to surface errors sooner.\n\t\t// Includes detection of duplicate schema identifiers.\n\t\ttoStoredSchema(config.schema);\n\n\t\tconst definitions = new Map<string, SimpleNodeSchema & TreeNodeSchema>();\n\n\t\twalkFieldSchema(config.schema, {\n\t\t\tnode: (schema) => {\n\t\t\t\t// Ensure all reachable schema are marked as most derived.\n\t\t\t\t// This ensures if multiple schema extending the same schema factory generated class are present (or have had instances of them constructed, or get instances of them constructed in the future),\n\t\t\t\t// an error is reported.\n\t\t\t\tmarkSchemaMostDerived(schema, true);\n\n\t\t\t\tdebugAssert(() => !definitions.has(schema.identifier));\n\t\t\t\tdefinitions.set(schema.identifier, schema as SimpleNodeSchema & TreeNodeSchema);\n\t\t\t},\n\t\t\tallowedTypes({ types }): void {\n\t\t\t\tcheckUnion(\n\t\t\t\t\ttypes.map((t) => evaluateLazySchema(isAnnotatedAllowedType(t) ? t.type : t)),\n\t\t\t\t\tconfig.preventAmbiguity,\n\t\t\t\t\tambiguityErrors,\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\n\t\tthis.definitionsInternal = definitions;\n\n\t\tif (ambiguityErrors.length !== 0) {\n\t\t\t// Duplicate errors are common since when two types conflict, both orders error:\n\t\t\tconst deduplicated = new Set(ambiguityErrors);\n\t\t\tthrow new UsageError(`Ambiguous schema found:\\n${[...deduplicated].join(\"\\n\")}`);\n\t\t}\n\t}\n}\n\n/**\n * {@link TreeViewConfiguration} extended with some alpha APIs.\n * @sealed @alpha\n */\nexport class TreeViewConfigurationAlpha<\n\t\tconst TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n\t>\n\textends TreeViewConfiguration<TSchema>\n\timplements TreeSchema\n{\n\t/**\n\t * {@inheritDoc TreeSchema.root}\n\t */\n\tpublic readonly root: FieldSchemaAlpha;\n\n\t/**\n\t * {@inheritDoc TreeSchema.definitions}\n\t */\n\tpublic get definitions(): ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema> {\n\t\treturn this.definitionsInternal as ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;\n\t}\n\n\tpublic constructor(props: ITreeViewConfiguration<TSchema>) {\n\t\tsuper(props);\n\t\tthis.root = normalizeFieldSchema(props.schema);\n\t}\n}\n\n/**\n * {@link TreeViewConfigurationAlpha}\n * @sealed @alpha\n */\nexport interface TreeSchema extends SimpleTreeSchema {\n\t/**\n\t * {@inheritDoc SimpleTreeSchema.root}\n\t */\n\treadonly root: FieldSchemaAlpha;\n\n\t/**\n\t * {@inheritDoc SimpleTreeSchema.definitions}\n\t */\n\treadonly definitions: ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;\n}\n\n/**\n * Pretty print a set of types for use in error messages.\n */\nfunction formatTypes(allowed: Iterable<TreeNodeSchema>): string {\n\t// Use JSON.stringify to quote and escape identifiers.\n\t// Don't just use a single array JSON.stringify since that omits spaces between items\n\treturn `[${Array.from(allowed, (s) => JSON.stringify(s.identifier)).join(\", \")}]`;\n}\n\n/**\n * Check if union contents are valid (shallowly).\n *\n * @param union - The union of {@link TreeNodeSchema} to check.\n * @param preventAmbiguity - If true, detect cases documented in {@link ITreeConfigurationOptions.preventAmbiguity}, reporting them to `ambiguityErrors`.\n * @param ambiguityErrors - An array into which this function inserts any ambiguity errors, see {@link ITreeConfigurationOptions.preventAmbiguity}.\n *\n * @remarks\n * Includes checks for non-ambiguity errors as well: such as duplicate schemas in the union.\n * Any non-ambiguity errors are thrown as exceptions: `UsageError`s if causable by incorrect API use, and asserts if violating internal invariants.\n */\nexport function checkUnion(\n\tunion: Iterable<TreeNodeSchema>,\n\tpreventAmbiguity: boolean,\n\tambiguityErrors: string[],\n): void {\n\tconst checked: Set<TreeNodeSchema> = new Set();\n\tconst maps: TreeNodeSchema[] = [];\n\tconst arrays: TreeNodeSchema[] = [];\n\n\tconst objects: ObjectNodeSchema[] = [];\n\t// Map from key to schema using that key\n\tconst allObjectKeys: Map<string, Set<TreeNodeSchema>> = new Map();\n\n\tfor (const schema of union) {\n\t\tif (checked.has(schema)) {\n\t\t\tthrow new UsageError(`Duplicate schema in allowed types: ${schema.identifier}`);\n\t\t}\n\t\tchecked.add(schema);\n\n\t\tif (schema instanceof LeafNodeSchema) {\n\t\t\t// nothing to do\n\t\t} else if (isObjectNodeSchema(schema)) {\n\t\t\tobjects.push(schema);\n\t\t\tfor (const key of schema.fields.keys()) {\n\t\t\t\tgetOrCreate(allObjectKeys, key, () => new Set()).add(schema);\n\t\t\t}\n\t\t} else if (schema.kind === NodeKind.Array) {\n\t\t\tarrays.push(schema);\n\t\t} else {\n\t\t\tassert(schema.kind === NodeKind.Map, 0x9e7 /* invalid schema */);\n\t\t\tmaps.push(schema);\n\t\t}\n\t}\n\n\tif (!preventAmbiguity) {\n\t\t// All remaining checks are for the preventAmbiguity case, so skip them if not enabled.\n\t\treturn;\n\t}\n\n\tif (arrays.length > 1) {\n\t\tambiguityErrors.push(\n\t\t\t`More than one kind of array allowed within union (${formatTypes(arrays)}). This would require type disambiguation which is not supported by arrays during import or export.`,\n\t\t);\n\t}\n\n\tif (maps.length > 1) {\n\t\tambiguityErrors.push(\n\t\t\t`More than one kind of map allowed within union (${formatTypes(maps)}). This would require type disambiguation which is not supported by maps during import or export.`,\n\t\t);\n\t}\n\n\tif (maps.length > 0 && arrays.length > 0) {\n\t\tambiguityErrors.push(\n\t\t\t`Both a map and an array allowed within union (${formatTypes([...arrays, ...maps])}). Both can be implicitly constructed from iterables like arrays, which are ambiguous when the array is empty.`,\n\t\t);\n\t}\n\n\tif (objects.length > 0 && maps.length > 0) {\n\t\tambiguityErrors.push(\n\t\t\t`Both a object and a map allowed within union (${formatTypes([...objects, ...maps])}). Both can be constructed from objects and can be ambiguous.`,\n\t\t);\n\t}\n\n\t// Check for objects which fully overlap:\n\tfor (const schema of objects) {\n\t\t// All objects which might be ambiguous relative to `schema`.\n\t\tconst possiblyAmbiguous = new Set(objects);\n\n\t\t// A schema can't be ambiguous with itself\n\t\tpossiblyAmbiguous.delete(schema);\n\n\t\t// For each field of schema, remove schema from possiblyAmbiguous that do not have that field\n\t\tfor (const [key, field] of schema.fields) {\n\t\t\tif (field.kind === FieldKind.Required) {\n\t\t\t\tconst withKey = allObjectKeys.get(key) ?? fail(0xb35 /* missing schema */);\n\t\t\t\tfor (const candidate of possiblyAmbiguous) {\n\t\t\t\t\tif (!withKey.has(candidate)) {\n\t\t\t\t\t\tpossiblyAmbiguous.delete(candidate);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (possiblyAmbiguous.size > 0) {\n\t\t\t// TODO: make this check more permissive.\n\t\t\t// Allow using the type of the field to disambiguate, at least for leaf types.\n\t\t\t// Add \"constant\" fields which can be used to disambiguate even more cases without adding persisted data: maybe make them optional in constructor?\n\t\t\t// Consider separating unambiguous implicit construction format from constructor arguments at type level, allowing constructor to superset the implicit construction options (ex: optional constant fields).\n\t\t\t// The policy here however must remain at least as conservative as shallowCompatibilityTest in src/simple-tree/unhydratedFlexTreeFromInsertable.ts.\n\n\t\t\tambiguityErrors.push(\n\t\t\t\t`The required fields of ${JSON.stringify(schema.identifier)} are insufficient to differentiate it from the following types: ${formatTypes(possiblyAmbiguous)}. For objects to be considered unambiguous, each must have required fields that do not all occur on any other object in the union.`,\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/simple-tree/api/configuration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,WAAW,EACX,IAAI,EACJ,GAAG,EACH,eAAe,GACf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAGN,kBAAkB,EAClB,SAAS,EACT,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACN,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GAKlB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAiGxD,MAAM,+BAA+B,GAAwC;IAC5E,sBAAsB,EAAE,KAAK;IAC7B,gBAAgB,EAAE,KAAK;CACvB,CAAC;AAeF;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IA0BjC;;;;;;;;;;;;OAYG;IACH,YAAmB,KAAsC;QACxD,MAAM,MAAM,GAAG,EAAE,GAAG,+BAA+B,EAAE,GAAG,KAAK,EAAE,CAAC;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,sBAAsB,CAAC;QAC5D,IAAI,CAAC,gBAAgB,GAAG,MAA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C5M,mJAAmJ;YAEnJ,eAAe,CAAC,IAAI,CACnB,0BAA0B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,mEAAmE,WAAW,CAAC,iBAAiB,CAAC,oIAAoI,CAChS,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC","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\toob,\n\tunreachableCase,\n} from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype FieldSchemaAlpha,\n\ttype ImplicitFieldSchema,\n\tevaluateLazySchema,\n\tFieldKind,\n\tisAnnotatedAllowedType,\n\tmarkSchemaMostDerived,\n\tnormalizeFieldSchema,\n} from \"../schemaTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\nimport {\n\tisArrayNodeSchema,\n\tisMapNodeSchema,\n\tisObjectNodeSchema,\n\tisRecordNodeSchema,\n\ttype ArrayNodeSchema,\n\ttype MapNodeSchema,\n\ttype ObjectNodeSchema,\n\ttype RecordNodeSchema,\n} from \"../node-kinds/index.js\";\nimport { getOrCreate } from \"../../util/index.js\";\nimport type { MakeNominal } from \"../../util/index.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.js\";\nimport type { SimpleNodeSchema, SimpleTreeSchema } from \"../simpleSchema.js\";\n\n/**\n * Options when constructing a tree view.\n * @public\n */\nexport interface ITreeConfigurationOptions {\n\t/**\n\t * If `true`, the tree will validate new content against its stored schema at insertion time\n\t * and throw an error if the new content doesn't match the expected schema.\n\t *\n\t * @defaultValue `false`.\n\t *\n\t * @remarks Enabling schema validation has a performance penalty when inserting new content into the tree because\n\t * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a\n\t * bit slower.\n\t */\n\tenableSchemaValidation?: boolean;\n\n\t/**\n\t * A flag used to opt into strict rules ensuring that the schema avoids cases which can make the type of nodes ambiguous when importing or exporting data.\n\t * @defaultValue `false`.\n\t *\n\t * @remarks\n\t * When this is true, it ensures that the compile time type safety for data when constructing nodes is sufficient to ensure that the runtime behavior will not give node data ambiguity errors.\n\t *\n\t * This ensures that the canonical JSON-like representation of all unions in the tree are lossless and unambiguous.\n\t * This canonical JSON-like representation consists of arrays, plain old JavaScript objects with string keys, booleans, numbers (excluding NaN, -0 and infinities), strings, null and {@link @fluidframework/core-interfaces#IFluidHandle}s.\n\t * It is compatible with the node creation APIs (such as schema class constructors) and is also compatible with JSON assuming any IFluidHandles get special handling (since they are not JSON compatible).\n\t * Currently these cases can cause ambiguity in a union:\n\t *\n\t * - More than one ArrayNode type: it's impossible to tell which array type is intended in the case of empty arrays (`[]`).\n\t *\n\t * - More than one MapNode type: it's impossible to tell which map type is intended in the case of an empty map (`{}`).\n\t *\n\t * - Both a MapNode and an ArrayNode: this case is not a problem for the canonical JSON representation, but is an issue when constructing from an Iterable, which is supported for both MapNode and ArrayNode.\n\t *\n\t * - Both a MapNode and an ObjectNode: when the input is valid for the ObjectNode, the current parser always considers it ambiguous with being a MapNode.\n\t *\n\t * - ObjectNodes which have fields (required or optional) which include all required fields of another ObjectNode: currently each ObjectNode is differentiated by the presence of its required fields.\n\t *\n\t * This check is conservative: some complex cases may error if the current simple algorithm cannot show no ambiguity is possible.\n\t * This check may become more permissive over time.\n\t *\n\t * @example Ambiguous schema (with `preventAmbiguity: false`), and how to disambiguate it using {@link Unhydrated} nodes:\n\t * ```typescript\n\t * const schemaFactory = new SchemaFactory(\"com.example\");\n\t * class Feet extends schemaFactory.object(\"Feet\", { length: schemaFactory.number }) {}\n\t * class Meters extends schemaFactory.object(\"Meters\", { length: schemaFactory.number }) {}\n\t * const config = new TreeViewConfiguration({\n\t * \t// This combination of schema can lead to ambiguous cases and will error if `preventAmbiguity` is true.\n\t * \tschema: [Feet, Meters],\n\t * \tpreventAmbiguity: false,\n\t * });\n\t * const view = tree.viewWith(config);\n\t * // This is invalid since it is ambiguous which type of node is being constructed:\n\t * // view.initialize({ length: 5 });\n\t * // To work, an explicit type can be provided by using an {@link Unhydrated} Node:\n\t * view.initialize(new Meters({ length: 5 }));\n\t * ```\n\t *\n\t * @example Schema disambiguated by adjusting field names, validated with `preventAmbiguity: true:`\n\t * ```typescript\n\t * const schemaFactory = new SchemaFactory(\"com.example\");\n\t * class Feet extends schemaFactory.object(\"Feet\", { length: schemaFactory.number }) {}\n\t * class Meters extends schemaFactory.object(\"Meters\", {\n\t * \t// To avoid ambiguity when parsing unions of Feet and Meters, this renames the length field to \"meters\".\n\t * \t// To preserve compatibility with existing data from the ambiguous case,\n\t * \t// `{ key: \"length\" }` is set, so when persisted in the tree \"length\" is used as the field name.\n\t * \tmeters: schemaFactory.required(schemaFactory.number, { key: \"length\" }),\n\t * }) {}\n\t * const config = new TreeViewConfiguration({\n\t * \t// This combination of schema is not ambiguous because `Feet` and `Meters` have different required keys.\n\t * \tschema: [Feet, Meters],\n\t * \tpreventAmbiguity: true,\n\t * });\n\t * const view = tree.viewWith(config);\n\t * // This now works, since the field is sufficient to determine this is a `Meters` node.\n\t * view.initialize({ meters: 5 });\n\t * ```\n\t *\n\t * @privateRemarks\n\t * In the future, we can support lossless round tripping via the canonical JSON-like representation above when unambiguous.\n\t * This could be done via methods added to `Tree` to export and import such objects, which would give us a place to explicitly define the type of this representation.\n\t *\n\t * To make this more permissive in the future we can:\n\t *\n\t * - Make unhydratedFlexTreeFromInsertable more permissive (ex: allow disambiguation based on leaf type)\n\t * - Update this check to more tightly match unhydratedFlexTreeFromInsertable\n\t * - Add options to help schema authors disambiguate their types, such as \"constant fields\" which are not persisted, and always have a constant value.\n\t *\n\t * The above examples exist in executable form in this files tests, and should be updated there then copied back here.\n\t */\n\treadonly preventAmbiguity?: boolean;\n}\n\nconst defaultTreeConfigurationOptions: Required<ITreeConfigurationOptions> = {\n\tenableSchemaValidation: false,\n\tpreventAmbiguity: false,\n};\n\n/**\n * Property-bag configuration for {@link TreeViewConfiguration} construction.\n * @public\n */\nexport interface ITreeViewConfiguration<\n\tTSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> extends ITreeConfigurationOptions {\n\t/**\n\t * The schema which the application wants to view the tree with.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * Configuration for {@link ViewableTree.viewWith}.\n * @sealed @public\n */\nexport class TreeViewConfiguration<\n\tconst TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> implements Required<ITreeViewConfiguration<TSchema>>\n{\n\tprotected _typeCheck!: MakeNominal;\n\n\t/**\n\t * {@inheritDoc ITreeViewConfiguration.schema}\n\t */\n\tpublic readonly schema: TSchema;\n\n\t/**\n\t * {@inheritDoc ITreeConfigurationOptions.enableSchemaValidation}\n\t */\n\tpublic readonly enableSchemaValidation: boolean;\n\n\t/**\n\t * {@inheritDoc ITreeConfigurationOptions.preventAmbiguity}\n\t */\n\tpublic readonly preventAmbiguity: boolean;\n\n\t/**\n\t * {@link TreeSchema.definitions} but with public types.\n\t */\n\tprotected readonly definitionsInternal: ReadonlyMap<string, TreeNodeSchema>;\n\n\t/**\n\t * Construct a new {@link TreeViewConfiguration}.\n\t *\n\t * @param props - Property bag of configuration options.\n\t *\n\t * @remarks\n\t * Performing this construction deeply validates the provided schema.\n\t * This means that when this constructor is called, all {@link LazyItem} {@link TreeNodeSchema} references will be evaluated (using {@link evaluateLazySchema}).\n\t * This means that the declarations for all transitively reachable {@link TreeNodeSchema} must be available at this time.\n\t *\n\t * For example, a schema reachable from this configuration cannot reference this configuration during its declaration,\n\t * since this would be a cyclic dependency that will cause an error when constructing this configuration.\n\t */\n\tpublic constructor(props: ITreeViewConfiguration<TSchema>) {\n\t\tconst config = { ...defaultTreeConfigurationOptions, ...props };\n\t\tthis.schema = config.schema;\n\t\tthis.enableSchemaValidation = config.enableSchemaValidation;\n\t\tthis.preventAmbiguity = config.preventAmbiguity;\n\n\t\t// Ambiguity errors are lower priority to report than invalid schema errors, so collect these in an array and report them all at once.\n\t\tconst ambiguityErrors: string[] = [];\n\n\t\t// Eagerly perform this conversion to surface errors sooner.\n\t\t// Includes detection of duplicate schema identifiers.\n\t\ttoStoredSchema(config.schema);\n\n\t\tconst definitions = new Map<string, SimpleNodeSchema & TreeNodeSchema>();\n\n\t\twalkFieldSchema(config.schema, {\n\t\t\tnode: (schema) => {\n\t\t\t\t// Ensure all reachable schema are marked as most derived.\n\t\t\t\t// This ensures if multiple schema extending the same schema factory generated class are present (or have had instances of them constructed, or get instances of them constructed in the future),\n\t\t\t\t// an error is reported.\n\t\t\t\tmarkSchemaMostDerived(schema, true);\n\n\t\t\t\tdebugAssert(() => !definitions.has(schema.identifier));\n\t\t\t\tdefinitions.set(schema.identifier, schema as SimpleNodeSchema & TreeNodeSchema);\n\t\t\t},\n\t\t\tallowedTypes({ types }): void {\n\t\t\t\tcheckUnion(\n\t\t\t\t\ttypes.map((t) => evaluateLazySchema(isAnnotatedAllowedType(t) ? t.type : t)),\n\t\t\t\t\tconfig.preventAmbiguity,\n\t\t\t\t\tambiguityErrors,\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\n\t\tthis.definitionsInternal = definitions;\n\n\t\tif (ambiguityErrors.length !== 0) {\n\t\t\t// Duplicate errors are common since when two types conflict, both orders error:\n\t\t\tconst deduplicated = new Set(ambiguityErrors);\n\t\t\tthrow new UsageError(`Ambiguous schema found:\\n${[...deduplicated].join(\"\\n\")}`);\n\t\t}\n\t}\n}\n\n/**\n * {@link TreeViewConfiguration} extended with some alpha APIs.\n * @sealed @alpha\n */\nexport class TreeViewConfigurationAlpha<\n\t\tconst TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n\t>\n\textends TreeViewConfiguration<TSchema>\n\timplements TreeSchema\n{\n\t/**\n\t * {@inheritDoc TreeSchema.root}\n\t */\n\tpublic readonly root: FieldSchemaAlpha;\n\n\t/**\n\t * {@inheritDoc TreeSchema.definitions}\n\t */\n\tpublic get definitions(): ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema> {\n\t\treturn this.definitionsInternal as ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;\n\t}\n\n\tpublic constructor(props: ITreeViewConfiguration<TSchema>) {\n\t\tsuper(props);\n\t\tthis.root = normalizeFieldSchema(props.schema);\n\t}\n}\n\n/**\n * {@link TreeViewConfigurationAlpha}\n * @sealed @alpha\n */\nexport interface TreeSchema extends SimpleTreeSchema {\n\t/**\n\t * {@inheritDoc SimpleTreeSchema.root}\n\t */\n\treadonly root: FieldSchemaAlpha;\n\n\t/**\n\t * {@inheritDoc SimpleTreeSchema.definitions}\n\t */\n\treadonly definitions: ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;\n}\n\n/**\n * Pretty print a set of types for use in error messages.\n */\nfunction formatTypes(allowed: Iterable<TreeNodeSchema>): string {\n\t// Use JSON.stringify to quote and escape identifiers.\n\t// Don't just use a single array JSON.stringify since that omits spaces between items\n\treturn `[${Array.from(allowed, (s) => JSON.stringify(s.identifier)).join(\", \")}]`;\n}\n\n/**\n * Check if union contents are valid (shallowly).\n *\n * @param union - The union of {@link TreeNodeSchema} to check.\n * @param preventAmbiguity - If true, detect cases documented in {@link ITreeConfigurationOptions.preventAmbiguity}, reporting them to `ambiguityErrors`.\n * @param ambiguityErrors - An array into which this function inserts any ambiguity errors, see {@link ITreeConfigurationOptions.preventAmbiguity}.\n *\n * @remarks\n * Includes checks for non-ambiguity errors as well: such as duplicate schemas in the union.\n * Any non-ambiguity errors are thrown as exceptions: `UsageError`s if causable by incorrect API use, and asserts if violating internal invariants.\n */\nexport function checkUnion(\n\tunion: Iterable<TreeNodeSchema>,\n\tpreventAmbiguity: boolean,\n\tambiguityErrors: string[],\n): void {\n\tconst checked: Set<TreeNodeSchema> = new Set();\n\tconst maps: MapNodeSchema[] = [];\n\tconst arrays: ArrayNodeSchema[] = [];\n\tconst records: RecordNodeSchema[] = [];\n\tconst objects: ObjectNodeSchema[] = [];\n\n\t// Map from key to schema using that key\n\tconst allObjectKeys: Map<string, Set<TreeNodeSchema>> = new Map();\n\n\tfor (const schema of union) {\n\t\tif (checked.has(schema)) {\n\t\t\tthrow new UsageError(`Duplicate schema in allowed types: ${schema.identifier}`);\n\t\t}\n\t\tchecked.add(schema);\n\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\t// nothing to do\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tassert(isObjectNodeSchema(schema), 0xbde /* Expected object schema. */);\n\t\t\t\tobjects.push(schema);\n\t\t\t\tfor (const key of schema.fields.keys()) {\n\t\t\t\t\tgetOrCreate(allObjectKeys, key, () => new Set()).add(schema);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tassert(isArrayNodeSchema(schema), 0xbdf /* Expected array schema. */);\n\t\t\t\tarrays.push(schema);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Map: {\n\t\t\t\tassert(isMapNodeSchema(schema), 0xbe0 /* Expected map schema. */);\n\t\t\t\tmaps.push(schema);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Record: {\n\t\t\t\tassert(isRecordNodeSchema(schema), 0xbe1 /* Expected record schema. */);\n\t\t\t\trecords.push(schema);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(schema.kind);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!preventAmbiguity) {\n\t\t// All remaining checks are for the preventAmbiguity case, so skip them if not enabled.\n\t\treturn;\n\t}\n\n\tif (arrays.length > 1) {\n\t\tambiguityErrors.push(\n\t\t\t`More than one kind of array allowed within union (${formatTypes(arrays)}). This would require type disambiguation which is not supported by arrays during import or export.`,\n\t\t);\n\t}\n\n\tif (maps.length > 1) {\n\t\tambiguityErrors.push(\n\t\t\t`More than one kind of map allowed within union (${formatTypes(maps)}). This would require type disambiguation which is not supported by maps during import or export.`,\n\t\t);\n\t}\n\n\tif (records.length > 1) {\n\t\tambiguityErrors.push(\n\t\t\t`More than one kind of record allowed within union (${formatTypes(records)}). This would require type disambiguation which is not supported by records during import or export.`,\n\t\t);\n\t}\n\n\tif (maps.length > 0 && arrays.length > 0) {\n\t\tambiguityErrors.push(\n\t\t\t`Both a map and an array allowed within union (${formatTypes([...arrays, ...maps])}). Both can be implicitly constructed from iterables like arrays, which are ambiguous when the array is empty.`,\n\t\t);\n\t}\n\n\tconst nodeKindListEntries = [];\n\tif (objects.length > 0) {\n\t\tnodeKindListEntries.push(\"objects\");\n\t}\n\tif (maps.length > 0) {\n\t\tnodeKindListEntries.push(\"maps\");\n\t}\n\tif (records.length > 0) {\n\t\tnodeKindListEntries.push(\"records\");\n\t}\n\tif (nodeKindListEntries.length > 1) {\n\t\tconst nodeKindListString =\n\t\t\tnodeKindListEntries.length === 2\n\t\t\t\t? `${nodeKindListEntries[0] ?? oob()} and ${nodeKindListEntries[1] ?? oob()}`\n\t\t\t\t: `${nodeKindListEntries.slice(0, -1).join(\", \")}, and ${nodeKindListEntries[nodeKindListEntries.length - 1]}`;\n\t\tambiguityErrors.push(\n\t\t\t`A combination of ${nodeKindListString} is allowed within union (${formatTypes([...objects, ...maps, ...records])}). These can be constructed from objects and can be ambiguous.`,\n\t\t);\n\t}\n\n\t// Check for objects which fully overlap:\n\tfor (const schema of objects) {\n\t\t// All objects which might be ambiguous relative to `schema`.\n\t\tconst possiblyAmbiguous = new Set(objects);\n\n\t\t// A schema can't be ambiguous with itself\n\t\tpossiblyAmbiguous.delete(schema);\n\n\t\t// For each field of schema, remove schema from possiblyAmbiguous that do not have that field\n\t\tfor (const [key, field] of schema.fields) {\n\t\t\tif (field.kind === FieldKind.Required) {\n\t\t\t\tconst withKey = allObjectKeys.get(key) ?? fail(0xb35 /* missing schema */);\n\t\t\t\tfor (const candidate of possiblyAmbiguous) {\n\t\t\t\t\tif (!withKey.has(candidate)) {\n\t\t\t\t\t\tpossiblyAmbiguous.delete(candidate);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (possiblyAmbiguous.size > 0) {\n\t\t\t// TODO: make this check more permissive.\n\t\t\t// Allow using the type of the field to disambiguate, at least for leaf types.\n\t\t\t// Add \"constant\" fields which can be used to disambiguate even more cases without adding persisted data: maybe make them optional in constructor?\n\t\t\t// Consider separating unambiguous implicit construction format from constructor arguments at type level, allowing constructor to superset the implicit construction options (ex: optional constant fields).\n\t\t\t// The policy here however must remain at least as conservative as shallowCompatibilityTest in src/simple-tree/unhydratedFlexTreeFromInsertable.ts.\n\n\t\t\tambiguityErrors.push(\n\t\t\t\t`The required fields of ${JSON.stringify(schema.identifier)} are insufficient to differentiate it from the following types: ${formatTypes(possiblyAmbiguous)}. For objects to be considered unambiguous, each must have required fields that do not all occur on any other object in the union.`,\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { type FieldKey, type ITreeCursor, type TreeNodeSchemaIdentifier, type TreeNodeStoredSchema } from "../../core/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import type { TreeNodeSchema } from "../core/index.js";
|
|
8
8
|
import type { TreeLeafValue } from "../schemaTypes.js";
|
|
9
9
|
/**
|
|
10
10
|
* Options for how to interpret or encode a tree when schema information is available.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAKpE,OAAO,EAON,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,MAAM,qBAAqB,CAAC;A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AAY,EAAE,CACb,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EACtC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,KACvC,MAAM,GACT,UAAU,CAAC,MAAM,CAAC,CA6CpB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAC5C,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,EACnE,YAAY,EAAE,CACb,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,KAC/D,MAAM,GACT,UAAU,CAAC,MAAM,CAAC,CAgCpB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,oBAAoB,GAC1B,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAQjC;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAStF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAIpD"}
|
|
@@ -8,9 +8,8 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
|
8
8
|
import { EmptyKey, forEachField, inCursorField, LeafNodeStoredSchema, mapCursorField, ObjectNodeStoredSchema, } from "../../core/index.js";
|
|
9
9
|
import { FieldKinds, valueSchemaAllows } from "../../feature-libraries/index.js";
|
|
10
10
|
import { cloneWithReplacements } from "../../util/index.js";
|
|
11
|
-
import { NodeKind } from "../core/index.js";
|
|
12
11
|
import { booleanSchema, handleSchema, nullSchema, numberSchema, stringSchema, } from "../leafNodeSchema.js";
|
|
13
|
-
import { isObjectNodeSchema } from "../node-kinds/index.js";
|
|
12
|
+
import { isArrayNodeSchema, isObjectNodeSchema } from "../node-kinds/index.js";
|
|
14
13
|
/**
|
|
15
14
|
* Builds an {@link CustomTree} from a cursor in Nodes mode.
|
|
16
15
|
*/
|
|
@@ -31,7 +30,7 @@ export function customFromCursor(reader, options, schema, childHandler) {
|
|
|
31
30
|
return reader.value;
|
|
32
31
|
default: {
|
|
33
32
|
assert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);
|
|
34
|
-
if (nodeSchema
|
|
33
|
+
if (isArrayNodeSchema(nodeSchema)) {
|
|
35
34
|
const fields = inCursorField(reader, EmptyKey, () => mapCursorField(reader, () => childHandler(reader, options, schema)));
|
|
36
35
|
return fields;
|
|
37
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GAKtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACN,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC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AI,MAAM,YAAY,sBAAsB,EAAE,CAAC;QAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YACnD,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC,KAAK,CAAC;QACpB,CAAC;IACF,CAAC;AACF,CAAC;AAUD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAI,IAAa,EAAE,QAA4B;IAC5E,OAAO,qBAAqB,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACrD,kDAAkD;QAClD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,CAAC;aAAM,CAAC;YACP,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,MAAM,IAAI,UAAU,CACnB,kDAAkD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,wCAAwC,CAC9G,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachField,\n\tinCursorField,\n\tLeafNodeStoredSchema,\n\tmapCursorField,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n} from \"../../core/index.js\";\nimport { FieldKinds, valueSchemaAllows } from \"../../feature-libraries/index.js\";\nimport { cloneWithReplacements } from \"../../util/index.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../node-kinds/index.js\";\nimport type { TreeLeafValue } from \"../schemaTypes.js\";\n\n/**\n * Options for how to interpret or encode a tree when schema information is available.\n * @alpha\n */\nexport interface TreeEncodingOptions {\n\t/**\n\t * If true, use the stored keys of object nodes.\n\t * If false, use the property keys.\n\t * @remarks\n\t * Has no effect on {@link NodeKind}s other than {@link NodeKind.Object}.\n\t * @defaultValue false.\n\t */\n\treadonly useStoredKeys?: boolean;\n}\n\n/**\n * Options for how to interpret a `ConciseTree<TCustom>` without relying on schema.\n */\nexport interface SchemalessParseOptions {\n\t/**\n\t * Converts stored keys into whatever key the tree is using in its encoding.\n\t */\n\tkeyConverter?: {\n\t\tparse(type: string, inputKey: string): FieldKey;\n\t\tencode(type: string, key: FieldKey): string;\n\t};\n}\n\n/**\n * Tree representation with fields as properties and customized handle and child representations.\n */\nexport type CustomTree<TChild> = CustomTreeNode<TChild> | CustomTreeValue;\n\n/**\n * TreeLeafValue except the handle type is customized.\n */\nexport type CustomTreeValue = TreeLeafValue;\n\n/**\n * Tree node representation with fields as properties and customized child representation.\n */\nexport type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n */\nexport function customFromCursor<TChild>(\n\treader: ITreeCursor,\n\toptions: Required<TreeEncodingOptions>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\toptions: Required<TreeEncodingOptions>,\n\t\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb2e /* missing schema for type in cursor */);\n\n\tswitch (type) {\n\t\tcase numberSchema.identifier:\n\t\tcase booleanSchema.identifier:\n\t\tcase nullSchema.identifier:\n\t\tcase stringSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa50 /* out of schema: missing value */);\n\t\t\tassert(!isFluidHandle(reader.value), 0xa51 /* out of schema: unexpected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tcase handleSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa52 /* out of schema: missing value */);\n\t\t\tassert(isFluidHandle(reader.value), 0xa53 /* out of schema: expected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tdefault: {\n\t\t\tassert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);\n\t\t\tif (nodeSchema.kind === NodeKind.Array) {\n\t\t\t\tconst fields = inCursorField(reader, EmptyKey, () =>\n\t\t\t\t\tmapCursorField(reader, () => childHandler(reader, options, schema)),\n\t\t\t\t);\n\t\t\t\treturn fields;\n\t\t\t} else {\n\t\t\t\tconst fields: Record<string, TChild> = {};\n\t\t\t\tforEachField(reader, () => {\n\t\t\t\t\tconst children = mapCursorField(reader, () => childHandler(reader, options, schema));\n\t\t\t\t\tif (children.length === 1) {\n\t\t\t\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\tisObjectNodeSchema(nodeSchema) && !options.useStoredKeys\n\t\t\t\t\t\t\t\t? (nodeSchema.storedKeyToPropertyKey.get(storedKey) ??\n\t\t\t\t\t\t\t\t\tfail(0xb2f /* missing property key */))\n\t\t\t\t\t\t\t\t: storedKey;\n\t\t\t\t\t\t// Length is checked above.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tfields[key] = children[0]!;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassert(children.length === 0, 0xa19 /* invalid children number */);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn fields;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n * @remarks\n * Uses stored keys and stored schema.\n */\nexport function customFromCursorStored<TChild>(\n\treader: ITreeCursor,\n\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb30 /* missing schema for type in cursor */);\n\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\tassert(valueSchemaAllows(nodeSchema.leafValue, reader.value), 0xa9c /* invalid value */);\n\t\treturn reader.value;\n\t}\n\n\tassert(reader.value === undefined, 0xa9d /* out of schema: unexpected value */);\n\n\tconst arrayTypes = tryStoredSchemaAsArray(nodeSchema);\n\tif (arrayTypes !== undefined) {\n\t\tconst field = inCursorField(reader, EmptyKey, () =>\n\t\t\tmapCursorField(reader, () => childHandler(reader, schema)),\n\t\t);\n\t\treturn field;\n\t}\n\n\tconst fields: Record<string, TChild> = {};\n\tforEachField(reader, () => {\n\t\tconst children = mapCursorField(reader, () => childHandler(reader, schema));\n\t\tif (children.length === 1) {\n\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t// Length is checked above.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tfields[storedKey] = children[0]!;\n\t\t} else {\n\t\t\tassert(children.length === 0, 0xa9e /* invalid children number */);\n\t\t}\n\t});\n\treturn fields;\n}\n\n/**\n * Assumes `schema` corresponds to a simple-tree schema.\n * If it is an array schema, returns the allowed types for the array field.\n * Otherwise returns `undefined`.\n */\nexport function tryStoredSchemaAsArray(\n\tschema: TreeNodeStoredSchema,\n): ReadonlySet<string> | undefined {\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\tconst empty = schema.getFieldSchema(EmptyKey);\n\t\tif (empty.kind === FieldKinds.sequence.identifier) {\n\t\t\tassert(schema.objectNodeFields.size === 1, 0xa9f /* invalid schema */);\n\t\t\treturn empty.types;\n\t\t}\n\t}\n}\n\n/**\n * Options for how to transcode handles.\n * @remarks\n * Can be applied using {@link replaceHandles}.\n * @alpha\n */\nexport type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * This can be useful converting data containing handles to JSON compatible formats,\n * or just asserting that data does not contain handles.\n *\n * Reversing this replacement depends on how the replacer encodes handles, and can often be impossible if the replacer\n * does not have all the necessary context to restore the handles\n * (e.g. if the handles are something insufficiently descriptive,\n * if data referenced by the handle got garbage collected,\n * if the encoded form of the handle can't be differentiated from other data,\n * or the replacer doesn't have access to the correct Fluid container to to restore them from).\n *\n * Code attempting to reverse this replacement may want to use {@link cloneWithReplacements}.\n * @alpha\n */\nexport function replaceHandles<T>(tree: unknown, replacer: HandleConverter<T>): unknown {\n\treturn cloneWithReplacements(tree, \"\", (key, value) => {\n\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\tif (isFluidHandle(value)) {\n\t\t\treturn { clone: false, value: replacer(value) };\n\t\t} else {\n\t\t\treturn { clone: true, value };\n\t\t}\n\t});\n}\n\n/**\n * Throws a `UsageError` indicating that a type is unknown in the current context.\n */\nexport function unknownTypeError(type: string): never {\n\tthrow new UsageError(\n\t\t`Failed to parse tree due to occurrence of type ${JSON.stringify(type)} which is not defined in this context.`,\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"customTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAG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M,CAAC;YACP,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,MAAM,IAAI,UAAU,CACnB,kDAAkD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,wCAAwC,CAC9G,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachField,\n\tinCursorField,\n\tLeafNodeStoredSchema,\n\tmapCursorField,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n} from \"../../core/index.js\";\nimport { FieldKinds, valueSchemaAllows } from \"../../feature-libraries/index.js\";\nimport { cloneWithReplacements } from \"../../util/index.js\";\nimport type { TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isArrayNodeSchema, isObjectNodeSchema } from \"../node-kinds/index.js\";\nimport type { TreeLeafValue } from \"../schemaTypes.js\";\n\n/**\n * Options for how to interpret or encode a tree when schema information is available.\n * @alpha\n */\nexport interface TreeEncodingOptions {\n\t/**\n\t * If true, use the stored keys of object nodes.\n\t * If false, use the property keys.\n\t * @remarks\n\t * Has no effect on {@link NodeKind}s other than {@link NodeKind.Object}.\n\t * @defaultValue false.\n\t */\n\treadonly useStoredKeys?: boolean;\n}\n\n/**\n * Options for how to interpret a `ConciseTree<TCustom>` without relying on schema.\n */\nexport interface SchemalessParseOptions {\n\t/**\n\t * Converts stored keys into whatever key the tree is using in its encoding.\n\t */\n\tkeyConverter?: {\n\t\tparse(type: string, inputKey: string): FieldKey;\n\t\tencode(type: string, key: FieldKey): string;\n\t};\n}\n\n/**\n * Tree representation with fields as properties and customized handle and child representations.\n */\nexport type CustomTree<TChild> = CustomTreeNode<TChild> | CustomTreeValue;\n\n/**\n * TreeLeafValue except the handle type is customized.\n */\nexport type CustomTreeValue = TreeLeafValue;\n\n/**\n * Tree node representation with fields as properties and customized child representation.\n */\nexport type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n */\nexport function customFromCursor<TChild>(\n\treader: ITreeCursor,\n\toptions: Required<TreeEncodingOptions>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\toptions: Required<TreeEncodingOptions>,\n\t\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb2e /* missing schema for type in cursor */);\n\n\tswitch (type) {\n\t\tcase numberSchema.identifier:\n\t\tcase booleanSchema.identifier:\n\t\tcase nullSchema.identifier:\n\t\tcase stringSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa50 /* out of schema: missing value */);\n\t\t\tassert(!isFluidHandle(reader.value), 0xa51 /* out of schema: unexpected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tcase handleSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa52 /* out of schema: missing value */);\n\t\t\tassert(isFluidHandle(reader.value), 0xa53 /* out of schema: expected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tdefault: {\n\t\t\tassert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);\n\t\t\tif (isArrayNodeSchema(nodeSchema)) {\n\t\t\t\tconst fields = inCursorField(reader, EmptyKey, () =>\n\t\t\t\t\tmapCursorField(reader, () => childHandler(reader, options, schema)),\n\t\t\t\t);\n\t\t\t\treturn fields;\n\t\t\t} else {\n\t\t\t\tconst fields: Record<string, TChild> = {};\n\t\t\t\tforEachField(reader, () => {\n\t\t\t\t\tconst children = mapCursorField(reader, () => childHandler(reader, options, schema));\n\t\t\t\t\tif (children.length === 1) {\n\t\t\t\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\tisObjectNodeSchema(nodeSchema) && !options.useStoredKeys\n\t\t\t\t\t\t\t\t? (nodeSchema.storedKeyToPropertyKey.get(storedKey) ??\n\t\t\t\t\t\t\t\t\tfail(0xb2f /* missing property key */))\n\t\t\t\t\t\t\t\t: storedKey;\n\t\t\t\t\t\t// Length is checked above.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tfields[key] = children[0]!;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassert(children.length === 0, 0xa19 /* invalid children number */);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn fields;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n * @remarks\n * Uses stored keys and stored schema.\n */\nexport function customFromCursorStored<TChild>(\n\treader: ITreeCursor,\n\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb30 /* missing schema for type in cursor */);\n\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\tassert(valueSchemaAllows(nodeSchema.leafValue, reader.value), 0xa9c /* invalid value */);\n\t\treturn reader.value;\n\t}\n\n\tassert(reader.value === undefined, 0xa9d /* out of schema: unexpected value */);\n\n\tconst arrayTypes = tryStoredSchemaAsArray(nodeSchema);\n\tif (arrayTypes !== undefined) {\n\t\tconst field = inCursorField(reader, EmptyKey, () =>\n\t\t\tmapCursorField(reader, () => childHandler(reader, schema)),\n\t\t);\n\t\treturn field;\n\t}\n\n\tconst fields: Record<string, TChild> = {};\n\tforEachField(reader, () => {\n\t\tconst children = mapCursorField(reader, () => childHandler(reader, schema));\n\t\tif (children.length === 1) {\n\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t// Length is checked above.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tfields[storedKey] = children[0]!;\n\t\t} else {\n\t\t\tassert(children.length === 0, 0xa9e /* invalid children number */);\n\t\t}\n\t});\n\treturn fields;\n}\n\n/**\n * Assumes `schema` corresponds to a simple-tree schema.\n * If it is an array schema, returns the allowed types for the array field.\n * Otherwise returns `undefined`.\n */\nexport function tryStoredSchemaAsArray(\n\tschema: TreeNodeStoredSchema,\n): ReadonlySet<string> | undefined {\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\tconst empty = schema.getFieldSchema(EmptyKey);\n\t\tif (empty.kind === FieldKinds.sequence.identifier) {\n\t\t\tassert(schema.objectNodeFields.size === 1, 0xa9f /* invalid schema */);\n\t\t\treturn empty.types;\n\t\t}\n\t}\n}\n\n/**\n * Options for how to transcode handles.\n * @remarks\n * Can be applied using {@link replaceHandles}.\n * @alpha\n */\nexport type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * This can be useful converting data containing handles to JSON compatible formats,\n * or just asserting that data does not contain handles.\n *\n * Reversing this replacement depends on how the replacer encodes handles, and can often be impossible if the replacer\n * does not have all the necessary context to restore the handles\n * (e.g. if the handles are something insufficiently descriptive,\n * if data referenced by the handle got garbage collected,\n * if the encoded form of the handle can't be differentiated from other data,\n * or the replacer doesn't have access to the correct Fluid container to to restore them from).\n *\n * Code attempting to reverse this replacement may want to use {@link cloneWithReplacements}.\n * @alpha\n */\nexport function replaceHandles<T>(tree: unknown, replacer: HandleConverter<T>): unknown {\n\treturn cloneWithReplacements(tree, \"\", (key, value) => {\n\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\tif (isFluidHandle(value)) {\n\t\t\treturn { clone: false, value: replacer(value) };\n\t\t} else {\n\t\t\treturn { clone: true, value };\n\t\t}\n\t});\n}\n\n/**\n * Throws a `UsageError` indicating that a type is unknown in the current context.\n */\nexport function unknownTypeError(type: string): never {\n\tthrow new UsageError(\n\t\t`Failed to parse tree due to occurrence of type ${JSON.stringify(type)} which is not defined in this context.`,\n\t);\n}\n"]}
|
|
@@ -13,12 +13,12 @@ export { allowUnused } from "./schemaFactoryRecursive.js";
|
|
|
13
13
|
export { adaptEnum, enumFromStrings, singletonSchema, } from "./schemaCreationUtilities.js";
|
|
14
14
|
export { getIdentifierFromNode, getPropertyKeyFromStoredKey, getStoredKey, treeNodeApi, type TreeNodeApi, tryGetSchema, } from "./treeNodeApi.js";
|
|
15
15
|
export { createFromCursor } from "./create.js";
|
|
16
|
-
export { type JsonSchemaId, type JsonSchemaType, type JsonObjectNodeSchema, type JsonArrayNodeSchema, type JsonMapNodeSchema, type JsonLeafNodeSchema, type JsonSchemaRef, type JsonRefPath, type JsonNodeSchema, type JsonNodeSchemaBase, type JsonTreeSchema, type JsonFieldSchema, type JsonLeafSchemaType, } from "./jsonSchema.js";
|
|
16
|
+
export { type JsonSchemaId, type JsonSchemaType, type JsonObjectNodeSchema, type JsonArrayNodeSchema, type JsonMapNodeSchema, type JsonLeafNodeSchema, type JsonSchemaRef, type JsonRefPath, type JsonNodeSchema, type JsonNodeSchemaBase, type JsonTreeSchema, type JsonFieldSchema, type JsonLeafSchemaType, type JsonRecordNodeSchema, type JsonStringKeyPatternProperties, } from "./jsonSchema.js";
|
|
17
17
|
export type { TreeSchemaEncodingOptions } from "./getJsonSchema.js";
|
|
18
18
|
export { getJsonSchema } from "./getJsonSchema.js";
|
|
19
19
|
export { getSimpleSchema } from "./getSimpleSchema.js";
|
|
20
20
|
export { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
|
|
21
|
-
export type { Unenforced, FieldSchemaAlphaUnsafe, ArrayNodeCustomizableSchemaUnsafe, MapNodeCustomizableSchemaUnsafe, System_Unsafe, } from "./typesUnsafe.js";
|
|
21
|
+
export type { Unenforced, FieldSchemaAlphaUnsafe, ArrayNodeCustomizableSchemaUnsafe, MapNodeCustomizableSchemaUnsafe, System_Unsafe, TreeRecordNodeUnsafe, } from "./typesUnsafe.js";
|
|
22
22
|
export { type VerboseTreeNode, type VerboseTree, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, replaceVerboseTreeHandles, } from "./verboseTree.js";
|
|
23
23
|
export { type TreeEncodingOptions, customFromCursorStored, type CustomTreeNode, type CustomTreeValue, tryStoredSchemaAsArray, replaceHandles, type HandleConverter, } from "./customTree.js";
|
|
24
24
|
export { type ConciseTree, conciseFromCursor, replaceConciseTreeHandles, } from "./conciseTree.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACX,UAAU,EACV,sBAAsB,EACtB,yBAAyB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,qBAAqB,EACrB,0BAA0B,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACX,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,yBAAyB,EACzB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,UAAU,GACV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACN,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,aAAa,EAClB,aAAa,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EACX,uBAAuB,EACvB,uBAAuB,EACvB,+BAA+B,EAC/B,0BAA0B,GAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EACN,SAAS,EACT,eAAe,EACf,eAAe,GACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,WAAW,EACX,KAAK,WAAW,EAChB,YAAY,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACX,UAAU,EACV,sBAAsB,EACtB,yBAAyB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,qBAAqB,EACrB,0BAA0B,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACX,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,yBAAyB,EACzB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,UAAU,GACV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACN,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B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M,kBAAkB,CAAC;AAE1B,OAAO,EAEN,sBAAsB,EAGtB,sBAAsB,EACtB,cAAc,GAEd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEN,iBAAiB,EACjB,yBAAyB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAmD,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAwB,MAAM,sBAAsB,CAAC;AACnF,OAAO,EACN,qBAAqB,GAErB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACN,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAUN,QAAQ,GACR,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type {\n\tTreeSchema,\n\tITreeViewConfiguration,\n\tITreeConfigurationOptions,\n} from \"./configuration.js\";\nexport {\n\tTreeViewConfiguration,\n\tTreeViewConfigurationAlpha,\n} from \"./configuration.js\";\nexport type {\n\tITree,\n\tTreeView,\n\tViewableTree,\n\tTreeViewEvents,\n\tSchemaCompatibilityStatus,\n\tTreeViewAlpha,\n\tTreeBranch,\n\tTreeBranchEvents,\n\tITreeAlpha,\n} from \"./tree.js\";\nexport { asTreeViewAlpha } from \"./tree.js\";\nexport {\n\tSchemaFactory,\n\ttype ScopedSchemaName,\n\ttype SchemaFactoryObjectOptions,\n\ttype SchemaStatics,\n\tschemaStatics,\n} from \"./schemaFactory.js\";\nexport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\nexport type {\n\tValidateRecursiveSchema,\n\tFixRecursiveArraySchema,\n\tValidateRecursiveSchemaTemplate,\n\tFixRecursiveRecursionLimit,\n} from \"./schemaFactoryRecursive.js\";\nexport { allowUnused } from \"./schemaFactoryRecursive.js\";\nexport {\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n} from \"./schemaCreationUtilities.js\";\nexport {\n\tgetIdentifierFromNode,\n\tgetPropertyKeyFromStoredKey,\n\tgetStoredKey,\n\ttreeNodeApi,\n\ttype TreeNodeApi,\n\ttryGetSchema,\n} from \"./treeNodeApi.js\";\nexport { createFromCursor } from \"./create.js\";\nexport {\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n\ttype JsonRecordNodeSchema,\n\ttype JsonStringKeyPatternProperties,\n} from \"./jsonSchema.js\";\nexport type { TreeSchemaEncodingOptions } from \"./getJsonSchema.js\";\nexport { getJsonSchema } from \"./getJsonSchema.js\";\nexport { getSimpleSchema } from \"./getSimpleSchema.js\";\nexport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nexport type {\n\tUnenforced,\n\tFieldSchemaAlphaUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n} from \"./typesUnsafe.js\";\n\nexport {\n\ttype VerboseTreeNode,\n\ttype VerboseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\treplaceVerboseTreeHandles,\n} from \"./verboseTree.js\";\n\nexport {\n\ttype TreeEncodingOptions,\n\tcustomFromCursorStored,\n\ttype CustomTreeNode,\n\ttype CustomTreeValue,\n\ttryStoredSchemaAsArray,\n\treplaceHandles,\n\ttype HandleConverter,\n} from \"./customTree.js\";\n\nexport {\n\ttype ConciseTree,\n\tconciseFromCursor,\n\treplaceConciseTreeHandles,\n} from \"./conciseTree.js\";\n\nexport { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from \"./treeBeta.js\";\nexport { createSimpleTreeIndex, type SimpleTreeIndex } from \"./simpleTreeIndex.js\";\nexport {\n\tcreateIdentifierIndex,\n\ttype IdentifierIndex,\n} from \"./identifierIndex.js\";\n\nexport {\n\textractPersistedSchema,\n\tcomparePersistedSchema,\n} from \"./storedSchema.js\";\n\nexport {\n\ttype TransactionConstraint,\n\ttype NodeInDocumentConstraint,\n\ttype RunTransactionParams,\n\ttype VoidTransactionCallbackStatus,\n\ttype TransactionCallbackStatus,\n\ttype TransactionResult,\n\ttype TransactionResultExt,\n\ttype TransactionResultSuccess,\n\ttype TransactionResultFailed,\n\trollback,\n} from \"./transactionTypes.js\";\n\nexport { generateSchemaFromSimpleSchema } from \"./schemaFromSimple.js\";\nexport { toSimpleTreeSchema } from \"./viewSchemaToSimpleSchema.js\";\nexport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\n"]}
|