@fluidframework/tree 2.53.1 → 2.61.0-355054

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.
Files changed (452) hide show
  1. package/.eslintrc.cjs +0 -19
  2. package/.mocharc.cjs +2 -3
  3. package/.mocharc.customBenchmarks.cjs +1 -9
  4. package/CHANGELOG.md +56 -0
  5. package/alpha.d.ts +1 -1
  6. package/api-report/tree.alpha.api.md +51 -37
  7. package/api-report/tree.beta.api.md +16 -2
  8. package/api-report/{tree.legacy.alpha.api.md → tree.legacy.beta.api.md} +72 -6
  9. package/api-report/tree.legacy.public.api.md +2 -2
  10. package/api-report/tree.public.api.md +2 -2
  11. package/beta.d.ts +1 -1
  12. package/dist/alpha.d.ts +17 -7
  13. package/dist/beta.d.ts +10 -4
  14. package/dist/codec/codec.d.ts +43 -6
  15. package/dist/codec/codec.d.ts.map +1 -1
  16. package/dist/codec/codec.js +22 -2
  17. package/dist/codec/codec.js.map +1 -1
  18. package/dist/codec/index.d.ts +1 -1
  19. package/dist/codec/index.d.ts.map +1 -1
  20. package/dist/codec/index.js +4 -1
  21. package/dist/codec/index.js.map +1 -1
  22. package/dist/external-utilities/index.d.ts +1 -1
  23. package/dist/external-utilities/index.d.ts.map +1 -1
  24. package/dist/external-utilities/index.js +2 -1
  25. package/dist/external-utilities/index.js.map +1 -1
  26. package/dist/external-utilities/typeboxValidator.d.ts +6 -1
  27. package/dist/external-utilities/typeboxValidator.d.ts.map +1 -1
  28. package/dist/external-utilities/typeboxValidator.js +7 -1
  29. package/dist/external-utilities/typeboxValidator.js.map +1 -1
  30. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
  31. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  32. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +28 -5
  33. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  34. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
  35. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
  37. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  38. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
  39. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/codecs.js +9 -2
  41. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  42. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
  43. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  44. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +91 -16
  45. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
  47. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/codec/format.js +10 -1
  49. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  51. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  53. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
  54. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  55. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +17 -6
  56. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  58. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  60. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  61. package/dist/feature-libraries/forest-summary/codec.js +3 -0
  62. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  63. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
  64. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  65. package/dist/feature-libraries/forest-summary/forestSummarizer.js +76 -38
  66. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  67. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
  68. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
  69. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +322 -0
  70. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
  71. package/dist/feature-libraries/forest-summary/index.d.ts +1 -1
  72. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  73. package/dist/feature-libraries/forest-summary/index.js +2 -1
  74. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  75. package/dist/feature-libraries/index.d.ts +1 -1
  76. package/dist/feature-libraries/index.d.ts.map +1 -1
  77. package/dist/feature-libraries/index.js +2 -1
  78. package/dist/feature-libraries/index.js.map +1 -1
  79. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  80. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  81. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +1 -1
  82. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  83. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
  84. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  85. package/dist/feature-libraries/treeCompressionUtils.d.ts +15 -0
  86. package/dist/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
  87. package/dist/feature-libraries/treeCompressionUtils.js +16 -1
  88. package/dist/feature-libraries/treeCompressionUtils.js.map +1 -1
  89. package/dist/index.d.ts +3 -3
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +6 -2
  92. package/dist/index.js.map +1 -1
  93. package/dist/jsonDomainSchema.d.ts +1 -1
  94. package/dist/jsonDomainSchema.d.ts.map +1 -1
  95. package/dist/legacy.d.ts +21 -4
  96. package/dist/packageVersion.d.ts +1 -1
  97. package/dist/packageVersion.d.ts.map +1 -1
  98. package/dist/packageVersion.js +1 -1
  99. package/dist/packageVersion.js.map +1 -1
  100. package/dist/public.d.ts +5 -3
  101. package/dist/shared-tree/schematizingTreeView.d.ts +1 -1
  102. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  103. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  104. package/dist/shared-tree/sharedTree.d.ts +23 -6
  105. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  106. package/dist/shared-tree/sharedTree.js +4 -1
  107. package/dist/shared-tree/sharedTree.js.map +1 -1
  108. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  109. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  110. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  111. package/dist/shared-tree/tree.d.ts.map +1 -1
  112. package/dist/shared-tree/tree.js +3 -0
  113. package/dist/shared-tree/tree.js.map +1 -1
  114. package/dist/shared-tree/treeAlpha.d.ts +9 -11
  115. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  116. package/dist/shared-tree/treeAlpha.js.map +1 -1
  117. package/dist/shared-tree/treeCheckout.d.ts +2 -2
  118. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  119. package/dist/shared-tree/treeCheckout.js +1 -0
  120. package/dist/shared-tree/treeCheckout.js.map +1 -1
  121. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  122. package/dist/shared-tree-core/sharedTreeCore.js +13 -0
  123. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  124. package/dist/sharedTreeAttributes.d.ts +2 -2
  125. package/dist/sharedTreeAttributes.js +2 -2
  126. package/dist/sharedTreeAttributes.js.map +1 -1
  127. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  128. package/dist/simple-tree/api/conciseTree.js +1 -1
  129. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  130. package/dist/simple-tree/api/customTree.d.ts +39 -11
  131. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  132. package/dist/simple-tree/api/customTree.js +79 -19
  133. package/dist/simple-tree/api/customTree.js.map +1 -1
  134. package/dist/simple-tree/api/getJsonSchema.d.ts +7 -2
  135. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  136. package/dist/simple-tree/api/getJsonSchema.js +1 -0
  137. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  138. package/dist/simple-tree/api/index.d.ts +2 -1
  139. package/dist/simple-tree/api/index.d.ts.map +1 -1
  140. package/dist/simple-tree/api/index.js +4 -1
  141. package/dist/simple-tree/api/index.js.map +1 -1
  142. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
  143. package/dist/simple-tree/api/schemaCreationUtilities.js +1 -1
  144. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  145. package/dist/simple-tree/api/schemaFactory.d.ts +9 -6
  146. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  147. package/dist/simple-tree/api/schemaFactory.js +8 -7
  148. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  149. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
  150. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  151. package/dist/simple-tree/api/schemaFactoryAlpha.js +21 -25
  152. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  153. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
  154. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
  155. package/dist/simple-tree/api/schemaFactoryBeta.js +26 -0
  156. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -0
  157. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +5 -3
  158. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  159. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  160. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
  161. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  162. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
  163. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  164. package/dist/simple-tree/api/transactionTypes.d.ts +1 -0
  165. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  166. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  167. package/dist/simple-tree/api/tree.d.ts +68 -74
  168. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  169. package/dist/simple-tree/api/tree.js.map +1 -1
  170. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  171. package/dist/simple-tree/api/verboseTree.js +3 -3
  172. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  173. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
  174. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
  175. package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
  176. package/dist/simple-tree/fieldSchema.d.ts +3 -4
  177. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  178. package/dist/simple-tree/fieldSchema.js +0 -3
  179. package/dist/simple-tree/fieldSchema.js.map +1 -1
  180. package/dist/simple-tree/index.d.ts +1 -1
  181. package/dist/simple-tree/index.d.ts.map +1 -1
  182. package/dist/simple-tree/index.js +4 -2
  183. package/dist/simple-tree/index.js.map +1 -1
  184. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  185. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -3
  186. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  187. package/dist/simple-tree/simpleSchema.d.ts +12 -0
  188. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  189. package/dist/simple-tree/simpleSchema.js.map +1 -1
  190. package/dist/simple-tree/toStoredSchema.d.ts +0 -3
  191. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  192. package/dist/simple-tree/toStoredSchema.js +0 -3
  193. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  194. package/dist/tableSchema.d.ts +11 -80
  195. package/dist/tableSchema.d.ts.map +1 -1
  196. package/dist/tableSchema.js +200 -117
  197. package/dist/tableSchema.js.map +1 -1
  198. package/dist/treeFactory.d.ts +1 -2
  199. package/dist/treeFactory.d.ts.map +1 -1
  200. package/dist/treeFactory.js +1 -2
  201. package/dist/treeFactory.js.map +1 -1
  202. package/dist/util/breakable.d.ts.map +1 -1
  203. package/dist/util/breakable.js +7 -1
  204. package/dist/util/breakable.js.map +1 -1
  205. package/internal.d.ts +1 -1
  206. package/legacy.d.ts +1 -1
  207. package/lib/alpha.d.ts +17 -7
  208. package/lib/beta.d.ts +10 -4
  209. package/lib/codec/codec.d.ts +43 -6
  210. package/lib/codec/codec.d.ts.map +1 -1
  211. package/lib/codec/codec.js +19 -1
  212. package/lib/codec/codec.js.map +1 -1
  213. package/lib/codec/index.d.ts +1 -1
  214. package/lib/codec/index.d.ts.map +1 -1
  215. package/lib/codec/index.js +1 -1
  216. package/lib/codec/index.js.map +1 -1
  217. package/lib/external-utilities/index.d.ts +1 -1
  218. package/lib/external-utilities/index.d.ts.map +1 -1
  219. package/lib/external-utilities/index.js +1 -1
  220. package/lib/external-utilities/index.js.map +1 -1
  221. package/lib/external-utilities/typeboxValidator.d.ts +6 -1
  222. package/lib/external-utilities/typeboxValidator.d.ts.map +1 -1
  223. package/lib/external-utilities/typeboxValidator.js +6 -0
  224. package/lib/external-utilities/typeboxValidator.js.map +1 -1
  225. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
  226. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  227. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +27 -5
  228. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  229. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
  230. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  231. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
  232. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  233. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
  234. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  235. package/lib/feature-libraries/chunked-forest/codec/codecs.js +10 -3
  236. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  237. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
  238. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  239. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +87 -14
  240. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  241. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
  242. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  243. package/lib/feature-libraries/chunked-forest/codec/format.js +9 -0
  244. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  245. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  246. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  247. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  248. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
  249. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  250. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +18 -7
  251. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  252. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  253. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  254. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  255. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  256. package/lib/feature-libraries/forest-summary/codec.js +3 -0
  257. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  258. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
  259. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  260. package/lib/feature-libraries/forest-summary/forestSummarizer.js +75 -37
  261. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  262. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
  263. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
  264. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +318 -0
  265. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
  266. package/lib/feature-libraries/forest-summary/index.d.ts +1 -1
  267. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  268. package/lib/feature-libraries/forest-summary/index.js +1 -1
  269. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  270. package/lib/feature-libraries/index.d.ts +1 -1
  271. package/lib/feature-libraries/index.d.ts.map +1 -1
  272. package/lib/feature-libraries/index.js +1 -1
  273. package/lib/feature-libraries/index.js.map +1 -1
  274. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  275. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  276. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +3 -3
  277. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  278. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
  279. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  280. package/lib/feature-libraries/treeCompressionUtils.d.ts +15 -0
  281. package/lib/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
  282. package/lib/feature-libraries/treeCompressionUtils.js +15 -0
  283. package/lib/feature-libraries/treeCompressionUtils.js.map +1 -1
  284. package/lib/index.d.ts +3 -3
  285. package/lib/index.d.ts.map +1 -1
  286. package/lib/index.js +4 -4
  287. package/lib/index.js.map +1 -1
  288. package/lib/jsonDomainSchema.d.ts +1 -1
  289. package/lib/jsonDomainSchema.d.ts.map +1 -1
  290. package/lib/legacy.d.ts +21 -4
  291. package/lib/packageVersion.d.ts +1 -1
  292. package/lib/packageVersion.d.ts.map +1 -1
  293. package/lib/packageVersion.js +1 -1
  294. package/lib/packageVersion.js.map +1 -1
  295. package/lib/public.d.ts +5 -3
  296. package/lib/shared-tree/schematizingTreeView.d.ts +1 -1
  297. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  298. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  299. package/lib/shared-tree/sharedTree.d.ts +23 -6
  300. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  301. package/lib/shared-tree/sharedTree.js +4 -1
  302. package/lib/shared-tree/sharedTree.js.map +1 -1
  303. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  304. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  305. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  306. package/lib/shared-tree/tree.d.ts.map +1 -1
  307. package/lib/shared-tree/tree.js +3 -0
  308. package/lib/shared-tree/tree.js.map +1 -1
  309. package/lib/shared-tree/treeAlpha.d.ts +9 -11
  310. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  311. package/lib/shared-tree/treeAlpha.js.map +1 -1
  312. package/lib/shared-tree/treeCheckout.d.ts +2 -2
  313. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  314. package/lib/shared-tree/treeCheckout.js +1 -0
  315. package/lib/shared-tree/treeCheckout.js.map +1 -1
  316. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  317. package/lib/shared-tree-core/sharedTreeCore.js +13 -0
  318. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  319. package/lib/sharedTreeAttributes.d.ts +2 -2
  320. package/lib/sharedTreeAttributes.js +2 -2
  321. package/lib/sharedTreeAttributes.js.map +1 -1
  322. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  323. package/lib/simple-tree/api/conciseTree.js +2 -2
  324. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  325. package/lib/simple-tree/api/customTree.d.ts +39 -11
  326. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  327. package/lib/simple-tree/api/customTree.js +79 -19
  328. package/lib/simple-tree/api/customTree.js.map +1 -1
  329. package/lib/simple-tree/api/getJsonSchema.d.ts +7 -2
  330. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  331. package/lib/simple-tree/api/getJsonSchema.js +1 -0
  332. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  333. package/lib/simple-tree/api/index.d.ts +2 -1
  334. package/lib/simple-tree/api/index.d.ts.map +1 -1
  335. package/lib/simple-tree/api/index.js +2 -1
  336. package/lib/simple-tree/api/index.js.map +1 -1
  337. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
  338. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
  339. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  340. package/lib/simple-tree/api/schemaFactory.d.ts +9 -6
  341. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  342. package/lib/simple-tree/api/schemaFactory.js +6 -6
  343. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  344. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
  345. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  346. package/lib/simple-tree/api/schemaFactoryAlpha.js +22 -26
  347. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  348. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
  349. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
  350. package/lib/simple-tree/api/schemaFactoryBeta.js +22 -0
  351. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -0
  352. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +5 -3
  353. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  354. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  355. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
  356. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  357. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
  358. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  359. package/lib/simple-tree/api/transactionTypes.d.ts +1 -0
  360. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  361. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  362. package/lib/simple-tree/api/tree.d.ts +68 -74
  363. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  364. package/lib/simple-tree/api/tree.js.map +1 -1
  365. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  366. package/lib/simple-tree/api/verboseTree.js +4 -4
  367. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  368. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
  369. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
  370. package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
  371. package/lib/simple-tree/fieldSchema.d.ts +3 -4
  372. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  373. package/lib/simple-tree/fieldSchema.js +0 -3
  374. package/lib/simple-tree/fieldSchema.js.map +1 -1
  375. package/lib/simple-tree/index.d.ts +1 -1
  376. package/lib/simple-tree/index.d.ts.map +1 -1
  377. package/lib/simple-tree/index.js +1 -1
  378. package/lib/simple-tree/index.js.map +1 -1
  379. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  380. package/lib/simple-tree/node-kinds/record/recordNode.js +2 -3
  381. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  382. package/lib/simple-tree/simpleSchema.d.ts +12 -0
  383. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  384. package/lib/simple-tree/simpleSchema.js.map +1 -1
  385. package/lib/simple-tree/toStoredSchema.d.ts +0 -3
  386. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  387. package/lib/simple-tree/toStoredSchema.js +0 -3
  388. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  389. package/lib/tableSchema.d.ts +11 -80
  390. package/lib/tableSchema.d.ts.map +1 -1
  391. package/lib/tableSchema.js +201 -118
  392. package/lib/tableSchema.js.map +1 -1
  393. package/lib/treeFactory.d.ts +1 -2
  394. package/lib/treeFactory.d.ts.map +1 -1
  395. package/lib/treeFactory.js +1 -2
  396. package/lib/treeFactory.js.map +1 -1
  397. package/lib/tsdoc-metadata.json +1 -1
  398. package/lib/util/breakable.d.ts.map +1 -1
  399. package/lib/util/breakable.js +7 -1
  400. package/lib/util/breakable.js.map +1 -1
  401. package/package.json +28 -28
  402. package/src/codec/codec.ts +52 -7
  403. package/src/codec/index.ts +4 -0
  404. package/src/external-utilities/index.ts +1 -1
  405. package/src/external-utilities/typeboxValidator.ts +7 -1
  406. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +38 -4
  407. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -3
  408. package/src/feature-libraries/chunked-forest/codec/codecs.ts +96 -8
  409. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +123 -19
  410. package/src/feature-libraries/chunked-forest/codec/format.ts +11 -0
  411. package/src/feature-libraries/chunked-forest/codec/index.ts +4 -0
  412. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +28 -3
  413. package/src/feature-libraries/chunked-forest/index.ts +2 -0
  414. package/src/feature-libraries/forest-summary/codec.ts +3 -0
  415. package/src/feature-libraries/forest-summary/forestSummarizer.ts +118 -50
  416. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +511 -0
  417. package/src/feature-libraries/forest-summary/index.ts +1 -1
  418. package/src/feature-libraries/index.ts +5 -1
  419. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +8 -4
  420. package/src/feature-libraries/treeCompressionUtils.ts +19 -0
  421. package/src/index.ts +6 -1
  422. package/src/packageVersion.ts +1 -1
  423. package/src/shared-tree/schematizingTreeView.ts +1 -1
  424. package/src/shared-tree/sharedTree.ts +37 -4
  425. package/src/shared-tree/sharedTreeChangeFamily.ts +2 -2
  426. package/src/shared-tree/tree.ts +3 -0
  427. package/src/shared-tree/treeAlpha.ts +10 -11
  428. package/src/shared-tree/treeCheckout.ts +3 -2
  429. package/src/shared-tree-core/sharedTreeCore.ts +17 -0
  430. package/src/sharedTreeAttributes.ts +2 -2
  431. package/src/simple-tree/api/conciseTree.ts +2 -1
  432. package/src/simple-tree/api/customTree.ts +102 -32
  433. package/src/simple-tree/api/getJsonSchema.ts +7 -2
  434. package/src/simple-tree/api/index.ts +3 -0
  435. package/src/simple-tree/api/schemaCreationUtilities.ts +1 -1
  436. package/src/simple-tree/api/schemaFactory.ts +21 -14
  437. package/src/simple-tree/api/schemaFactoryAlpha.ts +29 -30
  438. package/src/simple-tree/api/schemaFactoryBeta.ts +28 -0
  439. package/src/simple-tree/api/schemaFactoryRecursive.ts +41 -40
  440. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +7 -3
  441. package/src/simple-tree/api/transactionTypes.ts +1 -0
  442. package/src/simple-tree/api/tree.ts +75 -81
  443. package/src/simple-tree/api/verboseTree.ts +42 -39
  444. package/src/simple-tree/core/simpleNodeSchemaBase.ts +6 -0
  445. package/src/simple-tree/fieldSchema.ts +3 -4
  446. package/src/simple-tree/index.ts +3 -0
  447. package/src/simple-tree/node-kinds/record/recordNode.ts +2 -3
  448. package/src/simple-tree/simpleSchema.ts +12 -0
  449. package/src/simple-tree/toStoredSchema.ts +0 -3
  450. package/src/tableSchema.ts +261 -243
  451. package/src/treeFactory.ts +1 -2
  452. package/src/util/breakable.ts +9 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,KAAK,QAAQ,EACb,gBAAgB,EAChB,UAAU,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,mBAAmB,EACnB,KAAK,yBAAyB,EAC9B,yCAAyC,GACzC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,KAAK,QAAQ,EACb,gBAAgB,EAChB,UAAU,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,mBAAmB,EACnB,KAAK,yBAAyB,EAC9B,yCAAyC,EACzC,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAA6D;AAApD,+GAAA,YAAY,OAAA;AAAE,6GAAA,UAAU,OAAA;AACjC,gDAAgE;AAAvC,qGAAA,SAAS,OAAA;AAClC,+CAOwB;AANvB,yGAAA,SAAS,OAAA;AACT,kHAAA,kBAAkB,OAAA;AAClB,+GAAA,eAAe,OAAA;AAEf,gHAAA,gBAAgB,OAAA;AAChB,0GAAA,UAAU,OAAA;AAEX,uDAAwD;AAA/C,sHAAA,kBAAkB,OAAA;AAC3B,6CAO0B;AANzB,6GAAA,iBAAiB,OAAA;AAGjB,+GAAA,mBAAmB,OAAA;AAEnB,qIAAA,yCAAyC,OAAA;AAE1C,iDAA6C;AAApC,2GAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { uniformChunk, ChunkShape } from \"./uniformChunk.js\";\nexport { type TreeChunk, dummyRoot } from \"../../core/index.js\";\nexport {\n\tchunkTree,\n\tdefaultChunkPolicy,\n\tmakeTreeChunker,\n\ttype IChunker,\n\tchunkFieldSingle,\n\tchunkField,\n} from \"./chunkTree.js\";\nexport { buildChunkedForest } from \"./chunkedForest.js\";\nexport {\n\tEncodedFieldBatch,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeFieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n\tfluidVersionToFieldBatchCodecWriteVersion,\n} from \"./codec/index.js\";\nexport { emptyChunk } from \"./emptyChunk.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAA6D;AAApD,+GAAA,YAAY,OAAA;AAAE,6GAAA,UAAU,OAAA;AACjC,gDAAgE;AAAvC,qGAAA,SAAS,OAAA;AAClC,+CAOwB;AANvB,yGAAA,SAAS,OAAA;AACT,kHAAA,kBAAkB,OAAA;AAClB,+GAAA,eAAe,OAAA;AAEf,gHAAA,gBAAgB,OAAA;AAChB,0GAAA,UAAU,OAAA;AAEX,uDAAwD;AAA/C,sHAAA,kBAAkB,OAAA;AAC3B,6CAS0B;AARzB,6GAAA,iBAAiB,OAAA;AAGjB,+GAAA,mBAAmB,OAAA;AAEnB,qIAAA,yCAAyC,OAAA;AAI1C,iDAA6C;AAApC,2GAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { uniformChunk, ChunkShape } from \"./uniformChunk.js\";\nexport { type TreeChunk, dummyRoot } from \"../../core/index.js\";\nexport {\n\tchunkTree,\n\tdefaultChunkPolicy,\n\tmakeTreeChunker,\n\ttype IChunker,\n\tchunkFieldSingle,\n\tchunkField,\n} from \"./chunkTree.js\";\nexport { buildChunkedForest } from \"./chunkedForest.js\";\nexport {\n\tEncodedFieldBatch,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeFieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n\tfluidVersionToFieldBatchCodecWriteVersion,\n\ttype IncrementalEncoderDecoder,\n\ttype ChunkReferenceId,\n} from \"./codec/index.js\";\nexport { emptyChunk } from \"./emptyChunk.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/codec.ts"],"names":[],"mappings":"AAAA;;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index_js_1 = require("../../codec/index.js");
10
10
  const format_js_1 = require("./format.js");
11
11
  function makeForestSummarizerCodec(options, fieldBatchCodec) {
12
12
  const inner = fieldBatchCodec;
13
+ // TODO: AB#41865
14
+ // This needs to be updated to support multiple versions.
15
+ // The second version will be used to enable incremental summarization.
13
16
  return (0, index_js_1.makeVersionedValidatedCodec)(options, new Set([1]), format_js_1.Format, {
14
17
  encode: (data, context) => {
15
18
  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,mDAI8B;AAI9B,2CAAqC;AAQrC,SAAgB,yBAAyB,CACxC,OAAsB,EACtB,eAAgC;IAEhC,MAAM,KAAK,GAAG,eAAe,CAAC;IAC9B,OAAO,IAAA,sCAA2B,EAAC,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,kBAAM,EAAE;QACjE,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,CAAC,EAAE,CAAC;QACpE,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;AAzBD,8DAyBC","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\";\n\nimport {\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../codec/index.js\";\nimport type { FieldKey, ITreeCursorSynchronous } from \"../../core/index.js\";\nimport type { FieldBatchCodec, FieldBatchEncodingContext } from \"../chunked-forest/index.js\";\n\nimport { Format } from \"./format.js\";\n\n/**\n * Uses field cursors\n */\nexport type FieldSet = ReadonlyMap<FieldKey, ITreeCursorSynchronous>;\nexport type ForestCodec = IJsonCodec<FieldSet, Format, Format, FieldBatchEncodingContext>;\n\nexport function makeForestSummarizerCodec(\n\toptions: ICodecOptions,\n\tfieldBatchCodec: FieldBatchCodec,\n): ForestCodec {\n\tconst inner = fieldBatchCodec;\n\treturn makeVersionedValidatedCodec(options, new Set([1]), Format, {\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: 1 };\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"]}
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,mDAI8B;AAI9B,2CAAqC;AAQrC,SAAgB,yBAAyB,CACxC,OAAsB,EACtB,eAAgC;IAEhC,MAAM,KAAK,GAAG,eAAe,CAAC;IAC9B,iBAAiB;IACjB,yDAAyD;IACzD,uEAAuE;IACvE,OAAO,IAAA,sCAA2B,EAAC,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,kBAAM,EAAE;QACjE,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,CAAC,EAAE,CAAC;QACpE,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;AA5BD,8DA4BC","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\";\n\nimport {\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../codec/index.js\";\nimport type { FieldKey, ITreeCursorSynchronous } from \"../../core/index.js\";\nimport type { FieldBatchCodec, FieldBatchEncodingContext } from \"../chunked-forest/index.js\";\n\nimport { Format } from \"./format.js\";\n\n/**\n * Uses field cursors\n */\nexport type FieldSet = ReadonlyMap<FieldKey, ITreeCursorSynchronous>;\nexport type ForestCodec = IJsonCodec<FieldSet, Format, Format, FieldBatchEncodingContext>;\n\nexport function makeForestSummarizerCodec(\n\toptions: ICodecOptions,\n\tfieldBatchCodec: FieldBatchCodec,\n): ForestCodec {\n\tconst inner = fieldBatchCodec;\n\t// TODO: AB#41865\n\t// This needs to be updated to support multiple versions.\n\t// The second version will be used to enable incremental summarization.\n\treturn makeVersionedValidatedCodec(options, new Set([1]), Format, {\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: 1 };\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"]}
@@ -6,13 +6,15 @@ import type { IChannelStorageService } from "@fluidframework/datastore-definitio
6
6
  import type { IIdCompressor } from "@fluidframework/id-compressor";
7
7
  import type { IExperimentalIncrementalSummaryContext, ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions/internal";
8
8
  import type { CodecWriteOptions } from "../../codec/index.js";
9
- import { type IEditableForest, type RevisionTagCodec } from "../../core/index.js";
9
+ import { type FieldKey, type IEditableForest, type RevisionTagCodec, type TreeNodeSchemaIdentifier } from "../../core/index.js";
10
10
  import type { Summarizable, SummaryElementParser, SummaryElementStringifier } from "../../shared-tree-core/index.js";
11
11
  import type { FieldBatchCodec, FieldBatchEncodingContext } from "../chunked-forest/index.js";
12
12
  /**
13
- * The storage key for the blob in the summary containing tree data
13
+ * The key for the tree that contains the overall forest's summary tree.
14
+ * This tree is added by the parent of the forest summarizer.
15
+ * See {@link ForestIncrementalSummaryBuilder} for details on the summary structure.
14
16
  */
15
- export declare const treeBlobKey = "ForestTree";
17
+ export declare const forestSummaryKey = "Forest";
16
18
  /**
17
19
  * Provides methods for summarizing and loading a forest.
18
20
  */
@@ -23,18 +25,21 @@ export declare class ForestSummarizer implements Summarizable {
23
25
  private readonly idCompressor;
24
26
  readonly key = "Forest";
25
27
  private readonly codec;
28
+ private readonly incrementalSummaryBuilder;
26
29
  /**
27
30
  * @param encoderContext - The schema if provided here must be mutated by the caller to keep it up to date.
28
31
  */
29
- constructor(forest: IEditableForest, revisionTagCodec: RevisionTagCodec, fieldBatchCodec: FieldBatchCodec, encoderContext: FieldBatchEncodingContext, options: CodecWriteOptions, idCompressor: IIdCompressor);
32
+ constructor(forest: IEditableForest, revisionTagCodec: RevisionTagCodec, fieldBatchCodec: FieldBatchCodec, encoderContext: FieldBatchEncodingContext, options: CodecWriteOptions, idCompressor: IIdCompressor, shouldEncodeFieldIncrementally?: (nodeIdentifier: TreeNodeSchemaIdentifier, fieldKey: FieldKey) => boolean);
30
33
  /**
31
- * Synchronous monolithic summarization of tree content.
34
+ * Summarization of the forest's tree content.
35
+ * @returns a summary tree containing the forest's tree content.
36
+ * @remarks
37
+ * If incremental summary is disabled, all the content will be added to a single summary blob.
38
+ * If incremental summary is enabled, the summary will be a tree.
39
+ * See {@link ForestIncrementalSummaryBuilder} for details of what this tree looks like.
32
40
  *
33
41
  * TODO: when perf matters, this should be replaced with a chunked async version using a binary format.
34
- *
35
- * @returns a snapshot of the forest's tree as a string.
36
42
  */
37
- private getTreeString;
38
43
  summarize(props: {
39
44
  stringify: SummaryElementStringifier;
40
45
  fullTree?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"forestSummarizer.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/forestSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EACX,sCAAsC,EACtC,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CA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SAAS,EAAE,yBAAyB,CAAC;QACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,CAAC,EAAE,sCAAsC,CAAC;KACnE,GAAG,qBAAqB;IAyCZ,IAAI,CAChB,QAAQ,EAAE,sBAAsB,EAChC,KAAK,EAAE,oBAAoB,GACzB,OAAO,CAAC,IAAI,CAAC;CAsDhB"}
@@ -4,18 +4,22 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ForestSummarizer = exports.treeBlobKey = void 0;
7
+ exports.ForestSummarizer = exports.forestSummaryKey = void 0;
8
8
  const client_utils_1 = require("@fluid-internal/client-utils");
9
9
  const internal_1 = require("@fluidframework/core-utils/internal");
10
- const internal_2 = require("@fluidframework/shared-object-base/internal");
11
10
  const index_js_1 = require("../../core/index.js");
12
11
  const index_js_2 = require("../../util/index.js");
13
- const index_js_3 = require("../chunked-forest/index.js");
12
+ // eslint-disable-next-line import/no-internal-modules
13
+ const chunkTree_js_1 = require("../chunked-forest/chunkTree.js");
14
14
  const codec_js_1 = require("./codec.js");
15
+ const incrementalSummaryBuilder_js_1 = require("./incrementalSummaryBuilder.js");
16
+ const treeCompressionUtils_js_1 = require("../treeCompressionUtils.js");
15
17
  /**
16
- * The storage key for the blob in the summary containing tree data
18
+ * The key for the tree that contains the overall forest's summary tree.
19
+ * This tree is added by the parent of the forest summarizer.
20
+ * See {@link ForestIncrementalSummaryBuilder} for details on the summary structure.
17
21
  */
18
- exports.treeBlobKey = "ForestTree";
22
+ exports.forestSummaryKey = "Forest";
19
23
  /**
20
24
  * Provides methods for summarizing and loading a forest.
21
25
  */
@@ -23,23 +27,30 @@ class ForestSummarizer {
23
27
  /**
24
28
  * @param encoderContext - The schema if provided here must be mutated by the caller to keep it up to date.
25
29
  */
26
- constructor(forest, revisionTagCodec, fieldBatchCodec, encoderContext, options, idCompressor) {
30
+ constructor(forest, revisionTagCodec, fieldBatchCodec, encoderContext, options, idCompressor, shouldEncodeFieldIncrementally) {
27
31
  this.forest = forest;
28
32
  this.revisionTagCodec = revisionTagCodec;
29
33
  this.encoderContext = encoderContext;
30
34
  this.idCompressor = idCompressor;
31
- this.key = "Forest";
35
+ this.key = exports.forestSummaryKey;
32
36
  // TODO: this should take in CodecWriteOptions, and use it to pick the write version.
33
37
  this.codec = (0, codec_js_1.makeForestSummarizerCodec)(options, fieldBatchCodec);
38
+ const shouldEncodeFieldIncrementallyLocal = (nodeIdentifier, fieldKey) => shouldEncodeFieldIncrementally?.(nodeIdentifier, fieldKey) ?? false;
39
+ this.incrementalSummaryBuilder = new incrementalSummaryBuilder_js_1.ForestIncrementalSummaryBuilder(encoderContext.encodeType ===
40
+ treeCompressionUtils_js_1.TreeCompressionStrategyExtended.CompressedIncremental /* enableIncrementalSummary */, (cursor) => this.forest.chunkField(cursor), shouldEncodeFieldIncrementallyLocal);
34
41
  }
35
42
  /**
36
- * Synchronous monolithic summarization of tree content.
43
+ * Summarization of the forest's tree content.
44
+ * @returns a summary tree containing the forest's tree content.
45
+ * @remarks
46
+ * If incremental summary is disabled, all the content will be added to a single summary blob.
47
+ * If incremental summary is enabled, the summary will be a tree.
48
+ * See {@link ForestIncrementalSummaryBuilder} for details of what this tree looks like.
37
49
  *
38
50
  * TODO: when perf matters, this should be replaced with a chunked async version using a binary format.
39
- *
40
- * @returns a snapshot of the forest's tree as a string.
41
51
  */
42
- getTreeString(stringify) {
52
+ summarize(props) {
53
+ const { stringify, fullTree = false, incrementalSummaryContext } = props;
43
54
  const rootCursor = this.forest.getCursorAboveDetachedFields();
44
55
  const fieldMap = new Map();
45
56
  // TODO: Encode all detached fields in one operation for better performance and compression
@@ -50,38 +61,65 @@ class ForestSummarizer {
50
61
  1 /* TreeNavigationResult.Ok */, 0x892 /* failed to navigate to field */);
51
62
  fieldMap.set(key, innerCursor);
52
63
  });
53
- const encoded = this.codec.encode(fieldMap, this.encoderContext);
64
+ // Let the incremental summary builder know that we are starting a new summary.
65
+ // It returns whether incremental encoding is enabled.
66
+ const incrementalSummaryBehavior = this.incrementalSummaryBuilder.startSummary({
67
+ fullTree,
68
+ incrementalSummaryContext,
69
+ stringify,
70
+ });
71
+ const encoderContext = {
72
+ ...this.encoderContext,
73
+ incrementalEncoderDecoder: incrementalSummaryBehavior === incrementalSummaryBuilder_js_1.ForestIncrementalSummaryBehavior.Incremental
74
+ ? this.incrementalSummaryBuilder
75
+ : undefined,
76
+ };
77
+ const encoded = this.codec.encode(fieldMap, encoderContext);
54
78
  fieldMap.forEach((value) => value.free());
55
- return stringify(encoded);
56
- }
57
- summarize(props) {
58
- return (0, internal_2.createSingleBlobSummary)(exports.treeBlobKey, this.getTreeString(props.stringify));
79
+ return this.incrementalSummaryBuilder.completeSummary({
80
+ incrementalSummaryContext,
81
+ forestSummaryContent: stringify(encoded),
82
+ });
59
83
  }
60
84
  async load(services, parse) {
61
- if (await services.contains(exports.treeBlobKey)) {
62
- const treeBuffer = await services.readBlob(exports.treeBlobKey);
85
+ // The contents of the top-level forest must be present under a summary blob named `forestSummaryContentKey`.
86
+ // If the summary was generated as `ForestIncrementalSummaryBehavior.SingleBlob`, this blob will contain all
87
+ // of forest's contents.
88
+ // If the summary was generated as `ForestIncrementalSummaryBehavior.Incremental`, this blob will contain only
89
+ // the top-level forest node's contents.
90
+ // The contents of the incremental chunks will be in separate tree nodes and will be read later during decoding.
91
+ (0, internal_1.assert)(await services.contains(incrementalSummaryBuilder_js_1.forestSummaryContentKey), 0xc21 /* Forest summary content missing in snapshot */);
92
+ const readAndParseBlob = async (id) => {
93
+ const treeBuffer = await services.readBlob(id);
63
94
  const treeBufferString = (0, client_utils_1.bufferToString)(treeBuffer, "utf8");
64
- // TODO: this code is parsing data without an optional validator, this should be defined in a typebox schema as part of the
65
- // forest summary format.
66
- const fields = this.codec.decode(parse(treeBufferString), this.encoderContext);
67
- const allocator = (0, index_js_2.idAllocatorFromMaxId)();
68
- const fieldChanges = [];
69
- const build = [];
70
- for (const [fieldKey, field] of fields) {
71
- const chunked = (0, index_js_3.chunkFieldSingle)(field, {
72
- policy: index_js_3.defaultChunkPolicy,
73
- idCompressor: this.idCompressor,
74
- });
75
- const buildId = { minor: allocator.allocate(chunked.topLevelLength) };
76
- build.push({
77
- id: buildId,
78
- trees: chunked,
79
- });
80
- fieldChanges.push([fieldKey, [{ count: chunked.topLevelLength, attach: buildId }]]);
81
- }
82
- (0, internal_1.assert)(this.forest.isEmpty, 0x797 /* forest must be empty */);
83
- (0, index_js_1.applyDelta)({ build, fields: new Map(fieldChanges) }, undefined, this.forest, (0, index_js_1.makeDetachedFieldIndex)("init", this.revisionTagCodec, this.idCompressor));
95
+ return parse(treeBufferString);
96
+ };
97
+ // Load the incremental summary builder so that it can download any incremental chunks in the
98
+ // snapshot.
99
+ await this.incrementalSummaryBuilder.load(services, readAndParseBlob);
100
+ // TODO: this code is parsing data without an optional validator, this should be defined in a typebox schema as part of the
101
+ // forest summary format.
102
+ const fields = this.codec.decode(await readAndParseBlob(incrementalSummaryBuilder_js_1.forestSummaryContentKey), {
103
+ ...this.encoderContext,
104
+ incrementalEncoderDecoder: this.incrementalSummaryBuilder,
105
+ });
106
+ const allocator = (0, index_js_2.idAllocatorFromMaxId)();
107
+ const fieldChanges = [];
108
+ const build = [];
109
+ for (const [fieldKey, field] of fields) {
110
+ const chunked = (0, chunkTree_js_1.chunkFieldSingle)(field, {
111
+ policy: chunkTree_js_1.defaultChunkPolicy,
112
+ idCompressor: this.idCompressor,
113
+ });
114
+ const buildId = { minor: allocator.allocate(chunked.topLevelLength) };
115
+ build.push({
116
+ id: buildId,
117
+ trees: chunked,
118
+ });
119
+ fieldChanges.push([fieldKey, [{ count: chunked.topLevelLength, attach: buildId }]]);
84
120
  }
121
+ (0, internal_1.assert)(this.forest.isEmpty, 0x797 /* forest must be empty */);
122
+ (0, index_js_1.applyDelta)({ build, fields: new Map(fieldChanges) }, undefined, this.forest, (0, index_js_1.makeDetachedFieldIndex)("init", this.revisionTagCodec, this.idCompressor));
85
123
  }
86
124
  }
87
125
  exports.ForestSummarizer = ForestSummarizer;
@@ -1 +1 @@
1
- {"version":3,"file":"forestSummarizer.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/forestSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,kEAA6D;AAQ7D,0EAAsF;AAGtF,kDAY6B;AAM7B,kDAA2D;AAC3D,yDAAkF;AAGlF,yCAAyE;AAEzE;;GAEG;AACU,QAAA,WAAW,GAAG,YAAY,CAAC;AAExC;;GAEG;AACH,MAAa,gBAAgB;IAK5B;;OAEG;IACH,YACkB,MAAuB,EACvB,gBAAkC,EACnD,eAAgC,EACf,cAAyC,EAC1D,OAA0B,EACT,YAA2B;QAL3B,WAAM,GAAN,MAAM,CAAiB;QACvB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAElC,mBAAc,GAAd,cAAc,CAA2B;QAEzC,iBAAY,GAAZ,YAAY,CAAe;QAb7B,QAAG,GAAG,QAAQ,CAAC;QAe9B,qFAAqF;QACrF,IAAI,CAAC,KAAK,GAAG,IAAA,oCAAyB,EAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACK,aAAa,CAAC,SAAoC;QACzD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,4BAA4B,EAAE,CAAC;QAC9D,MAAM,QAAQ,GACb,IAAI,GAAG,EAAE,CAAC;QACX,2FAA2F;QAC3F,IAAA,uBAAY,EAAC,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE;YACnC,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;YACjC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;YAChE,IAAA,iBAAM,EACL,IAAI,CAAC,MAA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IAAI,MAAM,EAAE,CAAC;gBACxC,MAAM,OAAO,GAAG,IAAA,2BAAgB,EAAC,KAAK,EAAE;oBACvC,MAAM,EAAE,6BAAkB;oBAC1B,YAAY,EAAE,IAAI,CAAC,YAAY;iBAC/B,CAAC,CAAC;gBACH,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;gBACtE,KAAK,CAAC,IAAI,CAAC;oBACV,EAAE,EAAE,OAAO;oBACX,KAAK,EAAE,OAAO;iBACd,CAAC,CAAC;gBACH,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;YACrF,CAAC;YAED,IAAA,iBAAM,EAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAC9D,IAAA,qBAAU,EACT,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAG,CAAC,YAAY,CAAC,EAAE,EACxC,SAAS,EACT,IAAI,CAAC,MAAM,EACX,IAAA,iCAAsB,EAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,YAAY,CAAC,CACxE,CAAC;QACH,CAAC;IACF,CAAC;CACD;AA7FD,4CA6FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { createSingleBlobSummary } from \"@fluidframework/shared-object-base/internal\";\n\nimport type { CodecWriteOptions } from \"../../codec/index.js\";\nimport {\n\ttype DeltaDetachedNodeBuild,\n\ttype DeltaFieldChanges,\n\ttype FieldKey,\n\ttype IEditableForest,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype RevisionTagCodec,\n\tTreeNavigationResult,\n\tapplyDelta,\n\tforEachField,\n\tmakeDetachedFieldIndex,\n} from \"../../core/index.js\";\nimport type {\n\tSummarizable,\n\tSummaryElementParser,\n\tSummaryElementStringifier,\n} from \"../../shared-tree-core/index.js\";\nimport { idAllocatorFromMaxId } from \"../../util/index.js\";\nimport { chunkFieldSingle, defaultChunkPolicy } from \"../chunked-forest/index.js\";\nimport type { FieldBatchCodec, FieldBatchEncodingContext } from \"../chunked-forest/index.js\";\n\nimport { type ForestCodec, makeForestSummarizerCodec } from \"./codec.js\";\nimport type { Format } from \"./format.js\";\n/**\n * The storage key for the blob in the summary containing tree data\n */\nexport const treeBlobKey = \"ForestTree\";\n\n/**\n * Provides methods for summarizing and loading a forest.\n */\nexport class ForestSummarizer implements Summarizable {\n\tpublic readonly key = \"Forest\";\n\n\tprivate readonly codec: ForestCodec;\n\n\t/**\n\t * @param encoderContext - The schema if provided here must be mutated by the caller to keep it up to date.\n\t */\n\tpublic constructor(\n\t\tprivate readonly forest: IEditableForest,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tfieldBatchCodec: FieldBatchCodec,\n\t\tprivate readonly encoderContext: FieldBatchEncodingContext,\n\t\toptions: CodecWriteOptions,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t) {\n\t\t// TODO: this should take in CodecWriteOptions, and use it to pick the write version.\n\t\tthis.codec = makeForestSummarizerCodec(options, fieldBatchCodec);\n\t}\n\n\t/**\n\t * Synchronous monolithic summarization of tree content.\n\t *\n\t * TODO: when perf matters, this should be replaced with a chunked async version using a binary format.\n\t *\n\t * @returns a snapshot of the forest's tree as a string.\n\t */\n\tprivate getTreeString(stringify: SummaryElementStringifier): string {\n\t\tconst rootCursor = this.forest.getCursorAboveDetachedFields();\n\t\tconst fieldMap: Map<FieldKey, ITreeCursorSynchronous & ITreeSubscriptionCursor> =\n\t\t\tnew Map();\n\t\t// TODO: Encode all detached fields in one operation for better performance and compression\n\t\tforEachField(rootCursor, (cursor) => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tconst innerCursor = this.forest.allocateCursor(\"getTreeString\");\n\t\t\tassert(\n\t\t\t\tthis.forest.tryMoveCursorToField({ fieldKey: key, parent: undefined }, innerCursor) ===\n\t\t\t\t\tTreeNavigationResult.Ok,\n\t\t\t\t0x892 /* failed to navigate to field */,\n\t\t\t);\n\t\t\tfieldMap.set(key, innerCursor as ITreeCursorSynchronous & ITreeSubscriptionCursor);\n\t\t});\n\t\tconst encoded = this.codec.encode(fieldMap, this.encoderContext);\n\n\t\tfieldMap.forEach((value) => value.free());\n\t\treturn stringify(encoded);\n\t}\n\n\tpublic summarize(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t}): ISummaryTreeWithStats {\n\t\treturn createSingleBlobSummary(treeBlobKey, this.getTreeString(props.stringify));\n\t}\n\n\tpublic async load(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\tif (await services.contains(treeBlobKey)) {\n\t\t\tconst treeBuffer = await services.readBlob(treeBlobKey);\n\t\t\tconst treeBufferString = bufferToString(treeBuffer, \"utf8\");\n\t\t\t// TODO: this code is parsing data without an optional validator, this should be defined in a typebox schema as part of the\n\t\t\t// forest summary format.\n\t\t\tconst fields = this.codec.decode(parse(treeBufferString) as Format, this.encoderContext);\n\t\t\tconst allocator = idAllocatorFromMaxId();\n\t\t\tconst fieldChanges: [FieldKey, DeltaFieldChanges][] = [];\n\t\t\tconst build: DeltaDetachedNodeBuild[] = [];\n\t\t\tfor (const [fieldKey, field] of fields) {\n\t\t\t\tconst chunked = chunkFieldSingle(field, {\n\t\t\t\t\tpolicy: defaultChunkPolicy,\n\t\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t\t});\n\t\t\t\tconst buildId = { minor: allocator.allocate(chunked.topLevelLength) };\n\t\t\t\tbuild.push({\n\t\t\t\t\tid: buildId,\n\t\t\t\t\ttrees: chunked,\n\t\t\t\t});\n\t\t\t\tfieldChanges.push([fieldKey, [{ count: chunked.topLevelLength, attach: buildId }]]);\n\t\t\t}\n\n\t\t\tassert(this.forest.isEmpty, 0x797 /* forest must be empty */);\n\t\t\tapplyDelta(\n\t\t\t\t{ build, fields: new Map(fieldChanges) },\n\t\t\t\tundefined,\n\t\t\t\tthis.forest,\n\t\t\t\tmakeDetachedFieldIndex(\"init\", this.revisionTagCodec, this.idCompressor),\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"forestSummarizer.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/forestSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,kEAA6D;AAU7D,kDAa6B;AAM7B,kDAAgF;AAChF,sDAAsD;AACtD,iEAAsF;AAGtF,yCAAyE;AACzE,iFAIwC;AACxC,wEAA6E;AAG7E;;;;GAIG;AACU,QAAA,gBAAgB,GAAG,QAAQ,CAAC;AAEzC;;GAEG;AACH,MAAa,gBAAgB;IAO5B;;OAEG;IACH,YACkB,MAAuB,EACvB,gBAAkC,EACnD,eAAgC,EACf,cAAyC,EAC1D,OAA0B,EACT,YAA2B,EAC5C,8BAGY;QATK,WAAM,GAAN,MAAM,CAAiB;QACvB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAElC,mBAAc,GAAd,cAAc,CAA2B;QAEzC,iBAAY,GAAZ,YAAY,CAAe;QAf7B,QAAG,GAAG,wBAAgB,CAAC;QAqBtC,qFAAqF;QACrF,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,CACxE,CAAC;IACH,CAAC;CACD;AAvJD,4CAuJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport type { CodecWriteOptions } from \"../../codec/index.js\";\nimport {\n\ttype DeltaDetachedNodeBuild,\n\ttype DeltaFieldChanges,\n\ttype FieldKey,\n\ttype IEditableForest,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype RevisionTagCodec,\n\tTreeNavigationResult,\n\ttype TreeNodeSchemaIdentifier,\n\tapplyDelta,\n\tforEachField,\n\tmakeDetachedFieldIndex,\n} from \"../../core/index.js\";\nimport type {\n\tSummarizable,\n\tSummaryElementParser,\n\tSummaryElementStringifier,\n} from \"../../shared-tree-core/index.js\";\nimport { idAllocatorFromMaxId, type JsonCompatible } from \"../../util/index.js\";\n// eslint-disable-next-line import/no-internal-modules\nimport { chunkFieldSingle, defaultChunkPolicy } from \"../chunked-forest/chunkTree.js\";\nimport type { FieldBatchCodec, FieldBatchEncodingContext } from \"../chunked-forest/index.js\";\n\nimport { type ForestCodec, makeForestSummarizerCodec } from \"./codec.js\";\nimport {\n\tForestIncrementalSummaryBehavior,\n\tForestIncrementalSummaryBuilder,\n\tforestSummaryContentKey,\n} from \"./incrementalSummaryBuilder.js\";\nimport { TreeCompressionStrategyExtended } from \"../treeCompressionUtils.js\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\n/**\n * The key for the tree that contains the overall forest's summary tree.\n * This tree is added by the parent of the forest summarizer.\n * See {@link ForestIncrementalSummaryBuilder} for details on the summary structure.\n */\nexport const forestSummaryKey = \"Forest\";\n\n/**\n * Provides methods for summarizing and loading a forest.\n */\nexport class ForestSummarizer implements Summarizable {\n\tpublic readonly key = forestSummaryKey;\n\n\tprivate readonly codec: ForestCodec;\n\n\tprivate readonly incrementalSummaryBuilder: ForestIncrementalSummaryBuilder;\n\n\t/**\n\t * @param encoderContext - The schema if provided here must be mutated by the caller to keep it up to date.\n\t */\n\tpublic constructor(\n\t\tprivate readonly forest: IEditableForest,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tfieldBatchCodec: FieldBatchCodec,\n\t\tprivate readonly encoderContext: FieldBatchEncodingContext,\n\t\toptions: CodecWriteOptions,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tshouldEncodeFieldIncrementally?: (\n\t\t\tnodeIdentifier: TreeNodeSchemaIdentifier,\n\t\t\tfieldKey: FieldKey,\n\t\t) => boolean,\n\t) {\n\t\t// TODO: this should take in CodecWriteOptions, and use it to pick the write version.\n\t\tthis.codec = makeForestSummarizerCodec(options, fieldBatchCodec);\n\n\t\tconst shouldEncodeFieldIncrementallyLocal = (\n\t\t\tnodeIdentifier: TreeNodeSchemaIdentifier,\n\t\t\tfieldKey: FieldKey,\n\t\t): boolean => shouldEncodeFieldIncrementally?.(nodeIdentifier, fieldKey) ?? false;\n\t\tthis.incrementalSummaryBuilder = new ForestIncrementalSummaryBuilder(\n\t\t\tencoderContext.encodeType ===\n\t\t\t\tTreeCompressionStrategyExtended.CompressedIncremental /* enableIncrementalSummary */,\n\t\t\t(cursor: ITreeCursorSynchronous) => this.forest.chunkField(cursor),\n\t\t\tshouldEncodeFieldIncrementallyLocal,\n\t\t);\n\t}\n\n\t/**\n\t * Summarization of the forest's tree content.\n\t * @returns a summary tree containing the forest's tree content.\n\t * @remarks\n\t * If incremental summary is disabled, all the content will be added to a single summary blob.\n\t * If incremental summary is enabled, the summary will be a tree.\n\t * See {@link ForestIncrementalSummaryBuilder} for details of what this tree looks like.\n\t *\n\t * TODO: when perf matters, this should be replaced with a chunked async version using a binary format.\n\t */\n\tpublic summarize(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t}): ISummaryTreeWithStats {\n\t\tconst { stringify, fullTree = false, incrementalSummaryContext } = props;\n\n\t\tconst rootCursor = this.forest.getCursorAboveDetachedFields();\n\t\tconst fieldMap: Map<FieldKey, ITreeCursorSynchronous & ITreeSubscriptionCursor> =\n\t\t\tnew Map();\n\t\t// TODO: Encode all detached fields in one operation for better performance and compression\n\t\tforEachField(rootCursor, (cursor) => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tconst innerCursor = this.forest.allocateCursor(\"getTreeString\");\n\t\t\tassert(\n\t\t\t\tthis.forest.tryMoveCursorToField({ fieldKey: key, parent: undefined }, innerCursor) ===\n\t\t\t\t\tTreeNavigationResult.Ok,\n\t\t\t\t0x892 /* failed to navigate to field */,\n\t\t\t);\n\t\t\tfieldMap.set(key, innerCursor as ITreeCursorSynchronous & ITreeSubscriptionCursor);\n\t\t});\n\n\t\t// Let the incremental summary builder know that we are starting a new summary.\n\t\t// It returns whether incremental encoding is enabled.\n\t\tconst incrementalSummaryBehavior = this.incrementalSummaryBuilder.startSummary({\n\t\t\tfullTree,\n\t\t\tincrementalSummaryContext,\n\t\t\tstringify,\n\t\t});\n\t\tconst encoderContext: FieldBatchEncodingContext = {\n\t\t\t...this.encoderContext,\n\t\t\tincrementalEncoderDecoder:\n\t\t\t\tincrementalSummaryBehavior === ForestIncrementalSummaryBehavior.Incremental\n\t\t\t\t\t? this.incrementalSummaryBuilder\n\t\t\t\t\t: undefined,\n\t\t};\n\t\tconst encoded = this.codec.encode(fieldMap, encoderContext);\n\t\tfieldMap.forEach((value) => value.free());\n\n\t\treturn this.incrementalSummaryBuilder.completeSummary({\n\t\t\tincrementalSummaryContext,\n\t\t\tforestSummaryContent: stringify(encoded),\n\t\t});\n\t}\n\n\tpublic async load(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\t// The contents of the top-level forest must be present under a summary blob named `forestSummaryContentKey`.\n\t\t// If the summary was generated as `ForestIncrementalSummaryBehavior.SingleBlob`, this blob will contain all\n\t\t// of forest's contents.\n\t\t// If the summary was generated as `ForestIncrementalSummaryBehavior.Incremental`, this blob will contain only\n\t\t// the top-level forest node's contents.\n\t\t// The contents of the incremental chunks will be in separate tree nodes and will be read later during decoding.\n\t\tassert(\n\t\t\tawait services.contains(forestSummaryContentKey),\n\t\t\t0xc21 /* Forest summary content missing in snapshot */,\n\t\t);\n\n\t\tconst readAndParseBlob = async <T extends JsonCompatible<IFluidHandle>>(\n\t\t\tid: string,\n\t\t): Promise<T> => {\n\t\t\tconst treeBuffer = await services.readBlob(id);\n\t\t\tconst treeBufferString = bufferToString(treeBuffer, \"utf8\");\n\t\t\treturn parse(treeBufferString) as T;\n\t\t};\n\n\t\t// Load the incremental summary builder so that it can download any incremental chunks in the\n\t\t// snapshot.\n\t\tawait this.incrementalSummaryBuilder.load(services, readAndParseBlob);\n\n\t\t// TODO: this code is parsing data without an optional validator, this should be defined in a typebox schema as part of the\n\t\t// forest summary format.\n\t\tconst fields = this.codec.decode(await readAndParseBlob(forestSummaryContentKey), {\n\t\t\t...this.encoderContext,\n\t\t\tincrementalEncoderDecoder: this.incrementalSummaryBuilder,\n\t\t});\n\t\tconst allocator = idAllocatorFromMaxId();\n\t\tconst fieldChanges: [FieldKey, DeltaFieldChanges][] = [];\n\t\tconst build: DeltaDetachedNodeBuild[] = [];\n\t\tfor (const [fieldKey, field] of fields) {\n\t\t\tconst chunked = chunkFieldSingle(field, {\n\t\t\t\tpolicy: defaultChunkPolicy,\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t});\n\t\t\tconst buildId = { minor: allocator.allocate(chunked.topLevelLength) };\n\t\t\tbuild.push({\n\t\t\t\tid: buildId,\n\t\t\t\ttrees: chunked,\n\t\t\t});\n\t\t\tfieldChanges.push([fieldKey, [{ count: chunked.topLevelLength, attach: buildId }]]);\n\t\t}\n\n\t\tassert(this.forest.isEmpty, 0x797 /* forest must be empty */);\n\t\tapplyDelta(\n\t\t\t{ build, fields: new Map(fieldChanges) },\n\t\t\tundefined,\n\t\t\tthis.forest,\n\t\t\tmakeDetachedFieldIndex(\"init\", this.revisionTagCodec, this.idCompressor),\n\t\t);\n\t}\n}\n"]}
@@ -0,0 +1,178 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IExperimentalIncrementalSummaryContext, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
6
+ import { type JsonCompatible } from "../../util/index.js";
7
+ import type { ChunkReferenceId, EncodedFieldBatch, IncrementalEncoderDecoder, TreeChunk } from "../chunked-forest/index.js";
8
+ import type { FieldKey, ITreeCursorSynchronous, TreeNodeSchemaIdentifier } from "../../core/index.js";
9
+ import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
10
+ import type { IFluidHandle } from "@fluidframework/core-interfaces";
11
+ import type { SummaryElementStringifier } from "../../shared-tree-core/index.js";
12
+ /**
13
+ * The key for the blob under ForestSummarizer's root.
14
+ * This blob contains the ForestCodec's output.
15
+ * See {@link ForestIncrementalSummaryBuilder} for details on the summary structure.
16
+ */
17
+ export declare const forestSummaryContentKey = "ForestTree";
18
+ /**
19
+ * State that tells whether a summary is currently being tracked.
20
+ */
21
+ export declare const ForestSummaryTrackingState: {
22
+ /** A summary is currently being tracked. */
23
+ readonly Tracking: "Tracking";
24
+ /** A summary is ready to be tracked. */
25
+ readonly ReadyToTrack: "ReadyToTrack";
26
+ };
27
+ export type ForestSummaryTrackingState = (typeof ForestSummaryTrackingState)[keyof typeof ForestSummaryTrackingState];
28
+ /**
29
+ * The behavior of the forest's incremental summary - whether the summary should be a single blob or incremental.
30
+ */
31
+ export declare enum ForestIncrementalSummaryBehavior {
32
+ /**
33
+ * The forest can encode chunks incrementally, i.e., chunks that support incremental encoding will be encoded
34
+ * separately - they will be added to a separate tree.
35
+ * The incremental summary format is described in {@link ForestIncrementalSummaryBuilder}.
36
+ */
37
+ Incremental = 0,
38
+ /**
39
+ * The forest should encode all of it's data in a single summary blob.
40
+ * @remarks
41
+ * The format of the summary will be the same as the old format (pre-incremental summaries) and is fully
42
+ * backwards compatible with the old format. The summary will basically look like an incremental summary
43
+ * with no incremental fields - it will only contain the "ForestTree" blob in the summary format described
44
+ * in {@link ForestIncrementalSummaryBuilder}.
45
+ */
46
+ SingleBlob = 1
47
+ }
48
+ /**
49
+ * Tracks and builds the incremental summary tree for a forest where chunks that support incremental encoding are
50
+ * stored in a separate tree in the summary under its {@link ChunkReferenceId}.
51
+ * The summary tree for a chunk is self-sufficient and can be independently loaded and used to reconstruct the
52
+ * chunk's contents without any additional context from its parent.
53
+ *
54
+ * An example summary tree with incremental summary:
55
+ * Forest
56
+ * ├── ForestTree
57
+ * ├── 0
58
+ * | ├── contents
59
+ * | ├── 1
60
+ * | | ├── contents
61
+ * | | ├── 2
62
+ * | | | ├── contents
63
+ * | ├── 3 - ".../Forest/ForestTree/0/1/3"
64
+ * ├── 4
65
+ * | ├── contents
66
+ * | ├── ...
67
+ * ├── 5 - "/.../Forest/ForestTree/5"
68
+ * - Forest is a summary tree node added by the shared tree and contains the following:
69
+ * - The inline portion of the top-level forest content is stored in a summary blob called "ForestTree".
70
+ * It also contains the {@link ChunkReferenceId}s of the incremental chunks under it.
71
+ * - The summary for each incremental chunk under it is stored against its {@link ChunkReferenceId}.
72
+ * - For each chunk, the structure of the summary tree is the same as the Forest. It contains the following:
73
+ * - The inline portion of the chunk content is stored in a blob called "contents".
74
+ * It also contains the {@link ChunkReferenceId}s of the incremental chunks under it.
75
+ * - The summary for each incremental chunk under it is stored against its {@link ChunkReferenceId}.
76
+ * - Chunks that do not change between summaries are summarized as handles in the summary tree.
77
+ * @remarks
78
+ * It may seem inconsistent that although the structure for the top-level forest tree is similar to that of
79
+ * an incremental chunk, its content is stored in a summary blob called "ForestTree" while the content for
80
+ * the incremental chunks are stored in a summary blob called "contents".
81
+ * This is to keep this summary backwards compatible with old format (before incremental summaries were added)
82
+ * where the entire forest content was in a summary blob called "ForestTree". So, if incremental summaries were
83
+ * disabled, the forest content will be fully backwards compatible.
84
+ * Note that this limits reusing the root node in a location other than root and a non-root node in the root.
85
+ * We could phase this out by switching to write the top-level contents under "contents" if we want to support
86
+ * the above. However, there is no plan to do that for now.
87
+ *
88
+ * TODO: AB#46752
89
+ * Add strong types for the summary structure to document it better. It will help make it super clear what the actual
90
+ * format is in a way that can easily be linked to, documented and inspected.
91
+ */
92
+ export declare class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecoder {
93
+ private readonly enableIncrementalSummary;
94
+ private readonly getChunkAtCursor;
95
+ /**
96
+ * {@link IncrementalEncoder.shouldEncodeFieldIncrementally}
97
+ */
98
+ readonly shouldEncodeFieldIncrementally: (nodeIdentifier: TreeNodeSchemaIdentifier, fieldKey: FieldKey) => boolean;
99
+ /**
100
+ * The next reference ID to use for a chunk.
101
+ */
102
+ private nextReferenceId;
103
+ /**
104
+ * For a given summary sequence number, keeps track of a chunk's properties that will be used to generate
105
+ * a summary handle for the chunk if it does not change between summaries.
106
+ */
107
+ private readonly chunkTrackingPropertiesMap;
108
+ /**
109
+ * The state indicating whether a summary is currently being tracked or not.
110
+ */
111
+ forestSummaryState: ForestSummaryTrackingState;
112
+ /**
113
+ * The sequence number of the latest summary that was successful.
114
+ */
115
+ private latestSummarySequenceNumber;
116
+ /**
117
+ * The current state of the summary being tracked.
118
+ * This is undefined if no summary is currently being tracked.
119
+ */
120
+ private trackedSummaryProperties;
121
+ /**
122
+ * A map of chunk reference IDs to their encoded contents. This is typically used during the loading of the
123
+ * forest to retrieve the contents of the chunks that were summarized incrementally.
124
+ */
125
+ private readonly encodedChunkContentsMap;
126
+ constructor(enableIncrementalSummary: boolean, getChunkAtCursor: (cursor: ITreeCursorSynchronous) => TreeChunk,
127
+ /**
128
+ * {@link IncrementalEncoder.shouldEncodeFieldIncrementally}
129
+ */
130
+ shouldEncodeFieldIncrementally: (nodeIdentifier: TreeNodeSchemaIdentifier, fieldKey: FieldKey) => boolean);
131
+ /**
132
+ * Must be called when the forest is loaded to download the encoded contents of incremental chunks.
133
+ * @param services - The channel storage service to use to access the snapshot tree and download the
134
+ * contents of the chunks.
135
+ * @param readAndParse - A function that reads and parses a blob from the storage service.
136
+ */
137
+ load(services: IChannelStorageService, readAndParseChunk: <T extends JsonCompatible<IFluidHandle>>(id: string) => Promise<T>): Promise<void>;
138
+ /**
139
+ * Must be called when starting a new forest summary to track it.
140
+ * @param fullTree - Whether the summary is a full tree summary. If true, the summary will not contain
141
+ * any summary handles. All chunks must be summarized in full.
142
+ * @param incrementalSummaryContext - The context for the incremental summary that contains the sequence numbers
143
+ * for the current and latest summaries.
144
+ * @param stringify - Serializes content (including {@link (IFluidHandle:interface)}s) for adding to a summary blob.
145
+ * @returns the behavior of the forest's incremental summary.
146
+ */
147
+ startSummary(args: {
148
+ fullTree: boolean;
149
+ incrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;
150
+ stringify: SummaryElementStringifier;
151
+ }): ForestIncrementalSummaryBehavior;
152
+ /**
153
+ * {@link IncrementalEncoder.encodeIncrementalField}
154
+ * @remarks Returns an empty array if the field has no content.
155
+ */
156
+ encodeIncrementalField(cursor: ITreeCursorSynchronous, chunkEncoder: (chunk: TreeChunk) => EncodedFieldBatch): ChunkReferenceId[];
157
+ /**
158
+ * Must be called after summary generation is complete to finish tracking the summary.
159
+ * It clears any tracking state and deletes the tracking properties for summaries that are older than the
160
+ * latest successful summary.
161
+ * @param incrementalSummaryContext - The context for the incremental summary that contains the sequence numbers.
162
+ * If this is undefined, the summary tree will only contain a summary blob for `forestSummaryContent`.
163
+ * @param forestSummaryContent - The stringified ForestCodec output of top-level Forest content.
164
+ * @returns the Forest's summary tree.
165
+ */
166
+ completeSummary(args: {
167
+ incrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;
168
+ forestSummaryContent: string;
169
+ }): ISummaryTreeWithStats;
170
+ /**
171
+ * Called to get the encoded contents of an incremental chunk with the given reference ID.
172
+ * This is typically used when loading the forest to retrieve the contents of incremental chunks.
173
+ * @param referenceId - The reference ID of the chunk to retrieve.
174
+ * @returns The encoded contents of the chunk.
175
+ */
176
+ getEncodedIncrementalChunk(referenceId: ChunkReferenceId): EncodedFieldBatch;
177
+ }
178
+ //# sourceMappingURL=incrementalSummaryBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incrementalSummaryBuilder.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,sCAAsC,EACtC,qBAAqB,EACrB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAIN,KAAK,cAAc,EAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACX,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,EACzB,SAAS,EACT,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACX,QAAQ,EACR,sBAAsB,EACtB,wBAAwB,EACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAG7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,eAAe,CAAC;AAUpD;;GAEG;AACH,eAAO,MAAM,0BAA0B;IACtC,4CAA4C;;IAE5C,wCAAwC;;CAE/B,CAAC;AACX,MAAM,MAAM,0BAA0B,GACrC,CAAC,OAAO,0BAA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