@fluidframework/tree 2.23.0 → 2.31.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 (1027) hide show
  1. package/CHANGELOG.md +1636 -1466
  2. package/api-extractor/api-extractor.current.json +0 -3
  3. package/api-report/tree.alpha.api.md +261 -100
  4. package/api-report/tree.beta.api.md +86 -61
  5. package/api-report/tree.legacy.alpha.api.md +86 -61
  6. package/api-report/tree.legacy.public.api.md +86 -61
  7. package/api-report/tree.public.api.md +86 -61
  8. package/dist/alpha.d.ts +32 -1
  9. package/dist/beta.d.ts +5 -1
  10. package/dist/codec/codec.d.ts +1 -1
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +3 -4
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/discriminatedUnions.d.ts.map +1 -1
  15. package/dist/codec/discriminatedUnions.js +1 -1
  16. package/dist/codec/discriminatedUnions.js.map +1 -1
  17. package/dist/core/forest/editableForest.d.ts +1 -14
  18. package/dist/core/forest/editableForest.d.ts.map +1 -1
  19. package/dist/core/forest/editableForest.js +1 -28
  20. package/dist/core/forest/editableForest.js.map +1 -1
  21. package/dist/core/forest/forest.d.ts +16 -3
  22. package/dist/core/forest/forest.d.ts.map +1 -1
  23. package/dist/core/forest/forest.js +4 -1
  24. package/dist/core/forest/forest.js.map +1 -1
  25. package/dist/core/forest/index.d.ts +1 -1
  26. package/dist/core/forest/index.d.ts.map +1 -1
  27. package/dist/core/forest/index.js +1 -2
  28. package/dist/core/forest/index.js.map +1 -1
  29. package/dist/core/index.d.ts +2 -2
  30. package/dist/core/index.d.ts.map +1 -1
  31. package/dist/core/index.js +3 -3
  32. package/dist/core/index.js.map +1 -1
  33. package/dist/core/rebase/utils.js +1 -1
  34. package/dist/core/rebase/utils.js.map +1 -1
  35. package/dist/core/schema-stored/schema.d.ts +4 -1
  36. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  37. package/dist/core/schema-stored/schema.js +8 -4
  38. package/dist/core/schema-stored/schema.js.map +1 -1
  39. package/dist/core/tree/anchorSet.d.ts +8 -3
  40. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  41. package/dist/core/tree/anchorSet.js +16 -9
  42. package/dist/core/tree/anchorSet.js.map +1 -1
  43. package/dist/core/tree/delta.d.ts +8 -23
  44. package/dist/core/tree/delta.d.ts.map +1 -1
  45. package/dist/core/tree/delta.js.map +1 -1
  46. package/dist/core/tree/deltaUtil.d.ts +3 -3
  47. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  48. package/dist/core/tree/deltaUtil.js +2 -2
  49. package/dist/core/tree/deltaUtil.js.map +1 -1
  50. package/dist/core/tree/index.d.ts +2 -2
  51. package/dist/core/tree/index.d.ts.map +1 -1
  52. package/dist/core/tree/index.js +2 -1
  53. package/dist/core/tree/index.js.map +1 -1
  54. package/dist/core/tree/pathTree.d.ts +54 -1
  55. package/dist/core/tree/pathTree.d.ts.map +1 -1
  56. package/dist/core/tree/pathTree.js +8 -1
  57. package/dist/core/tree/pathTree.js.map +1 -1
  58. package/dist/core/tree/treeTextFormat.js +2 -2
  59. package/dist/core/tree/treeTextFormat.js.map +1 -1
  60. package/dist/core/tree/visitDelta.d.ts +7 -5
  61. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  62. package/dist/core/tree/visitDelta.js +19 -9
  63. package/dist/core/tree/visitDelta.js.map +1 -1
  64. package/dist/core/tree/visitorUtils.d.ts +5 -23
  65. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  66. package/dist/core/tree/visitorUtils.js +8 -5
  67. package/dist/core/tree/visitorUtils.js.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  69. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  70. package/dist/feature-libraries/chunked-forest/basicChunk.js +9 -9
  71. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  72. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
  73. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  74. package/dist/feature-libraries/chunked-forest/chunkTree.js +12 -9
  75. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  76. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
  77. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/chunkedForest.js +8 -5
  79. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +3 -3
  81. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  82. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  83. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  84. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  85. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -4
  86. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  87. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
  88. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  89. package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
  90. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
  91. package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +4 -5
  92. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
  93. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  94. package/dist/feature-libraries/chunked-forest/emptyChunk.js +15 -15
  95. package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  96. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
  97. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  98. package/dist/feature-libraries/chunked-forest/uniformChunk.js +7 -6
  99. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  100. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
  101. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  102. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
  103. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  104. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  105. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +19 -19
  106. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  107. package/dist/feature-libraries/default-schema/index.d.ts +1 -0
  108. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  109. package/dist/feature-libraries/default-schema/index.js +3 -1
  110. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  111. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
  112. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
  113. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +57 -0
  114. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
  115. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  116. package/dist/feature-libraries/default-schema/schemaChecker.js +1 -2
  117. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  118. package/dist/feature-libraries/deltaUtils.js +1 -1
  119. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  120. package/dist/feature-libraries/flex-tree/context.d.ts +5 -5
  121. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  122. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  123. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
  124. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  125. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  126. package/dist/feature-libraries/flex-tree/lazyField.d.ts +5 -4
  127. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  128. package/dist/feature-libraries/flex-tree/lazyField.js +12 -9
  129. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  130. package/dist/feature-libraries/flex-tree/lazyNode.js +4 -4
  131. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  132. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  133. package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -5
  134. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  135. package/dist/feature-libraries/index.d.ts +2 -1
  136. package/dist/feature-libraries/index.d.ts.map +1 -1
  137. package/dist/feature-libraries/index.js +9 -7
  138. package/dist/feature-libraries/index.js.map +1 -1
  139. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  140. package/dist/feature-libraries/indexing/anchorTreeIndex.js +1 -1
  141. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  142. package/dist/feature-libraries/initializeForest.d.ts +18 -0
  143. package/dist/feature-libraries/initializeForest.d.ts.map +1 -0
  144. package/dist/feature-libraries/initializeForest.js +35 -0
  145. package/dist/feature-libraries/initializeForest.js.map +1 -0
  146. package/dist/feature-libraries/modular-schema/comparison.js +4 -4
  147. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  148. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  149. package/dist/feature-libraries/modular-schema/isNeverTree.js +2 -3
  150. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  151. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  152. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -4
  153. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  154. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
  155. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  156. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +13 -19
  157. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  158. package/dist/feature-libraries/node-identifier/index.d.ts +8 -0
  159. package/dist/feature-libraries/node-identifier/index.d.ts.map +1 -0
  160. package/dist/feature-libraries/node-identifier/index.js +16 -0
  161. package/dist/feature-libraries/node-identifier/index.js.map +1 -0
  162. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
  163. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
  164. package/dist/feature-libraries/{node-key/mockNodeKeyManager.js → node-identifier/mockNodeIdentifierManager.js} +18 -18
  165. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
  166. package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
  167. package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
  168. package/dist/feature-libraries/node-identifier/nodeIdentifier.js +26 -0
  169. package/dist/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
  170. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
  171. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
  172. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +48 -0
  173. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
  174. package/dist/feature-libraries/object-forest/objectForest.d.ts +2 -1
  175. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  176. package/dist/feature-libraries/object-forest/objectForest.js +7 -3
  177. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  178. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  179. package/dist/feature-libraries/schema-index/codec.js +2 -1
  180. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  181. package/dist/feature-libraries/sequence-field/compose.d.ts +1 -1
  182. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  183. package/dist/feature-libraries/sequence-field/compose.js +16 -17
  184. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  185. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  186. package/dist/feature-libraries/sequence-field/invert.js +1 -1
  187. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  188. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  189. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
  190. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  191. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  192. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
  193. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  194. package/dist/feature-libraries/sequence-field/utils.js +1 -1
  195. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  196. package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  197. package/dist/feature-libraries/treeCursorUtils.js +5 -6
  198. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  199. package/dist/index.d.ts +5 -4
  200. package/dist/index.d.ts.map +1 -1
  201. package/dist/index.js +15 -3
  202. package/dist/index.js.map +1 -1
  203. package/dist/jsonDomainSchema.d.ts +15 -16
  204. package/dist/jsonDomainSchema.d.ts.map +1 -1
  205. package/dist/jsonDomainSchema.js +10 -5
  206. package/dist/jsonDomainSchema.js.map +1 -1
  207. package/dist/legacy.d.ts +5 -1
  208. package/dist/packageVersion.d.ts +1 -1
  209. package/dist/packageVersion.js +1 -1
  210. package/dist/packageVersion.js.map +1 -1
  211. package/dist/public.d.ts +5 -1
  212. package/dist/serializableDomainSchema.d.ts +8 -14
  213. package/dist/serializableDomainSchema.d.ts.map +1 -1
  214. package/dist/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  215. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  216. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  217. package/dist/shared-tree/independentView.d.ts.map +1 -1
  218. package/dist/shared-tree/independentView.js +3 -18
  219. package/dist/shared-tree/independentView.js.map +1 -1
  220. package/dist/shared-tree/index.d.ts +1 -1
  221. package/dist/shared-tree/index.d.ts.map +1 -1
  222. package/dist/shared-tree/index.js +2 -1
  223. package/dist/shared-tree/index.js.map +1 -1
  224. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  225. package/dist/shared-tree/schematizeTree.js +4 -3
  226. package/dist/shared-tree/schematizeTree.js.map +1 -1
  227. package/dist/shared-tree/schematizingTreeView.d.ts +4 -4
  228. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  229. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  230. package/dist/shared-tree/sharedTree.d.ts +1 -0
  231. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  232. package/dist/shared-tree/sharedTree.js +27 -19
  233. package/dist/shared-tree/sharedTree.js.map +1 -1
  234. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  235. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  236. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  237. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
  238. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  239. package/dist/shared-tree/sharedTreeEditBuilder.js +2 -2
  240. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  241. package/dist/shared-tree/treeApiAlpha.d.ts +9 -30
  242. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  243. package/dist/shared-tree/treeApiAlpha.js +22 -34
  244. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  245. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  246. package/dist/shared-tree/treeCheckout.js +2 -2
  247. package/dist/shared-tree/treeCheckout.js.map +1 -1
  248. package/dist/shared-tree-core/branch.d.ts +4 -3
  249. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  250. package/dist/shared-tree-core/branch.js +2 -2
  251. package/dist/shared-tree-core/branch.js.map +1 -1
  252. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  253. package/dist/shared-tree-core/editManager.js +37 -31
  254. package/dist/shared-tree-core/editManager.js.map +1 -1
  255. package/dist/sharedTreeAttributes.d.ts +18 -0
  256. package/dist/sharedTreeAttributes.d.ts.map +1 -0
  257. package/dist/sharedTreeAttributes.js +25 -0
  258. package/dist/sharedTreeAttributes.js.map +1 -0
  259. package/dist/simple-tree/api/conciseTree.d.ts +8 -2
  260. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  261. package/dist/simple-tree/api/conciseTree.js +10 -1
  262. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  263. package/dist/simple-tree/api/create.d.ts +3 -3
  264. package/dist/simple-tree/api/create.d.ts.map +1 -1
  265. package/dist/simple-tree/api/create.js.map +1 -1
  266. package/dist/simple-tree/api/customTree.d.ts +42 -12
  267. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  268. package/dist/simple-tree/api/customTree.js +33 -5
  269. package/dist/simple-tree/api/customTree.js.map +1 -1
  270. package/dist/simple-tree/api/getJsonSchema.d.ts +10 -0
  271. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  272. package/dist/simple-tree/api/getJsonSchema.js +10 -0
  273. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  274. package/dist/simple-tree/api/getSimpleSchema.d.ts +13 -43
  275. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  276. package/dist/simple-tree/api/getSimpleSchema.js +13 -43
  277. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  278. package/dist/simple-tree/api/index.d.ts +7 -6
  279. package/dist/simple-tree/api/index.d.ts.map +1 -1
  280. package/dist/simple-tree/api/index.js +8 -1
  281. package/dist/simple-tree/api/index.js.map +1 -1
  282. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  283. package/dist/simple-tree/api/schemaCreationUtilities.js +2 -2
  284. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  285. package/dist/simple-tree/api/schemaFactory.d.ts +112 -67
  286. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  287. package/dist/simple-tree/api/schemaFactory.js +80 -158
  288. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  289. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +38 -23
  290. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  291. package/dist/simple-tree/api/schemaFactoryAlpha.js +26 -1
  292. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  293. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +40 -5
  294. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  295. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  296. package/dist/simple-tree/api/schemaFromSimple.d.ts +19 -0
  297. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
  298. package/dist/simple-tree/api/schemaFromSimple.js +71 -0
  299. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -0
  300. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +3 -2
  301. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  302. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +7 -6
  303. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  304. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  305. package/dist/simple-tree/api/simpleTreeIndex.js +4 -3
  306. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  307. package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  308. package/dist/simple-tree/api/tree.d.ts +12 -6
  309. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  310. package/dist/simple-tree/api/tree.js +17 -8
  311. package/dist/simple-tree/api/tree.js.map +1 -1
  312. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  313. package/dist/simple-tree/api/treeNodeApi.js +5 -20
  314. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  315. package/dist/simple-tree/api/typesUnsafe.d.ts +102 -36
  316. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  317. package/dist/simple-tree/api/typesUnsafe.js +0 -1
  318. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  319. package/dist/simple-tree/api/verboseTree.d.ts +16 -25
  320. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  321. package/dist/simple-tree/api/verboseTree.js +19 -14
  322. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  323. package/dist/simple-tree/api/view.d.ts.map +1 -1
  324. package/dist/simple-tree/api/view.js +16 -17
  325. package/dist/simple-tree/api/view.js.map +1 -1
  326. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +16 -3
  327. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  328. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +70 -147
  329. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  330. package/dist/simple-tree/arrayNode.d.ts +5 -4
  331. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  332. package/dist/simple-tree/arrayNode.js +13 -9
  333. package/dist/simple-tree/arrayNode.js.map +1 -1
  334. package/dist/simple-tree/arrayNodeTypes.d.ts +46 -0
  335. package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -0
  336. package/dist/simple-tree/arrayNodeTypes.js +30 -0
  337. package/dist/simple-tree/arrayNodeTypes.js.map +1 -0
  338. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  339. package/dist/simple-tree/core/getOrCreateNode.js +1 -11
  340. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  341. package/dist/simple-tree/core/index.d.ts +1 -2
  342. package/dist/simple-tree/core/index.d.ts.map +1 -1
  343. package/dist/simple-tree/core/index.js +2 -3
  344. package/dist/simple-tree/core/index.js.map +1 -1
  345. package/dist/simple-tree/core/treeNodeKernel.d.ts +12 -5
  346. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  347. package/dist/simple-tree/core/treeNodeKernel.js +36 -20
  348. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  349. package/dist/simple-tree/core/treeNodeSchema.d.ts +14 -7
  350. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  351. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  352. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
  353. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  354. package/dist/simple-tree/core/unhydratedFlexTree.js +5 -5
  355. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  356. package/dist/simple-tree/flexList.d.ts +4 -5
  357. package/dist/simple-tree/flexList.d.ts.map +1 -1
  358. package/dist/simple-tree/flexList.js +1 -14
  359. package/dist/simple-tree/flexList.js.map +1 -1
  360. package/dist/simple-tree/index.d.ts +9 -2
  361. package/dist/simple-tree/index.d.ts.map +1 -1
  362. package/dist/simple-tree/index.js +15 -2
  363. package/dist/simple-tree/index.js.map +1 -1
  364. package/dist/simple-tree/leafNodeSchema.d.ts +22 -5
  365. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  366. package/dist/simple-tree/leafNodeSchema.js +2 -0
  367. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  368. package/dist/simple-tree/mapNode.d.ts +3 -2
  369. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  370. package/dist/simple-tree/mapNode.js +5 -1
  371. package/dist/simple-tree/mapNode.js.map +1 -1
  372. package/dist/simple-tree/mapNodeTypes.d.ts +46 -0
  373. package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -0
  374. package/dist/simple-tree/mapNodeTypes.js +30 -0
  375. package/dist/simple-tree/mapNodeTypes.js.map +1 -0
  376. package/dist/simple-tree/objectNode.d.ts +10 -3
  377. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  378. package/dist/simple-tree/objectNode.js +12 -5
  379. package/dist/simple-tree/objectNode.js.map +1 -1
  380. package/dist/simple-tree/objectNodeTypes.d.ts +9 -5
  381. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  382. package/dist/simple-tree/objectNodeTypes.js +3 -0
  383. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  384. package/dist/simple-tree/proxies.js +2 -1
  385. package/dist/simple-tree/proxies.js.map +1 -1
  386. package/dist/simple-tree/schemaTypes.d.ts +81 -8
  387. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  388. package/dist/simple-tree/schemaTypes.js +94 -5
  389. package/dist/simple-tree/schemaTypes.js.map +1 -1
  390. package/dist/simple-tree/{api/simpleSchema.d.ts → simpleSchema.d.ts} +55 -28
  391. package/dist/simple-tree/simpleSchema.d.ts.map +1 -0
  392. package/dist/simple-tree/simpleSchema.js.map +1 -0
  393. package/dist/simple-tree/toMapTree.d.ts +4 -4
  394. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  395. package/dist/simple-tree/toMapTree.js +3 -3
  396. package/dist/simple-tree/toMapTree.js.map +1 -1
  397. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  398. package/dist/simple-tree/toStoredSchema.js +2 -6
  399. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  400. package/dist/simple-tree/treeNodeValid.d.ts +7 -1
  401. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  402. package/dist/simple-tree/treeNodeValid.js +17 -10
  403. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  404. package/dist/treeFactory.d.ts +0 -12
  405. package/dist/treeFactory.d.ts.map +1 -1
  406. package/dist/treeFactory.js +5 -21
  407. package/dist/treeFactory.js.map +1 -1
  408. package/dist/util/cloneWithReplacements.d.ts +21 -0
  409. package/dist/util/cloneWithReplacements.d.ts.map +1 -0
  410. package/dist/util/cloneWithReplacements.js +38 -0
  411. package/dist/util/cloneWithReplacements.js.map +1 -0
  412. package/dist/util/idAllocator.d.ts.map +1 -1
  413. package/dist/util/idAllocator.js +1 -2
  414. package/dist/util/idAllocator.js.map +1 -1
  415. package/dist/util/index.d.ts +2 -1
  416. package/dist/util/index.d.ts.map +1 -1
  417. package/dist/util/index.js +4 -3
  418. package/dist/util/index.js.map +1 -1
  419. package/dist/util/referenceCounting.d.ts +18 -0
  420. package/dist/util/referenceCounting.d.ts.map +1 -1
  421. package/dist/util/referenceCounting.js.map +1 -1
  422. package/dist/util/typeCheck.d.ts +7 -0
  423. package/dist/util/typeCheck.d.ts.map +1 -1
  424. package/dist/util/typeCheck.js.map +1 -1
  425. package/dist/util/utils.d.ts +0 -1
  426. package/dist/util/utils.d.ts.map +1 -1
  427. package/dist/util/utils.js +1 -4
  428. package/dist/util/utils.js.map +1 -1
  429. package/lib/alpha.d.ts +32 -1
  430. package/lib/beta.d.ts +5 -1
  431. package/lib/codec/codec.d.ts +1 -1
  432. package/lib/codec/codec.d.ts.map +1 -1
  433. package/lib/codec/codec.js +1 -2
  434. package/lib/codec/codec.js.map +1 -1
  435. package/lib/codec/discriminatedUnions.d.ts.map +1 -1
  436. package/lib/codec/discriminatedUnions.js +2 -2
  437. package/lib/codec/discriminatedUnions.js.map +1 -1
  438. package/lib/core/forest/editableForest.d.ts +1 -14
  439. package/lib/core/forest/editableForest.d.ts.map +1 -1
  440. package/lib/core/forest/editableForest.js +0 -26
  441. package/lib/core/forest/editableForest.js.map +1 -1
  442. package/lib/core/forest/forest.d.ts +16 -3
  443. package/lib/core/forest/forest.d.ts.map +1 -1
  444. package/lib/core/forest/forest.js +4 -1
  445. package/lib/core/forest/forest.js.map +1 -1
  446. package/lib/core/forest/index.d.ts +1 -1
  447. package/lib/core/forest/index.d.ts.map +1 -1
  448. package/lib/core/forest/index.js +1 -1
  449. package/lib/core/forest/index.js.map +1 -1
  450. package/lib/core/index.d.ts +2 -2
  451. package/lib/core/index.d.ts.map +1 -1
  452. package/lib/core/index.js +2 -2
  453. package/lib/core/index.js.map +1 -1
  454. package/lib/core/rebase/utils.js +1 -1
  455. package/lib/core/rebase/utils.js.map +1 -1
  456. package/lib/core/schema-stored/schema.d.ts +4 -1
  457. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  458. package/lib/core/schema-stored/schema.js +6 -2
  459. package/lib/core/schema-stored/schema.js.map +1 -1
  460. package/lib/core/tree/anchorSet.d.ts +8 -3
  461. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  462. package/lib/core/tree/anchorSet.js +14 -7
  463. package/lib/core/tree/anchorSet.js.map +1 -1
  464. package/lib/core/tree/delta.d.ts +8 -23
  465. package/lib/core/tree/delta.d.ts.map +1 -1
  466. package/lib/core/tree/delta.js.map +1 -1
  467. package/lib/core/tree/deltaUtil.d.ts +3 -3
  468. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  469. package/lib/core/tree/deltaUtil.js +2 -2
  470. package/lib/core/tree/deltaUtil.js.map +1 -1
  471. package/lib/core/tree/index.d.ts +2 -2
  472. package/lib/core/tree/index.d.ts.map +1 -1
  473. package/lib/core/tree/index.js +1 -1
  474. package/lib/core/tree/index.js.map +1 -1
  475. package/lib/core/tree/pathTree.d.ts +54 -1
  476. package/lib/core/tree/pathTree.d.ts.map +1 -1
  477. package/lib/core/tree/pathTree.js +6 -0
  478. package/lib/core/tree/pathTree.js.map +1 -1
  479. package/lib/core/tree/treeTextFormat.js +1 -1
  480. package/lib/core/tree/treeTextFormat.js.map +1 -1
  481. package/lib/core/tree/visitDelta.d.ts +7 -5
  482. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  483. package/lib/core/tree/visitDelta.js +19 -9
  484. package/lib/core/tree/visitDelta.js.map +1 -1
  485. package/lib/core/tree/visitorUtils.d.ts +5 -23
  486. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  487. package/lib/core/tree/visitorUtils.js +8 -5
  488. package/lib/core/tree/visitorUtils.js.map +1 -1
  489. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  490. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  491. package/lib/feature-libraries/chunked-forest/basicChunk.js +3 -3
  492. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  493. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
  494. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  495. package/lib/feature-libraries/chunked-forest/chunkTree.js +12 -9
  496. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  497. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
  498. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  499. package/lib/feature-libraries/chunked-forest/chunkedForest.js +8 -5
  500. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  501. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +1 -1
  502. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  503. package/lib/feature-libraries/chunked-forest/codec/codecs.js +1 -1
  504. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  505. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  506. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  507. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  508. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
  509. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  510. package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
  511. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
  512. package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +2 -3
  513. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
  514. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  515. package/lib/feature-libraries/chunked-forest/emptyChunk.js +1 -1
  516. package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  517. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
  518. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  519. package/lib/feature-libraries/chunked-forest/uniformChunk.js +5 -4
  520. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  521. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
  522. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  523. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
  524. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  525. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  526. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  527. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  528. package/lib/feature-libraries/default-schema/index.d.ts +1 -0
  529. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  530. package/lib/feature-libraries/default-schema/index.js +1 -0
  531. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  532. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
  533. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
  534. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +53 -0
  535. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
  536. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  537. package/lib/feature-libraries/default-schema/schemaChecker.js +1 -2
  538. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  539. package/lib/feature-libraries/deltaUtils.js +1 -1
  540. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  541. package/lib/feature-libraries/flex-tree/context.d.ts +5 -5
  542. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  543. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  544. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
  545. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  546. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  547. package/lib/feature-libraries/flex-tree/lazyField.d.ts +5 -4
  548. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  549. package/lib/feature-libraries/flex-tree/lazyField.js +13 -10
  550. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  551. package/lib/feature-libraries/flex-tree/lazyNode.js +2 -2
  552. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  553. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  554. package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -7
  555. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  556. package/lib/feature-libraries/index.d.ts +2 -1
  557. package/lib/feature-libraries/index.d.ts.map +1 -1
  558. package/lib/feature-libraries/index.js +2 -1
  559. package/lib/feature-libraries/index.js.map +1 -1
  560. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  561. package/lib/feature-libraries/indexing/anchorTreeIndex.js +2 -2
  562. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  563. package/lib/feature-libraries/initializeForest.d.ts +18 -0
  564. package/lib/feature-libraries/initializeForest.d.ts.map +1 -0
  565. package/lib/feature-libraries/initializeForest.js +31 -0
  566. package/lib/feature-libraries/initializeForest.js.map +1 -0
  567. package/lib/feature-libraries/modular-schema/comparison.js +2 -2
  568. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  569. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  570. package/lib/feature-libraries/modular-schema/isNeverTree.js +1 -2
  571. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  572. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  573. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +2 -2
  574. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  575. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
  576. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  577. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +12 -18
  578. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  579. package/lib/feature-libraries/node-identifier/index.d.ts +8 -0
  580. package/lib/feature-libraries/node-identifier/index.d.ts.map +1 -0
  581. package/lib/feature-libraries/node-identifier/index.js +8 -0
  582. package/lib/feature-libraries/node-identifier/index.js.map +1 -0
  583. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
  584. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
  585. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +45 -0
  586. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
  587. package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
  588. package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
  589. package/lib/feature-libraries/node-identifier/nodeIdentifier.js +22 -0
  590. package/lib/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
  591. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
  592. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
  593. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +43 -0
  594. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
  595. package/lib/feature-libraries/object-forest/objectForest.d.ts +2 -1
  596. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  597. package/lib/feature-libraries/object-forest/objectForest.js +8 -4
  598. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  599. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  600. package/lib/feature-libraries/schema-index/codec.js +2 -1
  601. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  602. package/lib/feature-libraries/sequence-field/compose.d.ts +1 -1
  603. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  604. package/lib/feature-libraries/sequence-field/compose.js +1 -2
  605. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  606. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  607. package/lib/feature-libraries/sequence-field/invert.js +2 -2
  608. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  609. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  610. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +2 -2
  611. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  612. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  613. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +2 -2
  614. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  615. package/lib/feature-libraries/sequence-field/utils.js +2 -2
  616. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  617. package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  618. package/lib/feature-libraries/treeCursorUtils.js +2 -3
  619. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  620. package/lib/index.d.ts +5 -4
  621. package/lib/index.d.ts.map +1 -1
  622. package/lib/index.js +5 -3
  623. package/lib/index.js.map +1 -1
  624. package/lib/jsonDomainSchema.d.ts +15 -16
  625. package/lib/jsonDomainSchema.d.ts.map +1 -1
  626. package/lib/jsonDomainSchema.js +11 -6
  627. package/lib/jsonDomainSchema.js.map +1 -1
  628. package/lib/legacy.d.ts +5 -1
  629. package/lib/packageVersion.d.ts +1 -1
  630. package/lib/packageVersion.js +1 -1
  631. package/lib/packageVersion.js.map +1 -1
  632. package/lib/public.d.ts +5 -1
  633. package/lib/serializableDomainSchema.d.ts +8 -14
  634. package/lib/serializableDomainSchema.d.ts.map +1 -1
  635. package/lib/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  636. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  637. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  638. package/lib/shared-tree/independentView.d.ts.map +1 -1
  639. package/lib/shared-tree/independentView.js +5 -20
  640. package/lib/shared-tree/independentView.js.map +1 -1
  641. package/lib/shared-tree/index.d.ts +1 -1
  642. package/lib/shared-tree/index.d.ts.map +1 -1
  643. package/lib/shared-tree/index.js +1 -1
  644. package/lib/shared-tree/index.js.map +1 -1
  645. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  646. package/lib/shared-tree/schematizeTree.js +5 -4
  647. package/lib/shared-tree/schematizeTree.js.map +1 -1
  648. package/lib/shared-tree/schematizingTreeView.d.ts +4 -4
  649. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  650. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  651. package/lib/shared-tree/sharedTree.d.ts +1 -0
  652. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  653. package/lib/shared-tree/sharedTree.js +23 -16
  654. package/lib/shared-tree/sharedTree.js.map +1 -1
  655. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  656. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -3
  657. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  658. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
  659. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  660. package/lib/shared-tree/sharedTreeEditBuilder.js +2 -2
  661. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  662. package/lib/shared-tree/treeApiAlpha.d.ts +9 -30
  663. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  664. package/lib/shared-tree/treeApiAlpha.js +12 -24
  665. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  666. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  667. package/lib/shared-tree/treeCheckout.js +4 -4
  668. package/lib/shared-tree/treeCheckout.js.map +1 -1
  669. package/lib/shared-tree-core/branch.d.ts +4 -3
  670. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  671. package/lib/shared-tree-core/branch.js +2 -2
  672. package/lib/shared-tree-core/branch.js.map +1 -1
  673. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  674. package/lib/shared-tree-core/editManager.js +35 -29
  675. package/lib/shared-tree-core/editManager.js.map +1 -1
  676. package/lib/sharedTreeAttributes.d.ts +18 -0
  677. package/lib/sharedTreeAttributes.d.ts.map +1 -0
  678. package/lib/sharedTreeAttributes.js +22 -0
  679. package/lib/sharedTreeAttributes.js.map +1 -0
  680. package/lib/simple-tree/api/conciseTree.d.ts +8 -2
  681. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  682. package/lib/simple-tree/api/conciseTree.js +9 -1
  683. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  684. package/lib/simple-tree/api/create.d.ts +3 -3
  685. package/lib/simple-tree/api/create.d.ts.map +1 -1
  686. package/lib/simple-tree/api/create.js.map +1 -1
  687. package/lib/simple-tree/api/customTree.d.ts +42 -12
  688. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  689. package/lib/simple-tree/api/customTree.js +30 -3
  690. package/lib/simple-tree/api/customTree.js.map +1 -1
  691. package/lib/simple-tree/api/getJsonSchema.d.ts +10 -0
  692. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  693. package/lib/simple-tree/api/getJsonSchema.js +10 -0
  694. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  695. package/lib/simple-tree/api/getSimpleSchema.d.ts +13 -43
  696. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  697. package/lib/simple-tree/api/getSimpleSchema.js +13 -43
  698. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  699. package/lib/simple-tree/api/index.d.ts +7 -6
  700. package/lib/simple-tree/api/index.d.ts.map +1 -1
  701. package/lib/simple-tree/api/index.js +5 -3
  702. package/lib/simple-tree/api/index.js.map +1 -1
  703. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  704. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
  705. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  706. package/lib/simple-tree/api/schemaFactory.d.ts +112 -67
  707. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  708. package/lib/simple-tree/api/schemaFactory.js +78 -155
  709. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  710. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +38 -23
  711. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  712. package/lib/simple-tree/api/schemaFactoryAlpha.js +27 -2
  713. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  714. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +40 -5
  715. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  716. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  717. package/lib/simple-tree/api/schemaFromSimple.d.ts +19 -0
  718. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
  719. package/lib/simple-tree/api/schemaFromSimple.js +67 -0
  720. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -0
  721. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +3 -2
  722. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  723. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -6
  724. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  725. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  726. package/lib/simple-tree/api/simpleTreeIndex.js +2 -1
  727. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  728. package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  729. package/lib/simple-tree/api/tree.d.ts +12 -6
  730. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  731. package/lib/simple-tree/api/tree.js +14 -5
  732. package/lib/simple-tree/api/tree.js.map +1 -1
  733. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  734. package/lib/simple-tree/api/treeNodeApi.js +5 -20
  735. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  736. package/lib/simple-tree/api/typesUnsafe.d.ts +102 -36
  737. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  738. package/lib/simple-tree/api/typesUnsafe.js +0 -1
  739. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  740. package/lib/simple-tree/api/verboseTree.d.ts +16 -25
  741. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  742. package/lib/simple-tree/api/verboseTree.js +16 -12
  743. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  744. package/lib/simple-tree/api/view.d.ts.map +1 -1
  745. package/lib/simple-tree/api/view.js +1 -2
  746. package/lib/simple-tree/api/view.js.map +1 -1
  747. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +16 -3
  748. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  749. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +69 -146
  750. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  751. package/lib/simple-tree/arrayNode.d.ts +5 -4
  752. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  753. package/lib/simple-tree/arrayNode.js +7 -3
  754. package/lib/simple-tree/arrayNode.js.map +1 -1
  755. package/lib/simple-tree/arrayNodeTypes.d.ts +46 -0
  756. package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -0
  757. package/lib/simple-tree/arrayNodeTypes.js +26 -0
  758. package/lib/simple-tree/arrayNodeTypes.js.map +1 -0
  759. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  760. package/lib/simple-tree/core/getOrCreateNode.js +2 -12
  761. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  762. package/lib/simple-tree/core/index.d.ts +1 -2
  763. package/lib/simple-tree/core/index.d.ts.map +1 -1
  764. package/lib/simple-tree/core/index.js +1 -2
  765. package/lib/simple-tree/core/index.js.map +1 -1
  766. package/lib/simple-tree/core/treeNodeKernel.d.ts +12 -5
  767. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  768. package/lib/simple-tree/core/treeNodeKernel.js +28 -14
  769. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  770. package/lib/simple-tree/core/treeNodeSchema.d.ts +14 -7
  771. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  772. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  773. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
  774. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  775. package/lib/simple-tree/core/unhydratedFlexTree.js +2 -2
  776. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  777. package/lib/simple-tree/flexList.d.ts +4 -5
  778. package/lib/simple-tree/flexList.d.ts.map +1 -1
  779. package/lib/simple-tree/flexList.js +0 -12
  780. package/lib/simple-tree/flexList.js.map +1 -1
  781. package/lib/simple-tree/index.d.ts +9 -2
  782. package/lib/simple-tree/index.d.ts.map +1 -1
  783. package/lib/simple-tree/index.js +5 -2
  784. package/lib/simple-tree/index.js.map +1 -1
  785. package/lib/simple-tree/leafNodeSchema.d.ts +22 -5
  786. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  787. package/lib/simple-tree/leafNodeSchema.js +2 -0
  788. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  789. package/lib/simple-tree/mapNode.d.ts +3 -2
  790. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  791. package/lib/simple-tree/mapNode.js +5 -1
  792. package/lib/simple-tree/mapNode.js.map +1 -1
  793. package/lib/simple-tree/mapNodeTypes.d.ts +46 -0
  794. package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -0
  795. package/lib/simple-tree/mapNodeTypes.js +26 -0
  796. package/lib/simple-tree/mapNodeTypes.js.map +1 -0
  797. package/lib/simple-tree/objectNode.d.ts +10 -3
  798. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  799. package/lib/simple-tree/objectNode.js +12 -5
  800. package/lib/simple-tree/objectNode.js.map +1 -1
  801. package/lib/simple-tree/objectNodeTypes.d.ts +9 -5
  802. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  803. package/lib/simple-tree/objectNodeTypes.js +3 -0
  804. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  805. package/lib/simple-tree/proxies.js +2 -1
  806. package/lib/simple-tree/proxies.js.map +1 -1
  807. package/lib/simple-tree/schemaTypes.d.ts +81 -8
  808. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  809. package/lib/simple-tree/schemaTypes.js +91 -6
  810. package/lib/simple-tree/schemaTypes.js.map +1 -1
  811. package/lib/simple-tree/{api/simpleSchema.d.ts → simpleSchema.d.ts} +55 -28
  812. package/lib/simple-tree/simpleSchema.d.ts.map +1 -0
  813. package/lib/simple-tree/simpleSchema.js.map +1 -0
  814. package/lib/simple-tree/toMapTree.d.ts +4 -4
  815. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  816. package/lib/simple-tree/toMapTree.js +2 -2
  817. package/lib/simple-tree/toMapTree.js.map +1 -1
  818. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  819. package/lib/simple-tree/toStoredSchema.js +4 -8
  820. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  821. package/lib/simple-tree/treeNodeValid.d.ts +7 -1
  822. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  823. package/lib/simple-tree/treeNodeValid.js +14 -7
  824. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  825. package/lib/treeFactory.d.ts +0 -12
  826. package/lib/treeFactory.d.ts.map +1 -1
  827. package/lib/treeFactory.js +1 -17
  828. package/lib/treeFactory.js.map +1 -1
  829. package/lib/tsdoc-metadata.json +1 -1
  830. package/lib/util/cloneWithReplacements.d.ts +21 -0
  831. package/lib/util/cloneWithReplacements.d.ts.map +1 -0
  832. package/lib/util/cloneWithReplacements.js +34 -0
  833. package/lib/util/cloneWithReplacements.js.map +1 -0
  834. package/lib/util/idAllocator.d.ts.map +1 -1
  835. package/lib/util/idAllocator.js +1 -2
  836. package/lib/util/idAllocator.js.map +1 -1
  837. package/lib/util/index.d.ts +2 -1
  838. package/lib/util/index.d.ts.map +1 -1
  839. package/lib/util/index.js +2 -1
  840. package/lib/util/index.js.map +1 -1
  841. package/lib/util/referenceCounting.d.ts +18 -0
  842. package/lib/util/referenceCounting.d.ts.map +1 -1
  843. package/lib/util/referenceCounting.js.map +1 -1
  844. package/lib/util/typeCheck.d.ts +7 -0
  845. package/lib/util/typeCheck.d.ts.map +1 -1
  846. package/lib/util/typeCheck.js.map +1 -1
  847. package/lib/util/utils.d.ts +0 -1
  848. package/lib/util/utils.d.ts.map +1 -1
  849. package/lib/util/utils.js +0 -2
  850. package/lib/util/utils.js.map +1 -1
  851. package/package.json +37 -27
  852. package/src/codec/codec.ts +2 -2
  853. package/src/codec/discriminatedUnions.ts +2 -2
  854. package/src/core/forest/editableForest.ts +1 -52
  855. package/src/core/forest/forest.ts +17 -2
  856. package/src/core/forest/index.ts +0 -1
  857. package/src/core/index.ts +4 -2
  858. package/src/core/rebase/utils.ts +1 -1
  859. package/src/core/schema-stored/schema.ts +6 -2
  860. package/src/core/tree/anchorSet.ts +42 -12
  861. package/src/core/tree/delta.ts +8 -25
  862. package/src/core/tree/deltaUtil.ts +5 -5
  863. package/src/core/tree/index.ts +4 -1
  864. package/src/core/tree/pathTree.ts +72 -1
  865. package/src/core/tree/treeTextFormat.ts +1 -1
  866. package/src/core/tree/visitDelta.ts +38 -17
  867. package/src/core/tree/visitorUtils.ts +22 -36
  868. package/src/feature-libraries/chunked-forest/basicChunk.ts +3 -3
  869. package/src/feature-libraries/chunked-forest/chunkTree.ts +20 -9
  870. package/src/feature-libraries/chunked-forest/chunkedForest.ts +10 -6
  871. package/src/feature-libraries/chunked-forest/codec/README.md +3 -3
  872. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +1 -1
  873. package/src/feature-libraries/chunked-forest/codec/codecs.ts +1 -1
  874. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +3 -3
  875. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +2 -2
  876. package/src/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.ts → schemaBasedEncode.ts} +1 -2
  877. package/src/feature-libraries/chunked-forest/emptyChunk.ts +1 -1
  878. package/src/feature-libraries/chunked-forest/uniformChunk.ts +5 -4
  879. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +21 -38
  880. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
  881. package/src/feature-libraries/default-schema/index.ts +2 -0
  882. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +68 -0
  883. package/src/feature-libraries/default-schema/schemaChecker.ts +1 -2
  884. package/src/feature-libraries/deltaUtils.ts +1 -1
  885. package/src/feature-libraries/flex-tree/context.ts +4 -4
  886. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -2
  887. package/src/feature-libraries/flex-tree/lazyField.ts +21 -12
  888. package/src/feature-libraries/flex-tree/lazyNode.ts +2 -2
  889. package/src/feature-libraries/forest-summary/forestSummarizer.ts +5 -9
  890. package/src/feature-libraries/index.ts +10 -8
  891. package/src/feature-libraries/indexing/anchorTreeIndex.ts +4 -4
  892. package/src/feature-libraries/initializeForest.ts +55 -0
  893. package/src/feature-libraries/modular-schema/comparison.ts +2 -2
  894. package/src/feature-libraries/modular-schema/isNeverTree.ts +1 -2
  895. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +1 -2
  896. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +13 -30
  897. package/src/feature-libraries/node-identifier/README.md +11 -0
  898. package/src/feature-libraries/node-identifier/index.ts +17 -0
  899. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +59 -0
  900. package/src/feature-libraries/node-identifier/nodeIdentifier.ts +50 -0
  901. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +95 -0
  902. package/src/feature-libraries/object-forest/objectForest.ts +11 -5
  903. package/src/feature-libraries/schema-index/codec.ts +2 -1
  904. package/src/feature-libraries/sequence-field/compose.ts +2 -2
  905. package/src/feature-libraries/sequence-field/invert.ts +2 -2
  906. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +2 -2
  907. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +2 -2
  908. package/src/feature-libraries/sequence-field/utils.ts +2 -2
  909. package/src/feature-libraries/treeCursorUtils.ts +2 -3
  910. package/src/index.ts +43 -13
  911. package/src/jsonDomainSchema.ts +30 -11
  912. package/src/packageVersion.ts +1 -1
  913. package/src/shared-tree/checkoutFlexTreeView.ts +2 -2
  914. package/src/shared-tree/independentView.ts +5 -29
  915. package/src/shared-tree/index.ts +1 -0
  916. package/src/shared-tree/schematizeTree.ts +5 -4
  917. package/src/shared-tree/schematizingTreeView.ts +3 -3
  918. package/src/shared-tree/sharedTree.ts +29 -19
  919. package/src/shared-tree/sharedTreeChangeFamily.ts +1 -3
  920. package/src/shared-tree/sharedTreeEditBuilder.ts +5 -11
  921. package/src/shared-tree/treeApiAlpha.ts +45 -85
  922. package/src/shared-tree/treeCheckout.ts +4 -10
  923. package/src/shared-tree-core/branch.ts +5 -3
  924. package/src/shared-tree-core/editManager.ts +37 -45
  925. package/src/sharedTreeAttributes.ts +25 -0
  926. package/src/simple-tree/api/conciseTree.ts +25 -8
  927. package/src/simple-tree/api/create.ts +3 -3
  928. package/src/simple-tree/api/customTree.ts +60 -17
  929. package/src/simple-tree/api/getJsonSchema.ts +10 -0
  930. package/src/simple-tree/api/getSimpleSchema.ts +14 -44
  931. package/src/simple-tree/api/index.ts +17 -12
  932. package/src/simple-tree/api/schemaCreationUtilities.ts +1 -2
  933. package/src/simple-tree/api/schemaFactory.ts +179 -118
  934. package/src/simple-tree/api/schemaFactoryAlpha.ts +74 -67
  935. package/src/simple-tree/api/schemaFactoryRecursive.ts +44 -12
  936. package/src/simple-tree/api/schemaFromSimple.ts +96 -0
  937. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +7 -7
  938. package/src/simple-tree/api/simpleTreeIndex.ts +2 -1
  939. package/src/simple-tree/api/tree.ts +16 -11
  940. package/src/simple-tree/api/treeNodeApi.ts +5 -18
  941. package/src/simple-tree/api/typesUnsafe.ts +166 -48
  942. package/src/simple-tree/api/verboseTree.ts +45 -57
  943. package/src/simple-tree/api/view.ts +1 -2
  944. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +80 -185
  945. package/src/simple-tree/arrayNode.ts +20 -14
  946. package/src/simple-tree/arrayNodeTypes.ts +93 -0
  947. package/src/simple-tree/core/getOrCreateNode.ts +3 -13
  948. package/src/simple-tree/core/index.ts +1 -1
  949. package/src/simple-tree/core/treeNodeKernel.ts +32 -18
  950. package/src/simple-tree/core/treeNodeSchema.ts +14 -8
  951. package/src/simple-tree/core/unhydratedFlexTree.ts +4 -4
  952. package/src/simple-tree/flexList.ts +4 -14
  953. package/src/simple-tree/index.ts +36 -9
  954. package/src/simple-tree/leafNodeSchema.ts +28 -7
  955. package/src/simple-tree/mapNode.ts +13 -11
  956. package/src/simple-tree/mapNodeTypes.ts +90 -0
  957. package/src/simple-tree/objectNode.ts +40 -13
  958. package/src/simple-tree/objectNodeTypes.ts +21 -16
  959. package/src/simple-tree/proxies.ts +2 -2
  960. package/src/simple-tree/schemaTypes.ts +153 -23
  961. package/src/simple-tree/{api/simpleSchema.ts → simpleSchema.ts} +67 -28
  962. package/src/simple-tree/toMapTree.ts +8 -8
  963. package/src/simple-tree/toStoredSchema.ts +4 -7
  964. package/src/simple-tree/treeNodeValid.ts +17 -7
  965. package/src/treeFactory.ts +1 -19
  966. package/src/util/cloneWithReplacements.ts +41 -0
  967. package/src/util/idAllocator.ts +1 -3
  968. package/src/util/index.ts +2 -1
  969. package/src/util/referenceCounting.ts +18 -1
  970. package/src/util/typeCheck.ts +7 -0
  971. package/src/util/utils.ts +0 -3
  972. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
  973. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
  974. package/dist/feature-libraries/node-key/index.d.ts +0 -8
  975. package/dist/feature-libraries/node-key/index.d.ts.map +0 -1
  976. package/dist/feature-libraries/node-key/index.js +0 -16
  977. package/dist/feature-libraries/node-key/index.js.map +0 -1
  978. package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
  979. package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
  980. package/dist/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
  981. package/dist/feature-libraries/node-key/nodeKey.d.ts +0 -38
  982. package/dist/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
  983. package/dist/feature-libraries/node-key/nodeKey.js +0 -26
  984. package/dist/feature-libraries/node-key/nodeKey.js.map +0 -1
  985. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
  986. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
  987. package/dist/feature-libraries/node-key/nodeKeyManager.js +0 -48
  988. package/dist/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
  989. package/dist/simple-tree/api/simpleSchema.d.ts.map +0 -1
  990. package/dist/simple-tree/api/simpleSchema.js.map +0 -1
  991. package/dist/simple-tree/core/schemaCaching.d.ts +0 -16
  992. package/dist/simple-tree/core/schemaCaching.d.ts.map +0 -1
  993. package/dist/simple-tree/core/schemaCaching.js +0 -32
  994. package/dist/simple-tree/core/schemaCaching.js.map +0 -1
  995. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
  996. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
  997. package/lib/feature-libraries/node-key/index.d.ts +0 -8
  998. package/lib/feature-libraries/node-key/index.d.ts.map +0 -1
  999. package/lib/feature-libraries/node-key/index.js +0 -8
  1000. package/lib/feature-libraries/node-key/index.js.map +0 -1
  1001. package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
  1002. package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
  1003. package/lib/feature-libraries/node-key/mockNodeKeyManager.js +0 -45
  1004. package/lib/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
  1005. package/lib/feature-libraries/node-key/nodeKey.d.ts +0 -38
  1006. package/lib/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
  1007. package/lib/feature-libraries/node-key/nodeKey.js +0 -22
  1008. package/lib/feature-libraries/node-key/nodeKey.js.map +0 -1
  1009. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
  1010. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
  1011. package/lib/feature-libraries/node-key/nodeKeyManager.js +0 -43
  1012. package/lib/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
  1013. package/lib/simple-tree/api/simpleSchema.d.ts.map +0 -1
  1014. package/lib/simple-tree/api/simpleSchema.js.map +0 -1
  1015. package/lib/simple-tree/core/schemaCaching.d.ts +0 -16
  1016. package/lib/simple-tree/core/schemaCaching.d.ts.map +0 -1
  1017. package/lib/simple-tree/core/schemaCaching.js +0 -27
  1018. package/lib/simple-tree/core/schemaCaching.js.map +0 -1
  1019. package/prettier.config.cjs +0 -8
  1020. package/src/feature-libraries/node-key/README.md +0 -11
  1021. package/src/feature-libraries/node-key/index.ts +0 -17
  1022. package/src/feature-libraries/node-key/mockNodeKeyManager.ts +0 -54
  1023. package/src/feature-libraries/node-key/nodeKey.ts +0 -47
  1024. package/src/feature-libraries/node-key/nodeKeyManager.ts +0 -93
  1025. package/src/simple-tree/core/schemaCaching.ts +0 -35
  1026. /package/dist/simple-tree/{api/simpleSchema.js → simpleSchema.js} +0 -0
  1027. /package/lib/simple-tree/{api/simpleSchema.js → simpleSchema.js} +0 -0
@@ -2,75 +2,97 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { ValueSchema } from "../../core/index.js";
6
- import type { NodeKind } from "../core/index.js";
7
- import type { FieldKind, FieldSchemaMetadata, NodeSchemaMetadata } from "../schemaTypes.js";
5
+ import type { ValueSchema } from "../core/index.js";
6
+ import type { NodeKind } from "./core/index.js";
7
+ import type { FieldKind, FieldSchemaMetadata, NodeSchemaMetadata } from "./schemaTypes.js";
8
8
  /**
9
- * Base interface for all {@link SimpleNodeSchema} implementations.
10
- *
11
- * @internal
9
+ * Base interface for {@link TreeNodeSchema} and {@link SimpleNodeSchema} types.
10
+ * Once simple schema is stable this doesn't have a reason to be kept `@system`, but it could be.
11
+ * @system
12
+ * @public
12
13
  * @sealed
13
14
  */
14
- export interface SimpleNodeSchemaBase<TNodeKind extends NodeKind> {
15
+ export interface SimpleNodeSchemaBase<out TNodeKind extends NodeKind, out TCustomMetadata = unknown> {
15
16
  /**
16
- * The kind of {@link SimpleNodeSchema}.
17
+ * The {@link NodeKind}.
17
18
  *
18
19
  * @remarks can be used to type-switch between implementations.
19
20
  */
20
21
  readonly kind: TNodeKind;
21
22
  /**
22
- * {@inheritDoc NodeSchemaMetadata}
23
+ * User-provided {@link NodeSchemaMetadata} for this schema.
23
24
  */
24
- readonly metadata?: NodeSchemaMetadata | undefined;
25
+ readonly metadata: NodeSchemaMetadata<TCustomMetadata>;
25
26
  }
26
27
  /**
27
28
  * A {@link SimpleNodeSchema} for an object node.
28
29
  *
29
- * @internal
30
+ * @alpha
30
31
  * @sealed
31
32
  */
32
- export interface SimpleObjectNodeSchema extends SimpleNodeSchemaBase<NodeKind.Object> {
33
+ export interface SimpleObjectNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBase<NodeKind.Object, TCustomMetadata> {
33
34
  /**
34
35
  * Schemas for each of the object's fields, keyed off of schema's keys.
35
36
  * @remarks
36
- * Depending on how this schema was exported, the string keys may be either the property keys or the stored keys.
37
+ * The keys are the property keys if known, otherwise they are the stored keys.
38
+ * Use {@link SimpleObjectFieldSchema.storedKey} to get the stored key.
39
+ * @privateRemarks
40
+ * TODO: Provide and link a way to translate from stored keys to the property keys.
41
+ * TODO: Consider adding `storedKeysToFields` or something similar to reduce confusion,
42
+ * especially if/when TreeNodeSchema for objects provide more maps.
43
+ */
44
+ readonly fields: ReadonlyMap<string, SimpleObjectFieldSchema>;
45
+ }
46
+ /**
47
+ * A {@link SimpleFieldSchema} for an {@link SimpleObjectNodeSchema} field.
48
+ * @remarks
49
+ * The only other case fields are uses in the root schema.
50
+ *
51
+ * @alpha
52
+ * @sealed
53
+ */
54
+ export interface SimpleObjectFieldSchema extends SimpleFieldSchema {
55
+ /**
56
+ * The stored key of the field.
57
+ * @remarks
58
+ * See {@link FieldProps.key} for more information.
37
59
  */
38
- readonly fields: Record<string, SimpleFieldSchema>;
60
+ readonly storedKey: string;
39
61
  }
40
62
  /**
41
63
  * A {@link SimpleNodeSchema} for an array node.
42
64
  *
43
- * @internal
65
+ * @alpha
44
66
  * @sealed
45
67
  */
46
- export interface SimpleArrayNodeSchema extends SimpleNodeSchemaBase<NodeKind.Array> {
68
+ export interface SimpleArrayNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBase<NodeKind.Array, TCustomMetadata> {
47
69
  /**
48
70
  * The types allowed in the array.
49
71
  *
50
72
  * @remarks Refers to the types by identifier.
51
73
  * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
52
74
  */
53
- readonly allowedTypes: ReadonlySet<string>;
75
+ readonly allowedTypesIdentifiers: ReadonlySet<string>;
54
76
  }
55
77
  /**
56
78
  * A {@link SimpleNodeSchema} for a map node.
57
79
  *
58
- * @internal
80
+ * @alpha
59
81
  * @sealed
60
82
  */
61
- export interface SimpleMapNodeSchema extends SimpleNodeSchemaBase<NodeKind.Map> {
83
+ export interface SimpleMapNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBase<NodeKind.Map, TCustomMetadata> {
62
84
  /**
63
85
  * The types allowed as values in the map.
64
86
  *
65
87
  * @remarks Refers to the types by identifier.
66
88
  * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
67
89
  */
68
- readonly allowedTypes: ReadonlySet<string>;
90
+ readonly allowedTypesIdentifiers: ReadonlySet<string>;
69
91
  }
70
92
  /**
71
93
  * A {@link SimpleNodeSchema} for a leaf node.
72
94
  *
73
- * @internal
95
+ * @alpha
74
96
  * @sealed
75
97
  */
76
98
  export interface SimpleLeafNodeSchema extends SimpleNodeSchemaBase<NodeKind.Leaf> {
@@ -86,7 +108,12 @@ export interface SimpleLeafNodeSchema extends SimpleNodeSchemaBase<NodeKind.Leaf
86
108
  * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which
87
109
  * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.
88
110
  *
89
- * @internal
111
+ * Note that, as documented on {@link NodeKind}, more kinds of nodes may be added,
112
+ * and therefore code should not assume that switching over all these cases can be done exhaustively.
113
+ * @privateRemarks
114
+ * Because of the above mentioned extensibility of node kinds, does it make sense to stabilize this?
115
+ *
116
+ * @alpha
90
117
  */
91
118
  export type SimpleNodeSchema = SimpleLeafNodeSchema | SimpleMapNodeSchema | SimpleArrayNodeSchema | SimpleObjectNodeSchema;
92
119
  /**
@@ -96,7 +123,7 @@ export type SimpleNodeSchema = SimpleLeafNodeSchema | SimpleMapNodeSchema | Simp
96
123
  * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which
97
124
  * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.
98
125
  *
99
- * @internal
126
+ * @alpha
100
127
  * @sealed
101
128
  */
102
129
  export interface SimpleFieldSchema {
@@ -110,11 +137,11 @@ export interface SimpleFieldSchema {
110
137
  * @remarks Refers to the types by identifier.
111
138
  * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
112
139
  */
113
- readonly allowedTypes: ReadonlySet<string>;
140
+ readonly allowedTypesIdentifiers: ReadonlySet<string>;
114
141
  /**
115
142
  * {@inheritDoc FieldSchemaMetadata}
116
143
  */
117
- readonly metadata?: FieldSchemaMetadata | undefined;
144
+ readonly metadata: FieldSchemaMetadata;
118
145
  }
119
146
  /**
120
147
  * A simplified representation of a schema for a tree.
@@ -122,7 +149,7 @@ export interface SimpleFieldSchema {
122
149
  * @remarks Contains the complete set of schema {@link SimpleTreeSchema.definitions} required to resolve references,
123
150
  * which are represented inline with identifiers.
124
151
  *
125
- * @internal
152
+ * @alpha
126
153
  * @sealed
127
154
  */
128
155
  export interface SimpleTreeSchema extends SimpleFieldSchema {
@@ -136,9 +163,9 @@ export interface SimpleTreeSchema extends SimpleFieldSchema {
136
163
  * @remarks Refers to the types by identifier.
137
164
  * Can be resolved via {@link SimpleTreeSchema.definitions}.
138
165
  */
139
- readonly allowedTypes: ReadonlySet<string>;
166
+ readonly allowedTypesIdentifiers: ReadonlySet<string>;
140
167
  /**
141
- * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.allowedTypes}.
168
+ * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.allowedTypesIdentifiers}.
142
169
  *
143
170
  * @remarks the keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.
144
171
  */
@@ -0,0 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GAAG,OAAO,CACjE,SAAQ,oBAAoB,CAAC,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC;IAC3D;;;;;OAKG;IACH,QAAQ,CAAC,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACtD;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC;IAChF;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,gBAAgB,GACzB,oBAAoB,GACpB,mBAAmB,GACnB,qBAAqB,GACrB,sBAAsB,CAAC;AAE1B;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAEzB;;;;;OAKG;IACH,QAAQ,CAAC,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAEtD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;CACvC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IAC1D;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAEzB;;;;;OAKG;IACH,QAAQ,CAAC,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAEtD;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC5D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simpleSchema.js","sourceRoot":"","sources":["../../src/simple-tree/simpleSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ValueSchema } from \"../core/index.js\";\nimport type { NodeKind } from \"./core/index.js\";\nimport type { FieldKind, FieldSchemaMetadata, NodeSchemaMetadata } from \"./schemaTypes.js\";\n\n/*\n * TODO:\n * - Customize their JSON serialization to use these formats or provide some other serialization scheme.\n */\n\n/**\n * Base interface for {@link TreeNodeSchema} and {@link SimpleNodeSchema} types.\n * Once simple schema is stable this doesn't have a reason to be kept `@system`, but it could be.\n * @system\n * @public\n * @sealed\n */\nexport interface SimpleNodeSchemaBase<\n\tout TNodeKind extends NodeKind,\n\tout TCustomMetadata = unknown,\n> {\n\t/**\n\t * The {@link NodeKind}.\n\t *\n\t * @remarks can be used to type-switch between implementations.\n\t */\n\treadonly kind: TNodeKind;\n\n\t/**\n\t * User-provided {@link NodeSchemaMetadata} for this schema.\n\t */\n\treadonly metadata: NodeSchemaMetadata<TCustomMetadata>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for an object node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleObjectNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBase<NodeKind.Object, TCustomMetadata> {\n\t/**\n\t * Schemas for each of the object's fields, keyed off of schema's keys.\n\t * @remarks\n\t * The keys are the property keys if known, otherwise they are the stored keys.\n\t * Use {@link SimpleObjectFieldSchema.storedKey} to get the stored key.\n\t * @privateRemarks\n\t * TODO: Provide and link a way to translate from stored keys to the property keys.\n\t * TODO: Consider adding `storedKeysToFields` or something similar to reduce confusion,\n\t * especially if/when TreeNodeSchema for objects provide more maps.\n\t */\n\treadonly fields: ReadonlyMap<string, SimpleObjectFieldSchema>;\n}\n\n/**\n * A {@link SimpleFieldSchema} for an {@link SimpleObjectNodeSchema} field.\n * @remarks\n * The only other case fields are uses in the root schema.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleObjectFieldSchema extends SimpleFieldSchema {\n\t/**\n\t * The stored key of the field.\n\t * @remarks\n\t * See {@link FieldProps.key} for more information.\n\t */\n\treadonly storedKey: string;\n}\n\n/**\n * A {@link SimpleNodeSchema} for an array node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleArrayNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBase<NodeKind.Array, TCustomMetadata> {\n\t/**\n\t * The types allowed in the array.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a map node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleMapNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBase<NodeKind.Map, TCustomMetadata> {\n\t/**\n\t * The types allowed as values in the map.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a leaf node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleLeafNodeSchema extends SimpleNodeSchemaBase<NodeKind.Leaf> {\n\t/**\n\t * The kind of leaf node.\n\t */\n\treadonly leafKind: ValueSchema;\n}\n\n/**\n * A simple, shallow representation of a schema for a node.\n *\n * @remarks This definition is incomplete, and references child types by identifiers.\n * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which\n * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.\n *\n * Note that, as documented on {@link NodeKind}, more kinds of nodes may be added,\n * and therefore code should not assume that switching over all these cases can be done exhaustively.\n * @privateRemarks\n * Because of the above mentioned extensibility of node kinds, does it make sense to stabilize this?\n *\n * @alpha\n */\nexport type SimpleNodeSchema =\n\t| SimpleLeafNodeSchema\n\t| SimpleMapNodeSchema\n\t| SimpleArrayNodeSchema\n\t| SimpleObjectNodeSchema;\n\n/**\n * A simple, shallow representation of a schema for a field.\n *\n * @remarks This definition is incomplete, and references child types by identifiers.\n * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which\n * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleFieldSchema {\n\t/**\n\t * The kind of tree field.\n\t */\n\treadonly kind: FieldKind;\n\n\t/**\n\t * The types allowed under the field.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n\n\t/**\n\t * {@inheritDoc FieldSchemaMetadata}\n\t */\n\treadonly metadata: FieldSchemaMetadata;\n}\n\n/**\n * A simplified representation of a schema for a tree.\n *\n * @remarks Contains the complete set of schema {@link SimpleTreeSchema.definitions} required to resolve references,\n * which are represented inline with identifiers.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleTreeSchema extends SimpleFieldSchema {\n\t/**\n\t * The kind of tree field representing the root of the tree.\n\t */\n\treadonly kind: FieldKind;\n\n\t/**\n\t * The types allowed under the tree root.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * Can be resolved via {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n\n\t/**\n\t * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.allowedTypesIdentifiers}.\n\t *\n\t * @remarks the keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.\n\t */\n\treadonly definitions: ReadonlyMap<string, SimpleNodeSchema>;\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { type SchemaAndPolicy, type ExclusiveMapTree } from "../core/index.js";
6
- import { type NodeKeyManager } from "../feature-libraries/index.js";
6
+ import { type NodeIdentifierManager } from "../feature-libraries/index.js";
7
7
  import { type ImplicitAllowedTypes, type ImplicitFieldSchema } from "./schemaTypes.js";
8
8
  import { type TreeNode, type TreeNodeSchema, type Unhydrated } from "./core/index.js";
9
9
  import { SchemaValidationErrors } from "../feature-libraries/index.js";
@@ -57,8 +57,8 @@ import type { IFluidHandle } from "@fluidframework/core-interfaces";
57
57
  * 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,
58
58
  * as well as ensuring validation happens after defaulting (or can handle validating data missing defaults)
59
59
  */
60
- export declare function mapTreeFromNodeData(data: InsertableContent, allowedTypes: ImplicitAllowedTypes, context?: NodeKeyManager, schemaValidationPolicy?: SchemaAndPolicy): ExclusiveMapTree;
61
- export declare function mapTreeFromNodeData(data: InsertableContent | undefined, allowedTypes: ImplicitFieldSchema, context?: NodeKeyManager, schemaValidationPolicy?: SchemaAndPolicy): ExclusiveMapTree | undefined;
60
+ export declare function mapTreeFromNodeData(data: InsertableContent, allowedTypes: ImplicitAllowedTypes, context?: NodeIdentifierManager, schemaValidationPolicy?: SchemaAndPolicy): ExclusiveMapTree;
61
+ export declare function mapTreeFromNodeData(data: InsertableContent | undefined, allowedTypes: ImplicitFieldSchema, context?: NodeIdentifierManager, schemaValidationPolicy?: SchemaAndPolicy): ExclusiveMapTree | undefined;
62
62
  /**
63
63
  * Throws a UsageError if maybeError indicates a tree is out of schema.
64
64
  */
@@ -76,7 +76,7 @@ export declare function getPossibleTypes(allowedTypes: ReadonlySet<TreeNodeSchem
76
76
  * If absent, only defaults produced by a {@link ConstantFieldProvider} will be provided, and defaults produced by a {@link ContextualFieldProvider} will be ignored.
77
77
  * @remarks This function mutates the input tree by deeply adding new fields to the field maps where applicable.
78
78
  */
79
- export declare function addDefaultsToMapTree(mapTree: ExclusiveMapTree, allowedTypes: ImplicitAllowedTypes, context: NodeKeyManager | undefined): void;
79
+ export declare function addDefaultsToMapTree(mapTree: ExclusiveMapTree, allowedTypes: ImplicitAllowedTypes, context: NodeIdentifierManager | undefined): void;
80
80
  /**
81
81
  * Content which can be used to build a node.
82
82
  * @remarks
@@ -1 +1 @@
1
- {"version":3,"file":"toMapTree.d.ts","sourceRoot":"","sources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gB,mBAAmB,CAClC,IAAI,EAAE,iBAAiB,GAAG,SAAS,EACnC,YAAY,EAAE,mBAAmB,EACjC,OAAO,CAAC,EAAE,qBAAqB,EAC/B,sBAAsB,CAAC,EAAE,eAAe,GACtC,gBAAgB,GAAG,SAAS,CAAC;AA0FhC;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAIxE;AAgRD;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,EACzC,IAAI,EAAE,cAAc,GAClB,cAAc,EAAE,CAclB;AA6HD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,gBAAgB,EACzB,YAAY,EAAE,oBAAoB,EAClC,OAAO,EAAE,qBAAqB,GAAG,SAAS,GACxC,IAAI,CA8CN;AAqCD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACvB,YAAY,GACZ,MAAM,GACN,MAAM,GACN,OAAO,GAEP,IAAI,GACJ,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAC9C,SAAS,iBAAiB,EAAE,GAC5B,oBAAoB,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,iBAAiB;CAC1C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC"}
@@ -85,7 +85,7 @@ function nodeDataToMapTree(data, allowedTypes) {
85
85
  result = objectToMapTree(data, schema);
86
86
  break;
87
87
  default:
88
- (0, index_js_3.fail)(0xae0 /* Unrecognized schema kind */);
88
+ (0, internal_1.fail)(0xae0 /* Unrecognized schema kind */);
89
89
  }
90
90
  return result;
91
91
  }
@@ -441,7 +441,7 @@ function allowsValue(schema, value) {
441
441
  */
442
442
  function addDefaultsToMapTree(mapTree, allowedTypes, context) {
443
443
  const schema = (0, index_js_3.find)((0, schemaTypes_js_1.normalizeAllowedTypes)(allowedTypes), (s) => s.identifier === mapTree.type) ??
444
- (0, index_js_3.fail)(0xae1 /* MapTree is incompatible with schema */);
444
+ (0, internal_1.fail)(0xae1 /* MapTree is incompatible with schema */);
445
445
  if ((0, objectNodeTypes_js_1.isObjectNodeSchema)(schema)) {
446
446
  for (const [_key, fieldInfo] of schema.flexKeyMap) {
447
447
  const field = mapTree.fields.get(fieldInfo.storedKey);
@@ -459,7 +459,7 @@ function addDefaultsToMapTree(mapTree, allowedTypes, context) {
459
459
  setFieldValue(mapTree.fields, data, fieldInfo.schema, fieldInfo.storedKey);
460
460
  // call addDefaultsToMapTree on newly inserted default values
461
461
  for (const child of mapTree.fields.get(fieldInfo.storedKey) ??
462
- (0, index_js_3.fail)(0xae2 /* Expected field to be populated */)) {
462
+ (0, internal_1.fail)(0xae2 /* Expected field to be populated */)) {
463
463
  addDefaultsToMapTree(child, fieldInfo.schema.allowedTypes, context);
464
464
  }
465
465
  }
@@ -1 +1 @@
1
- {"version":3,"file":"toMapTree.js","sourceRoot":"","sources":["../../src/simple-tree/toMapTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AACtE,qEAAuE;AAEvE,+CAQ0B;AAC1B,4DAIuC;AACvC,+CAA0F;AAE1F,2DAAiD;AACjD,qDAW0B;AAC1B,8CAUyB;AACzB,4DAAuF;AACvF,6DAA0D;AAiE1D,SAAgB,mBAAmB,CAClC,IAAmC,EACnC,YAAiC,EACjC,OAAwB,EACxB,sBAAwC;IAExC,MAAM,qBAAqB,GAAG,IAAA,qCAAoB,EAAC,YAAY,CAAC,CAAC;IAEjE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,+CAA+C;QAC/C,IAAI,qBAAqB,CAAC,IAAI,KAAK,0BAAS,CAAC,QAAQ,EAAE,CAAC;YACvD,MAAM,IAA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AM,CAAC;YACP,6GAA6G;YAC7G,sHAAsH;QACvH,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,MAAe;IACvC,IAAI,IAAA,qBAAU,EAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,IAAA,oBAAS,EAAC,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(0xae0 /* Unrecognized 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(0xae1 /* 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(0xae2 /* 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,kEAAmE;AACnE,uEAAsE;AACtE,qEAAuE;AAEvE,+CAQ0B;AAC1B,4DAIuC;AACvC,+CAAoF;AAEpF,2DAAiD;AACjD,qDAW0B;AAC1B,8CAUyB;AACzB,4DAAuF;AACvF,6DAA0D;AAiE1D,SAAgB,mBAAmB,CAClC,IAAmC,EACnC,YAAiC,EACjC,OAA+B,EAC/B,sBAAwC;IAExC,MAAM,qBAAqB,GAAG,IAAA,qCAAoB,EAAC,YAAY,CAAC,CAAC;IAEjE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,+CAA+C;QAC/C,IAAI,qBAAqB,CAAC,IAAI,KAAK,0BAAS,CAAC,QAAQ,EAAE,CAAC;YACvD,MAAM,IAAI,qBAAU,CAAC,uC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A6G;YAC7G,sHAAsH;QACvH,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,MAAe;IACvC,IAAI,IAAA,qBAAU,EAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,IAAA,oBAAS,EAAC,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, fail } 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 NodeIdentifierManager,\n} from \"../feature-libraries/index.js\";\nimport { brand, 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?: NodeIdentifierManager,\n\tschemaValidationPolicy?: SchemaAndPolicy,\n): ExclusiveMapTree;\nexport function mapTreeFromNodeData(\n\tdata: InsertableContent | undefined,\n\tallowedTypes: ImplicitFieldSchema,\n\tcontext?: NodeIdentifierManager,\n\tschemaValidationPolicy?: SchemaAndPolicy,\n): ExclusiveMapTree | undefined;\nexport function mapTreeFromNodeData(\n\tdata: InsertableContent | undefined,\n\tallowedTypes: ImplicitFieldSchema,\n\tcontext?: NodeIdentifierManager,\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(0xae0 /* Unrecognized 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: NodeIdentifierManager | undefined,\n): void {\n\tconst schema =\n\t\tfind(normalizeAllowedTypes(allowedTypes), (s) => s.identifier === mapTree.type) ??\n\t\tfail(0xae1 /* 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(0xae2 /* 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: NodeIdentifierManager | 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 +1 @@
1
- {"version":3,"file":"toStoredSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAON,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAGN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,MAAM,kBAAkB,CAAC;AAQ1B;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,mBAAmB,GAAG,gBAAgB,CAwB1E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,qBAAqB,CAa/E;AAQD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,oBAAoB,GAAG,WAAW,CAK7E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,oBAAoB,CAgC5E"}
1
+ {"version":3,"file":"toStoredSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAON,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,MAAM,kBAAkB,CAAC;AAO1B;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,mBAAmB,GAAG,gBAAgB,CAwB1E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,qBAAqB,CAa/E;AAQD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,oBAAoB,GAAG,WAAW,CAE7E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,oBAAoB,CAgC5E"}
@@ -15,7 +15,6 @@ const schemaTypes_js_1 = require("./schemaTypes.js");
15
15
  const walkFieldSchema_js_1 = require("./walkFieldSchema.js");
16
16
  const leafNodeSchema_js_1 = require("./leafNodeSchema.js");
17
17
  const objectNodeTypes_js_1 = require("./objectNodeTypes.js");
18
- const flexList_js_1 = require("./flexList.js");
19
18
  const viewToStoredCache = new WeakMap();
20
19
  /**
21
20
  * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.
@@ -49,7 +48,7 @@ function convertField(schema) {
49
48
  let allowedTypes;
50
49
  if (schema instanceof schemaTypes_js_1.FieldSchema) {
51
50
  kind =
52
- convertFieldKind.get(schema.kind)?.identifier ?? (0, index_js_3.fail)(0xae3 /* Invalid field kind */);
51
+ convertFieldKind.get(schema.kind)?.identifier ?? (0, internal_1.fail)(0xae3 /* Invalid field kind */);
53
52
  allowedTypes = schema.allowedTypes;
54
53
  }
55
54
  else {
@@ -69,10 +68,7 @@ const convertFieldKind = new Map([
69
68
  * Normalizes an {@link ImplicitAllowedTypes} into an {@link TreeTypeSet}.
70
69
  */
71
70
  function convertAllowedTypes(schema) {
72
- if ((0, index_js_3.isReadonlyArray)(schema)) {
73
- return new Set((0, flexList_js_1.normalizeFlexListEager)(schema).map((item) => (0, index_js_3.brand)(item.identifier)));
74
- }
75
- return new Set([(0, index_js_3.brand)(schema.identifier)]);
71
+ return new Set([...(0, schemaTypes_js_1.normalizeAllowedTypes)(schema)].map((item) => (0, index_js_3.brand)(item.identifier)));
76
72
  }
77
73
  exports.convertAllowedTypes = convertAllowedTypes;
78
74
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAC9E,uEAAsE;AAEtE,+CAY0B;AAC1B,4DAA+E;AAC/E,+CAA6E;AAC7E,8CAAgE;AAChE,qDAK0B;AAC1B,6DAAuD;AACvD,2DAAqD;AACrD,6DAA0D;AAC1D,+CAAuD;AAEvD,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAyC,CAAC;AAE/E;;GAEG;AACH,SAAgB,cAAc,CAAC,IAAyB;IACvD,OAAO,IAAA,sBAAW,EAAC,iBAAiB,EAAE,IAAI,EAAE,GAAG,EAAE;QAChD,MAAM,UAAU,GAAwD,IAAI,GAAG,EAAE,CAAC;QAClF,IAAA,oCAAe,EAAC,IAAI,EAAE;YACrB,IAAI,CAAC,MAAM;gBACV,IAAI,UAAU,CAAC,GAAG,CAAC,IAAA,gBAAK,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;oBAC9C,4DAA4D;oBAC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IAAI,EAAE,qBAAU,CAAC,QAAQ,CAAC,UAAU;gBACpC,KAAK,EAAE,mBAAmB,CAAC,SAAS,CAAC;aACrC,CAAC;YACF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,mBAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO,IAAI,iCAAsB,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QACD,KAAK,mBAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,IAAA,iBAAM,EAAC,IAAA,uCAAkB,EAAC,MAAM,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAyC,IAAI,GAAG,EAAE,CAAC;YAC/D,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;gBAChD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,IAAI,iCAAsB,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QACD;YACC,IAAA,0BAAe,EAAC,IAAI,CAAC,CAAC;IACxB,CAAC;AACF,CAAC;AAhCD,0CAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport { brand, fail, getOrCreate, isReadonlyArray } from \"../util/index.js\";\nimport { NodeKind, type TreeNodeSchema } from \"./core/index.js\";\nimport {\n\tFieldKind,\n\tFieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n} from \"./schemaTypes.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\nimport { LeafNodeSchema } from \"./leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"./objectNodeTypes.js\";\nimport { normalizeFlexListEager } from \"./flexList.js\";\n\nconst viewToStoredCache = new WeakMap<ImplicitFieldSchema, TreeStoredSchema>();\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n */\nexport function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn getOrCreate(viewToStoredCache, root, () => {\n\t\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\t\twalkFieldSchema(root, {\n\t\t\tnode(schema) {\n\t\t\t\tif (nodeSchema.has(brand(schema.identifier))) {\n\t\t\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\t\t\tschema.identifier,\n\t\t\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tnodeSchema.set(brand(schema.identifier), getStoredSchema(schema));\n\t\t\t},\n\t\t});\n\n\t\tconst result: TreeStoredSchema = {\n\t\t\tnodeSchema,\n\t\t\trootFieldSchema: convertField(root),\n\t\t};\n\t\tviewToStoredCache.set(root, result);\n\t\treturn result;\n\t});\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(schema: ImplicitFieldSchema): TreeFieldStoredSchema {\n\tlet kind: FieldKindIdentifier;\n\tlet allowedTypes: ImplicitAllowedTypes;\n\tif (schema instanceof FieldSchema) {\n\t\tkind =\n\t\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\t\tallowedTypes = schema.allowedTypes;\n\t} else {\n\t\tkind = FieldKinds.required.identifier;\n\t\tallowedTypes = schema;\n\t}\n\tconst types = convertAllowedTypes(allowedTypes);\n\treturn { kind, types };\n}\n\nconst convertFieldKind = new Map<FieldKind, FlexFieldKind>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Normalizes an {@link ImplicitAllowedTypes} into an {@link TreeTypeSet}.\n */\nexport function convertAllowedTypes(schema: ImplicitAllowedTypes): TreeTypeSet {\n\tif (isReadonlyArray(schema)) {\n\t\treturn new Set(normalizeFlexListEager(schema).map((item) => brand(item.identifier)));\n\t}\n\treturn new Set([brand(schema.identifier)]);\n}\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n */\nexport function getStoredSchema(schema: TreeNodeSchema): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\tassert(schema instanceof LeafNodeSchema, 0xa4a /* invalid kind */);\n\t\t\treturn new LeafNodeStoredSchema(schema.info);\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\tconst types = convertAllowedTypes(fieldInfo);\n\t\t\treturn new MapNodeStoredSchema({ kind: FieldKinds.optional.identifier, types });\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\tconst field = {\n\t\t\t\tkind: FieldKinds.sequence.identifier,\n\t\t\t\ttypes: convertAllowedTypes(fieldInfo),\n\t\t\t};\n\t\t\tconst fields = new Map([[EmptyKey, field]]);\n\t\t\treturn new ObjectNodeStoredSchema(fields);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tassert(isObjectNodeSchema(schema), 0xa4b /* invalid kind */);\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const field of schema.flexKeyMap.values()) {\n\t\t\t\tfields.set(field.storedKey, convertField(field.schema));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields);\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(kind);\n\t}\n}\n"]}
1
+ {"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAoF;AACpF,uEAAsE;AAEtE,+CAY0B;AAC1B,4DAA+E;AAC/E,+CAAsD;AACtD,8CAAgE;AAChE,qDAM0B;AAC1B,6DAAuD;AACvD,2DAAqD;AACrD,6DAA0D;AAE1D,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAyC,CAAC;AAE/E;;GAEG;AACH,SAAgB,cAAc,CAAC,IAAyB;IACvD,OAAO,IAAA,sBAAW,EAAC,iBAAiB,EAAE,IAAI,EAAE,GAAG,EAAE;QAChD,MAAM,UAAU,GAAwD,IAAI,GAAG,EAAE,CAAC;QAClF,IAAA,oCAAe,EAAC,IAAI,EAAE;YACrB,IAAI,CAAC,MAAM;gBACV,IAAI,UAAU,CAAC,GAAG,CAAC,IAAA,gBAAK,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;oBAC9C,4DAA4D;oBAC5D,MAAM,IAAI,qBAAU,CACnB,mDAAmD,IAAI,CAAC,SAAS,CAChE,MAAM,CAAC,UAAU,CACjB,iDAAiD,CAClD,CAAC;gBACH,CAAC;gBACD,UAAU,CAAC,GAAG,CAAC,IAAA,gBAAK,EAAC,MAAM,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;YACnE,CAAC;SACD,CAAC,CAAC;QAEH,MAAM,MAAM,GAA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GAAyC,IAAI,GAAG,EAAE,CAAC;YAC/D,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;gBAChD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,IAAI,iCAAsB,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QACD;YACC,IAAA,0BAAe,EAAC,IAAI,CAAC,CAAC;IACxB,CAAC;AACF,CAAC;AAhCD,0CAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport { brand, getOrCreate } from \"../util/index.js\";\nimport { NodeKind, type TreeNodeSchema } from \"./core/index.js\";\nimport {\n\tFieldKind,\n\tFieldSchema,\n\tnormalizeAllowedTypes,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n} from \"./schemaTypes.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\nimport { LeafNodeSchema } from \"./leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"./objectNodeTypes.js\";\n\nconst viewToStoredCache = new WeakMap<ImplicitFieldSchema, TreeStoredSchema>();\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n */\nexport function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn getOrCreate(viewToStoredCache, root, () => {\n\t\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\t\twalkFieldSchema(root, {\n\t\t\tnode(schema) {\n\t\t\t\tif (nodeSchema.has(brand(schema.identifier))) {\n\t\t\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\t\t\tschema.identifier,\n\t\t\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tnodeSchema.set(brand(schema.identifier), getStoredSchema(schema));\n\t\t\t},\n\t\t});\n\n\t\tconst result: TreeStoredSchema = {\n\t\t\tnodeSchema,\n\t\t\trootFieldSchema: convertField(root),\n\t\t};\n\t\tviewToStoredCache.set(root, result);\n\t\treturn result;\n\t});\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(schema: ImplicitFieldSchema): TreeFieldStoredSchema {\n\tlet kind: FieldKindIdentifier;\n\tlet allowedTypes: ImplicitAllowedTypes;\n\tif (schema instanceof FieldSchema) {\n\t\tkind =\n\t\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\t\tallowedTypes = schema.allowedTypes;\n\t} else {\n\t\tkind = FieldKinds.required.identifier;\n\t\tallowedTypes = schema;\n\t}\n\tconst types = convertAllowedTypes(allowedTypes);\n\treturn { kind, types };\n}\n\nconst convertFieldKind = new Map<FieldKind, FlexFieldKind>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Normalizes an {@link ImplicitAllowedTypes} into an {@link TreeTypeSet}.\n */\nexport function convertAllowedTypes(schema: ImplicitAllowedTypes): TreeTypeSet {\n\treturn new Set([...normalizeAllowedTypes(schema)].map((item) => brand(item.identifier)));\n}\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n */\nexport function getStoredSchema(schema: TreeNodeSchema): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\tassert(schema instanceof LeafNodeSchema, 0xa4a /* invalid kind */);\n\t\t\treturn new LeafNodeStoredSchema(schema.info);\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\tconst types = convertAllowedTypes(fieldInfo);\n\t\t\treturn new MapNodeStoredSchema({ kind: FieldKinds.optional.identifier, types });\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\tconst field = {\n\t\t\t\tkind: FieldKinds.sequence.identifier,\n\t\t\t\ttypes: convertAllowedTypes(fieldInfo),\n\t\t\t};\n\t\t\tconst fields = new Map([[EmptyKey, field]]);\n\t\t\treturn new ObjectNodeStoredSchema(fields);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tassert(isObjectNodeSchema(schema), 0xa4b /* invalid kind */);\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const field of schema.flexKeyMap.values()) {\n\t\t\t\tfields.set(field.storedKey, convertField(field.schema));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields);\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(kind);\n\t}\n}\n"]}
@@ -29,6 +29,8 @@ export declare abstract class TreeNodeValid<TInput> extends TreeNode {
29
29
  /**
30
30
  * Schema classes can override to provide a callback that is called once when the first node is constructed.
31
31
  * This is a good place to perform extra validation and cache schema derived data needed for the implementation of the node.
32
+ * @remarks
33
+ * It is valid to dereference LazyItem schema references in this function (or anything that runs after it).
32
34
  */
33
35
  protected static oneTimeSetup<T>(this: typeof TreeNodeValid<T>): Context;
34
36
  /**
@@ -63,9 +65,13 @@ export declare abstract class TreeNodeValid<TInput> extends TreeNode {
63
65
  */
64
66
  static create<TInput, TOut, TThis extends new (args: TInput) => TOut>(this: TThis, input: TInput): TOut;
65
67
  /**
66
- * @see {@link TreeNodeSchemaCore.createFromInsertable}.
68
+ * See {@link TreeNodeSchemaCore.createFromInsertable}.
67
69
  */
68
70
  static createFromInsertable<TInput, TOut, TThis extends new (args: TInput) => TOut>(this: TThis, input: TInput): TOut;
71
+ /**
72
+ * Idempotent initialization function that pre-caches data and can dereference lazy schema references.
73
+ */
74
+ static oneTimeInitialize(this: typeof TreeNodeValid & TreeNodeSchema): Required<MostDerivedData>;
69
75
  constructor(input: TInput | InternalTreeNode);
70
76
  }
71
77
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeValid.d.ts","sourceRoot":"","sources":["../../src/simple-tree/treeNodeValid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,cAAc,EAKnB,QAAQ,EACR,KAAK,gBAAgB,EAGrB,KAAK,OAAO,EACZ,KAAK,sBAAsB,EAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,+BAA+B,CAAC;AAOlF;;;;;;;GAOG;AACH,8BAAsB,aAAa,CAAC,MAAM,CAAE,SAAQ,QAAQ;IAC3D;;;;;;;OAOG;IACH,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EACjC,IAAI,EAAE,OAAO,aAAa,CAAC,CAAC,CAAC,EAC7B,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,KAAK,EAAE,YAAY,GACjB,aAAa,CAAC,CAAC,CAAC;IAInB;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAC9B,IAAI,EAAE,OAAO,aAAa,CAAC,CAAC,CAAC,EAC7B,QAAQ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