@fluidframework/tree 2.53.0 → 2.60.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 (424) hide show
  1. package/.eslintrc.cjs +0 -19
  2. package/.mocharc.customBenchmarks.cjs +1 -9
  3. package/CHANGELOG.md +56 -0
  4. package/api-report/tree.alpha.api.md +50 -36
  5. package/api-report/tree.beta.api.md +15 -1
  6. package/api-report/{tree.legacy.alpha.api.md → tree.legacy.beta.api.md} +5 -5
  7. package/api-report/tree.legacy.public.api.md +1 -1
  8. package/api-report/tree.public.api.md +1 -1
  9. package/dist/alpha.d.ts +8 -2
  10. package/dist/beta.d.ts +3 -0
  11. package/dist/codec/codec.d.ts +43 -6
  12. package/dist/codec/codec.d.ts.map +1 -1
  13. package/dist/codec/codec.js +22 -2
  14. package/dist/codec/codec.js.map +1 -1
  15. package/dist/codec/index.d.ts +1 -1
  16. package/dist/codec/index.d.ts.map +1 -1
  17. package/dist/codec/index.js +4 -1
  18. package/dist/codec/index.js.map +1 -1
  19. package/dist/external-utilities/index.d.ts +1 -1
  20. package/dist/external-utilities/index.d.ts.map +1 -1
  21. package/dist/external-utilities/index.js +2 -1
  22. package/dist/external-utilities/index.js.map +1 -1
  23. package/dist/external-utilities/typeboxValidator.d.ts +6 -1
  24. package/dist/external-utilities/typeboxValidator.d.ts.map +1 -1
  25. package/dist/external-utilities/typeboxValidator.js +7 -1
  26. package/dist/external-utilities/typeboxValidator.js.map +1 -1
  27. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
  28. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  29. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +28 -5
  30. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  31. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
  32. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
  34. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  35. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
  36. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  37. package/dist/feature-libraries/chunked-forest/codec/codecs.js +9 -2
  38. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  39. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
  40. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +91 -16
  42. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
  44. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/codec/format.js +10 -1
  46. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  48. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  49. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
  51. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +17 -6
  53. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  55. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  57. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  58. package/dist/feature-libraries/forest-summary/codec.js +3 -0
  59. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  60. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
  61. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  62. package/dist/feature-libraries/forest-summary/forestSummarizer.js +76 -38
  63. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  64. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
  65. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
  66. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +322 -0
  67. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
  68. package/dist/feature-libraries/forest-summary/index.d.ts +1 -1
  69. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  70. package/dist/feature-libraries/forest-summary/index.js +2 -1
  71. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  72. package/dist/feature-libraries/index.d.ts +1 -1
  73. package/dist/feature-libraries/index.d.ts.map +1 -1
  74. package/dist/feature-libraries/index.js +2 -1
  75. package/dist/feature-libraries/index.js.map +1 -1
  76. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  77. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  78. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +1 -1
  79. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  80. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
  81. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  82. package/dist/feature-libraries/treeCompressionUtils.d.ts +15 -0
  83. package/dist/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
  84. package/dist/feature-libraries/treeCompressionUtils.js +16 -1
  85. package/dist/feature-libraries/treeCompressionUtils.js.map +1 -1
  86. package/dist/index.d.ts +3 -3
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +6 -2
  89. package/dist/index.js.map +1 -1
  90. package/dist/jsonDomainSchema.d.ts +1 -1
  91. package/dist/jsonDomainSchema.d.ts.map +1 -1
  92. package/dist/packageVersion.d.ts +1 -1
  93. package/dist/packageVersion.js +1 -1
  94. package/dist/packageVersion.js.map +1 -1
  95. package/dist/shared-tree/schematizingTreeView.d.ts +1 -1
  96. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  97. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  98. package/dist/shared-tree/sharedTree.d.ts +23 -6
  99. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  100. package/dist/shared-tree/sharedTree.js +4 -1
  101. package/dist/shared-tree/sharedTree.js.map +1 -1
  102. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  103. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  104. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  105. package/dist/shared-tree/tree.d.ts.map +1 -1
  106. package/dist/shared-tree/tree.js +3 -0
  107. package/dist/shared-tree/tree.js.map +1 -1
  108. package/dist/shared-tree/treeAlpha.d.ts +9 -11
  109. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  110. package/dist/shared-tree/treeAlpha.js.map +1 -1
  111. package/dist/shared-tree/treeCheckout.d.ts +2 -2
  112. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  113. package/dist/shared-tree/treeCheckout.js.map +1 -1
  114. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  115. package/dist/shared-tree-core/sharedTreeCore.js +13 -0
  116. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  117. package/dist/sharedTreeAttributes.d.ts +2 -2
  118. package/dist/sharedTreeAttributes.js +2 -2
  119. package/dist/sharedTreeAttributes.js.map +1 -1
  120. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  121. package/dist/simple-tree/api/conciseTree.js +1 -1
  122. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  123. package/dist/simple-tree/api/customTree.d.ts +39 -11
  124. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  125. package/dist/simple-tree/api/customTree.js +79 -19
  126. package/dist/simple-tree/api/customTree.js.map +1 -1
  127. package/dist/simple-tree/api/getJsonSchema.d.ts +7 -2
  128. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  129. package/dist/simple-tree/api/getJsonSchema.js +1 -0
  130. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  131. package/dist/simple-tree/api/index.d.ts +2 -1
  132. package/dist/simple-tree/api/index.d.ts.map +1 -1
  133. package/dist/simple-tree/api/index.js +4 -1
  134. package/dist/simple-tree/api/index.js.map +1 -1
  135. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
  136. package/dist/simple-tree/api/schemaCreationUtilities.js +1 -1
  137. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  138. package/dist/simple-tree/api/schemaFactory.d.ts +9 -6
  139. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  140. package/dist/simple-tree/api/schemaFactory.js +8 -7
  141. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  142. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
  143. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  144. package/dist/simple-tree/api/schemaFactoryAlpha.js +21 -25
  145. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  146. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
  147. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
  148. package/dist/simple-tree/api/schemaFactoryBeta.js +26 -0
  149. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -0
  150. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
  151. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  152. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
  153. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  154. package/dist/simple-tree/api/transactionTypes.d.ts +1 -0
  155. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  156. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  157. package/dist/simple-tree/api/tree.d.ts +68 -74
  158. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  159. package/dist/simple-tree/api/tree.js.map +1 -1
  160. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  161. package/dist/simple-tree/api/verboseTree.js +3 -3
  162. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  163. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
  164. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
  165. package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
  166. package/dist/simple-tree/fieldSchema.d.ts +3 -4
  167. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  168. package/dist/simple-tree/fieldSchema.js +0 -3
  169. package/dist/simple-tree/fieldSchema.js.map +1 -1
  170. package/dist/simple-tree/index.d.ts +1 -1
  171. package/dist/simple-tree/index.d.ts.map +1 -1
  172. package/dist/simple-tree/index.js +4 -2
  173. package/dist/simple-tree/index.js.map +1 -1
  174. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  175. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -3
  176. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  177. package/dist/simple-tree/simpleSchema.d.ts +12 -0
  178. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  179. package/dist/simple-tree/simpleSchema.js.map +1 -1
  180. package/dist/simple-tree/toStoredSchema.d.ts +0 -3
  181. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  182. package/dist/simple-tree/toStoredSchema.js +0 -3
  183. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  184. package/dist/tableSchema.d.ts +11 -80
  185. package/dist/tableSchema.d.ts.map +1 -1
  186. package/dist/tableSchema.js +200 -117
  187. package/dist/tableSchema.js.map +1 -1
  188. package/dist/treeFactory.d.ts +1 -2
  189. package/dist/treeFactory.d.ts.map +1 -1
  190. package/dist/treeFactory.js +1 -2
  191. package/dist/treeFactory.js.map +1 -1
  192. package/lib/alpha.d.ts +8 -2
  193. package/lib/beta.d.ts +3 -0
  194. package/lib/codec/codec.d.ts +43 -6
  195. package/lib/codec/codec.d.ts.map +1 -1
  196. package/lib/codec/codec.js +19 -1
  197. package/lib/codec/codec.js.map +1 -1
  198. package/lib/codec/index.d.ts +1 -1
  199. package/lib/codec/index.d.ts.map +1 -1
  200. package/lib/codec/index.js +1 -1
  201. package/lib/codec/index.js.map +1 -1
  202. package/lib/external-utilities/index.d.ts +1 -1
  203. package/lib/external-utilities/index.d.ts.map +1 -1
  204. package/lib/external-utilities/index.js +1 -1
  205. package/lib/external-utilities/index.js.map +1 -1
  206. package/lib/external-utilities/typeboxValidator.d.ts +6 -1
  207. package/lib/external-utilities/typeboxValidator.d.ts.map +1 -1
  208. package/lib/external-utilities/typeboxValidator.js +6 -0
  209. package/lib/external-utilities/typeboxValidator.js.map +1 -1
  210. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
  211. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  212. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +27 -5
  213. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  214. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
  215. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  216. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
  217. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  218. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
  219. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  220. package/lib/feature-libraries/chunked-forest/codec/codecs.js +10 -3
  221. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  222. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
  223. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  224. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +87 -14
  225. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  226. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
  227. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  228. package/lib/feature-libraries/chunked-forest/codec/format.js +9 -0
  229. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  230. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  231. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  232. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  233. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
  234. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  235. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +18 -7
  236. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  237. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  238. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  239. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  240. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  241. package/lib/feature-libraries/forest-summary/codec.js +3 -0
  242. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  243. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
  244. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  245. package/lib/feature-libraries/forest-summary/forestSummarizer.js +75 -37
  246. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  247. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
  248. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
  249. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +318 -0
  250. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
  251. package/lib/feature-libraries/forest-summary/index.d.ts +1 -1
  252. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  253. package/lib/feature-libraries/forest-summary/index.js +1 -1
  254. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  255. package/lib/feature-libraries/index.d.ts +1 -1
  256. package/lib/feature-libraries/index.d.ts.map +1 -1
  257. package/lib/feature-libraries/index.js +1 -1
  258. package/lib/feature-libraries/index.js.map +1 -1
  259. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  260. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  261. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +3 -3
  262. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  263. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
  264. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  265. package/lib/feature-libraries/treeCompressionUtils.d.ts +15 -0
  266. package/lib/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
  267. package/lib/feature-libraries/treeCompressionUtils.js +15 -0
  268. package/lib/feature-libraries/treeCompressionUtils.js.map +1 -1
  269. package/lib/index.d.ts +3 -3
  270. package/lib/index.d.ts.map +1 -1
  271. package/lib/index.js +4 -4
  272. package/lib/index.js.map +1 -1
  273. package/lib/jsonDomainSchema.d.ts +1 -1
  274. package/lib/jsonDomainSchema.d.ts.map +1 -1
  275. package/lib/packageVersion.d.ts +1 -1
  276. package/lib/packageVersion.js +1 -1
  277. package/lib/packageVersion.js.map +1 -1
  278. package/lib/shared-tree/schematizingTreeView.d.ts +1 -1
  279. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  280. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  281. package/lib/shared-tree/sharedTree.d.ts +23 -6
  282. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  283. package/lib/shared-tree/sharedTree.js +4 -1
  284. package/lib/shared-tree/sharedTree.js.map +1 -1
  285. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  286. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  287. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  288. package/lib/shared-tree/tree.d.ts.map +1 -1
  289. package/lib/shared-tree/tree.js +3 -0
  290. package/lib/shared-tree/tree.js.map +1 -1
  291. package/lib/shared-tree/treeAlpha.d.ts +9 -11
  292. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  293. package/lib/shared-tree/treeAlpha.js.map +1 -1
  294. package/lib/shared-tree/treeCheckout.d.ts +2 -2
  295. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  296. package/lib/shared-tree/treeCheckout.js.map +1 -1
  297. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  298. package/lib/shared-tree-core/sharedTreeCore.js +13 -0
  299. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  300. package/lib/sharedTreeAttributes.d.ts +2 -2
  301. package/lib/sharedTreeAttributes.js +2 -2
  302. package/lib/sharedTreeAttributes.js.map +1 -1
  303. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  304. package/lib/simple-tree/api/conciseTree.js +2 -2
  305. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  306. package/lib/simple-tree/api/customTree.d.ts +39 -11
  307. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  308. package/lib/simple-tree/api/customTree.js +79 -19
  309. package/lib/simple-tree/api/customTree.js.map +1 -1
  310. package/lib/simple-tree/api/getJsonSchema.d.ts +7 -2
  311. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  312. package/lib/simple-tree/api/getJsonSchema.js +1 -0
  313. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  314. package/lib/simple-tree/api/index.d.ts +2 -1
  315. package/lib/simple-tree/api/index.d.ts.map +1 -1
  316. package/lib/simple-tree/api/index.js +2 -1
  317. package/lib/simple-tree/api/index.js.map +1 -1
  318. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
  319. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
  320. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  321. package/lib/simple-tree/api/schemaFactory.d.ts +9 -6
  322. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  323. package/lib/simple-tree/api/schemaFactory.js +6 -6
  324. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  325. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
  326. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  327. package/lib/simple-tree/api/schemaFactoryAlpha.js +22 -26
  328. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  329. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
  330. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
  331. package/lib/simple-tree/api/schemaFactoryBeta.js +22 -0
  332. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -0
  333. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
  334. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  335. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
  336. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  337. package/lib/simple-tree/api/transactionTypes.d.ts +1 -0
  338. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  339. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  340. package/lib/simple-tree/api/tree.d.ts +68 -74
  341. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  342. package/lib/simple-tree/api/tree.js.map +1 -1
  343. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  344. package/lib/simple-tree/api/verboseTree.js +4 -4
  345. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  346. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
  347. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
  348. package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
  349. package/lib/simple-tree/fieldSchema.d.ts +3 -4
  350. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  351. package/lib/simple-tree/fieldSchema.js +0 -3
  352. package/lib/simple-tree/fieldSchema.js.map +1 -1
  353. package/lib/simple-tree/index.d.ts +1 -1
  354. package/lib/simple-tree/index.d.ts.map +1 -1
  355. package/lib/simple-tree/index.js +1 -1
  356. package/lib/simple-tree/index.js.map +1 -1
  357. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  358. package/lib/simple-tree/node-kinds/record/recordNode.js +2 -3
  359. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  360. package/lib/simple-tree/simpleSchema.d.ts +12 -0
  361. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  362. package/lib/simple-tree/simpleSchema.js.map +1 -1
  363. package/lib/simple-tree/toStoredSchema.d.ts +0 -3
  364. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  365. package/lib/simple-tree/toStoredSchema.js +0 -3
  366. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  367. package/lib/tableSchema.d.ts +11 -80
  368. package/lib/tableSchema.d.ts.map +1 -1
  369. package/lib/tableSchema.js +201 -118
  370. package/lib/tableSchema.js.map +1 -1
  371. package/lib/treeFactory.d.ts +1 -2
  372. package/lib/treeFactory.d.ts.map +1 -1
  373. package/lib/treeFactory.js +1 -2
  374. package/lib/treeFactory.js.map +1 -1
  375. package/package.json +22 -22
  376. package/src/codec/codec.ts +52 -7
  377. package/src/codec/index.ts +4 -0
  378. package/src/external-utilities/index.ts +1 -1
  379. package/src/external-utilities/typeboxValidator.ts +7 -1
  380. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +38 -4
  381. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -3
  382. package/src/feature-libraries/chunked-forest/codec/codecs.ts +96 -8
  383. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +123 -19
  384. package/src/feature-libraries/chunked-forest/codec/format.ts +11 -0
  385. package/src/feature-libraries/chunked-forest/codec/index.ts +4 -0
  386. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +28 -3
  387. package/src/feature-libraries/chunked-forest/index.ts +2 -0
  388. package/src/feature-libraries/forest-summary/codec.ts +3 -0
  389. package/src/feature-libraries/forest-summary/forestSummarizer.ts +118 -50
  390. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +511 -0
  391. package/src/feature-libraries/forest-summary/index.ts +1 -1
  392. package/src/feature-libraries/index.ts +5 -1
  393. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +8 -4
  394. package/src/feature-libraries/treeCompressionUtils.ts +19 -0
  395. package/src/index.ts +6 -1
  396. package/src/packageVersion.ts +1 -1
  397. package/src/shared-tree/schematizingTreeView.ts +1 -1
  398. package/src/shared-tree/sharedTree.ts +37 -4
  399. package/src/shared-tree/sharedTreeChangeFamily.ts +2 -2
  400. package/src/shared-tree/tree.ts +3 -0
  401. package/src/shared-tree/treeAlpha.ts +10 -11
  402. package/src/shared-tree/treeCheckout.ts +2 -2
  403. package/src/shared-tree-core/sharedTreeCore.ts +17 -0
  404. package/src/sharedTreeAttributes.ts +2 -2
  405. package/src/simple-tree/api/conciseTree.ts +2 -1
  406. package/src/simple-tree/api/customTree.ts +102 -32
  407. package/src/simple-tree/api/getJsonSchema.ts +7 -2
  408. package/src/simple-tree/api/index.ts +3 -0
  409. package/src/simple-tree/api/schemaCreationUtilities.ts +1 -1
  410. package/src/simple-tree/api/schemaFactory.ts +21 -14
  411. package/src/simple-tree/api/schemaFactoryAlpha.ts +29 -30
  412. package/src/simple-tree/api/schemaFactoryBeta.ts +28 -0
  413. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +7 -3
  414. package/src/simple-tree/api/transactionTypes.ts +1 -0
  415. package/src/simple-tree/api/tree.ts +75 -81
  416. package/src/simple-tree/api/verboseTree.ts +42 -39
  417. package/src/simple-tree/core/simpleNodeSchemaBase.ts +6 -0
  418. package/src/simple-tree/fieldSchema.ts +3 -4
  419. package/src/simple-tree/index.ts +3 -0
  420. package/src/simple-tree/node-kinds/record/recordNode.ts +2 -3
  421. package/src/simple-tree/simpleSchema.ts +12 -0
  422. package/src/simple-tree/toStoredSchema.ts +0 -3
  423. package/src/tableSchema.ts +261 -243
  424. package/src/treeFactory.ts +1 -2
@@ -17,7 +17,7 @@ import {
17
17
  } from "../node-kinds/index.js";
18
18
  import {
19
19
  defaultSchemaFactoryObjectOptions,
20
- SchemaFactory,
20
+ scoped,
21
21
  structuralName,
22
22
  type NodeSchemaOptionsAlpha,
23
23
  type SchemaFactoryObjectOptions,
@@ -46,6 +46,7 @@ import type {
46
46
  TreeRecordNodeUnsafe,
47
47
  } from "./typesUnsafe.js";
48
48
  import type { SimpleObjectNodeSchema } from "../simpleSchema.js";
49
+ import { SchemaFactoryBeta } from "./schemaFactoryBeta.js";
49
50
 
50
51
  // This import prevents a large number of type references in the API reports from showing up as *_2.
51
52
  /* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */
@@ -212,20 +213,14 @@ const schemaStaticsAlpha: SchemaStaticsAlpha = {
212
213
  *
213
214
  * @alpha
214
215
  * @privateRemarks
215
- *
216
- * Some private methods on `SchemaFactory` are intentionally duplicated here to avoid increasing their exposure to `protected`.
217
- * If we were to do so, they would be exposed on the public API surface of `SchemaFactory`.
216
+ * When building schema, when `options` is not provided, `TCustomMetadata` is inferred as `unknown`.
217
+ * If desired, this could be made to infer `undefined` instead by adding overloads for everything,
218
+ * but currently it is not worth the maintenance overhead as there is no use case which this is known to be helpful for.
218
219
  */
219
220
  export class SchemaFactoryAlpha<
220
221
  out TScope extends string | undefined = string | undefined,
221
222
  TName extends number | string = string,
222
- > extends SchemaFactory<TScope, TName> {
223
- private scoped2<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {
224
- return (
225
- this.scope === undefined ? `${name}` : `${this.scope}.${name}`
226
- ) as ScopedSchemaName<TScope, Name>;
227
- }
228
-
223
+ > extends SchemaFactoryBeta<TScope, TName> {
229
224
  /**
230
225
  * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.
231
226
  *
@@ -255,7 +250,7 @@ export class SchemaFactoryAlpha<
255
250
  readonly createFromInsertable: unknown;
256
251
  } {
257
252
  return objectSchema(
258
- this.scoped2(name),
253
+ scoped<TScope, TName, Name>(this, name),
259
254
  fields,
260
255
  true,
261
256
  options?.allowUnknownOptionalFields ??
@@ -410,7 +405,7 @@ export class SchemaFactoryAlpha<
410
405
  options?: NodeSchemaOptionsAlpha<TCustomMetadata>,
411
406
  ): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {
412
407
  return mapSchema(
413
- this.scoped2(name),
408
+ scoped<TScope, TName, Name>(this, name),
414
409
  allowedTypes,
415
410
  true,
416
411
  true,
@@ -440,7 +435,7 @@ export class SchemaFactoryAlpha<
440
435
  }
441
436
 
442
437
  /**
443
- * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.
438
+ * Define a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.
444
439
  *
445
440
  * @param name - Unique identifier for this schema within this factory's scope.
446
441
  * @param allowedTypes - The types that may appear in the array.
@@ -461,7 +456,7 @@ export class SchemaFactoryAlpha<
461
456
  options?: NodeSchemaOptionsAlpha<TCustomMetadata>,
462
457
  ): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {
463
458
  return arraySchema(
464
- this.scoped2(name),
459
+ scoped<TScope, TName, Name>(this, name),
465
460
  allowedTypes,
466
461
  true,
467
462
  true,
@@ -628,23 +623,24 @@ export class SchemaFactoryAlpha<
628
623
  }
629
624
 
630
625
  /**
631
- * Define a {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.
626
+ * Define a {@link TreeNodeSchema} for a {@link (TreeRecordNode:interface)}.
632
627
  *
633
628
  * @param name - Unique identifier for this schema within this factory's scope.
634
629
  *
635
630
  * @remarks
636
- * This is not intended to be used directly, use the overload of `array` which takes a name instead.
637
- * This is only public to work around a compiler limitation.
631
+ * This is not intended to be used directly, use the overload of `record` which takes a name instead.
638
632
  */
639
633
  private namedRecord<
640
634
  Name extends TName | string,
641
635
  const T extends ImplicitAllowedTypes,
642
636
  const ImplicitlyConstructable extends boolean,
637
+ const TCustomMetadata = unknown,
643
638
  >(
644
639
  name: Name,
645
640
  allowedTypes: T,
646
641
  customizable: boolean,
647
642
  implicitlyConstructable: ImplicitlyConstructable,
643
+ options?: NodeSchemaOptionsAlpha<TCustomMetadata>,
648
644
  ): TreeNodeSchemaBoth<
649
645
  /* Name */ ScopedSchemaName<TScope, Name>,
650
646
  /* Kind */ NodeKind.Record,
@@ -656,10 +652,12 @@ export class SchemaFactoryAlpha<
656
652
  /* TConstructorExtra */ undefined
657
653
  > {
658
654
  const record = recordSchema({
659
- identifier: this.scoped2(name),
655
+ identifier: scoped<TScope, TName, Name>(this, name),
660
656
  info: allowedTypes,
661
657
  customizable,
662
658
  implicitlyConstructable,
659
+ metadata: options?.metadata,
660
+ persistedMetadata: options?.persistedMetadata,
663
661
  });
664
662
 
665
663
  return record as TreeNodeSchemaBoth<
@@ -696,7 +694,7 @@ export class SchemaFactoryAlpha<
696
694
  options?: NodeSchemaOptionsAlpha<TCustomMetadata>,
697
695
  ): RecordNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {
698
696
  return recordSchema({
699
- identifier: this.scoped2(name),
697
+ identifier: scoped<TScope, TName, Name>(this, name),
700
698
  info: allowedTypes,
701
699
  customizable: true,
702
700
  implicitlyConstructable: true,
@@ -716,7 +714,8 @@ export class SchemaFactoryAlpha<
716
714
  public recordRecursive<
717
715
  Name extends TName,
718
716
  const T extends System_Unsafe.ImplicitAllowedTypesUnsafe,
719
- >(name: Name, allowedTypes: T) {
717
+ const TCustomMetadata = unknown,
718
+ >(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {
720
719
  const RecordSchema = this.namedRecord(
721
720
  name,
722
721
  allowedTypes as T & ImplicitAllowedTypes,
@@ -724,6 +723,7 @@ export class SchemaFactoryAlpha<
724
723
  // Setting this to true seems to work ok currently, but not for other node kinds.
725
724
  // Supporting this could be fragile and might break other future changes, so it's being kept as false for now.
726
725
  /* implicitlyConstructable */ false,
726
+ options,
727
727
  );
728
728
 
729
729
  return RecordSchema as TreeNodeSchemaClass<
@@ -740,19 +740,18 @@ export class SchemaFactoryAlpha<
740
740
  },
741
741
  /* ImplicitlyConstructable */ false,
742
742
  /* Info */ T,
743
- /* TConstructorExtra */ undefined
743
+ /* TConstructorExtra */ undefined,
744
+ /* TCustomMetadata */ TCustomMetadata
744
745
  >;
745
746
  }
746
747
 
747
748
  /**
748
- * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.
749
- * @remarks
750
- * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).
751
- * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.
749
+ * {@inheritDoc SchemaFactoryBeta.scopedFactory}
752
750
  */
753
- public scopedFactory<const T extends TName, TNameInner extends number | string = string>(
754
- name: T,
755
- ): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {
756
- return new SchemaFactoryAlpha(this.scoped2(name));
751
+ public scopedFactoryAlpha<
752
+ const T extends TName,
753
+ TNameInner extends number | string = string,
754
+ >(name: T): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {
755
+ return new SchemaFactoryAlpha(scoped<TScope, TName, T>(this, name));
757
756
  }
758
757
  }
@@ -0,0 +1,28 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { SchemaFactory, scoped, type ScopedSchemaName } from "./schemaFactory.js";
7
+
8
+ /**
9
+ * {@link SchemaFactory} with additional beta APIs.
10
+ * @beta
11
+ * @privateRemarks
12
+ */
13
+ export class SchemaFactoryBeta<
14
+ out TScope extends string | undefined = string | undefined,
15
+ TName extends number | string = string,
16
+ > extends SchemaFactory<TScope, TName> {
17
+ /**
18
+ * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.
19
+ * @remarks
20
+ * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).
21
+ * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.
22
+ */
23
+ public scopedFactory<const T extends TName, TNameInner extends number | string = string>(
24
+ name: T,
25
+ ): SchemaFactoryBeta<ScopedSchemaName<TScope, T>, TNameInner> {
26
+ return new SchemaFactoryBeta(scoped(this, name));
27
+ }
28
+ }
@@ -37,6 +37,7 @@ import {
37
37
  ObjectNodeSchema,
38
38
  } from "../node-kinds/index.js";
39
39
  import { LeafNodeSchema } from "../leafNodeSchema.js";
40
+ import { KeyEncodingOptions } from "./customTree.js";
40
41
 
41
42
  /**
42
43
  * Generates a JSON Schema representation from a simple tree schema.
@@ -45,8 +46,6 @@ import { LeafNodeSchema } from "../leafNodeSchema.js";
45
46
  *
46
47
  * This cannot handle the case where the root is undefined since undefined is not a concept in JSON.
47
48
  * This also cannot handle {@link SchemaStatics.handle} since they also are not supported in JSON.
48
- *
49
- * @internal
50
49
  */
51
50
  export function toJsonSchema(
52
51
  schema: TreeSchema,
@@ -62,6 +61,7 @@ export function toJsonSchema(
62
61
  // TODO: deduplicate field handling logic from convertObjectNodeSchema: at least include metadata's description.
63
62
  // TODO: maybe account for consider schema.kind, or just take in ImplicitAllowedTypes
64
63
  // TODO: handle case where allowedTypes is empty.
64
+ // TODO: handle staged types in a controllable way.
65
65
  return hasSingle(allowedTypes)
66
66
  ? {
67
67
  ...allowedTypes[0],
@@ -160,7 +160,10 @@ export function convertObjectNodeSchema(
160
160
  const properties: Record<string, JsonFieldSchema> = {};
161
161
  const required: string[] = [];
162
162
  for (const [propertyKey, fieldSchema] of schema.fields) {
163
- const key = options.useStoredKeys ? fieldSchema.storedKey : propertyKey;
163
+ const key =
164
+ options.keys === KeyEncodingOptions.usePropertyKeys
165
+ ? propertyKey
166
+ : fieldSchema.storedKey;
164
167
  const allowedTypes: JsonSchemaRef[] = [];
165
168
  for (const allowedType of fieldSchema.allowedTypesIdentifiers) {
166
169
  allowedTypes.push(createSchemaRef(allowedType));
@@ -190,6 +193,7 @@ export function convertObjectNodeSchema(
190
193
  _treeNodeSchemaKind: NodeKind.Object,
191
194
  properties,
192
195
  required,
196
+ // TODO: support unknown optional fields (only when using "allStoredKeys", and constrain the content to be in schema somehow)
193
197
  additionalProperties: false,
194
198
  };
195
199
 
@@ -113,6 +113,7 @@ export type TransactionResult =
113
113
  /**
114
114
  * The parameters for the {@link RunTransaction | RunTransaction} API.
115
115
  * @alpha
116
+ * @input
116
117
  */
117
118
  export interface RunTransactionParams {
118
119
  /**
@@ -166,6 +166,81 @@ export interface TreeBranch extends IDisposable {
166
166
  */
167
167
  rebaseOnto(branch: TreeBranch): void;
168
168
 
169
+ /**
170
+ * Run a transaction which applies one or more edits to the tree as a single atomic unit.
171
+ * @param transaction - The function to run as the body of the transaction.
172
+ * It should return a status object of {@link TransactionCallbackStatus | TransactionCallbackStatus } type.
173
+ * It includes a "rollback" property which may be returned as true at any point during the transaction. This will
174
+ * abort the transaction and discard any changes it made so far.
175
+ * "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
176
+ * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
177
+ * @returns A result object of {@link TransactionResultExt | TransactionResultExt} type. It includes the following:
178
+ *
179
+ * - A "success" flag indicating whether the transaction was successful or not.
180
+ * - The success or failure value as returned by the transaction function.
181
+ *
182
+ * @remarks
183
+ * This API will throw an error if the constraints are not met or something unexpected happens.
184
+ * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
185
+ * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
186
+ * However, using a transaction has the following additional consequences:
187
+ *
188
+ * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
189
+ * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
190
+ *
191
+ * Local change events will be emitted for each change as the transaction is being applied.
192
+ * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
193
+ *
194
+ * Nested transactions:
195
+ * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:
196
+ *
197
+ * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
198
+ * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
199
+ * for the outermost transaction which includes all inner transactions.
200
+ * - Undo will undo the outermost transaction and all inner transactions.
201
+ */
202
+ runTransaction<TSuccessValue, TFailureValue>(
203
+ transaction: () => TransactionCallbackStatus<TSuccessValue, TFailureValue>,
204
+ params?: RunTransactionParams,
205
+ ): TransactionResultExt<TSuccessValue, TFailureValue>;
206
+ /**
207
+ * Run a transaction which applies one or more edits to the tree as a single atomic unit.
208
+ * @param transaction - The function to run as the body of the transaction. It may return the following:
209
+ *
210
+ * - Nothing to indicate that the body of the transaction has successfully run.
211
+ * - A status object of {@link VoidTransactionCallbackStatus | VoidTransactionCallbackStatus } type. It includes a "rollback" property which
212
+ * may be returned as true at any point during the transaction. This will abort the transaction and discard any changes it made so
213
+ * far. "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
214
+ *
215
+ * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
216
+ * @returns A result object of {@link TransactionResult | TransactionResult} type. It includes a "success" flag indicating whether the
217
+ * transaction was successful or not.
218
+ *
219
+ * @remarks
220
+ * This API will throw an error if the constraints are not met or something unexpected happens.
221
+ * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
222
+ * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
223
+ * However, using a transaction has the following additional consequences:
224
+ *
225
+ * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
226
+ * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
227
+ *
228
+ * Local change events will be emitted for each change as the transaction is being applied.
229
+ * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
230
+ *
231
+ * Nested transactions:
232
+ * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:
233
+ *
234
+ * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
235
+ * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
236
+ * for the outermost transaction which includes all inner transactions.
237
+ * - Undo will undo the outermost transaction and all inner transactions.
238
+ */
239
+ runTransaction(
240
+ transaction: () => VoidTransactionCallbackStatus | void,
241
+ params?: RunTransactionParams,
242
+ ): TransactionResult;
243
+
169
244
  /**
170
245
  * Dispose of this branch, cleaning up any resources associated with it.
171
246
  * @param error - Optional error indicating the reason for the disposal, if the object was disposed as the result of an error.
@@ -279,87 +354,6 @@ export interface TreeViewAlpha<
279
354
 
280
355
  // Override the base branch method to return a typed view rather than merely a branch.
281
356
  fork(): ReturnType<TreeBranch["fork"]> & TreeViewAlpha<TSchema>;
282
-
283
- /**
284
- * Run a transaction which applies one or more edits to the tree as a single atomic unit.
285
- * @param transaction - The function to run as the body of the transaction.
286
- * It should return a status object of {@link TransactionCallbackStatus | TransactionCallbackStatus } type.
287
- * It includes a "rollback" property which may be returned as true at any point during the transaction. This will
288
- * abort the transaction and discard any changes it made so far.
289
- * "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
290
- * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
291
- * @returns A result object of {@link TransactionResultExt | TransactionResultExt} type. It includes the following:
292
- *
293
- * - A "success" flag indicating whether the transaction was successful or not.
294
- *
295
- * - The success of failure value as returned by the transaction function.
296
- * @remarks
297
- * This API will throw an error if the constraints are not met or something unexpected happens.
298
- * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
299
- * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
300
- * However, using a transaction has the following additional consequences:
301
- *
302
- * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
303
- *
304
- * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
305
- *
306
- * Local change events will be emitted for each change as the transaction is being applied.
307
- * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
308
- *
309
- * Nested transactions:
310
- * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:
311
- *
312
- * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
313
- *
314
- * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
315
- * for the outermost transaction which includes all inner transactions.
316
- *
317
- * - Undo will undo the outermost transaction and all inner transactions.
318
- */
319
- runTransaction<TSuccessValue, TFailureValue>(
320
- transaction: () => TransactionCallbackStatus<TSuccessValue, TFailureValue>,
321
- params?: RunTransactionParams,
322
- ): TransactionResultExt<TSuccessValue, TFailureValue>;
323
- /**
324
- * Run a transaction which applies one or more edits to the tree as a single atomic unit.
325
- * @param transaction - The function to run as the body of the transaction. It may return the following:
326
- *
327
- * - Nothing to indicate that the body of the transaction has successfully run.
328
- *
329
- * - A status object of {@link VoidTransactionCallbackStatus | VoidTransactionCallbackStatus } type. It includes a "rollback" property which
330
- * may be returned as true at any point during the transaction. This will abort the transaction and discard any changes it made so
331
- * far. "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
332
- *
333
- * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
334
- * @returns A result object of {@link TransactionResult | TransactionResult} type. It includes a "success" flag indicating whether the
335
- * transaction was successful or not.
336
- * @remarks
337
- * This API will throw an error if the constraints are not met or something unexpected happens.
338
- * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
339
- * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
340
- * However, using a transaction has the following additional consequences:
341
- *
342
- * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
343
- *
344
- * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
345
- *
346
- * Local change events will be emitted for each change as the transaction is being applied.
347
- * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
348
- *
349
- * Nested transactions:
350
- * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:
351
- *
352
- * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
353
- *
354
- * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
355
- * for the outermost transaction which includes all inner transactions.
356
- *
357
- * - Undo will undo the outermost transaction and all inner transactions.
358
- */
359
- runTransaction(
360
- transaction: () => VoidTransactionCallbackStatus | void,
361
- params?: RunTransactionParams,
362
- ): TransactionResult;
363
357
  }
364
358
 
365
359
  /**
@@ -37,6 +37,7 @@ import {
37
37
  import { isObjectNodeSchema } from "../node-kinds/index.js";
38
38
  import {
39
39
  customFromCursor,
40
+ KeyEncodingOptions,
40
41
  replaceHandles,
41
42
  unknownTypeError,
42
43
  type CustomTreeNode,
@@ -118,53 +119,55 @@ export function applySchemaToParserOptions(
118
119
  options: TreeEncodingOptions,
119
120
  ): SchemalessParseOptions {
120
121
  const config: Required<TreeEncodingOptions> = {
121
- useStoredKeys: false,
122
+ keys: KeyEncodingOptions.usePropertyKeys,
122
123
  ...options,
123
124
  };
124
125
 
125
126
  const context = getUnhydratedContext(schema);
126
127
 
127
128
  return {
128
- keyConverter: config.useStoredKeys
129
- ? undefined
130
- : {
131
- encode: (type, key: FieldKey): string => {
132
- // translate stored key into property key.
133
- const simpleNodeSchema =
134
- context.schema.get(brand(type)) ?? fail(0xb39 /* missing schema */);
135
- if (isObjectNodeSchema(simpleNodeSchema)) {
136
- const propertyKey = simpleNodeSchema.storedKeyToPropertyKey.get(key);
137
- if (propertyKey !== undefined) {
138
- return propertyKey;
139
- }
140
- // Looking up an out of schema key.
141
- // This must point to a non-existent field.
142
- // It's possible that the key, if we returned it unmodified, could point to some data
143
- // (for example if looking up a key which is a stored key already when using property keys).
144
- // Thus return an arbitrary key that was selected randomly, so should not exist on non-adversarial data:
145
- const arbitrary = "arbitrary unused key: fe71614a-bf3e-43b3-b7b0-4cef39538e90";
146
- assert(
147
- !simpleNodeSchema.storedKeyToPropertyKey.has(brand(arbitrary)),
148
- 0xa13 /* arbitrarily selected unused key was actually used */,
149
- );
150
- return arbitrary;
151
- }
152
- return key;
153
- },
154
- parse: (type, inputKey): FieldKey => {
155
- const simpleNodeSchema = context.schema.get(brand(type)) ?? unknownTypeError(type);
156
- if (isObjectNodeSchema(simpleNodeSchema)) {
157
- const info = simpleNodeSchema.flexKeyMap.get(inputKey);
158
- if (info === undefined) {
159
- throw new UsageError(
160
- `Failed to parse VerboseTree due to unexpected key ${JSON.stringify(inputKey)} on type ${JSON.stringify(type)}.`,
129
+ keyConverter:
130
+ config.keys !== KeyEncodingOptions.usePropertyKeys
131
+ ? undefined
132
+ : {
133
+ encode: (type, key: FieldKey): string => {
134
+ // translate stored key into property key.
135
+ const simpleNodeSchema =
136
+ context.schema.get(brand(type)) ?? fail(0xb39 /* missing schema */);
137
+ if (isObjectNodeSchema(simpleNodeSchema)) {
138
+ const propertyKey = simpleNodeSchema.storedKeyToPropertyKey.get(key);
139
+ if (propertyKey !== undefined) {
140
+ return propertyKey;
141
+ }
142
+ // Looking up an out of schema key.
143
+ // This must point to a non-existent field.
144
+ // It's possible that the key, if we returned it unmodified, could point to some data
145
+ // (for example if looking up a key which is a stored key already when using property keys).
146
+ // Thus return an arbitrary key that was selected randomly, so should not exist on non-adversarial data:
147
+ const arbitrary = "arbitrary unused key: fe71614a-bf3e-43b3-b7b0-4cef39538e90";
148
+ assert(
149
+ !simpleNodeSchema.storedKeyToPropertyKey.has(brand(arbitrary)),
150
+ 0xa13 /* arbitrarily selected unused key was actually used */,
161
151
  );
152
+ return arbitrary;
153
+ }
154
+ return key;
155
+ },
156
+ parse: (type, inputKey): FieldKey => {
157
+ const simpleNodeSchema =
158
+ context.schema.get(brand(type)) ?? unknownTypeError(type);
159
+ if (isObjectNodeSchema(simpleNodeSchema)) {
160
+ const info = simpleNodeSchema.flexKeyMap.get(inputKey);
161
+ if (info === undefined) {
162
+ throw new UsageError(
163
+ `Failed to parse VerboseTree due to unexpected key ${JSON.stringify(inputKey)} on type ${JSON.stringify(type)}.`,
164
+ );
165
+ }
166
+ return info.storedKey;
162
167
  }
163
- return info.storedKey;
164
- }
165
- return brand(inputKey);
168
+ return brand(inputKey);
169
+ },
166
170
  },
167
- },
168
171
  };
169
172
  }
170
173
 
@@ -284,7 +287,7 @@ export function verboseFromCursor(
284
287
  options: TreeEncodingOptions,
285
288
  ): VerboseTree {
286
289
  const config: Required<TreeEncodingOptions> = {
287
- useStoredKeys: false,
290
+ keys: KeyEncodingOptions.usePropertyKeys,
288
291
  ...options,
289
292
  };
290
293
 
@@ -25,6 +25,12 @@ export interface SimpleNodeSchemaBase<
25
25
 
26
26
  /**
27
27
  * User-provided {@link NodeSchemaMetadata} for this schema.
28
+ *
29
+ * @remarks
30
+ * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.
31
+ * Different clients in the same collaborative session may see different metadata for the same field.
32
+ *
33
+ * Set via {@link NodeSchemaOptions.metadata}.
28
34
  */
29
35
  readonly metadata: NodeSchemaMetadata<TCustomMetadata>;
30
36
  }
@@ -187,7 +187,9 @@ export interface FieldProps<TCustomMetadata = unknown> {
187
187
  export interface FieldPropsAlpha<TCustomMetadata = unknown>
188
188
  extends FieldProps<TCustomMetadata> {
189
189
  /**
190
- * The persisted metadata for this schema element.
190
+ * The persisted metadata for a field schema.
191
+ * @remarks
192
+ * Sets {@link SimpleFieldSchema.persistedMetadata}.
191
193
  */
192
194
  readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
193
195
  }
@@ -428,9 +430,6 @@ export class FieldSchemaAlpha<
428
430
  */
429
431
  public readonly allowedTypesMetadata: AllowedTypesMetadata;
430
432
 
431
- /**
432
- * Persisted metadata for this field schema.
433
- */
434
433
  public get persistedMetadata(): JsonCompatibleReadOnlyObject | undefined {
435
434
  return this.propsAlpha?.persistedMetadata;
436
435
  }
@@ -70,6 +70,7 @@ export {
70
70
  type SchemaCompatibilityStatus,
71
71
  type ITreeConfigurationOptions,
72
72
  SchemaFactory,
73
+ SchemaFactoryBeta,
73
74
  SchemaFactoryAlpha,
74
75
  type SchemaFactoryObjectOptions,
75
76
  type ScopedSchemaName,
@@ -161,6 +162,8 @@ export {
161
162
  type NodeSchemaOptions,
162
163
  type NodeSchemaOptionsAlpha,
163
164
  type SchemaStaticsAlpha,
165
+ KeyEncodingOptions,
166
+ type TreeParsingOptions,
164
167
  } from "./api/index.js";
165
168
  export type {
166
169
  SimpleTreeSchema,
@@ -184,11 +184,10 @@ function createRecordNodeProxy(
184
184
 
185
185
  const innerNode = getOrCreateInnerNode(proxy);
186
186
  const field = innerNode.tryGetField(brand(key)) as FlexTreeOptionalField | undefined;
187
- if (field === undefined) {
188
- return false;
187
+ if (field !== undefined) {
188
+ field.editor.set(undefined, field.length === 0);
189
189
  }
190
190
 
191
- field.editor.set(undefined, field.length === 0);
192
191
  return true;
193
192
  },
194
193
  });
@@ -26,6 +26,15 @@ export interface SimpleNodeSchemaBaseAlpha<
26
26
  > extends SimpleNodeSchemaBase<TNodeKind, TCustomMetadata> {
27
27
  /**
28
28
  * Persisted metadata for this node schema.
29
+ * @remarks
30
+ * While this can be stored in the document, not all versions / configurations will do so.
31
+ * Additionally, this is not part of {@link TreeView.compatibility|schema compatibility}, so different clients
32
+ * (even within the same collaborative session) may see different `persistedMetadata` for the same node.
33
+ * Specified using {@link NodeSchemaOptionsAlpha.persistedMetadata}.
34
+ * @privateRemarks
35
+ * How/when this gets updated in documents,
36
+ * and how to read it from documents should be documented here when this feature is more mature and these questions have good answers.
37
+ * If this does end up getting reflected in some compatibility value, that should also be documented.
29
38
  */
30
39
  readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined;
31
40
  }
@@ -184,6 +193,9 @@ export interface SimpleFieldSchema {
184
193
 
185
194
  /**
186
195
  * Persisted metadata for this field schema.
196
+ * @remarks
197
+ * Like {@link SimpleNodeSchemaBaseAlpha.persistedMetadata} but for fields.
198
+ * Set via {@link FieldPropsAlpha.persistedMetadata}.
187
199
  */
188
200
  readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
189
201
  }
@@ -161,9 +161,6 @@ export const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<
161
161
  * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.
162
162
  * @privateRemarks
163
163
  * TODO: Persist node metadata once schema FormatV2 is supported.
164
- *
165
- * TODO: AB#43548: Using a stored schema for unhydrated flex trees does not handle schema evolution features like "allowUnknownOptionalFields".
166
- * Usage of this and the conversion which wrap it should be audited and reduced.
167
164
  */
168
165
  export function getStoredSchema(
169
166
  schema: SimpleNodeSchema,