@fluidframework/tree 2.116.1 → 2.117.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.
Files changed (362) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/api-report/tree.alpha.api.md +78 -30
  3. package/api-report/tree.beta.api.md +12 -9
  4. package/api-report/tree.legacy.beta.api.md +12 -9
  5. package/dist/codec/codec.d.ts +18 -0
  6. package/dist/codec/codec.d.ts.map +1 -1
  7. package/dist/codec/codec.js +18 -0
  8. package/dist/codec/codec.js.map +1 -1
  9. package/dist/core/index.d.ts +2 -2
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/index.js +3 -2
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/rebase/index.d.ts +1 -1
  14. package/dist/core/rebase/index.d.ts.map +1 -1
  15. package/dist/core/rebase/index.js +2 -1
  16. package/dist/core/rebase/index.js.map +1 -1
  17. package/dist/core/rebase/types.d.ts +39 -2
  18. package/dist/core/rebase/types.d.ts.map +1 -1
  19. package/dist/core/rebase/types.js +37 -2
  20. package/dist/core/rebase/types.js.map +1 -1
  21. package/dist/core/rebase/utils.d.ts.map +1 -1
  22. package/dist/core/rebase/utils.js +1 -0
  23. package/dist/core/rebase/utils.js.map +1 -1
  24. package/dist/core/revertible.d.ts +62 -6
  25. package/dist/core/revertible.d.ts.map +1 -1
  26. package/dist/core/revertible.js.map +1 -1
  27. package/dist/entrypoints/alpha.d.ts +1 -1
  28. package/dist/entrypoints/alpha.d.ts.map +1 -1
  29. package/dist/entrypoints/alpha.js.map +1 -1
  30. package/dist/entrypoints/beta.d.ts +1 -1
  31. package/dist/entrypoints/beta.d.ts.map +1 -1
  32. package/dist/entrypoints/beta.js.map +1 -1
  33. package/dist/entrypoints/legacy.d.ts +1 -1
  34. package/dist/entrypoints/legacy.d.ts.map +1 -1
  35. package/dist/entrypoints/legacy.js.map +1 -1
  36. package/dist/feature-libraries/indexing/types.d.ts +1 -1
  37. package/dist/feature-libraries/indexing/types.js.map +1 -1
  38. package/dist/index.d.ts +2 -2
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/packageVersion.d.ts +1 -1
  42. package/dist/packageVersion.js +1 -1
  43. package/dist/packageVersion.js.map +1 -1
  44. package/dist/shared-tree/history.d.ts +22 -0
  45. package/dist/shared-tree/history.d.ts.map +1 -0
  46. package/dist/shared-tree/history.js +66 -0
  47. package/dist/shared-tree/history.js.map +1 -0
  48. package/dist/shared-tree/schematizingTreeView.d.ts +12 -7
  49. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  50. package/dist/shared-tree/schematizingTreeView.js +13 -0
  51. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  52. package/dist/shared-tree/sharedTree.d.ts +3 -2
  53. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  54. package/dist/shared-tree/sharedTree.js +2 -0
  55. package/dist/shared-tree/sharedTree.js.map +1 -1
  56. package/dist/shared-tree/tree.js +1 -1
  57. package/dist/shared-tree/tree.js.map +1 -1
  58. package/dist/shared-tree/treeAlpha.d.ts +8 -20
  59. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  60. package/dist/shared-tree/treeAlpha.js +9 -12
  61. package/dist/shared-tree/treeAlpha.js.map +1 -1
  62. package/dist/shared-tree/treeCheckout.d.ts +16 -9
  63. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  64. package/dist/shared-tree/treeCheckout.js +122 -25
  65. package/dist/shared-tree/treeCheckout.js.map +1 -1
  66. package/dist/shared-tree/unhydratedTreeContext.d.ts +3 -2
  67. package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  68. package/dist/shared-tree/unhydratedTreeContext.js +3 -0
  69. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  70. package/dist/shared-tree-core/branch.d.ts +16 -2
  71. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  72. package/dist/shared-tree-core/branch.js +20 -2
  73. package/dist/shared-tree-core/branch.js.map +1 -1
  74. package/dist/shared-tree-core/branchCommitCounter.d.ts +31 -0
  75. package/dist/shared-tree-core/branchCommitCounter.d.ts.map +1 -0
  76. package/dist/shared-tree-core/branchCommitCounter.js +79 -0
  77. package/dist/shared-tree-core/branchCommitCounter.js.map +1 -0
  78. package/dist/shared-tree-core/customMetadataCodec.d.ts +9 -0
  79. package/dist/shared-tree-core/customMetadataCodec.d.ts.map +1 -0
  80. package/dist/shared-tree-core/customMetadataCodec.js +37 -0
  81. package/dist/shared-tree-core/customMetadataCodec.js.map +1 -0
  82. package/dist/shared-tree-core/customMetadataFormat.d.ts +18 -0
  83. package/dist/shared-tree-core/customMetadataFormat.d.ts.map +1 -0
  84. package/dist/shared-tree-core/customMetadataFormat.js +15 -0
  85. package/dist/shared-tree-core/customMetadataFormat.js.map +1 -0
  86. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  87. package/dist/shared-tree-core/editManager.js +15 -3
  88. package/dist/shared-tree-core/editManager.js.map +1 -1
  89. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  90. package/dist/shared-tree-core/editManagerCodecs.js +5 -0
  91. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  92. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  93. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  94. package/dist/shared-tree-core/editManagerCodecsCommons.js +17 -5
  95. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  96. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  97. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +4 -2
  98. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  99. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  100. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
  101. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  102. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +17 -6
  103. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  104. package/dist/shared-tree-core/editManagerFormatCommons.js +18 -8
  105. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  106. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +7 -5
  107. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  108. package/dist/shared-tree-core/editManagerFormatV1toV4.js +4 -3
  109. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  110. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +4 -0
  111. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  112. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js +2 -2
  113. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
  114. package/dist/shared-tree-core/index.d.ts +2 -1
  115. package/dist/shared-tree-core/index.d.ts.map +1 -1
  116. package/dist/shared-tree-core/index.js +3 -1
  117. package/dist/shared-tree-core/index.js.map +1 -1
  118. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
  119. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  120. package/dist/shared-tree-core/messageCodecV1ToV4.js +12 -3
  121. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  122. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  123. package/dist/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  124. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  125. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  126. package/dist/shared-tree-core/messageCodecs.js +5 -0
  127. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  128. package/dist/shared-tree-core/messageFormat.d.ts +1 -0
  129. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  130. package/dist/shared-tree-core/messageFormat.js +6 -0
  131. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  132. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +10 -3
  133. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  134. package/dist/shared-tree-core/messageFormatV1ToV4.js +10 -2
  135. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  136. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -0
  137. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  138. package/dist/shared-tree-core/messageFormatVSharedBranches.js +2 -0
  139. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  140. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  141. package/dist/shared-tree-core/sharedTreeCore.js +4 -2
  142. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  143. package/dist/shared-tree-core/transaction.d.ts +9 -0
  144. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  145. package/dist/shared-tree-core/transaction.js +26 -4
  146. package/dist/shared-tree-core/transaction.js.map +1 -1
  147. package/dist/simple-tree/api/index.d.ts +1 -1
  148. package/dist/simple-tree/api/index.d.ts.map +1 -1
  149. package/dist/simple-tree/api/index.js.map +1 -1
  150. package/dist/simple-tree/api/transactionTypes.d.ts +28 -2
  151. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  152. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  153. package/dist/simple-tree/api/tree.d.ts +180 -61
  154. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  155. package/dist/simple-tree/api/tree.js.map +1 -1
  156. package/dist/simple-tree/index.d.ts +1 -1
  157. package/dist/simple-tree/index.d.ts.map +1 -1
  158. package/dist/simple-tree/index.js.map +1 -1
  159. package/dist/tableSchema.js +10 -10
  160. package/dist/tableSchema.js.map +1 -1
  161. package/lib/codec/codec.d.ts +18 -0
  162. package/lib/codec/codec.d.ts.map +1 -1
  163. package/lib/codec/codec.js +18 -0
  164. package/lib/codec/codec.js.map +1 -1
  165. package/lib/core/index.d.ts +2 -2
  166. package/lib/core/index.d.ts.map +1 -1
  167. package/lib/core/index.js +1 -1
  168. package/lib/core/index.js.map +1 -1
  169. package/lib/core/rebase/index.d.ts +1 -1
  170. package/lib/core/rebase/index.d.ts.map +1 -1
  171. package/lib/core/rebase/index.js +1 -1
  172. package/lib/core/rebase/index.js.map +1 -1
  173. package/lib/core/rebase/types.d.ts +39 -2
  174. package/lib/core/rebase/types.d.ts.map +1 -1
  175. package/lib/core/rebase/types.js +35 -1
  176. package/lib/core/rebase/types.js.map +1 -1
  177. package/lib/core/rebase/utils.d.ts.map +1 -1
  178. package/lib/core/rebase/utils.js +1 -0
  179. package/lib/core/rebase/utils.js.map +1 -1
  180. package/lib/core/revertible.d.ts +62 -6
  181. package/lib/core/revertible.d.ts.map +1 -1
  182. package/lib/core/revertible.js.map +1 -1
  183. package/lib/entrypoints/alpha.d.ts +1 -1
  184. package/lib/entrypoints/alpha.d.ts.map +1 -1
  185. package/lib/entrypoints/alpha.js.map +1 -1
  186. package/lib/entrypoints/beta.d.ts +1 -1
  187. package/lib/entrypoints/beta.d.ts.map +1 -1
  188. package/lib/entrypoints/beta.js.map +1 -1
  189. package/lib/entrypoints/legacy.d.ts +1 -1
  190. package/lib/entrypoints/legacy.d.ts.map +1 -1
  191. package/lib/entrypoints/legacy.js.map +1 -1
  192. package/lib/feature-libraries/indexing/types.d.ts +1 -1
  193. package/lib/feature-libraries/indexing/types.js.map +1 -1
  194. package/lib/index.d.ts +2 -2
  195. package/lib/index.d.ts.map +1 -1
  196. package/lib/index.js.map +1 -1
  197. package/lib/packageVersion.d.ts +1 -1
  198. package/lib/packageVersion.js +1 -1
  199. package/lib/packageVersion.js.map +1 -1
  200. package/lib/shared-tree/history.d.ts +22 -0
  201. package/lib/shared-tree/history.d.ts.map +1 -0
  202. package/lib/shared-tree/history.js +62 -0
  203. package/lib/shared-tree/history.js.map +1 -0
  204. package/lib/shared-tree/schematizingTreeView.d.ts +12 -7
  205. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  206. package/lib/shared-tree/schematizingTreeView.js +13 -0
  207. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  208. package/lib/shared-tree/sharedTree.d.ts +3 -2
  209. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  210. package/lib/shared-tree/sharedTree.js +2 -0
  211. package/lib/shared-tree/sharedTree.js.map +1 -1
  212. package/lib/shared-tree/tree.js +1 -1
  213. package/lib/shared-tree/tree.js.map +1 -1
  214. package/lib/shared-tree/treeAlpha.d.ts +8 -20
  215. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  216. package/lib/shared-tree/treeAlpha.js +9 -12
  217. package/lib/shared-tree/treeAlpha.js.map +1 -1
  218. package/lib/shared-tree/treeCheckout.d.ts +16 -9
  219. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  220. package/lib/shared-tree/treeCheckout.js +123 -26
  221. package/lib/shared-tree/treeCheckout.js.map +1 -1
  222. package/lib/shared-tree/unhydratedTreeContext.d.ts +3 -2
  223. package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  224. package/lib/shared-tree/unhydratedTreeContext.js +3 -0
  225. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  226. package/lib/shared-tree-core/branch.d.ts +16 -2
  227. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  228. package/lib/shared-tree-core/branch.js +20 -2
  229. package/lib/shared-tree-core/branch.js.map +1 -1
  230. package/lib/shared-tree-core/branchCommitCounter.d.ts +31 -0
  231. package/lib/shared-tree-core/branchCommitCounter.d.ts.map +1 -0
  232. package/lib/shared-tree-core/branchCommitCounter.js +75 -0
  233. package/lib/shared-tree-core/branchCommitCounter.js.map +1 -0
  234. package/lib/shared-tree-core/customMetadataCodec.d.ts +9 -0
  235. package/lib/shared-tree-core/customMetadataCodec.d.ts.map +1 -0
  236. package/lib/shared-tree-core/customMetadataCodec.js +32 -0
  237. package/lib/shared-tree-core/customMetadataCodec.js.map +1 -0
  238. package/lib/shared-tree-core/customMetadataFormat.d.ts +18 -0
  239. package/lib/shared-tree-core/customMetadataFormat.d.ts.map +1 -0
  240. package/lib/shared-tree-core/customMetadataFormat.js +11 -0
  241. package/lib/shared-tree-core/customMetadataFormat.js.map +1 -0
  242. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  243. package/lib/shared-tree-core/editManager.js +16 -4
  244. package/lib/shared-tree-core/editManager.js.map +1 -1
  245. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  246. package/lib/shared-tree-core/editManagerCodecs.js +5 -0
  247. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  248. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  249. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  250. package/lib/shared-tree-core/editManagerCodecsCommons.js +17 -5
  251. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  252. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  253. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +4 -2
  254. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  255. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  256. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
  257. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  258. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +17 -6
  259. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  260. package/lib/shared-tree-core/editManagerFormatCommons.js +18 -8
  261. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  262. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +7 -5
  263. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  264. package/lib/shared-tree-core/editManagerFormatV1toV4.js +4 -3
  265. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  266. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +4 -0
  267. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  268. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js +2 -2
  269. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
  270. package/lib/shared-tree-core/index.d.ts +2 -1
  271. package/lib/shared-tree-core/index.d.ts.map +1 -1
  272. package/lib/shared-tree-core/index.js +1 -0
  273. package/lib/shared-tree-core/index.js.map +1 -1
  274. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
  275. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  276. package/lib/shared-tree-core/messageCodecV1ToV4.js +12 -3
  277. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  278. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  279. package/lib/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  280. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  281. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  282. package/lib/shared-tree-core/messageCodecs.js +5 -0
  283. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  284. package/lib/shared-tree-core/messageFormat.d.ts +1 -0
  285. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  286. package/lib/shared-tree-core/messageFormat.js +6 -0
  287. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  288. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +10 -3
  289. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  290. package/lib/shared-tree-core/messageFormatV1ToV4.js +10 -2
  291. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  292. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -0
  293. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  294. package/lib/shared-tree-core/messageFormatVSharedBranches.js +2 -0
  295. package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  296. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  297. package/lib/shared-tree-core/sharedTreeCore.js +5 -3
  298. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  299. package/lib/shared-tree-core/transaction.d.ts +9 -0
  300. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  301. package/lib/shared-tree-core/transaction.js +27 -5
  302. package/lib/shared-tree-core/transaction.js.map +1 -1
  303. package/lib/simple-tree/api/index.d.ts +1 -1
  304. package/lib/simple-tree/api/index.d.ts.map +1 -1
  305. package/lib/simple-tree/api/index.js.map +1 -1
  306. package/lib/simple-tree/api/transactionTypes.d.ts +28 -2
  307. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  308. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  309. package/lib/simple-tree/api/tree.d.ts +180 -61
  310. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  311. package/lib/simple-tree/api/tree.js.map +1 -1
  312. package/lib/simple-tree/index.d.ts +1 -1
  313. package/lib/simple-tree/index.d.ts.map +1 -1
  314. package/lib/simple-tree/index.js.map +1 -1
  315. package/lib/tableSchema.js +10 -10
  316. package/lib/tableSchema.js.map +1 -1
  317. package/package.json +22 -22
  318. package/src/codec/codec.ts +19 -0
  319. package/src/core/index.ts +4 -0
  320. package/src/core/rebase/index.ts +2 -0
  321. package/src/core/rebase/types.ts +72 -2
  322. package/src/core/rebase/utils.ts +1 -0
  323. package/src/core/revertible.ts +67 -6
  324. package/src/entrypoints/alpha.ts +8 -0
  325. package/src/entrypoints/beta.ts +1 -0
  326. package/src/entrypoints/legacy.ts +1 -0
  327. package/src/feature-libraries/indexing/types.ts +1 -1
  328. package/src/index.ts +8 -0
  329. package/src/packageVersion.ts +1 -1
  330. package/src/shared-tree/history.ts +99 -0
  331. package/src/shared-tree/schematizingTreeView.ts +25 -8
  332. package/src/shared-tree/sharedTree.ts +5 -2
  333. package/src/shared-tree/tree.ts +1 -1
  334. package/src/shared-tree/treeAlpha.ts +17 -35
  335. package/src/shared-tree/treeCheckout.ts +170 -31
  336. package/src/shared-tree/unhydratedTreeContext.ts +6 -2
  337. package/src/shared-tree-core/branch.ts +34 -2
  338. package/src/shared-tree-core/branchCommitCounter.ts +103 -0
  339. package/src/shared-tree-core/customMetadataCodec.ts +42 -0
  340. package/src/shared-tree-core/customMetadataFormat.ts +39 -0
  341. package/src/shared-tree-core/editManager.ts +22 -3
  342. package/src/shared-tree-core/editManagerCodecs.ts +12 -0
  343. package/src/shared-tree-core/editManagerCodecsCommons.ts +41 -15
  344. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +7 -1
  345. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +2 -0
  346. package/src/shared-tree-core/editManagerFormatCommons.ts +46 -12
  347. package/src/shared-tree-core/editManagerFormatV1toV4.ts +13 -5
  348. package/src/shared-tree-core/editManagerFormatVSharedBranches.ts +2 -2
  349. package/src/shared-tree-core/index.ts +3 -0
  350. package/src/shared-tree-core/messageCodecV1ToV4.ts +18 -5
  351. package/src/shared-tree-core/messageCodecVSharedBranches.ts +9 -2
  352. package/src/shared-tree-core/messageCodecs.ts +12 -0
  353. package/src/shared-tree-core/messageFormat.ts +6 -0
  354. package/src/shared-tree-core/messageFormatV1ToV4.ts +21 -3
  355. package/src/shared-tree-core/messageFormatVSharedBranches.ts +8 -0
  356. package/src/shared-tree-core/sharedTreeCore.ts +5 -2
  357. package/src/shared-tree-core/transaction.ts +56 -4
  358. package/src/simple-tree/api/index.ts +5 -0
  359. package/src/simple-tree/api/transactionTypes.ts +29 -2
  360. package/src/simple-tree/api/tree.ts +199 -60
  361. package/src/simple-tree/index.ts +5 -0
  362. package/src/tableSchema.ts +9 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,121 @@
1
1
  # @fluidframework/tree
2
2
 
3
+ ## 2.117.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Rename TreeBranch and TreeBranchAlpha to UntypedTreeView ([#28104](https://github.com/microsoft/FluidFramework/pull/28104)) [e75bc54fa2](https://github.com/microsoft/FluidFramework/commit/e75bc54fa2cd24f8331e05e094c09ff602337c50)
8
+
9
+ `UntypedTreeView` and `UntypedTreeViewAlpha` replace the beta `TreeBranch` and alpha `TreeBranchAlpha` interfaces, clarifying that they represent tree views without known schemas. The old names remain available as deprecated compatibility aliases and will be removed in a future release.
10
+
11
+ Update API imports and type annotations to use the new names:
12
+
13
+ ```typescript
14
+ // Before
15
+ import type { TreeBranch } from "fluid-framework/beta";
16
+ import type { TreeBranchAlpha } from "fluid-framework/alpha";
17
+ const betaBranch: TreeBranch = betaView.fork();
18
+ const alphaBranch: TreeBranchAlpha = alphaView.fork();
19
+
20
+ // After
21
+ import type { UntypedTreeView } from "fluid-framework/beta";
22
+ import type { UntypedTreeViewAlpha } from "fluid-framework/alpha";
23
+ const betaForkedView: UntypedTreeView = betaView.fork();
24
+ const alphaForkedView: UntypedTreeViewAlpha = alphaView.fork();
25
+ ```
26
+
27
+ - New alpha API for attaching custom metadata to commits ([#28104](https://github.com/microsoft/FluidFramework/pull/28104)) [e75bc54fa2](https://github.com/microsoft/FluidFramework/commit/e75bc54fa2cd24f8331e05e094c09ff602337c50)
28
+
29
+ Applications can now attach arbitrary, JSON-serializable metadata to a commit, replicate it to collaborating clients, and persist it in the document.
30
+
31
+ Supply it via the new `customMetadata` field on [`RunTransactionParamsAlpha`](https://fluidframework.com/docs/api/fluid-framework/runtransactionparamsalpha-interface):
32
+
33
+ ```typescript
34
+ view.runTransaction(
35
+ () => {
36
+ view.root.insertAtEnd("new item");
37
+ },
38
+ { customMetadata: { author: "alice", intent: "add-item" } },
39
+ );
40
+ ```
41
+
42
+ The commit produced by reverting a `Revertible`, or by `revertTo`, can be annotated the same way via a new options argument:
43
+
44
+ ```typescript
45
+ revertible.revert({
46
+ customMetadata: { author: "alice", intent: "undo-add" },
47
+ });
48
+ view.revertTo(revision, {
49
+ customMetadata: { author: "alice", intent: "undo-add" },
50
+ });
51
+ ```
52
+
53
+ Read it back while walking the branch's [history](https://fluidframework.com/docs/api/fluid-framework/treebranchhistory-interface), via the new `custom` property on `TreeBranchCommitMetadata`:
54
+
55
+ ```typescript
56
+ for (
57
+ let commit = view.branchHistory.getHead();
58
+ commit !== undefined;
59
+ commit = commit.getParent()
60
+ ) {
61
+ const metadata = commit.custom;
62
+ }
63
+ ```
64
+
65
+ Because a commit may be produced by nested transactions, each of which may supply metadata, `custom` is the flattened combination of them all, with the outermost transaction winning on conflicting properties.
66
+ The structural view is available as `commit.customTree`, a `CustomMetadataTree` mirroring the transaction nesting — the same relationship `labels.tree` has to a change's label set.
67
+
68
+ Metadata shares the lifetime of the commit it is attached to, so it is dropped when that commit is trimmed from the trunk, or lasts as long as the document under the `retainHistory` option on `SharedTreeOptions`.
69
+ It also travels on every annotated op and occupies summary space for as long as its commit survives, so it should be kept small.
70
+
71
+ Persisting the metadata requires new op and summary format versions, which are written only when `minVersionForCollab` is set to `2.117.0` or later; until then, metadata is kept in memory for the local session but is neither replicated nor persisted.
72
+ Raising that floor makes every subsequent op and summary use the new versions, whether or not any commit carries metadata, so deploy metadata-capable code everywhere first.
73
+ Lowering it again is lossy: a client configured to write the older format can still read metadata but strips it when encoding.
74
+
75
+ - Bug fix: forking during changed event callback is now safe ([#28074](https://github.com/microsoft/FluidFramework/pull/28074)) [ca9458aa1a](https://github.com/microsoft/FluidFramework/commit/ca9458aa1ae9061928c5c7ff837b61d888468174)
76
+
77
+ [Forking](https://fluidframework.com/docs/api/fluid-framework/treeviewbeta-interface#fork-methodsignature) (beta) a view during the callback for the ["changed" event](https://fluidframework.com/docs/api/fluid-framework/treebranchevents-interface#changed-methodsignature) (alpha) emitted when a transaction is committed would create a fork with malformed change data.
78
+ This could result in asserts being triggered when utilizing the fork (including, but not limited to, error code `0x7ce`).
79
+
80
+ - Remove the deprecated TreeAlpha.branch API ([#28104](https://github.com/microsoft/FluidFramework/pull/28104)) [e75bc54fa2](https://github.com/microsoft/FluidFramework/commit/e75bc54fa2cd24f8331e05e094c09ff602337c50)
81
+
82
+ The deprecated alpha `TreeAlpha.branch(node)` API has been removed. Use [`TreeAlpha.context(node)`](https://fluidframework.com/docs/api/fluid-framework/treealpha-interface#context-methodsignature) and check [`isView()`](https://fluidframework.com/docs/api/fluid-framework/treecontextalpha-interface#isview-methodsignature) to access the untyped view for a hydrated node:
83
+
84
+ ```typescript
85
+ const context = TreeAlpha.context(node);
86
+ if (context.isView()) {
87
+ // `context` is an UntypedTreeViewAlpha here.
88
+ }
89
+ ```
90
+
91
+ - retainHistory now retains history in summaries ([#28104](https://github.com/microsoft/FluidFramework/pull/28104)) [e75bc54fa2](https://github.com/microsoft/FluidFramework/commit/e75bc54fa2cd24f8331e05e094c09ff602337c50)
92
+
93
+ The `retainHistory` option on `SharedTreeOptions` is documented as causing growth in summaries/snapshots as well as in memory, but it only ever prevented trunk commits from being evicted from memory.
94
+ Summaries continued to contain just the collaboration window, so retained history was discarded at the next summary and was unavailable to clients that loaded from it.
95
+
96
+ Summaries produced by a client with `retainHistory` enabled now contain the full trunk, matching the option's documented behavior.
97
+ History accumulated while the flag is enabled survives summarization and is available to clients that join later.
98
+ History is only retained from the point at which the flag is enabled: commits that were already evicted by a prior session cannot be recovered.
99
+
100
+ There is no change to the default (`retainHistory: false`) behavior, and no change to the persisted format.
101
+
102
+ - New alpha APIs for inspecting history and restoring past states ([#28104](https://github.com/microsoft/FluidFramework/pull/28104)) [e75bc54fa2](https://github.com/microsoft/FluidFramework/commit/e75bc54fa2cd24f8331e05e094c09ff602337c50)
103
+
104
+ `UntypedTreeViewAlpha` (formerly [`TreeBranchAlpha`](https://fluidframework.com/docs/api/fluid-framework/treebranchalpha-interface)) now exposes a `branchHistory` property which returns a `TreeBranchHistory` object with:
105
+ - `commitCount`: the number of commits currently in the branch's history.
106
+ This number grows when a new edit is made on the branch, when a branch containing new commits is merged into it, or when it is rebased onto a branch containing new commits.
107
+ It shrinks when past commits are trimmed from the history.
108
+ - `getHeadCommit()`: returns the `TreeBranchCommitMetadata` for the branch's head commit, or `undefined` if the branch has no commits.
109
+ Each `TreeBranchCommitMetadata` exposes the commit's `revision` string and its `parent` commit metadata, so the history can be walked backwards from the head.
110
+
111
+ A `revision` obtained this way can be passed to either of two new methods on `UntypedTreeViewAlpha` implementations:
112
+ - `revertTo(revision)`: applies a new change which reverts all changes made since `revision`.
113
+ The generated change is subject to the same merge semantics as the reverts of individual commits, so concurrent changes sequenced before the revert which affect different parts of the document are not overwritten.
114
+ - `rewindTo(revision)`: switches the view to a new underlying branch whose head is the commit at `revision`, without applying a change.
115
+ The original underlying branch is disposed unless it is the main branch or a shared branch, so consider `fork()`ing before rewinding if it needs to be retained.
116
+
117
+ How much history is available depends on how many commits the client retains; see the `retainHistory` option on `SharedTreeOptions`.
118
+
3
119
  ## 2.116.0
4
120
 
5
121
  ### Minor Changes
@@ -223,6 +223,9 @@ export enum CommitOutcome {
223
223
  NewContentOnly = 2
224
224
  }
225
225
 
226
+ // @alpha
227
+ export type CommitRevision = string;
228
+
226
229
  // @alpha
227
230
  export function comparePersistedSchema(persisted: JsonCompatible, view: ImplicitFieldSchema, options: ICodecOptions): Omit<SchemaCompatibilityStatus, "canInitialize">;
228
231
 
@@ -297,6 +300,12 @@ export function createTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey e
297
300
  // @beta
298
301
  export function createTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue, TSchema extends TreeNodeSchema>(view: TreeView<TFieldSchema>, indexer: Map<TreeNodeSchema, string>, getValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey, indexableSchema: readonly TSchema[]): TreeIndex<TKey, TValue>;
299
302
 
303
+ // @alpha @sealed
304
+ export interface CustomMetadataTree {
305
+ readonly children: readonly CustomMetadataTree[];
306
+ readonly metadata: JsonCompatibleReadOnlyObject | undefined;
307
+ }
308
+
300
309
  // @alpha
301
310
  export function decodeSchemaCompatibilitySnapshot(encodedSchema: JsonCompatibleReadOnly, validator?: FormatValidator): SimpleTreeSchema;
302
311
 
@@ -478,6 +487,7 @@ export const FluidClientVersion: {
478
487
  readonly v2_73: "2.73.0";
479
488
  readonly v2_74: "2.74.0";
480
489
  readonly v2_80: "2.80.0";
490
+ readonly v2_117: "2.117.0";
481
491
  };
482
492
 
483
493
  // @beta
@@ -1183,7 +1193,10 @@ export interface Revertible {
1183
1193
 
1184
1194
  // @alpha @sealed
1185
1195
  export interface RevertibleAlpha extends Revertible {
1186
- clone: (branch: TreeBranch) => RevertibleAlpha;
1196
+ clone: (view: UntypedTreeView) => RevertibleAlpha;
1197
+ revert(): void;
1198
+ revert(dispose: boolean): void;
1199
+ revert(options: RevertOptionsAlpha): void;
1187
1200
  }
1188
1201
 
1189
1202
  // @alpha @sealed
@@ -1198,6 +1211,17 @@ export enum RevertibleStatus {
1198
1211
  Valid = 0
1199
1212
  }
1200
1213
 
1214
+ // @alpha @sealed
1215
+ export interface RevertOptionsAlpha {
1216
+ readonly customMetadata?: JsonCompatibleReadOnlyObject;
1217
+ readonly dispose?: boolean;
1218
+ }
1219
+
1220
+ // @alpha @sealed
1221
+ export interface RevertToOptionsAlpha {
1222
+ readonly customMetadata?: JsonCompatibleReadOnlyObject;
1223
+ }
1224
+
1201
1225
  // @public
1202
1226
  export const rollback: unique symbol;
1203
1227
 
@@ -1220,6 +1244,7 @@ export interface RunTransaction {
1220
1244
 
1221
1245
  // @alpha @input
1222
1246
  export interface RunTransactionParamsAlpha extends RunTransactionParamsBeta {
1247
+ readonly customMetadata?: JsonCompatibleReadOnlyObject;
1223
1248
  readonly postProcessor?: TransactionPostProcessor;
1224
1249
  readonly preconditions?: readonly TransactionConstraintAlpha[];
1225
1250
  }
@@ -1825,8 +1850,6 @@ export const Tree: Tree;
1825
1850
 
1826
1851
  // @alpha @sealed
1827
1852
  export interface TreeAlpha {
1828
- // @deprecated
1829
- branch(node: TreeNode): TreeBranchAlpha | undefined;
1830
1853
  child(node: TreeNode, key: string | number): TreeNode | TreeLeafValue | undefined;
1831
1854
  children(node: TreeNode): Iterable<[propertyKey: string | number, child: TreeNode | TreeLeafValue]>;
1832
1855
  context(node: TreeNode): TreeContextAlpha;
@@ -1906,27 +1929,18 @@ export interface TreeBeta {
1906
1929
  // @beta
1907
1930
  export const TreeBeta: TreeBeta;
1908
1931
 
1909
- // @beta @sealed
1910
- export interface TreeBranch extends IDisposable {
1911
- dispose(error?: Error): void;
1912
- fork(): TreeBranch;
1913
- merge(branch: TreeBranch, disposeMerged?: boolean): void;
1914
- rebaseOnto(branch: TreeBranch): void;
1915
- }
1932
+ // @beta @deprecated
1933
+ export type TreeBranch = UntypedTreeView;
1934
+
1935
+ // @alpha @deprecated
1936
+ export type TreeBranchAlpha = UntypedTreeViewAlpha;
1916
1937
 
1917
1938
  // @alpha @sealed
1918
- export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
1919
- applyChange(change: JsonCompatibleReadOnly): void;
1920
- computeNetChangeIfRebasedOnto(branch: TreeBranch): JsonCompatibleReadOnly | undefined;
1921
- readonly events: Listenable_2<TreeBranchEvents>;
1922
- // (undocumented)
1923
- fork(): TreeBranchAlpha;
1924
- hasRootSchema<TSchema extends ImplicitFieldSchema>(schema: TSchema): this is TreeViewAlpha<TSchema>;
1925
- isMissingEditsFrom(branch: TreeBranch): boolean;
1926
- runTransaction<TSuccessValue, TFailureValue>(transaction: () => TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>, params?: RunTransactionParamsAlpha): TransactionValueResult<TSuccessValue, TFailureValue>;
1927
- runTransaction(transaction: () => VoidTransactionCallbackStatusAlpha | void, params?: RunTransactionParamsAlpha): TransactionVoidResult;
1928
- runTransactionAsync<TSuccessValue, TFailureValue>(transaction: () => Promise<TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>>, params?: RunTransactionParamsAlpha): Promise<TransactionValueResult<TSuccessValue, TFailureValue>>;
1929
- runTransactionAsync(transaction: () => Promise<VoidTransactionCallbackStatusAlpha | void>, params?: RunTransactionParamsAlpha): Promise<TransactionVoidResult>;
1939
+ export interface TreeBranchCommitMetadata {
1940
+ readonly custom: JsonCompatibleReadOnlyObject | undefined;
1941
+ readonly customTree: CustomMetadataTree | undefined;
1942
+ getParent(): TreeBranchCommitMetadata | undefined;
1943
+ readonly revision: CommitRevision;
1930
1944
  }
1931
1945
 
1932
1946
  // @alpha @sealed
@@ -1934,6 +1948,12 @@ export interface TreeBranchEvents {
1934
1948
  changed(data: ChangeMetadata, getRevertible?: RevertibleAlphaFactory): void;
1935
1949
  }
1936
1950
 
1951
+ // @alpha @sealed
1952
+ export interface TreeBranchHistory {
1953
+ getHead(): TreeBranchCommitMetadata | undefined;
1954
+ readonly length: number;
1955
+ }
1956
+
1937
1957
  // @public @sealed
1938
1958
  export interface TreeChangeEvents {
1939
1959
  nodeChanged(unstable?: unknown): void;
@@ -1960,7 +1980,9 @@ export enum TreeCompressionStrategy {
1960
1980
 
1961
1981
  // @alpha
1962
1982
  export interface TreeContextAlpha {
1963
- isBranch(): this is TreeBranchAlpha;
1983
+ // @deprecated
1984
+ isBranch(): this is UntypedTreeViewAlpha;
1985
+ isView(): this is UntypedTreeViewAlpha;
1964
1986
  runTransaction<TValue>(transaction: () => WithValue<TValue>, params?: RunTransactionParamsAlpha): TransactionValueResult<TValue, TValue>;
1965
1987
  runTransaction(transaction: () => void, params?: RunTransactionParamsAlpha): TransactionVoidResult;
1966
1988
  runTransactionAsync<TValue>(transaction: () => Promise<WithValue<TValue>>, params?: RunTransactionParamsAlpha): Promise<TransactionValueResult<TValue, TValue>>;
@@ -1987,10 +2009,10 @@ export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = Fie
1987
2009
  // @alpha @sealed
1988
2010
  export interface TreeIdentifierUtils {
1989
2011
  (node: TreeNode): string | undefined;
1990
- create(branch: TreeBranch): string;
2012
+ create(view: UntypedTreeView): string;
1991
2013
  getShort(node: TreeNode): number | undefined;
1992
- lengthen(branch: TreeBranch, nodeIdentifier: number): string;
1993
- shorten(branch: TreeBranch, nodeIdentifier: string): number | undefined;
2014
+ lengthen(view: UntypedTreeView, nodeIdentifier: number): string;
2015
+ shorten(view: UntypedTreeView, nodeIdentifier: string): number | undefined;
1994
2016
  }
1995
2017
 
1996
2018
  // @beta @sealed
@@ -2130,11 +2152,11 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
2130
2152
  }
2131
2153
 
2132
2154
  // @alpha @sealed
2133
- export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> extends Omit<TreeViewBeta<ReadSchema<TSchema>>, "root" | "initialize" | "fork" | "runTransaction" | "runTransactionAsync">, TreeBranchAlpha {
2155
+ export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> extends Omit<TreeViewBeta<ReadSchema<TSchema>>, "root" | "initialize" | "fork" | "runTransaction" | "runTransactionAsync">, UntypedTreeViewAlpha {
2134
2156
  // (undocumented)
2135
2157
  readonly events: Listenable_2<TreeViewEvents & TreeBranchEvents>;
2136
2158
  // (undocumented)
2137
- fork(): ReturnType<TreeBranch["fork"]> & TreeViewAlpha<TSchema>;
2159
+ fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewAlpha<TSchema>;
2138
2160
  initialize(content: InsertableField<TSchema>): void;
2139
2161
  // (undocumented)
2140
2162
  get root(): ReadableField<TSchema>;
@@ -2142,9 +2164,9 @@ export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | Unsa
2142
2164
  }
2143
2165
 
2144
2166
  // @beta @sealed
2145
- export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, TreeBranch {
2167
+ export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, UntypedTreeView {
2146
2168
  // (undocumented)
2147
- fork(): ReturnType<TreeBranch["fork"]> & TreeViewBeta<TSchema>;
2169
+ fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewBeta<TSchema>;
2148
2170
  runTransaction<TOut extends TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void>(transaction: () => TOut, params?: RunTransactionParamsBeta): TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult;
2149
2171
  runTransactionAsync<TOut extends TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void>(transaction: () => Promise<TOut>, params?: RunTransactionParamsBeta): Promise<TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult>;
2150
2172
  }
@@ -2215,6 +2237,32 @@ export const UnsafeUnknownSchema: unique symbol;
2215
2237
  // @alpha
2216
2238
  export type UnsafeUnknownSchema = typeof UnsafeUnknownSchema;
2217
2239
 
2240
+ // @beta @sealed
2241
+ export interface UntypedTreeView extends IDisposable {
2242
+ dispose(error?: Error): void;
2243
+ fork(): UntypedTreeView;
2244
+ merge(view: UntypedTreeView, disposeMerged?: boolean): void;
2245
+ rebaseOnto(view: UntypedTreeView): void;
2246
+ }
2247
+
2248
+ // @alpha @sealed
2249
+ export interface UntypedTreeViewAlpha extends UntypedTreeView, TreeContextAlpha {
2250
+ applyChange(change: JsonCompatibleReadOnly): void;
2251
+ readonly branchHistory: TreeBranchHistory;
2252
+ computeNetChangeIfRebasedOnto(view: UntypedTreeView): JsonCompatibleReadOnly | undefined;
2253
+ readonly events: Listenable_2<TreeBranchEvents>;
2254
+ // (undocumented)
2255
+ fork(): UntypedTreeViewAlpha;
2256
+ hasRootSchema<TSchema extends ImplicitFieldSchema>(schema: TSchema): this is TreeViewAlpha<TSchema>;
2257
+ isMissingEditsFrom(view: UntypedTreeView): boolean;
2258
+ revertTo(revision: CommitRevision, options?: RevertToOptionsAlpha): void;
2259
+ rewindTo(revision: CommitRevision): void;
2260
+ runTransaction<TSuccessValue, TFailureValue>(transaction: () => TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>, params?: RunTransactionParamsAlpha): TransactionValueResult<TSuccessValue, TFailureValue>;
2261
+ runTransaction(transaction: () => VoidTransactionCallbackStatusAlpha | void, params?: RunTransactionParamsAlpha): TransactionVoidResult;
2262
+ runTransactionAsync<TSuccessValue, TFailureValue>(transaction: () => Promise<TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>>, params?: RunTransactionParamsAlpha): Promise<TransactionValueResult<TSuccessValue, TFailureValue>>;
2263
+ runTransactionAsync(transaction: () => Promise<VoidTransactionCallbackStatusAlpha | void>, params?: RunTransactionParamsAlpha): Promise<TransactionVoidResult>;
2264
+ }
2265
+
2218
2266
  // @public
2219
2267
  export type ValidateRecursiveSchema<T extends ValidateRecursiveSchemaTemplate<T>> = true;
2220
2268
 
@@ -957,13 +957,8 @@ export interface TreeBeta {
957
957
  // @beta
958
958
  export const TreeBeta: TreeBeta;
959
959
 
960
- // @beta @sealed
961
- export interface TreeBranch extends IDisposable {
962
- dispose(error?: Error): void;
963
- fork(): TreeBranch;
964
- merge(branch: TreeBranch, disposeMerged?: boolean): void;
965
- rebaseOnto(branch: TreeBranch): void;
966
- }
960
+ // @beta @deprecated
961
+ export type TreeBranch = UntypedTreeView;
967
962
 
968
963
  // @public @sealed
969
964
  export interface TreeChangeEvents {
@@ -1100,9 +1095,9 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
1100
1095
  }
1101
1096
 
1102
1097
  // @beta @sealed
1103
- export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, TreeBranch {
1098
+ export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, UntypedTreeView {
1104
1099
  // (undocumented)
1105
- fork(): ReturnType<TreeBranch["fork"]> & TreeViewBeta<TSchema>;
1100
+ fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewBeta<TSchema>;
1106
1101
  runTransaction<TOut extends TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void>(transaction: () => TOut, params?: RunTransactionParamsBeta): TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult;
1107
1102
  runTransactionAsync<TOut extends TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void>(transaction: () => Promise<TOut>, params?: RunTransactionParamsBeta): Promise<TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult>;
1108
1103
  }
@@ -1157,6 +1152,14 @@ export type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) e
1157
1152
  // @beta @system
1158
1153
  export type UnionToTuple<Union, A extends unknown[] = [], First = PopUnion<Union>> = IsUnion<Union> extends true ? UnionToTuple<Exclude<Union, First>, [First, ...A]> : [Union, ...A];
1159
1154
 
1155
+ // @beta @sealed
1156
+ export interface UntypedTreeView extends IDisposable {
1157
+ dispose(error?: Error): void;
1158
+ fork(): UntypedTreeView;
1159
+ merge(view: UntypedTreeView, disposeMerged?: boolean): void;
1160
+ rebaseOnto(view: UntypedTreeView): void;
1161
+ }
1162
+
1160
1163
  // @public
1161
1164
  export type ValidateRecursiveSchema<T extends ValidateRecursiveSchemaTemplate<T>> = true;
1162
1165
 
@@ -969,13 +969,8 @@ export interface TreeBeta {
969
969
  // @beta
970
970
  export const TreeBeta: TreeBeta;
971
971
 
972
- // @beta @sealed
973
- export interface TreeBranch extends IDisposable {
974
- dispose(error?: Error): void;
975
- fork(): TreeBranch;
976
- merge(branch: TreeBranch, disposeMerged?: boolean): void;
977
- rebaseOnto(branch: TreeBranch): void;
978
- }
972
+ // @beta @deprecated
973
+ export type TreeBranch = UntypedTreeView;
979
974
 
980
975
  // @public @sealed
981
976
  export interface TreeChangeEvents {
@@ -1112,9 +1107,9 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
1112
1107
  }
1113
1108
 
1114
1109
  // @beta @sealed
1115
- export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, TreeBranch {
1110
+ export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, UntypedTreeView {
1116
1111
  // (undocumented)
1117
- fork(): ReturnType<TreeBranch["fork"]> & TreeViewBeta<TSchema>;
1112
+ fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewBeta<TSchema>;
1118
1113
  runTransaction<TOut extends TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void>(transaction: () => TOut, params?: RunTransactionParamsBeta): TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult;
1119
1114
  runTransactionAsync<TOut extends TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void>(transaction: () => Promise<TOut>, params?: RunTransactionParamsBeta): Promise<TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult>;
1120
1115
  }
@@ -1169,6 +1164,14 @@ export type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) e
1169
1164
  // @beta @system
1170
1165
  export type UnionToTuple<Union, A extends unknown[] = [], First = PopUnion<Union>> = IsUnion<Union> extends true ? UnionToTuple<Exclude<Union, First>, [First, ...A]> : [Union, ...A];
1171
1166
 
1167
+ // @beta @sealed
1168
+ export interface UntypedTreeView extends IDisposable {
1169
+ dispose(error?: Error): void;
1170
+ fork(): UntypedTreeView;
1171
+ merge(view: UntypedTreeView, disposeMerged?: boolean): void;
1172
+ rebaseOnto(view: UntypedTreeView): void;
1173
+ }
1174
+
1172
1175
  // @public
1173
1176
  export type ValidateRecursiveSchema<T extends ValidateRecursiveSchemaTemplate<T>> = true;
1174
1177
 
@@ -340,6 +340,24 @@ export declare const FluidClientVersion: {
340
340
  * - ModularChangeFormatVersion.v5 - written when minVersionForCollab \>= 2.80
341
341
  */
342
342
  readonly v2_80: "2.80.0";
343
+ /**
344
+ * Fluid Framework Client 2.117 and newer.
345
+ * @remarks
346
+ * New formats introduced in 2.117:
347
+ * - MessageFormatVersion.v7 - written when minVersionForCollab \>= 2.117
348
+ * - EditManagerFormatVersion.v7 - written when minVersionForCollab \>= 2.117
349
+ *
350
+ * @privateRemarks
351
+ * These formats are gated at 2.117.0 rather than 3.0.0 so that they can also be carried by a
352
+ * 2.117.0 minor cut from the last pre-3.0 commit on main, should one be needed for consumers
353
+ * that cannot yet absorb the 3.0 breaking changes. Since 3.0.0 \> 2.117.0, 3.x clients select
354
+ * these formats for any minVersionForCollab at or above 2.117.0 whether or not that release
355
+ * ever ships.
356
+ *
357
+ * Every client at or above 2.117.0 must therefore be able to read and write these formats. A
358
+ * client that maps 2.117.0 to an older format would silently strip metadata when encoding.
359
+ */
360
+ readonly v2_117: "2.117.0";
343
361
  };
344
362
  /**
345
363
  * An up to date version which includes all stable features.
@@ -1 +1 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAEjG,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IACrD;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,QAAQ,E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QG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;;OAWG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;;;;;;;;;;OAgBG;;CAE6D,CAAC;AAElE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,EAAE,4BAAgE,CAAC;AAE9F;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS,CAAC,cAAc,SAAS,aAAa,GAAG,aAAa;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;CACzC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,sBAAsB,CAMzE"}
@@ -187,6 +187,24 @@ exports.FluidClientVersion = {
187
187
  * - ModularChangeFormatVersion.v5 - written when minVersionForCollab \>= 2.80
188
188
  */
189
189
  v2_80: "2.80.0",
190
+ /**
191
+ * Fluid Framework Client 2.117 and newer.
192
+ * @remarks
193
+ * New formats introduced in 2.117:
194
+ * - MessageFormatVersion.v7 - written when minVersionForCollab \>= 2.117
195
+ * - EditManagerFormatVersion.v7 - written when minVersionForCollab \>= 2.117
196
+ *
197
+ * @privateRemarks
198
+ * These formats are gated at 2.117.0 rather than 3.0.0 so that they can also be carried by a
199
+ * 2.117.0 minor cut from the last pre-3.0 commit on main, should one be needed for consumers
200
+ * that cannot yet absorb the 3.0 breaking changes. Since 3.0.0 \> 2.117.0, 3.x clients select
201
+ * these formats for any minVersionForCollab at or above 2.117.0 whether or not that release
202
+ * ever ships.
203
+ *
204
+ * Every client at or above 2.117.0 must therefore be able to read and write these formats. A
205
+ * client that maps 2.117.0 to an older format would silently strip metadata when encoding.
206
+ */
207
+ v2_117: "2.117.0",
190
208
  };
191
209
  /**
192
210
  * An up to date version which includes all stable features.
@@ -1 +1 @@
1
- {"version":3,"file":"codec.js","sourceRo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n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { OldestSupportedClientVersion } from \"@fluidframework/runtime-definitions/internal\";\nimport { cleanedPackageVersion as runtimeUtilsCleanedPackageVersion } from \"@fluidframework/runtime-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * Returns whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * A kind of validator for SharedTree's internal data formats.\n * @remarks\n * Assuming no data corruption or type confusion, such validation should never fail.\n * Any client version compatibility issues should instead be detected by the data format versioning which Shared Tree does internally independent of data format validation.\n * However, persisted data can sometimes be corrupted, bugs can produce invalid data, or users can mix up which data is compatible with which APIs.\n * In such cases, a format validator can help catch issues.\n *\n * Current options are {@link FormatValidatorNoOp} and {@link FormatValidatorBasic}.\n * @privateRemarks\n * Implement using {@link toFormatValidator}.\n * Consume using {@link extractJsonValidator}.\n *\n * Exposing this as the stable API entry point (instead of {@link JsonValidator}) means that we avoid leaking the reference to TypeBox to the API surface.\n * Additionally, if we adopt non JSON formats, we can just update the validators as needed without breaking the API.\n * This also allows us to avoid stabilizing or documenting how handles interact with JSON validation since that is not exposed through this type.\n * @sealed @alpha\n */\nexport interface FormatValidator extends ErasedType<\"FormatValidator\"> {}\n\n/**\n * A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.\n * @privateRemarks Having this as an option unifies opting out of validation with selection of\n * validators, simplifying code performing validation.\n */\nconst noopValidator: JsonValidator = {\n\tcompile: <Schema extends TSchema>() => ({ check: (data): data is Static<Schema> => true }),\n};\n\n/**\n * A {@link FormatValidator} which does no validation.\n * @alpha\n */\nexport const FormatValidatorNoOp = toFormatValidator(noopValidator);\n\n/**\n * Type erase a {@link JsonValidator} to a {@link FormatValidator}.\n */\nexport function toFormatValidator(factory: JsonValidator): FormatValidator {\n\treturn factory as unknown as FormatValidator;\n}\n\n/**\n * Un-type-erase the {@link FormatValidator}.\n */\nexport function extractJsonValidator(input: FormatValidator | JsonValidator): JsonValidator {\n\treturn input as unknown as JsonValidator;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @alpha @input\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n *\n * @see {@link CodecWriteOptions} for options that are specific to encoding data.\n * @alpha @input\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link FormatValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t * @remarks\n\t * See {@link FormatValidatorNoOp} and {@link FormatValidatorBasic} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `FormatValidatorNoOp`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t * @privateRemarks\n\t * This property should probably be renamed to `validator` before stabilizing the API.\n\t */\n\treadonly jsonValidator: FormatValidator;\n}\n\n/**\n * Options relating to encoding of persisted data.\n * @input @beta\n */\nexport interface CodecWriteOptionsBeta {\n\t/**\n\t * The minimum version of the Fluid Framework client output must be encoded to be compatible with.\n\t * @remarks\n\t * This is used to ensure that the the output from this codec can be used with older versions of the Fluid Framework client.\n\t * This includes both concurrent collaboration, and an older version opening the document later.\n\t *\n\t * Note that versions older than this should not result in data corruption if they access the data:\n\t * the data's format should be versioned and if they can't handle the format they should error.\n\t */\n\treadonly minVersionForCollab: OldestSupportedClientVersion;\n}\n\n/**\n * Options relating to encoding of persisted data.\n * @remarks\n * Extends {@link ICodecOptions} with options that are specific to encoding data.\n * @alpha @input\n */\nexport interface CodecWriteOptions extends ICodecOptions, CodecWriteOptionsBeta {\n\t/**\n\t * Overrides the version of the codec to use for encoding.\n\t * @remarks\n\t * Without an override, the selected version will be based on {@link CodecWriteOptionsBeta.minVersionForCollab}.\n\t */\n\treadonly writeVersionOverrides?: ReadonlyMap<CodecName, FormatVersion>;\n\n\t/**\n\t * If true, suppress errors when `writeVersionOverrides` selects a version which may not be compatible with the {@link CodecWriteOptionsBeta.minVersionForCollab}.\n\t */\n\treadonly allowPossiblyIncompatibleWriteVersionOverrides?: boolean;\n}\n\n/**\n * `TEncodeContext` and `TDecodeContext` allow passing context to the codec which may configure how data is encoded/decoded.\n * `TDecodeContext` defaults to `TEncodeContext`; specify them separately when encode and decode need different context (for example, when encoding uses heuristics that are unneeded when decoding).\n * These parameters are typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of {@link https://en.wikipedia.org/wiki/Dictionary_coder | dictionary coding}\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n> extends IEncoder<TDecoded, TEncoded, TEncodeContext>,\n\t\tIDecoder<TDecoded, TValidate, TDecodeContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * Part of a codec.\n * @remarks\n * Encode and decode logic and schema for some chunk of data.\n * Can be composed into larger codecs, and eventually versioned at the top level using\n * {@link VersionDispatchingCodecBuilder}.\n *\n * This portion of a codec is not responsible for managing versioning or validation of the data against the schema.\n */\nexport interface JsonCodecPart<\n\tTDecoded,\n\tTEncodedSchema extends TAnySchema,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n> extends IEncoder<TDecoded, Static<TEncodedSchema>, TEncodeContext>,\n\t\tIDecoder<TDecoded, Static<TEncodedSchema>, TDecodeContext> {\n\t/**\n\t * TypeBox schema which describes the encoded format for this chunk of data.\n\t * @remarks\n\t * The user of this codec can use this to build its own larger schema,\n\t * until eventually it is provided to the {@link VersionDispatchingCodecBuilder}.\n\t */\n\tencodedSchema: TEncodedSchema;\n}\n\n/**\n * Type erase the more detailed encoded type from a codec.\n */\nexport function eraseEncodedType<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n>(\n\tcodec: IJsonCodec<TDecoded, TEncoded, TValidate, TEncodeContext, TDecodeContext>,\n): IJsonCodec<TDecoded, TValidate, TValidate, TEncodeContext, TDecodeContext> {\n\treturn codec as unknown as IJsonCodec<\n\t\tTDecoded,\n\t\tTValidate,\n\t\tTValidate,\n\t\tTEncodeContext,\n\t\tTDecodeContext\n\t>;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks\n * Encode and decode can be parameterized independently — the encode-side context type need not equal the decode-side context type.\n * `TDecodeContext` defaults to `TEncodeContext` so callers that share a single context shape (the common case) don't need to specify it.\n */\nexport interface ICodecFamily<\n\tTDecoded,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IJsonCodec<\n\t\tTDecoded,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tTEncodeContext,\n\t\tTDecodeContext\n\t>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n * @remarks\n * Strings are used for formats that are not yet officially supported.\n * When such formats become officially supported/stable, they will be switched to using a number.\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n * @alpha\n */\nexport type FormatVersion = number | string | undefined;\n\n/**\n * A unique name given to this codec family.\n * @remarks\n * This is not persisted: it is only used to specify version overrides and in errors.\n * @alpha\n */\nexport type CodecName = string;\n\n/**\n * A format version which is dependent on some parent format version.\n */\nexport interface DependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> {\n\t/**\n\t * Looks up the child format version for a given parent format version.\n\t * @param parent - The parent format version.\n\t * @returns The corresponding child format version.\n\t */\n\tlookup(parent: TParentVersion): TChildVersion;\n}\n\nexport class UniqueDependentFormatVersion<TChildVersion extends FormatVersion>\n\timplements DependentFormatVersion<FormatVersion, TChildVersion>\n{\n\tpublic constructor(private readonly child: TChildVersion) {}\n\tpublic lookup(_parent: FormatVersion): TChildVersion {\n\t\treturn this.child;\n\t}\n}\n\nexport class MappedDependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> implements DependentFormatVersion<TParentVersion, TChildVersion>\n{\n\tpublic constructor(private readonly map: ReadonlyMap<TParentVersion, TChildVersion>) {}\n\tpublic lookup(parent: TParentVersion): TChildVersion {\n\t\treturn this.map.get(parent) ?? fail(0xc73 /* Unknown parent version */);\n\t}\n}\n\nexport const DependentFormatVersion = {\n\tfromUnique: <TChildVersion extends FormatVersion>(\n\t\tchild: TChildVersion,\n\t): UniqueDependentFormatVersion<TChildVersion> => new UniqueDependentFormatVersion(child),\n\tfromMap: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tmap: ReadonlyMap<TParentVersion, TChildVersion>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(map),\n\tfromPairs: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tpairs: Iterable<[TParentVersion, TChildVersion]>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(new Map(pairs)),\n};\n\n/**\n * Creates a codec family from a registry of codecs.\n */\nexport function makeCodecFamily<TDecoded, TEncodeContext, TDecodeContext = TEncodeContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec: IJsonCodec<\n\t\t\t\tTDecoded,\n\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\tTEncodeContext,\n\t\t\t\tTDecodeContext\n\t\t\t>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TEncodeContext, TDecodeContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIJsonCodec<\n\t\t\tTDecoded,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tTEncodeContext,\n\t\t\tTDecodeContext\n\t\t>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(0xabf /* Duplicate codecs specified. */);\n\t\t}\n\t\tcodecs.set(formatVersion, codec);\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: FormatVersion,\n\t\t): IJsonCodec<\n\t\t\tTDecoded,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tTEncodeContext,\n\t\t\tTDecodeContext\n\t\t> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested codec for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IJsonCodec<\n\t0,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tunknown\n> = {\n\tencode: () => 0,\n\tdecode: () => 0,\n};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n * @remarks\n * Eventually all codecs should use the same pattern implemented by VersionDispatchingCodecBuilder, resulting in that having the only use of this API.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat,\n\tTValidate,\n\tTEncodeContext,\n\tTDecodeContext = TEncodeContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<\n\t\tTInMemoryFormat,\n\t\tTEncodedFormat,\n\t\tTValidate,\n\t\tTEncodeContext,\n\t\tTDecodeContext\n\t>,\n\tvalidator?: JsonValidator | FormatValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TEncodeContext, TDecodeContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = extractJsonValidator(validator).compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TEncodeContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac0 /* Encoded data should validate */);\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TDecodeContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac1 /* Data being decoded should validate */);\n\t\t\t}\n\t\t\treturn codec.decode(encoded, context);\n\t\t},\n\t\tencodedSchema: schema,\n\t};\n}\n\n/**\n * Versions of Fluid Framework client packages, usable as a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.\n * @remarks\n * Versions with no notable impact may be omitted, and added later if needed.\n *\n * @privateRemarks\n * Each entry should document:\n * - The user-facing impact of opting into it (e.g. encoding efficiency improvements).\n * - Any new data formats introduced in that version.\n * - Whether those features/formats are enabled by default or require {@link OldestSupportedClientVersion | minVersionForCollab} to be set accordingly.\n * @alpha\n */\nexport const FluidClientVersion = {\n\t/**\n\t * Fluid Framework Client 2.0 and newer.\n\t */\n\tv2_0: \"2.0.0\",\n\n\t/**\n\t * Fluid Framework Client 2.43 and newer.\n\t * @remarks\n\t * New formats introduced in 2.43:\n\t * - SchemaFormatVersion.v2 - written when minVersionForCollab \\>= 2.43\n\t * - MessageFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - EditManagerFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - sequence-field/formatV3 - written when minVersionForCollab \\>= 2.43\n\t */\n\tv2_43: \"2.43.0\",\n\n\t/**\n\t * Fluid Framework Client 2.52 and newer.\n\t * @remarks\n\t * New formats introduced in 2.52:\n\t * - DetachedFieldIndexFormatVersion.v2 - written when minVersionForCollab \\>= 2.52\n\t */\n\tv2_52: \"2.52.0\",\n\n\t/**\n\t * Fluid Framework Client 2.73 and newer.\n\t * @remarks\n\t * New formats introduced in 2.73:\n\t * - FieldBatchFormatVersion.v2 - written when minVersionForCollab \\>= 2.73\n\t */\n\tv2_73: \"2.73.0\",\n\n\t/**\n\t * Fluid Framework Client 2.74 and newer.\n\t * @remarks\n\t * New formats introduced in 2.74:\n\t * - SharedTreeSummaryFormatVersion.v2 - written by default\n\t * - DetachedFieldIndexSummaryFormatVersion.v2 - written by default\n\t * - SchemaSummaryFormatVersion.v2 - written by default\n\t * - EditManagerSummaryFormatVersion.v2 - written by default\n\t * - ForestSummaryFormatVersion.v2 - written by default\n\t * - ForestFormatVersion.v2 - written when minVersionForCollab \\>= 2.74\n\t * - ForestSummaryFormatVersion.v3 - written when minVersionForCollab \\>= 2.74\n\t */\n\tv2_74: \"2.74.0\",\n\n\t/**\n\t * Fluid Framework Client 2.80 and newer.\n\t * @remarks\n\t * New formats introduced in 2.80:\n\t * - MessageFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - EditManagerFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - SharedTreeChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t * - ModularChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t */\n\tv2_80: \"2.80.0\",\n} as const satisfies Record<string, OldestSupportedClientVersion>;\n\n/**\n * An up to date version which includes all stable features.\n * @remarks\n * Use for cases when data is not persisted and thus would only ever be read by the the same version of the code which read this value.\n *\n * The pkgVersion from this package (tree) can not be used here as it is not guaranteed to be a valid OldestSupportedClientVersion\n * and would also unexpectedly disable features in prereleases and on CI if it didn't fail validation.\n * See {@link @fluidframework/runtime-utils/internal#cleanedPackageVersion} for more details on why cleanedPackageVersion is preferred over pkgVersion.\n *\n * @privateRemarks\n * It is safe to use CleanedPackageVersion from runtime-utils here since features are enabled in minor versions,\n * and this package (tree) depends on runtime-utils with a `~` semver range\n * ensuring that the version of runtime-utils this was imported from will match the version of this (tree) package at least up to the minor version.\n * Reusing this from runtime-utils avoids duplicating the cleanup logic here as well as the cost or recomputing it.\n * If in the future for some reason this becomes not okay, runtime-utils could instead export a function that performs that cleanup logic which could be reused here.\n */\nexport const currentVersion: OldestSupportedClientVersion = runtimeUtilsCleanedPackageVersion;\n\n/**\n * TODO:\n * This needs to be documented.\n * Its documentation should cover at least the following:\n * - Is this used for anything other than testing.\n * - What should be included as children. For example should it include versioned codecs which dispatch base on the min version for collaboration? If so, what version of them should be used?\n * - What risks does having this mitigate?\n */\nexport interface CodecTree<TFormatVersion extends FormatVersion = FormatVersion> {\n\treadonly name: string;\n\treadonly version: TFormatVersion;\n\treadonly children?: readonly CodecTree[];\n}\n\nexport function jsonableCodecTree(tree: CodecTree): JsonCompatibleReadOnly {\n\treturn {\n\t\tname: tree.name,\n\t\tversion: tree.version ?? \"null\",\n\t\tchildren: tree.children?.map(jsonableCodecTree),\n\t};\n}\n"]}
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAAmE;AAEnE,qEAAoH;AA0DpH;;;;GAIG;AACH,MAAM,aAAa,GAAkB;IACpC,OAAO,EAAE,GAA2B,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAA0B,EAAE,CAAC,IAAI,EAAE,CAAC;CAC1F,CAAC;AAEF;;;GAGG;AACU,QAAA,mBAAmB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAEpE;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OAAsB;IACvD,OAAO,OAAqC,CAAC;AAC9C,CAAC;AAFD,8CAEC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAsC;IAC1E,OAAO,KAAiC,CAAC;AAC1C,CAAC;AAFD,oDAEC;AA0ID;;GAEG;AACH,SAAgB,gBAAgB,CAO/B,KAAgF;IAEhF,OAAO,KAMN,CAAC;AACH,CAAC;AAhBD,4CAgBC;AA4ED,MAAa,4BAA4B;IAGxC,YAAoC,KAAoB;QAApB,UAAK,GAAL,KAAK,CAAe;IAAG,CAAC;IACrD,MAAM,CAAC,OAAsB;QACnC,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD;AAPD,oEAOC;AAED,MAAa,4BAA4B;IAKxC,YAAoC,GAA+C;QAA/C,QAAG,GAAH,GAAG,CAA4C;IAAG,CAAC;IAChF,MAAM,CAAC,MAAsB;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACzE,CAAC;CACD;AATD,oEASC;AAEY,QAAA,sBAAsB,GAAG;IACrC,UAAU,EAAE,CACX,KAAoB,EAC0B,EAAE,CAAC,IAAI,4BAA4B,CAAC,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IAAI,MAAM;QAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,iBAAiB,CAAC;KAC/C,CAAC;AACH,CAAC;AAND,8CAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { OldestSupportedClientVersion } from \"@fluidframework/runtime-definitions/internal\";\nimport { cleanedPackageVersion as runtimeUtilsCleanedPackageVersion } from \"@fluidframework/runtime-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * Returns whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * A kind of validator for SharedTree's internal data formats.\n * @remarks\n * Assuming no data corruption or type confusion, such validation should never fail.\n * Any client version compatibility issues should instead be detected by the data format versioning which Shared Tree does internally independent of data format validation.\n * However, persisted data can sometimes be corrupted, bugs can produce invalid data, or users can mix up which data is compatible with which APIs.\n * In such cases, a format validator can help catch issues.\n *\n * Current options are {@link FormatValidatorNoOp} and {@link FormatValidatorBasic}.\n * @privateRemarks\n * Implement using {@link toFormatValidator}.\n * Consume using {@link extractJsonValidator}.\n *\n * Exposing this as the stable API entry point (instead of {@link JsonValidator}) means that we avoid leaking the reference to TypeBox to the API surface.\n * Additionally, if we adopt non JSON formats, we can just update the validators as needed without breaking the API.\n * This also allows us to avoid stabilizing or documenting how handles interact with JSON validation since that is not exposed through this type.\n * @sealed @alpha\n */\nexport interface FormatValidator extends ErasedType<\"FormatValidator\"> {}\n\n/**\n * A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.\n * @privateRemarks Having this as an option unifies opting out of validation with selection of\n * validators, simplifying code performing validation.\n */\nconst noopValidator: JsonValidator = {\n\tcompile: <Schema extends TSchema>() => ({ check: (data): data is Static<Schema> => true }),\n};\n\n/**\n * A {@link FormatValidator} which does no validation.\n * @alpha\n */\nexport const FormatValidatorNoOp = toFormatValidator(noopValidator);\n\n/**\n * Type erase a {@link JsonValidator} to a {@link FormatValidator}.\n */\nexport function toFormatValidator(factory: JsonValidator): FormatValidator {\n\treturn factory as unknown as FormatValidator;\n}\n\n/**\n * Un-type-erase the {@link FormatValidator}.\n */\nexport function extractJsonValidator(input: FormatValidator | JsonValidator): JsonValidator {\n\treturn input as unknown as JsonValidator;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @alpha @input\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n *\n * @see {@link CodecWriteOptions} for options that are specific to encoding data.\n * @alpha @input\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link FormatValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t * @remarks\n\t * See {@link FormatValidatorNoOp} and {@link FormatValidatorBasic} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `FormatValidatorNoOp`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t * @privateRemarks\n\t * This property should probably be renamed to `validator` before stabilizing the API.\n\t */\n\treadonly jsonValidator: FormatValidator;\n}\n\n/**\n * Options relating to encoding of persisted data.\n * @input @beta\n */\nexport interface CodecWriteOptionsBeta {\n\t/**\n\t * The minimum version of the Fluid Framework client output must be encoded to be compatible with.\n\t * @remarks\n\t * This is used to ensure that the the output from this codec can be used with older versions of the Fluid Framework client.\n\t * This includes both concurrent collaboration, and an older version opening the document later.\n\t *\n\t * Note that versions older than this should not result in data corruption if they access the data:\n\t * the data's format should be versioned and if they can't handle the format they should error.\n\t */\n\treadonly minVersionForCollab: OldestSupportedClientVersion;\n}\n\n/**\n * Options relating to encoding of persisted data.\n * @remarks\n * Extends {@link ICodecOptions} with options that are specific to encoding data.\n * @alpha @input\n */\nexport interface CodecWriteOptions extends ICodecOptions, CodecWriteOptionsBeta {\n\t/**\n\t * Overrides the version of the codec to use for encoding.\n\t * @remarks\n\t * Without an override, the selected version will be based on {@link CodecWriteOptionsBeta.minVersionForCollab}.\n\t */\n\treadonly writeVersionOverrides?: ReadonlyMap<CodecName, FormatVersion>;\n\n\t/**\n\t * If true, suppress errors when `writeVersionOverrides` selects a version which may not be compatible with the {@link CodecWriteOptionsBeta.minVersionForCollab}.\n\t */\n\treadonly allowPossiblyIncompatibleWriteVersionOverrides?: boolean;\n}\n\n/**\n * `TEncodeContext` and `TDecodeContext` allow passing context to the codec which may configure how data is encoded/decoded.\n * `TDecodeContext` defaults to `TEncodeContext`; specify them separately when encode and decode need different context (for example, when encoding uses heuristics that are unneeded when decoding).\n * These parameters are typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of {@link https://en.wikipedia.org/wiki/Dictionary_coder | dictionary coding}\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n> extends IEncoder<TDecoded, TEncoded, TEncodeContext>,\n\t\tIDecoder<TDecoded, TValidate, TDecodeContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * Part of a codec.\n * @remarks\n * Encode and decode logic and schema for some chunk of data.\n * Can be composed into larger codecs, and eventually versioned at the top level using\n * {@link VersionDispatchingCodecBuilder}.\n *\n * This portion of a codec is not responsible for managing versioning or validation of the data against the schema.\n */\nexport interface JsonCodecPart<\n\tTDecoded,\n\tTEncodedSchema extends TAnySchema,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n> extends IEncoder<TDecoded, Static<TEncodedSchema>, TEncodeContext>,\n\t\tIDecoder<TDecoded, Static<TEncodedSchema>, TDecodeContext> {\n\t/**\n\t * TypeBox schema which describes the encoded format for this chunk of data.\n\t * @remarks\n\t * The user of this codec can use this to build its own larger schema,\n\t * until eventually it is provided to the {@link VersionDispatchingCodecBuilder}.\n\t */\n\tencodedSchema: TEncodedSchema;\n}\n\n/**\n * Type erase the more detailed encoded type from a codec.\n */\nexport function eraseEncodedType<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n>(\n\tcodec: IJsonCodec<TDecoded, TEncoded, TValidate, TEncodeContext, TDecodeContext>,\n): IJsonCodec<TDecoded, TValidate, TValidate, TEncodeContext, TDecodeContext> {\n\treturn codec as unknown as IJsonCodec<\n\t\tTDecoded,\n\t\tTValidate,\n\t\tTValidate,\n\t\tTEncodeContext,\n\t\tTDecodeContext\n\t>;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks\n * Encode and decode can be parameterized independently — the encode-side context type need not equal the decode-side context type.\n * `TDecodeContext` defaults to `TEncodeContext` so callers that share a single context shape (the common case) don't need to specify it.\n */\nexport interface ICodecFamily<\n\tTDecoded,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IJsonCodec<\n\t\tTDecoded,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tTEncodeContext,\n\t\tTDecodeContext\n\t>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n * @remarks\n * Strings are used for formats that are not yet officially supported.\n * When such formats become officially supported/stable, they will be switched to using a number.\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n * @alpha\n */\nexport type FormatVersion = number | string | undefined;\n\n/**\n * A unique name given to this codec family.\n * @remarks\n * This is not persisted: it is only used to specify version overrides and in errors.\n * @alpha\n */\nexport type CodecName = string;\n\n/**\n * A format version which is dependent on some parent format version.\n */\nexport interface DependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> {\n\t/**\n\t * Looks up the child format version for a given parent format version.\n\t * @param parent - The parent format version.\n\t * @returns The corresponding child format version.\n\t */\n\tlookup(parent: TParentVersion): TChildVersion;\n}\n\nexport class UniqueDependentFormatVersion<TChildVersion extends FormatVersion>\n\timplements DependentFormatVersion<FormatVersion, TChildVersion>\n{\n\tpublic constructor(private readonly child: TChildVersion) {}\n\tpublic lookup(_parent: FormatVersion): TChildVersion {\n\t\treturn this.child;\n\t}\n}\n\nexport class MappedDependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> implements DependentFormatVersion<TParentVersion, TChildVersion>\n{\n\tpublic constructor(private readonly map: ReadonlyMap<TParentVersion, TChildVersion>) {}\n\tpublic lookup(parent: TParentVersion): TChildVersion {\n\t\treturn this.map.get(parent) ?? fail(0xc73 /* Unknown parent version */);\n\t}\n}\n\nexport const DependentFormatVersion = {\n\tfromUnique: <TChildVersion extends FormatVersion>(\n\t\tchild: TChildVersion,\n\t): UniqueDependentFormatVersion<TChildVersion> => new UniqueDependentFormatVersion(child),\n\tfromMap: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tmap: ReadonlyMap<TParentVersion, TChildVersion>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(map),\n\tfromPairs: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tpairs: Iterable<[TParentVersion, TChildVersion]>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(new Map(pairs)),\n};\n\n/**\n * Creates a codec family from a registry of codecs.\n */\nexport function makeCodecFamily<TDecoded, TEncodeContext, TDecodeContext = TEncodeContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec: IJsonCodec<\n\t\t\t\tTDecoded,\n\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\tTEncodeContext,\n\t\t\t\tTDecodeContext\n\t\t\t>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TEncodeContext, TDecodeContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIJsonCodec<\n\t\t\tTDecoded,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tTEncodeContext,\n\t\t\tTDecodeContext\n\t\t>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(0xabf /* Duplicate codecs specified. */);\n\t\t}\n\t\tcodecs.set(formatVersion, codec);\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: FormatVersion,\n\t\t): IJsonCodec<\n\t\t\tTDecoded,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tTEncodeContext,\n\t\t\tTDecodeContext\n\t\t> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested codec for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IJsonCodec<\n\t0,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tunknown\n> = {\n\tencode: () => 0,\n\tdecode: () => 0,\n};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n * @remarks\n * Eventually all codecs should use the same pattern implemented by VersionDispatchingCodecBuilder, resulting in that having the only use of this API.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat,\n\tTValidate,\n\tTEncodeContext,\n\tTDecodeContext = TEncodeContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<\n\t\tTInMemoryFormat,\n\t\tTEncodedFormat,\n\t\tTValidate,\n\t\tTEncodeContext,\n\t\tTDecodeContext\n\t>,\n\tvalidator?: JsonValidator | FormatValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TEncodeContext, TDecodeContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = extractJsonValidator(validator).compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TEncodeContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac0 /* Encoded data should validate */);\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TDecodeContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac1 /* Data being decoded should validate */);\n\t\t\t}\n\t\t\treturn codec.decode(encoded, context);\n\t\t},\n\t\tencodedSchema: schema,\n\t};\n}\n\n/**\n * Versions of Fluid Framework client packages, usable as a {@link @fluidframework/runtime-definitions#OldestSupportedClientVersion}.\n * @remarks\n * Versions with no notable impact may be omitted, and added later if needed.\n *\n * @privateRemarks\n * Each entry should document:\n * - The user-facing impact of opting into it (e.g. encoding efficiency improvements).\n * - Any new data formats introduced in that version.\n * - Whether those features/formats are enabled by default or require {@link OldestSupportedClientVersion | minVersionForCollab} to be set accordingly.\n * @alpha\n */\nexport const FluidClientVersion = {\n\t/**\n\t * Fluid Framework Client 2.0 and newer.\n\t */\n\tv2_0: \"2.0.0\",\n\n\t/**\n\t * Fluid Framework Client 2.43 and newer.\n\t * @remarks\n\t * New formats introduced in 2.43:\n\t * - SchemaFormatVersion.v2 - written when minVersionForCollab \\>= 2.43\n\t * - MessageFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - EditManagerFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - sequence-field/formatV3 - written when minVersionForCollab \\>= 2.43\n\t */\n\tv2_43: \"2.43.0\",\n\n\t/**\n\t * Fluid Framework Client 2.52 and newer.\n\t * @remarks\n\t * New formats introduced in 2.52:\n\t * - DetachedFieldIndexFormatVersion.v2 - written when minVersionForCollab \\>= 2.52\n\t */\n\tv2_52: \"2.52.0\",\n\n\t/**\n\t * Fluid Framework Client 2.73 and newer.\n\t * @remarks\n\t * New formats introduced in 2.73:\n\t * - FieldBatchFormatVersion.v2 - written when minVersionForCollab \\>= 2.73\n\t */\n\tv2_73: \"2.73.0\",\n\n\t/**\n\t * Fluid Framework Client 2.74 and newer.\n\t * @remarks\n\t * New formats introduced in 2.74:\n\t * - SharedTreeSummaryFormatVersion.v2 - written by default\n\t * - DetachedFieldIndexSummaryFormatVersion.v2 - written by default\n\t * - SchemaSummaryFormatVersion.v2 - written by default\n\t * - EditManagerSummaryFormatVersion.v2 - written by default\n\t * - ForestSummaryFormatVersion.v2 - written by default\n\t * - ForestFormatVersion.v2 - written when minVersionForCollab \\>= 2.74\n\t * - ForestSummaryFormatVersion.v3 - written when minVersionForCollab \\>= 2.74\n\t */\n\tv2_74: \"2.74.0\",\n\n\t/**\n\t * Fluid Framework Client 2.80 and newer.\n\t * @remarks\n\t * New formats introduced in 2.80:\n\t * - MessageFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - EditManagerFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - SharedTreeChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t * - ModularChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t */\n\tv2_80: \"2.80.0\",\n\n\t/**\n\t * Fluid Framework Client 2.117 and newer.\n\t * @remarks\n\t * New formats introduced in 2.117:\n\t * - MessageFormatVersion.v7 - written when minVersionForCollab \\>= 2.117\n\t * - EditManagerFormatVersion.v7 - written when minVersionForCollab \\>= 2.117\n\t *\n\t * @privateRemarks\n\t * These formats are gated at 2.117.0 rather than 3.0.0 so that they can also be carried by a\n\t * 2.117.0 minor cut from the last pre-3.0 commit on main, should one be needed for consumers\n\t * that cannot yet absorb the 3.0 breaking changes. Since 3.0.0 \\> 2.117.0, 3.x clients select\n\t * these formats for any minVersionForCollab at or above 2.117.0 whether or not that release\n\t * ever ships.\n\t *\n\t * Every client at or above 2.117.0 must therefore be able to read and write these formats. A\n\t * client that maps 2.117.0 to an older format would silently strip metadata when encoding.\n\t */\n\tv2_117: \"2.117.0\",\n} as const satisfies Record<string, OldestSupportedClientVersion>;\n\n/**\n * An up to date version which includes all stable features.\n * @remarks\n * Use for cases when data is not persisted and thus would only ever be read by the the same version of the code which read this value.\n *\n * The pkgVersion from this package (tree) can not be used here as it is not guaranteed to be a valid OldestSupportedClientVersion\n * and would also unexpectedly disable features in prereleases and on CI if it didn't fail validation.\n * See {@link @fluidframework/runtime-utils/internal#cleanedPackageVersion} for more details on why cleanedPackageVersion is preferred over pkgVersion.\n *\n * @privateRemarks\n * It is safe to use CleanedPackageVersion from runtime-utils here since features are enabled in minor versions,\n * and this package (tree) depends on runtime-utils with a `~` semver range\n * ensuring that the version of runtime-utils this was imported from will match the version of this (tree) package at least up to the minor version.\n * Reusing this from runtime-utils avoids duplicating the cleanup logic here as well as the cost or recomputing it.\n * If in the future for some reason this becomes not okay, runtime-utils could instead export a function that performs that cleanup logic which could be reused here.\n */\nexport const currentVersion: OldestSupportedClientVersion = runtimeUtilsCleanedPackageVersion;\n\n/**\n * TODO:\n * This needs to be documented.\n * Its documentation should cover at least the following:\n * - Is this used for anything other than testing.\n * - What should be included as children. For example should it include versioned codecs which dispatch base on the min version for collaboration? If so, what version of them should be used?\n * - What risks does having this mitigate?\n */\nexport interface CodecTree<TFormatVersion extends FormatVersion = FormatVersion> {\n\treadonly name: string;\n\treadonly version: TFormatVersion;\n\treadonly children?: readonly CodecTree[];\n}\n\nexport function jsonableCodecTree(tree: CodecTree): JsonCompatibleReadOnly {\n\treturn {\n\t\tname: tree.name,\n\t\tversion: tree.version ?? \"null\",\n\t\tchildren: tree.children?.map(jsonableCodecTree),\n\t};\n}\n"]}