@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
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,WAAW,EAEX,SAAS,EAET,YAAY,EAGZ,YAAY,GAEZ,MAAM,wBAAwB,CAA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AAG,aAAa,CAAC,QAAQ,AAAzB,CAA0B;AAElE;;GAEG;AAC6B,oCAAiB,GAAG,aAAa,CAAC,iBAAiB,AAAlC,CAAmC;AAEpF;;GAEG;AAC6B,oCAAiB,GAAG,aAAa,CAAC,iBAAiB,AAAlC,CAAmC;AAEpF;;GAEG;AACoB,6BAAU,GAAG,aAAa,CAAC,UAAU,AAA3B,CAA4B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ArrayNodeCustomizableSchema,\n\tarraySchema,\n\ttype MapNodeCustomizableSchema,\n\tmapSchema,\n\ttype ObjectNodeSchema,\n\tobjectSchema,\n\ttype RecordNodeCustomizableSchema,\n\ttype RecordNodeInsertableData,\n\trecordSchema,\n\ttype TreeRecordNode,\n} from \"../node-kinds/index.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tSchemaFactory,\n\tschemaStatics,\n\tstructuralName,\n\ttype NodeSchemaOptionsAlpha,\n\ttype SchemaFactoryObjectOptions,\n\ttype ScopedSchemaName,\n} from \"./schemaFactory.js\";\nimport type { ImplicitAnnotatedFieldSchema, ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type {\n\tNodeKind,\n\tTreeNodeSchema,\n\tTreeNodeSchemaBoth,\n\tTreeNodeSchemaClass,\n\tTreeNodeSchemaNonClass,\n\tWithType,\n\tImplicitAllowedTypes,\n\tImplicitAnnotatedAllowedTypes,\n} from \"../core/index.js\";\nimport type {\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n} from \"./typesUnsafe.js\";\nimport type { SimpleObjectNodeSchema } from \"../simpleSchema.js\";\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n *\n * Some private methods on `SchemaFactory` are intentionally duplicated here to avoid increasing their exposure to `protected`.\n * If we were to do so, they would be exposed on the public API surface of `SchemaFactory`.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactory<TScope, TName> {\n\tprivate scoped2<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic objectAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> & {\n\t\t/**\n\t\t * Typing checking workaround: not for for actual use.\n\t\t * @remarks\n\t\t * This API collides with {@link TreeNodeSchemaCore.createFromInsertable} to disable a type checking optimization which produces different and undesired results.\n\t\t * See {@link https://github.com/microsoft/TypeScript/issues/59049#issuecomment-2773459693} for more details.\n\t\t * @privateRemarks\n\t\t * The specific issue here is non-empty POJO mode object schema not being assignable to `ObjectNodeSchema`,\n\t\t * See the above link and the tests in objectNode.spec.ts which reference it.\n\t\t * @system\n\t\t */\n\t\treadonly createFromInsertable: unknown;\n\t} {\n\t\treturn objectSchema(\n\t\t\tthis.scoped2(name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\toptions?.allowUnknownOptionalFields ??\n\t\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic static override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic static override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAnnotatedAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(\n\t\t\tthis.scoped2(name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAnnotatedAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn arraySchema(\n\t\t\tthis.scoped2(name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param allowedTypes - The types that may appear in the record.\n\t *\n\t * @remarks\n\t * The identifier for this record is defined as a function of the provided types.\n\t * It is still scoped to this `SchemaFactory`, but multiple calls with the same arguments will return the same\n\t * schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named records, other types in this schema builder should avoid names of the form `Record<${string}>`.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyRecord = factory.record(factory.number);\n\t * type MyRecord = NodeFromSchema<typeof Record>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", { myRecord: factory.record(factory.number) });\n\t * ```\n\t *\n\t * @privateRemarks\n\t * The name produced at the type-level here is not as specific as it could be; however, doing type-level sorting and escaping is a real mess.\n\t * There are cases where not having this full type provided will be less than ideal, since TypeScript's structural types will allow assignment between runtime incompatible types at compile time.\n\t * For example, attempts to narrow unions of structural records by name won't work.\n\t * Planned future changes to move to a class based schema system as well as factor function based node construction should mostly avoid these issues,\n\t * though there may still be some problematic cases even after that work is done.\n\t *\n\t * The return value is a class, but its type is intentionally not specific enough to indicate it is a class.\n\t * This prevents callers of this from sub-classing it, which is unlikely to work well (due to the ease of accidentally giving two different calls to this different subclasses)\n\t * when working with structural typing.\n\t *\n\t * {@label STRUCTURAL}\n\t */\n\tpublic record<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaNonClass<\n\t\t/* Name */ ScopedSchemaName<TScope, `Record<${string}>`>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> &\n\t\t\tWithType<ScopedSchemaName<TScope, `Record<${string}>`>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined\n\t>;\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t *\n\t * @remarks\n\t * Like TypeScript `Record`s, record nodes have some potential pitfalls.\n\t * For example: TypeScript makes assumptions about built-in keys being present (e.g. `toString`, `hasOwnProperty`, etc.).\n\t * Since these are otherwise valid keys in a record, this can lead to unexpected behavior.\n\t * To prevent inconsistent behavior, these built-ins are hidden by record nodes.\n\t * This means that if you try to call these built-ins (e.g. `toString()`) on a record node, you will get an error.\n\t *\n\t * In most cases, it is probably preferable to use {@link SchemaFactory.(map:2)} instead.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.record(\"name\", factory.number) {}\n\t * ```\n\t *\n\t * {@label NAMED}\n\t */\n\tpublic record<const Name extends TName, const T extends ImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaClass<\n\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined\n\t>;\n\t/**\n\t * {@link SchemaFactory.array} implementation.\n\t *\n\t * @privateRemarks\n\t * This should return TreeNodeSchemaBoth: see note on \"map\" implementation for details.\n\t */\n\tpublic record<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tmaybeAllowedTypes?: T,\n\t): TreeNodeSchema<\n\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T\n\t> {\n\t\tif (maybeAllowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Record\", types);\n\t\t\treturn this.getStructuralType(fullName, types, () =>\n\t\t\t\tthis.namedRecord(\n\t\t\t\t\tfullName,\n\t\t\t\t\tnameOrAllowedTypes as T,\n\t\t\t\t\t/* customizable */ false,\n\t\t\t\t\t/* implicitlyConstructable */ true,\n\t\t\t\t),\n\t\t\t) as TreeNodeSchemaClass<\n\t\t\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t\t/* TNode */ TreeRecordNode<T>,\n\t\t\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t\t/* Info */ T,\n\t\t\t\t/* TConstructorExtra */ undefined\n\t\t\t>;\n\t\t}\n\t\tconst out: TreeNodeSchemaBoth<\n\t\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNode<T>,\n\t\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined\n\t\t> = this.namedRecord(\n\t\t\tnameOrAllowedTypes as TName,\n\t\t\tmaybeAllowedTypes,\n\t\t\t/* customizable */ true,\n\t\t\t/* implicitlyConstructable */ true,\n\t\t);\n\t\treturn out;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @remarks\n\t * This is not intended to be used directly, use the overload of `array` which takes a name instead.\n\t * This is only public to work around a compiler limitation.\n\t */\n\tprivate namedRecord<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t): TreeNodeSchemaBoth<\n\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> &\n\t\t\tWithType<ScopedSchemaName<TScope, string>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ ImplicitlyConstructable,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined\n\t> {\n\t\tconst record = recordSchema({\n\t\t\tidentifier: this.scoped2(name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable,\n\t\t\timplicitlyConstructable,\n\t\t});\n\n\t\treturn record as TreeNodeSchemaBoth<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNode<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, string>, NodeKind.Record>,\n\t\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t\t/* ImplicitlyConstructable */ ImplicitlyConstructable,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.recordAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic recordAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAnnotatedAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): RecordNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn recordSchema({\n\t\t\tidentifier: this.scoped2(name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable: true,\n\t\t\timplicitlyConstructable: true,\n\t\t\tmetadata: options?.metadata,\n\t\t\tpersistedMetadata: options?.persistedMetadata,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactoryAlpha.(record:2)} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.record` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic recordRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t>(name: Name, allowedTypes: T) {\n\t\tconst RecordSchema = this.namedRecord(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\t/* customizable */ true,\n\t\t\t// Setting this to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\t/* implicitlyConstructable */ false,\n\t\t);\n\n\t\treturn RecordSchema as TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNodeUnsafe<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t\t/* TInsertable */ {\n\t\t\t\t// Ideally this would be\n\t\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t\t// but doing so breaks recursive types.\n\t\t\t\t// Instead we do a less nice version:\n\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t},\n\t\t\t/* ImplicitlyConstructable */ false,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined\n\t\t>;\n\t}\n\n\t/**\n\t * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.\n\t * @remarks\n\t * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).\n\t * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.\n\t */\n\tpublic scopedFactory<const T extends TName, TNameInner extends number | string = string>(\n\t\tname: T,\n\t): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(this.scoped2(name));\n\t}\n}\n"]}
1
+ {"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,WAAW,EAEX,SAAS,EAET,YAAY,EAGZ,YAAY,GAEZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,iCAAiC,EACjC,aAAa,EACb,cAAc,GAId,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAenD,OAAO,EAAE,+BAA+B,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AA0JxF,MAAM,kBAAkB,GAAuB;IAC9C,MAAM,EAAE,CACP,CAA8B,EACJ,EAAE;QAC5B,MAAM,aAAa,GAAG,+BAA+B,CAAC,CAAC,CAAC,CAAC;QACzD,OAAO;YACN,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,QAAQ,EAAE;gBACT,GAAG,aAAa,CAAC,QAAQ;gBACzB,mBAAmB,EAAE,mBAAmB,EAAE;aAC1C;SACD,CAAC;IACH,CAAC;CACD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAGX,SAAQ,aAA4B;IAHtC;;QAuIC;;WAEG;QACsB,WAAM,GAAG,aAAa,CAAC,MAAM,CAAC;QAEvD;;WAEG;QACsB,aAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;QAE3D;;WAEG;QACsB,aAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;QAE3D;;WAEG;QACsB,sBAAiB,GAAG,aAAa,CAAC,iBAAiB,CAAC;QAE7E;;WAEG;QACsB,sBAAiB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.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ArrayNodeCustomizableSchema,\n\tarraySchema,\n\ttype MapNodeCustomizableSchema,\n\tmapSchema,\n\ttype ObjectNodeSchema,\n\tobjectSchema,\n\ttype RecordNodeCustomizableSchema,\n\ttype RecordNodeInsertableData,\n\trecordSchema,\n\ttype TreeRecordNode,\n} from \"../node-kinds/index.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tSchemaFactory,\n\tstructuralName,\n\ttype NodeSchemaOptionsAlpha,\n\ttype SchemaFactoryObjectOptions,\n\ttype ScopedSchemaName,\n} from \"./schemaFactory.js\";\nimport { schemaStatics } from \"./schemaStatics.js\";\nimport type { ImplicitAnnotatedFieldSchema, ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type {\n\tNodeKind,\n\tTreeNodeSchema,\n\tTreeNodeSchemaBoth,\n\tTreeNodeSchemaClass,\n\tTreeNodeSchemaNonClass,\n\tWithType,\n\tImplicitAllowedTypes,\n\tImplicitAnnotatedAllowedTypes,\n\tAnnotatedAllowedType,\n\tLazyItem,\n} from \"../core/index.js\";\nimport { normalizeToAnnotatedAllowedType, createSchemaUpgrade } from \"../core/index.js\";\nimport type {\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n} from \"./typesUnsafe.js\";\nimport type { SimpleObjectNodeSchema } from \"../simpleSchema.js\";\n\n// This import prevents a large number of type references in the API reports from showing up as *_2.\n/* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */\nimport type {\n\tFieldProps,\n\tFieldSchemaAlpha,\n\tFieldPropsAlpha,\n\tFieldKind,\n} from \"../fieldSchema.js\";\nimport type { LeafSchema } from \"../leafNodeSchema.js\";\nimport type { SimpleLeafNodeSchema } from \"../simpleSchema.js\";\nimport type { UnannotateImplicitAllowedTypes } from \"../core/index.js\";\nimport type { FieldSchemaAlphaUnsafe } from \"./typesUnsafe.js\";\n/* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */\n\n/**\n * Stateless APIs exposed via {@link SchemaFactoryAlpha} as both instance properties and as statics.\n * @remarks\n * See {@link SchemaStatics} for why this is useful.\n * @system @sealed @alpha\n */\nexport interface SchemaStaticsAlpha {\n\t/**\n\t * Declares a staged type in a set of {@link AllowedTypes}.\n\t *\n\t * @remarks\n\t * Staged allowed types add support for loading documents which may or may not permit an allowed type in a location in a schema.\n\t * This allows for an incremental rollout of a schema change to add a {@link TreeNodeSchema} to an {@link AllowedTypes} without breaking cross version collaboration.\n\t *\n\t * Once enough clients have the type staged (and thus can read documents which allow it), documents can start being created and upgraded to allow the staged type.\n\t * This is done by deploying a new version of the app which removes the `staged` wrapper around the allowed type in the the schema definition.\n\t * This will also require {@link TreeView.upgradeSchema|upgrading the schema} for existing documents.\n\t *\n\t * Using a staged allowed type in a schema is just like using the schema as an allowed type with the following exceptions:\n\t *\n\t * 1. {@link TreeView.initialize} will omit the staged allowed type from the newly created stored schema.\n\t * 2. {@link TreeView.upgradeSchema} will omit the staged allowed type from the the upgraded stored schema.\n\t * 3. When evaluating {@link TreeView.compatibility}, it will be viewable even if the staged allowed type is not present in the stored schema's corresponding allowed types.\n\t * 4. Because of the above, it is possible to get errors when inserting content which uses the staged allowed type when inserting the content into a tree who's stored schema does not permit it.\n\t *\n\t * Currently, `staged` is not supported in the recursive type APIs: this is a known limitation which future versions of the API will address.\n\t *\n\t * @example\n\t * Suppose you have a schema which has a field that allows some type `A`, but you want to add support for type `B`.\n\t *\n\t * The first change is to used to mark the new type as staged, replacing `A` in the schema with `[A, SchemaStaticsAlpha.staged(B)]`.\n\t * Once this is done, and any code which reads contents from documents is updated to handle any `B` content that may be present, this version of the code can be deployed.\n\t *\n\t * Once all users have the above changes, the schema can be updated again to `[A, B]`, and the app can be updated to allow creating of `B` content.\n\t * This updated version of the app will need to call {@link TreeView.upgradeSchema} when opening documents created by earlier versions.\n\t *\n\t * Adding a `B` schema as an option in the root could look like this:\n\t * ```typescript\n\t * const factory = new SchemaFactoryAlpha(\"test\");\n\t * class A extends factory.objectAlpha(\"A\", {}) {}\n\t * class B extends factory.objectAlpha(\"B\", {}) {}\n\t *\n\t * // Does not support B\n\t * const configBefore = new TreeViewConfigurationAlpha({\n\t * \tschema: A,\n\t * });\n\t *\n\t * // Supports documents with or without B\n\t * const configStaged = new TreeViewConfigurationAlpha({\n\t * \t// Adds staged support for B.\n\t * \t// Currently this requires wrapping the root field with `SchemaFactoryAlpha.required`:\n\t * \t// this is normally implicitly included, but is currently required while the \"staged\" APIs are `@alpha`.\n\t * \tschema: SchemaFactoryAlpha.required([A, SchemaFactoryAlpha.staged(B)]),\n\t * });\n\t *\n\t * // Only supports documents with A and B: can be used to upgrade schema to add B.\n\t * const configAfter = new TreeViewConfigurationAlpha({\n\t * \tschema: [A, B],\n\t * });\n\t * ```\n\t * @example\n\t * Below is a full example of how the schema migration process works.\n\t * This can also be found in our {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/src/test/simple-tree/api/stagedSchemaUpgrade.spec.ts | tests}.\n\t * ```typescript\n\t * // Schema A: only number allowed\n\t * const schemaA = SchemaFactoryAlpha.optional([SchemaFactoryAlpha.number]);\n\t *\n\t * // Schema B: number or string (string is staged)\n\t * const schemaB = SchemaFactoryAlpha.optional([\n\t * \tSchemaFactoryAlpha.number,\n\t * \tSchemaFactoryAlpha.staged(SchemaFactoryAlpha.string),\n\t * ]);\n\t *\n\t * // Schema C: number or string, both fully allowed\n\t * const schemaC = SchemaFactoryAlpha.optional([\n\t * \tSchemaFactoryAlpha.number,\n\t * \tSchemaFactoryAlpha.string,\n\t * ]);\n\t *\n\t * // Initialize with schema A.\n\t * const configA = new TreeViewConfiguration({\n\t * \tschema: schemaA,\n\t * });\n\t * const viewA = treeA.viewWith(configA);\n\t * viewA.initialize(5);\n\t *\n\t * // Since we are running all the different versions of the app in the same process making changes synchronously,\n\t * // an explicit flush is needed to make them available to each other.\n\t * synchronizeTrees();\n\t *\n\t * assert.deepEqual(viewA.root, 5);\n\t *\n\t * // View the same document with a second tree using schema B.\n\t * const configB = new TreeViewConfiguration({\n\t * \tschema: schemaB,\n\t * });\n\t * const viewB = treeB.viewWith(configB);\n\t * // B cannot write strings to the root.\n\t * assert.throws(() => (viewB.root = \"test\"));\n\t *\n\t * // View the same document with a third tree using schema C.\n\t * const configC = new TreeViewConfiguration({\n\t * \tschema: schemaC,\n\t * });\n\t * const viewC = treeC.viewWith(configC);\n\t * // Upgrade to schema C\n\t * viewC.upgradeSchema();\n\t * // Use the newly enabled schema.\n\t * viewC.root = \"test\";\n\t *\n\t * synchronizeTrees();\n\t *\n\t * // View A is now incompatible with the stored schema:\n\t * assert.equal(viewA.compatibility.canView, false);\n\t *\n\t * // View B can still read the document, and now sees the string root which relies on the staged schema.\n\t * assert.deepEqual(viewB.root, \"test\");\n\t * ```\n\t * @privateRemarks\n\t * TODO:#44317 staged allowed types rely on schema validation of stored schema to output errors, these errors are not very\n\t * user friendly and should be improved, particularly in the case of staged allowed types\n\t *\n\t * TODO: the example above does not work tell in intellisense: its formatted to work onm the website. We should find a solution that works well for both.\n\t *\n\t * TODO: AB#45711: Update the docs above when recursive type support is added.\n\t */\n\tstaged: <const T extends LazyItem<TreeNodeSchema>>(\n\t\tt: T | AnnotatedAllowedType<T>,\n\t) => AnnotatedAllowedType<T>;\n}\n\nconst schemaStaticsAlpha: SchemaStaticsAlpha = {\n\tstaged: <const T extends LazyItem<TreeNodeSchema>>(\n\t\tt: T | AnnotatedAllowedType<T>,\n\t): AnnotatedAllowedType<T> => {\n\t\tconst annotatedType = normalizeToAnnotatedAllowedType(t);\n\t\treturn {\n\t\t\ttype: annotatedType.type,\n\t\t\tmetadata: {\n\t\t\t\t...annotatedType.metadata,\n\t\t\t\tstagedSchemaUpgrade: createSchemaUpgrade(),\n\t\t\t},\n\t\t};\n\t},\n};\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n *\n * Some private methods on `SchemaFactory` are intentionally duplicated here to avoid increasing their exposure to `protected`.\n * If we were to do so, they would be exposed on the public API surface of `SchemaFactory`.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactory<TScope, TName> {\n\tprivate scoped2<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic objectAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> & {\n\t\t/**\n\t\t * Typing checking workaround: not for for actual use.\n\t\t * @remarks\n\t\t * This API collides with {@link TreeNodeSchemaCore.createFromInsertable} to disable a type checking optimization which produces different and undesired results.\n\t\t * See {@link https://github.com/microsoft/TypeScript/issues/59049#issuecomment-2773459693} for more details.\n\t\t * @privateRemarks\n\t\t * The specific issue here is non-empty POJO mode object schema not being assignable to `ObjectNodeSchema`,\n\t\t * See the above link and the tests in objectNode.spec.ts which reference it.\n\t\t * @system\n\t\t */\n\t\treadonly createFromInsertable: unknown;\n\t} {\n\t\treturn objectSchema(\n\t\t\tthis.scoped2(name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\toptions?.allowUnknownOptionalFields ??\n\t\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic static override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic static override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.staged}\n\t */\n\tpublic static staged = schemaStaticsAlpha.staged;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsAlpha.staged}\n\t */\n\tpublic staged = schemaStaticsAlpha.staged;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAnnotatedAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(\n\t\t\tthis.scoped2(name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAnnotatedAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn arraySchema(\n\t\t\tthis.scoped2(name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions?.metadata,\n\t\t\toptions?.persistedMetadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param allowedTypes - The types that may appear in the record.\n\t *\n\t * @remarks\n\t * The identifier for this record is defined as a function of the provided types.\n\t * It is still scoped to this `SchemaFactory`, but multiple calls with the same arguments will return the same\n\t * schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named records, other types in this schema builder should avoid names of the form `Record<${string}>`.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyRecord = factory.record(factory.number);\n\t * type MyRecord = NodeFromSchema<typeof Record>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", { myRecord: factory.record(factory.number) });\n\t * ```\n\t *\n\t * @privateRemarks\n\t * The name produced at the type-level here is not as specific as it could be; however, doing type-level sorting and escaping is a real mess.\n\t * There are cases where not having this full type provided will be less than ideal, since TypeScript's structural types will allow assignment between runtime incompatible types at compile time.\n\t * For example, attempts to narrow unions of structural records by name won't work.\n\t * Planned future changes to move to a class based schema system as well as factor function based node construction should mostly avoid these issues,\n\t * though there may still be some problematic cases even after that work is done.\n\t *\n\t * The return value is a class, but its type is intentionally not specific enough to indicate it is a class.\n\t * This prevents callers of this from sub-classing it, which is unlikely to work well (due to the ease of accidentally giving two different calls to this different subclasses)\n\t * when working with structural typing.\n\t *\n\t * {@label STRUCTURAL}\n\t */\n\tpublic record<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaNonClass<\n\t\t/* Name */ ScopedSchemaName<TScope, `Record<${string}>`>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> &\n\t\t\tWithType<ScopedSchemaName<TScope, `Record<${string}>`>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined\n\t>;\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t *\n\t * @remarks\n\t * Like TypeScript `Record`s, record nodes have some potential pitfalls.\n\t * For example: TypeScript makes assumptions about built-in keys being present (e.g. `toString`, `hasOwnProperty`, etc.).\n\t * Since these are otherwise valid keys in a record, this can lead to unexpected behavior.\n\t * To prevent inconsistent behavior, these built-ins are hidden by record nodes.\n\t * This means that if you try to call these built-ins (e.g. `toString()`) on a record node, you will get an error.\n\t *\n\t * In most cases, it is probably preferable to use {@link SchemaFactory.(map:2)} instead.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.record(\"name\", factory.number) {}\n\t * ```\n\t *\n\t * {@label NAMED}\n\t */\n\tpublic record<const Name extends TName, const T extends ImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaClass<\n\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined\n\t>;\n\t/**\n\t * {@link SchemaFactory.array} implementation.\n\t *\n\t * @privateRemarks\n\t * This should return TreeNodeSchemaBoth: see note on \"map\" implementation for details.\n\t */\n\tpublic record<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tmaybeAllowedTypes?: T,\n\t): TreeNodeSchema<\n\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T\n\t> {\n\t\tif (maybeAllowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Record\", types);\n\t\t\treturn this.getStructuralType(fullName, types, () =>\n\t\t\t\tthis.namedRecord(\n\t\t\t\t\tfullName,\n\t\t\t\t\tnameOrAllowedTypes as T,\n\t\t\t\t\t/* customizable */ false,\n\t\t\t\t\t/* implicitlyConstructable */ true,\n\t\t\t\t),\n\t\t\t) as TreeNodeSchemaClass<\n\t\t\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t\t/* TNode */ TreeRecordNode<T>,\n\t\t\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t\t/* Info */ T,\n\t\t\t\t/* TConstructorExtra */ undefined\n\t\t\t>;\n\t\t}\n\t\tconst out: TreeNodeSchemaBoth<\n\t\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNode<T>,\n\t\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined\n\t\t> = this.namedRecord(\n\t\t\tnameOrAllowedTypes as TName,\n\t\t\tmaybeAllowedTypes,\n\t\t\t/* customizable */ true,\n\t\t\t/* implicitlyConstructable */ true,\n\t\t);\n\t\treturn out;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @remarks\n\t * This is not intended to be used directly, use the overload of `array` which takes a name instead.\n\t * This is only public to work around a compiler limitation.\n\t */\n\tprivate namedRecord<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t): TreeNodeSchemaBoth<\n\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> &\n\t\t\tWithType<ScopedSchemaName<TScope, string>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ ImplicitlyConstructable,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined\n\t> {\n\t\tconst record = recordSchema({\n\t\t\tidentifier: this.scoped2(name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable,\n\t\t\timplicitlyConstructable,\n\t\t});\n\n\t\treturn record as TreeNodeSchemaBoth<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNode<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, string>, NodeKind.Record>,\n\t\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t\t/* ImplicitlyConstructable */ ImplicitlyConstructable,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.recordAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic recordAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAnnotatedAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): RecordNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn recordSchema({\n\t\t\tidentifier: this.scoped2(name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable: true,\n\t\t\timplicitlyConstructable: true,\n\t\t\tmetadata: options?.metadata,\n\t\t\tpersistedMetadata: options?.persistedMetadata,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactoryAlpha.(record:2)} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.record` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic recordRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t>(name: Name, allowedTypes: T) {\n\t\tconst RecordSchema = this.namedRecord(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\t/* customizable */ true,\n\t\t\t// Setting this to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\t/* implicitlyConstructable */ false,\n\t\t);\n\n\t\treturn RecordSchema as TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNodeUnsafe<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t\t/* TInsertable */ {\n\t\t\t\t// Ideally this would be\n\t\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t\t// but doing so breaks recursive types.\n\t\t\t\t// Instead we do a less nice version:\n\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t},\n\t\t\t/* ImplicitlyConstructable */ false,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined\n\t\t>;\n\t}\n\n\t/**\n\t * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.\n\t * @remarks\n\t * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).\n\t * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.\n\t */\n\tpublic scopedFactory<const T extends TName, TNameInner extends number | string = string>(\n\t\tname: T,\n\t): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(this.scoped2(name));\n\t}\n}\n"]}
@@ -5,9 +5,7 @@
5
5
  import type { RestrictiveStringRecord } from "../../util/index.js";
6
6
  import type { NodeKind, TreeNodeSchema, WithType, TreeNode, ImplicitAllowedTypes, InsertableTreeNodeFromImplicitAllowedTypes } from "../core/index.js";
7
7
  import type { InsertableObjectFromSchemaRecord } from "../node-kinds/index.js";
8
- import { type FieldKind, type FieldProps, type ImplicitFieldSchema } from "../fieldSchema.js";
9
- import type { FieldSchemaAlphaUnsafe, System_Unsafe } from "./typesUnsafe.js";
10
- export declare function createFieldSchemaUnsafe<Kind extends FieldKind, Types extends System_Unsafe.ImplicitAllowedTypesUnsafe, TCustomMetadata = unknown>(kind: Kind, allowedTypes: Types, props?: FieldProps<TCustomMetadata>): FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata>;
8
+ import type { ImplicitFieldSchema } from "../fieldSchema.js";
11
9
  /**
12
10
  * Compile time check for validity of a recursive schema.
13
11
  * This type also serves as a central location for documenting the requirements and issues related to recursive schema.
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryRecursive.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryRecursive.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,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ACH,MAAM,MAAM,0BAA0B,CAAC,CAAC,SAAS,cAAc,IAC9D,CAAC,SAAS,+BAA+B,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAG;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI,CAAC,SAAS,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC"}
@@ -2,11 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { createFieldSchema, } from "../fieldSchema.js";
6
- export function createFieldSchemaUnsafe(kind, allowedTypes, props) {
7
- // 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
8
- return createFieldSchema(kind, allowedTypes, props);
9
- }
10
5
  /**
11
6
  * Does nothing with the provided value, but appears to use it to make unused locals warnings and errors go away.
12
7
  *
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryRecursive.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryRecursive.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EAGN,iBAAiB,GAEjB,MAAM,mBAAmB,CAAC;AAI3B,MAAM,UAAU,uBAAuB,CAKtC,IAAU,EACV,YAAmB,EACnB,KAAmC;IAEnC,kJAAkJ;IAClJ,OAAO,iBAAiB,CACvB,IAAI,EACJ,YAA4C,EAC5C,KAAK,CACmD,CAAC;AAC3D,CAAC;AAkOD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAI,CAAK,IAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type {\n\tNodeKind,\n\tTreeNodeSchema,\n\tWithType,\n\tTreeNode,\n\tImplicitAllowedTypes,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n} from \"../core/index.js\";\nimport type { InsertableObjectFromSchemaRecord } from \"../node-kinds/index.js\";\nimport {\n\ttype FieldKind,\n\ttype FieldProps,\n\tcreateFieldSchema,\n\ttype ImplicitFieldSchema,\n} from \"../fieldSchema.js\";\n\nimport type { FieldSchemaAlphaUnsafe, System_Unsafe } from \"./typesUnsafe.js\";\n\nexport function 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\n/**\n * Compile time check for validity of a recursive schema.\n * This type also serves as a central location for documenting the requirements and issues related to recursive schema.\n *\n * @example\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => Test]) {}\n * {\n * type _check = ValidateRecursiveSchema<typeof Test>;\n * }\n * ```\n * @remarks\n * In this context recursive schema are defined as all {@link FieldSchema} and {@link TreeNodeSchema} schema which are part of a cycle such that walking down through each {@link TreeNodeSchemaCore.childTypes} the given starting schema can be reached again.\n * Schema referencing the recursive schema and schema they reference that are not part of a cycle are not considered recursive.\n *\n * TypeScript puts a lot of limitations on the typing of recursive schema.\n * To help avoid running into these limitations and thus getting schema that do not type check (or only type checks sometimes!),\n * {@link SchemaFactory} provides APIs (postfixed with `Recursive`) for writing recursive schema.\n * These APIs when combined with the patterns documented below should ensure that the schema provide robust type checking.\n * These special patterns (other than {@link LazyItem} forward references which are not recursion specific)\n * are not required for correct runtime behavior: they exist entirely to mitigate TypeScript type checking limitations and bugs.\n * Ideally TypeScript's type checker would be able to handle all of these cases and more, removing the need for recursive type specific guidance, rules and APIs.\n * Currently however there are open issues preventing this:\n * {@link https://github.com/microsoft/TypeScript/issues/59550 | 1},\n * {@link https://github.com/microsoft/TypeScript/issues/55832 | 2},\n * {@link https://github.com/microsoft/TypeScript/issues/55758 | 3}.\n * Note that the proposed resolution to some of these issues is for the compiler to error rather than allow the case,\n * so even if these are all resolved the recursive type workarounds may still be needed.\n *\n * # Patterns\n *\n * Below are patterns for how to use recursive schema.\n *\n * ## General Patterns\n *\n * When defining a recursive {@link TreeNodeSchema}, use the `*Recursive` {@link SchemaFactory} methods.\n * The returned class should be used as the base class for the recursive schema, which should then be passed to {@link ValidateRecursiveSchema}.\n *\n * Using {@link ValidateRecursiveSchema} will provide compile error for some of the cases of malformed schema.\n * This can be used to help mitigate the issue that recursive schema definitions are {@link Unenforced}.\n * If an issue is encountered where a mistake in a recursive schema is made which produces an invalid schema but is not rejected by this checker,\n * it should be considered a bug and this should be updated to handle that case (or have a disclaimer added to these docs that it misses that case).\n *\n * The non-recursive versions of the schema building methods will run into several issues when used recursively.\n * Consider the following example:\n *\n * ```typescript\n * const Test = sf.array(Test); // Bad\n * ```\n *\n * This has several issues:\n *\n * 1. It is a structurally named schema.\n * Structurally named schema derive their name from the names of their child types, which is not possible when the type is recursive since its name would include itself.\n * Instead a name must be explicitly provided.\n *\n * 2. The schema accesses itself before it's defined.\n * This would be a runtime error if the TypeScript compiler allowed it.\n * This can be fixed by wrapping the type in a function, which also requires explicitly listing the allowed types in an array (`[() => Test]`).\n *\n * 3. TypeScript fails to infer the recursive type and falls back to `any` with this warning or error (depending on the compiler configuration):\n * `'Test' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.ts(7022)`.\n * This issue is what the specialized recursive schema building methods fix.\n * This fix comes at a cost: to make the recursive cases work, the `extends` clauses had to be removed.\n * This means that mistakes declaring recursive schema often don't give compile errors in the schema.\n * Additionally support for implicit construction had to be disabled.\n * This means that new nested {@link Unhydrated} nodes can not be created like `new Test([[]])`.\n * Instead the nested nodes must be created explicitly using the construction like`new Test([new Test([])])`.\n *\n * 4. It is using \"POJO\" mode since it's not explicitly declaring a new class.\n * This means that the generated d.ts files for the schema replace recursive references with `any`, breaking use of recursive schema across compilation boundaries.\n * This is fixed by explicitly creating a class which extends the returned schema.\n *\n * All together, the fixed version looks like:\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => Test]) {} // Good\n * ```\n *\n * Be very careful when declaring recursive schema.\n * Due to the removed extends clauses, subtle mistakes will compile just fine but cause strange errors when the schema is used.\n *\n * For example if a reference to a schema is malformed (in this case boxed inside an object):\n *\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => ({ Test })]) {} // Bad\n * ```\n * This schema will still compile, and some (but not all) usages of it may look like they work correctly while other usages will produce generally unintelligible compile errors.\n * This issue can be partially mitigated using {@link ValidateRecursiveSchema}:\n *\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => ({ Test })]) {} // Bad\n * {\n * type _check = ValidateRecursiveSchema<typeof Test>; // Reports compile error due to invalid schema above.\n * }\n * ```\n *\n * If your TypeScript configuration objects to this patten due to the unused local, you can use {@link allowUnused} to suppress the error:\n *\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => ({ Test })]) {} // Bad\n * allowUnused<ValidateRecursiveSchema<typeof Test>>(); // Reports compile error due to invalid schema above.\n * ```\n *\n * ## Object Schema\n *\n * When defining fields, if the fields is part of the recursive cycle, use the `*Recursive` {@link SchemaFactory} methods for defining the {@link FieldSchema}.\n *\n * ## Array Schema\n *\n * See {@link FixRecursiveArraySchema} for array specific details.\n *\n * @privateRemarks\n * There are probably mistakes this misses: it's hard to guess all the wrong things people will accidentally do and defend against them.\n * Hopefully over time this can grow toward being robust, at least for common mistakes.\n *\n * This check duplicates logic that ideally would be entirely decided by the actual schema building methods.\n * Therefore changes to those methods may require updating `ValidateRecursiveSchema`.\n *\n * TODO: this currently does not reject `any`, but ideally should.\n * @public\n */\nexport type ValidateRecursiveSchema<\n\t// Recursive types should always be using TreeNodeSchemaClass (not TreeNodeSchemaNonClass) as thats part of the requirements for the type to work across compilation boundaries correctly.\n\tT extends ValidateRecursiveSchemaTemplate<T>,\n> = true;\n\n/**\n * Validation logic used by {@link ValidateRecursiveSchema}.\n * @system @public\n */\nexport type ValidateRecursiveSchemaTemplate<T extends TreeNodeSchema> = TreeNodeSchema<\n\t// Name: This validator places no restrictions on the name other than that it's a string (as required by TreeNodeSchemaClass).\n\tstring,\n\t// NodeKind: These are the NodeKinds which currently can be used recursively.\n\tNodeKind.Array | NodeKind.Map | NodeKind.Object | NodeKind.Record,\n\t// TNode: The produced node API. This is pretty minimal validation: more could be added if similar to how TInsertable works below if needed.\n\tTreeNode & WithType<T[\"identifier\"], T[\"kind\"]>,\n\t// TInsertable: What can be passed to the constructor. This should be enough to catch most issues with incorrect schema.\n\t// These match whats defined in the recursive methods on `SchemaFactory` except they do not use `Unenforced`.\n\t{\n\t\t[NodeKind.Object]: T[\"info\"] extends RestrictiveStringRecord<ImplicitFieldSchema>\n\t\t\t? InsertableObjectFromSchemaRecord<T[\"info\"]>\n\t\t\t: unknown;\n\t\t[NodeKind.Array]: T[\"info\"] extends ImplicitAllowedTypes\n\t\t\t? Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T[\"info\"]>>\n\t\t\t: unknown;\n\t\t[NodeKind.Map]: T[\"info\"] extends ImplicitAllowedTypes\n\t\t\t? Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T[\"info\"]>]>\n\t\t\t: unknown;\n\t\t[NodeKind.Record]: {\n\t\t\treadonly [P in string]: InsertableTreeNodeFromImplicitAllowedTypes<T>;\n\t\t};\n\t\t[NodeKind.Leaf]: unknown;\n\t}[T[\"kind\"]],\n\t// ImplicitlyConstructable: recursive types are currently not implicitly constructable.\n\tfalse,\n\t// Info: What's passed to the method to create the schema. Constraining these here should be about as effective as if the actual constraints existed on the actual method itself.\n\t{\n\t\t[NodeKind.Object]: RestrictiveStringRecord<ImplicitFieldSchema>;\n\t\t[NodeKind.Array]: ImplicitAllowedTypes;\n\t\t[NodeKind.Map]: ImplicitAllowedTypes;\n\t\t[NodeKind.Record]: ImplicitAllowedTypes;\n\t\t[NodeKind.Leaf]: unknown;\n\t}[T[\"kind\"]]\n>;\n\n/**\n * Workaround for \"Type instantiation is excessively deep and possibly infinite.ts\" errors.\n * @remarks\n *\n * Generally this workaround should be avoided if possible,\n * especially for exported types, as it is likely to result in issues when exporting or importing schema where the user will be forced to use the workaround as well.\n * This is particularly problematic since in some cases it may not be possible for the user to replicate the pattern.\n * Additionally, which cases hit these limits may vary based on TypeScript version and implementation details of this library.\n *\n * This workaround is provided and documented as a last resort to be able to keep an app compiling.\n * Future version of SharedTree should provide schema type erasure functionality as a better alternative for most cases.\n *\n * When TypeScript gives the error \"Error (TS2589) Type instantiation is excessively deep and possibly infinite.\" on the invocation of `ValidateRecursiveSchema`\n * for a large schema, it can sometimes be worked around by repeating the usage of the type multiple times.\n * This works because the TypeScript compiler caches some of the intermediate results from the first usage, and thus can get further on the second.\n *\n * This utility can be referenced when applying this pattern.\n * For recursive types this can be used directly:\n *\n * ```typescript\n * {\n * // @ts-expect-error Recursion limit\n * type _check1 = FixRecursiveRecursionLimit<typeof LargeType>;\n * type _check2 = FixRecursiveRecursionLimit<typeof LargeType>;\n * type _check3 = ValidateRecursiveSchemaTemplate<typeof LargeType>;\n * }\n * ```\n *\n * For non-recursive types, they can be ported to the more flexible recursive APIs and use the pattern above.\n *\n * Non-recursive types can also use this workaround by making a duplicate copy of the problematic schema written using the recursive APIs.\n * Then this pattern can be applied to the duplicate copy.\n *\n * ```typescript\n * // Workaround TypeScript recursion limit\n * \t{\n * \t\tclass LargeUnionObjectNode_Fix extends schema.objectRecursive(\"ObjectNode\", {\n * \t\t\tx: largeUnion,\n * \t\t}) {}\n *\n * \t\t// @ts-expect-error Recursion limit\n * \t\tallowUnused<FixRecursiveRecursionLimit<typeof LargeUnionObjectNode_Fix>>();\n * \t\tallowUnused<FixRecursiveRecursionLimit<typeof LargeUnionObjectNode_Fix>>();\n * \t\tallowUnused<ValidateRecursiveSchema<typeof LargeUnionObjectNode_Fix>>();\n * \t\t}\n *\n * \t// Fails to compile without the above workaround.\n * \tclass LargeUnionObjectNode extends schema.object(\"ObjectNode\", { x: largeUnion }) {}\n * ```\n * @privateRemarks\n * Using this is real sketchy, and leads to a lot of issues (errors which depend on how the schema is compiled, making different build setups produce different results and complicating exports).\n * This is being kept as internal for now: if a customer really needs it, we have this as a documented workaround, but it would be much better to find an alternative solution before using this one.\n * This uses ValidateRecursiveSchemaTemplate since it was found to evaluate enough of the type to work.\n * @internal\n */\nexport type FixRecursiveRecursionLimit<T extends TreeNodeSchema> =\n\tT extends ValidateRecursiveSchemaTemplate<T> ? undefined : undefined;\n\n/**\n * Does nothing with the provided value, but appears to use it to make unused locals warnings and errors go away.\n *\n * @remarks\n * When TypeScript is configured with \"noUnusedLocals\", it will produce an error if a local variable is declared but never used.\n * When you want to have this check enabled, but not follow it for a specific variable, you can pass the type or value to this function.\n *\n * Instead of using this, consider disabling \"noUnusedLocals\" in your tsconfig.json file, and enabling a similar check via a linter.\n * This will allow you to still have the check, but have more control over it, for example being able to suppress it, or enable patterns like allowing unused locals with an \"_\" prefix.\n * @alpha\n */\nexport function allowUnused<T>(t?: T): void {}\n\n/**\n * Workaround for fixing errors resulting from an issue with recursive ArrayNode schema exports.\n * @remarks\n * Importing a recursive ArrayNode schema via a d.ts file can produce an error like\n * `error TS2310: Type 'RecursiveArray' recursively references itself as a base type.`\n * if using a tsconfig with `\"skipLibCheck\": false`.\n *\n * This error occurs due to the TypeScript compiler splitting the class definition into two separate declarations in the d.ts file (one for the base, and one for the actual class).\n * For unknown reasons, splitting the class declaration in this way breaks the recursive type handling, leading to the mentioned error.\n *\n * This type always evaluates to `undefined` to ensure the dummy export (which doesn't exist at runtime) is typed correctly.\n *\n * {@link https://github.com/microsoft/TypeScript/issues/59550|TypeScript Issue 59550} tracks a suggestion which would make this workaround unnecessary.\n *\n * @example Usage\n * Since recursive type handling in TypeScript is order dependent, putting just the right kind of usages of the type before the declarations can cause it to not hit this error.\n * For the case of ArrayNodes, this can be done via usage that looks like this:\n *\n * This example should use a doc comment to ensure the workaround comment shows up in the intellisense for the dummy export,\n * however doing so is impossible due to how this example is included in a doc comment.\n * ```typescript\n * // Workaround to avoid\n * // `error TS2310: Type 'RecursiveArray' recursively references itself as a base type.` in the d.ts file.\n * export declare type _RecursiveArrayWorkaround = FixRecursiveArraySchema<typeof RecursiveArray>;\n * export class RecursiveArray extends schema.arrayRecursive(\"RA\", [() => RecursiveArray]) {}\n * {\n * \ttype _check = ValidateRecursiveSchema<typeof RecursiveArray>;\n * }\n * ```\n *\n * @alpha\n */\nexport type FixRecursiveArraySchema<T> = T extends TreeNodeSchema ? undefined : undefined;\n"]}
1
+ {"version":3,"file":"schemaFactoryRecursive.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryRecursive.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8OH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAI,CAAK,IAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type {\n\tNodeKind,\n\tTreeNodeSchema,\n\tWithType,\n\tTreeNode,\n\tImplicitAllowedTypes,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n} from \"../core/index.js\";\nimport type { InsertableObjectFromSchemaRecord } from \"../node-kinds/index.js\";\nimport type { ImplicitFieldSchema } from \"../fieldSchema.js\";\n\n/**\n * Compile time check for validity of a recursive schema.\n * This type also serves as a central location for documenting the requirements and issues related to recursive schema.\n *\n * @example\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => Test]) {}\n * {\n * type _check = ValidateRecursiveSchema<typeof Test>;\n * }\n * ```\n * @remarks\n * In this context recursive schema are defined as all {@link FieldSchema} and {@link TreeNodeSchema} schema which are part of a cycle such that walking down through each {@link TreeNodeSchemaCore.childTypes} the given starting schema can be reached again.\n * Schema referencing the recursive schema and schema they reference that are not part of a cycle are not considered recursive.\n *\n * TypeScript puts a lot of limitations on the typing of recursive schema.\n * To help avoid running into these limitations and thus getting schema that do not type check (or only type checks sometimes!),\n * {@link SchemaFactory} provides APIs (postfixed with `Recursive`) for writing recursive schema.\n * These APIs when combined with the patterns documented below should ensure that the schema provide robust type checking.\n * These special patterns (other than {@link LazyItem} forward references which are not recursion specific)\n * are not required for correct runtime behavior: they exist entirely to mitigate TypeScript type checking limitations and bugs.\n * Ideally TypeScript's type checker would be able to handle all of these cases and more, removing the need for recursive type specific guidance, rules and APIs.\n * Currently however there are open issues preventing this:\n * {@link https://github.com/microsoft/TypeScript/issues/59550 | 1},\n * {@link https://github.com/microsoft/TypeScript/issues/55832 | 2},\n * {@link https://github.com/microsoft/TypeScript/issues/55758 | 3}.\n * Note that the proposed resolution to some of these issues is for the compiler to error rather than allow the case,\n * so even if these are all resolved the recursive type workarounds may still be needed.\n *\n * # Patterns\n *\n * Below are patterns for how to use recursive schema.\n *\n * ## General Patterns\n *\n * When defining a recursive {@link TreeNodeSchema}, use the `*Recursive` {@link SchemaFactory} methods.\n * The returned class should be used as the base class for the recursive schema, which should then be passed to {@link ValidateRecursiveSchema}.\n *\n * Using {@link ValidateRecursiveSchema} will provide compile error for some of the cases of malformed schema.\n * This can be used to help mitigate the issue that recursive schema definitions are {@link Unenforced}.\n * If an issue is encountered where a mistake in a recursive schema is made which produces an invalid schema but is not rejected by this checker,\n * it should be considered a bug and this should be updated to handle that case (or have a disclaimer added to these docs that it misses that case).\n *\n * The non-recursive versions of the schema building methods will run into several issues when used recursively.\n * Consider the following example:\n *\n * ```typescript\n * const Test = sf.array(Test); // Bad\n * ```\n *\n * This has several issues:\n *\n * 1. It is a structurally named schema.\n * Structurally named schema derive their name from the names of their child types, which is not possible when the type is recursive since its name would include itself.\n * Instead a name must be explicitly provided.\n *\n * 2. The schema accesses itself before it's defined.\n * This would be a runtime error if the TypeScript compiler allowed it.\n * This can be fixed by wrapping the type in a function, which also requires explicitly listing the allowed types in an array (`[() => Test]`).\n *\n * 3. TypeScript fails to infer the recursive type and falls back to `any` with this warning or error (depending on the compiler configuration):\n * `'Test' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.ts(7022)`.\n * This issue is what the specialized recursive schema building methods fix.\n * This fix comes at a cost: to make the recursive cases work, the `extends` clauses had to be removed.\n * This means that mistakes declaring recursive schema often don't give compile errors in the schema.\n * Additionally support for implicit construction had to be disabled.\n * This means that new nested {@link Unhydrated} nodes can not be created like `new Test([[]])`.\n * Instead the nested nodes must be created explicitly using the construction like`new Test([new Test([])])`.\n *\n * 4. It is using \"POJO\" mode since it's not explicitly declaring a new class.\n * This means that the generated d.ts files for the schema replace recursive references with `any`, breaking use of recursive schema across compilation boundaries.\n * This is fixed by explicitly creating a class which extends the returned schema.\n *\n * All together, the fixed version looks like:\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => Test]) {} // Good\n * ```\n *\n * Be very careful when declaring recursive schema.\n * Due to the removed extends clauses, subtle mistakes will compile just fine but cause strange errors when the schema is used.\n *\n * For example if a reference to a schema is malformed (in this case boxed inside an object):\n *\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => ({ Test })]) {} // Bad\n * ```\n * This schema will still compile, and some (but not all) usages of it may look like they work correctly while other usages will produce generally unintelligible compile errors.\n * This issue can be partially mitigated using {@link ValidateRecursiveSchema}:\n *\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => ({ Test })]) {} // Bad\n * {\n * type _check = ValidateRecursiveSchema<typeof Test>; // Reports compile error due to invalid schema above.\n * }\n * ```\n *\n * If your TypeScript configuration objects to this patten due to the unused local, you can use {@link allowUnused} to suppress the error:\n *\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => ({ Test })]) {} // Bad\n * allowUnused<ValidateRecursiveSchema<typeof Test>>(); // Reports compile error due to invalid schema above.\n * ```\n *\n * ## Object Schema\n *\n * When defining fields, if the fields is part of the recursive cycle, use the `*Recursive` {@link SchemaFactory} methods for defining the {@link FieldSchema}.\n *\n * ## Array Schema\n *\n * See {@link FixRecursiveArraySchema} for array specific details.\n *\n * @privateRemarks\n * There are probably mistakes this misses: it's hard to guess all the wrong things people will accidentally do and defend against them.\n * Hopefully over time this can grow toward being robust, at least for common mistakes.\n *\n * This check duplicates logic that ideally would be entirely decided by the actual schema building methods.\n * Therefore changes to those methods may require updating `ValidateRecursiveSchema`.\n *\n * TODO: this currently does not reject `any`, but ideally should.\n * @public\n */\nexport type ValidateRecursiveSchema<\n\t// Recursive types should always be using TreeNodeSchemaClass (not TreeNodeSchemaNonClass) as thats part of the requirements for the type to work across compilation boundaries correctly.\n\tT extends ValidateRecursiveSchemaTemplate<T>,\n> = true;\n\n/**\n * Validation logic used by {@link ValidateRecursiveSchema}.\n * @system @public\n */\nexport type ValidateRecursiveSchemaTemplate<T extends TreeNodeSchema> = TreeNodeSchema<\n\t// Name: This validator places no restrictions on the name other than that it's a string (as required by TreeNodeSchemaClass).\n\tstring,\n\t// NodeKind: These are the NodeKinds which currently can be used recursively.\n\tNodeKind.Array | NodeKind.Map | NodeKind.Object | NodeKind.Record,\n\t// TNode: The produced node API. This is pretty minimal validation: more could be added if similar to how TInsertable works below if needed.\n\tTreeNode & WithType<T[\"identifier\"], T[\"kind\"]>,\n\t// TInsertable: What can be passed to the constructor. This should be enough to catch most issues with incorrect schema.\n\t// These match whats defined in the recursive methods on `SchemaFactory` except they do not use `Unenforced`.\n\t{\n\t\t[NodeKind.Object]: T[\"info\"] extends RestrictiveStringRecord<ImplicitFieldSchema>\n\t\t\t? InsertableObjectFromSchemaRecord<T[\"info\"]>\n\t\t\t: unknown;\n\t\t[NodeKind.Array]: T[\"info\"] extends ImplicitAllowedTypes\n\t\t\t? Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T[\"info\"]>>\n\t\t\t: unknown;\n\t\t[NodeKind.Map]: T[\"info\"] extends ImplicitAllowedTypes\n\t\t\t? Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T[\"info\"]>]>\n\t\t\t: unknown;\n\t\t[NodeKind.Record]: {\n\t\t\treadonly [P in string]: InsertableTreeNodeFromImplicitAllowedTypes<T>;\n\t\t};\n\t\t[NodeKind.Leaf]: unknown;\n\t}[T[\"kind\"]],\n\t// ImplicitlyConstructable: recursive types are currently not implicitly constructable.\n\tfalse,\n\t// Info: What's passed to the method to create the schema. Constraining these here should be about as effective as if the actual constraints existed on the actual method itself.\n\t{\n\t\t[NodeKind.Object]: RestrictiveStringRecord<ImplicitFieldSchema>;\n\t\t[NodeKind.Array]: ImplicitAllowedTypes;\n\t\t[NodeKind.Map]: ImplicitAllowedTypes;\n\t\t[NodeKind.Record]: ImplicitAllowedTypes;\n\t\t[NodeKind.Leaf]: unknown;\n\t}[T[\"kind\"]]\n>;\n\n/**\n * Workaround for \"Type instantiation is excessively deep and possibly infinite.ts\" errors.\n * @remarks\n *\n * Generally this workaround should be avoided if possible,\n * especially for exported types, as it is likely to result in issues when exporting or importing schema where the user will be forced to use the workaround as well.\n * This is particularly problematic since in some cases it may not be possible for the user to replicate the pattern.\n * Additionally, which cases hit these limits may vary based on TypeScript version and implementation details of this library.\n *\n * This workaround is provided and documented as a last resort to be able to keep an app compiling.\n * Future version of SharedTree should provide schema type erasure functionality as a better alternative for most cases.\n *\n * When TypeScript gives the error \"Error (TS2589) Type instantiation is excessively deep and possibly infinite.\" on the invocation of `ValidateRecursiveSchema`\n * for a large schema, it can sometimes be worked around by repeating the usage of the type multiple times.\n * This works because the TypeScript compiler caches some of the intermediate results from the first usage, and thus can get further on the second.\n *\n * This utility can be referenced when applying this pattern.\n * For recursive types this can be used directly:\n *\n * ```typescript\n * {\n * // @ts-expect-error Recursion limit\n * type _check1 = FixRecursiveRecursionLimit<typeof LargeType>;\n * type _check2 = FixRecursiveRecursionLimit<typeof LargeType>;\n * type _check3 = ValidateRecursiveSchemaTemplate<typeof LargeType>;\n * }\n * ```\n *\n * For non-recursive types, they can be ported to the more flexible recursive APIs and use the pattern above.\n *\n * Non-recursive types can also use this workaround by making a duplicate copy of the problematic schema written using the recursive APIs.\n * Then this pattern can be applied to the duplicate copy.\n *\n * ```typescript\n * // Workaround TypeScript recursion limit\n * \t{\n * \t\tclass LargeUnionObjectNode_Fix extends schema.objectRecursive(\"ObjectNode\", {\n * \t\t\tx: largeUnion,\n * \t\t}) {}\n *\n * \t\t// @ts-expect-error Recursion limit\n * \t\tallowUnused<FixRecursiveRecursionLimit<typeof LargeUnionObjectNode_Fix>>();\n * \t\tallowUnused<FixRecursiveRecursionLimit<typeof LargeUnionObjectNode_Fix>>();\n * \t\tallowUnused<ValidateRecursiveSchema<typeof LargeUnionObjectNode_Fix>>();\n * \t\t}\n *\n * \t// Fails to compile without the above workaround.\n * \tclass LargeUnionObjectNode extends schema.object(\"ObjectNode\", { x: largeUnion }) {}\n * ```\n * @privateRemarks\n * Using this is real sketchy, and leads to a lot of issues (errors which depend on how the schema is compiled, making different build setups produce different results and complicating exports).\n * This is being kept as internal for now: if a customer really needs it, we have this as a documented workaround, but it would be much better to find an alternative solution before using this one.\n * This uses ValidateRecursiveSchemaTemplate since it was found to evaluate enough of the type to work.\n * @internal\n */\nexport type FixRecursiveRecursionLimit<T extends TreeNodeSchema> =\n\tT extends ValidateRecursiveSchemaTemplate<T> ? undefined : undefined;\n\n/**\n * Does nothing with the provided value, but appears to use it to make unused locals warnings and errors go away.\n *\n * @remarks\n * When TypeScript is configured with \"noUnusedLocals\", it will produce an error if a local variable is declared but never used.\n * When you want to have this check enabled, but not follow it for a specific variable, you can pass the type or value to this function.\n *\n * Instead of using this, consider disabling \"noUnusedLocals\" in your tsconfig.json file, and enabling a similar check via a linter.\n * This will allow you to still have the check, but have more control over it, for example being able to suppress it, or enable patterns like allowing unused locals with an \"_\" prefix.\n * @alpha\n */\nexport function allowUnused<T>(t?: T): void {}\n\n/**\n * Workaround for fixing errors resulting from an issue with recursive ArrayNode schema exports.\n * @remarks\n * Importing a recursive ArrayNode schema via a d.ts file can produce an error like\n * `error TS2310: Type 'RecursiveArray' recursively references itself as a base type.`\n * if using a tsconfig with `\"skipLibCheck\": false`.\n *\n * This error occurs due to the TypeScript compiler splitting the class definition into two separate declarations in the d.ts file (one for the base, and one for the actual class).\n * For unknown reasons, splitting the class declaration in this way breaks the recursive type handling, leading to the mentioned error.\n *\n * This type always evaluates to `undefined` to ensure the dummy export (which doesn't exist at runtime) is typed correctly.\n *\n * {@link https://github.com/microsoft/TypeScript/issues/59550|TypeScript Issue 59550} tracks a suggestion which would make this workaround unnecessary.\n *\n * @example Usage\n * Since recursive type handling in TypeScript is order dependent, putting just the right kind of usages of the type before the declarations can cause it to not hit this error.\n * For the case of ArrayNodes, this can be done via usage that looks like this:\n *\n * This example should use a doc comment to ensure the workaround comment shows up in the intellisense for the dummy export,\n * however doing so is impossible due to how this example is included in a doc comment.\n * ```typescript\n * // Workaround to avoid\n * // `error TS2310: Type 'RecursiveArray' recursively references itself as a base type.` in the d.ts file.\n * export declare type _RecursiveArrayWorkaround = FixRecursiveArraySchema<typeof RecursiveArray>;\n * export class RecursiveArray extends schema.arrayRecursive(\"RA\", [() => RecursiveArray]) {}\n * {\n * \ttype _check = ValidateRecursiveSchema<typeof RecursiveArray>;\n * }\n * ```\n *\n * @alpha\n */\nexport type FixRecursiveArraySchema<T> = T extends TreeNodeSchema ? undefined : undefined;\n"]}
@@ -0,0 +1,158 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IFluidHandle } from "@fluidframework/core-interfaces";
6
+ import type { ImplicitAllowedTypes, ImplicitAnnotatedAllowedTypes, UnannotateImplicitAllowedTypes } from "../core/index.js";
7
+ import { FieldKind } from "../fieldSchema.js";
8
+ import type { FieldProps, FieldSchema, FieldPropsAlpha, FieldSchemaAlpha } from "../fieldSchema.js";
9
+ import type { LeafSchema } from "../leafNodeSchema.js";
10
+ import { stringSchema } from "../leafNodeSchema.js";
11
+ import type { System_Unsafe, FieldSchemaAlphaUnsafe } from "./typesUnsafe.js";
12
+ /**
13
+ * Stateless APIs exposed via {@link SchemaFactory} as both instance properties and as statics.
14
+ * @privateRemarks
15
+ * We have no way to make linkable members which exist both as statics and instance properties since API-Extractor does not support this.
16
+ * As a workaround, we have this type as a third place which can be linked.
17
+ * @system @sealed @public
18
+ */
19
+ export interface SchemaStatics {
20
+ /**
21
+ * {@link TreeNodeSchema} for holding a JavaScript `string`.
22
+ *
23
+ * @remarks
24
+ * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.
25
+ *
26
+ * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.
27
+ * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.
28
+ * @privateRemarks
29
+ * TODO:
30
+ * We should be much more clear about what happens if you use problematic values.
31
+ * We should validate and/or normalize them when inserting content.
32
+ */
33
+ readonly string: LeafSchema<"string", string>;
34
+ /**
35
+ * {@link TreeNodeSchema} for holding a JavaScript `number`.
36
+ *
37
+ * @remarks
38
+ * 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:
39
+ *
40
+ * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).
41
+ *
42
+ * - `-0` may be converted to `0` in some cases.
43
+ *
44
+ * These limitations match the limitations of JSON.
45
+ * @privateRemarks
46
+ * TODO:
47
+ * We should be much more clear about what happens if you use problematic values.
48
+ * We should validate and/or normalize them when inserting content.
49
+ */
50
+ readonly number: LeafSchema<"number", number>;
51
+ /**
52
+ * {@link TreeNodeSchema} for holding a boolean.
53
+ */
54
+ readonly boolean: LeafSchema<"boolean", boolean>;
55
+ /**
56
+ * {@link TreeNodeSchema} for JavaScript `null`.
57
+ *
58
+ * @remarks
59
+ * 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.
60
+ * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.
61
+ * 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.
62
+ */
63
+ readonly null: LeafSchema<"null", null>;
64
+ /**
65
+ * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.
66
+ */
67
+ readonly handle: LeafSchema<"handle", IFluidHandle>;
68
+ /**
69
+ * {@link AllowedTypes} for holding any of the leaf types.
70
+ */
71
+ readonly leaves: readonly [
72
+ SchemaStatics["string"],
73
+ SchemaStatics["number"],
74
+ SchemaStatics["boolean"],
75
+ SchemaStatics["null"],
76
+ SchemaStatics["handle"]
77
+ ];
78
+ /**
79
+ * Make a field optional instead of the default, which is required.
80
+ *
81
+ * @param t - The types allowed under the field.
82
+ * @param props - Optional properties to associate with the field.
83
+ *
84
+ * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
85
+ * See {@link FieldSchemaMetadata.custom}.
86
+ */
87
+ readonly optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => FieldSchema<FieldKind.Optional, T, TCustomMetadata>;
88
+ /**
89
+ * Make a field explicitly required.
90
+ *
91
+ * @param t - The types allowed under the field.
92
+ * @param props - Optional properties to associate with the field.
93
+ *
94
+ * @remarks
95
+ * Fields are required by default, but this API can be used to make the required nature explicit in the schema,
96
+ * and allows associating custom {@link FieldProps | properties} with the field.
97
+ *
98
+ * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
99
+ * See {@link FieldSchemaMetadata.custom}.
100
+ */
101
+ readonly required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => FieldSchema<FieldKind.Required, T, TCustomMetadata>;
102
+ /**
103
+ * {@link SchemaStatics.optional} except tweaked to work better for recursive types.
104
+ * Use with {@link ValidateRecursiveSchema} for improved type safety.
105
+ * @remarks
106
+ * This version of {@link SchemaStatics.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
107
+ * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
108
+ */
109
+ readonly optionalRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Optional, T, TCustomMetadata>;
110
+ /**
111
+ * {@link SchemaStatics.required} except tweaked to work better for recursive types.
112
+ * Use with {@link ValidateRecursiveSchema} for improved type safety.
113
+ * @remarks
114
+ * This version of {@link SchemaStatics.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
115
+ * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
116
+ */
117
+ readonly requiredRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Required, T, TCustomMetadata>;
118
+ }
119
+ declare function optional<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">): FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata>;
120
+ declare function optional<const T extends ImplicitAnnotatedAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">): FieldSchemaAlpha<FieldKind.Optional, UnannotateImplicitAllowedTypes<T>, TCustomMetadata>;
121
+ declare function required<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">): FieldSchemaAlpha<FieldKind.Required, T, TCustomMetadata>;
122
+ declare function required<const T extends ImplicitAnnotatedAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">): FieldSchemaAlpha<FieldKind.Required, UnannotateImplicitAllowedTypes<T>, TCustomMetadata>;
123
+ /**
124
+ * Implementation of {@link SchemaStatics}.
125
+ * @remarks
126
+ * Entries can use more specific types than {@link SchemaStatics} requires to be more useful for non-public consumers.
127
+ * Additional non-public members are in {@link schemaStatics}.
128
+ */
129
+ export declare const schemaStaticsStable: {
130
+ readonly string: LeafSchema<"string", string> & import("../simpleSchema.js").SimpleLeafNodeSchema;
131
+ readonly number: LeafSchema<"number", number> & import("../simpleSchema.js").SimpleLeafNodeSchema;
132
+ readonly boolean: LeafSchema<"boolean", boolean> & import("../simpleSchema.js").SimpleLeafNodeSchema;
133
+ readonly null: LeafSchema<"null", null> & import("../simpleSchema.js").SimpleLeafNodeSchema;
134
+ readonly handle: LeafSchema<"handle", IFluidHandle<unknown>> & import("../simpleSchema.js").SimpleLeafNodeSchema;
135
+ readonly leaves: readonly [LeafSchema<"string", string> & import("../simpleSchema.js").SimpleLeafNodeSchema, LeafSchema<"number", number> & import("../simpleSchema.js").SimpleLeafNodeSchema, LeafSchema<"boolean", boolean> & import("../simpleSchema.js").SimpleLeafNodeSchema, LeafSchema<"null", null> & import("../simpleSchema.js").SimpleLeafNodeSchema, LeafSchema<"handle", IFluidHandle<unknown>> & import("../simpleSchema.js").SimpleLeafNodeSchema];
136
+ readonly optional: typeof optional;
137
+ readonly required: typeof required;
138
+ readonly optionalRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">) => FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata>;
139
+ readonly requiredRecursive: <const T_1 extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata_1 = unknown>(t: T_1, props?: Omit<FieldPropsAlpha<TCustomMetadata_1>, "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Required, T_1, TCustomMetadata_1>;
140
+ };
141
+ /**
142
+ * Unstable extensions to {@link schemaStaticsStable}.
143
+ */
144
+ export declare const schemaStatics: {
145
+ readonly identifier: <const TCustomMetadata = unknown>(props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => FieldSchemaAlpha<FieldKind.Identifier, typeof stringSchema, TCustomMetadata>;
146
+ readonly string: LeafSchema<"string", string> & import("../simpleSchema.js").SimpleLeafNodeSchema;
147
+ readonly number: LeafSchema<"number", number> & import("../simpleSchema.js").SimpleLeafNodeSchema;
148
+ readonly boolean: LeafSchema<"boolean", boolean> & import("../simpleSchema.js").SimpleLeafNodeSchema;
149
+ readonly null: LeafSchema<"null", null> & import("../simpleSchema.js").SimpleLeafNodeSchema;
150
+ readonly handle: LeafSchema<"handle", IFluidHandle<unknown>> & import("../simpleSchema.js").SimpleLeafNodeSchema;
151
+ readonly leaves: readonly [LeafSchema<"string", string> & import("../simpleSchema.js").SimpleLeafNodeSchema, LeafSchema<"number", number> & import("../simpleSchema.js").SimpleLeafNodeSchema, LeafSchema<"boolean", boolean> & import("../simpleSchema.js").SimpleLeafNodeSchema, LeafSchema<"null", null> & import("../simpleSchema.js").SimpleLeafNodeSchema, LeafSchema<"handle", IFluidHandle<unknown>> & import("../simpleSchema.js").SimpleLeafNodeSchema];
152
+ readonly optional: typeof optional;
153
+ readonly required: typeof required;
154
+ readonly optionalRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata_1 = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata_1>, "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata_1>;
155
+ readonly requiredRecursive: <const T_1 extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata_2 = unknown>(t: T_1, props?: Omit<FieldPropsAlpha<TCustomMetadata_2>, "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Required, T_1, TCustomMetadata_2>;
156
+ };
157
+ export {};
158
+ //# sourceMappingURL=schemaStatics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaStatics.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaStatics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EACX,oBAAoB,EACpB,6BAA6B,EAC7B,8BAA8B,EAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAyC,MAAM,mBAAmB,CAAC;AACrF,OAAO,KAAK,EACX,UAAU,EACV,WAAW,EAEX,eAAe,EACf,gBAAgB,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACN,YAAY,EAKZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE9C;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE9C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEjD;;;;;;;OAO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AC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC;AAE5D,iBAAS,QAAQ,CAChB,KAAK,CAAC,CAAC,SAAS,6BAA6B,EAC7C,KAAK,CAAC,eAAe,GAAG,OAAO,EAE/B,CAAC,EAAE,CAAC,EACJ,KAAK,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,iBAAiB,CAAC,GAC/D,gBAAgB,CAAC,SAAS,CAAC,QAAQ,EAAE,8BAA8B,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;AAa5F;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;+HAgB3B,CAAC,UACI,KAAK,gBAAgB,eAAe,CAAC,EAAE,iBAAiB,CAAC,KAC/D,uBAAuB,UAAU,QAAQ,EAAE,CAAC,EAAE,eAAe,CAAC;;CAgBhC,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,aAAa;mEAGhB,KAAK,WAAW,eAAe,CAAC,EAAE,iBAAiB,CAAC,KAC1D,iBAAiB,UAAU,UAAU,EAAE,mBAAmB,EAAE,eAAe,CAAC;;;;;;;;;iIA3B3E,CAAC;;CA8BI,CAAC"}
@@ -0,0 +1,56 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { FieldKind, getDefaultProvider, createFieldSchema } from "../fieldSchema.js";
6
+ import { stringSchema, numberSchema, booleanSchema, nullSchema, handleSchema, } from "../leafNodeSchema.js";
7
+ const defaultOptionalProvider = getDefaultProvider(() => []);
8
+ function optional(t, props) {
9
+ return createFieldSchema(FieldKind.Optional, t, {
10
+ defaultProvider: defaultOptionalProvider,
11
+ ...props,
12
+ });
13
+ }
14
+ function required(t, props) {
15
+ return createFieldSchema(FieldKind.Required, t, props);
16
+ }
17
+ // #endregion
18
+ /**
19
+ * Implementation of {@link SchemaStatics}.
20
+ * @remarks
21
+ * Entries can use more specific types than {@link SchemaStatics} requires to be more useful for non-public consumers.
22
+ * Additional non-public members are in {@link schemaStatics}.
23
+ */
24
+ export const schemaStaticsStable = {
25
+ string: stringSchema,
26
+ number: numberSchema,
27
+ boolean: booleanSchema,
28
+ null: nullSchema,
29
+ handle: handleSchema,
30
+ leaves: [stringSchema, numberSchema, booleanSchema, nullSchema, handleSchema],
31
+ optional,
32
+ required,
33
+ optionalRecursive: (t, props) => {
34
+ return createFieldSchemaUnsafe(FieldKind.Optional, t, {
35
+ defaultProvider: defaultOptionalProvider,
36
+ ...props,
37
+ });
38
+ },
39
+ requiredRecursive: (t, props) => {
40
+ return createFieldSchemaUnsafe(FieldKind.Required, t, props);
41
+ },
42
+ };
43
+ /**
44
+ * Unstable extensions to {@link schemaStaticsStable}.
45
+ */
46
+ export const schemaStatics = {
47
+ ...schemaStaticsStable,
48
+ identifier: (props) => {
49
+ return createFieldSchema(FieldKind.Identifier, stringSchema, props);
50
+ },
51
+ };
52
+ function createFieldSchemaUnsafe(kind, allowedTypes, props) {
53
+ // At runtime, we still want this to be a FieldSchema instance, but we can't satisfy its extends clause, so just return it as an FieldSchemaUnsafe
54
+ return createFieldSchema(kind, allowedTypes, props);
55
+ }
56
+ //# sourceMappingURL=schemaStatics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaStatics.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaStatics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AASrF,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,GACZ,MAAM,sBAAsB,CAAC;AA2I9B,MAAM,uBAAuB,GAAoB,kBAAkB,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAmB9E,SAAS,QAAQ,CAIhB,CAAI,EACJ,KAAiE;IAEjE,OAAO,iBAAiB,CAAC,SAAS,CA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AA4C,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"}
@@ -7,14 +7,16 @@ import { encodeTreeSchema, makeSchemaCodec } from "../../feature-libraries/index
7
7
  import { clientVersionToSchemaVersion,
8
8
  // eslint-disable-next-line import/no-internal-modules
9
9
  } from "../../feature-libraries/schema-index/index.js";
10
- import { normalizeFieldSchema } from "../fieldSchema.js";
11
- import { simpleToStoredSchema } from "../toStoredSchema.js";
10
+ import { normalizeFieldSchema, } from "../fieldSchema.js";
11
+ import { toStoredSchema } from "../toStoredSchema.js";
12
12
  import { TreeViewConfigurationAlpha } from "./configuration.js";
13
13
  import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
14
14
  /**
15
15
  * Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.
16
16
  *
17
17
  * @param schema - The schema to dump.
18
+ * @param oldestCompatibleClient - The oldest client version which can read the schema: impacts the format used.
19
+ * @param includeStaged - filter for selecting which staged allowed types to include in the output.
18
20
  *
19
21
  * @remarks
20
22
  * 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.
@@ -41,8 +43,8 @@ import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
41
43
  * Public API surface uses "persisted" terminology while internally we use "stored".
42
44
  * @alpha
43
45
  */
44
- export function extractPersistedSchema(schema, oldestCompatibleClient) {
45
- const stored = simpleToStoredSchema(schema);
46
+ export function extractPersistedSchema(schema, oldestCompatibleClient, includeStaged) {
47
+ const stored = toStoredSchema(schema, { includeStaged });
46
48
  const schemaWriteVersion = clientVersionToSchemaVersion(oldestCompatibleClient);
47
49
  return encodeTreeSchema(stored, schemaWriteVersion);
48
50
  }