@fluidframework/tree 2.33.2 → 2.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +2 -0
- package/CHANGELOG.md +64 -0
- package/api-report/tree.alpha.api.md +124 -51
- package/api-report/tree.beta.api.md +31 -27
- package/api-report/tree.legacy.alpha.api.md +24 -23
- package/api-report/tree.legacy.public.api.md +24 -23
- package/api-report/tree.public.api.md +24 -23
- package/dist/alpha.d.ts +17 -1
- package/dist/beta.d.ts +2 -0
- package/dist/codec/codec.d.ts +5 -1
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +6 -2
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -1
- package/dist/codec/index.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
- package/dist/core/schema-stored/formatV1.d.ts.map +1 -0
- package/dist/core/schema-stored/{format.js → formatV1.js} +1 -1
- package/dist/core/schema-stored/formatV1.js.map +1 -0
- package/dist/core/schema-stored/index.d.ts +3 -3
- package/dist/core/schema-stored/index.d.ts.map +1 -1
- package/dist/core/schema-stored/index.js +3 -3
- package/dist/core/schema-stored/index.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +3 -1
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +8 -6
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
- package/dist/core/schema-view/index.d.ts +1 -1
- package/dist/core/schema-view/index.d.ts.map +1 -1
- package/dist/core/schema-view/index.js +1 -2
- package/dist/core/schema-view/index.js.map +1 -1
- package/dist/core/schema-view/view.d.ts +0 -27
- package/dist/core/schema-view/view.d.ts.map +1 -1
- package/dist/core/schema-view/view.js +1 -35
- package/dist/core/schema-view/view.js.map +1 -1
- package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
- package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
- package/dist/core/tree/persistedTreeTextFormat.js +1 -1
- package/dist/core/tree/persistedTreeTextFormat.js.map +1 -1
- package/dist/feature-libraries/forest-summary/format.d.ts +2 -2
- package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/format.js +1 -1
- package/dist/feature-libraries/forest-summary/format.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +4 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.d.ts +3 -3
- package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.js +2 -2
- package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -5
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +34 -5
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +63 -9
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/{lib/feature-libraries/schema-index/format.d.ts → dist/feature-libraries/schema-index/formatV1.d.ts} +9 -9
- package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
- package/dist/feature-libraries/schema-index/{format.js → formatV1.js} +4 -4
- package/dist/feature-libraries/schema-index/formatV1.js.map +1 -0
- package/dist/feature-libraries/schema-index/index.d.ts +2 -2
- package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/index.js +6 -3
- package/dist/feature-libraries/schema-index/index.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +4 -4
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +0 -1
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/jsonDomainSchema.d.ts +2 -2
- package/dist/jsonDomainSchema.js +2 -2
- package/dist/jsonDomainSchema.js.map +1 -1
- package/dist/legacy.d.ts +2 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +2 -0
- package/dist/serializableDomainSchema.d.ts +3 -3
- package/dist/serializableDomainSchema.js +2 -2
- package/dist/serializableDomainSchema.js.map +1 -1
- package/dist/shared-tree/independentView.d.ts +1 -1
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +1 -1
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +4 -3
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +6 -5
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +10 -11
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +11 -36
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +3 -3
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +4 -7
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +28 -3
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +29 -3
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/{treeApi.d.ts → tree.d.ts} +58 -34
- package/dist/shared-tree/tree.d.ts.map +1 -0
- package/dist/shared-tree/{treeApi.js → tree.js} +6 -6
- package/dist/shared-tree/tree.js.map +1 -0
- package/{lib/shared-tree/treeApiAlpha.d.ts → dist/shared-tree/treeAlpha.d.ts} +24 -14
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -0
- package/dist/shared-tree/{treeApiAlpha.js → treeAlpha.js} +7 -5
- package/dist/shared-tree/treeAlpha.js.map +1 -0
- package/dist/shared-tree-core/branchCommitEnricher.d.ts +0 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js +0 -1
- package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.d.ts +1 -1
- package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.js +4 -1
- package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts +1 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +177 -0
- package/dist/simple-tree/api/configuration.d.ts.map +1 -0
- package/dist/simple-tree/api/configuration.js +163 -0
- package/dist/simple-tree/api/configuration.js.map +1 -0
- package/dist/simple-tree/api/getJsonSchema.js +2 -2
- package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +9 -5
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +9 -7
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
- package/dist/simple-tree/api/{view.js → schemaCompatibilityTester.js} +9 -9
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
- package/dist/simple-tree/api/schemaFactory.d.ts +25 -10
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +27 -12
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +2 -2
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.d.ts +1 -1
- package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +11 -10
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +16 -11
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +30 -174
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +1 -156
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/{lib/simple-tree/api/treeApiBeta.d.ts → dist/simple-tree/api/treeBeta.d.ts} +17 -6
- package/dist/simple-tree/api/treeBeta.d.ts.map +1 -0
- package/dist/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
- package/dist/simple-tree/api/treeBeta.js.map +1 -0
- package/dist/simple-tree/api/treeChangeEvents.d.ts +83 -0
- package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
- package/dist/simple-tree/api/treeChangeEvents.js +7 -0
- package/dist/simple-tree/api/treeChangeEvents.js.map +1 -0
- package/dist/simple-tree/api/treeNodeApi.d.ts +2 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +4 -9
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +30 -2
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +3 -2
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/arrayNodeTypes.d.ts +3 -3
- package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/arrayNodeTypes.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +2 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +5 -5
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNode.d.ts +94 -0
- package/dist/simple-tree/core/treeNode.d.ts.map +1 -0
- package/dist/simple-tree/core/treeNode.js +123 -0
- package/dist/simple-tree/core/treeNode.js.map +1 -0
- package/dist/simple-tree/core/treeNodeKernel.d.ts +2 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +3 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/types.d.ts +0 -165
- package/dist/simple-tree/core/types.d.ts.map +1 -1
- package/dist/simple-tree/core/types.js +1 -113
- package/dist/simple-tree/core/types.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +1 -1
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js.map +1 -1
- package/dist/simple-tree/index.d.ts +4 -4
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +4 -3
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts +2 -2
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +1 -1
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/mapNodeTypes.d.ts +3 -3
- package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/mapNodeTypes.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +18 -5
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +4 -3
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/objectNodeTypes.d.ts +4 -4
- package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/objectNodeTypes.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +164 -13
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +107 -8
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts +8 -8
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +27 -32
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +2 -2
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/tableSchema.d.ts +455 -125
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +398 -101
- package/dist/tableSchema.js.map +1 -1
- package/dist/treeFactory.d.ts +1 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +30 -75
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/typeUtils.d.ts +1 -1
- package/dist/util/typeUtils.js.map +1 -1
- package/lib/alpha.d.ts +17 -1
- package/lib/beta.d.ts +2 -0
- package/lib/codec/codec.d.ts +5 -1
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +5 -1
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -2
- package/lib/core/index.js.map +1 -1
- package/lib/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
- package/lib/core/schema-stored/formatV1.d.ts.map +1 -0
- package/lib/core/schema-stored/{format.js → formatV1.js} +1 -1
- package/lib/core/schema-stored/formatV1.js.map +1 -0
- package/lib/core/schema-stored/index.d.ts +3 -3
- package/lib/core/schema-stored/index.d.ts.map +1 -1
- package/lib/core/schema-stored/index.js +2 -2
- package/lib/core/schema-stored/index.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +3 -1
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +3 -1
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.d.ts +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
- package/lib/core/schema-view/index.d.ts +1 -1
- package/lib/core/schema-view/index.d.ts.map +1 -1
- package/lib/core/schema-view/index.js +1 -1
- package/lib/core/schema-view/index.js.map +1 -1
- package/lib/core/schema-view/view.d.ts +0 -27
- package/lib/core/schema-view/view.d.ts.map +1 -1
- package/lib/core/schema-view/view.js +0 -34
- package/lib/core/schema-view/view.js.map +1 -1
- package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
- package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
- package/lib/core/tree/persistedTreeTextFormat.js +2 -2
- package/lib/core/tree/persistedTreeTextFormat.js.map +1 -1
- package/lib/feature-libraries/forest-summary/format.d.ts +2 -2
- package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/format.js +2 -2
- package/lib/feature-libraries/forest-summary/format.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.d.ts +3 -3
- package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.js +2 -2
- package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js +3 -3
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -6
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts +34 -5
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +61 -9
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/{dist/feature-libraries/schema-index/format.d.ts → lib/feature-libraries/schema-index/formatV1.d.ts} +9 -9
- package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
- package/lib/feature-libraries/schema-index/{format.js → formatV1.js} +5 -5
- package/lib/feature-libraries/schema-index/formatV1.js.map +1 -0
- package/lib/feature-libraries/schema-index/index.d.ts +2 -2
- package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/index.js +2 -2
- package/lib/feature-libraries/schema-index/index.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +5 -5
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +0 -1
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/jsonDomainSchema.d.ts +2 -2
- package/lib/jsonDomainSchema.js +2 -2
- package/lib/jsonDomainSchema.js.map +1 -1
- package/lib/legacy.d.ts +2 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +2 -0
- package/lib/serializableDomainSchema.d.ts +3 -3
- package/lib/serializableDomainSchema.js +2 -2
- package/lib/serializableDomainSchema.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts +1 -1
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +2 -2
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +4 -3
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +3 -3
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +10 -11
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +12 -37
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +3 -3
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +6 -9
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +28 -3
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +29 -4
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/{treeApi.d.ts → tree.d.ts} +58 -34
- package/lib/shared-tree/tree.d.ts.map +1 -0
- package/lib/shared-tree/{treeApi.js → tree.js} +5 -5
- package/lib/shared-tree/tree.js.map +1 -0
- package/{dist/shared-tree/treeApiAlpha.d.ts → lib/shared-tree/treeAlpha.d.ts} +24 -14
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -0
- package/lib/shared-tree/{treeApiAlpha.js → treeAlpha.js} +8 -6
- package/lib/shared-tree/treeAlpha.js.map +1 -0
- package/lib/shared-tree-core/branchCommitEnricher.d.ts +0 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.js +0 -1
- package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.d.ts +1 -1
- package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.js +4 -1
- package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts +1 -1
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +177 -0
- package/lib/simple-tree/api/configuration.d.ts.map +1 -0
- package/lib/simple-tree/api/configuration.js +157 -0
- package/lib/simple-tree/api/configuration.js.map +1 -0
- package/lib/simple-tree/api/getJsonSchema.js +1 -1
- package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +9 -5
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +5 -4
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
- package/lib/simple-tree/api/{view.js → schemaCompatibilityTester.js} +7 -7
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
- package/lib/simple-tree/api/schemaFactory.d.ts +25 -10
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +27 -12
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +2 -2
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.d.ts +1 -1
- package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +11 -10
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +20 -13
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +30 -174
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +0 -152
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/{dist/simple-tree/api/treeApiBeta.d.ts → lib/simple-tree/api/treeBeta.d.ts} +17 -6
- package/lib/simple-tree/api/treeBeta.d.ts.map +1 -0
- package/lib/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
- package/lib/simple-tree/api/treeBeta.js.map +1 -0
- package/lib/simple-tree/api/treeChangeEvents.d.ts +83 -0
- package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
- package/lib/simple-tree/api/treeChangeEvents.js +6 -0
- package/lib/simple-tree/api/treeChangeEvents.js.map +1 -0
- package/lib/simple-tree/api/treeNodeApi.d.ts +2 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +4 -9
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +30 -2
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +4 -3
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/arrayNodeTypes.d.ts +3 -3
- package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/arrayNodeTypes.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +2 -1
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +1 -1
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNode.d.ts +94 -0
- package/lib/simple-tree/core/treeNode.d.ts.map +1 -0
- package/lib/simple-tree/core/treeNode.js +118 -0
- package/lib/simple-tree/core/treeNode.js.map +1 -0
- package/lib/simple-tree/core/treeNodeKernel.d.ts +2 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +3 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/types.d.ts +0 -165
- package/lib/simple-tree/core/types.d.ts.map +1 -1
- package/lib/simple-tree/core/types.js +0 -110
- package/lib/simple-tree/core/types.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +1 -1
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/index.d.ts +4 -4
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts +2 -2
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +2 -2
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/mapNodeTypes.d.ts +3 -3
- package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/mapNodeTypes.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +18 -5
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +5 -4
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/objectNodeTypes.d.ts +4 -4
- package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/objectNodeTypes.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +164 -13
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +96 -8
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts +8 -8
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +26 -31
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +2 -2
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/tableSchema.d.ts +455 -125
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +398 -101
- package/lib/tableSchema.js.map +1 -1
- package/lib/treeFactory.d.ts +1 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +30 -75
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/typeUtils.d.ts +1 -1
- package/lib/util/typeUtils.js.map +1 -1
- package/package.json +21 -21
- package/src/codec/codec.ts +6 -1
- package/src/codec/index.ts +1 -0
- package/src/core/index.ts +1 -2
- package/src/core/schema-stored/index.ts +3 -3
- package/src/core/schema-stored/schema.ts +3 -1
- package/src/core/schema-stored/storedSchemaRepository.ts +1 -1
- package/src/core/schema-view/index.ts +0 -1
- package/src/core/schema-view/view.ts +0 -31
- package/src/core/tree/persistedTreeTextFormat.ts +2 -2
- package/src/feature-libraries/forest-summary/format.ts +2 -2
- package/src/feature-libraries/index.ts +7 -1
- package/src/feature-libraries/mapTreeCursor.ts +3 -3
- package/src/feature-libraries/modular-schema/modularChangeFormat.ts +3 -3
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +38 -9
- package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -4
- package/src/feature-libraries/schema-index/codec.ts +80 -12
- package/src/feature-libraries/schema-index/{format.ts → formatV1.ts} +4 -4
- package/src/feature-libraries/schema-index/index.ts +7 -2
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +9 -9
- package/src/index.ts +18 -1
- package/src/internalTypes.ts +0 -2
- package/src/jsonDomainSchema.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/src/serializableDomainSchema.ts +3 -3
- package/src/shared-tree/independentView.ts +4 -3
- package/src/shared-tree/index.ts +5 -6
- package/src/shared-tree/schematizeTree.ts +10 -40
- package/src/shared-tree/schematizingTreeView.ts +12 -17
- package/src/shared-tree/sharedTree.ts +67 -6
- package/src/shared-tree/{treeApi.ts → tree.ts} +75 -51
- package/src/shared-tree/{treeApiAlpha.ts → treeAlpha.ts} +28 -16
- package/src/shared-tree-core/branchCommitEnricher.ts +0 -1
- package/src/shared-tree-core/transactionEnricher.ts +4 -1
- package/src/simple-tree/api/conciseTree.ts +1 -1
- package/src/simple-tree/api/configuration.ts +353 -0
- package/src/simple-tree/api/getJsonSchema.ts +1 -1
- package/src/simple-tree/api/index.ts +23 -15
- package/src/simple-tree/api/{view.ts → schemaCompatibilityTester.ts} +8 -15
- package/src/simple-tree/api/schemaFactory.ts +139 -19
- package/src/simple-tree/api/schemaFactoryAlpha.ts +7 -5
- package/src/simple-tree/api/schemaFactoryRecursive.ts +102 -38
- package/src/simple-tree/api/schemaFromSimple.ts +2 -2
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
- package/src/simple-tree/api/storedSchema.ts +32 -17
- package/src/simple-tree/api/tree.ts +38 -354
- package/src/simple-tree/api/{treeApiBeta.ts → treeBeta.ts} +20 -6
- package/src/simple-tree/api/treeChangeEvents.ts +84 -0
- package/src/simple-tree/api/treeNodeApi.ts +1 -1
- package/src/simple-tree/api/typesUnsafe.ts +15 -11
- package/src/simple-tree/arrayNode.ts +38 -5
- package/src/simple-tree/arrayNodeTypes.ts +8 -7
- package/src/simple-tree/core/getOrCreateNode.ts +1 -1
- package/src/simple-tree/core/index.ts +5 -4
- package/src/simple-tree/core/treeNode.ts +163 -0
- package/src/simple-tree/core/treeNodeKernel.ts +2 -1
- package/src/simple-tree/core/treeNodeSchema.ts +3 -1
- package/src/simple-tree/core/types.ts +0 -234
- package/src/simple-tree/core/withType.ts +1 -1
- package/src/simple-tree/index.ts +19 -2
- package/src/simple-tree/mapNode.ts +11 -3
- package/src/simple-tree/mapNodeTypes.ts +10 -7
- package/src/simple-tree/objectNode.ts +39 -15
- package/src/simple-tree/objectNodeTypes.ts +9 -5
- package/src/simple-tree/schemaTypes.ts +354 -25
- package/src/simple-tree/toStoredSchema.ts +42 -41
- package/src/simple-tree/treeNodeValid.ts +2 -2
- package/src/tableSchema.ts +1206 -434
- package/src/treeFactory.ts +56 -173
- package/src/util/typeUtils.ts +1 -1
- package/dist/core/schema-stored/format.d.ts.map +0 -1
- package/dist/core/schema-stored/format.js.map +0 -1
- package/dist/feature-libraries/schema-index/format.d.ts.map +0 -1
- package/dist/feature-libraries/schema-index/format.js.map +0 -1
- package/dist/shared-tree/treeApi.d.ts.map +0 -1
- package/dist/shared-tree/treeApi.js.map +0 -1
- package/dist/shared-tree/treeApiAlpha.d.ts.map +0 -1
- package/dist/shared-tree/treeApiAlpha.js.map +0 -1
- package/dist/simple-tree/api/treeApiBeta.d.ts.map +0 -1
- package/dist/simple-tree/api/treeApiBeta.js.map +0 -1
- package/dist/simple-tree/api/view.d.ts.map +0 -1
- package/dist/simple-tree/api/view.js.map +0 -1
- package/lib/core/schema-stored/format.d.ts.map +0 -1
- package/lib/core/schema-stored/format.js.map +0 -1
- package/lib/feature-libraries/schema-index/format.d.ts.map +0 -1
- package/lib/feature-libraries/schema-index/format.js.map +0 -1
- package/lib/shared-tree/treeApi.d.ts.map +0 -1
- package/lib/shared-tree/treeApi.js.map +0 -1
- package/lib/shared-tree/treeApiAlpha.d.ts.map +0 -1
- package/lib/shared-tree/treeApiAlpha.js.map +0 -1
- package/lib/simple-tree/api/treeApiBeta.d.ts.map +0 -1
- package/lib/simple-tree/api/treeApiBeta.js.map +0 -1
- package/lib/simple-tree/api/view.d.ts.map +0 -1
- package/lib/simple-tree/api/view.js.map +0 -1
- /package/src/core/schema-stored/{format.ts → formatV1.ts} +0 -0
package/lib/tableSchema.js
CHANGED
|
@@ -3,49 +3,69 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { oob } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
6
7
|
import { Tree } from "./shared-tree/index.js";
|
|
7
|
-
import { TreeArrayNode, } from "./simple-tree/index.js";
|
|
8
|
-
// Future improvement TODOs
|
|
9
|
-
// -
|
|
10
|
-
// - Overloads to make Column/Row schema optional when constructing Tables
|
|
8
|
+
import { TreeArrayNode, SchemaFactory, } from "./simple-tree/index.js";
|
|
9
|
+
// Future improvement TODOs:
|
|
10
|
+
// - Omit `cells` property from Row insertion type.
|
|
11
11
|
// - Record-like type parameters / input parameters?
|
|
12
|
-
// -
|
|
12
|
+
// - Omit `props` properties from Row and Column schemas when not provided?
|
|
13
|
+
// Longer-term work:
|
|
14
|
+
// - Add constraint APIs to make it possible to avoid situations that could yield "orphaned" cells.
|
|
13
15
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @privateRemarks TODO: document in more detail and add `@example`s.
|
|
16
|
-
* @internal
|
|
16
|
+
* The sub-scope applied to user-provided {@link SchemaFactory}s by table schema factories.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const tableSchemaFactorySubScope = "table";
|
|
19
|
+
/**
|
|
20
|
+
* Not intended for use outside of this package.
|
|
21
|
+
*
|
|
22
|
+
* @privateRemarks
|
|
23
|
+
* This namespace is a collection of internal system types relate to {@link TableSchema}.
|
|
24
|
+
* This namespace should be strictly type-exported by the package.
|
|
25
|
+
* All members should be tagged with `@system`.
|
|
26
|
+
*
|
|
27
|
+
* @system @internal
|
|
28
|
+
*/
|
|
29
|
+
export var System_TableSchema;
|
|
30
|
+
(function (System_TableSchema) {
|
|
21
31
|
/**
|
|
22
32
|
* Factory for creating new table column schema.
|
|
23
|
-
* @
|
|
24
|
-
* TODO:
|
|
25
|
-
* - Add overloads to make propsSchema optional.
|
|
26
|
-
* - Take field schema rather than node schema for `propsSchema`, in particular to allow making
|
|
27
|
-
* the additional properties optional.
|
|
28
|
-
* @internal
|
|
33
|
+
* @system @internal
|
|
29
34
|
*/
|
|
30
35
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
31
|
-
function
|
|
36
|
+
function createColumnInternal(inputSchemaFactory, propsSchema) {
|
|
32
37
|
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
38
|
+
// Note: `columnFields` is broken into two parts to work around a TypeScript bug
|
|
39
|
+
// that results in broken `.d.ts` output.
|
|
40
|
+
// See definition of `ColumnInsertableType` below.
|
|
41
|
+
const columnFieldsBuiltInParts = {
|
|
42
|
+
id: schemaFactory.identifier,
|
|
43
|
+
};
|
|
44
|
+
const columnFieldsPropsPart = {
|
|
45
|
+
props: propsSchema,
|
|
46
|
+
};
|
|
33
47
|
/**
|
|
34
48
|
* {@link Column} fields.
|
|
35
|
-
*
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* Extracted for re-use in returned type signature defined later in this function.
|
|
36
52
|
* The implicit typing is intentional.
|
|
53
|
+
*
|
|
37
54
|
* Note: ideally we would add a satisfies clause here to ensure that this satisfies
|
|
38
55
|
* `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.
|
|
39
56
|
* Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
|
|
40
57
|
*/
|
|
41
58
|
const columnFields = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
59
|
+
...columnFieldsBuiltInParts,
|
|
60
|
+
...columnFieldsPropsPart,
|
|
61
|
+
}; // satisfies Record<string, ImplicitFieldSchema>;
|
|
45
62
|
/**
|
|
46
63
|
* A column in a table.
|
|
47
64
|
*/
|
|
48
|
-
class Column extends schemaFactory.
|
|
65
|
+
class Column extends schemaFactory.objectAlpha("Column", columnFields, {
|
|
66
|
+
// Will make it easier to evolve this schema in the future.
|
|
67
|
+
allowUnknownOptionalFields: true,
|
|
68
|
+
}) {
|
|
49
69
|
}
|
|
50
70
|
// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
|
|
51
71
|
// for the private brand field of TreeNode.
|
|
@@ -55,21 +75,29 @@ export var TableSchema;
|
|
|
55
75
|
const ColumnSchemaType = Column;
|
|
56
76
|
return ColumnSchemaType;
|
|
57
77
|
}
|
|
58
|
-
|
|
78
|
+
System_TableSchema.createColumnInternal = createColumnInternal;
|
|
59
79
|
/**
|
|
60
80
|
* Factory for creating new table row schema.
|
|
61
81
|
*
|
|
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.
|
|
67
|
-
*
|
|
68
82
|
* @sealed @internal
|
|
69
83
|
*/
|
|
70
84
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
71
|
-
function
|
|
85
|
+
function createRowInternal(inputSchemaFactory, cellSchema, propsSchema) {
|
|
72
86
|
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
87
|
+
// Note: `rowFields` is broken into two parts to work around a TypeScript bug
|
|
88
|
+
// that results in broken `.d.ts` output.
|
|
89
|
+
// See definition of `RowInsertableType` below.
|
|
90
|
+
const rowFieldsBuiltInParts = {
|
|
91
|
+
id: schemaFactory.identifier,
|
|
92
|
+
cells: schemaFactory.required(schemaFactory.map("Row.cells", cellSchema), {
|
|
93
|
+
metadata: {
|
|
94
|
+
description: "The cells of the table row, keyed by column ID.",
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
const rowFieldsPropsPart = {
|
|
99
|
+
props: propsSchema,
|
|
100
|
+
};
|
|
73
101
|
/**
|
|
74
102
|
* {@link Row} fields.
|
|
75
103
|
* @remarks Extracted for re-use in returned type signature defined later in this function.
|
|
@@ -79,28 +107,34 @@ export var TableSchema;
|
|
|
79
107
|
* Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
|
|
80
108
|
*/
|
|
81
109
|
const rowFields = {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
110
|
+
...rowFieldsBuiltInParts,
|
|
111
|
+
...rowFieldsPropsPart,
|
|
112
|
+
}; // satisfies Record<string, ImplicitFieldSchema>;
|
|
86
113
|
/**
|
|
87
114
|
* The Row schema - this is a map of Cells where the key is the column id
|
|
88
115
|
*/
|
|
89
|
-
class Row extends schemaFactory.
|
|
116
|
+
class Row extends schemaFactory.objectAlpha("Row", rowFields, {
|
|
117
|
+
// Will make it easier to evolve this schema in the future.
|
|
118
|
+
allowUnknownOptionalFields: true,
|
|
119
|
+
}) {
|
|
90
120
|
getCell(columnOrId) {
|
|
91
121
|
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
92
122
|
return this.cells.get(columnId);
|
|
93
123
|
}
|
|
94
124
|
setCell(columnOrId, value) {
|
|
125
|
+
// TODO: throw if column does not exist in the owning table.
|
|
95
126
|
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
96
127
|
this.cells.set(columnId, value);
|
|
97
128
|
}
|
|
98
129
|
removeCell(columnOrId) {
|
|
130
|
+
// TODO: throw if column does not exist in the owning table.
|
|
99
131
|
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
100
|
-
|
|
101
|
-
|
|
132
|
+
const cell = this.cells.get(columnId);
|
|
133
|
+
if (cell === undefined) {
|
|
134
|
+
return undefined;
|
|
102
135
|
}
|
|
103
136
|
this.cells.delete(columnId);
|
|
137
|
+
return cell;
|
|
104
138
|
}
|
|
105
139
|
}
|
|
106
140
|
// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
|
|
@@ -111,14 +145,7 @@ export var TableSchema;
|
|
|
111
145
|
const RowSchemaType = Row;
|
|
112
146
|
return RowSchemaType;
|
|
113
147
|
}
|
|
114
|
-
|
|
115
|
-
/** `createTable` implementation */
|
|
116
|
-
function createTable(inputSchemaFactory, _cellSchema, columnSchema, rowSchema) {
|
|
117
|
-
const column = columnSchema ?? createColumn(inputSchemaFactory, inputSchemaFactory.null);
|
|
118
|
-
return createTableInternal(inputSchemaFactory, _cellSchema, column, rowSchema ??
|
|
119
|
-
createRow(inputSchemaFactory, _cellSchema, inputSchemaFactory.null));
|
|
120
|
-
}
|
|
121
|
-
TableSchema.createTable = createTable;
|
|
148
|
+
System_TableSchema.createRowInternal = createRowInternal;
|
|
122
149
|
/**
|
|
123
150
|
* Factory for creating new table schema.
|
|
124
151
|
* @system @internal
|
|
@@ -138,7 +165,10 @@ export var TableSchema;
|
|
|
138
165
|
/**
|
|
139
166
|
* The Table schema
|
|
140
167
|
*/
|
|
141
|
-
class Table extends schemaFactory.
|
|
168
|
+
class Table extends schemaFactory.objectAlpha("Table", tableFields, {
|
|
169
|
+
// Will make it easier to evolve this schema in the future.
|
|
170
|
+
allowUnknownOptionalFields: true,
|
|
171
|
+
}) {
|
|
142
172
|
getColumn(id) {
|
|
143
173
|
// TypeScript is unable to narrow the types correctly here, hence the casts.
|
|
144
174
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
@@ -150,98 +180,245 @@ export var TableSchema;
|
|
|
150
180
|
return this.rows.find((_row) => _row.id === id);
|
|
151
181
|
}
|
|
152
182
|
getCell(key) {
|
|
153
|
-
const {
|
|
154
|
-
const row = this.
|
|
155
|
-
if (row
|
|
156
|
-
|
|
157
|
-
if (column !== undefined) {
|
|
158
|
-
return row.getCell(column.id);
|
|
159
|
-
}
|
|
183
|
+
const { column: columnOrId, row: rowOrId } = key;
|
|
184
|
+
const row = this._getRow(rowOrId);
|
|
185
|
+
if (row === undefined) {
|
|
186
|
+
return undefined;
|
|
160
187
|
}
|
|
161
|
-
|
|
162
|
-
|
|
188
|
+
const column = this._getColumn(columnOrId);
|
|
189
|
+
if (column === undefined) {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
return row.getCell(column);
|
|
163
193
|
}
|
|
164
194
|
insertColumn({ column, index, }) {
|
|
165
|
-
|
|
166
|
-
|
|
195
|
+
const inserted = this.insertColumns({
|
|
196
|
+
columns: [column],
|
|
197
|
+
index,
|
|
198
|
+
});
|
|
199
|
+
return inserted[0] ?? oob();
|
|
200
|
+
}
|
|
201
|
+
insertColumns({ columns, index, }) {
|
|
202
|
+
// #region Input validation
|
|
203
|
+
// Ensure index is valid
|
|
204
|
+
if (index !== undefined) {
|
|
205
|
+
Table.validateInsertionIndex(index, this.columns);
|
|
206
|
+
}
|
|
207
|
+
// Check all of the columns being inserted an ensure the table does not already contain any with the same ID.
|
|
208
|
+
for (const column of columns) {
|
|
209
|
+
// TypeScript is unable to narrow the type of the column type correctly here, hence the casts below.
|
|
167
210
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
211
|
+
const maybeId = column.id;
|
|
212
|
+
if (maybeId !== undefined && this.containsColumnWithId(maybeId)) {
|
|
213
|
+
throw new UsageError(`A column with ID "${column.id}" already exists in the table.`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// #endregion
|
|
217
|
+
// TypeScript is unable to narrow the column type correctly here, hence the casts below.
|
|
218
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
219
|
+
if (index === undefined) {
|
|
168
220
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
169
|
-
this.columns.insertAtEnd(
|
|
221
|
+
this.columns.insertAtEnd(TreeArrayNode.spread(columns));
|
|
170
222
|
}
|
|
171
223
|
else {
|
|
172
|
-
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
173
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
174
224
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
175
|
-
this.columns.insertAt(index,
|
|
225
|
+
this.columns.insertAt(index, TreeArrayNode.spread(columns));
|
|
176
226
|
}
|
|
177
|
-
// Inserting the input
|
|
178
|
-
return
|
|
227
|
+
// Inserting the input nodes into the tree hydrates them, making them usable as nodes.
|
|
228
|
+
return columns;
|
|
229
|
+
}
|
|
230
|
+
insertRow({ row, index, }) {
|
|
231
|
+
const inserted = this.insertRows({
|
|
232
|
+
rows: [row],
|
|
233
|
+
index,
|
|
234
|
+
});
|
|
235
|
+
return inserted[0] ?? oob();
|
|
179
236
|
}
|
|
180
237
|
insertRows({ index, rows, }) {
|
|
238
|
+
// #region Input validation
|
|
239
|
+
// Ensure index is valid
|
|
240
|
+
if (index !== undefined) {
|
|
241
|
+
Table.validateInsertionIndex(index, this.rows);
|
|
242
|
+
}
|
|
243
|
+
// Note: TypeScript is unable to narrow the type of the row type correctly here, hence the casts below.
|
|
244
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
245
|
+
for (const newRow of rows) {
|
|
246
|
+
// Check all of the rows being inserted an ensure the table does not already contain any with the same ID.
|
|
247
|
+
const maybeId = newRow.id;
|
|
248
|
+
if (maybeId !== undefined && this.containsRowWithId(maybeId)) {
|
|
249
|
+
throw new UsageError(`A row with ID "${newRow.id}" already exists in the table.`);
|
|
250
|
+
}
|
|
251
|
+
// If the row contains cells, verify that the table contains the columns for those cells.
|
|
252
|
+
// Note: we intentionally hide `cells` on `IRow` to avoid leaking the internal data representation as much as possible, so we have to cast here.
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
254
|
+
if (newRow.cells !== undefined) {
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
256
|
+
const keys = Object.keys(newRow.cells);
|
|
257
|
+
for (const key of keys) {
|
|
258
|
+
if (!this.containsColumnWithId(key)) {
|
|
259
|
+
throw new UsageError(`Attempted to insert row a cell under column ID "${key}", but the table does not contain a column with that ID.`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// #endregion
|
|
265
|
+
// TypeScript is unable to narrow the row type correctly here, hence the casts below.
|
|
266
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
181
267
|
if (index === undefined) {
|
|
182
|
-
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
183
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
184
268
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
185
269
|
this.rows.insertAtEnd(TreeArrayNode.spread(rows));
|
|
186
270
|
}
|
|
187
271
|
else {
|
|
188
|
-
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
189
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
190
272
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
191
273
|
this.rows.insertAt(index, TreeArrayNode.spread(rows));
|
|
192
274
|
}
|
|
193
275
|
// Inserting the input nodes into the tree hydrates them, making them usable as nodes.
|
|
194
276
|
return rows;
|
|
195
277
|
}
|
|
196
|
-
setCell({ key, cell }) {
|
|
197
|
-
const {
|
|
198
|
-
const row = this.
|
|
199
|
-
if (row
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
row.setCell(column.id, cell);
|
|
203
|
-
}
|
|
278
|
+
setCell({ key, cell, }) {
|
|
279
|
+
const { column: columnOrId, row: rowOrId } = key;
|
|
280
|
+
const row = this._getRow(rowOrId);
|
|
281
|
+
if (row === undefined) {
|
|
282
|
+
const rowId = this._getRowId(rowOrId);
|
|
283
|
+
throw new UsageError(`No row with ID "${rowId}" exists in the table.`);
|
|
204
284
|
}
|
|
285
|
+
const column = this._getColumn(columnOrId);
|
|
286
|
+
if (column === undefined) {
|
|
287
|
+
const columnId = this._getColumnId(columnOrId);
|
|
288
|
+
throw new UsageError(`No column with ID "${columnId}" exists in the table.`);
|
|
289
|
+
}
|
|
290
|
+
row.setCell(column, cell);
|
|
291
|
+
}
|
|
292
|
+
removeColumns(columns) {
|
|
293
|
+
// If there are no columns to remove, do nothing
|
|
294
|
+
if (columns.length === 0) {
|
|
295
|
+
return [];
|
|
296
|
+
}
|
|
297
|
+
// If there is only one column to remove, remove it (and don't incur cost of transaction)
|
|
298
|
+
if (columns.length === 1) {
|
|
299
|
+
const removedColumn = this.removeColumn(columns[0] ?? oob());
|
|
300
|
+
return [removedColumn];
|
|
301
|
+
}
|
|
302
|
+
// If there are multiple columns to remove, remove them in a transaction.
|
|
303
|
+
const removedColumns = [];
|
|
304
|
+
Tree.runTransaction(this, () => {
|
|
305
|
+
// Note, throwing an error within a transaction will abort the entire transaction.
|
|
306
|
+
// So if we throw an error here for any row, no columns will be removed.
|
|
307
|
+
for (const columnToRemove of columns) {
|
|
308
|
+
const removedRow = this.removeColumn(columnToRemove);
|
|
309
|
+
removedColumns.push(removedRow);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
return removedColumns;
|
|
205
313
|
}
|
|
206
|
-
removeColumn(
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
if (index === -1)
|
|
210
|
-
|
|
314
|
+
removeColumn(columnOrId) {
|
|
315
|
+
const column = this._getColumn(columnOrId);
|
|
316
|
+
const index = column === undefined ? -1 : this.columns.indexOf(column);
|
|
317
|
+
if (index === -1) {
|
|
318
|
+
const columnId = this._getColumnId(columnOrId);
|
|
319
|
+
throw new UsageError(`Specified column with ID "${columnId}" does not exist in the table.`);
|
|
320
|
+
}
|
|
211
321
|
this.columns.removeAt(index);
|
|
322
|
+
return column;
|
|
323
|
+
}
|
|
324
|
+
removeAllColumns() {
|
|
325
|
+
// TypeScript is unable to narrow the row type correctly here, hence the cast.
|
|
326
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
327
|
+
return this.removeColumns(this.columns);
|
|
212
328
|
}
|
|
213
329
|
removeRows(rows) {
|
|
214
330
|
// If there are no rows to remove, do nothing
|
|
215
331
|
if (rows.length === 0) {
|
|
216
|
-
return;
|
|
332
|
+
return [];
|
|
217
333
|
}
|
|
218
|
-
// If there is only one row to remove, remove it
|
|
334
|
+
// If there is only one row to remove, remove it (and don't incur cost of transaction)
|
|
219
335
|
if (rows.length === 1) {
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
return;
|
|
336
|
+
const removedRow = this.removeRow(rows[0] ?? oob());
|
|
337
|
+
return [removedRow];
|
|
223
338
|
}
|
|
224
|
-
// If there are multiple rows to remove, remove them in a transaction
|
|
225
|
-
|
|
339
|
+
// If there are multiple rows to remove, remove them in a transaction.
|
|
340
|
+
const removedRows = [];
|
|
226
341
|
Tree.runTransaction(this, () => {
|
|
227
|
-
//
|
|
228
|
-
for
|
|
229
|
-
|
|
230
|
-
this.
|
|
342
|
+
// Note, throwing an error within a transaction will abort the entire transaction.
|
|
343
|
+
// So if we throw an error here for any row, no rows will be removed.
|
|
344
|
+
for (const rowToRemove of rows) {
|
|
345
|
+
const removedRow = this.removeRow(rowToRemove);
|
|
346
|
+
removedRows.push(removedRow);
|
|
231
347
|
}
|
|
232
348
|
});
|
|
349
|
+
return removedRows;
|
|
350
|
+
}
|
|
351
|
+
removeRow(rowOrId) {
|
|
352
|
+
const rowToRemove = this._getRow(rowOrId);
|
|
353
|
+
const index = rowToRemove === undefined ? -1 : this.rows.indexOf(rowToRemove);
|
|
354
|
+
// If the row does not exist in the table, throw an error.
|
|
355
|
+
if (index === -1) {
|
|
356
|
+
const rowId = this._getRowId(rowOrId);
|
|
357
|
+
throw new UsageError(`Specified row with ID "${rowId}" does not exist in the table.`);
|
|
358
|
+
}
|
|
359
|
+
this.rows.removeAt(index);
|
|
360
|
+
return rowToRemove;
|
|
233
361
|
}
|
|
234
362
|
removeAllRows() {
|
|
235
|
-
|
|
363
|
+
// TypeScript is unable to narrow the row type correctly here, hence the cast.
|
|
364
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
365
|
+
return this.removeRows(this.rows);
|
|
236
366
|
}
|
|
237
367
|
removeCell(key) {
|
|
238
|
-
const {
|
|
239
|
-
const row = this.
|
|
240
|
-
if (row
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
368
|
+
const { column: columnOrId, row: rowOrId } = key;
|
|
369
|
+
const row = this._getRow(rowOrId);
|
|
370
|
+
if (row === undefined) {
|
|
371
|
+
const rowId = this._getRowId(rowOrId);
|
|
372
|
+
throw new UsageError(`Specified row with ID "${rowId}" does not exist in the table.`);
|
|
373
|
+
}
|
|
374
|
+
const column = this._getColumn(columnOrId);
|
|
375
|
+
if (column === undefined) {
|
|
376
|
+
const columnId = this._getColumnId(columnOrId);
|
|
377
|
+
throw new UsageError(`Specified column with ID "${columnId}" does not exist in the table.`);
|
|
378
|
+
}
|
|
379
|
+
const cell = row.getCell(column.id);
|
|
380
|
+
if (cell === undefined) {
|
|
381
|
+
return undefined;
|
|
382
|
+
}
|
|
383
|
+
row.removeCell(column.id);
|
|
384
|
+
return cell;
|
|
385
|
+
}
|
|
386
|
+
_getColumn(columnOrId) {
|
|
387
|
+
return typeof columnOrId === "string" ? this.getColumn(columnOrId) : columnOrId;
|
|
388
|
+
}
|
|
389
|
+
_getColumnId(columnOrId) {
|
|
390
|
+
return typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
391
|
+
}
|
|
392
|
+
_getRow(rowOrId) {
|
|
393
|
+
return typeof rowOrId === "string" ? this.getRow(rowOrId) : rowOrId;
|
|
394
|
+
}
|
|
395
|
+
_getRowId(rowOrId) {
|
|
396
|
+
return typeof rowOrId === "string" ? rowOrId : rowOrId.id;
|
|
397
|
+
}
|
|
398
|
+
containsColumnWithId(columnId) {
|
|
399
|
+
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
400
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
401
|
+
return (this.columns.find((column) => column.id === columnId) !==
|
|
402
|
+
undefined);
|
|
403
|
+
}
|
|
404
|
+
containsRowWithId(rowId) {
|
|
405
|
+
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
406
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
407
|
+
return this.rows.find((row) => row.id === rowId) !== undefined;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Ensure that the specified index is a valid location for item insertion in the destination list.
|
|
411
|
+
* @throws Throws a usage error if the destination is invalid.
|
|
412
|
+
*/
|
|
413
|
+
static validateInsertionIndex(index, destinationList) {
|
|
414
|
+
if (index < 0) {
|
|
415
|
+
throw new UsageError("The index must be greater than or equal to 0.");
|
|
416
|
+
}
|
|
417
|
+
if (index > destinationList.length) {
|
|
418
|
+
throw new UsageError("The index specified for insertion is out of bounds.");
|
|
419
|
+
}
|
|
420
|
+
if (!Number.isInteger(index)) {
|
|
421
|
+
throw new UsageError("The index must be an integer.");
|
|
245
422
|
}
|
|
246
423
|
}
|
|
247
424
|
}
|
|
@@ -254,7 +431,127 @@ export var TableSchema;
|
|
|
254
431
|
// Return the table schema
|
|
255
432
|
return TableSchemaType;
|
|
256
433
|
}
|
|
257
|
-
|
|
434
|
+
System_TableSchema.createTableInternal = createTableInternal;
|
|
435
|
+
// #endregion
|
|
436
|
+
})(System_TableSchema || (System_TableSchema = {}));
|
|
437
|
+
/**
|
|
438
|
+
* Contains types and factories for creating schema to represent dynamic tabular data.
|
|
439
|
+
*
|
|
440
|
+
* @remarks
|
|
441
|
+
*
|
|
442
|
+
* Tables created using these APIs are...
|
|
443
|
+
*
|
|
444
|
+
* - sparse, meaning that cells may be omitted, and new rows are empty by default.
|
|
445
|
+
*
|
|
446
|
+
* - dynamic, meaning that their structure can be modified at runtime.
|
|
447
|
+
* Columns and rows can be inserted, removed, modified, and reordered.
|
|
448
|
+
* Cells can be inserted, removed, and modified.
|
|
449
|
+
*
|
|
450
|
+
* - row-major, meaning that operating on rows (including inserts, removal, moves, and traversal) is more efficient than operating on columns.
|
|
451
|
+
*
|
|
452
|
+
* Column and Row schema created using these APIs are extensible via the `props` field.
|
|
453
|
+
* This allows association of additional properties with column and row nodes.
|
|
454
|
+
*
|
|
455
|
+
* Note: for now it is possible for table cells to become "orphaned".
|
|
456
|
+
* That is, it is possible to enter a state where one or more rows contain cells with no corresponding column.
|
|
457
|
+
* To help avoid this situation, you can manually remove corresponding cells when removing columns.
|
|
458
|
+
* Either way, it is possible to enter such a state via the merging of edits.
|
|
459
|
+
* For example: one client might add a row while another concurrently removes a column, orphaning the cell where the column and row intersected.
|
|
460
|
+
*
|
|
461
|
+
* @example Using default Column and Row schema
|
|
462
|
+
*
|
|
463
|
+
* ```typescript
|
|
464
|
+
* class Cell extends schemaFactory.object("TableCell", {
|
|
465
|
+
* value: schemaFactory.string,
|
|
466
|
+
* }) {}
|
|
467
|
+
*
|
|
468
|
+
* class Table extends TableSchema.createTable({
|
|
469
|
+
* schemaFactory,
|
|
470
|
+
* cell: Cell,
|
|
471
|
+
* }) {}
|
|
472
|
+
*
|
|
473
|
+
* const table = new Table({
|
|
474
|
+
* columns: [{ id: "column-0" }],
|
|
475
|
+
* rows: [{ id: "row-0", cells: {} }],
|
|
476
|
+
* });
|
|
477
|
+
* ```
|
|
478
|
+
*
|
|
479
|
+
* @example Customizing Column and Row schema
|
|
480
|
+
*
|
|
481
|
+
* ```typescript
|
|
482
|
+
* class Cell extends schemaFactory.object("TableCell", {
|
|
483
|
+
* value: schemaFactory.string,
|
|
484
|
+
* }) {}
|
|
485
|
+
*
|
|
486
|
+
* class ColumnProps extends schemaFactory.object("TableColumnProps", {
|
|
487
|
+
* // Column label to display.
|
|
488
|
+
* label: schemaFactory.string,
|
|
489
|
+
* // The type of data represented by the cells. Default: string.
|
|
490
|
+
* dataType: schemaFactory.optional(schemaFactory.string),
|
|
491
|
+
* }) {}
|
|
492
|
+
*
|
|
493
|
+
* class Column extends TableSchema.createColumn({
|
|
494
|
+
* schemaFactory,
|
|
495
|
+
* props: ColumnProps,
|
|
496
|
+
* }) {}
|
|
497
|
+
*
|
|
498
|
+
* class Row extends TableSchema.createRow({
|
|
499
|
+
* schemaFactory,
|
|
500
|
+
* cell: Cell,
|
|
501
|
+
* }) {}
|
|
502
|
+
*
|
|
503
|
+
* class Table extends TableSchema.createTable({
|
|
504
|
+
* schemaFactory,
|
|
505
|
+
* cell: Cell,
|
|
506
|
+
* column: Column,
|
|
507
|
+
* row: Row,
|
|
508
|
+
* }) {}
|
|
509
|
+
*
|
|
510
|
+
* const table = new Table({
|
|
511
|
+
* columns: [
|
|
512
|
+
* new Column({ props: { label: "Entry", dataType: "string" } }),
|
|
513
|
+
* new Column({ props: { label: "Date", dataType: "date" } }),
|
|
514
|
+
* new Column({ props: { label: "Amount", dataType: "number" } }),
|
|
515
|
+
* ],
|
|
516
|
+
* rows: [],
|
|
517
|
+
* });
|
|
518
|
+
* ```
|
|
519
|
+
*
|
|
520
|
+
* @privateRemarks
|
|
521
|
+
* The above examples are backed by tests in `tableSchema.spec.ts`.
|
|
522
|
+
* Those tests and these examples should be kept in-sync to ensure that the examples are correct.
|
|
523
|
+
*
|
|
524
|
+
* @internal
|
|
525
|
+
*/
|
|
526
|
+
export var TableSchema;
|
|
527
|
+
(function (TableSchema) {
|
|
528
|
+
// #region Column
|
|
529
|
+
/**
|
|
530
|
+
* Overload implementation
|
|
531
|
+
*/
|
|
532
|
+
function createColumn({ schemaFactory, props = SchemaFactory.optional(SchemaFactory.null), }) {
|
|
533
|
+
return System_TableSchema.createColumnInternal(schemaFactory, props);
|
|
534
|
+
}
|
|
535
|
+
TableSchema.createColumn = createColumn;
|
|
536
|
+
/**
|
|
537
|
+
* Overload implementation
|
|
538
|
+
*/
|
|
539
|
+
function createRow({ schemaFactory, cell, props = SchemaFactory.optional(SchemaFactory.null), }) {
|
|
540
|
+
return System_TableSchema.createRowInternal(schemaFactory, cell, props);
|
|
541
|
+
}
|
|
542
|
+
TableSchema.createRow = createRow;
|
|
543
|
+
/**
|
|
544
|
+
* Overload implementation
|
|
545
|
+
*/
|
|
546
|
+
function createTable({ schemaFactory, cell, column = createColumn({
|
|
547
|
+
schemaFactory,
|
|
548
|
+
}), row = createRow({
|
|
549
|
+
schemaFactory,
|
|
550
|
+
cell,
|
|
551
|
+
}), }) {
|
|
552
|
+
return System_TableSchema.createTableInternal(schemaFactory, cell, column, row);
|
|
553
|
+
}
|
|
554
|
+
TableSchema.createTable = createTable;
|
|
258
555
|
// #endregion
|
|
259
556
|
})(TableSchema || (TableSchema = {}));
|
|
260
557
|
//# sourceMappingURL=tableSchema.js.map
|