@fluidframework/tree 2.32.0 → 2.33.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 +53 -0
- package/api-report/tree.alpha.api.md +169 -192
- package/api-report/tree.beta.api.md +135 -164
- package/api-report/tree.legacy.alpha.api.md +138 -167
- package/api-report/tree.legacy.public.api.md +135 -164
- package/api-report/tree.public.api.md +135 -164
- package/dist/alpha.d.ts +3 -11
- package/dist/beta.d.ts +2 -11
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/schema-stored/index.d.ts +1 -1
- package/dist/core/schema-stored/index.d.ts.map +1 -1
- package/dist/core/schema-stored/index.js +1 -2
- package/dist/core/schema-stored/index.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +4 -11
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +7 -14
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +31 -24
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/deltaUtil.d.ts +1 -4
- package/dist/core/tree/deltaUtil.d.ts.map +1 -1
- package/dist/core/tree/deltaUtil.js +1 -13
- package/dist/core/tree/deltaUtil.js.map +1 -1
- package/dist/core/tree/visitDelta.d.ts +6 -29
- package/dist/core/tree/visitDelta.d.ts.map +1 -1
- package/dist/core/tree/visitDelta.js +11 -50
- package/dist/core/tree/visitDelta.js.map +1 -1
- package/dist/core/tree/visitorUtils.d.ts +12 -9
- package/dist/core/tree/visitorUtils.d.ts.map +1 -1
- package/dist/core/tree/visitorUtils.js +19 -32
- package/dist/core/tree/visitorUtils.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +6 -11
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +41 -5
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +43 -26
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts +5 -0
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js +4 -0
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js +15 -22
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
- package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +29 -25
- package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +1 -7
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +1 -1
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +1 -1
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/jsonDomainSchema.d.ts +6 -6
- package/dist/jsonDomainSchema.d.ts.map +1 -1
- package/dist/jsonDomainSchema.js.map +1 -1
- package/dist/legacy.d.ts +2 -11
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +2 -11
- package/dist/serializableDomainSchema.d.ts +5 -5
- package/dist/shared-tree/checkoutFlexTreeView.d.ts +1 -0
- package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
- package/dist/shared-tree/checkoutFlexTreeView.js +4 -0
- package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +3 -2
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +2 -2
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +4 -35
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +4 -54
- package/dist/shared-tree/sharedTree.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 +3 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +28 -28
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +11 -11
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +6 -7
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +24 -5
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js +14 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
- package/dist/simple-tree/api/tree.d.ts +1 -14
- 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/typesUnsafe.d.ts +237 -220
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +2 -2
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -2
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +39 -24
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/types.d.ts +14 -4
- package/dist/simple-tree/core/types.d.ts.map +1 -1
- package/dist/simple-tree/core/types.js +14 -4
- package/dist/simple-tree/core/types.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/index.d.ts +1 -1
- 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/objectNode.d.ts +9 -2
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +3 -0
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +10 -5
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +5 -2
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/tableSchema.d.ts +78 -26
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +53 -24
- package/dist/tableSchema.js.map +1 -1
- package/dist/treeFactory.d.ts +6 -12
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +56 -5
- package/dist/treeFactory.js.map +1 -1
- package/lib/alpha.d.ts +3 -11
- package/lib/beta.d.ts +2 -11
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/schema-stored/index.d.ts +1 -1
- package/lib/core/schema-stored/index.d.ts.map +1 -1
- package/lib/core/schema-stored/index.js +1 -1
- package/lib/core/schema-stored/index.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +4 -11
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +6 -12
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +31 -24
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/deltaUtil.d.ts +1 -4
- package/lib/core/tree/deltaUtil.d.ts.map +1 -1
- package/lib/core/tree/deltaUtil.js +0 -9
- package/lib/core/tree/deltaUtil.js.map +1 -1
- package/lib/core/tree/visitDelta.d.ts +6 -29
- package/lib/core/tree/visitDelta.d.ts.map +1 -1
- package/lib/core/tree/visitDelta.js +12 -51
- package/lib/core/tree/visitDelta.js.map +1 -1
- package/lib/core/tree/visitorUtils.d.ts +12 -9
- package/lib/core/tree/visitorUtils.d.ts.map +1 -1
- package/lib/core/tree/visitorUtils.js +19 -32
- package/lib/core/tree/visitorUtils.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -11
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +41 -5
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +43 -26
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts +5 -0
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js +5 -1
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js +15 -22
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
- package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +28 -24
- package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +1 -7
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +2 -2
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +1 -1
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/jsonDomainSchema.d.ts +6 -6
- package/lib/jsonDomainSchema.d.ts.map +1 -1
- package/lib/jsonDomainSchema.js.map +1 -1
- package/lib/legacy.d.ts +2 -11
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +2 -11
- package/lib/serializableDomainSchema.d.ts +5 -5
- package/lib/shared-tree/checkoutFlexTreeView.d.ts +1 -0
- package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
- package/lib/shared-tree/checkoutFlexTreeView.js +4 -0
- package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +3 -2
- 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/sharedTree.d.ts +4 -35
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +2 -51
- package/lib/shared-tree/sharedTree.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 -0
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +28 -28
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +11 -11
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +6 -7
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +24 -5
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js +12 -0
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
- package/lib/simple-tree/api/tree.d.ts +1 -14
- 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/typesUnsafe.d.ts +237 -220
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +2 -2
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -2
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +40 -25
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/types.d.ts +14 -4
- package/lib/simple-tree/core/types.d.ts.map +1 -1
- package/lib/simple-tree/core/types.js +14 -4
- package/lib/simple-tree/core/types.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +3 -0
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/index.d.ts +1 -1
- 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/objectNode.d.ts +9 -2
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +4 -1
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +10 -5
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +5 -2
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/tableSchema.d.ts +78 -26
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +53 -24
- package/lib/tableSchema.js.map +1 -1
- package/lib/treeFactory.d.ts +6 -12
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +55 -3
- package/lib/treeFactory.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +22 -23
- package/src/core/index.ts +0 -2
- package/src/core/schema-stored/index.ts +0 -2
- package/src/core/schema-stored/schema.ts +10 -29
- package/src/core/tree/anchorSet.ts +32 -24
- package/src/core/tree/deltaUtil.ts +1 -13
- package/src/core/tree/visitDelta.ts +24 -81
- package/src/core/tree/visitorUtils.ts +43 -53
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +7 -22
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +1 -1
- package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +45 -27
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +1 -1
- package/src/feature-libraries/flex-tree/context.ts +11 -1
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -0
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +17 -28
- package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +39 -38
- package/src/feature-libraries/object-forest/objectForest.ts +1 -18
- package/src/feature-libraries/schema-index/codec.ts +1 -2
- package/src/index.ts +3 -11
- package/src/internalTypes.ts +0 -19
- package/src/jsonDomainSchema.ts +1 -3
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/checkoutFlexTreeView.ts +6 -0
- package/src/shared-tree/index.ts +8 -3
- package/src/shared-tree/sharedTree.ts +5 -133
- package/src/simple-tree/api/index.ts +2 -22
- package/src/simple-tree/api/schemaFactory.ts +40 -54
- package/src/simple-tree/api/schemaFactoryAlpha.ts +9 -14
- package/src/simple-tree/api/schemaFactoryRecursive.ts +25 -5
- package/src/simple-tree/api/tree.ts +1 -14
- package/src/simple-tree/api/typesUnsafe.ts +359 -341
- package/src/simple-tree/arrayNode.ts +2 -2
- package/src/simple-tree/core/treeNodeKernel.ts +46 -28
- package/src/simple-tree/core/types.ts +14 -4
- package/src/simple-tree/core/unhydratedFlexTree.ts +5 -1
- package/src/simple-tree/index.ts +2 -22
- package/src/simple-tree/objectNode.ts +13 -4
- package/src/simple-tree/schemaTypes.ts +11 -7
- package/src/tableSchema.ts +190 -63
- package/src/treeFactory.ts +151 -8
package/src/tableSchema.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
TreeArrayNode,
|
|
18
18
|
type TreeNode,
|
|
19
19
|
type TreeNodeFromImplicitAllowedTypes,
|
|
20
|
+
type TreeNodeSchema,
|
|
20
21
|
type TreeNodeSchemaClass,
|
|
21
22
|
type WithType,
|
|
22
23
|
} from "./simple-tree/index.js";
|
|
@@ -42,22 +43,34 @@ export namespace TableSchema {
|
|
|
42
43
|
* @remarks Implemented by the schema class returned from {@link TableSchema.createColumn}.
|
|
43
44
|
* @sealed @internal
|
|
44
45
|
*/
|
|
45
|
-
export interface IColumn {
|
|
46
|
+
export interface IColumn<TPropsSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes> {
|
|
46
47
|
/**
|
|
47
48
|
* The unique identifier of the column.
|
|
48
49
|
* @remarks Uniquely identifies the node within the entire tree, not just the table.
|
|
49
50
|
*/
|
|
50
51
|
readonly id: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* User-provided column properties.
|
|
55
|
+
*/
|
|
56
|
+
get props(): TreeNodeFromImplicitAllowedTypes<TPropsSchema>;
|
|
57
|
+
set props(value: InsertableTreeNodeFromImplicitAllowedTypes<TPropsSchema>);
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
/**
|
|
54
61
|
* Factory for creating new table column schema.
|
|
62
|
+
* @privateRemarks
|
|
63
|
+
* TODO:
|
|
64
|
+
* - Add overloads to make propsSchema optional.
|
|
65
|
+
* - Take field schema rather than node schema for `propsSchema`, in particular to allow making
|
|
66
|
+
* the additional properties optional.
|
|
55
67
|
* @internal
|
|
56
68
|
*/
|
|
57
69
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
58
|
-
export function createColumn<
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
export function createColumn<
|
|
71
|
+
const TInputScope extends string | undefined,
|
|
72
|
+
const TPropsSchema extends ImplicitAllowedTypes,
|
|
73
|
+
>(inputSchemaFactory: SchemaFactoryAlpha<TInputScope>, propsSchema: TPropsSchema) {
|
|
61
74
|
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
62
75
|
type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
|
|
63
76
|
|
|
@@ -65,17 +78,24 @@ export namespace TableSchema {
|
|
|
65
78
|
* {@link Column} fields.
|
|
66
79
|
* @remarks Extracted for re-use in returned type signature defined later in this function.
|
|
67
80
|
* The implicit typing is intentional.
|
|
81
|
+
* Note: ideally we would add a satisfies clause here to ensure that this satisfies
|
|
82
|
+
* `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.
|
|
83
|
+
* Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
|
|
68
84
|
*/
|
|
69
85
|
const columnFields = {
|
|
70
86
|
id: schemaFactory.identifier,
|
|
71
|
-
|
|
87
|
+
props: schemaFactory.required(propsSchema),
|
|
88
|
+
} as const;
|
|
72
89
|
|
|
73
90
|
/**
|
|
74
91
|
* A column in a table.
|
|
75
92
|
*/
|
|
76
|
-
class Column extends schemaFactory.object("Column", columnFields)
|
|
93
|
+
class Column extends schemaFactory.object("Column", columnFields) {}
|
|
94
|
+
|
|
95
|
+
type ColumnValueType = TreeNode &
|
|
96
|
+
IColumn<TPropsSchema> &
|
|
97
|
+
WithType<ScopedSchemaName<Scope, "Column">>;
|
|
77
98
|
|
|
78
|
-
type ColumnValueType = TreeNode & IColumn & WithType<ScopedSchemaName<Scope, "Column">>;
|
|
79
99
|
type ColumnInsertableType = InsertableObjectFromSchemaRecord<typeof columnFields>;
|
|
80
100
|
|
|
81
101
|
// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
|
|
@@ -99,9 +119,10 @@ export namespace TableSchema {
|
|
|
99
119
|
* Base column schema type.
|
|
100
120
|
* @sealed @system @internal
|
|
101
121
|
*/
|
|
102
|
-
export type ColumnSchemaBase<
|
|
103
|
-
|
|
104
|
-
|
|
122
|
+
export type ColumnSchemaBase<
|
|
123
|
+
TScope extends string | undefined,
|
|
124
|
+
TPropsSchema extends ImplicitAllowedTypes,
|
|
125
|
+
> = ReturnType<typeof createColumn<TScope, TPropsSchema>>;
|
|
105
126
|
|
|
106
127
|
// #endregion
|
|
107
128
|
|
|
@@ -114,7 +135,7 @@ export namespace TableSchema {
|
|
|
114
135
|
*/
|
|
115
136
|
export interface IRow<
|
|
116
137
|
TCellSchema extends ImplicitAllowedTypes,
|
|
117
|
-
|
|
138
|
+
TPropsSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
118
139
|
> {
|
|
119
140
|
/**
|
|
120
141
|
* The unique identifier of the row.
|
|
@@ -123,45 +144,71 @@ export namespace TableSchema {
|
|
|
123
144
|
readonly id: string;
|
|
124
145
|
|
|
125
146
|
/**
|
|
126
|
-
* Gets the cell in the specified column
|
|
147
|
+
* Gets the cell in the specified column.
|
|
127
148
|
* @returns The cell if it exists, otherwise undefined.
|
|
128
|
-
* @privateRemarks TODO: add overload that takes column ID.
|
|
129
149
|
*/
|
|
130
|
-
getCell(
|
|
131
|
-
|
|
132
|
-
|
|
150
|
+
getCell(column: IColumn): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Gets the cell in the specified column, denoted by column ID.
|
|
153
|
+
* @returns The cell if it exists, otherwise undefined.
|
|
154
|
+
*/
|
|
155
|
+
getCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;
|
|
133
156
|
|
|
134
157
|
/**
|
|
135
158
|
* Sets the cell in the specified column.
|
|
136
|
-
* @remarks To
|
|
137
|
-
|
|
159
|
+
* @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:1)} instead.
|
|
160
|
+
*/
|
|
161
|
+
setCell(
|
|
162
|
+
column: IColumn,
|
|
163
|
+
value: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,
|
|
164
|
+
): void;
|
|
165
|
+
/**
|
|
166
|
+
* Sets the cell in the specified column, denoted by column ID.
|
|
167
|
+
* @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:2)} instead.
|
|
138
168
|
*/
|
|
139
169
|
setCell(
|
|
140
|
-
|
|
170
|
+
columnId: string,
|
|
141
171
|
value: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,
|
|
142
172
|
): void;
|
|
143
173
|
|
|
144
174
|
/**
|
|
145
|
-
*
|
|
146
|
-
* @privateRemarks TODO:
|
|
175
|
+
* Removes the cell in the specified column.
|
|
176
|
+
* @privateRemarks TODO: return removed cell
|
|
147
177
|
*/
|
|
148
|
-
|
|
178
|
+
removeCell(column: IColumn): void;
|
|
179
|
+
/**
|
|
180
|
+
* Removes the cell in the specified column, denoted by column ID.
|
|
181
|
+
* @privateRemarks TODO: return removed cell
|
|
182
|
+
*/
|
|
183
|
+
removeCell(columnId: string): void;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* User-provided row properties.
|
|
187
|
+
*/
|
|
188
|
+
get props(): TreeNodeFromImplicitAllowedTypes<TPropsSchema>;
|
|
189
|
+
set props(value: InsertableTreeNodeFromImplicitAllowedTypes<TPropsSchema>);
|
|
149
190
|
}
|
|
150
191
|
|
|
151
192
|
/**
|
|
152
193
|
* Factory for creating new table row schema.
|
|
153
|
-
*
|
|
194
|
+
*
|
|
195
|
+
* @privateRemarks
|
|
196
|
+
* TODO:
|
|
197
|
+
* - Add overloads to make propsSchema optional.
|
|
198
|
+
* - Take field schema rather than node schema for `propsSchema`, in particular to allow making
|
|
199
|
+
* the additional properties optional.
|
|
200
|
+
*
|
|
154
201
|
* @sealed @internal
|
|
155
202
|
*/
|
|
156
203
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
157
204
|
export function createRow<
|
|
158
205
|
const TInputScope extends string | undefined,
|
|
159
206
|
const TCellSchema extends ImplicitAllowedTypes,
|
|
160
|
-
const
|
|
207
|
+
const TPropsSchema extends ImplicitAllowedTypes,
|
|
161
208
|
>(
|
|
162
209
|
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
163
210
|
cellSchema: TCellSchema,
|
|
164
|
-
|
|
211
|
+
propsSchema: TPropsSchema,
|
|
165
212
|
) {
|
|
166
213
|
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
167
214
|
type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
|
|
@@ -169,41 +216,51 @@ export namespace TableSchema {
|
|
|
169
216
|
type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
170
217
|
type CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
171
218
|
|
|
172
|
-
type ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumnSchema>;
|
|
173
|
-
|
|
174
219
|
/**
|
|
175
220
|
* {@link Row} fields.
|
|
176
221
|
* @remarks Extracted for re-use in returned type signature defined later in this function.
|
|
177
222
|
* The implicit typing is intentional.
|
|
223
|
+
* Note: ideally we would add a satisfies clause here to ensure that this satisfies
|
|
224
|
+
* `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.
|
|
225
|
+
* Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
|
|
178
226
|
*/
|
|
179
227
|
const rowFields = {
|
|
180
228
|
id: schemaFactory.identifier,
|
|
181
229
|
cells: schemaFactory.map("Row.cells", cellSchema),
|
|
182
|
-
|
|
230
|
+
props: schemaFactory.required(propsSchema),
|
|
231
|
+
} as const;
|
|
183
232
|
|
|
184
233
|
/**
|
|
185
234
|
* The Row schema - this is a map of Cells where the key is the column id
|
|
186
235
|
*/
|
|
187
236
|
class Row
|
|
188
237
|
extends schemaFactory.object("Row", rowFields)
|
|
189
|
-
implements IRow<TCellSchema,
|
|
238
|
+
implements IRow<TCellSchema, TPropsSchema>
|
|
190
239
|
{
|
|
191
|
-
public getCell(
|
|
192
|
-
|
|
240
|
+
public getCell(columnOrId: IColumn | string): CellValueType | undefined {
|
|
241
|
+
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
242
|
+
return this.cells.get(columnId) as CellValueType | undefined;
|
|
193
243
|
}
|
|
194
244
|
|
|
195
|
-
public setCell(
|
|
196
|
-
|
|
245
|
+
public setCell(
|
|
246
|
+
columnOrId: IColumn | string,
|
|
247
|
+
value: CellInsertableType | undefined,
|
|
248
|
+
): void {
|
|
249
|
+
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
250
|
+
this.cells.set(columnId, value);
|
|
197
251
|
}
|
|
198
252
|
|
|
199
|
-
public
|
|
200
|
-
|
|
201
|
-
this.cells.
|
|
253
|
+
public removeCell(columnOrId: IColumn | string): void {
|
|
254
|
+
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
255
|
+
if (!this.cells.has(columnId)) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
this.cells.delete(columnId);
|
|
202
259
|
}
|
|
203
260
|
}
|
|
204
261
|
|
|
205
262
|
type RowValueType = TreeNode &
|
|
206
|
-
IRow<TCellSchema,
|
|
263
|
+
IRow<TCellSchema, TPropsSchema> &
|
|
207
264
|
WithType<ScopedSchemaName<Scope, "Row">>;
|
|
208
265
|
type RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFields>;
|
|
209
266
|
|
|
@@ -231,8 +288,8 @@ export namespace TableSchema {
|
|
|
231
288
|
export type RowSchemaBase<
|
|
232
289
|
TScope extends string | undefined,
|
|
233
290
|
TCellSchema extends ImplicitAllowedTypes,
|
|
234
|
-
|
|
235
|
-
> = ReturnType<typeof createRow<TScope, TCellSchema,
|
|
291
|
+
TPropsSchema extends ImplicitAllowedTypes,
|
|
292
|
+
> = ReturnType<typeof createRow<TScope, TCellSchema, TPropsSchema>>;
|
|
236
293
|
|
|
237
294
|
// #endregion
|
|
238
295
|
|
|
@@ -360,7 +417,7 @@ export namespace TableSchema {
|
|
|
360
417
|
|
|
361
418
|
/**
|
|
362
419
|
* Sets the cell at the specified location in the table.
|
|
363
|
-
* @remarks To
|
|
420
|
+
* @remarks To remove a cell, call {@link TableSchema.ITable.removeCell} instead.
|
|
364
421
|
* @privateRemarks TODO: add overload that takes column/row nodes?
|
|
365
422
|
*/
|
|
366
423
|
setCell(
|
|
@@ -378,37 +435,100 @@ export namespace TableSchema {
|
|
|
378
435
|
removeColumn: (column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>) => void;
|
|
379
436
|
|
|
380
437
|
/**
|
|
381
|
-
*
|
|
438
|
+
* Removes 0 or more rows from the table.
|
|
382
439
|
* @privateRemarks TODO: policy for when 1 or more rows are not in the table.
|
|
383
440
|
*/
|
|
384
|
-
|
|
441
|
+
removeRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRowSchema>[]) => void;
|
|
385
442
|
|
|
386
443
|
/**
|
|
387
|
-
*
|
|
444
|
+
* Removes all rows from the table.
|
|
388
445
|
*/
|
|
389
|
-
|
|
446
|
+
removeAllRows: () => void;
|
|
390
447
|
|
|
391
448
|
/**
|
|
392
|
-
*
|
|
449
|
+
* Removes the cell at the specified location in the table.
|
|
393
450
|
* @privateRemarks TODO: add overload that takes column/row nodes?
|
|
394
451
|
*/
|
|
395
|
-
|
|
452
|
+
removeCell: (key: CellKey) => void;
|
|
396
453
|
}
|
|
397
454
|
|
|
455
|
+
/**
|
|
456
|
+
* Factory for creating new table schema without specifying row or column schema.
|
|
457
|
+
* @internal
|
|
458
|
+
*/
|
|
459
|
+
export function createTable<
|
|
460
|
+
const TInputScope extends string | undefined,
|
|
461
|
+
const TCell extends ImplicitAllowedTypes,
|
|
462
|
+
>(
|
|
463
|
+
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
464
|
+
_cellSchema: TCell,
|
|
465
|
+
): ReturnType<typeof createTableInternal<TInputScope, TCell>>;
|
|
466
|
+
/**
|
|
467
|
+
* Factory for creating new table schema without specifying row schema
|
|
468
|
+
* @internal
|
|
469
|
+
*/
|
|
470
|
+
export function createTable<
|
|
471
|
+
const TInputScope extends string | undefined,
|
|
472
|
+
const TCell extends ImplicitAllowedTypes,
|
|
473
|
+
const TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
|
|
474
|
+
>(
|
|
475
|
+
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
476
|
+
_cellSchema: TCell,
|
|
477
|
+
columnSchema: TColumn,
|
|
478
|
+
): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn>>;
|
|
398
479
|
/**
|
|
399
480
|
* Factory for creating new table schema.
|
|
400
|
-
* @privateRemarks TODO: add overloads to make column/row schema optional.
|
|
401
481
|
* @internal
|
|
402
482
|
*/
|
|
403
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
404
483
|
export function createTable<
|
|
405
484
|
const TInputScope extends string | undefined,
|
|
406
485
|
const TCell extends ImplicitAllowedTypes,
|
|
407
|
-
const TColumn extends ColumnSchemaBase<TInputScope
|
|
408
|
-
const TRow extends RowSchemaBase<TInputScope, TCell,
|
|
486
|
+
const TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
|
|
487
|
+
const TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes>,
|
|
488
|
+
>(
|
|
489
|
+
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
490
|
+
_cellSchema: TCell,
|
|
491
|
+
columnSchema: TColumn,
|
|
492
|
+
rowSchema: TRow,
|
|
493
|
+
): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn, TRow>>;
|
|
494
|
+
/** `createTable` implementation */
|
|
495
|
+
export function createTable<
|
|
496
|
+
const TInputScope extends string | undefined,
|
|
497
|
+
const TCell extends ImplicitAllowedTypes,
|
|
498
|
+
const TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
|
|
499
|
+
const TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes>,
|
|
500
|
+
>(
|
|
501
|
+
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
502
|
+
_cellSchema: TCell,
|
|
503
|
+
columnSchema?: TColumn,
|
|
504
|
+
rowSchema?: TRow,
|
|
505
|
+
): TreeNodeSchema {
|
|
506
|
+
const column = columnSchema ?? createColumn(inputSchemaFactory, inputSchemaFactory.null);
|
|
507
|
+
return createTableInternal(
|
|
508
|
+
inputSchemaFactory,
|
|
509
|
+
_cellSchema,
|
|
510
|
+
column as TColumn,
|
|
511
|
+
rowSchema ??
|
|
512
|
+
(createRow(inputSchemaFactory, _cellSchema, inputSchemaFactory.null) as TRow),
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Factory for creating new table schema.
|
|
518
|
+
* @system @internal
|
|
519
|
+
*/
|
|
520
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
521
|
+
export function createTableInternal<
|
|
522
|
+
const TInputScope extends string | undefined,
|
|
523
|
+
const TCell extends ImplicitAllowedTypes,
|
|
524
|
+
const TColumn extends ColumnSchemaBase<
|
|
525
|
+
TInputScope,
|
|
526
|
+
ImplicitAllowedTypes
|
|
527
|
+
> = ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
|
|
528
|
+
const TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes> = RowSchemaBase<
|
|
409
529
|
TInputScope,
|
|
410
530
|
TCell,
|
|
411
|
-
|
|
531
|
+
ImplicitAllowedTypes
|
|
412
532
|
>,
|
|
413
533
|
>(
|
|
414
534
|
inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
|
|
@@ -467,7 +587,7 @@ export namespace TableSchema {
|
|
|
467
587
|
if (row !== undefined) {
|
|
468
588
|
const column = this.getColumn(columnId);
|
|
469
589
|
if (column !== undefined) {
|
|
470
|
-
return row.getCell(column);
|
|
590
|
+
return row.getCell(column.id);
|
|
471
591
|
}
|
|
472
592
|
}
|
|
473
593
|
// If the cell does not exist return undefined
|
|
@@ -520,7 +640,7 @@ export namespace TableSchema {
|
|
|
520
640
|
if (row !== undefined) {
|
|
521
641
|
const column = this.getColumn(columnId);
|
|
522
642
|
if (column !== undefined) {
|
|
523
|
-
row.setCell(column, cell);
|
|
643
|
+
row.setCell(column.id, cell);
|
|
524
644
|
}
|
|
525
645
|
}
|
|
526
646
|
}
|
|
@@ -532,22 +652,22 @@ export namespace TableSchema {
|
|
|
532
652
|
this.columns.removeAt(index);
|
|
533
653
|
}
|
|
534
654
|
|
|
535
|
-
public
|
|
536
|
-
// If there are no rows to
|
|
655
|
+
public removeRows(rows: readonly RowValueType[]): void {
|
|
656
|
+
// If there are no rows to remove, do nothing
|
|
537
657
|
if (rows.length === 0) {
|
|
538
658
|
return;
|
|
539
659
|
}
|
|
540
660
|
|
|
541
|
-
// If there is only one row to
|
|
661
|
+
// If there is only one row to remove, remove it
|
|
542
662
|
if (rows.length === 1) {
|
|
543
663
|
const index = this.rows.indexOf(rows[0] ?? oob());
|
|
544
664
|
this.rows.removeAt(index);
|
|
545
665
|
return;
|
|
546
666
|
}
|
|
547
|
-
// If there are multiple rows to
|
|
667
|
+
// If there are multiple rows to remove, remove them in a transaction
|
|
548
668
|
// This is to avoid the performance issues of deleting multiple rows at once
|
|
549
669
|
Tree.runTransaction(this, () => {
|
|
550
|
-
// Iterate over the rows and
|
|
670
|
+
// Iterate over the rows and remove them
|
|
551
671
|
for (const row of rows) {
|
|
552
672
|
const index = this.rows.indexOf(row);
|
|
553
673
|
this.rows.removeAt(index);
|
|
@@ -555,17 +675,17 @@ export namespace TableSchema {
|
|
|
555
675
|
});
|
|
556
676
|
}
|
|
557
677
|
|
|
558
|
-
public
|
|
678
|
+
public removeAllRows(): void {
|
|
559
679
|
this.rows.removeRange();
|
|
560
680
|
}
|
|
561
681
|
|
|
562
|
-
public
|
|
682
|
+
public removeCell(key: CellKey): void {
|
|
563
683
|
const { columnId, rowId } = key;
|
|
564
684
|
const row = this.getRow(rowId);
|
|
565
685
|
if (row !== undefined) {
|
|
566
686
|
const column = this.getColumn(columnId);
|
|
567
687
|
if (column !== undefined) {
|
|
568
|
-
row.
|
|
688
|
+
row.removeCell(column.id);
|
|
569
689
|
}
|
|
570
690
|
}
|
|
571
691
|
}
|
|
@@ -601,8 +721,15 @@ export namespace TableSchema {
|
|
|
601
721
|
export type TableSchemaBase<
|
|
602
722
|
TScope extends string | undefined,
|
|
603
723
|
TCell extends ImplicitAllowedTypes,
|
|
604
|
-
TColumn extends ColumnSchemaBase<TScope> = ColumnSchemaBase<
|
|
605
|
-
|
|
724
|
+
TColumn extends ColumnSchemaBase<TScope, ImplicitAllowedTypes> = ColumnSchemaBase<
|
|
725
|
+
TScope,
|
|
726
|
+
ImplicitAllowedTypes
|
|
727
|
+
>,
|
|
728
|
+
TRow extends RowSchemaBase<TScope, TCell, ImplicitAllowedTypes> = RowSchemaBase<
|
|
729
|
+
TScope,
|
|
730
|
+
TCell,
|
|
731
|
+
ImplicitAllowedTypes
|
|
732
|
+
>,
|
|
606
733
|
> = ReturnType<typeof createTable<TScope, TCell, TColumn, TRow>>;
|
|
607
734
|
|
|
608
735
|
// #endregion
|
package/src/treeFactory.ts
CHANGED
|
@@ -8,27 +8,170 @@ import type {
|
|
|
8
8
|
IChannelFactory,
|
|
9
9
|
IFluidDataStoreRuntime,
|
|
10
10
|
IChannelServices,
|
|
11
|
+
IChannelStorageService,
|
|
11
12
|
} from "@fluidframework/datastore-definitions/internal";
|
|
13
|
+
import type {
|
|
14
|
+
ITelemetryContext,
|
|
15
|
+
IExperimentalIncrementalSummaryContext,
|
|
16
|
+
ISummaryTreeWithStats,
|
|
17
|
+
IRuntimeMessageCollection,
|
|
18
|
+
} from "@fluidframework/runtime-definitions/internal";
|
|
19
|
+
|
|
20
|
+
import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
12
21
|
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
13
22
|
import {
|
|
23
|
+
type IFluidSerializer,
|
|
24
|
+
type ISharedObject,
|
|
14
25
|
type ISharedObjectKind,
|
|
26
|
+
SharedObject,
|
|
15
27
|
createSharedObjectKind,
|
|
16
28
|
} from "@fluidframework/shared-object-base/internal";
|
|
17
29
|
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
import type {
|
|
31
|
+
SchematizingSimpleTreeView,
|
|
32
|
+
SharedTreeContentSnapshot,
|
|
33
|
+
SharedTreeOptions,
|
|
34
|
+
SharedTreeOptionsInternal,
|
|
35
|
+
SharedTreeEditBuilder,
|
|
36
|
+
SharedTreeChange,
|
|
37
|
+
ITreePrivate,
|
|
23
38
|
} from "./shared-tree/index.js";
|
|
24
|
-
import type {
|
|
25
|
-
|
|
39
|
+
import type {
|
|
40
|
+
ImplicitFieldSchema,
|
|
41
|
+
ITree,
|
|
42
|
+
ReadSchema,
|
|
43
|
+
SimpleTreeSchema,
|
|
44
|
+
TreeView,
|
|
45
|
+
TreeViewConfiguration,
|
|
46
|
+
UnsafeUnknownSchema,
|
|
47
|
+
VerboseTree,
|
|
48
|
+
} from "./simple-tree/index.js";
|
|
26
49
|
import { SharedTreeFactoryType, SharedTreeAttributes } from "./sharedTreeAttributes.js";
|
|
50
|
+
import { Breakable } from "./util/index.js";
|
|
51
|
+
import { SharedTreeKernel } from "./shared-tree/index.js";
|
|
52
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
53
|
+
import { fail } from "@fluidframework/core-utils/internal";
|
|
54
|
+
import type { SharedTreeCore } from "./shared-tree-core/index.js";
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* {@link ITreePrivate} extended with ISharedObject.
|
|
58
|
+
* @remarks
|
|
59
|
+
* This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.
|
|
60
|
+
*/
|
|
61
|
+
export interface ISharedTree extends ISharedObject, ITreePrivate {}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Shared object wrapping {@link SharedTreeKernel}.
|
|
65
|
+
*/
|
|
66
|
+
class SharedTreeImpl extends SharedObject implements ISharedTree {
|
|
67
|
+
private readonly breaker: Breakable = new Breakable("Shared Tree");
|
|
68
|
+
|
|
69
|
+
public readonly kernel: SharedTreeKernel;
|
|
70
|
+
|
|
71
|
+
public constructor(
|
|
72
|
+
id: string,
|
|
73
|
+
runtime: IFluidDataStoreRuntime,
|
|
74
|
+
attributes: IChannelAttributes,
|
|
75
|
+
optionsParam: SharedTreeOptionsInternal,
|
|
76
|
+
telemetryContextPrefix: string = "fluid_sharedTree_",
|
|
77
|
+
) {
|
|
78
|
+
super(id, runtime, attributes, telemetryContextPrefix);
|
|
79
|
+
if (runtime.idCompressor === undefined) {
|
|
80
|
+
throw new UsageError("IdCompressor must be enabled to use SharedTree");
|
|
81
|
+
}
|
|
82
|
+
this.kernel = new SharedTreeKernel(
|
|
83
|
+
this.breaker,
|
|
84
|
+
this,
|
|
85
|
+
this.serializer,
|
|
86
|
+
(content, localOpMetadata) => this.submitLocalMessage(content, localOpMetadata),
|
|
87
|
+
() => this.deltaManager.lastSequenceNumber,
|
|
88
|
+
this.logger,
|
|
89
|
+
runtime.idCompressor,
|
|
90
|
+
optionsParam,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public summarizeCore(
|
|
95
|
+
serializer: IFluidSerializer,
|
|
96
|
+
telemetryContext?: ITelemetryContext,
|
|
97
|
+
incrementalSummaryContext?: IExperimentalIncrementalSummaryContext,
|
|
98
|
+
): ISummaryTreeWithStats {
|
|
99
|
+
return this.kernel.summarizeCore(serializer, telemetryContext, incrementalSummaryContext);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
protected processCore(
|
|
103
|
+
message: ISequencedDocumentMessage,
|
|
104
|
+
local: boolean,
|
|
105
|
+
localOpMetadata: unknown,
|
|
106
|
+
): void {
|
|
107
|
+
fail(0xb75 /* processCore should not be called on SharedTree */);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
protected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {
|
|
111
|
+
this.kernel.processMessagesCore(messagesCollection);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
protected onDisconnect(): void {
|
|
115
|
+
this.kernel.onDisconnect();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public exportVerbose(): VerboseTree | undefined {
|
|
119
|
+
return this.kernel.exportVerbose();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public exportSimpleSchema(): SimpleTreeSchema {
|
|
123
|
+
return this.kernel.exportSimpleSchema();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public contentSnapshot(): SharedTreeContentSnapshot {
|
|
127
|
+
return this.kernel.contentSnapshot();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// For the new TreeViewAlpha API
|
|
131
|
+
public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
132
|
+
config: TreeViewConfiguration<ReadSchema<TRoot>>,
|
|
133
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>>;
|
|
134
|
+
|
|
135
|
+
// For the old TreeView API
|
|
136
|
+
public viewWith<TRoot extends ImplicitFieldSchema>(
|
|
137
|
+
config: TreeViewConfiguration<TRoot>,
|
|
138
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<TRoot>;
|
|
139
|
+
|
|
140
|
+
public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
141
|
+
config: TreeViewConfiguration<ReadSchema<TRoot>>,
|
|
142
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>> {
|
|
143
|
+
return this.kernel.viewWith(config);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
protected override async loadCore(services: IChannelStorageService): Promise<void> {
|
|
147
|
+
await this.kernel.loadCore(services);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
protected override didAttach(): void {
|
|
151
|
+
this.kernel.didAttach();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
protected override applyStashedOp(
|
|
155
|
+
...args: Parameters<
|
|
156
|
+
SharedTreeCore<SharedTreeEditBuilder, SharedTreeChange>["applyStashedOp"]
|
|
157
|
+
>
|
|
158
|
+
): void {
|
|
159
|
+
this.kernel.applyStashedOp(...args);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
protected override reSubmitCore(
|
|
163
|
+
...args: Parameters<
|
|
164
|
+
SharedTreeCore<SharedTreeEditBuilder, SharedTreeChange>["reSubmitCore"]
|
|
165
|
+
>
|
|
166
|
+
): void {
|
|
167
|
+
this.kernel.reSubmitCore(...args);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
27
170
|
|
|
28
171
|
/**
|
|
29
172
|
* A channel factory that creates an {@link ITree}.
|
|
30
173
|
*/
|
|
31
|
-
|
|
174
|
+
class TreeFactory implements IChannelFactory<ISharedTree> {
|
|
32
175
|
public static Type: string = SharedTreeFactoryType;
|
|
33
176
|
public readonly type: string = SharedTreeFactoryType;
|
|
34
177
|
|