@fluidframework/tree 2.110.0 → 2.112.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (598) hide show
  1. package/.vscode/settings.json +1 -0
  2. package/CHANGELOG.md +193 -0
  3. package/api-report/tree.alpha.api.md +96 -36
  4. package/api-report/tree.beta.api.md +39 -1
  5. package/api-report/tree.legacy.beta.api.md +39 -1
  6. package/api-report/tree.legacy.public.api.md +1 -1
  7. package/api-report/tree.public.api.md +1 -1
  8. package/dist/componentApi.d.ts +198 -0
  9. package/dist/componentApi.d.ts.map +1 -0
  10. package/dist/componentApi.js +138 -0
  11. package/dist/componentApi.js.map +1 -0
  12. package/dist/core/change-family/changeFamily.d.ts +3 -10
  13. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  14. package/dist/core/change-family/changeFamily.js.map +1 -1
  15. package/dist/core/rebase/types.d.ts +2 -2
  16. package/dist/core/rebase/types.js.map +1 -1
  17. package/dist/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  18. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  19. package/dist/entrypoints/alpha.d.ts +1 -1
  20. package/dist/entrypoints/alpha.d.ts.map +1 -1
  21. package/dist/entrypoints/alpha.js +4 -2
  22. package/dist/entrypoints/alpha.js.map +1 -1
  23. package/dist/entrypoints/beta.d.ts +1 -1
  24. package/dist/entrypoints/beta.d.ts.map +1 -1
  25. package/dist/entrypoints/beta.js.map +1 -1
  26. package/dist/entrypoints/legacy.d.ts +1 -1
  27. package/dist/entrypoints/legacy.d.ts.map +1 -1
  28. package/dist/entrypoints/legacy.js.map +1 -1
  29. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -20
  30. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  31. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +13 -32
  32. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
  34. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  35. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +73 -28
  37. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  38. package/dist/feature-libraries/chunked-forest/codec/codecs.js +76 -9
  39. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +4 -2
  41. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  42. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +11 -0
  43. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  44. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  45. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/codec/index.js +2 -1
  47. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +1 -1
  49. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +3 -15
  51. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  53. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/index.js +2 -1
  55. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  56. package/dist/feature-libraries/forest-summary/codec.d.ts +3 -3
  57. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  58. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  59. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
  60. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  61. package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -6
  62. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  63. package/dist/feature-libraries/index.d.ts +3 -3
  64. package/dist/feature-libraries/index.d.ts.map +1 -1
  65. package/dist/feature-libraries/index.js +4 -2
  66. package/dist/feature-libraries/index.js.map +1 -1
  67. package/dist/feature-libraries/modular-schema/index.d.ts +1 -0
  68. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  69. package/dist/feature-libraries/modular-schema/index.js +3 -1
  70. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  71. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
  72. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
  73. package/dist/feature-libraries/modular-schema/minimizeModularChange.js +29 -0
  74. package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
  75. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  76. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +9 -9
  77. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  78. package/dist/feature-libraries/schemaChecker.d.ts +22 -3
  79. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
  80. package/dist/feature-libraries/schemaChecker.js +48 -5
  81. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  82. package/dist/index.d.ts +4 -3
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +6 -2
  85. package/dist/index.js.map +1 -1
  86. package/dist/packageVersion.d.ts +1 -1
  87. package/dist/packageVersion.js +1 -1
  88. package/dist/packageVersion.js.map +1 -1
  89. package/dist/shared-tree/independentView.d.ts +17 -4
  90. package/dist/shared-tree/independentView.d.ts.map +1 -1
  91. package/dist/shared-tree/independentView.js +15 -12
  92. package/dist/shared-tree/independentView.js.map +1 -1
  93. package/dist/shared-tree/index.d.ts +3 -2
  94. package/dist/shared-tree/index.d.ts.map +1 -1
  95. package/dist/shared-tree/index.js +3 -1
  96. package/dist/shared-tree/index.js.map +1 -1
  97. package/dist/shared-tree/schematizingTreeView.d.ts +6 -5
  98. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  99. package/dist/shared-tree/schematizingTreeView.js +6 -3
  100. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  101. package/dist/shared-tree/serializedChange.d.ts +41 -0
  102. package/dist/shared-tree/serializedChange.d.ts.map +1 -0
  103. package/dist/shared-tree/serializedChange.js +87 -0
  104. package/dist/shared-tree/serializedChange.js.map +1 -0
  105. package/dist/shared-tree/sharedTree.d.ts +18 -0
  106. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  107. package/dist/shared-tree/sharedTree.js +9 -4
  108. package/dist/shared-tree/sharedTree.js.map +1 -1
  109. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
  110. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  111. package/dist/shared-tree/sharedTreeChangeFamily.js +8 -1
  112. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  113. package/dist/shared-tree/transactionMinimize.d.ts +35 -0
  114. package/dist/shared-tree/transactionMinimize.d.ts.map +1 -0
  115. package/dist/shared-tree/transactionMinimize.js +65 -0
  116. package/dist/shared-tree/transactionMinimize.js.map +1 -0
  117. package/dist/shared-tree/transactionPostProcessor.d.ts +28 -0
  118. package/dist/shared-tree/transactionPostProcessor.d.ts.map +1 -0
  119. package/dist/shared-tree/transactionPostProcessor.js +28 -0
  120. package/dist/shared-tree/transactionPostProcessor.js.map +1 -0
  121. package/dist/shared-tree/treeAlpha.js +3 -3
  122. package/dist/shared-tree/treeAlpha.js.map +1 -1
  123. package/dist/shared-tree/treeCheckout.d.ts +19 -13
  124. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  125. package/dist/shared-tree/treeCheckout.js +54 -71
  126. package/dist/shared-tree/treeCheckout.js.map +1 -1
  127. package/dist/shared-tree/unhydratedTreeContext.d.ts +5 -5
  128. package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  129. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  130. package/dist/shared-tree-core/editManager.d.ts +6 -3
  131. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  132. package/dist/shared-tree-core/editManager.js +35 -14
  133. package/dist/shared-tree-core/editManager.js.map +1 -1
  134. package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -2
  135. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  136. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  137. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -9
  138. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  139. package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -4
  140. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  141. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -3
  142. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  143. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  144. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -3
  145. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  146. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  147. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
  148. package/dist/shared-tree-core/editManagerFormatCommons.js +1 -1
  149. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  150. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
  151. package/dist/shared-tree-core/editManagerSummarizer.d.ts +5 -9
  152. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  153. package/dist/shared-tree-core/editManagerSummarizer.js +5 -10
  154. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  155. package/dist/shared-tree-core/index.d.ts +1 -1
  156. package/dist/shared-tree-core/index.d.ts.map +1 -1
  157. package/dist/shared-tree-core/index.js +3 -2
  158. package/dist/shared-tree-core/index.js.map +1 -1
  159. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  160. package/dist/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  161. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  162. package/dist/shared-tree-core/messageFormat.d.ts +1 -1
  163. package/dist/shared-tree-core/messageFormat.js +1 -1
  164. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  165. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
  166. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  167. package/dist/shared-tree-core/messageFormatVSharedBranches.js +1 -0
  168. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  169. package/dist/shared-tree-core/messageTypes.d.ts +1 -0
  170. package/dist/shared-tree-core/messageTypes.d.ts.map +1 -1
  171. package/dist/shared-tree-core/messageTypes.js.map +1 -1
  172. package/dist/shared-tree-core/sharedTreeCore.d.ts +9 -3
  173. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  174. package/dist/shared-tree-core/sharedTreeCore.js +27 -12
  175. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  176. package/dist/shared-tree-core/transaction.d.ts +84 -9
  177. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  178. package/dist/shared-tree-core/transaction.js +88 -7
  179. package/dist/shared-tree-core/transaction.js.map +1 -1
  180. package/dist/simple-tree/api/index.d.ts +2 -2
  181. package/dist/simple-tree/api/index.d.ts.map +1 -1
  182. package/dist/simple-tree/api/index.js +2 -2
  183. package/dist/simple-tree/api/index.js.map +1 -1
  184. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +9 -24
  185. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  186. package/dist/simple-tree/api/schemaCompatibilityTester.js +31 -44
  187. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  188. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  189. package/dist/simple-tree/api/schemaCreationUtilities.js +3 -3
  190. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  191. package/dist/simple-tree/api/schemaFactory.d.ts +1 -1
  192. package/dist/simple-tree/api/schemaFactory.js +2 -2
  193. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  194. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
  195. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  196. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  197. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
  198. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  199. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  200. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +2 -2
  201. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  202. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +3 -4
  203. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  204. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  205. package/dist/simple-tree/api/storedSchema.js +1 -2
  206. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  207. package/dist/simple-tree/api/transactionTypes.d.ts +91 -28
  208. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  209. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  210. package/dist/simple-tree/api/tree.d.ts +108 -24
  211. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  212. package/dist/simple-tree/api/tree.js.map +1 -1
  213. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  214. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  215. package/dist/simple-tree/api/typesUnsafe.d.ts +2 -2
  216. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  217. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  218. package/dist/simple-tree/core/treeNodeSchema.d.ts +7 -7
  219. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  220. package/dist/simple-tree/index.d.ts +1 -1
  221. package/dist/simple-tree/index.d.ts.map +1 -1
  222. package/dist/simple-tree/index.js +2 -2
  223. package/dist/simple-tree/index.js.map +1 -1
  224. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +83 -4
  225. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  226. package/dist/simple-tree/node-kinds/array/arrayNode.js +39 -0
  227. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  228. package/dist/simple-tree/simpleSchemaFormatV1.js +1 -1
  229. package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  230. package/dist/text/index.d.ts +1 -0
  231. package/dist/text/index.d.ts.map +1 -1
  232. package/dist/text/index.js +3 -1
  233. package/dist/text/index.js.map +1 -1
  234. package/dist/text/textDomainFormatted.d.ts +69 -758
  235. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  236. package/dist/text/textDomainFormatted.js +275 -322
  237. package/dist/text/textDomainFormatted.js.map +1 -1
  238. package/dist/text/textDomainFormattedDefault.d.ts +273 -0
  239. package/dist/text/textDomainFormattedDefault.d.ts.map +1 -0
  240. package/dist/text/textDomainFormattedDefault.js +94 -0
  241. package/dist/text/textDomainFormattedDefault.js.map +1 -0
  242. package/dist/treeFactory.js +1 -1
  243. package/dist/treeFactory.js.map +1 -1
  244. package/dist/util/breakable.d.ts +16 -1
  245. package/dist/util/breakable.d.ts.map +1 -1
  246. package/dist/util/breakable.js +9 -1
  247. package/dist/util/breakable.js.map +1 -1
  248. package/dist/util/compressedIds.d.ts +185 -0
  249. package/dist/util/compressedIds.d.ts.map +1 -0
  250. package/dist/util/compressedIds.js +164 -0
  251. package/dist/util/compressedIds.js.map +1 -0
  252. package/dist/util/index.d.ts +2 -1
  253. package/dist/util/index.d.ts.map +1 -1
  254. package/dist/util/index.js +10 -2
  255. package/dist/util/index.js.map +1 -1
  256. package/dist/util/nestedMap.d.ts.map +1 -1
  257. package/dist/util/nestedMap.js +16 -3
  258. package/dist/util/nestedMap.js.map +1 -1
  259. package/dist/util/nestedSet.d.ts +1 -1
  260. package/dist/util/nestedSet.d.ts.map +1 -1
  261. package/dist/util/nestedSet.js.map +1 -1
  262. package/dist/util/utils.d.ts +0 -6
  263. package/dist/util/utils.d.ts.map +1 -1
  264. package/dist/util/utils.js +1 -15
  265. package/dist/util/utils.js.map +1 -1
  266. package/lib/componentApi.d.ts +198 -0
  267. package/lib/componentApi.d.ts.map +1 -0
  268. package/lib/componentApi.js +135 -0
  269. package/lib/componentApi.js.map +1 -0
  270. package/lib/core/change-family/changeFamily.d.ts +3 -10
  271. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  272. package/lib/core/change-family/changeFamily.js.map +1 -1
  273. package/lib/core/rebase/types.d.ts +2 -2
  274. package/lib/core/rebase/types.js.map +1 -1
  275. package/lib/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  276. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  277. package/lib/entrypoints/alpha.d.ts +1 -1
  278. package/lib/entrypoints/alpha.d.ts.map +1 -1
  279. package/lib/entrypoints/alpha.js +1 -1
  280. package/lib/entrypoints/alpha.js.map +1 -1
  281. package/lib/entrypoints/beta.d.ts +1 -1
  282. package/lib/entrypoints/beta.d.ts.map +1 -1
  283. package/lib/entrypoints/beta.js.map +1 -1
  284. package/lib/entrypoints/legacy.d.ts +1 -1
  285. package/lib/entrypoints/legacy.d.ts.map +1 -1
  286. package/lib/entrypoints/legacy.js.map +1 -1
  287. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -20
  288. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  289. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +14 -33
  290. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  291. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
  292. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  293. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  294. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +73 -28
  295. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  296. package/lib/feature-libraries/chunked-forest/codec/codecs.js +75 -9
  297. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  298. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +4 -2
  299. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  300. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +12 -1
  301. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  302. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  303. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  304. package/lib/feature-libraries/chunked-forest/codec/index.js +1 -1
  305. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  306. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +1 -1
  307. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  308. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +3 -15
  309. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  310. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  311. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  312. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  313. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  314. package/lib/feature-libraries/forest-summary/codec.d.ts +3 -3
  315. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  316. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  317. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
  318. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  319. package/lib/feature-libraries/forest-summary/forestSummarizer.js +4 -6
  320. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  321. package/lib/feature-libraries/index.d.ts +3 -3
  322. package/lib/feature-libraries/index.d.ts.map +1 -1
  323. package/lib/feature-libraries/index.js +2 -2
  324. package/lib/feature-libraries/index.js.map +1 -1
  325. package/lib/feature-libraries/modular-schema/index.d.ts +1 -0
  326. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  327. package/lib/feature-libraries/modular-schema/index.js +1 -0
  328. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  329. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
  330. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
  331. package/lib/feature-libraries/modular-schema/minimizeModularChange.js +25 -0
  332. package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
  333. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  334. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +10 -10
  335. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  336. package/lib/feature-libraries/schemaChecker.d.ts +22 -3
  337. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
  338. package/lib/feature-libraries/schemaChecker.js +48 -5
  339. package/lib/feature-libraries/schemaChecker.js.map +1 -1
  340. package/lib/index.d.ts +4 -3
  341. package/lib/index.d.ts.map +1 -1
  342. package/lib/index.js +3 -2
  343. package/lib/index.js.map +1 -1
  344. package/lib/packageVersion.d.ts +1 -1
  345. package/lib/packageVersion.js +1 -1
  346. package/lib/packageVersion.js.map +1 -1
  347. package/lib/shared-tree/independentView.d.ts +17 -4
  348. package/lib/shared-tree/independentView.d.ts.map +1 -1
  349. package/lib/shared-tree/independentView.js +13 -10
  350. package/lib/shared-tree/independentView.js.map +1 -1
  351. package/lib/shared-tree/index.d.ts +3 -2
  352. package/lib/shared-tree/index.d.ts.map +1 -1
  353. package/lib/shared-tree/index.js +1 -0
  354. package/lib/shared-tree/index.js.map +1 -1
  355. package/lib/shared-tree/schematizingTreeView.d.ts +6 -5
  356. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  357. package/lib/shared-tree/schematizingTreeView.js +7 -4
  358. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  359. package/lib/shared-tree/serializedChange.d.ts +41 -0
  360. package/lib/shared-tree/serializedChange.d.ts.map +1 -0
  361. package/lib/shared-tree/serializedChange.js +84 -0
  362. package/lib/shared-tree/serializedChange.js.map +1 -0
  363. package/lib/shared-tree/sharedTree.d.ts +18 -0
  364. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  365. package/lib/shared-tree/sharedTree.js +10 -5
  366. package/lib/shared-tree/sharedTree.js.map +1 -1
  367. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
  368. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  369. package/lib/shared-tree/sharedTreeChangeFamily.js +7 -1
  370. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  371. package/lib/shared-tree/transactionMinimize.d.ts +35 -0
  372. package/lib/shared-tree/transactionMinimize.d.ts.map +1 -0
  373. package/lib/shared-tree/transactionMinimize.js +62 -0
  374. package/lib/shared-tree/transactionMinimize.js.map +1 -0
  375. package/lib/shared-tree/transactionPostProcessor.d.ts +28 -0
  376. package/lib/shared-tree/transactionPostProcessor.d.ts.map +1 -0
  377. package/lib/shared-tree/transactionPostProcessor.js +23 -0
  378. package/lib/shared-tree/transactionPostProcessor.js.map +1 -0
  379. package/lib/shared-tree/treeAlpha.js +3 -3
  380. package/lib/shared-tree/treeAlpha.js.map +1 -1
  381. package/lib/shared-tree/treeCheckout.d.ts +19 -13
  382. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  383. package/lib/shared-tree/treeCheckout.js +36 -53
  384. package/lib/shared-tree/treeCheckout.js.map +1 -1
  385. package/lib/shared-tree/unhydratedTreeContext.d.ts +5 -5
  386. package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  387. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  388. package/lib/shared-tree-core/editManager.d.ts +6 -3
  389. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  390. package/lib/shared-tree-core/editManager.js +36 -15
  391. package/lib/shared-tree-core/editManager.js.map +1 -1
  392. package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -2
  393. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  394. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  395. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -9
  396. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  397. package/lib/shared-tree-core/editManagerCodecsCommons.js +3 -5
  398. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  399. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -3
  400. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  401. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  402. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -3
  403. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  404. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  405. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
  406. package/lib/shared-tree-core/editManagerFormatCommons.js +1 -1
  407. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  408. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
  409. package/lib/shared-tree-core/editManagerSummarizer.d.ts +5 -9
  410. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  411. package/lib/shared-tree-core/editManagerSummarizer.js +5 -10
  412. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  413. package/lib/shared-tree-core/index.d.ts +1 -1
  414. package/lib/shared-tree-core/index.d.ts.map +1 -1
  415. package/lib/shared-tree-core/index.js +1 -1
  416. package/lib/shared-tree-core/index.js.map +1 -1
  417. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  418. package/lib/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  419. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  420. package/lib/shared-tree-core/messageFormat.d.ts +1 -1
  421. package/lib/shared-tree-core/messageFormat.js +1 -1
  422. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  423. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
  424. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  425. package/lib/shared-tree-core/messageFormatVSharedBranches.js +1 -0
  426. package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  427. package/lib/shared-tree-core/messageTypes.d.ts +1 -0
  428. package/lib/shared-tree-core/messageTypes.d.ts.map +1 -1
  429. package/lib/shared-tree-core/messageTypes.js.map +1 -1
  430. package/lib/shared-tree-core/sharedTreeCore.d.ts +9 -3
  431. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  432. package/lib/shared-tree-core/sharedTreeCore.js +28 -13
  433. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  434. package/lib/shared-tree-core/transaction.d.ts +84 -9
  435. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  436. package/lib/shared-tree-core/transaction.js +87 -6
  437. package/lib/shared-tree-core/transaction.js.map +1 -1
  438. package/lib/simple-tree/api/index.d.ts +2 -2
  439. package/lib/simple-tree/api/index.d.ts.map +1 -1
  440. package/lib/simple-tree/api/index.js +1 -1
  441. package/lib/simple-tree/api/index.js.map +1 -1
  442. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +9 -24
  443. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  444. package/lib/simple-tree/api/schemaCompatibilityTester.js +29 -42
  445. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  446. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  447. package/lib/simple-tree/api/schemaCreationUtilities.js +3 -3
  448. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  449. package/lib/simple-tree/api/schemaFactory.d.ts +1 -1
  450. package/lib/simple-tree/api/schemaFactory.js +2 -2
  451. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  452. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
  453. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  454. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  455. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
  456. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  457. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  458. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +2 -2
  459. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  460. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +4 -5
  461. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  462. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  463. package/lib/simple-tree/api/storedSchema.js +2 -3
  464. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  465. package/lib/simple-tree/api/transactionTypes.d.ts +91 -28
  466. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  467. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  468. package/lib/simple-tree/api/tree.d.ts +108 -24
  469. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  470. package/lib/simple-tree/api/tree.js.map +1 -1
  471. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  472. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  473. package/lib/simple-tree/api/typesUnsafe.d.ts +2 -2
  474. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  475. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  476. package/lib/simple-tree/core/treeNodeSchema.d.ts +7 -7
  477. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  478. package/lib/simple-tree/index.d.ts +1 -1
  479. package/lib/simple-tree/index.d.ts.map +1 -1
  480. package/lib/simple-tree/index.js +1 -1
  481. package/lib/simple-tree/index.js.map +1 -1
  482. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +83 -4
  483. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  484. package/lib/simple-tree/node-kinds/array/arrayNode.js +39 -0
  485. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  486. package/lib/simple-tree/simpleSchemaFormatV1.js +1 -1
  487. package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  488. package/lib/text/index.d.ts +1 -0
  489. package/lib/text/index.d.ts.map +1 -1
  490. package/lib/text/index.js +1 -0
  491. package/lib/text/index.js.map +1 -1
  492. package/lib/text/textDomainFormatted.d.ts +69 -758
  493. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  494. package/lib/text/textDomainFormatted.js +277 -324
  495. package/lib/text/textDomainFormatted.js.map +1 -1
  496. package/lib/text/textDomainFormattedDefault.d.ts +273 -0
  497. package/lib/text/textDomainFormattedDefault.d.ts.map +1 -0
  498. package/lib/text/textDomainFormattedDefault.js +91 -0
  499. package/lib/text/textDomainFormattedDefault.js.map +1 -0
  500. package/lib/treeFactory.js +1 -1
  501. package/lib/treeFactory.js.map +1 -1
  502. package/lib/util/breakable.d.ts +16 -1
  503. package/lib/util/breakable.d.ts.map +1 -1
  504. package/lib/util/breakable.js +9 -1
  505. package/lib/util/breakable.js.map +1 -1
  506. package/lib/util/compressedIds.d.ts +185 -0
  507. package/lib/util/compressedIds.d.ts.map +1 -0
  508. package/lib/util/compressedIds.js +154 -0
  509. package/lib/util/compressedIds.js.map +1 -0
  510. package/lib/util/index.d.ts +2 -1
  511. package/lib/util/index.d.ts.map +1 -1
  512. package/lib/util/index.js +2 -1
  513. package/lib/util/index.js.map +1 -1
  514. package/lib/util/nestedMap.d.ts.map +1 -1
  515. package/lib/util/nestedMap.js +17 -4
  516. package/lib/util/nestedMap.js.map +1 -1
  517. package/lib/util/nestedSet.d.ts +1 -1
  518. package/lib/util/nestedSet.d.ts.map +1 -1
  519. package/lib/util/nestedSet.js.map +1 -1
  520. package/lib/util/utils.d.ts +0 -6
  521. package/lib/util/utils.d.ts.map +1 -1
  522. package/lib/util/utils.js +0 -13
  523. package/lib/util/utils.js.map +1 -1
  524. package/package.json +23 -23
  525. package/src/componentApi.ts +354 -0
  526. package/src/core/change-family/changeFamily.ts +3 -12
  527. package/src/core/rebase/types.ts +2 -2
  528. package/src/core/schema-stored/storedSchemaRepository.ts +2 -2
  529. package/src/entrypoints/alpha.ts +15 -8
  530. package/src/entrypoints/beta.ts +8 -0
  531. package/src/entrypoints/legacy.ts +8 -0
  532. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +22 -72
  533. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -2
  534. package/src/feature-libraries/chunked-forest/codec/codecs.ts +110 -41
  535. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +32 -4
  536. package/src/feature-libraries/chunked-forest/codec/index.ts +1 -0
  537. package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +7 -19
  538. package/src/feature-libraries/chunked-forest/index.ts +3 -0
  539. package/src/feature-libraries/forest-summary/codec.ts +5 -3
  540. package/src/feature-libraries/forest-summary/forestSummarizer.ts +4 -5
  541. package/src/feature-libraries/index.ts +5 -0
  542. package/src/feature-libraries/modular-schema/index.ts +1 -0
  543. package/src/feature-libraries/modular-schema/minimizeModularChange.ts +33 -0
  544. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +13 -9
  545. package/src/feature-libraries/schemaChecker.ts +86 -9
  546. package/src/index.ts +16 -8
  547. package/src/packageVersion.ts +1 -1
  548. package/src/shared-tree/independentView.ts +40 -15
  549. package/src/shared-tree/index.ts +4 -0
  550. package/src/shared-tree/schematizingTreeView.ts +40 -30
  551. package/src/shared-tree/serializedChange.ts +127 -0
  552. package/src/shared-tree/sharedTree.ts +32 -4
  553. package/src/shared-tree/sharedTreeChangeFamily.ts +7 -1
  554. package/src/shared-tree/transactionMinimize.ts +74 -0
  555. package/src/shared-tree/transactionPostProcessor.ts +40 -0
  556. package/src/shared-tree/treeAlpha.ts +3 -3
  557. package/src/shared-tree/treeCheckout.ts +103 -101
  558. package/src/shared-tree/unhydratedTreeContext.ts +18 -15
  559. package/src/shared-tree-core/editManager.ts +42 -6
  560. package/src/shared-tree-core/editManagerCodecs.ts +3 -2
  561. package/src/shared-tree-core/editManagerCodecsCommons.ts +10 -14
  562. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -2
  563. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -2
  564. package/src/shared-tree-core/editManagerFormatCommons.ts +1 -1
  565. package/src/shared-tree-core/editManagerSummarizer.ts +5 -9
  566. package/src/shared-tree-core/index.ts +8 -5
  567. package/src/shared-tree-core/messageCodecVSharedBranches.ts +8 -1
  568. package/src/shared-tree-core/messageFormat.ts +1 -1
  569. package/src/shared-tree-core/messageFormatVSharedBranches.ts +10 -0
  570. package/src/shared-tree-core/messageTypes.ts +1 -0
  571. package/src/shared-tree-core/sharedTreeCore.ts +36 -12
  572. package/src/shared-tree-core/transaction.ts +165 -18
  573. package/src/simple-tree/api/index.ts +14 -10
  574. package/src/simple-tree/api/schemaCompatibilityTester.ts +36 -48
  575. package/src/simple-tree/api/schemaCreationUtilities.ts +3 -3
  576. package/src/simple-tree/api/schemaFactory.ts +2 -2
  577. package/src/simple-tree/api/schemaFactoryAlpha.ts +56 -15
  578. package/src/simple-tree/api/schemaFactoryBeta.ts +0 -3
  579. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +4 -5
  580. package/src/simple-tree/api/storedSchema.ts +2 -3
  581. package/src/simple-tree/api/transactionTypes.ts +111 -39
  582. package/src/simple-tree/api/tree.ts +165 -49
  583. package/src/simple-tree/api/treeBeta.ts +2 -0
  584. package/src/simple-tree/api/typesUnsafe.ts +2 -1
  585. package/src/simple-tree/core/treeNodeSchema.ts +7 -7
  586. package/src/simple-tree/index.ts +13 -9
  587. package/src/simple-tree/node-kinds/array/arrayNode.ts +168 -4
  588. package/src/simple-tree/simpleSchemaFormatV1.ts +1 -1
  589. package/src/text/index.ts +1 -0
  590. package/src/text/textDomainFormatted.ts +520 -415
  591. package/src/text/textDomainFormattedDefault.ts +150 -0
  592. package/src/treeFactory.ts +1 -1
  593. package/src/util/breakable.ts +8 -1
  594. package/src/util/compressedIds.ts +304 -0
  595. package/src/util/index.ts +18 -1
  596. package/src/util/nestedMap.ts +21 -4
  597. package/src/util/nestedSet.ts +1 -1
  598. package/src/util/utils.ts +0 -18
@@ -40,15 +40,17 @@ export enum TransactionResult {
40
40
 
41
41
  /**
42
42
  * A simple API for managing transactions.
43
+ * @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
43
44
  */
44
- export interface Transactor {
45
+ export interface Transactor<TOptions> {
45
46
  /**
46
47
  * Start a new transaction.
48
+ * @param options - Options controlling how the transaction is committed.
47
49
  * @remarks
48
50
  * If a transaction is already in progress when this new transaction starts, then this transaction will be "nested" inside of it,
49
51
  * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.
50
52
  */
51
- start(): void;
53
+ start(options?: TOptions): void;
52
54
  /**
53
55
  * Close this transaction by squashing its edits and committing them as a single edit.
54
56
  * @remarks If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.
@@ -89,8 +91,9 @@ export interface TransactionEvents {
89
91
 
90
92
  /**
91
93
  * Callbacks for transaction lifecycle events.
94
+ * @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
92
95
  */
93
- export interface Callbacks {
96
+ export interface Callbacks<TOptions> {
94
97
  /**
95
98
  * Called when the current transaction is popped from the {@link TransactionStack | stack}.
96
99
  */
@@ -104,37 +107,42 @@ export interface Callbacks {
104
107
  * Put another way, a transaction always results in a call to exactly one `OnPush` callback - whichever is closest to the transaction.
105
108
  * The event "bubbles up" to (and no further past) its first registered callback.
106
109
  */
107
- readonly onPush?: OnPush;
110
+ readonly onPush?: OnPush<TOptions>;
108
111
  }
109
112
 
110
113
  /**
111
114
  * A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.
112
115
  * @remarks This function may return other functions that will be called when the transaction is popped from the stack or a nested transaction is pushed onto the stack.
113
116
  * This function runs just before the transaction begins, so if this is the beginning of an outermost (not nested) transaction then {@link Transactor.size} will be 0 during its execution.
117
+ * @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
118
+ * @param options - The options passed to {@link Transactor.start | start}.
114
119
  */
115
- export type OnPush = () => Callbacks | void;
120
+ export type OnPush<TOptions> = (options?: TOptions) => Callbacks<TOptions> | void;
116
121
 
117
122
  /**
118
123
  * A function that will be called when a transaction is popped from the {@link TransactionStack | stack}.
119
124
  * @remarks This function runs just after the transaction ends, so if this is the end of an outermost (not nested) transaction then {@link Transactor.size} will be 0 during its execution.
125
+ * @param result - The result of the transaction.
120
126
  */
121
127
  export type OnPop = (result: TransactionResult) => void;
122
128
 
123
129
  /**
124
130
  * A frame in the transaction stack.
131
+ * @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
125
132
  */
126
- interface TransactionStackFrame {
133
+ interface TransactionStackFrame<TOptions> {
127
134
  /** The callbacks provided when this transaction frame was pushed onto the stack. */
128
- readonly callbacks: Callbacks;
135
+ readonly callbacks: Callbacks<TOptions>;
129
136
  }
130
137
 
131
138
  /**
132
139
  * An implementation of {@link Transactor} that uses a stack to manage transactions.
133
140
  * @remarks Using a stack allows transactions to nest - i.e. an inner transaction may be started while an outer transaction is already in progress.
141
+ * @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
134
142
  */
135
- export class TransactionStack implements Transactor, IDisposable {
136
- readonly #stack: TransactionStackFrame[] = [];
137
- readonly #onPush?: OnPush;
143
+ export class TransactionStack<TOptions> implements Transactor<TOptions>, IDisposable {
144
+ readonly #stack: TransactionStackFrame<TOptions>[] = [];
145
+ readonly #onPush?: OnPush<TOptions>;
138
146
 
139
147
  readonly #events = createEmitter<TransactionEvents>();
140
148
  public get events(): Listenable<TransactionEvents> {
@@ -150,7 +158,7 @@ export class TransactionStack implements Transactor, IDisposable {
150
158
  * Construct a new {@link TransactionStack}.
151
159
  * @param onPush - A {@link OnPush | function} that will be called when a transaction begins.
152
160
  */
153
- public constructor(onPush?: OnPush) {
161
+ public constructor(onPush?: OnPush<TOptions>) {
154
162
  this.#onPush = onPush;
155
163
  }
156
164
 
@@ -159,11 +167,11 @@ export class TransactionStack implements Transactor, IDisposable {
159
167
  return this.#stack.length;
160
168
  }
161
169
 
162
- public start(): void {
170
+ public start(options?: TOptions): void {
163
171
  this.ensureNotDisposed();
164
172
  const last = getLast(this.#stack);
165
173
  const onPushCurrent = last === undefined ? this.#onPush : last.callbacks.onPush;
166
- const { onPush, onPop } = onPushCurrent?.() ?? {};
174
+ const { onPush, onPop } = onPushCurrent?.(options) ?? {};
167
175
  this.#stack.push({
168
176
  callbacks: { onPop, onPush: onPush ?? onPushCurrent },
169
177
  });
@@ -216,6 +224,73 @@ export type OnPopWithViewUpdate<TChange> = (
216
224
  viewUpdate: TChange | undefined,
217
225
  ) => void;
218
226
 
227
+ /**
228
+ * Informs the caller of {@link ChangeProcessor} what context it should be invoked for.
229
+ * @remarks This is purely a recommendation to the caller of the processor and
230
+ * not a strict rule.
231
+ */
232
+ export enum ChangeProcessorApplicability {
233
+ /**
234
+ * Invoke the processor if no later (outer) instance of this change processor
235
+ * may be applied to related changes before changes are "visible".
236
+ *
237
+ * @remarks
238
+ * This designation is meant for processors that only need to be applied
239
+ * once to a set of related changes independent of scope or nesting,
240
+ * with the understanding that the processor should still be applied no
241
+ * later than when the changes are "visible" (e.g. committed to a branch).
242
+ * For example, a processor that removes extraneous information from a
243
+ * change (e.g. data for nodes that were both created and removed within a
244
+ * transaction) only needs to be applied once to the squashed change
245
+ * produced by the outermost transaction.
246
+ */
247
+ IfOutermost,
248
+ /**
249
+ * Invoke the processor in all contexts.
250
+ */
251
+ Always,
252
+ }
253
+
254
+ /**
255
+ * Processes a change altering its representation.
256
+ *
257
+ * @remarks
258
+ * A change processor receives a change and returns a change with the
259
+ * same observable effect but otherwise transformed.
260
+ *
261
+ * Currently this is the internal counterpart of the type-erased post-processor
262
+ * exposed on the public transaction API. The public boundary type-erases this
263
+ * (see the conversion helpers in the `shared-tree` layer) so that its internal
264
+ * change representation does not leak into the public API.
265
+ */
266
+ export interface ChangeProcessor<TChange> {
267
+ /**
268
+ * Informs what context it should be invoked for.
269
+ */
270
+ readonly applicability: ChangeProcessorApplicability;
271
+ /**
272
+ * Processes the given change, returning a change with the same observable effect.
273
+ */
274
+ readonly processChange: (change: TChange) => TChange;
275
+ }
276
+
277
+ /**
278
+ * Options for {@link Transactor.start | starting} a transaction.
279
+ */
280
+ export interface SquashingTransactionOptions<TChange> {
281
+ /**
282
+ * An optional {@link ChangeProcessor} applied to the squashed change produced when a transaction that was started
283
+ * with this option is committed.
284
+ *
285
+ * @remarks
286
+ * When omitted, the transaction's edits are squashed without any post-processing.
287
+ *
288
+ * How often the processor is invoked across nested transactions is governed by its
289
+ * {@link ChangeProcessor.applicability | applicability}.
290
+ */
291
+ readonly postProcessor?: ChangeProcessor<TChange>;
292
+ }
293
+
219
294
  /**
220
295
  * An implementation of {@link Transactor} that {@link TransactionStack | uses a stack} and a {@link SharedTreeBranch | branch} to manage transactions.
221
296
  * @remarks Given a branch, this class will fork the branch when a transaction begins and squash the forked branch back into the original branch when the transaction ends.
@@ -225,7 +300,7 @@ export type OnPopWithViewUpdate<TChange> = (
225
300
  export class SquashingTransactionStack<
226
301
  TEditor extends ChangeFamilyEditor,
227
302
  TChange,
228
- > extends TransactionStack {
303
+ > extends TransactionStack<SquashingTransactionOptions<TChange>> {
229
304
  #transactionBranch?: SharedTreeBranch<TEditor, TChange>;
230
305
 
231
306
  /**
@@ -284,15 +359,41 @@ export class SquashingTransactionStack<
284
359
  * Construct a new {@link SquashingTransactionStack}.
285
360
  * @param branch - The {@link SquashingTransactionStack.branch | branch} that will be forked off of when a transaction begins.
286
361
  * @param onPush - A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.
362
+ * @remarks To post-process the squashed change produced when a transaction is committed (for example, to "minimize"
363
+ * it so that it contains no extraneous information), start the transaction with a
364
+ * {@link SquashingTransactionOptions.postProcessor | post-processor}. The post-processor is injected via the transaction
365
+ * options rather than baked into this stack, so different transactions may supply different post-processors (or none).
287
366
  */
288
367
  public constructor(
289
368
  public readonly branch: SharedTreeBranch<TEditor, TChange>,
290
369
  mintRevisionTag: () => RevisionTag,
291
370
  onPush?: () => OnPopWithViewUpdate<TChange> | void,
292
371
  ) {
372
+ // A stack of the post-processors to apply when each in-progress transaction commits, ordered from outermost to
373
+ // innermost. Each in-progress transaction contributes exactly one entry: either the processor to apply when it
374
+ // commits, or `undefined` when none should be applied.
375
+ const postProcessorStack: (ChangeProcessor<TChange> | undefined)[] = [];
376
+ // Determines the entry to push for a transaction that was started with the given `requested` processor (if any).
377
+ // A processor with "outermost" applicability that is already active in an enclosing transaction resolves to
378
+ // `undefined` so that it is only applied once (at the outermost transaction that supplied it).
379
+ const resolvePostProcessor = (
380
+ requested: ChangeProcessor<TChange> | undefined,
381
+ ): ChangeProcessor<TChange> | undefined => {
382
+ if (
383
+ requested?.applicability === ChangeProcessorApplicability.IfOutermost &&
384
+ postProcessorStack.includes(requested)
385
+ ) {
386
+ return undefined;
387
+ }
388
+ return requested;
389
+ };
390
+
293
391
  super(
294
392
  // Invoked when an outer transaction starts
295
- (): Callbacks => {
393
+ (
394
+ startOptions?: SquashingTransactionOptions<TChange>,
395
+ ): Callbacks<SquashingTransactionOptions<TChange>> => {
396
+ postProcessorStack.push(resolvePostProcessor(startOptions?.postProcessor));
296
397
  // Keep track of the commit that each transaction was on when it started
297
398
  const startHead = this.activeBranch.getHead();
298
399
  const rebaser = this.branch.changeFamily.rebaser;
@@ -309,6 +410,7 @@ export class SquashingTransactionStack<
309
410
  // Invoked when an outer transaction ends
310
411
  const onOuterTransactionPop: OnPop = (result) => {
311
412
  assert(this.size === 0, 0xcae /* The outer transaction should be ending */);
413
+ const postProcessor = postProcessorStack.pop();
312
414
  transactionBranch.editor.exitTransaction();
313
415
 
314
416
  const sourcePath: GraphCommit<TChange>[] = [];
@@ -357,16 +459,31 @@ export class SquashingTransactionStack<
357
459
  }
358
460
  // Squash all the new commits on the transaction branch into a new commit on the original branch
359
461
  const squash = rebaser.compose(transactionSteps);
462
+ // Apply this transaction's post-processor (if any) to the squashed change (for example, to
463
+ // "minimize" it so that it contains no extraneous information).
464
+ const change =
465
+ postProcessor === undefined ? squash : postProcessor.processChange(squash);
466
+
467
+ if (change !== squash) {
468
+ // The post-processor produced a change that differs from the
469
+ // one that was applied to the view as the transaction's edits
470
+ // were made. Roll back the transaction's changes on the transaction
471
+ // branch (which rolls back the view) and apply the post-processed
472
+ // change in their place so that the view fully reflects the modified
473
+ // `change`.
474
+ transactionBranch.removeAfter(startHead);
475
+ transactionBranch.apply(tagChange(change, transactionRevision));
476
+ }
360
477
 
361
478
  if (targetPath.length === 0) {
362
479
  // No changes were made on the original branch since the transaction began
363
480
  // The transaction commit can be applied directly
364
- this.branch.apply(tagChange(squash, transactionRevision));
481
+ this.branch.apply(tagChange(change, transactionRevision));
365
482
  // The view is already up-to-date so there's nothing more to do
366
483
  } else {
367
484
  // Some changes were made on `branch` since the transaction began
368
485
  const unrebasedHead = mintCommit(startHead, {
369
- change: squash,
486
+ change,
370
487
  revision: transactionRevision,
371
488
  });
372
489
  // We need to rebase the transaction commit on top of the new changes
@@ -407,13 +524,17 @@ export class SquashingTransactionStack<
407
524
  outerOnPop?.(result, viewUpdate);
408
525
  };
409
526
  // Invoked when a nested transaction begins
410
- const onNestedTransactionPush: OnPush = () => {
527
+ const onNestedTransactionPush: OnPush<SquashingTransactionOptions<TChange>> = (
528
+ nestedStartOptions,
529
+ ) => {
530
+ postProcessorStack.push(resolvePostProcessor(nestedStartOptions?.postProcessor));
411
531
  const nestedStartHead = this.activeBranch.getHead();
412
532
  const nestedOuterOnPop = onPush?.();
413
533
  transactionBranch.editor.enterTransaction();
414
534
  return {
415
535
  // Invoked when a nested transaction ends
416
536
  onPop: (result) => {
537
+ const nestedPostProcessor = postProcessorStack.pop();
417
538
  transactionBranch.editor.exitTransaction();
418
539
  switch (result) {
419
540
  case TransactionResult.Abort: {
@@ -422,6 +543,32 @@ export class SquashingTransactionStack<
422
543
  break;
423
544
  }
424
545
  case TransactionResult.Commit: {
546
+ // When this nested transaction supplied a post-processor that should be applied here, squash its
547
+ // edits into a single (post-processed) commit on the transaction branch rather than leaving them to
548
+ // be squashed only when the outermost transaction is committed.
549
+ if (nestedPostProcessor !== undefined) {
550
+ const nestedSteps: GraphCommit<TChange>[] = [];
551
+ findAncestor(
552
+ [transactionBranch.getHead(), nestedSteps],
553
+ (c) => c === nestedStartHead,
554
+ );
555
+ if (nestedSteps.length > 0) {
556
+ assert(
557
+ transactionRevision !== undefined,
558
+ 0xd07 /* Expected transaction revision in the presence of transaction steps */,
559
+ );
560
+ const squash = rebaser.compose(nestedSteps);
561
+ const processedSquash = nestedPostProcessor.processChange(squash);
562
+ // Roll back the transaction branch to the nested start head and apply the
563
+ // processed change if it differs from the original change.
564
+ if (processedSquash !== squash) {
565
+ transactionBranch.removeAfter(nestedStartHead);
566
+ transactionBranch.apply(
567
+ tagChange(processedSquash, transactionRevision),
568
+ );
569
+ }
570
+ }
571
+ }
425
572
  break;
426
573
  }
427
574
  default: {
@@ -100,7 +100,7 @@ export {
100
100
  export type { TreeSchemaEncodingOptions } from "./getJsonSchema.js";
101
101
  export { getJsonSchema } from "./getJsonSchema.js";
102
102
  export { getSimpleSchema } from "./getSimpleSchema.js";
103
- export { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
103
+ export { checkSchemaCompatibility } from "./schemaCompatibilityTester.js";
104
104
  export type {
105
105
  Unenforced,
106
106
  FieldSchemaAlphaUnsafe,
@@ -179,19 +179,23 @@ export {
179
179
  } from "./storedSchema.js";
180
180
 
181
181
  export {
182
+ type NoChangeConstraint,
183
+ type NodeInDocumentConstraint,
184
+ rollback,
185
+ type RunTransactionParamsAlpha,
186
+ type RunTransactionParamsBeta,
187
+ type TransactionCallbackStatusAlpha,
188
+ type TransactionCallbackStatusBeta,
182
189
  type TransactionConstraint,
183
190
  type TransactionConstraintAlpha,
184
- type NodeInDocumentConstraint,
185
- type NoChangeConstraint,
186
- type RunTransactionParams,
187
- type VoidTransactionCallbackStatus,
188
- type TransactionCallbackStatus,
189
- type TransactionResult,
190
- type TransactionResultExt,
191
- type TransactionResultSuccess,
191
+ type TransactionPostProcessor,
192
192
  type TransactionResultFailed,
193
+ type TransactionResultSuccess,
194
+ type TransactionValueResult,
195
+ type TransactionVoidResult,
196
+ type VoidTransactionCallbackStatusAlpha,
197
+ type VoidTransactionCallbackStatusBeta,
193
198
  type WithValue,
194
- rollback,
195
199
  } from "./transactionTypes.js";
196
200
 
197
201
  export { generateSchemaFromSimpleSchema } from "./schemaFromSimple.js";
@@ -12,58 +12,46 @@ import { getDiscrepanciesInAllowedContent } from "./discrepancies.js";
12
12
  import type { SchemaCompatibilityStatus } from "./tree.js";
13
13
 
14
14
  /**
15
- * A collection of View information for schema
15
+ * Determines the compatibility of a stored document
16
+ * (based on its stored schema) with a viewer (based on its view schema).
17
+ *
16
18
  * @remarks
17
- * This contains everything needed to determine compatibility with a given stored schema.
19
+ * Adapters can be provided to handle differences between the two schema.
20
+ * Adapters should only use to types in the `view` SchemaRepository.
21
+ *
22
+ * TODO: this API violates the parse don't validate design philosophy.
23
+ * It should be wrapped with (or replaced by) a parse style API.
18
24
  */
19
- export class SchemaCompatibilityTester {
20
- public constructor(
21
- /**
22
- * Schema for the view
23
- */
24
- public readonly viewSchema: TreeSchema,
25
- ) {}
26
-
27
- /**
28
- * Determines the compatibility of a stored document
29
- * (based on its stored schema) with a viewer (based on its view schema).
30
- *
31
- * Adapters can be provided to handle differences between the two schema.
32
- * Adapters should only use to types in the `view` SchemaRepository.
33
- *
34
- * TODO: this API violates the parse don't validate design philosophy.
35
- * It should be wrapped with (or replaced by) a parse style API.
36
- */
37
- public checkCompatibility(
38
- stored: TreeStoredSchema,
39
- ): Omit<SchemaCompatibilityStatus, "canInitialize"> {
40
- // The public API surface assumes defaultSchemaPolicy
41
- const policy = defaultSchemaPolicy;
42
-
43
- // View schema allows a subset of documents that stored schema does, and the discrepancies are allowed by policy
44
- // determined by the view schema (i.e. objects with extra optional fields in the stored schema have opted into allowing this.
45
- // In the future, this would also include things like:
46
- // - fields with more allowed types in the stored schema than in the view schema have out-of-schema "unknown content" adapters
47
- let canView = true;
48
-
49
- for (const _discrepancy of getDiscrepanciesInAllowedContent(this.viewSchema, stored)) {
50
- canView = false;
51
- break;
52
- }
25
+ export function checkSchemaCompatibility(
26
+ viewSchema: TreeSchema,
27
+ stored: TreeStoredSchema,
28
+ ): Omit<SchemaCompatibilityStatus, "canInitialize"> {
29
+ // The public API surface assumes defaultSchemaPolicy
30
+ const policy = defaultSchemaPolicy;
31
+
32
+ // View schema allows a subset of documents that stored schema does, and the discrepancies are allowed by policy
33
+ // determined by the view schema (i.e. objects with extra optional fields in the stored schema have opted into allowing this.
34
+ // In the future, this would also include things like:
35
+ // - fields with more allowed types in the stored schema than in the view schema have out-of-schema "unknown content" adapters
36
+ let canView = true;
37
+
38
+ for (const _discrepancy of getDiscrepanciesInAllowedContent(viewSchema, stored)) {
39
+ canView = false;
40
+ break;
41
+ }
53
42
 
54
- const wouldUpgradeTo = toUpgradeSchema(this.viewSchema.root);
43
+ const wouldUpgradeTo = toUpgradeSchema(viewSchema.root);
55
44
 
56
- const canUpgrade = allowsRepoSuperset(policy, stored, wouldUpgradeTo);
45
+ const canUpgrade = allowsRepoSuperset(policy, stored, wouldUpgradeTo);
57
46
 
58
- // If true, then upgrading has no effect on what can be stored in the document.
59
- // TODO: This should likely be changed to indicate up a schema upgrade would be a no-op, including stored schema metadata.
60
- const isEquivalent =
61
- canView && canUpgrade && allowsRepoSuperset(policy, wouldUpgradeTo, stored);
47
+ // If true, then upgrading has no effect on what can be stored in the document.
48
+ // TODO: This should likely be changed to indicate up a schema upgrade would be a no-op, including stored schema metadata.
49
+ const isEquivalent =
50
+ canView && canUpgrade && allowsRepoSuperset(policy, wouldUpgradeTo, stored);
62
51
 
63
- return {
64
- canView,
65
- canUpgrade,
66
- isEquivalent,
67
- };
68
- }
52
+ return {
53
+ canView,
54
+ canUpgrade,
55
+ isEquivalent,
56
+ };
69
57
  }
@@ -78,7 +78,7 @@ export function singletonSchema<TScope extends string, TName extends string | nu
78
78
  }
79
79
 
80
80
  /**
81
- * Converts an enum into a collection of schema which can be used in a union.
81
+ * Converts an enum into a collection of schemas which can be used in a union.
82
82
  *
83
83
  * @typeParam TScope - The scope of the provided factory.
84
84
  * There is a known issue where if a factory is provided that is typed as a {@link SchemaFactoryAlpha}, and its scope contains a "." character,
@@ -88,7 +88,7 @@ export function singletonSchema<TScope extends string, TName extends string | nu
88
88
  * @remarks
89
89
  * The string value of the enum is used as the name of the schema: callers must ensure that it is stable and unique.
90
90
  * Numeric enums values have the value implicitly converted into a string.
91
- * Consider making a dedicated schema factory with a nested scope (for example using {@link SchemaFactoryBeta.scopedFactory}) to avoid the enum members colliding with other schema.
91
+ * Consider making a dedicated schema factory with a nested scope (for example using {@link SchemaFactoryBeta.scopedFactory}) to avoid the enum members colliding with other schemas.
92
92
  * @example
93
93
  * ```typescript
94
94
  * const schemaFactory = new SchemaFactory("com.myApp");
@@ -213,7 +213,7 @@ export function enumEntries(
213
213
  }
214
214
 
215
215
  /**
216
- * Converts an array of distinct strings into a collection of schema which can be used like an enum style union.
216
+ * Converts an array of distinct strings into a collection of schemas which can be used like an enum style union.
217
217
  * @remarks
218
218
  * The returned collection is also a function which can be used to convert strings into {@link Unhydrated} nodes in the union.
219
219
  * Each node type has a `.value` getter which returns the associated string.
@@ -339,7 +339,7 @@ export class SchemaFactory<
339
339
  /**
340
340
  * Construct a SchemaFactory with a given {@link SchemaFactory.scope|scope}.
341
341
  * @remarks
342
- * There are no restrictions on mixing schema from different schema factories.
342
+ * There are no restrictions on mixing schemas from different schema factories.
343
343
  * Typically each library will create one or more SchemaFactories and use them to define its schema.
344
344
  */
345
345
  public constructor(
@@ -698,7 +698,7 @@ export class SchemaFactory<
698
698
  const same = compareSets({ a: inputTypes, b: outputTypes });
699
699
  if (!same) {
700
700
  throw new UsageError(
701
- `Structurally named schema collision: two schema named "${fullName}" were defined with different input schema.`,
701
+ `Structurally named schema collision: two schemas named "${fullName}" were defined with different input schemas.`,
702
702
  );
703
703
  }
704
704
  return structural;
@@ -80,6 +80,8 @@ import type {
80
80
  * Values should be preferred over generator functions when possible, as they are simpler and more efficient.
81
81
  * Generator functions should be used when the default value needs to be dynamic or when it is not possible to provide a value directly.
82
82
  *
83
+ * See {@link SchemaStaticsAlpha.withDefault} for the primary API that uses this type.
84
+ *
83
85
  * @example
84
86
  * ```typescript
85
87
  * // Provide a value directly
@@ -102,27 +104,63 @@ export type NodeProvider<T> = T | (() => T);
102
104
  */
103
105
  export interface SchemaStaticsAlpha {
104
106
  /**
105
- * Creates a field schema with a default value. Fields with defaults (whether required or optional) are recognized by the type system as optional in constructors,
106
- * allowing them to be omitted when creating new nodes.
107
+ * Creates a field schema with a default value.
108
+ *
109
+ * @remarks
110
+ * Fields with defaults are optional in constructors, allowing them to be omitted when creating new nodes.
111
+ * This works with both {@link SchemaStatics.required | required} and {@link SchemaStatics.optional | optional} fields:
112
+ *
113
+ * - **Required fields with defaults**: The field is always present in the tree, but can be omitted from the constructor.
114
+ * The default value is used when the field is not provided.
115
+ *
116
+ * - **Optional fields with defaults**: Optional fields already default to `undefined`, but `withDefault` lets you
117
+ * specify a different default value.
118
+ *
119
+ * The default value can be provided in two ways (see {@link NodeProvider}):
120
+ *
121
+ * 1. **A value**: The value is deep-copied for each use, ensuring independence between instances.
122
+ * Prefer this when the default is a fixed value.
123
+ *
124
+ * 2. **A generator function**: A function called each time a default is needed. Use this for dynamic defaults
125
+ * (e.g., timestamps, UUIDs) or when explicit control over value creation is required.
126
+ *
127
+ * Defaults are evaluated eagerly during node construction.
128
+ *
129
+ * For recursive schemas, use {@link SchemaStaticsAlpha.withDefaultRecursive} instead.
130
+ *
131
+ * See the {@link https://fluidframework.com/docs/data-structures/tree/schema-definition/default-field-values | Default Field Values documentation}
132
+ * for a comprehensive guide with additional examples.
107
133
  *
108
134
  * @param fieldSchema - The field schema to add a default to (e.g., `factory.required(factory.string)` or `factory.optional(factory.number)`)
109
135
  * @param defaultValue - A {@link NodeProvider} specifying the default value.
110
136
  *
111
137
  * @example
138
+ * A schema with a mix of required, defaulted, and dynamic fields:
112
139
  * ```typescript
113
- * const MySchema = factory.objectAlpha("MyObject", {
114
- * // Provide values directly
115
- * name: factory.withDefault(factory.required(factory.string), "untitled"),
116
- * count: factory.withDefault(factory.required(factory.number), 0),
117
- * metadata: factory.withDefault(factory.optional(Metadata), new Metadata({ version: 1 })),
118
- *
119
- * // Use generator functions for dynamic values
120
- * timestamp: factory.withDefault(factory.required(factory.number), () => Date.now()),
121
- * id: factory.withDefault(factory.required(factory.string), () => crypto.randomUUID()),
122
- * });
123
- *
124
- * const obj1 = new MySchema({}); // All defaults applied
125
- * const obj2 = new MySchema({ name: "custom" }); // name="custom", other defaults applied
140
+ * const factory = new SchemaFactoryAlpha("example");
141
+ *
142
+ * class Task extends factory.objectAlpha("Task", {
143
+ * // No default — must always be provided in the constructor
144
+ * title: factory.required(factory.string),
145
+ *
146
+ * // Required field with a static default
147
+ * status: factory.withDefault(factory.required(factory.string), "todo"),
148
+ *
149
+ * // Optional field with a custom default (instead of `undefined`)
150
+ * priority: factory.withDefault(factory.optional(factory.number), 0),
151
+ *
152
+ * // Dynamic default using a generator function
153
+ * createdAt: factory.withDefault(factory.required(factory.number), () => Date.now()),
154
+ * }) {}
155
+ *
156
+ * // Only `title` is required in the constructor; the rest use their defaults
157
+ * const task = new Task({ title: "Write docs" });
158
+ * // task.status === "todo"
159
+ * // task.priority === 0
160
+ * // task.createdAt is set to the current timestamp
161
+ *
162
+ * // Defaults can be overridden by providing explicit values
163
+ * const urgentTask = new Task({ title: "Fix bug", status: "in-progress", priority: 1 });
126
164
  * ```
127
165
  *
128
166
  * @privateRemarks
@@ -208,6 +246,9 @@ export interface SchemaStaticsAlpha {
208
246
  * @remarks
209
247
  * This version of {@link SchemaStaticsAlpha.withDefault} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
210
248
  * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
249
+ *
250
+ * See the {@link https://fluidframework.com/docs/data-structures/tree/schema-definition/default-field-values#recursive-types | Default Field Values — Recursive Types documentation}
251
+ * for usage examples and guidance on avoiding infinite recursion with recursive defaults.
211
252
  */
212
253
  withDefaultRecursive: <
213
254
  Kind extends FieldKind,
@@ -94,9 +94,6 @@ export interface SchemaStaticsBeta {
94
94
  * A full code example of the schema migration process can be found in our {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/src/test/simple-tree/api/stagedSchemaUpgrade.spec.ts | tests}.
95
95
  *
96
96
  * @privateRemarks
97
- * TODO:#44317 staged allowed types rely on schema validation of stored schema to output errors, these errors are not very
98
- * user friendly and should be improved, particularly in the case of staged allowed types
99
- *
100
97
  * TODO: AB#45711: Update the docs above when recursive type support is added.
101
98
  */
102
99
  readonly staged: <const T extends LazyItem<TreeNodeSchema>>(
@@ -13,7 +13,7 @@ import { toInitialSchema } from "../toStoredSchema.js";
13
13
  import { createTreeSchema } from "../treeSchema.js";
14
14
 
15
15
  import { TreeViewConfigurationAlpha, TreeViewConfiguration } from "./configuration.js";
16
- import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
16
+ import { checkSchemaCompatibility } from "./schemaCompatibilityTester.js";
17
17
  import { generateSchemaFromSimpleSchema } from "./schemaFromSimple.js";
18
18
  import {
19
19
  decodeSchemaCompatibilitySnapshot,
@@ -78,8 +78,7 @@ export function checkCompatibility(
78
78
  ): Omit<SchemaCompatibilityStatus, "canInitialize"> {
79
79
  const viewAsAlpha = new TreeViewConfigurationAlpha({ schema: view.schema });
80
80
  const stored = toInitialSchema(viewWhichCreatedStoredSchema.schema);
81
- const tester = new SchemaCompatibilityTester(viewAsAlpha);
82
- return tester.checkCompatibility(stored);
81
+ return checkSchemaCompatibility(viewAsAlpha, stored);
83
82
  }
84
83
 
85
84
  /**
@@ -422,11 +421,11 @@ export interface SnapshotSchemaCompatibilityOptions {
422
421
  * 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.
423
422
  *
424
423
  * This utility only tests compatibility of the historical snapshots against the current schema; it does not test them against each-other.
425
- * Generally any historical schema should have been tested against the ones before them at the time they were current.
424
+ * Generally any historical schemas should have been tested against the ones before them at the time they were current.
426
425
  * If for some reason a version of a schema made it into production that was not compatible with a previous version,
427
426
  * that can still be represented here (but may require manually generating a snapshot for that version)
428
427
  * and this will still allow testing that all historical version can be upgraded to the current one.
429
- * If a sufficiently incompatible historical schema were used in production, it may be impossible to make a single schema which can accommodate all of them:
428
+ * 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:
430
429
  * 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.
431
430
  *
432
431
  * @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.