@fluidframework/tree 2.3.0-288113 → 2.4.0-294316

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 (900) hide show
  1. package/.dependency-cruiser-known-violations.json +28 -40
  2. package/.vscode/Tree.code-workspace +0 -2
  3. package/CHANGELOG.md +92 -0
  4. package/README.md +6 -0
  5. package/alpha.d.ts +11 -0
  6. package/api-extractor/api-extractor-lint-alpha.cjs.json +5 -0
  7. package/api-extractor/api-extractor-lint-alpha.esm.json +5 -0
  8. package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
  9. package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
  10. package/api-extractor/api-extractor.current.json +8 -0
  11. package/api-extractor/api-extractor.legacy.json +4 -0
  12. package/api-extractor.json +1 -1
  13. package/api-report/tree.alpha.api.md +42 -54
  14. package/api-report/tree.beta.api.md +35 -16
  15. package/api-report/tree.legacy.alpha.api.md +571 -0
  16. package/api-report/tree.legacy.public.api.md +568 -0
  17. package/api-report/tree.public.api.md +22 -18
  18. package/dist/alpha.d.ts +103 -0
  19. package/dist/beta.d.ts +7 -2
  20. package/dist/core/index.d.ts +2 -2
  21. package/dist/core/index.d.ts.map +1 -1
  22. package/dist/core/index.js +4 -3
  23. package/dist/core/index.js.map +1 -1
  24. package/dist/core/rebase/index.d.ts +1 -1
  25. package/dist/core/rebase/index.d.ts.map +1 -1
  26. package/dist/core/rebase/index.js +2 -1
  27. package/dist/core/rebase/index.js.map +1 -1
  28. package/dist/core/rebase/types.d.ts +1 -0
  29. package/dist/core/rebase/types.d.ts.map +1 -1
  30. package/dist/core/rebase/types.js +8 -1
  31. package/dist/core/rebase/types.js.map +1 -1
  32. package/dist/core/{revertible/revertible.d.ts → revertible.d.ts} +12 -0
  33. package/dist/core/revertible.d.ts.map +1 -0
  34. package/dist/core/revertible.js.map +1 -0
  35. package/dist/core/schema-stored/format.d.ts +3 -3
  36. package/dist/core/schema-stored/format.js +1 -1
  37. package/dist/core/schema-stored/format.js.map +1 -1
  38. package/dist/core/schema-stored/schema.d.ts +2 -7
  39. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  40. package/dist/core/schema-stored/schema.js +4 -6
  41. package/dist/core/schema-stored/schema.js.map +1 -1
  42. package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  43. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  44. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  45. package/dist/core/tree/anchorSet.js +6 -2
  46. package/dist/core/tree/anchorSet.js.map +1 -1
  47. package/dist/core/tree/detachedFieldIndex.d.ts +0 -1
  48. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  49. package/dist/core/tree/detachedFieldIndex.js +1 -0
  50. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  51. package/dist/core/tree/visitDelta.d.ts +7 -2
  52. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  53. package/dist/core/tree/visitDelta.js.map +1 -1
  54. package/dist/events/emitter.d.ts +127 -0
  55. package/dist/events/emitter.d.ts.map +1 -0
  56. package/dist/events/{events.js → emitter.js} +48 -30
  57. package/dist/events/emitter.js.map +1 -0
  58. package/dist/events/index.d.ts +2 -1
  59. package/dist/events/index.d.ts.map +1 -1
  60. package/dist/events/index.js +4 -5
  61. package/dist/events/index.js.map +1 -1
  62. package/dist/events/interop.d.ts +36 -0
  63. package/dist/events/interop.d.ts.map +1 -0
  64. package/dist/{core/revertible/index.d.ts → events/interop.js} +3 -2
  65. package/dist/events/interop.js.map +1 -0
  66. package/dist/events/listeners.d.ts +65 -0
  67. package/dist/events/listeners.d.ts.map +1 -0
  68. package/{lib/core/revertible/index.d.ts → dist/events/listeners.js} +3 -2
  69. package/dist/events/listeners.js.map +1 -0
  70. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +25 -7
  71. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  72. package/dist/feature-libraries/chunked-forest/chunkTree.js +36 -15
  73. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  74. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +4 -2
  75. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  76. package/dist/feature-libraries/chunked-forest/chunkedForest.js +12 -5
  77. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +15 -2
  79. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/uniformChunk.js +28 -2
  81. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  82. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -1
  83. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  84. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +5 -4
  85. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  86. package/dist/feature-libraries/flex-map-tree/index.d.ts +1 -1
  87. package/dist/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
  88. package/dist/feature-libraries/flex-map-tree/index.js +2 -1
  89. package/dist/feature-libraries/flex-map-tree/index.js.map +1 -1
  90. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +35 -33
  91. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  92. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +82 -103
  93. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  94. package/dist/feature-libraries/flex-tree/context.d.ts +30 -14
  95. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  96. package/dist/feature-libraries/flex-tree/context.js +10 -7
  97. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  98. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +57 -190
  99. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  100. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +15 -3
  101. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  102. package/dist/feature-libraries/flex-tree/index.d.ts +2 -3
  103. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  104. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  105. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +3 -3
  106. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  107. package/dist/feature-libraries/flex-tree/lazyEntity.js +2 -10
  108. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  109. package/dist/feature-libraries/flex-tree/lazyField.d.ts +26 -28
  110. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  111. package/dist/feature-libraries/flex-tree/lazyField.js +11 -14
  112. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  113. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +5 -26
  114. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  115. package/dist/feature-libraries/flex-tree/lazyNode.js +23 -74
  116. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  117. package/dist/feature-libraries/flex-tree/unboxed.d.ts +4 -16
  118. package/dist/feature-libraries/flex-tree/unboxed.d.ts.map +1 -1
  119. package/dist/feature-libraries/flex-tree/unboxed.js +7 -41
  120. package/dist/feature-libraries/flex-tree/unboxed.js.map +1 -1
  121. package/dist/feature-libraries/flex-tree/utilities.d.ts +2 -2
  122. package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  123. package/dist/feature-libraries/flex-tree/utilities.js +3 -6
  124. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  125. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  126. package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -1
  127. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  128. package/dist/feature-libraries/index.d.ts +3 -5
  129. package/dist/feature-libraries/index.d.ts.map +1 -1
  130. package/dist/feature-libraries/index.js +5 -11
  131. package/dist/feature-libraries/index.js.map +1 -1
  132. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  133. package/dist/feature-libraries/modular-schema/comparison.js +3 -6
  134. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  135. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  136. package/dist/feature-libraries/modular-schema/discrepancies.js +3 -13
  137. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  138. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -1
  139. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  140. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  141. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  142. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +73 -22
  143. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  144. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +6 -6
  145. package/dist/feature-libraries/schema-index/format.d.ts +3 -3
  146. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  147. package/dist/feature-libraries/sequence-field/compose.js +3 -0
  148. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  149. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  150. package/dist/feature-libraries/sequence-field/utils.js +1 -4
  151. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  152. package/dist/feature-libraries/storedToViewSchema.d.ts.map +1 -1
  153. package/dist/feature-libraries/storedToViewSchema.js +2 -4
  154. package/dist/feature-libraries/storedToViewSchema.js.map +1 -1
  155. package/dist/feature-libraries/typed-schema/flexList.d.ts +3 -3
  156. package/dist/feature-libraries/typed-schema/flexList.js.map +1 -1
  157. package/dist/feature-libraries/typed-schema/index.d.ts +2 -2
  158. package/dist/feature-libraries/typed-schema/index.d.ts.map +1 -1
  159. package/dist/feature-libraries/typed-schema/index.js +2 -2
  160. package/dist/feature-libraries/typed-schema/index.js.map +1 -1
  161. package/dist/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
  162. package/dist/feature-libraries/typed-schema/schemaCollection.js +8 -10
  163. package/dist/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  164. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +17 -48
  165. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  166. package/dist/feature-libraries/typed-schema/typedTreeSchema.js +5 -37
  167. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  168. package/dist/feature-libraries/typed-schema/view.d.ts +4 -6
  169. package/dist/feature-libraries/typed-schema/view.d.ts.map +1 -1
  170. package/dist/feature-libraries/typed-schema/view.js +5 -4
  171. package/dist/feature-libraries/typed-schema/view.js.map +1 -1
  172. package/dist/index.d.ts +4 -4
  173. package/dist/index.d.ts.map +1 -1
  174. package/dist/index.js +33 -36
  175. package/dist/index.js.map +1 -1
  176. package/dist/legacy.d.ts +84 -0
  177. package/dist/packageVersion.d.ts +1 -1
  178. package/dist/packageVersion.js +1 -1
  179. package/dist/packageVersion.js.map +1 -1
  180. package/dist/public.d.ts +1 -1
  181. package/dist/shared-tree/checkoutFlexTreeView.d.ts +53 -0
  182. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -0
  183. package/dist/shared-tree/{treeView.js → checkoutFlexTreeView.js} +28 -6
  184. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -0
  185. package/dist/shared-tree/index.d.ts +3 -3
  186. package/dist/shared-tree/index.d.ts.map +1 -1
  187. package/dist/shared-tree/index.js +2 -2
  188. package/dist/shared-tree/index.js.map +1 -1
  189. package/dist/shared-tree/schematizeTree.d.ts +15 -4
  190. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  191. package/dist/shared-tree/schematizeTree.js +7 -8
  192. package/dist/shared-tree/schematizeTree.js.map +1 -1
  193. package/dist/shared-tree/schematizingTreeView.d.ts +10 -4
  194. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  195. package/dist/shared-tree/schematizingTreeView.js +28 -12
  196. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  197. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  198. package/dist/shared-tree/sharedTree.js +2 -2
  199. package/dist/shared-tree/sharedTree.js.map +1 -1
  200. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts +3 -1
  201. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  202. package/dist/shared-tree/sharedTreeChangeEnricher.js +6 -2
  203. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  204. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +3 -1
  205. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  206. package/dist/shared-tree/sharedTreeChangeFamily.js +3 -2
  207. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  208. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +2 -1
  209. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  210. package/dist/shared-tree/sharedTreeEditBuilder.js +2 -2
  211. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  212. package/dist/shared-tree/treeApi.d.ts +1 -3
  213. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  214. package/dist/shared-tree/treeApi.js +6 -4
  215. package/dist/shared-tree/treeApi.js.map +1 -1
  216. package/dist/shared-tree/treeCheckout.d.ts +2 -13
  217. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  218. package/dist/shared-tree/treeCheckout.js +17 -1
  219. package/dist/shared-tree/treeCheckout.js.map +1 -1
  220. package/dist/shared-tree-core/branch.js +1 -1
  221. package/dist/shared-tree-core/branch.js.map +1 -1
  222. package/dist/simple-tree/api/create.d.ts.map +1 -1
  223. package/dist/simple-tree/api/create.js +1 -1
  224. package/dist/simple-tree/api/create.js.map +1 -1
  225. package/{lib/simple-tree → dist/simple-tree/api}/getJsonSchema.d.ts +1 -1
  226. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -0
  227. package/dist/simple-tree/{getJsonSchema.js → api/getJsonSchema.js} +1 -1
  228. package/dist/simple-tree/api/getJsonSchema.js.map +1 -0
  229. package/{lib/simple-tree → dist/simple-tree/api}/getSimpleSchema.d.ts +1 -1
  230. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -0
  231. package/dist/simple-tree/{getSimpleSchema.js → api/getSimpleSchema.js} +1 -1
  232. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -0
  233. package/dist/simple-tree/api/index.d.ts +5 -0
  234. package/dist/simple-tree/api/index.d.ts.map +1 -1
  235. package/dist/simple-tree/api/index.js +7 -1
  236. package/dist/simple-tree/api/index.js.map +1 -1
  237. package/{lib/simple-tree → dist/simple-tree/api}/jsonSchema.d.ts +14 -15
  238. package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -0
  239. package/dist/simple-tree/api/jsonSchema.js.map +1 -0
  240. package/dist/simple-tree/api/schemaFactory.d.ts +53 -16
  241. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  242. package/dist/simple-tree/api/schemaFactory.js +49 -12
  243. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  244. package/dist/simple-tree/{simpleSchema.d.ts → api/simpleSchema.d.ts} +8 -4
  245. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -0
  246. package/dist/simple-tree/api/simpleSchema.js.map +1 -0
  247. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -0
  248. package/dist/simple-tree/{simpleSchemaToJsonSchema.js → api/simpleSchemaToJsonSchema.js} +34 -21
  249. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -0
  250. package/dist/simple-tree/api/tree.d.ts +5 -21
  251. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  252. package/dist/simple-tree/api/tree.js +3 -38
  253. package/dist/simple-tree/api/tree.js.map +1 -1
  254. package/dist/simple-tree/api/treeApiBeta.d.ts +79 -0
  255. package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -0
  256. package/dist/simple-tree/api/treeApiBeta.js +26 -0
  257. package/dist/simple-tree/api/treeApiBeta.js.map +1 -0
  258. package/dist/simple-tree/api/treeNodeApi.d.ts +1 -1
  259. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  260. package/dist/simple-tree/api/treeNodeApi.js +21 -19
  261. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  262. package/dist/simple-tree/api/verboseTree.js +2 -2
  263. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  264. package/dist/simple-tree/{viewSchemaToSimpleSchema.d.ts → api/viewSchemaToSimpleSchema.d.ts} +1 -1
  265. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -0
  266. package/dist/simple-tree/{viewSchemaToSimpleSchema.js → api/viewSchemaToSimpleSchema.js} +8 -4
  267. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -0
  268. package/dist/simple-tree/arrayNode.d.ts +2 -2
  269. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  270. package/dist/simple-tree/arrayNode.js +30 -21
  271. package/dist/simple-tree/arrayNode.js.map +1 -1
  272. package/dist/simple-tree/core/index.d.ts +3 -3
  273. package/dist/simple-tree/core/index.d.ts.map +1 -1
  274. package/dist/simple-tree/core/index.js +4 -1
  275. package/dist/simple-tree/core/index.js.map +1 -1
  276. package/dist/simple-tree/core/schemaCaching.d.ts +5 -0
  277. package/dist/simple-tree/core/schemaCaching.d.ts.map +1 -1
  278. package/dist/simple-tree/core/schemaCaching.js +10 -1
  279. package/dist/simple-tree/core/schemaCaching.js.map +1 -1
  280. package/dist/simple-tree/core/treeNodeKernel.d.ts +61 -3
  281. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  282. package/dist/simple-tree/core/treeNodeKernel.js +166 -13
  283. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  284. package/dist/simple-tree/core/treeNodeSchema.d.ts +1 -1
  285. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  286. package/dist/simple-tree/core/types.d.ts +17 -20
  287. package/dist/simple-tree/core/types.d.ts.map +1 -1
  288. package/dist/simple-tree/core/types.js.map +1 -1
  289. package/dist/simple-tree/core/withType.d.ts +3 -2
  290. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  291. package/dist/simple-tree/core/withType.js.map +1 -1
  292. package/dist/simple-tree/index.d.ts +8 -10
  293. package/dist/simple-tree/index.d.ts.map +1 -1
  294. package/dist/simple-tree/index.js +15 -6
  295. package/dist/simple-tree/index.js.map +1 -1
  296. package/dist/simple-tree/leafNodeSchema.d.ts +7 -9
  297. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  298. package/dist/simple-tree/leafNodeSchema.js +13 -11
  299. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  300. package/dist/simple-tree/mapNode.d.ts +1 -1
  301. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  302. package/dist/simple-tree/mapNode.js +38 -29
  303. package/dist/simple-tree/mapNode.js.map +1 -1
  304. package/dist/simple-tree/objectNode.d.ts +9 -7
  305. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  306. package/dist/simple-tree/objectNode.js +37 -31
  307. package/dist/simple-tree/objectNode.js.map +1 -1
  308. package/dist/simple-tree/proxies.d.ts +1 -14
  309. package/dist/simple-tree/proxies.d.ts.map +1 -1
  310. package/dist/simple-tree/proxies.js +12 -15
  311. package/dist/simple-tree/proxies.js.map +1 -1
  312. package/dist/simple-tree/proxyBinding.d.ts +2 -62
  313. package/dist/simple-tree/proxyBinding.d.ts.map +1 -1
  314. package/dist/simple-tree/proxyBinding.js +8 -181
  315. package/dist/simple-tree/proxyBinding.js.map +1 -1
  316. package/dist/simple-tree/schemaTypes.d.ts +51 -11
  317. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  318. package/dist/simple-tree/schemaTypes.js +14 -4
  319. package/dist/simple-tree/schemaTypes.js.map +1 -1
  320. package/dist/simple-tree/toFlexSchema.d.ts +11 -1
  321. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  322. package/dist/simple-tree/toFlexSchema.js +54 -31
  323. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  324. package/dist/simple-tree/toMapTree.d.ts +25 -37
  325. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  326. package/dist/simple-tree/toMapTree.js +53 -16
  327. package/dist/simple-tree/toMapTree.js.map +1 -1
  328. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  329. package/dist/simple-tree/treeNodeValid.js +7 -10
  330. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  331. package/dist/simple-tree/typesUnsafe.d.ts +13 -13
  332. package/dist/simple-tree/typesUnsafe.js.map +1 -1
  333. package/dist/simple-tree/walkSchema.d.ts +26 -0
  334. package/dist/simple-tree/walkSchema.d.ts.map +1 -0
  335. package/dist/simple-tree/walkSchema.js +49 -0
  336. package/dist/simple-tree/walkSchema.js.map +1 -0
  337. package/dist/treeFactory.d.ts +2 -1
  338. package/dist/treeFactory.d.ts.map +1 -1
  339. package/dist/treeFactory.js +2 -1
  340. package/dist/treeFactory.js.map +1 -1
  341. package/dist/util/typeUtils.d.ts +2 -2
  342. package/dist/util/typeUtils.js.map +1 -1
  343. package/legacy.d.ts +11 -0
  344. package/lib/alpha.d.ts +103 -0
  345. package/lib/beta.d.ts +7 -2
  346. package/lib/core/index.d.ts +2 -2
  347. package/lib/core/index.d.ts.map +1 -1
  348. package/lib/core/index.js +2 -2
  349. package/lib/core/index.js.map +1 -1
  350. package/lib/core/rebase/index.d.ts +1 -1
  351. package/lib/core/rebase/index.d.ts.map +1 -1
  352. package/lib/core/rebase/index.js +1 -1
  353. package/lib/core/rebase/index.js.map +1 -1
  354. package/lib/core/rebase/types.d.ts +1 -0
  355. package/lib/core/rebase/types.d.ts.map +1 -1
  356. package/lib/core/rebase/types.js +6 -0
  357. package/lib/core/rebase/types.js.map +1 -1
  358. package/lib/core/{revertible/revertible.d.ts → revertible.d.ts} +12 -0
  359. package/lib/core/revertible.d.ts.map +1 -0
  360. package/lib/core/revertible.js.map +1 -0
  361. package/lib/core/schema-stored/format.d.ts +3 -3
  362. package/lib/core/schema-stored/format.js +1 -1
  363. package/lib/core/schema-stored/format.js.map +1 -1
  364. package/lib/core/schema-stored/schema.d.ts +2 -7
  365. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  366. package/lib/core/schema-stored/schema.js +4 -6
  367. package/lib/core/schema-stored/schema.js.map +1 -1
  368. package/lib/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  369. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  370. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  371. package/lib/core/tree/anchorSet.js +6 -2
  372. package/lib/core/tree/anchorSet.js.map +1 -1
  373. package/lib/core/tree/detachedFieldIndex.d.ts +0 -1
  374. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  375. package/lib/core/tree/detachedFieldIndex.js +1 -0
  376. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  377. package/lib/core/tree/visitDelta.d.ts +7 -2
  378. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  379. package/lib/core/tree/visitDelta.js.map +1 -1
  380. package/lib/events/emitter.d.ts +127 -0
  381. package/lib/events/emitter.d.ts.map +1 -0
  382. package/lib/events/{events.js → emitter.js} +48 -29
  383. package/lib/events/emitter.js.map +1 -0
  384. package/lib/events/index.d.ts +2 -1
  385. package/lib/events/index.d.ts.map +1 -1
  386. package/lib/events/index.js +1 -1
  387. package/lib/events/index.js.map +1 -1
  388. package/lib/events/interop.d.ts +36 -0
  389. package/lib/events/interop.d.ts.map +1 -0
  390. package/{src/core/revertible/index.ts → lib/events/interop.js} +2 -2
  391. package/lib/events/interop.js.map +1 -0
  392. package/lib/events/listeners.d.ts +65 -0
  393. package/lib/events/listeners.d.ts.map +1 -0
  394. package/lib/{core/revertible/index.js → events/listeners.js} +2 -2
  395. package/lib/events/listeners.js.map +1 -0
  396. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +25 -7
  397. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  398. package/lib/feature-libraries/chunked-forest/chunkTree.js +37 -16
  399. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  400. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +4 -2
  401. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  402. package/lib/feature-libraries/chunked-forest/chunkedForest.js +12 -5
  403. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  404. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +15 -2
  405. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  406. package/lib/feature-libraries/chunked-forest/uniformChunk.js +28 -2
  407. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  408. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -1
  409. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  410. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +5 -4
  411. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  412. package/lib/feature-libraries/flex-map-tree/index.d.ts +1 -1
  413. package/lib/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
  414. package/lib/feature-libraries/flex-map-tree/index.js +1 -1
  415. package/lib/feature-libraries/flex-map-tree/index.js.map +1 -1
  416. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +35 -33
  417. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  418. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +83 -104
  419. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  420. package/lib/feature-libraries/flex-tree/context.d.ts +30 -14
  421. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  422. package/lib/feature-libraries/flex-tree/context.js +10 -7
  423. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  424. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +57 -190
  425. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  426. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +15 -2
  427. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  428. package/lib/feature-libraries/flex-tree/index.d.ts +2 -3
  429. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  430. package/lib/feature-libraries/flex-tree/index.js +1 -1
  431. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  432. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +3 -3
  433. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  434. package/lib/feature-libraries/flex-tree/lazyEntity.js +2 -10
  435. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  436. package/lib/feature-libraries/flex-tree/lazyField.d.ts +26 -28
  437. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  438. package/lib/feature-libraries/flex-tree/lazyField.js +11 -13
  439. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  440. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +5 -26
  441. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  442. package/lib/feature-libraries/flex-tree/lazyNode.js +23 -72
  443. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  444. package/lib/feature-libraries/flex-tree/unboxed.d.ts +4 -16
  445. package/lib/feature-libraries/flex-tree/unboxed.d.ts.map +1 -1
  446. package/lib/feature-libraries/flex-tree/unboxed.js +5 -37
  447. package/lib/feature-libraries/flex-tree/unboxed.js.map +1 -1
  448. package/lib/feature-libraries/flex-tree/utilities.d.ts +2 -2
  449. package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  450. package/lib/feature-libraries/flex-tree/utilities.js +3 -6
  451. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  452. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  453. package/lib/feature-libraries/forest-summary/forestSummarizer.js +4 -1
  454. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  455. package/lib/feature-libraries/index.d.ts +3 -5
  456. package/lib/feature-libraries/index.d.ts.map +1 -1
  457. package/lib/feature-libraries/index.js +5 -5
  458. package/lib/feature-libraries/index.js.map +1 -1
  459. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  460. package/lib/feature-libraries/modular-schema/comparison.js +3 -6
  461. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  462. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  463. package/lib/feature-libraries/modular-schema/discrepancies.js +3 -13
  464. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  465. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +4 -1
  466. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  467. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  468. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  469. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +74 -23
  470. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  471. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +6 -6
  472. package/lib/feature-libraries/schema-index/format.d.ts +3 -3
  473. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  474. package/lib/feature-libraries/sequence-field/compose.js +3 -0
  475. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  476. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  477. package/lib/feature-libraries/sequence-field/utils.js +2 -5
  478. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  479. package/lib/feature-libraries/storedToViewSchema.d.ts.map +1 -1
  480. package/lib/feature-libraries/storedToViewSchema.js +3 -5
  481. package/lib/feature-libraries/storedToViewSchema.js.map +1 -1
  482. package/lib/feature-libraries/typed-schema/flexList.d.ts +3 -3
  483. package/lib/feature-libraries/typed-schema/flexList.js.map +1 -1
  484. package/lib/feature-libraries/typed-schema/index.d.ts +2 -2
  485. package/lib/feature-libraries/typed-schema/index.d.ts.map +1 -1
  486. package/lib/feature-libraries/typed-schema/index.js +2 -2
  487. package/lib/feature-libraries/typed-schema/index.js.map +1 -1
  488. package/lib/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
  489. package/lib/feature-libraries/typed-schema/schemaCollection.js +9 -11
  490. package/lib/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  491. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +17 -48
  492. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  493. package/lib/feature-libraries/typed-schema/typedTreeSchema.js +5 -36
  494. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  495. package/lib/feature-libraries/typed-schema/view.d.ts +4 -6
  496. package/lib/feature-libraries/typed-schema/view.d.ts.map +1 -1
  497. package/lib/feature-libraries/typed-schema/view.js +5 -4
  498. package/lib/feature-libraries/typed-schema/view.js.map +1 -1
  499. package/lib/index.d.ts +4 -4
  500. package/lib/index.d.ts.map +1 -1
  501. package/lib/index.js +3 -5
  502. package/lib/index.js.map +1 -1
  503. package/lib/legacy.d.ts +84 -0
  504. package/lib/packageVersion.d.ts +1 -1
  505. package/lib/packageVersion.js +1 -1
  506. package/lib/packageVersion.js.map +1 -1
  507. package/lib/public.d.ts +1 -1
  508. package/lib/shared-tree/checkoutFlexTreeView.d.ts +53 -0
  509. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -0
  510. package/lib/shared-tree/{treeView.js → checkoutFlexTreeView.js} +26 -5
  511. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -0
  512. package/lib/shared-tree/index.d.ts +3 -3
  513. package/lib/shared-tree/index.d.ts.map +1 -1
  514. package/lib/shared-tree/index.js +1 -1
  515. package/lib/shared-tree/index.js.map +1 -1
  516. package/lib/shared-tree/schematizeTree.d.ts +15 -4
  517. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  518. package/lib/shared-tree/schematizeTree.js +8 -9
  519. package/lib/shared-tree/schematizeTree.js.map +1 -1
  520. package/lib/shared-tree/schematizingTreeView.d.ts +10 -4
  521. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  522. package/lib/shared-tree/schematizingTreeView.js +29 -13
  523. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  524. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  525. package/lib/shared-tree/sharedTree.js +2 -2
  526. package/lib/shared-tree/sharedTree.js.map +1 -1
  527. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts +3 -1
  528. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  529. package/lib/shared-tree/sharedTreeChangeEnricher.js +6 -2
  530. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  531. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +3 -1
  532. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  533. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -2
  534. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  535. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +2 -1
  536. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  537. package/lib/shared-tree/sharedTreeEditBuilder.js +2 -2
  538. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  539. package/lib/shared-tree/treeApi.d.ts +1 -3
  540. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  541. package/lib/shared-tree/treeApi.js +7 -5
  542. package/lib/shared-tree/treeApi.js.map +1 -1
  543. package/lib/shared-tree/treeCheckout.d.ts +2 -13
  544. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  545. package/lib/shared-tree/treeCheckout.js +18 -2
  546. package/lib/shared-tree/treeCheckout.js.map +1 -1
  547. package/lib/shared-tree-core/branch.js +1 -1
  548. package/lib/shared-tree-core/branch.js.map +1 -1
  549. package/lib/simple-tree/api/create.d.ts.map +1 -1
  550. package/lib/simple-tree/api/create.js +2 -2
  551. package/lib/simple-tree/api/create.js.map +1 -1
  552. package/{dist/simple-tree → lib/simple-tree/api}/getJsonSchema.d.ts +1 -1
  553. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -0
  554. package/lib/simple-tree/{getJsonSchema.js → api/getJsonSchema.js} +1 -1
  555. package/lib/simple-tree/api/getJsonSchema.js.map +1 -0
  556. package/{dist/simple-tree → lib/simple-tree/api}/getSimpleSchema.d.ts +1 -1
  557. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -0
  558. package/lib/simple-tree/{getSimpleSchema.js → api/getSimpleSchema.js} +1 -1
  559. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -0
  560. package/lib/simple-tree/api/index.d.ts +5 -0
  561. package/lib/simple-tree/api/index.d.ts.map +1 -1
  562. package/lib/simple-tree/api/index.js +3 -0
  563. package/lib/simple-tree/api/index.js.map +1 -1
  564. package/{dist/simple-tree → lib/simple-tree/api}/jsonSchema.d.ts +14 -15
  565. package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -0
  566. package/lib/simple-tree/api/jsonSchema.js.map +1 -0
  567. package/lib/simple-tree/api/schemaFactory.d.ts +53 -16
  568. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  569. package/lib/simple-tree/api/schemaFactory.js +49 -12
  570. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  571. package/lib/simple-tree/{simpleSchema.d.ts → api/simpleSchema.d.ts} +8 -4
  572. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -0
  573. package/lib/simple-tree/api/simpleSchema.js.map +1 -0
  574. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -0
  575. package/lib/simple-tree/{simpleSchemaToJsonSchema.js → api/simpleSchemaToJsonSchema.js} +35 -22
  576. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -0
  577. package/lib/simple-tree/api/tree.d.ts +5 -21
  578. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  579. package/lib/simple-tree/api/tree.js +2 -34
  580. package/lib/simple-tree/api/tree.js.map +1 -1
  581. package/lib/simple-tree/api/treeApiBeta.d.ts +79 -0
  582. package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -0
  583. package/lib/simple-tree/api/treeApiBeta.js +23 -0
  584. package/lib/simple-tree/api/treeApiBeta.js.map +1 -0
  585. package/lib/simple-tree/api/treeNodeApi.d.ts +1 -1
  586. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  587. package/lib/simple-tree/api/treeNodeApi.js +23 -21
  588. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  589. package/lib/simple-tree/api/verboseTree.js +1 -1
  590. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  591. package/lib/simple-tree/{viewSchemaToSimpleSchema.d.ts → api/viewSchemaToSimpleSchema.d.ts} +1 -1
  592. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -0
  593. package/lib/simple-tree/{viewSchemaToSimpleSchema.js → api/viewSchemaToSimpleSchema.js} +8 -4
  594. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -0
  595. package/lib/simple-tree/arrayNode.d.ts +2 -2
  596. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  597. package/lib/simple-tree/arrayNode.js +33 -24
  598. package/lib/simple-tree/arrayNode.js.map +1 -1
  599. package/lib/simple-tree/core/index.d.ts +3 -3
  600. package/lib/simple-tree/core/index.d.ts.map +1 -1
  601. package/lib/simple-tree/core/index.js +2 -2
  602. package/lib/simple-tree/core/index.js.map +1 -1
  603. package/lib/simple-tree/core/schemaCaching.d.ts +5 -0
  604. package/lib/simple-tree/core/schemaCaching.d.ts.map +1 -1
  605. package/lib/simple-tree/core/schemaCaching.js +8 -0
  606. package/lib/simple-tree/core/schemaCaching.js.map +1 -1
  607. package/lib/simple-tree/core/treeNodeKernel.d.ts +61 -3
  608. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  609. package/lib/simple-tree/core/treeNodeKernel.js +156 -5
  610. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  611. package/lib/simple-tree/core/treeNodeSchema.d.ts +1 -1
  612. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  613. package/lib/simple-tree/core/types.d.ts +17 -20
  614. package/lib/simple-tree/core/types.d.ts.map +1 -1
  615. package/lib/simple-tree/core/types.js.map +1 -1
  616. package/lib/simple-tree/core/withType.d.ts +3 -2
  617. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  618. package/lib/simple-tree/core/withType.js.map +1 -1
  619. package/lib/simple-tree/index.d.ts +8 -10
  620. package/lib/simple-tree/index.d.ts.map +1 -1
  621. package/lib/simple-tree/index.js +5 -5
  622. package/lib/simple-tree/index.js.map +1 -1
  623. package/lib/simple-tree/leafNodeSchema.d.ts +7 -9
  624. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  625. package/lib/simple-tree/leafNodeSchema.js +14 -12
  626. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  627. package/lib/simple-tree/mapNode.d.ts +1 -1
  628. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  629. package/lib/simple-tree/mapNode.js +38 -29
  630. package/lib/simple-tree/mapNode.js.map +1 -1
  631. package/lib/simple-tree/objectNode.d.ts +9 -7
  632. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  633. package/lib/simple-tree/objectNode.js +40 -34
  634. package/lib/simple-tree/objectNode.js.map +1 -1
  635. package/lib/simple-tree/proxies.d.ts +1 -14
  636. package/lib/simple-tree/proxies.d.ts.map +1 -1
  637. package/lib/simple-tree/proxies.js +11 -14
  638. package/lib/simple-tree/proxies.js.map +1 -1
  639. package/lib/simple-tree/proxyBinding.d.ts +2 -62
  640. package/lib/simple-tree/proxyBinding.d.ts.map +1 -1
  641. package/lib/simple-tree/proxyBinding.js +6 -174
  642. package/lib/simple-tree/proxyBinding.js.map +1 -1
  643. package/lib/simple-tree/schemaTypes.d.ts +51 -11
  644. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  645. package/lib/simple-tree/schemaTypes.js +14 -4
  646. package/lib/simple-tree/schemaTypes.js.map +1 -1
  647. package/lib/simple-tree/toFlexSchema.d.ts +11 -1
  648. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  649. package/lib/simple-tree/toFlexSchema.js +29 -8
  650. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  651. package/lib/simple-tree/toMapTree.d.ts +25 -37
  652. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  653. package/lib/simple-tree/toMapTree.js +54 -17
  654. package/lib/simple-tree/toMapTree.js.map +1 -1
  655. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  656. package/lib/simple-tree/treeNodeValid.js +8 -11
  657. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  658. package/lib/simple-tree/typesUnsafe.d.ts +13 -13
  659. package/lib/simple-tree/typesUnsafe.js.map +1 -1
  660. package/lib/simple-tree/walkSchema.d.ts +26 -0
  661. package/lib/simple-tree/walkSchema.d.ts.map +1 -0
  662. package/lib/simple-tree/walkSchema.js +43 -0
  663. package/lib/simple-tree/walkSchema.js.map +1 -0
  664. package/lib/treeFactory.d.ts +2 -1
  665. package/lib/treeFactory.d.ts.map +1 -1
  666. package/lib/treeFactory.js +2 -1
  667. package/lib/treeFactory.js.map +1 -1
  668. package/lib/tsdoc-metadata.json +1 -1
  669. package/lib/util/typeUtils.d.ts +2 -2
  670. package/lib/util/typeUtils.js.map +1 -1
  671. package/package.json +68 -26
  672. package/src/core/index.ts +2 -1
  673. package/src/core/rebase/index.ts +1 -0
  674. package/src/core/rebase/types.ts +11 -0
  675. package/src/core/{revertible/revertible.ts → revertible.ts} +15 -0
  676. package/src/core/schema-stored/format.ts +1 -1
  677. package/src/core/schema-stored/schema.ts +7 -13
  678. package/src/core/tree/anchorSet.ts +18 -3
  679. package/src/core/tree/detachedFieldIndex.ts +6 -5
  680. package/src/core/tree/visitDelta.ts +7 -2
  681. package/src/events/{events.ts → emitter.ts} +52 -139
  682. package/src/events/index.ts +7 -7
  683. package/src/events/interop.ts +49 -0
  684. package/src/events/listeners.ts +68 -0
  685. package/src/feature-libraries/chunked-forest/chunkTree.ts +63 -18
  686. package/src/feature-libraries/chunked-forest/chunkedForest.ts +18 -4
  687. package/src/feature-libraries/chunked-forest/uniformChunk.ts +33 -0
  688. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +5 -3
  689. package/src/feature-libraries/flex-map-tree/index.ts +1 -0
  690. package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +135 -210
  691. package/src/feature-libraries/flex-tree/README.md +4 -75
  692. package/src/feature-libraries/flex-tree/context.ts +37 -16
  693. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +69 -291
  694. package/src/feature-libraries/flex-tree/index.ts +7 -13
  695. package/src/feature-libraries/flex-tree/lazyEntity.ts +2 -11
  696. package/src/feature-libraries/flex-tree/lazyField.ts +49 -73
  697. package/src/feature-libraries/flex-tree/lazyNode.ts +25 -154
  698. package/src/feature-libraries/flex-tree/unboxed.ts +9 -68
  699. package/src/feature-libraries/flex-tree/utilities.ts +4 -8
  700. package/src/feature-libraries/forest-summary/forestSummarizer.ts +4 -1
  701. package/src/feature-libraries/index.ts +2 -27
  702. package/src/feature-libraries/modular-schema/comparison.ts +4 -6
  703. package/src/feature-libraries/modular-schema/discrepancies.ts +7 -16
  704. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +4 -1
  705. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +111 -14
  706. package/src/feature-libraries/sequence-field/compose.ts +3 -0
  707. package/src/feature-libraries/sequence-field/utils.ts +2 -4
  708. package/src/feature-libraries/storedToViewSchema.ts +5 -6
  709. package/src/feature-libraries/typed-schema/flexList.ts +3 -3
  710. package/src/feature-libraries/typed-schema/index.ts +1 -3
  711. package/src/feature-libraries/typed-schema/schemaCollection.ts +15 -17
  712. package/src/feature-libraries/typed-schema/typedTreeSchema.ts +35 -127
  713. package/src/feature-libraries/typed-schema/view.ts +4 -13
  714. package/src/index.ts +5 -8
  715. package/src/packageVersion.ts +1 -1
  716. package/src/shared-tree/checkoutFlexTreeView.ts +89 -0
  717. package/src/shared-tree/index.ts +2 -7
  718. package/src/shared-tree/schematizeTree.ts +23 -12
  719. package/src/shared-tree/schematizingTreeView.ts +38 -24
  720. package/src/shared-tree/sharedTree.ts +6 -1
  721. package/src/shared-tree/sharedTreeChangeEnricher.ts +6 -1
  722. package/src/shared-tree/sharedTreeChangeFamily.ts +7 -1
  723. package/src/shared-tree/sharedTreeEditBuilder.ts +9 -4
  724. package/src/shared-tree/treeApi.ts +10 -10
  725. package/src/shared-tree/treeCheckout.ts +26 -15
  726. package/src/shared-tree-core/branch.ts +1 -1
  727. package/src/simple-tree/ProxyBinding.md +23 -23
  728. package/src/simple-tree/api/create.ts +8 -3
  729. package/src/simple-tree/{getJsonSchema.ts → api/getJsonSchema.ts} +3 -3
  730. package/src/simple-tree/{getSimpleSchema.ts → api/getSimpleSchema.ts} +3 -3
  731. package/src/simple-tree/api/index.ts +20 -0
  732. package/src/simple-tree/{jsonSchema.ts → api/jsonSchema.ts} +20 -18
  733. package/src/simple-tree/api/schemaFactory.ts +56 -19
  734. package/src/simple-tree/{simpleSchema.ts → api/simpleSchema.ts} +9 -4
  735. package/src/simple-tree/{simpleSchemaToJsonSchema.ts → api/simpleSchemaToJsonSchema.ts} +43 -22
  736. package/src/simple-tree/api/tree.ts +7 -71
  737. package/src/simple-tree/api/treeApiBeta.ts +101 -0
  738. package/src/simple-tree/api/treeNodeApi.ts +32 -23
  739. package/src/simple-tree/api/verboseTree.ts +1 -1
  740. package/src/simple-tree/{viewSchemaToSimpleSchema.ts → api/viewSchemaToSimpleSchema.ts} +11 -6
  741. package/src/simple-tree/arrayNode.ts +37 -31
  742. package/src/simple-tree/core/index.ts +4 -1
  743. package/src/simple-tree/core/schemaCaching.ts +10 -0
  744. package/src/simple-tree/core/treeNodeKernel.ts +198 -5
  745. package/src/simple-tree/core/treeNodeSchema.ts +1 -1
  746. package/src/simple-tree/core/types.ts +16 -27
  747. package/src/simple-tree/core/withType.ts +3 -1
  748. package/src/simple-tree/index.ts +30 -21
  749. package/src/simple-tree/leafNodeSchema.ts +24 -28
  750. package/src/simple-tree/mapNode.ts +47 -29
  751. package/src/simple-tree/objectNode.ts +51 -46
  752. package/src/simple-tree/proxies.ts +22 -51
  753. package/src/simple-tree/proxyBinding.ts +3 -254
  754. package/src/simple-tree/schemaTypes.ts +63 -13
  755. package/src/simple-tree/toFlexSchema.ts +40 -7
  756. package/src/simple-tree/toMapTree.ts +113 -79
  757. package/src/simple-tree/treeNodeValid.ts +10 -13
  758. package/src/simple-tree/typesUnsafe.ts +13 -13
  759. package/src/simple-tree/walkSchema.ts +81 -0
  760. package/src/treeFactory.ts +2 -1
  761. package/src/util/typeUtils.ts +2 -2
  762. package/dist/core/revertible/index.d.ts.map +0 -1
  763. package/dist/core/revertible/index.js +0 -10
  764. package/dist/core/revertible/index.js.map +0 -1
  765. package/dist/core/revertible/revertible.d.ts.map +0 -1
  766. package/dist/core/revertible/revertible.js.map +0 -1
  767. package/dist/domains/index.d.ts +0 -8
  768. package/dist/domains/index.d.ts.map +0 -1
  769. package/dist/domains/index.js +0 -20
  770. package/dist/domains/index.js.map +0 -1
  771. package/dist/domains/json/index.d.ts +0 -7
  772. package/dist/domains/json/index.d.ts.map +0 -1
  773. package/dist/domains/json/index.js +0 -17
  774. package/dist/domains/json/index.js.map +0 -1
  775. package/dist/domains/json/jsonCursor.d.ts +0 -52
  776. package/dist/domains/json/jsonCursor.d.ts.map +0 -1
  777. package/dist/domains/json/jsonCursor.js +0 -197
  778. package/dist/domains/json/jsonCursor.js.map +0 -1
  779. package/dist/domains/json/jsonDomainSchema.d.ts +0 -24
  780. package/dist/domains/json/jsonDomainSchema.d.ts.map +0 -1
  781. package/dist/domains/json/jsonDomainSchema.js +0 -32
  782. package/dist/domains/json/jsonDomainSchema.js.map +0 -1
  783. package/dist/domains/leafDomain.d.ts +0 -72
  784. package/dist/domains/leafDomain.d.ts.map +0 -1
  785. package/dist/domains/leafDomain.js +0 -88
  786. package/dist/domains/leafDomain.js.map +0 -1
  787. package/dist/domains/schemaBuilder.d.ts +0 -103
  788. package/dist/domains/schemaBuilder.d.ts.map +0 -1
  789. package/dist/domains/schemaBuilder.js +0 -121
  790. package/dist/domains/schemaBuilder.js.map +0 -1
  791. package/dist/domains/testRecursiveDomain.d.ts +0 -17
  792. package/dist/domains/testRecursiveDomain.d.ts.map +0 -1
  793. package/dist/domains/testRecursiveDomain.js +0 -35
  794. package/dist/domains/testRecursiveDomain.js.map +0 -1
  795. package/dist/events/events.d.ts +0 -207
  796. package/dist/events/events.d.ts.map +0 -1
  797. package/dist/events/events.js.map +0 -1
  798. package/dist/feature-libraries/schemaBuilder.d.ts +0 -31
  799. package/dist/feature-libraries/schemaBuilder.d.ts.map +0 -1
  800. package/dist/feature-libraries/schemaBuilder.js +0 -40
  801. package/dist/feature-libraries/schemaBuilder.js.map +0 -1
  802. package/dist/feature-libraries/schemaBuilderBase.d.ts +0 -191
  803. package/dist/feature-libraries/schemaBuilderBase.d.ts.map +0 -1
  804. package/dist/feature-libraries/schemaBuilderBase.js +0 -201
  805. package/dist/feature-libraries/schemaBuilderBase.js.map +0 -1
  806. package/dist/shared-tree/treeView.d.ts +0 -73
  807. package/dist/shared-tree/treeView.d.ts.map +0 -1
  808. package/dist/shared-tree/treeView.js.map +0 -1
  809. package/dist/simple-tree/getJsonSchema.d.ts.map +0 -1
  810. package/dist/simple-tree/getJsonSchema.js.map +0 -1
  811. package/dist/simple-tree/getSimpleSchema.d.ts.map +0 -1
  812. package/dist/simple-tree/getSimpleSchema.js.map +0 -1
  813. package/dist/simple-tree/jsonSchema.d.ts.map +0 -1
  814. package/dist/simple-tree/jsonSchema.js.map +0 -1
  815. package/dist/simple-tree/simpleSchema.d.ts.map +0 -1
  816. package/dist/simple-tree/simpleSchema.js.map +0 -1
  817. package/dist/simple-tree/simpleSchemaToJsonSchema.d.ts.map +0 -1
  818. package/dist/simple-tree/simpleSchemaToJsonSchema.js.map +0 -1
  819. package/dist/simple-tree/viewSchemaToSimpleSchema.d.ts.map +0 -1
  820. package/dist/simple-tree/viewSchemaToSimpleSchema.js.map +0 -1
  821. package/lib/core/revertible/index.d.ts.map +0 -1
  822. package/lib/core/revertible/index.js.map +0 -1
  823. package/lib/core/revertible/revertible.d.ts.map +0 -1
  824. package/lib/core/revertible/revertible.js.map +0 -1
  825. package/lib/domains/index.d.ts +0 -8
  826. package/lib/domains/index.d.ts.map +0 -1
  827. package/lib/domains/index.js +0 -8
  828. package/lib/domains/index.js.map +0 -1
  829. package/lib/domains/json/index.d.ts +0 -7
  830. package/lib/domains/json/index.d.ts.map +0 -1
  831. package/lib/domains/json/index.js +0 -7
  832. package/lib/domains/json/index.js.map +0 -1
  833. package/lib/domains/json/jsonCursor.d.ts +0 -52
  834. package/lib/domains/json/jsonCursor.d.ts.map +0 -1
  835. package/lib/domains/json/jsonCursor.js +0 -192
  836. package/lib/domains/json/jsonCursor.js.map +0 -1
  837. package/lib/domains/json/jsonDomainSchema.d.ts +0 -24
  838. package/lib/domains/json/jsonDomainSchema.d.ts.map +0 -1
  839. package/lib/domains/json/jsonDomainSchema.js +0 -29
  840. package/lib/domains/json/jsonDomainSchema.js.map +0 -1
  841. package/lib/domains/leafDomain.d.ts +0 -72
  842. package/lib/domains/leafDomain.d.ts.map +0 -1
  843. package/lib/domains/leafDomain.js +0 -85
  844. package/lib/domains/leafDomain.js.map +0 -1
  845. package/lib/domains/schemaBuilder.d.ts +0 -103
  846. package/lib/domains/schemaBuilder.d.ts.map +0 -1
  847. package/lib/domains/schemaBuilder.js +0 -117
  848. package/lib/domains/schemaBuilder.js.map +0 -1
  849. package/lib/domains/testRecursiveDomain.d.ts +0 -17
  850. package/lib/domains/testRecursiveDomain.d.ts.map +0 -1
  851. package/lib/domains/testRecursiveDomain.js +0 -32
  852. package/lib/domains/testRecursiveDomain.js.map +0 -1
  853. package/lib/events/events.d.ts +0 -207
  854. package/lib/events/events.d.ts.map +0 -1
  855. package/lib/events/events.js.map +0 -1
  856. package/lib/feature-libraries/schemaBuilder.d.ts +0 -31
  857. package/lib/feature-libraries/schemaBuilder.d.ts.map +0 -1
  858. package/lib/feature-libraries/schemaBuilder.js +0 -36
  859. package/lib/feature-libraries/schemaBuilder.js.map +0 -1
  860. package/lib/feature-libraries/schemaBuilderBase.d.ts +0 -191
  861. package/lib/feature-libraries/schemaBuilderBase.d.ts.map +0 -1
  862. package/lib/feature-libraries/schemaBuilderBase.js +0 -195
  863. package/lib/feature-libraries/schemaBuilderBase.js.map +0 -1
  864. package/lib/shared-tree/treeView.d.ts +0 -73
  865. package/lib/shared-tree/treeView.d.ts.map +0 -1
  866. package/lib/shared-tree/treeView.js.map +0 -1
  867. package/lib/simple-tree/getJsonSchema.d.ts.map +0 -1
  868. package/lib/simple-tree/getJsonSchema.js.map +0 -1
  869. package/lib/simple-tree/getSimpleSchema.d.ts.map +0 -1
  870. package/lib/simple-tree/getSimpleSchema.js.map +0 -1
  871. package/lib/simple-tree/jsonSchema.d.ts.map +0 -1
  872. package/lib/simple-tree/jsonSchema.js.map +0 -1
  873. package/lib/simple-tree/simpleSchema.d.ts.map +0 -1
  874. package/lib/simple-tree/simpleSchema.js.map +0 -1
  875. package/lib/simple-tree/simpleSchemaToJsonSchema.d.ts.map +0 -1
  876. package/lib/simple-tree/simpleSchemaToJsonSchema.js.map +0 -1
  877. package/lib/simple-tree/viewSchemaToSimpleSchema.d.ts.map +0 -1
  878. package/lib/simple-tree/viewSchemaToSimpleSchema.js.map +0 -1
  879. package/src/domains/README.md +0 -6
  880. package/src/domains/fence.json +0 -5
  881. package/src/domains/index.ts +0 -19
  882. package/src/domains/json/fence.json +0 -5
  883. package/src/domains/json/index.ts +0 -13
  884. package/src/domains/json/jsonCursor.ts +0 -247
  885. package/src/domains/json/jsonDomainSchema.ts +0 -47
  886. package/src/domains/leafDomain.ts +0 -97
  887. package/src/domains/schemaBuilder.ts +0 -153
  888. package/src/domains/testRecursiveDomain.ts +0 -38
  889. package/src/events/fence.json +0 -5
  890. package/src/feature-libraries/schemaBuilder.ts +0 -45
  891. package/src/feature-libraries/schemaBuilderBase.ts +0 -393
  892. package/src/shared-tree/treeView.ts +0 -113
  893. /package/dist/core/{revertible/revertible.js → revertible.js} +0 -0
  894. /package/dist/simple-tree/{jsonSchema.js → api/jsonSchema.js} +0 -0
  895. /package/dist/simple-tree/{simpleSchema.js → api/simpleSchema.js} +0 -0
  896. /package/dist/simple-tree/{simpleSchemaToJsonSchema.d.ts → api/simpleSchemaToJsonSchema.d.ts} +0 -0
  897. /package/lib/core/{revertible/revertible.js → revertible.js} +0 -0
  898. /package/lib/simple-tree/{jsonSchema.js → api/jsonSchema.js} +0 -0
  899. /package/lib/simple-tree/{simpleSchema.js → api/simpleSchema.js} +0 -0
  900. /package/lib/simple-tree/{simpleSchemaToJsonSchema.d.ts → api/simpleSchemaToJsonSchema.d.ts} +0 -0
@@ -2,12 +2,13 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- /* eslint-disable import/no-internal-modules */
6
5
  import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
7
6
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
8
- import { EmptyKey } from "../core/index.js";
9
- import { FieldKinds, FlexFieldSchema, FlexMapNodeSchema, FlexObjectNodeSchema, TreeNodeSchemaBase, defaultSchemaPolicy, schemaIsLeaf, } from "../feature-libraries/index.js";
10
- import { normalizeFlexListEager } from "../feature-libraries/typed-schema/flexList.js";
7
+ import { EmptyKey, } from "../core/index.js";
8
+ import { FieldKinds, FlexFieldSchema, FlexMapNodeSchema, FlexObjectNodeSchema, TreeNodeSchemaBase, defaultSchemaPolicy, intoStoredSchemaCollection, schemaIsLeaf, } from "../feature-libraries/index.js";
9
+ // TODO: once flex schema is gone, this code can move into simple-tree
10
+ // eslint-disable-next-line import/no-internal-modules
11
+ import { normalizeFlexListEager } from "../feature-libraries/typed-schema/index.js";
11
12
  import { brand, fail, isReadonlyArray, mapIterable } from "../util/index.js";
12
13
  import { cachedFlexSchemaFromClassSchema, setFlexSchemaFromClassSchema, tryGetSimpleNodeSchema, NodeKind, } from "./core/index.js";
13
14
  import { FieldKind, FieldSchema, getStoredKey, } from "./schemaTypes.js";
@@ -38,6 +39,16 @@ export function toFlexSchema(root) {
38
39
  };
39
40
  return typed;
40
41
  }
42
+ /**
43
+ * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.
44
+ */
45
+ export function toStoredSchema(root) {
46
+ const flex = toFlexSchema(root);
47
+ return {
48
+ rootFieldSchema: flex.rootFieldSchema.stored,
49
+ ...intoStoredSchemaCollection(flex),
50
+ };
51
+ }
41
52
  /**
42
53
  * Return a flex schema for the provided class schema.
43
54
  *
@@ -47,6 +58,14 @@ export function getFlexSchema(root) {
47
58
  const treeSchema = toFlexSchema(root);
48
59
  return treeSchema.rootFieldSchema.monomorphicChildType ?? fail("root should be monomorphic");
49
60
  }
61
+ /**
62
+ * Return a stored schema for the provided class schema.
63
+ *
64
+ * This also has the side effect of populating the cached view schema on the class based schema.
65
+ */
66
+ export function getStoredSchema(root) {
67
+ return getFlexSchema(root).stored;
68
+ }
50
69
  /**
51
70
  * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.
52
71
  */
@@ -110,7 +129,9 @@ export function convertNodeSchema(schemaMap, schema) {
110
129
  const field = FlexFieldSchema.create(FieldKinds.optional, convertAllowedTypes(schemaMap, fieldInfo));
111
130
  // Lookup of cached schema is done here instead of before since walking the schema recursively to populate schemaMap is still required.
112
131
  const cached = cachedFlexSchemaFromClassSchema(schema);
113
- out = cached ?? FlexMapNodeSchema.create(builder, brand(schema.identifier), field);
132
+ out =
133
+ cached ??
134
+ FlexMapNodeSchema.create(builder, brand(schema.identifier), field);
114
135
  break;
115
136
  }
116
137
  case NodeKind.Array: {
@@ -127,10 +148,10 @@ export function convertNodeSchema(schemaMap, schema) {
127
148
  case NodeKind.Object: {
128
149
  const info = schema.info;
129
150
  const fields = Object.create(null);
130
- for (const [viewKey, implicitFieldSchema] of Object.entries(info)) {
151
+ for (const [propertyKey, implicitFieldSchema] of Object.entries(info)) {
131
152
  // If a `stored key` was provided, use it as the key in the flex schema.
132
- // Otherwise, use the view key.
133
- const flexKey = getStoredKey(viewKey, implicitFieldSchema);
153
+ // Otherwise, use the property key.
154
+ const flexKey = getStoredKey(propertyKey, implicitFieldSchema);
134
155
  // This code has to be careful to avoid assigning to __proto__ or similar built-in fields.
135
156
  Object.defineProperty(fields, flexKey, {
136
157
  enumerable: true,
@@ -1 +1 @@
1
- {"version":3,"file":"toFlexSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toFlexSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+CAA+C;AAC/C,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,QAAQ,EAAiC,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EACN,UAAU,EAGV,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EAGpB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,KAAK,E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,MAAM,GAAG,+BAA+B,CAAC,MAAM,CAAC,CAAC;gBACvD,GAAG,GAAG,MAAM,IAAI,oBAAoB,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;gBACvF,MAAM;YACP,CAAC;YACD;gBACC,eAAe,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QACD,MAAM,CAAC,GAAG,YAAY,kBAAkB,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAC/E,CAAC;YACA,MAAM,MAAM,GAAG,+BAA+B,CAAC,MAAM,CAAC,CAAC;YACvD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC1B,MAAM,CACL,+BAA+B,CAAC,MAAM,CAAC,KAAK,GAAG,EAC/C,KAAK,CAAC,gCAAgC,CACtC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACP,4BAA4B,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC3C,CAAC;QACF,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC,CAAC;IACF,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-internal-modules */\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { EmptyKey, type TreeNodeSchemaIdentifier } from \"../core/index.js\";\nimport {\n\tFieldKinds,\n\ttype FlexAllowedTypes,\n\ttype FlexFieldKind,\n\tFlexFieldSchema,\n\tFlexMapNodeSchema,\n\tFlexObjectNodeSchema,\n\ttype FlexTreeNodeSchema,\n\ttype FlexTreeSchema,\n\tTreeNodeSchemaBase,\n\tdefaultSchemaPolicy,\n\tschemaIsLeaf,\n} from \"../feature-libraries/index.js\";\nimport { normalizeFlexListEager } from \"../feature-libraries/typed-schema/flexList.js\";\nimport { brand, fail, isReadonlyArray, mapIterable } from \"../util/index.js\";\nimport {\n\tcachedFlexSchemaFromClassSchema,\n\tsetFlexSchemaFromClassSchema,\n\ttryGetSimpleNodeSchema,\n\tNodeKind,\n\ttype TreeNodeSchema,\n} from \"./core/index.js\";\nimport {\n\tFieldKind,\n\tFieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n} from \"./schemaTypes.js\";\n\ninterface SchemaInfo {\n\treadonly toFlex: () => FlexTreeNodeSchema;\n\treadonly original: TreeNodeSchema;\n}\n\ntype SchemaMap = Map<TreeNodeSchemaIdentifier, SchemaInfo>;\n\n/**\n * Generate a {@link FlexTreeSchema} with `root` as the root field.\n *\n * This also has the side effect of populating the cached view schema on the class-based schema.\n */\nexport function toFlexSchema(root: ImplicitFieldSchema): FlexTreeSchema {\n\tconst schemaMap: SchemaMap = new Map();\n\tconst field = convertField(schemaMap, root);\n\tconst nodeSchema = new Map(\n\t\tmapIterable(schemaMap, ([key, value]) => {\n\t\t\tconst schema = value.toFlex();\n\t\t\tconst classSchema = tryGetSimpleNodeSchema(schema);\n\t\t\tif (classSchema === undefined) {\n\t\t\t\tassert(schemaIsLeaf(schema), 0x83e /* invalid leaf */);\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(classSchema) === schema,\n\t\t\t\t\t0x83f /* mismatched schema */,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn [key, schema];\n\t\t}),\n\t);\n\n\tconst typed: FlexTreeSchema = {\n\t\tnodeSchema,\n\t\tadapters: {},\n\t\trootFieldSchema: field,\n\t\tpolicy: defaultSchemaPolicy,\n\t};\n\treturn typed;\n}\n\n/**\n * Return a flex schema for the provided class schema.\n *\n * This also has the side effect of populating the cached view schema on the class based schema.\n */\nexport function getFlexSchema(root: TreeNodeSchema): FlexTreeNodeSchema {\n\tconst treeSchema = toFlexSchema(root);\n\treturn treeSchema.rootFieldSchema.monomorphicChildType ?? fail(\"root should be monomorphic\");\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(\n\tschemaMap: SchemaMap,\n\tschema: ImplicitFieldSchema,\n): FlexFieldSchema {\n\tlet kind: FlexFieldKind;\n\tlet types: ImplicitAllowedTypes;\n\tif (schema instanceof FieldSchema) {\n\t\tkind = convertFieldKind.get(schema.kind) ?? fail(\"Invalid field kind\");\n\t\ttypes = schema.allowedTypes;\n\t} else {\n\t\tkind = FieldKinds.required;\n\t\ttypes = schema;\n\t}\n\tconst allowedTypes = convertAllowedTypes(schemaMap, types);\n\treturn FlexFieldSchema.create(kind, allowedTypes);\n}\n\nconst convertFieldKind = new Map<FieldKind, FlexFieldKind>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Normalizes an {@link ImplicitAllowedTypes} into an {@link AllowedTypes}.\n */\nexport function convertAllowedTypes(\n\tschemaMap: SchemaMap,\n\tschema: ImplicitAllowedTypes,\n): FlexAllowedTypes {\n\tif (isReadonlyArray(schema)) {\n\t\treturn normalizeFlexListEager(schema).map((item) => convertNodeSchema(schemaMap, item));\n\t}\n\treturn [convertNodeSchema(schemaMap, schema)];\n}\n\nconst builder = { name: \"simple schema\" };\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link FlexTreeNodeSchema}.\n * Ensures all types reachable from `schema` are included in `schemaMap`.\n *\n * Return value (and entries in map) are lazy to allow recursive types to work.\n * This laziness does NOT extend to adding entries to `schemaMap`:\n * all referenced types are added to it before this function returns.\n */\nexport function convertNodeSchema(\n\tschemaMap: SchemaMap,\n\tschema: TreeNodeSchema,\n): () => FlexTreeNodeSchema {\n\tconst fromMap = schemaMap.get(brand(schema.identifier));\n\tif (fromMap !== undefined) {\n\t\tif (fromMap.original !== schema) {\n\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\tthrow new UsageError(\n\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\tschema.identifier,\n\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t);\n\t\t}\n\t\treturn fromMap.toFlex;\n\t}\n\n\tconst toFlex = (): FlexTreeNodeSchema => {\n\t\tlet out: FlexTreeNodeSchema;\n\t\tconst kind = schema.kind;\n\t\tswitch (kind) {\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tconst cached =\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(schema) ?? fail(\"leaf schema should be pre-cached\");\n\t\t\t\tassert(schemaIsLeaf(cached), 0x840 /* expected leaf */);\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t\tcase NodeKind.Map: {\n\t\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\t\tconst field = FlexFieldSchema.create(\n\t\t\t\t\tFieldKinds.optional,\n\t\t\t\t\tconvertAllowedTypes(schemaMap, fieldInfo),\n\t\t\t\t);\n\t\t\t\t// Lookup of cached schema is done here instead of before since walking the schema recursively to populate schemaMap is still required.\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout = cached ?? FlexMapNodeSchema.create(builder, brand(schema.identifier), field);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\t\tconst field = FlexFieldSchema.create(\n\t\t\t\t\tFieldKinds.sequence,\n\t\t\t\t\tconvertAllowedTypes(schemaMap, fieldInfo),\n\t\t\t\t);\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout =\n\t\t\t\t\tcached ??\n\t\t\t\t\tFlexObjectNodeSchema.create(builder, brand(schema.identifier), {\n\t\t\t\t\t\t[EmptyKey]: field,\n\t\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tconst info = schema.info as Record<string, ImplicitFieldSchema>;\n\t\t\t\tconst fields: Record<string, FlexFieldSchema> = Object.create(null);\n\t\t\t\tfor (const [viewKey, implicitFieldSchema] of Object.entries(info)) {\n\t\t\t\t\t// If a `stored key` was provided, use it as the key in the flex schema.\n\t\t\t\t\t// Otherwise, use the view key.\n\t\t\t\t\tconst flexKey = getStoredKey(viewKey, implicitFieldSchema);\n\n\t\t\t\t\t// This code has to be careful to avoid assigning to __proto__ or similar built-in fields.\n\t\t\t\t\tObject.defineProperty(fields, flexKey, {\n\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\tconfigurable: false,\n\t\t\t\t\t\twritable: false,\n\t\t\t\t\t\tvalue: convertField(schemaMap, implicitFieldSchema),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout = cached ?? FlexObjectNodeSchema.create(builder, brand(schema.identifier), fields);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(kind);\n\t\t}\n\t\tassert(out instanceof TreeNodeSchemaBase, 0x841 /* invalid schema produced */);\n\t\t{\n\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\tif (cached !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(schema) === out,\n\t\t\t\t\t0x842 /* incorrect flexSchemaSymbol */,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsetFlexSchemaFromClassSchema(schema, out);\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t};\n\tschemaMap.set(brand(schema.identifier), { original: schema, toFlex });\n\treturn toFlex;\n}\n"]}
1
+ {"version":3,"file":"toFlexSchema.js","sourceRoot":"","sources":["../../src/simple-t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AE,CAAC;gBAC1B,MAAM,CACL,+BAA+B,CAAC,MAAM,CAAC,KAAK,GAAG,EAC/C,KAAK,CAAC,gCAAgC,CACtC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACP,4BAA4B,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC3C,CAAC;QACF,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC,CAAC;IACF,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n} from \"../core/index.js\";\nimport {\n\tFieldKinds,\n\ttype FlexAllowedTypes,\n\ttype FlexFieldKind,\n\tFlexFieldSchema,\n\tFlexMapNodeSchema,\n\tFlexObjectNodeSchema,\n\ttype FlexTreeNodeSchema,\n\ttype FlexTreeSchema,\n\tTreeNodeSchemaBase,\n\tdefaultSchemaPolicy,\n\tintoStoredSchemaCollection,\n\tschemaIsLeaf,\n} from \"../feature-libraries/index.js\";\n// TODO: once flex schema is gone, this code can move into simple-tree\n// eslint-disable-next-line import/no-internal-modules\nimport { normalizeFlexListEager } from \"../feature-libraries/typed-schema/index.js\";\nimport { brand, fail, isReadonlyArray, mapIterable } from \"../util/index.js\";\nimport {\n\tcachedFlexSchemaFromClassSchema,\n\tsetFlexSchemaFromClassSchema,\n\ttryGetSimpleNodeSchema,\n\tNodeKind,\n\ttype TreeNodeSchema,\n} from \"./core/index.js\";\nimport {\n\tFieldKind,\n\tFieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n} from \"./schemaTypes.js\";\n\ninterface SchemaInfo {\n\treadonly toFlex: () => FlexTreeNodeSchema;\n\treadonly original: TreeNodeSchema;\n}\n\ntype SchemaMap = Map<TreeNodeSchemaIdentifier, SchemaInfo>;\n\n/**\n * Generate a {@link FlexTreeSchema} with `root` as the root field.\n *\n * This also has the side effect of populating the cached view schema on the class-based schema.\n */\nexport function toFlexSchema(root: ImplicitFieldSchema): FlexTreeSchema {\n\tconst schemaMap: SchemaMap = new Map();\n\tconst field = convertField(schemaMap, root);\n\tconst nodeSchema = new Map(\n\t\tmapIterable(schemaMap, ([key, value]) => {\n\t\t\tconst schema = value.toFlex();\n\t\t\tconst classSchema = tryGetSimpleNodeSchema(schema);\n\t\t\tif (classSchema === undefined) {\n\t\t\t\tassert(schemaIsLeaf(schema), 0x83e /* invalid leaf */);\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(classSchema) === schema,\n\t\t\t\t\t0x83f /* mismatched schema */,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn [key, schema];\n\t\t}),\n\t);\n\n\tconst typed: FlexTreeSchema = {\n\t\tnodeSchema,\n\t\tadapters: {},\n\t\trootFieldSchema: field,\n\t\tpolicy: defaultSchemaPolicy,\n\t};\n\treturn typed;\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n */\nexport function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\tconst flex = toFlexSchema(root);\n\treturn {\n\t\trootFieldSchema: flex.rootFieldSchema.stored,\n\t\t...intoStoredSchemaCollection(flex),\n\t};\n}\n\n/**\n * Return a flex schema for the provided class schema.\n *\n * This also has the side effect of populating the cached view schema on the class based schema.\n */\nexport function getFlexSchema(root: TreeNodeSchema): FlexTreeNodeSchema {\n\tconst treeSchema = toFlexSchema(root);\n\treturn treeSchema.rootFieldSchema.monomorphicChildType ?? fail(\"root should be monomorphic\");\n}\n\n/**\n * Return a stored schema for the provided class schema.\n *\n * This also has the side effect of populating the cached view schema on the class based schema.\n */\nexport function getStoredSchema(root: TreeNodeSchema): TreeNodeStoredSchema {\n\treturn getFlexSchema(root).stored;\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(\n\tschemaMap: SchemaMap,\n\tschema: ImplicitFieldSchema,\n): FlexFieldSchema {\n\tlet kind: FlexFieldKind;\n\tlet types: ImplicitAllowedTypes;\n\tif (schema instanceof FieldSchema) {\n\t\tkind = convertFieldKind.get(schema.kind) ?? fail(\"Invalid field kind\");\n\t\ttypes = schema.allowedTypes;\n\t} else {\n\t\tkind = FieldKinds.required;\n\t\ttypes = schema;\n\t}\n\tconst allowedTypes = convertAllowedTypes(schemaMap, types);\n\treturn FlexFieldSchema.create(kind, allowedTypes);\n}\n\nconst convertFieldKind = new Map<FieldKind, FlexFieldKind>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Normalizes an {@link ImplicitAllowedTypes} into an {@link AllowedTypes}.\n */\nexport function convertAllowedTypes(\n\tschemaMap: SchemaMap,\n\tschema: ImplicitAllowedTypes,\n): FlexAllowedTypes {\n\tif (isReadonlyArray(schema)) {\n\t\treturn normalizeFlexListEager(schema).map((item) => convertNodeSchema(schemaMap, item));\n\t}\n\treturn [convertNodeSchema(schemaMap, schema)];\n}\n\nconst builder = { name: \"simple schema\" };\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link FlexTreeNodeSchema}.\n * Ensures all types reachable from `schema` are included in `schemaMap`.\n *\n * Return value (and entries in map) are lazy to allow recursive types to work.\n * This laziness does NOT extend to adding entries to `schemaMap`:\n * all referenced types are added to it before this function returns.\n */\nexport function convertNodeSchema(\n\tschemaMap: SchemaMap,\n\tschema: TreeNodeSchema,\n): () => FlexTreeNodeSchema {\n\tconst fromMap = schemaMap.get(brand(schema.identifier));\n\tif (fromMap !== undefined) {\n\t\tif (fromMap.original !== schema) {\n\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\tthrow new UsageError(\n\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\tschema.identifier,\n\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t);\n\t\t}\n\t\treturn fromMap.toFlex;\n\t}\n\n\tconst toFlex = (): FlexTreeNodeSchema => {\n\t\tlet out: FlexTreeNodeSchema;\n\t\tconst kind = schema.kind;\n\t\tswitch (kind) {\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tconst cached =\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(schema) ?? fail(\"leaf schema should be pre-cached\");\n\t\t\t\tassert(schemaIsLeaf(cached), 0x840 /* expected leaf */);\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t\tcase NodeKind.Map: {\n\t\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\t\tconst field = FlexFieldSchema.create(\n\t\t\t\t\tFieldKinds.optional,\n\t\t\t\t\tconvertAllowedTypes(schemaMap, fieldInfo),\n\t\t\t\t);\n\t\t\t\t// Lookup of cached schema is done here instead of before since walking the schema recursively to populate schemaMap is still required.\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout =\n\t\t\t\t\tcached ??\n\t\t\t\t\tFlexMapNodeSchema.create(\n\t\t\t\t\t\tbuilder,\n\t\t\t\t\t\tbrand<TreeNodeSchemaIdentifier>(schema.identifier),\n\t\t\t\t\t\tfield,\n\t\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\t\tconst field = FlexFieldSchema.create(\n\t\t\t\t\tFieldKinds.sequence,\n\t\t\t\t\tconvertAllowedTypes(schemaMap, fieldInfo),\n\t\t\t\t);\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout =\n\t\t\t\t\tcached ??\n\t\t\t\t\tFlexObjectNodeSchema.create(builder, brand(schema.identifier), {\n\t\t\t\t\t\t[EmptyKey]: field,\n\t\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tconst info = schema.info as Record<string, ImplicitFieldSchema>;\n\t\t\t\tconst fields: Record<string, FlexFieldSchema> = Object.create(null);\n\t\t\t\tfor (const [propertyKey, implicitFieldSchema] of Object.entries(info)) {\n\t\t\t\t\t// If a `stored key` was provided, use it as the key in the flex schema.\n\t\t\t\t\t// Otherwise, use the property key.\n\t\t\t\t\tconst flexKey = getStoredKey(propertyKey, implicitFieldSchema);\n\n\t\t\t\t\t// This code has to be careful to avoid assigning to __proto__ or similar built-in fields.\n\t\t\t\t\tObject.defineProperty(fields, flexKey, {\n\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\tconfigurable: false,\n\t\t\t\t\t\twritable: false,\n\t\t\t\t\t\tvalue: convertField(schemaMap, implicitFieldSchema),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout = cached ?? FlexObjectNodeSchema.create(builder, brand(schema.identifier), fields);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(kind);\n\t\t}\n\t\tassert(out instanceof TreeNodeSchemaBase, 0x841 /* invalid schema produced */);\n\t\t{\n\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\tif (cached !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(schema) === out,\n\t\t\t\t\t0x842 /* incorrect flexSchemaSymbol */,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsetFlexSchemaFromClassSchema(schema, out);\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t};\n\tschemaMap.set(brand(schema.identifier), { original: schema, toFlex });\n\treturn toFlex;\n}\n"]}
@@ -2,12 +2,12 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type FieldKey, type SchemaAndPolicy, type ExclusiveMapTree } from "../core/index.js";
5
+ import { type SchemaAndPolicy, type ExclusiveMapTree } from "../core/index.js";
6
6
  import { type NodeKeyManager } from "../feature-libraries/index.js";
7
- import type { InsertableContent } from "./proxies.js";
8
7
  import { type ImplicitAllowedTypes, type ImplicitFieldSchema } from "./schemaTypes.js";
9
- import { type TreeNodeSchema } from "./core/index.js";
8
+ import { type TreeNode, type TreeNodeSchema, type Unhydrated } from "./core/index.js";
10
9
  import { SchemaValidationErrors } from "../feature-libraries/index.js";
10
+ import type { IFluidHandle } from "@fluidframework/core-interfaces";
11
11
  /**
12
12
  * Module notes:
13
13
  *
@@ -66,40 +66,7 @@ export declare function inSchemaOrThrow(maybeError: SchemaValidationErrors): voi
66
66
  /**
67
67
  * @returns all types for which the data is schema-compatible.
68
68
  */
69
- export declare function getPossibleTypes(allowedTypes: ReadonlySet<TreeNodeSchema>, data: ContextuallyTypedNodeData): TreeNodeSchema[];
70
- /**
71
- * Content of a tree which needs external schema information to interpret.
72
- *
73
- * This format is intended for concise authoring of tree literals when the schema is statically known.
74
- *
75
- * Once schema aware APIs are implemented, they can be used to provide schema specific subsets of this type.
76
- */
77
- export type ContextuallyTypedNodeData = ContextuallyTypedNodeDataObject | number | string | boolean | null | readonly ContextuallyTypedNodeData[] | ReadonlyMap<string, ContextuallyTypedNodeData> | Iterable<ContextuallyTypedNodeData> | Iterable<[string, ContextuallyTypedNodeData]>;
78
- /**
79
- * Content of a field which needs external schema information to interpret.
80
- *
81
- * This format is intended for concise authoring of tree literals when the schema is statically known.
82
- *
83
- * Once schema aware APIs are implemented, they can be used to provide schema specific subsets of this type.
84
- */
85
- export type ContextuallyTypedFieldData = ContextuallyTypedNodeData | undefined;
86
- /**
87
- * Object case of {@link ContextuallyTypedNodeData}.
88
- */
89
- export interface ContextuallyTypedNodeDataObject {
90
- /**
91
- * Fields of this node, indexed by their field keys.
92
- *
93
- * Allow explicit undefined for compatibility with FlexTree, and type-safety on read.
94
- */
95
- [key: FieldKey]: ContextuallyTypedFieldData;
96
- /**
97
- * Fields of this node, indexed by their field keys as strings.
98
- *
99
- * Allow unbranded field keys as a convenience for literals.
100
- */
101
- [key: string]: ContextuallyTypedFieldData;
102
- }
69
+ export declare function getPossibleTypes(allowedTypes: ReadonlySet<TreeNodeSchema>, data: FactoryContent): TreeNodeSchema[];
103
70
  /**
104
71
  * Walk the given {@link ExclusiveMapTree} and deeply provide any field defaults for fields that are missing in the tree but present in the schema.
105
72
  * @param mapTree - The tree to populate with defaults. This is borrowed: no references to it are kept by this function.
@@ -110,4 +77,25 @@ export interface ContextuallyTypedNodeDataObject {
110
77
  * @remarks This function mutates the input tree by deeply adding new fields to the field maps where applicable.
111
78
  */
112
79
  export declare function addDefaultsToMapTree(mapTree: ExclusiveMapTree, allowedTypes: ImplicitAllowedTypes, context: NodeKeyManager | undefined): void;
80
+ /**
81
+ * Content which can be used to build a node.
82
+ * @remarks
83
+ * Can contain unhydrated nodes, but can not be an unhydrated node at the root.
84
+ */
85
+ export type FactoryContent = IFluidHandle | string | number | boolean | null | Iterable<readonly [string, InsertableContent]> | readonly InsertableContent[] | FactoryContentObject;
86
+ /**
87
+ * Record-like object which can be used to build some kinds of nodes.
88
+ * @remarks
89
+ * Can contain unhydrated nodes, but can not be an unhydrated node at the root.
90
+ *
91
+ * Supports object and map nodes.
92
+ */
93
+ type FactoryContentObject = {
94
+ readonly [P in string]?: InsertableContent;
95
+ };
96
+ /**
97
+ * Content which can be inserted into a tree.
98
+ */
99
+ export type InsertableContent = Unhydrated<TreeNode> | FactoryContent;
100
+ export {};
113
101
  //# sourceMappingURL=toMapTree.d.ts.map
@@ -1 +1 @@
1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AiB,EACvB,YAAY,EAAE,oBAAoB,EAClC,OAAO,CAAC,EAAE,cAAc,EACxB,sBAAsB,CAAC,EAAE,eAAe,GACtC,gBAAgB,CAAC;AACpB,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,iBAAiB,GAAG,SAAS,EACnC,YAAY,EAAE,mBAAmB,EACjC,OAAO,CAAC,EAAE,cAAc,EACxB,sBAAsB,CAAC,EAAE,eAAe,GACtC,gBAAgB,GAAG,SAAS,CAAC;AA0FhC;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAIxE;AAgRD;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,EACzC,IAAI,EAAE,cAAc,GAClB,cAAc,EAAE,CAclB;AA6HD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,gBAAgB,EACzB,YAAY,EAAE,oBAAoB,EAClC,OAAO,EAAE,cAAc,GAAG,SAAS,GACjC,IAAI,CA8CN;AAqCD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GACvB,YAAY,GACZ,MAAM,GACN,MAAM,GACN,OAAO,GAEP,IAAI,GACJ,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAC9C,SAAS,iBAAiB,EAAE,GAC5B,oBAAoB,CAAC;AAExB;;;;;;GAMG;AACH,KAAK,oBAAoB,GAAG;IAC3B,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,iBAAiB;CAC1C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC"}
@@ -10,9 +10,8 @@ import { isTreeValue, valueSchemaAllows, isMapTreeNode, } from "../feature-libra
10
10
  import { brand, fail, isReadonlyArray, find } from "../util/index.js";
11
11
  import { nullSchema } from "./leafNodeSchema.js";
12
12
  import { normalizeAllowedTypes, extractFieldProvider, isConstant, normalizeFieldSchema, FieldKind, } from "./schemaTypes.js";
13
- import { NodeKind, tryGetSimpleNodeSchema } from "./core/index.js";
13
+ import { getKernel, getSimpleNodeSchemaFromNode, isTreeNode, NodeKind, } from "./core/index.js";
14
14
  import { isNodeInSchema } from "../feature-libraries/index.js";
15
- import { tryGetInnerNode } from "./proxyBinding.js";
16
15
  import { isObjectNodeSchema } from "./objectNodeTypes.js";
17
16
  export function mapTreeFromNodeData(data, allowedTypes, context, schemaValidationPolicy) {
18
17
  const normalizedFieldSchema = normalizeFieldSchema(allowedTypes);
@@ -26,11 +25,14 @@ export function mapTreeFromNodeData(data, allowedTypes, context, schemaValidatio
26
25
  const mapTree = nodeDataToMapTree(data, normalizedFieldSchema.allowedTypeSet);
27
26
  // Add what defaults can be provided. If no `context` is providing, some defaults may still be missing.
28
27
  addDefaultsToMapTree(mapTree, normalizedFieldSchema.allowedTypes, context);
29
- // TODO:
30
- // Since some defaults may still be missing, this can give false positives when context is undefined but schemaValidationPolicy is provided.
31
28
  if (schemaValidationPolicy?.policy.validateSchema === true) {
32
- const maybeError = isNodeInSchema(mapTree, schemaValidationPolicy);
33
- inSchemaOrThrow(maybeError);
29
+ // TODO: BUG: AB#9131
30
+ // Since some defaults may still be missing, this can give false positives when context is undefined but schemaValidationPolicy is provided.
31
+ // For now disable this check when context is undefined:
32
+ if (context !== undefined) {
33
+ const maybeError = isNodeInSchema(mapTree, schemaValidationPolicy);
34
+ inSchemaOrThrow(maybeError);
35
+ }
34
36
  }
35
37
  return mapTree;
36
38
  }
@@ -44,10 +46,10 @@ export function mapTreeFromNodeData(data, allowedTypes, context, schemaValidatio
44
46
  function nodeDataToMapTree(data, allowedTypes) {
45
47
  // A special cache path for processing unhydrated nodes.
46
48
  // They already have the mapTree, so there is no need to recompute it.
47
- const flexNode = tryGetInnerNode(data);
48
- if (flexNode !== undefined) {
49
- if (isMapTreeNode(flexNode)) {
50
- if (!allowedTypes.has(tryGetSimpleNodeSchema(flexNode.schema) ?? fail("missing schema"))) {
49
+ const innerNode = tryGetInnerNode(data);
50
+ if (innerNode !== undefined) {
51
+ if (isMapTreeNode(innerNode)) {
52
+ if (!allowedTypes.has(getSimpleNodeSchemaFromNode(innerNode))) {
51
53
  throw new UsageError("Invalid schema for this context.");
52
54
  }
53
55
  // TODO: mapTreeFromNodeData modifies the trees it gets to add defaults.
@@ -55,13 +57,14 @@ function nodeDataToMapTree(data, allowedTypes) {
55
57
  // This is unnecessary and inefficient, but should be a no-op if all calls provide the same context (which they might not).
56
58
  // A cleaner design (avoiding this cast) might be to apply defaults eagerly if they don't need a context, and lazily (when hydrating) if they do.
57
59
  // This could avoid having to mutate the map tree to apply defaults, removing the need for this cast.
58
- return flexNode.mapTree;
60
+ return innerNode.mapTree;
59
61
  }
60
62
  else {
61
63
  // The node is already hydrated, meaning that it already got inserted into the tree previously
62
64
  throw new UsageError("A node may not be inserted into the tree more than once");
63
65
  }
64
66
  }
67
+ assert(!isTreeNode(data), 0xa23 /* data without an inner node cannot be TreeNode */);
65
68
  const schema = getType(data, allowedTypes);
66
69
  let result;
67
70
  switch (schema.kind) {
@@ -243,14 +246,17 @@ function mapToMapTree(data, schema) {
243
246
  */
244
247
  function objectToMapTree(data, schema) {
245
248
  assert(isObjectNodeSchema(schema), 0x924 /* Expected an Object schema. */);
246
- if (typeof data !== "object" || data === null) {
249
+ if (typeof data !== "object" ||
250
+ data === null ||
251
+ Symbol.iterator in data ||
252
+ isFluidHandle(data)) {
247
253
  throw new UsageError(`Input data is incompatible with Object schema: ${data}`);
248
254
  }
249
255
  const fields = new Map();
250
256
  // Loop through field keys without data.
251
257
  // This does NOT apply defaults.
252
258
  for (const [key, fieldInfo] of schema.flexKeyMap) {
253
- if (Object.hasOwnProperty.call(data, key)) {
259
+ if (checkFieldProperty(data, key)) {
254
260
  const value = data[key];
255
261
  setFieldValue(fields, value, fieldInfo.schema, fieldInfo.storedKey);
256
262
  }
@@ -260,6 +266,18 @@ function objectToMapTree(data, schema) {
260
266
  fields,
261
267
  };
262
268
  }
269
+ /**
270
+ * Check {@link FactoryContentObject} for a property which could be store a field.
271
+ * @remarks
272
+ * The currently policy is to only consider own properties.
273
+ * See {@link InsertableObjectFromSchemaRecord} for where this policy is documented in the public API.
274
+ *
275
+ * Explicit undefined members are considered to exist, as long as they are own properties.
276
+ */
277
+ function checkFieldProperty(data, key) {
278
+ // This policy only allows own properties.
279
+ return Object.hasOwnProperty.call(data, key);
280
+ }
263
281
  function setFieldValue(fields, fieldValue, fieldSchema, flexKey) {
264
282
  if (fieldValue !== undefined) {
265
283
  const mappedChildTree = nodeDataToMapTree(fieldValue, fieldSchema.allowedTypeSet);
@@ -331,7 +349,7 @@ var CompatibilityLevel;
331
349
  * Note that this may return true for cases where data is incompatible, but it must not return false in cases where the data is compatible.
332
350
  */
333
351
  function shallowCompatibilityTest(schema, data) {
334
- assert(data !== undefined, 0x889 /* undefined cannot be used as contextually typed data. Use ContextuallyTypedFieldData. */);
352
+ assert(data !== undefined, 0x889 /* undefined cannot be used as FactoryContent. */);
335
353
  if (isTreeValue(data)) {
336
354
  return allowsValue(schema, data) ? CompatibilityLevel.Normal : CompatibilityLevel.None;
337
355
  }
@@ -387,8 +405,15 @@ function shallowCompatibilityTest(schema, data) {
387
405
  // TODO#7441: Consider allowing data to be inserted which has keys that are extraneous/unknown to the schema (those keys are ignored)
388
406
  // If the schema has a required key which is not present in the input object, reject it.
389
407
  for (const [fieldKey, fieldSchema] of schema.fields) {
390
- if (data[fieldKey] === undefined && fieldSchema.requiresValue) {
391
- return CompatibilityLevel.None;
408
+ if (fieldSchema.requiresValue) {
409
+ if (checkFieldProperty(data, fieldKey)) {
410
+ if (data[fieldKey] === undefined) {
411
+ return CompatibilityLevel.None;
412
+ }
413
+ }
414
+ else {
415
+ return CompatibilityLevel.None;
416
+ }
392
417
  }
393
418
  }
394
419
  return CompatibilityLevel.Normal;
@@ -468,9 +493,21 @@ function provideDefault(fieldProvider, context) {
468
493
  return fieldProvider();
469
494
  }
470
495
  else {
471
- // Leaving field empty despite it needing a default value since a context was required and non was provided.
496
+ // Leaving field empty despite it needing a default value since a context was required and none was provided.
472
497
  // Caller better handle this case by providing the default at some other point in time when the context becomes known.
473
498
  }
474
499
  }
475
500
  }
501
+ /**
502
+ * Retrieves the InnerNode associated with the given target via {@link setInnerNode}, if any.
503
+ * @remarks
504
+ * If `target` is a unhydrated node, returns its MapTreeNode.
505
+ * If `target` is a cooked node (or marinated but a FlexTreeNode exists) returns the FlexTreeNode.
506
+ * If the target is not a node, or a marinated node with no FlexTreeNode for its anchor, returns undefined.
507
+ */
508
+ function tryGetInnerNode(target) {
509
+ if (isTreeNode(target)) {
510
+ return getKernel(target).tryGetInnerNode();
511
+ }
512
+ }
476
513
  //# sourceMappingURL=toMapTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toMapTree.js","sourceRoot":"","sources":["../../src/simple-tree/toMapTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,OAAO,EACN,QAAQ,GAOR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,WAAW,EACX,iBAAiB,EAEjB,aAAa,GACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAGN,qBAAqB,EACrB,oBAAoB,EACpB,UAAU,EAGV,oBAAoB,EACpB,SAAS,GAET,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAuB,MAAM,iBAAiB,CAAC;AACxF,OAAO,E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;oBACF,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO;IACR,CAAC;IAED,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,QAAQ,CAAC,KAAK,CAAC;QACpB,KAAK,QAAQ,CAAC,GAAG;YAChB,CAAC;gBACA,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;oBAC7C,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;wBAC3B,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,IAA4B,EAAE,OAAO,CAAC,CAAC;oBAC3E,CAAC;gBACF,CAAC;YACF,CAAC;YACD,MAAM;QACP;YACC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAC5E,MAAM;IACR,CAAC;AACF,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CACtB,aAA4B,EAC5B,OAAmC;IAEnC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACP,IAAI,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/B,OAAO,aAAa,EAAE,CAAC;QACxB,CAAC;aAAM,CAAC;YACP,4GAA4G;YAC5G,sHAAsH;QACvH,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\tEmptyKey,\n\ttype FieldKey,\n\ttype MapTree,\n\ttype TreeValue,\n\ttype ValueSchema,\n\ttype SchemaAndPolicy,\n\ttype ExclusiveMapTree,\n} from \"../core/index.js\";\nimport {\n\tisTreeValue,\n\tvalueSchemaAllows,\n\ttype NodeKeyManager,\n\tisMapTreeNode,\n} from \"../feature-libraries/index.js\";\nimport { brand, fail, isReadonlyArray, find } from \"../util/index.js\";\n\nimport { nullSchema } from \"./leafNodeSchema.js\";\nimport type { InsertableContent } from \"./proxies.js\";\nimport {\n\ttype FieldSchema,\n\ttype ImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n\textractFieldProvider,\n\tisConstant,\n\ttype FieldProvider,\n\ttype ImplicitFieldSchema,\n\tnormalizeFieldSchema,\n\tFieldKind,\n\ttype TreeLeafValue,\n} from \"./schemaTypes.js\";\nimport { NodeKind, tryGetSimpleNodeSchema, type TreeNodeSchema } from \"./core/index.js\";\nimport { SchemaValidationErrors, isNodeInSchema } from \"../feature-libraries/index.js\";\nimport { tryGetInnerNode } from \"./proxyBinding.js\";\nimport { isObjectNodeSchema } from \"./objectNodeTypes.js\";\n\n/**\n * Module notes:\n *\n * The flow of the below code is in terms of the structure of the input data. We then verify that the associated\n * schema is appropriate for that kind of data. This is fine while we have a 1:1 mapping of kind of input data to\n * the kind of schema we expect for it (e.g. an input that is an array always need to be associated with a sequence in\n * the schema). If/when we begin accepting kinds of input data that are ambiguous (e.g. accepting an input that is an\n * array of key/value tuples to instantiate a map) we may need to rethink the structure here to be based more on the\n * schema than on the input data.\n */\n\n/**\n * Transforms an input {@link TypedNode} tree to a {@link MapTree}.\n * @param data - The input tree to be converted.\n * If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,\n * otherwise an error will be thrown.\n *\n * Fallbacks:\n *\n * * `NaN` =\\> `null`\n *\n * * `+/-∞` =\\> `null`\n *\n * * `-0` =\\> `+0`\n *\n * For fields with a default value, the field may be omitted.\n * If `context` is not provided, defaults which require a context will be left empty which can be out of schema.\n *\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n * @param context - An optional context which, if present, will allow defaults to be created by {@link ContextualFieldProvider}s.\n * If absent, only defaults from {@link ConstantFieldProvider}s will be created.\n * @param schemaValidationPolicy - The stored schema and policy to be used for validation, if the policy says schema\n * validation should happen. If it does, the input tree will be validated against this schema + policy, and an error will\n * be thrown if the tree does not conform to the schema. If undefined, no validation against the stored schema is done.\n *\n * TODO:BUG: AB#9131\n * This schema validation is done before defaults are provided.\n * This can not easily be fixed by reordering things within this implementation since even at the end of this function defaults requiring a context may not have been filled.\n * This means schema validation reject required fields getting their value from a default like identifier fields.\n *\n * @remarks The resulting tree will be populated with any defaults from {@link FieldProvider}s in the schema.\n *\n * @privateRemarks\n * TODO: AB#9126 AB#9131\n * When an app wants schema validation, we should ensure data is validated. Doing the validation here is not robust (since many callers to this don't have a context and thus can't opt into validation).\n * Additionally the validation here does not correctly handle default values, and introduces a second schema representation which is a bit odd API wise as its typically derivable from the view schema.\n * It may make more sense to validate when hydrating the MapTreeNode when the context is known and the defaults are available.\n * Applying the \"parse don't validate\" idiom here could help ensuring we capture when the validation optionally happens in the type system to avoid missing or redundant validation,\n * as well as ensuring validation happens after defaulting (or can handle validating data missing defaults)\n */\nexport function mapTreeFromNodeData(\n\tdata: InsertableContent,\n\tallowedTypes: ImplicitAllowedTypes,\n\tcontext?: NodeKeyManager,\n\tschemaValidationPolicy?: SchemaAndPolicy,\n): ExclusiveMapTree;\nexport function mapTreeFromNodeData(\n\tdata: InsertableContent | undefined,\n\tallowedTypes: ImplicitFieldSchema,\n\tcontext?: NodeKeyManager,\n\tschemaValidationPolicy?: SchemaAndPolicy,\n): ExclusiveMapTree | undefined;\nexport function mapTreeFromNodeData(\n\tdata: InsertableContent | undefined,\n\tallowedTypes: ImplicitFieldSchema,\n\tcontext?: NodeKeyManager,\n\tschemaValidationPolicy?: SchemaAndPolicy,\n): ExclusiveMapTree | undefined {\n\tconst normalizedFieldSchema = normalizeFieldSchema(allowedTypes);\n\n\tif (data === undefined) {\n\t\t// TODO: this code-path should support defaults\n\t\tif (normalizedFieldSchema.kind !== FieldKind.Optional) {\n\t\t\tthrow new UsageError(\"Got undefined for non-optional field.\");\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst mapTree = nodeDataToMapTree(data, normalizedFieldSchema.allowedTypeSet);\n\t// Add what defaults can be provided. If no `context` is providing, some defaults may still be missing.\n\taddDefaultsToMapTree(mapTree, normalizedFieldSchema.allowedTypes, context);\n\n\t// TODO:\n\t// Since some defaults may still be missing, this can give false positives when context is undefined but schemaValidationPolicy is provided.\n\tif (schemaValidationPolicy?.policy.validateSchema === true) {\n\t\tconst maybeError = isNodeInSchema(mapTree, schemaValidationPolicy);\n\t\tinSchemaOrThrow(maybeError);\n\t}\n\n\treturn mapTree;\n}\n\n/**\n * Copy content from `data` into a MapTree.\n * Does NOT generate and default values for fields.\n * Often throws UsageErrors for invalid data, but may miss some cases.\n * @remarks\n * Output is likely out of schema even for valid input due to missing defaults.\n */\nfunction nodeDataToMapTree(\n\tdata: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): ExclusiveMapTree {\n\t// A special cache path for processing unhydrated nodes.\n\t// They already have the mapTree, so there is no need to recompute it.\n\tconst flexNode = tryGetInnerNode(data);\n\tif (flexNode !== undefined) {\n\t\tif (isMapTreeNode(flexNode)) {\n\t\t\tif (\n\t\t\t\t!allowedTypes.has(tryGetSimpleNodeSchema(flexNode.schema) ?? fail(\"missing schema\"))\n\t\t\t) {\n\t\t\t\tthrow new UsageError(\"Invalid schema for this context.\");\n\t\t\t}\n\t\t\t// TODO: mapTreeFromNodeData modifies the trees it gets to add defaults.\n\t\t\t// Using a cached value here can result in this tree having defaults applied to it more than once.\n\t\t\t// This is unnecessary and inefficient, but should be a no-op if all calls provide the same context (which they might not).\n\t\t\t// A cleaner design (avoiding this cast) might be to apply defaults eagerly if they don't need a context, and lazily (when hydrating) if they do.\n\t\t\t// This could avoid having to mutate the map tree to apply defaults, removing the need for this cast.\n\t\t\treturn flexNode.mapTree as ExclusiveMapTree;\n\t\t} else {\n\t\t\t// The node is already hydrated, meaning that it already got inserted into the tree previously\n\t\t\tthrow new UsageError(\"A node may not be inserted into the tree more than once\");\n\t\t}\n\t}\n\n\tconst schema = getType(data, allowedTypes);\n\n\tlet result: ExclusiveMapTree;\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Leaf:\n\t\t\tresult = leafToMapTree(data, schema, allowedTypes);\n\t\t\tbreak;\n\t\tcase NodeKind.Array:\n\t\t\tresult = arrayToMapTree(data, schema);\n\t\t\tbreak;\n\t\tcase NodeKind.Map:\n\t\t\tresult = mapToMapTree(data, schema);\n\t\t\tbreak;\n\t\tcase NodeKind.Object:\n\t\t\tresult = objectToMapTree(data, schema);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tfail(`Unrecognized schema kind: ${schema.kind}.`);\n\t}\n\n\treturn result;\n}\n\n/**\n * Throws a UsageError if maybeError indicates a tree is out of schema.\n */\nexport function inSchemaOrThrow(maybeError: SchemaValidationErrors): void {\n\tif (maybeError !== SchemaValidationErrors.NoError) {\n\t\tthrow new UsageError(\"Tree does not conform to schema.\");\n\t}\n}\n\n/**\n * Transforms data under a Leaf schema.\n * @param data - The tree data to be transformed. Must be a {@link TreeValue}.\n * @param schema - The schema associated with the value.\n * @param allowedTypes - The allowed types specified by the parent.\n * Used to determine which fallback values may be appropriate.\n */\nfunction leafToMapTree(\n\tdata: InsertableContent,\n\tschema: TreeNodeSchema,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): ExclusiveMapTree {\n\tassert(schema.kind === NodeKind.Leaf, 0x921 /* Expected a leaf schema. */);\n\tif (!isTreeValue(data)) {\n\t\t// This rule exists to protect against useless `toString` output like `[object Object]`.\n\t\t// In this case, that's actually reasonable behavior, since object input is not compatible with Leaf schemas.\n\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\tthrow new UsageError(`Input data is incompatible with leaf schema: ${data}`);\n\t}\n\n\tconst mappedValue = mapValueWithFallbacks(data, allowedTypes);\n\tconst mappedSchema = getType(mappedValue, allowedTypes);\n\n\tassert(\n\t\tallowsValue(mappedSchema, mappedValue),\n\t\t0x84a /* Unsupported schema for provided primitive. */,\n\t);\n\n\treturn {\n\t\tvalue: mappedValue,\n\t\ttype: brand(mappedSchema.identifier),\n\t\tfields: new Map(),\n\t};\n}\n\n/**\n * Checks an incoming {@link TreeLeafValue} to ensure it is compatible with its requirements.\n * For unsupported values with a schema-compatible replacement, return the replacement value.\n * For unsupported values without a schema-compatible replacement, throw.\n * For supported values, return the input.\n */\nfunction mapValueWithFallbacks(\n\tvalue: TreeLeafValue,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeValue {\n\tswitch (typeof value) {\n\t\tcase \"number\": {\n\t\t\tif (Object.is(value, -0)) {\n\t\t\t\t// Our serialized data format does not support -0.\n\t\t\t\t// Map such input to +0.\n\t\t\t\treturn 0;\n\t\t\t} else if (Number.isNaN(value) || !Number.isFinite(value)) {\n\t\t\t\t// Our serialized data format does not support NaN nor +/-∞.\n\t\t\t\t// If the schema supports `null`, fall back to that. Otherwise, throw.\n\t\t\t\t// This is intended to match JSON's behavior for such values.\n\t\t\t\tif (allowedTypes.has(nullSchema)) {\n\t\t\t\t\treturn null;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError(`Received unsupported numeric value: ${value}.`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\t\tcase \"string\":\n\t\t// TODO:\n\t\t// This should detect invalid strings. Something like @stdlib/regexp-utf16-unpaired-surrogate could be used to do this.\n\t\t// See SchemaFactory.string for details.\n\t\tcase \"boolean\":\n\t\t\treturn value;\n\t\tcase \"object\": {\n\t\t\tif (value === null || isFluidHandle(value)) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\t\tdefault:\n\t\t\tthrow new TypeError(`Received unsupported leaf value: ${value}.`);\n\t}\n}\n\n/**\n * Transforms data under an Array schema.\n * @param data - The tree data to be transformed.\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n */\nfunction arrayChildToMapTree(\n\tchild: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): ExclusiveMapTree {\n\t// We do not support undefined sequence entries.\n\t// If we encounter an undefined entry, use null instead if supported by the schema, otherwise throw.\n\tlet childWithFallback = child;\n\tif (child === undefined) {\n\t\tif (allowedTypes.has(nullSchema)) {\n\t\t\tchildWithFallback = null;\n\t\t} else {\n\t\t\tthrow new TypeError(`Received unsupported array entry value: ${child}.`);\n\t\t}\n\t}\n\treturn nodeDataToMapTree(childWithFallback, allowedTypes);\n}\n\n/**\n * Transforms data under an Array schema.\n * @param data - The tree data to be transformed. Must be an iterable.\n * @param schema - The schema associated with the value.\n * @param schemaValidationPolicy - The stored schema and policy to be used for validation, if the policy says schema\n * validation should happen. If it does, the input tree will be validated against this schema + policy, and an error will\n * be thrown if the tree does not conform to the schema. If undefined, no validation against the stored schema is done.\n */\nfunction arrayToMapTree(data: InsertableContent, schema: TreeNodeSchema): ExclusiveMapTree {\n\tassert(schema.kind === NodeKind.Array, 0x922 /* Expected an array schema. */);\n\tif (!(typeof data === \"object\" && data !== null && Symbol.iterator in data)) {\n\t\tthrow new UsageError(`Input data is incompatible with Array schema: ${data}`);\n\t}\n\n\tconst allowedChildTypes = normalizeAllowedTypes(schema.info as ImplicitAllowedTypes);\n\n\tconst mappedData = Array.from(data, (child) =>\n\t\tarrayChildToMapTree(child, allowedChildTypes),\n\t);\n\n\t// Array nodes have a single `EmptyKey` field:\n\tconst fieldsEntries = mappedData.length === 0 ? [] : ([[EmptyKey, mappedData]] as const);\n\n\treturn {\n\t\ttype: brand(schema.identifier),\n\t\tfields: new Map(fieldsEntries),\n\t};\n}\n\n/**\n * Transforms data under a Map schema.\n * @param data - The tree data to be transformed. Must be an iterable.\n * @param schema - The schema associated with the value.\n * @param schemaValidationPolicy - The stored schema and policy to be used for validation, if the policy says schema\n * validation should happen. If it does, the input tree will be validated against this schema + policy, and an error will\n * be thrown if the tree does not conform to the schema. If undefined, no validation against the stored schema is done.\n */\nfunction mapToMapTree(data: InsertableContent, schema: TreeNodeSchema): ExclusiveMapTree {\n\tassert(schema.kind === NodeKind.Map, 0x923 /* Expected a Map schema. */);\n\tif (!(typeof data === \"object\" && data !== null)) {\n\t\tthrow new UsageError(`Input data is incompatible with Map schema: ${data}`);\n\t}\n\n\tconst allowedChildTypes = normalizeAllowedTypes(schema.info as ImplicitAllowedTypes);\n\n\tconst fieldsIterator = (\n\t\tSymbol.iterator in data\n\t\t\t? // Support iterables of key value pairs (including Map objects)\n\t\t\t\tdata\n\t\t\t: // Support record objects for JSON style Map data\n\t\t\t\tObject.entries(data)\n\t) as Iterable<readonly [string, InsertableContent]>;\n\n\tconst transformedFields = new Map<FieldKey, ExclusiveMapTree[]>();\n\tfor (const item of fieldsIterator) {\n\t\tif (!isReadonlyArray(item) || item.length !== 2 || typeof item[0] !== \"string\") {\n\t\t\tthrow new UsageError(`Input data is incompatible with map entry: ${item}`);\n\t\t}\n\t\tconst [key, value] = item;\n\t\tassert(!transformedFields.has(brand(key)), 0x84c /* Keys should not be duplicated */);\n\n\t\t// Omit undefined values - an entry with an undefined value is equivalent to one that has been removed or omitted\n\t\tif (value !== undefined) {\n\t\t\tconst mappedField = nodeDataToMapTree(value, allowedChildTypes);\n\t\t\ttransformedFields.set(brand(key), [mappedField]);\n\t\t}\n\t}\n\n\treturn {\n\t\ttype: brand(schema.identifier),\n\t\tfields: transformedFields,\n\t};\n}\n\n/**\n * Transforms data under an Object schema.\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema associated with the value.\n */\nfunction objectToMapTree(data: InsertableContent, schema: TreeNodeSchema): ExclusiveMapTree {\n\tassert(isObjectNodeSchema(schema), 0x924 /* Expected an Object schema. */);\n\tif (typeof data !== \"object\" || data === null) {\n\t\tthrow new UsageError(`Input data is incompatible with Object schema: ${data}`);\n\t}\n\n\tconst fields = new Map<FieldKey, ExclusiveMapTree[]>();\n\n\t// Loop through field keys without data.\n\t// This does NOT apply defaults.\n\tfor (const [key, fieldInfo] of schema.flexKeyMap) {\n\t\tif (Object.hasOwnProperty.call(data, key)) {\n\t\t\tconst value = (data as Record<string, InsertableContent>)[key as string];\n\t\t\tsetFieldValue(fields, value, fieldInfo.schema, fieldInfo.storedKey);\n\t\t}\n\t}\n\n\treturn {\n\t\ttype: brand(schema.identifier),\n\t\tfields,\n\t};\n}\n\nfunction setFieldValue(\n\tfields: Map<FieldKey, readonly MapTree[]>,\n\tfieldValue: InsertableContent | undefined,\n\tfieldSchema: FieldSchema,\n\tflexKey: FieldKey,\n): void {\n\tif (fieldValue !== undefined) {\n\t\tconst mappedChildTree = nodeDataToMapTree(fieldValue, fieldSchema.allowedTypeSet);\n\n\t\tassert(!fields.has(flexKey), 0x956 /* Keys must not be duplicated */);\n\t\tfields.set(flexKey, [mappedChildTree]);\n\t}\n}\n\nfunction getType(\n\tdata: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeNodeSchema {\n\tconst possibleTypes = getPossibleTypes(allowedTypes, data as ContextuallyTypedNodeData);\n\tif (possibleTypes.length === 0) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is incompatible with all of the types allowed by the schema. The set of allowed types is: ${JSON.stringify(\n\t\t\t\t[...allowedTypes].map((schema) => schema.identifier),\n\t\t\t)}.`,\n\t\t);\n\t}\n\tassert(\n\t\tpossibleTypes.length !== 0,\n\t\t0x84e /* data is incompatible with all types allowed by the schema */,\n\t);\n\tif (possibleTypes.length !== 1) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is compatible with more than one type allowed by the schema.\nThe set of possible types is ${JSON.stringify([\n\t\t\t\t...possibleTypes.map((schema) => schema.identifier),\n\t\t\t])}.\nExplicitly construct an unhydrated node of the desired type to disambiguate.\nFor class-based schema, this can be done by replacing an expression like \"{foo: 1}\" with \"new MySchema({foo: 1})\".`,\n\t\t);\n\t}\n\treturn possibleTypes[0] ?? oob();\n}\n\n/**\n * @returns all types for which the data is schema-compatible.\n */\nexport function getPossibleTypes(\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\tdata: ContextuallyTypedNodeData,\n): TreeNodeSchema[] {\n\tlet best = CompatibilityLevel.None;\n\tconst possibleTypes: TreeNodeSchema[] = [];\n\tfor (const schema of allowedTypes) {\n\t\tconst level = shallowCompatibilityTest(schema, data);\n\t\tif (level > best) {\n\t\t\tpossibleTypes.length = 0;\n\t\t\tbest = level;\n\t\t}\n\t\tif (best === level) {\n\t\t\tpossibleTypes.push(schema);\n\t\t}\n\t}\n\treturn best === CompatibilityLevel.None ? [] : possibleTypes;\n}\n\n/**\n * Indicates a compatibility level for inferring a schema to apply to insertable data.\n * @remarks\n * Only the highest compatibility options are used.\n * This approach allows adding new possible matching at a new lower compatibility level as a non breaking change,\n * since that way they can't make a case that was compatible before ambiguous now.\n */\nenum CompatibilityLevel {\n\t/**\n\t * Not compatible. Constructor typing indicates incompatibility.\n\t */\n\tNone = 0,\n\t/**\n\t * Additional compatibility cases added in Fluid Framework 2.2.\n\t */\n\tLow = 1,\n\t/**\n\t * Compatible in Fluid Framework 2.0.\n\t */\n\tNormal = 2,\n}\n\n/**\n * Checks if data might be schema-compatible.\n *\n * @returns false if `data` is incompatible with `type` based on a cheap/shallow check.\n *\n * Note that this may return true for cases where data is incompatible, but it must not return false in cases where the data is compatible.\n */\nfunction shallowCompatibilityTest(\n\tschema: TreeNodeSchema,\n\tdata: ContextuallyTypedNodeData,\n): CompatibilityLevel {\n\tassert(\n\t\tdata !== undefined,\n\t\t0x889 /* undefined cannot be used as contextually typed data. Use ContextuallyTypedFieldData. */,\n\t);\n\n\tif (isTreeValue(data)) {\n\t\treturn allowsValue(schema, data) ? CompatibilityLevel.Normal : CompatibilityLevel.None;\n\t}\n\tif (schema.kind === NodeKind.Leaf) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\t// Typing (of schema based constructors and thus implicit node construction)\n\t// allows iterables for constructing maps and arrays.\n\t// Some users of this API may have unions of maps and arrays,\n\t// and rely on Arrays ending up as array nodes and maps as Map nodes,\n\t// despite both being iterable and thus compatible with both.\n\t// This uses a priority based system where an array would be parsed as an array when unioned with a map,\n\t// but if in a map only context, could still be used as a map.\n\n\tif (data instanceof Map) {\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Map:\n\t\t\t\treturn CompatibilityLevel.Normal;\n\t\t\tcase NodeKind.Array:\n\t\t\t\t// Maps are iterable, so type checking does allow constructing an ArrayNode from a map if the array's type is an array that includes the key and value types of the map.\n\t\t\t\treturn CompatibilityLevel.Low;\n\t\t\tdefault:\n\t\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\tif (isReadonlyArray(data)) {\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array:\n\t\t\t\treturn CompatibilityLevel.Normal;\n\t\t\tcase NodeKind.Map:\n\t\t\t\t// Arrays are iterable, so type checking does allow constructing an array from a MapNode from an if the array's type is key values pairs for the map.\n\t\t\t\treturn CompatibilityLevel.Low;\n\t\t\tdefault:\n\t\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\tconst mapOrArray = schema.kind === NodeKind.Array || schema.kind === NodeKind.Map;\n\n\tif (Symbol.iterator in data) {\n\t\treturn mapOrArray ? CompatibilityLevel.Normal : CompatibilityLevel.None;\n\t}\n\n\t// At this point, it is assumed data is a record-like object since all the other cases have been eliminated.\n\n\tif (schema.kind === NodeKind.Array) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (schema.kind === NodeKind.Map) {\n\t\t// When not unioned with an ObjectNode, allow objects to be used to create maps.\n\t\treturn CompatibilityLevel.Low;\n\t}\n\n\tassert(isObjectNodeSchema(schema), 0x9e6 /* unexpected schema kind */);\n\n\t// TODO: Improve type inference by making this logic more thorough. Handle at least:\n\t// * Types which are strict subsets of other types in the same polymorphic union\n\t// * Types which have the same keys but different types for those keys in the polymorphic union\n\t// * Types which have the same required fields but different optional fields and enough of those optional fields are populated to disambiguate\n\n\t// TODO#7441: Consider allowing data to be inserted which has keys that are extraneous/unknown to the schema (those keys are ignored)\n\n\t// If the schema has a required key which is not present in the input object, reject it.\n\tfor (const [fieldKey, fieldSchema] of schema.fields) {\n\t\tif (data[fieldKey] === undefined && fieldSchema.requiresValue) {\n\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\nfunction allowsValue(schema: TreeNodeSchema, value: TreeValue): boolean {\n\tif (schema.kind === NodeKind.Leaf) {\n\t\treturn valueSchemaAllows(schema.info as ValueSchema, value);\n\t}\n\treturn false;\n}\n\n/**\n * Content of a tree which needs external schema information to interpret.\n *\n * This format is intended for concise authoring of tree literals when the schema is statically known.\n *\n * Once schema aware APIs are implemented, they can be used to provide schema specific subsets of this type.\n */\nexport type ContextuallyTypedNodeData =\n\t| ContextuallyTypedNodeDataObject\n\t| number\n\t| string\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| readonly ContextuallyTypedNodeData[]\n\t| ReadonlyMap<string, ContextuallyTypedNodeData>\n\t| Iterable<ContextuallyTypedNodeData>\n\t| Iterable<[string, ContextuallyTypedNodeData]>;\n\n/**\n * Content of a field which needs external schema information to interpret.\n *\n * This format is intended for concise authoring of tree literals when the schema is statically known.\n *\n * Once schema aware APIs are implemented, they can be used to provide schema specific subsets of this type.\n */\nexport type ContextuallyTypedFieldData = ContextuallyTypedNodeData | undefined;\n\n/**\n * Object case of {@link ContextuallyTypedNodeData}.\n */\nexport interface ContextuallyTypedNodeDataObject {\n\t/**\n\t * Fields of this node, indexed by their field keys.\n\t *\n\t * Allow explicit undefined for compatibility with FlexTree, and type-safety on read.\n\t */\n\t// TODO: make sure explicit undefined is actually handled correctly.\n\t[key: FieldKey]: ContextuallyTypedFieldData;\n\n\t/**\n\t * Fields of this node, indexed by their field keys as strings.\n\t *\n\t * Allow unbranded field keys as a convenience for literals.\n\t */\n\t[key: string]: ContextuallyTypedFieldData;\n}\n\n/**\n * Walk the given {@link ExclusiveMapTree} and deeply provide any field defaults for fields that are missing in the tree but present in the schema.\n * @param mapTree - The tree to populate with defaults. This is borrowed: no references to it are kept by this function.\n * @param allowedTypes - Some {@link TreeNodeSchema}, at least one of which the input tree must conform to\n * @param context - An optional context for generating defaults.\n * If present, all applicable defaults will be provided.\n * If absent, only defaults produced by a {@link ConstantFieldProvider} will be provided, and defaults produced by a {@link ContextualFieldProvider} will be ignored.\n * @remarks This function mutates the input tree by deeply adding new fields to the field maps where applicable.\n */\nexport function addDefaultsToMapTree(\n\tmapTree: ExclusiveMapTree,\n\tallowedTypes: ImplicitAllowedTypes,\n\tcontext: NodeKeyManager | undefined,\n): void {\n\tconst schema =\n\t\tfind(normalizeAllowedTypes(allowedTypes), (s) => s.identifier === mapTree.type) ??\n\t\tfail(\"MapTree is incompatible with schema\");\n\n\tif (isObjectNodeSchema(schema)) {\n\t\tfor (const [_key, fieldInfo] of schema.flexKeyMap) {\n\t\t\tconst field = mapTree.fields.get(fieldInfo.storedKey);\n\t\t\tif (field !== undefined) {\n\t\t\t\tfor (const child of field) {\n\t\t\t\t\taddDefaultsToMapTree(child, fieldInfo.schema.allowedTypes, context);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst defaultProvider = fieldInfo.schema.props?.defaultProvider;\n\t\t\t\tif (defaultProvider !== undefined) {\n\t\t\t\t\tconst fieldProvider = extractFieldProvider(defaultProvider);\n\t\t\t\t\tconst data = provideDefault(fieldProvider, context);\n\t\t\t\t\tif (data !== undefined) {\n\t\t\t\t\t\tsetFieldValue(mapTree.fields, data, fieldInfo.schema, fieldInfo.storedKey);\n\t\t\t\t\t\t// call addDefaultsToMapTree on newly inserted default values\n\t\t\t\t\t\tfor (const child of mapTree.fields.get(fieldInfo.storedKey) ??\n\t\t\t\t\t\t\tfail(\"Expected field to be populated\")) {\n\t\t\t\t\t\t\taddDefaultsToMapTree(child, fieldInfo.schema.allowedTypes, context);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Array:\n\t\tcase NodeKind.Map:\n\t\t\t{\n\t\t\t\tfor (const field of mapTree.fields.values()) {\n\t\t\t\t\tfor (const child of field) {\n\t\t\t\t\t\taddDefaultsToMapTree(child, schema.info as ImplicitAllowedTypes, context);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tassert(schema.kind === NodeKind.Leaf, 0x989 /* Unrecognized schema kind */);\n\t\t\tbreak;\n\t}\n}\n\n/**\n * Provides the default value (which can be undefined, for example with optional fields), or undefined if a context is required but not provided.\n * @privateRemarks\n * It is a bit concerning that there is no way for the caller to know when undefined is returned if that is the default value, or a context was required.\n * TODO: maybe better formalize the two stage defaulting (without then with context), or rework this design we only do one stage.\n */\nfunction provideDefault(\n\tfieldProvider: FieldProvider,\n\tcontext: NodeKeyManager | undefined,\n): InsertableContent | undefined {\n\tif (context !== undefined) {\n\t\treturn fieldProvider(context);\n\t} else {\n\t\tif (isConstant(fieldProvider)) {\n\t\t\treturn fieldProvider();\n\t\t} else {\n\t\t\t// Leaving field empty despite it needing a default value since a context was required and non was provided.\n\t\t\t// Caller better handle this case by providing the default at some other point in time when the context becomes known.\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"toMapTree.js","sourceRoot":"","sources":["../../src/simple-tree/toMapTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,OAAO,EACN,QAAQ,GAOR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,WAAW,EACX,iBAAiB,EAEjB,aAAa,GACb,MAAM,+BAA+B,CAAC;AACvC,OAA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YACC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAC5E,MAAM;IACR,CAAC;AACF,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CACtB,aAA4B,EAC5B,OAAmC;IAEnC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACP,IAAI,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/B,OAAO,aAAa,EAAE,CAAC;QACxB,CAAC;aAAM,CAAC;YACP,6GAA6G;YAC7G,sHAAsH;QACvH,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,MAAe;IACvC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;IAC5C,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\tEmptyKey,\n\ttype FieldKey,\n\ttype MapTree,\n\ttype TreeValue,\n\ttype ValueSchema,\n\ttype SchemaAndPolicy,\n\ttype ExclusiveMapTree,\n} from \"../core/index.js\";\nimport {\n\tisTreeValue,\n\tvalueSchemaAllows,\n\ttype NodeKeyManager,\n\tisMapTreeNode,\n} from \"../feature-libraries/index.js\";\nimport { brand, fail, isReadonlyArray, find } from \"../util/index.js\";\n\nimport { nullSchema } from \"./leafNodeSchema.js\";\nimport {\n\ttype FieldSchema,\n\ttype ImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n\textractFieldProvider,\n\tisConstant,\n\ttype FieldProvider,\n\ttype ImplicitFieldSchema,\n\tnormalizeFieldSchema,\n\tFieldKind,\n\ttype TreeLeafValue,\n} from \"./schemaTypes.js\";\nimport {\n\tgetKernel,\n\tgetSimpleNodeSchemaFromNode,\n\tisTreeNode,\n\tNodeKind,\n\ttype InnerNode,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\ttype Unhydrated,\n} from \"./core/index.js\";\nimport { SchemaValidationErrors, isNodeInSchema } from \"../feature-libraries/index.js\";\nimport { isObjectNodeSchema } from \"./objectNodeTypes.js\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\n/**\n * Module notes:\n *\n * The flow of the below code is in terms of the structure of the input data. We then verify that the associated\n * schema is appropriate for that kind of data. This is fine while we have a 1:1 mapping of kind of input data to\n * the kind of schema we expect for it (e.g. an input that is an array always need to be associated with a sequence in\n * the schema). If/when we begin accepting kinds of input data that are ambiguous (e.g. accepting an input that is an\n * array of key/value tuples to instantiate a map) we may need to rethink the structure here to be based more on the\n * schema than on the input data.\n */\n\n/**\n * Transforms an input {@link TypedNode} tree to a {@link MapTree}.\n * @param data - The input tree to be converted.\n * If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,\n * otherwise an error will be thrown.\n *\n * Fallbacks:\n *\n * * `NaN` =\\> `null`\n *\n * * `+/-∞` =\\> `null`\n *\n * * `-0` =\\> `+0`\n *\n * For fields with a default value, the field may be omitted.\n * If `context` is not provided, defaults which require a context will be left empty which can be out of schema.\n *\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n * @param context - An optional context which, if present, will allow defaults to be created by {@link ContextualFieldProvider}s.\n * If absent, only defaults from {@link ConstantFieldProvider}s will be created.\n * @param schemaValidationPolicy - The stored schema and policy to be used for validation, if the policy says schema\n * validation should happen. If it does, the input tree will be validated against this schema + policy, and an error will\n * be thrown if the tree does not conform to the schema. If undefined, no validation against the stored schema is done.\n *\n * TODO:BUG: AB#9131\n * This schema validation is done before defaults are provided.\n * This can not easily be fixed by reordering things within this implementation since even at the end of this function defaults requiring a context may not have been filled.\n * This means schema validation reject required fields getting their value from a default like identifier fields.\n *\n * @remarks The resulting tree will be populated with any defaults from {@link FieldProvider}s in the schema.\n *\n * @privateRemarks\n * TODO: AB#9126 AB#9131\n * When an app wants schema validation, we should ensure data is validated. Doing the validation here is not robust (since many callers to this don't have a context and thus can't opt into validation).\n * Additionally the validation here does not correctly handle default values, and introduces a second schema representation which is a bit odd API wise as its typically derivable from the view schema.\n * It may make more sense to validate when hydrating the MapTreeNode when the context is known and the defaults are available.\n * Applying the \"parse don't validate\" idiom here could help ensuring we capture when the validation optionally happens in the type system to avoid missing or redundant validation,\n * as well as ensuring validation happens after defaulting (or can handle validating data missing defaults)\n */\nexport function mapTreeFromNodeData(\n\tdata: InsertableContent,\n\tallowedTypes: ImplicitAllowedTypes,\n\tcontext?: NodeKeyManager,\n\tschemaValidationPolicy?: SchemaAndPolicy,\n): ExclusiveMapTree;\nexport function mapTreeFromNodeData(\n\tdata: InsertableContent | undefined,\n\tallowedTypes: ImplicitFieldSchema,\n\tcontext?: NodeKeyManager,\n\tschemaValidationPolicy?: SchemaAndPolicy,\n): ExclusiveMapTree | undefined;\nexport function mapTreeFromNodeData(\n\tdata: InsertableContent | undefined,\n\tallowedTypes: ImplicitFieldSchema,\n\tcontext?: NodeKeyManager,\n\tschemaValidationPolicy?: SchemaAndPolicy,\n): ExclusiveMapTree | undefined {\n\tconst normalizedFieldSchema = normalizeFieldSchema(allowedTypes);\n\n\tif (data === undefined) {\n\t\t// TODO: this code-path should support defaults\n\t\tif (normalizedFieldSchema.kind !== FieldKind.Optional) {\n\t\t\tthrow new UsageError(\"Got undefined for non-optional field.\");\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst mapTree = nodeDataToMapTree(data, normalizedFieldSchema.allowedTypeSet);\n\t// Add what defaults can be provided. If no `context` is providing, some defaults may still be missing.\n\taddDefaultsToMapTree(mapTree, normalizedFieldSchema.allowedTypes, context);\n\n\tif (schemaValidationPolicy?.policy.validateSchema === true) {\n\t\t// TODO: BUG: AB#9131\n\t\t// Since some defaults may still be missing, this can give false positives when context is undefined but schemaValidationPolicy is provided.\n\t\t// For now disable this check when context is undefined:\n\t\tif (context !== undefined) {\n\t\t\tconst maybeError = isNodeInSchema(mapTree, schemaValidationPolicy);\n\t\t\tinSchemaOrThrow(maybeError);\n\t\t}\n\t}\n\n\treturn mapTree;\n}\n\n/**\n * Copy content from `data` into a MapTree.\n * Does NOT generate and default values for fields.\n * Often throws UsageErrors for invalid data, but may miss some cases.\n * @remarks\n * Output is likely out of schema even for valid input due to missing defaults.\n */\nfunction nodeDataToMapTree(\n\tdata: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): ExclusiveMapTree {\n\t// A special cache path for processing unhydrated nodes.\n\t// They already have the mapTree, so there is no need to recompute it.\n\tconst innerNode = tryGetInnerNode(data);\n\tif (innerNode !== undefined) {\n\t\tif (isMapTreeNode(innerNode)) {\n\t\t\tif (!allowedTypes.has(getSimpleNodeSchemaFromNode(innerNode))) {\n\t\t\t\tthrow new UsageError(\"Invalid schema for this context.\");\n\t\t\t}\n\t\t\t// TODO: mapTreeFromNodeData modifies the trees it gets to add defaults.\n\t\t\t// Using a cached value here can result in this tree having defaults applied to it more than once.\n\t\t\t// This is unnecessary and inefficient, but should be a no-op if all calls provide the same context (which they might not).\n\t\t\t// A cleaner design (avoiding this cast) might be to apply defaults eagerly if they don't need a context, and lazily (when hydrating) if they do.\n\t\t\t// This could avoid having to mutate the map tree to apply defaults, removing the need for this cast.\n\t\t\treturn innerNode.mapTree as ExclusiveMapTree;\n\t\t} else {\n\t\t\t// The node is already hydrated, meaning that it already got inserted into the tree previously\n\t\t\tthrow new UsageError(\"A node may not be inserted into the tree more than once\");\n\t\t}\n\t}\n\n\tassert(!isTreeNode(data), 0xa23 /* data without an inner node cannot be TreeNode */);\n\n\tconst schema = getType(data, allowedTypes);\n\n\tlet result: ExclusiveMapTree;\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Leaf:\n\t\t\tresult = leafToMapTree(data, schema, allowedTypes);\n\t\t\tbreak;\n\t\tcase NodeKind.Array:\n\t\t\tresult = arrayToMapTree(data, schema);\n\t\t\tbreak;\n\t\tcase NodeKind.Map:\n\t\t\tresult = mapToMapTree(data, schema);\n\t\t\tbreak;\n\t\tcase NodeKind.Object:\n\t\t\tresult = objectToMapTree(data, schema);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tfail(`Unrecognized schema kind: ${schema.kind}.`);\n\t}\n\n\treturn result;\n}\n\n/**\n * Throws a UsageError if maybeError indicates a tree is out of schema.\n */\nexport function inSchemaOrThrow(maybeError: SchemaValidationErrors): void {\n\tif (maybeError !== SchemaValidationErrors.NoError) {\n\t\tthrow new UsageError(\"Tree does not conform to schema.\");\n\t}\n}\n\n/**\n * Transforms data under a Leaf schema.\n * @param data - The tree data to be transformed. Must be a {@link TreeValue}.\n * @param schema - The schema associated with the value.\n * @param allowedTypes - The allowed types specified by the parent.\n * Used to determine which fallback values may be appropriate.\n */\nfunction leafToMapTree(\n\tdata: FactoryContent,\n\tschema: TreeNodeSchema,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): ExclusiveMapTree {\n\tassert(schema.kind === NodeKind.Leaf, 0x921 /* Expected a leaf schema. */);\n\tif (!isTreeValue(data)) {\n\t\t// This rule exists to protect against useless `toString` output like `[object Object]`.\n\t\t// In this case, that's actually reasonable behavior, since object input is not compatible with Leaf schemas.\n\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\tthrow new UsageError(`Input data is incompatible with leaf schema: ${data}`);\n\t}\n\n\tconst mappedValue = mapValueWithFallbacks(data, allowedTypes);\n\tconst mappedSchema = getType(mappedValue, allowedTypes);\n\n\tassert(\n\t\tallowsValue(mappedSchema, mappedValue),\n\t\t0x84a /* Unsupported schema for provided primitive. */,\n\t);\n\n\treturn {\n\t\tvalue: mappedValue,\n\t\ttype: brand(mappedSchema.identifier),\n\t\tfields: new Map(),\n\t};\n}\n\n/**\n * Checks an incoming {@link TreeLeafValue} to ensure it is compatible with its requirements.\n * For unsupported values with a schema-compatible replacement, return the replacement value.\n * For unsupported values without a schema-compatible replacement, throw.\n * For supported values, return the input.\n */\nfunction mapValueWithFallbacks(\n\tvalue: TreeLeafValue,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeValue {\n\tswitch (typeof value) {\n\t\tcase \"number\": {\n\t\t\tif (Object.is(value, -0)) {\n\t\t\t\t// Our serialized data format does not support -0.\n\t\t\t\t// Map such input to +0.\n\t\t\t\treturn 0;\n\t\t\t} else if (Number.isNaN(value) || !Number.isFinite(value)) {\n\t\t\t\t// Our serialized data format does not support NaN nor +/-∞.\n\t\t\t\t// If the schema supports `null`, fall back to that. Otherwise, throw.\n\t\t\t\t// This is intended to match JSON's behavior for such values.\n\t\t\t\tif (allowedTypes.has(nullSchema)) {\n\t\t\t\t\treturn null;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError(`Received unsupported numeric value: ${value}.`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\t\tcase \"string\":\n\t\t// TODO:\n\t\t// This should detect invalid strings. Something like @stdlib/regexp-utf16-unpaired-surrogate could be used to do this.\n\t\t// See SchemaFactory.string for details.\n\t\tcase \"boolean\":\n\t\t\treturn value;\n\t\tcase \"object\": {\n\t\t\tif (value === null || isFluidHandle(value)) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\t\tdefault:\n\t\t\tthrow new TypeError(`Received unsupported leaf value: ${value}.`);\n\t}\n}\n\n/**\n * Transforms data under an Array schema.\n * @param data - The tree data to be transformed.\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n */\nfunction arrayChildToMapTree(\n\tchild: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): ExclusiveMapTree {\n\t// We do not support undefined sequence entries.\n\t// If we encounter an undefined entry, use null instead if supported by the schema, otherwise throw.\n\tlet childWithFallback = child;\n\tif (child === undefined) {\n\t\tif (allowedTypes.has(nullSchema)) {\n\t\t\tchildWithFallback = null;\n\t\t} else {\n\t\t\tthrow new TypeError(`Received unsupported array entry value: ${child}.`);\n\t\t}\n\t}\n\treturn nodeDataToMapTree(childWithFallback, allowedTypes);\n}\n\n/**\n * Transforms data under an Array schema.\n * @param data - The tree data to be transformed. Must be an iterable.\n * @param schema - The schema associated with the value.\n * @param schemaValidationPolicy - The stored schema and policy to be used for validation, if the policy says schema\n * validation should happen. If it does, the input tree will be validated against this schema + policy, and an error will\n * be thrown if the tree does not conform to the schema. If undefined, no validation against the stored schema is done.\n */\nfunction arrayToMapTree(data: FactoryContent, schema: TreeNodeSchema): ExclusiveMapTree {\n\tassert(schema.kind === NodeKind.Array, 0x922 /* Expected an array schema. */);\n\tif (!(typeof data === \"object\" && data !== null && Symbol.iterator in data)) {\n\t\tthrow new UsageError(`Input data is incompatible with Array schema: ${data}`);\n\t}\n\n\tconst allowedChildTypes = normalizeAllowedTypes(schema.info as ImplicitAllowedTypes);\n\n\tconst mappedData = Array.from(data, (child) =>\n\t\tarrayChildToMapTree(child, allowedChildTypes),\n\t);\n\n\t// Array nodes have a single `EmptyKey` field:\n\tconst fieldsEntries = mappedData.length === 0 ? [] : ([[EmptyKey, mappedData]] as const);\n\n\treturn {\n\t\ttype: brand(schema.identifier),\n\t\tfields: new Map(fieldsEntries),\n\t};\n}\n\n/**\n * Transforms data under a Map schema.\n * @param data - The tree data to be transformed. Must be an iterable.\n * @param schema - The schema associated with the value.\n * @param schemaValidationPolicy - The stored schema and policy to be used for validation, if the policy says schema\n * validation should happen. If it does, the input tree will be validated against this schema + policy, and an error will\n * be thrown if the tree does not conform to the schema. If undefined, no validation against the stored schema is done.\n */\nfunction mapToMapTree(data: FactoryContent, schema: TreeNodeSchema): ExclusiveMapTree {\n\tassert(schema.kind === NodeKind.Map, 0x923 /* Expected a Map schema. */);\n\tif (!(typeof data === \"object\" && data !== null)) {\n\t\tthrow new UsageError(`Input data is incompatible with Map schema: ${data}`);\n\t}\n\n\tconst allowedChildTypes = normalizeAllowedTypes(schema.info as ImplicitAllowedTypes);\n\n\tconst fieldsIterator = (\n\t\tSymbol.iterator in data\n\t\t\t? // Support iterables of key value pairs (including Map objects)\n\t\t\t\tdata\n\t\t\t: // Support record objects for JSON style Map data\n\t\t\t\tObject.entries(data)\n\t) as Iterable<readonly [string, InsertableContent]>;\n\n\tconst transformedFields = new Map<FieldKey, ExclusiveMapTree[]>();\n\tfor (const item of fieldsIterator) {\n\t\tif (!isReadonlyArray(item) || item.length !== 2 || typeof item[0] !== \"string\") {\n\t\t\tthrow new UsageError(`Input data is incompatible with map entry: ${item}`);\n\t\t}\n\t\tconst [key, value] = item;\n\t\tassert(!transformedFields.has(brand(key)), 0x84c /* Keys should not be duplicated */);\n\n\t\t// Omit undefined values - an entry with an undefined value is equivalent to one that has been removed or omitted\n\t\tif (value !== undefined) {\n\t\t\tconst mappedField = nodeDataToMapTree(value, allowedChildTypes);\n\t\t\ttransformedFields.set(brand(key), [mappedField]);\n\t\t}\n\t}\n\n\treturn {\n\t\ttype: brand(schema.identifier),\n\t\tfields: transformedFields,\n\t};\n}\n\n/**\n * Transforms data under an Object schema.\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema associated with the value.\n */\nfunction objectToMapTree(data: FactoryContent, schema: TreeNodeSchema): ExclusiveMapTree {\n\tassert(isObjectNodeSchema(schema), 0x924 /* Expected an Object schema. */);\n\tif (\n\t\ttypeof data !== \"object\" ||\n\t\tdata === null ||\n\t\tSymbol.iterator in data ||\n\t\tisFluidHandle(data)\n\t) {\n\t\tthrow new UsageError(`Input data is incompatible with Object schema: ${data}`);\n\t}\n\n\tconst fields = new Map<FieldKey, ExclusiveMapTree[]>();\n\n\t// Loop through field keys without data.\n\t// This does NOT apply defaults.\n\tfor (const [key, fieldInfo] of schema.flexKeyMap) {\n\t\tif (checkFieldProperty(data, key)) {\n\t\t\tconst value = (data as Record<string, InsertableContent>)[key as string];\n\t\t\tsetFieldValue(fields, value, fieldInfo.schema, fieldInfo.storedKey);\n\t\t}\n\t}\n\n\treturn {\n\t\ttype: brand(schema.identifier),\n\t\tfields,\n\t};\n}\n\n/**\n * Check {@link FactoryContentObject} for a property which could be store a field.\n * @remarks\n * The currently policy is to only consider own properties.\n * See {@link InsertableObjectFromSchemaRecord} for where this policy is documented in the public API.\n *\n * Explicit undefined members are considered to exist, as long as they are own properties.\n */\nfunction checkFieldProperty(\n\tdata: FactoryContentObject,\n\tkey: string | symbol,\n): data is {\n\treadonly [P in string]: InsertableContent | undefined;\n} {\n\t// This policy only allows own properties.\n\treturn Object.hasOwnProperty.call(data, key);\n}\n\nfunction setFieldValue(\n\tfields: Map<FieldKey, readonly MapTree[]>,\n\tfieldValue: InsertableContent | undefined,\n\tfieldSchema: FieldSchema,\n\tflexKey: FieldKey,\n): void {\n\tif (fieldValue !== undefined) {\n\t\tconst mappedChildTree = nodeDataToMapTree(fieldValue, fieldSchema.allowedTypeSet);\n\n\t\tassert(!fields.has(flexKey), 0x956 /* Keys must not be duplicated */);\n\t\tfields.set(flexKey, [mappedChildTree]);\n\t}\n}\n\nfunction getType(\n\tdata: FactoryContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeNodeSchema {\n\tconst possibleTypes = getPossibleTypes(allowedTypes, data);\n\tif (possibleTypes.length === 0) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is incompatible with all of the types allowed by the schema. The set of allowed types is: ${JSON.stringify(\n\t\t\t\t[...allowedTypes].map((schema) => schema.identifier),\n\t\t\t)}.`,\n\t\t);\n\t}\n\tassert(\n\t\tpossibleTypes.length !== 0,\n\t\t0x84e /* data is incompatible with all types allowed by the schema */,\n\t);\n\tif (possibleTypes.length !== 1) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is compatible with more than one type allowed by the schema.\nThe set of possible types is ${JSON.stringify([\n\t\t\t\t...possibleTypes.map((schema) => schema.identifier),\n\t\t\t])}.\nExplicitly construct an unhydrated node of the desired type to disambiguate.\nFor class-based schema, this can be done by replacing an expression like \"{foo: 1}\" with \"new MySchema({foo: 1})\".`,\n\t\t);\n\t}\n\treturn possibleTypes[0] ?? oob();\n}\n\n/**\n * @returns all types for which the data is schema-compatible.\n */\nexport function getPossibleTypes(\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\tdata: FactoryContent,\n): TreeNodeSchema[] {\n\tlet best = CompatibilityLevel.None;\n\tconst possibleTypes: TreeNodeSchema[] = [];\n\tfor (const schema of allowedTypes) {\n\t\tconst level = shallowCompatibilityTest(schema, data);\n\t\tif (level > best) {\n\t\t\tpossibleTypes.length = 0;\n\t\t\tbest = level;\n\t\t}\n\t\tif (best === level) {\n\t\t\tpossibleTypes.push(schema);\n\t\t}\n\t}\n\treturn best === CompatibilityLevel.None ? [] : possibleTypes;\n}\n\n/**\n * Indicates a compatibility level for inferring a schema to apply to insertable data.\n * @remarks\n * Only the highest compatibility options are used.\n * This approach allows adding new possible matching at a new lower compatibility level as a non breaking change,\n * since that way they can't make a case that was compatible before ambiguous now.\n */\nenum CompatibilityLevel {\n\t/**\n\t * Not compatible. Constructor typing indicates incompatibility.\n\t */\n\tNone = 0,\n\t/**\n\t * Additional compatibility cases added in Fluid Framework 2.2.\n\t */\n\tLow = 1,\n\t/**\n\t * Compatible in Fluid Framework 2.0.\n\t */\n\tNormal = 2,\n}\n\n/**\n * Checks if data might be schema-compatible.\n *\n * @returns false if `data` is incompatible with `type` based on a cheap/shallow check.\n *\n * Note that this may return true for cases where data is incompatible, but it must not return false in cases where the data is compatible.\n */\nfunction shallowCompatibilityTest(\n\tschema: TreeNodeSchema,\n\tdata: FactoryContent,\n): CompatibilityLevel {\n\tassert(data !== undefined, 0x889 /* undefined cannot be used as FactoryContent. */);\n\n\tif (isTreeValue(data)) {\n\t\treturn allowsValue(schema, data) ? CompatibilityLevel.Normal : CompatibilityLevel.None;\n\t}\n\tif (schema.kind === NodeKind.Leaf) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\t// Typing (of schema based constructors and thus implicit node construction)\n\t// allows iterables for constructing maps and arrays.\n\t// Some users of this API may have unions of maps and arrays,\n\t// and rely on Arrays ending up as array nodes and maps as Map nodes,\n\t// despite both being iterable and thus compatible with both.\n\t// This uses a priority based system where an array would be parsed as an array when unioned with a map,\n\t// but if in a map only context, could still be used as a map.\n\n\tif (data instanceof Map) {\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Map:\n\t\t\t\treturn CompatibilityLevel.Normal;\n\t\t\tcase NodeKind.Array:\n\t\t\t\t// Maps are iterable, so type checking does allow constructing an ArrayNode from a map if the array's type is an array that includes the key and value types of the map.\n\t\t\t\treturn CompatibilityLevel.Low;\n\t\t\tdefault:\n\t\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\tif (isReadonlyArray(data)) {\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array:\n\t\t\t\treturn CompatibilityLevel.Normal;\n\t\t\tcase NodeKind.Map:\n\t\t\t\t// Arrays are iterable, so type checking does allow constructing an array from a MapNode from an if the array's type is key values pairs for the map.\n\t\t\t\treturn CompatibilityLevel.Low;\n\t\t\tdefault:\n\t\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\tconst mapOrArray = schema.kind === NodeKind.Array || schema.kind === NodeKind.Map;\n\n\tif (Symbol.iterator in data) {\n\t\treturn mapOrArray ? CompatibilityLevel.Normal : CompatibilityLevel.None;\n\t}\n\n\t// At this point, it is assumed data is a record-like object since all the other cases have been eliminated.\n\n\tif (schema.kind === NodeKind.Array) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (schema.kind === NodeKind.Map) {\n\t\t// When not unioned with an ObjectNode, allow objects to be used to create maps.\n\t\treturn CompatibilityLevel.Low;\n\t}\n\n\tassert(isObjectNodeSchema(schema), 0x9e6 /* unexpected schema kind */);\n\n\t// TODO: Improve type inference by making this logic more thorough. Handle at least:\n\t// * Types which are strict subsets of other types in the same polymorphic union\n\t// * Types which have the same keys but different types for those keys in the polymorphic union\n\t// * Types which have the same required fields but different optional fields and enough of those optional fields are populated to disambiguate\n\n\t// TODO#7441: Consider allowing data to be inserted which has keys that are extraneous/unknown to the schema (those keys are ignored)\n\n\t// If the schema has a required key which is not present in the input object, reject it.\n\tfor (const [fieldKey, fieldSchema] of schema.fields) {\n\t\tif (fieldSchema.requiresValue) {\n\t\t\tif (checkFieldProperty(data, fieldKey)) {\n\t\t\t\tif (data[fieldKey] === undefined) {\n\t\t\t\t\treturn CompatibilityLevel.None;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn CompatibilityLevel.None;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\nfunction allowsValue(schema: TreeNodeSchema, value: TreeValue): boolean {\n\tif (schema.kind === NodeKind.Leaf) {\n\t\treturn valueSchemaAllows(schema.info as ValueSchema, value);\n\t}\n\treturn false;\n}\n\n/**\n * Walk the given {@link ExclusiveMapTree} and deeply provide any field defaults for fields that are missing in the tree but present in the schema.\n * @param mapTree - The tree to populate with defaults. This is borrowed: no references to it are kept by this function.\n * @param allowedTypes - Some {@link TreeNodeSchema}, at least one of which the input tree must conform to\n * @param context - An optional context for generating defaults.\n * If present, all applicable defaults will be provided.\n * If absent, only defaults produced by a {@link ConstantFieldProvider} will be provided, and defaults produced by a {@link ContextualFieldProvider} will be ignored.\n * @remarks This function mutates the input tree by deeply adding new fields to the field maps where applicable.\n */\nexport function addDefaultsToMapTree(\n\tmapTree: ExclusiveMapTree,\n\tallowedTypes: ImplicitAllowedTypes,\n\tcontext: NodeKeyManager | undefined,\n): void {\n\tconst schema =\n\t\tfind(normalizeAllowedTypes(allowedTypes), (s) => s.identifier === mapTree.type) ??\n\t\tfail(\"MapTree is incompatible with schema\");\n\n\tif (isObjectNodeSchema(schema)) {\n\t\tfor (const [_key, fieldInfo] of schema.flexKeyMap) {\n\t\t\tconst field = mapTree.fields.get(fieldInfo.storedKey);\n\t\t\tif (field !== undefined) {\n\t\t\t\tfor (const child of field) {\n\t\t\t\t\taddDefaultsToMapTree(child, fieldInfo.schema.allowedTypes, context);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst defaultProvider = fieldInfo.schema.props?.defaultProvider;\n\t\t\t\tif (defaultProvider !== undefined) {\n\t\t\t\t\tconst fieldProvider = extractFieldProvider(defaultProvider);\n\t\t\t\t\tconst data = provideDefault(fieldProvider, context);\n\t\t\t\t\tif (data !== undefined) {\n\t\t\t\t\t\tsetFieldValue(mapTree.fields, data, fieldInfo.schema, fieldInfo.storedKey);\n\t\t\t\t\t\t// call addDefaultsToMapTree on newly inserted default values\n\t\t\t\t\t\tfor (const child of mapTree.fields.get(fieldInfo.storedKey) ??\n\t\t\t\t\t\t\tfail(\"Expected field to be populated\")) {\n\t\t\t\t\t\t\taddDefaultsToMapTree(child, fieldInfo.schema.allowedTypes, context);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Array:\n\t\tcase NodeKind.Map:\n\t\t\t{\n\t\t\t\tfor (const field of mapTree.fields.values()) {\n\t\t\t\t\tfor (const child of field) {\n\t\t\t\t\t\taddDefaultsToMapTree(child, schema.info as ImplicitAllowedTypes, context);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tassert(schema.kind === NodeKind.Leaf, 0x989 /* Unrecognized schema kind */);\n\t\t\tbreak;\n\t}\n}\n\n/**\n * Provides the default value (which can be undefined, for example with optional fields), or undefined if a context is required but not provided.\n * @privateRemarks\n * It is a bit concerning that there is no way for the caller to know when undefined is returned if that is the default value, or a context was required.\n * TODO: maybe better formalize the two stage defaulting (without then with context), or rework this design we only do one stage.\n */\nfunction provideDefault(\n\tfieldProvider: FieldProvider,\n\tcontext: NodeKeyManager | undefined,\n): InsertableContent | undefined {\n\tif (context !== undefined) {\n\t\treturn fieldProvider(context);\n\t} else {\n\t\tif (isConstant(fieldProvider)) {\n\t\t\treturn fieldProvider();\n\t\t} else {\n\t\t\t// Leaving field empty despite it needing a default value since a context was required and none was provided.\n\t\t\t// Caller better handle this case by providing the default at some other point in time when the context becomes known.\n\t\t}\n\t}\n}\n\n/**\n * Retrieves the InnerNode associated with the given target via {@link setInnerNode}, if any.\n * @remarks\n * If `target` is a unhydrated node, returns its MapTreeNode.\n * If `target` is a cooked node (or marinated but a FlexTreeNode exists) returns the FlexTreeNode.\n * If the target is not a node, or a marinated node with no FlexTreeNode for its anchor, returns undefined.\n */\nfunction tryGetInnerNode(target: unknown): InnerNode | undefined {\n\tif (isTreeNode(target)) {\n\t\treturn getKernel(target).tryGetInnerNode();\n\t}\n}\n\n/**\n * Content which can be used to build a node.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n */\nexport type FactoryContent =\n\t| IFluidHandle\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| Iterable<readonly [string, InsertableContent]>\n\t| readonly InsertableContent[]\n\t| FactoryContentObject;\n\n/**\n * Record-like object which can be used to build some kinds of nodes.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n *\n * Supports object and map nodes.\n */\ntype FactoryContentObject = {\n\treadonly [P in string]?: InsertableContent;\n};\n\n/**\n * Content which can be inserted into a tree.\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeValid.d.ts","sourceRoot":"","sources":["../../src/simple-tree/treeNodeValid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,cAAc,EAOnB,QAAQ,EACR,KAAK,gBAAgB,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,KAA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