@fluidframework/tree 2.74.0 → 2.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (895) hide show
  1. package/.eslintrc.cjs +1 -16
  2. package/CHANGELOG.md +18 -0
  3. package/api-report/tree.alpha.api.md +20 -2
  4. package/dist/alpha.d.ts +4 -0
  5. package/dist/codec/codec.d.ts +31 -3
  6. package/dist/codec/codec.d.ts.map +1 -1
  7. package/dist/codec/codec.js +10 -0
  8. package/dist/codec/codec.js.map +1 -1
  9. package/dist/codec/index.d.ts +2 -2
  10. package/dist/codec/index.d.ts.map +1 -1
  11. package/dist/codec/index.js +2 -2
  12. package/dist/codec/index.js.map +1 -1
  13. package/dist/codec/versioned/codec.d.ts +80 -22
  14. package/dist/codec/versioned/codec.d.ts.map +1 -1
  15. package/dist/codec/versioned/codec.js +137 -15
  16. package/dist/codec/versioned/codec.js.map +1 -1
  17. package/dist/codec/versioned/index.d.ts +1 -1
  18. package/dist/codec/versioned/index.d.ts.map +1 -1
  19. package/dist/codec/versioned/index.js +2 -2
  20. package/dist/codec/versioned/index.js.map +1 -1
  21. package/dist/core/index.d.ts +2 -2
  22. package/dist/core/index.d.ts.map +1 -1
  23. package/dist/core/index.js +3 -4
  24. package/dist/core/index.js.map +1 -1
  25. package/dist/core/rebase/changeRebaser.d.ts +36 -2
  26. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  27. package/dist/core/rebase/changeRebaser.js.map +1 -1
  28. package/dist/core/rebase/index.d.ts +2 -2
  29. package/dist/core/rebase/index.d.ts.map +1 -1
  30. package/dist/core/rebase/index.js +1 -2
  31. package/dist/core/rebase/index.js.map +1 -1
  32. package/dist/core/rebase/types.d.ts +6 -2
  33. package/dist/core/rebase/types.d.ts.map +1 -1
  34. package/dist/core/rebase/types.js +1 -12
  35. package/dist/core/rebase/types.js.map +1 -1
  36. package/dist/core/rebase/utils.js +3 -3
  37. package/dist/core/rebase/utils.js.map +1 -1
  38. package/dist/core/schema-stored/schema.js +3 -3
  39. package/dist/core/schema-stored/schema.js.map +1 -1
  40. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  41. package/dist/core/tree/anchorSet.js +3 -4
  42. package/dist/core/tree/anchorSet.js.map +1 -1
  43. package/dist/core/tree/detachedFieldIndex.d.ts +1 -2
  44. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  45. package/dist/core/tree/detachedFieldIndex.js +12 -56
  46. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  47. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
  48. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  49. package/dist/core/tree/detachedFieldIndexCodecCommon.js +6 -6
  50. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  51. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
  52. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  53. package/dist/core/tree/detachedFieldIndexCodecV1.js +4 -5
  54. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  55. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
  56. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  57. package/dist/core/tree/detachedFieldIndexCodecV2.js +4 -6
  58. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  59. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
  60. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  61. package/dist/core/tree/detachedFieldIndexCodecs.js +11 -41
  62. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  63. package/dist/core/tree/index.d.ts +1 -1
  64. package/dist/core/tree/index.d.ts.map +1 -1
  65. package/dist/core/tree/index.js +2 -2
  66. package/dist/core/tree/index.js.map +1 -1
  67. package/dist/core/tree/mapTree.js +1 -1
  68. package/dist/core/tree/mapTree.js.map +1 -1
  69. package/dist/core/tree/sparseTree.d.ts.map +1 -1
  70. package/dist/core/tree/sparseTree.js +1 -0
  71. package/dist/core/tree/sparseTree.js.map +1 -1
  72. package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
  73. package/dist/core/tree/treeTextFormat.js +5 -9
  74. package/dist/core/tree/treeTextFormat.js.map +1 -1
  75. package/dist/feature-libraries/changeAtomIdBTree.d.ts +10 -0
  76. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
  77. package/dist/feature-libraries/changeAtomIdBTree.js +16 -0
  78. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -0
  79. package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
  80. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  81. package/dist/feature-libraries/chunked-forest/chunkedForest.js +6 -6
  82. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  83. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  84. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
  85. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  86. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  87. package/dist/feature-libraries/chunked-forest/codec/codecs.js +19 -11
  88. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  89. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  90. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  91. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
  92. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  93. package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  94. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  95. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +15 -5
  96. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  97. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +19 -14
  98. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  99. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
  100. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  101. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
  102. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  103. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +2 -0
  104. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  105. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +6 -0
  106. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  107. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  108. package/dist/feature-libraries/flex-tree/lazyField.js +11 -13
  109. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  110. package/dist/feature-libraries/index.d.ts +3 -2
  111. package/dist/feature-libraries/index.d.ts.map +1 -1
  112. package/dist/feature-libraries/index.js +9 -7
  113. package/dist/feature-libraries/index.js.map +1 -1
  114. package/dist/feature-libraries/indexing/anchorTreeIndex.js +6 -6
  115. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  116. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  117. package/dist/feature-libraries/mitigatedChangeFamily.js +10 -1
  118. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  119. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  120. package/dist/feature-libraries/modular-schema/comparison.js +12 -9
  121. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  122. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
  123. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
  124. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +59 -0
  125. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
  126. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
  127. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  128. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  129. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  130. package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -4
  131. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  132. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +2 -2
  133. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  134. package/dist/feature-libraries/modular-schema/index.d.ts +4 -2
  135. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  136. package/dist/feature-libraries/modular-schema/index.js +11 -7
  137. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  138. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +49 -0
  139. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
  140. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +315 -0
  141. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
  142. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
  143. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
  144. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +31 -0
  145. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
  146. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  147. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  148. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +25 -288
  149. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  150. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
  151. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  152. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +225 -195
  153. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  154. package/dist/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +5 -6
  155. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
  156. package/dist/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +7 -7
  157. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
  158. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
  159. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
  160. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +21 -0
  161. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
  162. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +13 -3
  163. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  164. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  165. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
  166. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  167. package/dist/feature-libraries/object-forest/objectForest.js +4 -4
  168. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  169. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  170. package/dist/feature-libraries/optional-field/optionalField.js +34 -39
  171. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  172. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  173. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +14 -2
  174. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  175. package/dist/feature-libraries/schema-index/codec.d.ts +7 -21
  176. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  177. package/dist/feature-libraries/schema-index/codec.js +28 -70
  178. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  179. package/dist/feature-libraries/schema-index/index.d.ts +2 -2
  180. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  181. package/dist/feature-libraries/schema-index/index.js +2 -5
  182. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  183. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
  184. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  185. package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -12
  186. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  187. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
  188. package/dist/feature-libraries/schemaChecker.js +11 -6
  189. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  190. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  191. package/dist/feature-libraries/sequence-field/compose.js +17 -13
  192. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  193. package/dist/feature-libraries/sequence-field/invert.js +5 -4
  194. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  195. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  196. package/dist/feature-libraries/sequence-field/moveEffectTable.js +15 -9
  197. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  198. package/dist/feature-libraries/sequence-field/rebase.js +26 -18
  199. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  200. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
  201. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  202. package/dist/feature-libraries/sequence-field/replaceRevisions.js +40 -35
  203. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  204. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  205. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +16 -8
  206. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  207. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  208. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +4 -2
  209. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  210. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  211. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +6 -3
  212. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  213. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  214. package/dist/feature-libraries/sequence-field/utils.js +46 -27
  215. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  216. package/dist/feature-libraries/treeCursorUtils.js +7 -7
  217. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  218. package/dist/feature-libraries/treeTextCursor.js +2 -2
  219. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  220. package/dist/feature-libraries/valueUtilities.d.ts.map +1 -1
  221. package/dist/feature-libraries/valueUtilities.js +16 -8
  222. package/dist/feature-libraries/valueUtilities.js.map +1 -1
  223. package/dist/index.d.ts +2 -2
  224. package/dist/index.d.ts.map +1 -1
  225. package/dist/index.js.map +1 -1
  226. package/dist/packageVersion.d.ts +1 -1
  227. package/dist/packageVersion.js +1 -1
  228. package/dist/packageVersion.js.map +1 -1
  229. package/dist/shared-tree/schematizingTreeView.d.ts +2 -3
  230. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  231. package/dist/shared-tree/schematizingTreeView.js +20 -9
  232. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  233. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  234. package/dist/shared-tree/sharedTree.js +61 -44
  235. package/dist/shared-tree/sharedTree.js.map +1 -1
  236. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  237. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  238. package/dist/shared-tree/sharedTreeChangeCodecs.js +9 -8
  239. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  240. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  241. package/dist/shared-tree/sharedTreeChangeEnricher.js +4 -2
  242. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  243. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +3 -2
  244. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  245. package/dist/shared-tree/sharedTreeChangeFamily.js +19 -14
  246. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  247. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  248. package/dist/shared-tree/sharedTreeEditBuilder.js +1 -1
  249. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  250. package/dist/shared-tree/treeAlpha.d.ts +35 -29
  251. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  252. package/dist/shared-tree/treeAlpha.js +21 -23
  253. package/dist/shared-tree/treeAlpha.js.map +1 -1
  254. package/dist/shared-tree/treeCheckout.d.ts +2 -0
  255. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  256. package/dist/shared-tree/treeCheckout.js +31 -18
  257. package/dist/shared-tree/treeCheckout.js.map +1 -1
  258. package/dist/shared-tree-core/branch.d.ts +3 -1
  259. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  260. package/dist/shared-tree-core/branch.js +5 -3
  261. package/dist/shared-tree-core/branch.js.map +1 -1
  262. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  263. package/dist/shared-tree-core/branchCommitEnricher.js +1 -1
  264. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  265. package/dist/shared-tree-core/editManager.js +1 -1
  266. package/dist/shared-tree-core/editManager.js.map +1 -1
  267. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  268. package/dist/shared-tree-core/editManagerCodecs.js +9 -4
  269. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  270. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
  271. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  272. package/dist/shared-tree-core/editManagerFormatCommons.js +6 -0
  273. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  274. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  275. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  276. package/dist/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  277. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  278. package/dist/shared-tree-core/editManagerSummarizer.js +3 -3
  279. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  280. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  281. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  282. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  283. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  284. package/dist/shared-tree-core/messageCodecVSharedBranches.js +2 -1
  285. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  286. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  287. package/dist/shared-tree-core/messageCodecs.js +8 -4
  288. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  289. package/dist/shared-tree-core/messageFormat.d.ts +1 -0
  290. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  291. package/dist/shared-tree-core/messageFormat.js +6 -0
  292. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  293. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
  294. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  295. package/dist/shared-tree-core/messageFormatV1ToV4.js +8 -1
  296. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  297. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  298. package/dist/shared-tree-core/sequenceIdUtils.js +4 -4
  299. package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
  300. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  301. package/dist/shared-tree-core/sharedTreeCore.js +12 -8
  302. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  303. package/dist/shared-tree-core/transaction.d.ts +25 -8
  304. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  305. package/dist/shared-tree-core/transaction.js +65 -30
  306. package/dist/shared-tree-core/transaction.js.map +1 -1
  307. package/dist/shared-tree-core/transactionEnricher.d.ts +2 -2
  308. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  309. package/dist/shared-tree-core/transactionEnricher.js +3 -3
  310. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  311. package/dist/simple-tree/api/configuration.js +1 -1
  312. package/dist/simple-tree/api/configuration.js.map +1 -1
  313. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  314. package/dist/simple-tree/api/customTree.js +13 -9
  315. package/dist/simple-tree/api/customTree.js.map +1 -1
  316. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
  317. package/dist/simple-tree/api/discrepancies.js +21 -17
  318. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  319. package/dist/simple-tree/api/index.d.ts +1 -1
  320. package/dist/simple-tree/api/index.d.ts.map +1 -1
  321. package/dist/simple-tree/api/index.js.map +1 -1
  322. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  323. package/dist/simple-tree/api/schemaFactory.js +12 -8
  324. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  325. package/dist/simple-tree/api/schemaFromSimple.js +18 -9
  326. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  327. package/dist/simple-tree/api/simpleSchemaCodec.js +10 -5
  328. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  329. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  330. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
  331. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  332. package/dist/simple-tree/api/simpleTreeIndex.js +10 -10
  333. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  334. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  335. package/dist/simple-tree/api/storedSchema.js +2 -3
  336. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  337. package/dist/simple-tree/api/transactionTypes.d.ts +17 -4
  338. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  339. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  340. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  341. package/dist/simple-tree/api/treeNodeApi.js +21 -13
  342. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  343. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  344. package/dist/simple-tree/api/verboseTree.js +14 -9
  345. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  346. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  347. package/dist/simple-tree/core/treeNodeKernel.js +6 -3
  348. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  349. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  350. package/dist/simple-tree/core/unhydratedFlexTree.js +20 -15
  351. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  352. package/dist/simple-tree/getTreeNodeForField.d.ts.map +1 -1
  353. package/dist/simple-tree/getTreeNodeForField.js +2 -1
  354. package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
  355. package/dist/simple-tree/index.d.ts +1 -1
  356. package/dist/simple-tree/index.d.ts.map +1 -1
  357. package/dist/simple-tree/index.js.map +1 -1
  358. package/dist/simple-tree/leafNodeSchema.js +9 -6
  359. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  360. package/dist/simple-tree/node-kinds/array/arrayNode.js +15 -15
  361. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  362. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  363. package/dist/simple-tree/node-kinds/object/objectNode.js +4 -5
  364. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  365. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  366. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -3
  367. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  368. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  369. package/dist/simple-tree/toStoredSchema.js +9 -5
  370. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  371. package/dist/treeFactory.js +7 -3
  372. package/dist/treeFactory.js.map +1 -1
  373. package/dist/util/bTreeUtils.js +1 -1
  374. package/dist/util/bTreeUtils.js.map +1 -1
  375. package/dist/util/breakable.js +7 -9
  376. package/dist/util/breakable.js.map +1 -1
  377. package/dist/util/idAllocator.d.ts.map +1 -1
  378. package/dist/util/idAllocator.js +1 -2
  379. package/dist/util/idAllocator.js.map +1 -1
  380. package/dist/util/nestedMap.d.ts.map +1 -1
  381. package/dist/util/nestedMap.js +1 -1
  382. package/dist/util/nestedMap.js.map +1 -1
  383. package/dist/util/utils.d.ts.map +1 -1
  384. package/dist/util/utils.js +16 -15
  385. package/dist/util/utils.js.map +1 -1
  386. package/eslint.config.mts +1 -16
  387. package/lib/alpha.d.ts +4 -0
  388. package/lib/codec/codec.d.ts +31 -3
  389. package/lib/codec/codec.d.ts.map +1 -1
  390. package/lib/codec/codec.js +10 -0
  391. package/lib/codec/codec.js.map +1 -1
  392. package/lib/codec/index.d.ts +2 -2
  393. package/lib/codec/index.d.ts.map +1 -1
  394. package/lib/codec/index.js +1 -1
  395. package/lib/codec/index.js.map +1 -1
  396. package/lib/codec/versioned/codec.d.ts +80 -22
  397. package/lib/codec/versioned/codec.d.ts.map +1 -1
  398. package/lib/codec/versioned/codec.js +138 -15
  399. package/lib/codec/versioned/codec.js.map +1 -1
  400. package/lib/codec/versioned/index.d.ts +1 -1
  401. package/lib/codec/versioned/index.d.ts.map +1 -1
  402. package/lib/codec/versioned/index.js +1 -1
  403. package/lib/codec/versioned/index.js.map +1 -1
  404. package/lib/core/index.d.ts +2 -2
  405. package/lib/core/index.d.ts.map +1 -1
  406. package/lib/core/index.js +2 -2
  407. package/lib/core/index.js.map +1 -1
  408. package/lib/core/rebase/changeRebaser.d.ts +36 -2
  409. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  410. package/lib/core/rebase/changeRebaser.js.map +1 -1
  411. package/lib/core/rebase/index.d.ts +2 -2
  412. package/lib/core/rebase/index.d.ts.map +1 -1
  413. package/lib/core/rebase/index.js +1 -1
  414. package/lib/core/rebase/index.js.map +1 -1
  415. package/lib/core/rebase/types.d.ts +6 -2
  416. package/lib/core/rebase/types.d.ts.map +1 -1
  417. package/lib/core/rebase/types.js +0 -10
  418. package/lib/core/rebase/types.js.map +1 -1
  419. package/lib/core/rebase/utils.js +3 -3
  420. package/lib/core/rebase/utils.js.map +1 -1
  421. package/lib/core/schema-stored/schema.js +3 -3
  422. package/lib/core/schema-stored/schema.js.map +1 -1
  423. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  424. package/lib/core/tree/anchorSet.js +3 -4
  425. package/lib/core/tree/anchorSet.js.map +1 -1
  426. package/lib/core/tree/detachedFieldIndex.d.ts +1 -2
  427. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  428. package/lib/core/tree/detachedFieldIndex.js +13 -57
  429. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  430. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
  431. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  432. package/lib/core/tree/detachedFieldIndexCodecCommon.js +4 -4
  433. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  434. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
  435. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  436. package/lib/core/tree/detachedFieldIndexCodecV1.js +4 -5
  437. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  438. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
  439. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  440. package/lib/core/tree/detachedFieldIndexCodecV2.js +4 -6
  441. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  442. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
  443. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  444. package/lib/core/tree/detachedFieldIndexCodecs.js +12 -39
  445. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  446. package/lib/core/tree/index.d.ts +1 -1
  447. package/lib/core/tree/index.d.ts.map +1 -1
  448. package/lib/core/tree/index.js +1 -1
  449. package/lib/core/tree/index.js.map +1 -1
  450. package/lib/core/tree/mapTree.js +1 -1
  451. package/lib/core/tree/mapTree.js.map +1 -1
  452. package/lib/core/tree/sparseTree.d.ts.map +1 -1
  453. package/lib/core/tree/sparseTree.js +1 -0
  454. package/lib/core/tree/sparseTree.js.map +1 -1
  455. package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
  456. package/lib/core/tree/treeTextFormat.js +5 -9
  457. package/lib/core/tree/treeTextFormat.js.map +1 -1
  458. package/lib/feature-libraries/changeAtomIdBTree.d.ts +10 -0
  459. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
  460. package/lib/feature-libraries/changeAtomIdBTree.js +11 -0
  461. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -0
  462. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  463. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  464. package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -6
  465. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  466. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  467. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
  468. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  469. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  470. package/lib/feature-libraries/chunked-forest/codec/codecs.js +19 -11
  471. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  472. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  473. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  474. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
  475. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  476. package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  477. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  478. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +15 -5
  479. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  480. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +19 -14
  481. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  482. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
  483. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  484. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
  485. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  486. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +2 -0
  487. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  488. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +6 -0
  489. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  490. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  491. package/lib/feature-libraries/flex-tree/lazyField.js +11 -13
  492. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  493. package/lib/feature-libraries/index.d.ts +3 -2
  494. package/lib/feature-libraries/index.d.ts.map +1 -1
  495. package/lib/feature-libraries/index.js +3 -2
  496. package/lib/feature-libraries/index.js.map +1 -1
  497. package/lib/feature-libraries/indexing/anchorTreeIndex.js +6 -6
  498. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  499. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  500. package/lib/feature-libraries/mitigatedChangeFamily.js +10 -1
  501. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  502. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  503. package/lib/feature-libraries/modular-schema/comparison.js +12 -9
  504. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  505. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
  506. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
  507. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +55 -0
  508. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
  509. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
  510. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  511. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  512. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  513. package/lib/feature-libraries/modular-schema/genericFieldKind.js +5 -5
  514. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  515. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js +1 -1
  516. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  517. package/lib/feature-libraries/modular-schema/index.d.ts +4 -2
  518. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  519. package/lib/feature-libraries/modular-schema/index.js +3 -1
  520. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  521. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +49 -0
  522. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
  523. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +298 -0
  524. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
  525. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
  526. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
  527. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +27 -0
  528. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
  529. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  530. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  531. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +27 -290
  532. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  533. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
  534. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  535. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +118 -88
  536. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  537. package/lib/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +5 -6
  538. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
  539. package/lib/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +4 -4
  540. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
  541. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
  542. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
  543. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +18 -0
  544. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
  545. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +13 -3
  546. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  547. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  548. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
  549. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  550. package/lib/feature-libraries/object-forest/objectForest.js +4 -4
  551. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  552. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  553. package/lib/feature-libraries/optional-field/optionalField.js +35 -40
  554. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  555. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  556. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +15 -3
  557. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  558. package/lib/feature-libraries/schema-index/codec.d.ts +7 -21
  559. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  560. package/lib/feature-libraries/schema-index/codec.js +30 -68
  561. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  562. package/lib/feature-libraries/schema-index/index.d.ts +2 -2
  563. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  564. package/lib/feature-libraries/schema-index/index.js +2 -2
  565. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  566. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
  567. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  568. package/lib/feature-libraries/schema-index/schemaSummarizer.js +0 -10
  569. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  570. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
  571. package/lib/feature-libraries/schemaChecker.js +11 -6
  572. package/lib/feature-libraries/schemaChecker.js.map +1 -1
  573. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  574. package/lib/feature-libraries/sequence-field/compose.js +17 -13
  575. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  576. package/lib/feature-libraries/sequence-field/invert.js +5 -4
  577. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  578. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  579. package/lib/feature-libraries/sequence-field/moveEffectTable.js +15 -9
  580. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  581. package/lib/feature-libraries/sequence-field/rebase.js +26 -18
  582. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  583. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
  584. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  585. package/lib/feature-libraries/sequence-field/replaceRevisions.js +41 -36
  586. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  587. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  588. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +16 -8
  589. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  590. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  591. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +4 -2
  592. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  593. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  594. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +6 -3
  595. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  596. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  597. package/lib/feature-libraries/sequence-field/utils.js +46 -27
  598. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  599. package/lib/feature-libraries/treeCursorUtils.js +7 -7
  600. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  601. package/lib/feature-libraries/treeTextCursor.js +2 -2
  602. package/lib/feature-libraries/treeTextCursor.js.map +1 -1
  603. package/lib/feature-libraries/valueUtilities.d.ts.map +1 -1
  604. package/lib/feature-libraries/valueUtilities.js +16 -8
  605. package/lib/feature-libraries/valueUtilities.js.map +1 -1
  606. package/lib/index.d.ts +2 -2
  607. package/lib/index.d.ts.map +1 -1
  608. package/lib/index.js.map +1 -1
  609. package/lib/packageVersion.d.ts +1 -1
  610. package/lib/packageVersion.js +1 -1
  611. package/lib/packageVersion.js.map +1 -1
  612. package/lib/shared-tree/schematizingTreeView.d.ts +2 -3
  613. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  614. package/lib/shared-tree/schematizingTreeView.js +20 -9
  615. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  616. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  617. package/lib/shared-tree/sharedTree.js +30 -13
  618. package/lib/shared-tree/sharedTree.js.map +1 -1
  619. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  620. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  621. package/lib/shared-tree/sharedTreeChangeCodecs.js +9 -8
  622. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  623. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  624. package/lib/shared-tree/sharedTreeChangeEnricher.js +4 -2
  625. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  626. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +3 -2
  627. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  628. package/lib/shared-tree/sharedTreeChangeFamily.js +19 -14
  629. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  630. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  631. package/lib/shared-tree/sharedTreeEditBuilder.js +1 -1
  632. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  633. package/lib/shared-tree/treeAlpha.d.ts +35 -29
  634. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  635. package/lib/shared-tree/treeAlpha.js +21 -23
  636. package/lib/shared-tree/treeAlpha.js.map +1 -1
  637. package/lib/shared-tree/treeCheckout.d.ts +2 -0
  638. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  639. package/lib/shared-tree/treeCheckout.js +32 -19
  640. package/lib/shared-tree/treeCheckout.js.map +1 -1
  641. package/lib/shared-tree-core/branch.d.ts +3 -1
  642. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  643. package/lib/shared-tree-core/branch.js +5 -3
  644. package/lib/shared-tree-core/branch.js.map +1 -1
  645. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  646. package/lib/shared-tree-core/branchCommitEnricher.js +2 -2
  647. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  648. package/lib/shared-tree-core/editManager.js +1 -1
  649. package/lib/shared-tree-core/editManager.js.map +1 -1
  650. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  651. package/lib/shared-tree-core/editManagerCodecs.js +9 -4
  652. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  653. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
  654. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  655. package/lib/shared-tree-core/editManagerFormatCommons.js +6 -0
  656. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  657. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  658. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  659. package/lib/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  660. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  661. package/lib/shared-tree-core/editManagerSummarizer.js +3 -3
  662. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  663. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  664. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  665. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  666. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  667. package/lib/shared-tree-core/messageCodecVSharedBranches.js +2 -1
  668. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  669. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  670. package/lib/shared-tree-core/messageCodecs.js +8 -4
  671. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  672. package/lib/shared-tree-core/messageFormat.d.ts +1 -0
  673. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  674. package/lib/shared-tree-core/messageFormat.js +6 -0
  675. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  676. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
  677. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  678. package/lib/shared-tree-core/messageFormatV1ToV4.js +8 -1
  679. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  680. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  681. package/lib/shared-tree-core/sequenceIdUtils.js +4 -4
  682. package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
  683. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  684. package/lib/shared-tree-core/sharedTreeCore.js +12 -8
  685. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  686. package/lib/shared-tree-core/transaction.d.ts +25 -8
  687. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  688. package/lib/shared-tree-core/transaction.js +67 -32
  689. package/lib/shared-tree-core/transaction.js.map +1 -1
  690. package/lib/shared-tree-core/transactionEnricher.d.ts +2 -2
  691. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  692. package/lib/shared-tree-core/transactionEnricher.js +3 -3
  693. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  694. package/lib/simple-tree/api/configuration.js +1 -1
  695. package/lib/simple-tree/api/configuration.js.map +1 -1
  696. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  697. package/lib/simple-tree/api/customTree.js +13 -9
  698. package/lib/simple-tree/api/customTree.js.map +1 -1
  699. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
  700. package/lib/simple-tree/api/discrepancies.js +21 -17
  701. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  702. package/lib/simple-tree/api/index.d.ts +1 -1
  703. package/lib/simple-tree/api/index.d.ts.map +1 -1
  704. package/lib/simple-tree/api/index.js.map +1 -1
  705. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  706. package/lib/simple-tree/api/schemaFactory.js +12 -8
  707. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  708. package/lib/simple-tree/api/schemaFromSimple.js +18 -9
  709. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  710. package/lib/simple-tree/api/simpleSchemaCodec.js +10 -5
  711. package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  712. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  713. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
  714. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  715. package/lib/simple-tree/api/simpleTreeIndex.js +10 -10
  716. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  717. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  718. package/lib/simple-tree/api/storedSchema.js +4 -7
  719. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  720. package/lib/simple-tree/api/transactionTypes.d.ts +17 -4
  721. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  722. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  723. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  724. package/lib/simple-tree/api/treeNodeApi.js +21 -13
  725. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  726. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  727. package/lib/simple-tree/api/verboseTree.js +14 -9
  728. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  729. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  730. package/lib/simple-tree/core/treeNodeKernel.js +6 -3
  731. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  732. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  733. package/lib/simple-tree/core/unhydratedFlexTree.js +20 -15
  734. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  735. package/lib/simple-tree/getTreeNodeForField.d.ts.map +1 -1
  736. package/lib/simple-tree/getTreeNodeForField.js +2 -1
  737. package/lib/simple-tree/getTreeNodeForField.js.map +1 -1
  738. package/lib/simple-tree/index.d.ts +1 -1
  739. package/lib/simple-tree/index.d.ts.map +1 -1
  740. package/lib/simple-tree/index.js.map +1 -1
  741. package/lib/simple-tree/leafNodeSchema.js +9 -6
  742. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  743. package/lib/simple-tree/node-kinds/array/arrayNode.js +15 -15
  744. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  745. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  746. package/lib/simple-tree/node-kinds/object/objectNode.js +4 -5
  747. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  748. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  749. package/lib/simple-tree/node-kinds/record/recordNode.js +2 -3
  750. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  751. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  752. package/lib/simple-tree/toStoredSchema.js +9 -5
  753. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  754. package/lib/treeFactory.js +7 -3
  755. package/lib/treeFactory.js.map +1 -1
  756. package/lib/util/bTreeUtils.js +1 -1
  757. package/lib/util/bTreeUtils.js.map +1 -1
  758. package/lib/util/breakable.js +7 -9
  759. package/lib/util/breakable.js.map +1 -1
  760. package/lib/util/idAllocator.d.ts.map +1 -1
  761. package/lib/util/idAllocator.js +1 -2
  762. package/lib/util/idAllocator.js.map +1 -1
  763. package/lib/util/nestedMap.d.ts.map +1 -1
  764. package/lib/util/nestedMap.js +1 -1
  765. package/lib/util/nestedMap.js.map +1 -1
  766. package/lib/util/utils.d.ts.map +1 -1
  767. package/lib/util/utils.js +16 -15
  768. package/lib/util/utils.js.map +1 -1
  769. package/package.json +32 -32
  770. package/src/codec/codec.ts +48 -8
  771. package/src/codec/index.ts +4 -1
  772. package/src/codec/versioned/codec.ts +340 -22
  773. package/src/codec/versioned/index.ts +3 -1
  774. package/src/core/index.ts +2 -2
  775. package/src/core/rebase/changeRebaser.ts +40 -6
  776. package/src/core/rebase/index.ts +1 -1
  777. package/src/core/rebase/types.ts +6 -18
  778. package/src/core/rebase/utils.ts +3 -3
  779. package/src/core/schema-stored/schema.ts +3 -3
  780. package/src/core/tree/anchorSet.ts +3 -4
  781. package/src/core/tree/detachedFieldIndex.ts +13 -74
  782. package/src/core/tree/detachedFieldIndexCodecCommon.ts +4 -8
  783. package/src/core/tree/detachedFieldIndexCodecV1.ts +3 -7
  784. package/src/core/tree/detachedFieldIndexCodecV2.ts +5 -9
  785. package/src/core/tree/detachedFieldIndexCodecs.ts +21 -64
  786. package/src/core/tree/index.ts +1 -1
  787. package/src/core/tree/mapTree.ts +1 -1
  788. package/src/core/tree/sparseTree.ts +1 -0
  789. package/src/core/tree/treeTextFormat.ts +5 -9
  790. package/src/feature-libraries/changeAtomIdBTree.ts +24 -0
  791. package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
  792. package/src/feature-libraries/chunked-forest/chunkedForest.ts +5 -5
  793. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +7 -4
  794. package/src/feature-libraries/chunked-forest/codec/codecs.ts +19 -11
  795. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +3 -3
  796. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -5
  797. package/src/feature-libraries/chunked-forest/uniformChunk.ts +1 -1
  798. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +48 -17
  799. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +12 -2
  800. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +6 -0
  801. package/src/feature-libraries/flex-tree/lazyField.ts +13 -14
  802. package/src/feature-libraries/index.ts +10 -5
  803. package/src/feature-libraries/indexing/anchorTreeIndex.ts +5 -5
  804. package/src/feature-libraries/mitigatedChangeFamily.ts +11 -6
  805. package/src/feature-libraries/modular-schema/comparison.ts +12 -9
  806. package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +70 -0
  807. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +3 -6
  808. package/src/feature-libraries/modular-schema/genericFieldKind.ts +5 -7
  809. package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +1 -1
  810. package/src/feature-libraries/modular-schema/index.ts +5 -2
  811. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +703 -0
  812. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +89 -0
  813. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +39 -523
  814. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +159 -125
  815. package/src/feature-libraries/modular-schema/{modularChangeFormat.ts → modularChangeFormatV1.ts} +4 -4
  816. package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +34 -0
  817. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +13 -4
  818. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +1 -1
  819. package/src/feature-libraries/object-forest/objectForest.ts +4 -4
  820. package/src/feature-libraries/optional-field/optionalField.ts +34 -46
  821. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +18 -3
  822. package/src/feature-libraries/schema-index/codec.ts +30 -90
  823. package/src/feature-libraries/schema-index/index.ts +2 -4
  824. package/src/feature-libraries/schema-index/schemaSummarizer.ts +0 -17
  825. package/src/feature-libraries/schemaChecker.ts +11 -6
  826. package/src/feature-libraries/sequence-field/compose.ts +17 -13
  827. package/src/feature-libraries/sequence-field/invert.ts +5 -4
  828. package/src/feature-libraries/sequence-field/moveEffectTable.ts +15 -9
  829. package/src/feature-libraries/sequence-field/rebase.ts +26 -18
  830. package/src/feature-libraries/sequence-field/replaceRevisions.ts +52 -56
  831. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +16 -8
  832. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +4 -2
  833. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +6 -3
  834. package/src/feature-libraries/sequence-field/utils.ts +46 -27
  835. package/src/feature-libraries/treeCursorUtils.ts +7 -7
  836. package/src/feature-libraries/treeTextCursor.ts +2 -2
  837. package/src/feature-libraries/valueUtilities.ts +16 -8
  838. package/src/index.ts +4 -0
  839. package/src/packageVersion.ts +1 -1
  840. package/src/shared-tree/schematizingTreeView.ts +23 -13
  841. package/src/shared-tree/sharedTree.ts +30 -14
  842. package/src/shared-tree/sharedTreeChangeCodecs.ts +10 -9
  843. package/src/shared-tree/sharedTreeChangeEnricher.ts +4 -2
  844. package/src/shared-tree/sharedTreeChangeFamily.ts +29 -19
  845. package/src/shared-tree/sharedTreeEditBuilder.ts +9 -5
  846. package/src/shared-tree/treeAlpha.ts +60 -51
  847. package/src/shared-tree/treeCheckout.ts +66 -50
  848. package/src/shared-tree-core/branch.ts +8 -3
  849. package/src/shared-tree-core/branchCommitEnricher.ts +3 -8
  850. package/src/shared-tree-core/editManager.ts +1 -1
  851. package/src/shared-tree-core/editManagerCodecs.ts +9 -4
  852. package/src/shared-tree-core/editManagerFormatCommons.ts +6 -0
  853. package/src/shared-tree-core/editManagerFormatV1toV4.ts +3 -1
  854. package/src/shared-tree-core/editManagerSummarizer.ts +3 -3
  855. package/src/shared-tree-core/messageCodecV1ToV4.ts +2 -1
  856. package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -1
  857. package/src/shared-tree-core/messageCodecs.ts +8 -4
  858. package/src/shared-tree-core/messageFormat.ts +6 -1
  859. package/src/shared-tree-core/messageFormatV1ToV4.ts +16 -2
  860. package/src/shared-tree-core/sequenceIdUtils.ts +4 -4
  861. package/src/shared-tree-core/sharedTreeCore.ts +11 -7
  862. package/src/shared-tree-core/transaction.ts +115 -56
  863. package/src/shared-tree-core/transactionEnricher.ts +5 -6
  864. package/src/simple-tree/api/configuration.ts +1 -1
  865. package/src/simple-tree/api/customTree.ts +14 -10
  866. package/src/simple-tree/api/discrepancies.ts +23 -17
  867. package/src/simple-tree/api/index.ts +2 -0
  868. package/src/simple-tree/api/schemaFactory.ts +11 -7
  869. package/src/simple-tree/api/schemaFromSimple.ts +18 -9
  870. package/src/simple-tree/api/simpleSchemaCodec.ts +10 -5
  871. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -13
  872. package/src/simple-tree/api/simpleTreeIndex.ts +8 -8
  873. package/src/simple-tree/api/storedSchema.ts +10 -7
  874. package/src/simple-tree/api/transactionTypes.ts +19 -4
  875. package/src/simple-tree/api/treeNodeApi.ts +21 -13
  876. package/src/simple-tree/api/verboseTree.ts +14 -9
  877. package/src/simple-tree/core/treeNodeKernel.ts +6 -3
  878. package/src/simple-tree/core/unhydratedFlexTree.ts +22 -17
  879. package/src/simple-tree/getTreeNodeForField.ts +2 -1
  880. package/src/simple-tree/index.ts +2 -0
  881. package/src/simple-tree/leafNodeSchema.ts +8 -5
  882. package/src/simple-tree/node-kinds/array/arrayNode.ts +23 -23
  883. package/src/simple-tree/node-kinds/object/objectNode.ts +4 -5
  884. package/src/simple-tree/node-kinds/record/recordNode.ts +2 -3
  885. package/src/simple-tree/toStoredSchema.ts +9 -5
  886. package/src/treeFactory.ts +10 -5
  887. package/src/util/bTreeUtils.ts +1 -1
  888. package/src/util/breakable.ts +9 -9
  889. package/src/util/idAllocator.ts +1 -2
  890. package/src/util/nestedMap.ts +1 -3
  891. package/src/util/utils.ts +14 -13
  892. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
  893. package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
  894. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
  895. package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"transactionEnricher.js","sourceRoot":"","sources":["../../src/shared-tree-core/transactionEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAY/B,YACC,OAA+B,EAC/B,QAAiD;QAbzC,+CAAiC;QACjC,gDAAmD;QAC5D,kDAA8C,EAAE,EAAC;QACjD;;;;;WAKG;QACM,sDAAoC,EAAE,EAAC;QAM/C,uBAAA,IAAI,gCAAY,OAAO,MAAA,CAAC;QACxB,uBAAA,IAAI,iCAAa,QAAQ,MAAA,CAAC;IAC3B,CAAC;IAEM,aAAa;QACnB,OAAO,uBAAA,IAAI,mDAAwB,CAAC,MAAM,KAAK,CAAC,CAAC;IAClD,CAAC;IAEM,gBAAgB;QACtB,uBAAA,IAAI,mDAAwB,CAAC,IAAI,CAAC,uBAAA,IAAI,+CAAoB,CAAC,MAAM,CAAC,CAAC;IACpE,CAAC;IAED;;;OAGG;IACI,iBAAiB;QACvB,MAAM,gBAAgB,GAAG,uBAAA,IAAI,mDAAwB,CAAC,GAAG,EAAE,CAAC;QAC5D,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC7E,IAAI,uBAAA,IAAI,mDAAwB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/C,IAAI,uBAAA,IAAI,+CAAoB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC3C,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,MAAM,kBAAkB,GAAG,uBAAA,IAAI,+CAAoB,CAAC;YACpD,uBAAA,IAAI,2CAAuB,EAAE,MAAA,CAAC;YAC9B,OAAO,CAAC,QAAqB,EAAE,EAAE,CAChC,uBAAA,IAAI,oCAAS,CAAC,cAAc,CAAC,uBAAA,IAAI,oCAAS,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,CAAC;QACpF,CAAC;IACF,CAAC;IAEM,gBAAgB;QACtB,MAAM,UAAU,GAAG,uBAAA,IAAI,mDAAwB,CAAC,GAAG,EAAE,CAAC;QACtD,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACtE,uBAAA,IAAI,+CAAoB,CAAC,MAAM,GAAG,UAAU,CAAC;IAC9C,CAAC;IAEM,kBAAkB,CAAC,MAA4B;QACrD,MAAM,CACL,uBAAA,IAAI,mDAAwB,CAAC,MAAM,KAAK,CAAC,EACzC,KAAK,CAAC,qCAAqC,CAC3C,CAAC;QACF,MAAM,MAAM,GAAG,uBAAA,IAAI,qCAAU,CAAC,uBAAuB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACtF,uBAAA,IAAI,+CAAoB,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ChangeRebaser, GraphCommit, RevisionTag } from \"../core/index.js\";\n\nimport type { ChangeEnricherReadonlyCheckout } from \"./changeEnricher.js\";\n\n/**\n * Utility for producing an enriched commit out of multiple transaction steps\n */\nexport class TransactionEnricher<TChange> {\n\treadonly #rebaser: ChangeRebaser<TChange>;\n\treadonly #enricher: ChangeEnricherReadonlyCheckout<TChange>;\n\t#transactionCommits: GraphCommit<TChange>[] = [];\n\t/**\n\t * The number of commits before the start of each active transaction scope.\n\t * For a stack of `n` transaction scopes, the array will contain `n` integers,\n\t * where the integer at index `i` is the number of commits made before the start of the `i`th transaction scope\n\t * (therefore, the first element in the array, if present, is always 0)\n\t */\n\treadonly #transactionScopesStart: number[] = [];\n\n\tpublic constructor(\n\t\trebaser: ChangeRebaser<TChange>,\n\t\tenricher: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tthis.#rebaser = rebaser;\n\t\tthis.#enricher = enricher;\n\t}\n\n\tpublic isTransacting(): boolean {\n\t\treturn this.#transactionScopesStart.length !== 0;\n\t}\n\n\tpublic startTransaction(): void {\n\t\tthis.#transactionScopesStart.push(this.#transactionCommits.length);\n\t}\n\n\t/**\n\t * Commits the current transaction.\n\t * @returns A function which can be used to compute the composed change for that transaction's commits. Undefined if the transaction is still ongoing or contained no committed changes.\n\t */\n\tpublic commitTransaction(): ((revision: RevisionTag) => TChange) | undefined {\n\t\tconst commitsCommitted = this.#transactionScopesStart.pop();\n\t\tassert(commitsCommitted !== undefined, 0x985 /* No transaction to commit */);\n\t\tif (this.#transactionScopesStart.length === 0) {\n\t\t\tif (this.#transactionCommits.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst transactionCommits = this.#transactionCommits;\n\t\t\tthis.#transactionCommits = [];\n\t\t\treturn (revision: RevisionTag) =>\n\t\t\t\tthis.#rebaser.changeRevision(this.#rebaser.compose(transactionCommits), revision);\n\t\t}\n\t}\n\n\tpublic abortTransaction(): void {\n\t\tconst scopeStart = this.#transactionScopesStart.pop();\n\t\tassert(scopeStart !== undefined, 0x986 /* No transaction to abort */);\n\t\tthis.#transactionCommits.length = scopeStart;\n\t}\n\n\tpublic addTransactionStep(commit: GraphCommit<TChange>): void {\n\t\tassert(\n\t\t\tthis.#transactionScopesStart.length !== 0,\n\t\t\t0x987 /* No transaction to add a step to */,\n\t\t);\n\t\tconst change = this.#enricher.updateChangeEnrichments(commit.change, commit.revision);\n\t\tthis.#transactionCommits.push({ ...commit, change });\n\t}\n}\n"]}
1
+ {"version":3,"file":"transactionEnricher.js","sourceRoot":"","sources":["../../src/shared-tree-core/transactionEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAY/B,YACC,OAA+B,EAC/B,QAAiD;QAbzC,+CAAiC;QACjC,gDAAmD;QAC5D,kDAA8C,EAAE,EAAC;QACjD;;;;;WAKG;QACM,sDAAoC,EAAE,EAAC;QAM/C,uBAAA,IAAI,gCAAY,OAAO,MAAA,CAAC;QACxB,uBAAA,IAAI,iCAAa,QAAQ,MAAA,CAAC;IAC3B,CAAC;IAEM,aAAa;QACnB,OAAO,uBAAA,IAAI,mDAAwB,CAAC,MAAM,GAAG,CAAC,CAAC;IAChD,CAAC;IAEM,gBAAgB;QACtB,uBAAA,IAAI,mDAAwB,CAAC,IAAI,CAAC,uBAAA,IAAI,+CAAoB,CAAC,MAAM,CAAC,CAAC;IACpE,CAAC;IAED;;;OAGG;IACI,iBAAiB;QACvB,MAAM,gBAAgB,GAAG,uBAAA,IAAI,mDAAwB,CAAC,GAAG,EAAE,CAAC;QAC5D,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC7E,IAAI,uBAAA,IAAI,mDAAwB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/C,IAAI,uBAAA,IAAI,+CAAoB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC3C,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,MAAM,kBAAkB,GAAG,uBAAA,IAAI,+CAAoB,CAAC;YACpD,uBAAA,IAAI,2CAAuB,EAAE,MAAA,CAAC;YAC9B,OAAO,GAAG,EAAE,CAAC,uBAAA,IAAI,oCAAS,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACxD,CAAC;IACF,CAAC;IAEM,gBAAgB;QACtB,MAAM,UAAU,GAAG,uBAAA,IAAI,mDAAwB,CAAC,GAAG,EAAE,CAAC;QACtD,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACtE,uBAAA,IAAI,+CAAoB,CAAC,MAAM,GAAG,UAAU,CAAC;IAC9C,CAAC;IAEM,kBAAkB,CAAC,MAA4B;QACrD,MAAM,CACL,uBAAA,IAAI,mDAAwB,CAAC,MAAM,GAAG,CAAC,EACvC,KAAK,CAAC,qCAAqC,CAC3C,CAAC;QACF,MAAM,MAAM,GAAG,uBAAA,IAAI,qCAAU,CAAC,uBAAuB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACtF,uBAAA,IAAI,+CAAoB,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ChangeRebaser, GraphCommit } from \"../core/index.js\";\n\nimport type { ChangeEnricherReadonlyCheckout } from \"./changeEnricher.js\";\n\n/**\n * Utility for producing an enriched commit out of multiple transaction steps\n */\nexport class TransactionEnricher<TChange> {\n\treadonly #rebaser: ChangeRebaser<TChange>;\n\treadonly #enricher: ChangeEnricherReadonlyCheckout<TChange>;\n\t#transactionCommits: GraphCommit<TChange>[] = [];\n\t/**\n\t * The number of commits before the start of each active transaction scope.\n\t * For a stack of `n` transaction scopes, the array will contain `n` integers,\n\t * where the integer at index `i` is the number of commits made before the start of the `i`th transaction scope\n\t * (therefore, the first element in the array, if present, is always 0)\n\t */\n\treadonly #transactionScopesStart: number[] = [];\n\n\tpublic constructor(\n\t\trebaser: ChangeRebaser<TChange>,\n\t\tenricher: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tthis.#rebaser = rebaser;\n\t\tthis.#enricher = enricher;\n\t}\n\n\tpublic isTransacting(): boolean {\n\t\treturn this.#transactionScopesStart.length > 0;\n\t}\n\n\tpublic startTransaction(): void {\n\t\tthis.#transactionScopesStart.push(this.#transactionCommits.length);\n\t}\n\n\t/**\n\t * Commits the current transaction.\n\t * @returns A function which can be used to compute the composed change for that transaction's commits. Undefined if the transaction is still ongoing or contained no committed changes.\n\t */\n\tpublic commitTransaction(): (() => TChange) | undefined {\n\t\tconst commitsCommitted = this.#transactionScopesStart.pop();\n\t\tassert(commitsCommitted !== undefined, 0x985 /* No transaction to commit */);\n\t\tif (this.#transactionScopesStart.length === 0) {\n\t\t\tif (this.#transactionCommits.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst transactionCommits = this.#transactionCommits;\n\t\t\tthis.#transactionCommits = [];\n\t\t\treturn () => this.#rebaser.compose(transactionCommits);\n\t\t}\n\t}\n\n\tpublic abortTransaction(): void {\n\t\tconst scopeStart = this.#transactionScopesStart.pop();\n\t\tassert(scopeStart !== undefined, 0x986 /* No transaction to abort */);\n\t\tthis.#transactionCommits.length = scopeStart;\n\t}\n\n\tpublic addTransactionStep(commit: GraphCommit<TChange>): void {\n\t\tassert(\n\t\t\tthis.#transactionScopesStart.length > 0,\n\t\t\t0x987 /* No transaction to add a step to */,\n\t\t);\n\t\tconst change = this.#enricher.updateChangeEnrichments(commit.change, commit.revision);\n\t\tthis.#transactionCommits.push({ ...commit, change });\n\t}\n}\n"]}
@@ -56,7 +56,7 @@ export class TreeViewConfiguration {
56
56
  checkUnion(types.map((t) => t.type), config.preventAmbiguity, ambiguityErrors);
57
57
  },
58
58
  });
59
- if (ambiguityErrors.length !== 0) {
59
+ if (ambiguityErrors.length > 0) {
60
60
  // Duplicate errors are common since when two types conflict, both orders error:
61
61
  const deduplicated = new Set(ambiguityErrors);
62
62
  throw new UsageError(`Ambiguous schema found:\n${[...deduplicated].join("\n")}`);
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/simple-tree/api/configuration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAmD,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAEN,QAAQ,GAER,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,eAAe,EACf,kBAAkB,EAClB,qBAAqB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GAKlB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AAsGrE,MAAM,+BAA+B,GAAwC;IAC5E,sBAAsB,EAAE,KAAK;IAC7B,gBAAgB,EAAE,KAAK;CACvB,CAAC;AAeF;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAqBjC;;;;;;;;;;;;OAYG;IACH,YAAmB,KAAsC;QACxD,IAAI,IAAI,CAAC,WAAW,KAAK,qBAAqB,EAAE,CAAC;YAChD,4HAA4H;YAC5H,kKAAkK;YAClK,OAAO,IAAI,0BAA0B,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM;QACL,wGAAwG;QACvG,IAAI,CAAC,WAAuB,KAAK,0BA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AAoI,CAChS,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail, oob, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type FieldSchemaAlpha, type ImplicitFieldSchema, FieldKind } from \"../fieldSchema.js\";\nimport {\n\ttype AllowedTypesFullEvaluated,\n\tNodeKind,\n\ttype TreeNodeSchema,\n} from \"../core/index.js\";\nimport {\n\ttoInitialSchema,\n\ttoUnhydratedSchema,\n\ttransformSimpleSchema,\n} from \"../toStoredSchema.js\";\nimport {\n\tisArrayNodeSchema,\n\tisMapNodeSchema,\n\tisObjectNodeSchema,\n\tisRecordNodeSchema,\n\ttype ArrayNodeSchema,\n\ttype MapNodeSchema,\n\ttype ObjectNodeSchema,\n\ttype RecordNodeSchema,\n} from \"../node-kinds/index.js\";\nimport { getOrCreate } from \"../../util/index.js\";\nimport type { MakeNominal } from \"../../util/index.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.js\";\nimport type { SchemaType, SimpleNodeSchema } from \"../simpleSchema.js\";\nimport { createTreeSchema, type TreeSchema } from \"../treeSchema.js\";\n\n/**\n * Options when constructing a tree view.\n * @public\n */\nexport interface ITreeConfigurationOptions {\n\t/**\n\t * If `true`, the tree will perform additional validation of content against its stored schema\n\t * and throw an error if the new content doesn't match the expected schema.\n\t *\n\t * @defaultValue `false`.\n\t *\n\t * @remarks\n\t * Currently most cases already have some schema validation, so this is mainly for additional validation which may be useful when debugging issues,\n\t * working with untyped APIs, or when the small performance overhead is a non-issue.\n\t *\n\t * Enabling schema validation has a performance penalty when inserting new content into the tree because\n\t * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a\n\t * bit slower.\n\t *\n\t * For additional validation in more cases, see {@link ForestTypeExpensiveDebug}.\n\t */\n\tenableSchemaValidation?: boolean;\n\n\t/**\n\t * A flag used to opt into strict rules ensuring that the schema avoids cases which can make the type of nodes ambiguous when importing or exporting data.\n\t * @defaultValue `false`.\n\t *\n\t * @remarks\n\t * When this is true, it ensures that the compile time type safety for data when constructing nodes is sufficient to ensure that the runtime behavior will not give node data ambiguity errors.\n\t *\n\t * This ensures that the canonical JSON-like representation of all unions in the tree are lossless and unambiguous.\n\t * This canonical JSON-like representation consists of arrays, plain old JavaScript objects with string keys, booleans, numbers (excluding NaN, -0 and infinities), strings, null and {@link @fluidframework/core-interfaces#IFluidHandle}s.\n\t * It is compatible with the node creation APIs (such as schema class constructors) and is also compatible with JSON assuming any IFluidHandles get special handling (since they are not JSON compatible).\n\t * Currently these cases can cause ambiguity in a union:\n\t *\n\t * - More than one ArrayNode type: it's impossible to tell which array type is intended in the case of empty arrays (`[]`).\n\t *\n\t * - More than one MapNode type: it's impossible to tell which map type is intended in the case of an empty map (`{}`).\n\t *\n\t * - Both a MapNode and an ArrayNode: this case is not a problem for the canonical JSON representation, but is an issue when constructing from an Iterable, which is supported for both MapNode and ArrayNode.\n\t *\n\t * - Both a MapNode and an ObjectNode: when the input is valid for the ObjectNode, the current parser always considers it ambiguous with being a MapNode.\n\t *\n\t * - ObjectNodes which have fields (required or optional) which include all required fields of another ObjectNode: currently each ObjectNode is differentiated by the presence of its required fields.\n\t *\n\t * This check is conservative: some complex cases may error if the current simple algorithm cannot show no ambiguity is possible.\n\t * This check may become more permissive over time.\n\t *\n\t * @example Ambiguous schema (with `preventAmbiguity: false`), and how to disambiguate it using {@link Unhydrated} nodes:\n\t * ```typescript\n\t * const schemaFactory = new SchemaFactory(\"com.example\");\n\t * class Feet extends schemaFactory.object(\"Feet\", { length: schemaFactory.number }) {}\n\t * class Meters extends schemaFactory.object(\"Meters\", { length: schemaFactory.number }) {}\n\t * const config = new TreeViewConfiguration({\n\t * \t// This combination of schema can lead to ambiguous cases and will error if `preventAmbiguity` is true.\n\t * \tschema: [Feet, Meters],\n\t * \tpreventAmbiguity: false,\n\t * });\n\t * const view = tree.viewWith(config);\n\t * // This is invalid since it is ambiguous which type of node is being constructed:\n\t * // view.initialize({ length: 5 });\n\t * // To work, an explicit type can be provided by using an {@link Unhydrated} Node:\n\t * view.initialize(new Meters({ length: 5 }));\n\t * ```\n\t *\n\t * @example Schema disambiguated by adjusting field names, validated with `preventAmbiguity: true:`\n\t * ```typescript\n\t * const schemaFactory = new SchemaFactory(\"com.example\");\n\t * class Feet extends schemaFactory.object(\"Feet\", { length: schemaFactory.number }) {}\n\t * class Meters extends schemaFactory.object(\"Meters\", {\n\t * \t// To avoid ambiguity when parsing unions of Feet and Meters, this renames the length field to \"meters\".\n\t * \t// To preserve compatibility with existing data from the ambiguous case,\n\t * \t// `{ key: \"length\" }` is set, so when persisted in the tree \"length\" is used as the field name.\n\t * \tmeters: schemaFactory.required(schemaFactory.number, { key: \"length\" }),\n\t * }) {}\n\t * const config = new TreeViewConfiguration({\n\t * \t// This combination of schema is not ambiguous because `Feet` and `Meters` have different required keys.\n\t * \tschema: [Feet, Meters],\n\t * \tpreventAmbiguity: true,\n\t * });\n\t * const view = tree.viewWith(config);\n\t * // This now works, since the field is sufficient to determine this is a `Meters` node.\n\t * view.initialize({ meters: 5 });\n\t * ```\n\t *\n\t * @privateRemarks\n\t * In the future, we can support lossless round tripping via the canonical JSON-like representation above when unambiguous.\n\t * This could be done via methods added to `Tree` to export and import such objects, which would give us a place to explicitly define the type of this representation.\n\t *\n\t * To make this more permissive in the future we can:\n\t *\n\t * - Make unhydratedFlexTreeFromInsertable more permissive (ex: allow disambiguation based on leaf type)\n\t * - Update this check to more tightly match unhydratedFlexTreeFromInsertable\n\t * - Add options to help schema authors disambiguate their types, such as \"constant fields\" which are not persisted, and always have a constant value.\n\t *\n\t * The above examples exist in executable form in this files tests, and should be updated there then copied back here.\n\t */\n\treadonly preventAmbiguity?: boolean;\n}\n\nconst defaultTreeConfigurationOptions: Required<ITreeConfigurationOptions> = {\n\tenableSchemaValidation: false,\n\tpreventAmbiguity: false,\n};\n\n/**\n * Property-bag configuration for {@link TreeViewConfiguration} construction.\n * @public\n */\nexport interface ITreeViewConfiguration<\n\tTSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> extends ITreeConfigurationOptions {\n\t/**\n\t * The schema which the application wants to view the tree with.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * Configuration for {@link ViewableTree.viewWith}.\n * @sealed @public\n */\nexport class TreeViewConfiguration<\n\tconst TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> implements Required<ITreeViewConfiguration<TSchema>>\n{\n\tprotected _typeCheck!: MakeNominal;\n\n\t/**\n\t * {@inheritDoc ITreeViewConfiguration.schema}\n\t */\n\tpublic readonly schema!: TSchema;\n\n\t/**\n\t * {@inheritDoc ITreeConfigurationOptions.enableSchemaValidation}\n\t */\n\tpublic readonly enableSchemaValidation!: boolean;\n\n\t/**\n\t * {@inheritDoc ITreeConfigurationOptions.preventAmbiguity}\n\t */\n\tpublic readonly preventAmbiguity!: boolean;\n\n\t/**\n\t * Construct a new {@link TreeViewConfiguration}.\n\t *\n\t * @param props - Property bag of configuration options.\n\t *\n\t * @remarks\n\t * Performing this construction deeply validates the provided schema.\n\t * This means that when this constructor is called, all {@link LazyItem} {@link TreeNodeSchema} references will be evaluated (using {@link evaluateLazySchema}).\n\t * This means that the declarations for all transitively reachable {@link TreeNodeSchema} must be available at this time.\n\t *\n\t * For example, a schema reachable from this configuration cannot reference this configuration during its declaration,\n\t * since this would be a cyclic dependency that will cause an error when constructing this configuration.\n\t */\n\tpublic constructor(props: ITreeViewConfiguration<TSchema>) {\n\t\tif (this.constructor === TreeViewConfiguration) {\n\t\t\t// Ensure all TreeViewConfiguration instances are actually TreeViewConfigurationAlpha, allowing `asAlpha` to work correctly.\n\t\t\t// If everything in TreeViewConfigurationAlpha is stabilized and this is removed, the `!` on the properties above should be removed to restore better type safety.\n\t\t\treturn new TreeViewConfigurationAlpha(props);\n\t\t}\n\t\tassert(\n\t\t\t// The type cast here is needed to avoid this assert narrowing \"this\" to never, breaking the code below.\n\t\t\t(this.constructor as unknown) === TreeViewConfigurationAlpha,\n\t\t\t0xc9e /* Invalid configuration class constructed. */,\n\t\t);\n\n\t\tconst config = { ...defaultTreeConfigurationOptions, ...props };\n\t\tthis.schema = config.schema;\n\t\tthis.enableSchemaValidation = config.enableSchemaValidation;\n\t\tthis.preventAmbiguity = config.preventAmbiguity;\n\n\t\t// Ambiguity errors are lower priority to report than invalid schema errors, so collect these in an array and report them all at once.\n\t\tconst ambiguityErrors: string[] = [];\n\n\t\t// Validate the schema and collect ambiguity errors.\n\t\t// This does a lot of validation (throwing usage errors as a side effect) in addition to just collecting ambiguity errors.\n\t\t// ambiguityErrors are considered a lower priority, so only thrown if no other errors are found.\n\t\twalkFieldSchema(config.schema, {\n\t\t\tallowedTypes({ types }: AllowedTypesFullEvaluated): void {\n\t\t\t\tcheckUnion(\n\t\t\t\t\ttypes.map((t) => t.type),\n\t\t\t\t\tconfig.preventAmbiguity,\n\t\t\t\t\tambiguityErrors,\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\n\t\tif (ambiguityErrors.length !== 0) {\n\t\t\t// Duplicate errors are common since when two types conflict, both orders error:\n\t\t\tconst deduplicated = new Set(ambiguityErrors);\n\t\t\tthrow new UsageError(`Ambiguous schema found:\\n${[...deduplicated].join(\"\\n\")}`);\n\t\t}\n\t}\n}\n\n/**\n * {@link TreeViewConfiguration} extended with some alpha APIs.\n * @remarks\n * See {@link (asAlpha:2)} for an API to downcast from {@link TreeViewConfiguration} to this type.\n * @sealed @alpha\n */\nexport class TreeViewConfigurationAlpha<\n\t\tconst TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n\t>\n\textends TreeViewConfiguration<TSchema>\n\timplements TreeSchema\n{\n\tpublic readonly root: FieldSchemaAlpha;\n\tpublic readonly definitions: ReadonlyMap<\n\t\tstring,\n\t\tSimpleNodeSchema<SchemaType.View> & TreeNodeSchema\n\t>;\n\n\tpublic constructor(props: ITreeViewConfiguration<TSchema>) {\n\t\tsuper(props);\n\t\tconst treeSchema = createTreeSchema(this.schema);\n\t\tthis.root = treeSchema.root;\n\t\tthis.definitions = treeSchema.definitions;\n\n\t\t// Eagerly perform these conversions to surface errors sooner.\n\t\ttoInitialSchema(this.root);\n\t\ttransformSimpleSchema(treeSchema, toUnhydratedSchema);\n\t}\n}\n\n/**\n * Pretty print a set of types for use in error messages.\n */\nfunction formatTypes(allowed: Iterable<TreeNodeSchema>): string {\n\t// Use JSON.stringify to quote and escape identifiers.\n\t// Don't just use a single array JSON.stringify since that omits spaces between items\n\treturn `[${Array.from(allowed, (s) => JSON.stringify(s.identifier)).join(\", \")}]`;\n}\n\n/**\n * Check if union contents are valid (shallowly).\n *\n * @param union - The union of {@link TreeNodeSchema} to check.\n * @param preventAmbiguity - If true, detect cases documented in {@link ITreeConfigurationOptions.preventAmbiguity}, reporting them to `ambiguityErrors`.\n * @param ambiguityErrors - An array into which this function inserts any ambiguity errors, see {@link ITreeConfigurationOptions.preventAmbiguity}.\n *\n * @remarks\n * Includes checks for non-ambiguity errors as well: such as duplicate schemas in the union.\n * Any non-ambiguity errors are thrown as exceptions: `UsageError`s if causable by incorrect API use, and asserts if violating internal invariants.\n */\nexport function checkUnion(\n\tunion: Iterable<TreeNodeSchema>,\n\tpreventAmbiguity: boolean,\n\tambiguityErrors: string[],\n): void {\n\tconst checked: Set<TreeNodeSchema> = new Set();\n\tconst maps: MapNodeSchema[] = [];\n\tconst arrays: ArrayNodeSchema[] = [];\n\tconst records: RecordNodeSchema[] = [];\n\tconst objects: ObjectNodeSchema[] = [];\n\n\t// Map from key to schema using that key\n\tconst allObjectKeys: Map<string, Set<TreeNodeSchema>> = new Map();\n\n\tfor (const schema of union) {\n\t\tif (checked.has(schema)) {\n\t\t\tthrow new UsageError(`Duplicate schema in allowed types: ${schema.identifier}`);\n\t\t}\n\t\tchecked.add(schema);\n\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\t// nothing to do\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tassert(isObjectNodeSchema(schema), 0xbde /* Expected object schema. */);\n\t\t\t\tobjects.push(schema);\n\t\t\t\tfor (const key of schema.fields.keys()) {\n\t\t\t\t\tgetOrCreate(allObjectKeys, key, () => new Set()).add(schema);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tassert(isArrayNodeSchema(schema), 0xbdf /* Expected array schema. */);\n\t\t\t\tarrays.push(schema);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Map: {\n\t\t\t\tassert(isMapNodeSchema(schema), 0xbe0 /* Expected map schema. */);\n\t\t\t\tmaps.push(schema);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Record: {\n\t\t\t\tassert(isRecordNodeSchema(schema), 0xbe1 /* Expected record schema. */);\n\t\t\t\trecords.push(schema);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(schema.kind);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!preventAmbiguity) {\n\t\t// All remaining checks are for the preventAmbiguity case, so skip them if not enabled.\n\t\treturn;\n\t}\n\n\tif (arrays.length > 1) {\n\t\tambiguityErrors.push(\n\t\t\t`More than one kind of array allowed within union (${formatTypes(arrays)}). This would require type disambiguation which is not supported by arrays during import or export.`,\n\t\t);\n\t}\n\n\tif (maps.length > 1) {\n\t\tambiguityErrors.push(\n\t\t\t`More than one kind of map allowed within union (${formatTypes(maps)}). This would require type disambiguation which is not supported by maps during import or export.`,\n\t\t);\n\t}\n\n\tif (records.length > 1) {\n\t\tambiguityErrors.push(\n\t\t\t`More than one kind of record allowed within union (${formatTypes(records)}). This would require type disambiguation which is not supported by records during import or export.`,\n\t\t);\n\t}\n\n\tif (maps.length > 0 && arrays.length > 0) {\n\t\tambiguityErrors.push(\n\t\t\t`Both a map and an array allowed within union (${formatTypes([...arrays, ...maps])}). Both can be implicitly constructed from iterables like arrays, which are ambiguous when the array is empty.`,\n\t\t);\n\t}\n\n\tconst nodeKindListEntries = [];\n\tif (objects.length > 0) {\n\t\tnodeKindListEntries.push(\"objects\");\n\t}\n\tif (maps.length > 0) {\n\t\tnodeKindListEntries.push(\"maps\");\n\t}\n\tif (records.length > 0) {\n\t\tnodeKindListEntries.push(\"records\");\n\t}\n\tif (nodeKindListEntries.length > 1) {\n\t\tconst nodeKindListString =\n\t\t\tnodeKindListEntries.length === 2\n\t\t\t\t? `${nodeKindListEntries[0] ?? oob()} and ${nodeKindListEntries[1] ?? oob()}`\n\t\t\t\t: `${nodeKindListEntries.slice(0, -1).join(\", \")}, and ${nodeKindListEntries[nodeKindListEntries.length - 1]}`;\n\t\tambiguityErrors.push(\n\t\t\t`A combination of ${nodeKindListString} is allowed within union (${formatTypes([...objects, ...maps, ...records])}). These can be constructed from objects and can be ambiguous.`,\n\t\t);\n\t}\n\n\t// Check for objects which fully overlap:\n\tfor (const schema of objects) {\n\t\t// All objects which might be ambiguous relative to `schema`.\n\t\tconst possiblyAmbiguous = new Set(objects);\n\n\t\t// A schema can't be ambiguous with itself\n\t\tpossiblyAmbiguous.delete(schema);\n\n\t\t// For each field of schema, remove schema from possiblyAmbiguous that do not have that field\n\t\tfor (const [key, field] of schema.fields) {\n\t\t\tif (field.kind === FieldKind.Required) {\n\t\t\t\tconst withKey = allObjectKeys.get(key) ?? fail(0xb35 /* missing schema */);\n\t\t\t\tfor (const candidate of possiblyAmbiguous) {\n\t\t\t\t\tif (!withKey.has(candidate)) {\n\t\t\t\t\t\tpossiblyAmbiguous.delete(candidate);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (possiblyAmbiguous.size > 0) {\n\t\t\t// TODO: make this check more permissive.\n\t\t\t// Allow using the type of the field to disambiguate, at least for leaf types.\n\t\t\t// Add \"constant\" fields which can be used to disambiguate even more cases without adding persisted data: maybe make them optional in constructor?\n\t\t\t// Consider separating unambiguous implicit construction format from constructor arguments at type level, allowing constructor to superset the implicit construction options (ex: optional constant fields).\n\t\t\t// The policy here however must remain at least as conservative as shallowCompatibilityTest in src/simple-tree/unhydratedFlexTreeFromInsertable.ts.\n\n\t\t\tambiguityErrors.push(\n\t\t\t\t`The required fields of ${JSON.stringify(schema.identifier)} are insufficient to differentiate it from the following types: ${formatTypes(possiblyAmbiguous)}. For objects to be considered unambiguous, each must have required fields that do not all occur on any other object in the union.`,\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/simple-tree/api/configuration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAmD,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAEN,QAAQ,GAER,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,eAAe,EACf,kBAAkB,EAClB,qBAAqB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GAKlB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AAsGrE,MAAM,+BAA+B,GAAwC;IAC5E,sBAAsB,EAAE,KAAK;IAC7B,gBAAgB,EAAE,KAAK;CACvB,CAAC;AAeF;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAqBjC;;;;;;;;;;;;OAYG;IACH,YAAmB,KAAsC;QACxD,IAAI,IAAI,CA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ACzC,8EAA8E;YAC9E,kJAAkJ;YAClJ,4MAA4M;YAC5M,mJAAmJ;YAEnJ,eAAe,CAAC,IAAI,CACnB,0BAA0B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,mEAAmE,WAAW,CAAC,iBAAiB,CAAC,oIAAoI,CAChS,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail, oob, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type FieldSchemaAlpha, type ImplicitFieldSchema, FieldKind } from \"../fieldSchema.js\";\nimport {\n\ttype AllowedTypesFullEvaluated,\n\tNodeKind,\n\ttype TreeNodeSchema,\n} from \"../core/index.js\";\nimport {\n\ttoInitialSchema,\n\ttoUnhydratedSchema,\n\ttransformSimpleSchema,\n} from \"../toStoredSchema.js\";\nimport {\n\tisArrayNodeSchema,\n\tisMapNodeSchema,\n\tisObjectNodeSchema,\n\tisRecordNodeSchema,\n\ttype ArrayNodeSchema,\n\ttype MapNodeSchema,\n\ttype ObjectNodeSchema,\n\ttype RecordNodeSchema,\n} from \"../node-kinds/index.js\";\nimport { getOrCreate } from \"../../util/index.js\";\nimport type { MakeNominal } from \"../../util/index.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.js\";\nimport type { SchemaType, SimpleNodeSchema } from \"../simpleSchema.js\";\nimport { createTreeSchema, type TreeSchema } from \"../treeSchema.js\";\n\n/**\n * Options when constructing a tree view.\n * @public\n */\nexport interface ITreeConfigurationOptions {\n\t/**\n\t * If `true`, the tree will perform additional validation of content against its stored schema\n\t * and throw an error if the new content doesn't match the expected schema.\n\t *\n\t * @defaultValue `false`.\n\t *\n\t * @remarks\n\t * Currently most cases already have some schema validation, so this is mainly for additional validation which may be useful when debugging issues,\n\t * working with untyped APIs, or when the small performance overhead is a non-issue.\n\t *\n\t * Enabling schema validation has a performance penalty when inserting new content into the tree because\n\t * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a\n\t * bit slower.\n\t *\n\t * For additional validation in more cases, see {@link ForestTypeExpensiveDebug}.\n\t */\n\tenableSchemaValidation?: boolean;\n\n\t/**\n\t * A flag used to opt into strict rules ensuring that the schema avoids cases which can make the type of nodes ambiguous when importing or exporting data.\n\t * @defaultValue `false`.\n\t *\n\t * @remarks\n\t * When this is true, it ensures that the compile time type safety for data when constructing nodes is sufficient to ensure that the runtime behavior will not give node data ambiguity errors.\n\t *\n\t * This ensures that the canonical JSON-like representation of all unions in the tree are lossless and unambiguous.\n\t * This canonical JSON-like representation consists of arrays, plain old JavaScript objects with string keys, booleans, numbers (excluding NaN, -0 and infinities), strings, null and {@link @fluidframework/core-interfaces#IFluidHandle}s.\n\t * It is compatible with the node creation APIs (such as schema class constructors) and is also compatible with JSON assuming any IFluidHandles get special handling (since they are not JSON compatible).\n\t * Currently these cases can cause ambiguity in a union:\n\t *\n\t * - More than one ArrayNode type: it's impossible to tell which array type is intended in the case of empty arrays (`[]`).\n\t *\n\t * - More than one MapNode type: it's impossible to tell which map type is intended in the case of an empty map (`{}`).\n\t *\n\t * - Both a MapNode and an ArrayNode: this case is not a problem for the canonical JSON representation, but is an issue when constructing from an Iterable, which is supported for both MapNode and ArrayNode.\n\t *\n\t * - Both a MapNode and an ObjectNode: when the input is valid for the ObjectNode, the current parser always considers it ambiguous with being a MapNode.\n\t *\n\t * - ObjectNodes which have fields (required or optional) which include all required fields of another ObjectNode: currently each ObjectNode is differentiated by the presence of its required fields.\n\t *\n\t * This check is conservative: some complex cases may error if the current simple algorithm cannot show no ambiguity is possible.\n\t * This check may become more permissive over time.\n\t *\n\t * @example Ambiguous schema (with `preventAmbiguity: false`), and how to disambiguate it using {@link Unhydrated} nodes:\n\t * ```typescript\n\t * const schemaFactory = new SchemaFactory(\"com.example\");\n\t * class Feet extends schemaFactory.object(\"Feet\", { length: schemaFactory.number }) {}\n\t * class Meters extends schemaFactory.object(\"Meters\", { length: schemaFactory.number }) {}\n\t * const config = new TreeViewConfiguration({\n\t * \t// This combination of schema can lead to ambiguous cases and will error if `preventAmbiguity` is true.\n\t * \tschema: [Feet, Meters],\n\t * \tpreventAmbiguity: false,\n\t * });\n\t * const view = tree.viewWith(config);\n\t * // This is invalid since it is ambiguous which type of node is being constructed:\n\t * // view.initialize({ length: 5 });\n\t * // To work, an explicit type can be provided by using an {@link Unhydrated} Node:\n\t * view.initialize(new Meters({ length: 5 }));\n\t * ```\n\t *\n\t * @example Schema disambiguated by adjusting field names, validated with `preventAmbiguity: true:`\n\t * ```typescript\n\t * const schemaFactory = new SchemaFactory(\"com.example\");\n\t * class Feet extends schemaFactory.object(\"Feet\", { length: schemaFactory.number }) {}\n\t * class Meters extends schemaFactory.object(\"Meters\", {\n\t * \t// To avoid ambiguity when parsing unions of Feet and Meters, this renames the length field to \"meters\".\n\t * \t// To preserve compatibility with existing data from the ambiguous case,\n\t * \t// `{ key: \"length\" }` is set, so when persisted in the tree \"length\" is used as the field name.\n\t * \tmeters: schemaFactory.required(schemaFactory.number, { key: \"length\" }),\n\t * }) {}\n\t * const config = new TreeViewConfiguration({\n\t * \t// This combination of schema is not ambiguous because `Feet` and `Meters` have different required keys.\n\t * \tschema: [Feet, Meters],\n\t * \tpreventAmbiguity: true,\n\t * });\n\t * const view = tree.viewWith(config);\n\t * // This now works, since the field is sufficient to determine this is a `Meters` node.\n\t * view.initialize({ meters: 5 });\n\t * ```\n\t *\n\t * @privateRemarks\n\t * In the future, we can support lossless round tripping via the canonical JSON-like representation above when unambiguous.\n\t * This could be done via methods added to `Tree` to export and import such objects, which would give us a place to explicitly define the type of this representation.\n\t *\n\t * To make this more permissive in the future we can:\n\t *\n\t * - Make unhydratedFlexTreeFromInsertable more permissive (ex: allow disambiguation based on leaf type)\n\t * - Update this check to more tightly match unhydratedFlexTreeFromInsertable\n\t * - Add options to help schema authors disambiguate their types, such as \"constant fields\" which are not persisted, and always have a constant value.\n\t *\n\t * The above examples exist in executable form in this files tests, and should be updated there then copied back here.\n\t */\n\treadonly preventAmbiguity?: boolean;\n}\n\nconst defaultTreeConfigurationOptions: Required<ITreeConfigurationOptions> = {\n\tenableSchemaValidation: false,\n\tpreventAmbiguity: false,\n};\n\n/**\n * Property-bag configuration for {@link TreeViewConfiguration} construction.\n * @public\n */\nexport interface ITreeViewConfiguration<\n\tTSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> extends ITreeConfigurationOptions {\n\t/**\n\t * The schema which the application wants to view the tree with.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * Configuration for {@link ViewableTree.viewWith}.\n * @sealed @public\n */\nexport class TreeViewConfiguration<\n\tconst TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> implements Required<ITreeViewConfiguration<TSchema>>\n{\n\tprotected _typeCheck!: MakeNominal;\n\n\t/**\n\t * {@inheritDoc ITreeViewConfiguration.schema}\n\t */\n\tpublic readonly schema!: TSchema;\n\n\t/**\n\t * {@inheritDoc ITreeConfigurationOptions.enableSchemaValidation}\n\t */\n\tpublic readonly enableSchemaValidation!: boolean;\n\n\t/**\n\t * {@inheritDoc ITreeConfigurationOptions.preventAmbiguity}\n\t */\n\tpublic readonly preventAmbiguity!: boolean;\n\n\t/**\n\t * Construct a new {@link TreeViewConfiguration}.\n\t *\n\t * @param props - Property bag of configuration options.\n\t *\n\t * @remarks\n\t * Performing this construction deeply validates the provided schema.\n\t * This means that when this constructor is called, all {@link LazyItem} {@link TreeNodeSchema} references will be evaluated (using {@link evaluateLazySchema}).\n\t * This means that the declarations for all transitively reachable {@link TreeNodeSchema} must be available at this time.\n\t *\n\t * For example, a schema reachable from this configuration cannot reference this configuration during its declaration,\n\t * since this would be a cyclic dependency that will cause an error when constructing this configuration.\n\t */\n\tpublic constructor(props: ITreeViewConfiguration<TSchema>) {\n\t\tif (this.constructor === TreeViewConfiguration) {\n\t\t\t// Ensure all TreeViewConfiguration instances are actually TreeViewConfigurationAlpha, allowing `asAlpha` to work correctly.\n\t\t\t// If everything in TreeViewConfigurationAlpha is stabilized and this is removed, the `!` on the properties above should be removed to restore better type safety.\n\t\t\treturn new TreeViewConfigurationAlpha(props);\n\t\t}\n\t\tassert(\n\t\t\t// The type cast here is needed to avoid this assert narrowing \"this\" to never, breaking the code below.\n\t\t\t(this.constructor as unknown) === TreeViewConfigurationAlpha,\n\t\t\t0xc9e /* Invalid configuration class constructed. */,\n\t\t);\n\n\t\tconst config = { ...defaultTreeConfigurationOptions, ...props };\n\t\tthis.schema = config.schema;\n\t\tthis.enableSchemaValidation = config.enableSchemaValidation;\n\t\tthis.preventAmbiguity = config.preventAmbiguity;\n\n\t\t// Ambiguity errors are lower priority to report than invalid schema errors, so collect these in an array and report them all at once.\n\t\tconst ambiguityErrors: string[] = [];\n\n\t\t// Validate the schema and collect ambiguity errors.\n\t\t// This does a lot of validation (throwing usage errors as a side effect) in addition to just collecting ambiguity errors.\n\t\t// ambiguityErrors are considered a lower priority, so only thrown if no other errors are found.\n\t\twalkFieldSchema(config.schema, {\n\t\t\tallowedTypes({ types }: AllowedTypesFullEvaluated): void {\n\t\t\t\tcheckUnion(\n\t\t\t\t\ttypes.map((t) => t.type),\n\t\t\t\t\tconfig.preventAmbiguity,\n\t\t\t\t\tambiguityErrors,\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\n\t\tif (ambiguityErrors.length > 0) {\n\t\t\t// Duplicate errors are common since when two types conflict, both orders error:\n\t\t\tconst deduplicated = new Set(ambiguityErrors);\n\t\t\tthrow new UsageError(`Ambiguous schema found:\\n${[...deduplicated].join(\"\\n\")}`);\n\t\t}\n\t}\n}\n\n/**\n * {@link TreeViewConfiguration} extended with some alpha APIs.\n * @remarks\n * See {@link (asAlpha:2)} for an API to downcast from {@link TreeViewConfiguration} to this type.\n * @sealed @alpha\n */\nexport class TreeViewConfigurationAlpha<\n\t\tconst TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n\t>\n\textends TreeViewConfiguration<TSchema>\n\timplements TreeSchema\n{\n\tpublic readonly root: FieldSchemaAlpha;\n\tpublic readonly definitions: ReadonlyMap<\n\t\tstring,\n\t\tSimpleNodeSchema<SchemaType.View> & TreeNodeSchema\n\t>;\n\n\tpublic constructor(props: ITreeViewConfiguration<TSchema>) {\n\t\tsuper(props);\n\t\tconst treeSchema = createTreeSchema(this.schema);\n\t\tthis.root = treeSchema.root;\n\t\tthis.definitions = treeSchema.definitions;\n\n\t\t// Eagerly perform these conversions to surface errors sooner.\n\t\ttoInitialSchema(this.root);\n\t\ttransformSimpleSchema(treeSchema, toUnhydratedSchema);\n\t}\n}\n\n/**\n * Pretty print a set of types for use in error messages.\n */\nfunction formatTypes(allowed: Iterable<TreeNodeSchema>): string {\n\t// Use JSON.stringify to quote and escape identifiers.\n\t// Don't just use a single array JSON.stringify since that omits spaces between items\n\treturn `[${Array.from(allowed, (s) => JSON.stringify(s.identifier)).join(\", \")}]`;\n}\n\n/**\n * Check if union contents are valid (shallowly).\n *\n * @param union - The union of {@link TreeNodeSchema} to check.\n * @param preventAmbiguity - If true, detect cases documented in {@link ITreeConfigurationOptions.preventAmbiguity}, reporting them to `ambiguityErrors`.\n * @param ambiguityErrors - An array into which this function inserts any ambiguity errors, see {@link ITreeConfigurationOptions.preventAmbiguity}.\n *\n * @remarks\n * Includes checks for non-ambiguity errors as well: such as duplicate schemas in the union.\n * Any non-ambiguity errors are thrown as exceptions: `UsageError`s if causable by incorrect API use, and asserts if violating internal invariants.\n */\nexport function checkUnion(\n\tunion: Iterable<TreeNodeSchema>,\n\tpreventAmbiguity: boolean,\n\tambiguityErrors: string[],\n): void {\n\tconst checked: Set<TreeNodeSchema> = new Set();\n\tconst maps: MapNodeSchema[] = [];\n\tconst arrays: ArrayNodeSchema[] = [];\n\tconst records: RecordNodeSchema[] = [];\n\tconst objects: ObjectNodeSchema[] = [];\n\n\t// Map from key to schema using that key\n\tconst allObjectKeys: Map<string, Set<TreeNodeSchema>> = new Map();\n\n\tfor (const schema of union) {\n\t\tif (checked.has(schema)) {\n\t\t\tthrow new UsageError(`Duplicate schema in allowed types: ${schema.identifier}`);\n\t\t}\n\t\tchecked.add(schema);\n\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\t// nothing to do\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tassert(isObjectNodeSchema(schema), 0xbde /* Expected object schema. */);\n\t\t\t\tobjects.push(schema);\n\t\t\t\tfor (const key of schema.fields.keys()) {\n\t\t\t\t\tgetOrCreate(allObjectKeys, key, () => new Set()).add(schema);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tassert(isArrayNodeSchema(schema), 0xbdf /* Expected array schema. */);\n\t\t\t\tarrays.push(schema);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Map: {\n\t\t\t\tassert(isMapNodeSchema(schema), 0xbe0 /* Expected map schema. */);\n\t\t\t\tmaps.push(schema);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Record: {\n\t\t\t\tassert(isRecordNodeSchema(schema), 0xbe1 /* Expected record schema. */);\n\t\t\t\trecords.push(schema);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(schema.kind);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!preventAmbiguity) {\n\t\t// All remaining checks are for the preventAmbiguity case, so skip them if not enabled.\n\t\treturn;\n\t}\n\n\tif (arrays.length > 1) {\n\t\tambiguityErrors.push(\n\t\t\t`More than one kind of array allowed within union (${formatTypes(arrays)}). This would require type disambiguation which is not supported by arrays during import or export.`,\n\t\t);\n\t}\n\n\tif (maps.length > 1) {\n\t\tambiguityErrors.push(\n\t\t\t`More than one kind of map allowed within union (${formatTypes(maps)}). This would require type disambiguation which is not supported by maps during import or export.`,\n\t\t);\n\t}\n\n\tif (records.length > 1) {\n\t\tambiguityErrors.push(\n\t\t\t`More than one kind of record allowed within union (${formatTypes(records)}). This would require type disambiguation which is not supported by records during import or export.`,\n\t\t);\n\t}\n\n\tif (maps.length > 0 && arrays.length > 0) {\n\t\tambiguityErrors.push(\n\t\t\t`Both a map and an array allowed within union (${formatTypes([...arrays, ...maps])}). Both can be implicitly constructed from iterables like arrays, which are ambiguous when the array is empty.`,\n\t\t);\n\t}\n\n\tconst nodeKindListEntries = [];\n\tif (objects.length > 0) {\n\t\tnodeKindListEntries.push(\"objects\");\n\t}\n\tif (maps.length > 0) {\n\t\tnodeKindListEntries.push(\"maps\");\n\t}\n\tif (records.length > 0) {\n\t\tnodeKindListEntries.push(\"records\");\n\t}\n\tif (nodeKindListEntries.length > 1) {\n\t\tconst nodeKindListString =\n\t\t\tnodeKindListEntries.length === 2\n\t\t\t\t? `${nodeKindListEntries[0] ?? oob()} and ${nodeKindListEntries[1] ?? oob()}`\n\t\t\t\t: `${nodeKindListEntries.slice(0, -1).join(\", \")}, and ${nodeKindListEntries[nodeKindListEntries.length - 1]}`;\n\t\tambiguityErrors.push(\n\t\t\t`A combination of ${nodeKindListString} is allowed within union (${formatTypes([...objects, ...maps, ...records])}). These can be constructed from objects and can be ambiguous.`,\n\t\t);\n\t}\n\n\t// Check for objects which fully overlap:\n\tfor (const schema of objects) {\n\t\t// All objects which might be ambiguous relative to `schema`.\n\t\tconst possiblyAmbiguous = new Set(objects);\n\n\t\t// A schema can't be ambiguous with itself\n\t\tpossiblyAmbiguous.delete(schema);\n\n\t\t// For each field of schema, remove schema from possiblyAmbiguous that do not have that field\n\t\tfor (const [key, field] of schema.fields) {\n\t\t\tif (field.kind === FieldKind.Required) {\n\t\t\t\tconst withKey = allObjectKeys.get(key) ?? fail(0xb35 /* missing schema */);\n\t\t\t\tfor (const candidate of possiblyAmbiguous) {\n\t\t\t\t\tif (!withKey.has(candidate)) {\n\t\t\t\t\t\tpossiblyAmbiguous.delete(candidate);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (possiblyAmbiguous.size > 0) {\n\t\t\t// TODO: make this check more permissive.\n\t\t\t// Allow using the type of the field to disambiguate, at least for leaf types.\n\t\t\t// Add \"constant\" fields which can be used to disambiguate even more cases without adding persisted data: maybe make them optional in constructor?\n\t\t\t// Consider separating unambiguous implicit construction format from constructor arguments at type level, allowing constructor to superset the implicit construction options (ex: optional constant fields).\n\t\t\t// The policy here however must remain at least as conservative as shallowCompatibilityTest in src/simple-tree/unhydratedFlexTreeFromInsertable.ts.\n\n\t\t\tambiguityErrors.push(\n\t\t\t\t`The required fields of ${JSON.stringify(schema.identifier)} are insufficient to differentiate it from the following types: ${formatTypes(possiblyAmbiguous)}. For objects to be considered unambiguous, each must have required fields that do not all occur on any other object in the union.`,\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"customTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAKpE,OAAO,EAON,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAUtE;;;;GAIG;AACH,MAAM,WAAW,mBAAmB,CAAC,WAAW,GAAG,kBAAkB;IACpE;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,CACnD,kBAAkB,CAAC,eAAe,GAAG,kBAAkB,CAAC,eAAe,CACvE,CAAC;AAEF;;;;GAIG;AACH,oBAAY,kBAAkB;IAC7B;;;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,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,EACnE,YAAY,EAAE,CACb,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,KAC/D,MAAM,GACT,UAAU,CAAC,MAAM,CAAC,CAgCpB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,oBAAoB,GAAG,WAAW,GAAG,SAAS,CAU5F;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAStF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAIpD"}
@@ -59,23 +59,21 @@ export function customFromCursor(reader, options, storedSchema, schema, childHan
59
59
  case numberSchema.identifier:
60
60
  case booleanSchema.identifier:
61
61
  case nullSchema.identifier:
62
- case stringSchema.identifier:
62
+ case stringSchema.identifier: {
63
63
  assert(reader.value !== undefined, 0xa50 /* out of schema: missing value */);
64
64
  assert(!isFluidHandle(reader.value), 0xa51 /* out of schema: unexpected FluidHandle */);
65
65
  return reader.value;
66
- case handleSchema.identifier:
66
+ }
67
+ case handleSchema.identifier: {
67
68
  assert(reader.value !== undefined, 0xa52 /* out of schema: missing value */);
68
69
  assert(isFluidHandle(reader.value), 0xa53 /* out of schema: expected FluidHandle */);
69
70
  return reader.value;
71
+ }
70
72
  default: {
71
73
  assert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);
72
74
  const nodeSchema = storedSchema.get(type) ?? fail(0xb2e /* missing schema for type in cursor */);
73
75
  const arrayTypes = tryStoredSchemaAsArray(nodeSchema);
74
- if (arrayTypes !== undefined) {
75
- const fields = inCursorField(reader, EmptyKey, () => mapCursorField(reader, () => childHandler(reader, options, storedSchema, schema)));
76
- return fields;
77
- }
78
- else {
76
+ if (arrayTypes === undefined) {
79
77
  const fields = {};
80
78
  forEachField(reader, () => {
81
79
  assert(reader.getFieldLength() === 1, 0xa19 /* invalid children number */);
@@ -91,6 +89,10 @@ export function customFromCursor(reader, options, storedSchema, schema, childHan
91
89
  });
92
90
  return fields;
93
91
  }
92
+ else {
93
+ const fields = inCursorField(reader, EmptyKey, () => mapCursorField(reader, () => childHandler(reader, options, storedSchema, schema)));
94
+ return fields;
95
+ }
94
96
  }
95
97
  }
96
98
  }
@@ -110,11 +112,12 @@ export function customFromCursor(reader, options, storedSchema, schema, childHan
110
112
  */
111
113
  function getKeyFromOptions(options, type, storedKey, schema) {
112
114
  switch (options) {
113
- case KeyEncodingOptions.allStoredKeys:
115
+ case KeyEncodingOptions.allStoredKeys: {
114
116
  // Since this case might be inside of an unknown optional field,
115
117
  // it must not depend on there being a view schema.
116
118
  // Fortunately, its possible to implement this case without one.
117
119
  return storedKey;
120
+ }
118
121
  case KeyEncodingOptions.usePropertyKeys:
119
122
  case KeyEncodingOptions.knownStoredKeys: {
120
123
  // Both these cases avoid traversing into unknown optional fields,
@@ -135,8 +138,9 @@ function getKeyFromOptions(options, type, storedKey, schema) {
135
138
  return storedKey;
136
139
  }
137
140
  }
138
- default:
141
+ default: {
139
142
  unreachableCase(options);
143
+ }
140
144
  }
141
145
  }
142
146
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"customTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;A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AI,CAAC,SAAS,CAAC,IAAI,CAAC,wCAAwC,CAC9G,CAAC;AACH,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 { assert, fail, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachField,\n\tinCursorField,\n\tLeafNodeStoredSchema,\n\tmapCursorField,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../../core/index.js\";\nimport { FieldKinds, valueSchemaAllows } from \"../../feature-libraries/index.js\";\nimport { cloneWithReplacements } from \"../../util/index.js\";\nimport type { TreeNodeSchema, TreeLeafValue } from \"../core/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../node-kinds/index.js\";\n\n/**\n * Options for how to interpret or encode a tree when schema information is available.\n * @beta\n * @input\n */\nexport interface TreeEncodingOptions<TKeyOptions = KeyEncodingOptions> {\n\t/**\n\t * How to handle field keys.\n\t * @remarks\n\t * Has no effect on {@link NodeKind}s other than {@link NodeKind.Object}.\n\t *\n\t * {@link ObjectSchemaOptions.allowUnknownOptionalFields|Unknown optional field} will be omitted when using property keys.\n\t * @defaultValue {@link KeyEncodingOptions.usePropertyKeys}.\n\t */\n\treadonly keys?: TKeyOptions;\n}\n\n/**\n * Options for how to interpret a tree when schema information is available.\n * @alpha\n * @input\n */\nexport type TreeParsingOptions = TreeEncodingOptions<\n\tKeyEncodingOptions.usePropertyKeys | KeyEncodingOptions.knownStoredKeys\n>;\n\n/**\n * Options for how to encode keys in a tree.\n * @beta\n * @input\n */\nexport enum KeyEncodingOptions {\n\t/**\n\t * Use property keys.\n\t * @remarks\n\t * Supported for import and export.\n\t * {@link ObjectSchemaOptions.allowUnknownOptionalFields|Unknown optional fields} will be omitted when using property keys.\n\t */\n\tusePropertyKeys = \"usePropertyKeys\",\n\t/**\n\t * Use stored keys, and include {@link ObjectSchemaOptions.allowUnknownOptionalFields|Unknown optional fields}.\n\t * @remarks\n\t * Currently only supported for export.\n\t */\n\tallStoredKeys = \"allStoredKeys\",\n\t/**\n\t * Use stored keys but do not include {@link ObjectSchemaOptions.allowUnknownOptionalFields | unknown optional fields}.\n\t * @remarks\n\t * Supported for import and export.\n\t * For export, this omits unknown optional fields.\n\t * For import, any unexpected fields are errors, regardless of {@link ObjectSchemaOptions.allowUnknownOptionalFields}.\n\t */\n\tknownStoredKeys = \"knownStoredKeys\",\n}\n\n/**\n * Options for how to interpret a `ConciseTree<TCustom>` without relying on schema.\n */\nexport interface SchemalessParseOptions {\n\t/**\n\t * Converts stored keys into whatever key the tree is using in its encoding.\n\t */\n\tkeyConverter?: {\n\t\tparse(type: string, inputKey: string): FieldKey;\n\t\tencode(type: string, key: FieldKey): string;\n\t};\n}\n\n/**\n * Tree representation with fields as properties and customized handle and child representations.\n */\nexport type CustomTree<TChild> = CustomTreeNode<TChild> | CustomTreeValue;\n\n/**\n * TreeLeafValue except the handle type is customized.\n */\nexport type CustomTreeValue = TreeLeafValue;\n\n/**\n * Tree node representation with fields as properties and customized child representation.\n */\nexport type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n *\n * @param reader - The cursor to read from.\n * @param options - Options for how to interpret the tree.\n * @param storedSchema - Schema which the cursor must comply with.\n * Must be be possible to map to a view schema (mainly that sequences can only occur in the special ArrayNode pattern).\n * Must include even unknown optional fields.\n * @param schema - View schema used to derive the property keys for fields when `options` selects them via {@link TreeEncodingOptions.useStoredKeys}.\n * @param childHandler - Function to handle children of the cursor.\n *\n * @remarks\n * This can handle unknown optional fields only because they are included in the `storedSchema` and `schema` is only needed when using property keys, which also skips unknown optional fields.\n */\nexport function customFromCursor<TChild>(\n\treader: ITreeCursor,\n\toptions: Required<TreeEncodingOptions>,\n\tstoredSchema: ReadonlyMap<string, TreeNodeStoredSchema>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\toptions: Required<TreeEncodingOptions>,\n\t\tstoredSchema: ReadonlyMap<string, TreeNodeStoredSchema>,\n\t\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\n\tswitch (type) {\n\t\tcase numberSchema.identifier:\n\t\tcase booleanSchema.identifier:\n\t\tcase nullSchema.identifier:\n\t\tcase stringSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa50 /* out of schema: missing value */);\n\t\t\tassert(!isFluidHandle(reader.value), 0xa51 /* out of schema: unexpected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tcase handleSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa52 /* out of schema: missing value */);\n\t\t\tassert(isFluidHandle(reader.value), 0xa53 /* out of schema: expected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tdefault: {\n\t\t\tassert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);\n\t\t\tconst nodeSchema =\n\t\t\t\tstoredSchema.get(type) ?? fail(0xb2e /* missing schema for type in cursor */);\n\t\t\tconst arrayTypes = tryStoredSchemaAsArray(nodeSchema);\n\n\t\t\tif (arrayTypes !== undefined) {\n\t\t\t\tconst fields = inCursorField(reader, EmptyKey, () =>\n\t\t\t\t\tmapCursorField(reader, () => childHandler(reader, options, storedSchema, schema)),\n\t\t\t\t);\n\t\t\t\treturn fields;\n\t\t\t} else {\n\t\t\t\tconst fields: Record<string, TChild> = {};\n\t\t\t\tforEachField(reader, () => {\n\t\t\t\t\tassert(reader.getFieldLength() === 1, 0xa19 /* invalid children number */);\n\t\t\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t\t\tconst key = getKeyFromOptions(options.keys, type, storedKey, schema);\n\t\t\t\t\tif (key === undefined) {\n\t\t\t\t\t\t// Skip unknown optional fields when using property keys or only known stored keys.\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\treader.enterNode(0);\n\t\t\t\t\tfields[key] = childHandler(reader, options, storedSchema, schema);\n\t\t\t\t\treader.exitNode();\n\t\t\t\t});\n\t\t\t\treturn fields;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Returns the key if one should be used, and undefined if the field should be omitted/skipped.\n *\n * @param schema - Collection of known view schema.\n * If `options` is not `KeyEncodingOptions.allStoredKeys`, this must provide the schema for the `type`.\n * Note that if using this to perform a recursive walk, and `schema` has all view schema reachable from the starting type,\n * then it should be safe to use the same schema map on every invocation since types missing from it will only be\n * encountered after traversing unknown optional fields which for which this will return undefined.\n *\n * @remarks\n * Asserts that if encountering an unknown optional field, the schema allows them.\n * This is not robustly validated in all cases: when in allStoredKeys, it is not checked\n * (since the view schema might not even be available).\n */\nfunction getKeyFromOptions(\n\toptions: KeyEncodingOptions,\n\ttype: TreeNodeSchemaIdentifier,\n\tstoredKey: FieldKey,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n): string | undefined {\n\tswitch (options) {\n\t\tcase KeyEncodingOptions.allStoredKeys:\n\t\t\t// Since this case might be inside of an unknown optional field,\n\t\t\t// it must not depend on there being a view schema.\n\t\t\t// Fortunately, its possible to implement this case without one.\n\t\t\treturn storedKey;\n\t\tcase KeyEncodingOptions.usePropertyKeys:\n\t\tcase KeyEncodingOptions.knownStoredKeys: {\n\t\t\t// Both these cases avoid traversing into unknown optional fields,\n\t\t\t// so a view schema should be available.\n\t\t\tconst viewSchema =\n\t\t\t\tschema.get(type) ?? fail(0xbff /* missing schema for type in cursor */);\n\t\t\tif (isObjectNodeSchema(viewSchema)) {\n\t\t\t\tconst propertyKey = viewSchema.storedKeyToPropertyKey.get(storedKey);\n\t\t\t\tif (propertyKey === undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tviewSchema.allowUnknownOptionalFields,\n\t\t\t\t\t\t0xc00 /* found unknown field where not allowed */,\n\t\t\t\t\t);\n\t\t\t\t\t// Skip unknown optional fields when using property keys or only known stored keys.\n\t\t\t\t\treturn undefined;\n\t\t\t\t} else {\n\t\t\t\t\treturn options === KeyEncodingOptions.usePropertyKeys ? propertyKey : storedKey;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn storedKey;\n\t\t\t}\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(options);\n\t}\n}\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n * @remarks\n * Uses stored keys and stored schema.\n */\nexport function customFromCursorStored<TChild>(\n\treader: ITreeCursor,\n\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb30 /* missing schema for type in cursor */);\n\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\tassert(valueSchemaAllows(nodeSchema.leafValue, reader.value), 0xa9c /* invalid value */);\n\t\treturn reader.value;\n\t}\n\n\tassert(reader.value === undefined, 0xa9d /* out of schema: unexpected value */);\n\n\tconst arrayTypes = tryStoredSchemaAsArray(nodeSchema);\n\tif (arrayTypes !== undefined) {\n\t\tconst field = inCursorField(reader, EmptyKey, () =>\n\t\t\tmapCursorField(reader, () => childHandler(reader, schema)),\n\t\t);\n\t\treturn field;\n\t}\n\n\tconst fields: Record<string, TChild> = {};\n\tforEachField(reader, () => {\n\t\tconst children = mapCursorField(reader, () => childHandler(reader, schema));\n\t\tif (children.length === 1) {\n\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t// Length is checked above.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tfields[storedKey] = children[0]!;\n\t\t} else {\n\t\t\tassert(children.length === 0, 0xa9e /* invalid children number */);\n\t\t}\n\t});\n\treturn fields;\n}\n\n/**\n * Checks if `schema` could correspond to a simple-tree array node.\n * If it is an array schema, returns the allowed types for the array field.\n * Otherwise returns `undefined`.\n * @remarks\n * If the schema was defined by the public API, this will be accurate since there is no way to define an object node with a sequence field.\n */\nexport function tryStoredSchemaAsArray(schema: TreeNodeStoredSchema): TreeTypeSet | undefined {\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\tconst empty = schema.getFieldSchema(EmptyKey);\n\t\tif (empty.kind === FieldKinds.sequence.identifier) {\n\t\t\t// This assert can only be hit by schema created not using the public API surface.\n\t\t\t// If at some point this case needs to be tolerated, it can be replaced by \"return undefined\"\n\t\t\tassert(schema.objectNodeFields.size === 1, 0xa9f /* invalid schema */);\n\t\t\treturn empty.types;\n\t\t}\n\t}\n}\n\n/**\n * Options for how to transcode handles.\n * @remarks\n * Can be applied using {@link replaceHandles}.\n * @alpha\n */\nexport type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * This can be useful converting data containing handles to JSON compatible formats,\n * or just asserting that data does not contain handles.\n *\n * Reversing this replacement depends on how the replacer encodes handles, and can often be impossible if the replacer\n * does not have all the necessary context to restore the handles\n * (e.g. if the handles are something insufficiently descriptive,\n * if data referenced by the handle got garbage collected,\n * if the encoded form of the handle can't be differentiated from other data,\n * or the replacer doesn't have access to the correct Fluid container to to restore them from).\n *\n * Code attempting to reverse this replacement may want to use {@link cloneWithReplacements}.\n * @alpha\n */\nexport function replaceHandles<T>(tree: unknown, replacer: HandleConverter<T>): unknown {\n\treturn cloneWithReplacements(tree, \"\", (key, value) => {\n\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\tif (isFluidHandle(value)) {\n\t\t\treturn { clone: false, value: replacer(value) };\n\t\t} else {\n\t\t\treturn { clone: true, value };\n\t\t}\n\t});\n}\n\n/**\n * Throws a `UsageError` indicating that a type is unknown in the current context.\n */\nexport function unknownTypeError(type: string): never {\n\tthrow new UsageError(\n\t\t`Failed to parse tree due to occurrence of type ${JSON.stringify(type)} which is not defined in this context.`,\n\t);\n}\n"]}
1
+ {"version":3,"file":"customTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GAMtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EACN,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AA4B5D;;;;GAIG;AACH,MAAM,CAAN,IAAY,kBAsBX;AAtBD,WAAY,kBAAkB;IAC7B;;;;;OAKG;IACH,yDAAmC,CAAA;IACnC;;;;OAIG;IACH,qDAA+B,CAAA;IAC/B;;;;;;OAMG;IACH,yDAAmC,CAAA;AACpC,CAAC,EAtBW,kBAAkB,KAAlB,kBAAkB,QAsB7B;AA8BD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAC/B,MAAmB,EACn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AI,KAAK,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC,KAAK,CAAC;QACpB,CAAC;IACF,CAAC;AACF,CAAC;AAUD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAI,IAAa,EAAE,QAA4B;IAC5E,OAAO,qBAAqB,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACrD,kDAAkD;QAClD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,CAAC;aAAM,CAAC;YACP,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,MAAM,IAAI,UAAU,CACnB,kDAAkD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,wCAAwC,CAC9G,CAAC;AACH,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 { assert, fail, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachField,\n\tinCursorField,\n\tLeafNodeStoredSchema,\n\tmapCursorField,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../../core/index.js\";\nimport { FieldKinds, valueSchemaAllows } from \"../../feature-libraries/index.js\";\nimport { cloneWithReplacements } from \"../../util/index.js\";\nimport type { TreeNodeSchema, TreeLeafValue } from \"../core/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../node-kinds/index.js\";\n\n/**\n * Options for how to interpret or encode a tree when schema information is available.\n * @beta\n * @input\n */\nexport interface TreeEncodingOptions<TKeyOptions = KeyEncodingOptions> {\n\t/**\n\t * How to handle field keys.\n\t * @remarks\n\t * Has no effect on {@link NodeKind}s other than {@link NodeKind.Object}.\n\t *\n\t * {@link ObjectSchemaOptions.allowUnknownOptionalFields|Unknown optional field} will be omitted when using property keys.\n\t * @defaultValue {@link KeyEncodingOptions.usePropertyKeys}.\n\t */\n\treadonly keys?: TKeyOptions;\n}\n\n/**\n * Options for how to interpret a tree when schema information is available.\n * @alpha\n * @input\n */\nexport type TreeParsingOptions = TreeEncodingOptions<\n\tKeyEncodingOptions.usePropertyKeys | KeyEncodingOptions.knownStoredKeys\n>;\n\n/**\n * Options for how to encode keys in a tree.\n * @beta\n * @input\n */\nexport enum KeyEncodingOptions {\n\t/**\n\t * Use property keys.\n\t * @remarks\n\t * Supported for import and export.\n\t * {@link ObjectSchemaOptions.allowUnknownOptionalFields|Unknown optional fields} will be omitted when using property keys.\n\t */\n\tusePropertyKeys = \"usePropertyKeys\",\n\t/**\n\t * Use stored keys, and include {@link ObjectSchemaOptions.allowUnknownOptionalFields|Unknown optional fields}.\n\t * @remarks\n\t * Currently only supported for export.\n\t */\n\tallStoredKeys = \"allStoredKeys\",\n\t/**\n\t * Use stored keys but do not include {@link ObjectSchemaOptions.allowUnknownOptionalFields | unknown optional fields}.\n\t * @remarks\n\t * Supported for import and export.\n\t * For export, this omits unknown optional fields.\n\t * For import, any unexpected fields are errors, regardless of {@link ObjectSchemaOptions.allowUnknownOptionalFields}.\n\t */\n\tknownStoredKeys = \"knownStoredKeys\",\n}\n\n/**\n * Options for how to interpret a `ConciseTree<TCustom>` without relying on schema.\n */\nexport interface SchemalessParseOptions {\n\t/**\n\t * Converts stored keys into whatever key the tree is using in its encoding.\n\t */\n\tkeyConverter?: {\n\t\tparse(type: string, inputKey: string): FieldKey;\n\t\tencode(type: string, key: FieldKey): string;\n\t};\n}\n\n/**\n * Tree representation with fields as properties and customized handle and child representations.\n */\nexport type CustomTree<TChild> = CustomTreeNode<TChild> | CustomTreeValue;\n\n/**\n * TreeLeafValue except the handle type is customized.\n */\nexport type CustomTreeValue = TreeLeafValue;\n\n/**\n * Tree node representation with fields as properties and customized child representation.\n */\nexport type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n *\n * @param reader - The cursor to read from.\n * @param options - Options for how to interpret the tree.\n * @param storedSchema - Schema which the cursor must comply with.\n * Must be be possible to map to a view schema (mainly that sequences can only occur in the special ArrayNode pattern).\n * Must include even unknown optional fields.\n * @param schema - View schema used to derive the property keys for fields when `options` selects them via {@link TreeEncodingOptions.useStoredKeys}.\n * @param childHandler - Function to handle children of the cursor.\n *\n * @remarks\n * This can handle unknown optional fields only because they are included in the `storedSchema` and `schema` is only needed when using property keys, which also skips unknown optional fields.\n */\nexport function customFromCursor<TChild>(\n\treader: ITreeCursor,\n\toptions: Required<TreeEncodingOptions>,\n\tstoredSchema: ReadonlyMap<string, TreeNodeStoredSchema>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\toptions: Required<TreeEncodingOptions>,\n\t\tstoredSchema: ReadonlyMap<string, TreeNodeStoredSchema>,\n\t\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\n\tswitch (type) {\n\t\tcase numberSchema.identifier:\n\t\tcase booleanSchema.identifier:\n\t\tcase nullSchema.identifier:\n\t\tcase stringSchema.identifier: {\n\t\t\tassert(reader.value !== undefined, 0xa50 /* out of schema: missing value */);\n\t\t\tassert(!isFluidHandle(reader.value), 0xa51 /* out of schema: unexpected FluidHandle */);\n\t\t\treturn reader.value;\n\t\t}\n\t\tcase handleSchema.identifier: {\n\t\t\tassert(reader.value !== undefined, 0xa52 /* out of schema: missing value */);\n\t\t\tassert(isFluidHandle(reader.value), 0xa53 /* out of schema: expected FluidHandle */);\n\t\t\treturn reader.value;\n\t\t}\n\t\tdefault: {\n\t\t\tassert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);\n\t\t\tconst nodeSchema =\n\t\t\t\tstoredSchema.get(type) ?? fail(0xb2e /* missing schema for type in cursor */);\n\t\t\tconst arrayTypes = tryStoredSchemaAsArray(nodeSchema);\n\n\t\t\tif (arrayTypes === undefined) {\n\t\t\t\tconst fields: Record<string, TChild> = {};\n\t\t\t\tforEachField(reader, () => {\n\t\t\t\t\tassert(reader.getFieldLength() === 1, 0xa19 /* invalid children number */);\n\t\t\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t\t\tconst key = getKeyFromOptions(options.keys, type, storedKey, schema);\n\t\t\t\t\tif (key === undefined) {\n\t\t\t\t\t\t// Skip unknown optional fields when using property keys or only known stored keys.\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\treader.enterNode(0);\n\t\t\t\t\tfields[key] = childHandler(reader, options, storedSchema, schema);\n\t\t\t\t\treader.exitNode();\n\t\t\t\t});\n\t\t\t\treturn fields;\n\t\t\t} else {\n\t\t\t\tconst fields = inCursorField(reader, EmptyKey, () =>\n\t\t\t\t\tmapCursorField(reader, () => childHandler(reader, options, storedSchema, schema)),\n\t\t\t\t);\n\t\t\t\treturn fields;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Returns the key if one should be used, and undefined if the field should be omitted/skipped.\n *\n * @param schema - Collection of known view schema.\n * If `options` is not `KeyEncodingOptions.allStoredKeys`, this must provide the schema for the `type`.\n * Note that if using this to perform a recursive walk, and `schema` has all view schema reachable from the starting type,\n * then it should be safe to use the same schema map on every invocation since types missing from it will only be\n * encountered after traversing unknown optional fields which for which this will return undefined.\n *\n * @remarks\n * Asserts that if encountering an unknown optional field, the schema allows them.\n * This is not robustly validated in all cases: when in allStoredKeys, it is not checked\n * (since the view schema might not even be available).\n */\nfunction getKeyFromOptions(\n\toptions: KeyEncodingOptions,\n\ttype: TreeNodeSchemaIdentifier,\n\tstoredKey: FieldKey,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n): string | undefined {\n\tswitch (options) {\n\t\tcase KeyEncodingOptions.allStoredKeys: {\n\t\t\t// Since this case might be inside of an unknown optional field,\n\t\t\t// it must not depend on there being a view schema.\n\t\t\t// Fortunately, its possible to implement this case without one.\n\t\t\treturn storedKey;\n\t\t}\n\t\tcase KeyEncodingOptions.usePropertyKeys:\n\t\tcase KeyEncodingOptions.knownStoredKeys: {\n\t\t\t// Both these cases avoid traversing into unknown optional fields,\n\t\t\t// so a view schema should be available.\n\t\t\tconst viewSchema =\n\t\t\t\tschema.get(type) ?? fail(0xbff /* missing schema for type in cursor */);\n\t\t\tif (isObjectNodeSchema(viewSchema)) {\n\t\t\t\tconst propertyKey = viewSchema.storedKeyToPropertyKey.get(storedKey);\n\t\t\t\tif (propertyKey === undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tviewSchema.allowUnknownOptionalFields,\n\t\t\t\t\t\t0xc00 /* found unknown field where not allowed */,\n\t\t\t\t\t);\n\t\t\t\t\t// Skip unknown optional fields when using property keys or only known stored keys.\n\t\t\t\t\treturn undefined;\n\t\t\t\t} else {\n\t\t\t\t\treturn options === KeyEncodingOptions.usePropertyKeys ? propertyKey : storedKey;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn storedKey;\n\t\t\t}\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(options);\n\t\t}\n\t}\n}\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n * @remarks\n * Uses stored keys and stored schema.\n */\nexport function customFromCursorStored<TChild>(\n\treader: ITreeCursor,\n\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb30 /* missing schema for type in cursor */);\n\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\tassert(valueSchemaAllows(nodeSchema.leafValue, reader.value), 0xa9c /* invalid value */);\n\t\treturn reader.value;\n\t}\n\n\tassert(reader.value === undefined, 0xa9d /* out of schema: unexpected value */);\n\n\tconst arrayTypes = tryStoredSchemaAsArray(nodeSchema);\n\tif (arrayTypes !== undefined) {\n\t\tconst field = inCursorField(reader, EmptyKey, () =>\n\t\t\tmapCursorField(reader, () => childHandler(reader, schema)),\n\t\t);\n\t\treturn field;\n\t}\n\n\tconst fields: Record<string, TChild> = {};\n\tforEachField(reader, () => {\n\t\tconst children = mapCursorField(reader, () => childHandler(reader, schema));\n\t\tif (children.length === 1) {\n\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t// Length is checked above.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tfields[storedKey] = children[0]!;\n\t\t} else {\n\t\t\tassert(children.length === 0, 0xa9e /* invalid children number */);\n\t\t}\n\t});\n\treturn fields;\n}\n\n/**\n * Checks if `schema` could correspond to a simple-tree array node.\n * If it is an array schema, returns the allowed types for the array field.\n * Otherwise returns `undefined`.\n * @remarks\n * If the schema was defined by the public API, this will be accurate since there is no way to define an object node with a sequence field.\n */\nexport function tryStoredSchemaAsArray(schema: TreeNodeStoredSchema): TreeTypeSet | undefined {\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\tconst empty = schema.getFieldSchema(EmptyKey);\n\t\tif (empty.kind === FieldKinds.sequence.identifier) {\n\t\t\t// This assert can only be hit by schema created not using the public API surface.\n\t\t\t// If at some point this case needs to be tolerated, it can be replaced by \"return undefined\"\n\t\t\tassert(schema.objectNodeFields.size === 1, 0xa9f /* invalid schema */);\n\t\t\treturn empty.types;\n\t\t}\n\t}\n}\n\n/**\n * Options for how to transcode handles.\n * @remarks\n * Can be applied using {@link replaceHandles}.\n * @alpha\n */\nexport type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * This can be useful converting data containing handles to JSON compatible formats,\n * or just asserting that data does not contain handles.\n *\n * Reversing this replacement depends on how the replacer encodes handles, and can often be impossible if the replacer\n * does not have all the necessary context to restore the handles\n * (e.g. if the handles are something insufficiently descriptive,\n * if data referenced by the handle got garbage collected,\n * if the encoded form of the handle can't be differentiated from other data,\n * or the replacer doesn't have access to the correct Fluid container to to restore them from).\n *\n * Code attempting to reverse this replacement may want to use {@link cloneWithReplacements}.\n * @alpha\n */\nexport function replaceHandles<T>(tree: unknown, replacer: HandleConverter<T>): unknown {\n\treturn cloneWithReplacements(tree, \"\", (key, value) => {\n\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\tif (isFluidHandle(value)) {\n\t\t\treturn { clone: false, value: replacer(value) };\n\t\t} else {\n\t\t\treturn { clone: true, value };\n\t\t}\n\t});\n}\n\n/**\n * Throws a `UsageError` indicating that a type is unknown in the current context.\n */\nexport function unknownTypeError(type: string): never {\n\tthrow new UsageError(\n\t\t`Failed to parse tree due to occurrence of type ${JSON.stringify(type)} which is not defined in this context.`,\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"discrepancies.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/discrepancies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,mBAAmB,EAExB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EAGtB,KAAK,wBAAwB,EAE7B,KAAK,gBAAgB,E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BAAgB,EAAE,SAAS,oBAAoB,CAAC,cAAc,CAAC,EAAE,EACjE,kBAAkB,EAAE,WAAW,GAC7B,IAAI,CAAC,sBAAsB,EAAE,MAAM,GAAG,QAAQ,CAAC,CAkBjD"}
@@ -26,16 +26,20 @@ function getStoredNodeSchemaType(nodeSchema) {
26
26
  }
27
27
  function doesNodeKindMatchStoredNodeKind(viewKind, storedType) {
28
28
  switch (viewKind) {
29
- case NodeKind.Leaf:
29
+ case NodeKind.Leaf: {
30
30
  return storedType === LeafNodeStoredSchema;
31
+ }
31
32
  case NodeKind.Array:
32
- case NodeKind.Object:
33
+ case NodeKind.Object: {
33
34
  return storedType === ObjectNodeStoredSchema;
35
+ }
34
36
  case NodeKind.Map:
35
- case NodeKind.Record:
37
+ case NodeKind.Record: {
36
38
  return storedType === MapNodeStoredSchema;
37
- default:
39
+ }
40
+ default: {
38
41
  unreachableCase(viewKind);
42
+ }
39
43
  }
40
44
  }
41
45
  /**
@@ -112,8 +116,9 @@ function* getNodeDiscrepancies(identifier, view, stored) {
112
116
  }
113
117
  break;
114
118
  }
115
- default:
119
+ default: {
116
120
  break;
121
+ }
117
122
  }
118
123
  }
119
124
  /**
@@ -233,18 +238,17 @@ function* computeObjectNodeDiscrepancies(identifier, view, stored) {
233
238
  continue;
234
239
  }
235
240
  // If the stored schema has a field that's not in the view schema
236
- if (!viewKeys.has(fieldKey)) {
237
- // When the application has opted into it, we allow viewing documents which have additional
238
- // optional fields in the stored schema that are not present in the view schema.
239
- if (!view.allowUnknownOptionalFields || schema.kind !== FieldKinds.optional.identifier) {
240
- yield {
241
- identifier,
242
- fieldKey,
243
- mismatch: "fieldKind",
244
- view: storedEmptyFieldSchema.kind,
245
- stored: schema.kind,
246
- };
247
- }
241
+ // When the application has opted into it, we allow viewing documents which have additional
242
+ // optional fields in the stored schema that are not present in the view schema.
243
+ if (!viewKeys.has(fieldKey) &&
244
+ (!view.allowUnknownOptionalFields || schema.kind !== FieldKinds.optional.identifier)) {
245
+ yield {
246
+ identifier,
247
+ fieldKey,
248
+ mismatch: "fieldKind",
249
+ view: storedEmptyFieldSchema.kind,
250
+ stored: schema.kind,
251
+ };
248
252
  }
249
253
  }
250
254
  }
@@ -1 +1 @@
1
- {"version":3,"file":"discrepancies.js","sourceRoot":"","sources":["../../../src/simple-tree/api/discrepancies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAEpF,OAAO,EACN,QAAQ,EAGR,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,GAOtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EACN,QAAQ,EACR,yCAAyC,GAGzC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACN,iBAAiB,EACjB,SAAS,EACT,gBAAgB,GAEhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AA2F9D,SAAS,uBAAuB,CAAC,UAAgC;IAChE,IAAI,UAAU,YAAY,sBAAsB,EAAE,CAAC;QAClD,OAAO,sBAAsB,CAAC;IAC/B,CAAC;IACD,IAAI,UAAU,YAAY,mBAAmB,EAAE,CAAC;QAC/C,OAAO,mBAAmB,CAAC;IAC5B,CAAC;IACD,IAAI,UAAU,YAAY,oBAAoB,EAAE,CAAC;QAChD,OAAO,oBAAoB,CAAC;IAC7B,CAAC;IACD,IAA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AI,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC1D,IAAI,MAAM,CAAC,IAAI,KAAK,4BAA4B,EAAE,CAAC;YAClD,0DAA0D;YAC1D,qFAAqF;YACrF,2BAA2B;YAC3B,SAAS;QACV,CAAC;QAED,iEAAiE;QACjE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,2FAA2F;YAC3F,gFAAgF;YAChF,IAAI,CAAC,IAAI,CAAC,0BAA0B,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACxF,MAAM;oBACL,UAAU;oBACV,QAAQ;oBACR,QAAQ,EAAE,WAAW;oBACrB,IAAI,EAAE,sBAAsB,CAAC,IAAI;oBACjC,MAAM,EAAE,MAAM,CAAC,IAAI;iBACY,CAAC;YAClC,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail, unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tEmptyKey,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\tforbiddenFieldKindIdentifier,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tstoredEmptyFieldSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n\ttype ValueSchema,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\tNodeKind,\n\tnormalizeAndEvaluateAnnotatedAllowedTypes,\n\ttype AnnotatedAllowedType,\n\ttype TreeNodeSchema,\n} from \"../core/index.js\";\nimport {\n\tisArrayNodeSchema,\n\tisMapNodeSchema,\n\tisObjectNodeSchema,\n\tisRecordNodeSchema,\n\ttype ObjectNodeSchemaPrivate,\n} from \"../node-kinds/index.js\";\nimport { convertFieldKind } from \"../toStoredSchema.js\";\nimport {\n\tcreateFieldSchema,\n\tFieldKind,\n\tFieldSchemaAlpha,\n\ttype FieldSchema,\n} from \"../fieldSchema.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.js\";\nimport type { TreeSchema } from \"../treeSchema.js\";\nimport { tryStoredSchemaAsArray } from \"./customTree.js\";\nimport { FieldKinds } from \"../../feature-libraries/index.js\";\n\n/**\n * Discriminated union (keyed on `mismatch`) of discrepancies between a view and stored schema which\n * make it possible for content matching the stored schema to be incompatible with the view schema.\n */\nexport type Discrepancy = FieldDiscrepancy | NodeKindDiscrepancy;\n\n/**\n * A discrepancy in the declaration of a field.\n */\nexport type FieldDiscrepancy =\n\t| AllowedTypeDiscrepancy\n\t| FieldKindDiscrepancy\n\t| ValueSchemaDiscrepancy;\n\n/**\n * Information about where a field discrepancy is located within a collection of schema.\n */\nexport interface FieldDiscrepancyLocation {\n\t/**\n\t * The {@link TreeNodeSchemaIdentifier} that contains the discrepancy.\n\t *\n\t * Undefined iff the discrepancy is part of the root field schema.\n\t */\n\treadonly identifier: TreeNodeSchemaIdentifier | undefined;\n\t/**\n\t * The {@link FieldKey} for the field that contains the discrepancy.\n\t * Undefined when:\n\t * - the discrepancy is part of the root field schema\n\t * - the discrepancy is for 'all fields' of a map node\n\t */\n\treadonly fieldKey: FieldKey | undefined;\n}\n\n/**\n * A discrepancy in the allowed types of a field.\n *\n * @remarks\n * This reports the symmetric difference of allowed types.\n */\nexport interface AllowedTypeDiscrepancy extends FieldDiscrepancyLocation {\n\treadonly mismatch: \"allowedTypes\";\n\t/**\n\t * Annotated allowed types in viewed schema\n\t * (excluding {@link SchemaStaticsBeta.staged | staged} schema) which are not allowed in stored schema.\n\t */\n\treadonly view: readonly AnnotatedAllowedType<TreeNodeSchema>[];\n\t/**\n\t * Allowed type identifiers in stored schema which are not allowed in view schema\n\t * (including the view schema's {@link SchemaStaticsBeta.staged | staged} schema).\n\t */\n\treadonly stored: readonly TreeNodeSchemaIdentifier[];\n}\n\n/**\n * Differences in `FieldKindIdentifier` between two schema.\n */\nexport interface FieldKindDiscrepancy extends FieldDiscrepancyLocation {\n\treadonly mismatch: \"fieldKind\";\n\treadonly view: FieldKindIdentifier;\n\treadonly stored: FieldKindIdentifier;\n}\n\n/**\n * Differences in the `ValueSchema` of two `LeafNodeStoredSchema` objects.\n */\nexport interface ValueSchemaDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"valueSchema\";\n\tview: ValueSchema | undefined;\n\tstored: ValueSchema | undefined;\n}\n\n/**\n * Differences in the kind of node schema.\n *\n * Includes when stored object schema are expected to be compatible with an array node schema.\n */\nexport interface NodeKindDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"nodeKind\";\n\tview: NodeKind;\n\tstored: SchemaFactoryNodeKind;\n}\n\ntype SchemaFactoryNodeKind =\n\t| typeof ObjectNodeStoredSchema\n\t| typeof MapNodeStoredSchema\n\t| typeof LeafNodeStoredSchema;\n\nfunction getStoredNodeSchemaType(nodeSchema: TreeNodeStoredSchema): SchemaFactoryNodeKind {\n\tif (nodeSchema instanceof ObjectNodeStoredSchema) {\n\t\treturn ObjectNodeStoredSchema;\n\t}\n\tif (nodeSchema instanceof MapNodeStoredSchema) {\n\t\treturn MapNodeStoredSchema;\n\t}\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\treturn LeafNodeStoredSchema;\n\t}\n\tfail(0xbe8 /* Invalid stored node schema type */);\n}\n\nfunction doesNodeKindMatchStoredNodeKind(\n\tviewKind: NodeKind,\n\tstoredType: SchemaFactoryNodeKind,\n): boolean {\n\tswitch (viewKind) {\n\t\tcase NodeKind.Leaf:\n\t\t\treturn storedType === LeafNodeStoredSchema;\n\t\tcase NodeKind.Array:\n\t\tcase NodeKind.Object:\n\t\t\treturn storedType === ObjectNodeStoredSchema;\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record:\n\t\t\treturn storedType === MapNodeStoredSchema;\n\t\tdefault:\n\t\t\tunreachableCase(viewKind);\n\t}\n}\n\n/**\n * Finds and reports discrepancies between a view schema and a stored schema which make \"canView\" false.\n * @remarks\n * See documentation on {@link Discrepancy} and its subtypes for details of possible discrepancies.\n */\nexport function* getDiscrepanciesInAllowedContent(\n\tview: TreeSchema,\n\tstored: TreeStoredSchema,\n): Iterable<Discrepancy> {\n\t// check root field discrepancies\n\tyield* getFieldDiscrepancies(view.root, stored.rootFieldSchema, undefined, undefined);\n\n\t// Check all of the stored nodes, including their fields for discrepancies.\n\tfor (const [identifier, storedSchema] of stored.nodeSchema) {\n\t\tconst viewSchema = view.definitions.get(identifier);\n\n\t\t// if the view schema has a node that's also in the stored schema, check it.\n\t\tif (viewSchema !== undefined) {\n\t\t\tyield* getNodeDiscrepancies(identifier, viewSchema, storedSchema);\n\t\t}\n\t\t// Note that nodes that are missing in the view schema are only a problem if other stored schema nodes actually reference them which will produce its own discrepancy, so we can rely on that to produce any needed discrepancies.\n\t}\n}\n\nfunction* getNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: TreeNodeSchema,\n\tstored: TreeNodeStoredSchema,\n): Iterable<Discrepancy> {\n\tif (!doesNodeKindMatchStoredNodeKind(view.kind, getStoredNodeSchemaType(stored))) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tmismatch: \"nodeKind\",\n\t\t\tview: view.kind,\n\t\t\tstored: getStoredNodeSchemaType(stored),\n\t\t};\n\t\treturn;\n\t}\n\n\tswitch (view.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tassert(\n\t\t\t\tisObjectNodeSchema(view),\n\t\t\t\t0xbe9 /* schema with node kind of object must implement ObjectNodeSchema */,\n\t\t\t);\n\t\t\tyield* computeObjectNodeDiscrepancies(\n\t\t\t\tidentifier,\n\t\t\t\tview,\n\t\t\t\tstored as ObjectNodeStoredSchema,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\tassert(\n\t\t\t\tisArrayNodeSchema(view),\n\t\t\t\t0xbea /* schema with node kind of array must implement ArrayNodeSchema */,\n\t\t\t);\n\n\t\t\tconst arrayStoredSchema = tryStoredSchemaAsArray(stored);\n\t\t\tif (arrayStoredSchema === undefined) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: NodeKind.Array,\n\t\t\t\t\tstored: getStoredNodeSchemaType(stored),\n\t\t\t\t};\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tyield* getAllowedTypeDiscrepancies(\n\t\t\t\tnormalizeAndEvaluateAnnotatedAllowedTypes(view.info).types,\n\t\t\t\tarrayStoredSchema,\n\t\t\t\tbrand(view.identifier),\n\t\t\t\tEmptyKey,\n\t\t\t);\n\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\tassert(\n\t\t\t\tisMapNodeSchema(view),\n\t\t\t\t0xbeb /* schema with node kind of map must implement MapNodeSchema */,\n\t\t\t);\n\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\tcreateFieldSchema(FieldKind.Optional, view.info),\n\t\t\t\t(stored as MapNodeStoredSchema).mapFields,\n\t\t\t\tidentifier,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Record: {\n\t\t\tassert(\n\t\t\t\tisRecordNodeSchema(view),\n\t\t\t\t0xbec /* schema with node kind of record must implement RecordNodeSchema */,\n\t\t\t);\n\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\tcreateFieldSchema(FieldKind.Optional, view.info),\n\t\t\t\t(stored as MapNodeStoredSchema).mapFields,\n\t\t\t\tidentifier,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Leaf: {\n\t\t\tassert(\n\t\t\t\tview instanceof LeafNodeSchema,\n\t\t\t\t0xbed /* schema with node kind of leaf must implement LeafNodeSchema */,\n\t\t\t);\n\t\t\t// TODO: leafKind seems like a bad name\n\t\t\tconst viewValue = view.leafKind;\n\t\t\tconst storedValue = (stored as LeafNodeStoredSchema).leafValue;\n\t\t\tif (viewValue !== storedValue) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"valueSchema\",\n\t\t\t\t\tview: viewValue,\n\t\t\t\t\tstored: storedValue,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tbreak;\n\t}\n}\n\n/**\n * Returns the allowed types that are not present in both the given view and stored schemas.\n */\nexport function findExtraAllowedTypes(\n\tviewAllowedTypes: readonly AnnotatedAllowedType<TreeNodeSchema>[],\n\tstoredAllowedTypes: TreeTypeSet,\n): Pick<AllowedTypeDiscrepancy, \"view\" | \"stored\"> {\n\tconst viewNodeSchemaIdentifiers = new Set(\n\t\tviewAllowedTypes.map((value) => value.type.identifier),\n\t);\n\n\t// TODO:\n\t// Add detecting which SchemaUpgrades have been made.\n\t// When doing so, each will fall into one of three states: staged, partially applied, or fully applied.\n\t// This would allow for nicer compatibility errors and more detailed compatibility status in the future.\n\tconst view = viewAllowedTypes.filter(\n\t\t(value) =>\n\t\t\t!storedAllowedTypes.has(brand(value.type.identifier)) &&\n\t\t\tvalue.metadata.stagedSchemaUpgrade === undefined,\n\t);\n\tconst stored = [...storedAllowedTypes].filter(\n\t\t(value) => !viewNodeSchemaIdentifiers.has(value),\n\t);\n\treturn { view, stored };\n}\n\n/**\n * The function to track the discrepancies between a field view schema and a stored schema.\n *\n * @remarks\n * This function yields discrepancies in the following cases:\n * 1. If the view schema has allowed types that are not present in the stored schema.\n * 2. If the stored schema has allowed types that are not present in the view schema.\n * 3. If the field kind in the view schema is not compatible with the stored schema.\n *\n * This function does not recurse into the nodes of the view schema and only makes comparisons at the field level.\n *\n * @param fieldKey - If the key is missing, it indicates that this is the root field schema.\n */\nfunction* getFieldDiscrepancies(\n\tview: FieldSchema,\n\tstored: TreeFieldStoredSchema,\n\tidentifier: TreeNodeSchemaIdentifier | undefined,\n\tfieldKey: FieldKey | undefined,\n): Iterable<FieldDiscrepancy> {\n\tassert(\n\t\tview instanceof FieldSchemaAlpha,\n\t\t0xbee /* all field schema should be FieldSchemaAlpha */,\n\t);\n\tyield* getAllowedTypeDiscrepancies(\n\t\tview.allowedTypesFull.evaluate().types,\n\t\tstored.types,\n\t\tidentifier,\n\t\tfieldKey,\n\t);\n\n\tconst viewKind =\n\t\tconvertFieldKind.get(view.kind) ??\n\t\tfail(0xbef /* A conversion from a FieldKind to a FlexFieldKind should exist */);\n\n\t// This checks if the field kind in the view schema is not compatible with the stored schema.\n\tif (viewKind.identifier !== stored.kind) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tfieldKey,\n\t\t\tmismatch: \"fieldKind\",\n\t\t\tview: viewKind.identifier,\n\t\t\tstored: stored.kind,\n\t\t} satisfies FieldKindDiscrepancy;\n\t}\n}\n\n/**\n * The function to track the discrepancies between a field view schema and a stored schema.\n *\n * @remarks\n * This function yields discrepancies in the following cases:\n * 1. If the view schema has allowed types that are not present in the stored schema.\n * 2. If the stored schema has allowed types that are not present in the view schema.\n *\n * This function does not recurse into the nodes of the view schema and only makes comparisons at the field level.\n *\n * @param fieldKey - If the key is missing, it indicates that this is the root field schema.\n */\nfunction* getAllowedTypeDiscrepancies(\n\tview: readonly AnnotatedAllowedType<TreeNodeSchema>[],\n\tstored: TreeTypeSet,\n\tidentifier: TreeNodeSchemaIdentifier | undefined,\n\tfieldKey: FieldKey | undefined,\n): Iterable<FieldDiscrepancy> {\n\tconst discrepancies = findExtraAllowedTypes(view, stored);\n\tif (discrepancies.view.length > 0 || discrepancies.stored.length > 0) {\n\t\tyield {\n\t\t\t...discrepancies,\n\t\t\tidentifier,\n\t\t\tfieldKey,\n\t\t\tmismatch: \"allowedTypes\",\n\t\t} satisfies AllowedTypeDiscrepancy;\n\t}\n}\n\n/**\n * Computes discrepancies between a view schema and a stored schema for nodes that are treated as object nodes in the stored schema.\n * This includes both view object nodes and view array nodes.\n *\n * This function yields discrepancies in the following cases:\n *\n * 1. If the view schema has fields that are not present in the stored schema.\n * 2. If the stored schema has fields that are not present in the view schema.\n * 3. If the field kind or allowed types of a field in the view schema is not compatible with the stored schema.\n *\n * This function includes discrepancies within the common fields and their allowed types, but does NOT recurse to report and discrepancies within the node types referenced by those fields.\n */\nfunction* computeObjectNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: ObjectNodeSchemaPrivate,\n\tstored: ObjectNodeStoredSchema,\n): Iterable<FieldDiscrepancy> {\n\t/**\n\t * Similar to the logic used for tracking discrepancies between two node schemas, we will identify\n\t * three types of differences:\n\t * 1. Fields that exist in the view schema but not in the stored schema.\n\t * 2. Fields that exist in both schemas but have different contents.\n\t * 3. Fields that exist in the stored schema but not in the view schema.\n\t *\n\t * First, the view schema is iterated to track the first two types of differences.\n\t * Then, the stored schema is iterated to find the third type.\n\t */\n\n\tconst viewKeys = new Set<FieldKey>();\n\n\tfor (const [_, { storedKey: fieldKey, schema: fieldSchema }] of view.flexKeyMap) {\n\t\tconst storedSchema = stored.objectNodeFields.get(fieldKey);\n\t\tviewKeys.add(fieldKey);\n\n\t\t// If the view schema has a field that's not in the stored schema\n\t\tif (storedSchema === undefined) {\n\t\t\tconst viewKind =\n\t\t\t\tconvertFieldKind.get(fieldSchema.kind) ??\n\t\t\t\tfail(0xbf0 /* A conversion from a FieldKind to a FlexFieldKind should exist */);\n\t\t\tyield {\n\t\t\t\tidentifier,\n\t\t\t\tfieldKey,\n\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\tview: viewKind.identifier,\n\t\t\t\tstored: storedEmptyFieldSchema.kind,\n\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t} else {\n\t\t\tyield* getFieldDiscrepancies(fieldSchema, storedSchema, identifier, fieldKey);\n\t\t}\n\t}\n\n\tfor (const [fieldKey, schema] of stored.objectNodeFields) {\n\t\tif (schema.kind === forbiddenFieldKindIdentifier) {\n\t\t\t// In the stored schema the field is explicitly forbidden.\n\t\t\t// This has the same semantics of the field not being mentioned in the stored schema,\n\t\t\t// and thus can be skipped.\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If the stored schema has a field that's not in the view schema\n\t\tif (!viewKeys.has(fieldKey)) {\n\t\t\t// When the application has opted into it, we allow viewing documents which have additional\n\t\t\t// optional fields in the stored schema that are not present in the view schema.\n\t\t\tif (!view.allowUnknownOptionalFields || schema.kind !== FieldKinds.optional.identifier) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tfieldKey,\n\t\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\t\tview: storedEmptyFieldSchema.kind,\n\t\t\t\t\tstored: schema.kind,\n\t\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"discrepancies.js","sourceRoot":"","sources":["../../../src/simple-tree/api/discrepancies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAEpF,OAAO,EACN,QAAQ,EAGR,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,GAOtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EACN,QAAQ,EACR,yCAAyC,GAGzC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACN,iBAAiB,EACjB,SAAS,EACT,gBAAgB,GAEhB,MAAM,mBAAmB,CA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ed under the MIT License.\n */\n\nimport { assert, fail, unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tEmptyKey,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\tforbiddenFieldKindIdentifier,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tstoredEmptyFieldSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n\ttype ValueSchema,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\tNodeKind,\n\tnormalizeAndEvaluateAnnotatedAllowedTypes,\n\ttype AnnotatedAllowedType,\n\ttype TreeNodeSchema,\n} from \"../core/index.js\";\nimport {\n\tisArrayNodeSchema,\n\tisMapNodeSchema,\n\tisObjectNodeSchema,\n\tisRecordNodeSchema,\n\ttype ObjectNodeSchemaPrivate,\n} from \"../node-kinds/index.js\";\nimport { convertFieldKind } from \"../toStoredSchema.js\";\nimport {\n\tcreateFieldSchema,\n\tFieldKind,\n\tFieldSchemaAlpha,\n\ttype FieldSchema,\n} from \"../fieldSchema.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.js\";\nimport type { TreeSchema } from \"../treeSchema.js\";\nimport { tryStoredSchemaAsArray } from \"./customTree.js\";\nimport { FieldKinds } from \"../../feature-libraries/index.js\";\n\n/**\n * Discriminated union (keyed on `mismatch`) of discrepancies between a view and stored schema which\n * make it possible for content matching the stored schema to be incompatible with the view schema.\n */\nexport type Discrepancy = FieldDiscrepancy | NodeKindDiscrepancy;\n\n/**\n * A discrepancy in the declaration of a field.\n */\nexport type FieldDiscrepancy =\n\t| AllowedTypeDiscrepancy\n\t| FieldKindDiscrepancy\n\t| ValueSchemaDiscrepancy;\n\n/**\n * Information about where a field discrepancy is located within a collection of schema.\n */\nexport interface FieldDiscrepancyLocation {\n\t/**\n\t * The {@link TreeNodeSchemaIdentifier} that contains the discrepancy.\n\t *\n\t * Undefined iff the discrepancy is part of the root field schema.\n\t */\n\treadonly identifier: TreeNodeSchemaIdentifier | undefined;\n\t/**\n\t * The {@link FieldKey} for the field that contains the discrepancy.\n\t * Undefined when:\n\t * - the discrepancy is part of the root field schema\n\t * - the discrepancy is for 'all fields' of a map node\n\t */\n\treadonly fieldKey: FieldKey | undefined;\n}\n\n/**\n * A discrepancy in the allowed types of a field.\n *\n * @remarks\n * This reports the symmetric difference of allowed types.\n */\nexport interface AllowedTypeDiscrepancy extends FieldDiscrepancyLocation {\n\treadonly mismatch: \"allowedTypes\";\n\t/**\n\t * Annotated allowed types in viewed schema\n\t * (excluding {@link SchemaStaticsBeta.staged | staged} schema) which are not allowed in stored schema.\n\t */\n\treadonly view: readonly AnnotatedAllowedType<TreeNodeSchema>[];\n\t/**\n\t * Allowed type identifiers in stored schema which are not allowed in view schema\n\t * (including the view schema's {@link SchemaStaticsBeta.staged | staged} schema).\n\t */\n\treadonly stored: readonly TreeNodeSchemaIdentifier[];\n}\n\n/**\n * Differences in `FieldKindIdentifier` between two schema.\n */\nexport interface FieldKindDiscrepancy extends FieldDiscrepancyLocation {\n\treadonly mismatch: \"fieldKind\";\n\treadonly view: FieldKindIdentifier;\n\treadonly stored: FieldKindIdentifier;\n}\n\n/**\n * Differences in the `ValueSchema` of two `LeafNodeStoredSchema` objects.\n */\nexport interface ValueSchemaDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"valueSchema\";\n\tview: ValueSchema | undefined;\n\tstored: ValueSchema | undefined;\n}\n\n/**\n * Differences in the kind of node schema.\n *\n * Includes when stored object schema are expected to be compatible with an array node schema.\n */\nexport interface NodeKindDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"nodeKind\";\n\tview: NodeKind;\n\tstored: SchemaFactoryNodeKind;\n}\n\ntype SchemaFactoryNodeKind =\n\t| typeof ObjectNodeStoredSchema\n\t| typeof MapNodeStoredSchema\n\t| typeof LeafNodeStoredSchema;\n\nfunction getStoredNodeSchemaType(nodeSchema: TreeNodeStoredSchema): SchemaFactoryNodeKind {\n\tif (nodeSchema instanceof ObjectNodeStoredSchema) {\n\t\treturn ObjectNodeStoredSchema;\n\t}\n\tif (nodeSchema instanceof MapNodeStoredSchema) {\n\t\treturn MapNodeStoredSchema;\n\t}\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\treturn LeafNodeStoredSchema;\n\t}\n\tfail(0xbe8 /* Invalid stored node schema type */);\n}\n\nfunction doesNodeKindMatchStoredNodeKind(\n\tviewKind: NodeKind,\n\tstoredType: SchemaFactoryNodeKind,\n): boolean {\n\tswitch (viewKind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn storedType === LeafNodeStoredSchema;\n\t\t}\n\t\tcase NodeKind.Array:\n\t\tcase NodeKind.Object: {\n\t\t\treturn storedType === ObjectNodeStoredSchema;\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\treturn storedType === MapNodeStoredSchema;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(viewKind);\n\t\t}\n\t}\n}\n\n/**\n * Finds and reports discrepancies between a view schema and a stored schema which make \"canView\" false.\n * @remarks\n * See documentation on {@link Discrepancy} and its subtypes for details of possible discrepancies.\n */\nexport function* getDiscrepanciesInAllowedContent(\n\tview: TreeSchema,\n\tstored: TreeStoredSchema,\n): Iterable<Discrepancy> {\n\t// check root field discrepancies\n\tyield* getFieldDiscrepancies(view.root, stored.rootFieldSchema, undefined, undefined);\n\n\t// Check all of the stored nodes, including their fields for discrepancies.\n\tfor (const [identifier, storedSchema] of stored.nodeSchema) {\n\t\tconst viewSchema = view.definitions.get(identifier);\n\n\t\t// if the view schema has a node that's also in the stored schema, check it.\n\t\tif (viewSchema !== undefined) {\n\t\t\tyield* getNodeDiscrepancies(identifier, viewSchema, storedSchema);\n\t\t}\n\t\t// Note that nodes that are missing in the view schema are only a problem if other stored schema nodes actually reference them which will produce its own discrepancy, so we can rely on that to produce any needed discrepancies.\n\t}\n}\n\nfunction* getNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: TreeNodeSchema,\n\tstored: TreeNodeStoredSchema,\n): Iterable<Discrepancy> {\n\tif (!doesNodeKindMatchStoredNodeKind(view.kind, getStoredNodeSchemaType(stored))) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tmismatch: \"nodeKind\",\n\t\t\tview: view.kind,\n\t\t\tstored: getStoredNodeSchemaType(stored),\n\t\t};\n\t\treturn;\n\t}\n\n\tswitch (view.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tassert(\n\t\t\t\tisObjectNodeSchema(view),\n\t\t\t\t0xbe9 /* schema with node kind of object must implement ObjectNodeSchema */,\n\t\t\t);\n\t\t\tyield* computeObjectNodeDiscrepancies(\n\t\t\t\tidentifier,\n\t\t\t\tview,\n\t\t\t\tstored as ObjectNodeStoredSchema,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\tassert(\n\t\t\t\tisArrayNodeSchema(view),\n\t\t\t\t0xbea /* schema with node kind of array must implement ArrayNodeSchema */,\n\t\t\t);\n\n\t\t\tconst arrayStoredSchema = tryStoredSchemaAsArray(stored);\n\t\t\tif (arrayStoredSchema === undefined) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: NodeKind.Array,\n\t\t\t\t\tstored: getStoredNodeSchemaType(stored),\n\t\t\t\t};\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tyield* getAllowedTypeDiscrepancies(\n\t\t\t\tnormalizeAndEvaluateAnnotatedAllowedTypes(view.info).types,\n\t\t\t\tarrayStoredSchema,\n\t\t\t\tbrand(view.identifier),\n\t\t\t\tEmptyKey,\n\t\t\t);\n\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\tassert(\n\t\t\t\tisMapNodeSchema(view),\n\t\t\t\t0xbeb /* schema with node kind of map must implement MapNodeSchema */,\n\t\t\t);\n\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\tcreateFieldSchema(FieldKind.Optional, view.info),\n\t\t\t\t(stored as MapNodeStoredSchema).mapFields,\n\t\t\t\tidentifier,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Record: {\n\t\t\tassert(\n\t\t\t\tisRecordNodeSchema(view),\n\t\t\t\t0xbec /* schema with node kind of record must implement RecordNodeSchema */,\n\t\t\t);\n\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\tcreateFieldSchema(FieldKind.Optional, view.info),\n\t\t\t\t(stored as MapNodeStoredSchema).mapFields,\n\t\t\t\tidentifier,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase NodeKind.Leaf: {\n\t\t\tassert(\n\t\t\t\tview instanceof LeafNodeSchema,\n\t\t\t\t0xbed /* schema with node kind of leaf must implement LeafNodeSchema */,\n\t\t\t);\n\t\t\t// TODO: leafKind seems like a bad name\n\t\t\tconst viewValue = view.leafKind;\n\t\t\tconst storedValue = (stored as LeafNodeStoredSchema).leafValue;\n\t\t\tif (viewValue !== storedValue) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"valueSchema\",\n\t\t\t\t\tview: viewValue,\n\t\t\t\t\tstored: storedValue,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/**\n * Returns the allowed types that are not present in both the given view and stored schemas.\n */\nexport function findExtraAllowedTypes(\n\tviewAllowedTypes: readonly AnnotatedAllowedType<TreeNodeSchema>[],\n\tstoredAllowedTypes: TreeTypeSet,\n): Pick<AllowedTypeDiscrepancy, \"view\" | \"stored\"> {\n\tconst viewNodeSchemaIdentifiers = new Set(\n\t\tviewAllowedTypes.map((value) => value.type.identifier),\n\t);\n\n\t// TODO:\n\t// Add detecting which SchemaUpgrades have been made.\n\t// When doing so, each will fall into one of three states: staged, partially applied, or fully applied.\n\t// This would allow for nicer compatibility errors and more detailed compatibility status in the future.\n\tconst view = viewAllowedTypes.filter(\n\t\t(value) =>\n\t\t\t!storedAllowedTypes.has(brand(value.type.identifier)) &&\n\t\t\tvalue.metadata.stagedSchemaUpgrade === undefined,\n\t);\n\tconst stored = [...storedAllowedTypes].filter(\n\t\t(value) => !viewNodeSchemaIdentifiers.has(value),\n\t);\n\treturn { view, stored };\n}\n\n/**\n * The function to track the discrepancies between a field view schema and a stored schema.\n *\n * @remarks\n * This function yields discrepancies in the following cases:\n * 1. If the view schema has allowed types that are not present in the stored schema.\n * 2. If the stored schema has allowed types that are not present in the view schema.\n * 3. If the field kind in the view schema is not compatible with the stored schema.\n *\n * This function does not recurse into the nodes of the view schema and only makes comparisons at the field level.\n *\n * @param fieldKey - If the key is missing, it indicates that this is the root field schema.\n */\nfunction* getFieldDiscrepancies(\n\tview: FieldSchema,\n\tstored: TreeFieldStoredSchema,\n\tidentifier: TreeNodeSchemaIdentifier | undefined,\n\tfieldKey: FieldKey | undefined,\n): Iterable<FieldDiscrepancy> {\n\tassert(\n\t\tview instanceof FieldSchemaAlpha,\n\t\t0xbee /* all field schema should be FieldSchemaAlpha */,\n\t);\n\tyield* getAllowedTypeDiscrepancies(\n\t\tview.allowedTypesFull.evaluate().types,\n\t\tstored.types,\n\t\tidentifier,\n\t\tfieldKey,\n\t);\n\n\tconst viewKind =\n\t\tconvertFieldKind.get(view.kind) ??\n\t\tfail(0xbef /* A conversion from a FieldKind to a FlexFieldKind should exist */);\n\n\t// This checks if the field kind in the view schema is not compatible with the stored schema.\n\tif (viewKind.identifier !== stored.kind) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tfieldKey,\n\t\t\tmismatch: \"fieldKind\",\n\t\t\tview: viewKind.identifier,\n\t\t\tstored: stored.kind,\n\t\t} satisfies FieldKindDiscrepancy;\n\t}\n}\n\n/**\n * The function to track the discrepancies between a field view schema and a stored schema.\n *\n * @remarks\n * This function yields discrepancies in the following cases:\n * 1. If the view schema has allowed types that are not present in the stored schema.\n * 2. If the stored schema has allowed types that are not present in the view schema.\n *\n * This function does not recurse into the nodes of the view schema and only makes comparisons at the field level.\n *\n * @param fieldKey - If the key is missing, it indicates that this is the root field schema.\n */\nfunction* getAllowedTypeDiscrepancies(\n\tview: readonly AnnotatedAllowedType<TreeNodeSchema>[],\n\tstored: TreeTypeSet,\n\tidentifier: TreeNodeSchemaIdentifier | undefined,\n\tfieldKey: FieldKey | undefined,\n): Iterable<FieldDiscrepancy> {\n\tconst discrepancies = findExtraAllowedTypes(view, stored);\n\tif (discrepancies.view.length > 0 || discrepancies.stored.length > 0) {\n\t\tyield {\n\t\t\t...discrepancies,\n\t\t\tidentifier,\n\t\t\tfieldKey,\n\t\t\tmismatch: \"allowedTypes\",\n\t\t} satisfies AllowedTypeDiscrepancy;\n\t}\n}\n\n/**\n * Computes discrepancies between a view schema and a stored schema for nodes that are treated as object nodes in the stored schema.\n * This includes both view object nodes and view array nodes.\n *\n * This function yields discrepancies in the following cases:\n *\n * 1. If the view schema has fields that are not present in the stored schema.\n * 2. If the stored schema has fields that are not present in the view schema.\n * 3. If the field kind or allowed types of a field in the view schema is not compatible with the stored schema.\n *\n * This function includes discrepancies within the common fields and their allowed types, but does NOT recurse to report and discrepancies within the node types referenced by those fields.\n */\nfunction* computeObjectNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: ObjectNodeSchemaPrivate,\n\tstored: ObjectNodeStoredSchema,\n): Iterable<FieldDiscrepancy> {\n\t/**\n\t * Similar to the logic used for tracking discrepancies between two node schemas, we will identify\n\t * three types of differences:\n\t * 1. Fields that exist in the view schema but not in the stored schema.\n\t * 2. Fields that exist in both schemas but have different contents.\n\t * 3. Fields that exist in the stored schema but not in the view schema.\n\t *\n\t * First, the view schema is iterated to track the first two types of differences.\n\t * Then, the stored schema is iterated to find the third type.\n\t */\n\n\tconst viewKeys = new Set<FieldKey>();\n\n\tfor (const [_, { storedKey: fieldKey, schema: fieldSchema }] of view.flexKeyMap) {\n\t\tconst storedSchema = stored.objectNodeFields.get(fieldKey);\n\t\tviewKeys.add(fieldKey);\n\n\t\t// If the view schema has a field that's not in the stored schema\n\t\tif (storedSchema === undefined) {\n\t\t\tconst viewKind =\n\t\t\t\tconvertFieldKind.get(fieldSchema.kind) ??\n\t\t\t\tfail(0xbf0 /* A conversion from a FieldKind to a FlexFieldKind should exist */);\n\t\t\tyield {\n\t\t\t\tidentifier,\n\t\t\t\tfieldKey,\n\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\tview: viewKind.identifier,\n\t\t\t\tstored: storedEmptyFieldSchema.kind,\n\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t} else {\n\t\t\tyield* getFieldDiscrepancies(fieldSchema, storedSchema, identifier, fieldKey);\n\t\t}\n\t}\n\n\tfor (const [fieldKey, schema] of stored.objectNodeFields) {\n\t\tif (schema.kind === forbiddenFieldKindIdentifier) {\n\t\t\t// In the stored schema the field is explicitly forbidden.\n\t\t\t// This has the same semantics of the field not being mentioned in the stored schema,\n\t\t\t// and thus can be skipped.\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If the stored schema has a field that's not in the view schema\n\t\t// When the application has opted into it, we allow viewing documents which have additional\n\t\t// optional fields in the stored schema that are not present in the view schema.\n\t\tif (\n\t\t\t!viewKeys.has(fieldKey) &&\n\t\t\t(!view.allowUnknownOptionalFields || schema.kind !== FieldKinds.optional.identifier)\n\t\t) {\n\t\t\tyield {\n\t\t\t\tidentifier,\n\t\t\t\tfieldKey,\n\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\tview: storedEmptyFieldSchema.kind,\n\t\t\t\tstored: schema.kind,\n\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t}\n\t}\n}\n"]}
@@ -30,7 +30,7 @@ export { borrowCursorFromTreeNodeOrValue, exportConcise, importConcise, type Nod
30
30
  export { createSimpleTreeIndex, type SimpleTreeIndex } from "./simpleTreeIndex.js";
31
31
  export { createIdentifierIndex, type IdentifierIndex, } from "./identifierIndex.js";
32
32
  export { extractPersistedSchema, comparePersistedSchema, } from "./storedSchema.js";
33
- export { type TransactionConstraint, type NodeInDocumentConstraint, type RunTransactionParams, type VoidTransactionCallbackStatus, type TransactionCallbackStatus, type TransactionResult, type TransactionResultExt, type TransactionResultSuccess, type TransactionResultFailed, rollback, } from "./transactionTypes.js";
33
+ export { type TransactionConstraint, type TransactionConstraintAlpha, type NodeInDocumentConstraint, type NoChangeConstraint, type RunTransactionParams, type VoidTransactionCallbackStatus, type TransactionCallbackStatus, type TransactionResult, type TransactionResultExt, type TransactionResultSuccess, type TransactionResultFailed, rollback, } from "./transactionTypes.js";
34
34
  export { generateSchemaFromSimpleSchema } from "./schemaFromSimple.js";
35
35
  export type { TreeChangeEvents } from "./treeChangeEvents.js";
36
36
  export { incrementalEncodingPolicyForAllowedTypes, incrementalSummaryHint, } from "./incrementalAllowedTypes.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACX,sBAAsB,EACtB,yBAAyB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,qBAAqB,EACrB,0BAA0B,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACX,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,yBAAyB,EACzB,aAAa,EACb,YAAY,EACZ,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,GACV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,KAAK,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,E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B,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,QAAQ,GACR,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACN,wCAAwC,EACxC,sBAAsB,GACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,iCAAiC,EACjC,iCAAiC,GACjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,iCAAiC,EACjC,iCAAiC,EACjC,kBAAkB,GAClB,MAAM,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACX,sBAAsB,EACtB,yBAAyB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,qBAAqB,EACrB,0BAA0B,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACX,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,yBAAyB,EACzB,aAAa,EACb,YAAY,EACZ,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,GACV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,KAAK,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EACN,aAAa,EACb,MAAM,EACN,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,kB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0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEN,sBAAsB,EAGtB,sBAAsB,EACtB,cAAc,EAEd,kBAAkB,GAElB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEN,iBAAiB,EACjB,yBAAyB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,+BAA+B,EAC/B,aAAa,EACb,aAAa,EAEb,QAAQ,GAER,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAwB,MAAM,sBAAsB,CAAC;AACnF,OAAO,EACN,qBAAqB,GAErB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACN,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAUN,QAAQ,GACR,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EACN,wCAAwC,EACxC,sBAAsB,GACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,iCAAiC,EACjC,iCAAiC,GACjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,iCAAiC,EACjC,iCAAiC,EACjC,kBAAkB,GAClB,MAAM,mCAAmC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type {\n\tITreeViewConfiguration,\n\tITreeConfigurationOptions,\n} from \"./configuration.js\";\nexport {\n\tTreeViewConfiguration,\n\tTreeViewConfigurationAlpha,\n} from \"./configuration.js\";\nexport type {\n\tITree,\n\tTreeView,\n\tViewableTree,\n\tTreeViewEvents,\n\tSchemaCompatibilityStatus,\n\tTreeViewAlpha,\n\tTreeViewBeta,\n\tTreeBranch,\n\tTreeBranchAlpha,\n\tTreeBranchEvents,\n\tITreeAlpha,\n} from \"./tree.js\";\nexport { asTreeViewAlpha } from \"./tree.js\";\nexport { type SchemaStatics, schemaStatics } from \"./schemaStatics.js\";\nexport {\n\tSchemaFactory,\n\tscoped,\n\ttype ScopedSchemaName,\n\ttype ObjectSchemaOptionsAlpha,\n\ttype ObjectSchemaOptions,\n\ttype NodeSchemaOptions,\n\ttype NodeSchemaOptionsAlpha,\n\ttype SchemaFactory_base,\n} from \"./schemaFactory.js\";\nexport { SchemaFactoryBeta, type SchemaStaticsBeta } from \"./schemaFactoryBeta.js\";\nexport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\nexport {\n\teraseSchemaDetails,\n\teraseSchemaDetailsSubclassable,\n} from \"./eraseSchemaDetails.js\";\nexport type {\n\tValidateRecursiveSchema,\n\tFixRecursiveArraySchema,\n\tValidateRecursiveSchemaTemplate,\n\tFixRecursiveRecursionLimit,\n} from \"./schemaFactoryRecursive.js\";\nexport { allowUnused } from \"./schemaFactoryRecursive.js\";\nexport {\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n} from \"./schemaCreationUtilities.js\";\nexport {\n\tgetIdentifierFromNode,\n\tgetPropertyKeyFromStoredKey,\n\tgetStoredKey,\n\ttreeNodeApi,\n\ttype TreeNodeApi,\n\ttryGetSchema,\n} from \"./treeNodeApi.js\";\nexport { createFromCursor } from \"./create.js\";\nexport {\n\ttype DirtyTreeStatus,\n\ttrackDirtyNodes,\n\ttype DirtyTreeMap,\n} from \"./dirtyIndex.js\";\nexport {\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n\ttype JsonRecordNodeSchema,\n\ttype JsonStringKeyPatternProperties,\n} from \"./jsonSchema.js\";\nexport type { TreeSchemaEncodingOptions } from \"./getJsonSchema.js\";\nexport { getJsonSchema } from \"./getJsonSchema.js\";\nexport { getSimpleSchema } from \"./getSimpleSchema.js\";\nexport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nexport type {\n\tUnenforced,\n\tFieldSchemaAlphaUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n\tUnannotateAllowedTypeUnsafe,\n\tAnnotatedAllowedTypeUnsafe,\n\tAnnotatedAllowedTypesUnsafe,\n\tAllowedTypesFullUnsafe,\n\tAllowedTypesFullFromMixedUnsafe,\n\tUnannotateAllowedTypesListUnsafe,\n\tAnnotateAllowedTypesListUnsafe,\n} from \"./typesUnsafe.js\";\n\nexport {\n\ttype VerboseTreeNode,\n\ttype VerboseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\treplaceVerboseTreeHandles,\n} from \"./verboseTree.js\";\n\nexport {\n\ttype TreeEncodingOptions,\n\tcustomFromCursorStored,\n\ttype CustomTreeNode,\n\ttype CustomTreeValue,\n\ttryStoredSchemaAsArray,\n\treplaceHandles,\n\ttype HandleConverter,\n\tKeyEncodingOptions,\n\ttype TreeParsingOptions,\n} from \"./customTree.js\";\n\nexport {\n\ttype ConciseTree,\n\tconciseFromCursor,\n\treplaceConciseTreeHandles,\n} from \"./conciseTree.js\";\n\nexport {\n\tborrowCursorFromTreeNodeOrValue,\n\texportConcise,\n\timportConcise,\n\ttype NodeChangedData,\n\tTreeBeta,\n\ttype TreeChangeEventsBeta,\n} from \"./treeBeta.js\";\nexport { createSimpleTreeIndex, type SimpleTreeIndex } from \"./simpleTreeIndex.js\";\nexport {\n\tcreateIdentifierIndex,\n\ttype IdentifierIndex,\n} from \"./identifierIndex.js\";\n\nexport {\n\textractPersistedSchema,\n\tcomparePersistedSchema,\n} from \"./storedSchema.js\";\n\nexport {\n\ttype TransactionConstraint,\n\ttype NodeInDocumentConstraint,\n\ttype RunTransactionParams,\n\ttype VoidTransactionCallbackStatus,\n\ttype TransactionCallbackStatus,\n\ttype TransactionResult,\n\ttype TransactionResultExt,\n\ttype TransactionResultSuccess,\n\ttype TransactionResultFailed,\n\trollback,\n} from \"./transactionTypes.js\";\n\nexport { generateSchemaFromSimpleSchema } from \"./schemaFromSimple.js\";\nexport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nexport {\n\tincrementalEncodingPolicyForAllowedTypes,\n\tincrementalSummaryHint,\n} from \"./incrementalAllowedTypes.js\";\nexport {\n\tencodeSchemaCompatibilitySnapshot,\n\tdecodeSchemaCompatibilitySnapshot,\n} from \"./simpleSchemaCodec.js\";\nexport {\n\texportCompatibilitySchemaSnapshot,\n\timportCompatibilitySchemaSnapshot,\n\tcheckCompatibility,\n} from \"./snapshotCompatibilityChecker.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/api/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,qBAAqB,EACrB,0BAA0B,GAC1B,MAAM,oBAAoB,CAAC;AAc5B,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAsB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EACN,aAAa,EACb,MAAM,GAON,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAA0B,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACN,kBAAkB,EAClB,8BAA8B,GAC9B,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EACN,SAAS,EACT,eAAe,EACf,eAAe,GACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,WAAW,EAEX,YAAY,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAEN,eAAe,GAEf,MAAM,iBAAiB,CAAC;AAmBzB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAiB3E,OAAO,EAGN,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEN,sBAAsB,EAGtB,sBAAsB,EACtB,cAAc,EAEd,kBAAkB,GAElB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEN,iBAAiB,EACjB,yBAAyB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,+BAA+B,EAC/B,aAAa,EACb,aAAa,EAEb,QAAQ,GAER,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAwB,MAAM,sBAAsB,CAAC;AACnF,OAAO,EACN,qBAAqB,GAErB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACN,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAYN,QAAQ,GACR,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EACN,wCAAwC,EACxC,sBAAsB,GACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,iCAAiC,EACjC,iCAAiC,GACjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,iCAAiC,EACjC,iCAAiC,EACjC,kBAAkB,GAClB,MAAM,mCAAmC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type {\n\tITreeViewConfiguration,\n\tITreeConfigurationOptions,\n} from \"./configuration.js\";\nexport {\n\tTreeViewConfiguration,\n\tTreeViewConfigurationAlpha,\n} from \"./configuration.js\";\nexport type {\n\tITree,\n\tTreeView,\n\tViewableTree,\n\tTreeViewEvents,\n\tSchemaCompatibilityStatus,\n\tTreeViewAlpha,\n\tTreeViewBeta,\n\tTreeBranch,\n\tTreeBranchAlpha,\n\tTreeBranchEvents,\n\tITreeAlpha,\n} from \"./tree.js\";\nexport { asTreeViewAlpha } from \"./tree.js\";\nexport { type SchemaStatics, schemaStatics } from \"./schemaStatics.js\";\nexport {\n\tSchemaFactory,\n\tscoped,\n\ttype ScopedSchemaName,\n\ttype ObjectSchemaOptionsAlpha,\n\ttype ObjectSchemaOptions,\n\ttype NodeSchemaOptions,\n\ttype NodeSchemaOptionsAlpha,\n\ttype SchemaFactory_base,\n} from \"./schemaFactory.js\";\nexport { SchemaFactoryBeta, type SchemaStaticsBeta } from \"./schemaFactoryBeta.js\";\nexport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\nexport {\n\teraseSchemaDetails,\n\teraseSchemaDetailsSubclassable,\n} from \"./eraseSchemaDetails.js\";\nexport type {\n\tValidateRecursiveSchema,\n\tFixRecursiveArraySchema,\n\tValidateRecursiveSchemaTemplate,\n\tFixRecursiveRecursionLimit,\n} from \"./schemaFactoryRecursive.js\";\nexport { allowUnused } from \"./schemaFactoryRecursive.js\";\nexport {\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n} from \"./schemaCreationUtilities.js\";\nexport {\n\tgetIdentifierFromNode,\n\tgetPropertyKeyFromStoredKey,\n\tgetStoredKey,\n\ttreeNodeApi,\n\ttype TreeNodeApi,\n\ttryGetSchema,\n} from \"./treeNodeApi.js\";\nexport { createFromCursor } from \"./create.js\";\nexport {\n\ttype DirtyTreeStatus,\n\ttrackDirtyNodes,\n\ttype DirtyTreeMap,\n} from \"./dirtyIndex.js\";\nexport {\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n\ttype JsonRecordNodeSchema,\n\ttype JsonStringKeyPatternProperties,\n} from \"./jsonSchema.js\";\nexport type { TreeSchemaEncodingOptions } from \"./getJsonSchema.js\";\nexport { getJsonSchema } from \"./getJsonSchema.js\";\nexport { getSimpleSchema } from \"./getSimpleSchema.js\";\nexport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nexport type {\n\tUnenforced,\n\tFieldSchemaAlphaUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n\tUnannotateAllowedTypeUnsafe,\n\tAnnotatedAllowedTypeUnsafe,\n\tAnnotatedAllowedTypesUnsafe,\n\tAllowedTypesFullUnsafe,\n\tAllowedTypesFullFromMixedUnsafe,\n\tUnannotateAllowedTypesListUnsafe,\n\tAnnotateAllowedTypesListUnsafe,\n} from \"./typesUnsafe.js\";\n\nexport {\n\ttype VerboseTreeNode,\n\ttype VerboseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\treplaceVerboseTreeHandles,\n} from \"./verboseTree.js\";\n\nexport {\n\ttype TreeEncodingOptions,\n\tcustomFromCursorStored,\n\ttype CustomTreeNode,\n\ttype CustomTreeValue,\n\ttryStoredSchemaAsArray,\n\treplaceHandles,\n\ttype HandleConverter,\n\tKeyEncodingOptions,\n\ttype TreeParsingOptions,\n} from \"./customTree.js\";\n\nexport {\n\ttype ConciseTree,\n\tconciseFromCursor,\n\treplaceConciseTreeHandles,\n} from \"./conciseTree.js\";\n\nexport {\n\tborrowCursorFromTreeNodeOrValue,\n\texportConcise,\n\timportConcise,\n\ttype NodeChangedData,\n\tTreeBeta,\n\ttype TreeChangeEventsBeta,\n} from \"./treeBeta.js\";\nexport { createSimpleTreeIndex, type SimpleTreeIndex } from \"./simpleTreeIndex.js\";\nexport {\n\tcreateIdentifierIndex,\n\ttype IdentifierIndex,\n} from \"./identifierIndex.js\";\n\nexport {\n\textractPersistedSchema,\n\tcomparePersistedSchema,\n} from \"./storedSchema.js\";\n\nexport {\n\ttype TransactionConstraint,\n\ttype TransactionConstraintAlpha,\n\ttype NodeInDocumentConstraint,\n\ttype NoChangeConstraint,\n\ttype RunTransactionParams,\n\ttype VoidTransactionCallbackStatus,\n\ttype TransactionCallbackStatus,\n\ttype TransactionResult,\n\ttype TransactionResultExt,\n\ttype TransactionResultSuccess,\n\ttype TransactionResultFailed,\n\trollback,\n} from \"./transactionTypes.js\";\n\nexport { generateSchemaFromSimpleSchema } from \"./schemaFromSimple.js\";\nexport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nexport {\n\tincrementalEncodingPolicyForAllowedTypes,\n\tincrementalSummaryHint,\n} from \"./incrementalAllowedTypes.js\";\nexport {\n\tencodeSchemaCompatibilitySnapshot,\n\tdecodeSchemaCompatibilitySnapshot,\n} from \"./simpleSchemaCodec.js\";\nexport {\n\texportCompatibilitySchemaSnapshot,\n\timportCompatibilitySchemaSnapshot,\n\tcheckCompatibility,\n} from \"./snapshotCompatibilityChecker.js\";\n"]}