@fluidframework/tree 2.63.0-359461 → 2.63.0-359734
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/.mocharc.cjs +9 -1
- package/api-report/tree.alpha.api.md +93 -98
- package/api-report/tree.beta.api.md +37 -2
- package/api-report/tree.legacy.beta.api.md +37 -2
- package/api-report/tree.legacy.public.api.md +9 -2
- package/api-report/tree.public.api.md +9 -2
- package/dist/alpha.d.ts +11 -13
- package/dist/beta.d.ts +5 -0
- package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +17 -15
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/jsonDomainSchema.d.ts +5 -5
- package/dist/jsonDomainSchema.js +5 -5
- package/dist/jsonDomainSchema.js.map +1 -1
- package/dist/legacy.d.ts +5 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +1 -0
- package/dist/serializableDomainSchema.d.ts +6 -6
- package/dist/serializableDomainSchema.js +5 -5
- package/dist/serializableDomainSchema.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +1 -1
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +20 -28
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +4 -29
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts +1 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +0 -3
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js +1 -4
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +7 -7
- package/dist/simple-tree/api/customTree.js +5 -5
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.js +2 -2
- package/dist/simple-tree/api/discrepancies.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 +4 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +12 -4
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +3 -8
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +27 -26
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +11 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts +13 -2
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.js +14 -0
- package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/dist/simple-tree/api/schemaStatics.d.ts +9 -14
- package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaStatics.js +9 -12
- package/dist/simple-tree/api/schemaStatics.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +2 -2
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +3 -3
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeBeta.d.ts +52 -2
- package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeBeta.js +36 -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/core/allowedTypes.d.ts +120 -62
- package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/dist/simple-tree/core/allowedTypes.js +162 -84
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/context.d.ts +2 -2
- package/dist/simple-tree/core/context.d.ts.map +1 -1
- package/dist/simple-tree/core/context.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +2 -2
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +4 -3
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/toStored.d.ts +3 -3
- package/dist/simple-tree/core/toStored.d.ts.map +1 -1
- package/dist/simple-tree/core/toStored.js +2 -2
- package/dist/simple-tree/core/toStored.js.map +1 -1
- package/dist/simple-tree/core/treeNode.d.ts +1 -1
- package/dist/simple-tree/core/treeNode.js +1 -1
- package/dist/simple-tree/core/treeNode.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +3 -3
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.d.ts +2 -2
- package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
- package/dist/simple-tree/core/walkSchema.d.ts +3 -3
- package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/walkSchema.js +1 -1
- package/dist/simple-tree/core/walkSchema.js.map +1 -1
- package/dist/simple-tree/createContext.js +2 -2
- package/dist/simple-tree/createContext.js.map +1 -1
- package/dist/simple-tree/fieldSchema.d.ts +9 -32
- package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/fieldSchema.js +12 -20
- package/dist/simple-tree/fieldSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +4 -4
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +6 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +2 -2
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +5 -6
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +3 -3
- package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
- package/dist/simple-tree/node-kinds/common.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/common.js +2 -2
- package/dist/simple-tree/node-kinds/common.js.map +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts +2 -2
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +3 -3
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts +3 -3
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.d.ts +2 -2
- package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +5 -18
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +5 -15
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +4 -11
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts +3 -3
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +3 -3
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +5 -5
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts +5 -5
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/dist/simple-tree/prepareForInsertion.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts +8 -8
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +5 -5
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/dist/simple-tree/unsafeUnknownSchema.d.ts.map +1 -1
- package/dist/simple-tree/unsafeUnknownSchema.js.map +1 -1
- package/dist/simple-tree/walkFieldSchema.js +1 -1
- package/dist/simple-tree/walkFieldSchema.js.map +1 -1
- package/dist/tableSchema.d.ts +19 -19
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +2 -2
- package/dist/tableSchema.js.map +1 -1
- package/lib/alpha.d.ts +11 -13
- package/lib/beta.d.ts +5 -0
- package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +17 -15
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/jsonDomainSchema.d.ts +5 -5
- package/lib/jsonDomainSchema.js +5 -5
- package/lib/jsonDomainSchema.js.map +1 -1
- package/lib/legacy.d.ts +5 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -0
- package/lib/serializableDomainSchema.d.ts +6 -6
- package/lib/serializableDomainSchema.js +5 -5
- package/lib/serializableDomainSchema.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +1 -1
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +20 -28
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +3 -28
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts +1 -1
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +0 -3
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js +2 -5
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +7 -7
- package/lib/simple-tree/api/customTree.js +5 -5
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.js +3 -3
- package/lib/simple-tree/api/discrepancies.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 +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +12 -4
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +3 -8
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +27 -26
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +12 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts +13 -2
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.js +16 -2
- package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/lib/simple-tree/api/schemaStatics.d.ts +9 -14
- package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaStatics.js +9 -12
- package/lib/simple-tree/api/schemaStatics.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +2 -2
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +1 -1
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +3 -3
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeBeta.d.ts +52 -2
- package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeBeta.js +33 -1
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +1 -1
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +120 -62
- package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/lib/simple-tree/core/allowedTypes.js +158 -80
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/context.d.ts +2 -2
- package/lib/simple-tree/core/context.d.ts.map +1 -1
- package/lib/simple-tree/core/context.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +2 -2
- 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/toStored.d.ts +3 -3
- package/lib/simple-tree/core/toStored.d.ts.map +1 -1
- package/lib/simple-tree/core/toStored.js +3 -3
- package/lib/simple-tree/core/toStored.js.map +1 -1
- package/lib/simple-tree/core/treeNode.d.ts +1 -1
- package/lib/simple-tree/core/treeNode.js +1 -1
- package/lib/simple-tree/core/treeNode.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +3 -3
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.d.ts +2 -2
- package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
- package/lib/simple-tree/core/walkSchema.d.ts +3 -3
- package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/walkSchema.js +2 -2
- package/lib/simple-tree/core/walkSchema.js.map +1 -1
- package/lib/simple-tree/createContext.js +3 -3
- package/lib/simple-tree/createContext.js.map +1 -1
- package/lib/simple-tree/fieldSchema.d.ts +9 -32
- package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/fieldSchema.js +13 -21
- package/lib/simple-tree/fieldSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +4 -4
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +2 -2
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +2 -2
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +6 -7
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +3 -3
- package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
- package/lib/simple-tree/node-kinds/common.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/common.js +3 -3
- package/lib/simple-tree/node-kinds/common.js.map +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts +2 -2
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +4 -4
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts +3 -3
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.d.ts +2 -2
- package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +5 -18
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +6 -15
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +4 -11
- 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/recordNode.d.ts +3 -3
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +4 -4
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +5 -5
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts +5 -5
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts +8 -8
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +5 -5
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/lib/simple-tree/unsafeUnknownSchema.d.ts.map +1 -1
- package/lib/simple-tree/unsafeUnknownSchema.js.map +1 -1
- package/lib/simple-tree/walkFieldSchema.js +1 -1
- package/lib/simple-tree/walkFieldSchema.js.map +1 -1
- package/lib/tableSchema.d.ts +19 -19
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +2 -2
- package/lib/tableSchema.js.map +1 -1
- package/package.json +23 -21
- package/src/feature-libraries/treeCursorUtils.ts +34 -19
- package/src/index.ts +7 -10
- package/src/jsonDomainSchema.ts +5 -5
- package/src/packageVersion.ts +1 -1
- package/src/serializableDomainSchema.ts +6 -6
- package/src/shared-tree/schematizingTreeView.ts +1 -1
- package/src/shared-tree/treeAlpha.ts +32 -81
- package/src/simple-tree/api/conciseTree.ts +1 -1
- package/src/simple-tree/api/configuration.ts +3 -7
- package/src/simple-tree/api/customTree.ts +7 -7
- package/src/simple-tree/api/discrepancies.ts +3 -3
- package/src/simple-tree/api/index.ts +10 -2
- package/src/simple-tree/api/schemaFactory.ts +18 -73
- package/src/simple-tree/api/schemaFactoryAlpha.ts +45 -12
- package/src/simple-tree/api/schemaFactoryBeta.ts +76 -1
- package/src/simple-tree/api/schemaStatics.ts +16 -61
- package/src/simple-tree/api/storedSchema.ts +2 -6
- package/src/simple-tree/api/tree.ts +3 -3
- package/src/simple-tree/api/treeBeta.ts +136 -3
- package/src/simple-tree/api/treeNodeApi.ts +1 -1
- package/src/simple-tree/core/allowedTypes.ts +355 -159
- package/src/simple-tree/core/context.ts +2 -2
- package/src/simple-tree/core/index.ts +10 -8
- package/src/simple-tree/core/toStored.ts +7 -5
- package/src/simple-tree/core/treeNode.ts +1 -1
- package/src/simple-tree/core/treeNodeSchema.ts +3 -6
- package/src/simple-tree/core/treeNodeValid.ts +2 -2
- package/src/simple-tree/core/walkSchema.ts +9 -5
- package/src/simple-tree/createContext.ts +3 -3
- package/src/simple-tree/fieldSchema.ts +24 -98
- package/src/simple-tree/index.ts +11 -10
- package/src/simple-tree/node-kinds/array/arrayNode.ts +9 -14
- package/src/simple-tree/node-kinds/array/arrayNodeTypes.ts +7 -8
- package/src/simple-tree/node-kinds/common.ts +5 -3
- package/src/simple-tree/node-kinds/index.ts +0 -2
- package/src/simple-tree/node-kinds/map/mapNode.ts +5 -13
- package/src/simple-tree/node-kinds/map/mapNodeTypes.ts +7 -8
- package/src/simple-tree/node-kinds/object/index.ts +0 -2
- package/src/simple-tree/node-kinds/object/objectNode.ts +13 -51
- package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +5 -19
- package/src/simple-tree/node-kinds/record/recordNode.ts +9 -16
- package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +7 -11
- package/src/simple-tree/prepareForInsertion.ts +5 -5
- package/src/simple-tree/toStoredSchema.ts +8 -9
- package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +2 -6
- package/src/simple-tree/unsafeUnknownSchema.ts +2 -3
- package/src/simple-tree/walkFieldSchema.ts +1 -1
- package/src/tableSchema.ts +24 -37
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
import { type ErasedBaseType, ErasedTypeImplementation } from "@fluidframework/core-interfaces/internal";
|
|
5
6
|
import { type IsUnion, type MakeNominal } from "../../util/index.js";
|
|
6
7
|
import { type FlexListToUnion, type LazyItem } from "./flexList.js";
|
|
7
8
|
import { type InsertableTypedNode, type NodeFromSchema, type TreeNodeSchema } from "./treeNodeSchema.js";
|
|
@@ -24,8 +25,10 @@ import { type InsertableTypedNode, type NodeFromSchema, type TreeNodeSchema } fr
|
|
|
24
25
|
* but some of the items are known to be present unconditionally.
|
|
25
26
|
* For example, typing `[typeof A] | [typeof A, typeof B]` as `[typeof A, typeof B | typeof A]` is allowed,
|
|
26
27
|
* and can produce more useful {@link Input} types.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* Due to one implementation of this being {@link AllowedTypesFull}, it is not safe to assume this is an array (as determined by `Array.isArray`).
|
|
30
|
+
*
|
|
31
|
+
* Code reading data from this should use {@link normalizeAllowedTypes} to ensure consistent handling, caching, nice errors etc.
|
|
29
32
|
* @system @public
|
|
30
33
|
*/
|
|
31
34
|
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
|
@@ -33,6 +36,9 @@ export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
|
|
33
36
|
* Stores annotations for an individual allowed type.
|
|
34
37
|
* @remarks
|
|
35
38
|
* Create using APIs on {@link SchemaFactoryAlpha}, like {@link SchemaStaticsAlpha.staged}.
|
|
39
|
+
* @privateRemarks
|
|
40
|
+
* Since this is sealed, users are not supposed to create instances of it directly.
|
|
41
|
+
* Making it extend ErasedType could enforce that.
|
|
36
42
|
* @alpha
|
|
37
43
|
* @sealed
|
|
38
44
|
*/
|
|
@@ -47,22 +53,21 @@ export interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {
|
|
|
47
53
|
readonly type: T;
|
|
48
54
|
}
|
|
49
55
|
/**
|
|
50
|
-
* {@link
|
|
56
|
+
* {@link AllowedTypesFull} but with the lazy schema references eagerly evaluated.
|
|
51
57
|
* @sealed
|
|
52
58
|
* @alpha
|
|
53
59
|
*/
|
|
54
|
-
export
|
|
55
|
-
}
|
|
60
|
+
export type AllowedTypesFullEvaluated = AllowedTypesFull<readonly AnnotatedAllowedType<TreeNodeSchema>[]>;
|
|
56
61
|
/**
|
|
57
62
|
* Checks if the input is an {@link AnnotatedAllowedTypes}.
|
|
58
63
|
*/
|
|
59
|
-
export declare function isAnnotatedAllowedTypes(allowedTypes:
|
|
64
|
+
export declare function isAnnotatedAllowedTypes(allowedTypes: ImplicitAllowedTypes): allowedTypes is AllowedTypesFullInternal;
|
|
60
65
|
/**
|
|
61
66
|
* Stores annotations for a set of allowed types.
|
|
62
67
|
* @alpha
|
|
63
68
|
* @sealed
|
|
64
69
|
*/
|
|
65
|
-
export interface AnnotatedAllowedTypes<T =
|
|
70
|
+
export interface AnnotatedAllowedTypes<T = readonly AnnotatedAllowedType[]> extends ErasedBaseType<"tree.AnnotatedAllowedTypes"> {
|
|
66
71
|
/**
|
|
67
72
|
* Annotations that apply to a set of allowed types.
|
|
68
73
|
*/
|
|
@@ -70,7 +75,79 @@ export interface AnnotatedAllowedTypes<T = LazyItem<TreeNodeSchema>> {
|
|
|
70
75
|
/**
|
|
71
76
|
* All the allowed types that the annotations apply to. The types themselves may also have individual annotations.
|
|
72
77
|
*/
|
|
73
|
-
readonly types:
|
|
78
|
+
readonly types: T;
|
|
79
|
+
/**
|
|
80
|
+
* Get this {@link AnnotatedAllowedTypes} but with any lazy schema references eagerly evaluated.
|
|
81
|
+
* @remarks
|
|
82
|
+
* See {@link evaluateLazySchema} the implications of evaluating lazy schema references.
|
|
83
|
+
*/
|
|
84
|
+
evaluate(): AllowedTypesFullEvaluated;
|
|
85
|
+
/**
|
|
86
|
+
* Get the allowed types as a set with any lazy schema references eagerly evaluated.
|
|
87
|
+
* @remarks
|
|
88
|
+
* See {@link evaluateLazySchema} the implications of evaluating lazy schema references.
|
|
89
|
+
*/
|
|
90
|
+
evaluateSet(): ReadonlySet<TreeNodeSchema>;
|
|
91
|
+
/**
|
|
92
|
+
* Get the allowed types as a set of identifiers with any lazy schema references eagerly evaluated.
|
|
93
|
+
* @remarks
|
|
94
|
+
* See {@link evaluateLazySchema} the implications of evaluating lazy schema references.
|
|
95
|
+
*
|
|
96
|
+
* It is recommend to work in terms of {@link TreeNodeSchema}
|
|
97
|
+
* rather than identifiers where possible since its more type safe and it is possible that two schema with the same identifier exist.
|
|
98
|
+
*/
|
|
99
|
+
evaluateIdentifiers(): ReadonlySet<string>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Stores annotations for a set of allowed types.
|
|
103
|
+
* @remarks
|
|
104
|
+
* Most expressive form of AllowedTypes which any of the implicit types can be normalized to.
|
|
105
|
+
* @alpha
|
|
106
|
+
* @sealed
|
|
107
|
+
*/
|
|
108
|
+
export type AllowedTypesFull<T extends readonly AnnotatedAllowedType[] = readonly AnnotatedAllowedType[]> = AnnotatedAllowedTypes<T> & UnannotateAllowedTypesList<T>;
|
|
109
|
+
/**
|
|
110
|
+
* Creates an {@link AllowedTypesFull} type from a mixed array of annotated and unannotated allowed types.
|
|
111
|
+
* @alpha
|
|
112
|
+
* @sealed
|
|
113
|
+
*/
|
|
114
|
+
export type AllowedTypesFullFromMixed<T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]> = UnannotateAllowedTypesList<T> & AnnotatedAllowedTypes<AnnotateAllowedTypesList<T>>;
|
|
115
|
+
/**
|
|
116
|
+
* The same as the built-in InstanceType, but works on classes with private constructors.
|
|
117
|
+
* @privateRemarks
|
|
118
|
+
* This is based on the trick in {@link https://stackoverflow.com/a/74657881}.
|
|
119
|
+
*/
|
|
120
|
+
type InstanceTypeRelaxed<TClass> = InstanceType<(new () => never) & TClass>;
|
|
121
|
+
/**
|
|
122
|
+
* {@link AllowedTypesFull} but with internal types.
|
|
123
|
+
*/
|
|
124
|
+
export type AllowedTypesFullInternal<T extends readonly AnnotatedAllowedType[] = readonly AnnotatedAllowedType[]> = AnnotatedAllowedTypesInternal<T> & UnannotateAllowedTypesList<T>;
|
|
125
|
+
type AllowedTypesFullInternalEvaluated = AllowedTypesFullInternal<readonly AnnotatedAllowedType<TreeNodeSchema>[]>;
|
|
126
|
+
/**
|
|
127
|
+
* The implementation of {@link AnnotatedAllowedTypes}. Also implements {@link AllowedTypesFull}.
|
|
128
|
+
* @remarks
|
|
129
|
+
* Due to TypeScript limitations, this class cannot directly state it implements {@link AllowedTypesFull}.
|
|
130
|
+
* As a workaround for that, the static `create` method returns the intersection type.
|
|
131
|
+
*/
|
|
132
|
+
export declare class AnnotatedAllowedTypesInternal<T extends readonly AnnotatedAllowedType[] = readonly AnnotatedAllowedType[]> extends ErasedTypeImplementation<AnnotatedAllowedTypes<T>> implements AnnotatedAllowedTypes<T> {
|
|
133
|
+
readonly types: T;
|
|
134
|
+
readonly metadata: AllowedTypesMetadata;
|
|
135
|
+
readonly unannotatedTypes: UnannotateAllowedTypesList<T>;
|
|
136
|
+
/**
|
|
137
|
+
* True if and only if there is at least one lazy schema reference in the types arrays.
|
|
138
|
+
*/
|
|
139
|
+
private readonly isLazy;
|
|
140
|
+
private readonly lazyEvaluate;
|
|
141
|
+
private constructor();
|
|
142
|
+
evaluate(): AllowedTypesFullInternalEvaluated;
|
|
143
|
+
evaluateSet(): ReadonlySet<TreeNodeSchema>;
|
|
144
|
+
evaluateIdentifiers(): ReadonlySet<string>;
|
|
145
|
+
static [Symbol.hasInstance]<TThis extends (abstract new (...args: unknown[]) => object) | typeof AnnotatedAllowedTypesInternal>(this: TThis, value: ErasedBaseType | InstanceTypeRelaxed<TThis> | ImplicitAllowedTypes): value is InstanceTypeRelaxed<TThis> & AnnotatedAllowedTypesInternal & AllowedTypesFull;
|
|
146
|
+
static narrow<TThis extends (abstract new (...args: unknown[]) => object) | typeof AnnotatedAllowedTypesInternal>(this: TThis, value: ErasedBaseType | InstanceTypeRelaxed<TThis> | ImplicitAllowedTypes): asserts value is InstanceTypeRelaxed<TThis> & AnnotatedAllowedTypesInternal & AllowedTypesFull;
|
|
147
|
+
private static proxy;
|
|
148
|
+
static create<const T extends readonly AnnotatedAllowedType[]>(types: T, metadata?: AllowedTypesMetadata): AnnotatedAllowedTypesInternal<T> & AllowedTypesFull<T>;
|
|
149
|
+
static createUnannotated<const T extends AllowedTypes>(types: T, metadata?: AllowedTypesMetadata): AnnotatedAllowedTypesInternal & T;
|
|
150
|
+
static createMixed<const T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]>(types: T, metadata?: AllowedTypesMetadata): AllowedTypesFullFromMixed<T>;
|
|
74
151
|
}
|
|
75
152
|
/**
|
|
76
153
|
* Annotations that apply to a set of allowed types.
|
|
@@ -140,6 +217,8 @@ export declare class SchemaUpgrade {
|
|
|
140
217
|
* When referring to types that are declared after the definition of the `ImplicitAllowedTypes`, the schema can be wrapped in a lambda to allow the forward reference.
|
|
141
218
|
* See {@link ValidateRecursiveSchema} for details on how to structure the `ImplicitAllowedTypes` instances when constructing recursive schema.
|
|
142
219
|
*
|
|
220
|
+
* Code reading data from this should use {@link normalizeAllowedTypes} to ensure consistent handling, caching, nice errors etc.
|
|
221
|
+
*
|
|
143
222
|
* @example Explicit use with strong typing
|
|
144
223
|
* ```typescript
|
|
145
224
|
* const sf = new SchemaFactory("myScope");
|
|
@@ -153,80 +232,44 @@ export declare class SchemaUpgrade {
|
|
|
153
232
|
* class A extends sf.array("example", [() => B]) {}
|
|
154
233
|
* class B extends sf.array("Inner", sf.number) {}
|
|
155
234
|
* ```
|
|
156
|
-
* @privateRemarks
|
|
157
|
-
* Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.
|
|
158
235
|
* @public
|
|
159
236
|
*/
|
|
160
237
|
export type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;
|
|
161
|
-
/**
|
|
162
|
-
* Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree with
|
|
163
|
-
* additional metadata associated with the location they're allowed at.
|
|
164
|
-
* @alpha
|
|
165
|
-
* @input
|
|
166
|
-
*/
|
|
167
|
-
export type ImplicitAnnotatedAllowedTypes = TreeNodeSchema | AnnotatedAllowedType | AnnotatedAllowedTypes | readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];
|
|
168
|
-
/**
|
|
169
|
-
* Returns an {@link ImplicitAllowedTypes} that is equivalent to the input without annotations.
|
|
170
|
-
* @system @alpha
|
|
171
|
-
*/
|
|
172
|
-
export type UnannotateImplicitAllowedTypes<T extends ImplicitAnnotatedAllowedTypes> = T extends AnnotatedAllowedTypes ? UnannotateAllowedTypes<T> : T extends AnnotatedAllowedType ? UnannotateAllowedTypesList<[T]> : T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[] ? UnannotateAllowedTypesList<T> : T extends TreeNodeSchema ? T : ImplicitAllowedTypes;
|
|
173
238
|
/**
|
|
174
239
|
* Removes annotations from a list of allowed types that may contain annotations.
|
|
175
240
|
* @system @alpha
|
|
176
241
|
*/
|
|
177
242
|
export type UnannotateAllowedTypesList<T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]> = {
|
|
178
|
-
[I in keyof T]:
|
|
243
|
+
[I in keyof T]: T[I] extends AnnotatedAllowedType<infer X> ? X : T[I];
|
|
179
244
|
};
|
|
180
245
|
/**
|
|
181
|
-
*
|
|
182
|
-
* @system @alpha
|
|
183
|
-
*/
|
|
184
|
-
export type UnannotateAllowedTypes<T extends AnnotatedAllowedTypes> = UnannotateAllowedTypesList<T["types"]>;
|
|
185
|
-
/**
|
|
186
|
-
* Removes annotations from an allowed type.
|
|
187
|
-
* @remarks
|
|
188
|
-
* If the input could be lazy
|
|
189
|
-
* (is a LazyItem or AnnotatedAllowedType<LazyItem> instead of just a TreeNodeSchema | AnnotatedAllowedType<TreeNodeSchema>)
|
|
190
|
-
* then the output of this will be a LazyItem and thus is not valid as an ImplicitAllowedTypes without wrapping it in an array.
|
|
191
|
-
* This can however be used on items within an AllowedTypes array.
|
|
246
|
+
* Add annotations to a list of allowed types that may or may not contain annotations.
|
|
192
247
|
* @system @alpha
|
|
193
248
|
*/
|
|
194
|
-
export type
|
|
249
|
+
export type AnnotateAllowedTypesList<T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]> = {
|
|
250
|
+
[I in keyof T]: T[I] extends AnnotatedAllowedType<unknown> ? T[I] : AnnotatedAllowedType<T[I]>;
|
|
251
|
+
};
|
|
195
252
|
/**
|
|
196
|
-
* Normalizes
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of
|
|
200
|
-
* recursive schemas may fail.
|
|
201
|
-
*
|
|
202
|
-
* @internal
|
|
253
|
+
* Normalizes an {@link ImplicitAllowedTypes} to an {@link AllowedTypesFull}.
|
|
254
|
+
* @alpha
|
|
203
255
|
*/
|
|
204
|
-
export declare function normalizeAllowedTypes(types:
|
|
256
|
+
export declare function normalizeAllowedTypes(types: ImplicitAllowedTypes): AllowedTypesFull;
|
|
205
257
|
/**
|
|
206
258
|
* Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist.
|
|
207
259
|
*/
|
|
208
260
|
export declare function normalizeToAnnotatedAllowedType<T extends LazyItem<TreeNodeSchema>>(type: T | AnnotatedAllowedType<T>): AnnotatedAllowedType<T>;
|
|
209
261
|
/**
|
|
210
|
-
* Normalizes
|
|
262
|
+
* Normalizes allowed types to an {@link AllowedTypesFullInternal}.
|
|
263
|
+
*/
|
|
264
|
+
export declare function normalizeAllowedTypesInternal(type: ImplicitAllowedTypes): AllowedTypesFullInternal;
|
|
265
|
+
/**
|
|
266
|
+
* Normalizes an {@link ImplicitAllowedTypes} to an {@link AllowedTypesFullInternalEvaluated} by eagerly evaluating any
|
|
211
267
|
* lazy schema declarations and adding empty metadata if it doesn't already exist.
|
|
212
268
|
*
|
|
213
269
|
* @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of
|
|
214
270
|
* recursive schemas may fail.
|
|
215
271
|
*/
|
|
216
|
-
export declare function
|
|
217
|
-
/**
|
|
218
|
-
* Converts an {@link ImplicitAnnotatedAllowedTypes} to an {@link ImplicitAllowedTypes}s, by removing
|
|
219
|
-
* any annotations.
|
|
220
|
-
* @remarks
|
|
221
|
-
* This does not evaluate any lazy schemas.
|
|
222
|
-
*/
|
|
223
|
-
export declare function unannotateImplicitAllowedTypes<Types extends ImplicitAnnotatedAllowedTypes>(types: Types): UnannotateImplicitAllowedTypes<Types>;
|
|
224
|
-
/**
|
|
225
|
-
* Converts an {@link AnnotatedAllowedType} to an {@link LazyItem} by removing any annotations.
|
|
226
|
-
* @remarks
|
|
227
|
-
* This does not evaluate any lazy schemas.
|
|
228
|
-
*/
|
|
229
|
-
export declare function unannotateAllowedType<Type extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>>(allowedType: Type): UnannotateAllowedType<Type>;
|
|
272
|
+
export declare function normalizeAndEvaluateAnnotatedAllowedTypes(types: ImplicitAllowedTypes): AllowedTypesFullInternalEvaluated;
|
|
230
273
|
/**
|
|
231
274
|
* Returns the schema referenced by the {@link LazyItem}.
|
|
232
275
|
* @remarks
|
|
@@ -237,7 +280,7 @@ export declare function evaluateLazySchema<T extends TreeNodeSchema>(value: Lazy
|
|
|
237
280
|
/**
|
|
238
281
|
* Throws a UsageError if the provided schema is undefined, most likely due to being used before it was initialized.
|
|
239
282
|
*/
|
|
240
|
-
export declare function checkForUninitializedSchema(schema:
|
|
283
|
+
export declare function checkForUninitializedSchema(schema: ImplicitAllowedTypes | LazyItem<TreeNodeSchema> | AnnotatedAllowedType): void;
|
|
241
284
|
/**
|
|
242
285
|
* Indicates that the provided schema is the "most derived" version in its class hierarchy.
|
|
243
286
|
*
|
|
@@ -339,10 +382,25 @@ export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitA
|
|
|
339
382
|
* @typeparam TList - AllowedTypes to process
|
|
340
383
|
*
|
|
341
384
|
* @privateRemarks
|
|
342
|
-
* This loop is
|
|
385
|
+
* This loop is non-recursive to allow larger unions before hitting the recursion limit in TypeScript.
|
|
343
386
|
* @system @public
|
|
344
387
|
*/
|
|
345
388
|
export type InsertableTreeNodeFromAllowedTypes<TList extends AllowedTypes> = IsUnion<TList> extends true ? never : {
|
|
346
|
-
readonly [Property in keyof TList]: TList[Property] extends
|
|
347
|
-
|
|
389
|
+
readonly [Property in keyof TList]: [TList[Property]] extends [
|
|
390
|
+
LazyItem<infer TSchema extends TreeNodeSchema>
|
|
391
|
+
] ? InsertableTypedNode<TSchema> : never;
|
|
392
|
+
}[NumberKeys<TList>];
|
|
393
|
+
/**
|
|
394
|
+
* Extracts the keys of `T` which are numbers.
|
|
395
|
+
* @remarks
|
|
396
|
+
* The keys are extracted as strings which can be used to index `T`.
|
|
397
|
+
*
|
|
398
|
+
* This handles cases like `{ x: 4 } & [5, 6]` returning `"0"` and `"1"`.
|
|
399
|
+
* Such cases are difficult to handle since `keyof` includes `number` in such cases, but the type can not be indexed by `number`.
|
|
400
|
+
* @system @public
|
|
401
|
+
*/
|
|
402
|
+
export type NumberKeys<T, Transformed = {
|
|
403
|
+
readonly [Property in keyof T as number extends Property ? never : Property]: Property;
|
|
404
|
+
}> = Transformed[`${number}` & keyof Transformed];
|
|
405
|
+
export {};
|
|
348
406
|
//# sourceMappingURL=allowedTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allowedTypes.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/allowedTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"allowedTypes.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/allowedTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,KAAK,cAAc,EACnB,wBAAwB,EACxB,M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AM,MAAM,0CAA0C,CAAC,OAAO,SAAS,oBAAoB,IAC1F;IAAC,OAAO;CAAC,SAAS,CAAC,cAAc,CAAC,GAC/B,mBAAmB,CAAC,OAAO,CAAC,GAC5B,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,GAC/B,kCAAkC,CAAC,OAAO,CAAC,GAC3C,KAAK,CAAC;AAEX;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kCAAkC,CAAC,KAAK,SAAS,YAAY,IACxE,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,GACxB,KAAK,GACL;IACA,QAAQ,EAAE,QAAQ,IAAI,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,SAAS;QAC7D,QAAQ,CAAC,MAAM,OAAO,SAAS,cAAc,CAAC;KAC9C,GACE,mBAAmB,CAAC,OAAO,CAAC,GAC5B,KAAK;CACR,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,CACrB,CAAC,EACD,WAAW,GAAG;IACb,QAAQ,EAAE,QAAQ,IAAI,MAAM,CAAC,IAAI,MAAM,SAAS,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ;CACtF,IACE,WAAW,CAAC,GAAG,MAAM,EAAE,GAAG,MAAM,WAAW,CAAC,CAAC"}
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.markSchemaMostDerived = exports.checkForUninitializedSchema = exports.evaluateLazySchema = exports.
|
|
7
|
+
exports.markSchemaMostDerived = exports.checkForUninitializedSchema = exports.evaluateLazySchema = exports.normalizeAndEvaluateAnnotatedAllowedTypes = exports.normalizeAllowedTypesInternal = exports.normalizeToAnnotatedAllowedType = exports.normalizeAllowedTypes = exports.SchemaUpgrade = exports.createSchemaUpgrade = exports.isAnnotatedAllowedType = exports.AnnotatedAllowedTypesInternal = exports.isAnnotatedAllowedTypes = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/telemetry-utils/internal");
|
|
9
|
+
const internal_2 = require("@fluidframework/core-utils/internal");
|
|
10
|
+
const internal_3 = require("@fluidframework/core-interfaces/internal");
|
|
9
11
|
const index_js_1 = require("../../util/index.js");
|
|
10
12
|
const flexList_js_1 = require("./flexList.js");
|
|
11
13
|
const treeNodeSchema_js_1 = require("./treeNodeSchema.js");
|
|
@@ -15,11 +17,135 @@ const treeNodeValid_js_1 = require("./treeNodeValid.js");
|
|
|
15
17
|
*/
|
|
16
18
|
function isAnnotatedAllowedTypes(allowedTypes) {
|
|
17
19
|
checkForUninitializedSchema(allowedTypes);
|
|
18
|
-
return
|
|
19
|
-
// Class based schema, and lazy schema references report type "function": filtering them out with typeof makes narrowing based on members mostly safe
|
|
20
|
-
typeof allowedTypes === "object" && "metadata" in allowedTypes && "types" in allowedTypes);
|
|
20
|
+
return allowedTypes instanceof AnnotatedAllowedTypesInternal;
|
|
21
21
|
}
|
|
22
22
|
exports.isAnnotatedAllowedTypes = isAnnotatedAllowedTypes;
|
|
23
|
+
/**
|
|
24
|
+
* The implementation of {@link AnnotatedAllowedTypes}. Also implements {@link AllowedTypesFull}.
|
|
25
|
+
* @remarks
|
|
26
|
+
* Due to TypeScript limitations, this class cannot directly state it implements {@link AllowedTypesFull}.
|
|
27
|
+
* As a workaround for that, the static `create` method returns the intersection type.
|
|
28
|
+
*/
|
|
29
|
+
class AnnotatedAllowedTypesInternal extends internal_3.ErasedTypeImplementation {
|
|
30
|
+
constructor(types, metadata = {}) {
|
|
31
|
+
super();
|
|
32
|
+
this.types = types;
|
|
33
|
+
this.metadata = metadata;
|
|
34
|
+
this.unannotatedTypes = types.map((type) => type.type);
|
|
35
|
+
// Since the array has been copied, mutations to it will not be handled correctly so freeze it.
|
|
36
|
+
// Support for such mutations could be added at a later date by making more things lazy.
|
|
37
|
+
Object.freeze(this.types);
|
|
38
|
+
Object.freeze(this.unannotatedTypes);
|
|
39
|
+
this.isLazy = false;
|
|
40
|
+
for (const type of this.unannotatedTypes) {
|
|
41
|
+
if ((0, flexList_js_1.isLazy)(type)) {
|
|
42
|
+
this.isLazy = true;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
markSchemaMostDerived(type);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const proxy = AnnotatedAllowedTypesInternal.proxy(this);
|
|
49
|
+
this.lazyEvaluate = new internal_2.Lazy(() => {
|
|
50
|
+
const annotated = this.isLazy
|
|
51
|
+
? AnnotatedAllowedTypesInternal.create(this.types.map((type) => ({
|
|
52
|
+
...type,
|
|
53
|
+
type: evaluateLazySchema(type.type),
|
|
54
|
+
})), this.metadata)
|
|
55
|
+
: proxy;
|
|
56
|
+
return {
|
|
57
|
+
annotated,
|
|
58
|
+
set: new Set(annotated.unannotatedTypes),
|
|
59
|
+
identifiers: new Set(annotated.unannotatedTypes.map((t) => t.identifier)),
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
return proxy;
|
|
63
|
+
}
|
|
64
|
+
evaluate() {
|
|
65
|
+
return this.lazyEvaluate.value.annotated;
|
|
66
|
+
}
|
|
67
|
+
evaluateSet() {
|
|
68
|
+
return this.lazyEvaluate.value.set;
|
|
69
|
+
}
|
|
70
|
+
evaluateIdentifiers() {
|
|
71
|
+
return this.lazyEvaluate.value.identifiers;
|
|
72
|
+
}
|
|
73
|
+
static [Symbol.hasInstance](value) {
|
|
74
|
+
return Object.prototype.isPrototypeOf.call(this.prototype, value);
|
|
75
|
+
}
|
|
76
|
+
static narrow(value) {
|
|
77
|
+
if (!Object.prototype.isPrototypeOf.call(this.prototype, value)) {
|
|
78
|
+
throw new TypeError("Invalid AnnotatedAllowedTypes instance");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
static proxy(result) {
|
|
82
|
+
const proxy = new Proxy(result, {
|
|
83
|
+
set: () => {
|
|
84
|
+
throw new internal_1.UsageError("AnnotatedAllowedTypes is immutable");
|
|
85
|
+
},
|
|
86
|
+
get: (target, property, receiver) => {
|
|
87
|
+
// Hide common array editing methods.
|
|
88
|
+
if (property === "push" || property === "pop") {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
// Forward array lookup and array methods to the unannotated types array.
|
|
92
|
+
if (property in target.unannotatedTypes) {
|
|
93
|
+
return Reflect.get(target.unannotatedTypes, property);
|
|
94
|
+
}
|
|
95
|
+
// Forward anything else to target.
|
|
96
|
+
return Reflect.get(target, property);
|
|
97
|
+
},
|
|
98
|
+
has: (target, property) => {
|
|
99
|
+
if (property in target.unannotatedTypes) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
// Forward anything else to target.
|
|
103
|
+
return property in target;
|
|
104
|
+
},
|
|
105
|
+
ownKeys: (target) => {
|
|
106
|
+
const targetKeys = Reflect.ownKeys(target);
|
|
107
|
+
const unannotatedTypesKeys = Reflect.ownKeys(target.unannotatedTypes);
|
|
108
|
+
return [...unannotatedTypesKeys, ...targetKeys];
|
|
109
|
+
},
|
|
110
|
+
getOwnPropertyDescriptor: (target, property) => {
|
|
111
|
+
if (Object.prototype.hasOwnProperty.call(target.unannotatedTypes, property)) {
|
|
112
|
+
const inner = Object.getOwnPropertyDescriptor(target.unannotatedTypes, property);
|
|
113
|
+
return {
|
|
114
|
+
...inner,
|
|
115
|
+
// Since these properties are not on the target, make them non-configurable to confirm with proxy invariants.
|
|
116
|
+
configurable: true,
|
|
117
|
+
writable: false,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
const inner = Object.getOwnPropertyDescriptor(target, property);
|
|
122
|
+
return {
|
|
123
|
+
...inner,
|
|
124
|
+
writable: false,
|
|
125
|
+
// Allow only array entries to be enumerable.
|
|
126
|
+
enumerable: false,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
return proxy;
|
|
132
|
+
}
|
|
133
|
+
static create(types, metadata = {}) {
|
|
134
|
+
const result = new AnnotatedAllowedTypesInternal(types, metadata);
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
static createUnannotated(types, metadata = {}) {
|
|
138
|
+
const annotatedTypes = types.map(normalizeToAnnotatedAllowedType);
|
|
139
|
+
const result = AnnotatedAllowedTypesInternal.create(annotatedTypes, metadata);
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
static createMixed(types, metadata = {}) {
|
|
143
|
+
const annotatedTypes = types.map(normalizeToAnnotatedAllowedType);
|
|
144
|
+
const result = AnnotatedAllowedTypesInternal.create(annotatedTypes, metadata);
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.AnnotatedAllowedTypesInternal = AnnotatedAllowedTypesInternal;
|
|
23
149
|
/**
|
|
24
150
|
* Checks if the given allowed type is annotated with {@link AllowedTypeMetadata}.
|
|
25
151
|
*/
|
|
@@ -47,29 +173,11 @@ exports.SchemaUpgrade = SchemaUpgrade;
|
|
|
47
173
|
exports.createSchemaUpgrade = () => new SchemaUpgrade();
|
|
48
174
|
})();
|
|
49
175
|
/**
|
|
50
|
-
* Normalizes
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of
|
|
54
|
-
* recursive schemas may fail.
|
|
55
|
-
*
|
|
56
|
-
* @internal
|
|
176
|
+
* Normalizes an {@link ImplicitAllowedTypes} to an {@link AllowedTypesFull}.
|
|
177
|
+
* @alpha
|
|
57
178
|
*/
|
|
58
179
|
function normalizeAllowedTypes(types) {
|
|
59
|
-
|
|
60
|
-
const unannotated = unannotateImplicitAllowedTypes(types);
|
|
61
|
-
const normalized = new Set();
|
|
62
|
-
if ((0, index_js_1.isReadonlyArray)(unannotated)) {
|
|
63
|
-
// Types array must not be modified after it is normalized since that would result in the user of the normalized data having wrong (out of date) content.
|
|
64
|
-
Object.freeze(unannotated);
|
|
65
|
-
for (const lazyType of unannotated) {
|
|
66
|
-
normalized.add(evaluateLazySchema(lazyType));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
normalized.add(evaluateLazySchema(unannotated));
|
|
71
|
-
}
|
|
72
|
-
return normalized;
|
|
180
|
+
return normalizeAllowedTypesInternal(types);
|
|
73
181
|
}
|
|
74
182
|
exports.normalizeAllowedTypes = normalizeAllowedTypes;
|
|
75
183
|
/**
|
|
@@ -85,72 +193,42 @@ function normalizeToAnnotatedAllowedType(type) {
|
|
|
85
193
|
}
|
|
86
194
|
exports.normalizeToAnnotatedAllowedType = normalizeToAnnotatedAllowedType;
|
|
87
195
|
/**
|
|
88
|
-
*
|
|
89
|
-
* lazy schema declarations and adding empty metadata if it doesn't already exist.
|
|
90
|
-
*
|
|
91
|
-
* @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of
|
|
92
|
-
* recursive schemas may fail.
|
|
196
|
+
* See note inside {@link normalizeAllowedTypesInternal}.
|
|
93
197
|
*/
|
|
94
|
-
|
|
95
|
-
const typesWithoutAnnotation = isAnnotatedAllowedTypes(types) ? types.types : types;
|
|
96
|
-
const annotatedTypes = [];
|
|
97
|
-
if ((0, index_js_1.isReadonlyArray)(typesWithoutAnnotation)) {
|
|
98
|
-
for (const annotatedType of typesWithoutAnnotation) {
|
|
99
|
-
if (isAnnotatedAllowedType(annotatedType)) {
|
|
100
|
-
annotatedTypes.push({
|
|
101
|
-
type: evaluateLazySchema(annotatedType.type),
|
|
102
|
-
metadata: annotatedType.metadata,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
annotatedTypes.push({ type: evaluateLazySchema(annotatedType), metadata: {} });
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
if (isAnnotatedAllowedType(typesWithoutAnnotation)) {
|
|
112
|
-
annotatedTypes.push({
|
|
113
|
-
type: evaluateLazySchema(typesWithoutAnnotation.type),
|
|
114
|
-
metadata: typesWithoutAnnotation.metadata,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
annotatedTypes.push({ type: evaluateLazySchema(typesWithoutAnnotation), metadata: {} });
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
metadata: isAnnotatedAllowedTypes(types) ? types.metadata : {},
|
|
123
|
-
types: annotatedTypes,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
exports.normalizeAnnotatedAllowedTypes = normalizeAnnotatedAllowedTypes;
|
|
198
|
+
const cachedNormalize = new WeakMap();
|
|
127
199
|
/**
|
|
128
|
-
*
|
|
129
|
-
* any annotations.
|
|
130
|
-
* @remarks
|
|
131
|
-
* This does not evaluate any lazy schemas.
|
|
200
|
+
* Normalizes allowed types to an {@link AllowedTypesFullInternal}.
|
|
132
201
|
*/
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
202
|
+
function normalizeAllowedTypesInternal(type) {
|
|
203
|
+
if (isAnnotatedAllowedTypes(type)) {
|
|
204
|
+
return type;
|
|
205
|
+
}
|
|
206
|
+
// This caching accomplishes two things:
|
|
207
|
+
// 1. It avoids redundant computations for the same input.
|
|
208
|
+
// 2. It provides a stable object identity for the output in case the input is normalized twice and other systems (such as unhydrated contexts) are cached based on the object identity of the output.
|
|
209
|
+
// It is this second case which is the more important since creating the AnnotatedAllowedTypesInternal is rather cheap.
|
|
210
|
+
// Adding this cache improved the performance of the "large recursive union" test (which mostly just constructs a TreeConfiguration) by ~5 times.
|
|
211
|
+
// This cache is strictly a performance optimization: it is not required for correctness.
|
|
212
|
+
return (0, index_js_1.getOrCreate)(cachedNormalize, type, () => {
|
|
213
|
+
// Due to more specific internal type, the above does not narrow sufficiently, so more narrowing is needed.
|
|
214
|
+
// It is possible this will give a false error if a TreeNodeSchema which matches this check is used.
|
|
215
|
+
(0, internal_2.assert)(!("types" in type && "metadata" in type), "invalid AnnotatedAllowedTypes");
|
|
216
|
+
const annotatedTypes = ((0, index_js_1.isReadonlyArray)(type) ? type : [type]).map(normalizeToAnnotatedAllowedType);
|
|
217
|
+
return AnnotatedAllowedTypesInternal.create(annotatedTypes);
|
|
218
|
+
});
|
|
141
219
|
}
|
|
142
|
-
exports.
|
|
220
|
+
exports.normalizeAllowedTypesInternal = normalizeAllowedTypesInternal;
|
|
143
221
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
222
|
+
* Normalizes an {@link ImplicitAllowedTypes} to an {@link AllowedTypesFullInternalEvaluated} by eagerly evaluating any
|
|
223
|
+
* lazy schema declarations and adding empty metadata if it doesn't already exist.
|
|
224
|
+
*
|
|
225
|
+
* @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of
|
|
226
|
+
* recursive schemas may fail.
|
|
147
227
|
*/
|
|
148
|
-
function
|
|
149
|
-
return
|
|
150
|
-
? allowedType.type
|
|
151
|
-
: allowedType;
|
|
228
|
+
function normalizeAndEvaluateAnnotatedAllowedTypes(types) {
|
|
229
|
+
return normalizeAllowedTypesInternal(types).evaluate();
|
|
152
230
|
}
|
|
153
|
-
exports.
|
|
231
|
+
exports.normalizeAndEvaluateAnnotatedAllowedTypes = normalizeAndEvaluateAnnotatedAllowedTypes;
|
|
154
232
|
const cachedLazyItem = new WeakMap();
|
|
155
233
|
/**
|
|
156
234
|
* Returns the schema referenced by the {@link LazyItem}.
|