@fluidframework/tree 2.118.0 → 3.0.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 (1234) hide show
  1. package/CHANGELOG.md +367 -75
  2. package/README.md +55 -52
  3. package/{api-extractor.json → api-extractor/api-extractor-model.json} +1 -1
  4. package/api-report/tree.alpha.api.md +130 -145
  5. package/api-report/tree.beta.api.md +122 -91
  6. package/api-report/tree.legacy.beta.api.md +122 -91
  7. package/api-report/tree.legacy.public.api.md +26 -43
  8. package/api-report/tree.public.api.md +26 -43
  9. package/dist/api.d.ts +9 -1
  10. package/dist/api.d.ts.map +1 -1
  11. package/dist/api.js +2 -3
  12. package/dist/api.js.map +1 -1
  13. package/dist/codec/codec.d.ts +2 -2
  14. package/dist/codec/codec.d.ts.map +1 -1
  15. package/dist/codec/codec.js +9 -7
  16. package/dist/codec/codec.js.map +1 -1
  17. package/dist/codec/discriminatedUnions.js +1 -0
  18. package/dist/codec/discriminatedUnions.js.map +1 -1
  19. package/dist/codec/versioned/codec.d.ts.map +1 -1
  20. package/dist/codec/versioned/codec.js +4 -2
  21. package/dist/codec/versioned/codec.js.map +1 -1
  22. package/dist/componentApi.d.ts.map +1 -1
  23. package/dist/componentApi.js +20 -17
  24. package/dist/componentApi.js.map +1 -1
  25. package/dist/core/change-family/editBuilder.js +1 -0
  26. package/dist/core/change-family/editBuilder.js.map +1 -1
  27. package/dist/core/forest/editableForest.js +1 -2
  28. package/dist/core/forest/editableForest.js.map +1 -1
  29. package/dist/core/forest/forest.js +3 -3
  30. package/dist/core/forest/forest.js.map +1 -1
  31. package/dist/core/index.d.ts +2 -2
  32. package/dist/core/index.d.ts.map +1 -1
  33. package/dist/core/index.js +9 -5
  34. package/dist/core/index.js.map +1 -1
  35. package/dist/core/rebase/changeRebaser.js +5 -5
  36. package/dist/core/rebase/changeRebaser.js.map +1 -1
  37. package/dist/core/rebase/index.d.ts +1 -1
  38. package/dist/core/rebase/index.d.ts.map +1 -1
  39. package/dist/core/rebase/index.js +2 -1
  40. package/dist/core/rebase/index.js.map +1 -1
  41. package/dist/core/rebase/revisionTagCodec.d.ts +1 -1
  42. package/dist/core/rebase/revisionTagCodec.d.ts.map +1 -1
  43. package/dist/core/rebase/revisionTagCodec.js +3 -1
  44. package/dist/core/rebase/revisionTagCodec.js.map +1 -1
  45. package/dist/core/rebase/types.d.ts +12 -1
  46. package/dist/core/rebase/types.d.ts.map +1 -1
  47. package/dist/core/rebase/types.js +19 -15
  48. package/dist/core/rebase/types.js.map +1 -1
  49. package/dist/core/rebase/utils.js +9 -10
  50. package/dist/core/rebase/utils.js.map +1 -1
  51. package/dist/core/schema-stored/schema.js +9 -4
  52. package/dist/core/schema-stored/schema.js.map +1 -1
  53. package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  54. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  55. package/dist/core/schema-stored/storedSchemaRepository.js +6 -4
  56. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  57. package/dist/core/tree/anchorSet.d.ts +1 -1
  58. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  59. package/dist/core/tree/anchorSet.js +62 -55
  60. package/dist/core/tree/anchorSet.js.map +1 -1
  61. package/dist/core/tree/chunk.js +2 -2
  62. package/dist/core/tree/chunk.js.map +1 -1
  63. package/dist/core/tree/cursor.js +12 -12
  64. package/dist/core/tree/cursor.js.map +1 -1
  65. package/dist/core/tree/deltaUtil.d.ts +34 -9
  66. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  67. package/dist/core/tree/deltaUtil.js +51 -17
  68. package/dist/core/tree/deltaUtil.js.map +1 -1
  69. package/dist/core/tree/detachedFieldIndex.js +23 -21
  70. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  71. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +10 -10
  72. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  73. package/dist/core/tree/detachedFieldIndexCodecCommon.js +1 -2
  74. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  75. package/dist/core/tree/detachedFieldIndexCodecV1.js +3 -2
  76. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  77. package/dist/core/tree/detachedFieldIndexCodecV2.js +3 -2
  78. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  79. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +3 -3
  80. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  81. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +1 -1
  82. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +2 -2
  83. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  84. package/dist/core/tree/index.d.ts +1 -1
  85. package/dist/core/tree/index.d.ts.map +1 -1
  86. package/dist/core/tree/index.js +7 -4
  87. package/dist/core/tree/index.js.map +1 -1
  88. package/dist/core/tree/mapTree.js +1 -2
  89. package/dist/core/tree/mapTree.js.map +1 -1
  90. package/dist/core/tree/pathTree.js +7 -8
  91. package/dist/core/tree/pathTree.js.map +1 -1
  92. package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
  93. package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  94. package/dist/core/tree/sparseTree.js +17 -13
  95. package/dist/core/tree/sparseTree.js.map +1 -1
  96. package/dist/core/tree/treeTextFormat.js +4 -5
  97. package/dist/core/tree/treeTextFormat.js.map +1 -1
  98. package/dist/core/tree/types.js +3 -3
  99. package/dist/core/tree/types.js.map +1 -1
  100. package/dist/core/tree/visitDelta.js +1 -2
  101. package/dist/core/tree/visitDelta.js.map +1 -1
  102. package/dist/core/tree/visitorUtils.js +5 -6
  103. package/dist/core/tree/visitorUtils.js.map +1 -1
  104. package/dist/entrypoints/alpha.d.ts +1 -1
  105. package/dist/entrypoints/alpha.d.ts.map +1 -1
  106. package/dist/entrypoints/alpha.js +6 -4
  107. package/dist/entrypoints/alpha.js.map +1 -1
  108. package/dist/entrypoints/beta.d.ts +1 -1
  109. package/dist/entrypoints/beta.d.ts.map +1 -1
  110. package/dist/entrypoints/beta.js +2 -2
  111. package/dist/entrypoints/beta.js.map +1 -1
  112. package/dist/entrypoints/legacy.d.ts +1 -1
  113. package/dist/entrypoints/legacy.d.ts.map +1 -1
  114. package/dist/entrypoints/legacy.js +2 -2
  115. package/dist/entrypoints/legacy.js.map +1 -1
  116. package/dist/entrypoints/public.d.ts +1 -1
  117. package/dist/entrypoints/public.d.ts.map +1 -1
  118. package/dist/entrypoints/public.js +1 -2
  119. package/dist/entrypoints/public.js.map +1 -1
  120. package/dist/extensibleUnionNode.d.ts.map +1 -1
  121. package/dist/extensibleUnionNode.js +1 -1
  122. package/dist/extensibleUnionNode.js.map +1 -1
  123. package/dist/feature-libraries/changeAtomIdBTree.js +3 -4
  124. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
  125. package/dist/feature-libraries/changeAtomIdCodec.js +1 -2
  126. package/dist/feature-libraries/changeAtomIdCodec.js.map +1 -1
  127. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  128. package/dist/feature-libraries/chunked-forest/basicChunk.js +14 -1
  129. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  130. package/dist/feature-libraries/chunked-forest/chunkTree.js +28 -20
  131. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  132. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  133. package/dist/feature-libraries/chunked-forest/chunkedForest.js +22 -16
  134. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  135. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js +9 -11
  136. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  137. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +15 -7
  138. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  139. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +7 -3
  140. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  141. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +3 -2
  142. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  143. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  144. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -0
  145. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  146. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +33 -17
  147. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  148. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +2 -2
  149. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
  150. package/dist/feature-libraries/chunked-forest/codec/format/versions.js +2 -2
  151. package/dist/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
  152. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +11 -2
  153. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  154. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +5 -6
  155. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  156. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -3
  157. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  158. package/dist/feature-libraries/chunked-forest/sequenceChunk.js +1 -0
  159. package/dist/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  160. package/dist/feature-libraries/chunked-forest/uniformChunk.js +73 -15
  161. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  162. package/dist/feature-libraries/comparison-forest/comparisonForest.js +79 -79
  163. package/dist/feature-libraries/comparison-forest/comparisonForest.js.map +1 -1
  164. package/dist/feature-libraries/cursorComparator.d.ts +8 -0
  165. package/dist/feature-libraries/cursorComparator.d.ts.map +1 -1
  166. package/dist/feature-libraries/cursorComparator.js +43 -10
  167. package/dist/feature-libraries/cursorComparator.js.map +1 -1
  168. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +6 -3
  169. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  170. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +2 -2
  171. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  172. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +2 -0
  173. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  174. package/dist/feature-libraries/deltaUtils.js +2 -3
  175. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  176. package/dist/feature-libraries/detachedFieldIndexSummarizer.js +2 -0
  177. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  178. package/dist/feature-libraries/editableTreeBinder.js +1 -2
  179. package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
  180. package/dist/feature-libraries/flex-tree/context.js +19 -3
  181. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  182. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +2 -2
  183. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  184. package/dist/feature-libraries/flex-tree/lazyEntity.js +14 -14
  185. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  186. package/dist/feature-libraries/flex-tree/lazyField.js +28 -30
  187. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  188. package/dist/feature-libraries/flex-tree/lazyNode.js +24 -23
  189. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  190. package/dist/feature-libraries/flex-tree/observer.js +2 -2
  191. package/dist/feature-libraries/flex-tree/observer.js.map +1 -1
  192. package/dist/feature-libraries/flex-tree/utilities.js +5 -5
  193. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  194. package/dist/feature-libraries/forest-summary/forestSummarizer.js +122 -117
  195. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  196. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +49 -32
  197. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  198. package/dist/feature-libraries/forest-summary/summaryTypes.js +2 -3
  199. package/dist/feature-libraries/forest-summary/summaryTypes.js.map +1 -1
  200. package/dist/feature-libraries/indexing/anchorTreeIndex.js +35 -31
  201. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  202. package/dist/feature-libraries/mapTreeCursor.js +6 -7
  203. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  204. package/dist/feature-libraries/mitigatedChangeFamily.js +2 -3
  205. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  206. package/dist/feature-libraries/modular-schema/comparison.js +6 -7
  207. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  208. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +4 -4
  209. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  210. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +14 -12
  211. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  212. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +63 -10
  213. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  214. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +3 -3
  215. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  216. package/dist/feature-libraries/modular-schema/fieldKind.js +10 -0
  217. package/dist/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  218. package/dist/feature-libraries/modular-schema/filterEdits.d.ts +13 -0
  219. package/dist/feature-libraries/modular-schema/filterEdits.d.ts.map +1 -0
  220. package/dist/feature-libraries/modular-schema/filterEdits.js +51 -0
  221. package/dist/feature-libraries/modular-schema/filterEdits.js.map +1 -0
  222. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  223. package/dist/feature-libraries/modular-schema/genericFieldKind.js +7 -4
  224. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  225. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +1 -2
  226. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  227. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +2 -2
  228. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
  229. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.js +1 -2
  230. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.js.map +1 -1
  231. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  232. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  233. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  234. package/dist/feature-libraries/modular-schema/invert.d.ts +1 -1
  235. package/dist/feature-libraries/modular-schema/invert.d.ts.map +1 -1
  236. package/dist/feature-libraries/modular-schema/invert.js +5 -30
  237. package/dist/feature-libraries/modular-schema/invert.js.map +1 -1
  238. package/dist/feature-libraries/modular-schema/isNeverTree.js +4 -5
  239. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  240. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +5 -7
  241. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
  242. package/dist/feature-libraries/modular-schema/minimizeModularChange.js +459 -10
  243. package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
  244. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +14 -15
  245. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  246. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -2
  247. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  248. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +2 -2
  249. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  250. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -10
  251. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  252. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +30 -97
  253. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  254. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +9 -9
  255. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  256. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +4 -4
  257. package/dist/feature-libraries/modular-schema/modularChangeTypes.js +1 -2
  258. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  259. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts +13 -1
  260. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -1
  261. package/dist/feature-libraries/modular-schema/modularChangeUtils.js +115 -12
  262. package/dist/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -1
  263. package/dist/feature-libraries/modular-schema/prune.d.ts +2 -3
  264. package/dist/feature-libraries/modular-schema/prune.d.ts.map +1 -1
  265. package/dist/feature-libraries/modular-schema/prune.js +25 -8
  266. package/dist/feature-libraries/modular-schema/prune.js.map +1 -1
  267. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -3
  268. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  269. package/dist/feature-libraries/node-identifier/nodeIdentifier.js +2 -2
  270. package/dist/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -1
  271. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +3 -3
  272. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  273. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  274. package/dist/feature-libraries/object-forest/objectForest.js +274 -267
  275. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  276. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  277. package/dist/feature-libraries/optional-field/optionalField.js +27 -35
  278. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  279. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +7 -7
  280. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  281. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +8 -8
  282. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  283. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js +1 -2
  284. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  285. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  286. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +1 -2
  287. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  288. package/dist/feature-libraries/schema-index/schemaSummarizer.js +3 -0
  289. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  290. package/dist/feature-libraries/schemaChecker.js +5 -5
  291. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  292. package/dist/feature-libraries/sequence-field/compose.js +8 -2
  293. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  294. package/dist/feature-libraries/sequence-field/filterEdits.d.ts +3 -3
  295. package/dist/feature-libraries/sequence-field/filterEdits.d.ts.map +1 -1
  296. package/dist/feature-libraries/sequence-field/filterEdits.js +29 -11
  297. package/dist/feature-libraries/sequence-field/filterEdits.js.map +1 -1
  298. package/dist/feature-libraries/sequence-field/formatV1.d.ts +102 -102
  299. package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  300. package/dist/feature-libraries/sequence-field/formatV2.d.ts +79 -79
  301. package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  302. package/dist/feature-libraries/sequence-field/formatV3.d.ts +56 -56
  303. package/dist/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
  304. package/dist/feature-libraries/sequence-field/invert.js +1 -2
  305. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  306. package/dist/feature-libraries/sequence-field/markListFactory.js +3 -4
  307. package/dist/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  308. package/dist/feature-libraries/sequence-field/markQueue.js +4 -2
  309. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  310. package/dist/feature-libraries/sequence-field/moveEffectTable.js +9 -9
  311. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  312. package/dist/feature-libraries/sequence-field/prune.js +1 -2
  313. package/dist/feature-libraries/sequence-field/prune.js.map +1 -1
  314. package/dist/feature-libraries/sequence-field/rebase.js +7 -2
  315. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  316. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +1 -2
  317. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
  318. package/dist/feature-libraries/sequence-field/replaceRevisions.js +1 -2
  319. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  320. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +2 -3
  321. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  322. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +1 -2
  323. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  324. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  325. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +9 -9
  326. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  327. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -2
  328. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  329. package/dist/feature-libraries/sequence-field/utils.d.ts +2 -2
  330. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  331. package/dist/feature-libraries/sequence-field/utils.js +54 -67
  332. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  333. package/dist/feature-libraries/treeCursorUtils.js +19 -15
  334. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  335. package/dist/feature-libraries/treeTextCursor.js +8 -8
  336. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  337. package/dist/feature-libraries/valueUtilities.js +4 -5
  338. package/dist/feature-libraries/valueUtilities.js.map +1 -1
  339. package/dist/index.d.ts +4 -29
  340. package/dist/index.d.ts.map +1 -1
  341. package/dist/index.js +6 -9
  342. package/dist/index.js.map +1 -1
  343. package/dist/internalTypes.d.ts +1 -1
  344. package/dist/internalTypes.d.ts.map +1 -1
  345. package/dist/internalTypes.js.map +1 -1
  346. package/dist/packageVersion.d.ts +1 -1
  347. package/dist/packageVersion.d.ts.map +1 -1
  348. package/dist/packageVersion.js +1 -1
  349. package/dist/packageVersion.js.map +1 -1
  350. package/dist/serializableDomainSchema.d.ts +1 -1
  351. package/dist/shared-tree/history.d.ts.map +1 -1
  352. package/dist/shared-tree/history.js +32 -13
  353. package/dist/shared-tree/history.js.map +1 -1
  354. package/dist/shared-tree/independentView.d.ts +27 -3
  355. package/dist/shared-tree/independentView.d.ts.map +1 -1
  356. package/dist/shared-tree/independentView.js +36 -7
  357. package/dist/shared-tree/independentView.js.map +1 -1
  358. package/dist/shared-tree/index.d.ts +2 -1
  359. package/dist/shared-tree/index.d.ts.map +1 -1
  360. package/dist/shared-tree/index.js +6 -2
  361. package/dist/shared-tree/index.js.map +1 -1
  362. package/dist/shared-tree/isAuditableFromOutcome.js +1 -2
  363. package/dist/shared-tree/isAuditableFromOutcome.js.map +1 -1
  364. package/dist/shared-tree/schematizeTree.js +3 -4
  365. package/dist/shared-tree/schematizeTree.js.map +1 -1
  366. package/dist/shared-tree/schematizingTreeView.d.ts +2 -2
  367. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  368. package/dist/shared-tree/schematizingTreeView.js +59 -26
  369. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  370. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  371. package/dist/shared-tree/sharedTree.js +28 -19
  372. package/dist/shared-tree/sharedTree.js.map +1 -1
  373. package/dist/shared-tree/sharedTreeChangeCodecs.js +3 -3
  374. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  375. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  376. package/dist/shared-tree/sharedTreeChangeEnricher.js +12 -4
  377. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  378. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  379. package/dist/shared-tree/sharedTreeChangeFamily.js +11 -8
  380. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  381. package/dist/shared-tree/sharedTreeChangeFormat.js +2 -3
  382. package/dist/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  383. package/dist/shared-tree/sharedTreeEditBuilder.js +2 -0
  384. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  385. package/dist/shared-tree/transactionMinimize.d.ts.map +1 -1
  386. package/dist/shared-tree/transactionMinimize.js +2 -1
  387. package/dist/shared-tree/transactionMinimize.js.map +1 -1
  388. package/dist/shared-tree/transactionPostProcessor.js +2 -3
  389. package/dist/shared-tree/transactionPostProcessor.js.map +1 -1
  390. package/dist/shared-tree/tree.js +2 -2
  391. package/dist/shared-tree/tree.js.map +1 -1
  392. package/dist/shared-tree/treeAlpha.d.ts +5 -16
  393. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  394. package/dist/shared-tree/treeAlpha.js +18 -11
  395. package/dist/shared-tree/treeAlpha.js.map +1 -1
  396. package/{lib/simple-tree/api → dist/shared-tree}/treeBeta.d.ts +8 -65
  397. package/dist/shared-tree/treeBeta.d.ts.map +1 -0
  398. package/dist/shared-tree/treeBeta.js +70 -0
  399. package/dist/shared-tree/treeBeta.js.map +1 -0
  400. package/dist/shared-tree/treeCheckout.d.ts +5 -0
  401. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  402. package/dist/shared-tree/treeCheckout.js +986 -907
  403. package/dist/shared-tree/treeCheckout.js.map +1 -1
  404. package/dist/shared-tree/unhydratedTreeContext.js +3 -4
  405. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  406. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  407. package/dist/shared-tree-core/branch.js +24 -20
  408. package/dist/shared-tree-core/branch.js.map +1 -1
  409. package/dist/shared-tree-core/branchCommitCounter.js +35 -32
  410. package/dist/shared-tree-core/branchCommitCounter.js.map +1 -1
  411. package/dist/shared-tree-core/branchCommitEnricher.js +9 -8
  412. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  413. package/dist/shared-tree-core/branchIdCodec.js +2 -3
  414. package/dist/shared-tree-core/branchIdCodec.js.map +1 -1
  415. package/dist/shared-tree-core/customMetadataCodec.js +2 -3
  416. package/dist/shared-tree-core/customMetadataCodec.js.map +1 -1
  417. package/dist/shared-tree-core/customMetadataFormat.d.ts.map +1 -1
  418. package/dist/shared-tree-core/defaultResubmitMachine.js +11 -9
  419. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  420. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  421. package/dist/shared-tree-core/editManager.js +73 -44
  422. package/dist/shared-tree-core/editManager.js.map +1 -1
  423. package/dist/shared-tree-core/editManagerCodecs.js +3 -3
  424. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  425. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  426. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  427. package/dist/shared-tree-core/editManagerCodecsCommons.js +33 -36
  428. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  429. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +1 -2
  430. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  431. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -2
  432. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  433. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +11 -11
  434. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  435. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +5 -4
  436. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  437. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +10 -9
  438. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  439. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  440. package/dist/shared-tree-core/editManagerSummarizer.js +6 -1
  441. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  442. package/dist/shared-tree-core/messageCodecV1ToV4.js +1 -2
  443. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  444. package/dist/shared-tree-core/messageCodecVSharedBranches.js +1 -2
  445. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  446. package/dist/shared-tree-core/messageCodecs.js +3 -3
  447. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  448. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
  449. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  450. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +3 -2
  451. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  452. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  453. package/dist/shared-tree-core/sharedTreeCore.js +44 -22
  454. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  455. package/dist/shared-tree-core/summaryTypes.js +2 -2
  456. package/dist/shared-tree-core/summaryTypes.js.map +1 -1
  457. package/dist/shared-tree-core/transaction.js +36 -39
  458. package/dist/shared-tree-core/transaction.js.map +1 -1
  459. package/dist/shared-tree-core/versionedSummarizer.js +4 -0
  460. package/dist/shared-tree-core/versionedSummarizer.js.map +1 -1
  461. package/dist/simple-tree/api/cloneTree.d.ts +11 -0
  462. package/dist/simple-tree/api/cloneTree.d.ts.map +1 -0
  463. package/dist/simple-tree/api/cloneTree.js +31 -0
  464. package/dist/simple-tree/api/cloneTree.js.map +1 -0
  465. package/dist/simple-tree/api/conciseTree.js +2 -3
  466. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  467. package/dist/simple-tree/api/configuration.js +21 -2
  468. package/dist/simple-tree/api/configuration.js.map +1 -1
  469. package/dist/simple-tree/api/create.js +2 -3
  470. package/dist/simple-tree/api/create.js.map +1 -1
  471. package/dist/simple-tree/api/customTree.js +6 -6
  472. package/dist/simple-tree/api/customTree.js.map +1 -1
  473. package/dist/simple-tree/api/dirtyIndex.js +1 -2
  474. package/dist/simple-tree/api/dirtyIndex.js.map +1 -1
  475. package/dist/simple-tree/api/discrepancies.js +2 -3
  476. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  477. package/dist/simple-tree/api/eraseSchemaDetails.js +2 -3
  478. package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -1
  479. package/dist/simple-tree/api/getJsonSchema.js +1 -2
  480. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  481. package/dist/simple-tree/api/getSimpleSchema.js +1 -2
  482. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  483. package/dist/simple-tree/api/identifierIndex.js +1 -2
  484. package/dist/simple-tree/api/identifierIndex.js.map +1 -1
  485. package/dist/simple-tree/api/incrementalAllowedTypes.js +2 -2
  486. package/dist/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  487. package/dist/simple-tree/api/index.d.ts +3 -3
  488. package/dist/simple-tree/api/index.d.ts.map +1 -1
  489. package/dist/simple-tree/api/index.js +4 -7
  490. package/dist/simple-tree/api/index.js.map +1 -1
  491. package/dist/simple-tree/api/schemaCompatibilityTester.js +2 -3
  492. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  493. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -7
  494. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  495. package/dist/simple-tree/api/schemaCreationUtilities.js +6 -9
  496. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  497. package/dist/simple-tree/api/schemaFactory.d.ts +4 -9
  498. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  499. package/dist/simple-tree/api/schemaFactory.js +13 -12
  500. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  501. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +20 -22
  502. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  503. package/dist/simple-tree/api/schemaFactoryAlpha.js +78 -81
  504. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  505. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +7 -9
  506. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  507. package/dist/simple-tree/api/schemaFactoryBeta.js +32 -35
  508. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  509. package/dist/simple-tree/api/schemaFactoryRecursive.js +1 -2
  510. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  511. package/dist/simple-tree/api/schemaFromSimple.js +1 -2
  512. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  513. package/dist/simple-tree/api/schemaStatics.d.ts +7 -7
  514. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
  515. package/dist/simple-tree/api/simpleSchemaCodec.js +2 -3
  516. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  517. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +2 -3
  518. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  519. package/dist/simple-tree/api/simpleTreeIndex.js +1 -2
  520. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  521. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +46 -2
  522. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  523. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +54 -12
  524. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  525. package/dist/simple-tree/api/storedSchema.js +2 -3
  526. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  527. package/dist/simple-tree/api/transactionTypes.d.ts +4 -4
  528. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  529. package/dist/simple-tree/api/tree.d.ts +80 -61
  530. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  531. package/dist/simple-tree/api/tree.js +3 -5
  532. package/dist/simple-tree/api/tree.js.map +1 -1
  533. package/dist/simple-tree/api/treeChangeEvents.d.ts +16 -4
  534. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  535. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
  536. package/dist/simple-tree/api/treeChangeEventsBeta.d.ts +209 -0
  537. package/dist/simple-tree/api/treeChangeEventsBeta.d.ts.map +1 -0
  538. package/dist/simple-tree/api/{treeAlpha.js → treeChangeEventsBeta.js} +1 -1
  539. package/dist/simple-tree/api/treeChangeEventsBeta.js.map +1 -0
  540. package/dist/simple-tree/api/treeNodeApi.d.ts +1 -75
  541. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  542. package/dist/simple-tree/api/treeNodeApi.js +7 -7
  543. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  544. package/dist/simple-tree/api/typesUnsafe.d.ts +8 -6
  545. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  546. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  547. package/dist/simple-tree/api/verboseTree.js +5 -6
  548. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  549. package/dist/simple-tree/core/allowedTypes.js +22 -13
  550. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  551. package/dist/simple-tree/core/context.js +3 -0
  552. package/dist/simple-tree/core/context.js.map +1 -1
  553. package/dist/simple-tree/core/flexList.js +2 -3
  554. package/dist/simple-tree/core/flexList.js.map +1 -1
  555. package/dist/simple-tree/core/getOrCreateNode.js +2 -3
  556. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  557. package/dist/simple-tree/core/index.d.ts +1 -1
  558. package/dist/simple-tree/core/index.d.ts.map +1 -1
  559. package/dist/simple-tree/core/index.js +2 -2
  560. package/dist/simple-tree/core/index.js.map +1 -1
  561. package/dist/simple-tree/core/treeNode.d.ts +3 -4
  562. package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
  563. package/dist/simple-tree/core/treeNode.js +31 -32
  564. package/dist/simple-tree/core/treeNode.js.map +1 -1
  565. package/dist/simple-tree/core/treeNodeKernel.js +194 -192
  566. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  567. package/dist/simple-tree/core/treeNodeSchema.js +3 -3
  568. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  569. package/dist/simple-tree/core/treeNodeValid.js +23 -23
  570. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  571. package/dist/simple-tree/core/types.js +1 -2
  572. package/dist/simple-tree/core/types.js.map +1 -1
  573. package/dist/simple-tree/core/unhydratedFlexTree.js +177 -150
  574. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  575. package/dist/simple-tree/core/walkSchema.js +2 -3
  576. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  577. package/dist/simple-tree/core/withType.d.ts +7 -9
  578. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  579. package/dist/simple-tree/core/withType.js +6 -7
  580. package/dist/simple-tree/core/withType.js.map +1 -1
  581. package/dist/simple-tree/createContext.js +2 -3
  582. package/dist/simple-tree/createContext.js.map +1 -1
  583. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  584. package/dist/simple-tree/fieldSchema.js +33 -15
  585. package/dist/simple-tree/fieldSchema.js.map +1 -1
  586. package/dist/simple-tree/getTreeNodeForField.js +1 -2
  587. package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
  588. package/dist/simple-tree/index.d.ts +2 -2
  589. package/dist/simple-tree/index.d.ts.map +1 -1
  590. package/dist/simple-tree/index.js +5 -8
  591. package/dist/simple-tree/index.js.map +1 -1
  592. package/dist/simple-tree/leafNodeSchema.d.ts +1 -1
  593. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  594. package/dist/simple-tree/leafNodeSchema.js +18 -17
  595. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  596. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -2
  597. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  598. package/dist/simple-tree/node-kinds/array/arrayNode.js +31 -33
  599. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  600. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  601. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js +2 -2
  602. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  603. package/dist/simple-tree/node-kinds/common.js +1 -2
  604. package/dist/simple-tree/node-kinds/common.js.map +1 -1
  605. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +6 -6
  606. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  607. package/dist/simple-tree/node-kinds/map/mapNode.js +10 -16
  608. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  609. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  610. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js +2 -2
  611. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  612. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  613. package/dist/simple-tree/node-kinds/object/objectNode.js +27 -28
  614. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  615. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +1 -1
  616. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  617. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js +2 -2
  618. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  619. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  620. package/dist/simple-tree/node-kinds/record/recordNode.js +10 -13
  621. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  622. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -2
  623. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  624. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js +2 -2
  625. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  626. package/dist/simple-tree/prepareForInsertion.js +4 -5
  627. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  628. package/dist/simple-tree/toStoredSchema.js +11 -11
  629. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  630. package/dist/simple-tree/treeSchema.js +1 -2
  631. package/dist/simple-tree/treeSchema.js.map +1 -1
  632. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +3 -4
  633. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  634. package/dist/simple-tree/walkFieldSchema.js +1 -2
  635. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  636. package/dist/tableSchema.d.ts +2 -87
  637. package/dist/tableSchema.d.ts.map +1 -1
  638. package/dist/tableSchema.js +309 -275
  639. package/dist/tableSchema.js.map +1 -1
  640. package/dist/text/codePointUtils.d.ts +16 -3
  641. package/dist/text/codePointUtils.d.ts.map +1 -1
  642. package/dist/text/codePointUtils.js +24 -13
  643. package/dist/text/codePointUtils.js.map +1 -1
  644. package/dist/text/textDomain.d.ts +7 -1
  645. package/dist/text/textDomain.d.ts.map +1 -1
  646. package/dist/text/textDomain.js +32 -28
  647. package/dist/text/textDomain.js.map +1 -1
  648. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  649. package/dist/text/textDomainFormatted.js +45 -34
  650. package/dist/text/textDomainFormatted.js.map +1 -1
  651. package/dist/text/textDomainFormattedDefault.js +2 -5
  652. package/dist/text/textDomainFormattedDefault.js.map +1 -1
  653. package/dist/treeDataStore.js +2 -3
  654. package/dist/treeDataStore.js.map +1 -1
  655. package/dist/treeFactory.js +7 -7
  656. package/dist/treeFactory.js.map +1 -1
  657. package/dist/util/arrayUtilities.js +5 -6
  658. package/dist/util/arrayUtilities.js.map +1 -1
  659. package/dist/util/bTreeUtils.js +3 -4
  660. package/dist/util/bTreeUtils.js.map +1 -1
  661. package/dist/util/brand.js +6 -5
  662. package/dist/util/brand.js.map +1 -1
  663. package/dist/util/brandedMap.js +2 -3
  664. package/dist/util/brandedMap.js.map +1 -1
  665. package/dist/util/breakable.d.ts.map +1 -1
  666. package/dist/util/breakable.js +7 -4
  667. package/dist/util/breakable.js.map +1 -1
  668. package/dist/util/cloneWithReplacements.js +1 -2
  669. package/dist/util/cloneWithReplacements.js.map +1 -1
  670. package/dist/util/compressedIds.js +29 -7
  671. package/dist/util/compressedIds.js.map +1 -1
  672. package/dist/util/idAllocator.js +3 -3
  673. package/dist/util/idAllocator.js.map +1 -1
  674. package/dist/util/nestedMap.js +15 -17
  675. package/dist/util/nestedMap.js.map +1 -1
  676. package/dist/util/nestedSet.js +2 -3
  677. package/dist/util/nestedSet.js.map +1 -1
  678. package/dist/util/offsetList.js +2 -4
  679. package/dist/util/offsetList.js.map +1 -1
  680. package/dist/util/opaque.js +2 -3
  681. package/dist/util/opaque.js.map +1 -1
  682. package/dist/util/rangeMap.js +6 -2
  683. package/dist/util/rangeMap.js.map +1 -1
  684. package/dist/util/readSnapshotBlob.d.ts.map +1 -1
  685. package/dist/util/referenceCounting.js +1 -0
  686. package/dist/util/referenceCounting.js.map +1 -1
  687. package/dist/util/stackyIterator.js +3 -2
  688. package/dist/util/stackyIterator.js.map +1 -1
  689. package/dist/util/typeUtils.js +1 -2
  690. package/dist/util/typeUtils.js.map +1 -1
  691. package/dist/util/typeboxBrand.js +2 -3
  692. package/dist/util/typeboxBrand.js.map +1 -1
  693. package/dist/util/utils.d.ts +2 -2
  694. package/dist/util/utils.d.ts.map +1 -1
  695. package/dist/util/utils.js +32 -32
  696. package/dist/util/utils.js.map +1 -1
  697. package/lib/api.d.ts +9 -1
  698. package/lib/api.d.ts.map +1 -1
  699. package/lib/api.js.map +1 -1
  700. package/lib/codec/codec.d.ts +2 -2
  701. package/lib/codec/codec.d.ts.map +1 -1
  702. package/lib/codec/codec.js +2 -0
  703. package/lib/codec/codec.js.map +1 -1
  704. package/lib/codec/discriminatedUnions.js +1 -0
  705. package/lib/codec/discriminatedUnions.js.map +1 -1
  706. package/lib/codec/versioned/codec.d.ts.map +1 -1
  707. package/lib/codec/versioned/codec.js +2 -0
  708. package/lib/codec/versioned/codec.js.map +1 -1
  709. package/lib/componentApi.d.ts.map +1 -1
  710. package/lib/componentApi.js +20 -17
  711. package/lib/componentApi.js.map +1 -1
  712. package/lib/core/change-family/editBuilder.js +1 -0
  713. package/lib/core/change-family/editBuilder.js.map +1 -1
  714. package/lib/core/index.d.ts +2 -2
  715. package/lib/core/index.d.ts.map +1 -1
  716. package/lib/core/index.js +2 -2
  717. package/lib/core/index.js.map +1 -1
  718. package/lib/core/rebase/index.d.ts +1 -1
  719. package/lib/core/rebase/index.d.ts.map +1 -1
  720. package/lib/core/rebase/index.js +1 -1
  721. package/lib/core/rebase/index.js.map +1 -1
  722. package/lib/core/rebase/revisionTagCodec.js +3 -1
  723. package/lib/core/rebase/revisionTagCodec.js.map +1 -1
  724. package/lib/core/rebase/types.d.ts +12 -1
  725. package/lib/core/rebase/types.d.ts.map +1 -1
  726. package/lib/core/rebase/types.js +3 -0
  727. package/lib/core/rebase/types.js.map +1 -1
  728. package/lib/core/schema-stored/schema.js +5 -0
  729. package/lib/core/schema-stored/schema.js.map +1 -1
  730. package/lib/core/schema-stored/storedSchemaRepository.js +4 -2
  731. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  732. package/lib/core/tree/anchorSet.js +61 -54
  733. package/lib/core/tree/anchorSet.js.map +1 -1
  734. package/lib/core/tree/deltaUtil.d.ts +34 -9
  735. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  736. package/lib/core/tree/deltaUtil.js +41 -10
  737. package/lib/core/tree/deltaUtil.js.map +1 -1
  738. package/lib/core/tree/detachedFieldIndex.js +23 -21
  739. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  740. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +10 -10
  741. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  742. package/lib/core/tree/detachedFieldIndexCodecV1.js +2 -0
  743. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  744. package/lib/core/tree/detachedFieldIndexCodecV2.js +2 -0
  745. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  746. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +3 -3
  747. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  748. package/lib/core/tree/index.d.ts +1 -1
  749. package/lib/core/tree/index.d.ts.map +1 -1
  750. package/lib/core/tree/index.js +1 -1
  751. package/lib/core/tree/index.js.map +1 -1
  752. package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
  753. package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  754. package/lib/core/tree/sparseTree.js +15 -11
  755. package/lib/core/tree/sparseTree.js.map +1 -1
  756. package/lib/entrypoints/alpha.d.ts +1 -1
  757. package/lib/entrypoints/alpha.d.ts.map +1 -1
  758. package/lib/entrypoints/alpha.js +1 -1
  759. package/lib/entrypoints/alpha.js.map +1 -1
  760. package/lib/entrypoints/beta.d.ts +1 -1
  761. package/lib/entrypoints/beta.d.ts.map +1 -1
  762. package/lib/entrypoints/beta.js +1 -1
  763. package/lib/entrypoints/beta.js.map +1 -1
  764. package/lib/entrypoints/legacy.d.ts +1 -1
  765. package/lib/entrypoints/legacy.d.ts.map +1 -1
  766. package/lib/entrypoints/legacy.js +1 -1
  767. package/lib/entrypoints/legacy.js.map +1 -1
  768. package/lib/entrypoints/public.d.ts +1 -1
  769. package/lib/entrypoints/public.d.ts.map +1 -1
  770. package/lib/entrypoints/public.js +1 -1
  771. package/lib/entrypoints/public.js.map +1 -1
  772. package/lib/extensibleUnionNode.d.ts.map +1 -1
  773. package/lib/extensibleUnionNode.js +2 -2
  774. package/lib/extensibleUnionNode.js.map +1 -1
  775. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  776. package/lib/feature-libraries/chunked-forest/basicChunk.js +14 -1
  777. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  778. package/lib/feature-libraries/chunked-forest/chunkTree.js +14 -6
  779. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  780. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  781. package/lib/feature-libraries/chunked-forest/chunkedForest.js +18 -12
  782. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  783. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js +1 -3
  784. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  785. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +8 -0
  786. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  787. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -0
  788. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  789. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +1 -0
  790. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  791. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  792. package/lib/feature-libraries/chunked-forest/codec/codecs.js +2 -0
  793. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  794. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +28 -12
  795. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  796. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +2 -2
  797. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
  798. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +9 -0
  799. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  800. package/lib/feature-libraries/chunked-forest/sequenceChunk.js +1 -0
  801. package/lib/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  802. package/lib/feature-libraries/chunked-forest/uniformChunk.js +71 -13
  803. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  804. package/lib/feature-libraries/comparison-forest/comparisonForest.js +79 -79
  805. package/lib/feature-libraries/comparison-forest/comparisonForest.js.map +1 -1
  806. package/lib/feature-libraries/cursorComparator.d.ts +8 -0
  807. package/lib/feature-libraries/cursorComparator.d.ts.map +1 -1
  808. package/lib/feature-libraries/cursorComparator.js +43 -9
  809. package/lib/feature-libraries/cursorComparator.js.map +1 -1
  810. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
  811. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  812. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +2 -0
  813. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  814. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +2 -0
  815. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  816. package/lib/feature-libraries/flex-tree/context.js +19 -3
  817. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  818. package/lib/feature-libraries/flex-tree/lazyEntity.js +12 -12
  819. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  820. package/lib/feature-libraries/flex-tree/lazyField.js +25 -27
  821. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  822. package/lib/feature-libraries/flex-tree/lazyNode.js +22 -21
  823. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  824. package/lib/feature-libraries/forest-summary/forestSummarizer.js +122 -117
  825. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  826. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +49 -32
  827. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  828. package/lib/feature-libraries/indexing/anchorTreeIndex.js +33 -29
  829. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  830. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +14 -12
  831. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  832. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +63 -10
  833. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  834. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  835. package/lib/feature-libraries/modular-schema/fieldKind.js +10 -0
  836. package/lib/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  837. package/lib/feature-libraries/modular-schema/filterEdits.d.ts +13 -0
  838. package/lib/feature-libraries/modular-schema/filterEdits.d.ts.map +1 -0
  839. package/lib/feature-libraries/modular-schema/filterEdits.js +46 -0
  840. package/lib/feature-libraries/modular-schema/filterEdits.js.map +1 -0
  841. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  842. package/lib/feature-libraries/modular-schema/genericFieldKind.js +5 -2
  843. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  844. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +2 -2
  845. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
  846. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  847. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  848. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  849. package/lib/feature-libraries/modular-schema/invert.d.ts +1 -1
  850. package/lib/feature-libraries/modular-schema/invert.d.ts.map +1 -1
  851. package/lib/feature-libraries/modular-schema/invert.js +6 -30
  852. package/lib/feature-libraries/modular-schema/invert.js.map +1 -1
  853. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +5 -7
  854. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
  855. package/lib/feature-libraries/modular-schema/minimizeModularChange.js +458 -8
  856. package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
  857. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -10
  858. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  859. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +20 -85
  860. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  861. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts +13 -1
  862. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -1
  863. package/lib/feature-libraries/modular-schema/modularChangeUtils.js +100 -3
  864. package/lib/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -1
  865. package/lib/feature-libraries/modular-schema/prune.d.ts +2 -3
  866. package/lib/feature-libraries/modular-schema/prune.d.ts.map +1 -1
  867. package/lib/feature-libraries/modular-schema/prune.js +25 -7
  868. package/lib/feature-libraries/modular-schema/prune.js.map +1 -1
  869. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -3
  870. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  871. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +1 -0
  872. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  873. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  874. package/lib/feature-libraries/object-forest/objectForest.js +273 -266
  875. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  876. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  877. package/lib/feature-libraries/optional-field/optionalField.js +24 -32
  878. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  879. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +1 -1
  880. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  881. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +1 -1
  882. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  883. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  884. package/lib/feature-libraries/schema-index/schemaSummarizer.js +3 -0
  885. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  886. package/lib/feature-libraries/sequence-field/compose.js +6 -0
  887. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  888. package/lib/feature-libraries/sequence-field/filterEdits.d.ts +3 -3
  889. package/lib/feature-libraries/sequence-field/filterEdits.d.ts.map +1 -1
  890. package/lib/feature-libraries/sequence-field/filterEdits.js +31 -12
  891. package/lib/feature-libraries/sequence-field/filterEdits.js.map +1 -1
  892. package/lib/feature-libraries/sequence-field/formatV1.d.ts +3 -3
  893. package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  894. package/lib/feature-libraries/sequence-field/formatV2.d.ts +3 -3
  895. package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  896. package/lib/feature-libraries/sequence-field/formatV3.d.ts +2 -2
  897. package/lib/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
  898. package/lib/feature-libraries/sequence-field/markListFactory.js +3 -4
  899. package/lib/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  900. package/lib/feature-libraries/sequence-field/markQueue.js +4 -2
  901. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  902. package/lib/feature-libraries/sequence-field/rebase.js +6 -0
  903. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  904. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  905. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +9 -9
  906. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  907. package/lib/feature-libraries/sequence-field/utils.d.ts +2 -2
  908. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  909. package/lib/feature-libraries/sequence-field/utils.js +3 -15
  910. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  911. package/lib/feature-libraries/treeCursorUtils.js +13 -9
  912. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  913. package/lib/index.d.ts +4 -29
  914. package/lib/index.d.ts.map +1 -1
  915. package/lib/index.js +2 -17
  916. package/lib/index.js.map +1 -1
  917. package/lib/internalTypes.d.ts +1 -1
  918. package/lib/internalTypes.d.ts.map +1 -1
  919. package/lib/internalTypes.js.map +1 -1
  920. package/lib/packageVersion.d.ts +1 -1
  921. package/lib/packageVersion.d.ts.map +1 -1
  922. package/lib/packageVersion.js +1 -1
  923. package/lib/packageVersion.js.map +1 -1
  924. package/lib/serializableDomainSchema.d.ts +1 -1
  925. package/lib/shared-tree/history.d.ts.map +1 -1
  926. package/lib/shared-tree/history.js +32 -13
  927. package/lib/shared-tree/history.js.map +1 -1
  928. package/lib/shared-tree/independentView.d.ts +27 -3
  929. package/lib/shared-tree/independentView.d.ts.map +1 -1
  930. package/lib/shared-tree/independentView.js +30 -2
  931. package/lib/shared-tree/independentView.js.map +1 -1
  932. package/lib/shared-tree/index.d.ts +2 -1
  933. package/lib/shared-tree/index.d.ts.map +1 -1
  934. package/lib/shared-tree/index.js +2 -1
  935. package/lib/shared-tree/index.js.map +1 -1
  936. package/lib/shared-tree/schematizingTreeView.d.ts +2 -2
  937. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  938. package/lib/shared-tree/schematizingTreeView.js +60 -27
  939. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  940. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  941. package/lib/shared-tree/sharedTree.js +24 -15
  942. package/lib/shared-tree/sharedTree.js.map +1 -1
  943. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  944. package/lib/shared-tree/sharedTreeChangeEnricher.js +12 -4
  945. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  946. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  947. package/lib/shared-tree/sharedTreeChangeFamily.js +6 -3
  948. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  949. package/lib/shared-tree/sharedTreeEditBuilder.js +2 -0
  950. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  951. package/lib/shared-tree/transactionMinimize.d.ts.map +1 -1
  952. package/lib/shared-tree/transactionMinimize.js +4 -3
  953. package/lib/shared-tree/transactionMinimize.js.map +1 -1
  954. package/lib/shared-tree/treeAlpha.d.ts +5 -16
  955. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  956. package/lib/shared-tree/treeAlpha.js +13 -6
  957. package/lib/shared-tree/treeAlpha.js.map +1 -1
  958. package/{dist/simple-tree/api → lib/shared-tree}/treeBeta.d.ts +8 -65
  959. package/lib/shared-tree/treeBeta.d.ts.map +1 -0
  960. package/lib/shared-tree/treeBeta.js +64 -0
  961. package/lib/shared-tree/treeBeta.js.map +1 -0
  962. package/lib/shared-tree/treeCheckout.d.ts +5 -0
  963. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  964. package/lib/shared-tree/treeCheckout.js +985 -906
  965. package/lib/shared-tree/treeCheckout.js.map +1 -1
  966. package/lib/shared-tree/unhydratedTreeContext.js +3 -4
  967. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  968. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  969. package/lib/shared-tree-core/branch.js +22 -18
  970. package/lib/shared-tree-core/branch.js.map +1 -1
  971. package/lib/shared-tree-core/branchCommitCounter.js +35 -32
  972. package/lib/shared-tree-core/branchCommitCounter.js.map +1 -1
  973. package/lib/shared-tree-core/branchCommitEnricher.js +9 -8
  974. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  975. package/lib/shared-tree-core/customMetadataFormat.d.ts.map +1 -1
  976. package/lib/shared-tree-core/defaultResubmitMachine.js +11 -9
  977. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  978. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  979. package/lib/shared-tree-core/editManager.js +73 -44
  980. package/lib/shared-tree-core/editManager.js.map +1 -1
  981. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  982. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  983. package/lib/shared-tree-core/editManagerCodecsCommons.js +32 -34
  984. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  985. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  986. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  987. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +4 -4
  988. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  989. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -1
  990. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  991. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +2 -1
  992. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  993. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  994. package/lib/shared-tree-core/editManagerSummarizer.js +6 -1
  995. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  996. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +2 -1
  997. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  998. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +2 -1
  999. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  1000. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  1001. package/lib/shared-tree-core/sharedTreeCore.js +45 -23
  1002. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  1003. package/lib/shared-tree-core/transaction.js +36 -39
  1004. package/lib/shared-tree-core/transaction.js.map +1 -1
  1005. package/lib/shared-tree-core/versionedSummarizer.js +4 -0
  1006. package/lib/shared-tree-core/versionedSummarizer.js.map +1 -1
  1007. package/lib/simple-tree/api/cloneTree.d.ts +11 -0
  1008. package/lib/simple-tree/api/cloneTree.d.ts.map +1 -0
  1009. package/lib/simple-tree/api/cloneTree.js +28 -0
  1010. package/lib/simple-tree/api/cloneTree.js.map +1 -0
  1011. package/lib/simple-tree/api/configuration.js +19 -0
  1012. package/lib/simple-tree/api/configuration.js.map +1 -1
  1013. package/lib/simple-tree/api/index.d.ts +3 -3
  1014. package/lib/simple-tree/api/index.d.ts.map +1 -1
  1015. package/lib/simple-tree/api/index.js +1 -1
  1016. package/lib/simple-tree/api/index.js.map +1 -1
  1017. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -7
  1018. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  1019. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -3
  1020. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  1021. package/lib/simple-tree/api/schemaFactory.d.ts +4 -9
  1022. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  1023. package/lib/simple-tree/api/schemaFactory.js +9 -8
  1024. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  1025. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +18 -20
  1026. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  1027. package/lib/simple-tree/api/schemaFactoryAlpha.js +78 -81
  1028. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  1029. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +7 -9
  1030. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  1031. package/lib/simple-tree/api/schemaFactoryBeta.js +32 -35
  1032. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  1033. package/lib/simple-tree/api/schemaStatics.d.ts +7 -7
  1034. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
  1035. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +46 -2
  1036. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  1037. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +48 -6
  1038. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  1039. package/lib/simple-tree/api/transactionTypes.d.ts +4 -4
  1040. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  1041. package/lib/simple-tree/api/tree.d.ts +80 -61
  1042. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  1043. package/lib/simple-tree/api/tree.js +2 -3
  1044. package/lib/simple-tree/api/tree.js.map +1 -1
  1045. package/lib/simple-tree/api/treeChangeEvents.d.ts +16 -4
  1046. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  1047. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
  1048. package/lib/simple-tree/api/treeChangeEventsBeta.d.ts +209 -0
  1049. package/lib/simple-tree/api/treeChangeEventsBeta.d.ts.map +1 -0
  1050. package/lib/simple-tree/api/{treeAlpha.js → treeChangeEventsBeta.js} +1 -1
  1051. package/lib/simple-tree/api/treeChangeEventsBeta.js.map +1 -0
  1052. package/lib/simple-tree/api/treeNodeApi.d.ts +1 -75
  1053. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  1054. package/lib/simple-tree/api/treeNodeApi.js +1 -1
  1055. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  1056. package/lib/simple-tree/api/typesUnsafe.d.ts +8 -6
  1057. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  1058. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  1059. package/lib/simple-tree/core/allowedTypes.js +12 -3
  1060. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  1061. package/lib/simple-tree/core/context.js +3 -0
  1062. package/lib/simple-tree/core/context.js.map +1 -1
  1063. package/lib/simple-tree/core/index.d.ts +1 -1
  1064. package/lib/simple-tree/core/index.d.ts.map +1 -1
  1065. package/lib/simple-tree/core/index.js +1 -1
  1066. package/lib/simple-tree/core/index.js.map +1 -1
  1067. package/lib/simple-tree/core/treeNode.d.ts +3 -4
  1068. package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
  1069. package/lib/simple-tree/core/treeNode.js +29 -30
  1070. package/lib/simple-tree/core/treeNode.js.map +1 -1
  1071. package/lib/simple-tree/core/treeNodeKernel.js +181 -179
  1072. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  1073. package/lib/simple-tree/core/treeNodeValid.js +19 -19
  1074. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  1075. package/lib/simple-tree/core/unhydratedFlexTree.js +173 -146
  1076. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  1077. package/lib/simple-tree/core/withType.d.ts +7 -9
  1078. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  1079. package/lib/simple-tree/core/withType.js +5 -6
  1080. package/lib/simple-tree/core/withType.js.map +1 -1
  1081. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  1082. package/lib/simple-tree/fieldSchema.js +23 -5
  1083. package/lib/simple-tree/fieldSchema.js.map +1 -1
  1084. package/lib/simple-tree/index.d.ts +2 -2
  1085. package/lib/simple-tree/index.d.ts.map +1 -1
  1086. package/lib/simple-tree/index.js +2 -2
  1087. package/lib/simple-tree/index.js.map +1 -1
  1088. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  1089. package/lib/simple-tree/leafNodeSchema.js +16 -15
  1090. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  1091. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -2
  1092. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  1093. package/lib/simple-tree/node-kinds/array/arrayNode.js +28 -32
  1094. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  1095. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  1096. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +6 -6
  1097. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  1098. package/lib/simple-tree/node-kinds/map/mapNode.js +10 -17
  1099. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  1100. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  1101. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  1102. package/lib/simple-tree/node-kinds/object/objectNode.js +25 -28
  1103. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  1104. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +1 -1
  1105. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  1106. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  1107. package/lib/simple-tree/node-kinds/record/recordNode.js +10 -14
  1108. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  1109. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -2
  1110. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  1111. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  1112. package/lib/tableSchema.d.ts +2 -87
  1113. package/lib/tableSchema.d.ts.map +1 -1
  1114. package/lib/tableSchema.js +309 -275
  1115. package/lib/tableSchema.js.map +1 -1
  1116. package/lib/text/codePointUtils.d.ts +16 -3
  1117. package/lib/text/codePointUtils.d.ts.map +1 -1
  1118. package/lib/text/codePointUtils.js +22 -10
  1119. package/lib/text/codePointUtils.js.map +1 -1
  1120. package/lib/text/textDomain.d.ts +7 -1
  1121. package/lib/text/textDomain.d.ts.map +1 -1
  1122. package/lib/text/textDomain.js +21 -17
  1123. package/lib/text/textDomain.js.map +1 -1
  1124. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  1125. package/lib/text/textDomainFormatted.js +43 -32
  1126. package/lib/text/textDomainFormatted.js.map +1 -1
  1127. package/lib/text/textDomainFormattedDefault.js +2 -5
  1128. package/lib/text/textDomainFormattedDefault.js.map +1 -1
  1129. package/lib/util/brand.js +1 -0
  1130. package/lib/util/brand.js.map +1 -1
  1131. package/lib/util/breakable.d.ts.map +1 -1
  1132. package/lib/util/breakable.js +3 -0
  1133. package/lib/util/breakable.js.map +1 -1
  1134. package/lib/util/compressedIds.js +22 -0
  1135. package/lib/util/compressedIds.js.map +1 -1
  1136. package/lib/util/nestedMap.js +2 -4
  1137. package/lib/util/nestedMap.js.map +1 -1
  1138. package/lib/util/offsetList.js +2 -4
  1139. package/lib/util/offsetList.js.map +1 -1
  1140. package/lib/util/rangeMap.js +4 -0
  1141. package/lib/util/rangeMap.js.map +1 -1
  1142. package/lib/util/readSnapshotBlob.d.ts.map +1 -1
  1143. package/lib/util/referenceCounting.js +1 -0
  1144. package/lib/util/referenceCounting.js.map +1 -1
  1145. package/lib/util/stackyIterator.js +3 -2
  1146. package/lib/util/stackyIterator.js.map +1 -1
  1147. package/lib/util/utils.d.ts +2 -2
  1148. package/lib/util/utils.d.ts.map +1 -1
  1149. package/package.json +67 -95
  1150. package/src/api.ts +11 -0
  1151. package/src/core/index.ts +6 -2
  1152. package/src/core/rebase/index.ts +1 -0
  1153. package/src/core/rebase/types.ts +16 -1
  1154. package/src/core/tree/anchorSet.ts +2 -2
  1155. package/src/core/tree/deltaUtil.ts +67 -13
  1156. package/src/core/tree/index.ts +5 -2
  1157. package/src/entrypoints/alpha.ts +19 -21
  1158. package/src/entrypoints/beta.ts +12 -5
  1159. package/src/entrypoints/legacy.ts +12 -5
  1160. package/src/entrypoints/public.ts +1 -5
  1161. package/src/extensibleUnionNode.ts +1 -2
  1162. package/src/feature-libraries/cursorComparator.ts +57 -9
  1163. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +77 -12
  1164. package/src/feature-libraries/modular-schema/filterEdits.ts +108 -0
  1165. package/src/feature-libraries/modular-schema/genericFieldKind.ts +7 -4
  1166. package/src/feature-libraries/modular-schema/index.ts +5 -2
  1167. package/src/feature-libraries/modular-schema/invert.ts +16 -61
  1168. package/src/feature-libraries/modular-schema/minimizeModularChange.ts +831 -10
  1169. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +10 -124
  1170. package/src/feature-libraries/modular-schema/modularChangeUtils.ts +164 -2
  1171. package/src/feature-libraries/modular-schema/prune.ts +52 -10
  1172. package/src/feature-libraries/optional-field/optionalField.ts +30 -42
  1173. package/src/feature-libraries/sequence-field/filterEdits.ts +62 -26
  1174. package/src/feature-libraries/sequence-field/utils.ts +7 -19
  1175. package/src/index.ts +7 -39
  1176. package/src/internalTypes.ts +1 -1
  1177. package/src/packageVersion.ts +1 -1
  1178. package/src/shared-tree/history.ts +41 -19
  1179. package/src/shared-tree/independentView.ts +40 -3
  1180. package/src/shared-tree/index.ts +5 -1
  1181. package/src/shared-tree/schematizingTreeView.ts +2 -2
  1182. package/src/shared-tree/sharedTree.ts +2 -1
  1183. package/src/shared-tree/transactionMinimize.ts +13 -4
  1184. package/src/shared-tree/treeAlpha.ts +17 -31
  1185. package/src/{simple-tree/api → shared-tree}/treeBeta.ts +56 -167
  1186. package/src/shared-tree/treeCheckout.ts +82 -9
  1187. package/src/shared-tree-core/editManager.ts +16 -8
  1188. package/src/shared-tree-core/editManagerCodecsCommons.ts +30 -34
  1189. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +1 -1
  1190. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +2 -2
  1191. package/src/simple-tree/api/cloneTree.ts +47 -0
  1192. package/src/simple-tree/api/index.ts +15 -21
  1193. package/src/simple-tree/api/schemaFactoryAlpha.ts +2 -2
  1194. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +87 -6
  1195. package/src/simple-tree/api/transactionTypes.ts +4 -4
  1196. package/src/simple-tree/api/tree.ts +139 -85
  1197. package/src/simple-tree/api/treeChangeEvents.ts +16 -4
  1198. package/src/simple-tree/api/treeChangeEventsBeta.ts +245 -0
  1199. package/src/simple-tree/api/treeNodeApi.ts +6 -85
  1200. package/src/simple-tree/api/typesUnsafe.ts +8 -6
  1201. package/src/simple-tree/core/index.ts +1 -1
  1202. package/src/simple-tree/core/treeNode.ts +3 -10
  1203. package/src/simple-tree/core/withType.ts +8 -11
  1204. package/src/simple-tree/index.ts +3 -7
  1205. package/src/simple-tree/node-kinds/array/arrayNode.ts +14 -12
  1206. package/src/simple-tree/node-kinds/map/mapNode.ts +14 -15
  1207. package/src/simple-tree/node-kinds/object/objectNode.ts +3 -6
  1208. package/src/simple-tree/node-kinds/record/recordNode.ts +6 -8
  1209. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +2 -1
  1210. package/src/tableSchema.ts +8 -187
  1211. package/src/text/codePointUtils.ts +25 -14
  1212. package/src/text/textDomain.ts +15 -2
  1213. package/src/text/textDomainFormatted.ts +9 -4
  1214. package/tsconfig.json +1 -1
  1215. package/alpha.d.ts +0 -11
  1216. package/beta.d.ts +0 -11
  1217. package/dist/simple-tree/api/treeAlpha.d.ts +0 -126
  1218. package/dist/simple-tree/api/treeAlpha.d.ts.map +0 -1
  1219. package/dist/simple-tree/api/treeAlpha.js.map +0 -1
  1220. package/dist/simple-tree/api/treeBeta.d.ts.map +0 -1
  1221. package/dist/simple-tree/api/treeBeta.js +0 -83
  1222. package/dist/simple-tree/api/treeBeta.js.map +0 -1
  1223. package/docs/main/glossary.md +0 -163
  1224. package/internal.d.ts +0 -11
  1225. package/legacy.d.ts +0 -11
  1226. package/lib/simple-tree/api/treeAlpha.d.ts +0 -126
  1227. package/lib/simple-tree/api/treeAlpha.d.ts.map +0 -1
  1228. package/lib/simple-tree/api/treeAlpha.js.map +0 -1
  1229. package/lib/simple-tree/api/treeBeta.d.ts.map +0 -1
  1230. package/lib/simple-tree/api/treeBeta.js +0 -77
  1231. package/lib/simple-tree/api/treeBeta.js.map +0 -1
  1232. package/src/simple-tree/api/treeAlpha.ts +0 -153
  1233. /package/api-extractor/{api-extractor.current.json → api-extractor-report.current.json} +0 -0
  1234. /package/api-extractor/{api-extractor.legacy.json → api-extractor-report.legacy.json} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/simple-tree/api/configuration.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAyF;AACzF,uEAAsE;AAEtE,kDAAkD;AAElD,+CAK0B;AAC1B,sDAA+F;AAC/F,qDASgC;AAEhC,4DAI8B;AAC9B,oDAAqE;AACrE,8DAAwD;AAsGxD,MAAM,+BAA+B,GAAwC;IAC5E,sBAAsB,EAAE,KAAK;IAC7B,gBAAgB,EAAE,KAAK;CACvB,CAAC;AAgDF;;;GAGG;AACH,MAAa,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,IAAA,iBAAM;QACL,wGAAwG;QACvG,IAAI,CAAC,WAAuB,KAAK,0BAA0B,EAC5D,KAAK,CAAC,8CAA8C,CACpD,CAAC;QAEF,MAAM,MAAM,GAAG,EAAE,GAAG,+BAA+B,EAAE,GAAG,KAAK,EAAE,CAAC;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,M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AA0B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,mEAAmE,WAAW,CAAC,iBAAiB,CAAC,oIAAoI,CAChS,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC;AAvID,gCAuIC","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 { getOrCreate } from \"../../util/index.js\";\nimport type { MakeNominal } from \"../../util/index.js\";\nimport {\n\ttype AllowedTypesFullEvaluated,\n\tNodeKind,\n\tStagedSchemaUpgradePolicy,\n\ttype TreeNodeSchema,\n} from \"../core/index.js\";\nimport { type FieldSchemaAlpha, type ImplicitFieldSchema, FieldKind } from \"../fieldSchema.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 type { SchemaType, SimpleNodeSchema } from \"../simpleSchema.js\";\nimport {\n\ttoInitialSchema,\n\ttoUnhydratedSchema,\n\ttransformSimpleSchema,\n} from \"../toStoredSchema.js\";\nimport { createTreeSchema, type TreeSchema } from \"../treeSchema.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.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 * @remarks\n\t * Use {@link SchemaFactory} to construct the schema.\n\t * Changes to this schema between different versions have important compatibility implications.\n\t * See the {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution | documentation on schema evolution} for more details.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * Property-bag configuration for {@link TreeViewConfigurationAlpha} construction.\n * @input\n * @alpha\n */\nexport interface ITreeViewConfigurationAlpha<\n\tTSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> extends ITreeViewConfiguration<TSchema> {\n\t/**\n\t * Policy for generating stored schema from the view schema during staged schema upgrades.\n\t *\n\t * @remarks\n\t * If provided, this policy is used when generating stored schema to include in documents via\n\t * `initialize` / `upgradeSchema` as well as in {@link snapshotSchemaCompatibility} to validate\n\t * the compatibility of such documents.\n\t *\n\t * @defaultValue {@link StagedSchemaUpgradePolicyFactory.restrictive}\n\t *\n\t * @example Enabling specific staged upgrades\n\t * ```typescript\n\t * const config = new TreeViewConfigurationAlpha({\n\t * schema: MySchema,\n\t * stagedUpgradePolicy: StagedSchemaUpgradePolicy.enabledStagedUpgrades(myUpgrade),\n\t * });\n\t * ```\n\t */\n\treadonly stagedUpgradePolicy?: StagedSchemaUpgradePolicy;\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\t/**\n\t * {@inheritDoc ITreeViewConfigurationAlpha.stagedUpgradePolicy}\n\t */\n\tpublic readonly stagedUpgradePolicy: StagedSchemaUpgradePolicy;\n\n\tpublic constructor(props: ITreeViewConfigurationAlpha<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\tthis.stagedUpgradePolicy =\n\t\t\tprops.stagedUpgradePolicy ?? StagedSchemaUpgradePolicy.restrictive;\n\n\t\t// Eagerly perform these conversions to surface errors sooner.\n\t\ttoInitialSchema(this.root, this.stagedUpgradePolicy);\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;;;AAiUH,gCAuIC;AAtcD,kEAAyF;AACzF,uEAAsE;AAEtE,kDAAkD;AAElD,+CAK0B;AAC1B,sDAA+F;AAC/F,qDASgC;AAEhC,4DAI8B;AAC9B,oDAAqE;AACrE,8DAAwD;AAsGxD,MAAM,+BAA+B,GAAwC;IAC5E,sBAAsB,EAAE,KAAK;IAC7B,gBAAgB,EAAE,KAAK;CACvB,CAAC;AAgDF;;;GAGG;AACH,MAAa,qBAAqB;IAIvB,UAAU,CAAe;IAEnC;;OAEG;IACa,MAAM,CAAW;IAEjC;;OAEG;IACa,sBAAsB,CAAW;IAEjD;;OAEG;IACa,gBAAgB,CAAW;IAE3C;;;;;;;;;;;;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,IAAA,iBAAM;QACL,wGAAwG;QACvG,IAAI,CAAC,WAAuB,KAAK,0BAA0B,EAC5D,KAAK,CAAC,8CAA8C,CACpD,CAAC;QAEF,MAAM,MAAM,GAAG,EAAE,GAAG,+BAA+B,EAAE,GAAG,KAAK,EAAE,CAAC;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,sBAAsB,CAAC;QAC5D,IAAI,CAAC,gBAAgB,GAAG,MA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AAM,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 { getOrCreate } from \"../../util/index.js\";\nimport type { MakeNominal } from \"../../util/index.js\";\nimport {\n\ttype AllowedTypesFullEvaluated,\n\tNodeKind,\n\tStagedSchemaUpgradePolicy,\n\ttype TreeNodeSchema,\n} from \"../core/index.js\";\nimport { type FieldSchemaAlpha, type ImplicitFieldSchema, FieldKind } from \"../fieldSchema.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 type { SchemaType, SimpleNodeSchema } from \"../simpleSchema.js\";\nimport {\n\ttoInitialSchema,\n\ttoUnhydratedSchema,\n\ttransformSimpleSchema,\n} from \"../toStoredSchema.js\";\nimport { createTreeSchema, type TreeSchema } from \"../treeSchema.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.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 * @remarks\n\t * Use {@link SchemaFactory} to construct the schema.\n\t * Changes to this schema between different versions have important compatibility implications.\n\t * See the {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution | documentation on schema evolution} for more details.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * Property-bag configuration for {@link TreeViewConfigurationAlpha} construction.\n * @input\n * @alpha\n */\nexport interface ITreeViewConfigurationAlpha<\n\tTSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> extends ITreeViewConfiguration<TSchema> {\n\t/**\n\t * Policy for generating stored schema from the view schema during staged schema upgrades.\n\t *\n\t * @remarks\n\t * If provided, this policy is used when generating stored schema to include in documents via\n\t * `initialize` / `upgradeSchema` as well as in {@link snapshotSchemaCompatibility} to validate\n\t * the compatibility of such documents.\n\t *\n\t * @defaultValue {@link StagedSchemaUpgradePolicyFactory.restrictive}\n\t *\n\t * @example Enabling specific staged upgrades\n\t * ```typescript\n\t * const config = new TreeViewConfigurationAlpha({\n\t * schema: MySchema,\n\t * stagedUpgradePolicy: StagedSchemaUpgradePolicy.enabledStagedUpgrades(myUpgrade),\n\t * });\n\t * ```\n\t */\n\treadonly stagedUpgradePolicy?: StagedSchemaUpgradePolicy;\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\t/**\n\t * {@inheritDoc ITreeViewConfigurationAlpha.stagedUpgradePolicy}\n\t */\n\tpublic readonly stagedUpgradePolicy: StagedSchemaUpgradePolicy;\n\n\tpublic constructor(props: ITreeViewConfigurationAlpha<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\tthis.stagedUpgradePolicy =\n\t\t\tprops.stagedUpgradePolicy ?? StagedSchemaUpgradePolicy.restrictive;\n\n\t\t// Eagerly perform these conversions to surface errors sooner.\n\t\ttoInitialSchema(this.root, this.stagedUpgradePolicy);\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"]}
@@ -4,7 +4,8 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.unhydratedFlexTreeFromCursor = exports.createFromCursor = void 0;
7
+ exports.createFromCursor = createFromCursor;
8
+ exports.unhydratedFlexTreeFromCursor = unhydratedFlexTreeFromCursor;
8
9
  const internal_1 = require("@fluidframework/core-utils/internal");
9
10
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
10
11
  const index_js_1 = require("../../core/index.js");
@@ -37,7 +38,6 @@ function createFromCursor(schema, cursor, destinationSchema, contextForNewNodes)
37
38
  const mapTree = mapTrees[0];
38
39
  return (0, index_js_3.getOrCreateNodeFromInnerNode)(mapTree);
39
40
  }
40
- exports.createFromCursor = createFromCursor;
41
41
  /**
42
42
  * Construct an {@link UnhydratedFlexTreeNode} from a cursor in Nodes mode.
43
43
  * @remarks
@@ -69,5 +69,4 @@ function unhydratedFlexTreeFromCursor(context, cursor) {
69
69
  }));
70
70
  return new index_js_3.UnhydratedFlexTreeNode({ type: cursor.type, value: cursor.value }, fields, context);
71
71
  }
72
- exports.unhydratedFlexTreeFromCursor = unhydratedFlexTreeFromCursor;
73
72
  //# sourceMappingURL=create.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/simple-tree/api/create.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AAEtE,kDAQ6B;AAC7B,+DAI0C;AAC1C,+CAM0B;AAC1B,0DAA2D;AAG3D,mDAAmD;AAEnD;;;;;GAKG;AACH,SAAgB,gBAAgB,CAC/B,MAAe,EACf,MAA0C,EAC1C,iBAAwC,EACxC,kBAA4B;IAE5B,MAAM,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AAC;IAEvF,MAAM,MAAM,GAAG,IAAI,GAAG,CACrB,IAAA,0BAAe,EAAC,MAAM,EAAE,GAAG,EAAE;QAC5B,MAAM,WAAW,GAAG,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QACtE,IAAI,WAAW,CAAC,IAAI,KAAK,uCAA4B,EAAE,CAAC;YACvD,8DAA8D;YAC9D,iJAAiJ;YACjJ,uDAAuD;YACvD,6KAA6K;YAC7K,oFAAoF;YACpF,MAAM,IAAI,qBAAU;YACnB,+HAA+H;YAC/H,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,iCAAiC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAC3G,CAAC;QACH,CAAC;QACD,OAAO;YACN,MAAM,CAAC,WAAW,EAAE;YACpB,IAAA,sBAAW,EACV,OAAO,CAAC,WAAW,EACnB,WAAW,CAAC,IAAI,EAChB,MAAM,CAAC,WAAW,EAAE,EACpB,IAAA,yBAAc,EAAC,MAAM,EAAE,GAAG,EAAE,CAAC,4BAA4B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAC3E;SACD,CAAC;IACH,CAAC,CAAC,CACF,CAAC;IACF,OAAO,IAAI,iCAAsB,CAChC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,EAC1C,MAAM,EACN,OAAO,CACP,CAAC;AACH,CAAC;AAvCD,oEAuCC","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\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\tforbiddenFieldKindIdentifier,\n\tmapCursorField,\n\tmapCursorFields,\n\ttype ITreeCursorSynchronous,\n\ttype SchemaAndPolicy,\n\ttype TreeFieldStoredSchema,\n} from \"../../core/index.js\";\nimport {\n\tdefaultSchemaPolicy,\n\tisFieldInSchema,\n\tthrowOutOfSchema,\n} from \"../../feature-libraries/index.js\";\nimport {\n\ttype Context,\n\tgetOrCreateNodeFromInnerNode,\n\ttype Unhydrated,\n\tUnhydratedFlexTreeNode,\n\tcreateField,\n} from \"../core/index.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\nimport type { ImplicitFieldSchema, TreeFieldFromImplicitField } from \"../fieldSchema.js\";\n\nimport { unknownTypeError } from \"./customTree.js\";\n\n/**\n * Creates an unhydrated simple-tree field from a cursor in nodes mode.\n * @remarks\n * Does not support providing missing defaults values.\n * Validates the field is in schema using `destinationSchema` the provided `contextForNewNodes` or the default unhydrated context if not provided.\n */\nexport function createFromCursor<const TSchema extends ImplicitFieldSchema>(\n\tschema: TSchema,\n\tcursor: ITreeCursorSynchronous | undefined,\n\tdestinationSchema: TreeFieldStoredSchema,\n\tcontextForNewNodes?: Context,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\tconst context = contextForNewNodes ?? getUnhydratedContext(schema);\n\tassert(context.flexContext.isHydrated() === false, 0xbfe /* Expected unhydrated context */);\n\tconst mapTrees = cursor === undefined ? [] : [unhydratedFlexTreeFromCursor(context, cursor)];\n\n\tconst schemaAndPolicy: SchemaAndPolicy = {\n\t\tpolicy: defaultSchemaPolicy,\n\t\tschema: context.flexContext.schema,\n\t};\n\n\t// Assuming the caller provides the correct `contextForNewNodes`, this should handle unknown optional fields.\n\tisFieldInSchema(mapTrees, destinationSchema, schemaAndPolicy, throwOutOfSchema);\n\n\tif (mapTrees.length === 0) {\n\t\treturn undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t}\n\tassert(mapTrees.length === 1, 0xa11 /* unexpected field length */);\n\t// Length asserted above, so this is safe. This assert is done instead of checking for undefined after indexing to ensure a length greater than 1 also errors.\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst mapTree = mapTrees[0]!;\n\n\treturn getOrCreateNodeFromInnerNode(mapTree) as Unhydrated<\n\t\tTreeFieldFromImplicitField<TSchema>\n\t>;\n}\n\n/**\n * Construct an {@link UnhydratedFlexTreeNode} from a cursor in Nodes mode.\n * @remarks\n * This does not fully validate the node is in schema, but does throw UsageErrors for some cases of out-of-schema content.\n *\n * Does not support unknown optional fields: will throw a UsageError if the field is not in schema.\n * This cannot easily be fixed as this code requires a schema for each subtree to process, and none is available for unknown optional fields.\n */\nexport function unhydratedFlexTreeFromCursor(\n\tcontext: Context,\n\tcursor: ITreeCursorSynchronous,\n): UnhydratedFlexTreeNode {\n\tassert(cursor.mode === CursorLocationType.Nodes, 0xbb4 /* Expected nodes cursor */);\n\tconst identifier = cursor.type;\n\tconst storedSchema =\n\t\tcontext.flexContext.schema.nodeSchema.get(identifier) ?? unknownTypeError(identifier);\n\n\tconst fields = new Map(\n\t\tmapCursorFields(cursor, () => {\n\t\t\tconst fieldSchema = storedSchema.getFieldSchema(cursor.getFieldKey());\n\t\t\tif (fieldSchema.kind === forbiddenFieldKindIdentifier) {\n\t\t\t\t// Check for unexpected fields before recursing into children:\n\t\t\t\t// Code which hits this case is very likely to also use an unknown type in the unexpected field, which would give a more confusing error message.\n\t\t\t\t// This case is detected here to improve error quality.\n\t\t\t\t// Also note that if using the view schema from above to suppress this error for unknownOptionalFields, that would not provide a way to handle unknown types in those fields:\n\t\t\t\t// they would still error, but with that more confusing message about unknown types.\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t// Using JSON.stringify to handle quoting and escaping since both key and identifier can technically contain quotes themselves.\n\t\t\t\t\t`Field ${JSON.stringify(cursor.getFieldKey())} is not defined in the schema ${JSON.stringify(identifier)}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn [\n\t\t\t\tcursor.getFieldKey(),\n\t\t\t\tcreateField(\n\t\t\t\t\tcontext.flexContext,\n\t\t\t\t\tfieldSchema.kind,\n\t\t\t\t\tcursor.getFieldKey(),\n\t\t\t\t\tmapCursorField(cursor, () => unhydratedFlexTreeFromCursor(context, cursor)),\n\t\t\t\t),\n\t\t\t];\n\t\t}),\n\t);\n\treturn new UnhydratedFlexTreeNode(\n\t\t{ type: cursor.type, value: cursor.value },\n\t\tfields,\n\t\tcontext,\n\t);\n}\n"]}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/simple-tree/api/create.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAqCH,4CA6BC;AAUD,oEAuCC;AAjHD,kEAA6D;AAC7D,uEAAsE;AAEtE,kDAQ6B;AAC7B,+DAI0C;AAC1C,+CAM0B;AAC1B,0DAA2D;AAG3D,mDAAmD;AAEnD;;;;;GAKG;AACH,SAAgB,gBAAgB,CAC/B,MAAe,EACf,MAA0C,EAC1C,iBAAwC,EACxC,kBAA4B;IAE5B,MAAM,OAAO,GAAG,kBAAkB,IAAI,IAAA,uCAAoB,EAAC,MAAM,CAAC,CAAC;IACnE,IAAA,iBAAM,EAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,KAAK,EAAE,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC5F,MAAM,QAAQ,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAE7F,MAAM,eAAe,GAAoB;QACxC,MAAM,EAAE,8BAAmB;QAC3B,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,MAAM;KAClC,CAAC;IAEF,6GAA6G;IAC7G,IAAA,0BAAe,EAAC,QAAQ,EAAE,iBAAiB,EAAE,eAAe,EAAE,2BAAgB,CAAC,CAAC;IAEhF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,SAA4D,CAAC;IACrE,CAAC;IACD,IAAA,iBAAM,EAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACn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C;IACH,CAAC,CAAC,CACF,CAAC;IACF,OAAO,IAAI,iCAAsB,CAChC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,EAC1C,MAAM,EACN,OAAO,CACP,CAAC;AACH,CAAC","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\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\tforbiddenFieldKindIdentifier,\n\tmapCursorField,\n\tmapCursorFields,\n\ttype ITreeCursorSynchronous,\n\ttype SchemaAndPolicy,\n\ttype TreeFieldStoredSchema,\n} from \"../../core/index.js\";\nimport {\n\tdefaultSchemaPolicy,\n\tisFieldInSchema,\n\tthrowOutOfSchema,\n} from \"../../feature-libraries/index.js\";\nimport {\n\ttype Context,\n\tgetOrCreateNodeFromInnerNode,\n\ttype Unhydrated,\n\tUnhydratedFlexTreeNode,\n\tcreateField,\n} from \"../core/index.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\nimport type { ImplicitFieldSchema, TreeFieldFromImplicitField } from \"../fieldSchema.js\";\n\nimport { unknownTypeError } from \"./customTree.js\";\n\n/**\n * Creates an unhydrated simple-tree field from a cursor in nodes mode.\n * @remarks\n * Does not support providing missing defaults values.\n * Validates the field is in schema using `destinationSchema` the provided `contextForNewNodes` or the default unhydrated context if not provided.\n */\nexport function createFromCursor<const TSchema extends ImplicitFieldSchema>(\n\tschema: TSchema,\n\tcursor: ITreeCursorSynchronous | undefined,\n\tdestinationSchema: TreeFieldStoredSchema,\n\tcontextForNewNodes?: Context,\n): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\tconst context = contextForNewNodes ?? getUnhydratedContext(schema);\n\tassert(context.flexContext.isHydrated() === false, 0xbfe /* Expected unhydrated context */);\n\tconst mapTrees = cursor === undefined ? [] : [unhydratedFlexTreeFromCursor(context, cursor)];\n\n\tconst schemaAndPolicy: SchemaAndPolicy = {\n\t\tpolicy: defaultSchemaPolicy,\n\t\tschema: context.flexContext.schema,\n\t};\n\n\t// Assuming the caller provides the correct `contextForNewNodes`, this should handle unknown optional fields.\n\tisFieldInSchema(mapTrees, destinationSchema, schemaAndPolicy, throwOutOfSchema);\n\n\tif (mapTrees.length === 0) {\n\t\treturn undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t}\n\tassert(mapTrees.length === 1, 0xa11 /* unexpected field length */);\n\t// Length asserted above, so this is safe. This assert is done instead of checking for undefined after indexing to ensure a length greater than 1 also errors.\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst mapTree = mapTrees[0]!;\n\n\treturn getOrCreateNodeFromInnerNode(mapTree) as Unhydrated<\n\t\tTreeFieldFromImplicitField<TSchema>\n\t>;\n}\n\n/**\n * Construct an {@link UnhydratedFlexTreeNode} from a cursor in Nodes mode.\n * @remarks\n * This does not fully validate the node is in schema, but does throw UsageErrors for some cases of out-of-schema content.\n *\n * Does not support unknown optional fields: will throw a UsageError if the field is not in schema.\n * This cannot easily be fixed as this code requires a schema for each subtree to process, and none is available for unknown optional fields.\n */\nexport function unhydratedFlexTreeFromCursor(\n\tcontext: Context,\n\tcursor: ITreeCursorSynchronous,\n): UnhydratedFlexTreeNode {\n\tassert(cursor.mode === CursorLocationType.Nodes, 0xbb4 /* Expected nodes cursor */);\n\tconst identifier = cursor.type;\n\tconst storedSchema =\n\t\tcontext.flexContext.schema.nodeSchema.get(identifier) ?? unknownTypeError(identifier);\n\n\tconst fields = new Map(\n\t\tmapCursorFields(cursor, () => {\n\t\t\tconst fieldSchema = storedSchema.getFieldSchema(cursor.getFieldKey());\n\t\t\tif (fieldSchema.kind === forbiddenFieldKindIdentifier) {\n\t\t\t\t// Check for unexpected fields before recursing into children:\n\t\t\t\t// Code which hits this case is very likely to also use an unknown type in the unexpected field, which would give a more confusing error message.\n\t\t\t\t// This case is detected here to improve error quality.\n\t\t\t\t// Also note that if using the view schema from above to suppress this error for unknownOptionalFields, that would not provide a way to handle unknown types in those fields:\n\t\t\t\t// they would still error, but with that more confusing message about unknown types.\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t// Using JSON.stringify to handle quoting and escaping since both key and identifier can technically contain quotes themselves.\n\t\t\t\t\t`Field ${JSON.stringify(cursor.getFieldKey())} is not defined in the schema ${JSON.stringify(identifier)}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn [\n\t\t\t\tcursor.getFieldKey(),\n\t\t\t\tcreateField(\n\t\t\t\t\tcontext.flexContext,\n\t\t\t\t\tfieldSchema.kind,\n\t\t\t\t\tcursor.getFieldKey(),\n\t\t\t\t\tmapCursorField(cursor, () => unhydratedFlexTreeFromCursor(context, cursor)),\n\t\t\t\t),\n\t\t\t];\n\t\t}),\n\t);\n\treturn new UnhydratedFlexTreeNode(\n\t\t{ type: cursor.type, value: cursor.value },\n\t\tfields,\n\t\tcontext,\n\t);\n}\n"]}
@@ -4,7 +4,12 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.unknownTypeError = exports.replaceHandles = exports.tryStoredSchemaAsArray = exports.customFromCursorStored = exports.customFromCursor = exports.KeyEncodingOptions = void 0;
7
+ exports.KeyEncodingOptions = void 0;
8
+ exports.customFromCursor = customFromCursor;
9
+ exports.customFromCursorStored = customFromCursorStored;
10
+ exports.tryStoredSchemaAsArray = tryStoredSchemaAsArray;
11
+ exports.replaceHandles = replaceHandles;
12
+ exports.unknownTypeError = unknownTypeError;
8
13
  const internal_1 = require("@fluidframework/core-utils/internal");
9
14
  const internal_2 = require("@fluidframework/runtime-utils/internal");
10
15
  const internal_3 = require("@fluidframework/telemetry-utils/internal");
@@ -99,7 +104,6 @@ function customFromCursor(reader, options, storedSchema, schema, childHandler) {
99
104
  }
100
105
  }
101
106
  }
102
- exports.customFromCursor = customFromCursor;
103
107
  /**
104
108
  * Returns the key if one should be used, and undefined if the field should be omitted/skipped.
105
109
  *
@@ -180,7 +184,6 @@ function customFromCursorStored(reader, schema, childHandler) {
180
184
  });
181
185
  return fields;
182
186
  }
183
- exports.customFromCursorStored = customFromCursorStored;
184
187
  /**
185
188
  * Checks if `schema` could correspond to a simple-tree array node.
186
189
  * If it is an array schema, returns the allowed types for the array field.
@@ -199,7 +202,6 @@ function tryStoredSchemaAsArray(schema) {
199
202
  }
200
203
  }
201
204
  }
202
- exports.tryStoredSchemaAsArray = tryStoredSchemaAsArray;
203
205
  /**
204
206
  * Clones tree, replacing any handles.
205
207
  * @remarks
@@ -227,12 +229,10 @@ function replaceHandles(tree, replacer) {
227
229
  }
228
230
  });
229
231
  }
230
- exports.replaceHandles = replaceHandles;
231
232
  /**
232
233
  * Throws a `UsageError` indicating that a type is unknown in the current context.
233
234
  */
234
235
  function unknownTypeError(type) {
235
236
  throw new internal_3.UsageError(`Failed to parse tree due to occurrence of type ${JSON.stringify(type)} which is not defined in this context.`);
236
237
  }
237
- exports.unknownTypeError = unknownTypeError;
238
238
  //# sourceMappingURL=customTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"customTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAAoF;AACpF,qEAAuE;AACvE,uEAAsE;AAEtE,kDAY6B;AAC7B,+DAAiF;AACjF,kDAA4D;AAE5D,4DAM8B;AAC9B,qDAA4D;AA4B5D;;;;GAIG;AACH,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,kCAAlB,kBAAkB,QAsB7B;AA8BD;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB,CAC/B,MAAmB,EACnB,OAAsC,EACtC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,cAAc,CAAC,mBAAQ,CAAC,CAAC;QAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YACnD,kFAAkF;YAClF,6FAA6F;YAC7F,IAAA,iBAAM,EAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC,KAAK,CAAC;QACpB,CAAC;IACF,CAAC;AACF,CAAC;AAVD,wDAUC;AAUD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,cAAc,CAAI,IAAa,EAAE,QAA4B;IAC5E,OAAO,IAAA,gCAAqB,EAAC,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACrD,kDAAkD;QAClD,IAAI,IAAA,wBAAa,EAAC,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;AATD,wCASC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,IAAY;IAC5C,MAAM,IAAI,qBAAU,CACnB,kDAAkD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,wCAAwC,CAC9G,CAAC;AACH,CAAC;AAJD,4CAIC","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
+ {"version":3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O,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,IAAY;IAC5C,MAAM,IAAI,qBAAU,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"]}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.trackDirtyNodes = void 0;
7
+ exports.trackDirtyNodes = trackDirtyNodes;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../../core/index.js");
10
10
  const index_js_2 = require("../core/index.js");
@@ -39,7 +39,6 @@ function trackDirtyNodes(view, dirty) {
39
39
  forest.deregisterAnnouncedVisitor(announcedVisitor);
40
40
  };
41
41
  }
42
- exports.trackDirtyNodes = trackDirtyNodes;
43
42
  function createDirtyVisitor(forest, dirty) {
44
43
  // When cursor is in Fields mode, `parentField` is the field and `parent` is the parent node above that field (if any).
45
44
  // When cursor is in Nodes mode, `parent` is the current node and `parentField` is undefined.
@@ -1 +1 @@
1
- {"version":3,"file":"dirtyIndex.js","sourceRoot":"","sources":["../../../src/simple-tree/api/dirtyIndex.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,kDAO6B;AAE7B,+CAAgE;AA6BhE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,eAAe,CAC9B,IAAwC,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oBAAoB,CAAC,CAAC;YAC9D,MAAM,GAAG;gBACR,MAAM;gBACN,WAAW;gBACX,WAAW,EAAE,KAAK;aAClB,CAAC;YACF,WAAW,GAAG,SAAS,CAAC;QACzB,CAAC;QACD,QAAQ;YACP,IAAA,iBAAM,EAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACxD,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;YACjC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QACxB,CAAC;QACD,UAAU,EAAE,CAAC,GAAa,EAAE,EAAE;YAC7B,WAAW,GAAG,GAAG,CAAC;QACnB,CAAC;QACD,SAAS;YACR,WAAW,GAAG,SAAS,CAAC;QACzB,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAuB,EAAE,IAAY;IAC3D,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IACvC,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,IAAA,iBAAM,EAAC,MAAM,CAAC,IAAI,qCAA6B,EAAE,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC7F,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACpC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,CAAC,IAAI,EAAE,CAAC;IACd,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAA,6BAAkB,EAAC,UAAU,CAAC,CAAC;QAC5C,IAAI,IAAI,YAAY,mBAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","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 {\n\tcreateAnnouncedVisitor,\n\tCursorLocationType,\n\ttype AnnouncedVisitor,\n\ttype FieldKey,\n\ttype IEditableForest,\n\ttype UpPath,\n} from \"../../core/index.js\";\nimport type { SchematizingSimpleTreeView } from \"../../shared-tree/index.js\";\nimport { TreeNode, treeNodeFromAnchor } from \"../core/index.js\";\nimport type { ImplicitFieldSchema } from \"../fieldSchema.js\";\n\nimport type { TreeViewAlpha } from \"./tree.js\";\n\n/**\n * The status of a node in a that has been {@link trackDirtyNodes | tracked for changes}.\n * @remarks Nodes can be marked \"new\", \"changed\", or \"moved\", with \"new\" taking precedence over \"changed\" and \"changed\" taking precedence over \"moved\".\n * * \"new\": The node was added.\n * * \"changed\": A direct child was updated, added, removed, or moved (and the node is not \"new\").\n * * \"moved\": The node was moved between/within arrays (and the node is not \"new\" or \"changed\").\n * @privateRemarks\n * It is unclear how this will handle forward compatibility with other kinds of edits, like moves that are not limited to arrays (attach, detach, swap):\n * this needs to be sorted out before this is stabilized.\n * It is also unclear how this is supposed to handle schema changes (which can result in new TreeNode instance, but I think won't trigger \"new\" here).\n * @alpha\n */\nexport type DirtyTreeStatus = \"new\" | \"changed\" | \"moved\";\n\n/**\n * A map-like interface for tracking the {@link DirtyTreeStatus | status} of nodes that have been {@link trackDirtyNodes | tracked for changes}.\n * @privateRemarks TODO: Replace this with `MapGetSet` from `@fluidframework/core-interfaces`.\n * @alpha\n */\nexport interface DirtyTreeMap {\n\tget(node: TreeNode): DirtyTreeStatus | undefined;\n\tset(node: TreeNode, status: DirtyTreeStatus): void;\n}\n\n/**\n * Registers a visitor on the view's forest that tracks which nodes are dirty.\n * @param view - The view to track dirty nodes on\n * @param dirty - A {@link DirtyTreeMap | map} that will be updated over time to reflect the {@link DirtyTreeStatus | status} of nodes as they change.\n * Nodes that have not changed will not be inserted/updated in the map.\n * @returns a cleanup function that should be called when the tracking is no longer needed.\n * @example\n * ```typescript\n * const dirty = new Map<TreeNode, DirtyTreeStatus>();\n * const stopTracking = trackDirtyNodes(view, dirty);\n * // ... make changes to the view ...\n * console.log(`The root of the tree is ${dirty.get(view.root) ?? \"unchanged\"}`);\n * stopTracking();\n * ```\n * @privateRemarks\n * This provides an opportunity for user code (\"set\" on dirty) to run during forest changes, in the middle of processing an edit.\n * We have generally avoided exposing such times to users and instead flush events after the edit has finished and user facing invariants are known to be restored.\n * Before stabilizing, how this event relates to other events time/ordering wise should be clarified, and if any APIs have been provided to defer events, that mentioned as well.\n * Maybe updates should be deferred?\n *\n * This is also documented in terms of \"forest\" which is not a concept in the public API, and thus needs to be redefined in terms of public concepts.\n * @alpha\n */\nexport function trackDirtyNodes(\n\tview: TreeViewAlpha<ImplicitFieldSchema>,\n\tdirty: DirtyTreeMap,\n): () => void {\n\tconst forest = (view as SchematizingSimpleTreeView<ImplicitFieldSchema>).checkout.forest;\n\tconst announcedVisitor = (): AnnouncedVisitor => createDirtyVisitor(forest, dirty);\n\tforest.registerAnnouncedVisitor(announcedVisitor);\n\treturn () => {\n\t\tforest.deregisterAnnouncedVisitor(announcedVisitor);\n\t};\n}\n\nfunction createDirtyVisitor(forest: IEditableForest, dirty: DirtyTreeMap): AnnouncedVisitor {\n\t// When cursor is in Fields mode, `parentField` is the field and `parent` is the parent node above that field (if any).\n\t// When cursor is in Nodes mode, `parent` is the current node and `parentField` is undefined.\n\tlet parentField: FieldKey | undefined;\n\tlet parent: UpPath | undefined;\n\n\treturn createAnnouncedVisitor({\n\t\tbeforeDetach: (src) => {\n\t\t\tassert(parent !== undefined, 0xc48 /* Expected node */);\n\t\t\tassert(parentField !== undefined, 0xc49 /* Expected field */);\n\t\t\tfor (let parentIndex = src.start; parentIndex < src.end; parentIndex++) {\n\t\t\t\tconst path: UpPath = {\n\t\t\t\t\tparent,\n\t\t\t\t\tparentField,\n\t\t\t\t\tparentIndex,\n\t\t\t\t};\n\t\t\t\t// The only way a detached node can be re-attached (and become visible/usable again) is via a move, so mark it as moved ahead of time.\n\t\t\t\tconst node = getNodeAtPath(forest, path);\n\t\t\t\tif (node !== undefined && dirty.get(node) === undefined) {\n\t\t\t\t\t// Only mark the node as moved if it is not already marked as something else.\n\t\t\t\t\tdirty.set(node, \"moved\");\n\t\t\t\t}\n\t\t\t\t// Mark the parent as changed unless it is already marked as new.\n\t\t\t\tconst parentNode = getNodeAtPath(forest, parent);\n\t\t\t\tif (parentNode !== undefined && dirty.get(parentNode) !== \"new\") {\n\t\t\t\t\tdirty.set(parentNode, \"changed\");\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tafterAttach: (_, dst) => {\n\t\t\tassert(parent !== undefined, 0xc4a /* Expected node */);\n\t\t\tassert(parentField !== undefined, 0xc4b /* Expected field */);\n\t\t\tfor (let parentIndex = dst.start; parentIndex < dst.end; parentIndex++) {\n\t\t\t\tconst path: UpPath = {\n\t\t\t\t\tparent,\n\t\t\t\t\tparentField,\n\t\t\t\t\tparentIndex,\n\t\t\t\t};\n\t\t\t\tconst node = getNodeAtPath(forest, path);\n\t\t\t\tif (node !== undefined && dirty.get(node) === undefined) {\n\t\t\t\t\t// Only mark the node as new if it is not already marked as something else - this ensures that a moved node is not marked as new (since nodes are marked move when detached).\n\t\t\t\t\tdirty.set(node, \"new\");\n\t\t\t\t}\n\t\t\t\t// Mark the parent as changed unless it is already marked as new.\n\t\t\t\tconst parentNode = getNodeAtPath(forest, parent);\n\t\t\t\tif (parentNode !== undefined && dirty.get(parentNode) !== \"new\") {\n\t\t\t\t\tdirty.set(parentNode, \"changed\");\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tenterNode(index: number): void {\n\t\t\tassert(parentField !== undefined, 0xc4c /* Expected field */);\n\t\t\tparent = {\n\t\t\t\tparent,\n\t\t\t\tparentField,\n\t\t\t\tparentIndex: index,\n\t\t\t};\n\t\t\tparentField = undefined;\n\t\t},\n\t\texitNode(): void {\n\t\t\tassert(parent !== undefined, 0xc4d /* Expected node */);\n\t\t\tparentField = parent.parentField;\n\t\t\tparent = parent.parent;\n\t\t},\n\t\tenterField: (key: FieldKey) => {\n\t\t\tparentField = key;\n\t\t},\n\t\texitField(): void {\n\t\t\tparentField = undefined;\n\t\t},\n\t});\n}\n\nfunction getNodeAtPath(forest: IEditableForest, path: UpPath): TreeNode | undefined {\n\tconst cursor = forest.allocateCursor();\n\tforest.moveCursorToPath(path, cursor);\n\tassert(cursor.mode === CursorLocationType.Nodes, 0xc4e /* attach should happen in a node */);\n\tconst anchor = cursor.buildAnchor();\n\tconst anchorNode = forest.anchors.locate(anchor);\n\tcursor.free();\n\tif (anchorNode !== undefined) {\n\t\tconst node = treeNodeFromAnchor(anchorNode);\n\t\tif (node instanceof TreeNode) {\n\t\t\treturn node;\n\t\t}\n\t}\n\treturn undefined;\n}\n"]}
1
+ {"version":3,"file":"dirtyIndex.js","sourceRoot":"","sources":["../../../src/simple-tree/api/dirtyIndex.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAiEH,0CAUC;AAzED,kEAA6D;AAE7D,kDAO6B;AAE7B,+CAAgE;AA6BhE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,eAAe,CAC9B,IAAwC,EACxC,KAAmB;IAEnB,MAAM,MAAM,GAAI,IAAwD,CAAC,QAAQ,CAAC,MAAM,CAAC;IACzF,MAAM,gBAAgB,GAAG,GAAqB,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnF,MAAM,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;IAClD,OAAO,GAAG,EAAE;QACX,MAAM,CAAC,0BAA0B,CAAC,gBAAgB,CAAC,CAAC;IACrD,CAAC,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAuB,EAAE,KAAmB;IACvE,uHAAuH;IACvH,6FAA6F;IAC7F,IAAI,WAAiC,CAAC;IACtC,IAAI,MAA0B,CAAC;IAE/B,OAAO,IAAA,iCAAsB,EAAC;QAC7B,YAAY,EAAE,CAAC,GAAG,EAAE,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;IAC3D,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IACvC,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,IAAA,iBAAM,EAAC,MAAM,CAAC,IAAI,qCAA6B,EAAE,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC7F,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACpC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,CAAC,IAAI,EAAE,CAAC;IACd,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAA,6BAAkB,EAAC,UAAU,CAAC,CAAC;QAC5C,IAAI,IAAI,YAAY,mBAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","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 {\n\tcreateAnnouncedVisitor,\n\tCursorLocationType,\n\ttype AnnouncedVisitor,\n\ttype FieldKey,\n\ttype IEditableForest,\n\ttype UpPath,\n} from \"../../core/index.js\";\nimport type { SchematizingSimpleTreeView } from \"../../shared-tree/index.js\";\nimport { TreeNode, treeNodeFromAnchor } from \"../core/index.js\";\nimport type { ImplicitFieldSchema } from \"../fieldSchema.js\";\n\nimport type { TreeViewAlpha } from \"./tree.js\";\n\n/**\n * The status of a node in a that has been {@link trackDirtyNodes | tracked for changes}.\n * @remarks Nodes can be marked \"new\", \"changed\", or \"moved\", with \"new\" taking precedence over \"changed\" and \"changed\" taking precedence over \"moved\".\n * * \"new\": The node was added.\n * * \"changed\": A direct child was updated, added, removed, or moved (and the node is not \"new\").\n * * \"moved\": The node was moved between/within arrays (and the node is not \"new\" or \"changed\").\n * @privateRemarks\n * It is unclear how this will handle forward compatibility with other kinds of edits, like moves that are not limited to arrays (attach, detach, swap):\n * this needs to be sorted out before this is stabilized.\n * It is also unclear how this is supposed to handle schema changes (which can result in new TreeNode instance, but I think won't trigger \"new\" here).\n * @alpha\n */\nexport type DirtyTreeStatus = \"new\" | \"changed\" | \"moved\";\n\n/**\n * A map-like interface for tracking the {@link DirtyTreeStatus | status} of nodes that have been {@link trackDirtyNodes | tracked for changes}.\n * @privateRemarks TODO: Replace this with `MapGetSet` from `@fluidframework/core-interfaces`.\n * @alpha\n */\nexport interface DirtyTreeMap {\n\tget(node: TreeNode): DirtyTreeStatus | undefined;\n\tset(node: TreeNode, status: DirtyTreeStatus): void;\n}\n\n/**\n * Registers a visitor on the view's forest that tracks which nodes are dirty.\n * @param view - The view to track dirty nodes on\n * @param dirty - A {@link DirtyTreeMap | map} that will be updated over time to reflect the {@link DirtyTreeStatus | status} of nodes as they change.\n * Nodes that have not changed will not be inserted/updated in the map.\n * @returns a cleanup function that should be called when the tracking is no longer needed.\n * @example\n * ```typescript\n * const dirty = new Map<TreeNode, DirtyTreeStatus>();\n * const stopTracking = trackDirtyNodes(view, dirty);\n * // ... make changes to the view ...\n * console.log(`The root of the tree is ${dirty.get(view.root) ?? \"unchanged\"}`);\n * stopTracking();\n * ```\n * @privateRemarks\n * This provides an opportunity for user code (\"set\" on dirty) to run during forest changes, in the middle of processing an edit.\n * We have generally avoided exposing such times to users and instead flush events after the edit has finished and user facing invariants are known to be restored.\n * Before stabilizing, how this event relates to other events time/ordering wise should be clarified, and if any APIs have been provided to defer events, that mentioned as well.\n * Maybe updates should be deferred?\n *\n * This is also documented in terms of \"forest\" which is not a concept in the public API, and thus needs to be redefined in terms of public concepts.\n * @alpha\n */\nexport function trackDirtyNodes(\n\tview: TreeViewAlpha<ImplicitFieldSchema>,\n\tdirty: DirtyTreeMap,\n): () => void {\n\tconst forest = (view as SchematizingSimpleTreeView<ImplicitFieldSchema>).checkout.forest;\n\tconst announcedVisitor = (): AnnouncedVisitor => createDirtyVisitor(forest, dirty);\n\tforest.registerAnnouncedVisitor(announcedVisitor);\n\treturn () => {\n\t\tforest.deregisterAnnouncedVisitor(announcedVisitor);\n\t};\n}\n\nfunction createDirtyVisitor(forest: IEditableForest, dirty: DirtyTreeMap): AnnouncedVisitor {\n\t// When cursor is in Fields mode, `parentField` is the field and `parent` is the parent node above that field (if any).\n\t// When cursor is in Nodes mode, `parent` is the current node and `parentField` is undefined.\n\tlet parentField: FieldKey | undefined;\n\tlet parent: UpPath | undefined;\n\n\treturn createAnnouncedVisitor({\n\t\tbeforeDetach: (src) => {\n\t\t\tassert(parent !== undefined, 0xc48 /* Expected node */);\n\t\t\tassert(parentField !== undefined, 0xc49 /* Expected field */);\n\t\t\tfor (let parentIndex = src.start; parentIndex < src.end; parentIndex++) {\n\t\t\t\tconst path: UpPath = {\n\t\t\t\t\tparent,\n\t\t\t\t\tparentField,\n\t\t\t\t\tparentIndex,\n\t\t\t\t};\n\t\t\t\t// The only way a detached node can be re-attached (and become visible/usable again) is via a move, so mark it as moved ahead of time.\n\t\t\t\tconst node = getNodeAtPath(forest, path);\n\t\t\t\tif (node !== undefined && dirty.get(node) === undefined) {\n\t\t\t\t\t// Only mark the node as moved if it is not already marked as something else.\n\t\t\t\t\tdirty.set(node, \"moved\");\n\t\t\t\t}\n\t\t\t\t// Mark the parent as changed unless it is already marked as new.\n\t\t\t\tconst parentNode = getNodeAtPath(forest, parent);\n\t\t\t\tif (parentNode !== undefined && dirty.get(parentNode) !== \"new\") {\n\t\t\t\t\tdirty.set(parentNode, \"changed\");\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tafterAttach: (_, dst) => {\n\t\t\tassert(parent !== undefined, 0xc4a /* Expected node */);\n\t\t\tassert(parentField !== undefined, 0xc4b /* Expected field */);\n\t\t\tfor (let parentIndex = dst.start; parentIndex < dst.end; parentIndex++) {\n\t\t\t\tconst path: UpPath = {\n\t\t\t\t\tparent,\n\t\t\t\t\tparentField,\n\t\t\t\t\tparentIndex,\n\t\t\t\t};\n\t\t\t\tconst node = getNodeAtPath(forest, path);\n\t\t\t\tif (node !== undefined && dirty.get(node) === undefined) {\n\t\t\t\t\t// Only mark the node as new if it is not already marked as something else - this ensures that a moved node is not marked as new (since nodes are marked move when detached).\n\t\t\t\t\tdirty.set(node, \"new\");\n\t\t\t\t}\n\t\t\t\t// Mark the parent as changed unless it is already marked as new.\n\t\t\t\tconst parentNode = getNodeAtPath(forest, parent);\n\t\t\t\tif (parentNode !== undefined && dirty.get(parentNode) !== \"new\") {\n\t\t\t\t\tdirty.set(parentNode, \"changed\");\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tenterNode(index: number): void {\n\t\t\tassert(parentField !== undefined, 0xc4c /* Expected field */);\n\t\t\tparent = {\n\t\t\t\tparent,\n\t\t\t\tparentField,\n\t\t\t\tparentIndex: index,\n\t\t\t};\n\t\t\tparentField = undefined;\n\t\t},\n\t\texitNode(): void {\n\t\t\tassert(parent !== undefined, 0xc4d /* Expected node */);\n\t\t\tparentField = parent.parentField;\n\t\t\tparent = parent.parent;\n\t\t},\n\t\tenterField: (key: FieldKey) => {\n\t\t\tparentField = key;\n\t\t},\n\t\texitField(): void {\n\t\t\tparentField = undefined;\n\t\t},\n\t});\n}\n\nfunction getNodeAtPath(forest: IEditableForest, path: UpPath): TreeNode | undefined {\n\tconst cursor = forest.allocateCursor();\n\tforest.moveCursorToPath(path, cursor);\n\tassert(cursor.mode === CursorLocationType.Nodes, 0xc4e /* attach should happen in a node */);\n\tconst anchor = cursor.buildAnchor();\n\tconst anchorNode = forest.anchors.locate(anchor);\n\tcursor.free();\n\tif (anchorNode !== undefined) {\n\t\tconst node = treeNodeFromAnchor(anchorNode);\n\t\tif (node instanceof TreeNode) {\n\t\t\treturn node;\n\t\t}\n\t}\n\treturn undefined;\n}\n"]}
@@ -4,7 +4,8 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.findExtraAllowedTypes = exports.getDiscrepanciesInAllowedContent = void 0;
7
+ exports.getDiscrepanciesInAllowedContent = getDiscrepanciesInAllowedContent;
8
+ exports.findExtraAllowedTypes = findExtraAllowedTypes;
8
9
  const internal_1 = require("@fluidframework/core-utils/internal");
9
10
  const index_js_1 = require("../../core/index.js");
10
11
  const index_js_2 = require("../../feature-libraries/index.js");
@@ -66,7 +67,6 @@ function* getDiscrepanciesInAllowedContent(view, stored, upgradeCollector) {
66
67
  // 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.
67
68
  }
68
69
  }
69
- exports.getDiscrepanciesInAllowedContent = getDiscrepanciesInAllowedContent;
70
70
  function* getNodeDiscrepancies(identifier, view, stored, upgradeCollector) {
71
71
  if (!doesNodeKindMatchStoredNodeKind(view.kind, getStoredNodeSchemaType(stored))) {
72
72
  yield {
@@ -148,7 +148,6 @@ function findExtraAllowedTypes(viewAllowedTypes, storedAllowedTypes) {
148
148
  stored,
149
149
  };
150
150
  }
151
- exports.findExtraAllowedTypes = findExtraAllowedTypes;
152
151
  /**
153
152
  * The function to track the discrepancies between a field view schema and a stored schema.
154
153
  *
@@ -1 +1 @@
1
- {"version":3,"file":"discrepancies.js","sourceRoot":"","sources":["../../../src/simple-tree/api/discrepancies.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAoF;AAEpF,kDAe6B;AAC7B,+DAA8D;AAC9D,kDAA4C;AAC5C,+CAM0B;AAC1B,sDAK2B;AAC3B,4DAAsD;AACtD,qDAMgC;AAChC,4DAAwD;AAGxD,mDAAyD;AA0HzD,SAAS,uBAAuB,CAAC,UAAgC;IAChE,IAAI,UAAU,YAAY,iCAAsB,EAAE,CAAC;QAClD,OAAO,iCAAsB,CAAC;IAC/B,CAAC;IACD,IAAI,UAAU,YAAY,8BAAmB,EAAE,CAAC;QAC/C,OAAO,8BAAmB,CAAC;I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AC;YACvB,CAAC,CAAC,IAAI,CAAC,0BAA0B,IAAI,MAAM,CAAC,IAAI,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,EACnF,CAAC;YACF,MAAM;gBACL,UAAU;gBACV,QAAQ;gBACR,QAAQ,EAAE,WAAW;gBACrB,IAAI,EAAE,iCAAsB,CAAC,IAAI;gBACjC,MAAM,EAAE,MAAM,CAAC,IAAI;aACY,CAAC;QAClC,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 { FieldKinds } from \"../../feature-libraries/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\tNodeKind,\n\tnormalizeAndEvaluateAnnotatedAllowedTypes,\n\ttype AnnotatedAllowedType,\n\ttype SchemaUpgrade,\n\ttype TreeNodeSchema,\n} from \"../core/index.js\";\nimport {\n\tcreateFieldSchema,\n\tFieldKind,\n\tFieldSchemaAlpha,\n\ttype FieldSchema,\n} from \"../fieldSchema.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.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 type { TreeSchema } from \"../treeSchema.js\";\n\nimport { tryStoredSchemaAsArray } from \"./customTree.js\";\n\n/**\n * Collects upgrade location data during a schema walk.\n * @remarks Called for each staged type or staged optional field encountered.\n */\nexport interface UpgradeLocationCollector {\n\t/**\n\t * Record a staged allowed type location.\n\t * @param upgrade - The upgrade token guarding this type.\n\t * @param isEnabled - Whether this type is present in stored schema.\n\t */\n\tallowedType(upgrade: SchemaUpgrade, isEnabled: boolean): void;\n\t/**\n\t * Record a staged optional field location.\n\t * @param upgrade - The upgrade token guarding this field.\n\t * @param isEnabled - Whether the stored field is already optional.\n\t */\n\toptionalField(upgrade: SchemaUpgrade, isEnabled: boolean): void;\n}\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\t/**\n\t * Whether the view field is a staged optional field.\n\t * Omitted when false.\n\t */\n\treadonly viewIsStagedOptional?: true;\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 * Staged allowed types in the view schema which are not allowed in stored schema.\n\t *\n\t * @remarks\n\t * These types do not cause the discrepancy and are omitted when there are none.\n\t */\n\treadonly stagedView?: 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 *\n * Optionally collects upgrade location information for staged schema upgrades during the same walk.\n *\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\tupgradeCollector?: UpgradeLocationCollector,\n): Iterable<Discrepancy> {\n\t// check root field discrepancies\n\tyield* getFieldDiscrepancies(\n\t\tview.root,\n\t\tstored.rootFieldSchema,\n\t\tundefined,\n\t\tundefined,\n\t\tupgradeCollector,\n\t);\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, upgradeCollector);\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\tupgradeCollector?: UpgradeLocationCollector,\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\tupgradeCollector,\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\tfalse,\n\t\t\t\tupgradeCollector,\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\tupgradeCollector,\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\tupgradeCollector,\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\" | \"stagedView\" | \"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 stagedView = 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 {\n\t\tview,\n\t\t...(stagedView.length === 0 ? {} : { stagedView }),\n\t\tstored,\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 * 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\tupgradeCollector?: UpgradeLocationCollector,\n): Iterable<FieldDiscrepancy> {\n\tassert(\n\t\tview instanceof FieldSchemaAlpha,\n\t\t0xbee /* all field schema should be FieldSchemaAlpha */,\n\t);\n\n\t// Collect staged-optional upgrade location if present.\n\tif (upgradeCollector !== undefined && view.isStagedOptional !== false) {\n\t\tupgradeCollector.optionalField(\n\t\t\tview.isStagedOptional,\n\t\t\tstored.kind === FieldKinds.optional.identifier,\n\t\t);\n\t}\n\n\tyield* getAllowedTypeDiscrepancies(\n\t\tview.allowedTypesFull.evaluate().types,\n\t\tstored.types,\n\t\tidentifier,\n\t\tfieldKey,\n\t\tview.isStagedOptional !== false,\n\t\tupgradeCollector,\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\t// A staged optional field (optional in the view) is compatible with a required stored field\n\t// during the rollout period — suppress the kind discrepancy in that case.\n\tif (\n\t\tviewKind.identifier !== stored.kind &&\n\t\t!(view.isStagedOptional !== false && stored.kind === FieldKinds.required.identifier)\n\t) {\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\t...(view.isStagedOptional === false ? {} : { viewIsStagedOptional: true }),\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\tviewIsStagedOptional: boolean,\n\tupgradeCollector?: UpgradeLocationCollector,\n): Iterable<FieldDiscrepancy> {\n\t// Collect staged allowed type upgrade locations if present.\n\tif (upgradeCollector !== undefined) {\n\t\tfor (const allowedType of view) {\n\t\t\tif (allowedType.metadata.stagedSchemaUpgrade !== undefined) {\n\t\t\t\tupgradeCollector.allowedType(\n\t\t\t\t\tallowedType.metadata.stagedSchemaUpgrade,\n\t\t\t\t\tstored.has(brand(allowedType.type.identifier)),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\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\t...(viewIsStagedOptional ? { viewIsStagedOptional: true } : {}),\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\tupgradeCollector?: UpgradeLocationCollector,\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\t...(fieldSchema instanceof FieldSchemaAlpha && fieldSchema.isStagedOptional !== false\n\t\t\t\t\t? { viewIsStagedOptional: true }\n\t\t\t\t\t: {}),\n\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t} else {\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\tfieldSchema,\n\t\t\t\tstoredSchema,\n\t\t\t\tidentifier,\n\t\t\t\tfieldKey,\n\t\t\t\tupgradeCollector,\n\t\t\t);\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"]}
1
+ {"version":3,"file":"discrepancies.js","sourceRoot":"","sources":["../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AC3B,WAAW,EACX,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,gBAAgB,CAChB,CAAC;QACH,CAAC;IACF,CAAC;IAED,KAAK,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC1D,IAAI,MAAM,CAAC,IAAI,KAAK,uCAA4B,EAAE,CAAC;YAClD,0DAA0D;YAC1D,qFAAqF;YACrF,2BAA2B;YAC3B,SAAS;QACV,CAAC;QAED,iEAAiE;QACjE,2FAA2F;QAC3F,gFAAgF;QAChF,IACC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;YACvB,CAAC,CAAC,IAAI,CAAC,0BAA0B,IAAI,MAAM,CAAC,IAAI,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,EACnF,CAAC;YACF,MAAM;gBACL,UAAU;gBACV,QAAQ;gBACR,QAAQ,EAAE,WAAW;gBACrB,IAAI,EAAE,iCAAsB,CAAC,IAAI;gBACjC,MAAM,EAAE,MAAM,CAAC,IAAI;aACY,CAAC;QAClC,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 { FieldKinds } from \"../../feature-libraries/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\tNodeKind,\n\tnormalizeAndEvaluateAnnotatedAllowedTypes,\n\ttype AnnotatedAllowedType,\n\ttype SchemaUpgrade,\n\ttype TreeNodeSchema,\n} from \"../core/index.js\";\nimport {\n\tcreateFieldSchema,\n\tFieldKind,\n\tFieldSchemaAlpha,\n\ttype FieldSchema,\n} from \"../fieldSchema.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.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 type { TreeSchema } from \"../treeSchema.js\";\n\nimport { tryStoredSchemaAsArray } from \"./customTree.js\";\n\n/**\n * Collects upgrade location data during a schema walk.\n * @remarks Called for each staged type or staged optional field encountered.\n */\nexport interface UpgradeLocationCollector {\n\t/**\n\t * Record a staged allowed type location.\n\t * @param upgrade - The upgrade token guarding this type.\n\t * @param isEnabled - Whether this type is present in stored schema.\n\t */\n\tallowedType(upgrade: SchemaUpgrade, isEnabled: boolean): void;\n\t/**\n\t * Record a staged optional field location.\n\t * @param upgrade - The upgrade token guarding this field.\n\t * @param isEnabled - Whether the stored field is already optional.\n\t */\n\toptionalField(upgrade: SchemaUpgrade, isEnabled: boolean): void;\n}\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\t/**\n\t * Whether the view field is a staged optional field.\n\t * Omitted when false.\n\t */\n\treadonly viewIsStagedOptional?: true;\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 * Staged allowed types in the view schema which are not allowed in stored schema.\n\t *\n\t * @remarks\n\t * These types do not cause the discrepancy and are omitted when there are none.\n\t */\n\treadonly stagedView?: 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 *\n * Optionally collects upgrade location information for staged schema upgrades during the same walk.\n *\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\tupgradeCollector?: UpgradeLocationCollector,\n): Iterable<Discrepancy> {\n\t// check root field discrepancies\n\tyield* getFieldDiscrepancies(\n\t\tview.root,\n\t\tstored.rootFieldSchema,\n\t\tundefined,\n\t\tundefined,\n\t\tupgradeCollector,\n\t);\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, upgradeCollector);\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\tupgradeCollector?: UpgradeLocationCollector,\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\tupgradeCollector,\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\tfalse,\n\t\t\t\tupgradeCollector,\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\tupgradeCollector,\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\tupgradeCollector,\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\" | \"stagedView\" | \"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 stagedView = 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 {\n\t\tview,\n\t\t...(stagedView.length === 0 ? {} : { stagedView }),\n\t\tstored,\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 * 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\tupgradeCollector?: UpgradeLocationCollector,\n): Iterable<FieldDiscrepancy> {\n\tassert(\n\t\tview instanceof FieldSchemaAlpha,\n\t\t0xbee /* all field schema should be FieldSchemaAlpha */,\n\t);\n\n\t// Collect staged-optional upgrade location if present.\n\tif (upgradeCollector !== undefined && view.isStagedOptional !== false) {\n\t\tupgradeCollector.optionalField(\n\t\t\tview.isStagedOptional,\n\t\t\tstored.kind === FieldKinds.optional.identifier,\n\t\t);\n\t}\n\n\tyield* getAllowedTypeDiscrepancies(\n\t\tview.allowedTypesFull.evaluate().types,\n\t\tstored.types,\n\t\tidentifier,\n\t\tfieldKey,\n\t\tview.isStagedOptional !== false,\n\t\tupgradeCollector,\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\t// A staged optional field (optional in the view) is compatible with a required stored field\n\t// during the rollout period — suppress the kind discrepancy in that case.\n\tif (\n\t\tviewKind.identifier !== stored.kind &&\n\t\t!(view.isStagedOptional !== false && stored.kind === FieldKinds.required.identifier)\n\t) {\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\t...(view.isStagedOptional === false ? {} : { viewIsStagedOptional: true }),\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\tviewIsStagedOptional: boolean,\n\tupgradeCollector?: UpgradeLocationCollector,\n): Iterable<FieldDiscrepancy> {\n\t// Collect staged allowed type upgrade locations if present.\n\tif (upgradeCollector !== undefined) {\n\t\tfor (const allowedType of view) {\n\t\t\tif (allowedType.metadata.stagedSchemaUpgrade !== undefined) {\n\t\t\t\tupgradeCollector.allowedType(\n\t\t\t\t\tallowedType.metadata.stagedSchemaUpgrade,\n\t\t\t\t\tstored.has(brand(allowedType.type.identifier)),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\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\t...(viewIsStagedOptional ? { viewIsStagedOptional: true } : {}),\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\tupgradeCollector?: UpgradeLocationCollector,\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\t...(fieldSchema instanceof FieldSchemaAlpha && fieldSchema.isStagedOptional !== false\n\t\t\t\t\t? { viewIsStagedOptional: true }\n\t\t\t\t\t: {}),\n\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t} else {\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\tfieldSchema,\n\t\t\t\tstoredSchema,\n\t\t\t\tidentifier,\n\t\t\t\tfieldKey,\n\t\t\t\tupgradeCollector,\n\t\t\t);\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"]}
@@ -4,7 +4,8 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.eraseSchemaDetailsSubclassable = exports.eraseSchemaDetails = void 0;
7
+ exports.eraseSchemaDetails = eraseSchemaDetails;
8
+ exports.eraseSchemaDetailsSubclassable = eraseSchemaDetailsSubclassable;
8
9
  /**
9
10
  * Type-erase details of a schema.
10
11
  *
@@ -57,7 +58,6 @@ exports.eraseSchemaDetailsSubclassable = exports.eraseSchemaDetails = void 0;
57
58
  function eraseSchemaDetails() {
58
59
  return (schema) => schema;
59
60
  }
60
- exports.eraseSchemaDetails = eraseSchemaDetails;
61
61
  /**
62
62
  * Like {@link eraseSchemaDetails} but allows the returned schema to be subclassed.
63
63
  * @example
@@ -108,5 +108,4 @@ exports.eraseSchemaDetails = eraseSchemaDetails;
108
108
  function eraseSchemaDetailsSubclassable() {
109
109
  return (schema) => schema;
110
110
  }
111
- exports.eraseSchemaDetailsSubclassable = eraseSchemaDetailsSubclassable;
112
111
  //# sourceMappingURL=eraseSchemaDetails.js.map