@fluidframework/tree 2.33.2 → 2.40.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 (621) hide show
  1. package/.vscode/settings.json +2 -0
  2. package/CHANGELOG.md +64 -0
  3. package/api-report/tree.alpha.api.md +124 -51
  4. package/api-report/tree.beta.api.md +31 -27
  5. package/api-report/tree.legacy.alpha.api.md +24 -23
  6. package/api-report/tree.legacy.public.api.md +24 -23
  7. package/api-report/tree.public.api.md +24 -23
  8. package/dist/alpha.d.ts +17 -1
  9. package/dist/beta.d.ts +2 -0
  10. package/dist/codec/codec.d.ts +5 -1
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +6 -2
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/index.d.ts +1 -1
  15. package/dist/codec/index.d.ts.map +1 -1
  16. package/dist/codec/index.js +2 -1
  17. package/dist/codec/index.js.map +1 -1
  18. package/dist/core/index.d.ts +2 -2
  19. package/dist/core/index.d.ts.map +1 -1
  20. package/dist/core/index.js +2 -3
  21. package/dist/core/index.js.map +1 -1
  22. package/dist/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
  23. package/dist/core/schema-stored/formatV1.d.ts.map +1 -0
  24. package/dist/core/schema-stored/{format.js → formatV1.js} +1 -1
  25. package/dist/core/schema-stored/formatV1.js.map +1 -0
  26. package/dist/core/schema-stored/index.d.ts +3 -3
  27. package/dist/core/schema-stored/index.d.ts.map +1 -1
  28. package/dist/core/schema-stored/index.js +3 -3
  29. package/dist/core/schema-stored/index.js.map +1 -1
  30. package/dist/core/schema-stored/schema.d.ts +3 -1
  31. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  32. package/dist/core/schema-stored/schema.js +8 -6
  33. package/dist/core/schema-stored/schema.js.map +1 -1
  34. package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  35. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  36. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  37. package/dist/core/schema-view/index.d.ts +1 -1
  38. package/dist/core/schema-view/index.d.ts.map +1 -1
  39. package/dist/core/schema-view/index.js +1 -2
  40. package/dist/core/schema-view/index.js.map +1 -1
  41. package/dist/core/schema-view/view.d.ts +0 -27
  42. package/dist/core/schema-view/view.d.ts.map +1 -1
  43. package/dist/core/schema-view/view.js +1 -35
  44. package/dist/core/schema-view/view.js.map +1 -1
  45. package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
  46. package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  47. package/dist/core/tree/persistedTreeTextFormat.js +1 -1
  48. package/dist/core/tree/persistedTreeTextFormat.js.map +1 -1
  49. package/dist/feature-libraries/forest-summary/format.d.ts +2 -2
  50. package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
  51. package/dist/feature-libraries/forest-summary/format.js +1 -1
  52. package/dist/feature-libraries/forest-summary/format.js.map +1 -1
  53. package/dist/feature-libraries/index.d.ts +1 -1
  54. package/dist/feature-libraries/index.d.ts.map +1 -1
  55. package/dist/feature-libraries/index.js +4 -2
  56. package/dist/feature-libraries/index.js.map +1 -1
  57. package/dist/feature-libraries/mapTreeCursor.d.ts +3 -3
  58. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  59. package/dist/feature-libraries/mapTreeCursor.js +2 -2
  60. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  61. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
  62. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  63. package/dist/feature-libraries/modular-schema/modularChangeFormat.js +2 -2
  64. package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  65. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
  66. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  67. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -5
  68. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  69. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  70. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  71. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  72. package/dist/feature-libraries/schema-index/codec.d.ts +34 -5
  73. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  74. package/dist/feature-libraries/schema-index/codec.js +63 -9
  75. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  76. package/{lib/feature-libraries/schema-index/format.d.ts → dist/feature-libraries/schema-index/formatV1.d.ts} +9 -9
  77. package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
  78. package/dist/feature-libraries/schema-index/{format.js → formatV1.js} +4 -4
  79. package/dist/feature-libraries/schema-index/formatV1.js.map +1 -0
  80. package/dist/feature-libraries/schema-index/index.d.ts +2 -2
  81. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  82. package/dist/feature-libraries/schema-index/index.js +6 -3
  83. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  84. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
  85. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  86. package/dist/feature-libraries/schema-index/schemaSummarizer.js +4 -4
  87. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  88. package/dist/index.d.ts +3 -2
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +10 -8
  91. package/dist/index.js.map +1 -1
  92. package/dist/internalTypes.d.ts +0 -1
  93. package/dist/internalTypes.d.ts.map +1 -1
  94. package/dist/internalTypes.js.map +1 -1
  95. package/dist/jsonDomainSchema.d.ts +2 -2
  96. package/dist/jsonDomainSchema.js +2 -2
  97. package/dist/jsonDomainSchema.js.map +1 -1
  98. package/dist/legacy.d.ts +2 -0
  99. package/dist/packageVersion.d.ts +1 -1
  100. package/dist/packageVersion.js +1 -1
  101. package/dist/packageVersion.js.map +1 -1
  102. package/dist/public.d.ts +2 -0
  103. package/dist/serializableDomainSchema.d.ts +3 -3
  104. package/dist/serializableDomainSchema.js +2 -2
  105. package/dist/serializableDomainSchema.js.map +1 -1
  106. package/dist/shared-tree/independentView.d.ts +1 -1
  107. package/dist/shared-tree/independentView.d.ts.map +1 -1
  108. package/dist/shared-tree/independentView.js +1 -1
  109. package/dist/shared-tree/independentView.js.map +1 -1
  110. package/dist/shared-tree/index.d.ts +4 -3
  111. package/dist/shared-tree/index.d.ts.map +1 -1
  112. package/dist/shared-tree/index.js +6 -5
  113. package/dist/shared-tree/index.js.map +1 -1
  114. package/dist/shared-tree/schematizeTree.d.ts +10 -11
  115. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  116. package/dist/shared-tree/schematizeTree.js +11 -36
  117. package/dist/shared-tree/schematizeTree.js.map +1 -1
  118. package/dist/shared-tree/schematizingTreeView.d.ts +3 -3
  119. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  120. package/dist/shared-tree/schematizingTreeView.js +4 -7
  121. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  122. package/dist/shared-tree/sharedTree.d.ts +28 -3
  123. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  124. package/dist/shared-tree/sharedTree.js +29 -3
  125. package/dist/shared-tree/sharedTree.js.map +1 -1
  126. package/dist/shared-tree/{treeApi.d.ts → tree.d.ts} +58 -34
  127. package/dist/shared-tree/tree.d.ts.map +1 -0
  128. package/dist/shared-tree/{treeApi.js → tree.js} +6 -6
  129. package/dist/shared-tree/tree.js.map +1 -0
  130. package/{lib/shared-tree/treeApiAlpha.d.ts → dist/shared-tree/treeAlpha.d.ts} +24 -14
  131. package/dist/shared-tree/treeAlpha.d.ts.map +1 -0
  132. package/dist/shared-tree/{treeApiAlpha.js → treeAlpha.js} +7 -5
  133. package/dist/shared-tree/treeAlpha.js.map +1 -0
  134. package/dist/shared-tree-core/branchCommitEnricher.d.ts +0 -1
  135. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  136. package/dist/shared-tree-core/branchCommitEnricher.js +0 -1
  137. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  138. package/dist/shared-tree-core/transactionEnricher.d.ts +1 -1
  139. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  140. package/dist/shared-tree-core/transactionEnricher.js +4 -1
  141. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  142. package/dist/simple-tree/api/conciseTree.d.ts +1 -1
  143. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  144. package/dist/simple-tree/api/configuration.d.ts +177 -0
  145. package/dist/simple-tree/api/configuration.d.ts.map +1 -0
  146. package/dist/simple-tree/api/configuration.js +163 -0
  147. package/dist/simple-tree/api/configuration.js.map +1 -0
  148. package/dist/simple-tree/api/getJsonSchema.js +2 -2
  149. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  150. package/dist/simple-tree/api/index.d.ts +9 -5
  151. package/dist/simple-tree/api/index.d.ts.map +1 -1
  152. package/dist/simple-tree/api/index.js +9 -7
  153. package/dist/simple-tree/api/index.js.map +1 -1
  154. package/dist/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
  155. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
  156. package/dist/simple-tree/api/{view.js → schemaCompatibilityTester.js} +9 -9
  157. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
  158. package/dist/simple-tree/api/schemaFactory.d.ts +25 -10
  159. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  160. package/dist/simple-tree/api/schemaFactory.js +27 -12
  161. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  162. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
  163. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  164. package/dist/simple-tree/api/schemaFactoryAlpha.js +2 -2
  165. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  166. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
  167. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  168. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  169. package/dist/simple-tree/api/schemaFromSimple.d.ts +1 -1
  170. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  171. package/dist/simple-tree/api/schemaFromSimple.js +1 -1
  172. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  173. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  174. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  175. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  176. package/dist/simple-tree/api/storedSchema.d.ts +11 -10
  177. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  178. package/dist/simple-tree/api/storedSchema.js +16 -11
  179. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  180. package/dist/simple-tree/api/tree.d.ts +30 -174
  181. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  182. package/dist/simple-tree/api/tree.js +1 -156
  183. package/dist/simple-tree/api/tree.js.map +1 -1
  184. package/{lib/simple-tree/api/treeApiBeta.d.ts → dist/simple-tree/api/treeBeta.d.ts} +17 -6
  185. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -0
  186. package/dist/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
  187. package/dist/simple-tree/api/treeBeta.js.map +1 -0
  188. package/dist/simple-tree/api/treeChangeEvents.d.ts +83 -0
  189. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
  190. package/dist/simple-tree/api/treeChangeEvents.js +7 -0
  191. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -0
  192. package/dist/simple-tree/api/treeNodeApi.d.ts +2 -1
  193. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  194. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  195. package/dist/simple-tree/api/typesUnsafe.d.ts +4 -9
  196. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  197. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  198. package/dist/simple-tree/arrayNode.d.ts +30 -2
  199. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  200. package/dist/simple-tree/arrayNode.js +3 -2
  201. package/dist/simple-tree/arrayNode.js.map +1 -1
  202. package/dist/simple-tree/arrayNodeTypes.d.ts +3 -3
  203. package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -1
  204. package/dist/simple-tree/arrayNodeTypes.js.map +1 -1
  205. package/dist/simple-tree/core/getOrCreateNode.d.ts +1 -1
  206. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  207. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  208. package/dist/simple-tree/core/index.d.ts +2 -1
  209. package/dist/simple-tree/core/index.d.ts.map +1 -1
  210. package/dist/simple-tree/core/index.js +5 -5
  211. package/dist/simple-tree/core/index.js.map +1 -1
  212. package/dist/simple-tree/core/treeNode.d.ts +94 -0
  213. package/dist/simple-tree/core/treeNode.d.ts.map +1 -0
  214. package/dist/simple-tree/core/treeNode.js +123 -0
  215. package/dist/simple-tree/core/treeNode.js.map +1 -0
  216. package/dist/simple-tree/core/treeNodeKernel.d.ts +2 -1
  217. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  218. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  219. package/dist/simple-tree/core/treeNodeSchema.d.ts +3 -1
  220. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  221. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  222. package/dist/simple-tree/core/types.d.ts +0 -165
  223. package/dist/simple-tree/core/types.d.ts.map +1 -1
  224. package/dist/simple-tree/core/types.js +1 -113
  225. package/dist/simple-tree/core/types.js.map +1 -1
  226. package/dist/simple-tree/core/withType.d.ts +1 -1
  227. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  228. package/dist/simple-tree/core/withType.js.map +1 -1
  229. package/dist/simple-tree/index.d.ts +4 -4
  230. package/dist/simple-tree/index.d.ts.map +1 -1
  231. package/dist/simple-tree/index.js +4 -3
  232. package/dist/simple-tree/index.js.map +1 -1
  233. package/dist/simple-tree/mapNode.d.ts +2 -2
  234. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  235. package/dist/simple-tree/mapNode.js +1 -1
  236. package/dist/simple-tree/mapNode.js.map +1 -1
  237. package/dist/simple-tree/mapNodeTypes.d.ts +3 -3
  238. package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -1
  239. package/dist/simple-tree/mapNodeTypes.js.map +1 -1
  240. package/dist/simple-tree/objectNode.d.ts +18 -5
  241. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  242. package/dist/simple-tree/objectNode.js +4 -3
  243. package/dist/simple-tree/objectNode.js.map +1 -1
  244. package/dist/simple-tree/objectNodeTypes.d.ts +4 -4
  245. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  246. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  247. package/dist/simple-tree/schemaTypes.d.ts +164 -13
  248. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  249. package/dist/simple-tree/schemaTypes.js +107 -8
  250. package/dist/simple-tree/schemaTypes.js.map +1 -1
  251. package/dist/simple-tree/toStoredSchema.d.ts +8 -8
  252. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  253. package/dist/simple-tree/toStoredSchema.js +27 -32
  254. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  255. package/dist/simple-tree/treeNodeValid.js +2 -2
  256. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  257. package/dist/tableSchema.d.ts +455 -125
  258. package/dist/tableSchema.d.ts.map +1 -1
  259. package/dist/tableSchema.js +398 -101
  260. package/dist/tableSchema.js.map +1 -1
  261. package/dist/treeFactory.d.ts +1 -1
  262. package/dist/treeFactory.d.ts.map +1 -1
  263. package/dist/treeFactory.js +30 -75
  264. package/dist/treeFactory.js.map +1 -1
  265. package/dist/util/typeUtils.d.ts +1 -1
  266. package/dist/util/typeUtils.js.map +1 -1
  267. package/lib/alpha.d.ts +17 -1
  268. package/lib/beta.d.ts +2 -0
  269. package/lib/codec/codec.d.ts +5 -1
  270. package/lib/codec/codec.d.ts.map +1 -1
  271. package/lib/codec/codec.js +5 -1
  272. package/lib/codec/codec.js.map +1 -1
  273. package/lib/codec/index.d.ts +1 -1
  274. package/lib/codec/index.d.ts.map +1 -1
  275. package/lib/codec/index.js +1 -1
  276. package/lib/codec/index.js.map +1 -1
  277. package/lib/core/index.d.ts +2 -2
  278. package/lib/core/index.d.ts.map +1 -1
  279. package/lib/core/index.js +2 -2
  280. package/lib/core/index.js.map +1 -1
  281. package/lib/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
  282. package/lib/core/schema-stored/formatV1.d.ts.map +1 -0
  283. package/lib/core/schema-stored/{format.js → formatV1.js} +1 -1
  284. package/lib/core/schema-stored/formatV1.js.map +1 -0
  285. package/lib/core/schema-stored/index.d.ts +3 -3
  286. package/lib/core/schema-stored/index.d.ts.map +1 -1
  287. package/lib/core/schema-stored/index.js +2 -2
  288. package/lib/core/schema-stored/index.js.map +1 -1
  289. package/lib/core/schema-stored/schema.d.ts +3 -1
  290. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  291. package/lib/core/schema-stored/schema.js +3 -1
  292. package/lib/core/schema-stored/schema.js.map +1 -1
  293. package/lib/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  294. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  295. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  296. package/lib/core/schema-view/index.d.ts +1 -1
  297. package/lib/core/schema-view/index.d.ts.map +1 -1
  298. package/lib/core/schema-view/index.js +1 -1
  299. package/lib/core/schema-view/index.js.map +1 -1
  300. package/lib/core/schema-view/view.d.ts +0 -27
  301. package/lib/core/schema-view/view.d.ts.map +1 -1
  302. package/lib/core/schema-view/view.js +0 -34
  303. package/lib/core/schema-view/view.js.map +1 -1
  304. package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
  305. package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  306. package/lib/core/tree/persistedTreeTextFormat.js +2 -2
  307. package/lib/core/tree/persistedTreeTextFormat.js.map +1 -1
  308. package/lib/feature-libraries/forest-summary/format.d.ts +2 -2
  309. package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
  310. package/lib/feature-libraries/forest-summary/format.js +2 -2
  311. package/lib/feature-libraries/forest-summary/format.js.map +1 -1
  312. package/lib/feature-libraries/index.d.ts +1 -1
  313. package/lib/feature-libraries/index.d.ts.map +1 -1
  314. package/lib/feature-libraries/index.js +1 -1
  315. package/lib/feature-libraries/index.js.map +1 -1
  316. package/lib/feature-libraries/mapTreeCursor.d.ts +3 -3
  317. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  318. package/lib/feature-libraries/mapTreeCursor.js +2 -2
  319. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  320. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
  321. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  322. package/lib/feature-libraries/modular-schema/modularChangeFormat.js +3 -3
  323. package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  324. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
  325. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  326. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -6
  327. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  328. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  329. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  330. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
  331. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  332. package/lib/feature-libraries/schema-index/codec.d.ts +34 -5
  333. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  334. package/lib/feature-libraries/schema-index/codec.js +61 -9
  335. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  336. package/{dist/feature-libraries/schema-index/format.d.ts → lib/feature-libraries/schema-index/formatV1.d.ts} +9 -9
  337. package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
  338. package/lib/feature-libraries/schema-index/{format.js → formatV1.js} +5 -5
  339. package/lib/feature-libraries/schema-index/formatV1.js.map +1 -0
  340. package/lib/feature-libraries/schema-index/index.d.ts +2 -2
  341. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  342. package/lib/feature-libraries/schema-index/index.js +2 -2
  343. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  344. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
  345. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  346. package/lib/feature-libraries/schema-index/schemaSummarizer.js +5 -5
  347. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  348. package/lib/index.d.ts +3 -2
  349. package/lib/index.d.ts.map +1 -1
  350. package/lib/index.js +1 -0
  351. package/lib/index.js.map +1 -1
  352. package/lib/internalTypes.d.ts +0 -1
  353. package/lib/internalTypes.d.ts.map +1 -1
  354. package/lib/internalTypes.js.map +1 -1
  355. package/lib/jsonDomainSchema.d.ts +2 -2
  356. package/lib/jsonDomainSchema.js +2 -2
  357. package/lib/jsonDomainSchema.js.map +1 -1
  358. package/lib/legacy.d.ts +2 -0
  359. package/lib/packageVersion.d.ts +1 -1
  360. package/lib/packageVersion.js +1 -1
  361. package/lib/packageVersion.js.map +1 -1
  362. package/lib/public.d.ts +2 -0
  363. package/lib/serializableDomainSchema.d.ts +3 -3
  364. package/lib/serializableDomainSchema.js +2 -2
  365. package/lib/serializableDomainSchema.js.map +1 -1
  366. package/lib/shared-tree/independentView.d.ts +1 -1
  367. package/lib/shared-tree/independentView.d.ts.map +1 -1
  368. package/lib/shared-tree/independentView.js +2 -2
  369. package/lib/shared-tree/independentView.js.map +1 -1
  370. package/lib/shared-tree/index.d.ts +4 -3
  371. package/lib/shared-tree/index.d.ts.map +1 -1
  372. package/lib/shared-tree/index.js +3 -3
  373. package/lib/shared-tree/index.js.map +1 -1
  374. package/lib/shared-tree/schematizeTree.d.ts +10 -11
  375. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  376. package/lib/shared-tree/schematizeTree.js +12 -37
  377. package/lib/shared-tree/schematizeTree.js.map +1 -1
  378. package/lib/shared-tree/schematizingTreeView.d.ts +3 -3
  379. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  380. package/lib/shared-tree/schematizingTreeView.js +6 -9
  381. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  382. package/lib/shared-tree/sharedTree.d.ts +28 -3
  383. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  384. package/lib/shared-tree/sharedTree.js +29 -4
  385. package/lib/shared-tree/sharedTree.js.map +1 -1
  386. package/lib/shared-tree/{treeApi.d.ts → tree.d.ts} +58 -34
  387. package/lib/shared-tree/tree.d.ts.map +1 -0
  388. package/lib/shared-tree/{treeApi.js → tree.js} +5 -5
  389. package/lib/shared-tree/tree.js.map +1 -0
  390. package/{dist/shared-tree/treeApiAlpha.d.ts → lib/shared-tree/treeAlpha.d.ts} +24 -14
  391. package/lib/shared-tree/treeAlpha.d.ts.map +1 -0
  392. package/lib/shared-tree/{treeApiAlpha.js → treeAlpha.js} +8 -6
  393. package/lib/shared-tree/treeAlpha.js.map +1 -0
  394. package/lib/shared-tree-core/branchCommitEnricher.d.ts +0 -1
  395. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  396. package/lib/shared-tree-core/branchCommitEnricher.js +0 -1
  397. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  398. package/lib/shared-tree-core/transactionEnricher.d.ts +1 -1
  399. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  400. package/lib/shared-tree-core/transactionEnricher.js +4 -1
  401. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  402. package/lib/simple-tree/api/conciseTree.d.ts +1 -1
  403. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  404. package/lib/simple-tree/api/configuration.d.ts +177 -0
  405. package/lib/simple-tree/api/configuration.d.ts.map +1 -0
  406. package/lib/simple-tree/api/configuration.js +157 -0
  407. package/lib/simple-tree/api/configuration.js.map +1 -0
  408. package/lib/simple-tree/api/getJsonSchema.js +1 -1
  409. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  410. package/lib/simple-tree/api/index.d.ts +9 -5
  411. package/lib/simple-tree/api/index.d.ts.map +1 -1
  412. package/lib/simple-tree/api/index.js +5 -4
  413. package/lib/simple-tree/api/index.js.map +1 -1
  414. package/lib/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
  415. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
  416. package/lib/simple-tree/api/{view.js → schemaCompatibilityTester.js} +7 -7
  417. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
  418. package/lib/simple-tree/api/schemaFactory.d.ts +25 -10
  419. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  420. package/lib/simple-tree/api/schemaFactory.js +27 -12
  421. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  422. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
  423. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  424. package/lib/simple-tree/api/schemaFactoryAlpha.js +2 -2
  425. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  426. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
  427. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  428. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  429. package/lib/simple-tree/api/schemaFromSimple.d.ts +1 -1
  430. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  431. package/lib/simple-tree/api/schemaFromSimple.js +1 -1
  432. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  433. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  434. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  435. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  436. package/lib/simple-tree/api/storedSchema.d.ts +11 -10
  437. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  438. package/lib/simple-tree/api/storedSchema.js +20 -13
  439. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  440. package/lib/simple-tree/api/tree.d.ts +30 -174
  441. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  442. package/lib/simple-tree/api/tree.js +0 -152
  443. package/lib/simple-tree/api/tree.js.map +1 -1
  444. package/{dist/simple-tree/api/treeApiBeta.d.ts → lib/simple-tree/api/treeBeta.d.ts} +17 -6
  445. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -0
  446. package/lib/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
  447. package/lib/simple-tree/api/treeBeta.js.map +1 -0
  448. package/lib/simple-tree/api/treeChangeEvents.d.ts +83 -0
  449. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
  450. package/lib/simple-tree/api/treeChangeEvents.js +6 -0
  451. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -0
  452. package/lib/simple-tree/api/treeNodeApi.d.ts +2 -1
  453. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  454. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  455. package/lib/simple-tree/api/typesUnsafe.d.ts +4 -9
  456. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  457. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  458. package/lib/simple-tree/arrayNode.d.ts +30 -2
  459. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  460. package/lib/simple-tree/arrayNode.js +4 -3
  461. package/lib/simple-tree/arrayNode.js.map +1 -1
  462. package/lib/simple-tree/arrayNodeTypes.d.ts +3 -3
  463. package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -1
  464. package/lib/simple-tree/arrayNodeTypes.js.map +1 -1
  465. package/lib/simple-tree/core/getOrCreateNode.d.ts +1 -1
  466. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  467. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  468. package/lib/simple-tree/core/index.d.ts +2 -1
  469. package/lib/simple-tree/core/index.d.ts.map +1 -1
  470. package/lib/simple-tree/core/index.js +1 -1
  471. package/lib/simple-tree/core/index.js.map +1 -1
  472. package/lib/simple-tree/core/treeNode.d.ts +94 -0
  473. package/lib/simple-tree/core/treeNode.d.ts.map +1 -0
  474. package/lib/simple-tree/core/treeNode.js +118 -0
  475. package/lib/simple-tree/core/treeNode.js.map +1 -0
  476. package/lib/simple-tree/core/treeNodeKernel.d.ts +2 -1
  477. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  478. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  479. package/lib/simple-tree/core/treeNodeSchema.d.ts +3 -1
  480. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  481. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  482. package/lib/simple-tree/core/types.d.ts +0 -165
  483. package/lib/simple-tree/core/types.d.ts.map +1 -1
  484. package/lib/simple-tree/core/types.js +0 -110
  485. package/lib/simple-tree/core/types.js.map +1 -1
  486. package/lib/simple-tree/core/withType.d.ts +1 -1
  487. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  488. package/lib/simple-tree/core/withType.js.map +1 -1
  489. package/lib/simple-tree/index.d.ts +4 -4
  490. package/lib/simple-tree/index.d.ts.map +1 -1
  491. package/lib/simple-tree/index.js +1 -1
  492. package/lib/simple-tree/index.js.map +1 -1
  493. package/lib/simple-tree/mapNode.d.ts +2 -2
  494. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  495. package/lib/simple-tree/mapNode.js +2 -2
  496. package/lib/simple-tree/mapNode.js.map +1 -1
  497. package/lib/simple-tree/mapNodeTypes.d.ts +3 -3
  498. package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -1
  499. package/lib/simple-tree/mapNodeTypes.js.map +1 -1
  500. package/lib/simple-tree/objectNode.d.ts +18 -5
  501. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  502. package/lib/simple-tree/objectNode.js +5 -4
  503. package/lib/simple-tree/objectNode.js.map +1 -1
  504. package/lib/simple-tree/objectNodeTypes.d.ts +4 -4
  505. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  506. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  507. package/lib/simple-tree/schemaTypes.d.ts +164 -13
  508. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  509. package/lib/simple-tree/schemaTypes.js +96 -8
  510. package/lib/simple-tree/schemaTypes.js.map +1 -1
  511. package/lib/simple-tree/toStoredSchema.d.ts +8 -8
  512. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  513. package/lib/simple-tree/toStoredSchema.js +26 -31
  514. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  515. package/lib/simple-tree/treeNodeValid.js +2 -2
  516. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  517. package/lib/tableSchema.d.ts +455 -125
  518. package/lib/tableSchema.d.ts.map +1 -1
  519. package/lib/tableSchema.js +398 -101
  520. package/lib/tableSchema.js.map +1 -1
  521. package/lib/treeFactory.d.ts +1 -1
  522. package/lib/treeFactory.d.ts.map +1 -1
  523. package/lib/treeFactory.js +30 -75
  524. package/lib/treeFactory.js.map +1 -1
  525. package/lib/util/typeUtils.d.ts +1 -1
  526. package/lib/util/typeUtils.js.map +1 -1
  527. package/package.json +21 -21
  528. package/src/codec/codec.ts +6 -1
  529. package/src/codec/index.ts +1 -0
  530. package/src/core/index.ts +1 -2
  531. package/src/core/schema-stored/index.ts +3 -3
  532. package/src/core/schema-stored/schema.ts +3 -1
  533. package/src/core/schema-stored/storedSchemaRepository.ts +1 -1
  534. package/src/core/schema-view/index.ts +0 -1
  535. package/src/core/schema-view/view.ts +0 -31
  536. package/src/core/tree/persistedTreeTextFormat.ts +2 -2
  537. package/src/feature-libraries/forest-summary/format.ts +2 -2
  538. package/src/feature-libraries/index.ts +7 -1
  539. package/src/feature-libraries/mapTreeCursor.ts +3 -3
  540. package/src/feature-libraries/modular-schema/modularChangeFormat.ts +3 -3
  541. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +38 -9
  542. package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -4
  543. package/src/feature-libraries/schema-index/codec.ts +80 -12
  544. package/src/feature-libraries/schema-index/{format.ts → formatV1.ts} +4 -4
  545. package/src/feature-libraries/schema-index/index.ts +7 -2
  546. package/src/feature-libraries/schema-index/schemaSummarizer.ts +9 -9
  547. package/src/index.ts +18 -1
  548. package/src/internalTypes.ts +0 -2
  549. package/src/jsonDomainSchema.ts +2 -2
  550. package/src/packageVersion.ts +1 -1
  551. package/src/serializableDomainSchema.ts +3 -3
  552. package/src/shared-tree/independentView.ts +4 -3
  553. package/src/shared-tree/index.ts +5 -6
  554. package/src/shared-tree/schematizeTree.ts +10 -40
  555. package/src/shared-tree/schematizingTreeView.ts +12 -17
  556. package/src/shared-tree/sharedTree.ts +67 -6
  557. package/src/shared-tree/{treeApi.ts → tree.ts} +75 -51
  558. package/src/shared-tree/{treeApiAlpha.ts → treeAlpha.ts} +28 -16
  559. package/src/shared-tree-core/branchCommitEnricher.ts +0 -1
  560. package/src/shared-tree-core/transactionEnricher.ts +4 -1
  561. package/src/simple-tree/api/conciseTree.ts +1 -1
  562. package/src/simple-tree/api/configuration.ts +353 -0
  563. package/src/simple-tree/api/getJsonSchema.ts +1 -1
  564. package/src/simple-tree/api/index.ts +23 -15
  565. package/src/simple-tree/api/{view.ts → schemaCompatibilityTester.ts} +8 -15
  566. package/src/simple-tree/api/schemaFactory.ts +139 -19
  567. package/src/simple-tree/api/schemaFactoryAlpha.ts +7 -5
  568. package/src/simple-tree/api/schemaFactoryRecursive.ts +102 -38
  569. package/src/simple-tree/api/schemaFromSimple.ts +2 -2
  570. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
  571. package/src/simple-tree/api/storedSchema.ts +32 -17
  572. package/src/simple-tree/api/tree.ts +38 -354
  573. package/src/simple-tree/api/{treeApiBeta.ts → treeBeta.ts} +20 -6
  574. package/src/simple-tree/api/treeChangeEvents.ts +84 -0
  575. package/src/simple-tree/api/treeNodeApi.ts +1 -1
  576. package/src/simple-tree/api/typesUnsafe.ts +15 -11
  577. package/src/simple-tree/arrayNode.ts +38 -5
  578. package/src/simple-tree/arrayNodeTypes.ts +8 -7
  579. package/src/simple-tree/core/getOrCreateNode.ts +1 -1
  580. package/src/simple-tree/core/index.ts +5 -4
  581. package/src/simple-tree/core/treeNode.ts +163 -0
  582. package/src/simple-tree/core/treeNodeKernel.ts +2 -1
  583. package/src/simple-tree/core/treeNodeSchema.ts +3 -1
  584. package/src/simple-tree/core/types.ts +0 -234
  585. package/src/simple-tree/core/withType.ts +1 -1
  586. package/src/simple-tree/index.ts +19 -2
  587. package/src/simple-tree/mapNode.ts +11 -3
  588. package/src/simple-tree/mapNodeTypes.ts +10 -7
  589. package/src/simple-tree/objectNode.ts +39 -15
  590. package/src/simple-tree/objectNodeTypes.ts +9 -5
  591. package/src/simple-tree/schemaTypes.ts +354 -25
  592. package/src/simple-tree/toStoredSchema.ts +42 -41
  593. package/src/simple-tree/treeNodeValid.ts +2 -2
  594. package/src/tableSchema.ts +1206 -434
  595. package/src/treeFactory.ts +56 -173
  596. package/src/util/typeUtils.ts +1 -1
  597. package/dist/core/schema-stored/format.d.ts.map +0 -1
  598. package/dist/core/schema-stored/format.js.map +0 -1
  599. package/dist/feature-libraries/schema-index/format.d.ts.map +0 -1
  600. package/dist/feature-libraries/schema-index/format.js.map +0 -1
  601. package/dist/shared-tree/treeApi.d.ts.map +0 -1
  602. package/dist/shared-tree/treeApi.js.map +0 -1
  603. package/dist/shared-tree/treeApiAlpha.d.ts.map +0 -1
  604. package/dist/shared-tree/treeApiAlpha.js.map +0 -1
  605. package/dist/simple-tree/api/treeApiBeta.d.ts.map +0 -1
  606. package/dist/simple-tree/api/treeApiBeta.js.map +0 -1
  607. package/dist/simple-tree/api/view.d.ts.map +0 -1
  608. package/dist/simple-tree/api/view.js.map +0 -1
  609. package/lib/core/schema-stored/format.d.ts.map +0 -1
  610. package/lib/core/schema-stored/format.js.map +0 -1
  611. package/lib/feature-libraries/schema-index/format.d.ts.map +0 -1
  612. package/lib/feature-libraries/schema-index/format.js.map +0 -1
  613. package/lib/shared-tree/treeApi.d.ts.map +0 -1
  614. package/lib/shared-tree/treeApi.js.map +0 -1
  615. package/lib/shared-tree/treeApiAlpha.d.ts.map +0 -1
  616. package/lib/shared-tree/treeApiAlpha.js.map +0 -1
  617. package/lib/simple-tree/api/treeApiBeta.d.ts.map +0 -1
  618. package/lib/simple-tree/api/treeApiBeta.js.map +0 -1
  619. package/lib/simple-tree/api/view.d.ts.map +0 -1
  620. package/lib/simple-tree/api/view.js.map +0 -1
  621. /package/src/core/schema-stored/{format.ts → formatV1.ts} +0 -0
@@ -3,9 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert, fail } from "@fluidframework/core-utils/internal";
7
6
  import type { IFluidLoadable, IDisposable, Listenable } from "@fluidframework/core-interfaces";
8
- import { UsageError } from "@fluidframework/telemetry-utils/internal";
9
7
 
10
8
  import type {
11
9
  CommitMetadata,
@@ -19,28 +17,17 @@ import type {
19
17
  TreeAlpha,
20
18
  } from "../../shared-tree/index.js";
21
19
 
22
- import {
23
- type FieldSchemaAlpha,
24
- type ImplicitFieldSchema,
25
- type InsertableField,
26
- type InsertableTreeFieldFromImplicitField,
27
- type ReadableField,
28
- type ReadSchema,
29
- type TreeFieldFromImplicitField,
30
- type UnsafeUnknownSchema,
31
- FieldKind,
32
- markSchemaMostDerived,
33
- normalizeFieldSchema,
20
+ import type {
21
+ ImplicitFieldSchema,
22
+ InsertableField,
23
+ InsertableTreeFieldFromImplicitField,
24
+ ReadableField,
25
+ ReadSchema,
26
+ TreeFieldFromImplicitField,
27
+ UnsafeUnknownSchema,
34
28
  } from "../schemaTypes.js";
35
- import { NodeKind, type TreeNodeSchema } from "../core/index.js";
36
- import { toStoredSchema } from "../toStoredSchema.js";
37
- import { LeafNodeSchema } from "../leafNodeSchema.js";
38
- import { isObjectNodeSchema, type ObjectNodeSchema } from "../objectNodeTypes.js";
39
- import { getOrCreate } from "../../util/index.js";
40
- import type { MakeNominal } from "../../util/index.js";
41
- import { walkFieldSchema } from "../walkFieldSchema.js";
42
29
  import type { VerboseTree } from "./verboseTree.js";
43
- import type { SimpleNodeSchema, SimpleTreeSchema } from "../simpleSchema.js";
30
+ import type { SimpleTreeSchema } from "../simpleSchema.js";
44
31
  import type {
45
32
  RunTransactionParams,
46
33
  TransactionCallbackStatus,
@@ -48,12 +35,14 @@ import type {
48
35
  TransactionResultExt,
49
36
  VoidTransactionCallbackStatus,
50
37
  } from "./transactionTypes.js";
38
+ import type { TreeViewConfiguration } from "./configuration.js";
39
+
51
40
  /**
52
41
  * A tree from which a {@link TreeView} can be created.
53
42
  *
54
43
  * @privateRemarks
55
44
  * TODO:
56
- * Add stored key versions of {@link TreeAlpha.(exportVerbose:2)}, {@link TreeAlpha.(exportConcise:2)} and {@link TreeAlpha.exportCompressed} here so tree content can be accessed without a view schema.
45
+ * Add stored key versions of {@link (TreeAlpha:interface).(exportVerbose:2)}, {@link (TreeAlpha:interface).(exportConcise:2)} and {@link (TreeAlpha:interface).exportCompressed} here so tree content can be accessed without a view schema.
57
46
  * Add exportSimpleSchema and exportJsonSchema methods (which should exactly match the concise format, and match the free functions for exporting view schema).
58
47
  * Maybe rename "exportJsonSchema" to align on "concise" terminology.
59
48
  * Ensure schema exporting APIs here align and reference APIs for exporting view schema to the same formats (which should include stored vs property key choice).
@@ -99,7 +88,7 @@ export interface ITree extends ViewableTree, IFluidLoadable {}
99
88
  */
100
89
  export interface ITreeAlpha extends ITree {
101
90
  /**
102
- * Exports root in the same format as {@link TreeAlpha.(exportVerbose:1)} using stored keys.
91
+ * Exports root in the same format as {@link (TreeAlpha:interface).(exportVerbose:1)} using stored keys.
103
92
  * @remarks
104
93
  * This is `undefined` if and only if the root field is empty (this can only happen if the root field is optional).
105
94
  */
@@ -113,336 +102,6 @@ export interface ITreeAlpha extends ITree {
113
102
  exportSimpleSchema(): SimpleTreeSchema;
114
103
  }
115
104
 
116
- /**
117
- * Options when constructing a tree view.
118
- * @public
119
- */
120
- export interface ITreeConfigurationOptions {
121
- /**
122
- * If `true`, the tree will validate new content against its stored schema at insertion time
123
- * and throw an error if the new content doesn't match the expected schema.
124
- *
125
- * @defaultValue `false`.
126
- *
127
- * @remarks Enabling schema validation has a performance penalty when inserting new content into the tree because
128
- * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a
129
- * bit slower.
130
- */
131
- enableSchemaValidation?: boolean;
132
-
133
- /**
134
- * A flag used to opt into strict rules ensuring that the schema avoids cases which can make the type of nodes ambiguous when importing or exporting data.
135
- * @defaultValue `false`.
136
- *
137
- * @remarks
138
- * When this is true, it ensures that the compile time type safety for data when constructing nodes is sufficient to ensure that the runtime behavior will not give node data ambiguity errors.
139
- *
140
- * This ensures that the canonical JSON-like representation of all unions in the tree are lossless and unambiguous.
141
- * This canonical JSON-like representation consists of arrays, plain old JavaScript objects with string keys, booleans, numbers (excluding NaN, -0 and infinities), strings, null and {@link @fluidframework/core-interfaces#IFluidHandle}s.
142
- * It is compatible with the node creation APIs (such as schema class constructors) and is also compatible with JSON assuming any IFluidHandles get special handling (since they are not JSON compatible).
143
- * Currently these cases can cause ambiguity in a union:
144
- *
145
- * - More than one ArrayNode type: it's impossible to tell which array type is intended in the case of empty arrays (`[]`).
146
- *
147
- * - More than one MapNode type: it's impossible to tell which map type is intended in the case of an empty map (`{}`).
148
- *
149
- * - Both a MapNode and an ArrayNode: this case is not a problem for the canonical JSON representation, but is an issue when constructing from an Iterable, which is supported for both MapNode and ArrayNode.
150
- *
151
- * - Both a MapNode and an ObjectNode: when the input is valid for the ObjectNode, the current parser always considers it ambiguous with being a MapNode.
152
- *
153
- * - ObjectNodes which have fields (required or optional) which include all required fields of another ObjectNode: currently each ObjectNode is differentiated by the presence of its required fields.
154
- *
155
- * This check is conservative: some complex cases may error if the current simple algorithm cannot show no ambiguity is possible.
156
- * This check may become more permissive over time.
157
- *
158
- * @example Ambiguous schema (with `preventAmbiguity: false`), and how to disambiguate it using {@link Unhydrated} nodes:
159
- * ```typescript
160
- * const schemaFactory = new SchemaFactory("com.example");
161
- * class Feet extends schemaFactory.object("Feet", { length: schemaFactory.number }) {}
162
- * class Meters extends schemaFactory.object("Meters", { length: schemaFactory.number }) {}
163
- * const config = new TreeViewConfiguration({
164
- * // This combination of schema can lead to ambiguous cases and will error if `preventAmbiguity` is true.
165
- * schema: [Feet, Meters],
166
- * preventAmbiguity: false,
167
- * });
168
- * const view = tree.viewWith(config);
169
- * // This is invalid since it is ambiguous which type of node is being constructed:
170
- * // view.initialize({ length: 5 });
171
- * // To work, an explicit type can be provided by using an {@link Unhydrated} Node:
172
- * view.initialize(new Meters({ length: 5 }));
173
- * ```
174
- *
175
- * @example Schema disambiguated by adjusting field names, validated with `preventAmbiguity: true:`
176
- * ```typescript
177
- * const schemaFactory = new SchemaFactory("com.example");
178
- * class Feet extends schemaFactory.object("Feet", { length: schemaFactory.number }) {}
179
- * class Meters extends schemaFactory.object("Meters", {
180
- * // To avoid ambiguity when parsing unions of Feet and Meters, this renames the length field to "meters".
181
- * // To preserve compatibility with existing data from the ambiguous case,
182
- * // `{ key: "length" }` is set, so when persisted in the tree "length" is used as the field name.
183
- * meters: schemaFactory.required(schemaFactory.number, { key: "length" }),
184
- * }) {}
185
- * const config = new TreeViewConfiguration({
186
- * // This combination of schema is not ambiguous because `Feet` and `Meters` have different required keys.
187
- * schema: [Feet, Meters],
188
- * preventAmbiguity: true,
189
- * });
190
- * const view = tree.viewWith(config);
191
- * // This now works, since the field is sufficient to determine this is a `Meters` node.
192
- * view.initialize({ meters: 5 });
193
- * ```
194
- *
195
- * @privateRemarks
196
- * In the future, we can support lossless round tripping via the canonical JSON-like representation above when unambiguous.
197
- * This could be done via methods added to `Tree` to export and import such objects, which would give us a place to explicitly define the type of this representation.
198
- *
199
- * To make this more permissive in the future we can:
200
- *
201
- * - Make toMapTree more permissive (ex: allow disambiguation based on leaf type)
202
- * - Update this check to more tightly match toMapTree
203
- * - Add options to help schema authors disambiguate their types, such as "constant fields" which are not persisted, and always have a constant value.
204
- *
205
- * The above examples exist in executable form in this files tests, and should be updated there then copied back here.
206
- */
207
- readonly preventAmbiguity?: boolean;
208
- }
209
-
210
- const defaultTreeConfigurationOptions: Required<ITreeConfigurationOptions> = {
211
- enableSchemaValidation: false,
212
- preventAmbiguity: false,
213
- };
214
-
215
- /**
216
- * Property-bag configuration for {@link TreeViewConfiguration} construction.
217
- * @public
218
- */
219
- export interface ITreeViewConfiguration<
220
- TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,
221
- > extends ITreeConfigurationOptions {
222
- /**
223
- * The schema which the application wants to view the tree with.
224
- */
225
- readonly schema: TSchema;
226
- }
227
-
228
- /**
229
- * Configuration for {@link ViewableTree.viewWith}.
230
- * @sealed @public
231
- */
232
- export class TreeViewConfiguration<
233
- const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,
234
- > implements Required<ITreeViewConfiguration<TSchema>>
235
- {
236
- protected _typeCheck!: MakeNominal;
237
-
238
- /**
239
- * {@inheritDoc ITreeViewConfiguration.schema}
240
- */
241
- public readonly schema: TSchema;
242
-
243
- /**
244
- * {@inheritDoc ITreeConfigurationOptions.enableSchemaValidation}
245
- */
246
- public readonly enableSchemaValidation: boolean;
247
-
248
- /**
249
- * {@inheritDoc ITreeConfigurationOptions.preventAmbiguity}
250
- */
251
- public readonly preventAmbiguity: boolean;
252
-
253
- /**
254
- * Construct a new {@link TreeViewConfiguration}.
255
- *
256
- * @param props - Property bag of configuration options.
257
- *
258
- * @remarks
259
- * Performing this construction deeply validates the provided schema.
260
- * This means that when this constructor is called, all {@link LazyItem} {@link TreeNodeSchema} references will be evaluated (using {@link evaluateLazySchema}).
261
- * This means that the declarations for all transitively reachable {@link TreeNodeSchema} must be available at this time.
262
- *
263
- * For example, a schema reachable from this configuration cannot reference this configuration during its declaration,
264
- * since this would be a cyclic dependency that will cause an error when constructing this configuration.
265
- */
266
- public constructor(props: ITreeViewConfiguration<TSchema>) {
267
- const config = { ...defaultTreeConfigurationOptions, ...props };
268
- this.schema = config.schema;
269
- this.enableSchemaValidation = config.enableSchemaValidation;
270
- this.preventAmbiguity = config.preventAmbiguity;
271
-
272
- // Ambiguity errors are lower priority to report than invalid schema errors, so collect these in an array and report them all at once.
273
- const ambiguityErrors: string[] = [];
274
-
275
- walkFieldSchema(config.schema, {
276
- // Ensure all reachable schema are marked as most derived.
277
- // This ensures if multiple schema extending the same schema factory generated class are present (or have been constructed, or get constructed in the future),
278
- // an error is reported.
279
-
280
- node: (schema) => markSchemaMostDerived(schema, true),
281
- allowedTypes(types): void {
282
- if (config.preventAmbiguity) {
283
- checkUnion(types, ambiguityErrors);
284
- }
285
- },
286
- });
287
-
288
- if (ambiguityErrors.length !== 0) {
289
- // Duplicate errors are common since when two types conflict, both orders error:
290
- const deduplicated = new Set(ambiguityErrors);
291
- throw new UsageError(`Ambiguous schema found:\n${[...deduplicated].join("\n")}`);
292
- }
293
-
294
- // Eagerly perform this conversion to surface errors sooner.
295
- toStoredSchema(config.schema);
296
- }
297
- }
298
-
299
- /**
300
- * {@link TreeViewConfiguration} extended with some alpha APIs.
301
- * @sealed @alpha
302
- */
303
- export class TreeViewConfigurationAlpha<
304
- const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,
305
- >
306
- extends TreeViewConfiguration<TSchema>
307
- implements TreeSchema
308
- {
309
- /**
310
- * {@inheritDoc TreeSchema.root}
311
- */
312
- public readonly root: FieldSchemaAlpha;
313
- /**
314
- * {@inheritDoc TreeSchema.definitions}
315
- */
316
- public readonly definitions: ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;
317
-
318
- public constructor(props: ITreeViewConfiguration<TSchema>) {
319
- super(props);
320
- this.root = normalizeFieldSchema(props.schema);
321
- const definitions = new Map<string, SimpleNodeSchema & TreeNodeSchema>();
322
- walkFieldSchema(props.schema, {
323
- node: (schema) =>
324
- definitions.set(schema.identifier, schema as SimpleNodeSchema & TreeNodeSchema),
325
- });
326
- this.definitions = definitions;
327
- }
328
- }
329
-
330
- /**
331
- * {@link TreeViewConfigurationAlpha}
332
- * @sealed @alpha
333
- */
334
- export interface TreeSchema extends SimpleTreeSchema {
335
- /**
336
- * {@inheritDoc SimpleTreeSchema.root}
337
- */
338
- readonly root: FieldSchemaAlpha;
339
-
340
- /**
341
- * {@inheritDoc SimpleTreeSchema.definitions}
342
- */
343
- readonly definitions: ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;
344
- }
345
-
346
- /**
347
- * Pretty print a set of types for use in error messages.
348
- */
349
- function formatTypes(allowed: Iterable<TreeNodeSchema>): string {
350
- // Use JSON.stringify to quote and escape identifiers.
351
- // Don't just use a single array JSON.stringify since that omits spaces between items
352
- return `[${Array.from(allowed, (s) => JSON.stringify(s.identifier)).join(", ")}]`;
353
- }
354
-
355
- /**
356
- * Detect cases documented in {@link ITreeConfigurationOptions.preventAmbiguity}.
357
- */
358
- export function checkUnion(union: Iterable<TreeNodeSchema>, errors: string[]): void {
359
- const checked: Set<TreeNodeSchema> = new Set();
360
- const maps: TreeNodeSchema[] = [];
361
- const arrays: TreeNodeSchema[] = [];
362
-
363
- const objects: ObjectNodeSchema[] = [];
364
- // Map from key to schema using that key
365
- const allObjectKeys: Map<string, Set<TreeNodeSchema>> = new Map();
366
-
367
- for (const schema of union) {
368
- if (checked.has(schema)) {
369
- throw new UsageError(`Duplicate schema in allowed types: ${schema.identifier}`);
370
- }
371
- checked.add(schema);
372
-
373
- if (schema instanceof LeafNodeSchema) {
374
- // nothing to do
375
- } else if (isObjectNodeSchema(schema)) {
376
- objects.push(schema);
377
- for (const key of schema.fields.keys()) {
378
- getOrCreate(allObjectKeys, key, () => new Set()).add(schema);
379
- }
380
- } else if (schema.kind === NodeKind.Array) {
381
- arrays.push(schema);
382
- } else {
383
- assert(schema.kind === NodeKind.Map, 0x9e7 /* invalid schema */);
384
- maps.push(schema);
385
- }
386
- }
387
-
388
- if (arrays.length > 1) {
389
- errors.push(
390
- `More than one kind of array allowed within union (${formatTypes(arrays)}). This would require type disambiguation which is not supported by arrays during import or export.`,
391
- );
392
- }
393
-
394
- if (maps.length > 1) {
395
- errors.push(
396
- `More than one kind of map allowed within union (${formatTypes(maps)}). This would require type disambiguation which is not supported by maps during import or export.`,
397
- );
398
- }
399
-
400
- if (maps.length > 0 && arrays.length > 0) {
401
- errors.push(
402
- `Both a map and an array allowed within union (${formatTypes([...arrays, ...maps])}). Both can be implicitly constructed from iterables like arrays, which are ambiguous when the array is empty.`,
403
- );
404
- }
405
-
406
- if (objects.length > 0 && maps.length > 0) {
407
- errors.push(
408
- `Both a object and a map allowed within union (${formatTypes([...objects, ...maps])}). Both can be constructed from objects and can be ambiguous.`,
409
- );
410
- }
411
-
412
- // Check for objects which fully overlap:
413
- for (const schema of objects) {
414
- // All objects which might be ambiguous relative to `schema`.
415
- const possiblyAmbiguous = new Set(objects);
416
-
417
- // A schema can't be ambiguous with itself
418
- possiblyAmbiguous.delete(schema);
419
-
420
- // For each field of schema, remove schema from possiblyAmbiguous that do not have that field
421
- for (const [key, field] of schema.fields) {
422
- if (field.kind === FieldKind.Required) {
423
- const withKey = allObjectKeys.get(key) ?? fail(0xb35 /* missing schema */);
424
- for (const candidate of possiblyAmbiguous) {
425
- if (!withKey.has(candidate)) {
426
- possiblyAmbiguous.delete(candidate);
427
- }
428
- }
429
- }
430
- }
431
-
432
- if (possiblyAmbiguous.size > 0) {
433
- // TODO: make this check more permissive.
434
- // Allow using the type of the field to disambiguate, at least for leaf types.
435
- // Add "constant" fields which can be used to disambiguate even more cases without adding persisted data: maybe make them optional in constructor?
436
- // Consider separating unambiguous implicit construction format from constructor arguments at type level, allowing constructor to superset the implicit construction options (ex: optional constant fields).
437
- // The policy here however must remain at least as conservative as shallowCompatibilityTest in src/simple-tree/toMapTree.ts.
438
-
439
- errors.push(
440
- `The required fields of ${JSON.stringify(schema.identifier)} are insufficient to differentiate it from the following types: ${formatTypes(possiblyAmbiguous)}. For objects to be considered unambiguous, each must have required fields that do not all occur on any other object in the union.`,
441
- );
442
- }
443
- }
444
- }
445
-
446
105
  /**
447
106
  * A collection of functionality associated with a (version-control-style) branch of a SharedTree.
448
107
  * @remarks A `TreeBranch` allows for the {@link TreeBranch.fork | creation of branches} and for those branches to later be {@link TreeBranch.merge | merged}.
@@ -631,14 +290,18 @@ export interface TreeViewAlpha<
631
290
  * "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
632
291
  * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
633
292
  * @returns A result object of {@link TransactionResultExt | TransactionResultExt} type. It includes the following:
293
+ *
634
294
  * - A "success" flag indicating whether the transaction was successful or not.
295
+ *
635
296
  * - The success of failure value as returned by the transaction function.
636
297
  * @remarks
637
298
  * This API will throw an error if the constraints are not met or something unexpected happens.
638
299
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
639
300
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
640
301
  * However, using a transaction has the following additional consequences:
302
+ *
641
303
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
304
+ *
642
305
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
643
306
  *
644
307
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -646,9 +309,12 @@ export interface TreeViewAlpha<
646
309
  *
647
310
  * Nested transactions:
648
311
  * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:
312
+ *
649
313
  * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
314
+ *
650
315
  * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
651
316
  * for the outermost transaction which includes all inner transactions.
317
+ *
652
318
  * - Undo will undo the outermost transaction and all inner transactions.
653
319
  */
654
320
  runTransaction<TSuccessValue, TFailureValue>(
@@ -658,10 +324,13 @@ export interface TreeViewAlpha<
658
324
  /**
659
325
  * Run a transaction which applies one or more edits to the tree as a single atomic unit.
660
326
  * @param transaction - The function to run as the body of the transaction. It may return the following:
327
+ *
661
328
  * - Nothing to indicate that the body of the transaction has successfully run.
329
+ *
662
330
  * - A status object of {@link VoidTransactionCallbackStatus | VoidTransactionCallbackStatus } type. It includes a "rollback" property which
663
331
  * may be returned as true at any point during the transaction. This will abort the transaction and discard any changes it made so
664
332
  * far. "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
333
+ *
665
334
  * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
666
335
  * @returns A result object of {@link TransactionResult | TransactionResult} type. It includes a "success" flag indicating whether the
667
336
  * transaction was successful or not.
@@ -670,7 +339,9 @@ export interface TreeViewAlpha<
670
339
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
671
340
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
672
341
  * However, using a transaction has the following additional consequences:
342
+ *
673
343
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
344
+ *
674
345
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
675
346
  *
676
347
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -678,9 +349,12 @@ export interface TreeViewAlpha<
678
349
  *
679
350
  * Nested transactions:
680
351
  * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:
352
+ *
681
353
  * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
354
+ *
682
355
  * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
683
356
  * for the outermost transaction which includes all inner transactions.
357
+ *
684
358
  * - Undo will undo the outermost transaction and all inner transactions.
685
359
  */
686
360
  runTransaction(
@@ -704,7 +378,9 @@ export interface SchemaCompatibilityStatus {
704
378
  * exact matches in a strict (schema-based) sense but still allow the same documents, and the document notion is more useful to applications.
705
379
  *
706
380
  * Examples which are expressible where this may occur include:
381
+ *
707
382
  * - schema repository `A` has extra schema which schema `B` doesn't have, but they are unused (i.e. not reachable from the root schema)
383
+ *
708
384
  * - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (ex: an object node type containing a required field with no allowed types)
709
385
  *
710
386
  * These cases are typically not interesting to applications.
@@ -782,11 +458,15 @@ export interface TreeBranchEvents extends Omit<TreeViewEvents, "commitApplied">
782
458
 
783
459
  /**
784
460
  * Fired when:
461
+ *
785
462
  * - a local commit is applied outside of a transaction
463
+ *
786
464
  * - a local transaction is committed
787
465
  *
788
466
  * The event is not fired when:
467
+ *
789
468
  * - a local commit is applied within a transaction
469
+ *
790
470
  * - a remote commit is applied
791
471
  *
792
472
  * @param data - information about the commit that was applied
@@ -822,11 +502,15 @@ export interface TreeViewEvents {
822
502
 
823
503
  /**
824
504
  * Fired when:
505
+ *
825
506
  * - a local commit is applied outside of a transaction
507
+ *
826
508
  * - a local transaction is committed
827
509
  *
828
510
  * The event is not fired when:
511
+ *
829
512
  * - a local commit is applied within a transaction
513
+ *
830
514
  * - a remote commit is applied
831
515
  *
832
516
  * @param data - information about the commit that was applied
@@ -7,7 +7,6 @@ import {
7
7
  getKernel,
8
8
  isTreeNode,
9
9
  type NodeKind,
10
- type TreeChangeEvents,
11
10
  type TreeNode,
12
11
  type Unhydrated,
13
12
  type WithType,
@@ -15,6 +14,10 @@ import {
15
14
  import { treeNodeApi } from "./treeNodeApi.js";
16
15
  import { createFromCursor } from "./create.js";
17
16
  import type { ImplicitFieldSchema, TreeFieldFromImplicitField } from "../schemaTypes.js";
17
+ import type { TreeChangeEvents } from "./treeChangeEvents.js";
18
+
19
+ // Tests for this file are grouped with those for treeNodeApi.ts as that is where this functionality will eventually land,
20
+ // and where most of the actual implementation is for much of it.
18
21
 
19
22
  /**
20
23
  * Data included for {@link TreeChangeEventsBeta.nodeChanged}.
@@ -89,10 +92,12 @@ export interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode>
89
92
  }
90
93
 
91
94
  /**
92
- * Extensions to {@link Tree} which are not yet stable.
93
- * @sealed @beta
95
+ * Extensions to {@link (Tree:interface)} which are not yet stable.
96
+ * @remarks
97
+ * Use via the {@link (TreeBeta:variable)} singleton.
98
+ * @system @sealed @beta
94
99
  */
95
- export const TreeBeta: {
100
+ export interface TreeBeta {
96
101
  /**
97
102
  * Register an event listener on the given node.
98
103
  * @param node - The node whose events should be subscribed to.
@@ -117,7 +122,9 @@ export const TreeBeta: {
117
122
  *
118
123
  * - Local state, such as properties added to customized schema classes, will not be cloned. However, they will be
119
124
  * initialized to their default state just as if the node had been created via its constructor.
125
+ *
120
126
  * - Value node types (i.e., numbers, strings, booleans, nulls and Fluid handles) will be returned as is.
127
+ *
121
128
  * - The identifiers in the node's subtree will be preserved, i.e., they are not replaced with new values.
122
129
  */
123
130
  clone<const TSchema extends ImplicitFieldSchema>(
@@ -142,7 +149,14 @@ export const TreeBeta: {
142
149
  // replaceIdentifiers?: true;
143
150
  // },
144
151
  // ): TreeFieldFromImplicitField<TSchema>;
145
- } = {
152
+ }
153
+
154
+ /**
155
+ * Extensions to {@link (Tree:variable)} which are not yet stable.
156
+ * @see {@link (TreeBeta:interface)}.
157
+ * @beta
158
+ */
159
+ export const TreeBeta: TreeBeta = {
146
160
  on<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(
147
161
  node: TNode,
148
162
  eventName: K,
@@ -153,7 +167,7 @@ export const TreeBeta: {
153
167
  clone<const TSchema extends ImplicitFieldSchema>(
154
168
  node: TreeFieldFromImplicitField<TSchema>,
155
169
  ): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
156
- /** The only non-TreeNode cases are {@link TreeLeafValue} and `undefined` (for an empty optional field) which can be returned as is. */
170
+ // The only non-TreeNode cases are {@link TreeLeafValue} and `undefined` (for an empty optional field) which can be returned as is.
157
171
  if (!isTreeNode(node)) {
158
172
  return node;
159
173
  }
@@ -0,0 +1,84 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ /**
7
+ * A collection of events that can be emitted by a {@link TreeNode}.
8
+ *
9
+ * @privateRemarks
10
+ * TODO: add a way to subscribe to a specific field (for nodeChanged and treeChanged).
11
+ * Probably have object node and map node specific APIs for this.
12
+ *
13
+ * TODO: ensure that subscription API for fields aligns with API for subscribing to the root.
14
+ *
15
+ * TODO: add more wider area (avoid needing tons of nodeChanged registration) events for use-cases other than treeChanged.
16
+ * Some ideas:
17
+ *
18
+ * - treeChanged, but with some subtrees/fields/paths excluded
19
+ * - helper to batch several nodeChanged calls to a treeChanged scope
20
+ * - parent change (ex: registration on the parent field for a specific index: maybe allow it for a range. Ex: node event takes optional field and optional index range?)
21
+ * - new content inserted into subtree. Either provide event for this and/or enough info to treeChanged to find and search the new sub-trees.
22
+ * Add separate (non event related) API to efficiently scan tree for given set of types (using low level cursor and schema based filtering)
23
+ * to allow efficiently searching for new content (and initial content) of a given type.
24
+ *
25
+ * @sealed @public
26
+ */
27
+ export interface TreeChangeEvents {
28
+ /**
29
+ * Emitted by a node after a batch of changes has been applied to the tree, if any of the changes affected the node.
30
+ *
31
+ * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).
32
+ *
33
+ * - Array nodes define a change as when an element is added, removed, moved or replaced.
34
+ *
35
+ * - Map nodes define a change as when an entry is added, updated, or removed.
36
+ *
37
+ * @param unstable - Future versions of this API (such as the one in beta on TreeBeta) may use this argument to provide additional data to the event.
38
+ * users of this event should ensure that they do not provide a listener callback which has an optional parameter in this position, since unexpected data might get provided to it.
39
+ * This parameter exists to capture this fact in the type system.
40
+ * Using an inline lambda expression as the listener callback is a good pattern to avoid cases like this were arguments are added from breaking due to optional arguments.
41
+ *
42
+ * @remarks
43
+ * This event is not emitted when:
44
+ *
45
+ * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing
46
+ * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the
47
+ * array/map node as one of its properties.
48
+ *
49
+ * - The node is moved to a different location in the tree or removed from the tree.
50
+ * In this case the event is emitted on the _parent_ node, not the node itself.
51
+ *
52
+ * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in
53
+ * the client that made the original edit.
54
+ *
55
+ * When the event is emitted, the tree is guaranteed to be in-schema.
56
+ *
57
+ * @privateRemarks
58
+ * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.
59
+ * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the
60
+ * node, or when the node has to be updated due to resolution of a merge conflict
61
+ * (for example a previously applied local change might be undone, then reapplied differently or not at all).
62
+ *
63
+ * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).
64
+ */
65
+ nodeChanged(unstable?: unknown): void;
66
+
67
+ /**
68
+ * Emitted by a node after a batch of changes has been applied to the tree, when something changed anywhere in the
69
+ * subtree rooted at it.
70
+ *
71
+ * @remarks
72
+ * This event is not emitted when the node itself is moved to a different location in the tree or removed from the tree.
73
+ * In that case it is emitted on the _parent_ node, not the node itself.
74
+ *
75
+ * The node itself is part of the subtree, so this event will be emitted even if the only changes are to the properties
76
+ * of the node itself.
77
+ *
78
+ * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in
79
+ * the client that made the original edit.
80
+ *
81
+ * When it is emitted, the tree is guaranteed to be in-schema.
82
+ */
83
+ treeChanged(): void;
84
+ }
@@ -32,7 +32,6 @@ import {
32
32
  type TreeNodeSchema,
33
33
  NodeKind,
34
34
  type TreeNode,
35
- type TreeChangeEvents,
36
35
  tryGetTreeNodeSchema,
37
36
  getOrCreateNodeFromInnerNode,
38
37
  UnhydratedFlexTreeNode,
@@ -40,6 +39,7 @@ import {
40
39
  getOrCreateInnerNode,
41
40
  } from "../core/index.js";
42
41
  import { isObjectNodeSchema } from "../objectNodeTypes.js";
42
+ import type { TreeChangeEvents } from "./treeChangeEvents.js";
43
43
 
44
44
  /**
45
45
  * Provides various functions for analyzing {@link TreeNode}s.