@fluidframework/tree 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (465) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/api-report/tree.alpha.api.md +47 -16
  3. package/api-report/tree.beta.api.md +5 -14
  4. package/api-report/tree.legacy.alpha.api.md +5 -14
  5. package/api-report/tree.legacy.public.api.md +5 -14
  6. package/api-report/tree.public.api.md +5 -14
  7. package/dist/alpha.d.ts +9 -0
  8. package/dist/core/forest/forest.d.ts +10 -2
  9. package/dist/core/forest/forest.d.ts.map +1 -1
  10. package/dist/core/forest/forest.js.map +1 -1
  11. package/dist/core/index.d.ts +2 -2
  12. package/dist/core/index.d.ts.map +1 -1
  13. package/dist/core/index.js +3 -2
  14. package/dist/core/index.js.map +1 -1
  15. package/dist/core/rebase/utils.d.ts +1 -1
  16. package/dist/core/rebase/utils.d.ts.map +1 -1
  17. package/dist/core/rebase/utils.js +11 -8
  18. package/dist/core/rebase/utils.js.map +1 -1
  19. package/dist/core/revertible.d.ts +30 -1
  20. package/dist/core/revertible.d.ts.map +1 -1
  21. package/dist/core/revertible.js.map +1 -1
  22. package/dist/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  23. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  24. package/dist/core/schema-stored/storedSchemaRepository.js +5 -5
  25. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  26. package/dist/core/tree/anchorSet.d.ts +2 -2
  27. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  28. package/dist/core/tree/anchorSet.js +21 -21
  29. package/dist/core/tree/anchorSet.js.map +1 -1
  30. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  31. package/dist/core/tree/detachedFieldIndexCodec.js +3 -2
  32. package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
  33. package/dist/core/tree/index.d.ts +1 -1
  34. package/dist/core/tree/index.d.ts.map +1 -1
  35. package/dist/core/tree/index.js +2 -1
  36. package/dist/core/tree/index.js.map +1 -1
  37. package/dist/core/tree/visitorUtils.d.ts +25 -1
  38. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  39. package/dist/core/tree/visitorUtils.js +29 -1
  40. package/dist/core/tree/visitorUtils.js.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +5 -2
  42. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/chunkedForest.js +24 -14
  44. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/uniformChunk.js +2 -2
  47. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  48. package/dist/feature-libraries/flex-tree/context.d.ts +1 -1
  49. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  50. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  51. package/dist/feature-libraries/index.d.ts +1 -0
  52. package/dist/feature-libraries/index.d.ts.map +1 -1
  53. package/dist/feature-libraries/index.js +4 -1
  54. package/dist/feature-libraries/index.js.map +1 -1
  55. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +132 -0
  56. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
  57. package/dist/feature-libraries/indexing/anchorTreeIndex.js +361 -0
  58. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
  59. package/dist/feature-libraries/indexing/index.d.ts +7 -0
  60. package/dist/feature-libraries/indexing/index.d.ts.map +1 -0
  61. package/dist/feature-libraries/indexing/index.js +11 -0
  62. package/dist/feature-libraries/indexing/index.js.map +1 -0
  63. package/dist/feature-libraries/indexing/types.d.ts +32 -0
  64. package/dist/feature-libraries/indexing/types.d.ts.map +1 -0
  65. package/dist/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
  66. package/dist/feature-libraries/indexing/types.js.map +1 -0
  67. package/dist/feature-libraries/object-forest/objectForest.d.ts +5 -2
  68. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  69. package/dist/feature-libraries/object-forest/objectForest.js +21 -11
  70. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  71. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  72. package/dist/feature-libraries/sequence-field/invert.js +2 -2
  73. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  74. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +3 -2
  75. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  76. package/dist/index.d.ts +4 -4
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +4 -1
  79. package/dist/index.js.map +1 -1
  80. package/dist/packageVersion.d.ts +1 -1
  81. package/dist/packageVersion.js +1 -1
  82. package/dist/packageVersion.js.map +1 -1
  83. package/dist/shared-tree/index.d.ts +1 -1
  84. package/dist/shared-tree/index.d.ts.map +1 -1
  85. package/dist/shared-tree/index.js +1 -2
  86. package/dist/shared-tree/index.js.map +1 -1
  87. package/dist/shared-tree/schematizingTreeView.d.ts +7 -1
  88. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  89. package/dist/shared-tree/schematizingTreeView.js +31 -30
  90. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  91. package/dist/shared-tree/sharedTree.d.ts +3 -0
  92. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  93. package/dist/shared-tree/sharedTree.js +56 -20
  94. package/dist/shared-tree/sharedTree.js.map +1 -1
  95. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  96. package/dist/shared-tree/sharedTreeChangeFamily.js +3 -3
  97. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  98. package/dist/shared-tree/treeCheckout.d.ts +28 -64
  99. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  100. package/dist/shared-tree/treeCheckout.js +152 -129
  101. package/dist/shared-tree/treeCheckout.js.map +1 -1
  102. package/dist/shared-tree-core/branch.d.ts +25 -81
  103. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  104. package/dist/shared-tree-core/branch.js +72 -151
  105. package/dist/shared-tree-core/branch.js.map +1 -1
  106. package/dist/shared-tree-core/branchCommitEnricher.d.ts +19 -33
  107. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  108. package/dist/shared-tree-core/branchCommitEnricher.js +73 -54
  109. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  110. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  111. package/dist/shared-tree-core/defaultResubmitMachine.js +2 -1
  112. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  113. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  114. package/dist/shared-tree-core/editManager.js +2 -2
  115. package/dist/shared-tree-core/editManager.js.map +1 -1
  116. package/dist/shared-tree-core/index.d.ts +1 -1
  117. package/dist/shared-tree-core/index.d.ts.map +1 -1
  118. package/dist/shared-tree-core/index.js +4 -3
  119. package/dist/shared-tree-core/index.js.map +1 -1
  120. package/dist/shared-tree-core/sharedTreeCore.d.ts +2 -2
  121. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  122. package/dist/shared-tree-core/sharedTreeCore.js +11 -52
  123. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  124. package/dist/shared-tree-core/transaction.d.ts +108 -0
  125. package/dist/shared-tree-core/transaction.d.ts.map +1 -0
  126. package/dist/shared-tree-core/transaction.js +99 -0
  127. package/dist/shared-tree-core/transaction.js.map +1 -0
  128. package/dist/shared-tree-core/transactionEnricher.d.ts +8 -13
  129. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  130. package/dist/shared-tree-core/transactionEnricher.js +41 -21
  131. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  132. package/dist/simple-tree/api/identifierIndex.d.ts +21 -0
  133. package/dist/simple-tree/api/identifierIndex.d.ts.map +1 -0
  134. package/dist/simple-tree/api/identifierIndex.js +45 -0
  135. package/dist/simple-tree/api/identifierIndex.js.map +1 -0
  136. package/dist/simple-tree/api/index.d.ts +2 -0
  137. package/dist/simple-tree/api/index.d.ts.map +1 -1
  138. package/dist/simple-tree/api/index.js +5 -1
  139. package/dist/simple-tree/api/index.js.map +1 -1
  140. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +9 -7
  141. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  142. package/dist/simple-tree/api/simpleTreeIndex.d.ts +65 -0
  143. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
  144. package/dist/simple-tree/api/simpleTreeIndex.js +91 -0
  145. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -0
  146. package/dist/simple-tree/api/tree.d.ts +4 -5
  147. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  148. package/dist/simple-tree/api/tree.js.map +1 -1
  149. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  150. package/dist/simple-tree/core/index.d.ts +1 -1
  151. package/dist/simple-tree/core/index.d.ts.map +1 -1
  152. package/dist/simple-tree/core/index.js +2 -1
  153. package/dist/simple-tree/core/index.js.map +1 -1
  154. package/dist/simple-tree/core/treeNodeKernel.d.ts +6 -2
  155. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  156. package/dist/simple-tree/core/treeNodeKernel.js +53 -22
  157. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  158. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  159. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  160. package/dist/simple-tree/core/unhydratedFlexTree.js +2 -2
  161. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  162. package/dist/simple-tree/index.d.ts +1 -1
  163. package/dist/simple-tree/index.d.ts.map +1 -1
  164. package/dist/simple-tree/index.js +4 -2
  165. package/dist/simple-tree/index.js.map +1 -1
  166. package/dist/simple-tree/objectNode.d.ts +7 -2
  167. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  168. package/dist/simple-tree/objectNode.js.map +1 -1
  169. package/dist/simple-tree/toMapTree.js +3 -3
  170. package/dist/simple-tree/toMapTree.js.map +1 -1
  171. package/dist/util/index.d.ts +1 -2
  172. package/dist/util/index.d.ts.map +1 -1
  173. package/dist/util/index.js +5 -4
  174. package/dist/util/index.js.map +1 -1
  175. package/dist/util/typeCheck.d.ts +6 -1
  176. package/dist/util/typeCheck.d.ts.map +1 -1
  177. package/dist/util/typeCheck.js.map +1 -1
  178. package/dist/util/typeCheckTests.d.ts +14 -2
  179. package/dist/util/typeCheckTests.d.ts.map +1 -1
  180. package/dist/util/typeCheckTests.js.map +1 -1
  181. package/dist/util/utils.d.ts +29 -0
  182. package/dist/util/utils.d.ts.map +1 -1
  183. package/dist/util/utils.js +13 -1
  184. package/dist/util/utils.js.map +1 -1
  185. package/lib/alpha.d.ts +9 -0
  186. package/lib/core/forest/forest.d.ts +10 -2
  187. package/lib/core/forest/forest.d.ts.map +1 -1
  188. package/lib/core/forest/forest.js.map +1 -1
  189. package/lib/core/index.d.ts +2 -2
  190. package/lib/core/index.d.ts.map +1 -1
  191. package/lib/core/index.js +2 -2
  192. package/lib/core/index.js.map +1 -1
  193. package/lib/core/rebase/utils.d.ts +1 -1
  194. package/lib/core/rebase/utils.d.ts.map +1 -1
  195. package/lib/core/rebase/utils.js +11 -8
  196. package/lib/core/rebase/utils.js.map +1 -1
  197. package/lib/core/revertible.d.ts +30 -1
  198. package/lib/core/revertible.d.ts.map +1 -1
  199. package/lib/core/revertible.js.map +1 -1
  200. package/lib/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  201. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  202. package/lib/core/schema-stored/storedSchemaRepository.js +1 -1
  203. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  204. package/lib/core/tree/anchorSet.d.ts +2 -2
  205. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  206. package/lib/core/tree/anchorSet.js +1 -1
  207. package/lib/core/tree/anchorSet.js.map +1 -1
  208. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  209. package/lib/core/tree/detachedFieldIndexCodec.js +4 -3
  210. package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
  211. package/lib/core/tree/index.d.ts +1 -1
  212. package/lib/core/tree/index.d.ts.map +1 -1
  213. package/lib/core/tree/index.js +1 -1
  214. package/lib/core/tree/index.js.map +1 -1
  215. package/lib/core/tree/visitorUtils.d.ts +25 -1
  216. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  217. package/lib/core/tree/visitorUtils.js +27 -0
  218. package/lib/core/tree/visitorUtils.js.map +1 -1
  219. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +5 -2
  220. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  221. package/lib/feature-libraries/chunked-forest/chunkedForest.js +18 -8
  222. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  223. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  224. package/lib/feature-libraries/chunked-forest/uniformChunk.js +3 -3
  225. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  226. package/lib/feature-libraries/flex-tree/context.d.ts +1 -1
  227. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  228. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  229. package/lib/feature-libraries/index.d.ts +1 -0
  230. package/lib/feature-libraries/index.d.ts.map +1 -1
  231. package/lib/feature-libraries/index.js +1 -0
  232. package/lib/feature-libraries/index.js.map +1 -1
  233. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +132 -0
  234. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
  235. package/lib/feature-libraries/indexing/anchorTreeIndex.js +356 -0
  236. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
  237. package/lib/feature-libraries/indexing/index.d.ts +7 -0
  238. package/lib/feature-libraries/indexing/index.d.ts.map +1 -0
  239. package/lib/{events → feature-libraries/indexing}/index.js +1 -1
  240. package/lib/feature-libraries/indexing/index.js.map +1 -0
  241. package/lib/feature-libraries/indexing/types.d.ts +32 -0
  242. package/lib/feature-libraries/indexing/types.d.ts.map +1 -0
  243. package/lib/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
  244. package/lib/feature-libraries/indexing/types.js.map +1 -0
  245. package/lib/feature-libraries/object-forest/objectForest.d.ts +5 -2
  246. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  247. package/lib/feature-libraries/object-forest/objectForest.js +15 -5
  248. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  249. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  250. package/lib/feature-libraries/sequence-field/invert.js +4 -4
  251. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  252. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +4 -3
  253. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  254. package/lib/index.d.ts +4 -4
  255. package/lib/index.d.ts.map +1 -1
  256. package/lib/index.js +1 -1
  257. package/lib/index.js.map +1 -1
  258. package/lib/packageVersion.d.ts +1 -1
  259. package/lib/packageVersion.js +1 -1
  260. package/lib/packageVersion.js.map +1 -1
  261. package/lib/shared-tree/index.d.ts +1 -1
  262. package/lib/shared-tree/index.d.ts.map +1 -1
  263. package/lib/shared-tree/index.js +1 -1
  264. package/lib/shared-tree/index.js.map +1 -1
  265. package/lib/shared-tree/schematizingTreeView.d.ts +7 -1
  266. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  267. package/lib/shared-tree/schematizingTreeView.js +2 -2
  268. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  269. package/lib/shared-tree/sharedTree.d.ts +3 -0
  270. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  271. package/lib/shared-tree/sharedTree.js +37 -1
  272. package/lib/shared-tree/sharedTree.js.map +1 -1
  273. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  274. package/lib/shared-tree/sharedTreeChangeFamily.js +5 -5
  275. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  276. package/lib/shared-tree/treeCheckout.d.ts +28 -64
  277. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  278. package/lib/shared-tree/treeCheckout.js +140 -116
  279. package/lib/shared-tree/treeCheckout.js.map +1 -1
  280. package/lib/shared-tree-core/branch.d.ts +25 -81
  281. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  282. package/lib/shared-tree-core/branch.js +72 -151
  283. package/lib/shared-tree-core/branch.js.map +1 -1
  284. package/lib/shared-tree-core/branchCommitEnricher.d.ts +19 -33
  285. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  286. package/lib/shared-tree-core/branchCommitEnricher.js +74 -55
  287. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  288. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  289. package/lib/shared-tree-core/defaultResubmitMachine.js +3 -2
  290. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  291. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  292. package/lib/shared-tree-core/editManager.js +1 -1
  293. package/lib/shared-tree-core/editManager.js.map +1 -1
  294. package/lib/shared-tree-core/index.d.ts +1 -1
  295. package/lib/shared-tree-core/index.d.ts.map +1 -1
  296. package/lib/shared-tree-core/index.js +1 -1
  297. package/lib/shared-tree-core/index.js.map +1 -1
  298. package/lib/shared-tree-core/sharedTreeCore.d.ts +2 -2
  299. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  300. package/lib/shared-tree-core/sharedTreeCore.js +12 -53
  301. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  302. package/lib/shared-tree-core/transaction.d.ts +108 -0
  303. package/lib/shared-tree-core/transaction.d.ts.map +1 -0
  304. package/lib/shared-tree-core/transaction.js +95 -0
  305. package/lib/shared-tree-core/transaction.js.map +1 -0
  306. package/lib/shared-tree-core/transactionEnricher.d.ts +8 -13
  307. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  308. package/lib/shared-tree-core/transactionEnricher.js +41 -21
  309. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  310. package/lib/simple-tree/api/identifierIndex.d.ts +21 -0
  311. package/lib/simple-tree/api/identifierIndex.d.ts.map +1 -0
  312. package/lib/simple-tree/api/identifierIndex.js +41 -0
  313. package/lib/simple-tree/api/identifierIndex.js.map +1 -0
  314. package/lib/simple-tree/api/index.d.ts +2 -0
  315. package/lib/simple-tree/api/index.d.ts.map +1 -1
  316. package/lib/simple-tree/api/index.js +2 -0
  317. package/lib/simple-tree/api/index.js.map +1 -1
  318. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +11 -9
  319. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  320. package/lib/simple-tree/api/simpleTreeIndex.d.ts +65 -0
  321. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
  322. package/lib/simple-tree/api/simpleTreeIndex.js +87 -0
  323. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -0
  324. package/lib/simple-tree/api/tree.d.ts +4 -5
  325. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  326. package/lib/simple-tree/api/tree.js.map +1 -1
  327. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  328. package/lib/simple-tree/core/index.d.ts +1 -1
  329. package/lib/simple-tree/core/index.d.ts.map +1 -1
  330. package/lib/simple-tree/core/index.js +1 -1
  331. package/lib/simple-tree/core/index.js.map +1 -1
  332. package/lib/simple-tree/core/treeNodeKernel.d.ts +6 -2
  333. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  334. package/lib/simple-tree/core/treeNodeKernel.js +31 -1
  335. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  336. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  337. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  338. package/lib/simple-tree/core/unhydratedFlexTree.js +1 -1
  339. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  340. package/lib/simple-tree/index.d.ts +1 -1
  341. package/lib/simple-tree/index.d.ts.map +1 -1
  342. package/lib/simple-tree/index.js +1 -1
  343. package/lib/simple-tree/index.js.map +1 -1
  344. package/lib/simple-tree/objectNode.d.ts +7 -2
  345. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  346. package/lib/simple-tree/objectNode.js.map +1 -1
  347. package/lib/simple-tree/toMapTree.js +5 -5
  348. package/lib/simple-tree/toMapTree.js.map +1 -1
  349. package/lib/util/index.d.ts +1 -2
  350. package/lib/util/index.d.ts.map +1 -1
  351. package/lib/util/index.js +1 -2
  352. package/lib/util/index.js.map +1 -1
  353. package/lib/util/typeCheck.d.ts +6 -1
  354. package/lib/util/typeCheck.d.ts.map +1 -1
  355. package/lib/util/typeCheck.js.map +1 -1
  356. package/lib/util/typeCheckTests.d.ts +14 -2
  357. package/lib/util/typeCheckTests.d.ts.map +1 -1
  358. package/lib/util/typeCheckTests.js.map +1 -1
  359. package/lib/util/utils.d.ts +29 -0
  360. package/lib/util/utils.d.ts.map +1 -1
  361. package/lib/util/utils.js +9 -0
  362. package/lib/util/utils.js.map +1 -1
  363. package/package.json +22 -22
  364. package/src/core/forest/forest.ts +12 -1
  365. package/src/core/index.ts +8 -1
  366. package/src/core/rebase/utils.ts +12 -10
  367. package/src/core/revertible.ts +35 -1
  368. package/src/core/schema-stored/storedSchemaRepository.ts +2 -1
  369. package/src/core/tree/anchorSet.ts +2 -1
  370. package/src/core/tree/detachedFieldIndexCodec.ts +4 -3
  371. package/src/core/tree/index.ts +1 -0
  372. package/src/core/tree/visitorUtils.ts +56 -1
  373. package/src/feature-libraries/chunked-forest/chunkedForest.ts +33 -7
  374. package/src/feature-libraries/chunked-forest/uniformChunk.ts +3 -3
  375. package/src/feature-libraries/flex-tree/context.ts +1 -1
  376. package/src/feature-libraries/index.ts +9 -0
  377. package/src/feature-libraries/indexing/anchorTreeIndex.ts +453 -0
  378. package/src/feature-libraries/indexing/index.ts +11 -0
  379. package/src/feature-libraries/indexing/types.ts +37 -0
  380. package/src/feature-libraries/object-forest/objectForest.ts +22 -4
  381. package/src/feature-libraries/sequence-field/invert.ts +4 -4
  382. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +4 -4
  383. package/src/index.ts +16 -6
  384. package/src/packageVersion.ts +1 -1
  385. package/src/shared-tree/index.ts +0 -2
  386. package/src/shared-tree/schematizingTreeView.ts +7 -7
  387. package/src/shared-tree/sharedTree.ts +60 -6
  388. package/src/shared-tree/sharedTreeChangeFamily.ts +5 -4
  389. package/src/shared-tree/treeCheckout.ts +186 -193
  390. package/src/shared-tree-core/branch.ts +93 -220
  391. package/src/shared-tree-core/branchCommitEnricher.ts +69 -64
  392. package/src/shared-tree-core/defaultResubmitMachine.ts +3 -2
  393. package/src/shared-tree-core/editManager.ts +1 -1
  394. package/src/shared-tree-core/index.ts +9 -2
  395. package/src/shared-tree-core/sharedTreeCore.ts +17 -62
  396. package/src/shared-tree-core/transaction.ts +165 -0
  397. package/src/shared-tree-core/transactionEnricher.ts +30 -24
  398. package/src/simple-tree/api/identifierIndex.ts +64 -0
  399. package/src/simple-tree/api/index.ts +5 -0
  400. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -18
  401. package/src/simple-tree/api/simpleTreeIndex.ts +231 -0
  402. package/src/simple-tree/api/tree.ts +8 -5
  403. package/src/simple-tree/api/treeNodeApi.ts +1 -1
  404. package/src/simple-tree/core/index.ts +1 -0
  405. package/src/simple-tree/core/treeNodeKernel.ts +37 -2
  406. package/src/simple-tree/core/unhydratedFlexTree.ts +2 -1
  407. package/src/simple-tree/index.ts +4 -0
  408. package/src/simple-tree/objectNode.ts +19 -12
  409. package/src/simple-tree/toMapTree.ts +5 -5
  410. package/src/util/index.ts +3 -1
  411. package/src/util/typeCheck.ts +6 -1
  412. package/src/util/typeCheckTests.ts +11 -1
  413. package/src/util/utils.ts +38 -0
  414. package/dist/events/emitter.d.ts +0 -139
  415. package/dist/events/emitter.d.ts.map +0 -1
  416. package/dist/events/emitter.js +0 -165
  417. package/dist/events/emitter.js.map +0 -1
  418. package/dist/events/index.d.ts +0 -7
  419. package/dist/events/index.d.ts.map +0 -1
  420. package/dist/events/index.js +0 -11
  421. package/dist/events/index.js.map +0 -1
  422. package/dist/events/interop.d.ts +0 -30
  423. package/dist/events/interop.d.ts.map +0 -1
  424. package/dist/events/interop.js.map +0 -1
  425. package/dist/events/listeners.d.ts +0 -76
  426. package/dist/events/listeners.d.ts.map +0 -1
  427. package/dist/events/listeners.js +0 -7
  428. package/dist/events/listeners.js.map +0 -1
  429. package/dist/shared-tree-core/transactionStack.d.ts +0 -29
  430. package/dist/shared-tree-core/transactionStack.d.ts.map +0 -1
  431. package/dist/shared-tree-core/transactionStack.js +0 -41
  432. package/dist/shared-tree-core/transactionStack.js.map +0 -1
  433. package/dist/util/transactionResult.d.ts +0 -19
  434. package/dist/util/transactionResult.d.ts.map +0 -1
  435. package/dist/util/transactionResult.js +0 -23
  436. package/dist/util/transactionResult.js.map +0 -1
  437. package/lib/events/emitter.d.ts +0 -139
  438. package/lib/events/emitter.d.ts.map +0 -1
  439. package/lib/events/emitter.js +0 -160
  440. package/lib/events/emitter.js.map +0 -1
  441. package/lib/events/index.d.ts +0 -7
  442. package/lib/events/index.d.ts.map +0 -1
  443. package/lib/events/index.js.map +0 -1
  444. package/lib/events/interop.d.ts +0 -30
  445. package/lib/events/interop.d.ts.map +0 -1
  446. package/lib/events/interop.js.map +0 -1
  447. package/lib/events/listeners.d.ts +0 -76
  448. package/lib/events/listeners.d.ts.map +0 -1
  449. package/lib/events/listeners.js +0 -6
  450. package/lib/events/listeners.js.map +0 -1
  451. package/lib/shared-tree-core/transactionStack.d.ts +0 -29
  452. package/lib/shared-tree-core/transactionStack.d.ts.map +0 -1
  453. package/lib/shared-tree-core/transactionStack.js +0 -37
  454. package/lib/shared-tree-core/transactionStack.js.map +0 -1
  455. package/lib/util/transactionResult.d.ts +0 -19
  456. package/lib/util/transactionResult.d.ts.map +0 -1
  457. package/lib/util/transactionResult.js +0 -20
  458. package/lib/util/transactionResult.js.map +0 -1
  459. package/src/events/README.md +0 -3
  460. package/src/events/emitter.ts +0 -256
  461. package/src/events/index.ts +0 -19
  462. package/src/events/interop.ts +0 -38
  463. package/src/events/listeners.ts +0 -80
  464. package/src/shared-tree-core/transactionStack.ts +0 -45
  465. package/src/util/transactionResult.ts +0 -19
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,QAAQ,EACR,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAGrB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,SAAS,EACT,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EACzB,4BAA4B,E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,qBAAqB,CAAC;AAC7B,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,QAAQ,EACR,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAGrB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,SAAS,EACT,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EACzB,4BAA4B,EAC5B,WAAW,EACX,KAAK,WAAW,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,eAAe,EACpB,QAAQ,EACR,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACz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e,EACpB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,oBAAoB,EACpB,mBAAmB,EACnB,2BAA2B,EAC3B,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,kCAAkC,EACvC,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,UAAU,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,mBAAmB,EACnB,0BAA0B,GAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,aAAa,EACb,wBAAwB,EACxB,KAAK,iBAAiB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,gCAAgC,EACrC,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,QAAQ,GACR,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EACN,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,oBAAoB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,UAAU,GACV,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export { typeNameSymbol, typeSchemaSymbol, NodeKind, isTreeNode, tryDisposeTreeNode, HydratedContext, SimpleContextSlot, getOrCreateInnerNode, getKernel, } from "./core/index.js";
6
- export { TreeViewConfiguration, SchemaFactory, adaptEnum, enumFromStrings, singletonSchema, test_RecursiveObject, test_RecursiveObject_base, test_RecursiveObjectPojoMode, treeNodeApi, cursorFromInsertable, createFromInsertable, TreeBeta, getJsonSchema, getSimpleSchema, extractPersistedSchema, comparePersistedSchema, comparePersistedSchemaInternal, ViewSchema, tryGetSchema, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, conciseFromCursor, createFromCursor, asTreeViewAlpha, } from "./api/index.js";
6
+ export { TreeViewConfiguration, SchemaFactory, adaptEnum, enumFromStrings, singletonSchema, test_RecursiveObject, test_RecursiveObject_base, test_RecursiveObjectPojoMode, treeNodeApi, cursorFromInsertable, createFromInsertable, TreeBeta, createSimpleTreeIndex, createIdentifierIndex, getJsonSchema, getSimpleSchema, extractPersistedSchema, comparePersistedSchema, comparePersistedSchemaInternal, ViewSchema, tryGetSchema, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, conciseFromCursor, createFromCursor, asTreeViewAlpha, } from "./api/index.js";
7
7
  export { isTreeNodeSchemaClass, FieldKind, FieldSchema, normalizeFieldSchema, areFieldSchemaEqual, areImplicitFieldSchemaEqual, normalizeAllowedTypes, } from "./schemaTypes.js";
8
8
  export { getTreeNodeForField, prepareContentForHydration, } from "./proxies.js";
9
9
  export { TreeArrayNode, IterableTreeArrayContent, } from "./arrayNode.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,cAAc,EACd,gBAAgB,EAGhB,QAAQ,EAUR,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAKN,qBAAqB,EAIrB,aAAa,EAIb,SAAS,EACT,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EACzB,4BAA4B,EAC5B,WAAW,EAEX,oBAAoB,EACpB,oBAAoB,EAEpB,QAAQ,EAuBR,aAAa,EACb,eAAe,EAKf,sBAAsB,EACtB,sBAAsB,EAEtB,8BAA8B,EAC9B,UAAU,EAyBV,YAAY,EACZ,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEN,qBAAqB,EAQrB,SAAS,EACT,WAAW,EAMX,oBAAoB,EACpB,mBAAmB,EACnB,2BAA2B,EAM3B,qBAAqB,GAMrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,mBAAmB,EACnB,0BAA0B,GAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,aAAa,EACb,wBAAwB,GAExB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAKN,QAAQ,GACR,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,mBAAmB,GAInB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,UAAU,GACV,MAAM,qBAAqB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype WithType,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype TreeNodeSchemaCore,\n\ttype TreeChangeEvents,\n\t// TreeNode is only type exported, which prevents use of the class object for unsupported use-cases like direct sub-classing and instanceof.\n\t// See docs on TreeNode for more details.\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype InternalTreeNode,\n\tisTreeNode,\n\ttryDisposeTreeNode,\n\tHydratedContext,\n\tSimpleContextSlot,\n\tgetOrCreateInnerNode,\n\tgetKernel,\n} from \"./core/index.js\";\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype ViewableTree,\n\ttype TreeViewEvents,\n\tTreeViewConfiguration,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n\tSchemaFactory,\n\ttype ScopedSchemaName,\n\ttype ValidateRecursiveSchema,\n\ttype FixRecursiveArraySchema,\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n\ttest_RecursiveObject,\n\ttest_RecursiveObject_base,\n\ttest_RecursiveObjectPojoMode,\n\ttreeNodeApi,\n\ttype TreeNodeApi,\n\tcursorFromInsertable,\n\tcreateFromInsertable,\n\ttype NodeChangedData,\n\tTreeBeta,\n\ttype TreeChangeEventsBeta,\n\ttype SimpleNodeSchemaBase,\n\ttype SimpleTreeSchema,\n\ttype SimpleNodeSchema,\n\ttype SimpleFieldSchema,\n\ttype SimpleLeafNodeSchema,\n\ttype SimpleMapNodeSchema,\n\ttype SimpleArrayNodeSchema,\n\ttype SimpleObjectNodeSchema,\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n\tgetJsonSchema,\n\tgetSimpleSchema,\n\ttype VerboseTreeNode,\n\ttype EncodeOptions,\n\ttype ParseOptions,\n\ttype VerboseTree,\n\textractPersistedSchema,\n\tcomparePersistedSchema,\n\ttype ConciseTree,\n\tcomparePersistedSchemaInternal,\n\tViewSchema,\n\ttype Unenforced,\n\ttype FieldHasDefaultUnsafe,\n\ttype ObjectFromSchemaRecordUnsafe,\n\ttype TreeObjectNodeUnsafe,\n\ttype TreeFieldFromImplicitFieldUnsafe,\n\ttype TreeNodeFromImplicitAllowedTypesUnsafe,\n\ttype FieldSchemaUnsafe,\n\ttype InsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\ttype TreeArrayNodeUnsafe,\n\ttype TreeMapNodeUnsafe,\n\ttype InsertableObjectFromSchemaRecordUnsafe,\n\ttype InsertableTreeFieldFromImplicitFieldUnsafe,\n\ttype InsertableTypedNodeUnsafe,\n\ttype NodeBuilderDataUnsafe,\n\ttype NodeFromSchemaUnsafe,\n\ttype ReadonlyMapInlined,\n\ttype TreeNodeSchemaClassUnsafe,\n\ttype TreeNodeSchemaUnsafe,\n\ttype AllowedTypesUnsafe,\n\ttype TreeNodeSchemaNonClassUnsafe,\n\ttype InsertableTreeNodeFromAllowedTypesUnsafe,\n\ttype TreeViewAlpha,\n\ttype TreeBranch,\n\ttype TreeBranchEvents,\n\ttryGetSchema,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\tconciseFromCursor,\n\tcreateFromCursor,\n\tasTreeViewAlpha,\n} from \"./api/index.js\";\nexport {\n\ttype NodeFromSchema,\n\tisTreeNodeSchemaClass,\n\ttype ImplicitFieldSchema,\n\ttype TreeFieldFromImplicitField,\n\ttype ImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype TreeLeafValue,\n\ttype AllowedTypes,\n\tFieldKind,\n\tFieldSchema,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype InsertableTypedNode,\n\ttype NodeBuilderData,\n\ttype DefaultProvider,\n\ttype FieldProps,\n\tnormalizeFieldSchema,\n\tareFieldSchemaEqual,\n\tareImplicitFieldSchemaEqual,\n\ttype ApplyKind,\n\ttype FieldSchemaMetadata,\n\ttype InsertableField,\n\ttype Insertable,\n\ttype UnsafeUnknownSchema,\n\tnormalizeAllowedTypes,\n\ttype ApplyKindInput,\n\ttype InsertableTreeNodeFromAllowedTypes,\n\ttype Input,\n\ttype ReadableField,\n\ttype ReadSchema,\n} from \"./schemaTypes.js\";\nexport {\n\tgetTreeNodeForField,\n\tprepareContentForHydration,\n} from \"./proxies.js\";\nexport {\n\tTreeArrayNode,\n\tIterableTreeArrayContent,\n\ttype ReadonlyArrayNode,\n} from \"./arrayNode.js\";\nexport {\n\ttype FieldHasDefault,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype ObjectFromSchemaRecord,\n\ttype TreeObjectNode,\n\tsetField,\n} from \"./objectNode.js\";\nexport type { TreeMapNode, MapNodeInsertableData } from \"./mapNode.js\";\nexport {\n\tmapTreeFromNodeData,\n\ttype InsertableContent,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n} from \"./toMapTree.js\";\nexport { toStoredSchema, getStoredSchema } from \"./toStoredSchema.js\";\nexport {\n\tnumberSchema,\n\tstringSchema,\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n} from \"./leafNodeSchema.js\";\nexport type { LazyItem, FlexList, FlexListToUnion, ExtractItemType } from \"./flexList.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,cAAc,EACd,gBAAgB,EAGhB,QAAQ,EAUR,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAKN,qBAAqB,EAIrB,aAAa,EAIb,SAAS,EACT,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EACzB,4BAA4B,EAC5B,WAAW,EAEX,oBAAoB,EACpB,oBAAoB,EAEpB,QAAQ,EAIR,qBAAqB,EACrB,qBAAqB,EAsBrB,aAAa,EACb,eAAe,EAKf,sBAAsB,EACtB,sBAAsB,EAEtB,8BAA8B,EAC9B,UAAU,EAyBV,YAAY,EACZ,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEN,qBAAqB,EAQrB,SAAS,EACT,WAAW,EAMX,oBAAoB,EACpB,mBAAmB,EACnB,2BAA2B,EAM3B,qBAAqB,GAMrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,mBAAmB,EACnB,0BAA0B,GAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,aAAa,EACb,wBAAwB,GAExB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAKN,QAAQ,GACR,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,mBAAmB,GAInB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,UAAU,GACV,MAAM,qBAAqB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype WithType,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype TreeNodeSchemaCore,\n\ttype TreeChangeEvents,\n\t// TreeNode is only type exported, which prevents use of the class object for unsupported use-cases like direct sub-classing and instanceof.\n\t// See docs on TreeNode for more details.\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype InternalTreeNode,\n\tisTreeNode,\n\ttryDisposeTreeNode,\n\tHydratedContext,\n\tSimpleContextSlot,\n\tgetOrCreateInnerNode,\n\tgetKernel,\n} from \"./core/index.js\";\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype ViewableTree,\n\ttype TreeViewEvents,\n\tTreeViewConfiguration,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n\tSchemaFactory,\n\ttype ScopedSchemaName,\n\ttype ValidateRecursiveSchema,\n\ttype FixRecursiveArraySchema,\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n\ttest_RecursiveObject,\n\ttest_RecursiveObject_base,\n\ttest_RecursiveObjectPojoMode,\n\ttreeNodeApi,\n\ttype TreeNodeApi,\n\tcursorFromInsertable,\n\tcreateFromInsertable,\n\ttype NodeChangedData,\n\tTreeBeta,\n\ttype TreeChangeEventsBeta,\n\ttype SimpleTreeIndex,\n\ttype IdentifierIndex,\n\tcreateSimpleTreeIndex,\n\tcreateIdentifierIndex,\n\ttype SimpleNodeSchemaBase,\n\ttype SimpleTreeSchema,\n\ttype SimpleNodeSchema,\n\ttype SimpleFieldSchema,\n\ttype SimpleLeafNodeSchema,\n\ttype SimpleMapNodeSchema,\n\ttype SimpleArrayNodeSchema,\n\ttype SimpleObjectNodeSchema,\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n\tgetJsonSchema,\n\tgetSimpleSchema,\n\ttype VerboseTreeNode,\n\ttype EncodeOptions,\n\ttype ParseOptions,\n\ttype VerboseTree,\n\textractPersistedSchema,\n\tcomparePersistedSchema,\n\ttype ConciseTree,\n\tcomparePersistedSchemaInternal,\n\tViewSchema,\n\ttype Unenforced,\n\ttype FieldHasDefaultUnsafe,\n\ttype ObjectFromSchemaRecordUnsafe,\n\ttype TreeObjectNodeUnsafe,\n\ttype TreeFieldFromImplicitFieldUnsafe,\n\ttype TreeNodeFromImplicitAllowedTypesUnsafe,\n\ttype FieldSchemaUnsafe,\n\ttype InsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\ttype TreeArrayNodeUnsafe,\n\ttype TreeMapNodeUnsafe,\n\ttype InsertableObjectFromSchemaRecordUnsafe,\n\ttype InsertableTreeFieldFromImplicitFieldUnsafe,\n\ttype InsertableTypedNodeUnsafe,\n\ttype NodeBuilderDataUnsafe,\n\ttype NodeFromSchemaUnsafe,\n\ttype ReadonlyMapInlined,\n\ttype TreeNodeSchemaClassUnsafe,\n\ttype TreeNodeSchemaUnsafe,\n\ttype AllowedTypesUnsafe,\n\ttype TreeNodeSchemaNonClassUnsafe,\n\ttype InsertableTreeNodeFromAllowedTypesUnsafe,\n\ttype TreeViewAlpha,\n\ttype TreeBranch,\n\ttype TreeBranchEvents,\n\ttryGetSchema,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\tconciseFromCursor,\n\tcreateFromCursor,\n\tasTreeViewAlpha,\n} from \"./api/index.js\";\nexport {\n\ttype NodeFromSchema,\n\tisTreeNodeSchemaClass,\n\ttype ImplicitFieldSchema,\n\ttype TreeFieldFromImplicitField,\n\ttype ImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype TreeLeafValue,\n\ttype AllowedTypes,\n\tFieldKind,\n\tFieldSchema,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype InsertableTypedNode,\n\ttype NodeBuilderData,\n\ttype DefaultProvider,\n\ttype FieldProps,\n\tnormalizeFieldSchema,\n\tareFieldSchemaEqual,\n\tareImplicitFieldSchemaEqual,\n\ttype ApplyKind,\n\ttype FieldSchemaMetadata,\n\ttype InsertableField,\n\ttype Insertable,\n\ttype UnsafeUnknownSchema,\n\tnormalizeAllowedTypes,\n\ttype ApplyKindInput,\n\ttype InsertableTreeNodeFromAllowedTypes,\n\ttype Input,\n\ttype ReadableField,\n\ttype ReadSchema,\n} from \"./schemaTypes.js\";\nexport {\n\tgetTreeNodeForField,\n\tprepareContentForHydration,\n} from \"./proxies.js\";\nexport {\n\tTreeArrayNode,\n\tIterableTreeArrayContent,\n\ttype ReadonlyArrayNode,\n} from \"./arrayNode.js\";\nexport {\n\ttype FieldHasDefault,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype ObjectFromSchemaRecord,\n\ttype TreeObjectNode,\n\tsetField,\n} from \"./objectNode.js\";\nexport type { TreeMapNode, MapNodeInsertableData } from \"./mapNode.js\";\nexport {\n\tmapTreeFromNodeData,\n\ttype InsertableContent,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n} from \"./toMapTree.js\";\nexport { toStoredSchema, getStoredSchema } from \"./toStoredSchema.js\";\nexport {\n\tnumberSchema,\n\tstringSchema,\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n} from \"./leafNodeSchema.js\";\nexport type { LazyItem, FlexList, FlexListToUnion, ExtractItemType } from \"./flexList.js\";\n"]}
@@ -51,11 +51,16 @@ export type FieldHasDefault<T extends ImplicitFieldSchema> = T extends FieldSche
51
51
  *
52
52
  * @see {@link Input}
53
53
  *
54
- * @privateRemarks TODO: consider separating these cases into different types.
54
+ * @privateRemarks
55
+ * TODO: consider separating these cases into different types.
56
+ *
57
+ * Empty objects don't get "no excess property" checks in literals.
58
+ * To prevent extraneous properties in literals for the fields of an empty object from compiling, the empty case is special cased to produce `Record<string, never>`.
59
+ * More details at {@link https://mercury.com/blog/creating-an-emptyobject-type-in-typescript}.
55
60
  *
56
61
  * @system @public
57
62
  */
58
- export type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = FlattenKeys<{
63
+ export type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = Record<string, never> extends T ? Record<string, never> : FlattenKeys<{
59
64
  readonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<T[Property & string]>;
60
65
  } & {
61
66
  readonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false ? Property : never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;
@@ -1 +1 @@
1
- {"version":3,"file":"objectNode.d.ts","sourceRoot":"","sources":["../../src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AC;QACH,CAAC;QACD,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { FieldKey } from \"../core/index.js\";\nimport {\n\tFieldKinds,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\tgetSchemaAndPolicy,\n} from \"../feature-libraries/index.js\";\nimport { getTreeNodeForField, prepareContentForHydration } from \"./proxies.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tnormalizeFieldSchema,\n\ttype ImplicitAllowedTypes,\n\tFieldKind,\n} from \"./schemaTypes.js\";\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype WithType,\n\t// eslint-disable-next-line import/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype InternalTreeNode,\n\ttype TreeNode,\n\ttype Context,\n\tUnhydratedFlexTreeNode,\n\tgetOrCreateInnerNode,\n} from \"./core/index.js\";\nimport { mapTreeFromNodeData, type InsertableContent } from \"./toMapTree.js\";\nimport { type RestrictiveStringRecord, fail, type FlattenKeys } from \"../util/index.js\";\nimport type { ObjectNodeSchema, ObjectNodeSchemaInternalData } from \"./objectNodeTypes.js\";\nimport { TreeNodeValid, type MostDerivedData } from \"./treeNodeValid.js\";\nimport { getUnhydratedContext } from \"./createContext.js\";\n\n/**\n * Generates the properties for an ObjectNode from its field schema object.\n * @system @public\n */\nexport type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = {\n\t-readonly [Property in keyof T]: Property extends string\n\t\t? TreeFieldFromImplicitField<T[Property]>\n\t\t: unknown;\n};\n\n/**\n * A {@link TreeNode} which modules a JavaScript object.\n * @remarks\n * Object nodes consist of a type which specifies which {@link TreeNodeSchema} they use (see {@link TreeNodeApi.schema}), and a collections of fields, each with a distinct `key` and its own {@link FieldSchema} defining what can be placed under that key.\n *\n * All fields on an object node are exposed as own properties with string keys.\n * Non-empty fields are enumerable and empty optional fields are non-enumerable own properties with the value `undefined`.\n * No other own `own` or `enumerable` properties are included on object nodes unless the user of the node manually adds custom session only state.\n * This allows a majority of general purpose JavaScript object processing operations (like `for...in`, `Reflect.ownKeys()` and `Object.entries()`) to enumerate all the children.\n * @public\n */\nexport type TreeObjectNode<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tTypeName extends string = string,\n> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;\n\n/**\n * Type utility for determining whether or not an implicit field schema has a default value.\n *\n * @privateRemarks\n * TODO: Account for field schemas with default value providers.\n * For now, this only captures field kinds that we know always have defaults - optional fields and identifier fields.\n *\n * @system @public\n */\nexport type FieldHasDefault<T extends ImplicitFieldSchema> = T extends FieldSchema<\n\tFieldKind.Optional | FieldKind.Identifier\n>\n\t? true\n\t: false;\n\n/**\n * Helper used to produce types for:\n *\n * 1. Insertable content which can be used to construct an object node.\n * In this case, only own properties are considered.\n * This reduces the risk of incorrectly interpreting data at the cost of occasionally requiring users to convert data into a compatible format.\n *\n * 2. Insertable content which is an unhydrated object node.\n *\n * 3. Union of 1 and 2.\n *\n * @see {@link Input}\n *\n * @privateRemarks TODO: consider separating these cases into different types.\n *\n * @system @public\n */\nexport type InsertableObjectFromSchemaRecord<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> = FlattenKeys<\n\t{\n\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<\n\t\t\tT[Property & string]\n\t\t>;\n\t} & {\n\t\t// Field does not have a known default, make it required:\n\t\treadonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false\n\t\t\t? Property\n\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;\n\t}\n>;\n\n/**\n * Maps from simple field keys (\"property\" keys) to information about the field.\n *\n * @remarks\n * A missing entry for a given property key indicates that no such field exists.\n * Keys with symbols are currently never used, but allowed to make lookups on non-field things\n * (returning undefined) easier.\n */\nexport type SimpleKeyMap = ReadonlyMap<\n\tstring | symbol,\n\t{ storedKey: FieldKey; schema: FieldSchema }\n>;\n\n/**\n * Caches the mappings from property keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.\n */\nfunction createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): SimpleKeyMap {\n\tconst keyMap: Map<string | symbol, { storedKey: FieldKey; schema: FieldSchema }> = new Map();\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, fieldSchema);\n\t\tkeyMap.set(propertyKey, { storedKey, schema: normalizeFieldSchema(fieldSchema) });\n\t}\n\n\treturn keyMap;\n}\n\n/**\n * @param allowAdditionalProperties - If true, setting of unexpected properties will be forwarded to the target object.\n * Otherwise setting of unexpected properties will error.\n * TODO: consider implementing this using `Object.preventExtension` instead.\n * @param customTargetObject - Target object of the proxy.\n * If not provided `{}` is used for the target.\n */\nfunction createProxyHandler(\n\tschema: ObjectNodeSchema & ObjectNodeSchemaInternalData,\n\tallowAdditionalProperties: boolean,\n): ProxyHandler<TreeNode> {\n\t// To satisfy 'deepEquals' level scrutiny, the target of the proxy must be an object with the same\n\t// prototype as an object literal '{}'. This is because 'deepEquals' uses 'Object.getPrototypeOf'\n\t// as a way to quickly reject objects with different prototype chains.\n\t//\n\t// (Note that the prototype of an object literal appears as '[Object: null prototype] {}', not because\n\t// the prototype is null, but because the prototype object itself has a null prototype.)\n\n\t// TODO: Although the target is an object literal, it's still worthwhile to try experimenting with\n\t// a dispatch object to see if it improves performance.\n\tconst handler: ProxyHandler<TreeNode> = {\n\t\tget(target, propertyKey, proxy): unknown {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\n\t\t\tif (fieldInfo !== undefined) {\n\t\t\t\tconst flexNode = getOrCreateInnerNode(proxy);\n\t\t\t\tconst field = flexNode.tryGetField(fieldInfo.storedKey);\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn getTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\t// TODO: this special case logic should move to the inner node (who's schema claims it has an identifier), rather than here, after we already read undefined out of a required field.\n\t\t\t\t// Check if the user is trying to read an identifier field of an unhydrated node, but the identifier is not present.\n\t\t\t\t// This means the identifier is an \"auto-generated identifier\", because otherwise it would have been supplied by the user at construction time and would have been successfully read just above.\n\t\t\t\t// In this case, it is categorically impossible to provide an identifier (auto-generated identifiers can't be created until hydration/insertion time), so we emit an error.\n\t\t\t\tif (\n\t\t\t\t\tfieldInfo.schema.kind === FieldKind.Identifier &&\n\t\t\t\t\tflexNode instanceof UnhydratedFlexTreeNode\n\t\t\t\t) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"An automatically generated node identifier may not be queried until the node is inserted into the tree\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// POJO mode objects don't have TreeNode's build in members on their targets, so special case them:\n\t\t\tif (propertyKey === typeSchemaSymbol) {\n\t\t\t\treturn schema;\n\t\t\t}\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\tif (propertyKey === typeNameSymbol) {\n\t\t\t\treturn schema.identifier;\n\t\t\t}\n\n\t\t\t// Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.\n\t\t\treturn Reflect.get(target, propertyKey, proxy);\n\t\t},\n\t\tset(target, propertyKey, value: InsertableContent | undefined, proxy) {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\t// Pass the proxy as the receiver here, so that setters on the prototype receive `proxy` as `this`.\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.set(target, propertyKey, value, proxy)\n\t\t\t\t\t: false;\n\t\t\t}\n\n\t\t\tsetField(\n\t\t\t\tgetOrCreateInnerNode(proxy).getBoxed(fieldInfo.storedKey),\n\t\t\t\tfieldInfo.schema,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t\treturn true;\n\t\t},\n\t\tdeleteProperty(target, propertyKey): boolean {\n\t\t\t// TODO: supporting delete when it makes sense (custom local fields, and optional field) could be added as a feature in the future.\n\t\t\tthrow new UsageError(\n\t\t\t\t`Object nodes do not support the delete operator. Optional fields can be assigned to undefined instead.`,\n\t\t\t);\n\t\t},\n\t\thas: (target, propertyKey) => {\n\t\t\treturn (\n\t\t\t\tschema.flexKeyMap.has(propertyKey) ||\n\t\t\t\t(allowAdditionalProperties ? Reflect.has(target, propertyKey) : false)\n\t\t\t);\n\t\t},\n\t\townKeys: (target) => {\n\t\t\treturn [\n\t\t\t\t...schema.flexKeyMap.keys(),\n\t\t\t\t...(allowAdditionalProperties ? Reflect.ownKeys(target) : []),\n\t\t\t];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, propertyKey) => {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.getOwnPropertyDescriptor(target, propertyKey)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\n\t\t\t// For some reason, the getOwnPropertyDescriptor is not passed in the receiver, so use a weak map.\n\t\t\t// If a refactoring is done to associated flex tree data with the target not the proxy, this extra map could be removed,\n\t\t\t// and the design would be more compatible with proxyless nodes.\n\t\t\tconst proxy = targetToProxy.get(target) ?? fail(\"missing proxy\");\n\t\t\tconst field = getOrCreateInnerNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : getTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\t// Report empty fields as own properties so they shadow inherited properties (even when empty) to match TypeScript typing.\n\t\t\t\t// Make empty fields not enumerable so they get skipped when iterating over an object to better align with\n\t\t\t\t// JSON and deep equals with JSON compatible object (which can't have undefined fields).\n\t\t\t\tenumerable: field !== undefined,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\n\t\t\treturn p;\n\t\t},\n\t};\n\treturn handler;\n}\n\nexport function setField(\n\tfield: FlexTreeField,\n\tsimpleFieldSchema: FieldSchema,\n\tvalue: InsertableContent | undefined,\n): void {\n\tconst mapTree = mapTreeFromNodeData(\n\t\tvalue,\n\t\tsimpleFieldSchema,\n\t\tfield.context.isHydrated() ? field.context.nodeKeyManager : undefined,\n\t\tgetSchemaAndPolicy(field),\n\t);\n\n\tif (field.context.isHydrated()) {\n\t\tprepareContentForHydration(mapTree, field.context.checkout.forest);\n\t}\n\n\tswitch (field.schema) {\n\t\tcase FieldKinds.required.identifier: {\n\t\t\tassert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);\n\t\t\tconst typedField = field as FlexTreeRequiredField;\n\t\t\ttypedField.editor.set(mapTree);\n\t\t\tbreak;\n\t\t}\n\t\tcase FieldKinds.optional.identifier: {\n\t\t\tconst typedField = field as FlexTreeOptionalField;\n\t\t\ttypedField.editor.set(mapTree, typedField.length === 0);\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t\tfail(\"invalid FieldKind\");\n\t}\n}\n\nabstract class CustomObjectNodeBase<\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> extends TreeNodeValid<InsertableObjectFromSchemaRecord<T>> {\n\tpublic static readonly kind = NodeKind.Object;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n *\n * @param name - Unique identifier for this schema within this factory's scope.\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n */\nexport function objectSchema<\n\tTName extends string,\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable> & ObjectNodeSchemaInternalData {\n\t// Ensure no collisions between final set of property keys, and final set of stored keys (including those\n\t// implicitly derived from property keys)\n\tassertUniqueKeys(identifier, info);\n\n\t// Performance optimization: cache property key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);\n\n\tconst identifierFieldKeys: FieldKey[] = [];\n\tfor (const item of flexKeyMap.values()) {\n\t\tif (item.schema.kind === FieldKind.Identifier) {\n\t\t\tidentifierFieldKeys.push(item.storedKey);\n\t\t}\n\t}\n\n\tconst lazyChildTypes = new Lazy(\n\t\t() => new Set(Array.from(flexKeyMap.values(), (f) => [...f.schema.allowedTypeSet]).flat()),\n\t);\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\tlet unhydratedContext: Context;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<T> {\n\t\tpublic static readonly fields: ReadonlyMap<string, FieldSchema> = new Map(\n\t\t\tArray.from(flexKeyMap, ([key, value]) => [key as string, value.schema]),\n\t\t);\n\t\tpublic static readonly flexKeyMap: SimpleKeyMap = flexKeyMap;\n\t\tpublic static readonly storedKeyToPropertyKey: ReadonlyMap<FieldKey, string> = new Map<\n\t\t\tFieldKey,\n\t\t\tstring\n\t\t>(\n\t\t\tArray.from(flexKeyMap, ([key, value]): [FieldKey, string] => [\n\t\t\t\tvalue.storedKey,\n\t\t\t\tkey as string,\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.number});\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Object)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.object(\"Foo\", {bar: schemaFactory.number}) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\tconst proxy = new Proxy(proxyTarget, handler) as CustomObjectNode;\n\t\t\ttargetToProxy.set(proxyTarget, proxy);\n\t\t\treturn proxy;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn UnhydratedFlexTreeNode.getOrCreate(\n\t\t\t\tunhydratedContext,\n\t\t\t\tmapTreeFromNodeData(input as object, this as unknown as ImplicitAllowedTypes),\n\t\t\t);\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tprotected static override oneTimeSetup<T2>(this: typeof TreeNodeValid<T2>): Context {\n\t\t\t// One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.\n\t\t\tcustomizable = (this as unknown) !== CustomObjectNode;\n\t\t\tconst schema = this as unknown as ObjectNodeSchema & ObjectNodeSchemaInternalData;\n\t\t\thandler = createProxyHandler(schema, customizable);\n\t\t\tunhydratedContext = getUnhydratedContext(schema);\n\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== CustomObjectNode.prototype) {\n\t\t\t\t\tfor (const [key] of flexKeyMap) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which shadows a field. Since fields are exposed as own properties, this shadowing will not work, and is an error.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomObjectNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomObjectNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn unhydratedContext;\n\t\t}\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: ImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn lazyChildTypes.value;\n\t\t}\n\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn CustomObjectNode.constructorCached?.constructor as unknown as Output;\n\t\t}\n\t}\n\ttype Output = typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<T, TName>);\n\treturn CustomObjectNode as Output;\n}\n\nconst targetToProxy: WeakMap<object, TreeNode> = new WeakMap();\n\n/**\n * Ensures that the set of property keys in the schema is unique.\n * Also ensure that the final set of stored keys (including those implicitly derived from property keys) is unique.\n * @throws Throws a `UsageError` if either of the key uniqueness invariants is violated.\n */\nfunction assertUniqueKeys<\n\tconst Name extends number | string,\n\tconst Fields extends RestrictiveStringRecord<ImplicitFieldSchema>,\n>(schemaName: Name, fields: Fields): void {\n\t// Verify that there are no duplicates among the explicitly specified stored keys.\n\tconst explicitStoredKeys = new Set<string>();\n\tfor (const schema of Object.values(fields)) {\n\t\tconst storedKey = getExplicitStoredKey(schema);\n\t\tif (storedKey === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (explicitStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Duplicate stored key \"${storedKey}\" in schema \"${schemaName}\". Stored keys must be unique within an object schema.`,\n\t\t\t);\n\t\t}\n\t\texplicitStoredKeys.add(storedKey);\n\t}\n\n\t// Verify that there are no duplicates among the derived\n\t// (including those implicitly derived from property keys) stored keys.\n\tconst derivedStoredKeys = new Set<string>();\n\tfor (const [propertyKey, schema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tif (derivedStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Stored key \"${storedKey}\" in schema \"${schemaName}\" conflicts with a property key of the same name, which is not overridden by a stored key. The final set of stored keys in an object schema must be unique.`,\n\t\t\t);\n\t\t}\n\t\tderivedSto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AC;YACtC,MAAM,IAAI,UAAU,CACnB,eAAe,SAAS,gBAAgB,UAAU,6JAA6J,CAC/M,CAAC;QACH,CAAC;QACD,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { FieldKey } from \"../core/index.js\";\nimport {\n\tFieldKinds,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\tgetSchemaAndPolicy,\n} from \"../feature-libraries/index.js\";\nimport { getTreeNodeForField, prepareContentForHydration } from \"./proxies.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tnormalizeFieldSchema,\n\ttype ImplicitAllowedTypes,\n\tFieldKind,\n} from \"./schemaTypes.js\";\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype WithType,\n\t// eslint-disable-next-line import/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype InternalTreeNode,\n\ttype TreeNode,\n\ttype Context,\n\tUnhydratedFlexTreeNode,\n\tgetOrCreateInnerNode,\n} from \"./core/index.js\";\nimport { mapTreeFromNodeData, type InsertableContent } from \"./toMapTree.js\";\nimport { type RestrictiveStringRecord, fail, type FlattenKeys } from \"../util/index.js\";\nimport type { ObjectNodeSchema, ObjectNodeSchemaInternalData } from \"./objectNodeTypes.js\";\nimport { TreeNodeValid, type MostDerivedData } from \"./treeNodeValid.js\";\nimport { getUnhydratedContext } from \"./createContext.js\";\n\n/**\n * Generates the properties for an ObjectNode from its field schema object.\n * @system @public\n */\nexport type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = {\n\t-readonly [Property in keyof T]: Property extends string\n\t\t? TreeFieldFromImplicitField<T[Property]>\n\t\t: unknown;\n};\n\n/**\n * A {@link TreeNode} which modules a JavaScript object.\n * @remarks\n * Object nodes consist of a type which specifies which {@link TreeNodeSchema} they use (see {@link TreeNodeApi.schema}), and a collections of fields, each with a distinct `key` and its own {@link FieldSchema} defining what can be placed under that key.\n *\n * All fields on an object node are exposed as own properties with string keys.\n * Non-empty fields are enumerable and empty optional fields are non-enumerable own properties with the value `undefined`.\n * No other own `own` or `enumerable` properties are included on object nodes unless the user of the node manually adds custom session only state.\n * This allows a majority of general purpose JavaScript object processing operations (like `for...in`, `Reflect.ownKeys()` and `Object.entries()`) to enumerate all the children.\n * @public\n */\nexport type TreeObjectNode<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tTypeName extends string = string,\n> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;\n\n/**\n * Type utility for determining whether or not an implicit field schema has a default value.\n *\n * @privateRemarks\n * TODO: Account for field schemas with default value providers.\n * For now, this only captures field kinds that we know always have defaults - optional fields and identifier fields.\n *\n * @system @public\n */\nexport type FieldHasDefault<T extends ImplicitFieldSchema> = T extends FieldSchema<\n\tFieldKind.Optional | FieldKind.Identifier\n>\n\t? true\n\t: false;\n\n/**\n * Helper used to produce types for:\n *\n * 1. Insertable content which can be used to construct an object node.\n * In this case, only own properties are considered.\n * This reduces the risk of incorrectly interpreting data at the cost of occasionally requiring users to convert data into a compatible format.\n *\n * 2. Insertable content which is an unhydrated object node.\n *\n * 3. Union of 1 and 2.\n *\n * @see {@link Input}\n *\n * @privateRemarks\n * TODO: consider separating these cases into different types.\n *\n * Empty objects don't get \"no excess property\" checks in literals.\n * To prevent extraneous properties in literals for the fields of an empty object from compiling, the empty case is special cased to produce `Record<string, never>`.\n * More details at {@link https://mercury.com/blog/creating-an-emptyobject-type-in-typescript}.\n *\n * @system @public\n */\nexport type InsertableObjectFromSchemaRecord<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> = Record<string, never> extends T\n\t? Record<string, never>\n\t: FlattenKeys<\n\t\t\t{\n\t\t\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<\n\t\t\t\t\tT[Property & string]\n\t\t\t\t>;\n\t\t\t} & {\n\t\t\t\t// Field does not have a known default, make it required:\n\t\t\t\treadonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false\n\t\t\t\t\t? Property\n\t\t\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;\n\t\t\t}\n\t\t>;\n\n/**\n * Maps from simple field keys (\"property\" keys) to information about the field.\n *\n * @remarks\n * A missing entry for a given property key indicates that no such field exists.\n * Keys with symbols are currently never used, but allowed to make lookups on non-field things\n * (returning undefined) easier.\n */\nexport type SimpleKeyMap = ReadonlyMap<\n\tstring | symbol,\n\t{ storedKey: FieldKey; schema: FieldSchema }\n>;\n\n/**\n * Caches the mappings from property keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.\n */\nfunction createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): SimpleKeyMap {\n\tconst keyMap: Map<string | symbol, { storedKey: FieldKey; schema: FieldSchema }> = new Map();\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, fieldSchema);\n\t\tkeyMap.set(propertyKey, { storedKey, schema: normalizeFieldSchema(fieldSchema) });\n\t}\n\n\treturn keyMap;\n}\n\n/**\n * @param allowAdditionalProperties - If true, setting of unexpected properties will be forwarded to the target object.\n * Otherwise setting of unexpected properties will error.\n * TODO: consider implementing this using `Object.preventExtension` instead.\n * @param customTargetObject - Target object of the proxy.\n * If not provided `{}` is used for the target.\n */\nfunction createProxyHandler(\n\tschema: ObjectNodeSchema & ObjectNodeSchemaInternalData,\n\tallowAdditionalProperties: boolean,\n): ProxyHandler<TreeNode> {\n\t// To satisfy 'deepEquals' level scrutiny, the target of the proxy must be an object with the same\n\t// prototype as an object literal '{}'. This is because 'deepEquals' uses 'Object.getPrototypeOf'\n\t// as a way to quickly reject objects with different prototype chains.\n\t//\n\t// (Note that the prototype of an object literal appears as '[Object: null prototype] {}', not because\n\t// the prototype is null, but because the prototype object itself has a null prototype.)\n\n\t// TODO: Although the target is an object literal, it's still worthwhile to try experimenting with\n\t// a dispatch object to see if it improves performance.\n\tconst handler: ProxyHandler<TreeNode> = {\n\t\tget(target, propertyKey, proxy): unknown {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\n\t\t\tif (fieldInfo !== undefined) {\n\t\t\t\tconst flexNode = getOrCreateInnerNode(proxy);\n\t\t\t\tconst field = flexNode.tryGetField(fieldInfo.storedKey);\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn getTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\t// TODO: this special case logic should move to the inner node (who's schema claims it has an identifier), rather than here, after we already read undefined out of a required field.\n\t\t\t\t// Check if the user is trying to read an identifier field of an unhydrated node, but the identifier is not present.\n\t\t\t\t// This means the identifier is an \"auto-generated identifier\", because otherwise it would have been supplied by the user at construction time and would have been successfully read just above.\n\t\t\t\t// In this case, it is categorically impossible to provide an identifier (auto-generated identifiers can't be created until hydration/insertion time), so we emit an error.\n\t\t\t\tif (\n\t\t\t\t\tfieldInfo.schema.kind === FieldKind.Identifier &&\n\t\t\t\t\tflexNode instanceof UnhydratedFlexTreeNode\n\t\t\t\t) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"An automatically generated node identifier may not be queried until the node is inserted into the tree\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// POJO mode objects don't have TreeNode's build in members on their targets, so special case them:\n\t\t\tif (propertyKey === typeSchemaSymbol) {\n\t\t\t\treturn schema;\n\t\t\t}\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\tif (propertyKey === typeNameSymbol) {\n\t\t\t\treturn schema.identifier;\n\t\t\t}\n\n\t\t\t// Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.\n\t\t\treturn Reflect.get(target, propertyKey, proxy);\n\t\t},\n\t\tset(target, propertyKey, value: InsertableContent | undefined, proxy) {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\t// Pass the proxy as the receiver here, so that setters on the prototype receive `proxy` as `this`.\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.set(target, propertyKey, value, proxy)\n\t\t\t\t\t: false;\n\t\t\t}\n\n\t\t\tsetField(\n\t\t\t\tgetOrCreateInnerNode(proxy).getBoxed(fieldInfo.storedKey),\n\t\t\t\tfieldInfo.schema,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t\treturn true;\n\t\t},\n\t\tdeleteProperty(target, propertyKey): boolean {\n\t\t\t// TODO: supporting delete when it makes sense (custom local fields, and optional field) could be added as a feature in the future.\n\t\t\tthrow new UsageError(\n\t\t\t\t`Object nodes do not support the delete operator. Optional fields can be assigned to undefined instead.`,\n\t\t\t);\n\t\t},\n\t\thas: (target, propertyKey) => {\n\t\t\treturn (\n\t\t\t\tschema.flexKeyMap.has(propertyKey) ||\n\t\t\t\t(allowAdditionalProperties ? Reflect.has(target, propertyKey) : false)\n\t\t\t);\n\t\t},\n\t\townKeys: (target) => {\n\t\t\treturn [\n\t\t\t\t...schema.flexKeyMap.keys(),\n\t\t\t\t...(allowAdditionalProperties ? Reflect.ownKeys(target) : []),\n\t\t\t];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, propertyKey) => {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.getOwnPropertyDescriptor(target, propertyKey)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\n\t\t\t// For some reason, the getOwnPropertyDescriptor is not passed in the receiver, so use a weak map.\n\t\t\t// If a refactoring is done to associated flex tree data with the target not the proxy, this extra map could be removed,\n\t\t\t// and the design would be more compatible with proxyless nodes.\n\t\t\tconst proxy = targetToProxy.get(target) ?? fail(\"missing proxy\");\n\t\t\tconst field = getOrCreateInnerNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : getTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\t// Report empty fields as own properties so they shadow inherited properties (even when empty) to match TypeScript typing.\n\t\t\t\t// Make empty fields not enumerable so they get skipped when iterating over an object to better align with\n\t\t\t\t// JSON and deep equals with JSON compatible object (which can't have undefined fields).\n\t\t\t\tenumerable: field !== undefined,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\n\t\t\treturn p;\n\t\t},\n\t};\n\treturn handler;\n}\n\nexport function setField(\n\tfield: FlexTreeField,\n\tsimpleFieldSchema: FieldSchema,\n\tvalue: InsertableContent | undefined,\n): void {\n\tconst mapTree = mapTreeFromNodeData(\n\t\tvalue,\n\t\tsimpleFieldSchema,\n\t\tfield.context.isHydrated() ? field.context.nodeKeyManager : undefined,\n\t\tgetSchemaAndPolicy(field),\n\t);\n\n\tif (field.context.isHydrated()) {\n\t\tprepareContentForHydration(mapTree, field.context.checkout.forest);\n\t}\n\n\tswitch (field.schema) {\n\t\tcase FieldKinds.required.identifier: {\n\t\t\tassert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);\n\t\t\tconst typedField = field as FlexTreeRequiredField;\n\t\t\ttypedField.editor.set(mapTree);\n\t\t\tbreak;\n\t\t}\n\t\tcase FieldKinds.optional.identifier: {\n\t\t\tconst typedField = field as FlexTreeOptionalField;\n\t\t\ttypedField.editor.set(mapTree, typedField.length === 0);\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t\tfail(\"invalid FieldKind\");\n\t}\n}\n\nabstract class CustomObjectNodeBase<\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> extends TreeNodeValid<InsertableObjectFromSchemaRecord<T>> {\n\tpublic static readonly kind = NodeKind.Object;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n *\n * @param name - Unique identifier for this schema within this factory's scope.\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n */\nexport function objectSchema<\n\tTName extends string,\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable> & ObjectNodeSchemaInternalData {\n\t// Ensure no collisions between final set of property keys, and final set of stored keys (including those\n\t// implicitly derived from property keys)\n\tassertUniqueKeys(identifier, info);\n\n\t// Performance optimization: cache property key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);\n\n\tconst identifierFieldKeys: FieldKey[] = [];\n\tfor (const item of flexKeyMap.values()) {\n\t\tif (item.schema.kind === FieldKind.Identifier) {\n\t\t\tidentifierFieldKeys.push(item.storedKey);\n\t\t}\n\t}\n\n\tconst lazyChildTypes = new Lazy(\n\t\t() => new Set(Array.from(flexKeyMap.values(), (f) => [...f.schema.allowedTypeSet]).flat()),\n\t);\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\tlet unhydratedContext: Context;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<T> {\n\t\tpublic static readonly fields: ReadonlyMap<string, FieldSchema> = new Map(\n\t\t\tArray.from(flexKeyMap, ([key, value]) => [key as string, value.schema]),\n\t\t);\n\t\tpublic static readonly flexKeyMap: SimpleKeyMap = flexKeyMap;\n\t\tpublic static readonly storedKeyToPropertyKey: ReadonlyMap<FieldKey, string> = new Map<\n\t\t\tFieldKey,\n\t\t\tstring\n\t\t>(\n\t\t\tArray.from(flexKeyMap, ([key, value]): [FieldKey, string] => [\n\t\t\t\tvalue.storedKey,\n\t\t\t\tkey as string,\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.number});\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Object)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.object(\"Foo\", {bar: schemaFactory.number}) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\tconst proxy = new Proxy(proxyTarget, handler) as CustomObjectNode;\n\t\t\ttargetToProxy.set(proxyTarget, proxy);\n\t\t\treturn proxy;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn UnhydratedFlexTreeNode.getOrCreate(\n\t\t\t\tunhydratedContext,\n\t\t\t\tmapTreeFromNodeData(input as object, this as unknown as ImplicitAllowedTypes),\n\t\t\t);\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tprotected static override oneTimeSetup<T2>(this: typeof TreeNodeValid<T2>): Context {\n\t\t\t// One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.\n\t\t\tcustomizable = (this as unknown) !== CustomObjectNode;\n\t\t\tconst schema = this as unknown as ObjectNodeSchema & ObjectNodeSchemaInternalData;\n\t\t\thandler = createProxyHandler(schema, customizable);\n\t\t\tunhydratedContext = getUnhydratedContext(schema);\n\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== CustomObjectNode.prototype) {\n\t\t\t\t\tfor (const [key] of flexKeyMap) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which shadows a field. Since fields are exposed as own properties, this shadowing will not work, and is an error.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomObjectNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomObjectNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn unhydratedContext;\n\t\t}\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: ImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn lazyChildTypes.value;\n\t\t}\n\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn CustomObjectNode.constructorCached?.constructor as unknown as Output;\n\t\t}\n\t}\n\ttype Output = typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<T, TName>);\n\treturn CustomObjectNode as Output;\n}\n\nconst targetToProxy: WeakMap<object, TreeNode> = new WeakMap();\n\n/**\n * Ensures that the set of property keys in the schema is unique.\n * Also ensure that the final set of stored keys (including those implicitly derived from property keys) is unique.\n * @throws Throws a `UsageError` if either of the key uniqueness invariants is violated.\n */\nfunction assertUniqueKeys<\n\tconst Name extends number | string,\n\tconst Fields extends RestrictiveStringRecord<ImplicitFieldSchema>,\n>(schemaName: Name, fields: Fields): void {\n\t// Verify that there are no duplicates among the explicitly specified stored keys.\n\tconst explicitStoredKeys = new Set<string>();\n\tfor (const schema of Object.values(fields)) {\n\t\tconst storedKey = getExplicitStoredKey(schema);\n\t\tif (storedKey === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (explicitStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Duplicate stored key \"${storedKey}\" in schema \"${schemaName}\". Stored keys must be unique within an object schema.`,\n\t\t\t);\n\t\t}\n\t\texplicitStoredKeys.add(storedKey);\n\t}\n\n\t// Verify that there are no duplicates among the derived\n\t// (including those implicitly derived from property keys) stored keys.\n\tconst derivedStoredKeys = new Set<string>();\n\tfor (const [propertyKey, schema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tif (derivedStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Stored key \"${storedKey}\" in schema \"${schemaName}\" conflicts with a property key of the same name, which is not overridden by a stored key. The final set of stored keys in an object schema must be unique.`,\n\t\t\t);\n\t\t}\n\t\tderivedStoredKeys.add(storedKey);\n\t}\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 { assert, oob } from "@fluidframework/core-utils/internal";
5
+ import { assert } from "@fluidframework/core-utils/internal";
6
6
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
7
  import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
8
8
  import { EmptyKey, } from "../core/index.js";
9
9
  import { isTreeValue, valueSchemaAllows, } from "../feature-libraries/index.js";
10
- import { brand, fail, isReadonlyArray, find } from "../util/index.js";
10
+ import { brand, fail, isReadonlyArray, find, hasSome, hasSingle } from "../util/index.js";
11
11
  import { nullSchema } from "./leafNodeSchema.js";
12
12
  import { normalizeAllowedTypes, extractFieldProvider, isConstant, normalizeFieldSchema, FieldKind, } from "./schemaTypes.js";
13
13
  import { getKernel, getSimpleNodeSchemaFromInnerNode, isTreeNode, NodeKind, UnhydratedFlexTreeNode, } from "./core/index.js";
@@ -290,8 +290,8 @@ function getType(data, allowedTypes) {
290
290
  if (possibleTypes.length === 0) {
291
291
  throw new UsageError(`The provided data is incompatible with all of the types allowed by the schema. The set of allowed types is: ${JSON.stringify([...allowedTypes].map((schema) => schema.identifier))}.`);
292
292
  }
293
- assert(possibleTypes.length !== 0, 0x84e /* data is incompatible with all types allowed by the schema */);
294
- if (possibleTypes.length !== 1) {
293
+ assert(hasSome(possibleTypes), 0x84e /* data is incompatible with all types allowed by the schema */);
294
+ if (!hasSingle(possibleTypes)) {
295
295
  throw new UsageError(`The provided data is compatible with more than one type allowed by the schema.
296
296
  The set of possible types is ${JSON.stringify([
297
297
  ...possibleTypes.map((schema) => schema.identifier),
@@ -299,7 +299,7 @@ The set of possible types is ${JSON.stringify([
299
299
  Explicitly construct an unhydrated node of the desired type to disambiguate.
300
300
  For class-based schema, this can be done by replacing an expression like "{foo: 1}" with "new MySchema({foo: 1})".`);
301
301
  }
302
- return possibleTypes[0] ?? oob();
302
+ return possibleTypes[0];
303
303
  }
304
304
  /**
305
305
  * @returns all types for which the data is schema-compatible.
@@ -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,GAEjB,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;AACjD,OAAO,EAGN,qBAAqB,EACrB,oBAAoB,EACpB,UAAU,EAGV,oBAAoB,EACpB,SAAS,GAET,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,SAAS,EACT,gCAAgC,EAChC,UAAU,EACV,QAAQ,EAKR,sBAAsB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAA0B,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAiE1D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G;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} 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\tgetSimpleNodeSchemaFromInnerNode,\n\tisTreeNode,\n\tNodeKind,\n\ttype InnerNode,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\ttype Unhydrated,\n\tUnhydratedFlexTreeNode,\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 (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\t\tif (!allowedTypes.has(getSimpleNodeSchemaFromInnerNode(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;\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.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 UsageError(`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 UsageError(`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 * @system @alpha\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 * @system @alpha\n */\nexport type FactoryContentObject = {\n\treadonly [P in string]?: InsertableContent;\n};\n\n/**\n * Content which can be inserted into a tree.\n * @system @alpha\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n"]}
1
+ {"version":3,"file":"toMapTree.js","sourceRoot":"","sources":["../../src/simple-tree/toMapTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,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,GAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE1F,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAGN,qBAAqB,EACrB,oBAAoB,EACpB,UAAU,EAGV,oBAAoB,EACpB,SAAS,GAET,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,SAAS,EACT,gCAAgC,EAChC,UAAU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AE,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 } 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} from \"../feature-libraries/index.js\";\nimport { brand, fail, isReadonlyArray, find, hasSome, hasSingle } 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\tgetSimpleNodeSchemaFromInnerNode,\n\tisTreeNode,\n\tNodeKind,\n\ttype InnerNode,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\ttype Unhydrated,\n\tUnhydratedFlexTreeNode,\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 (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\t\tif (!allowedTypes.has(getSimpleNodeSchemaFromInnerNode(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;\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.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 UsageError(`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 UsageError(`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\thasSome(possibleTypes),\n\t\t0x84e /* data is incompatible with all types allowed by the schema */,\n\t);\n\tif (!hasSingle(possibleTypes)) {\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];\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 * @system @alpha\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 * @system @alpha\n */\nexport type FactoryContentObject = {\n\treadonly [P in string]?: InsertableContent;\n};\n\n/**\n * Content which can be inserted into a tree.\n * @system @alpha\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n"]}
@@ -8,10 +8,9 @@ export { brandOpaque, extractFromOpaque, type ExtractFromOpaque, type Opaque, }
8
8
  export { deleteFromNestedMap, getOrAddInMap, getOrAddInMapLazy, getOrAddInNestedMap, getOrDefaultInNestedMap, forEachInNestedMap, type NestedMap, type ReadonlyNestedMap, SizedNestedMap, populateNestedMap, setInNestedMap, tryAddToNestedMap, tryGetFromNestedMap, mapNestedMap, nestedMapToFlatList, nestedMapFromFlatList, } from "./nestedMap.js";
9
9
  export { addToNestedSet, type NestedSet, nestedSetContains } from "./nestedSet.js";
10
10
  export { type OffsetList, OffsetListFactory } from "./offsetList.js";
11
- export { TransactionResult } from "./transactionResult.js";
12
11
  export type { areSafelyAssignable, Contravariant, Covariant, eitherIsAny, EnforceTypeCheckTests, Invariant, isAny, isAssignableTo, isStrictSubset, MakeNominal, requireFalse, requireTrue, requireAssignableTo, areOnlyKeys, } from "./typeCheck.js";
13
12
  export { StackyIterator } from "./stackyIterator.js";
14
- export { asMutable, clone, compareSets, fail, getOrAddEmptyToMap, getOrCreate, isJsonObject, isReadonlyArray, type JsonCompatible, type JsonCompatibleObject, type JsonCompatibleReadOnly, type JsonCompatibleReadOnlyObject, JsonCompatibleReadOnlySchema, makeArray, mapIterable, filterIterable, type Mutable, type Populated, type RecursiveReadonly, assertValidIndex, assertValidRange, assertNonNegativeSafeInteger, objectToMap, invertMap, oneFromSet, type Named, compareNamed, disposeSymbol, type IDisposable, capitalize, assertValidRangeIndices, transformObjectMap, compareStrings, find, count, } from "./utils.js";
13
+ export { asMutable, clone, compareSets, fail, getOrAddEmptyToMap, getOrCreate, isJsonObject, isReadonlyArray, type JsonCompatible, type JsonCompatibleObject, type JsonCompatibleReadOnly, type JsonCompatibleReadOnlyObject, JsonCompatibleReadOnlySchema, makeArray, mapIterable, filterIterable, type Mutable, type Populated, type RecursiveReadonly, assertValidIndex, assertValidRange, assertNonNegativeSafeInteger, objectToMap, invertMap, oneFromSet, type Named, compareNamed, disposeSymbol, type IDisposable, capitalize, assertValidRangeIndices, transformObjectMap, compareStrings, find, count, getLast, hasSome, hasSingle, } from "./utils.js";
15
14
  export { ReferenceCountedBase, type ReferenceCounted } from "./referenceCounting.js";
16
15
  export type { _RecursiveTrick, RestrictiveReadonlyRecord, RestrictiveStringRecord, _InlineTrick, FlattenKeys, IsUnion, UnionToIntersection, UnionToTuple, PopUnion, } from "./typeUtils.js";
17
16
  export { unsafeArrayToTuple } from "./typeUtils.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,EACL,KAAK,KAAK,EACV,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,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,aAAa,EACb,KAAK,WAAW,EAChB,UAAU,EACV,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,IAAI,EACJ,KAAK,GACL,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAErF,YAAY,EACX,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,YAAY,EACZ,QAAQ,GACR,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EACN,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,WAAW,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,yBAAyB,EACzB,eAAe,EACf,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,aAAa,EACb,kBAAkB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACN,KAAK,WAAW,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,eAAe,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,SAAS,EACT,KAAK,aAAa,EAClB,cAAc,EACd,aAAa,EACb,aAAa,GACb,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,EACL,KAAK,KAAK,EACV,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,MAAM,GACX,MAAM,aAA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pB,OAAO,EAAE,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAErF,YAAY,EACX,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,YAAY,EACZ,QAAQ,GACR,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EACN,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,WAAW,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,yBAAyB,EACzB,eAAe,EACf,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,aAAa,EACb,kBAAkB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACN,KAAK,WAAW,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,eAAe,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,SAAS,EACT,KAAK,aAAa,EAClB,cAAc,EACd,aAAa,EACb,aAAa,GACb,MAAM,gBAAgB,CAAC"}
package/lib/util/index.js CHANGED
@@ -8,9 +8,8 @@ export { brandOpaque, extractFromOpaque, } from "./opaque.js";
8
8
  export { deleteFromNestedMap, getOrAddInMap, getOrAddInMapLazy, getOrAddInNestedMap, getOrDefaultInNestedMap, forEachInNestedMap, SizedNestedMap, populateNestedMap, setInNestedMap, tryAddToNestedMap, tryGetFromNestedMap, mapNestedMap, nestedMapToFlatList, nestedMapFromFlatList, } from "./nestedMap.js";
9
9
  export { addToNestedSet, nestedSetContains } from "./nestedSet.js";
10
10
  export { OffsetListFactory } from "./offsetList.js";
11
- export { TransactionResult } from "./transactionResult.js";
12
11
  export { StackyIterator } from "./stackyIterator.js";
13
- export { asMutable, clone, compareSets, fail, getOrAddEmptyToMap, getOrCreate, isJsonObject, isReadonlyArray, JsonCompatibleReadOnlySchema, makeArray, mapIterable, filterIterable, assertValidIndex, assertValidRange, assertNonNegativeSafeInteger, objectToMap, invertMap, oneFromSet, compareNamed, disposeSymbol, capitalize, assertValidRangeIndices, transformObjectMap, compareStrings, find, count, } from "./utils.js";
12
+ export { asMutable, clone, compareSets, fail, getOrAddEmptyToMap, getOrCreate, isJsonObject, isReadonlyArray, JsonCompatibleReadOnlySchema, makeArray, mapIterable, filterIterable, assertValidIndex, assertValidRange, assertNonNegativeSafeInteger, objectToMap, invertMap, oneFromSet, compareNamed, disposeSymbol, capitalize, assertValidRangeIndices, transformObjectMap, compareStrings, find, count, getLast, hasSome, hasSingle, } from "./utils.js";
14
13
  export { ReferenceCountedBase } from "./referenceCounting.js";
15
14
  export { unsafeArrayToTuple } from "./typeUtils.js";
16
15
  export { getOrCreateSlotContent, brandedSlot, } from "./brandedMap.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,EAEL,WAAW,GAGX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACN,WAAW,EACX,iBAAiB,GAGjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAGlB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAkB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAmB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAiB3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACN,SAAS,EACT,KAAK,EACL,WAAW,EACX,IAAI,EACJ,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,eAAe,EAKf,4BAA4B,EAC5B,SAAS,EACT,WAAW,EACX,cAAc,EAId,gBAAgB,EAChB,gBAAgB,EAChB,4BAA4B,EAC5B,WAAW,EACX,SAAS,EACT,UAAU,EAEV,YAAY,EACZ,aAAa,EAEb,UAAU,EACV,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,IAAI,EACJ,KAAK,GACL,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAyB,MAAM,wBAAwB,CAAC;AAcrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAIN,sBAAsB,EACtB,WAAW,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,yBAAyB,EACzB,eAAe,EAIf,aAAa,EACb,kBAAkB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAEN,oBAAoB,EACpB,oBAAoB,EAEpB,eAAe,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,SAAS,EAET,cAAc,EACd,aAAa,EACb,aAAa,GACb,MAAM,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tbrand,\n\ttype Brand,\n\tBrandedType,\n\ttype NameFromBranded,\n\ttype ValueFromBranded,\n} from \"./brand.js\";\nexport { brandedNumberType, brandedStringType } from \"./typeboxBrand.js\";\nexport {\n\tbrandOpaque,\n\textractFromOpaque,\n\ttype ExtractFromOpaque,\n\ttype Opaque,\n} from \"./opaque.js\";\nexport {\n\tdeleteFromNestedMap,\n\tgetOrAddInMap,\n\tgetOrAddInMapLazy,\n\tgetOrAddInNestedMap,\n\tgetOrDefaultInNestedMap,\n\tforEachInNestedMap,\n\ttype NestedMap,\n\ttype ReadonlyNestedMap,\n\tSizedNestedMap,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryAddToNestedMap,\n\ttryGetFromNestedMap,\n\tmapNestedMap,\n\tnestedMapToFlatList,\n\tnestedMapFromFlatList,\n} from \"./nestedMap.js\";\nexport { addToNestedSet, type NestedSet, nestedSetContains } from \"./nestedSet.js\";\nexport { type OffsetList, OffsetListFactory } from \"./offsetList.js\";\nexport { TransactionResult } from \"./transactionResult.js\";\nexport type {\n\tareSafelyAssignable,\n\tContravariant,\n\tCovariant,\n\teitherIsAny,\n\tEnforceTypeCheckTests,\n\tInvariant,\n\tisAny,\n\tisAssignableTo,\n\tisStrictSubset,\n\tMakeNominal,\n\trequireFalse,\n\trequireTrue,\n\trequireAssignableTo,\n\tareOnlyKeys,\n} from \"./typeCheck.js\";\nexport { StackyIterator } from \"./stackyIterator.js\";\nexport {\n\tasMutable,\n\tclone,\n\tcompareSets,\n\tfail,\n\tgetOrAddEmptyToMap,\n\tgetOrCreate,\n\tisJsonObject,\n\tisReadonlyArray,\n\ttype JsonCompatible,\n\ttype JsonCompatibleObject,\n\ttype JsonCompatibleReadOnly,\n\ttype JsonCompatibleReadOnlyObject,\n\tJsonCompatibleReadOnlySchema,\n\tmakeArray,\n\tmapIterable,\n\tfilterIterable,\n\ttype Mutable,\n\ttype Populated,\n\ttype RecursiveReadonly,\n\tassertValidIndex,\n\tassertValidRange,\n\tassertNonNegativeSafeInteger,\n\tobjectToMap,\n\tinvertMap,\n\toneFromSet,\n\ttype Named,\n\tcompareNamed,\n\tdisposeSymbol,\n\ttype IDisposable,\n\tcapitalize,\n\tassertValidRangeIndices,\n\ttransformObjectMap,\n\tcompareStrings,\n\tfind,\n\tcount,\n} from \"./utils.js\";\nexport { ReferenceCountedBase, type ReferenceCounted } from \"./referenceCounting.js\";\n\nexport type {\n\t_RecursiveTrick,\n\tRestrictiveReadonlyRecord,\n\tRestrictiveStringRecord,\n\t_InlineTrick,\n\tFlattenKeys,\n\tIsUnion,\n\tUnionToIntersection,\n\tUnionToTuple,\n\tPopUnion,\n} from \"./typeUtils.js\";\n\nexport { unsafeArrayToTuple } from \"./typeUtils.js\";\n\nexport {\n\ttype BrandedKey,\n\ttype BrandedKeyContent,\n\ttype BrandedMapSubset,\n\tgetOrCreateSlotContent,\n\tbrandedSlot,\n} from \"./brandedMap.js\";\n\nexport {\n\tgetFirstEntryFromRangeMap,\n\tgetFromRangeMap,\n\ttype RangeEntry,\n\ttype RangeMap,\n\ttype RangeQueryResult,\n\tsetInRangeMap,\n\tdeleteFromRangeMap,\n} from \"./rangeMap.js\";\n\nexport {\n\ttype IdAllocator,\n\tidAllocatorFromMaxId,\n\tidAllocatorFromState,\n\ttype IdAllocationState,\n\tfakeIdAllocator,\n} from \"./idAllocator.js\";\n\nexport {\n\tBreakable,\n\ttype WithBreakable,\n\tbreakingMethod,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"./breakable.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,EAEL,WAAW,GAGX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACN,WAAW,EACX,iBAAiB,GAGjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAGlB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAkB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAmB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAiBrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACN,SAAS,EACT,KAAK,EACL,WAAW,EACX,IAAI,EACJ,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,eAAe,EAKf,4BAA4B,EAC5B,SAAS,EACT,WAAW,EACX,cAAc,EAId,gBAAgB,EAChB,gBAAgB,EAChB,4BAA4B,EAC5B,WAAW,EACX,SAAS,EACT,UAAU,EAEV,YAAY,EACZ,aAAa,EAEb,UAAU,EACV,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,IAAI,EACJ,KAAK,EACL,OAAO,EACP,OAAO,EACP,SAAS,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAyB,MAAM,wBAAwB,CAAC;AAcrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAIN,sBAAsB,EACtB,WAAW,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,yBAAyB,EACzB,eAAe,EAIf,aAAa,EACb,kBAAkB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAEN,oBAAoB,EACpB,oBAAoB,EAEpB,eAAe,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,SAAS,EAET,cAAc,EACd,aAAa,EACb,aAAa,GACb,MAAM,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tbrand,\n\ttype Brand,\n\tBrandedType,\n\ttype NameFromBranded,\n\ttype ValueFromBranded,\n} from \"./brand.js\";\nexport { brandedNumberType, brandedStringType } from \"./typeboxBrand.js\";\nexport {\n\tbrandOpaque,\n\textractFromOpaque,\n\ttype ExtractFromOpaque,\n\ttype Opaque,\n} from \"./opaque.js\";\nexport {\n\tdeleteFromNestedMap,\n\tgetOrAddInMap,\n\tgetOrAddInMapLazy,\n\tgetOrAddInNestedMap,\n\tgetOrDefaultInNestedMap,\n\tforEachInNestedMap,\n\ttype NestedMap,\n\ttype ReadonlyNestedMap,\n\tSizedNestedMap,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryAddToNestedMap,\n\ttryGetFromNestedMap,\n\tmapNestedMap,\n\tnestedMapToFlatList,\n\tnestedMapFromFlatList,\n} from \"./nestedMap.js\";\nexport { addToNestedSet, type NestedSet, nestedSetContains } from \"./nestedSet.js\";\nexport { type OffsetList, OffsetListFactory } from \"./offsetList.js\";\nexport type {\n\tareSafelyAssignable,\n\tContravariant,\n\tCovariant,\n\teitherIsAny,\n\tEnforceTypeCheckTests,\n\tInvariant,\n\tisAny,\n\tisAssignableTo,\n\tisStrictSubset,\n\tMakeNominal,\n\trequireFalse,\n\trequireTrue,\n\trequireAssignableTo,\n\tareOnlyKeys,\n} from \"./typeCheck.js\";\nexport { StackyIterator } from \"./stackyIterator.js\";\nexport {\n\tasMutable,\n\tclone,\n\tcompareSets,\n\tfail,\n\tgetOrAddEmptyToMap,\n\tgetOrCreate,\n\tisJsonObject,\n\tisReadonlyArray,\n\ttype JsonCompatible,\n\ttype JsonCompatibleObject,\n\ttype JsonCompatibleReadOnly,\n\ttype JsonCompatibleReadOnlyObject,\n\tJsonCompatibleReadOnlySchema,\n\tmakeArray,\n\tmapIterable,\n\tfilterIterable,\n\ttype Mutable,\n\ttype Populated,\n\ttype RecursiveReadonly,\n\tassertValidIndex,\n\tassertValidRange,\n\tassertNonNegativeSafeInteger,\n\tobjectToMap,\n\tinvertMap,\n\toneFromSet,\n\ttype Named,\n\tcompareNamed,\n\tdisposeSymbol,\n\ttype IDisposable,\n\tcapitalize,\n\tassertValidRangeIndices,\n\ttransformObjectMap,\n\tcompareStrings,\n\tfind,\n\tcount,\n\tgetLast,\n\thasSome,\n\thasSingle,\n} from \"./utils.js\";\nexport { ReferenceCountedBase, type ReferenceCounted } from \"./referenceCounting.js\";\n\nexport type {\n\t_RecursiveTrick,\n\tRestrictiveReadonlyRecord,\n\tRestrictiveStringRecord,\n\t_InlineTrick,\n\tFlattenKeys,\n\tIsUnion,\n\tUnionToIntersection,\n\tUnionToTuple,\n\tPopUnion,\n} from \"./typeUtils.js\";\n\nexport { unsafeArrayToTuple } from \"./typeUtils.js\";\n\nexport {\n\ttype BrandedKey,\n\ttype BrandedKeyContent,\n\ttype BrandedMapSubset,\n\tgetOrCreateSlotContent,\n\tbrandedSlot,\n} from \"./brandedMap.js\";\n\nexport {\n\tgetFirstEntryFromRangeMap,\n\tgetFromRangeMap,\n\ttype RangeEntry,\n\ttype RangeMap,\n\ttype RangeQueryResult,\n\tsetInRangeMap,\n\tdeleteFromRangeMap,\n} from \"./rangeMap.js\";\n\nexport {\n\ttype IdAllocator,\n\tidAllocatorFromMaxId,\n\tidAllocatorFromState,\n\ttype IdAllocationState,\n\tfakeIdAllocator,\n} from \"./idAllocator.js\";\n\nexport {\n\tBreakable,\n\ttype WithBreakable,\n\tbreakingMethod,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"./breakable.js\";\n"]}
@@ -164,11 +164,16 @@ export type isAny<T> = boolean extends (T extends never ? true : false) ? true :
164
164
  export type requireAssignableTo<_A extends B, B> = true;
165
165
  /**
166
166
  * Returns a type parameter that is true iff the `Keys` union includes all the keys of `T`.
167
+ *
168
+ * @remarks
169
+ * This does not handle when the T has an index signature permitting keys like `string` which
170
+ * TypeScript cannot omit members from.
171
+ *
167
172
  * @example
168
173
  * ```ts
169
174
  * type _check = requireTrue<areOnlyKeys<{a: number, b: number}, 'a' | 'b'>> // true`
170
175
  * type _check = requireTrue<areOnlyKeys<{a: number, b: number}, 'a'>> // false`
171
176
  * ```
172
177
  */
173
- export type areOnlyKeys<T, Keys extends keyof T> = isAssignableTo<Record<string, never>, Omit<T, Keys>>;
178
+ export type areOnlyKeys<T, Keys extends keyof T> = isAssignableTo<Record<string, never>, Omit<Required<T>, Keys>>;
174
179
  //# sourceMappingURL=typeCheck.d.ts.map
@@ -1 +1 @@
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