@fluidframework/tree 2.74.0-365691 → 2.74.0-368706

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 (1243) hide show
  1. package/.vscode/settings.json +2 -2
  2. package/api-report/tree.alpha.api.md +119 -85
  3. package/api-report/tree.beta.api.md +0 -1
  4. package/api-report/tree.legacy.beta.api.md +0 -1
  5. package/api-report/tree.legacy.public.api.md +0 -1
  6. package/api-report/tree.public.api.md +0 -1
  7. package/dist/alpha.d.ts +3 -2
  8. package/dist/codec/codec.d.ts +14 -1
  9. package/dist/codec/codec.d.ts.map +1 -1
  10. package/dist/codec/codec.js +11 -0
  11. package/dist/codec/codec.js.map +1 -1
  12. package/dist/codec/versioned/codec.d.ts +1 -1
  13. package/dist/codec/versioned/codec.d.ts.map +1 -1
  14. package/dist/codec/versioned/codec.js.map +1 -1
  15. package/dist/codec/versioned/format.d.ts +4 -1
  16. package/dist/codec/versioned/format.d.ts.map +1 -1
  17. package/dist/codec/versioned/format.js +4 -1
  18. package/dist/codec/versioned/format.js.map +1 -1
  19. package/dist/core/change-family/changeFamily.d.ts +4 -1
  20. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  21. package/dist/core/change-family/changeFamily.js.map +1 -1
  22. package/dist/core/change-family/index.d.ts +1 -1
  23. package/dist/core/change-family/index.d.ts.map +1 -1
  24. package/dist/core/change-family/index.js.map +1 -1
  25. package/dist/core/index.d.ts +3 -3
  26. package/dist/core/index.d.ts.map +1 -1
  27. package/dist/core/index.js +7 -4
  28. package/dist/core/index.js.map +1 -1
  29. package/dist/core/rebase/changeRebaser.d.ts +6 -1
  30. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  31. package/dist/core/rebase/changeRebaser.js.map +1 -1
  32. package/dist/core/rebase/index.d.ts +1 -1
  33. package/dist/core/rebase/index.d.ts.map +1 -1
  34. package/dist/core/rebase/index.js +2 -1
  35. package/dist/core/rebase/index.js.map +1 -1
  36. package/dist/core/rebase/types.d.ts +2 -1
  37. package/dist/core/rebase/types.d.ts.map +1 -1
  38. package/dist/core/rebase/types.js +5 -1
  39. package/dist/core/rebase/types.js.map +1 -1
  40. package/dist/core/rebase/utils.d.ts.map +1 -1
  41. package/dist/core/rebase/utils.js +25 -7
  42. package/dist/core/rebase/utils.js.map +1 -1
  43. package/dist/core/tree/detachedFieldIndex.d.ts +40 -13
  44. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  45. package/dist/core/tree/detachedFieldIndex.js +21 -12
  46. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  47. package/dist/core/tree/index.d.ts +4 -3
  48. package/dist/core/tree/index.d.ts.map +1 -1
  49. package/dist/core/tree/index.js +6 -2
  50. package/dist/core/tree/index.js.map +1 -1
  51. package/dist/core/tree/pathTree.d.ts +11 -3
  52. package/dist/core/tree/pathTree.d.ts.map +1 -1
  53. package/dist/core/tree/pathTree.js +14 -2
  54. package/dist/core/tree/pathTree.js.map +1 -1
  55. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/basicChunk.js +7 -0
  57. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  58. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/chunkTree.js +4 -1
  60. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts +14 -6
  62. package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js.map +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +7 -2
  65. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  66. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +90 -42
  67. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  68. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +234 -69
  69. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  70. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +4 -4
  71. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  72. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +33 -28
  73. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  74. package/dist/feature-libraries/default-schema/index.d.ts +2 -1
  75. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  76. package/dist/feature-libraries/default-schema/index.js +4 -2
  77. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  78. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +36 -0
  79. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +1 -0
  80. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js +126 -0
  81. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js.map +1 -0
  82. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +7 -6
  83. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  84. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +15 -0
  85. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  86. package/dist/feature-libraries/deltaUtils.d.ts +1 -0
  87. package/dist/feature-libraries/deltaUtils.d.ts.map +1 -1
  88. package/dist/feature-libraries/deltaUtils.js +6 -1
  89. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  90. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +30 -8
  91. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  92. package/dist/feature-libraries/detachedFieldIndexSummarizer.js +41 -11
  93. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  94. package/dist/feature-libraries/flex-tree/context.d.ts +9 -0
  95. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  96. package/dist/feature-libraries/flex-tree/context.js +6 -0
  97. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  98. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  99. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  100. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  101. package/dist/feature-libraries/flex-tree/lazyField.d.ts +8 -7
  102. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  103. package/dist/feature-libraries/flex-tree/lazyField.js +37 -8
  104. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  105. package/dist/feature-libraries/forest-summary/codec.d.ts +2 -2
  106. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  107. package/dist/feature-libraries/forest-summary/codec.js +4 -4
  108. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  109. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +9 -13
  110. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  111. package/dist/feature-libraries/forest-summary/forestSummarizer.js +21 -26
  112. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  113. package/dist/feature-libraries/forest-summary/format.d.ts +41 -5
  114. package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
  115. package/dist/feature-libraries/forest-summary/format.js +7 -7
  116. package/dist/feature-libraries/forest-summary/format.js.map +1 -1
  117. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +11 -9
  118. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  119. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +16 -29
  120. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  121. package/dist/feature-libraries/forest-summary/index.d.ts +2 -1
  122. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  123. package/dist/feature-libraries/forest-summary/index.js +3 -2
  124. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  125. package/dist/feature-libraries/forest-summary/summaryTypes.d.ts +47 -0
  126. package/dist/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -0
  127. package/dist/feature-libraries/forest-summary/summaryTypes.js +57 -0
  128. package/dist/feature-libraries/forest-summary/summaryTypes.js.map +1 -0
  129. package/dist/feature-libraries/index.d.ts +4 -4
  130. package/dist/feature-libraries/index.d.ts.map +1 -1
  131. package/dist/feature-libraries/index.js +7 -3
  132. package/dist/feature-libraries/index.js.map +1 -1
  133. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  134. package/dist/feature-libraries/mapTreeCursor.js +1 -0
  135. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  136. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  137. package/dist/feature-libraries/mitigatedChangeFamily.js +2 -2
  138. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  139. package/dist/feature-libraries/modular-schema/comparison.d.ts +18 -2
  140. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  141. package/dist/feature-libraries/modular-schema/comparison.js +54 -3
  142. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  143. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +97 -21
  144. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  145. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +4 -7
  146. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  147. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +20 -52
  148. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  149. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  150. package/dist/feature-libraries/modular-schema/fieldKind.d.ts +25 -13
  151. package/dist/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  152. package/dist/feature-libraries/modular-schema/fieldKind.js +0 -21
  153. package/dist/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  154. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  155. package/dist/feature-libraries/modular-schema/genericFieldKind.js +7 -10
  156. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  157. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +2 -2
  158. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  159. package/dist/feature-libraries/modular-schema/index.d.ts +5 -5
  160. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  161. package/dist/feature-libraries/modular-schema/index.js +12 -8
  162. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  163. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +17 -0
  164. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
  165. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +388 -0
  166. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
  167. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +17 -0
  168. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
  169. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +413 -0
  170. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
  171. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  172. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  173. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +8 -284
  174. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  175. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +48 -15
  176. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  177. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1298 -465
  178. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  179. package/dist/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +2 -2
  180. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
  181. package/dist/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +5 -5
  182. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
  183. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +146 -0
  184. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
  185. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +32 -0
  186. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
  187. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +50 -10
  188. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  189. package/dist/feature-libraries/modular-schema/modularChangeTypes.js +24 -3
  190. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  191. package/dist/feature-libraries/optional-field/index.d.ts +2 -2
  192. package/dist/feature-libraries/optional-field/index.d.ts.map +1 -1
  193. package/dist/feature-libraries/optional-field/index.js +1 -2
  194. package/dist/feature-libraries/optional-field/index.js.map +1 -1
  195. package/dist/feature-libraries/optional-field/optionalField.d.ts +5 -26
  196. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  197. package/dist/feature-libraries/optional-field/optionalField.js +217 -451
  198. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  199. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +24 -33
  200. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  201. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  202. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  203. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  204. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js +57 -28
  205. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  206. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +27 -8
  207. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  208. package/dist/feature-libraries/schema-index/schemaSummarizer.js +42 -16
  209. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  210. package/dist/feature-libraries/sequence-field/compose.d.ts +6 -7
  211. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  212. package/dist/feature-libraries/sequence-field/compose.js +80 -256
  213. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  214. package/dist/feature-libraries/sequence-field/helperTypes.d.ts +14 -10
  215. package/dist/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  216. package/dist/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  217. package/dist/feature-libraries/sequence-field/index.d.ts +2 -3
  218. package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
  219. package/dist/feature-libraries/sequence-field/index.js +1 -3
  220. package/dist/feature-libraries/sequence-field/index.js.map +1 -1
  221. package/dist/feature-libraries/sequence-field/invert.d.ts +3 -3
  222. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  223. package/dist/feature-libraries/sequence-field/invert.js +65 -167
  224. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  225. package/dist/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  226. package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  227. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  228. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +4 -56
  229. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  230. package/dist/feature-libraries/sequence-field/moveEffectTable.js +7 -86
  231. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  232. package/dist/feature-libraries/sequence-field/rebase.d.ts +3 -3
  233. package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  234. package/dist/feature-libraries/sequence-field/rebase.js +106 -112
  235. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  236. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  237. package/dist/feature-libraries/sequence-field/replaceRevisions.js +16 -33
  238. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  239. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  240. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +0 -2
  241. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  242. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +22 -4
  243. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  244. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +358 -179
  245. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  246. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  247. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +20 -60
  248. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  249. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  250. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  251. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +10 -10
  252. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  253. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -2
  254. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  255. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +14 -109
  256. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  257. package/dist/feature-libraries/sequence-field/types.d.ts +30 -59
  258. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  259. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  260. package/dist/feature-libraries/sequence-field/utils.d.ts +15 -24
  261. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  262. package/dist/feature-libraries/sequence-field/utils.js +111 -299
  263. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  264. package/dist/index.d.ts +1 -1
  265. package/dist/index.d.ts.map +1 -1
  266. package/dist/index.js +3 -3
  267. package/dist/index.js.map +1 -1
  268. package/dist/packageVersion.d.ts +1 -1
  269. package/dist/packageVersion.js +1 -1
  270. package/dist/packageVersion.js.map +1 -1
  271. package/dist/shared-tree/independentView.d.ts +1 -1
  272. package/dist/shared-tree/independentView.d.ts.map +1 -1
  273. package/dist/shared-tree/independentView.js.map +1 -1
  274. package/dist/shared-tree/index.d.ts +1 -1
  275. package/dist/shared-tree/index.d.ts.map +1 -1
  276. package/dist/shared-tree/index.js.map +1 -1
  277. package/dist/shared-tree/schematizeTree.d.ts +4 -4
  278. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  279. package/dist/shared-tree/schematizeTree.js +2 -1
  280. package/dist/shared-tree/schematizeTree.js.map +1 -1
  281. package/dist/shared-tree/schematizingTreeView.d.ts +1 -5
  282. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  283. package/dist/shared-tree/schematizingTreeView.js +32 -33
  284. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  285. package/dist/shared-tree/sharedTree.d.ts +11 -5
  286. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  287. package/dist/shared-tree/sharedTree.js +14 -4
  288. package/dist/shared-tree/sharedTree.js.map +1 -1
  289. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  290. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  291. package/dist/shared-tree/sharedTreeChangeCodecs.js +1 -0
  292. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  293. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts +20 -8
  294. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  295. package/dist/shared-tree/sharedTreeChangeEnricher.js +25 -11
  296. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  297. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
  298. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  299. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  300. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  301. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +16 -6
  302. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  303. package/dist/shared-tree/sharedTreeEditBuilder.js +13 -6
  304. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  305. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  306. package/dist/shared-tree/treeAlpha.js +1 -1
  307. package/dist/shared-tree/treeAlpha.js.map +1 -1
  308. package/dist/shared-tree/treeCheckout.d.ts +12 -10
  309. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  310. package/dist/shared-tree/treeCheckout.js +66 -17
  311. package/dist/shared-tree/treeCheckout.js.map +1 -1
  312. package/dist/shared-tree-core/branch.d.ts +3 -2
  313. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  314. package/dist/shared-tree-core/branch.js +4 -3
  315. package/dist/shared-tree-core/branch.js.map +1 -1
  316. package/dist/shared-tree-core/editManager.d.ts +2 -2
  317. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  318. package/dist/shared-tree-core/editManager.js +9 -9
  319. package/dist/shared-tree-core/editManager.js.map +1 -1
  320. package/dist/shared-tree-core/editManagerCodecs.d.ts +4 -0
  321. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  322. package/dist/shared-tree-core/editManagerCodecs.js +16 -6
  323. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  324. package/{lib/shared-tree-core/editManagerCodecsV5.d.ts → dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts} +3 -3
  325. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -0
  326. package/dist/shared-tree-core/{editManagerCodecsV5.js → editManagerCodecsVSharedBranches.js} +7 -7
  327. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -0
  328. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +20 -6
  329. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  330. package/dist/shared-tree-core/editManagerFormatCommons.js +22 -7
  331. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  332. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  333. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  334. package/dist/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  335. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  336. package/dist/shared-tree-core/{editManagerFormatV5.d.ts → editManagerFormatVSharedBranches.d.ts} +3 -3
  337. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -0
  338. package/dist/shared-tree-core/{editManagerFormatV5.js → editManagerFormatVSharedBranches.js} +2 -2
  339. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -0
  340. package/dist/shared-tree-core/editManagerSummarizer.d.ts +29 -9
  341. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  342. package/dist/shared-tree-core/editManagerSummarizer.js +41 -13
  343. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  344. package/dist/shared-tree-core/index.d.ts +5 -3
  345. package/dist/shared-tree-core/index.d.ts.map +1 -1
  346. package/dist/shared-tree-core/index.js +8 -1
  347. package/dist/shared-tree-core/index.js.map +1 -1
  348. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  349. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  350. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  351. package/{lib/shared-tree-core/messageCodecV5.d.ts → dist/shared-tree-core/messageCodecVSharedBranches.d.ts} +2 -2
  352. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -0
  353. package/dist/shared-tree-core/{messageCodecV5.js → messageCodecVSharedBranches.js} +6 -6
  354. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -0
  355. package/dist/shared-tree-core/messageCodecs.d.ts +4 -0
  356. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  357. package/dist/shared-tree-core/messageCodecs.js +16 -6
  358. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  359. package/dist/shared-tree-core/messageFormat.d.ts +20 -6
  360. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  361. package/dist/shared-tree-core/messageFormat.js +22 -7
  362. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  363. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
  364. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  365. package/dist/shared-tree-core/messageFormatV1ToV4.js +8 -1
  366. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  367. package/dist/shared-tree-core/{messageFormatV5.d.ts → messageFormatVSharedBranches.d.ts} +5 -7
  368. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -0
  369. package/dist/shared-tree-core/{messageFormatV5.js → messageFormatVSharedBranches.js} +3 -2
  370. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -0
  371. package/dist/shared-tree-core/sharedTreeCore.d.ts +14 -47
  372. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  373. package/dist/shared-tree-core/sharedTreeCore.js +30 -18
  374. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  375. package/dist/shared-tree-core/summaryTypes.d.ts +94 -0
  376. package/dist/shared-tree-core/summaryTypes.d.ts.map +1 -0
  377. package/dist/shared-tree-core/summaryTypes.js +47 -0
  378. package/dist/shared-tree-core/summaryTypes.js.map +1 -0
  379. package/dist/shared-tree-core/versionedSummarizer.d.ts +67 -0
  380. package/dist/shared-tree-core/versionedSummarizer.d.ts.map +1 -0
  381. package/dist/shared-tree-core/versionedSummarizer.js +63 -0
  382. package/dist/shared-tree-core/versionedSummarizer.js.map +1 -0
  383. package/dist/simple-tree/api/configuration.d.ts +3 -26
  384. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  385. package/dist/simple-tree/api/configuration.js +10 -21
  386. package/dist/simple-tree/api/configuration.js.map +1 -1
  387. package/dist/simple-tree/api/dirtyIndex.d.ts +11 -0
  388. package/dist/simple-tree/api/dirtyIndex.d.ts.map +1 -1
  389. package/dist/simple-tree/api/dirtyIndex.js +7 -0
  390. package/dist/simple-tree/api/dirtyIndex.js.map +1 -1
  391. package/dist/simple-tree/api/discrepancies.d.ts +1 -1
  392. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
  393. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  394. package/dist/simple-tree/api/getSimpleSchema.d.ts +3 -3
  395. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  396. package/dist/simple-tree/api/getSimpleSchema.js +9 -3
  397. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  398. package/dist/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  399. package/dist/simple-tree/api/incrementalAllowedTypes.d.ts.map +1 -1
  400. package/dist/simple-tree/api/incrementalAllowedTypes.js +7 -0
  401. package/dist/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  402. package/dist/simple-tree/api/index.d.ts +3 -4
  403. package/dist/simple-tree/api/index.d.ts.map +1 -1
  404. package/dist/simple-tree/api/index.js +4 -5
  405. package/dist/simple-tree/api/index.js.map +1 -1
  406. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +1 -1
  407. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  408. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  409. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +5 -5
  410. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  411. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  412. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  413. package/dist/simple-tree/api/schemaFactoryRecursive.js +0 -1
  414. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  415. package/dist/simple-tree/api/schemaFromSimple.d.ts +6 -1
  416. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  417. package/dist/simple-tree/api/schemaFromSimple.js +5 -0
  418. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  419. package/dist/simple-tree/api/schemaStatics.d.ts +12 -12
  420. package/dist/simple-tree/api/simpleSchemaCodec.d.ts +15 -3
  421. package/dist/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -1
  422. package/dist/simple-tree/api/simpleSchemaCodec.js +18 -6
  423. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  424. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  425. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  426. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  427. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +8 -1
  428. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  429. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +13 -8
  430. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  431. package/dist/simple-tree/api/typesUnsafe.d.ts +3 -3
  432. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  433. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  434. package/dist/simple-tree/core/allowedTypes.d.ts +2 -2
  435. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  436. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  437. package/dist/simple-tree/core/index.d.ts +1 -1
  438. package/dist/simple-tree/core/index.d.ts.map +1 -1
  439. package/dist/simple-tree/core/index.js +2 -3
  440. package/dist/simple-tree/core/index.js.map +1 -1
  441. package/dist/simple-tree/core/toStored.d.ts +17 -15
  442. package/dist/simple-tree/core/toStored.d.ts.map +1 -1
  443. package/dist/simple-tree/core/toStored.js +5 -40
  444. package/dist/simple-tree/core/toStored.js.map +1 -1
  445. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +15 -15
  446. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  447. package/dist/simple-tree/core/unhydratedFlexTree.js +59 -8
  448. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  449. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  450. package/dist/simple-tree/core/walkSchema.js +4 -0
  451. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  452. package/dist/simple-tree/createContext.d.ts.map +1 -1
  453. package/dist/simple-tree/createContext.js +20 -5
  454. package/dist/simple-tree/createContext.js.map +1 -1
  455. package/dist/simple-tree/fieldSchema.d.ts +7 -7
  456. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  457. package/dist/simple-tree/fieldSchema.js.map +1 -1
  458. package/dist/simple-tree/index.d.ts +8 -7
  459. package/dist/simple-tree/index.d.ts.map +1 -1
  460. package/dist/simple-tree/index.js +15 -12
  461. package/dist/simple-tree/index.js.map +1 -1
  462. package/dist/simple-tree/leafNodeSchema.d.ts +5 -5
  463. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  464. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  465. package/dist/simple-tree/node-kinds/array/arrayNode.js +5 -3
  466. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  467. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +3 -3
  468. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  469. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  470. package/dist/simple-tree/node-kinds/common.d.ts.map +1 -1
  471. package/dist/simple-tree/node-kinds/common.js +1 -1
  472. package/dist/simple-tree/node-kinds/common.js.map +1 -1
  473. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  474. package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
  475. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  476. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts +3 -3
  477. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  478. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  479. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  480. package/dist/simple-tree/node-kinds/object/objectNode.js +18 -18
  481. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  482. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +2 -2
  483. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  484. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  485. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  486. package/dist/simple-tree/node-kinds/record/recordNode.js +4 -2
  487. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  488. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -3
  489. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  490. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  491. package/dist/simple-tree/prepareForInsertion.d.ts +54 -47
  492. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  493. package/dist/simple-tree/prepareForInsertion.js +183 -125
  494. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  495. package/dist/simple-tree/simpleSchema.d.ts +55 -23
  496. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  497. package/dist/simple-tree/simpleSchema.js +17 -0
  498. package/dist/simple-tree/simpleSchema.js.map +1 -1
  499. package/dist/simple-tree/simpleSchemaFormatV1.d.ts +1 -1
  500. package/dist/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -1
  501. package/dist/simple-tree/simpleSchemaFormatV1.js +8 -1
  502. package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  503. package/dist/simple-tree/toStoredSchema.d.ts +58 -11
  504. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  505. package/dist/simple-tree/toStoredSchema.js +205 -30
  506. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  507. package/dist/simple-tree/treeSchema.d.ts +23 -0
  508. package/dist/simple-tree/treeSchema.d.ts.map +1 -0
  509. package/dist/simple-tree/treeSchema.js +25 -0
  510. package/dist/simple-tree/treeSchema.js.map +1 -0
  511. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +13 -4
  512. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  513. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +29 -11
  514. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  515. package/dist/tableSchema.d.ts +117 -63
  516. package/dist/tableSchema.d.ts.map +1 -1
  517. package/dist/tableSchema.js +159 -58
  518. package/dist/tableSchema.js.map +1 -1
  519. package/dist/treeFactory.d.ts.map +1 -1
  520. package/dist/treeFactory.js +17 -3
  521. package/dist/treeFactory.js.map +1 -1
  522. package/dist/util/index.d.ts +2 -1
  523. package/dist/util/index.d.ts.map +1 -1
  524. package/dist/util/index.js +4 -1
  525. package/dist/util/index.js.map +1 -1
  526. package/dist/util/rangeMap.d.ts +24 -12
  527. package/dist/util/rangeMap.d.ts.map +1 -1
  528. package/dist/util/rangeMap.js +46 -6
  529. package/dist/util/rangeMap.js.map +1 -1
  530. package/dist/util/readSnapshotBlob.d.ts +13 -0
  531. package/dist/util/readSnapshotBlob.d.ts.map +1 -0
  532. package/dist/util/readSnapshotBlob.js +18 -0
  533. package/dist/util/readSnapshotBlob.js.map +1 -0
  534. package/lib/alpha.d.ts +3 -2
  535. package/lib/codec/codec.d.ts +14 -1
  536. package/lib/codec/codec.d.ts.map +1 -1
  537. package/lib/codec/codec.js +11 -0
  538. package/lib/codec/codec.js.map +1 -1
  539. package/lib/codec/versioned/codec.d.ts +1 -1
  540. package/lib/codec/versioned/codec.d.ts.map +1 -1
  541. package/lib/codec/versioned/codec.js.map +1 -1
  542. package/lib/codec/versioned/format.d.ts +4 -1
  543. package/lib/codec/versioned/format.d.ts.map +1 -1
  544. package/lib/codec/versioned/format.js +4 -1
  545. package/lib/codec/versioned/format.js.map +1 -1
  546. package/lib/core/change-family/changeFamily.d.ts +4 -1
  547. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  548. package/lib/core/change-family/changeFamily.js.map +1 -1
  549. package/lib/core/change-family/index.d.ts +1 -1
  550. package/lib/core/change-family/index.d.ts.map +1 -1
  551. package/lib/core/change-family/index.js.map +1 -1
  552. package/lib/core/index.d.ts +3 -3
  553. package/lib/core/index.d.ts.map +1 -1
  554. package/lib/core/index.js +2 -2
  555. package/lib/core/index.js.map +1 -1
  556. package/lib/core/rebase/changeRebaser.d.ts +6 -1
  557. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  558. package/lib/core/rebase/changeRebaser.js.map +1 -1
  559. package/lib/core/rebase/index.d.ts +1 -1
  560. package/lib/core/rebase/index.d.ts.map +1 -1
  561. package/lib/core/rebase/index.js +1 -1
  562. package/lib/core/rebase/index.js.map +1 -1
  563. package/lib/core/rebase/types.d.ts +2 -1
  564. package/lib/core/rebase/types.d.ts.map +1 -1
  565. package/lib/core/rebase/types.js +3 -0
  566. package/lib/core/rebase/types.js.map +1 -1
  567. package/lib/core/rebase/utils.d.ts.map +1 -1
  568. package/lib/core/rebase/utils.js +25 -7
  569. package/lib/core/rebase/utils.js.map +1 -1
  570. package/lib/core/tree/detachedFieldIndex.d.ts +40 -13
  571. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  572. package/lib/core/tree/detachedFieldIndex.js +22 -13
  573. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  574. package/lib/core/tree/index.d.ts +4 -3
  575. package/lib/core/tree/index.d.ts.map +1 -1
  576. package/lib/core/tree/index.js +3 -2
  577. package/lib/core/tree/index.js.map +1 -1
  578. package/lib/core/tree/pathTree.d.ts +11 -3
  579. package/lib/core/tree/pathTree.d.ts.map +1 -1
  580. package/lib/core/tree/pathTree.js +12 -1
  581. package/lib/core/tree/pathTree.js.map +1 -1
  582. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  583. package/lib/feature-libraries/chunked-forest/basicChunk.js +8 -1
  584. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  585. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  586. package/lib/feature-libraries/chunked-forest/chunkTree.js +4 -1
  587. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  588. package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts +14 -6
  589. package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts.map +1 -1
  590. package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js.map +1 -1
  591. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +7 -2
  592. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  593. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +90 -42
  594. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  595. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +232 -69
  596. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  597. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +4 -4
  598. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  599. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +34 -29
  600. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  601. package/lib/feature-libraries/default-schema/index.d.ts +2 -1
  602. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  603. package/lib/feature-libraries/default-schema/index.js +2 -1
  604. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  605. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +36 -0
  606. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +1 -0
  607. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js +122 -0
  608. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js.map +1 -0
  609. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +7 -6
  610. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  611. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +15 -0
  612. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  613. package/lib/feature-libraries/deltaUtils.d.ts +1 -0
  614. package/lib/feature-libraries/deltaUtils.d.ts.map +1 -1
  615. package/lib/feature-libraries/deltaUtils.js +5 -1
  616. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  617. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +30 -8
  618. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  619. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +38 -8
  620. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  621. package/lib/feature-libraries/flex-tree/context.d.ts +9 -0
  622. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  623. package/lib/feature-libraries/flex-tree/context.js +6 -0
  624. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  625. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  626. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  627. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  628. package/lib/feature-libraries/flex-tree/lazyField.d.ts +8 -7
  629. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  630. package/lib/feature-libraries/flex-tree/lazyField.js +38 -9
  631. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  632. package/lib/feature-libraries/forest-summary/codec.d.ts +2 -2
  633. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  634. package/lib/feature-libraries/forest-summary/codec.js +5 -5
  635. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  636. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +9 -13
  637. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  638. package/lib/feature-libraries/forest-summary/forestSummarizer.js +17 -22
  639. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  640. package/lib/feature-libraries/forest-summary/format.d.ts +41 -5
  641. package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
  642. package/lib/feature-libraries/forest-summary/format.js +3 -3
  643. package/lib/feature-libraries/forest-summary/format.js.map +1 -1
  644. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +11 -9
  645. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  646. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +13 -26
  647. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  648. package/lib/feature-libraries/forest-summary/index.d.ts +2 -1
  649. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  650. package/lib/feature-libraries/forest-summary/index.js +2 -1
  651. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  652. package/lib/feature-libraries/forest-summary/summaryTypes.d.ts +47 -0
  653. package/lib/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -0
  654. package/lib/feature-libraries/forest-summary/summaryTypes.js +53 -0
  655. package/lib/feature-libraries/forest-summary/summaryTypes.js.map +1 -0
  656. package/lib/feature-libraries/index.d.ts +4 -4
  657. package/lib/feature-libraries/index.d.ts.map +1 -1
  658. package/lib/feature-libraries/index.js +3 -3
  659. package/lib/feature-libraries/index.js.map +1 -1
  660. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  661. package/lib/feature-libraries/mapTreeCursor.js +2 -1
  662. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  663. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  664. package/lib/feature-libraries/mitigatedChangeFamily.js +2 -2
  665. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  666. package/lib/feature-libraries/modular-schema/comparison.d.ts +18 -2
  667. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  668. package/lib/feature-libraries/modular-schema/comparison.js +55 -5
  669. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  670. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +97 -21
  671. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  672. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +3 -5
  673. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  674. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +20 -52
  675. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  676. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  677. package/lib/feature-libraries/modular-schema/fieldKind.d.ts +25 -13
  678. package/lib/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  679. package/lib/feature-libraries/modular-schema/fieldKind.js +0 -21
  680. package/lib/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  681. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  682. package/lib/feature-libraries/modular-schema/genericFieldKind.js +7 -10
  683. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  684. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js +1 -1
  685. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  686. package/lib/feature-libraries/modular-schema/index.d.ts +5 -5
  687. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  688. package/lib/feature-libraries/modular-schema/index.js +4 -3
  689. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  690. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +17 -0
  691. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
  692. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +384 -0
  693. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
  694. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +17 -0
  695. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
  696. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +409 -0
  697. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
  698. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  699. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  700. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +9 -285
  701. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  702. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +48 -15
  703. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  704. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1284 -458
  705. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  706. package/lib/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +2 -2
  707. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
  708. package/lib/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +2 -2
  709. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
  710. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +146 -0
  711. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
  712. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +29 -0
  713. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
  714. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +50 -10
  715. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  716. package/lib/feature-libraries/modular-schema/modularChangeTypes.js +20 -2
  717. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  718. package/lib/feature-libraries/optional-field/index.d.ts +2 -2
  719. package/lib/feature-libraries/optional-field/index.d.ts.map +1 -1
  720. package/lib/feature-libraries/optional-field/index.js +1 -1
  721. package/lib/feature-libraries/optional-field/index.js.map +1 -1
  722. package/lib/feature-libraries/optional-field/optionalField.d.ts +5 -26
  723. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  724. package/lib/feature-libraries/optional-field/optionalField.js +217 -449
  725. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  726. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +24 -33
  727. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  728. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  729. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  730. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  731. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js +55 -26
  732. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  733. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +27 -8
  734. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  735. package/lib/feature-libraries/schema-index/schemaSummarizer.js +38 -12
  736. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  737. package/lib/feature-libraries/sequence-field/compose.d.ts +6 -7
  738. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  739. package/lib/feature-libraries/sequence-field/compose.js +82 -258
  740. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  741. package/lib/feature-libraries/sequence-field/helperTypes.d.ts +14 -10
  742. package/lib/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  743. package/lib/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  744. package/lib/feature-libraries/sequence-field/index.d.ts +2 -3
  745. package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
  746. package/lib/feature-libraries/sequence-field/index.js +0 -1
  747. package/lib/feature-libraries/sequence-field/index.js.map +1 -1
  748. package/lib/feature-libraries/sequence-field/invert.d.ts +3 -3
  749. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  750. package/lib/feature-libraries/sequence-field/invert.js +67 -169
  751. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  752. package/lib/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  753. package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  754. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  755. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +4 -56
  756. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  757. package/lib/feature-libraries/sequence-field/moveEffectTable.js +6 -80
  758. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  759. package/lib/feature-libraries/sequence-field/rebase.d.ts +3 -3
  760. package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  761. package/lib/feature-libraries/sequence-field/rebase.js +108 -114
  762. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  763. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  764. package/lib/feature-libraries/sequence-field/replaceRevisions.js +16 -33
  765. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  766. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  767. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +0 -2
  768. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  769. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +22 -4
  770. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  771. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +350 -175
  772. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  773. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  774. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +21 -61
  775. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  776. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  777. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  778. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +10 -10
  779. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  780. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -2
  781. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  782. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +14 -109
  783. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  784. package/lib/feature-libraries/sequence-field/types.d.ts +30 -59
  785. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  786. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  787. package/lib/feature-libraries/sequence-field/utils.d.ts +15 -24
  788. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  789. package/lib/feature-libraries/sequence-field/utils.js +107 -292
  790. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  791. package/lib/index.d.ts +1 -1
  792. package/lib/index.d.ts.map +1 -1
  793. package/lib/index.js +1 -1
  794. package/lib/index.js.map +1 -1
  795. package/lib/packageVersion.d.ts +1 -1
  796. package/lib/packageVersion.js +1 -1
  797. package/lib/packageVersion.js.map +1 -1
  798. package/lib/shared-tree/independentView.d.ts +1 -1
  799. package/lib/shared-tree/independentView.d.ts.map +1 -1
  800. package/lib/shared-tree/independentView.js.map +1 -1
  801. package/lib/shared-tree/index.d.ts +1 -1
  802. package/lib/shared-tree/index.d.ts.map +1 -1
  803. package/lib/shared-tree/index.js.map +1 -1
  804. package/lib/shared-tree/schematizeTree.d.ts +4 -4
  805. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  806. package/lib/shared-tree/schematizeTree.js +3 -2
  807. package/lib/shared-tree/schematizeTree.js.map +1 -1
  808. package/lib/shared-tree/schematizingTreeView.d.ts +1 -5
  809. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  810. package/lib/shared-tree/schematizingTreeView.js +35 -36
  811. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  812. package/lib/shared-tree/sharedTree.d.ts +11 -5
  813. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  814. package/lib/shared-tree/sharedTree.js +14 -4
  815. package/lib/shared-tree/sharedTree.js.map +1 -1
  816. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  817. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  818. package/lib/shared-tree/sharedTreeChangeCodecs.js +1 -0
  819. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  820. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts +20 -8
  821. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  822. package/lib/shared-tree/sharedTreeChangeEnricher.js +25 -11
  823. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  824. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
  825. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  826. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -3
  827. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  828. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +16 -6
  829. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  830. package/lib/shared-tree/sharedTreeEditBuilder.js +11 -5
  831. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  832. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  833. package/lib/shared-tree/treeAlpha.js +2 -2
  834. package/lib/shared-tree/treeAlpha.js.map +1 -1
  835. package/lib/shared-tree/treeCheckout.d.ts +12 -10
  836. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  837. package/lib/shared-tree/treeCheckout.js +69 -20
  838. package/lib/shared-tree/treeCheckout.js.map +1 -1
  839. package/lib/shared-tree-core/branch.d.ts +3 -2
  840. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  841. package/lib/shared-tree-core/branch.js +4 -3
  842. package/lib/shared-tree-core/branch.js.map +1 -1
  843. package/lib/shared-tree-core/editManager.d.ts +2 -2
  844. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  845. package/lib/shared-tree-core/editManager.js +9 -9
  846. package/lib/shared-tree-core/editManager.js.map +1 -1
  847. package/lib/shared-tree-core/editManagerCodecs.d.ts +4 -0
  848. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  849. package/lib/shared-tree-core/editManagerCodecs.js +14 -5
  850. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  851. package/{dist/shared-tree-core/editManagerCodecsV5.d.ts → lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts} +3 -3
  852. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -0
  853. package/lib/shared-tree-core/{editManagerCodecsV5.js → editManagerCodecsVSharedBranches.js} +4 -4
  854. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -0
  855. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +20 -6
  856. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  857. package/lib/shared-tree-core/editManagerFormatCommons.js +22 -7
  858. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  859. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  860. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  861. package/lib/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  862. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  863. package/lib/shared-tree-core/{editManagerFormatV5.d.ts → editManagerFormatVSharedBranches.d.ts} +3 -3
  864. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -0
  865. package/lib/shared-tree-core/{editManagerFormatV5.js → editManagerFormatVSharedBranches.js} +2 -2
  866. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -0
  867. package/lib/shared-tree-core/editManagerSummarizer.d.ts +29 -9
  868. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  869. package/lib/shared-tree-core/editManagerSummarizer.js +39 -11
  870. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  871. package/lib/shared-tree-core/index.d.ts +5 -3
  872. package/lib/shared-tree-core/index.d.ts.map +1 -1
  873. package/lib/shared-tree-core/index.js +4 -2
  874. package/lib/shared-tree-core/index.js.map +1 -1
  875. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  876. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  877. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  878. package/{dist/shared-tree-core/messageCodecV5.d.ts → lib/shared-tree-core/messageCodecVSharedBranches.d.ts} +2 -2
  879. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -0
  880. package/lib/shared-tree-core/{messageCodecV5.js → messageCodecVSharedBranches.js} +3 -3
  881. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -0
  882. package/lib/shared-tree-core/messageCodecs.d.ts +4 -0
  883. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  884. package/lib/shared-tree-core/messageCodecs.js +14 -5
  885. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  886. package/lib/shared-tree-core/messageFormat.d.ts +20 -6
  887. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  888. package/lib/shared-tree-core/messageFormat.js +22 -7
  889. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  890. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
  891. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  892. package/lib/shared-tree-core/messageFormatV1ToV4.js +8 -1
  893. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  894. package/lib/shared-tree-core/{messageFormatV5.d.ts → messageFormatVSharedBranches.d.ts} +5 -7
  895. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -0
  896. package/lib/shared-tree-core/{messageFormatV5.js → messageFormatVSharedBranches.js} +3 -2
  897. package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -0
  898. package/lib/shared-tree-core/sharedTreeCore.d.ts +14 -47
  899. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  900. package/lib/shared-tree-core/sharedTreeCore.js +28 -16
  901. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  902. package/lib/shared-tree-core/summaryTypes.d.ts +94 -0
  903. package/lib/shared-tree-core/summaryTypes.d.ts.map +1 -0
  904. package/lib/shared-tree-core/summaryTypes.js +43 -0
  905. package/lib/shared-tree-core/summaryTypes.js.map +1 -0
  906. package/lib/shared-tree-core/versionedSummarizer.d.ts +67 -0
  907. package/lib/shared-tree-core/versionedSummarizer.d.ts.map +1 -0
  908. package/lib/shared-tree-core/versionedSummarizer.js +59 -0
  909. package/lib/shared-tree-core/versionedSummarizer.js.map +1 -0
  910. package/lib/simple-tree/api/configuration.d.ts +3 -26
  911. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  912. package/lib/simple-tree/api/configuration.js +14 -25
  913. package/lib/simple-tree/api/configuration.js.map +1 -1
  914. package/lib/simple-tree/api/dirtyIndex.d.ts +11 -0
  915. package/lib/simple-tree/api/dirtyIndex.d.ts.map +1 -1
  916. package/lib/simple-tree/api/dirtyIndex.js +7 -0
  917. package/lib/simple-tree/api/dirtyIndex.js.map +1 -1
  918. package/lib/simple-tree/api/discrepancies.d.ts +1 -1
  919. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
  920. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  921. package/lib/simple-tree/api/getSimpleSchema.d.ts +3 -3
  922. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  923. package/lib/simple-tree/api/getSimpleSchema.js +9 -3
  924. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  925. package/lib/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  926. package/lib/simple-tree/api/incrementalAllowedTypes.d.ts.map +1 -1
  927. package/lib/simple-tree/api/incrementalAllowedTypes.js +8 -1
  928. package/lib/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  929. package/lib/simple-tree/api/index.d.ts +3 -4
  930. package/lib/simple-tree/api/index.d.ts.map +1 -1
  931. package/lib/simple-tree/api/index.js +2 -3
  932. package/lib/simple-tree/api/index.js.map +1 -1
  933. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +1 -1
  934. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  935. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  936. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +5 -5
  937. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  938. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  939. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  940. package/lib/simple-tree/api/schemaFactoryRecursive.js +0 -1
  941. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  942. package/lib/simple-tree/api/schemaFromSimple.d.ts +6 -1
  943. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  944. package/lib/simple-tree/api/schemaFromSimple.js +5 -0
  945. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  946. package/lib/simple-tree/api/schemaStatics.d.ts +12 -12
  947. package/lib/simple-tree/api/simpleSchemaCodec.d.ts +15 -3
  948. package/lib/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -1
  949. package/lib/simple-tree/api/simpleSchemaCodec.js +15 -3
  950. package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  951. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  952. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  953. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  954. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +8 -1
  955. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  956. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +15 -10
  957. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  958. package/lib/simple-tree/api/typesUnsafe.d.ts +3 -3
  959. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  960. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  961. package/lib/simple-tree/core/allowedTypes.d.ts +2 -2
  962. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  963. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  964. package/lib/simple-tree/core/index.d.ts +1 -1
  965. package/lib/simple-tree/core/index.d.ts.map +1 -1
  966. package/lib/simple-tree/core/index.js +1 -1
  967. package/lib/simple-tree/core/index.js.map +1 -1
  968. package/lib/simple-tree/core/toStored.d.ts +17 -15
  969. package/lib/simple-tree/core/toStored.d.ts.map +1 -1
  970. package/lib/simple-tree/core/toStored.js +4 -37
  971. package/lib/simple-tree/core/toStored.js.map +1 -1
  972. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +15 -15
  973. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  974. package/lib/simple-tree/core/unhydratedFlexTree.js +58 -8
  975. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  976. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  977. package/lib/simple-tree/core/walkSchema.js +5 -1
  978. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  979. package/lib/simple-tree/createContext.d.ts.map +1 -1
  980. package/lib/simple-tree/createContext.js +20 -5
  981. package/lib/simple-tree/createContext.js.map +1 -1
  982. package/lib/simple-tree/fieldSchema.d.ts +7 -7
  983. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  984. package/lib/simple-tree/fieldSchema.js.map +1 -1
  985. package/lib/simple-tree/index.d.ts +8 -7
  986. package/lib/simple-tree/index.d.ts.map +1 -1
  987. package/lib/simple-tree/index.js +6 -5
  988. package/lib/simple-tree/index.js.map +1 -1
  989. package/lib/simple-tree/leafNodeSchema.d.ts +5 -5
  990. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  991. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  992. package/lib/simple-tree/node-kinds/array/arrayNode.js +6 -4
  993. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  994. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +3 -3
  995. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  996. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  997. package/lib/simple-tree/node-kinds/common.d.ts.map +1 -1
  998. package/lib/simple-tree/node-kinds/common.js +2 -2
  999. package/lib/simple-tree/node-kinds/common.js.map +1 -1
  1000. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  1001. package/lib/simple-tree/node-kinds/map/mapNode.js +2 -2
  1002. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  1003. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts +3 -3
  1004. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  1005. package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  1006. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  1007. package/lib/simple-tree/node-kinds/object/objectNode.js +19 -19
  1008. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  1009. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +2 -2
  1010. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  1011. package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  1012. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  1013. package/lib/simple-tree/node-kinds/record/recordNode.js +4 -2
  1014. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  1015. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -3
  1016. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  1017. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  1018. package/lib/simple-tree/prepareForInsertion.d.ts +54 -47
  1019. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  1020. package/lib/simple-tree/prepareForInsertion.js +183 -124
  1021. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  1022. package/lib/simple-tree/simpleSchema.d.ts +55 -23
  1023. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  1024. package/lib/simple-tree/simpleSchema.js +16 -1
  1025. package/lib/simple-tree/simpleSchema.js.map +1 -1
  1026. package/lib/simple-tree/simpleSchemaFormatV1.d.ts +1 -1
  1027. package/lib/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -1
  1028. package/lib/simple-tree/simpleSchemaFormatV1.js +8 -1
  1029. package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  1030. package/lib/simple-tree/toStoredSchema.d.ts +58 -11
  1031. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  1032. package/lib/simple-tree/toStoredSchema.js +204 -31
  1033. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  1034. package/lib/simple-tree/treeSchema.d.ts +23 -0
  1035. package/lib/simple-tree/treeSchema.d.ts.map +1 -0
  1036. package/lib/simple-tree/treeSchema.js +21 -0
  1037. package/lib/simple-tree/treeSchema.js.map +1 -0
  1038. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +13 -4
  1039. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  1040. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +26 -9
  1041. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  1042. package/lib/tableSchema.d.ts +117 -63
  1043. package/lib/tableSchema.d.ts.map +1 -1
  1044. package/lib/tableSchema.js +160 -59
  1045. package/lib/tableSchema.js.map +1 -1
  1046. package/lib/treeFactory.d.ts.map +1 -1
  1047. package/lib/treeFactory.js +18 -4
  1048. package/lib/treeFactory.js.map +1 -1
  1049. package/lib/util/index.d.ts +2 -1
  1050. package/lib/util/index.d.ts.map +1 -1
  1051. package/lib/util/index.js +2 -1
  1052. package/lib/util/index.js.map +1 -1
  1053. package/lib/util/rangeMap.d.ts +24 -12
  1054. package/lib/util/rangeMap.d.ts.map +1 -1
  1055. package/lib/util/rangeMap.js +44 -5
  1056. package/lib/util/rangeMap.js.map +1 -1
  1057. package/lib/util/readSnapshotBlob.d.ts +13 -0
  1058. package/lib/util/readSnapshotBlob.d.ts.map +1 -0
  1059. package/lib/util/readSnapshotBlob.js +14 -0
  1060. package/lib/util/readSnapshotBlob.js.map +1 -0
  1061. package/package.json +21 -21
  1062. package/src/codec/codec.ts +15 -1
  1063. package/src/codec/versioned/codec.ts +1 -1
  1064. package/src/codec/versioned/format.ts +4 -1
  1065. package/src/core/change-family/changeFamily.ts +5 -0
  1066. package/src/core/change-family/index.ts +1 -0
  1067. package/src/core/index.ts +7 -2
  1068. package/src/core/rebase/changeRebaser.ts +6 -1
  1069. package/src/core/rebase/index.ts +1 -0
  1070. package/src/core/rebase/types.ts +8 -1
  1071. package/src/core/rebase/utils.ts +31 -7
  1072. package/src/core/tree/detachedFieldIndex.ts +71 -14
  1073. package/src/core/tree/index.ts +9 -3
  1074. package/src/core/tree/pathTree.ts +16 -4
  1075. package/src/feature-libraries/chunked-forest/basicChunk.ts +7 -1
  1076. package/src/feature-libraries/chunked-forest/chunkTree.ts +6 -1
  1077. package/src/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.ts +15 -7
  1078. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -9
  1079. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +393 -127
  1080. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +35 -38
  1081. package/src/feature-libraries/default-schema/index.ts +16 -5
  1082. package/src/feature-libraries/default-schema/locationBasedEditBuilder.ts +180 -0
  1083. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +35 -9
  1084. package/src/feature-libraries/deltaUtils.ts +6 -1
  1085. package/src/feature-libraries/detachedFieldIndexSummarizer.ts +62 -15
  1086. package/src/feature-libraries/flex-tree/context.ts +17 -0
  1087. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +7 -8
  1088. package/src/feature-libraries/flex-tree/lazyField.ts +66 -24
  1089. package/src/feature-libraries/forest-summary/codec.ts +8 -8
  1090. package/src/feature-libraries/forest-summary/forestSummarizer.ts +45 -37
  1091. package/src/feature-libraries/forest-summary/format.ts +4 -4
  1092. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +23 -39
  1093. package/src/feature-libraries/forest-summary/index.ts +2 -1
  1094. package/src/feature-libraries/forest-summary/summaryTypes.ts +61 -0
  1095. package/src/feature-libraries/index.ts +22 -9
  1096. package/src/feature-libraries/mapTreeCursor.ts +2 -1
  1097. package/src/feature-libraries/mitigatedChangeFamily.ts +3 -1
  1098. package/src/feature-libraries/modular-schema/comparison.ts +63 -5
  1099. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +142 -44
  1100. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +36 -57
  1101. package/src/feature-libraries/modular-schema/fieldKind.ts +24 -40
  1102. package/src/feature-libraries/modular-schema/genericFieldKind.ts +10 -19
  1103. package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +1 -1
  1104. package/src/feature-libraries/modular-schema/index.ts +21 -15
  1105. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +732 -0
  1106. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +790 -0
  1107. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +29 -499
  1108. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +2542 -742
  1109. package/src/feature-libraries/modular-schema/{modularChangeFormat.ts → modularChangeFormatV1.ts} +2 -1
  1110. package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +62 -0
  1111. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +98 -10
  1112. package/src/feature-libraries/optional-field/index.ts +1 -3
  1113. package/src/feature-libraries/optional-field/optionalField.ts +317 -574
  1114. package/src/feature-libraries/optional-field/optionalFieldChangeTypes.ts +24 -38
  1115. package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +89 -35
  1116. package/src/feature-libraries/schema-index/schemaSummarizer.ts +59 -18
  1117. package/src/feature-libraries/sequence-field/compose.ts +134 -519
  1118. package/src/feature-libraries/sequence-field/helperTypes.ts +34 -19
  1119. package/src/feature-libraries/sequence-field/index.ts +0 -9
  1120. package/src/feature-libraries/sequence-field/invert.ts +103 -228
  1121. package/src/feature-libraries/sequence-field/markQueue.ts +2 -2
  1122. package/src/feature-libraries/sequence-field/moveEffectTable.ts +8 -191
  1123. package/src/feature-libraries/sequence-field/rebase.ts +168 -203
  1124. package/src/feature-libraries/sequence-field/replaceRevisions.ts +31 -52
  1125. package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +0 -2
  1126. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +643 -220
  1127. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +56 -68
  1128. package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +25 -27
  1129. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +19 -129
  1130. package/src/feature-libraries/sequence-field/types.ts +34 -64
  1131. package/src/feature-libraries/sequence-field/utils.ts +133 -346
  1132. package/src/index.ts +3 -2
  1133. package/src/packageVersion.ts +1 -1
  1134. package/src/shared-tree/independentView.ts +1 -1
  1135. package/src/shared-tree/index.ts +3 -2
  1136. package/src/shared-tree/schematizeTree.ts +21 -8
  1137. package/src/shared-tree/schematizingTreeView.ts +50 -68
  1138. package/src/shared-tree/sharedTree.ts +39 -12
  1139. package/src/shared-tree/sharedTreeChangeCodecs.ts +5 -1
  1140. package/src/shared-tree/sharedTreeChangeEnricher.ts +31 -11
  1141. package/src/shared-tree/sharedTreeChangeFamily.ts +7 -4
  1142. package/src/shared-tree/sharedTreeEditBuilder.ts +46 -12
  1143. package/src/shared-tree/treeAlpha.ts +2 -3
  1144. package/src/shared-tree/treeCheckout.ts +104 -31
  1145. package/src/shared-tree-core/branch.ts +8 -2
  1146. package/src/shared-tree-core/editManager.ts +16 -2
  1147. package/src/shared-tree-core/editManagerCodecs.ts +17 -5
  1148. package/src/shared-tree-core/{editManagerCodecsV5.ts → editManagerCodecsVSharedBranches.ts} +3 -3
  1149. package/src/shared-tree-core/editManagerFormatCommons.ts +22 -7
  1150. package/src/shared-tree-core/editManagerFormatV1toV4.ts +3 -1
  1151. package/src/shared-tree-core/{editManagerFormatV5.ts → editManagerFormatVSharedBranches.ts} +2 -2
  1152. package/src/shared-tree-core/editManagerSummarizer.ts +58 -16
  1153. package/src/shared-tree-core/index.ts +11 -3
  1154. package/src/shared-tree-core/messageCodecV1ToV4.ts +2 -1
  1155. package/src/shared-tree-core/{messageCodecV5.ts → messageCodecVSharedBranches.ts} +3 -3
  1156. package/src/shared-tree-core/messageCodecs.ts +17 -5
  1157. package/src/shared-tree-core/messageFormat.ts +22 -7
  1158. package/src/shared-tree-core/messageFormatV1ToV4.ts +16 -2
  1159. package/src/shared-tree-core/{messageFormatV5.ts → messageFormatVSharedBranches.ts} +4 -6
  1160. package/src/shared-tree-core/sharedTreeCore.ts +67 -76
  1161. package/src/shared-tree-core/summaryTypes.ts +122 -0
  1162. package/src/shared-tree-core/versionedSummarizer.ts +107 -0
  1163. package/src/simple-tree/api/configuration.ts +21 -68
  1164. package/src/simple-tree/api/dirtyIndex.ts +11 -0
  1165. package/src/simple-tree/api/discrepancies.ts +1 -1
  1166. package/src/simple-tree/api/getSimpleSchema.ts +13 -6
  1167. package/src/simple-tree/api/incrementalAllowedTypes.ts +15 -3
  1168. package/src/simple-tree/api/index.ts +3 -4
  1169. package/src/simple-tree/api/schemaCompatibilityTester.ts +1 -1
  1170. package/src/simple-tree/api/schemaFactoryAlpha.ts +2 -2
  1171. package/src/simple-tree/api/schemaFactoryRecursive.ts +0 -2
  1172. package/src/simple-tree/api/schemaFromSimple.ts +11 -5
  1173. package/src/simple-tree/api/simpleSchemaCodec.ts +17 -3
  1174. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
  1175. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +18 -10
  1176. package/src/simple-tree/api/typesUnsafe.ts +7 -3
  1177. package/src/simple-tree/core/allowedTypes.ts +3 -3
  1178. package/src/simple-tree/core/index.ts +2 -2
  1179. package/src/simple-tree/core/toStored.ts +22 -55
  1180. package/src/simple-tree/core/unhydratedFlexTree.ts +87 -36
  1181. package/src/simple-tree/core/walkSchema.ts +6 -0
  1182. package/src/simple-tree/createContext.ts +26 -11
  1183. package/src/simple-tree/fieldSchema.ts +16 -7
  1184. package/src/simple-tree/index.ts +12 -11
  1185. package/src/simple-tree/node-kinds/array/arrayNode.ts +12 -7
  1186. package/src/simple-tree/node-kinds/array/arrayNodeTypes.ts +3 -3
  1187. package/src/simple-tree/node-kinds/common.ts +2 -5
  1188. package/src/simple-tree/node-kinds/map/mapNode.ts +9 -6
  1189. package/src/simple-tree/node-kinds/map/mapNodeTypes.ts +3 -3
  1190. package/src/simple-tree/node-kinds/object/objectNode.ts +26 -26
  1191. package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +6 -2
  1192. package/src/simple-tree/node-kinds/record/recordNode.ts +15 -11
  1193. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +3 -3
  1194. package/src/simple-tree/prepareForInsertion.ts +343 -200
  1195. package/src/simple-tree/simpleSchema.ts +79 -32
  1196. package/src/simple-tree/simpleSchemaFormatV1.ts +9 -1
  1197. package/src/simple-tree/toStoredSchema.ts +319 -61
  1198. package/src/simple-tree/treeSchema.ts +54 -0
  1199. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +42 -14
  1200. package/src/tableSchema.ts +485 -166
  1201. package/src/treeFactory.ts +19 -5
  1202. package/src/util/index.ts +5 -0
  1203. package/src/util/rangeMap.ts +72 -18
  1204. package/src/util/readSnapshotBlob.ts +23 -0
  1205. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
  1206. package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
  1207. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +0 -9
  1208. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +0 -1
  1209. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +0 -50
  1210. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +0 -1
  1211. package/dist/shared-tree-core/editManagerCodecsV5.d.ts.map +0 -1
  1212. package/dist/shared-tree-core/editManagerCodecsV5.js.map +0 -1
  1213. package/dist/shared-tree-core/editManagerFormatV5.d.ts.map +0 -1
  1214. package/dist/shared-tree-core/editManagerFormatV5.js.map +0 -1
  1215. package/dist/shared-tree-core/messageCodecV5.d.ts.map +0 -1
  1216. package/dist/shared-tree-core/messageCodecV5.js.map +0 -1
  1217. package/dist/shared-tree-core/messageFormatV5.d.ts.map +0 -1
  1218. package/dist/shared-tree-core/messageFormatV5.js.map +0 -1
  1219. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +0 -40
  1220. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +0 -1
  1221. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +0 -177
  1222. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +0 -1
  1223. package/docs/main/sequence-field/move-composition.md +0 -46
  1224. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
  1225. package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
  1226. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +0 -9
  1227. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +0 -1
  1228. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js +0 -46
  1229. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +0 -1
  1230. package/lib/shared-tree-core/editManagerCodecsV5.d.ts.map +0 -1
  1231. package/lib/shared-tree-core/editManagerCodecsV5.js.map +0 -1
  1232. package/lib/shared-tree-core/editManagerFormatV5.d.ts.map +0 -1
  1233. package/lib/shared-tree-core/editManagerFormatV5.js.map +0 -1
  1234. package/lib/shared-tree-core/messageCodecV5.d.ts.map +0 -1
  1235. package/lib/shared-tree-core/messageCodecV5.js.map +0 -1
  1236. package/lib/shared-tree-core/messageFormatV5.d.ts.map +0 -1
  1237. package/lib/shared-tree-core/messageFormatV5.js.map +0 -1
  1238. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +0 -40
  1239. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +0 -1
  1240. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +0 -171
  1241. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +0 -1
  1242. package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +0 -57
  1243. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +0 -209
@@ -2,18 +2,40 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { unreachableCase, fail, transformMapValues, } from "@fluidframework/core-utils/internal";
5
+ import { unreachableCase, fail, transformMapValues, assert, } from "@fluidframework/core-utils/internal";
6
6
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
7
  import { EmptyKey, LeafNodeStoredSchema, MapNodeStoredSchema, ObjectNodeStoredSchema, } from "../core/index.js";
8
8
  import { FieldKinds } from "../feature-libraries/index.js";
9
- import { brand, getOrCreate } from "../util/index.js";
10
- import { allowedTypeFilter, convertAllowedTypes, ExpectStored, NodeKind, } from "./core/index.js";
9
+ import { brand, filterIterable, getOrCreate, mapIterable, } from "../util/index.js";
10
+ import { ExpectStored, NodeKind, Unchanged, } from "./core/index.js";
11
11
  import { FieldKind, normalizeFieldSchema } from "./fieldSchema.js";
12
- import { walkFieldSchema } from "./walkFieldSchema.js";
12
+ import { createTreeSchema } from "./treeSchema.js";
13
+ // TODO: this file, src/simple-tree/api/storedSchema.ts and src/simple-tree/core/toStored.ts should be refactored to group the logic more logically.
14
+ // The content of src/simple-tree/api/storedSchema.ts should probably removed from the API surface, replaced by simple schema snapshotting APIs.
15
+ // The logic from this file for converting stored-simple-schema to the persisted format can be moved to its own file.
16
+ // The simple-schema related logic from this file and src/simple-tree/core/toStored.ts can be unified and `toStoredSchema` and its other ImplicitFieldSchema consuming variants should probably be removed in favor of acting on TreeSchema and SimpleTreeSchema directly.
13
17
  const viewToStoredCache = new WeakMap();
18
+ /**
19
+ * Maximally restrictive transformation of a view to stored schema.
20
+ * @remarks
21
+ * This should only be used when the intent is to produce a stored schema is as restrictive as possible while still being compatible with the input view schema.
22
+ * This is typically used for cases where backwards compatibility with past versions of an application is required, like {@link toUpgradeSchema} or {@link toInitialSchema}.
23
+ */
14
24
  export const restrictiveStoredSchemaGenerationOptions = {
15
25
  includeStaged: () => false,
16
26
  };
27
+ /**
28
+ * Maximally permissive transformation of a view to stored schema.
29
+ * @remarks
30
+ * This should only be used when the intent is to produce a stored schema which allows as much as possible while still being compatible with the input view schema.
31
+ * This is typically used for cases where forwards compatibility with future versions of an application is required, like {@link toUnhydratedSchema}.
32
+ *
33
+ * This is unable to include unknown optional fields in the output, which makes it not truly maximally permissive.
34
+ *
35
+ * TODO: {@link StoredFromViewSchemaGenerationOptions} could be updated to allow a way to inject extra optional fields.
36
+ * If done, then this could take in an existing stored schema, and attempt to generate a valid superset.
37
+ * This could be useful to use as the schema for unhydrated content cloned from hydrated content.
38
+ */
17
39
  export const permissiveStoredSchemaGenerationOptions = {
18
40
  includeStaged: () => true,
19
41
  };
@@ -55,25 +77,49 @@ export const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;
55
77
  export function toStoredSchema(root, options) {
56
78
  const cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());
57
79
  return getOrCreate(cache, root, () => {
58
- const normalized = normalizeFieldSchema(root);
59
- const nodeSchema = new Map();
60
- walkFieldSchema(normalized, {
61
- node(schema) {
62
- if (nodeSchema.has(brand(schema.identifier))) {
63
- // Use JSON.stringify to quote and escape identifier string.
64
- throw new UsageError(`Multiple schema encountered with the identifier ${JSON.stringify(schema.identifier)}. Remove or rename them to avoid the collision.`);
65
- }
66
- nodeSchema.set(brand(schema.identifier), getStoredSchema(schema, options));
67
- },
68
- allowedTypeFilter: (allowedType) => allowedTypeFilter({ isStaged: allowedType.metadata.stagedSchemaUpgrade ?? false }, options),
69
- });
70
- const result = {
71
- nodeSchema,
72
- rootFieldSchema: convertField(normalized, options),
73
- };
74
- return result;
80
+ const treeSchema = createTreeSchema(normalizeFieldSchema(root));
81
+ const simpleSchema = transformSimpleSchema(treeSchema, options);
82
+ return simpleStoredSchemaToStoredSchema(simpleSchema);
75
83
  });
76
84
  }
85
+ /**
86
+ * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if
87
+ * a staged allowed type has been upgraded and if so, include it in the conversion.
88
+ */
89
+ export function transformSimpleSchema(schema, options) {
90
+ const simpleNodeSchema = new Map();
91
+ const root = filterFieldAllowedTypes(schema.root, options);
92
+ const queue = Array.from(root.simpleAllowedTypes.keys());
93
+ for (const identifier of queue) {
94
+ getOrCreate(simpleNodeSchema, identifier, (id) => {
95
+ const nodeSchema = schema.definitions.get(id) ?? fail("missing schema");
96
+ const transformed = transformSimpleNodeSchema(nodeSchema, options);
97
+ const kind = transformed.kind;
98
+ switch (kind) {
99
+ case NodeKind.Leaf:
100
+ break;
101
+ case NodeKind.Array:
102
+ case NodeKind.Map:
103
+ case NodeKind.Record:
104
+ queue.push(...transformed.simpleAllowedTypes.keys());
105
+ break;
106
+ case NodeKind.Object:
107
+ for (const fieldSchema of transformed.fields.values()) {
108
+ queue.push(...fieldSchema.simpleAllowedTypes.keys());
109
+ }
110
+ break;
111
+ default:
112
+ unreachableCase(kind);
113
+ }
114
+ return transformed;
115
+ });
116
+ }
117
+ // Copy simpleNodeSchema, but in the order from the original schema.definitions
118
+ // Currently we do not specify anything about the order of definitions, but it is nicer to have a stable order and some tests rely on it.
119
+ const definitions = new Map(mapIterable(filterIterable(schema.definitions.keys(), (id) => simpleNodeSchema.has(id)), (id) => [id, simpleNodeSchema.get(id) ?? fail("missing schema")]));
120
+ assert(definitions.size === simpleNodeSchema.size, "Reachable schema missing from input TreeSchema");
121
+ return { root, definitions };
122
+ }
77
123
  /**
78
124
  * Convert a {@link SimpleTreeSchema} for a stored schema into a {@link TreeStoredSchema}.
79
125
  * @remarks
@@ -84,17 +130,17 @@ export function toStoredSchema(root, options) {
84
130
  */
85
131
  export function simpleStoredSchemaToStoredSchema(treeSchema) {
86
132
  const result = {
87
- nodeSchema: transformMapValues(treeSchema.definitions, (schema) => getStoredSchema(schema, ExpectStored)),
88
- rootFieldSchema: convertField(treeSchema.root, ExpectStored),
133
+ nodeSchema: transformMapValues(treeSchema.definitions, (schema) => getStoredSchema(schema)),
134
+ rootFieldSchema: convertField(treeSchema.root),
89
135
  };
90
136
  return result;
91
137
  }
92
138
  /**
93
139
  * Convert a {@link SimpleFieldSchema} into a {@link TreeFieldStoredSchema}.
94
140
  */
95
- export function convertField(schema, options) {
141
+ export function convertField(schema) {
96
142
  const kind = convertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);
97
- const types = convertAllowedTypes(schema.simpleAllowedTypes, options);
143
+ const types = convertAllowedTypes(schema.simpleAllowedTypes);
98
144
  return { kind, types, persistedMetadata: schema.persistedMetadata };
99
145
  }
100
146
  /**
@@ -110,7 +156,7 @@ export const convertFieldKind = new Map([
110
156
  * @privateRemarks
111
157
  * TODO: Persist node metadata once schema FormatV2 is supported.
112
158
  */
113
- export function getStoredSchema(schema, options) {
159
+ export function getStoredSchema(schema) {
114
160
  const kind = schema.kind;
115
161
  switch (kind) {
116
162
  case NodeKind.Leaf: {
@@ -118,7 +164,7 @@ export function getStoredSchema(schema, options) {
118
164
  }
119
165
  case NodeKind.Map:
120
166
  case NodeKind.Record: {
121
- const types = convertAllowedTypes(schema.simpleAllowedTypes, options);
167
+ const types = convertAllowedTypes(schema.simpleAllowedTypes);
122
168
  return new MapNodeStoredSchema({
123
169
  kind: FieldKinds.optional.identifier,
124
170
  types,
@@ -128,12 +174,12 @@ export function getStoredSchema(schema, options) {
128
174
  schema.persistedMetadata);
129
175
  }
130
176
  case NodeKind.Array: {
131
- return arrayNodeStoredSchema(schema.simpleAllowedTypes, options, schema.persistedMetadata);
177
+ return arrayNodeStoredSchema(schema.simpleAllowedTypes, schema.persistedMetadata);
132
178
  }
133
179
  case NodeKind.Object: {
134
180
  const fields = new Map();
135
181
  for (const fieldSchema of schema.fields.values()) {
136
- fields.set(brand(fieldSchema.storedKey), convertField(fieldSchema, options));
182
+ fields.set(brand(fieldSchema.storedKey), convertField(fieldSchema));
137
183
  }
138
184
  return new ObjectNodeStoredSchema(fields, schema.persistedMetadata);
139
185
  }
@@ -142,13 +188,140 @@ export function getStoredSchema(schema, options) {
142
188
  }
143
189
  }
144
190
  }
145
- export function arrayNodeStoredSchema(schema, options, persistedMetadata) {
191
+ /**
192
+ * TODO: Persist node metadata once schema FormatV2 is supported.
193
+ *
194
+ * This is only exported for use by tests: if other users need them more overloads could be provided, but this is currently sufficient.
195
+ */
196
+ export function transformSimpleNodeSchema(schema, options) {
197
+ const metadata = {
198
+ persistedMetadata: schema.persistedMetadata,
199
+ metadata: preservesViewData(options)
200
+ ? {
201
+ custom: schema.metadata.custom,
202
+ description: schema.metadata.description,
203
+ }
204
+ : {},
205
+ };
206
+ const kind = schema.kind;
207
+ switch (kind) {
208
+ case NodeKind.Leaf: {
209
+ return {
210
+ kind,
211
+ leafKind: schema.leafKind,
212
+ ...metadata,
213
+ };
214
+ }
215
+ case NodeKind.Array:
216
+ case NodeKind.Map:
217
+ case NodeKind.Record: {
218
+ return {
219
+ kind,
220
+ ...metadata,
221
+ simpleAllowedTypes: filterAllowedTypes(schema.simpleAllowedTypes, options),
222
+ };
223
+ }
224
+ case NodeKind.Object: {
225
+ return {
226
+ kind,
227
+ ...metadata,
228
+ fields: transformMapValues(schema.fields, (f) => ({
229
+ ...filterFieldAllowedTypes(f, options),
230
+ storedKey: f.storedKey,
231
+ })),
232
+ allowUnknownOptionalFields: filterViewData(options, schema.allowUnknownOptionalFields),
233
+ };
234
+ }
235
+ default: {
236
+ unreachableCase(kind);
237
+ }
238
+ }
239
+ }
240
+ function arrayNodeStoredSchema(schema, persistedMetadata) {
146
241
  const field = {
147
242
  kind: FieldKinds.sequence.identifier,
148
- types: convertAllowedTypes(schema, options),
243
+ types: convertAllowedTypes(schema),
149
244
  persistedMetadata,
150
245
  };
151
246
  const fields = new Map([[EmptyKey, field]]);
152
247
  return new ObjectNodeStoredSchema(fields, persistedMetadata);
153
248
  }
249
+ /**
250
+ * Converts a {@link SimpleAllowedTypes} to a stored schema.
251
+ * @param schema - The schema to convert.
252
+ * @param options - The options to use for filtering.
253
+ * @returns The converted stored schema.
254
+ */
255
+ export function filterAllowedTypes(schema, options) {
256
+ const filtered = new Map();
257
+ for (const [type, data] of schema) {
258
+ if (options === Unchanged) {
259
+ filtered.set(type, { isStaged: data.isStaged });
260
+ }
261
+ else if (allowedTypeFilter(data, options)) {
262
+ filtered.set(type, { isStaged: undefined });
263
+ }
264
+ }
265
+ return filtered;
266
+ }
267
+ function filterFieldAllowedTypes(f, options) {
268
+ return {
269
+ kind: f.kind,
270
+ persistedMetadata: f.persistedMetadata,
271
+ metadata: preservesViewData(options)
272
+ ? {
273
+ custom: f.metadata.custom,
274
+ description: f.metadata.description,
275
+ }
276
+ : {},
277
+ simpleAllowedTypes: filterAllowedTypes(f.simpleAllowedTypes, options),
278
+ };
279
+ }
280
+ /**
281
+ * Converts a stored {@link SimpleAllowedTypes} to a {@link TreeTypeSet}.
282
+ */
283
+ function convertAllowedTypes(schema) {
284
+ return new Set(schema.keys());
285
+ }
286
+ /**
287
+ * Filters an allowed type based on the provided options.
288
+ * @param allowedType - The allowed type to filter.
289
+ * @param options - The options to use for filtering.
290
+ * @returns Whether the allowed type passes the filter.
291
+ */
292
+ function allowedTypeFilter(data, options) {
293
+ if (options === ExpectStored) {
294
+ if (data.isStaged !== undefined) {
295
+ throw new UsageError("Failed to covert view schema to stored schema. The simple schema provided was indicated to be a stored schema by the use of `ExpectStored`, but view schema specific content was encountered which requires a `StoredFromViewSchemaGenerationOptions` to process.");
296
+ }
297
+ return true;
298
+ }
299
+ if (data.isStaged === undefined) {
300
+ throw new UsageError("Failed to covert view schema to stored schema. The simple schema provided as the view schema was actually a stored schema. If this was intended, use `ExpectStored` for the `StoredSchemaGenerationOptions` to indicate the input is already a stored schema and only a format conversion is required.");
301
+ }
302
+ // If the allowed type is staged, only include it if the options allow it.
303
+ if (data.isStaged === false) {
304
+ return true;
305
+ }
306
+ return options.includeStaged(data.isStaged);
307
+ }
308
+ function isStoredFromView(options) {
309
+ return typeof options === "object" && "includeStaged" in options;
310
+ }
311
+ function filterViewData(options, data) {
312
+ return preservesViewData(options) ? data : undefined;
313
+ }
314
+ /**
315
+ * Determines if the provided options indicate that view specific data should be preserved.
316
+ * @remarks
317
+ * This assumes that stored simple schema should not contain view specific data.
318
+ * Therefore the only case where what this returns should matter is when the input schema is view schema
319
+ * (and thus there might be view specific data).
320
+ */
321
+ function preservesViewData(options) {
322
+ // As noted above in the doc comment, the only case we care about the return value is when the input is a view schema.
323
+ // There are two such cases: isStoredFromView where we return false, and Unchanged when applied to a view schema, where we return true.
324
+ // It does not matter what we return in other cases, so for simplicity they just end up as "true".
325
+ return isStoredFromView(options) ? false : true;
326
+ }
154
327
  //# sourceMappingURL=toStoredSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EACf,IAAI,EACJ,kBAAkB,GAClB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GAOtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAsB,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,WAAW,EAAqC,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,QAAQ,GAIR,MAAM,iBAAiB,CAAC;AACzB,OA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,MAAM,EAAE,EAAE,CAAC;gBAClD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;YAC9E,CAAC;YACD,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,eAAe,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,UAAU,qBAAqB,CACpC,MAA0B,EAC1B,OAAsC,EACtC,iBAA2D;IAE3D,MAAM,KAAK,GAAG;QACb,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU;QACpC,KAAK,EAAE,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC;QAC3C,iBAAiB;KACjB,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5C,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tunreachableCase,\n\tfail,\n\ttransformMapValues,\n} from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport { brand, getOrCreate, type JsonCompatibleReadOnlyObject } from \"../util/index.js\";\n\nimport {\n\tallowedTypeFilter,\n\tconvertAllowedTypes,\n\tExpectStored,\n\tNodeKind,\n\ttype SimpleNodeSchemaBase,\n\ttype StoredFromViewSchemaGenerationOptions,\n\ttype StoredSchemaGenerationOptions,\n} from \"./core/index.js\";\nimport { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from \"./fieldSchema.js\";\nimport type {\n\tSimpleAllowedTypes,\n\tSimpleFieldSchema,\n\tSimpleNodeSchema,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\n\nconst viewToStoredCache = new WeakMap<\n\tStoredFromViewSchemaGenerationOptions,\n\tWeakMap<ImplicitFieldSchema, TreeStoredSchema>\n>();\n\nexport const restrictiveStoredSchemaGenerationOptions: StoredSchemaGenerationOptions = {\n\tincludeStaged: () => false,\n};\n\nexport const permissiveStoredSchemaGenerationOptions: StoredSchemaGenerationOptions = {\n\tincludeStaged: () => true,\n};\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.\n *\n * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.\n */\nexport function toUpgradeSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.\n */\nexport function toInitialSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.\n * @remarks\n * This allows as much as possible, relying on further validation when inserting the content.\n *\n * TODO: this should get additional options to enable support for unknown optional fields.\n */\nexport const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n *\n * @privateRemarks\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n *\n * Even if this took in a SimpleTreeSchema,\n * it would still need to walk the schema to avoid including schema that become unreachable due to filtered out staged schema.\n *\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(\n\troot: ImplicitFieldSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeStoredSchema {\n\tconst cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());\n\treturn getOrCreate(cache, root, () => {\n\t\tconst normalized = normalizeFieldSchema(root);\n\t\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\t\twalkFieldSchema(normalized, {\n\t\t\tnode(schema) {\n\t\t\t\tif (nodeSchema.has(brand(schema.identifier))) {\n\t\t\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\t\t\tschema.identifier,\n\t\t\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tnodeSchema.set(\n\t\t\t\t\tbrand(schema.identifier),\n\t\t\t\t\tgetStoredSchema(\n\t\t\t\t\t\tschema as SimpleNodeSchemaBase<NodeKind> as SimpleNodeSchema,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t},\n\t\t\tallowedTypeFilter: (allowedType) =>\n\t\t\t\tallowedTypeFilter(\n\t\t\t\t\t{ isStaged: allowedType.metadata.stagedSchemaUpgrade ?? false },\n\t\t\t\t\toptions,\n\t\t\t\t),\n\t\t});\n\n\t\tconst result: TreeStoredSchema = {\n\t\t\tnodeSchema,\n\t\t\trootFieldSchema: convertField(normalized, options),\n\t\t};\n\t\treturn result;\n\t});\n}\n\n/**\n * Convert a {@link SimpleTreeSchema} for a stored schema into a {@link TreeStoredSchema}.\n * @remarks\n * This only supports simple schemas that are already logically stored schemas.\n * @privateRemarks\n * To correctly support view schema here, this would need to filter out unreferenced schema after excluding staged schema.\n * @see {@link ExpectStored}.\n */\nexport function simpleStoredSchemaToStoredSchema(\n\ttreeSchema: SimpleTreeSchema,\n): TreeStoredSchema {\n\tconst result: TreeStoredSchema = {\n\t\tnodeSchema: transformMapValues(treeSchema.definitions, (schema) =>\n\t\t\tgetStoredSchema(schema, ExpectStored),\n\t\t) as Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t\trootFieldSchema: convertField(treeSchema.root, ExpectStored),\n\t};\n\treturn result;\n}\n\n/**\n * Convert a {@link SimpleFieldSchema} into a {@link TreeFieldStoredSchema}.\n */\nexport function convertField(\n\tschema: SimpleFieldSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tconst types = convertAllowedTypes(schema.simpleAllowedTypes, options);\n\treturn { kind, types, persistedMetadata: schema.persistedMetadata };\n}\n\n/**\n * A map that converts {@link FieldKind} to {@link FlexFieldKind}.\n */\nexport const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<\n\tFieldKind,\n\tFlexFieldKind\n>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n * @privateRemarks\n * TODO: Persist node metadata once schema FormatV2 is supported.\n */\nexport function getStoredSchema(\n\tschema: SimpleNodeSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn new LeafNodeStoredSchema(schema.leafKind);\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\tconst types = convertAllowedTypes(schema.simpleAllowedTypes, options);\n\t\t\treturn new MapNodeStoredSchema(\n\t\t\t\t{\n\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\ttypes,\n\t\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t\t},\n\t\t\t\t// TODO: Find a way to avoid injecting persistedMetadata twice in these constructor calls.\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\treturn arrayNodeStoredSchema(\n\t\t\t\tschema.simpleAllowedTypes,\n\t\t\t\toptions,\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const fieldSchema of schema.fields.values()) {\n\t\t\t\tfields.set(brand(fieldSchema.storedKey), convertField(fieldSchema, options));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields, schema.persistedMetadata);\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\nexport function arrayNodeStoredSchema(\n\tschema: SimpleAllowedTypes,\n\toptions: StoredSchemaGenerationOptions,\n\tpersistedMetadata: JsonCompatibleReadOnlyObject | undefined,\n): ObjectNodeStoredSchema {\n\tconst field = {\n\t\tkind: FieldKinds.sequence.identifier,\n\t\ttypes: convertAllowedTypes(schema, options),\n\t\tpersistedMetadata,\n\t};\n\tconst fields = new Map([[EmptyKey, field]]);\n\treturn new ObjectNodeStoredSchema(fields, persistedMetadata);\n}\n"]}
1
+ {"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EACf,IAAI,EACJ,kBAAkB,EAClB,MAAM,GACN,MAAM,qCAAqC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AC;IACb,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,IAAI,UAAU,CACnB,wSAAwS,CACxS,CAAC;IACH,CAAC;IAED,0EAA0E;IAC1E,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,gBAAgB,CACxB,OAA0C;IAE1C,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,eAAe,IAAI,OAAO,CAAC;AAClE,CAAC;AAED,SAAS,cAAc,CACtB,OAA0C,EAC1C,IAAO;IAEP,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,OAA0C;IACpE,sHAAsH;IACtH,uIAAuI;IACvI,kGAAkG;IAClG,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tunreachableCase,\n\tfail,\n\ttransformMapValues,\n\tassert,\n} from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport {\n\tbrand,\n\tfilterIterable,\n\tgetOrCreate,\n\tmapIterable,\n\ttype JsonCompatibleReadOnlyObject,\n} from \"../util/index.js\";\n\nimport {\n\tExpectStored,\n\tNodeKind,\n\tUnchanged,\n\ttype SimpleSchemaTransformationOptions,\n\ttype StoredFromViewSchemaGenerationOptions,\n\ttype StoredSchemaGenerationOptions,\n} from \"./core/index.js\";\nimport { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from \"./fieldSchema.js\";\nimport type {\n\tSchemaType,\n\tSimpleAllowedTypeAttributes,\n\tSimpleAllowedTypes,\n\tSimpleArrayNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleRecordNodeSchema,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport { createTreeSchema } from \"./treeSchema.js\";\n\n// TODO: this file, src/simple-tree/api/storedSchema.ts and src/simple-tree/core/toStored.ts should be refactored to group the logic more logically.\n// The content of src/simple-tree/api/storedSchema.ts should probably removed from the API surface, replaced by simple schema snapshotting APIs.\n// The logic from this file for converting stored-simple-schema to the persisted format can be moved to its own file.\n// The simple-schema related logic from this file and src/simple-tree/core/toStored.ts can be unified and `toStoredSchema` and its other ImplicitFieldSchema consuming variants should probably be removed in favor of acting on TreeSchema and SimpleTreeSchema directly.\n\nconst viewToStoredCache = new WeakMap<\n\tStoredFromViewSchemaGenerationOptions,\n\tWeakMap<ImplicitFieldSchema, TreeStoredSchema>\n>();\n\n/**\n * Maximally restrictive transformation of a view to stored schema.\n * @remarks\n * This should only be used when the intent is to produce a stored schema is as restrictive as possible while still being compatible with the input view schema.\n * This is typically used for cases where backwards compatibility with past versions of an application is required, like {@link toUpgradeSchema} or {@link toInitialSchema}.\n */\nexport const restrictiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions =\n\t{\n\t\tincludeStaged: () => false,\n\t};\n\n/**\n * Maximally permissive transformation of a view to stored schema.\n * @remarks\n * This should only be used when the intent is to produce a stored schema which allows as much as possible while still being compatible with the input view schema.\n * This is typically used for cases where forwards compatibility with future versions of an application is required, like {@link toUnhydratedSchema}.\n *\n * This is unable to include unknown optional fields in the output, which makes it not truly maximally permissive.\n *\n * TODO: {@link StoredFromViewSchemaGenerationOptions} could be updated to allow a way to inject extra optional fields.\n * If done, then this could take in an existing stored schema, and attempt to generate a valid superset.\n * This could be useful to use as the schema for unhydrated content cloned from hydrated content.\n */\nexport const permissiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions = {\n\tincludeStaged: () => true,\n};\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.\n *\n * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.\n */\nexport function toUpgradeSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.\n */\nexport function toInitialSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.\n * @remarks\n * This allows as much as possible, relying on further validation when inserting the content.\n *\n * TODO: this should get additional options to enable support for unknown optional fields.\n */\nexport const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n *\n * @privateRemarks\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n *\n * Even if this took in a SimpleTreeSchema,\n * it would still need to walk the schema to avoid including schema that become unreachable due to filtered out staged schema.\n *\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(\n\troot: ImplicitFieldSchema,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): TreeStoredSchema {\n\tconst cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());\n\treturn getOrCreate(cache, root, () => {\n\t\tconst treeSchema = createTreeSchema(normalizeFieldSchema(root));\n\t\tconst simpleSchema = transformSimpleSchema(treeSchema, options);\n\t\treturn simpleStoredSchemaToStoredSchema(simpleSchema);\n\t});\n}\n\n/**\n * Converts a {@link SimpleTreeSchema} from `SchemaType.View` to `SchemaType.Stored`.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema<SchemaType.View>,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): SimpleTreeSchema<SchemaType.Stored>;\n\n/**\n * Copies a `SchemaType.Stored` {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema<SchemaType.Stored>,\n\toptions: ExpectStored,\n): SimpleTreeSchema<SchemaType.Stored>;\n\n/**\n * Copies a {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema<T extends SchemaType>(\n\tschema: SimpleTreeSchema<T>,\n\toptions: Unchanged,\n): SimpleTreeSchema<T>;\n\n/**\n * Converts a {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleTreeSchema;\n\n/**\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleTreeSchema {\n\tconst simpleNodeSchema = new Map<string, SimpleNodeSchema>();\n\tconst root = filterFieldAllowedTypes(schema.root, options);\n\tconst queue = Array.from(root.simpleAllowedTypes.keys());\n\tfor (const identifier of queue) {\n\t\tgetOrCreate(simpleNodeSchema, identifier, (id) => {\n\t\t\tconst nodeSchema = schema.definitions.get(id) ?? fail(\"missing schema\");\n\t\t\tconst transformed = transformSimpleNodeSchema(nodeSchema, options);\n\t\t\tconst kind = transformed.kind;\n\t\t\tswitch (kind) {\n\t\t\t\tcase NodeKind.Leaf:\n\t\t\t\t\tbreak;\n\t\t\t\tcase NodeKind.Array:\n\t\t\t\tcase NodeKind.Map:\n\t\t\t\tcase NodeKind.Record:\n\t\t\t\t\tqueue.push(...transformed.simpleAllowedTypes.keys());\n\t\t\t\t\tbreak;\n\t\t\t\tcase NodeKind.Object:\n\t\t\t\t\tfor (const fieldSchema of transformed.fields.values()) {\n\t\t\t\t\t\tqueue.push(...fieldSchema.simpleAllowedTypes.keys());\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(kind);\n\t\t\t}\n\t\t\treturn transformed;\n\t\t});\n\t}\n\t// Copy simpleNodeSchema, but in the order from the original schema.definitions\n\t// Currently we do not specify anything about the order of definitions, but it is nicer to have a stable order and some tests rely on it.\n\tconst definitions = new Map<string, SimpleNodeSchema>(\n\t\tmapIterable(\n\t\t\tfilterIterable(schema.definitions.keys(), (id) => simpleNodeSchema.has(id)),\n\t\t\t(id) => [id, simpleNodeSchema.get(id) ?? fail(\"missing schema\")],\n\t\t),\n\t);\n\tassert(\n\t\tdefinitions.size === simpleNodeSchema.size,\n\t\t\"Reachable schema missing from input TreeSchema\",\n\t);\n\treturn { root, definitions };\n}\n\n/**\n * Convert a {@link SimpleTreeSchema} for a stored schema into a {@link TreeStoredSchema}.\n * @remarks\n * This only supports simple schemas that are already logically stored schemas.\n * @privateRemarks\n * To correctly support view schema here, this would need to filter out unreferenced schema after excluding staged schema.\n * @see {@link ExpectStored}.\n */\nexport function simpleStoredSchemaToStoredSchema(\n\ttreeSchema: SimpleTreeSchema<SchemaType.Stored>,\n): TreeStoredSchema {\n\tconst result: TreeStoredSchema = {\n\t\tnodeSchema: transformMapValues(treeSchema.definitions, (schema) =>\n\t\t\tgetStoredSchema(schema),\n\t\t) as Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t\trootFieldSchema: convertField(treeSchema.root),\n\t};\n\treturn result;\n}\n\n/**\n * Convert a {@link SimpleFieldSchema} into a {@link TreeFieldStoredSchema}.\n */\nexport function convertField(\n\tschema: SimpleFieldSchema<SchemaType.Stored>,\n): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tconst types = convertAllowedTypes(schema.simpleAllowedTypes);\n\treturn { kind, types, persistedMetadata: schema.persistedMetadata };\n}\n\n/**\n * A map that converts {@link FieldKind} to {@link FlexFieldKind}.\n */\nexport const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<\n\tFieldKind,\n\tFlexFieldKind\n>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n * @privateRemarks\n * TODO: Persist node metadata once schema FormatV2 is supported.\n */\nexport function getStoredSchema(\n\tschema: SimpleNodeSchema<SchemaType.Stored>,\n): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn new LeafNodeStoredSchema(schema.leafKind);\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\tconst types = convertAllowedTypes(schema.simpleAllowedTypes);\n\t\t\treturn new MapNodeStoredSchema(\n\t\t\t\t{\n\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\ttypes,\n\t\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t\t},\n\t\t\t\t// TODO: Find a way to avoid injecting persistedMetadata twice in these constructor calls.\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\treturn arrayNodeStoredSchema(schema.simpleAllowedTypes, schema.persistedMetadata);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const fieldSchema of schema.fields.values()) {\n\t\t\t\tfields.set(brand(fieldSchema.storedKey), convertField(fieldSchema));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields, schema.persistedMetadata);\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\n/**\n * Converts a {@link SimpleNodeSchema} from view to stored.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema<SchemaType.View>,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): SimpleNodeSchema<SchemaType.Stored>;\n\n/**\n * Converts a {@link SimpleNodeSchema}.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleNodeSchema;\n\n/**\n * TODO: Persist node metadata once schema FormatV2 is supported.\n *\n * This is only exported for use by tests: if other users need them more overloads could be provided, but this is currently sufficient.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleNodeSchema {\n\tconst metadata = {\n\t\tpersistedMetadata: schema.persistedMetadata,\n\t\tmetadata: preservesViewData(options)\n\t\t\t? {\n\t\t\t\t\tcustom: schema.metadata.custom,\n\t\t\t\t\tdescription: schema.metadata.description,\n\t\t\t\t}\n\t\t\t: {},\n\t};\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tleafKind: schema.leafKind,\n\t\t\t\t...metadata,\n\t\t\t} satisfies SimpleLeafNodeSchema;\n\t\t}\n\t\tcase NodeKind.Array:\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\t...metadata,\n\t\t\t\tsimpleAllowedTypes: filterAllowedTypes(schema.simpleAllowedTypes, options),\n\t\t\t} satisfies SimpleMapNodeSchema | SimpleRecordNodeSchema | SimpleArrayNodeSchema;\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\t...metadata,\n\t\t\t\tfields: transformMapValues(schema.fields, (f) => ({\n\t\t\t\t\t...filterFieldAllowedTypes(f, options),\n\t\t\t\t\tstoredKey: f.storedKey,\n\t\t\t\t})),\n\t\t\t\tallowUnknownOptionalFields: filterViewData(options, schema.allowUnknownOptionalFields),\n\t\t\t} satisfies SimpleObjectNodeSchema;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\nfunction arrayNodeStoredSchema(\n\tschema: SimpleAllowedTypes<SchemaType.Stored>,\n\tpersistedMetadata: JsonCompatibleReadOnlyObject | undefined,\n): ObjectNodeStoredSchema {\n\tconst field = {\n\t\tkind: FieldKinds.sequence.identifier,\n\t\ttypes: convertAllowedTypes(schema),\n\t\tpersistedMetadata,\n\t};\n\tconst fields = new Map([[EmptyKey, field]]);\n\treturn new ObjectNodeStoredSchema(fields, persistedMetadata);\n}\n\n/**\n * Converts a {@link SimpleAllowedTypes} to a stored schema.\n * @param schema - The schema to convert.\n * @param options - The options to use for filtering.\n * @returns The converted stored schema.\n */\nexport function filterAllowedTypes(\n\tschema: SimpleAllowedTypes,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleAllowedTypes {\n\tconst filtered: Map<string, SimpleAllowedTypeAttributes> = new Map();\n\tfor (const [type, data] of schema) {\n\t\tif (options === Unchanged) {\n\t\t\tfiltered.set(type, { isStaged: data.isStaged });\n\t\t} else if (allowedTypeFilter(data, options)) {\n\t\t\tfiltered.set(type, { isStaged: undefined });\n\t\t}\n\t}\n\treturn filtered;\n}\n\nfunction filterFieldAllowedTypes(\n\tf: SimpleFieldSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleFieldSchema {\n\treturn {\n\t\tkind: f.kind,\n\t\tpersistedMetadata: f.persistedMetadata,\n\t\tmetadata: preservesViewData(options)\n\t\t\t? {\n\t\t\t\t\tcustom: f.metadata.custom,\n\t\t\t\t\tdescription: f.metadata.description,\n\t\t\t\t}\n\t\t\t: {},\n\t\tsimpleAllowedTypes: filterAllowedTypes(f.simpleAllowedTypes, options),\n\t};\n}\n\n/**\n * Converts a stored {@link SimpleAllowedTypes} to a {@link TreeTypeSet}.\n */\nfunction convertAllowedTypes(schema: SimpleAllowedTypes<SchemaType.Stored>): TreeTypeSet {\n\treturn new Set(schema.keys() as Iterable<TreeNodeSchemaIdentifier>);\n}\n\n/**\n * Filters an allowed type based on the provided options.\n * @param allowedType - The allowed type to filter.\n * @param options - The options to use for filtering.\n * @returns Whether the allowed type passes the filter.\n */\nfunction allowedTypeFilter(\n\tdata: SimpleAllowedTypeAttributes,\n\toptions: StoredSchemaGenerationOptions,\n): boolean {\n\tif (options === ExpectStored) {\n\t\tif (data.isStaged !== undefined) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Failed to covert view schema to stored schema. The simple schema provided was indicated to be a stored schema by the use of `ExpectStored`, but view schema specific content was encountered which requires a `StoredFromViewSchemaGenerationOptions` to process.\",\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n\n\tif (data.isStaged === undefined) {\n\t\tthrow new UsageError(\n\t\t\t\"Failed to covert view schema to stored schema. The simple schema provided as the view schema was actually a stored schema. If this was intended, use `ExpectStored` for the `StoredSchemaGenerationOptions` to indicate the input is already a stored schema and only a format conversion is required.\",\n\t\t);\n\t}\n\n\t// If the allowed type is staged, only include it if the options allow it.\n\tif (data.isStaged === false) {\n\t\treturn true;\n\t}\n\n\treturn options.includeStaged(data.isStaged);\n}\n\nfunction isStoredFromView(\n\toptions: SimpleSchemaTransformationOptions,\n): options is StoredFromViewSchemaGenerationOptions {\n\treturn typeof options === \"object\" && \"includeStaged\" in options;\n}\n\nfunction filterViewData<T>(\n\toptions: SimpleSchemaTransformationOptions,\n\tdata: T,\n): T | undefined {\n\treturn preservesViewData(options) ? data : undefined;\n}\n\n/**\n * Determines if the provided options indicate that view specific data should be preserved.\n * @remarks\n * This assumes that stored simple schema should not contain view specific data.\n * Therefore the only case where what this returns should matter is when the input schema is view schema\n * (and thus there might be view specific data).\n */\nfunction preservesViewData(options: SimpleSchemaTransformationOptions): boolean {\n\t// As noted above in the doc comment, the only case we care about the return value is when the input is a view schema.\n\t// There are two such cases: isStoredFromView where we return false, and Unchanged when applied to a view schema, where we return true.\n\t// It does not matter what we return in other cases, so for simplicity they just end up as \"true\".\n\treturn isStoredFromView(options) ? false : true;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { TreeNodeSchema } from "./core/index.js";
6
+ import { type FieldSchemaAlpha, type ImplicitFieldSchema } from "./fieldSchema.js";
7
+ import type { SchemaType, SimpleNodeSchema, SimpleTreeSchema } from "./simpleSchema.js";
8
+ export declare function createTreeSchema(rootSchema: ImplicitFieldSchema): TreeSchema;
9
+ /**
10
+ * {@link TreeViewConfigurationAlpha}
11
+ * @sealed @alpha
12
+ */
13
+ export interface TreeSchema extends SimpleTreeSchema<SchemaType.View> {
14
+ /**
15
+ * {@inheritDoc SimpleTreeSchema.root}
16
+ */
17
+ readonly root: FieldSchemaAlpha;
18
+ /**
19
+ * {@inheritDoc SimpleTreeSchema.definitions}
20
+ */
21
+ readonly definitions: ReadonlyMap<string, SimpleNodeSchema<SchemaType.View> & TreeNodeSchema>;
22
+ }
23
+ //# sourceMappingURL=treeSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/treeSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EAExB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGxF,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,mBAAmB,GAAG,UAAU,CAmB5E;AAED;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC;IACpE;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAChC,MAAM,EACN,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAClD,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { UsageError } from "@fluidframework/telemetry-utils/internal";
6
+ import { normalizeFieldSchema, } from "./fieldSchema.js";
7
+ import { walkFieldSchema } from "./walkFieldSchema.js";
8
+ export function createTreeSchema(rootSchema) {
9
+ const root = normalizeFieldSchema(rootSchema);
10
+ const definitions = new Map();
11
+ walkFieldSchema(root, {
12
+ node: (schema) => {
13
+ if (definitions.has(schema.identifier)) {
14
+ throw new UsageError(`Multiple schema encountered with the identifier ${JSON.stringify(schema.identifier)}. Remove or rename them to avoid the collision.`);
15
+ }
16
+ definitions.set(schema.identifier, schema);
17
+ },
18
+ });
19
+ return { root, definitions };
20
+ }
21
+ //# sourceMappingURL=treeSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeSchema.js","sourceRoot":"","sources":["../../src/simple-tree/treeSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAGN,oBAAoB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,UAAU,gBAAgB,CAAC,UAA+B;IAC/D,MAAM,IAAI,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,IAAI,GAAG,EAA8D,CAAC;IAE1F,eAAe,CAAC,IAAI,EAAE;QACrB,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE;YAChB,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxC,MAAM,IAAI,UAAU,CACnB,mDAAmD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,iDAAiD,CACrI,CAAC;YACH,CAAC;YACD,WAAW,CAAC,GAAG,CACd,MAAM,CAAC,UAAU,EACjB,MAA4D,CAC5D,CAAC;QACH,CAAC;KACD,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { TreeNodeSchema } from \"./core/index.js\";\nimport {\n\ttype FieldSchemaAlpha,\n\ttype ImplicitFieldSchema,\n\tnormalizeFieldSchema,\n} from \"./fieldSchema.js\";\nimport type { SchemaType, SimpleNodeSchema, SimpleTreeSchema } from \"./simpleSchema.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\n\nexport function createTreeSchema(rootSchema: ImplicitFieldSchema): TreeSchema {\n\tconst root = normalizeFieldSchema(rootSchema);\n\tconst definitions = new Map<string, SimpleNodeSchema<SchemaType.View> & TreeNodeSchema>();\n\n\twalkFieldSchema(root, {\n\t\tnode: (schema) => {\n\t\t\tif (definitions.has(schema.identifier)) {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(schema.identifier)}. Remove or rename them to avoid the collision.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdefinitions.set(\n\t\t\t\tschema.identifier,\n\t\t\t\tschema as SimpleNodeSchema<SchemaType.View> & TreeNodeSchema,\n\t\t\t);\n\t\t},\n\t});\n\n\treturn { root, definitions };\n}\n\n/**\n * {@link TreeViewConfigurationAlpha}\n * @sealed @alpha\n */\nexport interface TreeSchema extends SimpleTreeSchema<SchemaType.View> {\n\t/**\n\t * {@inheritDoc SimpleTreeSchema.root}\n\t */\n\treadonly root: FieldSchemaAlpha;\n\n\t/**\n\t * {@inheritDoc SimpleTreeSchema.definitions}\n\t */\n\treadonly definitions: ReadonlyMap<\n\t\tstring,\n\t\tSimpleNodeSchema<SchemaType.View> & TreeNodeSchema\n\t>;\n}\n"]}
@@ -3,10 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { IFluidHandle } from "@fluidframework/core-interfaces";
6
- import { type ImplicitFieldSchema } from "./fieldSchema.js";
6
+ import type { FlexTreeNode } from "../feature-libraries/index.js";
7
+ import type { ImplicitFieldSchema } from "./fieldSchema.js";
7
8
  import { type TreeNode, type TreeNodeSchema, type Unhydrated, UnhydratedFlexTreeNode } from "./core/index.js";
8
9
  /**
9
- * Transforms an input {@link TypedNode} tree to an {@link UnhydratedFlexTreeNode}.
10
+ * Transforms an input {@link TypedNode} tree to a {@link FlexTreeNode}.
10
11
  * @param data - The input tree to be converted.
11
12
  * If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,
12
13
  * otherwise an error will be thrown.
@@ -31,11 +32,19 @@ import { type TreeNode, type TreeNodeSchema, type Unhydrated, UnhydratedFlexTree
31
32
  * Output should comply with the provided view schema, but this is not explicitly validated:
32
33
  * validation against stored schema (to guard against document corruption) is done elsewhere.
33
34
  */
35
+ export declare function flexTreeFromInsertable<TIn extends InsertableContent | undefined>(data: TIn, allowedTypes: ImplicitFieldSchema): TIn extends undefined ? undefined : FlexTreeNode;
36
+ /**
37
+ * Wrapper around {@link flexTreeFromInsertable} which always returns an unhydrated nodes (or undefined).
38
+ * @remarks
39
+ * This does not deeply check content is unhydrated.
40
+ *
41
+ * Once hybrid content is better supported, this should likely be removed as a simplification.
42
+ */
34
43
  export declare function unhydratedFlexTreeFromInsertable<TIn extends InsertableContent | undefined>(data: TIn, allowedTypes: ImplicitFieldSchema): TIn extends undefined ? undefined : UnhydratedFlexTreeNode;
35
44
  /**
36
- * Copy content from `data` into a UnhydratedFlexTreeNode.
45
+ * Copy content from `data` into a UnhydratedFlexTreeNode or return an existing node if `data` is a TreeNode.
37
46
  */
38
- export declare function unhydratedFlexTreeFromInsertableNode(data: InsertableContent, allowedTypes: ReadonlySet<TreeNodeSchema>): UnhydratedFlexTreeNode;
47
+ export declare function flexTreeFromInsertableNode(data: InsertableContent, allowedTypes: ReadonlySet<TreeNodeSchema>): FlexTreeNode;
39
48
  /**
40
49
  * Returns all types for which the data is schema-compatible.
41
50
  * @remarks This will respect the {@link contentSchemaSymbol} property on data to disambiguate types - if present, only that type will be returned.
@@ -1 +1 @@
1
- {"version":3,"file":"unhydratedFlexTreeFromInsertable.d.ts","sourceRoot":"","sources":["../../src/simple-tree/unhydratedFlexTreeFromInsertable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAMpE,OAAO,EAAmC,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAKN,KAAK,QAAQ,EACb,KAAK,cAAc,EAEnB,KAAK,UAAU,EACf,sBAAsB,EACtB,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,SAAS,iBAAiB,GAAG,SAAS,EACzF,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,mBAAmB,GAC/B,GA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B,GAAG,SAAS,EAC/E,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,mBAAmB,GAC/B,GAAG,SAAS,SAAS,GAAG,SAAS,GAAG,YAAY,CAiBlD;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,SAAS,iBAAiB,GAAG,SAAS,EACzF,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,mBAAmB,GAC/B,GAAG,SAAS,SAAS,GAAG,SAAS,GAAG,sBAAsB,CAO5D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,iBAAiB,EACvB,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,GACvC,YAAY,CAgCd;AA2BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC/B,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,EACzC,IAAI,EAAE,cAAc,GAClB,cAAc,EAAE,CA2BlB;AAED;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACvB,YAAY,GACZ,MAAM,GACN,MAAM,GACN,OAAO,GAEP,IAAI,GACJ,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAC9C,SAAS,iBAAiB,EAAE,GAC5B,oBAAoB,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,iBAAiB;CAC1C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC"}
@@ -9,7 +9,7 @@ import { normalizeFieldSchema, FieldKind } from "./fieldSchema.js";
9
9
  import { CompatibilityLevel, getKernel, getTreeNodeSchemaPrivateData, isTreeNode, contentSchemaSymbol, UnhydratedFlexTreeNode, } from "./core/index.js";
10
10
  import { getUnhydratedContext } from "./createContext.js";
11
11
  /**
12
- * Transforms an input {@link TypedNode} tree to an {@link UnhydratedFlexTreeNode}.
12
+ * Transforms an input {@link TypedNode} tree to a {@link FlexTreeNode}.
13
13
  * @param data - The input tree to be converted.
14
14
  * If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,
15
15
  * otherwise an error will be thrown.
@@ -34,7 +34,7 @@ import { getUnhydratedContext } from "./createContext.js";
34
34
  * Output should comply with the provided view schema, but this is not explicitly validated:
35
35
  * validation against stored schema (to guard against document corruption) is done elsewhere.
36
36
  */
37
- export function unhydratedFlexTreeFromInsertable(data, allowedTypes) {
37
+ export function flexTreeFromInsertable(data, allowedTypes) {
38
38
  const normalizedFieldSchema = normalizeFieldSchema(allowedTypes);
39
39
  if (data === undefined) {
40
40
  // TODO: this code-path should support defaults
@@ -43,24 +43,41 @@ export function unhydratedFlexTreeFromInsertable(data, allowedTypes) {
43
43
  }
44
44
  return undefined;
45
45
  }
46
- const flexTree = unhydratedFlexTreeFromInsertableNode(data, normalizedFieldSchema.allowedTypeSet);
46
+ const flexTree = flexTreeFromInsertableNode(data, normalizedFieldSchema.allowedTypeSet);
47
47
  return flexTree;
48
48
  }
49
49
  /**
50
- * Copy content from `data` into a UnhydratedFlexTreeNode.
50
+ * Wrapper around {@link flexTreeFromInsertable} which always returns an unhydrated nodes (or undefined).
51
+ * @remarks
52
+ * This does not deeply check content is unhydrated.
53
+ *
54
+ * Once hybrid content is better supported, this should likely be removed as a simplification.
55
+ */
56
+ export function unhydratedFlexTreeFromInsertable(data, allowedTypes) {
57
+ const result = flexTreeFromInsertable(data, allowedTypes);
58
+ if (result === undefined) {
59
+ return undefined;
60
+ }
61
+ assert(result instanceof UnhydratedFlexTreeNode, "expected unhydrated node");
62
+ return result;
63
+ }
64
+ /**
65
+ * Copy content from `data` into a UnhydratedFlexTreeNode or return an existing node if `data` is a TreeNode.
51
66
  */
52
- export function unhydratedFlexTreeFromInsertableNode(data, allowedTypes) {
67
+ export function flexTreeFromInsertableNode(data, allowedTypes) {
53
68
  if (isTreeNode(data)) {
54
69
  const kernel = getKernel(data);
55
- const inner = kernel.getInnerNodeIfUnhydrated();
56
- if (inner === undefined) {
57
- // The node is already hydrated, meaning that it already got inserted into the tree previously
58
- throw new UsageError("A node may not be inserted into the tree more than once");
70
+ const inner = kernel.getInnerNode();
71
+ if (inner.parentField.parent.parent !== undefined) {
72
+ throw new UsageError("A node which already has a parent may not be used as part of a new tree.");
59
73
  }
60
74
  else {
61
75
  if (!allowedTypes.has(kernel.schema)) {
62
76
  throw new UsageError("Invalid schema for this context.");
63
77
  }
78
+ if (inner.isHydrated()) {
79
+ // TODO: hook up event bubbling from hydrated to unhydrated tree.
80
+ }
64
81
  return inner;
65
82
  }
66
83
  }
@@ -1 +1 @@
1
- {"version":3,"file":"unhydratedFlexTreeFromInsertable.js","sourceRoot":"","sources":["../../src/simple-tree/unhydratedFlexTreeFromInsertable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAA4B,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,4BAA4B,EAC5B,UAAU,EAGV,mBAAmB,EAEnB,sBAAsB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,gCAAgC,CAC/C,IAAS,EACT,YAAiC;IAEjC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAEjE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,+CAA+C;QAC/C,IAAI,qBAAqB,CAAC,IAAI,KAAK,SAAS,CAAC,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CAAC,CAAC;IAChF,CAAC;SAAM,CAAC;QACP,OAAO,GAAG,YAAY,CAAC;IACxB,CAAC;IAED,2GAA2G;IAC3G,IAAI,IAAI,GAAG,kBAAkB,CAAC,GAAG,CAAC;IAClC,MAAM,aAAa,GAAqB,EAAE,CAAC;IAC3C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,4BAA4B,CAAC,MAAM,CAAC,CAAC,oBAAoB,EAAE,CAAC;QAC5E,MAAM,KAAK,GAAG,OAAO,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;YAClB,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;YACzB,IAAI,GAAG,KAAK,CAAC;QACd,CAAC;QACD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YACpB,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;IACF,CAAC;IACD,OAAO,aAAa,CAAC;AACtB,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 { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport { filterIterable, hasSingle, oneFromIterable } from \"../util/index.js\";\n\nimport { normalizeFieldSchema, FieldKind, type ImplicitFieldSchema } from \"./fieldSchema.js\";\nimport {\n\tCompatibilityLevel,\n\tgetKernel,\n\tgetTreeNodeSchemaPrivateData,\n\tisTreeNode,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\tcontentSchemaSymbol,\n\ttype Unhydrated,\n\tUnhydratedFlexTreeNode,\n} from \"./core/index.js\";\nimport { getUnhydratedContext } from \"./createContext.js\";\n\n/**\n * Transforms an input {@link TypedNode} tree to an {@link UnhydratedFlexTreeNode}.\n * @param data - The input tree to be converted.\n * If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,\n * otherwise an error will be thrown.\n *\n * Fallbacks:\n *\n * * `NaN` =\\> `null`\n *\n * * `+/-∞` =\\> `null`\n *\n * * `-0` =\\> `+0`\n *\n * For fields with a default value, the field may be omitted.\n * If `context` is not provided, defaults which require a context will be left empty which can be out of schema.\n *\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n * @remarks\n * The resulting tree will be populated with any defaults from {@link FieldProvider}s in the schema.\n *\n * Often throws UsageErrors for invalid data, but may miss some cases.\n *\n * Output should comply with the provided view schema, but this is not explicitly validated:\n * validation against stored schema (to guard against document corruption) is done elsewhere.\n */\nexport function unhydratedFlexTreeFromInsertable<TIn extends InsertableContent | undefined>(\n\tdata: TIn,\n\tallowedTypes: ImplicitFieldSchema,\n): TIn extends undefined ? undefined : UnhydratedFlexTreeNode {\n\tconst normalizedFieldSchema = normalizeFieldSchema(allowedTypes);\n\n\tif (data === undefined) {\n\t\t// TODO: this code-path should support defaults\n\t\tif (normalizedFieldSchema.kind !== FieldKind.Optional) {\n\t\t\tthrow new UsageError(\"Got undefined for non-optional field.\");\n\t\t}\n\t\treturn undefined as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n\t}\n\n\tconst flexTree: UnhydratedFlexTreeNode = unhydratedFlexTreeFromInsertableNode(\n\t\tdata,\n\t\tnormalizedFieldSchema.allowedTypeSet,\n\t);\n\n\treturn flexTree as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n}\n\n/**\n * Copy content from `data` into a UnhydratedFlexTreeNode.\n */\nexport function unhydratedFlexTreeFromInsertableNode(\n\tdata: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): UnhydratedFlexTreeNode {\n\tif (isTreeNode(data)) {\n\t\tconst kernel = getKernel(data);\n\t\tconst inner = kernel.getInnerNodeIfUnhydrated();\n\t\tif (inner === undefined) {\n\t\t\t// The node is already hydrated, meaning that it already got inserted into the tree previously\n\t\t\tthrow new UsageError(\"A node may not be inserted into the tree more than once\");\n\t\t} else {\n\t\t\tif (!allowedTypes.has(kernel.schema)) {\n\t\t\t\tthrow new UsageError(\"Invalid schema for this context.\");\n\t\t\t}\n\t\t\treturn inner;\n\t\t}\n\t}\n\n\tconst schema = getType(data, allowedTypes);\n\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\tconst result = handler.toFlexContent(data, allowedTypes);\n\n\t// Might not match schema due to fallbacks, see TODO on toFlexContent\n\t// TODO: fix TODO in `toFlexContent`, and remove this.\n\tconst finalSchema =\n\t\toneFromIterable(filterIterable(allowedTypes, (s) => s.identifier === result[0].type)) ??\n\t\tfail(0xc9d /* missing schema */);\n\n\treturn new UnhydratedFlexTreeNode(...result, getUnhydratedContext(finalSchema));\n}\n\nfunction getType(\n\tdata: FactoryContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeNodeSchema {\n\tconst possibleTypes = getPossibleTypes(allowedTypes, data);\n\tif (possibleTypes.length === 0) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is incompatible with all of the types allowed by the schema. The set of allowed types is: ${JSON.stringify(\n\t\t\t\t[...allowedTypes].map((schema) => schema.identifier),\n\t\t\t)}.`,\n\t\t);\n\t}\n\tif (!hasSingle(possibleTypes)) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is compatible with more than one type allowed by the schema.\nThe set of possible types is ${JSON.stringify([\n\t\t\t\t...possibleTypes.map((schema) => schema.identifier),\n\t\t\t])}.\nExplicitly construct an unhydrated node of the desired type to disambiguate.\nFor class-based schema, this can be done by replacing an expression like \"{foo: 1}\" with \"new MySchema({foo: 1})\".`,\n\t\t);\n\t}\n\treturn possibleTypes[0];\n}\n\n/**\n * Returns all types for which the data is schema-compatible.\n * @remarks This will respect the {@link contentSchemaSymbol} property on data to disambiguate types - if present, only that type will be returned.\n */\nexport function getPossibleTypes(\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\tdata: FactoryContent,\n): TreeNodeSchema[] {\n\tassert(data !== undefined, 0x889 /* undefined cannot be used as FactoryContent. */);\n\n\tlet toCheck: Iterable<TreeNodeSchema>;\n\tif (typeof data === \"object\" && data !== null && contentSchemaSymbol in data) {\n\t\t// If the data has an explicit brand via contentSchemaSymbol, only check that type.\n\t\tconst type = data[contentSchemaSymbol];\n\t\ttoCheck = filterIterable(allowedTypes, (schema) => schema.identifier === type);\n\t} else {\n\t\ttoCheck = allowedTypes;\n\t}\n\n\t// Start at the lowest level of compat we would ever accept: this discards types which are less compatible.\n\tlet best = CompatibilityLevel.Low;\n\tconst possibleTypes: TreeNodeSchema[] = [];\n\tfor (const schema of toCheck) {\n\t\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\t\tconst level = handler.shallowCompatibilityTest(data);\n\t\tif (level > best) {\n\t\t\tpossibleTypes.length = 0;\n\t\t\tbest = level;\n\t\t}\n\t\tif (best === level) {\n\t\t\tpossibleTypes.push(schema);\n\t\t}\n\t}\n\treturn possibleTypes;\n}\n\n/**\n * Content which can be used to build a node.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n * @system @alpha\n */\nexport type FactoryContent =\n\t| IFluidHandle\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| Iterable<readonly [string, InsertableContent]>\n\t| readonly InsertableContent[]\n\t| FactoryContentObject;\n\n/**\n * Record-like object which can be used to build some kinds of nodes.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n *\n * Supports object and map nodes.\n * @system @alpha\n */\nexport type FactoryContentObject = {\n\treadonly [P in string]?: InsertableContent;\n};\n\n/**\n * Content which can be inserted into a tree.\n * @system @alpha\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n"]}
1
+ {"version":3,"file":"unhydratedFlexTreeFromInsertable.js","sourceRoot":"","sources":["../../src/simple-tree/unhydratedFlexTreeFromInsertable.ts"],"names":[],"mappings":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G,kBAAkB,CAAC,GAAG,CAAC;IAClC,MAAM,aAAa,GAAqB,EAAE,CAAC;IAC3C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,4BAA4B,CAAC,MAAM,CAAC,CAAC,oBAAoB,EAAE,CAAC;QAC5E,MAAM,KAAK,GAAG,OAAO,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;YAClB,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;YACzB,IAAI,GAAG,KAAK,CAAC;QACd,CAAC;QACD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YACpB,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;IACF,CAAC;IACD,OAAO,aAAa,CAAC;AACtB,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 { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport { filterIterable, hasSingle, oneFromIterable } from \"../util/index.js\";\n\nimport type { FlexTreeNode } from \"../feature-libraries/index.js\";\n\nimport type { ImplicitFieldSchema } from \"./fieldSchema.js\";\nimport { normalizeFieldSchema, FieldKind } from \"./fieldSchema.js\";\nimport {\n\tCompatibilityLevel,\n\tgetKernel,\n\tgetTreeNodeSchemaPrivateData,\n\tisTreeNode,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\tcontentSchemaSymbol,\n\ttype Unhydrated,\n\tUnhydratedFlexTreeNode,\n} from \"./core/index.js\";\nimport { getUnhydratedContext } from \"./createContext.js\";\n\n/**\n * Transforms an input {@link TypedNode} tree to a {@link FlexTreeNode}.\n * @param data - The input tree to be converted.\n * If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,\n * otherwise an error will be thrown.\n *\n * Fallbacks:\n *\n * * `NaN` =\\> `null`\n *\n * * `+/-∞` =\\> `null`\n *\n * * `-0` =\\> `+0`\n *\n * For fields with a default value, the field may be omitted.\n * If `context` is not provided, defaults which require a context will be left empty which can be out of schema.\n *\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n * @remarks\n * The resulting tree will be populated with any defaults from {@link FieldProvider}s in the schema.\n *\n * Often throws UsageErrors for invalid data, but may miss some cases.\n *\n * Output should comply with the provided view schema, but this is not explicitly validated:\n * validation against stored schema (to guard against document corruption) is done elsewhere.\n */\nexport function flexTreeFromInsertable<TIn extends InsertableContent | undefined>(\n\tdata: TIn,\n\tallowedTypes: ImplicitFieldSchema,\n): TIn extends undefined ? undefined : FlexTreeNode {\n\tconst normalizedFieldSchema = normalizeFieldSchema(allowedTypes);\n\n\tif (data === undefined) {\n\t\t// TODO: this code-path should support defaults\n\t\tif (normalizedFieldSchema.kind !== FieldKind.Optional) {\n\t\t\tthrow new UsageError(\"Got undefined for non-optional field.\");\n\t\t}\n\t\treturn undefined as TIn extends undefined ? undefined : FlexTreeNode;\n\t}\n\n\tconst flexTree: FlexTreeNode = flexTreeFromInsertableNode(\n\t\tdata,\n\t\tnormalizedFieldSchema.allowedTypeSet,\n\t);\n\n\treturn flexTree as TIn extends undefined ? undefined : FlexTreeNode;\n}\n\n/**\n * Wrapper around {@link flexTreeFromInsertable} which always returns an unhydrated nodes (or undefined).\n * @remarks\n * This does not deeply check content is unhydrated.\n *\n * Once hybrid content is better supported, this should likely be removed as a simplification.\n */\nexport function unhydratedFlexTreeFromInsertable<TIn extends InsertableContent | undefined>(\n\tdata: TIn,\n\tallowedTypes: ImplicitFieldSchema,\n): TIn extends undefined ? undefined : UnhydratedFlexTreeNode {\n\tconst result = flexTreeFromInsertable(data, allowedTypes);\n\tif (result === undefined) {\n\t\treturn undefined as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n\t}\n\tassert(result instanceof UnhydratedFlexTreeNode, \"expected unhydrated node\");\n\treturn result as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n}\n\n/**\n * Copy content from `data` into a UnhydratedFlexTreeNode or return an existing node if `data` is a TreeNode.\n */\nexport function flexTreeFromInsertableNode(\n\tdata: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): FlexTreeNode {\n\tif (isTreeNode(data)) {\n\t\tconst kernel = getKernel(data);\n\t\tconst inner = kernel.getInnerNode();\n\t\tif (inner.parentField.parent.parent !== undefined) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"A node which already has a parent may not be used as part of a new tree.\",\n\t\t\t);\n\t\t} else {\n\t\t\tif (!allowedTypes.has(kernel.schema)) {\n\t\t\t\tthrow new UsageError(\"Invalid schema for this context.\");\n\t\t\t}\n\n\t\t\tif (inner.isHydrated()) {\n\t\t\t\t// TODO: hook up event bubbling from hydrated to unhydrated tree.\n\t\t\t}\n\n\t\t\treturn inner;\n\t\t}\n\t}\n\n\tconst schema = getType(data, allowedTypes);\n\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\tconst result = handler.toFlexContent(data, allowedTypes);\n\n\t// Might not match schema due to fallbacks, see TODO on toFlexContent\n\t// TODO: fix TODO in `toFlexContent`, and remove this.\n\tconst finalSchema =\n\t\toneFromIterable(filterIterable(allowedTypes, (s) => s.identifier === result[0].type)) ??\n\t\tfail(0xc9d /* missing schema */);\n\n\treturn new UnhydratedFlexTreeNode(...result, getUnhydratedContext(finalSchema));\n}\n\nfunction getType(\n\tdata: FactoryContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeNodeSchema {\n\tconst possibleTypes = getPossibleTypes(allowedTypes, data);\n\tif (possibleTypes.length === 0) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is incompatible with all of the types allowed by the schema. The set of allowed types is: ${JSON.stringify(\n\t\t\t\t[...allowedTypes].map((schema) => schema.identifier),\n\t\t\t)}.`,\n\t\t);\n\t}\n\tif (!hasSingle(possibleTypes)) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is compatible with more than one type allowed by the schema.\nThe set of possible types is ${JSON.stringify([\n\t\t\t\t...possibleTypes.map((schema) => schema.identifier),\n\t\t\t])}.\nExplicitly construct an unhydrated node of the desired type to disambiguate.\nFor class-based schema, this can be done by replacing an expression like \"{foo: 1}\" with \"new MySchema({foo: 1})\".`,\n\t\t);\n\t}\n\treturn possibleTypes[0];\n}\n\n/**\n * Returns all types for which the data is schema-compatible.\n * @remarks This will respect the {@link contentSchemaSymbol} property on data to disambiguate types - if present, only that type will be returned.\n */\nexport function getPossibleTypes(\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\tdata: FactoryContent,\n): TreeNodeSchema[] {\n\tassert(data !== undefined, 0x889 /* undefined cannot be used as FactoryContent. */);\n\n\tlet toCheck: Iterable<TreeNodeSchema>;\n\tif (typeof data === \"object\" && data !== null && contentSchemaSymbol in data) {\n\t\t// If the data has an explicit brand via contentSchemaSymbol, only check that type.\n\t\tconst type = data[contentSchemaSymbol];\n\t\ttoCheck = filterIterable(allowedTypes, (schema) => schema.identifier === type);\n\t} else {\n\t\ttoCheck = allowedTypes;\n\t}\n\n\t// Start at the lowest level of compat we would ever accept: this discards types which are less compatible.\n\tlet best = CompatibilityLevel.Low;\n\tconst possibleTypes: TreeNodeSchema[] = [];\n\tfor (const schema of toCheck) {\n\t\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\t\tconst level = handler.shallowCompatibilityTest(data);\n\t\tif (level > best) {\n\t\t\tpossibleTypes.length = 0;\n\t\t\tbest = level;\n\t\t}\n\t\tif (best === level) {\n\t\t\tpossibleTypes.push(schema);\n\t\t}\n\t}\n\treturn possibleTypes;\n}\n\n/**\n * Content which can be used to build a node.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n * @system @alpha\n */\nexport type FactoryContent =\n\t| IFluidHandle\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| Iterable<readonly [string, InsertableContent]>\n\t| readonly InsertableContent[]\n\t| FactoryContentObject;\n\n/**\n * Record-like object which can be used to build some kinds of nodes.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n *\n * Supports object and map nodes.\n * @system @alpha\n */\nexport type FactoryContentObject = {\n\treadonly [P in string]?: InsertableContent;\n};\n\n/**\n * Content which can be inserted into a tree.\n * @system @alpha\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n"]}