@fluidframework/tree 2.40.0-336023 → 2.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (445) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/api-report/tree.alpha.api.md +4 -1
  3. package/dist/alpha.d.ts +1 -0
  4. package/dist/codec/codec.d.ts +5 -1
  5. package/dist/codec/codec.d.ts.map +1 -1
  6. package/dist/codec/codec.js +6 -2
  7. package/dist/codec/codec.js.map +1 -1
  8. package/dist/codec/index.d.ts +1 -1
  9. package/dist/codec/index.d.ts.map +1 -1
  10. package/dist/codec/index.js +2 -1
  11. package/dist/codec/index.js.map +1 -1
  12. package/dist/core/index.d.ts +2 -2
  13. package/dist/core/index.d.ts.map +1 -1
  14. package/dist/core/index.js +2 -3
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
  17. package/dist/core/schema-stored/formatV1.d.ts.map +1 -0
  18. package/dist/core/schema-stored/{format.js → formatV1.js} +1 -1
  19. package/dist/core/schema-stored/formatV1.js.map +1 -0
  20. package/dist/core/schema-stored/index.d.ts +3 -3
  21. package/dist/core/schema-stored/index.d.ts.map +1 -1
  22. package/dist/core/schema-stored/index.js +3 -3
  23. package/dist/core/schema-stored/index.js.map +1 -1
  24. package/dist/core/schema-stored/schema.d.ts +3 -1
  25. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  26. package/dist/core/schema-stored/schema.js +8 -6
  27. package/dist/core/schema-stored/schema.js.map +1 -1
  28. package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  29. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  30. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  31. package/dist/core/schema-view/index.d.ts +1 -1
  32. package/dist/core/schema-view/index.d.ts.map +1 -1
  33. package/dist/core/schema-view/index.js +1 -2
  34. package/dist/core/schema-view/index.js.map +1 -1
  35. package/dist/core/schema-view/view.d.ts +0 -27
  36. package/dist/core/schema-view/view.d.ts.map +1 -1
  37. package/dist/core/schema-view/view.js +1 -35
  38. package/dist/core/schema-view/view.js.map +1 -1
  39. package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
  40. package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  41. package/dist/core/tree/persistedTreeTextFormat.js +1 -1
  42. package/dist/core/tree/persistedTreeTextFormat.js.map +1 -1
  43. package/dist/feature-libraries/forest-summary/format.d.ts +2 -2
  44. package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
  45. package/dist/feature-libraries/forest-summary/format.js +1 -1
  46. package/dist/feature-libraries/forest-summary/format.js.map +1 -1
  47. package/dist/feature-libraries/index.d.ts +1 -1
  48. package/dist/feature-libraries/index.d.ts.map +1 -1
  49. package/dist/feature-libraries/index.js +4 -2
  50. package/dist/feature-libraries/index.js.map +1 -1
  51. package/dist/feature-libraries/mapTreeCursor.d.ts +3 -3
  52. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  53. package/dist/feature-libraries/mapTreeCursor.js +2 -2
  54. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  55. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
  56. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  57. package/dist/feature-libraries/modular-schema/modularChangeFormat.js +2 -2
  58. package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  59. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
  60. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  61. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -5
  62. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  63. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  64. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  65. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  66. package/dist/feature-libraries/schema-index/codec.d.ts +34 -5
  67. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  68. package/dist/feature-libraries/schema-index/codec.js +63 -9
  69. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  70. package/{lib/feature-libraries/schema-index/format.d.ts → dist/feature-libraries/schema-index/formatV1.d.ts} +9 -9
  71. package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
  72. package/dist/feature-libraries/schema-index/{format.js → formatV1.js} +4 -4
  73. package/dist/feature-libraries/schema-index/formatV1.js.map +1 -0
  74. package/dist/feature-libraries/schema-index/index.d.ts +2 -2
  75. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  76. package/dist/feature-libraries/schema-index/index.js +6 -3
  77. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  78. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
  79. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  80. package/dist/feature-libraries/schema-index/schemaSummarizer.js +4 -4
  81. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  82. package/dist/index.d.ts +1 -0
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +10 -8
  85. package/dist/index.js.map +1 -1
  86. package/dist/packageVersion.d.ts +1 -1
  87. package/dist/packageVersion.d.ts.map +1 -1
  88. package/dist/packageVersion.js +1 -1
  89. package/dist/packageVersion.js.map +1 -1
  90. package/dist/shared-tree/independentView.d.ts.map +1 -1
  91. package/dist/shared-tree/independentView.js +1 -1
  92. package/dist/shared-tree/independentView.js.map +1 -1
  93. package/dist/shared-tree/index.d.ts +1 -1
  94. package/dist/shared-tree/index.d.ts.map +1 -1
  95. package/dist/shared-tree/index.js +2 -1
  96. package/dist/shared-tree/index.js.map +1 -1
  97. package/dist/shared-tree/schematizeTree.d.ts +8 -9
  98. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  99. package/dist/shared-tree/schematizeTree.js +9 -33
  100. package/dist/shared-tree/schematizeTree.js.map +1 -1
  101. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  102. package/dist/shared-tree/schematizingTreeView.js +1 -4
  103. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  104. package/dist/shared-tree/sharedTree.d.ts +28 -3
  105. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  106. package/dist/shared-tree/sharedTree.js +29 -3
  107. package/dist/shared-tree/sharedTree.js.map +1 -1
  108. package/dist/shared-tree/tree.d.ts +24 -0
  109. package/dist/shared-tree/tree.d.ts.map +1 -1
  110. package/dist/shared-tree/tree.js.map +1 -1
  111. package/dist/shared-tree/treeAlpha.d.ts +2 -0
  112. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  113. package/dist/shared-tree/treeAlpha.js +3 -2
  114. package/dist/shared-tree/treeAlpha.js.map +1 -1
  115. package/dist/shared-tree-core/branchCommitEnricher.d.ts +0 -1
  116. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  117. package/dist/shared-tree-core/branchCommitEnricher.js +0 -1
  118. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  119. package/dist/shared-tree-core/transactionEnricher.d.ts +1 -1
  120. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  121. package/dist/shared-tree-core/transactionEnricher.js +4 -1
  122. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  123. package/dist/simple-tree/api/index.d.ts +2 -1
  124. package/dist/simple-tree/api/index.d.ts.map +1 -1
  125. package/dist/simple-tree/api/index.js +2 -1
  126. package/dist/simple-tree/api/index.js.map +1 -1
  127. package/dist/simple-tree/api/schemaFactory.d.ts +9 -0
  128. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  129. package/dist/simple-tree/api/schemaFactory.js +7 -0
  130. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  131. package/dist/simple-tree/api/storedSchema.d.ts +8 -7
  132. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  133. package/dist/simple-tree/api/storedSchema.js +13 -9
  134. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  135. package/dist/simple-tree/api/tree.d.ts +25 -0
  136. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  137. package/dist/simple-tree/api/tree.js.map +1 -1
  138. package/dist/simple-tree/api/treeBeta.d.ts +4 -1
  139. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  140. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  141. package/dist/simple-tree/api/treeChangeEvents.d.ts +83 -0
  142. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
  143. package/dist/simple-tree/api/treeChangeEvents.js +7 -0
  144. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -0
  145. package/dist/simple-tree/api/treeNodeApi.d.ts +2 -1
  146. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  147. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  148. package/dist/simple-tree/arrayNode.d.ts +28 -0
  149. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  150. package/dist/simple-tree/arrayNode.js.map +1 -1
  151. package/dist/simple-tree/core/getOrCreateNode.d.ts +1 -1
  152. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  153. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  154. package/dist/simple-tree/core/index.d.ts +2 -1
  155. package/dist/simple-tree/core/index.d.ts.map +1 -1
  156. package/dist/simple-tree/core/index.js +5 -5
  157. package/dist/simple-tree/core/index.js.map +1 -1
  158. package/dist/simple-tree/core/treeNode.d.ts +94 -0
  159. package/dist/simple-tree/core/treeNode.d.ts.map +1 -0
  160. package/dist/simple-tree/core/treeNode.js +123 -0
  161. package/dist/simple-tree/core/treeNode.js.map +1 -0
  162. package/dist/simple-tree/core/treeNodeKernel.d.ts +2 -1
  163. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  164. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  165. package/dist/simple-tree/core/treeNodeSchema.d.ts +3 -1
  166. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  167. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  168. package/dist/simple-tree/core/types.d.ts +0 -165
  169. package/dist/simple-tree/core/types.d.ts.map +1 -1
  170. package/dist/simple-tree/core/types.js +1 -113
  171. package/dist/simple-tree/core/types.js.map +1 -1
  172. package/dist/simple-tree/core/withType.d.ts +1 -1
  173. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  174. package/dist/simple-tree/core/withType.js.map +1 -1
  175. package/dist/simple-tree/index.d.ts +2 -2
  176. package/dist/simple-tree/index.d.ts.map +1 -1
  177. package/dist/simple-tree/index.js +3 -2
  178. package/dist/simple-tree/index.js.map +1 -1
  179. package/dist/simple-tree/schemaTypes.d.ts +1 -0
  180. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  181. package/dist/simple-tree/schemaTypes.js.map +1 -1
  182. package/dist/simple-tree/toStoredSchema.d.ts +8 -8
  183. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  184. package/dist/simple-tree/toStoredSchema.js +27 -32
  185. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  186. package/dist/tableSchema.d.ts +302 -83
  187. package/dist/tableSchema.d.ts.map +1 -1
  188. package/dist/tableSchema.js +299 -57
  189. package/dist/tableSchema.js.map +1 -1
  190. package/dist/treeFactory.d.ts +1 -1
  191. package/dist/treeFactory.d.ts.map +1 -1
  192. package/dist/treeFactory.js +30 -75
  193. package/dist/treeFactory.js.map +1 -1
  194. package/lib/alpha.d.ts +1 -0
  195. package/lib/codec/codec.d.ts +5 -1
  196. package/lib/codec/codec.d.ts.map +1 -1
  197. package/lib/codec/codec.js +5 -1
  198. package/lib/codec/codec.js.map +1 -1
  199. package/lib/codec/index.d.ts +1 -1
  200. package/lib/codec/index.d.ts.map +1 -1
  201. package/lib/codec/index.js +1 -1
  202. package/lib/codec/index.js.map +1 -1
  203. package/lib/core/index.d.ts +2 -2
  204. package/lib/core/index.d.ts.map +1 -1
  205. package/lib/core/index.js +2 -2
  206. package/lib/core/index.js.map +1 -1
  207. package/lib/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
  208. package/lib/core/schema-stored/formatV1.d.ts.map +1 -0
  209. package/lib/core/schema-stored/{format.js → formatV1.js} +1 -1
  210. package/lib/core/schema-stored/formatV1.js.map +1 -0
  211. package/lib/core/schema-stored/index.d.ts +3 -3
  212. package/lib/core/schema-stored/index.d.ts.map +1 -1
  213. package/lib/core/schema-stored/index.js +2 -2
  214. package/lib/core/schema-stored/index.js.map +1 -1
  215. package/lib/core/schema-stored/schema.d.ts +3 -1
  216. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  217. package/lib/core/schema-stored/schema.js +3 -1
  218. package/lib/core/schema-stored/schema.js.map +1 -1
  219. package/lib/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  220. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  221. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  222. package/lib/core/schema-view/index.d.ts +1 -1
  223. package/lib/core/schema-view/index.d.ts.map +1 -1
  224. package/lib/core/schema-view/index.js +1 -1
  225. package/lib/core/schema-view/index.js.map +1 -1
  226. package/lib/core/schema-view/view.d.ts +0 -27
  227. package/lib/core/schema-view/view.d.ts.map +1 -1
  228. package/lib/core/schema-view/view.js +0 -34
  229. package/lib/core/schema-view/view.js.map +1 -1
  230. package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
  231. package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  232. package/lib/core/tree/persistedTreeTextFormat.js +2 -2
  233. package/lib/core/tree/persistedTreeTextFormat.js.map +1 -1
  234. package/lib/feature-libraries/forest-summary/format.d.ts +2 -2
  235. package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
  236. package/lib/feature-libraries/forest-summary/format.js +2 -2
  237. package/lib/feature-libraries/forest-summary/format.js.map +1 -1
  238. package/lib/feature-libraries/index.d.ts +1 -1
  239. package/lib/feature-libraries/index.d.ts.map +1 -1
  240. package/lib/feature-libraries/index.js +1 -1
  241. package/lib/feature-libraries/index.js.map +1 -1
  242. package/lib/feature-libraries/mapTreeCursor.d.ts +3 -3
  243. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  244. package/lib/feature-libraries/mapTreeCursor.js +2 -2
  245. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  246. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
  247. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  248. package/lib/feature-libraries/modular-schema/modularChangeFormat.js +3 -3
  249. package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  250. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
  251. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  252. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -6
  253. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  254. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  255. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  256. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
  257. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  258. package/lib/feature-libraries/schema-index/codec.d.ts +34 -5
  259. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  260. package/lib/feature-libraries/schema-index/codec.js +61 -9
  261. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  262. package/{dist/feature-libraries/schema-index/format.d.ts → lib/feature-libraries/schema-index/formatV1.d.ts} +9 -9
  263. package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
  264. package/lib/feature-libraries/schema-index/{format.js → formatV1.js} +5 -5
  265. package/lib/feature-libraries/schema-index/formatV1.js.map +1 -0
  266. package/lib/feature-libraries/schema-index/index.d.ts +2 -2
  267. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  268. package/lib/feature-libraries/schema-index/index.js +2 -2
  269. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  270. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
  271. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  272. package/lib/feature-libraries/schema-index/schemaSummarizer.js +5 -5
  273. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  274. package/lib/index.d.ts +1 -0
  275. package/lib/index.d.ts.map +1 -1
  276. package/lib/index.js +1 -0
  277. package/lib/index.js.map +1 -1
  278. package/lib/packageVersion.d.ts +1 -1
  279. package/lib/packageVersion.d.ts.map +1 -1
  280. package/lib/packageVersion.js +1 -1
  281. package/lib/packageVersion.js.map +1 -1
  282. package/lib/shared-tree/independentView.d.ts.map +1 -1
  283. package/lib/shared-tree/independentView.js +2 -2
  284. package/lib/shared-tree/independentView.js.map +1 -1
  285. package/lib/shared-tree/index.d.ts +1 -1
  286. package/lib/shared-tree/index.d.ts.map +1 -1
  287. package/lib/shared-tree/index.js +1 -1
  288. package/lib/shared-tree/index.js.map +1 -1
  289. package/lib/shared-tree/schematizeTree.d.ts +8 -9
  290. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  291. package/lib/shared-tree/schematizeTree.js +10 -34
  292. package/lib/shared-tree/schematizeTree.js.map +1 -1
  293. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  294. package/lib/shared-tree/schematizingTreeView.js +2 -5
  295. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  296. package/lib/shared-tree/sharedTree.d.ts +28 -3
  297. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  298. package/lib/shared-tree/sharedTree.js +29 -4
  299. package/lib/shared-tree/sharedTree.js.map +1 -1
  300. package/lib/shared-tree/tree.d.ts +24 -0
  301. package/lib/shared-tree/tree.d.ts.map +1 -1
  302. package/lib/shared-tree/tree.js.map +1 -1
  303. package/lib/shared-tree/treeAlpha.d.ts +2 -0
  304. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  305. package/lib/shared-tree/treeAlpha.js +4 -3
  306. package/lib/shared-tree/treeAlpha.js.map +1 -1
  307. package/lib/shared-tree-core/branchCommitEnricher.d.ts +0 -1
  308. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  309. package/lib/shared-tree-core/branchCommitEnricher.js +0 -1
  310. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  311. package/lib/shared-tree-core/transactionEnricher.d.ts +1 -1
  312. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  313. package/lib/shared-tree-core/transactionEnricher.js +4 -1
  314. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  315. package/lib/simple-tree/api/index.d.ts +2 -1
  316. package/lib/simple-tree/api/index.d.ts.map +1 -1
  317. package/lib/simple-tree/api/index.js +1 -1
  318. package/lib/simple-tree/api/index.js.map +1 -1
  319. package/lib/simple-tree/api/schemaFactory.d.ts +9 -0
  320. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  321. package/lib/simple-tree/api/schemaFactory.js +7 -0
  322. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  323. package/lib/simple-tree/api/storedSchema.d.ts +8 -7
  324. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  325. package/lib/simple-tree/api/storedSchema.js +17 -11
  326. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  327. package/lib/simple-tree/api/tree.d.ts +25 -0
  328. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  329. package/lib/simple-tree/api/tree.js.map +1 -1
  330. package/lib/simple-tree/api/treeBeta.d.ts +4 -1
  331. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  332. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  333. package/lib/simple-tree/api/treeChangeEvents.d.ts +83 -0
  334. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
  335. package/lib/simple-tree/api/treeChangeEvents.js +6 -0
  336. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -0
  337. package/lib/simple-tree/api/treeNodeApi.d.ts +2 -1
  338. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  339. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  340. package/lib/simple-tree/arrayNode.d.ts +28 -0
  341. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  342. package/lib/simple-tree/arrayNode.js.map +1 -1
  343. package/lib/simple-tree/core/getOrCreateNode.d.ts +1 -1
  344. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  345. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  346. package/lib/simple-tree/core/index.d.ts +2 -1
  347. package/lib/simple-tree/core/index.d.ts.map +1 -1
  348. package/lib/simple-tree/core/index.js +1 -1
  349. package/lib/simple-tree/core/index.js.map +1 -1
  350. package/lib/simple-tree/core/treeNode.d.ts +94 -0
  351. package/lib/simple-tree/core/treeNode.d.ts.map +1 -0
  352. package/lib/simple-tree/core/treeNode.js +118 -0
  353. package/lib/simple-tree/core/treeNode.js.map +1 -0
  354. package/lib/simple-tree/core/treeNodeKernel.d.ts +2 -1
  355. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  356. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  357. package/lib/simple-tree/core/treeNodeSchema.d.ts +3 -1
  358. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  359. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  360. package/lib/simple-tree/core/types.d.ts +0 -165
  361. package/lib/simple-tree/core/types.d.ts.map +1 -1
  362. package/lib/simple-tree/core/types.js +0 -110
  363. package/lib/simple-tree/core/types.js.map +1 -1
  364. package/lib/simple-tree/core/withType.d.ts +1 -1
  365. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  366. package/lib/simple-tree/core/withType.js.map +1 -1
  367. package/lib/simple-tree/index.d.ts +2 -2
  368. package/lib/simple-tree/index.d.ts.map +1 -1
  369. package/lib/simple-tree/index.js +1 -1
  370. package/lib/simple-tree/index.js.map +1 -1
  371. package/lib/simple-tree/schemaTypes.d.ts +1 -0
  372. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  373. package/lib/simple-tree/schemaTypes.js.map +1 -1
  374. package/lib/simple-tree/toStoredSchema.d.ts +8 -8
  375. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  376. package/lib/simple-tree/toStoredSchema.js +26 -31
  377. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  378. package/lib/tableSchema.d.ts +302 -83
  379. package/lib/tableSchema.d.ts.map +1 -1
  380. package/lib/tableSchema.js +299 -57
  381. package/lib/tableSchema.js.map +1 -1
  382. package/lib/treeFactory.d.ts +1 -1
  383. package/lib/treeFactory.d.ts.map +1 -1
  384. package/lib/treeFactory.js +30 -75
  385. package/lib/treeFactory.js.map +1 -1
  386. package/package.json +21 -21
  387. package/src/codec/codec.ts +6 -1
  388. package/src/codec/index.ts +1 -0
  389. package/src/core/index.ts +1 -2
  390. package/src/core/schema-stored/index.ts +3 -3
  391. package/src/core/schema-stored/schema.ts +3 -1
  392. package/src/core/schema-stored/storedSchemaRepository.ts +1 -1
  393. package/src/core/schema-view/index.ts +0 -1
  394. package/src/core/schema-view/view.ts +0 -31
  395. package/src/core/tree/persistedTreeTextFormat.ts +2 -2
  396. package/src/feature-libraries/forest-summary/format.ts +2 -2
  397. package/src/feature-libraries/index.ts +7 -1
  398. package/src/feature-libraries/mapTreeCursor.ts +3 -3
  399. package/src/feature-libraries/modular-schema/modularChangeFormat.ts +3 -3
  400. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +38 -9
  401. package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -4
  402. package/src/feature-libraries/schema-index/codec.ts +80 -12
  403. package/src/feature-libraries/schema-index/{format.ts → formatV1.ts} +4 -4
  404. package/src/feature-libraries/schema-index/index.ts +7 -2
  405. package/src/feature-libraries/schema-index/schemaSummarizer.ts +9 -9
  406. package/src/index.ts +1 -0
  407. package/src/packageVersion.ts +1 -1
  408. package/src/shared-tree/independentView.ts +3 -2
  409. package/src/shared-tree/index.ts +2 -0
  410. package/src/shared-tree/schematizeTree.ts +5 -35
  411. package/src/shared-tree/schematizingTreeView.ts +2 -10
  412. package/src/shared-tree/sharedTree.ts +67 -6
  413. package/src/shared-tree/tree.ts +24 -0
  414. package/src/shared-tree/treeAlpha.ts +6 -3
  415. package/src/shared-tree-core/branchCommitEnricher.ts +0 -1
  416. package/src/shared-tree-core/transactionEnricher.ts +4 -1
  417. package/src/simple-tree/api/index.ts +2 -0
  418. package/src/simple-tree/api/schemaFactory.ts +9 -0
  419. package/src/simple-tree/api/storedSchema.ts +24 -13
  420. package/src/simple-tree/api/tree.ts +25 -0
  421. package/src/simple-tree/api/treeBeta.ts +3 -1
  422. package/src/simple-tree/api/treeChangeEvents.ts +84 -0
  423. package/src/simple-tree/api/treeNodeApi.ts +1 -1
  424. package/src/simple-tree/arrayNode.ts +28 -0
  425. package/src/simple-tree/core/getOrCreateNode.ts +1 -1
  426. package/src/simple-tree/core/index.ts +5 -4
  427. package/src/simple-tree/core/treeNode.ts +163 -0
  428. package/src/simple-tree/core/treeNodeKernel.ts +2 -1
  429. package/src/simple-tree/core/treeNodeSchema.ts +3 -1
  430. package/src/simple-tree/core/types.ts +0 -234
  431. package/src/simple-tree/core/withType.ts +1 -1
  432. package/src/simple-tree/index.ts +2 -1
  433. package/src/simple-tree/schemaTypes.ts +1 -0
  434. package/src/simple-tree/toStoredSchema.ts +42 -41
  435. package/src/tableSchema.ts +665 -197
  436. package/src/treeFactory.ts +56 -173
  437. package/dist/core/schema-stored/format.d.ts.map +0 -1
  438. package/dist/core/schema-stored/format.js.map +0 -1
  439. package/dist/feature-libraries/schema-index/format.d.ts.map +0 -1
  440. package/dist/feature-libraries/schema-index/format.js.map +0 -1
  441. package/lib/core/schema-stored/format.d.ts.map +0 -1
  442. package/lib/core/schema-stored/format.js.map +0 -1
  443. package/lib/feature-libraries/schema-index/format.d.ts.map +0 -1
  444. package/lib/feature-libraries/schema-index/format.js.map +0 -1
  445. /package/src/core/schema-stored/{format.ts → formatV1.ts} +0 -0
@@ -4,13 +4,8 @@
4
4
  */
5
5
 
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
- import { UsageError } from "@fluidframework/telemetry-utils/internal";
8
7
  import type { ErasedType } from "@fluidframework/core-interfaces";
9
8
 
10
- import { NodeKind, type TreeNodeSchemaClass } from "./treeNodeSchema.js";
11
- // eslint-disable-next-line import/no-deprecated
12
- import { type WithType, typeNameSymbol, type typeSchemaSymbol } from "./withType.js";
13
- import { tryGetTreeNodeSchema } from "./treeNodeKernel.js";
14
9
  import { isFlexTreeNode, type FlexTreeNode } from "../../feature-libraries/index.js";
15
10
 
16
11
  /**
@@ -29,235 +24,6 @@ import { isFlexTreeNode, type FlexTreeNode } from "../../feature-libraries/index
29
24
  */
30
25
  export type Unhydrated<T> = T;
31
26
 
32
- /**
33
- * A collection of events that can be emitted by a {@link TreeNode}.
34
- *
35
- * @privateRemarks
36
- * TODO: add a way to subscribe to a specific field (for nodeChanged and treeChanged).
37
- * Probably have object node and map node specific APIs for this.
38
- *
39
- * TODO: ensure that subscription API for fields aligns with API for subscribing to the root.
40
- *
41
- * TODO: add more wider area (avoid needing tons of nodeChanged registration) events for use-cases other than treeChanged.
42
- * Some ideas:
43
- *
44
- * - treeChanged, but with some subtrees/fields/paths excluded
45
- * - helper to batch several nodeChanged calls to a treeChanged scope
46
- * - parent change (ex: registration on the parent field for a specific index: maybe allow it for a range. Ex: node event takes optional field and optional index range?)
47
- * - new content inserted into subtree. Either provide event for this and/or enough info to treeChanged to find and search the new sub-trees.
48
- * Add separate (non event related) API to efficiently scan tree for given set of types (using low level cursor and schema based filtering)
49
- * to allow efficiently searching for new content (and initial content) of a given type.
50
- *
51
- * @sealed @public
52
- */
53
- export interface TreeChangeEvents {
54
- /**
55
- * Emitted by a node after a batch of changes has been applied to the tree, if any of the changes affected the node.
56
- *
57
- * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).
58
- *
59
- * - Array nodes define a change as when an element is added, removed, moved or replaced.
60
- *
61
- * - Map nodes define a change as when an entry is added, updated, or removed.
62
- *
63
- * @param unstable - Future versions of this API (such as the one in beta on TreeBeta) may use this argument to provide additional data to the event.
64
- * users of this event should ensure that they do not provide a listener callback which has an optional parameter in this position, since unexpected data might get provided to it.
65
- * This parameter exists to capture this fact in the type system.
66
- * Using an inline lambda expression as the listener callback is a good pattern to avoid cases like this were arguments are added from breaking due to optional arguments.
67
- *
68
- * @remarks
69
- * This event is not emitted when:
70
- *
71
- * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing
72
- * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the
73
- * array/map node as one of its properties.
74
- *
75
- * - The node is moved to a different location in the tree or removed from the tree.
76
- * In this case the event is emitted on the _parent_ node, not the node itself.
77
- *
78
- * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in
79
- * the client that made the original edit.
80
- *
81
- * When the event is emitted, the tree is guaranteed to be in-schema.
82
- *
83
- * @privateRemarks
84
- * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.
85
- * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the
86
- * node, or when the node has to be updated due to resolution of a merge conflict
87
- * (for example a previously applied local change might be undone, then reapplied differently or not at all).
88
- *
89
- * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).
90
- */
91
- nodeChanged(unstable?: unknown): void;
92
-
93
- /**
94
- * Emitted by a node after a batch of changes has been applied to the tree, when something changed anywhere in the
95
- * subtree rooted at it.
96
- *
97
- * @remarks
98
- * This event is not emitted when the node itself is moved to a different location in the tree or removed from the tree.
99
- * In that case it is emitted on the _parent_ node, not the node itself.
100
- *
101
- * The node itself is part of the subtree, so this event will be emitted even if the only changes are to the properties
102
- * of the node itself.
103
- *
104
- * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in
105
- * the client that made the original edit.
106
- *
107
- * When it is emitted, the tree is guaranteed to be in-schema.
108
- */
109
- treeChanged(): void;
110
- }
111
-
112
- /**
113
- * A non-{@link NodeKind.Leaf|leaf} SharedTree node. Includes objects, arrays, and maps.
114
- *
115
- * @remarks
116
- * Base type which all nodes extend.
117
- *
118
- * This type can be used as a type to indicate/document values which should be tree nodes.
119
- * Runtime use of this class object (for example when used with `instanceof` or extending it), is not currently supported.
120
- *
121
- * There are three ways to get instances of TreeNode:
122
- *
123
- * 1. From a {@link TreeView} loading nodes from an existing document, or creating local copies of nodes inserted by a remote collaborator.
124
- * This case provides an {@link InternalTreeNode} to the constructor: subclasses must not modify how the constructor handles this case.
125
- * 2. Explicit construction of {@link Unhydrated} nodes using either {@link TreeNodeSchemaClass} as a constructor or {@link TreeNodeSchemaNonClass|TreeNodeSchemaNonClass.create}.
126
- * Either way the {@link TreeNodeSchema} produced must be produced using a {@link SchemaFactory}.
127
- * 3. Implicit construction: Several APIs which logically require an unhydrated TreeNode also allow passing in a value which could be used to explicitly construct the node instead.
128
- * These APIs internally call the constructor with the provided value, so it's really just a special case of the above option.
129
- * Note that when constructing nodes, sometimes implicit construction is not allowed
130
- * (either at runtime due to ambiguous types or at compile time due to TypeScript limitations):
131
- * in such cases, explicit construction must be used.
132
- *
133
- * @privateRemarks
134
- * This is a class not an interface to enable stricter type checking (see {@link TreeNode.#brand})
135
- * and some runtime enforcement of schema class policy (see the the validation in the constructor).
136
- * This class is however only `type` exported not value exported, preventing the class object from being used,
137
- * similar to how interfaces work.
138
- *
139
- * Not all node implementations include this in their prototype chain (some hide it with a proxy),
140
- * and thus cause the default/built in `instanceof` to return false despite our type checking and all other APIs treating them as TreeNodes.
141
- * This class provides a custom `Symbol.hasInstance` to fix `instanceof` for this class and all classes extending it.
142
- * For now the type-only export prevents use of `instanceof` on this class (but allows it in subclasses like schema classes).
143
- * @sealed @public
144
- */
145
- export abstract class TreeNode implements WithType {
146
- /**
147
- * This is added to prevent TypeScript from implicitly allowing non-TreeNode types to be used as TreeNodes.
148
- * @remarks
149
- * This field forces TypeScript to use nominal instead of structural typing,
150
- * preventing compiler error messages and tools like "add missing properties"
151
- * from adding the [type] field as a solution when using a non-TreeNode object where a TreeNode is required.
152
- * Instead TreeNodes must be created through the appropriate APIs, see the documentation on {@link TreeNode} for details.
153
- *
154
- * @privateRemarks
155
- * This is a JavaScript private field, so is not accessible from outside this class.
156
- * This prevents it from having name collisions with object fields.
157
- * Since this is private, the type of this field is stripped in the d.ts file.
158
- * To get matching type checking within and from outside the package, the least informative type (`unknown`) is used.
159
- * To avoid this having any runtime impact, the field is uninitialized.
160
- *
161
- * Making this field optional results in different type checking within this project than outside of it, since the d.ts file drops the optional aspect of the field.
162
- * This is extra confusing since since the tests get in-project typing for intellisense and separate project checking at build time.
163
- * To avoid all this mess, this field is required, not optional.
164
- *
165
- * Another option would be to use a symbol (possibly as a private field).
166
- * That approach ran into some strange difficulties causing SchemaFactory to fail to compile, and was not investigated further.
167
- *
168
- * The [type] symbol provides a lot of the value this private brand does, but is not all of it:
169
- * someone could manually (or via Intellisense auto-implement completion, or in response to a type error)
170
- * make an object literal with the [type] field and pass it off as a node: this private brand prevents that.
171
- */
172
- readonly #brand!: unknown;
173
-
174
- /**
175
- * Adds a type symbol for stronger typing.
176
- * @privateRemarks
177
- * Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.
178
- * @deprecated Use {@link typeSchemaSymbol} instead.
179
- */
180
- // eslint-disable-next-line import/no-deprecated
181
- public abstract get [typeNameSymbol](): string;
182
-
183
- /**
184
- * Adds a type symbol for stronger typing.
185
- * @privateRemarks
186
- * Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.
187
- */
188
- public abstract get [typeSchemaSymbol](): TreeNodeSchemaClass;
189
-
190
- /**
191
- * Provides `instanceof` support for testing if a value is a `TreeNode`.
192
- * @remarks
193
- * For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.
194
- * @privateRemarks
195
- * Due to type-only export, this functionality is not available outside the package.
196
- */
197
- public static [Symbol.hasInstance](value: unknown): value is TreeNode;
198
-
199
- /**
200
- * Provides `instanceof` support for all schema classes with public constructors.
201
- * @remarks
202
- * For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.
203
- * @privateRemarks
204
- * Despite type-only export, this functionality is available outside the package since it is inherited by subclasses.
205
- */
206
- public static [Symbol.hasInstance]<
207
- TSchema extends abstract new (
208
- ...args: any[]
209
- ) => TreeNode,
210
- >(this: TSchema, value: unknown): value is InstanceType<TSchema>;
211
-
212
- public static [Symbol.hasInstance](this: { prototype: object }, value: unknown): boolean {
213
- const schema = tryGetTreeNodeSchema(value);
214
-
215
- if (schema === undefined || schema.kind === NodeKind.Leaf) {
216
- return false;
217
- }
218
-
219
- assert("prototype" in schema, 0x98a /* expected class based schema */);
220
- return inPrototypeChain(schema.prototype, this.prototype);
221
- }
222
-
223
- /**
224
- * TreeNodes must extend schema classes created by SchemaFactory, and therefore this constructor should not be invoked directly by code outside this package.
225
- * @privateRemarks
226
- * `token` must be the {@link privateToken} value, which is not package exported.
227
- * This is used to detect invalid subclasses.
228
- *
229
- * All valid subclass should use {@link TreeNodeValid}, but this code doesn't directly reference it to avoid cyclic dependencies.
230
- */
231
- protected constructor(token: unknown) {
232
- if (token !== privateToken) {
233
- throw new UsageError("TreeNodes must extend schema classes created by SchemaFactory");
234
- }
235
- }
236
- }
237
-
238
- /**
239
- * `token` to pass to {@link TreeNode}'s constructor used to detect invalid subclasses.
240
- */
241
- export const privateToken = {};
242
-
243
- /**
244
- * Check if the prototype derived's prototype chain contains `base`.
245
- * @param derived - prototype to check
246
- * @param base - prototype to search for
247
- * @returns true iff `base` is in the prototype chain starting at `derived`.
248
- */
249
- // eslint-disable-next-line @rushstack/no-new-null
250
- export function inPrototypeChain(derived: object | null, base: object): boolean {
251
- let checking = derived;
252
- while (checking !== null) {
253
- if (base === checking) {
254
- return true;
255
- }
256
- checking = Reflect.getPrototypeOf(checking);
257
- }
258
- return false;
259
- }
260
-
261
27
  /**
262
28
  * A node type internal to `@fluidframework/tree`.
263
29
  * @remarks
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { NodeKind, TreeNodeSchemaClass } from "./treeNodeSchema.js";
7
- import type { TreeNode } from "./types.js";
7
+ import type { TreeNode } from "./treeNode.js";
8
8
 
9
9
  /**
10
10
  * The type of a {@link TreeNode}.
@@ -12,7 +12,6 @@ export {
12
12
  type TreeNodeSchemaClass,
13
13
  type TreeNodeSchemaNonClass,
14
14
  type TreeNodeSchemaCore,
15
- type TreeChangeEvents,
16
15
  // TreeNode is only type exported, which prevents use of the class object for unsupported use-cases like direct sub-classing and instanceof.
17
16
  // See docs on TreeNode for more details.
18
17
  type TreeNode,
@@ -122,6 +121,8 @@ export {
122
121
  type TreeSchema,
123
122
  type ValidateRecursiveSchemaTemplate,
124
123
  type FixRecursiveRecursionLimit,
124
+ schemaStatics,
125
+ type TreeChangeEvents,
125
126
  } from "./api/index.js";
126
127
  export type {
127
128
  SimpleTreeSchema,
@@ -1142,6 +1142,7 @@ export type TreeNodeFromImplicitAllowedTypes<
1142
1142
  * Consider a field with schema type of `A | B` (where A and B are types of schema).
1143
1143
  *
1144
1144
  * - Reading the field behaves covariantly so {@link NodeFromSchema} of `<A | B>` is the same as `NodeFromSchema<A> | NodeFromSchema<B>`, indicating that either type of node can be read from the field.
1145
+ *
1145
1146
  * - Writing to the field behaves contravariantly. Since it is unknown if the node actually has a schema `A` or a schema `B`, the only legal values (known to be in schema regardless of which schema the underlying node has) are values which are legal for both `A & B`.
1146
1147
  *
1147
1148
  * Note that this is distinct from the case where the schema is `[A, B]`.
@@ -21,17 +21,16 @@ import {
21
21
  } from "../core/index.js";
22
22
  import { FieldKinds, type FlexFieldKind } from "../feature-libraries/index.js";
23
23
  import { brand, getOrCreate } from "../util/index.js";
24
- import { NodeKind, type TreeNodeSchema } from "./core/index.js";
25
- import {
26
- FieldKind,
27
- FieldSchema,
28
- normalizeAllowedTypes,
29
- type ImplicitAllowedTypes,
30
- type ImplicitFieldSchema,
31
- } from "./schemaTypes.js";
24
+ import { NodeKind } from "./core/index.js";
25
+ import { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from "./schemaTypes.js";
32
26
  import { walkFieldSchema } from "./walkFieldSchema.js";
33
27
  import { LeafNodeSchema } from "./leafNodeSchema.js";
34
- import { isObjectNodeSchema } from "./objectNodeTypes.js";
28
+ import type {
29
+ SimpleFieldSchema,
30
+ SimpleNodeSchema,
31
+ SimpleNodeSchemaBase,
32
+ SimpleTreeSchema,
33
+ } from "./simpleSchema.js";
35
34
 
36
35
  const viewToStoredCache = new WeakMap<ImplicitFieldSchema, TreeStoredSchema>();
37
36
 
@@ -40,8 +39,9 @@ const viewToStoredCache = new WeakMap<ImplicitFieldSchema, TreeStoredSchema>();
40
39
  */
41
40
  export function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {
42
41
  return getOrCreate(viewToStoredCache, root, () => {
42
+ const normalized = normalizeFieldSchema(root);
43
43
  const nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();
44
- walkFieldSchema(root, {
44
+ walkFieldSchema(normalized, {
45
45
  node(schema) {
46
46
  if (nodeSchema.has(brand(schema.identifier))) {
47
47
  // Use JSON.stringify to quote and escape identifier string.
@@ -51,34 +51,44 @@ export function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {
51
51
  )}. Remove or rename them to avoid the collision.`,
52
52
  );
53
53
  }
54
- nodeSchema.set(brand(schema.identifier), getStoredSchema(schema));
54
+ nodeSchema.set(
55
+ brand(schema.identifier),
56
+ getStoredSchema(schema as SimpleNodeSchemaBase<NodeKind> as SimpleNodeSchema),
57
+ );
55
58
  },
56
59
  });
57
60
 
58
61
  const result: TreeStoredSchema = {
59
62
  nodeSchema,
60
- rootFieldSchema: convertField(root),
63
+ rootFieldSchema: convertField(normalized),
61
64
  };
62
- viewToStoredCache.set(root, result);
63
65
  return result;
64
66
  });
65
67
  }
66
68
 
67
69
  /**
68
- * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.
70
+ * Converts a {@link SimpleTreeSchema} into a {@link TreeStoredSchema}.
69
71
  */
70
- export function convertField(schema: ImplicitFieldSchema): TreeFieldStoredSchema {
71
- let kind: FieldKindIdentifier;
72
- let allowedTypes: ImplicitAllowedTypes;
73
- if (schema instanceof FieldSchema) {
74
- kind =
75
- convertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);
76
- allowedTypes = schema.allowedTypes;
77
- } else {
78
- kind = FieldKinds.required.identifier;
79
- allowedTypes = schema;
72
+ export function simpleToStoredSchema(root: SimpleTreeSchema): TreeStoredSchema {
73
+ const nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();
74
+ for (const [identifier, schema] of root.definitions) {
75
+ nodeSchema.set(brand(identifier), getStoredSchema(schema));
80
76
  }
81
- const types = convertAllowedTypes(allowedTypes);
77
+
78
+ const result: TreeStoredSchema = {
79
+ nodeSchema,
80
+ rootFieldSchema: convertField(root.root),
81
+ };
82
+ return result;
83
+ }
84
+
85
+ /**
86
+ * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.
87
+ */
88
+ export function convertField(schema: SimpleFieldSchema): TreeFieldStoredSchema {
89
+ const kind: FieldKindIdentifier =
90
+ convertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);
91
+ const types: TreeTypeSet = schema.allowedTypesIdentifiers as TreeTypeSet;
82
92
  return { kind, types };
83
93
  }
84
94
 
@@ -88,42 +98,33 @@ const convertFieldKind = new Map<FieldKind, FlexFieldKind>([
88
98
  [FieldKind.Identifier, FieldKinds.identifier],
89
99
  ]);
90
100
 
91
- /**
92
- * Normalizes an {@link ImplicitAllowedTypes} into an {@link TreeTypeSet}.
93
- */
94
- export function convertAllowedTypes(schema: ImplicitAllowedTypes): TreeTypeSet {
95
- return new Set([...normalizeAllowedTypes(schema)].map((item) => brand(item.identifier)));
96
- }
97
-
98
101
  /**
99
102
  * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.
100
103
  */
101
- export function getStoredSchema(schema: TreeNodeSchema): TreeNodeStoredSchema {
104
+ export function getStoredSchema(schema: SimpleNodeSchema): TreeNodeStoredSchema {
102
105
  const kind = schema.kind;
103
106
  switch (kind) {
104
107
  case NodeKind.Leaf: {
105
108
  assert(schema instanceof LeafNodeSchema, 0xa4a /* invalid kind */);
106
- return new LeafNodeStoredSchema(schema.info);
109
+ return new LeafNodeStoredSchema(schema.leafKind);
107
110
  }
108
111
  case NodeKind.Map: {
109
- const fieldInfo = schema.info as ImplicitAllowedTypes;
110
- const types = convertAllowedTypes(fieldInfo);
112
+ const types = schema.allowedTypesIdentifiers as TreeTypeSet;
111
113
  return new MapNodeStoredSchema({ kind: FieldKinds.optional.identifier, types });
112
114
  }
113
115
  case NodeKind.Array: {
114
- const fieldInfo = schema.info as ImplicitAllowedTypes;
116
+ const types = schema.allowedTypesIdentifiers as TreeTypeSet;
115
117
  const field = {
116
118
  kind: FieldKinds.sequence.identifier,
117
- types: convertAllowedTypes(fieldInfo),
119
+ types,
118
120
  };
119
121
  const fields = new Map([[EmptyKey, field]]);
120
122
  return new ObjectNodeStoredSchema(fields);
121
123
  }
122
124
  case NodeKind.Object: {
123
- assert(isObjectNodeSchema(schema), 0xa4b /* invalid kind */);
124
125
  const fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();
125
- for (const field of schema.flexKeyMap.values()) {
126
- fields.set(field.storedKey, convertField(field.schema));
126
+ for (const fieldSchema of schema.fields.values()) {
127
+ fields.set(brand(fieldSchema.storedKey), convertField(fieldSchema));
127
128
  }
128
129
  return new ObjectNodeStoredSchema(fields);
129
130
  }