@fluidframework/tree 2.82.0 → 2.83.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 +43 -0
- package/README.md +33 -5
- package/api-report/tree.alpha.api.md +25 -21
- package/api-report/tree.beta.api.md +14 -2
- package/api-report/tree.legacy.beta.api.md +14 -2
- package/api-report/tree.legacy.public.api.md +1 -1
- package/api-report/tree.public.api.md +1 -1
- package/dist/alpha.d.ts +3 -3
- package/dist/beta.d.ts +1 -0
- package/dist/codec/codec.d.ts +3 -39
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +5 -50
- 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 +1 -2
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +20 -7
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +56 -30
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +6 -4
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/extensibleUnionNode.d.ts +97 -0
- package/dist/extensibleUnionNode.d.ts.map +1 -0
- package/dist/{extensibleSchemaUnion.js → extensibleUnionNode.js} +28 -18
- package/dist/extensibleUnionNode.js.map +1 -0
- 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 +4 -4
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js +7 -1
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts +3 -3
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
- package/dist/feature-libraries/forest-summary/formatV1.d.ts +2 -3
- package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/formatV1.js +1 -2
- package/dist/feature-libraries/forest-summary/formatV1.js.map +1 -1
- package/dist/feature-libraries/forest-summary/formatV2.d.ts +2 -3
- package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/formatV2.js +1 -2
- package/dist/feature-libraries/forest-summary/formatV2.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +4 -4
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +6 -4
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/tree.d.ts +1 -1
- package/dist/shared-tree/tree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +1 -1
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +2 -4
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -2
- package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +2 -2
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +2 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js +180 -99
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeBeta.d.ts +1 -1
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts +1 -1
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -0
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +29 -0
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/index.d.ts +1 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +2 -2
- package/dist/simple-tree/index.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 +4 -13
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +33 -7
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +3 -3
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/text/textDomainFormatted.js +48 -32
- package/dist/text/textDomainFormatted.js.map +1 -1
- package/dist/util/bTreeUtils.d.ts.map +1 -1
- package/dist/util/bTreeUtils.js +6 -6
- package/dist/util/bTreeUtils.js.map +1 -1
- package/dist/util/rangeMap.d.ts.map +1 -1
- package/dist/util/rangeMap.js +5 -6
- package/dist/util/rangeMap.js.map +1 -1
- package/lib/alpha.d.ts +3 -3
- package/lib/beta.d.ts +1 -0
- package/lib/codec/codec.d.ts +3 -39
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +4 -47
- 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 +20 -7
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +59 -33
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +6 -4
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/extensibleUnionNode.d.ts +97 -0
- package/lib/extensibleUnionNode.d.ts.map +1 -0
- package/lib/{extensibleSchemaUnion.js → extensibleUnionNode.js} +28 -18
- package/lib/extensibleUnionNode.js.map +1 -0
- 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 +5 -5
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js +8 -2
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts +3 -3
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
- package/lib/feature-libraries/forest-summary/formatV1.d.ts +2 -3
- package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/formatV1.js +1 -2
- package/lib/feature-libraries/forest-summary/formatV1.js.map +1 -1
- package/lib/feature-libraries/forest-summary/formatV2.d.ts +2 -3
- package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/formatV2.js +1 -2
- package/lib/feature-libraries/forest-summary/formatV2.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +4 -4
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +6 -4
- package/lib/feature-libraries/schema-index/codec.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/legacy.d.ts +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/tree.d.ts +1 -1
- package/lib/shared-tree/tree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +1 -1
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +2 -4
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.js +2 -2
- package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js +2 -2
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +2 -2
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js +179 -98
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeBeta.d.ts +1 -1
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +1 -1
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -0
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +29 -0
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/index.d.ts +1 -1
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +5 -14
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +34 -8
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +3 -3
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/text/textDomainFormatted.js +30 -14
- package/lib/text/textDomainFormatted.js.map +1 -1
- package/lib/util/bTreeUtils.d.ts.map +1 -1
- package/lib/util/bTreeUtils.js +6 -6
- package/lib/util/bTreeUtils.js.map +1 -1
- package/lib/util/rangeMap.d.ts.map +1 -1
- package/lib/util/rangeMap.js +5 -6
- package/lib/util/rangeMap.js.map +1 -1
- package/package.json +23 -23
- package/src/codec/codec.ts +10 -112
- package/src/codec/index.ts +0 -3
- package/src/codec/versioned/codec.ts +119 -83
- package/src/core/tree/detachedFieldIndexCodecs.ts +6 -4
- package/src/{extensibleSchemaUnion.ts → extensibleUnionNode.ts} +61 -19
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +5 -11
- package/src/feature-libraries/forest-summary/codec.ts +8 -7
- package/src/feature-libraries/forest-summary/formatCommon.ts +5 -3
- package/src/feature-libraries/forest-summary/formatV1.ts +1 -3
- package/src/feature-libraries/forest-summary/formatV2.ts +1 -3
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +5 -6
- package/src/feature-libraries/schema-index/codec.ts +6 -4
- package/src/index.ts +3 -3
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/sharedTreeChangeCodecs.ts +2 -2
- package/src/shared-tree/tree.ts +1 -1
- package/src/shared-tree/treeAlpha.ts +1 -1
- package/src/shared-tree/treeCheckout.ts +2 -4
- package/src/shared-tree-core/editManagerCodecsCommons.ts +7 -7
- package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -10
- package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -10
- package/src/shared-tree-core/messageCodecs.ts +2 -6
- package/src/simple-tree/api/index.ts +2 -2
- package/src/simple-tree/api/snapshotCompatibilityChecker.ts +344 -142
- package/src/simple-tree/api/tree.ts +1 -1
- package/src/simple-tree/api/treeBeta.ts +1 -1
- package/src/simple-tree/core/allowedTypes.ts +1 -1
- package/src/simple-tree/core/unhydratedFlexTree.ts +43 -1
- package/src/simple-tree/index.ts +2 -2
- package/src/simple-tree/node-kinds/array/arrayNode.ts +13 -19
- package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +51 -10
- package/src/text/textDomainFormatted.ts +37 -17
- package/src/util/bTreeUtils.ts +10 -6
- package/src/util/rangeMap.ts +9 -6
- package/api-extractor-lint.json +0 -4
- package/dist/extensibleSchemaUnion.d.ts +0 -72
- package/dist/extensibleSchemaUnion.d.ts.map +0 -1
- package/dist/extensibleSchemaUnion.js.map +0 -1
- package/lib/extensibleSchemaUnion.d.ts +0 -72
- package/lib/extensibleSchemaUnion.d.ts.map +0 -1
- package/lib/extensibleSchemaUnion.js.map +0 -1
|
@@ -10,14 +10,16 @@ const index_js_1 = require("../../codec/index.js");
|
|
|
10
10
|
const detachedFieldIndexCodecV1_js_1 = require("./detachedFieldIndexCodecV1.js");
|
|
11
11
|
const detachedFieldIndexCodecV2_js_1 = require("./detachedFieldIndexCodecV2.js");
|
|
12
12
|
const detachedFieldIndexFormatCommon_js_1 = require("./detachedFieldIndexFormatCommon.js");
|
|
13
|
-
exports.detachedFieldIndexCodecBuilder = index_js_1.ClientVersionDispatchingCodecBuilder.build("DetachedFieldIndex",
|
|
14
|
-
|
|
13
|
+
exports.detachedFieldIndexCodecBuilder = index_js_1.ClientVersionDispatchingCodecBuilder.build("DetachedFieldIndex", [
|
|
14
|
+
{
|
|
15
|
+
minVersionForCollab: internal_1.lowestMinVersionForCollab,
|
|
15
16
|
formatVersion: detachedFieldIndexFormatCommon_js_1.DetachedFieldIndexFormatVersion.v1,
|
|
16
17
|
codec: (buildData) => (0, detachedFieldIndexCodecV1_js_1.makeDetachedNodeToFieldCodecV1)(buildData.revisionTagCodec, buildData.idCompressor),
|
|
17
18
|
},
|
|
18
|
-
|
|
19
|
+
{
|
|
20
|
+
minVersionForCollab: index_js_1.FluidClientVersion.v2_52,
|
|
19
21
|
formatVersion: detachedFieldIndexFormatCommon_js_1.DetachedFieldIndexFormatVersion.v2,
|
|
20
22
|
codec: (buildData) => (0, detachedFieldIndexCodecV2_js_1.makeDetachedNodeToFieldCodecV2)(buildData.revisionTagCodec, buildData.idCompressor),
|
|
21
23
|
},
|
|
22
|
-
|
|
24
|
+
]);
|
|
23
25
|
//# sourceMappingURL=detachedFieldIndexCodecs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detachedFieldIndexCodecs.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qEAAmF;AAEnF,mDAI8B;AAG9B,iFAAgF;AAChF,iFAAgF;AAChF,2FAAsF;AAOzE,QAAA,8BAA8B,GAAG,+CAAoC,CAAC,KAAK,CACvF,oBAAoB,EACpB;IACC,
|
|
1
|
+
{"version":3,"file":"detachedFieldIndexCodecs.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qEAAmF;AAEnF,mDAI8B;AAG9B,iFAAgF;AAChF,iFAAgF;AAChF,2FAAsF;AAOzE,QAAA,8BAA8B,GAAG,+CAAoC,CAAC,KAAK,CACvF,oBAAoB,EACpB;IACC;QACC,mBAAmB,EAAE,oCAAyB;QAC9C,aAAa,EAAE,mEAA+B,CAAC,EAAE;QACjD,KAAK,EAAE,CAAC,SAAoB,EAAE,EAAE,CAC/B,IAAA,6DAA8B,EAAC,SAAS,CAAC,gBAAgB,EAAE,SAAS,CAAC,YAAY,CAAC;KACnF;IACD;QACC,mBAAmB,EAAE,6BAAkB,CAAC,KAAK;QAC7C,aAAa,EAAE,mEAA+B,CAAC,EAAE;QACjD,KAAK,EAAE,CAAC,SAAoB,EAAE,EAAE,CAC/B,IAAA,6DAA8B,EAAC,SAAS,CAAC,gBAAgB,EAAE,SAAS,CAAC,YAAY,CAAC;KACnF;CACD,CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { lowestMinVersionForCollab } from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\tClientVersionDispatchingCodecBuilder,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n} from \"../../codec/index.js\";\nimport type { RevisionTagCodec } from \"../rebase/index.js\";\n\nimport { makeDetachedNodeToFieldCodecV1 } from \"./detachedFieldIndexCodecV1.js\";\nimport { makeDetachedNodeToFieldCodecV2 } from \"./detachedFieldIndexCodecV2.js\";\nimport { DetachedFieldIndexFormatVersion } from \"./detachedFieldIndexFormatCommon.js\";\n\ntype BuildData = CodecWriteOptions & {\n\trevisionTagCodec: RevisionTagCodec;\n\tidCompressor: IIdCompressor;\n};\n\nexport const detachedFieldIndexCodecBuilder = ClientVersionDispatchingCodecBuilder.build(\n\t\"DetachedFieldIndex\",\n\t[\n\t\t{\n\t\t\tminVersionForCollab: lowestMinVersionForCollab,\n\t\t\tformatVersion: DetachedFieldIndexFormatVersion.v1,\n\t\t\tcodec: (buildData: BuildData) =>\n\t\t\t\tmakeDetachedNodeToFieldCodecV1(buildData.revisionTagCodec, buildData.idCompressor),\n\t\t},\n\t\t{\n\t\t\tminVersionForCollab: FluidClientVersion.v2_52,\n\t\t\tformatVersion: DetachedFieldIndexFormatVersion.v2,\n\t\t\tcodec: (buildData: BuildData) =>\n\t\t\t\tmakeDetachedNodeToFieldCodecV2(buildData.revisionTagCodec, buildData.idCompressor),\n\t\t},\n\t],\n);\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { TreeNodeSchema, TreeNodeFromImplicitAllowedTypes, TreeFieldFromImplicitField, SchemaFactoryBeta } from "./simple-tree/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Utilities for creating extensible unions using a node.
|
|
8
|
+
* @remarks
|
|
9
|
+
* Use {@link ExtensibleUnionNode.createSchema} to create the union schema.
|
|
10
|
+
*
|
|
11
|
+
* Unlike a schema union created using {@link SchemaStaticsBeta.staged | staged} allowed types, this union allows for unknown future types to exist in addition to the known types.
|
|
12
|
+
* This allows for faster roll-outs of new types without waiting for old clients to be updated to be aware of them.
|
|
13
|
+
* This does mean however that old clients may see types they do not know about, which are simply exposed as `undefined` children.
|
|
14
|
+
*
|
|
15
|
+
* `staged` types are lower overhead, and might gain support for `unknown` types in the future, so prefer them when possible.
|
|
16
|
+
* This is simply an alternative for when future compatibility with unknown types is required.
|
|
17
|
+
* It is built on top of the existing {@link ObjectSchemaOptions.allowUnknownOptionalFields | allowUnknownOptionalFields} feature.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const sf = new SchemaFactoryBeta("extensibleUnionNodeExample.items");
|
|
22
|
+
* class ItemA extends sf.object("A", { x: sf.string }) {}
|
|
23
|
+
* class ItemB extends sf.object("B", { x: sf.number }) {}
|
|
24
|
+
*
|
|
25
|
+
* class AnyItem extends ExtensibleUnionNode.createSchema(
|
|
26
|
+
* [ItemA, ItemB], // Future versions may add more members here
|
|
27
|
+
* sf,
|
|
28
|
+
* "ExtensibleUnion",
|
|
29
|
+
* ) {}
|
|
30
|
+
* // Instances of the union are created using `create`.
|
|
31
|
+
* const anyItem = AnyItem.create(new ItemA({ x: "hello" }));
|
|
32
|
+
* // Reading the content from the union is done via the `union` property,
|
|
33
|
+
* // which can be `undefined` to handle the case where a future version of this schema allows a type unknown to the current version.
|
|
34
|
+
* const childNode: ItemA | ItemB | undefined = anyItem.union;
|
|
35
|
+
* // To determine which member of the union was present, its schema can be inspected:
|
|
36
|
+
* const aSchema = Tree.schema(childNode ?? assert.fail("No child"));
|
|
37
|
+
* assert.equal(aSchema, ItemA);
|
|
38
|
+
* ```
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export declare namespace ExtensibleUnionNode {
|
|
42
|
+
/**
|
|
43
|
+
* Members for classes created by {@link ExtensibleUnionNode.createSchema}.
|
|
44
|
+
* @beta
|
|
45
|
+
*/
|
|
46
|
+
interface Members<T> {
|
|
47
|
+
/**
|
|
48
|
+
* The child wrapped by this node has one of the types allowed by the union,
|
|
49
|
+
* or `undefined` if the type is one which was added to the union by a future version of this schema.
|
|
50
|
+
*
|
|
51
|
+
* @throws if {@link ExtensibleUnionNode.Members.isValid} is false.
|
|
52
|
+
*/
|
|
53
|
+
readonly union: T | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Returns true, unless this node is in an invalid state.
|
|
56
|
+
* @remarks
|
|
57
|
+
* A well behaved application should not need this API.
|
|
58
|
+
* If an application is hitting errors when accessing {@link ExtensibleUnionNode.Members.union},
|
|
59
|
+
* this API can be used to help detect and recover from the invalid state which causes those errors (for example by replacing the invalid nodes with new ones).
|
|
60
|
+
*
|
|
61
|
+
* In this context "invalid" means that the internal implementation details of this node have had their invariants violated.
|
|
62
|
+
* This can happen when:
|
|
63
|
+
* - Using weakly typed construction APIs like {@link (TreeBeta:interface).importConcise} or {@link (TreeAlpha:interface).importVerbose} to construct an invalid state directly.
|
|
64
|
+
* Using such APIs, even when not creating invalid nodes, is not supported for this schema,
|
|
65
|
+
* since doing so requires knowing the implementation details of this node which are subject to change.
|
|
66
|
+
* - By editing a document using a different client using a different schema for this node.
|
|
67
|
+
* - Violating the TypeScript types to directly manipulate the node internals.
|
|
68
|
+
* - A bug in this node's implementation (possibly in a different client) corrupted the node.
|
|
69
|
+
* - Corruption of the document this node is contained in.
|
|
70
|
+
*
|
|
71
|
+
* @privateRemarks
|
|
72
|
+
* We could support {@link (TreeBeta:interface).exportVerbose} using {@link KeyEncodingOptions.allStoredKeys}
|
|
73
|
+
* then {@link (TreeAlpha:interface).importVerbose} with {@link KeyEncodingOptions.knownStoredKeys}.
|
|
74
|
+
* However, even this will error (but will not produce an invalid node) if there is a node of an unknown type in the union.
|
|
75
|
+
*/
|
|
76
|
+
isValid(): boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Statics for classes created by {@link ExtensibleUnionNode.createSchema}.
|
|
80
|
+
* @beta
|
|
81
|
+
*/
|
|
82
|
+
interface Statics<T extends readonly TreeNodeSchema[]> {
|
|
83
|
+
/**
|
|
84
|
+
* Create a {@link TreeNode} with `this` schema which wraps the provided child to create the union.
|
|
85
|
+
*/
|
|
86
|
+
create<TThis extends TreeNodeSchema>(this: TThis, child: TreeNodeFromImplicitAllowedTypes<T>): TreeFieldFromImplicitField<TThis>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create an extensible schema union which currently supports the types in `types`,
|
|
90
|
+
* but tolerates collaboration with future versions that may include additional types.
|
|
91
|
+
* @remarks
|
|
92
|
+
* See {@link ExtensibleUnionNode} for an example use.
|
|
93
|
+
* @beta
|
|
94
|
+
*/
|
|
95
|
+
function createSchema<const T extends readonly TreeNodeSchema[], const TScope extends string, const TName extends string>(types: T, inputSchemaFactory: SchemaFactoryBeta<TScope>, name: TName): Statics<T> & import("./simple-tree/index.js").TreeNodeSchemaCore<import("./simple-tree/index.js").ScopedSchemaName<`com.fluidframework.extensibleUnionNode<${TScope}>`, TName>, import("./simple-tree/index.js").NodeKind, false, unknown, never, unknown> & (new (data: import("./simple-tree/index.js").InternalTreeNode) => Members<TreeNodeFromImplicitAllowedTypes<T>> & import("./simple-tree/index.js").TreeNode & import("./simple-tree/index.js").WithType<import("./simple-tree/index.js").ScopedSchemaName<`com.fluidframework.extensibleUnionNode<${TScope}>`, TName>, import("./simple-tree/index.js").NodeKind, unknown>);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=extensibleUnionNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensibleUnionNode.d.ts","sourceRoot":"","sources":["../src/extensibleUnionNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EACX,cAAc,EACd,gCAAgC,EAChC,0BAA0B,EAG1B,iBAAiB,EACjB,MAAM,wBAAwB,CAAC;AAUhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,yBAAiB,mBAAmB,CAAC;IACpC;;;OAGG;IACH,UAAiB,OAAO,CAAC,CAAC;QACzB;;;;;WAKG;QACH,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;QAE9B;;;;;;;;;;;;;;;;;;;;;WAqBG;QACH,OAAO,IAAI,OAAO,CAAC;KACnB;IAED;;;OAGG;IACH,UAAiB,OAAO,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE;QAC3D;;WAEG;QACH,MAAM,CAAC,KAAK,SAAS,cAAc,EAClC,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,gCAAgC,CAAC,CAAC,CAAC,GACxC,0BAA0B,CAAC,KAAK,CAAC,CAAC;KACrC;IAED;;;;;;OAMG;IAEH,SAAgB,YAAY,CAC3B,KAAK,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE,EACzC,KAAK,CAAC,MAAM,SAAS,MAAM,EAC3B,KAAK,CAAC,KAAK,SAAS,MAAM,EACzB,KAAK,EAAE,CAAC,EAAE,kBAAkB,EAAE,iBAAiB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,2mBAkDrE;CACD"}
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.ExtensibleUnionNode = void 0;
|
|
8
|
+
const internal_1 = require("@fluidframework/telemetry-utils/internal");
|
|
8
9
|
const index_js_1 = require("./shared-tree/index.js");
|
|
9
10
|
const index_js_2 = require("./simple-tree/index.js");
|
|
10
11
|
/**
|
|
11
|
-
* Utilities for creating extensible
|
|
12
|
+
* Utilities for creating extensible unions using a node.
|
|
12
13
|
* @remarks
|
|
13
|
-
* Use {@link
|
|
14
|
+
* Use {@link ExtensibleUnionNode.createSchema} to create the union schema.
|
|
14
15
|
*
|
|
15
16
|
* Unlike a schema union created using {@link SchemaStaticsBeta.staged | staged} allowed types, this union allows for unknown future types to exist in addition to the known types.
|
|
16
17
|
* This allows for faster roll-outs of new types without waiting for old clients to be updated to be aware of them.
|
|
@@ -22,49 +23,58 @@ const index_js_2 = require("./simple-tree/index.js");
|
|
|
22
23
|
*
|
|
23
24
|
* @example
|
|
24
25
|
* ```typescript
|
|
25
|
-
* const sf = new SchemaFactoryBeta("
|
|
26
|
+
* const sf = new SchemaFactoryBeta("extensibleUnionNodeExample.items");
|
|
26
27
|
* class ItemA extends sf.object("A", { x: sf.string }) {}
|
|
27
28
|
* class ItemB extends sf.object("B", { x: sf.number }) {}
|
|
28
29
|
*
|
|
29
|
-
* class AnyItem extends
|
|
30
|
+
* class AnyItem extends ExtensibleUnionNode.createSchema(
|
|
30
31
|
* [ItemA, ItemB], // Future versions may add more members here
|
|
31
32
|
* sf,
|
|
32
33
|
* "ExtensibleUnion",
|
|
33
34
|
* ) {}
|
|
34
35
|
* // Instances of the union are created using `create`.
|
|
35
36
|
* const anyItem = AnyItem.create(new ItemA({ x: "hello" }));
|
|
36
|
-
* // Reading the content from the union is done via `
|
|
37
|
+
* // Reading the content from the union is done via the `union` property,
|
|
37
38
|
* // which can be `undefined` to handle the case where a future version of this schema allows a type unknown to the current version.
|
|
38
|
-
* const childNode: ItemA | ItemB | undefined = anyItem.
|
|
39
|
+
* const childNode: ItemA | ItemB | undefined = anyItem.union;
|
|
39
40
|
* // To determine which member of the union was present, its schema can be inspected:
|
|
40
41
|
* const aSchema = Tree.schema(childNode ?? assert.fail("No child"));
|
|
41
42
|
* assert.equal(aSchema, ItemA);
|
|
42
43
|
* ```
|
|
43
|
-
* @
|
|
44
|
+
* @beta
|
|
44
45
|
*/
|
|
45
|
-
var
|
|
46
|
-
(function (
|
|
46
|
+
var ExtensibleUnionNode;
|
|
47
|
+
(function (ExtensibleUnionNode) {
|
|
47
48
|
/**
|
|
48
49
|
* Create an extensible schema union which currently supports the types in `types`,
|
|
49
50
|
* but tolerates collaboration with future versions that may include additional types.
|
|
50
51
|
* @remarks
|
|
51
|
-
* See {@link
|
|
52
|
-
* @
|
|
52
|
+
* See {@link ExtensibleUnionNode} for an example use.
|
|
53
|
+
* @beta
|
|
53
54
|
*/
|
|
54
55
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
55
|
-
function
|
|
56
|
+
function createSchema(types, inputSchemaFactory, name) {
|
|
56
57
|
const record = {};
|
|
57
58
|
for (const type of types) {
|
|
58
59
|
record[`_${type.identifier}`] = index_js_2.SchemaFactory.optional(type, { key: type.identifier });
|
|
59
60
|
}
|
|
60
|
-
const schemaFactory = (0, index_js_2.createCustomizedFluidFrameworkScopedFactory)(inputSchemaFactory, "
|
|
61
|
+
const schemaFactory = (0, index_js_2.createCustomizedFluidFrameworkScopedFactory)(inputSchemaFactory, "extensibleUnionNode");
|
|
61
62
|
class Union extends schemaFactory.object(name, record, { allowUnknownOptionalFields: true }) {
|
|
62
|
-
get
|
|
63
|
+
get union() {
|
|
64
|
+
if (!this.isValid()) {
|
|
65
|
+
throw new internal_1.UsageError(`This ExtensibleUnionNode (${Union.identifier}) is in an invalid state. It must have been edited by another client using a different schema or been directly imported or constructed in an invalid state.`);
|
|
66
|
+
}
|
|
63
67
|
for (const [_key, child] of index_js_1.TreeAlpha.children(this)) {
|
|
64
68
|
return child;
|
|
65
69
|
}
|
|
66
70
|
return undefined;
|
|
67
71
|
}
|
|
72
|
+
isValid() {
|
|
73
|
+
// Use inner node, since it includes populated fields even when they are unknown.
|
|
74
|
+
const inner = (0, index_js_2.getInnerNode)(this);
|
|
75
|
+
// Fields only includes non-empty fields, so this is what we need to check the one child invariant.
|
|
76
|
+
return [...inner.fields].length === 1;
|
|
77
|
+
}
|
|
68
78
|
static create(child) {
|
|
69
79
|
const schema = index_js_1.Tree.schema(child);
|
|
70
80
|
return index_js_2.TreeBeta.create(this, {
|
|
@@ -74,6 +84,6 @@ var ExtensibleSchemaUnion;
|
|
|
74
84
|
}
|
|
75
85
|
return (0, index_js_2.eraseSchemaDetailsSubclassable)()(Union);
|
|
76
86
|
}
|
|
77
|
-
|
|
78
|
-
})(
|
|
79
|
-
//# sourceMappingURL=
|
|
87
|
+
ExtensibleUnionNode.createSchema = createSchema;
|
|
88
|
+
})(ExtensibleUnionNode || (exports.ExtensibleUnionNode = ExtensibleUnionNode = {}));
|
|
89
|
+
//# sourceMappingURL=extensibleUnionNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensibleUnionNode.js","sourceRoot":"","sources":["../src/extensibleUnionNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uEAAsE;AAEtE,qDAAyD;AASzD,qDAMgC;AAGhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,IAAiB,mBAAmB,CAoHnC;AApHD,WAAiB,mBAAmB;IAqDnC;;;;;;OAMG;IACH,4EAA4E;IAC5E,SAAgB,YAAY,CAI1B,KAAQ,EAAE,kBAA6C,EAAE,IAAW;QACrE,MAAM,MAAM,GAAwC,EAAE,CAAC;QACvD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,wBAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QACxF,CAAC;QACD,MAAM,aAAa,GAAG,IAAA,sDAA2C,EAChE,kBAAkB,EAClB,qBAAqB,CACrB,CAAC;QAEF,MAAM,KACL,SAAQ,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,0BAA0B,EAAE,IAAI,EAAE,CAAC;YAGhF,IAAW,KAAK;gBACf,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;oBACrB,MAAM,IAAI,qBAAU,CACnB,6BAA6B,KAAK,CAAC,UAAU,6JAA6J,CAC1M,CAAC;gBACH,CAAC;gBACD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,oBAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtD,OAAO,KAA4C,CAAC;gBACrD,CAAC;gBACD,OAAO,SAAS,CAAC;YAClB,CAAC;YAEM,OAAO;gBACb,iFAAiF;gBACjF,MAAM,KAAK,GAAG,IAAA,uBAAY,EAAC,IAAI,CAAC,CAAC;gBACjC,mGAAmG;gBACnG,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;YACvC,CAAC;YAEM,MAAM,CAAC,MAAM,CAEnB,KAA0C;gBAE1C,MAAM,MAAM,GAAG,eAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAClC,OAAO,mBAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;oBAC5B,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC,EAAE,KAAK;iBAIhC,CAAC,CAAC;YACJ,CAAC;SACD;QACD,OAAO,IAAA,yCAA8B,GAGlC,CAAC,KAAK,CAAC,CAAC;IACZ,CAAC;IAtDe,gCAAY,eAsD3B,CAAA;AACF,CAAC,EApHgB,mBAAmB,mCAAnB,mBAAmB,QAoHnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { TreeAlpha, Tree } from \"./shared-tree/index.js\";\nimport type {\n\tTreeNodeSchema,\n\tTreeNodeFromImplicitAllowedTypes,\n\tTreeFieldFromImplicitField,\n\tImplicitFieldSchema,\n\tInsertableTreeFieldFromImplicitField,\n\tSchemaFactoryBeta,\n} from \"./simple-tree/index.js\";\nimport {\n\tcreateCustomizedFluidFrameworkScopedFactory,\n\teraseSchemaDetailsSubclassable,\n\tgetInnerNode,\n\tSchemaFactory,\n\tTreeBeta,\n} from \"./simple-tree/index.js\";\nimport type { UnionToIntersection } from \"./util/index.js\";\n\n/**\n * Utilities for creating extensible unions using a node.\n * @remarks\n * Use {@link ExtensibleUnionNode.createSchema} to create the union schema.\n *\n * Unlike a schema union created using {@link SchemaStaticsBeta.staged | staged} allowed types, this union allows for unknown future types to exist in addition to the known types.\n * This allows for faster roll-outs of new types without waiting for old clients to be updated to be aware of them.\n * This does mean however that old clients may see types they do not know about, which are simply exposed as `undefined` children.\n *\n * `staged` types are lower overhead, and might gain support for `unknown` types in the future, so prefer them when possible.\n * This is simply an alternative for when future compatibility with unknown types is required.\n * It is built on top of the existing {@link ObjectSchemaOptions.allowUnknownOptionalFields | allowUnknownOptionalFields} feature.\n *\n * @example\n * ```typescript\n * const sf = new SchemaFactoryBeta(\"extensibleUnionNodeExample.items\");\n * class ItemA extends sf.object(\"A\", { x: sf.string }) {}\n * class ItemB extends sf.object(\"B\", { x: sf.number }) {}\n *\n * class AnyItem extends ExtensibleUnionNode.createSchema(\n * \t[ItemA, ItemB], // Future versions may add more members here\n * \tsf,\n * \t\"ExtensibleUnion\",\n * ) {}\n * // Instances of the union are created using `create`.\n * const anyItem = AnyItem.create(new ItemA({ x: \"hello\" }));\n * // Reading the content from the union is done via the `union` property,\n * // which can be `undefined` to handle the case where a future version of this schema allows a type unknown to the current version.\n * const childNode: ItemA | ItemB | undefined = anyItem.union;\n * // To determine which member of the union was present, its schema can be inspected:\n * const aSchema = Tree.schema(childNode ?? assert.fail(\"No child\"));\n * assert.equal(aSchema, ItemA);\n * ```\n * @beta\n */\nexport namespace ExtensibleUnionNode {\n\t/**\n\t * Members for classes created by {@link ExtensibleUnionNode.createSchema}.\n\t * @beta\n\t */\n\texport interface Members<T> {\n\t\t/**\n\t\t * The child wrapped by this node has one of the types allowed by the union,\n\t\t * or `undefined` if the type is one which was added to the union by a future version of this schema.\n\t\t *\n\t\t * @throws if {@link ExtensibleUnionNode.Members.isValid} is false.\n\t\t */\n\t\treadonly union: T | undefined;\n\n\t\t/**\n\t\t * Returns true, unless this node is in an invalid state.\n\t\t * @remarks\n\t\t * A well behaved application should not need this API.\n\t\t * If an application is hitting errors when accessing {@link ExtensibleUnionNode.Members.union},\n\t\t * this API can be used to help detect and recover from the invalid state which causes those errors (for example by replacing the invalid nodes with new ones).\n\t\t *\n\t\t * In this context \"invalid\" means that the internal implementation details of this node have had their invariants violated.\n\t\t * This can happen when:\n\t\t * - Using weakly typed construction APIs like {@link (TreeBeta:interface).importConcise} or {@link (TreeAlpha:interface).importVerbose} to construct an invalid state directly.\n\t\t * Using such APIs, even when not creating invalid nodes, is not supported for this schema,\n\t\t * since doing so requires knowing the implementation details of this node which are subject to change.\n\t\t * - By editing a document using a different client using a different schema for this node.\n\t\t * - Violating the TypeScript types to directly manipulate the node internals.\n\t\t * - A bug in this node's implementation (possibly in a different client) corrupted the node.\n\t\t * - Corruption of the document this node is contained in.\n\t\t *\n\t\t * @privateRemarks\n\t\t * We could support {@link (TreeBeta:interface).exportVerbose} using {@link KeyEncodingOptions.allStoredKeys}\n\t\t * then {@link (TreeAlpha:interface).importVerbose} with {@link KeyEncodingOptions.knownStoredKeys}.\n\t\t * However, even this will error (but will not produce an invalid node) if there is a node of an unknown type in the union.\n\t\t */\n\t\tisValid(): boolean;\n\t}\n\n\t/**\n\t * Statics for classes created by {@link ExtensibleUnionNode.createSchema}.\n\t * @beta\n\t */\n\texport interface Statics<T extends readonly TreeNodeSchema[]> {\n\t\t/**\n\t\t * Create a {@link TreeNode} with `this` schema which wraps the provided child to create the union.\n\t\t */\n\t\tcreate<TThis extends TreeNodeSchema>(\n\t\t\tthis: TThis,\n\t\t\tchild: TreeNodeFromImplicitAllowedTypes<T>,\n\t\t): TreeFieldFromImplicitField<TThis>;\n\t}\n\n\t/**\n\t * Create an extensible schema union which currently supports the types in `types`,\n\t * but tolerates collaboration with future versions that may include additional types.\n\t * @remarks\n\t * See {@link ExtensibleUnionNode} for an example use.\n\t * @beta\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\texport function createSchema<\n\t\tconst T extends readonly TreeNodeSchema[],\n\t\tconst TScope extends string,\n\t\tconst TName extends string,\n\t>(types: T, inputSchemaFactory: SchemaFactoryBeta<TScope>, name: TName) {\n\t\tconst record: Record<string, ImplicitFieldSchema> = {};\n\t\tfor (const type of types) {\n\t\t\trecord[`_${type.identifier}`] = SchemaFactory.optional(type, { key: type.identifier });\n\t\t}\n\t\tconst schemaFactory = createCustomizedFluidFrameworkScopedFactory(\n\t\t\tinputSchemaFactory,\n\t\t\t\"extensibleUnionNode\",\n\t\t);\n\n\t\tclass Union\n\t\t\textends schemaFactory.object(name, record, { allowUnknownOptionalFields: true })\n\t\t\timplements Members<TreeNodeFromImplicitAllowedTypes<T>>\n\t\t{\n\t\t\tpublic get union(): TreeNodeFromImplicitAllowedTypes<T> | undefined {\n\t\t\t\tif (!this.isValid()) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`This ExtensibleUnionNode (${Union.identifier}) is in an invalid state. It must have been edited by another client using a different schema or been directly imported or constructed in an invalid state.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tfor (const [_key, child] of TreeAlpha.children(this)) {\n\t\t\t\t\treturn child as TreeNodeFromImplicitAllowedTypes<T>;\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tpublic isValid(): boolean {\n\t\t\t\t// Use inner node, since it includes populated fields even when they are unknown.\n\t\t\t\tconst inner = getInnerNode(this);\n\t\t\t\t// Fields only includes non-empty fields, so this is what we need to check the one child invariant.\n\t\t\t\treturn [...inner.fields].length === 1;\n\t\t\t}\n\n\t\t\tpublic static create<TThis extends TreeNodeSchema>(\n\t\t\t\tthis: TThis,\n\t\t\t\tchild: TreeNodeFromImplicitAllowedTypes<T>,\n\t\t\t): TreeFieldFromImplicitField<TThis> {\n\t\t\t\tconst schema = Tree.schema(child);\n\t\t\t\treturn TreeBeta.create(this, {\n\t\t\t\t\t[`_${schema.identifier}`]: child,\n\t\t\t\t} as unknown as InsertableTreeFieldFromImplicitField<\n\t\t\t\t\tTThis,\n\t\t\t\t\tUnionToIntersection<TThis>\n\t\t\t\t>);\n\t\t\t}\n\t\t}\n\t\treturn eraseSchemaDetailsSubclassable<\n\t\t\tMembers<TreeNodeFromImplicitAllowedTypes<T>>,\n\t\t\tStatics<T>\n\t\t>()(Union);\n\t}\n}\n"]}
|
|
@@ -9,7 +9,7 @@ import { type ITreeCursorSynchronous, type SchemaAndPolicy, type TreeChunk } fro
|
|
|
9
9
|
import { type Brand, type JsonCompatibleReadOnly } from "../../../util/index.js";
|
|
10
10
|
import { TreeCompressionStrategy } from "../../treeCompressionUtils.js";
|
|
11
11
|
import type { FieldBatch } from "./fieldBatch.js";
|
|
12
|
-
import {
|
|
12
|
+
import { EncodedFieldBatch } from "./format.js";
|
|
13
13
|
import type { IncrementalEncodingPolicy } from "./incrementalEncodingPolicy.js";
|
|
14
14
|
/**
|
|
15
15
|
* Reference ID for a chunk that is incrementally encoded.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAM5F,OAAO,EACN,KAAK,SAAS,EACd,KAAK,iBAAiB,EAEtB,KAAK,UAAU,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGN,KAAK,KAAK,EACV,KAAK,sBAAsB,EAE3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAGxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.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AG;AAE5F,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;IAC7C,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,yBAAyB,CAAC,EAAE,yBAAyB,CAAC;CAC/D;AACD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,CACvC,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,CACzB,CAAC;AAiBF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,CA+F/E;AAED,wBAAgB,+BAA+B,CAC9C,aAAa,EAAE,uBAAuB,GACpC,SAAS,CAEX"}
|
|
@@ -34,25 +34,25 @@ function makeFieldBatchCodec(options) {
|
|
|
34
34
|
(0, internal_1.assert)(format_js_1.validVersions.has(writeVersion), 0x935 /* Invalid write version for FieldBatch codec */);
|
|
35
35
|
let uncompressedEncodeFn;
|
|
36
36
|
let schemaCompressedEncodeFn;
|
|
37
|
-
let encodedFieldBatchType;
|
|
38
37
|
switch (writeVersion) {
|
|
39
38
|
case (0, index_js_2.unbrand)(format_js_1.FieldBatchFormatVersion.v1): {
|
|
40
39
|
uncompressedEncodeFn = uncompressedEncode_js_1.uncompressedEncodeV1;
|
|
41
40
|
schemaCompressedEncodeFn = schemaBasedEncode_js_1.schemaCompressedEncodeV1;
|
|
42
|
-
encodedFieldBatchType = format_js_1.EncodedFieldBatchV1;
|
|
43
41
|
break;
|
|
44
42
|
}
|
|
45
43
|
case (0, index_js_2.unbrand)(format_js_1.FieldBatchFormatVersion.v2): {
|
|
46
44
|
uncompressedEncodeFn = uncompressedEncode_js_1.uncompressedEncodeV2;
|
|
47
45
|
schemaCompressedEncodeFn = schemaBasedEncode_js_1.schemaCompressedEncodeV2;
|
|
48
|
-
encodedFieldBatchType = format_js_1.EncodedFieldBatchV2;
|
|
49
46
|
break;
|
|
50
47
|
}
|
|
51
48
|
default: {
|
|
52
49
|
(0, internal_1.unreachableCase)(writeVersion);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
|
-
|
|
52
|
+
// Both the encode and decode logic here support both v1 and v2, as does `validVersions` and `EncodedFieldBatch`.
|
|
53
|
+
// This makes this use of makeVersionedValidatedCodec atypical as it is a single call being used to make a codec that supports all versions,
|
|
54
|
+
// instead of one call per version, then using another utility to select between them based on version.
|
|
55
|
+
return (0, index_js_1.makeVersionedValidatedCodec)(options, format_js_1.validVersions, format_js_1.EncodedFieldBatch, {
|
|
56
56
|
encode: (data, context) => {
|
|
57
57
|
for (const cursor of data) {
|
|
58
58
|
(0, internal_1.assert)(cursor.mode === 1 /* CursorLocationType.Fields */, 0x8a3 /* FieldBatch expects fields cursors */);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAG9E,qEAGgD;AAEhD,sDAMiC;AAOjC,qDAMgC;AAChC,2EAAwE;AAExE,yDAA4C;AAE5C,2CAMqB;AAErB,iEAA4F;AAC5F,mEAAqF;AAMrF,MAAM,gBAAgB,GAAG,IAAA,4BAAiB,EAAmB,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AA6E5F;;;GAGG;AACH,SAAS,gCAAgC,CACxC,aAAsC;IAEtC,OAAO,IAAA,gBAAK,EACX,IAAA,0CAA+B,EAAC,aAAa,EAAE;QAC9C,CAAC,oCAAyB,CAAC,EAAE,mCAAuB,CAAC,EAAE;QACvD,CAAC,6BAAkB,CAAC,KAAK,CAAC,EAAE,mCAAuB,CAAC,EAAE;KACtD,CAAC,CACF,CAAC;AACH,CAAC;AAED,SAAgB,mBAAmB,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AAC,MAAM,EAAE,CAAC,CAAC;QAClC,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AA/FD,kDA+FC;AAED,SAAgB,+BAA+B,CAC9C,aAAsC;IAEtC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,gCAAgC,CAAC,aAAa,CAAC,EAAE,CAAC;AACzF,CAAC;AAJD,0EAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tgetConfigForMinVersionForCollab,\n\tlowestMinVersionForCollab,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../../codec/index.js\";\nimport {\n\tCursorLocationType,\n\ttype ITreeCursorSynchronous,\n\ttype SchemaAndPolicy,\n\ttype TreeChunk,\n} from \"../../../core/index.js\";\nimport {\n\tbrand,\n\tbrandedNumberType,\n\ttype Brand,\n\ttype JsonCompatibleReadOnly,\n\tunbrand,\n} from \"../../../util/index.js\";\nimport { TreeCompressionStrategy } from \"../../treeCompressionUtils.js\";\n\nimport { decode } from \"./chunkDecoding.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport {\n\ttype EncodedFieldBatch,\n\tvalidVersions,\n\tFieldBatchFormatVersion,\n\tEncodedFieldBatchV1,\n\tEncodedFieldBatchV2,\n} from \"./format.js\";\nimport type { IncrementalEncodingPolicy } from \"./incrementalEncodingPolicy.js\";\nimport { schemaCompressedEncodeV1, schemaCompressedEncodeV2 } from \"./schemaBasedEncode.js\";\nimport { uncompressedEncodeV1, uncompressedEncodeV2 } from \"./uncompressedEncode.js\";\n\n/**\n * Reference ID for a chunk that is incrementally encoded.\n */\nexport type ChunkReferenceId = Brand<number, \"forest.ChunkReferenceId\">;\nconst ChunkReferenceId = brandedNumberType<ChunkReferenceId>({ multipleOf: 1, minimum: 0 });\n\n/**\n * Properties for incremental encoding.\n * Fields that support incremental encoding will encode their chunks separately by calling `encodeIncrementalField`.\n * @remarks\n * This supports features like incremental summarization where the summary from these fields can be re-used if\n * unchanged between summaries.\n * Note that each of these chunks that are incrementally encoded is fully self-describing (contain its own shapes\n * list and identifier table) and does not rely on context from its parent.\n */\nexport interface IncrementalEncoder {\n\t/**\n\t * Returns whether a node / field should be incrementally encoded.\n\t * @remarks See {@link IncrementalEncodingPolicy}.\n\t */\n\tshouldEncodeIncrementally: IncrementalEncodingPolicy;\n\t/**\n\t * Called to encode an incremental field at the cursor.\n\t * The chunks for this field are encoded separately from the main buffer.\n\t * @param cursor - The cursor pointing to the field to encode.\n\t * @param chunkEncoder - A function that encodes the contents of the passed chunk in the field.\n\t * @returns The reference IDs of the encoded chunks in the field.\n\t * This is used to retrieve the encoded chunks later.\n\t */\n\tencodeIncrementalField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tchunkEncoder: (chunk: TreeChunk) => EncodedFieldBatch,\n\t): ChunkReferenceId[];\n}\n\n/**\n * Properties for incremental decoding.\n *\n * Fields that had their chunks incrementally encoded will retrieve them by calling `getEncodedIncrementalChunk`.\n * @remarks\n * See {@link IncrementalEncoder} for more details.\n */\nexport interface IncrementalDecoder {\n\t/**\n\t * Called to decode an incremental chunk with the given reference ID.\n\t * @param referenceId - The reference ID of the chunk to decode.\n\t * @param chunkDecoder - A function that decodes the chunk.\n\t * @returns The decoded chunk.\n\t */\n\tdecodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatch) => TreeChunk,\n\t): TreeChunk;\n}\n/**\n * Combines the properties of {@link IncrementalEncoder} and {@link IncrementalDecoder}.\n */\nexport interface IncrementalEncoderDecoder extends IncrementalEncoder, IncrementalDecoder {}\n\nexport interface FieldBatchEncodingContext {\n\treadonly encodeType: TreeCompressionStrategy;\n\treadonly idCompressor: IIdCompressor;\n\treadonly originatorId: SessionId;\n\treadonly schema?: SchemaAndPolicy;\n\t/**\n\t * An encoder / decoder for encoding and decoding of incremental fields.\n\t * This will be defined if incremental encoding is supported and enabled.\n\t */\n\treadonly incrementalEncoderDecoder?: IncrementalEncoderDecoder;\n}\n/**\n * @remarks\n * Fields in this batch currently don't have field schema for the root, which limits optimizations.\n */\nexport type FieldBatchCodec = IJsonCodec<\n\tFieldBatch,\n\tEncodedFieldBatch,\n\tJsonCompatibleReadOnly,\n\tFieldBatchEncodingContext\n>;\n\n/**\n * Convert a MinimumVersionForCollab to write version for {@link FieldBatchCodec}.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n */\nfunction clientVersionToFieldBatchVersion(\n\tclientVersion: MinimumVersionForCollab,\n): FieldBatchFormatVersion {\n\treturn brand(\n\t\tgetConfigForMinVersionForCollab(clientVersion, {\n\t\t\t[lowestMinVersionForCollab]: FieldBatchFormatVersion.v1,\n\t\t\t[FluidClientVersion.v2_73]: FieldBatchFormatVersion.v2,\n\t\t}),\n\t);\n}\n\nexport function makeFieldBatchCodec(options: CodecWriteOptions): FieldBatchCodec {\n\tconst writeVersion = clientVersionToFieldBatchVersion(options.minVersionForCollab);\n\t// Note: it's important that the decode function is schema-agnostic for this strategy/layering to work, since\n\t// the schema that an op was encoded in doesn't necessarily match the current schema for the document (e.g. if\n\t// decode is being run on a client that just submitted a schema change, but the op is from another client who has\n\t// yet to receive that change).\n\tassert(\n\t\tvalidVersions.has(writeVersion),\n\t\t0x935 /* Invalid write version for FieldBatch codec */,\n\t);\n\n\tlet uncompressedEncodeFn: typeof uncompressedEncodeV1 | typeof uncompressedEncodeV2;\n\tlet schemaCompressedEncodeFn:\n\t\t| typeof schemaCompressedEncodeV1\n\t\t| typeof schemaCompressedEncodeV2;\n\tlet encodedFieldBatchType: typeof EncodedFieldBatchV1 | typeof EncodedFieldBatchV2;\n\tswitch (writeVersion) {\n\t\tcase unbrand(FieldBatchFormatVersion.v1): {\n\t\t\tuncompressedEncodeFn = uncompressedEncodeV1;\n\t\t\tschemaCompressedEncodeFn = schemaCompressedEncodeV1;\n\t\t\tencodedFieldBatchType = EncodedFieldBatchV1;\n\t\t\tbreak;\n\t\t}\n\t\tcase unbrand(FieldBatchFormatVersion.v2): {\n\t\t\tuncompressedEncodeFn = uncompressedEncodeV2;\n\t\t\tschemaCompressedEncodeFn = schemaCompressedEncodeV2;\n\t\t\tencodedFieldBatchType = EncodedFieldBatchV2;\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(writeVersion);\n\t\t}\n\t}\n\n\treturn makeVersionedValidatedCodec(options, validVersions, encodedFieldBatchType, {\n\t\tencode: (data: FieldBatch, context: FieldBatchEncodingContext): EncodedFieldBatch => {\n\t\t\tfor (const cursor of data) {\n\t\t\t\tassert(\n\t\t\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t\t\t0x8a3 /* FieldBatch expects fields cursors */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet encoded: EncodedFieldBatch;\n\t\t\tlet incrementalEncoder: IncrementalEncoder | undefined;\n\t\t\tswitch (context.encodeType) {\n\t\t\t\tcase TreeCompressionStrategy.Uncompressed: {\n\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase TreeCompressionStrategy.CompressedIncremental: {\n\t\t\t\t\tassert(\n\t\t\t\t\t\twriteVersion >= FieldBatchFormatVersion.v2,\n\t\t\t\t\t\t0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */,\n\t\t\t\t\t);\n\t\t\t\t\t// Incremental encoding is only supported for CompressedIncremental.\n\t\t\t\t\tincrementalEncoder = context.incrementalEncoderDecoder;\n\t\t\t\t}\n\t\t\t\t// fallthrough\n\t\t\t\tcase TreeCompressionStrategy.Compressed: {\n\t\t\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\t\t\tif (context.schema === undefined) {\n\t\t\t\t\t\t// TODO: consider enabling a somewhat compressed but not schema accelerated encode.\n\t\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tencoded = schemaCompressedEncodeFn(\n\t\t\t\t\t\t\tcontext.schema.schema,\n\t\t\t\t\t\t\tcontext.schema.policy,\n\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\tcontext.idCompressor,\n\t\t\t\t\t\t\tincrementalEncoder,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(context.encodeType);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// TODO: consider checking input data was in schema.\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (data: EncodedFieldBatch, context: FieldBatchEncodingContext): FieldBatch => {\n\t\t\t// TODO: consider checking data is in schema.\n\t\t\treturn decode(\n\t\t\t\tdata,\n\t\t\t\t{\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t},\n\t\t\t\tcontext.incrementalEncoderDecoder,\n\t\t\t).map((chunk) => chunk.cursor());\n\t\t},\n\t});\n}\n\nexport function getCodecTreeForFieldBatchFormat(\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\treturn { name: \"FieldBatch\", version: clientVersionToFieldBatchVersion(clientVersion) };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAG9E,qEAGgD;AAEhD,sDAMiC;AAOjC,qDAMgC;AAChC,2EAAwE;AAExE,yDAA4C;AAE5C,2CAAwF;AAExF,iEAA4F;AA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C,CAAC;gBACrC,CAAC;YACF,CAAC;YAED,oDAAoD;YACpD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,IAAuB,EAAE,OAAkC,EAAc,EAAE;YACnF,6CAA6C;YAC7C,OAAO,IAAA,yBAAM,EACZ,IAAI,EACJ;gBACC,YAAY,EAAE,OAAO,CAAC,YAAY;gBAClC,YAAY,EAAE,OAAO,CAAC,YAAY;aAClC,EACD,OAAO,CAAC,yBAAyB,CACjC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAClC,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AA/FD,kDA+FC;AAED,SAAgB,+BAA+B,CAC9C,aAAsC;IAEtC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,gCAAgC,CAAC,aAAa,CAAC,EAAE,CAAC;AACzF,CAAC;AAJD,0EAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tgetConfigForMinVersionForCollab,\n\tlowestMinVersionForCollab,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../../codec/index.js\";\nimport {\n\tCursorLocationType,\n\ttype ITreeCursorSynchronous,\n\ttype SchemaAndPolicy,\n\ttype TreeChunk,\n} from \"../../../core/index.js\";\nimport {\n\tbrand,\n\tbrandedNumberType,\n\ttype Brand,\n\ttype JsonCompatibleReadOnly,\n\tunbrand,\n} from \"../../../util/index.js\";\nimport { TreeCompressionStrategy } from \"../../treeCompressionUtils.js\";\n\nimport { decode } from \"./chunkDecoding.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport { EncodedFieldBatch, validVersions, FieldBatchFormatVersion } from \"./format.js\";\nimport type { IncrementalEncodingPolicy } from \"./incrementalEncodingPolicy.js\";\nimport { schemaCompressedEncodeV1, schemaCompressedEncodeV2 } from \"./schemaBasedEncode.js\";\nimport { uncompressedEncodeV1, uncompressedEncodeV2 } from \"./uncompressedEncode.js\";\n\n/**\n * Reference ID for a chunk that is incrementally encoded.\n */\nexport type ChunkReferenceId = Brand<number, \"forest.ChunkReferenceId\">;\nconst ChunkReferenceId = brandedNumberType<ChunkReferenceId>({ multipleOf: 1, minimum: 0 });\n\n/**\n * Properties for incremental encoding.\n * Fields that support incremental encoding will encode their chunks separately by calling `encodeIncrementalField`.\n * @remarks\n * This supports features like incremental summarization where the summary from these fields can be re-used if\n * unchanged between summaries.\n * Note that each of these chunks that are incrementally encoded is fully self-describing (contain its own shapes\n * list and identifier table) and does not rely on context from its parent.\n */\nexport interface IncrementalEncoder {\n\t/**\n\t * Returns whether a node / field should be incrementally encoded.\n\t * @remarks See {@link IncrementalEncodingPolicy}.\n\t */\n\tshouldEncodeIncrementally: IncrementalEncodingPolicy;\n\t/**\n\t * Called to encode an incremental field at the cursor.\n\t * The chunks for this field are encoded separately from the main buffer.\n\t * @param cursor - The cursor pointing to the field to encode.\n\t * @param chunkEncoder - A function that encodes the contents of the passed chunk in the field.\n\t * @returns The reference IDs of the encoded chunks in the field.\n\t * This is used to retrieve the encoded chunks later.\n\t */\n\tencodeIncrementalField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tchunkEncoder: (chunk: TreeChunk) => EncodedFieldBatch,\n\t): ChunkReferenceId[];\n}\n\n/**\n * Properties for incremental decoding.\n *\n * Fields that had their chunks incrementally encoded will retrieve them by calling `getEncodedIncrementalChunk`.\n * @remarks\n * See {@link IncrementalEncoder} for more details.\n */\nexport interface IncrementalDecoder {\n\t/**\n\t * Called to decode an incremental chunk with the given reference ID.\n\t * @param referenceId - The reference ID of the chunk to decode.\n\t * @param chunkDecoder - A function that decodes the chunk.\n\t * @returns The decoded chunk.\n\t */\n\tdecodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatch) => TreeChunk,\n\t): TreeChunk;\n}\n/**\n * Combines the properties of {@link IncrementalEncoder} and {@link IncrementalDecoder}.\n */\nexport interface IncrementalEncoderDecoder extends IncrementalEncoder, IncrementalDecoder {}\n\nexport interface FieldBatchEncodingContext {\n\treadonly encodeType: TreeCompressionStrategy;\n\treadonly idCompressor: IIdCompressor;\n\treadonly originatorId: SessionId;\n\treadonly schema?: SchemaAndPolicy;\n\t/**\n\t * An encoder / decoder for encoding and decoding of incremental fields.\n\t * This will be defined if incremental encoding is supported and enabled.\n\t */\n\treadonly incrementalEncoderDecoder?: IncrementalEncoderDecoder;\n}\n/**\n * @remarks\n * Fields in this batch currently don't have field schema for the root, which limits optimizations.\n */\nexport type FieldBatchCodec = IJsonCodec<\n\tFieldBatch,\n\tEncodedFieldBatch,\n\tJsonCompatibleReadOnly,\n\tFieldBatchEncodingContext\n>;\n\n/**\n * Convert a MinimumVersionForCollab to write version for {@link FieldBatchCodec}.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n */\nfunction clientVersionToFieldBatchVersion(\n\tclientVersion: MinimumVersionForCollab,\n): FieldBatchFormatVersion {\n\treturn brand(\n\t\tgetConfigForMinVersionForCollab(clientVersion, {\n\t\t\t[lowestMinVersionForCollab]: FieldBatchFormatVersion.v1,\n\t\t\t[FluidClientVersion.v2_73]: FieldBatchFormatVersion.v2,\n\t\t}),\n\t);\n}\n\nexport function makeFieldBatchCodec(options: CodecWriteOptions): FieldBatchCodec {\n\tconst writeVersion = clientVersionToFieldBatchVersion(options.minVersionForCollab);\n\t// Note: it's important that the decode function is schema-agnostic for this strategy/layering to work, since\n\t// the schema that an op was encoded in doesn't necessarily match the current schema for the document (e.g. if\n\t// decode is being run on a client that just submitted a schema change, but the op is from another client who has\n\t// yet to receive that change).\n\tassert(\n\t\tvalidVersions.has(writeVersion),\n\t\t0x935 /* Invalid write version for FieldBatch codec */,\n\t);\n\n\tlet uncompressedEncodeFn: typeof uncompressedEncodeV1 | typeof uncompressedEncodeV2;\n\tlet schemaCompressedEncodeFn:\n\t\t| typeof schemaCompressedEncodeV1\n\t\t| typeof schemaCompressedEncodeV2;\n\tswitch (writeVersion) {\n\t\tcase unbrand(FieldBatchFormatVersion.v1): {\n\t\t\tuncompressedEncodeFn = uncompressedEncodeV1;\n\t\t\tschemaCompressedEncodeFn = schemaCompressedEncodeV1;\n\t\t\tbreak;\n\t\t}\n\t\tcase unbrand(FieldBatchFormatVersion.v2): {\n\t\t\tuncompressedEncodeFn = uncompressedEncodeV2;\n\t\t\tschemaCompressedEncodeFn = schemaCompressedEncodeV2;\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(writeVersion);\n\t\t}\n\t}\n\n\t// Both the encode and decode logic here support both v1 and v2, as does `validVersions` and `EncodedFieldBatch`.\n\t// This makes this use of makeVersionedValidatedCodec atypical as it is a single call being used to make a codec that supports all versions,\n\t// instead of one call per version, then using another utility to select between them based on version.\n\treturn makeVersionedValidatedCodec(options, validVersions, EncodedFieldBatch, {\n\t\tencode: (data: FieldBatch, context: FieldBatchEncodingContext): EncodedFieldBatch => {\n\t\t\tfor (const cursor of data) {\n\t\t\t\tassert(\n\t\t\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t\t\t0x8a3 /* FieldBatch expects fields cursors */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet encoded: EncodedFieldBatch;\n\t\t\tlet incrementalEncoder: IncrementalEncoder | undefined;\n\t\t\tswitch (context.encodeType) {\n\t\t\t\tcase TreeCompressionStrategy.Uncompressed: {\n\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase TreeCompressionStrategy.CompressedIncremental: {\n\t\t\t\t\tassert(\n\t\t\t\t\t\twriteVersion >= FieldBatchFormatVersion.v2,\n\t\t\t\t\t\t0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */,\n\t\t\t\t\t);\n\t\t\t\t\t// Incremental encoding is only supported for CompressedIncremental.\n\t\t\t\t\tincrementalEncoder = context.incrementalEncoderDecoder;\n\t\t\t\t}\n\t\t\t\t// fallthrough\n\t\t\t\tcase TreeCompressionStrategy.Compressed: {\n\t\t\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\t\t\tif (context.schema === undefined) {\n\t\t\t\t\t\t// TODO: consider enabling a somewhat compressed but not schema accelerated encode.\n\t\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tencoded = schemaCompressedEncodeFn(\n\t\t\t\t\t\t\tcontext.schema.schema,\n\t\t\t\t\t\t\tcontext.schema.policy,\n\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\tcontext.idCompressor,\n\t\t\t\t\t\t\tincrementalEncoder,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(context.encodeType);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// TODO: consider checking input data was in schema.\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (data: EncodedFieldBatch, context: FieldBatchEncodingContext): FieldBatch => {\n\t\t\t// TODO: consider checking data is in schema.\n\t\t\treturn decode(\n\t\t\t\tdata,\n\t\t\t\t{\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t},\n\t\t\t\tcontext.incrementalEncoderDecoder,\n\t\t\t).map((chunk) => chunk.cursor());\n\t\t},\n\t});\n}\n\nexport function getCodecTreeForFieldBatchFormat(\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\treturn { name: \"FieldBatch\", version: clientVersionToFieldBatchVersion(clientVersion) };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAO5F,OAAO,EACN,KAAK,SAAS,EACd,KAAK,iBAAiB,EAEtB,KAAK,UAAU,EAEf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAS,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAE7F,OAAO,EAAE,mBAAmB,EAAiB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIpF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;AACrE,MAAM,MAAM,WAAW,GAAG,UAAU,CACnC,QAAQ,EACR,MAAM,EACN,sBAAsB,EACtB,yBAAyB,CACzB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kCAAkC,CACjD,aAAa,EAAE,uBAAuB,GACpC,mBAAmB,CAOrB;AAED,wBAAgB,yBAAyB,CACxC,OAAO,EAAE,iBAAiB,EAC1B,eAAe,EAAE,eAAe,GAC9B,WAAW,CA2Bb;AAED,wBAAgB,2BAA2B,CAC1C,aAAa,EAAE,uBAAuB,GACpC,SAAS,CAEX"}
|
|
@@ -7,9 +7,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.getCodecTreeForForestFormat = exports.makeForestSummarizerCodec = exports.clientVersionToForestFormatVersion = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
9
|
const internal_2 = require("@fluidframework/runtime-utils/internal");
|
|
10
|
+
const typebox_1 = require("@sinclair/typebox");
|
|
10
11
|
const index_js_1 = require("../../codec/index.js");
|
|
11
12
|
const index_js_2 = require("../../util/index.js");
|
|
12
13
|
const formatCommon_js_1 = require("./formatCommon.js");
|
|
14
|
+
const formatV1_js_1 = require("./formatV1.js");
|
|
15
|
+
const formatV2_js_1 = require("./formatV2.js");
|
|
13
16
|
/**
|
|
14
17
|
* Convert a MinimumVersionForCollab to a ForestFormatVersion.
|
|
15
18
|
* @param clientVersion - The MinimumVersionForCollab to convert.
|
|
@@ -25,7 +28,10 @@ exports.clientVersionToForestFormatVersion = clientVersionToForestFormatVersion;
|
|
|
25
28
|
function makeForestSummarizerCodec(options, fieldBatchCodec) {
|
|
26
29
|
const inner = fieldBatchCodec;
|
|
27
30
|
const writeVersion = clientVersionToForestFormatVersion(options.minVersionForCollab);
|
|
28
|
-
const formatSchema = (
|
|
31
|
+
const formatSchema = typebox_1.Type.Union([formatV1_js_1.FormatV1, formatV2_js_1.FormatV2]);
|
|
32
|
+
// Both the encode and decode logic here support both v1 and v2, as does `validVersions` and `formatSchema`.
|
|
33
|
+
// This makes this use of makeVersionedValidatedCodec atypical as it is a single call being used to make a codec that supports all versions,
|
|
34
|
+
// instead of one call per version, then using another utility to select between them based on version.
|
|
29
35
|
return (0, index_js_1.makeVersionedValidatedCodec)(options, formatCommon_js_1.validVersions, formatSchema, {
|
|
30
36
|
encode: (data, context) => {
|
|
31
37
|
const keys = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,qEAGgD;
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,qEAGgD;AAChD,+CAAyC;AAEzC,mDAM8B;AAE9B,kDAAyE;AAGzE,uDAAoF;AACpF,+CAAyC;AACzC,+CAAyC;AAazC;;;;GAIG;AACH,SAAgB,kCAAkC,CACjD,aAAsC;IAEtC,OAAO,IAAA,gBAAK,EACX,IAAA,0CAA+B,EAAC,aAAa,EAAE;QAC9C,CAAC,oCAAyB,CAAC,EAAE,qCAAmB,CAAC,EAAE;QACnD,CAAC,6BAAkB,CAAC,KAAK,CAAC,EAAE,qCAAmB,CAAC,EAAE;KAClD,CAAC,CACF,CAAC;AACH,CAAC;AATD,gFASC;AAED,SAAgB,yBAAyB,CACxC,OAA0B,EAC1B,eAAgC;IAEhC,MAAM,KAAK,GAAG,eAAe,CAAC;IAC9B,MAAM,YAAY,GAAG,kCAAkC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACrF,MAAM,YAAY,GAAG,cAAI,CAAC,KAAK,CAAC,CAAC,sBAAQ,EAAE,sBAAQ,CAAC,CAAC,CAAC;IACtD,4GAA4G;IAC5G,4IAA4I;IAC5I,uGAAuG;IACvG,OAAO,IAAA,sCAA2B,EAAC,OAAO,EAAE,+BAAa,EAAE,YAAY,EAAE;QACxE,MAAM,EAAE,CAAC,IAAc,EAAE,OAAkC,EAAU,EAAE;YACtE,MAAM,IAAI,GAAe,EAAE,CAAC;YAC5B,MAAM,MAAM,GAA6B,EAAE,CAAC;YAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;gBACjC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACf,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QAC/E,CAAC;QACD,MAAM,EAAE,CAAC,IAAY,EAAE,OAAkC,EAAY,EAAE;YACtE,MAAM,GAAG,GAA0C,IAAI,GAAG,EAAE,CAAC;YAC7D,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAClD,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC3E,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC/C,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAA,cAAG,GAAE,EAAE,KAAK,CAAC,CAAC;YAC3C,CAAC;YACD,OAAO,GAAG,CAAC;QACZ,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AA9BD,8DA8BC;AAED,SAAgB,2BAA2B,CAC1C,aAAsC;IAEtC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,kCAAkC,CAAC,aAAa,CAAC,EAAE,CAAC;AACvF,CAAC;AAJD,kEAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tgetConfigForMinVersionForCollab,\n\tlowestMinVersionForCollab,\n} from \"@fluidframework/runtime-utils/internal\";\nimport { Type } from \"@sinclair/typebox\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../codec/index.js\";\nimport type { FieldKey, ITreeCursorSynchronous } from \"../../core/index.js\";\nimport { brand, type JsonCompatibleReadOnly } from \"../../util/index.js\";\nimport type { FieldBatchCodec, FieldBatchEncodingContext } from \"../chunked-forest/index.js\";\n\nimport { ForestFormatVersion, validVersions, type Format } from \"./formatCommon.js\";\nimport { FormatV1 } from \"./formatV1.js\";\nimport { FormatV2 } from \"./formatV2.js\";\n\n/**\n * Uses field cursors\n */\nexport type FieldSet = ReadonlyMap<FieldKey, ITreeCursorSynchronous>;\nexport type ForestCodec = IJsonCodec<\n\tFieldSet,\n\tFormat,\n\tJsonCompatibleReadOnly,\n\tFieldBatchEncodingContext\n>;\n\n/**\n * Convert a MinimumVersionForCollab to a ForestFormatVersion.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n * @returns The ForestFormatVersion that corresponds to the provided MinimumVersionForCollab.\n */\nexport function clientVersionToForestFormatVersion(\n\tclientVersion: MinimumVersionForCollab,\n): ForestFormatVersion {\n\treturn brand(\n\t\tgetConfigForMinVersionForCollab(clientVersion, {\n\t\t\t[lowestMinVersionForCollab]: ForestFormatVersion.v1,\n\t\t\t[FluidClientVersion.v2_74]: ForestFormatVersion.v2,\n\t\t}),\n\t);\n}\n\nexport function makeForestSummarizerCodec(\n\toptions: CodecWriteOptions,\n\tfieldBatchCodec: FieldBatchCodec,\n): ForestCodec {\n\tconst inner = fieldBatchCodec;\n\tconst writeVersion = clientVersionToForestFormatVersion(options.minVersionForCollab);\n\tconst formatSchema = Type.Union([FormatV1, FormatV2]);\n\t// Both the encode and decode logic here support both v1 and v2, as does `validVersions` and `formatSchema`.\n\t// This makes this use of makeVersionedValidatedCodec atypical as it is a single call being used to make a codec that supports all versions,\n\t// instead of one call per version, then using another utility to select between them based on version.\n\treturn makeVersionedValidatedCodec(options, validVersions, formatSchema, {\n\t\tencode: (data: FieldSet, context: FieldBatchEncodingContext): Format => {\n\t\t\tconst keys: FieldKey[] = [];\n\t\t\tconst fields: ITreeCursorSynchronous[] = [];\n\t\t\tfor (const [key, value] of data) {\n\t\t\t\tkeys.push(key);\n\t\t\t\tfields.push(value);\n\t\t\t}\n\t\t\treturn { keys, fields: inner.encode(fields, context), version: writeVersion };\n\t\t},\n\t\tdecode: (data: Format, context: FieldBatchEncodingContext): FieldSet => {\n\t\t\tconst out: Map<FieldKey, ITreeCursorSynchronous> = new Map();\n\t\t\tconst fields = inner.decode(data.fields, context);\n\t\t\tassert(data.keys.length === fields.length, 0x891 /* mismatched lengths */);\n\t\t\tfor (const [index, field] of fields.entries()) {\n\t\t\t\tout.set(data.keys[index] ?? oob(), field);\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\t});\n}\n\nexport function getCodecTreeForForestFormat(\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\treturn { name: \"Forest\", version: clientVersionToForestFormatVersion(clientVersion) };\n}\n"]}
|
|
@@ -14,10 +14,10 @@ export declare const ForestFormatVersion: {
|
|
|
14
14
|
};
|
|
15
15
|
export type ForestFormatVersion = Values<typeof ForestFormatVersion>;
|
|
16
16
|
export declare const validVersions: Set<import("../../util/brand.js").Brand<1, "ForestFormatVersion"> | import("../../util/brand.js").Brand<2, "ForestFormatVersion">>;
|
|
17
|
-
export declare const FormatCommon: (version:
|
|
18
|
-
version: import("@sinclair/typebox").TLiteral<
|
|
17
|
+
export declare const FormatCommon: <const TVersion extends ForestFormatVersion>(version: TVersion) => import("@sinclair/typebox").TObject<{
|
|
18
|
+
version: import("@sinclair/typebox").TLiteral<TVersion>;
|
|
19
19
|
keys: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnsafe<schemaFormatV1.FieldKey>>;
|
|
20
20
|
fields: import("@sinclair/typebox").TUnsafe<import("../../util/utils.js").JsonCompatibleReadOnly>;
|
|
21
21
|
}>;
|
|
22
|
-
export type Format = Static<ReturnType<typeof FormatCommon
|
|
22
|
+
export type Format<TVersion extends ForestFormatVersion = ForestFormatVersion> = Static<ReturnType<typeof FormatCommon<TVersion>>>;
|
|
23
23
|
//# sourceMappingURL=formatCommon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatCommon.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAc,KAAK,MAAM,EAAgC,MAAM,qBAAqB,CAAC;AAE5F;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;CAI9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE,eAAO,MAAM,aAAa,oIAAmD,CAAC;AAE9E,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"formatCommon.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAc,KAAK,MAAM,EAAgC,MAAM,qBAAqB,CAAC;AAE5F;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;CAI9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE,eAAO,MAAM,aAAa,oIAAmD,CAAC;AAE9E,eAAO,MAAM,YAAY,wDACf,QAAQ;;;;EAWhB,CAAC;AACH,MAAM,MAAM,MAAM,CAAC,QAAQ,SAAS,mBAAmB,GAAG,mBAAmB,IAAI,MAAM,CACtF,UAAU,CAAC,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC,CACzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatCommon.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatCommon.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAsD;AAEtD,kDAAqD;AACrD,kDAA4F;AAE5F;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,qBAAU,EAAC,qBAAqB,EAAE;IACpE,EAAE,EAAE,CAAC;IACL,gDAAgD;IAChD,EAAE,EAAE,CAAC;CACL,CAAC,CAAC;AAGU,QAAA,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC,CAAC,CAAC;AAEvE,MAAM,YAAY,GAAG,CAC3B,
|
|
1
|
+
{"version":3,"file":"formatCommon.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatCommon.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAsD;AAEtD,kDAAqD;AACrD,kDAA4F;AAE5F;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,qBAAU,EAAC,qBAAqB,EAAE;IACpE,EAAE,EAAE,CAAC;IACL,gDAAgD;IAChD,EAAE,EAAE,CAAC;CACL,CAAC,CAAC;AAGU,QAAA,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC,CAAC,CAAC;AAEvE,MAAM,YAAY,GAAG,CAC3B,OAAiB,EAGhB,EAAE,CACH,cAAI,CAAC,MAAM,CACV;IACC,OAAO,EAAE,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,IAAI,EAAE,cAAI,CAAC,KAAK,CAAC,yBAAc,CAAC,cAAc,CAAC;IAC/C,MAAM,EAAE,uCAA4B,EAAE,yBAAyB;CAC/D,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAZU,QAAA,YAAY,gBAYtB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type Static, Type } from \"@sinclair/typebox\";\n\nimport { schemaFormatV1 } from \"../../core/index.js\";\nimport { strictEnum, type Values, JsonCompatibleReadOnlySchema } from \"../../util/index.js\";\n\n/**\n * The format version for the forest.\n */\nexport const ForestFormatVersion = strictEnum(\"ForestFormatVersion\", {\n\tv1: 1,\n\t/** This format supports incremental encoding */\n\tv2: 2,\n});\nexport type ForestFormatVersion = Values<typeof ForestFormatVersion>;\n\nexport const validVersions = new Set([...Object.values(ForestFormatVersion)]);\n\nexport const FormatCommon = <const TVersion extends ForestFormatVersion>(\n\tversion: TVersion,\n\t// Return type is intentionally derived.\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n) =>\n\tType.Object(\n\t\t{\n\t\t\tversion: Type.Literal(version),\n\t\t\tkeys: Type.Array(schemaFormatV1.FieldKeySchema),\n\t\t\tfields: JsonCompatibleReadOnlySchema, // Uses field batch codec\n\t\t},\n\t\t{ additionalProperties: false },\n\t);\nexport type Format<TVersion extends ForestFormatVersion = ForestFormatVersion> = Static<\n\tReturnType<typeof FormatCommon<TVersion>>\n>;\n"]}
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { Static } from "@sinclair/typebox";
|
|
6
|
-
import { ForestFormatVersion } from "./formatCommon.js";
|
|
7
6
|
export declare const FormatV1: import("@sinclair/typebox").TObject<{
|
|
8
|
-
version: import("@sinclair/typebox").TLiteral<ForestFormatVersion
|
|
7
|
+
version: import("@sinclair/typebox").TLiteral<import("../../util/brand.js").Brand<1, "ForestFormatVersion">>;
|
|
9
8
|
keys: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnsafe<import("../../core/index.js").FieldKey>>;
|
|
10
|
-
fields: import("@sinclair/typebox").TUnsafe<import("../../
|
|
9
|
+
fields: import("@sinclair/typebox").TUnsafe<import("../../index.js").JsonCompatibleReadOnly>;
|
|
11
10
|
}>;
|
|
12
11
|
export type FormatV1 = Static<typeof FormatV1>;
|
|
13
12
|
//# sourceMappingURL=formatV1.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatV1.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIhD,
|
|
1
|
+
{"version":3,"file":"formatV1.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIhD,eAAO,MAAM,QAAQ;;;;EAAuC,CAAC;AAC7D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC"}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.FormatV1 = void 0;
|
|
8
|
-
const index_js_1 = require("../../util/index.js");
|
|
9
8
|
const formatCommon_js_1 = require("./formatCommon.js");
|
|
10
|
-
exports.FormatV1 = (0, formatCommon_js_1.FormatCommon)(
|
|
9
|
+
exports.FormatV1 = (0, formatCommon_js_1.FormatCommon)(formatCommon_js_1.ForestFormatVersion.v1);
|
|
11
10
|
//# sourceMappingURL=formatV1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatV1.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatV1.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,
|
|
1
|
+
{"version":3,"file":"formatV1.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatV1.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,uDAAsE;AAEzD,QAAA,QAAQ,GAAG,IAAA,8BAAY,EAAC,qCAAmB,CAAC,EAAE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Static } from \"@sinclair/typebox\";\n\nimport { FormatCommon, ForestFormatVersion } from \"./formatCommon.js\";\n\nexport const FormatV1 = FormatCommon(ForestFormatVersion.v1);\nexport type FormatV1 = Static<typeof FormatV1>;\n"]}
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { Static } from "@sinclair/typebox";
|
|
6
|
-
import { ForestFormatVersion } from "./formatCommon.js";
|
|
7
6
|
export declare const FormatV2: import("@sinclair/typebox").TObject<{
|
|
8
|
-
version: import("@sinclair/typebox").TLiteral<ForestFormatVersion
|
|
7
|
+
version: import("@sinclair/typebox").TLiteral<import("../../util/brand.js").Brand<2, "ForestFormatVersion">>;
|
|
9
8
|
keys: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnsafe<import("../../core/index.js").FieldKey>>;
|
|
10
|
-
fields: import("@sinclair/typebox").TUnsafe<import("../../
|
|
9
|
+
fields: import("@sinclair/typebox").TUnsafe<import("../../index.js").JsonCompatibleReadOnly>;
|
|
11
10
|
}>;
|
|
12
11
|
export type FormatV2 = Static<typeof FormatV2>;
|
|
13
12
|
//# sourceMappingURL=formatV2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatV2.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatV2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIhD,
|
|
1
|
+
{"version":3,"file":"formatV2.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatV2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIhD,eAAO,MAAM,QAAQ;;;;EAAuC,CAAC;AAC7D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC"}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.FormatV2 = void 0;
|
|
8
|
-
const index_js_1 = require("../../util/index.js");
|
|
9
8
|
const formatCommon_js_1 = require("./formatCommon.js");
|
|
10
|
-
exports.FormatV2 = (0, formatCommon_js_1.FormatCommon)(
|
|
9
|
+
exports.FormatV2 = (0, formatCommon_js_1.FormatCommon)(formatCommon_js_1.ForestFormatVersion.v2);
|
|
11
10
|
//# sourceMappingURL=formatV2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatV2.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatV2.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,
|
|
1
|
+
{"version":3,"file":"formatV2.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatV2.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,uDAAsE;AAEzD,QAAA,QAAQ,GAAG,IAAA,8BAAY,EAAC,qCAAmB,CAAC,EAAE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Static } from \"@sinclair/typebox\";\n\nimport { FormatCommon, ForestFormatVersion } from \"./formatCommon.js\";\n\nexport const FormatV2 = FormatCommon(ForestFormatVersion.v2);\nexport type FormatV2 = Static<typeof FormatV2>;\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { TAnySchema } from "@sinclair/typebox";
|
|
6
|
-
import { type ICodecOptions, type IJsonCodec, type
|
|
6
|
+
import { type ICodecOptions, type IJsonCodec, type SchemaValidationFunction } from "../../codec/index.js";
|
|
7
7
|
import type { ChangeEncodingContext, EncodedRevisionTag, FieldKindIdentifier, RevisionInfo, RevisionTag } from "../../core/index.js";
|
|
8
8
|
import { type IdAllocator, type JsonCompatibleReadOnly, type Mutable } from "../../util/index.js";
|
|
9
9
|
import { type ChangeAtomIdBTree } from "../changeAtomIdBTree.js";
|
|
@@ -14,7 +14,7 @@ import type { FieldKindConfiguration } from "./fieldKindConfiguration.js";
|
|
|
14
14
|
import { type EncodedBuilds, type EncodedFieldChangeMap, EncodedModularChangesetV1, type EncodedNodeChangeset, type EncodedRevisionInfo } from "./modularChangeFormatV1.js";
|
|
15
15
|
import { type FieldChangeset, type FieldChangeMap, type ModularChangeset, type NodeChangeset, type NodeId } from "./modularChangeTypes.js";
|
|
16
16
|
type ModularChangeCodec = IJsonCodec<ModularChangeset, EncodedModularChangesetV1, EncodedModularChangesetV1, ChangeEncodingContext>;
|
|
17
|
-
type FieldCodec =
|
|
17
|
+
type FieldCodec = IJsonCodec<FieldChangeset, JsonCompatibleReadOnly, JsonCompatibleReadOnly, FieldChangeEncodingContext>;
|
|
18
18
|
type FieldChangesetCodecs = Map<FieldKindIdentifier, {
|
|
19
19
|
compiledSchema?: SchemaValidationFunction<TAnySchema>;
|
|
20
20
|
codec: FieldCodec;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modularChangeCodecV1.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeCodecV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,
|
|
1
|
+
{"version":3,"file":"modularChangeCodecV1.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeCodecV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OA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