@fluidframework/tree 2.116.1 → 2.118.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 (421) hide show
  1. package/CHANGELOG.md +202 -0
  2. package/api-report/tree.alpha.api.md +122 -31
  3. package/api-report/tree.beta.api.md +50 -9
  4. package/api-report/tree.legacy.beta.api.md +50 -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/index.d.ts +1 -1
  37. package/dist/feature-libraries/index.js.map +1 -1
  38. package/dist/feature-libraries/indexing/types.d.ts +1 -1
  39. package/dist/feature-libraries/indexing/types.js.map +1 -1
  40. package/dist/feature-libraries/schemaChecker.d.ts +9 -19
  41. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
  42. package/dist/feature-libraries/schemaChecker.js +130 -46
  43. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  44. package/dist/index.d.ts +2 -2
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/packageVersion.d.ts +1 -1
  48. package/dist/packageVersion.js +1 -1
  49. package/dist/packageVersion.js.map +1 -1
  50. package/dist/shared-tree/history.d.ts +22 -0
  51. package/dist/shared-tree/history.d.ts.map +1 -0
  52. package/dist/shared-tree/history.js +66 -0
  53. package/dist/shared-tree/history.js.map +1 -0
  54. package/dist/shared-tree/schematizingTreeView.d.ts +24 -9
  55. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  56. package/dist/shared-tree/schematizingTreeView.js +61 -11
  57. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  58. package/dist/shared-tree/sharedTree.d.ts +3 -2
  59. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  60. package/dist/shared-tree/sharedTree.js +2 -0
  61. package/dist/shared-tree/sharedTree.js.map +1 -1
  62. package/dist/shared-tree/tree.js +1 -1
  63. package/dist/shared-tree/tree.js.map +1 -1
  64. package/dist/shared-tree/treeAlpha.d.ts +8 -20
  65. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  66. package/dist/shared-tree/treeAlpha.js +9 -12
  67. package/dist/shared-tree/treeAlpha.js.map +1 -1
  68. package/dist/shared-tree/treeCheckout.d.ts +16 -9
  69. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  70. package/dist/shared-tree/treeCheckout.js +122 -25
  71. package/dist/shared-tree/treeCheckout.js.map +1 -1
  72. package/dist/shared-tree/unhydratedTreeContext.d.ts +3 -2
  73. package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  74. package/dist/shared-tree/unhydratedTreeContext.js +3 -0
  75. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  76. package/dist/shared-tree-core/branch.d.ts +16 -2
  77. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  78. package/dist/shared-tree-core/branch.js +20 -2
  79. package/dist/shared-tree-core/branch.js.map +1 -1
  80. package/dist/shared-tree-core/branchCommitCounter.d.ts +31 -0
  81. package/dist/shared-tree-core/branchCommitCounter.d.ts.map +1 -0
  82. package/dist/shared-tree-core/branchCommitCounter.js +79 -0
  83. package/dist/shared-tree-core/branchCommitCounter.js.map +1 -0
  84. package/dist/shared-tree-core/customMetadataCodec.d.ts +9 -0
  85. package/dist/shared-tree-core/customMetadataCodec.d.ts.map +1 -0
  86. package/dist/shared-tree-core/customMetadataCodec.js +37 -0
  87. package/dist/shared-tree-core/customMetadataCodec.js.map +1 -0
  88. package/dist/shared-tree-core/customMetadataFormat.d.ts +18 -0
  89. package/dist/shared-tree-core/customMetadataFormat.d.ts.map +1 -0
  90. package/dist/shared-tree-core/customMetadataFormat.js +15 -0
  91. package/dist/shared-tree-core/customMetadataFormat.js.map +1 -0
  92. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  93. package/dist/shared-tree-core/editManager.js +15 -3
  94. package/dist/shared-tree-core/editManager.js.map +1 -1
  95. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  96. package/dist/shared-tree-core/editManagerCodecs.js +5 -0
  97. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  98. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  99. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  100. package/dist/shared-tree-core/editManagerCodecsCommons.js +17 -5
  101. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  102. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  103. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +4 -2
  104. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  105. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  106. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
  107. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  108. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +17 -6
  109. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  110. package/dist/shared-tree-core/editManagerFormatCommons.js +18 -8
  111. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  112. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +7 -5
  113. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  114. package/dist/shared-tree-core/editManagerFormatV1toV4.js +4 -3
  115. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  116. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +4 -0
  117. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  118. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js +2 -2
  119. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
  120. package/dist/shared-tree-core/index.d.ts +2 -1
  121. package/dist/shared-tree-core/index.d.ts.map +1 -1
  122. package/dist/shared-tree-core/index.js +3 -1
  123. package/dist/shared-tree-core/index.js.map +1 -1
  124. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
  125. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  126. package/dist/shared-tree-core/messageCodecV1ToV4.js +12 -3
  127. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  128. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  129. package/dist/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  130. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  131. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  132. package/dist/shared-tree-core/messageCodecs.js +5 -0
  133. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  134. package/dist/shared-tree-core/messageFormat.d.ts +1 -0
  135. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  136. package/dist/shared-tree-core/messageFormat.js +6 -0
  137. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  138. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +10 -3
  139. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  140. package/dist/shared-tree-core/messageFormatV1ToV4.js +10 -2
  141. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  142. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -0
  143. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  144. package/dist/shared-tree-core/messageFormatVSharedBranches.js +2 -0
  145. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  146. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  147. package/dist/shared-tree-core/sharedTreeCore.js +4 -2
  148. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  149. package/dist/shared-tree-core/transaction.d.ts +9 -0
  150. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  151. package/dist/shared-tree-core/transaction.js +26 -4
  152. package/dist/shared-tree-core/transaction.js.map +1 -1
  153. package/dist/simple-tree/api/configuration.d.ts +4 -4
  154. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  155. package/dist/simple-tree/api/configuration.js.map +1 -1
  156. package/dist/simple-tree/api/discrepancies.d.ts +36 -3
  157. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
  158. package/dist/simple-tree/api/discrepancies.js +40 -14
  159. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  160. package/dist/simple-tree/api/index.d.ts +3 -2
  161. package/dist/simple-tree/api/index.d.ts.map +1 -1
  162. package/dist/simple-tree/api/index.js +3 -2
  163. package/dist/simple-tree/api/index.js.map +1 -1
  164. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +22 -3
  165. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  166. package/dist/simple-tree/api/schemaCompatibilityTester.js +140 -10
  167. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  168. package/dist/simple-tree/api/transactionTypes.d.ts +28 -2
  169. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  170. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  171. package/dist/simple-tree/api/tree.d.ts +353 -68
  172. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  173. package/dist/simple-tree/api/tree.js.map +1 -1
  174. package/dist/simple-tree/core/toStored.d.ts +7 -0
  175. package/dist/simple-tree/core/toStored.d.ts.map +1 -1
  176. package/dist/simple-tree/core/toStored.js.map +1 -1
  177. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  178. package/dist/simple-tree/core/treeNodeValid.js +2 -2
  179. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  180. package/dist/simple-tree/index.d.ts +1 -1
  181. package/dist/simple-tree/index.d.ts.map +1 -1
  182. package/dist/simple-tree/index.js +4 -3
  183. package/dist/simple-tree/index.js.map +1 -1
  184. package/dist/tableSchema.js +10 -10
  185. package/dist/tableSchema.js.map +1 -1
  186. package/docs/main/glossary.md +163 -0
  187. package/lib/codec/codec.d.ts +18 -0
  188. package/lib/codec/codec.d.ts.map +1 -1
  189. package/lib/codec/codec.js +18 -0
  190. package/lib/codec/codec.js.map +1 -1
  191. package/lib/core/index.d.ts +2 -2
  192. package/lib/core/index.d.ts.map +1 -1
  193. package/lib/core/index.js +1 -1
  194. package/lib/core/index.js.map +1 -1
  195. package/lib/core/rebase/index.d.ts +1 -1
  196. package/lib/core/rebase/index.d.ts.map +1 -1
  197. package/lib/core/rebase/index.js +1 -1
  198. package/lib/core/rebase/index.js.map +1 -1
  199. package/lib/core/rebase/types.d.ts +39 -2
  200. package/lib/core/rebase/types.d.ts.map +1 -1
  201. package/lib/core/rebase/types.js +35 -1
  202. package/lib/core/rebase/types.js.map +1 -1
  203. package/lib/core/rebase/utils.d.ts.map +1 -1
  204. package/lib/core/rebase/utils.js +1 -0
  205. package/lib/core/rebase/utils.js.map +1 -1
  206. package/lib/core/revertible.d.ts +62 -6
  207. package/lib/core/revertible.d.ts.map +1 -1
  208. package/lib/core/revertible.js.map +1 -1
  209. package/lib/entrypoints/alpha.d.ts +1 -1
  210. package/lib/entrypoints/alpha.d.ts.map +1 -1
  211. package/lib/entrypoints/alpha.js.map +1 -1
  212. package/lib/entrypoints/beta.d.ts +1 -1
  213. package/lib/entrypoints/beta.d.ts.map +1 -1
  214. package/lib/entrypoints/beta.js.map +1 -1
  215. package/lib/entrypoints/legacy.d.ts +1 -1
  216. package/lib/entrypoints/legacy.d.ts.map +1 -1
  217. package/lib/entrypoints/legacy.js.map +1 -1
  218. package/lib/feature-libraries/index.d.ts +1 -1
  219. package/lib/feature-libraries/index.js.map +1 -1
  220. package/lib/feature-libraries/indexing/types.d.ts +1 -1
  221. package/lib/feature-libraries/indexing/types.js.map +1 -1
  222. package/lib/feature-libraries/schemaChecker.d.ts +9 -19
  223. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
  224. package/lib/feature-libraries/schemaChecker.js +133 -49
  225. package/lib/feature-libraries/schemaChecker.js.map +1 -1
  226. package/lib/index.d.ts +2 -2
  227. package/lib/index.d.ts.map +1 -1
  228. package/lib/index.js.map +1 -1
  229. package/lib/packageVersion.d.ts +1 -1
  230. package/lib/packageVersion.js +1 -1
  231. package/lib/packageVersion.js.map +1 -1
  232. package/lib/shared-tree/history.d.ts +22 -0
  233. package/lib/shared-tree/history.d.ts.map +1 -0
  234. package/lib/shared-tree/history.js +62 -0
  235. package/lib/shared-tree/history.js.map +1 -0
  236. package/lib/shared-tree/schematizingTreeView.d.ts +24 -9
  237. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  238. package/lib/shared-tree/schematizingTreeView.js +62 -12
  239. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  240. package/lib/shared-tree/sharedTree.d.ts +3 -2
  241. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  242. package/lib/shared-tree/sharedTree.js +2 -0
  243. package/lib/shared-tree/sharedTree.js.map +1 -1
  244. package/lib/shared-tree/tree.js +1 -1
  245. package/lib/shared-tree/tree.js.map +1 -1
  246. package/lib/shared-tree/treeAlpha.d.ts +8 -20
  247. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  248. package/lib/shared-tree/treeAlpha.js +9 -12
  249. package/lib/shared-tree/treeAlpha.js.map +1 -1
  250. package/lib/shared-tree/treeCheckout.d.ts +16 -9
  251. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  252. package/lib/shared-tree/treeCheckout.js +123 -26
  253. package/lib/shared-tree/treeCheckout.js.map +1 -1
  254. package/lib/shared-tree/unhydratedTreeContext.d.ts +3 -2
  255. package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  256. package/lib/shared-tree/unhydratedTreeContext.js +3 -0
  257. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  258. package/lib/shared-tree-core/branch.d.ts +16 -2
  259. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  260. package/lib/shared-tree-core/branch.js +20 -2
  261. package/lib/shared-tree-core/branch.js.map +1 -1
  262. package/lib/shared-tree-core/branchCommitCounter.d.ts +31 -0
  263. package/lib/shared-tree-core/branchCommitCounter.d.ts.map +1 -0
  264. package/lib/shared-tree-core/branchCommitCounter.js +75 -0
  265. package/lib/shared-tree-core/branchCommitCounter.js.map +1 -0
  266. package/lib/shared-tree-core/customMetadataCodec.d.ts +9 -0
  267. package/lib/shared-tree-core/customMetadataCodec.d.ts.map +1 -0
  268. package/lib/shared-tree-core/customMetadataCodec.js +32 -0
  269. package/lib/shared-tree-core/customMetadataCodec.js.map +1 -0
  270. package/lib/shared-tree-core/customMetadataFormat.d.ts +18 -0
  271. package/lib/shared-tree-core/customMetadataFormat.d.ts.map +1 -0
  272. package/lib/shared-tree-core/customMetadataFormat.js +11 -0
  273. package/lib/shared-tree-core/customMetadataFormat.js.map +1 -0
  274. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  275. package/lib/shared-tree-core/editManager.js +16 -4
  276. package/lib/shared-tree-core/editManager.js.map +1 -1
  277. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  278. package/lib/shared-tree-core/editManagerCodecs.js +5 -0
  279. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  280. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  281. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  282. package/lib/shared-tree-core/editManagerCodecsCommons.js +17 -5
  283. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  284. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  285. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +4 -2
  286. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  287. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  288. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
  289. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  290. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +17 -6
  291. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  292. package/lib/shared-tree-core/editManagerFormatCommons.js +18 -8
  293. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  294. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +7 -5
  295. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  296. package/lib/shared-tree-core/editManagerFormatV1toV4.js +4 -3
  297. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  298. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +4 -0
  299. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  300. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js +2 -2
  301. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
  302. package/lib/shared-tree-core/index.d.ts +2 -1
  303. package/lib/shared-tree-core/index.d.ts.map +1 -1
  304. package/lib/shared-tree-core/index.js +1 -0
  305. package/lib/shared-tree-core/index.js.map +1 -1
  306. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
  307. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  308. package/lib/shared-tree-core/messageCodecV1ToV4.js +12 -3
  309. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  310. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  311. package/lib/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  312. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  313. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  314. package/lib/shared-tree-core/messageCodecs.js +5 -0
  315. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  316. package/lib/shared-tree-core/messageFormat.d.ts +1 -0
  317. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  318. package/lib/shared-tree-core/messageFormat.js +6 -0
  319. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  320. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +10 -3
  321. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  322. package/lib/shared-tree-core/messageFormatV1ToV4.js +10 -2
  323. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  324. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -0
  325. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  326. package/lib/shared-tree-core/messageFormatVSharedBranches.js +2 -0
  327. package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  328. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  329. package/lib/shared-tree-core/sharedTreeCore.js +5 -3
  330. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  331. package/lib/shared-tree-core/transaction.d.ts +9 -0
  332. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  333. package/lib/shared-tree-core/transaction.js +27 -5
  334. package/lib/shared-tree-core/transaction.js.map +1 -1
  335. package/lib/simple-tree/api/configuration.d.ts +4 -4
  336. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  337. package/lib/simple-tree/api/configuration.js.map +1 -1
  338. package/lib/simple-tree/api/discrepancies.d.ts +36 -3
  339. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
  340. package/lib/simple-tree/api/discrepancies.js +40 -14
  341. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  342. package/lib/simple-tree/api/index.d.ts +3 -2
  343. package/lib/simple-tree/api/index.d.ts.map +1 -1
  344. package/lib/simple-tree/api/index.js +1 -1
  345. package/lib/simple-tree/api/index.js.map +1 -1
  346. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +22 -3
  347. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  348. package/lib/simple-tree/api/schemaCompatibilityTester.js +136 -7
  349. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  350. package/lib/simple-tree/api/transactionTypes.d.ts +28 -2
  351. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  352. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  353. package/lib/simple-tree/api/tree.d.ts +353 -68
  354. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  355. package/lib/simple-tree/api/tree.js.map +1 -1
  356. package/lib/simple-tree/core/toStored.d.ts +7 -0
  357. package/lib/simple-tree/core/toStored.d.ts.map +1 -1
  358. package/lib/simple-tree/core/toStored.js.map +1 -1
  359. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  360. package/lib/simple-tree/core/treeNodeValid.js +3 -3
  361. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  362. package/lib/simple-tree/index.d.ts +1 -1
  363. package/lib/simple-tree/index.d.ts.map +1 -1
  364. package/lib/simple-tree/index.js +1 -1
  365. package/lib/simple-tree/index.js.map +1 -1
  366. package/lib/tableSchema.js +10 -10
  367. package/lib/tableSchema.js.map +1 -1
  368. package/package.json +22 -22
  369. package/src/codec/codec.ts +19 -0
  370. package/src/core/index.ts +4 -0
  371. package/src/core/rebase/index.ts +2 -0
  372. package/src/core/rebase/types.ts +72 -2
  373. package/src/core/rebase/utils.ts +1 -0
  374. package/src/core/revertible.ts +67 -6
  375. package/src/entrypoints/alpha.ts +11 -0
  376. package/src/entrypoints/beta.ts +3 -0
  377. package/src/entrypoints/legacy.ts +3 -0
  378. package/src/feature-libraries/index.ts +1 -1
  379. package/src/feature-libraries/indexing/types.ts +1 -1
  380. package/src/feature-libraries/schemaChecker.ts +198 -82
  381. package/src/index.ts +11 -0
  382. package/src/packageVersion.ts +1 -1
  383. package/src/shared-tree/history.ts +99 -0
  384. package/src/shared-tree/schematizingTreeView.ts +100 -29
  385. package/src/shared-tree/sharedTree.ts +5 -2
  386. package/src/shared-tree/tree.ts +1 -1
  387. package/src/shared-tree/treeAlpha.ts +17 -35
  388. package/src/shared-tree/treeCheckout.ts +170 -31
  389. package/src/shared-tree/unhydratedTreeContext.ts +6 -2
  390. package/src/shared-tree-core/branch.ts +34 -2
  391. package/src/shared-tree-core/branchCommitCounter.ts +103 -0
  392. package/src/shared-tree-core/customMetadataCodec.ts +42 -0
  393. package/src/shared-tree-core/customMetadataFormat.ts +39 -0
  394. package/src/shared-tree-core/editManager.ts +22 -3
  395. package/src/shared-tree-core/editManagerCodecs.ts +12 -0
  396. package/src/shared-tree-core/editManagerCodecsCommons.ts +41 -15
  397. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +7 -1
  398. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +2 -0
  399. package/src/shared-tree-core/editManagerFormatCommons.ts +46 -12
  400. package/src/shared-tree-core/editManagerFormatV1toV4.ts +13 -5
  401. package/src/shared-tree-core/editManagerFormatVSharedBranches.ts +2 -2
  402. package/src/shared-tree-core/index.ts +3 -0
  403. package/src/shared-tree-core/messageCodecV1ToV4.ts +18 -5
  404. package/src/shared-tree-core/messageCodecVSharedBranches.ts +9 -2
  405. package/src/shared-tree-core/messageCodecs.ts +12 -0
  406. package/src/shared-tree-core/messageFormat.ts +6 -0
  407. package/src/shared-tree-core/messageFormatV1ToV4.ts +21 -3
  408. package/src/shared-tree-core/messageFormatVSharedBranches.ts +8 -0
  409. package/src/shared-tree-core/sharedTreeCore.ts +5 -2
  410. package/src/shared-tree-core/transaction.ts +56 -4
  411. package/src/simple-tree/api/configuration.ts +4 -4
  412. package/src/simple-tree/api/discrepancies.ts +100 -5
  413. package/src/simple-tree/api/index.ts +12 -1
  414. package/src/simple-tree/api/schemaCompatibilityTester.ts +185 -11
  415. package/src/simple-tree/api/transactionTypes.ts +29 -2
  416. package/src/simple-tree/api/tree.ts +384 -68
  417. package/src/simple-tree/core/toStored.ts +8 -0
  418. package/src/simple-tree/core/treeNodeValid.ts +3 -1
  419. package/src/simple-tree/index.ts +9 -0
  420. package/src/tableSchema.ts +9 -9
  421. package/docs/main/runtime-schema-upgrade.md +0 -208
@@ -8,8 +8,12 @@ import type { IFluidLoadable, IDisposable, Listenable } from "@fluidframework/co
8
8
  import type {
9
9
  ChangeMetadata,
10
10
  CommitMetadata,
11
+ CustomMetadataTree,
12
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.
13
+ Revertible,
11
14
  RevertibleAlphaFactory,
12
15
  RevertibleFactory,
16
+ RevertToOptionsAlpha,
13
17
  } from "../../core/index.js";
14
18
  // eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.
15
19
  import type { TreeStatus } from "../../feature-libraries/index.js";
@@ -17,9 +21,12 @@ import type {
17
21
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports -- This is referenced by doc comments.
18
22
  TreeAlpha,
19
23
  } from "../../shared-tree/index.js";
20
- import type { JsonCompatibleReadOnly } from "../../util/index.js";
24
+ import type {
25
+ JsonCompatibleReadOnly,
26
+ JsonCompatibleReadOnlyObject,
27
+ } from "../../util/index.js";
21
28
  // eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.
22
- import type { Unhydrated } from "../core/index.js";
29
+ import type { SchemaUpgrade, Unhydrated } from "../core/index.js";
23
30
  import type {
24
31
  ImplicitFieldSchema,
25
32
  InsertableField,
@@ -32,6 +39,7 @@ import type { SimpleTreeSchema } from "../simpleSchema.js";
32
39
  import type { UnsafeUnknownSchema } from "../unsafeUnknownSchema.js";
33
40
 
34
41
  import type { TreeViewConfiguration } from "./configuration.js";
42
+ import type { StagedUpgradeStatus } from "./schemaCompatibilityTester.js";
35
43
  import type {
36
44
  RunTransactionParamsAlpha,
37
45
  RunTransactionParamsBeta,
@@ -144,58 +152,66 @@ export interface ITreeAlpha extends ITree {
144
152
  }
145
153
 
146
154
  /**
147
- * A collection of functionality associated with a (version-control-style) branch of a SharedTree.
148
- * @remarks A `TreeBranch` allows for the {@link TreeBranch.fork | creation of branches} and for those branches to later be {@link TreeBranch.merge | merged}.
155
+ * An untyped view of a (version-control-style) branch of a SharedTree.
156
+ * @remarks An `UntypedTreeView` allows for the {@link UntypedTreeView.fork | creation of branches} and for those branches to later be {@link UntypedTreeView.merge | merged}.
149
157
  *
150
158
  * The branch associated directly with the {@link ITree | SharedTree} is the "main" branch, and all other branches fork (directly or transitively) from that main branch.
151
159
  *
152
- * See {@link TreeBranchAlpha} for additional APIs that are in an earlier stage of development.
160
+ * See {@link UntypedTreeViewAlpha} for additional APIs that are in an earlier stage of development.
153
161
  * @sealed @beta
154
162
  */
155
- export interface TreeBranch extends IDisposable {
163
+ export interface UntypedTreeView extends IDisposable {
156
164
  /**
157
165
  * Fork a new branch off of this branch which is based off of this branch's current state.
158
- * @remarks Any changes to the tree on the new branch will not apply to this branch until the new branch is e.g. {@link TreeBranch.merge | merged} back into this branch.
159
- * The branch should be disposed when no longer needed, either {@link TreeBranch.dispose | explicitly} or {@link TreeBranch.merge | implicitly when merging} into another branch.
166
+ * @remarks Any changes to the tree on the new view will not apply to this view until the new view is e.g. {@link UntypedTreeView.merge | merged} back into this view.
167
+ * The view should be disposed when no longer needed, either {@link UntypedTreeView.dispose | explicitly} or {@link UntypedTreeView.merge | implicitly when merging} into another view.
160
168
  */
161
- fork(): TreeBranch;
169
+ fork(): UntypedTreeView;
162
170
 
163
171
  /**
164
- * Apply all the new changes on the given branch to this branch.
165
- * @param branch - a branch which was created by a call to `branch()`.
166
- * @param disposeMerged - whether or not to dispose `branch` after the merge completes.
172
+ * Apply all the new changes on the given view to this view.
173
+ * @param view - A view created by {@link UntypedTreeView.fork}.
174
+ * @param disposeMerged - Whether or not to dispose `view` after the merge completes.
167
175
  * Defaults to true.
168
- * The {@link TreeBranch | main branch} cannot be disposed - attempting to do so will have no effect.
169
- * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.
176
+ * The {@link UntypedTreeView | main view} cannot be disposed - attempting to do so will have no effect.
177
+ * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.
170
178
  */
171
- merge(branch: TreeBranch, disposeMerged?: boolean): void;
179
+ merge(view: UntypedTreeView, disposeMerged?: boolean): void;
172
180
 
173
181
  /**
174
- * Advance this branch forward such that all new changes on the target branch become part of this branch.
175
- * @param branch - The branch to rebase onto.
176
- * @remarks After rebasing, this branch will be "ahead" of the target branch, that is, its unique changes will have been recreated as if they happened after all changes on the target branch.
177
- * This method may only be called on branches produced via {@link TreeBranch.fork | branch} - attempting to rebase the main branch will throw.
182
+ * Advance this view forward such that all new changes on the target view become part of this view.
183
+ * @param view - The view to rebase onto.
184
+ * @remarks After rebasing, this view will be "ahead" of the target view, that is, its unique changes will have been recreated as if they happened after all changes on the target view.
185
+ * This method may only be called on views produced via {@link UntypedTreeView.fork | fork} - attempting to rebase the main view will throw.
178
186
  *
179
187
  * Rebasing long-lived branches is important to avoid consuming memory unnecessarily.
180
188
  * In particular, the SharedTree retains all sequenced changes made to the tree since the "most-behind" branch was created or last rebased.
181
189
  *
182
- * The {@link TreeBranch | main branch} cannot be rebased onto another branch - attempting to do so will throw an error.
190
+ * The {@link UntypedTreeView | main view} cannot be rebased onto another view - attempting to do so will throw an error.
183
191
  */
184
- rebaseOnto(branch: TreeBranch): void;
192
+ rebaseOnto(view: UntypedTreeView): void;
185
193
 
186
194
  /**
187
- * Dispose of this branch, cleaning up any resources associated with it.
195
+ * Dispose of this view, cleaning up any resources associated with it.
188
196
  * @param error - Optional error indicating the reason for the disposal, if the object was disposed as the result of an error.
189
- * @remarks Branches can also be automatically disposed when {@link TreeBranch.merge | they are merged} into another branch.
197
+ * @remarks Views can also be automatically disposed when {@link UntypedTreeView.merge | they are merged} into another view.
190
198
  *
191
199
  * Disposing branches is important to avoid consuming memory unnecessarily.
192
- * In particular, the SharedTree retains all sequenced changes made to the tree since the "most-behind" branch was created or last {@link TreeBranch.rebaseOnto | rebased}.
200
+ * In particular, the SharedTree retains all sequenced changes made to the tree since the "most-behind" view was created or last {@link UntypedTreeView.rebaseOnto | rebased}.
193
201
  *
194
- * The {@link TreeBranch | main branch} cannot be disposed - attempting to do so will have no effect.
202
+ * The {@link UntypedTreeView | main view} cannot be disposed - attempting to do so will have no effect.
195
203
  */
196
204
  dispose(error?: Error): void;
197
205
  }
198
206
 
207
+ /**
208
+ * Compatibility alias for {@link UntypedTreeView}.
209
+ *
210
+ * @deprecated Use {@link UntypedTreeView} instead.
211
+ * @beta
212
+ */
213
+ export type TreeBranch = UntypedTreeView;
214
+
199
215
  /**
200
216
  * Provides additional APIs that may be used to interact with a tree node or a tree node's SharedTree.
201
217
  * @alpha
@@ -223,7 +239,7 @@ export interface TreeContextAlpha {
223
239
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
224
240
  *
225
241
  * `runTransaction` may be invoked on the context of a {@link TreeStatus.InDocument | hydrated } or {@link Unhydrated | unhydrated } node.
226
- * Use {@link TreeContextAlpha.isBranch | isBranch() } to check whether this context is associated with a branch and gain {@link TreeBranchAlpha.(runTransaction:1) | access to more transaction capabilities} if so.
242
+ * Use {@link TreeContextAlpha.isView | isView() } to check whether this context is associated with a view and gain {@link UntypedTreeViewAlpha.(runTransaction:1) | access to more transaction capabilities} if so.
227
243
  */
228
244
  runTransaction<TValue>(
229
245
  transaction: () => WithValue<TValue>,
@@ -271,44 +287,130 @@ export interface TreeContextAlpha {
271
287
  ): Promise<TransactionVoidResult>;
272
288
 
273
289
  /**
274
- * True if this context is associated with a {@link TreeBranchAlpha | branch} and false if it is associated with an {@link Unhydrated | unhydrated } node.
275
- * @remarks If this returns true, the context can be safely inferred or cast to {@link TreeBranchAlpha} to access additional branch-specific APIs.
290
+ * True if this context is associated with an {@link UntypedTreeViewAlpha | untyped view} and false if it is associated with an {@link Unhydrated | unhydrated } node.
291
+ * @remarks If this returns true, the context can be safely inferred or cast to {@link UntypedTreeViewAlpha} to access additional view-specific APIs.
276
292
  * @example
277
293
  * ```typescript
278
294
  * const context = tree.context(someNode);
279
- * if (context.isBranch()) {
280
- * assert(context.hasRootSchema(MySchema)) // `hasRootSchema` is a method on TreeBranchAlpha, so this is only accessible if `context` is a branch context.
295
+ * if (context.isView()) {
296
+ * assert(context.hasRootSchema(MySchema)) // `hasRootSchema` is a method on UntypedTreeViewAlpha, so this is only accessible if `context` is a view context.
281
297
  * context.root.foo = "bar"; // Edit the root of the SharedTree that `someNode` belongs to.
282
298
  * }
283
299
  * ```
300
+ * @returns Whether this context is associated with an untyped view.
301
+ */
302
+ isView(): this is UntypedTreeViewAlpha;
303
+
304
+ /**
305
+ * {@inheritDoc TreeContextAlpha.isView}
306
+ * @deprecated Use {@link TreeContextAlpha.isView | isView()} instead.
307
+ */
308
+ isBranch(): this is UntypedTreeViewAlpha;
309
+ }
310
+
311
+ /**
312
+ * An identifier for a commit in a {@link UntypedTreeViewAlpha}'s {@link UntypedTreeViewAlpha.branchHistory | history}.
313
+ * @alpha
314
+ */
315
+ export type CommitRevision = string;
316
+
317
+ /**
318
+ * Metadata describing a single commit in a {@link UntypedTreeViewAlpha}'s history.
319
+ * @sealed @alpha
320
+ */
321
+ export interface TreeBranchCommitMetadata {
322
+ /**
323
+ * The revision UUID that uniquely identifies this commit within the branch's history.
324
+ */
325
+ readonly revision: CommitRevision;
326
+
327
+ /**
328
+ * Arbitrary, application-defined metadata that was {@link RunTransactionParamsAlpha.customMetadata | attached}
329
+ * to this commit when it was created, flattened into a single object.
330
+ *
331
+ * @remarks
332
+ * This is `undefined` for commits that were not annotated.
333
+ *
334
+ * A commit may be produced by nested transactions, each of which may supply metadata. This property combines
335
+ * them: where two of them used the same property, the outermost transaction wins, and between siblings the
336
+ * later one wins. Use {@link TreeBranchCommitMetadata.customTree} to recover which transaction supplied what.
337
+ */
338
+ readonly custom: JsonCompatibleReadOnlyObject | undefined;
339
+
340
+ /**
341
+ * The {@link CustomMetadataTree | tree} of metadata attached to this commit, reflecting the nesting of
342
+ * the transactions that produced it.
343
+ *
344
+ * @remarks
345
+ * The structural counterpart to {@link TreeBranchCommitMetadata.custom}, and `undefined` whenever it is.
346
+ * Prefer `custom` unless you need to know which transaction supplied a particular property.
347
+ */
348
+ readonly customTree: CustomMetadataTree | undefined;
349
+
350
+ /**
351
+ * The metadata for the commit that this commit was based on, or `undefined` if this commit has no parent
352
+ * (i.e. it is the oldest commit in the branch's history).
353
+ *
354
+ * @remarks
355
+ * This method may return a different value over time if the parent commit is trimmed from the branch's history.
356
+ */
357
+ getParent(): TreeBranchCommitMetadata | undefined;
358
+ }
359
+
360
+ /**
361
+ * Provides APIs for querying information about the history of a {@link UntypedTreeViewAlpha}.
362
+ * @remarks
363
+ * The history of a branch is the sequence of commits leading up to its current state.
364
+ * @sealed @alpha
365
+ */
366
+ export interface TreeBranchHistory {
367
+ /**
368
+ * The number of commits in this branch's history.
369
+ * @remarks
370
+ * This number grows when any of the following occurs:
371
+ * - A new edit is made on this branch (either through editing or by reverting an existing commit on this branch).
372
+ * - A branch that contains commits not already on this branch is merged into this branch.
373
+ * - The branch is rebased onto another branch that contains commits not already on this branch.
374
+ * This number shrinks when past commits are trimmed from the history.
284
375
  */
285
- isBranch(): this is TreeBranchAlpha;
376
+ readonly length: number;
377
+
378
+ /**
379
+ * Returns metadata for the current head commit of this branch.
380
+ * @returns The metadata for the head commit, or `undefined` if the branch has no commits.
381
+ */
382
+ getHead(): TreeBranchCommitMetadata | undefined;
286
383
  }
287
384
 
288
385
  /**
289
- * {@link TreeBranch} with alpha-level APIs.
386
+ * An untyped view of a {@link UntypedTreeView} with alpha-level APIs.
290
387
  * @remarks
291
- * The `TreeBranch` for a specific {@link TreeNode} may be acquired by calling `TreeAlpha.branch`.
388
+ * The untyped view for a specific {@link TreeNode} may be acquired by calling `TreeAlpha.context` and checking {@link TreeContextAlpha.isView | isView()}.
292
389
  *
293
- * A branch does not necessarily know the schema of its SharedTree - to convert a branch to a {@link TreeViewAlpha | view with a schema}, use {@link TreeBranchAlpha.hasRootSchema | hasRootSchema()}.
390
+ * An untyped view does not necessarily know the schema of its SharedTree. To convert it to a {@link TreeViewAlpha | view with a schema}, use {@link UntypedTreeViewAlpha.hasRootSchema | hasRootSchema()}.
294
391
  * @sealed @alpha
295
392
  */
296
- export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
393
+ export interface UntypedTreeViewAlpha extends UntypedTreeView, TreeContextAlpha {
297
394
  /**
298
- * Events for the branch
395
+ * Events for the view's underlying branch.
299
396
  */
300
397
  readonly events: Listenable<TreeBranchEvents>;
301
398
 
302
399
  /**
303
- * Returns true if this branch has the given schema as its root schema.
304
- * @remarks This is a type guard which allows this branch to become strongly typed as a {@link TreeViewAlpha | view} of the given schema.
400
+ * APIs for querying the history of the branch being viewed.
401
+ */
402
+ readonly branchHistory: TreeBranchHistory;
403
+
404
+ /**
405
+ * Returns true if this view has the given schema as its root schema.
406
+ * @remarks This is a type guard which allows this view to become strongly typed as a {@link TreeViewAlpha | view} of the given schema.
305
407
  *
306
408
  * To succeed, the given schema must be invariant to the schema of the view - it must include exactly the same allowed types.
307
409
  * For example, a schema of `Foo | Bar` will not match a view schema of `Foo`, and likewise a schema of `Foo` will not match a view schema of `Foo | Bar`.
308
410
  * @example
309
411
  * ```typescript
310
- * if (branch.hasRootSchema(MySchema)) {
311
- * const { root } = branch; // `branch` is now a TreeViewAlpha<MySchema>
412
+ * if (view.hasRootSchema(MySchema)) {
413
+ * const { root } = view; // `view` is now a TreeViewAlpha<MySchema>
312
414
  * // ...
313
415
  * }
314
416
  * ```
@@ -318,10 +420,40 @@ export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
318
420
  ): this is TreeViewAlpha<TSchema>;
319
421
 
320
422
  // Override the base fork method to return the alpha variant.
321
- fork(): TreeBranchAlpha;
423
+ fork(): UntypedTreeViewAlpha;
424
+
425
+ /**
426
+ * Switches this view to a new underlying branch with the given commit as the head, updating the view state accordingly.
427
+ *
428
+ * @param revision - The {@link TreeBranchCommitMetadata.revision | revision} to rewind to.
429
+ * Can be obtained by navigating the commits on the {@link UntypedTreeViewAlpha.branchHistory | branch history}.
430
+ *
431
+ * @remarks
432
+ * Unlike {@link UntypedTreeViewAlpha.revertTo | revertTo}, this does not apply a change to the underlying branch.
433
+ * The original underlying branch will be disposed.
434
+ * Consider {@link UntypedTreeViewAlpha.fork | forking} before rewinding.
435
+ * Not valid to invoke on the main branch or a {@link (ITreeAlpha:interface).createSharedBranch | shared branch}.
436
+ */
437
+ rewindTo(revision: CommitRevision): void;
322
438
 
323
439
  /**
324
- * {@link TreeContextAlpha.(runTransaction:1) | Run a transaction} on a branch of the SharedTree.
440
+ * Applies a new change which reverts all changes made since the given `revision`.
441
+ * This is a no-op if the given revision is the head commit of the underlying branch being viewed.
442
+ *
443
+ * @param revision - The {@link TreeBranchCommitMetadata.revision | revision} to restore the state of.
444
+ * Can be obtained by navigating the commits on the {@link UntypedTreeViewAlpha.branchHistory | branch history}.
445
+ * @param options - Optional {@link RevertToOptionsAlpha | options} for the revert.
446
+ *
447
+ * @remarks
448
+ * The generated change is subject to the same merge semantics as the {@link Revertible.(revert:1) | reverts of individual commits}:
449
+ * Concurrent changes that are sequenced before the revert will not be overwritten by the revert if they affect different parts of the document.
450
+ *
451
+ * Unlike {@link UntypedTreeViewAlpha.rewindTo | rewindTo}, this does not switch to a new branch.
452
+ */
453
+ revertTo(revision: CommitRevision, options?: RevertToOptionsAlpha): void;
454
+
455
+ /**
456
+ * {@link TreeContextAlpha.(runTransaction:1) | Run a transaction} on this view of the SharedTree.
325
457
  * @param transaction - The function to run as the body of the transaction, which may optionally return a {@link TransactionCallbackStatusAlpha | value or rollback signal}.
326
458
  * @remarks
327
459
  * If the transaction is rolled back, a corresponding {@link TreeBranchEvents.changed | `changed`} event will also be emitted for the rollback.
@@ -332,7 +464,7 @@ export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
332
464
  ): TransactionValueResult<TSuccessValue, TFailureValue>;
333
465
 
334
466
  /**
335
- * An overload of {@link TreeBranchAlpha.(runTransaction:1) | runTransaction } which does not return a value.
467
+ * An overload of {@link UntypedTreeViewAlpha.(runTransaction:1) | runTransaction } which does not return a value.
336
468
  *
337
469
  * @privateRemarks
338
470
  * TODO: Consider updating these methods to avoid the need for overloads.
@@ -344,7 +476,7 @@ export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
344
476
  ): TransactionVoidResult;
345
477
 
346
478
  /**
347
- * An asynchronous version of {@link TreeBranchAlpha.(runTransaction:1) | runTransaction}.
479
+ * An asynchronous version of {@link UntypedTreeViewAlpha.(runTransaction:1) | runTransaction}.
348
480
  * @remarks See {@link TreeContextAlpha.(runTransactionAsync:1) | runTransactionAsync} for additional information about asynchronous transactions.
349
481
  */
350
482
 
@@ -354,7 +486,7 @@ export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
354
486
  ): Promise<TransactionValueResult<TSuccessValue, TFailureValue>>;
355
487
 
356
488
  /**
357
- * An overload of {@link TreeBranchAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value.
489
+ * An overload of {@link UntypedTreeViewAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value.
358
490
  *
359
491
  * @privateRemarks
360
492
  * TODO: Consider updating these methods to avoid the need for overloads.
@@ -379,27 +511,35 @@ export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
379
511
  applyChange(change: JsonCompatibleReadOnly): void;
380
512
 
381
513
  /**
382
- * Determines if there are changes on the given branch that are not present on this branch.
383
- * @param branch - The branch to compare to.
514
+ * Determines if there are changes on the given view that are not present on this view.
515
+ * @param view - The view to compare to.
384
516
  *
385
- * The new edits, if any, can be applied to this branch by {@link TreeBranch.rebaseOnto | rebasing this branch onto the given branch}
386
- * or by {@link TreeBranch.merge | merging the given branch into this branch}.
517
+ * The new edits, if any, can be applied to this view by {@link UntypedTreeView.rebaseOnto | rebasing this view onto the given view}
518
+ * or by {@link UntypedTreeView.merge | merging the given view into this view}.
387
519
  *
388
520
  * @throws UsageError if the branches are unrelated.
389
521
  */
390
- isMissingEditsFrom(branch: TreeBranch): boolean;
522
+ isMissingEditsFrom(view: UntypedTreeView): boolean;
391
523
 
392
524
  /**
393
- * Computes the net change that would result if this branch were {@link TreeBranch.rebaseOnto | rebased onto} the given branch.
394
- * Note that this method does not actually perform the rebase and therefore has no effect on this branch.
525
+ * Computes the net change that would result if this view were {@link UntypedTreeView.rebaseOnto | rebased onto} the given view.
526
+ * Note that this method does not actually perform the rebase and therefore has no effect on this view.
395
527
  *
396
- * @param branch - The branch that would be rebased onto.
397
- * @returns The net change that would result if this branch were rebased onto the given branch,
528
+ * @param view - The view that would be rebased onto.
529
+ * @returns The net change that would result if this view were rebased onto the given view,
398
530
  * or `undefined` if rebasing would have no impact.
399
531
  */
400
- computeNetChangeIfRebasedOnto(branch: TreeBranch): JsonCompatibleReadOnly | undefined;
532
+ computeNetChangeIfRebasedOnto(view: UntypedTreeView): JsonCompatibleReadOnly | undefined;
401
533
  }
402
534
 
535
+ /**
536
+ * Compatibility alias for {@link UntypedTreeViewAlpha}.
537
+ *
538
+ * @deprecated Use {@link UntypedTreeViewAlpha} instead.
539
+ * @alpha
540
+ */
541
+ export type TreeBranchAlpha = UntypedTreeViewAlpha;
542
+
403
543
  /**
404
544
  * An editable view of a (version control style) branch of a shared tree based on some schema.
405
545
  *
@@ -410,7 +550,7 @@ export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
410
550
  * Application authors are encouraged to read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/docs/user-facing/schema-evolution.md | schema-evolution.md}
411
551
  * and choose a schema compatibility policy that aligns with their application's needs.
412
552
  *
413
- * See also {@link TreeViewAlpha}, {@link TreeViewBeta} and {@link TreeBranch} for additional APIs that are in earlier stages of development.
553
+ * See also {@link TreeViewAlpha}, {@link TreeViewBeta} and {@link UntypedTreeView} for additional APIs that are in earlier stages of development.
414
554
  *
415
555
  * @privateRemarks
416
556
  * From an API design perspective, `upgradeSchema` could be merged into `viewWith` and/or `viewWith` could return errors explicitly on incompatible documents.
@@ -462,9 +602,9 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
462
602
  *
463
603
  * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},
464
604
  * staged schema upgrades matching the configured policy are included in the target stored schema.
465
- * Once a staged schema upgrade has been enabled in a document's stored schema, loading that document
466
- * with a view that does not include equivalent staged members in its construction-time policy will cause
467
- * `upgradeSchema` to throw a `UsageError` because the requested target would narrow the stored schema.
605
+ * Staged upgrades that are already enabled in the document are also included by default. Set
606
+ * {@link (StagedSchemaUpgradePolicy:interface).includeAlreadyEnabledUpgrades} to `false` when
607
+ * creating the policy to only include staged upgrades selected explicitly by the policy.
468
608
  *
469
609
  * @example Enabling a staged allowed type for documents, selected by a feature flag
470
610
  *
@@ -536,15 +676,178 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
536
676
  readonly schema: TSchema;
537
677
  }
538
678
 
679
+ /**
680
+ * A discrepancy between a view schema and a document's stored schema.
681
+ *
682
+ * @remarks
683
+ * The `mismatch` property discriminates the different discrepancy shapes.
684
+ *
685
+ * @sealed @beta
686
+ */
687
+ export type SchemaDiscrepancy =
688
+ | {
689
+ /**
690
+ * Indicates that a field allows different node types in the view and stored schemas.
691
+ */
692
+ readonly mismatch: "allowedTypes";
693
+ /**
694
+ * The field with the discrepancy.
695
+ *
696
+ * `"root"` identifies the root field. Otherwise, `nodeType` identifies the containing
697
+ * node schema and `fieldKey` identifies its field. `fieldKey` is undefined for a map
698
+ * node's implicit field.
699
+ */
700
+ readonly location:
701
+ | "root"
702
+ | {
703
+ readonly nodeType: string;
704
+ readonly fieldKey: string | undefined;
705
+ };
706
+ /**
707
+ * Non-staged node type identifiers allowed by the view schema but not the stored schema.
708
+ */
709
+ readonly view: readonly string[];
710
+ /**
711
+ * Staged node type identifiers allowed by the view schema but not the stored schema.
712
+ *
713
+ * @remarks These types provide rollout context but do not cause the discrepancy.
714
+ */
715
+ readonly stagedView?: readonly string[];
716
+ /**
717
+ * Node type identifiers allowed by the stored schema but not the view schema.
718
+ */
719
+ readonly stored: readonly string[];
720
+ /**
721
+ * Whether the view field is a staged optional field.
722
+ *
723
+ * @remarks Omitted when false.
724
+ */
725
+ readonly viewIsStagedOptional?: true;
726
+ }
727
+ | {
728
+ /**
729
+ * Indicates that a field has different field kinds in the view and stored schemas.
730
+ */
731
+ readonly mismatch: "fieldKind";
732
+ /**
733
+ * The field with the discrepancy.
734
+ *
735
+ * `"root"` identifies the root field. Otherwise, `nodeType` identifies the containing
736
+ * node schema and `fieldKey` identifies its field. `fieldKey` is undefined for a map
737
+ * node's implicit field.
738
+ */
739
+ readonly location:
740
+ | "root"
741
+ | {
742
+ readonly nodeType: string;
743
+ readonly fieldKey: string | undefined;
744
+ };
745
+ /**
746
+ * The field kind required by the view schema.
747
+ */
748
+ readonly view: string;
749
+ /**
750
+ * The field kind recorded in the stored schema.
751
+ */
752
+ readonly stored: string;
753
+ /**
754
+ * Whether the view field is a staged optional field.
755
+ *
756
+ * @remarks Omitted when false.
757
+ */
758
+ readonly viewIsStagedOptional?: true;
759
+ }
760
+ | {
761
+ /**
762
+ * Indicates that a leaf node accepts different value types in the view and stored schemas.
763
+ */
764
+ readonly mismatch: "valueSchema";
765
+ /**
766
+ * The identifier of the leaf node schema with the discrepancy.
767
+ */
768
+ readonly nodeType: string;
769
+ /**
770
+ * The value schema required by the view, or undefined when it does not constrain values.
771
+ */
772
+ readonly view: string | undefined;
773
+ /**
774
+ * The value schema recorded in the stored schema, or undefined when it does not constrain values.
775
+ */
776
+ readonly stored: string | undefined;
777
+ }
778
+ | {
779
+ /**
780
+ * Indicates that a node is represented by different node kinds in the view and stored schemas.
781
+ */
782
+ readonly mismatch: "nodeKind";
783
+ /**
784
+ * The identifier of the node schema with the discrepancy.
785
+ */
786
+ readonly nodeType: string;
787
+ /**
788
+ * The node kind required by the view schema.
789
+ */
790
+ readonly view: string;
791
+ /**
792
+ * The node kind recorded in the stored schema.
793
+ */
794
+ readonly stored: string;
795
+ };
796
+
797
+ /**
798
+ * {@link SchemaCompatibilityStatus} with additional beta APIs.
799
+ *
800
+ * @sealed @beta
801
+ */
802
+ export interface SchemaCompatibilityStatusBeta extends SchemaCompatibilityStatus {
803
+ /**
804
+ * Details about the schema discrepancies that prevent this view from accessing the tree.
805
+ *
806
+ * @remarks
807
+ * This property is undefined when {@link SchemaCompatibilityStatus.canView} is true and present
808
+ * when `canView` is false.
809
+ * It can include application-defined schema identifiers and field keys.
810
+ *
811
+ * @example Interpreting an allowed-types discrepancy
812
+ *
813
+ * If a document's stored schema allows `string` for `Todo.title`, but the view schema expects
814
+ * `number`, the discrepancy identifies the field and the type permitted by each schema:
815
+ *
816
+ * ```typescript
817
+ * const sf = new SchemaFactory("com.example");
818
+ * class Todo extends sf.object("Todo", {
819
+ * title: sf.number,
820
+ * }) {}
821
+ *
822
+ * const view = asBeta(tree.viewWith(new TreeViewConfiguration({ schema: Todo })));
823
+ * if (!view.compatibility.canView) {
824
+ * // [{
825
+ * // mismatch: "allowedTypes",
826
+ * // location: { nodeType: "com.example.Todo", fieldKey: "title" },
827
+ * // view: ["com.fluidframework.leaf.number"],
828
+ * // stored: ["com.fluidframework.leaf.string"],
829
+ * // }]
830
+ * console.error(view.compatibility.discrepancies);
831
+ * }
832
+ * ```
833
+ */
834
+ readonly discrepancies: readonly SchemaDiscrepancy[] | undefined;
835
+ }
836
+
539
837
  /**
540
838
  * {@link TreeView} with additional beta APIs.
541
839
  * @sealed @beta
542
840
  */
543
841
  export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema>
544
842
  extends TreeView<TSchema>,
545
- TreeBranch {
843
+ UntypedTreeView {
844
+ /**
845
+ * {@inheritDoc TreeView.compatibility}
846
+ */
847
+ readonly compatibility: SchemaCompatibilityStatusBeta;
848
+
546
849
  // Override the base branch method to return a typed view rather than merely a branch.
547
- fork(): ReturnType<TreeBranch["fork"]> & TreeViewBeta<TSchema>;
850
+ fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewBeta<TSchema>;
548
851
 
549
852
  /**
550
853
  * Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.
@@ -622,7 +925,7 @@ export interface TreeViewAlpha<
622
925
  TreeViewBeta<ReadSchema<TSchema>>,
623
926
  "root" | "initialize" | "fork" | "runTransaction" | "runTransactionAsync"
624
927
  >,
625
- TreeBranchAlpha {
928
+ UntypedTreeViewAlpha {
626
929
  get root(): ReadableField<TSchema>;
627
930
 
628
931
  set root(newRoot: InsertableField<TSchema>);
@@ -634,20 +937,33 @@ export interface TreeViewAlpha<
634
937
  * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.
635
938
  *
636
939
  * Enables staged schema upgrades declared by {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy} when generating the initial stored schema.
637
- * Once a staged schema upgrade has been enabled in a document's stored schema, loading that document
638
- * with a view that does not include equivalent staged members in its construction-time policy will cause
639
- * a subsequent `upgradeSchema` call to throw a `UsageError` because the stored schema already contains
640
- * the upgraded members and the new target would narrow it.
641
940
  *
642
941
  * Applications should typically call this function before attaching a `SharedTree`.
643
942
  * @param content - The content to initialize the tree with.
644
943
  */
645
944
  initialize(content: InsertableField<TSchema>): void;
646
945
 
946
+ /**
947
+ * Checks whether a staged schema upgrade has been applied to the document's stored schema.
948
+ *
949
+ * @param upgrade - The upgrade token to check.
950
+ *
951
+ * @returns The {@link StagedUpgradeStatus} of the upgrade.
952
+ *
953
+ * @remarks
954
+ * Use this to determine whether a document has already been upgraded, for example when deciding
955
+ * whether to include an upgrade token in the view configuration after a feature flag rollback.
956
+ *
957
+ * Results are derived from this view's schema and the current stored schema.
958
+ * The full schema is checked even when the view is incompatible with the stored schema, so the
959
+ * result includes all locations declared by the view schema.
960
+ */
961
+ isStagedUpgradeEnabled(upgrade: SchemaUpgrade): StagedUpgradeStatus;
962
+
647
963
  readonly events: Listenable<TreeViewEvents & TreeBranchEvents>;
648
964
 
649
965
  // Override the base fork method to return a TreeViewAlpha.
650
- fork(): ReturnType<TreeBranch["fork"]> & TreeViewAlpha<TSchema>;
966
+ fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewAlpha<TSchema>;
651
967
  }
652
968
 
653
969
  /**
@@ -744,7 +1060,7 @@ export interface SchemaCompatibilityStatus {
744
1060
  }
745
1061
 
746
1062
  /**
747
- * Events for {@link TreeBranch}.
1063
+ * Events for {@link UntypedTreeView}.
748
1064
  * @sealed @alpha
749
1065
  */
750
1066
  export interface TreeBranchEvents {
@@ -11,6 +11,14 @@ import type { SchemaUpgrade } from "./allowedTypes.js";
11
11
  * @alpha
12
12
  */
13
13
  export interface StagedSchemaUpgradePolicy {
14
+ /**
15
+ * Whether schema upgrades should include staged upgrades that are already enabled in the
16
+ * document's stored schema.
17
+ *
18
+ * @defaultValue `true`
19
+ */
20
+ readonly includeAlreadyEnabledUpgrades?: boolean;
21
+
14
22
  /**
15
23
  * Determines whether to include staged allowed types in the resulting stored schema.
16
24
  * @remarks