@fluidframework/tree 2.40.0-336023 → 2.41.0-337492
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -0
- package/api-report/tree.alpha.api.md +4 -1
- package/dist/alpha.d.ts +1 -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/default-schema/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js +0 -7
- package/dist/feature-libraries/default-schema/schemaChecker.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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/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 +1 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +2 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +9 -10
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +10 -34
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +4 -6
- 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/tree.d.ts +24 -0
- package/dist/shared-tree/tree.d.ts.map +1 -1
- package/dist/shared-tree/tree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +2 -0
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +3 -2
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- 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/index.d.ts +2 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +2 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +9 -0
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +7 -0
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +8 -7
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +13 -9
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +25 -0
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeBeta.d.ts +4 -1
- package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/api/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/arrayNode.d.ts +28 -0
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.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/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +5 -1
- package/dist/simple-tree/core/unhydratedFlexTree.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 +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +3 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +1 -0
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- 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/tableSchema.d.ts +309 -91
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +319 -78
- 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/lib/alpha.d.ts +1 -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/default-schema/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js +0 -7
- package/lib/feature-libraries/default-schema/schemaChecker.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 +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/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 +1 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +9 -10
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +11 -35
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +5 -7
- 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/tree.d.ts +24 -0
- package/lib/shared-tree/tree.d.ts.map +1 -1
- package/lib/shared-tree/tree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +2 -0
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +4 -3
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- 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/index.d.ts +2 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +9 -0
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +7 -0
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +8 -7
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +17 -11
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +25 -0
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeBeta.d.ts +4 -1
- package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/api/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/arrayNode.d.ts +28 -0
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.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/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +5 -1
- package/lib/simple-tree/core/unhydratedFlexTree.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 +2 -2
- 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/schemaTypes.d.ts +1 -0
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- 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/tableSchema.d.ts +309 -91
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +319 -78
- 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/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/default-schema/schemaChecker.ts +0 -8
- 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 +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +3 -2
- package/src/shared-tree/index.ts +2 -0
- package/src/shared-tree/schematizeTree.ts +6 -36
- package/src/shared-tree/schematizingTreeView.ts +5 -12
- package/src/shared-tree/sharedTree.ts +67 -6
- package/src/shared-tree/tree.ts +24 -0
- package/src/shared-tree/treeAlpha.ts +6 -3
- package/src/shared-tree-core/branchCommitEnricher.ts +0 -1
- package/src/shared-tree-core/transactionEnricher.ts +4 -1
- package/src/simple-tree/api/index.ts +2 -0
- package/src/simple-tree/api/schemaFactory.ts +9 -0
- package/src/simple-tree/api/storedSchema.ts +24 -13
- package/src/simple-tree/api/tree.ts +25 -0
- package/src/simple-tree/api/treeBeta.ts +3 -1
- package/src/simple-tree/api/treeChangeEvents.ts +84 -0
- package/src/simple-tree/api/treeNodeApi.ts +1 -1
- package/src/simple-tree/arrayNode.ts +28 -0
- 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/unhydratedFlexTree.ts +6 -1
- package/src/simple-tree/core/withType.ts +1 -1
- package/src/simple-tree/index.ts +2 -1
- package/src/simple-tree/schemaTypes.ts +1 -0
- package/src/simple-tree/toStoredSchema.ts +42 -41
- package/src/tableSchema.ts +713 -259
- package/src/treeFactory.ts +56 -173
- 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/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/src/core/schema-stored/{format.ts → formatV1.ts} +0 -0
package/src/tableSchema.ts
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { oob } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
8
|
|
|
8
9
|
import { Tree } from "./shared-tree/index.js";
|
|
9
10
|
import {
|
|
10
11
|
type FieldHasDefault,
|
|
11
12
|
type ImplicitAllowedTypes,
|
|
12
|
-
type ImplicitFieldSchema,
|
|
13
13
|
type InsertableObjectFromSchemaRecord,
|
|
14
14
|
type InsertableTreeNodeFromImplicitAllowedTypes,
|
|
15
15
|
type NodeKind,
|
|
@@ -24,17 +24,22 @@ import {
|
|
|
24
24
|
type TreeFieldFromImplicitField,
|
|
25
25
|
type InsertableTreeFieldFromImplicitField,
|
|
26
26
|
type InternalTreeNode,
|
|
27
|
-
type FieldSchema,
|
|
28
|
-
type FieldKind,
|
|
29
27
|
SchemaFactory,
|
|
30
28
|
type ImplicitAnnotatedFieldSchema,
|
|
31
29
|
type UnannotateImplicitFieldSchema,
|
|
32
30
|
} from "./simple-tree/index.js";
|
|
33
31
|
|
|
34
|
-
// Future improvement TODOs
|
|
32
|
+
// Future improvement TODOs:
|
|
33
|
+
// - Omit `cells` property from Row insertion type.
|
|
35
34
|
// - Record-like type parameters / input parameters?
|
|
36
35
|
// - Omit `props` properties from Row and Column schemas when not provided?
|
|
37
36
|
|
|
37
|
+
// Longer-term work:
|
|
38
|
+
// - Add constraint APIs to make it possible to avoid situations that could yield "orphaned" cells.
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The sub-scope applied to user-provided {@link SchemaFactory}s by table schema factories.
|
|
42
|
+
*/
|
|
38
43
|
const tableSchemaFactorySubScope = "table";
|
|
39
44
|
|
|
40
45
|
/**
|
|
@@ -48,20 +53,28 @@ const tableSchemaFactorySubScope = "table";
|
|
|
48
53
|
* @system @internal
|
|
49
54
|
*/
|
|
50
55
|
export namespace System_TableSchema {
|
|
56
|
+
/**
|
|
57
|
+
* Default type used for column and row "props" fields.
|
|
58
|
+
* @privateRemarks
|
|
59
|
+
* Longer term, it would be better to simply omit "props" altogether by default.
|
|
60
|
+
* For now, this ensures that the user doesn't have to specify a "props" entry when initializing column/row nodes
|
|
61
|
+
* and ensures that they cannot set anything that might conflict with future evolutions of the schema.
|
|
62
|
+
* @system @internal
|
|
63
|
+
*/
|
|
64
|
+
export type DefaultPropsType = ReturnType<typeof SchemaFactory.optional<[]>>;
|
|
65
|
+
|
|
51
66
|
/**
|
|
52
67
|
* A base interface for factory input options which include an schema factory.
|
|
53
68
|
* @remarks This interface should not be referenced directly.
|
|
54
69
|
* @privateRemarks This interface primarily exists to provide a single home for property documentation.
|
|
55
70
|
* @system @internal
|
|
56
71
|
*/
|
|
57
|
-
export interface OptionsWithSchemaFactory<
|
|
58
|
-
TScope extends string | undefined = string | undefined,
|
|
59
|
-
> {
|
|
72
|
+
export interface OptionsWithSchemaFactory<TSchemaFactory extends SchemaFactoryAlpha> {
|
|
60
73
|
/**
|
|
61
74
|
* Schema factory with which the Column schema will be associated.
|
|
62
75
|
* @remarks Can be used to associate the resulting schema with an existing {@link SchemaFactory.scope|scope}.
|
|
63
76
|
*/
|
|
64
|
-
readonly schemaFactory:
|
|
77
|
+
readonly schemaFactory: TSchemaFactory;
|
|
65
78
|
}
|
|
66
79
|
|
|
67
80
|
/**
|
|
@@ -70,9 +83,7 @@ export namespace System_TableSchema {
|
|
|
70
83
|
* @privateRemarks This interface primarily exists to provide a single home for property documentation.
|
|
71
84
|
* @system @internal
|
|
72
85
|
*/
|
|
73
|
-
export interface OptionsWithCellSchema<
|
|
74
|
-
TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
75
|
-
> {
|
|
86
|
+
export interface OptionsWithCellSchema<TCellSchema extends ImplicitAllowedTypes> {
|
|
76
87
|
/**
|
|
77
88
|
* Schema for the table's cells.
|
|
78
89
|
*/
|
|
@@ -87,15 +98,15 @@ export namespace System_TableSchema {
|
|
|
87
98
|
* @system @internal
|
|
88
99
|
*/
|
|
89
100
|
export type CreateColumnOptionsBase<
|
|
90
|
-
|
|
91
|
-
> = OptionsWithSchemaFactory<
|
|
101
|
+
TSchemaFactory extends SchemaFactoryAlpha = SchemaFactoryAlpha,
|
|
102
|
+
> = OptionsWithSchemaFactory<TSchemaFactory>;
|
|
92
103
|
|
|
93
104
|
/**
|
|
94
|
-
* Factory for creating
|
|
105
|
+
* Factory for creating column schema.
|
|
95
106
|
* @system @internal
|
|
96
107
|
*/
|
|
97
108
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
98
|
-
export function
|
|
109
|
+
export function createColumnSchema<
|
|
99
110
|
const TInputScope extends string | undefined,
|
|
100
111
|
const TPropsSchema extends ImplicitAnnotatedFieldSchema,
|
|
101
112
|
>(inputSchemaFactory: SchemaFactoryAlpha<TInputScope>, propsSchema: TPropsSchema) {
|
|
@@ -136,10 +147,10 @@ export namespace System_TableSchema {
|
|
|
136
147
|
// Will make it easier to evolve this schema in the future.
|
|
137
148
|
allowUnknownOptionalFields: true,
|
|
138
149
|
})
|
|
139
|
-
implements TableSchema.
|
|
150
|
+
implements TableSchema.Column<TPropsSchema> {}
|
|
140
151
|
|
|
141
152
|
type ColumnValueType = TreeNode &
|
|
142
|
-
TableSchema.
|
|
153
|
+
TableSchema.Column<TPropsSchema> &
|
|
143
154
|
WithType<ScopedSchemaName<Scope, "Column">>;
|
|
144
155
|
|
|
145
156
|
// Note: ideally this type would just leverage `InsertableObjectFromSchemaRecord<typeof columnFields>`,
|
|
@@ -151,7 +162,7 @@ export namespace System_TableSchema {
|
|
|
151
162
|
typeof columnFieldsBuiltInParts
|
|
152
163
|
> &
|
|
153
164
|
(FieldHasDefault<UnannotateImplicitFieldSchema<TPropsSchema>> extends true
|
|
154
|
-
? // Note: The docs on the below properties are copied from `
|
|
165
|
+
? // Note: The docs on the below properties are copied from `IColumn.props`' docs to ensure that the
|
|
155
166
|
// documentation appears in the data insertion scenario.
|
|
156
167
|
// The contents are duplicated instead of using `@inheritdoc`, as intellisense does not correctly
|
|
157
168
|
// support `@inheritDoc`.
|
|
@@ -215,8 +226,8 @@ export namespace System_TableSchema {
|
|
|
215
226
|
*/
|
|
216
227
|
export type ColumnSchemaBase<
|
|
217
228
|
TScope extends string | undefined = string | undefined,
|
|
218
|
-
TPropsSchema extends
|
|
219
|
-
> = ReturnType<typeof
|
|
229
|
+
TPropsSchema extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
|
|
230
|
+
> = ReturnType<typeof createColumnSchema<TScope, TPropsSchema>>;
|
|
220
231
|
|
|
221
232
|
// #endregion
|
|
222
233
|
|
|
@@ -228,20 +239,19 @@ export namespace System_TableSchema {
|
|
|
228
239
|
* @system @internal
|
|
229
240
|
*/
|
|
230
241
|
export type CreateRowOptionsBase<
|
|
231
|
-
|
|
242
|
+
TSchemaFactory extends SchemaFactoryAlpha = SchemaFactoryAlpha,
|
|
232
243
|
TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
233
|
-
> = OptionsWithSchemaFactory<
|
|
244
|
+
> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
|
|
234
245
|
|
|
235
246
|
/**
|
|
236
|
-
* Factory for creating
|
|
237
|
-
*
|
|
247
|
+
* Factory for creating row schema.
|
|
238
248
|
* @sealed @internal
|
|
239
249
|
*/
|
|
240
250
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
241
|
-
export function
|
|
251
|
+
export function createRowSchema<
|
|
242
252
|
const TInputScope extends string | undefined,
|
|
243
253
|
const TCellSchema extends ImplicitAllowedTypes,
|
|
244
|
-
const TPropsSchema extends
|
|
254
|
+
const TPropsSchema extends ImplicitAnnotatedFieldSchema,
|
|
245
255
|
>(
|
|
246
256
|
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
247
257
|
cellSchema: TCellSchema,
|
|
@@ -289,32 +299,40 @@ export namespace System_TableSchema {
|
|
|
289
299
|
// Will make it easier to evolve this schema in the future.
|
|
290
300
|
allowUnknownOptionalFields: true,
|
|
291
301
|
})
|
|
292
|
-
implements TableSchema.
|
|
302
|
+
implements TableSchema.Row<TCellSchema, TPropsSchema>
|
|
293
303
|
{
|
|
294
|
-
public getCell(columnOrId: TableSchema.
|
|
304
|
+
public getCell(columnOrId: TableSchema.Column | string): CellValueType | undefined {
|
|
295
305
|
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
296
306
|
return this.cells.get(columnId) as CellValueType | undefined;
|
|
297
307
|
}
|
|
298
308
|
|
|
299
309
|
public setCell(
|
|
300
|
-
columnOrId: TableSchema.
|
|
310
|
+
columnOrId: TableSchema.Column | string,
|
|
301
311
|
value: CellInsertableType | undefined,
|
|
302
312
|
): void {
|
|
313
|
+
// TODO: throw if column does not exist in the owning table.
|
|
314
|
+
|
|
303
315
|
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
304
316
|
this.cells.set(columnId, value);
|
|
305
317
|
}
|
|
306
318
|
|
|
307
|
-
public removeCell(columnOrId: TableSchema.
|
|
319
|
+
public removeCell(columnOrId: TableSchema.Column | string): CellValueType | undefined {
|
|
320
|
+
// TODO: throw if column does not exist in the owning table.
|
|
321
|
+
|
|
308
322
|
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
309
|
-
|
|
310
|
-
|
|
323
|
+
|
|
324
|
+
const cell: CellValueType | undefined = this.cells.get(columnId);
|
|
325
|
+
if (cell === undefined) {
|
|
326
|
+
return undefined;
|
|
311
327
|
}
|
|
328
|
+
|
|
312
329
|
this.cells.delete(columnId);
|
|
330
|
+
return cell;
|
|
313
331
|
}
|
|
314
332
|
}
|
|
315
333
|
|
|
316
334
|
type RowValueType = TreeNode &
|
|
317
|
-
TableSchema.
|
|
335
|
+
TableSchema.Row<TCellSchema, TPropsSchema> &
|
|
318
336
|
WithType<ScopedSchemaName<Scope, "Row">>;
|
|
319
337
|
|
|
320
338
|
// Note: ideally this type would just leverage `InsertableObjectFromSchemaRecord<typeof rowFields>`,
|
|
@@ -324,7 +342,7 @@ export namespace System_TableSchema {
|
|
|
324
342
|
// the issue.
|
|
325
343
|
// type RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFields>;
|
|
326
344
|
type RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFieldsBuiltInParts> &
|
|
327
|
-
(FieldHasDefault<TPropsSchema
|
|
345
|
+
(FieldHasDefault<UnannotateImplicitFieldSchema<TPropsSchema>> extends true
|
|
328
346
|
? // Note: The docs on the below properties are copied from `IRow.props`' docs to ensure that the
|
|
329
347
|
// documentation appears in the data insertion scenario.
|
|
330
348
|
// The contents are duplicated instead of using `@inheritdoc`, as intellisense does not correctly
|
|
@@ -336,7 +354,9 @@ export namespace System_TableSchema {
|
|
|
336
354
|
* @remarks This is a user-defined schema that can be used to store additional information
|
|
337
355
|
* about the row.
|
|
338
356
|
*/
|
|
339
|
-
props?: InsertableTreeFieldFromImplicitField<
|
|
357
|
+
props?: InsertableTreeFieldFromImplicitField<
|
|
358
|
+
UnannotateImplicitFieldSchema<TPropsSchema>
|
|
359
|
+
>;
|
|
340
360
|
}
|
|
341
361
|
: {
|
|
342
362
|
/**
|
|
@@ -344,10 +364,12 @@ export namespace System_TableSchema {
|
|
|
344
364
|
* @remarks This is a user-defined schema that can be used to store additional information
|
|
345
365
|
* about the row.
|
|
346
366
|
*/
|
|
347
|
-
props: InsertableTreeFieldFromImplicitField<
|
|
367
|
+
props: InsertableTreeFieldFromImplicitField<
|
|
368
|
+
UnannotateImplicitFieldSchema<TPropsSchema>
|
|
369
|
+
>;
|
|
348
370
|
});
|
|
349
371
|
|
|
350
|
-
// Modified version of `
|
|
372
|
+
// Modified version of `Row` that ensures the constructor (and `createFromInsertable`) are
|
|
351
373
|
// typed correctly in terms of our insertable type.
|
|
352
374
|
// This lets us be selective in our type-cast for the value returned from this function,
|
|
353
375
|
// preserving as much type-safety as we reasonably can.
|
|
@@ -388,8 +410,8 @@ export namespace System_TableSchema {
|
|
|
388
410
|
export type RowSchemaBase<
|
|
389
411
|
TScope extends string | undefined = string | undefined,
|
|
390
412
|
TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
391
|
-
TPropsSchema extends
|
|
392
|
-
> = ReturnType<typeof
|
|
413
|
+
TPropsSchema extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
|
|
414
|
+
> = ReturnType<typeof createRowSchema<TScope, TCellSchema, TPropsSchema>>;
|
|
393
415
|
|
|
394
416
|
// #endregion
|
|
395
417
|
|
|
@@ -401,23 +423,20 @@ export namespace System_TableSchema {
|
|
|
401
423
|
* @system @internal
|
|
402
424
|
*/
|
|
403
425
|
export type TableFactoryOptionsBase<
|
|
404
|
-
|
|
426
|
+
TSchemaFactory extends SchemaFactoryAlpha = SchemaFactoryAlpha,
|
|
405
427
|
TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
406
|
-
> = OptionsWithSchemaFactory<
|
|
428
|
+
> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
|
|
407
429
|
|
|
408
430
|
/**
|
|
409
|
-
* Factory for creating
|
|
431
|
+
* Factory for creating table schema.
|
|
410
432
|
* @system @internal
|
|
411
433
|
*/
|
|
412
434
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
413
|
-
export function
|
|
435
|
+
export function createTableSchema<
|
|
414
436
|
const TInputScope extends string | undefined,
|
|
415
437
|
const TCellSchema extends ImplicitAllowedTypes,
|
|
416
|
-
const TColumnSchema extends ColumnSchemaBase<TInputScope
|
|
417
|
-
const TRowSchema extends RowSchemaBase<TInputScope, TCellSchema
|
|
418
|
-
TInputScope,
|
|
419
|
-
TCellSchema
|
|
420
|
-
>,
|
|
438
|
+
const TColumnSchema extends ColumnSchemaBase<TInputScope>,
|
|
439
|
+
const TRowSchema extends RowSchemaBase<TInputScope, TCellSchema>,
|
|
421
440
|
>(
|
|
422
441
|
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
423
442
|
_cellSchema: TCellSchema,
|
|
@@ -428,13 +447,8 @@ export namespace System_TableSchema {
|
|
|
428
447
|
type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
|
|
429
448
|
|
|
430
449
|
type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
431
|
-
type CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
432
|
-
|
|
433
450
|
type ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumnSchema>;
|
|
434
|
-
type ColumnInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TColumnSchema>;
|
|
435
|
-
|
|
436
451
|
type RowValueType = TreeNodeFromImplicitAllowedTypes<TRowSchema>;
|
|
437
|
-
type RowInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TRowSchema>;
|
|
438
452
|
|
|
439
453
|
/**
|
|
440
454
|
* {@link Table} fields.
|
|
@@ -444,7 +458,7 @@ export namespace System_TableSchema {
|
|
|
444
458
|
const tableFields = {
|
|
445
459
|
rows: schemaFactory.array("Table.rows", rowSchema),
|
|
446
460
|
columns: schemaFactory.array("Table.columns", columnSchema),
|
|
447
|
-
} as const satisfies Record<string,
|
|
461
|
+
} as const satisfies Record<string, ImplicitAnnotatedFieldSchema>;
|
|
448
462
|
|
|
449
463
|
/**
|
|
450
464
|
* The Table schema
|
|
@@ -454,7 +468,7 @@ export namespace System_TableSchema {
|
|
|
454
468
|
// Will make it easier to evolve this schema in the future.
|
|
455
469
|
allowUnknownOptionalFields: true,
|
|
456
470
|
})
|
|
457
|
-
implements TableSchema.
|
|
471
|
+
implements TableSchema.Table<TCellSchema, TColumnSchema, TRowSchema>
|
|
458
472
|
{
|
|
459
473
|
public getColumn(id: string): ColumnValueType | undefined {
|
|
460
474
|
// TypeScript is unable to narrow the types correctly here, hence the casts.
|
|
@@ -472,51 +486,130 @@ export namespace System_TableSchema {
|
|
|
472
486
|
| undefined;
|
|
473
487
|
}
|
|
474
488
|
|
|
475
|
-
public getCell(
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
489
|
+
public getCell(
|
|
490
|
+
key: TableSchema.CellKey<TColumnSchema, TRowSchema>,
|
|
491
|
+
): CellValueType | undefined {
|
|
492
|
+
const { column: columnOrId, row: rowOrId } = key;
|
|
493
|
+
const row = this._getRow(rowOrId);
|
|
494
|
+
if (row === undefined) {
|
|
495
|
+
return undefined;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
const column = this._getColumn(columnOrId);
|
|
499
|
+
if (column === undefined) {
|
|
500
|
+
return undefined;
|
|
483
501
|
}
|
|
484
|
-
|
|
485
|
-
return
|
|
502
|
+
|
|
503
|
+
return row.getCell(column);
|
|
486
504
|
}
|
|
487
505
|
|
|
488
506
|
public insertColumn({
|
|
489
507
|
column,
|
|
490
508
|
index,
|
|
491
|
-
}: TableSchema.InsertColumnParameters<
|
|
492
|
-
|
|
493
|
-
|
|
509
|
+
}: TableSchema.InsertColumnParameters<TColumnSchema>): ColumnValueType {
|
|
510
|
+
const inserted = this.insertColumns({
|
|
511
|
+
columns: [column],
|
|
512
|
+
index,
|
|
513
|
+
});
|
|
514
|
+
return inserted[0] ?? oob();
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
public insertColumns({
|
|
518
|
+
columns,
|
|
519
|
+
index,
|
|
520
|
+
}: TableSchema.InsertColumnsParameters<TColumnSchema>): ColumnValueType[] {
|
|
521
|
+
// #region Input validation
|
|
522
|
+
|
|
523
|
+
// Ensure index is valid
|
|
524
|
+
if (index !== undefined) {
|
|
525
|
+
Table.validateInsertionIndex(index, this.columns);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// Check all of the columns being inserted an ensure the table does not already contain any with the same ID.
|
|
529
|
+
for (const column of columns) {
|
|
530
|
+
// TypeScript is unable to narrow the type of the column type correctly here, hence the casts below.
|
|
494
531
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
532
|
+
const maybeId = (column as ColumnValueType).id;
|
|
533
|
+
if (maybeId !== undefined && this.containsColumnWithId(maybeId)) {
|
|
534
|
+
throw new UsageError(
|
|
535
|
+
`A column with ID "${(column as ColumnValueType).id}" already exists in the table.`,
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// #endregion
|
|
541
|
+
|
|
542
|
+
// TypeScript is unable to narrow the column type correctly here, hence the casts below.
|
|
543
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
544
|
+
if (index === undefined) {
|
|
495
545
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
496
|
-
this.columns.insertAtEnd(
|
|
546
|
+
this.columns.insertAtEnd(TreeArrayNode.spread(columns) as any);
|
|
497
547
|
} else {
|
|
498
|
-
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
499
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
500
548
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
501
|
-
this.columns.insertAt(index,
|
|
549
|
+
this.columns.insertAt(index, TreeArrayNode.spread(columns) as any);
|
|
502
550
|
}
|
|
503
551
|
|
|
504
|
-
// Inserting the input
|
|
505
|
-
return
|
|
552
|
+
// Inserting the input nodes into the tree hydrates them, making them usable as nodes.
|
|
553
|
+
return columns as unknown as ColumnValueType[];
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
public insertRow({
|
|
557
|
+
row,
|
|
558
|
+
index,
|
|
559
|
+
}: TableSchema.InsertRowParameters<TRowSchema>): RowValueType {
|
|
560
|
+
const inserted = this.insertRows({
|
|
561
|
+
rows: [row],
|
|
562
|
+
index,
|
|
563
|
+
});
|
|
564
|
+
return inserted[0] ?? oob();
|
|
506
565
|
}
|
|
507
566
|
|
|
508
567
|
public insertRows({
|
|
509
568
|
index,
|
|
510
569
|
rows,
|
|
511
|
-
}: TableSchema.InsertRowsParameters<
|
|
570
|
+
}: TableSchema.InsertRowsParameters<TRowSchema>): RowValueType[] {
|
|
571
|
+
// #region Input validation
|
|
572
|
+
|
|
573
|
+
// Ensure index is valid
|
|
574
|
+
if (index !== undefined) {
|
|
575
|
+
Table.validateInsertionIndex(index, this.rows);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// Note: TypeScript is unable to narrow the type of the row type correctly here, hence the casts below.
|
|
579
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
580
|
+
for (const newRow of rows) {
|
|
581
|
+
// Check all of the rows being inserted an ensure the table does not already contain any with the same ID.
|
|
582
|
+
const maybeId = (newRow as RowValueType).id;
|
|
583
|
+
if (maybeId !== undefined && this.containsRowWithId(maybeId)) {
|
|
584
|
+
throw new UsageError(
|
|
585
|
+
`A row with ID "${(newRow as RowValueType).id}" already exists in the table.`,
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// If the row contains cells, verify that the table contains the columns for those cells.
|
|
590
|
+
// Note: we intentionally hide `cells` on `IRow` to avoid leaking the internal data representation as much as possible, so we have to cast here.
|
|
591
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
592
|
+
if ((newRow as any).cells !== undefined) {
|
|
593
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
594
|
+
const keys: string[] = Object.keys((newRow as any).cells);
|
|
595
|
+
for (const key of keys) {
|
|
596
|
+
if (!this.containsColumnWithId(key)) {
|
|
597
|
+
throw new UsageError(
|
|
598
|
+
`Attempted to insert row a cell under column ID "${key}", but the table does not contain a column with that ID.`,
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// #endregion
|
|
606
|
+
|
|
607
|
+
// TypeScript is unable to narrow the row type correctly here, hence the casts below.
|
|
608
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
512
609
|
if (index === undefined) {
|
|
513
|
-
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
514
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
515
610
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
516
611
|
this.rows.insertAtEnd(TreeArrayNode.spread(rows) as any);
|
|
517
612
|
} else {
|
|
518
|
-
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
519
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
520
613
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
521
614
|
this.rows.insertAt(index, TreeArrayNode.spread(rows) as any);
|
|
522
615
|
}
|
|
@@ -525,65 +618,204 @@ export namespace System_TableSchema {
|
|
|
525
618
|
return rows as unknown as RowValueType[];
|
|
526
619
|
}
|
|
527
620
|
|
|
528
|
-
public setCell({
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
621
|
+
public setCell({
|
|
622
|
+
key,
|
|
623
|
+
cell,
|
|
624
|
+
}: TableSchema.SetCellParameters<TCellSchema, TColumnSchema, TRowSchema>): void {
|
|
625
|
+
const { column: columnOrId, row: rowOrId } = key;
|
|
626
|
+
|
|
627
|
+
const row = this._getRow(rowOrId);
|
|
628
|
+
if (row === undefined) {
|
|
629
|
+
const rowId = this._getRowId(rowOrId);
|
|
630
|
+
throw new UsageError(`No row with ID "${rowId}" exists in the table.`);
|
|
536
631
|
}
|
|
632
|
+
|
|
633
|
+
const column = this._getColumn(columnOrId);
|
|
634
|
+
if (column === undefined) {
|
|
635
|
+
const columnId = this._getColumnId(columnOrId);
|
|
636
|
+
throw new UsageError(`No column with ID "${columnId}" exists in the table.`);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
row.setCell(column, cell);
|
|
537
640
|
}
|
|
538
641
|
|
|
539
|
-
public
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
642
|
+
public removeColumns(
|
|
643
|
+
columns: readonly string[] | readonly ColumnValueType[],
|
|
644
|
+
): ColumnValueType[] {
|
|
645
|
+
// If there are no columns to remove, do nothing
|
|
646
|
+
if (columns.length === 0) {
|
|
647
|
+
return [];
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// If there is only one column to remove, remove it (and don't incur cost of transaction)
|
|
651
|
+
if (columns.length === 1) {
|
|
652
|
+
const removedColumn = this.removeColumn(columns[0] ?? oob());
|
|
653
|
+
return [removedColumn];
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// If there are multiple columns to remove, remove them in a transaction.
|
|
657
|
+
const removedColumns: ColumnValueType[] = [];
|
|
658
|
+
Tree.runTransaction(this, () => {
|
|
659
|
+
// Note, throwing an error within a transaction will abort the entire transaction.
|
|
660
|
+
// So if we throw an error here for any row, no columns will be removed.
|
|
661
|
+
for (const columnToRemove of columns) {
|
|
662
|
+
const removedRow = this.removeColumn(columnToRemove);
|
|
663
|
+
removedColumns.push(removedRow);
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
return removedColumns;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
public removeColumn(columnOrId: string | ColumnValueType): ColumnValueType {
|
|
670
|
+
const column = this._getColumn(columnOrId);
|
|
671
|
+
const index = column === undefined ? -1 : this.columns.indexOf(column);
|
|
672
|
+
if (index === -1) {
|
|
673
|
+
const columnId = this._getColumnId(columnOrId);
|
|
674
|
+
throw new UsageError(
|
|
675
|
+
`Specified column with ID "${columnId}" does not exist in the table.`,
|
|
676
|
+
);
|
|
677
|
+
}
|
|
543
678
|
this.columns.removeAt(index);
|
|
679
|
+
return column as ColumnValueType;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
public removeAllColumns(): ColumnValueType[] {
|
|
683
|
+
// TypeScript is unable to narrow the row type correctly here, hence the cast.
|
|
684
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
685
|
+
return this.removeColumns(this.columns as unknown as ColumnValueType[]);
|
|
544
686
|
}
|
|
545
687
|
|
|
546
|
-
public removeRows(rows: readonly RowValueType[]):
|
|
688
|
+
public removeRows(rows: readonly string[] | readonly RowValueType[]): RowValueType[] {
|
|
547
689
|
// If there are no rows to remove, do nothing
|
|
548
690
|
if (rows.length === 0) {
|
|
549
|
-
return;
|
|
691
|
+
return [];
|
|
550
692
|
}
|
|
551
693
|
|
|
552
|
-
// If there is only one row to remove, remove it
|
|
694
|
+
// If there is only one row to remove, remove it (and don't incur cost of transaction)
|
|
553
695
|
if (rows.length === 1) {
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
return;
|
|
696
|
+
const removedRow = this.removeRow(rows[0] ?? oob());
|
|
697
|
+
return [removedRow];
|
|
557
698
|
}
|
|
558
|
-
|
|
559
|
-
//
|
|
699
|
+
|
|
700
|
+
// If there are multiple rows to remove, remove them in a transaction.
|
|
701
|
+
const removedRows: RowValueType[] = [];
|
|
560
702
|
Tree.runTransaction(this, () => {
|
|
561
|
-
//
|
|
562
|
-
for
|
|
563
|
-
|
|
564
|
-
this.
|
|
703
|
+
// Note, throwing an error within a transaction will abort the entire transaction.
|
|
704
|
+
// So if we throw an error here for any row, no rows will be removed.
|
|
705
|
+
for (const rowToRemove of rows) {
|
|
706
|
+
const removedRow = this.removeRow(rowToRemove);
|
|
707
|
+
removedRows.push(removedRow);
|
|
565
708
|
}
|
|
566
709
|
});
|
|
710
|
+
return removedRows;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
public removeRow(rowOrId: string | RowValueType): RowValueType {
|
|
714
|
+
const rowToRemove = this._getRow(rowOrId);
|
|
715
|
+
const index = rowToRemove === undefined ? -1 : this.rows.indexOf(rowToRemove);
|
|
716
|
+
|
|
717
|
+
// If the row does not exist in the table, throw an error.
|
|
718
|
+
if (index === -1) {
|
|
719
|
+
const rowId = this._getRowId(rowOrId);
|
|
720
|
+
throw new UsageError(
|
|
721
|
+
`Specified row with ID "${rowId}" does not exist in the table.`,
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
this.rows.removeAt(index);
|
|
726
|
+
return rowToRemove as RowValueType;
|
|
567
727
|
}
|
|
568
728
|
|
|
569
|
-
public removeAllRows():
|
|
570
|
-
|
|
729
|
+
public removeAllRows(): RowValueType[] {
|
|
730
|
+
// TypeScript is unable to narrow the row type correctly here, hence the cast.
|
|
731
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
732
|
+
return this.removeRows(this.rows as unknown as RowValueType[]);
|
|
571
733
|
}
|
|
572
734
|
|
|
573
|
-
public removeCell(
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
735
|
+
public removeCell(
|
|
736
|
+
key: TableSchema.CellKey<TColumnSchema, TRowSchema>,
|
|
737
|
+
): CellValueType | undefined {
|
|
738
|
+
const { column: columnOrId, row: rowOrId } = key;
|
|
739
|
+
const row = this._getRow(rowOrId);
|
|
740
|
+
if (row === undefined) {
|
|
741
|
+
const rowId = this._getRowId(rowOrId);
|
|
742
|
+
throw new UsageError(
|
|
743
|
+
`Specified row with ID "${rowId}" does not exist in the table.`,
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
const column = this._getColumn(columnOrId);
|
|
748
|
+
if (column === undefined) {
|
|
749
|
+
const columnId = this._getColumnId(columnOrId);
|
|
750
|
+
throw new UsageError(
|
|
751
|
+
`Specified column with ID "${columnId}" does not exist in the table.`,
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
const cell: CellValueType | undefined = row.getCell(column.id);
|
|
756
|
+
if (cell === undefined) {
|
|
757
|
+
return undefined;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
row.removeCell(column.id);
|
|
761
|
+
return cell;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
private _getColumn(columnOrId: string | ColumnValueType): ColumnValueType | undefined {
|
|
765
|
+
return typeof columnOrId === "string" ? this.getColumn(columnOrId) : columnOrId;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
private _getColumnId(columnOrId: string | ColumnValueType): string {
|
|
769
|
+
return typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
private _getRow(rowOrId: string | RowValueType): RowValueType | undefined {
|
|
773
|
+
return typeof rowOrId === "string" ? this.getRow(rowOrId) : rowOrId;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
private _getRowId(rowOrId: string | RowValueType): string {
|
|
777
|
+
return typeof rowOrId === "string" ? rowOrId : rowOrId.id;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
private containsColumnWithId(columnId: string): boolean {
|
|
781
|
+
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
782
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
783
|
+
return (
|
|
784
|
+
this.columns.find((column) => (column as TableSchema.Column).id === columnId) !==
|
|
785
|
+
undefined
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
private containsRowWithId(rowId: string): boolean {
|
|
790
|
+
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
791
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
792
|
+
return this.rows.find((row) => (row as TableSchema.Row).id === rowId) !== undefined;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Ensure that the specified index is a valid location for item insertion in the destination list.
|
|
797
|
+
* @throws Throws a usage error if the destination is invalid.
|
|
798
|
+
*/
|
|
799
|
+
private static validateInsertionIndex(
|
|
800
|
+
index: number,
|
|
801
|
+
destinationList: readonly unknown[],
|
|
802
|
+
): void {
|
|
803
|
+
if (index < 0) {
|
|
804
|
+
throw new UsageError("The index must be greater than or equal to 0.");
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
if (index > destinationList.length) {
|
|
808
|
+
throw new UsageError("The index specified for insertion is out of bounds.");
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
if (!Number.isInteger(index)) {
|
|
812
|
+
throw new UsageError("The index must be an integer.");
|
|
581
813
|
}
|
|
582
814
|
}
|
|
583
815
|
}
|
|
584
816
|
|
|
585
817
|
type TableValueType = TreeNode &
|
|
586
|
-
TableSchema.
|
|
818
|
+
TableSchema.Table<TCellSchema, TColumnSchema, TRowSchema> &
|
|
587
819
|
WithType<ScopedSchemaName<Scope, "Table">>;
|
|
588
820
|
type TableInsertableType = InsertableObjectFromSchemaRecord<typeof tableFields>;
|
|
589
821
|
|
|
@@ -612,20 +844,100 @@ export namespace System_TableSchema {
|
|
|
612
844
|
export type TableSchemaBase<
|
|
613
845
|
TScope extends string | undefined,
|
|
614
846
|
TCell extends ImplicitAllowedTypes,
|
|
615
|
-
TColumn extends ColumnSchemaBase<TScope
|
|
616
|
-
TRow extends RowSchemaBase<TScope, TCell
|
|
617
|
-
|
|
618
|
-
TCell,
|
|
619
|
-
ImplicitAllowedTypes
|
|
620
|
-
>,
|
|
621
|
-
> = ReturnType<typeof TableSchema.createTable<TScope, TCell, TColumn, TRow>>;
|
|
847
|
+
TColumn extends ColumnSchemaBase<TScope>,
|
|
848
|
+
TRow extends RowSchemaBase<TScope, TCell>,
|
|
849
|
+
> = ReturnType<typeof createTableSchema<TScope, TCell, TColumn, TRow>>;
|
|
622
850
|
|
|
623
851
|
// #endregion
|
|
624
852
|
}
|
|
625
853
|
|
|
626
854
|
/**
|
|
627
855
|
* Contains types and factories for creating schema to represent dynamic tabular data.
|
|
628
|
-
*
|
|
856
|
+
*
|
|
857
|
+
* @remarks
|
|
858
|
+
*
|
|
859
|
+
* Tables created using these APIs are...
|
|
860
|
+
*
|
|
861
|
+
* - sparse, meaning that cells may be omitted, and new rows are empty by default.
|
|
862
|
+
*
|
|
863
|
+
* - dynamic, meaning that their structure can be modified at runtime.
|
|
864
|
+
* Columns and rows can be inserted, removed, modified, and reordered.
|
|
865
|
+
* Cells can be inserted, removed, and modified.
|
|
866
|
+
*
|
|
867
|
+
* - row-major, meaning that operating on rows (including inserts, removal, moves, and traversal) is more efficient than operating on columns.
|
|
868
|
+
*
|
|
869
|
+
* Column and Row schema created using these APIs are extensible via the `props` field.
|
|
870
|
+
* This allows association of additional properties with column and row nodes.
|
|
871
|
+
*
|
|
872
|
+
* Note: for now it is possible for table cells to become "orphaned".
|
|
873
|
+
* That is, it is possible to enter a state where one or more rows contain cells with no corresponding column.
|
|
874
|
+
* To help avoid this situation, you can manually remove corresponding cells when removing columns.
|
|
875
|
+
* Either way, it is possible to enter such a state via the merging of edits.
|
|
876
|
+
* For example: one client might add a row while another concurrently removes a column, orphaning the cell where the column and row intersected.
|
|
877
|
+
*
|
|
878
|
+
* @example Using default Column and Row schema
|
|
879
|
+
*
|
|
880
|
+
* ```typescript
|
|
881
|
+
* class Cell extends schemaFactory.object("TableCell", {
|
|
882
|
+
* value: schemaFactory.string,
|
|
883
|
+
* }) {}
|
|
884
|
+
*
|
|
885
|
+
* class Table extends TableSchema.table({
|
|
886
|
+
* schemaFactory,
|
|
887
|
+
* cell: Cell,
|
|
888
|
+
* }) {}
|
|
889
|
+
*
|
|
890
|
+
* const table = new Table({
|
|
891
|
+
* columns: [{ id: "column-0" }],
|
|
892
|
+
* rows: [{ id: "row-0", cells: {} }],
|
|
893
|
+
* });
|
|
894
|
+
* ```
|
|
895
|
+
*
|
|
896
|
+
* @example Customizing Column and Row schema
|
|
897
|
+
*
|
|
898
|
+
* ```typescript
|
|
899
|
+
* class Cell extends schemaFactory.object("TableCell", {
|
|
900
|
+
* value: schemaFactory.string,
|
|
901
|
+
* }) {}
|
|
902
|
+
*
|
|
903
|
+
* class ColumnProps extends schemaFactory.object("TableColumnProps", {
|
|
904
|
+
* // Column label to display.
|
|
905
|
+
* label: schemaFactory.string,
|
|
906
|
+
* // The type of data represented by the cells. Default: string.
|
|
907
|
+
* dataType: schemaFactory.optional(schemaFactory.string),
|
|
908
|
+
* }) {}
|
|
909
|
+
*
|
|
910
|
+
* class Column extends TableSchema.column({
|
|
911
|
+
* schemaFactory,
|
|
912
|
+
* props: ColumnProps,
|
|
913
|
+
* }) {}
|
|
914
|
+
*
|
|
915
|
+
* class Row extends TableSchema.row({
|
|
916
|
+
* schemaFactory,
|
|
917
|
+
* cell: Cell,
|
|
918
|
+
* }) {}
|
|
919
|
+
*
|
|
920
|
+
* class Table extends TableSchema.table({
|
|
921
|
+
* schemaFactory,
|
|
922
|
+
* cell: Cell,
|
|
923
|
+
* column: Column,
|
|
924
|
+
* row: Row,
|
|
925
|
+
* }) {}
|
|
926
|
+
*
|
|
927
|
+
* const table = new Table({
|
|
928
|
+
* columns: [
|
|
929
|
+
* new Column({ props: { label: "Entry", dataType: "string" } }),
|
|
930
|
+
* new Column({ props: { label: "Date", dataType: "date" } }),
|
|
931
|
+
* new Column({ props: { label: "Amount", dataType: "number" } }),
|
|
932
|
+
* ],
|
|
933
|
+
* rows: [],
|
|
934
|
+
* });
|
|
935
|
+
* ```
|
|
936
|
+
*
|
|
937
|
+
* @privateRemarks
|
|
938
|
+
* The above examples are backed by tests in `tableSchema.spec.ts`.
|
|
939
|
+
* Those tests and these examples should be kept in-sync to ensure that the examples are correct.
|
|
940
|
+
*
|
|
629
941
|
* @internal
|
|
630
942
|
*/
|
|
631
943
|
export namespace TableSchema {
|
|
@@ -633,10 +945,10 @@ export namespace TableSchema {
|
|
|
633
945
|
|
|
634
946
|
/**
|
|
635
947
|
* A column in a table.
|
|
636
|
-
* @remarks Implemented by the schema class returned from {@link TableSchema.(
|
|
948
|
+
* @remarks Implemented by the schema class returned from {@link TableSchema.(column:2)}.
|
|
637
949
|
* @sealed @internal
|
|
638
950
|
*/
|
|
639
|
-
export interface
|
|
951
|
+
export interface Column<
|
|
640
952
|
TProps extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
|
|
641
953
|
> {
|
|
642
954
|
/**
|
|
@@ -649,10 +961,10 @@ export namespace TableSchema {
|
|
|
649
961
|
* The column's properties.
|
|
650
962
|
* @remarks This is a user-defined schema that can be used to store additional information about the column.
|
|
651
963
|
* @privateRemarks
|
|
652
|
-
* Note: these docs are duplicated on the inline type definitions in {@link
|
|
964
|
+
* Note: these docs are duplicated on the inline type definitions in {@link System_TableSchema.createColumnSchema}.
|
|
653
965
|
* If you update the docs here, please also update the inline type definitions.
|
|
654
966
|
*/
|
|
655
|
-
get props(): TreeFieldFromImplicitField<UnannotateImplicitFieldSchema<TProps
|
|
967
|
+
get props(): TreeFieldFromImplicitField<UnannotateImplicitFieldSchema<TProps>>;
|
|
656
968
|
set props(value: InsertableTreeFieldFromImplicitField<
|
|
657
969
|
UnannotateImplicitFieldSchema<TProps>
|
|
658
970
|
>);
|
|
@@ -662,40 +974,34 @@ export namespace TableSchema {
|
|
|
662
974
|
* Factory for creating new table column schema.
|
|
663
975
|
* @internal
|
|
664
976
|
*/
|
|
665
|
-
export function
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
typeof System_TableSchema.createColumnInternal<
|
|
669
|
-
TScope,
|
|
670
|
-
FieldSchema<FieldKind.Optional, typeof SchemaFactoryAlpha.null>
|
|
671
|
-
>
|
|
672
|
-
>;
|
|
977
|
+
export function column<const TScope extends string | undefined>(
|
|
978
|
+
params: System_TableSchema.CreateColumnOptionsBase<SchemaFactoryAlpha<TScope>>,
|
|
979
|
+
): System_TableSchema.ColumnSchemaBase<TScope, System_TableSchema.DefaultPropsType>;
|
|
673
980
|
/**
|
|
674
981
|
* Factory for creating new table column schema.
|
|
675
982
|
* @internal
|
|
676
983
|
*/
|
|
677
|
-
export function
|
|
984
|
+
export function column<
|
|
678
985
|
const TScope extends string | undefined,
|
|
679
|
-
const TProps extends
|
|
680
|
-
>(
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
}): ReturnType<typeof System_TableSchema.createColumnInternal<TScope, TProps>>;
|
|
986
|
+
const TProps extends ImplicitAnnotatedFieldSchema,
|
|
987
|
+
>(
|
|
988
|
+
params: System_TableSchema.CreateColumnOptionsBase<SchemaFactoryAlpha<TScope>> & {
|
|
989
|
+
/**
|
|
990
|
+
* Optional column properties.
|
|
991
|
+
*/
|
|
992
|
+
readonly props: TProps;
|
|
993
|
+
},
|
|
994
|
+
): System_TableSchema.ColumnSchemaBase<TScope, TProps>;
|
|
689
995
|
/**
|
|
690
996
|
* Overload implementation
|
|
691
997
|
*/
|
|
692
|
-
export function
|
|
998
|
+
export function column({
|
|
693
999
|
schemaFactory,
|
|
694
1000
|
props = SchemaFactory.optional(SchemaFactory.null),
|
|
695
1001
|
}: System_TableSchema.CreateColumnOptionsBase & {
|
|
696
|
-
readonly props?:
|
|
1002
|
+
readonly props?: ImplicitAnnotatedFieldSchema;
|
|
697
1003
|
}): TreeNodeSchema {
|
|
698
|
-
return System_TableSchema.
|
|
1004
|
+
return System_TableSchema.createColumnSchema(schemaFactory, props);
|
|
699
1005
|
}
|
|
700
1006
|
|
|
701
1007
|
// #endregion
|
|
@@ -707,8 +1013,8 @@ export namespace TableSchema {
|
|
|
707
1013
|
* @remarks Implemented by the schema class returned from {@link TableSchema.(createRow:2)}.
|
|
708
1014
|
* @sealed @internal
|
|
709
1015
|
*/
|
|
710
|
-
export interface
|
|
711
|
-
TCell extends ImplicitAllowedTypes,
|
|
1016
|
+
export interface Row<
|
|
1017
|
+
TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
712
1018
|
TProps extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
|
|
713
1019
|
> {
|
|
714
1020
|
/**
|
|
@@ -720,8 +1026,9 @@ export namespace TableSchema {
|
|
|
720
1026
|
/**
|
|
721
1027
|
* Gets the cell in the specified column.
|
|
722
1028
|
* @returns The cell if it exists, otherwise undefined.
|
|
1029
|
+
* @privateRemarks TODO: throw if the column does not belong to the same table as the row.
|
|
723
1030
|
*/
|
|
724
|
-
getCell(column:
|
|
1031
|
+
getCell(column: Column): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
725
1032
|
/**
|
|
726
1033
|
* Gets the cell in the specified column, denoted by column ID.
|
|
727
1034
|
* @returns The cell if it exists, otherwise undefined.
|
|
@@ -730,31 +1037,33 @@ export namespace TableSchema {
|
|
|
730
1037
|
|
|
731
1038
|
/**
|
|
732
1039
|
* Sets the cell in the specified column.
|
|
733
|
-
* @remarks To remove a cell, call {@link TableSchema.
|
|
1040
|
+
* @remarks To remove a cell, call {@link TableSchema.Row.(removeCell:1)} instead.
|
|
1041
|
+
* @privateRemarks TODO: Throw an error if the column does not exist in the table.
|
|
734
1042
|
*/
|
|
735
|
-
setCell(column:
|
|
1043
|
+
setCell(column: Column, value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>): void;
|
|
736
1044
|
/**
|
|
737
1045
|
* Sets the cell in the specified column, denoted by column ID.
|
|
738
|
-
* @remarks To remove a cell, call {@link TableSchema.
|
|
1046
|
+
* @remarks To remove a cell, call {@link TableSchema.Row.(removeCell:2)} instead.
|
|
739
1047
|
*/
|
|
740
1048
|
setCell(columnId: string, value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>): void;
|
|
741
1049
|
|
|
742
1050
|
/**
|
|
743
1051
|
* Removes the cell in the specified column.
|
|
744
|
-
* @
|
|
1052
|
+
* @returns The cell if it exists, otherwise undefined.
|
|
1053
|
+
* @privateRemarks TODO: Throw if the column does not belong to the same table as the row.
|
|
745
1054
|
*/
|
|
746
|
-
removeCell(column:
|
|
1055
|
+
removeCell(column: Column): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
747
1056
|
/**
|
|
748
1057
|
* Removes the cell in the specified column, denoted by column ID.
|
|
749
|
-
* @
|
|
1058
|
+
* @returns The cell if it exists, otherwise undefined.
|
|
750
1059
|
*/
|
|
751
|
-
removeCell(columnId: string):
|
|
1060
|
+
removeCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
752
1061
|
|
|
753
1062
|
/**
|
|
754
1063
|
* The row's properties.
|
|
755
1064
|
* @remarks This is a user-defined schema that can be used to store additional information about the row.
|
|
756
1065
|
* @privateRemarks
|
|
757
|
-
* Note: these docs are duplicated on the inline type definitions in {@link
|
|
1066
|
+
* Note: these docs are duplicated on the inline type definitions in {@link System_TableSchema.createRowSchema}.
|
|
758
1067
|
* If you update the docs here, please also update the inline type definitions.
|
|
759
1068
|
*/
|
|
760
1069
|
get props(): TreeFieldFromImplicitField<UnannotateImplicitFieldSchema<TProps>>;
|
|
@@ -767,48 +1076,39 @@ export namespace TableSchema {
|
|
|
767
1076
|
* Factory for creating new table column schema.
|
|
768
1077
|
* @internal
|
|
769
1078
|
*/
|
|
770
|
-
export function
|
|
1079
|
+
export function row<
|
|
771
1080
|
const TScope extends string | undefined,
|
|
772
1081
|
const TCell extends ImplicitAllowedTypes,
|
|
773
|
-
>(
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
}: System_TableSchema.CreateRowOptionsBase<TScope, TCell>): ReturnType<
|
|
777
|
-
typeof System_TableSchema.createRowInternal<
|
|
778
|
-
TScope,
|
|
779
|
-
TCell,
|
|
780
|
-
FieldSchema<FieldKind.Optional, typeof SchemaFactoryAlpha.null>
|
|
781
|
-
>
|
|
782
|
-
>;
|
|
1082
|
+
>(
|
|
1083
|
+
params: System_TableSchema.CreateRowOptionsBase<SchemaFactoryAlpha<TScope>, TCell>,
|
|
1084
|
+
): System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>;
|
|
783
1085
|
/**
|
|
784
|
-
* Factory for creating new table
|
|
1086
|
+
* Factory for creating new table row schema.
|
|
785
1087
|
* @internal
|
|
786
1088
|
*/
|
|
787
|
-
export function
|
|
1089
|
+
export function row<
|
|
788
1090
|
const TScope extends string | undefined,
|
|
789
1091
|
const TCell extends ImplicitAllowedTypes,
|
|
790
|
-
const TProps extends
|
|
791
|
-
>(
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
readonly props: TProps;
|
|
800
|
-
}): ReturnType<typeof System_TableSchema.createRowInternal<TScope, TCell, TProps>>;
|
|
1092
|
+
const TProps extends ImplicitAnnotatedFieldSchema,
|
|
1093
|
+
>(
|
|
1094
|
+
params: System_TableSchema.CreateRowOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
|
|
1095
|
+
/**
|
|
1096
|
+
* Optional row properties.
|
|
1097
|
+
*/
|
|
1098
|
+
readonly props: TProps;
|
|
1099
|
+
},
|
|
1100
|
+
): System_TableSchema.RowSchemaBase<TScope, TCell, TProps>;
|
|
801
1101
|
/**
|
|
802
1102
|
* Overload implementation
|
|
803
1103
|
*/
|
|
804
|
-
export function
|
|
1104
|
+
export function row({
|
|
805
1105
|
schemaFactory,
|
|
806
1106
|
cell,
|
|
807
1107
|
props = SchemaFactory.optional(SchemaFactory.null),
|
|
808
1108
|
}: System_TableSchema.CreateRowOptionsBase & {
|
|
809
|
-
readonly props?:
|
|
1109
|
+
readonly props?: ImplicitAnnotatedFieldSchema;
|
|
810
1110
|
}): TreeNodeSchema {
|
|
811
|
-
return System_TableSchema.
|
|
1111
|
+
return System_TableSchema.createRowSchema(schemaFactory, cell, props);
|
|
812
1112
|
}
|
|
813
1113
|
|
|
814
1114
|
// #endregion
|
|
@@ -816,26 +1116,29 @@ export namespace TableSchema {
|
|
|
816
1116
|
// #region Table
|
|
817
1117
|
|
|
818
1118
|
/**
|
|
819
|
-
* A key to uniquely identify a cell
|
|
1119
|
+
* A key to uniquely identify a cell within a table.
|
|
820
1120
|
* @internal
|
|
821
1121
|
*/
|
|
822
|
-
export interface CellKey
|
|
1122
|
+
export interface CellKey<
|
|
1123
|
+
TColumn extends ImplicitAllowedTypes,
|
|
1124
|
+
TRow extends ImplicitAllowedTypes,
|
|
1125
|
+
> {
|
|
823
1126
|
/**
|
|
824
|
-
* {@link TableSchema.
|
|
1127
|
+
* {@link TableSchema.Column} or {@link TableSchema.Column.id} at which the cell is located.
|
|
825
1128
|
*/
|
|
826
|
-
readonly
|
|
1129
|
+
readonly column: string | TreeNodeFromImplicitAllowedTypes<TColumn>;
|
|
827
1130
|
|
|
828
1131
|
/**
|
|
829
|
-
* {@link TableSchema.
|
|
1132
|
+
* {@link TableSchema.Row} or {@link TableSchema.Row.id} at which the cell is located.
|
|
830
1133
|
*/
|
|
831
|
-
readonly
|
|
1134
|
+
readonly row: string | TreeNodeFromImplicitAllowedTypes<TRow>;
|
|
832
1135
|
}
|
|
833
1136
|
|
|
834
1137
|
/**
|
|
835
|
-
* {@link TableSchema.
|
|
1138
|
+
* {@link TableSchema.Table.insertColumn} parameters.
|
|
836
1139
|
* @internal
|
|
837
1140
|
*/
|
|
838
|
-
export interface InsertColumnParameters<
|
|
1141
|
+
export interface InsertColumnParameters<TColumn extends ImplicitAllowedTypes> {
|
|
839
1142
|
/**
|
|
840
1143
|
* The index at which to insert the new column.
|
|
841
1144
|
* @remarks If not provided, the column will be appended to the end of the table.
|
|
@@ -845,14 +1148,48 @@ export namespace TableSchema {
|
|
|
845
1148
|
/**
|
|
846
1149
|
* The column to insert.
|
|
847
1150
|
*/
|
|
848
|
-
readonly column:
|
|
1151
|
+
readonly column: InsertableTreeNodeFromImplicitAllowedTypes<TColumn>;
|
|
849
1152
|
}
|
|
850
1153
|
|
|
851
1154
|
/**
|
|
852
|
-
* {@link TableSchema.
|
|
1155
|
+
* {@link TableSchema.Table.insertColumns} parameters.
|
|
853
1156
|
* @internal
|
|
854
1157
|
*/
|
|
855
|
-
export interface
|
|
1158
|
+
export interface InsertColumnsParameters<TColumn extends ImplicitAllowedTypes> {
|
|
1159
|
+
/**
|
|
1160
|
+
* The index at which to insert the new columns.
|
|
1161
|
+
* @remarks If not provided, the columns will be appended to the end of the table.
|
|
1162
|
+
*/
|
|
1163
|
+
readonly index?: number | undefined;
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* The columns to insert.
|
|
1167
|
+
*/
|
|
1168
|
+
readonly columns: InsertableTreeNodeFromImplicitAllowedTypes<TColumn>[];
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* {@link TableSchema.Table.insertRow} parameters.
|
|
1173
|
+
* @internal
|
|
1174
|
+
*/
|
|
1175
|
+
export interface InsertRowParameters<TRow extends ImplicitAllowedTypes> {
|
|
1176
|
+
/**
|
|
1177
|
+
* The index at which to insert the new row.
|
|
1178
|
+
* @remarks If not provided, the row will be appended to the end of the table.
|
|
1179
|
+
*/
|
|
1180
|
+
readonly index?: number | undefined;
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* The row to insert.
|
|
1184
|
+
*/
|
|
1185
|
+
readonly row: InsertableTreeNodeFromImplicitAllowedTypes<TRow>;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* {@link TableSchema.Table.insertRows} parameters.
|
|
1190
|
+
* @internal
|
|
1191
|
+
*/
|
|
1192
|
+
export interface InsertRowsParameters<TRow extends ImplicitAllowedTypes> {
|
|
856
1193
|
/**
|
|
857
1194
|
* The index at which to insert the new rows.
|
|
858
1195
|
* @remarks If not provided, the rows will be appended to the end of the table.
|
|
@@ -862,30 +1199,34 @@ export namespace TableSchema {
|
|
|
862
1199
|
/**
|
|
863
1200
|
* The rows to insert.
|
|
864
1201
|
*/
|
|
865
|
-
readonly rows:
|
|
1202
|
+
readonly rows: InsertableTreeNodeFromImplicitAllowedTypes<TRow>[];
|
|
866
1203
|
}
|
|
867
1204
|
|
|
868
1205
|
/**
|
|
869
|
-
* {@link TableSchema.
|
|
1206
|
+
* {@link TableSchema.Table.setCell} parameters.
|
|
870
1207
|
* @internal
|
|
871
1208
|
*/
|
|
872
|
-
export interface SetCellParameters<
|
|
1209
|
+
export interface SetCellParameters<
|
|
1210
|
+
TCell extends ImplicitAllowedTypes,
|
|
1211
|
+
TColumn extends ImplicitAllowedTypes,
|
|
1212
|
+
TRow extends ImplicitAllowedTypes,
|
|
1213
|
+
> {
|
|
873
1214
|
/**
|
|
874
1215
|
* The key to uniquely identify a cell in a table.
|
|
875
1216
|
*/
|
|
876
|
-
readonly key: CellKey
|
|
1217
|
+
readonly key: CellKey<TColumn, TRow>;
|
|
877
1218
|
|
|
878
1219
|
/**
|
|
879
1220
|
* The cell to set.
|
|
880
1221
|
*/
|
|
881
|
-
readonly cell:
|
|
1222
|
+
readonly cell: InsertableTreeNodeFromImplicitAllowedTypes<TCell>;
|
|
882
1223
|
}
|
|
883
1224
|
|
|
884
1225
|
/**
|
|
885
1226
|
* A table.
|
|
886
1227
|
* @sealed @internal
|
|
887
1228
|
*/
|
|
888
|
-
export interface
|
|
1229
|
+
export interface Table<
|
|
889
1230
|
TCell extends ImplicitAllowedTypes,
|
|
890
1231
|
TColumn extends ImplicitAllowedTypes,
|
|
891
1232
|
TRow extends ImplicitAllowedTypes,
|
|
@@ -901,139 +1242,252 @@ export namespace TableSchema {
|
|
|
901
1242
|
readonly rows: TreeArrayNode<TRow>;
|
|
902
1243
|
|
|
903
1244
|
/**
|
|
904
|
-
* Gets a table column by its {@link TableSchema.
|
|
1245
|
+
* Gets a table column by its {@link TableSchema.Column.id}.
|
|
905
1246
|
*/
|
|
906
1247
|
getColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumn> | undefined;
|
|
907
1248
|
|
|
908
1249
|
/**
|
|
909
|
-
* Gets a table row by its {@link TableSchema.
|
|
1250
|
+
* Gets a table row by its {@link TableSchema.Row.id}.
|
|
910
1251
|
*/
|
|
911
1252
|
getRow(id: string): TreeNodeFromImplicitAllowedTypes<TRow> | undefined;
|
|
912
1253
|
|
|
913
1254
|
/**
|
|
914
1255
|
* Gets a cell in the table by column and row IDs.
|
|
915
1256
|
* @param key - A key that uniquely distinguishes a cell in the table, represented as a combination of the column ID and row ID.
|
|
916
|
-
* @privateRemarks TODO: add overload that takes row and column nodes.
|
|
917
1257
|
*/
|
|
918
|
-
getCell(key: CellKey): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
1258
|
+
getCell(key: CellKey<TColumn, TRow>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
919
1259
|
|
|
920
1260
|
/**
|
|
921
1261
|
* Inserts a column into the table.
|
|
922
|
-
*
|
|
1262
|
+
*
|
|
1263
|
+
* @throws
|
|
1264
|
+
* Throws an error in the following cases:
|
|
1265
|
+
*
|
|
1266
|
+
* - The column, or a column with the same ID is already in the tree.
|
|
1267
|
+
*
|
|
1268
|
+
* - The specified index is out of range.
|
|
1269
|
+
*
|
|
1270
|
+
* No column is inserted in these cases.
|
|
923
1271
|
*/
|
|
924
1272
|
insertColumn(
|
|
925
|
-
params: InsertColumnParameters<
|
|
1273
|
+
params: InsertColumnParameters<TColumn>,
|
|
926
1274
|
): TreeNodeFromImplicitAllowedTypes<TColumn>;
|
|
927
1275
|
|
|
1276
|
+
/**
|
|
1277
|
+
* Inserts 0 or more columns into the table.
|
|
1278
|
+
*
|
|
1279
|
+
* @throws
|
|
1280
|
+
* Throws an error in the following cases:
|
|
1281
|
+
*
|
|
1282
|
+
* - At least one column, or a column with the same ID is already in the tree.
|
|
1283
|
+
*
|
|
1284
|
+
* - The specified index is out of range.
|
|
1285
|
+
*
|
|
1286
|
+
* No columns are inserted in these cases.
|
|
1287
|
+
*/
|
|
1288
|
+
insertColumns(
|
|
1289
|
+
params: InsertColumnsParameters<TColumn>,
|
|
1290
|
+
): TreeNodeFromImplicitAllowedTypes<TColumn>[];
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* Inserts a row into the table.
|
|
1294
|
+
*
|
|
1295
|
+
* @throws
|
|
1296
|
+
* Throws an error in the following cases:
|
|
1297
|
+
*
|
|
1298
|
+
* - The row, or a row with the same ID is already in the tree.
|
|
1299
|
+
*
|
|
1300
|
+
* - The row contains cells, but the table does not contain matching columns for one or more of those cells.
|
|
1301
|
+
*
|
|
1302
|
+
* - The specified index is out of range.
|
|
1303
|
+
*
|
|
1304
|
+
* No row is inserted in these cases.
|
|
1305
|
+
*/
|
|
1306
|
+
insertRow(params: InsertRowParameters<TRow>): TreeNodeFromImplicitAllowedTypes<TRow>;
|
|
1307
|
+
|
|
928
1308
|
/**
|
|
929
1309
|
* Inserts 0 or more rows into the table.
|
|
930
|
-
*
|
|
1310
|
+
*
|
|
1311
|
+
* @throws
|
|
1312
|
+
* Throws an error in the following cases:
|
|
1313
|
+
*
|
|
1314
|
+
* - At least one row, or a row with the same ID is already in the tree.
|
|
1315
|
+
*
|
|
1316
|
+
* - The row contains cells, but the table does not contain matching columns for one or more of those cells.
|
|
1317
|
+
*
|
|
1318
|
+
* - The specified index is out of range.
|
|
1319
|
+
*
|
|
1320
|
+
* No rows are inserted in these cases.
|
|
931
1321
|
*/
|
|
932
|
-
insertRows(
|
|
933
|
-
params: InsertRowsParameters<InsertableTreeNodeFromImplicitAllowedTypes<TRow>>,
|
|
934
|
-
): TreeNodeFromImplicitAllowedTypes<TRow>[];
|
|
1322
|
+
insertRows(params: InsertRowsParameters<TRow>): TreeNodeFromImplicitAllowedTypes<TRow>[];
|
|
935
1323
|
|
|
936
1324
|
/**
|
|
937
1325
|
* Sets the cell at the specified location in the table.
|
|
938
|
-
* @remarks To remove a cell, call {@link TableSchema.
|
|
939
|
-
* @privateRemarks TODO: add overload that takes column/row nodes?
|
|
1326
|
+
* @remarks To remove a cell, call {@link TableSchema.Table.removeCell} instead.
|
|
940
1327
|
*/
|
|
941
|
-
setCell(
|
|
942
|
-
params: SetCellParameters<InsertableTreeNodeFromImplicitAllowedTypes<TCell>>,
|
|
943
|
-
): void;
|
|
1328
|
+
setCell(params: SetCellParameters<TCell, TColumn, TRow>): void;
|
|
944
1329
|
|
|
945
1330
|
/**
|
|
946
1331
|
* Removes the specified column from the table.
|
|
947
|
-
*
|
|
948
|
-
* @
|
|
949
|
-
*
|
|
950
|
-
*
|
|
951
|
-
*
|
|
1332
|
+
*
|
|
1333
|
+
* @remarks
|
|
1334
|
+
* Note: this does not remove any cells from the table's rows.
|
|
1335
|
+
* To remove the corresponding cells, use {@link TableSchema.Table.removeCell}.
|
|
1336
|
+
*
|
|
1337
|
+
* @param column - The {@link TableSchema.Column | column} or {@link TableSchema.Column.id | column ID} to remove.
|
|
1338
|
+
* @throws Throws an error if the column is not in the table.
|
|
1339
|
+
* @privateRemarks TODO (future): Actually remove corresponding cells from table rows.
|
|
952
1340
|
*/
|
|
953
|
-
removeColumn
|
|
1341
|
+
removeColumn(
|
|
1342
|
+
column: string | TreeNodeFromImplicitAllowedTypes<TColumn>,
|
|
1343
|
+
): TreeNodeFromImplicitAllowedTypes<TColumn>;
|
|
954
1344
|
|
|
1345
|
+
/**
|
|
1346
|
+
* Removes 0 or more columns from the table.
|
|
1347
|
+
*
|
|
1348
|
+
* @remarks
|
|
1349
|
+
* Note: this does not remove any cells from the table's rows.
|
|
1350
|
+
* To remove the corresponding cells, use {@link TableSchema.Table.removeCell}.
|
|
1351
|
+
*
|
|
1352
|
+
* @param columns - The columns to remove.
|
|
1353
|
+
* @throws Throws an error if any of the columns are not in the table.
|
|
1354
|
+
* In this case, no columns are removed.
|
|
1355
|
+
*/
|
|
1356
|
+
removeColumns(
|
|
1357
|
+
columns: readonly TreeNodeFromImplicitAllowedTypes<TColumn>[],
|
|
1358
|
+
): TreeNodeFromImplicitAllowedTypes<TColumn>[];
|
|
1359
|
+
/**
|
|
1360
|
+
* Removes 0 or more columns from the table.
|
|
1361
|
+
*
|
|
1362
|
+
* @remarks
|
|
1363
|
+
* Note: this does not remove any cells from the table's rows.
|
|
1364
|
+
* To remove the corresponding cells, use {@link TableSchema.Table.removeCell}.
|
|
1365
|
+
*
|
|
1366
|
+
* @param columns - The columns to remove, specified by their {@link TableSchema.Column.id}.
|
|
1367
|
+
* @throws Throws an error if any of the columns are not in the table.
|
|
1368
|
+
* In this case, no columns are removed.
|
|
1369
|
+
*/
|
|
1370
|
+
removeColumns(columns: readonly string[]): TreeNodeFromImplicitAllowedTypes<TColumn>[];
|
|
1371
|
+
|
|
1372
|
+
/**
|
|
1373
|
+
* Removes all columns from the table.
|
|
1374
|
+
* @returns The removed columns.
|
|
1375
|
+
*/
|
|
1376
|
+
removeAllColumns(): TreeNodeFromImplicitAllowedTypes<TColumn>[];
|
|
1377
|
+
|
|
1378
|
+
/**
|
|
1379
|
+
* Removes the specified row from the table.
|
|
1380
|
+
* @param row - The {@link TableSchema.Row | row} or {@link TableSchema.Row.id | row ID} to remove.
|
|
1381
|
+
* @throws Throws an error if the row is not in the table.
|
|
1382
|
+
*/
|
|
1383
|
+
removeRow(
|
|
1384
|
+
row: string | TreeNodeFromImplicitAllowedTypes<TRow>,
|
|
1385
|
+
): TreeNodeFromImplicitAllowedTypes<TRow>;
|
|
1386
|
+
|
|
1387
|
+
/**
|
|
1388
|
+
* Removes 0 or more rows from the table.
|
|
1389
|
+
* @param rows - The rows to remove.
|
|
1390
|
+
* @throws Throws an error if any of the rows are not in the table.
|
|
1391
|
+
* In this case, no rows are removed.
|
|
1392
|
+
*/
|
|
1393
|
+
removeRows(
|
|
1394
|
+
rows: readonly TreeNodeFromImplicitAllowedTypes<TRow>[],
|
|
1395
|
+
): TreeNodeFromImplicitAllowedTypes<TRow>[];
|
|
955
1396
|
/**
|
|
956
1397
|
* Removes 0 or more rows from the table.
|
|
957
|
-
* @
|
|
1398
|
+
* @param rows - The rows to remove, specified by their {@link TableSchema.Row.id}.
|
|
1399
|
+
* @throws Throws an error if any of the rows are not in the table.
|
|
1400
|
+
* In this case, no rows are removed.
|
|
958
1401
|
*/
|
|
959
|
-
removeRows
|
|
1402
|
+
removeRows(rows: readonly string[]): TreeNodeFromImplicitAllowedTypes<TRow>[];
|
|
960
1403
|
|
|
961
1404
|
/**
|
|
962
1405
|
* Removes all rows from the table.
|
|
1406
|
+
* @returns The removed rows.
|
|
963
1407
|
*/
|
|
964
|
-
removeAllRows
|
|
1408
|
+
removeAllRows(): TreeNodeFromImplicitAllowedTypes<TRow>[];
|
|
965
1409
|
|
|
966
1410
|
/**
|
|
967
1411
|
* Removes the cell at the specified location in the table.
|
|
968
|
-
* @
|
|
1412
|
+
* @returns The cell if it exists, otherwise undefined.
|
|
1413
|
+
* @throws Throws an error if the location does not exist in the table.
|
|
969
1414
|
*/
|
|
970
|
-
removeCell
|
|
1415
|
+
removeCell(
|
|
1416
|
+
key: CellKey<TColumn, TRow>,
|
|
1417
|
+
): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
971
1418
|
}
|
|
972
1419
|
|
|
973
1420
|
/**
|
|
974
1421
|
* Factory for creating new table schema without specifying row or column schema.
|
|
975
1422
|
* @internal
|
|
976
1423
|
*/
|
|
977
|
-
export function
|
|
1424
|
+
export function table<
|
|
978
1425
|
const TScope extends string | undefined,
|
|
979
1426
|
const TCell extends ImplicitAllowedTypes,
|
|
980
|
-
>(
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1427
|
+
>(
|
|
1428
|
+
params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell>,
|
|
1429
|
+
): System_TableSchema.TableSchemaBase<
|
|
1430
|
+
TScope,
|
|
1431
|
+
TCell,
|
|
1432
|
+
System_TableSchema.ColumnSchemaBase<TScope, System_TableSchema.DefaultPropsType>,
|
|
1433
|
+
System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>
|
|
985
1434
|
>;
|
|
986
1435
|
/**
|
|
987
1436
|
* Factory for creating new table schema without specifying row schema.
|
|
988
1437
|
* @internal
|
|
989
1438
|
*/
|
|
990
|
-
export function
|
|
1439
|
+
export function table<
|
|
991
1440
|
const TScope extends string | undefined,
|
|
992
1441
|
const TCell extends ImplicitAllowedTypes,
|
|
993
1442
|
const TColumn extends System_TableSchema.ColumnSchemaBase<TScope>,
|
|
994
|
-
>(
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1443
|
+
>(
|
|
1444
|
+
params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
|
|
1445
|
+
readonly column: TColumn;
|
|
1446
|
+
},
|
|
1447
|
+
): System_TableSchema.TableSchemaBase<
|
|
1448
|
+
TScope,
|
|
1449
|
+
TCell,
|
|
1450
|
+
TColumn,
|
|
1451
|
+
System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>
|
|
1452
|
+
>;
|
|
1001
1453
|
/**
|
|
1002
1454
|
* Factory for creating new table schema.
|
|
1003
1455
|
* @internal
|
|
1004
1456
|
*/
|
|
1005
|
-
export function
|
|
1457
|
+
export function table<
|
|
1006
1458
|
const TScope extends string | undefined,
|
|
1007
1459
|
const TCell extends ImplicitAllowedTypes,
|
|
1008
1460
|
const TColumn extends System_TableSchema.ColumnSchemaBase<TScope>,
|
|
1009
1461
|
const TRow extends System_TableSchema.RowSchemaBase<TScope, TCell>,
|
|
1010
|
-
>(
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
readonly column: TColumn;
|
|
1017
|
-
readonly row: TRow;
|
|
1018
|
-
}): ReturnType<typeof System_TableSchema.createTableInternal<TScope, TCell, TColumn, TRow>>;
|
|
1462
|
+
>(
|
|
1463
|
+
params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
|
|
1464
|
+
readonly column: TColumn;
|
|
1465
|
+
readonly row: TRow;
|
|
1466
|
+
},
|
|
1467
|
+
): System_TableSchema.TableSchemaBase<TScope, TCell, TColumn, TRow>;
|
|
1019
1468
|
/**
|
|
1020
1469
|
* Overload implementation
|
|
1021
1470
|
*/
|
|
1022
|
-
export function
|
|
1471
|
+
export function table({
|
|
1023
1472
|
schemaFactory,
|
|
1024
|
-
cell,
|
|
1025
|
-
column =
|
|
1473
|
+
cell: cellSchema,
|
|
1474
|
+
column: columnSchema = column({
|
|
1026
1475
|
schemaFactory,
|
|
1027
1476
|
}),
|
|
1028
|
-
row =
|
|
1477
|
+
row: rowSchema = row({
|
|
1029
1478
|
schemaFactory,
|
|
1030
|
-
cell,
|
|
1479
|
+
cell: cellSchema,
|
|
1031
1480
|
}),
|
|
1032
1481
|
}: System_TableSchema.TableFactoryOptionsBase & {
|
|
1033
1482
|
readonly column?: System_TableSchema.ColumnSchemaBase;
|
|
1034
1483
|
readonly row?: System_TableSchema.RowSchemaBase;
|
|
1035
1484
|
}): TreeNodeSchema {
|
|
1036
|
-
return System_TableSchema.
|
|
1485
|
+
return System_TableSchema.createTableSchema(
|
|
1486
|
+
schemaFactory,
|
|
1487
|
+
cellSchema,
|
|
1488
|
+
columnSchema,
|
|
1489
|
+
rowSchema,
|
|
1490
|
+
);
|
|
1037
1491
|
}
|
|
1038
1492
|
|
|
1039
1493
|
// #endregion
|