@fluidframework/tree 2.33.2 → 2.40.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/.vscode/settings.json +2 -0
- package/CHANGELOG.md +64 -0
- package/api-report/tree.alpha.api.md +124 -51
- package/api-report/tree.beta.api.md +31 -27
- package/api-report/tree.legacy.alpha.api.md +24 -23
- package/api-report/tree.legacy.public.api.md +24 -23
- package/api-report/tree.public.api.md +24 -23
- package/dist/alpha.d.ts +17 -1
- package/dist/beta.d.ts +2 -0
- package/dist/codec/codec.d.ts +5 -1
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +6 -2
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -1
- package/dist/codec/index.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
- package/dist/core/schema-stored/formatV1.d.ts.map +1 -0
- package/dist/core/schema-stored/{format.js → formatV1.js} +1 -1
- package/dist/core/schema-stored/formatV1.js.map +1 -0
- package/dist/core/schema-stored/index.d.ts +3 -3
- package/dist/core/schema-stored/index.d.ts.map +1 -1
- package/dist/core/schema-stored/index.js +3 -3
- package/dist/core/schema-stored/index.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +3 -1
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +8 -6
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
- package/dist/core/schema-view/index.d.ts +1 -1
- package/dist/core/schema-view/index.d.ts.map +1 -1
- package/dist/core/schema-view/index.js +1 -2
- package/dist/core/schema-view/index.js.map +1 -1
- package/dist/core/schema-view/view.d.ts +0 -27
- package/dist/core/schema-view/view.d.ts.map +1 -1
- package/dist/core/schema-view/view.js +1 -35
- package/dist/core/schema-view/view.js.map +1 -1
- package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
- package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
- package/dist/core/tree/persistedTreeTextFormat.js +1 -1
- package/dist/core/tree/persistedTreeTextFormat.js.map +1 -1
- package/dist/feature-libraries/forest-summary/format.d.ts +2 -2
- package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/format.js +1 -1
- package/dist/feature-libraries/forest-summary/format.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +4 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.d.ts +3 -3
- package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.js +2 -2
- package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -5
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +34 -5
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +63 -9
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/{lib/feature-libraries/schema-index/format.d.ts → dist/feature-libraries/schema-index/formatV1.d.ts} +9 -9
- package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
- package/dist/feature-libraries/schema-index/{format.js → formatV1.js} +4 -4
- package/dist/feature-libraries/schema-index/formatV1.js.map +1 -0
- package/dist/feature-libraries/schema-index/index.d.ts +2 -2
- package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/index.js +6 -3
- package/dist/feature-libraries/schema-index/index.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +4 -4
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +0 -1
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/jsonDomainSchema.d.ts +2 -2
- package/dist/jsonDomainSchema.js +2 -2
- package/dist/jsonDomainSchema.js.map +1 -1
- package/dist/legacy.d.ts +2 -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 +2 -0
- package/dist/serializableDomainSchema.d.ts +3 -3
- package/dist/serializableDomainSchema.js +2 -2
- package/dist/serializableDomainSchema.js.map +1 -1
- package/dist/shared-tree/independentView.d.ts +1 -1
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +1 -1
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +4 -3
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +6 -5
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +10 -11
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +11 -36
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +3 -3
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +4 -7
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +28 -3
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +29 -3
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/{treeApi.d.ts → tree.d.ts} +58 -34
- package/dist/shared-tree/tree.d.ts.map +1 -0
- package/dist/shared-tree/{treeApi.js → tree.js} +6 -6
- package/dist/shared-tree/tree.js.map +1 -0
- package/{lib/shared-tree/treeApiAlpha.d.ts → dist/shared-tree/treeAlpha.d.ts} +24 -14
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -0
- package/dist/shared-tree/{treeApiAlpha.js → treeAlpha.js} +7 -5
- package/dist/shared-tree/treeAlpha.js.map +1 -0
- package/dist/shared-tree-core/branchCommitEnricher.d.ts +0 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js +0 -1
- package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.d.ts +1 -1
- package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.js +4 -1
- package/dist/shared-tree-core/transactionEnricher.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 +177 -0
- package/dist/simple-tree/api/configuration.d.ts.map +1 -0
- package/dist/simple-tree/api/configuration.js +163 -0
- package/dist/simple-tree/api/configuration.js.map +1 -0
- package/dist/simple-tree/api/getJsonSchema.js +2 -2
- package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +9 -5
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +9 -7
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
- package/dist/simple-tree/api/{view.js → schemaCompatibilityTester.js} +9 -9
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
- package/dist/simple-tree/api/schemaFactory.d.ts +25 -10
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +27 -12
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +2 -2
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
- 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.d.ts +1 -1
- package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +11 -10
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +16 -11
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +30 -174
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +1 -156
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/{lib/simple-tree/api/treeApiBeta.d.ts → dist/simple-tree/api/treeBeta.d.ts} +17 -6
- package/dist/simple-tree/api/treeBeta.d.ts.map +1 -0
- package/dist/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
- package/dist/simple-tree/api/treeBeta.js.map +1 -0
- package/dist/simple-tree/api/treeChangeEvents.d.ts +83 -0
- package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
- package/dist/simple-tree/api/treeChangeEvents.js +7 -0
- package/dist/simple-tree/api/treeChangeEvents.js.map +1 -0
- package/dist/simple-tree/api/treeNodeApi.d.ts +2 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +4 -9
- 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/arrayNode.d.ts +30 -2
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +3 -2
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/arrayNodeTypes.d.ts +3 -3
- package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/arrayNodeTypes.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +2 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +5 -5
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNode.d.ts +94 -0
- package/dist/simple-tree/core/treeNode.d.ts.map +1 -0
- package/dist/simple-tree/core/treeNode.js +123 -0
- package/dist/simple-tree/core/treeNode.js.map +1 -0
- package/dist/simple-tree/core/treeNodeKernel.d.ts +2 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +3 -1
- 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/types.d.ts +0 -165
- package/dist/simple-tree/core/types.d.ts.map +1 -1
- package/dist/simple-tree/core/types.js +1 -113
- package/dist/simple-tree/core/types.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +1 -1
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.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 +4 -3
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts +2 -2
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +1 -1
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/mapNodeTypes.d.ts +3 -3
- package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/mapNodeTypes.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +18 -5
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +4 -3
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/objectNodeTypes.d.ts +4 -4
- package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/objectNodeTypes.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +164 -13
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +107 -8
- package/dist/simple-tree/schemaTypes.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 +27 -32
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +2 -2
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/tableSchema.d.ts +455 -125
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +398 -101
- package/dist/tableSchema.js.map +1 -1
- package/dist/treeFactory.d.ts +1 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +30 -75
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/typeUtils.d.ts +1 -1
- package/dist/util/typeUtils.js.map +1 -1
- package/lib/alpha.d.ts +17 -1
- package/lib/beta.d.ts +2 -0
- package/lib/codec/codec.d.ts +5 -1
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +5 -1
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -2
- package/lib/core/index.js.map +1 -1
- package/lib/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
- package/lib/core/schema-stored/formatV1.d.ts.map +1 -0
- package/lib/core/schema-stored/{format.js → formatV1.js} +1 -1
- package/lib/core/schema-stored/formatV1.js.map +1 -0
- package/lib/core/schema-stored/index.d.ts +3 -3
- package/lib/core/schema-stored/index.d.ts.map +1 -1
- package/lib/core/schema-stored/index.js +2 -2
- package/lib/core/schema-stored/index.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +3 -1
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +3 -1
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.d.ts +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
- package/lib/core/schema-view/index.d.ts +1 -1
- package/lib/core/schema-view/index.d.ts.map +1 -1
- package/lib/core/schema-view/index.js +1 -1
- package/lib/core/schema-view/index.js.map +1 -1
- package/lib/core/schema-view/view.d.ts +0 -27
- package/lib/core/schema-view/view.d.ts.map +1 -1
- package/lib/core/schema-view/view.js +0 -34
- package/lib/core/schema-view/view.js.map +1 -1
- package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
- package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
- package/lib/core/tree/persistedTreeTextFormat.js +2 -2
- package/lib/core/tree/persistedTreeTextFormat.js.map +1 -1
- package/lib/feature-libraries/forest-summary/format.d.ts +2 -2
- package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/format.js +2 -2
- package/lib/feature-libraries/forest-summary/format.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.d.ts +3 -3
- package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.js +2 -2
- package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js +3 -3
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -6
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts +34 -5
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +61 -9
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/{dist/feature-libraries/schema-index/format.d.ts → lib/feature-libraries/schema-index/formatV1.d.ts} +9 -9
- package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
- package/lib/feature-libraries/schema-index/{format.js → formatV1.js} +5 -5
- package/lib/feature-libraries/schema-index/formatV1.js.map +1 -0
- package/lib/feature-libraries/schema-index/index.d.ts +2 -2
- package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/index.js +2 -2
- package/lib/feature-libraries/schema-index/index.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +5 -5
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +0 -1
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/jsonDomainSchema.d.ts +2 -2
- package/lib/jsonDomainSchema.js +2 -2
- package/lib/jsonDomainSchema.js.map +1 -1
- package/lib/legacy.d.ts +2 -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 +2 -0
- package/lib/serializableDomainSchema.d.ts +3 -3
- package/lib/serializableDomainSchema.js +2 -2
- package/lib/serializableDomainSchema.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts +1 -1
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +2 -2
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +4 -3
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +3 -3
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +10 -11
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +12 -37
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +3 -3
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +6 -9
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +28 -3
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +29 -4
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/{treeApi.d.ts → tree.d.ts} +58 -34
- package/lib/shared-tree/tree.d.ts.map +1 -0
- package/lib/shared-tree/{treeApi.js → tree.js} +5 -5
- package/lib/shared-tree/tree.js.map +1 -0
- package/{dist/shared-tree/treeApiAlpha.d.ts → lib/shared-tree/treeAlpha.d.ts} +24 -14
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -0
- package/lib/shared-tree/{treeApiAlpha.js → treeAlpha.js} +8 -6
- package/lib/shared-tree/treeAlpha.js.map +1 -0
- package/lib/shared-tree-core/branchCommitEnricher.d.ts +0 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.js +0 -1
- package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.d.ts +1 -1
- package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.js +4 -1
- package/lib/shared-tree-core/transactionEnricher.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 +177 -0
- package/lib/simple-tree/api/configuration.d.ts.map +1 -0
- package/lib/simple-tree/api/configuration.js +157 -0
- package/lib/simple-tree/api/configuration.js.map +1 -0
- package/lib/simple-tree/api/getJsonSchema.js +1 -1
- package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +9 -5
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +5 -4
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
- package/lib/simple-tree/api/{view.js → schemaCompatibilityTester.js} +7 -7
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
- package/lib/simple-tree/api/schemaFactory.d.ts +25 -10
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +27 -12
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +2 -2
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
- 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.d.ts +1 -1
- package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +11 -10
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +20 -13
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +30 -174
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +0 -152
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/{dist/simple-tree/api/treeApiBeta.d.ts → lib/simple-tree/api/treeBeta.d.ts} +17 -6
- package/lib/simple-tree/api/treeBeta.d.ts.map +1 -0
- package/lib/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
- package/lib/simple-tree/api/treeBeta.js.map +1 -0
- package/lib/simple-tree/api/treeChangeEvents.d.ts +83 -0
- package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
- package/lib/simple-tree/api/treeChangeEvents.js +6 -0
- package/lib/simple-tree/api/treeChangeEvents.js.map +1 -0
- package/lib/simple-tree/api/treeNodeApi.d.ts +2 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +4 -9
- 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/arrayNode.d.ts +30 -2
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +4 -3
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/arrayNodeTypes.d.ts +3 -3
- package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/arrayNodeTypes.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +2 -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/treeNode.d.ts +94 -0
- package/lib/simple-tree/core/treeNode.d.ts.map +1 -0
- package/lib/simple-tree/core/treeNode.js +118 -0
- package/lib/simple-tree/core/treeNode.js.map +1 -0
- package/lib/simple-tree/core/treeNodeKernel.d.ts +2 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +3 -1
- 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/types.d.ts +0 -165
- package/lib/simple-tree/core/types.d.ts.map +1 -1
- package/lib/simple-tree/core/types.js +0 -110
- package/lib/simple-tree/core/types.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +1 -1
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/index.d.ts +4 -4
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts +2 -2
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +2 -2
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/mapNodeTypes.d.ts +3 -3
- package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/mapNodeTypes.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +18 -5
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +5 -4
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/objectNodeTypes.d.ts +4 -4
- package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/objectNodeTypes.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +164 -13
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +96 -8
- package/lib/simple-tree/schemaTypes.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 +26 -31
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +2 -2
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/tableSchema.d.ts +455 -125
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +398 -101
- package/lib/tableSchema.js.map +1 -1
- package/lib/treeFactory.d.ts +1 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +30 -75
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/typeUtils.d.ts +1 -1
- package/lib/util/typeUtils.js.map +1 -1
- package/package.json +21 -21
- package/src/codec/codec.ts +6 -1
- package/src/codec/index.ts +1 -0
- package/src/core/index.ts +1 -2
- package/src/core/schema-stored/index.ts +3 -3
- package/src/core/schema-stored/schema.ts +3 -1
- package/src/core/schema-stored/storedSchemaRepository.ts +1 -1
- package/src/core/schema-view/index.ts +0 -1
- package/src/core/schema-view/view.ts +0 -31
- package/src/core/tree/persistedTreeTextFormat.ts +2 -2
- package/src/feature-libraries/forest-summary/format.ts +2 -2
- package/src/feature-libraries/index.ts +7 -1
- package/src/feature-libraries/mapTreeCursor.ts +3 -3
- package/src/feature-libraries/modular-schema/modularChangeFormat.ts +3 -3
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +38 -9
- package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -4
- package/src/feature-libraries/schema-index/codec.ts +80 -12
- package/src/feature-libraries/schema-index/{format.ts → formatV1.ts} +4 -4
- package/src/feature-libraries/schema-index/index.ts +7 -2
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +9 -9
- package/src/index.ts +18 -1
- package/src/internalTypes.ts +0 -2
- package/src/jsonDomainSchema.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/src/serializableDomainSchema.ts +3 -3
- package/src/shared-tree/independentView.ts +4 -3
- package/src/shared-tree/index.ts +5 -6
- package/src/shared-tree/schematizeTree.ts +10 -40
- package/src/shared-tree/schematizingTreeView.ts +12 -17
- package/src/shared-tree/sharedTree.ts +67 -6
- package/src/shared-tree/{treeApi.ts → tree.ts} +75 -51
- package/src/shared-tree/{treeApiAlpha.ts → treeAlpha.ts} +28 -16
- package/src/shared-tree-core/branchCommitEnricher.ts +0 -1
- package/src/shared-tree-core/transactionEnricher.ts +4 -1
- package/src/simple-tree/api/conciseTree.ts +1 -1
- package/src/simple-tree/api/configuration.ts +353 -0
- package/src/simple-tree/api/getJsonSchema.ts +1 -1
- package/src/simple-tree/api/index.ts +23 -15
- package/src/simple-tree/api/{view.ts → schemaCompatibilityTester.ts} +8 -15
- package/src/simple-tree/api/schemaFactory.ts +139 -19
- package/src/simple-tree/api/schemaFactoryAlpha.ts +7 -5
- package/src/simple-tree/api/schemaFactoryRecursive.ts +102 -38
- package/src/simple-tree/api/schemaFromSimple.ts +2 -2
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
- package/src/simple-tree/api/storedSchema.ts +32 -17
- package/src/simple-tree/api/tree.ts +38 -354
- package/src/simple-tree/api/{treeApiBeta.ts → treeBeta.ts} +20 -6
- package/src/simple-tree/api/treeChangeEvents.ts +84 -0
- package/src/simple-tree/api/treeNodeApi.ts +1 -1
- package/src/simple-tree/api/typesUnsafe.ts +15 -11
- package/src/simple-tree/arrayNode.ts +38 -5
- package/src/simple-tree/arrayNodeTypes.ts +8 -7
- package/src/simple-tree/core/getOrCreateNode.ts +1 -1
- package/src/simple-tree/core/index.ts +5 -4
- package/src/simple-tree/core/treeNode.ts +163 -0
- package/src/simple-tree/core/treeNodeKernel.ts +2 -1
- package/src/simple-tree/core/treeNodeSchema.ts +3 -1
- package/src/simple-tree/core/types.ts +0 -234
- package/src/simple-tree/core/withType.ts +1 -1
- package/src/simple-tree/index.ts +19 -2
- package/src/simple-tree/mapNode.ts +11 -3
- package/src/simple-tree/mapNodeTypes.ts +10 -7
- package/src/simple-tree/objectNode.ts +39 -15
- package/src/simple-tree/objectNodeTypes.ts +9 -5
- package/src/simple-tree/schemaTypes.ts +354 -25
- package/src/simple-tree/toStoredSchema.ts +42 -41
- package/src/simple-tree/treeNodeValid.ts +2 -2
- package/src/tableSchema.ts +1206 -434
- package/src/treeFactory.ts +56 -173
- package/src/util/typeUtils.ts +1 -1
- package/dist/core/schema-stored/format.d.ts.map +0 -1
- package/dist/core/schema-stored/format.js.map +0 -1
- package/dist/feature-libraries/schema-index/format.d.ts.map +0 -1
- package/dist/feature-libraries/schema-index/format.js.map +0 -1
- package/dist/shared-tree/treeApi.d.ts.map +0 -1
- package/dist/shared-tree/treeApi.js.map +0 -1
- package/dist/shared-tree/treeApiAlpha.d.ts.map +0 -1
- package/dist/shared-tree/treeApiAlpha.js.map +0 -1
- package/dist/simple-tree/api/treeApiBeta.d.ts.map +0 -1
- package/dist/simple-tree/api/treeApiBeta.js.map +0 -1
- package/dist/simple-tree/api/view.d.ts.map +0 -1
- package/dist/simple-tree/api/view.js.map +0 -1
- package/lib/core/schema-stored/format.d.ts.map +0 -1
- package/lib/core/schema-stored/format.js.map +0 -1
- package/lib/feature-libraries/schema-index/format.d.ts.map +0 -1
- package/lib/feature-libraries/schema-index/format.js.map +0 -1
- package/lib/shared-tree/treeApi.d.ts.map +0 -1
- package/lib/shared-tree/treeApi.js.map +0 -1
- package/lib/shared-tree/treeApiAlpha.d.ts.map +0 -1
- package/lib/shared-tree/treeApiAlpha.js.map +0 -1
- package/lib/simple-tree/api/treeApiBeta.d.ts.map +0 -1
- package/lib/simple-tree/api/treeApiBeta.js.map +0 -1
- package/lib/simple-tree/api/view.d.ts.map +0 -1
- package/lib/simple-tree/api/view.js.map +0 -1
- /package/src/core/schema-stored/{format.ts → formatV1.ts} +0 -0
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
type requireTrue,
|
|
18
18
|
type areOnlyKeys,
|
|
19
19
|
getOrCreate,
|
|
20
|
+
type RestrictiveStringRecord,
|
|
21
|
+
type IsUnion,
|
|
20
22
|
} from "../util/index.js";
|
|
21
23
|
import type {
|
|
22
24
|
Unhydrated,
|
|
@@ -73,13 +75,97 @@ export function isTreeNodeSchemaClass<
|
|
|
73
75
|
* Ideally this restriction would be modeled in the type itself, but it is not ergonomic to do so as there is no easy (when compared to arrays)
|
|
74
76
|
* way to declare and manipulate unordered sets of types in TypeScript.
|
|
75
77
|
*
|
|
76
|
-
*
|
|
78
|
+
* Duplicate entries in this array are not allowed and will produce runtime errors.
|
|
79
|
+
* Duplicate types are allowed,
|
|
80
|
+
* but this must only be reflected in the type and not the runtime values.
|
|
81
|
+
* This duplication can be used to encode the typing when the number of items in the array is not known at compile time
|
|
82
|
+
* but some of the items are known to be present unconditionally.
|
|
83
|
+
* For example, typing `[typeof A] | [typeof A, typeof B]` as `[typeof A, typeof B | typeof A]` is allowed,
|
|
84
|
+
* and can produce more useful {@link Input} types.
|
|
77
85
|
* @privateRemarks
|
|
78
86
|
* Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.
|
|
79
87
|
* @system @public
|
|
80
88
|
*/
|
|
81
89
|
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
|
82
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Stores annotations for a set of allowed types.
|
|
93
|
+
* @alpha
|
|
94
|
+
*/
|
|
95
|
+
export interface AnnotatedAllowedTypes {
|
|
96
|
+
/**
|
|
97
|
+
* Annotations that apply to a set of allowed types.
|
|
98
|
+
*/
|
|
99
|
+
readonly metadata: AllowedTypesMetadata;
|
|
100
|
+
/**
|
|
101
|
+
* All the allowed types that the annotations apply to. The types themselves may also have individual annotations.
|
|
102
|
+
*/
|
|
103
|
+
readonly types: readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Checks if the input is an {@link AnnotatedAllowedTypes}.
|
|
108
|
+
*/
|
|
109
|
+
export function isAnnotatedAllowedTypes(
|
|
110
|
+
allowedTypes: ImplicitAnnotatedAllowedTypes,
|
|
111
|
+
): allowedTypes is AnnotatedAllowedTypes {
|
|
112
|
+
return (
|
|
113
|
+
typeof allowedTypes === "object" && "metadata" in allowedTypes && "types" in allowedTypes
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Annotations that apply to a set of allowed types.
|
|
119
|
+
* @remarks
|
|
120
|
+
* Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.
|
|
121
|
+
* @alpha
|
|
122
|
+
*/
|
|
123
|
+
export interface AllowedTypesMetadata {
|
|
124
|
+
/**
|
|
125
|
+
* User defined metadata
|
|
126
|
+
*/
|
|
127
|
+
readonly custom?: unknown;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Stores annotations for an individual allowed type.
|
|
132
|
+
* @alpha
|
|
133
|
+
*/
|
|
134
|
+
export interface AnnotatedAllowedType<T extends TreeNodeSchema = TreeNodeSchema> {
|
|
135
|
+
/**
|
|
136
|
+
* Annotations for the allowed type.
|
|
137
|
+
*/
|
|
138
|
+
readonly metadata: AllowedTypeMetadata;
|
|
139
|
+
/**
|
|
140
|
+
* The allowed type the annotations apply to in a particular schema.
|
|
141
|
+
*/
|
|
142
|
+
readonly type: LazyItem<T>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Checks if the given allowed type is annotated with {@link AllowedTypeMetadata}.
|
|
147
|
+
*/
|
|
148
|
+
export function isAnnotatedAllowedType(
|
|
149
|
+
allowedType: AnnotatedAllowedType | LazyItem<TreeNodeSchema>,
|
|
150
|
+
): allowedType is AnnotatedAllowedType {
|
|
151
|
+
return "metadata" in allowedType && "type" in allowedType;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Annotations that apply to an individual allowed type.
|
|
156
|
+
* @remarks
|
|
157
|
+
* Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.
|
|
158
|
+
* @alpha
|
|
159
|
+
*/
|
|
160
|
+
export interface AllowedTypeMetadata {
|
|
161
|
+
/**
|
|
162
|
+
* User defined metadata
|
|
163
|
+
*/
|
|
164
|
+
readonly custom?: unknown;
|
|
165
|
+
|
|
166
|
+
// TODO metadata for enablable types will be added here
|
|
167
|
+
}
|
|
168
|
+
|
|
83
169
|
/**
|
|
84
170
|
* Kind of a field on an {@link TreeObjectNode}.
|
|
85
171
|
* @remarks
|
|
@@ -276,15 +362,53 @@ export interface FieldSchemaMetadata<TCustomMetadata = unknown> {
|
|
|
276
362
|
/**
|
|
277
363
|
* Package internal construction API.
|
|
278
364
|
*/
|
|
279
|
-
export
|
|
280
|
-
Kind extends FieldKind
|
|
281
|
-
Types extends ImplicitAllowedTypes
|
|
365
|
+
export function createFieldSchema<
|
|
366
|
+
Kind extends FieldKind,
|
|
367
|
+
Types extends ImplicitAllowedTypes,
|
|
368
|
+
TCustomMetadata = unknown,
|
|
369
|
+
>(
|
|
370
|
+
kind: Kind,
|
|
371
|
+
annotatedTypes: Types,
|
|
372
|
+
props?: FieldProps<TCustomMetadata>,
|
|
373
|
+
): FieldSchemaAlpha<Kind, Types, TCustomMetadata>;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Package internal construction API that supports annotations for allowed types.
|
|
377
|
+
*/
|
|
378
|
+
export function createFieldSchema<
|
|
379
|
+
Kind extends FieldKind,
|
|
380
|
+
Types extends ImplicitAnnotatedAllowedTypes,
|
|
381
|
+
TCustomMetadata = unknown,
|
|
382
|
+
>(
|
|
383
|
+
kind: Kind,
|
|
384
|
+
annotatedTypes: Types,
|
|
385
|
+
props?: FieldProps<TCustomMetadata>,
|
|
386
|
+
): FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata>;
|
|
387
|
+
|
|
388
|
+
export function createFieldSchema<
|
|
389
|
+
Kind extends FieldKind,
|
|
390
|
+
Types extends ImplicitAnnotatedAllowedTypes,
|
|
282
391
|
TCustomMetadata = unknown,
|
|
283
392
|
>(
|
|
284
393
|
kind: Kind,
|
|
285
|
-
|
|
394
|
+
annotatedTypes: Types,
|
|
286
395
|
props?: FieldProps<TCustomMetadata>,
|
|
287
|
-
)
|
|
396
|
+
): FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata> {
|
|
397
|
+
return createFieldSchemaPrivate(kind, annotatedTypes, props);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Implementation for {@link createFieldSchema}
|
|
402
|
+
*/
|
|
403
|
+
let createFieldSchemaPrivate: <
|
|
404
|
+
Kind extends FieldKind,
|
|
405
|
+
Types extends ImplicitAnnotatedAllowedTypes,
|
|
406
|
+
TCustomMetadata,
|
|
407
|
+
>(
|
|
408
|
+
kind: Kind,
|
|
409
|
+
annotatedTypes: Types,
|
|
410
|
+
props?: FieldProps<TCustomMetadata>,
|
|
411
|
+
) => FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata>;
|
|
288
412
|
|
|
289
413
|
/**
|
|
290
414
|
* All policy for a specific field,
|
|
@@ -382,21 +506,45 @@ export class FieldSchemaAlpha<
|
|
|
382
506
|
implements SimpleFieldSchema
|
|
383
507
|
{
|
|
384
508
|
private readonly lazyIdentifiers: Lazy<ReadonlySet<string>>;
|
|
509
|
+
private readonly lazyAnnotatedTypes: Lazy<ReadonlyMap<TreeNodeSchema, AllowedTypeMetadata>>;
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Metadata on the types of tree nodes allowed on this field.
|
|
513
|
+
*/
|
|
514
|
+
public readonly allowedTypesMetadata: AllowedTypesMetadata;
|
|
385
515
|
|
|
386
516
|
static {
|
|
387
|
-
|
|
388
|
-
Kind2 extends FieldKind
|
|
389
|
-
Types2 extends
|
|
390
|
-
TCustomMetadata2
|
|
517
|
+
createFieldSchemaPrivate = <
|
|
518
|
+
Kind2 extends FieldKind,
|
|
519
|
+
Types2 extends ImplicitAnnotatedAllowedTypes,
|
|
520
|
+
TCustomMetadata2,
|
|
391
521
|
>(
|
|
392
522
|
kind: Kind2,
|
|
393
|
-
|
|
523
|
+
annotatedAllowedTypes: Types2,
|
|
394
524
|
props?: FieldProps<TCustomMetadata2>,
|
|
395
|
-
) =>
|
|
525
|
+
) =>
|
|
526
|
+
new FieldSchemaAlpha(
|
|
527
|
+
kind,
|
|
528
|
+
unannotateImplicitAllowedTypes(annotatedAllowedTypes),
|
|
529
|
+
annotatedAllowedTypes,
|
|
530
|
+
props,
|
|
531
|
+
);
|
|
396
532
|
}
|
|
397
533
|
|
|
398
|
-
protected constructor(
|
|
399
|
-
|
|
534
|
+
protected constructor(
|
|
535
|
+
kind: Kind,
|
|
536
|
+
types: Types,
|
|
537
|
+
public readonly annotatedAllowedTypes: ImplicitAnnotatedAllowedTypes,
|
|
538
|
+
props?: FieldProps<TCustomMetadata>,
|
|
539
|
+
) {
|
|
540
|
+
super(kind, types, props);
|
|
541
|
+
|
|
542
|
+
this.allowedTypesMetadata = isAnnotatedAllowedTypes(annotatedAllowedTypes)
|
|
543
|
+
? annotatedAllowedTypes.metadata
|
|
544
|
+
: {};
|
|
545
|
+
this.lazyAnnotatedTypes = new Lazy(() =>
|
|
546
|
+
extractAnnotationsFromAllowedTypes(this.annotatedAllowedTypes),
|
|
547
|
+
);
|
|
400
548
|
this.lazyIdentifiers = new Lazy(
|
|
401
549
|
() => new Set([...this.allowedTypeSet].map((t) => t.identifier)),
|
|
402
550
|
);
|
|
@@ -405,6 +553,14 @@ export class FieldSchemaAlpha<
|
|
|
405
553
|
public get allowedTypesIdentifiers(): ReadonlySet<string> {
|
|
406
554
|
return this.lazyIdentifiers.value;
|
|
407
555
|
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* What types of tree nodes are allowed in this field and their annotations.
|
|
559
|
+
* @remarks Counterpart to {@link FieldSchemaAlpha.annotatedAllowedTypes}, with any lazy definitions evaluated.
|
|
560
|
+
*/
|
|
561
|
+
public get annotatedAllowedTypeSet(): ReadonlyMap<TreeNodeSchema, AllowedTypeMetadata> {
|
|
562
|
+
return this.lazyAnnotatedTypes.value;
|
|
563
|
+
}
|
|
408
564
|
}
|
|
409
565
|
|
|
410
566
|
/**
|
|
@@ -423,21 +579,25 @@ export class ObjectFieldSchema<
|
|
|
423
579
|
public constructor(
|
|
424
580
|
kind: Kind,
|
|
425
581
|
allowedTypes: Types,
|
|
582
|
+
annotatedTypes: ImplicitAnnotatedAllowedTypes,
|
|
426
583
|
props: FieldProps<TCustomMetadata> & { readonly key: string },
|
|
427
584
|
) {
|
|
428
|
-
super(kind, allowedTypes, props);
|
|
585
|
+
super(kind, allowedTypes, annotatedTypes, props);
|
|
429
586
|
this.storedKey = props.key;
|
|
430
587
|
}
|
|
431
588
|
}
|
|
432
589
|
|
|
433
590
|
/**
|
|
434
|
-
* Normalizes a {@link ImplicitFieldSchema} to a {@link FieldSchema}.
|
|
591
|
+
* Normalizes a {@link ImplicitFieldSchema} or {@link ImplicitAnnotatedFieldSchema} to a {@link FieldSchema}.
|
|
435
592
|
*/
|
|
436
|
-
export function normalizeFieldSchema(
|
|
593
|
+
export function normalizeFieldSchema(
|
|
594
|
+
schema: ImplicitFieldSchema | ImplicitAnnotatedFieldSchema,
|
|
595
|
+
): FieldSchemaAlpha {
|
|
437
596
|
return schema instanceof FieldSchema
|
|
438
597
|
? (schema as FieldSchemaAlpha)
|
|
439
598
|
: createFieldSchema(FieldKind.Required, schema);
|
|
440
599
|
}
|
|
600
|
+
|
|
441
601
|
/**
|
|
442
602
|
* Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any
|
|
443
603
|
* lazy schema declarations.
|
|
@@ -463,6 +623,88 @@ export function normalizeAllowedTypes(
|
|
|
463
623
|
return normalized;
|
|
464
624
|
}
|
|
465
625
|
|
|
626
|
+
/**
|
|
627
|
+
* Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist.
|
|
628
|
+
*/
|
|
629
|
+
export function normalizeToAnnotatedAllowedType<T extends TreeNodeSchema>(
|
|
630
|
+
type: T | AnnotatedAllowedType<T>,
|
|
631
|
+
): AnnotatedAllowedType<T> {
|
|
632
|
+
return isAnnotatedAllowedType(type)
|
|
633
|
+
? type
|
|
634
|
+
: {
|
|
635
|
+
metadata: {},
|
|
636
|
+
type,
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Converts an {@link ImplicitAnnotatedAllowedTypes} to an {@link ImplicitAllowedTypes}s, by removing
|
|
642
|
+
* any annotations.
|
|
643
|
+
* @remarks
|
|
644
|
+
* This does not evaluate any lazy schemas.
|
|
645
|
+
*/
|
|
646
|
+
export function unannotateImplicitAllowedTypes<Types extends ImplicitAnnotatedAllowedTypes>(
|
|
647
|
+
types: Types,
|
|
648
|
+
): UnannotateImplicitAllowedTypes<Types> {
|
|
649
|
+
return (
|
|
650
|
+
isAnnotatedAllowedTypes(types)
|
|
651
|
+
? types.types.map((allowedType) =>
|
|
652
|
+
isAnnotatedAllowedType(allowedType) ? allowedType.type : allowedType,
|
|
653
|
+
)
|
|
654
|
+
: isReadonlyArray(types)
|
|
655
|
+
? types.map((allowedType) =>
|
|
656
|
+
isAnnotatedAllowedType(allowedType) ? allowedType.type : allowedType,
|
|
657
|
+
)
|
|
658
|
+
: isAnnotatedAllowedType(types)
|
|
659
|
+
? (types.type as UnannotateImplicitAllowedTypes<Types>)
|
|
660
|
+
: types
|
|
661
|
+
) as UnannotateImplicitAllowedTypes<Types>;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Removes annotations from a schema record.
|
|
666
|
+
*/
|
|
667
|
+
export function unannotateSchemaRecord<
|
|
668
|
+
Schema extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,
|
|
669
|
+
>(schemaRecord: Schema): UnannotateSchemaRecord<Schema> {
|
|
670
|
+
return Object.fromEntries(
|
|
671
|
+
Object.entries(schemaRecord).map(([key, schema]) => [
|
|
672
|
+
key,
|
|
673
|
+
schema instanceof FieldSchema ? schema : unannotateImplicitAllowedTypes(schema),
|
|
674
|
+
]),
|
|
675
|
+
) as UnannotateSchemaRecord<Schema>;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Converts annotated allowed types into a mapping between the type schema and their associated annotations.
|
|
680
|
+
*/
|
|
681
|
+
export function extractAnnotationsFromAllowedTypes(
|
|
682
|
+
types: ImplicitAnnotatedAllowedTypes,
|
|
683
|
+
): ReadonlyMap<TreeNodeSchema, AllowedTypeMetadata> {
|
|
684
|
+
const typesWithoutAnnotation = isAnnotatedAllowedTypes(types) ? types.types : types;
|
|
685
|
+
const annotations = new Map<TreeNodeSchema, AllowedTypeMetadata>();
|
|
686
|
+
if (isReadonlyArray(typesWithoutAnnotation)) {
|
|
687
|
+
for (const annotatedType of typesWithoutAnnotation) {
|
|
688
|
+
if (isAnnotatedAllowedType(annotatedType)) {
|
|
689
|
+
annotations.set(evaluateLazySchema(annotatedType.type), annotatedType.metadata);
|
|
690
|
+
} else {
|
|
691
|
+
annotations.set(evaluateLazySchema(annotatedType), {});
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
} else {
|
|
695
|
+
if (isAnnotatedAllowedType(typesWithoutAnnotation)) {
|
|
696
|
+
annotations.set(
|
|
697
|
+
evaluateLazySchema(typesWithoutAnnotation.type),
|
|
698
|
+
typesWithoutAnnotation.metadata,
|
|
699
|
+
);
|
|
700
|
+
} else {
|
|
701
|
+
annotations.set(evaluateLazySchema(typesWithoutAnnotation), {});
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
return annotations;
|
|
706
|
+
}
|
|
707
|
+
|
|
466
708
|
/**
|
|
467
709
|
* Returns true if the given {@link ImplicitFieldSchema} are equivalent, otherwise false.
|
|
468
710
|
* @remarks Two ImplicitFieldSchema are considered equivalent if all of the following are true:
|
|
@@ -645,6 +887,64 @@ export function markSchemaMostDerived(
|
|
|
645
887
|
*/
|
|
646
888
|
export type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;
|
|
647
889
|
|
|
890
|
+
/**
|
|
891
|
+
* Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree with
|
|
892
|
+
* additional metadata associated with the location they're allowed at.
|
|
893
|
+
* @alpha
|
|
894
|
+
*/
|
|
895
|
+
export type ImplicitAnnotatedAllowedTypes =
|
|
896
|
+
| TreeNodeSchema
|
|
897
|
+
| AnnotatedAllowedType
|
|
898
|
+
| AnnotatedAllowedTypes
|
|
899
|
+
| readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Returns an {@link ImplicitAllowedTypes} that is equivalent to the input without annotations.
|
|
903
|
+
* @system @alpha
|
|
904
|
+
*/
|
|
905
|
+
export type UnannotateImplicitAllowedTypes<T extends ImplicitAnnotatedAllowedTypes> =
|
|
906
|
+
T extends AnnotatedAllowedTypes
|
|
907
|
+
? UnannotateAllowedTypes<T>
|
|
908
|
+
: T extends AnnotatedAllowedType
|
|
909
|
+
? UnannotateAllowedType<T>
|
|
910
|
+
: T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]
|
|
911
|
+
? UnannotateAllowedTypesList<T>
|
|
912
|
+
: T extends TreeNodeSchema
|
|
913
|
+
? T
|
|
914
|
+
: never;
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Removes annotations from a list of allowed types that may contain annotations.
|
|
918
|
+
* @system @alpha
|
|
919
|
+
*/
|
|
920
|
+
export type UnannotateAllowedTypesList<
|
|
921
|
+
T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[],
|
|
922
|
+
> = {
|
|
923
|
+
[I in keyof T]: UnannotateAllowedTypeOrLazyItem<T[I]>;
|
|
924
|
+
};
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Removes annotations from an allowed type that may contain annotations.
|
|
928
|
+
* @system @alpha
|
|
929
|
+
*/
|
|
930
|
+
export type UnannotateAllowedTypeOrLazyItem<
|
|
931
|
+
T extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>,
|
|
932
|
+
> = T extends AnnotatedAllowedType<infer X> ? X : T;
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Removes all annotations from a set of allowed types.
|
|
936
|
+
* @system @alpha
|
|
937
|
+
*/
|
|
938
|
+
export type UnannotateAllowedTypes<T extends AnnotatedAllowedTypes> =
|
|
939
|
+
UnannotateAllowedTypesList<T["types"]>;
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Removes annotations from an allowed type.
|
|
943
|
+
* @system @alpha
|
|
944
|
+
*/
|
|
945
|
+
export type UnannotateAllowedType<T extends AnnotatedAllowedType> =
|
|
946
|
+
T extends AnnotatedAllowedType<infer X> ? [X] : T;
|
|
947
|
+
|
|
648
948
|
/**
|
|
649
949
|
* Schema for a field of a tree node.
|
|
650
950
|
* @remarks
|
|
@@ -653,6 +953,29 @@ export type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;
|
|
|
653
953
|
*/
|
|
654
954
|
export type ImplicitFieldSchema = FieldSchema | ImplicitAllowedTypes;
|
|
655
955
|
|
|
956
|
+
/**
|
|
957
|
+
* Annotated schema for a field of a tree node.
|
|
958
|
+
* @alpha
|
|
959
|
+
*/
|
|
960
|
+
export type ImplicitAnnotatedFieldSchema = FieldSchema | ImplicitAnnotatedAllowedTypes;
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Removes annotations from an annotated field schema.
|
|
964
|
+
* @system @alpha
|
|
965
|
+
*/
|
|
966
|
+
export type UnannotateImplicitFieldSchema<T extends ImplicitAnnotatedFieldSchema> =
|
|
967
|
+
T extends ImplicitAnnotatedAllowedTypes ? UnannotateImplicitAllowedTypes<T> : T;
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Removes annotations from field schemas in a schema record.
|
|
971
|
+
* @system @alpha
|
|
972
|
+
*/
|
|
973
|
+
export type UnannotateSchemaRecord<
|
|
974
|
+
T extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,
|
|
975
|
+
> = {
|
|
976
|
+
readonly [P in Extract<keyof T, string>]: UnannotateImplicitFieldSchema<T[P]>;
|
|
977
|
+
};
|
|
978
|
+
|
|
656
979
|
/**
|
|
657
980
|
* Converts an `ImplicitFieldSchema` to a property type suitable for reading a field with this that schema.
|
|
658
981
|
*
|
|
@@ -819,6 +1142,7 @@ export type TreeNodeFromImplicitAllowedTypes<
|
|
|
819
1142
|
* Consider a field with schema type of `A | B` (where A and B are types of schema).
|
|
820
1143
|
*
|
|
821
1144
|
* - Reading the field behaves covariantly so {@link NodeFromSchema} of `<A | B>` is the same as `NodeFromSchema<A> | NodeFromSchema<B>`, indicating that either type of node can be read from the field.
|
|
1145
|
+
*
|
|
822
1146
|
* - Writing to the field behaves contravariantly. Since it is unknown if the node actually has a schema `A` or a schema `B`, the only legal values (known to be in schema regardless of which schema the underlying node has) are values which are legal for both `A & B`.
|
|
823
1147
|
*
|
|
824
1148
|
* Note that this is distinct from the case where the schema is `[A, B]`.
|
|
@@ -884,16 +1208,21 @@ export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitA
|
|
|
884
1208
|
* @see {@link Input}
|
|
885
1209
|
*
|
|
886
1210
|
* @typeparam TList - AllowedTypes to process
|
|
1211
|
+
*
|
|
1212
|
+
* @privateRemarks
|
|
1213
|
+
* This loop is manually unrolled to allow larger unions before hitting the recursion limit in TypeScript.
|
|
887
1214
|
* @system @public
|
|
888
1215
|
*/
|
|
889
|
-
export type InsertableTreeNodeFromAllowedTypes<TList extends AllowedTypes> =
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
1216
|
+
export type InsertableTreeNodeFromAllowedTypes<TList extends AllowedTypes> =
|
|
1217
|
+
IsUnion<TList> extends true
|
|
1218
|
+
? never
|
|
1219
|
+
: {
|
|
1220
|
+
readonly [Property in keyof TList]: TList[Property] extends LazyItem<
|
|
1221
|
+
infer TSchema extends TreeNodeSchema
|
|
1222
|
+
>
|
|
1223
|
+
? InsertableTypedNode<TSchema>
|
|
1224
|
+
: never;
|
|
1225
|
+
}[number];
|
|
897
1226
|
|
|
898
1227
|
/**
|
|
899
1228
|
* Takes in `TreeNodeSchema[]` and returns a TypedNode union.
|
|
@@ -21,17 +21,16 @@ import {
|
|
|
21
21
|
} from "../core/index.js";
|
|
22
22
|
import { FieldKinds, type FlexFieldKind } from "../feature-libraries/index.js";
|
|
23
23
|
import { brand, getOrCreate } from "../util/index.js";
|
|
24
|
-
import { NodeKind
|
|
25
|
-
import {
|
|
26
|
-
FieldKind,
|
|
27
|
-
FieldSchema,
|
|
28
|
-
normalizeAllowedTypes,
|
|
29
|
-
type ImplicitAllowedTypes,
|
|
30
|
-
type ImplicitFieldSchema,
|
|
31
|
-
} from "./schemaTypes.js";
|
|
24
|
+
import { NodeKind } from "./core/index.js";
|
|
25
|
+
import { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from "./schemaTypes.js";
|
|
32
26
|
import { walkFieldSchema } from "./walkFieldSchema.js";
|
|
33
27
|
import { LeafNodeSchema } from "./leafNodeSchema.js";
|
|
34
|
-
import {
|
|
28
|
+
import type {
|
|
29
|
+
SimpleFieldSchema,
|
|
30
|
+
SimpleNodeSchema,
|
|
31
|
+
SimpleNodeSchemaBase,
|
|
32
|
+
SimpleTreeSchema,
|
|
33
|
+
} from "./simpleSchema.js";
|
|
35
34
|
|
|
36
35
|
const viewToStoredCache = new WeakMap<ImplicitFieldSchema, TreeStoredSchema>();
|
|
37
36
|
|
|
@@ -40,8 +39,9 @@ const viewToStoredCache = new WeakMap<ImplicitFieldSchema, TreeStoredSchema>();
|
|
|
40
39
|
*/
|
|
41
40
|
export function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {
|
|
42
41
|
return getOrCreate(viewToStoredCache, root, () => {
|
|
42
|
+
const normalized = normalizeFieldSchema(root);
|
|
43
43
|
const nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();
|
|
44
|
-
walkFieldSchema(
|
|
44
|
+
walkFieldSchema(normalized, {
|
|
45
45
|
node(schema) {
|
|
46
46
|
if (nodeSchema.has(brand(schema.identifier))) {
|
|
47
47
|
// Use JSON.stringify to quote and escape identifier string.
|
|
@@ -51,34 +51,44 @@ export function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {
|
|
|
51
51
|
)}. Remove or rename them to avoid the collision.`,
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
|
-
nodeSchema.set(
|
|
54
|
+
nodeSchema.set(
|
|
55
|
+
brand(schema.identifier),
|
|
56
|
+
getStoredSchema(schema as SimpleNodeSchemaBase<NodeKind> as SimpleNodeSchema),
|
|
57
|
+
);
|
|
55
58
|
},
|
|
56
59
|
});
|
|
57
60
|
|
|
58
61
|
const result: TreeStoredSchema = {
|
|
59
62
|
nodeSchema,
|
|
60
|
-
rootFieldSchema: convertField(
|
|
63
|
+
rootFieldSchema: convertField(normalized),
|
|
61
64
|
};
|
|
62
|
-
viewToStoredCache.set(root, result);
|
|
63
65
|
return result;
|
|
64
66
|
});
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
/**
|
|
68
|
-
*
|
|
70
|
+
* Converts a {@link SimpleTreeSchema} into a {@link TreeStoredSchema}.
|
|
69
71
|
*/
|
|
70
|
-
export function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
kind =
|
|
75
|
-
convertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);
|
|
76
|
-
allowedTypes = schema.allowedTypes;
|
|
77
|
-
} else {
|
|
78
|
-
kind = FieldKinds.required.identifier;
|
|
79
|
-
allowedTypes = schema;
|
|
72
|
+
export function simpleToStoredSchema(root: SimpleTreeSchema): TreeStoredSchema {
|
|
73
|
+
const nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();
|
|
74
|
+
for (const [identifier, schema] of root.definitions) {
|
|
75
|
+
nodeSchema.set(brand(identifier), getStoredSchema(schema));
|
|
80
76
|
}
|
|
81
|
-
|
|
77
|
+
|
|
78
|
+
const result: TreeStoredSchema = {
|
|
79
|
+
nodeSchema,
|
|
80
|
+
rootFieldSchema: convertField(root.root),
|
|
81
|
+
};
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.
|
|
87
|
+
*/
|
|
88
|
+
export function convertField(schema: SimpleFieldSchema): TreeFieldStoredSchema {
|
|
89
|
+
const kind: FieldKindIdentifier =
|
|
90
|
+
convertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);
|
|
91
|
+
const types: TreeTypeSet = schema.allowedTypesIdentifiers as TreeTypeSet;
|
|
82
92
|
return { kind, types };
|
|
83
93
|
}
|
|
84
94
|
|
|
@@ -88,42 +98,33 @@ const convertFieldKind = new Map<FieldKind, FlexFieldKind>([
|
|
|
88
98
|
[FieldKind.Identifier, FieldKinds.identifier],
|
|
89
99
|
]);
|
|
90
100
|
|
|
91
|
-
/**
|
|
92
|
-
* Normalizes an {@link ImplicitAllowedTypes} into an {@link TreeTypeSet}.
|
|
93
|
-
*/
|
|
94
|
-
export function convertAllowedTypes(schema: ImplicitAllowedTypes): TreeTypeSet {
|
|
95
|
-
return new Set([...normalizeAllowedTypes(schema)].map((item) => brand(item.identifier)));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
101
|
/**
|
|
99
102
|
* Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.
|
|
100
103
|
*/
|
|
101
|
-
export function getStoredSchema(schema:
|
|
104
|
+
export function getStoredSchema(schema: SimpleNodeSchema): TreeNodeStoredSchema {
|
|
102
105
|
const kind = schema.kind;
|
|
103
106
|
switch (kind) {
|
|
104
107
|
case NodeKind.Leaf: {
|
|
105
108
|
assert(schema instanceof LeafNodeSchema, 0xa4a /* invalid kind */);
|
|
106
|
-
return new LeafNodeStoredSchema(schema.
|
|
109
|
+
return new LeafNodeStoredSchema(schema.leafKind);
|
|
107
110
|
}
|
|
108
111
|
case NodeKind.Map: {
|
|
109
|
-
const
|
|
110
|
-
const types = convertAllowedTypes(fieldInfo);
|
|
112
|
+
const types = schema.allowedTypesIdentifiers as TreeTypeSet;
|
|
111
113
|
return new MapNodeStoredSchema({ kind: FieldKinds.optional.identifier, types });
|
|
112
114
|
}
|
|
113
115
|
case NodeKind.Array: {
|
|
114
|
-
const
|
|
116
|
+
const types = schema.allowedTypesIdentifiers as TreeTypeSet;
|
|
115
117
|
const field = {
|
|
116
118
|
kind: FieldKinds.sequence.identifier,
|
|
117
|
-
types
|
|
119
|
+
types,
|
|
118
120
|
};
|
|
119
121
|
const fields = new Map([[EmptyKey, field]]);
|
|
120
122
|
return new ObjectNodeStoredSchema(fields);
|
|
121
123
|
}
|
|
122
124
|
case NodeKind.Object: {
|
|
123
|
-
assert(isObjectNodeSchema(schema), 0xa4b /* invalid kind */);
|
|
124
125
|
const fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();
|
|
125
|
-
for (const
|
|
126
|
-
fields.set(
|
|
126
|
+
for (const fieldSchema of schema.fields.values()) {
|
|
127
|
+
fields.set(brand(fieldSchema.storedKey), convertField(fieldSchema));
|
|
127
128
|
}
|
|
128
129
|
return new ObjectNodeStoredSchema(fields);
|
|
129
130
|
}
|
|
@@ -174,9 +174,9 @@ export abstract class TreeNodeValid<TInput> extends TreeNode {
|
|
|
174
174
|
const cache = schema.oneTimeInitialize();
|
|
175
175
|
|
|
176
176
|
if (isTreeNode(input)) {
|
|
177
|
-
// TODO: update this once
|
|
177
|
+
// TODO: update this once TreeBeta.clone is stable.
|
|
178
178
|
throw new UsageError(
|
|
179
|
-
"Existing nodes may not be used as the constructor parameter for a new node. The existing node may be used directly instead of creating a new one, used as a child of the new node (if it has not yet been inserted into the tree). If the desired result is copying the provided node, it must be deep copied (since any child node would be parented under both the new and old nodes).
|
|
179
|
+
"Existing nodes may not be used as the constructor parameter for a new node. The existing node may be used directly instead of creating a new one, used as a child of the new node (if it has not yet been inserted into the tree). If the desired result is copying the provided node, it must be deep copied (since any child node would be parented under both the new and old nodes). `TreeBeta.clone` can be used to do this.",
|
|
180
180
|
);
|
|
181
181
|
}
|
|
182
182
|
|