@fluidframework/tree 2.12.0 → 2.13.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 (329) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/api-report/tree.alpha.api.md +86 -10
  3. package/api-report/tree.beta.api.md +22 -10
  4. package/api-report/tree.legacy.alpha.api.md +22 -10
  5. package/api-report/tree.legacy.public.api.md +22 -10
  6. package/api-report/tree.public.api.md +22 -10
  7. package/dist/alpha.d.ts +11 -0
  8. package/dist/beta.d.ts +2 -0
  9. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +10 -0
  10. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  11. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
  12. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  13. package/dist/feature-libraries/index.d.ts +0 -1
  14. package/dist/feature-libraries/index.d.ts.map +1 -1
  15. package/dist/feature-libraries/index.js +2 -4
  16. package/dist/feature-libraries/index.js.map +1 -1
  17. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +1 -1
  18. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  19. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +8 -2
  20. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  21. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +12 -5
  22. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  23. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  24. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  25. package/dist/feature-libraries/modular-schema/genericFieldKind.js +2 -1
  26. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  27. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  28. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  29. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  30. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -0
  31. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  32. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +89 -25
  33. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  34. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +12 -0
  35. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  36. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  37. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  38. package/dist/feature-libraries/optional-field/optionalField.js +24 -4
  39. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  40. package/dist/feature-libraries/sequence-field/utils.d.ts +2 -2
  41. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  42. package/dist/feature-libraries/sequence-field/utils.js +14 -5
  43. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  44. package/dist/index.d.ts +2 -2
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +2 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/legacy.d.ts +2 -0
  49. package/dist/packageVersion.d.ts +1 -1
  50. package/dist/packageVersion.js +1 -1
  51. package/dist/packageVersion.js.map +1 -1
  52. package/dist/public.d.ts +2 -0
  53. package/dist/shared-tree/index.d.ts +2 -1
  54. package/dist/shared-tree/index.d.ts.map +1 -1
  55. package/dist/shared-tree/index.js +2 -1
  56. package/dist/shared-tree/index.js.map +1 -1
  57. package/dist/shared-tree/schematizingTreeView.d.ts +10 -1
  58. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  59. package/dist/shared-tree/schematizingTreeView.js +43 -0
  60. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  61. package/dist/shared-tree/sharedTree.d.ts +6 -3
  62. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  63. package/dist/shared-tree/sharedTree.js +3 -1
  64. package/dist/shared-tree/sharedTree.js.map +1 -1
  65. package/dist/shared-tree/transactionTypes.d.ts +105 -0
  66. package/dist/shared-tree/transactionTypes.d.ts.map +1 -0
  67. package/dist/shared-tree/transactionTypes.js +13 -0
  68. package/dist/shared-tree/transactionTypes.js.map +1 -0
  69. package/dist/shared-tree/treeApi.d.ts +1 -25
  70. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  71. package/dist/shared-tree/treeApi.js +4 -8
  72. package/dist/shared-tree/treeApi.js.map +1 -1
  73. package/dist/shared-tree/treeCheckout.d.ts +4 -1
  74. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  75. package/dist/shared-tree/treeCheckout.js +130 -15
  76. package/dist/shared-tree/treeCheckout.js.map +1 -1
  77. package/dist/shared-tree-core/sharedTreeCore.js +1 -1
  78. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  79. package/dist/simple-tree/api/index.d.ts +1 -0
  80. package/dist/simple-tree/api/index.d.ts.map +1 -1
  81. package/dist/simple-tree/api/index.js +3 -1
  82. package/dist/simple-tree/api/index.js.map +1 -1
  83. package/dist/simple-tree/api/jsonSchema.d.ts +6 -0
  84. package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -1
  85. package/dist/simple-tree/api/jsonSchema.js.map +1 -1
  86. package/dist/simple-tree/api/schemaFactory.d.ts +21 -12
  87. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  88. package/dist/simple-tree/api/schemaFactory.js +5 -2
  89. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  90. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +83 -0
  91. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -0
  92. package/dist/simple-tree/api/schemaFactoryAlpha.js +90 -0
  93. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -0
  94. package/dist/simple-tree/api/simpleSchema.d.ts +5 -1
  95. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
  96. package/dist/simple-tree/api/simpleSchema.js.map +1 -1
  97. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +13 -10
  98. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  99. package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  100. package/dist/simple-tree/api/tree.d.ts +60 -0
  101. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  102. package/dist/simple-tree/api/tree.js.map +1 -1
  103. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  104. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +11 -11
  105. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  106. package/dist/simple-tree/arrayNode.d.ts +2 -2
  107. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  108. package/dist/simple-tree/arrayNode.js +2 -1
  109. package/dist/simple-tree/arrayNode.js.map +1 -1
  110. package/dist/simple-tree/core/treeNodeSchema.d.ts +10 -6
  111. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  112. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  113. package/dist/simple-tree/index.d.ts +2 -2
  114. package/dist/simple-tree/index.d.ts.map +1 -1
  115. package/dist/simple-tree/index.js +3 -2
  116. package/dist/simple-tree/index.js.map +1 -1
  117. package/dist/simple-tree/leafNodeSchema.d.ts +5 -5
  118. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  119. package/dist/simple-tree/mapNode.d.ts +2 -2
  120. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  121. package/dist/simple-tree/mapNode.js +2 -1
  122. package/dist/simple-tree/mapNode.js.map +1 -1
  123. package/dist/simple-tree/objectNode.d.ts +2 -2
  124. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  125. package/dist/simple-tree/objectNode.js +2 -1
  126. package/dist/simple-tree/objectNode.js.map +1 -1
  127. package/dist/simple-tree/objectNodeTypes.d.ts +2 -2
  128. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  129. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  130. package/dist/simple-tree/schemaTypes.d.ts +47 -1
  131. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  132. package/dist/simple-tree/schemaTypes.js.map +1 -1
  133. package/dist/util/index.d.ts +2 -2
  134. package/dist/util/index.d.ts.map +1 -1
  135. package/dist/util/index.js +3 -5
  136. package/dist/util/index.js.map +1 -1
  137. package/dist/util/rangeMap.d.ts +72 -42
  138. package/dist/util/rangeMap.d.ts.map +1 -1
  139. package/dist/util/rangeMap.js +161 -151
  140. package/dist/util/rangeMap.js.map +1 -1
  141. package/dist/util/utils.d.ts +22 -1
  142. package/dist/util/utils.d.ts.map +1 -1
  143. package/dist/util/utils.js +10 -1
  144. package/dist/util/utils.js.map +1 -1
  145. package/lib/alpha.d.ts +11 -0
  146. package/lib/beta.d.ts +2 -0
  147. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +10 -0
  148. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  149. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
  150. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  151. package/lib/feature-libraries/index.d.ts +0 -1
  152. package/lib/feature-libraries/index.d.ts.map +1 -1
  153. package/lib/feature-libraries/index.js +0 -1
  154. package/lib/feature-libraries/index.js.map +1 -1
  155. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +1 -1
  156. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  157. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +9 -3
  158. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  159. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +12 -5
  160. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  161. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  162. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  163. package/lib/feature-libraries/modular-schema/genericFieldKind.js +2 -1
  164. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  165. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  166. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  167. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  168. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -0
  169. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  170. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +89 -25
  171. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  172. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +12 -0
  173. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  174. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  175. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  176. package/lib/feature-libraries/optional-field/optionalField.js +24 -4
  177. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  178. package/lib/feature-libraries/sequence-field/utils.d.ts +2 -2
  179. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  180. package/lib/feature-libraries/sequence-field/utils.js +14 -5
  181. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  182. package/lib/index.d.ts +2 -2
  183. package/lib/index.d.ts.map +1 -1
  184. package/lib/index.js +1 -1
  185. package/lib/index.js.map +1 -1
  186. package/lib/legacy.d.ts +2 -0
  187. package/lib/packageVersion.d.ts +1 -1
  188. package/lib/packageVersion.js +1 -1
  189. package/lib/packageVersion.js.map +1 -1
  190. package/lib/public.d.ts +2 -0
  191. package/lib/shared-tree/index.d.ts +2 -1
  192. package/lib/shared-tree/index.d.ts.map +1 -1
  193. package/lib/shared-tree/index.js +2 -1
  194. package/lib/shared-tree/index.js.map +1 -1
  195. package/lib/shared-tree/schematizingTreeView.d.ts +10 -1
  196. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  197. package/lib/shared-tree/schematizingTreeView.js +46 -3
  198. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  199. package/lib/shared-tree/sharedTree.d.ts +6 -3
  200. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  201. package/lib/shared-tree/sharedTree.js +3 -1
  202. package/lib/shared-tree/sharedTree.js.map +1 -1
  203. package/lib/shared-tree/transactionTypes.d.ts +105 -0
  204. package/lib/shared-tree/transactionTypes.d.ts.map +1 -0
  205. package/lib/shared-tree/transactionTypes.js +10 -0
  206. package/lib/shared-tree/transactionTypes.js.map +1 -0
  207. package/lib/shared-tree/treeApi.d.ts +1 -25
  208. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  209. package/lib/shared-tree/treeApi.js +1 -5
  210. package/lib/shared-tree/treeApi.js.map +1 -1
  211. package/lib/shared-tree/treeCheckout.d.ts +4 -1
  212. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  213. package/lib/shared-tree/treeCheckout.js +130 -15
  214. package/lib/shared-tree/treeCheckout.js.map +1 -1
  215. package/lib/shared-tree-core/sharedTreeCore.js +1 -1
  216. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  217. package/lib/simple-tree/api/index.d.ts +1 -0
  218. package/lib/simple-tree/api/index.d.ts.map +1 -1
  219. package/lib/simple-tree/api/index.js +1 -0
  220. package/lib/simple-tree/api/index.js.map +1 -1
  221. package/lib/simple-tree/api/jsonSchema.d.ts +6 -0
  222. package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -1
  223. package/lib/simple-tree/api/jsonSchema.js.map +1 -1
  224. package/lib/simple-tree/api/schemaFactory.d.ts +21 -12
  225. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  226. package/lib/simple-tree/api/schemaFactory.js +5 -2
  227. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  228. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +83 -0
  229. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -0
  230. package/lib/simple-tree/api/schemaFactoryAlpha.js +86 -0
  231. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -0
  232. package/lib/simple-tree/api/simpleSchema.d.ts +5 -1
  233. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
  234. package/lib/simple-tree/api/simpleSchema.js.map +1 -1
  235. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +14 -11
  236. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  237. package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  238. package/lib/simple-tree/api/tree.d.ts +60 -0
  239. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  240. package/lib/simple-tree/api/tree.js.map +1 -1
  241. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  242. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +12 -12
  243. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  244. package/lib/simple-tree/arrayNode.d.ts +2 -2
  245. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  246. package/lib/simple-tree/arrayNode.js +2 -1
  247. package/lib/simple-tree/arrayNode.js.map +1 -1
  248. package/lib/simple-tree/core/treeNodeSchema.d.ts +10 -6
  249. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  250. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  251. package/lib/simple-tree/index.d.ts +2 -2
  252. package/lib/simple-tree/index.d.ts.map +1 -1
  253. package/lib/simple-tree/index.js +1 -1
  254. package/lib/simple-tree/index.js.map +1 -1
  255. package/lib/simple-tree/leafNodeSchema.d.ts +5 -5
  256. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  257. package/lib/simple-tree/mapNode.d.ts +2 -2
  258. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  259. package/lib/simple-tree/mapNode.js +2 -1
  260. package/lib/simple-tree/mapNode.js.map +1 -1
  261. package/lib/simple-tree/objectNode.d.ts +2 -2
  262. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  263. package/lib/simple-tree/objectNode.js +2 -1
  264. package/lib/simple-tree/objectNode.js.map +1 -1
  265. package/lib/simple-tree/objectNodeTypes.d.ts +2 -2
  266. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  267. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  268. package/lib/simple-tree/schemaTypes.d.ts +47 -1
  269. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  270. package/lib/simple-tree/schemaTypes.js.map +1 -1
  271. package/lib/util/index.d.ts +2 -2
  272. package/lib/util/index.d.ts.map +1 -1
  273. package/lib/util/index.js +2 -2
  274. package/lib/util/index.js.map +1 -1
  275. package/lib/util/rangeMap.d.ts +72 -42
  276. package/lib/util/rangeMap.d.ts.map +1 -1
  277. package/lib/util/rangeMap.js +159 -146
  278. package/lib/util/rangeMap.js.map +1 -1
  279. package/lib/util/utils.d.ts +22 -1
  280. package/lib/util/utils.d.ts.map +1 -1
  281. package/lib/util/utils.js +8 -0
  282. package/lib/util/utils.js.map +1 -1
  283. package/package.json +22 -22
  284. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +14 -1
  285. package/src/feature-libraries/index.ts +0 -1
  286. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +9 -9
  287. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +13 -9
  288. package/src/feature-libraries/modular-schema/genericFieldKind.ts +4 -2
  289. package/src/feature-libraries/modular-schema/index.ts +1 -0
  290. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +124 -31
  291. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +12 -0
  292. package/src/feature-libraries/optional-field/optionalField.ts +34 -5
  293. package/src/feature-libraries/sequence-field/utils.ts +18 -7
  294. package/src/index.ts +11 -0
  295. package/src/packageVersion.ts +1 -1
  296. package/src/shared-tree/index.ts +12 -2
  297. package/src/shared-tree/schematizingTreeView.ts +91 -2
  298. package/src/shared-tree/sharedTree.ts +9 -4
  299. package/src/shared-tree/transactionTypes.ts +125 -0
  300. package/src/shared-tree/treeApi.ts +1 -28
  301. package/src/shared-tree/treeCheckout.ts +147 -13
  302. package/src/shared-tree-core/sharedTreeCore.ts +1 -1
  303. package/src/simple-tree/api/index.ts +1 -0
  304. package/src/simple-tree/api/jsonSchema.ts +7 -0
  305. package/src/simple-tree/api/schemaFactory.ts +33 -6
  306. package/src/simple-tree/api/schemaFactoryAlpha.ts +253 -0
  307. package/src/simple-tree/api/simpleSchema.ts +6 -1
  308. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +22 -12
  309. package/src/simple-tree/api/tree.ts +76 -4
  310. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +19 -13
  311. package/src/simple-tree/arrayNode.ts +7 -1
  312. package/src/simple-tree/core/treeNodeSchema.ts +51 -7
  313. package/src/simple-tree/index.ts +3 -0
  314. package/src/simple-tree/mapNode.ts +7 -1
  315. package/src/simple-tree/objectNode.ts +7 -1
  316. package/src/simple-tree/objectNodeTypes.ts +4 -1
  317. package/src/simple-tree/schemaTypes.ts +50 -1
  318. package/src/util/index.ts +2 -6
  319. package/src/util/rangeMap.ts +199 -189
  320. package/src/util/utils.ts +47 -1
  321. package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -38
  322. package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts.map +0 -1
  323. package/dist/feature-libraries/memoizedIdRangeAllocator.js +0 -74
  324. package/dist/feature-libraries/memoizedIdRangeAllocator.js.map +0 -1
  325. package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -38
  326. package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts.map +0 -1
  327. package/lib/feature-libraries/memoizedIdRangeAllocator.js +0 -71
  328. package/lib/feature-libraries/memoizedIdRangeAllocator.js.map +0 -1
  329. package/src/feature-libraries/memoizedIdRangeAllocator.ts +0 -112
@@ -19,6 +19,7 @@ import {
19
19
  CrossFieldTarget,
20
20
  type NodeId,
21
21
  type CrossFieldKeyRange,
22
+ type NestedChangesIndices,
22
23
  } from "../modular-schema/index.js";
23
24
 
24
25
  import type {
@@ -61,15 +62,25 @@ export function createEmpty(): Changeset {
61
62
  return [];
62
63
  }
63
64
 
64
- export function getNestedChanges(change: Changeset): [NodeId, number | undefined][] {
65
- const output: [NodeId, number | undefined][] = [];
66
- let index = 0;
67
- for (const { changes, cellId, count } of change) {
65
+ export function getNestedChanges(change: Changeset): NestedChangesIndices {
66
+ const output: NestedChangesIndices = [];
67
+ let inputIndex = 0;
68
+ let outputIndex = 0;
69
+ for (const mark of change) {
70
+ const { changes, count } = mark;
68
71
  if (changes !== undefined) {
69
- output.push([changes, cellId === undefined ? index : undefined]);
72
+ output.push([
73
+ changes,
74
+ !areInputCellsEmpty(mark) ? inputIndex : undefined /* inputIndex */,
75
+ !areOutputCellsEmpty(mark) ? outputIndex : undefined /* outputIndex */,
76
+ ]);
77
+ }
78
+ if (!areInputCellsEmpty(mark)) {
79
+ inputIndex += count;
70
80
  }
71
- if (cellId === undefined) {
72
- index += count;
81
+
82
+ if (!areOutputCellsEmpty(mark)) {
83
+ outputIndex += count;
73
84
  }
74
85
  }
75
86
  return output;
package/src/index.ts CHANGED
@@ -48,6 +48,13 @@ export {
48
48
  type ViewContent,
49
49
  TreeAlpha,
50
50
  independentView,
51
+ type RunTransactionParams,
52
+ type VoidTransactionCallbackStatus,
53
+ type TransactionCallbackStatus,
54
+ type TransactionResult,
55
+ type TransactionResultExt,
56
+ type TransactionResultSuccess,
57
+ type TransactionResultFailed,
51
58
  } from "./shared-tree/index.js";
52
59
 
53
60
  export {
@@ -64,6 +71,8 @@ export {
64
71
  type TreeView,
65
72
  type TreeViewEvents,
66
73
  SchemaFactory,
74
+ SchemaFactoryAlpha,
75
+ type SchemaFactoryObjectOptions,
67
76
  type ImplicitFieldSchema,
68
77
  type TreeFieldFromImplicitField,
69
78
  type TreeChangeEvents,
@@ -175,6 +184,8 @@ export {
175
184
  type TreeBranch,
176
185
  type TreeBranchEvents,
177
186
  asTreeViewAlpha,
187
+ type NodeSchemaOptions,
188
+ type NodeSchemaMetadata,
178
189
  } from "./simple-tree/index.js";
179
190
  export {
180
191
  SharedTree,
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/tree";
9
- export const pkgVersion = "2.12.0";
9
+ export const pkgVersion = "2.13.0";
@@ -40,11 +40,21 @@ export type { ISharedTreeEditor, ISchemaEditor } from "./sharedTreeEditBuilder.j
40
40
  export {
41
41
  treeApi as Tree,
42
42
  type TreeApi,
43
+ type RunTransaction,
44
+ } from "./treeApi.js";
45
+
46
+ export {
43
47
  type TransactionConstraint,
44
48
  type NodeInDocumentConstraint,
45
- type RunTransaction,
49
+ type RunTransactionParams,
50
+ type VoidTransactionCallbackStatus,
51
+ type TransactionCallbackStatus,
52
+ type TransactionResult,
53
+ type TransactionResultExt,
54
+ type TransactionResultSuccess,
55
+ type TransactionResultFailed,
46
56
  rollback,
47
- } from "./treeApi.js";
57
+ } from "./transactionTypes.js";
48
58
 
49
59
  export { TreeAlpha } from "./treeApiAlpha.js";
50
60
 
@@ -9,7 +9,7 @@ import type {
9
9
  Listenable,
10
10
  } from "@fluidframework/core-interfaces/internal";
11
11
  import { createEmitter } from "@fluid-internal/client-utils";
12
- import { assert } from "@fluidframework/core-utils/internal";
12
+ import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
13
13
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
14
14
 
15
15
  import { AllowedUpdateType, anchorSlot, type SchemaPolicy } from "../core/index.js";
@@ -19,6 +19,7 @@ import {
19
19
  ContextSlot,
20
20
  cursorForMapTreeNode,
21
21
  type FullSchemaPolicy,
22
+ TreeStatus,
22
23
  } from "../feature-libraries/index.js";
23
24
  import {
24
25
  type FieldSchema,
@@ -43,6 +44,8 @@ import {
43
44
  type UnsafeUnknownSchema,
44
45
  type TreeBranch,
45
46
  type TreeBranchEvents,
47
+ getOrCreateInnerNode,
48
+ getKernel,
46
49
  } from "../simple-tree/index.js";
47
50
  import { Breakable, breakingClass, disposeSymbol, type WithBreakable } from "../util/index.js";
48
51
 
@@ -55,6 +58,14 @@ import {
55
58
  areImplicitFieldSchemaEqual,
56
59
  createUnknownOptionalFieldPolicy,
57
60
  } from "../simple-tree/index.js";
61
+ import type {
62
+ VoidTransactionCallbackStatus,
63
+ TransactionCallbackStatus,
64
+ TransactionResult,
65
+ TransactionResultExt,
66
+ RunTransactionParams,
67
+ TransactionConstraint,
68
+ } from "./transactionTypes.js";
58
69
 
59
70
  /**
60
71
  * Creating multiple tree views from the same checkout is not supported. This slot is used to detect if one already
@@ -213,6 +224,84 @@ export class SchematizingSimpleTreeView<
213
224
  return this.view;
214
225
  }
215
226
 
227
+ /**
228
+ * {@inheritDoc @fluidframework/shared-tree#TreeViewAlpha.runTransaction}
229
+ */
230
+ public runTransaction<TSuccessValue, TFailureValue>(
231
+ transaction: () => TransactionCallbackStatus<TSuccessValue, TFailureValue>,
232
+ params?: RunTransactionParams,
233
+ ): TransactionResultExt<TSuccessValue, TFailureValue>;
234
+ /**
235
+ * {@inheritDoc @fluidframework/shared-tree#TreeViewAlpha.runTransaction}
236
+ */
237
+ public runTransaction(
238
+ transaction: () => VoidTransactionCallbackStatus | void,
239
+ params?: RunTransactionParams,
240
+ ): TransactionResult;
241
+ public runTransaction<TSuccessValue, TFailureValue>(
242
+ transaction: () =>
243
+ | TransactionCallbackStatus<TSuccessValue, TFailureValue>
244
+ | VoidTransactionCallbackStatus
245
+ | void,
246
+ params?: RunTransactionParams,
247
+ ): TransactionResultExt<TSuccessValue, TFailureValue> | TransactionResult {
248
+ const addConstraints = (
249
+ constraintsOnRevert: boolean,
250
+ constraints: readonly TransactionConstraint[] = [],
251
+ ): void => {
252
+ for (const constraint of constraints) {
253
+ switch (constraint.type) {
254
+ case "nodeInDocument": {
255
+ const node = getOrCreateInnerNode(constraint.node);
256
+ const nodeStatus = getKernel(constraint.node).getStatus();
257
+ if (nodeStatus !== TreeStatus.InDocument) {
258
+ const revertText = constraintsOnRevert ? " on revert" : "";
259
+ throw new UsageError(
260
+ `Attempted to add a "nodeInDocument" constraint${revertText}, but the node is not currently in the document. Node status: ${nodeStatus}`,
261
+ );
262
+ }
263
+ if (constraintsOnRevert) {
264
+ this.checkout.editor.addNodeExistsConstraintOnRevert(node.anchorNode);
265
+ } else {
266
+ this.checkout.editor.addNodeExistsConstraint(node.anchorNode);
267
+ }
268
+ break;
269
+ }
270
+ default:
271
+ unreachableCase(constraint.type);
272
+ }
273
+ }
274
+ };
275
+
276
+ this.checkout.transaction.start();
277
+
278
+ // Validate preconditions before running the transaction callback.
279
+ addConstraints(false /* constraintsOnRevert */, params?.preconditions);
280
+ const transactionCallbackStatus = transaction();
281
+ const rollback = transactionCallbackStatus?.rollback;
282
+ const value = (
283
+ transactionCallbackStatus as TransactionCallbackStatus<TSuccessValue, TFailureValue>
284
+ )?.value;
285
+
286
+ if (rollback === true) {
287
+ this.checkout.transaction.abort();
288
+ return value !== undefined
289
+ ? { success: false, value: value as TFailureValue }
290
+ : { success: false };
291
+ }
292
+
293
+ // Validate preconditions on revert after running the transaction callback and was successful.
294
+ addConstraints(
295
+ true /* constraintsOnRevert */,
296
+ transactionCallbackStatus?.preconditionsOnRevert,
297
+ );
298
+
299
+ this.checkout.transaction.commit();
300
+ return value !== undefined
301
+ ? { success: true, value: value as TSuccessValue }
302
+ : { success: true };
303
+ }
304
+
216
305
  private ensureUndisposed(): void {
217
306
  if (this.disposed) {
218
307
  this.failDisposed();
@@ -383,7 +472,7 @@ export class SchematizingSimpleTreeView<
383
472
 
384
473
  // #region Branching
385
474
 
386
- public fork(): ReturnType<TreeBranch["fork"]> & TreeViewAlpha<TRootSchema> {
475
+ public fork(): ReturnType<TreeBranch["fork"]> & SchematizingSimpleTreeView<TRootSchema> {
387
476
  return this.checkout.branch().viewWith(this.config);
388
477
  }
389
478
 
@@ -229,7 +229,7 @@ export class SharedTree
229
229
  id: string,
230
230
  runtime: IFluidDataStoreRuntime,
231
231
  attributes: IChannelAttributes,
232
- optionsParam: SharedTreeOptions,
232
+ optionsParam: SharedTreeOptionsInternal,
233
233
  telemetryContextPrefix: string = "fluid_sharedTree_",
234
234
  ) {
235
235
  if (runtime.idCompressor === undefined) {
@@ -333,6 +333,7 @@ export class SharedTree
333
333
  chunkCompressionStrategy: options.treeEncodeType,
334
334
  logger: this.logger,
335
335
  breaker: this.breaker,
336
+ disposeForksAfterTransaction: options.disposeForksAfterTransaction,
336
337
  },
337
338
  );
338
339
 
@@ -459,7 +460,7 @@ export class SharedTree
459
460
  ): void {
460
461
  assert(
461
462
  !this.checkout.transaction.isInProgress(),
462
- "Cannot submit a commit while a transaction is in progress",
463
+ 0xaa6 /* Cannot submit a commit while a transaction is in progress */,
463
464
  );
464
465
  if (isResubmit) {
465
466
  return super.submitCommit(commit, schemaAndPolicy, isResubmit);
@@ -555,6 +556,9 @@ export type SharedTreeOptions = Partial<ICodecOptions> &
555
556
  Partial<SharedTreeFormatOptions> &
556
557
  ForestOptions;
557
558
 
559
+ export interface SharedTreeOptionsInternal extends SharedTreeOptions {
560
+ disposeForksAfterTransaction?: boolean;
561
+ }
558
562
  /**
559
563
  * Configuration options for SharedTree's internal tree storage.
560
564
  * @alpha
@@ -609,11 +613,12 @@ export enum ForestType {
609
613
  Expensive = 2,
610
614
  }
611
615
 
612
- export const defaultSharedTreeOptions: Required<SharedTreeOptions> = {
616
+ export const defaultSharedTreeOptions: Required<SharedTreeOptionsInternal> = {
613
617
  jsonValidator: noopValidator,
614
618
  forest: ForestType.Reference,
615
619
  treeEncodeType: TreeCompressionStrategy.Compressed,
616
620
  formatVersion: SharedTreeFormatVersion.v3,
621
+ disposeForksAfterTransaction: true,
617
622
  };
618
623
 
619
624
  /**
@@ -628,7 +633,7 @@ export class SharedTreeFactory implements IChannelFactory<ISharedTree> {
628
633
  packageVersion: "0.0.0",
629
634
  };
630
635
 
631
- public constructor(private readonly options: SharedTreeOptions = {}) {}
636
+ public constructor(private readonly options: SharedTreeOptionsInternal = {}) {}
632
637
 
633
638
  public async load(
634
639
  runtime: IFluidDataStoreRuntime,
@@ -0,0 +1,125 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import type { TreeNode } from "../simple-tree/index.js";
7
+
8
+ /**
9
+ * A special object that signifies when a SharedTree {@link RunTransaction | transaction} should "roll back".
10
+ * @public
11
+ */
12
+ export const rollback = Symbol("SharedTree Transaction Rollback");
13
+
14
+ /**
15
+ * A requirement for a SharedTree transaction to succeed.
16
+ * @remarks Transaction constraints are useful for validating that the state of the tree meets some requirement when a transaction runs.
17
+ * In general, when running a transaction a client can validate their tree state in whatever way they wish and decide to either proceed with the transaction or not.
18
+ * However, they cannot know what the tree state will be when the transaction is _sequenced_.
19
+ * There may have been any number of edits from other clients that get sequenced before the transaction is eventually sequenced.
20
+ * Constraints provide a way to validate the tree state after the transaction has been sequenced and abort the transaction if the constraints are not met.
21
+ * All clients will validate the constraints of a transaction when it is sequenced, so all clients will agree on whether the transaction succeeds or not.
22
+ * @public
23
+ */
24
+ export type TransactionConstraint = NodeInDocumentConstraint; // TODO: Add more constraint types here
25
+
26
+ /**
27
+ * A transaction {@link TransactionConstraint | constraint} which requires that the given node exists in the tree.
28
+ * @remarks The node must be in the document (its {@link TreeStatus | status} must be {@link TreeStatus.InDocument | InDocument}) to qualify as "existing".
29
+ * @public
30
+ */
31
+ export interface NodeInDocumentConstraint {
32
+ readonly type: "nodeInDocument";
33
+ readonly node: TreeNode;
34
+ }
35
+
36
+ /**
37
+ * The status of the transaction callback in the {@link RunTransaction | RunTransaction} API.
38
+ * @alpha
39
+ */
40
+ export type TransactionCallbackStatus<TSuccessValue, TFailureValue> = (
41
+ | {
42
+ /** Indicates that the transaction callback ran successfully. */
43
+ rollback?: false;
44
+ /** The user defined value when the transaction ran successfully. */
45
+ value: TSuccessValue;
46
+ }
47
+ | {
48
+ /** Indicates that the transaction callback failed and the transaction should be rolled back. */
49
+ rollback: true;
50
+ /** The user defined value when the transaction failed. */
51
+ value: TFailureValue;
52
+ }
53
+ ) & {
54
+ /**
55
+ * An optional list of {@link TransactionConstraint | constraints} that will be checked when the commit corresponding
56
+ * to this transaction is reverted. If any of these constraints are not met when the revert is being applied either
57
+ * locally or on remote clients, the revert will be ignored.
58
+ * These constraints must also be met at the time they are first introduced. If they are not met after the transaction
59
+ * callback returns, then `runTransaction` (which invokes the transaction callback) will throw a `UsageError`.
60
+ */
61
+ preconditionsOnRevert?: readonly TransactionConstraint[];
62
+ };
63
+
64
+ /**
65
+ * The status of a the transaction callback in the {@link RunTransaction | RunTransaction} API where the transaction doesn't
66
+ * need to return a value. This is the same as {@link TransactionCallbackStatus} but with the `value` field omitted. This
67
+ * @alpha
68
+ */
69
+ export type VoidTransactionCallbackStatus = Omit<
70
+ TransactionCallbackStatus<unknown, unknown>,
71
+ "value"
72
+ >;
73
+
74
+ /**
75
+ * The result of the {@link RunTransaction | RunTransaction} API when it was successful.
76
+ * @alpha
77
+ */
78
+ export interface TransactionResultSuccess<TSuccessValue> {
79
+ /** Indicates that the transaction was successful. */
80
+ success: true;
81
+ /** The user defined value when the transaction was successful. */
82
+ value: TSuccessValue;
83
+ }
84
+
85
+ /**
86
+ * The result of the {@link RunTransaction | RunTransaction} API when it failed.
87
+ * @alpha
88
+ */
89
+ export interface TransactionResultFailed<TFailureValue> {
90
+ /** Indicates that the transaction failed. */
91
+ success: false;
92
+ /** The user defined value when the transaction failed. */
93
+ value: TFailureValue;
94
+ }
95
+
96
+ /**
97
+ * The result of the {@link RunTransaction | RunTransaction} API.
98
+ * @alpha
99
+ */
100
+ export type TransactionResultExt<TSuccessValue, TFailureValue> =
101
+ | TransactionResultSuccess<TSuccessValue>
102
+ | TransactionResultFailed<TFailureValue>;
103
+
104
+ /**
105
+ * The result of the {@link RunTransaction | RunTransaction} API. This is the same as {@link TransactionResultExt}
106
+ * but with the `value` field omitted. This is useful when the transaction callback doesn't need to return a value.
107
+ * @alpha
108
+ */
109
+ export type TransactionResult =
110
+ | Omit<TransactionResultSuccess<unknown>, "value">
111
+ | Omit<TransactionResultFailed<unknown>, "value">;
112
+
113
+ /**
114
+ * The parameters for the {@link RunTransaction | RunTransaction} API.
115
+ * @alpha
116
+ */
117
+ export interface RunTransactionParams {
118
+ /**
119
+ * An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.
120
+ * If any of the constraints are not met when `runTransaction` is called, an error will be thrown.
121
+ * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on
122
+ * this client and ignored by all other clients.
123
+ */
124
+ readonly preconditions?: readonly TransactionConstraint[];
125
+ }
@@ -19,12 +19,7 @@ import {
19
19
  import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
20
20
  import type { ITreeCheckout } from "./treeCheckout.js";
21
21
  import { getCheckoutFlexTreeView } from "./checkoutFlexTreeView.js";
22
-
23
- /**
24
- * A special object that signifies when a SharedTree {@link RunTransaction | transaction} should "roll back".
25
- * @public
26
- */
27
- export const rollback = Symbol("SharedTree Transaction Rollback");
22
+ import { rollback, type TransactionConstraint } from "./transactionTypes.js";
28
23
 
29
24
  /**
30
25
  * A function which runs a transaction in a SharedTree.
@@ -380,28 +375,6 @@ export const treeApi: TreeApi = {
380
375
  },
381
376
  };
382
377
 
383
- /**
384
- * A requirement for a SharedTree transaction to succeed.
385
- * @remarks Transaction constraints are useful for validating that the state of the tree meets some requirement when a transaction runs.
386
- * In general, when running a transaction a client can validate their tree state in whatever way they wish and decide to either proceed with the transaction or not.
387
- * However, they cannot know what the tree state will be when the transaction is _sequenced_.
388
- * There may have been any number of edits from other clients that get sequenced before the transaction is eventually sequenced.
389
- * Constraints provide a way to validate the tree state after the transaction has been sequenced and abort the transaction if the constraints are not met.
390
- * All clients will validate the constraints of a transaction when it is sequenced, so all clients will agree on whether the transaction succeeds or not.
391
- * @public
392
- */
393
- export type TransactionConstraint = NodeInDocumentConstraint; // TODO: Add more constraint types here
394
-
395
- /**
396
- * A transaction {@link TransactionConstraint | constraint} which requires that the given node exists in the tree.
397
- * @remarks The node must be in the document (its {@link TreeStatus | status} must be {@link TreeStatus.InDocument | InDocument}) to qualify as "existing".
398
- * @public
399
- */
400
- export interface NodeInDocumentConstraint {
401
- readonly type: "nodeInDocument";
402
- readonly node: TreeNode;
403
- }
404
-
405
378
  // TODO: Add more constraint types here
406
379
 
407
380
  /** Creates a copy of `runTransaction` with the `rollback` property added so as to satisfy the `RunTransaction` interface. */