@fluidframework/tree 2.72.0 → 2.73.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 +99 -0
- package/api-report/tree.alpha.api.md +17 -30
- package/dist/alpha.d.ts +3 -1
- package/dist/api.d.ts +6 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +2 -11
- package/dist/api.js.map +1 -1
- package/dist/codec/codec.d.ts +9 -2
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +9 -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/codec/versioned/codec.d.ts +7 -2
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +24 -1
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/codec/versioned/index.d.ts +1 -1
- package/dist/codec/versioned/index.d.ts.map +1 -1
- package/dist/codec/versioned/index.js +2 -1
- package/dist/codec/versioned/index.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +12 -1
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +5 -3
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +4 -5
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +1 -0
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +2 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +31 -17
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +6 -6
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -2
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts +156 -4
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.js +7 -3
- package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts +8 -3
- package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/formatGeneric.js +4 -1
- package/dist/feature-libraries/chunked-forest/codec/formatGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js +2 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +13 -13
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +23 -6
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +9 -8
- package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +20 -4
- package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.js +2 -1
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +35 -17
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +53 -55
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts +1 -3
- package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/index.js +2 -8
- package/dist/feature-libraries/default-schema/index.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 +4 -2
- package/dist/feature-libraries/forest-summary/format.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +4 -3
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +8 -7
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.js +1 -2
- package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldKind.d.ts +38 -12
- package/dist/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldKind.js +29 -11
- package/dist/feature-libraries/modular-schema/fieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldKindConfiguration.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/fieldKindConfiguration.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldKindConfiguration.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +3 -2
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +0 -1
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +1 -3
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.d.ts +5 -6
- package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -8
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1 -2
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +66 -9
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +3 -2
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/optional-field/index.d.ts +1 -1
- package/dist/feature-libraries/optional-field/index.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/index.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.js +1 -5
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +5 -3
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/{default-schema/schemaChecker.d.ts → schemaChecker.d.ts} +2 -2
- package/dist/feature-libraries/schemaChecker.d.ts.map +1 -0
- package/dist/feature-libraries/{default-schema/schemaChecker.js → schemaChecker.js} +3 -3
- package/dist/feature-libraries/schemaChecker.js.map +1 -0
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js +0 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/index.d.ts +1 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +1 -2
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +0 -44
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +1 -52
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +0 -2
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +12 -6
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +3 -4
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +5 -8
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +2 -2
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +3 -2
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +20 -9
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/messageFormat.d.ts +4 -6
- package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormat.js +9 -7
- package/dist/shared-tree-core/messageFormat.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +2 -0
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js +10 -0
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -0
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +5 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +7 -1
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaCodec.js +4 -6
- package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +103 -0
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -0
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js +128 -0
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -0
- package/dist/simple-tree/api/tree.d.ts +1 -1
- package/dist/simple-tree/api/tree.js +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.js +1 -1
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +3 -3
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +3 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/toStored.d.ts +12 -5
- package/dist/simple-tree/core/toStored.d.ts.map +1 -1
- package/dist/simple-tree/core/toStored.js +26 -10
- package/dist/simple-tree/core/toStored.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +1 -6
- 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/treeNodeValid.d.ts +1 -1
- package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.js +1 -2
- package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
- package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/fieldSchema.js +1 -8
- package/dist/simple-tree/fieldSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +9 -3
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +0 -1
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +13 -49
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +1 -5
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +2 -10
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +1 -5
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/simpleSchema.d.ts +15 -3
- package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/simpleSchema.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts +20 -8
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +27 -22
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +18 -15
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/dist/tableSchema.d.ts +22 -52
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +141 -277
- package/dist/tableSchema.js.map +1 -1
- package/dist/util/arrayUtilities.d.ts +45 -0
- package/dist/util/arrayUtilities.d.ts.map +1 -0
- package/dist/util/arrayUtilities.js +76 -0
- package/dist/util/arrayUtilities.js.map +1 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +7 -2
- package/dist/util/index.js.map +1 -1
- package/lib/alpha.d.ts +3 -1
- package/lib/api.d.ts +6 -2
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +2 -13
- package/lib/api.js.map +1 -1
- package/lib/codec/codec.d.ts +9 -2
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +9 -2
- 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/codec/versioned/codec.d.ts +7 -2
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +22 -0
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/codec/versioned/index.d.ts +1 -1
- package/lib/codec/versioned/index.d.ts.map +1 -1
- package/lib/codec/versioned/index.js +1 -1
- package/lib/codec/versioned/index.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +12 -1
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +5 -3
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +4 -5
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +2 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +2 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +34 -20
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +6 -6
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -2
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts +156 -4
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.js +6 -2
- package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts +8 -3
- package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/formatGeneric.js +4 -1
- package/lib/feature-libraries/chunked-forest/codec/formatGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +13 -13
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +22 -6
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +9 -8
- package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +17 -2
- package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +35 -17
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +55 -57
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts +1 -3
- package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/index.js +1 -3
- package/lib/feature-libraries/default-schema/index.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 +4 -2
- package/lib/feature-libraries/forest-summary/format.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +4 -3
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +4 -3
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.js +1 -2
- package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldKind.d.ts +38 -12
- package/lib/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldKind.js +29 -11
- package/lib/feature-libraries/modular-schema/fieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldKindConfiguration.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/fieldKindConfiguration.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldKindConfiguration.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +3 -2
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +0 -1
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +0 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.d.ts +5 -6
- package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -8
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1 -2
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +66 -9
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +2 -1
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/optional-field/index.d.ts +1 -1
- package/lib/feature-libraries/optional-field/index.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/index.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.js +1 -5
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +5 -3
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/{default-schema/schemaChecker.d.ts → schemaChecker.d.ts} +2 -2
- package/lib/feature-libraries/schemaChecker.d.ts.map +1 -0
- package/lib/feature-libraries/{default-schema/schemaChecker.js → schemaChecker.js} +3 -3
- package/lib/feature-libraries/schemaChecker.js.map +1 -0
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js +0 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/index.d.ts +1 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +0 -44
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +0 -51
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +0 -2
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +13 -7
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +3 -4
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +4 -7
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +2 -2
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js +2 -2
- package/lib/shared-tree-core/index.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +21 -10
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/messageFormat.d.ts +4 -6
- package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormat.js +8 -6
- package/lib/shared-tree-core/messageFormat.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +2 -0
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js +10 -0
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -0
- 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/schemaFromSimple.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +8 -2
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaCodec.js +5 -7
- package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +103 -0
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -0
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js +122 -0
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -0
- package/lib/simple-tree/api/tree.d.ts +1 -1
- package/lib/simple-tree/api/tree.js +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.js +1 -1
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +3 -3
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +2 -2
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/toStored.d.ts +12 -5
- package/lib/simple-tree/core/toStored.d.ts.map +1 -1
- package/lib/simple-tree/core/toStored.js +25 -9
- package/lib/simple-tree/core/toStored.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +1 -6
- 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/treeNodeValid.d.ts +1 -1
- package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.js +1 -2
- package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
- package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/fieldSchema.js +2 -9
- package/lib/simple-tree/fieldSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +2 -2
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +1 -2
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +15 -51
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +3 -7
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +3 -11
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +3 -7
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/simpleSchema.d.ts +15 -3
- package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/simpleSchema.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts +20 -8
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +28 -24
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +20 -17
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/lib/tableSchema.d.ts +22 -52
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +143 -279
- package/lib/tableSchema.js.map +1 -1
- package/lib/util/arrayUtilities.d.ts +45 -0
- package/lib/util/arrayUtilities.d.ts.map +1 -0
- package/lib/util/arrayUtilities.js +69 -0
- package/lib/util/arrayUtilities.js.map +1 -0
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/package.json +21 -21
- package/src/api.ts +22 -11
- package/src/codec/codec.ts +10 -2
- package/src/codec/index.ts +1 -0
- package/src/codec/versioned/codec.ts +40 -2
- package/src/codec/versioned/index.ts +1 -0
- package/src/core/schema-stored/schema.ts +12 -1
- package/src/core/tree/detachedFieldIndexCodecs.ts +10 -3
- package/src/feature-libraries/README.md +1 -1
- package/src/feature-libraries/chunked-forest/chunkTree.ts +3 -3
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +5 -0
- package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +2 -1
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +52 -19
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +8 -3
- package/src/feature-libraries/chunked-forest/codec/format.ts +14 -4
- package/src/feature-libraries/chunked-forest/codec/formatGeneric.ts +7 -2
- package/src/feature-libraries/chunked-forest/codec/index.ts +1 -4
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +62 -9
- package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +24 -2
- package/src/feature-libraries/chunked-forest/index.ts +1 -1
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +86 -74
- package/src/feature-libraries/default-schema/index.ts +1 -9
- package/src/feature-libraries/forest-summary/format.ts +15 -9
- package/src/feature-libraries/index.ts +7 -5
- package/src/feature-libraries/modular-schema/comparison.ts +2 -3
- package/src/feature-libraries/modular-schema/fieldKind.ts +90 -13
- package/src/feature-libraries/modular-schema/fieldKindConfiguration.ts +2 -3
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +6 -6
- package/src/feature-libraries/modular-schema/index.ts +0 -1
- package/src/feature-libraries/modular-schema/isNeverTree.ts +7 -8
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +13 -13
- package/src/feature-libraries/object-forest/objectForest.ts +2 -6
- package/src/feature-libraries/optional-field/index.ts +1 -0
- package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +1 -5
- package/src/feature-libraries/schema-index/codec.ts +10 -3
- package/src/feature-libraries/{default-schema/schemaChecker.ts → schemaChecker.ts} +4 -4
- package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +0 -2
- package/src/index.ts +3 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +0 -1
- package/src/shared-tree/sharedTree.ts +0 -70
- package/src/shared-tree/sharedTreeChangeCodecs.ts +1 -6
- package/src/shared-tree-core/editManagerCodecs.ts +19 -7
- package/src/shared-tree-core/editManagerFormatCommons.ts +11 -12
- package/src/shared-tree-core/index.ts +6 -2
- package/src/shared-tree-core/messageCodecs.ts +32 -17
- package/src/shared-tree-core/messageFormat.ts +8 -6
- package/src/simple-tree/api/configuration.ts +17 -4
- package/src/simple-tree/api/index.ts +5 -0
- package/src/simple-tree/api/schemaFromSimple.ts +14 -6
- package/src/simple-tree/api/simpleSchemaCodec.ts +10 -9
- package/src/simple-tree/api/snapshotCompatibilityChecker.ts +135 -0
- package/src/simple-tree/api/tree.ts +1 -1
- package/src/simple-tree/core/allowedTypes.ts +1 -1
- package/src/simple-tree/core/index.ts +3 -1
- package/src/simple-tree/core/toStored.ts +42 -18
- package/src/simple-tree/core/treeNodeSchema.ts +1 -7
- package/src/simple-tree/core/treeNodeValid.ts +0 -2
- package/src/simple-tree/fieldSchema.ts +2 -11
- package/src/simple-tree/index.ts +6 -1
- package/src/simple-tree/leafNodeSchema.ts +1 -2
- package/src/simple-tree/node-kinds/array/arrayNode.ts +26 -75
- package/src/simple-tree/node-kinds/map/mapNode.ts +1 -15
- package/src/simple-tree/node-kinds/object/objectNode.ts +2 -17
- package/src/simple-tree/node-kinds/record/recordNode.ts +1 -15
- package/src/simple-tree/simpleSchema.ts +16 -3
- package/src/simple-tree/toStoredSchema.ts +54 -38
- package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +22 -17
- package/src/tableSchema.ts +110 -334
- package/src/util/arrayUtilities.ts +88 -0
- package/src/util/index.ts +6 -0
- package/dist/feature-libraries/default-schema/defaultSchema.d.ts +0 -10
- package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +0 -1
- package/dist/feature-libraries/default-schema/defaultSchema.js +0 -15
- package/dist/feature-libraries/default-schema/defaultSchema.js.map +0 -1
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +0 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js.map +0 -1
- package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts +0 -50
- package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +0 -1
- package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js +0 -76
- package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js.map +0 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecV1.d.ts +0 -12
- package/dist/feature-libraries/optional-field/optionalFieldCodecV1.d.ts.map +0 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecV1.js +0 -158
- package/dist/feature-libraries/optional-field/optionalFieldCodecV1.js.map +0 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +0 -11
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +0 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +0 -245
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +0 -1
- package/lib/feature-libraries/default-schema/defaultSchema.d.ts +0 -10
- package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +0 -1
- package/lib/feature-libraries/default-schema/defaultSchema.js +0 -12
- package/lib/feature-libraries/default-schema/defaultSchema.js.map +0 -1
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +0 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js.map +0 -1
- package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts +0 -50
- package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +0 -1
- package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js +0 -71
- package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js.map +0 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecV1.d.ts +0 -12
- package/lib/feature-libraries/optional-field/optionalFieldCodecV1.d.ts.map +0 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecV1.js +0 -154
- package/lib/feature-libraries/optional-field/optionalFieldCodecV1.js.map +0 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +0 -11
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +0 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +0 -241
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +0 -1
- package/src/feature-libraries/default-schema/defaultSchema.ts +0 -15
- package/src/feature-libraries/modular-schema/fieldKindWithEditor.ts +0 -108
- package/src/feature-libraries/optional-field/optionalFieldCodecV1.ts +0 -208
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +0 -344
package/src/tableSchema.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { fail } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { TreeAlpha } from "./shared-tree/index.js";
|
|
10
10
|
import {
|
|
11
11
|
type FieldHasDefault,
|
|
12
12
|
type ImplicitAllowedTypes,
|
|
@@ -26,10 +26,10 @@ import {
|
|
|
26
26
|
type InternalTreeNode,
|
|
27
27
|
SchemaFactory,
|
|
28
28
|
type ImplicitFieldSchema,
|
|
29
|
-
isArrayNodeSchema,
|
|
30
|
-
type InsertableField,
|
|
31
29
|
withBufferedTreeEvents,
|
|
30
|
+
type TreeRecordNode,
|
|
32
31
|
} from "./simple-tree/index.js";
|
|
32
|
+
import { validateIndex, validateIndexRange } from "./util/index.js";
|
|
33
33
|
|
|
34
34
|
// Future improvement TODOs:
|
|
35
35
|
// - Omit `cells` property from Row insertion type.
|
|
@@ -44,52 +44,31 @@ import {
|
|
|
44
44
|
*/
|
|
45
45
|
const tableSchemaFactorySubScope = "table";
|
|
46
46
|
|
|
47
|
-
/**
|
|
48
|
-
* Gets the table containing the provided row/column node, if the node is part of a table.
|
|
49
|
-
* @remarks Assumes that the table is the grandparent of the row/column node.
|
|
50
|
-
*/
|
|
51
|
-
function getParentTable(
|
|
52
|
-
rowOrColumnNode: TreeNode,
|
|
53
|
-
):
|
|
54
|
-
| (TreeNode &
|
|
55
|
-
TableSchema.Table<
|
|
56
|
-
string | undefined,
|
|
57
|
-
ImplicitAllowedTypes,
|
|
58
|
-
System_TableSchema.ColumnSchemaBase,
|
|
59
|
-
System_TableSchema.RowSchemaBase
|
|
60
|
-
>)
|
|
61
|
-
| undefined {
|
|
62
|
-
const rowListNode = Tree.parent(rowOrColumnNode);
|
|
63
|
-
if (rowListNode === undefined || !isArrayNodeSchema(Tree.schema(rowListNode))) {
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
const tableNode = Tree.parent(rowListNode);
|
|
67
|
-
if (tableNode === undefined || !isTableNode(tableNode)) {
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return tableNode;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
47
|
/**
|
|
75
48
|
* A private symbol put on table schema to help identify them.
|
|
76
49
|
*/
|
|
77
50
|
const tableSchemaSymbol: unique symbol = Symbol("tableNode");
|
|
78
51
|
|
|
79
52
|
/**
|
|
80
|
-
*
|
|
81
|
-
* @
|
|
53
|
+
* A row in a table.
|
|
54
|
+
* @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
|
|
55
|
+
* @typeParam TProps - Additional properties to associate with the row.
|
|
56
|
+
* @privateRemarks Private counterpart to the {@link TableSchema.Row}.
|
|
57
|
+
* Exposes internal properties needed for table operations (publicly exposed via {@link TableSchema.Table}).
|
|
58
|
+
* @sealed
|
|
82
59
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
60
|
+
export interface RowPrivate<
|
|
61
|
+
TCell extends ImplicitAllowedTypes,
|
|
62
|
+
TProps extends ImplicitFieldSchema = ImplicitFieldSchema,
|
|
63
|
+
> extends TableSchema.Row<TCell, TProps> {
|
|
64
|
+
/**
|
|
65
|
+
* The row's cells.
|
|
66
|
+
* @remarks This is a user-defined schema that can be used to store additional information about the row.
|
|
67
|
+
* @privateRemarks
|
|
68
|
+
* Note: these docs are duplicated on the inline type definitions in {@link System_TableSchema.createRowSchema}.
|
|
69
|
+
* If you update the docs here, please also update the inline type definitions.
|
|
70
|
+
*/
|
|
71
|
+
readonly cells: TreeRecordNode<TCell>;
|
|
93
72
|
}
|
|
94
73
|
|
|
95
74
|
/**
|
|
@@ -161,16 +140,10 @@ export namespace System_TableSchema {
|
|
|
161
140
|
const TInputScope extends string | undefined,
|
|
162
141
|
const TCellSchema extends ImplicitAllowedTypes,
|
|
163
142
|
const TPropsSchema extends ImplicitFieldSchema,
|
|
164
|
-
>(
|
|
165
|
-
inputSchemaFactory: SchemaFactoryBeta<TInputScope>,
|
|
166
|
-
cellSchema: TCellSchema,
|
|
167
|
-
propsSchema: TPropsSchema,
|
|
168
|
-
) {
|
|
143
|
+
>(inputSchemaFactory: SchemaFactoryBeta<TInputScope>, propsSchema: TPropsSchema) {
|
|
169
144
|
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
170
145
|
type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
|
|
171
146
|
|
|
172
|
-
type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
173
|
-
|
|
174
147
|
// Note: `columnFields` is broken into two parts to work around a TypeScript bug
|
|
175
148
|
// that results in broken `.d.ts` output.
|
|
176
149
|
// See definition of `ColumnInsertableType` below.
|
|
@@ -205,36 +178,7 @@ export namespace System_TableSchema {
|
|
|
205
178
|
// Will make it easier to evolve this schema in the future.
|
|
206
179
|
allowUnknownOptionalFields: true,
|
|
207
180
|
})
|
|
208
|
-
implements TableSchema.Column<TCellSchema, TPropsSchema>
|
|
209
|
-
{
|
|
210
|
-
public getCells(): {
|
|
211
|
-
rowId: string;
|
|
212
|
-
cell: CellValueType;
|
|
213
|
-
}[] {
|
|
214
|
-
const tableNode = getParentTable(this);
|
|
215
|
-
if (tableNode === undefined) {
|
|
216
|
-
throw new UsageError(`Column with ID "${this.id}" is not contained in a table.`);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const result: {
|
|
220
|
-
rowId: string;
|
|
221
|
-
cell: CellValueType;
|
|
222
|
-
}[] = [];
|
|
223
|
-
for (const row of tableNode.rows) {
|
|
224
|
-
const cell = row.getCell(this.id);
|
|
225
|
-
if (cell !== undefined) {
|
|
226
|
-
if (!Tree.is(cell, cellSchema)) {
|
|
227
|
-
throw new UsageError(
|
|
228
|
-
"Parent table contains a cell with incompatible with this column.",
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
result.push({ rowId: row.id, cell });
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
181
|
+
implements TableSchema.Column<TCellSchema, TPropsSchema> {}
|
|
238
182
|
|
|
239
183
|
type ColumnValueType = TreeNode &
|
|
240
184
|
TableSchema.Column<TCellSchema, TPropsSchema> &
|
|
@@ -344,9 +288,6 @@ export namespace System_TableSchema {
|
|
|
344
288
|
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
345
289
|
type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
|
|
346
290
|
|
|
347
|
-
type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
348
|
-
type CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
349
|
-
|
|
350
291
|
// Note: `rowFields` is broken into two parts to work around a TypeScript bug
|
|
351
292
|
// that results in broken `.d.ts` output.
|
|
352
293
|
// See definition of `RowInsertableType` below.
|
|
@@ -368,7 +309,7 @@ export namespace System_TableSchema {
|
|
|
368
309
|
} as const;
|
|
369
310
|
|
|
370
311
|
/**
|
|
371
|
-
* {@link
|
|
312
|
+
* {@link RowSchema} fields.
|
|
372
313
|
* @remarks Extracted for re-use in returned type signature defined later in this function.
|
|
373
314
|
* The implicit typing is intentional.
|
|
374
315
|
* Note: ideally we would add a satisfies clause here to ensure that this satisfies
|
|
@@ -383,75 +324,12 @@ export namespace System_TableSchema {
|
|
|
383
324
|
/**
|
|
384
325
|
* The Row schema - this is a map of Cells where the key is the column id
|
|
385
326
|
*/
|
|
386
|
-
class
|
|
327
|
+
class RowSchema
|
|
387
328
|
extends schemaFactory.object("Row", rowFields, {
|
|
388
329
|
// Will make it easier to evolve this schema in the future.
|
|
389
330
|
allowUnknownOptionalFields: true,
|
|
390
331
|
})
|
|
391
|
-
implements
|
|
392
|
-
{
|
|
393
|
-
public getCell(
|
|
394
|
-
columnOrId: TableSchema.Column<TCellSchema> | string,
|
|
395
|
-
): CellValueType | undefined {
|
|
396
|
-
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
397
|
-
// Unlike most objects, RecordNodes don't have the default inherited object properties, so this is safe
|
|
398
|
-
return this.cells[columnId];
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
public setCell(
|
|
402
|
-
columnOrId: TableSchema.Column<TCellSchema> | string,
|
|
403
|
-
value: CellInsertableType | undefined,
|
|
404
|
-
): void {
|
|
405
|
-
// TODO: throw if column does not exist in the owning table.
|
|
406
|
-
|
|
407
|
-
if (value === undefined) {
|
|
408
|
-
this.removeCell(columnOrId);
|
|
409
|
-
} else {
|
|
410
|
-
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
411
|
-
|
|
412
|
-
// TypeScript is unable to narrow the types correctly here, hence the casts.
|
|
413
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
414
|
-
this.cells[columnId] = TreeAlpha.create(
|
|
415
|
-
cellSchema,
|
|
416
|
-
value as InsertableField<TCellSchema>,
|
|
417
|
-
) as CellValueType;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
public removeCell(
|
|
422
|
-
columnOrId: TableSchema.Column<TCellSchema> | string,
|
|
423
|
-
): CellValueType | undefined {
|
|
424
|
-
// TODO: throw if column does not exist in the owning table.
|
|
425
|
-
|
|
426
|
-
const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
427
|
-
|
|
428
|
-
const cell: CellValueType | undefined = this.getCell(columnId);
|
|
429
|
-
if (cell === undefined) {
|
|
430
|
-
return undefined;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- The record's values are non-optional, so setting `undefined` as a means to remove the cell is not supported.
|
|
434
|
-
delete this.cells[columnId];
|
|
435
|
-
|
|
436
|
-
return cell;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
public getCells(): {
|
|
440
|
-
columnId: string;
|
|
441
|
-
cell: CellValueType;
|
|
442
|
-
}[] {
|
|
443
|
-
const result = [];
|
|
444
|
-
for (const [columnId, cell] of Object.entries(this.cells)) {
|
|
445
|
-
if (cell !== undefined) {
|
|
446
|
-
result.push({
|
|
447
|
-
columnId,
|
|
448
|
-
cell,
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
return result;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
332
|
+
implements RowPrivate<TCellSchema, TPropsSchema> {}
|
|
455
333
|
|
|
456
334
|
type RowValueType = TreeNode &
|
|
457
335
|
TableSchema.Row<TCellSchema, TPropsSchema> &
|
|
@@ -494,14 +372,14 @@ export namespace System_TableSchema {
|
|
|
494
372
|
type RowSchemaModifiedType = Omit<
|
|
495
373
|
// Use mapped type to omit the constructor
|
|
496
374
|
{
|
|
497
|
-
[Property in keyof typeof
|
|
375
|
+
[Property in keyof typeof RowSchema]: (typeof RowSchema)[Property];
|
|
498
376
|
},
|
|
499
377
|
"createFromInsertable"
|
|
500
378
|
> &
|
|
501
379
|
(new (
|
|
502
380
|
parameters: InternalTreeNode | RowInsertableType,
|
|
503
|
-
) =>
|
|
504
|
-
createFromInsertable(parameters: RowInsertableType):
|
|
381
|
+
) => RowSchema) & {
|
|
382
|
+
createFromInsertable(parameters: RowInsertableType): RowSchema;
|
|
505
383
|
};
|
|
506
384
|
|
|
507
385
|
// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
|
|
@@ -516,7 +394,7 @@ export namespace System_TableSchema {
|
|
|
516
394
|
/* TInsertable */ object & RowInsertableType,
|
|
517
395
|
/* ImplicitlyConstructable */ true,
|
|
518
396
|
/* Info */ typeof rowFields
|
|
519
|
-
> =
|
|
397
|
+
> = RowSchema as RowSchemaModifiedType;
|
|
520
398
|
|
|
521
399
|
return RowSchemaType;
|
|
522
400
|
}
|
|
@@ -568,6 +446,9 @@ export namespace System_TableSchema {
|
|
|
568
446
|
type ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumnSchema>;
|
|
569
447
|
type RowValueType = TreeNodeFromImplicitAllowedTypes<TRowSchema>;
|
|
570
448
|
|
|
449
|
+
// Internal version of RowValueType that exposes the `cells` property for use within Table methods.
|
|
450
|
+
type RowValueInternalType = RowValueType & RowPrivate<TCellSchema>;
|
|
451
|
+
|
|
571
452
|
/**
|
|
572
453
|
* {@link Table} fields.
|
|
573
454
|
* @remarks Extracted for re-use in returned type signature defined later in this function.
|
|
@@ -595,45 +476,43 @@ export namespace System_TableSchema {
|
|
|
595
476
|
}
|
|
596
477
|
|
|
597
478
|
public getColumn(indexOrId: number | string): ColumnValueType | undefined {
|
|
598
|
-
return this
|
|
479
|
+
return this.#tryGetColumn(indexOrId);
|
|
599
480
|
}
|
|
600
481
|
|
|
601
482
|
public getRow(indexOrId: number | string): RowValueType | undefined {
|
|
602
|
-
return this
|
|
483
|
+
return this.#tryGetRow(indexOrId);
|
|
603
484
|
}
|
|
604
485
|
|
|
605
486
|
public getCell(
|
|
606
487
|
key: TableSchema.CellKey<TColumnSchema, TRowSchema>,
|
|
607
488
|
): CellValueType | undefined {
|
|
608
489
|
const { column: columnOrIdOrIndex, row: rowOrIdOrIndex } = key;
|
|
609
|
-
const row = this
|
|
490
|
+
const row = this.#tryGetRow(rowOrIdOrIndex);
|
|
610
491
|
if (row === undefined) {
|
|
611
492
|
return undefined;
|
|
612
493
|
}
|
|
613
494
|
|
|
614
|
-
const column = this
|
|
495
|
+
const column = this.#tryGetColumn(columnOrIdOrIndex);
|
|
615
496
|
if (column === undefined) {
|
|
616
497
|
return undefined;
|
|
617
498
|
}
|
|
618
499
|
|
|
619
|
-
return row.
|
|
500
|
+
return (row as RowValueInternalType).cells[column.id];
|
|
620
501
|
}
|
|
621
502
|
|
|
622
503
|
public insertColumns({
|
|
623
504
|
columns,
|
|
624
505
|
index,
|
|
625
506
|
}: TableSchema.InsertColumnsParameters<TColumnSchema>): ColumnValueType[] {
|
|
626
|
-
// Ensure index is valid
|
|
627
|
-
if (index !== undefined) {
|
|
628
|
-
Table.validateInsertionIndex(index, this.columns);
|
|
629
|
-
}
|
|
630
|
-
|
|
631
507
|
// TypeScript is unable to narrow the column type correctly here, hence the casts below.
|
|
632
508
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
633
509
|
if (index === undefined) {
|
|
634
510
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
635
511
|
this.columns.insertAtEnd(TreeArrayNode.spread(columns) as any);
|
|
636
512
|
} else {
|
|
513
|
+
// Ensure specified index is valid
|
|
514
|
+
validateIndex(index, this.columns, "Table.insertColumns", true);
|
|
515
|
+
|
|
637
516
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
638
517
|
this.columns.insertAt(index, TreeArrayNode.spread(columns) as any);
|
|
639
518
|
}
|
|
@@ -648,9 +527,9 @@ export namespace System_TableSchema {
|
|
|
648
527
|
}: TableSchema.InsertRowsParameters<TRowSchema>): RowValueType[] {
|
|
649
528
|
// #region Input validation
|
|
650
529
|
|
|
651
|
-
// Ensure index is valid
|
|
530
|
+
// Ensure specified index is valid
|
|
652
531
|
if (index !== undefined) {
|
|
653
|
-
|
|
532
|
+
validateIndex(index, this.rows, "Table.insertRows", true);
|
|
654
533
|
}
|
|
655
534
|
|
|
656
535
|
// Note: TypeScript is unable to narrow the type of the row type correctly here, hence the casts below.
|
|
@@ -663,7 +542,7 @@ export namespace System_TableSchema {
|
|
|
663
542
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
664
543
|
const keys: string[] = Object.keys((newRow as any).cells);
|
|
665
544
|
for (const key of keys) {
|
|
666
|
-
if (!this
|
|
545
|
+
if (!this.#containsColumnWithId(key)) {
|
|
667
546
|
throw new UsageError(
|
|
668
547
|
`Attempted to insert row a cell under column ID "${key}", but the table does not contain a column with that ID.`,
|
|
669
548
|
);
|
|
@@ -694,10 +573,10 @@ export namespace System_TableSchema {
|
|
|
694
573
|
}: TableSchema.SetCellParameters<TCellSchema, TColumnSchema, TRowSchema>): void {
|
|
695
574
|
const { column: columnOrId, row: rowOrId } = key;
|
|
696
575
|
|
|
697
|
-
const row = this
|
|
698
|
-
const column = this
|
|
576
|
+
const row = this.#getRow(rowOrId);
|
|
577
|
+
const column = this.#getColumn(columnOrId);
|
|
699
578
|
|
|
700
|
-
row.
|
|
579
|
+
(row as RowValueInternalType).cells[column.id] = cell as CellValueType;
|
|
701
580
|
}
|
|
702
581
|
|
|
703
582
|
public removeColumns(
|
|
@@ -707,34 +586,28 @@ export namespace System_TableSchema {
|
|
|
707
586
|
if (typeof indexOrColumns === "number" || indexOrColumns === undefined) {
|
|
708
587
|
let removedColumns: ColumnValueType[] | undefined;
|
|
709
588
|
const startIndex = indexOrColumns ?? 0;
|
|
710
|
-
const
|
|
589
|
+
const endIndex = count === undefined ? this.columns.length : startIndex + count;
|
|
711
590
|
|
|
712
591
|
// If there are no columns to remove, do nothing
|
|
713
|
-
if (
|
|
592
|
+
if (startIndex === endIndex) {
|
|
714
593
|
return [];
|
|
715
594
|
}
|
|
716
595
|
|
|
717
|
-
|
|
596
|
+
validateIndexRange(startIndex, endIndex, this.columns, "Table.removeColumns");
|
|
718
597
|
|
|
719
|
-
this
|
|
598
|
+
this.#applyEditsInBatch(() => {
|
|
720
599
|
const columnsToRemove = this.columns.slice(
|
|
721
600
|
startIndex,
|
|
722
|
-
|
|
601
|
+
endIndex,
|
|
723
602
|
) as ColumnValueType[];
|
|
724
603
|
|
|
725
604
|
// First, remove all cells that correspond to each column from each row:
|
|
726
605
|
for (const column of columnsToRemove) {
|
|
727
|
-
this
|
|
606
|
+
this.#removeCells(column);
|
|
728
607
|
}
|
|
729
608
|
|
|
730
609
|
// Second, remove the column nodes:
|
|
731
|
-
Table.
|
|
732
|
-
{
|
|
733
|
-
index: startIndex,
|
|
734
|
-
count: _count,
|
|
735
|
-
},
|
|
736
|
-
this.columns,
|
|
737
|
-
);
|
|
610
|
+
removeRangeFromArray(startIndex, endIndex, this.columns, "Table.removeColumns");
|
|
738
611
|
removedColumns = columnsToRemove;
|
|
739
612
|
});
|
|
740
613
|
return removedColumns ?? fail(0xc1f /* Transaction did not complete. */);
|
|
@@ -749,10 +622,10 @@ export namespace System_TableSchema {
|
|
|
749
622
|
// This improves user-facing error experience.
|
|
750
623
|
const columnsToRemove: ColumnValueType[] = [];
|
|
751
624
|
for (const columnOrIdToRemove of indexOrColumns) {
|
|
752
|
-
columnsToRemove.push(this
|
|
625
|
+
columnsToRemove.push(this.#getColumn(columnOrIdToRemove));
|
|
753
626
|
}
|
|
754
627
|
|
|
755
|
-
this
|
|
628
|
+
this.#applyEditsInBatch(() => {
|
|
756
629
|
// Note, throwing an error within a transaction will abort the entire transaction.
|
|
757
630
|
// So if we throw an error here for any column, no columns will be removed.
|
|
758
631
|
for (const columnToRemove of columnsToRemove) {
|
|
@@ -760,7 +633,10 @@ export namespace System_TableSchema {
|
|
|
760
633
|
for (const row of this.rows) {
|
|
761
634
|
// TypeScript is unable to narrow the row type correctly here, hence the cast.
|
|
762
635
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
763
|
-
|
|
636
|
+
this.removeCell({
|
|
637
|
+
column: columnToRemove,
|
|
638
|
+
row: row as RowValueType,
|
|
639
|
+
});
|
|
764
640
|
}
|
|
765
641
|
|
|
766
642
|
// We have already validated that all of the columns exist above, so this is safe.
|
|
@@ -777,20 +653,14 @@ export namespace System_TableSchema {
|
|
|
777
653
|
): RowValueType[] {
|
|
778
654
|
if (typeof indexOrRows === "number" || indexOrRows === undefined) {
|
|
779
655
|
const startIndex = indexOrRows ?? 0;
|
|
780
|
-
const
|
|
656
|
+
const endIndex = count === undefined ? this.columns.length : startIndex + count;
|
|
781
657
|
|
|
782
658
|
// If there are no rows to remove, do nothing
|
|
783
|
-
if (
|
|
659
|
+
if (startIndex === endIndex) {
|
|
784
660
|
return [];
|
|
785
661
|
}
|
|
786
662
|
|
|
787
|
-
return Table.
|
|
788
|
-
{
|
|
789
|
-
index: startIndex,
|
|
790
|
-
count: _count,
|
|
791
|
-
},
|
|
792
|
-
this.rows,
|
|
793
|
-
);
|
|
663
|
+
return removeRangeFromArray(startIndex, endIndex, this.rows, "Table.removeRows");
|
|
794
664
|
}
|
|
795
665
|
|
|
796
666
|
// If there are no rows to remove, do nothing
|
|
@@ -803,10 +673,10 @@ export namespace System_TableSchema {
|
|
|
803
673
|
// This improves user-facing error experience.
|
|
804
674
|
const rowsToRemove: RowValueType[] = [];
|
|
805
675
|
for (const rowToRemove of indexOrRows) {
|
|
806
|
-
rowsToRemove.push(this
|
|
676
|
+
rowsToRemove.push(this.#getRow(rowToRemove));
|
|
807
677
|
}
|
|
808
678
|
|
|
809
|
-
this
|
|
679
|
+
this.#applyEditsInBatch(() => {
|
|
810
680
|
// Note, throwing an error within a transaction will abort the entire transaction.
|
|
811
681
|
// So if we throw an error here for any row, no rows will be removed.
|
|
812
682
|
for (const rowToRemove of rowsToRemove) {
|
|
@@ -822,48 +692,30 @@ export namespace System_TableSchema {
|
|
|
822
692
|
key: TableSchema.CellKey<TColumnSchema, TRowSchema>,
|
|
823
693
|
): CellValueType | undefined {
|
|
824
694
|
const { column: columnOrIdOrIndex, row: rowOrIdOrIndex } = key;
|
|
825
|
-
const row = this
|
|
826
|
-
const column = this
|
|
695
|
+
const row = this.#getRow(rowOrIdOrIndex) as RowValueInternalType;
|
|
696
|
+
const column = this.#getColumn(columnOrIdOrIndex);
|
|
827
697
|
|
|
828
|
-
const cell: CellValueType | undefined = row.
|
|
698
|
+
const cell: CellValueType | undefined = row.cells[column.id];
|
|
829
699
|
if (cell === undefined) {
|
|
830
700
|
return undefined;
|
|
831
701
|
}
|
|
832
702
|
|
|
833
|
-
|
|
703
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
704
|
+
delete row.cells[column.id];
|
|
834
705
|
return cell;
|
|
835
706
|
}
|
|
836
707
|
|
|
837
708
|
/**
|
|
838
709
|
* Removes the cell corresponding with the specified column from each row in the table.
|
|
839
710
|
*/
|
|
840
|
-
|
|
711
|
+
#removeCells(column: ColumnValueType): void {
|
|
841
712
|
for (const row of this.rows) {
|
|
842
713
|
// TypeScript is unable to narrow the row type correctly here, hence the cast.
|
|
843
714
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
private static _assertValidRange<T>(
|
|
849
|
-
range: { index: number; count: number },
|
|
850
|
-
array: readonly T[],
|
|
851
|
-
): void {
|
|
852
|
-
const { index, count } = range;
|
|
853
|
-
if (index < 0 || index >= array.length) {
|
|
854
|
-
throw new UsageError(
|
|
855
|
-
`Start index out of bounds. Expected index to be on [0, ${array.length - 1}], but got ${index}.`,
|
|
856
|
-
);
|
|
857
|
-
}
|
|
858
|
-
if (count < 0) {
|
|
859
|
-
throw new UsageError(`Expected non-negative count. Got ${count}.`);
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
const end = index + count; // exclusive
|
|
863
|
-
if (end > array.length) {
|
|
864
|
-
throw new UsageError(
|
|
865
|
-
`End index out of bounds. Expected end to be on [${index}, ${array.length}], but got ${end}.`,
|
|
866
|
-
);
|
|
715
|
+
this.removeCell({
|
|
716
|
+
column,
|
|
717
|
+
row: row as RowValueType,
|
|
718
|
+
});
|
|
867
719
|
}
|
|
868
720
|
}
|
|
869
721
|
|
|
@@ -876,7 +728,7 @@ export namespace System_TableSchema {
|
|
|
876
728
|
* Transactions are not supported for unhydrated trees, so we cannot run a transaction in that case.
|
|
877
729
|
* But since there are no collaborators, this is not an issue.
|
|
878
730
|
*/
|
|
879
|
-
|
|
731
|
+
#applyEditsInBatch(applyEdits: () => void): void {
|
|
880
732
|
const branch = TreeAlpha.branch(this);
|
|
881
733
|
|
|
882
734
|
// Ensure events are paused until all of the edits are applied.
|
|
@@ -901,7 +753,7 @@ export namespace System_TableSchema {
|
|
|
901
753
|
* Returns `undefined` if there is no match.
|
|
902
754
|
* @remarks Searches for a match based strictly on the ID and returns that result.
|
|
903
755
|
*/
|
|
904
|
-
|
|
756
|
+
#tryGetColumn(
|
|
905
757
|
columnOrIdOrIndex: ColumnValueType | string | number,
|
|
906
758
|
): ColumnValueType | undefined {
|
|
907
759
|
if (typeof columnOrIdOrIndex === "number") {
|
|
@@ -935,10 +787,8 @@ export namespace System_TableSchema {
|
|
|
935
787
|
* @throws Throws a `UsageError` if there is no match.
|
|
936
788
|
* @remarks Searches for a match based strictly on the ID and returns that result.
|
|
937
789
|
*/
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
): ColumnValueType {
|
|
941
|
-
const column = this._tryGetColumn(columnOrIdOrIndex);
|
|
790
|
+
#getColumn(columnOrIdOrIndex: ColumnValueType | string | number): ColumnValueType {
|
|
791
|
+
const column = this.#tryGetColumn(columnOrIdOrIndex);
|
|
942
792
|
if (column === undefined) {
|
|
943
793
|
Table._throwMissingColumnError(columnOrIdOrIndex);
|
|
944
794
|
}
|
|
@@ -948,8 +798,8 @@ export namespace System_TableSchema {
|
|
|
948
798
|
/**
|
|
949
799
|
* Checks if a Column with the specified ID exists in the table.
|
|
950
800
|
*/
|
|
951
|
-
|
|
952
|
-
return this
|
|
801
|
+
#containsColumnWithId(columnId: string): boolean {
|
|
802
|
+
return this.#tryGetColumn(columnId) !== undefined;
|
|
953
803
|
}
|
|
954
804
|
|
|
955
805
|
/**
|
|
@@ -978,9 +828,7 @@ export namespace System_TableSchema {
|
|
|
978
828
|
* Returns `undefined` if there is no match.
|
|
979
829
|
* @remarks Searches for a match based strictly on the ID and returns that result.
|
|
980
830
|
*/
|
|
981
|
-
|
|
982
|
-
rowOrIdOrIndex: RowValueType | string | number,
|
|
983
|
-
): RowValueType | undefined {
|
|
831
|
+
#tryGetRow(rowOrIdOrIndex: RowValueType | string | number): RowValueType | undefined {
|
|
984
832
|
if (typeof rowOrIdOrIndex === "number") {
|
|
985
833
|
if (rowOrIdOrIndex < 0 || rowOrIdOrIndex >= this.rows.length) {
|
|
986
834
|
return undefined;
|
|
@@ -1012,8 +860,8 @@ export namespace System_TableSchema {
|
|
|
1012
860
|
* @throws Throws a `UsageError` if there is no match.
|
|
1013
861
|
* @remarks Searches for a match based strictly on the ID and returns that result.
|
|
1014
862
|
*/
|
|
1015
|
-
|
|
1016
|
-
const row = this
|
|
863
|
+
#getRow(rowOrIdOrIndex: RowValueType | string | number): RowValueType {
|
|
864
|
+
const row = this.#tryGetRow(rowOrIdOrIndex);
|
|
1017
865
|
if (row === undefined) {
|
|
1018
866
|
Table._throwMissingRowError(rowOrIdOrIndex);
|
|
1019
867
|
}
|
|
@@ -1038,47 +886,6 @@ export namespace System_TableSchema {
|
|
|
1038
886
|
`The specified row node with ID "${rowOrIdOrIndex.id}" does not exist in the table.`,
|
|
1039
887
|
);
|
|
1040
888
|
}
|
|
1041
|
-
|
|
1042
|
-
private static _removeRange<TNodeSchema extends ImplicitAllowedTypes>(
|
|
1043
|
-
range: { index: number; count: number },
|
|
1044
|
-
array: TreeArrayNode<TNodeSchema>,
|
|
1045
|
-
): TreeNodeFromImplicitAllowedTypes<TNodeSchema>[] {
|
|
1046
|
-
Table._assertValidRange(range, array);
|
|
1047
|
-
|
|
1048
|
-
const { index, count } = range;
|
|
1049
|
-
const end = index + count; // exclusive
|
|
1050
|
-
|
|
1051
|
-
// TypeScript is unable to narrow the array element type correctly here, hence the cast.
|
|
1052
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
1053
|
-
const removedRows = array.slice(
|
|
1054
|
-
index,
|
|
1055
|
-
end,
|
|
1056
|
-
) as TreeNodeFromImplicitAllowedTypes<TNodeSchema>[];
|
|
1057
|
-
array.removeRange(index, end);
|
|
1058
|
-
|
|
1059
|
-
return removedRows;
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
/**
|
|
1063
|
-
* Ensure that the specified index is a valid location for item insertion in the destination list.
|
|
1064
|
-
* @throws Throws a usage error if the destination is invalid.
|
|
1065
|
-
*/
|
|
1066
|
-
private static validateInsertionIndex(
|
|
1067
|
-
index: number,
|
|
1068
|
-
destinationList: readonly unknown[],
|
|
1069
|
-
): void {
|
|
1070
|
-
if (index < 0) {
|
|
1071
|
-
throw new UsageError("The index must be greater than or equal to 0.");
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
if (index > destinationList.length) {
|
|
1075
|
-
throw new UsageError("The index specified for insertion is out of bounds.");
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
if (!Number.isInteger(index)) {
|
|
1079
|
-
throw new UsageError("The index must be an integer.");
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
889
|
}
|
|
1083
890
|
|
|
1084
891
|
// Set a private symbol on the schema class that marks it as having been generated by this factory.
|
|
@@ -1131,6 +938,29 @@ export namespace System_TableSchema {
|
|
|
1131
938
|
// #endregion
|
|
1132
939
|
}
|
|
1133
940
|
|
|
941
|
+
/**
|
|
942
|
+
* Removes the specified range of elements from the array.
|
|
943
|
+
* @returns The removed elements.
|
|
944
|
+
*/
|
|
945
|
+
function removeRangeFromArray<TNodeSchema extends ImplicitAllowedTypes>(
|
|
946
|
+
startIndex: number,
|
|
947
|
+
endIndex: number,
|
|
948
|
+
array: TreeArrayNode<TNodeSchema>,
|
|
949
|
+
methodName: string,
|
|
950
|
+
): TreeNodeFromImplicitAllowedTypes<TNodeSchema>[] {
|
|
951
|
+
validateIndexRange(startIndex, endIndex, array, methodName);
|
|
952
|
+
|
|
953
|
+
// TypeScript is unable to narrow the array element type correctly here, hence the cast.
|
|
954
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
955
|
+
const removedRows = array.slice(
|
|
956
|
+
startIndex,
|
|
957
|
+
endIndex,
|
|
958
|
+
) as TreeNodeFromImplicitAllowedTypes<TNodeSchema>[];
|
|
959
|
+
array.removeRange(startIndex, endIndex);
|
|
960
|
+
|
|
961
|
+
return removedRows;
|
|
962
|
+
}
|
|
963
|
+
|
|
1134
964
|
/**
|
|
1135
965
|
* Contains types and factories for creating schema to represent dynamic tabular data.
|
|
1136
966
|
*
|
|
@@ -1256,6 +1086,7 @@ export namespace TableSchema {
|
|
|
1256
1086
|
* @sealed @alpha
|
|
1257
1087
|
*/
|
|
1258
1088
|
export interface Column<
|
|
1089
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Reserving this for future use.
|
|
1259
1090
|
TCell extends ImplicitAllowedTypes,
|
|
1260
1091
|
TProps extends ImplicitFieldSchema = ImplicitFieldSchema,
|
|
1261
1092
|
> {
|
|
@@ -1274,15 +1105,6 @@ export namespace TableSchema {
|
|
|
1274
1105
|
*/
|
|
1275
1106
|
get props(): TreeFieldFromImplicitField<TProps>;
|
|
1276
1107
|
set props(value: InsertableTreeFieldFromImplicitField<TProps>);
|
|
1277
|
-
|
|
1278
|
-
/**
|
|
1279
|
-
* Gets all of the populated cells in the column, keyed by their associated row IDs.
|
|
1280
|
-
* @throws Throws an error if the column is not in a table.
|
|
1281
|
-
*/
|
|
1282
|
-
getCells(): readonly {
|
|
1283
|
-
rowId: string;
|
|
1284
|
-
cell: TreeNodeFromImplicitAllowedTypes<TCell>;
|
|
1285
|
-
}[];
|
|
1286
1108
|
}
|
|
1287
1109
|
|
|
1288
1110
|
/**
|
|
@@ -1326,7 +1148,7 @@ export namespace TableSchema {
|
|
|
1326
1148
|
}: System_TableSchema.CreateColumnOptionsBase & {
|
|
1327
1149
|
readonly props?: ImplicitFieldSchema;
|
|
1328
1150
|
}): TreeNodeSchema {
|
|
1329
|
-
return System_TableSchema.createColumnSchema(schemaFactory,
|
|
1151
|
+
return System_TableSchema.createColumnSchema(schemaFactory, props);
|
|
1330
1152
|
}
|
|
1331
1153
|
|
|
1332
1154
|
// #endregion
|
|
@@ -1341,6 +1163,7 @@ export namespace TableSchema {
|
|
|
1341
1163
|
* @sealed @alpha
|
|
1342
1164
|
*/
|
|
1343
1165
|
export interface Row<
|
|
1166
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Reserving this for future use.
|
|
1344
1167
|
TCell extends ImplicitAllowedTypes,
|
|
1345
1168
|
TProps extends ImplicitFieldSchema = ImplicitFieldSchema,
|
|
1346
1169
|
> {
|
|
@@ -1350,53 +1173,6 @@ export namespace TableSchema {
|
|
|
1350
1173
|
*/
|
|
1351
1174
|
readonly id: string;
|
|
1352
1175
|
|
|
1353
|
-
/**
|
|
1354
|
-
* Gets the cell in the specified column.
|
|
1355
|
-
* @returns The cell if it exists, otherwise undefined.
|
|
1356
|
-
* @privateRemarks TODO: throw if the column does not belong to the same table as the row.
|
|
1357
|
-
*/
|
|
1358
|
-
getCell(column: Column<TCell>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
1359
|
-
/**
|
|
1360
|
-
* Gets the cell in the specified column, denoted by column ID.
|
|
1361
|
-
* @returns The cell if it exists, otherwise undefined.
|
|
1362
|
-
*/
|
|
1363
|
-
getCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
1364
|
-
|
|
1365
|
-
/**
|
|
1366
|
-
* Gets all of the populated cells in the row, keyed by their associated column IDs.
|
|
1367
|
-
*/
|
|
1368
|
-
getCells(): readonly {
|
|
1369
|
-
columnId: string;
|
|
1370
|
-
cell: TreeNodeFromImplicitAllowedTypes<TCell>;
|
|
1371
|
-
}[];
|
|
1372
|
-
|
|
1373
|
-
/**
|
|
1374
|
-
* Sets the cell in the specified column.
|
|
1375
|
-
* @remarks To remove a cell, call {@link TableSchema.Row.(removeCell:1)} instead.
|
|
1376
|
-
* @privateRemarks TODO: Throw an error if the column does not exist in the table.
|
|
1377
|
-
*/
|
|
1378
|
-
setCell(
|
|
1379
|
-
column: Column<TCell>,
|
|
1380
|
-
value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>,
|
|
1381
|
-
): void;
|
|
1382
|
-
/**
|
|
1383
|
-
* Sets the cell in the specified column, denoted by column ID.
|
|
1384
|
-
* @remarks To remove a cell, call {@link TableSchema.Row.(removeCell:2)} instead.
|
|
1385
|
-
*/
|
|
1386
|
-
setCell(columnId: string, value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>): void;
|
|
1387
|
-
|
|
1388
|
-
/**
|
|
1389
|
-
* Removes the cell in the specified column.
|
|
1390
|
-
* @returns The cell if it exists, otherwise undefined.
|
|
1391
|
-
* @privateRemarks TODO: Throw if the column does not belong to the same table as the row.
|
|
1392
|
-
*/
|
|
1393
|
-
removeCell(column: Column<TCell>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
1394
|
-
/**
|
|
1395
|
-
* Removes the cell in the specified column, denoted by column ID.
|
|
1396
|
-
* @returns The cell if it exists, otherwise undefined.
|
|
1397
|
-
*/
|
|
1398
|
-
removeCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
1399
|
-
|
|
1400
1176
|
/**
|
|
1401
1177
|
* The row's properties.
|
|
1402
1178
|
* @remarks This is a user-defined schema that can be used to store additional information about the row.
|