@fluidframework/tree 2.20.0 → 2.22.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 (357) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +1 -0
  3. package/api-report/tree.alpha.api.md +29 -4
  4. package/api-report/tree.beta.api.md +29 -4
  5. package/api-report/tree.legacy.alpha.api.md +35 -4
  6. package/api-report/tree.legacy.public.api.md +29 -4
  7. package/api-report/tree.public.api.md +29 -4
  8. package/dist/alpha.d.ts +1 -0
  9. package/dist/beta.d.ts +1 -0
  10. package/dist/core/forest/editableForest.js +1 -1
  11. package/dist/core/forest/editableForest.js.map +1 -1
  12. package/dist/core/index.d.ts +1 -1
  13. package/dist/core/index.d.ts.map +1 -1
  14. package/dist/core/index.js.map +1 -1
  15. package/dist/core/tree/anchorSet.d.ts +2 -5
  16. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  17. package/dist/core/tree/anchorSet.js +1 -151
  18. package/dist/core/tree/anchorSet.js.map +1 -1
  19. package/dist/core/tree/index.d.ts +1 -2
  20. package/dist/core/tree/index.d.ts.map +1 -1
  21. package/dist/core/tree/index.js.map +1 -1
  22. package/dist/core/tree/pathTree.d.ts +0 -11
  23. package/dist/core/tree/pathTree.d.ts.map +1 -1
  24. package/dist/core/tree/pathTree.js.map +1 -1
  25. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  26. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  27. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  28. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  29. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +1 -2
  30. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  31. package/dist/feature-libraries/detachedFieldIndexSummarizer.js +0 -9
  32. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  33. package/dist/feature-libraries/flex-tree/treeEvents.d.ts +2 -4
  34. package/dist/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
  35. package/dist/feature-libraries/flex-tree/treeEvents.js.map +1 -1
  36. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -2
  37. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  38. package/dist/feature-libraries/forest-summary/forestSummarizer.js +0 -9
  39. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  40. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +6 -2
  41. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  42. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  43. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -4
  44. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  45. package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -19
  46. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  47. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  48. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +11 -12
  49. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  50. package/dist/feature-libraries/node-key/mockNodeKeyManager.js +1 -1
  51. package/dist/feature-libraries/node-key/mockNodeKeyManager.js.map +1 -1
  52. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  53. package/dist/feature-libraries/optional-field/optionalField.js +7 -3
  54. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  55. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +3 -5
  56. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  57. package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -11
  58. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  59. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +1 -1
  60. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  61. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -1
  62. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  63. package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  64. package/dist/feature-libraries/treeCursorUtils.js +1 -1
  65. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  66. package/dist/index.d.ts +3 -3
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +4 -2
  69. package/dist/index.js.map +1 -1
  70. package/dist/legacy.d.ts +4 -1
  71. package/dist/packageVersion.d.ts +1 -1
  72. package/dist/packageVersion.js +1 -1
  73. package/dist/packageVersion.js.map +1 -1
  74. package/dist/public.d.ts +1 -0
  75. package/dist/shared-tree/index.d.ts +1 -2
  76. package/dist/shared-tree/index.d.ts.map +1 -1
  77. package/dist/shared-tree/index.js +1 -4
  78. package/dist/shared-tree/index.js.map +1 -1
  79. package/dist/shared-tree/schematizingTreeView.d.ts +4 -5
  80. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  81. package/dist/shared-tree/schematizingTreeView.js +9 -10
  82. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  83. package/dist/shared-tree/sharedTree.d.ts +39 -39
  84. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  85. package/dist/shared-tree/sharedTree.js +81 -55
  86. package/dist/shared-tree/sharedTree.js.map +1 -1
  87. package/dist/shared-tree/treeApi.d.ts +2 -2
  88. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  89. package/dist/shared-tree/treeApi.js +9 -3
  90. package/dist/shared-tree/treeApi.js.map +1 -1
  91. package/dist/shared-tree/treeCheckout.d.ts +3 -3
  92. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  93. package/dist/shared-tree/treeCheckout.js +3 -2
  94. package/dist/shared-tree/treeCheckout.js.map +1 -1
  95. package/dist/shared-tree-core/editManager.js +1 -1
  96. package/dist/shared-tree-core/editManager.js.map +1 -1
  97. package/dist/shared-tree-core/editManagerSummarizer.d.ts +1 -2
  98. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  99. package/dist/shared-tree-core/editManagerSummarizer.js +0 -9
  100. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  101. package/dist/shared-tree-core/sequenceIdUtils.d.ts +12 -1
  102. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  103. package/dist/shared-tree-core/sequenceIdUtils.js +25 -7
  104. package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
  105. package/dist/shared-tree-core/sharedTreeCore.d.ts +25 -30
  106. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  107. package/dist/shared-tree-core/sharedTreeCore.js +20 -49
  108. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  109. package/dist/simple-tree/api/index.d.ts +3 -2
  110. package/dist/simple-tree/api/index.d.ts.map +1 -1
  111. package/dist/simple-tree/api/index.js +3 -1
  112. package/dist/simple-tree/api/index.js.map +1 -1
  113. package/dist/simple-tree/api/schemaFactory.d.ts +158 -63
  114. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  115. package/dist/simple-tree/api/schemaFactory.js +181 -86
  116. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  117. package/dist/{shared-tree → simple-tree/api}/transactionTypes.d.ts +1 -1
  118. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -0
  119. package/dist/{shared-tree → simple-tree/api}/transactionTypes.js.map +1 -1
  120. package/dist/simple-tree/api/tree.d.ts +27 -2
  121. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  122. package/dist/simple-tree/api/tree.js.map +1 -1
  123. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  124. package/dist/simple-tree/core/getOrCreateNode.js +1 -1
  125. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  126. package/dist/simple-tree/core/index.d.ts +1 -1
  127. package/dist/simple-tree/core/index.d.ts.map +1 -1
  128. package/dist/simple-tree/core/index.js +2 -2
  129. package/dist/simple-tree/core/index.js.map +1 -1
  130. package/dist/simple-tree/core/treeNodeKernel.d.ts +2 -6
  131. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  132. package/dist/simple-tree/core/treeNodeKernel.js +10 -13
  133. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  134. package/dist/simple-tree/index.d.ts +1 -1
  135. package/dist/simple-tree/index.d.ts.map +1 -1
  136. package/dist/simple-tree/index.js +3 -2
  137. package/dist/simple-tree/index.js.map +1 -1
  138. package/dist/simple-tree/proxies.js +1 -1
  139. package/dist/simple-tree/proxies.js.map +1 -1
  140. package/dist/simple-tree/schemaTypes.d.ts +2 -2
  141. package/dist/simple-tree/schemaTypes.js +1 -1
  142. package/dist/simple-tree/schemaTypes.js.map +1 -1
  143. package/dist/simple-tree/treeNodeValid.js +1 -2
  144. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  145. package/dist/treeFactory.d.ts +16 -5
  146. package/dist/treeFactory.d.ts.map +1 -1
  147. package/dist/treeFactory.js +21 -12
  148. package/dist/treeFactory.js.map +1 -1
  149. package/dist/util/breakable.d.ts +1 -1
  150. package/dist/util/breakable.d.ts.map +1 -1
  151. package/dist/util/breakable.js.map +1 -1
  152. package/dist/util/rangeMap.d.ts +11 -2
  153. package/dist/util/rangeMap.d.ts.map +1 -1
  154. package/dist/util/rangeMap.js +36 -8
  155. package/dist/util/rangeMap.js.map +1 -1
  156. package/lib/alpha.d.ts +1 -0
  157. package/lib/beta.d.ts +1 -0
  158. package/lib/core/forest/editableForest.js +1 -1
  159. package/lib/core/forest/editableForest.js.map +1 -1
  160. package/lib/core/index.d.ts +1 -1
  161. package/lib/core/index.d.ts.map +1 -1
  162. package/lib/core/index.js.map +1 -1
  163. package/lib/core/tree/anchorSet.d.ts +2 -5
  164. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  165. package/lib/core/tree/anchorSet.js +1 -151
  166. package/lib/core/tree/anchorSet.js.map +1 -1
  167. package/lib/core/tree/index.d.ts +1 -2
  168. package/lib/core/tree/index.d.ts.map +1 -1
  169. package/lib/core/tree/index.js.map +1 -1
  170. package/lib/core/tree/pathTree.d.ts +0 -11
  171. package/lib/core/tree/pathTree.d.ts.map +1 -1
  172. package/lib/core/tree/pathTree.js.map +1 -1
  173. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  174. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  175. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  176. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  177. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +1 -2
  178. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  179. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +0 -9
  180. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  181. package/lib/feature-libraries/flex-tree/treeEvents.d.ts +2 -4
  182. package/lib/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
  183. package/lib/feature-libraries/flex-tree/treeEvents.js.map +1 -1
  184. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -2
  185. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  186. package/lib/feature-libraries/forest-summary/forestSummarizer.js +0 -9
  187. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  188. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +6 -2
  189. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  190. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  191. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -4
  192. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  193. package/lib/feature-libraries/modular-schema/genericFieldKind.js +4 -19
  194. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  195. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  196. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +11 -12
  197. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  198. package/lib/feature-libraries/node-key/mockNodeKeyManager.js +1 -1
  199. package/lib/feature-libraries/node-key/mockNodeKeyManager.js.map +1 -1
  200. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  201. package/lib/feature-libraries/optional-field/optionalField.js +7 -3
  202. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  203. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +3 -5
  204. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  205. package/lib/feature-libraries/schema-index/schemaSummarizer.js +1 -11
  206. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  207. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +1 -1
  208. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  209. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -1
  210. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  211. package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  212. package/lib/feature-libraries/treeCursorUtils.js +2 -2
  213. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  214. package/lib/index.d.ts +3 -3
  215. package/lib/index.d.ts.map +1 -1
  216. package/lib/index.js +3 -3
  217. package/lib/index.js.map +1 -1
  218. package/lib/legacy.d.ts +4 -1
  219. package/lib/packageVersion.d.ts +1 -1
  220. package/lib/packageVersion.js +1 -1
  221. package/lib/packageVersion.js.map +1 -1
  222. package/lib/public.d.ts +1 -0
  223. package/lib/shared-tree/index.d.ts +1 -2
  224. package/lib/shared-tree/index.d.ts.map +1 -1
  225. package/lib/shared-tree/index.js +1 -2
  226. package/lib/shared-tree/index.js.map +1 -1
  227. package/lib/shared-tree/schematizingTreeView.d.ts +4 -5
  228. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  229. package/lib/shared-tree/schematizingTreeView.js +4 -5
  230. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  231. package/lib/shared-tree/sharedTree.d.ts +39 -39
  232. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  233. package/lib/shared-tree/sharedTree.js +79 -53
  234. package/lib/shared-tree/sharedTree.js.map +1 -1
  235. package/lib/shared-tree/treeApi.d.ts +2 -2
  236. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  237. package/lib/shared-tree/treeApi.js +8 -2
  238. package/lib/shared-tree/treeApi.js.map +1 -1
  239. package/lib/shared-tree/treeCheckout.d.ts +3 -3
  240. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  241. package/lib/shared-tree/treeCheckout.js +4 -3
  242. package/lib/shared-tree/treeCheckout.js.map +1 -1
  243. package/lib/shared-tree-core/editManager.js +2 -2
  244. package/lib/shared-tree-core/editManager.js.map +1 -1
  245. package/lib/shared-tree-core/editManagerSummarizer.d.ts +1 -2
  246. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  247. package/lib/shared-tree-core/editManagerSummarizer.js +0 -9
  248. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  249. package/lib/shared-tree-core/sequenceIdUtils.d.ts +12 -1
  250. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  251. package/lib/shared-tree-core/sequenceIdUtils.js +23 -5
  252. package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
  253. package/lib/shared-tree-core/sharedTreeCore.d.ts +25 -30
  254. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  255. package/lib/shared-tree-core/sharedTreeCore.js +19 -48
  256. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  257. package/lib/simple-tree/api/index.d.ts +3 -2
  258. package/lib/simple-tree/api/index.d.ts.map +1 -1
  259. package/lib/simple-tree/api/index.js +1 -0
  260. package/lib/simple-tree/api/index.js.map +1 -1
  261. package/lib/simple-tree/api/schemaFactory.d.ts +158 -63
  262. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  263. package/lib/simple-tree/api/schemaFactory.js +180 -85
  264. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  265. package/lib/{shared-tree → simple-tree/api}/transactionTypes.d.ts +1 -1
  266. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -0
  267. package/lib/{shared-tree → simple-tree/api}/transactionTypes.js.map +1 -1
  268. package/lib/simple-tree/api/tree.d.ts +27 -2
  269. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  270. package/lib/simple-tree/api/tree.js.map +1 -1
  271. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  272. package/lib/simple-tree/core/getOrCreateNode.js +2 -2
  273. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  274. package/lib/simple-tree/core/index.d.ts +1 -1
  275. package/lib/simple-tree/core/index.d.ts.map +1 -1
  276. package/lib/simple-tree/core/index.js +1 -1
  277. package/lib/simple-tree/core/index.js.map +1 -1
  278. package/lib/simple-tree/core/treeNodeKernel.d.ts +2 -6
  279. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  280. package/lib/simple-tree/core/treeNodeKernel.js +9 -11
  281. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  282. package/lib/simple-tree/index.d.ts +1 -1
  283. package/lib/simple-tree/index.d.ts.map +1 -1
  284. package/lib/simple-tree/index.js +1 -1
  285. package/lib/simple-tree/index.js.map +1 -1
  286. package/lib/simple-tree/proxies.js +2 -2
  287. package/lib/simple-tree/proxies.js.map +1 -1
  288. package/lib/simple-tree/schemaTypes.d.ts +2 -2
  289. package/lib/simple-tree/schemaTypes.js +1 -1
  290. package/lib/simple-tree/schemaTypes.js.map +1 -1
  291. package/lib/simple-tree/treeNodeValid.js +1 -2
  292. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  293. package/lib/treeFactory.d.ts +16 -5
  294. package/lib/treeFactory.d.ts.map +1 -1
  295. package/lib/treeFactory.js +20 -11
  296. package/lib/treeFactory.js.map +1 -1
  297. package/lib/util/breakable.d.ts +1 -1
  298. package/lib/util/breakable.d.ts.map +1 -1
  299. package/lib/util/breakable.js.map +1 -1
  300. package/lib/util/rangeMap.d.ts +11 -2
  301. package/lib/util/rangeMap.d.ts.map +1 -1
  302. package/lib/util/rangeMap.js +36 -8
  303. package/lib/util/rangeMap.js.map +1 -1
  304. package/package.json +23 -23
  305. package/src/core/forest/editableForest.ts +1 -1
  306. package/src/core/index.ts +0 -3
  307. package/src/core/tree/anchorSet.ts +4 -197
  308. package/src/core/tree/index.ts +0 -3
  309. package/src/core/tree/pathTree.ts +0 -13
  310. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
  311. package/src/feature-libraries/detachedFieldIndexSummarizer.ts +0 -11
  312. package/src/feature-libraries/flex-tree/treeEvents.ts +2 -4
  313. package/src/feature-libraries/forest-summary/forestSummarizer.ts +0 -11
  314. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +6 -2
  315. package/src/feature-libraries/modular-schema/genericFieldKind.ts +3 -35
  316. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +9 -42
  317. package/src/feature-libraries/optional-field/optionalField.ts +10 -3
  318. package/src/feature-libraries/schema-index/schemaSummarizer.ts +1 -16
  319. package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +13 -2
  320. package/src/feature-libraries/treeCursorUtils.ts +4 -2
  321. package/src/index.ts +15 -10
  322. package/src/packageVersion.ts +1 -1
  323. package/src/shared-tree/index.ts +3 -14
  324. package/src/shared-tree/schematizingTreeView.ts +18 -16
  325. package/src/shared-tree/sharedTree.ts +203 -103
  326. package/src/shared-tree/treeApi.ts +10 -1
  327. package/src/shared-tree/treeCheckout.ts +11 -8
  328. package/src/shared-tree-core/editManager.ts +2 -2
  329. package/src/shared-tree-core/editManagerSummarizer.ts +0 -11
  330. package/src/shared-tree-core/sequenceIdUtils.ts +26 -5
  331. package/src/shared-tree-core/sharedTreeCore.ts +30 -87
  332. package/src/simple-tree/api/index.ts +15 -0
  333. package/src/simple-tree/api/schemaFactory.ts +205 -89
  334. package/src/{shared-tree → simple-tree/api}/transactionTypes.ts +1 -1
  335. package/src/simple-tree/api/tree.ts +35 -6
  336. package/src/simple-tree/core/getOrCreateNode.ts +6 -2
  337. package/src/simple-tree/core/index.ts +1 -1
  338. package/src/simple-tree/core/treeNodeKernel.ts +16 -14
  339. package/src/simple-tree/index.ts +12 -0
  340. package/src/simple-tree/proxies.ts +2 -2
  341. package/src/simple-tree/schemaTypes.ts +2 -2
  342. package/src/treeFactory.ts +29 -11
  343. package/src/util/breakable.ts +1 -1
  344. package/src/util/rangeMap.ts +36 -7
  345. package/dist/core/tree/visitPath.d.ts +0 -101
  346. package/dist/core/tree/visitPath.d.ts.map +0 -1
  347. package/dist/core/tree/visitPath.js +0 -7
  348. package/dist/core/tree/visitPath.js.map +0 -1
  349. package/dist/shared-tree/transactionTypes.d.ts.map +0 -1
  350. package/lib/core/tree/visitPath.d.ts +0 -101
  351. package/lib/core/tree/visitPath.d.ts.map +0 -1
  352. package/lib/core/tree/visitPath.js +0 -6
  353. package/lib/core/tree/visitPath.js.map +0 -1
  354. package/lib/shared-tree/transactionTypes.d.ts.map +0 -1
  355. package/src/core/tree/visitPath.ts +0 -124
  356. /package/dist/{shared-tree → simple-tree/api}/transactionTypes.js +0 -0
  357. /package/lib/{shared-tree → simple-tree/api}/transactionTypes.js +0 -0
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.markSchemaMostDerived = exports.structuralName = exports.SchemaFactory = exports.defaultSchemaFactoryObjectOptions = exports.schemaFromValue = void 0;
7
+ exports.markSchemaMostDerived = exports.structuralName = exports.SchemaFactory = exports.schemaStatics = exports.defaultSchemaFactoryObjectOptions = exports.schemaFromValue = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
10
10
  const internal_3 = require("@fluidframework/runtime-utils/internal");
@@ -45,6 +45,119 @@ exports.defaultSchemaFactoryObjectOptions = {
45
45
  allowUnknownOptionalFields: false,
46
46
  };
47
47
  // > = `${TScope extends undefined ? "" : `${TScope}.`}${TName}`;
48
+ /**
49
+ * Stateless APIs exposed via {@link SchemaFactory} as both instance properties and as statics.
50
+ * @privateRemarks
51
+ * We have no way to make linkable members which exist both as statics and instance properties since API-Extractor does not support this.
52
+ * As a workaround, we have this type as a third place which can be linked.
53
+ * @system @sealed @public
54
+ */
55
+ exports.schemaStatics = {
56
+ /**
57
+ * {@link TreeNodeSchema} for holding a JavaScript `string`.
58
+ *
59
+ * @remarks
60
+ * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.
61
+ *
62
+ * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.
63
+ * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.
64
+ * @privateRemarks
65
+ * TODO:
66
+ * We should be much more clear about what happens if you use problematic values.
67
+ * We should validate and/or normalize them when inserting content.
68
+ */
69
+ string: leafNodeSchema_js_1.stringSchema,
70
+ /**
71
+ * {@link TreeNodeSchema} for holding a JavaScript `number`.
72
+ *
73
+ * @remarks
74
+ * The number is a {@link https://en.wikipedia.org/wiki/Double-precision_floating-point_format | double-precision 64-bit binary format IEEE 754} value, however there are some exceptions:
75
+ * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).
76
+ * - `-0` may be converted to `0` in some cases.
77
+ *
78
+ * These limitations match the limitations of JSON.
79
+ * @privateRemarks
80
+ * TODO:
81
+ * We should be much more clear about what happens if you use problematic values.
82
+ * We should validate and/or normalize them when inserting content.
83
+ */
84
+ number: leafNodeSchema_js_1.numberSchema,
85
+ /**
86
+ * {@link TreeNodeSchema} for holding a boolean.
87
+ */
88
+ boolean: leafNodeSchema_js_1.booleanSchema,
89
+ /**
90
+ * {@link TreeNodeSchema} for JavaScript `null`.
91
+ *
92
+ * @remarks
93
+ * There are good {@link https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null | reasons to avoid using null} in JavaScript, however sometimes it is desired.
94
+ * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.
95
+ * Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.
96
+ */
97
+ null: leafNodeSchema_js_1.nullSchema,
98
+ /**
99
+ * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.
100
+ */
101
+ handle: leafNodeSchema_js_1.handleSchema,
102
+ /**
103
+ * {@link AllowedTypes} for holding any of the leaf types.
104
+ */
105
+ leaves: [leafNodeSchema_js_1.stringSchema, leafNodeSchema_js_1.numberSchema, leafNodeSchema_js_1.booleanSchema, leafNodeSchema_js_1.nullSchema, leafNodeSchema_js_1.handleSchema],
106
+ /**
107
+ * Make a field optional instead of the default, which is required.
108
+ *
109
+ * @param t - The types allowed under the field.
110
+ * @param props - Optional properties to associate with the field.
111
+ *
112
+ * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
113
+ * See {@link FieldSchemaMetadata.custom}.
114
+ */
115
+ optional: (t, props) => {
116
+ const defaultOptionalProvider = (0, schemaTypes_js_1.getDefaultProvider)(() => {
117
+ return undefined;
118
+ });
119
+ return (0, schemaTypes_js_1.createFieldSchema)(schemaTypes_js_1.FieldKind.Optional, t, {
120
+ defaultProvider: defaultOptionalProvider,
121
+ ...props,
122
+ });
123
+ },
124
+ /**
125
+ * Make a field explicitly required.
126
+ *
127
+ * @param t - The types allowed under the field.
128
+ * @param props - Optional properties to associate with the field.
129
+ *
130
+ * @remarks
131
+ * Fields are required by default, but this API can be used to make the required nature explicit in the schema,
132
+ * and allows associating custom {@link FieldProps | properties} with the field.
133
+ *
134
+ * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
135
+ * See {@link FieldSchemaMetadata.custom}.
136
+ */
137
+ required: (t, props) => {
138
+ return (0, schemaTypes_js_1.createFieldSchema)(schemaTypes_js_1.FieldKind.Required, t, props);
139
+ },
140
+ /**
141
+ * {@link schemaStatics.optional} except tweaked to work better for recursive types.
142
+ * Use with {@link ValidateRecursiveSchema} for improved type safety.
143
+ * @remarks
144
+ * This version of {@link schemaStatics.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
145
+ * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
146
+ */
147
+ optionalRecursive: (t, props) => {
148
+ return (0, schemaFactoryRecursive_js_1.createFieldSchemaUnsafe)(schemaTypes_js_1.FieldKind.Optional, t, props);
149
+ },
150
+ /**
151
+ * {@link schemaStatics.required} except tweaked to work better for recursive types.
152
+ * Use with {@link ValidateRecursiveSchema} for improved type safety.
153
+ * @remarks
154
+ * This version of {@link schemaStatics.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
155
+ * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
156
+ */
157
+ requiredRecursive: (t, props) => {
158
+ return (0, schemaFactoryRecursive_js_1.createFieldSchemaUnsafe)(schemaTypes_js_1.FieldKind.Required, t, props);
159
+ },
160
+ };
48
161
  // TODO:
49
162
  // SchemaFactory.array references should link to the correct overloads, however the syntax for this does not seems to work currently for methods unless the they are not qualified with the class.
50
163
  // API-Extractor requires such links to be qualified with the class, so it can't work.
@@ -137,6 +250,8 @@ exports.defaultSchemaFactoryObjectOptions = {
137
250
  *
138
251
  * Note: the comparison between the customizable and POJO modes is not done in a table because TSDoc does not currently have support for embedded markdown.
139
252
  *
253
+ * @see {@link SchemaFactoryAlpha}
254
+ *
140
255
  * @sealed @public
141
256
  */
142
257
  class SchemaFactory {
@@ -189,51 +304,45 @@ class SchemaFactory {
189
304
  */
190
305
  this.structuralTypes = new Map();
191
306
  /**
192
- * {@link TreeNodeSchema} for holding a JavaScript `string`.
193
- *
194
- * @remarks
195
- * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.
196
- *
197
- * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.
198
- * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.
199
- * @privateRemarks
200
- * TODO:
201
- * We should be much more clear about what happens if you use problematic values.
202
- * We should validate and/or normalize them when inserting content.
307
+ * {@inheritDoc schemaStatics.string}
203
308
  */
204
309
  this.string = leafNodeSchema_js_1.stringSchema;
205
310
  /**
206
- * {@link TreeNodeSchema} for holding a JavaScript `number`.
207
- *
208
- * @remarks
209
- * The number is a [double-precision 64-bit binary format IEEE 754](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) value, however there are some exceptions:
210
- * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).
211
- * - `-0` may be converted to `0` in some cases.
212
- *
213
- * These limitations match the limitations of JSON.
214
- * @privateRemarks
215
- * TODO:
216
- * We should be much more clear about what happens if you use problematic values.
217
- * We should validate and/or normalize them when inserting content.
311
+ * {@inheritDoc schemaStatics.number}
218
312
  */
219
313
  this.number = leafNodeSchema_js_1.numberSchema;
220
314
  /**
221
- * {@link TreeNodeSchema} for holding a boolean.
315
+ * {@inheritDoc schemaStatics.boolean}
222
316
  */
223
317
  this.boolean = leafNodeSchema_js_1.booleanSchema;
224
318
  /**
225
- * {@link TreeNodeSchema} for JavaScript `null`.
226
- *
227
- * @remarks
228
- * There are good [reasons to avoid using null](https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null) in JavaScript, however sometimes it is desired.
229
- * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.
230
- * Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.
319
+ * {@inheritDoc schemaStatics.null}
231
320
  */
232
321
  this.null = leafNodeSchema_js_1.nullSchema;
233
322
  /**
234
- * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.
323
+ * {@inheritDoc schemaStatics.handle}
235
324
  */
236
325
  this.handle = leafNodeSchema_js_1.handleSchema;
326
+ /**
327
+ * {@inheritDoc schemaStatics.leaves}
328
+ */
329
+ this.leaves = exports.schemaStatics.leaves;
330
+ /**
331
+ * {@inheritDoc schemaStatics.optional}
332
+ */
333
+ this.optional = exports.schemaStatics.optional;
334
+ /**
335
+ * {@inheritDoc schemaStatics.required}
336
+ */
337
+ this.required = exports.schemaStatics.required;
338
+ /**
339
+ * {@inheritDoc schemaStatics.optionalRecursive}
340
+ */
341
+ this.optionalRecursive = exports.schemaStatics.optionalRecursive;
342
+ /**
343
+ * {@inheritDoc schemaStatics.requiredRecursive}
344
+ */
345
+ this.requiredRecursive = exports.schemaStatics.requiredRecursive;
237
346
  }
238
347
  scoped(name) {
239
348
  return (this.scope === undefined ? `${name}` : `${this.scope}.${name}`);
@@ -302,60 +411,6 @@ class SchemaFactory {
302
411
  namedArray(name, allowedTypes, customizable, implicitlyConstructable) {
303
412
  return (0, arrayNode_js_1.arraySchema)(this.scoped(name), allowedTypes, implicitlyConstructable, customizable);
304
413
  }
305
- /**
306
- * Make a field optional instead of the default, which is required.
307
- *
308
- * @param t - The types allowed under the field.
309
- * @param props - Optional properties to associate with the field.
310
- *
311
- * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
312
- * See {@link FieldSchemaMetadata.custom}.
313
- */
314
- optional(t, props) {
315
- const defaultOptionalProvider = (0, schemaTypes_js_1.getDefaultProvider)(() => {
316
- return undefined;
317
- });
318
- return (0, schemaTypes_js_1.createFieldSchema)(schemaTypes_js_1.FieldKind.Optional, t, {
319
- defaultProvider: defaultOptionalProvider,
320
- ...props,
321
- });
322
- }
323
- /**
324
- * Make a field explicitly required.
325
- *
326
- * @param t - The types allowed under the field.
327
- * @param props - Optional properties to associate with the field.
328
- *
329
- * @remarks
330
- * Fields are required by default, but this API can be used to make the required nature explicit in the schema,
331
- * and allows associating custom {@link FieldProps | properties} with the field.
332
- *
333
- * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
334
- * See {@link FieldSchemaMetadata.custom}.
335
- */
336
- required(t, props) {
337
- return (0, schemaTypes_js_1.createFieldSchema)(schemaTypes_js_1.FieldKind.Required, t, props);
338
- }
339
- /**
340
- * {@link SchemaFactory.optional} except tweaked to work better for recursive types.
341
- * Use with {@link ValidateRecursiveSchema} for improved type safety.
342
- * @remarks
343
- * This version of {@link SchemaFactory.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
344
- * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
345
- */
346
- optionalRecursive(t, props) {
347
- return (0, schemaFactoryRecursive_js_1.createFieldSchemaUnsafe)(schemaTypes_js_1.FieldKind.Optional, t, props);
348
- }
349
- /**
350
- * {@link SchemaFactory.required} except tweaked to work better for recursive types.
351
- * Use with {@link ValidateRecursiveSchema} for improved type safety.
352
- * @remarks
353
- * This version of {@link SchemaFactory.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
354
- * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
355
- */
356
- requiredRecursive(t, props) {
357
- return (0, schemaFactoryRecursive_js_1.createFieldSchemaUnsafe)(schemaTypes_js_1.FieldKind.Required, t, props);
358
- }
359
414
  /**
360
415
  * A special field which holds a unique identifier for an object node.
361
416
  * @remarks
@@ -427,6 +482,46 @@ class SchemaFactory {
427
482
  }
428
483
  }
429
484
  exports.SchemaFactory = SchemaFactory;
485
+ /**
486
+ * {@inheritDoc schemaStatics.string}
487
+ */
488
+ SchemaFactory.string = leafNodeSchema_js_1.stringSchema;
489
+ /**
490
+ * {@inheritDoc schemaStatics.number}
491
+ */
492
+ SchemaFactory.number = leafNodeSchema_js_1.numberSchema;
493
+ /**
494
+ * {@inheritDoc schemaStatics.boolean}
495
+ */
496
+ SchemaFactory.boolean = leafNodeSchema_js_1.booleanSchema;
497
+ /**
498
+ * {@inheritDoc schemaStatics.null}
499
+ */
500
+ SchemaFactory.null = leafNodeSchema_js_1.nullSchema;
501
+ /**
502
+ * {@inheritDoc schemaStatics.handle}
503
+ */
504
+ SchemaFactory.handle = leafNodeSchema_js_1.handleSchema;
505
+ /**
506
+ * {@inheritDoc schemaStatics.leaves}
507
+ */
508
+ SchemaFactory.leaves = exports.schemaStatics.leaves;
509
+ /**
510
+ * {@inheritDoc schemaStatics.optional}
511
+ */
512
+ SchemaFactory.optional = exports.schemaStatics.optional;
513
+ /**
514
+ * {@inheritDoc schemaStatics.required}
515
+ */
516
+ SchemaFactory.required = exports.schemaStatics.required;
517
+ /**
518
+ * {@inheritDoc schemaStatics.optionalRecursive}
519
+ */
520
+ SchemaFactory.optionalRecursive = exports.schemaStatics.optionalRecursive;
521
+ /**
522
+ * {@inheritDoc schemaStatics.requiredRecursive}
523
+ */
524
+ SchemaFactory.requiredRecursive = exports.schemaStatics.requiredRecursive;
430
525
  function structuralName(collectionName, allowedTypes) {
431
526
  let inner;
432
527
  if (!(0, index_js_1.isReadonlyArray)(allowedTypes)) {
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactory.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAK9E,uEAAsE;AACtE,qEAAuE;AAIvE,kDAI6B;AAK7B,4DAO8B;AAC9B,sDAW2B;AAC3B,+CAAoD;AASpD,kDAAkE;AAClE,oDAI0B;AAC1B,8CAAwF;AAkBxF,2EAAsE;AACtE,0DAAoD;AACpD,gDAAwC;AAExC;;GAEG;AACH,SAAgB,eAAe,CAAC,KAAgB;IAC/C,QAAQ,OAAO,KAAK,EAAE,CAAC;QACtB,KAAK,SAAS;YACb,OAAO,iCAAa,CAAC;QACtB,KAAK,QAAQ;YACZ,OAAO,gCAAY,CAAC;QACrB,KAAK,QAAQ;YACZ,OAAO,gCAAY,CAAC;QACrB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACf,IAAI,K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,GAAG,CAAC,CAAC,CAAC,EAAU,EAAE;YAC5C,8DAA8D;YAC9D,IAAA,iBAAM,EAAC,CAAC,IAAA,oBAAM,EAAC,CAAC,CAAC,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAC;YACtD,qBAAqB,CAAC,CAAC,CAAC,CAAC;YACzB,OAAO,CAAC,CAAC,UAAU,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,mCAAmC;QACnC,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,8FAA8F;QAC9F,iDAAiD;QACjD,2IAA2I;QAC3I,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,cAAc,IAAI,KAAK,GAAG,CAAC;AACtC,CAAC;AAtBD,wCAsBC;AAED;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,MAAsB;IAC3D,IAAI,MAAM,YAAY,kCAAc,EAAE,CAAC;QACtC,OAAO;IACR,CAAC;IAED,IAAI,CAAC,IAAA,2BAAgB,EAAC,MAAM,EAAE,gCAAa,CAAC,EAAE,CAAC;QAC9C,4DAA4D;QAC5D,MAAM,IAAI,qBAAU,CACnB,cAAc,IAAI,CAAC,SAAS,CAC3B,MAAM,CAAC,UAAU,CACjB,oEAAoE,CACrE,CAAC;IACH,CAAC;IAEA,MAAgD,CAAC,eAAe,EAAE,CAAC;AACrE,CAAC;AAfD,sDAeC","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\";\n// Include this unused import to avoid TypeScript generating an inline import for IFluidHandle in the d.ts file\n// which degrades the API-Extractor report quality since API-Extractor can not tell the inline import is the same as the non-inline one.\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport type { IFluidHandle as _dummyImport } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\n\nimport type { TreeValue } from \"../../core/index.js\";\nimport type { NodeKeyManager } from \"../../feature-libraries/index.js\";\nimport {\n\ttype RestrictiveStringRecord,\n\tgetOrCreate,\n\tisReadonlyArray,\n} from \"../../util/index.js\";\n// This import is required for intellisense in @link doc comments on mouseover in VSCode.\n// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars\nimport type { TreeAlpha } from \"../../shared-tree/index.js\";\n\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tLeafNodeSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport {\n\tFieldKind,\n\ttype FieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype FieldProps,\n\tcreateFieldSchema,\n\ttype DefaultProvider,\n\tgetDefaultProvider,\n\ttype NodeSchemaOptions,\n} from \"../schemaTypes.js\";\nimport { inPrototypeChain } from \"../core/index.js\";\nimport type {\n\tNodeKind,\n\tWithType,\n\tTreeNodeSchema,\n\tTreeNodeSchemaClass,\n\tTreeNodeSchemaNonClass,\n\tTreeNodeSchemaBoth,\n} from \"../core/index.js\";\nimport { type TreeArrayNode, arraySchema } from \"../arrayNode.js\";\nimport {\n\ttype InsertableObjectFromSchemaRecord,\n\ttype TreeObjectNode,\n\tobjectSchema,\n} from \"../objectNode.js\";\nimport { type MapNodeInsertableData, type TreeMapNode, mapSchema } from \"../mapNode.js\";\nimport type {\n\tFieldSchemaUnsafe,\n\t// Adding these unused imports makes the generated d.ts file produced by TypeScript stop breaking API-Extractor's rollup generation.\n\t// Without this import, TypeScript generates inline `import(\"../..\")` statements in the d.ts file,\n\t// which API-Extractor leaves as is when generating the rollup, leaving them pointing at the wrong directory.\n\t// API-Extractor issue: https://github.com/microsoft/rushstack/issues/4507\n\t// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars\n\tFieldHasDefaultUnsafe,\n\t// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars\n\tInsertableTreeFieldFromImplicitFieldUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tTreeObjectNodeUnsafe,\n\tUnenforced,\n} from \"./typesUnsafe.js\";\nimport { createFieldSchemaUnsafe } from \"./schemaFactoryRecursive.js\";\nimport { TreeNodeValid } from \"../treeNodeValid.js\";\nimport { isLazy } from \"../flexList.js\";\n\n/**\n * Gets the leaf domain schema compatible with a given {@link TreeValue}.\n */\nexport function schemaFromValue(value: TreeValue): TreeNodeSchema {\n\tswitch (typeof value) {\n\t\tcase \"boolean\":\n\t\t\treturn booleanSchema;\n\t\tcase \"number\":\n\t\t\treturn numberSchema;\n\t\tcase \"string\":\n\t\t\treturn stringSchema;\n\t\tcase \"object\": {\n\t\t\tif (value === null) {\n\t\t\t\treturn nullSchema;\n\t\t\t}\n\t\t\tassert(isFluidHandle(value), 0x87e /* invalid TreeValue */);\n\t\t\treturn handleSchema;\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(value);\n\t}\n}\n\n/**\n * Options when declaring an {@link SchemaFactory.object|object node}'s schema\n *\n * @alpha\n */\nexport interface SchemaFactoryObjectOptions<TCustomMetadata = unknown>\n\textends NodeSchemaOptions<TCustomMetadata> {\n\t/**\n\t * Allow nodes typed with this object node schema to contain optional fields that are not present in the schema declaration.\n\t * Such nodes can come into existence either via import APIs (see remarks) or by way of collaboration with another client\n\t * that has upgraded the document's schema to include those optional fields.\n\t *\n\t * @defaultValue `false`\n\t * @remarks\n\t * The advantage of enabling this option is that it allows an application ecosystem with staged rollout to more quickly\n\t * upgrade documents to include schema for new optional features.\n\t *\n\t * However, it does come with trade-offs that applications should weigh carefully when it comes to interactions between\n\t * code and documents.\n\t * When opening such documents, the API presented is still determined by the view schema.\n\t * This can have implications on the behavior of edits or code which uses portions of the view schema,\n\t * since this may inadvertently drop data which is present in those optional fields in the document schema.\n\t *\n\t * Consider the following example:\n\t *\n\t * ```typescript\n\t * const sf = new SchemaFactory(\"com.example\");\n\t * class PersonView extends sf.object(\"Person\", { name: sf.string }, { allowUnknownOptionalFields: true }) {}\n\t * class PersonStored extends sf.object(\"Person\", { name: sf.string, nickname: sf.optional(sf.string) }) {}\n\t *\n\t * // Say we have a document which uses `PersonStored` in its schema, and application code constructs\n\t * // a tree view using `PersonView`. If the application for some reason had implemented a function like this:\n\t * function clonePerson(a: PersonView): PersonView {\n\t * \treturn new PersonView({ name: a.name });\n\t * }\n\t * // ...or even like this:\n\t * function clonePerson(a: PersonView): PersonView {\n\t * return new PersonView({ ...a})\n\t * }\n\t * // Then the alleged clone wouldn't actually clone the entire person in either case, it would drop the nickname.\n\t * ```\n\t *\n\t * If an application wants to be particularly careful to preserve all data on a node when editing it, it can use\n\t * {@link TreeAlpha.(importVerbose:2)|import}/{@link TreeAlpha.(exportVerbose:2)|export} APIs with persistent keys.\n\t *\n\t * Note that public API methods which operate on entire nodes (such as `moveTo`, `moveToEnd`, etc. on arrays) do not encounter\n\t * this problem as SharedTree's implementation stores the entire node in its lower layers. It's only when application code\n\t * reaches into a node (either by accessing its fields, spreading it, or some other means) that this problem arises.\n\t */\n\tallowUnknownOptionalFields?: boolean;\n}\n\nexport const defaultSchemaFactoryObjectOptions: Required<\n\tOmit<SchemaFactoryObjectOptions, \"metadata\">\n> = {\n\tallowUnknownOptionalFields: false,\n};\n\n/**\n * The name of a schema produced by {@link SchemaFactory}, including its optional scope prefix.\n *\n * @system @public\n */\nexport type ScopedSchemaName<\n\tTScope extends string | undefined,\n\tTName extends number | string,\n> = TScope extends undefined ? `${TName}` : `${TScope}.${TName}`;\n// > = `${TScope extends undefined ? \"\" : `${TScope}.`}${TName}`;\n\n// TODO:\n// SchemaFactory.array references should link to the correct overloads, however the syntax for this does not seems to work currently for methods unless the they are not qualified with the class.\n// API-Extractor requires such links to be qualified with the class, so it can't work.\n// Since linking the overload set as a whole also doesn't work, these have been made non-links for now.\n/**\n * Creates various types of {@link TreeNodeSchema|schema} for {@link TreeNode}s.\n *\n * @typeParam TScope - Scope added as a prefix to the name of every schema produced by this factory.\n * @typeParam TName - Type of names used to identify each schema produced in this factory.\n * Typically this is just `string` but it is also possible to use `string` or `number` based enums if you prefer to identify your types that way.\n *\n * @remarks\n * For details related to inputting data constrained by schema (including via assignment), and how non-exact schema types are handled in general refer to {@link Input}.\n * For information about recursive schema support, see methods postfixed with \"recursive\" and {@link ValidateRecursiveSchema}.\n * To apply schema defined with this factory to a tree, see {@link ViewableTree.viewWith} and {@link TreeViewConfiguration}.\n *\n * All schema produced by this factory get a {@link TreeNodeSchemaCore.identifier|unique identifier} by combining the {@link SchemaFactory.scope} with the schema's `Name`.\n * The `Name` part may be explicitly provided as a parameter, or inferred as a structural combination of the provided types.\n * The APIs which use this second approach, structural naming, also deduplicate all equivalent calls.\n * Therefor two calls to `array(allowedTypes)` with the same allowedTypes will return the same {@link TreeNodeSchema} instance.\n * On the other hand, two calls to `array(name, allowedTypes)` will always return different {@link TreeNodeSchema} instances\n * and it is an error to use both in the same tree (since their identifiers are not unique).\n *\n * Note:\n * POJO stands for Plain Old JavaScript Object.\n * This means an object that works like a `{}` style object literal.\n * In this case it means the prototype is `Object.prototype` and acts like a set of key value pairs (data, not methods).\n * The usage below generalizes this to include array and map like objects as well.\n *\n * There are two ways to use these APIs:\n *\n * Customizable Approach:\n *\n * 1. Declaration: `class X extends schemaFactory.object(\"x\", {}) {}`\n *\n * 2. Allows adding \"local\" (non-persisted) members: Yes. Members (including methods) can be added to the class.\n *\n * 3. Prototype: The user-defined class.\n *\n * 4. Structurally named Schema: Not Supported.\n *\n * 5. Explicitly named Objects: Supported.\n *\n * 6. Explicitly named Maps and Arrays: Supported: Both declaration approaches can be used.\n *\n * 7. Node.js `assert.deepEqual`: Compares like class instances: equal to other nodes of the same type with the same content, including custom local fields.\n *\n * 8. IntelliSense: Shows and links to user-defined class by name: `X`.\n *\n * 9. Recursion: Supported with special declaration patterns.\n *\n * POJO Emulation Approach:\n *\n * 1. Declaration: `const X = schemaFactory.object(\"x\", {}); type X = NodeFromSchema<typeof X>;`\n *\n * 2. Allows adding \"local\" (non-persisted) members: No. Attempting to set non-field members will result in an error.\n *\n * 3. Prototype: `Object.prototype`, `Map.prototype`, or `Array.prototype` depending on node kind.\n *\n * 4. Structurally named Schema: Supported.\n *\n * 5. Explicitly named Objects: Supported.\n *\n * 6. Explicitly named Maps and Arrays: Not Supported.\n *\n * 7. Node.js `assert.deepEqual`: Compares like plain objects: equal to plain JavaScript objects with the same fields, and other nodes with the same fields, even if the types are different.\n *\n * 8. IntelliSense: Shows internal type generation logic: `object & TreeNode & ObjectFromSchemaRecord<{}> & WithType<\"test.x\">`.\n *\n * 9. Recursion: Unsupported: Generated `.d.ts` files replace recursive references with `any`, breaking the use of recursive schema across compilation boundaries.\n *\n * Note that while \"POJO Emulation\" nodes act a lot like POJO objects, they are not true POJO objects:\n *\n * - Adding new arbitrary fields will error, as well some cases of invalid edits.\n *\n * - They are implemented using proxies.\n *\n * - They have state that is not exposed via enumerable own properties, including a {@link TreeNodeSchema}.\n * This makes libraries like node.js `assert.deepEqual` fail to detect differences in type.\n *\n * - Assigning members has side effects (in this case editing the persisted/shared tree).\n *\n * - Not all operations implied by the prototype will work correctly: stick to the APIs explicitly declared in the TypeScript types.\n *\n * @privateRemarks\n * It's perfectly possible to make `POJO Emulation` mode (or even just hiding the prototype) selectable even when using the custom user class declaration syntax.\n * When doing this, it's still possible to make `instanceof` perform correctly.\n * Allowing (or banning) custom/out-of-schema properties on the class is also possible in both modes: it could be orthogonal.\n * Also for consistency, if keeping the current approach to detecting `POJO Emulation` mode it might make sense to make explicitly named Maps and Arrays do the detection the same as how object does it.\n *\n * Note: the comparison between the customizable and POJO modes is not done in a table because TSDoc does not currently have support for embedded markdown.\n *\n * @sealed @public\n */\nexport class SchemaFactory<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> {\n\t/**\n\t * TODO:\n\t * If users of this generate the same name because two different schema with the same identifier were used,\n\t * the second use can get a cache hit, and reference the wrong schema.\n\t * Such usage should probably return a distinct type or error but currently does not.\n\t * The use of markSchemaMostDerived in structuralName at least ensure an error in the case where the collision is from two types extending the same schema factor class.\n\t */\n\tprivate readonly structuralTypes: Map<string, TreeNodeSchema> = new Map();\n\n\t/**\n\t * Construct a SchemaFactory with a given {@link SchemaFactory.scope|scope}.\n\t * @remarks\n\t * There are no restrictions on mixing schema from different schema factories.\n\t * Typically each library will create one or more SchemaFactories and use them to define its schema.\n\t */\n\tpublic constructor(\n\t\t/**\n\t\t * Prefix appended to the identifiers of all {@link TreeNodeSchema} produced by this builder.\n\t\t *\n\t\t * @remarks\n\t\t * Generally each independently developed library\n\t\t * (possibly a package, but could also be part of a package or multiple packages developed together)\n\t\t * should get its own unique `scope`.\n\t\t * Then each schema in the library get a name which is unique within the library.\n\t\t * The scope and name are joined (with a period) to form the {@link TreeNodeSchemaCore.identifier|schema identifier}.\n\t\t * Following this pattern allows a single application to depend on multiple libraries which define their own schema, and use them together in a single tree without risk of collisions.\n\t\t * If a library logically contains sub-libraries with their own schema, they can be given a scope nested inside the parent scope, such as \"ParentScope.ChildScope\".\n\t\t *\n\t\t * To avoid collisions between the scopes of libraries\n\t\t * it is recommended that the libraries use {@link https://en.wikipedia.org/wiki/Reverse_domain_name_notation | Reverse domain name notation} or a UUIDv4 for their scope.\n\t\t * If this pattern is followed, application can safely use third party libraries without risk of the schema in them colliding.\n\t\t *\n\t\t * You may opt out of using a scope by passing `undefined`, but note that this increases the risk of collisions.\n\t\t *\n\t\t * @example\n\t\t * Fluid Framework follows this pattern, placing the schema for the built in leaf types in the `com.fluidframework.leaf` scope.\n\t\t * If Fluid Framework publishes more schema in the future, they would be under some other `com.fluidframework` scope.\n\t\t * This ensures that any schema defined by any other library will not conflict with Fluid Framework's schema\n\t\t * as long as the library uses the recommended patterns for how to scope its schema..\n\t\t *\n\t\t * @example\n\t\t * A library could generate a random UUIDv4, like `242c4397-49ed-47e6-8dd0-d5c3bc31778b` and use that as the scope.\n\t\t * Note: do not use this UUID: a new one must be randomly generated when needed to ensure collision resistance.\n\t\t * ```typescript\n\t\t * const factory = new SchemaFactory(\"242c4397-49ed-47e6-8dd0-d5c3bc31778b\");\n\t\t * ```\n\t\t */\n\t\tpublic readonly scope: TScope,\n\t) {}\n\n\tprivate scoped<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `string`.\n\t *\n\t * @remarks\n\t * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.\n\t *\n\t * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.\n\t * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\tpublic readonly string = stringSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `number`.\n\t *\n\t * @remarks\n\t * The number is a [double-precision 64-bit binary format IEEE 754](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) value, however there are some exceptions:\n\t * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).\n\t * - `-0` may be converted to `0` in some cases.\n\t *\n\t * These limitations match the limitations of JSON.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\tpublic readonly number = numberSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a boolean.\n\t */\n\tpublic readonly boolean = booleanSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for JavaScript `null`.\n\t *\n\t * @remarks\n\t * There are good [reasons to avoid using null](https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null) in JavaScript, however sometimes it is desired.\n\t * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.\n\t * Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.\n\t */\n\tpublic readonly null = nullSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.\n\t */\n\tpublic readonly handle = handleSchema;\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t */\n\tpublic object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNode<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecord<T>,\n\t\ttrue,\n\t\tT\n\t> {\n\t\treturn objectSchema(\n\t\t\tthis.scoped(name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t);\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t *\n\t * @remarks\n\t * The unique identifier for this Map is defined as a function of the provided types.\n\t * It is still scoped to this SchemaBuilder, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named maps, other types in this schema builder should avoid names of the form `Map<${string}>`.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyMap = factory.map(factory.number);\n\t * type MyMap = NodeFromSchema<typeof MyMap>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", {myMap: factory.map(factory.number)});\n\t * ```\n\t * @privateRemarks\n\t * See note on array.\n\t */\n\tpublic map<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaNonClass<\n\t\tScopedSchemaName<TScope, `Map<${string}>`>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, `Map<${string}>`>, NodeKind.Map>,\n\t\tMapNodeInsertableData<T>,\n\t\ttrue,\n\t\tT,\n\t\tundefined\n\t>;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic map<Name extends TName, const T extends ImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,\n\t\tMapNodeInsertableData<T>,\n\t\ttrue,\n\t\tT,\n\t\tundefined\n\t>;\n\n\t/**\n\t * {@link SchemaFactory.map} implementation.\n\t *\n\t * @privateRemarks\n\t * This should return `TreeNodeSchemaBoth`, however TypeScript gives an error if one of the overloads implicitly up-casts the return type of the implementation.\n\t * This seems like a TypeScript bug getting variance backwards for overload return types since it's erroring when the relation between the overload\n\t * and the implementation is type safe, and forcing an unsafe typing instead.\n\t */\n\tpublic map<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): TreeNodeSchema<string, NodeKind.Map, TreeMapNode<T>, MapNodeInsertableData<T>, true, T> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Map\", types);\n\t\t\treturn getOrCreate(\n\t\t\t\tthis.structuralTypes,\n\t\t\t\tfullName,\n\t\t\t\t() =>\n\t\t\t\t\tthis.namedMap(\n\t\t\t\t\t\tfullName as TName,\n\t\t\t\t\t\tnameOrAllowedTypes as T,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t) as TreeNodeSchema,\n\t\t\t) as TreeNodeSchemaBoth<\n\t\t\t\tstring,\n\t\t\t\tNodeKind.Map,\n\t\t\t\tTreeMapNode<T>,\n\t\t\t\tMapNodeInsertableData<T>,\n\t\t\t\ttrue,\n\t\t\t\tT,\n\t\t\t\tundefined\n\t\t\t>;\n\t\t}\n\t\t// To actually have type safety, assign to the type this method should return before implicitly upcasting when returning.\n\t\tconst out: TreeNodeSchemaBoth<\n\t\t\tstring,\n\t\t\tNodeKind.Map,\n\t\t\tTreeMapNode<T>,\n\t\t\tMapNodeInsertableData<T>,\n\t\t\ttrue,\n\t\t\tT,\n\t\t\tundefined\n\t\t> = this.namedMap(nameOrAllowedTypes as TName, allowedTypes, true, true);\n\t\treturn out;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeMapNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t */\n\tprivate namedMap<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t): TreeNodeSchemaBoth<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,\n\t\tMapNodeInsertableData<T>,\n\t\tImplicitlyConstructable,\n\t\tT,\n\t\tundefined\n\t> {\n\t\treturn mapSchema(\n\t\t\tthis.scoped(name),\n\t\t\tallowedTypes,\n\t\t\timplicitlyConstructable,\n\t\t\t// The current policy is customizable nodes don't get fake prototypes.\n\t\t\t!customizable,\n\t\t\tundefined,\n\t\t);\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param allowedTypes - The types that may appear in the array.\n\t *\n\t * @remarks\n\t * The identifier for this Array is defined as a function of the provided types.\n\t * It is still scoped to this SchemaFactory, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named arrays, other types in this schema builder should avoid names of the form `Array<${string}>`.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyArray = factory.array(factory.number);\n\t * type MyArray = NodeFromSchema<typeof MyArray>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", {myArray: factory.array(factory.number)});\n\t * ```\n\t * @privateRemarks\n\t * The name produced at the type level here is not as specific as it could be, however doing type level sorting and escaping is a real mess.\n\t * There are cases where not having this full type provided will be less than ideal since TypeScript's structural types.\n\t * For example attempts to narrow unions of structural arrays by name won't work.\n\t * Planned future changes to move to a class based schema system as well as factor function based node construction should mostly avoid these issues,\n\t * though there may still be some problematic cases even after that work is done.\n\t *\n\t * The return value is a class, but its the type is intentionally not specific enough to indicate it is a class.\n\t * This prevents callers of this from sub-classing it, which is unlikely to work well (due to the ease of accidentally giving two different calls o this different subclasses)\n\t * when working with structural typing.\n\t *\n\t * {@label STRUCTURAL}\n\t */\n\tpublic array<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaNonClass<\n\t\tScopedSchemaName<TScope, `Array<${string}>`>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, `Array<${string}>`>, NodeKind.Array>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT,\n\t\tundefined\n\t>;\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.array(\"name\", factory.number) {}\n\t * ```\n\t *\n\t * {@label NAMED}\n\t */\n\tpublic array<const Name extends TName, const T extends ImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Array>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT,\n\t\tundefined\n\t>;\n\n\t/**\n\t * {@link SchemaFactory.array} implementation.\n\t *\n\t * @privateRemarks\n\t * This should return TreeNodeSchemaBoth: see note on \"map\" implementation for details.\n\t */\n\tpublic array<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): TreeNodeSchema<\n\t\tScopedSchemaName<TScope, string>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT\n\t> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Array\", types);\n\t\t\treturn getOrCreate(this.structuralTypes, fullName, () =>\n\t\t\t\tthis.namedArray(fullName, nameOrAllowedTypes as T, false, true),\n\t\t\t) as TreeNodeSchemaClass<\n\t\t\t\tScopedSchemaName<TScope, string>,\n\t\t\t\tNodeKind.Array,\n\t\t\t\tTreeArrayNode<T>,\n\t\t\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\t\t\ttrue,\n\t\t\t\tT,\n\t\t\t\tundefined\n\t\t\t>;\n\t\t}\n\t\tconst out: TreeNodeSchemaBoth<\n\t\t\tScopedSchemaName<TScope, string>,\n\t\t\tNodeKind.Array,\n\t\t\tTreeArrayNode<T>,\n\t\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\t\ttrue,\n\t\t\tT,\n\t\t\tundefined\n\t\t> = this.namedArray(nameOrAllowedTypes as TName, allowedTypes, true, true);\n\t\treturn out;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @remarks\n\t * This is not intended to be used directly, use the overload of `array` which takes a name instead.\n\t * This is only public to work around a compiler limitation.\n\t */\n\tprivate namedArray<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t): TreeNodeSchemaBoth<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, string>, NodeKind.Array>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\tImplicitlyConstructable,\n\t\tT,\n\t\tundefined\n\t> {\n\t\treturn arraySchema(this.scoped(name), allowedTypes, implicitlyConstructable, customizable);\n\t}\n\n\t/**\n\t * Make a field optional instead of the default, which is required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n\t * See {@link FieldSchemaMetadata.custom}.\n\t */\n\tpublic optional<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchema<FieldKind.Optional, T, TCustomMetadata> {\n\t\tconst defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => {\n\t\t\treturn undefined;\n\t\t});\n\t\treturn createFieldSchema(FieldKind.Optional, t, {\n\t\t\tdefaultProvider: defaultOptionalProvider,\n\t\t\t...props,\n\t\t});\n\t}\n\n\t/**\n\t * Make a field explicitly required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @remarks\n\t * Fields are required by default, but this API can be used to make the required nature explicit in the schema,\n\t * and allows associating custom {@link FieldProps | properties} with the field.\n\t *\n\t * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n\t * See {@link FieldSchemaMetadata.custom}.\n\t */\n\tpublic required<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchema<FieldKind.Required, T, TCustomMetadata> {\n\t\treturn createFieldSchema(FieldKind.Required, t, props);\n\t}\n\n\t/**\n\t * {@link SchemaFactory.optional} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaFactory.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tpublic optionalRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchemaUnsafe<FieldKind.Optional, T> {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Optional, t, props);\n\t}\n\n\t/**\n\t * {@link SchemaFactory.required} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaFactory.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tpublic requiredRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchemaUnsafe<FieldKind.Required, T> {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Required, t, props);\n\t}\n\n\t/**\n\t * A special field which holds a unique identifier for an object node.\n\t * @remarks\n\t * The value of this field, a \"node identifier\", uniquely identifies a node among all other nodes in the tree.\n\t * Node identifiers are strings, and can therefore be used as lookup keys in maps or written to a database.\n\t * When the node is constructed, the identifier field does not need to be populated.\n\t * The SharedTree will provide an identifier for the node automatically.\n\t * An identifier provided automatically by the SharedTree has the following properties:\n\t * - It is a UUID.\n\t * - It is compressed to a space-efficient representation when stored in the document.\n\t * - A compressed form of the identifier can be accessed at runtime via the `Tree.shortId()` API.\n\t * - It will error if read (and will not be present in the object's iterable properties) before the node has been inserted into the tree.\n\t *\n\t * However, a user may alternatively supply their own string as the identifier if desired (for example, if importing identifiers from another system).\n\t * In that case, it is up to the user to ensure that the identifier is unique within the current tree - no other node should have the same identifier at the same time.\n\t * If the identifier is not unique, it may be read, but may cause libraries or features which operate over node identifiers to misbehave.\n\t * User-supplied identifiers may be read immediately, even before insertion into the tree.\n\t *\n\t * A node may have more than one identifier field (though note that this precludes the use of the `Tree.shortId()` API).\n\t */\n\tpublic get identifier(): FieldSchema<FieldKind.Identifier, typeof this.string> {\n\t\tconst defaultIdentifierProvider: DefaultProvider = getDefaultProvider(\n\t\t\t(nodeKeyManager: NodeKeyManager) => {\n\t\t\t\treturn nodeKeyManager.stabilizeNodeKey(nodeKeyManager.generateLocalNodeKey());\n\t\t\t},\n\t\t);\n\t\treturn createFieldSchema(FieldKind.Identifier, this.string, {\n\t\t\tdefaultProvider: defaultIdentifierProvider,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactory.object} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaFactory.object} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t *\n\t * Additionally `ImplicitlyConstructable` is disabled (forcing use of constructor) to avoid\n\t * `error TS2589: Type instantiation is excessively deep and possibly infinite.`\n\t * which otherwise gets reported at sometimes incorrect source locations that vary based on incremental builds.\n\t */\n\tpublic objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<RestrictiveStringRecord<ImplicitFieldSchema>>,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT\n\t> {\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tTreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT\n\t\t>;\n\t}\n\n\t/**\n\t * `SchemaFactory.array` except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.array` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<ImplicitAllowedTypes>,\n\t>(name: Name, allowedTypes: T) {\n\t\tconst RecursiveArray = this.namedArray(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\ttrue,\n\t\t\tfalse,\n\t\t);\n\n\t\treturn RecursiveArray as TreeNodeSchemaClass<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tNodeKind.Array,\n\t\t\tTreeArrayNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Array>,\n\t\t\t{\n\t\t\t\t/**\n\t\t\t\t * Iterator for the iterable of content for this node.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Wrapping the constructor parameter for recursive arrays and maps in an inlined object type avoids (for unknown reasons)\n\t\t\t\t * the following compile error when declaring the recursive schema:\n\t\t\t\t * `Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.`\n\t\t\t\t * To benefit from this without impacting the API, the definition of `Iterable` has been inlined as such an object.\n\t\t\t\t *\n\t\t\t\t * If this workaround is kept, ideally this comment would be deduplicated with the other instance of it.\n\t\t\t\t * Unfortunately attempts to do this failed to avoid the compile error this was introduced to solve.\n\t\t\t\t */\n\t\t\t\t[Symbol.iterator](): Iterator<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>;\n\t\t\t},\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tundefined\n\t\t>;\n\t}\n\n\t/**\n\t * `SchemaFactory.map` except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.map` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic mapRecursive<Name extends TName, const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t) {\n\t\tconst MapSchema = this.namedMap(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\ttrue,\n\t\t\t// Setting this (implicitlyConstructable) to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\tfalse,\n\t\t);\n\n\t\treturn MapSchema as TreeNodeSchemaClass<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tNodeKind.Map,\n\t\t\tTreeMapNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,\n\t\t\t| {\n\t\t\t\t\t/**\n\t\t\t\t\t * Iterator for the iterable of content for this node.\n\t\t\t\t\t * @privateRemarks\n\t\t\t\t\t * Wrapping the constructor parameter for recursive arrays and maps in an inlined object type avoids (for unknown reasons)\n\t\t\t\t\t * the following compile error when declaring the recursive schema:\n\t\t\t\t\t * `Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.`\n\t\t\t\t\t * To benefit from this without impacting the API, the definition of `Iterable` has been inlined as such an object.\n\t\t\t\t\t *\n\t\t\t\t\t * If this workaround is kept, ideally this comment would be deduplicated with the other instance of it.\n\t\t\t\t\t * Unfortunately attempts to do this failed to avoid the compile error this was introduced to solve.\n\t\t\t\t\t */\n\t\t\t\t\t[Symbol.iterator](): Iterator<\n\t\t\t\t\t\t[string, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>]\n\t\t\t\t\t>;\n\t\t\t }\n\t\t\t// Ideally this would be\n\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t// but doing so breaks recursive types.\n\t\t\t// Instead we do a less nice version:\n\t\t\t| {\n\t\t\t\t\treadonly [P in string]: InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t },\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tundefined\n\t\t>;\n\t}\n}\n\nexport function structuralName<const T extends string>(\n\tcollectionName: T,\n\tallowedTypes: TreeNodeSchema | readonly TreeNodeSchema[],\n): `${T}<${string}>` {\n\tlet inner: string;\n\tif (!isReadonlyArray(allowedTypes)) {\n\t\treturn structuralName(collectionName, [allowedTypes]);\n\t} else {\n\t\tconst names = allowedTypes.map((t): string => {\n\t\t\t// Ensure that lazy types (functions) don't slip through here.\n\t\t\tassert(!isLazy(t), 0x83d /* invalid type provided */);\n\t\t\tmarkSchemaMostDerived(t);\n\t\t\treturn t.identifier;\n\t\t});\n\t\t// Ensure name is order independent\n\t\tnames.sort();\n\t\t// Ensure name can't have collisions by quoting and escaping any quotes in the names of types.\n\t\t// Using JSON is a simple way to accomplish this.\n\t\t// The outer `[]` around the result were needed so that a single type name \"Any\" would not collide with the \"any\" case which used to exist.\n\t\tinner = JSON.stringify(names);\n\t}\n\treturn `${collectionName}<${inner}>`;\n}\n\n/**\n * Indicates that a schema is the \"most derived\" version which is allowed to be used, see {@link MostDerivedData}.\n * Calling helps with error messages about invalid schema usage (using more than one type from single schema factor produced type,\n * and thus calling this for one than one subclass).\n * @remarks\n * Helper for invoking {@link TreeNodeValid.markMostDerived} for any {@link TreeNodeSchema} if it needed.\n */\nexport function markSchemaMostDerived(schema: TreeNodeSchema): void {\n\tif (schema instanceof LeafNodeSchema) {\n\t\treturn;\n\t}\n\n\tif (!inPrototypeChain(schema, TreeNodeValid)) {\n\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\tthrow new UsageError(\n\t\t\t`Schema for ${JSON.stringify(\n\t\t\t\tschema.identifier,\n\t\t\t)} does not extend a SchemaFactory generated class. This is invalid.`,\n\t\t);\n\t}\n\n\t(schema as typeof TreeNodeValid & TreeNodeSchema).markMostDerived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,IAAI,MAAM,YAAY,kCAAc,EAAE,CAAC;QACtC,OAAO;IACR,CAAC;IAED,IAAI,CAAC,IAAA,2BAAgB,EAAC,MAAM,EAAE,gCAAa,CAAC,EAAE,CAAC;QAC9C,4DAA4D;QAC5D,MAAM,IAAI,qBAAU,CACnB,cAAc,IAAI,CAAC,SAAS,CAC3B,MAAM,CAAC,UAAU,CACjB,oEAAoE,CACrE,CAAC;IACH,CAAC;IAEA,MAAgD,CAAC,eAAe,EAAE,CAAC;AACrE,CAAC;AAfD,sDAeC","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\";\n// Include this unused import to avoid TypeScript generating an inline import for IFluidHandle in the d.ts file\n// which degrades the API-Extractor report quality since API-Extractor can not tell the inline import is the same as the non-inline one.\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport type { IFluidHandle as _dummyImport } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\n\nimport type { TreeValue } from \"../../core/index.js\";\nimport type { NodeKeyManager } from \"../../feature-libraries/index.js\";\nimport {\n\ttype RestrictiveStringRecord,\n\tgetOrCreate,\n\tisReadonlyArray,\n} from \"../../util/index.js\";\n// This import is required for intellisense in @link doc comments on mouseover in VSCode.\n// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars\nimport type { TreeAlpha } from \"../../shared-tree/index.js\";\n\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tLeafNodeSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport {\n\tFieldKind,\n\ttype FieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype FieldProps,\n\tcreateFieldSchema,\n\ttype DefaultProvider,\n\tgetDefaultProvider,\n\ttype NodeSchemaOptions,\n} from \"../schemaTypes.js\";\nimport { inPrototypeChain } from \"../core/index.js\";\nimport type {\n\tNodeKind,\n\tWithType,\n\tTreeNodeSchema,\n\tTreeNodeSchemaClass,\n\tTreeNodeSchemaNonClass,\n\tTreeNodeSchemaBoth,\n} from \"../core/index.js\";\nimport { type TreeArrayNode, arraySchema } from \"../arrayNode.js\";\nimport {\n\ttype InsertableObjectFromSchemaRecord,\n\ttype TreeObjectNode,\n\tobjectSchema,\n} from \"../objectNode.js\";\nimport { type MapNodeInsertableData, type TreeMapNode, mapSchema } from \"../mapNode.js\";\nimport type {\n\tFieldSchemaUnsafe,\n\t// Adding these unused imports makes the generated d.ts file produced by TypeScript stop breaking API-Extractor's rollup generation.\n\t// Without this import, TypeScript generates inline `import(\"../..\")` statements in the d.ts file,\n\t// which API-Extractor leaves as is when generating the rollup, leaving them pointing at the wrong directory.\n\t// API-Extractor issue: https://github.com/microsoft/rushstack/issues/4507\n\t// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars\n\tFieldHasDefaultUnsafe,\n\t// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars\n\tInsertableTreeFieldFromImplicitFieldUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tTreeObjectNodeUnsafe,\n\tUnenforced,\n} from \"./typesUnsafe.js\";\nimport { createFieldSchemaUnsafe } from \"./schemaFactoryRecursive.js\";\nimport { TreeNodeValid } from \"../treeNodeValid.js\";\nimport { isLazy } from \"../flexList.js\";\n\n/**\n * Gets the leaf domain schema compatible with a given {@link TreeValue}.\n */\nexport function schemaFromValue(value: TreeValue): TreeNodeSchema {\n\tswitch (typeof value) {\n\t\tcase \"boolean\":\n\t\t\treturn booleanSchema;\n\t\tcase \"number\":\n\t\t\treturn numberSchema;\n\t\tcase \"string\":\n\t\t\treturn stringSchema;\n\t\tcase \"object\": {\n\t\t\tif (value === null) {\n\t\t\t\treturn nullSchema;\n\t\t\t}\n\t\t\tassert(isFluidHandle(value), 0x87e /* invalid TreeValue */);\n\t\t\treturn handleSchema;\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(value);\n\t}\n}\n\n/**\n * Options when declaring an {@link SchemaFactory.object|object node}'s schema\n *\n * @alpha\n */\nexport interface SchemaFactoryObjectOptions<TCustomMetadata = unknown>\n\textends NodeSchemaOptions<TCustomMetadata> {\n\t/**\n\t * Allow nodes typed with this object node schema to contain optional fields that are not present in the schema declaration.\n\t * Such nodes can come into existence either via import APIs (see remarks) or by way of collaboration with another client\n\t * that has upgraded the document's schema to include those optional fields.\n\t *\n\t * @defaultValue `false`\n\t * @remarks\n\t * The advantage of enabling this option is that it allows an application ecosystem with staged rollout to more quickly\n\t * upgrade documents to include schema for new optional features.\n\t *\n\t * However, it does come with trade-offs that applications should weigh carefully when it comes to interactions between\n\t * code and documents.\n\t * When opening such documents, the API presented is still determined by the view schema.\n\t * This can have implications on the behavior of edits or code which uses portions of the view schema,\n\t * since this may inadvertently drop data which is present in those optional fields in the document schema.\n\t *\n\t * Consider the following example:\n\t *\n\t * ```typescript\n\t * const sf = new SchemaFactory(\"com.example\");\n\t * class PersonView extends sf.object(\"Person\", { name: sf.string }, { allowUnknownOptionalFields: true }) {}\n\t * class PersonStored extends sf.object(\"Person\", { name: sf.string, nickname: sf.optional(sf.string) }) {}\n\t *\n\t * // Say we have a document which uses `PersonStored` in its schema, and application code constructs\n\t * // a tree view using `PersonView`. If the application for some reason had implemented a function like this:\n\t * function clonePerson(a: PersonView): PersonView {\n\t * \treturn new PersonView({ name: a.name });\n\t * }\n\t * // ...or even like this:\n\t * function clonePerson(a: PersonView): PersonView {\n\t * return new PersonView({ ...a})\n\t * }\n\t * // Then the alleged clone wouldn't actually clone the entire person in either case, it would drop the nickname.\n\t * ```\n\t *\n\t * If an application wants to be particularly careful to preserve all data on a node when editing it, it can use\n\t * {@link TreeAlpha.(importVerbose:2)|import}/{@link TreeAlpha.(exportVerbose:2)|export} APIs with persistent keys.\n\t *\n\t * Note that public API methods which operate on entire nodes (such as `moveTo`, `moveToEnd`, etc. on arrays) do not encounter\n\t * this problem as SharedTree's implementation stores the entire node in its lower layers. It's only when application code\n\t * reaches into a node (either by accessing its fields, spreading it, or some other means) that this problem arises.\n\t */\n\tallowUnknownOptionalFields?: boolean;\n}\n\nexport const defaultSchemaFactoryObjectOptions: Required<\n\tOmit<SchemaFactoryObjectOptions, \"metadata\">\n> = {\n\tallowUnknownOptionalFields: false,\n};\n\n/**\n * The name of a schema produced by {@link SchemaFactory}, including its optional scope prefix.\n *\n * @system @public\n */\nexport type ScopedSchemaName<\n\tTScope extends string | undefined,\n\tTName extends number | string,\n> = TScope extends undefined ? `${TName}` : `${TScope}.${TName}`;\n// > = `${TScope extends undefined ? \"\" : `${TScope}.`}${TName}`;\n\n/**\n * Stateless APIs exposed via {@link SchemaFactory} as both instance properties and as statics.\n * @privateRemarks\n * We have no way to make linkable members which exist both as statics and instance properties since API-Extractor does not support this.\n * As a workaround, we have this type as a third place which can be linked.\n * @system @sealed @public\n */\nexport const schemaStatics = {\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `string`.\n\t *\n\t * @remarks\n\t * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.\n\t *\n\t * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.\n\t * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\tstring: stringSchema,\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `number`.\n\t *\n\t * @remarks\n\t * The number is a {@link https://en.wikipedia.org/wiki/Double-precision_floating-point_format | double-precision 64-bit binary format IEEE 754} value, however there are some exceptions:\n\t * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).\n\t * - `-0` may be converted to `0` in some cases.\n\t *\n\t * These limitations match the limitations of JSON.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\tnumber: numberSchema,\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a boolean.\n\t */\n\tboolean: booleanSchema,\n\n\t/**\n\t * {@link TreeNodeSchema} for JavaScript `null`.\n\t *\n\t * @remarks\n\t * There are good {@link https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null | reasons to avoid using null} in JavaScript, however sometimes it is desired.\n\t * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.\n\t * Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.\n\t */\n\tnull: nullSchema,\n\n\t/**\n\t * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.\n\t */\n\thandle: handleSchema,\n\n\t/**\n\t * {@link AllowedTypes} for holding any of the leaf types.\n\t */\n\tleaves: [stringSchema, numberSchema, booleanSchema, nullSchema, handleSchema],\n\n\t/**\n\t * Make a field optional instead of the default, which is required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n\t * See {@link FieldSchemaMetadata.custom}.\n\t */\n\toptional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchema<FieldKind.Optional, T, TCustomMetadata> => {\n\t\tconst defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => {\n\t\t\treturn undefined;\n\t\t});\n\t\treturn createFieldSchema(FieldKind.Optional, t, {\n\t\t\tdefaultProvider: defaultOptionalProvider,\n\t\t\t...props,\n\t\t});\n\t},\n\n\t/**\n\t * Make a field explicitly required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @remarks\n\t * Fields are required by default, but this API can be used to make the required nature explicit in the schema,\n\t * and allows associating custom {@link FieldProps | properties} with the field.\n\t *\n\t * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n\t * See {@link FieldSchemaMetadata.custom}.\n\t */\n\trequired: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchema<FieldKind.Required, T, TCustomMetadata> => {\n\t\treturn createFieldSchema(FieldKind.Required, t, props);\n\t},\n\n\t/**\n\t * {@link schemaStatics.optional} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link schemaStatics.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\toptionalRecursive: <const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchemaUnsafe<FieldKind.Optional, T> => {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Optional, t, props);\n\t},\n\n\t/**\n\t * {@link schemaStatics.required} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link schemaStatics.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\trequiredRecursive: <const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchemaUnsafe<FieldKind.Required, T> => {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Required, t, props);\n\t},\n} as const;\n\n// TODO:\n// SchemaFactory.array references should link to the correct overloads, however the syntax for this does not seems to work currently for methods unless the they are not qualified with the class.\n// API-Extractor requires such links to be qualified with the class, so it can't work.\n// Since linking the overload set as a whole also doesn't work, these have been made non-links for now.\n/**\n * Creates various types of {@link TreeNodeSchema|schema} for {@link TreeNode}s.\n *\n * @typeParam TScope - Scope added as a prefix to the name of every schema produced by this factory.\n * @typeParam TName - Type of names used to identify each schema produced in this factory.\n * Typically this is just `string` but it is also possible to use `string` or `number` based enums if you prefer to identify your types that way.\n *\n * @remarks\n * For details related to inputting data constrained by schema (including via assignment), and how non-exact schema types are handled in general refer to {@link Input}.\n * For information about recursive schema support, see methods postfixed with \"recursive\" and {@link ValidateRecursiveSchema}.\n * To apply schema defined with this factory to a tree, see {@link ViewableTree.viewWith} and {@link TreeViewConfiguration}.\n *\n * All schema produced by this factory get a {@link TreeNodeSchemaCore.identifier|unique identifier} by combining the {@link SchemaFactory.scope} with the schema's `Name`.\n * The `Name` part may be explicitly provided as a parameter, or inferred as a structural combination of the provided types.\n * The APIs which use this second approach, structural naming, also deduplicate all equivalent calls.\n * Therefor two calls to `array(allowedTypes)` with the same allowedTypes will return the same {@link TreeNodeSchema} instance.\n * On the other hand, two calls to `array(name, allowedTypes)` will always return different {@link TreeNodeSchema} instances\n * and it is an error to use both in the same tree (since their identifiers are not unique).\n *\n * Note:\n * POJO stands for Plain Old JavaScript Object.\n * This means an object that works like a `{}` style object literal.\n * In this case it means the prototype is `Object.prototype` and acts like a set of key value pairs (data, not methods).\n * The usage below generalizes this to include array and map like objects as well.\n *\n * There are two ways to use these APIs:\n *\n * Customizable Approach:\n *\n * 1. Declaration: `class X extends schemaFactory.object(\"x\", {}) {}`\n *\n * 2. Allows adding \"local\" (non-persisted) members: Yes. Members (including methods) can be added to the class.\n *\n * 3. Prototype: The user-defined class.\n *\n * 4. Structurally named Schema: Not Supported.\n *\n * 5. Explicitly named Objects: Supported.\n *\n * 6. Explicitly named Maps and Arrays: Supported: Both declaration approaches can be used.\n *\n * 7. Node.js `assert.deepEqual`: Compares like class instances: equal to other nodes of the same type with the same content, including custom local fields.\n *\n * 8. IntelliSense: Shows and links to user-defined class by name: `X`.\n *\n * 9. Recursion: Supported with special declaration patterns.\n *\n * POJO Emulation Approach:\n *\n * 1. Declaration: `const X = schemaFactory.object(\"x\", {}); type X = NodeFromSchema<typeof X>;`\n *\n * 2. Allows adding \"local\" (non-persisted) members: No. Attempting to set non-field members will result in an error.\n *\n * 3. Prototype: `Object.prototype`, `Map.prototype`, or `Array.prototype` depending on node kind.\n *\n * 4. Structurally named Schema: Supported.\n *\n * 5. Explicitly named Objects: Supported.\n *\n * 6. Explicitly named Maps and Arrays: Not Supported.\n *\n * 7. Node.js `assert.deepEqual`: Compares like plain objects: equal to plain JavaScript objects with the same fields, and other nodes with the same fields, even if the types are different.\n *\n * 8. IntelliSense: Shows internal type generation logic: `object & TreeNode & ObjectFromSchemaRecord<{}> & WithType<\"test.x\">`.\n *\n * 9. Recursion: Unsupported: Generated `.d.ts` files replace recursive references with `any`, breaking the use of recursive schema across compilation boundaries.\n *\n * Note that while \"POJO Emulation\" nodes act a lot like POJO objects, they are not true POJO objects:\n *\n * - Adding new arbitrary fields will error, as well some cases of invalid edits.\n *\n * - They are implemented using proxies.\n *\n * - They have state that is not exposed via enumerable own properties, including a {@link TreeNodeSchema}.\n * This makes libraries like node.js `assert.deepEqual` fail to detect differences in type.\n *\n * - Assigning members has side effects (in this case editing the persisted/shared tree).\n *\n * - Not all operations implied by the prototype will work correctly: stick to the APIs explicitly declared in the TypeScript types.\n *\n * @privateRemarks\n * It's perfectly possible to make `POJO Emulation` mode (or even just hiding the prototype) selectable even when using the custom user class declaration syntax.\n * When doing this, it's still possible to make `instanceof` perform correctly.\n * Allowing (or banning) custom/out-of-schema properties on the class is also possible in both modes: it could be orthogonal.\n * Also for consistency, if keeping the current approach to detecting `POJO Emulation` mode it might make sense to make explicitly named Maps and Arrays do the detection the same as how object does it.\n *\n * Note: the comparison between the customizable and POJO modes is not done in a table because TSDoc does not currently have support for embedded markdown.\n *\n * @see {@link SchemaFactoryAlpha}\n *\n * @sealed @public\n */\nexport class SchemaFactory<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> {\n\t/**\n\t * TODO:\n\t * If users of this generate the same name because two different schema with the same identifier were used,\n\t * the second use can get a cache hit, and reference the wrong schema.\n\t * Such usage should probably return a distinct type or error but currently does not.\n\t * The use of markSchemaMostDerived in structuralName at least ensure an error in the case where the collision is from two types extending the same schema factor class.\n\t */\n\tprivate readonly structuralTypes: Map<string, TreeNodeSchema> = new Map();\n\n\t/**\n\t * Construct a SchemaFactory with a given {@link SchemaFactory.scope|scope}.\n\t * @remarks\n\t * There are no restrictions on mixing schema from different schema factories.\n\t * Typically each library will create one or more SchemaFactories and use them to define its schema.\n\t */\n\tpublic constructor(\n\t\t/**\n\t\t * Prefix appended to the identifiers of all {@link TreeNodeSchema} produced by this builder.\n\t\t *\n\t\t * @remarks\n\t\t * Generally each independently developed library\n\t\t * (possibly a package, but could also be part of a package or multiple packages developed together)\n\t\t * should get its own unique `scope`.\n\t\t * Then each schema in the library get a name which is unique within the library.\n\t\t * The scope and name are joined (with a period) to form the {@link TreeNodeSchemaCore.identifier|schema identifier}.\n\t\t * Following this pattern allows a single application to depend on multiple libraries which define their own schema, and use them together in a single tree without risk of collisions.\n\t\t * If a library logically contains sub-libraries with their own schema, they can be given a scope nested inside the parent scope, such as \"ParentScope.ChildScope\".\n\t\t *\n\t\t * To avoid collisions between the scopes of libraries\n\t\t * it is recommended that the libraries use {@link https://en.wikipedia.org/wiki/Reverse_domain_name_notation | Reverse domain name notation} or a UUIDv4 for their scope.\n\t\t * If this pattern is followed, application can safely use third party libraries without risk of the schema in them colliding.\n\t\t *\n\t\t * You may opt out of using a scope by passing `undefined`, but note that this increases the risk of collisions.\n\t\t *\n\t\t * @example\n\t\t * Fluid Framework follows this pattern, placing the schema for the built in leaf types in the `com.fluidframework.leaf` scope.\n\t\t * If Fluid Framework publishes more schema in the future, they would be under some other `com.fluidframework` scope.\n\t\t * This ensures that any schema defined by any other library will not conflict with Fluid Framework's schema\n\t\t * as long as the library uses the recommended patterns for how to scope its schema..\n\t\t *\n\t\t * @example\n\t\t * A library could generate a random UUIDv4, like `242c4397-49ed-47e6-8dd0-d5c3bc31778b` and use that as the scope.\n\t\t * Note: do not use this UUID: a new one must be randomly generated when needed to ensure collision resistance.\n\t\t * ```typescript\n\t\t * const factory = new SchemaFactory(\"242c4397-49ed-47e6-8dd0-d5c3bc31778b\");\n\t\t * ```\n\t\t */\n\t\tpublic readonly scope: TScope,\n\t) {}\n\n\tprivate scoped<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * {@inheritDoc schemaStatics.string}\n\t */\n\tpublic readonly string = stringSchema;\n\n\t/**\n\t * {@inheritDoc schemaStatics.number}\n\t */\n\tpublic readonly number = numberSchema;\n\n\t/**\n\t * {@inheritDoc schemaStatics.boolean}\n\t */\n\tpublic readonly boolean = booleanSchema;\n\n\t/**\n\t * {@inheritDoc schemaStatics.null}\n\t */\n\tpublic readonly null = nullSchema;\n\n\t/**\n\t * {@inheritDoc schemaStatics.handle}\n\t */\n\tpublic readonly handle = handleSchema;\n\n\t/**\n\t * {@inheritDoc schemaStatics.leaves}\n\t */\n\tpublic readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc schemaStatics.string}\n\t */\n\tpublic static readonly string = stringSchema;\n\n\t/**\n\t * {@inheritDoc schemaStatics.number}\n\t */\n\tpublic static readonly number = numberSchema;\n\n\t/**\n\t * {@inheritDoc schemaStatics.boolean}\n\t */\n\tpublic static readonly boolean = booleanSchema;\n\n\t/**\n\t * {@inheritDoc schemaStatics.null}\n\t */\n\tpublic static readonly null = nullSchema;\n\n\t/**\n\t * {@inheritDoc schemaStatics.handle}\n\t */\n\tpublic static readonly handle = handleSchema;\n\n\t/**\n\t * {@inheritDoc schemaStatics.leaves}\n\t */\n\tpublic static readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t */\n\tpublic object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNode<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecord<T>,\n\t\ttrue,\n\t\tT\n\t> {\n\t\treturn objectSchema(\n\t\t\tthis.scoped(name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t);\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t *\n\t * @remarks\n\t * The unique identifier for this Map is defined as a function of the provided types.\n\t * It is still scoped to this SchemaBuilder, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named maps, other types in this schema builder should avoid names of the form `Map<${string}>`.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyMap = factory.map(factory.number);\n\t * type MyMap = NodeFromSchema<typeof MyMap>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", {myMap: factory.map(factory.number)});\n\t * ```\n\t * @privateRemarks\n\t * See note on array.\n\t */\n\tpublic map<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaNonClass<\n\t\tScopedSchemaName<TScope, `Map<${string}>`>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, `Map<${string}>`>, NodeKind.Map>,\n\t\tMapNodeInsertableData<T>,\n\t\ttrue,\n\t\tT,\n\t\tundefined\n\t>;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic map<Name extends TName, const T extends ImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,\n\t\tMapNodeInsertableData<T>,\n\t\ttrue,\n\t\tT,\n\t\tundefined\n\t>;\n\n\t/**\n\t * {@link SchemaFactory.map} implementation.\n\t *\n\t * @privateRemarks\n\t * This should return `TreeNodeSchemaBoth`, however TypeScript gives an error if one of the overloads implicitly up-casts the return type of the implementation.\n\t * This seems like a TypeScript bug getting variance backwards for overload return types since it's erroring when the relation between the overload\n\t * and the implementation is type safe, and forcing an unsafe typing instead.\n\t */\n\tpublic map<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): TreeNodeSchema<string, NodeKind.Map, TreeMapNode<T>, MapNodeInsertableData<T>, true, T> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Map\", types);\n\t\t\treturn getOrCreate(\n\t\t\t\tthis.structuralTypes,\n\t\t\t\tfullName,\n\t\t\t\t() =>\n\t\t\t\t\tthis.namedMap(\n\t\t\t\t\t\tfullName as TName,\n\t\t\t\t\t\tnameOrAllowedTypes as T,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t) as TreeNodeSchema,\n\t\t\t) as TreeNodeSchemaBoth<\n\t\t\t\tstring,\n\t\t\t\tNodeKind.Map,\n\t\t\t\tTreeMapNode<T>,\n\t\t\t\tMapNodeInsertableData<T>,\n\t\t\t\ttrue,\n\t\t\t\tT,\n\t\t\t\tundefined\n\t\t\t>;\n\t\t}\n\t\t// To actually have type safety, assign to the type this method should return before implicitly upcasting when returning.\n\t\tconst out: TreeNodeSchemaBoth<\n\t\t\tstring,\n\t\t\tNodeKind.Map,\n\t\t\tTreeMapNode<T>,\n\t\t\tMapNodeInsertableData<T>,\n\t\t\ttrue,\n\t\t\tT,\n\t\t\tundefined\n\t\t> = this.namedMap(nameOrAllowedTypes as TName, allowedTypes, true, true);\n\t\treturn out;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeMapNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t */\n\tprivate namedMap<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t): TreeNodeSchemaBoth<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,\n\t\tMapNodeInsertableData<T>,\n\t\tImplicitlyConstructable,\n\t\tT,\n\t\tundefined\n\t> {\n\t\treturn mapSchema(\n\t\t\tthis.scoped(name),\n\t\t\tallowedTypes,\n\t\t\timplicitlyConstructable,\n\t\t\t// The current policy is customizable nodes don't get fake prototypes.\n\t\t\t!customizable,\n\t\t\tundefined,\n\t\t);\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param allowedTypes - The types that may appear in the array.\n\t *\n\t * @remarks\n\t * The identifier for this Array is defined as a function of the provided types.\n\t * It is still scoped to this SchemaFactory, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named arrays, other types in this schema builder should avoid names of the form `Array<${string}>`.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyArray = factory.array(factory.number);\n\t * type MyArray = NodeFromSchema<typeof MyArray>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", {myArray: factory.array(factory.number)});\n\t * ```\n\t * @privateRemarks\n\t * The name produced at the type level here is not as specific as it could be, however doing type level sorting and escaping is a real mess.\n\t * There are cases where not having this full type provided will be less than ideal since TypeScript's structural types.\n\t * For example attempts to narrow unions of structural arrays by name won't work.\n\t * Planned future changes to move to a class based schema system as well as factor function based node construction should mostly avoid these issues,\n\t * though there may still be some problematic cases even after that work is done.\n\t *\n\t * The return value is a class, but its the type is intentionally not specific enough to indicate it is a class.\n\t * This prevents callers of this from sub-classing it, which is unlikely to work well (due to the ease of accidentally giving two different calls o this different subclasses)\n\t * when working with structural typing.\n\t *\n\t * {@label STRUCTURAL}\n\t */\n\tpublic array<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaNonClass<\n\t\tScopedSchemaName<TScope, `Array<${string}>`>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, `Array<${string}>`>, NodeKind.Array>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT,\n\t\tundefined\n\t>;\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.array(\"name\", factory.number) {}\n\t * ```\n\t *\n\t * {@label NAMED}\n\t */\n\tpublic array<const Name extends TName, const T extends ImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Array>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT,\n\t\tundefined\n\t>;\n\n\t/**\n\t * {@link SchemaFactory.array} implementation.\n\t *\n\t * @privateRemarks\n\t * This should return TreeNodeSchemaBoth: see note on \"map\" implementation for details.\n\t */\n\tpublic array<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): TreeNodeSchema<\n\t\tScopedSchemaName<TScope, string>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT\n\t> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Array\", types);\n\t\t\treturn getOrCreate(this.structuralTypes, fullName, () =>\n\t\t\t\tthis.namedArray(fullName, nameOrAllowedTypes as T, false, true),\n\t\t\t) as TreeNodeSchemaClass<\n\t\t\t\tScopedSchemaName<TScope, string>,\n\t\t\t\tNodeKind.Array,\n\t\t\t\tTreeArrayNode<T>,\n\t\t\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\t\t\ttrue,\n\t\t\t\tT,\n\t\t\t\tundefined\n\t\t\t>;\n\t\t}\n\t\tconst out: TreeNodeSchemaBoth<\n\t\t\tScopedSchemaName<TScope, string>,\n\t\t\tNodeKind.Array,\n\t\t\tTreeArrayNode<T>,\n\t\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\t\ttrue,\n\t\t\tT,\n\t\t\tundefined\n\t\t> = this.namedArray(nameOrAllowedTypes as TName, allowedTypes, true, true);\n\t\treturn out;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @remarks\n\t * This is not intended to be used directly, use the overload of `array` which takes a name instead.\n\t * This is only public to work around a compiler limitation.\n\t */\n\tprivate namedArray<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t): TreeNodeSchemaBoth<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, string>, NodeKind.Array>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\tImplicitlyConstructable,\n\t\tT,\n\t\tundefined\n\t> {\n\t\treturn arraySchema(this.scoped(name), allowedTypes, implicitlyConstructable, customizable);\n\t}\n\n\t/**\n\t * {@inheritDoc schemaStatics.optional}\n\t */\n\tpublic readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc schemaStatics.required}\n\t */\n\tpublic readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc schemaStatics.optionalRecursive}\n\t */\n\tpublic readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc schemaStatics.requiredRecursive}\n\t */\n\tpublic readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * {@inheritDoc schemaStatics.optional}\n\t */\n\tpublic static readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc schemaStatics.required}\n\t */\n\tpublic static readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc schemaStatics.optionalRecursive}\n\t */\n\tpublic static readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc schemaStatics.requiredRecursive}\n\t */\n\tpublic static readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * A special field which holds a unique identifier for an object node.\n\t * @remarks\n\t * The value of this field, a \"node identifier\", uniquely identifies a node among all other nodes in the tree.\n\t * Node identifiers are strings, and can therefore be used as lookup keys in maps or written to a database.\n\t * When the node is constructed, the identifier field does not need to be populated.\n\t * The SharedTree will provide an identifier for the node automatically.\n\t * An identifier provided automatically by the SharedTree has the following properties:\n\t * - It is a UUID.\n\t * - It is compressed to a space-efficient representation when stored in the document.\n\t * - A compressed form of the identifier can be accessed at runtime via the `Tree.shortId()` API.\n\t * - It will error if read (and will not be present in the object's iterable properties) before the node has been inserted into the tree.\n\t *\n\t * However, a user may alternatively supply their own string as the identifier if desired (for example, if importing identifiers from another system).\n\t * In that case, it is up to the user to ensure that the identifier is unique within the current tree - no other node should have the same identifier at the same time.\n\t * If the identifier is not unique, it may be read, but may cause libraries or features which operate over node identifiers to misbehave.\n\t * User-supplied identifiers may be read immediately, even before insertion into the tree.\n\t *\n\t * A node may have more than one identifier field (though note that this precludes the use of the `Tree.shortId()` API).\n\t */\n\tpublic get identifier(): FieldSchema<FieldKind.Identifier, typeof this.string> {\n\t\tconst defaultIdentifierProvider: DefaultProvider = getDefaultProvider(\n\t\t\t(nodeKeyManager: NodeKeyManager) => {\n\t\t\t\treturn nodeKeyManager.stabilizeNodeKey(nodeKeyManager.generateLocalNodeKey());\n\t\t\t},\n\t\t);\n\t\treturn createFieldSchema(FieldKind.Identifier, this.string, {\n\t\t\tdefaultProvider: defaultIdentifierProvider,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactory.object} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaFactory.object} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t *\n\t * Additionally `ImplicitlyConstructable` is disabled (forcing use of constructor) to avoid\n\t * `error TS2589: Type instantiation is excessively deep and possibly infinite.`\n\t * which otherwise gets reported at sometimes incorrect source locations that vary based on incremental builds.\n\t */\n\tpublic objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<RestrictiveStringRecord<ImplicitFieldSchema>>,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT\n\t> {\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tTreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT\n\t\t>;\n\t}\n\n\t/**\n\t * `SchemaFactory.array` except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.array` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<ImplicitAllowedTypes>,\n\t>(name: Name, allowedTypes: T) {\n\t\tconst RecursiveArray = this.namedArray(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\ttrue,\n\t\t\tfalse,\n\t\t);\n\n\t\treturn RecursiveArray as TreeNodeSchemaClass<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tNodeKind.Array,\n\t\t\tTreeArrayNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Array>,\n\t\t\t{\n\t\t\t\t/**\n\t\t\t\t * Iterator for the iterable of content for this node.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Wrapping the constructor parameter for recursive arrays and maps in an inlined object type avoids (for unknown reasons)\n\t\t\t\t * the following compile error when declaring the recursive schema:\n\t\t\t\t * `Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.`\n\t\t\t\t * To benefit from this without impacting the API, the definition of `Iterable` has been inlined as such an object.\n\t\t\t\t *\n\t\t\t\t * If this workaround is kept, ideally this comment would be deduplicated with the other instance of it.\n\t\t\t\t * Unfortunately attempts to do this failed to avoid the compile error this was introduced to solve.\n\t\t\t\t */\n\t\t\t\t[Symbol.iterator](): Iterator<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>;\n\t\t\t},\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tundefined\n\t\t>;\n\t}\n\n\t/**\n\t * `SchemaFactory.map` except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.map` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic mapRecursive<Name extends TName, const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t) {\n\t\tconst MapSchema = this.namedMap(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\ttrue,\n\t\t\t// Setting this (implicitlyConstructable) to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\tfalse,\n\t\t);\n\n\t\treturn MapSchema as TreeNodeSchemaClass<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tNodeKind.Map,\n\t\t\tTreeMapNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,\n\t\t\t| {\n\t\t\t\t\t/**\n\t\t\t\t\t * Iterator for the iterable of content for this node.\n\t\t\t\t\t * @privateRemarks\n\t\t\t\t\t * Wrapping the constructor parameter for recursive arrays and maps in an inlined object type avoids (for unknown reasons)\n\t\t\t\t\t * the following compile error when declaring the recursive schema:\n\t\t\t\t\t * `Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.`\n\t\t\t\t\t * To benefit from this without impacting the API, the definition of `Iterable` has been inlined as such an object.\n\t\t\t\t\t *\n\t\t\t\t\t * If this workaround is kept, ideally this comment would be deduplicated with the other instance of it.\n\t\t\t\t\t * Unfortunately attempts to do this failed to avoid the compile error this was introduced to solve.\n\t\t\t\t\t */\n\t\t\t\t\t[Symbol.iterator](): Iterator<\n\t\t\t\t\t\t[string, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>]\n\t\t\t\t\t>;\n\t\t\t }\n\t\t\t// Ideally this would be\n\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t// but doing so breaks recursive types.\n\t\t\t// Instead we do a less nice version:\n\t\t\t| {\n\t\t\t\t\treadonly [P in string]: InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t },\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tundefined\n\t\t>;\n\t}\n}\n\nexport function structuralName<const T extends string>(\n\tcollectionName: T,\n\tallowedTypes: TreeNodeSchema | readonly TreeNodeSchema[],\n): `${T}<${string}>` {\n\tlet inner: string;\n\tif (!isReadonlyArray(allowedTypes)) {\n\t\treturn structuralName(collectionName, [allowedTypes]);\n\t} else {\n\t\tconst names = allowedTypes.map((t): string => {\n\t\t\t// Ensure that lazy types (functions) don't slip through here.\n\t\t\tassert(!isLazy(t), 0x83d /* invalid type provided */);\n\t\t\tmarkSchemaMostDerived(t);\n\t\t\treturn t.identifier;\n\t\t});\n\t\t// Ensure name is order independent\n\t\tnames.sort();\n\t\t// Ensure name can't have collisions by quoting and escaping any quotes in the names of types.\n\t\t// Using JSON is a simple way to accomplish this.\n\t\t// The outer `[]` around the result were needed so that a single type name \"Any\" would not collide with the \"any\" case which used to exist.\n\t\tinner = JSON.stringify(names);\n\t}\n\treturn `${collectionName}<${inner}>`;\n}\n\n/**\n * Indicates that a schema is the \"most derived\" version which is allowed to be used, see {@link MostDerivedData}.\n * Calling helps with error messages about invalid schema usage (using more than one type from single schema factor produced type,\n * and thus calling this for one than one subclass).\n * @remarks\n * Helper for invoking {@link TreeNodeValid.markMostDerived} for any {@link TreeNodeSchema} if it needed.\n */\nexport function markSchemaMostDerived(schema: TreeNodeSchema): void {\n\tif (schema instanceof LeafNodeSchema) {\n\t\treturn;\n\t}\n\n\tif (!inPrototypeChain(schema, TreeNodeValid)) {\n\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\tthrow new UsageError(\n\t\t\t`Schema for ${JSON.stringify(\n\t\t\t\tschema.identifier,\n\t\t\t)} does not extend a SchemaFactory generated class. This is invalid.`,\n\t\t);\n\t}\n\n\t(schema as typeof TreeNodeValid & TreeNodeSchema).markMostDerived();\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { TreeNode } from "../simple-tree/index.js";
5
+ import type { TreeNode } from "../core/index.js";
6
6
  /**
7
7
  * A special object that signifies when a SharedTree {@link RunTransaction | transaction} should "roll back".
8
8
  * @public
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactionTypes.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/transactionTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,QAAQ,eAA4C,CAAC;AAElE;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CAAC,aAAa,EAAE,aAAa,IAAI,CACnE;IACA,gEAAgE;IAChE,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,oEAAoE;IACpE,KAAK,EAAE,aAAa,CAAC;CACpB,GACD;IACA,gGAAgG;IAChG,QAAQ,EAAE,IAAI,CAAC;IACf,0DAA0D;IAC1D,KAAK,EAAE,aAAa,CAAC;CACpB,CACH,GAAG;IACH;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACzD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAC/C,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,EAC3C,OAAO,CACP,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,wBAAwB,CAAC,aAAa;IACtD,qDAAqD;IACrD,OAAO,EAAE,IAAI,CAAC;IACd,kEAAkE;IAClE,KAAK,EAAE,aAAa,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB,CAAC,aAAa;IACrD,6CAA6C;IAC7C,OAAO,EAAE,KAAK,CAAC;IACf,0DAA0D;IAC1D,KAAK,EAAE,aAAa,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,aAAa,EAAE,aAAa,IAC1D,wBAAwB,CAAC,aAAa,CAAC,GACvC,uBAAuB,CAAC,aAAa,CAAC,CAAC;AAE1C;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAC1B,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAChD,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;CAC1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"transactionTypes.js","sourceRoot":"","sources":["../../src/shared-tree/transactionTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;;GAGG;AACU,QAAA,QAAQ,GAAG,MAAM,CAAC,iCAAiC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeNode } from \"../simple-tree/index.js\";\n\n/**\n * A special object that signifies when a SharedTree {@link RunTransaction | transaction} should \"roll back\".\n * @public\n */\nexport const rollback = Symbol(\"SharedTree Transaction Rollback\");\n\n/**\n * A requirement for a SharedTree transaction to succeed.\n * @remarks Transaction constraints are useful for validating that the state of the tree meets some requirement when a transaction runs.\n * In general, when running a transaction a client can validate their tree state in whatever way they wish and decide to either proceed with the transaction or not.\n * However, they cannot know what the tree state will be when the transaction is _sequenced_.\n * There may have been any number of edits from other clients that get sequenced before the transaction is eventually sequenced.\n * Constraints provide a way to validate the tree state after the transaction has been sequenced and abort the transaction if the constraints are not met.\n * All clients will validate the constraints of a transaction when it is sequenced, so all clients will agree on whether the transaction succeeds or not.\n * @public\n */\nexport type TransactionConstraint = NodeInDocumentConstraint; // TODO: Add more constraint types here\n\n/**\n * A transaction {@link TransactionConstraint | constraint} which requires that the given node exists in the tree.\n * @remarks The node must be in the document (its {@link TreeStatus | status} must be {@link TreeStatus.InDocument | InDocument}) to qualify as \"existing\".\n * @public\n */\nexport interface NodeInDocumentConstraint {\n\treadonly type: \"nodeInDocument\";\n\treadonly node: TreeNode;\n}\n\n/**\n * The status of the transaction callback in the {@link RunTransaction | RunTransaction} API.\n * @alpha\n */\nexport type TransactionCallbackStatus<TSuccessValue, TFailureValue> = (\n\t| {\n\t\t\t/** Indicates that the transaction callback ran successfully. */\n\t\t\trollback?: false;\n\t\t\t/** The user defined value when the transaction ran successfully. */\n\t\t\tvalue: TSuccessValue;\n\t }\n\t| {\n\t\t\t/** Indicates that the transaction callback failed and the transaction should be rolled back. */\n\t\t\trollback: true;\n\t\t\t/** The user defined value when the transaction failed. */\n\t\t\tvalue: TFailureValue;\n\t }\n) & {\n\t/**\n\t * An optional list of {@link TransactionConstraint | constraints} that will be checked when the commit corresponding\n\t * to this transaction is reverted. If any of these constraints are not met when the revert is being applied either\n\t * locally or on remote clients, the revert will be ignored.\n\t * These constraints must also be met at the time they are first introduced. If they are not met after the transaction\n\t * callback returns, then `runTransaction` (which invokes the transaction callback) will throw a `UsageError`.\n\t */\n\tpreconditionsOnRevert?: readonly TransactionConstraint[];\n};\n\n/**\n * The status of a the transaction callback in the {@link RunTransaction | RunTransaction} API where the transaction doesn't\n * need to return a value. This is the same as {@link TransactionCallbackStatus} but with the `value` field omitted. This\n * @alpha\n */\nexport type VoidTransactionCallbackStatus = Omit<\n\tTransactionCallbackStatus<unknown, unknown>,\n\t\"value\"\n>;\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API when it was successful.\n * @alpha\n */\nexport interface TransactionResultSuccess<TSuccessValue> {\n\t/** Indicates that the transaction was successful. */\n\tsuccess: true;\n\t/** The user defined value when the transaction was successful. */\n\tvalue: TSuccessValue;\n}\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API when it failed.\n * @alpha\n */\nexport interface TransactionResultFailed<TFailureValue> {\n\t/** Indicates that the transaction failed. */\n\tsuccess: false;\n\t/** The user defined value when the transaction failed. */\n\tvalue: TFailureValue;\n}\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API.\n * @alpha\n */\nexport type TransactionResultExt<TSuccessValue, TFailureValue> =\n\t| TransactionResultSuccess<TSuccessValue>\n\t| TransactionResultFailed<TFailureValue>;\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API. This is the same as {@link TransactionResultExt}\n * but with the `value` field omitted. This is useful when the transaction callback doesn't need to return a value.\n * @alpha\n */\nexport type TransactionResult =\n\t| Omit<TransactionResultSuccess<unknown>, \"value\">\n\t| Omit<TransactionResultFailed<unknown>, \"value\">;\n\n/**\n * The parameters for the {@link RunTransaction | RunTransaction} API.\n * @alpha\n */\nexport interface RunTransactionParams {\n\t/**\n\t * An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, an error will be thrown.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on\n\t * this client and ignored by all other clients.\n\t */\n\treadonly preconditions?: readonly TransactionConstraint[];\n}\n"]}
1
+ {"version":3,"file":"transactionTypes.js","sourceRoot":"","sources":["../../../src/simple-tree/api/transactionTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;;GAGG;AACU,QAAA,QAAQ,GAAG,MAAM,CAAC,iCAAiC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeNode } from \"../core/index.js\";\n\n/**\n * A special object that signifies when a SharedTree {@link RunTransaction | transaction} should \"roll back\".\n * @public\n */\nexport const rollback = Symbol(\"SharedTree Transaction Rollback\");\n\n/**\n * A requirement for a SharedTree transaction to succeed.\n * @remarks Transaction constraints are useful for validating that the state of the tree meets some requirement when a transaction runs.\n * In general, when running a transaction a client can validate their tree state in whatever way they wish and decide to either proceed with the transaction or not.\n * However, they cannot know what the tree state will be when the transaction is _sequenced_.\n * There may have been any number of edits from other clients that get sequenced before the transaction is eventually sequenced.\n * Constraints provide a way to validate the tree state after the transaction has been sequenced and abort the transaction if the constraints are not met.\n * All clients will validate the constraints of a transaction when it is sequenced, so all clients will agree on whether the transaction succeeds or not.\n * @public\n */\nexport type TransactionConstraint = NodeInDocumentConstraint; // TODO: Add more constraint types here\n\n/**\n * A transaction {@link TransactionConstraint | constraint} which requires that the given node exists in the tree.\n * @remarks The node must be in the document (its {@link TreeStatus | status} must be {@link TreeStatus.InDocument | InDocument}) to qualify as \"existing\".\n * @public\n */\nexport interface NodeInDocumentConstraint {\n\treadonly type: \"nodeInDocument\";\n\treadonly node: TreeNode;\n}\n\n/**\n * The status of the transaction callback in the {@link RunTransaction | RunTransaction} API.\n * @alpha\n */\nexport type TransactionCallbackStatus<TSuccessValue, TFailureValue> = (\n\t| {\n\t\t\t/** Indicates that the transaction callback ran successfully. */\n\t\t\trollback?: false;\n\t\t\t/** The user defined value when the transaction ran successfully. */\n\t\t\tvalue: TSuccessValue;\n\t }\n\t| {\n\t\t\t/** Indicates that the transaction callback failed and the transaction should be rolled back. */\n\t\t\trollback: true;\n\t\t\t/** The user defined value when the transaction failed. */\n\t\t\tvalue: TFailureValue;\n\t }\n) & {\n\t/**\n\t * An optional list of {@link TransactionConstraint | constraints} that will be checked when the commit corresponding\n\t * to this transaction is reverted. If any of these constraints are not met when the revert is being applied either\n\t * locally or on remote clients, the revert will be ignored.\n\t * These constraints must also be met at the time they are first introduced. If they are not met after the transaction\n\t * callback returns, then `runTransaction` (which invokes the transaction callback) will throw a `UsageError`.\n\t */\n\tpreconditionsOnRevert?: readonly TransactionConstraint[];\n};\n\n/**\n * The status of a the transaction callback in the {@link RunTransaction | RunTransaction} API where the transaction doesn't\n * need to return a value. This is the same as {@link TransactionCallbackStatus} but with the `value` field omitted. This\n * @alpha\n */\nexport type VoidTransactionCallbackStatus = Omit<\n\tTransactionCallbackStatus<unknown, unknown>,\n\t\"value\"\n>;\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API when it was successful.\n * @alpha\n */\nexport interface TransactionResultSuccess<TSuccessValue> {\n\t/** Indicates that the transaction was successful. */\n\tsuccess: true;\n\t/** The user defined value when the transaction was successful. */\n\tvalue: TSuccessValue;\n}\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API when it failed.\n * @alpha\n */\nexport interface TransactionResultFailed<TFailureValue> {\n\t/** Indicates that the transaction failed. */\n\tsuccess: false;\n\t/** The user defined value when the transaction failed. */\n\tvalue: TFailureValue;\n}\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API.\n * @alpha\n */\nexport type TransactionResultExt<TSuccessValue, TFailureValue> =\n\t| TransactionResultSuccess<TSuccessValue>\n\t| TransactionResultFailed<TFailureValue>;\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API. This is the same as {@link TransactionResultExt}\n * but with the `value` field omitted. This is useful when the transaction callback doesn't need to return a value.\n * @alpha\n */\nexport type TransactionResult =\n\t| Omit<TransactionResultSuccess<unknown>, \"value\">\n\t| Omit<TransactionResultFailed<unknown>, \"value\">;\n\n/**\n * The parameters for the {@link RunTransaction | RunTransaction} API.\n * @alpha\n */\nexport interface RunTransactionParams {\n\t/**\n\t * An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, an error will be thrown.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on\n\t * this client and ignored by all other clients.\n\t */\n\treadonly preconditions?: readonly TransactionConstraint[];\n}\n"]}