@fluidframework/tree 2.10.0 → 2.12.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 (776) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/api-report/tree.alpha.api.md +49 -18
  3. package/api-report/tree.beta.api.md +6 -15
  4. package/api-report/tree.legacy.alpha.api.md +6 -15
  5. package/api-report/tree.legacy.public.api.md +6 -15
  6. package/api-report/tree.public.api.md +6 -15
  7. package/dist/alpha.d.ts +9 -0
  8. package/dist/core/forest/forest.d.ts +10 -2
  9. package/dist/core/forest/forest.d.ts.map +1 -1
  10. package/dist/core/forest/forest.js.map +1 -1
  11. package/dist/core/index.d.ts +3 -3
  12. package/dist/core/index.d.ts.map +1 -1
  13. package/dist/core/index.js +6 -3
  14. package/dist/core/index.js.map +1 -1
  15. package/dist/core/rebase/utils.d.ts +1 -1
  16. package/dist/core/rebase/utils.d.ts.map +1 -1
  17. package/dist/core/rebase/utils.js +13 -17
  18. package/dist/core/rebase/utils.js.map +1 -1
  19. package/dist/core/revertible.d.ts +30 -1
  20. package/dist/core/revertible.d.ts.map +1 -1
  21. package/dist/core/revertible.js.map +1 -1
  22. package/dist/core/schema-stored/format.d.ts +0 -3
  23. package/dist/core/schema-stored/format.d.ts.map +1 -1
  24. package/dist/core/schema-stored/format.js.map +1 -1
  25. package/dist/core/schema-stored/schema.d.ts +12 -10
  26. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  27. package/dist/core/schema-stored/schema.js +3 -5
  28. package/dist/core/schema-stored/schema.js.map +1 -1
  29. package/dist/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  30. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  31. package/dist/core/schema-stored/storedSchemaRepository.js +5 -5
  32. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  33. package/dist/core/schema-view/index.d.ts +1 -1
  34. package/dist/core/schema-view/index.d.ts.map +1 -1
  35. package/dist/core/schema-view/index.js +1 -2
  36. package/dist/core/schema-view/index.js.map +1 -1
  37. package/dist/core/schema-view/view.d.ts +0 -7
  38. package/dist/core/schema-view/view.d.ts.map +1 -1
  39. package/dist/core/schema-view/view.js +1 -12
  40. package/dist/core/schema-view/view.js.map +1 -1
  41. package/dist/core/tree/anchorSet.d.ts +2 -2
  42. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  43. package/dist/core/tree/anchorSet.js +21 -21
  44. package/dist/core/tree/anchorSet.js.map +1 -1
  45. package/{lib/feature-libraries/chunked-forest → dist/core/tree}/chunk.d.ts +2 -1
  46. package/dist/core/tree/chunk.d.ts.map +1 -0
  47. package/dist/{feature-libraries/chunked-forest → core/tree}/chunk.js +2 -2
  48. package/dist/core/tree/chunk.js.map +1 -0
  49. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  50. package/dist/core/tree/detachedFieldIndexCodec.js +3 -2
  51. package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
  52. package/dist/core/tree/index.d.ts +2 -1
  53. package/dist/core/tree/index.d.ts.map +1 -1
  54. package/dist/core/tree/index.js +6 -1
  55. package/dist/core/tree/index.js.map +1 -1
  56. package/dist/core/tree/treeTextFormat.d.ts +0 -5
  57. package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
  58. package/dist/core/tree/treeTextFormat.js.map +1 -1
  59. package/dist/core/tree/types.d.ts +0 -5
  60. package/dist/core/tree/types.d.ts.map +1 -1
  61. package/dist/core/tree/types.js +0 -1
  62. package/dist/core/tree/types.js.map +1 -1
  63. package/dist/core/tree/visitorUtils.d.ts +25 -1
  64. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  65. package/dist/core/tree/visitorUtils.js +29 -1
  66. package/dist/core/tree/visitorUtils.js.map +1 -1
  67. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
  68. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/basicChunk.js +14 -14
  70. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  71. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
  72. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  73. package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -3
  74. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  75. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +5 -3
  76. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  77. package/dist/feature-libraries/chunked-forest/chunkedForest.js +24 -14
  78. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  79. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
  80. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  81. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  82. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
  83. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  84. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  85. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  86. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  87. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  88. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
  89. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  90. package/dist/feature-libraries/chunked-forest/emptyChunk.js +2 -3
  91. package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  92. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  93. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  94. package/dist/feature-libraries/chunked-forest/index.js +5 -5
  95. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  96. package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
  97. package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
  98. package/dist/feature-libraries/chunked-forest/sequenceChunk.js +2 -2
  99. package/dist/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  100. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
  101. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  102. package/dist/feature-libraries/chunked-forest/uniformChunk.js +14 -14
  103. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  104. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  105. package/dist/feature-libraries/default-schema/defaultSchema.js +1 -0
  106. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  107. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  108. package/dist/feature-libraries/default-schema/schemaChecker.js +2 -1
  109. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  110. package/dist/feature-libraries/flex-tree/context.d.ts +1 -1
  111. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  112. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  113. package/dist/feature-libraries/index.d.ts +2 -1
  114. package/dist/feature-libraries/index.d.ts.map +1 -1
  115. package/dist/feature-libraries/index.js +9 -2
  116. package/dist/feature-libraries/index.js.map +1 -1
  117. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +139 -0
  118. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
  119. package/dist/feature-libraries/indexing/anchorTreeIndex.js +387 -0
  120. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
  121. package/dist/feature-libraries/indexing/index.d.ts +7 -0
  122. package/dist/feature-libraries/indexing/index.d.ts.map +1 -0
  123. package/dist/feature-libraries/indexing/index.js +11 -0
  124. package/dist/feature-libraries/indexing/index.js.map +1 -0
  125. package/dist/feature-libraries/indexing/types.d.ts +32 -0
  126. package/dist/feature-libraries/indexing/types.d.ts.map +1 -0
  127. package/dist/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
  128. package/dist/feature-libraries/indexing/types.js.map +1 -0
  129. package/dist/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
  130. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  131. package/dist/feature-libraries/modular-schema/discrepancies.js +32 -33
  132. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  133. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  134. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  135. package/dist/feature-libraries/modular-schema/index.js +5 -1
  136. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  137. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
  138. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  139. package/dist/feature-libraries/modular-schema/isNeverTree.js +0 -1
  140. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  141. package/dist/feature-libraries/object-forest/objectForest.d.ts +5 -2
  142. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  143. package/dist/feature-libraries/object-forest/objectForest.js +21 -11
  144. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  145. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  146. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  147. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  148. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  149. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
  150. package/dist/feature-libraries/sequence-field/formatV1.d.ts +99 -99
  151. package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  152. package/dist/feature-libraries/sequence-field/formatV2.d.ts +76 -76
  153. package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  154. package/dist/feature-libraries/sequence-field/formatV3.d.ts +54 -54
  155. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  156. package/dist/feature-libraries/sequence-field/invert.js +2 -2
  157. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  158. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +3 -2
  159. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  160. package/dist/feature-libraries/sequence-field/types.d.ts +0 -1
  161. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  162. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  163. package/dist/index.d.ts +6 -7
  164. package/dist/index.d.ts.map +1 -1
  165. package/dist/index.js +3 -13
  166. package/dist/index.js.map +1 -1
  167. package/dist/packageVersion.d.ts +1 -1
  168. package/dist/packageVersion.js +1 -1
  169. package/dist/packageVersion.js.map +1 -1
  170. package/dist/shared-tree/index.d.ts +2 -2
  171. package/dist/shared-tree/index.d.ts.map +1 -1
  172. package/dist/shared-tree/index.js +1 -2
  173. package/dist/shared-tree/index.js.map +1 -1
  174. package/dist/shared-tree/schematizeTree.d.ts +1 -1
  175. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  176. package/dist/shared-tree/schematizeTree.js +6 -6
  177. package/dist/shared-tree/schematizeTree.js.map +1 -1
  178. package/dist/shared-tree/schematizingTreeView.d.ts +7 -1
  179. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  180. package/dist/shared-tree/schematizingTreeView.js +35 -38
  181. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  182. package/dist/shared-tree/sharedTree.d.ts +27 -6
  183. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  184. package/dist/shared-tree/sharedTree.js +146 -21
  185. package/dist/shared-tree/sharedTree.js.map +1 -1
  186. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  187. package/dist/shared-tree/sharedTreeChangeFamily.js +3 -3
  188. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  189. package/dist/shared-tree/treeCheckout.d.ts +59 -72
  190. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  191. package/dist/shared-tree/treeCheckout.js +243 -188
  192. package/dist/shared-tree/treeCheckout.js.map +1 -1
  193. package/dist/shared-tree-core/branch.d.ts +29 -107
  194. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  195. package/dist/shared-tree-core/branch.js +51 -195
  196. package/dist/shared-tree-core/branch.js.map +1 -1
  197. package/dist/shared-tree-core/branchCommitEnricher.d.ts +24 -32
  198. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  199. package/dist/shared-tree-core/branchCommitEnricher.js +70 -53
  200. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  201. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  202. package/dist/shared-tree-core/defaultResubmitMachine.js +2 -1
  203. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  204. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  205. package/dist/shared-tree-core/editManager.js +4 -4
  206. package/dist/shared-tree-core/editManager.js.map +1 -1
  207. package/dist/shared-tree-core/index.d.ts +3 -3
  208. package/dist/shared-tree-core/index.d.ts.map +1 -1
  209. package/dist/shared-tree-core/index.js +5 -4
  210. package/dist/shared-tree-core/index.js.map +1 -1
  211. package/dist/shared-tree-core/sharedTreeCore.d.ts +3 -10
  212. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  213. package/dist/shared-tree-core/sharedTreeCore.js +14 -67
  214. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  215. package/dist/shared-tree-core/transaction.d.ts +146 -0
  216. package/dist/shared-tree-core/transaction.d.ts.map +1 -0
  217. package/dist/shared-tree-core/transaction.js +211 -0
  218. package/dist/shared-tree-core/transaction.js.map +1 -0
  219. package/dist/shared-tree-core/transactionEnricher.d.ts +8 -13
  220. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  221. package/dist/shared-tree-core/transactionEnricher.js +41 -21
  222. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  223. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  224. package/dist/simple-tree/api/conciseTree.js +1 -1
  225. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  226. package/dist/simple-tree/api/create.d.ts.map +1 -1
  227. package/dist/simple-tree/api/create.js +5 -1
  228. package/dist/simple-tree/api/create.js.map +1 -1
  229. package/dist/simple-tree/api/customTree.d.ts +14 -2
  230. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  231. package/dist/simple-tree/api/customTree.js +53 -3
  232. package/dist/simple-tree/api/customTree.js.map +1 -1
  233. package/dist/simple-tree/api/identifierIndex.d.ts +21 -0
  234. package/dist/simple-tree/api/identifierIndex.d.ts.map +1 -0
  235. package/dist/simple-tree/api/identifierIndex.js +45 -0
  236. package/dist/simple-tree/api/identifierIndex.js.map +1 -0
  237. package/dist/simple-tree/api/index.d.ts +4 -2
  238. package/dist/simple-tree/api/index.d.ts.map +1 -1
  239. package/dist/simple-tree/api/index.js +8 -1
  240. package/dist/simple-tree/api/index.js.map +1 -1
  241. package/dist/simple-tree/api/schemaFactory.d.ts +48 -0
  242. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  243. package/dist/simple-tree/api/schemaFactory.js +5 -2
  244. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  245. package/dist/simple-tree/api/simpleSchema.d.ts +3 -1
  246. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
  247. package/dist/simple-tree/api/simpleSchema.js.map +1 -1
  248. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +9 -7
  249. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  250. package/dist/simple-tree/api/simpleTreeIndex.d.ts +65 -0
  251. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
  252. package/dist/simple-tree/api/simpleTreeIndex.js +93 -0
  253. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -0
  254. package/dist/simple-tree/api/storedSchema.d.ts +4 -4
  255. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  256. package/dist/simple-tree/api/storedSchema.js +8 -21
  257. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  258. package/dist/simple-tree/api/tree.d.ts +5 -5
  259. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  260. package/dist/simple-tree/api/tree.js.map +1 -1
  261. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  262. package/dist/simple-tree/api/verboseTree.js +1 -1
  263. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  264. package/dist/simple-tree/api/view.d.ts +14 -9
  265. package/dist/simple-tree/api/view.d.ts.map +1 -1
  266. package/dist/simple-tree/api/view.js +129 -40
  267. package/dist/simple-tree/api/view.js.map +1 -1
  268. package/dist/simple-tree/core/index.d.ts +1 -1
  269. package/dist/simple-tree/core/index.d.ts.map +1 -1
  270. package/dist/simple-tree/core/index.js +2 -1
  271. package/dist/simple-tree/core/index.js.map +1 -1
  272. package/dist/simple-tree/core/treeNodeKernel.d.ts +6 -2
  273. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  274. package/dist/simple-tree/core/treeNodeKernel.js +53 -22
  275. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  276. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  277. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  278. package/dist/simple-tree/core/unhydratedFlexTree.js +2 -2
  279. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  280. package/dist/simple-tree/index.d.ts +2 -2
  281. package/dist/simple-tree/index.d.ts.map +1 -1
  282. package/dist/simple-tree/index.js +7 -2
  283. package/dist/simple-tree/index.js.map +1 -1
  284. package/dist/simple-tree/leafNodeSchema.d.ts +0 -15
  285. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  286. package/dist/simple-tree/leafNodeSchema.js +0 -15
  287. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  288. package/dist/simple-tree/objectNode.d.ts +15 -5
  289. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  290. package/dist/simple-tree/objectNode.js +18 -2
  291. package/dist/simple-tree/objectNode.js.map +1 -1
  292. package/dist/simple-tree/objectNodeTypes.d.ts +4 -0
  293. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  294. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  295. package/dist/simple-tree/schemaTypes.d.ts +4 -2
  296. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  297. package/dist/simple-tree/schemaTypes.js.map +1 -1
  298. package/dist/simple-tree/toMapTree.js +3 -3
  299. package/dist/simple-tree/toMapTree.js.map +1 -1
  300. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  301. package/dist/simple-tree/toStoredSchema.js +18 -13
  302. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  303. package/dist/util/brand.d.ts +0 -2
  304. package/dist/util/brand.d.ts.map +1 -1
  305. package/dist/util/brand.js +0 -1
  306. package/dist/util/brand.js.map +1 -1
  307. package/dist/util/index.d.ts +1 -2
  308. package/dist/util/index.d.ts.map +1 -1
  309. package/dist/util/index.js +6 -4
  310. package/dist/util/index.js.map +1 -1
  311. package/dist/util/typeCheck.d.ts +6 -3
  312. package/dist/util/typeCheck.d.ts.map +1 -1
  313. package/dist/util/typeCheck.js.map +1 -1
  314. package/dist/util/typeCheckTests.d.ts +14 -2
  315. package/dist/util/typeCheckTests.d.ts.map +1 -1
  316. package/dist/util/typeCheckTests.js.map +1 -1
  317. package/dist/util/utils.d.ts +42 -0
  318. package/dist/util/utils.d.ts.map +1 -1
  319. package/dist/util/utils.js +35 -1
  320. package/dist/util/utils.js.map +1 -1
  321. package/lib/alpha.d.ts +9 -0
  322. package/lib/core/forest/forest.d.ts +10 -2
  323. package/lib/core/forest/forest.d.ts.map +1 -1
  324. package/lib/core/forest/forest.js.map +1 -1
  325. package/lib/core/index.d.ts +3 -3
  326. package/lib/core/index.d.ts.map +1 -1
  327. package/lib/core/index.js +3 -3
  328. package/lib/core/index.js.map +1 -1
  329. package/lib/core/rebase/utils.d.ts +1 -1
  330. package/lib/core/rebase/utils.d.ts.map +1 -1
  331. package/lib/core/rebase/utils.js +13 -17
  332. package/lib/core/rebase/utils.js.map +1 -1
  333. package/lib/core/revertible.d.ts +30 -1
  334. package/lib/core/revertible.d.ts.map +1 -1
  335. package/lib/core/revertible.js.map +1 -1
  336. package/lib/core/schema-stored/format.d.ts +0 -3
  337. package/lib/core/schema-stored/format.d.ts.map +1 -1
  338. package/lib/core/schema-stored/format.js.map +1 -1
  339. package/lib/core/schema-stored/schema.d.ts +12 -10
  340. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  341. package/lib/core/schema-stored/schema.js +3 -5
  342. package/lib/core/schema-stored/schema.js.map +1 -1
  343. package/lib/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  344. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  345. package/lib/core/schema-stored/storedSchemaRepository.js +1 -1
  346. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  347. package/lib/core/schema-view/index.d.ts +1 -1
  348. package/lib/core/schema-view/index.d.ts.map +1 -1
  349. package/lib/core/schema-view/index.js +1 -1
  350. package/lib/core/schema-view/index.js.map +1 -1
  351. package/lib/core/schema-view/view.d.ts +0 -7
  352. package/lib/core/schema-view/view.d.ts.map +1 -1
  353. package/lib/core/schema-view/view.js +0 -11
  354. package/lib/core/schema-view/view.js.map +1 -1
  355. package/lib/core/tree/anchorSet.d.ts +2 -2
  356. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  357. package/lib/core/tree/anchorSet.js +1 -1
  358. package/lib/core/tree/anchorSet.js.map +1 -1
  359. package/{dist/feature-libraries/chunked-forest → lib/core/tree}/chunk.d.ts +2 -1
  360. package/lib/core/tree/chunk.d.ts.map +1 -0
  361. package/lib/{feature-libraries/chunked-forest → core/tree}/chunk.js +1 -1
  362. package/lib/core/tree/chunk.js.map +1 -0
  363. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  364. package/lib/core/tree/detachedFieldIndexCodec.js +4 -3
  365. package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
  366. package/lib/core/tree/index.d.ts +2 -1
  367. package/lib/core/tree/index.d.ts.map +1 -1
  368. package/lib/core/tree/index.js +2 -1
  369. package/lib/core/tree/index.js.map +1 -1
  370. package/lib/core/tree/treeTextFormat.d.ts +0 -5
  371. package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
  372. package/lib/core/tree/treeTextFormat.js.map +1 -1
  373. package/lib/core/tree/types.d.ts +0 -5
  374. package/lib/core/tree/types.d.ts.map +1 -1
  375. package/lib/core/tree/types.js +0 -1
  376. package/lib/core/tree/types.js.map +1 -1
  377. package/lib/core/tree/visitorUtils.d.ts +25 -1
  378. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  379. package/lib/core/tree/visitorUtils.js +27 -0
  380. package/lib/core/tree/visitorUtils.js.map +1 -1
  381. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
  382. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  383. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  384. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  385. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
  386. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  387. package/lib/feature-libraries/chunked-forest/chunkTree.js +1 -2
  388. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  389. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +5 -3
  390. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  391. package/lib/feature-libraries/chunked-forest/chunkedForest.js +18 -8
  392. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  393. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
  394. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  395. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  396. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
  397. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  398. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  399. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  400. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  401. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  402. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
  403. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  404. package/lib/feature-libraries/chunked-forest/emptyChunk.js +1 -2
  405. package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  406. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  407. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  408. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  409. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  410. package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
  411. package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
  412. package/lib/feature-libraries/chunked-forest/sequenceChunk.js +1 -1
  413. package/lib/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  414. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
  415. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  416. package/lib/feature-libraries/chunked-forest/uniformChunk.js +4 -4
  417. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  418. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  419. package/lib/feature-libraries/default-schema/defaultSchema.js +1 -0
  420. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  421. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  422. package/lib/feature-libraries/default-schema/schemaChecker.js +2 -1
  423. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  424. package/lib/feature-libraries/flex-tree/context.d.ts +1 -1
  425. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  426. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  427. package/lib/feature-libraries/index.d.ts +2 -1
  428. package/lib/feature-libraries/index.d.ts.map +1 -1
  429. package/lib/feature-libraries/index.js +2 -1
  430. package/lib/feature-libraries/index.js.map +1 -1
  431. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +139 -0
  432. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
  433. package/lib/feature-libraries/indexing/anchorTreeIndex.js +382 -0
  434. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
  435. package/lib/feature-libraries/indexing/index.d.ts +7 -0
  436. package/lib/feature-libraries/indexing/index.d.ts.map +1 -0
  437. package/lib/{events → feature-libraries/indexing}/index.js +1 -1
  438. package/lib/feature-libraries/indexing/index.js.map +1 -0
  439. package/lib/feature-libraries/indexing/types.d.ts +32 -0
  440. package/lib/feature-libraries/indexing/types.d.ts.map +1 -0
  441. package/lib/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
  442. package/lib/feature-libraries/indexing/types.js.map +1 -0
  443. package/lib/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
  444. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  445. package/lib/feature-libraries/modular-schema/discrepancies.js +25 -28
  446. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  447. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  448. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  449. package/lib/feature-libraries/modular-schema/index.js +1 -1
  450. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  451. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
  452. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  453. package/lib/feature-libraries/modular-schema/isNeverTree.js +0 -1
  454. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  455. package/lib/feature-libraries/object-forest/objectForest.d.ts +5 -2
  456. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  457. package/lib/feature-libraries/object-forest/objectForest.js +15 -5
  458. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  459. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  460. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  461. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  462. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  463. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
  464. package/lib/feature-libraries/sequence-field/formatV1.d.ts +99 -99
  465. package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  466. package/lib/feature-libraries/sequence-field/formatV2.d.ts +76 -76
  467. package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  468. package/lib/feature-libraries/sequence-field/formatV3.d.ts +54 -54
  469. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  470. package/lib/feature-libraries/sequence-field/invert.js +4 -4
  471. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  472. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +4 -3
  473. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  474. package/lib/feature-libraries/sequence-field/types.d.ts +0 -1
  475. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  476. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  477. package/lib/index.d.ts +6 -7
  478. package/lib/index.d.ts.map +1 -1
  479. package/lib/index.js +3 -4
  480. package/lib/index.js.map +1 -1
  481. package/lib/packageVersion.d.ts +1 -1
  482. package/lib/packageVersion.js +1 -1
  483. package/lib/packageVersion.js.map +1 -1
  484. package/lib/shared-tree/index.d.ts +2 -2
  485. package/lib/shared-tree/index.d.ts.map +1 -1
  486. package/lib/shared-tree/index.js +1 -1
  487. package/lib/shared-tree/index.js.map +1 -1
  488. package/lib/shared-tree/schematizeTree.d.ts +1 -1
  489. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  490. package/lib/shared-tree/schematizeTree.js +7 -7
  491. package/lib/shared-tree/schematizeTree.js.map +1 -1
  492. package/lib/shared-tree/schematizingTreeView.d.ts +7 -1
  493. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  494. package/lib/shared-tree/schematizingTreeView.js +12 -16
  495. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  496. package/lib/shared-tree/sharedTree.d.ts +27 -6
  497. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  498. package/lib/shared-tree/sharedTree.js +135 -10
  499. package/lib/shared-tree/sharedTree.js.map +1 -1
  500. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  501. package/lib/shared-tree/sharedTreeChangeFamily.js +5 -5
  502. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  503. package/lib/shared-tree/treeCheckout.d.ts +59 -72
  504. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  505. package/lib/shared-tree/treeCheckout.js +233 -177
  506. package/lib/shared-tree/treeCheckout.js.map +1 -1
  507. package/lib/shared-tree-core/branch.d.ts +29 -107
  508. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  509. package/lib/shared-tree-core/branch.js +50 -193
  510. package/lib/shared-tree-core/branch.js.map +1 -1
  511. package/lib/shared-tree-core/branchCommitEnricher.d.ts +24 -32
  512. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  513. package/lib/shared-tree-core/branchCommitEnricher.js +71 -54
  514. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  515. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  516. package/lib/shared-tree-core/defaultResubmitMachine.js +3 -2
  517. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  518. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  519. package/lib/shared-tree-core/editManager.js +4 -4
  520. package/lib/shared-tree-core/editManager.js.map +1 -1
  521. package/lib/shared-tree-core/index.d.ts +3 -3
  522. package/lib/shared-tree-core/index.d.ts.map +1 -1
  523. package/lib/shared-tree-core/index.js +2 -2
  524. package/lib/shared-tree-core/index.js.map +1 -1
  525. package/lib/shared-tree-core/sharedTreeCore.d.ts +3 -10
  526. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  527. package/lib/shared-tree-core/sharedTreeCore.js +15 -68
  528. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  529. package/lib/shared-tree-core/transaction.d.ts +146 -0
  530. package/lib/shared-tree-core/transaction.d.ts.map +1 -0
  531. package/lib/shared-tree-core/transaction.js +206 -0
  532. package/lib/shared-tree-core/transaction.js.map +1 -0
  533. package/lib/shared-tree-core/transactionEnricher.d.ts +8 -13
  534. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  535. package/lib/shared-tree-core/transactionEnricher.js +41 -21
  536. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  537. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  538. package/lib/simple-tree/api/conciseTree.js +2 -2
  539. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  540. package/lib/simple-tree/api/create.d.ts.map +1 -1
  541. package/lib/simple-tree/api/create.js +5 -1
  542. package/lib/simple-tree/api/create.js.map +1 -1
  543. package/lib/simple-tree/api/customTree.d.ts +14 -2
  544. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  545. package/lib/simple-tree/api/customTree.js +50 -2
  546. package/lib/simple-tree/api/customTree.js.map +1 -1
  547. package/lib/simple-tree/api/identifierIndex.d.ts +21 -0
  548. package/lib/simple-tree/api/identifierIndex.d.ts.map +1 -0
  549. package/lib/simple-tree/api/identifierIndex.js +41 -0
  550. package/lib/simple-tree/api/identifierIndex.js.map +1 -0
  551. package/lib/simple-tree/api/index.d.ts +4 -2
  552. package/lib/simple-tree/api/index.d.ts.map +1 -1
  553. package/lib/simple-tree/api/index.js +4 -1
  554. package/lib/simple-tree/api/index.js.map +1 -1
  555. package/lib/simple-tree/api/schemaFactory.d.ts +48 -0
  556. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  557. package/lib/simple-tree/api/schemaFactory.js +4 -1
  558. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  559. package/lib/simple-tree/api/simpleSchema.d.ts +3 -1
  560. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
  561. package/lib/simple-tree/api/simpleSchema.js.map +1 -1
  562. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +11 -9
  563. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  564. package/lib/simple-tree/api/simpleTreeIndex.d.ts +65 -0
  565. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
  566. package/lib/simple-tree/api/simpleTreeIndex.js +89 -0
  567. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -0
  568. package/lib/simple-tree/api/storedSchema.d.ts +4 -4
  569. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  570. package/lib/simple-tree/api/storedSchema.js +5 -18
  571. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  572. package/lib/simple-tree/api/tree.d.ts +5 -5
  573. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  574. package/lib/simple-tree/api/tree.js.map +1 -1
  575. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  576. package/lib/simple-tree/api/verboseTree.js +2 -2
  577. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  578. package/lib/simple-tree/api/view.d.ts +14 -9
  579. package/lib/simple-tree/api/view.d.ts.map +1 -1
  580. package/lib/simple-tree/api/view.js +131 -42
  581. package/lib/simple-tree/api/view.js.map +1 -1
  582. package/lib/simple-tree/core/index.d.ts +1 -1
  583. package/lib/simple-tree/core/index.d.ts.map +1 -1
  584. package/lib/simple-tree/core/index.js +1 -1
  585. package/lib/simple-tree/core/index.js.map +1 -1
  586. package/lib/simple-tree/core/treeNodeKernel.d.ts +6 -2
  587. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  588. package/lib/simple-tree/core/treeNodeKernel.js +31 -1
  589. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  590. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  591. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  592. package/lib/simple-tree/core/unhydratedFlexTree.js +1 -1
  593. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  594. package/lib/simple-tree/index.d.ts +2 -2
  595. package/lib/simple-tree/index.d.ts.map +1 -1
  596. package/lib/simple-tree/index.js +2 -2
  597. package/lib/simple-tree/index.js.map +1 -1
  598. package/lib/simple-tree/leafNodeSchema.d.ts +0 -15
  599. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  600. package/lib/simple-tree/leafNodeSchema.js +0 -15
  601. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  602. package/lib/simple-tree/objectNode.d.ts +15 -5
  603. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  604. package/lib/simple-tree/objectNode.js +16 -1
  605. package/lib/simple-tree/objectNode.js.map +1 -1
  606. package/lib/simple-tree/objectNodeTypes.d.ts +4 -0
  607. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  608. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  609. package/lib/simple-tree/schemaTypes.d.ts +4 -2
  610. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  611. package/lib/simple-tree/schemaTypes.js.map +1 -1
  612. package/lib/simple-tree/toMapTree.js +5 -5
  613. package/lib/simple-tree/toMapTree.js.map +1 -1
  614. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  615. package/lib/simple-tree/toStoredSchema.js +19 -14
  616. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  617. package/lib/util/brand.d.ts +0 -2
  618. package/lib/util/brand.d.ts.map +1 -1
  619. package/lib/util/brand.js +0 -1
  620. package/lib/util/brand.js.map +1 -1
  621. package/lib/util/index.d.ts +1 -2
  622. package/lib/util/index.d.ts.map +1 -1
  623. package/lib/util/index.js +1 -2
  624. package/lib/util/index.js.map +1 -1
  625. package/lib/util/typeCheck.d.ts +6 -3
  626. package/lib/util/typeCheck.d.ts.map +1 -1
  627. package/lib/util/typeCheck.js.map +1 -1
  628. package/lib/util/typeCheckTests.d.ts +14 -2
  629. package/lib/util/typeCheckTests.d.ts.map +1 -1
  630. package/lib/util/typeCheckTests.js.map +1 -1
  631. package/lib/util/utils.d.ts +42 -0
  632. package/lib/util/utils.d.ts.map +1 -1
  633. package/lib/util/utils.js +30 -0
  634. package/lib/util/utils.js.map +1 -1
  635. package/package.json +23 -23
  636. package/src/core/forest/forest.ts +12 -1
  637. package/src/core/index.ts +13 -2
  638. package/src/core/rebase/utils.ts +28 -29
  639. package/src/core/revertible.ts +35 -1
  640. package/src/core/schema-stored/format.ts +0 -3
  641. package/src/core/schema-stored/schema.ts +13 -10
  642. package/src/core/schema-stored/storedSchemaRepository.ts +2 -1
  643. package/src/core/schema-view/index.ts +0 -1
  644. package/src/core/schema-view/view.ts +0 -11
  645. package/src/core/tree/anchorSet.ts +2 -1
  646. package/src/{feature-libraries/chunked-forest → core/tree}/chunk.ts +4 -4
  647. package/src/core/tree/detachedFieldIndexCodec.ts +4 -3
  648. package/src/core/tree/index.ts +9 -0
  649. package/src/core/tree/treeTextFormat.ts +0 -5
  650. package/src/core/tree/types.ts +0 -5
  651. package/src/core/tree/visitorUtils.ts +56 -1
  652. package/src/feature-libraries/chunked-forest/basicChunk.ts +4 -2
  653. package/src/feature-libraries/chunked-forest/chunkTree.ts +2 -1
  654. package/src/feature-libraries/chunked-forest/chunkedForest.ts +35 -8
  655. package/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +1 -2
  656. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +6 -2
  657. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -1
  658. package/src/feature-libraries/chunked-forest/emptyChunk.ts +4 -2
  659. package/src/feature-libraries/chunked-forest/index.ts +1 -1
  660. package/src/feature-libraries/chunked-forest/sequenceChunk.ts +1 -1
  661. package/src/feature-libraries/chunked-forest/uniformChunk.ts +7 -4
  662. package/src/feature-libraries/default-schema/defaultSchema.ts +1 -0
  663. package/src/feature-libraries/default-schema/schemaChecker.ts +4 -1
  664. package/src/feature-libraries/flex-tree/context.ts +1 -1
  665. package/src/feature-libraries/index.ts +22 -0
  666. package/src/feature-libraries/indexing/anchorTreeIndex.ts +482 -0
  667. package/src/feature-libraries/indexing/index.ts +11 -0
  668. package/src/feature-libraries/indexing/types.ts +37 -0
  669. package/src/feature-libraries/modular-schema/discrepancies.ts +76 -38
  670. package/src/feature-libraries/modular-schema/index.ts +13 -0
  671. package/src/feature-libraries/modular-schema/isNeverTree.ts +0 -2
  672. package/src/feature-libraries/object-forest/objectForest.ts +22 -4
  673. package/src/feature-libraries/sequence-field/invert.ts +4 -4
  674. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +4 -4
  675. package/src/feature-libraries/sequence-field/types.ts +0 -1
  676. package/src/index.ts +17 -35
  677. package/src/packageVersion.ts +1 -1
  678. package/src/shared-tree/index.ts +1 -2
  679. package/src/shared-tree/schematizeTree.ts +6 -10
  680. package/src/shared-tree/schematizingTreeView.ts +18 -28
  681. package/src/shared-tree/sharedTree.ts +216 -30
  682. package/src/shared-tree/sharedTreeChangeFamily.ts +5 -4
  683. package/src/shared-tree/treeCheckout.ts +341 -299
  684. package/src/shared-tree-core/branch.ts +80 -300
  685. package/src/shared-tree-core/branchCommitEnricher.ts +66 -62
  686. package/src/shared-tree-core/defaultResubmitMachine.ts +3 -2
  687. package/src/shared-tree-core/editManager.ts +4 -9
  688. package/src/shared-tree-core/index.ts +11 -3
  689. package/src/shared-tree-core/sharedTreeCore.ts +23 -79
  690. package/src/shared-tree-core/transaction.ts +310 -0
  691. package/src/shared-tree-core/transactionEnricher.ts +30 -24
  692. package/src/simple-tree/api/conciseTree.ts +2 -2
  693. package/src/simple-tree/api/create.ts +5 -1
  694. package/src/simple-tree/api/customTree.ts +69 -1
  695. package/src/simple-tree/api/identifierIndex.ts +64 -0
  696. package/src/simple-tree/api/index.ts +17 -2
  697. package/src/simple-tree/api/schemaFactory.ts +62 -1
  698. package/src/simple-tree/api/simpleSchema.ts +3 -1
  699. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -18
  700. package/src/simple-tree/api/simpleTreeIndex.ts +233 -0
  701. package/src/simple-tree/api/storedSchema.ts +7 -22
  702. package/src/simple-tree/api/tree.ts +14 -5
  703. package/src/simple-tree/api/treeNodeApi.ts +1 -1
  704. package/src/simple-tree/api/verboseTree.ts +2 -2
  705. package/src/simple-tree/api/view.ts +197 -51
  706. package/src/simple-tree/core/index.ts +1 -0
  707. package/src/simple-tree/core/treeNodeKernel.ts +37 -2
  708. package/src/simple-tree/core/unhydratedFlexTree.ts +2 -1
  709. package/src/simple-tree/index.ts +10 -0
  710. package/src/simple-tree/leafNodeSchema.ts +0 -19
  711. package/src/simple-tree/objectNode.ts +45 -14
  712. package/src/simple-tree/objectNodeTypes.ts +5 -0
  713. package/src/simple-tree/schemaTypes.ts +7 -2
  714. package/src/simple-tree/toMapTree.ts +5 -5
  715. package/src/simple-tree/toStoredSchema.ts +25 -19
  716. package/src/util/brand.ts +0 -2
  717. package/src/util/index.ts +4 -1
  718. package/src/util/typeCheck.ts +6 -3
  719. package/src/util/typeCheckTests.ts +11 -1
  720. package/src/util/utils.ts +64 -0
  721. package/dist/events/emitter.d.ts +0 -139
  722. package/dist/events/emitter.d.ts.map +0 -1
  723. package/dist/events/emitter.js +0 -165
  724. package/dist/events/emitter.js.map +0 -1
  725. package/dist/events/index.d.ts +0 -7
  726. package/dist/events/index.d.ts.map +0 -1
  727. package/dist/events/index.js +0 -11
  728. package/dist/events/index.js.map +0 -1
  729. package/dist/events/interop.d.ts +0 -30
  730. package/dist/events/interop.d.ts.map +0 -1
  731. package/dist/events/interop.js.map +0 -1
  732. package/dist/events/listeners.d.ts +0 -76
  733. package/dist/events/listeners.d.ts.map +0 -1
  734. package/dist/events/listeners.js +0 -7
  735. package/dist/events/listeners.js.map +0 -1
  736. package/dist/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
  737. package/dist/feature-libraries/chunked-forest/chunk.js.map +0 -1
  738. package/dist/shared-tree-core/transactionStack.d.ts +0 -29
  739. package/dist/shared-tree-core/transactionStack.d.ts.map +0 -1
  740. package/dist/shared-tree-core/transactionStack.js +0 -41
  741. package/dist/shared-tree-core/transactionStack.js.map +0 -1
  742. package/dist/util/transactionResult.d.ts +0 -19
  743. package/dist/util/transactionResult.d.ts.map +0 -1
  744. package/dist/util/transactionResult.js +0 -23
  745. package/dist/util/transactionResult.js.map +0 -1
  746. package/lib/events/emitter.d.ts +0 -139
  747. package/lib/events/emitter.d.ts.map +0 -1
  748. package/lib/events/emitter.js +0 -160
  749. package/lib/events/emitter.js.map +0 -1
  750. package/lib/events/index.d.ts +0 -7
  751. package/lib/events/index.d.ts.map +0 -1
  752. package/lib/events/index.js.map +0 -1
  753. package/lib/events/interop.d.ts +0 -30
  754. package/lib/events/interop.d.ts.map +0 -1
  755. package/lib/events/interop.js.map +0 -1
  756. package/lib/events/listeners.d.ts +0 -76
  757. package/lib/events/listeners.d.ts.map +0 -1
  758. package/lib/events/listeners.js +0 -6
  759. package/lib/events/listeners.js.map +0 -1
  760. package/lib/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
  761. package/lib/feature-libraries/chunked-forest/chunk.js.map +0 -1
  762. package/lib/shared-tree-core/transactionStack.d.ts +0 -29
  763. package/lib/shared-tree-core/transactionStack.d.ts.map +0 -1
  764. package/lib/shared-tree-core/transactionStack.js +0 -37
  765. package/lib/shared-tree-core/transactionStack.js.map +0 -1
  766. package/lib/util/transactionResult.d.ts +0 -19
  767. package/lib/util/transactionResult.d.ts.map +0 -1
  768. package/lib/util/transactionResult.js +0 -20
  769. package/lib/util/transactionResult.js.map +0 -1
  770. package/src/events/README.md +0 -3
  771. package/src/events/emitter.ts +0 -256
  772. package/src/events/index.ts +0 -19
  773. package/src/events/interop.ts +0 -38
  774. package/src/events/listeners.ts +0 -80
  775. package/src/shared-tree-core/transactionStack.ts +0 -45
  776. package/src/util/transactionResult.ts +0 -19
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchorTreeIndex.js","sourceRoot":"","sources":["../../../src/feature-libraries/indexing/anchorTreeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAKN,YAAY,EACZ,WAAW,EAEX,sBAAsB,EAItB,SAAS,EAGT,kBAAkB,EAClB,cAAc,GAEd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAenD;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IA4B3B;;;;;;;;OAQG;IACH,YACkB,MAA2B,EAC3B,OAEe,EACf,QAAyE,EACzE,eAA6D,EAC7D,iBAAiB,KAAK;QANtB,WAAM,GAAN,MAAM,CAAqB;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AAED;;GAEG;AACH,SAAS,WAAW,CACnB,WAA8C,EAC9C,MAAqC;IAErC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAI,KAAmB;IAChD,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;AAC1B,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 { disposeSymbol, fail, getOrCreate } from \"../../util/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorNode,\n\ttype FieldKey,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\tforEachNode,\n\ttype ITreeSubscriptionCursor,\n\tcreateAnnouncedVisitor,\n\ttype IForestSubscription,\n\ttype AnnouncedVisitor,\n\tCursorLocationType,\n\trootField,\n\ttype UpPath,\n\ttype ProtoNodes,\n\tkeyAsDetachedField,\n\tcompareUpPaths,\n\tTreeNavigationResult,\n} from \"../../core/index.js\";\nimport type { TreeIndex, TreeIndexKey, TreeIndexNodes } from \"./types.js\";\nimport { TreeStatus } from \"../flex-tree/index.js\";\n\n/**\n * A function that gets the value to index a node on, must be pure and functional.\n * The given cursor should point to the node that will be indexed.\n *\n * @returns a value the index will use as the key for the given node\n *\n * @remarks\n * This function does not own the cursor in any way, it walks the cursor to find the key the node is indexed on\n * but returns the cursor to the state it was in before being passed to the function. It should also not be disposed by this function\n * and must be disposed elsewhere.\n */\nexport type KeyFinder<TKey extends TreeIndexKey> = (tree: ITreeSubscriptionCursor) => TKey;\n\n/**\n * An index from some arbitrary keys to anchor nodes. Keys can be anything that is a {@link TreeValue}.\n * A key can map to multiple nodes but each collection of nodes only results in a single value.\n *\n * @remarks\n * Detached nodes are stored in the index but filtered out when any public facing apis are called. This means that\n * calling {@link keys} will not include any keys that are stored in the index but only map to detached nodes.\n */\nexport class AnchorTreeIndex<TKey extends TreeIndexKey, TValue>\n\timplements TreeIndex<TKey, TValue>\n{\n\tpublic disposed = false;\n\t/**\n\t * Caches {@link KeyFinder}s for each schema definition. If a schema maps to null, it does not\n\t * need to be considered at all for this index. This allows us to skip subtrees that aren't relevant\n\t * as a performance optimization.\n\t */\n\tprivate readonly keyFinders = new Map<TreeNodeSchemaIdentifier, KeyFinder<TKey> | null>();\n\t/**\n\t * The actual index from keys to anchor nodes.\n\t */\n\tprivate readonly keyToNodes = new Map<TKey, AnchorNode[]>();\n\t/**\n\t * Maintained for efficient removal of anchor nodes from the index when updating their keys\n\t */\n\tprivate readonly nodeToKey = new Map<AnchorNode, TKey>();\n\t/**\n\t * Keeps track of anchors for disposal.\n\t */\n\tprivate readonly anchors = new Map<AnchorNode, Anchor[]>();\n\t/**\n\t * The key finder that is registered on the forest to keep this index updated, maintained\n\t * here for deregistration on disposal\n\t */\n\tprivate readonly keyFinder = this.acquireVisitor.bind(this);\n\n\t/**\n\t * @param forest - the forest that is being indexed\n\t * @param indexer - a function that retrieves the key finder based on a given schema or undefined if the schema does not have an associated key finder\n\t * @param getValue - a pure and functional function that returns the associated value of one or more anchor nodes, can be used to map and filter the indexed anchor nodes\n\t * so that the values returned from the index are more usable\n\t * @param checkTreeStatus - a function that gets the tree status from an anchor node, used for filtering out detached nodes\n\t * @param isShallowIndex - indicates if this index is shallow, meaning that it only allows nodes to be keyed off of fields directly under them rather than anywhere in their subtree.\n\t * As a performance optimization, re-indexing up the spine can be turned off for shallow indexes.\n\t */\n\tpublic constructor(\n\t\tprivate readonly forest: IForestSubscription,\n\t\tprivate readonly indexer: (\n\t\t\tschemaId: TreeNodeSchemaIdentifier,\n\t\t) => KeyFinder<TKey> | undefined,\n\t\tprivate readonly getValue: (anchorNodes: TreeIndexNodes<AnchorNode>) => TValue | undefined,\n\t\tprivate readonly checkTreeStatus: (node: AnchorNode) => TreeStatus | undefined,\n\t\tprivate readonly isShallowIndex = false,\n\t) {\n\t\tthis.forest.registerAnnouncedVisitor(this.keyFinder);\n\n\t\tconst detachedFieldKeys: FieldKey[] = [];\n\t\tconst detachedFieldsCursor = forest.getCursorAboveDetachedFields();\n\t\tforEachField(detachedFieldsCursor, (field) => {\n\t\t\tdetachedFieldKeys.push(field.getFieldKey());\n\t\t});\n\n\t\t// index all existing trees (this includes the primary document tree and all other detached/removed trees)\n\t\tfor (const fieldKey of detachedFieldKeys) {\n\t\t\tconst cursor = forest.allocateCursor();\n\t\t\tforest.tryMoveCursorToField({ fieldKey, parent: undefined }, cursor);\n\t\t\tthis.indexField(cursor);\n\t\t\tcursor.free();\n\t\t}\n\t}\n\n\t/**\n\t * Creates an announced visitor that responds to edits to the forest and updates the index accordingly.\n\t */\n\tprivate acquireVisitor(): AnnouncedVisitor {\n\t\tthis.checkNotDisposed(\n\t\t\t\"visitor getter should be deregistered from the forest when index is disposed\",\n\t\t);\n\t\tlet parentField: FieldKey | undefined;\n\t\tlet parent: UpPath | undefined;\n\n\t\treturn createAnnouncedVisitor({\n\t\t\t// nodes (and their entire subtrees) are added to the index as soon as they are created\n\t\t\tafterCreate: (content: ProtoNodes, destination: FieldKey) => {\n\t\t\t\tconst detachedCursor = this.forest.allocateCursor();\n\t\t\t\tassert(\n\t\t\t\t\tthis.forest.tryMoveCursorToField(\n\t\t\t\t\t\t{ fieldKey: destination, parent: undefined },\n\t\t\t\t\t\tdetachedCursor,\n\t\t\t\t\t) === TreeNavigationResult.Ok,\n\t\t\t\t\t0xa8a /* destination of created nodes must be a valid detached field */,\n\t\t\t\t);\n\t\t\t\tthis.indexField(detachedCursor);\n\t\t\t\tdetachedCursor.free();\n\t\t\t},\n\t\t\tafterAttach: () => {\n\t\t\t\tassert(parent !== undefined, 0xa99 /* must have a parent */);\n\t\t\t\tthis.reIndexSpine(parent);\n\t\t\t},\n\t\t\tafterDetach: () => {\n\t\t\t\tassert(parent !== undefined, 0xa9a /* must have a parent */);\n\t\t\t\tthis.reIndexSpine(parent);\n\t\t\t},\n\t\t\t// when a replace happens, the keys of previously indexed nodes could be changed so we must re-index them\n\t\t\tafterReplace: () => {\n\t\t\t\tassert(parent !== undefined, 0xa8b /* must have a parent */);\n\t\t\t\tconst cursor = this.forest.allocateCursor();\n\t\t\t\tthis.forest.moveCursorToPath(parent, cursor);\n\t\t\t\tassert(\n\t\t\t\t\tcursor.mode === CursorLocationType.Nodes,\n\t\t\t\t\t0xa8c /* replace should happen in a node */,\n\t\t\t\t);\n\t\t\t\tcursor.exitNode();\n\t\t\t\tthis.indexField(cursor);\n\t\t\t\tif (!this.isShallowIndex) {\n\t\t\t\t\t// we must also re-index the spine if the key finders allow for any value under a subtree to be the key\n\t\t\t\t\t// this means that a replace can cause the key for any node up its spine to be changed\n\t\t\t\t\tthis.indexSpine(cursor);\n\t\t\t\t}\n\t\t\t\tcursor.clear();\n\t\t\t},\n\t\t\t// the methods below are used to keep track of the path that has been traversed by the visitor\n\t\t\t// this is required so that cursors can be moved to the correct location when index updates are required\n\t\t\tenterNode(index: number): void {\n\t\t\t\tassert(parentField !== undefined, 0xa8d /* must be in a field to enter node */);\n\n\t\t\t\tparent = {\n\t\t\t\t\tparent,\n\t\t\t\t\tparentField,\n\t\t\t\t\tparentIndex: index,\n\t\t\t\t};\n\t\t\t\tparentField = undefined;\n\t\t\t},\n\t\t\texitNode(index: number): void {\n\t\t\t\tassert(parent !== undefined, 0xa8e /* must have parent node */);\n\t\t\t\tconst temp = parent;\n\t\t\t\tparentField = temp.parentField;\n\t\t\t\tparent = temp.parent;\n\t\t\t},\n\t\t\tenterField: (key: FieldKey) => {\n\t\t\t\tparentField = key;\n\t\t\t},\n\t\t\texitField(key: FieldKey): void {\n\t\t\t\tparentField = undefined;\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Returns the value associated with the given key if it has been indexed\n\t */\n\tpublic get(key: TKey): TValue | undefined {\n\t\tthis.checkNotDisposed();\n\t\treturn this.getFilteredValue(this.keyToNodes.get(key));\n\t}\n\n\t/**\n\t * Returns true iff the key exists in the index\n\t */\n\tpublic has(key: TKey): boolean {\n\t\tthis.checkNotDisposed();\n\t\treturn this.get(key) !== undefined;\n\t}\n\n\t/**\n\t * Returns the number of values that are indexed\n\t */\n\tpublic get size(): number {\n\t\tthis.checkNotDisposed();\n\t\tlet s = 0;\n\t\tfor (const nodes of this.keyToNodes.values()) {\n\t\t\tif (this.getFilteredValue(nodes) !== undefined) {\n\t\t\t\ts += 1;\n\t\t\t}\n\t\t}\n\t\treturn s;\n\t}\n\n\t/**\n\t * Returns all keys in the index\n\t */\n\tpublic *keys(): IterableIterator<TKey> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tif (this.getFilteredValue(nodes) !== undefined) {\n\t\t\t\tyield key;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns an iterable of values in the index\n\t */\n\tpublic *values(): IterableIterator<TValue> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const nodes of this.keyToNodes.values()) {\n\t\t\tconst filtered = this.getFilteredValue(nodes);\n\t\t\tif (filtered !== undefined) {\n\t\t\t\tyield filtered;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the index\n\t */\n\tpublic *entries(): IterableIterator<[TKey, TValue]> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tconst filtered = this.getFilteredValue(nodes);\n\t\t\tif (filtered !== undefined) {\n\t\t\t\tyield [key, filtered];\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<[TKey, TValue]> {\n\t\tthis.checkNotDisposed();\n\t\treturn this.entries();\n\t}\n\n\t/**\n\t * Applies the provided callback to each entry in the index.\n\t */\n\tpublic forEach(\n\t\tcallbackfn: (value: TValue, key: TKey, map: AnchorTreeIndex<TKey, TValue>) => void,\n\t\tthisArg?: unknown,\n\t): void {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tconst filtered = this.getFilteredValue(nodes);\n\t\t\tif (filtered !== undefined) {\n\t\t\t\tcallbackfn.call(thisArg, filtered, key, this);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the index, including ones that are detached.\n\t * This function should only be used for testing purposes, it is not exposed as part of the public {@link TreeIndex} API.\n\t */\n\tpublic *allEntries(): IterableIterator<[TKey, TValue]> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tconst value = this.getValue(nodes as unknown as TreeIndexNodes<AnchorNode>);\n\t\t\tif (value !== undefined) {\n\t\t\t\tyield [key, value];\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic dispose(): void {\n\t\tthis[disposeSymbol]();\n\t}\n\n\t/**\n\t * Disposes this index and all the anchors it holds onto.\n\t */\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed(\"index is already disposed\");\n\t\tfor (const anchors of this.anchors.values()) {\n\t\t\tfor (const anchor of anchors) {\n\t\t\t\tthis.forest.forgetAnchor(anchor);\n\t\t\t}\n\t\t}\n\t\tthis.keyToNodes.clear();\n\t\tthis.anchors.clear();\n\t\tthis.forest.deregisterAnnouncedVisitor(this.keyFinder);\n\t\tthis.disposed = true;\n\t}\n\n\t/**\n\t * Checks if the spine needs to be re-indexed and if so, re-indexes it starting from the given path.\n\t */\n\tprivate reIndexSpine(path: UpPath): void {\n\t\tif (!this.isShallowIndex) {\n\t\t\tconst cursor = this.forest.allocateCursor();\n\t\t\tthis.forest.moveCursorToPath(path, cursor);\n\t\t\tassert(\n\t\t\t\tcursor.mode === CursorLocationType.Nodes,\n\t\t\t\t0xa9b /* attach should happen in a node */,\n\t\t\t);\n\t\t\tcursor.exitNode();\n\t\t\tthis.indexSpine(cursor);\n\t\t\tcursor.clear();\n\t\t}\n\t}\n\n\tprivate checkNotDisposed(errorMessage?: string): void {\n\t\tif (this.disposed) {\n\t\t\tif (errorMessage !== undefined) {\n\t\t\t\tthrow new Error(errorMessage);\n\t\t\t}\n\t\t\tassert(false, 0xa8f /* invalid operation on a disposed index */);\n\t\t}\n\t}\n\n\t/**\n\t * Given a cursor in node mode, indexes it.\n\t */\n\tprivate indexNode(nodeCursor: ITreeSubscriptionCursor): void {\n\t\tconst keyFinder = getOrCreate(\n\t\t\tthis.keyFinders,\n\t\t\t// the node schema type to look up\n\t\t\tnodeCursor.type,\n\t\t\t// if the indexer does not return a key finder for this schema, we cache a null value to indicate the indexer\n\t\t\t// does not need to be called if this schema is encountered in the future\n\t\t\t(schema) => this.indexer(schema) ?? null,\n\t\t);\n\n\t\tif (keyFinder !== null) {\n\t\t\tconst expectedPath = nodeCursor.getPath();\n\t\t\tconst key = keyFinder(nodeCursor);\n\t\t\t// TODO: determine perf impact of this check, alternative is not doing it in which case (if the key finder is not pure and functional),\n\t\t\t// an error may be thrown further down the line if the structure of the nodes aren't expected or the contents of the index could be inaccurate\n\t\t\tif (!compareUpPaths(nodeCursor.getPath(), expectedPath)) {\n\t\t\t\tthrow new Error(\"key finder should be pure and functional\");\n\t\t\t}\n\t\t\tconst anchor = nodeCursor.buildAnchor();\n\t\t\tconst anchorNode = this.forest.anchors.locate(anchor) ?? fail(\"expected anchor node\");\n\n\t\t\t// check if this anchor node already exists in the index\n\t\t\tconst existingKey = this.nodeToKey.get(anchorNode);\n\t\t\tif (existingKey !== undefined) {\n\t\t\t\t// if the node already exists but has the same key, we return early\n\t\t\t\tif (existingKey === key) {\n\t\t\t\t\tthis.forest.forgetAnchor(anchor);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\t// if the node has a different key, we remove the existing one first because it means the key had been detached\n\t\t\t\t\tthis.removeAnchor(anchorNode, existingKey);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tgetOrCreate(this.keyToNodes, key, () => []).push(anchorNode);\n\t\t\tthis.nodeToKey.set(anchorNode, key);\n\n\t\t\tgetOrCreate(this.anchors, anchorNode, () => []).push(anchor);\n\t\t\t// when the anchor node is destroyed, delete it from the index\n\t\t\tanchorNode.events.on(\"afterDestroy\", () => {\n\t\t\t\tthis.removeAnchor(anchorNode, key);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Given a cursor in field mode, recursively indexes all nodes under the field.\n\t */\n\tprivate indexField(fieldCursor: ITreeSubscriptionCursor): void {\n\t\tforEachNode(fieldCursor, (nodeCursor) => {\n\t\t\tthis.indexNode(nodeCursor);\n\n\t\t\tforEachField(nodeCursor, (f) => {\n\t\t\t\tthis.indexField(f);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Given a cursor in field mode, indexes all nodes under the field and then indexes all nodes up the spine.\n\t */\n\tprivate indexSpine(cursor: ITreeSubscriptionCursor): void {\n\t\tif (keyAsDetachedField(cursor.getFieldKey()) !== rootField) {\n\t\t\tcursor.exitField();\n\t\t\tcursor.exitNode();\n\t\t} else {\n\t\t\t// return early if we're already at the root field\n\t\t\treturn;\n\t\t}\n\n\t\t// walk up the spine and index nodes until we reach the root\n\t\twhile (\n\t\t\tcursor.mode === CursorLocationType.Fields &&\n\t\t\tkeyAsDetachedField(cursor.getFieldKey()) !== rootField\n\t\t) {\n\t\t\tforEachNode(cursor, (nodeCursor) => {\n\t\t\t\tthis.indexNode(nodeCursor);\n\t\t\t});\n\n\t\t\tcursor.exitField();\n\t\t\tcursor.exitNode();\n\t\t}\n\t}\n\n\tprivate removeAnchor(anchorNode: AnchorNode, key: TKey): void {\n\t\tconst indexedNodes = this.keyToNodes.get(key);\n\t\tassert(\n\t\t\tindexedNodes !== undefined,\n\t\t\t0xa90 /* destroyed anchor node should be tracked by index */,\n\t\t);\n\t\tconst index = indexedNodes.indexOf(anchorNode);\n\t\tassert(index !== -1, 0xa91 /* destroyed anchor node should be tracked by index */);\n\t\tconst newNodes = filterNodes(indexedNodes, (n) => n !== anchorNode);\n\t\tif (newNodes !== undefined && newNodes.length > 0) {\n\t\t\tthis.keyToNodes.set(key, newNodes);\n\t\t} else {\n\t\t\tthis.keyToNodes.delete(key);\n\t\t}\n\t\tthis.nodeToKey.delete(anchorNode);\n\t\tassert(\n\t\t\tthis.anchors.delete(anchorNode),\n\t\t\t0xa92 /* destroyed anchor should be tracked by index */,\n\t\t);\n\t}\n\n\t/**\n\t * Filters out any anchor nodes that are detached and returns the value for the remaining nodes.\n\t */\n\tprivate getFilteredValue(anchorNodes: AnchorNode[] | undefined): TValue | undefined {\n\t\tconst attachedNodes = filterNodes(anchorNodes, (anchorNode) => {\n\t\t\tconst nodeStatus = this.checkTreeStatus(anchorNode);\n\t\t\treturn nodeStatus === TreeStatus.InDocument;\n\t\t});\n\n\t\tif (attachedNodes !== undefined && hasElement(attachedNodes)) {\n\t\t\treturn this.getValue(attachedNodes);\n\t\t}\n\t}\n}\n\n/**\n * Filters the given anchor nodes based on the given filter function.\n */\nfunction filterNodes(\n\tanchorNodes: readonly AnchorNode[] | undefined,\n\tfilter: (node: AnchorNode) => boolean,\n): AnchorNode[] | undefined {\n\tif (anchorNodes !== undefined) {\n\t\treturn anchorNodes.filter(filter);\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Checks that an array is of the type {@link TreeIndexNodes} and has at least one element.\n */\nexport function hasElement<T>(array: readonly T[]): array is TreeIndexNodes<T> {\n\treturn array.length >= 1;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { AnchorTreeIndex, type KeyFinder, hasElement, } from "./anchorTreeIndex.js";
6
+ export type { TreeIndex, TreeIndexKey, TreeIndexNodes } from "./types.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/indexing/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EACf,KAAK,SAAS,EACd,UAAU,GACV,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
@@ -2,5 +2,5 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { createEmitter, EventEmitter, } from "./emitter.js";
5
+ export { AnchorTreeIndex, hasElement, } from "./anchorTreeIndex.js";
6
6
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/indexing/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EAEf,UAAU,GACV,MAAM,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tAnchorTreeIndex,\n\ttype KeyFinder,\n\thasElement,\n} from \"./anchorTreeIndex.js\";\nexport type { TreeIndex, TreeIndexKey, TreeIndexNodes } from \"./types.js\";\n"]}
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IFluidHandle } from "@fluidframework/core-interfaces";
6
+ /**
7
+ * an array of nodes that is guaranteed to have at least one element
8
+ *
9
+ * @alpha
10
+ */
11
+ export type TreeIndexNodes<TNode> = readonly [first: TNode, ...rest: TNode[]];
12
+ /**
13
+ * Value that may be used as keys in a {@link TreeIndex}.
14
+ *
15
+ * @privateRemarks
16
+ * no-new-null is disabled for this type so that it supports the TreeValue type.
17
+ *
18
+ * @alpha
19
+ */
20
+ export type TreeIndexKey = number | string | boolean | IFluidHandle | null;
21
+ /**
22
+ * A index where values are keyed on {@link TreeIndexKey}s.
23
+ *
24
+ * @alpha
25
+ */
26
+ export interface TreeIndex<TKey extends TreeIndexKey, TValue> extends ReadonlyMap<TKey, TValue> {
27
+ /**
28
+ * Disposes the index such that it can no longer be used and receives no updates from the forest
29
+ */
30
+ dispose(): void;
31
+ }
32
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/indexing/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,IAAI,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAE9E;;;;;;;GAOG;AAEH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,IAAI,CAAC;AAE3E;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,IAAI,SAAS,YAAY,EAAE,MAAM,CAC3D,SAAQ,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;IACjC;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB"}
@@ -3,4 +3,4 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=interop.js.map
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/feature-libraries/indexing/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","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\";\n\n/**\n * an array of nodes that is guaranteed to have at least one element\n *\n * @alpha\n */\nexport type TreeIndexNodes<TNode> = readonly [first: TNode, ...rest: TNode[]];\n\n/**\n * Value that may be used as keys in a {@link TreeIndex}.\n *\n * @privateRemarks\n * no-new-null is disabled for this type so that it supports the TreeValue type.\n *\n * @alpha\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport type TreeIndexKey = number | string | boolean | IFluidHandle | null;\n\n/**\n * A index where values are keyed on {@link TreeIndexKey}s.\n *\n * @alpha\n */\nexport interface TreeIndex<TKey extends TreeIndexKey, TValue>\n\textends ReadonlyMap<TKey, TValue> {\n\t/**\n\t * Disposes the index such that it can no longer be used and receives no updates from the forest\n\t */\n\tdispose(): void;\n}\n"]}
@@ -2,8 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type FieldKindIdentifier, type TreeStoredSchema, type ValueSchema } from "../../core/index.js";
5
+ import { type FieldKey, type FieldKindIdentifier, type TreeNodeSchemaIdentifier, type TreeStoredSchema, type ValueSchema } from "../../core/index.js";
6
6
  /**
7
+ * Discriminated union (keyed on `mismatch`) of discrepancies between a view and stored schema.
7
8
  * @remarks
8
9
  *
9
10
  * 1. FieldDiscrepancy
@@ -37,39 +38,64 @@ import { type FieldKindIdentifier, type TreeStoredSchema, type ValueSchema } fro
37
38
  */
38
39
  export type Discrepancy = FieldDiscrepancy | NodeDiscrepancy;
39
40
  export type NodeDiscrepancy = NodeKindDiscrepancy | NodeFieldsDiscrepancy;
41
+ /**
42
+ * A discrepancy in the declaration of a field.
43
+ */
40
44
  export type FieldDiscrepancy = AllowedTypeDiscrepancy | FieldKindDiscrepancy | ValueSchemaDiscrepancy;
41
- export interface AllowedTypeDiscrepancy {
42
- identifier: string | undefined;
45
+ /**
46
+ * Information about where a field discrepancy is located within a collection of schema.
47
+ */
48
+ export interface FieldDiscrepancyLocation {
49
+ /**
50
+ * The {@link TreeNodeSchemaIdentifier} that contains the discrepancy.
51
+ *
52
+ * Undefined iff the discrepancy is part of the root field schema.
53
+ */
54
+ identifier: TreeNodeSchemaIdentifier | undefined;
55
+ /**
56
+ * The {@link FieldKey} for the field that contains the discrepancy.
57
+ * Undefined when:
58
+ * - the discrepancy is part of the root field schema
59
+ * - the discrepancy is for 'all fields' of a map node
60
+ */
61
+ fieldKey: FieldKey | undefined;
62
+ }
63
+ /**
64
+ * A discrepancy in the allowed types of a field.
65
+ *
66
+ * @remarks
67
+ * This reports the symmetric difference of allowed types in view/stored to enable more efficient checks for compatibility
68
+ */
69
+ export interface AllowedTypeDiscrepancy extends FieldDiscrepancyLocation {
43
70
  mismatch: "allowedTypes";
44
71
  /**
45
- * List of allowed type identifiers in viewed schema
72
+ * List of allowed type identifiers in viewed schema which are not allowed in stored schema
46
73
  */
47
- view: string[];
74
+ view: TreeNodeSchemaIdentifier[];
48
75
  /**
49
- * List of allowed type identifiers in stored schema
76
+ * List of allowed type identifiers in stored schema which are not allowed in view schema
50
77
  */
51
- stored: string[];
78
+ stored: TreeNodeSchemaIdentifier[];
52
79
  }
53
- export interface FieldKindDiscrepancy {
54
- identifier: string | undefined;
80
+ export interface FieldKindDiscrepancy extends FieldDiscrepancyLocation {
55
81
  mismatch: "fieldKind";
56
82
  view: FieldKindIdentifier;
57
83
  stored: FieldKindIdentifier;
58
84
  }
59
85
  export interface ValueSchemaDiscrepancy {
60
- identifier: string;
86
+ identifier: TreeNodeSchemaIdentifier;
61
87
  mismatch: "valueSchema";
62
88
  view: ValueSchema | undefined;
63
89
  stored: ValueSchema | undefined;
64
90
  }
65
91
  export interface NodeKindDiscrepancy {
66
- identifier: string;
92
+ identifier: TreeNodeSchemaIdentifier;
67
93
  mismatch: "nodeKind";
68
94
  view: SchemaFactoryNodeKind | undefined;
69
95
  stored: SchemaFactoryNodeKind | undefined;
70
96
  }
71
97
  export interface NodeFieldsDiscrepancy {
72
- identifier: string;
98
+ identifier: TreeNodeSchemaIdentifier;
73
99
  mismatch: "fields";
74
100
  differences: FieldDiscrepancy[];
75
101
  }
@@ -77,19 +103,13 @@ type SchemaFactoryNodeKind = "object" | "leaf" | "map";
77
103
  /**
78
104
  * Finds and reports discrepancies between a view schema and a stored schema.
79
105
  *
80
- * The workflow for finding schema incompatibilities:
81
- * 1. Compare the two root schemas to identify any `FieldDiscrepancy`.
82
- *
83
- * 2. For each node schema in the `view`:
84
- * - Verify if the node schema exists in the stored. If it does, ensure that the `SchemaFactoryNodeKind` are
85
- * consistent. Otherwise this difference is treated as `NodeKindDiscrepancy`
86
- * - If a node schema with the same identifier exists in both view and stored, and their `SchemaFactoryNodeKind`
87
- * are consistent, perform a exhaustive validation to identify all `FieldDiscrepancy`.
88
- *
89
- * 3. For each node schema in the stored, verify if it exists in the view. The overlapping parts were already
90
- * addressed in the previous step.
106
+ * See documentation on {@link Discrepancy} for details of possible discrepancies.
107
+ * @remarks
108
+ * This function does not attempt to distinguish between equivalent representations of a node/field involving extraneous never trees.
109
+ * For example, a Forbidden field with allowed type set `[]` is equivalent to an optional field with allowed type set `[]`,
110
+ * as well as an optional field with an allowed type set containing only unconstructable types.
91
111
  *
92
- * @returns the discrepancies between two TreeStoredSchema objects
112
+ * It is up to the caller to determine whether such discrepancies matter.
93
113
  */
94
114
  export declare function getAllowedContentDiscrepancies(view: TreeStoredSchema, stored: TreeStoredSchema): Iterable<Discrepancy>;
95
115
  /**
@@ -110,5 +130,45 @@ export declare function getAllowedContentDiscrepancies(view: TreeStoredSchema, s
110
130
  * validating internal fields.
111
131
  */
112
132
  export declare function isRepoSuperset(view: TreeStoredSchema, stored: TreeStoredSchema): boolean;
133
+ /**
134
+ * A linear extension of a partially-ordered set of `T`s. See:
135
+ * https://en.wikipedia.org/wiki/Linear_extension
136
+ *
137
+ * The linear extension is represented as a lookup from each poset element to its index in the linear extension.
138
+ */
139
+ export type LinearExtension<T> = Map<T, number>;
140
+ /**
141
+ * A realizer for a partially-ordered set. See:
142
+ * https://en.wikipedia.org/wiki/Order_dimension
143
+ */
144
+ export type Realizer<T> = LinearExtension<T>[];
145
+ /**
146
+ * A realizer for the partial order of field kind relaxability.
147
+ *
148
+ * It seems extremely likely that this partial order will remain dimension 2 over time (i.e. the set of allowed relaxations can be visualized
149
+ * with a [dominance drawing](https://en.wikipedia.org/wiki/Dominance_drawing)), so this strategy allows efficient comarison between field kinds
150
+ * without excessive casework.
151
+ *
152
+ * Hasse diagram for the partial order is shown below (lower fields can be relaxed to higher fields):
153
+ * ```
154
+ * sequence
155
+ * |
156
+ * optional
157
+ * | \
158
+ * required forbidden
159
+ * |
160
+ * identifier
161
+ * ```
162
+ */
163
+ export declare const fieldRealizer: Realizer<FieldKindIdentifier>;
164
+ export declare const PosetComparisonResult: {
165
+ readonly Less: "<";
166
+ readonly Greater: ">";
167
+ readonly Equal: "=";
168
+ readonly Incomparable: "||";
169
+ };
170
+ type PosetComparisonResult = (typeof PosetComparisonResult)[keyof typeof PosetComparisonResult];
171
+ export declare function comparePosetElements<T>(a: T, b: T, realizer: Realizer<T>): PosetComparisonResult;
172
+ export declare function posetLte<T>(a: T, b: T, realizer: Realizer<T>): boolean;
113
173
  export {};
114
174
  //# sourceMappingURL=discrepancies.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"discrepancies.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/discrepancies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,mBAAmB,EAQxB,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAChB,MAAM,qBAAqB,CAAC;AAO7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAE7D,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAE1E,MAAM,MAAM,gBAAgB,GACzB,sBAAsB,GACtB,oBAAoB,GACpB,sBAAsB,CAAC;AAE1B,MAAM,WAAW,sBAAsB;IACtC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,cAAc,CAAC;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACpC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,WAAW,CAAC;IACtB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,MAAM,EAAE,mBAAmB,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC;IAC9B,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,UAAU,CAAC;IACrB,IAAI,EAAE,qBAAqB,GAAG,SAAS,CAAC;IACxC,MAAM,EAAE,qBAAqB,GAAG,SAAS,CAAC;CAC1C;AAED,MAAM,WAAW,qBAAqB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAED,KAAK,qBAAqB,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAavD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAiB,8BAA8B,CAC9C,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,gBAAgB,GACtB,QAAQ,CAAC,WAAW,CAAC,CAkCvB;AAkLD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAkCxF"}
1
+ {"version":3,"file":"discrepancies.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/discrepancies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,mBAAmB,EAMxB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ports discrepancies between a view schema and a stored schema.
22
22
  *
23
- * The workflow for finding schema incompatibilities:
24
- * 1. Compare the two root schemas to identify any `FieldDiscrepancy`.
25
- *
26
- * 2. For each node schema in the `view`:
27
- * - Verify if the node schema exists in the stored. If it does, ensure that the `SchemaFactoryNodeKind` are
28
- * consistent. Otherwise this difference is treated as `NodeKindDiscrepancy`
29
- * - If a node schema with the same identifier exists in both view and stored, and their `SchemaFactoryNodeKind`
30
- * are consistent, perform a exhaustive validation to identify all `FieldDiscrepancy`.
31
- *
32
- * 3. For each node schema in the stored, verify if it exists in the view. The overlapping parts were already
33
- * addressed in the previous step.
23
+ * See documentation on {@link Discrepancy} for details of possible discrepancies.
24
+ * @remarks
25
+ * This function does not attempt to distinguish between equivalent representations of a node/field involving extraneous never trees.
26
+ * For example, a Forbidden field with allowed type set `[]` is equivalent to an optional field with allowed type set `[]`,
27
+ * as well as an optional field with an allowed type set containing only unconstructable types.
34
28
  *
35
- * @returns the discrepancies between two TreeStoredSchema objects
29
+ * It is up to the caller to determine whether such discrepancies matter.
36
30
  */
37
31
  export function* getAllowedContentDiscrepancies(view, stored) {
38
32
  // check root schema discrepancies
39
- yield* getFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema);
33
+ yield* getFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema, undefined, undefined);
40
34
  for (const result of compareMaps(view.nodeSchema, stored.nodeSchema)) {
41
35
  switch (result.type) {
42
36
  case "aExtra": {
@@ -82,7 +76,7 @@ function* getNodeDiscrepancies(identifier, view, stored) {
82
76
  }
83
77
  switch (viewType) {
84
78
  case "object": {
85
- const differences = Array.from(trackObjectNodeDiscrepancies(view, stored));
79
+ const differences = Array.from(trackObjectNodeDiscrepancies(identifier, view, stored));
86
80
  if (differences.length > 0) {
87
81
  yield {
88
82
  identifier,
@@ -93,7 +87,7 @@ function* getNodeDiscrepancies(identifier, view, stored) {
93
87
  break;
94
88
  }
95
89
  case "map":
96
- yield* getFieldDiscrepancies(view.mapFields, stored.mapFields, identifier);
90
+ yield* getFieldDiscrepancies(view.mapFields, stored.mapFields, identifier, undefined);
97
91
  break;
98
92
  case "leaf": {
99
93
  const viewValue = view.leafValue;
@@ -117,7 +111,7 @@ function* getNodeDiscrepancies(identifier, view, stored) {
117
111
  *
118
112
  * @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.
119
113
  */
120
- function* getFieldDiscrepancies(view, stored, keyOrRoot) {
114
+ function* getFieldDiscrepancies(view, stored, identifier, fieldKey) {
121
115
  // Only track the symmetric differences of two sets.
122
116
  const findSetDiscrepancies = (a, b) => {
123
117
  const aDiff = [...a].filter((value) => !b.has(value));
@@ -127,7 +121,8 @@ function* getFieldDiscrepancies(view, stored, keyOrRoot) {
127
121
  const [viewExtra, storedExtra] = findSetDiscrepancies(view.types, stored.types);
128
122
  if (viewExtra.length > 0 || storedExtra.length > 0) {
129
123
  yield {
130
- identifier: keyOrRoot,
124
+ identifier,
125
+ fieldKey,
131
126
  mismatch: "allowedTypes",
132
127
  view: viewExtra,
133
128
  stored: storedExtra,
@@ -135,14 +130,15 @@ function* getFieldDiscrepancies(view, stored, keyOrRoot) {
135
130
  }
136
131
  if (view.kind !== stored.kind) {
137
132
  yield {
138
- identifier: keyOrRoot,
133
+ identifier,
134
+ fieldKey,
139
135
  mismatch: "fieldKind",
140
136
  view: view.kind,
141
137
  stored: stored.kind,
142
138
  };
143
139
  }
144
140
  }
145
- function* trackObjectNodeDiscrepancies(view, stored) {
141
+ function* trackObjectNodeDiscrepancies(identifier, view, stored) {
146
142
  /**
147
143
  * Similar to the logic used for tracking discrepancies between two node schemas, we will identify
148
144
  * three types of differences:
@@ -163,7 +159,8 @@ function* trackObjectNodeDiscrepancies(view, stored) {
163
159
  break;
164
160
  }
165
161
  yield {
166
- identifier: fieldKey,
162
+ identifier,
163
+ fieldKey,
167
164
  mismatch: "fieldKind",
168
165
  view: result.value.kind,
169
166
  stored: storedEmptyFieldSchema.kind,
@@ -177,7 +174,8 @@ function* trackObjectNodeDiscrepancies(view, stored) {
177
174
  break;
178
175
  }
179
176
  yield {
180
- identifier: fieldKey,
177
+ identifier,
178
+ fieldKey,
181
179
  mismatch: "fieldKind",
182
180
  view: storedEmptyFieldSchema.kind,
183
181
  stored: result.value.kind,
@@ -185,12 +183,11 @@ function* trackObjectNodeDiscrepancies(view, stored) {
185
183
  break;
186
184
  }
187
185
  case "both": {
188
- yield* getFieldDiscrepancies(result.valueA, result.valueB, fieldKey);
186
+ yield* getFieldDiscrepancies(result.valueA, result.valueB, identifier, fieldKey);
189
187
  break;
190
188
  }
191
- default: {
189
+ default:
192
190
  break;
193
- }
194
191
  }
195
192
  }
196
193
  }
@@ -303,7 +300,7 @@ const FieldKindIdentifiers = {
303
300
  * identifier
304
301
  * ```
305
302
  */
306
- const fieldRealizer = [
303
+ export const fieldRealizer = [
307
304
  [
308
305
  FieldKindIdentifiers.forbidden,
309
306
  FieldKindIdentifiers.identifier,
@@ -319,13 +316,13 @@ const fieldRealizer = [
319
316
  FieldKindIdentifiers.sequence,
320
317
  ],
321
318
  ].map((extension) => new Map(extension.map((identifier, index) => [identifier, index])));
322
- const PosetComparisonResult = {
319
+ export const PosetComparisonResult = {
323
320
  Less: "<",
324
321
  Greater: ">",
325
322
  Equal: "=",
326
323
  Incomparable: "||",
327
324
  };
328
- function comparePosetElements(a, b, realizer) {
325
+ export function comparePosetElements(a, b, realizer) {
329
326
  let hasLessThanResult = false;
330
327
  let hasGreaterThanResult = false;
331
328
  for (const extension of realizer) {
@@ -347,7 +344,7 @@ function comparePosetElements(a, b, realizer) {
347
344
  ? PosetComparisonResult.Greater
348
345
  : PosetComparisonResult.Equal;
349
346
  }
350
- function posetLte(a, b, realizer) {
347
+ export function posetLte(a, b, realizer) {
351
348
  const comparison = comparePosetElements(a, b, realizer);
352
349
  return (comparison === PosetComparisonResult.Less || comparison === PosetComparisonResult.Equal);
353
350
  }
@@ -1 +1 @@
1
- {"version":3,"file":"discrepancies.js","sourceRoot":"","sources":["../../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AC,CAAC;QAChC,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACnF,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;YACrB,iBAAiB,GAAG,IAAI,CAAC;QAC1B,CAAC;aAAM,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;YAC5B,oBAAoB,GAAG,IAAI,CAAC;QAC7B,CAAC;IACF,CAAC;IAED,OAAO,iBAAiB;QACvB,CAAC,CAAC,oBAAoB;YACrB,CAAC,CAAC,qBAAqB,CAAC,YAAY;YACpC,CAAC,CAAC,qBAAqB,CAAC,IAAI;QAC7B,CAAC,CAAC,oBAAoB;YACrB,CAAC,CAAC,qBAAqB,CAAC,OAAO;YAC/B,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC;AACjC,CAAC;AAED,SAAS,QAAQ,CAAI,CAAI,EAAE,CAAI,EAAE,QAAqB;IACrD,MAAM,UAAU,GAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IACxD,OAAO,CACN,UAAU,KAAK,qBAAqB,CAAC,IAAI,IAAI,UAAU,KAAK,qBAAqB,CAAC,KAAK,CACvF,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAY;IAC7C,MAAM,IAAI,SAAS,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;AACrE,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\ttype FieldKindIdentifier,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tstoredEmptyFieldSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n\ttype ValueSchema,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\n\n// TODO:\n// The comparisons in this file seem redundant with those in comparison.ts.\n// Rather than both existing, one of which just returns boolean and the other which returns additional details, a simple comparison which returns everything needed should be used.\n\n/**\n * @remarks\n *\n * 1. FieldDiscrepancy\n *\n * `FieldDiscrepancy` represents the differences between two `TreeFieldStoredSchema` objects. It consists of\n * three types of incompatibilities:\n *\n * - FieldKindDiscrepancy: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`\n * objects (e.g., optional, required, sequence, etc.).\n * - AllowedTypesDiscrepancy: Indicates the differences in the allowed child types between the two schemas.\n * - ValueSchemaDiscrepancy: Specifically indicates the differences in the `ValueSchema` of two\n * `LeafNodeStoredSchema` objects.\n *\n * 2. NodeDiscrepancy\n *\n * `NodeDiscrepancy` represents the differences between two `TreeNodeStoredSchema` objects and includes:\n *\n * - NodeKindDiscrepancy: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports\n * `ObjectNodeStoredSchema`, `MapNodeStoredSchema`, and `LeafNodeStoredSchema`).\n * - NodeFieldsDiscrepancy: Indicates the `FieldDiscrepancy` of `TreeFieldStoredSchema` within two\n * `TreeNodeStoredSchema`. It includes an array of `FieldDiscrepancy` instances in the `differences` field.\n *\n * When comparing two nodes for compatibility, it only makes sense to compare their fields if the nodes are of\n * the same kind (map, object, leaf).\n *\n * 3. Discrepancy\n *\n * Discrepancy consists of both `NodeDiscrepancy` and `FieldDiscrepancy`, representing any kind of\n * schema differences. See {@link getAllowedContentDiscrepancies} for more details about how we process it\n * and the ordering.\n */\nexport type Discrepancy = FieldDiscrepancy | NodeDiscrepancy;\n\nexport type NodeDiscrepancy = NodeKindDiscrepancy | NodeFieldsDiscrepancy;\n\nexport type FieldDiscrepancy =\n\t| AllowedTypeDiscrepancy\n\t| FieldKindDiscrepancy\n\t| ValueSchemaDiscrepancy;\n\nexport interface AllowedTypeDiscrepancy {\n\tidentifier: string | undefined; // undefined indicates root field schema\n\tmismatch: \"allowedTypes\";\n\t/**\n\t * List of allowed type identifiers in viewed schema\n\t */\n\tview: string[];\n\t/**\n\t * List of allowed type identifiers in stored schema\n\t */\n\tstored: string[];\n}\n\nexport interface FieldKindDiscrepancy {\n\tidentifier: string | undefined; // undefined indicates root field schema\n\tmismatch: \"fieldKind\";\n\tview: FieldKindIdentifier;\n\tstored: FieldKindIdentifier;\n}\n\nexport interface ValueSchemaDiscrepancy {\n\tidentifier: string;\n\tmismatch: \"valueSchema\";\n\tview: ValueSchema | undefined;\n\tstored: ValueSchema | undefined;\n}\n\nexport interface NodeKindDiscrepancy {\n\tidentifier: string;\n\tmismatch: \"nodeKind\";\n\tview: SchemaFactoryNodeKind | undefined;\n\tstored: SchemaFactoryNodeKind | undefined;\n}\n\nexport interface NodeFieldsDiscrepancy {\n\tidentifier: string;\n\tmismatch: \"fields\";\n\tdifferences: FieldDiscrepancy[];\n}\n\ntype SchemaFactoryNodeKind = \"object\" | \"leaf\" | \"map\";\n\nfunction getNodeSchemaType(nodeSchema: TreeNodeStoredSchema): SchemaFactoryNodeKind {\n\tif (nodeSchema instanceof ObjectNodeStoredSchema) {\n\t\treturn \"object\";\n\t} else if (nodeSchema instanceof MapNodeStoredSchema) {\n\t\treturn \"map\";\n\t} else if (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\treturn \"leaf\";\n\t}\n\tthrowUnsupportedNodeType(nodeSchema.constructor.name);\n}\n\n/**\n * Finds and reports discrepancies between a view schema and a stored schema.\n *\n * The workflow for finding schema incompatibilities:\n * 1. Compare the two root schemas to identify any `FieldDiscrepancy`.\n *\n * 2. For each node schema in the `view`:\n * - Verify if the node schema exists in the stored. If it does, ensure that the `SchemaFactoryNodeKind` are\n * consistent. Otherwise this difference is treated as `NodeKindDiscrepancy`\n * - If a node schema with the same identifier exists in both view and stored, and their `SchemaFactoryNodeKind`\n * are consistent, perform a exhaustive validation to identify all `FieldDiscrepancy`.\n *\n * 3. For each node schema in the stored, verify if it exists in the view. The overlapping parts were already\n * addressed in the previous step.\n *\n * @returns the discrepancies between two TreeStoredSchema objects\n */\nexport function* getAllowedContentDiscrepancies(\n\tview: TreeStoredSchema,\n\tstored: TreeStoredSchema,\n): Iterable<Discrepancy> {\n\t// check root schema discrepancies\n\tyield* getFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema);\n\n\tfor (const result of compareMaps(view.nodeSchema, stored.nodeSchema)) {\n\t\tswitch (result.type) {\n\t\t\tcase \"aExtra\": {\n\t\t\t\tconst viewType = getNodeSchemaType(result.value);\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: result.key,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: viewType,\n\t\t\t\t\tstored: undefined,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"bExtra\": {\n\t\t\t\tconst storedType = getNodeSchemaType(result.value);\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: result.key,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: undefined,\n\t\t\t\t\tstored: storedType,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"both\": {\n\t\t\t\tyield* getNodeDiscrepancies(result.key, result.valueA, result.valueB);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction* getNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: TreeNodeStoredSchema,\n\tstored: TreeNodeStoredSchema,\n): Iterable<Discrepancy> {\n\tconst viewType = getNodeSchemaType(view);\n\tconst storedType = getNodeSchemaType(stored);\n\tif (viewType !== storedType) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tmismatch: \"nodeKind\",\n\t\t\tview: viewType,\n\t\t\tstored: storedType,\n\t\t};\n\t\treturn;\n\t}\n\n\tswitch (viewType) {\n\t\tcase \"object\": {\n\t\t\tconst differences = Array.from(\n\t\t\t\ttrackObjectNodeDiscrepancies(\n\t\t\t\t\tview as ObjectNodeStoredSchema,\n\t\t\t\t\tstored as ObjectNodeStoredSchema,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (differences.length > 0) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"fields\",\n\t\t\t\t\tdifferences,\n\t\t\t\t} satisfies NodeFieldsDiscrepancy;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"map\":\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\t(view as MapNodeStoredSchema).mapFields,\n\t\t\t\t(stored as MapNodeStoredSchema).mapFields,\n\t\t\t\tidentifier,\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"leaf\": {\n\t\t\tconst viewValue = (view as LeafNodeStoredSchema).leafValue;\n\t\t\tconst storedValue = (stored as LeafNodeStoredSchema).leafValue;\n\t\t\tif (viewValue !== storedValue) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"valueSchema\",\n\t\t\t\t\tview: viewValue,\n\t\t\t\t\tstored: storedValue,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tbreak;\n\t}\n}\n\n/**\n * The function to track the discrepancies between two field stored schemas.\n *\n * @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.\n */\nfunction* getFieldDiscrepancies(\n\tview: TreeFieldStoredSchema,\n\tstored: TreeFieldStoredSchema,\n\tkeyOrRoot?: string,\n): Iterable<FieldDiscrepancy> {\n\t// Only track the symmetric differences of two sets.\n\tconst findSetDiscrepancies = (\n\t\ta: TreeTypeSet,\n\t\tb: TreeTypeSet,\n\t): [TreeNodeSchemaIdentifier[], TreeNodeSchemaIdentifier[]] => {\n\t\tconst aDiff = [...a].filter((value) => !b.has(value));\n\t\tconst bDiff = [...b].filter((value) => !a.has(value));\n\t\treturn [aDiff, bDiff];\n\t};\n\n\tconst [viewExtra, storedExtra] = findSetDiscrepancies(view.types, stored.types);\n\tif (viewExtra.length > 0 || storedExtra.length > 0) {\n\t\tyield {\n\t\t\tidentifier: keyOrRoot,\n\t\t\tmismatch: \"allowedTypes\",\n\t\t\tview: viewExtra,\n\t\t\tstored: storedExtra,\n\t\t} satisfies AllowedTypeDiscrepancy;\n\t}\n\n\tif (view.kind !== stored.kind) {\n\t\tyield {\n\t\t\tidentifier: keyOrRoot,\n\t\t\tmismatch: \"fieldKind\",\n\t\t\tview: view.kind,\n\t\t\tstored: stored.kind,\n\t\t} satisfies FieldKindDiscrepancy;\n\t}\n}\n\nfunction* trackObjectNodeDiscrepancies(\n\tview: ObjectNodeStoredSchema,\n\tstored: ObjectNodeStoredSchema,\n): Iterable<FieldDiscrepancy> {\n\t/**\n\t * Similar to the logic used for tracking discrepancies between two node schemas, we will identify\n\t * three types of differences:\n\t * 1. Fields that exist in the view schema but not in the stored schema.\n\t * 2. Fields that exist in both schemas but have different contents.\n\t * 3. Fields that exist in the stored schema but not in the view schema.\n\t *\n\t * First, the view schema is iterated to track the first two types of differences.\n\t * Then, the stored schema is iterated to find the third type.\n\t */\n\n\tfor (const result of compareMaps(view.objectNodeFields, stored.objectNodeFields)) {\n\t\tconst fieldKey = result.key;\n\t\tswitch (result.type) {\n\t\t\tcase \"aExtra\": {\n\t\t\t\tif (result.value.kind === storedEmptyFieldSchema.kind) {\n\t\t\t\t\t// In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden\n\t\t\t\t\t// (by way of omission). We treat these identically anyway.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: fieldKey,\n\t\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\t\tview: result.value.kind,\n\t\t\t\t\tstored: storedEmptyFieldSchema.kind,\n\t\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"bExtra\": {\n\t\t\t\tif (result.value.kind === storedEmptyFieldSchema.kind) {\n\t\t\t\t\t// In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden\n\t\t\t\t\t// (by way of omission). We treat these identically anyway.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: fieldKey,\n\t\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\t\tview: storedEmptyFieldSchema.kind,\n\t\t\t\t\tstored: result.value.kind,\n\t\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"both\": {\n\t\t\t\tyield* getFieldDiscrepancies(result.valueA, result.valueB, fieldKey);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction* compareMaps<K, V1, V2>(\n\ta: ReadonlyMap<K, V1>,\n\tb: ReadonlyMap<K, V2>,\n): Iterable<\n\t| { type: \"aExtra\"; key: K; value: V1 }\n\t| { type: \"bExtra\"; key: K; value: V2 }\n\t| { type: \"both\"; key: K; valueA: V1; valueB: V2 }\n> {\n\tfor (const [key, valueA] of a) {\n\t\tconst valueB = b.get(key);\n\t\tyield valueB === undefined\n\t\t\t? { type: \"aExtra\", key, value: valueA }\n\t\t\t: { type: \"both\", key, valueA, valueB };\n\t}\n\tfor (const [key, valueB] of b) {\n\t\tif (!a.has(key)) {\n\t\t\tyield { type: \"bExtra\", key, value: valueB };\n\t\t}\n\t}\n}\n/**\n * @remarks\n *\n * This function uses incompatibilities to determine if changes to a document schema are backward-compatible, i.e., it determines\n * whether the `view` schema allows a superset of the documents that the `stored` schema allows.\n * According to the policy of schema evolution, `isRepoSuperset` supports three types of changes:\n * 1. Adding an optional field to an object node.\n * 2. Expanding the set of allowed types for a field.\n * 3. Relaxing a field kind to a more general field kind.\n *\n * Notes: We expect isRepoSuperset to return consistent results with allowsRepoSuperset. However, currently there are some scenarios\n * where the inconsistency will occur:\n *\n * - Different Node Kinds: If a and b have different node kinds (e.g., a is an objectNodeSchema and b is a mapNodeSchema),\n * `isRepoSuperset` will determine that a can never be the superset of b. In contrast, `allowsRepoSuperset` will continue\n * validating internal fields.\n */\nexport function isRepoSuperset(view: TreeStoredSchema, stored: TreeStoredSchema): boolean {\n\tconst discrepancies = getAllowedContentDiscrepancies(view, stored);\n\n\tfor (const discrepancy of discrepancies) {\n\t\tswitch (discrepancy.mismatch) {\n\t\t\tcase \"nodeKind\": {\n\t\t\t\tif (discrepancy.stored !== undefined) {\n\t\t\t\t\t// It's fine for the view schema to know of a node type that the stored schema doesn't know about.\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"valueSchema\":\n\t\t\tcase \"allowedTypes\":\n\t\t\tcase \"fieldKind\": {\n\t\t\t\tif (!isFieldDiscrepancyCompatible(discrepancy)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"fields\": {\n\t\t\t\tif (\n\t\t\t\t\tdiscrepancy.differences.some(\n\t\t\t\t\t\t(difference) => !isFieldDiscrepancyCompatible(difference),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// No default\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction isFieldDiscrepancyCompatible(discrepancy: FieldDiscrepancy): boolean {\n\tswitch (discrepancy.mismatch) {\n\t\tcase \"allowedTypes\": {\n\t\t\t// Since we only track the symmetric difference between the allowed types in the view and\n\t\t\t// stored schemas, it's sufficient to check if any extra allowed types still exist in the\n\t\t\t// stored schema.\n\t\t\treturn discrepancy.stored.length === 0;\n\t\t}\n\t\tcase \"fieldKind\": {\n\t\t\treturn posetLte(discrepancy.stored, discrepancy.view, fieldRealizer);\n\t\t}\n\t\tcase \"valueSchema\": {\n\t\t\treturn false;\n\t\t}\n\t\t// No default\n\t}\n\treturn false;\n}\n\n/**\n * A linear extension of a partially-ordered set of `T`s. See:\n * https://en.wikipedia.org/wiki/Linear_extension\n *\n * The linear extension is represented as a lookup from each poset element to its index in the linear extension.\n */\ntype LinearExtension<T> = Map<T, number>;\n\n/**\n * A realizer for a partially-ordered set. See:\n * https://en.wikipedia.org/wiki/Order_dimension\n */\ntype Realizer<T> = LinearExtension<T>[];\n\n/**\n * @privateRemarks\n * TODO: Knowledge of specific field kinds is not appropriate for modular schema.\n * This bit of field comparison should be dependency injected by default-schema if this comparison logic remains in modular-schema\n * (this is analogous to what is done in comparison.ts).\n */\nconst FieldKindIdentifiers = {\n\tforbidden: brand<FieldKindIdentifier>(\"Forbidden\"),\n\trequired: brand<FieldKindIdentifier>(\"Value\"),\n\tidentifier: brand<FieldKindIdentifier>(\"Identifier\"),\n\toptional: brand<FieldKindIdentifier>(\"Optional\"),\n\tsequence: brand<FieldKindIdentifier>(\"Sequence\"),\n};\n\n/**\n * A realizer for the partial order of field kind relaxability.\n *\n * It seems extremely likely that this partial order will remain dimension 2 over time (i.e. the set of allowed relaxations can be visualized\n * with a [dominance drawing](https://en.wikipedia.org/wiki/Dominance_drawing)), so this strategy allows efficient comarison between field kinds\n * without excessive casework.\n *\n * Hasse diagram for the partial order is shown below (lower fields can be relaxed to higher fields):\n * ```\n * sequence\n * |\n * optional\n * | \\\n * required forbidden\n * |\n * identifier\n * ```\n */\nconst fieldRealizer: Realizer<FieldKindIdentifier> = [\n\t[\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n\t[\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n].map((extension) => new Map(extension.map((identifier, index) => [identifier, index])));\n\nconst PosetComparisonResult = {\n\tLess: \"<\",\n\tGreater: \">\",\n\tEqual: \"=\",\n\tIncomparable: \"||\",\n} as const;\ntype PosetComparisonResult =\n\t(typeof PosetComparisonResult)[keyof typeof PosetComparisonResult];\n\nfunction comparePosetElements<T>(a: T, b: T, realizer: Realizer<T>): PosetComparisonResult {\n\tlet hasLessThanResult = false;\n\tlet hasGreaterThanResult = false;\n\tfor (const extension of realizer) {\n\t\tconst aIndex = extension.get(a);\n\t\tconst bIndex = extension.get(b);\n\t\tassert(aIndex !== undefined && bIndex !== undefined, 0xa72 /* Invalid realizer */);\n\t\tif (aIndex < bIndex) {\n\t\t\thasLessThanResult = true;\n\t\t} else if (aIndex > bIndex) {\n\t\t\thasGreaterThanResult = true;\n\t\t}\n\t}\n\n\treturn hasLessThanResult\n\t\t? hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Incomparable\n\t\t\t: PosetComparisonResult.Less\n\t\t: hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Greater\n\t\t\t: PosetComparisonResult.Equal;\n}\n\nfunction posetLte<T>(a: T, b: T, realizer: Realizer<T>): boolean {\n\tconst comparison = comparePosetElements(a, b, realizer);\n\treturn (\n\t\tcomparison === PosetComparisonResult.Less || comparison === PosetComparisonResult.Equal\n\t);\n}\n\nfunction throwUnsupportedNodeType(type: string): never {\n\tthrow new TypeError(`Unsupported node stored schema type: ${type}`);\n}\n"]}
1
+ {"version":3,"file":"discrepancies.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/discrepancies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAGN,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,GAOtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAoH5C,SAAS,iBAAiB,CAAC,UAAgC;IAC1D,IAAI,U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oBAAoB,GAAG,IAAI,CAAC;QAC7B,CAAC;IACF,CAAC;IAED,OAAO,iBAAiB;QACvB,CAAC,CAAC,oBAAoB;YACrB,CAAC,CAAC,qBAAqB,CAAC,YAAY;YACpC,CAAC,CAAC,qBAAqB,CAAC,IAAI;QAC7B,CAAC,CAAC,oBAAoB;YACrB,CAAC,CAAC,qBAAqB,CAAC,OAAO;YAC/B,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAI,CAAI,EAAE,CAAI,EAAE,QAAqB;IAC5D,MAAM,UAAU,GAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IACxD,OAAO,CACN,UAAU,KAAK,qBAAqB,CAAC,IAAI,IAAI,UAAU,KAAK,qBAAqB,CAAC,KAAK,CACvF,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAY;IAC7C,MAAM,IAAI,SAAS,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;AACrE,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\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tstoredEmptyFieldSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n\ttype ValueSchema,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\n\n// TODO:\n// The comparisons in this file seem redundant with those in comparison.ts.\n// Rather than both existing, one of which just returns boolean and the other which returns additional details, a simple comparison which returns everything needed should be used.\n\n/**\n * Discriminated union (keyed on `mismatch`) of discrepancies between a view and stored schema.\n * @remarks\n *\n * 1. FieldDiscrepancy\n *\n * `FieldDiscrepancy` represents the differences between two `TreeFieldStoredSchema` objects. It consists of\n * three types of incompatibilities:\n *\n * - FieldKindDiscrepancy: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`\n * objects (e.g., optional, required, sequence, etc.).\n * - AllowedTypesDiscrepancy: Indicates the differences in the allowed child types between the two schemas.\n * - ValueSchemaDiscrepancy: Specifically indicates the differences in the `ValueSchema` of two\n * `LeafNodeStoredSchema` objects.\n *\n * 2. NodeDiscrepancy\n *\n * `NodeDiscrepancy` represents the differences between two `TreeNodeStoredSchema` objects and includes:\n *\n * - NodeKindDiscrepancy: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports\n * `ObjectNodeStoredSchema`, `MapNodeStoredSchema`, and `LeafNodeStoredSchema`).\n * - NodeFieldsDiscrepancy: Indicates the `FieldDiscrepancy` of `TreeFieldStoredSchema` within two\n * `TreeNodeStoredSchema`. It includes an array of `FieldDiscrepancy` instances in the `differences` field.\n *\n * When comparing two nodes for compatibility, it only makes sense to compare their fields if the nodes are of\n * the same kind (map, object, leaf).\n *\n * 3. Discrepancy\n *\n * Discrepancy consists of both `NodeDiscrepancy` and `FieldDiscrepancy`, representing any kind of\n * schema differences. See {@link getAllowedContentDiscrepancies} for more details about how we process it\n * and the ordering.\n */\nexport type Discrepancy = FieldDiscrepancy | NodeDiscrepancy;\n\nexport type NodeDiscrepancy = NodeKindDiscrepancy | NodeFieldsDiscrepancy;\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\tidentifier: 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\tfieldKey: FieldKey | undefined;\n}\n\n/**\n * A discrepancy in the allowed types of a field.\n *\n * @remarks\n * This reports the symmetric difference of allowed types in view/stored to enable more efficient checks for compatibility\n */\nexport interface AllowedTypeDiscrepancy extends FieldDiscrepancyLocation {\n\tmismatch: \"allowedTypes\";\n\t/**\n\t * List of allowed type identifiers in viewed schema which are not allowed in stored schema\n\t */\n\tview: TreeNodeSchemaIdentifier[];\n\t/**\n\t * List of allowed type identifiers in stored schema which are not allowed in view schema\n\t */\n\tstored: TreeNodeSchemaIdentifier[];\n}\n\nexport interface FieldKindDiscrepancy extends FieldDiscrepancyLocation {\n\tmismatch: \"fieldKind\";\n\tview: FieldKindIdentifier;\n\tstored: FieldKindIdentifier;\n}\n\nexport interface ValueSchemaDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"valueSchema\";\n\tview: ValueSchema | undefined;\n\tstored: ValueSchema | undefined;\n}\n\nexport interface NodeKindDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"nodeKind\";\n\tview: SchemaFactoryNodeKind | undefined;\n\tstored: SchemaFactoryNodeKind | undefined;\n}\n\nexport interface NodeFieldsDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"fields\";\n\tdifferences: FieldDiscrepancy[];\n}\n\ntype SchemaFactoryNodeKind = \"object\" | \"leaf\" | \"map\";\n\nfunction getNodeSchemaType(nodeSchema: TreeNodeStoredSchema): SchemaFactoryNodeKind {\n\tif (nodeSchema instanceof ObjectNodeStoredSchema) {\n\t\treturn \"object\";\n\t} else if (nodeSchema instanceof MapNodeStoredSchema) {\n\t\treturn \"map\";\n\t} else if (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\treturn \"leaf\";\n\t}\n\tthrowUnsupportedNodeType(nodeSchema.constructor.name);\n}\n\n/**\n * Finds and reports discrepancies between a view schema and a stored schema.\n *\n * See documentation on {@link Discrepancy} for details of possible discrepancies.\n * @remarks\n * This function does not attempt to distinguish between equivalent representations of a node/field involving extraneous never trees.\n * For example, a Forbidden field with allowed type set `[]` is equivalent to an optional field with allowed type set `[]`,\n * as well as an optional field with an allowed type set containing only unconstructable types.\n *\n * It is up to the caller to determine whether such discrepancies matter.\n */\nexport function* getAllowedContentDiscrepancies(\n\tview: TreeStoredSchema,\n\tstored: TreeStoredSchema,\n): Iterable<Discrepancy> {\n\t// check root schema discrepancies\n\tyield* getFieldDiscrepancies(\n\t\tview.rootFieldSchema,\n\t\tstored.rootFieldSchema,\n\t\tundefined,\n\t\tundefined,\n\t);\n\n\tfor (const result of compareMaps(view.nodeSchema, stored.nodeSchema)) {\n\t\tswitch (result.type) {\n\t\t\tcase \"aExtra\": {\n\t\t\t\tconst viewType = getNodeSchemaType(result.value);\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: result.key,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: viewType,\n\t\t\t\t\tstored: undefined,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"bExtra\": {\n\t\t\t\tconst storedType = getNodeSchemaType(result.value);\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: result.key,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: undefined,\n\t\t\t\t\tstored: storedType,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"both\": {\n\t\t\t\tyield* getNodeDiscrepancies(result.key, result.valueA, result.valueB);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction* getNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: TreeNodeStoredSchema,\n\tstored: TreeNodeStoredSchema,\n): Iterable<Discrepancy> {\n\tconst viewType = getNodeSchemaType(view);\n\tconst storedType = getNodeSchemaType(stored);\n\tif (viewType !== storedType) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tmismatch: \"nodeKind\",\n\t\t\tview: viewType,\n\t\t\tstored: storedType,\n\t\t};\n\t\treturn;\n\t}\n\n\tswitch (viewType) {\n\t\tcase \"object\": {\n\t\t\tconst differences = Array.from(\n\t\t\t\ttrackObjectNodeDiscrepancies(\n\t\t\t\t\tidentifier,\n\t\t\t\t\tview as ObjectNodeStoredSchema,\n\t\t\t\t\tstored as ObjectNodeStoredSchema,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (differences.length > 0) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"fields\",\n\t\t\t\t\tdifferences,\n\t\t\t\t} satisfies NodeFieldsDiscrepancy;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"map\":\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\t(view as MapNodeStoredSchema).mapFields,\n\t\t\t\t(stored as MapNodeStoredSchema).mapFields,\n\t\t\t\tidentifier,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"leaf\": {\n\t\t\tconst viewValue = (view as LeafNodeStoredSchema).leafValue;\n\t\t\tconst storedValue = (stored as LeafNodeStoredSchema).leafValue;\n\t\t\tif (viewValue !== storedValue) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"valueSchema\",\n\t\t\t\t\tview: viewValue,\n\t\t\t\t\tstored: storedValue,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tbreak;\n\t}\n}\n\n/**\n * The function to track the discrepancies between two field stored schemas.\n *\n * @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.\n */\nfunction* getFieldDiscrepancies(\n\tview: TreeFieldStoredSchema,\n\tstored: TreeFieldStoredSchema,\n\tidentifier: TreeNodeSchemaIdentifier | undefined,\n\tfieldKey: FieldKey | undefined,\n): Iterable<FieldDiscrepancy> {\n\t// Only track the symmetric differences of two sets.\n\tconst findSetDiscrepancies = (\n\t\ta: TreeTypeSet,\n\t\tb: TreeTypeSet,\n\t): [TreeNodeSchemaIdentifier[], TreeNodeSchemaIdentifier[]] => {\n\t\tconst aDiff = [...a].filter((value) => !b.has(value));\n\t\tconst bDiff = [...b].filter((value) => !a.has(value));\n\t\treturn [aDiff, bDiff];\n\t};\n\n\tconst [viewExtra, storedExtra] = findSetDiscrepancies(view.types, stored.types);\n\tif (viewExtra.length > 0 || storedExtra.length > 0) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tfieldKey,\n\t\t\tmismatch: \"allowedTypes\",\n\t\t\tview: viewExtra,\n\t\t\tstored: storedExtra,\n\t\t} satisfies AllowedTypeDiscrepancy;\n\t}\n\n\tif (view.kind !== stored.kind) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tfieldKey,\n\t\t\tmismatch: \"fieldKind\",\n\t\t\tview: view.kind,\n\t\t\tstored: stored.kind,\n\t\t} satisfies FieldKindDiscrepancy;\n\t}\n}\n\nfunction* trackObjectNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: ObjectNodeStoredSchema,\n\tstored: ObjectNodeStoredSchema,\n): Iterable<FieldDiscrepancy> {\n\t/**\n\t * Similar to the logic used for tracking discrepancies between two node schemas, we will identify\n\t * three types of differences:\n\t * 1. Fields that exist in the view schema but not in the stored schema.\n\t * 2. Fields that exist in both schemas but have different contents.\n\t * 3. Fields that exist in the stored schema but not in the view schema.\n\t *\n\t * First, the view schema is iterated to track the first two types of differences.\n\t * Then, the stored schema is iterated to find the third type.\n\t */\n\n\tfor (const result of compareMaps(view.objectNodeFields, stored.objectNodeFields)) {\n\t\tconst fieldKey = result.key;\n\t\tswitch (result.type) {\n\t\t\tcase \"aExtra\": {\n\t\t\t\tif (result.value.kind === storedEmptyFieldSchema.kind) {\n\t\t\t\t\t// In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden\n\t\t\t\t\t// (by way of omission). We treat these identically anyway.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tfieldKey,\n\t\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\t\tview: result.value.kind,\n\t\t\t\t\tstored: storedEmptyFieldSchema.kind,\n\t\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"bExtra\": {\n\t\t\t\tif (result.value.kind === storedEmptyFieldSchema.kind) {\n\t\t\t\t\t// In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden\n\t\t\t\t\t// (by way of omission). We treat these identically anyway.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tfieldKey,\n\t\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\t\tview: storedEmptyFieldSchema.kind,\n\t\t\t\t\tstored: result.value.kind,\n\t\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"both\": {\n\t\t\t\tyield* getFieldDiscrepancies(result.valueA, result.valueB, identifier, fieldKey);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction* compareMaps<K, V1, V2>(\n\ta: ReadonlyMap<K, V1>,\n\tb: ReadonlyMap<K, V2>,\n): Iterable<\n\t| { type: \"aExtra\"; key: K; value: V1 }\n\t| { type: \"bExtra\"; key: K; value: V2 }\n\t| { type: \"both\"; key: K; valueA: V1; valueB: V2 }\n> {\n\tfor (const [key, valueA] of a) {\n\t\tconst valueB = b.get(key);\n\t\tyield valueB === undefined\n\t\t\t? { type: \"aExtra\", key, value: valueA }\n\t\t\t: { type: \"both\", key, valueA, valueB };\n\t}\n\tfor (const [key, valueB] of b) {\n\t\tif (!a.has(key)) {\n\t\t\tyield { type: \"bExtra\", key, value: valueB };\n\t\t}\n\t}\n}\n/**\n * @remarks\n *\n * This function uses incompatibilities to determine if changes to a document schema are backward-compatible, i.e., it determines\n * whether the `view` schema allows a superset of the documents that the `stored` schema allows.\n * According to the policy of schema evolution, `isRepoSuperset` supports three types of changes:\n * 1. Adding an optional field to an object node.\n * 2. Expanding the set of allowed types for a field.\n * 3. Relaxing a field kind to a more general field kind.\n *\n * Notes: We expect isRepoSuperset to return consistent results with allowsRepoSuperset. However, currently there are some scenarios\n * where the inconsistency will occur:\n *\n * - Different Node Kinds: If a and b have different node kinds (e.g., a is an objectNodeSchema and b is a mapNodeSchema),\n * `isRepoSuperset` will determine that a can never be the superset of b. In contrast, `allowsRepoSuperset` will continue\n * validating internal fields.\n */\nexport function isRepoSuperset(view: TreeStoredSchema, stored: TreeStoredSchema): boolean {\n\tconst discrepancies = getAllowedContentDiscrepancies(view, stored);\n\n\tfor (const discrepancy of discrepancies) {\n\t\tswitch (discrepancy.mismatch) {\n\t\t\tcase \"nodeKind\": {\n\t\t\t\tif (discrepancy.stored !== undefined) {\n\t\t\t\t\t// It's fine for the view schema to know of a node type that the stored schema doesn't know about.\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"valueSchema\":\n\t\t\tcase \"allowedTypes\":\n\t\t\tcase \"fieldKind\": {\n\t\t\t\tif (!isFieldDiscrepancyCompatible(discrepancy)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"fields\": {\n\t\t\t\tif (\n\t\t\t\t\tdiscrepancy.differences.some(\n\t\t\t\t\t\t(difference) => !isFieldDiscrepancyCompatible(difference),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// No default\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction isFieldDiscrepancyCompatible(discrepancy: FieldDiscrepancy): boolean {\n\tswitch (discrepancy.mismatch) {\n\t\tcase \"allowedTypes\": {\n\t\t\t// Since we only track the symmetric difference between the allowed types in the view and\n\t\t\t// stored schemas, it's sufficient to check if any extra allowed types still exist in the\n\t\t\t// stored schema.\n\t\t\treturn discrepancy.stored.length === 0;\n\t\t}\n\t\tcase \"fieldKind\": {\n\t\t\treturn posetLte(discrepancy.stored, discrepancy.view, fieldRealizer);\n\t\t}\n\t\tcase \"valueSchema\": {\n\t\t\treturn false;\n\t\t}\n\t\t// No default\n\t}\n\treturn false;\n}\n\n/**\n * A linear extension of a partially-ordered set of `T`s. See:\n * https://en.wikipedia.org/wiki/Linear_extension\n *\n * The linear extension is represented as a lookup from each poset element to its index in the linear extension.\n */\nexport type LinearExtension<T> = Map<T, number>;\n\n/**\n * A realizer for a partially-ordered set. See:\n * https://en.wikipedia.org/wiki/Order_dimension\n */\nexport type Realizer<T> = LinearExtension<T>[];\n\n/**\n * @privateRemarks\n * TODO: Knowledge of specific field kinds is not appropriate for modular schema.\n * This bit of field comparison should be dependency injected by default-schema if this comparison logic remains in modular-schema\n * (this is analogous to what is done in comparison.ts).\n */\nconst FieldKindIdentifiers = {\n\tforbidden: brand<FieldKindIdentifier>(\"Forbidden\"),\n\trequired: brand<FieldKindIdentifier>(\"Value\"),\n\tidentifier: brand<FieldKindIdentifier>(\"Identifier\"),\n\toptional: brand<FieldKindIdentifier>(\"Optional\"),\n\tsequence: brand<FieldKindIdentifier>(\"Sequence\"),\n};\n\n/**\n * A realizer for the partial order of field kind relaxability.\n *\n * It seems extremely likely that this partial order will remain dimension 2 over time (i.e. the set of allowed relaxations can be visualized\n * with a [dominance drawing](https://en.wikipedia.org/wiki/Dominance_drawing)), so this strategy allows efficient comarison between field kinds\n * without excessive casework.\n *\n * Hasse diagram for the partial order is shown below (lower fields can be relaxed to higher fields):\n * ```\n * sequence\n * |\n * optional\n * | \\\n * required forbidden\n * |\n * identifier\n * ```\n */\nexport const fieldRealizer: Realizer<FieldKindIdentifier> = [\n\t[\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n\t[\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n].map((extension) => new Map(extension.map((identifier, index) => [identifier, index])));\n\nexport const PosetComparisonResult = {\n\tLess: \"<\",\n\tGreater: \">\",\n\tEqual: \"=\",\n\tIncomparable: \"||\",\n} as const;\ntype PosetComparisonResult =\n\t(typeof PosetComparisonResult)[keyof typeof PosetComparisonResult];\n\nexport function comparePosetElements<T>(\n\ta: T,\n\tb: T,\n\trealizer: Realizer<T>,\n): PosetComparisonResult {\n\tlet hasLessThanResult = false;\n\tlet hasGreaterThanResult = false;\n\tfor (const extension of realizer) {\n\t\tconst aIndex = extension.get(a);\n\t\tconst bIndex = extension.get(b);\n\t\tassert(aIndex !== undefined && bIndex !== undefined, 0xa72 /* Invalid realizer */);\n\t\tif (aIndex < bIndex) {\n\t\t\thasLessThanResult = true;\n\t\t} else if (aIndex > bIndex) {\n\t\t\thasGreaterThanResult = true;\n\t\t}\n\t}\n\n\treturn hasLessThanResult\n\t\t? hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Incomparable\n\t\t\t: PosetComparisonResult.Less\n\t\t: hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Greater\n\t\t\t: PosetComparisonResult.Equal;\n}\n\nexport function posetLte<T>(a: T, b: T, realizer: Realizer<T>): boolean {\n\tconst comparison = comparePosetElements(a, b, realizer);\n\treturn (\n\t\tcomparison === PosetComparisonResult.Less || comparison === PosetComparisonResult.Equal\n\t);\n}\n\nfunction throwUnsupportedNodeType(type: string): never {\n\tthrow new TypeError(`Unsupported node stored schema type: ${type}`);\n}\n"]}
@@ -15,5 +15,5 @@ export type { GenericChangeset } from "./genericFieldKindTypes.js";
15
15
  export { ModularChangeFamily, ModularEditBuilder, type EditDescription, type GlobalEditDescription, type FieldEditDescription, rebaseRevisionMetadataFromInfo, intoDelta, relevantRemovedRoots, updateRefreshers, } from "./modularChangeFamily.js";
16
16
  export { makeModularChangeCodecFamily } from "./modularChangeCodecs.js";
17
17
  export type { FieldKindConfiguration, FieldKindConfigurationEntry, } from "./fieldKindConfiguration.js";
18
- export { getAllowedContentDiscrepancies, isRepoSuperset, } from "./discrepancies.js";
18
+ export { getAllowedContentDiscrepancies, isRepoSuperset, type AllowedTypeDiscrepancy, type FieldKindDiscrepancy, type ValueSchemaDiscrepancy, type FieldDiscrepancy, type NodeDiscrepancy, type NodeKindDiscrepancy, type NodeFieldsDiscrepancy, type LinearExtension, type Realizer, fieldRealizer, PosetComparisonResult, comparePosetElements, posetLte, } from "./discrepancies.js";
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,EAClB,kCAAkC,EAClC,mBAAmB,EACnB,kBAAkB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EACN,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,+BAA+B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,EAClC,KAAK,OAAO,EACZ,eAAe,EACf,KAAK,0BAA0B,GAC/B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,GACN,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EACN,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,8BAA8B,EAC9B,SAAS,EACT,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,YAAY,EACX,sBAAsB,EACtB,2BAA2B,GAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,8BAA8B,EAC9B,cAAc,GACd,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,EAClB,kCAAkC,EAClC,mBAAmB,EACnB,kBAAkB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kB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BAA6B,CAAC;AACrC,OAAO,EACN,8BAA8B,EAC9B,cAAc,EACd,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,GACR,MAAM,oBAAoB,CAAC"}
@@ -12,5 +12,5 @@ export { referenceFreeFieldChangeRebaser, NodeAttachState, } from "./fieldChange
12
12
  export { convertGenericChange, genericChangeHandler, genericFieldKind, } from "./genericFieldKind.js";
13
13
  export { ModularChangeFamily, ModularEditBuilder, rebaseRevisionMetadataFromInfo, intoDelta, relevantRemovedRoots, updateRefreshers, } from "./modularChangeFamily.js";
14
14
  export { makeModularChangeCodecFamily } from "./modularChangeCodecs.js";
15
- export { getAllowedContentDiscrepancies, isRepoSuperset, } from "./discrepancies.js";
15
+ export { getAllowedContentDiscrepancies, isRepoSuperset, fieldRealizer, PosetComparisonResult, comparePosetElements, posetLte, } from "./discrepancies.js";
16
16
  //# sourceMappingURL=index.js.map