@fluidframework/tree 2.52.0 → 2.53.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 (488) hide show
  1. package/.eslintrc.cjs +14 -2
  2. package/CHANGELOG.md +125 -0
  3. package/api-report/tree.alpha.api.md +48 -41
  4. package/dist/alpha.d.ts +2 -1
  5. package/dist/core/tree/visitDelta.d.ts +1 -1
  6. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  7. package/dist/core/tree/visitDelta.js.map +1 -1
  8. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -0
  9. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  10. package/dist/feature-libraries/chunked-forest/index.js +3 -1
  11. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  12. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +2 -4
  13. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  14. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
  15. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  16. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  17. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
  18. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  19. package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts +1 -1
  20. package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
  21. package/dist/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
  22. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +4 -0
  23. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  24. package/dist/feature-libraries/forest-summary/forestSummarizer.js +5 -5
  25. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  26. package/dist/feature-libraries/index.d.ts +1 -1
  27. package/dist/feature-libraries/index.d.ts.map +1 -1
  28. package/dist/feature-libraries/index.js +4 -2
  29. package/dist/feature-libraries/index.js.map +1 -1
  30. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
  31. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  32. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
  33. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  34. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  35. package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -0
  36. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  37. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +1 -0
  38. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  39. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  40. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  41. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +49 -20
  42. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  43. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  44. package/dist/feature-libraries/optional-field/optionalField.js +3 -0
  45. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  46. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
  47. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  48. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
  49. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  50. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +1 -1
  51. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  52. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  53. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +1 -1
  54. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  55. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  56. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +1 -1
  57. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  58. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  59. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +1 -1
  60. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  61. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  62. package/dist/feature-libraries/sequence-field/types.d.ts +1 -1
  63. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  64. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  65. package/dist/index.d.ts +1 -1
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +3 -2
  68. package/dist/index.js.map +1 -1
  69. package/dist/jsonDomainSchema.d.ts +5 -3
  70. package/dist/jsonDomainSchema.d.ts.map +1 -1
  71. package/dist/jsonDomainSchema.js.map +1 -1
  72. package/dist/packageVersion.d.ts +1 -1
  73. package/dist/packageVersion.js +1 -1
  74. package/dist/packageVersion.js.map +1 -1
  75. package/dist/shared-tree/independentView.d.ts.map +1 -1
  76. package/dist/shared-tree/independentView.js +1 -1
  77. package/dist/shared-tree/independentView.js.map +1 -1
  78. package/dist/shared-tree/index.d.ts +0 -1
  79. package/dist/shared-tree/index.d.ts.map +1 -1
  80. package/dist/shared-tree/index.js.map +1 -1
  81. package/dist/shared-tree/schematizeTree.d.ts +23 -60
  82. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  83. package/dist/shared-tree/schematizeTree.js +59 -151
  84. package/dist/shared-tree/schematizeTree.js.map +1 -1
  85. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  86. package/dist/shared-tree/schematizingTreeView.js +11 -11
  87. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  88. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  89. package/dist/shared-tree/treeAlpha.js +9 -3
  90. package/dist/shared-tree/treeAlpha.js.map +1 -1
  91. package/dist/shared-tree-core/defaultResubmitMachine.d.ts +2 -1
  92. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  93. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  94. package/dist/simple-tree/api/configuration.d.ts +3 -0
  95. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  96. package/dist/simple-tree/api/configuration.js +5 -1
  97. package/dist/simple-tree/api/configuration.js.map +1 -1
  98. package/dist/simple-tree/api/create.d.ts +4 -4
  99. package/dist/simple-tree/api/create.d.ts.map +1 -1
  100. package/dist/simple-tree/api/create.js +3 -6
  101. package/dist/simple-tree/api/create.js.map +1 -1
  102. package/dist/simple-tree/api/discrepancies.d.ts +5 -9
  103. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
  104. package/dist/simple-tree/api/discrepancies.js +11 -10
  105. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  106. package/dist/simple-tree/api/index.d.ts +3 -2
  107. package/dist/simple-tree/api/index.d.ts.map +1 -1
  108. package/dist/simple-tree/api/index.js +3 -2
  109. package/dist/simple-tree/api/index.js.map +1 -1
  110. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  111. package/dist/simple-tree/api/schemaCompatibilityTester.js +3 -4
  112. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  113. package/dist/simple-tree/api/schemaFactory.d.ts +9 -155
  114. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  115. package/dist/simple-tree/api/schemaFactory.js +4 -47
  116. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  117. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
  118. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  119. package/dist/simple-tree/api/schemaFactoryAlpha.js +33 -11
  120. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  121. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
  122. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  123. package/dist/simple-tree/api/schemaFactoryRecursive.js +1 -7
  124. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  125. package/dist/simple-tree/api/schemaStatics.d.ts +158 -0
  126. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -0
  127. package/dist/simple-tree/api/schemaStatics.js +59 -0
  128. package/dist/simple-tree/api/schemaStatics.js.map +1 -0
  129. package/dist/simple-tree/api/storedSchema.d.ts +5 -3
  130. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  131. package/dist/simple-tree/api/storedSchema.js +4 -2
  132. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  133. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  134. package/dist/simple-tree/api/treeBeta.js +12 -6
  135. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  136. package/dist/simple-tree/core/allowedTypes.d.ts +46 -30
  137. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  138. package/dist/simple-tree/core/allowedTypes.js +20 -12
  139. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  140. package/dist/simple-tree/core/index.d.ts +5 -3
  141. package/dist/simple-tree/core/index.d.ts.map +1 -1
  142. package/dist/simple-tree/core/index.js +6 -1
  143. package/dist/simple-tree/core/index.js.map +1 -1
  144. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
  145. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
  146. package/dist/simple-tree/core/simpleNodeSchemaBase.js +7 -0
  147. package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
  148. package/dist/simple-tree/core/toStored.d.ts +32 -0
  149. package/dist/simple-tree/core/toStored.d.ts.map +1 -0
  150. package/dist/simple-tree/core/toStored.js +37 -0
  151. package/dist/simple-tree/core/toStored.js.map +1 -0
  152. package/dist/simple-tree/core/treeNode.d.ts +0 -3
  153. package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
  154. package/dist/simple-tree/core/treeNode.js +3 -3
  155. package/dist/simple-tree/core/treeNode.js.map +1 -1
  156. package/dist/simple-tree/core/treeNodeSchema.d.ts +7 -2
  157. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  158. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  159. package/dist/simple-tree/core/treeNodeValid.d.ts +6 -1
  160. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  161. package/dist/simple-tree/core/treeNodeValid.js +11 -6
  162. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  163. package/dist/simple-tree/core/walkSchema.d.ts +19 -5
  164. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  165. package/dist/simple-tree/core/walkSchema.js +4 -2
  166. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  167. package/dist/simple-tree/createContext.d.ts.map +1 -1
  168. package/dist/simple-tree/createContext.js +1 -1
  169. package/dist/simple-tree/createContext.js.map +1 -1
  170. package/dist/simple-tree/fieldSchema.d.ts +2 -1
  171. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  172. package/dist/simple-tree/fieldSchema.js +1 -1
  173. package/dist/simple-tree/fieldSchema.js.map +1 -1
  174. package/dist/simple-tree/index.d.ts +4 -4
  175. package/dist/simple-tree/index.d.ts.map +1 -1
  176. package/dist/simple-tree/index.js +9 -2
  177. package/dist/simple-tree/index.js.map +1 -1
  178. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  179. package/dist/simple-tree/leafNodeSchema.js +1 -0
  180. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  181. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  182. package/dist/simple-tree/node-kinds/array/arrayNode.js +18 -4
  183. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  184. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  185. package/dist/simple-tree/node-kinds/map/mapNode.js +9 -2
  186. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  187. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +2 -2
  188. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  189. package/dist/simple-tree/node-kinds/object/objectNode.js +37 -26
  190. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  191. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  192. package/dist/simple-tree/node-kinds/record/recordNode.js +9 -2
  193. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  194. package/dist/simple-tree/prepareForInsertion.d.ts +5 -5
  195. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  196. package/dist/simple-tree/prepareForInsertion.js +10 -10
  197. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  198. package/dist/simple-tree/simpleSchema.d.ts +6 -21
  199. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  200. package/dist/simple-tree/simpleSchema.js.map +1 -1
  201. package/dist/simple-tree/toStoredSchema.d.ts +35 -11
  202. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  203. package/dist/simple-tree/toStoredSchema.js +68 -33
  204. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  205. package/dist/tableSchema.d.ts +25 -32
  206. package/dist/tableSchema.d.ts.map +1 -1
  207. package/dist/tableSchema.js +10 -24
  208. package/dist/tableSchema.js.map +1 -1
  209. package/docs/.attachments/cell-ordering/C-knows-of-ABC.png +0 -0
  210. package/docs/.attachments/cell-ordering/C-knows-of-C.png +0 -0
  211. package/docs/.attachments/cell-ordering/XvsA.png +0 -0
  212. package/docs/.attachments/cell-ordering/compose-a-b.png +0 -0
  213. package/docs/.attachments/cell-ordering/compose-a-ref-p1-b-ref-p2.png +0 -0
  214. package/docs/.attachments/cell-ordering/compose-b-no-ref-to-ca.png +0 -0
  215. package/docs/.attachments/cell-ordering/rebase-ab-over-x.png +0 -0
  216. package/docs/.attachments/cell-ordering/rebase-b-over-x.png +0 -0
  217. package/docs/.attachments/cell-ordering/rebase-b2-over-x.png +0 -0
  218. package/docs/.attachments/cell-ordering/rebase-b2.png +0 -0
  219. package/docs/.attachments/cell-ordering/rebase-to-abprime.png +0 -0
  220. package/docs/.attachments/cell-ordering/rebase-to-bprime.png +0 -0
  221. package/docs/main/cell-ordering.md +638 -0
  222. package/lib/alpha.d.ts +2 -1
  223. package/lib/core/tree/visitDelta.d.ts +1 -1
  224. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  225. package/lib/core/tree/visitDelta.js.map +1 -1
  226. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -0
  227. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  228. package/lib/feature-libraries/chunked-forest/index.js +1 -0
  229. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  230. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +2 -4
  231. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  232. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +4 -1
  233. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  234. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  235. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
  236. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  237. package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts +1 -1
  238. package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
  239. package/lib/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
  240. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +4 -0
  241. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  242. package/lib/feature-libraries/forest-summary/forestSummarizer.js +1 -1
  243. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  244. package/lib/feature-libraries/index.d.ts +1 -1
  245. package/lib/feature-libraries/index.d.ts.map +1 -1
  246. package/lib/feature-libraries/index.js +1 -1
  247. package/lib/feature-libraries/index.js.map +1 -1
  248. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
  249. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  250. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
  251. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  252. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  253. package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -0
  254. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  255. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +1 -0
  256. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  257. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  258. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  259. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +50 -21
  260. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  261. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  262. package/lib/feature-libraries/optional-field/optionalField.js +3 -0
  263. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  264. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
  265. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  266. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
  267. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  268. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +1 -1
  269. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  270. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
  271. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  272. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +1 -1
  273. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  274. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
  275. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  276. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +1 -1
  277. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  278. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +1 -1
  279. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  280. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +1 -1
  281. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  282. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  283. package/lib/feature-libraries/sequence-field/types.d.ts +1 -1
  284. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  285. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  286. package/lib/index.d.ts +1 -1
  287. package/lib/index.d.ts.map +1 -1
  288. package/lib/index.js +1 -1
  289. package/lib/index.js.map +1 -1
  290. package/lib/jsonDomainSchema.d.ts +5 -3
  291. package/lib/jsonDomainSchema.d.ts.map +1 -1
  292. package/lib/jsonDomainSchema.js.map +1 -1
  293. package/lib/packageVersion.d.ts +1 -1
  294. package/lib/packageVersion.js +1 -1
  295. package/lib/packageVersion.js.map +1 -1
  296. package/lib/shared-tree/independentView.d.ts.map +1 -1
  297. package/lib/shared-tree/independentView.js +2 -2
  298. package/lib/shared-tree/independentView.js.map +1 -1
  299. package/lib/shared-tree/index.d.ts +0 -1
  300. package/lib/shared-tree/index.d.ts.map +1 -1
  301. package/lib/shared-tree/index.js.map +1 -1
  302. package/lib/shared-tree/schematizeTree.d.ts +23 -60
  303. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  304. package/lib/shared-tree/schematizeTree.js +60 -150
  305. package/lib/shared-tree/schematizeTree.js.map +1 -1
  306. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  307. package/lib/shared-tree/schematizingTreeView.js +14 -14
  308. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  309. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  310. package/lib/shared-tree/treeAlpha.js +10 -4
  311. package/lib/shared-tree/treeAlpha.js.map +1 -1
  312. package/lib/shared-tree-core/defaultResubmitMachine.d.ts +2 -1
  313. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  314. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  315. package/lib/simple-tree/api/configuration.d.ts +3 -0
  316. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  317. package/lib/simple-tree/api/configuration.js +6 -2
  318. package/lib/simple-tree/api/configuration.js.map +1 -1
  319. package/lib/simple-tree/api/create.d.ts +4 -4
  320. package/lib/simple-tree/api/create.d.ts.map +1 -1
  321. package/lib/simple-tree/api/create.js +3 -6
  322. package/lib/simple-tree/api/create.js.map +1 -1
  323. package/lib/simple-tree/api/discrepancies.d.ts +5 -9
  324. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
  325. package/lib/simple-tree/api/discrepancies.js +11 -10
  326. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  327. package/lib/simple-tree/api/index.d.ts +3 -2
  328. package/lib/simple-tree/api/index.d.ts.map +1 -1
  329. package/lib/simple-tree/api/index.js +2 -1
  330. package/lib/simple-tree/api/index.js.map +1 -1
  331. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  332. package/lib/simple-tree/api/schemaCompatibilityTester.js +4 -5
  333. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  334. package/lib/simple-tree/api/schemaFactory.d.ts +9 -155
  335. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  336. package/lib/simple-tree/api/schemaFactory.js +2 -45
  337. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  338. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
  339. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  340. package/lib/simple-tree/api/schemaFactoryAlpha.js +23 -1
  341. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  342. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
  343. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  344. package/lib/simple-tree/api/schemaFactoryRecursive.js +0 -5
  345. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  346. package/lib/simple-tree/api/schemaStatics.d.ts +158 -0
  347. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -0
  348. package/lib/simple-tree/api/schemaStatics.js +56 -0
  349. package/lib/simple-tree/api/schemaStatics.js.map +1 -0
  350. package/lib/simple-tree/api/storedSchema.d.ts +5 -3
  351. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  352. package/lib/simple-tree/api/storedSchema.js +6 -4
  353. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  354. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  355. package/lib/simple-tree/api/treeBeta.js +8 -2
  356. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  357. package/lib/simple-tree/core/allowedTypes.d.ts +46 -30
  358. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  359. package/lib/simple-tree/core/allowedTypes.js +23 -12
  360. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  361. package/lib/simple-tree/core/index.d.ts +5 -3
  362. package/lib/simple-tree/core/index.d.ts.map +1 -1
  363. package/lib/simple-tree/core/index.js +3 -2
  364. package/lib/simple-tree/core/index.js.map +1 -1
  365. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
  366. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
  367. package/lib/simple-tree/core/simpleNodeSchemaBase.js +6 -0
  368. package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
  369. package/lib/simple-tree/core/toStored.d.ts +32 -0
  370. package/lib/simple-tree/core/toStored.d.ts.map +1 -0
  371. package/lib/simple-tree/core/toStored.js +32 -0
  372. package/lib/simple-tree/core/toStored.js.map +1 -0
  373. package/lib/simple-tree/core/treeNode.d.ts +0 -3
  374. package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
  375. package/lib/simple-tree/core/treeNode.js +3 -3
  376. package/lib/simple-tree/core/treeNode.js.map +1 -1
  377. package/lib/simple-tree/core/treeNodeSchema.d.ts +7 -2
  378. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  379. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  380. package/lib/simple-tree/core/treeNodeValid.d.ts +6 -1
  381. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  382. package/lib/simple-tree/core/treeNodeValid.js +9 -5
  383. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  384. package/lib/simple-tree/core/walkSchema.d.ts +19 -5
  385. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  386. package/lib/simple-tree/core/walkSchema.js +4 -2
  387. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  388. package/lib/simple-tree/createContext.d.ts.map +1 -1
  389. package/lib/simple-tree/createContext.js +2 -2
  390. package/lib/simple-tree/createContext.js.map +1 -1
  391. package/lib/simple-tree/fieldSchema.d.ts +2 -1
  392. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  393. package/lib/simple-tree/fieldSchema.js +1 -1
  394. package/lib/simple-tree/fieldSchema.js.map +1 -1
  395. package/lib/simple-tree/index.d.ts +4 -4
  396. package/lib/simple-tree/index.d.ts.map +1 -1
  397. package/lib/simple-tree/index.js +2 -2
  398. package/lib/simple-tree/index.js.map +1 -1
  399. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  400. package/lib/simple-tree/leafNodeSchema.js +2 -1
  401. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  402. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  403. package/lib/simple-tree/node-kinds/array/arrayNode.js +21 -7
  404. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  405. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  406. package/lib/simple-tree/node-kinds/map/mapNode.js +12 -5
  407. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  408. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +2 -2
  409. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  410. package/lib/simple-tree/node-kinds/object/objectNode.js +16 -5
  411. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  412. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  413. package/lib/simple-tree/node-kinds/record/recordNode.js +12 -5
  414. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  415. package/lib/simple-tree/prepareForInsertion.d.ts +5 -5
  416. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  417. package/lib/simple-tree/prepareForInsertion.js +10 -10
  418. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  419. package/lib/simple-tree/simpleSchema.d.ts +6 -21
  420. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  421. package/lib/simple-tree/simpleSchema.js.map +1 -1
  422. package/lib/simple-tree/toStoredSchema.d.ts +35 -11
  423. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  424. package/lib/simple-tree/toStoredSchema.js +67 -34
  425. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  426. package/lib/tableSchema.d.ts +25 -32
  427. package/lib/tableSchema.d.ts.map +1 -1
  428. package/lib/tableSchema.js +11 -25
  429. package/lib/tableSchema.js.map +1 -1
  430. package/package.json +21 -21
  431. package/src/core/tree/visitDelta.ts +3 -1
  432. package/src/feature-libraries/chunked-forest/index.ts +1 -0
  433. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +12 -5
  434. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -0
  435. package/src/feature-libraries/default-schema/noChangeCodecs.ts +1 -1
  436. package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -1
  437. package/src/feature-libraries/index.ts +2 -0
  438. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +9 -0
  439. package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -0
  440. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +1 -0
  441. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +61 -19
  442. package/src/feature-libraries/optional-field/optionalField.ts +4 -0
  443. package/src/feature-libraries/sequence-field/sequenceFieldChangeRebaser.ts +4 -0
  444. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +4 -2
  445. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +4 -2
  446. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +4 -2
  447. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +1 -1
  448. package/src/feature-libraries/sequence-field/types.ts +1 -1
  449. package/src/index.ts +2 -1
  450. package/src/jsonDomainSchema.ts +4 -0
  451. package/src/packageVersion.ts +1 -1
  452. package/src/shared-tree/independentView.ts +6 -2
  453. package/src/shared-tree/index.ts +0 -2
  454. package/src/shared-tree/schematizeTree.ts +83 -199
  455. package/src/shared-tree/schematizingTreeView.ts +26 -12
  456. package/src/shared-tree/treeAlpha.ts +18 -4
  457. package/src/shared-tree-core/defaultResubmitMachine.ts +2 -1
  458. package/src/simple-tree/api/configuration.ts +10 -2
  459. package/src/simple-tree/api/create.ts +5 -10
  460. package/src/simple-tree/api/discrepancies.ts +18 -17
  461. package/src/simple-tree/api/index.ts +2 -3
  462. package/src/simple-tree/api/schemaCompatibilityTester.ts +5 -9
  463. package/src/simple-tree/api/schemaFactory.ts +6 -250
  464. package/src/simple-tree/api/schemaFactoryAlpha.ts +174 -1
  465. package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -25
  466. package/src/simple-tree/api/schemaStatics.ts +291 -0
  467. package/src/simple-tree/api/storedSchema.ts +12 -5
  468. package/src/simple-tree/api/treeBeta.ts +9 -2
  469. package/src/simple-tree/core/allowedTypes.ts +71 -42
  470. package/src/simple-tree/core/index.ts +9 -1
  471. package/src/simple-tree/core/simpleNodeSchemaBase.ts +30 -0
  472. package/src/simple-tree/core/toStored.ts +58 -0
  473. package/src/simple-tree/core/treeNode.ts +3 -3
  474. package/src/simple-tree/core/treeNodeSchema.ts +8 -2
  475. package/src/simple-tree/core/treeNodeValid.ts +14 -5
  476. package/src/simple-tree/core/walkSchema.ts +23 -6
  477. package/src/simple-tree/createContext.ts +5 -2
  478. package/src/simple-tree/fieldSchema.ts +4 -2
  479. package/src/simple-tree/index.ts +15 -6
  480. package/src/simple-tree/leafNodeSchema.ts +2 -1
  481. package/src/simple-tree/node-kinds/array/arrayNode.ts +58 -37
  482. package/src/simple-tree/node-kinds/map/mapNode.ts +26 -2
  483. package/src/simple-tree/node-kinds/object/objectNode.ts +37 -4
  484. package/src/simple-tree/node-kinds/record/recordNode.ts +23 -2
  485. package/src/simple-tree/prepareForInsertion.ts +12 -7
  486. package/src/simple-tree/simpleSchema.ts +6 -26
  487. package/src/simple-tree/toStoredSchema.ts +107 -44
  488. package/src/tableSchema.ts +40 -35
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaStatics.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaStatics.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,sDAAqF;AASrF,4DAM8B;AA2I9B,MAAM,uBAAuB,GAAoB,IAAA,mCAAkB,EAAC,GAAG,EAAE,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AAC;AAEX,SAAS,uBAAuB,CAK/B,IAAU,EACV,YAAmB,EACnB,KAAmC;IAEnC,kJAAkJ;IAClJ,OAAO,IAAA,kCAAiB,EACvB,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 {\n\tImplicitAllowedTypes,\n\tImplicitAnnotatedAllowedTypes,\n\tUnannotateImplicitAllowedTypes,\n} 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// The following overloads for optional and required are used to get around the fact that\n// the compiler can't infer that UnannotateImplicitAllowedTypes<T> is equal to T when T is known to extend ImplicitAllowedTypes\n\n// #region Overloads for optional and required\nfunction optional<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\tt: T,\n\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n): FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata>;\n\nfunction optional<\n\tconst T extends ImplicitAnnotatedAllowedTypes,\n\tconst TCustomMetadata = unknown,\n>(\n\tt: T,\n\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n): FieldSchemaAlpha<FieldKind.Optional, UnannotateImplicitAllowedTypes<T>, TCustomMetadata>;\n\nfunction optional<\n\tconst T extends ImplicitAnnotatedAllowedTypes,\n\tconst TCustomMetadata = unknown,\n>(\n\tt: T,\n\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n): FieldSchemaAlpha<FieldKind.Optional, UnannotateImplicitAllowedTypes<T>, TCustomMetadata> {\n\treturn createFieldSchema(FieldKind.Optional, t, {\n\t\tdefaultProvider: defaultOptionalProvider,\n\t\t...props,\n\t});\n}\n\nfunction required<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\tt: T,\n\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n): FieldSchemaAlpha<FieldKind.Required, T, TCustomMetadata>;\n\nfunction required<\n\tconst T extends ImplicitAnnotatedAllowedTypes,\n\tconst TCustomMetadata = unknown,\n>(\n\tt: T,\n\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n): FieldSchemaAlpha<FieldKind.Required, UnannotateImplicitAllowedTypes<T>, TCustomMetadata>;\n\nfunction required<\n\tconst T extends ImplicitAnnotatedAllowedTypes,\n\tconst TCustomMetadata = unknown,\n>(\n\tt: T,\n\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\">,\n): FieldSchemaAlpha<FieldKind.Required, UnannotateImplicitAllowedTypes<T>, TCustomMetadata> {\n\treturn createFieldSchema(FieldKind.Required, t, props);\n}\n// #endregion\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,\n\n\trequired,\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"]}
@@ -4,13 +4,15 @@
4
4
  */
5
5
  import type { FluidClientVersion, ICodecOptions } from "../../codec/index.js";
6
6
  import type { JsonCompatible } from "../../util/index.js";
7
- import { type ImplicitFieldSchema } from "../fieldSchema.js";
8
- import type { SimpleTreeSchema } from "../simpleSchema.js";
7
+ import type { SchemaUpgrade } from "../core/index.js";
8
+ import { type ImplicitAnnotatedFieldSchema, type ImplicitFieldSchema } from "../fieldSchema.js";
9
9
  import type { SchemaCompatibilityStatus } from "./tree.js";
10
10
  /**
11
11
  * Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.
12
12
  *
13
13
  * @param schema - The schema to dump.
14
+ * @param oldestCompatibleClient - The oldest client version which can read the schema: impacts the format used.
15
+ * @param includeStaged - filter for selecting which staged allowed types to include in the output.
14
16
  *
15
17
  * @remarks
16
18
  * 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.
@@ -37,7 +39,7 @@ import type { SchemaCompatibilityStatus } from "./tree.js";
37
39
  * Public API surface uses "persisted" terminology while internally we use "stored".
38
40
  * @alpha
39
41
  */
40
- export declare function extractPersistedSchema(schema: SimpleTreeSchema, oldestCompatibleClient: FluidClientVersion): JsonCompatible;
42
+ export declare function extractPersistedSchema(schema: ImplicitAnnotatedFieldSchema, oldestCompatibleClient: FluidClientVersion, includeStaged: (upgrade: SchemaUpgrade) => boolean): JsonCompatible;
41
43
  /**
42
44
  * Compares two schema extracted using {@link extractPersistedSchema}.
43
45
  * 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,EAAwB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK3D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,gBAAgB,EACxB,sBAAsB,EAAE,kBAAkB,GACxC,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,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,EAEN,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACxB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,4BAA4B,EACpC,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"}
@@ -16,6 +16,8 @@ const schemaCompatibilityTester_js_1 = require("./schemaCompatibilityTester.js")
16
16
  * Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.
17
17
  *
18
18
  * @param schema - The schema to dump.
19
+ * @param oldestCompatibleClient - The oldest client version which can read the schema: impacts the format used.
20
+ * @param includeStaged - filter for selecting which staged allowed types to include in the output.
19
21
  *
20
22
  * @remarks
21
23
  * 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.
@@ -42,8 +44,8 @@ const schemaCompatibilityTester_js_1 = require("./schemaCompatibilityTester.js")
42
44
  * Public API surface uses "persisted" terminology while internally we use "stored".
43
45
  * @alpha
44
46
  */
45
- function extractPersistedSchema(schema, oldestCompatibleClient) {
46
- const stored = (0, toStoredSchema_js_1.simpleToStoredSchema)(schema);
47
+ function extractPersistedSchema(schema, oldestCompatibleClient, includeStaged) {
48
+ const stored = (0, toStoredSchema_js_1.toStoredSchema)(schema, { includeStaged });
47
49
  const schemaWriteVersion = (0, index_js_3.clientVersionToSchemaVersion)(oldestCompatibleClient);
48
50
  return (0, index_js_2.encodeTreeSchema)(stored, schemaWriteVersion);
49
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kDAAoD;AACpD,+DAAqF;AACrF,4EAIuD;AAEvD,sDAAmF;AAEnF,4DAA4D;AAC5D,yDAAgE;AAEhE,iFAA2E;AAG3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,sBAAsB,CACrC,MAAwB,EACxB,sBAA0C;IAE1C,MAAM,MAAM,GAAG,IAAA,wCAAoB,EAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,kBAAkB,GAAG,IAAA,uCAA4B,EAAC,sBAAsB,CAAC,CAAC;IAChF,OAAO,IAAA,2BAAgB,EAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AACrD,CAAC;AAPD,wDAOC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,sBAAsB,CACrC,SAAyB,EACzB,IAAyB,EACzB,OAAsB;IAEtB,0DAA0D;IAC1D,2JAA2J;IAC3J,MAAM,WAAW,GAAG,IAAA,0BAAe,EAAC,OAAO,EAAE,wBAAa,CAAC,EAAE,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAqB,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,6CAA0B,CAAC;QAC7C,MAAM,EAAE,IAAA,qCAAoB,EAAC,IAAI,CAAC;KAClC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,wDAAyB,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAdD,wDAcC","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 { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport type { SimpleTreeSchema } from \"../simpleSchema.js\";\nimport { simpleToStoredSchema } 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 *\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: SimpleTreeSchema,\n\toldestCompatibleClient: FluidClientVersion,\n): JsonCompatible {\n\tconst stored = simpleToStoredSchema(schema);\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;;;AAGH,kDAAoD;AACpD,+DAAqF;AACrF,4EAIuD;AAGvD,sDAI2B;AAC3B,4DAAsD;AACtD,yDAAgE;AAEhE,iFAA2E;AAG3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,sBAAsB,CACrC,MAAoC,EACpC,sBAA0C,EAC1C,aAAkD;IAElD,MAAM,MAAM,GAAG,IAAA,kCAAc,EAAC,MAAM,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IACzD,MAAM,kBAAkB,GAAG,IAAA,uCAA4B,EAAC,sBAAsB,CAAC,CAAC;IAChF,OAAO,IAAA,2BAAgB,EAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AACrD,CAAC;AARD,wDAQC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,sBAAsB,CACrC,SAAyB,EACzB,IAAyB,EACzB,OAAsB;IAEtB,0DAA0D;IAC1D,2JAA2J;IAC3J,MAAM,WAAW,GAAG,IAAA,0BAAe,EAAC,OAAO,EAAE,wBAAa,CAAC,EAAE,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAqB,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,6CAA0B,CAAC;QAC7C,MAAM,EAAE,IAAA,qCAAoB,EAAC,IAAI,CAAC;KAClC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,wDAAyB,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAdD,wDAcC","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 {\n\tnormalizeFieldSchema,\n\ttype ImplicitAnnotatedFieldSchema,\n\ttype ImplicitFieldSchema,\n} 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: ImplicitAnnotatedFieldSchema,\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 +1 @@
1
- {"version":3,"file":"treeBeta.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/treeBeta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAKN,KAAK,QAAQ,EACb,KAAK,QAAQ,EAEb,KAAK,QAAQ,EACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAGzF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAM9D;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,KAAK,SAAS,QAAQ,GAAG,QAAQ;IACjE;;;;;;;;OAQG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,WAAW,CAEvC,KAAK,SAAS,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,GACzD,MAAM,GAAG,MAAM,KAAK,GACpB,MAAM,CACT,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB,CAAC,KAAK,SAAS,QAAQ,GAAG,QAAQ,CACtE,SAAQ,gBAAgB;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,WAAW,EAAE,CACZ,IAAI,EAAE,eAAe,CA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: true });
7
7
  exports.TreeBeta = void 0;
8
8
  const index_js_1 = require("../../feature-libraries/index.js");
9
- const index_js_2 = require("../core/index.js");
9
+ const index_js_2 = require("../../util/index.js");
10
+ const index_js_3 = require("../core/index.js");
10
11
  const createContext_js_1 = require("../createContext.js");
11
12
  const create_js_1 = require("./create.js");
12
13
  const treeNodeApi_js_1 = require("./treeNodeApi.js");
@@ -21,16 +22,21 @@ exports.TreeBeta = {
21
22
  },
22
23
  clone(node) {
23
24
  // The only non-TreeNode cases are {@link TreeLeafValue} and `undefined` (for an empty optional field) which can be returned as is.
24
- if (!(0, index_js_2.isTreeNode)(node)) {
25
+ if (!(0, index_js_3.isTreeNode)(node)) {
25
26
  return node;
26
27
  }
27
- const kernel = (0, index_js_2.getKernel)(node);
28
+ const kernel = (0, index_js_3.getKernel)(node);
28
29
  const cursor = kernel.getOrCreateInnerNode().borrowCursor();
29
30
  // To handle when the node transitively contains unknown optional fields,
30
31
  // derive the context from the source node's stored schema which has stored schema for any such fields and their contents.
31
- const flexContext = new index_js_2.UnhydratedContext(index_js_1.defaultSchemaPolicy, kernel.context.flexContext.schema);
32
- const context = new index_js_2.Context(flexContext, (0, createContext_js_1.getUnhydratedContext)(kernel.schema).schema);
33
- return (0, create_js_1.createFromCursor)(kernel.schema, cursor, context);
32
+ const flexContext = new index_js_3.UnhydratedContext(index_js_1.defaultSchemaPolicy, kernel.context.flexContext.schema);
33
+ const context = new index_js_3.Context(flexContext, (0, createContext_js_1.getUnhydratedContext)(kernel.schema).schema);
34
+ const fieldSchema = {
35
+ kind: index_js_1.FieldKinds.required.identifier,
36
+ types: new Set([(0, index_js_2.brand)(kernel.schema.identifier)]),
37
+ persistedMetadata: undefined,
38
+ };
39
+ return (0, create_js_1.createFromCursor)(kernel.schema, cursor, fieldSchema, context);
34
40
  },
35
41
  };
36
42
  //# sourceMappingURL=treeBeta.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeBeta.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeBeta.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAuE;AACvE,+CAS0B;AAC1B,0DAA2D;AAG3D,2CAA+C;AAE/C,qDAA+C;AA4I/C;;;;GAIG;AACU,QAAA,QAAQ,GAAa;IACjC,EAAE,CACD,IAAW,EACX,SAAY,EACZ,QAAiD;QAEjD,OAAO,4BAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IACD,KAAK,CACJ,IAAyC;QAEzC,mIAAmI;QACnI,IAAI,CAAC,IAAA,qBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,MAAM,GAAG,IAAA,oBAAS,EAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC,YAAY,EAAE,CAAC;QAE5D,yEAAyE;QACzE,0HAA0H;QAC1H,MAAM,WAAW,GAAG,IAAI,4BAAiB,CACxC,8BAAmB,EACnB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CACjC,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,kBAAO,CAAC,WAAW,EAAE,IAAA,uCAAoB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;QAErF,OAAO,IAAA,4BAAgB,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAErD,CAAC;IACH,CAAC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { defaultSchemaPolicy } from \"../../feature-libraries/index.js\";\nimport {\n\tContext,\n\tgetKernel,\n\tisTreeNode,\n\tUnhydratedContext,\n\ttype NodeKind,\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype WithType,\n} from \"../core/index.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\nimport type { ImplicitFieldSchema, TreeFieldFromImplicitField } from \"../fieldSchema.js\";\n\nimport { createFromCursor } from \"./create.js\";\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nimport { treeNodeApi } from \"./treeNodeApi.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 * 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 SchemaFactoryObjectOptions.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\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\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\treturn createFromCursor(kernel.schema, cursor, context) as Unhydrated<\n\t\t\tTreeFieldFromImplicitField<TSchema>\n\t\t>;\n\t},\n};\n"]}
1
+ {"version":3,"file":"treeBeta.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeBeta.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAmF;AACnF,kDAA4C;AAC5C,+CAS0B;AAC1B,0DAA2D;AAG3D,2CAA+C;AAE/C,qDAA+C;AA4I/C;;;;GAIG;AACU,QAAA,QAAQ,GAAa;IACjC,EAAE,CACD,IAAW,EACX,SAAY,EACZ,QAAiD;QAEjD,OAAO,4BAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IACD,KAAK,CACJ,IAAyC;QAEzC,mIAAmI;QACnI,IAAI,CAAC,IAAA,qBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,MAAM,GAAG,IAAA,oBAAS,EAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC,YAAY,EAAE,CAAC;QAE5D,yEAAyE;QACzE,0HAA0H;QAC1H,MAAM,WAAW,GAAG,IAAI,4BAAiB,CACxC,8BAAmB,EACnB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CACjC,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,kBAAO,CAAC,WAAW,EAAE,IAAA,uCAAoB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;QAErF,MAAM,WAAW,GAA0B;YAC1C,IAAI,EAAE,qBAAU,CAAC,QAAQ,CAAC,UAAU;YACpC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,IAAA,gBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;YACjD,iBAAiB,EAAE,SAAS;SAC5B,CAAC;QACF,OAAO,IAAA,4BAAgB,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAElE,CAAC;IACH,CAAC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeFieldStoredSchema } from \"../../core/index.js\";\nimport { defaultSchemaPolicy, FieldKinds } from \"../../feature-libraries/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\tContext,\n\tgetKernel,\n\tisTreeNode,\n\tUnhydratedContext,\n\ttype NodeKind,\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype WithType,\n} from \"../core/index.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\nimport type { ImplicitFieldSchema, TreeFieldFromImplicitField } from \"../fieldSchema.js\";\n\nimport { createFromCursor } from \"./create.js\";\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nimport { treeNodeApi } from \"./treeNodeApi.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 * 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 SchemaFactoryObjectOptions.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\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\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"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IsUnion } from "../../util/index.js";
5
+ import { type IsUnion, type MakeNominal } from "../../util/index.js";
6
6
  import { type FlexListToUnion, type LazyItem } from "./flexList.js";
7
7
  import { type InsertableTypedNode, type NodeFromSchema, type TreeNodeSchema } from "./treeNodeSchema.js";
8
8
  /**
@@ -31,7 +31,10 @@ import { type InsertableTypedNode, type NodeFromSchema, type TreeNodeSchema } fr
31
31
  export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
32
32
  /**
33
33
  * Stores annotations for an individual allowed type.
34
+ * @remarks
35
+ * Create using APIs on {@link SchemaFactoryAlpha}, like {@link SchemaStaticsAlpha.staged}.
34
36
  * @alpha
37
+ * @sealed
35
38
  */
36
39
  export interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {
37
40
  /**
@@ -44,18 +47,11 @@ export interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {
44
47
  readonly type: T;
45
48
  }
46
49
  /**
47
- * Stores annotations for a set of evaluated annotated allowed types.
50
+ * {@link AnnotatedAllowedTypes} but with the lazy schema references eagerly evaluated.
51
+ * @sealed
48
52
  * @alpha
49
53
  */
50
- export interface NormalizedAnnotatedAllowedTypes {
51
- /**
52
- * Annotations that apply to a set of allowed types.
53
- */
54
- readonly metadata: AllowedTypesMetadata;
55
- /**
56
- * All the evaluated allowed types that the annotations apply to. The types themselves are also individually annotated.
57
- */
58
- readonly types: readonly AnnotatedAllowedType<TreeNodeSchema>[];
54
+ export interface NormalizedAnnotatedAllowedTypes extends AnnotatedAllowedTypes<TreeNodeSchema> {
59
55
  }
60
56
  /**
61
57
  * Checks if the input is an {@link AnnotatedAllowedTypes}.
@@ -64,8 +60,9 @@ export declare function isAnnotatedAllowedTypes(allowedTypes: ImplicitAnnotatedA
64
60
  /**
65
61
  * Stores annotations for a set of allowed types.
66
62
  * @alpha
63
+ * @sealed
67
64
  */
68
- export interface AnnotatedAllowedTypes {
65
+ export interface AnnotatedAllowedTypes<T = LazyItem<TreeNodeSchema>> {
69
66
  /**
70
67
  * Annotations that apply to a set of allowed types.
71
68
  */
@@ -73,13 +70,14 @@ export interface AnnotatedAllowedTypes {
73
70
  /**
74
71
  * All the allowed types that the annotations apply to. The types themselves may also have individual annotations.
75
72
  */
76
- readonly types: readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];
73
+ readonly types: readonly AnnotatedAllowedType<T>[];
77
74
  }
78
75
  /**
79
76
  * Annotations that apply to a set of allowed types.
80
77
  * @remarks
81
78
  * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.
82
79
  * @alpha
80
+ * @input
83
81
  */
84
82
  export interface AllowedTypesMetadata {
85
83
  /**
@@ -96,12 +94,35 @@ export declare function isAnnotatedAllowedType(allowedType: AnnotatedAllowedType
96
94
  * @remarks
97
95
  * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.
98
96
  * @alpha
97
+ * @input
99
98
  */
100
99
  export interface AllowedTypeMetadata {
101
100
  /**
102
101
  * User defined metadata
103
102
  */
104
103
  readonly custom?: unknown;
104
+ /**
105
+ * If defined, indicates that an allowed type is {@link SchemaStaticsAlpha.staged | staged}.
106
+ */
107
+ readonly stagedSchemaUpgrade?: SchemaUpgrade;
108
+ }
109
+ /**
110
+ * Package internal {@link SchemaUpgrade} construction API.
111
+ */
112
+ export declare let createSchemaUpgrade: () => SchemaUpgrade;
113
+ /**
114
+ * Unique token used to upgrade schemas and determine if a particular upgrade has been completed.
115
+ * @remarks
116
+ * Create using {@link SchemaStaticsAlpha.staged}.
117
+ * @privateRemarks
118
+ * TODO:#38722 implement runtime schema upgrades.
119
+ * Until then, the class purely behaves mostly as a placeholder.
120
+ * TODO: Consider allowing users to store a name for the upgrade to use in error messages.
121
+ * @sealed @alpha
122
+ */
123
+ export declare class SchemaUpgrade {
124
+ protected _typeCheck: MakeNominal;
125
+ private constructor();
105
126
  }
106
127
  /**
107
128
  * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree.
@@ -141,25 +162,21 @@ export type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;
141
162
  * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree with
142
163
  * additional metadata associated with the location they're allowed at.
143
164
  * @alpha
165
+ * @input
144
166
  */
145
167
  export type ImplicitAnnotatedAllowedTypes = TreeNodeSchema | AnnotatedAllowedType | AnnotatedAllowedTypes | readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];
146
168
  /**
147
169
  * Returns an {@link ImplicitAllowedTypes} that is equivalent to the input without annotations.
148
170
  * @system @alpha
149
171
  */
150
- export type UnannotateImplicitAllowedTypes<T extends ImplicitAnnotatedAllowedTypes> = T extends AnnotatedAllowedTypes ? UnannotateAllowedTypes<T> : T extends AnnotatedAllowedType ? UnannotateAllowedType<T> : T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[] ? UnannotateAllowedTypesList<T> : T extends TreeNodeSchema ? T : never;
172
+ export type UnannotateImplicitAllowedTypes<T extends ImplicitAnnotatedAllowedTypes> = T extends AnnotatedAllowedTypes ? UnannotateAllowedTypes<T> : T extends AnnotatedAllowedType ? UnannotateAllowedTypesList<[T]> : T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[] ? UnannotateAllowedTypesList<T> : T extends TreeNodeSchema ? T : ImplicitAllowedTypes;
151
173
  /**
152
174
  * Removes annotations from a list of allowed types that may contain annotations.
153
175
  * @system @alpha
154
176
  */
155
177
  export type UnannotateAllowedTypesList<T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]> = {
156
- [I in keyof T]: UnannotateAllowedTypeOrLazyItem<T[I]>;
178
+ [I in keyof T]: UnannotateAllowedType<T[I]>;
157
179
  };
158
- /**
159
- * Removes annotations from an allowed type that may contain annotations.
160
- * @system @alpha
161
- */
162
- export type UnannotateAllowedTypeOrLazyItem<T extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>> = T extends AnnotatedAllowedType<infer X> ? X : T;
163
180
  /**
164
181
  * Removes all annotations from a set of allowed types.
165
182
  * @system @alpha
@@ -167,9 +184,14 @@ export type UnannotateAllowedTypeOrLazyItem<T extends AnnotatedAllowedType | Laz
167
184
  export type UnannotateAllowedTypes<T extends AnnotatedAllowedTypes> = UnannotateAllowedTypesList<T["types"]>;
168
185
  /**
169
186
  * Removes annotations from an allowed type.
187
+ * @remarks
188
+ * If the input could be lazy
189
+ * (is a LazyItem or AnnotatedAllowedType<LazyItem> instead of just a TreeNodeSchema | AnnotatedAllowedType<TreeNodeSchema>)
190
+ * then the output of this will be a LazyItem and thus is not valid as an ImplicitAllowedTypes without wrapping it in an array.
191
+ * This can however be used on items within an AllowedTypes array.
170
192
  * @system @alpha
171
193
  */
172
- export type UnannotateAllowedType<T extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>> = T extends AnnotatedAllowedType<infer X> ? [X] : T;
194
+ export type UnannotateAllowedType<T extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>> = T extends AnnotatedAllowedType<infer X> ? X : T;
173
195
  /**
174
196
  * Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any
175
197
  * lazy schema declarations.
@@ -181,15 +203,9 @@ export type UnannotateAllowedType<T extends AnnotatedAllowedType | LazyItem<Tree
181
203
  */
182
204
  export declare function normalizeAllowedTypes(types: ImplicitAnnotatedAllowedTypes): ReadonlySet<TreeNodeSchema>;
183
205
  /**
184
- * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist
185
- * and eagerly evaluating any lazy schema declarations.
186
- *
187
- * @remarks
188
- * Note: this must only be called after all required schemas have been declared, otherwise evaluation of
189
- * recursive schemas may fail.
190
- * type is frozen and should not be modified after being passed in.
206
+ * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist.
191
207
  */
192
- export declare function normalizeToAnnotatedAllowedType<T extends TreeNodeSchema>(type: T | AnnotatedAllowedType<T> | AnnotatedAllowedType<LazyItem<T>>): AnnotatedAllowedType<T>;
208
+ export declare function normalizeToAnnotatedAllowedType<T extends LazyItem<TreeNodeSchema>>(type: T | AnnotatedAllowedType<T>): AnnotatedAllowedType<T>;
193
209
  /**
194
210
  * Normalizes a {@link ImplicitAnnotatedAllowedTypes} to a set of {@link AnnotatedAllowedSchema}s, by eagerly evaluating any
195
211
  * lazy schema declarations and adding empty metadata if it doesn't already exist.
@@ -221,7 +237,7 @@ export declare function evaluateLazySchema<T extends TreeNodeSchema>(value: Lazy
221
237
  /**
222
238
  * Throws a UsageError if the provided schema is undefined, most likely due to being used before it was initialized.
223
239
  */
224
- export declare function checkForUninitializedSchema(schema: ImplicitAnnotatedAllowedTypes | LazyItem<TreeNodeSchema>): void;
240
+ export declare function checkForUninitializedSchema(schema: ImplicitAnnotatedAllowedTypes | LazyItem<TreeNodeSchema> | AnnotatedAllowedType): void;
225
241
  /**
226
242
  * Indicates that the provided schema is the "most derived" version in its class hierarchy.
227
243
  *
@@ -1 +1 @@
1
- {"version":3,"file":"allowedTypes.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/allowedTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAgC,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAU,KAAK,eA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vB,OAAO,SAAS,YAAY,GAC3B,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,GACxC,OAAO,CAAC;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,0CAA0C,CAAC,OAAO,SAAS,oBAAoB,IAC1F;IAAC,OAAO;CAAC,SAAS,CAAC,cAAc,CAAC,GAC/B,mBAAmB,CAAC,OAAO,CAAC,GAC5B,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,GAC/B,kCAAkC,CAAC,OAAO,CAAC,GAC3C,KAAK,CAAC;AAEX;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kCAAkC,CAAC,KAAK,SAAS,YAAY,IACxE,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,GACxB,KAAK,GACL;IACA,QAAQ,EAAE,QAAQ,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,QAAQ,CACnE,MAAM,OAAO,SAAS,cAAc,CACpC,GACE,mBAAmB,CAAC,OAAO,CAAC,GAC5B,KAAK;CACR,CAAC,MAAM,CAAC,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.markSchemaMostDerived = exports.checkForUninitializedSchema = exports.evaluateLazySchema = exports.unannotateAllowedType = exports.unannotateImplicitAllowedTypes = exports.normalizeAnnotatedAllowedTypes = exports.normalizeToAnnotatedAllowedType = exports.normalizeAllowedTypes = exports.isAnnotatedAllowedType = exports.isAnnotatedAllowedTypes = void 0;
7
+ exports.markSchemaMostDerived = exports.checkForUninitializedSchema = exports.evaluateLazySchema = exports.unannotateAllowedType = exports.unannotateImplicitAllowedTypes = exports.normalizeAnnotatedAllowedTypes = exports.normalizeToAnnotatedAllowedType = exports.normalizeAllowedTypes = exports.SchemaUpgrade = exports.createSchemaUpgrade = exports.isAnnotatedAllowedType = exports.isAnnotatedAllowedTypes = void 0;
8
8
  const internal_1 = require("@fluidframework/telemetry-utils/internal");
9
9
  const index_js_1 = require("../../util/index.js");
10
10
  const flexList_js_1 = require("./flexList.js");
@@ -29,6 +29,23 @@ function isAnnotatedAllowedType(allowedType) {
29
29
  return typeof allowedType === "object" && "metadata" in allowedType && "type" in allowedType;
30
30
  }
31
31
  exports.isAnnotatedAllowedType = isAnnotatedAllowedType;
32
+ /**
33
+ * Unique token used to upgrade schemas and determine if a particular upgrade has been completed.
34
+ * @remarks
35
+ * Create using {@link SchemaStaticsAlpha.staged}.
36
+ * @privateRemarks
37
+ * TODO:#38722 implement runtime schema upgrades.
38
+ * Until then, the class purely behaves mostly as a placeholder.
39
+ * TODO: Consider allowing users to store a name for the upgrade to use in error messages.
40
+ * @sealed @alpha
41
+ */
42
+ class SchemaUpgrade {
43
+ constructor() { }
44
+ }
45
+ exports.SchemaUpgrade = SchemaUpgrade;
46
+ (() => {
47
+ exports.createSchemaUpgrade = () => new SchemaUpgrade();
48
+ })();
32
49
  /**
33
50
  * Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any
34
51
  * lazy schema declarations.
@@ -56,20 +73,11 @@ function normalizeAllowedTypes(types) {
56
73
  }
57
74
  exports.normalizeAllowedTypes = normalizeAllowedTypes;
58
75
  /**
59
- * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist
60
- * and eagerly evaluating any lazy schema declarations.
61
- *
62
- * @remarks
63
- * Note: this must only be called after all required schemas have been declared, otherwise evaluation of
64
- * recursive schemas may fail.
65
- * type is frozen and should not be modified after being passed in.
76
+ * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist.
66
77
  */
67
78
  function normalizeToAnnotatedAllowedType(type) {
68
79
  return isAnnotatedAllowedType(type)
69
- ? {
70
- metadata: type.metadata,
71
- type: evaluateLazySchema(type.type),
72
- }
80
+ ? type
73
81
  : {
74
82
  metadata: {},
75
83
  type,
@@ -1 +1 @@
1
- {"version":3,"file":"allowedTypes.js","sourceRoot":"","sources":["../../../src/simple-tree/core/allowedTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uEAAsE;AAEtE,kDAAiF;AACjF,+CAA4E;AAC5E,2DAK6B;AAC7B,yDAA2D;AAyD3D;;GAEG;AACH,SAAgB,uBAAuB,CACtC,YAA2C;IAE3C,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAC1C,OAAO;IACN,qJAAqJ;IACrJ,OAAO,YAAY,KAAK,QAAQ,IAAI,UAAU,IAAI,YAAY,IAAI,OAAO,IAAI,YAAY,CACzF,CAAC;AACH,CAAC;AARD,0DAQC;AA8BD;;GAEG;AACH,SAAgB,sBAAsB,CACrC,WAA4D;IAE5D,2BAA2B,CAAC,WAAW,CAAC,CAAC;IACzC,qJAAqJ;IACrJ,OAAO,OAAO,WAAW,KAAK,QAAQ,IAAI,UAAU,IAAI,WAAW,IAAI,MAAM,IAAI,WAAW,CAAC;AAC9F,CAAC;AAND,wDAMC;AA8GD;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACpC,KAAoC;IAEpC,wCAAwC;IACxC,MAAM,WAAW,GAAG,8BAA8B,CAAC,KAAK,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,IAAI,IAAA,0BAAe,EAAC,WAAW,CAAC,EAAE,CAAC;QAClC,yJAAyJ;QACzJ,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC3B,KAAK,MAAM,QAAQ,IAAI,WAAW,EAAE,CAAC;YACpC,UAAU,CAAC,GAAG,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;SAAM,CAAC;QACP,UAAU,CAAC,GA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c,EAAE,KAAK,EAAE,KAAK,CAAO;QAClD,CAAC,CAAC,KAAK,CAAC;IAET,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAC7C,qBAAqB,CAAC,eAAe,CAAC,CAAC;IACvC,OAAO,eAAe,CAAC;AACxB,CAAC;AARD,gDAQC;AAED;;GAEG;AACH,SAAgB,2BAA2B,CAC1C,MAAgE;IAEhE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,qBAAU,CACnB,6PAA6P,CAC7P,CAAC;IACH,CAAC;AACF,CAAC;AARD,kEAQC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,qBAAqB,CACpC,MAAsB,EACtB,iBAAiB,GAAG,KAAK;IAEzB,kFAAkF;IAClF,IAAI,MAAM,CAAC,IAAI,KAAK,4BAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO;IACR,CAAC;IAED,MAAM,WAAW,GAAG,IAAA,wCAAqB,EAAC,MAAM,CAAC,CAAC;IAElD,IAAI,iBAAiB,EAAE,CAAC;QACvB,WAAW,CAAC,iBAAiB,EAAE,CAAC;IACjC,CAAC;SAAM,CAAC;QACP,WAAW,CAAC,eAAe,EAAE,CAAC;IAC/B,CAAC;AACF,CAAC;AAhBD,sDAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { getOrCreate, isReadonlyArray, type IsUnion } from \"../../util/index.js\";\nimport { isLazy, type FlexListToUnion, type LazyItem } from \"./flexList.js\";\nimport {\n\tNodeKind,\n\ttype InsertableTypedNode,\n\ttype NodeFromSchema,\n\ttype TreeNodeSchema,\n} from \"./treeNodeSchema.js\";\nimport { schemaAsTreeNodeValid } from \"./treeNodeValid.js\";\n\n/**\n * Schema for types allowed in some location in a tree (like a field, map entry or array).\n * @remarks\n * Type constraint used in schema declaration APIs.\n *\n * The order of types in the array is not significant.\n * Additionally, it is legal for users of this type to have the runtime and compile time order of items within this array not match.\n * Therefor to ensure type safety, these arrays should not be indexed, and instead just be iterated.\n *\n * Ideally this restriction would be modeled in the type itself, but it is not ergonomic to do so as there is no easy (when compared to arrays)\n * way to declare and manipulate unordered sets of types in TypeScript.\n *\n * Duplicate entries in this array are not allowed and will produce runtime errors.\n * Duplicate types are allowed,\n * but this must only be reflected in the type and not the runtime values.\n * This duplication can be used to encode the typing when the number of items in the array is not known at compile time\n * but some of the items are known to be present unconditionally.\n * For example, typing `[typeof A] | [typeof A, typeof B]` as `[typeof A, typeof B | typeof A]` is allowed,\n * and can produce more useful {@link Input} types.\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @system @public\n */\nexport type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];\n\n/**\n * Stores annotations for an individual allowed type.\n * @alpha\n */\nexport interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {\n\t/**\n\t * Annotations for the allowed type.\n\t */\n\treadonly metadata: AllowedTypeMetadata;\n\t/**\n\t * The allowed type the annotations apply to in a particular schema.\n\t */\n\treadonly type: T;\n}\n\n/**\n * Stores annotations for a set of evaluated annotated allowed types.\n * @alpha\n */\nexport interface NormalizedAnnotatedAllowedTypes {\n\t/**\n\t * Annotations that apply to a set of allowed types.\n\t */\n\treadonly metadata: AllowedTypesMetadata;\n\t/**\n\t * All the evaluated allowed types that the annotations apply to. The types themselves are also individually annotated.\n\t */\n\treadonly types: readonly AnnotatedAllowedType<TreeNodeSchema>[];\n}\n\n/**\n * Checks if the input is an {@link AnnotatedAllowedTypes}.\n */\nexport function isAnnotatedAllowedTypes(\n\tallowedTypes: ImplicitAnnotatedAllowedTypes,\n): allowedTypes is AnnotatedAllowedTypes {\n\tcheckForUninitializedSchema(allowedTypes);\n\treturn (\n\t\t// Class based schema, and lazy schema references report type \"function\": filtering them out with typeof makes narrowing based on members mostly safe\n\t\ttypeof allowedTypes === \"object\" && \"metadata\" in allowedTypes && \"types\" in allowedTypes\n\t);\n}\n\n/**\n * Stores annotations for a set of allowed types.\n * @alpha\n */\nexport interface AnnotatedAllowedTypes {\n\t/**\n\t * Annotations that apply to a set of allowed types.\n\t */\n\treadonly metadata: AllowedTypesMetadata;\n\t/**\n\t * All the allowed types that the annotations apply to. The types themselves may also have individual annotations.\n\t */\n\treadonly types: readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];\n}\n\n/**\n * Annotations that apply to a set of allowed types.\n * @remarks\n * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.\n * @alpha\n */\nexport interface AllowedTypesMetadata {\n\t/**\n\t * User defined metadata\n\t */\n\treadonly custom?: unknown;\n}\n\n/**\n * Checks if the given allowed type is annotated with {@link AllowedTypeMetadata}.\n */\nexport function isAnnotatedAllowedType(\n\tallowedType: AnnotatedAllowedType | LazyItem<TreeNodeSchema>,\n): allowedType is AnnotatedAllowedType {\n\tcheckForUninitializedSchema(allowedType);\n\t// Class based schema, and lazy schema references report type \"function\": filtering them out with typeof makes narrowing based on members mostly safe\n\treturn typeof allowedType === \"object\" && \"metadata\" in allowedType && \"type\" in allowedType;\n}\n\n/**\n * Annotations that apply to an individual allowed type.\n * @remarks\n * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.\n * @alpha\n */\nexport interface AllowedTypeMetadata {\n\t/**\n\t * User defined metadata\n\t */\n\treadonly custom?: unknown;\n\n\t// TODO metadata for enablable types will be added here\n}\n\n/**\n * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree.\n * @remarks\n * Used by {@link TreeViewConfiguration} for the root and various kinds of {@link TreeNodeSchema} to specify their allowed child types.\n *\n * Use {@link SchemaFactory} to access leaf schema or declare new composite schema.\n *\n * Implicitly treats a single type as an array of one type.\n *\n * Arrays of schema can be used to specify multiple types are allowed, which result in unions of those types in the Tree APIs.\n *\n * When saved into variables, avoid type-erasing the details, as doing so loses the compile time schema awareness of APIs derived from the types.\n *\n * When referring to types that are declared after the definition of the `ImplicitAllowedTypes`, the schema can be wrapped in a lambda to allow the forward reference.\n * See {@link ValidateRecursiveSchema} for details on how to structure the `ImplicitAllowedTypes` instances when constructing recursive schema.\n *\n * @example Explicit use with strong typing\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * const childTypes = [sf.number, sf.string] as const satisfies ImplicitAllowedTypes;\n * const config = new TreeViewConfiguration({ schema: childTypes });\n * ```\n *\n * @example Forward reference\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * class A extends sf.array(\"example\", [() => B]) {}\n * class B extends sf.array(\"Inner\", sf.number) {}\n * ```\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @public\n */\nexport type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;\n\n/**\n * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree with\n * additional metadata associated with the location they're allowed at.\n * @alpha\n */\nexport type ImplicitAnnotatedAllowedTypes =\n\t| TreeNodeSchema\n\t| AnnotatedAllowedType\n\t| AnnotatedAllowedTypes\n\t| readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];\n\n/**\n * Returns an {@link ImplicitAllowedTypes} that is equivalent to the input without annotations.\n * @system @alpha\n */\nexport type UnannotateImplicitAllowedTypes<T extends ImplicitAnnotatedAllowedTypes> =\n\tT extends AnnotatedAllowedTypes\n\t\t? UnannotateAllowedTypes<T>\n\t\t: T extends AnnotatedAllowedType\n\t\t\t? UnannotateAllowedType<T>\n\t\t\t: T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]\n\t\t\t\t? UnannotateAllowedTypesList<T>\n\t\t\t\t: T extends TreeNodeSchema\n\t\t\t\t\t? T\n\t\t\t\t\t: never;\n\n/**\n * Removes annotations from a list of allowed types that may contain annotations.\n * @system @alpha\n */\nexport type UnannotateAllowedTypesList<\n\tT extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[],\n> = {\n\t[I in keyof T]: UnannotateAllowedTypeOrLazyItem<T[I]>;\n};\n\n/**\n * Removes annotations from an allowed type that may contain annotations.\n * @system @alpha\n */\nexport type UnannotateAllowedTypeOrLazyItem<\n\tT extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>,\n> = T extends AnnotatedAllowedType<infer X> ? X : T;\n\n/**\n * Removes all annotations from a set of allowed types.\n * @system @alpha\n */\nexport type UnannotateAllowedTypes<T extends AnnotatedAllowedTypes> =\n\tUnannotateAllowedTypesList<T[\"types\"]>;\n\n/**\n * Removes annotations from an allowed type.\n * @system @alpha\n */\nexport type UnannotateAllowedType<T extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>> =\n\tT extends AnnotatedAllowedType<infer X> ? [X] : T;\n\n/**\n * Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any\n * lazy schema declarations.\n *\n * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of\n * recursive schemas may fail.\n *\n * @internal\n */\nexport function normalizeAllowedTypes(\n\ttypes: ImplicitAnnotatedAllowedTypes,\n): ReadonlySet<TreeNodeSchema> {\n\t// remove annotations before normalizing\n\tconst unannotated = unannotateImplicitAllowedTypes(types);\n\tconst normalized = new Set<TreeNodeSchema>();\n\tif (isReadonlyArray(unannotated)) {\n\t\t// Types array must not be modified after it is normalized since that would result in the user of the normalized data having wrong (out of date) content.\n\t\tObject.freeze(unannotated);\n\t\tfor (const lazyType of unannotated) {\n\t\t\tnormalized.add(evaluateLazySchema(lazyType));\n\t\t}\n\t} else {\n\t\tnormalized.add(evaluateLazySchema(unannotated));\n\t}\n\treturn normalized;\n}\n\n/**\n * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist\n * and eagerly evaluating any lazy schema declarations.\n *\n * @remarks\n * Note: this must only be called after all required schemas have been declared, otherwise evaluation of\n * recursive schemas may fail.\n * type is frozen and should not be modified after being passed in.\n */\nexport function normalizeToAnnotatedAllowedType<T extends TreeNodeSchema>(\n\ttype: T | AnnotatedAllowedType<T> | AnnotatedAllowedType<LazyItem<T>>,\n): AnnotatedAllowedType<T> {\n\treturn isAnnotatedAllowedType(type)\n\t\t? {\n\t\t\t\tmetadata: type.metadata,\n\t\t\t\ttype: evaluateLazySchema(type.type),\n\t\t\t}\n\t\t: {\n\t\t\t\tmetadata: {},\n\t\t\t\ttype,\n\t\t\t};\n}\n\n/**\n * Normalizes a {@link ImplicitAnnotatedAllowedTypes} to a set of {@link AnnotatedAllowedSchema}s, by eagerly evaluating any\n * lazy schema declarations and adding empty metadata if it doesn't already exist.\n *\n * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of\n * recursive schemas may fail.\n */\nexport function normalizeAnnotatedAllowedTypes(\n\ttypes: ImplicitAnnotatedAllowedTypes,\n): NormalizedAnnotatedAllowedTypes {\n\tconst typesWithoutAnnotation = isAnnotatedAllowedTypes(types) ? types.types : types;\n\tconst annotatedTypes: AnnotatedAllowedType<TreeNodeSchema>[] = [];\n\tif (isReadonlyArray(typesWithoutAnnotation)) {\n\t\tfor (const annotatedType of typesWithoutAnnotation) {\n\t\t\tif (isAnnotatedAllowedType(annotatedType)) {\n\t\t\t\tannotatedTypes.push({\n\t\t\t\t\ttype: evaluateLazySchema(annotatedType.type),\n\t\t\t\t\tmetadata: annotatedType.metadata,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tannotatedTypes.push({ type: evaluateLazySchema(annotatedType), metadata: {} });\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (isAnnotatedAllowedType(typesWithoutAnnotation)) {\n\t\t\tannotatedTypes.push({\n\t\t\t\ttype: evaluateLazySchema(typesWithoutAnnotation.type),\n\t\t\t\tmetadata: typesWithoutAnnotation.metadata,\n\t\t\t});\n\t\t} else {\n\t\t\tannotatedTypes.push({ type: evaluateLazySchema(typesWithoutAnnotation), metadata: {} });\n\t\t}\n\t}\n\n\treturn {\n\t\tmetadata: isAnnotatedAllowedTypes(types) ? types.metadata : {},\n\t\ttypes: annotatedTypes,\n\t};\n}\n\n/**\n * Converts an {@link ImplicitAnnotatedAllowedTypes} to an {@link ImplicitAllowedTypes}s, by removing\n * any annotations.\n * @remarks\n * This does not evaluate any lazy schemas.\n */\nexport function unannotateImplicitAllowedTypes<Types extends ImplicitAnnotatedAllowedTypes>(\n\ttypes: Types,\n): UnannotateImplicitAllowedTypes<Types> {\n\treturn (\n\t\tisAnnotatedAllowedTypes(types)\n\t\t\t? types.types.map(unannotateAllowedType)\n\t\t\t: isReadonlyArray(types)\n\t\t\t\t? types.map(unannotateAllowedType)\n\t\t\t\t: isAnnotatedAllowedType(types)\n\t\t\t\t\t? types.type\n\t\t\t\t\t: types\n\t) as UnannotateImplicitAllowedTypes<Types>;\n}\n\n/**\n * Converts an {@link AnnotatedAllowedType} to an {@link LazyItem} by removing any annotations.\n * @remarks\n * This does not evaluate any lazy schemas.\n */\nexport function unannotateAllowedType<\n\tType extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>,\n>(allowedType: Type): UnannotateAllowedType<Type> {\n\treturn isAnnotatedAllowedType(allowedType)\n\t\t? (allowedType.type as UnannotateAllowedType<Type>)\n\t\t: (allowedType as UnannotateAllowedType<Type>);\n}\n\nconst cachedLazyItem = new WeakMap<() => unknown, unknown>();\n\n/**\n * Returns the schema referenced by the {@link LazyItem}.\n * @remarks\n * Caches results to handle {@link LazyItem}s which compute their resulting schema.\n * @alpha\n */\nexport function evaluateLazySchema<T extends TreeNodeSchema>(value: LazyItem<T>): T {\n\tconst evaluatedSchema = isLazy(value)\n\t\t? (getOrCreate(cachedLazyItem, value, value) as T)\n\t\t: value;\n\n\tcheckForUninitializedSchema(evaluatedSchema);\n\tmarkSchemaMostDerived(evaluatedSchema);\n\treturn evaluatedSchema;\n}\n\n/**\n * Throws a UsageError if the provided schema is undefined, most likely due to being used before it was initialized.\n */\nexport function checkForUninitializedSchema(\n\tschema: ImplicitAnnotatedAllowedTypes | LazyItem<TreeNodeSchema>,\n): void {\n\tif (schema === undefined) {\n\t\tthrow new UsageError(\n\t\t\t`Encountered an undefined schema. This could indicate that some referenced schema has not yet been instantiated. Consider using a lazy schema reference (like \"() => schema\") or delaying the evaluation of the lazy reference if one is already being used.`,\n\t\t);\n\t}\n}\n\n/**\n * Indicates that the provided schema is the \"most derived\" version in its class hierarchy.\n *\n * @param oneTimeInitialize - If true this runs {@link TreeNodeValid.oneTimeInitialize} which does even more initialization and validation.\n * `oneTimeInitialize` can't safely be run until all transitively referenced schema are defined, so which cases can safely use it are more limited.\n * When legal for the caller to set this to true, it is preferred, but it is often not safe due to possible forward references.\n * @remarks\n * See {@link MostDerivedData} and {@link SchemaFactory} for details on what a \"most derived\" schema is and why it matters.\n *\n * This is a helper for invoking {@link TreeNodeValid.markMostDerived} for {@link TreeNodeSchema}.\n *\n * Calling this helps with error messages about invalid schema usage (See {@link SchemaFactory} for the rules, some of which this helps validate).\n * Typically this should be called for each schema as early as practical to improve error reporting for invalid usages of schema\n * (using two different schema derived from the same {@link SchemaFactory} produced base class).\n *\n * Note that construction of actual {@link TreeNode} instances or use of a schema transitively in a {@link TreeViewConfiguration} already do this,\n * so any calls to this that is unconditionally after that point for the given schema is not needed.\n * Instead most usages of this should be from those cases, and from miscellaneous cases where a schema is passed into an public API where theoretically someone could accidentally\n * pass in a base class of a schema instead of the most derived one.\n */\nexport function markSchemaMostDerived(\n\tschema: TreeNodeSchema,\n\toneTimeInitialize = false,\n): void {\n\t// Leaf schema are not classes, and thus do not need to be marked as most derived.\n\tif (schema.kind === NodeKind.Leaf) {\n\t\treturn;\n\t}\n\n\tconst schemaValid = schemaAsTreeNodeValid(schema);\n\n\tif (oneTimeInitialize) {\n\t\tschemaValid.oneTimeInitialize();\n\t} else {\n\t\tschemaValid.markMostDerived();\n\t}\n}\n\n/**\n * Type of tree node for a field of the given schema.\n * @public\n */\nexport type TreeNodeFromImplicitAllowedTypes<\n\tTSchema extends ImplicitAllowedTypes = TreeNodeSchema,\n> = TSchema extends TreeNodeSchema\n\t? NodeFromSchema<TSchema>\n\t: TSchema extends AllowedTypes\n\t\t? NodeFromSchema<FlexListToUnion<TSchema>>\n\t\t: unknown;\n\n/**\n * This type exists only to be linked from documentation to provide a single linkable place to document some details of\n * \"Input\" types and how they handle schema.\n *\n * When a schema is used to describe data which is an input into an API, the API is [contravariant](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)) over the schema.\n * (See also, [TypeScript Variance Annotations](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations)).\n *\n * Since these schema are expressed using TypeScript types, it is possible for the user of the API to provide non-exact values of these types which has implications that depended on the variance.\n *\n * Consider a field with schema type of `A | B` (where A and B are types of schema).\n *\n * - Reading the field behaves covariantly so {@link NodeFromSchema} of `<A | B>` is the same as `NodeFromSchema<A> | NodeFromSchema<B>`, indicating that either type of node can be read from the field.\n *\n * - Writing to the field behaves contravariantly. Since it is unknown if the node actually has a schema `A` or a schema `B`, the only legal values (known to be in schema regardless of which schema the underlying node has) are values which are legal for both `A & B`.\n *\n * Note that this is distinct from the case where the schema is `[A, B]`.\n * In this case it is known that the field allows both A and B (the field can be set to an A or a B value).\n * When `A | B` is used, the field might allow\n * A but not B (so assigning a B value would be out of schema),\n * B but not A (so assigning an A value would be out of schema)\n * or both A and B.\n *\n * This gets more extreme when given completely unspecified schema.\n * For example if a field is just provided {@link ImplicitFieldSchema}, nothing is known about the content of the field.\n * This means that reading the field (via {@link TreeFieldFromImplicitField}) can give any valid tree field content,\n * but there are no safe values which could be written to the field (since it is unknown what values would be out of schema) so {@link InsertableTreeFieldFromImplicitField} gives `never`.\n *\n * To implement this variance correctly, the computation of types for input and output have to use separate utilities\n * which take very different approaches when encountering non-exact schema like unions or `ImplicitFieldSchema`.\n * The utilities which behave contravariantly (as required to handle input correctly) link this documentation to indicate that this is how they behave.\n *\n * In addition to behaving contravariantly, these input type computation utilities often have further limitations.\n * This is due to TypeScript making it difficult to implement this contravariance exactly.\n * When faced with these implementation limitations these contravariant type computation utilities error on the side of producing overly strict requirements.\n * For example in the above case of `A | B`, the utilities might compute an allowed insertable type as `never` even if there happens to be a common value accepted by both `A` and `B`.\n * Future versions of the API can relax these requirements as the type computations are made more accurate.\n *\n * For a more concrete example: if {@link InsertableTreeFieldFromImplicitField} produced `never` for a schema `A | OptionalField<A>`,\n * a future version could instead return a more flexible but still safe type, like `A`.\n *\n * More generally: try to avoid providing non-exact schema, especially for the fields of other schema.\n * While these APIs attempt to handle such cases correctly, there are limitations and known bugs in this handling.\n * Code using non-exact schema is much more likely to have its compilation break due to updates of this package or even TypeScript,\n * and thus compilation breaks due to edge cases of non-exact schema handling, especially with recursive schema, are not considered breaking changes.\n * This may change as the API become more stable.\n *\n * @privateRemarks\n * There likely is a better way to share this documentation, but none was found at the time of writing.\n *\n * TODO: Once {@link InsertableField} is public, consider using it in the examples above.\n * @system @public\n */\nexport type Input<T extends never> = T;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TSchema - Schema to process.\n *\n * @privateRemarks\n * This is a bit overly conservative, since cases like `A | [A]` give never and could give `A`.\n * @public\n */\nexport type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes> =\n\t[TSchema] extends [TreeNodeSchema]\n\t\t? InsertableTypedNode<TSchema>\n\t\t: [TSchema] extends [AllowedTypes]\n\t\t\t? InsertableTreeNodeFromAllowedTypes<TSchema>\n\t\t\t: never;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TList - AllowedTypes to process\n *\n * @privateRemarks\n * This loop is manually unrolled to allow larger unions before hitting the recursion limit in TypeScript.\n * @system @public\n */\nexport type InsertableTreeNodeFromAllowedTypes<TList extends AllowedTypes> =\n\tIsUnion<TList> extends true\n\t\t? never\n\t\t: {\n\t\t\t\treadonly [Property in keyof TList]: TList[Property] extends LazyItem<\n\t\t\t\t\tinfer TSchema extends TreeNodeSchema\n\t\t\t\t>\n\t\t\t\t\t? InsertableTypedNode<TSchema>\n\t\t\t\t\t: never;\n\t\t\t}[number];\n"]}
1
+ {"version":3,"file":"allowedTypes.js","sourceRoot":"","sources":["../../../src/simple-tree/core/allowedTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uEAAsE;AAEtE,kDAK6B;AAC7B,+CAA4E;AAC5E,2DAK6B;AAC7B,yDAA2D;AAqD3D;;GAEG;AACH,SAAgB,uBAAuB,CACtC,YAA2C;IAE3C,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAC1C,OAAO;IACN,qJAAqJ;IACrJ,OAAO,YAAY,KAAK,QAAQ,IAAI,UAAU,IAAI,YAAY,IAAI,OAAO,IAAI,YAAY,CACzF,CAAC;AACH,CAAC;AARD,0DAQC;AAgCD;;GAEG;AACH,SAAgB,sBAAsB,CACrC,WAA4D;IAE5D,2BAA2B,CAAC,WAAW,CAAC,CAAC;IACzC,qJAAqJ;IACrJ,OAAO,OAAO,WAAW,KAAK,QAAQ,IAAI,UAAU,IAAI,WAAW,IAAI,MAAM,IAAI,WAAW,CAAC;AAC9F,CAAC;AAND,wDAMC;AA0BD;;;;;;;;;GASG;AACH,MAAa,aAAa;IAMzB,gBAAuB,CAAC;CACxB;AAPD,sCAOC;AALA;IACC,2BAAmB,GAAG,GAAG,EAAE,CAAC,IAAI,aAAa,EAAE,CAAC;AACjD,CAAC,GAAA,CAAA;AAyGF;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACpC,KAAoC;IAEpC,wCAAwC;IACxC,MAAM,WAAW,GAAG,8BAA8B,CAAC,KAAK,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,IAAI,IAAA,0BAAe,EAAC,WAAW,CAAC,EAAE,CAAC;QAClC,yJAAyJ;QACzJ,MA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,CAA2B,KAAkB;IAC9E,MAAM,eAAe,GAAG,IAAA,oBAAM,EAAC,KAAK,CAAC;QACpC,CAAC,CAAE,IAAA,sBAAW,EAAC,cAAc,EAAE,KAAK,EAAE,KAAK,CAAO;QAClD,CAAC,CAAC,KAAK,CAAC;IAET,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAC7C,qBAAqB,CAAC,eAAe,CAAC,CAAC;IACvC,OAAO,eAAe,CAAC;AACxB,CAAC;AARD,gDAQC;AAED;;GAEG;AACH,SAAgB,2BAA2B,CAC1C,MAAuF;IAEvF,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,qBAAU,CACnB,6PAA6P,CAC7P,CAAC;IACH,CAAC;AACF,CAAC;AARD,kEAQC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,qBAAqB,CACpC,MAAsB,EACtB,iBAAiB,GAAG,KAAK;IAEzB,kFAAkF;IAClF,IAAI,MAAM,CAAC,IAAI,KAAK,4BAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO;IACR,CAAC;IAED,MAAM,WAAW,GAAG,IAAA,wCAAqB,EAAC,MAAM,CAAC,CAAC;IAElD,IAAI,iBAAiB,EAAE,CAAC;QACvB,WAAW,CAAC,iBAAiB,EAAE,CAAC;IACjC,CAAC;SAAM,CAAC;QACP,WAAW,CAAC,eAAe,EAAE,CAAC;IAC/B,CAAC;AACF,CAAC;AAhBD,sDAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tgetOrCreate,\n\tisReadonlyArray,\n\ttype IsUnion,\n\ttype MakeNominal,\n} from \"../../util/index.js\";\nimport { isLazy, type FlexListToUnion, type LazyItem } from \"./flexList.js\";\nimport {\n\tNodeKind,\n\ttype InsertableTypedNode,\n\ttype NodeFromSchema,\n\ttype TreeNodeSchema,\n} from \"./treeNodeSchema.js\";\nimport { schemaAsTreeNodeValid } from \"./treeNodeValid.js\";\n\n/**\n * Schema for types allowed in some location in a tree (like a field, map entry or array).\n * @remarks\n * Type constraint used in schema declaration APIs.\n *\n * The order of types in the array is not significant.\n * Additionally, it is legal for users of this type to have the runtime and compile time order of items within this array not match.\n * Therefor to ensure type safety, these arrays should not be indexed, and instead just be iterated.\n *\n * Ideally this restriction would be modeled in the type itself, but it is not ergonomic to do so as there is no easy (when compared to arrays)\n * way to declare and manipulate unordered sets of types in TypeScript.\n *\n * Duplicate entries in this array are not allowed and will produce runtime errors.\n * Duplicate types are allowed,\n * but this must only be reflected in the type and not the runtime values.\n * This duplication can be used to encode the typing when the number of items in the array is not known at compile time\n * but some of the items are known to be present unconditionally.\n * For example, typing `[typeof A] | [typeof A, typeof B]` as `[typeof A, typeof B | typeof A]` is allowed,\n * and can produce more useful {@link Input} types.\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @system @public\n */\nexport type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];\n\n/**\n * Stores annotations for an individual allowed type.\n * @remarks\n * Create using APIs on {@link SchemaFactoryAlpha}, like {@link SchemaStaticsAlpha.staged}.\n * @alpha\n * @sealed\n */\nexport interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {\n\t/**\n\t * Annotations for the allowed type.\n\t */\n\treadonly metadata: AllowedTypeMetadata;\n\t/**\n\t * The allowed type the annotations apply to in a particular schema.\n\t */\n\treadonly type: T;\n}\n\n/**\n * {@link AnnotatedAllowedTypes} but with the lazy schema references eagerly evaluated.\n * @sealed\n * @alpha\n */\nexport interface NormalizedAnnotatedAllowedTypes\n\textends AnnotatedAllowedTypes<TreeNodeSchema> {}\n\n/**\n * Checks if the input is an {@link AnnotatedAllowedTypes}.\n */\nexport function isAnnotatedAllowedTypes(\n\tallowedTypes: ImplicitAnnotatedAllowedTypes,\n): allowedTypes is AnnotatedAllowedTypes {\n\tcheckForUninitializedSchema(allowedTypes);\n\treturn (\n\t\t// Class based schema, and lazy schema references report type \"function\": filtering them out with typeof makes narrowing based on members mostly safe\n\t\ttypeof allowedTypes === \"object\" && \"metadata\" in allowedTypes && \"types\" in allowedTypes\n\t);\n}\n\n/**\n * Stores annotations for a set of allowed types.\n * @alpha\n * @sealed\n */\nexport interface AnnotatedAllowedTypes<T = LazyItem<TreeNodeSchema>> {\n\t/**\n\t * Annotations that apply to a set of allowed types.\n\t */\n\treadonly metadata: AllowedTypesMetadata;\n\t/**\n\t * All the allowed types that the annotations apply to. The types themselves may also have individual annotations.\n\t */\n\treadonly types: readonly AnnotatedAllowedType<T>[];\n}\n\n/**\n * Annotations that apply to a set of allowed types.\n * @remarks\n * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.\n * @alpha\n * @input\n */\nexport interface AllowedTypesMetadata {\n\t/**\n\t * User defined metadata\n\t */\n\treadonly custom?: unknown;\n}\n\n/**\n * Checks if the given allowed type is annotated with {@link AllowedTypeMetadata}.\n */\nexport function isAnnotatedAllowedType(\n\tallowedType: AnnotatedAllowedType | LazyItem<TreeNodeSchema>,\n): allowedType is AnnotatedAllowedType {\n\tcheckForUninitializedSchema(allowedType);\n\t// Class based schema, and lazy schema references report type \"function\": filtering them out with typeof makes narrowing based on members mostly safe\n\treturn typeof allowedType === \"object\" && \"metadata\" in allowedType && \"type\" in allowedType;\n}\n\n/**\n * Annotations that apply to an individual allowed type.\n * @remarks\n * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.\n * @alpha\n * @input\n */\nexport interface AllowedTypeMetadata {\n\t/**\n\t * User defined metadata\n\t */\n\treadonly custom?: unknown;\n\n\t/**\n\t * If defined, indicates that an allowed type is {@link SchemaStaticsAlpha.staged | staged}.\n\t */\n\treadonly stagedSchemaUpgrade?: SchemaUpgrade;\n}\n\n/**\n * Package internal {@link SchemaUpgrade} construction API.\n */\nexport let createSchemaUpgrade: () => SchemaUpgrade;\n\n/**\n * Unique token used to upgrade schemas and determine if a particular upgrade has been completed.\n * @remarks\n * Create using {@link SchemaStaticsAlpha.staged}.\n * @privateRemarks\n * TODO:#38722 implement runtime schema upgrades.\n * Until then, the class purely behaves mostly as a placeholder.\n * TODO: Consider allowing users to store a name for the upgrade to use in error messages.\n * @sealed @alpha\n */\nexport class SchemaUpgrade {\n\tprotected _typeCheck!: MakeNominal;\n\tstatic {\n\t\tcreateSchemaUpgrade = () => new SchemaUpgrade();\n\t}\n\n\tprivate constructor() {}\n}\n\n/**\n * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree.\n * @remarks\n * Used by {@link TreeViewConfiguration} for the root and various kinds of {@link TreeNodeSchema} to specify their allowed child types.\n *\n * Use {@link SchemaFactory} to access leaf schema or declare new composite schema.\n *\n * Implicitly treats a single type as an array of one type.\n *\n * Arrays of schema can be used to specify multiple types are allowed, which result in unions of those types in the Tree APIs.\n *\n * When saved into variables, avoid type-erasing the details, as doing so loses the compile time schema awareness of APIs derived from the types.\n *\n * When referring to types that are declared after the definition of the `ImplicitAllowedTypes`, the schema can be wrapped in a lambda to allow the forward reference.\n * See {@link ValidateRecursiveSchema} for details on how to structure the `ImplicitAllowedTypes` instances when constructing recursive schema.\n *\n * @example Explicit use with strong typing\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * const childTypes = [sf.number, sf.string] as const satisfies ImplicitAllowedTypes;\n * const config = new TreeViewConfiguration({ schema: childTypes });\n * ```\n *\n * @example Forward reference\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * class A extends sf.array(\"example\", [() => B]) {}\n * class B extends sf.array(\"Inner\", sf.number) {}\n * ```\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @public\n */\nexport type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;\n\n/**\n * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree with\n * additional metadata associated with the location they're allowed at.\n * @alpha\n * @input\n */\nexport type ImplicitAnnotatedAllowedTypes =\n\t| TreeNodeSchema\n\t| AnnotatedAllowedType\n\t| AnnotatedAllowedTypes\n\t| readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];\n\n/**\n * Returns an {@link ImplicitAllowedTypes} that is equivalent to the input without annotations.\n * @system @alpha\n */\nexport type UnannotateImplicitAllowedTypes<T extends ImplicitAnnotatedAllowedTypes> =\n\tT extends AnnotatedAllowedTypes\n\t\t? UnannotateAllowedTypes<T>\n\t\t: T extends AnnotatedAllowedType\n\t\t\t? UnannotateAllowedTypesList<[T]>\n\t\t\t: T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]\n\t\t\t\t? UnannotateAllowedTypesList<T>\n\t\t\t\t: // This should able to just return `T` here, however doing so breaks generic code in ArrayNode.\n\t\t\t\t\tT extends TreeNodeSchema\n\t\t\t\t\t? T\n\t\t\t\t\t: // Ideally this case would not be hit as it should be impossible.\n\t\t\t\t\t\t// Due to limitations of TypeScript some generic code does depend on this case,\n\t\t\t\t\t\t// so return a valid nonspecific schema in this otherwise unreachable case.\n\t\t\t\t\t\t// This ensures that when this case is hit, the type system can still reason about it.\n\t\t\t\t\t\t// It also ensures that if bugs cause this to matter in other cases, they will err on the side of restricting the API\n\t\t\t\t\t\t// (due to non-specific schema) rather than being unsafe.\n\t\t\t\t\t\t// This helps any such bugs be noticed more easily, be less likely to lead to runtime errors,\n\t\t\t\t\t\t// and be more likely to be fixable as non-breaking changes.\n\t\t\t\t\t\tImplicitAllowedTypes;\n\n/**\n * Removes annotations from a list of allowed types that may contain annotations.\n * @system @alpha\n */\nexport type UnannotateAllowedTypesList<\n\tT extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[],\n> = {\n\t[I in keyof T]: UnannotateAllowedType<T[I]>;\n};\n\n/**\n * Removes all annotations from a set of allowed types.\n * @system @alpha\n */\nexport type UnannotateAllowedTypes<T extends AnnotatedAllowedTypes> =\n\tUnannotateAllowedTypesList<T[\"types\"]>;\n\n/**\n * Removes annotations from an allowed type.\n * @remarks\n * If the input could be lazy\n * (is a LazyItem or AnnotatedAllowedType<LazyItem> instead of just a TreeNodeSchema | AnnotatedAllowedType<TreeNodeSchema>)\n * then the output of this will be a LazyItem and thus is not valid as an ImplicitAllowedTypes without wrapping it in an array.\n * This can however be used on items within an AllowedTypes array.\n * @system @alpha\n */\nexport type UnannotateAllowedType<T extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>> =\n\tT extends AnnotatedAllowedType<infer X> ? X : T;\n\n/**\n * Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any\n * lazy schema declarations.\n *\n * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of\n * recursive schemas may fail.\n *\n * @internal\n */\nexport function normalizeAllowedTypes(\n\ttypes: ImplicitAnnotatedAllowedTypes,\n): ReadonlySet<TreeNodeSchema> {\n\t// remove annotations before normalizing\n\tconst unannotated = unannotateImplicitAllowedTypes(types);\n\tconst normalized = new Set<TreeNodeSchema>();\n\tif (isReadonlyArray(unannotated)) {\n\t\t// Types array must not be modified after it is normalized since that would result in the user of the normalized data having wrong (out of date) content.\n\t\tObject.freeze(unannotated);\n\t\tfor (const lazyType of unannotated) {\n\t\t\tnormalized.add(evaluateLazySchema(lazyType));\n\t\t}\n\t} else {\n\t\tnormalized.add(evaluateLazySchema(unannotated));\n\t}\n\treturn normalized;\n}\n\n/**\n * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist.\n */\nexport function normalizeToAnnotatedAllowedType<T extends LazyItem<TreeNodeSchema>>(\n\ttype: T | AnnotatedAllowedType<T>,\n): AnnotatedAllowedType<T> {\n\treturn isAnnotatedAllowedType(type)\n\t\t? type\n\t\t: {\n\t\t\t\tmetadata: {},\n\t\t\t\ttype,\n\t\t\t};\n}\n\n/**\n * Normalizes a {@link ImplicitAnnotatedAllowedTypes} to a set of {@link AnnotatedAllowedSchema}s, by eagerly evaluating any\n * lazy schema declarations and adding empty metadata if it doesn't already exist.\n *\n * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of\n * recursive schemas may fail.\n */\nexport function normalizeAnnotatedAllowedTypes(\n\ttypes: ImplicitAnnotatedAllowedTypes,\n): NormalizedAnnotatedAllowedTypes {\n\tconst typesWithoutAnnotation = isAnnotatedAllowedTypes(types) ? types.types : types;\n\tconst annotatedTypes: AnnotatedAllowedType<TreeNodeSchema>[] = [];\n\tif (isReadonlyArray(typesWithoutAnnotation)) {\n\t\tfor (const annotatedType of typesWithoutAnnotation) {\n\t\t\tif (isAnnotatedAllowedType(annotatedType)) {\n\t\t\t\tannotatedTypes.push({\n\t\t\t\t\ttype: evaluateLazySchema(annotatedType.type),\n\t\t\t\t\tmetadata: annotatedType.metadata,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tannotatedTypes.push({ type: evaluateLazySchema(annotatedType), metadata: {} });\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (isAnnotatedAllowedType(typesWithoutAnnotation)) {\n\t\t\tannotatedTypes.push({\n\t\t\t\ttype: evaluateLazySchema(typesWithoutAnnotation.type),\n\t\t\t\tmetadata: typesWithoutAnnotation.metadata,\n\t\t\t});\n\t\t} else {\n\t\t\tannotatedTypes.push({ type: evaluateLazySchema(typesWithoutAnnotation), metadata: {} });\n\t\t}\n\t}\n\n\treturn {\n\t\tmetadata: isAnnotatedAllowedTypes(types) ? types.metadata : {},\n\t\ttypes: annotatedTypes,\n\t};\n}\n\n/**\n * Converts an {@link ImplicitAnnotatedAllowedTypes} to an {@link ImplicitAllowedTypes}s, by removing\n * any annotations.\n * @remarks\n * This does not evaluate any lazy schemas.\n */\nexport function unannotateImplicitAllowedTypes<Types extends ImplicitAnnotatedAllowedTypes>(\n\ttypes: Types,\n): UnannotateImplicitAllowedTypes<Types> {\n\treturn (\n\t\tisAnnotatedAllowedTypes(types)\n\t\t\t? types.types.map(unannotateAllowedType)\n\t\t\t: isReadonlyArray(types)\n\t\t\t\t? types.map(unannotateAllowedType)\n\t\t\t\t: isAnnotatedAllowedType(types)\n\t\t\t\t\t? types.type\n\t\t\t\t\t: types\n\t) as UnannotateImplicitAllowedTypes<Types>;\n}\n\n/**\n * Converts an {@link AnnotatedAllowedType} to an {@link LazyItem} by removing any annotations.\n * @remarks\n * This does not evaluate any lazy schemas.\n */\nexport function unannotateAllowedType<\n\tType extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>,\n>(allowedType: Type): UnannotateAllowedType<Type> {\n\treturn isAnnotatedAllowedType(allowedType)\n\t\t? (allowedType.type as UnannotateAllowedType<Type>)\n\t\t: (allowedType as UnannotateAllowedType<Type>);\n}\n\nconst cachedLazyItem = new WeakMap<() => unknown, unknown>();\n\n/**\n * Returns the schema referenced by the {@link LazyItem}.\n * @remarks\n * Caches results to handle {@link LazyItem}s which compute their resulting schema.\n * @alpha\n */\nexport function evaluateLazySchema<T extends TreeNodeSchema>(value: LazyItem<T>): T {\n\tconst evaluatedSchema = isLazy(value)\n\t\t? (getOrCreate(cachedLazyItem, value, value) as T)\n\t\t: value;\n\n\tcheckForUninitializedSchema(evaluatedSchema);\n\tmarkSchemaMostDerived(evaluatedSchema);\n\treturn evaluatedSchema;\n}\n\n/**\n * Throws a UsageError if the provided schema is undefined, most likely due to being used before it was initialized.\n */\nexport function checkForUninitializedSchema(\n\tschema: ImplicitAnnotatedAllowedTypes | LazyItem<TreeNodeSchema> | AnnotatedAllowedType,\n): void {\n\tif (schema === undefined) {\n\t\tthrow new UsageError(\n\t\t\t`Encountered an undefined schema. This could indicate that some referenced schema has not yet been instantiated. Consider using a lazy schema reference (like \"() => schema\") or delaying the evaluation of the lazy reference if one is already being used.`,\n\t\t);\n\t}\n}\n\n/**\n * Indicates that the provided schema is the \"most derived\" version in its class hierarchy.\n *\n * @param oneTimeInitialize - If true this runs {@link TreeNodeValid.oneTimeInitialize} which does even more initialization and validation.\n * `oneTimeInitialize` can't safely be run until all transitively referenced schema are defined, so which cases can safely use it are more limited.\n * When legal for the caller to set this to true, it is preferred, but it is often not safe due to possible forward references.\n * @remarks\n * See {@link MostDerivedData} and {@link SchemaFactory} for details on what a \"most derived\" schema is and why it matters.\n *\n * This is a helper for invoking {@link TreeNodeValid.markMostDerived} for {@link TreeNodeSchema}.\n *\n * Calling this helps with error messages about invalid schema usage (See {@link SchemaFactory} for the rules, some of which this helps validate).\n * Typically this should be called for each schema as early as practical to improve error reporting for invalid usages of schema\n * (using two different schema derived from the same {@link SchemaFactory} produced base class).\n *\n * Note that construction of actual {@link TreeNode} instances or use of a schema transitively in a {@link TreeViewConfiguration} already do this,\n * so any calls to this that is unconditionally after that point for the given schema is not needed.\n * Instead most usages of this should be from those cases, and from miscellaneous cases where a schema is passed into an public API where theoretically someone could accidentally\n * pass in a base class of a schema instead of the most derived one.\n */\nexport function markSchemaMostDerived(\n\tschema: TreeNodeSchema,\n\toneTimeInitialize = false,\n): void {\n\t// Leaf schema are not classes, and thus do not need to be marked as most derived.\n\tif (schema.kind === NodeKind.Leaf) {\n\t\treturn;\n\t}\n\n\tconst schemaValid = schemaAsTreeNodeValid(schema);\n\n\tif (oneTimeInitialize) {\n\t\tschemaValid.oneTimeInitialize();\n\t} else {\n\t\tschemaValid.markMostDerived();\n\t}\n}\n\n/**\n * Type of tree node for a field of the given schema.\n * @public\n */\nexport type TreeNodeFromImplicitAllowedTypes<\n\tTSchema extends ImplicitAllowedTypes = TreeNodeSchema,\n> = TSchema extends TreeNodeSchema\n\t? NodeFromSchema<TSchema>\n\t: TSchema extends AllowedTypes\n\t\t? NodeFromSchema<FlexListToUnion<TSchema>>\n\t\t: unknown;\n\n/**\n * This type exists only to be linked from documentation to provide a single linkable place to document some details of\n * \"Input\" types and how they handle schema.\n *\n * When a schema is used to describe data which is an input into an API, the API is [contravariant](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)) over the schema.\n * (See also, [TypeScript Variance Annotations](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations)).\n *\n * Since these schema are expressed using TypeScript types, it is possible for the user of the API to provide non-exact values of these types which has implications that depended on the variance.\n *\n * Consider a field with schema type of `A | B` (where A and B are types of schema).\n *\n * - Reading the field behaves covariantly so {@link NodeFromSchema} of `<A | B>` is the same as `NodeFromSchema<A> | NodeFromSchema<B>`, indicating that either type of node can be read from the field.\n *\n * - Writing to the field behaves contravariantly. Since it is unknown if the node actually has a schema `A` or a schema `B`, the only legal values (known to be in schema regardless of which schema the underlying node has) are values which are legal for both `A & B`.\n *\n * Note that this is distinct from the case where the schema is `[A, B]`.\n * In this case it is known that the field allows both A and B (the field can be set to an A or a B value).\n * When `A | B` is used, the field might allow\n * A but not B (so assigning a B value would be out of schema),\n * B but not A (so assigning an A value would be out of schema)\n * or both A and B.\n *\n * This gets more extreme when given completely unspecified schema.\n * For example if a field is just provided {@link ImplicitFieldSchema}, nothing is known about the content of the field.\n * This means that reading the field (via {@link TreeFieldFromImplicitField}) can give any valid tree field content,\n * but there are no safe values which could be written to the field (since it is unknown what values would be out of schema) so {@link InsertableTreeFieldFromImplicitField} gives `never`.\n *\n * To implement this variance correctly, the computation of types for input and output have to use separate utilities\n * which take very different approaches when encountering non-exact schema like unions or `ImplicitFieldSchema`.\n * The utilities which behave contravariantly (as required to handle input correctly) link this documentation to indicate that this is how they behave.\n *\n * In addition to behaving contravariantly, these input type computation utilities often have further limitations.\n * This is due to TypeScript making it difficult to implement this contravariance exactly.\n * When faced with these implementation limitations these contravariant type computation utilities error on the side of producing overly strict requirements.\n * For example in the above case of `A | B`, the utilities might compute an allowed insertable type as `never` even if there happens to be a common value accepted by both `A` and `B`.\n * Future versions of the API can relax these requirements as the type computations are made more accurate.\n *\n * For a more concrete example: if {@link InsertableTreeFieldFromImplicitField} produced `never` for a schema `A | OptionalField<A>`,\n * a future version could instead return a more flexible but still safe type, like `A`.\n *\n * More generally: try to avoid providing non-exact schema, especially for the fields of other schema.\n * While these APIs attempt to handle such cases correctly, there are limitations and known bugs in this handling.\n * Code using non-exact schema is much more likely to have its compilation break due to updates of this package or even TypeScript,\n * and thus compilation breaks due to edge cases of non-exact schema handling, especially with recursive schema, are not considered breaking changes.\n * This may change as the API become more stable.\n *\n * @privateRemarks\n * There likely is a better way to share this documentation, but none was found at the time of writing.\n *\n * TODO: Once {@link InsertableField} is public, consider using it in the examples above.\n * @system @public\n */\nexport type Input<T extends never> = T;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TSchema - Schema to process.\n *\n * @privateRemarks\n * This is a bit overly conservative, since cases like `A | [A]` give never and could give `A`.\n * @public\n */\nexport type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes> =\n\t[TSchema] extends [TreeNodeSchema]\n\t\t? InsertableTypedNode<TSchema>\n\t\t: [TSchema] extends [AllowedTypes]\n\t\t\t? InsertableTreeNodeFromAllowedTypes<TSchema>\n\t\t\t: never;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TList - AllowedTypes to process\n *\n * @privateRemarks\n * This loop is manually unrolled to allow larger unions before hitting the recursion limit in TypeScript.\n * @system @public\n */\nexport type InsertableTreeNodeFromAllowedTypes<TList extends AllowedTypes> =\n\tIsUnion<TList> extends true\n\t\t? never\n\t\t: {\n\t\t\t\treadonly [Property in keyof TList]: TList[Property] extends LazyItem<\n\t\t\t\t\tinfer TSchema extends TreeNodeSchema\n\t\t\t\t>\n\t\t\t\t\t? InsertableTypedNode<TSchema>\n\t\t\t\t\t: never;\n\t\t\t}[number];\n"]}