@fluidframework/tree 2.42.0 → 2.43.0-343119

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 (431) hide show
  1. package/api-report/tree.alpha.api.md +59 -21
  2. package/api-report/tree.beta.api.md +33 -0
  3. package/dist/alpha.d.ts +11 -6
  4. package/dist/beta.d.ts +6 -1
  5. package/dist/core/index.d.ts +1 -1
  6. package/dist/core/index.d.ts.map +1 -1
  7. package/dist/core/index.js +5 -2
  8. package/dist/core/index.js.map +1 -1
  9. package/dist/core/schema-stored/formatV2.d.ts +80 -0
  10. package/dist/core/schema-stored/formatV2.d.ts.map +1 -0
  11. package/dist/core/schema-stored/formatV2.js +55 -0
  12. package/dist/core/schema-stored/formatV2.js.map +1 -0
  13. package/dist/core/schema-stored/index.d.ts +3 -1
  14. package/dist/core/schema-stored/index.d.ts.map +1 -1
  15. package/dist/core/schema-stored/index.js +5 -2
  16. package/dist/core/schema-stored/index.js.map +1 -1
  17. package/dist/core/schema-stored/schema.d.ts +49 -17
  18. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  19. package/dist/core/schema-stored/schema.js +65 -22
  20. package/dist/core/schema-stored/schema.js.map +1 -1
  21. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +9 -7
  22. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  23. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +13 -9
  24. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  25. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +3 -3
  26. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  27. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +6 -6
  28. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  29. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
  30. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  31. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +3 -3
  32. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  33. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +8 -3
  34. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  35. package/dist/feature-libraries/detachedFieldIndexSummarizer.js +2 -5
  36. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  37. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +23 -24
  38. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  39. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  40. package/dist/feature-libraries/flex-tree/index.d.ts +0 -1
  41. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  42. package/dist/feature-libraries/flex-tree/index.js +1 -7
  43. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  44. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +2 -2
  45. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  46. package/dist/feature-libraries/flex-tree/lazyEntity.js +3 -0
  47. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  48. package/dist/feature-libraries/flex-tree/lazyField.d.ts +1 -2
  49. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  50. package/dist/feature-libraries/flex-tree/lazyField.js +2 -5
  51. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  52. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +5 -5
  53. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  54. package/dist/feature-libraries/flex-tree/lazyNode.js +15 -7
  55. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  56. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +8 -3
  57. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  58. package/dist/feature-libraries/forest-summary/forestSummarizer.js +2 -5
  59. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  60. package/dist/feature-libraries/index.d.ts +2 -2
  61. package/dist/feature-libraries/index.d.ts.map +1 -1
  62. package/dist/feature-libraries/index.js +1 -2
  63. package/dist/feature-libraries/index.js.map +1 -1
  64. package/dist/feature-libraries/mapTreeCursor.d.ts +16 -2
  65. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  66. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  67. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
  68. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js +2 -0
  69. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
  70. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  71. package/dist/feature-libraries/object-forest/objectForest.js +2 -0
  72. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  73. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  74. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -4
  75. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  76. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -36
  77. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  78. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
  79. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  80. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  81. package/dist/feature-libraries/schema-index/codec.js +59 -9
  82. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  83. package/dist/feature-libraries/schema-index/formatV1.d.ts +1 -1
  84. package/dist/feature-libraries/schema-index/formatV2.d.ts +42 -0
  85. package/dist/feature-libraries/schema-index/formatV2.d.ts.map +1 -0
  86. package/dist/feature-libraries/schema-index/formatV2.js +26 -0
  87. package/dist/feature-libraries/schema-index/formatV2.js.map +1 -0
  88. package/dist/feature-libraries/schema-index/index.d.ts +2 -1
  89. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  90. package/dist/feature-libraries/schema-index/index.js +4 -2
  91. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  92. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +7 -2
  93. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  94. package/dist/feature-libraries/schema-index/schemaSummarizer.js +6 -6
  95. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  96. package/dist/index.d.ts +2 -2
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js.map +1 -1
  99. package/dist/packageVersion.d.ts +1 -1
  100. package/dist/packageVersion.d.ts.map +1 -1
  101. package/dist/packageVersion.js +1 -1
  102. package/dist/packageVersion.js.map +1 -1
  103. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  104. package/dist/shared-tree/schematizeTree.js +1 -0
  105. package/dist/shared-tree/schematizeTree.js.map +1 -1
  106. package/dist/shared-tree/sharedTree.d.ts +5 -1
  107. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  108. package/dist/shared-tree/sharedTree.js +34 -5
  109. package/dist/shared-tree/sharedTree.js.map +1 -1
  110. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  111. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  112. package/dist/shared-tree/treeAlpha.js +12 -11
  113. package/dist/shared-tree/treeAlpha.js.map +1 -1
  114. package/dist/shared-tree-core/editManagerSummarizer.d.ts +8 -3
  115. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  116. package/dist/shared-tree-core/editManagerSummarizer.js +2 -5
  117. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  118. package/dist/shared-tree-core/sharedTreeCore.d.ts +18 -7
  119. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  120. package/dist/shared-tree-core/sharedTreeCore.js +15 -2
  121. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  122. package/dist/simple-tree/api/schemaCompatibilityTester.js +1 -1
  123. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  124. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  125. package/dist/simple-tree/api/schemaCreationUtilities.js +3 -3
  126. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  127. package/dist/simple-tree/api/schemaFactory.d.ts +15 -11
  128. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  129. package/dist/simple-tree/api/schemaFactory.js +4 -0
  130. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  131. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +41 -11
  132. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  133. package/dist/simple-tree/api/schemaFactoryAlpha.js +31 -4
  134. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  135. package/dist/simple-tree/api/storedSchema.js +2 -2
  136. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  137. package/dist/simple-tree/api/treeChangeEvents.d.ts +8 -3
  138. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  139. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
  140. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  141. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +5 -0
  142. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  143. package/dist/simple-tree/core/treeNodeKernel.js +1 -1
  144. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  145. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +5 -9
  146. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  147. package/dist/simple-tree/core/unhydratedFlexTree.js +12 -31
  148. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  149. package/dist/simple-tree/index.d.ts +2 -2
  150. package/dist/simple-tree/index.d.ts.map +1 -1
  151. package/dist/simple-tree/index.js.map +1 -1
  152. package/dist/simple-tree/leafNodeSchema.d.ts +2 -0
  153. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  154. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  155. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -1
  156. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  157. package/dist/simple-tree/node-kinds/array/arrayNode.js +3 -1
  158. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  159. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +3 -2
  160. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  161. package/dist/simple-tree/node-kinds/map/mapNode.js +4 -2
  162. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  163. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +3 -2
  164. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  165. package/dist/simple-tree/node-kinds/object/objectNode.js +3 -1
  166. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  167. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  168. package/dist/simple-tree/prepareForInsertion.js +5 -1
  169. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  170. package/dist/simple-tree/schemaTypes.d.ts +50 -3
  171. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  172. package/dist/simple-tree/schemaTypes.js +28 -1
  173. package/dist/simple-tree/schemaTypes.js.map +1 -1
  174. package/dist/simple-tree/simpleSchema.d.ts +22 -4
  175. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  176. package/dist/simple-tree/simpleSchema.js.map +1 -1
  177. package/dist/simple-tree/toStoredSchema.d.ts +2 -0
  178. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  179. package/dist/simple-tree/toStoredSchema.js +13 -4
  180. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  181. package/dist/tableSchema.d.ts +1 -1
  182. package/dist/util/typeUtils.d.ts +2 -2
  183. package/dist/util/typeUtils.js.map +1 -1
  184. package/dist/util/utils.d.ts +2 -0
  185. package/dist/util/utils.d.ts.map +1 -1
  186. package/dist/util/utils.js.map +1 -1
  187. package/lib/alpha.d.ts +11 -6
  188. package/lib/beta.d.ts +6 -1
  189. package/lib/core/index.d.ts +1 -1
  190. package/lib/core/index.d.ts.map +1 -1
  191. package/lib/core/index.js +1 -1
  192. package/lib/core/index.js.map +1 -1
  193. package/lib/core/schema-stored/formatV2.d.ts +80 -0
  194. package/lib/core/schema-stored/formatV2.d.ts.map +1 -0
  195. package/lib/core/schema-stored/formatV2.js +52 -0
  196. package/lib/core/schema-stored/formatV2.js.map +1 -0
  197. package/lib/core/schema-stored/index.d.ts +3 -1
  198. package/lib/core/schema-stored/index.d.ts.map +1 -1
  199. package/lib/core/schema-stored/index.js +3 -1
  200. package/lib/core/schema-stored/index.js.map +1 -1
  201. package/lib/core/schema-stored/schema.d.ts +49 -17
  202. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  203. package/lib/core/schema-stored/schema.js +63 -21
  204. package/lib/core/schema-stored/schema.js.map +1 -1
  205. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +9 -7
  206. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  207. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +11 -7
  208. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  209. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +3 -3
  210. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  211. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +7 -7
  212. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  213. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
  214. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  215. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +3 -3
  216. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  217. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +8 -3
  218. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  219. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +2 -5
  220. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  221. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +23 -24
  222. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  223. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  224. package/lib/feature-libraries/flex-tree/index.d.ts +0 -1
  225. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  226. package/lib/feature-libraries/flex-tree/index.js +0 -1
  227. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  228. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +2 -2
  229. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  230. package/lib/feature-libraries/flex-tree/lazyEntity.js +3 -0
  231. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  232. package/lib/feature-libraries/flex-tree/lazyField.d.ts +1 -2
  233. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  234. package/lib/feature-libraries/flex-tree/lazyField.js +3 -6
  235. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  236. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +5 -5
  237. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  238. package/lib/feature-libraries/flex-tree/lazyNode.js +15 -7
  239. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  240. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +8 -3
  241. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  242. package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -5
  243. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  244. package/lib/feature-libraries/index.d.ts +2 -2
  245. package/lib/feature-libraries/index.d.ts.map +1 -1
  246. package/lib/feature-libraries/index.js +1 -1
  247. package/lib/feature-libraries/index.js.map +1 -1
  248. package/lib/feature-libraries/mapTreeCursor.d.ts +16 -2
  249. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  250. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  251. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
  252. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js +2 -0
  253. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
  254. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  255. package/lib/feature-libraries/object-forest/objectForest.js +2 -0
  256. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  257. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  258. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -4
  259. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  260. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -36
  261. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  262. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
  263. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  264. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  265. package/lib/feature-libraries/schema-index/codec.js +60 -10
  266. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  267. package/lib/feature-libraries/schema-index/formatV1.d.ts +1 -1
  268. package/lib/feature-libraries/schema-index/formatV2.d.ts +42 -0
  269. package/lib/feature-libraries/schema-index/formatV2.d.ts.map +1 -0
  270. package/lib/feature-libraries/schema-index/formatV2.js +23 -0
  271. package/lib/feature-libraries/schema-index/formatV2.js.map +1 -0
  272. package/lib/feature-libraries/schema-index/index.d.ts +2 -1
  273. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  274. package/lib/feature-libraries/schema-index/index.js +2 -1
  275. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  276. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +7 -2
  277. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  278. package/lib/feature-libraries/schema-index/schemaSummarizer.js +6 -6
  279. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  280. package/lib/index.d.ts +2 -2
  281. package/lib/index.d.ts.map +1 -1
  282. package/lib/index.js.map +1 -1
  283. package/lib/packageVersion.d.ts +1 -1
  284. package/lib/packageVersion.d.ts.map +1 -1
  285. package/lib/packageVersion.js +1 -1
  286. package/lib/packageVersion.js.map +1 -1
  287. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  288. package/lib/shared-tree/schematizeTree.js +1 -0
  289. package/lib/shared-tree/schematizeTree.js.map +1 -1
  290. package/lib/shared-tree/sharedTree.d.ts +5 -1
  291. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  292. package/lib/shared-tree/sharedTree.js +34 -5
  293. package/lib/shared-tree/sharedTree.js.map +1 -1
  294. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  295. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  296. package/lib/shared-tree/treeAlpha.js +3 -2
  297. package/lib/shared-tree/treeAlpha.js.map +1 -1
  298. package/lib/shared-tree-core/editManagerSummarizer.d.ts +8 -3
  299. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  300. package/lib/shared-tree-core/editManagerSummarizer.js +2 -5
  301. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  302. package/lib/shared-tree-core/sharedTreeCore.d.ts +18 -7
  303. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  304. package/lib/shared-tree-core/sharedTreeCore.js +15 -2
  305. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  306. package/lib/simple-tree/api/schemaCompatibilityTester.js +1 -1
  307. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  308. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  309. package/lib/simple-tree/api/schemaCreationUtilities.js +3 -3
  310. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  311. package/lib/simple-tree/api/schemaFactory.d.ts +15 -11
  312. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  313. package/lib/simple-tree/api/schemaFactory.js +4 -0
  314. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  315. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +41 -11
  316. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  317. package/lib/simple-tree/api/schemaFactoryAlpha.js +31 -4
  318. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  319. package/lib/simple-tree/api/storedSchema.js +2 -2
  320. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  321. package/lib/simple-tree/api/treeChangeEvents.d.ts +8 -3
  322. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  323. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
  324. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  325. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +5 -0
  326. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  327. package/lib/simple-tree/core/treeNodeKernel.js +1 -1
  328. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  329. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +5 -9
  330. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  331. package/lib/simple-tree/core/unhydratedFlexTree.js +15 -34
  332. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  333. package/lib/simple-tree/index.d.ts +2 -2
  334. package/lib/simple-tree/index.d.ts.map +1 -1
  335. package/lib/simple-tree/index.js.map +1 -1
  336. package/lib/simple-tree/leafNodeSchema.d.ts +2 -0
  337. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  338. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  339. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -1
  340. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  341. package/lib/simple-tree/node-kinds/array/arrayNode.js +3 -1
  342. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  343. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +3 -2
  344. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  345. package/lib/simple-tree/node-kinds/map/mapNode.js +5 -3
  346. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  347. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +3 -2
  348. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  349. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -1
  350. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  351. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  352. package/lib/simple-tree/prepareForInsertion.js +5 -1
  353. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  354. package/lib/simple-tree/schemaTypes.d.ts +50 -3
  355. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  356. package/lib/simple-tree/schemaTypes.js +28 -1
  357. package/lib/simple-tree/schemaTypes.js.map +1 -1
  358. package/lib/simple-tree/simpleSchema.d.ts +22 -4
  359. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  360. package/lib/simple-tree/simpleSchema.js.map +1 -1
  361. package/lib/simple-tree/toStoredSchema.d.ts +2 -0
  362. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  363. package/lib/simple-tree/toStoredSchema.js +13 -4
  364. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  365. package/lib/tableSchema.d.ts +1 -1
  366. package/lib/util/typeUtils.d.ts +2 -2
  367. package/lib/util/typeUtils.js.map +1 -1
  368. package/lib/util/utils.d.ts +2 -0
  369. package/lib/util/utils.d.ts.map +1 -1
  370. package/lib/util/utils.js.map +1 -1
  371. package/package.json +21 -21
  372. package/src/core/index.ts +3 -1
  373. package/src/core/schema-stored/formatV2.ts +78 -0
  374. package/src/core/schema-stored/index.ts +4 -1
  375. package/src/core/schema-stored/schema.ts +123 -33
  376. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +16 -11
  377. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +16 -7
  378. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +4 -4
  379. package/src/feature-libraries/detachedFieldIndexSummarizer.ts +9 -16
  380. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +32 -29
  381. package/src/feature-libraries/flex-tree/index.ts +0 -8
  382. package/src/feature-libraries/flex-tree/lazyEntity.ts +5 -1
  383. package/src/feature-libraries/flex-tree/lazyField.ts +5 -8
  384. package/src/feature-libraries/flex-tree/lazyNode.ts +17 -8
  385. package/src/feature-libraries/forest-summary/forestSummarizer.ts +9 -16
  386. package/src/feature-libraries/index.ts +1 -1
  387. package/src/feature-libraries/mapTreeCursor.ts +17 -8
  388. package/src/feature-libraries/modular-schema/fieldKindWithEditor.ts +2 -0
  389. package/src/feature-libraries/object-forest/objectForest.ts +3 -0
  390. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +11 -6
  391. package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -3
  392. package/src/feature-libraries/schema-index/codec.ts +73 -14
  393. package/src/feature-libraries/schema-index/formatV2.ts +30 -0
  394. package/src/feature-libraries/schema-index/index.ts +2 -1
  395. package/src/feature-libraries/schema-index/schemaSummarizer.ts +11 -18
  396. package/src/index.ts +5 -0
  397. package/src/packageVersion.ts +1 -1
  398. package/src/shared-tree/schematizeTree.ts +1 -0
  399. package/src/shared-tree/sharedTree.ts +42 -12
  400. package/src/shared-tree/treeAlpha.ts +8 -3
  401. package/src/shared-tree-core/editManagerSummarizer.ts +9 -16
  402. package/src/shared-tree-core/sharedTreeCore.ts +33 -24
  403. package/src/simple-tree/api/schemaCompatibilityTester.ts +1 -1
  404. package/src/simple-tree/api/schemaCreationUtilities.ts +3 -3
  405. package/src/simple-tree/api/schemaFactory.ts +16 -11
  406. package/src/simple-tree/api/schemaFactoryAlpha.ts +53 -8
  407. package/src/simple-tree/api/storedSchema.ts +4 -4
  408. package/src/simple-tree/api/treeChangeEvents.ts +8 -3
  409. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +5 -0
  410. package/src/simple-tree/core/treeNodeKernel.ts +1 -1
  411. package/src/simple-tree/core/unhydratedFlexTree.ts +22 -44
  412. package/src/simple-tree/index.ts +3 -0
  413. package/src/simple-tree/leafNodeSchema.ts +2 -0
  414. package/src/simple-tree/node-kinds/array/arrayNode.ts +5 -0
  415. package/src/simple-tree/node-kinds/map/mapNode.ts +11 -2
  416. package/src/simple-tree/node-kinds/object/objectNode.ts +9 -1
  417. package/src/simple-tree/prepareForInsertion.ts +5 -1
  418. package/src/simple-tree/schemaTypes.ts +96 -7
  419. package/src/simple-tree/simpleSchema.ts +27 -5
  420. package/src/simple-tree/toStoredSchema.ts +15 -4
  421. package/src/util/typeUtils.ts +2 -2
  422. package/src/util/utils.ts +2 -0
  423. package/dist/feature-libraries/flex-tree/navigation.d.ts +0 -46
  424. package/dist/feature-libraries/flex-tree/navigation.d.ts.map +0 -1
  425. package/dist/feature-libraries/flex-tree/navigation.js +0 -104
  426. package/dist/feature-libraries/flex-tree/navigation.js.map +0 -1
  427. package/lib/feature-libraries/flex-tree/navigation.d.ts +0 -46
  428. package/lib/feature-libraries/flex-tree/navigation.d.ts.map +0 -1
  429. package/lib/feature-libraries/flex-tree/navigation.js +0 -97
  430. package/lib/feature-libraries/flex-tree/navigation.js.map +0 -1
  431. package/src/feature-libraries/flex-tree/navigation.ts +0 -121
@@ -10,7 +10,6 @@ import {
10
10
  type AnchorNode,
11
11
  CursorLocationType,
12
12
  type FieldKey,
13
- type ITreeCursorSynchronous,
14
13
  type FieldKindIdentifier,
15
14
  type ITreeSubscriptionCursor,
16
15
  type TreeNavigationResult,
@@ -75,14 +74,14 @@ export class LazyTreeNode extends LazyEntity<Anchor> implements HydratedFlexTree
75
74
 
76
75
  public constructor(
77
76
  context: Context,
78
- public readonly schema: TreeNodeSchemaIdentifier,
77
+ public readonly type: TreeNodeSchemaIdentifier,
79
78
  cursor: ITreeSubscriptionCursor,
80
79
  public readonly anchorNode: AnchorNode,
81
80
  anchor: Anchor,
82
81
  ) {
83
82
  super(context, cursor, anchor);
84
83
  this.storedSchema =
85
- context.schema.nodeSchema.get(this.schema) ?? fail(0xb14 /* missing schema */);
84
+ context.schema.nodeSchema.get(this.type) ?? fail(0xb14 /* missing schema */);
86
85
  assert(cursor.mode === CursorLocationType.Nodes, 0x783 /* must be in nodes mode */);
87
86
  anchorNode.slots.set(flexTreeSlot, this);
88
87
  this.#removeDeleteCallback = anchorNode.events.on("afterDestroy", cleanupTree);
@@ -92,10 +91,6 @@ export class LazyTreeNode extends LazyEntity<Anchor> implements HydratedFlexTree
92
91
  return true;
93
92
  }
94
93
 
95
- public borrowCursor(): ITreeCursorSynchronous {
96
- return this.cursor as ITreeCursorSynchronous;
97
- }
98
-
99
94
  protected override tryMoveCursorToAnchor(
100
95
  cursor: ITreeSubscriptionCursor,
101
96
  ): TreeNavigationResult {
@@ -115,6 +110,20 @@ export class LazyTreeNode extends LazyEntity<Anchor> implements HydratedFlexTree
115
110
  return this.cursor.value;
116
111
  }
117
112
 
113
+ public readonly fields: Pick<Map<FieldKey, FlexTreeField>, typeof Symbol.iterator | "get"> =
114
+ {
115
+ get: (key: FieldKey): FlexTreeField | undefined => this.tryGetField(key),
116
+ [Symbol.iterator]: (): IterableIterator<[FieldKey, FlexTreeField]> =>
117
+ mapCursorFields(this.cursor, (cursor) => {
118
+ const key: FieldKey = cursor.getFieldKey();
119
+ const pair: [FieldKey, FlexTreeField] = [
120
+ key,
121
+ makeField(this.context, this.storedSchema.getFieldSchema(key).kind, cursor),
122
+ ];
123
+ return pair;
124
+ }).values(),
125
+ };
126
+
118
127
  public tryGetField(fieldKey: FieldKey): FlexTreeField | undefined {
119
128
  const schema = this.storedSchema.getFieldSchema(fieldKey);
120
129
  return inCursorField(this.cursor, fieldKey, (cursor) => {
@@ -132,7 +141,7 @@ export class LazyTreeNode extends LazyEntity<Anchor> implements HydratedFlexTree
132
141
  });
133
142
  }
134
143
 
135
- public boxedIterator(): IterableIterator<FlexTreeField> {
144
+ public [Symbol.iterator](): IterableIterator<FlexTreeField> {
136
145
  return mapCursorFields(this.cursor, (cursor) =>
137
146
  makeField(
138
147
  this.context,
@@ -8,6 +8,7 @@ import { assert } from "@fluidframework/core-utils/internal";
8
8
  import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
9
9
  import type { IIdCompressor } from "@fluidframework/id-compressor";
10
10
  import type {
11
+ IExperimentalIncrementalSummaryContext,
11
12
  ISummaryTreeWithStats,
12
13
  ITelemetryContext,
13
14
  } from "@fluidframework/runtime-definitions/internal";
@@ -95,22 +96,14 @@ export class ForestSummarizer implements Summarizable {
95
96
  return stringify(encoded);
96
97
  }
97
98
 
98
- public getAttachSummary(
99
- stringify: SummaryElementStringifier,
100
- fullTree?: boolean,
101
- trackState?: boolean,
102
- telemetryContext?: ITelemetryContext,
103
- ): ISummaryTreeWithStats {
104
- return createSingleBlobSummary(treeBlobKey, this.getTreeString(stringify));
105
- }
106
-
107
- public async summarize(
108
- stringify: SummaryElementStringifier,
109
- fullTree?: boolean,
110
- trackState?: boolean,
111
- telemetryContext?: ITelemetryContext,
112
- ): Promise<ISummaryTreeWithStats> {
113
- return createSingleBlobSummary(treeBlobKey, this.getTreeString(stringify));
99
+ public summarize(props: {
100
+ stringify: SummaryElementStringifier;
101
+ fullTree?: boolean;
102
+ trackState?: boolean;
103
+ telemetryContext?: ITelemetryContext;
104
+ incrementalSummaryContext?: IExperimentalIncrementalSummaryContext;
105
+ }): ISummaryTreeWithStats {
106
+ return createSingleBlobSummary(treeBlobKey, this.getTreeString(props.stringify));
114
107
  }
115
108
 
116
109
  public async load(
@@ -20,6 +20,7 @@ export {
20
20
  mapTreeWithField,
21
21
  type MapTreeFieldViewGeneric,
22
22
  type MapTreeNodeViewGeneric,
23
+ type MinimalFieldMap,
23
24
  } from "./mapTreeCursor.js";
24
25
  export { buildForest } from "./object-forest/index.js";
25
26
  export {
@@ -157,7 +158,6 @@ export {
157
158
  type FlexTreeOptionalField,
158
159
  type FlexTreeRequiredField,
159
160
  type FlexTreeSequenceField,
160
- Skip,
161
161
  type FlexTreeContext,
162
162
  type FlexTreeHydratedContext,
163
163
  type FlexTreeTypedField,
@@ -42,19 +42,28 @@ export interface MapTreeNodeViewGeneric<TNode> extends NodeData {
42
42
  * This is the subset of map needed to view the tree.
43
43
  * Theoretically `Symbol.iterator` and "keys" are redundant.
44
44
  */
45
- readonly fields: Pick<
46
- Map<FieldKey, MapTreeFieldViewGeneric<TNode>>,
47
- typeof Symbol.iterator | "get"
48
- >;
45
+ readonly fields: MinimalFieldMap<MapTreeFieldViewGeneric<TNode>>;
46
+ }
47
+
48
+ /**
49
+ * A minimal map for the fields of a {@link MapTreeNodeViewGeneric}.
50
+ * @remarks
51
+ * Subset of map, so can be implemented by `Map<FieldKey, TField>`.
52
+ */
53
+ export interface MinimalFieldMap<TField> {
54
+ [Symbol.iterator]: () => Iterator<[FieldKey, TField]>;
55
+ get: (key: FieldKey) => TField | undefined;
49
56
  }
50
57
 
51
58
  /**
52
59
  * A field in {@link MapTreeNodeViewGeneric}.
60
+ * @remarks
61
+ * Subset of array, so can be implemented by `TNode[]`.
53
62
  */
54
- export type MapTreeFieldViewGeneric<TNode> = Pick<
55
- readonly TNode[],
56
- typeof Symbol.iterator | "length"
57
- >;
63
+ export interface MapTreeFieldViewGeneric<TNode> {
64
+ readonly [Symbol.iterator]: () => Iterator<TNode>;
65
+ readonly length: number;
66
+ }
58
67
 
59
68
  /**
60
69
  * Like {@link MapTree} but with the minimal properties needed for reading.
@@ -79,6 +79,8 @@ export class FieldKindWithEditor<
79
79
  isNeverField(policy, originalData, {
80
80
  kind: this.identifier,
81
81
  types: originalTypes,
82
+ // Metadata is not used for this check.
83
+ persistedMetadata: undefined,
82
84
  })
83
85
  ) {
84
86
  return true;
@@ -154,6 +154,9 @@ export class ObjectForest implements IEditableForest, WithBreakable {
154
154
  // Some detached fields may have multiple nodes, so we must treat them as sequences:
155
155
  kind: FieldKinds.sequence.identifier,
156
156
  types: new Set(documentRoot.map((node) => node.type)),
157
+
158
+ // Metadata is not used for schema checks
159
+ persistedMetadata: undefined,
157
160
  };
158
161
  const maybeError = isFieldInSchema(documentRoot, fieldSchema, {
159
162
  schema,
@@ -13,7 +13,7 @@ import {
13
13
  makeVersionDispatchingCodec,
14
14
  withSchemaValidation,
15
15
  } from "../../codec/index.js";
16
- import { makeSchemaCodec, type Format as FormatV1 } from "../schema-index/index.js";
16
+ import { makeSchemaCodec } from "../schema-index/index.js";
17
17
 
18
18
  import { EncodedSchemaChange } from "./schemaChangeFormat.js";
19
19
  import type { SchemaChange } from "./schemaChangeTypes.js";
@@ -25,7 +25,10 @@ import { SchemaVersion } from "../../core/index.js";
25
25
  * @returns The composed codec family.
26
26
  */
27
27
  export function makeSchemaChangeCodecs(options: ICodecOptions): ICodecFamily<SchemaChange> {
28
- return makeCodecFamily([[SchemaVersion.v1, makeSchemaChangeCodecV1(options)]]);
28
+ return makeCodecFamily([
29
+ [SchemaVersion.v1, makeSchemaChangeCodecV1(options, SchemaVersion.v1)],
30
+ [SchemaVersion.v2, makeSchemaChangeCodecV1(options, SchemaVersion.v2)],
31
+ ]);
29
32
  }
30
33
 
31
34
  /**
@@ -43,14 +46,16 @@ export function makeSchemaChangeCodec(
43
46
  }
44
47
 
45
48
  /**
46
- * Compose the v1 schema change codec.
49
+ * Compose the change codec using mostly v1 logic.
47
50
  * @param options - The codec options.
51
+ * @param schemaWriteVersion - The schema write version.
48
52
  * @returns The composed schema change codec.
49
53
  */
50
54
  function makeSchemaChangeCodecV1(
51
55
  options: ICodecOptions,
56
+ schemaWriteVersion: SchemaVersion,
52
57
  ): IJsonCodec<SchemaChange, EncodedSchemaChange> {
53
- const schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);
58
+ const schemaCodec = makeSchemaCodec(options, schemaWriteVersion);
54
59
  const schemaChangeCodec: IJsonCodec<SchemaChange, EncodedSchemaChange> = {
55
60
  encode: (schemaChange) => {
56
61
  assert(
@@ -58,8 +63,8 @@ function makeSchemaChangeCodecV1(
58
63
  0x933 /* Inverse schema changes should never be transmitted */,
59
64
  );
60
65
  return {
61
- new: schemaCodec.encode(schemaChange.schema.new) as FormatV1,
62
- old: schemaCodec.encode(schemaChange.schema.old) as FormatV1,
66
+ new: schemaCodec.encode(schemaChange.schema.new),
67
+ old: schemaCodec.encode(schemaChange.schema.old),
63
68
  };
64
69
  },
65
70
  decode: (encoded) => {
@@ -4,11 +4,11 @@
4
4
  */
5
5
 
6
6
  import { type Static, Type } from "@sinclair/typebox";
7
- import { Format as FormatV1 } from "../schema-index/index.js";
7
+ import { JsonCompatibleReadOnlySchema } from "../../util/index.js";
8
8
 
9
9
  export const EncodedSchemaChange = Type.Object({
10
- new: FormatV1,
11
- old: FormatV1,
10
+ new: JsonCompatibleReadOnlySchema,
11
+ old: JsonCompatibleReadOnlySchema,
12
12
  });
13
13
 
14
14
  export type EncodedSchemaChange = Static<typeof EncodedSchemaChange>;
@@ -20,13 +20,14 @@ import {
20
20
  type TreeNodeStoredSchema,
21
21
  type TreeStoredSchema,
22
22
  decodeFieldSchema,
23
- encodeFieldSchema,
24
- type schemaFormatV1,
23
+ encodeFieldSchemaV1,
24
+ encodeFieldSchemaV2,
25
25
  storedSchemaDecodeDispatcher,
26
26
  } from "../../core/index.js";
27
27
  import { brand, type JsonCompatible } from "../../util/index.js";
28
28
 
29
29
  import { Format as FormatV1 } from "./formatV1.js";
30
+ import { Format as FormatV2 } from "./formatV2.js";
30
31
 
31
32
  /**
32
33
  * Convert a FluidClientVersion to a SchemaVersion.
@@ -62,7 +63,10 @@ export function makeSchemaCodec(
62
63
  * @returns The composed codec family.
63
64
  */
64
65
  export function makeSchemaCodecs(options: ICodecOptions): ICodecFamily<TreeStoredSchema> {
65
- return makeCodecFamily([[SchemaVersion.v1, makeSchemaCodecV1(options)]]);
66
+ return makeCodecFamily([
67
+ [SchemaVersion.v1, makeSchemaCodecV1(options)],
68
+ [SchemaVersion.v2, makeSchemaCodecV2(options)],
69
+ ]);
66
70
  }
67
71
 
68
72
  /**
@@ -74,36 +78,79 @@ export function makeSchemaCodecs(options: ICodecOptions): ICodecFamily<TreeStore
74
78
  export function encodeRepo(repo: TreeStoredSchema, version: SchemaVersion): JsonCompatible {
75
79
  switch (version) {
76
80
  case SchemaVersion.v1:
77
- return encodeRepoV1(repo);
81
+ return encodeRepoV1(repo) as JsonCompatible;
82
+ case SchemaVersion.v2:
83
+ return encodeRepoV2(repo) as JsonCompatible;
78
84
  default:
79
85
  unreachableCase(version);
80
86
  }
81
87
  }
82
88
 
83
89
  function encodeRepoV1(repo: TreeStoredSchema): FormatV1 {
84
- const nodeSchema: Record<string, schemaFormatV1.TreeNodeSchemaDataFormat> =
85
- Object.create(null);
86
- const rootFieldSchema = encodeFieldSchema(repo.rootFieldSchema);
90
+ const nodeSchema = encodeNodeSchema(repo, (schema) => schema.encodeV1());
91
+ const rootFieldSchema = encodeFieldSchemaV1(repo.rootFieldSchema);
92
+ return {
93
+ version: SchemaVersion.v1,
94
+ nodes: nodeSchema,
95
+ root: rootFieldSchema,
96
+ };
97
+ }
98
+
99
+ function encodeRepoV2(repo: TreeStoredSchema): FormatV2 {
100
+ const nodeSchema = encodeNodeSchema(repo, (schema) => schema.encodeV2());
101
+ const rootFieldSchema = encodeFieldSchemaV2(repo.rootFieldSchema);
102
+ return {
103
+ version: SchemaVersion.v2,
104
+ nodes: nodeSchema,
105
+ root: rootFieldSchema,
106
+ };
107
+ }
108
+
109
+ /**
110
+ * Shared logic for encoding node schemas.
111
+ * @param repo - The stored schema to encode.
112
+ * @param encodeValue - A function which encodes a single node schema.
113
+ * @returns The encoded node schema.
114
+ */
115
+ function encodeNodeSchema<TFormat>(
116
+ repo: TreeStoredSchema,
117
+ encodeValue: (schema: TreeNodeStoredSchema) => TFormat,
118
+ ): Record<string, TFormat> {
119
+ const nodeSchema: Record<string, TFormat> = Object.create(null);
87
120
  for (const name of [...repo.nodeSchema.keys()].sort()) {
88
121
  const schema = repo.nodeSchema.get(name) ?? fail(0xb28 /* missing schema */);
89
122
  Object.defineProperty(nodeSchema, name, {
90
123
  enumerable: true,
91
124
  configurable: true,
92
125
  writable: true,
93
- value: schema.encode(),
126
+ value: encodeValue(schema),
94
127
  });
95
128
  }
129
+
130
+ return nodeSchema;
131
+ }
132
+
133
+ function decodeV1(f: FormatV1): TreeStoredSchema {
134
+ const nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();
135
+ for (const [key, schema] of Object.entries(f.nodes)) {
136
+ const storedSchemaDecoder = storedSchemaDecodeDispatcher.dispatch(schema);
137
+
138
+ // No metadata in v1, so pass undefined
139
+ nodeSchema.set(brand(key), storedSchemaDecoder(undefined));
140
+ }
96
141
  return {
97
- version: SchemaVersion.v1,
98
- nodes: nodeSchema,
99
- root: rootFieldSchema,
142
+ rootFieldSchema: decodeFieldSchema(f.root),
143
+ nodeSchema,
100
144
  };
101
145
  }
102
146
 
103
- function decode(f: FormatV1): TreeStoredSchema {
147
+ function decodeV2(f: FormatV2): TreeStoredSchema {
104
148
  const nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();
105
149
  for (const [key, schema] of Object.entries(f.nodes)) {
106
- nodeSchema.set(brand(key), storedSchemaDecodeDispatcher.dispatch(schema));
150
+ const storedSchemaDecoder = storedSchemaDecodeDispatcher.dispatch(schema.kind);
151
+
152
+ // Pass in the node metadata
153
+ nodeSchema.set(brand(key), storedSchemaDecoder(schema.metadata));
107
154
  }
108
155
  return {
109
156
  rootFieldSchema: decodeFieldSchema(f.root),
@@ -119,6 +166,18 @@ function decode(f: FormatV1): TreeStoredSchema {
119
166
  function makeSchemaCodecV1(options: ICodecOptions): IJsonCodec<TreeStoredSchema, FormatV1> {
120
167
  return makeVersionedValidatedCodec(options, new Set([SchemaVersion.v1]), FormatV1, {
121
168
  encode: (data: TreeStoredSchema) => encodeRepoV1(data),
122
- decode: (data: FormatV1) => decode(data),
169
+ decode: (data: FormatV1) => decodeV1(data),
170
+ });
171
+ }
172
+
173
+ /**
174
+ * Creates a codec which performs synchronous monolithic encoding of schema content.
175
+ * @param options - Specifies common codec options, including which `validator` to use.
176
+ * @returns The codec.
177
+ */
178
+ function makeSchemaCodecV2(options: ICodecOptions): IJsonCodec<TreeStoredSchema, FormatV2> {
179
+ return makeVersionedValidatedCodec(options, new Set([SchemaVersion.v2]), FormatV2, {
180
+ encode: (data: TreeStoredSchema) => encodeRepoV2(data),
181
+ decode: (data: FormatV2) => decodeV2(data),
123
182
  });
124
183
  }
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { type ObjectOptions, type Static, Type } from "@sinclair/typebox";
7
+
8
+ import { SchemaVersion, schemaFormatV2 } from "../../core/index.js";
9
+
10
+ const noAdditionalProps: ObjectOptions = { additionalProperties: false };
11
+
12
+ /**
13
+ * Format for encoding as json.
14
+ *
15
+ * For consistency all lists are sorted and undefined values are omitted.
16
+ *
17
+ * This chooses to use lists of named objects instead of maps:
18
+ * this choice is somewhat arbitrary, but avoids user data being used as object keys,
19
+ * which can sometimes be an issue (for example handling that for "__proto__" can require care).
20
+ * It also makes it simpler to determinately sort by keys.
21
+ */
22
+ export const Format = Type.Object(
23
+ {
24
+ version: Type.Literal(SchemaVersion.v2),
25
+ nodes: Type.Record(Type.String(), schemaFormatV2.TreeNodeSchemaDataFormat),
26
+ root: schemaFormatV2.FieldSchemaFormat,
27
+ },
28
+ noAdditionalProps,
29
+ );
30
+ export type Format = Static<typeof Format>;
@@ -9,4 +9,5 @@ export {
9
9
  makeSchemaCodecs,
10
10
  clientVersionToSchemaVersion,
11
11
  } from "./codec.js";
12
- export { Format } from "./formatV1.js";
12
+ export { Format as FormatV1 } from "./formatV1.js";
13
+ export { Format as FormatV2 } from "./formatV2.js";
@@ -51,15 +51,18 @@ export class SchemaSummarizer implements Summarizable {
51
51
  });
52
52
  }
53
53
 
54
- public getAttachSummary(
55
- stringify: SummaryElementStringifier,
56
- fullTree?: boolean,
57
- trackState?: boolean,
58
- telemetryContext?: ITelemetryContext,
59
- incrementalSummaryContext?: IExperimentalIncrementalSummaryContext | undefined,
60
- ): ISummaryTreeWithStats {
54
+ public summarize(props: {
55
+ stringify: SummaryElementStringifier;
56
+ fullTree?: boolean;
57
+ trackState?: boolean;
58
+ telemetryContext?: ITelemetryContext;
59
+ incrementalSummaryContext?: IExperimentalIncrementalSummaryContext;
60
+ }): ISummaryTreeWithStats {
61
+ const incrementalSummaryContext = props.incrementalSummaryContext;
61
62
  const builder = new SummaryTreeBuilder();
63
+ const fullTree = props.fullTree ?? false;
62
64
  if (
65
+ !fullTree &&
63
66
  incrementalSummaryContext !== undefined &&
64
67
  this.schemaIndexLastChangedSeq !== undefined &&
65
68
  incrementalSummaryContext.latestSummarySequenceNumber >= this.schemaIndexLastChangedSeq
@@ -67,7 +70,7 @@ export class SchemaSummarizer implements Summarizable {
67
70
  builder.addHandle(
68
71
  schemaStringKey,
69
72
  SummaryType.Blob,
70
- `${incrementalSummaryContext.summaryPath}/indexes/${this.key}/${schemaStringKey}`,
73
+ `${incrementalSummaryContext.summaryPath}/${schemaStringKey}`,
71
74
  );
72
75
  } else {
73
76
  const dataString = JSON.stringify(this.codec.encode(this.schema));
@@ -76,16 +79,6 @@ export class SchemaSummarizer implements Summarizable {
76
79
  return builder.getSummaryTree();
77
80
  }
78
81
 
79
- public async summarize(
80
- stringify: SummaryElementStringifier,
81
- fullTree?: boolean,
82
- trackState?: boolean,
83
- telemetryContext?: ITelemetryContext,
84
- incrementalSummaryContext?: IExperimentalIncrementalSummaryContext | undefined,
85
- ): Promise<ISummaryTreeWithStats> {
86
- throw new Error("Method not implemented.");
87
- }
88
-
89
82
  public async load(
90
83
  services: IChannelStorageService,
91
84
  parse: SummaryElementParser,
package/src/index.ts CHANGED
@@ -113,6 +113,7 @@ export {
113
113
  type TreeNodeSchemaClass,
114
114
  type SchemaCompatibilityStatus,
115
115
  type FieldProps,
116
+ type FieldPropsAlpha,
116
117
  type InternalTreeNode,
117
118
  type WithType,
118
119
  type NodeChangedData,
@@ -198,6 +199,7 @@ export {
198
199
  type LazyItem,
199
200
  type Unenforced,
200
201
  type SimpleNodeSchemaBase,
202
+ type SimpleNodeSchemaBaseAlpha,
201
203
  type SimpleTreeSchema,
202
204
  type SimpleNodeSchema,
203
205
  type SimpleFieldSchema,
@@ -215,6 +217,7 @@ export {
215
217
  type TreeBranchEvents,
216
218
  asTreeViewAlpha,
217
219
  type NodeSchemaOptions,
220
+ type NodeSchemaOptionsAlpha,
218
221
  type NodeSchemaMetadata,
219
222
  type SchemaStatics,
220
223
  type ITreeAlpha,
@@ -282,6 +285,8 @@ export type {
282
285
  PopUnion,
283
286
  JsonCompatible,
284
287
  JsonCompatibleObject,
288
+ JsonCompatibleReadOnly,
289
+ JsonCompatibleReadOnlyObject,
285
290
  } from "./util/index.js";
286
291
  export { cloneWithReplacements } from "./util/index.js";
287
292
 
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/tree";
9
- export const pkgVersion = "2.42.0";
9
+ export const pkgVersion = "2.43.0-343119";
@@ -68,6 +68,7 @@ export function initializeContent(
68
68
  rootFieldSchema: {
69
69
  kind: FieldKinds.optional.identifier,
70
70
  types: rootSchema.types,
71
+ persistedMetadata: rootSchema.persistedMetadata,
71
72
  },
72
73
  };
73
74
  }
@@ -64,7 +64,7 @@ import {
64
64
  makeTreeChunker,
65
65
  } from "../feature-libraries/index.js";
66
66
  // eslint-disable-next-line import/no-internal-modules
67
- import type { Format } from "../feature-libraries/schema-index/index.js";
67
+ import type { FormatV1 } from "../feature-libraries/schema-index/index.js";
68
68
  import {
69
69
  type ClonableSchemaAndPolicy,
70
70
  DefaultResubmitMachine,
@@ -92,12 +92,6 @@ import {
92
92
  type ITreeAlpha,
93
93
  type SimpleObjectFieldSchema,
94
94
  } from "../simple-tree/index.js";
95
- import {
96
- type Breakable,
97
- breakingClass,
98
- type JsonCompatible,
99
- throwIfBroken,
100
- } from "../util/index.js";
101
95
 
102
96
  import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
103
97
  import { SharedTreeReadonlyChangeEnricher } from "./sharedTreeChangeEnricher.js";
@@ -105,6 +99,12 @@ import { SharedTreeChangeFamily } from "./sharedTreeChangeFamily.js";
105
99
  import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
106
100
  import type { SharedTreeEditBuilder } from "./sharedTreeEditBuilder.js";
107
101
  import { type TreeCheckout, type BranchableTree, createTreeCheckout } from "./treeCheckout.js";
102
+ import {
103
+ type Breakable,
104
+ breakingClass,
105
+ type JsonCompatible,
106
+ throwIfBroken,
107
+ } from "../util/index.js";
108
108
 
109
109
  /**
110
110
  * Copy of data from an {@link ITreePrivate} at some point in time.
@@ -192,6 +192,10 @@ const formatVersionToTopLevelCodecVersions = new Map<number, ExplicitCodecVersio
192
192
  4,
193
193
  { forest: 1, schema: 1, detachedFieldIndex: 1, editManager: 4, message: 4, fieldBatch: 1 },
194
194
  ],
195
+ [
196
+ 5,
197
+ { forest: 1, schema: 2, detachedFieldIndex: 1, editManager: 4, message: 4, fieldBatch: 1 },
198
+ ],
195
199
  ]);
196
200
 
197
201
  function getCodecVersions(formatVersion: number): ExplicitCodecVersions {
@@ -511,7 +515,7 @@ export function persistedToSimpleSchema(
511
515
  options: ICodecOptions,
512
516
  ): SimpleTreeSchema {
513
517
  const schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);
514
- const stored = schemaCodec.decode(persisted as Format);
518
+ const stored = schemaCodec.decode(persisted as FormatV1);
515
519
  return exportSimpleSchema(stored);
516
520
  }
517
521
 
@@ -572,6 +576,11 @@ export const SharedTreeFormatVersion = {
572
576
  * Requires \@fluidframework/tree \>= 2.0.0.
573
577
  */
574
578
  v3: 3,
579
+
580
+ /**
581
+ * Requires \@fluidframework/tree \>= 2.0.0.
582
+ */
583
+ v5: 5,
575
584
  } as const;
576
585
 
577
586
  /**
@@ -750,20 +759,35 @@ function exportSimpleFieldSchemaStored(schema: TreeFieldStoredSchema): SimpleFie
750
759
  default:
751
760
  fail(0xaca /* invalid field kind */);
752
761
  }
753
- return { kind, allowedTypesIdentifiers: schema.types, metadata: {} };
762
+ return {
763
+ kind,
764
+ allowedTypesIdentifiers: schema.types,
765
+ metadata: {},
766
+ persistedMetadata: schema.persistedMetadata,
767
+ };
754
768
  }
755
769
 
770
+ /**
771
+ * Export a {@link SimpleNodeSchema} from a {@link TreeNodeStoredSchema}.
772
+ * @privateRemarks
773
+ * TODO: Persist node metadata once schema FormatV2 is supported.
774
+ */
756
775
  function exportSimpleNodeSchemaStored(schema: TreeNodeStoredSchema): SimpleNodeSchema {
757
776
  const arrayTypes = tryStoredSchemaAsArray(schema);
758
777
  if (arrayTypes !== undefined) {
759
- return { kind: NodeKind.Array, allowedTypesIdentifiers: arrayTypes, metadata: {} };
778
+ return {
779
+ kind: NodeKind.Array,
780
+ allowedTypesIdentifiers: arrayTypes,
781
+ metadata: {},
782
+ persistedMetadata: schema.metadata,
783
+ };
760
784
  }
761
785
  if (schema instanceof ObjectNodeStoredSchema) {
762
786
  const fields = new Map<FieldKey, SimpleObjectFieldSchema>();
763
787
  for (const [storedKey, field] of schema.objectNodeFields) {
764
788
  fields.set(storedKey, { ...exportSimpleFieldSchemaStored(field), storedKey });
765
789
  }
766
- return { kind: NodeKind.Object, fields, metadata: {} };
790
+ return { kind: NodeKind.Object, fields, metadata: {}, persistedMetadata: schema.metadata };
767
791
  }
768
792
  if (schema instanceof MapNodeStoredSchema) {
769
793
  assert(
@@ -774,10 +798,16 @@ function exportSimpleNodeSchemaStored(schema: TreeNodeStoredSchema): SimpleNodeS
774
798
  kind: NodeKind.Map,
775
799
  allowedTypesIdentifiers: schema.mapFields.types,
776
800
  metadata: {},
801
+ persistedMetadata: schema.metadata,
777
802
  };
778
803
  }
779
804
  if (schema instanceof LeafNodeStoredSchema) {
780
- return { kind: NodeKind.Leaf, leafKind: schema.leafValue, metadata: {} };
805
+ return {
806
+ kind: NodeKind.Leaf,
807
+ leafKind: schema.leafValue,
808
+ metadata: {},
809
+ persistedMetadata: schema.metadata,
810
+ };
781
811
  }
782
812
  fail(0xacb /* invalid schema kind */);
783
813
  }
@@ -42,7 +42,12 @@ import {
42
42
  getOrCreateNodeFromInnerNode,
43
43
  } from "../simple-tree/index.js";
44
44
  import { extractFromOpaque, type JsonCompatible } from "../util/index.js";
45
- import type { CodecWriteOptions, ICodecOptions } from "../codec/index.js";
45
+ import {
46
+ FluidClientVersion,
47
+ noopValidator,
48
+ type ICodecOptions,
49
+ type CodecWriteOptions,
50
+ } from "../codec/index.js";
46
51
  import type { ITreeCursorSynchronous } from "../core/index.js";
47
52
  import {
48
53
  cursorForMapTreeField,
@@ -58,7 +63,6 @@ import {
58
63
  } from "../feature-libraries/index.js";
59
64
  import { independentInitializedView, type ViewContent } from "./independentView.js";
60
65
  import { SchematizingSimpleTreeView, ViewSlot } from "./schematizingTreeView.js";
61
- import { currentVersion, noopValidator } from "../codec/index.js";
62
66
 
63
67
  const identifier: TreeIdentifierUtils = (node: TreeNode): string | undefined => {
64
68
  const nodeIdentifier = getIdentifierFromNode(node, "uncompressed");
@@ -463,7 +467,8 @@ export const TreeAlpha: TreeAlpha = {
463
467
  ): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
464
468
  const config = new TreeViewConfigurationAlpha({ schema });
465
469
  const content: ViewContent = {
466
- schema: extractPersistedSchema(config, currentVersion),
470
+ // Always use a v1 schema codec for consistency.
471
+ schema: extractPersistedSchema(config, FluidClientVersion.v2_0),
467
472
  tree: compressedData,
468
473
  idCompressor: options.idCompressor ?? createIdCompressor(),
469
474
  };