@fluidframework/tree 2.32.0 → 2.33.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 (339) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/api-report/tree.alpha.api.md +169 -192
  3. package/api-report/tree.beta.api.md +135 -164
  4. package/api-report/tree.legacy.alpha.api.md +138 -167
  5. package/api-report/tree.legacy.public.api.md +135 -164
  6. package/api-report/tree.public.api.md +135 -164
  7. package/dist/alpha.d.ts +3 -11
  8. package/dist/beta.d.ts +2 -11
  9. package/dist/core/index.d.ts +1 -1
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/index.js +1 -2
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/schema-stored/index.d.ts +1 -1
  14. package/dist/core/schema-stored/index.d.ts.map +1 -1
  15. package/dist/core/schema-stored/index.js +1 -2
  16. package/dist/core/schema-stored/index.js.map +1 -1
  17. package/dist/core/schema-stored/schema.d.ts +4 -11
  18. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  19. package/dist/core/schema-stored/schema.js +7 -14
  20. package/dist/core/schema-stored/schema.js.map +1 -1
  21. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  22. package/dist/core/tree/anchorSet.js +31 -24
  23. package/dist/core/tree/anchorSet.js.map +1 -1
  24. package/dist/core/tree/deltaUtil.d.ts +1 -4
  25. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  26. package/dist/core/tree/deltaUtil.js +1 -13
  27. package/dist/core/tree/deltaUtil.js.map +1 -1
  28. package/dist/core/tree/visitDelta.d.ts +6 -29
  29. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  30. package/dist/core/tree/visitDelta.js +11 -50
  31. package/dist/core/tree/visitDelta.js.map +1 -1
  32. package/dist/core/tree/visitorUtils.d.ts +12 -9
  33. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  34. package/dist/core/tree/visitorUtils.js +19 -32
  35. package/dist/core/tree/visitorUtils.js.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  37. package/dist/feature-libraries/chunked-forest/chunkedForest.js +6 -11
  38. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  39. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  42. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +41 -5
  43. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  44. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +43 -26
  45. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +1 -1
  47. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  48. package/dist/feature-libraries/flex-tree/context.d.ts +5 -0
  49. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  50. package/dist/feature-libraries/flex-tree/context.js +4 -0
  51. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  52. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  53. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  54. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  55. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  56. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  57. package/dist/feature-libraries/indexing/anchorTreeIndex.js +15 -22
  58. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  59. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  60. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +29 -25
  61. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  62. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  63. package/dist/feature-libraries/object-forest/objectForest.js +1 -7
  64. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  65. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  66. package/dist/feature-libraries/schema-index/codec.js +1 -1
  67. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  68. package/dist/index.d.ts +1 -1
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +3 -2
  71. package/dist/index.js.map +1 -1
  72. package/dist/internalTypes.d.ts +1 -1
  73. package/dist/internalTypes.d.ts.map +1 -1
  74. package/dist/internalTypes.js.map +1 -1
  75. package/dist/jsonDomainSchema.d.ts +6 -6
  76. package/dist/jsonDomainSchema.d.ts.map +1 -1
  77. package/dist/jsonDomainSchema.js.map +1 -1
  78. package/dist/legacy.d.ts +2 -11
  79. package/dist/packageVersion.d.ts +1 -1
  80. package/dist/packageVersion.js +1 -1
  81. package/dist/packageVersion.js.map +1 -1
  82. package/dist/public.d.ts +2 -11
  83. package/dist/serializableDomainSchema.d.ts +5 -5
  84. package/dist/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  85. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  86. package/dist/shared-tree/checkoutFlexTreeView.js +4 -0
  87. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  88. package/dist/shared-tree/index.d.ts +3 -2
  89. package/dist/shared-tree/index.d.ts.map +1 -1
  90. package/dist/shared-tree/index.js +2 -2
  91. package/dist/shared-tree/index.js.map +1 -1
  92. package/dist/shared-tree/sharedTree.d.ts +4 -35
  93. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  94. package/dist/shared-tree/sharedTree.js +4 -54
  95. package/dist/shared-tree/sharedTree.js.map +1 -1
  96. package/dist/simple-tree/api/index.d.ts +2 -1
  97. package/dist/simple-tree/api/index.d.ts.map +1 -1
  98. package/dist/simple-tree/api/index.js +3 -1
  99. package/dist/simple-tree/api/index.js.map +1 -1
  100. package/dist/simple-tree/api/schemaFactory.d.ts +28 -28
  101. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  102. package/dist/simple-tree/api/schemaFactory.js +11 -11
  103. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  104. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +6 -7
  105. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  106. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  107. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +24 -5
  108. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  109. package/dist/simple-tree/api/schemaFactoryRecursive.js +14 -1
  110. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  111. package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  112. package/dist/simple-tree/api/tree.d.ts +1 -14
  113. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  114. package/dist/simple-tree/api/tree.js.map +1 -1
  115. package/dist/simple-tree/api/typesUnsafe.d.ts +237 -220
  116. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  117. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  118. package/dist/simple-tree/arrayNode.d.ts +2 -2
  119. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  120. package/dist/simple-tree/arrayNode.js.map +1 -1
  121. package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -2
  122. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  123. package/dist/simple-tree/core/treeNodeKernel.js +39 -24
  124. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  125. package/dist/simple-tree/core/types.d.ts +14 -4
  126. package/dist/simple-tree/core/types.d.ts.map +1 -1
  127. package/dist/simple-tree/core/types.js +14 -4
  128. package/dist/simple-tree/core/types.js.map +1 -1
  129. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  130. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  131. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
  132. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  133. package/dist/simple-tree/index.d.ts +1 -1
  134. package/dist/simple-tree/index.d.ts.map +1 -1
  135. package/dist/simple-tree/index.js +3 -2
  136. package/dist/simple-tree/index.js.map +1 -1
  137. package/dist/simple-tree/objectNode.d.ts +9 -2
  138. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  139. package/dist/simple-tree/objectNode.js +3 -0
  140. package/dist/simple-tree/objectNode.js.map +1 -1
  141. package/dist/simple-tree/schemaTypes.d.ts +10 -5
  142. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  143. package/dist/simple-tree/schemaTypes.js +5 -2
  144. package/dist/simple-tree/schemaTypes.js.map +1 -1
  145. package/dist/tableSchema.d.ts +78 -26
  146. package/dist/tableSchema.d.ts.map +1 -1
  147. package/dist/tableSchema.js +53 -24
  148. package/dist/tableSchema.js.map +1 -1
  149. package/dist/treeFactory.d.ts +6 -12
  150. package/dist/treeFactory.d.ts.map +1 -1
  151. package/dist/treeFactory.js +56 -5
  152. package/dist/treeFactory.js.map +1 -1
  153. package/lib/alpha.d.ts +3 -11
  154. package/lib/beta.d.ts +2 -11
  155. package/lib/core/index.d.ts +1 -1
  156. package/lib/core/index.d.ts.map +1 -1
  157. package/lib/core/index.js +1 -1
  158. package/lib/core/index.js.map +1 -1
  159. package/lib/core/schema-stored/index.d.ts +1 -1
  160. package/lib/core/schema-stored/index.d.ts.map +1 -1
  161. package/lib/core/schema-stored/index.js +1 -1
  162. package/lib/core/schema-stored/index.js.map +1 -1
  163. package/lib/core/schema-stored/schema.d.ts +4 -11
  164. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  165. package/lib/core/schema-stored/schema.js +6 -12
  166. package/lib/core/schema-stored/schema.js.map +1 -1
  167. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  168. package/lib/core/tree/anchorSet.js +31 -24
  169. package/lib/core/tree/anchorSet.js.map +1 -1
  170. package/lib/core/tree/deltaUtil.d.ts +1 -4
  171. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  172. package/lib/core/tree/deltaUtil.js +0 -9
  173. package/lib/core/tree/deltaUtil.js.map +1 -1
  174. package/lib/core/tree/visitDelta.d.ts +6 -29
  175. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  176. package/lib/core/tree/visitDelta.js +12 -51
  177. package/lib/core/tree/visitDelta.js.map +1 -1
  178. package/lib/core/tree/visitorUtils.d.ts +12 -9
  179. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  180. package/lib/core/tree/visitorUtils.js +19 -32
  181. package/lib/core/tree/visitorUtils.js.map +1 -1
  182. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  183. package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -11
  184. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  185. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  186. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  187. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  188. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +41 -5
  189. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  190. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +43 -26
  191. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  192. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +1 -1
  193. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  194. package/lib/feature-libraries/flex-tree/context.d.ts +5 -0
  195. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  196. package/lib/feature-libraries/flex-tree/context.js +5 -1
  197. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  198. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  199. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  200. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  201. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  202. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  203. package/lib/feature-libraries/indexing/anchorTreeIndex.js +15 -22
  204. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  205. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  206. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +28 -24
  207. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  208. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  209. package/lib/feature-libraries/object-forest/objectForest.js +1 -7
  210. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  211. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  212. package/lib/feature-libraries/schema-index/codec.js +2 -2
  213. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  214. package/lib/index.d.ts +1 -1
  215. package/lib/index.d.ts.map +1 -1
  216. package/lib/index.js +1 -1
  217. package/lib/index.js.map +1 -1
  218. package/lib/internalTypes.d.ts +1 -1
  219. package/lib/internalTypes.d.ts.map +1 -1
  220. package/lib/internalTypes.js.map +1 -1
  221. package/lib/jsonDomainSchema.d.ts +6 -6
  222. package/lib/jsonDomainSchema.d.ts.map +1 -1
  223. package/lib/jsonDomainSchema.js.map +1 -1
  224. package/lib/legacy.d.ts +2 -11
  225. package/lib/packageVersion.d.ts +1 -1
  226. package/lib/packageVersion.js +1 -1
  227. package/lib/packageVersion.js.map +1 -1
  228. package/lib/public.d.ts +2 -11
  229. package/lib/serializableDomainSchema.d.ts +5 -5
  230. package/lib/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  231. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  232. package/lib/shared-tree/checkoutFlexTreeView.js +4 -0
  233. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  234. package/lib/shared-tree/index.d.ts +3 -2
  235. package/lib/shared-tree/index.d.ts.map +1 -1
  236. package/lib/shared-tree/index.js +1 -1
  237. package/lib/shared-tree/index.js.map +1 -1
  238. package/lib/shared-tree/sharedTree.d.ts +4 -35
  239. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  240. package/lib/shared-tree/sharedTree.js +2 -51
  241. package/lib/shared-tree/sharedTree.js.map +1 -1
  242. package/lib/simple-tree/api/index.d.ts +2 -1
  243. package/lib/simple-tree/api/index.d.ts.map +1 -1
  244. package/lib/simple-tree/api/index.js +1 -0
  245. package/lib/simple-tree/api/index.js.map +1 -1
  246. package/lib/simple-tree/api/schemaFactory.d.ts +28 -28
  247. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  248. package/lib/simple-tree/api/schemaFactory.js +11 -11
  249. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  250. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +6 -7
  251. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  252. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  253. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +24 -5
  254. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  255. package/lib/simple-tree/api/schemaFactoryRecursive.js +12 -0
  256. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  257. package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  258. package/lib/simple-tree/api/tree.d.ts +1 -14
  259. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  260. package/lib/simple-tree/api/tree.js.map +1 -1
  261. package/lib/simple-tree/api/typesUnsafe.d.ts +237 -220
  262. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  263. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  264. package/lib/simple-tree/arrayNode.d.ts +2 -2
  265. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  266. package/lib/simple-tree/arrayNode.js.map +1 -1
  267. package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -2
  268. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  269. package/lib/simple-tree/core/treeNodeKernel.js +40 -25
  270. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  271. package/lib/simple-tree/core/types.d.ts +14 -4
  272. package/lib/simple-tree/core/types.d.ts.map +1 -1
  273. package/lib/simple-tree/core/types.js +14 -4
  274. package/lib/simple-tree/core/types.js.map +1 -1
  275. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  276. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  277. package/lib/simple-tree/core/unhydratedFlexTree.js +3 -0
  278. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  279. package/lib/simple-tree/index.d.ts +1 -1
  280. package/lib/simple-tree/index.d.ts.map +1 -1
  281. package/lib/simple-tree/index.js +1 -1
  282. package/lib/simple-tree/index.js.map +1 -1
  283. package/lib/simple-tree/objectNode.d.ts +9 -2
  284. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  285. package/lib/simple-tree/objectNode.js +4 -1
  286. package/lib/simple-tree/objectNode.js.map +1 -1
  287. package/lib/simple-tree/schemaTypes.d.ts +10 -5
  288. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  289. package/lib/simple-tree/schemaTypes.js +5 -2
  290. package/lib/simple-tree/schemaTypes.js.map +1 -1
  291. package/lib/tableSchema.d.ts +78 -26
  292. package/lib/tableSchema.d.ts.map +1 -1
  293. package/lib/tableSchema.js +53 -24
  294. package/lib/tableSchema.js.map +1 -1
  295. package/lib/treeFactory.d.ts +6 -12
  296. package/lib/treeFactory.d.ts.map +1 -1
  297. package/lib/treeFactory.js +55 -3
  298. package/lib/treeFactory.js.map +1 -1
  299. package/lib/tsdoc-metadata.json +1 -1
  300. package/package.json +22 -23
  301. package/src/core/index.ts +0 -2
  302. package/src/core/schema-stored/index.ts +0 -2
  303. package/src/core/schema-stored/schema.ts +10 -29
  304. package/src/core/tree/anchorSet.ts +32 -24
  305. package/src/core/tree/deltaUtil.ts +1 -13
  306. package/src/core/tree/visitDelta.ts +24 -81
  307. package/src/core/tree/visitorUtils.ts +43 -53
  308. package/src/feature-libraries/chunked-forest/chunkedForest.ts +7 -22
  309. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +1 -1
  310. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +45 -27
  311. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +1 -1
  312. package/src/feature-libraries/flex-tree/context.ts +11 -1
  313. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -0
  314. package/src/feature-libraries/indexing/anchorTreeIndex.ts +17 -28
  315. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +39 -38
  316. package/src/feature-libraries/object-forest/objectForest.ts +1 -18
  317. package/src/feature-libraries/schema-index/codec.ts +1 -2
  318. package/src/index.ts +3 -11
  319. package/src/internalTypes.ts +0 -19
  320. package/src/jsonDomainSchema.ts +1 -3
  321. package/src/packageVersion.ts +1 -1
  322. package/src/shared-tree/checkoutFlexTreeView.ts +6 -0
  323. package/src/shared-tree/index.ts +8 -3
  324. package/src/shared-tree/sharedTree.ts +5 -133
  325. package/src/simple-tree/api/index.ts +2 -22
  326. package/src/simple-tree/api/schemaFactory.ts +40 -54
  327. package/src/simple-tree/api/schemaFactoryAlpha.ts +9 -14
  328. package/src/simple-tree/api/schemaFactoryRecursive.ts +25 -5
  329. package/src/simple-tree/api/tree.ts +1 -14
  330. package/src/simple-tree/api/typesUnsafe.ts +359 -341
  331. package/src/simple-tree/arrayNode.ts +2 -2
  332. package/src/simple-tree/core/treeNodeKernel.ts +46 -28
  333. package/src/simple-tree/core/types.ts +14 -4
  334. package/src/simple-tree/core/unhydratedFlexTree.ts +5 -1
  335. package/src/simple-tree/index.ts +2 -22
  336. package/src/simple-tree/objectNode.ts +13 -4
  337. package/src/simple-tree/schemaTypes.ts +11 -7
  338. package/src/tableSchema.ts +190 -63
  339. package/src/treeFactory.ts +151 -8
@@ -23,18 +23,27 @@ var TableSchema;
23
23
  const tableSchemaFactorySubScope = "table";
24
24
  /**
25
25
  * Factory for creating new table column schema.
26
+ * @privateRemarks
27
+ * TODO:
28
+ * - Add overloads to make propsSchema optional.
29
+ * - Take field schema rather than node schema for `propsSchema`, in particular to allow making
30
+ * the additional properties optional.
26
31
  * @internal
27
32
  */
28
33
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
29
- function createColumn(inputSchemaFactory) {
34
+ function createColumn(inputSchemaFactory, propsSchema) {
30
35
  const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
31
36
  /**
32
37
  * {@link Column} fields.
33
38
  * @remarks Extracted for re-use in returned type signature defined later in this function.
34
39
  * The implicit typing is intentional.
40
+ * Note: ideally we would add a satisfies clause here to ensure that this satisfies
41
+ * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.
42
+ * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
35
43
  */
36
44
  const columnFields = {
37
45
  id: schemaFactory.identifier,
46
+ props: schemaFactory.required(propsSchema),
38
47
  };
39
48
  /**
40
49
  * A column in a table.
@@ -52,35 +61,49 @@ var TableSchema;
52
61
  TableSchema.createColumn = createColumn;
53
62
  /**
54
63
  * Factory for creating new table row schema.
55
- * @privateRemarks TODO: add overloads to make column schema optional.
64
+ *
65
+ * @privateRemarks
66
+ * TODO:
67
+ * - Add overloads to make propsSchema optional.
68
+ * - Take field schema rather than node schema for `propsSchema`, in particular to allow making
69
+ * the additional properties optional.
70
+ *
56
71
  * @sealed @internal
57
72
  */
58
73
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
59
- function createRow(inputSchemaFactory, cellSchema, _columnSchema) {
74
+ function createRow(inputSchemaFactory, cellSchema, propsSchema) {
60
75
  const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
61
76
  /**
62
77
  * {@link Row} fields.
63
78
  * @remarks Extracted for re-use in returned type signature defined later in this function.
64
79
  * The implicit typing is intentional.
80
+ * Note: ideally we would add a satisfies clause here to ensure that this satisfies
81
+ * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.
82
+ * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
65
83
  */
66
84
  const rowFields = {
67
85
  id: schemaFactory.identifier,
68
86
  cells: schemaFactory.map("Row.cells", cellSchema),
87
+ props: schemaFactory.required(propsSchema),
69
88
  };
70
89
  /**
71
90
  * The Row schema - this is a map of Cells where the key is the column id
72
91
  */
73
92
  class Row extends schemaFactory.object("Row", rowFields) {
74
- getCell(column) {
75
- return this.cells.get(column.id);
93
+ getCell(columnOrId) {
94
+ const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
95
+ return this.cells.get(columnId);
76
96
  }
77
- setCell(column, value) {
78
- this.cells.set(column.id, value);
97
+ setCell(columnOrId, value) {
98
+ const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
99
+ this.cells.set(columnId, value);
79
100
  }
80
- deleteCell(column) {
81
- if (!this.cells.has(column.id))
101
+ removeCell(columnOrId) {
102
+ const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
103
+ if (!this.cells.has(columnId)) {
82
104
  return;
83
- this.cells.delete(column.id);
105
+ }
106
+ this.cells.delete(columnId);
84
107
  }
85
108
  }
86
109
  // Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
@@ -92,13 +115,19 @@ var TableSchema;
92
115
  return RowSchemaType;
93
116
  }
94
117
  TableSchema.createRow = createRow;
118
+ /** `createTable` implementation */
119
+ function createTable(inputSchemaFactory, _cellSchema, columnSchema, rowSchema) {
120
+ const column = columnSchema ?? createColumn(inputSchemaFactory, inputSchemaFactory.null);
121
+ return createTableInternal(inputSchemaFactory, _cellSchema, column, rowSchema ??
122
+ createRow(inputSchemaFactory, _cellSchema, inputSchemaFactory.null));
123
+ }
124
+ TableSchema.createTable = createTable;
95
125
  /**
96
126
  * Factory for creating new table schema.
97
- * @privateRemarks TODO: add overloads to make column/row schema optional.
98
- * @internal
127
+ * @system @internal
99
128
  */
100
129
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
101
- function createTable(inputSchemaFactory, _cellSchema, columnSchema, rowSchema) {
130
+ function createTableInternal(inputSchemaFactory, _cellSchema, columnSchema, rowSchema) {
102
131
  const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
103
132
  /**
104
133
  * {@link Table} fields.
@@ -129,7 +158,7 @@ var TableSchema;
129
158
  if (row !== undefined) {
130
159
  const column = this.getColumn(columnId);
131
160
  if (column !== undefined) {
132
- return row.getCell(column);
161
+ return row.getCell(column.id);
133
162
  }
134
163
  }
135
164
  // If the cell does not exist return undefined
@@ -173,7 +202,7 @@ var TableSchema;
173
202
  if (row !== undefined) {
174
203
  const column = this.getColumn(columnId);
175
204
  if (column !== undefined) {
176
- row.setCell(column, cell);
205
+ row.setCell(column.id, cell);
177
206
  }
178
207
  }
179
208
  }
@@ -184,37 +213,37 @@ var TableSchema;
184
213
  return;
185
214
  this.columns.removeAt(index);
186
215
  }
187
- deleteRows(rows) {
188
- // If there are no rows to delete, do nothing
216
+ removeRows(rows) {
217
+ // If there are no rows to remove, do nothing
189
218
  if (rows.length === 0) {
190
219
  return;
191
220
  }
192
- // If there is only one row to delete, delete it
221
+ // If there is only one row to remove, remove it
193
222
  if (rows.length === 1) {
194
223
  const index = this.rows.indexOf(rows[0] ?? (0, internal_1.oob)());
195
224
  this.rows.removeAt(index);
196
225
  return;
197
226
  }
198
- // If there are multiple rows to delete, delete them in a transaction
227
+ // If there are multiple rows to remove, remove them in a transaction
199
228
  // This is to avoid the performance issues of deleting multiple rows at once
200
229
  index_js_1.Tree.runTransaction(this, () => {
201
- // Iterate over the rows and delete them
230
+ // Iterate over the rows and remove them
202
231
  for (const row of rows) {
203
232
  const index = this.rows.indexOf(row);
204
233
  this.rows.removeAt(index);
205
234
  }
206
235
  });
207
236
  }
208
- deleteAllRows() {
237
+ removeAllRows() {
209
238
  this.rows.removeRange();
210
239
  }
211
- deleteCell(key) {
240
+ removeCell(key) {
212
241
  const { columnId, rowId } = key;
213
242
  const row = this.getRow(rowId);
214
243
  if (row !== undefined) {
215
244
  const column = this.getColumn(columnId);
216
245
  if (column !== undefined) {
217
- row.deleteCell(column);
246
+ row.removeCell(column.id);
218
247
  }
219
248
  }
220
249
  }
@@ -228,7 +257,7 @@ var TableSchema;
228
257
  // Return the table schema
229
258
  return TableSchemaType;
230
259
  }
231
- TableSchema.createTable = createTable;
260
+ TableSchema.createTableInternal = createTableInternal;
232
261
  // #endregion
233
262
  })(TableSchema || (exports.TableSchema = TableSchema = {}));
234
263
  //# sourceMappingURL=tableSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tableSchema.js","sourceRoot":"","sources":["../src/tableSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA0D;AAE1D,qDAA8C;AAC9C,qDAagC;AAEhC,yFAAyF;AACzF,uEAAuE;AACvE,0EAA0E;AAC1E,oDAAoD;AACpD,oDAAoD;AAEpD;;;;GAIG;AACH,IAAiB,WAAW,CA8jB3B;AA9jBD,WAAiB,WAAW;IAC3B,MAAM,0BAA0B,GAAG,OAAO,CAAC;IAiB3C;;;OAGG;IACH,sIAAsI;IACtI,SAAgB,YAAY,CAC3B,kBAAmD;QAEnD,MAAM,aAAa,GAAG,kBAAkB,CAAC,aAAa,CAAC,0BAA0B,CAAC,CAAC;QAGnF;;;;WAIG;QACH,MAAM,YAAY,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KAAK,CAAC,CAAC;oBAC3B,CAAC;gBACF,CAAC,CAAC,CAAC;YACJ,CAAC;YAEM,aAAa;gBACnB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACzB,CAAC;YAEM,UAAU,CAAC,GAAY;gBAC7B,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;gBAChC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC/B,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;oBACvB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;oBACxC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;wBAC1B,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;oBACxB,CAAC;gBACF,CAAC;YACF,CAAC;SACD;QAOD,8IAA8I;QAC9I,2CAA2C;QAC3C,yHAAyH;QACzH,iDAAiD;QACjD,qFAAqF;QACrF,MAAM,eAAe,GAOjB,KAAK,CAAC;QAEV,0BAA0B;QAC1B,OAAO,eAAe,CAAC;IACxB,CAAC;IA/Le,uBAAW,cA+L1B,CAAA;IAaD,aAAa;AACd,CAAC,EA9jBgB,WAAW,2BAAX,WAAW,QA8jB3B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\n\nimport { Tree } from \"./shared-tree/index.js\";\nimport {\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype NodeKind,\n\ttype SchemaFactoryAlpha,\n\ttype ScopedSchemaName,\n\tTreeArrayNode,\n\ttype TreeNode,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype TreeNodeSchemaClass,\n\ttype WithType,\n} from \"./simple-tree/index.js\";\n\n// Future improvement TODOs (ideally to be done before promoting these APIs to `@alpha`):\n// - Custom fields on Table/Row/Column (props pattern from Nick's demo)\n// - Overloads to make Column/Row schema optional when constructing Tables\n// - Record-like type parameters / input parameters?\n// - Move `@system` types into separate / sub scope?\n\n/**\n * Contains types and factories for creating schema to represent dynamic tabular data.\n * @privateRemarks TODO: document in more detail and add `@example`s.\n * @internal\n */\nexport namespace TableSchema {\n\tconst tableSchemaFactorySubScope = \"table\";\n\n\t// #region Column\n\n\t/**\n\t * A column in a table.\n\t * @remarks Implemented by the schema class returned from {@link TableSchema.createColumn}.\n\t * @sealed @internal\n\t */\n\texport interface IColumn {\n\t\t/**\n\t\t * The unique identifier of the column.\n\t\t * @remarks Uniquely identifies the node within the entire tree, not just the table.\n\t\t */\n\t\treadonly id: string;\n\t}\n\n\t/**\n\t * Factory for creating new table column schema.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createColumn<const TInputScope extends string | undefined>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\t/**\n\t\t * {@link Column} fields.\n\t\t * @remarks Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t */\n\t\tconst columnFields = {\n\t\t\tid: schemaFactory.identifier,\n\t\t} as const satisfies Record<string, ImplicitFieldSchema>;\n\n\t\t/**\n\t\t * A column in a table.\n\t\t */\n\t\tclass Column extends schemaFactory.object(\"Column\", columnFields) implements IColumn {}\n\n\t\ttype ColumnValueType = TreeNode & IColumn & WithType<ScopedSchemaName<Scope, \"Column\">>;\n\t\ttype ColumnInsertableType = InsertableObjectFromSchemaRecord<typeof columnFields>;\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst ColumnSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Column\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ ColumnValueType,\n\t\t\t/* TInsertable */ object & ColumnInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof columnFields\n\t\t> = Column;\n\n\t\treturn ColumnSchemaType;\n\t}\n\n\t/**\n\t * Base column schema type.\n\t * @sealed @system @internal\n\t */\n\texport type ColumnSchemaBase<TScope extends string | undefined> = ReturnType<\n\t\ttypeof createColumn<TScope>\n\t>;\n\n\t// #endregion\n\n\t// #region Row\n\n\t/**\n\t * A row in a table.\n\t * @remarks Implemented by the schema class returned from {@link TableSchema.createRow}.\n\t * @sealed @internal\n\t */\n\texport interface IRow<\n\t\tTCellSchema extends ImplicitAllowedTypes,\n\t\tTColumnSchema extends ImplicitAllowedTypes,\n\t> {\n\t\t/**\n\t\t * The unique identifier of the row.\n\t\t * @remarks Uniquely identifies the node within the entire tree, not just the table.\n\t\t */\n\t\treadonly id: string;\n\n\t\t/**\n\t\t * Gets the cell in the specified column\n\t\t * @returns The cell if it exists, otherwise undefined.\n\t\t * @privateRemarks TODO: add overload that takes column ID.\n\t\t */\n\t\tgetCell(\n\t\t\tcolumn: TreeNodeFromImplicitAllowedTypes<TColumnSchema>,\n\t\t): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;\n\n\t\t/**\n\t\t * Sets the cell in the specified column.\n\t\t * @remarks To delete a cell, call {@link TableSchema.IRow.deleteCell} instead.\n\t\t * @privateRemarks TODO: add overload that takes column ID.\n\t\t */\n\t\tsetCell(\n\t\t\tcolumn: TreeNodeFromImplicitAllowedTypes<TColumnSchema>,\n\t\t\tvalue: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,\n\t\t): void;\n\n\t\t/**\n\t\t * Deletes the cell in the specified column.\n\t\t * @privateRemarks TODO: add overload that takes column ID.\n\t\t */\n\t\tdeleteCell(column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>): void;\n\t}\n\n\t/**\n\t * Factory for creating new table row schema.\n\t * @privateRemarks TODO: add overloads to make column schema optional.\n\t * @sealed @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createRow<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCellSchema extends ImplicitAllowedTypes,\n\t\tconst TColumnSchema extends ColumnSchemaBase<TInputScope> = ColumnSchemaBase<TInputScope>,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\tcellSchema: TCellSchema,\n\t\t_columnSchema: TColumnSchema,\n\t) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\ttype CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;\n\t\ttype CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;\n\n\t\ttype ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumnSchema>;\n\n\t\t/**\n\t\t * {@link Row} fields.\n\t\t * @remarks Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t */\n\t\tconst rowFields = {\n\t\t\tid: schemaFactory.identifier,\n\t\t\tcells: schemaFactory.map(\"Row.cells\", cellSchema),\n\t\t} as const satisfies Record<string, ImplicitFieldSchema>;\n\n\t\t/**\n\t\t * The Row schema - this is a map of Cells where the key is the column id\n\t\t */\n\t\tclass Row\n\t\t\textends schemaFactory.object(\"Row\", rowFields)\n\t\t\timplements IRow<TCellSchema, TColumnSchema>\n\t\t{\n\t\t\tpublic getCell(column: ColumnValueType): CellValueType | undefined {\n\t\t\t\treturn this.cells.get(column.id) as CellValueType | undefined;\n\t\t\t}\n\n\t\t\tpublic setCell(column: ColumnValueType, value: CellInsertableType | undefined): void {\n\t\t\t\tthis.cells.set(column.id, value);\n\t\t\t}\n\n\t\t\tpublic deleteCell(column: ColumnValueType): void {\n\t\t\t\tif (!this.cells.has(column.id)) return;\n\t\t\t\tthis.cells.delete(column.id);\n\t\t\t}\n\t\t}\n\n\t\ttype RowValueType = TreeNode &\n\t\t\tIRow<TCellSchema, TColumnSchema> &\n\t\t\tWithType<ScopedSchemaName<Scope, \"Row\">>;\n\t\ttype RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFields>;\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst RowSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Row\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ RowValueType,\n\t\t\t/* TInsertable */ object & RowInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof rowFields\n\t\t> = Row;\n\n\t\treturn RowSchemaType;\n\t}\n\n\t/**\n\t * Base row schema type.\n\t * @sealed @system @internal\n\t */\n\texport type RowSchemaBase<\n\t\tTScope extends string | undefined,\n\t\tTCellSchema extends ImplicitAllowedTypes,\n\t\tTColumnSchema extends ColumnSchemaBase<TScope> = ColumnSchemaBase<TScope>,\n\t> = ReturnType<typeof createRow<TScope, TCellSchema, TColumnSchema>>;\n\n\t// #endregion\n\n\t// #region Table\n\n\t/**\n\t * A key to uniquely identify a cell in a table.\n\t * @sealed @internal\n\t */\n\texport interface CellKey {\n\t\t/**\n\t\t * {@link TableSchema.IColumn.id} of the containing {@link TableSchema.IColumn}.\n\t\t */\n\t\treadonly columnId: string;\n\n\t\t/**\n\t\t * {@link TableSchema.IRow.id} of the containing {@link TableSchema.IRow}.\n\t\t */\n\t\treadonly rowId: string;\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.insertColumn} parameters.\n\t * @sealed @internal\n\t */\n\texport interface InsertColumnParameters<TInsertableColumn> {\n\t\t/**\n\t\t * The index at which to insert the new column.\n\t\t * @remarks If not provided, the column will be appended to the end of the table.\n\t\t */\n\t\treadonly index?: number | undefined;\n\n\t\t/**\n\t\t * The column to insert.\n\t\t */\n\t\treadonly column: TInsertableColumn;\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.insertRows} parameters.\n\t * @sealed @internal\n\t */\n\texport interface InsertRowsParameters<TInsertableRow> {\n\t\t/**\n\t\t * The index at which to insert the new rows.\n\t\t * @remarks If not provided, the rows will be appended to the end of the table.\n\t\t */\n\t\treadonly index?: number | undefined;\n\n\t\t/**\n\t\t * The rows to insert.\n\t\t */\n\t\treadonly rows: TInsertableRow[];\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.setCell} parameters.\n\t * @sealed @internal\n\t */\n\texport interface SetCellParameters<TInsertableCell> {\n\t\t/**\n\t\t * The key to uniquely identify a cell in a table.\n\t\t */\n\t\treadonly key: CellKey;\n\n\t\t/**\n\t\t * The cell to set.\n\t\t */\n\t\treadonly cell: TInsertableCell;\n\t}\n\n\t/**\n\t * A table.\n\t * @sealed @internal\n\t */\n\texport interface ITable<\n\t\tTCellSchema extends ImplicitAllowedTypes,\n\t\tTColumnSchema extends ImplicitAllowedTypes,\n\t\tTRowSchema extends ImplicitAllowedTypes,\n\t> {\n\t\t/**\n\t\t * The table's columns.\n\t\t */\n\t\treadonly columns: TreeArrayNode<TColumnSchema>;\n\n\t\t/**\n\t\t * The table's rows.\n\t\t */\n\t\treadonly rows: TreeArrayNode<TRowSchema>;\n\n\t\t/**\n\t\t * Gets a table column by its {@link TableSchema.IRow.id}.\n\t\t */\n\t\tgetColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumnSchema> | undefined;\n\n\t\t/**\n\t\t * Gets a table row by its {@link TableSchema.IRow.id}.\n\t\t */\n\t\tgetRow(id: string): TreeNodeFromImplicitAllowedTypes<TRowSchema> | undefined;\n\n\t\t/**\n\t\t * Gets a cell in the table by column and row IDs.\n\t\t * @param key - A key that uniquely distinguishes a cell in the table, represented as a combination of the column ID and row ID.\n\t\t * @privateRemarks TODO: add overload that takes row and column nodes.\n\t\t */\n\t\tgetCell(key: CellKey): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;\n\n\t\t/**\n\t\t * Inserts a column into the table.\n\t\t * @throws Throws an error if the column is already in the tree, or if the specified index is out of range.\n\t\t */\n\t\tinsertColumn(\n\t\t\tparams: InsertColumnParameters<\n\t\t\t\tInsertableTreeNodeFromImplicitAllowedTypes<TColumnSchema>\n\t\t\t>,\n\t\t): TreeNodeFromImplicitAllowedTypes<TColumnSchema>;\n\n\t\t/**\n\t\t * Inserts 0 or more rows into the table.\n\t\t * @throws Throws an error if any of the rows are already in the tree, or if the specified index is out of range.\n\t\t */\n\t\tinsertRows(\n\t\t\tparams: InsertRowsParameters<InsertableTreeNodeFromImplicitAllowedTypes<TRowSchema>>,\n\t\t): TreeNodeFromImplicitAllowedTypes<TRowSchema>[];\n\n\t\t/**\n\t\t * Sets the cell at the specified location in the table.\n\t\t * @remarks To delete a cell, call {@link TableSchema.ITable.deleteCell} instead.\n\t\t * @privateRemarks TODO: add overload that takes column/row nodes?\n\t\t */\n\t\tsetCell(\n\t\t\tparams: SetCellParameters<InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>>,\n\t\t): void;\n\n\t\t/**\n\t\t * Removes the specified column from the table.\n\t\t * @remarks Note: this does not remove any cells from the table's rows.\n\t\t * @privateRemarks\n\t\t * TODO:\n\t\t * - Policy for when the column is not in the table.\n\t\t * - Actually remove corresponding cells from table rows.\n\t\t */\n\t\tremoveColumn: (column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>) => void;\n\n\t\t/**\n\t\t * Deletes 0 or more rows from the table.\n\t\t * @privateRemarks TODO: policy for when 1 or more rows are not in the table.\n\t\t */\n\t\tdeleteRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRowSchema>[]) => void;\n\n\t\t/**\n\t\t * Deletes all rows from the table.\n\t\t */\n\t\tdeleteAllRows: () => void;\n\n\t\t/**\n\t\t * Deletes the cell at the specified location in the table.\n\t\t * @privateRemarks TODO: add overload that takes column/row nodes?\n\t\t */\n\t\tdeleteCell: (key: CellKey) => void;\n\t}\n\n\t/**\n\t * Factory for creating new table schema.\n\t * @privateRemarks TODO: add overloads to make column/row schema optional.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createTable<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TColumn extends ColumnSchemaBase<TInputScope> = ColumnSchemaBase<TInputScope>,\n\t\tconst TRow extends RowSchemaBase<TInputScope, TCell, TColumn> = RowSchemaBase<\n\t\t\tTInputScope,\n\t\t\tTCell,\n\t\t\tTColumn\n\t\t>,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCell,\n\t\tcolumnSchema: TColumn,\n\t\trowSchema: TRow,\n\t) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\ttype CellValueType = TreeNodeFromImplicitAllowedTypes<TCell>;\n\t\ttype CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCell>;\n\n\t\ttype ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumn>;\n\t\ttype ColumnInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TColumn>;\n\n\t\ttype RowValueType = TreeNodeFromImplicitAllowedTypes<TRow>;\n\t\ttype RowInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TRow>;\n\n\t\t/**\n\t\t * {@link Table} fields.\n\t\t * @remarks Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t */\n\t\tconst tableFields = {\n\t\t\trows: schemaFactory.array(\"Table.rows\", rowSchema),\n\t\t\tcolumns: schemaFactory.array(\"Table.columns\", columnSchema),\n\t\t} as const satisfies Record<string, ImplicitFieldSchema>;\n\n\t\t/**\n\t\t * The Table schema\n\t\t */\n\t\tclass Table\n\t\t\textends schemaFactory.object(\"Table\", tableFields)\n\t\t\timplements ITable<TCell, TColumn, TRow>\n\t\t{\n\t\t\tpublic getColumn(id: string): ColumnValueType | undefined {\n\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the casts.\n\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\treturn this.columns.find((column) => (column as ColumnValueType).id === id) as\n\t\t\t\t\t| ColumnValueType\n\t\t\t\t\t| undefined;\n\t\t\t}\n\n\t\t\tpublic getRow(id: string): RowValueType | undefined {\n\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the casts.\n\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\treturn this.rows.find((_row) => (_row as RowValueType).id === id) as\n\t\t\t\t\t| RowValueType\n\t\t\t\t\t| undefined;\n\t\t\t}\n\n\t\t\tpublic getCell(key: CellKey): CellValueType | undefined {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\treturn row.getCell(column);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If the cell does not exist return undefined\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tpublic insertColumn({\n\t\t\t\tcolumn,\n\t\t\t\tindex,\n\t\t\t}: InsertColumnParameters<ColumnInsertableType>): ColumnValueType {\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.columns.insertAtEnd(column as any);\n\t\t\t\t} else {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.columns.insertAt(index, column as any);\n\t\t\t\t}\n\n\t\t\t\t// Inserting the input node into the tree hydrates it, making it usable as a node.\n\t\t\t\treturn column as ColumnValueType;\n\t\t\t}\n\n\t\t\tpublic insertRows({\n\t\t\t\tindex,\n\t\t\t\trows,\n\t\t\t}: InsertRowsParameters<RowInsertableType>): RowValueType[] {\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.rows.insertAtEnd(TreeArrayNode.spread(rows) as any);\n\t\t\t\t} else {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.rows.insertAt(index, TreeArrayNode.spread(rows) as any);\n\t\t\t\t}\n\n\t\t\t\t// Inserting the input nodes into the tree hydrates them, making them usable as nodes.\n\t\t\t\treturn rows as unknown as RowValueType[];\n\t\t\t}\n\n\t\t\tpublic setCell({ key, cell }: SetCellParameters<CellInsertableType>): void {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\trow.setCell(column, cell);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpublic removeColumn(column: ColumnValueType): void {\n\t\t\t\tconst index = this.columns.indexOf(column);\n\t\t\t\t// If the column is not in the table, do nothing\n\t\t\t\tif (index === -1) return;\n\t\t\t\tthis.columns.removeAt(index);\n\t\t\t}\n\n\t\t\tpublic deleteRows(rows: readonly RowValueType[]): void {\n\t\t\t\t// If there are no rows to delete, do nothing\n\t\t\t\tif (rows.length === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If there is only one row to delete, delete it\n\t\t\t\tif (rows.length === 1) {\n\t\t\t\t\tconst index = this.rows.indexOf(rows[0] ?? oob());\n\t\t\t\t\tthis.rows.removeAt(index);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// If there are multiple rows to delete, delete them in a transaction\n\t\t\t\t// This is to avoid the performance issues of deleting multiple rows at once\n\t\t\t\tTree.runTransaction(this, () => {\n\t\t\t\t\t// Iterate over the rows and delete them\n\t\t\t\t\tfor (const row of rows) {\n\t\t\t\t\t\tconst index = this.rows.indexOf(row);\n\t\t\t\t\t\tthis.rows.removeAt(index);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublic deleteAllRows(): void {\n\t\t\t\tthis.rows.removeRange();\n\t\t\t}\n\n\t\t\tpublic deleteCell(key: CellKey): void {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\trow.deleteCell(column);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ttype TableValueType = TreeNode &\n\t\t\tITable<TCell, TColumn, TRow> &\n\t\t\tWithType<ScopedSchemaName<Scope, \"Table\">>;\n\t\ttype TableInsertableType = InsertableObjectFromSchemaRecord<typeof tableFields>;\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst TableSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Table\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ TableValueType,\n\t\t\t/* TInsertable */ object & TableInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof tableFields\n\t\t> = Table;\n\n\t\t// Return the table schema\n\t\treturn TableSchemaType;\n\t}\n\n\t/**\n\t * Base row schema type.\n\t * @sealed @system @internal\n\t */\n\texport type TableSchemaBase<\n\t\tTScope extends string | undefined,\n\t\tTCell extends ImplicitAllowedTypes,\n\t\tTColumn extends ColumnSchemaBase<TScope> = ColumnSchemaBase<TScope>,\n\t\tTRow extends RowSchemaBase<TScope, TCell, TColumn> = RowSchemaBase<TScope, TCell, TColumn>,\n\t> = ReturnType<typeof createTable<TScope, TCell, TColumn, TRow>>;\n\n\t// #endregion\n}\n"]}
1
+ {"version":3,"file":"tableSchema.js","sourceRoot":"","sources":["../src/tableSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA0D;AAE1D,qDAA8C;AAC9C,qDAcgC;AAEhC,yFAAyF;AACzF,uEAAuE;AACvE,0EAA0E;AAC1E,oDAAoD;AACpD,oDAAoD;AAEpD;;;;GAIG;AACH,IAAiB,WAA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AAI,CAAC,WAAW,EAAE,CAAC;YACzB,CAAC;YAEM,UAAU,CAAC,GAAY;gBAC7B,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;gBAChC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC/B,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;oBACvB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;oBACxC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;wBAC1B,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;oBAC3B,CAAC;gBACF,CAAC;YACF,CAAC;SACD;QAOD,8IAA8I;QAC9I,2CAA2C;QAC3C,yHAAyH;QACzH,iDAAiD;QACjD,qFAAqF;QACrF,MAAM,eAAe,GAOjB,KAAK,CAAC;QAEV,0BAA0B;QAC1B,OAAO,eAAe,CAAC;IACxB,CAAC;IAlMe,+BAAmB,sBAkMlC,CAAA;IAoBD,aAAa;AACd,CAAC,EA5rBgB,WAAW,2BAAX,WAAW,QA4rB3B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\n\nimport { Tree } from \"./shared-tree/index.js\";\nimport {\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype NodeKind,\n\ttype SchemaFactoryAlpha,\n\ttype ScopedSchemaName,\n\tTreeArrayNode,\n\ttype TreeNode,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype TreeNodeSchema,\n\ttype TreeNodeSchemaClass,\n\ttype WithType,\n} from \"./simple-tree/index.js\";\n\n// Future improvement TODOs (ideally to be done before promoting these APIs to `@alpha`):\n// - Custom fields on Table/Row/Column (props pattern from Nick's demo)\n// - Overloads to make Column/Row schema optional when constructing Tables\n// - Record-like type parameters / input parameters?\n// - Move `@system` types into separate / sub scope?\n\n/**\n * Contains types and factories for creating schema to represent dynamic tabular data.\n * @privateRemarks TODO: document in more detail and add `@example`s.\n * @internal\n */\nexport namespace TableSchema {\n\tconst tableSchemaFactorySubScope = \"table\";\n\n\t// #region Column\n\n\t/**\n\t * A column in a table.\n\t * @remarks Implemented by the schema class returned from {@link TableSchema.createColumn}.\n\t * @sealed @internal\n\t */\n\texport interface IColumn<TPropsSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes> {\n\t\t/**\n\t\t * The unique identifier of the column.\n\t\t * @remarks Uniquely identifies the node within the entire tree, not just the table.\n\t\t */\n\t\treadonly id: string;\n\n\t\t/**\n\t\t * User-provided column properties.\n\t\t */\n\t\tget props(): TreeNodeFromImplicitAllowedTypes<TPropsSchema>;\n\t\tset props(value: InsertableTreeNodeFromImplicitAllowedTypes<TPropsSchema>);\n\t}\n\n\t/**\n\t * Factory for creating new table column schema.\n\t * @privateRemarks\n\t * TODO:\n\t * - Add overloads to make propsSchema optional.\n\t * - Take field schema rather than node schema for `propsSchema`, in particular to allow making\n\t * the additional properties optional.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createColumn<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TPropsSchema extends ImplicitAllowedTypes,\n\t>(inputSchemaFactory: SchemaFactoryAlpha<TInputScope>, propsSchema: TPropsSchema) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\t/**\n\t\t * {@link Column} fields.\n\t\t * @remarks Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t * Note: ideally we would add a satisfies clause here to ensure that this satisfies\n\t\t * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.\n\t\t * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394\n\t\t */\n\t\tconst columnFields = {\n\t\t\tid: schemaFactory.identifier,\n\t\t\tprops: schemaFactory.required(propsSchema),\n\t\t} as const;\n\n\t\t/**\n\t\t * A column in a table.\n\t\t */\n\t\tclass Column extends schemaFactory.object(\"Column\", columnFields) {}\n\n\t\ttype ColumnValueType = TreeNode &\n\t\t\tIColumn<TPropsSchema> &\n\t\t\tWithType<ScopedSchemaName<Scope, \"Column\">>;\n\n\t\ttype ColumnInsertableType = InsertableObjectFromSchemaRecord<typeof columnFields>;\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst ColumnSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Column\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ ColumnValueType,\n\t\t\t/* TInsertable */ object & ColumnInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof columnFields\n\t\t> = Column;\n\n\t\treturn ColumnSchemaType;\n\t}\n\n\t/**\n\t * Base column schema type.\n\t * @sealed @system @internal\n\t */\n\texport type ColumnSchemaBase<\n\t\tTScope extends string | undefined,\n\t\tTPropsSchema extends ImplicitAllowedTypes,\n\t> = ReturnType<typeof createColumn<TScope, TPropsSchema>>;\n\n\t// #endregion\n\n\t// #region Row\n\n\t/**\n\t * A row in a table.\n\t * @remarks Implemented by the schema class returned from {@link TableSchema.createRow}.\n\t * @sealed @internal\n\t */\n\texport interface IRow<\n\t\tTCellSchema extends ImplicitAllowedTypes,\n\t\tTPropsSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t> {\n\t\t/**\n\t\t * The unique identifier of the row.\n\t\t * @remarks Uniquely identifies the node within the entire tree, not just the table.\n\t\t */\n\t\treadonly id: string;\n\n\t\t/**\n\t\t * Gets the cell in the specified column.\n\t\t * @returns The cell if it exists, otherwise undefined.\n\t\t */\n\t\tgetCell(column: IColumn): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;\n\t\t/**\n\t\t * Gets the cell in the specified column, denoted by column ID.\n\t\t * @returns The cell if it exists, otherwise undefined.\n\t\t */\n\t\tgetCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;\n\n\t\t/**\n\t\t * Sets the cell in the specified column.\n\t\t * @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:1)} instead.\n\t\t */\n\t\tsetCell(\n\t\t\tcolumn: IColumn,\n\t\t\tvalue: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,\n\t\t): void;\n\t\t/**\n\t\t * Sets the cell in the specified column, denoted by column ID.\n\t\t * @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:2)} instead.\n\t\t */\n\t\tsetCell(\n\t\t\tcolumnId: string,\n\t\t\tvalue: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,\n\t\t): void;\n\n\t\t/**\n\t\t * Removes the cell in the specified column.\n\t\t * @privateRemarks TODO: return removed cell\n\t\t */\n\t\tremoveCell(column: IColumn): void;\n\t\t/**\n\t\t * Removes the cell in the specified column, denoted by column ID.\n\t\t * @privateRemarks TODO: return removed cell\n\t\t */\n\t\tremoveCell(columnId: string): void;\n\n\t\t/**\n\t\t * User-provided row properties.\n\t\t */\n\t\tget props(): TreeNodeFromImplicitAllowedTypes<TPropsSchema>;\n\t\tset props(value: InsertableTreeNodeFromImplicitAllowedTypes<TPropsSchema>);\n\t}\n\n\t/**\n\t * Factory for creating new table row schema.\n\t *\n\t * @privateRemarks\n\t * TODO:\n\t * - Add overloads to make propsSchema optional.\n\t * - Take field schema rather than node schema for `propsSchema`, in particular to allow making\n\t * the additional properties optional.\n\t *\n\t * @sealed @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createRow<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCellSchema extends ImplicitAllowedTypes,\n\t\tconst TPropsSchema extends ImplicitAllowedTypes,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\tcellSchema: TCellSchema,\n\t\tpropsSchema: TPropsSchema,\n\t) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\ttype CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;\n\t\ttype CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;\n\n\t\t/**\n\t\t * {@link Row} fields.\n\t\t * @remarks Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t * Note: ideally we would add a satisfies clause here to ensure that this satisfies\n\t\t * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.\n\t\t * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394\n\t\t */\n\t\tconst rowFields = {\n\t\t\tid: schemaFactory.identifier,\n\t\t\tcells: schemaFactory.map(\"Row.cells\", cellSchema),\n\t\t\tprops: schemaFactory.required(propsSchema),\n\t\t} as const;\n\n\t\t/**\n\t\t * The Row schema - this is a map of Cells where the key is the column id\n\t\t */\n\t\tclass Row\n\t\t\textends schemaFactory.object(\"Row\", rowFields)\n\t\t\timplements IRow<TCellSchema, TPropsSchema>\n\t\t{\n\t\t\tpublic getCell(columnOrId: IColumn | string): CellValueType | undefined {\n\t\t\t\tconst columnId = typeof columnOrId === \"string\" ? columnOrId : columnOrId.id;\n\t\t\t\treturn this.cells.get(columnId) as CellValueType | undefined;\n\t\t\t}\n\n\t\t\tpublic setCell(\n\t\t\t\tcolumnOrId: IColumn | string,\n\t\t\t\tvalue: CellInsertableType | undefined,\n\t\t\t): void {\n\t\t\t\tconst columnId = typeof columnOrId === \"string\" ? columnOrId : columnOrId.id;\n\t\t\t\tthis.cells.set(columnId, value);\n\t\t\t}\n\n\t\t\tpublic removeCell(columnOrId: IColumn | string): void {\n\t\t\t\tconst columnId = typeof columnOrId === \"string\" ? columnOrId : columnOrId.id;\n\t\t\t\tif (!this.cells.has(columnId)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.cells.delete(columnId);\n\t\t\t}\n\t\t}\n\n\t\ttype RowValueType = TreeNode &\n\t\t\tIRow<TCellSchema, TPropsSchema> &\n\t\t\tWithType<ScopedSchemaName<Scope, \"Row\">>;\n\t\ttype RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFields>;\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst RowSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Row\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ RowValueType,\n\t\t\t/* TInsertable */ object & RowInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof rowFields\n\t\t> = Row;\n\n\t\treturn RowSchemaType;\n\t}\n\n\t/**\n\t * Base row schema type.\n\t * @sealed @system @internal\n\t */\n\texport type RowSchemaBase<\n\t\tTScope extends string | undefined,\n\t\tTCellSchema extends ImplicitAllowedTypes,\n\t\tTPropsSchema extends ImplicitAllowedTypes,\n\t> = ReturnType<typeof createRow<TScope, TCellSchema, TPropsSchema>>;\n\n\t// #endregion\n\n\t// #region Table\n\n\t/**\n\t * A key to uniquely identify a cell in a table.\n\t * @sealed @internal\n\t */\n\texport interface CellKey {\n\t\t/**\n\t\t * {@link TableSchema.IColumn.id} of the containing {@link TableSchema.IColumn}.\n\t\t */\n\t\treadonly columnId: string;\n\n\t\t/**\n\t\t * {@link TableSchema.IRow.id} of the containing {@link TableSchema.IRow}.\n\t\t */\n\t\treadonly rowId: string;\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.insertColumn} parameters.\n\t * @sealed @internal\n\t */\n\texport interface InsertColumnParameters<TInsertableColumn> {\n\t\t/**\n\t\t * The index at which to insert the new column.\n\t\t * @remarks If not provided, the column will be appended to the end of the table.\n\t\t */\n\t\treadonly index?: number | undefined;\n\n\t\t/**\n\t\t * The column to insert.\n\t\t */\n\t\treadonly column: TInsertableColumn;\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.insertRows} parameters.\n\t * @sealed @internal\n\t */\n\texport interface InsertRowsParameters<TInsertableRow> {\n\t\t/**\n\t\t * The index at which to insert the new rows.\n\t\t * @remarks If not provided, the rows will be appended to the end of the table.\n\t\t */\n\t\treadonly index?: number | undefined;\n\n\t\t/**\n\t\t * The rows to insert.\n\t\t */\n\t\treadonly rows: TInsertableRow[];\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.setCell} parameters.\n\t * @sealed @internal\n\t */\n\texport interface SetCellParameters<TInsertableCell> {\n\t\t/**\n\t\t * The key to uniquely identify a cell in a table.\n\t\t */\n\t\treadonly key: CellKey;\n\n\t\t/**\n\t\t * The cell to set.\n\t\t */\n\t\treadonly cell: TInsertableCell;\n\t}\n\n\t/**\n\t * A table.\n\t * @sealed @internal\n\t */\n\texport interface ITable<\n\t\tTCellSchema extends ImplicitAllowedTypes,\n\t\tTColumnSchema extends ImplicitAllowedTypes,\n\t\tTRowSchema extends ImplicitAllowedTypes,\n\t> {\n\t\t/**\n\t\t * The table's columns.\n\t\t */\n\t\treadonly columns: TreeArrayNode<TColumnSchema>;\n\n\t\t/**\n\t\t * The table's rows.\n\t\t */\n\t\treadonly rows: TreeArrayNode<TRowSchema>;\n\n\t\t/**\n\t\t * Gets a table column by its {@link TableSchema.IRow.id}.\n\t\t */\n\t\tgetColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumnSchema> | undefined;\n\n\t\t/**\n\t\t * Gets a table row by its {@link TableSchema.IRow.id}.\n\t\t */\n\t\tgetRow(id: string): TreeNodeFromImplicitAllowedTypes<TRowSchema> | undefined;\n\n\t\t/**\n\t\t * Gets a cell in the table by column and row IDs.\n\t\t * @param key - A key that uniquely distinguishes a cell in the table, represented as a combination of the column ID and row ID.\n\t\t * @privateRemarks TODO: add overload that takes row and column nodes.\n\t\t */\n\t\tgetCell(key: CellKey): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;\n\n\t\t/**\n\t\t * Inserts a column into the table.\n\t\t * @throws Throws an error if the column is already in the tree, or if the specified index is out of range.\n\t\t */\n\t\tinsertColumn(\n\t\t\tparams: InsertColumnParameters<\n\t\t\t\tInsertableTreeNodeFromImplicitAllowedTypes<TColumnSchema>\n\t\t\t>,\n\t\t): TreeNodeFromImplicitAllowedTypes<TColumnSchema>;\n\n\t\t/**\n\t\t * Inserts 0 or more rows into the table.\n\t\t * @throws Throws an error if any of the rows are already in the tree, or if the specified index is out of range.\n\t\t */\n\t\tinsertRows(\n\t\t\tparams: InsertRowsParameters<InsertableTreeNodeFromImplicitAllowedTypes<TRowSchema>>,\n\t\t): TreeNodeFromImplicitAllowedTypes<TRowSchema>[];\n\n\t\t/**\n\t\t * Sets the cell at the specified location in the table.\n\t\t * @remarks To remove a cell, call {@link TableSchema.ITable.removeCell} instead.\n\t\t * @privateRemarks TODO: add overload that takes column/row nodes?\n\t\t */\n\t\tsetCell(\n\t\t\tparams: SetCellParameters<InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>>,\n\t\t): void;\n\n\t\t/**\n\t\t * Removes the specified column from the table.\n\t\t * @remarks Note: this does not remove any cells from the table's rows.\n\t\t * @privateRemarks\n\t\t * TODO:\n\t\t * - Policy for when the column is not in the table.\n\t\t * - Actually remove corresponding cells from table rows.\n\t\t */\n\t\tremoveColumn: (column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>) => void;\n\n\t\t/**\n\t\t * Removes 0 or more rows from the table.\n\t\t * @privateRemarks TODO: policy for when 1 or more rows are not in the table.\n\t\t */\n\t\tremoveRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRowSchema>[]) => void;\n\n\t\t/**\n\t\t * Removes all rows from the table.\n\t\t */\n\t\tremoveAllRows: () => void;\n\n\t\t/**\n\t\t * Removes the cell at the specified location in the table.\n\t\t * @privateRemarks TODO: add overload that takes column/row nodes?\n\t\t */\n\t\tremoveCell: (key: CellKey) => void;\n\t}\n\n\t/**\n\t * Factory for creating new table schema without specifying row or column schema.\n\t * @internal\n\t */\n\texport function createTable<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCell,\n\t): ReturnType<typeof createTableInternal<TInputScope, TCell>>;\n\t/**\n\t * Factory for creating new table schema without specifying row schema\n\t * @internal\n\t */\n\texport function createTable<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCell,\n\t\tcolumnSchema: TColumn,\n\t): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn>>;\n\t/**\n\t * Factory for creating new table schema.\n\t * @internal\n\t */\n\texport function createTable<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,\n\t\tconst TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes>,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCell,\n\t\tcolumnSchema: TColumn,\n\t\trowSchema: TRow,\n\t): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn, TRow>>;\n\t/** `createTable` implementation */\n\texport function createTable<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,\n\t\tconst TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes>,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCell,\n\t\tcolumnSchema?: TColumn,\n\t\trowSchema?: TRow,\n\t): TreeNodeSchema {\n\t\tconst column = columnSchema ?? createColumn(inputSchemaFactory, inputSchemaFactory.null);\n\t\treturn createTableInternal(\n\t\t\tinputSchemaFactory,\n\t\t\t_cellSchema,\n\t\t\tcolumn as TColumn,\n\t\t\trowSchema ??\n\t\t\t\t(createRow(inputSchemaFactory, _cellSchema, inputSchemaFactory.null) as TRow),\n\t\t);\n\t}\n\n\t/**\n\t * Factory for creating new table schema.\n\t * @system @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createTableInternal<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TColumn extends ColumnSchemaBase<\n\t\t\tTInputScope,\n\t\t\tImplicitAllowedTypes\n\t\t> = ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,\n\t\tconst TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes> = RowSchemaBase<\n\t\t\tTInputScope,\n\t\t\tTCell,\n\t\t\tImplicitAllowedTypes\n\t\t>,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCell,\n\t\tcolumnSchema: TColumn,\n\t\trowSchema: TRow,\n\t) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\ttype CellValueType = TreeNodeFromImplicitAllowedTypes<TCell>;\n\t\ttype CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCell>;\n\n\t\ttype ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumn>;\n\t\ttype ColumnInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TColumn>;\n\n\t\ttype RowValueType = TreeNodeFromImplicitAllowedTypes<TRow>;\n\t\ttype RowInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TRow>;\n\n\t\t/**\n\t\t * {@link Table} fields.\n\t\t * @remarks Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t */\n\t\tconst tableFields = {\n\t\t\trows: schemaFactory.array(\"Table.rows\", rowSchema),\n\t\t\tcolumns: schemaFactory.array(\"Table.columns\", columnSchema),\n\t\t} as const satisfies Record<string, ImplicitFieldSchema>;\n\n\t\t/**\n\t\t * The Table schema\n\t\t */\n\t\tclass Table\n\t\t\textends schemaFactory.object(\"Table\", tableFields)\n\t\t\timplements ITable<TCell, TColumn, TRow>\n\t\t{\n\t\t\tpublic getColumn(id: string): ColumnValueType | undefined {\n\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the casts.\n\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\treturn this.columns.find((column) => (column as ColumnValueType).id === id) as\n\t\t\t\t\t| ColumnValueType\n\t\t\t\t\t| undefined;\n\t\t\t}\n\n\t\t\tpublic getRow(id: string): RowValueType | undefined {\n\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the casts.\n\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\treturn this.rows.find((_row) => (_row as RowValueType).id === id) as\n\t\t\t\t\t| RowValueType\n\t\t\t\t\t| undefined;\n\t\t\t}\n\n\t\t\tpublic getCell(key: CellKey): CellValueType | undefined {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\treturn row.getCell(column.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If the cell does not exist return undefined\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tpublic insertColumn({\n\t\t\t\tcolumn,\n\t\t\t\tindex,\n\t\t\t}: InsertColumnParameters<ColumnInsertableType>): ColumnValueType {\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.columns.insertAtEnd(column as any);\n\t\t\t\t} else {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.columns.insertAt(index, column as any);\n\t\t\t\t}\n\n\t\t\t\t// Inserting the input node into the tree hydrates it, making it usable as a node.\n\t\t\t\treturn column as ColumnValueType;\n\t\t\t}\n\n\t\t\tpublic insertRows({\n\t\t\t\tindex,\n\t\t\t\trows,\n\t\t\t}: InsertRowsParameters<RowInsertableType>): RowValueType[] {\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.rows.insertAtEnd(TreeArrayNode.spread(rows) as any);\n\t\t\t\t} else {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.rows.insertAt(index, TreeArrayNode.spread(rows) as any);\n\t\t\t\t}\n\n\t\t\t\t// Inserting the input nodes into the tree hydrates them, making them usable as nodes.\n\t\t\t\treturn rows as unknown as RowValueType[];\n\t\t\t}\n\n\t\t\tpublic setCell({ key, cell }: SetCellParameters<CellInsertableType>): void {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\trow.setCell(column.id, cell);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpublic removeColumn(column: ColumnValueType): void {\n\t\t\t\tconst index = this.columns.indexOf(column);\n\t\t\t\t// If the column is not in the table, do nothing\n\t\t\t\tif (index === -1) return;\n\t\t\t\tthis.columns.removeAt(index);\n\t\t\t}\n\n\t\t\tpublic removeRows(rows: readonly RowValueType[]): void {\n\t\t\t\t// If there are no rows to remove, do nothing\n\t\t\t\tif (rows.length === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If there is only one row to remove, remove it\n\t\t\t\tif (rows.length === 1) {\n\t\t\t\t\tconst index = this.rows.indexOf(rows[0] ?? oob());\n\t\t\t\t\tthis.rows.removeAt(index);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// If there are multiple rows to remove, remove them in a transaction\n\t\t\t\t// This is to avoid the performance issues of deleting multiple rows at once\n\t\t\t\tTree.runTransaction(this, () => {\n\t\t\t\t\t// Iterate over the rows and remove them\n\t\t\t\t\tfor (const row of rows) {\n\t\t\t\t\t\tconst index = this.rows.indexOf(row);\n\t\t\t\t\t\tthis.rows.removeAt(index);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublic removeAllRows(): void {\n\t\t\t\tthis.rows.removeRange();\n\t\t\t}\n\n\t\t\tpublic removeCell(key: CellKey): void {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\trow.removeCell(column.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ttype TableValueType = TreeNode &\n\t\t\tITable<TCell, TColumn, TRow> &\n\t\t\tWithType<ScopedSchemaName<Scope, \"Table\">>;\n\t\ttype TableInsertableType = InsertableObjectFromSchemaRecord<typeof tableFields>;\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst TableSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Table\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ TableValueType,\n\t\t\t/* TInsertable */ object & TableInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof tableFields\n\t\t> = Table;\n\n\t\t// Return the table schema\n\t\treturn TableSchemaType;\n\t}\n\n\t/**\n\t * Base row schema type.\n\t * @sealed @system @internal\n\t */\n\texport type TableSchemaBase<\n\t\tTScope extends string | undefined,\n\t\tTCell extends ImplicitAllowedTypes,\n\t\tTColumn extends ColumnSchemaBase<TScope, ImplicitAllowedTypes> = ColumnSchemaBase<\n\t\t\tTScope,\n\t\t\tImplicitAllowedTypes\n\t\t>,\n\t\tTRow extends RowSchemaBase<TScope, TCell, ImplicitAllowedTypes> = RowSchemaBase<\n\t\t\tTScope,\n\t\t\tTCell,\n\t\t\tImplicitAllowedTypes\n\t\t>,\n\t> = ReturnType<typeof createTable<TScope, TCell, TColumn, TRow>>;\n\n\t// #endregion\n}\n"]}
@@ -2,22 +2,16 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { IChannelAttributes, IChannelFactory, IFluidDataStoreRuntime, IChannelServices } from "@fluidframework/datastore-definitions/internal";
6
5
  import type { SharedObjectKind } from "@fluidframework/shared-object-base";
7
- import { type ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
8
- import { type ISharedTree, type SharedTreeOptions, type SharedTreeOptionsInternal } from "./shared-tree/index.js";
6
+ import { type ISharedObject, type ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
7
+ import type { SharedTreeOptions, ITreePrivate } from "./shared-tree/index.js";
9
8
  import type { ITree } from "./simple-tree/index.js";
10
9
  /**
11
- * A channel factory that creates an {@link ITree}.
10
+ * {@link ITreePrivate} extended with ISharedObject.
11
+ * @remarks
12
+ * This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.
12
13
  */
13
- export declare class TreeFactory implements IChannelFactory<ISharedTree> {
14
- private readonly options;
15
- static Type: string;
16
- readonly type: string;
17
- readonly attributes: IChannelAttributes;
18
- constructor(options: SharedTreeOptionsInternal);
19
- load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, channelAttributes: Readonly<IChannelAttributes>): Promise<ISharedTree>;
20
- create(runtime: IFluidDataStoreRuntime, id: string): ISharedTree;
14
+ export interface ISharedTree extends ISharedObject, ITreePrivate {
21
15
  }
22
16
  /**
23
17
  * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees
@@ -1 +1 @@
1
- {"version":3,"file":"treeFactory.d.ts","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EACN,KAAK,iBAAiB,EAEtB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAEN,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAIpD;;GAEG;AACH,qBAAa,WAAY,YAAW,eAAe,CAAC,WAAW,CAAC;IAM5C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL3C,OAAc,IAAI,EAAE,MAAM,CAAyB;IACnD,SAAgB,IAAI,EAAE,MAAM,CAAyB;IAErD,SAAgB,UAAU,EAAE,kBAAkB,CAAwB;gBAElC,OAAO,EAAE,yBAAyB;IAEzD,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,iBAAiB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAC7C,OAAO,CAAC,WAAW,CAAC;IAMhB,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW;CAKvE;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,oDAA2B,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,iBAAiB,GACxB,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAOpD"}
1
+ {"version":3,"file":"treeFactory.d.ts","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAEN,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAGtB,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EAGX,iBAAiB,EAIjB,YAAY,EACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAEX,KAAK,EAOL,MAAM,wBAAwB,CAAC;AAQhC;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,aAAa,EAAE,YAAY;CAAG;AA2InE;;;;;GAKG;AACH,eAAO,MAAM,UAAU,oDAA2B,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,iBAAiB,GACxB,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAOpD"}
@@ -4,10 +4,62 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.configuredSharedTree = exports.SharedTree = exports.TreeFactory = void 0;
7
+ exports.configuredSharedTree = exports.SharedTree = void 0;
8
8
  const internal_1 = require("@fluidframework/shared-object-base/internal");
9
- const index_js_1 = require("./shared-tree/index.js");
10
9
  const sharedTreeAttributes_js_1 = require("./sharedTreeAttributes.js");
10
+ const index_js_1 = require("./util/index.js");
11
+ const index_js_2 = require("./shared-tree/index.js");
12
+ const internal_2 = require("@fluidframework/telemetry-utils/internal");
13
+ const internal_3 = require("@fluidframework/core-utils/internal");
14
+ /**
15
+ * Shared object wrapping {@link SharedTreeKernel}.
16
+ */
17
+ class SharedTreeImpl extends internal_1.SharedObject {
18
+ constructor(id, runtime, attributes, optionsParam, telemetryContextPrefix = "fluid_sharedTree_") {
19
+ super(id, runtime, attributes, telemetryContextPrefix);
20
+ this.breaker = new index_js_1.Breakable("Shared Tree");
21
+ if (runtime.idCompressor === undefined) {
22
+ throw new internal_2.UsageError("IdCompressor must be enabled to use SharedTree");
23
+ }
24
+ this.kernel = new index_js_2.SharedTreeKernel(this.breaker, this, this.serializer, (content, localOpMetadata) => this.submitLocalMessage(content, localOpMetadata), () => this.deltaManager.lastSequenceNumber, this.logger, runtime.idCompressor, optionsParam);
25
+ }
26
+ summarizeCore(serializer, telemetryContext, incrementalSummaryContext) {
27
+ return this.kernel.summarizeCore(serializer, telemetryContext, incrementalSummaryContext);
28
+ }
29
+ processCore(message, local, localOpMetadata) {
30
+ (0, internal_3.fail)(0xb75 /* processCore should not be called on SharedTree */);
31
+ }
32
+ processMessagesCore(messagesCollection) {
33
+ this.kernel.processMessagesCore(messagesCollection);
34
+ }
35
+ onDisconnect() {
36
+ this.kernel.onDisconnect();
37
+ }
38
+ exportVerbose() {
39
+ return this.kernel.exportVerbose();
40
+ }
41
+ exportSimpleSchema() {
42
+ return this.kernel.exportSimpleSchema();
43
+ }
44
+ contentSnapshot() {
45
+ return this.kernel.contentSnapshot();
46
+ }
47
+ viewWith(config) {
48
+ return this.kernel.viewWith(config);
49
+ }
50
+ async loadCore(services) {
51
+ await this.kernel.loadCore(services);
52
+ }
53
+ didAttach() {
54
+ this.kernel.didAttach();
55
+ }
56
+ applyStashedOp(...args) {
57
+ this.kernel.applyStashedOp(...args);
58
+ }
59
+ reSubmitCore(...args) {
60
+ this.kernel.reSubmitCore(...args);
61
+ }
62
+ }
11
63
  /**
12
64
  * A channel factory that creates an {@link ITree}.
13
65
  */
@@ -18,17 +70,16 @@ class TreeFactory {
18
70
  this.attributes = sharedTreeAttributes_js_1.SharedTreeAttributes;
19
71
  }
20
72
  async load(runtime, id, services, channelAttributes) {
21
- const tree = new index_js_1.SharedTree(id, runtime, channelAttributes, this.options);
73
+ const tree = new SharedTreeImpl(id, runtime, channelAttributes, this.options);
22
74
  await tree.load(services);
23
75
  return tree;
24
76
  }
25
77
  create(runtime, id) {
26
- const tree = new index_js_1.SharedTree(id, runtime, this.attributes, this.options);
78
+ const tree = new SharedTreeImpl(id, runtime, this.attributes, this.options);
27
79
  tree.initializeLocal();
28
80
  return tree;
29
81
  }
30
82
  }
31
- exports.TreeFactory = TreeFactory;
32
83
  TreeFactory.Type = sharedTreeAttributes_js_1.SharedTreeFactoryType;
33
84
  /**
34
85
  * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees
@@ -1 +1 @@
1
- {"version":3,"file":"treeFactory.js","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,0EAGqD;AAErD,qDAKgC;AAGhC,uEAAwF;AAExF;;GAEG;AACH,MAAa,WAAW;IAMvB,YAAoC,OAAkC;QAAlC,YAAO,GAAP,OAAO,CAA2B;QAJtD,SAAI,GAAW,+CAAqB,CAAC;QAErC,eAAU,GAAuB,8CAAoB,CAAC;IAEG,CAAC;IAEnE,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,iBAA+C;QAE/C,MAAM,IAAI,GAAG,IAAI,qBAAc,CAAC,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9E,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,MAAM,CAAC,OAA+B,EAAE,EAAU;QACxD,MAAM,IAAI,GAAG,IAAI,qBAAc,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5E,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;;AAvBF,kCAwBC;AAvBc,gBAAI,GAAW,+CAAqB,AAAhC,CAAiC;AAyBpD;;;;;GAKG;AACU,QAAA,UAAU,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,oBAAoB,CACnC,OAA0B;IAE1B,MAAM,iBAAkB,SAAQ,WAAW;QAC1C;YACC,KAAK,CAAC,OAAO,CAAC,CAAC;QAChB,CAAC;KACD;IACD,OAAO,IAAA,iCAAsB,EAAQ,iBAAiB,CAAC,CAAC;AACzD,CAAC;AATD,oDASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport {\n\ttype ISharedObjectKind,\n\tcreateSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport {\n\tSharedTree as SharedTreeImpl,\n\ttype ISharedTree,\n\ttype SharedTreeOptions,\n\ttype SharedTreeOptionsInternal,\n} from \"./shared-tree/index.js\";\nimport type { ITree } from \"./simple-tree/index.js\";\n\nimport { SharedTreeFactoryType, SharedTreeAttributes } from \"./sharedTreeAttributes.js\";\n\n/**\n * A channel factory that creates an {@link ITree}.\n */\nexport class TreeFactory implements IChannelFactory<ISharedTree> {\n\tpublic static Type: string = SharedTreeFactoryType;\n\tpublic readonly type: string = SharedTreeFactoryType;\n\n\tpublic readonly attributes: IChannelAttributes = SharedTreeAttributes;\n\n\tpublic constructor(private readonly options: SharedTreeOptionsInternal) {}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tchannelAttributes: Readonly<IChannelAttributes>,\n\t): Promise<ISharedTree> {\n\t\tconst tree = new SharedTreeImpl(id, runtime, channelAttributes, this.options);\n\t\tawait tree.load(services);\n\t\treturn tree;\n\t}\n\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): ISharedTree {\n\t\tconst tree = new SharedTreeImpl(id, runtime, this.attributes, this.options);\n\t\ttree.initializeLocal();\n\t\treturn tree;\n\t}\n}\n\n/**\n * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees\n * of objects, arrays, and other data types.\n * @legacy\n * @alpha\n */\nexport const SharedTree = configuredSharedTree({});\n\n/**\n * {@link SharedTree} but allowing a non-default configuration.\n * @remarks\n * This is useful for debugging and testing to opt into extra validation or see if opting out of some optimizations fixes an issue.\n * @example\n * ```typescript\n * import {\n * \tForestType,\n * \tTreeCompressionStrategy,\n * \tconfiguredSharedTree,\n * \ttypeboxValidator,\n * \t// eslint-disable-next-line import/no-internal-modules\n * } from \"@fluidframework/tree/internal\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestType.Reference,\n * \tjsonValidator: typeboxValidator,\n * \ttreeEncodeType: TreeCompressionStrategy.Uncompressed,\n * });\n * ```\n * @privateRemarks\n * This should be legacy, but has to be internal due to limitations of API tagging preventing it from being both alpha and alpha+legacy.\n * TODO:\n * Expose Ajv validator for better error message quality somehow.\n * Maybe as part of a test utils or dev-tool package?\n * @internal\n */\nexport function configuredSharedTree(\n\toptions: SharedTreeOptions,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tclass ConfiguredFactory extends TreeFactory {\n\t\tpublic constructor() {\n\t\t\tsuper(options);\n\t\t}\n\t}\n\treturn createSharedObjectKind<ITree>(ConfiguredFactory);\n}\n"]}
1
+ {"version":3,"file":"treeFactory.js","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAkBH,0EAMqD;AAqBrD,uEAAwF;AACxF,8CAA4C;AAC5C,qDAA0D;AAC1D,uEAAsE;AACtE,kEAA2D;AAU3D;;GAEG;AACH,MAAM,cAAe,SAAQ,uBAAY;IAKxC,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EAC9B,YAAuC,EACvC,yBAAiC,mBAAmB;QAEpD,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,CAAC,C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;AAyBpD;;;;;GAKG;AACU,QAAA,UAAU,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,oBAAoB,CACnC,OAA0B;IAE1B,MAAM,iBAAkB,SAAQ,WAAW;QAC1C;YACC,KAAK,CAAC,OAAO,CAAC,CAAC;QAChB,CAAC;KACD;IACD,OAAO,IAAA,iCAAsB,EAAQ,iBAAiB,CAAC,CAAC;AACzD,CAAC;AATD,oDASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tITelemetryContext,\n\tIExperimentalIncrementalSummaryContext,\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport {\n\ttype IFluidSerializer,\n\ttype ISharedObject,\n\ttype ISharedObjectKind,\n\tSharedObject,\n\tcreateSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type {\n\tSchematizingSimpleTreeView,\n\tSharedTreeContentSnapshot,\n\tSharedTreeOptions,\n\tSharedTreeOptionsInternal,\n\tSharedTreeEditBuilder,\n\tSharedTreeChange,\n\tITreePrivate,\n} from \"./shared-tree/index.js\";\nimport type {\n\tImplicitFieldSchema,\n\tITree,\n\tReadSchema,\n\tSimpleTreeSchema,\n\tTreeView,\n\tTreeViewConfiguration,\n\tUnsafeUnknownSchema,\n\tVerboseTree,\n} from \"./simple-tree/index.js\";\nimport { SharedTreeFactoryType, SharedTreeAttributes } from \"./sharedTreeAttributes.js\";\nimport { Breakable } from \"./util/index.js\";\nimport { SharedTreeKernel } from \"./shared-tree/index.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { fail } from \"@fluidframework/core-utils/internal\";\nimport type { SharedTreeCore } from \"./shared-tree-core/index.js\";\n\n/**\n * {@link ITreePrivate} extended with ISharedObject.\n * @remarks\n * This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.\n */\nexport interface ISharedTree extends ISharedObject, ITreePrivate {}\n\n/**\n * Shared object wrapping {@link SharedTreeKernel}.\n */\nclass SharedTreeImpl extends SharedObject implements ISharedTree {\n\tprivate readonly breaker: Breakable = new Breakable(\"Shared Tree\");\n\n\tpublic readonly kernel: SharedTreeKernel;\n\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\toptionsParam: SharedTreeOptionsInternal,\n\t\ttelemetryContextPrefix: string = \"fluid_sharedTree_\",\n\t) {\n\t\tsuper(id, runtime, attributes, telemetryContextPrefix);\n\t\tif (runtime.idCompressor === undefined) {\n\t\t\tthrow new UsageError(\"IdCompressor must be enabled to use SharedTree\");\n\t\t}\n\t\tthis.kernel = new SharedTreeKernel(\n\t\t\tthis.breaker,\n\t\t\tthis,\n\t\t\tthis.serializer,\n\t\t\t(content, localOpMetadata) => this.submitLocalMessage(content, localOpMetadata),\n\t\t\t() => this.deltaManager.lastSequenceNumber,\n\t\t\tthis.logger,\n\t\t\truntime.idCompressor,\n\t\t\toptionsParam,\n\t\t);\n\t}\n\n\tpublic summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats {\n\t\treturn this.kernel.summarizeCore(serializer, telemetryContext, incrementalSummaryContext);\n\t}\n\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tfail(0xb75 /* processCore should not be called on SharedTree */);\n\t}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tthis.kernel.processMessagesCore(messagesCollection);\n\t}\n\n\tprotected onDisconnect(): void {\n\t\tthis.kernel.onDisconnect();\n\t}\n\n\tpublic exportVerbose(): VerboseTree | undefined {\n\t\treturn this.kernel.exportVerbose();\n\t}\n\n\tpublic exportSimpleSchema(): SimpleTreeSchema {\n\t\treturn this.kernel.exportSimpleSchema();\n\t}\n\n\tpublic contentSnapshot(): SharedTreeContentSnapshot {\n\t\treturn this.kernel.contentSnapshot();\n\t}\n\n\t// For the new TreeViewAlpha API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>>;\n\n\t// For the old TreeView API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): SchematizingSimpleTreeView<TRoot> & TreeView<TRoot>;\n\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>> {\n\t\treturn this.kernel.viewWith(config);\n\t}\n\n\tprotected override async loadCore(services: IChannelStorageService): Promise<void> {\n\t\tawait this.kernel.loadCore(services);\n\t}\n\n\tprotected override didAttach(): void {\n\t\tthis.kernel.didAttach();\n\t}\n\n\tprotected override applyStashedOp(\n\t\t...args: Parameters<\n\t\t\tSharedTreeCore<SharedTreeEditBuilder, SharedTreeChange>[\"applyStashedOp\"]\n\t\t>\n\t): void {\n\t\tthis.kernel.applyStashedOp(...args);\n\t}\n\n\tprotected override reSubmitCore(\n\t\t...args: Parameters<\n\t\t\tSharedTreeCore<SharedTreeEditBuilder, SharedTreeChange>[\"reSubmitCore\"]\n\t\t>\n\t): void {\n\t\tthis.kernel.reSubmitCore(...args);\n\t}\n}\n\n/**\n * A channel factory that creates an {@link ITree}.\n */\nclass TreeFactory implements IChannelFactory<ISharedTree> {\n\tpublic static Type: string = SharedTreeFactoryType;\n\tpublic readonly type: string = SharedTreeFactoryType;\n\n\tpublic readonly attributes: IChannelAttributes = SharedTreeAttributes;\n\n\tpublic constructor(private readonly options: SharedTreeOptionsInternal) {}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tchannelAttributes: Readonly<IChannelAttributes>,\n\t): Promise<ISharedTree> {\n\t\tconst tree = new SharedTreeImpl(id, runtime, channelAttributes, this.options);\n\t\tawait tree.load(services);\n\t\treturn tree;\n\t}\n\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): ISharedTree {\n\t\tconst tree = new SharedTreeImpl(id, runtime, this.attributes, this.options);\n\t\ttree.initializeLocal();\n\t\treturn tree;\n\t}\n}\n\n/**\n * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees\n * of objects, arrays, and other data types.\n * @legacy\n * @alpha\n */\nexport const SharedTree = configuredSharedTree({});\n\n/**\n * {@link SharedTree} but allowing a non-default configuration.\n * @remarks\n * This is useful for debugging and testing to opt into extra validation or see if opting out of some optimizations fixes an issue.\n * @example\n * ```typescript\n * import {\n * \tForestType,\n * \tTreeCompressionStrategy,\n * \tconfiguredSharedTree,\n * \ttypeboxValidator,\n * \t// eslint-disable-next-line import/no-internal-modules\n * } from \"@fluidframework/tree/internal\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestType.Reference,\n * \tjsonValidator: typeboxValidator,\n * \ttreeEncodeType: TreeCompressionStrategy.Uncompressed,\n * });\n * ```\n * @privateRemarks\n * This should be legacy, but has to be internal due to limitations of API tagging preventing it from being both alpha and alpha+legacy.\n * TODO:\n * Expose Ajv validator for better error message quality somehow.\n * Maybe as part of a test utils or dev-tool package?\n * @internal\n */\nexport function configuredSharedTree(\n\toptions: SharedTreeOptions,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tclass ConfiguredFactory extends TreeFactory {\n\t\tpublic constructor() {\n\t\t\tsuper(options);\n\t\t}\n\t}\n\treturn createSharedObjectKind<ITree>(ConfiguredFactory);\n}\n"]}
package/lib/alpha.d.ts CHANGED
@@ -20,22 +20,15 @@ export {
20
20
  FieldProps,
21
21
  FieldSchema,
22
22
  FieldSchemaMetadata,
23
- FieldSchemaUnsafe,
24
23
  ITree,
25
24
  ITreeConfigurationOptions,
26
25
  ITreeViewConfiguration,
27
26
  ImplicitAllowedTypes,
28
- ImplicitAllowedTypesUnsafe,
29
27
  ImplicitFieldSchema,
30
- ImplicitFieldSchemaUnsafe,
31
28
  Input,
32
- InsertableObjectFromSchemaRecordUnsafe,
33
29
  InsertableTreeFieldFromImplicitField,
34
- InsertableTreeFieldFromImplicitFieldUnsafe,
35
30
  InsertableTreeNodeFromAllowedTypes,
36
- InsertableTreeNodeFromAllowedTypesUnsafe,
37
31
  InsertableTreeNodeFromImplicitAllowedTypes,
38
- InsertableTreeNodeFromImplicitAllowedTypesUnsafe,
39
32
  InsertableTypedNode,
40
33
  InternalTreeNode,
41
34
  IsListener,
@@ -51,6 +44,7 @@ export {
51
44
  NodeKind,
52
45
  NodeSchemaMetadata,
53
46
  NodeSchemaOptions,
47
+ ObjectFromSchemaRecord,
54
48
  Off,
55
49
  ReadonlyArrayNode,
56
50
  RestrictiveReadonlyRecord,
@@ -63,25 +57,22 @@ export {
63
57
  SchemaFactory,
64
58
  SchemaStatics,
65
59
  SimpleNodeSchemaBase,
60
+ System_Unsafe,
66
61
  TransactionConstraint,
67
62
  Tree,
68
63
  TreeArrayNode,
69
- TreeArrayNodeUnsafe,
70
64
  TreeChangeEvents,
71
65
  TreeFieldFromImplicitField,
72
66
  TreeLeafValue,
73
67
  TreeMapNode,
74
- TreeMapNodeUnsafe,
75
68
  TreeNode,
76
69
  TreeNodeApi,
77
70
  TreeNodeFromImplicitAllowedTypes,
78
71
  TreeNodeSchema,
79
72
  TreeNodeSchemaClass,
80
- TreeNodeSchemaClassUnsafe,
81
73
  TreeNodeSchemaCore,
82
74
  TreeNodeSchemaNonClass,
83
75
  TreeObjectNode,
84
- TreeObjectNodeUnsafe,
85
76
  TreeStatus,
86
77
  TreeView,
87
78
  TreeViewConfiguration,
@@ -195,6 +186,7 @@ export {
195
186
  ViewContent,
196
187
  VoidTransactionCallbackStatus,
197
188
  adaptEnum,
189
+ allowUnused,
198
190
  asTreeViewAlpha,
199
191
  cloneWithReplacements,
200
192
  comparePersistedSchema,
package/lib/beta.d.ts CHANGED
@@ -20,22 +20,15 @@ export {
20
20
  FieldProps,
21
21
  FieldSchema,
22
22
  FieldSchemaMetadata,
23
- FieldSchemaUnsafe,
24
23
  ITree,
25
24
  ITreeConfigurationOptions,
26
25
  ITreeViewConfiguration,
27
26
  ImplicitAllowedTypes,
28
- ImplicitAllowedTypesUnsafe,
29
27
  ImplicitFieldSchema,
30
- ImplicitFieldSchemaUnsafe,
31
28
  Input,
32
- InsertableObjectFromSchemaRecordUnsafe,
33
29
  InsertableTreeFieldFromImplicitField,
34
- InsertableTreeFieldFromImplicitFieldUnsafe,
35
30
  InsertableTreeNodeFromAllowedTypes,
36
- InsertableTreeNodeFromAllowedTypesUnsafe,
37
31
  InsertableTreeNodeFromImplicitAllowedTypes,
38
- InsertableTreeNodeFromImplicitAllowedTypesUnsafe,
39
32
  InsertableTypedNode,
40
33
  InternalTreeNode,
41
34
  IsListener,
@@ -51,6 +44,7 @@ export {
51
44
  NodeKind,
52
45
  NodeSchemaMetadata,
53
46
  NodeSchemaOptions,
47
+ ObjectFromSchemaRecord,
54
48
  Off,
55
49
  ReadonlyArrayNode,
56
50
  RestrictiveReadonlyRecord,
@@ -63,25 +57,22 @@ export {
63
57
  SchemaFactory,
64
58
  SchemaStatics,
65
59
  SimpleNodeSchemaBase,
60
+ System_Unsafe,
66
61
  TransactionConstraint,
67
62
  Tree,
68
63
  TreeArrayNode,
69
- TreeArrayNodeUnsafe,
70
64
  TreeChangeEvents,
71
65
  TreeFieldFromImplicitField,
72
66
  TreeLeafValue,
73
67
  TreeMapNode,
74
- TreeMapNodeUnsafe,
75
68
  TreeNode,
76
69
  TreeNodeApi,
77
70
  TreeNodeFromImplicitAllowedTypes,
78
71
  TreeNodeSchema,
79
72
  TreeNodeSchemaClass,
80
- TreeNodeSchemaClassUnsafe,
81
73
  TreeNodeSchemaCore,
82
74
  TreeNodeSchemaNonClass,
83
75
  TreeObjectNode,
84
- TreeObjectNodeUnsafe,
85
76
  TreeStatus,
86
77
  TreeView,
87
78
  TreeViewConfiguration,
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export { EmptyKey, type TreeType, type Value, type TreeValue, AnchorSet, type DetachedField, type UpPath, type NormalizedUpPath, type INormalizedUpPath, type NormalizedFieldUpPath, type Range, type RangeUpPath, type PlaceUpPath, type PlaceIndex, type NodeIndex, type FieldUpPath, type Anchor, type RootField, type ChildCollection, type ChildLocation, type FieldMapObject, type NodeData, type GenericTreeNode, type JsonableTree, EncodedJsonableTree, rootFieldKey, rootField, type ITreeCursor, CursorLocationType, type ITreeCursorSynchronous, castCursorToSynchronous, type GenericFieldsNode, type AnchorLocator, genericTreeKeys, getGenericTreeField, genericTreeDeleteIfEmpty, getDepth, mapCursorField, mapCursorFields, iterateCursorField, type MapTree, detachedFieldAsKey, keyAsDetachedField, visitDelta, createAnnouncedVisitor, combineVisitors, announceDelta, applyDelta, makeDetachedFieldIndex, setGenericTreeField, type DeltaVisitor, type AnnouncedVisitor, SparseNode, getDescendant, compareUpPaths, clonePath, topDownPath, compareFieldUpPaths, forEachNode, forEachNodeInSubtree, forEachField, type PathRootPrefix, deltaForRootInitialization, makeDetachedNodeId, offsetDetachId, emptyDelta, type AnchorSlot, type AnchorNode, anchorSlot, type UpPathDefault, isDetachedUpPath, inCursorField, inCursorNode, type AnchorEvents, type AnchorSetRootEvents, type ProtoNodes, CursorMarker, isCursor, DetachedFieldIndex, type ForestRootId, getDetachedFieldContainingPath, aboveRootPlaceholder, type DeltaRoot, type DeltaMark, type DeltaDetachedNodeId, type DeltaFieldMap, type DeltaDetachedNodeChanges, type DeltaDetachedNodeBuild, type DeltaDetachedNodeDestruction, type DeltaDetachedNodeRename, type DeltaFieldChanges, type ExclusiveMapTree, deepCopyMapTree, type TreeChunk, dummyRoot, cursorChunk, tryGetChunk, type ChunkedCursor, } from "./tree/index.js";
6
6
  export { TreeNavigationResult, type IEditableForest, type IForestSubscription, type TreeLocation, type FieldLocation, type ForestLocation, type ITreeSubscriptionCursor, ITreeSubscriptionCursorState, type FieldAnchor, moveToDetachedField, type ForestEvents, } from "./forest/index.js";
7
- export { type FieldKey, type TreeNodeSchemaIdentifier, type TreeFieldStoredSchema, ValueSchema, TreeNodeStoredSchema, type TreeStoredSchemaSubscription, type MutableTreeStoredSchema, type FieldKindIdentifier, type FieldKindData, type TreeTypeSet, type TreeStoredSchema, TreeStoredSchemaRepository, schemaDataIsEmpty, type SchemaEvents, forbiddenFieldKindIdentifier, identifierFieldKindIdentifier, storedEmptyFieldSchema, type StoredSchemaCollection, schemaFormat, LeafNodeStoredSchema, ObjectNodeStoredSchema, MapNodeStoredSchema, toTreeNodeSchemaDataFormat, decodeFieldSchema, encodeFieldSchema, storedSchemaDecodeDispatcher, type ErasedTreeNodeSchemaDataFormat, type SchemaAndPolicy, Multiplicity, type SchemaPolicy, } from "./schema-stored/index.js";
7
+ export { type FieldKey, type TreeNodeSchemaIdentifier, type TreeFieldStoredSchema, ValueSchema, TreeNodeStoredSchema, type TreeStoredSchemaSubscription, type MutableTreeStoredSchema, type FieldKindIdentifier, type FieldKindData, type TreeTypeSet, type TreeStoredSchema, TreeStoredSchemaRepository, schemaDataIsEmpty, type SchemaEvents, forbiddenFieldKindIdentifier, identifierFieldKindIdentifier, storedEmptyFieldSchema, type StoredSchemaCollection, schemaFormat, LeafNodeStoredSchema, ObjectNodeStoredSchema, MapNodeStoredSchema, decodeFieldSchema, encodeFieldSchema, storedSchemaDecodeDispatcher, type SchemaAndPolicy, Multiplicity, type SchemaPolicy, } from "./schema-stored/index.js";
8
8
  export { type ChangeFamily, type ChangeFamilyCodec, type ChangeEncodingContext, type ChangeFamilyEditor, EditBuilder, } from "./change-family/index.js";
9
9
  export { areEqualChangeAtomIds, areEqualChangeAtomIdOpts, makeChangeAtomId, asChangeAtomId, type ChangeRebaser, findAncestor, findCommonAncestor, type GraphCommit, CommitKind, type CommitMetadata, type RevisionTag, RevisionTagSchema, RevisionTagCodec, type ChangesetLocalId, type ChangeAtomId, type ChangeAtomIdMap, type TaggedChange, makeAnonChange, tagChange, mapTaggedChange, tagRollbackInverse, SessionIdSchema, mintCommit, rebaseBranch, type BranchRebaseResult, rebaseChange, rebaseChangeOverChanges, type RevisionMetadataSource, revisionMetadataSourceFromInfo, type RevisionInfo, type EncodedRevisionTag, type EncodedChangeAtomId, taggedAtomId, taggedOptAtomId, offsetChangeAtomId, subtractChangeAtomIds, replaceAtomRevisions, replaceChange, type RebaseStats, type RebaseStatsWithDuration, isAncestor, type ChangeAtomIdRangeMap, newChangeAtomIdRangeMap, compareRevisions, } from "./rebase/index.js";
10
10
  export { type Adapters, AdaptedViewSchema, type TreeAdapter, AllowedUpdateType, } from "./schema-view/index.js";