@fluidframework/tree 2.10.0-305357 → 2.10.0-307060

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 (292) hide show
  1. package/.eslintrc.cjs +56 -25
  2. package/api-report/tree.alpha.api.md +14 -11
  3. package/api-report/tree.beta.api.md +5 -2
  4. package/api-report/tree.legacy.alpha.api.md +5 -2
  5. package/api-report/tree.legacy.public.api.md +5 -2
  6. package/api-report/tree.public.api.md +5 -2
  7. package/dist/core/forest/forest.d.ts +5 -1
  8. package/dist/core/forest/forest.d.ts.map +1 -1
  9. package/dist/core/forest/forest.js.map +1 -1
  10. package/dist/core/index.d.ts +1 -1
  11. package/dist/core/index.d.ts.map +1 -1
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/schema-stored/storedSchemaRepository.d.ts +7 -3
  14. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  15. package/dist/core/schema-stored/storedSchemaRepository.js +4 -6
  16. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  17. package/dist/core/tree/anchorSet.d.ts +8 -5
  18. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  19. package/dist/core/tree/anchorSet.js +12 -11
  20. package/dist/core/tree/anchorSet.js.map +1 -1
  21. package/dist/events/emitter.d.ts +21 -9
  22. package/dist/events/emitter.d.ts.map +1 -1
  23. package/dist/events/emitter.js +36 -21
  24. package/dist/events/emitter.js.map +1 -1
  25. package/dist/events/listeners.d.ts +16 -5
  26. package/dist/events/listeners.d.ts.map +1 -1
  27. package/dist/events/listeners.js.map +1 -1
  28. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +26 -5
  29. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  30. package/dist/feature-libraries/chunked-forest/basicChunk.js +15 -5
  31. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  32. package/dist/feature-libraries/chunked-forest/chunkTree.js +1 -1
  33. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  34. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +3 -2
  35. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/chunkedForest.js +19 -9
  37. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  38. package/dist/feature-libraries/flex-tree/context.d.ts +3 -2
  39. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  40. package/dist/feature-libraries/flex-tree/context.js +3 -3
  41. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  42. package/dist/feature-libraries/flex-tree/lazyField.js +1 -1
  43. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  44. package/dist/feature-libraries/flex-tree/lazyNode.js +1 -1
  45. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  46. package/dist/feature-libraries/flex-tree/utilities.js +1 -1
  47. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  48. package/dist/feature-libraries/index.d.ts +1 -1
  49. package/dist/feature-libraries/index.d.ts.map +1 -1
  50. package/dist/feature-libraries/index.js +2 -2
  51. package/dist/feature-libraries/index.js.map +1 -1
  52. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  53. package/dist/feature-libraries/modular-schema/comparison.js +3 -0
  54. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  55. package/dist/feature-libraries/modular-schema/discrepancies.d.ts +29 -29
  56. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  57. package/dist/feature-libraries/modular-schema/discrepancies.js +121 -75
  58. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  59. package/dist/feature-libraries/modular-schema/genericFieldKind.js +2 -2
  60. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  61. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  62. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  63. package/dist/feature-libraries/modular-schema/index.js +2 -2
  64. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  65. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1 -1
  66. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  67. package/dist/feature-libraries/object-forest/objectForest.d.ts +2 -2
  68. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  69. package/dist/feature-libraries/object-forest/objectForest.js +6 -8
  70. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  71. package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -1
  72. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  73. package/dist/feature-libraries/sequence-field/compose.js +2 -2
  74. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  75. package/dist/feature-libraries/sequence-field/markListFactory.js +1 -1
  76. package/dist/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  77. package/dist/packageVersion.d.ts +1 -1
  78. package/dist/packageVersion.js +1 -1
  79. package/dist/packageVersion.js.map +1 -1
  80. package/dist/shared-tree/schematizingTreeView.js +2 -2
  81. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  82. package/dist/shared-tree/treeApi.js +6 -3
  83. package/dist/shared-tree/treeApi.js.map +1 -1
  84. package/dist/shared-tree/treeCheckout.js +7 -7
  85. package/dist/shared-tree/treeCheckout.js.map +1 -1
  86. package/dist/shared-tree-core/branch.d.ts +7 -7
  87. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  88. package/dist/shared-tree-core/branch.js +35 -25
  89. package/dist/shared-tree-core/branch.js.map +1 -1
  90. package/dist/shared-tree-core/editManager.js +4 -4
  91. package/dist/shared-tree-core/editManager.js.map +1 -1
  92. package/dist/shared-tree-core/sharedTreeCore.js +5 -5
  93. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  94. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +12 -14
  95. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  96. package/dist/simple-tree/api/schemaCreationUtilities.js +9 -7
  97. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  98. package/dist/simple-tree/api/schemaFactory.d.ts +68 -10
  99. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  100. package/dist/simple-tree/api/schemaFactory.js +38 -10
  101. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  102. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  103. package/dist/simple-tree/api/treeNodeApi.js +4 -4
  104. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  105. package/dist/simple-tree/arrayNode.js +1 -1
  106. package/dist/simple-tree/arrayNode.js.map +1 -1
  107. package/dist/simple-tree/core/treeNodeKernel.d.ts +7 -8
  108. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  109. package/dist/simple-tree/core/treeNodeKernel.js +68 -73
  110. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  111. package/dist/simple-tree/objectNode.d.ts +1 -1
  112. package/dist/simple-tree/objectNode.js.map +1 -1
  113. package/dist/simple-tree/objectNodeTypes.d.ts +3 -0
  114. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  115. package/dist/simple-tree/objectNodeTypes.js +3 -1
  116. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  117. package/dist/simple-tree/proxies.js +1 -1
  118. package/dist/simple-tree/proxies.js.map +1 -1
  119. package/dist/simple-tree/schemaTypes.d.ts +26 -1
  120. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  121. package/dist/simple-tree/schemaTypes.js.map +1 -1
  122. package/dist/simple-tree/treeNodeValid.js +2 -2
  123. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  124. package/dist/util/nestedMap.d.ts.map +1 -1
  125. package/dist/util/nestedMap.js.map +1 -1
  126. package/docs/.attachments/object-merge-semantics.drawio +145 -0
  127. package/docs/user-facing/array-merge-semantics.md +344 -0
  128. package/docs/user-facing/map-merge-semantics.md +128 -0
  129. package/docs/user-facing/merge-semantics.md +7 -3
  130. package/docs/user-facing/object-merge-semantics.md +77 -0
  131. package/lib/core/forest/forest.d.ts +5 -1
  132. package/lib/core/forest/forest.d.ts.map +1 -1
  133. package/lib/core/forest/forest.js.map +1 -1
  134. package/lib/core/index.d.ts +1 -1
  135. package/lib/core/index.d.ts.map +1 -1
  136. package/lib/core/index.js.map +1 -1
  137. package/lib/core/schema-stored/storedSchemaRepository.d.ts +7 -3
  138. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  139. package/lib/core/schema-stored/storedSchemaRepository.js +4 -6
  140. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  141. package/lib/core/tree/anchorSet.d.ts +8 -5
  142. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  143. package/lib/core/tree/anchorSet.js +12 -11
  144. package/lib/core/tree/anchorSet.js.map +1 -1
  145. package/lib/events/emitter.d.ts +21 -9
  146. package/lib/events/emitter.d.ts.map +1 -1
  147. package/lib/events/emitter.js +37 -22
  148. package/lib/events/emitter.js.map +1 -1
  149. package/lib/events/listeners.d.ts +16 -5
  150. package/lib/events/listeners.d.ts.map +1 -1
  151. package/lib/events/listeners.js.map +1 -1
  152. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +26 -5
  153. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  154. package/lib/feature-libraries/chunked-forest/basicChunk.js +15 -5
  155. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  156. package/lib/feature-libraries/chunked-forest/chunkTree.js +1 -1
  157. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  158. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +3 -2
  159. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  160. package/lib/feature-libraries/chunked-forest/chunkedForest.js +19 -9
  161. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  162. package/lib/feature-libraries/flex-tree/context.d.ts +3 -2
  163. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  164. package/lib/feature-libraries/flex-tree/context.js +3 -3
  165. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  166. package/lib/feature-libraries/flex-tree/lazyField.js +1 -1
  167. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  168. package/lib/feature-libraries/flex-tree/lazyNode.js +1 -1
  169. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  170. package/lib/feature-libraries/flex-tree/utilities.js +1 -1
  171. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  172. package/lib/feature-libraries/index.d.ts +1 -1
  173. package/lib/feature-libraries/index.d.ts.map +1 -1
  174. package/lib/feature-libraries/index.js +1 -1
  175. package/lib/feature-libraries/index.js.map +1 -1
  176. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  177. package/lib/feature-libraries/modular-schema/comparison.js +3 -0
  178. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  179. package/lib/feature-libraries/modular-schema/discrepancies.d.ts +29 -29
  180. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  181. package/lib/feature-libraries/modular-schema/discrepancies.js +120 -74
  182. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  183. package/lib/feature-libraries/modular-schema/genericFieldKind.js +2 -2
  184. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  185. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  186. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  187. package/lib/feature-libraries/modular-schema/index.js +1 -1
  188. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  189. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1 -1
  190. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  191. package/lib/feature-libraries/object-forest/objectForest.d.ts +2 -2
  192. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  193. package/lib/feature-libraries/object-forest/objectForest.js +6 -8
  194. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  195. package/lib/feature-libraries/schema-index/schemaSummarizer.js +1 -1
  196. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  197. package/lib/feature-libraries/sequence-field/compose.js +2 -2
  198. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  199. package/lib/feature-libraries/sequence-field/markListFactory.js +1 -1
  200. package/lib/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  201. package/lib/packageVersion.d.ts +1 -1
  202. package/lib/packageVersion.js +1 -1
  203. package/lib/packageVersion.js.map +1 -1
  204. package/lib/shared-tree/schematizingTreeView.js +2 -2
  205. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  206. package/lib/shared-tree/treeApi.js +7 -4
  207. package/lib/shared-tree/treeApi.js.map +1 -1
  208. package/lib/shared-tree/treeCheckout.js +7 -7
  209. package/lib/shared-tree/treeCheckout.js.map +1 -1
  210. package/lib/shared-tree-core/branch.d.ts +7 -7
  211. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  212. package/lib/shared-tree-core/branch.js +36 -26
  213. package/lib/shared-tree-core/branch.js.map +1 -1
  214. package/lib/shared-tree-core/editManager.js +4 -4
  215. package/lib/shared-tree-core/editManager.js.map +1 -1
  216. package/lib/shared-tree-core/sharedTreeCore.js +5 -5
  217. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  218. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +12 -14
  219. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  220. package/lib/simple-tree/api/schemaCreationUtilities.js +9 -7
  221. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  222. package/lib/simple-tree/api/schemaFactory.d.ts +68 -10
  223. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  224. package/lib/simple-tree/api/schemaFactory.js +38 -10
  225. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  226. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  227. package/lib/simple-tree/api/treeNodeApi.js +4 -4
  228. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  229. package/lib/simple-tree/arrayNode.js +1 -1
  230. package/lib/simple-tree/arrayNode.js.map +1 -1
  231. package/lib/simple-tree/core/treeNodeKernel.d.ts +7 -8
  232. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  233. package/lib/simple-tree/core/treeNodeKernel.js +69 -74
  234. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  235. package/lib/simple-tree/objectNode.d.ts +1 -1
  236. package/lib/simple-tree/objectNode.js.map +1 -1
  237. package/lib/simple-tree/objectNodeTypes.d.ts +3 -0
  238. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  239. package/lib/simple-tree/objectNodeTypes.js +3 -1
  240. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  241. package/lib/simple-tree/proxies.js +1 -1
  242. package/lib/simple-tree/proxies.js.map +1 -1
  243. package/lib/simple-tree/schemaTypes.d.ts +26 -1
  244. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  245. package/lib/simple-tree/schemaTypes.js.map +1 -1
  246. package/lib/simple-tree/treeNodeValid.js +2 -2
  247. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  248. package/lib/util/nestedMap.d.ts.map +1 -1
  249. package/lib/util/nestedMap.js.map +1 -1
  250. package/package.json +20 -20
  251. package/src/core/forest/forest.ts +6 -1
  252. package/src/core/index.ts +1 -1
  253. package/src/core/schema-stored/storedSchemaRepository.ts +10 -13
  254. package/src/core/tree/anchorSet.ts +13 -20
  255. package/src/events/emitter.ts +45 -24
  256. package/src/events/listeners.ts +17 -5
  257. package/src/feature-libraries/chunked-forest/basicChunk.ts +12 -4
  258. package/src/feature-libraries/chunked-forest/chunkTree.ts +1 -1
  259. package/src/feature-libraries/chunked-forest/chunkedForest.ts +13 -14
  260. package/src/feature-libraries/flex-tree/context.ts +5 -7
  261. package/src/feature-libraries/flex-tree/lazyField.ts +1 -1
  262. package/src/feature-libraries/flex-tree/lazyNode.ts +1 -1
  263. package/src/feature-libraries/flex-tree/utilities.ts +1 -1
  264. package/src/feature-libraries/index.ts +1 -1
  265. package/src/feature-libraries/modular-schema/comparison.ts +4 -0
  266. package/src/feature-libraries/modular-schema/discrepancies.ts +188 -124
  267. package/src/feature-libraries/modular-schema/genericFieldKind.ts +2 -2
  268. package/src/feature-libraries/modular-schema/index.ts +4 -1
  269. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +1 -1
  270. package/src/feature-libraries/object-forest/objectForest.ts +5 -11
  271. package/src/feature-libraries/schema-index/schemaSummarizer.ts +1 -1
  272. package/src/feature-libraries/sequence-field/compose.ts +2 -2
  273. package/src/feature-libraries/sequence-field/markListFactory.ts +1 -1
  274. package/src/packageVersion.ts +1 -1
  275. package/src/shared-tree/schematizingTreeView.ts +2 -2
  276. package/src/shared-tree/treeApi.ts +9 -7
  277. package/src/shared-tree/treeCheckout.ts +7 -7
  278. package/src/shared-tree-core/branch.ts +30 -30
  279. package/src/shared-tree-core/editManager.ts +4 -4
  280. package/src/shared-tree-core/sharedTreeCore.ts +5 -5
  281. package/src/simple-tree/api/schemaCreationUtilities.ts +29 -17
  282. package/src/simple-tree/api/schemaFactory.ts +62 -29
  283. package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -1
  284. package/src/simple-tree/api/treeNodeApi.ts +4 -4
  285. package/src/simple-tree/arrayNode.ts +1 -1
  286. package/src/simple-tree/core/treeNodeKernel.ts +68 -72
  287. package/src/simple-tree/objectNode.ts +1 -1
  288. package/src/simple-tree/objectNodeTypes.ts +3 -1
  289. package/src/simple-tree/proxies.ts +1 -1
  290. package/src/simple-tree/schemaTypes.ts +26 -1
  291. package/src/simple-tree/treeNodeValid.ts +2 -2
  292. package/src/util/nestedMap.ts +1 -0
@@ -14,7 +14,7 @@ export { cursorForJsonableTreeNode, cursorForJsonableTreeField, jsonableTreeFrom
14
14
  // Split this up into separate import and export for compatibility with API-Extractor.
15
15
  import * as SequenceField from "./sequence-field/index.js";
16
16
  export { SequenceField };
17
- export { isNeverField, ModularEditBuilder, makeModularChangeCodecFamily, CrossFieldTarget, FlexFieldKind, allowsRepoSuperset, genericFieldKind, FieldKindWithEditor, ModularChangeFamily, EncodedModularChangeset, updateRefreshers, getAllowedContentIncompatibilities, isRepoSuperset, isNeverTree, } from "./modular-schema/index.js";
17
+ export { isNeverField, ModularEditBuilder, makeModularChangeCodecFamily, CrossFieldTarget, FlexFieldKind, allowsRepoSuperset, genericFieldKind, FieldKindWithEditor, ModularChangeFamily, EncodedModularChangeset, updateRefreshers, getAllowedContentDiscrepancies, isRepoSuperset, isNeverTree, } from "./modular-schema/index.js";
18
18
  export { mapRootChanges } from "./deltaUtils.js";
19
19
  export { chunkTree, chunkFieldSingle, buildChunkedForest, defaultChunkPolicy, makeTreeChunker, makeFieldBatchCodec, } from "./chunked-forest/index.js";
20
20
  export { compareLocalNodeKeys, createNodeKeyManager, isStableNodeKey, MockNodeKeyManager, nodeKeyTreeIdentifier, } from "./node-key/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feature-libraries/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,UAAU,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,wBAAwB,EAAgB,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAA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,kBAAkB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,OAAO,EAEN,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype DownPath,\n\ttoDownPath,\n} from \"./editableTreeBinder.js\";\nexport { allowsValue, assertAllowedValue, isTreeValue } from \"./valueUtilities.js\";\n\nexport { ForestSummarizer } from \"./forest-summary/index.js\";\nexport {\n\tcursorForMapTreeField,\n\tcursorForMapTreeNode,\n\tmapTreeFromCursor,\n\tmapTreeFieldFromCursor,\n} from \"./mapTreeCursor.js\";\nexport { MemoizedIdRangeAllocator, type IdRange } from \"./memoizedIdRangeAllocator.js\";\nexport { buildForest } from \"./object-forest/index.js\";\nexport { SchemaSummarizer, encodeTreeSchema, makeSchemaCodec } from \"./schema-index/index.js\";\nexport {\n\tstackTreeNodeCursor,\n\ttype CursorAdapter,\n\tprefixPath,\n\tprefixFieldPath,\n\ttype CursorWithNode,\n\tstackTreeFieldCursor,\n} from \"./treeCursorUtils.js\";\nexport {\n\tcursorForJsonableTreeNode,\n\tcursorForJsonableTreeField,\n\tjsonableTreeFromCursor,\n\tjsonableTreeFromFieldCursor,\n\tjsonableTreeFromForest,\n} from \"./treeTextCursor.js\";\n\n// Split this up into separate import and export for compatibility with API-Extractor.\nimport * as SequenceField from \"./sequence-field/index.js\";\nexport { SequenceField };\n\nexport {\n\tisNeverField,\n\tModularEditBuilder,\n\ttype FieldEditDescription as EditDescription,\n\ttype FieldChangeHandler,\n\ttype FieldChangeRebaser,\n\ttype FieldEditor,\n\ttype FieldChangeMap,\n\ttype FieldChange,\n\ttype FieldChangeset,\n\ttype ToDelta,\n\ttype ModularChangeset,\n\tmakeModularChangeCodecFamily,\n\ttype NodeChangeComposer,\n\ttype NodeChangeInverter,\n\ttype NodeChangeRebaser,\n\ttype NodeChangePruner,\n\ttype CrossFieldManager,\n\tCrossFieldTarget,\n\tFlexFieldKind,\n\ttype FullSchemaPolicy,\n\tallowsRepoSuperset,\n\ttype GenericChangeset,\n\tgenericFieldKind,\n\ttype HasFieldChanges,\n\ttype NodeExistsConstraint,\n\tFieldKindWithEditor,\n\tModularChangeFamily,\n\ttype RelevantRemovedRootsFromChild,\n\tEncodedModularChangeset,\n\tupdateRefreshers,\n\ttype NodeId,\n\ttype FieldChangeEncodingContext,\n\ttype FieldKindConfiguration,\n\ttype FieldKindConfigurationEntry,\n\tgetAllowedContentIncompatibilities,\n\tisRepoSuperset,\n\tisNeverTree,\n} from \"./modular-schema/index.js\";\n\nexport { mapRootChanges } from \"./deltaUtils.js\";\n\nexport {\n\ttype TreeChunk,\n\tchunkTree,\n\tchunkFieldSingle,\n\tbuildChunkedForest,\n\tdefaultChunkPolicy,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeTreeChunker,\n\tmakeFieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n} from \"./chunked-forest/index.js\";\n\nexport {\n\tcompareLocalNodeKeys,\n\tcreateNodeKeyManager,\n\tisStableNodeKey,\n\ttype LocalNodeKey,\n\tMockNodeKeyManager,\n\ttype NodeKeyManager,\n\tnodeKeyTreeIdentifier,\n\ttype StableNodeKey,\n} from \"./node-key/index.js\";\n\nexport {\n\tFieldKinds,\n\ttype Required,\n\ttype Optional,\n\ttype Sequence,\n\ttype Identifier,\n\ttype Forbidden,\n\ttype DefaultChangeset,\n\tDefaultChangeFamily,\n\tDefaultEditBuilder,\n\ttype IDefaultEditBuilder,\n\ttype ValueFieldEditBuilder,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\tdefaultSchemaPolicy,\n\tfieldKinds,\n\tfieldKindConfigurations,\n\tintoDelta,\n\trelevantRemovedRoots,\n\tSchemaValidationErrors,\n\tisNodeInSchema,\n\tisFieldInSchema,\n} from \"./default-schema/index.js\";\n\nexport {\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\tSkip,\n\ttype FlexTreeContext,\n\ttype FlexTreeHydratedContext,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeEntity,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\tgetTreeContext,\n\tTreeStatus,\n\tContext,\n\ttype FlexTreeNodeEvents,\n\ttype FlexTreeUnknownUnboxed,\n\tisFlexTreeNode,\n\tContextSlot,\n\t// Internal\n\tflexTreeMarker,\n\tassertFlexTreeEntityNotFreed,\n\tflexTreeSlot,\n\tgetSchemaAndPolicy,\n\tisFreedSymbol,\n\tLazyEntity,\n\ttreeStatusFromAnchorCache,\n\tindexForAt,\n\tFlexTreeEntityKind,\n} from \"./flex-tree/index.js\";\n\nexport { TreeCompressionStrategy } from \"./treeCompressionUtils.js\";\n\nexport { valueSchemaAllows } from \"./valueUtilities.js\";\n\nexport { DetachedFieldIndexSummarizer } from \"./detachedFieldIndexSummarizer.js\";\n\nexport {\n\ttype SchemaChange,\n\tmakeSchemaChangeCodecs,\n\tEncodedSchemaChange,\n} from \"./schema-edits/index.js\";\n\nexport { makeMitigatedChangeFamily } from \"./mitigatedChangeFamily.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feature-libraries/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,UAAU,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,E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EACd,eAAe,GACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAIN,IAAI,EAOJ,cAAc,EACd,UAAU,EACV,OAAO,EAGP,cAAc,EACd,WAAW;AACX,WAAW;AACX,cAAc,EACd,4BAA4B,EAC5B,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,yBAAyB,EACzB,UAAU,EACV,kBAAkB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,OAAO,EAEN,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype DownPath,\n\ttoDownPath,\n} from \"./editableTreeBinder.js\";\nexport { allowsValue, assertAllowedValue, isTreeValue } from \"./valueUtilities.js\";\n\nexport { ForestSummarizer } from \"./forest-summary/index.js\";\nexport {\n\tcursorForMapTreeField,\n\tcursorForMapTreeNode,\n\tmapTreeFromCursor,\n\tmapTreeFieldFromCursor,\n} from \"./mapTreeCursor.js\";\nexport { MemoizedIdRangeAllocator, type IdRange } from \"./memoizedIdRangeAllocator.js\";\nexport { buildForest } from \"./object-forest/index.js\";\nexport { SchemaSummarizer, encodeTreeSchema, makeSchemaCodec } from \"./schema-index/index.js\";\nexport {\n\tstackTreeNodeCursor,\n\ttype CursorAdapter,\n\tprefixPath,\n\tprefixFieldPath,\n\ttype CursorWithNode,\n\tstackTreeFieldCursor,\n} from \"./treeCursorUtils.js\";\nexport {\n\tcursorForJsonableTreeNode,\n\tcursorForJsonableTreeField,\n\tjsonableTreeFromCursor,\n\tjsonableTreeFromFieldCursor,\n\tjsonableTreeFromForest,\n} from \"./treeTextCursor.js\";\n\n// Split this up into separate import and export for compatibility with API-Extractor.\nimport * as SequenceField from \"./sequence-field/index.js\";\nexport { SequenceField };\n\nexport {\n\tisNeverField,\n\tModularEditBuilder,\n\ttype FieldEditDescription as EditDescription,\n\ttype FieldChangeHandler,\n\ttype FieldChangeRebaser,\n\ttype FieldEditor,\n\ttype FieldChangeMap,\n\ttype FieldChange,\n\ttype FieldChangeset,\n\ttype ToDelta,\n\ttype ModularChangeset,\n\tmakeModularChangeCodecFamily,\n\ttype NodeChangeComposer,\n\ttype NodeChangeInverter,\n\ttype NodeChangeRebaser,\n\ttype NodeChangePruner,\n\ttype CrossFieldManager,\n\tCrossFieldTarget,\n\tFlexFieldKind,\n\ttype FullSchemaPolicy,\n\tallowsRepoSuperset,\n\ttype GenericChangeset,\n\tgenericFieldKind,\n\ttype HasFieldChanges,\n\ttype NodeExistsConstraint,\n\tFieldKindWithEditor,\n\tModularChangeFamily,\n\ttype RelevantRemovedRootsFromChild,\n\tEncodedModularChangeset,\n\tupdateRefreshers,\n\ttype NodeId,\n\ttype FieldChangeEncodingContext,\n\ttype FieldKindConfiguration,\n\ttype FieldKindConfigurationEntry,\n\tgetAllowedContentDiscrepancies,\n\tisRepoSuperset,\n\tisNeverTree,\n} from \"./modular-schema/index.js\";\n\nexport { mapRootChanges } from \"./deltaUtils.js\";\n\nexport {\n\ttype TreeChunk,\n\tchunkTree,\n\tchunkFieldSingle,\n\tbuildChunkedForest,\n\tdefaultChunkPolicy,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeTreeChunker,\n\tmakeFieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n} from \"./chunked-forest/index.js\";\n\nexport {\n\tcompareLocalNodeKeys,\n\tcreateNodeKeyManager,\n\tisStableNodeKey,\n\ttype LocalNodeKey,\n\tMockNodeKeyManager,\n\ttype NodeKeyManager,\n\tnodeKeyTreeIdentifier,\n\ttype StableNodeKey,\n} from \"./node-key/index.js\";\n\nexport {\n\tFieldKinds,\n\ttype Required,\n\ttype Optional,\n\ttype Sequence,\n\ttype Identifier,\n\ttype Forbidden,\n\ttype DefaultChangeset,\n\tDefaultChangeFamily,\n\tDefaultEditBuilder,\n\ttype IDefaultEditBuilder,\n\ttype ValueFieldEditBuilder,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\tdefaultSchemaPolicy,\n\tfieldKinds,\n\tfieldKindConfigurations,\n\tintoDelta,\n\trelevantRemovedRoots,\n\tSchemaValidationErrors,\n\tisNodeInSchema,\n\tisFieldInSchema,\n} from \"./default-schema/index.js\";\n\nexport {\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\tSkip,\n\ttype FlexTreeContext,\n\ttype FlexTreeHydratedContext,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeEntity,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\tgetTreeContext,\n\tTreeStatus,\n\tContext,\n\ttype FlexTreeNodeEvents,\n\ttype FlexTreeUnknownUnboxed,\n\tisFlexTreeNode,\n\tContextSlot,\n\t// Internal\n\tflexTreeMarker,\n\tassertFlexTreeEntityNotFreed,\n\tflexTreeSlot,\n\tgetSchemaAndPolicy,\n\tisFreedSymbol,\n\tLazyEntity,\n\ttreeStatusFromAnchorCache,\n\tindexForAt,\n\tFlexTreeEntityKind,\n} from \"./flex-tree/index.js\";\n\nexport { TreeCompressionStrategy } from \"./treeCompressionUtils.js\";\n\nexport { valueSchemaAllows } from \"./valueUtilities.js\";\n\nexport { DetachedFieldIndexSummarizer } from \"./detachedFieldIndexSummarizer.js\";\n\nexport {\n\ttype SchemaChange,\n\tmakeSchemaChangeCodecs,\n\tEncodedSchemaChange,\n} from \"./schema-edits/index.js\";\n\nexport { makeMitigatedChangeFamily } from \"./mitigatedChangeFamily.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"comparison.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/comparison.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAIN,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAQvD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAC1C,QAAQ,EAAE,oBAAoB,GAAG,SAAS,GACxC,OAAO,CAgFT;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,QAAQ,EAAE,WAAW,GAAG,SAAS,EACjC,QAAQ,EAAE,WAAW,GAAG,SAAS,GAC/B,OAAO,CAET;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,qBAAqB,EAC/B,QAAQ,EAAE,qBAAqB,GAC7B,OAAO,CAIT;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CACjD,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,WAAW,GACnB,OAAO,CAOT;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACxB,OAAO,CAqBT;AAED,wBAAgB,cAAc,CAC7B,MAAM,EAAE,qBAAqB,GAAG,SAAS,GACvC,qBAAqB,CAEvB"}
1
+ {"version":3,"file":"comparison.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/comparison.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAIN,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAQvD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAC1C,QAAQ,EAAE,oBAAoB,GAAG,SAAS,GACxC,OAAO,CAoFT;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,QAAQ,EAAE,WAAW,GAAG,SAAS,EACjC,QAAQ,EAAE,WAAW,GAAG,SAAS,GAC/B,OAAO,CAET;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,qBAAqB,EAC/B,QAAQ,EAAE,qBAAqB,GAC7B,OAAO,CAIT;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CACjD,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,WAAW,GACnB,OAAO,CAOT;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACxB,OAAO,CAqBT;AAED,wBAAgB,cAAc,CAC7B,MAAM,EAAE,qBAAqB,GAAG,SAAS,GACvC,qBAAqB,CAEvB"}
@@ -32,6 +32,9 @@ export function allowsTreeSuperset(policy, originalData, original, superset) {
32
32
  }
33
33
  return false;
34
34
  }
35
+ if (superset instanceof LeafNodeStoredSchema) {
36
+ return false;
37
+ }
35
38
  assert(original instanceof MapNodeStoredSchema || original instanceof ObjectNodeStoredSchema, 0x893 /* unsupported node kind */);
36
39
  assert(superset instanceof MapNodeStoredSchema || superset instanceof ObjectNodeStoredSchema, 0x894 /* unsupported node kind */);
37
40
  if (original instanceof MapNodeStoredSchema) {
@@ -1 +1 @@
1
- {"version":3,"file":"comparison.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/comparison.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EACN,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EAMtB,sBAAsB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,QAAQ;AACR,8EAA8E;AAC9E,mLAAmL;AAEnL;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CACjC,MAAwB,EACxB,YAA8B,EAC9B,QAA0C,EAC1C,QAA0C;IAE1C,IAAI,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,CAAC;QACjD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,4CAA4C,CAAC,CAAC;IACnF,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,4CAA4C,CAAC,CAAC;IACnF,IAAI,QAAQ,YAAY,oBAAoB,EAAE,CAAC;QAC9C,IAAI,QAAQ,YAAY,oBAAoB,EAAE,CAAC;YAC9C,OAAO,mBAAmB,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,CACL,QAA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AAO,IAAI,CAAC;AACb,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CACjC,MAAwB,EACxB,QAA0B,EAC1B,QAA0B;IAE1B,CAAC;QACA,0GAA0G;QAC1G,IACC,CAAC,mBAAmB,CACnB,MAAM,EACN,QAAQ,EACR,QAAQ,CAAC,eAAe,EACxB,QAAQ,CAAC,eAAe,CACxB,EACA,CAAC;YACF,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;QACjD,yGAAyG;QACzG,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACjF,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,UAAU,cAAc,CAC7B,MAAyC;IAEzC,OAAO,MAAM,IAAI,sBAAsB,CAAC;AACzC,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\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n\ttype ValueSchema,\n\tstoredEmptyFieldSchema,\n} from \"../../core/index.js\";\nimport { compareSets, fail } from \"../../util/index.js\";\n\nimport type { FullSchemaPolicy } from \"./fieldKind.js\";\nimport { withEditor } from \"./fieldKindWithEditor.js\";\nimport { isNeverTree } from \"./isNeverTree.js\";\n\n// TODO:\n// The comparisons in this file seem redundant with those in discrepancies.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 * @returns true iff `superset` is a superset of `original`.\n *\n * This does not require a strict (aka proper) superset: equivalent schema will return true.\n *\n * `undefined` TreeNodeStoredSchema means the schema is not present (and thus treated as a NeverTree).\n */\nexport function allowsTreeSuperset(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\toriginal: TreeNodeStoredSchema | undefined,\n\tsuperset: TreeNodeStoredSchema | undefined,\n): boolean {\n\tif (isNeverTree(policy, originalData, original)) {\n\t\treturn true;\n\t}\n\tif (isNeverTree(policy, originalData, superset)) {\n\t\treturn false;\n\t}\n\tassert(original !== undefined, 0x716 /* only never trees have undefined schema */);\n\tassert(superset !== undefined, 0x717 /* only never trees have undefined schema */);\n\tif (original instanceof LeafNodeStoredSchema) {\n\t\tif (superset instanceof LeafNodeStoredSchema) {\n\t\t\treturn allowsValueSuperset(original.leafValue, superset.leafValue);\n\t\t}\n\t\treturn false;\n\t}\n\n\tassert(\n\t\toriginal instanceof MapNodeStoredSchema || original instanceof ObjectNodeStoredSchema,\n\t\t0x893 /* unsupported node kind */,\n\t);\n\tassert(\n\t\tsuperset instanceof MapNodeStoredSchema || superset instanceof ObjectNodeStoredSchema,\n\t\t0x894 /* unsupported node kind */,\n\t);\n\n\tif (original instanceof MapNodeStoredSchema) {\n\t\tif (superset instanceof MapNodeStoredSchema) {\n\t\t\treturn allowsFieldSuperset(\n\t\t\t\tpolicy,\n\t\t\t\toriginalData,\n\t\t\t\tnormalizeField(original.mapFields),\n\t\t\t\tnormalizeField(superset.mapFields),\n\t\t\t);\n\t\t}\n\t\treturn false;\n\t}\n\n\tassert(original instanceof ObjectNodeStoredSchema, 0x895 /* unsupported node kind */);\n\tif (superset instanceof MapNodeStoredSchema) {\n\t\tfor (const [_key, field] of original.objectNodeFields) {\n\t\t\tif (\n\t\t\t\t!allowsFieldSuperset(\n\t\t\t\t\tpolicy,\n\t\t\t\t\toriginalData,\n\t\t\t\t\tnormalizeField(field),\n\t\t\t\t\tnormalizeField(superset.mapFields),\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tassert(superset instanceof ObjectNodeStoredSchema, 0x896 /* unsupported node kind */);\n\n\treturn compareSets({\n\t\ta: original.objectNodeFields,\n\t\tb: superset.objectNodeFields,\n\t\taExtra: (originalField) =>\n\t\t\tallowsFieldSuperset(\n\t\t\t\tpolicy,\n\t\t\t\toriginalData,\n\t\t\t\toriginal.objectNodeFields.get(originalField) ?? fail(\"missing expected field\"),\n\t\t\t\tnormalizeField(undefined),\n\t\t\t),\n\t\tbExtra: (supersetField) =>\n\t\t\tallowsFieldSuperset(\n\t\t\t\tpolicy,\n\t\t\t\toriginalData,\n\t\t\t\tnormalizeField(undefined),\n\t\t\t\tsuperset.objectNodeFields.get(supersetField) ?? fail(\"missing expected field\"),\n\t\t\t),\n\t\tsame: (sameField) =>\n\t\t\tallowsFieldSuperset(\n\t\t\t\tpolicy,\n\t\t\t\toriginalData,\n\t\t\t\toriginal.objectNodeFields.get(sameField) ?? fail(\"missing expected field\"),\n\t\t\t\tsuperset.objectNodeFields.get(sameField) ?? fail(\"missing expected field\"),\n\t\t\t),\n\t});\n}\n\n/**\n * @returns true iff `superset` is a superset of `original`.\n *\n * This does not require a strict (aka proper) superset: equivalent schema will return true.\n */\nexport function allowsValueSuperset(\n\toriginal: ValueSchema | undefined,\n\tsuperset: ValueSchema | undefined,\n): boolean {\n\treturn original === superset;\n}\n\n/**\n * @returns true iff `superset` is a superset of `original`.\n *\n * This does not require a strict (aka proper) superset: equivalent schema will return true.\n */\nexport function allowsFieldSuperset(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\toriginal: TreeFieldStoredSchema,\n\tsuperset: TreeFieldStoredSchema,\n): boolean {\n\treturn withEditor(\n\t\tpolicy.fieldKinds.get(original.kind) ?? fail(\"missing kind\"),\n\t).allowsFieldSuperset(policy, originalData, original.types, superset);\n}\n\n/**\n * @returns true iff `superset` is a superset of `original`.\n *\n * This does not require a strict (aka proper) superset: equivalent schema will return true.\n */\nexport function allowsTreeSchemaIdentifierSuperset(\n\toriginal: TreeTypeSet,\n\tsuperset: TreeTypeSet,\n): boolean {\n\tfor (const originalType of original) {\n\t\tif (!superset.has(originalType)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * @returns true iff `superset` is a superset of `original`.\n *\n * This does not require a strict (aka proper) superset: equivalent schema will return true.\n *\n * A version of this that assumes a specific root field could be slightly more permissive in some simple cases,\n * however if any extra fields and fields with unconstrained types are reachable,\n * it would have to compare everything anyway.\n */\nexport function allowsRepoSuperset(\n\tpolicy: FullSchemaPolicy,\n\toriginal: TreeStoredSchema,\n\tsuperset: TreeStoredSchema,\n): boolean {\n\t{\n\t\t// TODO: I think its ok to use the field from superset here, but I should confirm it is, and document why.\n\t\tif (\n\t\t\t!allowsFieldSuperset(\n\t\t\t\tpolicy,\n\t\t\t\toriginal,\n\t\t\t\toriginal.rootFieldSchema,\n\t\t\t\tsuperset.rootFieldSchema,\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tfor (const [key, schema] of original.nodeSchema) {\n\t\t// TODO: I think its ok to use the tree from superset here, but I should confirm it is, and document why.\n\t\tif (!allowsTreeSuperset(policy, original, schema, superset.nodeSchema.get(key))) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nexport function normalizeField(\n\tschema: TreeFieldStoredSchema | undefined,\n): TreeFieldStoredSchema {\n\treturn schema ?? storedEmptyFieldSchema;\n}\n"]}
1
+ {"version":3,"file":"comparison.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/comparison.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EACN,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EAMtB,sBAAsB,GACtB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e,EACxB,QAAQ,CAAC,eAAe,CACxB,EACA,CAAC;YACF,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;QACjD,yGAAyG;QACzG,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACjF,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,UAAU,cAAc,CAC7B,MAAyC;IAEzC,OAAO,MAAM,IAAI,sBAAsB,CAAC;AACzC,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\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n\ttype ValueSchema,\n\tstoredEmptyFieldSchema,\n} from \"../../core/index.js\";\nimport { compareSets, fail } from \"../../util/index.js\";\n\nimport type { FullSchemaPolicy } from \"./fieldKind.js\";\nimport { withEditor } from \"./fieldKindWithEditor.js\";\nimport { isNeverTree } from \"./isNeverTree.js\";\n\n// TODO:\n// The comparisons in this file seem redundant with those in discrepancies.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 * @returns true iff `superset` is a superset of `original`.\n *\n * This does not require a strict (aka proper) superset: equivalent schema will return true.\n *\n * `undefined` TreeNodeStoredSchema means the schema is not present (and thus treated as a NeverTree).\n */\nexport function allowsTreeSuperset(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\toriginal: TreeNodeStoredSchema | undefined,\n\tsuperset: TreeNodeStoredSchema | undefined,\n): boolean {\n\tif (isNeverTree(policy, originalData, original)) {\n\t\treturn true;\n\t}\n\tif (isNeverTree(policy, originalData, superset)) {\n\t\treturn false;\n\t}\n\tassert(original !== undefined, 0x716 /* only never trees have undefined schema */);\n\tassert(superset !== undefined, 0x717 /* only never trees have undefined schema */);\n\tif (original instanceof LeafNodeStoredSchema) {\n\t\tif (superset instanceof LeafNodeStoredSchema) {\n\t\t\treturn allowsValueSuperset(original.leafValue, superset.leafValue);\n\t\t}\n\t\treturn false;\n\t}\n\n\tif (superset instanceof LeafNodeStoredSchema) {\n\t\treturn false;\n\t}\n\n\tassert(\n\t\toriginal instanceof MapNodeStoredSchema || original instanceof ObjectNodeStoredSchema,\n\t\t0x893 /* unsupported node kind */,\n\t);\n\tassert(\n\t\tsuperset instanceof MapNodeStoredSchema || superset instanceof ObjectNodeStoredSchema,\n\t\t0x894 /* unsupported node kind */,\n\t);\n\n\tif (original instanceof MapNodeStoredSchema) {\n\t\tif (superset instanceof MapNodeStoredSchema) {\n\t\t\treturn allowsFieldSuperset(\n\t\t\t\tpolicy,\n\t\t\t\toriginalData,\n\t\t\t\tnormalizeField(original.mapFields),\n\t\t\t\tnormalizeField(superset.mapFields),\n\t\t\t);\n\t\t}\n\t\treturn false;\n\t}\n\n\tassert(original instanceof ObjectNodeStoredSchema, 0x895 /* unsupported node kind */);\n\tif (superset instanceof MapNodeStoredSchema) {\n\t\tfor (const [_key, field] of original.objectNodeFields) {\n\t\t\tif (\n\t\t\t\t!allowsFieldSuperset(\n\t\t\t\t\tpolicy,\n\t\t\t\t\toriginalData,\n\t\t\t\t\tnormalizeField(field),\n\t\t\t\t\tnormalizeField(superset.mapFields),\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\tassert(superset instanceof ObjectNodeStoredSchema, 0x896 /* unsupported node kind */);\n\n\treturn compareSets({\n\t\ta: original.objectNodeFields,\n\t\tb: superset.objectNodeFields,\n\t\taExtra: (originalField) =>\n\t\t\tallowsFieldSuperset(\n\t\t\t\tpolicy,\n\t\t\t\toriginalData,\n\t\t\t\toriginal.objectNodeFields.get(originalField) ?? fail(\"missing expected field\"),\n\t\t\t\tnormalizeField(undefined),\n\t\t\t),\n\t\tbExtra: (supersetField) =>\n\t\t\tallowsFieldSuperset(\n\t\t\t\tpolicy,\n\t\t\t\toriginalData,\n\t\t\t\tnormalizeField(undefined),\n\t\t\t\tsuperset.objectNodeFields.get(supersetField) ?? fail(\"missing expected field\"),\n\t\t\t),\n\t\tsame: (sameField) =>\n\t\t\tallowsFieldSuperset(\n\t\t\t\tpolicy,\n\t\t\t\toriginalData,\n\t\t\t\toriginal.objectNodeFields.get(sameField) ?? fail(\"missing expected field\"),\n\t\t\t\tsuperset.objectNodeFields.get(sameField) ?? fail(\"missing expected field\"),\n\t\t\t),\n\t});\n}\n\n/**\n * @returns true iff `superset` is a superset of `original`.\n *\n * This does not require a strict (aka proper) superset: equivalent schema will return true.\n */\nexport function allowsValueSuperset(\n\toriginal: ValueSchema | undefined,\n\tsuperset: ValueSchema | undefined,\n): boolean {\n\treturn original === superset;\n}\n\n/**\n * @returns true iff `superset` is a superset of `original`.\n *\n * This does not require a strict (aka proper) superset: equivalent schema will return true.\n */\nexport function allowsFieldSuperset(\n\tpolicy: FullSchemaPolicy,\n\toriginalData: TreeStoredSchema,\n\toriginal: TreeFieldStoredSchema,\n\tsuperset: TreeFieldStoredSchema,\n): boolean {\n\treturn withEditor(\n\t\tpolicy.fieldKinds.get(original.kind) ?? fail(\"missing kind\"),\n\t).allowsFieldSuperset(policy, originalData, original.types, superset);\n}\n\n/**\n * @returns true iff `superset` is a superset of `original`.\n *\n * This does not require a strict (aka proper) superset: equivalent schema will return true.\n */\nexport function allowsTreeSchemaIdentifierSuperset(\n\toriginal: TreeTypeSet,\n\tsuperset: TreeTypeSet,\n): boolean {\n\tfor (const originalType of original) {\n\t\tif (!superset.has(originalType)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * @returns true iff `superset` is a superset of `original`.\n *\n * This does not require a strict (aka proper) superset: equivalent schema will return true.\n *\n * A version of this that assumes a specific root field could be slightly more permissive in some simple cases,\n * however if any extra fields and fields with unconstrained types are reachable,\n * it would have to compare everything anyway.\n */\nexport function allowsRepoSuperset(\n\tpolicy: FullSchemaPolicy,\n\toriginal: TreeStoredSchema,\n\tsuperset: TreeStoredSchema,\n): boolean {\n\t{\n\t\t// TODO: I think its ok to use the field from superset here, but I should confirm it is, and document why.\n\t\tif (\n\t\t\t!allowsFieldSuperset(\n\t\t\t\tpolicy,\n\t\t\t\toriginal,\n\t\t\t\toriginal.rootFieldSchema,\n\t\t\t\tsuperset.rootFieldSchema,\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tfor (const [key, schema] of original.nodeSchema) {\n\t\t// TODO: I think its ok to use the tree from superset here, but I should confirm it is, and document why.\n\t\tif (!allowsTreeSuperset(policy, original, schema, superset.nodeSchema.get(key))) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nexport function normalizeField(\n\tschema: TreeFieldStoredSchema | undefined,\n): TreeFieldStoredSchema {\n\treturn schema ?? storedEmptyFieldSchema;\n}\n"]}
@@ -6,39 +6,39 @@ import { type FieldKindIdentifier, type TreeStoredSchema, type ValueSchema } fro
6
6
  /**
7
7
  * @remarks
8
8
  *
9
- * 1. FieldIncompatibility
9
+ * 1. FieldDiscrepancy
10
10
  *
11
- * `FieldIncompatibility` represents the differences between two `TreeFieldStoredSchema` objects. It consists of
11
+ * `FieldDiscrepancy` represents the differences between two `TreeFieldStoredSchema` objects. It consists of
12
12
  * three types of incompatibilities:
13
13
  *
14
- * - FieldKindIncompatibility: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`
14
+ * - FieldKindDiscrepancy: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`
15
15
  * objects (e.g., optional, required, sequence, etc.).
16
- * - AllowedTypesIncompatibility: Indicates the differences in the allowed child types between the two schemas.
17
- * - ValueSchemaIncompatibility: Specifically indicates the differences in the `ValueSchema` of two
16
+ * - AllowedTypesDiscrepancy: Indicates the differences in the allowed child types between the two schemas.
17
+ * - ValueSchemaDiscrepancy: Specifically indicates the differences in the `ValueSchema` of two
18
18
  * `LeafNodeStoredSchema` objects.
19
19
  *
20
- * 2. NodeIncompatibility
20
+ * 2. NodeDiscrepancy
21
21
  *
22
- * `NodeIncompatibility` represents the differences between two `TreeNodeStoredSchema` objects and includes:
22
+ * `NodeDiscrepancy` represents the differences between two `TreeNodeStoredSchema` objects and includes:
23
23
  *
24
- * - NodeKindIncompatibility: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports
24
+ * - NodeKindDiscrepancy: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports
25
25
  * `ObjectNodeStoredSchema`, `MapNodeStoredSchema`, and `LeafNodeStoredSchema`).
26
- * - NodeFieldsIncompatibility: Indicates the `FieldIncompatibility` of `TreeFieldStoredSchema` within two
27
- * `TreeNodeStoredSchema`. It includes an array of `FieldIncompatibility` instances in the `differences` field.
26
+ * - NodeFieldsDiscrepancy: Indicates the `FieldDiscrepancy` of `TreeFieldStoredSchema` within two
27
+ * `TreeNodeStoredSchema`. It includes an array of `FieldDiscrepancy` instances in the `differences` field.
28
28
  *
29
29
  * When comparing two nodes for compatibility, it only makes sense to compare their fields if the nodes are of
30
30
  * the same kind (map, object, leaf).
31
31
  *
32
- * 3. Incompatibility
32
+ * 3. Discrepancy
33
33
  *
34
- * Incompatibility consists of both `NodeIncompatibility` and `FieldIncompatibility`, representing any kind of
35
- * schema differences. See {@link getAllowedContentIncompatibilities} for more details about how we process it
34
+ * Discrepancy consists of both `NodeDiscrepancy` and `FieldDiscrepancy`, representing any kind of
35
+ * schema differences. See {@link getAllowedContentDiscrepancies} for more details about how we process it
36
36
  * and the ordering.
37
37
  */
38
- export type Incompatibility = FieldIncompatibility | NodeIncompatibility;
39
- export type NodeIncompatibility = NodeKindIncompatibility | NodeFieldsIncompatibility;
40
- export type FieldIncompatibility = AllowedTypeIncompatibility | FieldKindIncompatibility | ValueSchemaIncompatibility;
41
- export interface AllowedTypeIncompatibility {
38
+ export type Discrepancy = FieldDiscrepancy | NodeDiscrepancy;
39
+ export type NodeDiscrepancy = NodeKindDiscrepancy | NodeFieldsDiscrepancy;
40
+ export type FieldDiscrepancy = AllowedTypeDiscrepancy | FieldKindDiscrepancy | ValueSchemaDiscrepancy;
41
+ export interface AllowedTypeDiscrepancy {
42
42
  identifier: string | undefined;
43
43
  mismatch: "allowedTypes";
44
44
  /**
@@ -50,48 +50,48 @@ export interface AllowedTypeIncompatibility {
50
50
  */
51
51
  stored: string[];
52
52
  }
53
- export interface FieldKindIncompatibility {
53
+ export interface FieldKindDiscrepancy {
54
54
  identifier: string | undefined;
55
55
  mismatch: "fieldKind";
56
- view: FieldKindIdentifier | undefined;
57
- stored: FieldKindIdentifier | undefined;
56
+ view: FieldKindIdentifier;
57
+ stored: FieldKindIdentifier;
58
58
  }
59
- export interface ValueSchemaIncompatibility {
59
+ export interface ValueSchemaDiscrepancy {
60
60
  identifier: string;
61
61
  mismatch: "valueSchema";
62
62
  view: ValueSchema | undefined;
63
63
  stored: ValueSchema | undefined;
64
64
  }
65
- export interface NodeKindIncompatibility {
65
+ export interface NodeKindDiscrepancy {
66
66
  identifier: string;
67
67
  mismatch: "nodeKind";
68
68
  view: SchemaFactoryNodeKind | undefined;
69
69
  stored: SchemaFactoryNodeKind | undefined;
70
70
  }
71
- export interface NodeFieldsIncompatibility {
71
+ export interface NodeFieldsDiscrepancy {
72
72
  identifier: string;
73
73
  mismatch: "fields";
74
- differences: FieldIncompatibility[];
74
+ differences: FieldDiscrepancy[];
75
75
  }
76
76
  type SchemaFactoryNodeKind = "object" | "leaf" | "map";
77
77
  /**
78
- * @remarks
78
+ * Finds and reports discrepancies between a view schema and a stored schema.
79
79
  *
80
80
  * The workflow for finding schema incompatibilities:
81
- * 1. Compare the two root schemas to identify any `FieldIncompatibility`.
81
+ * 1. Compare the two root schemas to identify any `FieldDiscrepancy`.
82
82
  *
83
83
  * 2. For each node schema in the `view`:
84
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 `NodeKindIncompatibility`
85
+ * consistent. Otherwise this difference is treated as `NodeKindDiscrepancy`
86
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 `FieldIncompatibility`.
87
+ * are consistent, perform a exhaustive validation to identify all `FieldDiscrepancy`.
88
88
  *
89
89
  * 3. For each node schema in the stored, verify if it exists in the view. The overlapping parts were already
90
90
  * addressed in the previous step.
91
91
  *
92
92
  * @returns the discrepancies between two TreeStoredSchema objects
93
93
  */
94
- export declare function getAllowedContentIncompatibilities(view: TreeStoredSchema, stored: TreeStoredSchema): Incompatibility[];
94
+ export declare function getAllowedContentDiscrepancies(view: TreeStoredSchema, stored: TreeStoredSchema): Discrepancy[];
95
95
  /**
96
96
  * @remarks
97
97
  *
@@ -1 +1 @@
1
- {"version":3,"file":"discrepancies.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/discrepancies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,mBAAmB,EAMxB,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAChB,MAAM,qBAAqB,CAAC;AAM7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,mBAAmB,CAAC;AAEzE,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GAAG,yBAAyB,CAAC;AAEtF,MAAM,MAAM,oBAAoB,GAC7B,0BAA0B,GAC1B,wBAAwB,GACxB,0BAA0B,CAAC;AA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AAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAED,KAAK,qBAAqB,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,8BAA8B,CAC7C,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,gBAAgB,GACtB,WAAW,EAAE,CA4Jf;AAwGD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAkCxF"}
@@ -3,28 +3,29 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { assert } from "@fluidframework/core-utils/internal";
6
- import { LeafNodeStoredSchema, MapNodeStoredSchema, ObjectNodeStoredSchema, } from "../../core/index.js";
6
+ import { LeafNodeStoredSchema, MapNodeStoredSchema, ObjectNodeStoredSchema, storedEmptyFieldSchema, } from "../../core/index.js";
7
+ import { brand } from "../../util/index.js";
7
8
  /**
8
- * @remarks
9
+ * Finds and reports discrepancies between a view schema and a stored schema.
9
10
  *
10
11
  * The workflow for finding schema incompatibilities:
11
- * 1. Compare the two root schemas to identify any `FieldIncompatibility`.
12
+ * 1. Compare the two root schemas to identify any `FieldDiscrepancy`.
12
13
  *
13
14
  * 2. For each node schema in the `view`:
14
15
  * - Verify if the node schema exists in the stored. If it does, ensure that the `SchemaFactoryNodeKind` are
15
- * consistent. Otherwise this difference is treated as `NodeKindIncompatibility`
16
+ * consistent. Otherwise this difference is treated as `NodeKindDiscrepancy`
16
17
  * - If a node schema with the same identifier exists in both view and stored, and their `SchemaFactoryNodeKind`
17
- * are consistent, perform a exhaustive validation to identify all `FieldIncompatibility`.
18
+ * are consistent, perform a exhaustive validation to identify all `FieldDiscrepancy`.
18
19
  *
19
20
  * 3. For each node schema in the stored, verify if it exists in the view. The overlapping parts were already
20
21
  * addressed in the previous step.
21
22
  *
22
23
  * @returns the discrepancies between two TreeStoredSchema objects
23
24
  */
24
- export function getAllowedContentIncompatibilities(view, stored) {
25
- const incompatibilities = [];
25
+ export function getAllowedContentDiscrepancies(view, stored) {
26
+ const discrepancies = [];
26
27
  // check root schema discrepancies
27
- incompatibilities.push(...trackFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema));
28
+ discrepancies.push(...trackFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema));
28
29
  // Verify the existence and type of a node schema given its identifier (key), then determine if
29
30
  // an exhaustive search is necessary.
30
31
  const viewNodeKeys = new Set();
@@ -32,7 +33,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
32
33
  viewNodeKeys.add(key);
33
34
  if (viewNodeSchema instanceof ObjectNodeStoredSchema) {
34
35
  if (!stored.nodeSchema.has(key)) {
35
- incompatibilities.push({
36
+ discrepancies.push({
36
37
  identifier: key,
37
38
  mismatch: "nodeKind",
38
39
  view: "object",
@@ -43,7 +44,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
43
44
  const storedNodeSchema = stored.nodeSchema.get(key);
44
45
  assert(storedNodeSchema !== undefined, 0x9be /* The storedNodeSchema in stored.nodeSchema should not be undefined */);
45
46
  if (storedNodeSchema instanceof MapNodeStoredSchema) {
46
- incompatibilities.push({
47
+ discrepancies.push({
47
48
  identifier: key,
48
49
  mismatch: "nodeKind",
49
50
  view: "object",
@@ -51,7 +52,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
51
52
  });
52
53
  }
53
54
  else if (storedNodeSchema instanceof LeafNodeStoredSchema) {
54
- incompatibilities.push({
55
+ discrepancies.push({
55
56
  identifier: key,
56
57
  mismatch: "nodeKind",
57
58
  view: "object",
@@ -61,7 +62,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
61
62
  else if (storedNodeSchema instanceof ObjectNodeStoredSchema) {
62
63
  const differences = trackObjectNodeDiscrepancies(viewNodeSchema, storedNodeSchema);
63
64
  if (differences.length > 0) {
64
- incompatibilities.push({
65
+ discrepancies.push({
65
66
  identifier: key,
66
67
  mismatch: "fields",
67
68
  differences,
@@ -75,7 +76,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
75
76
  }
76
77
  else if (viewNodeSchema instanceof MapNodeStoredSchema) {
77
78
  if (!stored.nodeSchema.has(key)) {
78
- incompatibilities.push({
79
+ discrepancies.push({
79
80
  identifier: key,
80
81
  mismatch: "nodeKind",
81
82
  view: "map",
@@ -86,7 +87,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
86
87
  const storedNodeSchema = stored.nodeSchema.get(key);
87
88
  assert(storedNodeSchema !== undefined, 0x9bf /* The storedNodeSchema in stored.nodeSchema should not be undefined */);
88
89
  if (storedNodeSchema instanceof ObjectNodeStoredSchema) {
89
- incompatibilities.push({
90
+ discrepancies.push({
90
91
  identifier: key,
91
92
  mismatch: "nodeKind",
92
93
  view: "map",
@@ -94,7 +95,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
94
95
  });
95
96
  }
96
97
  else if (storedNodeSchema instanceof LeafNodeStoredSchema) {
97
- incompatibilities.push({
98
+ discrepancies.push({
98
99
  identifier: key,
99
100
  mismatch: "nodeKind",
100
101
  view: "map",
@@ -102,7 +103,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
102
103
  });
103
104
  }
104
105
  else if (storedNodeSchema instanceof MapNodeStoredSchema) {
105
- incompatibilities.push(...trackFieldDiscrepancies(viewNodeSchema.mapFields, storedNodeSchema.mapFields, key));
106
+ discrepancies.push(...trackFieldDiscrepancies(viewNodeSchema.mapFields, storedNodeSchema.mapFields, key));
106
107
  }
107
108
  else {
108
109
  throwUnsupportedNodeType(storedNodeSchema.constructor.name);
@@ -111,7 +112,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
111
112
  }
112
113
  else if (viewNodeSchema instanceof LeafNodeStoredSchema) {
113
114
  if (!stored.nodeSchema.has(key)) {
114
- incompatibilities.push({
115
+ discrepancies.push({
115
116
  identifier: key,
116
117
  mismatch: "nodeKind",
117
118
  view: "leaf",
@@ -122,7 +123,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
122
123
  const storedNodeSchema = stored.nodeSchema.get(key);
123
124
  assert(storedNodeSchema !== undefined, 0x9c0 /* The storedNodeSchema in stored.nodeSchema should not be undefined */);
124
125
  if (storedNodeSchema instanceof MapNodeStoredSchema) {
125
- incompatibilities.push({
126
+ discrepancies.push({
126
127
  identifier: key,
127
128
  mismatch: "nodeKind",
128
129
  view: "leaf",
@@ -130,7 +131,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
130
131
  });
131
132
  }
132
133
  else if (storedNodeSchema instanceof ObjectNodeStoredSchema) {
133
- incompatibilities.push({
134
+ discrepancies.push({
134
135
  identifier: key,
135
136
  mismatch: "nodeKind",
136
137
  view: "leaf",
@@ -139,7 +140,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
139
140
  }
140
141
  else if (storedNodeSchema instanceof LeafNodeStoredSchema) {
141
142
  if (viewNodeSchema.leafValue !== storedNodeSchema.leafValue) {
142
- incompatibilities.push({
143
+ discrepancies.push({
143
144
  identifier: key,
144
145
  mismatch: "valueSchema",
145
146
  view: viewNodeSchema.leafValue,
@@ -158,7 +159,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
158
159
  }
159
160
  for (const [key, storedNodeSchema] of stored.nodeSchema) {
160
161
  if (!viewNodeKeys.has(key)) {
161
- incompatibilities.push({
162
+ discrepancies.push({
162
163
  identifier: key,
163
164
  mismatch: "nodeKind",
164
165
  view: undefined,
@@ -170,7 +171,7 @@ export function getAllowedContentIncompatibilities(view, stored) {
170
171
  });
171
172
  }
172
173
  }
173
- return incompatibilities;
174
+ return discrepancies;
174
175
  }
175
176
  /**
176
177
  * The function to track the discrepancies between two field stored schemas.
@@ -219,12 +220,13 @@ function trackObjectNodeDiscrepancies(view, stored) {
219
220
  */
220
221
  for (const [fieldKey, fieldStoredSchema] of view.objectNodeFields) {
221
222
  viewFieldKeys.add(fieldKey);
222
- if (!stored.objectNodeFields.has(fieldKey)) {
223
+ if (!stored.objectNodeFields.has(fieldKey) &&
224
+ fieldStoredSchema.kind !== storedEmptyFieldSchema.kind) {
223
225
  differences.push({
224
226
  identifier: fieldKey,
225
227
  mismatch: "fieldKind",
226
228
  view: fieldStoredSchema.kind,
227
- stored: undefined,
229
+ stored: storedEmptyFieldSchema.kind,
228
230
  });
229
231
  }
230
232
  else {
@@ -235,12 +237,14 @@ function trackObjectNodeDiscrepancies(view, stored) {
235
237
  if (viewFieldKeys.has(fieldKey)) {
236
238
  continue;
237
239
  }
238
- differences.push({
239
- identifier: fieldKey,
240
- mismatch: "fieldKind",
241
- view: undefined,
242
- stored: fieldStoredSchema.kind,
243
- });
240
+ if (fieldStoredSchema.kind !== storedEmptyFieldSchema.kind) {
241
+ differences.push({
242
+ identifier: fieldKey,
243
+ mismatch: "fieldKind",
244
+ view: storedEmptyFieldSchema.kind,
245
+ stored: fieldStoredSchema.kind,
246
+ });
247
+ }
244
248
  }
245
249
  return differences;
246
250
  }
@@ -262,22 +266,26 @@ function trackObjectNodeDiscrepancies(view, stored) {
262
266
  * validating internal fields.
263
267
  */
264
268
  export function isRepoSuperset(view, stored) {
265
- const incompatibilities = getAllowedContentIncompatibilities(view, stored);
266
- for (const incompatibility of incompatibilities) {
267
- switch (incompatibility.mismatch) {
269
+ const discrepancies = getAllowedContentDiscrepancies(view, stored);
270
+ for (const discrepancy of discrepancies) {
271
+ switch (discrepancy.mismatch) {
268
272
  case "nodeKind": {
269
- return false;
273
+ if (discrepancy.stored !== undefined) {
274
+ // It's fine for the view schema to know of a node type that the stored schema doesn't know about.
275
+ return false;
276
+ }
277
+ break;
270
278
  }
271
279
  case "valueSchema":
272
280
  case "allowedTypes":
273
281
  case "fieldKind": {
274
- if (!validateFieldIncompatibility(incompatibility)) {
282
+ if (!validateFieldIncompatibility(discrepancy)) {
275
283
  return false;
276
284
  }
277
285
  break;
278
286
  }
279
287
  case "fields": {
280
- if (incompatibility.differences.some((difference) => !validateFieldIncompatibility(difference))) {
288
+ if (discrepancy.differences.some((difference) => !validateFieldIncompatibility(difference))) {
281
289
  return false;
282
290
  }
283
291
  break;
@@ -287,26 +295,16 @@ export function isRepoSuperset(view, stored) {
287
295
  }
288
296
  return true;
289
297
  }
290
- function validateFieldIncompatibility(incompatibility) {
291
- switch (incompatibility.mismatch) {
298
+ function validateFieldIncompatibility(discrepancy) {
299
+ switch (discrepancy.mismatch) {
292
300
  case "allowedTypes": {
293
301
  // Since we only track the symmetric difference between the allowed types in the view and
294
302
  // stored schemas, it's sufficient to check if any extra allowed types still exist in the
295
303
  // stored schema.
296
- return incompatibility.stored.length === 0;
304
+ return discrepancy.stored.length === 0;
297
305
  }
298
306
  case "fieldKind": {
299
- if (incompatibility.stored === undefined) {
300
- // Add an optional field
301
- if (incompatibility.view === "Optional") {
302
- return true;
303
- }
304
- }
305
- else {
306
- // Relax the field to make it more general
307
- return compareFieldKind(incompatibility.stored, incompatibility.view);
308
- }
309
- break;
307
+ return posetLte(discrepancy.stored, discrepancy.view, fieldRealizer);
310
308
  }
311
309
  case "valueSchema": {
312
310
  return false;
@@ -316,35 +314,83 @@ function validateFieldIncompatibility(incompatibility) {
316
314
  return false;
317
315
  }
318
316
  /**
319
- * A mapping that defines the order of field kinds for comparison purposes.
320
- * The numeric values indicate the hierarchy or "strength" of each field kind, where lower numbers are more restrictive.
321
- * This is used to determine if one field kind can be considered a superset of another.
322
- *
323
- * - "Forbidden": The most restrictive, represented by 1. Indicates a forbidden field.
324
- * - "Value": Represented by 2. Indicates a required field with a specific value.
325
- * - "Optional": Represented by 3. Indicates an optional field.
317
+ * @privateRemarks
318
+ * TODO: Knowledge of specific field kinds is not appropriate for modular schema.
319
+ * This bit of field comparison should be dependency injected by default-schema if this comparison logic remains in modular-schema
320
+ * (this is analogous to what is done in comparison.ts).
321
+ */
322
+ const FieldKindIdentifiers = {
323
+ forbidden: brand("Forbidden"),
324
+ required: brand("Value"),
325
+ identifier: brand("Identifier"),
326
+ optional: brand("Optional"),
327
+ sequence: brand("Sequence"),
328
+ };
329
+ /**
330
+ * A realizer for the partial order of field kind relaxability.
326
331
  *
327
- * Note:
328
- * - "Sequence": (Currently commented out) was intended to represent a sequence field kind with a value of 4.
329
- * Relaxing non-sequence fields to sequences is not currently supported but may be considered in the future.
332
+ * It seems extremely likely that this partial order will remain dimension 2 over time (i.e. the set of allowed relaxations can be visualized
333
+ * with a [dominance drawing](https://en.wikipedia.org/wiki/Dominance_drawing)), so this strategy allows efficient comarison between field kinds
334
+ * without excessive casework.
330
335
  *
331
- * TODO: We may need more coverage in realm to prove the correctness of the Forbidden -\> Value transaction
336
+ * Hasse diagram for the partial order is shown below (lower fields can be relaxed to higher fields):
337
+ * ```
338
+ * sequence
339
+ * |
340
+ * optional
341
+ * | \
342
+ * required forbidden
343
+ * |
344
+ * identifier
345
+ * ```
332
346
  */
333
- const fieldKindOrder = {
334
- "Forbidden": 1,
335
- "Value": 2,
336
- "Optional": 3,
337
- // "Sequence": 4, // Relaxing non-sequence fields to sequences is not currently supported, though we could consider doing so in the future.
347
+ const fieldRealizer = [
348
+ [
349
+ FieldKindIdentifiers.forbidden,
350
+ FieldKindIdentifiers.identifier,
351
+ FieldKindIdentifiers.required,
352
+ FieldKindIdentifiers.optional,
353
+ FieldKindIdentifiers.sequence,
354
+ ],
355
+ [
356
+ FieldKindIdentifiers.identifier,
357
+ FieldKindIdentifiers.required,
358
+ FieldKindIdentifiers.forbidden,
359
+ FieldKindIdentifiers.optional,
360
+ FieldKindIdentifiers.sequence,
361
+ ],
362
+ ].map((extension) => new Map(extension.map((identifier, index) => [identifier, index])));
363
+ const PosetComparisonResult = {
364
+ Less: "<",
365
+ Greater: ">",
366
+ Equal: "=",
367
+ Incomparable: "||",
338
368
  };
339
- function compareFieldKind(aKind, bKind) {
340
- if (aKind === undefined || bKind === undefined) {
341
- return false;
342
- }
343
- if (!(aKind in fieldKindOrder) || !(bKind in fieldKindOrder)) {
344
- return false;
369
+ function comparePosetElements(a, b, realizer) {
370
+ let hasLessThanResult = false;
371
+ let hasGreaterThanResult = false;
372
+ for (const extension of realizer) {
373
+ const aIndex = extension.get(a);
374
+ const bIndex = extension.get(b);
375
+ assert(aIndex !== undefined && bIndex !== undefined, "Invalid realizer");
376
+ if (aIndex < bIndex) {
377
+ hasLessThanResult = true;
378
+ }
379
+ else if (aIndex > bIndex) {
380
+ hasGreaterThanResult = true;
381
+ }
345
382
  }
346
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
347
- return fieldKindOrder[aKind] <= fieldKindOrder[bKind];
383
+ return hasLessThanResult
384
+ ? hasGreaterThanResult
385
+ ? PosetComparisonResult.Incomparable
386
+ : PosetComparisonResult.Less
387
+ : hasGreaterThanResult
388
+ ? PosetComparisonResult.Greater
389
+ : PosetComparisonResult.Equal;
390
+ }
391
+ function posetLte(a, b, realizer) {
392
+ const comparison = comparePosetElements(a, b, realizer);
393
+ return (comparison === PosetComparisonResult.Less || comparison === PosetComparisonResult.Equal);
348
394
  }
349
395
  function throwUnsupportedNodeType(type) {
350
396
  throw new TypeError(`Unsupported node stored schema type: ${type}`);