@fluidframework/tree 2.53.1 → 2.60.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 (424) hide show
  1. package/.eslintrc.cjs +0 -19
  2. package/.mocharc.customBenchmarks.cjs +1 -9
  3. package/CHANGELOG.md +56 -0
  4. package/api-report/tree.alpha.api.md +50 -36
  5. package/api-report/tree.beta.api.md +15 -1
  6. package/api-report/{tree.legacy.alpha.api.md → tree.legacy.beta.api.md} +5 -5
  7. package/api-report/tree.legacy.public.api.md +1 -1
  8. package/api-report/tree.public.api.md +1 -1
  9. package/dist/alpha.d.ts +8 -2
  10. package/dist/beta.d.ts +3 -0
  11. package/dist/codec/codec.d.ts +43 -6
  12. package/dist/codec/codec.d.ts.map +1 -1
  13. package/dist/codec/codec.js +22 -2
  14. package/dist/codec/codec.js.map +1 -1
  15. package/dist/codec/index.d.ts +1 -1
  16. package/dist/codec/index.d.ts.map +1 -1
  17. package/dist/codec/index.js +4 -1
  18. package/dist/codec/index.js.map +1 -1
  19. package/dist/external-utilities/index.d.ts +1 -1
  20. package/dist/external-utilities/index.d.ts.map +1 -1
  21. package/dist/external-utilities/index.js +2 -1
  22. package/dist/external-utilities/index.js.map +1 -1
  23. package/dist/external-utilities/typeboxValidator.d.ts +6 -1
  24. package/dist/external-utilities/typeboxValidator.d.ts.map +1 -1
  25. package/dist/external-utilities/typeboxValidator.js +7 -1
  26. package/dist/external-utilities/typeboxValidator.js.map +1 -1
  27. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
  28. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  29. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +28 -5
  30. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  31. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
  32. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
  34. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  35. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
  36. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  37. package/dist/feature-libraries/chunked-forest/codec/codecs.js +9 -2
  38. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  39. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
  40. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +91 -16
  42. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
  44. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/codec/format.js +10 -1
  46. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  48. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  49. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
  51. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +17 -6
  53. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  55. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  57. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  58. package/dist/feature-libraries/forest-summary/codec.js +3 -0
  59. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  60. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
  61. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  62. package/dist/feature-libraries/forest-summary/forestSummarizer.js +76 -38
  63. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  64. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
  65. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
  66. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +322 -0
  67. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
  68. package/dist/feature-libraries/forest-summary/index.d.ts +1 -1
  69. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  70. package/dist/feature-libraries/forest-summary/index.js +2 -1
  71. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  72. package/dist/feature-libraries/index.d.ts +1 -1
  73. package/dist/feature-libraries/index.d.ts.map +1 -1
  74. package/dist/feature-libraries/index.js +2 -1
  75. package/dist/feature-libraries/index.js.map +1 -1
  76. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  77. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  78. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +1 -1
  79. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  80. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
  81. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  82. package/dist/feature-libraries/treeCompressionUtils.d.ts +15 -0
  83. package/dist/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
  84. package/dist/feature-libraries/treeCompressionUtils.js +16 -1
  85. package/dist/feature-libraries/treeCompressionUtils.js.map +1 -1
  86. package/dist/index.d.ts +3 -3
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +6 -2
  89. package/dist/index.js.map +1 -1
  90. package/dist/jsonDomainSchema.d.ts +1 -1
  91. package/dist/jsonDomainSchema.d.ts.map +1 -1
  92. package/dist/packageVersion.d.ts +1 -1
  93. package/dist/packageVersion.js +1 -1
  94. package/dist/packageVersion.js.map +1 -1
  95. package/dist/shared-tree/schematizingTreeView.d.ts +1 -1
  96. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  97. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  98. package/dist/shared-tree/sharedTree.d.ts +23 -6
  99. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  100. package/dist/shared-tree/sharedTree.js +4 -1
  101. package/dist/shared-tree/sharedTree.js.map +1 -1
  102. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  103. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  104. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  105. package/dist/shared-tree/tree.d.ts.map +1 -1
  106. package/dist/shared-tree/tree.js +3 -0
  107. package/dist/shared-tree/tree.js.map +1 -1
  108. package/dist/shared-tree/treeAlpha.d.ts +9 -11
  109. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  110. package/dist/shared-tree/treeAlpha.js.map +1 -1
  111. package/dist/shared-tree/treeCheckout.d.ts +2 -2
  112. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  113. package/dist/shared-tree/treeCheckout.js.map +1 -1
  114. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  115. package/dist/shared-tree-core/sharedTreeCore.js +13 -0
  116. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  117. package/dist/sharedTreeAttributes.d.ts +2 -2
  118. package/dist/sharedTreeAttributes.js +2 -2
  119. package/dist/sharedTreeAttributes.js.map +1 -1
  120. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  121. package/dist/simple-tree/api/conciseTree.js +1 -1
  122. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  123. package/dist/simple-tree/api/customTree.d.ts +39 -11
  124. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  125. package/dist/simple-tree/api/customTree.js +79 -19
  126. package/dist/simple-tree/api/customTree.js.map +1 -1
  127. package/dist/simple-tree/api/getJsonSchema.d.ts +7 -2
  128. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  129. package/dist/simple-tree/api/getJsonSchema.js +1 -0
  130. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  131. package/dist/simple-tree/api/index.d.ts +2 -1
  132. package/dist/simple-tree/api/index.d.ts.map +1 -1
  133. package/dist/simple-tree/api/index.js +4 -1
  134. package/dist/simple-tree/api/index.js.map +1 -1
  135. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
  136. package/dist/simple-tree/api/schemaCreationUtilities.js +1 -1
  137. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  138. package/dist/simple-tree/api/schemaFactory.d.ts +9 -6
  139. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  140. package/dist/simple-tree/api/schemaFactory.js +8 -7
  141. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  142. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
  143. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  144. package/dist/simple-tree/api/schemaFactoryAlpha.js +21 -25
  145. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  146. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
  147. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
  148. package/dist/simple-tree/api/schemaFactoryBeta.js +26 -0
  149. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -0
  150. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
  151. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  152. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
  153. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  154. package/dist/simple-tree/api/transactionTypes.d.ts +1 -0
  155. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  156. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  157. package/dist/simple-tree/api/tree.d.ts +68 -74
  158. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  159. package/dist/simple-tree/api/tree.js.map +1 -1
  160. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  161. package/dist/simple-tree/api/verboseTree.js +3 -3
  162. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  163. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
  164. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
  165. package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
  166. package/dist/simple-tree/fieldSchema.d.ts +3 -4
  167. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  168. package/dist/simple-tree/fieldSchema.js +0 -3
  169. package/dist/simple-tree/fieldSchema.js.map +1 -1
  170. package/dist/simple-tree/index.d.ts +1 -1
  171. package/dist/simple-tree/index.d.ts.map +1 -1
  172. package/dist/simple-tree/index.js +4 -2
  173. package/dist/simple-tree/index.js.map +1 -1
  174. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  175. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -3
  176. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  177. package/dist/simple-tree/simpleSchema.d.ts +12 -0
  178. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  179. package/dist/simple-tree/simpleSchema.js.map +1 -1
  180. package/dist/simple-tree/toStoredSchema.d.ts +0 -3
  181. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  182. package/dist/simple-tree/toStoredSchema.js +0 -3
  183. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  184. package/dist/tableSchema.d.ts +11 -80
  185. package/dist/tableSchema.d.ts.map +1 -1
  186. package/dist/tableSchema.js +200 -117
  187. package/dist/tableSchema.js.map +1 -1
  188. package/dist/treeFactory.d.ts +1 -2
  189. package/dist/treeFactory.d.ts.map +1 -1
  190. package/dist/treeFactory.js +1 -2
  191. package/dist/treeFactory.js.map +1 -1
  192. package/lib/alpha.d.ts +8 -2
  193. package/lib/beta.d.ts +3 -0
  194. package/lib/codec/codec.d.ts +43 -6
  195. package/lib/codec/codec.d.ts.map +1 -1
  196. package/lib/codec/codec.js +19 -1
  197. package/lib/codec/codec.js.map +1 -1
  198. package/lib/codec/index.d.ts +1 -1
  199. package/lib/codec/index.d.ts.map +1 -1
  200. package/lib/codec/index.js +1 -1
  201. package/lib/codec/index.js.map +1 -1
  202. package/lib/external-utilities/index.d.ts +1 -1
  203. package/lib/external-utilities/index.d.ts.map +1 -1
  204. package/lib/external-utilities/index.js +1 -1
  205. package/lib/external-utilities/index.js.map +1 -1
  206. package/lib/external-utilities/typeboxValidator.d.ts +6 -1
  207. package/lib/external-utilities/typeboxValidator.d.ts.map +1 -1
  208. package/lib/external-utilities/typeboxValidator.js +6 -0
  209. package/lib/external-utilities/typeboxValidator.js.map +1 -1
  210. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
  211. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  212. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +27 -5
  213. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  214. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
  215. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  216. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
  217. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  218. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
  219. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  220. package/lib/feature-libraries/chunked-forest/codec/codecs.js +10 -3
  221. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  222. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
  223. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  224. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +87 -14
  225. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  226. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
  227. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  228. package/lib/feature-libraries/chunked-forest/codec/format.js +9 -0
  229. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  230. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  231. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  232. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  233. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
  234. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  235. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +18 -7
  236. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  237. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  238. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  239. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  240. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  241. package/lib/feature-libraries/forest-summary/codec.js +3 -0
  242. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  243. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
  244. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  245. package/lib/feature-libraries/forest-summary/forestSummarizer.js +75 -37
  246. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  247. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
  248. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
  249. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +318 -0
  250. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
  251. package/lib/feature-libraries/forest-summary/index.d.ts +1 -1
  252. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  253. package/lib/feature-libraries/forest-summary/index.js +1 -1
  254. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  255. package/lib/feature-libraries/index.d.ts +1 -1
  256. package/lib/feature-libraries/index.d.ts.map +1 -1
  257. package/lib/feature-libraries/index.js +1 -1
  258. package/lib/feature-libraries/index.js.map +1 -1
  259. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  260. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  261. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +3 -3
  262. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  263. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
  264. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  265. package/lib/feature-libraries/treeCompressionUtils.d.ts +15 -0
  266. package/lib/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
  267. package/lib/feature-libraries/treeCompressionUtils.js +15 -0
  268. package/lib/feature-libraries/treeCompressionUtils.js.map +1 -1
  269. package/lib/index.d.ts +3 -3
  270. package/lib/index.d.ts.map +1 -1
  271. package/lib/index.js +4 -4
  272. package/lib/index.js.map +1 -1
  273. package/lib/jsonDomainSchema.d.ts +1 -1
  274. package/lib/jsonDomainSchema.d.ts.map +1 -1
  275. package/lib/packageVersion.d.ts +1 -1
  276. package/lib/packageVersion.js +1 -1
  277. package/lib/packageVersion.js.map +1 -1
  278. package/lib/shared-tree/schematizingTreeView.d.ts +1 -1
  279. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  280. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  281. package/lib/shared-tree/sharedTree.d.ts +23 -6
  282. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  283. package/lib/shared-tree/sharedTree.js +4 -1
  284. package/lib/shared-tree/sharedTree.js.map +1 -1
  285. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  286. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  287. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  288. package/lib/shared-tree/tree.d.ts.map +1 -1
  289. package/lib/shared-tree/tree.js +3 -0
  290. package/lib/shared-tree/tree.js.map +1 -1
  291. package/lib/shared-tree/treeAlpha.d.ts +9 -11
  292. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  293. package/lib/shared-tree/treeAlpha.js.map +1 -1
  294. package/lib/shared-tree/treeCheckout.d.ts +2 -2
  295. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  296. package/lib/shared-tree/treeCheckout.js.map +1 -1
  297. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  298. package/lib/shared-tree-core/sharedTreeCore.js +13 -0
  299. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  300. package/lib/sharedTreeAttributes.d.ts +2 -2
  301. package/lib/sharedTreeAttributes.js +2 -2
  302. package/lib/sharedTreeAttributes.js.map +1 -1
  303. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  304. package/lib/simple-tree/api/conciseTree.js +2 -2
  305. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  306. package/lib/simple-tree/api/customTree.d.ts +39 -11
  307. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  308. package/lib/simple-tree/api/customTree.js +79 -19
  309. package/lib/simple-tree/api/customTree.js.map +1 -1
  310. package/lib/simple-tree/api/getJsonSchema.d.ts +7 -2
  311. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  312. package/lib/simple-tree/api/getJsonSchema.js +1 -0
  313. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  314. package/lib/simple-tree/api/index.d.ts +2 -1
  315. package/lib/simple-tree/api/index.d.ts.map +1 -1
  316. package/lib/simple-tree/api/index.js +2 -1
  317. package/lib/simple-tree/api/index.js.map +1 -1
  318. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
  319. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
  320. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  321. package/lib/simple-tree/api/schemaFactory.d.ts +9 -6
  322. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  323. package/lib/simple-tree/api/schemaFactory.js +6 -6
  324. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  325. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
  326. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  327. package/lib/simple-tree/api/schemaFactoryAlpha.js +22 -26
  328. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  329. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
  330. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
  331. package/lib/simple-tree/api/schemaFactoryBeta.js +22 -0
  332. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -0
  333. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
  334. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  335. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
  336. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  337. package/lib/simple-tree/api/transactionTypes.d.ts +1 -0
  338. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  339. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  340. package/lib/simple-tree/api/tree.d.ts +68 -74
  341. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  342. package/lib/simple-tree/api/tree.js.map +1 -1
  343. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  344. package/lib/simple-tree/api/verboseTree.js +4 -4
  345. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  346. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
  347. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
  348. package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
  349. package/lib/simple-tree/fieldSchema.d.ts +3 -4
  350. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  351. package/lib/simple-tree/fieldSchema.js +0 -3
  352. package/lib/simple-tree/fieldSchema.js.map +1 -1
  353. package/lib/simple-tree/index.d.ts +1 -1
  354. package/lib/simple-tree/index.d.ts.map +1 -1
  355. package/lib/simple-tree/index.js +1 -1
  356. package/lib/simple-tree/index.js.map +1 -1
  357. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  358. package/lib/simple-tree/node-kinds/record/recordNode.js +2 -3
  359. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  360. package/lib/simple-tree/simpleSchema.d.ts +12 -0
  361. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  362. package/lib/simple-tree/simpleSchema.js.map +1 -1
  363. package/lib/simple-tree/toStoredSchema.d.ts +0 -3
  364. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  365. package/lib/simple-tree/toStoredSchema.js +0 -3
  366. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  367. package/lib/tableSchema.d.ts +11 -80
  368. package/lib/tableSchema.d.ts.map +1 -1
  369. package/lib/tableSchema.js +201 -118
  370. package/lib/tableSchema.js.map +1 -1
  371. package/lib/treeFactory.d.ts +1 -2
  372. package/lib/treeFactory.d.ts.map +1 -1
  373. package/lib/treeFactory.js +1 -2
  374. package/lib/treeFactory.js.map +1 -1
  375. package/package.json +21 -21
  376. package/src/codec/codec.ts +52 -7
  377. package/src/codec/index.ts +4 -0
  378. package/src/external-utilities/index.ts +1 -1
  379. package/src/external-utilities/typeboxValidator.ts +7 -1
  380. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +38 -4
  381. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -3
  382. package/src/feature-libraries/chunked-forest/codec/codecs.ts +96 -8
  383. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +123 -19
  384. package/src/feature-libraries/chunked-forest/codec/format.ts +11 -0
  385. package/src/feature-libraries/chunked-forest/codec/index.ts +4 -0
  386. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +28 -3
  387. package/src/feature-libraries/chunked-forest/index.ts +2 -0
  388. package/src/feature-libraries/forest-summary/codec.ts +3 -0
  389. package/src/feature-libraries/forest-summary/forestSummarizer.ts +118 -50
  390. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +511 -0
  391. package/src/feature-libraries/forest-summary/index.ts +1 -1
  392. package/src/feature-libraries/index.ts +5 -1
  393. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +8 -4
  394. package/src/feature-libraries/treeCompressionUtils.ts +19 -0
  395. package/src/index.ts +6 -1
  396. package/src/packageVersion.ts +1 -1
  397. package/src/shared-tree/schematizingTreeView.ts +1 -1
  398. package/src/shared-tree/sharedTree.ts +37 -4
  399. package/src/shared-tree/sharedTreeChangeFamily.ts +2 -2
  400. package/src/shared-tree/tree.ts +3 -0
  401. package/src/shared-tree/treeAlpha.ts +10 -11
  402. package/src/shared-tree/treeCheckout.ts +2 -2
  403. package/src/shared-tree-core/sharedTreeCore.ts +17 -0
  404. package/src/sharedTreeAttributes.ts +2 -2
  405. package/src/simple-tree/api/conciseTree.ts +2 -1
  406. package/src/simple-tree/api/customTree.ts +102 -32
  407. package/src/simple-tree/api/getJsonSchema.ts +7 -2
  408. package/src/simple-tree/api/index.ts +3 -0
  409. package/src/simple-tree/api/schemaCreationUtilities.ts +1 -1
  410. package/src/simple-tree/api/schemaFactory.ts +21 -14
  411. package/src/simple-tree/api/schemaFactoryAlpha.ts +29 -30
  412. package/src/simple-tree/api/schemaFactoryBeta.ts +28 -0
  413. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +7 -3
  414. package/src/simple-tree/api/transactionTypes.ts +1 -0
  415. package/src/simple-tree/api/tree.ts +75 -81
  416. package/src/simple-tree/api/verboseTree.ts +42 -39
  417. package/src/simple-tree/core/simpleNodeSchemaBase.ts +6 -0
  418. package/src/simple-tree/fieldSchema.ts +3 -4
  419. package/src/simple-tree/index.ts +3 -0
  420. package/src/simple-tree/node-kinds/record/recordNode.ts +2 -3
  421. package/src/simple-tree/simpleSchema.ts +12 -0
  422. package/src/simple-tree/toStoredSchema.ts +0 -3
  423. package/src/tableSchema.ts +261 -243
  424. package/src/treeFactory.ts +1 -2
@@ -35,6 +35,7 @@ import {
35
35
  SchemaVersion,
36
36
  type TaggedChange,
37
37
  type TreeFieldStoredSchema,
38
+ type TreeNodeSchemaIdentifier,
38
39
  type TreeNodeStoredSchema,
39
40
  type TreeStoredSchema,
40
41
  TreeStoredSchemaRepository,
@@ -56,6 +57,7 @@ import {
56
57
  makeMitigatedChangeFamily,
57
58
  makeSchemaCodec,
58
59
  makeTreeChunker,
60
+ type TreeCompressionStrategyPrivate,
59
61
  } from "../feature-libraries/index.js";
60
62
  // eslint-disable-next-line import/no-internal-modules
61
63
  import type { FormatV1 } from "../feature-libraries/schema-index/index.js";
@@ -271,6 +273,7 @@ export class SharedTreeKernel
271
273
  encoderContext,
272
274
  options,
273
275
  idCompressor,
276
+ options.shouldEncodeFieldIncrementally,
274
277
  );
275
278
  const removedRootsSummarizer = new DetachedFieldIndexSummarizer(removedRoots);
276
279
  const innerChangeFamily = new SharedTreeChangeFamily(
@@ -582,12 +585,25 @@ export type SharedTreeOptions = Partial<CodecWriteOptions> &
582
585
  Partial<SharedTreeFormatOptions> &
583
586
  ForestOptions;
584
587
 
585
- export interface SharedTreeOptionsInternal extends SharedTreeOptions {
588
+ export interface SharedTreeOptionsInternal
589
+ extends Omit<SharedTreeOptions, "treeEncodeType">,
590
+ Partial<SharedTreeFormatOptionsInternal> {
586
591
  disposeForksAfterTransaction?: boolean;
592
+ /**
593
+ * Returns whether a field should be incrementally encoded.
594
+ * @param nodeIdentifier - The identifier of the node containing the field.
595
+ * @param fieldKey - The key of the field to check.
596
+ * @remarks
597
+ * The policy for which fields should get incremental encoding should eventually be specified some other way.
598
+ */
599
+ shouldEncodeFieldIncrementally?(
600
+ nodeIdentifier: TreeNodeSchemaIdentifier,
601
+ fieldKey: FieldKey,
602
+ ): boolean;
587
603
  }
588
604
  /**
589
605
  * Configuration options for SharedTree's internal tree storage.
590
- * @alpha
606
+ * @beta @input
591
607
  */
592
608
  export interface ForestOptions {
593
609
  /**
@@ -598,7 +614,7 @@ export interface ForestOptions {
598
614
 
599
615
  /**
600
616
  * Options for configuring the persisted format SharedTree uses.
601
- * @alpha
617
+ * @alpha @input
602
618
  */
603
619
  export interface SharedTreeFormatOptions {
604
620
  /**
@@ -620,11 +636,22 @@ export interface SharedTreeFormatOptions {
620
636
  formatVersion: SharedTreeFormatVersion[keyof SharedTreeFormatVersion];
621
637
  }
622
638
 
639
+ export interface SharedTreeFormatOptionsInternal
640
+ extends Omit<SharedTreeFormatOptions, "treeEncodeType"> {
641
+ treeEncodeType: TreeCompressionStrategyPrivate;
642
+ }
643
+
623
644
  /**
624
645
  * Used to distinguish between different forest types.
625
646
  * @remarks
647
+ * The "Forest" is the internal data structure used to store all the trees (the main tree and any removed ones) for a given view or branch.
648
+ * ForestTypes should all have the same behavior, but may differ in performance and debuggability.
649
+ *
626
650
  * Current options are {@link ForestTypeReference}, {@link ForestTypeOptimized} and {@link ForestTypeExpensiveDebug}.
627
- * @sealed @alpha
651
+ * @privateRemarks
652
+ * Implement using {@link toForestType}.
653
+ * Consume using {@link buildConfiguredForest}.
654
+ * @sealed @beta
628
655
  */
629
656
  export interface ForestType extends ErasedType<"ForestType"> {}
630
657
 
@@ -698,6 +725,12 @@ export const defaultSharedTreeOptions: Required<SharedTreeOptionsInternal> = {
698
725
  treeEncodeType: TreeCompressionStrategy.Compressed,
699
726
  formatVersion: SharedTreeFormatVersion.v3,
700
727
  disposeForksAfterTransaction: true,
728
+ shouldEncodeFieldIncrementally: (
729
+ nodeIdentifier: TreeNodeSchemaIdentifier,
730
+ fieldKey: FieldKey,
731
+ ): boolean => {
732
+ return false;
733
+ },
701
734
  };
702
735
 
703
736
  function exportSimpleFieldSchemaStored(schema: TreeFieldStoredSchema): SimpleFieldSchema {
@@ -23,7 +23,7 @@ import {
23
23
  ModularChangeFamily,
24
24
  type ModularChangeset,
25
25
  type TreeChunk,
26
- type TreeCompressionStrategy,
26
+ type TreeCompressionStrategyPrivate,
27
27
  fieldKindConfigurations,
28
28
  fieldKinds,
29
29
  makeModularChangeCodecFamily,
@@ -61,7 +61,7 @@ export class SharedTreeChangeFamily
61
61
  revisionTagCodec: RevisionTagCodec,
62
62
  fieldBatchCodec: FieldBatchCodec,
63
63
  codecOptions: ICodecOptions,
64
- chunkCompressionStrategy?: TreeCompressionStrategy,
64
+ chunkCompressionStrategy?: TreeCompressionStrategyPrivate,
65
65
  private readonly idCompressor?: IIdCompressor,
66
66
  ) {
67
67
  const modularChangeCodec = makeModularChangeCodecFamily(
@@ -60,6 +60,9 @@ export interface Tree extends TreeNodeApi {
60
60
  export const Tree: Tree = {
61
61
  ...treeNodeApi,
62
62
 
63
+ // Note: the implementation details of `createRunTransaction` are deprecated.
64
+ // We have introduced replacement `@alpha` APIs on `TreeBranch`, but until they are `@public`, we can't reasonably deprecated this.
65
+ // Once they have been promoted to public, we can deprecate this API.
63
66
  runTransaction: createRunTransaction(),
64
67
 
65
68
  contains(parent: TreeNode, child: TreeNode): boolean {
@@ -54,6 +54,7 @@ import {
54
54
  toInitialSchema,
55
55
  convertField,
56
56
  toUnhydratedSchema,
57
+ type TreeParsingOptions,
57
58
  } from "../simple-tree/index.js";
58
59
  import { brand, extractFromOpaque, type JsonCompatible } from "../util/index.js";
59
60
  import {
@@ -201,7 +202,7 @@ export interface TreeIdentifierUtils {
201
202
  * Note that {@link (TreeBeta:interface).clone} can create an unhydrated node with unknown optional fields, as it uses the source node's stored schema (if any).
202
203
  *
203
204
  * Export APIs in this interface include {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | unknown optional fields}
204
- * if they are using {@link TreeEncodingOptions.useStoredKeys | stored keys}.
205
+ * if they are using {@link KeyEncodingOptions.allStoredKeys}.
205
206
  *
206
207
  * @privateRemarks
207
208
  * TODO:
@@ -273,18 +274,16 @@ export interface TreeAlpha {
273
274
  * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
274
275
  * @param data - The data used to construct the field content. See {@link (TreeAlpha:interface).(exportVerbose:1)}.
275
276
  * @remarks
276
- * This currently does not support input containing {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields| unknown optional fields}.
277
- * @privateRemarks
278
- * See TODOs in {@link TreeEncodingOptions}.
279
- *
280
- * TODO: clarify how this handles out of schema data.
281
- * Does it robustly validate? How do you use it with schema evolution features like staged allowed types and allowUnknownOptionalFields? Which errors are deferred until insertion/hydration?
282
- * Ensure whatever policy is chosen is documented, enforces, tested and applied consistently to all import code paths.
277
+ * This currently does not support input containing
278
+ * {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields| unknown optional fields} but does support
279
+ * {@link SchemaStaticsAlpha.staged | staged} allowed types.
280
+ * Non-empty default values for fields are currently not supported (must be provided in the input).
281
+ * The content will be validated against the schema and an error will be thrown if out of schema.
283
282
  */
284
283
  importVerbose<const TSchema extends ImplicitFieldSchema>(
285
284
  schema: TSchema,
286
285
  data: VerboseTree | undefined,
287
- options?: Partial<TreeEncodingOptions>,
286
+ options?: TreeParsingOptions,
288
287
  ): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
289
288
 
290
289
  /**
@@ -322,7 +321,7 @@ export interface TreeAlpha {
322
321
  * If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.
323
322
  *
324
323
  * Always uses "stored" keys.
325
- * See {@link TreeEncodingOptions.useStoredKeys} for details.
324
+ * See {@link KeyEncodingOptions.allStoredKeys} for details.
326
325
  * @privateRemarks
327
326
  * TODO: It is currently not clear how to work with the idCompressors correctly in the package API.
328
327
  * Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,
@@ -482,7 +481,7 @@ export const TreeAlpha: TreeAlpha = {
482
481
  importVerbose<const TSchema extends ImplicitFieldSchema>(
483
482
  schema: TSchema,
484
483
  data: VerboseTree | undefined,
485
- options?: TreeEncodingOptions,
484
+ options?: TreeParsingOptions,
486
485
  ): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
487
486
  const config: TreeEncodingOptions = { ...options };
488
487
  // Create a config which is standalone, and thus can be used without having to refer back to the schema.
@@ -50,7 +50,7 @@ import {
50
50
  } from "../core/index.js";
51
51
  import {
52
52
  type FieldBatchCodec,
53
- type TreeCompressionStrategy,
53
+ type TreeCompressionStrategyPrivate,
54
54
  allowsRepoSuperset,
55
55
  buildForest,
56
56
  createNodeIdentifierManager,
@@ -286,7 +286,7 @@ export function createTreeCheckout(
286
286
  forest?: IEditableForest;
287
287
  fieldBatchCodec?: FieldBatchCodec;
288
288
  removedRoots?: DetachedFieldIndex;
289
- chunkCompressionStrategy?: TreeCompressionStrategy;
289
+ chunkCompressionStrategy?: TreeCompressionStrategyPrivate;
290
290
  logger?: ITelemetryLoggerExt;
291
291
  breaker?: Breakable;
292
292
  disposeForksAfterTransaction?: boolean;
@@ -6,6 +6,7 @@
6
6
  import type { IFluidLoadable, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
7
7
  import { assert } from "@fluidframework/core-utils/internal";
8
8
  import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
9
+ import type { ISnapshotTree } from "@fluidframework/driver-definitions/internal";
9
10
  import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
10
11
  import type {
11
12
  IExperimentalIncrementalSummaryContext,
@@ -517,5 +518,21 @@ function scopeStorageService(
517
518
  async list(path) {
518
519
  return service.list(`${scope}${path}`);
519
520
  },
521
+ getSnapshotTree(): ISnapshotTree | undefined {
522
+ const snapshotTree = service.getSnapshotTree?.();
523
+ if (snapshotTree === undefined) {
524
+ return undefined;
525
+ }
526
+ let scopedTree = snapshotTree;
527
+ for (const element of pathElements) {
528
+ const tree = scopedTree.trees[element];
529
+ assert(
530
+ tree !== undefined,
531
+ 0xc20 /* snapshot tree not found for one of tree's summarizables */,
532
+ );
533
+ scopedTree = tree;
534
+ }
535
+ return scopedTree;
536
+ },
520
537
  };
521
538
  }
@@ -9,14 +9,14 @@ import { pkgVersion } from "./packageVersion.js";
9
9
 
10
10
  /**
11
11
  * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory."type"}
12
- * @alpha
12
+ * @beta
13
13
  * @legacy
14
14
  */
15
15
  export const SharedTreeFactoryType = "https://graph.microsoft.com/types/tree";
16
16
 
17
17
  /**
18
18
  * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory.attributes}
19
- * @alpha
19
+ * @beta
20
20
  * @legacy
21
21
  */
22
22
  export const SharedTreeAttributes: IChannelAttributes = {
@@ -13,6 +13,7 @@ import {
13
13
  replaceHandles,
14
14
  type TreeEncodingOptions,
15
15
  type HandleConverter,
16
+ KeyEncodingOptions,
16
17
  } from "./customTree.js";
17
18
 
18
19
  /**
@@ -46,7 +47,7 @@ export function conciseFromCursor(
46
47
  options: TreeEncodingOptions,
47
48
  ): ConciseTree {
48
49
  const config: Required<TreeEncodingOptions> = {
49
- useStoredKeys: false,
50
+ keys: KeyEncodingOptions.usePropertyKeys,
50
51
  ...options,
51
52
  };
52
53
 
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { IFluidHandle } from "@fluidframework/core-interfaces";
7
- import { assert, fail } from "@fluidframework/core-utils/internal";
7
+ import { assert, fail, unreachableCase } from "@fluidframework/core-utils/internal";
8
8
  import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
9
9
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
10
10
 
@@ -36,24 +36,56 @@ import { isObjectNodeSchema } from "../node-kinds/index.js";
36
36
  /**
37
37
  * Options for how to interpret or encode a tree when schema information is available.
38
38
  * @alpha
39
+ * @input
39
40
  */
40
- export interface TreeEncodingOptions {
41
+ export interface TreeEncodingOptions<TKeyOptions = KeyEncodingOptions> {
41
42
  /**
42
- * If true, use the stored keys of object nodes.
43
- * If false, use the property keys.
43
+ * How to handle field keys.
44
44
  * @remarks
45
45
  * Has no effect on {@link NodeKind}s other than {@link NodeKind.Object}.
46
46
  *
47
47
  * {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields|Unknown optional field} will be omitted when using property keys.
48
- * @defaultValue false.
49
- * @privateRemarks
50
- * TODO AB#43548:
51
- * Replace this with an enum that provides three options:
52
- * - `usePropertyKeys`: use property keys. Supported for import and export.
53
- * - `allStoredKeys`: use stored keys, and include unknown optional fields. Supported for export only, at least for the short term.
54
- * - `knownStoredKeys`: use stored keys but do not include unknown optional fields. Supported for import and export.
48
+ * @defaultValue {@link KeyEncodingOptions.usePropertyKeys}.
55
49
  */
56
- readonly useStoredKeys?: boolean;
50
+ readonly keys?: TKeyOptions;
51
+ }
52
+
53
+ /**
54
+ * Options for how to interpret a tree when schema information is available.
55
+ * @alpha
56
+ * @input
57
+ */
58
+ export type TreeParsingOptions = TreeEncodingOptions<
59
+ KeyEncodingOptions.usePropertyKeys | KeyEncodingOptions.knownStoredKeys
60
+ >;
61
+
62
+ /**
63
+ * Options for how to encode keys in a tree.
64
+ * @alpha
65
+ * @input
66
+ */
67
+ export enum KeyEncodingOptions {
68
+ /**
69
+ * Use property keys.
70
+ * @remarks
71
+ * Supported for import and export.
72
+ * {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields|Unknown optional fields} will be omitted when using property keys.
73
+ */
74
+ usePropertyKeys = "usePropertyKeys",
75
+ /**
76
+ * Use stored keys, and include {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields|Unknown optional fields}.
77
+ * @remarks
78
+ * Currently only supported for export.
79
+ */
80
+ allStoredKeys = "allStoredKeys",
81
+ /**
82
+ * Use stored keys but do not include {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields|Unknown optional fields}.
83
+ * @remarks
84
+ * Supported for import and export.
85
+ * For export, this omits unknown optional fields.
86
+ * For import, any unexpected fields are errors, regardless of {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields}.
87
+ */
88
+ knownStoredKeys = "knownStoredKeys",
57
89
  }
58
90
 
59
91
  /**
@@ -140,27 +172,12 @@ export function customFromCursor<TChild>(
140
172
  forEachField(reader, () => {
141
173
  assert(reader.getFieldLength() === 1, 0xa19 /* invalid children number */);
142
174
  const storedKey = reader.getFieldKey();
143
- let key: string;
144
- if (!options.useStoredKeys) {
145
- const viewSchema =
146
- schema.get(type) ?? fail(0xbff /* missing schema for type in cursor */);
147
- if (isObjectNodeSchema(viewSchema)) {
148
- const propertyKey = viewSchema.storedKeyToPropertyKey.get(storedKey);
149
- if (propertyKey === undefined) {
150
- assert(
151
- viewSchema.allowUnknownOptionalFields,
152
- 0xc00 /* found unknown field where not allowed */,
153
- );
154
- // Skip unknown optional fields when using property keys.
155
- return;
156
- }
157
- key = propertyKey;
158
- } else {
159
- key = storedKey;
160
- }
161
- } else {
162
- key = storedKey;
175
+ const key = getKeyFromOptions(options.keys, type, storedKey, schema);
176
+ if (key === undefined) {
177
+ // Skip unknown optional fields when using property keys or only known stored keys.
178
+ return;
163
179
  }
180
+
164
181
  reader.enterNode(0);
165
182
  fields[key] = childHandler(reader, options, storedSchema, schema);
166
183
  reader.exitNode();
@@ -171,6 +188,59 @@ export function customFromCursor<TChild>(
171
188
  }
172
189
  }
173
190
 
191
+ /**
192
+ * Returns the key if one should be used, and undefined if the field should be omitted/skipped.
193
+ *
194
+ * @param schema - Collection of known view schema.
195
+ * If `options` is not `KeyEncodingOptions.allStoredKeys`, this must provide the schema for the `type`.
196
+ * Note that if using this to perform a recursive walk, and `schema` has all view schema reachable from the starting type,
197
+ * then it should be safe to use the same schema map on every invocation since types missing from it will only be
198
+ * encountered after traversing unknown optional fields which for which this will return undefined.
199
+ *
200
+ * @remarks
201
+ * Asserts that if encountering an unknown optional field, the schema allows them.
202
+ * This is not robustly validated in all cases: when in allStoredKeys, it is not checked
203
+ * (since the view schema might not even be available).
204
+ */
205
+ function getKeyFromOptions(
206
+ options: KeyEncodingOptions,
207
+ type: TreeNodeSchemaIdentifier,
208
+ storedKey: FieldKey,
209
+ schema: ReadonlyMap<string, TreeNodeSchema>,
210
+ ): string | undefined {
211
+ switch (options) {
212
+ case KeyEncodingOptions.allStoredKeys:
213
+ // Since this case might be inside of an unknown optional field,
214
+ // it must not depend on there being a view schema.
215
+ // Fortunately, its possible to implement this case without one.
216
+ return storedKey;
217
+ case KeyEncodingOptions.usePropertyKeys:
218
+ case KeyEncodingOptions.knownStoredKeys: {
219
+ // Both these cases avoid traversing into unknown optional fields,
220
+ // so a view schema should be available.
221
+ const viewSchema =
222
+ schema.get(type) ?? fail(0xbff /* missing schema for type in cursor */);
223
+ if (isObjectNodeSchema(viewSchema)) {
224
+ const propertyKey = viewSchema.storedKeyToPropertyKey.get(storedKey);
225
+ if (propertyKey === undefined) {
226
+ assert(
227
+ viewSchema.allowUnknownOptionalFields,
228
+ 0xc00 /* found unknown field where not allowed */,
229
+ );
230
+ // Skip unknown optional fields when using property keys or only known stored keys.
231
+ return undefined;
232
+ } else {
233
+ return options === KeyEncodingOptions.usePropertyKeys ? propertyKey : storedKey;
234
+ }
235
+ } else {
236
+ return storedKey;
237
+ }
238
+ }
239
+ default:
240
+ unreachableCase(options);
241
+ }
242
+ }
243
+
174
244
  /**
175
245
  * Builds an {@link CustomTree} from a cursor in Nodes mode.
176
246
  * @remarks
@@ -6,14 +6,18 @@
6
6
  import type { JsonTreeSchema } from "./jsonSchema.js";
7
7
  import type { ImplicitAllowedTypes } from "../core/index.js";
8
8
  import { toJsonSchema } from "./simpleSchemaToJsonSchema.js";
9
- import type { TreeEncodingOptions } from "./customTree.js";
9
+ import type { TreeParsingOptions } from "./customTree.js";
10
10
  import { TreeViewConfigurationAlpha } from "./configuration.js";
11
11
 
12
12
  /**
13
13
  * Options for how to interpret or encode a tree when schema information is available.
14
+ * @remarks
15
+ * This currently extends {@link TreeParsingOptions},
16
+ * removing the option to declare {@link KeyEncodingOptions.allStoredKeys} since this option is currently not supported.
17
+ * @input
14
18
  * @alpha
15
19
  */
16
- export interface TreeSchemaEncodingOptions extends TreeEncodingOptions {
20
+ export interface TreeSchemaEncodingOptions extends TreeParsingOptions {
17
21
  /**
18
22
  * If true, fields with default providers (like {@link SchemaFactory.identifier}) will be required.
19
23
  * If false, they will be optional.
@@ -75,6 +79,7 @@ export interface TreeSchemaEncodingOptions extends TreeEncodingOptions {
75
79
  * 1. VerboseTree and (Done) ConciseTree
76
80
  * 2. (Done) With and without requiring values with defaults (for insertion vs reading)
77
81
  * 3. (Done) Using stored keys and property keys.
82
+ * 4. Control over unknown optional fields and staged allowed types (able to manually control them and/or get them from some context).
78
83
  *
79
84
  * This takes in `ImplicitAllowedTypes` since underlying `toJsonSchema` can't handle optional roots.
80
85
  *
@@ -32,6 +32,7 @@ export {
32
32
  type NodeSchemaOptions,
33
33
  type NodeSchemaOptionsAlpha,
34
34
  } from "./schemaFactory.js";
35
+ export { SchemaFactoryBeta } from "./schemaFactoryBeta.js";
35
36
  export { SchemaFactoryAlpha, type SchemaStaticsAlpha } from "./schemaFactoryAlpha.js";
36
37
  export type {
37
38
  ValidateRecursiveSchema,
@@ -101,6 +102,8 @@ export {
101
102
  tryStoredSchemaAsArray,
102
103
  replaceHandles,
103
104
  type HandleConverter,
105
+ KeyEncodingOptions,
106
+ type TreeParsingOptions,
104
107
  } from "./customTree.js";
105
108
 
106
109
  export {
@@ -86,7 +86,7 @@ export function singletonSchema<TScope extends string, TName extends string | nu
86
86
  * @remarks
87
87
  * The string value of the enum is used as the name of the schema: callers must ensure that it is stable and unique.
88
88
  * Numeric enums values have the value implicitly converted into a string.
89
- * Consider making a dedicated schema factory with a nested scope (for example using {@link SchemaFactoryAlpha.scopedFactory}) to avoid the enum members colliding with other schema.
89
+ * Consider making a dedicated schema factory with a nested scope (for example using {@link SchemaFactoryBeta.scopedFactory}) to avoid the enum members colliding with other schema.
90
90
  * @example
91
91
  * ```typescript
92
92
  * const schemaFactory = new SchemaFactory("com.myApp");
@@ -98,6 +98,7 @@ export function schemaFromValue(value: TreeValue): TreeNodeSchema {
98
98
  /**
99
99
  * Options when declaring an {@link SchemaFactory.object|object node}'s schema
100
100
  *
101
+ * @input
101
102
  * @alpha
102
103
  */
103
104
  export interface SchemaFactoryObjectOptions<TCustomMetadata = unknown>
@@ -147,7 +148,7 @@ export interface SchemaFactoryObjectOptions<TCustomMetadata = unknown>
147
148
  * It's only when application code reaches into a node
148
149
  * (either by accessing its fields, spreading it, or some other means) that this problem arises.
149
150
  */
150
- allowUnknownOptionalFields?: boolean;
151
+ readonly allowUnknownOptionalFields?: boolean;
151
152
  }
152
153
 
153
154
  /**
@@ -340,12 +341,6 @@ export class SchemaFactory<
340
341
  public readonly scope: TScope,
341
342
  ) {}
342
343
 
343
- private scoped<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {
344
- return (
345
- this.scope === undefined ? `${name}` : `${this.scope}.${name}`
346
- ) as ScopedSchemaName<TScope, Name>;
347
- }
348
-
349
344
  /**
350
345
  * {@inheritDoc SchemaStatics.string}
351
346
  */
@@ -435,7 +430,7 @@ export class SchemaFactory<
435
430
  true,
436
431
  T
437
432
  > = objectSchema(
438
- this.scoped(name),
433
+ scoped(this, name),
439
434
  fields,
440
435
  true,
441
436
  defaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,
@@ -593,7 +588,7 @@ export class SchemaFactory<
593
588
  T,
594
589
  undefined
595
590
  > = mapSchema(
596
- this.scoped(name),
591
+ scoped(this, name),
597
592
  allowedTypes,
598
593
  implicitlyConstructable,
599
594
  // The current policy is customizable nodes don't get fake prototypes.
@@ -669,7 +664,7 @@ export class SchemaFactory<
669
664
  >;
670
665
 
671
666
  /**
672
- * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.
667
+ * Define a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.
673
668
  *
674
669
  * @param name - Unique identifier for this schema within this factory's scope.
675
670
  * @param allowedTypes - The types that may appear in the array.
@@ -795,7 +790,7 @@ export class SchemaFactory<
795
790
  undefined
796
791
  > {
797
792
  const array = arraySchema(
798
- this.scoped(name),
793
+ scoped(this, name),
799
794
  allowedTypes,
800
795
  implicitlyConstructable,
801
796
  customizable,
@@ -1063,6 +1058,16 @@ export function structuralName<const T extends string>(
1063
1058
  return `${collectionName}<${inner}>`;
1064
1059
  }
1065
1060
 
1061
+ export function scoped<
1062
+ TScope extends string | undefined,
1063
+ TName extends number | string,
1064
+ Name extends TName | string,
1065
+ >(factory: SchemaFactory<TScope, TName>, name: Name): ScopedSchemaName<TScope, Name> {
1066
+ return (
1067
+ factory.scope === undefined ? `${name}` : `${factory.scope}.${name}`
1068
+ ) as ScopedSchemaName<TScope, Name>;
1069
+ }
1070
+
1066
1071
  /**
1067
1072
  * Used to allocate default identifiers for unhydrated nodes when no context is available.
1068
1073
  * @remarks
@@ -1077,7 +1082,7 @@ const globalIdentifierAllocator: IIdCompressor = createIdCompressor();
1077
1082
  * @typeParam TCustomMetadata - Custom metadata properties to associate with the Node Schema.
1078
1083
  * See {@link NodeSchemaMetadata.custom}.
1079
1084
  *
1080
- * @sealed
1085
+ * @input
1081
1086
  * @public
1082
1087
  */
1083
1088
  export interface NodeSchemaOptions<out TCustomMetadata = unknown> {
@@ -1085,8 +1090,7 @@ export interface NodeSchemaOptions<out TCustomMetadata = unknown> {
1085
1090
  * Optional metadata to associate with the Node Schema.
1086
1091
  *
1087
1092
  * @remarks
1088
- * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.
1089
- * Different clients in the same collaborative session may see different metadata for the same field.
1093
+ * This specifies {@link SimpleNodeSchemaBase.metadata} which has more details about its use.
1090
1094
  */
1091
1095
  readonly metadata?: NodeSchemaMetadata<TCustomMetadata> | undefined;
1092
1096
  }
@@ -1097,12 +1101,15 @@ export interface NodeSchemaOptions<out TCustomMetadata = unknown> {
1097
1101
  * @typeParam TCustomMetadata - Custom metadata properties to associate with the Node Schema.
1098
1102
  * See {@link NodeSchemaMetadata.custom}.
1099
1103
  *
1104
+ * @input
1100
1105
  * @alpha
1101
1106
  */
1102
1107
  export interface NodeSchemaOptionsAlpha<out TCustomMetadata = unknown>
1103
1108
  extends NodeSchemaOptions<TCustomMetadata> {
1104
1109
  /**
1105
1110
  * The persisted metadata for this schema element.
1111
+ * @remarks
1112
+ * This gets exposed via {@link SimpleNodeSchemaBaseAlpha.persistedMetadata}.
1106
1113
  */
1107
1114
  readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
1108
1115
  }