@fluidframework/tree 2.111.0 → 2.113.0-411909

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 (490) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/api-report/tree.alpha.api.md +71 -7
  3. package/api-report/tree.beta.api.md +1 -1
  4. package/api-report/tree.legacy.beta.api.md +1 -1
  5. package/api-report/tree.legacy.public.api.md +1 -1
  6. package/api-report/tree.public.api.md +1 -1
  7. package/dist/componentApi.d.ts +198 -0
  8. package/dist/componentApi.d.ts.map +1 -0
  9. package/dist/componentApi.js +138 -0
  10. package/dist/componentApi.js.map +1 -0
  11. package/dist/entrypoints/alpha.d.ts +1 -1
  12. package/dist/entrypoints/alpha.d.ts.map +1 -1
  13. package/dist/entrypoints/alpha.js +5 -2
  14. package/dist/entrypoints/alpha.js.map +1 -1
  15. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -25
  16. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  17. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  18. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
  19. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  20. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  21. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +6 -18
  22. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  23. package/dist/feature-libraries/chunked-forest/codec/codecs.js +9 -16
  24. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  25. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  26. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  27. package/dist/feature-libraries/index.d.ts +2 -2
  28. package/dist/feature-libraries/index.d.ts.map +1 -1
  29. package/dist/feature-libraries/index.js +3 -2
  30. package/dist/feature-libraries/index.js.map +1 -1
  31. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +39 -7
  32. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  33. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +22 -2
  34. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  35. package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  36. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  37. package/dist/feature-libraries/modular-schema/index.d.ts +2 -1
  38. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  39. package/dist/feature-libraries/modular-schema/index.js +4 -1
  40. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  41. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
  42. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
  43. package/dist/feature-libraries/modular-schema/minimizeModularChange.js +29 -0
  44. package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
  45. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  46. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +8 -1
  47. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  48. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  49. package/dist/feature-libraries/optional-field/optionalField.js +26 -3
  50. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  51. package/dist/feature-libraries/schemaChecker.d.ts +22 -3
  52. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
  53. package/dist/feature-libraries/schemaChecker.js +48 -5
  54. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  55. package/dist/feature-libraries/sequence-field/filterEdits.d.ts +12 -0
  56. package/dist/feature-libraries/sequence-field/filterEdits.d.ts.map +1 -0
  57. package/dist/feature-libraries/sequence-field/filterEdits.js +111 -0
  58. package/dist/feature-libraries/sequence-field/filterEdits.js.map +1 -0
  59. package/dist/feature-libraries/sequence-field/markQueue.d.ts +8 -3
  60. package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  61. package/dist/feature-libraries/sequence-field/markQueue.js +22 -8
  62. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  63. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
  64. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  65. package/dist/feature-libraries/sequence-field/moveEffectTable.js +2 -6
  66. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  67. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +7 -6
  68. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  69. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +2 -4
  70. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  71. package/dist/index.d.ts +3 -2
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +6 -2
  74. package/dist/index.js.map +1 -1
  75. package/dist/packageVersion.d.ts +1 -1
  76. package/dist/packageVersion.d.ts.map +1 -1
  77. package/dist/packageVersion.js +1 -1
  78. package/dist/packageVersion.js.map +1 -1
  79. package/dist/shared-tree/independentView.d.ts +17 -4
  80. package/dist/shared-tree/independentView.d.ts.map +1 -1
  81. package/dist/shared-tree/independentView.js +11 -5
  82. package/dist/shared-tree/independentView.js.map +1 -1
  83. package/dist/shared-tree/index.d.ts +2 -1
  84. package/dist/shared-tree/index.d.ts.map +1 -1
  85. package/dist/shared-tree/index.js +3 -1
  86. package/dist/shared-tree/index.js.map +1 -1
  87. package/dist/shared-tree/schematizingTreeView.d.ts +9 -0
  88. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  89. package/dist/shared-tree/schematizingTreeView.js +29 -14
  90. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  91. package/dist/shared-tree/serializedChange.d.ts +41 -0
  92. package/dist/shared-tree/serializedChange.d.ts.map +1 -0
  93. package/dist/shared-tree/serializedChange.js +87 -0
  94. package/dist/shared-tree/serializedChange.js.map +1 -0
  95. package/dist/shared-tree/sharedTree.d.ts +13 -0
  96. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  97. package/dist/shared-tree/sharedTree.js +2 -0
  98. package/dist/shared-tree/sharedTree.js.map +1 -1
  99. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
  100. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  101. package/dist/shared-tree/sharedTreeChangeFamily.js +8 -1
  102. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  103. package/dist/shared-tree/transactionMinimize.d.ts +35 -0
  104. package/dist/shared-tree/transactionMinimize.d.ts.map +1 -0
  105. package/dist/shared-tree/transactionMinimize.js +65 -0
  106. package/dist/shared-tree/transactionMinimize.js.map +1 -0
  107. package/dist/shared-tree/treeCheckout.d.ts +3 -1
  108. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  109. package/dist/shared-tree/treeCheckout.js +36 -62
  110. package/dist/shared-tree/treeCheckout.js.map +1 -1
  111. package/dist/shared-tree-core/editManager.d.ts +6 -3
  112. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  113. package/dist/shared-tree-core/editManager.js +35 -14
  114. package/dist/shared-tree-core/editManager.js.map +1 -1
  115. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
  116. package/dist/shared-tree-core/editManagerFormatCommons.js +1 -1
  117. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  118. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
  119. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  120. package/dist/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  121. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  122. package/dist/shared-tree-core/messageFormat.d.ts +1 -1
  123. package/dist/shared-tree-core/messageFormat.js +1 -1
  124. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  125. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
  126. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  127. package/dist/shared-tree-core/messageFormatVSharedBranches.js +1 -0
  128. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  129. package/dist/shared-tree-core/messageTypes.d.ts +1 -0
  130. package/dist/shared-tree-core/messageTypes.d.ts.map +1 -1
  131. package/dist/shared-tree-core/messageTypes.js.map +1 -1
  132. package/dist/shared-tree-core/sharedTreeCore.d.ts +9 -3
  133. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  134. package/dist/shared-tree-core/sharedTreeCore.js +24 -11
  135. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  136. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  137. package/dist/shared-tree-core/transaction.js +16 -2
  138. package/dist/shared-tree-core/transaction.js.map +1 -1
  139. package/dist/simple-tree/api/configuration.d.ts +32 -2
  140. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  141. package/dist/simple-tree/api/configuration.js +3 -1
  142. package/dist/simple-tree/api/configuration.js.map +1 -1
  143. package/dist/simple-tree/api/index.d.ts +2 -2
  144. package/dist/simple-tree/api/index.d.ts.map +1 -1
  145. package/dist/simple-tree/api/index.js +2 -2
  146. package/dist/simple-tree/api/index.js.map +1 -1
  147. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +13 -25
  148. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  149. package/dist/simple-tree/api/schemaCompatibilityTester.js +34 -45
  150. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  151. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
  152. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  153. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  154. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
  155. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  156. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  157. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  158. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +1 -2
  159. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  160. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  161. package/dist/simple-tree/api/storedSchema.js +1 -2
  162. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  163. package/dist/simple-tree/api/tree.d.ts +80 -3
  164. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  165. package/dist/simple-tree/api/tree.js.map +1 -1
  166. package/dist/simple-tree/api/typesUnsafe.d.ts +2 -2
  167. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  168. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  169. package/dist/simple-tree/core/index.d.ts +1 -1
  170. package/dist/simple-tree/core/index.d.ts.map +1 -1
  171. package/dist/simple-tree/core/index.js +2 -1
  172. package/dist/simple-tree/core/index.js.map +1 -1
  173. package/dist/simple-tree/core/toStored.d.ts +72 -6
  174. package/dist/simple-tree/core/toStored.d.ts.map +1 -1
  175. package/dist/simple-tree/core/toStored.js +25 -1
  176. package/dist/simple-tree/core/toStored.js.map +1 -1
  177. package/dist/simple-tree/index.d.ts +3 -3
  178. package/dist/simple-tree/index.d.ts.map +1 -1
  179. package/dist/simple-tree/index.js +5 -6
  180. package/dist/simple-tree/index.js.map +1 -1
  181. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +83 -4
  182. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  183. package/dist/simple-tree/node-kinds/array/arrayNode.js +39 -0
  184. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  185. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  186. package/dist/simple-tree/prepareForInsertion.js +9 -0
  187. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  188. package/dist/simple-tree/simpleSchemaFormatV1.js +1 -1
  189. package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  190. package/dist/simple-tree/toStoredSchema.d.ts +11 -27
  191. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  192. package/dist/simple-tree/toStoredSchema.js +25 -33
  193. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  194. package/dist/treeFactory.js +1 -1
  195. package/dist/treeFactory.js.map +1 -1
  196. package/dist/util/breakable.d.ts +16 -1
  197. package/dist/util/breakable.d.ts.map +1 -1
  198. package/dist/util/breakable.js +9 -1
  199. package/dist/util/breakable.js.map +1 -1
  200. package/dist/util/compressedIds.d.ts +69 -2
  201. package/dist/util/compressedIds.d.ts.map +1 -1
  202. package/dist/util/compressedIds.js +32 -1
  203. package/dist/util/compressedIds.js.map +1 -1
  204. package/dist/util/index.d.ts +2 -2
  205. package/dist/util/index.d.ts.map +1 -1
  206. package/dist/util/index.js +2 -2
  207. package/dist/util/index.js.map +1 -1
  208. package/dist/util/nestedMap.d.ts.map +1 -1
  209. package/dist/util/nestedMap.js +16 -3
  210. package/dist/util/nestedMap.js.map +1 -1
  211. package/dist/util/nestedSet.d.ts +1 -1
  212. package/dist/util/nestedSet.d.ts.map +1 -1
  213. package/dist/util/nestedSet.js.map +1 -1
  214. package/dist/util/utils.d.ts +0 -6
  215. package/dist/util/utils.d.ts.map +1 -1
  216. package/dist/util/utils.js +1 -15
  217. package/dist/util/utils.js.map +1 -1
  218. package/docs/main/runtime-schema-upgrade.md +208 -0
  219. package/lib/componentApi.d.ts +198 -0
  220. package/lib/componentApi.d.ts.map +1 -0
  221. package/lib/componentApi.js +135 -0
  222. package/lib/componentApi.js.map +1 -0
  223. package/lib/entrypoints/alpha.d.ts +1 -1
  224. package/lib/entrypoints/alpha.d.ts.map +1 -1
  225. package/lib/entrypoints/alpha.js +1 -1
  226. package/lib/entrypoints/alpha.js.map +1 -1
  227. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -25
  228. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  229. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +1 -1
  230. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  231. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
  232. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  233. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  234. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +6 -18
  235. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  236. package/lib/feature-libraries/chunked-forest/codec/codecs.js +10 -17
  237. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  238. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  239. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  240. package/lib/feature-libraries/index.d.ts +2 -2
  241. package/lib/feature-libraries/index.d.ts.map +1 -1
  242. package/lib/feature-libraries/index.js +1 -1
  243. package/lib/feature-libraries/index.js.map +1 -1
  244. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +39 -7
  245. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  246. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +21 -1
  247. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  248. package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  249. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  250. package/lib/feature-libraries/modular-schema/index.d.ts +2 -1
  251. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  252. package/lib/feature-libraries/modular-schema/index.js +2 -1
  253. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  254. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
  255. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
  256. package/lib/feature-libraries/modular-schema/minimizeModularChange.js +25 -0
  257. package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
  258. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  259. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +9 -2
  260. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  261. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  262. package/lib/feature-libraries/optional-field/optionalField.js +27 -4
  263. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  264. package/lib/feature-libraries/schemaChecker.d.ts +22 -3
  265. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
  266. package/lib/feature-libraries/schemaChecker.js +48 -5
  267. package/lib/feature-libraries/schemaChecker.js.map +1 -1
  268. package/lib/feature-libraries/sequence-field/filterEdits.d.ts +12 -0
  269. package/lib/feature-libraries/sequence-field/filterEdits.d.ts.map +1 -0
  270. package/lib/feature-libraries/sequence-field/filterEdits.js +107 -0
  271. package/lib/feature-libraries/sequence-field/filterEdits.js.map +1 -0
  272. package/lib/feature-libraries/sequence-field/markQueue.d.ts +8 -3
  273. package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  274. package/lib/feature-libraries/sequence-field/markQueue.js +22 -9
  275. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  276. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
  277. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  278. package/lib/feature-libraries/sequence-field/moveEffectTable.js +2 -6
  279. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  280. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +7 -6
  281. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  282. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +2 -4
  283. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  284. package/lib/index.d.ts +3 -2
  285. package/lib/index.d.ts.map +1 -1
  286. package/lib/index.js +3 -2
  287. package/lib/index.js.map +1 -1
  288. package/lib/packageVersion.d.ts +1 -1
  289. package/lib/packageVersion.d.ts.map +1 -1
  290. package/lib/packageVersion.js +1 -1
  291. package/lib/packageVersion.js.map +1 -1
  292. package/lib/shared-tree/independentView.d.ts +17 -4
  293. package/lib/shared-tree/independentView.d.ts.map +1 -1
  294. package/lib/shared-tree/independentView.js +9 -3
  295. package/lib/shared-tree/independentView.js.map +1 -1
  296. package/lib/shared-tree/index.d.ts +2 -1
  297. package/lib/shared-tree/index.d.ts.map +1 -1
  298. package/lib/shared-tree/index.js +1 -0
  299. package/lib/shared-tree/index.js.map +1 -1
  300. package/lib/shared-tree/schematizingTreeView.d.ts +9 -0
  301. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  302. package/lib/shared-tree/schematizingTreeView.js +31 -16
  303. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  304. package/lib/shared-tree/serializedChange.d.ts +41 -0
  305. package/lib/shared-tree/serializedChange.d.ts.map +1 -0
  306. package/lib/shared-tree/serializedChange.js +84 -0
  307. package/lib/shared-tree/serializedChange.js.map +1 -0
  308. package/lib/shared-tree/sharedTree.d.ts +13 -0
  309. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  310. package/lib/shared-tree/sharedTree.js +2 -0
  311. package/lib/shared-tree/sharedTree.js.map +1 -1
  312. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
  313. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  314. package/lib/shared-tree/sharedTreeChangeFamily.js +7 -1
  315. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  316. package/lib/shared-tree/transactionMinimize.d.ts +35 -0
  317. package/lib/shared-tree/transactionMinimize.d.ts.map +1 -0
  318. package/lib/shared-tree/transactionMinimize.js +62 -0
  319. package/lib/shared-tree/transactionMinimize.js.map +1 -0
  320. package/lib/shared-tree/treeCheckout.d.ts +3 -1
  321. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  322. package/lib/shared-tree/treeCheckout.js +18 -44
  323. package/lib/shared-tree/treeCheckout.js.map +1 -1
  324. package/lib/shared-tree-core/editManager.d.ts +6 -3
  325. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  326. package/lib/shared-tree-core/editManager.js +36 -15
  327. package/lib/shared-tree-core/editManager.js.map +1 -1
  328. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
  329. package/lib/shared-tree-core/editManagerFormatCommons.js +1 -1
  330. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  331. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
  332. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  333. package/lib/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  334. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  335. package/lib/shared-tree-core/messageFormat.d.ts +1 -1
  336. package/lib/shared-tree-core/messageFormat.js +1 -1
  337. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  338. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
  339. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  340. package/lib/shared-tree-core/messageFormatVSharedBranches.js +1 -0
  341. package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  342. package/lib/shared-tree-core/messageTypes.d.ts +1 -0
  343. package/lib/shared-tree-core/messageTypes.d.ts.map +1 -1
  344. package/lib/shared-tree-core/messageTypes.js.map +1 -1
  345. package/lib/shared-tree-core/sharedTreeCore.d.ts +9 -3
  346. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  347. package/lib/shared-tree-core/sharedTreeCore.js +25 -12
  348. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  349. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  350. package/lib/shared-tree-core/transaction.js +16 -2
  351. package/lib/shared-tree-core/transaction.js.map +1 -1
  352. package/lib/simple-tree/api/configuration.d.ts +32 -2
  353. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  354. package/lib/simple-tree/api/configuration.js +4 -2
  355. package/lib/simple-tree/api/configuration.js.map +1 -1
  356. package/lib/simple-tree/api/index.d.ts +2 -2
  357. package/lib/simple-tree/api/index.d.ts.map +1 -1
  358. package/lib/simple-tree/api/index.js +1 -1
  359. package/lib/simple-tree/api/index.js.map +1 -1
  360. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +13 -25
  361. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  362. package/lib/simple-tree/api/schemaCompatibilityTester.js +32 -43
  363. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  364. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
  365. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  366. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  367. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
  368. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  369. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  370. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  371. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +2 -3
  372. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  373. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  374. package/lib/simple-tree/api/storedSchema.js +2 -3
  375. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  376. package/lib/simple-tree/api/tree.d.ts +80 -3
  377. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  378. package/lib/simple-tree/api/tree.js.map +1 -1
  379. package/lib/simple-tree/api/typesUnsafe.d.ts +2 -2
  380. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  381. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  382. package/lib/simple-tree/core/index.d.ts +1 -1
  383. package/lib/simple-tree/core/index.d.ts.map +1 -1
  384. package/lib/simple-tree/core/index.js +1 -1
  385. package/lib/simple-tree/core/index.js.map +1 -1
  386. package/lib/simple-tree/core/toStored.d.ts +72 -6
  387. package/lib/simple-tree/core/toStored.d.ts.map +1 -1
  388. package/lib/simple-tree/core/toStored.js +24 -0
  389. package/lib/simple-tree/core/toStored.js.map +1 -1
  390. package/lib/simple-tree/index.d.ts +3 -3
  391. package/lib/simple-tree/index.d.ts.map +1 -1
  392. package/lib/simple-tree/index.js +3 -3
  393. package/lib/simple-tree/index.js.map +1 -1
  394. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +83 -4
  395. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  396. package/lib/simple-tree/node-kinds/array/arrayNode.js +39 -0
  397. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  398. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  399. package/lib/simple-tree/prepareForInsertion.js +9 -0
  400. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  401. package/lib/simple-tree/simpleSchemaFormatV1.js +1 -1
  402. package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  403. package/lib/simple-tree/toStoredSchema.d.ts +11 -27
  404. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  405. package/lib/simple-tree/toStoredSchema.js +24 -33
  406. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  407. package/lib/treeFactory.js +1 -1
  408. package/lib/treeFactory.js.map +1 -1
  409. package/lib/util/breakable.d.ts +16 -1
  410. package/lib/util/breakable.d.ts.map +1 -1
  411. package/lib/util/breakable.js +9 -1
  412. package/lib/util/breakable.js.map +1 -1
  413. package/lib/util/compressedIds.d.ts +69 -2
  414. package/lib/util/compressedIds.d.ts.map +1 -1
  415. package/lib/util/compressedIds.js +30 -0
  416. package/lib/util/compressedIds.js.map +1 -1
  417. package/lib/util/index.d.ts +2 -2
  418. package/lib/util/index.d.ts.map +1 -1
  419. package/lib/util/index.js +2 -2
  420. package/lib/util/index.js.map +1 -1
  421. package/lib/util/nestedMap.d.ts.map +1 -1
  422. package/lib/util/nestedMap.js +17 -4
  423. package/lib/util/nestedMap.js.map +1 -1
  424. package/lib/util/nestedSet.d.ts +1 -1
  425. package/lib/util/nestedSet.d.ts.map +1 -1
  426. package/lib/util/nestedSet.js.map +1 -1
  427. package/lib/util/utils.d.ts +0 -6
  428. package/lib/util/utils.d.ts.map +1 -1
  429. package/lib/util/utils.js +0 -13
  430. package/lib/util/utils.js.map +1 -1
  431. package/package.json +22 -22
  432. package/src/componentApi.ts +354 -0
  433. package/src/entrypoints/alpha.ts +6 -0
  434. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +6 -27
  435. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -2
  436. package/src/feature-libraries/chunked-forest/codec/codecs.ts +17 -44
  437. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
  438. package/src/feature-libraries/index.ts +2 -0
  439. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +51 -7
  440. package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -1
  441. package/src/feature-libraries/modular-schema/index.ts +5 -2
  442. package/src/feature-libraries/modular-schema/minimizeModularChange.ts +33 -0
  443. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +16 -1
  444. package/src/feature-libraries/optional-field/optionalField.ts +43 -3
  445. package/src/feature-libraries/schemaChecker.ts +86 -9
  446. package/src/feature-libraries/sequence-field/filterEdits.ts +143 -0
  447. package/src/feature-libraries/sequence-field/markQueue.ts +28 -11
  448. package/src/feature-libraries/sequence-field/moveEffectTable.ts +2 -7
  449. package/src/feature-libraries/sequence-field/sequenceFieldChangeRebaser.ts +3 -5
  450. package/src/index.ts +6 -0
  451. package/src/packageVersion.ts +1 -1
  452. package/src/shared-tree/independentView.ts +35 -5
  453. package/src/shared-tree/index.ts +3 -0
  454. package/src/shared-tree/schematizingTreeView.ts +52 -20
  455. package/src/shared-tree/serializedChange.ts +127 -0
  456. package/src/shared-tree/sharedTree.ts +16 -0
  457. package/src/shared-tree/sharedTreeChangeFamily.ts +7 -1
  458. package/src/shared-tree/transactionMinimize.ts +74 -0
  459. package/src/shared-tree/treeCheckout.ts +42 -57
  460. package/src/shared-tree-core/editManager.ts +42 -6
  461. package/src/shared-tree-core/editManagerFormatCommons.ts +1 -1
  462. package/src/shared-tree-core/messageCodecVSharedBranches.ts +8 -1
  463. package/src/shared-tree-core/messageFormat.ts +1 -1
  464. package/src/shared-tree-core/messageFormatVSharedBranches.ts +10 -0
  465. package/src/shared-tree-core/messageTypes.ts +1 -0
  466. package/src/shared-tree-core/sharedTreeCore.ts +33 -10
  467. package/src/shared-tree-core/transaction.ts +19 -2
  468. package/src/simple-tree/api/configuration.ts +40 -2
  469. package/src/simple-tree/api/index.ts +2 -1
  470. package/src/simple-tree/api/schemaCompatibilityTester.ts +41 -49
  471. package/src/simple-tree/api/schemaFactoryAlpha.ts +56 -15
  472. package/src/simple-tree/api/schemaFactoryBeta.ts +0 -3
  473. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +2 -3
  474. package/src/simple-tree/api/storedSchema.ts +2 -3
  475. package/src/simple-tree/api/tree.ts +82 -3
  476. package/src/simple-tree/api/typesUnsafe.ts +2 -1
  477. package/src/simple-tree/core/index.ts +2 -1
  478. package/src/simple-tree/core/toStored.ts +95 -8
  479. package/src/simple-tree/index.ts +4 -3
  480. package/src/simple-tree/node-kinds/array/arrayNode.ts +168 -4
  481. package/src/simple-tree/prepareForInsertion.ts +12 -0
  482. package/src/simple-tree/simpleSchemaFormatV1.ts +1 -1
  483. package/src/simple-tree/toStoredSchema.ts +44 -39
  484. package/src/treeFactory.ts +1 -1
  485. package/src/util/breakable.ts +8 -1
  486. package/src/util/compressedIds.ts +90 -2
  487. package/src/util/index.ts +3 -1
  488. package/src/util/nestedMap.ts +21 -4
  489. package/src/util/nestedSet.ts +1 -1
  490. package/src/util/utils.ts +0 -18
@@ -9,7 +9,7 @@ import * as semver from "semver-ts";
9
9
  import { toInitialSchema } from "../toStoredSchema.js";
10
10
  import { createTreeSchema } from "../treeSchema.js";
11
11
  import { TreeViewConfigurationAlpha, TreeViewConfiguration } from "./configuration.js";
12
- import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
12
+ import { checkSchemaCompatibility } from "./schemaCompatibilityTester.js";
13
13
  import { generateSchemaFromSimpleSchema } from "./schemaFromSimple.js";
14
14
  import { decodeSchemaCompatibilitySnapshot, encodeSchemaCompatibilitySnapshot, } from "./simpleSchemaCodec.js";
15
15
  /**
@@ -66,8 +66,7 @@ import { decodeSchemaCompatibilitySnapshot, encodeSchemaCompatibilitySnapshot, }
66
66
  export function checkCompatibility(viewWhichCreatedStoredSchema, view) {
67
67
  const viewAsAlpha = new TreeViewConfigurationAlpha({ schema: view.schema });
68
68
  const stored = toInitialSchema(viewWhichCreatedStoredSchema.schema);
69
- const tester = new SchemaCompatibilityTester(viewAsAlpha);
70
- return tester.checkCompatibility(stored);
69
+ return checkSchemaCompatibility(viewAsAlpha, stored);
71
70
  }
72
71
  /**
73
72
  * Returns a JSON compatible representation of the tree schema for snapshot compatibility checking.
@@ -1 +1 @@
1
- {"version":3,"file":"snapshotCompatibilityChecker.js","sourceRoot":"","sources":["../../../src/simple-tree/api/snapshotCompatibilityChecker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACvF,OAAO,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,CAAC,iBAAiB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/E,CAAC;CACD;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC/B,iBAAwC,EACxC,kBAAyC;IAEzC,MAAM,4BAA4B,GAAG,kBAAkB,CACtD,kBAAkB,EAClB,iBAAiB,CACjB,CAAC;IAEF,MAAM,2BAA2B,GAAG,kBAAkB,CACrD,iBAAiB,EACjB,kBAAkB,CAClB,CAAC;IAEF,MAAM,CACL,4BAA4B,CAAC,YAAY,KAAK,2BAA2B,CAAC,YAAY,EACtF,KAAK,CAAC,kCAAkC,CACxC,CAAC;IAEF,yHAAyH;IACzH,MAAM,sBAAsB,GAC3B,IAAI,CAAC,SAAS,CAAC,iCAAiC,CAAC,iBAAiB,CAAC,CAAC;QACpE,IAAI,CAAC,SAAS,CAAC,iCAAiC,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAEvE,IAAI,sBAAsB,EAAE,CAAC;QAC5B,MAAM,CACL,4BAA4B,CAAC,YAAY,EACzC,KAAK,CAAC,iEAAiE,CACvE,CAAC;IACH,CAAC;IAED,OAAO;QACN,6BAA6B,EAAE,4BAA4B;QAC3D,6BAA6B,EAAE,2BAA2B;QAC1D,sBAAsB;KACtB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail, transformMapValues } from \"@fluidframework/core-utils/internal\";\nimport { selectVersionRoundedDown } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport * as semver from \"semver-ts\";\n\nimport type { JsonCompatibleReadOnly } from \"../../util/index.js\";\nimport { toInitialSchema } from \"../toStoredSchema.js\";\nimport { createTreeSchema } from \"../treeSchema.js\";\n\nimport { TreeViewConfigurationAlpha, TreeViewConfiguration } from \"./configuration.js\";\nimport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nimport { generateSchemaFromSimpleSchema } from \"./schemaFromSimple.js\";\nimport {\n\tdecodeSchemaCompatibilitySnapshot,\n\tencodeSchemaCompatibilitySnapshot,\n} from \"./simpleSchemaCodec.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Compute the compatibility of using `view` to {@link ViewableTree.viewWith | view a tree} who's {@link ITreeAlpha.exportSimpleSchema | stored schema} could be derived from `viewWhichCreatedStoredSchema` via either {@link TreeView.initialize} or {@link TreeView.upgradeSchema}.\n *\n * @remarks See {@link SchemaCompatibilityStatus} for details on the compatibility results.\n *\n * @example This example demonstrates checking the compatibility of a historical schema against a current schema.\n * In this case, the historical schema is a Point2D object with x and y fields, while the current schema is a Point3D object\n * that adds an optional z field.\n *\n * ```ts\n * // This snapshot is assumed to be the same as Point3D, except missing `z`.\n * const encodedSchema = JSON.parse(fs.readFileSync(\"PointSchema.json\", \"utf8\"));\n * const oldViewSchema = importCompatibilitySchemaSnapshot(encodedSchema);\n *\n * // Build the current view schema\n * class Point3D extends factory.object(\"Point\", {\n * \tx: factory.number,\n * \ty: factory.number,\n *\n * \t// The current schema has a new optional field that was not present on Point2D\n * \tz: factory.optional(factory.number),\n * }) {}\n * const currentViewSchema = new TreeViewConfiguration({ schema: Point3D });\n *\n * // Check to see if the document created by the historical view schema can be opened with the current view schema\n * const backwardsCompatibilityStatus = checkCompatibility(oldViewSchema, currentViewSchema);\n *\n * // z is not present in Point2D, so the schema must be upgraded\n * assert.equal(backwardsCompatibilityStatus.canView, false);\n *\n * // The schema can be upgraded to add the new optional field\n * assert.equal(backwardsCompatibilityStatus.canUpgrade, true);\n *\n * // Test what the old version of the application would do with a tree using the new schema:\n * const forwardsCompatibilityStatus = checkCompatibility(currentViewSchema, oldViewSchema);\n *\n * // If the old schema set allowUnknownOptionalFields, this would be true, but since it did not,\n * // this assert will fail, detecting the forwards compatibility break:\n * // this means these two versions of the application cannot collaborate on content using these schema.\n * assert.equal(forwardsCompatibilityStatus.canView, true);\n * ```\n *\n * @param viewWhichCreatedStoredSchema - From which to derive the stored schema, as if it initialized or upgraded a tree via {@link TreeView}.\n * @param view - The view being tested to see if it could view tree created or initialized using `viewWhichCreatedStoredSchema`.\n * @returns The compatibility status.\n *\n * @privateRemarks\n * TODO: a simple high level API for snapshot based schema compatibility checking should replace the need to export this.\n *\n * @alpha\n */\nexport function checkCompatibility(\n\tviewWhichCreatedStoredSchema: TreeViewConfiguration,\n\tview: TreeViewConfiguration,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\tconst viewAsAlpha = new TreeViewConfigurationAlpha({ schema: view.schema });\n\tconst stored = toInitialSchema(viewWhichCreatedStoredSchema.schema);\n\tconst tester = new SchemaCompatibilityTester(viewAsAlpha);\n\treturn tester.checkCompatibility(stored);\n}\n\n/**\n * Returns a JSON compatible representation of the tree schema for snapshot compatibility checking.\n *\n * Snapshots can be loaded by the same or newer package versions, but not necessarily older versions.\n *\n * @see {@link importCompatibilitySchemaSnapshot} which loads these snapshots.\n *\n * @param config - The schema to snapshot. Only the schema field of the `TreeViewConfiguration` is used.\n * @returns The JSON representation of the schema.\n *\n * @example This example creates and persists a snapshot of a Point2D schema.\n *\n * ```ts\n * const schemaFactory = new SchemaFactory(\"test\");\n * class Point2D extends schemaFactory.object(\"Point\", {\n * \tx: factory.number,\n * \ty: factory.number,\n * }) {}\n * const viewSchema = new TreeViewConfiguration({ schema: Point2D });\n * const encodedSchema = JSON.stringify(exportCompatibilitySchemaSnapshot(viewSchema));\n * fs.writeFileSync(\"PointSchema.json\", encodedSchema);\n * ```\n *\n * @privateRemarks\n * TODO: a simple high level API for snapshot based schema compatibility checking should replace the need to export this.\n *\n * @alpha\n */\nexport function exportCompatibilitySchemaSnapshot(\n\tconfig: Pick<TreeViewConfiguration, \"schema\">,\n): JsonCompatibleReadOnly {\n\tconst treeSchema = createTreeSchema(config.schema);\n\treturn encodeSchemaCompatibilitySnapshot(treeSchema);\n}\n\n/**\n * Parse the format exported by {@link exportCompatibilitySchemaSnapshot} into a schema.\n *\n * Can load snapshots created by the same or older package versions, but not necessarily newer versions.\n *\n * @see {@link exportCompatibilitySchemaSnapshot} which creates these snapshots.\n *\n * @param config - The JSON representation of the schema.\n * @returns The schema. Only the schema field of the {@link TreeViewConfiguration} is populated.\n * @throws Will throw a usage error if the encoded schema is not in the expected format.\n *\n * @example This example loads and parses a snapshot of a Point2D schema.\n *\n * ```ts;\n * const oldViewSchema = importCompatibilitySchemaSnapshot(fs.readFileSync(\"PointSchema.json\", \"utf8\"));\n * ```\n * @privateRemarks\n * TODO: a simple high level API for snapshot based schema compatibility checking should replace the need to export this.\n * @alpha\n */\nexport function importCompatibilitySchemaSnapshot(\n\tconfig: JsonCompatibleReadOnly,\n): TreeViewConfiguration {\n\tconst simpleSchema = decodeSchemaCompatibilitySnapshot(config);\n\tconst viewSchema = generateSchemaFromSimpleSchema(simpleSchema);\n\n\t// We construct a TreeViewConfiguration here with the default parameters. The default set of validation parameters are fine for\n\t// a schema produced by `generateSchemaFromSimpleSchema`.\n\treturn new TreeViewConfiguration({ schema: viewSchema.root });\n}\n\n/**\n * The file system methods required by {@link snapshotSchemaCompatibility}.\n * @remarks\n * Implemented by both Node.js `fs` and `path` modules, but other implementations can be provided as needed.\n *\n * @example\n * ```typescript\n * import path from \"node:path\";\n * import fs from \"node:fs\";\n *\n * const nodeFileSystem: SnapshotFileSystem = { ...fs, ...path };\n * ```\n *\n * @privateRemarks\n * This interface is designed to be compatible with Node.js `fs` and `path` modules.\n * It is needed to avoid direct dependencies on Node.js APIs in the core library code,\n * allowing for greater portability and easier testing.\n *\n * @input\n * @beta\n */\nexport interface SnapshotFileSystem {\n\t/**\n\t * Writes a UTF-8 encoded file to disk, replacing the file if it already exists.\n\t *\n\t * @param file - Path to the file to write.\n\t * @param data - String data to be written.\n\t * @param options - Options specifying that the encoding is UTF-8.\n\t */\n\twriteFileSync(file: string, data: string, options: { encoding: \"utf8\" }): void;\n\n\t/**\n\t * Reads a UTF-8 encoded file from disk and returns its contents as a string.\n\t *\n\t * @param file - Path to the file to read.\n\t * @param encoding - The text encoding to use when reading the file. Must be `\"utf8\"`.\n\t * @returns The contents of the file as a string.\n\t */\n\t// We include the encoding here to match the function overload for readFileSync that returns a string.\n\treadFileSync(file: string, encoding: \"utf8\"): string;\n\n\t/**\n\t * How a {@link TreeView} using the snapshotted schema would report its compatibility with a document created with the current schema.\n\t *\n\t * @param dir - Path of the directory to create.\n\t * @param options - Options indicating that creation should be recursive.\n\t */\n\tmkdirSync(dir: string, options: { recursive: true }): void;\n\n\t/**\n\t * Reads the contents of a directory.\n\t *\n\t * @param dir - Path of the directory to read.\n\t * @returns An array of names of the directory entries.\n\t */\n\treaddirSync(dir: string): readonly string[];\n\n\t/**\n\t * Joins two path segments into a single path string.\n\t *\n\t * @param parentPath - The directory path.\n\t * @param childPath - Filename within `parentPath` directory.\n\t * @returns The combined path string.\n\t */\n\tjoin(parentPath: string, childPath: string): string;\n}\n\n/**\n * The combined compatibility status for both backwards and forwards compatibility checks.\n */\nexport interface CombinedSchemaCompatibilityStatus {\n\t/**\n\t * How a {@link TreeView} using the current schema would report its compatibility with the historical snapshot.\n\t */\n\treadonly currentViewOfSnapshotDocument: Omit<SchemaCompatibilityStatus, \"canInitialize\">;\n\t/**\n\t * How a {@link TreeView} using the snapshotted schema would report its compatibility with a document created with the current schema.\n\t */\n\treadonly snapshotViewOfCurrentDocument: Omit<SchemaCompatibilityStatus, \"canInitialize\">;\n\n\t/**\n\t * True if and only if the schema have identical compatibility.\n\t * @remarks\n\t * This includes producing the equivalent stored schema (which currentViewOfSnapshotDocument and snapshotViewOfCurrentDocument also measure)\n\t * as well as equivalent compatibility with potential future schema changes beyond just those in these two schema.\n\t *\n\t * This includes compatibility with all potential future schema changes.\n\t * For example two schema different only in compatibility with future optional fields via allow unknown optional fields or staged schema\n\t * would be considered non-equivalent, even though they are forwards and backwards compatible with each other, and both status above report them as equivalent\n\t * since they would produce the same stored schema upon schema upgrade.\n\t */\n\treadonly identicalCompatibility: boolean;\n}\n\n/**\n * The options for {@link snapshotSchemaCompatibility}.\n * @input\n * @beta\n */\nexport interface SnapshotSchemaCompatibilityOptions {\n\t/**\n\t * Directory where historical schema snapshots are stored.\n\t * @remarks\n\t * As the contents of this directory (specifically historical snapshots) cannot be regenerated,\n\t * a directory appropriate for test data should be used.\n\t * Generally this means that this directory should be versioned like code,\n\t * and not erased when regenerating snapshots.\n\t *\n\t * This directory will be created if it does not already exist.\n\t * All \".json\" files in this directory will be treated as schema snapshots.\n\t * It is recommended to use a dedicated directory for each {@link snapshotSchemaCompatibility} powered test.\n\t *\n\t * This can use any path syntax supported by the provided {@link SnapshotSchemaCompatibilityOptions.fileSystem}.\n\t */\n\treadonly snapshotDirectory: string;\n\n\t/**\n\t * How the `snapshotDirectory` is accessed.\n\t */\n\treadonly fileSystem: SnapshotFileSystem;\n\n\t/**\n\t * The current view schema.\n\t */\n\treadonly schema: TreeViewConfiguration;\n\n\t/**\n\t * The version which will be associated with this version of the schema.\n\t * @remarks\n\t * Often the easiest way to ensure this is to simply use the next version which will be released for the package or application itself, and set the `minVersionForCollaboration` based on telemetry about which versions are still in use.\n\t * To do this, it is recommended that this version be programmatically derived from the application version rather than hard coded inline.\n\t * For example, reading it from the `package.json` or some other source of truth can be done to ensure it is kept up to date, and thus snapshots always have the correct version.\n\t * The version used should typically be the _next_ production version (whose formats must be supported long term) that will be released (but is not yet released).\n\t * This usually means that the correct version to use is the same version that would be used when releasing the application or library, but with any prerelease version tags removed.\n\t * If an automated way to keep this version up to date is not used, be very careful when reviewing changes to snapshot files to ensure the version is correct.\n\t * If incorrectly versioned snapshots were committed accidentally, rename the snapshot files to have the correct version, and restore the old files from, version control.\n\t *\n\t * It is possible to use a different versioning scheme, for example one specific to the schema in question.\n\t * This can be done robustly as long as care is taken to ensure the version increases such that every released version has a unique `version` (and therefore unique snapshot),\n\t * and `minVersionForCollaboration` is set appropriately using the same versioning scheme.\n\t * {@link SnapshotSchemaCompatibilityOptions.rejectVersionsWithNoSchemaChange} and\n\t * {@link SnapshotSchemaCompatibilityOptions.rejectSchemaChangesWithNoVersionChange}\n\t * can be used to help enforce the expected relationship between version changes and schema changes in such cases.\n\t *\n\t * Can use any format supported by {@link SnapshotSchemaCompatibilityOptions.versionComparer}.\n\t * Only compared against the version from previous snapshots (taken from this version when they were created by setting `mode` to \"update\") and the `minVersionForCollaboration`.\n\t *\n\t * Typically `minVersionForCollaboration` should be set to the oldest version currently in use, so it's helpful to use a version which can be easily measured to tell if clients are still using it.\n\t */\n\treadonly version: string;\n\n\t/**\n\t * The minimum version that the current version is expected to be able to collaborate with.\n\t * @remarks\n\t * Can use any format supported by {@link SnapshotSchemaCompatibilityOptions.versionComparer}.\n\t *\n\t * This defines a range of versions whose schema must be forwards compatible with trees using the current schema:\n\t * Any schema from snapshots with a version greater than or equal to this must be able to view documents created with the current schema.\n\t * This means that if the current `schema` is used to create a {@link TreeView}, then {@link TreeView.upgradeSchema} is used, the older clients,\n\t * all the way back to this `minVersionForCollaboration` will be able to view and edit the tree using their schema and thus collaborate.\n\t *\n\t * Typically applications will attempt to manage their deployment/update schedule such that all versions concurrently deployed can\n\t * collaborate to avoid users losing access to documents when other users upgrade the schema.\n\t * Such applications can set this to the oldest version currently deployed,\n\t * then rely on {@link snapshotSchemaCompatibility} to verify that no schema changes are made which would break collaboration with that (or newer) versions.\n\t *\n\t * This is the same approach used by {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}\n\t * except that type is specifically for use with the version of the Fluid Framework client packages,\n\t * and this corresponds to whatever versioning scheme is used with {@link SnapshotSchemaCompatibilityOptions.version}.\n\t */\n\treadonly minVersionForCollaboration: string;\n\n\t/**\n\t * A comparison function for version strings.\n\t * @remarks\n\t * A comparison function like that provided to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#comparefn | Array.sort}.\n\t * This is used to partition snapshots into those less than `minVersionForCollaboration` and those greater than or equal to it, as well as to sanity check `version` against the versions of the snapshots.\n\t * If not provided, the ordering is defined by {@link https://semver.org/#spec-item-11|semver}.\n\t * @returns A negative number if `a` is less than `b`, zero if they are equal, or a positive number if `a` is greater than `b`.\n\t */\n\treadonly versionComparer?: (a: string, b: string) => number;\n\n\t/**\n\t * When true, every version must be snapshotted, and an increased version number will require a new snapshot.\n\t * @remarks\n\t * If this is true, it is assumed there is a snapshot for every release, and thus it is required that the `minVersionForCollaboration` refer to a version which has a snapshot.\n\t * When this is not true, versions without snapshots are assumed to have the same schema as the latest previous version which has a snapshot, and thus `minVersionForCollaboration`\n\t * can refer to versions between snapshots and will get its schema from the preceding version.\n\t */\n\treadonly snapshotUnchangedVersions?: true;\n\n\t/**\n\t * When true, it is an error if a new a snapshot for a new version would be created, but the schema compatibility is identical to the previous snapshot.\n\t * @remarks\n\t * This prevents creating a snapshot with the same schema compatibility results as the previous one.\n\t *\n\t * Applications and libraries which do not have versioned releases can make up a version specific to the compatibility of the schema, and use this option to help ensure they manage that version correctly.\n\t * Such cases can also opt into {@link SnapshotSchemaCompatibilityOptions.rejectSchemaChangesWithNoVersionChange} if they want additional strictness.\n\t */\n\treadonly rejectVersionsWithNoSchemaChange?: true;\n\n\t/**\n\t * When true, it is an error if a schema change occurs without a corresponding version change.\n\t * @remarks\n\t * This disables overwriting existing snapshots.\n\t * This option is recommended if the {@link SnapshotSchemaCompatibilityOptions.version} is not automatically updated ahead of releasing a version which must be supported.\n\t * If updating the snapshot is still desired, the preceding one which needs to be overwritten can be manually deleted before running the update.\n\t *\n\t * This option does not impact the behavior of assert mode (other than impacting what error is given).\n\t * This option simply makes update mode more strict, converting cases that would overwrite a snapshot in place into errors.\n\t */\n\treadonly rejectSchemaChangesWithNoVersionChange?: true;\n\n\t/**\n\t * The mode of operation, either \"assert\" or \"update\".\n\t * @remarks\n\t * Both modes will throw errors if any compatibility issues are detected (but after updating snapshots in \"update\" mode so the diff can be used to help debug).\n\t *\n\t * In \"assert\" mode, an error is additionally thrown if the latest snapshot is not up to date (meaning \"update\" mode would make a change).\n\t *\n\t * In \"update\" mode, a new snapshot is created if the current schema differs from the latest existing snapshot.\n\t * If {@link SnapshotSchemaCompatibilityOptions.rejectVersionsWithNoSchemaChange} or\n\t * {@link SnapshotSchemaCompatibilityOptions.rejectSchemaChangesWithNoVersionChange} disallows the update, an error is thrown instead.\n\t *\n\t * It is recommended that \"assert\" mode be used in automated tests to verify schema compatibility,\n\t * and \"update\" mode only be used manually to update snapshots when making schema or version changes.\n\t *\n\t * @privateRemarks\n\t * Modes we might want to add in the future:\n\t * - normalize: update the latest snapshot (or maybe all of them) to the latest encoded format.\n\t * - some mode like assert but returns information instead of throwing.\n\t */\n\treadonly mode: \"assert\" | \"update\";\n}\n\n/**\n * Check `currentViewSchema` for compatibility with a collection of historical schema snapshots stored in `snapshotDirectory`.\n *\n * @throws Throws errors if the input version strings (including those in snapshot file names) are not valid semver versions when using default semver version comparison.\n * @throws Throws errors if the input version strings (including those in snapshot file names) are not ordered as expected (current being the highest, and `minVersionForCollaboration` corresponding to the current version or a lower snapshotted version).\n * @throws In `test` mode, throws an error if there is not an up to date snapshot for the current version.\n * @throws Throws an error if any snapshotted schema cannot be upgraded to the current schema.\n * @throws Throws an error if any snapshotted schema with a version greater than or equal to `minVersionForCollaboration` cannot view documents created with the current schema.\n * @remarks\n * This is intended for use in snapshot-based schema compatibility tests.\n * Every SharedTree-based component or application with a schema is recommended to use this to verify schema compatibility across versions.\n *\n * Schema snapshots should be added to `snapshotDirectory` using this function in \"update\" mode whenever the schema changes in a compatibility impacting way\n * (or when `snapshotUnchangedVersions` is true and a new version about to be released is getting prepared for release (and thus `version` changed)).\n *\n * This will throw an exception if any snapshotted schema would result in documents that cannot be viewed (after using {@link TreeView.upgradeSchema}), or if any schema with a version greater than or equal to `minVersionForCollaboration` cannot view documents created with the `currentViewSchema`.\n * See {@link TreeView.compatibility} for more information.\n *\n * Proper use of this utility should do a good job at detecting schema compatibility issues,\n * however it currently does not do a good job of explaining exactly what change to the schema is causing the compatibility issues.\n * This is a known limitation that will be improved in future releases.\n * These improvements, as well as other changes, may change the exact messages produced by this function in the error cases: no stability of these messages should be assumed.\n *\n * Unlike some other snapshot based testing tools, this stores more than just the current snapshot: historical snapshots are retained as well.\n * Retention of these additional historical snapshots, whose content can't be regenerated from the current schema, is necessary to properly test compatibility across versions.\n * Since there is content in the snapshots which cannot be regenerated, tools which assume all snapshotted content can be regenerated cannot be used here.\n * This means that tools like Jest's built in snapshot testing are not suitable for this purpose.\n * These snapshots behave partly like test data, and partly like snapshots.\n * Typically the easiest way to manage this is to place {@link SnapshotSchemaCompatibilityOptions.snapshotDirectory} inside a directory appropriate for test data,\n * and use node to provide the filesystem access via {@link SnapshotSchemaCompatibilityOptions.fileSystem}.\n *\n * For now, locating what change broke compatibility is likely best discovered by making small schema changes one at a time and updating the snapshot and reviewing the diffs.\n * Details for what kinds of changes are breaking and in which ways can be found in the documentation for {@link TreeView.compatibility} and\n * {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution/ | schema-evolution}.\n *\n * This utility does not enforce anything with respect to API compatibility, or special semantics for major, minor, or patch versions.\n * Libraries which export schema for use by others will need to take special care to ensure the stability contract they offer their users aligns which what is validated by this utility.\n *\n * This utility only tests compatibility of the historical snapshots against the current schema; it does not test them against each-other.\n * Generally any historical schemas should have been tested against the ones before them at the time they were current.\n * If for some reason a version of a schema made it into production that was not compatible with a previous version,\n * that can still be represented here (but may require manually generating a snapshot for that version)\n * and this will still allow testing that all historical version can be upgraded to the current one.\n * If a sufficiently incompatible historical schemas were used in production, it may be impossible to make a single schema which can accommodate all of them:\n * this utility can be used to confirm that is the case, as well as to avoid the problem in the first place by testing schema before each one is deployed.\n *\n * @example Mocha test which validates the current `config` can collaborate with all historical version back to 2.0.0, and load and update any versions older than that.\n * ```typescript\n * it(\"schema compatibility\", () => {\n * \tsnapshotSchemaCompatibility({\n * \t\tversion: pkgVersion,\n * \t\tschema: config,\n * \t\tfileSystem: { ...fs, ...path },\n * \t\tminVersionForCollaboration: \"2.0.0\",\n * \t\tmode: process.argv.includes(\"--snapshot\") ? \"update\" : \"test\",\n * \t\tsnapshotDirectory,\n * \t});\n * });\n * ```\n * @example Complete Mocha test file\n * ```typescript\n * import fs from \"node:fs\";\n * import path from \"node:path\";\n *\n * import { snapshotSchemaCompatibility } from \"@fluidframework/tree/beta\";\n *\n * // The TreeViewConfiguration the application uses, which contains the application's schema.\n * import { treeViewConfiguration } from \"./schema.js\";\n * // The next version of the application which will be released.\n * import { packageVersion } from \"./version.js\";\n *\n * // Provide some way to run the check in \"update\" mode when updating snapshots is intended.\n * const regenerateSnapshots = process.argv.includes(\"--snapshot\");\n *\n * // Setup the actual test. In this case using Mocha syntax.\n * describe(\"schema\", () => {\n * \tit(\"schema compatibility\", () => {\n * \t\t// Select a path to save the snapshots in.\n * \t\t// This will depend on how your application organizes its test data.\n * \t\tconst snapshotDirectory = path.join(\n * \t\t\timport.meta.dirname,\n * \t\t\t\"../../../src/test/schema-snapshots\",\n * \t\t);\n * \t\tsnapshotSchemaCompatibility({\n * \t\t\tschema: config,\n * \t\t\tfileSystem: { ...fs, ...path },\n * \t\t\tversion: pkgVersion,\n * \t\t\tminVersionForCollaboration: \"2.0.0\",\n * \t\t\tmode: process.argv.includes(\"--snapshot\") ? \"update\" : \"assert\",\n * \t\t\tsnapshotDirectory,\n * \t\t});\n * \t});\n * });\n * ```\n * @privateRemarks\n * Use of this function within this package (for schema libraries released as part of this package) should use {@link testSchemaCompatibilitySnapshots} instead.\n *\n * This uses the format defined in simpleSchemaCodec.ts.\n * This does include versioning information in the snapshot format,\n * but it would be nice to better unify how we do that versioning and format validation with our codecs.\n *\n * See snapshotCompatibilityChecker.example.mts for the large example included above.\n * @beta\n */\nexport function snapshotSchemaCompatibility(\n\toptions: SnapshotSchemaCompatibilityOptions,\n): void {\n\tconst checker = new SnapshotCompatibilityChecker(\n\t\toptions.snapshotDirectory,\n\t\toptions.fileSystem,\n\t);\n\tconst {\n\t\tversion: currentVersion,\n\t\tschema: currentViewSchema,\n\t\tmode,\n\t\tminVersionForCollaboration,\n\t\tsnapshotUnchangedVersions,\n\t\trejectVersionsWithNoSchemaChange,\n\t\trejectSchemaChangesWithNoVersionChange,\n\t} = options;\n\n\tconst validateVersion =\n\t\toptions.versionComparer === undefined ? semver.valid : (v: string) => v;\n\tconst versionComparer = options.versionComparer ?? semver.compare;\n\n\tif (validateVersion(currentVersion) === null) {\n\t\tthrow new UsageError(\n\t\t\t`Invalid version: ${JSON.stringify(currentVersion)}. Must be a valid semver version.`,\n\t\t);\n\t}\n\tif (validateVersion(minVersionForCollaboration) === null) {\n\t\tthrow new UsageError(\n\t\t\t`Invalid minVersionForCollaboration: ${JSON.stringify(minVersionForCollaboration)}. Must be a valid semver version.`,\n\t\t);\n\t}\n\n\tif (versionComparer(minVersionForCollaboration, currentVersion) > 0) {\n\t\tthrow new UsageError(\n\t\t\t`Invalid minVersionForCollaboration: ${JSON.stringify(minVersionForCollaboration)}. Must be less than or equal to current version ${JSON.stringify(currentVersion)}.`,\n\t\t);\n\t}\n\n\tif (mode !== \"assert\" && mode !== \"update\") {\n\t\tthrow new UsageError(\n\t\t\t`Invalid mode: ${JSON.stringify(mode)}. Must be either \"assert\" or \"update\".`,\n\t\t);\n\t}\n\n\tconst currentEncodedForSnapshotting = exportCompatibilitySchemaSnapshot(currentViewSchema);\n\tconst snapshots = checker.readAllSchemaSnapshots(versionComparer);\n\n\tconst compatibilityErrors: string[] = [];\n\n\tconst contextNotes: string[] = [];\n\n\tfunction errorWithContext(message: string): Error {\n\t\treturn new Error(\n\t\t\t[\n\t\t\t\t\"Schema compatibility check failed:\",\n\t\t\t\tmessage,\n\t\t\t\t`Snapshots in: ${JSON.stringify(options.snapshotDirectory)}`,\n\t\t\t\t`Snapshots exist for versions: ${JSON.stringify([...snapshots.keys()], undefined, \"\\t\")}.`,\n\t\t\t\t...contextNotes,\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t}\n\n\tconst compatibilityMap = transformMapValues(snapshots, (snapshot) =>\n\t\tgetCompatibility(currentViewSchema, snapshot),\n\t);\n\n\t// Either:\n\t// - false: no update needed\n\t// - the updateError message (update in update mode, error otherwise)\n\t// - an error if the update is disallowed by the flags\n\tlet wouldUpdate: false | string | Error;\n\n\t// Set wouldUpdate\n\t{\n\t\tconst latestSnapshot = [...snapshots][snapshots.size - 1];\n\t\tif (latestSnapshot === undefined) {\n\t\t\twouldUpdate = `No snapshots found.`;\n\t\t} else {\n\t\t\tconst latestCompatibility =\n\t\t\t\tcompatibilityMap.get(latestSnapshot[0]) ??\n\t\t\t\tfail(0xcd1 /* missing compatibilityMap entry */);\n\n\t\t\tconst schemaChange = !latestCompatibility.identicalCompatibility;\n\t\t\tconst versionChange = versionComparer(latestSnapshot[0], currentVersion) !== 0;\n\n\t\t\tif (rejectVersionsWithNoSchemaChange === true && versionChange && !schemaChange) {\n\t\t\t\twouldUpdate = errorWithContext(\n\t\t\t\t\t`Rejecting version change (${JSON.stringify(latestSnapshot[0])} to ${JSON.stringify(currentVersion)}) due to rejectVersionsWithNoSchemaChange being set.`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\trejectSchemaChangesWithNoVersionChange === true &&\n\t\t\t\tschemaChange &&\n\t\t\t\t!versionChange\n\t\t\t) {\n\t\t\t\twouldUpdate = errorWithContext(\n\t\t\t\t\t`Rejecting schema change without version change due to existing non-equivalent snapshot for version (${JSON.stringify(latestSnapshot[0])} due to rejectSchemaChangesWithNoVersionChange being set.`,\n\t\t\t\t);\n\t\t\t} else if (snapshotUnchangedVersions === true) {\n\t\t\t\tconst currentRead = snapshots.get(currentVersion);\n\t\t\t\tif (currentRead === undefined) {\n\t\t\t\t\twouldUpdate = `No snapshot found for version ${JSON.stringify(currentVersion)}: snapshotUnchangedVersions is true, so every version must be snapshotted.`;\n\t\t\t\t} else if (\n\t\t\t\t\tJSON.stringify(exportCompatibilitySchemaSnapshot(currentRead)) ===\n\t\t\t\t\tJSON.stringify(currentEncodedForSnapshotting)\n\t\t\t\t) {\n\t\t\t\t\twouldUpdate = false;\n\t\t\t\t} else {\n\t\t\t\t\twouldUpdate = `Snapshot for current version ${JSON.stringify(currentVersion)} is out of date.`;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (versionComparer(latestSnapshot[0], currentVersion) <= 0) {\n\t\t\t\t\twouldUpdate = schemaChange\n\t\t\t\t\t\t? `Snapshot for current version ${JSON.stringify(currentVersion)} is out of date: schema has changed since latest existing snapshot version ${JSON.stringify(latestSnapshot[0])}.`\n\t\t\t\t\t\t: false;\n\t\t\t\t} else {\n\t\t\t\t\twouldUpdate = errorWithContext(\n\t\t\t\t\t\t`Current version ${JSON.stringify(currentVersion)} is less than latest existing snapshot version ${JSON.stringify(latestSnapshot[0])}: version is expected to increase monotonically.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!schemaChange && (snapshotUnchangedVersions !== true || !versionChange)) {\n\t\t\t\t// eslint-disable-next-line unicorn/no-lonely-if\n\t\t\t\tif (\n\t\t\t\t\tJSON.stringify(exportCompatibilitySchemaSnapshot(latestSnapshot[1])) !==\n\t\t\t\t\tJSON.stringify(currentEncodedForSnapshotting)\n\t\t\t\t) {\n\t\t\t\t\t// Schema are compatibility wise equivalent, but differ in some way (excluding json formatting).\n\t\t\t\t\t// TODO: add a \"normalize\" mode, which do an update only in this case (or maybe even normalize json formatting as well and just always rewrite when !schemaChange)\n\t\t\t\t\t// This would be useful to minimize diffs from future schema changes.\n\t\t\t\t\t// This would be particularly useful if adding a second version of the format used in the snapshots.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (wouldUpdate !== false) {\n\t\tif (wouldUpdate instanceof Error) {\n\t\t\tthrow wouldUpdate;\n\t\t}\n\t\tif (mode === \"update\") {\n\t\t\tchecker.writeSchemaSnapshot(currentVersion, currentEncodedForSnapshotting);\n\t\t\t// Update so errors below will reflect the new snapshot.\n\t\t\tcompatibilityMap.set(\n\t\t\t\tcurrentVersion,\n\t\t\t\tgetCompatibility(currentViewSchema, currentViewSchema),\n\t\t\t);\n\t\t} else {\n\t\t\tcompatibilityErrors.push(\n\t\t\t\t`${wouldUpdate} If this is expected, snapshotSchemaCompatibility can be rerun in \"update\" mode to update or create the snapshot.`,\n\t\t\t);\n\n\t\t\t// This case could update compatibilityMap as well, but it would hide some information about how the existing snapshot might be incompatible with the proposed new one.\n\t\t\t// This lost information could be annoying if the user's intention was not to edit the schema (which is what we assume in assert mode),\n\t\t\t// especially once we produce more detailed error messages that can help users understand what changed in the schema.\n\t\t}\n\t}\n\n\t// Add compatibilityErrors and contextNotes as needed regarding minVersionForCollaboration.\n\t// This is only done when minVersionForCollaboration is not the current version to avoid extra noise in \"assert\" mode\n\t// (which is the only case that could error when minVersionForCollaboration === currentVersion).\n\tif (minVersionForCollaboration !== currentVersion) {\n\t\tif (snapshotUnchangedVersions === true) {\n\t\t\tconst minSnapshot = compatibilityMap.get(minVersionForCollaboration);\n\t\t\tif (minSnapshot === undefined) {\n\t\t\t\tcompatibilityErrors.push(\n\t\t\t\t\t`Using snapshotUnchangedVersions: a snapshot of the exact minVersionForCollaboration ${JSON.stringify(minVersionForCollaboration)} is required. No snapshot found.`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst selectedMinVersionForCollaborationSnapshot = selectVersionRoundedDown(\n\t\t\t\tminVersionForCollaboration,\n\t\t\t\tcompatibilityMap,\n\t\t\t\tversionComparer,\n\t\t\t);\n\t\t\tif (selectedMinVersionForCollaborationSnapshot === undefined) {\n\t\t\t\tcompatibilityErrors.push(\n\t\t\t\t\t`No snapshot found with version less than or equal to minVersionForCollaboration ${JSON.stringify(minVersionForCollaboration)}.`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tselectedMinVersionForCollaborationSnapshot[0] !== minVersionForCollaboration\n\t\t\t) {\n\t\t\t\t// Add an entry to ensure that the version which spans from before until after the cutoff for collaboration is included in the compatibility checks.\n\t\t\t\tcompatibilityMap.set(\n\t\t\t\t\tminVersionForCollaboration,\n\t\t\t\t\tselectedMinVersionForCollaborationSnapshot[1],\n\t\t\t\t);\n\t\t\t\tcontextNotes.push(\n\t\t\t\t\t`Due to snapshotUnchangedVersions being false and minVersionForCollaboration (${JSON.stringify(minVersionForCollaboration)}) not having an exact snapshot, the last snapshot before that version (which is ${JSON.stringify(\n\t\t\t\t\t\tselectedMinVersionForCollaborationSnapshot[0],\n\t\t\t\t\t)}) is being also being checked as if it is version ${JSON.stringify(minVersionForCollaboration)}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Compare all snapshots against the current schema, using the compatibilityMap.\n\tfor (const [snapshotVersion, compatibility] of compatibilityMap) {\n\t\t// Current should be able to view all versions.\n\t\tif (!compatibility.currentViewOfSnapshotDocument.canUpgrade) {\n\t\t\tcompatibilityErrors.push(\n\t\t\t\t`Current version ${JSON.stringify(currentVersion)} cannot upgrade documents from ${JSON.stringify(snapshotVersion)}.`,\n\t\t\t);\n\t\t}\n\n\t\tconst versionComparisonToCurrent = versionComparer(snapshotVersion, currentVersion);\n\t\tif (versionComparisonToCurrent === 0) {\n\t\t\tif (currentVersion !== snapshotVersion) {\n\t\t\t\tthrow errorWithContext(\n\t\t\t\t\t`Snapshot version ${JSON.stringify(snapshotVersion)} is semantically equal but not string equal to current version ${JSON.stringify(currentVersion)}: this is not supported.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (compatibility.identicalCompatibility === false) {\n\t\t\t\tassert(\n\t\t\t\t\twouldUpdate !== false,\n\t\t\t\t\t0xcd2 /* there should have been an error for the snapshot being out of date */,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (versionComparisonToCurrent < 0) {\n\t\t\t// Collaboration with this version is expected to work.\n\t\t\tif (versionComparer(snapshotVersion, minVersionForCollaboration) >= 0) {\n\t\t\t\t// Check that the historical version can view documents from the current version, since collaboration with this one is expected to work.\n\t\t\t\tif (!compatibility.snapshotViewOfCurrentDocument.canView) {\n\t\t\t\t\tcompatibilityErrors.push(\n\t\t\t\t\t\t`Historical version ${JSON.stringify(snapshotVersion)} cannot view documents from ${JSON.stringify(currentVersion)}: these versions are expected to be able to collaborate due to the selected minVersionForCollaboration ${JSON.stringify(minVersionForCollaboration)}.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// This is the case where the historical version is less than the minimum version for collaboration.\n\t\t\t\t// No additional validation is needed here currently, since forwards document compat from these versions is already tested above (since it applies to all snapshots).\n\t\t\t}\n\t\t} else {\n\t\t\tcompatibilityErrors.push(\n\t\t\t\t`Snapshot exists for version ${JSON.stringify(snapshotVersion)} which is greater than the current version ${JSON.stringify(currentVersion)}. This is not supported.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (compatibilityErrors.length > 0) {\n\t\tthrow errorWithContext(compatibilityErrors.map((e) => ` - ${e}`).join(\"\\n\"));\n\t}\n}\n\n/**\n * The high-level API for checking snapshot compatibility and generating new snapshots.\n */\nexport class SnapshotCompatibilityChecker {\n\tpublic constructor(\n\t\t/**\n\t\t * Directory where historical schema snapshots are stored.\n\t\t */\n\t\tprivate readonly snapshotDirectory: string,\n\t\t/**\n\t\t * How the `snapshotDirectory` is accessed.\n\t\t */\n\t\tprivate readonly fileSystemMethods: SnapshotFileSystem,\n\t) {}\n\n\tpublic writeSchemaSnapshot(snapshotName: string, snapshot: JsonCompatibleReadOnly): void {\n\t\tconst fullPath = this.fileSystemMethods.join(\n\t\t\tthis.snapshotDirectory,\n\t\t\t`${snapshotName}.json`,\n\t\t);\n\t\tthis.ensureSnapshotDirectoryExists();\n\t\tthis.fileSystemMethods.writeFileSync(fullPath, JSON.stringify(snapshot, undefined, \"\\t\"), {\n\t\t\tencoding: \"utf8\",\n\t\t});\n\t}\n\n\tpublic readSchemaSnapshot(snapshotName: string): TreeViewConfiguration {\n\t\tconst snapshot = this.readSchemaSnapshotRaw(snapshotName);\n\t\treturn importCompatibilitySchemaSnapshot(snapshot);\n\t}\n\n\tpublic readSchemaSnapshotRaw(snapshotName: string): JsonCompatibleReadOnly {\n\t\tconst fullPath = this.fileSystemMethods.join(\n\t\t\tthis.snapshotDirectory,\n\t\t\t`${snapshotName}.json`,\n\t\t);\n\t\tconst snapshot = JSON.parse(\n\t\t\tthis.fileSystemMethods.readFileSync(fullPath, \"utf8\"),\n\t\t) as JsonCompatibleReadOnly;\n\t\treturn snapshot;\n\t}\n\n\t/**\n\t * Returns all schema snapshots stored in the snapshot directory, sorted in order of increasing version.\n\t */\n\tpublic readAllSchemaSnapshots(\n\t\tcompare: (a: string, b: string) => number,\n\t): Map<string, TreeViewConfiguration> {\n\t\tthis.ensureSnapshotDirectoryExists();\n\t\tconst files = this.fileSystemMethods.readdirSync(this.snapshotDirectory);\n\t\tconst versions: string[] = [];\n\t\tfor (const file of files) {\n\t\t\tif (file.endsWith(\".json\")) {\n\t\t\t\tconst snapshotName = file.slice(0, \".json\".length * -1);\n\t\t\t\tversions.push(snapshotName);\n\t\t\t}\n\t\t}\n\t\t// Ensures that errors are in a consistent and friendly order, independent of file system order.\n\t\tversions.sort(compare);\n\n\t\tconst snapshots: Map<string, TreeViewConfiguration> = new Map();\n\t\tfor (const version of versions) {\n\t\t\tsnapshots.set(version, this.readSchemaSnapshot(version));\n\t\t}\n\t\treturn snapshots;\n\t}\n\n\tpublic ensureSnapshotDirectoryExists(): void {\n\t\tthis.fileSystemMethods.mkdirSync(this.snapshotDirectory, { recursive: true });\n\t}\n}\n\n/**\n * Gets the compatibility of the current view schema against a historical snapshot.\n * @param currentViewSchema - The current view schema.\n * @param previousViewSchema - The historical view schema.\n * @returns The combined compatibility status.\n */\nexport function getCompatibility(\n\tcurrentViewSchema: TreeViewConfiguration,\n\tpreviousViewSchema: TreeViewConfiguration,\n): CombinedSchemaCompatibilityStatus {\n\tconst backwardsCompatibilityStatus = checkCompatibility(\n\t\tpreviousViewSchema,\n\t\tcurrentViewSchema,\n\t);\n\n\tconst forwardsCompatibilityStatus = checkCompatibility(\n\t\tcurrentViewSchema,\n\t\tpreviousViewSchema,\n\t);\n\n\tassert(\n\t\tbackwardsCompatibilityStatus.isEquivalent === forwardsCompatibilityStatus.isEquivalent,\n\t\t0xcd3 /* equality should be symmetric */,\n\t);\n\n\t// This relies on exportCompatibilitySchemaSnapshot being well normalized, and not differing for non-significant changes.\n\tconst identicalCompatibility =\n\t\tJSON.stringify(exportCompatibilitySchemaSnapshot(currentViewSchema)) ===\n\t\tJSON.stringify(exportCompatibilitySchemaSnapshot(previousViewSchema));\n\n\tif (identicalCompatibility) {\n\t\tassert(\n\t\t\tbackwardsCompatibilityStatus.isEquivalent,\n\t\t\t0xcd4 /* identicalCompatibility should have equivalent stored schema */,\n\t\t);\n\t}\n\n\treturn {\n\t\tcurrentViewOfSnapshotDocument: backwardsCompatibilityStatus,\n\t\tsnapshotViewOfCurrentDocument: forwardsCompatibilityStatus,\n\t\tidenticalCompatibility,\n\t};\n}\n"]}
1
+ {"version":3,"file":"snapshotCompatibilityChecker.js","sourceRoot":"","sources":["../../../src/simple-tree/api/snapshotCompatibilityChecker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EACN,i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CAAC,CAAC;QACpE,IAAI,CAAC,SAAS,CAAC,iCAAiC,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAEvE,IAAI,sBAAsB,EAAE,CAAC;QAC5B,MAAM,CACL,4BAA4B,CAAC,YAAY,EACzC,KAAK,CAAC,iEAAiE,CACvE,CAAC;IACH,CAAC;IAED,OAAO;QACN,6BAA6B,EAAE,4BAA4B;QAC3D,6BAA6B,EAAE,2BAA2B;QAC1D,sBAAsB;KACtB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail, transformMapValues } from \"@fluidframework/core-utils/internal\";\nimport { selectVersionRoundedDown } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport * as semver from \"semver-ts\";\n\nimport type { JsonCompatibleReadOnly } from \"../../util/index.js\";\nimport { toInitialSchema } from \"../toStoredSchema.js\";\nimport { createTreeSchema } from \"../treeSchema.js\";\n\nimport { TreeViewConfigurationAlpha, TreeViewConfiguration } from \"./configuration.js\";\nimport { checkSchemaCompatibility } from \"./schemaCompatibilityTester.js\";\nimport { generateSchemaFromSimpleSchema } from \"./schemaFromSimple.js\";\nimport {\n\tdecodeSchemaCompatibilitySnapshot,\n\tencodeSchemaCompatibilitySnapshot,\n} from \"./simpleSchemaCodec.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Compute the compatibility of using `view` to {@link ViewableTree.viewWith | view a tree} who's {@link ITreeAlpha.exportSimpleSchema | stored schema} could be derived from `viewWhichCreatedStoredSchema` via either {@link TreeView.initialize} or {@link TreeView.upgradeSchema}.\n *\n * @remarks See {@link SchemaCompatibilityStatus} for details on the compatibility results.\n *\n * @example This example demonstrates checking the compatibility of a historical schema against a current schema.\n * In this case, the historical schema is a Point2D object with x and y fields, while the current schema is a Point3D object\n * that adds an optional z field.\n *\n * ```ts\n * // This snapshot is assumed to be the same as Point3D, except missing `z`.\n * const encodedSchema = JSON.parse(fs.readFileSync(\"PointSchema.json\", \"utf8\"));\n * const oldViewSchema = importCompatibilitySchemaSnapshot(encodedSchema);\n *\n * // Build the current view schema\n * class Point3D extends factory.object(\"Point\", {\n * \tx: factory.number,\n * \ty: factory.number,\n *\n * \t// The current schema has a new optional field that was not present on Point2D\n * \tz: factory.optional(factory.number),\n * }) {}\n * const currentViewSchema = new TreeViewConfiguration({ schema: Point3D });\n *\n * // Check to see if the document created by the historical view schema can be opened with the current view schema\n * const backwardsCompatibilityStatus = checkCompatibility(oldViewSchema, currentViewSchema);\n *\n * // z is not present in Point2D, so the schema must be upgraded\n * assert.equal(backwardsCompatibilityStatus.canView, false);\n *\n * // The schema can be upgraded to add the new optional field\n * assert.equal(backwardsCompatibilityStatus.canUpgrade, true);\n *\n * // Test what the old version of the application would do with a tree using the new schema:\n * const forwardsCompatibilityStatus = checkCompatibility(currentViewSchema, oldViewSchema);\n *\n * // If the old schema set allowUnknownOptionalFields, this would be true, but since it did not,\n * // this assert will fail, detecting the forwards compatibility break:\n * // this means these two versions of the application cannot collaborate on content using these schema.\n * assert.equal(forwardsCompatibilityStatus.canView, true);\n * ```\n *\n * @param viewWhichCreatedStoredSchema - From which to derive the stored schema, as if it initialized or upgraded a tree via {@link TreeView}.\n * @param view - The view being tested to see if it could view tree created or initialized using `viewWhichCreatedStoredSchema`.\n * @returns The compatibility status.\n *\n * @privateRemarks\n * TODO: a simple high level API for snapshot based schema compatibility checking should replace the need to export this.\n *\n * @alpha\n */\nexport function checkCompatibility(\n\tviewWhichCreatedStoredSchema: TreeViewConfiguration,\n\tview: TreeViewConfiguration,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\tconst viewAsAlpha = new TreeViewConfigurationAlpha({ schema: view.schema });\n\tconst stored = toInitialSchema(viewWhichCreatedStoredSchema.schema);\n\treturn checkSchemaCompatibility(viewAsAlpha, stored);\n}\n\n/**\n * Returns a JSON compatible representation of the tree schema for snapshot compatibility checking.\n *\n * Snapshots can be loaded by the same or newer package versions, but not necessarily older versions.\n *\n * @see {@link importCompatibilitySchemaSnapshot} which loads these snapshots.\n *\n * @param config - The schema to snapshot. Only the schema field of the `TreeViewConfiguration` is used.\n * @returns The JSON representation of the schema.\n *\n * @example This example creates and persists a snapshot of a Point2D schema.\n *\n * ```ts\n * const schemaFactory = new SchemaFactory(\"test\");\n * class Point2D extends schemaFactory.object(\"Point\", {\n * \tx: factory.number,\n * \ty: factory.number,\n * }) {}\n * const viewSchema = new TreeViewConfiguration({ schema: Point2D });\n * const encodedSchema = JSON.stringify(exportCompatibilitySchemaSnapshot(viewSchema));\n * fs.writeFileSync(\"PointSchema.json\", encodedSchema);\n * ```\n *\n * @privateRemarks\n * TODO: a simple high level API for snapshot based schema compatibility checking should replace the need to export this.\n *\n * @alpha\n */\nexport function exportCompatibilitySchemaSnapshot(\n\tconfig: Pick<TreeViewConfiguration, \"schema\">,\n): JsonCompatibleReadOnly {\n\tconst treeSchema = createTreeSchema(config.schema);\n\treturn encodeSchemaCompatibilitySnapshot(treeSchema);\n}\n\n/**\n * Parse the format exported by {@link exportCompatibilitySchemaSnapshot} into a schema.\n *\n * Can load snapshots created by the same or older package versions, but not necessarily newer versions.\n *\n * @see {@link exportCompatibilitySchemaSnapshot} which creates these snapshots.\n *\n * @param config - The JSON representation of the schema.\n * @returns The schema. Only the schema field of the {@link TreeViewConfiguration} is populated.\n * @throws Will throw a usage error if the encoded schema is not in the expected format.\n *\n * @example This example loads and parses a snapshot of a Point2D schema.\n *\n * ```ts;\n * const oldViewSchema = importCompatibilitySchemaSnapshot(fs.readFileSync(\"PointSchema.json\", \"utf8\"));\n * ```\n * @privateRemarks\n * TODO: a simple high level API for snapshot based schema compatibility checking should replace the need to export this.\n * @alpha\n */\nexport function importCompatibilitySchemaSnapshot(\n\tconfig: JsonCompatibleReadOnly,\n): TreeViewConfiguration {\n\tconst simpleSchema = decodeSchemaCompatibilitySnapshot(config);\n\tconst viewSchema = generateSchemaFromSimpleSchema(simpleSchema);\n\n\t// We construct a TreeViewConfiguration here with the default parameters. The default set of validation parameters are fine for\n\t// a schema produced by `generateSchemaFromSimpleSchema`.\n\treturn new TreeViewConfiguration({ schema: viewSchema.root });\n}\n\n/**\n * The file system methods required by {@link snapshotSchemaCompatibility}.\n * @remarks\n * Implemented by both Node.js `fs` and `path` modules, but other implementations can be provided as needed.\n *\n * @example\n * ```typescript\n * import path from \"node:path\";\n * import fs from \"node:fs\";\n *\n * const nodeFileSystem: SnapshotFileSystem = { ...fs, ...path };\n * ```\n *\n * @privateRemarks\n * This interface is designed to be compatible with Node.js `fs` and `path` modules.\n * It is needed to avoid direct dependencies on Node.js APIs in the core library code,\n * allowing for greater portability and easier testing.\n *\n * @input\n * @beta\n */\nexport interface SnapshotFileSystem {\n\t/**\n\t * Writes a UTF-8 encoded file to disk, replacing the file if it already exists.\n\t *\n\t * @param file - Path to the file to write.\n\t * @param data - String data to be written.\n\t * @param options - Options specifying that the encoding is UTF-8.\n\t */\n\twriteFileSync(file: string, data: string, options: { encoding: \"utf8\" }): void;\n\n\t/**\n\t * Reads a UTF-8 encoded file from disk and returns its contents as a string.\n\t *\n\t * @param file - Path to the file to read.\n\t * @param encoding - The text encoding to use when reading the file. Must be `\"utf8\"`.\n\t * @returns The contents of the file as a string.\n\t */\n\t// We include the encoding here to match the function overload for readFileSync that returns a string.\n\treadFileSync(file: string, encoding: \"utf8\"): string;\n\n\t/**\n\t * How a {@link TreeView} using the snapshotted schema would report its compatibility with a document created with the current schema.\n\t *\n\t * @param dir - Path of the directory to create.\n\t * @param options - Options indicating that creation should be recursive.\n\t */\n\tmkdirSync(dir: string, options: { recursive: true }): void;\n\n\t/**\n\t * Reads the contents of a directory.\n\t *\n\t * @param dir - Path of the directory to read.\n\t * @returns An array of names of the directory entries.\n\t */\n\treaddirSync(dir: string): readonly string[];\n\n\t/**\n\t * Joins two path segments into a single path string.\n\t *\n\t * @param parentPath - The directory path.\n\t * @param childPath - Filename within `parentPath` directory.\n\t * @returns The combined path string.\n\t */\n\tjoin(parentPath: string, childPath: string): string;\n}\n\n/**\n * The combined compatibility status for both backwards and forwards compatibility checks.\n */\nexport interface CombinedSchemaCompatibilityStatus {\n\t/**\n\t * How a {@link TreeView} using the current schema would report its compatibility with the historical snapshot.\n\t */\n\treadonly currentViewOfSnapshotDocument: Omit<SchemaCompatibilityStatus, \"canInitialize\">;\n\t/**\n\t * How a {@link TreeView} using the snapshotted schema would report its compatibility with a document created with the current schema.\n\t */\n\treadonly snapshotViewOfCurrentDocument: Omit<SchemaCompatibilityStatus, \"canInitialize\">;\n\n\t/**\n\t * True if and only if the schema have identical compatibility.\n\t * @remarks\n\t * This includes producing the equivalent stored schema (which currentViewOfSnapshotDocument and snapshotViewOfCurrentDocument also measure)\n\t * as well as equivalent compatibility with potential future schema changes beyond just those in these two schema.\n\t *\n\t * This includes compatibility with all potential future schema changes.\n\t * For example two schema different only in compatibility with future optional fields via allow unknown optional fields or staged schema\n\t * would be considered non-equivalent, even though they are forwards and backwards compatible with each other, and both status above report them as equivalent\n\t * since they would produce the same stored schema upon schema upgrade.\n\t */\n\treadonly identicalCompatibility: boolean;\n}\n\n/**\n * The options for {@link snapshotSchemaCompatibility}.\n * @input\n * @beta\n */\nexport interface SnapshotSchemaCompatibilityOptions {\n\t/**\n\t * Directory where historical schema snapshots are stored.\n\t * @remarks\n\t * As the contents of this directory (specifically historical snapshots) cannot be regenerated,\n\t * a directory appropriate for test data should be used.\n\t * Generally this means that this directory should be versioned like code,\n\t * and not erased when regenerating snapshots.\n\t *\n\t * This directory will be created if it does not already exist.\n\t * All \".json\" files in this directory will be treated as schema snapshots.\n\t * It is recommended to use a dedicated directory for each {@link snapshotSchemaCompatibility} powered test.\n\t *\n\t * This can use any path syntax supported by the provided {@link SnapshotSchemaCompatibilityOptions.fileSystem}.\n\t */\n\treadonly snapshotDirectory: string;\n\n\t/**\n\t * How the `snapshotDirectory` is accessed.\n\t */\n\treadonly fileSystem: SnapshotFileSystem;\n\n\t/**\n\t * The current view schema.\n\t */\n\treadonly schema: TreeViewConfiguration;\n\n\t/**\n\t * The version which will be associated with this version of the schema.\n\t * @remarks\n\t * Often the easiest way to ensure this is to simply use the next version which will be released for the package or application itself, and set the `minVersionForCollaboration` based on telemetry about which versions are still in use.\n\t * To do this, it is recommended that this version be programmatically derived from the application version rather than hard coded inline.\n\t * For example, reading it from the `package.json` or some other source of truth can be done to ensure it is kept up to date, and thus snapshots always have the correct version.\n\t * The version used should typically be the _next_ production version (whose formats must be supported long term) that will be released (but is not yet released).\n\t * This usually means that the correct version to use is the same version that would be used when releasing the application or library, but with any prerelease version tags removed.\n\t * If an automated way to keep this version up to date is not used, be very careful when reviewing changes to snapshot files to ensure the version is correct.\n\t * If incorrectly versioned snapshots were committed accidentally, rename the snapshot files to have the correct version, and restore the old files from, version control.\n\t *\n\t * It is possible to use a different versioning scheme, for example one specific to the schema in question.\n\t * This can be done robustly as long as care is taken to ensure the version increases such that every released version has a unique `version` (and therefore unique snapshot),\n\t * and `minVersionForCollaboration` is set appropriately using the same versioning scheme.\n\t * {@link SnapshotSchemaCompatibilityOptions.rejectVersionsWithNoSchemaChange} and\n\t * {@link SnapshotSchemaCompatibilityOptions.rejectSchemaChangesWithNoVersionChange}\n\t * can be used to help enforce the expected relationship between version changes and schema changes in such cases.\n\t *\n\t * Can use any format supported by {@link SnapshotSchemaCompatibilityOptions.versionComparer}.\n\t * Only compared against the version from previous snapshots (taken from this version when they were created by setting `mode` to \"update\") and the `minVersionForCollaboration`.\n\t *\n\t * Typically `minVersionForCollaboration` should be set to the oldest version currently in use, so it's helpful to use a version which can be easily measured to tell if clients are still using it.\n\t */\n\treadonly version: string;\n\n\t/**\n\t * The minimum version that the current version is expected to be able to collaborate with.\n\t * @remarks\n\t * Can use any format supported by {@link SnapshotSchemaCompatibilityOptions.versionComparer}.\n\t *\n\t * This defines a range of versions whose schema must be forwards compatible with trees using the current schema:\n\t * Any schema from snapshots with a version greater than or equal to this must be able to view documents created with the current schema.\n\t * This means that if the current `schema` is used to create a {@link TreeView}, then {@link TreeView.upgradeSchema} is used, the older clients,\n\t * all the way back to this `minVersionForCollaboration` will be able to view and edit the tree using their schema and thus collaborate.\n\t *\n\t * Typically applications will attempt to manage their deployment/update schedule such that all versions concurrently deployed can\n\t * collaborate to avoid users losing access to documents when other users upgrade the schema.\n\t * Such applications can set this to the oldest version currently deployed,\n\t * then rely on {@link snapshotSchemaCompatibility} to verify that no schema changes are made which would break collaboration with that (or newer) versions.\n\t *\n\t * This is the same approach used by {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}\n\t * except that type is specifically for use with the version of the Fluid Framework client packages,\n\t * and this corresponds to whatever versioning scheme is used with {@link SnapshotSchemaCompatibilityOptions.version}.\n\t */\n\treadonly minVersionForCollaboration: string;\n\n\t/**\n\t * A comparison function for version strings.\n\t * @remarks\n\t * A comparison function like that provided to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#comparefn | Array.sort}.\n\t * This is used to partition snapshots into those less than `minVersionForCollaboration` and those greater than or equal to it, as well as to sanity check `version` against the versions of the snapshots.\n\t * If not provided, the ordering is defined by {@link https://semver.org/#spec-item-11|semver}.\n\t * @returns A negative number if `a` is less than `b`, zero if they are equal, or a positive number if `a` is greater than `b`.\n\t */\n\treadonly versionComparer?: (a: string, b: string) => number;\n\n\t/**\n\t * When true, every version must be snapshotted, and an increased version number will require a new snapshot.\n\t * @remarks\n\t * If this is true, it is assumed there is a snapshot for every release, and thus it is required that the `minVersionForCollaboration` refer to a version which has a snapshot.\n\t * When this is not true, versions without snapshots are assumed to have the same schema as the latest previous version which has a snapshot, and thus `minVersionForCollaboration`\n\t * can refer to versions between snapshots and will get its schema from the preceding version.\n\t */\n\treadonly snapshotUnchangedVersions?: true;\n\n\t/**\n\t * When true, it is an error if a new a snapshot for a new version would be created, but the schema compatibility is identical to the previous snapshot.\n\t * @remarks\n\t * This prevents creating a snapshot with the same schema compatibility results as the previous one.\n\t *\n\t * Applications and libraries which do not have versioned releases can make up a version specific to the compatibility of the schema, and use this option to help ensure they manage that version correctly.\n\t * Such cases can also opt into {@link SnapshotSchemaCompatibilityOptions.rejectSchemaChangesWithNoVersionChange} if they want additional strictness.\n\t */\n\treadonly rejectVersionsWithNoSchemaChange?: true;\n\n\t/**\n\t * When true, it is an error if a schema change occurs without a corresponding version change.\n\t * @remarks\n\t * This disables overwriting existing snapshots.\n\t * This option is recommended if the {@link SnapshotSchemaCompatibilityOptions.version} is not automatically updated ahead of releasing a version which must be supported.\n\t * If updating the snapshot is still desired, the preceding one which needs to be overwritten can be manually deleted before running the update.\n\t *\n\t * This option does not impact the behavior of assert mode (other than impacting what error is given).\n\t * This option simply makes update mode more strict, converting cases that would overwrite a snapshot in place into errors.\n\t */\n\treadonly rejectSchemaChangesWithNoVersionChange?: true;\n\n\t/**\n\t * The mode of operation, either \"assert\" or \"update\".\n\t * @remarks\n\t * Both modes will throw errors if any compatibility issues are detected (but after updating snapshots in \"update\" mode so the diff can be used to help debug).\n\t *\n\t * In \"assert\" mode, an error is additionally thrown if the latest snapshot is not up to date (meaning \"update\" mode would make a change).\n\t *\n\t * In \"update\" mode, a new snapshot is created if the current schema differs from the latest existing snapshot.\n\t * If {@link SnapshotSchemaCompatibilityOptions.rejectVersionsWithNoSchemaChange} or\n\t * {@link SnapshotSchemaCompatibilityOptions.rejectSchemaChangesWithNoVersionChange} disallows the update, an error is thrown instead.\n\t *\n\t * It is recommended that \"assert\" mode be used in automated tests to verify schema compatibility,\n\t * and \"update\" mode only be used manually to update snapshots when making schema or version changes.\n\t *\n\t * @privateRemarks\n\t * Modes we might want to add in the future:\n\t * - normalize: update the latest snapshot (or maybe all of them) to the latest encoded format.\n\t * - some mode like assert but returns information instead of throwing.\n\t */\n\treadonly mode: \"assert\" | \"update\";\n}\n\n/**\n * Check `currentViewSchema` for compatibility with a collection of historical schema snapshots stored in `snapshotDirectory`.\n *\n * @throws Throws errors if the input version strings (including those in snapshot file names) are not valid semver versions when using default semver version comparison.\n * @throws Throws errors if the input version strings (including those in snapshot file names) are not ordered as expected (current being the highest, and `minVersionForCollaboration` corresponding to the current version or a lower snapshotted version).\n * @throws In `test` mode, throws an error if there is not an up to date snapshot for the current version.\n * @throws Throws an error if any snapshotted schema cannot be upgraded to the current schema.\n * @throws Throws an error if any snapshotted schema with a version greater than or equal to `minVersionForCollaboration` cannot view documents created with the current schema.\n * @remarks\n * This is intended for use in snapshot-based schema compatibility tests.\n * Every SharedTree-based component or application with a schema is recommended to use this to verify schema compatibility across versions.\n *\n * Schema snapshots should be added to `snapshotDirectory` using this function in \"update\" mode whenever the schema changes in a compatibility impacting way\n * (or when `snapshotUnchangedVersions` is true and a new version about to be released is getting prepared for release (and thus `version` changed)).\n *\n * This will throw an exception if any snapshotted schema would result in documents that cannot be viewed (after using {@link TreeView.upgradeSchema}), or if any schema with a version greater than or equal to `minVersionForCollaboration` cannot view documents created with the `currentViewSchema`.\n * See {@link TreeView.compatibility} for more information.\n *\n * Proper use of this utility should do a good job at detecting schema compatibility issues,\n * however it currently does not do a good job of explaining exactly what change to the schema is causing the compatibility issues.\n * This is a known limitation that will be improved in future releases.\n * These improvements, as well as other changes, may change the exact messages produced by this function in the error cases: no stability of these messages should be assumed.\n *\n * Unlike some other snapshot based testing tools, this stores more than just the current snapshot: historical snapshots are retained as well.\n * Retention of these additional historical snapshots, whose content can't be regenerated from the current schema, is necessary to properly test compatibility across versions.\n * Since there is content in the snapshots which cannot be regenerated, tools which assume all snapshotted content can be regenerated cannot be used here.\n * This means that tools like Jest's built in snapshot testing are not suitable for this purpose.\n * These snapshots behave partly like test data, and partly like snapshots.\n * Typically the easiest way to manage this is to place {@link SnapshotSchemaCompatibilityOptions.snapshotDirectory} inside a directory appropriate for test data,\n * and use node to provide the filesystem access via {@link SnapshotSchemaCompatibilityOptions.fileSystem}.\n *\n * For now, locating what change broke compatibility is likely best discovered by making small schema changes one at a time and updating the snapshot and reviewing the diffs.\n * Details for what kinds of changes are breaking and in which ways can be found in the documentation for {@link TreeView.compatibility} and\n * {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution/ | schema-evolution}.\n *\n * This utility does not enforce anything with respect to API compatibility, or special semantics for major, minor, or patch versions.\n * Libraries which export schema for use by others will need to take special care to ensure the stability contract they offer their users aligns which what is validated by this utility.\n *\n * This utility only tests compatibility of the historical snapshots against the current schema; it does not test them against each-other.\n * Generally any historical schemas should have been tested against the ones before them at the time they were current.\n * If for some reason a version of a schema made it into production that was not compatible with a previous version,\n * that can still be represented here (but may require manually generating a snapshot for that version)\n * and this will still allow testing that all historical version can be upgraded to the current one.\n * If a sufficiently incompatible historical schemas were used in production, it may be impossible to make a single schema which can accommodate all of them:\n * this utility can be used to confirm that is the case, as well as to avoid the problem in the first place by testing schema before each one is deployed.\n *\n * @example Mocha test which validates the current `config` can collaborate with all historical version back to 2.0.0, and load and update any versions older than that.\n * ```typescript\n * it(\"schema compatibility\", () => {\n * \tsnapshotSchemaCompatibility({\n * \t\tversion: pkgVersion,\n * \t\tschema: config,\n * \t\tfileSystem: { ...fs, ...path },\n * \t\tminVersionForCollaboration: \"2.0.0\",\n * \t\tmode: process.argv.includes(\"--snapshot\") ? \"update\" : \"test\",\n * \t\tsnapshotDirectory,\n * \t});\n * });\n * ```\n * @example Complete Mocha test file\n * ```typescript\n * import fs from \"node:fs\";\n * import path from \"node:path\";\n *\n * import { snapshotSchemaCompatibility } from \"@fluidframework/tree/beta\";\n *\n * // The TreeViewConfiguration the application uses, which contains the application's schema.\n * import { treeViewConfiguration } from \"./schema.js\";\n * // The next version of the application which will be released.\n * import { packageVersion } from \"./version.js\";\n *\n * // Provide some way to run the check in \"update\" mode when updating snapshots is intended.\n * const regenerateSnapshots = process.argv.includes(\"--snapshot\");\n *\n * // Setup the actual test. In this case using Mocha syntax.\n * describe(\"schema\", () => {\n * \tit(\"schema compatibility\", () => {\n * \t\t// Select a path to save the snapshots in.\n * \t\t// This will depend on how your application organizes its test data.\n * \t\tconst snapshotDirectory = path.join(\n * \t\t\timport.meta.dirname,\n * \t\t\t\"../../../src/test/schema-snapshots\",\n * \t\t);\n * \t\tsnapshotSchemaCompatibility({\n * \t\t\tschema: config,\n * \t\t\tfileSystem: { ...fs, ...path },\n * \t\t\tversion: pkgVersion,\n * \t\t\tminVersionForCollaboration: \"2.0.0\",\n * \t\t\tmode: process.argv.includes(\"--snapshot\") ? \"update\" : \"assert\",\n * \t\t\tsnapshotDirectory,\n * \t\t});\n * \t});\n * });\n * ```\n * @privateRemarks\n * Use of this function within this package (for schema libraries released as part of this package) should use {@link testSchemaCompatibilitySnapshots} instead.\n *\n * This uses the format defined in simpleSchemaCodec.ts.\n * This does include versioning information in the snapshot format,\n * but it would be nice to better unify how we do that versioning and format validation with our codecs.\n *\n * See snapshotCompatibilityChecker.example.mts for the large example included above.\n * @beta\n */\nexport function snapshotSchemaCompatibility(\n\toptions: SnapshotSchemaCompatibilityOptions,\n): void {\n\tconst checker = new SnapshotCompatibilityChecker(\n\t\toptions.snapshotDirectory,\n\t\toptions.fileSystem,\n\t);\n\tconst {\n\t\tversion: currentVersion,\n\t\tschema: currentViewSchema,\n\t\tmode,\n\t\tminVersionForCollaboration,\n\t\tsnapshotUnchangedVersions,\n\t\trejectVersionsWithNoSchemaChange,\n\t\trejectSchemaChangesWithNoVersionChange,\n\t} = options;\n\n\tconst validateVersion =\n\t\toptions.versionComparer === undefined ? semver.valid : (v: string) => v;\n\tconst versionComparer = options.versionComparer ?? semver.compare;\n\n\tif (validateVersion(currentVersion) === null) {\n\t\tthrow new UsageError(\n\t\t\t`Invalid version: ${JSON.stringify(currentVersion)}. Must be a valid semver version.`,\n\t\t);\n\t}\n\tif (validateVersion(minVersionForCollaboration) === null) {\n\t\tthrow new UsageError(\n\t\t\t`Invalid minVersionForCollaboration: ${JSON.stringify(minVersionForCollaboration)}. Must be a valid semver version.`,\n\t\t);\n\t}\n\n\tif (versionComparer(minVersionForCollaboration, currentVersion) > 0) {\n\t\tthrow new UsageError(\n\t\t\t`Invalid minVersionForCollaboration: ${JSON.stringify(minVersionForCollaboration)}. Must be less than or equal to current version ${JSON.stringify(currentVersion)}.`,\n\t\t);\n\t}\n\n\tif (mode !== \"assert\" && mode !== \"update\") {\n\t\tthrow new UsageError(\n\t\t\t`Invalid mode: ${JSON.stringify(mode)}. Must be either \"assert\" or \"update\".`,\n\t\t);\n\t}\n\n\tconst currentEncodedForSnapshotting = exportCompatibilitySchemaSnapshot(currentViewSchema);\n\tconst snapshots = checker.readAllSchemaSnapshots(versionComparer);\n\n\tconst compatibilityErrors: string[] = [];\n\n\tconst contextNotes: string[] = [];\n\n\tfunction errorWithContext(message: string): Error {\n\t\treturn new Error(\n\t\t\t[\n\t\t\t\t\"Schema compatibility check failed:\",\n\t\t\t\tmessage,\n\t\t\t\t`Snapshots in: ${JSON.stringify(options.snapshotDirectory)}`,\n\t\t\t\t`Snapshots exist for versions: ${JSON.stringify([...snapshots.keys()], undefined, \"\\t\")}.`,\n\t\t\t\t...contextNotes,\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t}\n\n\tconst compatibilityMap = transformMapValues(snapshots, (snapshot) =>\n\t\tgetCompatibility(currentViewSchema, snapshot),\n\t);\n\n\t// Either:\n\t// - false: no update needed\n\t// - the updateError message (update in update mode, error otherwise)\n\t// - an error if the update is disallowed by the flags\n\tlet wouldUpdate: false | string | Error;\n\n\t// Set wouldUpdate\n\t{\n\t\tconst latestSnapshot = [...snapshots][snapshots.size - 1];\n\t\tif (latestSnapshot === undefined) {\n\t\t\twouldUpdate = `No snapshots found.`;\n\t\t} else {\n\t\t\tconst latestCompatibility =\n\t\t\t\tcompatibilityMap.get(latestSnapshot[0]) ??\n\t\t\t\tfail(0xcd1 /* missing compatibilityMap entry */);\n\n\t\t\tconst schemaChange = !latestCompatibility.identicalCompatibility;\n\t\t\tconst versionChange = versionComparer(latestSnapshot[0], currentVersion) !== 0;\n\n\t\t\tif (rejectVersionsWithNoSchemaChange === true && versionChange && !schemaChange) {\n\t\t\t\twouldUpdate = errorWithContext(\n\t\t\t\t\t`Rejecting version change (${JSON.stringify(latestSnapshot[0])} to ${JSON.stringify(currentVersion)}) due to rejectVersionsWithNoSchemaChange being set.`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\trejectSchemaChangesWithNoVersionChange === true &&\n\t\t\t\tschemaChange &&\n\t\t\t\t!versionChange\n\t\t\t) {\n\t\t\t\twouldUpdate = errorWithContext(\n\t\t\t\t\t`Rejecting schema change without version change due to existing non-equivalent snapshot for version (${JSON.stringify(latestSnapshot[0])} due to rejectSchemaChangesWithNoVersionChange being set.`,\n\t\t\t\t);\n\t\t\t} else if (snapshotUnchangedVersions === true) {\n\t\t\t\tconst currentRead = snapshots.get(currentVersion);\n\t\t\t\tif (currentRead === undefined) {\n\t\t\t\t\twouldUpdate = `No snapshot found for version ${JSON.stringify(currentVersion)}: snapshotUnchangedVersions is true, so every version must be snapshotted.`;\n\t\t\t\t} else if (\n\t\t\t\t\tJSON.stringify(exportCompatibilitySchemaSnapshot(currentRead)) ===\n\t\t\t\t\tJSON.stringify(currentEncodedForSnapshotting)\n\t\t\t\t) {\n\t\t\t\t\twouldUpdate = false;\n\t\t\t\t} else {\n\t\t\t\t\twouldUpdate = `Snapshot for current version ${JSON.stringify(currentVersion)} is out of date.`;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (versionComparer(latestSnapshot[0], currentVersion) <= 0) {\n\t\t\t\t\twouldUpdate = schemaChange\n\t\t\t\t\t\t? `Snapshot for current version ${JSON.stringify(currentVersion)} is out of date: schema has changed since latest existing snapshot version ${JSON.stringify(latestSnapshot[0])}.`\n\t\t\t\t\t\t: false;\n\t\t\t\t} else {\n\t\t\t\t\twouldUpdate = errorWithContext(\n\t\t\t\t\t\t`Current version ${JSON.stringify(currentVersion)} is less than latest existing snapshot version ${JSON.stringify(latestSnapshot[0])}: version is expected to increase monotonically.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!schemaChange && (snapshotUnchangedVersions !== true || !versionChange)) {\n\t\t\t\t// eslint-disable-next-line unicorn/no-lonely-if\n\t\t\t\tif (\n\t\t\t\t\tJSON.stringify(exportCompatibilitySchemaSnapshot(latestSnapshot[1])) !==\n\t\t\t\t\tJSON.stringify(currentEncodedForSnapshotting)\n\t\t\t\t) {\n\t\t\t\t\t// Schema are compatibility wise equivalent, but differ in some way (excluding json formatting).\n\t\t\t\t\t// TODO: add a \"normalize\" mode, which do an update only in this case (or maybe even normalize json formatting as well and just always rewrite when !schemaChange)\n\t\t\t\t\t// This would be useful to minimize diffs from future schema changes.\n\t\t\t\t\t// This would be particularly useful if adding a second version of the format used in the snapshots.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (wouldUpdate !== false) {\n\t\tif (wouldUpdate instanceof Error) {\n\t\t\tthrow wouldUpdate;\n\t\t}\n\t\tif (mode === \"update\") {\n\t\t\tchecker.writeSchemaSnapshot(currentVersion, currentEncodedForSnapshotting);\n\t\t\t// Update so errors below will reflect the new snapshot.\n\t\t\tcompatibilityMap.set(\n\t\t\t\tcurrentVersion,\n\t\t\t\tgetCompatibility(currentViewSchema, currentViewSchema),\n\t\t\t);\n\t\t} else {\n\t\t\tcompatibilityErrors.push(\n\t\t\t\t`${wouldUpdate} If this is expected, snapshotSchemaCompatibility can be rerun in \"update\" mode to update or create the snapshot.`,\n\t\t\t);\n\n\t\t\t// This case could update compatibilityMap as well, but it would hide some information about how the existing snapshot might be incompatible with the proposed new one.\n\t\t\t// This lost information could be annoying if the user's intention was not to edit the schema (which is what we assume in assert mode),\n\t\t\t// especially once we produce more detailed error messages that can help users understand what changed in the schema.\n\t\t}\n\t}\n\n\t// Add compatibilityErrors and contextNotes as needed regarding minVersionForCollaboration.\n\t// This is only done when minVersionForCollaboration is not the current version to avoid extra noise in \"assert\" mode\n\t// (which is the only case that could error when minVersionForCollaboration === currentVersion).\n\tif (minVersionForCollaboration !== currentVersion) {\n\t\tif (snapshotUnchangedVersions === true) {\n\t\t\tconst minSnapshot = compatibilityMap.get(minVersionForCollaboration);\n\t\t\tif (minSnapshot === undefined) {\n\t\t\t\tcompatibilityErrors.push(\n\t\t\t\t\t`Using snapshotUnchangedVersions: a snapshot of the exact minVersionForCollaboration ${JSON.stringify(minVersionForCollaboration)} is required. No snapshot found.`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst selectedMinVersionForCollaborationSnapshot = selectVersionRoundedDown(\n\t\t\t\tminVersionForCollaboration,\n\t\t\t\tcompatibilityMap,\n\t\t\t\tversionComparer,\n\t\t\t);\n\t\t\tif (selectedMinVersionForCollaborationSnapshot === undefined) {\n\t\t\t\tcompatibilityErrors.push(\n\t\t\t\t\t`No snapshot found with version less than or equal to minVersionForCollaboration ${JSON.stringify(minVersionForCollaboration)}.`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tselectedMinVersionForCollaborationSnapshot[0] !== minVersionForCollaboration\n\t\t\t) {\n\t\t\t\t// Add an entry to ensure that the version which spans from before until after the cutoff for collaboration is included in the compatibility checks.\n\t\t\t\tcompatibilityMap.set(\n\t\t\t\t\tminVersionForCollaboration,\n\t\t\t\t\tselectedMinVersionForCollaborationSnapshot[1],\n\t\t\t\t);\n\t\t\t\tcontextNotes.push(\n\t\t\t\t\t`Due to snapshotUnchangedVersions being false and minVersionForCollaboration (${JSON.stringify(minVersionForCollaboration)}) not having an exact snapshot, the last snapshot before that version (which is ${JSON.stringify(\n\t\t\t\t\t\tselectedMinVersionForCollaborationSnapshot[0],\n\t\t\t\t\t)}) is being also being checked as if it is version ${JSON.stringify(minVersionForCollaboration)}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Compare all snapshots against the current schema, using the compatibilityMap.\n\tfor (const [snapshotVersion, compatibility] of compatibilityMap) {\n\t\t// Current should be able to view all versions.\n\t\tif (!compatibility.currentViewOfSnapshotDocument.canUpgrade) {\n\t\t\tcompatibilityErrors.push(\n\t\t\t\t`Current version ${JSON.stringify(currentVersion)} cannot upgrade documents from ${JSON.stringify(snapshotVersion)}.`,\n\t\t\t);\n\t\t}\n\n\t\tconst versionComparisonToCurrent = versionComparer(snapshotVersion, currentVersion);\n\t\tif (versionComparisonToCurrent === 0) {\n\t\t\tif (currentVersion !== snapshotVersion) {\n\t\t\t\tthrow errorWithContext(\n\t\t\t\t\t`Snapshot version ${JSON.stringify(snapshotVersion)} is semantically equal but not string equal to current version ${JSON.stringify(currentVersion)}: this is not supported.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (compatibility.identicalCompatibility === false) {\n\t\t\t\tassert(\n\t\t\t\t\twouldUpdate !== false,\n\t\t\t\t\t0xcd2 /* there should have been an error for the snapshot being out of date */,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (versionComparisonToCurrent < 0) {\n\t\t\t// Collaboration with this version is expected to work.\n\t\t\tif (versionComparer(snapshotVersion, minVersionForCollaboration) >= 0) {\n\t\t\t\t// Check that the historical version can view documents from the current version, since collaboration with this one is expected to work.\n\t\t\t\tif (!compatibility.snapshotViewOfCurrentDocument.canView) {\n\t\t\t\t\tcompatibilityErrors.push(\n\t\t\t\t\t\t`Historical version ${JSON.stringify(snapshotVersion)} cannot view documents from ${JSON.stringify(currentVersion)}: these versions are expected to be able to collaborate due to the selected minVersionForCollaboration ${JSON.stringify(minVersionForCollaboration)}.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// This is the case where the historical version is less than the minimum version for collaboration.\n\t\t\t\t// No additional validation is needed here currently, since forwards document compat from these versions is already tested above (since it applies to all snapshots).\n\t\t\t}\n\t\t} else {\n\t\t\tcompatibilityErrors.push(\n\t\t\t\t`Snapshot exists for version ${JSON.stringify(snapshotVersion)} which is greater than the current version ${JSON.stringify(currentVersion)}. This is not supported.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (compatibilityErrors.length > 0) {\n\t\tthrow errorWithContext(compatibilityErrors.map((e) => ` - ${e}`).join(\"\\n\"));\n\t}\n}\n\n/**\n * The high-level API for checking snapshot compatibility and generating new snapshots.\n */\nexport class SnapshotCompatibilityChecker {\n\tpublic constructor(\n\t\t/**\n\t\t * Directory where historical schema snapshots are stored.\n\t\t */\n\t\tprivate readonly snapshotDirectory: string,\n\t\t/**\n\t\t * How the `snapshotDirectory` is accessed.\n\t\t */\n\t\tprivate readonly fileSystemMethods: SnapshotFileSystem,\n\t) {}\n\n\tpublic writeSchemaSnapshot(snapshotName: string, snapshot: JsonCompatibleReadOnly): void {\n\t\tconst fullPath = this.fileSystemMethods.join(\n\t\t\tthis.snapshotDirectory,\n\t\t\t`${snapshotName}.json`,\n\t\t);\n\t\tthis.ensureSnapshotDirectoryExists();\n\t\tthis.fileSystemMethods.writeFileSync(fullPath, JSON.stringify(snapshot, undefined, \"\\t\"), {\n\t\t\tencoding: \"utf8\",\n\t\t});\n\t}\n\n\tpublic readSchemaSnapshot(snapshotName: string): TreeViewConfiguration {\n\t\tconst snapshot = this.readSchemaSnapshotRaw(snapshotName);\n\t\treturn importCompatibilitySchemaSnapshot(snapshot);\n\t}\n\n\tpublic readSchemaSnapshotRaw(snapshotName: string): JsonCompatibleReadOnly {\n\t\tconst fullPath = this.fileSystemMethods.join(\n\t\t\tthis.snapshotDirectory,\n\t\t\t`${snapshotName}.json`,\n\t\t);\n\t\tconst snapshot = JSON.parse(\n\t\t\tthis.fileSystemMethods.readFileSync(fullPath, \"utf8\"),\n\t\t) as JsonCompatibleReadOnly;\n\t\treturn snapshot;\n\t}\n\n\t/**\n\t * Returns all schema snapshots stored in the snapshot directory, sorted in order of increasing version.\n\t */\n\tpublic readAllSchemaSnapshots(\n\t\tcompare: (a: string, b: string) => number,\n\t): Map<string, TreeViewConfiguration> {\n\t\tthis.ensureSnapshotDirectoryExists();\n\t\tconst files = this.fileSystemMethods.readdirSync(this.snapshotDirectory);\n\t\tconst versions: string[] = [];\n\t\tfor (const file of files) {\n\t\t\tif (file.endsWith(\".json\")) {\n\t\t\t\tconst snapshotName = file.slice(0, \".json\".length * -1);\n\t\t\t\tversions.push(snapshotName);\n\t\t\t}\n\t\t}\n\t\t// Ensures that errors are in a consistent and friendly order, independent of file system order.\n\t\tversions.sort(compare);\n\n\t\tconst snapshots: Map<string, TreeViewConfiguration> = new Map();\n\t\tfor (const version of versions) {\n\t\t\tsnapshots.set(version, this.readSchemaSnapshot(version));\n\t\t}\n\t\treturn snapshots;\n\t}\n\n\tpublic ensureSnapshotDirectoryExists(): void {\n\t\tthis.fileSystemMethods.mkdirSync(this.snapshotDirectory, { recursive: true });\n\t}\n}\n\n/**\n * Gets the compatibility of the current view schema against a historical snapshot.\n * @param currentViewSchema - The current view schema.\n * @param previousViewSchema - The historical view schema.\n * @returns The combined compatibility status.\n */\nexport function getCompatibility(\n\tcurrentViewSchema: TreeViewConfiguration,\n\tpreviousViewSchema: TreeViewConfiguration,\n): CombinedSchemaCompatibilityStatus {\n\tconst backwardsCompatibilityStatus = checkCompatibility(\n\t\tpreviousViewSchema,\n\t\tcurrentViewSchema,\n\t);\n\n\tconst forwardsCompatibilityStatus = checkCompatibility(\n\t\tcurrentViewSchema,\n\t\tpreviousViewSchema,\n\t);\n\n\tassert(\n\t\tbackwardsCompatibilityStatus.isEquivalent === forwardsCompatibilityStatus.isEquivalent,\n\t\t0xcd3 /* equality should be symmetric */,\n\t);\n\n\t// This relies on exportCompatibilitySchemaSnapshot being well normalized, and not differing for non-significant changes.\n\tconst identicalCompatibility =\n\t\tJSON.stringify(exportCompatibilitySchemaSnapshot(currentViewSchema)) ===\n\t\tJSON.stringify(exportCompatibilitySchemaSnapshot(previousViewSchema));\n\n\tif (identicalCompatibility) {\n\t\tassert(\n\t\t\tbackwardsCompatibilityStatus.isEquivalent,\n\t\t\t0xcd4 /* identicalCompatibility should have equivalent stored schema */,\n\t\t);\n\t}\n\n\treturn {\n\t\tcurrentViewOfSnapshotDocument: backwardsCompatibilityStatus,\n\t\tsnapshotViewOfCurrentDocument: forwardsCompatibilityStatus,\n\t\tidenticalCompatibility,\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"storedSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAE5F,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAKnF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,mBAAmB,EAAE,uBAAuB,EAC5C,aAAa,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,GAChD,cAAc,CAUhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,aAAa,GACpB,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAQlD"}
1
+ {"version":3,"file":"storedSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAE5F,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAKnF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,mBAAmB,EAAE,uBAAuB,EAC5C,aAAa,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,GAChD,cAAc,CAUhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,aAAa,GACpB,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAOlD"}
@@ -7,7 +7,7 @@ import { schemaCodecBuilder } from "../../feature-libraries/index.js";
7
7
  import { normalizeFieldSchema } from "../fieldSchema.js";
8
8
  import { toStoredSchema } from "../toStoredSchema.js";
9
9
  import { TreeViewConfigurationAlpha } from "./configuration.js";
10
- import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
10
+ import { checkSchemaCompatibility } from "./schemaCompatibilityTester.js";
11
11
  /**
12
12
  * Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.
13
13
  *
@@ -87,7 +87,6 @@ export function comparePersistedSchema(persisted, view, options) {
87
87
  const config = new TreeViewConfigurationAlpha({
88
88
  schema: normalizeFieldSchema(view),
89
89
  });
90
- const viewSchema = new SchemaCompatibilityTester(config);
91
- return viewSchema.checkCompatibility(stored);
90
+ return checkSchemaCompatibility(config, stored);
92
91
  }
93
92
  //# sourceMappingURL=storedSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAG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(c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { FormatValidatorNoOp, type ICodecOptions } from \"../../codec/index.js\";\nimport { schemaCodecBuilder } from \"../../feature-libraries/index.js\";\nimport type { JsonCompatible } from \"../../util/index.js\";\nimport type { SchemaUpgrade } from \"../core/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\n\nimport { TreeViewConfigurationAlpha } from \"./configuration.js\";\nimport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Dumps the \"persisted\" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.\n *\n * @param schema - The schema to dump.\n * @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.\n * @param includeStaged - filter for selecting which staged allowed types to include in the output.\n *\n * @remarks\n * This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.\n * This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.\n *\n * This only includes the \"persisted\" subset of schema information, which means the portion which gets included in documents.\n * It thus uses \"persisted\" keys, see {@link FieldProps.key}.\n *\n * If two schema have identical \"persisted\" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.\n *\n * See also {@link comparePersistedSchema}.\n *\n * @example\n * An application could use this API to generate a `schema.json` file when it first releases,\n * then test that the schema is sill compatible with documents from that version with a test like :\n * ```typescript\n * assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require(\"./schema.json\"));\n * ```\n *\n * @privateRemarks\n * This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).\n * This intentionally does not leak the format types in the API.\n *\n * Public API surface uses \"persisted\" terminology while internally we use \"stored\".\n * @alpha\n */\nexport function extractPersistedSchema(\n\tschema: ImplicitFieldSchema,\n\tminVersionForCollab: MinimumVersionForCollab,\n\tincludeStaged: (upgrade: SchemaUpgrade) => boolean,\n): JsonCompatible {\n\tconst stored = toStoredSchema(schema, {\n\t\tincludeStaged,\n\t\tincludeStagedOptional: includeStaged,\n\t});\n\tconst codec = schemaCodecBuilder.build({\n\t\tminVersionForCollab,\n\t\tjsonValidator: FormatValidatorNoOp,\n\t});\n\treturn codec.encode(stored) as JsonCompatible;\n}\n\n/**\n * Compares two schema extracted using {@link extractPersistedSchema}.\n * Reports the same compatibility that {@link TreeView.compatibility} would report if\n * opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.\n *\n * @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.\n * @param view - Schema which would be used to view persisted content.\n * @param options - {@link ICodecOptions} used when parsing the provided schema.\n * @param canInitialize - Passed through to the return value unchanged and otherwise unused.\n * @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.\n *\n * @remarks\n * This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.\n * It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.\n *\n * @example\n * An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,\n * then test that documents using those schema can be upgraded to work with the current schema using a test like:\n * ```typescript\n * assert(\n * \tcomparePersistedSchema(\n * \t\trequire(\"./schema.json\"),\n * \t\tMySchema,\n * \t\t{ jsonValidator: typeboxValidator },\n * \t\tfalse,\n * \t).canUpgrade,\n * );\n * ```\n * @alpha\n */\nexport function comparePersistedSchema(\n\tpersisted: JsonCompatible,\n\tview: ImplicitFieldSchema,\n\toptions: ICodecOptions,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\tconst schemaCodec = schemaCodecBuilder.buildDecoder(options);\n\tconst stored = schemaCodec.decode(persisted);\n\tconst config = new TreeViewConfigurationAlpha({\n\t\tschema: normalizeFieldSchema(view),\n\t});\n\tconst viewSchema = new SchemaCompatibilityTester(config);\n\treturn viewSchema.checkCompatibility(stored);\n}\n"]}
1
+ {"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,mBAAmB,EAAsB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAGtE,OAAO,EAAE,oBAAoB,EAA4B,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAG1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAA2B,EAC3B,mBAA4C,EAC5C,aAAkD;IAElD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE;QACrC,aAAa;QACb,qBAAqB,EAAE,aAAa;KACpC,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC;QACtC,mBAAmB;QACnB,aAAa,EAAE,mBAAmB;KAClC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAmB,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,sBAAsB,CACrC,SAAyB,EACzB,IAAyB,EACzB,OAAsB;IAEtB,MAAM,WAAW,GAAG,kBAAkB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,0BAA0B,CAAC;QAC7C,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC;KAClC,CAAC,CAAC;IACH,OAAO,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { FormatValidatorNoOp, type ICodecOptions } from \"../../codec/index.js\";\nimport { schemaCodecBuilder } from \"../../feature-libraries/index.js\";\nimport type { JsonCompatible } from \"../../util/index.js\";\nimport type { SchemaUpgrade } from \"../core/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\n\nimport { TreeViewConfigurationAlpha } from \"./configuration.js\";\nimport { checkSchemaCompatibility } from \"./schemaCompatibilityTester.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Dumps the \"persisted\" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.\n *\n * @param schema - The schema to dump.\n * @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.\n * @param includeStaged - filter for selecting which staged allowed types to include in the output.\n *\n * @remarks\n * This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.\n * This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.\n *\n * This only includes the \"persisted\" subset of schema information, which means the portion which gets included in documents.\n * It thus uses \"persisted\" keys, see {@link FieldProps.key}.\n *\n * If two schema have identical \"persisted\" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.\n *\n * See also {@link comparePersistedSchema}.\n *\n * @example\n * An application could use this API to generate a `schema.json` file when it first releases,\n * then test that the schema is sill compatible with documents from that version with a test like :\n * ```typescript\n * assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require(\"./schema.json\"));\n * ```\n *\n * @privateRemarks\n * This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).\n * This intentionally does not leak the format types in the API.\n *\n * Public API surface uses \"persisted\" terminology while internally we use \"stored\".\n * @alpha\n */\nexport function extractPersistedSchema(\n\tschema: ImplicitFieldSchema,\n\tminVersionForCollab: MinimumVersionForCollab,\n\tincludeStaged: (upgrade: SchemaUpgrade) => boolean,\n): JsonCompatible {\n\tconst stored = toStoredSchema(schema, {\n\t\tincludeStaged,\n\t\tincludeStagedOptional: includeStaged,\n\t});\n\tconst codec = schemaCodecBuilder.build({\n\t\tminVersionForCollab,\n\t\tjsonValidator: FormatValidatorNoOp,\n\t});\n\treturn codec.encode(stored) as JsonCompatible;\n}\n\n/**\n * Compares two schema extracted using {@link extractPersistedSchema}.\n * Reports the same compatibility that {@link TreeView.compatibility} would report if\n * opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.\n *\n * @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.\n * @param view - Schema which would be used to view persisted content.\n * @param options - {@link ICodecOptions} used when parsing the provided schema.\n * @param canInitialize - Passed through to the return value unchanged and otherwise unused.\n * @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.\n *\n * @remarks\n * This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.\n * It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.\n *\n * @example\n * An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,\n * then test that documents using those schema can be upgraded to work with the current schema using a test like:\n * ```typescript\n * assert(\n * \tcomparePersistedSchema(\n * \t\trequire(\"./schema.json\"),\n * \t\tMySchema,\n * \t\t{ jsonValidator: typeboxValidator },\n * \t\tfalse,\n * \t).canUpgrade,\n * );\n * ```\n * @alpha\n */\nexport function comparePersistedSchema(\n\tpersisted: JsonCompatible,\n\tview: ImplicitFieldSchema,\n\toptions: ICodecOptions,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\tconst schemaCodec = schemaCodecBuilder.buildDecoder(options);\n\tconst stored = schemaCodec.decode(persisted);\n\tconst config = new TreeViewConfigurationAlpha({\n\t\tschema: normalizeFieldSchema(view),\n\t});\n\treturn checkSchemaCompatibility(config, stored);\n}\n"]}
@@ -73,8 +73,19 @@ export interface ITreeAlpha extends ITree {
73
73
  /**
74
74
  * Creates a fork of the current state of the main branch.
75
75
  * This new branch will be shared with and editable by all clients.
76
+ * @param name - Optional name for the new branch.
77
+ * This name is not guaranteed to be unique.
78
+ * (Maximum {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length | length}: 1024)
79
+ * @returns The ID of the new branch, which can be used to {@link ITreeAlpha.viewSharedBranchWith | view} the branch.
76
80
  */
77
- createSharedBranch(): string;
81
+ createSharedBranch(name?: string): string;
82
+ /**
83
+ * Retrieves the name, if any, of the shared branch with the given ID.
84
+ * @param branchId - The ID of the shared branch to retrieve the name of.
85
+ * @returns The name of the shared branch, or `undefined` if the branch has no assigned name.
86
+ * @throws if the branch with the given ID does not exist.
87
+ */
88
+ getSharedBranchName(branchId: string): string | undefined;
78
89
  /**
79
90
  * Returns a list of all shared branches that currently exist on this tree.
80
91
  * Any one of them can be checked out using {@link ITreeAlpha.viewSharedBranchWith}.
@@ -286,6 +297,15 @@ export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
286
297
  * @throws UsageError if the branches are unrelated.
287
298
  */
288
299
  isMissingEditsFrom(branch: TreeBranch): boolean;
300
+ /**
301
+ * Computes the net change that would result if this branch were {@link TreeBranch.rebaseOnto | rebased onto} the given branch.
302
+ * Note that this method does not actually perform the rebase and therefore has no effect on this branch.
303
+ *
304
+ * @param branch - The branch that would be rebased onto.
305
+ * @returns The net change that would result if this branch were rebased onto the given branch,
306
+ * or `undefined` if rebasing would have no impact.
307
+ */
308
+ computeNetChangeIfRebasedOnto(branch: TreeBranch): JsonCompatibleReadOnly | undefined;
289
309
  }
290
310
  /**
291
311
  * An editable view of a (version control style) branch of a shared tree based on some schema.
@@ -329,7 +349,7 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
329
349
  /**
330
350
  * Description of the current compatibility status between the view schema and stored schema.
331
351
  * @remarks
332
- * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status changes.
352
+ * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status of the document's stored schema changes.
333
353
  * See {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution/ | schema-evolution} for more guidance on how to change schema while maintaining compatibility.
334
354
  * Use {@link snapshotSchemaCompatibility} to write tests to validate that this compatibility behaves as desired across schema changes.
335
355
  */
@@ -343,6 +363,44 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
343
363
  *
344
364
  * It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false.
345
365
  * {@link SchemaCompatibilityStatus.canUpgrade} being true does not mean that an upgrade is required, nor that an upgrade will have any effect.
366
+ *
367
+ * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},
368
+ * staged schema upgrades matching the configured policy are included in the target stored schema.
369
+ * Once a staged schema upgrade has been enabled in a document's stored schema, loading that document
370
+ * with a view that does not include equivalent staged members in its construction-time policy will cause
371
+ * `upgradeSchema` to throw a `UsageError` because the requested target would narrow the stored schema.
372
+ *
373
+ * @example Enabling a staged allowed type for documents, selected by a feature flag
374
+ *
375
+ * ```typescript
376
+ * const sf = new SchemaFactoryBeta("my-app");
377
+ *
378
+ * class TaskItem extends sf.object("TaskItem", { title: sf.string }) {}
379
+ * class ChecklistItem extends sf.object("ChecklistItem", { text: sf.string }) {}
380
+ *
381
+ * // `staged` wraps ChecklistItem so it can be enabled at runtime.
382
+ * const stagedChecklist = SchemaFactoryBeta.staged(ChecklistItem);
383
+ * const checklistUpgrade = stagedChecklist.metadata.stagedSchemaUpgrade;
384
+ *
385
+ * class AppSchema extends sf.object("AppSchema", {
386
+ * items: sf.array([TaskItem, stagedChecklist]),
387
+ * }) {}
388
+ *
389
+ * // Feature flag controls whether the upgrade is enabled for this session.
390
+ * const policy = featureFlags.enableChecklist
391
+ * ? StagedSchemaUpgradePolicy.enabledStagedUpgrades(checklistUpgrade)
392
+ * : undefined;
393
+ *
394
+ * const view = tree.viewWith(
395
+ * new TreeViewConfigurationAlpha({ schema: AppSchema, stagedUpgradePolicy: policy }),
396
+ * );
397
+ *
398
+ * if (view.compatibility.canUpgrade) {
399
+ * // Writes the staged type into the document's stored schema.
400
+ * view.upgradeSchema();
401
+ * }
402
+ * ```
403
+ *
346
404
  * @privateRemarks
347
405
  * In the future, more upgrade options could be provided here.
348
406
  * Some options that could be added:
@@ -359,8 +417,12 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
359
417
  /**
360
418
  * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.
361
419
  *
420
+ * @remarks
362
421
  * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.
363
422
  *
423
+ * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},
424
+ * staged schema upgrades matching the configured policy are included in the initial stored schema.
425
+ *
364
426
  * Applications should typically call this function before attaching a `SharedTree`.
365
427
  * @param content - The content to initialize the tree with.
366
428
  */
@@ -429,6 +491,21 @@ export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extend
429
491
  export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> extends Omit<TreeViewBeta<ReadSchema<TSchema>>, "root" | "initialize" | "fork" | "runTransaction" | "runTransactionAsync">, TreeBranchAlpha {
430
492
  get root(): ReadableField<TSchema>;
431
493
  set root(newRoot: InsertableField<TSchema>);
494
+ /**
495
+ * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.
496
+ *
497
+ * @remarks
498
+ * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.
499
+ *
500
+ * Enables staged schema upgrades declared by {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy} when generating the initial stored schema.
501
+ * Once a staged schema upgrade has been enabled in a document's stored schema, loading that document
502
+ * with a view that does not include equivalent staged members in its construction-time policy will cause
503
+ * a subsequent `upgradeSchema` call to throw a `UsageError` because the stored schema already contains
504
+ * the upgraded members and the new target would narrow it.
505
+ *
506
+ * Applications should typically call this function before attaching a `SharedTree`.
507
+ * @param content - The content to initialize the tree with.
508
+ */
432
509
  initialize(content: InsertableField<TSchema>): void;
433
510
  readonly events: Listenable<TreeViewEvents & TreeBranchEvents>;
434
511
  fork(): ReturnType<TreeBranch["fork"]> & TreeViewAlpha<TSchema>;
@@ -440,7 +517,7 @@ export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | Unsa
440
517
  * See SharedTree's README for more information about choosing a compatibility policy.
441
518
  *
442
519
  * @privateRemarks
443
- * See {@link SchemaCompatibilityTester} for the implementation of this compatibility checking.
520
+ * See {@link checkSchemaCompatibility} for the implementation of this compatibility checking.
444
521
  *
445
522
  * @sealed @public
446
523
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE/F,OAAO,KAAK,EACX,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,MAAM,qBAAqB,CAAC;AAO7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,KAAK,EACX,mBAAmB,EACnB,eAAe,EACf,oCAAoC,EACpC,aAAa,EACb,UAAU,EACV,0BAA0B,EAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oB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