@fluidframework/tree 2.71.0 → 2.72.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 (603) hide show
  1. package/CHANGELOG.md +26 -40
  2. package/api-report/tree.alpha.api.md +27 -18
  3. package/api-report/tree.beta.api.md +42 -0
  4. package/api-report/tree.legacy.beta.api.md +42 -0
  5. package/dist/alpha.d.ts +9 -7
  6. package/dist/api.js +1 -1
  7. package/dist/api.js.map +1 -1
  8. package/dist/beta.d.ts +7 -0
  9. package/dist/codec/codec.d.ts +16 -1
  10. package/dist/codec/codec.d.ts.map +1 -1
  11. package/dist/codec/codec.js +16 -3
  12. package/dist/codec/codec.js.map +1 -1
  13. package/dist/core/index.d.ts +1 -1
  14. package/dist/core/index.d.ts.map +1 -1
  15. package/dist/core/index.js +2 -2
  16. package/dist/core/index.js.map +1 -1
  17. package/dist/core/schema-stored/index.d.ts +1 -1
  18. package/dist/core/schema-stored/index.d.ts.map +1 -1
  19. package/dist/core/schema-stored/index.js +2 -2
  20. package/dist/core/schema-stored/index.js.map +1 -1
  21. package/dist/core/schema-stored/schema.d.ts +6 -6
  22. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  23. package/dist/core/schema-stored/schema.js +6 -7
  24. package/dist/core/schema-stored/schema.js.map +1 -1
  25. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +2 -1
  26. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  27. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  28. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +1 -1
  29. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  30. package/dist/core/tree/detachedFieldIndexCodecV1.js +3 -2
  31. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  32. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  33. package/dist/core/tree/detachedFieldIndexCodecV2.js +3 -1
  34. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  35. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +2 -3
  36. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  37. package/dist/core/tree/detachedFieldIndexCodecs.js +29 -8
  38. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  39. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +10 -1
  40. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  41. package/dist/core/tree/detachedFieldIndexFormatCommon.js +8 -1
  42. package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
  43. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +2 -2
  44. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -1
  45. package/dist/core/tree/detachedFieldIndexFormatV1.js +3 -3
  46. package/dist/core/tree/detachedFieldIndexFormatV1.js.map +1 -1
  47. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +2 -2
  48. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  49. package/dist/core/tree/detachedFieldIndexFormatV2.js +3 -3
  50. package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
  51. package/dist/core/tree/index.d.ts +2 -1
  52. package/dist/core/tree/index.d.ts.map +1 -1
  53. package/dist/core/tree/index.js.map +1 -1
  54. package/dist/external-utilities/typeboxValidator.js +1 -1
  55. package/dist/external-utilities/typeboxValidator.js.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -10
  57. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  58. package/dist/feature-libraries/chunked-forest/codec/codecs.js +12 -8
  59. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  62. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +8 -3
  63. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/format.js +9 -4
  65. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  66. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  67. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/codec/index.js +1 -2
  69. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  70. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  71. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +1 -1
  72. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  73. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  74. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  75. package/dist/feature-libraries/chunked-forest/index.js +1 -2
  76. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  77. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -9
  78. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  79. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +3 -21
  80. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  81. package/dist/feature-libraries/forest-summary/codec.d.ts +4 -5
  82. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  83. package/dist/feature-libraries/forest-summary/codec.js +15 -4
  84. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  85. package/dist/feature-libraries/forest-summary/forestSummarizer.js +1 -1
  86. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  87. package/dist/feature-libraries/forest-summary/format.d.ts +8 -1
  88. package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
  89. package/dist/feature-libraries/forest-summary/format.js +8 -3
  90. package/dist/feature-libraries/forest-summary/format.js.map +1 -1
  91. package/dist/feature-libraries/forest-summary/index.d.ts +2 -1
  92. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  93. package/dist/feature-libraries/forest-summary/index.js +3 -1
  94. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  95. package/dist/feature-libraries/index.d.ts +3 -3
  96. package/dist/feature-libraries/index.d.ts.map +1 -1
  97. package/dist/feature-libraries/index.js +2 -2
  98. package/dist/feature-libraries/index.js.map +1 -1
  99. package/dist/feature-libraries/schema-edits/index.d.ts +1 -1
  100. package/dist/feature-libraries/schema-edits/index.d.ts.map +1 -1
  101. package/dist/feature-libraries/schema-edits/index.js.map +1 -1
  102. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -7
  103. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  104. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +5 -4
  105. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  106. package/dist/feature-libraries/schema-index/codec.d.ts +10 -10
  107. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  108. package/dist/feature-libraries/schema-index/codec.js +22 -18
  109. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  110. package/dist/feature-libraries/schema-index/formatV1.d.ts +2 -2
  111. package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
  112. package/dist/feature-libraries/schema-index/formatV1.js +1 -1
  113. package/dist/feature-libraries/schema-index/formatV1.js.map +1 -1
  114. package/dist/feature-libraries/schema-index/formatV2.d.ts +1 -2
  115. package/dist/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
  116. package/dist/feature-libraries/schema-index/formatV2.js +1 -1
  117. package/dist/feature-libraries/schema-index/formatV2.js.map +1 -1
  118. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
  119. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  120. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  121. package/dist/index.d.ts +1 -1
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +3 -1
  124. package/dist/index.js.map +1 -1
  125. package/dist/legacy.d.ts +7 -0
  126. package/dist/packageVersion.d.ts +1 -1
  127. package/dist/packageVersion.js +1 -1
  128. package/dist/packageVersion.js.map +1 -1
  129. package/dist/shared-tree/independentView.d.ts +1 -1
  130. package/dist/shared-tree/independentView.d.ts.map +1 -1
  131. package/dist/shared-tree/independentView.js +22 -15
  132. package/dist/shared-tree/independentView.js.map +1 -1
  133. package/dist/shared-tree/sharedTree.d.ts +12 -16
  134. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  135. package/dist/shared-tree/sharedTree.js +87 -127
  136. package/dist/shared-tree/sharedTree.js.map +1 -1
  137. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +7 -6
  138. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  139. package/dist/shared-tree/sharedTreeChangeCodecs.js +12 -11
  140. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  141. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  142. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  143. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  144. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  145. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  146. package/dist/shared-tree/treeAlpha.js +4 -2
  147. package/dist/shared-tree/treeAlpha.js.map +1 -1
  148. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  149. package/dist/shared-tree/treeCheckout.js +1 -3
  150. package/dist/shared-tree/treeCheckout.js.map +1 -1
  151. package/dist/shared-tree-core/editManagerCodecs.d.ts +19 -6
  152. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  153. package/dist/shared-tree-core/editManagerCodecs.js +35 -17
  154. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  155. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +37 -0
  156. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  157. package/dist/shared-tree-core/editManagerFormatCommons.js +43 -1
  158. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  159. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  160. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  161. package/dist/shared-tree-core/editManagerFormatV1toV4.js +4 -4
  162. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  163. package/dist/shared-tree-core/editManagerFormatV5.d.ts +2 -2
  164. package/dist/shared-tree-core/editManagerFormatV5.d.ts.map +1 -1
  165. package/dist/shared-tree-core/editManagerFormatV5.js +1 -1
  166. package/dist/shared-tree-core/editManagerFormatV5.js.map +1 -1
  167. package/dist/shared-tree-core/index.d.ts +5 -3
  168. package/dist/shared-tree-core/index.d.ts.map +1 -1
  169. package/dist/shared-tree-core/index.js +11 -3
  170. package/dist/shared-tree-core/index.js.map +1 -1
  171. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -1
  172. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  173. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  174. package/dist/shared-tree-core/messageCodecV5.d.ts +2 -1
  175. package/dist/shared-tree-core/messageCodecV5.d.ts.map +1 -1
  176. package/dist/shared-tree-core/messageCodecV5.js.map +1 -1
  177. package/dist/shared-tree-core/messageCodecs.d.ts +19 -6
  178. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  179. package/dist/shared-tree-core/messageCodecs.js +38 -21
  180. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  181. package/dist/shared-tree-core/messageFormat.d.ts +50 -0
  182. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -0
  183. package/dist/shared-tree-core/messageFormat.js +51 -0
  184. package/dist/shared-tree-core/messageFormat.js.map +1 -0
  185. package/dist/shared-tree-core/sharedTreeCore.d.ts +8 -8
  186. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  187. package/dist/shared-tree-core/sharedTreeCore.js +3 -3
  188. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  189. package/dist/simple-tree/api/discrepancies.d.ts +2 -2
  190. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  191. package/dist/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  192. package/dist/simple-tree/api/incrementalAllowedTypes.js +1 -1
  193. package/dist/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  194. package/dist/simple-tree/api/index.d.ts +3 -2
  195. package/dist/simple-tree/api/index.d.ts.map +1 -1
  196. package/dist/simple-tree/api/index.js +4 -1
  197. package/dist/simple-tree/api/index.js.map +1 -1
  198. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +2 -98
  199. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  200. package/dist/simple-tree/api/schemaFactoryAlpha.js +1 -52
  201. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  202. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +98 -2
  203. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  204. package/dist/simple-tree/api/schemaFactoryBeta.js +61 -7
  205. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  206. package/dist/simple-tree/api/schemaFromSimple.js +6 -3
  207. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  208. package/dist/simple-tree/api/simpleSchemaCodec.d.ts +28 -0
  209. package/dist/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -0
  210. package/dist/simple-tree/api/simpleSchemaCodec.js +292 -0
  211. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -0
  212. package/dist/simple-tree/api/storedSchema.d.ts +2 -2
  213. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  214. package/dist/simple-tree/api/storedSchema.js +8 -6
  215. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  216. package/dist/simple-tree/api/tree.d.ts +2 -2
  217. package/dist/simple-tree/api/tree.js.map +1 -1
  218. package/dist/simple-tree/api/typesUnsafe.d.ts +6 -6
  219. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  220. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +18 -3
  221. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  222. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +78 -35
  223. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  224. package/dist/simple-tree/core/allowedTypes.d.ts +3 -3
  225. package/dist/simple-tree/core/allowedTypes.js +1 -1
  226. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  227. package/dist/simple-tree/core/treeNode.js +1 -1
  228. package/dist/simple-tree/core/treeNode.js.map +1 -1
  229. package/dist/simple-tree/index.d.ts +2 -1
  230. package/dist/simple-tree/index.d.ts.map +1 -1
  231. package/dist/simple-tree/index.js +4 -0
  232. package/dist/simple-tree/index.js.map +1 -1
  233. package/dist/simple-tree/node-kinds/array/arrayNode.js +1 -1
  234. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  235. package/dist/simple-tree/node-kinds/map/mapNode.js +1 -1
  236. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  237. package/dist/simple-tree/node-kinds/object/objectNode.js +2 -2
  238. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  239. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -2
  240. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  241. package/dist/simple-tree/simpleSchema.d.ts +11 -3
  242. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  243. package/dist/simple-tree/simpleSchema.js.map +1 -1
  244. package/dist/simple-tree/simpleSchemaFormatV1.d.ts +249 -0
  245. package/dist/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -0
  246. package/dist/simple-tree/simpleSchemaFormatV1.js +115 -0
  247. package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -0
  248. package/dist/tableSchema.d.ts.map +1 -1
  249. package/dist/tableSchema.js +1 -1
  250. package/dist/tableSchema.js.map +1 -1
  251. package/dist/treeFactory.d.ts +3 -1
  252. package/dist/treeFactory.d.ts.map +1 -1
  253. package/dist/treeFactory.js +26 -2
  254. package/dist/treeFactory.js.map +1 -1
  255. package/dist/util/brand.d.ts +31 -2
  256. package/dist/util/brand.d.ts.map +1 -1
  257. package/dist/util/brand.js +28 -2
  258. package/dist/util/brand.js.map +1 -1
  259. package/dist/util/brandedMap.d.ts +3 -1
  260. package/dist/util/brandedMap.d.ts.map +1 -1
  261. package/dist/util/brandedMap.js.map +1 -1
  262. package/dist/util/index.d.ts +1 -1
  263. package/dist/util/index.d.ts.map +1 -1
  264. package/dist/util/index.js +3 -2
  265. package/dist/util/index.js.map +1 -1
  266. package/lib/alpha.d.ts +9 -7
  267. package/lib/api.js +2 -2
  268. package/lib/api.js.map +1 -1
  269. package/lib/beta.d.ts +7 -0
  270. package/lib/codec/codec.d.ts +16 -1
  271. package/lib/codec/codec.d.ts.map +1 -1
  272. package/lib/codec/codec.js +16 -3
  273. package/lib/codec/codec.js.map +1 -1
  274. package/lib/core/index.d.ts +1 -1
  275. package/lib/core/index.d.ts.map +1 -1
  276. package/lib/core/index.js +1 -1
  277. package/lib/core/index.js.map +1 -1
  278. package/lib/core/schema-stored/index.d.ts +1 -1
  279. package/lib/core/schema-stored/index.d.ts.map +1 -1
  280. package/lib/core/schema-stored/index.js +1 -1
  281. package/lib/core/schema-stored/index.js.map +1 -1
  282. package/lib/core/schema-stored/schema.d.ts +6 -6
  283. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  284. package/lib/core/schema-stored/schema.js +6 -7
  285. package/lib/core/schema-stored/schema.js.map +1 -1
  286. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +2 -1
  287. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  288. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  289. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +1 -1
  290. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  291. package/lib/core/tree/detachedFieldIndexCodecV1.js +3 -2
  292. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  293. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  294. package/lib/core/tree/detachedFieldIndexCodecV2.js +4 -2
  295. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  296. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +2 -3
  297. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  298. package/lib/core/tree/detachedFieldIndexCodecs.js +29 -8
  299. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  300. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +10 -1
  301. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  302. package/lib/core/tree/detachedFieldIndexFormatCommon.js +7 -0
  303. package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
  304. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts +2 -2
  305. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -1
  306. package/lib/core/tree/detachedFieldIndexFormatV1.js +3 -3
  307. package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -1
  308. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +2 -2
  309. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  310. package/lib/core/tree/detachedFieldIndexFormatV2.js +3 -3
  311. package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
  312. package/lib/core/tree/index.d.ts +2 -1
  313. package/lib/core/tree/index.d.ts.map +1 -1
  314. package/lib/core/tree/index.js +1 -1
  315. package/lib/core/tree/index.js.map +1 -1
  316. package/lib/external-utilities/typeboxValidator.js +1 -1
  317. package/lib/external-utilities/typeboxValidator.js.map +1 -1
  318. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -10
  319. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  320. package/lib/feature-libraries/chunked-forest/codec/codecs.js +13 -8
  321. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  322. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +2 -2
  323. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  324. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +8 -3
  325. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  326. package/lib/feature-libraries/chunked-forest/codec/format.js +8 -3
  327. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  328. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  329. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  330. package/lib/feature-libraries/chunked-forest/codec/index.js +2 -2
  331. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  332. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  333. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  334. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  335. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  336. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  337. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  338. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  339. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -9
  340. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  341. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +2 -20
  342. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  343. package/lib/feature-libraries/forest-summary/codec.d.ts +4 -5
  344. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  345. package/lib/feature-libraries/forest-summary/codec.js +16 -5
  346. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  347. package/lib/feature-libraries/forest-summary/forestSummarizer.js +1 -1
  348. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  349. package/lib/feature-libraries/forest-summary/format.d.ts +8 -1
  350. package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
  351. package/lib/feature-libraries/forest-summary/format.js +7 -2
  352. package/lib/feature-libraries/forest-summary/format.js.map +1 -1
  353. package/lib/feature-libraries/forest-summary/index.d.ts +2 -1
  354. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  355. package/lib/feature-libraries/forest-summary/index.js +1 -0
  356. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  357. package/lib/feature-libraries/index.d.ts +3 -3
  358. package/lib/feature-libraries/index.d.ts.map +1 -1
  359. package/lib/feature-libraries/index.js +2 -2
  360. package/lib/feature-libraries/index.js.map +1 -1
  361. package/lib/feature-libraries/schema-edits/index.d.ts +1 -1
  362. package/lib/feature-libraries/schema-edits/index.d.ts.map +1 -1
  363. package/lib/feature-libraries/schema-edits/index.js.map +1 -1
  364. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -7
  365. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  366. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +6 -5
  367. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  368. package/lib/feature-libraries/schema-index/codec.d.ts +10 -10
  369. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  370. package/lib/feature-libraries/schema-index/codec.js +24 -20
  371. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  372. package/lib/feature-libraries/schema-index/formatV1.d.ts +2 -2
  373. package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
  374. package/lib/feature-libraries/schema-index/formatV1.js +2 -2
  375. package/lib/feature-libraries/schema-index/formatV1.js.map +1 -1
  376. package/lib/feature-libraries/schema-index/formatV2.d.ts +1 -2
  377. package/lib/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
  378. package/lib/feature-libraries/schema-index/formatV2.js +2 -2
  379. package/lib/feature-libraries/schema-index/formatV2.js.map +1 -1
  380. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
  381. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  382. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  383. package/lib/index.d.ts +1 -1
  384. package/lib/index.d.ts.map +1 -1
  385. package/lib/index.js +1 -1
  386. package/lib/index.js.map +1 -1
  387. package/lib/legacy.d.ts +7 -0
  388. package/lib/packageVersion.d.ts +1 -1
  389. package/lib/packageVersion.js +1 -1
  390. package/lib/packageVersion.js.map +1 -1
  391. package/lib/shared-tree/independentView.d.ts +1 -1
  392. package/lib/shared-tree/independentView.d.ts.map +1 -1
  393. package/lib/shared-tree/independentView.js +11 -4
  394. package/lib/shared-tree/independentView.js.map +1 -1
  395. package/lib/shared-tree/sharedTree.d.ts +12 -16
  396. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  397. package/lib/shared-tree/sharedTree.js +90 -130
  398. package/lib/shared-tree/sharedTree.js.map +1 -1
  399. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +7 -6
  400. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  401. package/lib/shared-tree/sharedTreeChangeCodecs.js +7 -6
  402. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  403. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  404. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  405. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  406. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  407. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  408. package/lib/shared-tree/treeAlpha.js +5 -3
  409. package/lib/shared-tree/treeAlpha.js.map +1 -1
  410. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  411. package/lib/shared-tree/treeCheckout.js +1 -3
  412. package/lib/shared-tree/treeCheckout.js.map +1 -1
  413. package/lib/shared-tree-core/editManagerCodecs.d.ts +19 -6
  414. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  415. package/lib/shared-tree-core/editManagerCodecs.js +32 -16
  416. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  417. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +37 -0
  418. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  419. package/lib/shared-tree-core/editManagerFormatCommons.js +42 -0
  420. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  421. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  422. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  423. package/lib/shared-tree-core/editManagerFormatV1toV4.js +5 -5
  424. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  425. package/lib/shared-tree-core/editManagerFormatV5.d.ts +2 -2
  426. package/lib/shared-tree-core/editManagerFormatV5.d.ts.map +1 -1
  427. package/lib/shared-tree-core/editManagerFormatV5.js +2 -2
  428. package/lib/shared-tree-core/editManagerFormatV5.js.map +1 -1
  429. package/lib/shared-tree-core/index.d.ts +5 -3
  430. package/lib/shared-tree-core/index.d.ts.map +1 -1
  431. package/lib/shared-tree-core/index.js +4 -2
  432. package/lib/shared-tree-core/index.js.map +1 -1
  433. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -1
  434. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  435. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  436. package/lib/shared-tree-core/messageCodecV5.d.ts +2 -1
  437. package/lib/shared-tree-core/messageCodecV5.d.ts.map +1 -1
  438. package/lib/shared-tree-core/messageCodecV5.js.map +1 -1
  439. package/lib/shared-tree-core/messageCodecs.d.ts +19 -6
  440. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  441. package/lib/shared-tree-core/messageCodecs.js +35 -20
  442. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  443. package/lib/shared-tree-core/messageFormat.d.ts +50 -0
  444. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -0
  445. package/lib/shared-tree-core/messageFormat.js +48 -0
  446. package/lib/shared-tree-core/messageFormat.js.map +1 -0
  447. package/lib/shared-tree-core/sharedTreeCore.d.ts +8 -8
  448. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  449. package/lib/shared-tree-core/sharedTreeCore.js +3 -3
  450. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  451. package/lib/simple-tree/api/discrepancies.d.ts +2 -2
  452. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  453. package/lib/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  454. package/lib/simple-tree/api/incrementalAllowedTypes.js +1 -1
  455. package/lib/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  456. package/lib/simple-tree/api/index.d.ts +3 -2
  457. package/lib/simple-tree/api/index.d.ts.map +1 -1
  458. package/lib/simple-tree/api/index.js +1 -0
  459. package/lib/simple-tree/api/index.js.map +1 -1
  460. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +2 -98
  461. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  462. package/lib/simple-tree/api/schemaFactoryAlpha.js +1 -52
  463. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  464. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +98 -2
  465. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  466. package/lib/simple-tree/api/schemaFactoryBeta.js +58 -4
  467. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  468. package/lib/simple-tree/api/schemaFromSimple.js +6 -3
  469. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  470. package/lib/simple-tree/api/simpleSchemaCodec.d.ts +28 -0
  471. package/lib/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -0
  472. package/lib/simple-tree/api/simpleSchemaCodec.js +264 -0
  473. package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -0
  474. package/lib/simple-tree/api/storedSchema.d.ts +2 -2
  475. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  476. package/lib/simple-tree/api/storedSchema.js +5 -3
  477. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  478. package/lib/simple-tree/api/tree.d.ts +2 -2
  479. package/lib/simple-tree/api/tree.js.map +1 -1
  480. package/lib/simple-tree/api/typesUnsafe.d.ts +6 -6
  481. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  482. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +18 -3
  483. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  484. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +75 -34
  485. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  486. package/lib/simple-tree/core/allowedTypes.d.ts +3 -3
  487. package/lib/simple-tree/core/allowedTypes.js +1 -1
  488. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  489. package/lib/simple-tree/core/treeNode.js +1 -1
  490. package/lib/simple-tree/core/treeNode.js.map +1 -1
  491. package/lib/simple-tree/index.d.ts +2 -1
  492. package/lib/simple-tree/index.d.ts.map +1 -1
  493. package/lib/simple-tree/index.js +1 -0
  494. package/lib/simple-tree/index.js.map +1 -1
  495. package/lib/simple-tree/node-kinds/array/arrayNode.js +2 -2
  496. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  497. package/lib/simple-tree/node-kinds/map/mapNode.js +2 -2
  498. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  499. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -3
  500. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  501. package/lib/simple-tree/node-kinds/record/recordNode.js +3 -3
  502. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  503. package/lib/simple-tree/simpleSchema.d.ts +11 -3
  504. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  505. package/lib/simple-tree/simpleSchema.js.map +1 -1
  506. package/lib/simple-tree/simpleSchemaFormatV1.d.ts +249 -0
  507. package/lib/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -0
  508. package/lib/simple-tree/simpleSchemaFormatV1.js +112 -0
  509. package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -0
  510. package/lib/tableSchema.d.ts.map +1 -1
  511. package/lib/tableSchema.js +1 -1
  512. package/lib/tableSchema.js.map +1 -1
  513. package/lib/treeFactory.d.ts +3 -1
  514. package/lib/treeFactory.d.ts.map +1 -1
  515. package/lib/treeFactory.js +23 -1
  516. package/lib/treeFactory.js.map +1 -1
  517. package/lib/util/brand.d.ts +31 -2
  518. package/lib/util/brand.d.ts.map +1 -1
  519. package/lib/util/brand.js +26 -1
  520. package/lib/util/brand.js.map +1 -1
  521. package/lib/util/brandedMap.d.ts +3 -1
  522. package/lib/util/brandedMap.d.ts.map +1 -1
  523. package/lib/util/brandedMap.js.map +1 -1
  524. package/lib/util/index.d.ts +1 -1
  525. package/lib/util/index.d.ts.map +1 -1
  526. package/lib/util/index.js +1 -1
  527. package/lib/util/index.js.map +1 -1
  528. package/package.json +24 -24
  529. package/src/api.ts +2 -2
  530. package/src/codec/codec.ts +17 -3
  531. package/src/core/index.ts +1 -2
  532. package/src/core/schema-stored/index.ts +1 -2
  533. package/src/core/schema-stored/schema.ts +10 -7
  534. package/src/core/tree/detachedFieldIndexCodecCommon.ts +2 -1
  535. package/src/core/tree/detachedFieldIndexCodecV1.ts +4 -2
  536. package/src/core/tree/detachedFieldIndexCodecV2.ts +4 -6
  537. package/src/core/tree/detachedFieldIndexCodecs.ts +33 -11
  538. package/src/core/tree/detachedFieldIndexFormatCommon.ts +17 -2
  539. package/src/core/tree/detachedFieldIndexFormatV1.ts +6 -4
  540. package/src/core/tree/detachedFieldIndexFormatV2.ts +6 -4
  541. package/src/core/tree/index.ts +2 -4
  542. package/src/external-utilities/typeboxValidator.ts +1 -1
  543. package/src/feature-libraries/chunked-forest/codec/codecs.ts +18 -13
  544. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +2 -2
  545. package/src/feature-libraries/chunked-forest/codec/format.ts +15 -4
  546. package/src/feature-libraries/chunked-forest/codec/index.ts +4 -2
  547. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +2 -2
  548. package/src/feature-libraries/chunked-forest/index.ts +0 -1
  549. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +2 -29
  550. package/src/feature-libraries/forest-summary/codec.ts +24 -9
  551. package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -1
  552. package/src/feature-libraries/forest-summary/format.ts +12 -2
  553. package/src/feature-libraries/forest-summary/index.ts +2 -1
  554. package/src/feature-libraries/index.ts +1 -2
  555. package/src/feature-libraries/schema-edits/index.ts +0 -1
  556. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +16 -16
  557. package/src/feature-libraries/schema-index/codec.ts +34 -22
  558. package/src/feature-libraries/schema-index/formatV1.ts +2 -2
  559. package/src/feature-libraries/schema-index/formatV2.ts +2 -2
  560. package/src/feature-libraries/schema-index/schemaSummarizer.ts +2 -1
  561. package/src/index.ts +3 -1
  562. package/src/packageVersion.ts +1 -1
  563. package/src/shared-tree/independentView.ts +16 -5
  564. package/src/shared-tree/sharedTree.ts +112 -172
  565. package/src/shared-tree/sharedTreeChangeCodecs.ts +15 -9
  566. package/src/shared-tree/sharedTreeChangeFamily.ts +2 -2
  567. package/src/shared-tree/treeAlpha.ts +6 -5
  568. package/src/shared-tree/treeCheckout.ts +1 -3
  569. package/src/shared-tree-core/editManagerCodecs.ts +56 -19
  570. package/src/shared-tree-core/editManagerFormatCommons.ts +47 -0
  571. package/src/shared-tree-core/editManagerFormatV1toV4.ts +10 -5
  572. package/src/shared-tree-core/editManagerFormatV5.ts +3 -3
  573. package/src/shared-tree-core/index.ts +11 -5
  574. package/src/shared-tree-core/messageCodecV1ToV4.ts +6 -1
  575. package/src/shared-tree-core/messageCodecV5.ts +2 -1
  576. package/src/shared-tree-core/messageCodecs.ts +60 -26
  577. package/src/shared-tree-core/messageFormat.ts +56 -0
  578. package/src/shared-tree-core/sharedTreeCore.ts +11 -13
  579. package/src/simple-tree/api/discrepancies.ts +2 -2
  580. package/src/simple-tree/api/incrementalAllowedTypes.ts +1 -1
  581. package/src/simple-tree/api/index.ts +6 -2
  582. package/src/simple-tree/api/schemaFactoryAlpha.ts +2 -168
  583. package/src/simple-tree/api/schemaFactoryBeta.ts +180 -14
  584. package/src/simple-tree/api/schemaFromSimple.ts +6 -3
  585. package/src/simple-tree/api/simpleSchemaCodec.ts +360 -0
  586. package/src/simple-tree/api/storedSchema.ts +8 -5
  587. package/src/simple-tree/api/tree.ts +2 -2
  588. package/src/simple-tree/api/typesUnsafe.ts +6 -6
  589. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +80 -47
  590. package/src/simple-tree/core/allowedTypes.ts +3 -3
  591. package/src/simple-tree/core/treeNode.ts +2 -2
  592. package/src/simple-tree/index.ts +5 -1
  593. package/src/simple-tree/node-kinds/array/arrayNode.ts +2 -2
  594. package/src/simple-tree/node-kinds/map/mapNode.ts +2 -2
  595. package/src/simple-tree/node-kinds/object/objectNode.ts +3 -3
  596. package/src/simple-tree/node-kinds/record/recordNode.ts +3 -3
  597. package/src/simple-tree/simpleSchema.ts +12 -3
  598. package/src/simple-tree/simpleSchemaFormatV1.ts +179 -0
  599. package/src/tableSchema.ts +5 -2
  600. package/src/treeFactory.ts +33 -1
  601. package/src/util/brand.ts +40 -2
  602. package/src/util/brandedMap.ts +3 -1
  603. package/src/util/index.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6jBH;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC9B,IAAuB;IAEvB,OAAO,IAA8B,CAAC;AACvC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, IDisposable, Listenable } from \"@fluidframework/core-interfaces\";\n\nimport type {\n\tCommitMetadata,\n\tRevertibleAlphaFactory,\n\tRevertibleFactory,\n} from \"../../core/index.js\";\nimport type {\n\t// This is referenced by doc comments.\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports\n\tTreeAlpha,\n} from \"../../shared-tree/index.js\";\nimport type {\n\tImplicitFieldSchema,\n\tInsertableField,\n\tInsertableTreeFieldFromImplicitField,\n\tReadableField,\n\tReadSchema,\n\tTreeFieldFromImplicitField,\n} from \"../fieldSchema.js\";\nimport type { UnsafeUnknownSchema } from \"../unsafeUnknownSchema.js\";\nimport type { SimpleTreeSchema } from \"../simpleSchema.js\";\n\nimport type { TreeViewConfiguration } from \"./configuration.js\";\nimport type {\n\tRunTransactionParams,\n\tTransactionCallbackStatus,\n\tTransactionResult,\n\tTransactionResultExt,\n\tVoidTransactionCallbackStatus,\n} from \"./transactionTypes.js\";\nimport type { VerboseTree } from \"./verboseTree.js\";\n\n/**\n * A tree from which a {@link TreeView} can be created.\n *\n * @privateRemarks\n * TODO:\n * Add stored key versions of {@link (TreeAlpha:interface).(exportVerbose:2)}, {@link (TreeAlpha:interface).(exportConcise:2)} and {@link (TreeAlpha:interface).exportCompressed} here so tree content can be accessed without a view schema.\n * Add exportSimpleSchema and exportJsonSchema methods (which should exactly match the concise format, and match the free functions for exporting view schema).\n * Maybe rename \"exportJsonSchema\" to align on \"concise\" terminology.\n * Ensure schema exporting APIs here align and reference APIs for exporting view schema to the same formats (which should include stored vs property key choice).\n * Make sure users of independentView can use these export APIs (maybe provide a reference back to the ViewableTree from the TreeView to accomplish that).\n * @system @sealed @public\n */\nexport interface ViewableTree {\n\t/**\n\t * Returns a {@link TreeView} using the provided schema.\n\t * If the stored schema is compatible with the view schema specified by `config`,\n\t * the returned {@link TreeView} will expose the root with a schema-aware API based on the provided view schema.\n\t * If the provided schema is incompatible with the stored schema, the view will instead expose a status indicating the incompatibility.\n\t *\n\t * @remarks\n\t * If the tree is uninitialized (has no schema and no content), use {@link TreeView.initialize} on the returned view to set the schema and content together.\n\t * Using `viewWith` followed by {@link TreeView.upgradeSchema} to initialize only the schema for a document is technically valid when the schema\n\t * permits trees with no content.\n\t *\n\t * Note that other clients can modify the document at any time, causing the view to change its compatibility status: see {@link TreeView.events} for how to handle invalidation in these cases.\n\t *\n\t * Only one schematized view may exist for a given ITree at a time.\n\t * If creating a second, the first must be disposed before calling `viewWith` again.\n\t *\n\t * @privateRemarks\n\t * TODO: Support adapters for handling out-of-schema data.\n\t */\n\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * Channel for a Fluid Tree DDS.\n * @remarks\n * Allows storing and collaboratively editing schema-aware hierarchial data.\n * @sealed @public\n */\nexport interface ITree extends ViewableTree, IFluidLoadable {}\n\n/**\n * {@link ITree} extended with some alpha APIs.\n * @sealed @alpha\n */\nexport interface ITreeAlpha extends ITree {\n\t/**\n\t * Exports root in the same format as {@link (TreeAlpha:interface).(exportVerbose:1)} using stored keys.\n\t * @remarks\n\t * This is `undefined` if and only if the root field is empty (this can only happen if the root field is optional).\n\t */\n\texportVerbose(): VerboseTree | undefined;\n\n\t/**\n\t * Exports the SimpleTreeSchema that is stored in the tree, using stored keys for object fields.\n\t * @remarks\n\t * To get the schema using property keys, use {@link getSimpleSchema} on the view schema.\n\t */\n\texportSimpleSchema(): SimpleTreeSchema;\n\n\t/**\n\t * Creates a fork of the current state of the main branch.\n\t * This new branch will be shared with and editable by all clients.\n\t */\n\tcreateSharedBranch(): string;\n\n\t/**\n\t * Returns a list of all shared branches that currently exist on this tree.\n\t * Any one of them can be checked out using {@link ITreeAlpha.viewSharedBranchWith}.\n\t */\n\tgetSharedBranchIds(): string[];\n\n\t/**\n\t * Returns a view of the tree on the specified shared branch, using the provided schema.\n\t * See {@link ViewableTree.viewWith}.\n\t */\n\tviewSharedBranchWith<TRoot extends ImplicitFieldSchema>(\n\t\tbranchId: string,\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * A collection of functionality associated with a (version-control-style) branch of a SharedTree.\n * @remarks A `TreeBranch` allows for the {@link TreeBranch.fork | creation of branches} and for those branches to later be {@link TreeBranch.merge | merged}.\n *\n * The branch associated directly with the {@link ITree | SharedTree} is the \"main\" branch, and all other branches fork (directly or transitively) from that main branch.\n * @sealed @beta\n */\nexport interface TreeBranch extends IDisposable {\n\t/**\n\t * Fork a new branch off of this branch which is based off of this branch's current state.\n\t * @remarks Any changes to the tree on the new branch will not apply to this branch until the new branch is e.g. {@link TreeBranch.merge | merged} back into this branch.\n\t * The branch should be disposed when no longer needed, either {@link TreeBranch.dispose | explicitly} or {@link TreeBranch.merge | implicitly when merging} into another branch.\n\t */\n\tfork(): TreeBranch;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param branch - a branch which was created by a call to `branch()`.\n\t * @param disposeMerged - whether or not to dispose `branch` after the merge completes.\n\t * Defaults to true.\n\t * The {@link TreeBranch | main branch} cannot be disposed - attempting to do so will have no effect.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t */\n\tmerge(branch: TreeBranch, disposeMerged?: boolean): void;\n\n\t/**\n\t * Advance this branch forward such that all new changes on the target branch become part of this branch.\n\t * @param branch - The branch to rebase onto.\n\t * @remarks After rebasing, this branch will be \"ahead\" of the target branch, that is, its unique changes will have been recreated as if they happened after all changes on the target branch.\n\t * This method may only be called on branches produced via {@link TreeBranch.fork | branch} - attempting to rebase the main branch will throw.\n\t *\n\t * Rebasing long-lived branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" branch was created or last rebased.\n\t *\n\t * The {@link TreeBranch | main branch} cannot be rebased onto another branch - attempting to do so will throw an error.\n\t */\n\trebaseOnto(branch: TreeBranch): void;\n\n\t/**\n\t * Dispose of this branch, cleaning up any resources associated with it.\n\t * @param error - Optional error indicating the reason for the disposal, if the object was disposed as the result of an error.\n\t * @remarks Branches can also be automatically disposed when {@link TreeBranch.merge | they are merged} into another branch.\n\t *\n\t * Disposing branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" branch was created or last {@link TreeBranch.rebaseOnto | rebased}.\n\t *\n\t * The {@link TreeBranch | main branch} cannot be disposed - attempting to do so will have no effect.\n\t */\n\tdispose(error?: Error): void;\n}\n\n/**\n * {@link TreeBranch} with alpha-level APIs.\n * @remarks\n * The `TreeBranch` for a specific {@link TreeNode} may be acquired by calling `TreeAlpha.branch`.\n *\n * A branch does not necessarily know the schema of its SharedTree - to convert a branch to a {@link TreeViewAlpha | view with a schema}, use {@link TreeBranchAlpha.hasRootSchema | hasRootSchema()}.\n * @sealed @alpha\n */\nexport interface TreeBranchAlpha extends TreeBranch {\n\t/**\n\t * Events for the branch\n\t */\n\treadonly events: Listenable<TreeBranchEvents>;\n\n\t/**\n\t * Returns true if this branch has the given schema as its root schema.\n\t * @remarks This is a type guard which allows this branch to become strongly typed as a {@link TreeViewAlpha | view} of the given schema.\n\t *\n\t * To succeed, the given schema must be invariant to the schema of the view - it must include exactly the same allowed types.\n\t * For example, a schema of `Foo | Bar` will not match a view schema of `Foo`, and likewise a schema of `Foo` will not match a view schema of `Foo | Bar`.\n\t * @example\n\t * ```typescript\n\t * if (branch.hasRootSchema(MySchema)) {\n\t * const { root } = branch; // `branch` is now a TreeViewAlpha<MySchema>\n\t * // ...\n\t * }\n\t * ```\n\t */\n\thasRootSchema<TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t): this is TreeViewAlpha<TSchema>;\n\n\t// Override the base fork method to return the alpha variant.\n\tfork(): TreeBranchAlpha;\n\n\t/**\n\t * Run a transaction which applies one or more edits to the tree as a single atomic unit.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * It should return a status object of {@link TransactionCallbackStatus | TransactionCallbackStatus } type.\n\t * It includes a \"rollback\" property which may be returned as true at any point during the transaction. This will\n\t * abort the transaction and discard any changes it made so far.\n\t * \"rollback\" can be set to false or left undefined to indicate that the body of the transaction has successfully run.\n\t * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.\n\t * @returns A result object of {@link TransactionResultExt | TransactionResultExt} type. It includes the following:\n\t *\n\t * - A \"success\" flag indicating whether the transaction was successful or not.\n\t * - The success or failure value as returned by the transaction function.\n\t *\n\t * @remarks\n\t * This API will throw an error if the constraints are not met or something unexpected happens.\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t *\n\t * Nested transactions:\n\t * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:\n\t *\n\t * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.\n\t * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated\n\t * for the outermost transaction which includes all inner transactions.\n\t * - Undo will undo the outermost transaction and all inner transactions.\n\t */\n\trunTransaction<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => TransactionCallbackStatus<TSuccessValue, TFailureValue>,\n\t\tparams?: RunTransactionParams,\n\t): TransactionResultExt<TSuccessValue, TFailureValue>;\n\t/**\n\t * Run a transaction which applies one or more edits to the tree as a single atomic unit.\n\t * @param transaction - The function to run as the body of the transaction. It may return the following:\n\t *\n\t * - Nothing to indicate that the body of the transaction has successfully run.\n\t * - A status object of {@link VoidTransactionCallbackStatus | VoidTransactionCallbackStatus } type. It includes a \"rollback\" property which\n\t * may be returned as true at any point during the transaction. This will abort the transaction and discard any changes it made so\n\t * far. \"rollback\" can be set to false or left undefined to indicate that the body of the transaction has successfully run.\n\t *\n\t * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.\n\t * @returns A result object of {@link TransactionResult | TransactionResult} type. It includes a \"success\" flag indicating whether the\n\t * transaction was successful or not.\n\t *\n\t * @remarks\n\t * This API will throw an error if the constraints are not met or something unexpected happens.\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t *\n\t * Nested transactions:\n\t * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:\n\t *\n\t * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.\n\t * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated\n\t * for the outermost transaction which includes all inner transactions.\n\t * - Undo will undo the outermost transaction and all inner transactions.\n\t */\n\trunTransaction(\n\t\ttransaction: () => VoidTransactionCallbackStatus | void,\n\t\tparams?: RunTransactionParams,\n\t): TransactionResult;\n}\n\n/**\n * An editable view of a (version control style) branch of a shared tree based on some schema.\n *\n * @remarks\n * This schema (known as the view schema) may or may not align with the stored schema of the document.\n * Information about discrepancies between the two schemas is available via {@link TreeView.compatibility | compatibility}.\n *\n * Application authors are encouraged to read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/docs/user-facing/schema-evolution.md | schema-evolution.md}\n * and choose a schema compatibility policy that aligns with their application's needs.\n *\n * @privateRemarks\n * From an API design perspective, `upgradeSchema` could be merged into `viewWith` and/or `viewWith` could return errors explicitly on incompatible documents.\n * Such approaches would make it discoverable that out of schema handling may need to be done.\n * Doing that would however complicate trivial \"hello world\" style example slightly, as well as be a breaking API change.\n * It also seems more complex to handle invalidation with that pattern.\n * Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.\n *\n * @see {@link TreeViewAlpha}\n * @see {@link asTreeViewAlpha}\n *\n * @sealed @public\n */\nexport interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {\n\t/**\n\t * The current root of the tree.\n\t *\n\t * If the view schema not sufficiently compatible with the stored schema, accessing this will throw.\n\t * To handle this case, check {@link TreeView.compatibility | compatibility}'s {@link SchemaCompatibilityStatus.canView | canView} before using.\n\t *\n\t * To get notified about changes to this field,\n\t * use {@link TreeViewEvents.rootChanged} via `view.events.on(\"rootChanged\", callback)`.\n\t *\n\t * To get notified about changes to stored schema (which may affect compatibility between this view's schema and\n\t * the stored schema), use {@link TreeViewEvents.schemaChanged} via `view.events.on(\"schemaChanged\", callback)`.\n\t */\n\tget root(): TreeFieldFromImplicitField<TSchema>;\n\n\tset root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);\n\n\t/**\n\t * Description of the current compatibility status between the view schema and stored schema.\n\t *\n\t * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status changes.\n\t */\n\treadonly compatibility: SchemaCompatibilityStatus;\n\n\t/**\n\t * When {@link SchemaCompatibilityStatus.canUpgrade} is true,\n\t * this can be used to modify the stored schema to make it match the view schema.\n\t * @remarks\n\t * This will update the {@link TreeView.compatibility}, allowing access to `root`.\n\t * Beware that this may impact other clients' ability to view the document: see {@link SchemaCompatibilityStatus.canView} for more information.\n\t *\n\t * It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false.\n\t * {@link SchemaCompatibilityStatus.canUpgrade} being true does not mean that an upgrade is required, nor that an upgrade will have any effect.\n\t * @privateRemarks\n\t * In the future, more upgrade options could be provided here.\n\t * Some options that could be added:\n\t * - check the actual document contents (not just the schema) and attempt an atomic document update if the data is compatible.\n\t * - apply converters and upgrade the document.\n\t * - apply converters to lazily to adapt the document to the requested view schema (with optional lazy schema updates or transparent conversions on write).\n\t * - update only a specific change (add an optional field, or apply a staged upgrade)\n\t * - update persistedMetadata or not\n\t *\n\t * As persisted metadata becomes more supported, how it interacts with isEquivalent and upgradeSchema should be clarified:\n\t * for now the docs are being left somewhat vague to allow flexibility in this area.\n\t */\n\tupgradeSchema(): void;\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;\n\n\t/**\n\t * Events for the tree.\n\t */\n\treadonly events: Listenable<TreeViewEvents>;\n\n\t/**\n\t * The view schema used by this TreeView.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * {@link TreeView} with proposed changes to the schema aware typing to allow use with `UnsafeUnknownSchema`.\n * @sealed @alpha\n */\nexport interface TreeViewAlpha<\n\tin out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,\n> extends Omit<TreeViewBeta<ReadSchema<TSchema>>, \"root\" | \"initialize\" | \"fork\">,\n\t\tTreeBranchAlpha {\n\tget root(): ReadableField<TSchema>;\n\n\tset root(newRoot: InsertableField<TSchema>);\n\n\tinitialize(content: InsertableField<TSchema>): void;\n\n\treadonly events: Listenable<TreeViewEvents & TreeBranchEvents>;\n\n\t// Override the base fork method to return a TreeViewAlpha.\n\tfork(): ReturnType<TreeBranch[\"fork\"]> & TreeViewAlpha<TSchema>;\n}\n\n/**\n * {@link TreeView} with additional beta APIs.\n * @sealed @beta\n */\nexport interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema>\n\textends TreeView<TSchema>,\n\t\tTreeBranch {\n\t// Override the base branch method to return a typed view rather than merely a branch.\n\tfork(): ReturnType<TreeBranch[\"fork\"]> & TreeViewBeta<TSchema>;\n}\n\n/**\n * Information about a view schema's compatibility with the document's stored schema.\n *\n * See SharedTree's README for more information about choosing a compatibility policy.\n * @privateRemarks\n * See {@link SchemaCompatibilityTester} for the implementation of this compatibility checking.\n * @sealed @public\n */\nexport interface SchemaCompatibilityStatus {\n\t/**\n\t * Whether the view schema allows exactly the same set of documents as the stored schema.\n\t *\n\t * @remarks\n\t * Equivalence here is defined in terms of allowed documents because there are some degenerate cases where schemas are not\n\t * exact matches in a strict (schema-based) sense but still allow the same documents, and the document notion is more useful to applications.\n\t *\n\t * Examples which are expressible where this may occur include:\n\t *\n\t * - schema repository `A` has extra schema which schema `B` doesn't have, but they are unused (i.e. not reachable from the root schema)\n\t *\n\t * - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (for example: an object node type containing a required field with no allowed types)\n\t *\n\t * These cases are typically not interesting to applications.\n\t *\n\t * Note that other content in the stored schema that does not impact document compatibility, like {@link NodeSchemaOptionsAlpha.persistedMetadata}, does not affect this field.\n\t *\n\t * For the computation of this equivalence, {@link SchemaStaticsAlpha.staged | staged} schemas are not included.\n\t * If there are any unknown optional fields, even if allowed by {@link ObjectSchemaOptions.allowUnknownOptionalFields}, `isEquivalent` will be false.\n\t */\n\treadonly isEquivalent: boolean;\n\n\t/**\n\t * Whether the current view schema is sufficiently compatible with the stored schema to allow viewing tree data.\n\t * If false, {@link TreeView.root} will throw upon access.\n\t * @remarks\n\t * If the view schema does not opt into supporting any additional cases, then `canView` is only true when `isEquivalent` is also true.\n\t * The view schema can however opt into supporting additional cases, and thus can also view documents with stored schema which would be equivalent, except for the following discrepancies:\n\t *\n\t * - An object node with {@link ObjectSchemaOptions.allowUnknownOptionalFields} to set to true that has additional optional fields in the stored schema beyond those mentioned in its view schema.\n\t *\n\t * - An additional type allowed at a location in the stored schema where it is {@link SchemaStaticsAlpha.staged | staged} in the view schema.\n\t *\n\t * In these cases `canUpgrade` and `isEquivalent` will be false.\n\t *\n\t * When the documents allowed by the view schema is a strict superset of those by the stored schema,\n\t * `canView` is false because writes to the document using the view schema could make the document violate its stored schema.\n\t * In this case, the stored schema could be updated to match the provided view schema, allowing read-write access to the tree.\n\t * See {@link SchemaCompatibilityStatus.canUpgrade}.\n\t *\n\t * Future versions of SharedTree may provide readonly access to the document in this case because that would be safe,\n\t * but this is not currently supported.\n\t *\n\t * @privateRemarks\n\t * A necessary condition for this to be true is that the documents allowed by the view schema are a subset of those allowed by the stored schema.\n\t * This is not sufficient: the simple-tree layer's read APIs only tolerate very specific cases beyond their schema (unknown optional fields).\n\t * For example, if the view schema for a node has a required `Point` field but the stored schema has an optional `Point` field,\n\t * read APIs on the view schema do not work correctly when the document has a node with a missing `Point` field.\n\t * Similar issues happen when the view schema has a field with less allowed types than the stored schema and the document actually leverages those types.\n\t */\n\treadonly canView: boolean;\n\n\t/**\n\t * True when {@link TreeView.upgradeSchema} can add support for all content required to be supported by the view schema.\n\t * @remarks\n\t * When true, it is valid to call {@link TreeView.upgradeSchema} (though if the stored schema is already an exact match, this is a no-op).\n\t *\n\t * When adding optional fields to schema which previously were marked with {@link ObjectSchemaOptions.allowUnknownOptionalFields}\n\t * the schema upgrade (assuming no other changes are included) will allow the previous version to view.\n\t * Even this case must still must be done with caution however as only clients with the newly added field will be able to do future upgrades.\n\t * Thus if a version of an application is shipped that adds an unknown optional field, all future versions should include it, even if its no longer used,\n\t * to ensure that documents containing it can still be upgraded.\n\t */\n\treadonly canUpgrade: boolean;\n\n\t/**\n\t * True iff the document is uninitialized (i.e. it has no schema and no content).\n\t *\n\t * To initialize the document, call {@link TreeView.initialize}.\n\t *\n\t * @remarks\n\t * It's not necessary to check this field before calling {@link TreeView.initialize} in most scenarios; application authors typically know from\n\t * branch that they're in a flow which creates a new `SharedTree` and would like to initialize it.\n\t */\n\treadonly canInitialize: boolean;\n\n\t// TODO: Consider extending this status to include:\n\t// - application-defined metadata about the stored schema\n\t// - details about the differences between the stored and view schema sufficient for implementing \"safe mismatch\" policies\n}\n\n/**\n * Events for {@link TreeBranch}.\n * @sealed @alpha\n */\nexport interface TreeBranchEvents extends Omit<TreeViewEvents, \"commitApplied\"> {\n\t/**\n\t * Fired when a change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about (e.g. local vs. remote changes).\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;\n\n\t/**\n\t * Fired when:\n\t *\n\t * - a local commit is applied outside of a transaction\n\t *\n\t * - a local transaction is committed\n\t *\n\t * The event is not fired when:\n\t *\n\t * - a local commit is applied within a transaction\n\t *\n\t * - a remote commit is applied\n\t *\n\t * @param data - information about the commit that was applied\n\t * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,\n\t * this commit is not revertible.\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;\n}\n\n/**\n * Events for {@link TreeView}.\n * @sealed @public\n */\nexport interface TreeViewEvents {\n\t/**\n\t * Raised whenever {@link TreeView.root} is invalidated.\n\t *\n\t * This includes changes to the document schema.\n\t * It also includes changes to the field containing the root such as setting or clearing an optional root or changing which node is the root.\n\t * This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.\n\t */\n\trootChanged(): void;\n\n\t/**\n\t * The stored schema for the document has changed.\n\t * This may affect the compatibility between the view schema and the stored schema, and thus the ability to use the view.\n\t *\n\t * @remarks\n\t * This event implies that the old {@link TreeView.root} is no longer valid, but applications need not handle that separately:\n\t * {@link TreeViewEvents.rootChanged} will be fired after this event.\n\t */\n\tschemaChanged(): void;\n\n\t/**\n\t * Fired when:\n\t *\n\t * - a local commit is applied outside of a transaction\n\t *\n\t * - a local transaction is committed\n\t *\n\t * The event is not fired when:\n\t *\n\t * - a local commit is applied within a transaction\n\t *\n\t * - a remote commit is applied\n\t *\n\t * @param data - information about the commit that was applied\n\t * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,\n\t * this commit is not revertible.\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * Retrieve the {@link TreeViewAlpha | alpha API} for a {@link TreeView}.\n * @alpha\n * @deprecated Use {@link asAlpha} instead.\n * @privateRemarks Despite being deprecated, this function should be used within the tree package (outside of tests) rather than `asAlpha` in order to avoid circular import dependencies.\n */\nexport function asTreeViewAlpha<TSchema extends ImplicitFieldSchema>(\n\tview: TreeView<TSchema>,\n): TreeViewAlpha<TSchema> {\n\treturn view as TreeViewAlpha<TSchema>;\n}\n"]}
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6jBH;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC9B,IAAuB;IAEvB,OAAO,IAA8B,CAAC;AACvC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, IDisposable, Listenable } from \"@fluidframework/core-interfaces\";\n\nimport type {\n\tCommitMetadata,\n\tRevertibleAlphaFactory,\n\tRevertibleFactory,\n} from \"../../core/index.js\";\nimport type {\n\t// This is referenced by doc comments.\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports\n\tTreeAlpha,\n} from \"../../shared-tree/index.js\";\nimport type {\n\tImplicitFieldSchema,\n\tInsertableField,\n\tInsertableTreeFieldFromImplicitField,\n\tReadableField,\n\tReadSchema,\n\tTreeFieldFromImplicitField,\n} from \"../fieldSchema.js\";\nimport type { UnsafeUnknownSchema } from \"../unsafeUnknownSchema.js\";\nimport type { SimpleTreeSchema } from \"../simpleSchema.js\";\n\nimport type { TreeViewConfiguration } from \"./configuration.js\";\nimport type {\n\tRunTransactionParams,\n\tTransactionCallbackStatus,\n\tTransactionResult,\n\tTransactionResultExt,\n\tVoidTransactionCallbackStatus,\n} from \"./transactionTypes.js\";\nimport type { VerboseTree } from \"./verboseTree.js\";\n\n/**\n * A tree from which a {@link TreeView} can be created.\n *\n * @privateRemarks\n * TODO:\n * Add stored key versions of {@link (TreeAlpha:interface).(exportVerbose:2)}, {@link (TreeAlpha:interface).(exportConcise:2)} and {@link (TreeAlpha:interface).exportCompressed} here so tree content can be accessed without a view schema.\n * Add exportSimpleSchema and exportJsonSchema methods (which should exactly match the concise format, and match the free functions for exporting view schema).\n * Maybe rename \"exportJsonSchema\" to align on \"concise\" terminology.\n * Ensure schema exporting APIs here align and reference APIs for exporting view schema to the same formats (which should include stored vs property key choice).\n * Make sure users of independentView can use these export APIs (maybe provide a reference back to the ViewableTree from the TreeView to accomplish that).\n * @system @sealed @public\n */\nexport interface ViewableTree {\n\t/**\n\t * Returns a {@link TreeView} using the provided schema.\n\t * If the stored schema is compatible with the view schema specified by `config`,\n\t * the returned {@link TreeView} will expose the root with a schema-aware API based on the provided view schema.\n\t * If the provided schema is incompatible with the stored schema, the view will instead expose a status indicating the incompatibility.\n\t *\n\t * @remarks\n\t * If the tree is uninitialized (has no schema and no content), use {@link TreeView.initialize} on the returned view to set the schema and content together.\n\t * Using `viewWith` followed by {@link TreeView.upgradeSchema} to initialize only the schema for a document is technically valid when the schema\n\t * permits trees with no content.\n\t *\n\t * Note that other clients can modify the document at any time, causing the view to change its compatibility status: see {@link TreeView.events} for how to handle invalidation in these cases.\n\t *\n\t * Only one schematized view may exist for a given ITree at a time.\n\t * If creating a second, the first must be disposed before calling `viewWith` again.\n\t *\n\t * @privateRemarks\n\t * TODO: Support adapters for handling out-of-schema data.\n\t */\n\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * Channel for a Fluid Tree DDS.\n * @remarks\n * Allows storing and collaboratively editing schema-aware hierarchial data.\n * @sealed @public\n */\nexport interface ITree extends ViewableTree, IFluidLoadable {}\n\n/**\n * {@link ITree} extended with some alpha APIs.\n * @sealed @alpha\n */\nexport interface ITreeAlpha extends ITree {\n\t/**\n\t * Exports root in the same format as {@link (TreeAlpha:interface).(exportVerbose:1)} using stored keys.\n\t * @remarks\n\t * This is `undefined` if and only if the root field is empty (this can only happen if the root field is optional).\n\t */\n\texportVerbose(): VerboseTree | undefined;\n\n\t/**\n\t * Exports the SimpleTreeSchema that is stored in the tree, using stored keys for object fields.\n\t * @remarks\n\t * To get the schema using property keys, use {@link getSimpleSchema} on the view schema.\n\t */\n\texportSimpleSchema(): SimpleTreeSchema;\n\n\t/**\n\t * Creates a fork of the current state of the main branch.\n\t * This new branch will be shared with and editable by all clients.\n\t */\n\tcreateSharedBranch(): string;\n\n\t/**\n\t * Returns a list of all shared branches that currently exist on this tree.\n\t * Any one of them can be checked out using {@link ITreeAlpha.viewSharedBranchWith}.\n\t */\n\tgetSharedBranchIds(): string[];\n\n\t/**\n\t * Returns a view of the tree on the specified shared branch, using the provided schema.\n\t * See {@link ViewableTree.viewWith}.\n\t */\n\tviewSharedBranchWith<TRoot extends ImplicitFieldSchema>(\n\t\tbranchId: string,\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * A collection of functionality associated with a (version-control-style) branch of a SharedTree.\n * @remarks A `TreeBranch` allows for the {@link TreeBranch.fork | creation of branches} and for those branches to later be {@link TreeBranch.merge | merged}.\n *\n * The branch associated directly with the {@link ITree | SharedTree} is the \"main\" branch, and all other branches fork (directly or transitively) from that main branch.\n * @sealed @beta\n */\nexport interface TreeBranch extends IDisposable {\n\t/**\n\t * Fork a new branch off of this branch which is based off of this branch's current state.\n\t * @remarks Any changes to the tree on the new branch will not apply to this branch until the new branch is e.g. {@link TreeBranch.merge | merged} back into this branch.\n\t * The branch should be disposed when no longer needed, either {@link TreeBranch.dispose | explicitly} or {@link TreeBranch.merge | implicitly when merging} into another branch.\n\t */\n\tfork(): TreeBranch;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param branch - a branch which was created by a call to `branch()`.\n\t * @param disposeMerged - whether or not to dispose `branch` after the merge completes.\n\t * Defaults to true.\n\t * The {@link TreeBranch | main branch} cannot be disposed - attempting to do so will have no effect.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t */\n\tmerge(branch: TreeBranch, disposeMerged?: boolean): void;\n\n\t/**\n\t * Advance this branch forward such that all new changes on the target branch become part of this branch.\n\t * @param branch - The branch to rebase onto.\n\t * @remarks After rebasing, this branch will be \"ahead\" of the target branch, that is, its unique changes will have been recreated as if they happened after all changes on the target branch.\n\t * This method may only be called on branches produced via {@link TreeBranch.fork | branch} - attempting to rebase the main branch will throw.\n\t *\n\t * Rebasing long-lived branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" branch was created or last rebased.\n\t *\n\t * The {@link TreeBranch | main branch} cannot be rebased onto another branch - attempting to do so will throw an error.\n\t */\n\trebaseOnto(branch: TreeBranch): void;\n\n\t/**\n\t * Dispose of this branch, cleaning up any resources associated with it.\n\t * @param error - Optional error indicating the reason for the disposal, if the object was disposed as the result of an error.\n\t * @remarks Branches can also be automatically disposed when {@link TreeBranch.merge | they are merged} into another branch.\n\t *\n\t * Disposing branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" branch was created or last {@link TreeBranch.rebaseOnto | rebased}.\n\t *\n\t * The {@link TreeBranch | main branch} cannot be disposed - attempting to do so will have no effect.\n\t */\n\tdispose(error?: Error): void;\n}\n\n/**\n * {@link TreeBranch} with alpha-level APIs.\n * @remarks\n * The `TreeBranch` for a specific {@link TreeNode} may be acquired by calling `TreeAlpha.branch`.\n *\n * A branch does not necessarily know the schema of its SharedTree - to convert a branch to a {@link TreeViewAlpha | view with a schema}, use {@link TreeBranchAlpha.hasRootSchema | hasRootSchema()}.\n * @sealed @alpha\n */\nexport interface TreeBranchAlpha extends TreeBranch {\n\t/**\n\t * Events for the branch\n\t */\n\treadonly events: Listenable<TreeBranchEvents>;\n\n\t/**\n\t * Returns true if this branch has the given schema as its root schema.\n\t * @remarks This is a type guard which allows this branch to become strongly typed as a {@link TreeViewAlpha | view} of the given schema.\n\t *\n\t * To succeed, the given schema must be invariant to the schema of the view - it must include exactly the same allowed types.\n\t * For example, a schema of `Foo | Bar` will not match a view schema of `Foo`, and likewise a schema of `Foo` will not match a view schema of `Foo | Bar`.\n\t * @example\n\t * ```typescript\n\t * if (branch.hasRootSchema(MySchema)) {\n\t * const { root } = branch; // `branch` is now a TreeViewAlpha<MySchema>\n\t * // ...\n\t * }\n\t * ```\n\t */\n\thasRootSchema<TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t): this is TreeViewAlpha<TSchema>;\n\n\t// Override the base fork method to return the alpha variant.\n\tfork(): TreeBranchAlpha;\n\n\t/**\n\t * Run a transaction which applies one or more edits to the tree as a single atomic unit.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * It should return a status object of {@link TransactionCallbackStatus | TransactionCallbackStatus } type.\n\t * It includes a \"rollback\" property which may be returned as true at any point during the transaction. This will\n\t * abort the transaction and discard any changes it made so far.\n\t * \"rollback\" can be set to false or left undefined to indicate that the body of the transaction has successfully run.\n\t * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.\n\t * @returns A result object of {@link TransactionResultExt | TransactionResultExt} type. It includes the following:\n\t *\n\t * - A \"success\" flag indicating whether the transaction was successful or not.\n\t * - The success or failure value as returned by the transaction function.\n\t *\n\t * @remarks\n\t * This API will throw an error if the constraints are not met or something unexpected happens.\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t *\n\t * Nested transactions:\n\t * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:\n\t *\n\t * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.\n\t * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated\n\t * for the outermost transaction which includes all inner transactions.\n\t * - Undo will undo the outermost transaction and all inner transactions.\n\t */\n\trunTransaction<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => TransactionCallbackStatus<TSuccessValue, TFailureValue>,\n\t\tparams?: RunTransactionParams,\n\t): TransactionResultExt<TSuccessValue, TFailureValue>;\n\t/**\n\t * Run a transaction which applies one or more edits to the tree as a single atomic unit.\n\t * @param transaction - The function to run as the body of the transaction. It may return the following:\n\t *\n\t * - Nothing to indicate that the body of the transaction has successfully run.\n\t * - A status object of {@link VoidTransactionCallbackStatus | VoidTransactionCallbackStatus } type. It includes a \"rollback\" property which\n\t * may be returned as true at any point during the transaction. This will abort the transaction and discard any changes it made so\n\t * far. \"rollback\" can be set to false or left undefined to indicate that the body of the transaction has successfully run.\n\t *\n\t * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.\n\t * @returns A result object of {@link TransactionResult | TransactionResult} type. It includes a \"success\" flag indicating whether the\n\t * transaction was successful or not.\n\t *\n\t * @remarks\n\t * This API will throw an error if the constraints are not met or something unexpected happens.\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t *\n\t * Nested transactions:\n\t * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:\n\t *\n\t * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.\n\t * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated\n\t * for the outermost transaction which includes all inner transactions.\n\t * - Undo will undo the outermost transaction and all inner transactions.\n\t */\n\trunTransaction(\n\t\ttransaction: () => VoidTransactionCallbackStatus | void,\n\t\tparams?: RunTransactionParams,\n\t): TransactionResult;\n}\n\n/**\n * An editable view of a (version control style) branch of a shared tree based on some schema.\n *\n * @remarks\n * This schema (known as the view schema) may or may not align with the stored schema of the document.\n * Information about discrepancies between the two schemas is available via {@link TreeView.compatibility | compatibility}.\n *\n * Application authors are encouraged to read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/docs/user-facing/schema-evolution.md | schema-evolution.md}\n * and choose a schema compatibility policy that aligns with their application's needs.\n *\n * @privateRemarks\n * From an API design perspective, `upgradeSchema` could be merged into `viewWith` and/or `viewWith` could return errors explicitly on incompatible documents.\n * Such approaches would make it discoverable that out of schema handling may need to be done.\n * Doing that would however complicate trivial \"hello world\" style example slightly, as well as be a breaking API change.\n * It also seems more complex to handle invalidation with that pattern.\n * Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.\n *\n * @see {@link TreeViewAlpha}\n * @see {@link asTreeViewAlpha}\n *\n * @sealed @public\n */\nexport interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {\n\t/**\n\t * The current root of the tree.\n\t *\n\t * If the view schema not sufficiently compatible with the stored schema, accessing this will throw.\n\t * To handle this case, check {@link TreeView.compatibility | compatibility}'s {@link SchemaCompatibilityStatus.canView | canView} before using.\n\t *\n\t * To get notified about changes to this field,\n\t * use {@link TreeViewEvents.rootChanged} via `view.events.on(\"rootChanged\", callback)`.\n\t *\n\t * To get notified about changes to stored schema (which may affect compatibility between this view's schema and\n\t * the stored schema), use {@link TreeViewEvents.schemaChanged} via `view.events.on(\"schemaChanged\", callback)`.\n\t */\n\tget root(): TreeFieldFromImplicitField<TSchema>;\n\n\tset root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);\n\n\t/**\n\t * Description of the current compatibility status between the view schema and stored schema.\n\t *\n\t * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status changes.\n\t */\n\treadonly compatibility: SchemaCompatibilityStatus;\n\n\t/**\n\t * When {@link SchemaCompatibilityStatus.canUpgrade} is true,\n\t * this can be used to modify the stored schema to make it match the view schema.\n\t * @remarks\n\t * This will update the {@link TreeView.compatibility}, allowing access to `root`.\n\t * Beware that this may impact other clients' ability to view the document: see {@link SchemaCompatibilityStatus.canView} for more information.\n\t *\n\t * It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false.\n\t * {@link SchemaCompatibilityStatus.canUpgrade} being true does not mean that an upgrade is required, nor that an upgrade will have any effect.\n\t * @privateRemarks\n\t * In the future, more upgrade options could be provided here.\n\t * Some options that could be added:\n\t * - check the actual document contents (not just the schema) and attempt an atomic document update if the data is compatible.\n\t * - apply converters and upgrade the document.\n\t * - apply converters to lazily to adapt the document to the requested view schema (with optional lazy schema updates or transparent conversions on write).\n\t * - update only a specific change (add an optional field, or apply a staged upgrade)\n\t * - update persistedMetadata or not\n\t *\n\t * As persisted metadata becomes more supported, how it interacts with isEquivalent and upgradeSchema should be clarified:\n\t * for now the docs are being left somewhat vague to allow flexibility in this area.\n\t */\n\tupgradeSchema(): void;\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;\n\n\t/**\n\t * Events for the tree.\n\t */\n\treadonly events: Listenable<TreeViewEvents>;\n\n\t/**\n\t * The view schema used by this TreeView.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * {@link TreeView} with proposed changes to the schema aware typing to allow use with `UnsafeUnknownSchema`.\n * @sealed @alpha\n */\nexport interface TreeViewAlpha<\n\tin out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,\n> extends Omit<TreeViewBeta<ReadSchema<TSchema>>, \"root\" | \"initialize\" | \"fork\">,\n\t\tTreeBranchAlpha {\n\tget root(): ReadableField<TSchema>;\n\n\tset root(newRoot: InsertableField<TSchema>);\n\n\tinitialize(content: InsertableField<TSchema>): void;\n\n\treadonly events: Listenable<TreeViewEvents & TreeBranchEvents>;\n\n\t// Override the base fork method to return a TreeViewAlpha.\n\tfork(): ReturnType<TreeBranch[\"fork\"]> & TreeViewAlpha<TSchema>;\n}\n\n/**\n * {@link TreeView} with additional beta APIs.\n * @sealed @beta\n */\nexport interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema>\n\textends TreeView<TSchema>,\n\t\tTreeBranch {\n\t// Override the base branch method to return a typed view rather than merely a branch.\n\tfork(): ReturnType<TreeBranch[\"fork\"]> & TreeViewBeta<TSchema>;\n}\n\n/**\n * Information about a view schema's compatibility with the document's stored schema.\n *\n * See SharedTree's README for more information about choosing a compatibility policy.\n * @privateRemarks\n * See {@link SchemaCompatibilityTester} for the implementation of this compatibility checking.\n * @sealed @public\n */\nexport interface SchemaCompatibilityStatus {\n\t/**\n\t * Whether the view schema allows exactly the same set of documents as the stored schema.\n\t *\n\t * @remarks\n\t * Equivalence here is defined in terms of allowed documents because there are some degenerate cases where schemas are not\n\t * exact matches in a strict (schema-based) sense but still allow the same documents, and the document notion is more useful to applications.\n\t *\n\t * Examples which are expressible where this may occur include:\n\t *\n\t * - schema repository `A` has extra schema which schema `B` doesn't have, but they are unused (i.e. not reachable from the root schema)\n\t *\n\t * - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (for example: an object node type containing a required field with no allowed types)\n\t *\n\t * These cases are typically not interesting to applications.\n\t *\n\t * Note that other content in the stored schema that does not impact document compatibility, like {@link NodeSchemaOptionsAlpha.persistedMetadata}, does not affect this field.\n\t *\n\t * For the computation of this equivalence, {@link SchemaStaticsBeta.staged | staged} schemas are not included.\n\t * If there are any unknown optional fields, even if allowed by {@link ObjectSchemaOptions.allowUnknownOptionalFields}, `isEquivalent` will be false.\n\t */\n\treadonly isEquivalent: boolean;\n\n\t/**\n\t * Whether the current view schema is sufficiently compatible with the stored schema to allow viewing tree data.\n\t * If false, {@link TreeView.root} will throw upon access.\n\t * @remarks\n\t * If the view schema does not opt into supporting any additional cases, then `canView` is only true when `isEquivalent` is also true.\n\t * The view schema can however opt into supporting additional cases, and thus can also view documents with stored schema which would be equivalent, except for the following discrepancies:\n\t *\n\t * - An object node with {@link ObjectSchemaOptions.allowUnknownOptionalFields} to set to true that has additional optional fields in the stored schema beyond those mentioned in its view schema.\n\t *\n\t * - An additional type allowed at a location in the stored schema where it is {@link SchemaStaticsBeta.staged | staged} in the view schema.\n\t *\n\t * In these cases `canUpgrade` and `isEquivalent` will be false.\n\t *\n\t * When the documents allowed by the view schema is a strict superset of those by the stored schema,\n\t * `canView` is false because writes to the document using the view schema could make the document violate its stored schema.\n\t * In this case, the stored schema could be updated to match the provided view schema, allowing read-write access to the tree.\n\t * See {@link SchemaCompatibilityStatus.canUpgrade}.\n\t *\n\t * Future versions of SharedTree may provide readonly access to the document in this case because that would be safe,\n\t * but this is not currently supported.\n\t *\n\t * @privateRemarks\n\t * A necessary condition for this to be true is that the documents allowed by the view schema are a subset of those allowed by the stored schema.\n\t * This is not sufficient: the simple-tree layer's read APIs only tolerate very specific cases beyond their schema (unknown optional fields).\n\t * For example, if the view schema for a node has a required `Point` field but the stored schema has an optional `Point` field,\n\t * read APIs on the view schema do not work correctly when the document has a node with a missing `Point` field.\n\t * Similar issues happen when the view schema has a field with less allowed types than the stored schema and the document actually leverages those types.\n\t */\n\treadonly canView: boolean;\n\n\t/**\n\t * True when {@link TreeView.upgradeSchema} can add support for all content required to be supported by the view schema.\n\t * @remarks\n\t * When true, it is valid to call {@link TreeView.upgradeSchema} (though if the stored schema is already an exact match, this is a no-op).\n\t *\n\t * When adding optional fields to schema which previously were marked with {@link ObjectSchemaOptions.allowUnknownOptionalFields}\n\t * the schema upgrade (assuming no other changes are included) will allow the previous version to view.\n\t * Even this case must still must be done with caution however as only clients with the newly added field will be able to do future upgrades.\n\t * Thus if a version of an application is shipped that adds an unknown optional field, all future versions should include it, even if its no longer used,\n\t * to ensure that documents containing it can still be upgraded.\n\t */\n\treadonly canUpgrade: boolean;\n\n\t/**\n\t * True iff the document is uninitialized (i.e. it has no schema and no content).\n\t *\n\t * To initialize the document, call {@link TreeView.initialize}.\n\t *\n\t * @remarks\n\t * It's not necessary to check this field before calling {@link TreeView.initialize} in most scenarios; application authors typically know from\n\t * branch that they're in a flow which creates a new `SharedTree` and would like to initialize it.\n\t */\n\treadonly canInitialize: boolean;\n\n\t// TODO: Consider extending this status to include:\n\t// - application-defined metadata about the stored schema\n\t// - details about the differences between the stored and view schema sufficient for implementing \"safe mismatch\" policies\n}\n\n/**\n * Events for {@link TreeBranch}.\n * @sealed @alpha\n */\nexport interface TreeBranchEvents extends Omit<TreeViewEvents, \"commitApplied\"> {\n\t/**\n\t * Fired when a change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about (e.g. local vs. remote changes).\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;\n\n\t/**\n\t * Fired when:\n\t *\n\t * - a local commit is applied outside of a transaction\n\t *\n\t * - a local transaction is committed\n\t *\n\t * The event is not fired when:\n\t *\n\t * - a local commit is applied within a transaction\n\t *\n\t * - a remote commit is applied\n\t *\n\t * @param data - information about the commit that was applied\n\t * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,\n\t * this commit is not revertible.\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;\n}\n\n/**\n * Events for {@link TreeView}.\n * @sealed @public\n */\nexport interface TreeViewEvents {\n\t/**\n\t * Raised whenever {@link TreeView.root} is invalidated.\n\t *\n\t * This includes changes to the document schema.\n\t * It also includes changes to the field containing the root such as setting or clearing an optional root or changing which node is the root.\n\t * This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.\n\t */\n\trootChanged(): void;\n\n\t/**\n\t * The stored schema for the document has changed.\n\t * This may affect the compatibility between the view schema and the stored schema, and thus the ability to use the view.\n\t *\n\t * @remarks\n\t * This event implies that the old {@link TreeView.root} is no longer valid, but applications need not handle that separately:\n\t * {@link TreeViewEvents.rootChanged} will be fired after this event.\n\t */\n\tschemaChanged(): void;\n\n\t/**\n\t * Fired when:\n\t *\n\t * - a local commit is applied outside of a transaction\n\t *\n\t * - a local transaction is committed\n\t *\n\t * The event is not fired when:\n\t *\n\t * - a local commit is applied within a transaction\n\t *\n\t * - a remote commit is applied\n\t *\n\t * @param data - information about the commit that was applied\n\t * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,\n\t * this commit is not revertible.\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * Retrieve the {@link TreeViewAlpha | alpha API} for a {@link TreeView}.\n * @alpha\n * @deprecated Use {@link asAlpha} instead.\n * @privateRemarks Despite being deprecated, this function should be used within the tree package (outside of tests) rather than `asAlpha` in order to avoid circular import dependencies.\n */\nexport function asTreeViewAlpha<TSchema extends ImplicitFieldSchema>(\n\tview: TreeView<TSchema>,\n): TreeViewAlpha<TSchema> {\n\treturn view as TreeViewAlpha<TSchema>;\n}\n"]}
@@ -324,7 +324,7 @@ export interface TreeRecordNodeUnsafe<TAllowedTypes extends System_Unsafe.Implic
324
324
  * @remarks
325
325
  * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
326
326
  * @sealed
327
- * @alpha
327
+ * @beta
328
328
  * @system
329
329
  */
330
330
  export type UnannotateAllowedTypeUnsafe<T extends Unenforced<AnnotatedAllowedTypeUnsafe | LazyItem<System_Unsafe.TreeNodeSchemaUnsafe>>> = T extends AnnotatedAllowedTypeUnsafe<infer X> ? X : T;
@@ -332,7 +332,7 @@ export type UnannotateAllowedTypeUnsafe<T extends Unenforced<AnnotatedAllowedTyp
332
332
  * {@link Unenforced} version of {@link AnnotatedAllowedType}.
333
333
  * @remarks
334
334
  * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
335
- * @system @sealed @alpha
335
+ * @system @sealed @beta
336
336
  */
337
337
  export interface AnnotatedAllowedTypeUnsafe<T = Unenforced<LazyItem<TreeNodeSchema>>> extends AnnotatedAllowedType<T> {
338
338
  }
@@ -340,7 +340,7 @@ export interface AnnotatedAllowedTypeUnsafe<T = Unenforced<LazyItem<TreeNodeSche
340
340
  * {@link Unenforced} version of {@link AnnotatedAllowedTypes}.
341
341
  * @remarks
342
342
  * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
343
- * @system @sealed @alpha
343
+ * @system @sealed @beta
344
344
  */
345
345
  export interface AnnotatedAllowedTypesUnsafe extends AnnotatedAllowedTypes<LazyItem<System_Unsafe.TreeNodeSchemaUnsafe>> {
346
346
  }
@@ -355,14 +355,14 @@ export type AllowedTypesFullUnsafe<T extends readonly AnnotatedAllowedTypeUnsafe
355
355
  * {@link Unenforced} version of {@link AllowedTypesFullFromMixed}.
356
356
  * @remarks
357
357
  * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
358
- * @system @sealed @alpha
358
+ * @system @sealed @beta
359
359
  */
360
360
  export type AllowedTypesFullFromMixedUnsafe<T extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[]> = UnannotateAllowedTypesListUnsafe<T> & AnnotatedAllowedTypes<AnnotateAllowedTypesListUnsafe<T>>;
361
361
  /**
362
362
  * {@link Unenforced} version of {@link UnannotateAllowedTypesList}.
363
363
  * @remarks
364
364
  * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
365
- * @system @sealed @alpha
365
+ * @system @sealed @beta
366
366
  */
367
367
  export type UnannotateAllowedTypesListUnsafe<T extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[]> = {
368
368
  readonly [I in keyof T]: T[I] extends {
@@ -373,7 +373,7 @@ export type UnannotateAllowedTypesListUnsafe<T extends readonly Unenforced<Annot
373
373
  * {@link Unenforced} version of {@link AnnotateAllowedTypesList}.
374
374
  * @remarks
375
375
  * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
376
- * @system @sealed @alpha
376
+ * @system @sealed @beta
377
377
  */
378
378
  export type AnnotateAllowedTypesListUnsafe<T extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[]> = {
379
379
  [I in keyof T]: T[I] extends AnnotatedAllowedTypeUnsafe ? T[I] : AnnotatedAllowedTypeUnsafe<T[I]>;
@@ -1 +1 @@
1
- {"version":3,"file":"typesUnsafe.js","sourceRoot":"","sources":["../../../src/simple-tree/api/typesUnsafe.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIsUnion,\n\tRestrictiveStringRecord,\n\tUnionToIntersection,\n} from \"../../util/index.js\";\n\nimport type {\n\tApplyKind,\n\tApplyKindInput,\n\tFieldKind,\n\tFieldSchema,\n\tFieldSchemaAlpha,\n} from \"../fieldSchema.js\";\nimport type {\n\tNodeKind,\n\tWithType,\n\tTreeNode,\n\tUnhydrated,\n\tInternalTreeNode,\n\tTreeNodeSchema,\n\tTreeNodeSchemaCore,\n\tTreeNodeSchemaClass,\n\tImplicitAllowedTypes,\n\tTreeLeafValue,\n\tFlexListToUnion,\n\tLazyItem,\n\tAnnotatedAllowedType,\n\tAnnotatedAllowedTypes,\n} from \"../core/index.js\";\nimport type { TreeArrayNode } from \"../node-kinds/index.js\";\nimport type { SimpleArrayNodeSchema, SimpleMapNodeSchema } from \"../simpleSchema.js\";\n\n/*\n * TODO:\n * Below are a bunch of \"unsafe\" versions of types from \"schemaTypes.ts\".\n * These types duplicate the ones in \"schemaTypes.ts\", except with some of the extends clauses unenforced.\n * This is not great for type safety or maintainability.\n * Eventually it would be great to do at least one of the following:\n * 1. Find a way to avoid needing these entirely, possibly by improving TSC's recursive type support.\n * 2. Deduplicate the safe and unsafe types (possibly by having the safe one call the unsafe ones, or some other trick).\n * 3. Add type tests that check that the two copies of these types produce identical results.\n */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * A placeholder to use in {@link https://www.typescriptlang.org/docs/handbook/2/generics.html#generic-constraints | extends constraints} when using the real type breaks compilation of some recursive types due to {@link https://github.com/microsoft/TypeScript/issues/55758 | a design limitation of TypeScript}.\n *\n * These extends constraints only serve as documentation:\n * to avoid breaking compilation, this type has to not actually enforce anything, and thus is just `unknown`.\n * Therefore the type safety is the responsibility of the user of the API.\n * @public\n */\nexport type Unenforced<_DesiredExtendsConstraint> = unknown;\n\n/**\n * A collection of {@link Unenforced} types that are used in the implementation of recursive schema.\n * These are all `@system` types, and thus should not be used directly.\n * @privateRemarks\n * Due to limitations of API-Extractor, all types in this namespace are treated as `@public`:\n * therefore, non-public types should not be included in this namespace.\n * @system @public\n */\nexport namespace System_Unsafe {\n\t/**\n\t * {@link Unenforced} version of `ObjectFromSchemaRecord`.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @privateRemarks\n\t * This does not bother special casing `{}` since no one should make empty objects using the *Recursive APIs.\n\t * @system @public\n\t */\n\texport type ObjectFromSchemaRecordUnsafe<\n\t\tT extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>,\n\t> = {\n\t\t-readonly [Property in keyof T]: Property extends string\n\t\t\t? TreeFieldFromImplicitFieldUnsafe<T[Property]>\n\t\t\t: unknown;\n\t};\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeNodeSchema}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type TreeNodeSchemaUnsafe<\n\t\tName extends string = string,\n\t\tKind extends NodeKind = NodeKind,\n\t\tTNode extends Unenforced<TreeNode | TreeLeafValue> = unknown,\n\t\tTBuild = never,\n\t\tImplicitlyConstructable extends boolean = boolean,\n\t\tInfo = unknown,\n\t> =\n\t\t| TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>\n\t\t| TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeNodeSchemaClass}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport interface TreeNodeSchemaClassUnsafe<\n\t\tout Name extends string,\n\t\tout Kind extends NodeKind,\n\t\tout TNode extends Unenforced<TreeNode>,\n\t\tin TInsertable,\n\t\tout ImplicitlyConstructable extends boolean,\n\t\tout Info,\n\t\tout TCustomMetadata = unknown,\n\t> extends TreeNodeSchemaCore<\n\t\t\tName,\n\t\t\tKind,\n\t\t\tImplicitlyConstructable,\n\t\t\tInfo,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> {\n\t\t/**\n\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t * @remarks\n\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t * @sealed\n\t\t */\n\t\tnew (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;\n\t}\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeNodeSchemaNonClass}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport interface TreeNodeSchemaNonClassUnsafe<\n\t\tout Name extends string,\n\t\tout Kind extends NodeKind,\n\t\tout TNode extends Unenforced<TreeNode | TreeLeafValue>,\n\t\tin TInsertable,\n\t\tout ImplicitlyConstructable extends boolean,\n\t\tout Info = unknown,\n\t> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {\n\t\tcreate(data: TInsertable): TNode;\n\t}\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeObjectNode}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type TreeObjectNodeUnsafe<\n\t\tT extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>,\n\t\tTypeName extends string = string,\n\t> = TreeNode & ObjectFromSchemaRecordUnsafe<T> & WithType<TypeName, NodeKind.Object, T>;\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeFieldFromImplicitField}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type TreeFieldFromImplicitFieldUnsafe<TSchema extends ImplicitFieldSchemaUnsafe> =\n\t\tTSchema extends FieldSchemaUnsafe<infer Kind, infer Types>\n\t\t\t? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind>\n\t\t\t: TSchema extends ImplicitAllowedTypesUnsafe\n\t\t\t\t? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema>\n\t\t\t\t: unknown;\n\n\t/**\n\t * {@link Unenforced} version of {@link AllowedTypes}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];\n\n\t/**\n\t * {@link Unenforced} version of {@link ImplicitAllowedTypes}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @privateRemarks\n\t * This is similar to `Unenforced<ImplicitAllowedTypes>` in that it avoids constraining the schema\n\t * (which is necessary to avoid breaking recursive types),\n\t * but is superior from a safety perspective because it constrains the structure containing the schema.\n\t * @system @public\n\t */\n\texport type ImplicitAllowedTypesUnsafe =\n\t\t| TreeNodeSchemaUnsafe\n\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments\n\t\t| readonly LazyItem<Unenforced<TreeNodeSchema>>[];\n\n\t/**\n\t * {@link Unenforced} version of {@link ImplicitFieldSchema}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @privateRemarks\n\t * This is similar to `Unenforced<ImplicitFieldSchema>` in that it avoids constraining the schema\n\t * (which is necessary to avoid breaking recursive types),\n\t * but is superior from a safety perspective because it constrains the structure containing the schema.\n\t * @system @public\n\t */\n\texport type ImplicitFieldSchemaUnsafe =\n\t\t| FieldSchemaUnsafe<FieldKind, ImplicitAllowedTypesUnsafe>\n\t\t| ImplicitAllowedTypesUnsafe;\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeNodeFromImplicitAllowedTypes}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type TreeNodeFromImplicitAllowedTypesUnsafe<\n\t\tTSchema extends ImplicitAllowedTypesUnsafe,\n\t> = TSchema extends TreeNodeSchemaUnsafe\n\t\t? NodeFromSchemaUnsafe<TSchema>\n\t\t: TSchema extends AllowedTypesUnsafe\n\t\t\t? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>>\n\t\t\t: unknown;\n\n\t/**\n\t * {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.\n\t * @see {@link Input}\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<\n\t\tTSchema extends ImplicitAllowedTypesUnsafe,\n\t> = [TSchema] extends [TreeNodeSchemaUnsafe]\n\t\t? InsertableTypedNodeUnsafe<TSchema>\n\t\t: [TSchema] extends [AllowedTypesUnsafe]\n\t\t\t? InsertableTreeNodeFromAllowedTypesUnsafe<TSchema>\n\t\t\t: never;\n\n\t/**\n\t * {@link Unenforced} version of {@link InsertableTreeNodeFromAllowedTypes}.\n\t * @see {@link Input}\n\t * @privateRemarks\n\t * TODO: AB#36348: it seems like the order of the union this produces is what is non-deterministic in incremental builds\n\t * of the JsonAsTree schema.\n\t * @system @public\n\t */\n\texport type InsertableTreeNodeFromAllowedTypesUnsafe<TList extends AllowedTypesUnsafe> =\n\t\tIsUnion<TList> extends true\n\t\t\t? never\n\t\t\t: {\n\t\t\t\t\treadonly [Property in keyof TList]: TList[Property] extends LazyItem<\n\t\t\t\t\t\tinfer TSchema extends TreeNodeSchemaUnsafe\n\t\t\t\t\t>\n\t\t\t\t\t\t? InsertableTypedNodeUnsafe<TSchema>\n\t\t\t\t\t\t: never;\n\t\t\t\t}[number];\n\n\t/**\n\t * {@link Unenforced} version of {@link InsertableTypedNode}.\n\t * @see {@link Input}\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @privateRemarks\n\t * TODO:\n\t * This is less strict than InsertableTypedNode when given non-exact schema to avoid compilation issues.\n\t * This should probably be fixed or documented somehow.\n\t * @system @public\n\t */\n\texport type InsertableTypedNodeUnsafe<\n\t\tTSchema extends TreeNodeSchemaUnsafe,\n\t\tT = UnionToIntersection<TSchema>,\n\t> =\n\t\t| (T extends TreeNodeSchemaUnsafe<string, NodeKind, TreeNode | TreeLeafValue, never, true>\n\t\t\t\t? NodeBuilderDataUnsafe<T>\n\t\t\t\t: never)\n\t\t| (T extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<T> : never);\n\n\t/**\n\t * {@link Unenforced} version of {@link NodeFromSchema}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> =\n\t\tT extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;\n\n\t/**\n\t * {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> =\n\t\tT extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;\n\n\t/**\n\t * {@link Unenforced} version of {@link (TreeArrayNode:interface)}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @sealed @public\n\t */\n\texport interface TreeArrayNodeUnsafe<TAllowedTypes extends ImplicitAllowedTypesUnsafe>\n\t\textends TreeArrayNode<\n\t\t\tTAllowedTypes,\n\t\t\tTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>,\n\t\t\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>\n\t\t> {}\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeMapNode}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @sealed @public\n\t */\n\texport interface TreeMapNodeUnsafe<T extends ImplicitAllowedTypesUnsafe>\n\t\textends ReadonlyMapInlined<string, T>,\n\t\t\tTreeNode {\n\t\t/**\n\t\t * {@inheritdoc TreeMapNode.set}\n\t\t */\n\t\tset(\n\t\t\tkey: string,\n\t\t\tvalue: InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T> | undefined,\n\t\t): void;\n\n\t\t/**\n\t\t * {@inheritdoc TreeMapNode.delete}\n\t\t */\n\t\tdelete(key: string): void;\n\t}\n\n\t/**\n\t * Copy of TypeScript's ReadonlyMap, but with `TreeNodeFromImplicitAllowedTypesUnsafe<T>` inlined into it.\n\t * Using this instead of ReadonlyMap in TreeMapNodeUnsafe is necessary to make recursive map schema not generate compile errors in the d.ts files when exported.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @privateRemarks\n\t * This is the same as `ReadonlyMap<K, TreeNodeFromImplicitAllowedTypesUnsafe<T>>` (Checked in test),\n\t * except that it avoids the above mentioned compile error.\n\t * Authored by manually inlining ReadonlyMap from from the TypeScript lib which can be found by navigating to the definition of `ReadonlyMap`.\n\t * @system @sealed @public\n\t */\n\texport interface ReadonlyMapInlined<K, T extends ImplicitAllowedTypesUnsafe> {\n\t\t/** Returns an iterable of entries in the map. */\n\t\t[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;\n\n\t\t/**\n\t\t * Returns an iterable of key, value pairs for every entry in the map.\n\t\t */\n\t\tentries(): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;\n\n\t\t/**\n\t\t * Returns an iterable of keys in the map\n\t\t */\n\t\tkeys(): IterableIterator<K>;\n\n\t\t/**\n\t\t * Returns an iterable of values in the map\n\t\t */\n\t\tvalues(): IterableIterator<TreeNodeFromImplicitAllowedTypesUnsafe<T>>;\n\n\t\tforEach(\n\t\t\tcallbackfn: (\n\t\t\t\tvalue: TreeNodeFromImplicitAllowedTypesUnsafe<T>,\n\t\t\t\tkey: K,\n\t\t\t\tmap: ReadonlyMap<K, TreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t) => void,\n\t\t\tthisArg?: any,\n\t\t): void;\n\t\tget(key: K): TreeNodeFromImplicitAllowedTypesUnsafe<T> | undefined;\n\t\thas(key: K): boolean;\n\t\treadonly size: number;\n\t}\n\n\t/**\n\t * {@link Unenforced} version of `FieldHasDefault`.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @sealed @public\n\t */\n\texport type FieldHasDefaultUnsafe<T extends ImplicitFieldSchemaUnsafe> =\n\t\tT extends FieldSchemaUnsafe<\n\t\t\tFieldKind.Optional | FieldKind.Identifier,\n\t\t\tImplicitAllowedTypesUnsafe\n\t\t>\n\t\t\t? true\n\t\t\t: false;\n\n\t/**\n\t * {@link Unenforced} version of `InsertableObjectFromSchemaRecord`.\n\t * @see {@link Input}\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type InsertableObjectFromSchemaRecordUnsafe<\n\t\tT extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>,\n\t> = {\n\t\t// Field might not have a default, so make it required:\n\t\treadonly [Property in keyof T as FieldHasDefaultUnsafe<T[Property & string]> extends false\n\t\t\t? Property\n\t\t\t: never]: InsertableTreeFieldFromImplicitFieldUnsafe<T[Property & string]>;\n\t} & {\n\t\t// Field might have a default, so allow optional.\n\t\t// Note that if the field could be either, this returns boolean, causing both fields to exist, resulting in required.\n\t\treadonly [Property in keyof T as FieldHasDefaultUnsafe<T[Property & string]> extends true\n\t\t\t? Property\n\t\t\t: never]?: InsertableTreeFieldFromImplicitFieldUnsafe<T[Property & string]>;\n\t};\n\n\t/**\n\t * {@link Unenforced} version of {@link InsertableTreeFieldFromImplicitField}.\n\t * @see {@link Input}\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type InsertableTreeFieldFromImplicitFieldUnsafe<\n\t\tTSchemaInput extends ImplicitFieldSchemaUnsafe,\n\t\tTSchema = UnionToIntersection<TSchemaInput>,\n\t> = [TSchema] extends [FieldSchemaUnsafe<infer Kind, infer Types>]\n\t\t? ApplyKindInput<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true>\n\t\t: [TSchema] extends [ImplicitAllowedTypes]\n\t\t\t? InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>\n\t\t\t: never;\n\n\t/**\n\t * {@link Unenforced} version of {@link FieldSchema}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @sealed @public\n\t */\n\texport interface FieldSchemaUnsafe<\n\t\tout Kind extends FieldKind,\n\t\tout Types extends ImplicitAllowedTypesUnsafe,\n\t\tout TCustomMetadata = unknown,\n\t> extends FieldSchema<Kind, any, TCustomMetadata> {\n\t\t/**\n\t\t * {@inheritDoc FieldSchema.kind}\n\t\t */\n\t\treadonly kind: Kind;\n\t\t/**\n\t\t * {@inheritDoc FieldSchema.allowedTypes}\n\t\t */\n\t\treadonly allowedTypes: Types;\n\t\t/**\n\t\t * {@inheritDoc FieldSchema.allowedTypeSet}\n\t\t */\n\t\treadonly allowedTypeSet: ReadonlySet<TreeNodeSchema>;\n\t}\n}\n\n/**\n * {@link Unenforced} version of {@link FieldSchemaAlpha}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @alpha\n */\nexport interface FieldSchemaAlphaUnsafe<\n\tout Kind extends FieldKind,\n\tout Types extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\tout TCustomMetadata = unknown,\n> extends FieldSchemaAlpha<Kind, any, TCustomMetadata>,\n\t\tSystem_Unsafe.FieldSchemaUnsafe<Kind, Types, TCustomMetadata> {\n\t/**\n\t * {@inheritDoc FieldSchema.allowedTypes}\n\t */\n\treadonly allowedTypes: Types;\n}\n\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n/**\n * {@link Unenforced} version of {@link ArrayNodeCustomizableSchema}s.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @sealed\n * @alpha\n * @system\n */\nexport interface ArrayNodeCustomizableSchemaUnsafe<\n\tout TName extends string,\n\tin out T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\tout TCustomMetadata,\n> extends TreeNodeSchemaClass<\n\t\t\tTName,\n\t\t\tNodeKind.Array,\n\t\t\tSystem_Unsafe.TreeArrayNodeUnsafe<T> & WithType<TName, NodeKind.Array, T>,\n\t\t\t{\n\t\t\t\t[Symbol.iterator](): Iterator<\n\t\t\t\t\tSystem_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>\n\t\t\t\t>;\n\t\t\t},\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tundefined,\n\t\t\tTCustomMetadata\n\t\t>,\n\t\tSimpleArrayNodeSchema<TCustomMetadata> {}\n\n/**\n * {@link Unenforced} version of {@link MapNodeCustomizableSchema}s.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @sealed\n * @alpha\n * @system\n */\nexport interface MapNodeCustomizableSchemaUnsafe<\n\tout TName extends string,\n\tin out T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\tout TCustomMetadata,\n> extends TreeNodeSchemaClass<\n\t\t\tTName,\n\t\t\tNodeKind.Map,\n\t\t\tSystem_Unsafe.TreeMapNodeUnsafe<T> & WithType<TName, NodeKind.Map, T>,\n\t\t\t| {\n\t\t\t\t\t[Symbol.iterator](): Iterator<\n\t\t\t\t\t\t[string, System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>]\n\t\t\t\t\t>;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t },\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tundefined,\n\t\t\tTCustomMetadata\n\t\t>,\n\t\tSimpleMapNodeSchema<TCustomMetadata> {}\n\n/**\n * {@link Unenforced} version of {@link TreeRecordNode}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @beta\n */\nexport interface TreeRecordNodeUnsafe<\n\tTAllowedTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n> extends Record<string, System_Unsafe.TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>>,\n\t\tTreeNode {\n\t[Symbol.iterator](): IterableIterator<\n\t\t[string, System_Unsafe.TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>]\n\t>;\n}\n\n/**\n * {@link Unenforced} utility to remove {@link AnnotatedAllowedTypeUnsafe} wrappers.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @sealed\n * @alpha\n * @system\n */\nexport type UnannotateAllowedTypeUnsafe<\n\tT extends Unenforced<\n\t\tAnnotatedAllowedTypeUnsafe | LazyItem<System_Unsafe.TreeNodeSchemaUnsafe>\n\t>,\n> = T extends AnnotatedAllowedTypeUnsafe<infer X> ? X : T;\n\n/**\n * {@link Unenforced} version of {@link AnnotatedAllowedType}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @alpha\n */\nexport interface AnnotatedAllowedTypeUnsafe<T = Unenforced<LazyItem<TreeNodeSchema>>>\n\textends AnnotatedAllowedType<T> {}\n\n/**\n * {@link Unenforced} version of {@link AnnotatedAllowedTypes}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @alpha\n */\nexport interface AnnotatedAllowedTypesUnsafe\n\textends AnnotatedAllowedTypes<LazyItem<System_Unsafe.TreeNodeSchemaUnsafe>> {}\n\n/**\n * {@link Unenforced} version of {@link AllowedTypesFull}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @alpha\n */\nexport type AllowedTypesFullUnsafe<\n\tT extends readonly AnnotatedAllowedTypeUnsafe[] = readonly AnnotatedAllowedTypeUnsafe[],\n> = AnnotatedAllowedTypes<T> & UnannotateAllowedTypesListUnsafe<T>;\n\n/**\n * {@link Unenforced} version of {@link AllowedTypesFullFromMixed}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @alpha\n */\nexport type AllowedTypesFullFromMixedUnsafe<\n\tT extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],\n> = UnannotateAllowedTypesListUnsafe<T> &\n\tAnnotatedAllowedTypes<AnnotateAllowedTypesListUnsafe<T>>;\n\n/**\n * {@link Unenforced} version of {@link UnannotateAllowedTypesList}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @alpha\n */\nexport type UnannotateAllowedTypesListUnsafe<\n\tT extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],\n> = {\n\treadonly [I in keyof T]: T[I] extends { type: infer X } ? X : T[I];\n};\n\n/**\n * {@link Unenforced} version of {@link AnnotateAllowedTypesList}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @alpha\n */\nexport type AnnotateAllowedTypesListUnsafe<\n\tT extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],\n> = {\n\t[I in keyof T]: T[I] extends AnnotatedAllowedTypeUnsafe\n\t\t? T[I]\n\t\t: AnnotatedAllowedTypeUnsafe<T[I]>;\n};\n"]}
1
+ {"version":3,"file":"typesUnsafe.js","sourceRoot":"","sources":["../../../src/simple-tree/api/typesUnsafe.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIsUnion,\n\tRestrictiveStringRecord,\n\tUnionToIntersection,\n} from \"../../util/index.js\";\n\nimport type {\n\tApplyKind,\n\tApplyKindInput,\n\tFieldKind,\n\tFieldSchema,\n\tFieldSchemaAlpha,\n} from \"../fieldSchema.js\";\nimport type {\n\tNodeKind,\n\tWithType,\n\tTreeNode,\n\tUnhydrated,\n\tInternalTreeNode,\n\tTreeNodeSchema,\n\tTreeNodeSchemaCore,\n\tTreeNodeSchemaClass,\n\tImplicitAllowedTypes,\n\tTreeLeafValue,\n\tFlexListToUnion,\n\tLazyItem,\n\tAnnotatedAllowedType,\n\tAnnotatedAllowedTypes,\n} from \"../core/index.js\";\nimport type { TreeArrayNode } from \"../node-kinds/index.js\";\nimport type { SimpleArrayNodeSchema, SimpleMapNodeSchema } from \"../simpleSchema.js\";\n\n/*\n * TODO:\n * Below are a bunch of \"unsafe\" versions of types from \"schemaTypes.ts\".\n * These types duplicate the ones in \"schemaTypes.ts\", except with some of the extends clauses unenforced.\n * This is not great for type safety or maintainability.\n * Eventually it would be great to do at least one of the following:\n * 1. Find a way to avoid needing these entirely, possibly by improving TSC's recursive type support.\n * 2. Deduplicate the safe and unsafe types (possibly by having the safe one call the unsafe ones, or some other trick).\n * 3. Add type tests that check that the two copies of these types produce identical results.\n */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * A placeholder to use in {@link https://www.typescriptlang.org/docs/handbook/2/generics.html#generic-constraints | extends constraints} when using the real type breaks compilation of some recursive types due to {@link https://github.com/microsoft/TypeScript/issues/55758 | a design limitation of TypeScript}.\n *\n * These extends constraints only serve as documentation:\n * to avoid breaking compilation, this type has to not actually enforce anything, and thus is just `unknown`.\n * Therefore the type safety is the responsibility of the user of the API.\n * @public\n */\nexport type Unenforced<_DesiredExtendsConstraint> = unknown;\n\n/**\n * A collection of {@link Unenforced} types that are used in the implementation of recursive schema.\n * These are all `@system` types, and thus should not be used directly.\n * @privateRemarks\n * Due to limitations of API-Extractor, all types in this namespace are treated as `@public`:\n * therefore, non-public types should not be included in this namespace.\n * @system @public\n */\nexport namespace System_Unsafe {\n\t/**\n\t * {@link Unenforced} version of `ObjectFromSchemaRecord`.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @privateRemarks\n\t * This does not bother special casing `{}` since no one should make empty objects using the *Recursive APIs.\n\t * @system @public\n\t */\n\texport type ObjectFromSchemaRecordUnsafe<\n\t\tT extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>,\n\t> = {\n\t\t-readonly [Property in keyof T]: Property extends string\n\t\t\t? TreeFieldFromImplicitFieldUnsafe<T[Property]>\n\t\t\t: unknown;\n\t};\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeNodeSchema}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type TreeNodeSchemaUnsafe<\n\t\tName extends string = string,\n\t\tKind extends NodeKind = NodeKind,\n\t\tTNode extends Unenforced<TreeNode | TreeLeafValue> = unknown,\n\t\tTBuild = never,\n\t\tImplicitlyConstructable extends boolean = boolean,\n\t\tInfo = unknown,\n\t> =\n\t\t| TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>\n\t\t| TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeNodeSchemaClass}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport interface TreeNodeSchemaClassUnsafe<\n\t\tout Name extends string,\n\t\tout Kind extends NodeKind,\n\t\tout TNode extends Unenforced<TreeNode>,\n\t\tin TInsertable,\n\t\tout ImplicitlyConstructable extends boolean,\n\t\tout Info,\n\t\tout TCustomMetadata = unknown,\n\t> extends TreeNodeSchemaCore<\n\t\t\tName,\n\t\t\tKind,\n\t\t\tImplicitlyConstructable,\n\t\t\tInfo,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> {\n\t\t/**\n\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t * @remarks\n\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t * @sealed\n\t\t */\n\t\tnew (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;\n\t}\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeNodeSchemaNonClass}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport interface TreeNodeSchemaNonClassUnsafe<\n\t\tout Name extends string,\n\t\tout Kind extends NodeKind,\n\t\tout TNode extends Unenforced<TreeNode | TreeLeafValue>,\n\t\tin TInsertable,\n\t\tout ImplicitlyConstructable extends boolean,\n\t\tout Info = unknown,\n\t> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {\n\t\tcreate(data: TInsertable): TNode;\n\t}\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeObjectNode}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type TreeObjectNodeUnsafe<\n\t\tT extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>,\n\t\tTypeName extends string = string,\n\t> = TreeNode & ObjectFromSchemaRecordUnsafe<T> & WithType<TypeName, NodeKind.Object, T>;\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeFieldFromImplicitField}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type TreeFieldFromImplicitFieldUnsafe<TSchema extends ImplicitFieldSchemaUnsafe> =\n\t\tTSchema extends FieldSchemaUnsafe<infer Kind, infer Types>\n\t\t\t? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind>\n\t\t\t: TSchema extends ImplicitAllowedTypesUnsafe\n\t\t\t\t? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema>\n\t\t\t\t: unknown;\n\n\t/**\n\t * {@link Unenforced} version of {@link AllowedTypes}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];\n\n\t/**\n\t * {@link Unenforced} version of {@link ImplicitAllowedTypes}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @privateRemarks\n\t * This is similar to `Unenforced<ImplicitAllowedTypes>` in that it avoids constraining the schema\n\t * (which is necessary to avoid breaking recursive types),\n\t * but is superior from a safety perspective because it constrains the structure containing the schema.\n\t * @system @public\n\t */\n\texport type ImplicitAllowedTypesUnsafe =\n\t\t| TreeNodeSchemaUnsafe\n\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments\n\t\t| readonly LazyItem<Unenforced<TreeNodeSchema>>[];\n\n\t/**\n\t * {@link Unenforced} version of {@link ImplicitFieldSchema}.\n\t * @remarks\n\t * Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @privateRemarks\n\t * This is similar to `Unenforced<ImplicitFieldSchema>` in that it avoids constraining the schema\n\t * (which is necessary to avoid breaking recursive types),\n\t * but is superior from a safety perspective because it constrains the structure containing the schema.\n\t * @system @public\n\t */\n\texport type ImplicitFieldSchemaUnsafe =\n\t\t| FieldSchemaUnsafe<FieldKind, ImplicitAllowedTypesUnsafe>\n\t\t| ImplicitAllowedTypesUnsafe;\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeNodeFromImplicitAllowedTypes}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type TreeNodeFromImplicitAllowedTypesUnsafe<\n\t\tTSchema extends ImplicitAllowedTypesUnsafe,\n\t> = TSchema extends TreeNodeSchemaUnsafe\n\t\t? NodeFromSchemaUnsafe<TSchema>\n\t\t: TSchema extends AllowedTypesUnsafe\n\t\t\t? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>>\n\t\t\t: unknown;\n\n\t/**\n\t * {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.\n\t * @see {@link Input}\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<\n\t\tTSchema extends ImplicitAllowedTypesUnsafe,\n\t> = [TSchema] extends [TreeNodeSchemaUnsafe]\n\t\t? InsertableTypedNodeUnsafe<TSchema>\n\t\t: [TSchema] extends [AllowedTypesUnsafe]\n\t\t\t? InsertableTreeNodeFromAllowedTypesUnsafe<TSchema>\n\t\t\t: never;\n\n\t/**\n\t * {@link Unenforced} version of {@link InsertableTreeNodeFromAllowedTypes}.\n\t * @see {@link Input}\n\t * @privateRemarks\n\t * TODO: AB#36348: it seems like the order of the union this produces is what is non-deterministic in incremental builds\n\t * of the JsonAsTree schema.\n\t * @system @public\n\t */\n\texport type InsertableTreeNodeFromAllowedTypesUnsafe<TList extends AllowedTypesUnsafe> =\n\t\tIsUnion<TList> extends true\n\t\t\t? never\n\t\t\t: {\n\t\t\t\t\treadonly [Property in keyof TList]: TList[Property] extends LazyItem<\n\t\t\t\t\t\tinfer TSchema extends TreeNodeSchemaUnsafe\n\t\t\t\t\t>\n\t\t\t\t\t\t? InsertableTypedNodeUnsafe<TSchema>\n\t\t\t\t\t\t: never;\n\t\t\t\t}[number];\n\n\t/**\n\t * {@link Unenforced} version of {@link InsertableTypedNode}.\n\t * @see {@link Input}\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @privateRemarks\n\t * TODO:\n\t * This is less strict than InsertableTypedNode when given non-exact schema to avoid compilation issues.\n\t * This should probably be fixed or documented somehow.\n\t * @system @public\n\t */\n\texport type InsertableTypedNodeUnsafe<\n\t\tTSchema extends TreeNodeSchemaUnsafe,\n\t\tT = UnionToIntersection<TSchema>,\n\t> =\n\t\t| (T extends TreeNodeSchemaUnsafe<string, NodeKind, TreeNode | TreeLeafValue, never, true>\n\t\t\t\t? NodeBuilderDataUnsafe<T>\n\t\t\t\t: never)\n\t\t| (T extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<T> : never);\n\n\t/**\n\t * {@link Unenforced} version of {@link NodeFromSchema}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> =\n\t\tT extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;\n\n\t/**\n\t * {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> =\n\t\tT extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;\n\n\t/**\n\t * {@link Unenforced} version of {@link (TreeArrayNode:interface)}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @sealed @public\n\t */\n\texport interface TreeArrayNodeUnsafe<TAllowedTypes extends ImplicitAllowedTypesUnsafe>\n\t\textends TreeArrayNode<\n\t\t\tTAllowedTypes,\n\t\t\tTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>,\n\t\t\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>\n\t\t> {}\n\n\t/**\n\t * {@link Unenforced} version of {@link TreeMapNode}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @sealed @public\n\t */\n\texport interface TreeMapNodeUnsafe<T extends ImplicitAllowedTypesUnsafe>\n\t\textends ReadonlyMapInlined<string, T>,\n\t\t\tTreeNode {\n\t\t/**\n\t\t * {@inheritdoc TreeMapNode.set}\n\t\t */\n\t\tset(\n\t\t\tkey: string,\n\t\t\tvalue: InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T> | undefined,\n\t\t): void;\n\n\t\t/**\n\t\t * {@inheritdoc TreeMapNode.delete}\n\t\t */\n\t\tdelete(key: string): void;\n\t}\n\n\t/**\n\t * Copy of TypeScript's ReadonlyMap, but with `TreeNodeFromImplicitAllowedTypesUnsafe<T>` inlined into it.\n\t * Using this instead of ReadonlyMap in TreeMapNodeUnsafe is necessary to make recursive map schema not generate compile errors in the d.ts files when exported.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @privateRemarks\n\t * This is the same as `ReadonlyMap<K, TreeNodeFromImplicitAllowedTypesUnsafe<T>>` (Checked in test),\n\t * except that it avoids the above mentioned compile error.\n\t * Authored by manually inlining ReadonlyMap from from the TypeScript lib which can be found by navigating to the definition of `ReadonlyMap`.\n\t * @system @sealed @public\n\t */\n\texport interface ReadonlyMapInlined<K, T extends ImplicitAllowedTypesUnsafe> {\n\t\t/** Returns an iterable of entries in the map. */\n\t\t[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;\n\n\t\t/**\n\t\t * Returns an iterable of key, value pairs for every entry in the map.\n\t\t */\n\t\tentries(): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;\n\n\t\t/**\n\t\t * Returns an iterable of keys in the map\n\t\t */\n\t\tkeys(): IterableIterator<K>;\n\n\t\t/**\n\t\t * Returns an iterable of values in the map\n\t\t */\n\t\tvalues(): IterableIterator<TreeNodeFromImplicitAllowedTypesUnsafe<T>>;\n\n\t\tforEach(\n\t\t\tcallbackfn: (\n\t\t\t\tvalue: TreeNodeFromImplicitAllowedTypesUnsafe<T>,\n\t\t\t\tkey: K,\n\t\t\t\tmap: ReadonlyMap<K, TreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t) => void,\n\t\t\tthisArg?: any,\n\t\t): void;\n\t\tget(key: K): TreeNodeFromImplicitAllowedTypesUnsafe<T> | undefined;\n\t\thas(key: K): boolean;\n\t\treadonly size: number;\n\t}\n\n\t/**\n\t * {@link Unenforced} version of `FieldHasDefault`.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @sealed @public\n\t */\n\texport type FieldHasDefaultUnsafe<T extends ImplicitFieldSchemaUnsafe> =\n\t\tT extends FieldSchemaUnsafe<\n\t\t\tFieldKind.Optional | FieldKind.Identifier,\n\t\t\tImplicitAllowedTypesUnsafe\n\t\t>\n\t\t\t? true\n\t\t\t: false;\n\n\t/**\n\t * {@link Unenforced} version of `InsertableObjectFromSchemaRecord`.\n\t * @see {@link Input}\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type InsertableObjectFromSchemaRecordUnsafe<\n\t\tT extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>,\n\t> = {\n\t\t// Field might not have a default, so make it required:\n\t\treadonly [Property in keyof T as FieldHasDefaultUnsafe<T[Property & string]> extends false\n\t\t\t? Property\n\t\t\t: never]: InsertableTreeFieldFromImplicitFieldUnsafe<T[Property & string]>;\n\t} & {\n\t\t// Field might have a default, so allow optional.\n\t\t// Note that if the field could be either, this returns boolean, causing both fields to exist, resulting in required.\n\t\treadonly [Property in keyof T as FieldHasDefaultUnsafe<T[Property & string]> extends true\n\t\t\t? Property\n\t\t\t: never]?: InsertableTreeFieldFromImplicitFieldUnsafe<T[Property & string]>;\n\t};\n\n\t/**\n\t * {@link Unenforced} version of {@link InsertableTreeFieldFromImplicitField}.\n\t * @see {@link Input}\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @public\n\t */\n\texport type InsertableTreeFieldFromImplicitFieldUnsafe<\n\t\tTSchemaInput extends ImplicitFieldSchemaUnsafe,\n\t\tTSchema = UnionToIntersection<TSchemaInput>,\n\t> = [TSchema] extends [FieldSchemaUnsafe<infer Kind, infer Types>]\n\t\t? ApplyKindInput<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true>\n\t\t: [TSchema] extends [ImplicitAllowedTypes]\n\t\t\t? InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>\n\t\t\t: never;\n\n\t/**\n\t * {@link Unenforced} version of {@link FieldSchema}.\n\t * @remarks\n\t * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n\t * @system @sealed @public\n\t */\n\texport interface FieldSchemaUnsafe<\n\t\tout Kind extends FieldKind,\n\t\tout Types extends ImplicitAllowedTypesUnsafe,\n\t\tout TCustomMetadata = unknown,\n\t> extends FieldSchema<Kind, any, TCustomMetadata> {\n\t\t/**\n\t\t * {@inheritDoc FieldSchema.kind}\n\t\t */\n\t\treadonly kind: Kind;\n\t\t/**\n\t\t * {@inheritDoc FieldSchema.allowedTypes}\n\t\t */\n\t\treadonly allowedTypes: Types;\n\t\t/**\n\t\t * {@inheritDoc FieldSchema.allowedTypeSet}\n\t\t */\n\t\treadonly allowedTypeSet: ReadonlySet<TreeNodeSchema>;\n\t}\n}\n\n/**\n * {@link Unenforced} version of {@link FieldSchemaAlpha}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @alpha\n */\nexport interface FieldSchemaAlphaUnsafe<\n\tout Kind extends FieldKind,\n\tout Types extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\tout TCustomMetadata = unknown,\n> extends FieldSchemaAlpha<Kind, any, TCustomMetadata>,\n\t\tSystem_Unsafe.FieldSchemaUnsafe<Kind, Types, TCustomMetadata> {\n\t/**\n\t * {@inheritDoc FieldSchema.allowedTypes}\n\t */\n\treadonly allowedTypes: Types;\n}\n\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n/**\n * {@link Unenforced} version of {@link ArrayNodeCustomizableSchema}s.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @sealed\n * @alpha\n * @system\n */\nexport interface ArrayNodeCustomizableSchemaUnsafe<\n\tout TName extends string,\n\tin out T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\tout TCustomMetadata,\n> extends TreeNodeSchemaClass<\n\t\t\tTName,\n\t\t\tNodeKind.Array,\n\t\t\tSystem_Unsafe.TreeArrayNodeUnsafe<T> & WithType<TName, NodeKind.Array, T>,\n\t\t\t{\n\t\t\t\t[Symbol.iterator](): Iterator<\n\t\t\t\t\tSystem_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>\n\t\t\t\t>;\n\t\t\t},\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tundefined,\n\t\t\tTCustomMetadata\n\t\t>,\n\t\tSimpleArrayNodeSchema<TCustomMetadata> {}\n\n/**\n * {@link Unenforced} version of {@link MapNodeCustomizableSchema}s.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @sealed\n * @alpha\n * @system\n */\nexport interface MapNodeCustomizableSchemaUnsafe<\n\tout TName extends string,\n\tin out T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\tout TCustomMetadata,\n> extends TreeNodeSchemaClass<\n\t\t\tTName,\n\t\t\tNodeKind.Map,\n\t\t\tSystem_Unsafe.TreeMapNodeUnsafe<T> & WithType<TName, NodeKind.Map, T>,\n\t\t\t| {\n\t\t\t\t\t[Symbol.iterator](): Iterator<\n\t\t\t\t\t\t[string, System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>]\n\t\t\t\t\t>;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t },\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tundefined,\n\t\t\tTCustomMetadata\n\t\t>,\n\t\tSimpleMapNodeSchema<TCustomMetadata> {}\n\n/**\n * {@link Unenforced} version of {@link TreeRecordNode}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @beta\n */\nexport interface TreeRecordNodeUnsafe<\n\tTAllowedTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n> extends Record<string, System_Unsafe.TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>>,\n\t\tTreeNode {\n\t[Symbol.iterator](): IterableIterator<\n\t\t[string, System_Unsafe.TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>]\n\t>;\n}\n\n/**\n * {@link Unenforced} utility to remove {@link AnnotatedAllowedTypeUnsafe} wrappers.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @sealed\n * @beta\n * @system\n */\nexport type UnannotateAllowedTypeUnsafe<\n\tT extends Unenforced<\n\t\tAnnotatedAllowedTypeUnsafe | LazyItem<System_Unsafe.TreeNodeSchemaUnsafe>\n\t>,\n> = T extends AnnotatedAllowedTypeUnsafe<infer X> ? X : T;\n\n/**\n * {@link Unenforced} version of {@link AnnotatedAllowedType}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @beta\n */\nexport interface AnnotatedAllowedTypeUnsafe<T = Unenforced<LazyItem<TreeNodeSchema>>>\n\textends AnnotatedAllowedType<T> {}\n\n/**\n * {@link Unenforced} version of {@link AnnotatedAllowedTypes}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @beta\n */\nexport interface AnnotatedAllowedTypesUnsafe\n\textends AnnotatedAllowedTypes<LazyItem<System_Unsafe.TreeNodeSchemaUnsafe>> {}\n\n/**\n * {@link Unenforced} version of {@link AllowedTypesFull}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @alpha\n */\nexport type AllowedTypesFullUnsafe<\n\tT extends readonly AnnotatedAllowedTypeUnsafe[] = readonly AnnotatedAllowedTypeUnsafe[],\n> = AnnotatedAllowedTypes<T> & UnannotateAllowedTypesListUnsafe<T>;\n\n/**\n * {@link Unenforced} version of {@link AllowedTypesFullFromMixed}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @beta\n */\nexport type AllowedTypesFullFromMixedUnsafe<\n\tT extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],\n> = UnannotateAllowedTypesListUnsafe<T> &\n\tAnnotatedAllowedTypes<AnnotateAllowedTypesListUnsafe<T>>;\n\n/**\n * {@link Unenforced} version of {@link UnannotateAllowedTypesList}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @beta\n */\nexport type UnannotateAllowedTypesListUnsafe<\n\tT extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],\n> = {\n\treadonly [I in keyof T]: T[I] extends { type: infer X } ? X : T[I];\n};\n\n/**\n * {@link Unenforced} version of {@link AnnotateAllowedTypesList}.\n * @remarks\n * Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.\n * @system @sealed @beta\n */\nexport type AnnotateAllowedTypesListUnsafe<\n\tT extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],\n> = {\n\t[I in keyof T]: T[I] extends AnnotatedAllowedTypeUnsafe\n\t\t? T[I]\n\t\t: AnnotatedAllowedTypeUnsafe<T[I]>;\n};\n"]}
@@ -3,13 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { type ImplicitFieldSchema } from "../fieldSchema.js";
6
- import type { SimpleTreeSchema } from "../simpleSchema.js";
6
+ import type { SimpleNodeSchema, SimpleTreeSchema } from "../simpleSchema.js";
7
7
  /**
8
8
  * Converts an {@link ImplicitFieldSchema} to a "simple" schema representation.
9
9
  *
10
10
  * @param schema - The schema to convert
11
11
  * @param copySchemaObjects - If true, TreeNodeSchema and FieldSchema are copied into plain JavaScript objects. Either way, custom metadata is referenced and not copied.
12
- * @param isViewSchema - If true (default), properties used by view schema but not part of stored schema (for example, `isStaged` on allowed types) are preserved in the output.
13
12
  *
14
13
  * @remarks
15
14
  * Given that the Schema types used in {@link ImplicitFieldSchema} already implement the {@link SimpleNodeSchema} interfaces, there are limited use-cases for this function.
@@ -21,5 +20,21 @@ import type { SimpleTreeSchema } from "../simpleSchema.js";
21
20
  * TODO: once SimpleTreeSchema is stable, {@link TreeViewConfiguration} could implement {@link SimpleTreeSchema} directly.
22
21
  * That would provide the non-copying alternative that could expose the value type of the definitions map as {@link TreeNodeSchema}.
23
22
  */
24
- export declare function toSimpleTreeSchema(schema: ImplicitFieldSchema, copySchemaObjects: boolean, isViewSchema?: boolean): SimpleTreeSchema;
23
+ export declare function toSimpleTreeSchema(schema: ImplicitFieldSchema, copySchemaObjects: boolean): SimpleTreeSchema;
24
+ /**
25
+ * Copies a {@link SimpleNodeSchema} into a new plain JavaScript object.
26
+ *
27
+ * @remarks Caches the result on the input schema for future calls.
28
+ */
29
+ export declare function copySimpleNodeSchema(schema: SimpleNodeSchema): SimpleNodeSchema;
30
+ /**
31
+ * Creates a copy of a SimpleTreeSchema without metadata fields. This is useful for comparing deserialized view schemas with in-memory schemas.
32
+ * metadata and persistedMetadata are not relevant for schema compatibility checks and are not serialized by the Simple Schema serializer.
33
+ * @see {@link simpleSchemaSerializer.ts} for the serialization logic.
34
+ *
35
+ * @param schema - The SimpleTreeSchema to remove fields from.
36
+ * @param fieldsToRemove - An object specifying which fields to remove.
37
+ * @returns A new SimpleTreeSchema without the specified fields.
38
+ */
39
+ export declare function copySimpleTreeSchemaWithoutMetadata(schema: SimpleTreeSchema): SimpleTreeSchema;
25
40
  //# sourceMappingURL=viewSchemaToSimpleSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewSchemaToSimpleSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/viewSchemaToSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,KAAK,EAUX,gBAAgB,EAChB,MAAM,oBAAoB,CAAC;AAW5B;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,mBAAmB,EAC3B,iBAAiB,EAAE,OAAO,EAC1B,YAAY,GAAE,OAAc,GAC1B,gBAAgB,CAmClB"}
1
+ {"version":3,"file":"viewSchemaToSimpleSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/viewSchemaToSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,KAAK,EAKX,gBAAgB,EAIhB,gBAAgB,EAChB,MAAM,oBAAoB,CAAC;AAW5B;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,mBAAmB,EAC3B,iBAAiB,EAAE,OAAO,GACxB,gBAAgB,CA8BlB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAc/E;AAgDD;;;;;;;;GAQG;AACH,wBAAgB,mCAAmC,CAClD,MAAM,EAAE,gBAAgB,GACtB,gBAAgB,CAmDlB"}
@@ -13,7 +13,6 @@ import { LeafNodeSchema } from "../leafNodeSchema.js";
13
13
  *
14
14
  * @param schema - The schema to convert
15
15
  * @param copySchemaObjects - If true, TreeNodeSchema and FieldSchema are copied into plain JavaScript objects. Either way, custom metadata is referenced and not copied.
16
- * @param isViewSchema - If true (default), properties used by view schema but not part of stored schema (for example, `isStaged` on allowed types) are preserved in the output.
17
16
  *
18
17
  * @remarks
19
18
  * Given that the Schema types used in {@link ImplicitFieldSchema} already implement the {@link SimpleNodeSchema} interfaces, there are limited use-cases for this function.
@@ -25,7 +24,7 @@ import { LeafNodeSchema } from "../leafNodeSchema.js";
25
24
  * TODO: once SimpleTreeSchema is stable, {@link TreeViewConfiguration} could implement {@link SimpleTreeSchema} directly.
26
25
  * That would provide the non-copying alternative that could expose the value type of the definitions map as {@link TreeNodeSchema}.
27
26
  */
28
- export function toSimpleTreeSchema(schema, copySchemaObjects, isViewSchema = true) {
27
+ export function toSimpleTreeSchema(schema, copySchemaObjects) {
29
28
  const normalizedSchema = normalizeFieldSchema(schema);
30
29
  const definitions = new Map();
31
30
  walkFieldSchema(normalizedSchema, {
@@ -36,16 +35,14 @@ export function toSimpleTreeSchema(schema, copySchemaObjects, isViewSchema = tru
36
35
  nodeSchema instanceof LeafNodeSchema ||
37
36
  nodeSchema instanceof ObjectNodeSchema ||
38
37
  nodeSchema instanceof RecordNodeSchema, 0xb60 /* Invalid schema */);
39
- const outSchema = copySchemaObjects
40
- ? copySimpleNodeSchema(nodeSchema, isViewSchema)
41
- : nodeSchema;
38
+ const outSchema = copySchemaObjects ? copySimpleNodeSchema(nodeSchema) : nodeSchema;
42
39
  definitions.set(nodeSchema.identifier, outSchema);
43
40
  },
44
41
  });
45
42
  return {
46
43
  root: copySchemaObjects
47
44
  ? ({
48
- simpleAllowedTypes: normalizeSimpleAllowedTypes(normalizedSchema.simpleAllowedTypes, isViewSchema),
45
+ simpleAllowedTypes: normalizedSchema.simpleAllowedTypes,
49
46
  kind: normalizedSchema.kind,
50
47
  metadata: normalizedSchema.metadata,
51
48
  persistedMetadata: normalizedSchema.persistedMetadata,
@@ -54,30 +51,12 @@ export function toSimpleTreeSchema(schema, copySchemaObjects, isViewSchema = tru
54
51
  definitions,
55
52
  };
56
53
  }
57
- /**
58
- * Normalizes the {@link SimpleAllowedTypeAttributes} by either preserving or omitting view-specific schema properties.
59
- * @param simpleAllowedTypes - The simple allowed types to normalize.
60
- * @param isViewSchema - If true, properties used by view schema but not part of stored schema (for example, `isStaged` on allowed types) are preserved in the output.
61
- * @returns The normalized simple allowed types.
62
- */
63
- function normalizeSimpleAllowedTypes(simpleAllowedTypes, isViewSchema) {
64
- if (isViewSchema) {
65
- return simpleAllowedTypes;
66
- }
67
- else {
68
- const normalized = new Map();
69
- for (const [identifier, attributes] of simpleAllowedTypes.entries()) {
70
- normalized.set(identifier, { ...attributes, isStaged: undefined });
71
- }
72
- return normalized;
73
- }
74
- }
75
54
  /**
76
55
  * Copies a {@link SimpleNodeSchema} into a new plain JavaScript object.
77
56
  *
78
57
  * @remarks Caches the result on the input schema for future calls.
79
58
  */
80
- function copySimpleNodeSchema(schema, isViewSchema) {
59
+ export function copySimpleNodeSchema(schema) {
81
60
  const kind = schema.kind;
82
61
  switch (kind) {
83
62
  case NodeKind.Leaf:
@@ -85,9 +64,9 @@ function copySimpleNodeSchema(schema, isViewSchema) {
85
64
  case NodeKind.Array:
86
65
  case NodeKind.Map:
87
66
  case NodeKind.Record:
88
- return copySimpleSchemaWithAllowedTypes(schema, isViewSchema);
67
+ return copySimpleSchemaWithAllowedTypes(schema);
89
68
  case NodeKind.Object:
90
- return copySimpleObjectSchema(schema, isViewSchema);
69
+ return copySimpleObjectSchema(schema);
91
70
  default:
92
71
  unreachableCase(kind);
93
72
  }
@@ -100,31 +79,93 @@ function copySimpleLeafSchema(schema) {
100
79
  persistedMetadata: schema.persistedMetadata,
101
80
  };
102
81
  }
103
- function copySimpleSchemaWithAllowedTypes(schema, isViewSchema) {
82
+ function copySimpleSchemaWithAllowedTypes(schema) {
104
83
  return {
105
84
  kind: schema.kind,
106
- simpleAllowedTypes: normalizeSimpleAllowedTypes(schema.simpleAllowedTypes, isViewSchema),
85
+ simpleAllowedTypes: schema.simpleAllowedTypes,
107
86
  metadata: schema.metadata,
108
87
  persistedMetadata: schema.persistedMetadata,
109
88
  };
110
89
  }
111
- function copySimpleObjectSchema(schema, isViewSchema) {
90
+ function copySimpleObjectSchema(schema) {
112
91
  const fields = new Map();
113
92
  for (const [propertyKey, field] of schema.fields) {
114
93
  // field already is a SimpleObjectFieldSchema, but copy the subset of the properties needed by this interface to get a clean simple object.
115
- fields.set(propertyKey, {
94
+ const simpleField = {
116
95
  kind: field.kind,
117
- simpleAllowedTypes: normalizeSimpleAllowedTypes(field.simpleAllowedTypes, isViewSchema),
96
+ simpleAllowedTypes: field.simpleAllowedTypes,
118
97
  metadata: field.metadata,
119
98
  persistedMetadata: field.persistedMetadata,
120
99
  storedKey: field.storedKey,
121
- });
100
+ };
101
+ fields.set(propertyKey, simpleField);
122
102
  }
123
- return {
103
+ const simpleObject = {
124
104
  kind: NodeKind.Object,
125
105
  fields,
126
106
  metadata: schema.metadata,
127
107
  persistedMetadata: schema.persistedMetadata,
108
+ allowUnknownOptionalFields: schema.allowUnknownOptionalFields,
109
+ };
110
+ return simpleObject;
111
+ }
112
+ /**
113
+ * Creates a copy of a SimpleTreeSchema without metadata fields. This is useful for comparing deserialized view schemas with in-memory schemas.
114
+ * metadata and persistedMetadata are not relevant for schema compatibility checks and are not serialized by the Simple Schema serializer.
115
+ * @see {@link simpleSchemaSerializer.ts} for the serialization logic.
116
+ *
117
+ * @param schema - The SimpleTreeSchema to remove fields from.
118
+ * @param fieldsToRemove - An object specifying which fields to remove.
119
+ * @returns A new SimpleTreeSchema without the specified fields.
120
+ */
121
+ export function copySimpleTreeSchemaWithoutMetadata(schema) {
122
+ const definitions = new Map();
123
+ for (const [identifier, nodeSchema] of schema.definitions.entries()) {
124
+ const kind = nodeSchema.kind;
125
+ switch (kind) {
126
+ case NodeKind.Array:
127
+ case NodeKind.Map:
128
+ case NodeKind.Record:
129
+ case NodeKind.Leaf: {
130
+ const outputNodeSchema = {
131
+ ...nodeSchema,
132
+ metadata: {},
133
+ persistedMetadata: undefined,
134
+ };
135
+ definitions.set(identifier, outputNodeSchema);
136
+ break;
137
+ }
138
+ case NodeKind.Object: {
139
+ const outputFields = new Map();
140
+ for (const [propertyKey, fieldSchema] of nodeSchema.fields.entries()) {
141
+ const outputField = {
142
+ ...fieldSchema,
143
+ metadata: {},
144
+ persistedMetadata: undefined,
145
+ };
146
+ outputFields.set(propertyKey, outputField);
147
+ }
148
+ const outputNodeSchema = {
149
+ ...nodeSchema,
150
+ metadata: {},
151
+ persistedMetadata: undefined,
152
+ fields: outputFields,
153
+ };
154
+ definitions.set(identifier, outputNodeSchema);
155
+ break;
156
+ }
157
+ default:
158
+ unreachableCase(kind);
159
+ }
160
+ }
161
+ return {
162
+ root: {
163
+ kind: schema.root.kind,
164
+ simpleAllowedTypes: schema.root.simpleAllowedTypes,
165
+ metadata: {},
166
+ persistedMetadata: undefined,
167
+ },
168
+ definitions,
128
169
  };
129
170
  }
130
171
  //# sourceMappingURL=viewSchemaToSimpleSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewSchemaToSimpleSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/viewSchemaToSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAA4B,MAAM,mBAAmB,CAAC;AAanF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACN,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,kBAAkB,CACjC,MAA2B,EAC3B,iBAA0B,EAC1B,eAAwB,IAAI;IAE5B,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACtD,MAAM,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IACxD,eAAe,CAAC,gBAAgB,EAAE;QACjC,IAAI,EAAE,CAAC,UAAU,EAAE,EAAE;YACpB,iJAAiJ;YACjJ,MAAM,CACL,UAAU,YAAY,eAAe;gBACpC,UAAU,YAAY,aAAa;gBACnC,UAAU,YAAY,cAAc;gBACpC,UAAU,YAAY,gBAAgB;gBACtC,UAAU,YAAY,gBAAgB,EACvC,KAAK,CAAC,oBAAoB,CAC1B,CAAC;YACF,MAAM,SAAS,GAAG,iBAAiB;gBAClC,CAAC,CAAC,oBAAoB,CAAC,UAAU,EAAE,YAAY,CAAC;gBAChD,CAAC,CAAC,UAAU,CAAC;YACd,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC;KACD,CAAC,CAAC;IAEH,OAAO;QACN,IAAI,EAAE,iBAAiB;YACtB,CAAC,CAAC,CAAC;gBACD,kBAAkB,EAAE,2BAA2B,CAC9C,gBAAgB,CAAC,kBAAkB,EACnC,YAAY,CACZ;gBACD,IAAI,EAAE,gBAAgB,CAAC,IAAI;gBAC3B,QAAQ,EAAE,gBAAgB,CAAC,QAAQ;gBACnC,iBAAiB,EAAE,gBAAgB,CAAC,iBAAiB;aACzB,CAAC;YAC/B,CAAC,CAAC,gBAAgB;QACnB,WAAW;KACX,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,2BAA2B,CACnC,kBAAoE,EACpE,YAAqB;IAErB,IAAI,YAAY,EAAE,CAAC;QAClB,OAAO,kBAAkB,CAAC;IAC3B,CAAC;SAAM,CAAC;QACP,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuC,CAAC;QAClE,KAAK,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,kBAAkB,CAAC,OAAO,EAAE,EAAE,CAAC;YACrE,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,UAAU,CAAC;IACnB,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAC5B,MAAwB,EACxB,YAAqB;IAErB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,QAAQ,CAAC,IAAI;YACjB,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;QACrC,KAAK,QAAQ,CAAC,KAAK,CAAC;QACpB,KAAK,QAAQ,CAAC,GAAG,CAAC;QAClB,KAAK,QAAQ,CAAC,MAAM;YACnB,OAAO,gCAAgC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAC/D,KAAK,QAAQ,CAAC,MAAM;YACnB,OAAO,sBAAsB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACrD;YACC,eAAe,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;AACF,CAAC;AAED,SAAS,oBAAoB,CAAC,MAA4B;IACzD,OAAO;QACN,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;KAC3C,CAAC;AACH,CAAC;AAED,SAAS,gCAAgC,CACxC,MAA4E,EAC5E,YAAqB;IAErB,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,kBAAkB,EAAE,2BAA2B,CAAC,MAAM,CAAC,kBAAkB,EAAE,YAAY,CAAC;QACxF,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;KAC3C,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAC9B,MAA8B,EAC9B,YAAqB;IAErB,MAAM,MAAM,GAAyC,IAAI,GAAG,EAAE,CAAC;IAC/D,KAAK,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClD,2IAA2I;QAC3I,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE;YACvB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,kBAAkB,EAAE,2BAA2B,CAAC,KAAK,CAAC,kBAAkB,EAAE,YAAY,CAAC;YACvF,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,SAAS,EAAE,KAAK,CAAC,SAAS;SAC1B,CAAC,CAAC;IACJ,CAAC;IAED,OAAO;QACN,IAAI,EAAE,QAAQ,CAAC,MAAM;QACrB,MAAM;QACN,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;KAC3C,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport type {\n\tSimpleAllowedTypeAttributes,\n\tSimpleArrayNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectFieldSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleRecordNodeSchema,\n\tSimpleTreeSchema,\n} from \"../simpleSchema.js\";\nimport { NodeKind } from \"../core/index.js\";\nimport {\n\tArrayNodeSchema,\n\tMapNodeSchema,\n\tObjectNodeSchema,\n\tRecordNodeSchema,\n} from \"../node-kinds/index.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.js\";\n\n/**\n * Converts an {@link ImplicitFieldSchema} to a \"simple\" schema representation.\n *\n * @param schema - The schema to convert\n * @param copySchemaObjects - If true, TreeNodeSchema and FieldSchema are copied into plain JavaScript objects. Either way, custom metadata is referenced and not copied.\n * @param isViewSchema - If true (default), properties used by view schema but not part of stored schema (for example, `isStaged` on allowed types) are preserved in the output.\n *\n * @remarks\n * Given that the Schema types used in {@link ImplicitFieldSchema} already implement the {@link SimpleNodeSchema} interfaces, there are limited use-cases for this function.\n * One possible use-case is converting schema to a more serialization friendly format.\n * This format however is not JSON compatible due to use of Maps and Sets,\n * but it it does not rely on cyclic object references for handling recursive schema and instead uses the `definitions` map.\n *\n * @privateRemarks\n * TODO: once SimpleTreeSchema is stable, {@link TreeViewConfiguration} could implement {@link SimpleTreeSchema} directly.\n * That would provide the non-copying alternative that could expose the value type of the definitions map as {@link TreeNodeSchema}.\n */\nexport function toSimpleTreeSchema(\n\tschema: ImplicitFieldSchema,\n\tcopySchemaObjects: boolean,\n\tisViewSchema: boolean = true,\n): SimpleTreeSchema {\n\tconst normalizedSchema = normalizeFieldSchema(schema);\n\tconst definitions = new Map<string, SimpleNodeSchema>();\n\twalkFieldSchema(normalizedSchema, {\n\t\tnode: (nodeSchema) => {\n\t\t\t// The set of node kinds is extensible, but the typing of SimpleNodeSchema is not, so we need to check that the schema is one of the known kinds.\n\t\t\tassert(\n\t\t\t\tnodeSchema instanceof ArrayNodeSchema ||\n\t\t\t\t\tnodeSchema instanceof MapNodeSchema ||\n\t\t\t\t\tnodeSchema instanceof LeafNodeSchema ||\n\t\t\t\t\tnodeSchema instanceof ObjectNodeSchema ||\n\t\t\t\t\tnodeSchema instanceof RecordNodeSchema,\n\t\t\t\t0xb60 /* Invalid schema */,\n\t\t\t);\n\t\t\tconst outSchema = copySchemaObjects\n\t\t\t\t? copySimpleNodeSchema(nodeSchema, isViewSchema)\n\t\t\t\t: nodeSchema;\n\t\t\tdefinitions.set(nodeSchema.identifier, outSchema);\n\t\t},\n\t});\n\n\treturn {\n\t\troot: copySchemaObjects\n\t\t\t? ({\n\t\t\t\t\tsimpleAllowedTypes: normalizeSimpleAllowedTypes(\n\t\t\t\t\t\tnormalizedSchema.simpleAllowedTypes,\n\t\t\t\t\t\tisViewSchema,\n\t\t\t\t\t),\n\t\t\t\t\tkind: normalizedSchema.kind,\n\t\t\t\t\tmetadata: normalizedSchema.metadata,\n\t\t\t\t\tpersistedMetadata: normalizedSchema.persistedMetadata,\n\t\t\t\t} satisfies SimpleFieldSchema)\n\t\t\t: normalizedSchema,\n\t\tdefinitions,\n\t};\n}\n\n/**\n * Normalizes the {@link SimpleAllowedTypeAttributes} by either preserving or omitting view-specific schema properties.\n * @param simpleAllowedTypes - The simple allowed types to normalize.\n * @param isViewSchema - If true, properties used by view schema but not part of stored schema (for example, `isStaged` on allowed types) are preserved in the output.\n * @returns The normalized simple allowed types.\n */\nfunction normalizeSimpleAllowedTypes(\n\tsimpleAllowedTypes: ReadonlyMap<string, SimpleAllowedTypeAttributes>,\n\tisViewSchema: boolean,\n): ReadonlyMap<string, SimpleAllowedTypeAttributes> {\n\tif (isViewSchema) {\n\t\treturn simpleAllowedTypes;\n\t} else {\n\t\tconst normalized = new Map<string, SimpleAllowedTypeAttributes>();\n\t\tfor (const [identifier, attributes] of simpleAllowedTypes.entries()) {\n\t\t\tnormalized.set(identifier, { ...attributes, isStaged: undefined });\n\t\t}\n\t\treturn normalized;\n\t}\n}\n\n/**\n * Copies a {@link SimpleNodeSchema} into a new plain JavaScript object.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nfunction copySimpleNodeSchema(\n\tschema: SimpleNodeSchema,\n\tisViewSchema: boolean,\n): SimpleNodeSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf:\n\t\t\treturn copySimpleLeafSchema(schema);\n\t\tcase NodeKind.Array:\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record:\n\t\t\treturn copySimpleSchemaWithAllowedTypes(schema, isViewSchema);\n\t\tcase NodeKind.Object:\n\t\t\treturn copySimpleObjectSchema(schema, isViewSchema);\n\t\tdefault:\n\t\t\tunreachableCase(kind);\n\t}\n}\n\nfunction copySimpleLeafSchema(schema: SimpleLeafNodeSchema): SimpleLeafNodeSchema {\n\treturn {\n\t\tkind: NodeKind.Leaf,\n\t\tleafKind: schema.leafKind,\n\t\tmetadata: schema.metadata,\n\t\tpersistedMetadata: schema.persistedMetadata,\n\t};\n}\n\nfunction copySimpleSchemaWithAllowedTypes(\n\tschema: SimpleMapNodeSchema | SimpleArrayNodeSchema | SimpleRecordNodeSchema,\n\tisViewSchema: boolean,\n): SimpleMapNodeSchema | SimpleArrayNodeSchema | SimpleRecordNodeSchema {\n\treturn {\n\t\tkind: schema.kind,\n\t\tsimpleAllowedTypes: normalizeSimpleAllowedTypes(schema.simpleAllowedTypes, isViewSchema),\n\t\tmetadata: schema.metadata,\n\t\tpersistedMetadata: schema.persistedMetadata,\n\t};\n}\n\nfunction copySimpleObjectSchema(\n\tschema: SimpleObjectNodeSchema,\n\tisViewSchema: boolean,\n): SimpleObjectNodeSchema {\n\tconst fields: Map<string, SimpleObjectFieldSchema> = new Map();\n\tfor (const [propertyKey, field] of schema.fields) {\n\t\t// field already is a SimpleObjectFieldSchema, but copy the subset of the properties needed by this interface to get a clean simple object.\n\t\tfields.set(propertyKey, {\n\t\t\tkind: field.kind,\n\t\t\tsimpleAllowedTypes: normalizeSimpleAllowedTypes(field.simpleAllowedTypes, isViewSchema),\n\t\t\tmetadata: field.metadata,\n\t\t\tpersistedMetadata: field.persistedMetadata,\n\t\t\tstoredKey: field.storedKey,\n\t\t});\n\t}\n\n\treturn {\n\t\tkind: NodeKind.Object,\n\t\tfields,\n\t\tmetadata: schema.metadata,\n\t\tpersistedMetadata: schema.persistedMetadata,\n\t};\n}\n"]}
1
+ {"version":3,"file":"viewSchemaToSimpleSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/viewSchemaToSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAA4B,MAAM,mBAAmB,CAAC;AAYnF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACN,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,kBAAkB,CACjC,MAA2B,EAC3B,iBAA0B;IAE1B,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACtD,MAAM,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IACxD,eAAe,CAAC,gBAAgB,EAAE;QACjC,IAAI,EAAE,CAAC,UAAU,EAAE,EAAE;YACpB,iJAAiJ;YACjJ,MAAM,CACL,UAAU,YAAY,eAAe;gBACpC,UAAU,YAAY,aAAa;gBACnC,UAAU,YAAY,cAAc;gBACpC,UAAU,YAAY,gBAAgB;gBACtC,UAAU,YAAY,gBAAgB,EACvC,KAAK,CAAC,oBAAoB,CAC1B,CAAC;YACF,MAAM,SAAS,GAAG,iBAAiB,CAAC,CAAC,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;YACpF,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC;KACD,CAAC,CAAC;IAEH,OAAO;QACN,IAAI,EAAE,iBAAiB;YACtB,CAAC,CAAC,CAAC;gBACD,kBAAkB,EAAE,gBAAgB,CAAC,kBAAkB;gBACvD,IAAI,EAAE,gBAAgB,CAAC,IAAI;gBAC3B,QAAQ,EAAE,gBAAgB,CAAC,QAAQ;gBACnC,iBAAiB,EAAE,gBAAgB,CAAC,iBAAiB;aACzB,CAAC;YAC/B,CAAC,CAAC,gBAAgB;QACnB,WAAW;KACX,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAwB;IAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,QAAQ,CAAC,IAAI;YACjB,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;QACrC,KAAK,QAAQ,CAAC,KAAK,CAAC;QACpB,KAAK,QAAQ,CAAC,GAAG,CAAC;QAClB,KAAK,QAAQ,CAAC,MAAM;YACnB,OAAO,gCAAgC,CAAC,MAAM,CAAC,CAAC;QACjD,KAAK,QAAQ,CAAC,MAAM;YACnB,OAAO,sBAAsB,CAAC,MAAM,CAAC,CAAC;QACvC;YACC,eAAe,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;AACF,CAAC;AAED,SAAS,oBAAoB,CAAC,MAA4B;IACzD,OAAO;QACN,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;KAC3C,CAAC;AACH,CAAC;AAED,SAAS,gCAAgC,CACxC,MAA4E;IAE5E,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;KAC3C,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,MAA8B;IAC7D,MAAM,MAAM,GAAyC,IAAI,GAAG,EAAE,CAAC;IAC/D,KAAK,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClD,2IAA2I;QAC3I,MAAM,WAAW,GAAG;YACnB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,SAAS,EAAE,KAAK,CAAC,SAAS;SAC1B,CAAC;QAEF,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,YAAY,GAAG;QACpB,IAAI,EAAE,QAAQ,CAAC,MAAM;QACrB,MAAM;QACN,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,0BAA0B,EAAE,MAAM,CAAC,0BAA0B;KAC5B,CAAC;IAEnC,OAAO,YAAY,CAAC;AACrB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mCAAmC,CAClD,MAAwB;IAExB,MAAM,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IAExD,KAAK,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC;QACrE,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC7B,QAAQ,IAAI,EAAE,CAAC;YACd,KAAK,QAAQ,CAAC,KAAK,CAAC;YACpB,KAAK,QAAQ,CAAC,GAAG,CAAC;YAClB,KAAK,QAAQ,CAAC,MAAM,CAAC;YACrB,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;gBACpB,MAAM,gBAAgB,GAAG;oBACxB,GAAG,UAAU;oBACb,QAAQ,EAAE,EAAE;oBACZ,iBAAiB,EAAE,SAAS;iBAC5B,CAAC;gBACF,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;gBAC9C,MAAM;YACP,CAAC;YACD,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;gBACtB,MAAM,YAAY,GAAG,IAAI,GAAG,EAAmC,CAAC;gBAChE,KAAK,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;oBACtE,MAAM,WAAW,GAA4B;wBAC5C,GAAG,WAAW;wBACd,QAAQ,EAAE,EAAE;wBACZ,iBAAiB,EAAE,SAAS;qBAC5B,CAAC;oBACF,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;gBAC5C,CAAC;gBACD,MAAM,gBAAgB,GAAG;oBACxB,GAAG,UAAU;oBACb,QAAQ,EAAE,EAAE;oBACZ,iBAAiB,EAAE,SAAS;oBAC5B,MAAM,EAAE,YAAY;iBACpB,CAAC;gBACF,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;gBAC9C,MAAM;YACP,CAAC;YACD;gBACC,eAAe,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;IACF,CAAC;IAED,OAAO;QACN,IAAI,EAAE;YACL,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI;YACtB,kBAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,kBAAkB;YAClD,QAAQ,EAAE,EAAE;YACZ,iBAAiB,EAAE,SAAS;SAC5B;QACD,WAAW;KACX,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectFieldSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleRecordNodeSchema,\n\tSimpleTreeSchema,\n} from \"../simpleSchema.js\";\nimport { NodeKind } from \"../core/index.js\";\nimport {\n\tArrayNodeSchema,\n\tMapNodeSchema,\n\tObjectNodeSchema,\n\tRecordNodeSchema,\n} from \"../node-kinds/index.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.js\";\n\n/**\n * Converts an {@link ImplicitFieldSchema} to a \"simple\" schema representation.\n *\n * @param schema - The schema to convert\n * @param copySchemaObjects - If true, TreeNodeSchema and FieldSchema are copied into plain JavaScript objects. Either way, custom metadata is referenced and not copied.\n *\n * @remarks\n * Given that the Schema types used in {@link ImplicitFieldSchema} already implement the {@link SimpleNodeSchema} interfaces, there are limited use-cases for this function.\n * One possible use-case is converting schema to a more serialization friendly format.\n * This format however is not JSON compatible due to use of Maps and Sets,\n * but it it does not rely on cyclic object references for handling recursive schema and instead uses the `definitions` map.\n *\n * @privateRemarks\n * TODO: once SimpleTreeSchema is stable, {@link TreeViewConfiguration} could implement {@link SimpleTreeSchema} directly.\n * That would provide the non-copying alternative that could expose the value type of the definitions map as {@link TreeNodeSchema}.\n */\nexport function toSimpleTreeSchema(\n\tschema: ImplicitFieldSchema,\n\tcopySchemaObjects: boolean,\n): SimpleTreeSchema {\n\tconst normalizedSchema = normalizeFieldSchema(schema);\n\tconst definitions = new Map<string, SimpleNodeSchema>();\n\twalkFieldSchema(normalizedSchema, {\n\t\tnode: (nodeSchema) => {\n\t\t\t// The set of node kinds is extensible, but the typing of SimpleNodeSchema is not, so we need to check that the schema is one of the known kinds.\n\t\t\tassert(\n\t\t\t\tnodeSchema instanceof ArrayNodeSchema ||\n\t\t\t\t\tnodeSchema instanceof MapNodeSchema ||\n\t\t\t\t\tnodeSchema instanceof LeafNodeSchema ||\n\t\t\t\t\tnodeSchema instanceof ObjectNodeSchema ||\n\t\t\t\t\tnodeSchema instanceof RecordNodeSchema,\n\t\t\t\t0xb60 /* Invalid schema */,\n\t\t\t);\n\t\t\tconst outSchema = copySchemaObjects ? copySimpleNodeSchema(nodeSchema) : nodeSchema;\n\t\t\tdefinitions.set(nodeSchema.identifier, outSchema);\n\t\t},\n\t});\n\n\treturn {\n\t\troot: copySchemaObjects\n\t\t\t? ({\n\t\t\t\t\tsimpleAllowedTypes: normalizedSchema.simpleAllowedTypes,\n\t\t\t\t\tkind: normalizedSchema.kind,\n\t\t\t\t\tmetadata: normalizedSchema.metadata,\n\t\t\t\t\tpersistedMetadata: normalizedSchema.persistedMetadata,\n\t\t\t\t} satisfies SimpleFieldSchema)\n\t\t\t: normalizedSchema,\n\t\tdefinitions,\n\t};\n}\n\n/**\n * Copies a {@link SimpleNodeSchema} into a new plain JavaScript object.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nexport function copySimpleNodeSchema(schema: SimpleNodeSchema): SimpleNodeSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf:\n\t\t\treturn copySimpleLeafSchema(schema);\n\t\tcase NodeKind.Array:\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record:\n\t\t\treturn copySimpleSchemaWithAllowedTypes(schema);\n\t\tcase NodeKind.Object:\n\t\t\treturn copySimpleObjectSchema(schema);\n\t\tdefault:\n\t\t\tunreachableCase(kind);\n\t}\n}\n\nfunction copySimpleLeafSchema(schema: SimpleLeafNodeSchema): SimpleLeafNodeSchema {\n\treturn {\n\t\tkind: NodeKind.Leaf,\n\t\tleafKind: schema.leafKind,\n\t\tmetadata: schema.metadata,\n\t\tpersistedMetadata: schema.persistedMetadata,\n\t};\n}\n\nfunction copySimpleSchemaWithAllowedTypes(\n\tschema: SimpleMapNodeSchema | SimpleArrayNodeSchema | SimpleRecordNodeSchema,\n): SimpleMapNodeSchema | SimpleArrayNodeSchema | SimpleRecordNodeSchema {\n\treturn {\n\t\tkind: schema.kind,\n\t\tsimpleAllowedTypes: schema.simpleAllowedTypes,\n\t\tmetadata: schema.metadata,\n\t\tpersistedMetadata: schema.persistedMetadata,\n\t};\n}\n\nfunction copySimpleObjectSchema(schema: SimpleObjectNodeSchema): SimpleObjectNodeSchema {\n\tconst fields: Map<string, SimpleObjectFieldSchema> = new Map();\n\tfor (const [propertyKey, field] of schema.fields) {\n\t\t// field already is a SimpleObjectFieldSchema, but copy the subset of the properties needed by this interface to get a clean simple object.\n\t\tconst simpleField = {\n\t\t\tkind: field.kind,\n\t\t\tsimpleAllowedTypes: field.simpleAllowedTypes,\n\t\t\tmetadata: field.metadata,\n\t\t\tpersistedMetadata: field.persistedMetadata,\n\t\t\tstoredKey: field.storedKey,\n\t\t};\n\n\t\tfields.set(propertyKey, simpleField);\n\t}\n\n\tconst simpleObject = {\n\t\tkind: NodeKind.Object,\n\t\tfields,\n\t\tmetadata: schema.metadata,\n\t\tpersistedMetadata: schema.persistedMetadata,\n\t\tallowUnknownOptionalFields: schema.allowUnknownOptionalFields,\n\t} satisfies SimpleObjectNodeSchema;\n\n\treturn simpleObject;\n}\n\n/**\n * Creates a copy of a SimpleTreeSchema without metadata fields. This is useful for comparing deserialized view schemas with in-memory schemas.\n * metadata and persistedMetadata are not relevant for schema compatibility checks and are not serialized by the Simple Schema serializer.\n * @see {@link simpleSchemaSerializer.ts} for the serialization logic.\n *\n * @param schema - The SimpleTreeSchema to remove fields from.\n * @param fieldsToRemove - An object specifying which fields to remove.\n * @returns A new SimpleTreeSchema without the specified fields.\n */\nexport function copySimpleTreeSchemaWithoutMetadata(\n\tschema: SimpleTreeSchema,\n): SimpleTreeSchema {\n\tconst definitions = new Map<string, SimpleNodeSchema>();\n\n\tfor (const [identifier, nodeSchema] of schema.definitions.entries()) {\n\t\tconst kind = nodeSchema.kind;\n\t\tswitch (kind) {\n\t\t\tcase NodeKind.Array:\n\t\t\tcase NodeKind.Map:\n\t\t\tcase NodeKind.Record:\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tconst outputNodeSchema = {\n\t\t\t\t\t...nodeSchema,\n\t\t\t\t\tmetadata: {},\n\t\t\t\t\tpersistedMetadata: undefined,\n\t\t\t\t};\n\t\t\t\tdefinitions.set(identifier, outputNodeSchema);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tconst outputFields = new Map<string, SimpleObjectFieldSchema>();\n\t\t\t\tfor (const [propertyKey, fieldSchema] of nodeSchema.fields.entries()) {\n\t\t\t\t\tconst outputField: SimpleObjectFieldSchema = {\n\t\t\t\t\t\t...fieldSchema,\n\t\t\t\t\t\tmetadata: {},\n\t\t\t\t\t\tpersistedMetadata: undefined,\n\t\t\t\t\t};\n\t\t\t\t\toutputFields.set(propertyKey, outputField);\n\t\t\t\t}\n\t\t\t\tconst outputNodeSchema = {\n\t\t\t\t\t...nodeSchema,\n\t\t\t\t\tmetadata: {},\n\t\t\t\t\tpersistedMetadata: undefined,\n\t\t\t\t\tfields: outputFields,\n\t\t\t\t};\n\t\t\t\tdefinitions.set(identifier, outputNodeSchema);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n\n\treturn {\n\t\troot: {\n\t\t\tkind: schema.root.kind,\n\t\t\tsimpleAllowedTypes: schema.root.simpleAllowedTypes,\n\t\t\tmetadata: {},\n\t\t\tpersistedMetadata: undefined,\n\t\t},\n\t\tdefinitions,\n\t};\n}\n"]}