@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
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Validates that the provided index is a safe integer.
|
|
10
|
+
* @throws If the index is invalid.
|
|
11
|
+
* @param index - The index to validate.
|
|
12
|
+
* @param apiName - The name of the API performing the validation.
|
|
13
|
+
* @throws If the index is invalid.
|
|
14
|
+
*/
|
|
15
|
+
export function validateSafeInteger(index: number, apiName: string): void {
|
|
16
|
+
if (!Number.isSafeInteger(index)) {
|
|
17
|
+
throw new UsageError(`Expected a safe integer passed to ${apiName}, got ${index}.`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Validates that the provided index is a 0 or greater safe integer.
|
|
23
|
+
* @param index - The index to validate.
|
|
24
|
+
* @param apiName - The name of the API performing the validation.
|
|
25
|
+
* @throws If the index is invalid.
|
|
26
|
+
*/
|
|
27
|
+
export function validatePositiveIndex(index: number, apiName: string): void {
|
|
28
|
+
validateSafeInteger(index, apiName);
|
|
29
|
+
if (index < 0) {
|
|
30
|
+
throw new UsageError(`Expected non-negative index passed to ${apiName}, got ${index}.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Validates that the provided index is a non-negative safe integer within the bounds of the provided array (or, optionally, 1 past its end).
|
|
36
|
+
* @throws If the index is invalid.
|
|
37
|
+
* @param index - The index to validate.
|
|
38
|
+
* @param array - The array to validate against.
|
|
39
|
+
* @param apiName - The name of the API performing the validation.
|
|
40
|
+
* @param allowOnePastEnd - Whether to allow the index to be one past the end of the array.
|
|
41
|
+
*/
|
|
42
|
+
export function validateIndex(
|
|
43
|
+
index: number,
|
|
44
|
+
array: { readonly length: number },
|
|
45
|
+
apiName: string,
|
|
46
|
+
allowOnePastEnd: boolean = false,
|
|
47
|
+
): void {
|
|
48
|
+
validatePositiveIndex(index, apiName);
|
|
49
|
+
if (allowOnePastEnd) {
|
|
50
|
+
if (index > array.length) {
|
|
51
|
+
throw new UsageError(
|
|
52
|
+
`Index value passed to ${apiName} is out of bounds. Expected at most ${array.length}, got ${index}.`,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
if (index >= array.length) {
|
|
57
|
+
throw new UsageError(
|
|
58
|
+
`Index value passed to ${apiName} is out of bounds. Expected at most ${array.length - 1}, got ${index}.`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Validates that the provided range `[startIndex, endIndex)` is valid and within the bounds of the provided array.
|
|
66
|
+
* @remarks
|
|
67
|
+
* This is intended for ranges which are inclusive for the lower bound, and exclusive for the upper bound,
|
|
68
|
+
* and permits 0 length ranges, even `[array.length, array.length)`.
|
|
69
|
+
* @throws If the index is invalid.
|
|
70
|
+
* @param startIndex - The index that starts the range (inclusive).
|
|
71
|
+
* @param endIndex - The index that ends the range (exclusive).
|
|
72
|
+
* @param array - The array to validate against.
|
|
73
|
+
* @param apiName - The name of the API performing the validation.
|
|
74
|
+
*/
|
|
75
|
+
export function validateIndexRange(
|
|
76
|
+
startIndex: number,
|
|
77
|
+
endIndex: number,
|
|
78
|
+
array: { readonly length: number },
|
|
79
|
+
apiName: string,
|
|
80
|
+
): void {
|
|
81
|
+
if (startIndex > endIndex) {
|
|
82
|
+
throw new UsageError(
|
|
83
|
+
`Malformed range passed to ${apiName}. Start index ${startIndex} is greater than end index ${endIndex}.`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
validateIndex(startIndex, array, apiName, true);
|
|
87
|
+
validateIndex(endIndex, array, apiName, true);
|
|
88
|
+
}
|
package/src/util/index.ts
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { FullSchemaPolicy } from "../modular-schema/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* FullSchemaPolicy with the default field kinds.
|
|
8
|
-
*/
|
|
9
|
-
export declare const defaultSchemaPolicy: FullSchemaPolicy;
|
|
10
|
-
//# sourceMappingURL=defaultSchema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaultSchema.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/defaultSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAInE;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,gBAEjC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.defaultSchemaPolicy = void 0;
|
|
8
|
-
const defaultFieldKinds_js_1 = require("./defaultFieldKinds.js");
|
|
9
|
-
/**
|
|
10
|
-
* FullSchemaPolicy with the default field kinds.
|
|
11
|
-
*/
|
|
12
|
-
exports.defaultSchemaPolicy = {
|
|
13
|
-
fieldKinds: defaultFieldKinds_js_1.fieldKinds,
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=defaultSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaultSchema.js","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/defaultSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,iEAAoD;AAEpD;;GAEG;AACU,QAAA,mBAAmB,GAAqB;IACpD,UAAU,EAAV,iCAAU;CACV,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { FullSchemaPolicy } from \"../modular-schema/index.js\";\n\nimport { fieldKinds } from \"./defaultFieldKinds.js\";\n\n/**\n * FullSchemaPolicy with the default field kinds.\n */\nexport const defaultSchemaPolicy: FullSchemaPolicy = {\n\tfieldKinds,\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemaChecker.d.ts","sour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
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemaChecker.js","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/schemaChecker.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA4E;AAC5E,uEAAsE;AAEtE,kDAO6B;AAC7B,4DAAmD;AAEnD,kDAAmE;AAEnE,IAAY,qBAWX;AAXD,WAAY,qBAAqB;IAChC,+GAA2B,CAAA;IAC3B,6GAA0B,CAAA;IAC1B,yHAAgC,CAAA;IAChC,+GAA2B,CAAA;IAC3B,yGAAwB,CAAA;IACxB,mGAAqB,CAAA;IACrB,2GAAyB,CAAA;IACzB,+GAA2B,CAAA;IAC3B,+GAA2B,CAAA;IAC3B,6FAAkB,CAAA;AACnB,CAAC,EAXW,qBAAqB,qCAArB,qBAAqB,QAWhC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,UAAiC;IACjE,MAAM,IAAI,qBAAU,CACnB,oCAAoC,qBAAqB,CAAC,UAAU,CAAC,EAAE,CACvE,CAAC;AACH,CAAC;AAJD,4CAIC;AAID;;;;;;GAMG;AACH,SAAgB,cAAc,CAC7B,IAA4B,EAC5B,eAAgC,EAChC,OAA4C;IAE5C,kDAAkD;IAClD,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAC1D,CAAC;IAED,2DAA2D;IAE3D,IAAI,MAAM,YAAY,+BAAoB,EAAE,CAAC;QAC5C,IAAI,IAAA,0BAAe,EAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,OAAO,OAAO,CAAC,qBAAqB,CAAC,yBAAyB,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,CAAC,IAAA,+BAAW,EAAC,MAAM,CAAC,SAAS,EA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,OAAO,CAAC,CAAC;QAC1E,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;YACtC,OAAO,kBAAkB,CAAC;QAC3B,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC;AAlCD,0CAkCC;AAED;;;;;GAKG;AACH,SAAgB,wBAAwB,CACvC,aAAqB,EACrB,YAA0B;IAE1B,QAAQ,YAAY,EAAE,CAAC;QACtB,KAAK,uBAAY,CAAC,MAAM;YACvB,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;gBACvB,OAAO,qBAAqB,CAAC,0BAA0B,CAAC;YACzD,CAAC;iBAAM,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;gBAC9B,OAAO,qBAAqB,CAAC,gCAAgC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACP,OAAO,SAAS,CAAC;YAClB,CAAC;QACF,KAAK,uBAAY,CAAC,QAAQ;YACzB,OAAO,aAAa,GAAG,CAAC;gBACvB,CAAC,CAAC,qBAAqB,CAAC,gCAAgC;gBACxD,CAAC,CAAC,SAAS,CAAC;QACd,KAAK,uBAAY,CAAC,QAAQ;YACzB,OAAO,SAAS,CAAC;QAClB,KAAK,uBAAY,CAAC,SAAS;YAC1B,OAAO,aAAa,KAAK,CAAC;gBACzB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,qBAAqB,CAAC,2BAA2B,CAAC;QACtD;YACC,IAAA,0BAAe,EAAC,YAAY,CAAC,CAAC;IAChC,CAAC;AACF,CAAC;AA1BD,4DA0BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype TreeFieldStoredSchema,\n\tLeafNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tMultiplicity,\n\ttype SchemaAndPolicy,\n} from \"../../core/index.js\";\nimport { allowsValue } from \"../valueUtilities.js\";\nimport type { MapTreeFieldViewGeneric, MinimalMapTreeNodeView } from \"../mapTreeCursor.js\";\nimport { iterableHasSome, mapIterable } from \"../../util/index.js\";\n\nexport enum SchemaValidationError {\n\tField_KindNotInSchemaPolicy,\n\tField_MissingRequiredChild,\n\tField_MultipleChildrenNotAllowed,\n\tField_ChildInForbiddenField,\n\tField_NodeTypeNotAllowed,\n\tLeafNode_InvalidValue,\n\tLeafNode_FieldsNotAllowed,\n\tObjectNode_FieldNotInSchema,\n\tNonLeafNode_ValueNotAllowed,\n\tNode_MissingSchema,\n}\n\n/**\n * Throws a UsageError indicating a tree is out of schema.\n */\nexport function throwOutOfSchema(maybeError: SchemaValidationError): never {\n\tthrow new UsageError(\n\t\t`Tree does not conform to schema: ${SchemaValidationError[maybeError]}`,\n\t);\n}\n\ntype NotUndefined = number | string | boolean | bigint | symbol | object;\n\n/**\n * Deeply checks that the provided node complies with the schema based on its identifier.\n *\n * @param onError - Called with the first error (if any).\n *\n * @returns the return value from `onError` if the node or anything inside of it is out of schema, otherwise `undefined`.\n */\nexport function isNodeInSchema<T extends NotUndefined>(\n\tnode: MinimalMapTreeNodeView,\n\tschemaAndPolicy: SchemaAndPolicy,\n\tonError: (error: SchemaValidationError) => T,\n): T | undefined {\n\t// Validate the schema declared by the node exists\n\tconst schema = schemaAndPolicy.schema.nodeSchema.get(node.type);\n\tif (schema === undefined) {\n\t\treturn onError(SchemaValidationError.Node_MissingSchema);\n\t}\n\n\t// Validate the node is well formed according to its schema\n\n\tif (schema instanceof LeafNodeStoredSchema) {\n\t\tif (iterableHasSome(node.fields)) {\n\t\t\treturn onError(SchemaValidationError.LeafNode_FieldsNotAllowed);\n\t\t}\n\t\tif (!allowsValue(schema.leafValue, node.value)) {\n\t\t\treturn onError(SchemaValidationError.LeafNode_InvalidValue);\n\t\t}\n\t} else {\n\t\tif (node.value !== undefined) {\n\t\t\treturn onError(SchemaValidationError.NonLeafNode_ValueNotAllowed);\n\t\t}\n\n\t\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\t\tconst uncheckedFieldsFromNode = new Set(mapIterable(node.fields, ([key, field]) => key));\n\t\t\tfor (const [fieldKey, fieldSchema] of schema.objectNodeFields) {\n\t\t\t\tconst nodeField = node.fields.get(fieldKey) ?? [];\n\t\t\t\tconst fieldInSchemaResult = isFieldInSchema(\n\t\t\t\t\tnodeField,\n\t\t\t\t\tfieldSchema,\n\t\t\t\t\tschemaAndPolicy,\n\t\t\t\t\tonError,\n\t\t\t\t);\n\t\t\t\tif (fieldInSchemaResult !== undefined) {\n\t\t\t\t\treturn fieldInSchemaResult;\n\t\t\t\t}\n\t\t\t\tuncheckedFieldsFromNode.delete(fieldKey);\n\t\t\t}\n\t\t\t// The node has fields that we did not check as part of looking at every field defined in the node's schema.\n\t\t\t// Since this is testing compatibility with a stored schema (not view schema), \"allowUnknownOptionalFields\" does not exist at this layer.\n\t\t\t// Code using this with a stored schema derived from a view schema rather than the document can be problematic because it may be missing unknown fields that the actual document has.\n\t\t\t// Other schema evolution features like \"staged\" allowed types will likely cause similar issues elsewhere in this checker.\n\t\t\tif (uncheckedFieldsFromNode.size !== 0) {\n\t\t\t\treturn onError(SchemaValidationError.ObjectNode_FieldNotInSchema);\n\t\t\t}\n\t\t} else if (schema instanceof MapNodeStoredSchema) {\n\t\t\tfor (const [_key, field] of node.fields) {\n\t\t\t\tconst fieldInSchemaResult = isFieldInSchema(\n\t\t\t\t\tfield,\n\t\t\t\t\tschema.mapFields,\n\t\t\t\t\tschemaAndPolicy,\n\t\t\t\t\tonError,\n\t\t\t\t);\n\t\t\t\tif (fieldInSchemaResult !== undefined) {\n\t\t\t\t\treturn fieldInSchemaResult;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfail(0xb0e /* Unknown TreeNodeStoredSchema type */);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Deeply checks that the nodes comply with the field schema and included schema.\n *\n * @param onError - Called with the first error (if any).\n *\n * @returns the return value from `onError` if the field or anything inside of it is out of schema, otherwise `undefined`.\n */\nexport function isFieldInSchema<T extends NotUndefined>(\n\tchildNodes: MapTreeFieldViewGeneric<MinimalMapTreeNodeView>,\n\tschema: TreeFieldStoredSchema,\n\tschemaAndPolicy: SchemaAndPolicy,\n\tonError: (error: SchemaValidationError) => T,\n): T | undefined {\n\t// Validate that the field kind is handled by the schema policy\n\tconst kind = schemaAndPolicy.policy.fieldKinds.get(schema.kind);\n\tif (kind === undefined) {\n\t\treturn onError(SchemaValidationError.Field_KindNotInSchemaPolicy);\n\t}\n\n\t// Validate that the field doesn't contain more nodes than its type supports\n\t{\n\t\tconst multiplicityCheck = compliesWithMultiplicity(childNodes.length, kind.multiplicity);\n\t\tif (multiplicityCheck !== undefined) {\n\t\t\treturn onError(multiplicityCheck);\n\t\t}\n\t}\n\n\tfor (const node of childNodes) {\n\t\t// Validate the type declared by the node is allowed in this field\n\t\tif (schema.types !== undefined && !schema.types.has(node.type)) {\n\t\t\treturn onError(SchemaValidationError.Field_NodeTypeNotAllowed);\n\t\t}\n\n\t\t// Validate the node complies with the type it declares to be.\n\t\tconst nodeInSchemaResult = isNodeInSchema(node, schemaAndPolicy, onError);\n\t\tif (nodeInSchemaResult !== undefined) {\n\t\t\treturn nodeInSchemaResult;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Validates that a given number of items complies with the specified {@link Multiplicity | multiplicity}.\n * @param numberOfItems - Number of items.\n * @param multiplicity - Kind of multiplicity to validate against.\n * @returns `true` if the specified number of items complies with the specified multiplicity; otherwise, `false`.\n */\nexport function compliesWithMultiplicity(\n\tnumberOfItems: number,\n\tmultiplicity: Multiplicity,\n): SchemaValidationError | undefined {\n\tswitch (multiplicity) {\n\t\tcase Multiplicity.Single:\n\t\t\tif (numberOfItems < 1) {\n\t\t\t\treturn SchemaValidationError.Field_MissingRequiredChild;\n\t\t\t} else if (numberOfItems > 1) {\n\t\t\t\treturn SchemaValidationError.Field_MultipleChildrenNotAllowed;\n\t\t\t} else {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\tcase Multiplicity.Optional:\n\t\t\treturn numberOfItems > 1\n\t\t\t\t? SchemaValidationError.Field_MultipleChildrenNotAllowed\n\t\t\t\t: undefined;\n\t\tcase Multiplicity.Sequence:\n\t\t\treturn undefined;\n\t\tcase Multiplicity.Forbidden:\n\t\t\treturn numberOfItems === 0\n\t\t\t\t? undefined\n\t\t\t\t: SchemaValidationError.Field_ChildInForbiddenField;\n\t\tdefault:\n\t\t\tunreachableCase(multiplicity);\n\t}\n}\n"]}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { FieldKindIdentifier, TreeFieldStoredSchema, TreeStoredSchema, TreeTypeSet, Multiplicity } from "../../core/index.js";
|
|
6
|
-
import type { FieldChangeHandler, FieldEditor } from "./fieldChangeHandler.js";
|
|
7
|
-
import { FlexFieldKind, type FullSchemaPolicy } from "./fieldKind.js";
|
|
8
|
-
/**
|
|
9
|
-
* Functionality for FieldKinds that is stable,
|
|
10
|
-
* meaning that it can not change in any measurable way without providing a new identifier.
|
|
11
|
-
*
|
|
12
|
-
* It is assumed that this information and policy is available on all clients interacting with a document
|
|
13
|
-
* using the identifier.
|
|
14
|
-
*
|
|
15
|
-
* This must contain enough information to process remote edits to this FieldKind consistently with all clients.
|
|
16
|
-
* All behavior must be deterministic, and not change across versions of the app/library.
|
|
17
|
-
*
|
|
18
|
-
* These policies include the data encoding, change encoding, change rebase and change application.
|
|
19
|
-
*/
|
|
20
|
-
export declare class FieldKindWithEditor<TEditor extends FieldEditor<any> = FieldEditor<any>, TMultiplicity extends Multiplicity = Multiplicity, TName extends string = string> extends FlexFieldKind<TName, TMultiplicity> {
|
|
21
|
-
readonly changeHandler: FieldChangeHandler<any, TEditor>;
|
|
22
|
-
private readonly allowsTreeSupersetOf;
|
|
23
|
-
readonly handlesEditsFrom: ReadonlySet<FieldKindIdentifier>;
|
|
24
|
-
/**
|
|
25
|
-
* @param identifier - Globally scoped identifier.
|
|
26
|
-
* @param multiplicity - bound on the number of children that fields of this kind may have.
|
|
27
|
-
* TODO: replace with numeric upper and lower bounds.
|
|
28
|
-
* @param changeHandler - Change handling policy.
|
|
29
|
-
* @param allowsTreeSupersetOf - returns true iff `superset` supports all that this does
|
|
30
|
-
* and `superset` is an allowed upgrade. Does not have to handle the `never` cases.
|
|
31
|
-
* See {@link isNeverField}.
|
|
32
|
-
* TODO: when used as a method (instead of a free function like the other superset related functions),
|
|
33
|
-
* this name is/signature is confusing and seems backwards.
|
|
34
|
-
* @param handlesEditsFrom - Kinds (in addition to this) whose edits can be processed by changeHandler.
|
|
35
|
-
* If the kind of a field changes, and edits are rebased across that kind change,
|
|
36
|
-
* listing the other old kind here can prevent those edits from being conflicted and
|
|
37
|
-
* provide a chance to handle them.
|
|
38
|
-
*/
|
|
39
|
-
constructor(identifier: TName, multiplicity: TMultiplicity, changeHandler: FieldChangeHandler<any, TEditor>, allowsTreeSupersetOf: (originalTypes: TreeTypeSet, superset: TreeFieldStoredSchema) => boolean, handlesEditsFrom: ReadonlySet<FieldKindIdentifier>);
|
|
40
|
-
/**
|
|
41
|
-
* Returns true if and only if `superset` permits a (non-strict) superset of the subtrees
|
|
42
|
-
* allowed by field made from `this` and `originalTypes`.
|
|
43
|
-
*/
|
|
44
|
-
allowsFieldSuperset(policy: FullSchemaPolicy, originalData: TreeStoredSchema, originalTypes: TreeTypeSet, superset: TreeFieldStoredSchema): boolean;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Downcasts to {@link FieldKindWithEditor}.
|
|
48
|
-
*/
|
|
49
|
-
export declare function withEditor<TName extends string = string, TMultiplicity extends Multiplicity = Multiplicity>(kind: FlexFieldKind<TName, TMultiplicity>): FieldKindWithEditor<FieldEditor<any>, TMultiplicity, TName>;
|
|
50
|
-
//# sourceMappingURL=fieldKindWithEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fieldKindWithEditor.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/fieldKindWithEditor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EACX,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMtE;;;;;;;;;;;GAWG;AACH,qBAAa,mBAAmB,CAC/B,OAAO,SAAS,WAAW,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EACnD,aAAa,SAAS,YAAY,GAAG,YAAY,EACjD,KAAK,SAAS,MAAM,GAAG,MAAM,CAC5B,SAAQ,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC;aAmB3B,aAAa,EAAE,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC;IAC/D,OAAO,CAAC,QAAQ,CAAC,oBAAoB;aAIrB,gBAAgB,EAAE,WAAW,CAAC,mBAAmB,CAAC;IAvBnE;;;;;;;;;;;;;;OAcG;gBAEF,UAAU,EAAE,KAAK,EACjB,YAAY,EAAE,aAAa,EACX,aAAa,EAAE,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,EAC9C,oBAAoB,EAAE,CACtC,aAAa,EAAE,WAAW,EAC1B,QAAQ,EAAE,qBAAqB,KAC3B,OAAO,EACI,gBAAgB,EAAE,WAAW,CAAC,mBAAmB,CAAC;IAKnE;;;OAGG;IACI,mBAAmB,CACzB,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,WAAW,EAC1B,QAAQ,EAAE,qBAAqB,GAC7B,OAAO;CAgBV;AAED;;GAEG;AACH,wBAAgB,UAAU,CACzB,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,aAAa,SAAS,YAAY,GAAG,YAAY,EAEjD,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,GACvC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,CAG7D"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.withEditor = exports.FieldKindWithEditor = void 0;
|
|
8
|
-
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
-
const fieldKind_js_1 = require("./fieldKind.js");
|
|
10
|
-
const isNeverTree_js_1 = require("./isNeverTree.js");
|
|
11
|
-
// TODO: stronger typing
|
|
12
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
13
|
-
/**
|
|
14
|
-
* Functionality for FieldKinds that is stable,
|
|
15
|
-
* meaning that it can not change in any measurable way without providing a new identifier.
|
|
16
|
-
*
|
|
17
|
-
* It is assumed that this information and policy is available on all clients interacting with a document
|
|
18
|
-
* using the identifier.
|
|
19
|
-
*
|
|
20
|
-
* This must contain enough information to process remote edits to this FieldKind consistently with all clients.
|
|
21
|
-
* All behavior must be deterministic, and not change across versions of the app/library.
|
|
22
|
-
*
|
|
23
|
-
* These policies include the data encoding, change encoding, change rebase and change application.
|
|
24
|
-
*/
|
|
25
|
-
class FieldKindWithEditor extends fieldKind_js_1.FlexFieldKind {
|
|
26
|
-
/**
|
|
27
|
-
* @param identifier - Globally scoped identifier.
|
|
28
|
-
* @param multiplicity - bound on the number of children that fields of this kind may have.
|
|
29
|
-
* TODO: replace with numeric upper and lower bounds.
|
|
30
|
-
* @param changeHandler - Change handling policy.
|
|
31
|
-
* @param allowsTreeSupersetOf - returns true iff `superset` supports all that this does
|
|
32
|
-
* and `superset` is an allowed upgrade. Does not have to handle the `never` cases.
|
|
33
|
-
* See {@link isNeverField}.
|
|
34
|
-
* TODO: when used as a method (instead of a free function like the other superset related functions),
|
|
35
|
-
* this name is/signature is confusing and seems backwards.
|
|
36
|
-
* @param handlesEditsFrom - Kinds (in addition to this) whose edits can be processed by changeHandler.
|
|
37
|
-
* If the kind of a field changes, and edits are rebased across that kind change,
|
|
38
|
-
* listing the other old kind here can prevent those edits from being conflicted and
|
|
39
|
-
* provide a chance to handle them.
|
|
40
|
-
*/
|
|
41
|
-
constructor(identifier, multiplicity, changeHandler, allowsTreeSupersetOf, handlesEditsFrom) {
|
|
42
|
-
super(identifier, multiplicity);
|
|
43
|
-
this.changeHandler = changeHandler;
|
|
44
|
-
this.allowsTreeSupersetOf = allowsTreeSupersetOf;
|
|
45
|
-
this.handlesEditsFrom = handlesEditsFrom;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Returns true if and only if `superset` permits a (non-strict) superset of the subtrees
|
|
49
|
-
* allowed by field made from `this` and `originalTypes`.
|
|
50
|
-
*/
|
|
51
|
-
allowsFieldSuperset(policy, originalData, originalTypes, superset) {
|
|
52
|
-
if ((0, isNeverTree_js_1.isNeverField)(policy, originalData, {
|
|
53
|
-
kind: this.identifier,
|
|
54
|
-
types: originalTypes,
|
|
55
|
-
// Metadata is not used for this check.
|
|
56
|
-
persistedMetadata: undefined,
|
|
57
|
-
})) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
if ((0, isNeverTree_js_1.isNeverField)(policy, originalData, superset)) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
return this.allowsTreeSupersetOf(originalTypes, superset);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.FieldKindWithEditor = FieldKindWithEditor;
|
|
67
|
-
/**
|
|
68
|
-
* Downcasts to {@link FieldKindWithEditor}.
|
|
69
|
-
*/
|
|
70
|
-
function withEditor(kind) {
|
|
71
|
-
(0, internal_1.assert)(kind instanceof FieldKindWithEditor, 0x7b5 /* kind must be FieldKindWithEditor */);
|
|
72
|
-
return kind;
|
|
73
|
-
}
|
|
74
|
-
exports.withEditor = withEditor;
|
|
75
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
76
|
-
//# sourceMappingURL=fieldKindWithEditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fieldKindWithEditor.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/fieldKindWithEditor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAW7D,iDAAsE;AACtE,qDAAgD;AAEhD,wBAAwB;AACxB,uDAAuD;AAEvD;;;;;;;;;;;GAWG;AACH,MAAa,mBAIX,SAAQ,4BAAmC;IAC5C;;;;;;;;;;;;;;OAcG;IACH,YACC,UAAiB,EACjB,YAA2B,EACX,aAA+C,EAC9C,oBAGL,EACI,gBAAkD;QAElE,KAAK,CAAC,UAAyC,EAAE,YAAY,CAAC,CAAC;QAP/C,kBAAa,GAAb,aAAa,CAAkC;QAC9C,yBAAoB,GAApB,oBAAoB,CAGzB;QACI,qBAAgB,GAAhB,gBAAgB,CAAkC;IAGnE,CAAC;IAED;;;OAGG;IACI,mBAAmB,CACzB,MAAwB,EACxB,YAA8B,EAC9B,aAA0B,EAC1B,QAA+B;QAE/B,IACC,IAAA,6BAAY,EAAC,MAAM,EAAE,YAAY,EAAE;YAClC,IAAI,EAAE,IAAI,CAAC,UAAU;YACrB,KAAK,EAAE,aAAa;YACpB,uCAAuC;YACvC,iBAAiB,EAAE,SAAS;SAC5B,CAAC,EACD,CAAC;YACF,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,IAAA,6BAAY,EAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,CAAC;YAClD,OAAO,KAAK,CAAC;QACd,CAAC;QACD,OAAO,IAAI,CAAC,oBAAoB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACD;AA1DD,kDA0DC;AAED;;GAEG;AACH,SAAgB,UAAU,CAIzB,IAAyC;IAEzC,IAAA,iBAAM,EAAC,IAAI,YAAY,mBAAmB,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1F,OAAO,IAAmE,CAAC;AAC5E,CAAC;AARD,gCAQC;AAED,sDAAsD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type {\n\tFieldKindIdentifier,\n\tTreeFieldStoredSchema,\n\tTreeStoredSchema,\n\tTreeTypeSet,\n\tMultiplicity,\n} from \"../../core/index.js\";\n\nimport type { FieldChangeHandler, FieldEditor } from \"./fieldChangeHandler.js\";\nimport { FlexFieldKind, type FullSchemaPolicy } from \"./fieldKind.js\";\nimport { isNeverField } from \"./isNeverTree.js\";\n\n// TODO: stronger typing\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Functionality for FieldKinds that is stable,\n * meaning that it can not change in any measurable way without providing a new identifier.\n *\n * It is assumed that this information and policy is available on all clients interacting with a document\n * using the identifier.\n *\n * This must contain enough information to process remote edits to this FieldKind consistently with all clients.\n * All behavior must be deterministic, and not change across versions of the app/library.\n *\n * These policies include the data encoding, change encoding, change rebase and change application.\n */\nexport class FieldKindWithEditor<\n\tTEditor extends FieldEditor<any> = FieldEditor<any>,\n\tTMultiplicity extends Multiplicity = Multiplicity,\n\tTName extends string = string,\n> extends FlexFieldKind<TName, TMultiplicity> {\n\t/**\n\t * @param identifier - Globally scoped identifier.\n\t * @param multiplicity - bound on the number of children that fields of this kind may have.\n\t * TODO: replace with numeric upper and lower bounds.\n\t * @param changeHandler - Change handling policy.\n\t * @param allowsTreeSupersetOf - returns true iff `superset` supports all that this does\n\t * and `superset` is an allowed upgrade. Does not have to handle the `never` cases.\n\t * See {@link isNeverField}.\n\t * TODO: when used as a method (instead of a free function like the other superset related functions),\n\t * this name is/signature is confusing and seems backwards.\n\t * @param handlesEditsFrom - Kinds (in addition to this) whose edits can be processed by changeHandler.\n\t * If the kind of a field changes, and edits are rebased across that kind change,\n\t * listing the other old kind here can prevent those edits from being conflicted and\n\t * provide a chance to handle them.\n\t */\n\tpublic constructor(\n\t\tidentifier: TName,\n\t\tmultiplicity: TMultiplicity,\n\t\tpublic readonly changeHandler: FieldChangeHandler<any, TEditor>,\n\t\tprivate readonly allowsTreeSupersetOf: (\n\t\t\toriginalTypes: TreeTypeSet,\n\t\t\tsuperset: TreeFieldStoredSchema,\n\t\t) => boolean,\n\t\tpublic readonly handlesEditsFrom: ReadonlySet<FieldKindIdentifier>,\n\t) {\n\t\tsuper(identifier as TName & FieldKindIdentifier, multiplicity);\n\t}\n\n\t/**\n\t * Returns true if and only if `superset` permits a (non-strict) superset of the subtrees\n\t * allowed by field made from `this` and `originalTypes`.\n\t */\n\tpublic allowsFieldSuperset(\n\t\tpolicy: FullSchemaPolicy,\n\t\toriginalData: TreeStoredSchema,\n\t\toriginalTypes: TreeTypeSet,\n\t\tsuperset: TreeFieldStoredSchema,\n\t): boolean {\n\t\tif (\n\t\t\tisNeverField(policy, originalData, {\n\t\t\t\tkind: this.identifier,\n\t\t\t\ttypes: originalTypes,\n\t\t\t\t// Metadata is not used for this check.\n\t\t\t\tpersistedMetadata: undefined,\n\t\t\t})\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\tif (isNeverField(policy, originalData, superset)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.allowsTreeSupersetOf(originalTypes, superset);\n\t}\n}\n\n/**\n * Downcasts to {@link FieldKindWithEditor}.\n */\nexport function withEditor<\n\tTName extends string = string,\n\tTMultiplicity extends Multiplicity = Multiplicity,\n>(\n\tkind: FlexFieldKind<TName, TMultiplicity>,\n): FieldKindWithEditor<FieldEditor<any>, TMultiplicity, TName> {\n\tassert(kind instanceof FieldKindWithEditor, 0x7b5 /* kind must be FieldKindWithEditor */);\n\treturn kind as FieldKindWithEditor<FieldEditor<any>, TMultiplicity, TName>;\n}\n\n/* eslint-enable @typescript-eslint/no-explicit-any */\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { TAnySchema } from "@sinclair/typebox";
|
|
6
|
-
import type { IJsonCodec } from "../../codec/index.js";
|
|
7
|
-
import type { ChangeEncodingContext, EncodedRevisionTag, RevisionTag } from "../../core/index.js";
|
|
8
|
-
import { type FieldChangeEncodingContext } from "../modular-schema/index.js";
|
|
9
|
-
import { EncodedOptionalChangeset } from "./optionalFieldChangeFormatV1.js";
|
|
10
|
-
import type { OptionalChangeset } from "./optionalFieldChangeTypes.js";
|
|
11
|
-
export declare function makeOptionalFieldCodec(revisionTagCodec: IJsonCodec<RevisionTag, EncodedRevisionTag, EncodedRevisionTag, ChangeEncodingContext>): IJsonCodec<OptionalChangeset, EncodedOptionalChangeset<TAnySchema>, EncodedOptionalChangeset<TAnySchema>, FieldChangeEncodingContext>;
|
|
12
|
-
//# sourceMappingURL=optionalFieldCodecV1.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"optionalFieldCodecV1.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/optional-field/optionalFieldCodecV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EACX,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAEN,KAAK,0BAA0B,EAC/B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,wBAAwB,EAAqB,MAAM,kCAAkC,CAAC;AAC/F,OAAO,KAAK,EAAQ,iBAAiB,EAAc,MAAM,+BAA+B,CAAC;AA4BzF,wBAAgB,sBAAsB,CACrC,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,GACC,UAAU,CACZ,iBAAiB,EACjB,wBAAwB,CAAC,UAAU,CAAC,EACpC,wBAAwB,CAAC,UAAU,CAAC,EACpC,0BAA0B,CAC1B,CAiJA"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.makeOptionalFieldCodec = void 0;
|
|
8
|
-
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
-
const changeAtomIdCodec_js_1 = require("../changeAtomIdCodec.js");
|
|
10
|
-
const index_js_1 = require("../modular-schema/index.js");
|
|
11
|
-
const optionalFieldChangeFormatV1_js_1 = require("./optionalFieldChangeFormatV1.js");
|
|
12
|
-
function makeRegisterIdCodec(revisionTagCodec) {
|
|
13
|
-
const changeAtomIdCodec = (0, changeAtomIdCodec_js_1.makeChangeAtomIdCodec)(revisionTagCodec);
|
|
14
|
-
return {
|
|
15
|
-
encode: (registerId, context) => {
|
|
16
|
-
if (registerId === "self") {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return changeAtomIdCodec.encode(registerId, context);
|
|
20
|
-
},
|
|
21
|
-
decode: (registerId, context) => {
|
|
22
|
-
if (registerId === null) {
|
|
23
|
-
return "self";
|
|
24
|
-
}
|
|
25
|
-
return changeAtomIdCodec.decode(registerId, context);
|
|
26
|
-
},
|
|
27
|
-
encodedSchema: optionalFieldChangeFormatV1_js_1.EncodedRegisterId,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function makeOptionalFieldCodec(revisionTagCodec) {
|
|
31
|
-
const registerIdCodec = makeRegisterIdCodec(revisionTagCodec);
|
|
32
|
-
return {
|
|
33
|
-
encode: (change, context) => {
|
|
34
|
-
const encoded = {};
|
|
35
|
-
encoded.m = [];
|
|
36
|
-
if (change.valueReplace !== undefined) {
|
|
37
|
-
if (change.valueReplace.src !== undefined) {
|
|
38
|
-
encoded.m.push([
|
|
39
|
-
registerIdCodec.encode(change.valueReplace.src, context.baseContext),
|
|
40
|
-
registerIdCodec.encode("self", context.baseContext),
|
|
41
|
-
true,
|
|
42
|
-
]);
|
|
43
|
-
}
|
|
44
|
-
// When the source of the replace is "self", the destination is a reserved ID that will only be used if
|
|
45
|
-
// the tree in the field is concurrently replaced.
|
|
46
|
-
if (change.valueReplace.isEmpty || change.valueReplace.src === "self") {
|
|
47
|
-
encoded.d = registerIdCodec.encode(change.valueReplace.dst, context.baseContext);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
encoded.m.push([
|
|
51
|
-
registerIdCodec.encode("self", context.baseContext),
|
|
52
|
-
registerIdCodec.encode(change.valueReplace.dst, context.baseContext),
|
|
53
|
-
false,
|
|
54
|
-
]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
for (const [src, dst] of change.moves) {
|
|
58
|
-
encoded.m.push([
|
|
59
|
-
registerIdCodec.encode(src, context.baseContext),
|
|
60
|
-
registerIdCodec.encode(dst, context.baseContext),
|
|
61
|
-
true,
|
|
62
|
-
]);
|
|
63
|
-
}
|
|
64
|
-
if (encoded.m.length === 0) {
|
|
65
|
-
delete encoded.m;
|
|
66
|
-
}
|
|
67
|
-
if (change.childChanges.length > 0) {
|
|
68
|
-
encoded.c = [];
|
|
69
|
-
for (const [id, childChange] of change.childChanges) {
|
|
70
|
-
encoded.c.push([
|
|
71
|
-
registerIdCodec.encode(id, context.baseContext),
|
|
72
|
-
context.encodeNode(childChange),
|
|
73
|
-
]);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return encoded;
|
|
77
|
-
},
|
|
78
|
-
decode: (encoded, context) => {
|
|
79
|
-
// The register that the node in the optional field is moved to upon detach
|
|
80
|
-
let detached;
|
|
81
|
-
// The register that the node is moved from to upon attaching that node in the optional field
|
|
82
|
-
let attached;
|
|
83
|
-
const moves = [];
|
|
84
|
-
if (encoded.m !== undefined) {
|
|
85
|
-
for (const [encodedSrc, encodedDst] of encoded.m) {
|
|
86
|
-
const src = registerIdCodec.decode(encodedSrc, context.baseContext);
|
|
87
|
-
const dst = registerIdCodec.decode(encodedDst, context.baseContext);
|
|
88
|
-
if (src === "self" || dst === "self") {
|
|
89
|
-
if (src === "self") {
|
|
90
|
-
(0, internal_1.assert)(detached === undefined, 0x8d0 /* Multiple detached nodes */);
|
|
91
|
-
detached = dst;
|
|
92
|
-
}
|
|
93
|
-
if (dst === "self") {
|
|
94
|
-
(0, internal_1.assert)(attached === undefined, 0x8d1 /* Multiple attached nodes */);
|
|
95
|
-
attached = src;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
moves.push([src, dst]);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const decoded = {
|
|
104
|
-
moves,
|
|
105
|
-
childChanges: encoded.c?.map(([id, encodedChange]) => [
|
|
106
|
-
registerIdCodec.decode(id, context.baseContext),
|
|
107
|
-
context.decodeNode(encodedChange),
|
|
108
|
-
]) ?? [],
|
|
109
|
-
};
|
|
110
|
-
if (detached !== undefined && attached !== undefined) {
|
|
111
|
-
if (detached === "self" || attached === "self") {
|
|
112
|
-
(0, internal_1.assert)(encoded.d !== undefined, 0x8d2 /* Invalid change: pin must have a reserved detach ID */);
|
|
113
|
-
const reserved = registerIdCodec.decode(encoded.d, context.baseContext);
|
|
114
|
-
(0, internal_1.assert)(reserved !== "self", 0x8d3 /* Invalid reserved detach ID */);
|
|
115
|
-
decoded.valueReplace = { isEmpty: false, dst: reserved, src: "self" };
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
(0, internal_1.assert)(encoded.d === undefined, 0x8d4 /* Invalid change: unexpected reserved detach ID on a change that detaches a node from the field */);
|
|
119
|
-
decoded.valueReplace = {
|
|
120
|
-
isEmpty: false,
|
|
121
|
-
dst: detached,
|
|
122
|
-
src: attached,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
else if (attached !== undefined) {
|
|
127
|
-
(0, internal_1.assert)(encoded.d !== undefined, 0x8d5 /* Invalid change: attach must have a reserved detach ID */);
|
|
128
|
-
const reserved = registerIdCodec.decode(encoded.d, context.baseContext);
|
|
129
|
-
(0, internal_1.assert)(reserved !== "self", 0x8d6 /* Invalid reserved detach ID */);
|
|
130
|
-
decoded.valueReplace = {
|
|
131
|
-
isEmpty: true,
|
|
132
|
-
dst: reserved,
|
|
133
|
-
src: attached,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
else if (detached !== undefined) {
|
|
137
|
-
(0, internal_1.assert)(encoded.d === undefined, 0x8d7 /* Invalid change: unexpected reserved detach ID on a change that detaches a node from the field */);
|
|
138
|
-
(0, internal_1.assert)(detached !== "self", 0x8d8 /* Invalid detach ID */);
|
|
139
|
-
decoded.valueReplace = {
|
|
140
|
-
isEmpty: false,
|
|
141
|
-
dst: detached,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
else if (encoded.d !== undefined) {
|
|
145
|
-
const detachId = registerIdCodec.decode(encoded.d, context.baseContext);
|
|
146
|
-
(0, internal_1.assert)(detachId !== "self", 0x8d9 /* Invalid detach ID */);
|
|
147
|
-
decoded.valueReplace = {
|
|
148
|
-
isEmpty: true,
|
|
149
|
-
dst: detachId,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
return decoded;
|
|
153
|
-
},
|
|
154
|
-
encodedSchema: (0, optionalFieldChangeFormatV1_js_1.EncodedOptionalChangeset)(index_js_1.EncodedNodeChangeset),
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
exports.makeOptionalFieldCodec = makeOptionalFieldCodec;
|
|
158
|
-
//# sourceMappingURL=optionalFieldCodecV1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"optionalFieldCodecV1.js","sourceRoot":"","sources":["../../../src/feature-libraries/optional-field/optionalFieldCodecV1.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAU7D,kEAAgE;AAChE,yDAGoC;AAEpC,qFAA+F;AAG/F,SAAS,mBAAmB,CAC3B,gBAKC;IAED,MAAM,iBAAiB,GAAG,IAAA,4CAAqB,EAAC,gBAAgB,CAAC,CAAC;IAClE,OAAO;QACN,MAAM,EAAE,CAAC,UAAsB,EAAE,OAA8B,EAAE,EAAE;YAClE,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC;YACb,CAAC;YACD,OAAO,iBAAiB,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;QACD,MAAM,EAAE,CAAC,UAA6B,EAAE,OAA8B,EAAE,EAAE;YACzE,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;gBACzB,OAAO,MAAM,CAAC;YACf,CAAC;YACD,OAAO,iBAAiB,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;QACD,aAAa,EAAE,kDAAiB;KAChC,CAAC;AACH,CAAC;AAED,SAAgB,sBAAsB,CACrC,gBAKC;IAOD,MAAM,eAAe,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAE9D,OAAO;QACN,MAAM,EAAE,CAAC,MAAyB,EAAE,OAAmC,EAAE,EAAE;YAC1E,MAAM,OAAO,GAAyC,EAAE,CAAC;YACz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C,uBAAuB,CAAC,CAAC;gBAC3D,OAAO,CAAC,YAAY,GAAG;oBACtB,OAAO,EAAE,IAAI;oBACb,GAAG,EAAE,QAAQ;iBACb,CAAC;YACH,CAAC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,aAAa,EAAE,IAAA,yDAAwB,EAAC,+BAAoB,CAAC;KAC7D,CAAC;AACH,CAAC;AA7JD,wDA6JC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { TAnySchema } from \"@sinclair/typebox\";\n\nimport type { IJsonCodec } from \"../../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tEncodedRevisionTag,\n\tRevisionTag,\n} from \"../../core/index.js\";\nimport type { Mutable } from \"../../util/index.js\";\nimport { makeChangeAtomIdCodec } from \"../changeAtomIdCodec.js\";\nimport {\n\tEncodedNodeChangeset,\n\ttype FieldChangeEncodingContext,\n} from \"../modular-schema/index.js\";\n\nimport { EncodedOptionalChangeset, EncodedRegisterId } from \"./optionalFieldChangeFormatV1.js\";\nimport type { Move, OptionalChangeset, RegisterId } from \"./optionalFieldChangeTypes.js\";\n\nfunction makeRegisterIdCodec(\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n): IJsonCodec<RegisterId, EncodedRegisterId, EncodedRegisterId, ChangeEncodingContext> {\n\tconst changeAtomIdCodec = makeChangeAtomIdCodec(revisionTagCodec);\n\treturn {\n\t\tencode: (registerId: RegisterId, context: ChangeEncodingContext) => {\n\t\t\tif (registerId === \"self\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn changeAtomIdCodec.encode(registerId, context);\n\t\t},\n\t\tdecode: (registerId: EncodedRegisterId, context: ChangeEncodingContext) => {\n\t\t\tif (registerId === null) {\n\t\t\t\treturn \"self\";\n\t\t\t}\n\t\t\treturn changeAtomIdCodec.decode(registerId, context);\n\t\t},\n\t\tencodedSchema: EncodedRegisterId,\n\t};\n}\n\nexport function makeOptionalFieldCodec(\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n): IJsonCodec<\n\tOptionalChangeset,\n\tEncodedOptionalChangeset<TAnySchema>,\n\tEncodedOptionalChangeset<TAnySchema>,\n\tFieldChangeEncodingContext\n> {\n\tconst registerIdCodec = makeRegisterIdCodec(revisionTagCodec);\n\n\treturn {\n\t\tencode: (change: OptionalChangeset, context: FieldChangeEncodingContext) => {\n\t\t\tconst encoded: EncodedOptionalChangeset<TAnySchema> = {};\n\t\t\tencoded.m = [];\n\n\t\t\tif (change.valueReplace !== undefined) {\n\t\t\t\tif (change.valueReplace.src !== undefined) {\n\t\t\t\t\tencoded.m.push([\n\t\t\t\t\t\tregisterIdCodec.encode(change.valueReplace.src, context.baseContext),\n\t\t\t\t\t\tregisterIdCodec.encode(\"self\", context.baseContext),\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t]);\n\t\t\t\t}\n\n\t\t\t\t// When the source of the replace is \"self\", the destination is a reserved ID that will only be used if\n\t\t\t\t// the tree in the field is concurrently replaced.\n\t\t\t\tif (change.valueReplace.isEmpty || change.valueReplace.src === \"self\") {\n\t\t\t\t\tencoded.d = registerIdCodec.encode(change.valueReplace.dst, context.baseContext);\n\t\t\t\t} else {\n\t\t\t\t\tencoded.m.push([\n\t\t\t\t\t\tregisterIdCodec.encode(\"self\", context.baseContext),\n\t\t\t\t\t\tregisterIdCodec.encode(change.valueReplace.dst, context.baseContext),\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const [src, dst] of change.moves) {\n\t\t\t\tencoded.m.push([\n\t\t\t\t\tregisterIdCodec.encode(src, context.baseContext),\n\t\t\t\t\tregisterIdCodec.encode(dst, context.baseContext),\n\t\t\t\t\ttrue,\n\t\t\t\t]);\n\t\t\t}\n\n\t\t\tif (encoded.m.length === 0) {\n\t\t\t\tdelete encoded.m;\n\t\t\t}\n\n\t\t\tif (change.childChanges.length > 0) {\n\t\t\t\tencoded.c = [];\n\t\t\t\tfor (const [id, childChange] of change.childChanges) {\n\t\t\t\t\tencoded.c.push([\n\t\t\t\t\t\tregisterIdCodec.encode(id, context.baseContext),\n\t\t\t\t\t\tcontext.encodeNode(childChange),\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn encoded;\n\t\t},\n\n\t\tdecode: (\n\t\t\tencoded: EncodedOptionalChangeset<TAnySchema>,\n\t\t\tcontext: FieldChangeEncodingContext,\n\t\t) => {\n\t\t\t// The register that the node in the optional field is moved to upon detach\n\t\t\tlet detached: RegisterId | undefined;\n\t\t\t// The register that the node is moved from to upon attaching that node in the optional field\n\t\t\tlet attached: RegisterId | undefined;\n\t\t\tconst moves: Move[] = [];\n\t\t\tif (encoded.m !== undefined) {\n\t\t\t\tfor (const [encodedSrc, encodedDst] of encoded.m) {\n\t\t\t\t\tconst src = registerIdCodec.decode(encodedSrc, context.baseContext);\n\t\t\t\t\tconst dst = registerIdCodec.decode(encodedDst, context.baseContext);\n\t\t\t\t\tif (src === \"self\" || dst === \"self\") {\n\t\t\t\t\t\tif (src === \"self\") {\n\t\t\t\t\t\t\tassert(detached === undefined, 0x8d0 /* Multiple detached nodes */);\n\t\t\t\t\t\t\tdetached = dst;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (dst === \"self\") {\n\t\t\t\t\t\t\tassert(attached === undefined, 0x8d1 /* Multiple attached nodes */);\n\t\t\t\t\t\t\tattached = src;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmoves.push([src, dst]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst decoded: Mutable<OptionalChangeset> = {\n\t\t\t\tmoves,\n\t\t\t\tchildChanges:\n\t\t\t\t\tencoded.c?.map(([id, encodedChange]) => [\n\t\t\t\t\t\tregisterIdCodec.decode(id, context.baseContext),\n\t\t\t\t\t\tcontext.decodeNode(encodedChange),\n\t\t\t\t\t]) ?? [],\n\t\t\t};\n\n\t\t\tif (detached !== undefined && attached !== undefined) {\n\t\t\t\tif (detached === \"self\" || attached === \"self\") {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tencoded.d !== undefined,\n\t\t\t\t\t\t0x8d2 /* Invalid change: pin must have a reserved detach ID */,\n\t\t\t\t\t);\n\t\t\t\t\tconst reserved = registerIdCodec.decode(encoded.d, context.baseContext);\n\t\t\t\t\tassert(reserved !== \"self\", 0x8d3 /* Invalid reserved detach ID */);\n\t\t\t\t\tdecoded.valueReplace = { isEmpty: false, dst: reserved, src: \"self\" };\n\t\t\t\t} else {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tencoded.d === undefined,\n\t\t\t\t\t\t0x8d4 /* Invalid change: unexpected reserved detach ID on a change that detaches a node from the field */,\n\t\t\t\t\t);\n\t\t\t\t\tdecoded.valueReplace = {\n\t\t\t\t\t\tisEmpty: false,\n\t\t\t\t\t\tdst: detached,\n\t\t\t\t\t\tsrc: attached,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else if (attached !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tencoded.d !== undefined,\n\t\t\t\t\t0x8d5 /* Invalid change: attach must have a reserved detach ID */,\n\t\t\t\t);\n\t\t\t\tconst reserved = registerIdCodec.decode(encoded.d, context.baseContext);\n\t\t\t\tassert(reserved !== \"self\", 0x8d6 /* Invalid reserved detach ID */);\n\t\t\t\tdecoded.valueReplace = {\n\t\t\t\t\tisEmpty: true,\n\t\t\t\t\tdst: reserved,\n\t\t\t\t\tsrc: attached,\n\t\t\t\t};\n\t\t\t} else if (detached !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tencoded.d === undefined,\n\t\t\t\t\t0x8d7 /* Invalid change: unexpected reserved detach ID on a change that detaches a node from the field */,\n\t\t\t\t);\n\t\t\t\tassert(detached !== \"self\", 0x8d8 /* Invalid detach ID */);\n\t\t\t\tdecoded.valueReplace = {\n\t\t\t\t\tisEmpty: false,\n\t\t\t\t\tdst: detached,\n\t\t\t\t};\n\t\t\t} else if (encoded.d !== undefined) {\n\t\t\t\tconst detachId = registerIdCodec.decode(encoded.d, context.baseContext);\n\t\t\t\tassert(detachId !== \"self\", 0x8d9 /* Invalid detach ID */);\n\t\t\t\tdecoded.valueReplace = {\n\t\t\t\t\tisEmpty: true,\n\t\t\t\t\tdst: detachId,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn decoded;\n\t\t},\n\t\tencodedSchema: EncodedOptionalChangeset(EncodedNodeChangeset),\n\t};\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { type IJsonCodec } from "../../codec/index.js";
|
|
6
|
-
import type { ChangeEncodingContext, EncodedRevisionTag, RevisionTag } from "../../core/index.js";
|
|
7
|
-
import { type JsonCompatibleReadOnly } from "../../util/index.js";
|
|
8
|
-
import { type FieldChangeEncodingContext } from "../modular-schema/index.js";
|
|
9
|
-
import { type Changeset } from "./types.js";
|
|
10
|
-
export declare function makeV1Codec(revisionTagCodec: IJsonCodec<RevisionTag, EncodedRevisionTag, EncodedRevisionTag, ChangeEncodingContext>): IJsonCodec<Changeset, JsonCompatibleReadOnly, JsonCompatibleReadOnly, FieldChangeEncodingContext>;
|
|
11
|
-
//# sourceMappingURL=sequenceFieldCodecV1.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sequenceFieldCodecV1.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EACX,qBAAqB,EAErB,kBAAkB,EAClB,WAAW,EACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,sBAAsB,EAAuB,MAAM,qBAAqB,CAAC;AAEvF,OAAO,EAEN,KAAK,0BAA0B,EAC/B,MAAM,4BAA4B,CAAC;AAOpC,OAAO,EAIN,KAAK,SAAS,EAUd,MAAM,YAAY,CAAC;AAGpB,wBAAgB,WAAW,CAC1B,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,GACC,UAAU,CACZ,SAAS,EACT,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,CAC1B,CA0RA"}
|