@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
@@ -8,7 +8,7 @@ import { allowsRepoSuperset, defaultSchemaPolicy } from "../../feature-libraries
8
8
 
9
9
  import type { SchemaCompatibilityStatus } from "./tree.js";
10
10
  import { getDiscrepanciesInAllowedContent } from "./discrepancies.js";
11
- import { toStoredSchema } from "../toStoredSchema.js";
11
+ import { toUpgradeSchema } from "../toStoredSchema.js";
12
12
  import type { TreeSchema } from "./configuration.js";
13
13
 
14
14
  /**
@@ -51,18 +51,14 @@ export class SchemaCompatibilityTester {
51
51
  break;
52
52
  }
53
53
 
54
- const canUpgrade = allowsRepoSuperset(
55
- policy,
56
- stored,
57
- toStoredSchema(this.viewSchema.root),
58
- );
54
+ const wouldUpgradeTo = toUpgradeSchema(this.viewSchema.root);
55
+
56
+ const canUpgrade = allowsRepoSuperset(policy, stored, wouldUpgradeTo);
59
57
 
60
58
  // If true, then upgrading has no effect on what can be stored in the document.
61
59
  // TODO: This should likely be changed to indicate up a schema upgrade would be a no-op, including stored schema metadata.
62
60
  const isEquivalent =
63
- canView &&
64
- canUpgrade &&
65
- allowsRepoSuperset(policy, toStoredSchema(this.viewSchema.root), stored);
61
+ canView && canUpgrade && allowsRepoSuperset(policy, wouldUpgradeTo, stored);
66
62
 
67
63
  return {
68
64
  canView,
@@ -3,7 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import type { IFluidHandle } from "@fluidframework/core-interfaces";
7
6
  import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
8
7
  import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
9
8
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
@@ -29,7 +28,6 @@ import type {
29
28
  TreeNodeSchemaBoth,
30
29
  UnhydratedFlexTreeNode,
31
30
  NodeSchemaMetadata,
32
- ImplicitAnnotatedAllowedTypes,
33
31
  UnannotateImplicitAllowedTypes,
34
32
  ImplicitAllowedTypes,
35
33
  InsertableTreeNodeFromImplicitAllowedTypes,
@@ -40,6 +38,8 @@ import {
40
38
  nullSchema,
41
39
  numberSchema,
42
40
  stringSchema,
41
+ // This import prevents a large number of LeafSchema references in the API reports from showing up as LeafSchema_2.
42
+ // eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars
43
43
  type LeafSchema,
44
44
  } from "../leafNodeSchema.js";
45
45
  import {
@@ -57,20 +57,20 @@ import {
57
57
  FieldKind,
58
58
  type FieldSchema,
59
59
  type ImplicitFieldSchema,
60
+ // This import prevents a large number of FieldProps references in the API reports from showing up as FieldProps_2.
61
+ // eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars
60
62
  type FieldProps,
61
63
  createFieldSchema,
62
64
  type DefaultProvider,
63
65
  getDefaultProvider,
64
- type FieldSchemaAlpha,
65
- type FieldPropsAlpha,
66
66
  } from "../fieldSchema.js";
67
67
 
68
- import { createFieldSchemaUnsafe } from "./schemaFactoryRecursive.js";
69
- import type { System_Unsafe, FieldSchemaAlphaUnsafe } from "./typesUnsafe.js";
68
+ import type { System_Unsafe } from "./typesUnsafe.js";
70
69
  import type { IIdCompressor } from "@fluidframework/id-compressor";
71
70
  import { createIdCompressor } from "@fluidframework/id-compressor/internal";
72
71
  import type { FlexTreeHydratedContextMinimal } from "../../feature-libraries/index.js";
73
72
  import { unhydratedFlexTreeFromInsertable } from "../unhydratedFlexTreeFromInsertable.js";
73
+ import { type SchemaStatics, schemaStatics } from "./schemaStatics.js";
74
74
 
75
75
  /**
76
76
  * Gets the leaf domain schema compatible with a given {@link TreeValue}.
@@ -171,250 +171,6 @@ export type ScopedSchemaName<
171
171
  > = TScope extends undefined ? `${TName}` : `${TScope}.${TName}`;
172
172
  // > = `${TScope extends undefined ? "" : `${TScope}.`}${TName}`;
173
173
 
174
- /**
175
- * Stateless APIs exposed via {@link SchemaFactory} as both instance properties and as statics.
176
- * @privateRemarks
177
- * We have no way to make linkable members which exist both as statics and instance properties since API-Extractor does not support this.
178
- * As a workaround, we have this type as a third place which can be linked.
179
- * @system @sealed @public
180
- */
181
- export interface SchemaStatics {
182
- /**
183
- * {@link TreeNodeSchema} for holding a JavaScript `string`.
184
- *
185
- * @remarks
186
- * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.
187
- *
188
- * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.
189
- * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.
190
- * @privateRemarks
191
- * TODO:
192
- * We should be much more clear about what happens if you use problematic values.
193
- * We should validate and/or normalize them when inserting content.
194
- */
195
- readonly string: LeafSchema<"string", string>;
196
-
197
- /**
198
- * {@link TreeNodeSchema} for holding a JavaScript `number`.
199
- *
200
- * @remarks
201
- * 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:
202
- *
203
- * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).
204
- *
205
- * - `-0` may be converted to `0` in some cases.
206
- *
207
- * These limitations match the limitations of JSON.
208
- * @privateRemarks
209
- * TODO:
210
- * We should be much more clear about what happens if you use problematic values.
211
- * We should validate and/or normalize them when inserting content.
212
- */
213
- readonly number: LeafSchema<"number", number>;
214
-
215
- /**
216
- * {@link TreeNodeSchema} for holding a boolean.
217
- */
218
- readonly boolean: LeafSchema<"boolean", boolean>;
219
-
220
- /**
221
- * {@link TreeNodeSchema} for JavaScript `null`.
222
- *
223
- * @remarks
224
- * 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.
225
- * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.
226
- * 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.
227
- */
228
- // eslint-disable-next-line @rushstack/no-new-null
229
- readonly null: LeafSchema<"null", null>;
230
-
231
- /**
232
- * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.
233
- */
234
- readonly handle: LeafSchema<"handle", IFluidHandle>;
235
-
236
- /**
237
- * {@link AllowedTypes} for holding any of the leaf types.
238
- */
239
- readonly leaves: readonly [
240
- SchemaStatics["string"],
241
- SchemaStatics["number"],
242
- SchemaStatics["boolean"],
243
- SchemaStatics["null"],
244
- SchemaStatics["handle"],
245
- ];
246
-
247
- /**
248
- * Make a field optional instead of the default, which is required.
249
- *
250
- * @param t - The types allowed under the field.
251
- * @param props - Optional properties to associate with the field.
252
- *
253
- * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
254
- * See {@link FieldSchemaMetadata.custom}.
255
- */
256
- readonly optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
257
- t: T,
258
- props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
259
- ) => FieldSchema<FieldKind.Optional, T, TCustomMetadata>;
260
-
261
- /**
262
- * Make a field explicitly required.
263
- *
264
- * @param t - The types allowed under the field.
265
- * @param props - Optional properties to associate with the field.
266
- *
267
- * @remarks
268
- * Fields are required by default, but this API can be used to make the required nature explicit in the schema,
269
- * and allows associating custom {@link FieldProps | properties} with the field.
270
- *
271
- * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
272
- * See {@link FieldSchemaMetadata.custom}.
273
- */
274
- readonly required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
275
- t: T,
276
- props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
277
- ) => FieldSchema<FieldKind.Required, T, TCustomMetadata>;
278
-
279
- /**
280
- * {@link SchemaStatics.optional} except tweaked to work better for recursive types.
281
- * Use with {@link ValidateRecursiveSchema} for improved type safety.
282
- * @remarks
283
- * This version of {@link SchemaStatics.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
284
- * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
285
- */
286
- readonly optionalRecursive: <
287
- const T extends System_Unsafe.ImplicitAllowedTypesUnsafe,
288
- const TCustomMetadata = unknown,
289
- >(
290
- t: T,
291
- props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
292
- ) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Optional, T, TCustomMetadata>;
293
-
294
- /**
295
- * {@link SchemaStatics.required} except tweaked to work better for recursive types.
296
- * Use with {@link ValidateRecursiveSchema} for improved type safety.
297
- * @remarks
298
- * This version of {@link SchemaStatics.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
299
- * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
300
- */
301
- readonly requiredRecursive: <
302
- const T extends System_Unsafe.ImplicitAllowedTypesUnsafe,
303
- const TCustomMetadata = unknown,
304
- >(
305
- t: T,
306
- props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
307
- ) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Required, T, TCustomMetadata>;
308
- }
309
-
310
- const defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => []);
311
-
312
- // The following overloads for optional and required are used to get around the fact that
313
- // the compiler can't infer that UnannotateImplicitAllowedTypes<T> is equal to T when T is known to extend ImplicitAllowedTypes
314
-
315
- function optional<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
316
- t: T,
317
- props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">,
318
- ): FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata>;
319
-
320
- function optional<
321
- const T extends ImplicitAnnotatedAllowedTypes,
322
- const TCustomMetadata = unknown,
323
- >(
324
- t: T,
325
- props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">,
326
- ): FieldSchemaAlpha<FieldKind.Optional, UnannotateImplicitAllowedTypes<T>, TCustomMetadata>;
327
-
328
- function optional<
329
- const T extends ImplicitAnnotatedAllowedTypes,
330
- const TCustomMetadata = unknown,
331
- >(
332
- t: T,
333
- props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">,
334
- ): FieldSchemaAlpha<FieldKind.Optional, UnannotateImplicitAllowedTypes<T>, TCustomMetadata> {
335
- return createFieldSchema(FieldKind.Optional, t, {
336
- defaultProvider: defaultOptionalProvider,
337
- ...props,
338
- });
339
- }
340
-
341
- function required<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
342
- t: T,
343
- props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">,
344
- ): FieldSchemaAlpha<FieldKind.Required, T, TCustomMetadata>;
345
-
346
- function required<
347
- const T extends ImplicitAnnotatedAllowedTypes,
348
- const TCustomMetadata = unknown,
349
- >(
350
- t: T,
351
- props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">,
352
- ): FieldSchemaAlpha<FieldKind.Required, UnannotateImplicitAllowedTypes<T>, TCustomMetadata>;
353
-
354
- function required<
355
- const T extends ImplicitAnnotatedAllowedTypes,
356
- const TCustomMetadata = unknown,
357
- >(
358
- t: T,
359
- props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">,
360
- ): FieldSchemaAlpha<FieldKind.Required, UnannotateImplicitAllowedTypes<T>, TCustomMetadata> {
361
- return createFieldSchema(FieldKind.Required, t, props);
362
- }
363
-
364
- /**
365
- * Implementation of {@link SchemaStatics}.
366
- * @remarks
367
- * Entries can use more specific types than {@link SchemaStatics} requires to be more useful for non-public consumers.
368
- * Additional non-public members are in {@link schemaStatics}.
369
- */
370
- export const schemaStaticsBase = {
371
- string: stringSchema,
372
- number: numberSchema,
373
- boolean: booleanSchema,
374
- null: nullSchema,
375
- handle: handleSchema,
376
- leaves: [stringSchema, numberSchema, booleanSchema, nullSchema, handleSchema],
377
-
378
- optional,
379
-
380
- required,
381
-
382
- optionalRecursive: <
383
- const T extends System_Unsafe.ImplicitAllowedTypesUnsafe,
384
- const TCustomMetadata = unknown,
385
- >(
386
- t: T,
387
- props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">,
388
- ): FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata> => {
389
- return createFieldSchemaUnsafe(FieldKind.Optional, t, {
390
- defaultProvider: defaultOptionalProvider,
391
- ...props,
392
- });
393
- },
394
-
395
- requiredRecursive: <
396
- const T extends System_Unsafe.ImplicitAllowedTypesUnsafe,
397
- const TCustomMetadata = unknown,
398
- >(
399
- t: T,
400
- props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider">,
401
- ): FieldSchemaAlphaUnsafe<FieldKind.Required, T, TCustomMetadata> => {
402
- return createFieldSchemaUnsafe(FieldKind.Required, t, props);
403
- },
404
- } as const satisfies SchemaStatics;
405
-
406
- /**
407
- * Unstable extensions to {@link schemaStaticsBase}.
408
- */
409
- export const schemaStatics = {
410
- ...schemaStaticsBase,
411
- identifier: <const TCustomMetadata = unknown>(
412
- props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
413
- ): FieldSchemaAlpha<FieldKind.Identifier, typeof stringSchema, TCustomMetadata> => {
414
- return createFieldSchema(FieldKind.Identifier, stringSchema, props);
415
- },
416
- } as const;
417
-
418
174
  const schemaStaticsPublic: SchemaStatics = schemaStatics;
419
175
 
420
176
  // TODO:
@@ -18,12 +18,12 @@ import {
18
18
  import {
19
19
  defaultSchemaFactoryObjectOptions,
20
20
  SchemaFactory,
21
- schemaStatics,
22
21
  structuralName,
23
22
  type NodeSchemaOptionsAlpha,
24
23
  type SchemaFactoryObjectOptions,
25
24
  type ScopedSchemaName,
26
25
  } from "./schemaFactory.js";
26
+ import { schemaStatics } from "./schemaStatics.js";
27
27
  import type { ImplicitAnnotatedFieldSchema, ImplicitFieldSchema } from "../fieldSchema.js";
28
28
  import type { RestrictiveStringRecord } from "../../util/index.js";
29
29
  import type {
@@ -35,7 +35,10 @@ import type {
35
35
  WithType,
36
36
  ImplicitAllowedTypes,
37
37
  ImplicitAnnotatedAllowedTypes,
38
+ AnnotatedAllowedType,
39
+ LazyItem,
38
40
  } from "../core/index.js";
41
+ import { normalizeToAnnotatedAllowedType, createSchemaUpgrade } from "../core/index.js";
39
42
  import type {
40
43
  ArrayNodeCustomizableSchemaUnsafe,
41
44
  MapNodeCustomizableSchemaUnsafe,
@@ -44,6 +47,166 @@ import type {
44
47
  } from "./typesUnsafe.js";
45
48
  import type { SimpleObjectNodeSchema } from "../simpleSchema.js";
46
49
 
50
+ // This import prevents a large number of type references in the API reports from showing up as *_2.
51
+ /* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */
52
+ import type {
53
+ FieldProps,
54
+ FieldSchemaAlpha,
55
+ FieldPropsAlpha,
56
+ FieldKind,
57
+ } from "../fieldSchema.js";
58
+ import type { LeafSchema } from "../leafNodeSchema.js";
59
+ import type { SimpleLeafNodeSchema } from "../simpleSchema.js";
60
+ import type { UnannotateImplicitAllowedTypes } from "../core/index.js";
61
+ import type { FieldSchemaAlphaUnsafe } from "./typesUnsafe.js";
62
+ /* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */
63
+
64
+ /**
65
+ * Stateless APIs exposed via {@link SchemaFactoryAlpha} as both instance properties and as statics.
66
+ * @remarks
67
+ * See {@link SchemaStatics} for why this is useful.
68
+ * @system @sealed @alpha
69
+ */
70
+ export interface SchemaStaticsAlpha {
71
+ /**
72
+ * Declares a staged type in a set of {@link AllowedTypes}.
73
+ *
74
+ * @remarks
75
+ * Staged allowed types add support for loading documents which may or may not permit an allowed type in a location in a schema.
76
+ * This allows for an incremental rollout of a schema change to add a {@link TreeNodeSchema} to an {@link AllowedTypes} without breaking cross version collaboration.
77
+ *
78
+ * 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.
79
+ * 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.
80
+ * This will also require {@link TreeView.upgradeSchema|upgrading the schema} for existing documents.
81
+ *
82
+ * Using a staged allowed type in a schema is just like using the schema as an allowed type with the following exceptions:
83
+ *
84
+ * 1. {@link TreeView.initialize} will omit the staged allowed type from the newly created stored schema.
85
+ * 2. {@link TreeView.upgradeSchema} will omit the staged allowed type from the the upgraded stored schema.
86
+ * 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.
87
+ * 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.
88
+ *
89
+ * Currently, `staged` is not supported in the recursive type APIs: this is a known limitation which future versions of the API will address.
90
+ *
91
+ * @example
92
+ * Suppose you have a schema which has a field that allows some type `A`, but you want to add support for type `B`.
93
+ *
94
+ * The first change is to used to mark the new type as staged, replacing `A` in the schema with `[A, SchemaStaticsAlpha.staged(B)]`.
95
+ * 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.
96
+ *
97
+ * 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.
98
+ * This updated version of the app will need to call {@link TreeView.upgradeSchema} when opening documents created by earlier versions.
99
+ *
100
+ * Adding a `B` schema as an option in the root could look like this:
101
+ * ```typescript
102
+ * const factory = new SchemaFactoryAlpha("test");
103
+ * class A extends factory.objectAlpha("A", {}) {}
104
+ * class B extends factory.objectAlpha("B", {}) {}
105
+ *
106
+ * // Does not support B
107
+ * const configBefore = new TreeViewConfigurationAlpha({
108
+ * schema: A,
109
+ * });
110
+ *
111
+ * // Supports documents with or without B
112
+ * const configStaged = new TreeViewConfigurationAlpha({
113
+ * // Adds staged support for B.
114
+ * // Currently this requires wrapping the root field with `SchemaFactoryAlpha.required`:
115
+ * // this is normally implicitly included, but is currently required while the "staged" APIs are `@alpha`.
116
+ * schema: SchemaFactoryAlpha.required([A, SchemaFactoryAlpha.staged(B)]),
117
+ * });
118
+ *
119
+ * // Only supports documents with A and B: can be used to upgrade schema to add B.
120
+ * const configAfter = new TreeViewConfigurationAlpha({
121
+ * schema: [A, B],
122
+ * });
123
+ * ```
124
+ * @example
125
+ * Below is a full example of how the schema migration process works.
126
+ * 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}.
127
+ * ```typescript
128
+ * // Schema A: only number allowed
129
+ * const schemaA = SchemaFactoryAlpha.optional([SchemaFactoryAlpha.number]);
130
+ *
131
+ * // Schema B: number or string (string is staged)
132
+ * const schemaB = SchemaFactoryAlpha.optional([
133
+ * SchemaFactoryAlpha.number,
134
+ * SchemaFactoryAlpha.staged(SchemaFactoryAlpha.string),
135
+ * ]);
136
+ *
137
+ * // Schema C: number or string, both fully allowed
138
+ * const schemaC = SchemaFactoryAlpha.optional([
139
+ * SchemaFactoryAlpha.number,
140
+ * SchemaFactoryAlpha.string,
141
+ * ]);
142
+ *
143
+ * // Initialize with schema A.
144
+ * const configA = new TreeViewConfiguration({
145
+ * schema: schemaA,
146
+ * });
147
+ * const viewA = treeA.viewWith(configA);
148
+ * viewA.initialize(5);
149
+ *
150
+ * // Since we are running all the different versions of the app in the same process making changes synchronously,
151
+ * // an explicit flush is needed to make them available to each other.
152
+ * synchronizeTrees();
153
+ *
154
+ * assert.deepEqual(viewA.root, 5);
155
+ *
156
+ * // View the same document with a second tree using schema B.
157
+ * const configB = new TreeViewConfiguration({
158
+ * schema: schemaB,
159
+ * });
160
+ * const viewB = treeB.viewWith(configB);
161
+ * // B cannot write strings to the root.
162
+ * assert.throws(() => (viewB.root = "test"));
163
+ *
164
+ * // View the same document with a third tree using schema C.
165
+ * const configC = new TreeViewConfiguration({
166
+ * schema: schemaC,
167
+ * });
168
+ * const viewC = treeC.viewWith(configC);
169
+ * // Upgrade to schema C
170
+ * viewC.upgradeSchema();
171
+ * // Use the newly enabled schema.
172
+ * viewC.root = "test";
173
+ *
174
+ * synchronizeTrees();
175
+ *
176
+ * // View A is now incompatible with the stored schema:
177
+ * assert.equal(viewA.compatibility.canView, false);
178
+ *
179
+ * // View B can still read the document, and now sees the string root which relies on the staged schema.
180
+ * assert.deepEqual(viewB.root, "test");
181
+ * ```
182
+ * @privateRemarks
183
+ * TODO:#44317 staged allowed types rely on schema validation of stored schema to output errors, these errors are not very
184
+ * user friendly and should be improved, particularly in the case of staged allowed types
185
+ *
186
+ * 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.
187
+ *
188
+ * TODO: AB#45711: Update the docs above when recursive type support is added.
189
+ */
190
+ staged: <const T extends LazyItem<TreeNodeSchema>>(
191
+ t: T | AnnotatedAllowedType<T>,
192
+ ) => AnnotatedAllowedType<T>;
193
+ }
194
+
195
+ const schemaStaticsAlpha: SchemaStaticsAlpha = {
196
+ staged: <const T extends LazyItem<TreeNodeSchema>>(
197
+ t: T | AnnotatedAllowedType<T>,
198
+ ): AnnotatedAllowedType<T> => {
199
+ const annotatedType = normalizeToAnnotatedAllowedType(t);
200
+ return {
201
+ type: annotatedType.type,
202
+ metadata: {
203
+ ...annotatedType.metadata,
204
+ stagedSchemaUpgrade: createSchemaUpgrade(),
205
+ },
206
+ };
207
+ },
208
+ };
209
+
47
210
  /**
48
211
  * {@link SchemaFactory} with additional alpha APIs.
49
212
  *
@@ -213,6 +376,16 @@ export class SchemaFactoryAlpha<
213
376
  */
214
377
  public override readonly requiredRecursive = schemaStatics.requiredRecursive;
215
378
 
379
+ /**
380
+ * {@inheritDoc SchemaStaticsAlpha.staged}
381
+ */
382
+ public static staged = schemaStaticsAlpha.staged;
383
+
384
+ /**
385
+ * {@inheritDoc SchemaStaticsAlpha.staged}
386
+ */
387
+ public staged = schemaStaticsAlpha.staged;
388
+
216
389
  /**
217
390
  * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.
218
391
  *
@@ -13,31 +13,7 @@ import type {
13
13
  InsertableTreeNodeFromImplicitAllowedTypes,
14
14
  } from "../core/index.js";
15
15
  import type { InsertableObjectFromSchemaRecord } from "../node-kinds/index.js";
16
- import {
17
- type FieldKind,
18
- type FieldProps,
19
- createFieldSchema,
20
- type ImplicitFieldSchema,
21
- } from "../fieldSchema.js";
22
-
23
- import type { FieldSchemaAlphaUnsafe, System_Unsafe } from "./typesUnsafe.js";
24
-
25
- export function createFieldSchemaUnsafe<
26
- Kind extends FieldKind,
27
- Types extends System_Unsafe.ImplicitAllowedTypesUnsafe,
28
- TCustomMetadata = unknown,
29
- >(
30
- kind: Kind,
31
- allowedTypes: Types,
32
- props?: FieldProps<TCustomMetadata>,
33
- ): FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata> {
34
- // 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
35
- return createFieldSchema(
36
- kind,
37
- allowedTypes as ImplicitAllowedTypes & Types,
38
- props,
39
- ) as FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata>;
40
- }
16
+ import type { ImplicitFieldSchema } from "../fieldSchema.js";
41
17
 
42
18
  /**
43
19
  * Compile time check for validity of a recursive schema.