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