@fluidframework/tree 2.63.0-359734 → 2.63.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 (328) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/api-report/tree.alpha.api.md +42 -8
  3. package/dist/alpha.d.ts +7 -0
  4. package/dist/codec/codec.d.ts +10 -27
  5. package/dist/codec/codec.d.ts.map +1 -1
  6. package/dist/codec/codec.js +9 -28
  7. package/dist/codec/codec.js.map +1 -1
  8. package/dist/codec/versioned/codec.d.ts +6 -5
  9. package/dist/codec/versioned/codec.d.ts.map +1 -1
  10. package/dist/codec/versioned/codec.js +4 -4
  11. package/dist/codec/versioned/codec.js.map +1 -1
  12. package/dist/core/tree/detachedFieldIndex.js +1 -1
  13. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  14. package/dist/core/tree/detachedFieldIndexCodecs.js +1 -1
  15. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  16. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +67 -13
  17. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  18. package/dist/feature-libraries/chunked-forest/chunkTree.js +70 -35
  19. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  20. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -8
  21. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  22. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  23. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  24. package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts +23 -0
  25. package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts.map +1 -0
  26. package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js +15 -0
  27. package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js.map +1 -0
  28. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -0
  29. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  30. package/dist/feature-libraries/chunked-forest/codec/index.js +3 -1
  31. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  32. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +3 -2
  34. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  35. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  36. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  37. package/dist/feature-libraries/chunked-forest/index.js +2 -1
  38. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  39. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  40. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  41. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -1
  42. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  43. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  44. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -3
  45. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  46. package/dist/feature-libraries/forest-summary/forestSummarizer.js +3 -3
  47. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  48. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +4 -11
  49. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  50. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +2 -6
  51. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  52. package/dist/feature-libraries/index.d.ts +1 -1
  53. package/dist/feature-libraries/index.d.ts.map +1 -1
  54. package/dist/feature-libraries/index.js +2 -1
  55. package/dist/feature-libraries/index.js.map +1 -1
  56. package/dist/feature-libraries/schema-index/codec.d.ts +6 -5
  57. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  58. package/dist/feature-libraries/schema-index/codec.js +3 -3
  59. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/packageVersion.d.ts +1 -1
  64. package/dist/packageVersion.d.ts.map +1 -1
  65. package/dist/packageVersion.js +1 -1
  66. package/dist/packageVersion.js.map +1 -1
  67. package/dist/shared-tree/independentView.d.ts.map +1 -1
  68. package/dist/shared-tree/independentView.js +2 -2
  69. package/dist/shared-tree/independentView.js.map +1 -1
  70. package/dist/shared-tree/schematizingTreeView.d.ts +5 -0
  71. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  72. package/dist/shared-tree/schematizingTreeView.js +37 -7
  73. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  74. package/dist/shared-tree/sharedTree.d.ts +6 -8
  75. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  76. package/dist/shared-tree/sharedTree.js +7 -9
  77. package/dist/shared-tree/sharedTree.js.map +1 -1
  78. package/dist/shared-tree/sharedTreeChangeCodecs.js +1 -1
  79. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  80. package/dist/shared-tree/tree.js +1 -1
  81. package/dist/shared-tree/tree.js.map +1 -1
  82. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  83. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  84. package/dist/shared-tree/treeAlpha.js +3 -3
  85. package/dist/shared-tree/treeAlpha.js.map +1 -1
  86. package/dist/shared-tree/treeCheckout.js +1 -1
  87. package/dist/shared-tree/treeCheckout.js.map +1 -1
  88. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  89. package/dist/shared-tree-core/defaultResubmitMachine.js +3 -2
  90. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  91. package/dist/simple-tree/api/index.d.ts +1 -1
  92. package/dist/simple-tree/api/index.d.ts.map +1 -1
  93. package/dist/simple-tree/api/index.js.map +1 -1
  94. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +37 -2
  95. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  96. package/dist/simple-tree/api/schemaFactoryAlpha.js +34 -14
  97. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  98. package/dist/simple-tree/api/schemaStatics.js +3 -0
  99. package/dist/simple-tree/api/schemaStatics.js.map +1 -1
  100. package/dist/simple-tree/api/storedSchema.d.ts +4 -3
  101. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  102. package/dist/simple-tree/api/storedSchema.js +3 -3
  103. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  104. package/dist/simple-tree/api/treeBeta.js +2 -2
  105. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  106. package/dist/simple-tree/api/treeNodeApi.js +3 -3
  107. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  108. package/dist/simple-tree/api/typesUnsafe.d.ts +60 -1
  109. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  110. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  111. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  112. package/dist/simple-tree/core/allowedTypes.js +1 -1
  113. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  114. package/dist/simple-tree/core/index.d.ts +1 -1
  115. package/dist/simple-tree/core/index.d.ts.map +1 -1
  116. package/dist/simple-tree/core/index.js +2 -2
  117. package/dist/simple-tree/core/index.js.map +1 -1
  118. package/dist/simple-tree/core/treeNodeKernel.d.ts +7 -11
  119. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  120. package/dist/simple-tree/core/treeNodeKernel.js +24 -47
  121. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  122. package/dist/simple-tree/getTreeNodeForField.js +1 -1
  123. package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
  124. package/dist/simple-tree/index.d.ts +2 -2
  125. package/dist/simple-tree/index.d.ts.map +1 -1
  126. package/dist/simple-tree/index.js +2 -2
  127. package/dist/simple-tree/index.js.map +1 -1
  128. package/dist/simple-tree/node-kinds/array/arrayNode.js +2 -2
  129. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  130. package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
  131. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  132. package/dist/simple-tree/node-kinds/object/objectNode.js +3 -3
  133. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  134. package/dist/simple-tree/node-kinds/record/recordNode.js +6 -6
  135. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  136. package/dist/simple-tree/prepareForInsertion.d.ts +36 -4
  137. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  138. package/dist/simple-tree/prepareForInsertion.js +43 -15
  139. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  140. package/dist/treeFactory.d.ts.map +1 -1
  141. package/dist/treeFactory.js +13 -4
  142. package/dist/treeFactory.js.map +1 -1
  143. package/lib/alpha.d.ts +7 -0
  144. package/lib/codec/codec.d.ts +10 -27
  145. package/lib/codec/codec.d.ts.map +1 -1
  146. package/lib/codec/codec.js +8 -27
  147. package/lib/codec/codec.js.map +1 -1
  148. package/lib/codec/versioned/codec.d.ts +6 -5
  149. package/lib/codec/versioned/codec.d.ts.map +1 -1
  150. package/lib/codec/versioned/codec.js +4 -4
  151. package/lib/codec/versioned/codec.js.map +1 -1
  152. package/lib/core/tree/detachedFieldIndex.js +1 -1
  153. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  154. package/lib/core/tree/detachedFieldIndexCodecs.js +1 -1
  155. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  156. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +67 -13
  157. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  158. package/lib/feature-libraries/chunked-forest/chunkTree.js +68 -32
  159. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  160. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -8
  161. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  162. package/lib/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  163. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  164. package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts +23 -0
  165. package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts.map +1 -0
  166. package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js +11 -0
  167. package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js.map +1 -0
  168. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -0
  169. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  170. package/lib/feature-libraries/chunked-forest/codec/index.js +1 -0
  171. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  172. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  173. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +3 -2
  174. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  175. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  176. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  177. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  178. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  179. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  180. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  181. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -1
  182. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  183. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  184. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -3
  185. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  186. package/lib/feature-libraries/forest-summary/forestSummarizer.js +3 -3
  187. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  188. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +4 -11
  189. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  190. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +2 -6
  191. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  192. package/lib/feature-libraries/index.d.ts +1 -1
  193. package/lib/feature-libraries/index.d.ts.map +1 -1
  194. package/lib/feature-libraries/index.js +1 -1
  195. package/lib/feature-libraries/index.js.map +1 -1
  196. package/lib/feature-libraries/schema-index/codec.d.ts +6 -5
  197. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  198. package/lib/feature-libraries/schema-index/codec.js +3 -3
  199. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  200. package/lib/index.d.ts +1 -1
  201. package/lib/index.d.ts.map +1 -1
  202. package/lib/index.js.map +1 -1
  203. package/lib/packageVersion.d.ts +1 -1
  204. package/lib/packageVersion.d.ts.map +1 -1
  205. package/lib/packageVersion.js +1 -1
  206. package/lib/packageVersion.js.map +1 -1
  207. package/lib/shared-tree/independentView.d.ts.map +1 -1
  208. package/lib/shared-tree/independentView.js +3 -3
  209. package/lib/shared-tree/independentView.js.map +1 -1
  210. package/lib/shared-tree/schematizingTreeView.d.ts +5 -0
  211. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  212. package/lib/shared-tree/schematizingTreeView.js +40 -10
  213. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  214. package/lib/shared-tree/sharedTree.d.ts +6 -8
  215. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  216. package/lib/shared-tree/sharedTree.js +8 -10
  217. package/lib/shared-tree/sharedTree.js.map +1 -1
  218. package/lib/shared-tree/sharedTreeChangeCodecs.js +1 -1
  219. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  220. package/lib/shared-tree/tree.js +2 -2
  221. package/lib/shared-tree/tree.js.map +1 -1
  222. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  223. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  224. package/lib/shared-tree/treeAlpha.js +4 -4
  225. package/lib/shared-tree/treeAlpha.js.map +1 -1
  226. package/lib/shared-tree/treeCheckout.js +1 -1
  227. package/lib/shared-tree/treeCheckout.js.map +1 -1
  228. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  229. package/lib/shared-tree-core/defaultResubmitMachine.js +3 -2
  230. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  231. package/lib/simple-tree/api/index.d.ts +1 -1
  232. package/lib/simple-tree/api/index.d.ts.map +1 -1
  233. package/lib/simple-tree/api/index.js.map +1 -1
  234. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +37 -2
  235. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  236. package/lib/simple-tree/api/schemaFactoryAlpha.js +34 -14
  237. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  238. package/lib/simple-tree/api/schemaStatics.js +3 -0
  239. package/lib/simple-tree/api/schemaStatics.js.map +1 -1
  240. package/lib/simple-tree/api/storedSchema.d.ts +4 -3
  241. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  242. package/lib/simple-tree/api/storedSchema.js +3 -3
  243. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  244. package/lib/simple-tree/api/treeBeta.js +2 -2
  245. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  246. package/lib/simple-tree/api/treeNodeApi.js +4 -4
  247. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  248. package/lib/simple-tree/api/typesUnsafe.d.ts +60 -1
  249. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  250. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  251. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  252. package/lib/simple-tree/core/allowedTypes.js +1 -1
  253. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  254. package/lib/simple-tree/core/index.d.ts +1 -1
  255. package/lib/simple-tree/core/index.d.ts.map +1 -1
  256. package/lib/simple-tree/core/index.js +1 -1
  257. package/lib/simple-tree/core/index.js.map +1 -1
  258. package/lib/simple-tree/core/treeNodeKernel.d.ts +7 -11
  259. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  260. package/lib/simple-tree/core/treeNodeKernel.js +23 -46
  261. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  262. package/lib/simple-tree/getTreeNodeForField.js +1 -1
  263. package/lib/simple-tree/getTreeNodeForField.js.map +1 -1
  264. package/lib/simple-tree/index.d.ts +2 -2
  265. package/lib/simple-tree/index.d.ts.map +1 -1
  266. package/lib/simple-tree/index.js +1 -1
  267. package/lib/simple-tree/index.js.map +1 -1
  268. package/lib/simple-tree/node-kinds/array/arrayNode.js +3 -3
  269. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  270. package/lib/simple-tree/node-kinds/map/mapNode.js +3 -3
  271. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  272. package/lib/simple-tree/node-kinds/object/objectNode.js +4 -4
  273. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  274. package/lib/simple-tree/node-kinds/record/recordNode.js +7 -7
  275. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  276. package/lib/simple-tree/prepareForInsertion.d.ts +36 -4
  277. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  278. package/lib/simple-tree/prepareForInsertion.js +45 -17
  279. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  280. package/lib/treeFactory.d.ts.map +1 -1
  281. package/lib/treeFactory.js +13 -4
  282. package/lib/treeFactory.js.map +1 -1
  283. package/package.json +21 -20
  284. package/src/codec/codec.ts +11 -29
  285. package/src/codec/versioned/codec.ts +6 -6
  286. package/src/core/tree/detachedFieldIndex.ts +1 -1
  287. package/src/core/tree/detachedFieldIndexCodecs.ts +1 -1
  288. package/src/feature-libraries/chunked-forest/chunkTree.ts +112 -45
  289. package/src/feature-libraries/chunked-forest/codec/codecs.ts +7 -12
  290. package/src/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.ts +33 -0
  291. package/src/feature-libraries/chunked-forest/codec/index.ts +4 -0
  292. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +4 -7
  293. package/src/feature-libraries/chunked-forest/index.ts +2 -0
  294. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
  295. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +1 -1
  296. package/src/feature-libraries/forest-summary/forestSummarizer.ts +8 -12
  297. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +3 -12
  298. package/src/feature-libraries/index.ts +2 -0
  299. package/src/feature-libraries/schema-index/codec.ts +5 -5
  300. package/src/index.ts +7 -0
  301. package/src/packageVersion.ts +1 -1
  302. package/src/shared-tree/independentView.ts +3 -0
  303. package/src/shared-tree/schematizingTreeView.ts +63 -8
  304. package/src/shared-tree/sharedTree.ts +34 -21
  305. package/src/shared-tree/sharedTreeChangeCodecs.ts +1 -1
  306. package/src/shared-tree/tree.ts +2 -2
  307. package/src/shared-tree/treeAlpha.ts +6 -12
  308. package/src/shared-tree/treeCheckout.ts +1 -1
  309. package/src/shared-tree-core/defaultResubmitMachine.ts +3 -2
  310. package/src/simple-tree/api/index.ts +7 -0
  311. package/src/simple-tree/api/schemaFactoryAlpha.ts +79 -19
  312. package/src/simple-tree/api/schemaStatics.ts +3 -0
  313. package/src/simple-tree/api/storedSchema.ts +5 -4
  314. package/src/simple-tree/api/treeBeta.ts +2 -2
  315. package/src/simple-tree/api/treeNodeApi.ts +4 -4
  316. package/src/simple-tree/api/typesUnsafe.ts +81 -0
  317. package/src/simple-tree/core/TreeNodeBinding.md +14 -70
  318. package/src/simple-tree/core/allowedTypes.ts +4 -1
  319. package/src/simple-tree/core/index.ts +1 -1
  320. package/src/simple-tree/core/treeNodeKernel.ts +25 -59
  321. package/src/simple-tree/getTreeNodeForField.ts +1 -1
  322. package/src/simple-tree/index.ts +8 -1
  323. package/src/simple-tree/node-kinds/array/arrayNode.ts +3 -3
  324. package/src/simple-tree/node-kinds/map/mapNode.ts +3 -3
  325. package/src/simple-tree/node-kinds/object/objectNode.ts +4 -4
  326. package/src/simple-tree/node-kinds/record/recordNode.ts +7 -7
  327. package/src/simple-tree/prepareForInsertion.ts +87 -25
  328. package/src/treeFactory.ts +17 -4
@@ -7,20 +7,24 @@ import { defaultSchemaFactoryObjectOptions, scoped, } from "./schemaFactory.js";
7
7
  import { schemaStatics } from "./schemaStatics.js";
8
8
  import { normalizeToAnnotatedAllowedType, createSchemaUpgrade, AnnotatedAllowedTypesInternal, } from "../core/index.js";
9
9
  import { SchemaFactoryBeta } from "./schemaFactoryBeta.js";
10
+ const staged = (t) => {
11
+ const annotatedType = normalizeToAnnotatedAllowedType(t);
12
+ return {
13
+ type: annotatedType.type,
14
+ metadata: {
15
+ ...annotatedType.metadata,
16
+ stagedSchemaUpgrade: createSchemaUpgrade(),
17
+ },
18
+ };
19
+ };
20
+ const types = (t, metadata = {}) => {
21
+ return AnnotatedAllowedTypesInternal.createMixed(t, metadata);
22
+ };
10
23
  const schemaStaticsAlpha = {
11
- staged: (t) => {
12
- const annotatedType = normalizeToAnnotatedAllowedType(t);
13
- return {
14
- type: annotatedType.type,
15
- metadata: {
16
- ...annotatedType.metadata,
17
- stagedSchemaUpgrade: createSchemaUpgrade(),
18
- },
19
- };
20
- },
21
- types: (t, metadata = {}) => {
22
- return AnnotatedAllowedTypesInternal.createMixed(t, metadata);
23
- },
24
+ staged,
25
+ types,
26
+ stagedRecursive: staged,
27
+ typesRecursive: types,
24
28
  };
25
29
  /**
26
30
  * {@link SchemaFactory} with additional alpha APIs.
@@ -58,10 +62,18 @@ export class SchemaFactoryAlpha extends SchemaFactoryBeta {
58
62
  * {@inheritDoc SchemaStaticsAlpha.staged}
59
63
  */
60
64
  this.staged = schemaStaticsAlpha.staged;
65
+ /**
66
+ * {@inheritDoc SchemaStaticsAlpha.stagedRecursive}
67
+ */
68
+ this.stagedRecursive = schemaStaticsAlpha.stagedRecursive;
61
69
  /**
62
70
  * {@inheritDoc SchemaStaticsAlpha.types}
63
71
  */
64
72
  this.types = schemaStaticsAlpha.types;
73
+ /**
74
+ * {@inheritDoc SchemaStaticsAlpha.typesRecursive}
75
+ */
76
+ this.typesRecursive = schemaStaticsAlpha.typesRecursive;
65
77
  }
66
78
  /**
67
79
  * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.
@@ -120,7 +132,7 @@ export class SchemaFactoryAlpha extends SchemaFactoryBeta {
120
132
  return arraySchema(scoped(this, name), allowedTypes, true, true, options?.metadata, options?.persistedMetadata);
121
133
  }
122
134
  /**
123
- * {@inheritDoc SchemaFactory.objectRecursive}
135
+ * {@link SchemaFactory.arrayRecursive} but with support for some alpha features.
124
136
  */
125
137
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
126
138
  arrayRecursive(name, allowedTypes, options) {
@@ -204,8 +216,16 @@ SchemaFactoryAlpha.identifier = schemaStatics.identifier;
204
216
  * {@inheritDoc SchemaStaticsAlpha.staged}
205
217
  */
206
218
  SchemaFactoryAlpha.staged = schemaStaticsAlpha.staged;
219
+ /**
220
+ * {@inheritDoc SchemaStaticsAlpha.stagedRecursive}
221
+ */
222
+ SchemaFactoryAlpha.stagedRecursive = schemaStaticsAlpha.stagedRecursive;
207
223
  /**
208
224
  * {@inheritDoc SchemaStaticsAlpha.types}
209
225
  */
210
226
  SchemaFactoryAlpha.types = schemaStaticsAlpha.types;
227
+ /**
228
+ * {@inheritDoc SchemaStaticsAlpha.typesRecursive}
229
+ */
230
+ SchemaFactoryAlpha.typesRecursive = schemaStaticsAlpha.typesRecursive;
211
231
  //# sourceMappingURL=schemaFactoryAlpha.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ArrayNodeCustomizableSchema,\n\tarraySchema,\n\ttype MapNodeCustomizableSchema,\n\tmapSchema,\n\ttype ObjectNodeSchema,\n\tobjectSchema,\n\ttype RecordNodeCustomizableSchema,\n\trecordSchema,\n} from \"../node-kinds/index.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tscoped,\n\ttype NodeSchemaOptionsAlpha,\n\ttype ObjectSchemaOptionsAlpha,\n\ttype ScopedSchemaName,\n} from \"./schemaFactory.js\";\nimport { schemaStatics } from \"./schemaStatics.js\";\nimport type { ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type {\n\tNodeKind,\n\tTreeNodeSchema,\n\tTreeNodeSchemaClass,\n\tImplicitAllowedTypes,\n\tAnnotatedAllowedType,\n\tLazyItem,\n\tWithType,\n\tAllowedTypesMetadata,\n\tAllowedTypesFullFromMixed,\n} from \"../core/index.js\";\nimport {\n\tnormalizeToAnnotatedAllowedType,\n\tcreateSchemaUpgrade,\n\tAnnotatedAllowedTypesInternal,\n} from \"../core/index.js\";\nimport type {\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n} from \"./typesUnsafe.js\";\nimport type { SimpleObjectNodeSchema } from \"../simpleSchema.js\";\nimport { SchemaFactoryBeta } from \"./schemaFactoryBeta.js\";\n\n// These imports prevent a large number of type references in the API reports from showing up as *_2.\n/* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */\nimport type {\n\tFieldProps,\n\tFieldSchemaAlpha,\n\tFieldPropsAlpha,\n\tFieldKind,\n} from \"../fieldSchema.js\";\nimport type { LeafSchema } from \"../leafNodeSchema.js\";\nimport type { SimpleLeafNodeSchema } from \"../simpleSchema.js\";\nimport type { FieldSchemaAlphaUnsafe } from \"./typesUnsafe.js\";\n/* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */\n\n/**\n * Stateless APIs exposed via {@link SchemaFactoryAlpha} as both instance properties and as statics.\n * @remarks\n * See {@link SchemaStatics} for why this is useful.\n * @system @sealed @alpha\n */\nexport interface SchemaStaticsAlpha {\n\t/**\n\t * Declares a staged type in a set of {@link AllowedTypes}.\n\t *\n\t * @remarks\n\t * Staged allowed types add support for loading documents which may contain that type at the declared location.\n\t * This allows for an incremental rollout of a schema change to add a {@link TreeNodeSchema} to an {@link AllowedTypes} without breaking cross version collaboration.\n\t * A guide on this process can be found here: https://fluidframework.com/docs/data-structures/tree/schema-evolution/allowed-types-rollout\n\t *\n\t * Once enough clients have the type staged (and thus can read documents which allow it), documents can start being created and upgraded to allow the staged type.\n\t * This is done by deploying a new version of the app which removes the `staged` wrapper around the allowed type in the the schema definition.\n\t * This will also require {@link TreeView.upgradeSchema|upgrading the schema} for existing documents.\n\t *\n\t * Using a staged allowed type in a schema is just like using the schema as an allowed type with the following exceptions:\n\t *\n\t * 1. {@link TreeView.initialize} will omit the staged allowed type from the newly created stored schema.\n\t * 2. {@link TreeView.upgradeSchema} will omit the staged allowed type from the the upgraded stored schema.\n\t * 3. When evaluating {@link TreeView.compatibility}, it will be viewable even if the staged allowed type is not present in the stored schema's corresponding allowed types.\n\t * 4. Because of the above, it is possible to get errors when inserting content which uses the staged allowed type into a tree whose stored schema does not permit it.\n\t *\n\t * Currently, `staged` is not supported in the recursive type APIs: this is a known limitation which future versions of the API will address.\n\t *\n\t * @example\n\t * A full code example of the schema migration process can be found in our {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/src/test/simple-tree/api/stagedSchemaUpgrade.spec.ts | tests}.\n\t *\n\t * @privateRemarks\n\t * TODO:#44317 staged allowed types rely on schema validation of stored schema to output errors, these errors are not very\n\t * user friendly and should be improved, particularly in the case of staged allowed types\n\t *\n\t * TODO: AB#45711: Update the docs above when recursive type support is added.\n\t */\n\treadonly staged: <const T extends LazyItem<TreeNodeSchema>>(\n\t\tt: T | AnnotatedAllowedType<T>,\n\t) => AnnotatedAllowedType<T>;\n\n\t/**\n\t * Normalize information about a set of {@link AllowedTypes} into an {@link AllowedTypesFull}.\n\t * @remarks\n\t * This can take in {@link AnnotatedAllowedType} to preserve their annotations.\n\t */\n\treadonly types: <\n\t\tconst T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[],\n\t>(\n\t\tt: T,\n\t\tmetadata?: AllowedTypesMetadata,\n\t) => AllowedTypesFullFromMixed<T>;\n}\n\nconst schemaStaticsAlpha: SchemaStaticsAlpha = {\n\tstaged: <const T extends LazyItem<TreeNodeSchema>>(\n\t\tt: T | AnnotatedAllowedType<T>,\n\t): AnnotatedAllowedType<T> => {\n\t\tconst annotatedType = normalizeToAnnotatedAllowedType(t);\n\t\treturn {\n\t\t\ttype: annotatedType.type,\n\t\t\tmetadata: {\n\t\t\t\t...annotatedType.metadata,\n\t\t\t\tstagedSchemaUpgrade: createSchemaUpgrade(),\n\t\t\t},\n\t\t};\n\t},\n\n\ttypes: <const T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]>(\n\t\tt: T,\n\t\tmetadata: AllowedTypesMetadata = {},\n\t): AllowedTypesFullFromMixed<T> => {\n\t\treturn AnnotatedAllowedTypesInternal.createMixed<T>(t, metadata);\n\t},\n};\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n * When building schema, when `options` is not provided, `TCustomMetadata` is inferred as `unknown`.\n * If desired, this could be made to infer `undefined` instead by adding overloads for everything,\n * but currently it is not worth the maintenance overhead as there is no use case which this is known to be helpful for.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactoryBeta<TScope, TName> {\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic objectAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> & {\n\t\t/**\n\t\t * Typing checking workaround: not for for actual use.\n\t\t * @remarks\n\t\t * This API collides with {@link TreeNodeSchemaCore.createFromInsertable} to disable a type checking optimization which produces different and undesired results.\n\t\t * See {@link https://github.com/microsoft/TypeScript/issues/59049#issuecomment-2773459693} for more details.\n\t\t * @privateRemarks\n\t\t * The specific issue here is non-empty POJO mode object schema not being assignable to `ObjectNodeSchema`,\n\t\t * See the above link and the tests in objectNode.spec.ts which reference it.\n\t\t * @system\n\t\t */\n\t\treadonly createFromInsertable: unknown;\n\t} {\n\t\treturn objectSchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\toptions?.allowUnknownOptionalFields ??\n\t\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic static override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic static override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.staged}\n\t */\n\tpublic static staged = schemaStaticsAlpha.staged;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.staged}\n\t */\n\tpublic staged = schemaStaticsAlpha.staged;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.types}\n\t */\n\tpublic static types = schemaStaticsAlpha.types;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.types}\n\t */\n\tpublic types = schemaStaticsAlpha.types;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn arraySchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.recordAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic recordAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): RecordNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable: true,\n\t\t\timplicitlyConstructable: true,\n\t\t\tmetadata: options?.metadata,\n\t\t\tpersistedMetadata: options?.persistedMetadata,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactoryBeta.(record:2)} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.record` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override recordRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\tconst RecordSchema = recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes as T & ImplicitAllowedTypes,\n\t\t\tcustomizable: true,\n\t\t\t// Setting this to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\timplicitlyConstructable: false,\n\t\t\tmetadata: options?.metadata,\n\t\t\tpersistedMetadata: options?.persistedMetadata,\n\t\t});\n\n\t\treturn RecordSchema as TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNodeUnsafe<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t\t/* TInsertable */ {\n\t\t\t\t// Ideally this would be\n\t\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t\t// but doing so breaks recursive types.\n\t\t\t\t// Instead we do a less nice version:\n\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t},\n\t\t\t/* ImplicitlyConstructable */ false,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined,\n\t\t\t/* TCustomMetadata */ TCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactoryBeta.scopedFactory}\n\t */\n\tpublic scopedFactoryAlpha<\n\t\tconst T extends TName,\n\t\tTNameInner extends number | string = string,\n\t>(name: T): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(scoped<TScope, TName, T>(this, name));\n\t}\n}\n"]}
1
+ {"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ArrayNodeCustomizableSchema,\n\tarraySchema,\n\ttype MapNodeCustomizableSchema,\n\tmapSchema,\n\ttype ObjectNodeSchema,\n\tobjectSchema,\n\ttype RecordNodeCustomizableSchema,\n\trecordSchema,\n} from \"../node-kinds/index.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tscoped,\n\ttype NodeSchemaOptionsAlpha,\n\ttype ObjectSchemaOptionsAlpha,\n\ttype ScopedSchemaName,\n} from \"./schemaFactory.js\";\nimport { schemaStatics } from \"./schemaStatics.js\";\nimport type { ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type {\n\tNodeKind,\n\tTreeNodeSchema,\n\tTreeNodeSchemaClass,\n\tImplicitAllowedTypes,\n\tAnnotatedAllowedType,\n\tLazyItem,\n\tWithType,\n\tAllowedTypesMetadata,\n\tAllowedTypesFullFromMixed,\n} from \"../core/index.js\";\nimport {\n\tnormalizeToAnnotatedAllowedType,\n\tcreateSchemaUpgrade,\n\tAnnotatedAllowedTypesInternal,\n} from \"../core/index.js\";\nimport type {\n\tAllowedTypesFullFromMixedUnsafe,\n\tAnnotatedAllowedTypeUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n\tUnannotateAllowedTypeUnsafe,\n\tUnenforced,\n} from \"./typesUnsafe.js\";\nimport type { SimpleObjectNodeSchema } from \"../simpleSchema.js\";\nimport { SchemaFactoryBeta } from \"./schemaFactoryBeta.js\";\n\n// These imports prevent a large number of type references in the API reports from showing up as *_2.\n/* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */\nimport type {\n\tFieldProps,\n\tFieldSchemaAlpha,\n\tFieldPropsAlpha,\n\tFieldKind,\n} from \"../fieldSchema.js\";\nimport type { LeafSchema } from \"../leafNodeSchema.js\";\nimport type { SimpleLeafNodeSchema } from \"../simpleSchema.js\";\nimport type { FieldSchemaAlphaUnsafe } from \"./typesUnsafe.js\";\n/* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */\n\n/**\n * Stateless APIs exposed via {@link SchemaFactoryAlpha} as both instance properties and as statics.\n * @remarks\n * See {@link SchemaStatics} for why this is useful.\n * @system @sealed @alpha\n */\nexport interface SchemaStaticsAlpha {\n\t/**\n\t * Declares a staged type in a set of {@link AllowedTypes}.\n\t *\n\t * @remarks\n\t * Staged allowed types add support for loading documents which may contain that type at the declared location.\n\t * This allows for an incremental rollout of a schema change to add a {@link TreeNodeSchema} to an {@link AllowedTypes} without breaking cross version collaboration.\n\t * A guide on this process can be found here: https://fluidframework.com/docs/data-structures/tree/schema-evolution/allowed-types-rollout\n\t *\n\t * Once enough clients have the type staged (and thus can read documents which allow it), documents can start being created and upgraded to allow the staged type.\n\t * This is done by deploying a new version of the app which removes the `staged` wrapper around the allowed type in the the schema definition.\n\t * This will also require {@link TreeView.upgradeSchema|upgrading the schema} for existing documents.\n\t *\n\t * Using a staged allowed type in a schema is just like using the schema as an allowed type with the following exceptions:\n\t *\n\t * 1. {@link TreeView.initialize} will omit the staged allowed type from the newly created stored schema.\n\t * 2. {@link TreeView.upgradeSchema} will omit the staged allowed type from the the upgraded stored schema.\n\t * 3. When evaluating {@link TreeView.compatibility}, it will be viewable even if the staged allowed type is not present in the stored schema's corresponding allowed types.\n\t * 4. Because of the above, it is possible to get errors when inserting content which uses the staged allowed type into a tree whose stored schema does not permit it.\n\t *\n\t * Currently, `staged` is not supported in the recursive type APIs: this is a known limitation which future versions of the API will address.\n\t *\n\t * @example\n\t * A full code example of the schema migration process can be found in our {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/src/test/simple-tree/api/stagedSchemaUpgrade.spec.ts | tests}.\n\t *\n\t * @privateRemarks\n\t * TODO:#44317 staged allowed types rely on schema validation of stored schema to output errors, these errors are not very\n\t * user friendly and should be improved, particularly in the case of staged allowed types\n\t *\n\t * TODO: AB#45711: Update the docs above when recursive type support is added.\n\t */\n\treadonly staged: <const T extends LazyItem<TreeNodeSchema>>(\n\t\tt: T | AnnotatedAllowedType<T>,\n\t) => AnnotatedAllowedType<T>;\n\n\t/**\n\t * Normalize information about a set of {@link AllowedTypes} into an {@link AllowedTypesFull}.\n\t * @remarks\n\t * This can take in {@link AnnotatedAllowedType} to preserve their annotations.\n\t */\n\treadonly types: <\n\t\tconst T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[],\n\t>(\n\t\tt: T,\n\t\tmetadata?: AllowedTypesMetadata,\n\t) => AllowedTypesFullFromMixed<T>;\n\n\t/**\n\t * {@link SchemaStaticsAlpha.staged} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStaticsAlpha.staged} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tstagedRecursive: <\n\t\tconst T extends Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>,\n\t>(\n\t\tt: T,\n\t) => AnnotatedAllowedTypeUnsafe<UnannotateAllowedTypeUnsafe<T>>;\n\n\t/**\n\t * {@link SchemaStaticsAlpha.types} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStaticsAlpha.types} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t * @privateRemarks\n\t * If all inputs (at least recursive ones) were required to be annotated, this could be typed more strongly.\n\t * In that case it could use `T extends readonly (AnnotatedAllowedTypeUnsafe | LazyItem<System_Unsafe.TreeNodeSchemaUnsafe>)[]`.\n\t */\n\treadonly typesRecursive: <\n\t\tconst T extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],\n\t>(\n\t\tt: T,\n\t\tmetadata?: AllowedTypesMetadata,\n\t) => AllowedTypesFullFromMixedUnsafe<T>;\n}\n\nconst staged = <const T extends LazyItem<TreeNodeSchema>>(\n\tt: T | AnnotatedAllowedType<T>,\n): AnnotatedAllowedType<T> => {\n\tconst annotatedType = normalizeToAnnotatedAllowedType(t);\n\treturn {\n\t\ttype: annotatedType.type,\n\t\tmetadata: {\n\t\t\t...annotatedType.metadata,\n\t\t\tstagedSchemaUpgrade: createSchemaUpgrade(),\n\t\t},\n\t};\n};\n\nconst types = <const T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]>(\n\tt: T,\n\tmetadata: AllowedTypesMetadata = {},\n): AllowedTypesFullFromMixed<T> => {\n\treturn AnnotatedAllowedTypesInternal.createMixed<T>(t, metadata);\n};\n\nconst schemaStaticsAlpha: SchemaStaticsAlpha = {\n\tstaged,\n\ttypes,\n\n\tstagedRecursive: staged as SchemaStaticsAlpha[\"stagedRecursive\"],\n\ttypesRecursive: types as unknown as SchemaStaticsAlpha[\"typesRecursive\"],\n};\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n * When building schema, when `options` is not provided, `TCustomMetadata` is inferred as `unknown`.\n * If desired, this could be made to infer `undefined` instead by adding overloads for everything,\n * but currently it is not worth the maintenance overhead as there is no use case which this is known to be helpful for.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactoryBeta<TScope, TName> {\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic objectAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> & {\n\t\t/**\n\t\t * Typing checking workaround: not for for actual use.\n\t\t * @remarks\n\t\t * This API collides with {@link TreeNodeSchemaCore.createFromInsertable} to disable a type checking optimization which produces different and undesired results.\n\t\t * See {@link https://github.com/microsoft/TypeScript/issues/59049#issuecomment-2773459693} for more details.\n\t\t * @privateRemarks\n\t\t * The specific issue here is non-empty POJO mode object schema not being assignable to `ObjectNodeSchema`,\n\t\t * See the above link and the tests in objectNode.spec.ts which reference it.\n\t\t * @system\n\t\t */\n\t\treadonly createFromInsertable: unknown;\n\t} {\n\t\treturn objectSchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\toptions?.allowUnknownOptionalFields ??\n\t\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic static override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic static override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.staged}\n\t */\n\tpublic static staged = schemaStaticsAlpha.staged;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.staged}\n\t */\n\tpublic staged = schemaStaticsAlpha.staged;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.stagedRecursive}\n\t */\n\tpublic static stagedRecursive = schemaStaticsAlpha.stagedRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.stagedRecursive}\n\t */\n\tpublic stagedRecursive = schemaStaticsAlpha.stagedRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.types}\n\t */\n\tpublic static types = schemaStaticsAlpha.types;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.types}\n\t */\n\tpublic types = schemaStaticsAlpha.types;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.typesRecursive}\n\t */\n\tpublic static typesRecursive = schemaStaticsAlpha.typesRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.typesRecursive}\n\t */\n\tpublic typesRecursive = schemaStaticsAlpha.typesRecursive;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn arraySchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@link SchemaFactory.arrayRecursive} but with support for some alpha features.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.recordAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic recordAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): RecordNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable: true,\n\t\t\timplicitlyConstructable: true,\n\t\t\tmetadata: options?.metadata,\n\t\t\tpersistedMetadata: options?.persistedMetadata,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactoryBeta.(record:2)} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.record` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override recordRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\tconst RecordSchema = recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes as T & ImplicitAllowedTypes,\n\t\t\tcustomizable: true,\n\t\t\t// Setting this to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\timplicitlyConstructable: false,\n\t\t\tmetadata: options?.metadata,\n\t\t\tpersistedMetadata: options?.persistedMetadata,\n\t\t});\n\n\t\treturn RecordSchema as TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNodeUnsafe<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t\t/* TInsertable */ {\n\t\t\t\t// Ideally this would be\n\t\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t\t// but doing so breaks recursive types.\n\t\t\t\t// Instead we do a less nice version:\n\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t},\n\t\t\t/* ImplicitlyConstructable */ false,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined,\n\t\t\t/* TCustomMetadata */ TCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactoryBeta.scopedFactory}\n\t */\n\tpublic scopedFactoryAlpha<\n\t\tconst T extends TName,\n\t\tTNameInner extends number | string = string,\n\t>(name: T): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(scoped<TScope, TName, T>(this, name));\n\t}\n}\n"]}
@@ -46,6 +46,9 @@ export const schemaStatics = {
46
46
  return createFieldSchema(FieldKind.Identifier, stringSchema, props);
47
47
  },
48
48
  };
49
+ /**
50
+ * {@link Unenforced} version of {@link createFieldSchema}.
51
+ */
49
52
  function createFieldSchemaUnsafe(kind, allowedTypes, props) {
50
53
  // At runtime, we still want this to be a FieldSchema instance, but we can't satisfy its extends clause, so just return it as an FieldSchemaUnsafe
51
54
  return createFieldSchema(kind, allowedTypes, props);
@@ -1 +1 @@
1
- {"version":3,"file":"schemaStatics.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaStatics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AASrF,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,GACZ,MAAM,sBAAsB,CAAC;AA2I9B,MAAM,uBAAuB,GAAoB,kBAAkB,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,CAAC;IAE7E,QAAQ,EAAE,CACT,CAAI,EACJ,KAAiE,EACN,EAAE;QAC7D,OAAO,iBAAiB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE;YAC/C,eAAe,EAAE,uBAAuB;YACxC,GAAG,KAAK;SACR,CAAC,CAAC;IACJ,CAAC;IAED,QAAQ,EAAE,CACT,CAAI,EACJ,KAAiE,EACN,EAAE;QAC7D,OAAO,iBAAiB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,iBAAiB,EAAE,CAIlB,CAAI,EACJ,KAAiE,EACA,EAAE;QACnE,OAAO,uBAAuB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE;YACrD,eAAe,EAAE,uBAAuB;YACxC,GAAG,KAAK;SACR,CAAC,CAAC;IACJ,CAAC;IAED,iBAAiB,EAAE,CAIlB,CAAI,EACJ,KAAiE,EACA,EAAE;QACnE,OAAO,uBAAuB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;CACgC,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,GAAG,mBAAmB;IACtB,UAAU,EAAE,CACX,KAA4D,EACmB,EAAE;QACjF,OAAO,iBAAiB,CAAC,SAAS,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACrE,CAAC;CACQ,CAAC;AAEX,SAAS,uBAAuB,CAK/B,IAAU,EACV,YAAmB,EACnB,KAAmC;IAEnC,kJAAkJ;IAClJ,OAAO,iBAAiB,CACvB,IAAI,EACJ,YAA4C,EAC5C,KAAK,CACmD,CAAC;AAC3D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { ImplicitAllowedTypes } from \"../core/index.js\";\nimport { FieldKind, getDefaultProvider, createFieldSchema } from \"../fieldSchema.js\";\nimport type {\n\tFieldProps,\n\tFieldSchema,\n\tDefaultProvider,\n\tFieldPropsAlpha,\n\tFieldSchemaAlpha,\n} from \"../fieldSchema.js\";\nimport type { LeafSchema } from \"../leafNodeSchema.js\";\nimport {\n\tstringSchema,\n\tnumberSchema,\n\tbooleanSchema,\n\tnullSchema,\n\thandleSchema,\n} from \"../leafNodeSchema.js\";\nimport type { System_Unsafe, FieldSchemaAlphaUnsafe } from \"./typesUnsafe.js\";\n\n/**\n * Stateless APIs exposed via {@link SchemaFactory} as both instance properties and as statics.\n * @privateRemarks\n * We have no way to make linkable members which exist both as statics and instance properties since API-Extractor does not support this.\n * As a workaround, we have this type as a third place which can be linked.\n * @system @sealed @public\n */\nexport interface SchemaStatics {\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `string`.\n\t *\n\t * @remarks\n\t * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.\n\t *\n\t * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.\n\t * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\treadonly string: LeafSchema<\"string\", string>;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `number`.\n\t *\n\t * @remarks\n\t * The number is a {@link https://en.wikipedia.org/wiki/Double-precision_floating-point_format | double-precision 64-bit binary format IEEE 754} value, however there are some exceptions:\n\t *\n\t * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).\n\t *\n\t * - `-0` may be converted to `0` in some cases.\n\t *\n\t * These limitations match the limitations of JSON.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\treadonly number: LeafSchema<\"number\", number>;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a boolean.\n\t */\n\treadonly boolean: LeafSchema<\"boolean\", boolean>;\n\n\t/**\n\t * {@link TreeNodeSchema} for JavaScript `null`.\n\t *\n\t * @remarks\n\t * There are good {@link https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null | reasons to avoid using null} in JavaScript, however sometimes it is desired.\n\t * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.\n\t * Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\treadonly null: LeafSchema<\"null\", null>;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.\n\t */\n\treadonly handle: LeafSchema<\"handle\", IFluidHandle>;\n\n\t/**\n\t * {@link AllowedTypes} for holding any of the leaf types.\n\t */\n\treadonly leaves: readonly [\n\t\tSchemaStatics[\"string\"],\n\t\tSchemaStatics[\"number\"],\n\t\tSchemaStatics[\"boolean\"],\n\t\tSchemaStatics[\"null\"],\n\t\tSchemaStatics[\"handle\"],\n\t];\n\n\t/**\n\t * Make a field optional instead of the default, which is required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n\t * See {@link FieldSchemaMetadata.custom}.\n\t */\n\treadonly optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t) => FieldSchema<FieldKind.Optional, T, TCustomMetadata>;\n\n\t/**\n\t * Make a field explicitly required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @remarks\n\t * Fields are required by default, but this API can be used to make the required nature explicit in the schema,\n\t * and allows associating custom {@link FieldProps | properties} with the field.\n\t *\n\t * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n\t * See {@link FieldSchemaMetadata.custom}.\n\t */\n\treadonly required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t) => FieldSchema<FieldKind.Required, T, TCustomMetadata>;\n\n\t/**\n\t * {@link SchemaStatics.optional} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStatics.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\treadonly optionalRecursive: <\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Optional, T, TCustomMetadata>;\n\n\t/**\n\t * {@link SchemaStatics.required} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStatics.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\treadonly requiredRecursive: <\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Required, T, TCustomMetadata>;\n}\n\nconst defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => []);\n\n/**\n * Implementation of {@link SchemaStatics}.\n * @remarks\n * Entries can use more specific types than {@link SchemaStatics} requires to be more useful for non-public consumers.\n * Additional non-public members are in {@link schemaStatics}.\n */\nexport const schemaStaticsStable = {\n\tstring: stringSchema,\n\tnumber: numberSchema,\n\tboolean: booleanSchema,\n\tnull: nullSchema,\n\thandle: handleSchema,\n\tleaves: [stringSchema, numberSchema, booleanSchema, nullSchema, handleSchema],\n\n\toptional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata> => {\n\t\treturn createFieldSchema(FieldKind.Optional, t, {\n\t\t\tdefaultProvider: defaultOptionalProvider,\n\t\t\t...props,\n\t\t});\n\t},\n\n\trequired: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchemaAlpha<FieldKind.Required, T, TCustomMetadata> => {\n\t\treturn createFieldSchema(FieldKind.Required, t, props);\n\t},\n\n\toptionalRecursive: <\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata> => {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Optional, t, {\n\t\t\tdefaultProvider: defaultOptionalProvider,\n\t\t\t...props,\n\t\t});\n\t},\n\n\trequiredRecursive: <\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchemaAlphaUnsafe<FieldKind.Required, T, TCustomMetadata> => {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Required, t, props);\n\t},\n} as const satisfies SchemaStatics;\n\n/**\n * Unstable extensions to {@link schemaStaticsStable}.\n */\nexport const schemaStatics = {\n\t...schemaStaticsStable,\n\tidentifier: <const TCustomMetadata = unknown>(\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchemaAlpha<FieldKind.Identifier, typeof stringSchema, TCustomMetadata> => {\n\t\treturn createFieldSchema(FieldKind.Identifier, stringSchema, props);\n\t},\n} as const;\n\nfunction createFieldSchemaUnsafe<\n\tKind extends FieldKind,\n\tTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\tTCustomMetadata = unknown,\n>(\n\tkind: Kind,\n\tallowedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n): FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata> {\n\t// At runtime, we still want this to be a FieldSchema instance, but we can't satisfy its extends clause, so just return it as an FieldSchemaUnsafe\n\treturn createFieldSchema(\n\t\tkind,\n\t\tallowedTypes as ImplicitAllowedTypes & Types,\n\t\tprops,\n\t) as FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata>;\n}\n"]}
1
+ {"version":3,"file":"schemaStatics.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaStatics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AASrF,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,GACZ,MAAM,sBAAsB,CAAC;AA2I9B,MAAM,uBAAuB,GAAoB,kBAAkB,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,CAAC;IAE7E,QAAQ,EAAE,CACT,CAAI,EACJ,KAAiE,EACN,EAAE;QAC7D,OAAO,iBAAiB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE;YAC/C,eAAe,EAAE,uBAAuB;YACxC,GAAG,KAAK;SACR,CAAC,CAAC;IACJ,CAAC;IAED,QAAQ,EAAE,CACT,CAAI,EACJ,KAAiE,EACN,EAAE;QAC7D,OAAO,iBAAiB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,iBAAiB,EAAE,CAIlB,CAAI,EACJ,KAAiE,EACA,EAAE;QACnE,OAAO,uBAAuB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE;YACrD,eAAe,EAAE,uBAAuB;YACxC,GAAG,KAAK;SACR,CAAC,CAAC;IACJ,CAAC;IAED,iBAAiB,EAAE,CAIlB,CAAI,EACJ,KAAiE,EACA,EAAE;QACnE,OAAO,uBAAuB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;CACgC,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,GAAG,mBAAmB;IACtB,UAAU,EAAE,CACX,KAA4D,EACmB,EAAE;QACjF,OAAO,iBAAiB,CAAC,SAAS,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACrE,CAAC;CACQ,CAAC;AAEX;;GAEG;AACH,SAAS,uBAAuB,CAK/B,IAAU,EACV,YAAmB,EACnB,KAAmC;IAEnC,kJAAkJ;IAClJ,OAAO,iBAAiB,CACvB,IAAI,EACJ,YAA4C,EAC5C,KAAK,CACmD,CAAC;AAC3D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { ImplicitAllowedTypes } from \"../core/index.js\";\nimport { FieldKind, getDefaultProvider, createFieldSchema } from \"../fieldSchema.js\";\nimport type {\n\tFieldProps,\n\tFieldSchema,\n\tDefaultProvider,\n\tFieldPropsAlpha,\n\tFieldSchemaAlpha,\n} from \"../fieldSchema.js\";\nimport type { LeafSchema } from \"../leafNodeSchema.js\";\nimport {\n\tstringSchema,\n\tnumberSchema,\n\tbooleanSchema,\n\tnullSchema,\n\thandleSchema,\n} from \"../leafNodeSchema.js\";\nimport type { System_Unsafe, FieldSchemaAlphaUnsafe } from \"./typesUnsafe.js\";\n\n/**\n * Stateless APIs exposed via {@link SchemaFactory} as both instance properties and as statics.\n * @privateRemarks\n * We have no way to make linkable members which exist both as statics and instance properties since API-Extractor does not support this.\n * As a workaround, we have this type as a third place which can be linked.\n * @system @sealed @public\n */\nexport interface SchemaStatics {\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `string`.\n\t *\n\t * @remarks\n\t * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.\n\t *\n\t * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.\n\t * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\treadonly string: LeafSchema<\"string\", string>;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `number`.\n\t *\n\t * @remarks\n\t * The number is a {@link https://en.wikipedia.org/wiki/Double-precision_floating-point_format | double-precision 64-bit binary format IEEE 754} value, however there are some exceptions:\n\t *\n\t * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).\n\t *\n\t * - `-0` may be converted to `0` in some cases.\n\t *\n\t * These limitations match the limitations of JSON.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\treadonly number: LeafSchema<\"number\", number>;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a boolean.\n\t */\n\treadonly boolean: LeafSchema<\"boolean\", boolean>;\n\n\t/**\n\t * {@link TreeNodeSchema} for JavaScript `null`.\n\t *\n\t * @remarks\n\t * There are good {@link https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null | reasons to avoid using null} in JavaScript, however sometimes it is desired.\n\t * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.\n\t * Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\treadonly null: LeafSchema<\"null\", null>;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.\n\t */\n\treadonly handle: LeafSchema<\"handle\", IFluidHandle>;\n\n\t/**\n\t * {@link AllowedTypes} for holding any of the leaf types.\n\t */\n\treadonly leaves: readonly [\n\t\tSchemaStatics[\"string\"],\n\t\tSchemaStatics[\"number\"],\n\t\tSchemaStatics[\"boolean\"],\n\t\tSchemaStatics[\"null\"],\n\t\tSchemaStatics[\"handle\"],\n\t];\n\n\t/**\n\t * Make a field optional instead of the default, which is required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n\t * See {@link FieldSchemaMetadata.custom}.\n\t */\n\treadonly optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t) => FieldSchema<FieldKind.Optional, T, TCustomMetadata>;\n\n\t/**\n\t * Make a field explicitly required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @remarks\n\t * Fields are required by default, but this API can be used to make the required nature explicit in the schema,\n\t * and allows associating custom {@link FieldProps | properties} with the field.\n\t *\n\t * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n\t * See {@link FieldSchemaMetadata.custom}.\n\t */\n\treadonly required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t) => FieldSchema<FieldKind.Required, T, TCustomMetadata>;\n\n\t/**\n\t * {@link SchemaStatics.optional} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStatics.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\treadonly optionalRecursive: <\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Optional, T, TCustomMetadata>;\n\n\t/**\n\t * {@link SchemaStatics.required} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStatics.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\treadonly requiredRecursive: <\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Required, T, TCustomMetadata>;\n}\n\nconst defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => []);\n\n/**\n * Implementation of {@link SchemaStatics}.\n * @remarks\n * Entries can use more specific types than {@link SchemaStatics} requires to be more useful for non-public consumers.\n * Additional non-public members are in {@link schemaStatics}.\n */\nexport const schemaStaticsStable = {\n\tstring: stringSchema,\n\tnumber: numberSchema,\n\tboolean: booleanSchema,\n\tnull: nullSchema,\n\thandle: handleSchema,\n\tleaves: [stringSchema, numberSchema, booleanSchema, nullSchema, handleSchema],\n\n\toptional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata> => {\n\t\treturn createFieldSchema(FieldKind.Optional, t, {\n\t\t\tdefaultProvider: defaultOptionalProvider,\n\t\t\t...props,\n\t\t});\n\t},\n\n\trequired: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\t\tt: T,\n\t\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchemaAlpha<FieldKind.Required, T, TCustomMetadata> => {\n\t\treturn createFieldSchema(FieldKind.Required, t, props);\n\t},\n\n\toptionalRecursive: <\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata> => {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Optional, t, {\n\t\t\tdefaultProvider: defaultOptionalProvider,\n\t\t\t...props,\n\t\t});\n\t},\n\n\trequiredRecursive: <\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchemaAlphaUnsafe<FieldKind.Required, T, TCustomMetadata> => {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Required, t, props);\n\t},\n} as const satisfies SchemaStatics;\n\n/**\n * Unstable extensions to {@link schemaStaticsStable}.\n */\nexport const schemaStatics = {\n\t...schemaStaticsStable,\n\tidentifier: <const TCustomMetadata = unknown>(\n\t\tprops?: Omit<FieldProps<TCustomMetadata>, \"defaultProvider\">,\n\t): FieldSchemaAlpha<FieldKind.Identifier, typeof stringSchema, TCustomMetadata> => {\n\t\treturn createFieldSchema(FieldKind.Identifier, stringSchema, props);\n\t},\n} as const;\n\n/**\n * {@link Unenforced} version of {@link createFieldSchema}.\n */\nfunction createFieldSchemaUnsafe<\n\tKind extends FieldKind,\n\tTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\tTCustomMetadata = unknown,\n>(\n\tkind: Kind,\n\tallowedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n): FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata> {\n\t// At runtime, we still want this to be a FieldSchema instance, but we can't satisfy its extends clause, so just return it as an FieldSchemaUnsafe\n\treturn createFieldSchema(\n\t\tkind,\n\t\tallowedTypes as ImplicitAllowedTypes & Types,\n\t\tprops,\n\t) as FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata>;\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { FluidClientVersion, ICodecOptions } from "../../codec/index.js";
5
+ import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
6
+ import type { ICodecOptions } from "../../codec/index.js";
6
7
  import type { JsonCompatible } from "../../util/index.js";
7
8
  import type { SchemaUpgrade } from "../core/index.js";
8
9
  import { type ImplicitFieldSchema } from "../fieldSchema.js";
@@ -11,7 +12,7 @@ import type { SchemaCompatibilityStatus } from "./tree.js";
11
12
  * Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.
12
13
  *
13
14
  * @param schema - The schema to dump.
14
- * @param oldestCompatibleClient - The oldest client version which can read the schema: impacts the format used.
15
+ * @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.
15
16
  * @param includeStaged - filter for selecting which staged allowed types to include in the output.
16
17
  *
17
18
  * @remarks
@@ -39,7 +40,7 @@ import type { SchemaCompatibilityStatus } from "./tree.js";
39
40
  * Public API surface uses "persisted" terminology while internally we use "stored".
40
41
  * @alpha
41
42
  */
42
- export declare function extractPersistedSchema(schema: ImplicitFieldSchema, oldestCompatibleClient: FluidClientVersion, includeStaged: (upgrade: SchemaUpgrade) => boolean): JsonCompatible;
43
+ export declare function extractPersistedSchema(schema: ImplicitFieldSchema, minVersionForCollab: MinimumVersionForCollab, includeStaged: (upgrade: SchemaUpgrade) => boolean): JsonCompatible;
43
44
  /**
44
45
  * Compares two schema extracted using {@link extractPersistedSchema}.
45
46
  * Reports the same compatibility that {@link TreeView.compatibility} would report if
@@ -1 +1 @@
1
- {"version":3,"file":"storedSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAQ9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAKnF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,sBAAsB,EAAE,kBAAkB,EAC1C,aAAa,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,GAChD,cAAc,CAIhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,aAAa,GACpB,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAUlD"}
1
+ {"version":3,"file":"storedSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAQ1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAKnF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,mBAAmB,EAAE,uBAAuB,EAC5C,aAAa,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,GAChD,cAAc,CAIhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,aAAa,GACpB,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAUlD"}
@@ -15,7 +15,7 @@ import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
15
15
  * Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.
16
16
  *
17
17
  * @param schema - The schema to dump.
18
- * @param oldestCompatibleClient - The oldest client version which can read the schema: impacts the format used.
18
+ * @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.
19
19
  * @param includeStaged - filter for selecting which staged allowed types to include in the output.
20
20
  *
21
21
  * @remarks
@@ -43,9 +43,9 @@ import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
43
43
  * Public API surface uses "persisted" terminology while internally we use "stored".
44
44
  * @alpha
45
45
  */
46
- export function extractPersistedSchema(schema, oldestCompatibleClient, includeStaged) {
46
+ export function extractPersistedSchema(schema, minVersionForCollab, includeStaged) {
47
47
  const stored = toStoredSchema(schema, { includeStaged });
48
- const schemaWriteVersion = clientVersionToSchemaVersion(oldestCompatibleClient);
48
+ const schemaWriteVersion = clientVersionToSchemaVersion(minVersionForCollab);
49
49
  return encodeTreeSchema(stored, schemaWriteVersion);
50
50
  }
51
51
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,EACN,4BAA4B;AAE5B,sDAAsD;EACtD,MAAM,+CAA+C,CAAC;AAGvD,OAAO,EAAE,oBAAoB,EAA4B,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAA2B,EAC3B,sBAA0C,EAC1C,aAAkD;IAElD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IACzD,MAAM,kBAAkB,GAAG,4BAA4B,CAAC,sBAAsB,CAAC,CAAC;IAChF,OAAO,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,sBAAsB,CACrC,SAAyB,EACzB,IAAyB,EACzB,OAAsB;IAEtB,0DAA0D;IAC1D,2JAA2J;IAC3J,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAqB,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,0BAA0B,CAAC;QAC7C,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC;KAClC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { FluidClientVersion, ICodecOptions } from \"../../codec/index.js\";\nimport { SchemaVersion } from \"../../core/index.js\";\nimport { encodeTreeSchema, makeSchemaCodec } from \"../../feature-libraries/index.js\";\nimport {\n\tclientVersionToSchemaVersion,\n\ttype FormatV1,\n\t// eslint-disable-next-line import/no-internal-modules\n} from \"../../feature-libraries/schema-index/index.js\";\nimport type { JsonCompatible } from \"../../util/index.js\";\nimport type { SchemaUpgrade } from \"../core/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\nimport { TreeViewConfigurationAlpha } from \"./configuration.js\";\n\nimport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Dumps the \"persisted\" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.\n *\n * @param schema - The schema to dump.\n * @param oldestCompatibleClient - The oldest client version which can read the schema: impacts the format used.\n * @param includeStaged - filter for selecting which staged allowed types to include in the output.\n *\n * @remarks\n * This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.\n * This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.\n *\n * This only includes the \"persisted\" subset of schema information, which means the portion which gets included in documents.\n * It thus uses \"persisted\" keys, see {@link FieldProps.key}.\n *\n * If two schema have identical \"persisted\" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.\n *\n * See also {@link comparePersistedSchema}.\n *\n * @example\n * An application could use this API to generate a `schema.json` file when it first releases,\n * then test that the schema is sill compatible with documents from that version with a test like :\n * ```typescript\n * assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require(\"./schema.json\"));\n * ```\n *\n * @privateRemarks\n * This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).\n * This intentionally does not leak the format types in the API.\n *\n * Public API surface uses \"persisted\" terminology while internally we use \"stored\".\n * @alpha\n */\nexport function extractPersistedSchema(\n\tschema: ImplicitFieldSchema,\n\toldestCompatibleClient: FluidClientVersion,\n\tincludeStaged: (upgrade: SchemaUpgrade) => boolean,\n): JsonCompatible {\n\tconst stored = toStoredSchema(schema, { includeStaged });\n\tconst schemaWriteVersion = clientVersionToSchemaVersion(oldestCompatibleClient);\n\treturn encodeTreeSchema(stored, schemaWriteVersion);\n}\n\n/**\n * Compares two schema extracted using {@link extractPersistedSchema}.\n * Reports the same compatibility that {@link TreeView.compatibility} would report if\n * opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.\n *\n * @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.\n * @param view - Schema which would be used to view persisted content.\n * @param options - {@link ICodecOptions} used when parsing the provided schema.\n * @param canInitialize - Passed through to the return value unchanged and otherwise unused.\n * @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.\n *\n * @remarks\n * This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.\n * It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.\n *\n * @example\n * An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,\n * then test that documents using those schema can be upgraded to work with the current schema using a test like:\n * ```typescript\n * assert(\n * \tcomparePersistedSchema(\n * \t\trequire(\"./schema.json\"),\n * \t\tMySchema,\n * \t\t{ jsonValidator: typeboxValidator },\n * \t\tfalse,\n * \t).canUpgrade,\n * );\n * ```\n * @alpha\n */\nexport function comparePersistedSchema(\n\tpersisted: JsonCompatible,\n\tview: ImplicitFieldSchema,\n\toptions: ICodecOptions,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\t// Any version can be passed down to makeSchemaCodec here.\n\t// We only use the decode part, which always dispatches to the correct codec based on the version in the data, not the version passed to `makeSchemaCodec`.\n\tconst schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);\n\tconst stored = schemaCodec.decode(persisted as FormatV1);\n\tconst config = new TreeViewConfigurationAlpha({\n\t\tschema: normalizeFieldSchema(view),\n\t});\n\tconst viewSchema = new SchemaCompatibilityTester(config);\n\treturn viewSchema.checkCompatibility(stored);\n}\n"]}
1
+ {"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,EACN,4BAA4B;AAE5B,sDAAsD;EACtD,MAAM,+CAA+C,CAAC;AAGvD,OAAO,EAAE,oBAAoB,EAA4B,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAA2B,EAC3B,mBAA4C,EAC5C,aAAkD;IAElD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IACzD,MAAM,kBAAkB,GAAG,4BAA4B,CAAC,mBAAmB,CAAC,CAAC;IAC7E,OAAO,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,sBAAsB,CACrC,SAAyB,EACzB,IAAyB,EACzB,OAAsB;IAEtB,0DAA0D;IAC1D,2JAA2J;IAC3J,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAqB,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,0BAA0B,CAAC;QAC7C,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC;KAClC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport type { ICodecOptions } from \"../../codec/index.js\";\nimport { SchemaVersion } from \"../../core/index.js\";\nimport { encodeTreeSchema, makeSchemaCodec } from \"../../feature-libraries/index.js\";\nimport {\n\tclientVersionToSchemaVersion,\n\ttype FormatV1,\n\t// eslint-disable-next-line import/no-internal-modules\n} from \"../../feature-libraries/schema-index/index.js\";\nimport type { JsonCompatible } from \"../../util/index.js\";\nimport type { SchemaUpgrade } from \"../core/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\nimport { TreeViewConfigurationAlpha } from \"./configuration.js\";\n\nimport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Dumps the \"persisted\" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.\n *\n * @param schema - The schema to dump.\n * @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.\n * @param includeStaged - filter for selecting which staged allowed types to include in the output.\n *\n * @remarks\n * This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.\n * This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.\n *\n * This only includes the \"persisted\" subset of schema information, which means the portion which gets included in documents.\n * It thus uses \"persisted\" keys, see {@link FieldProps.key}.\n *\n * If two schema have identical \"persisted\" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.\n *\n * See also {@link comparePersistedSchema}.\n *\n * @example\n * An application could use this API to generate a `schema.json` file when it first releases,\n * then test that the schema is sill compatible with documents from that version with a test like :\n * ```typescript\n * assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require(\"./schema.json\"));\n * ```\n *\n * @privateRemarks\n * This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).\n * This intentionally does not leak the format types in the API.\n *\n * Public API surface uses \"persisted\" terminology while internally we use \"stored\".\n * @alpha\n */\nexport function extractPersistedSchema(\n\tschema: ImplicitFieldSchema,\n\tminVersionForCollab: MinimumVersionForCollab,\n\tincludeStaged: (upgrade: SchemaUpgrade) => boolean,\n): JsonCompatible {\n\tconst stored = toStoredSchema(schema, { includeStaged });\n\tconst schemaWriteVersion = clientVersionToSchemaVersion(minVersionForCollab);\n\treturn encodeTreeSchema(stored, schemaWriteVersion);\n}\n\n/**\n * Compares two schema extracted using {@link extractPersistedSchema}.\n * Reports the same compatibility that {@link TreeView.compatibility} would report if\n * opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.\n *\n * @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.\n * @param view - Schema which would be used to view persisted content.\n * @param options - {@link ICodecOptions} used when parsing the provided schema.\n * @param canInitialize - Passed through to the return value unchanged and otherwise unused.\n * @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.\n *\n * @remarks\n * This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.\n * It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.\n *\n * @example\n * An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,\n * then test that documents using those schema can be upgraded to work with the current schema using a test like:\n * ```typescript\n * assert(\n * \tcomparePersistedSchema(\n * \t\trequire(\"./schema.json\"),\n * \t\tMySchema,\n * \t\t{ jsonValidator: typeboxValidator },\n * \t\tfalse,\n * \t).canUpgrade,\n * );\n * ```\n * @alpha\n */\nexport function comparePersistedSchema(\n\tpersisted: JsonCompatible,\n\tview: ImplicitFieldSchema,\n\toptions: ICodecOptions,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\t// Any version can be passed down to makeSchemaCodec here.\n\t// We only use the decode part, which always dispatches to the correct codec based on the version in the data, not the version passed to `makeSchemaCodec`.\n\tconst schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);\n\tconst stored = schemaCodec.decode(persisted as FormatV1);\n\tconst config = new TreeViewConfigurationAlpha({\n\t\tschema: normalizeFieldSchema(view),\n\t});\n\tconst viewSchema = new SchemaCompatibilityTester(config);\n\treturn viewSchema.checkCompatibility(stored);\n}\n"]}
@@ -21,7 +21,7 @@ export function borrowCursorFromTreeNodeOrValue(node) {
21
21
  return cursorFromVerbose(node, {});
22
22
  }
23
23
  const kernel = getKernel(node);
24
- const cursor = kernel.getOrCreateInnerNode().borrowCursor();
24
+ const cursor = kernel.getInnerNode().borrowCursor();
25
25
  return cursor;
26
26
  }
27
27
  export function importConcise(schema, data) {
@@ -56,7 +56,7 @@ export const TreeBeta = {
56
56
  return node;
57
57
  }
58
58
  const kernel = getKernel(node);
59
- const cursor = kernel.getOrCreateInnerNode().borrowCursor();
59
+ const cursor = kernel.getInnerNode().borrowCursor();
60
60
  // To handle when the node transitively contains unknown optional fields,
61
61
  // derive the context from the source node's stored schema which has stored schema for any such fields and their contents.
62
62
  const flexContext = new UnhydratedContext(defaultSchemaPolicy, kernel.context.flexContext.schema);
@@ -1 +1 @@
1
- {"version":3,"file":"treeBeta.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeBeta.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITreeCursorSynchronous, TreeFieldStoredSchema } from \"../../core/index.js\";\nimport {\n\tdefaultSchemaPolicy,\n\tFieldKinds,\n\tisTreeValue,\n} from \"../../feature-libraries/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\tContext,\n\tgetKernel,\n\tgetOrCreateNodeFromInnerNode,\n\tisTreeNode,\n\tUnhydratedContext,\n\ttype NodeKind,\n\ttype TreeLeafValue,\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype WithType,\n} from \"../core/index.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\nimport type {\n\tImplicitFieldSchema,\n\tInsertableTreeFieldFromImplicitField,\n\tTreeFieldFromImplicitField,\n} from \"../fieldSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype InsertableContent,\n} from \"../unhydratedFlexTreeFromInsertable.js\";\n\nimport { createFromCursor } from \"./create.js\";\nimport { conciseFromCursor, type ConciseTree } from \"./conciseTree.js\";\nimport type { TreeEncodingOptions } from \"./customTree.js\";\nimport { cursorFromVerbose } from \"./verboseTree.js\";\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nimport { treeNodeApi } from \"./treeNodeApi.js\";\nimport type { InsertableField, UnsafeUnknownSchema } from \"../unsafeUnknownSchema.js\";\n\n// Tests for this file are grouped with those for treeNodeApi.ts as that is where this functionality will eventually land,\n// and where most of the actual implementation is for much of it.\n\n/**\n * Data included for {@link TreeChangeEventsBeta.nodeChanged}.\n * @sealed @beta\n */\nexport interface NodeChangedData<TNode extends TreeNode = TreeNode> {\n\t/**\n\t * When the node changed is an object or Map node, this lists all the properties which changed.\n\t * @remarks\n\t * This only includes changes to the node itself (which would trigger {@link TreeChangeEvents.nodeChanged}).\n\t *\n\t * Set to `undefined` when the {@link NodeKind} does not support this feature (currently just ArrayNodes).\n\t *\n\t * When defined, the set should never be empty, since `nodeChanged` will only be triggered when there is a change, and for the supported node types, the only things that can change are properties.\n\t */\n\treadonly changedProperties?: ReadonlySet<\n\t\t// For Object nodes, make changedProperties required and strongly typed with the property names from the schema:\n\t\tTNode extends WithType<string, NodeKind.Object, infer TInfo>\n\t\t\t? string & keyof TInfo\n\t\t\t: string\n\t>;\n}\n\n/**\n * Extensions to {@link TreeChangeEvents} which are not yet stable.\n *\n * @sealed @beta\n */\nexport interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode>\n\textends TreeChangeEvents {\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, if any of the changes affected the node.\n\t *\n\t * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).\n\t *\n\t * - Array nodes define a change as when an element is added, removed, moved or replaced.\n\t *\n\t * - Map nodes define a change as when an entry is added, updated, or removed.\n\t *\n\t * @remarks\n\t * This event is not emitted when:\n\t *\n\t * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing\n\t * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the\n\t * array/map node as one of its properties.\n\t *\n\t * - The node is moved to a different location in the tree or removed from the tree.\n\t * In this case the event is emitted on the _parent_ node, not the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When the event is emitted, the tree is guaranteed to be in-schema.\n\t *\n\t * @privateRemarks\n\t * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.\n\t * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the\n\t * node, or when the node has to be updated due to resolution of a merge conflict\n\t * (for example a previously applied local change might be undone, then reapplied differently or not at all).\n\t *\n\t * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).\n\t *\n\t * This defines a property which is a function instead of using the method syntax to avoid function bi-variance issues with the input data to the callback.\n\t */\n\tnodeChanged: (\n\t\tdata: NodeChangedData<TNode> &\n\t\t\t// Make the properties of object, map, and record nodes required:\n\t\t\t(TNode extends WithType<string, NodeKind.Map | NodeKind.Object | NodeKind.Record>\n\t\t\t\t? Required<Pick<NodeChangedData<TNode>, \"changedProperties\">>\n\t\t\t\t: unknown),\n\t) => void;\n}\n\n/**\n * Extensions to {@link (Tree:interface)} which are not yet stable.\n * @remarks\n * Use via the {@link (TreeBeta:variable)} singleton.\n * @system @sealed @beta\n */\nexport interface TreeBeta {\n\t/**\n\t * Register an event listener on the given node.\n\t * @param node - The node whose events should be subscribed to.\n\t * @param eventName - Which event to subscribe to.\n\t * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.\n\t * @returns A callback function which will deregister the event.\n\t * This callback should be called only once.\n\t */\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void;\n\n\t/**\n\t * A less type-safe version of {@link (TreeAlpha:interface).create}, suitable for importing data.\n\t * @remarks\n\t * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.\n\t * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.\n\t * Use \"compressed\" or \"verbose\" formats for more flexibility.\n\t *\n\t * When using this function,\n\t * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.\n\t * If the schema is ambiguous, consider using {@link (TreeAlpha:interface).create} and {@link Unhydrated} nodes where needed,\n\t * or using {@link (TreeAlpha:interface).(importVerbose:1)} and specify all types.\n\t *\n\t * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,\n\t * but for now most invalid inputs will throw a recoverable error.\n\t */\n\timportConcise<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.\n\t */\n\texportConcise(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): ConciseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}, allowing undefined.\n\t */\n\texportConcise(\n\t\tnode: TreeNode | TreeLeafValue | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): ConciseTree | undefined;\n\n\t/**\n\t * Clones the persisted data associated with a node.\n\t *\n\t * @param node - The node to clone.\n\t * @returns A new unhydrated node with the same persisted data as the original node.\n\t * @remarks\n\t * Some key things to note:\n\t *\n\t * - Local state, such as properties added to customized schema classes, will not be cloned. However, they will be\n\t * initialized to their default state just as if the node had been created via its constructor.\n\t *\n\t * - Value node types (i.e., numbers, strings, booleans, nulls and Fluid handles) will be returned as is.\n\t *\n\t * - The identifiers in the node's subtree will be preserved, i.e., they are not replaced with new values.\n\t *\n\t * - If the node (or any node in its subtree) contains {@link ObjectSchemaOptions.allowUnknownOptionalFields|unknown optional fields},\n\t * those fields will be cloned just like the known fields.\n\t */\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): TreeFieldFromImplicitField<TSchema>;\n\n\t// TODO: support more clone options\n\t// /**\n\t// * Like {@link (TreeBeta:interface).create}, except deeply clones existing nodes.\n\t// * @remarks\n\t// * This only clones the persisted data associated with a node.\n\t// * Local state, such as properties added to customized schema classes, will not be cloned:\n\t// * they will be initialized however they end up after running the constructor, just like if a remote client had inserted the same nodes.\n\t// */\n\t// clone<const TSchema extends ImplicitFieldSchema>(\n\t// \toriginal: TreeFieldFromImplicitField<TSchema>,\n\t// \toptions?: {\n\t// \t\t/**\n\t// \t\t * If set, all identifier's in the cloned tree (See {@link SchemaFactory.identifier}) will be replaced with new ones allocated using the default identifier allocation schema.\n\t// \t\t * Otherwise any identifiers will be preserved as is.\n\t// \t\t */\n\t// \t\treplaceIdentifiers?: true;\n\t// \t},\n\t// ): TreeFieldFromImplicitField<TSchema>;\n\n\t/**\n\t * Construct tree content that is compatible with the field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content.\n\t * @remarks\n\t * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n\t * This function exists as a generalization that can be used in other cases as well,\n\t * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n\t */\n\tcreate<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: InsertableTreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n}\n\n/**\n * Borrow a cursor from a node.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nexport function borrowCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tif (isTreeValue(node)) {\n\t\treturn cursorFromVerbose(node, {});\n\t}\n\tconst kernel = getKernel(node);\n\tconst cursor = kernel.getOrCreateInnerNode().borrowCursor();\n\treturn cursor;\n}\n\n/**\n * {@inheritDoc (TreeBeta:interface).importConcise}\n */\nexport function importConcise<TSchema extends ImplicitFieldSchema>(\n\tschema: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n/**\n * {@inheritDoc (TreeAlpha:interface).importConcise}\n */\nexport function importConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\tschema: UnsafeUnknownSchema extends TSchema\n\t\t? ImplicitFieldSchema\n\t\t: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<\n\tTSchema extends ImplicitFieldSchema\n\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t: TreeNode | TreeLeafValue | undefined\n>;\nexport function importConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\tschema: UnsafeUnknownSchema extends TSchema\n\t\t? ImplicitFieldSchema\n\t\t: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<\n\tTSchema extends ImplicitFieldSchema\n\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t: TreeNode | TreeLeafValue | undefined\n> {\n\t// Create the tree content from insertable data\n\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\tschema,\n\t);\n\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\treturn result as Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n}\n\n/**\n * {@inheritDoc (TreeBeta:interface).(exportConcise:1)}\n */\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue,\n\toptions?: TreeEncodingOptions,\n): ConciseTree;\n/**\n * {@inheritDoc (TreeBeta:interface).(exportConcise:2)}\n */\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined;\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined {\n\tif (!isTreeNode(node)) {\n\t\treturn node;\n\t}\n\tconst config: TreeEncodingOptions = { ...options };\n\n\tconst kernel = getKernel(node);\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\treturn conciseFromCursor(cursor, kernel.context, config);\n}\n\n/**\n * Extensions to {@link (Tree:variable)} which are not yet stable.\n * @see {@link (TreeBeta:interface)}.\n * @beta\n */\nexport const TreeBeta: TreeBeta = {\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void {\n\t\treturn treeNodeApi.on(node, eventName, listener);\n\t},\n\n\timportConcise,\n\texportConcise,\n\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\t// The only non-TreeNode cases are {@link TreeLeafValue} and `undefined` (for an empty optional field) which can be returned as is.\n\t\tif (!isTreeNode(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tconst kernel = getKernel(node);\n\t\tconst cursor = kernel.getOrCreateInnerNode().borrowCursor();\n\n\t\t// To handle when the node transitively contains unknown optional fields,\n\t\t// derive the context from the source node's stored schema which has stored schema for any such fields and their contents.\n\t\tconst flexContext = new UnhydratedContext(\n\t\t\tdefaultSchemaPolicy,\n\t\t\tkernel.context.flexContext.schema,\n\t\t);\n\t\tconst context = new Context(flexContext, getUnhydratedContext(kernel.schema).schema);\n\n\t\tconst fieldSchema: TreeFieldStoredSchema = {\n\t\t\tkind: FieldKinds.required.identifier,\n\t\t\ttypes: new Set([brand(kernel.schema.identifier)]),\n\t\t\tpersistedMetadata: undefined,\n\t\t};\n\t\treturn createFromCursor(kernel.schema, cursor, fieldSchema, context) as Unhydrated<\n\t\t\tTreeFieldFromImplicitField<TSchema>\n\t\t>;\n\t},\n\n\tcreate<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: InsertableTreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\t\tdata as InsertableContent | undefined,\n\t\t\tschema,\n\t\t);\n\t\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\t\treturn result as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t},\n};\n"]}
1
+ {"version":3,"file":"treeBeta.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeBeta.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITreeCursorSynchronous, TreeFieldStoredSchema } from \"../../core/index.js\";\nimport {\n\tdefaultSchemaPolicy,\n\tFieldKinds,\n\tisTreeValue,\n} from \"../../feature-libraries/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\tContext,\n\tgetKernel,\n\tgetOrCreateNodeFromInnerNode,\n\tisTreeNode,\n\tUnhydratedContext,\n\ttype NodeKind,\n\ttype TreeLeafValue,\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype WithType,\n} from \"../core/index.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\nimport type {\n\tImplicitFieldSchema,\n\tInsertableTreeFieldFromImplicitField,\n\tTreeFieldFromImplicitField,\n} from \"../fieldSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype InsertableContent,\n} from \"../unhydratedFlexTreeFromInsertable.js\";\n\nimport { createFromCursor } from \"./create.js\";\nimport { conciseFromCursor, type ConciseTree } from \"./conciseTree.js\";\nimport type { TreeEncodingOptions } from \"./customTree.js\";\nimport { cursorFromVerbose } from \"./verboseTree.js\";\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nimport { treeNodeApi } from \"./treeNodeApi.js\";\nimport type { InsertableField, UnsafeUnknownSchema } from \"../unsafeUnknownSchema.js\";\n\n// Tests for this file are grouped with those for treeNodeApi.ts as that is where this functionality will eventually land,\n// and where most of the actual implementation is for much of it.\n\n/**\n * Data included for {@link TreeChangeEventsBeta.nodeChanged}.\n * @sealed @beta\n */\nexport interface NodeChangedData<TNode extends TreeNode = TreeNode> {\n\t/**\n\t * When the node changed is an object or Map node, this lists all the properties which changed.\n\t * @remarks\n\t * This only includes changes to the node itself (which would trigger {@link TreeChangeEvents.nodeChanged}).\n\t *\n\t * Set to `undefined` when the {@link NodeKind} does not support this feature (currently just ArrayNodes).\n\t *\n\t * When defined, the set should never be empty, since `nodeChanged` will only be triggered when there is a change, and for the supported node types, the only things that can change are properties.\n\t */\n\treadonly changedProperties?: ReadonlySet<\n\t\t// For Object nodes, make changedProperties required and strongly typed with the property names from the schema:\n\t\tTNode extends WithType<string, NodeKind.Object, infer TInfo>\n\t\t\t? string & keyof TInfo\n\t\t\t: string\n\t>;\n}\n\n/**\n * Extensions to {@link TreeChangeEvents} which are not yet stable.\n *\n * @sealed @beta\n */\nexport interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode>\n\textends TreeChangeEvents {\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, if any of the changes affected the node.\n\t *\n\t * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).\n\t *\n\t * - Array nodes define a change as when an element is added, removed, moved or replaced.\n\t *\n\t * - Map nodes define a change as when an entry is added, updated, or removed.\n\t *\n\t * @remarks\n\t * This event is not emitted when:\n\t *\n\t * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing\n\t * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the\n\t * array/map node as one of its properties.\n\t *\n\t * - The node is moved to a different location in the tree or removed from the tree.\n\t * In this case the event is emitted on the _parent_ node, not the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When the event is emitted, the tree is guaranteed to be in-schema.\n\t *\n\t * @privateRemarks\n\t * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.\n\t * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the\n\t * node, or when the node has to be updated due to resolution of a merge conflict\n\t * (for example a previously applied local change might be undone, then reapplied differently or not at all).\n\t *\n\t * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).\n\t *\n\t * This defines a property which is a function instead of using the method syntax to avoid function bi-variance issues with the input data to the callback.\n\t */\n\tnodeChanged: (\n\t\tdata: NodeChangedData<TNode> &\n\t\t\t// Make the properties of object, map, and record nodes required:\n\t\t\t(TNode extends WithType<string, NodeKind.Map | NodeKind.Object | NodeKind.Record>\n\t\t\t\t? Required<Pick<NodeChangedData<TNode>, \"changedProperties\">>\n\t\t\t\t: unknown),\n\t) => void;\n}\n\n/**\n * Extensions to {@link (Tree:interface)} which are not yet stable.\n * @remarks\n * Use via the {@link (TreeBeta:variable)} singleton.\n * @system @sealed @beta\n */\nexport interface TreeBeta {\n\t/**\n\t * Register an event listener on the given node.\n\t * @param node - The node whose events should be subscribed to.\n\t * @param eventName - Which event to subscribe to.\n\t * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.\n\t * @returns A callback function which will deregister the event.\n\t * This callback should be called only once.\n\t */\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void;\n\n\t/**\n\t * A less type-safe version of {@link (TreeAlpha:interface).create}, suitable for importing data.\n\t * @remarks\n\t * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.\n\t * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.\n\t * Use \"compressed\" or \"verbose\" formats for more flexibility.\n\t *\n\t * When using this function,\n\t * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.\n\t * If the schema is ambiguous, consider using {@link (TreeAlpha:interface).create} and {@link Unhydrated} nodes where needed,\n\t * or using {@link (TreeAlpha:interface).(importVerbose:1)} and specify all types.\n\t *\n\t * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,\n\t * but for now most invalid inputs will throw a recoverable error.\n\t */\n\timportConcise<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.\n\t */\n\texportConcise(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): ConciseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}, allowing undefined.\n\t */\n\texportConcise(\n\t\tnode: TreeNode | TreeLeafValue | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): ConciseTree | undefined;\n\n\t/**\n\t * Clones the persisted data associated with a node.\n\t *\n\t * @param node - The node to clone.\n\t * @returns A new unhydrated node with the same persisted data as the original node.\n\t * @remarks\n\t * Some key things to note:\n\t *\n\t * - Local state, such as properties added to customized schema classes, will not be cloned. However, they will be\n\t * initialized to their default state just as if the node had been created via its constructor.\n\t *\n\t * - Value node types (i.e., numbers, strings, booleans, nulls and Fluid handles) will be returned as is.\n\t *\n\t * - The identifiers in the node's subtree will be preserved, i.e., they are not replaced with new values.\n\t *\n\t * - If the node (or any node in its subtree) contains {@link ObjectSchemaOptions.allowUnknownOptionalFields|unknown optional fields},\n\t * those fields will be cloned just like the known fields.\n\t */\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): TreeFieldFromImplicitField<TSchema>;\n\n\t// TODO: support more clone options\n\t// /**\n\t// * Like {@link (TreeBeta:interface).create}, except deeply clones existing nodes.\n\t// * @remarks\n\t// * This only clones the persisted data associated with a node.\n\t// * Local state, such as properties added to customized schema classes, will not be cloned:\n\t// * they will be initialized however they end up after running the constructor, just like if a remote client had inserted the same nodes.\n\t// */\n\t// clone<const TSchema extends ImplicitFieldSchema>(\n\t// \toriginal: TreeFieldFromImplicitField<TSchema>,\n\t// \toptions?: {\n\t// \t\t/**\n\t// \t\t * If set, all identifier's in the cloned tree (See {@link SchemaFactory.identifier}) will be replaced with new ones allocated using the default identifier allocation schema.\n\t// \t\t * Otherwise any identifiers will be preserved as is.\n\t// \t\t */\n\t// \t\treplaceIdentifiers?: true;\n\t// \t},\n\t// ): TreeFieldFromImplicitField<TSchema>;\n\n\t/**\n\t * Construct tree content that is compatible with the field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content.\n\t * @remarks\n\t * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n\t * This function exists as a generalization that can be used in other cases as well,\n\t * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n\t */\n\tcreate<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: InsertableTreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n}\n\n/**\n * Borrow a cursor from a node.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nexport function borrowCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tif (isTreeValue(node)) {\n\t\treturn cursorFromVerbose(node, {});\n\t}\n\tconst kernel = getKernel(node);\n\tconst cursor = kernel.getInnerNode().borrowCursor();\n\treturn cursor;\n}\n\n/**\n * {@inheritDoc (TreeBeta:interface).importConcise}\n */\nexport function importConcise<TSchema extends ImplicitFieldSchema>(\n\tschema: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n/**\n * {@inheritDoc (TreeAlpha:interface).importConcise}\n */\nexport function importConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\tschema: UnsafeUnknownSchema extends TSchema\n\t\t? ImplicitFieldSchema\n\t\t: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<\n\tTSchema extends ImplicitFieldSchema\n\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t: TreeNode | TreeLeafValue | undefined\n>;\nexport function importConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\tschema: UnsafeUnknownSchema extends TSchema\n\t\t? ImplicitFieldSchema\n\t\t: TSchema & ImplicitFieldSchema,\n\tdata: ConciseTree | undefined,\n): Unhydrated<\n\tTSchema extends ImplicitFieldSchema\n\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t: TreeNode | TreeLeafValue | undefined\n> {\n\t// Create the tree content from insertable data\n\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\tschema,\n\t);\n\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\treturn result as Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n}\n\n/**\n * {@inheritDoc (TreeBeta:interface).(exportConcise:1)}\n */\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue,\n\toptions?: TreeEncodingOptions,\n): ConciseTree;\n/**\n * {@inheritDoc (TreeBeta:interface).(exportConcise:2)}\n */\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined;\nexport function exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined {\n\tif (!isTreeNode(node)) {\n\t\treturn node;\n\t}\n\tconst config: TreeEncodingOptions = { ...options };\n\n\tconst kernel = getKernel(node);\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\treturn conciseFromCursor(cursor, kernel.context, config);\n}\n\n/**\n * Extensions to {@link (Tree:variable)} which are not yet stable.\n * @see {@link (TreeBeta:interface)}.\n * @beta\n */\nexport const TreeBeta: TreeBeta = {\n\ton<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\teventName: K,\n\t\tlistener: NoInfer<TreeChangeEventsBeta<TNode>[K]>,\n\t): () => void {\n\t\treturn treeNodeApi.on(node, eventName, listener);\n\t},\n\n\timportConcise,\n\texportConcise,\n\n\tclone<const TSchema extends ImplicitFieldSchema>(\n\t\tnode: TreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\t// The only non-TreeNode cases are {@link TreeLeafValue} and `undefined` (for an empty optional field) which can be returned as is.\n\t\tif (!isTreeNode(node)) {\n\t\t\treturn node;\n\t\t}\n\n\t\tconst kernel = getKernel(node);\n\t\tconst cursor = kernel.getInnerNode().borrowCursor();\n\n\t\t// To handle when the node transitively contains unknown optional fields,\n\t\t// derive the context from the source node's stored schema which has stored schema for any such fields and their contents.\n\t\tconst flexContext = new UnhydratedContext(\n\t\t\tdefaultSchemaPolicy,\n\t\t\tkernel.context.flexContext.schema,\n\t\t);\n\t\tconst context = new Context(flexContext, getUnhydratedContext(kernel.schema).schema);\n\n\t\tconst fieldSchema: TreeFieldStoredSchema = {\n\t\t\tkind: FieldKinds.required.identifier,\n\t\t\ttypes: new Set([brand(kernel.schema.identifier)]),\n\t\t\tpersistedMetadata: undefined,\n\t\t};\n\t\treturn createFromCursor(kernel.schema, cursor, fieldSchema, context) as Unhydrated<\n\t\t\tTreeFieldFromImplicitField<TSchema>\n\t\t>;\n\t},\n\n\tcreate<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: InsertableTreeFieldFromImplicitField<TSchema>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\t\tdata as InsertableContent | undefined,\n\t\t\tschema,\n\t\t);\n\t\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\t\treturn result as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t},\n};\n"]}
@@ -10,7 +10,7 @@ import { FieldSchema } from "../fieldSchema.js";
10
10
  import { booleanSchema, handleSchema, nullSchema, numberSchema, stringSchema, } from "../leafNodeSchema.js";
11
11
  import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
12
12
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
13
- import { getKernel, isTreeNode, NodeKind, tryGetTreeNodeSchema, getOrCreateNodeFromInnerNode, typeSchemaSymbol, getOrCreateInnerNode, normalizeAllowedTypes, } from "../core/index.js";
13
+ import { getKernel, isTreeNode, NodeKind, tryGetTreeNodeSchema, getOrCreateNodeFromInnerNode, typeSchemaSymbol, getInnerNode, normalizeAllowedTypes, } from "../core/index.js";
14
14
  import { isArrayNodeSchema, isObjectNodeSchema } from "../node-kinds/index.js";
15
15
  import { tryGetTreeNodeForField } from "../getTreeNodeForField.js";
16
16
  /**
@@ -18,7 +18,7 @@ import { tryGetTreeNodeForField } from "../getTreeNodeForField.js";
18
18
  */
19
19
  export const treeNodeApi = {
20
20
  parent(node) {
21
- const editNode = getOrCreateInnerNode(node).parentField.parent.parent;
21
+ const editNode = getInnerNode(node).parentField.parent.parent;
22
22
  if (editNode === undefined) {
23
23
  return undefined;
24
24
  }
@@ -124,7 +124,7 @@ export function getIdentifierFromNode(node, compression) {
124
124
  if (!isObjectNodeSchema(schema)) {
125
125
  return undefined;
126
126
  }
127
- const flexNode = getOrCreateInnerNode(node);
127
+ const flexNode = getInnerNode(node);
128
128
  const identifierFieldKeys = schema.identifierFieldKeys;
129
129
  switch (identifierFieldKeys.length) {
130
130
  case 0:
@@ -174,7 +174,7 @@ export function getIdentifierFromNode(node, compression) {
174
174
  export function getStoredKey(node) {
175
175
  // Note: the flex domain strictly works with "stored keys", and knows nothing about the developer-facing
176
176
  // "property keys".
177
- const parentField = getOrCreateInnerNode(node).parentField;
177
+ const parentField = getInnerNode(node).parentField;
178
178
  if (parentField.parent.schema === FieldKinds.sequence.identifier) {
179
179
  // The parent of `node` is an array node
180
180
  assert(parentField.parent.key === EmptyKey, 0xa28 /* When using index as key, field should use EmptyKey */);