@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
@@ -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,gBAAg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CvB;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,KAAK,wBAAwB,EAE7B,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAChB,MAAM,qBAAqB,CAAC;AAO7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAE7D,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACzB,sBAAsB,GACtB,oBAAoB,GACpB,sBAAsB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;;OAIG;IACH,UAAU,EAAE,wBAAwB,GAAG,SAAS,CAAC;IACjD;;;;;OAKG;IACH,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC/B;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAuB,SAAQ,wBAAwB;IACvE,QAAQ,EAAE,cAAc,CAAC;IACzB;;OAEG;IACH,IAAI,EAAE,wBAAwB,EAAE,CAAC;IACjC;;OAEG;IACH,MAAM,EAAE,wBAAwB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,oBAAqB,SAAQ,wBAAwB;IACrE,QAAQ,EAAE,WAAW,CAAC;IACtB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,MAAM,EAAE,mBAAmB,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACtC,UAAU,EAAE,wBAAwB,CAAC;IACrC,QAAQ,EAAE,aAAa,CAAC;IACx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C,EAAE,CAAC,EACJ,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GACnB,qBAAqB,CAqBvB;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,CAKtE"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.isRepoSuperset = exports.getAllowedContentDiscrepancies = void 0;
7
+ exports.posetLte = exports.comparePosetElements = exports.PosetComparisonResult = exports.fieldRealizer = exports.isRepoSuperset = exports.getAllowedContentDiscrepancies = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../../core/index.js");
10
10
  const index_js_2 = require("../../util/index.js");
@@ -23,23 +23,17 @@ function getNodeSchemaType(nodeSchema) {
23
23
  /**
24
24
  * Finds and reports discrepancies between a view schema and a stored schema.
25
25
  *
26
- * The workflow for finding schema incompatibilities:
27
- * 1. Compare the two root schemas to identify any `FieldDiscrepancy`.
28
- *
29
- * 2. For each node schema in the `view`:
30
- * - Verify if the node schema exists in the stored. If it does, ensure that the `SchemaFactoryNodeKind` are
31
- * consistent. Otherwise this difference is treated as `NodeKindDiscrepancy`
32
- * - If a node schema with the same identifier exists in both view and stored, and their `SchemaFactoryNodeKind`
33
- * are consistent, perform a exhaustive validation to identify all `FieldDiscrepancy`.
34
- *
35
- * 3. For each node schema in the stored, verify if it exists in the view. The overlapping parts were already
36
- * addressed in the previous step.
26
+ * See documentation on {@link Discrepancy} for details of possible discrepancies.
27
+ * @remarks
28
+ * This function does not attempt to distinguish between equivalent representations of a node/field involving extraneous never trees.
29
+ * For example, a Forbidden field with allowed type set `[]` is equivalent to an optional field with allowed type set `[]`,
30
+ * as well as an optional field with an allowed type set containing only unconstructable types.
37
31
  *
38
- * @returns the discrepancies between two TreeStoredSchema objects
32
+ * It is up to the caller to determine whether such discrepancies matter.
39
33
  */
40
34
  function* getAllowedContentDiscrepancies(view, stored) {
41
35
  // check root schema discrepancies
42
- yield* getFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema);
36
+ yield* getFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema, undefined, undefined);
43
37
  for (const result of compareMaps(view.nodeSchema, stored.nodeSchema)) {
44
38
  switch (result.type) {
45
39
  case "aExtra": {
@@ -86,7 +80,7 @@ function* getNodeDiscrepancies(identifier, view, stored) {
86
80
  }
87
81
  switch (viewType) {
88
82
  case "object": {
89
- const differences = Array.from(trackObjectNodeDiscrepancies(view, stored));
83
+ const differences = Array.from(trackObjectNodeDiscrepancies(identifier, view, stored));
90
84
  if (differences.length > 0) {
91
85
  yield {
92
86
  identifier,
@@ -97,7 +91,7 @@ function* getNodeDiscrepancies(identifier, view, stored) {
97
91
  break;
98
92
  }
99
93
  case "map":
100
- yield* getFieldDiscrepancies(view.mapFields, stored.mapFields, identifier);
94
+ yield* getFieldDiscrepancies(view.mapFields, stored.mapFields, identifier, undefined);
101
95
  break;
102
96
  case "leaf": {
103
97
  const viewValue = view.leafValue;
@@ -121,7 +115,7 @@ function* getNodeDiscrepancies(identifier, view, stored) {
121
115
  *
122
116
  * @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.
123
117
  */
124
- function* getFieldDiscrepancies(view, stored, keyOrRoot) {
118
+ function* getFieldDiscrepancies(view, stored, identifier, fieldKey) {
125
119
  // Only track the symmetric differences of two sets.
126
120
  const findSetDiscrepancies = (a, b) => {
127
121
  const aDiff = [...a].filter((value) => !b.has(value));
@@ -131,7 +125,8 @@ function* getFieldDiscrepancies(view, stored, keyOrRoot) {
131
125
  const [viewExtra, storedExtra] = findSetDiscrepancies(view.types, stored.types);
132
126
  if (viewExtra.length > 0 || storedExtra.length > 0) {
133
127
  yield {
134
- identifier: keyOrRoot,
128
+ identifier,
129
+ fieldKey,
135
130
  mismatch: "allowedTypes",
136
131
  view: viewExtra,
137
132
  stored: storedExtra,
@@ -139,14 +134,15 @@ function* getFieldDiscrepancies(view, stored, keyOrRoot) {
139
134
  }
140
135
  if (view.kind !== stored.kind) {
141
136
  yield {
142
- identifier: keyOrRoot,
137
+ identifier,
138
+ fieldKey,
143
139
  mismatch: "fieldKind",
144
140
  view: view.kind,
145
141
  stored: stored.kind,
146
142
  };
147
143
  }
148
144
  }
149
- function* trackObjectNodeDiscrepancies(view, stored) {
145
+ function* trackObjectNodeDiscrepancies(identifier, view, stored) {
150
146
  /**
151
147
  * Similar to the logic used for tracking discrepancies between two node schemas, we will identify
152
148
  * three types of differences:
@@ -167,7 +163,8 @@ function* trackObjectNodeDiscrepancies(view, stored) {
167
163
  break;
168
164
  }
169
165
  yield {
170
- identifier: fieldKey,
166
+ identifier,
167
+ fieldKey,
171
168
  mismatch: "fieldKind",
172
169
  view: result.value.kind,
173
170
  stored: index_js_1.storedEmptyFieldSchema.kind,
@@ -181,7 +178,8 @@ function* trackObjectNodeDiscrepancies(view, stored) {
181
178
  break;
182
179
  }
183
180
  yield {
184
- identifier: fieldKey,
181
+ identifier,
182
+ fieldKey,
185
183
  mismatch: "fieldKind",
186
184
  view: index_js_1.storedEmptyFieldSchema.kind,
187
185
  stored: result.value.kind,
@@ -189,12 +187,11 @@ function* trackObjectNodeDiscrepancies(view, stored) {
189
187
  break;
190
188
  }
191
189
  case "both": {
192
- yield* getFieldDiscrepancies(result.valueA, result.valueB, fieldKey);
190
+ yield* getFieldDiscrepancies(result.valueA, result.valueB, identifier, fieldKey);
193
191
  break;
194
192
  }
195
- default: {
193
+ default:
196
194
  break;
197
- }
198
195
  }
199
196
  }
200
197
  }
@@ -268,7 +265,7 @@ function isFieldDiscrepancyCompatible(discrepancy) {
268
265
  return discrepancy.stored.length === 0;
269
266
  }
270
267
  case "fieldKind": {
271
- return posetLte(discrepancy.stored, discrepancy.view, fieldRealizer);
268
+ return posetLte(discrepancy.stored, discrepancy.view, exports.fieldRealizer);
272
269
  }
273
270
  case "valueSchema": {
274
271
  return false;
@@ -308,7 +305,7 @@ const FieldKindIdentifiers = {
308
305
  * identifier
309
306
  * ```
310
307
  */
311
- const fieldRealizer = [
308
+ exports.fieldRealizer = [
312
309
  [
313
310
  FieldKindIdentifiers.forbidden,
314
311
  FieldKindIdentifiers.identifier,
@@ -324,7 +321,7 @@ const fieldRealizer = [
324
321
  FieldKindIdentifiers.sequence,
325
322
  ],
326
323
  ].map((extension) => new Map(extension.map((identifier, index) => [identifier, index])));
327
- const PosetComparisonResult = {
324
+ exports.PosetComparisonResult = {
328
325
  Less: "<",
329
326
  Greater: ">",
330
327
  Equal: "=",
@@ -346,16 +343,18 @@ function comparePosetElements(a, b, realizer) {
346
343
  }
347
344
  return hasLessThanResult
348
345
  ? hasGreaterThanResult
349
- ? PosetComparisonResult.Incomparable
350
- : PosetComparisonResult.Less
346
+ ? exports.PosetComparisonResult.Incomparable
347
+ : exports.PosetComparisonResult.Less
351
348
  : hasGreaterThanResult
352
- ? PosetComparisonResult.Greater
353
- : PosetComparisonResult.Equal;
349
+ ? exports.PosetComparisonResult.Greater
350
+ : exports.PosetComparisonResult.Equal;
354
351
  }
352
+ exports.comparePosetElements = comparePosetElements;
355
353
  function posetLte(a, b, realizer) {
356
354
  const comparison = comparePosetElements(a, b, realizer);
357
- return (comparison === PosetComparisonResult.Less || comparison === PosetComparisonResult.Equal);
355
+ return (comparison === exports.PosetComparisonResult.Less || comparison === exports.PosetComparisonResult.Equal);
358
356
  }
357
+ exports.posetLte = posetLte;
359
358
  function throwUnsupportedNodeType(type) {
360
359
  throw new TypeError(`Unsupported node stored schema type: ${type}`);
361
360
  }
@@ -1 +1 @@
1
- {"version":3,"file":"discrepancies.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/discrepancies.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,kDAY6B;AAC7B,kDAA4C;AAyF5C,SAAS,iBAAiB,CAAC,UAAg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,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,kEAA6D;AAE7D,kDAa6B;AAC7B,kDAA4C;AAoH5C,SAAS,iBAAiB,CAAC,UAAgC;IAC1D,IAAI,UAAU,YAAY,iCAAsB,EAAE,CAAC;QAClD,OAAO,QAAQ,CAAC;IACjB,CAAC;SAAM,IAAI,UAAU,YAAY,8BAAmB,EAAE,CAAC;QACtD,OAAO,KAAK,CAAC;IACd,CAAC;SAAM,IAAI,UAAU,YAAY,+BAAoB,EAAE,CAAC;QACvD,OAAO,MAAM,CAAC;IACf,CAAC;IACD,wBAAwB,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;GAUG;AACH,QAAe,CAAC,CAAC,8BAA8B,CAC9C,IAAsB,EACtB,MAAwB;IA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E,CAAI,EAAE,QAAqB;IAC5D,MAAM,UAAU,GAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IACxD,OAAO,CACN,UAAU,KAAK,6BAAqB,CAAC,IAAI,IAAI,UAAU,KAAK,6BAAqB,CAAC,KAAK,CACvF,CAAC;AACH,CAAC;AALD,4BAKC;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,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,gBAAg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7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.isRepoSuperset = exports.getAllowedContentDiscrepancies = exports.makeModularChangeCodecFamily = exports.updateRefreshers = exports.relevantRemovedRoots = exports.intoDelta = exports.rebaseRevisionMetadataFromInfo = exports.ModularEditBuilder = exports.ModularChangeFamily = exports.genericFieldKind = exports.genericChangeHandler = exports.convertGenericChange = exports.NodeAttachState = exports.referenceFreeFieldChangeRebaser = exports.FieldKindWithEditor = exports.FlexFieldKind = exports.EncodedNodeChangeset = exports.EncodedModularChangeset = exports.EncodedRevisionInfo = exports.EncodedChangeAtomId = exports.ChangesetLocalIdSchema = exports.setInCrossFieldMap = exports.CrossFieldTarget = exports.addCrossFieldQuery = exports.isNeverTree = exports.isNeverField = exports.allowsTreeSuperset = exports.allowsFieldSuperset = exports.allowsTreeSchemaIdentifierSuperset = exports.allowsRepoSuperset = void 0;
7
+ exports.posetLte = exports.comparePosetElements = exports.PosetComparisonResult = exports.fieldRealizer = exports.isRepoSuperset = exports.getAllowedContentDiscrepancies = exports.makeModularChangeCodecFamily = exports.updateRefreshers = exports.relevantRemovedRoots = exports.intoDelta = exports.rebaseRevisionMetadataFromInfo = exports.ModularEditBuilder = exports.ModularChangeFamily = exports.genericFieldKind = exports.genericChangeHandler = exports.convertGenericChange = exports.NodeAttachState = exports.referenceFreeFieldChangeRebaser = exports.FieldKindWithEditor = exports.FlexFieldKind = exports.EncodedNodeChangeset = exports.EncodedModularChangeset = exports.EncodedRevisionInfo = exports.EncodedChangeAtomId = exports.ChangesetLocalIdSchema = exports.setInCrossFieldMap = exports.CrossFieldTarget = exports.addCrossFieldQuery = exports.isNeverTree = exports.isNeverField = exports.allowsTreeSuperset = exports.allowsFieldSuperset = exports.allowsTreeSchemaIdentifierSuperset = exports.allowsRepoSuperset = void 0;
8
8
  var comparison_js_1 = require("./comparison.js");
9
9
  Object.defineProperty(exports, "allowsRepoSuperset", { enumerable: true, get: function () { return comparison_js_1.allowsRepoSuperset; } });
10
10
  Object.defineProperty(exports, "allowsTreeSchemaIdentifierSuperset", { enumerable: true, get: function () { return comparison_js_1.allowsTreeSchemaIdentifierSuperset; } });
@@ -46,4 +46,8 @@ Object.defineProperty(exports, "makeModularChangeCodecFamily", { enumerable: tru
46
46
  var discrepancies_js_1 = require("./discrepancies.js");
47
47
  Object.defineProperty(exports, "getAllowedContentDiscrepancies", { enumerable: true, get: function () { return discrepancies_js_1.getAllowedContentDiscrepancies; } });
48
48
  Object.defineProperty(exports, "isRepoSuperset", { enumerable: true, get: function () { return discrepancies_js_1.isRepoSuperset; } });
49
+ Object.defineProperty(exports, "fieldRealizer", { enumerable: true, get: function () { return discrepancies_js_1.fieldRealizer; } });
50
+ Object.defineProperty(exports, "PosetComparisonResult", { enumerable: true, get: function () { return discrepancies_js_1.PosetComparisonResult; } });
51
+ Object.defineProperty(exports, "comparePosetElements", { enumerable: true, get: function () { return discrepancies_js_1.comparePosetElements; } });
52
+ Object.defineProperty(exports, "posetLte", { enumerable: true, get: function () { return discrepancies_js_1.posetLte; } });
49
53
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAKyB;AAJxB,mHAAA,kBAAkB,OAAA;AAClB,mIAAA,kCAAkC,OAAA;AAClC,oHAAA,mBAAmB,OAAA;AACnB,mHAAA,kBAAkB,OAAA;AAEnB,mDAA6D;AAApD,8GAAA,YAAY,OAAA;AAAE,6GAAA,WAAW,OAAA;AAClC,+DAOgC;AAN/B,0HAAA,kBAAkB,OAAA;AAIlB,wHAAA,gBAAgB,OAAA;AAChB,0HAAA,kBAAkB,OAAA;AAEnB,mEAMkC;AALjC,gIAAA,sBAAsB,OAAA;AACtB,6HAAA,mBAAmB,OAAA;AACnB,6HAAA,mBAAmB,OAAA;AACnB,iIAAA,uBAAuB,OAAA;AACvB,8HAAA,oBAAoB,OAAA;AAErB,+CAAsE;AAA7D,6GAAA,aAAa,OAAA;AACtB,mEAA+D;AAAtD,6HAAA,mBAAmB,OAAA;AAC5B,iEAciC;AANhC,wIAAA,+BAA+B,OAAA;AAI/B,wHAAA,eAAe,OAAA;AAahB,6DAI+B;AAH9B,2HAAA,oBAAoB,OAAA;AACpB,2HAAA,oBAAoB,OAAA;AACpB,uHAAA,gBAAgB,OAAA;AAGjB,mEAUkC;AATjC,6HAAA,mBAAmB,OAAA;AACnB,4HAAA,kBAAkB,OAAA;AAIlB,wIAAA,8BAA8B,OAAA;AAC9B,mHAAA,SAAS,OAAA;AACT,8HAAA,oBAAoB,OAAA;AACpB,0HAAA,gBAAgB,OAAA;AAEjB,mEAAwE;AAA/D,sIAAA,4BAA4B,OAAA;AAKrC,uDAG4B;AAF3B,kIAAA,8BAA8B,OAAA;AAC9B,kHAAA,cAAc,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tallowsRepoSuperset,\n\tallowsTreeSchemaIdentifierSuperset,\n\tallowsFieldSuperset,\n\tallowsTreeSuperset,\n} from \"./comparison.js\";\nexport { isNeverField, isNeverTree } from \"./isNeverTree.js\";\nexport {\n\taddCrossFieldQuery,\n\ttype CrossFieldManager,\n\ttype CrossFieldMap,\n\ttype CrossFieldQuerySet,\n\tCrossFieldTarget,\n\tsetInCrossFieldMap,\n} from \"./crossFieldQueries.js\";\nexport {\n\tChangesetLocalIdSchema,\n\tEncodedChangeAtomId,\n\tEncodedRevisionInfo,\n\tEncodedModularChangeset,\n\tEncodedNodeChangeset,\n} from \"./modularChangeFormat.js\";\nexport { FlexFieldKind, type FullSchemaPolicy } from \"./fieldKind.js\";\nexport { FieldKindWithEditor } from \"./fieldKindWithEditor.js\";\nexport {\n\ttype FieldChangeHandler,\n\ttype FieldChangeRebaser,\n\ttype FieldEditor,\n\ttype NodeChangeComposer,\n\ttype NodeChangeInverter,\n\ttype NodeChangeRebaser,\n\ttype NodeChangePruner,\n\treferenceFreeFieldChangeRebaser,\n\ttype RebaseRevisionMetadata,\n\ttype RelevantRemovedRootsFromChild,\n\ttype ToDelta,\n\tNodeAttachState,\n\ttype FieldChangeEncodingContext,\n} from \"./fieldChangeHandler.js\";\nexport type {\n\tCrossFieldKeyRange,\n\tFieldChange,\n\tFieldChangeMap,\n\tFieldChangeset,\n\tHasFieldChanges,\n\tModularChangeset,\n\tNodeExistsConstraint,\n\tNodeId,\n} from \"./modularChangeTypes.js\";\nexport {\n\tconvertGenericChange,\n\tgenericChangeHandler,\n\tgenericFieldKind,\n} from \"./genericFieldKind.js\";\nexport type { GenericChangeset } from \"./genericFieldKindTypes.js\";\nexport {\n\tModularChangeFamily,\n\tModularEditBuilder,\n\ttype EditDescription,\n\ttype GlobalEditDescription,\n\ttype FieldEditDescription,\n\trebaseRevisionMetadataFromInfo,\n\tintoDelta,\n\trelevantRemovedRoots,\n\tupdateRefreshers,\n} from \"./modularChangeFamily.js\";\nexport { makeModularChangeCodecFamily } from \"./modularChangeCodecs.js\";\nexport type {\n\tFieldKindConfiguration,\n\tFieldKindConfigurationEntry,\n} from \"./fieldKindConfiguration.js\";\nexport {\n\tgetAllowedContentDiscrepancies,\n\tisRepoSuperset,\n} from \"./discrepancies.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAKyB;AAJxB,mHAAA,kBAAkB,OAAA;AAClB,mIAAA,kCAAkC,OAAA;AAClC,oHAAA,mBAAmB,OAAA;AACnB,mHAAA,kBAAkB,OAAA;AAEnB,mDAA6D;AAApD,8GAAA,YAAY,OAAA;AAAE,6GAAA,WAAW,OAAA;AAClC,+DAOgC;AAN/B,0HAAA,kBAAkB,OAAA;AAIlB,wHAAA,gBAAgB,OAAA;AAChB,0HAAA,kBAAkB,OAAA;AAEnB,mEAMkC;AALjC,gIAAA,sBAAsB,OAAA;AACtB,6HAAA,mBAAmB,OAAA;AACnB,6HAAA,mBAAmB,OAAA;AACnB,iIAAA,uBAAuB,OAAA;AACvB,8HAAA,oBAAoB,OAAA;AAErB,+CAAsE;AAA7D,6GAAA,aAAa,OAAA;AACtB,mEAA+D;AAAtD,6HAAA,mBAAmB,OAAA;AAC5B,iEAciC;AANhC,wIAAA,+BAA+B,OAAA;AAI/B,wHAAA,eAAe,OAAA;AAahB,6DAI+B;AAH9B,2HAAA,oBAAoB,OAAA;AACpB,2HAAA,oBAAoB,OAAA;AACpB,uHAAA,gBAAgB,OAAA;AAGjB,mEAUkC;AATjC,6HAAA,mBAAmB,OAAA;AACnB,4HAAA,kBAAkB,OAAA;AAIlB,wIAAA,8BAA8B,OAAA;AAC9B,mHAAA,SAAS,OAAA;AACT,8HAAA,oBAAoB,OAAA;AACpB,0HAAA,gBAAgB,OAAA;AAEjB,mEAAwE;AAA/D,sIAAA,4BAA4B,OAAA;AAKrC,uDAgB4B;AAf3B,kIAAA,8BAA8B,OAAA;AAC9B,kHAAA,cAAc,OAAA;AAUd,iHAAA,aAAa,OAAA;AACb,yHAAA,qBAAqB,OAAA;AACrB,wHAAA,oBAAoB,OAAA;AACpB,4GAAA,QAAQ,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tallowsRepoSuperset,\n\tallowsTreeSchemaIdentifierSuperset,\n\tallowsFieldSuperset,\n\tallowsTreeSuperset,\n} from \"./comparison.js\";\nexport { isNeverField, isNeverTree } from \"./isNeverTree.js\";\nexport {\n\taddCrossFieldQuery,\n\ttype CrossFieldManager,\n\ttype CrossFieldMap,\n\ttype CrossFieldQuerySet,\n\tCrossFieldTarget,\n\tsetInCrossFieldMap,\n} from \"./crossFieldQueries.js\";\nexport {\n\tChangesetLocalIdSchema,\n\tEncodedChangeAtomId,\n\tEncodedRevisionInfo,\n\tEncodedModularChangeset,\n\tEncodedNodeChangeset,\n} from \"./modularChangeFormat.js\";\nexport { FlexFieldKind, type FullSchemaPolicy } from \"./fieldKind.js\";\nexport { FieldKindWithEditor } from \"./fieldKindWithEditor.js\";\nexport {\n\ttype FieldChangeHandler,\n\ttype FieldChangeRebaser,\n\ttype FieldEditor,\n\ttype NodeChangeComposer,\n\ttype NodeChangeInverter,\n\ttype NodeChangeRebaser,\n\ttype NodeChangePruner,\n\treferenceFreeFieldChangeRebaser,\n\ttype RebaseRevisionMetadata,\n\ttype RelevantRemovedRootsFromChild,\n\ttype ToDelta,\n\tNodeAttachState,\n\ttype FieldChangeEncodingContext,\n} from \"./fieldChangeHandler.js\";\nexport type {\n\tCrossFieldKeyRange,\n\tFieldChange,\n\tFieldChangeMap,\n\tFieldChangeset,\n\tHasFieldChanges,\n\tModularChangeset,\n\tNodeExistsConstraint,\n\tNodeId,\n} from \"./modularChangeTypes.js\";\nexport {\n\tconvertGenericChange,\n\tgenericChangeHandler,\n\tgenericFieldKind,\n} from \"./genericFieldKind.js\";\nexport type { GenericChangeset } from \"./genericFieldKindTypes.js\";\nexport {\n\tModularChangeFamily,\n\tModularEditBuilder,\n\ttype EditDescription,\n\ttype GlobalEditDescription,\n\ttype FieldEditDescription,\n\trebaseRevisionMetadataFromInfo,\n\tintoDelta,\n\trelevantRemovedRoots,\n\tupdateRefreshers,\n} from \"./modularChangeFamily.js\";\nexport { makeModularChangeCodecFamily } from \"./modularChangeCodecs.js\";\nexport type {\n\tFieldKindConfiguration,\n\tFieldKindConfigurationEntry,\n} from \"./fieldKindConfiguration.js\";\nexport {\n\tgetAllowedContentDiscrepancies,\n\tisRepoSuperset,\n\ttype AllowedTypeDiscrepancy,\n\ttype FieldKindDiscrepancy,\n\ttype ValueSchemaDiscrepancy,\n\ttype FieldDiscrepancy,\n\ttype NodeDiscrepancy,\n\ttype NodeKindDiscrepancy,\n\ttype NodeFieldsDiscrepancy,\n\ttype LinearExtension,\n\ttype Realizer,\n\tfieldRealizer,\n\tPosetComparisonResult,\n\tcomparePosetElements,\n\tposetLte,\n} from \"./discrepancies.js\";\n"]}
@@ -5,7 +5,6 @@
5
5
  import { type TreeFieldStoredSchema, type TreeNodeStoredSchema, type TreeStoredSchema } from "../../core/index.js";
6
6
  import type { FullSchemaPolicy } from "./fieldKind.js";
7
7
  /**
8
- * @internal
9
8
  */
10
9
  export declare function isNeverField(policy: FullSchemaPolicy, originalData: TreeStoredSchema, field: TreeFieldStoredSchema): boolean;
11
10
  export declare function isNeverFieldRecursive(policy: FullSchemaPolicy, originalData: TreeStoredSchema, field: TreeFieldStoredSchema, parentTypeStack: Set<TreeNodeStoredSchema>): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"isNeverTree.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/isNeverTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAIN,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAErB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;GAEG;AAEH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,KAAK,EAAE,qBAAqB,GAC1B,OAAO,CAET;AAED,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,KAAK,EAAE,qBAAqB,EAC5B,eAAe,EAAE,GAAG,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAuBT;AACD;;;;;GAKG;AAEH,wBAAgB,WAAW,CAC1B,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,oBAAoB,GAAG,SAAS,GACxC,OAAO,CAET;AACD;;;;;GAKG;AAEH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAC1C,eAAe,EAAE,GAAG,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAgCT"}
1
+ {"version":3,"file":"isNeverTree.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/isNeverTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAIN,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAErB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;GACG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,KAAK,EAAE,qBAAqB,GAC1B,OAAO,CAET;AAED,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,KAAK,EAAE,qBAAqB,EAC5B,eAAe,EAAE,GAAG,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAuBT;AACD;;;;;GAKG;AAEH,wBAAgB,WAAW,CAC1B,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,oBAAoB,GAAG,SAAS,GACxC,OAAO,CAET;AACD;;;;;GAKG;AAEH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAC1C,eAAe,EAAE,GAAG,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAgCT"}
@@ -9,7 +9,6 @@ const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../../core/index.js");
10
10
  const index_js_2 = require("../../util/index.js");
11
11
  /**
12
- * @internal
13
12
  */
14
13
  function isNeverField(policy, originalData, field) {
15
14
  return isNeverFieldRecursive(policy, originalData, field, new Set());
@@ -1 +1 @@
1
- {"version":3,"file":"isNeverTree.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/isNeverTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,kDAQ6B;AAC7B,kDAA2C;AAI3C;;GAEG;AAEH,SAAgB,YAAY,CAC3B,MAAwB,EACxB,YAA8B,EAC9B,KAA4B;IAE5B,OAAO,qBAAqB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AACtE,CAAC;AAND,oCAMC;AAED,SAAgB,qBAAqB,CACpC,MAAwB,EACxB,YAA8B,EAC9B,KAA4B,EAC5B,eAA0C;IAE1C,IACC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,oBAAoB,CAAC,CAAC,CAAC,YAAY;QAC7E,uBAAY,CAAC,MAAM;QACpB,KAAK,CAAC,KAAK,KAAK,SAAS,EACxB,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChC,IACC,CAAC,oBAAoB,CACpB,MAAM,EACN,YAAY,EACZ,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EACjC,eAAe,CACf,EACA,CAAC;gBACF,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;QACD,iGAAiG;QACjG,qGAAqG;QACrG,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AA5BD,sDA4BC;AACD;;;;;GAKG;AAEH,SAAgB,WAAW,CAC1B,MAAwB,EACxB,YAA8B,EAC9B,QAA0C;IAE1C,OAAO,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AACxE,CAAC;AAND,kCAMC;AACD;;;;;GAKG;AAEH,SAAgB,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\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\tMultiplicity,\n} from \"../../core/index.js\";\nimport { fail } from \"../../util/index.js\";\n\nimport type { FullSchemaPolicy } from \"./fieldKind.js\";\n\n/**\n * @internal\n */\n\nexport function isNeverField(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\tfield: TreeFieldStoredSchema,\n): boolean {\n\treturn isNeverFieldRecursive(policy, originalData, field, new Set());\n}\n\nexport function isNeverFieldRecursive(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\tfield: TreeFieldStoredSchema,\n\tparentTypeStack: Set<TreeNodeStoredSchema>,\n): boolean {\n\tif (\n\t\t(policy.fieldKinds.get(field.kind) ?? fail(\"missing field kind\")).multiplicity ===\n\t\t\tMultiplicity.Single &&\n\t\tfield.types !== undefined\n\t) {\n\t\tfor (const type of field.types) {\n\t\t\tif (\n\t\t\t\t!isNeverTreeRecursive(\n\t\t\t\t\tpolicy,\n\t\t\t\t\toriginalData,\n\t\t\t\t\toriginalData.nodeSchema.get(type),\n\t\t\t\t\tparentTypeStack,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t// This field requires at least one child, and there are no types permitted in it that can exist,\n\t\t// so this is a never field (field which no sequence of children content could ever be in schema for)\n\t\treturn true;\n\t}\n\treturn false;\n}\n/**\n * Returns true iff there are no possible trees that could meet this schema.\n * Trees which are infinite (like endless linked lists) are considered impossible.\n *\n * `undefined` means the schema is not present and thus a NeverTree.\n */\n\nexport function isNeverTree(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\ttreeNode: TreeNodeStoredSchema | undefined,\n): boolean {\n\treturn isNeverTreeRecursive(policy, originalData, treeNode, new Set());\n}\n/**\n * Returns true iff there are no possible trees that could meet this schema.\n * Trees which are infinite (like endless linked lists) are considered impossible.\n *\n * `undefined` means the schema is not present and thus a NeverTree.\n */\n\nexport function isNeverTreeRecursive(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\ttreeNode: TreeNodeStoredSchema | undefined,\n\tparentTypeStack: Set<TreeNodeStoredSchema>,\n): boolean {\n\tif (treeNode === undefined) {\n\t\treturn true;\n\t}\n\tif (parentTypeStack.has(treeNode)) {\n\t\treturn true;\n\t}\n\ttry {\n\t\tparentTypeStack.add(treeNode);\n\t\tif (treeNode instanceof MapNodeStoredSchema) {\n\t\t\treturn (\n\t\t\t\t(policy.fieldKinds.get(treeNode.mapFields.kind) ?? fail(\"missing field kind\"))\n\t\t\t\t\t.multiplicity === Multiplicity.Single\n\t\t\t);\n\t\t} else if (treeNode instanceof ObjectNodeStoredSchema) {\n\t\t\tfor (const field of treeNode.objectNodeFields.values()) {\n\t\t\t\t// TODO: this can recurse infinitely for schema that include themselves in a value field.\n\t\t\t\t// This breaks even if there are other allowed types.\n\t\t\t\t// Such schema should either be rejected (as an error here) or considered never (and thus detected by this).\n\t\t\t\t// This can be done by passing a set/stack of current types recursively here.\n\t\t\t\tif (isNeverFieldRecursive(policy, originalData, field, parentTypeStack)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t} else {\n\t\t\tassert(treeNode instanceof LeafNodeStoredSchema, 0x897 /* unsupported node kind */);\n\t\t\treturn false;\n\t\t}\n\t} finally {\n\t\tparentTypeStack.delete(treeNode);\n\t}\n}\n"]}
1
+ {"version":3,"file":"isNeverTree.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/isNeverTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,kDAQ6B;AAC7B,kDAA2C;AAI3C;GACG;AACH,SAAgB,YAAY,CAC3B,MAAwB,EACxB,YAA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IACD,IAAI,CAAC;QACJ,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,IAAI,QAAQ,YAAY,8BAAmB,EAAE,CAAC;YAC7C,OAAO,CACN,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,oBAAoB,CAAC,CAAC;iBAC5E,YAAY,KAAK,uBAAY,CAAC,MAAM,CACtC,CAAC;QACH,CAAC;aAAM,IAAI,QAAQ,YAAY,iCAAsB,EAAE,CAAC;YACvD,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC;gBACxD,yFAAyF;gBACzF,qDAAqD;gBACrD,4GAA4G;gBAC5G,6EAA6E;gBAC7E,IAAI,qBAAqB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,CAAC,EAAE,CAAC;oBACzE,OAAO,IAAI,CAAC;gBACb,CAAC;YACF,CAAC;YACD,OAAO,KAAK,CAAC;QACd,CAAC;aAAM,CAAC;YACP,IAAA,iBAAM,EAAC,QAAQ,YAAY,+BAAoB,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAC;YACpF,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;YAAS,CAAC;QACV,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;AACF,CAAC;AArCD,oDAqCC","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\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\tMultiplicity,\n} from \"../../core/index.js\";\nimport { fail } from \"../../util/index.js\";\n\nimport type { FullSchemaPolicy } from \"./fieldKind.js\";\n\n/**\n */\nexport function isNeverField(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\tfield: TreeFieldStoredSchema,\n): boolean {\n\treturn isNeverFieldRecursive(policy, originalData, field, new Set());\n}\n\nexport function isNeverFieldRecursive(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\tfield: TreeFieldStoredSchema,\n\tparentTypeStack: Set<TreeNodeStoredSchema>,\n): boolean {\n\tif (\n\t\t(policy.fieldKinds.get(field.kind) ?? fail(\"missing field kind\")).multiplicity ===\n\t\t\tMultiplicity.Single &&\n\t\tfield.types !== undefined\n\t) {\n\t\tfor (const type of field.types) {\n\t\t\tif (\n\t\t\t\t!isNeverTreeRecursive(\n\t\t\t\t\tpolicy,\n\t\t\t\t\toriginalData,\n\t\t\t\t\toriginalData.nodeSchema.get(type),\n\t\t\t\t\tparentTypeStack,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t// This field requires at least one child, and there are no types permitted in it that can exist,\n\t\t// so this is a never field (field which no sequence of children content could ever be in schema for)\n\t\treturn true;\n\t}\n\treturn false;\n}\n/**\n * Returns true iff there are no possible trees that could meet this schema.\n * Trees which are infinite (like endless linked lists) are considered impossible.\n *\n * `undefined` means the schema is not present and thus a NeverTree.\n */\n\nexport function isNeverTree(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\ttreeNode: TreeNodeStoredSchema | undefined,\n): boolean {\n\treturn isNeverTreeRecursive(policy, originalData, treeNode, new Set());\n}\n/**\n * Returns true iff there are no possible trees that could meet this schema.\n * Trees which are infinite (like endless linked lists) are considered impossible.\n *\n * `undefined` means the schema is not present and thus a NeverTree.\n */\n\nexport function isNeverTreeRecursive(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\ttreeNode: TreeNodeStoredSchema | undefined,\n\tparentTypeStack: Set<TreeNodeStoredSchema>,\n): boolean {\n\tif (treeNode === undefined) {\n\t\treturn true;\n\t}\n\tif (parentTypeStack.has(treeNode)) {\n\t\treturn true;\n\t}\n\ttry {\n\t\tparentTypeStack.add(treeNode);\n\t\tif (treeNode instanceof MapNodeStoredSchema) {\n\t\t\treturn (\n\t\t\t\t(policy.fieldKinds.get(treeNode.mapFields.kind) ?? fail(\"missing field kind\"))\n\t\t\t\t\t.multiplicity === Multiplicity.Single\n\t\t\t);\n\t\t} else if (treeNode instanceof ObjectNodeStoredSchema) {\n\t\t\tfor (const field of treeNode.objectNodeFields.values()) {\n\t\t\t\t// TODO: this can recurse infinitely for schema that include themselves in a value field.\n\t\t\t\t// This breaks even if there are other allowed types.\n\t\t\t\t// Such schema should either be rejected (as an error here) or considered never (and thus detected by this).\n\t\t\t\t// This can be done by passing a set/stack of current types recursively here.\n\t\t\t\tif (isNeverFieldRecursive(policy, originalData, field, parentTypeStack)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t} else {\n\t\t\tassert(treeNode instanceof LeafNodeStoredSchema, 0x897 /* unsupported node kind */);\n\t\t\treturn false;\n\t\t}\n\t} finally {\n\t\tparentTypeStack.delete(treeNode);\n\t}\n}\n"]}