@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
|
@@ -39,6 +39,9 @@ import {
|
|
|
39
39
|
type NodeSchemaOptions,
|
|
40
40
|
markSchemaMostDerived,
|
|
41
41
|
type FieldSchemaAlpha,
|
|
42
|
+
type ImplicitAnnotatedAllowedTypes,
|
|
43
|
+
type UnannotateImplicitAllowedTypes,
|
|
44
|
+
type UnannotateSchemaRecord,
|
|
42
45
|
} from "../schemaTypes.js";
|
|
43
46
|
import type {
|
|
44
47
|
NodeKind,
|
|
@@ -125,7 +128,7 @@ export interface SchemaFactoryObjectOptions<TCustomMetadata = unknown>
|
|
|
125
128
|
* ```
|
|
126
129
|
*
|
|
127
130
|
* If an application wants to be particularly careful to preserve all data on a node when editing it, it can use
|
|
128
|
-
* {@link TreeAlpha.importVerbose|import}/{@link TreeAlpha.exportVerbose|export} APIs with persistent keys.
|
|
131
|
+
* {@link (TreeAlpha:interface).importVerbose|import}/{@link (TreeAlpha:interface).exportVerbose|export} APIs with persistent keys.
|
|
129
132
|
*
|
|
130
133
|
* Note that public API methods which operate on entire nodes (such as `moveTo`, `moveToEnd`, etc. on arrays) do not encounter
|
|
131
134
|
* this problem as SharedTree's implementation stores the entire node in its lower layers. It's only when application code
|
|
@@ -179,7 +182,9 @@ export interface SchemaStatics {
|
|
|
179
182
|
*
|
|
180
183
|
* @remarks
|
|
181
184
|
* The number is a {@link https://en.wikipedia.org/wiki/Double-precision_floating-point_format | double-precision 64-bit binary format IEEE 754} value, however there are some exceptions:
|
|
185
|
+
*
|
|
182
186
|
* - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).
|
|
187
|
+
*
|
|
183
188
|
* - `-0` may be converted to `0` in some cases.
|
|
184
189
|
*
|
|
185
190
|
* These limitations match the limitations of JSON.
|
|
@@ -289,6 +294,58 @@ const defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => {
|
|
|
289
294
|
return undefined;
|
|
290
295
|
});
|
|
291
296
|
|
|
297
|
+
// The following overloads for optional and required are used to get around the fact that
|
|
298
|
+
// the compiler can't infer that UnannotateImplicitAllowedTypes<T> is equal to T when T is known to extend ImplicitAllowedTypes
|
|
299
|
+
|
|
300
|
+
function optional<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
|
|
301
|
+
t: T,
|
|
302
|
+
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
303
|
+
): FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata>;
|
|
304
|
+
|
|
305
|
+
function optional<
|
|
306
|
+
const T extends ImplicitAnnotatedAllowedTypes,
|
|
307
|
+
const TCustomMetadata = unknown,
|
|
308
|
+
>(
|
|
309
|
+
t: T,
|
|
310
|
+
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
311
|
+
): FieldSchemaAlpha<FieldKind.Optional, UnannotateImplicitAllowedTypes<T>, TCustomMetadata>;
|
|
312
|
+
|
|
313
|
+
function optional<
|
|
314
|
+
const T extends ImplicitAnnotatedAllowedTypes,
|
|
315
|
+
const TCustomMetadata = unknown,
|
|
316
|
+
>(
|
|
317
|
+
t: T,
|
|
318
|
+
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
319
|
+
): FieldSchemaAlpha<FieldKind.Optional, UnannotateImplicitAllowedTypes<T>, TCustomMetadata> {
|
|
320
|
+
return createFieldSchema(FieldKind.Optional, t, {
|
|
321
|
+
defaultProvider: defaultOptionalProvider,
|
|
322
|
+
...props,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function required<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
|
|
327
|
+
t: T,
|
|
328
|
+
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
329
|
+
): FieldSchemaAlpha<FieldKind.Required, T, TCustomMetadata>;
|
|
330
|
+
|
|
331
|
+
function required<
|
|
332
|
+
const T extends ImplicitAnnotatedAllowedTypes,
|
|
333
|
+
const TCustomMetadata = unknown,
|
|
334
|
+
>(
|
|
335
|
+
t: T,
|
|
336
|
+
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
337
|
+
): FieldSchemaAlpha<FieldKind.Required, UnannotateImplicitAllowedTypes<T>, TCustomMetadata>;
|
|
338
|
+
|
|
339
|
+
function required<
|
|
340
|
+
const T extends ImplicitAnnotatedAllowedTypes,
|
|
341
|
+
const TCustomMetadata = unknown,
|
|
342
|
+
>(
|
|
343
|
+
t: T,
|
|
344
|
+
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
345
|
+
): FieldSchemaAlpha<FieldKind.Required, UnannotateImplicitAllowedTypes<T>, TCustomMetadata> {
|
|
346
|
+
return createFieldSchema(FieldKind.Required, t, props);
|
|
347
|
+
}
|
|
348
|
+
|
|
292
349
|
/**
|
|
293
350
|
* Implementation of {@link SchemaStatics}.
|
|
294
351
|
* @remarks
|
|
@@ -303,22 +360,9 @@ export const schemaStaticsBase = {
|
|
|
303
360
|
handle: handleSchema,
|
|
304
361
|
leaves: [stringSchema, numberSchema, booleanSchema, nullSchema, handleSchema],
|
|
305
362
|
|
|
306
|
-
optional
|
|
307
|
-
t: T,
|
|
308
|
-
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
309
|
-
): FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata> => {
|
|
310
|
-
return createFieldSchema(FieldKind.Optional, t, {
|
|
311
|
-
defaultProvider: defaultOptionalProvider,
|
|
312
|
-
...props,
|
|
313
|
-
});
|
|
314
|
-
},
|
|
363
|
+
optional,
|
|
315
364
|
|
|
316
|
-
required
|
|
317
|
-
t: T,
|
|
318
|
-
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
319
|
-
): FieldSchemaAlpha<FieldKind.Required, T, TCustomMetadata> => {
|
|
320
|
-
return createFieldSchema(FieldKind.Required, t, props);
|
|
321
|
-
},
|
|
365
|
+
required,
|
|
322
366
|
|
|
323
367
|
optionalRecursive: <
|
|
324
368
|
const T extends System_Unsafe.ImplicitAllowedTypesUnsafe,
|
|
@@ -387,9 +431,13 @@ const schemaStaticsPublic: SchemaStatics = schemaStatics;
|
|
|
387
431
|
* It is legal to subclass the returned class, and even subclass that class,
|
|
388
432
|
* but only a single class from that class hierarchy can ever be instantiated or passed to any API as a {@link TreeNodeSchema|schema}.
|
|
389
433
|
* These base classes can be used with `instanceof`, but not with schema based APIs like `Tree.is`.
|
|
434
|
+
*
|
|
390
435
|
* 2. If overriding the constructor, the constructor must accept the same argument as the base constructor `super` and forward it to `super` unchanged.
|
|
436
|
+
*
|
|
391
437
|
* 3. Properties for fields defined in the schema should not be overridden.
|
|
438
|
+
*
|
|
392
439
|
* 4. Additional static members added to schema should pick relatively unique keys to reduce the risk of colliding with implementation details what are not exposed in the API.
|
|
440
|
+
*
|
|
393
441
|
* 5. If exporting the schema from a package which uses API-Extractor, export the base class and derived class separately to work around [a known limitation](https://github.com/microsoft/rushstack/issues/4429).
|
|
394
442
|
*
|
|
395
443
|
* Note:
|
|
@@ -607,12 +655,36 @@ export class SchemaFactory<
|
|
|
607
655
|
true,
|
|
608
656
|
T
|
|
609
657
|
> {
|
|
610
|
-
|
|
658
|
+
// The compiler can't infer that UnannotateSchemaRecord<T> is equal to T so we have to do a bunch of typing to make the error go away.
|
|
659
|
+
const object: TreeNodeSchemaClass<
|
|
660
|
+
ScopedSchemaName<TScope, Name>,
|
|
661
|
+
NodeKind.Object,
|
|
662
|
+
TreeObjectNode<UnannotateSchemaRecord<T>, ScopedSchemaName<TScope, Name>>,
|
|
663
|
+
object & InsertableObjectFromSchemaRecord<UnannotateSchemaRecord<T>>,
|
|
664
|
+
true,
|
|
665
|
+
T
|
|
666
|
+
> = objectSchema(
|
|
611
667
|
this.scoped(name),
|
|
612
668
|
fields,
|
|
613
669
|
true,
|
|
614
670
|
defaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,
|
|
615
671
|
);
|
|
672
|
+
|
|
673
|
+
return object as TreeNodeSchemaClass<
|
|
674
|
+
ScopedSchemaName<TScope, Name>,
|
|
675
|
+
NodeKind.Object,
|
|
676
|
+
TreeObjectNode<RestrictiveStringRecord<ImplicitFieldSchema>>,
|
|
677
|
+
unknown,
|
|
678
|
+
true,
|
|
679
|
+
T
|
|
680
|
+
> as TreeNodeSchemaClass<
|
|
681
|
+
ScopedSchemaName<TScope, Name>,
|
|
682
|
+
NodeKind.Object,
|
|
683
|
+
TreeObjectNode<T, ScopedSchemaName<TScope, Name>>,
|
|
684
|
+
object & InsertableObjectFromSchemaRecord<T>,
|
|
685
|
+
true,
|
|
686
|
+
T
|
|
687
|
+
>;
|
|
616
688
|
}
|
|
617
689
|
|
|
618
690
|
/**
|
|
@@ -747,7 +819,17 @@ export class SchemaFactory<
|
|
|
747
819
|
T,
|
|
748
820
|
undefined
|
|
749
821
|
> {
|
|
750
|
-
|
|
822
|
+
// The compiler can't infer that UnannotateImplicitAllowedTypes<T> is equal to T so we have to do a bunch of typing to make the error go away.
|
|
823
|
+
const map: TreeNodeSchemaBoth<
|
|
824
|
+
ScopedSchemaName<TScope, Name>,
|
|
825
|
+
NodeKind.Map,
|
|
826
|
+
TreeMapNode<UnannotateImplicitAllowedTypes<T>> &
|
|
827
|
+
WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,
|
|
828
|
+
MapNodeInsertableData<UnannotateImplicitAllowedTypes<T>>,
|
|
829
|
+
ImplicitlyConstructable,
|
|
830
|
+
T,
|
|
831
|
+
undefined
|
|
832
|
+
> = mapSchema(
|
|
751
833
|
this.scoped(name),
|
|
752
834
|
allowedTypes,
|
|
753
835
|
implicitlyConstructable,
|
|
@@ -755,6 +837,25 @@ export class SchemaFactory<
|
|
|
755
837
|
!customizable,
|
|
756
838
|
undefined,
|
|
757
839
|
);
|
|
840
|
+
|
|
841
|
+
return map as TreeNodeSchemaBoth<
|
|
842
|
+
ScopedSchemaName<TScope, Name>,
|
|
843
|
+
NodeKind.Map,
|
|
844
|
+
TreeMapNode<UnannotateImplicitAllowedTypes<T>> &
|
|
845
|
+
WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,
|
|
846
|
+
MapNodeInsertableData<ImplicitAllowedTypes>,
|
|
847
|
+
ImplicitlyConstructable,
|
|
848
|
+
T,
|
|
849
|
+
undefined
|
|
850
|
+
> as TreeNodeSchemaBoth<
|
|
851
|
+
ScopedSchemaName<TScope, Name>,
|
|
852
|
+
NodeKind.Map,
|
|
853
|
+
TreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,
|
|
854
|
+
MapNodeInsertableData<T>,
|
|
855
|
+
ImplicitlyConstructable,
|
|
856
|
+
T,
|
|
857
|
+
undefined
|
|
858
|
+
>;
|
|
758
859
|
}
|
|
759
860
|
|
|
760
861
|
/**
|
|
@@ -901,7 +1002,22 @@ export class SchemaFactory<
|
|
|
901
1002
|
T,
|
|
902
1003
|
undefined
|
|
903
1004
|
> {
|
|
904
|
-
|
|
1005
|
+
const array = arraySchema(
|
|
1006
|
+
this.scoped(name),
|
|
1007
|
+
allowedTypes,
|
|
1008
|
+
implicitlyConstructable,
|
|
1009
|
+
customizable,
|
|
1010
|
+
);
|
|
1011
|
+
|
|
1012
|
+
return array as TreeNodeSchemaBoth<
|
|
1013
|
+
ScopedSchemaName<TScope, Name>,
|
|
1014
|
+
NodeKind.Array,
|
|
1015
|
+
TreeArrayNode<T> & WithType<ScopedSchemaName<TScope, string>, NodeKind.Array>,
|
|
1016
|
+
Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
|
|
1017
|
+
ImplicitlyConstructable,
|
|
1018
|
+
T,
|
|
1019
|
+
undefined
|
|
1020
|
+
>;
|
|
905
1021
|
}
|
|
906
1022
|
|
|
907
1023
|
/**
|
|
@@ -954,8 +1070,11 @@ export class SchemaFactory<
|
|
|
954
1070
|
* The identifier generated by the SharedTree has the following properties:
|
|
955
1071
|
*
|
|
956
1072
|
* - It is a UUID which will not collide with other generated UUIDs.
|
|
1073
|
+
*
|
|
957
1074
|
* - It is compressed to a space-efficient representation when stored in the document.
|
|
1075
|
+
*
|
|
958
1076
|
* - A compressed form of the identifier can be accessed at runtime via the {@link TreeNodeApi.shortId|Tree.shortId()} API.
|
|
1077
|
+
*
|
|
959
1078
|
* - It will error if read (and will not be present in the object's iterable properties) before the node has been inserted into a tree.
|
|
960
1079
|
*
|
|
961
1080
|
* However, a user may alternatively supply their own string as the identifier if desired (for example, if importing identifiers from another system).
|
|
@@ -1022,6 +1141,7 @@ export class SchemaFactory<
|
|
|
1022
1141
|
* @remarks
|
|
1023
1142
|
* This version of `SchemaFactory.array` uses the same workarounds as {@link SchemaFactory.objectRecursive}.
|
|
1024
1143
|
* See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
|
|
1144
|
+
* See also {@link FixRecursiveArraySchema} for additional information specific to recursive arrays schema exports.
|
|
1025
1145
|
*/
|
|
1026
1146
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
1027
1147
|
public arrayRecursive<
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
} from "./schemaFactory.js";
|
|
13
13
|
import type {
|
|
14
14
|
ImplicitAllowedTypes,
|
|
15
|
+
ImplicitAnnotatedAllowedTypes,
|
|
16
|
+
ImplicitAnnotatedFieldSchema,
|
|
15
17
|
ImplicitFieldSchema,
|
|
16
18
|
NodeSchemaOptions,
|
|
17
19
|
} from "../schemaTypes.js";
|
|
@@ -56,9 +58,9 @@ export class SchemaFactoryAlpha<
|
|
|
56
58
|
* @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.
|
|
57
59
|
* @param options - Additional options for the schema.
|
|
58
60
|
*/
|
|
59
|
-
public
|
|
61
|
+
public objectAlpha<
|
|
60
62
|
const Name extends TName,
|
|
61
|
-
const T extends RestrictiveStringRecord<
|
|
63
|
+
const T extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,
|
|
62
64
|
const TCustomMetadata = unknown,
|
|
63
65
|
>(
|
|
64
66
|
name: Name,
|
|
@@ -121,7 +123,7 @@ export class SchemaFactoryAlpha<
|
|
|
121
123
|
Pick<ObjectNodeSchema, "fields"> {
|
|
122
124
|
// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.
|
|
123
125
|
type TScopedName = ScopedSchemaName<TScope, Name>;
|
|
124
|
-
return this.
|
|
126
|
+
return this.objectAlpha(
|
|
125
127
|
name,
|
|
126
128
|
t as T & RestrictiveStringRecord<ImplicitFieldSchema>,
|
|
127
129
|
options,
|
|
@@ -184,7 +186,7 @@ export class SchemaFactoryAlpha<
|
|
|
184
186
|
*/
|
|
185
187
|
public mapAlpha<
|
|
186
188
|
Name extends TName,
|
|
187
|
-
const T extends
|
|
189
|
+
const T extends ImplicitAnnotatedAllowedTypes,
|
|
188
190
|
const TCustomMetadata = unknown,
|
|
189
191
|
>(
|
|
190
192
|
name: Name,
|
|
@@ -228,7 +230,7 @@ export class SchemaFactoryAlpha<
|
|
|
228
230
|
*/
|
|
229
231
|
public arrayAlpha<
|
|
230
232
|
const Name extends TName,
|
|
231
|
-
const T extends
|
|
233
|
+
const T extends ImplicitAnnotatedAllowedTypes,
|
|
232
234
|
const TCustomMetadata = unknown,
|
|
233
235
|
>(
|
|
234
236
|
name: Name,
|
|
@@ -14,13 +14,7 @@ import {
|
|
|
14
14
|
type ImplicitFieldSchema,
|
|
15
15
|
type InsertableTreeNodeFromImplicitAllowedTypes,
|
|
16
16
|
} from "../schemaTypes.js";
|
|
17
|
-
import type {
|
|
18
|
-
NodeKind,
|
|
19
|
-
TreeNodeSchemaClass,
|
|
20
|
-
TreeNodeSchema,
|
|
21
|
-
WithType,
|
|
22
|
-
TreeNode,
|
|
23
|
-
} from "../core/index.js";
|
|
17
|
+
import type { NodeKind, TreeNodeSchema, WithType, TreeNode } from "../core/index.js";
|
|
24
18
|
import type { FieldSchemaAlphaUnsafe, System_Unsafe } from "./typesUnsafe.js";
|
|
25
19
|
|
|
26
20
|
export function createFieldSchemaUnsafe<
|
|
@@ -33,7 +27,11 @@ export function createFieldSchemaUnsafe<
|
|
|
33
27
|
props?: FieldProps<TCustomMetadata>,
|
|
34
28
|
): FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata> {
|
|
35
29
|
// At runtime, we still want this to be a FieldSchema instance, but we can't satisfy its extends clause, so just return it as an FieldSchemaUnsafe
|
|
36
|
-
return createFieldSchema(
|
|
30
|
+
return createFieldSchema(
|
|
31
|
+
kind,
|
|
32
|
+
allowedTypes as ImplicitAllowedTypes & Types,
|
|
33
|
+
props,
|
|
34
|
+
) as FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata>;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
/**
|
|
@@ -159,37 +157,103 @@ export function createFieldSchemaUnsafe<
|
|
|
159
157
|
*/
|
|
160
158
|
export type ValidateRecursiveSchema<
|
|
161
159
|
// Recursive types should always be using TreeNodeSchemaClass (not TreeNodeSchemaNonClass) as thats part of the requirements for the type to work across compilation boundaries correctly.
|
|
162
|
-
T extends
|
|
163
|
-
// Name: This validator places no restrictions on the name other than that it's a string (as required by TreeNodeSchemaClass).
|
|
164
|
-
string,
|
|
165
|
-
// NodeKind: These are the NodeKinds which currently can be used recursively.
|
|
166
|
-
NodeKind.Array | NodeKind.Map | NodeKind.Object,
|
|
167
|
-
// TNode: The produced node API. This is pretty minimal validation: more could be added if similar to how TInsertable works below if needed.
|
|
168
|
-
TreeNode & WithType<T["identifier"], T["kind"]>,
|
|
169
|
-
// TInsertable: What can be passed to the constructor. This should be enough to catch most issues with incorrect schema.
|
|
170
|
-
// These match whats defined in the recursive methods on `SchemaFactory` except they do not use `Unenforced`.
|
|
171
|
-
{
|
|
172
|
-
[NodeKind.Object]: T["info"] extends RestrictiveStringRecord<ImplicitFieldSchema>
|
|
173
|
-
? InsertableObjectFromSchemaRecord<T["info"]>
|
|
174
|
-
: unknown;
|
|
175
|
-
[NodeKind.Array]: T["info"] extends ImplicitAllowedTypes
|
|
176
|
-
? Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T["info"]>>
|
|
177
|
-
: unknown;
|
|
178
|
-
[NodeKind.Map]: T["info"] extends ImplicitAllowedTypes
|
|
179
|
-
? Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T["info"]>]>
|
|
180
|
-
: unknown;
|
|
181
|
-
}[T["kind"]],
|
|
182
|
-
// ImplicitlyConstructable: recursive types are currently not implicitly constructable.
|
|
183
|
-
false,
|
|
184
|
-
// Info: What's passed to the method to create the schema. Constraining these here should be about as effective as if the actual constraints existed on the actual method itself.
|
|
185
|
-
{
|
|
186
|
-
[NodeKind.Object]: RestrictiveStringRecord<ImplicitFieldSchema>;
|
|
187
|
-
[NodeKind.Array]: ImplicitAllowedTypes;
|
|
188
|
-
[NodeKind.Map]: ImplicitAllowedTypes;
|
|
189
|
-
}[T["kind"]]
|
|
190
|
-
>,
|
|
160
|
+
T extends ValidateRecursiveSchemaTemplate<T>,
|
|
191
161
|
> = true;
|
|
192
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Validation logic used by {@link ValidateRecursiveSchema}.
|
|
165
|
+
* @system @public
|
|
166
|
+
*/
|
|
167
|
+
export type ValidateRecursiveSchemaTemplate<T extends TreeNodeSchema> = TreeNodeSchema<
|
|
168
|
+
// Name: This validator places no restrictions on the name other than that it's a string (as required by TreeNodeSchemaClass).
|
|
169
|
+
string,
|
|
170
|
+
// NodeKind: These are the NodeKinds which currently can be used recursively.
|
|
171
|
+
NodeKind.Array | NodeKind.Map | NodeKind.Object,
|
|
172
|
+
// TNode: The produced node API. This is pretty minimal validation: more could be added if similar to how TInsertable works below if needed.
|
|
173
|
+
TreeNode & WithType<T["identifier"], T["kind"]>,
|
|
174
|
+
// TInsertable: What can be passed to the constructor. This should be enough to catch most issues with incorrect schema.
|
|
175
|
+
// These match whats defined in the recursive methods on `SchemaFactory` except they do not use `Unenforced`.
|
|
176
|
+
{
|
|
177
|
+
[NodeKind.Object]: T["info"] extends RestrictiveStringRecord<ImplicitFieldSchema>
|
|
178
|
+
? InsertableObjectFromSchemaRecord<T["info"]>
|
|
179
|
+
: unknown;
|
|
180
|
+
[NodeKind.Array]: T["info"] extends ImplicitAllowedTypes
|
|
181
|
+
? Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T["info"]>>
|
|
182
|
+
: unknown;
|
|
183
|
+
[NodeKind.Map]: T["info"] extends ImplicitAllowedTypes
|
|
184
|
+
? Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T["info"]>]>
|
|
185
|
+
: unknown;
|
|
186
|
+
[NodeKind.Leaf]: unknown;
|
|
187
|
+
}[T["kind"]],
|
|
188
|
+
// ImplicitlyConstructable: recursive types are currently not implicitly constructable.
|
|
189
|
+
false,
|
|
190
|
+
// Info: What's passed to the method to create the schema. Constraining these here should be about as effective as if the actual constraints existed on the actual method itself.
|
|
191
|
+
{
|
|
192
|
+
[NodeKind.Object]: RestrictiveStringRecord<ImplicitFieldSchema>;
|
|
193
|
+
[NodeKind.Array]: ImplicitAllowedTypes;
|
|
194
|
+
[NodeKind.Map]: ImplicitAllowedTypes;
|
|
195
|
+
[NodeKind.Leaf]: unknown;
|
|
196
|
+
}[T["kind"]]
|
|
197
|
+
>;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Workaround for "Type instantiation is excessively deep and possibly infinite.ts" errors.
|
|
201
|
+
* @remarks
|
|
202
|
+
*
|
|
203
|
+
* Generally this workaround should be avoided if possible,
|
|
204
|
+
* especially for exported types, as it is likely to result in issues when exporting or importing schema where the user will be forced to use the workaround as well.
|
|
205
|
+
* This is particularly problematic since in some cases it may not be possible for the user to replicate the pattern.
|
|
206
|
+
* Additionally, which cases hit these limits may vary based on TypeScript version and implementation details of this library.
|
|
207
|
+
*
|
|
208
|
+
* This workaround is provided and documented as a last resort to be able to keep an app compiling.
|
|
209
|
+
* Future version of SharedTree should provide schema type erasure functionality as a better alternative for most cases.
|
|
210
|
+
*
|
|
211
|
+
* When TypeScript gives the error "Error (TS2589) Type instantiation is excessively deep and possibly infinite." on the invocation of `ValidateRecursiveSchema`
|
|
212
|
+
* for a large schema, it can sometimes be worked around by repeating the usage of the type multiple times.
|
|
213
|
+
* This works because the TypeScript compiler caches some of the intermediate results from the first usage, and thus can get further on the second.
|
|
214
|
+
*
|
|
215
|
+
* This utility can be referenced when applying this pattern.
|
|
216
|
+
* For recursive types this can be used directly:
|
|
217
|
+
*
|
|
218
|
+
* ```typescript
|
|
219
|
+
* {
|
|
220
|
+
* // @ts-expect-error Recursion limit
|
|
221
|
+
* type _check1 = FixRecursiveRecursionLimit<typeof LargeType>;
|
|
222
|
+
* type _check2 = FixRecursiveRecursionLimit<typeof LargeType>;
|
|
223
|
+
* type _check3 = ValidateRecursiveSchemaTemplate<typeof LargeType>;
|
|
224
|
+
* }
|
|
225
|
+
* ```
|
|
226
|
+
*
|
|
227
|
+
* For non-recursive types, they can be ported to the more flexible recursive APIs and use the pattern above.
|
|
228
|
+
*
|
|
229
|
+
* Non-recursive types can also use this workaround by making a duplicate copy of the problematic schema written using the recursive APIs.
|
|
230
|
+
* Then this pattern can be applied to the duplicate copy.
|
|
231
|
+
*
|
|
232
|
+
* ```typescript
|
|
233
|
+
* // Workaround TypeScript recursion limit
|
|
234
|
+
* {
|
|
235
|
+
* class LargeUnionObjectNode_Fix extends schema.objectRecursive("ObjectNode", {
|
|
236
|
+
* x: largeUnion,
|
|
237
|
+
* }) {}
|
|
238
|
+
*
|
|
239
|
+
* // @ts-expect-error Recursion limit
|
|
240
|
+
* allowUnused<FixRecursiveRecursionLimit<typeof LargeUnionObjectNode_Fix>>();
|
|
241
|
+
* allowUnused<FixRecursiveRecursionLimit<typeof LargeUnionObjectNode_Fix>>();
|
|
242
|
+
* allowUnused<ValidateRecursiveSchema<typeof LargeUnionObjectNode_Fix>>();
|
|
243
|
+
* }
|
|
244
|
+
*
|
|
245
|
+
* // Fails to compile without the above workaround.
|
|
246
|
+
* class LargeUnionObjectNode extends schema.object("ObjectNode", { x: largeUnion }) {}
|
|
247
|
+
* ```
|
|
248
|
+
* @privateRemarks
|
|
249
|
+
* Using this is real sketchy, and leads to a lot of issues (errors which depend on how the schema is compiled, making different build setups produce different results and complicating exports).
|
|
250
|
+
* This is being kept as internal for now: if a customer really needs it, we have this as a documented workaround, but it would be much better to find an alternative solution before using this one.
|
|
251
|
+
* This uses ValidateRecursiveSchemaTemplate since it was found to evaluate enough of the type to work.
|
|
252
|
+
* @internal
|
|
253
|
+
*/
|
|
254
|
+
export type FixRecursiveRecursionLimit<T extends TreeNodeSchema> =
|
|
255
|
+
T extends ValidateRecursiveSchemaTemplate<T> ? undefined : undefined;
|
|
256
|
+
|
|
193
257
|
/**
|
|
194
258
|
* Does nothing with the provided value, but appears to use it to make unused locals warnings and errors go away.
|
|
195
259
|
*
|
|
@@ -215,7 +279,7 @@ export function allowUnused<T>(t?: T): void {}
|
|
|
215
279
|
*
|
|
216
280
|
* This type always evaluates to `undefined` to ensure the dummy export (which doesn't exist at runtime) is typed correctly.
|
|
217
281
|
*
|
|
218
|
-
*
|
|
282
|
+
* {@link https://github.com/microsoft/TypeScript/issues/59550|TypeScript Issue 59550} tracks a suggestion which would make this workaround unnecessary.
|
|
219
283
|
*
|
|
220
284
|
* @example Usage
|
|
221
285
|
* Since recursive type handling in TypeScript is order dependent, putting just the right kind of usages of the type before the declarations can cause it to not hit this error.
|
|
@@ -18,7 +18,7 @@ import type {
|
|
|
18
18
|
SimpleTreeSchema,
|
|
19
19
|
} from "../simpleSchema.js";
|
|
20
20
|
import { SchemaFactoryAlpha } from "./schemaFactoryAlpha.js";
|
|
21
|
-
import type { TreeSchema } from "./
|
|
21
|
+
import type { TreeSchema } from "./configuration.js";
|
|
22
22
|
|
|
23
23
|
const factory = new SchemaFactoryAlpha(undefined);
|
|
24
24
|
|
|
@@ -100,7 +100,7 @@ function generateNode(
|
|
|
100
100
|
}
|
|
101
101
|
// Here allowUnknownOptionalFields is implicitly defaulting. This is a subjective policy choice:
|
|
102
102
|
// users of this code are expected to handle what ever choice this code makes for cases like this.
|
|
103
|
-
return factory.
|
|
103
|
+
return factory.objectAlpha(id, fields, { metadata: schema.metadata });
|
|
104
104
|
}
|
|
105
105
|
case NodeKind.Array:
|
|
106
106
|
return factory.arrayAlpha(
|
|
@@ -26,7 +26,7 @@ import type {
|
|
|
26
26
|
SimpleMapNodeSchema,
|
|
27
27
|
} from "../simpleSchema.js";
|
|
28
28
|
import { NodeKind, type TreeNodeSchema } from "../core/index.js";
|
|
29
|
-
import type { TreeSchema } from "./
|
|
29
|
+
import type { TreeSchema } from "./configuration.js";
|
|
30
30
|
import type { TreeSchemaEncodingOptions } from "./getJsonSchema.js";
|
|
31
31
|
import { ObjectNodeSchema } from "../objectNodeTypes.js";
|
|
32
32
|
import { ArrayNodeSchema } from "../arrayNodeTypes.js";
|
|
@@ -3,29 +3,34 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { ICodecOptions } from "../../codec/index.js";
|
|
6
|
+
import type { FluidClientVersion, ICodecOptions } from "../../codec/index.js";
|
|
7
7
|
import type { TreeStoredSchema } from "../../core/index.js";
|
|
8
8
|
import {
|
|
9
9
|
defaultSchemaPolicy,
|
|
10
10
|
encodeTreeSchema,
|
|
11
11
|
makeSchemaCodec,
|
|
12
|
+
SchemaCodecVersion,
|
|
12
13
|
} from "../../feature-libraries/index.js";
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
import {
|
|
15
|
+
clientVersionToSchemaVersion,
|
|
16
|
+
type Format,
|
|
17
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
18
|
+
} from "../../feature-libraries/schema-index/index.js";
|
|
15
19
|
import type { JsonCompatible } from "../../util/index.js";
|
|
16
|
-
import type
|
|
17
|
-
import {
|
|
20
|
+
import { normalizeFieldSchema, type ImplicitFieldSchema } from "../schemaTypes.js";
|
|
21
|
+
import { simpleToStoredSchema } from "../toStoredSchema.js";
|
|
18
22
|
import type { SchemaCompatibilityStatus } from "./tree.js";
|
|
19
|
-
import {
|
|
23
|
+
import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
|
|
24
|
+
import type { SimpleTreeSchema } from "../simpleSchema.js";
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
|
-
* Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable
|
|
27
|
+
* Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.
|
|
28
|
+
*
|
|
29
|
+
* @param schema - The schema to dump.
|
|
23
30
|
*
|
|
24
31
|
* @remarks
|
|
25
32
|
* This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.
|
|
26
|
-
*
|
|
27
|
-
* This format may change across major versions of this package: such changes are considered breaking.
|
|
28
|
-
* Beyond that, no compatibility guarantee is provided for this format: it should never be relied upon to load data, it should only be used for comparing outputs from this function.
|
|
33
|
+
* This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.
|
|
29
34
|
*
|
|
30
35
|
* This only includes the "persisted" subset of schema information, which means the portion which gets included in documents.
|
|
31
36
|
* It thus uses "persisted" keys, see {@link FieldProps.key}.
|
|
@@ -38,7 +43,7 @@ import { ViewSchema } from "./view.js";
|
|
|
38
43
|
* An application could use this API to generate a `schema.json` file when it first releases,
|
|
39
44
|
* then test that the schema is sill compatible with documents from that version with a test like :
|
|
40
45
|
* ```typescript
|
|
41
|
-
* assert.deepEqual(extractPersistedSchema(MySchema), require("./schema.json"));
|
|
46
|
+
* assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require("./schema.json"));
|
|
42
47
|
* ```
|
|
43
48
|
*
|
|
44
49
|
* @privateRemarks
|
|
@@ -48,9 +53,13 @@ import { ViewSchema } from "./view.js";
|
|
|
48
53
|
* Public API surface uses "persisted" terminology while internally we use "stored".
|
|
49
54
|
* @alpha
|
|
50
55
|
*/
|
|
51
|
-
export function extractPersistedSchema(
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
export function extractPersistedSchema(
|
|
57
|
+
schema: SimpleTreeSchema,
|
|
58
|
+
oldestCompatibleClient: FluidClientVersion,
|
|
59
|
+
): JsonCompatible {
|
|
60
|
+
const stored = simpleToStoredSchema(schema);
|
|
61
|
+
const writeVersion = clientVersionToSchemaVersion(oldestCompatibleClient);
|
|
62
|
+
return encodeTreeSchema(stored, writeVersion);
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
/**
|
|
@@ -89,9 +98,15 @@ export function comparePersistedSchema(
|
|
|
89
98
|
options: ICodecOptions,
|
|
90
99
|
canInitialize: boolean,
|
|
91
100
|
): SchemaCompatibilityStatus {
|
|
92
|
-
|
|
101
|
+
// Any version can be passed down to makeSchemaCodec here.
|
|
102
|
+
// We only use the decode part, which always dispatches to the correct codec based on the version in the data, not the version passed to `makeSchemaCodec`.
|
|
103
|
+
const schemaCodec = makeSchemaCodec(options, SchemaCodecVersion.v1);
|
|
93
104
|
const stored = schemaCodec.decode(persisted as Format);
|
|
94
|
-
const viewSchema = new
|
|
105
|
+
const viewSchema = new SchemaCompatibilityTester(
|
|
106
|
+
defaultSchemaPolicy,
|
|
107
|
+
{},
|
|
108
|
+
normalizeFieldSchema(view),
|
|
109
|
+
);
|
|
95
110
|
return comparePersistedSchemaInternal(stored, viewSchema, canInitialize);
|
|
96
111
|
}
|
|
97
112
|
|
|
@@ -101,7 +116,7 @@ export function comparePersistedSchema(
|
|
|
101
116
|
*/
|
|
102
117
|
export function comparePersistedSchemaInternal(
|
|
103
118
|
stored: TreeStoredSchema,
|
|
104
|
-
viewSchema:
|
|
119
|
+
viewSchema: SchemaCompatibilityTester,
|
|
105
120
|
canInitialize: boolean,
|
|
106
121
|
): SchemaCompatibilityStatus {
|
|
107
122
|
return {
|