@fluidframework/tree 2.4.0 → 2.5.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 (446) hide show
  1. package/.vscode/settings.json +12 -1
  2. package/CHANGELOG.md +371 -0
  3. package/api-report/tree.alpha.api.md +271 -80
  4. package/api-report/tree.beta.api.md +100 -51
  5. package/api-report/tree.legacy.alpha.api.md +99 -50
  6. package/api-report/tree.legacy.public.api.md +99 -50
  7. package/api-report/tree.public.api.md +99 -50
  8. package/dist/alpha.d.ts +32 -2
  9. package/dist/beta.d.ts +6 -0
  10. package/dist/codec/codec.d.ts +24 -0
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +26 -1
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/index.d.ts +1 -1
  15. package/dist/codec/index.d.ts.map +1 -1
  16. package/dist/codec/index.js +2 -1
  17. package/dist/codec/index.js.map +1 -1
  18. package/dist/core/rebase/index.d.ts +2 -2
  19. package/dist/core/rebase/index.d.ts.map +1 -1
  20. package/dist/core/rebase/index.js +2 -2
  21. package/dist/core/rebase/index.js.map +1 -1
  22. package/dist/core/rebase/types.d.ts +0 -4
  23. package/dist/core/rebase/types.d.ts.map +1 -1
  24. package/dist/core/rebase/types.js +1 -7
  25. package/dist/core/rebase/types.js.map +1 -1
  26. package/dist/core/rebase/utils.d.ts +1 -0
  27. package/dist/core/rebase/utils.d.ts.map +1 -1
  28. package/dist/core/rebase/utils.js +29 -4
  29. package/dist/core/rebase/utils.js.map +1 -1
  30. package/dist/events/interop.d.ts +1 -7
  31. package/dist/events/interop.d.ts.map +1 -1
  32. package/dist/events/interop.js.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
  34. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  35. package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  36. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  37. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
  38. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  39. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  40. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
  41. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  42. package/dist/feature-libraries/flex-tree/lazyNode.js +3 -0
  43. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  44. package/dist/feature-libraries/object-forest/objectForest.js +1 -1
  45. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  46. package/dist/feature-libraries/treeCursorUtils.js +2 -2
  47. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  48. package/dist/index.d.ts +4 -4
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +12 -7
  51. package/dist/index.js.map +1 -1
  52. package/dist/internalTypes.d.ts +1 -1
  53. package/dist/internalTypes.d.ts.map +1 -1
  54. package/dist/internalTypes.js.map +1 -1
  55. package/dist/legacy.d.ts +6 -0
  56. package/dist/packageVersion.d.ts +1 -1
  57. package/dist/packageVersion.js +1 -1
  58. package/dist/packageVersion.js.map +1 -1
  59. package/dist/public.d.ts +6 -0
  60. package/dist/shared-tree/independentView.d.ts +57 -0
  61. package/dist/shared-tree/independentView.d.ts.map +1 -0
  62. package/dist/shared-tree/independentView.js +89 -0
  63. package/dist/shared-tree/independentView.js.map +1 -0
  64. package/dist/shared-tree/index.d.ts +3 -1
  65. package/dist/shared-tree/index.d.ts.map +1 -1
  66. package/dist/shared-tree/index.js +6 -1
  67. package/dist/shared-tree/index.js.map +1 -1
  68. package/dist/shared-tree/schematizingTreeView.d.ts +12 -8
  69. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  70. package/dist/shared-tree/schematizingTreeView.js +28 -0
  71. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  72. package/dist/shared-tree/sharedTree.d.ts +10 -7
  73. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  74. package/dist/shared-tree/sharedTree.js.map +1 -1
  75. package/dist/shared-tree/treeApi.d.ts +6 -6
  76. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  77. package/dist/shared-tree/treeApi.js.map +1 -1
  78. package/dist/shared-tree/treeApiAlpha.d.ts +147 -0
  79. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -0
  80. package/dist/shared-tree/treeApiAlpha.js +122 -0
  81. package/dist/shared-tree/treeApiAlpha.js.map +1 -0
  82. package/dist/shared-tree/treeCheckout.d.ts +12 -7
  83. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  84. package/dist/shared-tree/treeCheckout.js +11 -4
  85. package/dist/shared-tree/treeCheckout.js.map +1 -1
  86. package/dist/shared-tree-core/editManager.d.ts +13 -6
  87. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  88. package/dist/shared-tree-core/editManager.js +80 -33
  89. package/dist/shared-tree-core/editManager.js.map +1 -1
  90. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
  91. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  92. package/dist/shared-tree-core/sharedTreeCore.js +28 -3
  93. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  94. package/dist/simple-tree/api/conciseTree.d.ts +2 -1
  95. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  96. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  97. package/dist/simple-tree/api/create.d.ts +6 -24
  98. package/dist/simple-tree/api/create.d.ts.map +1 -1
  99. package/dist/simple-tree/api/create.js +4 -19
  100. package/dist/simple-tree/api/create.js.map +1 -1
  101. package/dist/simple-tree/api/customTree.d.ts +1 -0
  102. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  103. package/dist/simple-tree/api/customTree.js +2 -2
  104. package/dist/simple-tree/api/customTree.js.map +1 -1
  105. package/dist/simple-tree/api/index.d.ts +7 -7
  106. package/dist/simple-tree/api/index.d.ts.map +1 -1
  107. package/dist/simple-tree/api/index.js +10 -2
  108. package/dist/simple-tree/api/index.js.map +1 -1
  109. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +25 -27
  110. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  111. package/dist/simple-tree/api/schemaCreationUtilities.js +31 -21
  112. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  113. package/dist/simple-tree/api/schemaFactory.d.ts +16 -12
  114. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  115. package/dist/simple-tree/api/schemaFactory.js +4 -0
  116. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  117. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +3 -3
  118. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  119. package/dist/simple-tree/api/storedSchema.js +2 -2
  120. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  121. package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  122. package/dist/simple-tree/api/tree.d.ts +122 -5
  123. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  124. package/dist/simple-tree/api/tree.js +12 -4
  125. package/dist/simple-tree/api/tree.js.map +1 -1
  126. package/dist/simple-tree/api/treeApiBeta.d.ts +8 -5
  127. package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -1
  128. package/dist/simple-tree/api/treeApiBeta.js +3 -15
  129. package/dist/simple-tree/api/treeApiBeta.js.map +1 -1
  130. package/dist/simple-tree/api/typesUnsafe.d.ts +69 -17
  131. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  132. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  133. package/dist/simple-tree/api/verboseTree.d.ts +3 -0
  134. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  135. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  136. package/dist/simple-tree/arrayNode.d.ts +15 -4
  137. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  138. package/dist/simple-tree/arrayNode.js +1 -1
  139. package/dist/simple-tree/arrayNode.js.map +1 -1
  140. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  141. package/dist/simple-tree/core/treeNodeSchema.d.ts +51 -11
  142. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  143. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  144. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  145. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  146. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
  147. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  148. package/dist/simple-tree/core/withType.d.ts +2 -1
  149. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  150. package/dist/simple-tree/core/withType.js.map +1 -1
  151. package/dist/simple-tree/createContext.js +2 -2
  152. package/dist/simple-tree/createContext.js.map +1 -1
  153. package/dist/simple-tree/index.d.ts +6 -6
  154. package/dist/simple-tree/index.d.ts.map +1 -1
  155. package/dist/simple-tree/index.js +15 -5
  156. package/dist/simple-tree/index.js.map +1 -1
  157. package/dist/simple-tree/leafNodeSchema.d.ts +6 -5
  158. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  159. package/dist/simple-tree/leafNodeSchema.js +3 -0
  160. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  161. package/dist/simple-tree/mapNode.d.ts +1 -1
  162. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  163. package/dist/simple-tree/mapNode.js +6 -0
  164. package/dist/simple-tree/mapNode.js.map +1 -1
  165. package/dist/simple-tree/objectNode.d.ts +4 -2
  166. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  167. package/dist/simple-tree/objectNode.js.map +1 -1
  168. package/dist/simple-tree/schemaTypes.d.ts +210 -18
  169. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  170. package/dist/simple-tree/schemaTypes.js +66 -1
  171. package/dist/simple-tree/schemaTypes.js.map +1 -1
  172. package/dist/simple-tree/toMapTree.d.ts +4 -2
  173. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  174. package/dist/simple-tree/toMapTree.js.map +1 -1
  175. package/dist/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
  176. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -0
  177. package/dist/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
  178. package/dist/simple-tree/toStoredSchema.js.map +1 -0
  179. package/dist/simple-tree/treeNodeValid.d.ts +5 -1
  180. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  181. package/dist/simple-tree/treeNodeValid.js +7 -1
  182. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  183. package/dist/util/index.d.ts +3 -2
  184. package/dist/util/index.d.ts.map +1 -1
  185. package/dist/util/index.js +3 -1
  186. package/dist/util/index.js.map +1 -1
  187. package/dist/util/typeCheck.d.ts +9 -0
  188. package/dist/util/typeCheck.d.ts.map +1 -1
  189. package/dist/util/typeCheck.js.map +1 -1
  190. package/dist/util/typeUtils.d.ts +61 -0
  191. package/dist/util/typeUtils.d.ts.map +1 -1
  192. package/dist/util/typeUtils.js +27 -0
  193. package/dist/util/typeUtils.js.map +1 -1
  194. package/dist/util/utils.d.ts +7 -3
  195. package/dist/util/utils.d.ts.map +1 -1
  196. package/dist/util/utils.js +13 -3
  197. package/dist/util/utils.js.map +1 -1
  198. package/lib/alpha.d.ts +32 -2
  199. package/lib/beta.d.ts +6 -0
  200. package/lib/codec/codec.d.ts +24 -0
  201. package/lib/codec/codec.d.ts.map +1 -1
  202. package/lib/codec/codec.js +25 -0
  203. package/lib/codec/codec.js.map +1 -1
  204. package/lib/codec/index.d.ts +1 -1
  205. package/lib/codec/index.d.ts.map +1 -1
  206. package/lib/codec/index.js +1 -1
  207. package/lib/codec/index.js.map +1 -1
  208. package/lib/core/rebase/index.d.ts +2 -2
  209. package/lib/core/rebase/index.d.ts.map +1 -1
  210. package/lib/core/rebase/index.js +2 -2
  211. package/lib/core/rebase/index.js.map +1 -1
  212. package/lib/core/rebase/types.d.ts +0 -4
  213. package/lib/core/rebase/types.d.ts.map +1 -1
  214. package/lib/core/rebase/types.js +0 -5
  215. package/lib/core/rebase/types.js.map +1 -1
  216. package/lib/core/rebase/utils.d.ts +1 -0
  217. package/lib/core/rebase/utils.d.ts.map +1 -1
  218. package/lib/core/rebase/utils.js +27 -3
  219. package/lib/core/rebase/utils.js.map +1 -1
  220. package/lib/events/interop.d.ts +1 -7
  221. package/lib/events/interop.d.ts.map +1 -1
  222. package/lib/events/interop.js.map +1 -1
  223. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  224. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  225. package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  226. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  227. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
  228. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  229. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  230. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
  231. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  232. package/lib/feature-libraries/flex-tree/lazyNode.js +3 -0
  233. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  234. package/lib/feature-libraries/object-forest/objectForest.js +1 -1
  235. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  236. package/lib/feature-libraries/treeCursorUtils.js +2 -2
  237. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  238. package/lib/index.d.ts +4 -4
  239. package/lib/index.d.ts.map +1 -1
  240. package/lib/index.js +4 -3
  241. package/lib/index.js.map +1 -1
  242. package/lib/internalTypes.d.ts +1 -1
  243. package/lib/internalTypes.d.ts.map +1 -1
  244. package/lib/internalTypes.js.map +1 -1
  245. package/lib/legacy.d.ts +6 -0
  246. package/lib/packageVersion.d.ts +1 -1
  247. package/lib/packageVersion.js +1 -1
  248. package/lib/packageVersion.js.map +1 -1
  249. package/lib/public.d.ts +6 -0
  250. package/lib/shared-tree/independentView.d.ts +57 -0
  251. package/lib/shared-tree/independentView.d.ts.map +1 -0
  252. package/lib/shared-tree/independentView.js +84 -0
  253. package/lib/shared-tree/independentView.js.map +1 -0
  254. package/lib/shared-tree/index.d.ts +3 -1
  255. package/lib/shared-tree/index.d.ts.map +1 -1
  256. package/lib/shared-tree/index.js +2 -0
  257. package/lib/shared-tree/index.js.map +1 -1
  258. package/lib/shared-tree/schematizingTreeView.d.ts +12 -8
  259. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  260. package/lib/shared-tree/schematizingTreeView.js +29 -1
  261. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  262. package/lib/shared-tree/sharedTree.d.ts +10 -7
  263. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  264. package/lib/shared-tree/sharedTree.js.map +1 -1
  265. package/lib/shared-tree/treeApi.d.ts +6 -6
  266. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  267. package/lib/shared-tree/treeApi.js.map +1 -1
  268. package/lib/shared-tree/treeApiAlpha.d.ts +147 -0
  269. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -0
  270. package/lib/shared-tree/treeApiAlpha.js +119 -0
  271. package/lib/shared-tree/treeApiAlpha.js.map +1 -0
  272. package/lib/shared-tree/treeCheckout.d.ts +12 -7
  273. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  274. package/lib/shared-tree/treeCheckout.js +11 -4
  275. package/lib/shared-tree/treeCheckout.js.map +1 -1
  276. package/lib/shared-tree-core/editManager.d.ts +13 -6
  277. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  278. package/lib/shared-tree-core/editManager.js +80 -33
  279. package/lib/shared-tree-core/editManager.js.map +1 -1
  280. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
  281. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  282. package/lib/shared-tree-core/sharedTreeCore.js +29 -4
  283. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  284. package/lib/simple-tree/api/conciseTree.d.ts +2 -1
  285. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  286. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  287. package/lib/simple-tree/api/create.d.ts +6 -24
  288. package/lib/simple-tree/api/create.d.ts.map +1 -1
  289. package/lib/simple-tree/api/create.js +2 -16
  290. package/lib/simple-tree/api/create.js.map +1 -1
  291. package/lib/simple-tree/api/customTree.d.ts +1 -0
  292. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  293. package/lib/simple-tree/api/customTree.js +2 -2
  294. package/lib/simple-tree/api/customTree.js.map +1 -1
  295. package/lib/simple-tree/api/index.d.ts +7 -7
  296. package/lib/simple-tree/api/index.d.ts.map +1 -1
  297. package/lib/simple-tree/api/index.js +6 -4
  298. package/lib/simple-tree/api/index.js.map +1 -1
  299. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +25 -27
  300. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  301. package/lib/simple-tree/api/schemaCreationUtilities.js +30 -19
  302. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  303. package/lib/simple-tree/api/schemaFactory.d.ts +16 -12
  304. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  305. package/lib/simple-tree/api/schemaFactory.js +4 -0
  306. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  307. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +3 -3
  308. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  309. package/lib/simple-tree/api/storedSchema.js +1 -1
  310. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  311. package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  312. package/lib/simple-tree/api/tree.d.ts +122 -5
  313. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  314. package/lib/simple-tree/api/tree.js +9 -2
  315. package/lib/simple-tree/api/tree.js.map +1 -1
  316. package/lib/simple-tree/api/treeApiBeta.d.ts +8 -5
  317. package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -1
  318. package/lib/simple-tree/api/treeApiBeta.js +4 -16
  319. package/lib/simple-tree/api/treeApiBeta.js.map +1 -1
  320. package/lib/simple-tree/api/typesUnsafe.d.ts +69 -17
  321. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  322. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  323. package/lib/simple-tree/api/verboseTree.d.ts +3 -0
  324. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  325. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  326. package/lib/simple-tree/arrayNode.d.ts +15 -4
  327. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  328. package/lib/simple-tree/arrayNode.js +1 -1
  329. package/lib/simple-tree/arrayNode.js.map +1 -1
  330. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  331. package/lib/simple-tree/core/treeNodeSchema.d.ts +51 -11
  332. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  333. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  334. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  335. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  336. package/lib/simple-tree/core/unhydratedFlexTree.js +4 -1
  337. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  338. package/lib/simple-tree/core/withType.d.ts +2 -1
  339. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  340. package/lib/simple-tree/core/withType.js.map +1 -1
  341. package/lib/simple-tree/createContext.js +1 -1
  342. package/lib/simple-tree/createContext.js.map +1 -1
  343. package/lib/simple-tree/index.d.ts +6 -6
  344. package/lib/simple-tree/index.d.ts.map +1 -1
  345. package/lib/simple-tree/index.js +5 -5
  346. package/lib/simple-tree/index.js.map +1 -1
  347. package/lib/simple-tree/leafNodeSchema.d.ts +6 -5
  348. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  349. package/lib/simple-tree/leafNodeSchema.js +3 -0
  350. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  351. package/lib/simple-tree/mapNode.d.ts +1 -1
  352. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  353. package/lib/simple-tree/mapNode.js +6 -0
  354. package/lib/simple-tree/mapNode.js.map +1 -1
  355. package/lib/simple-tree/objectNode.d.ts +4 -2
  356. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  357. package/lib/simple-tree/objectNode.js.map +1 -1
  358. package/lib/simple-tree/schemaTypes.d.ts +210 -18
  359. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  360. package/lib/simple-tree/schemaTypes.js +64 -1
  361. package/lib/simple-tree/schemaTypes.js.map +1 -1
  362. package/lib/simple-tree/toMapTree.d.ts +4 -2
  363. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  364. package/lib/simple-tree/toMapTree.js.map +1 -1
  365. package/lib/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
  366. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -0
  367. package/lib/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
  368. package/lib/simple-tree/toStoredSchema.js.map +1 -0
  369. package/lib/simple-tree/treeNodeValid.d.ts +5 -1
  370. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  371. package/lib/simple-tree/treeNodeValid.js +7 -1
  372. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  373. package/lib/util/index.d.ts +3 -2
  374. package/lib/util/index.d.ts.map +1 -1
  375. package/lib/util/index.js +1 -0
  376. package/lib/util/index.js.map +1 -1
  377. package/lib/util/typeCheck.d.ts +9 -0
  378. package/lib/util/typeCheck.d.ts.map +1 -1
  379. package/lib/util/typeCheck.js.map +1 -1
  380. package/lib/util/typeUtils.d.ts +61 -0
  381. package/lib/util/typeUtils.d.ts.map +1 -1
  382. package/lib/util/typeUtils.js +25 -1
  383. package/lib/util/typeUtils.js.map +1 -1
  384. package/lib/util/utils.d.ts +7 -3
  385. package/lib/util/utils.d.ts.map +1 -1
  386. package/lib/util/utils.js +13 -3
  387. package/lib/util/utils.js.map +1 -1
  388. package/package.json +55 -30
  389. package/src/codec/codec.ts +25 -0
  390. package/src/codec/index.ts +1 -0
  391. package/src/core/rebase/index.ts +1 -1
  392. package/src/core/rebase/types.ts +0 -12
  393. package/src/core/rebase/utils.ts +35 -3
  394. package/src/events/interop.ts +1 -12
  395. package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
  396. package/src/feature-libraries/chunked-forest/uniformChunk.ts +1 -1
  397. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +9 -0
  398. package/src/feature-libraries/flex-tree/lazyNode.ts +5 -0
  399. package/src/feature-libraries/object-forest/objectForest.ts +1 -1
  400. package/src/feature-libraries/treeCursorUtils.ts +2 -2
  401. package/src/index.ts +36 -6
  402. package/src/internalTypes.ts +4 -0
  403. package/src/packageVersion.ts +1 -1
  404. package/src/shared-tree/independentView.ts +176 -0
  405. package/src/shared-tree/index.ts +9 -1
  406. package/src/shared-tree/schematizingTreeView.ts +64 -13
  407. package/src/shared-tree/sharedTree.ts +29 -9
  408. package/src/shared-tree/treeApi.ts +19 -9
  409. package/src/shared-tree/treeApiAlpha.ts +401 -0
  410. package/src/shared-tree/treeCheckout.ts +28 -5
  411. package/src/shared-tree-core/editManager.ts +126 -59
  412. package/src/shared-tree-core/sharedTreeCore.ts +37 -8
  413. package/src/simple-tree/api/conciseTree.ts +2 -1
  414. package/src/simple-tree/api/create.ts +33 -65
  415. package/src/simple-tree/api/customTree.ts +3 -2
  416. package/src/simple-tree/api/index.ts +19 -8
  417. package/src/simple-tree/api/schemaCreationUtilities.ts +59 -37
  418. package/src/simple-tree/api/schemaFactory.ts +28 -12
  419. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +3 -3
  420. package/src/simple-tree/api/storedSchema.ts +1 -1
  421. package/src/simple-tree/api/tree.ts +152 -7
  422. package/src/simple-tree/api/treeApiBeta.ts +35 -31
  423. package/src/simple-tree/api/typesUnsafe.ts +125 -30
  424. package/src/simple-tree/api/verboseTree.ts +3 -0
  425. package/src/simple-tree/arrayNode.ts +38 -17
  426. package/src/simple-tree/core/getOrCreateNode.ts +1 -1
  427. package/src/simple-tree/core/treeNodeSchema.ts +107 -34
  428. package/src/simple-tree/core/unhydratedFlexTree.ts +6 -0
  429. package/src/simple-tree/core/withType.ts +2 -1
  430. package/src/simple-tree/createContext.ts +1 -1
  431. package/src/simple-tree/index.ts +34 -3
  432. package/src/simple-tree/leafNodeSchema.ts +6 -1
  433. package/src/simple-tree/mapNode.ts +13 -4
  434. package/src/simple-tree/objectNode.ts +5 -3
  435. package/src/simple-tree/schemaTypes.ts +342 -36
  436. package/src/simple-tree/toMapTree.ts +4 -1
  437. package/src/simple-tree/treeNodeValid.ts +11 -1
  438. package/src/util/index.ts +7 -0
  439. package/src/util/typeCheck.ts +13 -0
  440. package/src/util/typeUtils.ts +87 -0
  441. package/src/util/utils.ts +20 -7
  442. package/dist/simple-tree/toFlexSchema.d.ts.map +0 -1
  443. package/dist/simple-tree/toFlexSchema.js.map +0 -1
  444. package/lib/simple-tree/toFlexSchema.d.ts.map +0 -1
  445. package/lib/simple-tree/toFlexSchema.js.map +0 -1
  446. /package/src/simple-tree/{toFlexSchema.ts → toStoredSchema.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTreeCore.js","sourceRoot":"","sources":["../../src/shared-tree-core/sharedTreeCore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAkE;AAclE,qEAA4E;AAC5E,0EAGqD;AAGrD,+CAU0B;AAC1B,+CAO0B;AAE1B,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AAK,GAAG,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI;YACd,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ICodecOptions, IJsonCodec } from \"../codec/index.js\";\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tRevisionTagCodec,\n\ttype SchemaAndPolicy,\n\ttype SchemaPolicy,\n\ttype TaggedChange,\n\ttype TreeStoredSchemaRepository,\n} from \"../core/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\tbrand,\n\tBreakable,\n\ttype WithBreakable,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"../util/index.js\";\n\nimport { type SharedTreeBranch, getChangeReplaceType } from \"./branch.js\";\nimport { EditManager, minimumPossibleSequenceNumber } from \"./editManager.js\";\nimport { makeEditManagerCodec } from \"./editManagerCodecs.js\";\nimport type { SeqNumber } from \"./editManagerFormat.js\";\nimport { EditManagerSummarizer } from \"./editManagerSummarizer.js\";\nimport { type MessageEncodingContext, makeMessageCodec } from \"./messageCodecs.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\nimport { type ChangeEnricherReadonlyCheckout, NoOpChangeEnricher } from \"./changeEnricher.js\";\nimport type { ResubmitMachine } from \"./resubmitMachine.js\";\nimport { DefaultResubmitMachine } from \"./defaultResubmitMachine.js\";\nimport { BranchCommitEnricher } from \"./branchCommitEnricher.js\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\n// TODO: Organize this to be adjacent to persisted types.\nconst summarizablesTreeKey = \"indexes\";\n\nexport interface ExplicitCoreCodecVersions {\n\teditManager: number;\n\tmessage: number;\n}\n\nexport interface ClonableSchemaAndPolicy extends SchemaAndPolicy {\n\tschema: TreeStoredSchemaRepository;\n}\n\n/**\n * Generic shared tree, which needs to be configured with indexes, field kinds and other configuration.\n */\n@breakingClass\nexport class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>\n\textends SharedObject\n\timplements WithBreakable\n{\n\tpublic readonly breaker: Breakable = new Breakable(\"Shared Tree\");\n\n\tprivate readonly editManager: EditManager<TEditor, TChange, ChangeFamily<TEditor, TChange>>;\n\tprivate readonly summarizables: readonly Summarizable[];\n\t/**\n\t * The sequence number that this instance is at.\n\t * This number is artificial in that it is made up by this instance as opposed to being provided by the runtime.\n\t * Is `undefined` after (and only after) this instance is attached.\n\t */\n\tprivate detachedRevision: SeqNumber | undefined = minimumPossibleSequenceNumber;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\tpublic get editor(): TEditor {\n\t\treturn this.getLocalBranch().editor;\n\t}\n\n\t/**\n\t * Gets the revision at the head of the trunk.\n\t */\n\tprotected get trunkHeadRevision(): RevisionTag {\n\t\treturn this.editManager.getTrunkHead().revision;\n\t}\n\n\t/**\n\t * Used to encode/decode messages sent to/received from the Fluid runtime.\n\t *\n\t * @remarks Since there is currently only one format, this can just be cached on the class.\n\t * With more write formats active, it may make sense to keep around the \"usual\" format codec\n\t * (the one for the current persisted configuration) and resolve codecs for different versions\n\t * as necessary (e.g. an upgrade op came in, or the configuration changed within the collab window\n\t * and an op needs to be interpreted which isn't written with the current configuration).\n\t */\n\tprivate readonly messageCodec: IJsonCodec<\n\t\tDecodedMessage<TChange>,\n\t\tunknown,\n\t\tunknown,\n\t\tMessageEncodingContext\n\t>;\n\n\tprivate readonly idCompressor: IIdCompressor;\n\n\tprivate readonly resubmitMachine: ResubmitMachine<TChange>;\n\tprotected readonly commitEnricher: BranchCommitEnricher<TChange>;\n\n\tprotected readonly mintRevisionTag: () => RevisionTag;\n\n\tprivate readonly schemaAndPolicy: ClonableSchemaAndPolicy;\n\n\t/**\n\t * @param summarizables - Summarizers for all indexes used by this tree\n\t * @param changeFamily - The change family\n\t * @param editManager - The edit manager\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t * @param telemetryContextPrefix - The property prefix for telemetry pertaining to this object. See {@link ITelemetryContext}\n\t */\n\tpublic constructor(\n\t\tsummarizables: readonly Summarizable[],\n\t\tchangeFamily: ChangeFamily<TEditor, TChange>,\n\t\toptions: ICodecOptions,\n\t\tformatOptions: ExplicitCoreCodecVersions,\n\t\t// Base class arguments\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\ttelemetryContextPrefix: string,\n\t\tschema: TreeStoredSchemaRepository,\n\t\tschemaPolicy: SchemaPolicy,\n\t\tresubmitMachine?: ResubmitMachine<TChange>,\n\t\tenricher?: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tsuper(id, runtime, attributes, telemetryContextPrefix);\n\n\t\tthis.schemaAndPolicy = {\n\t\t\tschema,\n\t\t\tpolicy: schemaPolicy,\n\t\t};\n\n\t\tconst rebaseLogger = createChildLogger({\n\t\t\tlogger: this.logger,\n\t\t\tnamespace: \"Rebase\",\n\t\t});\n\n\t\tassert(\n\t\t\truntime.idCompressor !== undefined,\n\t\t\t0x886 /* IdCompressor must be enabled to use SharedTree */,\n\t\t);\n\t\tthis.idCompressor = runtime.idCompressor;\n\t\tthis.mintRevisionTag = () => this.idCompressor.generateCompressedId();\n\t\t/**\n\t\t * A random ID that uniquely identifies this client in the collab session.\n\t\t * This is sent alongside every op to identify which client the op originated from.\n\t\t * This is used rather than the Fluid client ID because the Fluid client ID is not stable across reconnections.\n\t\t */\n\t\tconst localSessionId = runtime.idCompressor.localSessionId;\n\t\tthis.editManager = new EditManager(\n\t\t\tchangeFamily,\n\t\t\tlocalSessionId,\n\t\t\tthis.mintRevisionTag,\n\t\t\trebaseLogger,\n\t\t);\n\t\tthis.editManager.localBranch.on(\"transactionStarted\", () => {\n\t\t\tthis.commitEnricher.startNewTransaction();\n\t\t});\n\t\tthis.editManager.localBranch.on(\"transactionAborted\", () => {\n\t\t\tthis.commitEnricher.abortCurrentTransaction();\n\t\t});\n\t\tthis.editManager.localBranch.on(\"transactionCommitted\", () => {\n\t\t\tthis.commitEnricher.commitCurrentTransaction();\n\t\t});\n\t\tthis.editManager.localBranch.on(\"beforeChange\", (change) => {\n\t\t\t// Ensure that any previously prepared commits that have not been sent are purged.\n\t\t\tthis.commitEnricher.purgePreparedCommits();\n\t\t\tif (this.detachedRevision !== undefined) {\n\t\t\t\t// Edits submitted before the first attach do not need enrichment because they will not be applied by peers.\n\t\t\t} else if (change.type === \"append\") {\n\t\t\t\tif (this.getLocalBranch().isTransacting()) {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tthis.commitEnricher.ingestTransactionCommit(newCommit);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tthis.commitEnricher.prepareCommit(newCommit, false);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tchange.type === \"replace\" &&\n\t\t\t\tgetChangeReplaceType(change) === \"transactionCommit\" &&\n\t\t\t\t!this.getLocalBranch().isTransacting()\n\t\t\t) {\n\t\t\t\tassert(\n\t\t\t\t\tchange.newCommits.length === 1,\n\t\t\t\t\t0x983 /* Unexpected number of commits when committing transaction */,\n\t\t\t\t);\n\t\t\t\tthis.commitEnricher.prepareCommit(change.newCommits[0] ?? oob(), true);\n\t\t\t}\n\t\t});\n\t\tthis.editManager.localBranch.on(\"afterChange\", (change) => {\n\t\t\tif (this.getLocalBranch().isTransacting()) {\n\t\t\t\t// We do not submit ops for changes that are part of a transaction.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tchange.type === \"append\" ||\n\t\t\t\t(change.type === \"replace\" && getChangeReplaceType(change) === \"transactionCommit\")\n\t\t\t) {\n\t\t\t\tif (this.detachedRevision !== undefined) {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tthis.submitCommit(newCommit, this.schemaAndPolicy);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tconst prepared = this.commitEnricher.getPreparedCommit(newCommit);\n\t\t\t\t\t\tthis.submitCommit(prepared, this.schemaAndPolicy);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tconst revisionTagCodec = new RevisionTagCodec(runtime.idCompressor);\n\t\tconst editManagerCodec = makeEditManagerCodec(\n\t\t\tthis.editManager.changeFamily.codecs,\n\t\t\trevisionTagCodec,\n\t\t\toptions,\n\t\t\tformatOptions.editManager,\n\t\t);\n\t\tthis.summarizables = [\n\t\t\tnew EditManagerSummarizer(\n\t\t\t\tthis.editManager,\n\t\t\t\teditManagerCodec,\n\t\t\t\tthis.idCompressor,\n\t\t\t\tthis.schemaAndPolicy,\n\t\t\t),\n\t\t\t...summarizables,\n\t\t];\n\t\tassert(\n\t\t\tnew Set(this.summarizables.map((e) => e.key)).size === this.summarizables.length,\n\t\t\t0x350 /* Index summary element keys must be unique */,\n\t\t);\n\n\t\tthis.messageCodec = makeMessageCodec(\n\t\t\tchangeFamily.codecs,\n\t\t\tnew RevisionTagCodec(runtime.idCompressor),\n\t\t\toptions,\n\t\t\tformatOptions.message,\n\t\t);\n\n\t\tconst changeEnricher = enricher ?? new NoOpChangeEnricher();\n\t\tthis.resubmitMachine =\n\t\t\tresubmitMachine ??\n\t\t\tnew DefaultResubmitMachine(\n\t\t\t\t(change: TaggedChange<TChange>) =>\n\t\t\t\t\tchangeFamily.rebaser.invert(change, true, this.mintRevisionTag()),\n\t\t\t\tchangeEnricher,\n\t\t\t);\n\t\tthis.commitEnricher = new BranchCommitEnricher(changeFamily.rebaser, changeEnricher);\n\t}\n\n\t// TODO: SharedObject's merging of the two summary methods into summarizeCore is not what we want here:\n\t// We might want to not subclass it, or override/reimplement most of its functionality.\n\t@throwIfBroken\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tconst summarizableBuilder = new SummaryTreeBuilder();\n\t\t// Merge the summaries of all summarizables together under a single ISummaryTree\n\t\tfor (const s of this.summarizables) {\n\t\t\tsummarizableBuilder.addWithStats(\n\t\t\t\ts.key,\n\t\t\t\ts.getAttachSummary(\n\t\t\t\t\t(contents) => serializer.stringify(contents, this.handle),\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\ttelemetryContext,\n\t\t\t\t\tincrementalSummaryContext,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tbuilder.addWithStats(summarizablesTreeKey, summarizableBuilder.getSummaryTree());\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tprotected async loadCore(services: IChannelStorageService): Promise<void> {\n\t\tconst loadSummaries = this.summarizables.map(async (summaryElement) =>\n\t\t\tsummaryElement.load(\n\t\t\t\tscopeStorageService(services, summarizablesTreeKey, summaryElement.key),\n\t\t\t\t(contents) => this.serializer.parse(contents),\n\t\t\t),\n\t\t);\n\n\t\tawait Promise.all(loadSummaries);\n\t}\n\n\t/**\n\t * Submits an op to the Fluid runtime containing the given commit\n\t * @param commit - the commit to submit\n\t * @returns the submitted commit. This is undefined if the underlying `SharedObject` is not attached,\n\t * and may differ from `commit` due to enrichments like detached tree refreshers.\n\t */\n\n\tprivate submitCommit(\n\t\tcommit: GraphCommit<TChange>,\n\t\tschemaAndPolicy: ClonableSchemaAndPolicy,\n\t\tisResubmit = false,\n\t): void {\n\t\tassert(\n\t\t\t// Edits should not be submitted until all transactions finish\n\t\t\t!this.getLocalBranch().isTransacting() || isResubmit,\n\t\t\t0x68b /* Unexpected edit submitted during transaction */,\n\t\t);\n\t\tassert(\n\t\t\tthis.isAttached() === (this.detachedRevision === undefined),\n\t\t\t0x95a /* Detached revision should only be set when not attached */,\n\t\t);\n\n\t\t// Edits submitted before the first attach are treated as sequenced because they will be included\n\t\t// in the attach summary that is uploaded to the service.\n\t\t// Until this attach workflow happens, this instance essentially behaves as a centralized data structure.\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\tconst newRevision: SeqNumber = brand((this.detachedRevision as number) + 1);\n\t\t\tthis.detachedRevision = newRevision;\n\t\t\tthis.editManager.addSequencedChange(\n\t\t\t\t{ ...commit, sessionId: this.editManager.localSessionId },\n\t\t\t\tnewRevision,\n\t\t\t\tthis.detachedRevision,\n\t\t\t);\n\t\t\tthis.editManager.advanceMinimumSequenceNumber(newRevision);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst message = this.messageCodec.encode(\n\t\t\t{\n\t\t\t\tcommit,\n\t\t\t\tsessionId: this.editManager.localSessionId,\n\t\t\t},\n\t\t\t{\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t\tschema: schemaAndPolicy,\n\t\t\t},\n\t\t);\n\t\tthis.submitLocalMessage(message, {\n\t\t\t// Clone the schema to ensure that during resubmit the schema has not been mutated by later changes\n\t\t\tschema: schemaAndPolicy.schema.clone(),\n\t\t\tpolicy: schemaAndPolicy.policy,\n\t\t});\n\t\tthis.resubmitMachine.onCommitSubmitted(commit);\n\t}\n\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst { commit, sessionId } = this.messageCodec.decode(message.contents, {\n\t\t\tidCompressor: this.idCompressor,\n\t\t});\n\n\t\tthis.editManager.addSequencedChange(\n\t\t\t{ ...commit, sessionId },\n\t\t\tbrand(message.sequenceNumber),\n\t\t\tbrand(message.referenceSequenceNumber),\n\t\t);\n\t\tthis.resubmitMachine.onSequencedCommitApplied(local);\n\n\t\tthis.editManager.advanceMinimumSequenceNumber(brand(message.minimumSequenceNumber));\n\t}\n\n\t/**\n\t * @returns the head commit of the root local branch\n\t */\n\tprotected getLocalBranch(): SharedTreeBranch<TEditor, TChange> {\n\t\treturn this.editManager.localBranch;\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override didAttach(): void {\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\tthis.detachedRevision = undefined;\n\t\t}\n\t}\n\n\tprotected override reSubmitCore(\n\t\tcontent: JsonCompatibleReadOnly,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision },\n\t\t} = this.messageCodec.decode(this.serializer.decode(content), {\n\t\t\tidCompressor: this.idCompressor,\n\t\t});\n\t\tconst [commit] = this.editManager.findLocalCommit(revision);\n\t\t// If a resubmit phase is not already in progress, then this must be the first commit of a new resubmit phase.\n\t\tif (this.resubmitMachine.isInResubmitPhase === false) {\n\t\t\tconst toResubmit = this.editManager.getLocalCommits();\n\t\t\tassert(\n\t\t\t\tcommit === toResubmit[0],\n\t\t\t\t0x95d /* Resubmit phase should start with the oldest local commit */,\n\t\t\t);\n\t\t\tthis.resubmitMachine.prepareForResubmit(toResubmit);\n\t\t}\n\t\tassert(\n\t\t\tisClonableSchemaPolicy(localOpMetadata),\n\t\t\t0x95e /* Local metadata must contain schema and policy. */,\n\t\t);\n\t\tassert(\n\t\t\tthis.resubmitMachine.isInResubmitPhase !== false,\n\t\t\t0x984 /* Invalid resubmit outside of resubmit phase */,\n\t\t);\n\t\tconst enrichedCommit = this.resubmitMachine.peekNextCommit();\n\t\tthis.submitCommit(enrichedCommit, localOpMetadata, true);\n\t}\n\n\tprotected applyStashedOp(content: JsonCompatibleReadOnly): void {\n\t\tassert(\n\t\t\t!this.getLocalBranch().isTransacting(),\n\t\t\t0x674 /* Unexpected transaction is open while applying stashed ops */,\n\t\t);\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision, change },\n\t\t} = this.messageCodec.decode(content, { idCompressor: this.idCompressor });\n\t\tthis.editManager.localBranch.apply({ change, revision });\n\t}\n\n\tpublic override getGCData(fullGC?: boolean): IGarbageCollectionData {\n\t\tconst gcNodes: IGarbageCollectionData[\"gcNodes\"] = super.getGCData(fullGC).gcNodes;\n\t\tfor (const s of this.summarizables) {\n\t\t\tfor (const [id, routes] of Object.entries(s.getGCData(fullGC).gcNodes)) {\n\t\t\t\tgcNodes[id] ??= [];\n\t\t\t\tfor (const route of routes) {\n\t\t\t\t\t// Non null asserting here because we are creating an array at gcNodes[id] if it is undefined\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tgcNodes[id]!.push(route);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tgcNodes,\n\t\t};\n\t}\n}\n\nfunction isClonableSchemaPolicy(\n\tmaybeSchemaPolicy: unknown,\n): maybeSchemaPolicy is ClonableSchemaAndPolicy {\n\tconst schemaAndPolicy = maybeSchemaPolicy as ClonableSchemaAndPolicy;\n\treturn schemaAndPolicy.schema !== undefined && schemaAndPolicy.policy !== undefined;\n}\n\n/**\n * Specifies the behavior of a component that puts data in a summary.\n */\nexport interface Summarizable {\n\t/**\n\t * Field name in summary json under which this element stores its data.\n\t */\n\treadonly key: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.\n\t */\n\tgetAttachSummary(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.\n\t */\n\tsummarize(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).getGCData}\n\t */\n\t// TODO: Change this interface (and the one in ISharedObject, if necessary) to support \"handles within handles\".\n\t// Consider the case of a document with history; the return value here currently grows unboundedly.\n\tgetGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Allows the component to perform custom loading. The storage service is scoped to this component and therefore\n\t * paths in this component will not collide with those in other components, even if they are the same string.\n\t * @param service - Storage used by the component\n\t * @param parse - Parses serialized data from storage into runtime objects for the component\n\t */\n\tload(service: IChannelStorageService, parse: SummaryElementParser): Promise<void>;\n}\n\n/**\n * Serializes the given contents into a string acceptable for storing in summaries, i.e. all\n * Fluid handles have been replaced appropriately by an IFluidSerializer\n */\nexport type SummaryElementStringifier = (contents: unknown) => string;\n\n/**\n * Parses a serialized/summarized string into an object, rehydrating any Fluid handles as necessary\n */\nexport type SummaryElementParser = (contents: string) => unknown;\n\n/**\n * Compose an {@link IChannelStorageService} which prefixes all paths before forwarding them to the original service\n */\nfunction scopeStorageService(\n\tservice: IChannelStorageService,\n\t...pathElements: string[]\n): IChannelStorageService {\n\tconst scope = `${pathElements.join(\"/\")}/`;\n\n\treturn {\n\t\tasync readBlob(path: string): Promise<ArrayBufferLike> {\n\t\t\treturn service.readBlob(`${scope}${path}`);\n\t\t},\n\t\tasync contains(path) {\n\t\t\treturn service.contains(`${scope}${path}`);\n\t\t},\n\t\tasync list(path) {\n\t\t\treturn service.list(`${scope}${path}`);\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"sharedTreeCore.js","sourceRoot":"","sources":["../../src/shared-tree-core/sharedTreeCore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAkE;AAclE,qEAA4E;AAC5E,0EAGqD;AAGrD,+CAW0B;AAC1B,+CAO0B;AAE1B,2CAA0E;AAC1E,qDAA8E;AAC9E,iEAA8D;AAE9D,yEAAmE;AACnE,yDAAmF;AAEnF,2DAA8F;AAE9F,2EAAqE;AACrE,uEAAiE;AACjE,uEAA6E;AAE7E,yDAAyD;AACzD,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAWvC;;GAEG;IAEU,cAAc;4BAD1B,wBAAa;;;;sBAEL,uBAAY;;;2CAApB,SAAQ,WAAY;QAcpB;;;WAGG;QACH,IAAW,MAAM;YAChB,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,CAAC;QACrC,CAAC;QAED;;WAEG;QACH,IAAc,iBAAiB;YAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC;QACjD,CAAC;QA2BD;;;;;;;;WAQG;QACH,YACC,aAAsC,EACtC,YAA4C,EAC5C,OAAsB,EACtB,aAAwC;QACxC,uBAAuB;Q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IACrE,OAAO,eAAe,CAAC,MAAM,KAAK,SAAS,IAAI,eAAe,CAAC,MAAM,KAAK,SAAS,CAAC;AACrF,CAAC;AA6DD;;GAEG;AACH,SAAS,mBAAmB,CAC3B,OAA+B,EAC/B,GAAG,YAAsB;IAEzB,MAAM,KAAK,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAE3C,OAAO;QACN,KAAK,CAAC,QAAQ,CAAC,IAAY;YAC1B,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,IAAI;YAClB,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI;YACd,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ICodecOptions, IJsonCodec } from \"../codec/index.js\";\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\tfindAncestor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tRevisionTagCodec,\n\ttype SchemaAndPolicy,\n\ttype SchemaPolicy,\n\ttype TaggedChange,\n\ttype TreeStoredSchemaRepository,\n} from \"../core/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\tbrand,\n\tBreakable,\n\ttype WithBreakable,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"../util/index.js\";\n\nimport { type SharedTreeBranch, getChangeReplaceType } from \"./branch.js\";\nimport { EditManager, minimumPossibleSequenceNumber } from \"./editManager.js\";\nimport { makeEditManagerCodec } from \"./editManagerCodecs.js\";\nimport type { SeqNumber } from \"./editManagerFormat.js\";\nimport { EditManagerSummarizer } from \"./editManagerSummarizer.js\";\nimport { type MessageEncodingContext, makeMessageCodec } from \"./messageCodecs.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\nimport { type ChangeEnricherReadonlyCheckout, NoOpChangeEnricher } from \"./changeEnricher.js\";\nimport type { ResubmitMachine } from \"./resubmitMachine.js\";\nimport { DefaultResubmitMachine } from \"./defaultResubmitMachine.js\";\nimport { BranchCommitEnricher } from \"./branchCommitEnricher.js\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\n// TODO: Organize this to be adjacent to persisted types.\nconst summarizablesTreeKey = \"indexes\";\n\nexport interface ExplicitCoreCodecVersions {\n\teditManager: number;\n\tmessage: number;\n}\n\nexport interface ClonableSchemaAndPolicy extends SchemaAndPolicy {\n\tschema: TreeStoredSchemaRepository;\n}\n\n/**\n * Generic shared tree, which needs to be configured with indexes, field kinds and other configuration.\n */\n@breakingClass\nexport class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>\n\textends SharedObject\n\timplements WithBreakable\n{\n\tpublic readonly breaker: Breakable = new Breakable(\"Shared Tree\");\n\n\tprivate readonly editManager: EditManager<TEditor, TChange, ChangeFamily<TEditor, TChange>>;\n\tprivate readonly summarizables: readonly [EditManagerSummarizer<TChange>, ...Summarizable[]];\n\t/**\n\t * The sequence number that this instance is at.\n\t * This number is artificial in that it is made up by this instance as opposed to being provided by the runtime.\n\t * Is `undefined` after (and only after) this instance is attached.\n\t */\n\tprivate detachedRevision: SeqNumber | undefined = minimumPossibleSequenceNumber;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\tpublic get editor(): TEditor {\n\t\treturn this.getLocalBranch().editor;\n\t}\n\n\t/**\n\t * Gets the revision at the head of the trunk.\n\t */\n\tprotected get trunkHeadRevision(): RevisionTag {\n\t\treturn this.editManager.getTrunkHead().revision;\n\t}\n\n\t/**\n\t * Used to encode/decode messages sent to/received from the Fluid runtime.\n\t *\n\t * @remarks Since there is currently only one format, this can just be cached on the class.\n\t * With more write formats active, it may make sense to keep around the \"usual\" format codec\n\t * (the one for the current persisted configuration) and resolve codecs for different versions\n\t * as necessary (e.g. an upgrade op came in, or the configuration changed within the collab window\n\t * and an op needs to be interpreted which isn't written with the current configuration).\n\t */\n\tprivate readonly messageCodec: IJsonCodec<\n\t\tDecodedMessage<TChange>,\n\t\tunknown,\n\t\tunknown,\n\t\tMessageEncodingContext\n\t>;\n\n\tprivate readonly idCompressor: IIdCompressor;\n\n\tprivate readonly resubmitMachine: ResubmitMachine<TChange>;\n\tprotected readonly commitEnricher: BranchCommitEnricher<TChange>;\n\n\tprotected readonly mintRevisionTag: () => RevisionTag;\n\n\tprivate readonly schemaAndPolicy: ClonableSchemaAndPolicy;\n\n\t/**\n\t * @param summarizables - Summarizers for all indexes used by this tree\n\t * @param changeFamily - The change family\n\t * @param editManager - The edit manager\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t * @param telemetryContextPrefix - The property prefix for telemetry pertaining to this object. See {@link ITelemetryContext}\n\t */\n\tpublic constructor(\n\t\tsummarizables: readonly Summarizable[],\n\t\tchangeFamily: ChangeFamily<TEditor, TChange>,\n\t\toptions: ICodecOptions,\n\t\tformatOptions: ExplicitCoreCodecVersions,\n\t\t// Base class arguments\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\ttelemetryContextPrefix: string,\n\t\tschema: TreeStoredSchemaRepository,\n\t\tschemaPolicy: SchemaPolicy,\n\t\tresubmitMachine?: ResubmitMachine<TChange>,\n\t\tenricher?: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tsuper(id, runtime, attributes, telemetryContextPrefix);\n\n\t\tthis.schemaAndPolicy = {\n\t\t\tschema,\n\t\t\tpolicy: schemaPolicy,\n\t\t};\n\n\t\tconst rebaseLogger = createChildLogger({\n\t\t\tlogger: this.logger,\n\t\t\tnamespace: \"Rebase\",\n\t\t});\n\n\t\tassert(\n\t\t\truntime.idCompressor !== undefined,\n\t\t\t0x886 /* IdCompressor must be enabled to use SharedTree */,\n\t\t);\n\t\tthis.idCompressor = runtime.idCompressor;\n\t\tthis.mintRevisionTag = () => this.idCompressor.generateCompressedId();\n\t\t/**\n\t\t * A random ID that uniquely identifies this client in the collab session.\n\t\t * This is sent alongside every op to identify which client the op originated from.\n\t\t * This is used rather than the Fluid client ID because the Fluid client ID is not stable across reconnections.\n\t\t */\n\t\tconst localSessionId = runtime.idCompressor.localSessionId;\n\t\tthis.editManager = new EditManager(\n\t\t\tchangeFamily,\n\t\t\tlocalSessionId,\n\t\t\tthis.mintRevisionTag,\n\t\t\trebaseLogger,\n\t\t);\n\t\tthis.editManager.localBranch.on(\"transactionStarted\", () => {\n\t\t\tthis.commitEnricher.startNewTransaction();\n\t\t});\n\t\tthis.editManager.localBranch.on(\"transactionAborted\", () => {\n\t\t\tthis.commitEnricher.abortCurrentTransaction();\n\t\t});\n\t\tthis.editManager.localBranch.on(\"transactionCommitted\", () => {\n\t\t\tthis.commitEnricher.commitCurrentTransaction();\n\t\t});\n\t\tthis.editManager.localBranch.on(\"beforeChange\", (change) => {\n\t\t\t// Ensure that any previously prepared commits that have not been sent are purged.\n\t\t\tthis.commitEnricher.purgePreparedCommits();\n\t\t\tif (this.detachedRevision !== undefined) {\n\t\t\t\t// Edits submitted before the first attach do not need enrichment because they will not be applied by peers.\n\t\t\t} else if (change.type === \"append\") {\n\t\t\t\tif (this.getLocalBranch().isTransacting()) {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tthis.commitEnricher.ingestTransactionCommit(newCommit);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tthis.commitEnricher.prepareCommit(newCommit, false);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tchange.type === \"replace\" &&\n\t\t\t\tgetChangeReplaceType(change) === \"transactionCommit\" &&\n\t\t\t\t!this.getLocalBranch().isTransacting()\n\t\t\t) {\n\t\t\t\tassert(\n\t\t\t\t\tchange.newCommits.length === 1,\n\t\t\t\t\t0x983 /* Unexpected number of commits when committing transaction */,\n\t\t\t\t);\n\t\t\t\tthis.commitEnricher.prepareCommit(change.newCommits[0] ?? oob(), true);\n\t\t\t}\n\t\t});\n\t\tthis.editManager.localBranch.on(\"afterChange\", (change) => {\n\t\t\tif (this.getLocalBranch().isTransacting()) {\n\t\t\t\t// We do not submit ops for changes that are part of a transaction.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tchange.type === \"append\" ||\n\t\t\t\t(change.type === \"replace\" && getChangeReplaceType(change) === \"transactionCommit\")\n\t\t\t) {\n\t\t\t\tif (this.detachedRevision !== undefined) {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tthis.submitCommit(newCommit, this.schemaAndPolicy);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tconst prepared = this.commitEnricher.getPreparedCommit(newCommit);\n\t\t\t\t\t\tthis.submitCommit(prepared, this.schemaAndPolicy);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tconst revisionTagCodec = new RevisionTagCodec(runtime.idCompressor);\n\t\tconst editManagerCodec = makeEditManagerCodec(\n\t\t\tthis.editManager.changeFamily.codecs,\n\t\t\trevisionTagCodec,\n\t\t\toptions,\n\t\t\tformatOptions.editManager,\n\t\t);\n\t\tthis.summarizables = [\n\t\t\tnew EditManagerSummarizer(\n\t\t\t\tthis.editManager,\n\t\t\t\teditManagerCodec,\n\t\t\t\tthis.idCompressor,\n\t\t\t\tthis.schemaAndPolicy,\n\t\t\t),\n\t\t\t...summarizables,\n\t\t];\n\t\tassert(\n\t\t\tnew Set(this.summarizables.map((e) => e.key)).size === this.summarizables.length,\n\t\t\t0x350 /* Index summary element keys must be unique */,\n\t\t);\n\n\t\tthis.messageCodec = makeMessageCodec(\n\t\t\tchangeFamily.codecs,\n\t\t\tnew RevisionTagCodec(runtime.idCompressor),\n\t\t\toptions,\n\t\t\tformatOptions.message,\n\t\t);\n\n\t\tconst changeEnricher = enricher ?? new NoOpChangeEnricher();\n\t\tthis.resubmitMachine =\n\t\t\tresubmitMachine ??\n\t\t\tnew DefaultResubmitMachine(\n\t\t\t\t(change: TaggedChange<TChange>) =>\n\t\t\t\t\tchangeFamily.rebaser.invert(change, true, this.mintRevisionTag()),\n\t\t\t\tchangeEnricher,\n\t\t\t);\n\t\tthis.commitEnricher = new BranchCommitEnricher(changeFamily.rebaser, changeEnricher);\n\t}\n\n\t// TODO: SharedObject's merging of the two summary methods into summarizeCore is not what we want here:\n\t// We might want to not subclass it, or override/reimplement most of its functionality.\n\t@throwIfBroken\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tconst summarizableBuilder = new SummaryTreeBuilder();\n\t\t// Merge the summaries of all summarizables together under a single ISummaryTree\n\t\tfor (const s of this.summarizables) {\n\t\t\tsummarizableBuilder.addWithStats(\n\t\t\t\ts.key,\n\t\t\t\ts.getAttachSummary(\n\t\t\t\t\t(contents) => serializer.stringify(contents, this.handle),\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\ttelemetryContext,\n\t\t\t\t\tincrementalSummaryContext,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tbuilder.addWithStats(summarizablesTreeKey, summarizableBuilder.getSummaryTree());\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tprotected async loadCore(services: IChannelStorageService): Promise<void> {\n\t\tconst [editManagerSummarizer, ...summarizables] = this.summarizables;\n\t\tconst loadEditManager = this.loadSummarizable(editManagerSummarizer, services);\n\t\tconst loadSummarizables = summarizables.map(async (s) =>\n\t\t\tthis.loadSummarizable(s, services),\n\t\t);\n\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\t// If we are detached but loading from a summary, then we need to update our detached revision to ensure that it is ahead of all detached revisions in the summary.\n\t\t\t// First, finish loading the edit manager so that we can inspect the sequence numbers of the commits on the trunk.\n\t\t\tawait loadEditManager;\n\t\t\t// Find the most recent detached revision in the summary trunk...\n\t\t\tlet latestDetachedSequenceNumber: SeqNumber | undefined;\n\t\t\tfindAncestor(this.editManager.getTrunkHead(), (c) => {\n\t\t\t\tconst sequenceNumber = this.editManager.getSequenceNumber(c);\n\t\t\t\tif (sequenceNumber !== undefined && sequenceNumber < 0) {\n\t\t\t\t\tlatestDetachedSequenceNumber = sequenceNumber;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t});\n\t\t\t// ...and set our detached revision to be as it would be if we had been already created that revision.\n\t\t\tthis.detachedRevision = latestDetachedSequenceNumber ?? this.detachedRevision;\n\t\t\tawait Promise.all(loadSummarizables);\n\t\t} else {\n\t\t\tawait Promise.all([loadEditManager, ...loadSummarizables]);\n\t\t}\n\t}\n\n\tprivate async loadSummarizable(\n\t\tsummarizable: Summarizable,\n\t\tservices: IChannelStorageService,\n\t): Promise<void> {\n\t\treturn summarizable.load(\n\t\t\tscopeStorageService(services, summarizablesTreeKey, summarizable.key),\n\t\t\t(contents) => this.serializer.parse(contents),\n\t\t);\n\t}\n\n\t/**\n\t * Submits an op to the Fluid runtime containing the given commit\n\t * @param commit - the commit to submit\n\t * @returns the submitted commit. This is undefined if the underlying `SharedObject` is not attached,\n\t * and may differ from `commit` due to enrichments like detached tree refreshers.\n\t */\n\n\tprivate submitCommit(\n\t\tcommit: GraphCommit<TChange>,\n\t\tschemaAndPolicy: ClonableSchemaAndPolicy,\n\t\tisResubmit = false,\n\t): void {\n\t\tassert(\n\t\t\t// Edits should not be submitted until all transactions finish\n\t\t\t!this.getLocalBranch().isTransacting() || isResubmit,\n\t\t\t0x68b /* Unexpected edit submitted during transaction */,\n\t\t);\n\t\tassert(\n\t\t\tthis.isAttached() === (this.detachedRevision === undefined),\n\t\t\t0x95a /* Detached revision should only be set when not attached */,\n\t\t);\n\n\t\t// Edits submitted before the first attach are treated as sequenced because they will be included\n\t\t// in the attach summary that is uploaded to the service.\n\t\t// Until this attach workflow happens, this instance essentially behaves as a centralized data structure.\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\tconst newRevision: SeqNumber = brand((this.detachedRevision as number) + 1);\n\t\t\tthis.detachedRevision = newRevision;\n\t\t\tthis.editManager.addSequencedChange(\n\t\t\t\t{ ...commit, sessionId: this.editManager.localSessionId },\n\t\t\t\tnewRevision,\n\t\t\t\tthis.detachedRevision,\n\t\t\t);\n\t\t\tthis.editManager.advanceMinimumSequenceNumber(newRevision, false);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst message = this.messageCodec.encode(\n\t\t\t{\n\t\t\t\tcommit,\n\t\t\t\tsessionId: this.editManager.localSessionId,\n\t\t\t},\n\t\t\t{\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t\tschema: schemaAndPolicy,\n\t\t\t},\n\t\t);\n\t\tthis.submitLocalMessage(message, {\n\t\t\t// Clone the schema to ensure that during resubmit the schema has not been mutated by later changes\n\t\t\tschema: schemaAndPolicy.schema.clone(),\n\t\t\tpolicy: schemaAndPolicy.policy,\n\t\t});\n\t\tthis.resubmitMachine.onCommitSubmitted(commit);\n\t}\n\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst { commit, sessionId } = this.messageCodec.decode(message.contents, {\n\t\t\tidCompressor: this.idCompressor,\n\t\t});\n\n\t\tthis.editManager.addSequencedChange(\n\t\t\t{ ...commit, sessionId },\n\t\t\tbrand(message.sequenceNumber),\n\t\t\tbrand(message.referenceSequenceNumber),\n\t\t);\n\t\tthis.resubmitMachine.onSequencedCommitApplied(local);\n\n\t\tthis.editManager.advanceMinimumSequenceNumber(brand(message.minimumSequenceNumber));\n\t}\n\n\t/**\n\t * @returns the head commit of the root local branch\n\t */\n\tprotected getLocalBranch(): SharedTreeBranch<TEditor, TChange> {\n\t\treturn this.editManager.localBranch;\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override didAttach(): void {\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\tthis.detachedRevision = undefined;\n\t\t}\n\t}\n\n\tprotected override reSubmitCore(\n\t\tcontent: JsonCompatibleReadOnly,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision },\n\t\t} = this.messageCodec.decode(this.serializer.decode(content), {\n\t\t\tidCompressor: this.idCompressor,\n\t\t});\n\t\tconst [commit] = this.editManager.findLocalCommit(revision);\n\t\t// If a resubmit phase is not already in progress, then this must be the first commit of a new resubmit phase.\n\t\tif (this.resubmitMachine.isInResubmitPhase === false) {\n\t\t\tconst toResubmit = this.editManager.getLocalCommits();\n\t\t\tassert(\n\t\t\t\tcommit === toResubmit[0],\n\t\t\t\t0x95d /* Resubmit phase should start with the oldest local commit */,\n\t\t\t);\n\t\t\tthis.resubmitMachine.prepareForResubmit(toResubmit);\n\t\t}\n\t\tassert(\n\t\t\tisClonableSchemaPolicy(localOpMetadata),\n\t\t\t0x95e /* Local metadata must contain schema and policy. */,\n\t\t);\n\t\tassert(\n\t\t\tthis.resubmitMachine.isInResubmitPhase !== false,\n\t\t\t0x984 /* Invalid resubmit outside of resubmit phase */,\n\t\t);\n\t\tconst enrichedCommit = this.resubmitMachine.peekNextCommit();\n\t\tthis.submitCommit(enrichedCommit, localOpMetadata, true);\n\t}\n\n\tprotected applyStashedOp(content: JsonCompatibleReadOnly): void {\n\t\tassert(\n\t\t\t!this.getLocalBranch().isTransacting(),\n\t\t\t0x674 /* Unexpected transaction is open while applying stashed ops */,\n\t\t);\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision, change },\n\t\t} = this.messageCodec.decode(content, { idCompressor: this.idCompressor });\n\t\tthis.editManager.localBranch.apply({ change, revision });\n\t}\n\n\tpublic override getGCData(fullGC?: boolean): IGarbageCollectionData {\n\t\tconst gcNodes: IGarbageCollectionData[\"gcNodes\"] = super.getGCData(fullGC).gcNodes;\n\t\tfor (const s of this.summarizables) {\n\t\t\tfor (const [id, routes] of Object.entries(s.getGCData(fullGC).gcNodes)) {\n\t\t\t\tgcNodes[id] ??= [];\n\t\t\t\tfor (const route of routes) {\n\t\t\t\t\t// Non null asserting here because we are creating an array at gcNodes[id] if it is undefined\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tgcNodes[id]!.push(route);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tgcNodes,\n\t\t};\n\t}\n}\n\nfunction isClonableSchemaPolicy(\n\tmaybeSchemaPolicy: unknown,\n): maybeSchemaPolicy is ClonableSchemaAndPolicy {\n\tconst schemaAndPolicy = maybeSchemaPolicy as ClonableSchemaAndPolicy;\n\treturn schemaAndPolicy.schema !== undefined && schemaAndPolicy.policy !== undefined;\n}\n\n/**\n * Specifies the behavior of a component that puts data in a summary.\n */\nexport interface Summarizable {\n\t/**\n\t * Field name in summary json under which this element stores its data.\n\t */\n\treadonly key: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.\n\t */\n\tgetAttachSummary(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.\n\t */\n\tsummarize(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).getGCData}\n\t */\n\t// TODO: Change this interface (and the one in ISharedObject, if necessary) to support \"handles within handles\".\n\t// Consider the case of a document with history; the return value here currently grows unboundedly.\n\tgetGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Allows the component to perform custom loading. The storage service is scoped to this component and therefore\n\t * paths in this component will not collide with those in other components, even if they are the same string.\n\t * @param service - Storage used by the component\n\t * @param parse - Parses serialized data from storage into runtime objects for the component\n\t */\n\tload(service: IChannelStorageService, parse: SummaryElementParser): Promise<void>;\n}\n\n/**\n * Serializes the given contents into a string acceptable for storing in summaries, i.e. all\n * Fluid handles have been replaced appropriately by an IFluidSerializer\n */\nexport type SummaryElementStringifier = (contents: unknown) => string;\n\n/**\n * Parses a serialized/summarized string into an object, rehydrating any Fluid handles as necessary\n */\nexport type SummaryElementParser = (contents: string) => unknown;\n\n/**\n * Compose an {@link IChannelStorageService} which prefixes all paths before forwarding them to the original service\n */\nfunction scopeStorageService(\n\tservice: IChannelStorageService,\n\t...pathElements: string[]\n): IChannelStorageService {\n\tconst scope = `${pathElements.join(\"/\")}/`;\n\n\treturn {\n\t\tasync readBlob(path: string): Promise<ArrayBufferLike> {\n\t\t\treturn service.readBlob(`${scope}${path}`);\n\t\t},\n\t\tasync contains(path) {\n\t\t\treturn service.contains(`${scope}${path}`);\n\t\t},\n\t\tasync list(path) {\n\t\t\treturn service.list(`${scope}${path}`);\n\t\t},\n\t};\n}\n"]}
@@ -11,13 +11,14 @@ import { type EncodeOptions } from "./customTree.js";
11
11
  * @remarks
12
12
  * This is "concise" meaning that explicit type information is omitted.
13
13
  * If the schema is compatible with {@link ITreeConfigurationOptions.preventAmbiguity},
14
- * types will be lossless and compatible with {@link TreeBeta.create} (unless the options are used to customize it).
14
+ * types will be lossless and compatible with {@link TreeAlpha.create} (unless the options are used to customize it).
15
15
  *
16
16
  * Every {@link TreeNode} is an array or object.
17
17
  * Any IFluidHandle values have been replaced by `THandle`.
18
18
  * @privateRemarks
19
19
  * This can store all possible simple trees,
20
20
  * but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.
21
+ * @alpha
21
22
  */
22
23
  export type ConciseTree<THandle = IFluidHandle> = Exclude<TreeLeafValue, IFluidHandle> | THandle | ConciseTree<THandle>[] | {
23
24
  [key: string]: ConciseTree<THandle>;
@@ -1 +1 @@
1
- {"version":3,"file":"conciseTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/conciseTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,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AO,EACxC,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE,oBAAoB,EAChC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,GAC7B,WAAW,CAAC,OAAO,CAAC,CAQtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"conciseTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/conciseTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,mDAA4E;AAC5E,0DAA2D;AAuB3D;;GAEG;AACH,SAAgB,iBAAiB,CAChC,MAAmB,EACnB,UAAgC,EAChC,OAA+B;IAE/B,MAAM,MAAM,GAAqC;QAChD,aAAa,EAAE,KAAK;QACpB,GAAG,OAAO;KACV,CAAC;IAEF,MAAM,SAAS,GAAG,IAAA,uCAAoB,EAAC,UAAU,CAAC,CAAC,MAAM,CAAC;IAC1D,OAAO,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC1D,CAAC;AAZD,8CAYC;AAED,SAAS,sBAAsB,CAC9B,MAAmB,EACnB,OAAyC,EACzC,MAA2C;IAE3C,OAAO,IAAA,qCAAqB,EAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\nimport type { ITreeCursor } from \"../../core/index.js\";\nimport type { TreeLeafValue, ImplicitAllowedTypes } from \"../schemaTypes.js\";\nimport type { TreeNodeSchema } from \"../core/index.js\";\nimport { customFromCursorInner, type EncodeOptions } from \"./customTree.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\n\n/**\n * Concise encoding of a {@link TreeNode} or {@link TreeLeafValue}.\n * @remarks\n * This is \"concise\" meaning that explicit type information is omitted.\n * If the schema is compatible with {@link ITreeConfigurationOptions.preventAmbiguity},\n * types will be lossless and compatible with {@link TreeBeta.create} (unless the options are used to customize it).\n *\n * Every {@link TreeNode} is an array or object.\n * Any IFluidHandle values have been replaced by `THandle`.\n * @privateRemarks\n * This can store all possible simple trees,\n * but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.\n */\nexport type ConciseTree<THandle = IFluidHandle> =\n\t| Exclude<TreeLeafValue, IFluidHandle>\n\t| THandle\n\t| ConciseTree<THandle>[]\n\t| {\n\t\t\t[key: string]: ConciseTree<THandle>;\n\t };\n\n/**\n * Used to read a node cursor as a ConciseTree.\n */\nexport function conciseFromCursor<TCustom>(\n\treader: ITreeCursor,\n\trootSchema: ImplicitAllowedTypes,\n\toptions: EncodeOptions<TCustom>,\n): ConciseTree<TCustom> {\n\tconst config: Required<EncodeOptions<TCustom>> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst schemaMap = getUnhydratedContext(rootSchema).schema;\n\treturn conciseFromCursorInner(reader, config, schemaMap);\n}\n\nfunction conciseFromCursorInner<TCustom>(\n\treader: ITreeCursor,\n\toptions: Required<EncodeOptions<TCustom>>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n): ConciseTree<TCustom> {\n\treturn customFromCursorInner(reader, options, schema, conciseFromCursorInner);\n}\n"]}
1
+ {"version":3,"file":"conciseTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/conciseTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,mDAA4E;AAC5E,0DAA2D;AAwB3D;;GAEG;AACH,SAAgB,iBAAiB,CAChC,MAAmB,EACnB,UAAgC,EAChC,OAA+B;IAE/B,MAAM,MAAM,GAAqC;QAChD,aAAa,EAAE,KAAK;QACpB,GAAG,OAAO;KACV,CAAC;IAEF,MAAM,SAAS,GAAG,IAAA,uCAAoB,EAAC,UAAU,CAAC,CAAC,MAAM,CAAC;IAC1D,OAAO,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC1D,CAAC;AAZD,8CAYC;AAED,SAAS,sBAAsB,CAC9B,MAAmB,EACnB,OAAyC,EACzC,MAA2C;IAE3C,OAAO,IAAA,qCAAqB,EAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\nimport type { ITreeCursor } from \"../../core/index.js\";\nimport type { TreeLeafValue, ImplicitAllowedTypes } from \"../schemaTypes.js\";\nimport type { TreeNodeSchema } from \"../core/index.js\";\nimport { customFromCursorInner, type EncodeOptions } from \"./customTree.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\n\n/**\n * Concise encoding of a {@link TreeNode} or {@link TreeLeafValue}.\n * @remarks\n * This is \"concise\" meaning that explicit type information is omitted.\n * If the schema is compatible with {@link ITreeConfigurationOptions.preventAmbiguity},\n * types will be lossless and compatible with {@link TreeAlpha.create} (unless the options are used to customize it).\n *\n * Every {@link TreeNode} is an array or object.\n * Any IFluidHandle values have been replaced by `THandle`.\n * @privateRemarks\n * This can store all possible simple trees,\n * but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.\n * @alpha\n */\nexport type ConciseTree<THandle = IFluidHandle> =\n\t| Exclude<TreeLeafValue, IFluidHandle>\n\t| THandle\n\t| ConciseTree<THandle>[]\n\t| {\n\t\t\t[key: string]: ConciseTree<THandle>;\n\t };\n\n/**\n * Used to read a node cursor as a ConciseTree.\n */\nexport function conciseFromCursor<TCustom>(\n\treader: ITreeCursor,\n\trootSchema: ImplicitAllowedTypes,\n\toptions: EncodeOptions<TCustom>,\n): ConciseTree<TCustom> {\n\tconst config: Required<EncodeOptions<TCustom>> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst schemaMap = getUnhydratedContext(rootSchema).schema;\n\treturn conciseFromCursorInner(reader, config, schemaMap);\n}\n\nfunction conciseFromCursorInner<TCustom>(\n\treader: ITreeCursor,\n\toptions: Required<EncodeOptions<TCustom>>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n): ConciseTree<TCustom> {\n\treturn customFromCursorInner(reader, options, schema, conciseFromCursorInner);\n}\n"]}
@@ -2,12 +2,10 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { IFluidHandle } from "@fluidframework/core-interfaces";
6
5
  import type { ITreeCursorSynchronous } from "../../core/index.js";
7
- import type { ImplicitFieldSchema, InsertableTreeFieldFromImplicitField, TreeFieldFromImplicitField, FieldSchema, FieldKind } from "../schemaTypes.js";
8
- import { type Unhydrated } from "../core/index.js";
6
+ import type { ImplicitFieldSchema, TreeFieldFromImplicitField, FieldSchema, FieldKind, UnsafeUnknownSchema, InsertableField, TreeLeafValue } from "../schemaTypes.js";
7
+ import { type TreeNode, type Unhydrated } from "../core/index.js";
9
8
  import { type NodeKeyManager } from "../../feature-libraries/index.js";
10
- import { type ParseOptions, type VerboseTreeNode } from "./verboseTree.js";
11
9
  /**
12
10
  * Construct tree content that is compatible with the field defined by the provided `schema`.
13
11
  * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
@@ -18,11 +16,9 @@ import { type ParseOptions, type VerboseTreeNode } from "./verboseTree.js";
18
16
  * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.
19
17
  *
20
18
  * Like with {@link TreeNodeSchemaClass}'s constructor, its an error to provide an existing node to this API.
21
- * TODO: For that case, use we should provide `Tree.clone`.
22
- * @privateRemarks
23
- * This could be exposed as a public `Tree.create` function.
19
+ * For that case, use {@link TreeBeta.clone}.
24
20
  */
25
- export declare function createFromInsertable<TSchema extends ImplicitFieldSchema>(schema: TSchema, data: InsertableTreeFieldFromImplicitField<TSchema>, context?: NodeKeyManager | undefined): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
21
+ export declare function createFromInsertable<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(schema: UnsafeUnknownSchema extends TSchema ? ImplicitFieldSchema : TSchema & ImplicitFieldSchema, data: InsertableField<TSchema>, context?: NodeKeyManager | undefined): Unhydrated<TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeNode | TreeLeafValue | undefined>;
26
22
  /**
27
23
  * Construct tree content that is compatible with the field defined by the provided `schema`.
28
24
  * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
@@ -32,23 +28,9 @@ export declare function createFromInsertable<TSchema extends ImplicitFieldSchema
32
28
  * this is the same as invoking its constructor except that an unhydrated node can also be provided and the returned value is a cursor.
33
29
  * When `undefined` is provided (for an optional field), `undefined` is returned.
34
30
  */
35
- export declare function cursorFromInsertable<TSchema extends ImplicitFieldSchema>(schema: TSchema, data: InsertableTreeFieldFromImplicitField<TSchema>, context?: NodeKeyManager | undefined): ITreeCursorSynchronous | (TSchema extends FieldSchema<FieldKind.Optional> ? undefined : never);
36
- /**
37
- * Construct tree content compatible with a field defined by the provided `schema`.
38
- * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
39
- * @param data - The data used to construct the field content. See `Tree.cloneToJSONVerbose`.
40
- * @privateRemarks
41
- * This could be exposed as a public `Tree.createFromVerbose` function.
42
- */
43
- export declare function createFromVerbose<TSchema extends ImplicitFieldSchema, THandle>(schema: TSchema, data: VerboseTreeNode<THandle> | undefined, options: ParseOptions<THandle>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
44
- /**
45
- * Construct tree content compatible with a field defined by the provided `schema`.
46
- * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
47
- * @param data - The data used to construct the field content. See `Tree.cloneToJSONVerbose`.
48
- */
49
- export declare function createFromVerbose<TSchema extends ImplicitFieldSchema>(schema: TSchema, data: VerboseTreeNode | undefined, options?: Partial<ParseOptions<IFluidHandle>>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
31
+ export declare function cursorFromInsertable<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(schema: UnsafeUnknownSchema extends TSchema ? ImplicitFieldSchema : TSchema & ImplicitFieldSchema, data: InsertableField<TSchema>, context?: NodeKeyManager | undefined): ITreeCursorSynchronous | (TSchema extends FieldSchema<FieldKind.Optional> ? undefined : never);
50
32
  /**
51
33
  * Creates an unhydrated simple-tree field from a cursor in nodes mode.
52
34
  */
53
- export declare function createFromCursor<TSchema extends ImplicitFieldSchema>(schema: TSchema, cursor: ITreeCursorSynchronous | undefined): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
35
+ export declare function createFromCursor<const TSchema extends ImplicitFieldSchema>(schema: TSchema, cursor: ITreeCursorSynchronous | undefined): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
54
36
  //# sourceMappingURL=create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,KAAK,EAAE,sBAAsB,EAAmB,MAAM,qBAAqB,CAAC;AACnF,OAAO,KAAK,EAEX,mBAAmB,EACnB,oCAAoC,EACpC,0BAA0B,EAC1B,WAAW,EACX,SAAS,EACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGN,KAAK,UAAU,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAKN,KAAK,cAAc,EACnB,MAAM,kCAAkC,CAAC;AAI1C,OAAO,EAGN,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,MAAM,kBAAkB,CAAC;AAG1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AM,EAAE,OAAO,EACf,MAAM,EAAE,sBAAsB,GAAG,SAAS,GACxC,UAAU,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,CA+BjD"}
@@ -4,14 +4,13 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createFromCursor = exports.createFromVerbose = exports.cursorFromInsertable = exports.createFromInsertable = void 0;
7
+ exports.createFromCursor = exports.cursorFromInsertable = exports.createFromInsertable = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../core/index.js");
10
10
  const index_js_2 = require("../../feature-libraries/index.js");
11
11
  const index_js_3 = require("../../feature-libraries/index.js");
12
- const toFlexSchema_js_1 = require("../toFlexSchema.js");
12
+ const toStoredSchema_js_1 = require("../toStoredSchema.js");
13
13
  const toMapTree_js_1 = require("../toMapTree.js");
14
- const verboseTree_js_1 = require("./verboseTree.js");
15
14
  const createContext_js_1 = require("../createContext.js");
16
15
  /**
17
16
  * Construct tree content that is compatible with the field defined by the provided `schema`.
@@ -23,9 +22,7 @@ const createContext_js_1 = require("../createContext.js");
23
22
  * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.
24
23
  *
25
24
  * Like with {@link TreeNodeSchemaClass}'s constructor, its an error to provide an existing node to this API.
26
- * TODO: For that case, use we should provide `Tree.clone`.
27
- * @privateRemarks
28
- * This could be exposed as a public `Tree.create` function.
25
+ * For that case, use {@link TreeBeta.clone}.
29
26
  */
30
27
  function createFromInsertable(schema, data, context) {
31
28
  const cursor = cursorFromInsertable(schema, data, context);
@@ -43,7 +40,7 @@ exports.createFromInsertable = createFromInsertable;
43
40
  * When `undefined` is provided (for an optional field), `undefined` is returned.
44
41
  */
45
42
  function cursorFromInsertable(schema, data, context) {
46
- const storedSchema = (0, toFlexSchema_js_1.toStoredSchema)(schema);
43
+ const storedSchema = (0, toStoredSchema_js_1.toStoredSchema)(schema);
47
44
  const schemaValidationPolicy = {
48
45
  policy: index_js_2.defaultSchemaPolicy,
49
46
  // TODO: optimize: This isn't the most efficient operation since its not cached, and has to convert all the schema.
@@ -57,18 +54,6 @@ function cursorFromInsertable(schema, data, context) {
57
54
  return (0, index_js_2.cursorForMapTreeNode)(mapTree);
58
55
  }
59
56
  exports.cursorFromInsertable = cursorFromInsertable;
60
- function createFromVerbose(schema, data, options) {
61
- const config = {
62
- valueConverter: (input) => {
63
- return input;
64
- },
65
- ...options,
66
- };
67
- const schemalessConfig = (0, verboseTree_js_1.applySchemaToParserOptions)(schema, config);
68
- const cursor = (0, verboseTree_js_1.cursorFromVerbose)(data, schemalessConfig);
69
- return createFromCursor(schema, cursor);
70
- }
71
- exports.createFromVerbose = createFromVerbose;
72
57
  /**
73
58
  * Creates an unhydrated simple-tree field from a cursor in nodes mode.
74
59
  */
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/simple-tree/api/create.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAW7D,+CAI0B;AAC1B,+DAM0C;AAC1C,+DAAmE;AACnE,wDAAoD;AACpD,kDAA+F;AAC/F,qDAM0B;AAC1B,0DAA2D;AAE3D;;;;;;;;;;;;;GAaG;AACH,SAAgB,oBAAoB,CACnC,MAAe,EACf,IAAmD,EACnD,OAAoC;IAEpC,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnF,OAAO,MAAyD,CAAC;AAClE,CAAC;AARD,oDAQC;AAED;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CACnC,MAAe,EACf,IAAmD,EACnD,OAAoC;IAIpC,MAAM,YAAY,GAAG,IAAA,gCAAc,EAAC,MAAM,CAAC,C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CAAC,MAAM,CAAC;IAE9C,MAAM,sBAAsB,GAAoB;QAC/C,MAAM,EAAE,8BAAmB;QAC3B,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,MAAM;KAClC,CAAC;IAEF,MAAM,UAAU,GAAG,IAAA,0BAAe,EACjC,QAAQ,EACR,UAAU,CAAC,eAAe,EAC1B,sBAAsB,CACtB,CAAC;IACF,IAAA,8BAAe,EAAC,UAAU,CAAC,CAAC;IAE5B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,SAA4D,CAAC;IACrE,CAAC;IACD,IAAA,iBAAM,EAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACnE,8JAA8J;IAC9J,oEAAoE;IACpE,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAE,CAAC;IAC7B,MAAM,WAAW,GAAG,iCAAsB,CAAC,WAAW,CACrD,IAAA,uCAAoB,EAAC,MAAM,CAAC,EAC5B,OAAO,CACP,CAAC;IAEF,MAAM,MAAM,GAAG,IAAA,uCAA4B,EAAC,WAAW,CAAC,CAAC;IACzD,OAAO,MAAyD,CAAC;AAClE,CAAC;AAlCD,4CAkCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ITreeCursorSynchronous, SchemaAndPolicy } from \"../../core/index.js\";\nimport type {\n\tTreeLeafValue,\n\tImplicitFieldSchema,\n\tInsertableTreeFieldFromImplicitField,\n\tTreeFieldFromImplicitField,\n\tFieldSchema,\n\tFieldKind,\n} from \"../schemaTypes.js\";\nimport {\n\tgetOrCreateNodeFromInnerNode,\n\tUnhydratedFlexTreeNode,\n\ttype Unhydrated,\n} from \"../core/index.js\";\nimport {\n\tcursorForMapTreeNode,\n\tdefaultSchemaPolicy,\n\tFieldKinds,\n\tmapTreeFromCursor,\n\ttype NodeKeyManager,\n} from \"../../feature-libraries/index.js\";\nimport { isFieldInSchema } from \"../../feature-libraries/index.js\";\nimport { toStoredSchema } from \"../toFlexSchema.js\";\nimport { inSchemaOrThrow, mapTreeFromNodeData, type InsertableContent } from \"../toMapTree.js\";\nimport {\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\ttype ParseOptions,\n\ttype VerboseTree,\n\ttype VerboseTreeNode,\n} from \"./verboseTree.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\n\n/**\n * Construct tree content that is compatible with the field defined by the provided `schema`.\n * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n * @param data - The data used to construct the field content.\n * @remarks\n * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n * This function exists as a generalization that can be used in other cases as well,\n * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n *\n * Like with {@link TreeNodeSchemaClass}'s constructor, its an error to provide an existing node to this API.\n * TODO: For that case, use we should provide `Tree.clone`.\n * @privateRemarks\n * This could be exposed as a public `Tree.create` function.\n */\nexport function createFromInsertable<TSchema extends ImplicitFieldSchema>(\n\tschema: TSchema,\n\tdata: InsertableTreeFieldFromImplicitField<TSchema>,\n\tcontext?: NodeKeyManager | undefined,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\tconst cursor = cursorFromInsertable(schema, data, context);\n\tconst result = cursor === undefined ? undefined : createFromCursor(schema, cursor);\n\treturn result as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n}\n\n/**\n * Construct tree content that is compatible with the field defined by the provided `schema`.\n * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n * @param data - The data used to construct the field content.\n * @remarks\n * When providing a {@link TreeNodeSchemaClass},\n * this is the same as invoking its constructor except that an unhydrated node can also be provided and the returned value is a cursor.\n * When `undefined` is provided (for an optional field), `undefined` is returned.\n */\nexport function cursorFromInsertable<TSchema extends ImplicitFieldSchema>(\n\tschema: TSchema,\n\tdata: InsertableTreeFieldFromImplicitField<TSchema>,\n\tcontext?: NodeKeyManager | undefined,\n):\n\t| ITreeCursorSynchronous\n\t| (TSchema extends FieldSchema<FieldKind.Optional> ? undefined : never) {\n\tconst storedSchema = toStoredSchema(schema);\n\tconst schemaValidationPolicy: SchemaAndPolicy = {\n\t\tpolicy: defaultSchemaPolicy,\n\t\t// TODO: optimize: This isn't the most efficient operation since its not cached, and has to convert all the schema.\n\t\tschema: storedSchema,\n\t};\n\n\tconst mapTree = mapTreeFromNodeData(\n\t\tdata as InsertableContent | undefined,\n\t\tschema,\n\t\tcontext,\n\t\tschemaValidationPolicy,\n\t);\n\tif (mapTree === undefined) {\n\t\tassert(\n\t\t\tstoredSchema.rootFieldSchema.kind === FieldKinds.optional.identifier,\n\t\t\t0xa10 /* missing non-optional field */,\n\t\t);\n\t\treturn undefined as TSchema extends FieldSchema<FieldKind.Optional> ? undefined : never;\n\t}\n\treturn cursorForMapTreeNode(mapTree);\n}\n\n/**\n * Construct tree content compatible with a field defined by the provided `schema`.\n * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n * @param data - The data used to construct the field content. See `Tree.cloneToJSONVerbose`.\n * @privateRemarks\n * This could be exposed as a public `Tree.createFromVerbose` function.\n */\nexport function createFromVerbose<TSchema extends ImplicitFieldSchema, THandle>(\n\tschema: TSchema,\n\tdata: VerboseTreeNode<THandle> | undefined,\n\toptions: ParseOptions<THandle>,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n/**\n * Construct tree content compatible with a field defined by the provided `schema`.\n * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n * @param data - The data used to construct the field content. See `Tree.cloneToJSONVerbose`.\n */\nexport function createFromVerbose<TSchema extends ImplicitFieldSchema>(\n\tschema: TSchema,\n\tdata: VerboseTreeNode | undefined,\n\toptions?: Partial<ParseOptions<IFluidHandle>>,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\nexport function createFromVerbose<TSchema extends ImplicitFieldSchema, THandle>(\n\tschema: TSchema,\n\tdata: VerboseTreeNode<THandle> | undefined,\n\toptions?: Partial<ParseOptions<THandle>>,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\tconst config: ParseOptions<THandle> = {\n\t\tvalueConverter: (input: VerboseTree<THandle>) => {\n\t\t\treturn input as TreeLeafValue | VerboseTreeNode<THandle>;\n\t\t},\n\t\t...options,\n\t};\n\tconst schemalessConfig = applySchemaToParserOptions(schema, config);\n\tconst cursor = cursorFromVerbose(data, schemalessConfig);\n\treturn createFromCursor(schema, cursor);\n}\n\n/**\n * Creates an unhydrated simple-tree field from a cursor in nodes mode.\n */\nexport function createFromCursor<TSchema extends ImplicitFieldSchema>(\n\tschema: TSchema,\n\tcursor: ITreeCursorSynchronous | undefined,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\tconst mapTrees = cursor === undefined ? [] : [mapTreeFromCursor(cursor)];\n\tconst context = getUnhydratedContext(schema);\n\tconst flexSchema = context.flexContext.schema;\n\n\tconst schemaValidationPolicy: SchemaAndPolicy = {\n\t\tpolicy: defaultSchemaPolicy,\n\t\tschema: context.flexContext.schema,\n\t};\n\n\tconst maybeError = isFieldInSchema(\n\t\tmapTrees,\n\t\tflexSchema.rootFieldSchema,\n\t\tschemaValidationPolicy,\n\t);\n\tinSchemaOrThrow(maybeError);\n\n\tif (mapTrees.length === 0) {\n\t\treturn undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t}\n\tassert(mapTrees.length === 1, 0xa11 /* unexpected field length */);\n\t// Length asserted above, so this is safe. This assert is done instead of checking for undefined after indexing to ensure a length greater than 1 also errors.\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst mapTree = mapTrees[0]!;\n\tconst mapTreeNode = UnhydratedFlexTreeNode.getOrCreate(\n\t\tgetUnhydratedContext(schema),\n\t\tmapTree,\n\t);\n\n\tconst result = getOrCreateNodeFromInnerNode(mapTreeNode);\n\treturn result as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n}\n"]}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/simple-tree/api/create.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAY7D,+CAK0B;AAC1B,+DAM0C;AAC1C,+DAAmE;AACnE,4DAAsD;AACtD,kDAAuE;AACvE,0DAA2D;AAE3D;;;;;;;;;;;GAWG;AACH,SAAgB,oBAAoB,CAGnC,MAEgC,EAChC,IAA8B,EAC9B,OAAoC;IAMpC,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnF,OAAO,MAIN,CAAC;AACH,CAAC;AApBD,oDAoBC;AAED;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAGnC,MAEgC,EAChC,IAA8B,EAC9B,OAAoC;IAIpC,MAAM,YAAY,GAAG,IAAA,kCAAc,EAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,sBAAsB,GAAoB;QAC/C,MAAM,EAAE,8BAAmB;QAC3B,mHAAmH;QACnH,MAAM,EAAE,YAAY;KACpB,CAAC;IAEF,MAAM,OAAO,GAAG,IAAA,kCAAmB,EAClC,IAA4C,EAC5C,MAAM,EACN,OAAO,EACP,sBAAsB,CACtB,CAAC;IACF,IAAI,OAAO,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IAEF,MAAM,MAAM,GAAG,IAAA,uCAA4B,EAAC,WAAW,CAAC,CAAC;IACzD,OAAO,MAAyD,CAAC;AAClE,CAAC;AAlCD,4CAkCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ITreeCursorSynchronous, SchemaAndPolicy } from \"../../core/index.js\";\nimport type {\n\tImplicitFieldSchema,\n\tTreeFieldFromImplicitField,\n\tFieldSchema,\n\tFieldKind,\n\tUnsafeUnknownSchema,\n\tInsertableField,\n\tTreeLeafValue,\n} from \"../schemaTypes.js\";\nimport {\n\tgetOrCreateNodeFromInnerNode,\n\tUnhydratedFlexTreeNode,\n\ttype TreeNode,\n\ttype Unhydrated,\n} from \"../core/index.js\";\nimport {\n\tcursorForMapTreeNode,\n\tdefaultSchemaPolicy,\n\tFieldKinds,\n\tmapTreeFromCursor,\n\ttype NodeKeyManager,\n} from \"../../feature-libraries/index.js\";\nimport { isFieldInSchema } from \"../../feature-libraries/index.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\nimport { inSchemaOrThrow, mapTreeFromNodeData } from \"../toMapTree.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\n\n/**\n * Construct tree content that is compatible with the field defined by the provided `schema`.\n * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n * @param data - The data used to construct the field content.\n * @remarks\n * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n * This function exists as a generalization that can be used in other cases as well,\n * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n *\n * Like with {@link TreeNodeSchemaClass}'s constructor, its an error to provide an existing node to this API.\n * For that case, use {@link TreeBeta.clone}.\n */\nexport function createFromInsertable<\n\tconst TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,\n>(\n\tschema: UnsafeUnknownSchema extends TSchema\n\t\t? ImplicitFieldSchema\n\t\t: TSchema & ImplicitFieldSchema,\n\tdata: InsertableField<TSchema>,\n\tcontext?: NodeKeyManager | undefined,\n): Unhydrated<\n\tTSchema extends ImplicitFieldSchema\n\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t: TreeNode | TreeLeafValue | undefined\n> {\n\tconst cursor = cursorFromInsertable(schema, data, context);\n\tconst result = cursor === undefined ? undefined : createFromCursor(schema, cursor);\n\treturn result as Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n}\n\n/**\n * Construct tree content that is compatible with the field defined by the provided `schema`.\n * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n * @param data - The data used to construct the field content.\n * @remarks\n * When providing a {@link TreeNodeSchemaClass},\n * this is the same as invoking its constructor except that an unhydrated node can also be provided and the returned value is a cursor.\n * When `undefined` is provided (for an optional field), `undefined` is returned.\n */\nexport function cursorFromInsertable<\n\tTSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,\n>(\n\tschema: UnsafeUnknownSchema extends TSchema\n\t\t? ImplicitFieldSchema\n\t\t: TSchema & ImplicitFieldSchema,\n\tdata: InsertableField<TSchema>,\n\tcontext?: NodeKeyManager | undefined,\n):\n\t| ITreeCursorSynchronous\n\t| (TSchema extends FieldSchema<FieldKind.Optional> ? undefined : never) {\n\tconst storedSchema = toStoredSchema(schema);\n\tconst schemaValidationPolicy: SchemaAndPolicy = {\n\t\tpolicy: defaultSchemaPolicy,\n\t\t// TODO: optimize: This isn't the most efficient operation since its not cached, and has to convert all the schema.\n\t\tschema: storedSchema,\n\t};\n\n\tconst mapTree = mapTreeFromNodeData(\n\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\tschema,\n\t\tcontext,\n\t\tschemaValidationPolicy,\n\t);\n\tif (mapTree === undefined) {\n\t\tassert(\n\t\t\tstoredSchema.rootFieldSchema.kind === FieldKinds.optional.identifier,\n\t\t\t0xa10 /* missing non-optional field */,\n\t\t);\n\t\treturn undefined as TSchema extends FieldSchema<FieldKind.Optional> ? undefined : never;\n\t}\n\treturn cursorForMapTreeNode(mapTree);\n}\n\n/**\n * Creates an unhydrated simple-tree field from a cursor in nodes mode.\n */\nexport function createFromCursor<const TSchema extends ImplicitFieldSchema>(\n\tschema: TSchema,\n\tcursor: ITreeCursorSynchronous | undefined,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\tconst mapTrees = cursor === undefined ? [] : [mapTreeFromCursor(cursor)];\n\tconst context = getUnhydratedContext(schema);\n\tconst flexSchema = context.flexContext.schema;\n\n\tconst schemaValidationPolicy: SchemaAndPolicy = {\n\t\tpolicy: defaultSchemaPolicy,\n\t\tschema: context.flexContext.schema,\n\t};\n\n\tconst maybeError = isFieldInSchema(\n\t\tmapTrees,\n\t\tflexSchema.rootFieldSchema,\n\t\tschemaValidationPolicy,\n\t);\n\tinSchemaOrThrow(maybeError);\n\n\tif (mapTrees.length === 0) {\n\t\treturn undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t}\n\tassert(mapTrees.length === 1, 0xa11 /* unexpected field length */);\n\t// Length asserted above, so this is safe. This assert is done instead of checking for undefined after indexing to ensure a length greater than 1 also errors.\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst mapTree = mapTrees[0]!;\n\tconst mapTreeNode = UnhydratedFlexTreeNode.getOrCreate(\n\t\tgetUnhydratedContext(schema),\n\t\tmapTree,\n\t);\n\n\tconst result = getOrCreateNodeFromInnerNode(mapTreeNode);\n\treturn result as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n}\n"]}
@@ -8,6 +8,7 @@ import type { TreeLeafValue } from "../schemaTypes.js";
8
8
  import { type TreeNodeSchema } from "../core/index.js";
9
9
  /**
10
10
  * Options for how to encode a tree.
11
+ * @alpha
11
12
  */
12
13
  export interface EncodeOptions<TCustom> {
13
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"customTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAIpE,OAAO,EAKN,KAAK,WAAW,EAChB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAUjE;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,OAAO;IACrC;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,MAAM,EAAE,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AAE5F;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,IAAI,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC;AAEtF;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,MAAM,IAAI,MAAM,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAE1E;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,EACpD,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,EACzC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,EAC3C,YAAY,EAAE,CACb,MAAM,EAAE,WAAW,EACnB,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MAAM,EAAE,cAAc,CAAC,EAC3C,YAAY,EAAE,CACb,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,EACzC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,KACvC,MAAM,GACT,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CA6C7B"}
@@ -43,8 +43,8 @@ function customFromCursorInner(reader, options, schema, childHandler) {
43
43
  if (children.length === 1) {
44
44
  const storedKey = reader.getFieldKey();
45
45
  const key = (0, objectNodeTypes_js_1.isObjectNodeSchema)(nodeSchema) && !options.useStoredKeys
46
- ? nodeSchema.storedKeyToPropertyKey.get(storedKey) ??
47
- (0, index_js_2.fail)("missing property key")
46
+ ? (nodeSchema.storedKeyToPropertyKey.get(storedKey) ??
47
+ (0, index_js_2.fail)("missing property key"))
48
48
  : storedKey;
49
49
  // Length is checked above.
50
50
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -1 +1 @@
1
- {"version":3,"file":"customTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qEAAuE;AACvE,kEAA6D;AAE7D,kDAM6B;AAC7B,kDAA2C;AAE3C,+CAAiE;AACjE,4DAM8B;AAC9B,8DAA2D;AAmC3D;;GAEG;AACH,SAAgB,qBAAqB,CACpC,MAAmB,EACnB,OAAyC,EACzC,MAA2C,EAC3C,YAIW;IAEX,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,mCAAmC,CAAC,CAAC;IAEjF,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,gCAAY,CAAC,UAAU,CAAC;QAC7B,KAAK,iCAAa,CAAC,UAAU,CAAC;QAC9B,KAAK,8BAAU,CAAC,UAAU,CAAC;QAC3B,K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C,CAAC;oBACrF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;wBAC3B,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;wBACvC,MAAM,GAAG,GACR,IAAA,uCAAkB,EAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa;4BACvD,CAAC,CAAC,UAAU,CAAC,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC;gCACjD,IAAA,eAAI,EAAC,sBAAsB,CAAC;4BAC7B,CAAC,CAAC,SAAS,CAAC;wBACd,2BAA2B;wBAC3B,oEAAoE;wBACpE,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAE,CAAC;oBAC5B,CAAC;yBAAM,CAAC;wBACP,IAAA,iBAAM,EAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;oBACpE,CAAC;gBACF,CAAC,CAAC,CAAC;gBACH,OAAO,MAAM,CAAC;YACf,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAtDD,sDAsDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachField,\n\tinCursorField,\n\tmapCursorField,\n\ttype ITreeCursor,\n} from \"../../core/index.js\";\nimport { fail } from \"../../util/index.js\";\nimport type { TreeLeafValue } from \"../schemaTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../objectNodeTypes.js\";\n\n/**\n * Options for how to encode a tree.\n */\nexport interface EncodeOptions<TCustom> {\n\t/**\n\t * How to encode any {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the tree.\n\t * @remarks\n\t * See note on {@link ParseOptions.valueConverter}.\n\t */\n\tvalueConverter(data: IFluidHandle): TCustom;\n\t/**\n\t * If true, interpret the input keys of object nodes as stored keys.\n\t * If false, interpret them as property keys.\n\t * @defaultValue false.\n\t */\n\treadonly useStoredKeys?: boolean;\n}\n\n/**\n * Tree representation with fields as properties and customized handle and child representations.\n */\nexport type CustomTree<TChild, THandle> = CustomTreeNode<TChild> | CustomTreeValue<THandle>;\n\n/**\n * TreeLeafValue except the handle type is customized.\n */\nexport type CustomTreeValue<THandle> = Exclude<TreeLeafValue, IFluidHandle> | THandle;\n\n/**\n * Tree node representation with fields as properties and customized child representation.\n */\nexport type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n */\nexport function customFromCursorInner<TChild, THandle>(\n\treader: ITreeCursor,\n\toptions: Required<EncodeOptions<THandle>>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\toptions: Required<EncodeOptions<THandle>>,\n\t\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\t) => TChild,\n): CustomTree<TChild, THandle> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(\"missing schema for type in cursor\");\n\n\tswitch (type) {\n\t\tcase numberSchema.identifier:\n\t\tcase booleanSchema.identifier:\n\t\tcase nullSchema.identifier:\n\t\tcase stringSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa50 /* out of schema: missing value */);\n\t\t\tassert(!isFluidHandle(reader.value), 0xa51 /* out of schema: unexpected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tcase handleSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa52 /* out of schema: missing value */);\n\t\t\tassert(isFluidHandle(reader.value), 0xa53 /* out of schema: expected FluidHandle */);\n\t\t\treturn options.valueConverter(reader.value);\n\t\tdefault: {\n\t\t\tassert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);\n\t\t\tif (nodeSchema.kind === NodeKind.Array) {\n\t\t\t\tconst fields = inCursorField(reader, EmptyKey, () =>\n\t\t\t\t\tmapCursorField(reader, () => childHandler(reader, options, schema)),\n\t\t\t\t);\n\t\t\t\treturn fields;\n\t\t\t} else {\n\t\t\t\tconst fields: Record<string, TChild> = {};\n\t\t\t\tforEachField(reader, () => {\n\t\t\t\t\tconst children = mapCursorField(reader, () => childHandler(reader, options, schema));\n\t\t\t\t\tif (children.length === 1) {\n\t\t\t\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\tisObjectNodeSchema(nodeSchema) && !options.useStoredKeys\n\t\t\t\t\t\t\t\t? nodeSchema.storedKeyToPropertyKey.get(storedKey) ??\n\t\t\t\t\t\t\t\t\tfail(\"missing property key\")\n\t\t\t\t\t\t\t\t: storedKey;\n\t\t\t\t\t\t// Length is checked above.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tfields[key] = children[0]!;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassert(children.length === 0, 0xa19 /* invalid children number */);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn fields;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"customTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qEAAuE;AACvE,kEAA6D;AAE7D,kDAM6B;AAC7B,kDAA2C;AAE3C,+CAAiE;AACjE,4DAM8B;AAC9B,8DAA2D;AAoC3D;;GAEG;AACH,SAAgB,qBAAqB,CACpC,MAAmB,EACnB,OAAyC,EACzC,MAA2C,EAC3C,YAIW;IAEX,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,C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BACF,OAAO,MAAM,CAAC;YACf,CAAC;iBAAM,CAAC;gBACP,MAAM,MAAM,GAA2B,EAAE,CAAC;gBAC1C,IAAA,uBAAY,EAAC,MAAM,EAAE,GAAG,EAAE;oBACzB,MAAM,QAAQ,GAAG,IAAA,yBAAc,EAAC,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;oBACrF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;wBAC3B,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;wBACvC,MAAM,GAAG,GACR,IAAA,uCAAkB,EAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa;4BACvD,CAAC,CAAC,CAAC,UAAU,CAAC,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC;gCAClD,IAAA,eAAI,EAAC,sBAAsB,CAAC,CAAC;4BAC9B,CAAC,CAAC,SAAS,CAAC;wBACd,2BAA2B;wBAC3B,oEAAoE;wBACpE,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAE,CAAC;oBAC5B,CAAC;yBAAM,CAAC;wBACP,IAAA,iBAAM,EAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;oBACpE,CAAC;gBACF,CAAC,CAAC,CAAC;gBACH,OAAO,MAAM,CAAC;YACf,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAtDD,sDAsDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachField,\n\tinCursorField,\n\tmapCursorField,\n\ttype ITreeCursor,\n} from \"../../core/index.js\";\nimport { fail } from \"../../util/index.js\";\nimport type { TreeLeafValue } from \"../schemaTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../objectNodeTypes.js\";\n\n/**\n * Options for how to encode a tree.\n * @alpha\n */\nexport interface EncodeOptions<TCustom> {\n\t/**\n\t * How to encode any {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the tree.\n\t * @remarks\n\t * See note on {@link ParseOptions.valueConverter}.\n\t */\n\tvalueConverter(data: IFluidHandle): TCustom;\n\t/**\n\t * If true, interpret the input keys of object nodes as stored keys.\n\t * If false, interpret them as property keys.\n\t * @defaultValue false.\n\t */\n\treadonly useStoredKeys?: boolean;\n}\n\n/**\n * Tree representation with fields as properties and customized handle and child representations.\n */\nexport type CustomTree<TChild, THandle> = CustomTreeNode<TChild> | CustomTreeValue<THandle>;\n\n/**\n * TreeLeafValue except the handle type is customized.\n */\nexport type CustomTreeValue<THandle> = Exclude<TreeLeafValue, IFluidHandle> | THandle;\n\n/**\n * Tree node representation with fields as properties and customized child representation.\n */\nexport type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n */\nexport function customFromCursorInner<TChild, THandle>(\n\treader: ITreeCursor,\n\toptions: Required<EncodeOptions<THandle>>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\toptions: Required<EncodeOptions<THandle>>,\n\t\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\t) => TChild,\n): CustomTree<TChild, THandle> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(\"missing schema for type in cursor\");\n\n\tswitch (type) {\n\t\tcase numberSchema.identifier:\n\t\tcase booleanSchema.identifier:\n\t\tcase nullSchema.identifier:\n\t\tcase stringSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa50 /* out of schema: missing value */);\n\t\t\tassert(!isFluidHandle(reader.value), 0xa51 /* out of schema: unexpected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tcase handleSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa52 /* out of schema: missing value */);\n\t\t\tassert(isFluidHandle(reader.value), 0xa53 /* out of schema: expected FluidHandle */);\n\t\t\treturn options.valueConverter(reader.value);\n\t\tdefault: {\n\t\t\tassert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);\n\t\t\tif (nodeSchema.kind === NodeKind.Array) {\n\t\t\t\tconst fields = inCursorField(reader, EmptyKey, () =>\n\t\t\t\t\tmapCursorField(reader, () => childHandler(reader, options, schema)),\n\t\t\t\t);\n\t\t\t\treturn fields;\n\t\t\t} else {\n\t\t\t\tconst fields: Record<string, TChild> = {};\n\t\t\t\tforEachField(reader, () => {\n\t\t\t\t\tconst children = mapCursorField(reader, () => childHandler(reader, options, schema));\n\t\t\t\t\tif (children.length === 1) {\n\t\t\t\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\tisObjectNodeSchema(nodeSchema) && !options.useStoredKeys\n\t\t\t\t\t\t\t\t? (nodeSchema.storedKeyToPropertyKey.get(storedKey) ??\n\t\t\t\t\t\t\t\t\tfail(\"missing property key\"))\n\t\t\t\t\t\t\t\t: storedKey;\n\t\t\t\t\t\t// Length is checked above.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tfields[key] = children[0]!;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassert(children.length === 0, 0xa19 /* invalid children number */);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn fields;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -2,21 +2,21 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { type ITree, type TreeView, type ViewableTree, type TreeViewEvents, TreeViewConfiguration, type ITreeViewConfiguration, type SchemaCompatibilityStatus, type ITreeConfigurationOptions, } from "./tree.js";
5
+ export { type ITree, type TreeView, type ViewableTree, type TreeViewEvents, TreeViewConfiguration, type ITreeViewConfiguration, type SchemaCompatibilityStatus, type ITreeConfigurationOptions, type TreeViewAlpha, type TreeBranch, type TreeBranchEvents, asTreeViewAlpha, } from "./tree.js";
6
6
  export { SchemaFactory, type ScopedSchemaName } from "./schemaFactory.js";
7
7
  export type { ValidateRecursiveSchema, FixRecursiveArraySchema, } from "./schemaFactoryRecursive.js";
8
- export { adaptEnum, enumFromStrings, singletonSchema, typedObjectValues, } from "./schemaCreationUtilities.js";
9
- export { treeNodeApi, type TreeNodeApi } from "./treeNodeApi.js";
10
- export { createFromInsertable, cursorFromInsertable } from "./create.js";
8
+ export { adaptEnum, enumFromStrings, singletonSchema, } from "./schemaCreationUtilities.js";
9
+ export { treeNodeApi, type TreeNodeApi, tryGetSchema } from "./treeNodeApi.js";
10
+ export { createFromInsertable, cursorFromInsertable, createFromCursor } from "./create.js";
11
11
  export type { SimpleTreeSchema } from "./simpleSchema.js";
12
12
  export { type JsonSchemaId, type JsonSchemaType, type JsonObjectNodeSchema, type JsonArrayNodeSchema, type JsonMapNodeSchema, type JsonLeafNodeSchema, type JsonSchemaRef, type JsonRefPath, type JsonNodeSchema, type JsonNodeSchemaBase, type JsonTreeSchema, type JsonFieldSchema, type JsonLeafSchemaType, } from "./jsonSchema.js";
13
13
  export { getJsonSchema } from "./getJsonSchema.js";
14
14
  export { getSimpleSchema } from "./getSimpleSchema.js";
15
15
  export { ViewSchema } from "./view.js";
16
- export type { Unenforced, FieldHasDefaultUnsafe, ObjectFromSchemaRecordUnsafe, TreeObjectNodeUnsafe, TreeFieldFromImplicitFieldUnsafe, TreeNodeFromImplicitAllowedTypesUnsafe, FieldSchemaUnsafe, InsertableTreeNodeFromImplicitAllowedTypesUnsafe, TreeArrayNodeUnsafe, TreeMapNodeUnsafe, InsertableObjectFromSchemaRecordUnsafe, InsertableTreeFieldFromImplicitFieldUnsafe, InsertableTypedNodeUnsafe, NodeBuilderDataUnsafe, NodeFromSchemaUnsafe, ReadonlyMapInlined, } from "./typesUnsafe.js";
17
- export type { VerboseTreeNode, ParseOptions, VerboseTree, } from "./verboseTree.js";
16
+ export type { Unenforced, FieldHasDefaultUnsafe, ObjectFromSchemaRecordUnsafe, TreeObjectNodeUnsafe, TreeFieldFromImplicitFieldUnsafe, TreeNodeFromImplicitAllowedTypesUnsafe, FieldSchemaUnsafe, InsertableTreeNodeFromImplicitAllowedTypesUnsafe, TreeArrayNodeUnsafe, TreeMapNodeUnsafe, InsertableObjectFromSchemaRecordUnsafe, InsertableTreeFieldFromImplicitFieldUnsafe, InsertableTypedNodeUnsafe, NodeBuilderDataUnsafe, NodeFromSchemaUnsafe, ReadonlyMapInlined, TreeNodeSchemaClassUnsafe, TreeNodeSchemaUnsafe, AllowedTypesUnsafe, TreeNodeSchemaNonClassUnsafe, InsertableTreeNodeFromAllowedTypesUnsafe, } from "./typesUnsafe.js";
17
+ export { type VerboseTreeNode, type ParseOptions, type VerboseTree, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, } from "./verboseTree.js";
18
18
  export type { EncodeOptions } from "./customTree.js";
19
- export type { ConciseTree } from "./conciseTree.js";
19
+ export { type ConciseTree, conciseFromCursor } from "./conciseTree.js";
20
20
  export { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from "./treeApiBeta.js";
21
21
  export { extractPersistedSchema, comparePersistedSchemaInternal, comparePersistedSchema, } from "./storedSchema.js";
22
22
  export { RecursiveObject as test_RecursiveObject, base as test_RecursiveObject_base, RecursiveObjectPojoMode as test_RecursiveObjectPojoMode, } from "./testRecursiveDomain.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/simple-tree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,CAAC;AAE7F,OAAO,EACN,sBAAsB,EACtB,8BAA8B,EAC9B,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACN,eAAe,IAAI,oBAAoB,EACvC,IAAI,IAAI,yBAAyB,EACjC,uBAAuB,IAAI,4BAA4B,GACvD,MAAM,0BAA0B,CAAC"}
@@ -4,27 +4,35 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.test_RecursiveObjectPojoMode = exports.test_RecursiveObject_base = exports.test_RecursiveObject = exports.comparePersistedSchema = exports.comparePersistedSchemaInternal = exports.extractPersistedSchema = exports.TreeBeta = exports.ViewSchema = exports.getSimpleSchema = exports.getJsonSchema = exports.cursorFromInsertable = exports.createFromInsertable = exports.treeNodeApi = exports.typedObjectValues = exports.singletonSchema = exports.enumFromStrings = exports.adaptEnum = exports.SchemaFactory = exports.TreeViewConfiguration = void 0;
7
+ exports.test_RecursiveObjectPojoMode = exports.test_RecursiveObject_base = exports.test_RecursiveObject = exports.comparePersistedSchema = exports.comparePersistedSchemaInternal = exports.extractPersistedSchema = exports.TreeBeta = exports.conciseFromCursor = exports.verboseFromCursor = exports.cursorFromVerbose = exports.applySchemaToParserOptions = exports.ViewSchema = exports.getSimpleSchema = exports.getJsonSchema = exports.createFromCursor = exports.cursorFromInsertable = exports.createFromInsertable = exports.tryGetSchema = exports.treeNodeApi = exports.singletonSchema = exports.enumFromStrings = exports.adaptEnum = exports.SchemaFactory = exports.asTreeViewAlpha = exports.TreeViewConfiguration = void 0;
8
8
  var tree_js_1 = require("./tree.js");
9
9
  Object.defineProperty(exports, "TreeViewConfiguration", { enumerable: true, get: function () { return tree_js_1.TreeViewConfiguration; } });
10
+ Object.defineProperty(exports, "asTreeViewAlpha", { enumerable: true, get: function () { return tree_js_1.asTreeViewAlpha; } });
10
11
  var schemaFactory_js_1 = require("./schemaFactory.js");
11
12
  Object.defineProperty(exports, "SchemaFactory", { enumerable: true, get: function () { return schemaFactory_js_1.SchemaFactory; } });
12
13
  var schemaCreationUtilities_js_1 = require("./schemaCreationUtilities.js");
13
14
  Object.defineProperty(exports, "adaptEnum", { enumerable: true, get: function () { return schemaCreationUtilities_js_1.adaptEnum; } });
14
15
  Object.defineProperty(exports, "enumFromStrings", { enumerable: true, get: function () { return schemaCreationUtilities_js_1.enumFromStrings; } });
15
16
  Object.defineProperty(exports, "singletonSchema", { enumerable: true, get: function () { return schemaCreationUtilities_js_1.singletonSchema; } });
16
- Object.defineProperty(exports, "typedObjectValues", { enumerable: true, get: function () { return schemaCreationUtilities_js_1.typedObjectValues; } });
17
17
  var treeNodeApi_js_1 = require("./treeNodeApi.js");
18
18
  Object.defineProperty(exports, "treeNodeApi", { enumerable: true, get: function () { return treeNodeApi_js_1.treeNodeApi; } });
19
+ Object.defineProperty(exports, "tryGetSchema", { enumerable: true, get: function () { return treeNodeApi_js_1.tryGetSchema; } });
19
20
  var create_js_1 = require("./create.js");
20
21
  Object.defineProperty(exports, "createFromInsertable", { enumerable: true, get: function () { return create_js_1.createFromInsertable; } });
21
22
  Object.defineProperty(exports, "cursorFromInsertable", { enumerable: true, get: function () { return create_js_1.cursorFromInsertable; } });
23
+ Object.defineProperty(exports, "createFromCursor", { enumerable: true, get: function () { return create_js_1.createFromCursor; } });
22
24
  var getJsonSchema_js_1 = require("./getJsonSchema.js");
23
25
  Object.defineProperty(exports, "getJsonSchema", { enumerable: true, get: function () { return getJsonSchema_js_1.getJsonSchema; } });
24
26
  var getSimpleSchema_js_1 = require("./getSimpleSchema.js");
25
27
  Object.defineProperty(exports, "getSimpleSchema", { enumerable: true, get: function () { return getSimpleSchema_js_1.getSimpleSchema; } });
26
28
  var view_js_1 = require("./view.js");
27
29
  Object.defineProperty(exports, "ViewSchema", { enumerable: true, get: function () { return view_js_1.ViewSchema; } });
30
+ var verboseTree_js_1 = require("./verboseTree.js");
31
+ Object.defineProperty(exports, "applySchemaToParserOptions", { enumerable: true, get: function () { return verboseTree_js_1.applySchemaToParserOptions; } });
32
+ Object.defineProperty(exports, "cursorFromVerbose", { enumerable: true, get: function () { return verboseTree_js_1.cursorFromVerbose; } });
33
+ Object.defineProperty(exports, "verboseFromCursor", { enumerable: true, get: function () { return verboseTree_js_1.verboseFromCursor; } });
34
+ var conciseTree_js_1 = require("./conciseTree.js");
35
+ Object.defineProperty(exports, "conciseFromCursor", { enumerable: true, get: function () { return conciseTree_js_1.conciseFromCursor; } });
28
36
  var treeApiBeta_js_1 = require("./treeApiBeta.js");
29
37
  Object.defineProperty(exports, "TreeBeta", { enumerable: true, get: function () { return treeApiBeta_js_1.TreeBeta; } });
30
38
  var storedSchema_js_1 = require("./storedSchema.js");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/api/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCASmB;AAJlB,gHAAA,qBAAqB,OAAA;AAKtB,uDAA0E;AAAjE,iHAAA,aAAa,OAAA;AAKtB,2EAKsC;AAJrC,uHAAA,SAAS,OAAA;AACT,6HAAA,eAAe,OAAA;AACf,6HAAA,eAAe,OAAA;AACf,+HAAA,iBAAiB,OAAA;AAElB,mDAAiE;AAAxD,6GAAA,WAAW,OAAA;AACpB,yCAAyE;AAAhE,iHAAA,oBAAoB,OAAA;AAAE,iHAAA,oBAAoB,OAAA;AAiBnD,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,2DAAuD;AAA9C,qHAAA,eAAe,OAAA;AACxB,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AA8BnB,mDAA6F;AAApF,0GAAA,QAAQ,OAAA;AAEjB,qDAI2B;AAH1B,yHAAA,sBAAsB,OAAA;AACtB,iIAAA,8BAA8B,OAAA;AAC9B,yHAAA,sBAAsB,OAAA;AAGvB,6FAA6F;AAC7F,4IAA4I;AAC5I,mEAIkC;AAHjC,8HAAA,eAAe,OAAwB;AACvC,mIAAA,IAAI,OAA6B;AACjC,sIAAA,uBAAuB,OAAgC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype ViewableTree,\n\ttype TreeViewEvents,\n\tTreeViewConfiguration,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n} from \"./tree.js\";\nexport { SchemaFactory, type ScopedSchemaName } from \"./schemaFactory.js\";\nexport type {\n\tValidateRecursiveSchema,\n\tFixRecursiveArraySchema,\n} from \"./schemaFactoryRecursive.js\";\nexport {\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n\ttypedObjectValues,\n} from \"./schemaCreationUtilities.js\";\nexport { treeNodeApi, type TreeNodeApi } from \"./treeNodeApi.js\";\nexport { createFromInsertable, cursorFromInsertable } from \"./create.js\";\nexport type { SimpleTreeSchema } from \"./simpleSchema.js\";\nexport {\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n} from \"./jsonSchema.js\";\nexport { getJsonSchema } from \"./getJsonSchema.js\";\nexport { getSimpleSchema } from \"./getSimpleSchema.js\";\nexport { ViewSchema } from \"./view.js\";\nexport type {\n\tUnenforced,\n\tFieldHasDefaultUnsafe,\n\tObjectFromSchemaRecordUnsafe,\n\tTreeObjectNodeUnsafe,\n\tTreeFieldFromImplicitFieldUnsafe,\n\tTreeNodeFromImplicitAllowedTypesUnsafe,\n\tFieldSchemaUnsafe,\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n\tInsertableTreeFieldFromImplicitFieldUnsafe,\n\tInsertableTypedNodeUnsafe,\n\tNodeBuilderDataUnsafe,\n\tNodeFromSchemaUnsafe,\n\tReadonlyMapInlined,\n} from \"./typesUnsafe.js\";\n\nexport type {\n\tVerboseTreeNode,\n\tParseOptions,\n\tVerboseTree,\n} from \"./verboseTree.js\";\n\nexport type { EncodeOptions } from \"./customTree.js\";\n\nexport type { ConciseTree } from \"./conciseTree.js\";\n\nexport { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from \"./treeApiBeta.js\";\n\nexport {\n\textractPersistedSchema,\n\tcomparePersistedSchemaInternal,\n\tcomparePersistedSchema,\n} from \"./storedSchema.js\";\n\n// Exporting the schema (RecursiveObject) to test that recursive types are working correctly.\n// These are `@internal` so they can't be included in the `InternalClassTreeTypes` due to https://github.com/microsoft/rushstack/issues/3639\nexport {\n\tRecursiveObject as test_RecursiveObject,\n\tbase as test_RecursiveObject_base,\n\tRecursiveObjectPojoMode as test_RecursiveObjectPojoMode,\n} from \"./testRecursiveDomain.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/api/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAamB;AARlB,gHAAA,qBAAqB,OAAA;AAOrB,0GAAA,eAAe,OAAA;AAEhB,uDAA0E;AAAjE,iHAAA,aAAa,OAAA;AAKtB,2EAIsC;AAHrC,uHAAA,SAAS,OAAA;AACT,6HAAA,eAAe,OAAA;AACf,6HAAA,eAAe,OAAA;AAEhB,mDAA+E;AAAtE,6GAAA,WAAW,OAAA;AAAoB,8GAAA,YAAY,OAAA;AACpD,yCAA2F;AAAlF,iHAAA,oBAAoB,OAAA;AAAE,iHAAA,oBAAoB,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAiBrE,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,2DAAuD;AAA9C,qHAAA,eAAe,OAAA;AACxB,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AAyBnB,mDAO0B;AAHzB,4HAAA,0BAA0B,OAAA;AAC1B,mHAAA,iBAAiB,OAAA;AACjB,mHAAA,iBAAiB,OAAA;AAKlB,mDAAuE;AAA5C,mHAAA,iBAAiB,OAAA;AAE5C,mDAA6F;AAApF,0GAAA,QAAQ,OAAA;AAEjB,qDAI2B;AAH1B,yHAAA,sBAAsB,OAAA;AACtB,iIAAA,8BAA8B,OAAA;AAC9B,yHAAA,sBAAsB,OAAA;AAGvB,6FAA6F;AAC7F,4IAA4I;AAC5I,mEAIkC;AAHjC,8HAAA,eAAe,OAAwB;AACvC,mIAAA,IAAI,OAA6B;AACjC,sIAAA,uBAAuB,OAAgC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype ViewableTree,\n\ttype TreeViewEvents,\n\tTreeViewConfiguration,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n\ttype TreeViewAlpha,\n\ttype TreeBranch,\n\ttype TreeBranchEvents,\n\tasTreeViewAlpha,\n} from \"./tree.js\";\nexport { SchemaFactory, type ScopedSchemaName } from \"./schemaFactory.js\";\nexport type {\n\tValidateRecursiveSchema,\n\tFixRecursiveArraySchema,\n} from \"./schemaFactoryRecursive.js\";\nexport {\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n} from \"./schemaCreationUtilities.js\";\nexport { treeNodeApi, type TreeNodeApi, tryGetSchema } from \"./treeNodeApi.js\";\nexport { createFromInsertable, cursorFromInsertable, createFromCursor } from \"./create.js\";\nexport type { SimpleTreeSchema } from \"./simpleSchema.js\";\nexport {\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n} from \"./jsonSchema.js\";\nexport { getJsonSchema } from \"./getJsonSchema.js\";\nexport { getSimpleSchema } from \"./getSimpleSchema.js\";\nexport { ViewSchema } from \"./view.js\";\nexport type {\n\tUnenforced,\n\tFieldHasDefaultUnsafe,\n\tObjectFromSchemaRecordUnsafe,\n\tTreeObjectNodeUnsafe,\n\tTreeFieldFromImplicitFieldUnsafe,\n\tTreeNodeFromImplicitAllowedTypesUnsafe,\n\tFieldSchemaUnsafe,\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n\tInsertableTreeFieldFromImplicitFieldUnsafe,\n\tInsertableTypedNodeUnsafe,\n\tNodeBuilderDataUnsafe,\n\tNodeFromSchemaUnsafe,\n\tReadonlyMapInlined,\n\tTreeNodeSchemaClassUnsafe,\n\tTreeNodeSchemaUnsafe,\n\tAllowedTypesUnsafe,\n\tTreeNodeSchemaNonClassUnsafe,\n\tInsertableTreeNodeFromAllowedTypesUnsafe,\n} from \"./typesUnsafe.js\";\n\nexport {\n\ttype VerboseTreeNode,\n\ttype ParseOptions,\n\ttype VerboseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n} from \"./verboseTree.js\";\n\nexport type { EncodeOptions } from \"./customTree.js\";\n\nexport { type ConciseTree, conciseFromCursor } from \"./conciseTree.js\";\n\nexport { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from \"./treeApiBeta.js\";\n\nexport {\n\textractPersistedSchema,\n\tcomparePersistedSchemaInternal,\n\tcomparePersistedSchema,\n} from \"./storedSchema.js\";\n\n// Exporting the schema (RecursiveObject) to test that recursive types are working correctly.\n// These are `@internal` so they can't be included in the `InternalClassTreeTypes` due to https://github.com/microsoft/rushstack/issues/3639\nexport {\n\tRecursiveObject as test_RecursiveObject,\n\tbase as test_RecursiveObject_base,\n\tRecursiveObjectPojoMode as test_RecursiveObjectPojoMode,\n} from \"./testRecursiveDomain.js\";\n"]}